Skip to content

Commit de7d9bc

Browse files
author
SentienceDEV
committed
P6: passthrough fields for captcha detection
1 parent 00009b9 commit de7d9bc

File tree

2 files changed

+26
-1
lines changed

2 files changed

+26
-1
lines changed

sentience/models.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -290,12 +290,29 @@ class SnapshotDiagnosticsMetrics(BaseModel):
290290
raw_elements_count: int | None = None
291291

292292

293+
class CaptchaEvidence(BaseModel):
294+
text_hits: list[str] = Field(default_factory=list)
295+
selector_hits: list[str] = Field(default_factory=list)
296+
iframe_src_hits: list[str] = Field(default_factory=list)
297+
url_hits: list[str] = Field(default_factory=list)
298+
299+
300+
class CaptchaDiagnostics(BaseModel):
301+
"""Detection-only CAPTCHA signal (no solving/bypass)."""
302+
303+
detected: bool = False
304+
provider_hint: str | None = None
305+
confidence: float = 0.0
306+
evidence: CaptchaEvidence = Field(default_factory=CaptchaEvidence)
307+
308+
293309
class SnapshotDiagnostics(BaseModel):
294310
"""Runtime stability/debug information (reserved for diagnostics, not ML metadata)."""
295311

296312
confidence: float | None = None
297-
reasons: list[str] = []
313+
reasons: list[str] = Field(default_factory=list)
298314
metrics: SnapshotDiagnosticsMetrics | None = None
315+
captcha: CaptchaDiagnostics | None = None
299316

300317
def get_grid_bounds(self, grid_id: int | None = None) -> list[GridInfo]:
301318
"""

sentience/snapshot.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,17 @@ def _build_snapshot_payload(
103103
"""
104104
diagnostics = raw_result.get("diagnostics") or {}
105105
client_metrics = None
106+
client_diagnostics = None
106107
try:
107108
client_metrics = diagnostics.get("metrics")
108109
except Exception:
109110
client_metrics = None
111+
try:
112+
captcha = diagnostics.get("captcha")
113+
if captcha is not None:
114+
client_diagnostics = {"captcha": captcha}
115+
except Exception:
116+
client_diagnostics = None
110117

111118
return {
112119
"raw_elements": raw_result.get("raw_elements", []),
@@ -118,6 +125,7 @@ def _build_snapshot_payload(
118125
"filter": options.filter.model_dump() if options.filter else None,
119126
},
120127
"client_metrics": client_metrics,
128+
"client_diagnostics": client_diagnostics,
121129
}
122130

123131

0 commit comments

Comments
 (0)