job-apply-cli 0.2.0__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- job_apply_agent/__init__.py +3 -0
- job_apply_agent/api.py +340 -0
- job_apply_agent/ats/__init__.py +12 -0
- job_apply_agent/ats/answer_binding.py +308 -0
- job_apply_agent/ats/base.py +64 -0
- job_apply_agent/ats/captcha.py +76 -0
- job_apply_agent/ats/codex_planner.py +174 -0
- job_apply_agent/ats/cua_harness.py +846 -0
- job_apply_agent/ats/dom_browser.py +275 -0
- job_apply_agent/ats/form_preparation.py +452 -0
- job_apply_agent/ats/hybrid_harness.py +379 -0
- job_apply_agent/ats/lcu_bridge.mjs +94 -0
- job_apply_agent/ats/lcu_harness.py +226 -0
- job_apply_agent/ats/lcu_worker.sh +12 -0
- job_apply_agent/ats/page_readiness.py +119 -0
- job_apply_agent/ats/playwright_adapter.py +561 -0
- job_apply_agent/cli.py +108 -0
- job_apply_agent/collectors/__init__.py +7 -0
- job_apply_agent/collectors/ashby.py +64 -0
- job_apply_agent/collectors/base.py +75 -0
- job_apply_agent/collectors/greenhouse.py +50 -0
- job_apply_agent/collectors/job_link.py +471 -0
- job_apply_agent/collectors/lever.py +42 -0
- job_apply_agent/collectors/normalizer.py +156 -0
- job_apply_agent/config.py +190 -0
- job_apply_agent/db.py +40 -0
- job_apply_agent/domain/__init__.py +11 -0
- job_apply_agent/domain/enums.py +50 -0
- job_apply_agent/domain/schemas.py +173 -0
- job_apply_agent/examples/__init__.py +1 -0
- job_apply_agent/examples/answer-bank.json +7 -0
- job_apply_agent/examples/experiences.json +8 -0
- job_apply_agent/examples/profile.json +24 -0
- job_apply_agent/examples/search-policy.json +15 -0
- job_apply_agent/examples/source-boards.json +10 -0
- job_apply_agent/experience/__init__.py +1 -0
- job_apply_agent/experience/benchmark.py +199 -0
- job_apply_agent/experience/library.py +140 -0
- job_apply_agent/experience/reasoning.py +240 -0
- job_apply_agent/experience/retrieval.py +221 -0
- job_apply_agent/managed_apply.py +104 -0
- job_apply_agent/managed_backlog.py +410 -0
- job_apply_agent/models.py +133 -0
- job_apply_agent/onboarding.py +152 -0
- job_apply_agent/repository.py +54 -0
- job_apply_agent/resume/__init__.py +3 -0
- job_apply_agent/resume/composer.py +121 -0
- job_apply_agent/scheduler.py +115 -0
- job_apply_agent/services/__init__.py +18 -0
- job_apply_agent/services/answer_derivation.py +59 -0
- job_apply_agent/services/answers.py +71 -0
- job_apply_agent/services/application_report.py +144 -0
- job_apply_agent/services/artifacts.py +38 -0
- job_apply_agent/services/codex_narratives.py +64 -0
- job_apply_agent/services/facts.py +57 -0
- job_apply_agent/services/model_errors.py +93 -0
- job_apply_agent/services/narratives.py +278 -0
- job_apply_agent/services/orchestrator.py +149 -0
- job_apply_agent/services/policy.py +173 -0
- job_apply_agent/services/quota.py +88 -0
- job_apply_agent/services/resumes.py +86 -0
- job_apply_agent/services/review_actions.py +120 -0
- job_apply_agent/tasks.py +775 -0
- job_apply_agent/telegram/__init__.py +1 -0
- job_apply_agent/telegram/experiences.py +105 -0
- job_apply_agent/telegram/review.py +494 -0
- job_apply_cli-0.2.0.dist-info/METADATA +330 -0
- job_apply_cli-0.2.0.dist-info/RECORD +71 -0
- job_apply_cli-0.2.0.dist-info/WHEEL +4 -0
- job_apply_cli-0.2.0.dist-info/entry_points.txt +3 -0
- job_apply_cli-0.2.0.dist-info/licenses/LICENSE +201 -0
|
@@ -0,0 +1,64 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
from abc import ABC, abstractmethod
|
|
4
|
+
from dataclasses import dataclass, field
|
|
5
|
+
from pathlib import Path
|
|
6
|
+
from typing import Any, Protocol
|
|
7
|
+
|
|
8
|
+
from job_apply_agent.domain.enums import BlockerKind
|
|
9
|
+
from job_apply_agent.domain.schemas import FormQuestion, ResolvedAnswer
|
|
10
|
+
|
|
11
|
+
|
|
12
|
+
class ATSBlocked(RuntimeError):
|
|
13
|
+
def __init__(
|
|
14
|
+
self,
|
|
15
|
+
kind: BlockerKind,
|
|
16
|
+
detail: str,
|
|
17
|
+
*,
|
|
18
|
+
evidence: dict[str, Any] | None = None,
|
|
19
|
+
) -> None:
|
|
20
|
+
super().__init__(detail)
|
|
21
|
+
self.kind = kind
|
|
22
|
+
self.detail = detail
|
|
23
|
+
self.evidence = evidence or {}
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@dataclass
|
|
27
|
+
class InspectionResult:
|
|
28
|
+
questions: list[FormQuestion]
|
|
29
|
+
blocker: BlockerKind | None = None
|
|
30
|
+
blocker_detail: str | None = None
|
|
31
|
+
|
|
32
|
+
|
|
33
|
+
@dataclass
|
|
34
|
+
class ApplicationResult:
|
|
35
|
+
submitted: bool
|
|
36
|
+
receipt: dict[str, Any] = field(default_factory=dict)
|
|
37
|
+
blocker: BlockerKind | None = None
|
|
38
|
+
|
|
39
|
+
|
|
40
|
+
class SubmissionClaim(Protocol):
|
|
41
|
+
def claim(self) -> bool: ...
|
|
42
|
+
|
|
43
|
+
def complete(self, receipt: dict[str, Any]) -> None: ...
|
|
44
|
+
|
|
45
|
+
|
|
46
|
+
class ATSAdapter(ABC):
|
|
47
|
+
@abstractmethod
|
|
48
|
+
async def inspect(self, page: Any) -> InspectionResult: ...
|
|
49
|
+
|
|
50
|
+
@abstractmethod
|
|
51
|
+
async def fill(
|
|
52
|
+
self,
|
|
53
|
+
page: Any,
|
|
54
|
+
answers: list[ResolvedAnswer],
|
|
55
|
+
*,
|
|
56
|
+
resume_path: Path,
|
|
57
|
+
cover_letter_path: Path | None = None,
|
|
58
|
+
) -> None: ...
|
|
59
|
+
|
|
60
|
+
@abstractmethod
|
|
61
|
+
async def verify(self, page: Any) -> list[str]: ...
|
|
62
|
+
|
|
63
|
+
@abstractmethod
|
|
64
|
+
async def submit(self, page: Any, claim: SubmissionClaim) -> ApplicationResult: ...
|
|
@@ -0,0 +1,76 @@
|
|
|
1
|
+
"""Read-only CAPTCHA evidence: passive badges do not prove an active challenge."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
from typing import Any
|
|
6
|
+
from urllib.parse import urlparse
|
|
7
|
+
|
|
8
|
+
from playwright.async_api import Error
|
|
9
|
+
|
|
10
|
+
CAPTCHA_EVIDENCE_JS = r"""() => {
|
|
11
|
+
const selector = 'iframe[src*="captcha" i],iframe[src*="challenges.cloudflare.com" i],'
|
|
12
|
+
+ '.g-recaptcha,.h-captcha,.cf-turnstile,[data-sitekey],.grecaptcha-badge,.hcaptcha-overlay-badge';
|
|
13
|
+
return [...document.querySelectorAll(selector)].map(el => {
|
|
14
|
+
const rect = el.getBoundingClientRect();
|
|
15
|
+
const visible = rect.width > 0 && rect.height > 0 &&
|
|
16
|
+
![el, ...function*(n){while(n.parentElement){n=n.parentElement;yield n;}}(el)]
|
|
17
|
+
.some(n => ['hidden','collapse'].includes(getComputedStyle(n).visibility)
|
|
18
|
+
|| getComputedStyle(n).display === 'none');
|
|
19
|
+
const src = el.getAttribute('src') || '';
|
|
20
|
+
const url = new URL(src || location.href, location.href);
|
|
21
|
+
const title = (el.getAttribute('title') || '').toLowerCase();
|
|
22
|
+
const challenge = el.tagName === 'IFRAME' &&
|
|
23
|
+
(/\/bframe(?:[/?]|$)/i.test(url.pathname) || /(?:[?#&])frame=challenge(?:&|$)/i.test(src)
|
|
24
|
+
|| /challenge/.test(title) && !/cloudflare/.test(url.hostname));
|
|
25
|
+
const invisible = el.getAttribute('data-size') === 'invisible'
|
|
26
|
+
|| /(?:[?#&])size=invisible(?:&|$)/i.test(src);
|
|
27
|
+
const badge = !!el.closest('.grecaptcha-badge,.hcaptcha-overlay-badge');
|
|
28
|
+
// Challenge evidence wins even if the provider was configured as invisible.
|
|
29
|
+
const state = !visible ? 'hidden' : challenge ? 'challenge' :
|
|
30
|
+
badge || invisible ? 'passive' : 'visible_unknown';
|
|
31
|
+
return {state, tag:el.tagName.toLowerCase(), provider_host:src ? url.hostname : '',
|
|
32
|
+
path:src ? url.pathname : '', title, invisible, badge,
|
|
33
|
+
width:Math.round(rect.width), height:Math.round(rect.height)};
|
|
34
|
+
});
|
|
35
|
+
}"""
|
|
36
|
+
|
|
37
|
+
|
|
38
|
+
async def inspect_captcha(page: Any) -> dict:
|
|
39
|
+
"""No token reads, widget interaction, solving or challenge suppression."""
|
|
40
|
+
try:
|
|
41
|
+
return await _inspect_captcha(page)
|
|
42
|
+
except Error as exc:
|
|
43
|
+
if not any(
|
|
44
|
+
message in str(exc)
|
|
45
|
+
for message in (
|
|
46
|
+
"Execution context was destroyed",
|
|
47
|
+
"Frame was detached",
|
|
48
|
+
"frame has been detached",
|
|
49
|
+
)
|
|
50
|
+
):
|
|
51
|
+
raise
|
|
52
|
+
# Navigation may destroy a snapshot between request/response events.
|
|
53
|
+
# Reobserve once after the new DOM; never classify missing evidence as safe.
|
|
54
|
+
await page.wait_for_load_state("domcontentloaded", timeout=10_000)
|
|
55
|
+
return await _inspect_captcha(page)
|
|
56
|
+
|
|
57
|
+
|
|
58
|
+
async def _inspect_captcha(page: Any) -> dict:
|
|
59
|
+
evidence: list[dict[str, Any]] = []
|
|
60
|
+
for index, frame in enumerate(page.frames):
|
|
61
|
+
if frame != page.main_frame:
|
|
62
|
+
# Provider frames are identified from their outer iframe, never operated.
|
|
63
|
+
if urlparse(frame.url).hostname != urlparse(page.url).hostname:
|
|
64
|
+
continue
|
|
65
|
+
handle = await frame.frame_element()
|
|
66
|
+
if not await handle.is_visible():
|
|
67
|
+
continue
|
|
68
|
+
evidence.extend(
|
|
69
|
+
{**item, "frame": index} for item in await frame.evaluate(CAPTCHA_EVIDENCE_JS)
|
|
70
|
+
)
|
|
71
|
+
blocking = any(e["state"] in {"challenge", "visible_unknown"} for e in evidence)
|
|
72
|
+
return {
|
|
73
|
+
"status": "manual_required" if blocking else "passive" if evidence else "absent",
|
|
74
|
+
"blocking": blocking,
|
|
75
|
+
"evidence": evidence,
|
|
76
|
+
}
|
|
@@ -0,0 +1,174 @@
|
|
|
1
|
+
"""Server-local Codex structured decisions; browser effects remain host-owned."""
|
|
2
|
+
|
|
3
|
+
from __future__ import annotations
|
|
4
|
+
|
|
5
|
+
import asyncio
|
|
6
|
+
import json
|
|
7
|
+
import re
|
|
8
|
+
import tempfile
|
|
9
|
+
import time
|
|
10
|
+
from pathlib import Path
|
|
11
|
+
from typing import Any
|
|
12
|
+
|
|
13
|
+
from .cua_harness import UnsafeComputerAction
|
|
14
|
+
|
|
15
|
+
ACTION_SCHEMA: dict[str, Any] = {
|
|
16
|
+
"type": "object",
|
|
17
|
+
"additionalProperties": False,
|
|
18
|
+
"properties": {
|
|
19
|
+
"action": {
|
|
20
|
+
"type": "string",
|
|
21
|
+
"enum": ["click", "fill", "select", "check", "uncheck", "scroll", "finish", "stop"],
|
|
22
|
+
},
|
|
23
|
+
"ref": {"type": ["string", "null"]},
|
|
24
|
+
"value": {"type": ["string", "null"]},
|
|
25
|
+
"reason": {"type": ["string", "null"]},
|
|
26
|
+
},
|
|
27
|
+
"required": ["action", "ref", "value", "reason"],
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
class CodexCLIPlanner:
|
|
32
|
+
def __init__(self, *, binary: str, model: str, timeout_seconds: int = 120) -> None:
|
|
33
|
+
self.binary, self.model, self.timeout_seconds = binary, model, timeout_seconds
|
|
34
|
+
self.observed_model: str | None = None
|
|
35
|
+
self.calls = 0
|
|
36
|
+
self.telemetry: list[dict[str, Any]] = []
|
|
37
|
+
|
|
38
|
+
async def check_ready(self) -> None:
|
|
39
|
+
try:
|
|
40
|
+
process = await asyncio.create_subprocess_exec(
|
|
41
|
+
self.binary,
|
|
42
|
+
"login",
|
|
43
|
+
"status",
|
|
44
|
+
stdout=asyncio.subprocess.DEVNULL,
|
|
45
|
+
stderr=asyncio.subprocess.DEVNULL,
|
|
46
|
+
)
|
|
47
|
+
except OSError as exc:
|
|
48
|
+
raise UnsafeComputerAction("Codex CLI is not installed or executable") from exc
|
|
49
|
+
try:
|
|
50
|
+
await asyncio.wait_for(process.wait(), timeout=15)
|
|
51
|
+
except BaseException as exc:
|
|
52
|
+
if process.returncode is None:
|
|
53
|
+
process.kill()
|
|
54
|
+
await process.wait()
|
|
55
|
+
if isinstance(exc, TimeoutError):
|
|
56
|
+
raise UnsafeComputerAction("Codex login status timed out") from exc
|
|
57
|
+
raise
|
|
58
|
+
if process.returncode:
|
|
59
|
+
raise UnsafeComputerAction("Codex CLI is not signed in in this runtime")
|
|
60
|
+
|
|
61
|
+
async def request_json(
|
|
62
|
+
self, prompt: str, schema: dict[str, Any], screenshot_path: Path | None = None
|
|
63
|
+
) -> dict[str, Any]:
|
|
64
|
+
with tempfile.TemporaryDirectory(prefix="job-codex-") as temporary:
|
|
65
|
+
root = Path(temporary)
|
|
66
|
+
schema_path, output_path = root / "schema.json", root / "answer.json"
|
|
67
|
+
schema_path.write_text(json.dumps(schema))
|
|
68
|
+
command = [
|
|
69
|
+
self.binary,
|
|
70
|
+
"exec",
|
|
71
|
+
"--ephemeral",
|
|
72
|
+
"--json",
|
|
73
|
+
"--ignore-user-config",
|
|
74
|
+
"--skip-git-repo-check",
|
|
75
|
+
"--sandbox",
|
|
76
|
+
"read-only",
|
|
77
|
+
"--output-schema",
|
|
78
|
+
str(schema_path),
|
|
79
|
+
"--output-last-message",
|
|
80
|
+
str(output_path),
|
|
81
|
+
]
|
|
82
|
+
if self.model:
|
|
83
|
+
command += ["--model", self.model]
|
|
84
|
+
if screenshot_path is not None:
|
|
85
|
+
command += ["--image", str(screenshot_path)]
|
|
86
|
+
command += ["-"]
|
|
87
|
+
self.calls += 1
|
|
88
|
+
started = time.perf_counter()
|
|
89
|
+
try:
|
|
90
|
+
process = await asyncio.create_subprocess_exec(
|
|
91
|
+
*command,
|
|
92
|
+
cwd=root,
|
|
93
|
+
stdin=asyncio.subprocess.PIPE,
|
|
94
|
+
stdout=asyncio.subprocess.PIPE,
|
|
95
|
+
stderr=asyncio.subprocess.PIPE,
|
|
96
|
+
)
|
|
97
|
+
except OSError as exc:
|
|
98
|
+
raise UnsafeComputerAction("Codex CLI is not installed or executable") from exc
|
|
99
|
+
try:
|
|
100
|
+
stdout, stderr = await asyncio.wait_for(
|
|
101
|
+
process.communicate(prompt.encode()), timeout=self.timeout_seconds
|
|
102
|
+
)
|
|
103
|
+
except BaseException as exc:
|
|
104
|
+
if process.returncode is None:
|
|
105
|
+
process.kill()
|
|
106
|
+
await process.wait()
|
|
107
|
+
self.telemetry.append(
|
|
108
|
+
{
|
|
109
|
+
"elapsed_seconds": time.perf_counter() - started,
|
|
110
|
+
"usage": None,
|
|
111
|
+
"exit_code": process.returncode,
|
|
112
|
+
"error_type": type(exc).__name__,
|
|
113
|
+
}
|
|
114
|
+
)
|
|
115
|
+
if isinstance(exc, TimeoutError):
|
|
116
|
+
raise UnsafeComputerAction("Codex planner timed out") from exc
|
|
117
|
+
raise
|
|
118
|
+
usage = []
|
|
119
|
+
unexpected_tools = False
|
|
120
|
+
for line in (stdout or b"").splitlines():
|
|
121
|
+
try:
|
|
122
|
+
event = json.loads(line)
|
|
123
|
+
except (ValueError, TypeError):
|
|
124
|
+
continue
|
|
125
|
+
if not isinstance(event, dict):
|
|
126
|
+
continue
|
|
127
|
+
if event.get("type") == "turn.completed" and isinstance(event.get("usage"), dict):
|
|
128
|
+
usage.append(
|
|
129
|
+
{
|
|
130
|
+
k: v
|
|
131
|
+
for k, v in event["usage"].items()
|
|
132
|
+
if k.endswith("tokens") and isinstance(v, int) and v >= 0
|
|
133
|
+
}
|
|
134
|
+
)
|
|
135
|
+
item = event.get("item") or {}
|
|
136
|
+
if item.get("type") in {
|
|
137
|
+
"command_execution",
|
|
138
|
+
"mcp_tool_call",
|
|
139
|
+
"web_search",
|
|
140
|
+
"file_change",
|
|
141
|
+
}:
|
|
142
|
+
unexpected_tools = True
|
|
143
|
+
self.telemetry.append(
|
|
144
|
+
{
|
|
145
|
+
"elapsed_seconds": time.perf_counter() - started,
|
|
146
|
+
"usage": usage or None,
|
|
147
|
+
"exit_code": process.returncode,
|
|
148
|
+
"unexpected_tools": unexpected_tools,
|
|
149
|
+
}
|
|
150
|
+
)
|
|
151
|
+
if unexpected_tools:
|
|
152
|
+
raise UnsafeComputerAction("Codex decision unexpectedly used a tool")
|
|
153
|
+
matched = re.search(r"(?m)^model:\s*(\S+)", stderr.decode(errors="replace"))
|
|
154
|
+
if matched:
|
|
155
|
+
self.observed_model = matched.group(1)
|
|
156
|
+
if process.returncode or not output_path.is_file():
|
|
157
|
+
# CLI stderr can contain the entire candidate prompt or credentials.
|
|
158
|
+
raise UnsafeComputerAction(f"Codex planner failed (exit={process.returncode})")
|
|
159
|
+
try:
|
|
160
|
+
result = json.loads(output_path.read_text())
|
|
161
|
+
except (ValueError, OSError) as exc:
|
|
162
|
+
raise UnsafeComputerAction("Codex planner returned invalid JSON") from exc
|
|
163
|
+
if not isinstance(result, dict):
|
|
164
|
+
raise UnsafeComputerAction("Codex planner returned a non-object")
|
|
165
|
+
return result
|
|
166
|
+
|
|
167
|
+
async def next_action(self, prompt: str, screenshot_path: Path) -> dict[str, Any]:
|
|
168
|
+
action = await self.request_json(prompt, ACTION_SCHEMA, screenshot_path)
|
|
169
|
+
if action.get("action") not in ACTION_SCHEMA["properties"]["action"]["enum"]:
|
|
170
|
+
raise UnsafeComputerAction("Codex returned an unsupported action")
|
|
171
|
+
return action
|
|
172
|
+
|
|
173
|
+
async def close(self) -> None:
|
|
174
|
+
pass
|