feat: add resume agent MVP

This commit is contained in:
OfferPai
2026-07-20 14:48:41 +08:00
commit 48599bf55b
65 changed files with 10988 additions and 0 deletions
+63
View File
@@ -0,0 +1,63 @@
from __future__ import annotations
from typing import Any
def strict_phone(value: str) -> bool:
return (
len(value) == 11
and value.isascii()
and value.isdigit()
and value[0] == "1"
and value[1] in "3456789"
)
def mask_phone(value: Any) -> str | None:
if not isinstance(value, str) or len(value) != 11:
return None
return f"{value[:3]}****{value[-4:]}"
def valid_month(value: Any) -> bool:
if not isinstance(value, str) or len(value) != 7 or value[4] != "-":
return False
year, month = value.split("-", 1)
return (
year.isdigit()
and month.isdigit()
and 1900 <= int(year) <= 2100
and 1 <= int(month) <= 12
)
def anchor_missing_fields(
profile: dict[str, Any], required: list[str]
) -> list[str]:
anchor = profile.get("anchor", {})
missing = [field for field in required if not _present(anchor.get(field))]
start = anchor.get("start_date")
end = anchor.get("end_date_or_present")
if start and not valid_month(start) and "start_date" not in missing:
missing.append("start_date")
if end and end != "present" and not valid_month(end) and "end_date_or_present" not in missing:
missing.append("end_date_or_present")
if valid_month(start) and valid_month(end) and end < start and "end_date_or_present" not in missing:
missing.append("end_date_or_present")
return missing
def can_create_resume(profile: dict[str, Any], missing: list[str]) -> bool:
return bool(
profile.get("privacy_accepted")
and strict_phone(str(profile.get("phone") or ""))
and str(profile.get("name") or "").strip()
and profile.get("job_type") in {"campus", "social", "other"}
and profile.get("anchor_type")
and profile.get("anchor_confirmed")
and not missing
)
def _present(value: Any) -> bool:
return bool(value.strip()) if isinstance(value, str) else value is not None