captchakraken 4.2.0 → 5.0.0-beta.42

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.
Files changed (35) hide show
  1. package/README.md +0 -1
  2. package/dist/index.d.ts +1 -1
  3. package/dist/kinds.d.ts +1 -0
  4. package/dist/kinds.js +1 -0
  5. package/dist/playwright-types.d.ts +4 -0
  6. package/dist/puppeteer-adapter.d.ts +2 -0
  7. package/dist/puppeteer-adapter.js +34 -2
  8. package/dist/selectors.d.ts +22 -11
  9. package/dist/selectors.js +9 -19
  10. package/dist/solver.d.ts +49 -4
  11. package/dist/solver.js +177 -47
  12. package/package.json +2 -2
  13. package/python/AGENTS.md +5 -4
  14. package/python/README.md +3 -6
  15. package/python/pyproject.toml +6 -9
  16. package/python/src/captchakraken/__init__.py +1 -1
  17. package/python/src/captchakraken/captchakraken.config.json +43 -9
  18. package/python/src/captchakraken/cli.py +2 -47
  19. package/python/src/captchakraken/config.py +0 -4
  20. package/python/src/captchakraken/kinds.py +1 -0
  21. package/python/src/captchakraken/models.json +15 -14
  22. package/python/src/captchakraken/page_solver.py +168 -49
  23. package/python/src/captchakraken/pointer/__init__.py +7 -9
  24. package/python/src/captchakraken/pointer/elements.py +1 -1
  25. package/python/src/captchakraken/pointer/server.py +13 -17
  26. package/python/src/captchakraken/pointer/service.py +35 -324
  27. package/python/src/captchakraken/prompts.py +3 -4
  28. package/python/src/captchakraken/selectors.py +19 -17
  29. package/python/src/captchakraken/selfhost.py +9 -16
  30. package/python/src/captchakraken/server_manager.py +0 -4
  31. package/python/src/captchakraken/solver.py +4 -25
  32. package/python/src/captchakraken/tool_calls/find_checkbox.py +150 -13
  33. package/python/src/captchakraken/tool_calls/find_grid.py +6 -132
  34. package/python/src/captchakraken/updater.py +57 -27
  35. package/python/src/captchakraken/pointer/detector.py +0 -333
package/dist/solver.js CHANGED
@@ -212,6 +212,8 @@ function isClosedTargetError(message) {
212
212
  }
213
213
  /** How often a page that has not drawn its widget yet is looked at again. */
214
214
  const DETECTION_POLL_MS = 250;
215
+ /** How long a widget frame is given to draw the board inside it (`board`) before the frame itself is shot. */
216
+ const BOARD_INSIDE_WAIT_MS = 3000;
215
217
  // Frame-diff thresholds; two screens of one board differ by ~0.0056, a different board by ~0.77.
216
218
  const NOT_THIS_BOARD_DIFF = 0.5;
217
219
  // Tighter than staleFrameDiffThreshold (0.02), which was blind to GeeTest svg; 0.001 is the noise floor.
@@ -288,6 +290,10 @@ function hostname(page) {
288
290
  }
289
291
  }
290
292
  class CaptchaKrakenSolver {
293
+ /** A stylesheet that takes every verdict message out of a photograph, laid out as if it had never been shown. */
294
+ get feedbackHidden() {
295
+ return this.sel.feedback.map((s) => `${s} { display: none !important; }`).join('\n');
296
+ }
291
297
  ph(name, fn) {
292
298
  return this.budget ? this.budget.phase(name, fn) : fn();
293
299
  }
@@ -380,17 +386,17 @@ class CaptchaKrakenSolver {
380
386
  * repaints nothing, and measured twice as fast. `disabled` freezes CSS animation, which once sliced GeeTest svg to
381
387
  * a static clip; callers filming motion pass `allow`.
382
388
  */
383
- async shot(el, p, timeout = 2500, animations = 'disabled') {
389
+ async shot(el, p, timeout = 2500, animations = 'disabled', style) {
384
390
  const page = this.page;
385
391
  const view = await viewportOf(page);
386
392
  const rect = (await layoutIsTheViewport(page, view)) ? await this.rectInView(el, view) : null;
387
393
  if (!rect) {
388
394
  // Bigger than the viewport, or a zoomed-out mobile layout: no viewport capture holds it in its own
389
395
  // coordinates, so the element photographs itself.
390
- await el.screenshot({ path: p, timeout, animations });
396
+ await el.screenshot({ path: p, timeout, animations, style });
391
397
  return;
392
398
  }
393
- fs.writeFileSync(p, (0, png_1.cropPng)(await page.screenshot({ timeout, animations }), rect, view.width));
399
+ fs.writeFileSync(p, (0, png_1.cropPng)(await page.screenshot({ timeout, animations, style }), rect, view.width));
394
400
  }
395
401
  async rectOf(el) {
396
402
  const box = await el.boundingBox();
@@ -764,8 +770,6 @@ class CaptchaKrakenSolver {
764
770
  ...(this.solveWidgetHost ? { CAPTCHA_KRAKEN_WIDGET_HOST: this.solveWidgetHost } : {}),
765
771
  // This driver warns about a legacy model name itself, once; the engine it starts per round stays quiet.
766
772
  CAPTCHA_KRAKEN_MODEL_WARNING: '0',
767
- // The config's detector choice; the caller's own environment variable still wins, as it does in Python.
768
- ...(process.env.CAPTCHA_KRAKEN_DETECTOR_MODEL ? {} : { CAPTCHA_KRAKEN_DETECTOR_MODEL: this.sel.config.detector }),
769
773
  };
770
774
  }
771
775
  /** Fire the optional onStep observer with a fresh screenshot; best-effort, never fails the solve. */
@@ -817,20 +821,9 @@ class CaptchaKrakenSolver {
817
821
  // gate on every dynamic round, on the family with the tightest per-board budget.
818
822
  const painted = puzzleSource === kinds_1.Vendor.RECAPTCHA ? null
819
823
  : await this.ph(kinds_1.Phase.BOARD_PAINT, () => this.waitForBoardPainted(captchaElement));
820
- // Only the DOM can tell a typed captcha from a click puzzle; hCaptcha and reCAPTCHA never type.
821
- const answerBox = VENDORS_WITH_BESPOKE_HANDLING.has(puzzleSource) ? null : await this.answerBox(scope, widget.at);
822
- const textMode = answerBox !== null;
823
- if (textMode) {
824
- console.log('Widget has a text box; solving as a distorted-text captcha.');
825
- captchaElement = withAnswerBox(captchaElement, answerBox);
826
- }
827
- else if (!VENDORS_WITH_BESPOKE_HANDLING.has(puzzleSource)) {
828
- const track = await this.trackOutside(scope, puzzleSource, captchaElement, widget.at);
829
- if (track) {
830
- console.log('The slider track sits outside the widget; photographing the two as one.');
831
- captchaElement = withAnswerBox(captchaElement, track, SLIDER_TRACK_MAX_GROWTH);
832
- }
833
- }
824
+ const framed = await this.framed(widget, frame, scope);
825
+ captchaElement = framed.element;
826
+ const textMode = framed.answerBox !== null;
834
827
  // A reCAPTCHA board is read by its grid below, not filmed.
835
828
  const filmable = puzzleSource !== kinds_1.Vendor.RECAPTCHA && !textMode;
836
829
  if (filmable && !this.knownAnimated)
@@ -863,7 +856,7 @@ class CaptchaKrakenSolver {
863
856
  isAnimated = probing = true;
864
857
  }
865
858
  let establishedGridSize = null;
866
- // The challenge frame only: on the anchor this wasted an 8s grid-load timeout plus a find-grid subprocess.
859
+ // The challenge frame only: on the anchor this wasted an 8s grid-load timeout.
867
860
  if (puzzleSource === kinds_1.Vendor.RECAPTCHA && frameRole === kinds_1.FrameRole.CHALLENGE) {
868
861
  await this.ph(kinds_1.Phase.GRID_LOAD, () => this.waitForGridCellsLoaded(captchaElement));
869
862
  const grid = await this.getGridBoxes(captchaElement);
@@ -892,7 +885,7 @@ class CaptchaKrakenSolver {
892
885
  else {
893
886
  await this.ph(kinds_1.Phase.SCREENSHOT, () => this.shot(captchaElement, screenshotPath, cfg.elementScreenshotTimeoutMs ?? 8000));
894
887
  }
895
- const boardHash = await this.boardHash(captchaElement, screenshotPath, filmed);
888
+ const boardHash = await this.boardHash(captchaElement);
896
889
  // A refresh that brought the same picture back has replaced nothing, and every plan has been spent on it.
897
890
  if (this.refreshedBoards.has(boardHash))
898
891
  throw new Error('No progress: the board came back unchanged after a refresh.');
@@ -902,6 +895,7 @@ class CaptchaKrakenSolver {
902
895
  let performedAction = false;
903
896
  let slid = false;
904
897
  let answered = false;
898
+ let typed = false;
905
899
  let allTokenUsage = [];
906
900
  let burstDir = null;
907
901
  try {
@@ -1116,7 +1110,7 @@ class CaptchaKrakenSolver {
1116
1110
  }
1117
1111
  else if (action.action === kinds_1.ActionKind.TYPE) {
1118
1112
  if (await this.executeType(page, scope, action, widget.at)) {
1119
- performedAction = answered = true;
1113
+ performedAction = answered = typed = true;
1120
1114
  await this.emitStep(captchaElement, kinds_1.SolveStage.TYPE, 'typed the code', puzzleSource, frameRole, attempt, { action });
1121
1115
  }
1122
1116
  }
@@ -1139,7 +1133,8 @@ class CaptchaKrakenSolver {
1139
1133
  // Verify/Skip. FunCaptcha is the exception: its answer is the click itself — an arrow pages, Submit (which the
1140
1134
  // model clicks on the match) submits — so the generic fallback submits page one right after an arrow turned it.
1141
1135
  const submits = slid ? this.submittedOnBoard : answered || !performedAction;
1142
- const verifyButton = submits && puzzleSource !== kinds_1.Vendor.FUNCAPTCHA ? await this.getVerifyButton(scope) : null;
1136
+ const verifyButton = submits && puzzleSource !== kinds_1.Vendor.FUNCAPTCHA
1137
+ ? await this.getVerifyButton(scope, typed ? widget.at : null) : null;
1143
1138
  if (verifyButton) {
1144
1139
  console.log(`Clicking Verify to submit (${puzzleSource}).`);
1145
1140
  await this.moveAndClick(page, verifyButton);
@@ -1215,7 +1210,7 @@ class CaptchaKrakenSolver {
1215
1210
  await delay(DETECTION_POLL_MS);
1216
1211
  }
1217
1212
  }
1218
- /** One capture and the element detector, no model: a point inside the tick box, or null when none is drawn. */
1213
+ /** One capture and plain pixel arithmetic, no model: a point inside the tick box, or null when none is drawn. */
1219
1214
  async checkboxOnScreen(el) {
1220
1215
  const box = await el.boundingBox();
1221
1216
  if (!box)
@@ -1251,8 +1246,18 @@ class CaptchaKrakenSolver {
1251
1246
  }
1252
1247
  });
1253
1248
  }
1254
- getVerifyButton(scope) {
1255
- return this.findControl(scope, this.sel.submit);
1249
+ /**
1250
+ * The widget's Verify, else, after a typed answer, the vendor-named submit beside its text box. BotDetect's Validate
1251
+ * sits in the widget's fieldset, outside the 280x50 `.BDC_CaptchaDiv`, like `#captchaCode` (see `answerBox`):
1252
+ * without it the code was typed and never sent (live 0/9, 2026-11-13). Only vendor-named selectors widen, so a
1253
+ * login form's own Submit is never pressed.
1254
+ */
1255
+ async getVerifyButton(scope, typedAt) {
1256
+ const inside = await this.findControl(scope, this.sel.submit);
1257
+ if (inside !== null || !typedAt)
1258
+ return inside;
1259
+ const around = await Promise.all(['ancestor::fieldset[1]', 'ancestor::form[1]'].map((axis) => this.findControl(typedAt.locator(`xpath=${axis}`), this.sel.submitVendor)));
1260
+ return around.find((h) => h !== null) ?? null;
1256
1261
  }
1257
1262
  /** Any element at `selector` carrying a non-blank value; response fields are hidden, so no visibility filter. */
1258
1263
  async hasValue(scopes, selector) {
@@ -1657,8 +1662,11 @@ class CaptchaKrakenSolver {
1657
1662
  if (frames.length < 2)
1658
1663
  return undefined;
1659
1664
  const late = Date.now() - start >= timeout;
1660
- const res = await this.runCvTool('grid-cell-states', { a: frames[0], b: frames[1] }, ['grid-cell-states', frames[0], frames[1]]);
1661
- if (!res || res.grid === null)
1665
+ const boxes = await this.domGrid(captchaElement, frames[1]);
1666
+ if (!boxes)
1667
+ return late ? false : undefined;
1668
+ const res = await this.runCvTool('grid-cell-states-fixed', { a: frames[0], b: frames[1], grid_boxes: boxes }, ['grid-cell-states-fixed', frames[0], frames[1], JSON.stringify(boxes)]);
1669
+ if (!res)
1662
1670
  return late ? false : undefined;
1663
1671
  if (!Array.isArray(res.loaded) || !res.loaded.length || !Array.isArray(res.changing) || res.changing.length)
1664
1672
  return undefined;
@@ -1668,11 +1676,45 @@ class CaptchaKrakenSolver {
1668
1676
  console.log('[captchakraken] [recaptcha-grid] the board never finished loading; asking about it as it stands');
1669
1677
  return verdict === true;
1670
1678
  }
1679
+ /**
1680
+ * The board's tiles as [x0, y0, x1, y1] pixels of `shotPath`, a screenshot of `captchaElement`, in reading order.
1681
+ *
1682
+ * Read from the vendor's own markup, not the picture: a tile is where the challenge frame placed it. Tile and
1683
+ * iframe boxes are both in page pixels, so a tile less the iframe's corner, scaled, lands on the screenshot.
1684
+ * Null when the vendor names no tiles or the frame shows fewer than four.
1685
+ */
1686
+ async domGrid(captchaElement, shotPath) {
1687
+ const tiles = this.sel.selectors[kinds_1.Vendor.RECAPTCHA].tiles ?? [];
1688
+ const dims = readPngDimensions(shotPath);
1689
+ if (!tiles.length || !dims)
1690
+ return null;
1691
+ try {
1692
+ const frame = await captchaElement.contentFrame();
1693
+ const box = await captchaElement.boundingBox();
1694
+ if (!frame || !box || box.width <= 0 || box.height <= 0)
1695
+ return null;
1696
+ const sx = dims.width / box.width;
1697
+ const sy = dims.height / box.height;
1698
+ const boxes = [];
1699
+ for (const tile of await frame.locator(tiles.join(',')).all()) {
1700
+ const r = await (await tile.elementHandle({ timeout: 1000 }))?.boundingBox();
1701
+ if (!r || r.width <= 0 || r.height <= 0)
1702
+ continue;
1703
+ const x0 = r.x - box.x;
1704
+ const y0 = r.y - box.y;
1705
+ boxes.push([Math.round(x0 * sx), Math.round(y0 * sy), Math.round((x0 + r.width) * sx), Math.round((y0 + r.height) * sy)]);
1706
+ }
1707
+ return boxes.length >= 4 ? boxes : null;
1708
+ }
1709
+ catch {
1710
+ return null;
1711
+ }
1712
+ }
1671
1713
  async getGridBoxes(captchaElement) {
1672
1714
  const f = tmp('findgrid');
1673
1715
  try {
1674
1716
  await this.shot(captchaElement, f);
1675
- const res = await this.runCvTool('find-grid', { image: f }, ['find-grid', f]);
1717
+ const res = await this.domGrid(captchaElement, f);
1676
1718
  const dims = readPngDimensions(f);
1677
1719
  if (!Array.isArray(res) || (res.length !== 9 && res.length !== 16) || !dims)
1678
1720
  return null;
@@ -2424,13 +2466,15 @@ class CaptchaKrakenSolver {
2424
2466
  const log = this.verdicts;
2425
2467
  return !!log?.listening && log.exchanges === this.exchangesAtAnswer;
2426
2468
  }
2427
- /** The board's identity, always from a plain photograph: a filmed frame of an unchanged board differs in bytes. */
2428
- async boardHash(element, shot, filmed) {
2429
- if (!filmed)
2430
- return sha1(shot);
2469
+ /**
2470
+ * The board's identity, from a photograph of its own: a filmed frame of an unchanged board differs in bytes, and so
2471
+ * does one wearing the vendor's verdict message, a toast that comes and goes over the same board (see
2472
+ * TRIBAL_KNOWLEDGE.md). The message is left out of the picture, not waited out.
2473
+ */
2474
+ async boardHash(element) {
2431
2475
  const plain = tmp('board');
2432
2476
  try {
2433
- await this.shot(element, plain, this.config.elementScreenshotTimeoutMs ?? 8000);
2477
+ await this.shot(element, plain, this.config.elementScreenshotTimeoutMs ?? 8000, 'disabled', this.feedbackHidden);
2434
2478
  return sha1(plain);
2435
2479
  }
2436
2480
  finally {
@@ -2924,30 +2968,116 @@ class CaptchaKrakenSolver {
2924
2968
  return first ? handleOf(first) : null;
2925
2969
  }
2926
2970
  /**
2927
- * The track of the first of the vendor's own slider handles that is visible with its centre outside the widget
2928
- * element's box. It is looked for in the widget, then in its parent and grandparent: Yidun's `.yidun_slider` is in
2971
+ * The vendor's own `bar`, else the track of its first slider handle, visible with its centre outside the widget
2972
+ * element's box. The bar is what Yidun's click modes need: `.yidun_control` holds the 请依次点击 prompt that names the
2973
+ * marks and their order, and on the bare `.yidun_panel` the pointer was shown neither (live 0/6 on 2026-11-13). The
2974
+ * 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
2929
2975
  * `.yidun_control`, a sibling of the `.yidun_panel` the widget resolves to. A match inside the widget is passed over,
2930
2976
  * not taken as the answer: Yidun lists its piece (`.yidun_jigsaw`, in the panel) as a handle too. The track (the
2931
2977
  * handle's parent) is returned rather than the handle, whose box moves as it slides and would resize the frame.
2932
2978
  */
2979
+ /**
2980
+ * The element whose screenshot the model is shown for `widget`, and the text box when it is typed. This is the whole
2981
+ * of what the client PHOTOGRAPHS, kept in one place so the capture gate can check it without solving: the widget,
2982
+ * else the board its frame pads (Proton), widened by a text box beside it (BotDetect) or by the vendor's bar or
2983
+ * slider track outside it (Yidun).
2984
+ */
2985
+ async framed(widget, frame, scope) {
2986
+ const puzzleSource = widget.vendor;
2987
+ let element = widget.el;
2988
+ // A widget frame that pads its board (Proton) is photographed by the board inside it.
2989
+ const board = await this.boardInside(frame, puzzleSource);
2990
+ if (board) {
2991
+ console.log('The widget frame pads its board; photographing the board itself.');
2992
+ element = board;
2993
+ }
2994
+ // Only the DOM can tell a typed captcha from a click puzzle; hCaptcha and reCAPTCHA never type.
2995
+ const answerBox = VENDORS_WITH_BESPOKE_HANDLING.has(puzzleSource) ? null : await this.answerBox(scope, widget.at);
2996
+ if (answerBox) {
2997
+ console.log('Widget has a text box; solving as a distorted-text captcha.');
2998
+ element = withAnswerBox(element, answerBox);
2999
+ }
3000
+ else if (!VENDORS_WITH_BESPOKE_HANDLING.has(puzzleSource)) {
3001
+ const track = await this.trackOutside(scope, puzzleSource, element, widget.at);
3002
+ if (track) {
3003
+ console.log('The vendor bar or slider track sits outside the widget; photographing the two as one.');
3004
+ element = withAnswerBox(element, track, SLIDER_TRACK_MAX_GROWTH);
3005
+ }
3006
+ }
3007
+ return { element, answerBox };
3008
+ }
3009
+ /**
3010
+ * The widget on `page` and the element the solver would photograph for it, without solving anything. For release
3011
+ * gates: whether the client finds a vendor's widget, by its selectors and URL markers, and frames the whole board,
3012
+ * is checkable on a live page at no inference cost. A checkbox widget is returned with its own element.
3013
+ */
3014
+ async capture(page) {
3015
+ const widget = await this.detectCaptcha(page);
3016
+ if (!widget)
3017
+ return null;
3018
+ if (widget.role === kinds_1.FrameRole.CHECKBOX)
3019
+ return { widget, element: widget.el };
3020
+ const frame = await widget.el.contentFrame();
3021
+ if (widget.vendor !== kinds_1.Vendor.RECAPTCHA)
3022
+ await this.waitForBoardPainted(widget.el);
3023
+ const { element } = await this.framed(widget, frame, frame ?? widget.at);
3024
+ return { widget, element };
3025
+ }
3026
+ /**
3027
+ * The vendor's own `board`, found in the widget's frame or a frame nested in it, or null. Proton's widget frame is
3028
+ * 682x600 with its 370x534 `.protonCaptchaContainer` centred two frames down; the pointer trained on that container,
3029
+ * and shown the padded frame it repeated one answer until the solve gave up (live 0/2 on 2026-11-13). The board is
3030
+ * drawn a moment after the frame, so it is waited for briefly.
3031
+ */
3032
+ async boardInside(frame, vendor) {
3033
+ const own = this.sel.selectors[vendor]?.board;
3034
+ if (!own?.length || !frame)
3035
+ return null;
3036
+ const deadline = Date.now() + BOARD_INSIDE_WAIT_MS;
3037
+ for (;;) {
3038
+ try {
3039
+ const frames = [frame];
3040
+ while (frames.length) {
3041
+ const where = frames.shift();
3042
+ for (const found of await visible(where, own)) {
3043
+ const handle = await handleOf(found);
3044
+ if (handle && (await handle.boundingBox()))
3045
+ return handle;
3046
+ }
3047
+ frames.push(...(where.childFrames?.() ?? []));
3048
+ }
3049
+ }
3050
+ catch {
3051
+ return null;
3052
+ }
3053
+ if (Date.now() >= deadline)
3054
+ return null;
3055
+ await delay(DETECTION_POLL_MS);
3056
+ }
3057
+ }
2933
3058
  async trackOutside(scope, vendor, el, at) {
2934
- const own = this.sel.selectors[vendor]?.sliderHandle;
2935
- if (!own?.length)
3059
+ const mine = this.sel.selectors[vendor];
3060
+ const kinds = [[mine?.bar, true], [mine?.sliderHandle, false]].filter(([s]) => s?.length);
3061
+ if (!kinds.length)
2936
3062
  return null;
2937
3063
  // Widening the shot is a nicety: a scope that cannot be searched (a detached frame) leaves the shot as it was.
2938
3064
  try {
2939
3065
  const a = await el.boundingBox();
2940
3066
  if (!a)
2941
3067
  return null;
2942
- for (const where of [scope, ...(at ? [1, 2].map((k) => at.locator(`xpath=ancestor::*[${k}]`)) : [])]) {
2943
- for (const found of await visible(where, own)) {
2944
- const b = await (await handleOf(found))?.boundingBox();
2945
- if (!b)
2946
- continue;
2947
- const cx = b.x + b.width / 2, cy = b.y + b.height / 2;
2948
- if (cx >= a.x && cx <= a.x + a.width && cy >= a.y && cy <= a.y + a.height)
2949
- continue;
2950
- return (await handleOf(found.locator('xpath=..'))) ?? handleOf(found);
3068
+ for (const [own, isBar] of kinds) {
3069
+ for (const where of [scope, ...(at ? [1, 2].map((k) => at.locator(`xpath=ancestor::*[${k}]`)) : [])]) {
3070
+ for (const found of await visible(where, own)) {
3071
+ const b = await (await handleOf(found))?.boundingBox();
3072
+ if (!b)
3073
+ continue;
3074
+ const cx = b.x + b.width / 2, cy = b.y + b.height / 2;
3075
+ if (cx >= a.x && cx <= a.x + a.width && cy >= a.y && cy <= a.y + a.height)
3076
+ continue;
3077
+ if (isBar)
3078
+ return handleOf(found);
3079
+ return (await handleOf(found.locator('xpath=..'))) ?? handleOf(found);
3080
+ }
2951
3081
  }
2952
3082
  }
2953
3083
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "captchakraken",
3
- "version": "4.2.0",
4
- "description": "Captcha solver for Playwright and Puppeteer. Finds the captcha, reads it with the v2 pointer model, and clicks, drags, slides or types through to a token \u2014 reCAPTCHA, GeeTest, NetEase Yidun, Tencent, Lemin, Prosopo, Turnstile and distorted text. Hosted API or self-hosted.",
3
+ "version": "5.0.0-beta.42",
4
+ "description": "Captcha solver for Playwright and Puppeteer. Finds the captcha, reads it with the v2 pointer model, and clicks, drags, slides or types through to a token — reCAPTCHA, GeeTest, NetEase Yidun, Tencent, Lemin, Prosopo, Turnstile and distorted text. Hosted API or self-hosted.",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
7
7
  "bin": {
package/python/AGENTS.md CHANGED
@@ -64,8 +64,8 @@ captchakraken path/to/captcha.png # prints a JSON click plan
64
64
 
65
65
  Other CLI modes, all printing JSON: `captchakraken server start|stop|status|run`
66
66
  manages a local vLLM server, `captchakraken fetch` updates weights and the
67
- serving stack together, and the detector tool calls (`find-grid`, `find-checkbox`,
68
- `get-numbered-grid`, `detect-selected`, …) are exposed one per subcommand. The
67
+ serving stack together, and the pixel tool calls (`find-checkbox`,
68
+ `grid-cell-states-fixed`) are exposed one per subcommand. The
69
69
  module docstring of `captchakraken/cli.py` lists every mode with its arguments.
70
70
 
71
71
  ## 4. Errors
@@ -92,8 +92,9 @@ succeed.
92
92
 
93
93
  ## 5. If you drive the model yourself
94
94
 
95
- Grid screenshots must be sent with **cell numbers drawn on them** — the client
96
- runs `find_grid`, renders the numbered overlay, and sends that image, because
95
+ Grid screenshots sent to a chat model must have **cell numbers drawn on them** —
96
+ the client reads the cell boxes from the reCAPTCHA challenge frame's tiles,
97
+ renders the numbered overlay, and sends that image, because
97
98
  the model reads those labels and was never trained to invent a numbering.
98
99
  Without the overlay reCAPTCHA 4×4 scores zero without erroring. Image area is
99
100
  also clamped into the `pixel_budget` the model declares in
package/python/README.md CHANGED
@@ -95,7 +95,7 @@ captchakraken server start | stop | status | run
95
95
  ## Usage
96
96
 
97
97
  ```bash
98
- # Solve an image/video: classify → find_grid → plan. Prints the click actions.
98
+ # Solve an image/video: classify → plan. Prints the click actions.
99
99
  captchakraken path/to/captcha.png
100
100
  captchakraken path/to/captcha.png --puzzle-source recaptcha
101
101
  ```
@@ -107,8 +107,8 @@ solver = CaptchaSolver() # connects to / auto-starts a local vLLM
107
107
  actions = solver.solve("captcha.png")
108
108
  ```
109
109
 
110
- Element-detector tool subcommands (CPU only, no planner model): `find-grid`, `find-checkbox`,
111
- `detect-selected`, `grid-cell-states`, and a persistent `serve` worker the browser driver polls.
110
+ Pixel tool subcommands (CPU only, no model): `find-checkbox`, `grid-cell-states-fixed`
111
+ (takes the grid boxes as JSON), and a persistent `serve` worker the browser driver polls.
112
112
 
113
113
  ## Configuration (model-agnostic)
114
114
 
@@ -123,9 +123,6 @@ Everything model-specific lives in `captchakraken.config` and is env-overridable
123
123
  | `CAPTCHA_LORA_ADAPTER` | Captcha adapter (HF id or path) | `CaptchaKraken/CaptchaKraken-Lora-v1.2` |
124
124
  | `CAPTCHA_LORA_NAME` | Served adapter name the client requests | `captcha-v12` |
125
125
  | `CAPTCHA_KRAKEN_AUTOSTART` | `0` disables local auto-start | `1` |
126
- | `CAPTCHA_KRAKEN_DETECTOR` | A local element-detector `.onnx` to run instead of downloading the released one | the released weights, fetched once |
127
- | `CAPTCHA_KRAKEN_DETECTOR_MODEL` | Which released detector runs: `lite` (MobileNetV3, about 100 ms a board on one vCPU), `standard` (ResNet-18), or `auto`; overrides `detector` in `captchakraken.config.json` | the config's `detector`, shipped as `auto`: `lite` on two usable CPUs or fewer (a container's CPU quota included), else one board is timed and `standard` runs when it fits in 200 ms |
128
- | `HF_TOKEN` | A Hugging Face token, sent only when downloading the detector weights from a private copy of their repo | unset: the download sends no credential |
129
126
  | `CAPTCHA_HUMANIZATION` | How gestures are performed: `mouse`, `mobile` or `none` | `mouse` |
130
127
 
131
128
  **How it moves** is a choice of input device, not a realism dial. `mobile`
@@ -4,8 +4,8 @@ build-backend = "hatchling.build"
4
4
 
5
5
  [project]
6
6
  name = "captchakraken"
7
- version = "4.2.0"
8
- description = "Captcha-solving engine and CLI: a v2 pointer model and CNN element detector for image grids, click and drag puzzles, sliders, distorted text and animated challenges. Hosted API or self-hosted on vLLM."
7
+ version = "5.0.0b42"
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
- # Runs the element detector (find_grid, find_checkbox) on the CPU. Its
57
- # wheels cover CPython 3.11-3.14 on Linux x86_64/aarch64, Windows and Apple
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",
@@ -100,4 +100,4 @@ __all__ = [
100
100
  "PauseKind",
101
101
  ]
102
102
 
103
- __version__ = "4.2.0"
103
+ __version__ = "5.0.0b42"
@@ -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",
@@ -29,7 +22,9 @@
29
22
  "`hold_completes` (true or false). `note` is for people, not the solver.",
30
23
  "",
31
24
  "generic: the fallbacks tried after every vendor's own. `submit_text` is the",
32
- "button text probed for a submit control, in order.",
25
+ "button text probed for a submit control, in order. `feedback` (CSS only) names the",
26
+ "verdict messages, such as a \"Please try again\" toast, that the photograph telling",
27
+ "one board from the next leaves out; every vendor's `banners` are left out too.",
33
28
  "",
34
29
  "Keys starting with `_` are comments. Field reference: `_fields`."
35
30
  ],
@@ -45,17 +40,19 @@
45
40
  "accepted": "On the host page: the vendor painted its success state. Visibility is part of the test (see TRIBAL_KNOWLEDGE.md).",
46
41
  "fresh": "Inside the challenge frame: a new round has painted, with text.",
47
42
  "images": "Inside the challenge frame: the pictures a board is made of; the driver waits for each to have painted.",
43
+ "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
44
  "submit": "Inside the widget: the vendor's own submit control, tried after the generic text probes.",
49
45
  "banners": "Inside the challenge frame: verdict banners and what each means.",
50
46
  "blocked": "Inside the challenge frame: the vendor refusing to serve this client at all. Nothing after it can succeed.",
51
47
  "passive": "On the host page: the vendor's frames that are never interactive, so a page showing only these has no widget.",
52
48
  "text_input": "Inside the widget, and its enclosing fieldset/form: the answer box of a typed captcha.",
53
49
  "slider_handle": "Inside the widget: the knob a slide must start on; a drag from the piece moves nothing.",
50
+ "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.",
51
+ "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
52
  "piece": "Inside the widget: the piece, measured to steer the slide and dragged directly when there is no track.",
55
53
  "refresh": "Inside the widget: the control that deals a new puzzle, pressed when the model answers `refresh`.",
56
54
  "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
55
  },
58
- "detector": "auto",
59
56
  "custom": null,
60
57
  "vendors": {
61
58
  "recaptcha": {
@@ -78,6 +75,9 @@
78
75
  "#recaptcha-anchor"
79
76
  ],
80
77
  "fresh": ".rc-imageselect-instructions, #rc-imageselect",
78
+ "tiles": [
79
+ "td.rc-imageselect-tile"
80
+ ],
81
81
  "submit": [
82
82
  "#recaptcha-verify-button"
83
83
  ],
@@ -228,6 +228,9 @@
228
228
  ".yidun_slider",
229
229
  ".yidun_jigsaw"
230
230
  ],
231
+ "bar": [
232
+ ".yidun_control"
233
+ ],
231
234
  "piece": [
232
235
  ".yidun_jigsaw"
233
236
  ],
@@ -305,6 +308,11 @@
305
308
  "input[id*=validateCaptcha]",
306
309
  ".BDC_CaptchaDiv input[type=text]"
307
310
  ],
311
+ "submit": [
312
+ "input#validateCaptchaButton",
313
+ "input[type=submit][id*=\"validateCaptcha\" i]",
314
+ "button[id*=\"validateCaptcha\" i]"
315
+ ],
308
316
  "refresh": [
309
317
  "a[id*=\"ReloadLink\"]",
310
318
  ".BDC_ReloadIcon"
@@ -375,6 +383,9 @@
375
383
  ],
376
384
  "widget": [
377
385
  "iframe[src*=\"/core/v4/captcha\"]"
386
+ ],
387
+ "board": [
388
+ ".protonCaptchaContainer"
378
389
  ]
379
390
  },
380
391
  "datadome": {
@@ -395,6 +406,24 @@
395
406
  "#captcha__reload__button"
396
407
  ]
397
408
  },
409
+ "cybersiara": {
410
+ "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.",
411
+ "hosts": [
412
+ "mycybersiara.com"
413
+ ],
414
+ "widget": [
415
+ "#myModal .pluginPopups:has(#Img_Original)",
416
+ ".pluginPopups:has(img.cy-sa-si-main-img)"
417
+ ],
418
+ "text_input": [
419
+ "#Input_Captcha",
420
+ ".cy-sa-page-2 input.Uinput"
421
+ ],
422
+ "refresh": [
423
+ "#a_Refresh",
424
+ ".pluginPopups a.ref_icon"
425
+ ]
426
+ },
398
427
  "unknown": {
399
428
  "hosts": []
400
429
  }
@@ -429,6 +458,11 @@
429
458
  "piece": [
430
459
  "[class*=\"puzzle\"][class*=\"piece\"]",
431
460
  "[class*=\"jigsaw\"]"
461
+ ],
462
+ "feedback": [
463
+ "[role=\"alert\"]",
464
+ "[class*=\"toast\" i]",
465
+ "[id*=\"toast\" i]"
432
466
  ]
433
467
  }
434
468
  }