captchakraken 4.2.0 → 5.0.0-beta.41
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.
- package/README.md +0 -1
- package/dist/index.d.ts +1 -1
- package/dist/kinds.d.ts +1 -0
- package/dist/kinds.js +1 -0
- package/dist/playwright-types.d.ts +2 -0
- package/dist/selectors.d.ts +19 -10
- package/dist/selectors.js +7 -18
- package/dist/solver.d.ts +42 -3
- package/dist/solver.js +162 -38
- package/package.json +2 -2
- package/python/AGENTS.md +5 -4
- package/python/README.md +3 -6
- package/python/pyproject.toml +6 -9
- package/python/src/captchakraken/__init__.py +1 -1
- package/python/src/captchakraken/captchakraken.config.json +35 -8
- package/python/src/captchakraken/cli.py +2 -47
- package/python/src/captchakraken/config.py +0 -4
- package/python/src/captchakraken/kinds.py +1 -0
- package/python/src/captchakraken/models.json +15 -14
- package/python/src/captchakraken/page_solver.py +138 -39
- package/python/src/captchakraken/pointer/__init__.py +7 -9
- package/python/src/captchakraken/pointer/elements.py +1 -1
- package/python/src/captchakraken/pointer/server.py +13 -17
- package/python/src/captchakraken/pointer/service.py +35 -324
- package/python/src/captchakraken/prompts.py +3 -4
- package/python/src/captchakraken/selectors.py +15 -16
- package/python/src/captchakraken/selfhost.py +9 -16
- package/python/src/captchakraken/server_manager.py +0 -4
- package/python/src/captchakraken/solver.py +4 -25
- package/python/src/captchakraken/tool_calls/find_checkbox.py +150 -13
- package/python/src/captchakraken/tool_calls/find_grid.py +6 -132
- package/python/src/captchakraken/updater.py +57 -27
- package/python/src/captchakraken/pointer/detector.py +0 -333
package/python/pyproject.toml
CHANGED
|
@@ -4,8 +4,8 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "captchakraken"
|
|
7
|
-
version = "
|
|
8
|
-
description = "Captcha-solving engine and CLI: a v2 pointer model
|
|
7
|
+
version = "5.0.0b41"
|
|
8
|
+
description = "Captcha-solving engine and CLI: a v2 pointer model for image grids, click and drag puzzles, sliders, distorted text and animated challenges. Hosted API or self-hosted on vLLM."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
11
11
|
license = { file = "LICENSE" }
|
|
@@ -53,13 +53,8 @@ dependencies = [
|
|
|
53
53
|
# 2.3.x rather than 2.2.6 because `cursory` requires `numpy~=2.3.3` and the
|
|
54
54
|
# old pin was ours. Moved deliberately as part of the major bump.
|
|
55
55
|
"numpy==2.3.5",
|
|
56
|
-
#
|
|
57
|
-
#
|
|
58
|
-
# silicon macOS; there is NO Intel-macOS wheel, so the client does not
|
|
59
|
-
# install there. Weights are fetched at first use, not shipped (detector.py).
|
|
60
|
-
"onnxruntime==1.31.1",
|
|
61
|
-
# The slide and hold trackers' image arithmetic: smoothing, morphology,
|
|
62
|
-
# labelling, distance transforms and FFT correlation. 1.17.1 is the newest
|
|
56
|
+
# The slide and hold trackers' and the tick-box finder's image arithmetic:
|
|
57
|
+
# smoothing, morphology, labelling, distance transforms and FFT correlation. 1.17.1 is the newest
|
|
63
58
|
# release whose Requires-Python (>=3.11) covers the floor; 1.18 needs 3.12.
|
|
64
59
|
"scipy==1.17.1",
|
|
65
60
|
# Decodes the first frame of a video passed to `solve` (.mp4, .avi, .webm).
|
|
@@ -89,6 +84,8 @@ serve = [
|
|
|
89
84
|
"huggingface_hub==1.30.0",
|
|
90
85
|
]
|
|
91
86
|
dev = [
|
|
87
|
+
# The licensed-model fetch tests raise the Hub's own refusal types.
|
|
88
|
+
"huggingface_hub==1.30.0",
|
|
92
89
|
"pytest==9.1.1",
|
|
93
90
|
"pytest-cov==7.1.0",
|
|
94
91
|
"mypy==2.3.1",
|
|
@@ -14,13 +14,6 @@
|
|
|
14
14
|
"submit, text box, refresh and slider controls are tried before the generic",
|
|
15
15
|
"ones. It must name a `widget`, `challenge` or `checkbox`; `hosts` is optional.",
|
|
16
16
|
"",
|
|
17
|
-
"detector: the element detector that finds grids, tick boxes and pieces on the",
|
|
18
|
-
"CPU before any model is asked. `standard` (ResNet-18, 124 MB), `lite`",
|
|
19
|
-
"(MobileNetV3, 24 MB, ~6x faster on one CPU) or `auto`: lite on two usable",
|
|
20
|
-
"CPUs or fewer, and above that standard only when a one-off timing predicts",
|
|
21
|
-
"it inside 200 ms a board. Only the chosen model is downloaded.",
|
|
22
|
-
"CAPTCHA_KRAKEN_DETECTOR_MODEL overrides this.",
|
|
23
|
-
"",
|
|
24
17
|
"vendors: one entry per vendor, in detection order. Order matters: the driver",
|
|
25
18
|
"takes the first visible match in table order. `hosts` are URL substrings of",
|
|
26
19
|
"the vendor's code on the wire; every other field is a list of CSS (or",
|
|
@@ -45,17 +38,19 @@
|
|
|
45
38
|
"accepted": "On the host page: the vendor painted its success state. Visibility is part of the test (see TRIBAL_KNOWLEDGE.md).",
|
|
46
39
|
"fresh": "Inside the challenge frame: a new round has painted, with text.",
|
|
47
40
|
"images": "Inside the challenge frame: the pictures a board is made of; the driver waits for each to have painted.",
|
|
41
|
+
"tiles": "Inside the challenge frame: the tiles of the board's grid, in reading order. Where each one is placed is read from the DOM, to click it and to watch it reload.",
|
|
48
42
|
"submit": "Inside the widget: the vendor's own submit control, tried after the generic text probes.",
|
|
49
43
|
"banners": "Inside the challenge frame: verdict banners and what each means.",
|
|
50
44
|
"blocked": "Inside the challenge frame: the vendor refusing to serve this client at all. Nothing after it can succeed.",
|
|
51
45
|
"passive": "On the host page: the vendor's frames that are never interactive, so a page showing only these has no widget.",
|
|
52
46
|
"text_input": "Inside the widget, and its enclosing fieldset/form: the answer box of a typed captcha.",
|
|
53
47
|
"slider_handle": "Inside the widget: the knob a slide must start on; a drag from the piece moves nothing.",
|
|
48
|
+
"board": "Inside the widget's frame or a frame nested in it: the element that is the board itself, when the widget frame pads it. The shot is this element, so the model sees the crop it was trained on.",
|
|
49
|
+
"bar": "Beside the widget (a sibling of it, or of its parent): a strip the vendor draws outside the widget element that every board carries, such as Yidun's prompt and slider bar. The shot takes it in, so the model sees what it was trained on.",
|
|
54
50
|
"piece": "Inside the widget: the piece, measured to steer the slide and dragged directly when there is no track.",
|
|
55
51
|
"refresh": "Inside the widget: the control that deals a new puzzle, pressed when the model answers `refresh`.",
|
|
56
52
|
"hold_completes": "A press-and-hold that completes on its own once full, and resets when let go before it has: the fill reaching the answer's `to` is not a release, and the hold lasts until the widget says it is done."
|
|
57
53
|
},
|
|
58
|
-
"detector": "auto",
|
|
59
54
|
"custom": null,
|
|
60
55
|
"vendors": {
|
|
61
56
|
"recaptcha": {
|
|
@@ -78,6 +73,9 @@
|
|
|
78
73
|
"#recaptcha-anchor"
|
|
79
74
|
],
|
|
80
75
|
"fresh": ".rc-imageselect-instructions, #rc-imageselect",
|
|
76
|
+
"tiles": [
|
|
77
|
+
"td.rc-imageselect-tile"
|
|
78
|
+
],
|
|
81
79
|
"submit": [
|
|
82
80
|
"#recaptcha-verify-button"
|
|
83
81
|
],
|
|
@@ -228,6 +226,9 @@
|
|
|
228
226
|
".yidun_slider",
|
|
229
227
|
".yidun_jigsaw"
|
|
230
228
|
],
|
|
229
|
+
"bar": [
|
|
230
|
+
".yidun_control"
|
|
231
|
+
],
|
|
231
232
|
"piece": [
|
|
232
233
|
".yidun_jigsaw"
|
|
233
234
|
],
|
|
@@ -305,6 +306,11 @@
|
|
|
305
306
|
"input[id*=validateCaptcha]",
|
|
306
307
|
".BDC_CaptchaDiv input[type=text]"
|
|
307
308
|
],
|
|
309
|
+
"submit": [
|
|
310
|
+
"input#validateCaptchaButton",
|
|
311
|
+
"input[type=submit][id*=\"validateCaptcha\" i]",
|
|
312
|
+
"button[id*=\"validateCaptcha\" i]"
|
|
313
|
+
],
|
|
308
314
|
"refresh": [
|
|
309
315
|
"a[id*=\"ReloadLink\"]",
|
|
310
316
|
".BDC_ReloadIcon"
|
|
@@ -375,6 +381,9 @@
|
|
|
375
381
|
],
|
|
376
382
|
"widget": [
|
|
377
383
|
"iframe[src*=\"/core/v4/captcha\"]"
|
|
384
|
+
],
|
|
385
|
+
"board": [
|
|
386
|
+
".protonCaptchaContainer"
|
|
378
387
|
]
|
|
379
388
|
},
|
|
380
389
|
"datadome": {
|
|
@@ -395,6 +404,24 @@
|
|
|
395
404
|
"#captcha__reload__button"
|
|
396
405
|
]
|
|
397
406
|
},
|
|
407
|
+
"cybersiara": {
|
|
408
|
+
"note": "SiaraShield draws its challenge inline on the host page: a modal (`#myModal .pluginPopups`) holding a looping GIF of four letters read out of noise, `#Input_Captcha` and a refresh. It checks the answer itself once the fourth letter is typed (measured live 2026-11-14: a wrong answer clears the box and deals a new GIF), so it has no submit control. The host's own `.CaptchaSubmit` opens the modal, so it is never pressed for an answer.",
|
|
409
|
+
"hosts": [
|
|
410
|
+
"mycybersiara.com"
|
|
411
|
+
],
|
|
412
|
+
"widget": [
|
|
413
|
+
"#myModal .pluginPopups:has(#Img_Original)",
|
|
414
|
+
".pluginPopups:has(img.cy-sa-si-main-img)"
|
|
415
|
+
],
|
|
416
|
+
"text_input": [
|
|
417
|
+
"#Input_Captcha",
|
|
418
|
+
".cy-sa-page-2 input.Uinput"
|
|
419
|
+
],
|
|
420
|
+
"refresh": [
|
|
421
|
+
"#a_Refresh",
|
|
422
|
+
".pluginPopups a.ref_icon"
|
|
423
|
+
]
|
|
424
|
+
},
|
|
398
425
|
"unknown": {
|
|
399
426
|
"hosts": []
|
|
400
427
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
"""The `captchakraken` CLI: one-shot solves, the
|
|
1
|
+
"""The `captchakraken` CLI: one-shot solves, the pixel tool calls, the CV worker, and server management.
|
|
2
2
|
|
|
3
3
|
`captchakraken image.png [model] [api_provider] [api_key] [--puzzle-source ...]` solves one still.
|
|
4
4
|
Exit codes: 1 failure, 2 unsupported puzzle, 3 the hosted API refused.
|
|
@@ -106,13 +106,6 @@ def fill_step(req: dict) -> dict:
|
|
|
106
106
|
return {"error": str(e)}
|
|
107
107
|
|
|
108
108
|
|
|
109
|
-
def _find_grid(args):
|
|
110
|
-
from .tool_calls.find_grid import find_grid
|
|
111
|
-
|
|
112
|
-
_need(args, 1, "find-grid image.png")
|
|
113
|
-
return find_grid(_image(args[0]))
|
|
114
|
-
|
|
115
|
-
|
|
116
109
|
def _find_checkbox(args):
|
|
117
110
|
from .tool_calls.find_checkbox import find_checkbox
|
|
118
111
|
|
|
@@ -120,25 +113,6 @@ def _find_checkbox(args):
|
|
|
120
113
|
return find_checkbox(_image(args[0]))
|
|
121
114
|
|
|
122
115
|
|
|
123
|
-
def _detect_selected(args):
|
|
124
|
-
from .tool_calls.find_grid import detect_selected_cells, find_grid
|
|
125
|
-
|
|
126
|
-
_need(args, 1, "detect-selected image.png")
|
|
127
|
-
boxes = find_grid(_image(args[0]))
|
|
128
|
-
if not boxes:
|
|
129
|
-
return {"error": "No grid detected"}
|
|
130
|
-
selected, loading = detect_selected_cells(args[0], boxes)
|
|
131
|
-
return {"selected": selected, "loading": loading}
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
def _get_numbered_grid(args):
|
|
135
|
-
from .tool_calls.find_grid import find_grid, get_numbered_grid_overlay
|
|
136
|
-
|
|
137
|
-
_need(args, 1, "get-numbered-grid image.png")
|
|
138
|
-
boxes = find_grid(_image(args[0]))
|
|
139
|
-
return {"overlay_image": get_numbered_grid_overlay(args[0], boxes)} if boxes else {"error": "No grid detected"}
|
|
140
|
-
|
|
141
|
-
|
|
142
116
|
def _check_movement(args):
|
|
143
117
|
from .image_processor import ImageProcessor
|
|
144
118
|
|
|
@@ -152,17 +126,8 @@ def _check_movement(args):
|
|
|
152
126
|
return {"has_movement": ImageProcessor.detect_movement(args[0], args[1], threshold)}
|
|
153
127
|
|
|
154
128
|
|
|
155
|
-
def _grid_cell_states(args):
|
|
156
|
-
from .tool_calls.find_grid import find_grid
|
|
157
|
-
|
|
158
|
-
_need(args, 2, "grid-cell-states imgA.png imgB.png")
|
|
159
|
-
a, b = _image(args[0]), _image(args[1])
|
|
160
|
-
boxes = find_grid(b)
|
|
161
|
-
return grid_cell_states(a, b, boxes) if boxes else {"grid": None}
|
|
162
|
-
|
|
163
|
-
|
|
164
129
|
def _grid_cell_states_fixed(args):
|
|
165
|
-
"""Boxes supplied by the caller:
|
|
130
|
+
"""Boxes supplied by the caller, read from the vendor's DOM: the pixels alone do not say where the tiles are."""
|
|
166
131
|
_need(args, 3, "grid-cell-states-fixed imgA.png imgB.png '<json grid_boxes>'")
|
|
167
132
|
a, b = _image(args[0]), _image(args[1])
|
|
168
133
|
try:
|
|
@@ -216,15 +181,9 @@ def _serve(args):
|
|
|
216
181
|
"""Persistent CV worker: one JSON request per stdin line, one JSON reply per stdout line."""
|
|
217
182
|
from .image_processor import ImageProcessor
|
|
218
183
|
from .tool_calls.find_checkbox import find_checkbox
|
|
219
|
-
from .tool_calls.find_grid import find_grid
|
|
220
184
|
|
|
221
185
|
def handle(req):
|
|
222
186
|
cmd = req.get("cmd")
|
|
223
|
-
if cmd == "find-grid":
|
|
224
|
-
return find_grid(req["image"])
|
|
225
|
-
if cmd == "grid-cell-states":
|
|
226
|
-
boxes = find_grid(req["b"])
|
|
227
|
-
return grid_cell_states(req["a"], req["b"], boxes) if boxes else {"grid": None}
|
|
228
187
|
if cmd == "grid-cell-states-fixed":
|
|
229
188
|
boxes = [tuple(int(v) for v in box) for box in req["grid_boxes"]]
|
|
230
189
|
if not boxes:
|
|
@@ -423,12 +382,8 @@ def _fetch(args):
|
|
|
423
382
|
|
|
424
383
|
|
|
425
384
|
COMMANDS: Dict[str, Callable[[List[str]], Any]] = {
|
|
426
|
-
"find-grid": _find_grid,
|
|
427
385
|
"find-checkbox": _find_checkbox,
|
|
428
|
-
"detect-selected": _detect_selected,
|
|
429
|
-
"get-numbered-grid": _get_numbered_grid,
|
|
430
386
|
"check-movement": _check_movement,
|
|
431
|
-
"grid-cell-states": _grid_cell_states,
|
|
432
387
|
"grid-cell-states-fixed": _grid_cell_states_fixed,
|
|
433
388
|
"match-region": _match_region,
|
|
434
389
|
"board-painted": _board_painted,
|
|
@@ -246,10 +246,6 @@ def serve_model() -> str:
|
|
|
246
246
|
return os.getenv("CAPTCHA_BASE_MODEL") or selfhost_active().get("model_path") or base_model()
|
|
247
247
|
|
|
248
248
|
|
|
249
|
-
def pointer_detector() -> Optional[str]:
|
|
250
|
-
return os.getenv("CAPTCHA_POINTER_DETECTOR") or selfhost_active().get("detector")
|
|
251
|
-
|
|
252
|
-
|
|
253
249
|
def max_model_len() -> int:
|
|
254
250
|
return int(os.getenv("VLLM_MAX_MODEL_LEN", "65536"))
|
|
255
251
|
|
|
@@ -58,25 +58,26 @@
|
|
|
58
58
|
" NOT pre-empt it — doing so would stop our own admin token",
|
|
59
59
|
" from fetching weights it is entitled to.",
|
|
60
60
|
"",
|
|
61
|
-
"
|
|
62
|
-
"
|
|
63
|
-
"
|
|
64
|
-
" never be private either — an unpinned self-hoster would get",
|
|
65
|
-
" a 401 instead of a model — and the release parity gate says so.",
|
|
61
|
+
" `latest` may never be private — an unpinned self-hoster",
|
|
62
|
+
" would get a 401 instead of a model — and the release parity",
|
|
63
|
+
" gate says so.",
|
|
66
64
|
"",
|
|
67
|
-
" \"licensed\" —
|
|
68
|
-
"
|
|
69
|
-
"
|
|
70
|
-
"
|
|
65
|
+
" \"licensed\" — ON THE HUB, in a GATED repo named by the entry's key.",
|
|
66
|
+
" Access is granted to the Hugging Face account of each",
|
|
67
|
+
" licence holder, and withdrawn when the licence lapses.",
|
|
68
|
+
" Served to every account through api.captchakraken.com.",
|
|
69
|
+
" `captchakraken fetch` downloads it with the caller's own",
|
|
70
|
+
" Hub token, like a private model; a refusal from the Hub",
|
|
71
|
+
" becomes LicensedModelError, which names where the licence",
|
|
72
|
+
" is sold rather than reading as \"you are not logged in\".",
|
|
71
73
|
"",
|
|
72
74
|
"Why it lives HERE and not only in a policy doc: this file is already the one",
|
|
73
75
|
"place that decides what an unpinned client downloads and what prompts it",
|
|
74
76
|
"sends. A second list of 'models you may not publish' kept somewhere else",
|
|
75
77
|
"would be a list that drifts, and the drift is silent in the direction that",
|
|
76
|
-
"costs the most. The
|
|
77
|
-
"
|
|
78
|
-
"
|
|
79
|
-
"they cannot obtain.",
|
|
78
|
+
"costs the most. The release parity gate refuses to let `latest` be a",
|
|
79
|
+
"licensed model, because an unpinned self-hoster would resolve to weights",
|
|
80
|
+
"they cannot obtain without a licence.",
|
|
80
81
|
"",
|
|
81
82
|
"`experts` is the fourth axis, and the newest. A ROUTED model is not one",
|
|
82
83
|
"adapter: Abyss is four LoRAs behind one endpoint, and the thing that picks",
|
|
@@ -263,7 +264,7 @@
|
|
|
263
264
|
"video": "abyss-video",
|
|
264
265
|
"text": "abyss-text"
|
|
265
266
|
},
|
|
266
|
-
"note": "A routed mixture of four expert LoRAs on Qwen3.5-9B — grid, pixel, video and text — selected by prompt family.
|
|
267
|
+
"note": "A routed mixture of four expert LoRAs on Qwen3.5-9B — grid, pixel, video and text — selected by prompt family. Its weights are in a gated Hub repo open to licence holders; everyone else reaches it through the hosted API. The current client names this model against our endpoint, which is why it and each of its arms has a served_aliases entry. `lora_name` is `abyss-general` rather than a fifth name because the generalist IS the fallback for any family `experts` does not map, so the two point at one adapter and the mixture needs one fewer resident LoRA slot."
|
|
267
268
|
},
|
|
268
269
|
"CaptchaKraken/Abyss-27B": {
|
|
269
270
|
"availability": "private",
|
|
@@ -37,6 +37,8 @@ _SITE_ENV = "CAPTCHA_KRAKEN_SITE"
|
|
|
37
37
|
_WIDGET_HOST_ENV = "CAPTCHA_KRAKEN_WIDGET_HOST"
|
|
38
38
|
# How often a page that has not drawn its widget yet is looked at again.
|
|
39
39
|
_DETECTION_POLL_MS = 250
|
|
40
|
+
#: How long a widget frame is given to draw the board inside it (`board`) before the frame itself is shot.
|
|
41
|
+
_BOARD_INSIDE_WAIT_MS = 3_000
|
|
40
42
|
|
|
41
43
|
|
|
42
44
|
def _log(message: str) -> None:
|
|
@@ -468,6 +470,11 @@ SLIDE_STALL_PX = 1.0
|
|
|
468
470
|
|
|
469
471
|
# No prompt and no pictures both read as ready: waiting for `.prompt-text` to exist once paid the whole timeout
|
|
470
472
|
# before every board of a challenge that draws none (tower_stack: 18s a round, 2/2 -> 0/2).
|
|
473
|
+
_TILE_RECTS_JS = """(sel) => Array.from(document.querySelectorAll(sel))
|
|
474
|
+
.map((e) => e.getBoundingClientRect())
|
|
475
|
+
.filter((r) => r.width > 0 && r.height > 0)
|
|
476
|
+
.map((r) => [r.left, r.top, r.right, r.bottom])"""
|
|
477
|
+
|
|
471
478
|
_BOARD_IMAGES_READY_JS = """({ prompt, images }) => {
|
|
472
479
|
const vis = (el) => !!el && el.getClientRects().length > 0
|
|
473
480
|
&& getComputedStyle(el).visibility !== 'hidden';
|
|
@@ -514,9 +521,6 @@ class PageSolver:
|
|
|
514
521
|
self._solver = solver or CaptchaSolver(**solver_kwargs)
|
|
515
522
|
self._human: Humanizer = resolve_humanizer(self.config)
|
|
516
523
|
self._sel = SelectorTable(self.config.custom_selectors, config=self.config.selectors)
|
|
517
|
-
# The config's `detector`: which element detector finds this solver's grids and tick boxes.
|
|
518
|
-
from .pointer import detector as _detector
|
|
519
|
-
_detector.configure(self._sel.config.detector)
|
|
520
524
|
self._last_submit_frame_hash: Optional[str] = None
|
|
521
525
|
self._deadline_ms: Optional[float] = None
|
|
522
526
|
self._budget: Optional[PhaseBudget] = None
|
|
@@ -788,14 +792,30 @@ class PageSolver:
|
|
|
788
792
|
|
|
789
793
|
# ── the shared half, in-process ──────────────────────────────────────
|
|
790
794
|
|
|
791
|
-
def
|
|
792
|
-
|
|
795
|
+
def _dom_grid(self, element: Any, image_path: str) -> Optional[List[Sequence[int]]]:
|
|
796
|
+
"""The board's tiles as (x0, y0, x1, y1) pixels of `image_path`, a screenshot of `element`, in reading order.
|
|
793
797
|
|
|
798
|
+
Read from the vendor's own markup, not the picture: a tile is where the challenge frame placed it. A tile's
|
|
799
|
+
rectangle is in the frame's CSS pixels, which start at the iframe's corner, so it scales straight onto the
|
|
800
|
+
screenshot. None when the vendor names no tiles or the frame shows none.
|
|
801
|
+
"""
|
|
802
|
+
sel = self._sel.selectors.get(Vendor.RECAPTCHA)
|
|
803
|
+
dims = _read_png_dimensions(image_path)
|
|
804
|
+
if sel is None or not sel.tiles or not dims:
|
|
805
|
+
return None
|
|
794
806
|
try:
|
|
795
|
-
|
|
807
|
+
frame = element.content_frame()
|
|
808
|
+
box = element.bounding_box()
|
|
809
|
+
if frame is None or not box or box["width"] <= 0 or box["height"] <= 0:
|
|
810
|
+
return None
|
|
811
|
+
rects = frame.evaluate(_TILE_RECTS_JS, ",".join(sel.tiles))
|
|
796
812
|
except Exception as exc:
|
|
797
|
-
_debug(f"
|
|
813
|
+
_debug(f"reading the grid's tiles failed: {exc}")
|
|
798
814
|
return None
|
|
815
|
+
sx, sy = dims[0] / box["width"], dims[1] / box["height"]
|
|
816
|
+
boxes = [(int(round(x0 * sx)), int(round(y0 * sy)), int(round(x1 * sx)), int(round(y1 * sy)))
|
|
817
|
+
for x0, y0, x1, y1 in rects or ()]
|
|
818
|
+
return boxes if len(boxes) >= 4 else None
|
|
799
819
|
|
|
800
820
|
def _has_movement(self, path_a: str, path_b: str, threshold: float) -> bool:
|
|
801
821
|
from .image_processor import ImageProcessor
|
|
@@ -1058,17 +1078,92 @@ class PageSolver:
|
|
|
1058
1078
|
first = next(iter(_visible(scope, selectors)), None)
|
|
1059
1079
|
return _handle_of(first) if first is not None else None
|
|
1060
1080
|
|
|
1081
|
+
def _framed(self, widget: Widget, frame: Any, scope: Any) -> Tuple[Any, Optional[Any]]:
|
|
1082
|
+
"""The element whose screenshot the model is shown for `widget`, and the text box when it is typed.
|
|
1083
|
+
|
|
1084
|
+
This is the whole of what the client PHOTOGRAPHS, kept in one place so the capture gate can check it without
|
|
1085
|
+
solving: the widget, else the board its frame pads (Proton), widened by a text box beside it (BotDetect) or
|
|
1086
|
+
by the vendor's bar or slider track outside it (Yidun).
|
|
1087
|
+
"""
|
|
1088
|
+
element, puzzle_source = widget.element, widget.vendor
|
|
1089
|
+
# A widget frame that pads its board (Proton) is photographed by the board inside it.
|
|
1090
|
+
board = self._board_inside(frame, puzzle_source)
|
|
1091
|
+
if board is not None:
|
|
1092
|
+
_log("the widget frame pads its board; photographing the board itself")
|
|
1093
|
+
element = board
|
|
1094
|
+
|
|
1095
|
+
# Only the DOM can tell a typed captcha from a click puzzle; hCaptcha and reCAPTCHA never type.
|
|
1096
|
+
answer_box = None if puzzle_source in VENDORS_WITH_BESPOKE_HANDLING else self._answer_box(scope, widget.at)
|
|
1097
|
+
if answer_box is not None:
|
|
1098
|
+
_log("widget has a text box; solving as a distorted-text captcha")
|
|
1099
|
+
element = _WithAnswerBox(element, answer_box)
|
|
1100
|
+
elif puzzle_source not in VENDORS_WITH_BESPOKE_HANDLING:
|
|
1101
|
+
track = self._track_outside(scope, puzzle_source, element, widget.at)
|
|
1102
|
+
if track is not None:
|
|
1103
|
+
_log("the vendor bar or slider track sits outside the widget; photographing the two as one")
|
|
1104
|
+
element = _WithAnswerBox(element, track, SLIDER_TRACK_MAX_GROWTH)
|
|
1105
|
+
return element, answer_box
|
|
1106
|
+
|
|
1107
|
+
def capture(self, page: Any) -> Optional[Tuple[Widget, Any]]:
|
|
1108
|
+
"""The widget on `page` and the element the solver would photograph for it, without solving anything.
|
|
1109
|
+
|
|
1110
|
+
For release gates: whether the client finds a vendor's widget, by its selectors and URL markers, and frames
|
|
1111
|
+
the whole board, is checkable on a live page at no inference cost. A checkbox widget is returned with its own
|
|
1112
|
+
element; it is clicked, not photographed.
|
|
1113
|
+
"""
|
|
1114
|
+
self._page = page
|
|
1115
|
+
widget = self.detect_captcha(page)
|
|
1116
|
+
if widget is None:
|
|
1117
|
+
return None
|
|
1118
|
+
if widget.role == FrameRole.CHECKBOX:
|
|
1119
|
+
return widget, widget.element
|
|
1120
|
+
frame = widget.element.content_frame()
|
|
1121
|
+
if widget.vendor != Vendor.RECAPTCHA:
|
|
1122
|
+
self._wait_for_board_painted(widget.element)
|
|
1123
|
+
element, _ = self._framed(widget, frame, frame or widget.at)
|
|
1124
|
+
return widget, element
|
|
1125
|
+
|
|
1126
|
+
def _board_inside(self, frame: Any, vendor: Any) -> Optional[Any]:
|
|
1127
|
+
"""The vendor's own `board`, found in the widget's frame or a frame nested in it, or None.
|
|
1128
|
+
|
|
1129
|
+
Proton's widget frame is 682x600 with its 370x534 `.protonCaptchaContainer` centred two frames down; the
|
|
1130
|
+
pointer trained on that container, and shown the padded frame it repeated one answer until the solve gave up
|
|
1131
|
+
(live 0/2 on 2026-11-13). The board is drawn a moment after the frame, so it is waited for briefly.
|
|
1132
|
+
"""
|
|
1133
|
+
own = getattr(self._sel.selectors.get(vendor), "board", None)
|
|
1134
|
+
if not own or frame is None:
|
|
1135
|
+
return None
|
|
1136
|
+
deadline = _now() + _BOARD_INSIDE_WAIT_MS
|
|
1137
|
+
while True:
|
|
1138
|
+
try:
|
|
1139
|
+
frames = [frame]
|
|
1140
|
+
while frames:
|
|
1141
|
+
where = frames.pop(0)
|
|
1142
|
+
for found in _visible(where, own):
|
|
1143
|
+
handle = _handle_of(found)
|
|
1144
|
+
if handle is not None and handle.bounding_box():
|
|
1145
|
+
return handle
|
|
1146
|
+
frames.extend(where.child_frames)
|
|
1147
|
+
except Exception:
|
|
1148
|
+
return None
|
|
1149
|
+
if _now() >= deadline:
|
|
1150
|
+
return None
|
|
1151
|
+
_delay(_DETECTION_POLL_MS)
|
|
1152
|
+
|
|
1061
1153
|
def _track_outside(self, scope: Any, vendor: Any, element: Any, at: Any = None) -> Optional[Any]:
|
|
1062
|
-
"""The
|
|
1154
|
+
"""The vendor's own `bar`, else the track of its first slider handle, visible with its centre outside the widget.
|
|
1063
1155
|
|
|
1064
|
-
|
|
1156
|
+
The bar is what Yidun's click modes need: `.yidun_control` holds the 请依次点击 prompt that names the marks and
|
|
1157
|
+
their order, and on the bare `.yidun_panel` the pointer was shown neither (live 0/6 on 2026-11-13). The
|
|
1158
|
+
handle's track covers vendors that name only a handle. Either is looked for in the widget, then in its parent and grandparent: Yidun's `.yidun_slider` is in
|
|
1065
1159
|
`.yidun_control`, a sibling of the `.yidun_panel` the widget resolves to. A match inside the widget is passed
|
|
1066
1160
|
over, not taken as the answer: Yidun lists its piece (`.yidun_jigsaw`, in the panel) as a handle too. The
|
|
1067
1161
|
track (the handle's parent) is returned rather than the handle, whose box moves as it slides and would
|
|
1068
1162
|
resize the frame.
|
|
1069
1163
|
"""
|
|
1070
|
-
|
|
1071
|
-
if
|
|
1164
|
+
mine = self._sel.selectors.get(vendor)
|
|
1165
|
+
kinds = [(sels, is_bar) for sels, is_bar in ((getattr(mine, "bar", None), True), (getattr(mine, "slider_handle", None), False)) if sels]
|
|
1166
|
+
if not kinds:
|
|
1072
1167
|
return None
|
|
1073
1168
|
# Widening the shot is a nicety: a scope that cannot be searched (a detached frame) leaves the shot as it was.
|
|
1074
1169
|
try:
|
|
@@ -1076,16 +1171,17 @@ class PageSolver:
|
|
|
1076
1171
|
a = element.bounding_box()
|
|
1077
1172
|
if not a:
|
|
1078
1173
|
return None
|
|
1079
|
-
for
|
|
1080
|
-
for
|
|
1081
|
-
|
|
1082
|
-
|
|
1083
|
-
|
|
1084
|
-
|
|
1085
|
-
|
|
1086
|
-
|
|
1087
|
-
|
|
1088
|
-
|
|
1174
|
+
for own, is_bar in kinds:
|
|
1175
|
+
for where in wheres:
|
|
1176
|
+
for found in _visible(where, own):
|
|
1177
|
+
handle = _handle_of(found)
|
|
1178
|
+
b = handle.bounding_box() if handle is not None else None
|
|
1179
|
+
if not b:
|
|
1180
|
+
continue
|
|
1181
|
+
cx, cy = b["x"] + b["width"] / 2, b["y"] + b["height"] / 2
|
|
1182
|
+
if a["x"] <= cx <= a["x"] + a["width"] and a["y"] <= cy <= a["y"] + a["height"]:
|
|
1183
|
+
continue
|
|
1184
|
+
return handle if is_bar else (_handle_of(found.locator("xpath=..")) or handle)
|
|
1089
1185
|
except Exception:
|
|
1090
1186
|
return None
|
|
1091
1187
|
return None
|
|
@@ -1430,7 +1526,7 @@ class PageSolver:
|
|
|
1430
1526
|
_delay(_DETECTION_POLL_MS)
|
|
1431
1527
|
|
|
1432
1528
|
def _checkbox_on_screen(self, element: Any) -> Optional[Tuple[float, float]]:
|
|
1433
|
-
"""One capture and
|
|
1529
|
+
"""One capture and plain pixel arithmetic, no model: a point inside the tick box, or None when none is drawn."""
|
|
1434
1530
|
from .tool_calls.find_checkbox import find_checkbox
|
|
1435
1531
|
|
|
1436
1532
|
box = element.bounding_box()
|
|
@@ -1462,8 +1558,19 @@ class PageSolver:
|
|
|
1462
1558
|
return
|
|
1463
1559
|
_delay(self.config.post_solve_outcome_poll_ms)
|
|
1464
1560
|
|
|
1465
|
-
def _get_verify_button(self, scope: Any) -> Optional[Any]:
|
|
1466
|
-
|
|
1561
|
+
def _get_verify_button(self, scope: Any, typed_at: Any = None) -> Optional[Any]:
|
|
1562
|
+
"""The widget's Verify, else, after a typed answer, the vendor-named submit beside its text box.
|
|
1563
|
+
|
|
1564
|
+
BotDetect's Validate sits in the widget's fieldset, outside the 280x50 `.BDC_CaptchaDiv`, like `#captchaCode`
|
|
1565
|
+
(see `_answer_box`). Without it the code was typed and never sent: live 0/9 on 2026-11-13. Only vendor-named
|
|
1566
|
+
selectors widen, so a login form's own Submit is never pressed.
|
|
1567
|
+
"""
|
|
1568
|
+
inside = self._find_control(scope, self._sel.submit)
|
|
1569
|
+
if inside is not None or typed_at is None:
|
|
1570
|
+
return inside
|
|
1571
|
+
around = (self._find_control(typed_at.locator(f"xpath={axis}"), self._sel.submit_vendor)
|
|
1572
|
+
for axis in ("ancestor::fieldset[1]", "ancestor::form[1]"))
|
|
1573
|
+
return next((found for found in around if found is not None), None)
|
|
1467
1574
|
|
|
1468
1575
|
# ── frames and polling ───────────────────────────────────────────────
|
|
1469
1576
|
|
|
@@ -1594,7 +1701,7 @@ class PageSolver:
|
|
|
1594
1701
|
def judge(frames, elapsed):
|
|
1595
1702
|
if len(frames) < 2:
|
|
1596
1703
|
return None
|
|
1597
|
-
boxes = self.
|
|
1704
|
+
boxes = self._dom_grid(element, frames[1])
|
|
1598
1705
|
if not boxes:
|
|
1599
1706
|
return False if elapsed >= cfg.grid_load_timeout_ms else None
|
|
1600
1707
|
states = self._grid_cell_states(frames[0], frames[1], boxes)
|
|
@@ -1645,7 +1752,7 @@ class PageSolver:
|
|
|
1645
1752
|
path = _tmp_png("findgrid")
|
|
1646
1753
|
try:
|
|
1647
1754
|
self._screenshot(element, path, timeout_ms=self.config.element_screenshot_timeout_ms)
|
|
1648
|
-
boxes = self.
|
|
1755
|
+
boxes = self._dom_grid(element, path)
|
|
1649
1756
|
dims = _read_png_dimensions(path)
|
|
1650
1757
|
if not boxes or len(boxes) not in (9, 16) or not dims:
|
|
1651
1758
|
return None
|
|
@@ -2260,17 +2367,8 @@ class PageSolver:
|
|
|
2260
2367
|
with self._phase(Phase.BOARD_PAINT):
|
|
2261
2368
|
self._wait_for_board_painted(element)
|
|
2262
2369
|
|
|
2263
|
-
|
|
2264
|
-
answer_box = None if puzzle_source in VENDORS_WITH_BESPOKE_HANDLING else self._answer_box(scope, widget.at)
|
|
2370
|
+
element, answer_box = self._framed(widget, frame, scope)
|
|
2265
2371
|
text_mode = answer_box is not None
|
|
2266
|
-
if text_mode:
|
|
2267
|
-
_log("widget has a text box; solving as a distorted-text captcha")
|
|
2268
|
-
element = _WithAnswerBox(element, answer_box)
|
|
2269
|
-
elif puzzle_source not in VENDORS_WITH_BESPOKE_HANDLING:
|
|
2270
|
-
track = self._track_outside(scope, puzzle_source, element, widget.at)
|
|
2271
|
-
if track is not None:
|
|
2272
|
-
_log("the slider track sits outside the widget; photographing the two as one")
|
|
2273
|
-
element = _WithAnswerBox(element, track, SLIDER_TRACK_MAX_GROWTH)
|
|
2274
2372
|
|
|
2275
2373
|
# A reCAPTCHA board is read by its grid below, not filmed.
|
|
2276
2374
|
filmable = puzzle_source != Vendor.RECAPTCHA and not text_mode
|
|
@@ -2298,7 +2396,7 @@ class PageSolver:
|
|
|
2298
2396
|
|
|
2299
2397
|
shot = _tmp_png("captcha")
|
|
2300
2398
|
self._round_board = None
|
|
2301
|
-
performed = slid = answered = have_shot = False
|
|
2399
|
+
performed = slid = answered = typed = have_shot = False
|
|
2302
2400
|
all_usage: List[Dict[str, Any]] = []
|
|
2303
2401
|
keyframe_dir: Optional[str] = None
|
|
2304
2402
|
try:
|
|
@@ -2399,7 +2497,7 @@ class PageSolver:
|
|
|
2399
2497
|
performed = answered = True
|
|
2400
2498
|
elif kind == ActionKind.TYPE:
|
|
2401
2499
|
if self._execute_type(page, scope, action, widget.at):
|
|
2402
|
-
performed = answered = True
|
|
2500
|
+
performed = answered = typed = True
|
|
2403
2501
|
elif kind == ActionKind.HOLD:
|
|
2404
2502
|
# The widget submits itself when the hold completes, like a slide on release.
|
|
2405
2503
|
self._execute_hold(page, action, element_box, element, self._sel.selectors[widget.vendor].hold_completes)
|
|
@@ -2419,7 +2517,8 @@ class PageSolver:
|
|
|
2419
2517
|
# `done` plan still presses Verify/Skip. FunCaptcha's answer is the click itself: an arrow pages and
|
|
2420
2518
|
# Submit submits. The generic Verify fallback would submit the page an arrow just turned to.
|
|
2421
2519
|
submits = self._submitted_on_board if slid else answered or not performed
|
|
2422
|
-
verify_button = self._get_verify_button(scope
|
|
2520
|
+
verify_button = (self._get_verify_button(scope, widget.at if typed else None)
|
|
2521
|
+
if submits and puzzle_source != Vendor.FUNCAPTCHA else None)
|
|
2423
2522
|
if verify_button:
|
|
2424
2523
|
_log(f"clicking Verify to submit ({puzzle_source}).")
|
|
2425
2524
|
self._move_and_click(page, verify_button)
|
|
@@ -1,20 +1,18 @@
|
|
|
1
1
|
"""The pointer solver: a captcha answered from ONE forward pass, never generated.
|
|
2
2
|
|
|
3
|
-
The board is shown to a Qwen3.5 model (still, or a video)
|
|
4
|
-
|
|
5
|
-
in the prompt. Every question the answer needs (which action, how many clicks,
|
|
3
|
+
The board is shown to a Qwen3.5 model (still, or a video) as it was captured.
|
|
4
|
+
Every question the answer needs (which action, how many clicks,
|
|
6
5
|
where each one lands, what to type, which moment of a video) has a marker
|
|
7
6
|
token in the prompt, and small heads read each marker's hidden state from the
|
|
8
|
-
prefill. The answer always carries points
|
|
9
|
-
when the point lands on a numbered element.
|
|
7
|
+
prefill. The answer always carries points.
|
|
10
8
|
|
|
11
9
|
layout the prompt, the questions and the packed decision vector
|
|
12
|
-
elements
|
|
13
|
-
|
|
10
|
+
elements numbered elements, and the element under a point (training reads
|
|
11
|
+
them; the client sends every board bare)
|
|
12
|
+
marks the outlines and numbers a marked training board is drawn with
|
|
14
13
|
heads the torch heads (training and serving share them)
|
|
15
|
-
detector the element detector (Mask R-CNN, ResNet-18 FPN)
|
|
16
14
|
vllm_plugin the heads inside vLLM's pooling runner
|
|
17
|
-
service board in, answer out:
|
|
15
|
+
service board in, answer out: vLLM, decode
|
|
18
16
|
|
|
19
17
|
Only `layout`, `elements` and `marks` import without torch.
|
|
20
18
|
"""
|
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
An element is {"class", "box": [x0, y0, x1, y1], "score", "mask": ((x, y), bool
|
|
4
4
|
array)} in board pixels; the mask is cropped to its own extent and placed at
|
|
5
|
-
(x, y), as
|
|
5
|
+
(x, y), as an element detector returns it. Numbers are 1-based in reading
|
|
6
6
|
order (rows of ~12 px, then left to right), so a grid's cells number row-major.
|
|
7
7
|
|
|
8
8
|
`element_at` is the inverse question training asks: which numbered element does
|