captchakraken 4.1.0 → 4.1.1
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/dist/model-name.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ export declare function getBundledCliRoot(): string;
|
|
|
2
2
|
export declare function isHostedEndpoint(baseUrl: string | undefined, env?: NodeJS.ProcessEnv): boolean;
|
|
3
3
|
/** Printed once when a hosted request names a model the endpoint no longer routes; the same text as the Python port's `prompts.LEGACY_MODEL_WARNING`. */
|
|
4
4
|
export declare const LEGACY_MODEL_WARNING: string;
|
|
5
|
-
/** Every name a current client puts on the wire to the hosted API: each routing alias and its expert arms. */
|
|
5
|
+
/** Every name a current client puts on the wire to the hosted API: each routing alias and its expert arms, and the alias of the hosted default (`captcha-pointer` has no arms, and a client sends it unasked). */
|
|
6
6
|
export declare function routedNames(cliRoot?: string): Set<string>;
|
|
7
7
|
/** A name the hosted API serves with an older model: neither a routing alias nor one of its arms. */
|
|
8
8
|
export declare function isLegacyHostedName(model: string | undefined, cliRoot?: string): boolean;
|
package/dist/model-name.js
CHANGED
|
@@ -38,13 +38,15 @@ function isHostedEndpoint(baseUrl, env = process.env) {
|
|
|
38
38
|
/** Printed once when a hosted request names a model the endpoint no longer routes; the same text as the Python port's `prompts.LEGACY_MODEL_WARNING`. */
|
|
39
39
|
exports.LEGACY_MODEL_WARNING = "The hosted API answers the model name '{model}' with an older model. Remove the model "
|
|
40
40
|
+ 'pin (CAPTCHA_LORA_NAME or the model option) to use the current one.';
|
|
41
|
-
/** Every name a current client puts on the wire to the hosted API: each routing alias and its expert arms. */
|
|
41
|
+
/** Every name a current client puts on the wire to the hosted API: each routing alias and its expert arms, and the alias of the hosted default (`captcha-pointer` has no arms, and a client sends it unasked). */
|
|
42
42
|
function routedNames(cliRoot = getBundledCliRoot()) {
|
|
43
43
|
const out = new Set();
|
|
44
44
|
const reg = readJson(cliRoot, 'models.json');
|
|
45
45
|
for (const [alias, id] of Object.entries(reg?.served_aliases ?? {})) {
|
|
46
46
|
if (alias.startsWith('_') || typeof id !== 'string')
|
|
47
47
|
continue;
|
|
48
|
+
if (id === reg?.hosted_default)
|
|
49
|
+
out.add(alias);
|
|
48
50
|
const declared = reg?.models?.[id]?.experts ?? {};
|
|
49
51
|
const arms = Object.values(kinds_1.PromptFamily).map((family) => declared[family])
|
|
50
52
|
.filter((n) => typeof n === 'string' && n !== '');
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "captchakraken",
|
|
3
|
-
"version": "4.1.
|
|
3
|
+
"version": "4.1.1",
|
|
4
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.",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
package/python/pyproject.toml
CHANGED
|
@@ -4,7 +4,7 @@ build-backend = "hatchling.build"
|
|
|
4
4
|
|
|
5
5
|
[project]
|
|
6
6
|
name = "captchakraken"
|
|
7
|
-
version = "4.1.
|
|
7
|
+
version = "4.1.1"
|
|
8
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."
|
|
9
9
|
readme = "README.md"
|
|
10
10
|
requires-python = ">=3.11"
|
|
@@ -447,8 +447,39 @@ COMMANDS: Dict[str, Callable[[List[str]], Any]] = {
|
|
|
447
447
|
}
|
|
448
448
|
|
|
449
449
|
|
|
450
|
+
# What `captchakraken --help` leads with: the commands a person types. The rest of COMMANDS are the JS port's.
|
|
451
|
+
USER_COMMANDS = """commands:
|
|
452
|
+
fetch choose a model, a GPU and a startup mode, then install and start it
|
|
453
|
+
start start the local server (it stays on until stop)
|
|
454
|
+
stop stop the local server and keep it off
|
|
455
|
+
status show the endpoint, model and whether it is up
|
|
456
|
+
demo [site ...] solve the public demo pages with your setup
|
|
457
|
+
server ensure start the local server if it should be running
|
|
458
|
+
|
|
459
|
+
Run `captchakraken <command> --help` for a command's options.
|
|
460
|
+
Given an image path instead, it solves that one image with these options."""
|
|
461
|
+
|
|
462
|
+
|
|
463
|
+
# `<command> --help` for the commands that take no parser of their own. Asking for help must never act.
|
|
464
|
+
COMMAND_HELP = {
|
|
465
|
+
"start": "usage: captchakraken start\n\nStart the local server set up by `captchakraken fetch`. It stays on until stop.",
|
|
466
|
+
"stop": "usage: captchakraken stop\n\nStop the local server. It stays off, across reboots and solves, until start.",
|
|
467
|
+
"status": "usage: captchakraken status\n\nPrint the endpoint, the model and whether the server is up, as JSON.",
|
|
468
|
+
"demo": ("usage: captchakraken demo [--list] [--headed] [site ...]\n\n"
|
|
469
|
+
"Solve the public demo pages with your setup: all of them, or the sites named.\n"
|
|
470
|
+
" --list list the sites\n --headed show the browser"),
|
|
471
|
+
"server": "usage: captchakraken server {start,ensure,stop,status,run}\n\nManage the local server directly.",
|
|
472
|
+
}
|
|
473
|
+
|
|
474
|
+
|
|
450
475
|
def main():
|
|
451
476
|
argv = sys.argv[1:]
|
|
477
|
+
if not argv:
|
|
478
|
+
argv = ["--help"]
|
|
479
|
+
sys.argv.append("--help")
|
|
480
|
+
if argv[0] in COMMAND_HELP and ("-h" in argv[1:] or "--help" in argv[1:]):
|
|
481
|
+
print(COMMAND_HELP[argv[0]])
|
|
482
|
+
return
|
|
452
483
|
if argv and argv[0] in COMMANDS:
|
|
453
484
|
try:
|
|
454
485
|
result = COMMANDS[argv[0]](argv[1:])
|
|
@@ -461,7 +492,9 @@ def main():
|
|
|
461
492
|
print(json.dumps(result))
|
|
462
493
|
return
|
|
463
494
|
|
|
464
|
-
parser = argparse.ArgumentParser(
|
|
495
|
+
parser = argparse.ArgumentParser(prog="captchakraken", description=USER_COMMANDS,
|
|
496
|
+
usage="%(prog)s <command> [options]\n %(prog)s [options] image_path [model]",
|
|
497
|
+
formatter_class=argparse.RawDescriptionHelpFormatter)
|
|
465
498
|
parser.add_argument("image_path", help="Path to the captcha image or video")
|
|
466
499
|
parser.add_argument("model", nargs="?", default=None, help="Served LoRA name; defaults to models.json's latest.")
|
|
467
500
|
parser.add_argument("api_provider", nargs="?", default="captchaKrakenApi", choices=["captchaKrakenApi"],
|
|
@@ -498,11 +498,15 @@ LEGACY_MODEL_WARNING = ("The hosted API answers the model name '{model}' with an
|
|
|
498
498
|
|
|
499
499
|
|
|
500
500
|
def routed_names() -> set:
|
|
501
|
-
"""Every name a current client puts on the wire to the hosted API: each routing alias and its expert arms
|
|
501
|
+
"""Every name a current client puts on the wire to the hosted API: each routing alias and its expert arms,
|
|
502
|
+
and the alias of the hosted default (`captcha-pointer` has no arms, and a client sends it unasked)."""
|
|
502
503
|
out = set()
|
|
503
|
-
|
|
504
|
+
default = hosted_default_model()
|
|
505
|
+
for alias, target in served_aliases().items():
|
|
504
506
|
if alias.startswith("_"):
|
|
505
507
|
continue
|
|
508
|
+
if default and target == default:
|
|
509
|
+
out.add(alias)
|
|
506
510
|
arms = experts(alias)
|
|
507
511
|
if arms:
|
|
508
512
|
out.add(alias)
|