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.
- package/AGENTS.md +5 -9
- package/LICENSE +165 -145
- package/NOTICE +4 -4
- package/README.md +10 -11
- package/dist/cli-invocation.d.ts +6 -3
- package/dist/cli-invocation.js +26 -10
- package/dist/humanize.d.ts +37 -1
- package/dist/humanize.js +143 -9
- package/dist/index.d.ts +13 -12
- package/dist/index.js +25 -33
- package/dist/kinds.d.ts +15 -2
- package/dist/kinds.js +12 -4
- package/dist/playwright-types.d.ts +3 -0
- package/dist/selectors.d.ts +96 -11
- package/dist/selectors.js +226 -112
- package/dist/solver.d.ts +93 -13
- package/dist/solver.js +579 -208
- package/dist/types.d.ts +53 -8
- package/dist/verdicts.d.ts +3 -0
- package/dist/verdicts.js +6 -0
- package/package.json +4 -4
- package/python/AGENTS.md +7 -11
- package/python/LICENSE +165 -145
- package/python/NOTICE +4 -4
- package/python/README.md +10 -9
- package/python/pyproject.toml +27 -13
- package/python/src/captchakraken/__init__.py +43 -46
- package/python/src/captchakraken/action_types.py +32 -1
- package/python/src/captchakraken/captchakraken.config.json +416 -0
- package/python/src/captchakraken/cli.py +66 -30
- package/python/src/captchakraken/clipvideo.py +258 -0
- package/python/src/captchakraken/humanize.py +141 -10
- package/python/src/captchakraken/image_processor.py +3 -7
- package/python/src/captchakraken/keyframes.py +96 -14
- package/python/src/captchakraken/kinds.py +14 -2
- package/python/src/captchakraken/models.json +28 -3
- package/python/src/captchakraken/page_solver.py +621 -259
- package/python/src/captchakraken/planner.py +298 -47
- package/python/src/captchakraken/pointer/__init__.py +20 -0
- package/python/src/captchakraken/pointer/detector.py +333 -0
- package/python/src/captchakraken/pointer/elements.py +273 -0
- package/python/src/captchakraken/pointer/heads.py +163 -0
- package/python/src/captchakraken/pointer/layout.py +319 -0
- package/python/src/captchakraken/pointer/marks.py +184 -0
- package/python/src/captchakraken/pointer/server.py +146 -0
- package/python/src/captchakraken/pointer/service.py +553 -0
- package/python/src/captchakraken/pointer/vllm_plugin.py +109 -0
- package/python/src/captchakraken/prompts.py +111 -34
- package/python/src/captchakraken/selectors.py +224 -131
- package/python/src/captchakraken/server_manager.py +18 -0
- package/python/src/captchakraken/solver.py +169 -88
- package/python/src/captchakraken/tool_calls/board_painted.py +11 -6
- package/python/src/captchakraken/tool_calls/fill_tracker.py +152 -0
- package/python/src/captchakraken/tool_calls/find_checkbox.py +14 -59
- package/python/src/captchakraken/tool_calls/find_grid.py +273 -1191
- package/python/src/captchakraken/tool_calls/slide_tracker.py +1102 -0
- package/python/src/captchakraken/verdicts.py +16 -0
- package/dist/slide-geometry.d.ts +0 -6
- package/dist/slide-geometry.js +0 -38
- 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
|
-
- **
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
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
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
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.
|
|
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
|
|
6
|
-
|
|
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
|
|
14
|
-
|
|
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` |
|
|
159
|
-
| `CAPTCHA_LORA_ADAPTER` |
|
|
160
|
-
| `CAPTCHA_LORA_NAME` | Served
|
|
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
|
-
**
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
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.
|
package/dist/cli-invocation.d.ts
CHANGED
|
@@ -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
|
-
|
|
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;
|
package/dist/cli-invocation.js
CHANGED
|
@@ -1,16 +1,16 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.API_PROVIDER = exports.
|
|
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
|
-
|
|
28
|
-
|
|
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
|
+
}
|
package/dist/humanize.d.ts
CHANGED
|
@@ -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
|
-
|
|
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. */
|