@weavetab/mcp 2.5.0-beta.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 +48 -0
- package/ARCHITECTURE.md +590 -0
- package/LICENSE +631 -0
- package/README.md +909 -0
- package/SECURITY.md +196 -0
- package/TROUBLESHOOTING.md +365 -0
- package/dist/anticaptcha/detector.d.ts +49 -0
- package/dist/anticaptcha/detector.js +465 -0
- package/dist/anticaptcha/integration.d.ts +36 -0
- package/dist/anticaptcha/integration.js +123 -0
- package/dist/anticaptcha/solver.d.ts +27 -0
- package/dist/anticaptcha/solver.js +552 -0
- package/dist/audit/logger.d.ts +13 -0
- package/dist/audit/logger.js +177 -0
- package/dist/audit/telemetry.d.ts +36 -0
- package/dist/audit/telemetry.js +162 -0
- package/dist/cdp/bridge.d.ts +16 -0
- package/dist/cdp/bridge.js +826 -0
- package/dist/cdp/confirm.d.ts +26 -0
- package/dist/cdp/confirm.js +79 -0
- package/dist/cdp/connector.d.ts +37 -0
- package/dist/cdp/connector.js +661 -0
- package/dist/cdp/extension.d.ts +36 -0
- package/dist/cdp/extension.js +118 -0
- package/dist/cdp/finder.d.ts +1 -0
- package/dist/cdp/finder.js +2 -0
- package/dist/cdp/helpers.d.ts +11 -0
- package/dist/cdp/helpers.js +195 -0
- package/dist/cdp/label_cache.d.ts +12 -0
- package/dist/cdp/label_cache.js +51 -0
- package/dist/cdp/lock.d.ts +33 -0
- package/dist/cdp/lock.js +206 -0
- package/dist/cdp/omni_broker.d.ts +17 -0
- package/dist/cdp/omni_broker.js +119 -0
- package/dist/cdp/profiles.d.ts +1 -0
- package/dist/cdp/profiles.js +87 -0
- package/dist/cdp/pruner.d.ts +41 -0
- package/dist/cdp/pruner.js +263 -0
- package/dist/cdp/ref_cache.d.ts +101 -0
- package/dist/cdp/ref_cache.js +234 -0
- package/dist/cdp/retry.d.ts +5 -0
- package/dist/cdp/retry.js +39 -0
- package/dist/cdp/retry_enhanced.d.ts +44 -0
- package/dist/cdp/retry_enhanced.js +102 -0
- package/dist/cdp/security.d.ts +50 -0
- package/dist/cdp/security.js +237 -0
- package/dist/cdp/verify.d.ts +39 -0
- package/dist/cdp/verify.js +143 -0
- package/dist/cdp/walker.d.ts +91 -0
- package/dist/cdp/walker.js +896 -0
- package/dist/cdp/walker.test.d.ts +2 -0
- package/dist/cdp/walker.test.js +172 -0
- package/dist/cdp/websocket_transport.d.ts +15 -0
- package/dist/cdp/websocket_transport.js +118 -0
- package/dist/cli/plugin.d.ts +9 -0
- package/dist/cli/plugin.js +1134 -0
- package/dist/cli/updater.d.ts +1 -0
- package/dist/cli/updater.js +72 -0
- package/dist/config/loader.d.ts +120 -0
- package/dist/config/loader.js +704 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +1248 -0
- package/dist/intelligence/hints.d.ts +11 -0
- package/dist/intelligence/hints.js +39 -0
- package/dist/intelligence/intent.d.ts +33 -0
- package/dist/intelligence/intent.js +171 -0
- package/dist/intelligence/sessionMemory.d.ts +66 -0
- package/dist/intelligence/sessionMemory.js +284 -0
- package/dist/intelligence/sessionMemory.test.d.ts +2 -0
- package/dist/intelligence/sessionMemory.test.js +62 -0
- package/dist/intelligence/trail.d.ts +64 -0
- package/dist/intelligence/trail.js +233 -0
- package/dist/intelligence/trail.test.d.ts +2 -0
- package/dist/intelligence/trail.test.js +110 -0
- package/dist/intelligence/vision.d.ts +24 -0
- package/dist/intelligence/vision.js +151 -0
- package/dist/lifecycle/mission_manager.d.ts +16 -0
- package/dist/lifecycle/mission_manager.js +44 -0
- package/dist/overlay/bubble.d.ts +16 -0
- package/dist/overlay/bubble.js +37 -0
- package/dist/overlay/ghost.d.ts +35 -0
- package/dist/overlay/ghost.js +508 -0
- package/dist/overlay/injector.d.ts +22 -0
- package/dist/overlay/injector.js +198 -0
- package/dist/plugin/interface.d.ts +134 -0
- package/dist/plugin/interface.js +1 -0
- package/dist/plugin/loader.d.ts +18 -0
- package/dist/plugin/loader.js +155 -0
- package/dist/plugin/registry.d.ts +50 -0
- package/dist/plugin/registry.js +234 -0
- package/dist/security/blacklist.d.ts +24 -0
- package/dist/security/blacklist.js +80 -0
- package/dist/security/filter.d.ts +2 -0
- package/dist/security/filter.js +20 -0
- package/dist/security/guard.d.ts +8 -0
- package/dist/security/guard.js +35 -0
- package/dist/security/ratelimit.d.ts +11 -0
- package/dist/security/ratelimit.js +57 -0
- package/dist/security/secrets.d.ts +75 -0
- package/dist/security/secrets.js +365 -0
- package/dist/sensors/actionability.d.ts +81 -0
- package/dist/sensors/actionability.js +303 -0
- package/dist/sensors/guard.d.ts +25 -0
- package/dist/sensors/guard.js +168 -0
- package/dist/sensors/mutations.d.ts +23 -0
- package/dist/sensors/mutations.js +93 -0
- package/dist/sensors/network.d.ts +67 -0
- package/dist/sensors/network.js +193 -0
- package/dist/sensors/operation_monitor.d.ts +80 -0
- package/dist/sensors/operation_monitor.js +203 -0
- package/dist/sensors/pacing.d.ts +44 -0
- package/dist/sensors/pacing.js +111 -0
- package/dist/sensors/thoughts.d.ts +2 -0
- package/dist/sensors/thoughts.js +59 -0
- package/dist/sensors/wait.d.ts +12 -0
- package/dist/sensors/wait.js +44 -0
- package/dist/server.d.ts +7 -0
- package/dist/server.js +1687 -0
- package/dist/state/agent.d.ts +36 -0
- package/dist/state/agent.js +101 -0
- package/dist/state/cache.d.ts +16 -0
- package/dist/state/cache.js +92 -0
- package/dist/state/cache.test.d.ts +2 -0
- package/dist/state/cache.test.js +76 -0
- package/dist/state/delta.d.ts +71 -0
- package/dist/state/delta.js +234 -0
- package/dist/state/delta.test.d.ts +2 -0
- package/dist/state/delta.test.js +279 -0
- package/dist/state/groups.d.ts +15 -0
- package/dist/state/groups.js +80 -0
- package/dist/state/session.d.ts +30 -0
- package/dist/state/session.js +155 -0
- package/dist/tools/accessibility.d.ts +14 -0
- package/dist/tools/accessibility.js +32 -0
- package/dist/tools/ask.d.ts +14 -0
- package/dist/tools/ask.js +49 -0
- package/dist/tools/automation.d.ts +36 -0
- package/dist/tools/automation.js +218 -0
- package/dist/tools/browser_detect.d.ts +13 -0
- package/dist/tools/browser_detect.js +73 -0
- package/dist/tools/burst.d.ts +35 -0
- package/dist/tools/burst.js +344 -0
- package/dist/tools/canvas.d.ts +25 -0
- package/dist/tools/canvas.js +132 -0
- package/dist/tools/captcha.d.ts +38 -0
- package/dist/tools/captcha.js +209 -0
- package/dist/tools/click.d.ts +36 -0
- package/dist/tools/click.js +561 -0
- package/dist/tools/click_and_wait.d.ts +33 -0
- package/dist/tools/click_and_wait.js +149 -0
- package/dist/tools/clipboard.d.ts +29 -0
- package/dist/tools/clipboard.js +279 -0
- package/dist/tools/console.d.ts +21 -0
- package/dist/tools/console.js +107 -0
- package/dist/tools/cookies.d.ts +67 -0
- package/dist/tools/cookies.js +121 -0
- package/dist/tools/design_extract.d.ts +109 -0
- package/dist/tools/design_extract.js +641 -0
- package/dist/tools/dialog.d.ts +24 -0
- package/dist/tools/dialog.js +109 -0
- package/dist/tools/drag.d.ts +15 -0
- package/dist/tools/drag.js +29 -0
- package/dist/tools/emulation.d.ts +33 -0
- package/dist/tools/emulation.js +69 -0
- package/dist/tools/eval.d.ts +20 -0
- package/dist/tools/eval.js +92 -0
- package/dist/tools/fill.d.ts +41 -0
- package/dist/tools/fill.js +667 -0
- package/dist/tools/find.d.ts +30 -0
- package/dist/tools/find.js +60 -0
- package/dist/tools/geo.d.ts +19 -0
- package/dist/tools/geo.js +29 -0
- package/dist/tools/github/analyze.d.ts +4 -0
- package/dist/tools/github/analyze.js +113 -0
- package/dist/tools/github/cache.d.ts +21 -0
- package/dist/tools/github/cache.js +28 -0
- package/dist/tools/github/index.d.ts +4 -0
- package/dist/tools/github/index.js +4 -0
- package/dist/tools/github/issues.d.ts +9 -0
- package/dist/tools/github/issues.js +88 -0
- package/dist/tools/github/pr.d.ts +5 -0
- package/dist/tools/github/pr.js +88 -0
- package/dist/tools/github/rateLimiter.d.ts +4 -0
- package/dist/tools/github/rateLimiter.js +46 -0
- package/dist/tools/github/read.d.ts +34 -0
- package/dist/tools/github/read.js +74 -0
- package/dist/tools/github/repoContext.d.ts +20 -0
- package/dist/tools/github/repoContext.js +129 -0
- package/dist/tools/highlight.d.ts +20 -0
- package/dist/tools/highlight.js +140 -0
- package/dist/tools/hover.d.ts +19 -0
- package/dist/tools/hover.js +57 -0
- package/dist/tools/inspect.d.ts +17 -0
- package/dist/tools/inspect.js +125 -0
- package/dist/tools/integration.test.d.ts +2 -0
- package/dist/tools/integration.test.js +96 -0
- package/dist/tools/key.d.ts +25 -0
- package/dist/tools/key.js +173 -0
- package/dist/tools/macro_compiler.d.ts +7 -0
- package/dist/tools/macro_compiler.js +82 -0
- package/dist/tools/mouse.d.ts +21 -0
- package/dist/tools/mouse.js +62 -0
- package/dist/tools/navigate.d.ts +16 -0
- package/dist/tools/navigate.js +188 -0
- package/dist/tools/network_intercept.d.ts +17 -0
- package/dist/tools/network_intercept.js +151 -0
- package/dist/tools/office/index.d.ts +9 -0
- package/dist/tools/office/index.js +7 -0
- package/dist/tools/office/list.d.ts +15 -0
- package/dist/tools/office/list.js +41 -0
- package/dist/tools/office/parse.d.ts +20 -0
- package/dist/tools/office/parse.js +172 -0
- package/dist/tools/pdf.d.ts +22 -0
- package/dist/tools/pdf.js +42 -0
- package/dist/tools/performance.d.ts +12 -0
- package/dist/tools/performance.js +47 -0
- package/dist/tools/performance_test.d.ts +70 -0
- package/dist/tools/performance_test.js +128 -0
- package/dist/tools/plan.d.ts +39 -0
- package/dist/tools/plan.js +161 -0
- package/dist/tools/pointer.d.ts +35 -0
- package/dist/tools/pointer.js +522 -0
- package/dist/tools/read.d.ts +30 -0
- package/dist/tools/read.js +488 -0
- package/dist/tools/recording.d.ts +45 -0
- package/dist/tools/recording.js +124 -0
- package/dist/tools/response.d.ts +129 -0
- package/dist/tools/response.js +5 -0
- package/dist/tools/scrape.d.ts +24 -0
- package/dist/tools/scrape.js +140 -0
- package/dist/tools/screenshot.d.ts +40 -0
- package/dist/tools/screenshot.js +79 -0
- package/dist/tools/scroll.d.ts +23 -0
- package/dist/tools/scroll.js +196 -0
- package/dist/tools/select.d.ts +13 -0
- package/dist/tools/select.js +217 -0
- package/dist/tools/snapshot.d.ts +27 -0
- package/dist/tools/snapshot.js +99 -0
- package/dist/tools/storage.d.ts +18 -0
- package/dist/tools/storage.js +29 -0
- package/dist/tools/tabs.d.ts +77 -0
- package/dist/tools/tabs.js +342 -0
- package/dist/tools/thought.d.ts +16 -0
- package/dist/tools/thought.js +79 -0
- package/dist/tools/type.d.ts +65 -0
- package/dist/tools/type.js +1061 -0
- package/dist/tools/type_secret.d.ts +23 -0
- package/dist/tools/type_secret.js +229 -0
- package/dist/tools/upload.d.ts +19 -0
- package/dist/tools/upload.js +103 -0
- package/dist/tools/video_compiler.d.ts +24 -0
- package/dist/tools/video_compiler.js +199 -0
- package/dist/tools/viewport.d.ts +44 -0
- package/dist/tools/viewport.js +230 -0
- package/dist/tools/wait.d.ts +19 -0
- package/dist/tools/wait.js +202 -0
- package/dist/tools/wait_for.d.ts +23 -0
- package/dist/tools/wait_for.js +30 -0
- package/dist/tools/windows.d.ts +22 -0
- package/dist/tools/windows.js +57 -0
- package/dist/ui/index.d.ts +1 -0
- package/dist/ui/index.js +12 -0
- package/docs/DEV_MODE.md +68 -0
- package/docs/DOCUMENTATION.md +532 -0
- package/docs/PLUGINS.md +538 -0
- package/docs/TOOLS.md +104 -0
- package/docs/dev_plugin.md +310 -0
- package/ext-dist/background.js +467 -0
- package/ext-dist/content.js +3089 -0
- package/ext-dist/dashboard.html +583 -0
- package/ext-dist/hud/hud.js +73 -0
- package/ext-dist/hud/index.html +20 -0
- package/ext-dist/manifest.json +77 -0
- package/ext-dist/sidepanel/sidepanel.js +25 -0
- package/ext-dist/sidepanel.html +547 -0
- package/ext-dist/styles.css +218 -0
- package/icon.png +0 -0
- package/mcp.json +796 -0
- package/package.json +113 -0
- package/server.json +23 -0
- package/smithery.yaml +11 -0
|
@@ -0,0 +1,209 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Weavetab — tools/captcha.ts
|
|
3
|
+
* Dedicated browser_captcha tool for autonomous CAPTCHA detection and solving.
|
|
4
|
+
*
|
|
5
|
+
* Actions:
|
|
6
|
+
* detect → Identify CAPTCHA type, interaction method, and confidence
|
|
7
|
+
* solve → Attempt full autonomous solve (slider drag, hold, checkbox, invisible)
|
|
8
|
+
* wait_for_user → Show HUD prompt and poll until CAPTCHA is gone (120s timeout)
|
|
9
|
+
* status → Quick check: is a CAPTCHA currently blocking?
|
|
10
|
+
*
|
|
11
|
+
* Zero API keys. All solving via CDP mouse simulation.
|
|
12
|
+
* Weavetab by fy2ne
|
|
13
|
+
*/
|
|
14
|
+
import { detectCaptcha, quickCaptchaCheck, isCaptchaBlocking } from "../anticaptcha/detector.js";
|
|
15
|
+
import { solveCaptcha } from "../anticaptcha/solver.js";
|
|
16
|
+
import { sendToExtension } from "../cdp/helpers.js";
|
|
17
|
+
import { logAction } from "../audit/logger.js";
|
|
18
|
+
export async function browserCaptcha(session, args, _config) {
|
|
19
|
+
const t0 = Date.now();
|
|
20
|
+
const { action, timeout = 120000 } = args;
|
|
21
|
+
try {
|
|
22
|
+
switch (action) {
|
|
23
|
+
// ── detect ─────────────────────────────────────────────────────────────
|
|
24
|
+
case "detect": {
|
|
25
|
+
const detection = await detectCaptcha(session);
|
|
26
|
+
logAction("browser_captcha", "detect", detection.type);
|
|
27
|
+
if (!detection.detected) {
|
|
28
|
+
return {
|
|
29
|
+
success: true,
|
|
30
|
+
action: "detect",
|
|
31
|
+
captcha_detected: false,
|
|
32
|
+
human_needed: false,
|
|
33
|
+
message: "No CAPTCHA detected on this page.",
|
|
34
|
+
next_action: "Continue with your task.",
|
|
35
|
+
execution_ms: Date.now() - t0,
|
|
36
|
+
};
|
|
37
|
+
}
|
|
38
|
+
return {
|
|
39
|
+
success: true,
|
|
40
|
+
action: "detect",
|
|
41
|
+
captcha_detected: true,
|
|
42
|
+
captcha_type: detection.type,
|
|
43
|
+
interaction_type: detection.interactionType,
|
|
44
|
+
difficulty: detection.difficulty,
|
|
45
|
+
confidence: detection.confidence,
|
|
46
|
+
human_needed: false,
|
|
47
|
+
message: `CAPTCHA detected: ${detection.type} (${detection.interactionType}, ${Math.round(detection.confidence * 100)}% confidence)`,
|
|
48
|
+
next_action: `Call browser_captcha({ action: "solve" }) to attempt automated solving.`,
|
|
49
|
+
execution_ms: Date.now() - t0,
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
// ── solve ───────────────────────────────────────────────────────────────
|
|
53
|
+
case "solve": {
|
|
54
|
+
const detection = await detectCaptcha(session);
|
|
55
|
+
if (!detection.detected) {
|
|
56
|
+
return {
|
|
57
|
+
success: true,
|
|
58
|
+
action: "solve",
|
|
59
|
+
captcha_detected: false,
|
|
60
|
+
human_needed: false,
|
|
61
|
+
message: "No CAPTCHA found — nothing to solve.",
|
|
62
|
+
next_action: "Continue with your task.",
|
|
63
|
+
execution_ms: Date.now() - t0,
|
|
64
|
+
};
|
|
65
|
+
}
|
|
66
|
+
await sendToExtension(session, {
|
|
67
|
+
type: "Weavetab_STATE",
|
|
68
|
+
hud: { action: `Solving ${detection.type} (${detection.interactionType})…` },
|
|
69
|
+
}).catch(() => { });
|
|
70
|
+
logAction("browser_captcha", "solve", `${detection.type}/${detection.interactionType}`);
|
|
71
|
+
const solution = await solveCaptcha(session, detection);
|
|
72
|
+
if (solution.solved) {
|
|
73
|
+
await sendToExtension(session, {
|
|
74
|
+
type: "Weavetab_STATE",
|
|
75
|
+
hud: { action: `✓ CAPTCHA solved` },
|
|
76
|
+
}).catch(() => { });
|
|
77
|
+
return {
|
|
78
|
+
success: true,
|
|
79
|
+
action: "solve",
|
|
80
|
+
captcha_detected: true,
|
|
81
|
+
captcha_type: detection.type,
|
|
82
|
+
interaction_type: detection.interactionType,
|
|
83
|
+
confidence: solution.confidence,
|
|
84
|
+
human_needed: false,
|
|
85
|
+
solved: true,
|
|
86
|
+
solve_method: solution.method,
|
|
87
|
+
message: `CAPTCHA solved automatically using ${solution.method}.`,
|
|
88
|
+
next_action: "Continue with your task. Wait ~500ms for page to settle if needed.",
|
|
89
|
+
execution_ms: Date.now() - t0,
|
|
90
|
+
};
|
|
91
|
+
}
|
|
92
|
+
// Automated failed — should user be notified?
|
|
93
|
+
if (solution.requiresUserIntervention) {
|
|
94
|
+
const isVisionAssisted = solution.method === "vision_assisted";
|
|
95
|
+
await sendToExtension(session, {
|
|
96
|
+
type: "Weavetab_STATE",
|
|
97
|
+
hud: { action: isVisionAssisted ? `AI Vision required` : `CAPTCHA needs you` },
|
|
98
|
+
}).catch(() => { });
|
|
99
|
+
return {
|
|
100
|
+
success: false,
|
|
101
|
+
action: "solve",
|
|
102
|
+
captcha_detected: true,
|
|
103
|
+
captcha_type: detection.type,
|
|
104
|
+
interaction_type: detection.interactionType,
|
|
105
|
+
human_needed: !isVisionAssisted,
|
|
106
|
+
solved: false,
|
|
107
|
+
solve_method: solution.method,
|
|
108
|
+
message: isVisionAssisted
|
|
109
|
+
? "Automated DOM solve skipped. This CAPTCHA requires your visual intelligence to solve."
|
|
110
|
+
: "Automated solve attempted but CAPTCHA requires human interaction.",
|
|
111
|
+
user_instructions: solution.userInstructions,
|
|
112
|
+
next_action: isVisionAssisted
|
|
113
|
+
? "Take a screenshot to view the CAPTCHA, then use browser_click or browser_type to solve it yourself. Do not ask the user for help."
|
|
114
|
+
: `Call browser_thought({ action: "question", message: "${solution.userInstructions}" }) to ask the user to complete it, then call browser_captcha({ action: "wait_for_user" }).`,
|
|
115
|
+
execution_ms: Date.now() - t0,
|
|
116
|
+
};
|
|
117
|
+
}
|
|
118
|
+
return {
|
|
119
|
+
success: false,
|
|
120
|
+
action: "solve",
|
|
121
|
+
captcha_detected: true,
|
|
122
|
+
captcha_type: detection.type,
|
|
123
|
+
human_needed: false,
|
|
124
|
+
solved: false,
|
|
125
|
+
message: "Automated solve failed. Retry or call wait_for_user.",
|
|
126
|
+
next_action: `Retry browser_captcha({ action: "solve" }) once, then escalate to browser_captcha({ action: "wait_for_user" }).`,
|
|
127
|
+
execution_ms: Date.now() - t0,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
// ── wait_for_user ───────────────────────────────────────────────────────
|
|
131
|
+
case "wait_for_user": {
|
|
132
|
+
await sendToExtension(session, {
|
|
133
|
+
type: "Weavetab_STATE",
|
|
134
|
+
hud: { action: "⏳ Waiting for CAPTCHA to be solved…" },
|
|
135
|
+
}).catch(() => { });
|
|
136
|
+
logAction("browser_captcha", "wait_for_user", "polling");
|
|
137
|
+
const pollInterval = 1500;
|
|
138
|
+
const maxPolls = Math.floor(timeout / pollInterval);
|
|
139
|
+
let elapsed = 0;
|
|
140
|
+
for (let i = 0; i < maxPolls; i++) {
|
|
141
|
+
await new Promise((r) => setTimeout(r, pollInterval));
|
|
142
|
+
elapsed += pollInterval;
|
|
143
|
+
const stillBlocking = await quickCaptchaCheck(session);
|
|
144
|
+
if (!stillBlocking) {
|
|
145
|
+
await sendToExtension(session, {
|
|
146
|
+
type: "Weavetab_STATE",
|
|
147
|
+
hud: { action: "✓ CAPTCHA cleared" },
|
|
148
|
+
}).catch(() => { });
|
|
149
|
+
return {
|
|
150
|
+
success: true,
|
|
151
|
+
action: "wait_for_user",
|
|
152
|
+
captcha_detected: false,
|
|
153
|
+
human_needed: false,
|
|
154
|
+
solved: true,
|
|
155
|
+
message: `CAPTCHA cleared after ${Math.round(elapsed / 1000)}s.`,
|
|
156
|
+
next_action: "Continue with your task.",
|
|
157
|
+
execution_ms: Date.now() - t0,
|
|
158
|
+
};
|
|
159
|
+
}
|
|
160
|
+
}
|
|
161
|
+
return {
|
|
162
|
+
success: false,
|
|
163
|
+
action: "wait_for_user",
|
|
164
|
+
captcha_detected: true,
|
|
165
|
+
human_needed: true,
|
|
166
|
+
solved: false,
|
|
167
|
+
message: `CAPTCHA still present after ${Math.round(timeout / 1000)}s wait.`,
|
|
168
|
+
user_instructions: "The CAPTCHA was not completed in time. Please solve it and let me know.",
|
|
169
|
+
next_action: "Ask the user to complete the CAPTCHA, then retry.",
|
|
170
|
+
execution_ms: Date.now() - t0,
|
|
171
|
+
};
|
|
172
|
+
}
|
|
173
|
+
// ── status ──────────────────────────────────────────────────────────────
|
|
174
|
+
case "status": {
|
|
175
|
+
const blocking = await isCaptchaBlocking(session);
|
|
176
|
+
return {
|
|
177
|
+
success: true,
|
|
178
|
+
action: "status",
|
|
179
|
+
captcha_detected: blocking,
|
|
180
|
+
human_needed: false,
|
|
181
|
+
message: blocking ? "CAPTCHA is currently blocking the page." : "No blocking CAPTCHA.",
|
|
182
|
+
next_action: blocking
|
|
183
|
+
? `Call browser_captcha({ action: "solve" }) to attempt automated solving.`
|
|
184
|
+
: "Continue with your task.",
|
|
185
|
+
execution_ms: Date.now() - t0,
|
|
186
|
+
};
|
|
187
|
+
}
|
|
188
|
+
default:
|
|
189
|
+
return {
|
|
190
|
+
success: false,
|
|
191
|
+
action: action,
|
|
192
|
+
captcha_detected: false,
|
|
193
|
+
human_needed: false,
|
|
194
|
+
message: `Unknown action: ${action}. Use detect, solve, wait_for_user, or status.`,
|
|
195
|
+
execution_ms: Date.now() - t0,
|
|
196
|
+
};
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
catch (err) {
|
|
200
|
+
return {
|
|
201
|
+
success: false,
|
|
202
|
+
action,
|
|
203
|
+
captcha_detected: false,
|
|
204
|
+
human_needed: false,
|
|
205
|
+
message: `browser_captcha error: ${err instanceof Error ? err.message : String(err)}`,
|
|
206
|
+
execution_ms: Date.now() - t0,
|
|
207
|
+
};
|
|
208
|
+
}
|
|
209
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import CDP from "chrome-remote-interface";
|
|
2
|
+
import type { Config } from "../config/loader.js";
|
|
3
|
+
export interface WeaveError {
|
|
4
|
+
success: false;
|
|
5
|
+
error_code: string;
|
|
6
|
+
message: string;
|
|
7
|
+
suggestion?: string;
|
|
8
|
+
human_needed?: boolean;
|
|
9
|
+
tab_id?: string;
|
|
10
|
+
url?: string;
|
|
11
|
+
}
|
|
12
|
+
export interface ClickResult {
|
|
13
|
+
success: true;
|
|
14
|
+
clicked: string;
|
|
15
|
+
ref: string;
|
|
16
|
+
execution_ms: number;
|
|
17
|
+
tab_id: string;
|
|
18
|
+
url: string;
|
|
19
|
+
title: string;
|
|
20
|
+
url_changed: boolean;
|
|
21
|
+
/** Only present when include_map:true was passed or url_changed is true. */
|
|
22
|
+
page_map?: string;
|
|
23
|
+
dom_changed: boolean;
|
|
24
|
+
stuck_warning: boolean;
|
|
25
|
+
stuck_hint?: string;
|
|
26
|
+
sniper_warning?: string;
|
|
27
|
+
}
|
|
28
|
+
export declare function weaveClick(session: CDP.Client, args: {
|
|
29
|
+
id?: string;
|
|
30
|
+
label?: string;
|
|
31
|
+
intent?: string;
|
|
32
|
+
backendNodeId?: number;
|
|
33
|
+
x?: number;
|
|
34
|
+
y?: number;
|
|
35
|
+
include_map?: boolean;
|
|
36
|
+
}, config: Config): Promise<ClickResult | WeaveError>;
|