captchakraken 3.2.0 → 4.0.0

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 (60) hide show
  1. package/AGENTS.md +5 -9
  2. package/LICENSE +165 -145
  3. package/NOTICE +4 -4
  4. package/README.md +10 -11
  5. package/dist/cli-invocation.d.ts +6 -3
  6. package/dist/cli-invocation.js +26 -10
  7. package/dist/humanize.d.ts +37 -1
  8. package/dist/humanize.js +143 -9
  9. package/dist/index.d.ts +13 -12
  10. package/dist/index.js +25 -33
  11. package/dist/kinds.d.ts +15 -2
  12. package/dist/kinds.js +12 -4
  13. package/dist/playwright-types.d.ts +3 -0
  14. package/dist/selectors.d.ts +96 -11
  15. package/dist/selectors.js +226 -112
  16. package/dist/solver.d.ts +93 -13
  17. package/dist/solver.js +579 -208
  18. package/dist/types.d.ts +53 -8
  19. package/dist/verdicts.d.ts +3 -0
  20. package/dist/verdicts.js +6 -0
  21. package/package.json +4 -4
  22. package/python/AGENTS.md +7 -11
  23. package/python/LICENSE +165 -145
  24. package/python/NOTICE +4 -4
  25. package/python/README.md +10 -9
  26. package/python/pyproject.toml +27 -13
  27. package/python/src/captchakraken/__init__.py +43 -46
  28. package/python/src/captchakraken/action_types.py +32 -1
  29. package/python/src/captchakraken/captchakraken.config.json +416 -0
  30. package/python/src/captchakraken/cli.py +66 -30
  31. package/python/src/captchakraken/clipvideo.py +258 -0
  32. package/python/src/captchakraken/humanize.py +141 -10
  33. package/python/src/captchakraken/image_processor.py +3 -7
  34. package/python/src/captchakraken/keyframes.py +96 -14
  35. package/python/src/captchakraken/kinds.py +14 -2
  36. package/python/src/captchakraken/models.json +28 -3
  37. package/python/src/captchakraken/page_solver.py +621 -259
  38. package/python/src/captchakraken/planner.py +298 -47
  39. package/python/src/captchakraken/pointer/__init__.py +20 -0
  40. package/python/src/captchakraken/pointer/detector.py +333 -0
  41. package/python/src/captchakraken/pointer/elements.py +273 -0
  42. package/python/src/captchakraken/pointer/heads.py +163 -0
  43. package/python/src/captchakraken/pointer/layout.py +319 -0
  44. package/python/src/captchakraken/pointer/marks.py +184 -0
  45. package/python/src/captchakraken/pointer/server.py +146 -0
  46. package/python/src/captchakraken/pointer/service.py +553 -0
  47. package/python/src/captchakraken/pointer/vllm_plugin.py +109 -0
  48. package/python/src/captchakraken/prompts.py +111 -34
  49. package/python/src/captchakraken/selectors.py +224 -131
  50. package/python/src/captchakraken/server_manager.py +18 -0
  51. package/python/src/captchakraken/solver.py +169 -88
  52. package/python/src/captchakraken/tool_calls/board_painted.py +11 -6
  53. package/python/src/captchakraken/tool_calls/fill_tracker.py +152 -0
  54. package/python/src/captchakraken/tool_calls/find_checkbox.py +14 -59
  55. package/python/src/captchakraken/tool_calls/find_grid.py +273 -1191
  56. package/python/src/captchakraken/tool_calls/slide_tracker.py +1102 -0
  57. package/python/src/captchakraken/verdicts.py +16 -0
  58. package/dist/slide-geometry.d.ts +0 -6
  59. package/dist/slide-geometry.js +0 -38
  60. package/python/src/captchakraken/tool_calls/track_piece.py +0 -120
package/AGENTS.md CHANGED
@@ -96,15 +96,11 @@ where one exists. Retrying a `403` that means "no licence" will never succeed.
96
96
  - **Never print an API key** into a transcript, a log, or a commit. Use
97
97
  `create_api_key`, which writes it to disk instead. `captchakraken.env` and
98
98
  `.env` hold keys and are never committed.
99
- - **Abyss is what our hosted API serves, and it is never downloadable.** The
100
- current client names an Abyss expert on every request to our endpoint and is
101
- answered by Abyss; an older client, or a request that names no model, gets
102
- Twilight v1.2, because its prompts belong to that generation. Nothing about it
103
- is gated on the account. Do not suggest weights, a download or a workaround
104
- for it, and do not quote accuracy figures for it — none are published. Verify
105
- what is serving with `GET /v1/models`.
106
- - **Respect the licence.** Building automation with this is fine; selling the
107
- solve, or shipping it inside a browser or automation product, is not. See
99
+ - **Midnight V2 4B Q4 is the default self-hosted and hosted model.** The v2
100
+ weights are downloadable under LGPL-3.0-only. Older clients keep using their
101
+ registered chat-completion model because the protocols are not interchangeable.
102
+ - **Respect the licence.** CaptchaKraken and all its models are LGPL-3.0-only;
103
+ commercial use and integration are permitted under those terms. See
108
104
  [LICENSE](./LICENSE) and
109
105
  [docs/licensing.md](https://github.com/CaptchaKraken/CaptchaKraken/blob/main/docs/licensing.md).
110
106
  - **Changing this package's own code?** Its rules are in
package/LICENSE CHANGED
@@ -1,145 +1,165 @@
1
- CaptchaKraken Source-Available License v1.1
2
- Copyright (c) 2026 CaptchaKraken LLC. All rights reserved.
3
-
4
- This license governs use of the CaptchaKraken software in this repository and of
5
- the associated machine-learning model weights and LoRA adapters published by the
6
- copyright holder (collectively, the "Software"). By using the Software you agree
7
- to these terms. If you do not agree, do not use the Software.
8
-
9
- ================================================================================
10
- 1. GRANT
11
- ================================================================================
12
- Subject to the restrictions below, you are granted a worldwide, royalty-free,
13
- non-exclusive license to use, copy, modify, and distribute the Software, and to
14
- incorporate it into your own products and services.
15
-
16
- ================================================================================
17
- 2. PERMITTED USES
18
- ================================================================================
19
- You MAY use the Software for:
20
-
21
- (a) Personal, non-commercial use, research, and education.
22
-
23
- (b) Commercial use INSIDE a larger product or service that delivers
24
- substantial value BEYOND captcha solving itself — that is, where captcha
25
- solving is an internal, enabling component rather than the product.
26
-
27
- Illustrative (non-exhaustive) examples of PERMITTED commercial use:
28
- - Web scrapers and data-collection pipelines.
29
- - Browser automation you build and operate for your own purposes.
30
- - QA, testing, and accessibility tooling.
31
- - Any application where the captcha solve is a means to an end the user
32
- is actually paying for.
33
-
34
- (c) RUNNING the Software alongside a stealth, anti-detection, or antidetect
35
- browser — Camoufox, Puppeteer, Playwright, or any similar tool — to
36
- automate your own work, commercially or otherwise. Section 3(d) restricts
37
- SHIPPING the Software as a feature of such a browser to other people. It
38
- does not restrict USING it with one.
39
-
40
- ================================================================================
41
- 3. PROHIBITED USES
42
- ================================================================================
43
- You MAY NOT, without a separate written commercial agreement from the copyright
44
- holder:
45
-
46
- (a) Sell, resell, rent, or otherwise offer for a fee any captcha-SOLVING
47
- service, product, or API whose primary value is solving captchas,
48
- where that service is powered by the Software or its model outputs.
49
-
50
- (b) Distribute "thin wrappers" around the Software whose primary purpose is
51
- captcha solving — including but not limited to browser extensions,
52
- hosted endpoints, SaaS products, or CLIs that simply expose the
53
- Software's solving capability to end users.
54
-
55
- (c) Expose, proxy, or relay the responses or outputs of the Software's LoRA
56
- models (e.g. bounding boxes, tile selections, click plans) through a paid
57
- or public API as a captcha-solving service.
58
-
59
- (d) Embed, bundle, preinstall, or otherwise ship the Software — or a client,
60
- wrapper, plugin, or extension for it — as a captcha-solving capability of
61
- any stealth browser, anti-detection or antidetect browser, browser
62
- profile or identity manager, or browser-automation product or platform
63
- that you distribute, host, or otherwise offer to third parties. This
64
- applies whether the Software ships inside your distribution, is fetched
65
- on demand, or is merely wired up and advertised as a supported
66
- integration, and it applies whether or not you charge for it.
67
-
68
- This restriction is about DISTRIBUTION, not use. Nothing in it limits
69
- Section 2(c): a person who uses such a browser may install and run the
70
- Software with it freely.
71
-
72
- In short: you may BUILD WITH this Software, and you may USE it with whatever
73
- browser you like — but you may not SELL THE SOLVE, and you may not SHIP THE
74
- SOLVE as a feature of a stealth browser or automation product you hand to
75
- other people.
76
-
77
- ================================================================================
78
- 4. MODEL OUTPUTS
79
- ================================================================================
80
- Outputs produced by the model weights/adapters are subject to Sections 2 and 3
81
- to the same extent as the Software itself. Reselling or API-relaying those
82
- outputs as a captcha-solving service is prohibited under Section 3(c).
83
-
84
- ================================================================================
85
- 5. REDISTRIBUTION
86
- ================================================================================
87
- If you redistribute the Software (modified or not), you must retain this license
88
- and this notice, and you must not remove or alter the restrictions in Section 3.
89
- The right to redistribute granted by Section 1 is subject to Section 3(d).
90
-
91
- ================================================================================
92
- 6. TRADEMARKS
93
- ================================================================================
94
- This license does not grant permission to use the trade names, trademarks, or
95
- product names of the copyright holder, except as required to describe the origin
96
- of the Software.
97
-
98
- ================================================================================
99
- 7. NO WARRANTY
100
- ================================================================================
101
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
102
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
103
- FOR A PARTICULAR PURPOSE, AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
104
- COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES, OR OTHER LIABILITY, WHETHER
105
- IN AN ACTION OF CONTRACT, TORT, OR OTHERWISE, ARISING FROM, OUT OF, OR IN
106
- CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
107
-
108
- ================================================================================
109
- 8. RESPONSIBLE USE
110
- ================================================================================
111
- You are responsible for ensuring your use of the Software complies with all
112
- applicable laws, the terms of service of any site you interact with, and
113
- applicable anti-fraud and computer-access statutes. The copyright holder does
114
- not endorse using the Software to violate any third party's terms or rights.
115
-
116
- ================================================================================
117
- 9. COMMERCIAL LICENSING
118
- ================================================================================
119
- For uses prohibited under Section 3 — including selling captcha-solving as a
120
- service, and shipping the Software as a built-in capability of a stealth browser
121
- or automation product — contact the copyright holder to discuss a separate
122
- commercial license. These uses are licensable; they are not categorically
123
- refused.
124
-
125
- ================================================================================
126
- 10. VERSION HISTORY
127
- ================================================================================
128
- v1.1 — Section 3(d) added: shipping the Software as a captcha-solving feature of
129
- a stealth/anti-detection browser or automation product distributed to
130
- third parties now requires a commercial license. Section 2(c) added to
131
- make clear that USING the Software with such a browser remains permitted.
132
- The v1.0 text listed "stealth / anti-detection browsers" as an
133
- illustrative PERMITTED commercial use; that example is removed.
134
- v1.0 — Initial release.
135
-
136
- Each version applies to the releases distributed under it. Copies obtained under
137
- v1.0 remain governed by v1.0.
138
-
139
- --------------------------------------------------------------------------------
140
- This text is a license, not legal advice. If the boundary between a permitted
141
- "value-add" product and a prohibited "thin wrapper", or between using the
142
- Software with a browser and shipping it as part of one, is unclear for your use
143
- case, ask by opening an issue or messaging the maintainer on GitHub:
144
- https://github.com/CaptchaKraken/CaptchaKraken
145
- --------------------------------------------------------------------------------
1
+ GNU LESSER GENERAL PUBLIC LICENSE
2
+ Version 3, 29 June 2007
3
+
4
+ Copyright (C) 2007 Free Software Foundation, Inc. <https://fsf.org/>
5
+ Everyone is permitted to copy and distribute verbatim copies
6
+ of this license document, but changing it is not allowed.
7
+
8
+
9
+ This version of the GNU Lesser General Public License incorporates
10
+ the terms and conditions of version 3 of the GNU General Public
11
+ License, supplemented by the additional permissions listed below.
12
+
13
+ 0. Additional Definitions.
14
+
15
+ As used herein, "this License" refers to version 3 of the GNU Lesser
16
+ General Public License, and the "GNU GPL" refers to version 3 of the GNU
17
+ General Public License.
18
+
19
+ "The Library" refers to a covered work governed by this License,
20
+ other than an Application or a Combined Work as defined below.
21
+
22
+ An "Application" is any work that makes use of an interface provided
23
+ by the Library, but which is not otherwise based on the Library.
24
+ Defining a subclass of a class defined by the Library is deemed a mode
25
+ of using an interface provided by the Library.
26
+
27
+ A "Combined Work" is a work produced by combining or linking an
28
+ Application with the Library. The particular version of the Library
29
+ with which the Combined Work was made is also called the "Linked
30
+ Version".
31
+
32
+ The "Minimal Corresponding Source" for a Combined Work means the
33
+ Corresponding Source for the Combined Work, excluding any source code
34
+ for portions of the Combined Work that, considered in isolation, are
35
+ based on the Application, and not on the Linked Version.
36
+
37
+ The "Corresponding Application Code" for a Combined Work means the
38
+ object code and/or source code for the Application, including any data
39
+ and utility programs needed for reproducing the Combined Work from the
40
+ Application, but excluding the System Libraries of the Combined Work.
41
+
42
+ 1. Exception to Section 3 of the GNU GPL.
43
+
44
+ You may convey a covered work under sections 3 and 4 of this License
45
+ without being bound by section 3 of the GNU GPL.
46
+
47
+ 2. Conveying Modified Versions.
48
+
49
+ If you modify a copy of the Library, and, in your modifications, a
50
+ facility refers to a function or data to be supplied by an Application
51
+ that uses the facility (other than as an argument passed when the
52
+ facility is invoked), then you may convey a copy of the modified
53
+ version:
54
+
55
+ a) under this License, provided that you make a good faith effort to
56
+ ensure that, in the event an Application does not supply the
57
+ function or data, the facility still operates, and performs
58
+ whatever part of its purpose remains meaningful, or
59
+
60
+ b) under the GNU GPL, with none of the additional permissions of
61
+ this License applicable to that copy.
62
+
63
+ 3. Object Code Incorporating Material from Library Header Files.
64
+
65
+ The object code form of an Application may incorporate material from
66
+ a header file that is part of the Library. You may convey such object
67
+ code under terms of your choice, provided that, if the incorporated
68
+ material is not limited to numerical parameters, data structure
69
+ layouts and accessors, or small macros, inline functions and templates
70
+ (ten or fewer lines in length), you do both of the following:
71
+
72
+ a) Give prominent notice with each copy of the object code that the
73
+ Library is used in it and that the Library and its use are
74
+ covered by this License.
75
+
76
+ b) Accompany the object code with a copy of the GNU GPL and this license
77
+ document.
78
+
79
+ 4. Combined Works.
80
+
81
+ You may convey a Combined Work under terms of your choice that,
82
+ taken together, effectively do not restrict modification of the
83
+ portions of the Library contained in the Combined Work and reverse
84
+ engineering for debugging such modifications, if you also do each of
85
+ the following:
86
+
87
+ a) Give prominent notice with each copy of the Combined Work that
88
+ the Library is used in it and that the Library and its use are
89
+ covered by this License.
90
+
91
+ b) Accompany the Combined Work with a copy of the GNU GPL and this license
92
+ document.
93
+
94
+ c) For a Combined Work that displays copyright notices during
95
+ execution, include the copyright notice for the Library among
96
+ these notices, as well as a reference directing the user to the
97
+ copies of the GNU GPL and this license document.
98
+
99
+ d) Do one of the following:
100
+
101
+ 0) Convey the Minimal Corresponding Source under the terms of this
102
+ License, and the Corresponding Application Code in a form
103
+ suitable for, and under terms that permit, the user to
104
+ recombine or relink the Application with a modified version of
105
+ the Linked Version to produce a modified Combined Work, in the
106
+ manner specified by section 6 of the GNU GPL for conveying
107
+ Corresponding Source.
108
+
109
+ 1) Use a suitable shared library mechanism for linking with the
110
+ Library. A suitable mechanism is one that (a) uses at run time
111
+ a copy of the Library already present on the user's computer
112
+ system, and (b) will operate properly with a modified version
113
+ of the Library that is interface-compatible with the Linked
114
+ Version.
115
+
116
+ e) Provide Installation Information, but only if you would otherwise
117
+ be required to provide such information under section 6 of the
118
+ GNU GPL, and only to the extent that such information is
119
+ necessary to install and execute a modified version of the
120
+ Combined Work produced by recombining or relinking the
121
+ Application with a modified version of the Linked Version. (If
122
+ you use option 4d0, the Installation Information must accompany
123
+ the Minimal Corresponding Source and Corresponding Application
124
+ Code. If you use option 4d1, you must provide the Installation
125
+ Information in the manner specified by section 6 of the GNU GPL
126
+ for conveying Corresponding Source.)
127
+
128
+ 5. Combined Libraries.
129
+
130
+ You may place library facilities that are a work based on the
131
+ Library side by side in a single library together with other library
132
+ facilities that are not Applications and are not covered by this
133
+ License, and convey such a combined library under terms of your
134
+ choice, if you do both of the following:
135
+
136
+ a) Accompany the combined library with a copy of the same work based
137
+ on the Library, uncombined with any other library facilities,
138
+ conveyed under the terms of this License.
139
+
140
+ b) Give prominent notice with the combined library that part of it
141
+ is a work based on the Library, and explaining where to find the
142
+ accompanying uncombined form of the same work.
143
+
144
+ 6. Revised Versions of the GNU Lesser General Public License.
145
+
146
+ The Free Software Foundation may publish revised and/or new versions
147
+ of the GNU Lesser General Public License from time to time. Such new
148
+ versions will be similar in spirit to the present version, but may
149
+ differ in detail to address new problems or concerns.
150
+
151
+ Each version is given a distinguishing version number. If the
152
+ Library as you received it specifies that a certain numbered version
153
+ of the GNU Lesser General Public License "or any later version"
154
+ applies to it, you have the option of following the terms and
155
+ conditions either of that published version or of any later version
156
+ published by the Free Software Foundation. If the Library as you
157
+ received it does not specify a version number of the GNU Lesser
158
+ General Public License, you may choose any version of the GNU Lesser
159
+ General Public License ever published by the Free Software Foundation.
160
+
161
+ If the Library as you received it specifies that a proxy can decide
162
+ whether future versions of the GNU Lesser General Public License shall
163
+ apply, that proxy's public statement of acceptance of any version is
164
+ permanent authorization for you to choose that version for the
165
+ Library.
package/NOTICE CHANGED
@@ -1,10 +1,10 @@
1
1
  CaptchaKraken
2
- Copyright (c) 2026 CaptchaKraken LLC. All rights reserved.
2
+ Copyright (c) 2026 CaptchaKraken LLC.
3
3
 
4
4
  This product includes third-party software. The notices below are required by
5
- those components' licences and do not change the terms of the CaptchaKraken
6
- Source-Available License, which governs everything in this repository that is
7
- not listed here.
5
+ those components' licences and do not change the terms of the GNU Lesser
6
+ General Public License, version 3 only (LGPL-3.0-only), which governs
7
+ everything in this repository that is not listed here.
8
8
 
9
9
  ────────────────────────────────────────────────────────────────────────────
10
10
  Cursory — mouse trajectory generation
package/README.md CHANGED
@@ -10,8 +10,8 @@
10
10
  </p>
11
11
 
12
12
  Hand it a Playwright or Puppeteer `Page`. It finds the captcha, reads the whole
13
- puzzle with a fine-tuned **Qwen3.5-9B** vision model, and clicks, drags, slides
14
- or types human-like through to a token.
13
+ puzzle with the **v2 pointer model**, and clicks, drags, slides or types
14
+ human-like through to a token.
15
15
 
16
16
  Run the model on **your own hardware**, or point it at the **hosted API** and run
17
17
  nothing at all.
@@ -155,9 +155,10 @@ Full details, including writing your own humanizer:
155
155
  | `VLLM_BASE_URL` | Inference endpoint (local vLLM, a server you run, or `https://api.captchakraken.com/v1`) | credentials file, else `http://localhost:8000/v1` |
156
156
  | `CAPTCHA_KRAKEN_API_KEY` | Bearer token (`VLLM_API_KEY` also accepted) | credentials file, else `EMPTY` |
157
157
  | `CAPTCHA_HUMANIZATION` | How gestures are performed: `mouse`, `mobile` or `none`. Loses to anything set in code | `mouse` |
158
- | `CAPTCHA_BASE_MODEL` | Base weights vLLM loads | `RedHatAI/Qwen3.5-9B-FP8-dynamic` |
159
- | `CAPTCHA_LORA_ADAPTER` | Captcha adapter (HF id or path) | `CaptchaKraken/CaptchaKraken-Lora-v1.2` |
160
- | `CAPTCHA_LORA_NAME` | Served adapter name sent as `model` | `captcha-v12` |
158
+ | `CAPTCHA_BASE_MODEL` | Merged v2 weights vLLM loads | `CaptchaKraken/MidnightV2-4B-q4` |
159
+ | `CAPTCHA_LORA_ADAPTER` | Model repository (HF id or path) | `CaptchaKraken/MidnightV2-4B-q4` |
160
+ | `CAPTCHA_LORA_NAME` | Served model name sent as `model` | `captcha-pointer` |
161
+ | `CAPTCHA_POINTER_DETECTOR` | CNN element detector | path written by `setup.sh` |
161
162
  | `CAPTCHA_KRAKEN_AUTOSTART` | `0` never auto-starts a local server | `1` |
162
163
  | `CAPTCHA_KRAKEN_PYTHON` | Interpreter used for the bundled engine | the package's venv, else `python3` |
163
164
  | `CAPTCHA_KRAKEN_SKIP_PYTHON_SETUP` | `1` skips the `postinstall` bootstrap | unset |
@@ -175,9 +176,7 @@ the vLLM server knobs, are in
175
176
 
176
177
  ## License
177
178
 
178
- **CaptchaKraken Source-Available License v1.1** — see [LICENSE](./LICENSE).
179
- Build *with* it (scrapers, QA tooling) and run it against **any** browser you
180
- like, stealth or not. You may **not sell the solve itself**, ship a thin wrapper
181
- (browser extension, hosted solving API), or **bundle it as a built-in feature of
182
- a stealth/antidetect browser you distribute** — using it with one is fine. Those
183
- three are licensable, not categorically refused: open an issue to ask.
179
+ **LGPL-3.0-only** — see [LICENSE](./LICENSE). Use, modify and redistribute it,
180
+ including in commercial and hosted services. If you distribute a modified
181
+ version, keep the licence and copyright notices and make your changes available
182
+ under LGPLv3.
@@ -1,6 +1,6 @@
1
1
  import type { PromptFamily, RetryMode, Vendor } from './kinds.js';
2
+ import type { CliResponse } from './types.js';
2
3
  export declare const API_KEY_ENV = "CAPTCHA_KRAKEN_API_KEY";
3
- export declare const RESAMPLE_LEVEL_ENV = "CAPTCHA_RESAMPLE_LEVEL";
4
4
  export declare const API_PROVIDER = "captchaKrakenApi";
5
5
  export interface SolveInvocation {
6
6
  imagePath: string;
@@ -9,9 +9,12 @@ export interface SolveInvocation {
9
9
  retryMode?: RetryMode | null;
10
10
  textMode?: boolean;
11
11
  expert?: PromptFamily | null;
12
+ /** Earlier screens of the same paged puzzle, oldest first. */
13
+ history?: string[];
12
14
  }
13
15
  /** An argv array for execFile, never a shell string. */
14
16
  export declare function buildSolveArgs(invocation: SolveInvocation): string[];
15
- /** The resample LEVEL travels, not a temperature: the schedule lives once in planner.RESAMPLE_TEMPERATURES, and a fresh CLI process cannot know the round count. */
16
- export declare function solveEnv(base: NodeJS.ProcessEnv, apiKey?: string, resampleLevel?: number): NodeJS.ProcessEnv;
17
+ export declare function solveEnv(base: NodeJS.ProcessEnv, apiKey?: string): NodeJS.ProcessEnv;
17
18
  export declare function redactCommand(command: string, apiKey?: string): string;
19
+ /** What the CLI printed, as one response: the answer, the server's other plans for it, and the usage. */
20
+ export declare function parseSolveOutput(stdout: string): CliResponse;
@@ -1,16 +1,16 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.API_PROVIDER = exports.RESAMPLE_LEVEL_ENV = exports.API_KEY_ENV = void 0;
3
+ exports.API_PROVIDER = exports.API_KEY_ENV = void 0;
4
4
  exports.buildSolveArgs = buildSolveArgs;
5
5
  exports.solveEnv = solveEnv;
6
6
  exports.redactCommand = redactCommand;
7
+ exports.parseSolveOutput = parseSolveOutput;
7
8
  // The key travels in env, never argv: argv is world-readable on Linux via /proc/<pid>/cmdline and `ps`. See TRIBAL_KNOWLEDGE.md.
8
9
  exports.API_KEY_ENV = 'CAPTCHA_KRAKEN_API_KEY';
9
- exports.RESAMPLE_LEVEL_ENV = 'CAPTCHA_RESAMPLE_LEVEL';
10
10
  exports.API_PROVIDER = 'captchaKrakenApi';
11
11
  /** An argv array for execFile, never a shell string. */
12
12
  function buildSolveArgs(invocation) {
13
- const { imagePath, model, puzzleSource, retryMode, textMode, expert } = invocation;
13
+ const { imagePath, model, puzzleSource, retryMode, textMode, expert, history } = invocation;
14
14
  const args = ['-m', 'captchakraken.cli', imagePath];
15
15
  // Both positionals or neither: the provider passed alone would bind to `model`.
16
16
  if (model)
@@ -20,20 +20,36 @@ function buildSolveArgs(invocation) {
20
20
  args.push(`--retry-mode=${retryMode}`);
21
21
  if (textMode)
22
22
  args.push('--text-mode');
23
+ for (const screen of history ?? [])
24
+ args.push(`--history=${screen}`);
23
25
  if (expert)
24
26
  args.push(`--expert=${expert}`);
25
27
  return args;
26
28
  }
27
- /** The resample LEVEL travels, not a temperature: the schedule lives once in planner.RESAMPLE_TEMPERATURES, and a fresh CLI process cannot know the round count. */
28
- function solveEnv(base, apiKey, resampleLevel) {
29
- const out = apiKey ? { ...base, [exports.API_KEY_ENV]: apiKey } : { ...base };
30
- if (resampleLevel && resampleLevel > 0) {
31
- out[exports.RESAMPLE_LEVEL_ENV] = String(resampleLevel);
32
- }
33
- return out;
29
+ function solveEnv(base, apiKey) {
30
+ return apiKey ? { ...base, [exports.API_KEY_ENV]: apiKey } : { ...base };
34
31
  }
35
32
  function redactCommand(command, apiKey) {
36
33
  if (!apiKey)
37
34
  return command;
38
35
  return command.split(apiKey).join('***');
39
36
  }
37
+ /** What the CLI printed, as one response: the answer, the server's other plans for it, and the usage. */
38
+ function parseSolveOutput(stdout) {
39
+ let actions = [];
40
+ for (const line of stdout.trim().split('\n')) {
41
+ try {
42
+ const parsed = JSON.parse(line);
43
+ if (parsed.actions !== undefined && parsed.token_usage !== undefined) {
44
+ return { actions: parsed.actions, token_usage: parsed.token_usage,
45
+ ...(Array.isArray(parsed.fallbacks) ? { fallbacks: parsed.fallbacks } : {}) };
46
+ }
47
+ if (Array.isArray(parsed))
48
+ actions = parsed;
49
+ else if (parsed.action && (parsed.target_bounding_box || parsed.target_coordinates || parsed.action === 'wait'))
50
+ actions = [parsed];
51
+ }
52
+ catch { /* not json or not relevant */ }
53
+ }
54
+ return { actions, token_usage: [] };
55
+ }
@@ -14,10 +14,24 @@ import type { Page, PlaywrightElementHandle } from './playwright-types.js';
14
14
  import { HumanizationMode, PauseKind } from './kinds.js';
15
15
  export type { HumanizationMode, PauseKind } from './kinds.js';
16
16
  export type Point = [number, number];
17
- /** A recorded human movement morphed onto the endpoints; timings are cumulative ms. */
17
+ export declare const gauss: (sigma: number) => number;
18
+ export declare const MAX_EVENT_GAP_MS = 8;
19
+ export declare const MAX_EVENT_STEP_PX = 16;
20
+ export declare const MAX_DEVIATION = 0.15;
21
+ export declare const MIN_DEVIATION_PX = 3;
22
+ /** A recorded human movement morphed onto the endpoints, held near the line between them and sampled at least
23
+ * once per mouse report; timings are cumulative ms. */
18
24
  export declare function trajectory(start: Point, end: Point, frequency: number): [Point[], number[]];
19
25
  /** Every inter-gesture wait the driver takes, named, so each device supplies its own table. */
20
26
  export declare const PAUSE_KINDS: readonly PauseKind[];
27
+ /** How often a held press looks at the widget, in ms: a frame hash per look, so not every frame. */
28
+ export declare const HOLD_POLL_MS: readonly [number, number];
29
+ /**
30
+ * Press at `to` until `done()` says the widget completed, or `maxMs` passes; true when it completed.
31
+ * Built on move/press/release so any humanizer can hold. The hand drifts a pixel or so meanwhile, because a
32
+ * press that does not move for seconds is a synthetic one, and the button is released whatever `done` throws.
33
+ */
34
+ export declare function hold(human: Humanizer, page: Page, to: Point, done: () => Promise<boolean>, maxMs: number): Promise<boolean>;
21
35
  export interface Humanizer {
22
36
  readonly name: string;
23
37
  /** False on a device with no resting cursor; switches off every hover-for-realism behaviour. */
@@ -25,6 +39,8 @@ export interface Humanizer {
25
39
  at: Point;
26
40
  reset(page: Page): Promise<void>;
27
41
  move(page: Page, to: Point): Promise<void>;
42
+ /** A pixel of wander while held; a humanizer without it drifts with `move`. */
43
+ drift?(page: Page, to: Point): Promise<void>;
28
44
  press(page: Page): Promise<void>;
29
45
  release(page: Page): Promise<void>;
30
46
  click(page: Page, to: Point): Promise<void>;
@@ -41,6 +57,11 @@ export declare abstract class BaseHumanizer implements Humanizer {
41
57
  constructor(start?: Point);
42
58
  reset(_page: Page): Promise<void>;
43
59
  abstract move(page: Page, to: Point): Promise<void>;
60
+ /**
61
+ * A held hand's pixel of wander. `move` is a reach, and a reach overshoots: on a 1px move it wandered up to 34px,
62
+ * off a thin bar, which the widget takes for a release.
63
+ */
64
+ drift(page: Page, to: Point): Promise<void>;
44
65
  abstract press(page: Page): Promise<void>;
45
66
  abstract release(page: Page): Promise<void>;
46
67
  abstract typeText(page: Page, field: PlaywrightElementHandle, text: string): Promise<boolean>;
@@ -50,16 +71,30 @@ export declare abstract class BaseHumanizer implements Humanizer {
50
71
  click(page: Page, to: Point): Promise<void>;
51
72
  drag(page: Page, src: Point, dst: Point): Promise<void>;
52
73
  }
74
+ /** How much longer than the bare round trip a step takes when the browser re-draws it as a path of its own. */
75
+ export declare const BROWSER_PATH_MS = 100;
53
76
  export declare class MouseHumanizer extends BaseHumanizer {
54
77
  readonly name: HumanizationMode;
55
78
  readonly hovers = true;
56
79
  protected readonly pauses: PauseTable;
57
80
  private frequency;
58
81
  private viewportCache;
82
+ /** Undefined until the first move of a solve measures it. */
83
+ private browserDrawsPath;
59
84
  constructor(start?: Point, frequency?: number);
60
85
  reset(_page: Page): Promise<void>;
61
86
  /** The window to keep the cursor inside; null under camoufox, which reports no viewport and whose window we ask instead. */
62
87
  private viewport;
88
+ drift(page: Page, to: Point): Promise<void>;
89
+ /** Clamp only when the viewport is known: a coordinate pinned to the edge of a guessed one deadlocks camoufox's juggler (upstream #225). */
90
+ private clamp;
91
+ /**
92
+ * Whether the browser draws its own path for every mouse.move(), as camoufox's humanize does. Ours on top has every
93
+ * sample re-drawn: a 1px step took 190ms there against 1ms, and one GeeTest slider 82s against 13s. One short step
94
+ * towards `to`, timed against a zero-length move (the bare round trip, so a remote browser is not mistaken for
95
+ * one), tells them apart with no movement the page could single out.
96
+ */
97
+ private measureBrowserPath;
63
98
  move(page: Page, to: Point): Promise<void>;
64
99
  press(page: Page): Promise<void>;
65
100
  release(page: Page): Promise<void>;
@@ -154,6 +189,7 @@ export declare class MobileHumanizer extends BaseHumanizer {
154
189
  reset(page: Page): Promise<void>;
155
190
  private touch;
156
191
  move(page: Page, to: Point): Promise<void>;
192
+ drift(page: Page, to: Point): Promise<void>;
157
193
  press(page: Page): Promise<void>;
158
194
  release(page: Page): Promise<void>;
159
195
  /** A tap whose contact patch wobbles a pixel while held; a motionless tap is a synthetic one. */