@andorra-labs/code 0.1.5 → 0.1.7
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/src/account-presentation.js +3 -3
- package/dist/src/agent-execution.d.ts +2 -0
- package/dist/src/agent-execution.js +526 -41
- package/dist/src/agent-mcp-catalog.d.ts +21 -0
- package/dist/src/agent-mcp-catalog.js +40 -0
- package/dist/src/agent-mcp.d.ts +36 -3
- package/dist/src/agent-mcp.js +114 -45
- package/dist/src/app-server/protocol.d.ts +57 -5
- package/dist/src/app-server/protocol.js +18 -1
- package/dist/src/app-server/workspace.d.ts +9 -1
- package/dist/src/app-server/workspace.js +50 -3
- package/dist/src/app-server.d.ts +115 -41
- package/dist/src/app-server.js +1316 -221
- package/dist/src/auth/AuthManager.d.ts +33 -1
- package/dist/src/auth/AuthManager.js +138 -10
- package/dist/src/auth/callback-page.d.ts +4 -0
- package/dist/src/auth/callback-page.js +70 -0
- package/dist/src/auth/callback.d.ts +39 -0
- package/dist/src/auth/callback.js +146 -22
- package/dist/src/auth/index.d.ts +10 -6
- package/dist/src/auth/index.js +2 -2
- package/dist/src/auth/store.d.ts +142 -3
- package/dist/src/auth/store.js +334 -13
- package/dist/src/auth/types.d.ts +17 -1
- package/dist/src/auth-commands.d.ts +11 -2
- package/dist/src/auth-commands.js +14 -7
- package/dist/src/automation-runner.d.ts +9 -0
- package/dist/src/automation-runner.js +22 -1
- package/dist/src/automation-tool.js +18 -3
- package/dist/src/automations.d.ts +5 -0
- package/dist/src/automations.js +11 -1
- package/dist/src/browser-captcha-tool.d.ts +54 -0
- package/dist/src/browser-captcha-tool.js +374 -0
- package/dist/src/browser-panel-tool.d.ts +7 -0
- package/dist/src/browser-panel-tool.js +74 -3
- package/dist/src/browser-runner.js +19 -4
- package/dist/src/browser-server.js +21 -1
- package/dist/src/browser-session.d.ts +16 -0
- package/dist/src/browser-session.js +35 -0
- package/dist/src/browser-ui/app.js +193 -3
- package/dist/src/browser-ui/style.css +15 -1
- package/dist/src/browser-view.d.ts +72 -4
- package/dist/src/browser-view.js +229 -17
- package/dist/src/capabilities.d.ts +9 -3
- package/dist/src/capabilities.js +20 -5
- package/dist/src/capsolver.d.ts +60 -0
- package/dist/src/capsolver.js +101 -0
- package/dist/src/claude-provider.d.ts +6 -0
- package/dist/src/claude-provider.js +34 -3
- package/dist/src/cli-executable.d.ts +33 -0
- package/dist/src/cli-executable.js +64 -0
- package/dist/src/cli-process.d.ts +47 -0
- package/dist/src/cli-process.js +113 -0
- package/dist/src/cli-sign-in.d.ts +68 -0
- package/dist/src/cli-sign-in.js +224 -0
- package/dist/src/cli.js +84 -26
- package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +1 -1
- package/dist/src/code-intelligence/CodeIntelligenceManager.js +5 -5
- package/dist/src/codex-provider.js +12 -0
- package/dist/src/coding-tools.d.ts +5 -0
- package/dist/src/coding-tools.js +98 -53
- package/dist/src/command-output-tap.d.ts +16 -0
- package/dist/src/command-output-tap.js +45 -0
- package/dist/src/command-screens.js +3 -3
- package/dist/src/commands.d.ts +15 -2
- package/dist/src/commands.js +14 -13
- package/dist/src/completion.d.ts +23 -5
- package/dist/src/completion.js +380 -17
- package/dist/src/config.d.ts +61 -0
- package/dist/src/config.js +276 -12
- package/dist/src/context-budget.d.ts +7 -0
- package/dist/src/context-budget.js +18 -1
- package/dist/src/deadline.js +6 -0
- package/dist/src/decision/FactContinuations.d.ts +41 -6
- package/dist/src/decision/FactContinuations.js +211 -64
- package/dist/src/decision/PreparedSteps.js +3 -1
- package/dist/src/decision/checks.d.ts +25 -0
- package/dist/src/decision/checks.js +77 -6
- package/dist/src/delegation-changes.d.ts +109 -0
- package/dist/src/delegation-changes.js +431 -0
- package/dist/src/extensions.d.ts +1 -0
- package/dist/src/extensions.js +16 -3
- package/dist/src/graph-provider-portability.js +2 -2
- package/dist/src/graph-quota.d.ts +1 -1
- package/dist/src/graph-quota.js +1 -1
- package/dist/src/graph-runner.js +35 -21
- package/dist/src/graph-selection.d.ts +6 -0
- package/dist/src/graph-selection.js +10 -0
- package/dist/src/graph-server.d.ts +8 -0
- package/dist/src/graph-server.js +76 -6
- package/dist/src/graph-sync.d.ts +65 -0
- package/dist/src/graph-sync.js +433 -13
- package/dist/src/graph-tool.d.ts +52 -0
- package/dist/src/graph-tool.js +136 -0
- package/dist/src/graph-ui/app.js +272 -50
- package/dist/src/graph-ui/controls.js +6 -0
- package/dist/src/graph-ui/drafts.js +39 -0
- package/dist/src/graph-ui/embed.js +1 -1
- package/dist/src/graph-ui/icons.js +1 -0
- package/dist/src/graph-ui/index.html +2 -2
- package/dist/src/graph-ui/skill-picker.js +242 -0
- package/dist/src/graph-ui/studio.css +7 -5
- package/dist/src/graph-ui/style.css +65 -12
- package/dist/src/graphs.d.ts +60 -5
- package/dist/src/graphs.js +191 -37
- package/dist/src/grok-provider.d.ts +50 -0
- package/dist/src/grok-provider.js +186 -0
- package/dist/src/handoffs.d.ts +13 -0
- package/dist/src/handoffs.js +31 -1
- package/dist/src/hardened-runtime.d.ts +4 -4
- package/dist/src/hardened-runtime.js +109 -9
- package/dist/src/managed-sign-in.d.ts +38 -0
- package/dist/src/managed-sign-in.js +169 -0
- package/dist/src/markdown.d.ts +5 -0
- package/dist/src/markdown.js +5 -2
- package/dist/src/mcp.js +11 -0
- package/dist/src/membership.d.ts +8 -1
- package/dist/src/membership.js +15 -5
- package/dist/src/model-metadata.js +14 -2
- package/dist/src/model-override.d.ts +10 -0
- package/dist/src/model-override.js +20 -0
- package/dist/src/opencode-cli-provider.d.ts +122 -0
- package/dist/src/opencode-cli-provider.js +415 -0
- package/dist/src/opencode-provider.js +23 -8
- package/dist/src/palette.d.ts +2 -0
- package/dist/src/palette.js +2 -0
- package/dist/src/permissions.d.ts +19 -1
- package/dist/src/permissions.js +30 -1
- package/dist/src/powershell-pool.d.ts +11 -2
- package/dist/src/powershell-pool.js +34 -5
- package/dist/src/provider-connection.js +36 -0
- package/dist/src/provider-engine.d.ts +2 -1
- package/dist/src/provider-engine.js +64 -13
- package/dist/src/provider-import.js +6 -1
- package/dist/src/provider-keys.d.ts +48 -0
- package/dist/src/provider-keys.js +121 -0
- package/dist/src/provider-settings.js +22 -3
- package/dist/src/providers.d.ts +12 -1
- package/dist/src/providers.js +27 -8
- package/dist/src/pull-requests.d.ts +123 -20
- package/dist/src/pull-requests.js +334 -84
- package/dist/src/qa/qa-authorize.js +9 -1
- package/dist/src/qa/runtime/ProcessManager.d.ts +6 -0
- package/dist/src/qa/runtime/ProcessManager.js +16 -0
- package/dist/src/react-runtime.js +106 -7
- package/dist/src/read-image.d.ts +30 -0
- package/dist/src/read-image.js +97 -0
- package/dist/src/remote/engine-pool.js +1 -1
- package/dist/src/run-progress.js +6 -1
- package/dist/src/run-records.d.ts +133 -27
- package/dist/src/run-records.js +320 -40
- package/dist/src/runtime.d.ts +38 -1
- package/dist/src/runtime.js +27 -4
- package/dist/src/save-lock.d.ts +11 -0
- package/dist/src/save-lock.js +29 -2
- package/dist/src/secret-redaction.d.ts +13 -0
- package/dist/src/secret-redaction.js +71 -0
- package/dist/src/session-summary.d.ts +10 -4
- package/dist/src/session-summary.js +14 -7
- package/dist/src/sessions.js +8 -2
- package/dist/src/shell.js +4 -1
- package/dist/src/side-panel.d.ts +1 -1
- package/dist/src/side-panel.js +1 -1
- package/dist/src/skill-commands.d.ts +2 -0
- package/dist/src/skill-commands.js +2 -0
- package/dist/src/skills/bundled/create-agent/SKILL.md +81 -0
- package/dist/src/skills/bundled/create-skill/SKILL.md +81 -0
- package/dist/src/skills/bundled/doctor/SKILL.md +43 -0
- package/dist/src/skills/bundled/graph-manager/SKILL.md +100 -0
- package/dist/src/skills/bundled/graph-manager/errors.md +38 -0
- package/dist/src/skills/bundled/graph-manager/patterns.md +78 -0
- package/dist/src/skills/bundled/manage-mcp/SKILL.md +75 -0
- package/dist/src/skills/bundled/manage-mcp/probe.md +165 -0
- package/dist/src/skills/bundled/manage-skills/SKILL.md +67 -0
- package/dist/src/skills/bundled/provenance.json +50 -0
- package/dist/src/skills/bundled/write-instructions/SKILL.md +42 -0
- package/dist/src/skills/invocable-skills.d.ts +41 -0
- package/dist/src/skills/invocable-skills.js +49 -0
- package/dist/src/skills/prompt-skills.d.ts +1 -0
- package/dist/src/skills/prompt-skills.js +33 -0
- package/dist/src/skills/runtime-skills.d.ts +4 -0
- package/dist/src/skills/runtime-skills.js +21 -0
- package/dist/src/structured-step.d.ts +55 -0
- package/dist/src/structured-step.js +85 -0
- package/dist/src/subagent-run.d.ts +1 -1
- package/dist/src/subagent-run.js +29 -33
- package/dist/src/telemetry/schema.d.ts +2 -2
- package/dist/src/telemetry/schema.js +3 -2
- package/dist/src/terminal-ui.d.ts +38 -0
- package/dist/src/terminal-ui.js +126 -28
- package/dist/src/timers.d.ts +21 -2
- package/dist/src/timers.js +12 -4
- package/dist/src/tool-dependencies.js +4 -0
- package/dist/src/tool-names.d.ts +18 -0
- package/dist/src/tool-names.js +26 -0
- package/dist/src/tools.d.ts +9 -0
- package/dist/src/tools.js +159 -20
- package/dist/src/trajectory.js +32 -12
- package/dist/src/transcript.js +5 -0
- package/dist/src/types.d.ts +36 -0
- package/dist/src/web-search.d.ts +59 -0
- package/dist/src/web-search.js +216 -0
- package/docs/agents/README.md +2 -2
- package/docs/agents/mcp-server.md +28 -3
- package/docs/agents/subagent-mode.md +7 -4
- package/docs/concepts/README.md +1 -1
- package/docs/concepts/security.md +4 -2
- package/docs/getting-started/accounts.md +15 -4
- package/docs/getting-started/configure-providers.md +30 -3
- package/docs/guides/README.md +1 -0
- package/docs/guides/browser.md +12 -0
- package/docs/guides/desktop-app.md +11 -4
- package/docs/guides/graph-builder.md +9 -1
- package/docs/guides/web-search.md +47 -0
- package/docs/reference/cli.md +4 -3
- package/docs/reference/config.md +4 -4
- package/docs/reference/slash-commands.md +2 -1
- package/docs/superpowers/plans/2026-11-06-graph-soft-delete.md +125 -0
- package/docs/superpowers/plans/2026-11-09-orchestrator-delegation.md +295 -0
- package/docs/superpowers/specs/2026-11-01-pr-section-design.md +7 -0
- package/docs/superpowers/specs/2026-11-06-bundled-skills-design.md +206 -0
- package/docs/superpowers/specs/2026-11-09-orchestrator-delegation-design.md +291 -0
- package/package.json +1 -1
- package/tests/permissions-test-plan.md +2 -1
|
@@ -103,6 +103,30 @@ export declare function frameGate(now: number, lastEmittedAt: number | undefined
|
|
|
103
103
|
* locations. The probe reads the filesystem and never launches anything.
|
|
104
104
|
*/
|
|
105
105
|
export declare function channelCandidate(channel: BrowserViewChannel, platform: NodeJS.Platform, chromiumExecutable: () => string): string | undefined;
|
|
106
|
+
/**
|
|
107
|
+
* Where a session's panel browser keeps its state.
|
|
108
|
+
*
|
|
109
|
+
* `project` is the project's persistent profile — cookies, storage, history and
|
|
110
|
+
* cache survive restarts and are shared by every session of that project.
|
|
111
|
+
* `incognito` is a throwaway browser the agent asked for, and `isolated` is the
|
|
112
|
+
* same throwaway browser used when no project profile is available (no
|
|
113
|
+
* resolver, or another process already holds the profile folder).
|
|
114
|
+
*/
|
|
115
|
+
export type BrowserViewProfileKind = 'project' | 'incognito' | 'isolated';
|
|
116
|
+
/** A project's persistent profile: an opaque key and the folder Chromium keeps it in. */
|
|
117
|
+
export interface BrowserViewProfile {
|
|
118
|
+
key: string;
|
|
119
|
+
directory: string;
|
|
120
|
+
}
|
|
121
|
+
export interface BrowserViewOptions {
|
|
122
|
+
/** The project profile a session's panel browser persists into; `undefined` keeps it isolated. */
|
|
123
|
+
profileFor?: (sessionId: string) => Promise<BrowserViewProfile | undefined>;
|
|
124
|
+
/** Tests supply a fake persistent context; production launches Chromium on the folder. */
|
|
125
|
+
launchProfile?: (directory: string, viewport: {
|
|
126
|
+
width: number;
|
|
127
|
+
height: number;
|
|
128
|
+
}) => Promise<any>;
|
|
129
|
+
}
|
|
106
130
|
export type BrowserViewEmit = (event: string, data: Record<string, unknown>) => void;
|
|
107
131
|
/**
|
|
108
132
|
* One engine's panel browsers: a browser per session, a page per tab, and a CDP
|
|
@@ -112,6 +136,7 @@ export type BrowserViewEmit = (event: string, data: Record<string, unknown>) =>
|
|
|
112
136
|
export declare class BrowserViewManager {
|
|
113
137
|
private readonly emit;
|
|
114
138
|
private readonly launchBrowser?;
|
|
139
|
+
private readonly options;
|
|
115
140
|
private readonly sessions;
|
|
116
141
|
/**
|
|
117
142
|
* The pane's standing stream request per session, kept before a browser exists.
|
|
@@ -139,8 +164,16 @@ export declare class BrowserViewManager {
|
|
|
139
164
|
* deleted session can never reach, or else it would hold a slot for good.
|
|
140
165
|
*/
|
|
141
166
|
private readonly released;
|
|
167
|
+
/** Project profiles open now, by profile key. */
|
|
168
|
+
private readonly profiles;
|
|
169
|
+
/**
|
|
170
|
+
* Sessions whose panel browser is (or is about to be) incognito. The mark
|
|
171
|
+
* lives exactly as long as that browser: it is cleared when the browser
|
|
172
|
+
* closes, so the next open returns to the project profile.
|
|
173
|
+
*/
|
|
174
|
+
private readonly incognito;
|
|
142
175
|
private closed;
|
|
143
|
-
constructor(emit: BrowserViewEmit, launchBrowser?: (() => Promise<any>) | undefined);
|
|
176
|
+
constructor(emit: BrowserViewEmit, launchBrowser?: (() => Promise<any>) | undefined, options?: BrowserViewOptions);
|
|
144
177
|
private publishRuntime;
|
|
145
178
|
/**
|
|
146
179
|
* Probe the same executables `launch` will use, without launching anything;
|
|
@@ -155,6 +188,24 @@ export declare class BrowserViewManager {
|
|
|
155
188
|
*/
|
|
156
189
|
install(): Promise<BrowserRuntimeStatus>;
|
|
157
190
|
private launch;
|
|
191
|
+
/** Launch Chromium on a project's profile folder, with the same candidates as `launch`. */
|
|
192
|
+
private launchPersistent;
|
|
193
|
+
/**
|
|
194
|
+
* Join the project's shared profile browser, launching it for the first session.
|
|
195
|
+
*
|
|
196
|
+
* A profile that is still closing is waited out rather than reopened beside it:
|
|
197
|
+
* two processes on one profile folder is exactly what Chromium refuses.
|
|
198
|
+
*/
|
|
199
|
+
private acquireProfile;
|
|
200
|
+
/** Leave a project's profile; the last session out closes it, which flushes cookies to disk. */
|
|
201
|
+
private releaseProfile;
|
|
202
|
+
/**
|
|
203
|
+
* Open the browser a new session's pages will live in: its project's profile,
|
|
204
|
+
* or a throwaway browser when the session is incognito or has no usable profile.
|
|
205
|
+
*/
|
|
206
|
+
private openBrowserFor;
|
|
207
|
+
/** Close a session's browser, or only its pages when they live in a shared project profile. */
|
|
208
|
+
private disposeBrowser;
|
|
158
209
|
private summary;
|
|
159
210
|
private publishTabs;
|
|
160
211
|
private scheduleIdleClose;
|
|
@@ -214,14 +265,30 @@ export declare class BrowserViewManager {
|
|
|
214
265
|
/**
|
|
215
266
|
* The session's browser context, created once.
|
|
216
267
|
*
|
|
217
|
-
* One context
|
|
218
|
-
*
|
|
219
|
-
*
|
|
268
|
+
* One context is what makes the tabs one browser: cookies, local storage and
|
|
269
|
+
* cache are shared across the pages in it. A project session's context is its
|
|
270
|
+
* project's persistent profile, shared with that project's other sessions; an
|
|
271
|
+
* incognito or isolated session gets a fresh context of its own.
|
|
220
272
|
*/
|
|
221
273
|
private contextFor;
|
|
222
274
|
openTab(sessionId: string, url: string, signal?: AbortSignal): Promise<{
|
|
223
275
|
tabId: string;
|
|
224
276
|
}>;
|
|
277
|
+
/**
|
|
278
|
+
* Replace the session's panel browser with an incognito one showing a blank tab.
|
|
279
|
+
*
|
|
280
|
+
* The current browser closes first — its tabs go with it, and a project
|
|
281
|
+
* profile it used is left untouched on disk. Nothing the incognito browser
|
|
282
|
+
* does is saved, and it lasts until `endIncognito` or until it closes.
|
|
283
|
+
*/
|
|
284
|
+
startIncognito(sessionId: string, signal?: AbortSignal): Promise<{
|
|
285
|
+
tabId: string;
|
|
286
|
+
}>;
|
|
287
|
+
/** Close the session's incognito browser, if it has one; the next open uses the project profile. */
|
|
288
|
+
endIncognito(sessionId: string, signal?: AbortSignal): Promise<boolean>;
|
|
289
|
+
/** The kind of browser the session's pages live in now, or would on the next open. */
|
|
290
|
+
profileKind(sessionId: string): BrowserViewProfileKind | undefined;
|
|
291
|
+
private openPage;
|
|
225
292
|
/**
|
|
226
293
|
* Remove one tab an open created and did not finish.
|
|
227
294
|
*
|
|
@@ -334,6 +401,7 @@ export declare class BrowserViewManager {
|
|
|
334
401
|
sessionSummaries(): Record<string, {
|
|
335
402
|
tabs: BrowserViewTab[];
|
|
336
403
|
activeTabId?: string;
|
|
404
|
+
profile: BrowserViewProfileKind;
|
|
337
405
|
}>;
|
|
338
406
|
/**
|
|
339
407
|
* Release one session's panel browser now.
|
package/dist/src/browser-view.js
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
2
|
import { randomUUID } from 'node:crypto';
|
|
3
3
|
import { existsSync } from 'node:fs';
|
|
4
|
+
import { mkdir } from 'node:fs/promises';
|
|
4
5
|
import { dirname, join } from 'node:path';
|
|
5
6
|
import { fileURLToPath } from 'node:url';
|
|
6
7
|
import { observePage, observationResult } from './browser-observation.js';
|
|
@@ -266,6 +267,8 @@ export function channelCandidate(channel, platform, chromiumExecutable) {
|
|
|
266
267
|
? ['/usr/bin/microsoft-edge', '/usr/bin/microsoft-edge-stable'].find(existsSync)
|
|
267
268
|
: ['/usr/bin/google-chrome', '/usr/bin/google-chrome-stable'].find(existsSync);
|
|
268
269
|
}
|
|
270
|
+
/** How long closing a profile may take: a graceful close is what flushes cookies to disk. */
|
|
271
|
+
const PROFILE_CLOSE_TIMEOUT_MS = 5_000;
|
|
269
272
|
/**
|
|
270
273
|
* One engine's panel browsers: a browser per session, a page per tab, and a CDP
|
|
271
274
|
* screencast relay per active tab. Everything is keyed by the saved session id —
|
|
@@ -274,6 +277,7 @@ export function channelCandidate(channel, platform, chromiumExecutable) {
|
|
|
274
277
|
export class BrowserViewManager {
|
|
275
278
|
emit;
|
|
276
279
|
launchBrowser;
|
|
280
|
+
options;
|
|
277
281
|
sessions = new Map();
|
|
278
282
|
/**
|
|
279
283
|
* The pane's standing stream request per session, kept before a browser exists.
|
|
@@ -301,10 +305,19 @@ export class BrowserViewManager {
|
|
|
301
305
|
* deleted session can never reach, or else it would hold a slot for good.
|
|
302
306
|
*/
|
|
303
307
|
released = new Set();
|
|
308
|
+
/** Project profiles open now, by profile key. */
|
|
309
|
+
profiles = new Map();
|
|
310
|
+
/**
|
|
311
|
+
* Sessions whose panel browser is (or is about to be) incognito. The mark
|
|
312
|
+
* lives exactly as long as that browser: it is cleared when the browser
|
|
313
|
+
* closes, so the next open returns to the project profile.
|
|
314
|
+
*/
|
|
315
|
+
incognito = new Set();
|
|
304
316
|
closed = false;
|
|
305
|
-
constructor(emit, launchBrowser) {
|
|
317
|
+
constructor(emit, launchBrowser, options = {}) {
|
|
306
318
|
this.emit = emit;
|
|
307
319
|
this.launchBrowser = launchBrowser;
|
|
320
|
+
this.options = options;
|
|
308
321
|
}
|
|
309
322
|
publishRuntime(status) {
|
|
310
323
|
this.runtime = status;
|
|
@@ -440,8 +453,123 @@ export class BrowserViewManager {
|
|
|
440
453
|
}
|
|
441
454
|
throw new Error(`Browser runtime is not usable: ${failures.join('; ').slice(0, 1000)}`);
|
|
442
455
|
}
|
|
456
|
+
/** Launch Chromium on a project's profile folder, with the same candidates as `launch`. */
|
|
457
|
+
async launchPersistent(directory, viewport) {
|
|
458
|
+
if (this.options.launchProfile)
|
|
459
|
+
return await this.options.launchProfile(directory, viewport);
|
|
460
|
+
await mkdir(directory, { recursive: true });
|
|
461
|
+
const { chromium } = await import('playwright-core');
|
|
462
|
+
const failures = [];
|
|
463
|
+
for (const channel of ['chromium', 'msedge', 'chrome']) {
|
|
464
|
+
if (this.closed)
|
|
465
|
+
throw new Error('Application is shutting down');
|
|
466
|
+
const candidate = channelCandidate(channel, process.platform, () => chromium.executablePath());
|
|
467
|
+
if (!candidate || !existsSync(candidate))
|
|
468
|
+
continue;
|
|
469
|
+
try {
|
|
470
|
+
return await chromium.launchPersistentContext(directory, { ...viewLaunchOptions(channel, candidate), viewport: { ...viewport }, acceptDownloads: false });
|
|
471
|
+
}
|
|
472
|
+
catch (error) {
|
|
473
|
+
failures.push((error instanceof Error ? error.message : String(error)).split('\n')[0]);
|
|
474
|
+
}
|
|
475
|
+
}
|
|
476
|
+
throw new Error(`Project browser profile is not usable: ${failures.join('; ').slice(0, 1000)}`);
|
|
477
|
+
}
|
|
478
|
+
/**
|
|
479
|
+
* Join the project's shared profile browser, launching it for the first session.
|
|
480
|
+
*
|
|
481
|
+
* A profile that is still closing is waited out rather than reopened beside it:
|
|
482
|
+
* two processes on one profile folder is exactly what Chromium refuses.
|
|
483
|
+
*/
|
|
484
|
+
async acquireProfile(owner, profile, viewport) {
|
|
485
|
+
for (;;) {
|
|
486
|
+
const current = this.profiles.get(profile.key);
|
|
487
|
+
if (current?.closing) {
|
|
488
|
+
await current.closing;
|
|
489
|
+
continue;
|
|
490
|
+
}
|
|
491
|
+
const host = current ?? { users: new Set() };
|
|
492
|
+
if (!current)
|
|
493
|
+
this.profiles.set(profile.key, host);
|
|
494
|
+
host.users.add(owner);
|
|
495
|
+
host.starting ??= this.launchPersistent(profile.directory, viewport).then(async (context) => {
|
|
496
|
+
// A persistent launch opens with a blank page of its own; every tab the
|
|
497
|
+
// panel shows is one a session asked for.
|
|
498
|
+
for (const page of context.pages?.() ?? [])
|
|
499
|
+
await Promise.resolve().then(() => page.close()).catch(() => { });
|
|
500
|
+
context.on?.('close', () => { if (this.profiles.get(profile.key) === host)
|
|
501
|
+
this.profiles.delete(profile.key); });
|
|
502
|
+
host.context = context;
|
|
503
|
+
return context;
|
|
504
|
+
});
|
|
505
|
+
try {
|
|
506
|
+
return await host.starting;
|
|
507
|
+
}
|
|
508
|
+
catch (error) {
|
|
509
|
+
// A failed launch is not cached: the next open tries the profile again.
|
|
510
|
+
host.users.delete(owner);
|
|
511
|
+
if (this.profiles.get(profile.key) === host)
|
|
512
|
+
this.profiles.delete(profile.key);
|
|
513
|
+
throw error;
|
|
514
|
+
}
|
|
515
|
+
}
|
|
516
|
+
}
|
|
517
|
+
/** Leave a project's profile; the last session out closes it, which flushes cookies to disk. */
|
|
518
|
+
async releaseProfile(key, owner) {
|
|
519
|
+
const host = this.profiles.get(key);
|
|
520
|
+
if (!host)
|
|
521
|
+
return;
|
|
522
|
+
host.users.delete(owner);
|
|
523
|
+
if (host.users.size > 0)
|
|
524
|
+
return;
|
|
525
|
+
host.closing ??= (async () => {
|
|
526
|
+
const context = host.context ?? await host.starting?.catch(() => undefined);
|
|
527
|
+
await Promise.race([
|
|
528
|
+
Promise.resolve().then(() => context?.close()).catch(() => { }),
|
|
529
|
+
new Promise(resolve => { const timer = setTimeout(resolve, PROFILE_CLOSE_TIMEOUT_MS); timer.unref?.(); }),
|
|
530
|
+
]);
|
|
531
|
+
if (this.profiles.get(key) === host)
|
|
532
|
+
this.profiles.delete(key);
|
|
533
|
+
})();
|
|
534
|
+
await host.closing;
|
|
535
|
+
}
|
|
536
|
+
/**
|
|
537
|
+
* Open the browser a new session's pages will live in: its project's profile,
|
|
538
|
+
* or a throwaway browser when the session is incognito or has no usable profile.
|
|
539
|
+
*/
|
|
540
|
+
async openBrowserFor(sessionId, viewport) {
|
|
541
|
+
if (!this.incognito.has(sessionId)) {
|
|
542
|
+
const profile = this.options.profileFor ? await this.options.profileFor(sessionId).catch(() => undefined) : undefined;
|
|
543
|
+
if (profile) {
|
|
544
|
+
try {
|
|
545
|
+
const owner = {};
|
|
546
|
+
const context = await this.acquireProfile(owner, profile, viewport);
|
|
547
|
+
return { context, profileKey: profile.key, profileOwner: owner, profile: 'project' };
|
|
548
|
+
}
|
|
549
|
+
catch (error) {
|
|
550
|
+
if (this.closed)
|
|
551
|
+
throw error;
|
|
552
|
+
// Another process holds the folder, or the profile cannot be opened: the
|
|
553
|
+
// panel still works, on a throwaway browser that says so.
|
|
554
|
+
}
|
|
555
|
+
}
|
|
556
|
+
}
|
|
557
|
+
return { browser: await this.launch(), profile: this.incognito.has(sessionId) ? 'incognito' : 'isolated' };
|
|
558
|
+
}
|
|
559
|
+
/** Close a session's browser, or only its pages when they live in a shared project profile. */
|
|
560
|
+
async disposeBrowser(session) {
|
|
561
|
+
if (session.profileKey === undefined || session.profileOwner === undefined) {
|
|
562
|
+
// Playwright transport shutdown is not reliably awaitable; own the
|
|
563
|
+
// rejection and let the browser close land whenever it lands.
|
|
564
|
+
await Promise.resolve().then(() => session.browser?.close()).catch(() => { });
|
|
565
|
+
return;
|
|
566
|
+
}
|
|
567
|
+
await Promise.all([...session.tabs.values()].map(tab => Promise.resolve().then(() => tab.page.close()).catch(() => { })));
|
|
568
|
+
await this.releaseProfile(session.profileKey, session.profileOwner);
|
|
569
|
+
}
|
|
443
570
|
summary(session) {
|
|
444
571
|
return {
|
|
572
|
+
profile: session.profile,
|
|
445
573
|
tabs: [...session.tabs.values()].map(tab => ({ id: tab.id, url: tab.url, title: tab.title, loading: tab.loading })),
|
|
446
574
|
...(session.activeTabId ? { activeTabId: session.activeTabId } : {}),
|
|
447
575
|
};
|
|
@@ -801,27 +929,32 @@ export class BrowserViewManager {
|
|
|
801
929
|
if (this.closed)
|
|
802
930
|
throw new Error('Application is shutting down');
|
|
803
931
|
const starting = (async () => {
|
|
804
|
-
const
|
|
932
|
+
const desired = this.desired.get(sessionId);
|
|
933
|
+
const viewport = desired?.viewport ?? clampViewport(undefined, undefined);
|
|
934
|
+
const opened = await this.openBrowserFor(sessionId, viewport);
|
|
805
935
|
// Shutdown may have finished while the launch was in flight: the browser
|
|
806
936
|
// that arrived late belongs to nobody, so it is closed here rather than
|
|
807
937
|
// inserted into a manager that has already visited its sessions.
|
|
808
938
|
if (this.closed) {
|
|
809
|
-
await
|
|
939
|
+
await this.disposeBrowser({ ...opened, tabs: new Map() });
|
|
810
940
|
throw new Error('Application is shutting down');
|
|
811
941
|
}
|
|
812
942
|
// A release that landed while this launch was in flight has already closed
|
|
813
943
|
// whatever it found; the browser this launch just produced belongs to the
|
|
814
944
|
// session that no longer exists, so it goes the same way.
|
|
815
945
|
if (this.released.delete(sessionId)) {
|
|
816
|
-
await
|
|
946
|
+
await this.disposeBrowser({ ...opened, tabs: new Map() });
|
|
817
947
|
throw new Error('That session was deleted.');
|
|
818
948
|
}
|
|
819
|
-
|
|
949
|
+
// The pane can enable streaming, resize or switch mode while the launch is in
|
|
950
|
+
// flight; those requests found no session to update, so the session takes
|
|
951
|
+
// the request as it stands now, not as it stood when the launch began.
|
|
952
|
+
const current = this.desired.get(sessionId);
|
|
820
953
|
const session = {
|
|
821
|
-
|
|
822
|
-
viewport:
|
|
823
|
-
mode:
|
|
824
|
-
streaming:
|
|
954
|
+
...opened, tabs: new Map(), activeTabId: undefined, pendingTabs: 0,
|
|
955
|
+
viewport: current?.viewport ?? viewport,
|
|
956
|
+
mode: current?.mode ?? 'desktop',
|
|
957
|
+
streaming: current !== undefined, quality: current?.quality ?? VIEW_STREAM_QUALITY, idleTimer: undefined,
|
|
825
958
|
};
|
|
826
959
|
this.sessions.set(sessionId, session);
|
|
827
960
|
this.scheduleIdleClose(sessionId, session);
|
|
@@ -838,9 +971,10 @@ export class BrowserViewManager {
|
|
|
838
971
|
/**
|
|
839
972
|
* The session's browser context, created once.
|
|
840
973
|
*
|
|
841
|
-
* One context
|
|
842
|
-
*
|
|
843
|
-
*
|
|
974
|
+
* One context is what makes the tabs one browser: cookies, local storage and
|
|
975
|
+
* cache are shared across the pages in it. A project session's context is its
|
|
976
|
+
* project's persistent profile, shared with that project's other sessions; an
|
|
977
|
+
* incognito or isolated session gets a fresh context of its own.
|
|
844
978
|
*/
|
|
845
979
|
async contextFor(session) {
|
|
846
980
|
if (session.context)
|
|
@@ -851,11 +985,71 @@ export class BrowserViewManager {
|
|
|
851
985
|
return await session.contextTask;
|
|
852
986
|
}
|
|
853
987
|
async openTab(sessionId, url, signal) {
|
|
854
|
-
|
|
988
|
+
return await this.openPage(sessionId, browserViewUrl(url), signal);
|
|
989
|
+
}
|
|
990
|
+
/**
|
|
991
|
+
* Replace the session's panel browser with an incognito one showing a blank tab.
|
|
992
|
+
*
|
|
993
|
+
* The current browser closes first — its tabs go with it, and a project
|
|
994
|
+
* profile it used is left untouched on disk. Nothing the incognito browser
|
|
995
|
+
* does is saved, and it lasts until `endIncognito` or until it closes.
|
|
996
|
+
*/
|
|
997
|
+
async startIncognito(sessionId, signal) {
|
|
998
|
+
// Wait out every launch for this session, including one an open began while
|
|
999
|
+
// this call was waiting, so nothing registers a project browser behind it.
|
|
1000
|
+
while (this.launching.has(sessionId))
|
|
1001
|
+
await this.launching.get(sessionId).catch(() => undefined);
|
|
1002
|
+
// A switch that was stopped or timed out while waiting must not tear down the
|
|
1003
|
+
// browser the user is using: nothing has been closed yet.
|
|
1004
|
+
signal?.throwIfAborted();
|
|
1005
|
+
// From here to the mark there is no await: the old browser leaves the session
|
|
1006
|
+
// table synchronously, and the mark is set before anything can open another,
|
|
1007
|
+
// so an open that arrives during the teardown launches incognito too.
|
|
1008
|
+
const closing = this.closeSession(sessionId, 'incognito');
|
|
1009
|
+
this.incognito.add(sessionId);
|
|
1010
|
+
await closing;
|
|
1011
|
+
try {
|
|
1012
|
+
signal?.throwIfAborted();
|
|
1013
|
+
return await this.openPage(sessionId, 'about:blank', signal, 'incognito');
|
|
1014
|
+
}
|
|
1015
|
+
catch (error) {
|
|
1016
|
+
// A start that failed or was abandoned (stopped, or past its deadline) must
|
|
1017
|
+
// not leave an incognito browser a later open would land in unannounced:
|
|
1018
|
+
// one that launched but holds no tab is closed, which also clears the mark,
|
|
1019
|
+
// and a browser that never started leaves no mark behind.
|
|
1020
|
+
const session = this.sessions.get(sessionId);
|
|
1021
|
+
if (!session)
|
|
1022
|
+
this.incognito.delete(sessionId);
|
|
1023
|
+
else if (session.profile === 'incognito' && session.tabs.size === 0 && session.pendingTabs === 0)
|
|
1024
|
+
await this.closeSession(sessionId, 'incognito cancelled', session);
|
|
1025
|
+
throw error;
|
|
1026
|
+
}
|
|
1027
|
+
}
|
|
1028
|
+
/** Close the session's incognito browser, if it has one; the next open uses the project profile. */
|
|
1029
|
+
async endIncognito(sessionId, signal) {
|
|
1030
|
+
while (this.launching.has(sessionId))
|
|
1031
|
+
await this.launching.get(sessionId).catch(() => undefined);
|
|
1032
|
+
// An end that was stopped or timed out while a launch finished must not close
|
|
1033
|
+
// the browser afterwards: nothing has changed yet, and the agent was told it failed.
|
|
1034
|
+
signal?.throwIfAborted();
|
|
1035
|
+
const session = this.sessions.get(sessionId);
|
|
1036
|
+
const active = this.incognito.delete(sessionId) || session?.profile === 'incognito';
|
|
1037
|
+
if (session?.profile === 'incognito')
|
|
1038
|
+
await this.closeSession(sessionId, 'incognito ended');
|
|
1039
|
+
return active;
|
|
1040
|
+
}
|
|
1041
|
+
/** The kind of browser the session's pages live in now, or would on the next open. */
|
|
1042
|
+
profileKind(sessionId) {
|
|
1043
|
+
return this.sessions.get(sessionId)?.profile ?? (this.incognito.has(sessionId) ? 'incognito' : undefined);
|
|
1044
|
+
}
|
|
1045
|
+
async openPage(sessionId, target, signal, requireProfile) {
|
|
855
1046
|
const session = await this.ensureSession(sessionId);
|
|
856
1047
|
// The launch is the longest wait here, and the one a stop usually arrives
|
|
857
1048
|
// during: a cancelled call returns before creating a page at all.
|
|
858
1049
|
signal?.throwIfAborted();
|
|
1050
|
+
// A switch to incognito must never report success on the signed-in profile.
|
|
1051
|
+
if (requireProfile !== undefined && session.profile !== requireProfile)
|
|
1052
|
+
throw new Error(`The panel browser is not ${requireProfile}; retry the switch`);
|
|
859
1053
|
if (session.closing)
|
|
860
1054
|
throw new Error('Browser is closing; retry shortly');
|
|
861
1055
|
// Capacity is reserved before the first await. Stopping the previous
|
|
@@ -878,7 +1072,20 @@ export class BrowserViewManager {
|
|
|
878
1072
|
await this.stopScreencast(previous);
|
|
879
1073
|
const context = await this.contextFor(session);
|
|
880
1074
|
const page = await context.newPage();
|
|
881
|
-
const cdp = await page.context().newCDPSession(page)
|
|
1075
|
+
const cdp = await Promise.resolve().then(() => page.context().newCDPSession(page)).catch(async (error) => {
|
|
1076
|
+
await Promise.resolve().then(() => page.close()).catch(() => { });
|
|
1077
|
+
throw error;
|
|
1078
|
+
});
|
|
1079
|
+
// A shared project profile outlives this session: a page whose session
|
|
1080
|
+
// started closing while it was created or attached would otherwise stay
|
|
1081
|
+
// open in it, unowned, because teardown closes only registered tabs. The
|
|
1082
|
+
// check sits directly before registration, with no await between them, so
|
|
1083
|
+
// a teardown that starts afterwards always finds this tab.
|
|
1084
|
+
if (session.closing) {
|
|
1085
|
+
await Promise.resolve().then(() => cdp.detach?.()).catch(() => { });
|
|
1086
|
+
await Promise.resolve().then(() => page.close()).catch(() => { });
|
|
1087
|
+
throw new Error('Browser is closing; retry shortly');
|
|
1088
|
+
}
|
|
882
1089
|
const tab = this.wireTab(sessionId, session, page, cdp);
|
|
883
1090
|
// The context was created at the viewport of the first open; a tab opened
|
|
884
1091
|
// after the pane was resized has to match the pane it will be shown in, or
|
|
@@ -1412,14 +1619,18 @@ export class BrowserViewManager {
|
|
|
1412
1619
|
// replacement that took its id in the meantime.
|
|
1413
1620
|
if (expected !== undefined && session !== expected)
|
|
1414
1621
|
return;
|
|
1622
|
+
// Incognito lasts exactly as long as its browser: once it closes, the next
|
|
1623
|
+
// open returns to the project profile.
|
|
1624
|
+
if (session.profile === 'incognito')
|
|
1625
|
+
this.incognito.delete(sessionId);
|
|
1415
1626
|
session.closing = (async () => {
|
|
1416
1627
|
this.sessions.delete(sessionId);
|
|
1417
1628
|
if (session.idleTimer)
|
|
1418
1629
|
clearTimeout(session.idleTimer);
|
|
1419
1630
|
await Promise.all([...session.tabs.values()].map(tab => this.stopScreencast(tab)));
|
|
1420
|
-
//
|
|
1421
|
-
//
|
|
1422
|
-
await
|
|
1631
|
+
// A shared project profile loses only this session's pages; the profile
|
|
1632
|
+
// itself closes when its last session leaves.
|
|
1633
|
+
await this.disposeBrowser(session);
|
|
1423
1634
|
// A new browser may already hold this session id; its pane has content of
|
|
1424
1635
|
// its own, so the old generation stays silent.
|
|
1425
1636
|
if (this.sessions.has(sessionId))
|
|
@@ -1445,6 +1656,7 @@ export class BrowserViewManager {
|
|
|
1445
1656
|
// Marked before the close, so a launch finishing in between still sees the
|
|
1446
1657
|
// release; the marker is dropped once no launch can still be holding it.
|
|
1447
1658
|
this.released.add(sessionId);
|
|
1659
|
+
this.incognito.delete(sessionId);
|
|
1448
1660
|
try {
|
|
1449
1661
|
await this.closeSession(sessionId, reason);
|
|
1450
1662
|
}
|
|
@@ -1,9 +1,15 @@
|
|
|
1
|
-
import { type GraphNode } from './graphs.js';
|
|
1
|
+
import { type CommandScope, type GraphNode } from './graphs.js';
|
|
2
2
|
import type { Tool, ToolContext } from './types.js';
|
|
3
3
|
/** No command-string heuristics: constrained agents receive structured operations instead of a shell.
|
|
4
4
|
* QA tools are the one self-declared command surface: they are matched by an explicit
|
|
5
5
|
* allowlist, gated by node capability AND their declared capability, and serialized by default. */
|
|
6
|
-
export declare function capabilityTools(node: GraphNode, tools: Tool[], child?:
|
|
7
|
-
|
|
6
|
+
export declare function capabilityTools(node: GraphNode, tools: Tool[], child?: CommandScope): Tool[];
|
|
7
|
+
/**
|
|
8
|
+
* `requireUser` asks a person even under Full Access: the operation stands for something only the
|
|
9
|
+
* user can want, so no permission mode answers it on their behalf. Headless runs still refuse it.
|
|
10
|
+
*/
|
|
11
|
+
export declare function approveOperation(context: ToolContext, name: string, args: Record<string, unknown>, options?: {
|
|
12
|
+
requireUser?: boolean;
|
|
13
|
+
}): Promise<void>;
|
|
8
14
|
/** Fixed Git operations disable diff/textconv, pager and hooks, but remain host processes. */
|
|
9
15
|
export declare function gitReadTool(): Tool;
|
package/dist/src/capabilities.js
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { permissionMode } from './permissions.js';
|
|
1
|
+
import { permissionMode, assertPlanMutationAllowed } from './permissions.js';
|
|
2
2
|
import { execFile } from 'node:child_process';
|
|
3
3
|
import { promisify } from 'node:util';
|
|
4
4
|
import { effectiveCapabilities, isQaToolName, permitsBuiltInTool } from './graphs.js';
|
|
@@ -14,7 +14,7 @@ export function capabilityTools(node, tools, child = false) {
|
|
|
14
14
|
if (tool.providerVisible === false)
|
|
15
15
|
return false;
|
|
16
16
|
// Task-owned MCP clients keep the parent workspace for their entire lifetime.
|
|
17
|
-
// Delegation cannot rebind them safely, even
|
|
17
|
+
// Delegation cannot rebind them safely, even for a delegated worktree child with a shell.
|
|
18
18
|
if (child && tool.capability === 'external')
|
|
19
19
|
return false;
|
|
20
20
|
if (allowed && !allowed.some(name => toolNameMatches(name, tool.name)))
|
|
@@ -87,12 +87,23 @@ function permits(policy, required) {
|
|
|
87
87
|
return policy.deployment === 'allowed';
|
|
88
88
|
return false;
|
|
89
89
|
}
|
|
90
|
-
|
|
90
|
+
/**
|
|
91
|
+
* `requireUser` asks a person even under Full Access: the operation stands for something only the
|
|
92
|
+
* user can want, so no permission mode answers it on their behalf. Headless runs still refuse it.
|
|
93
|
+
*/
|
|
94
|
+
export async function approveOperation(context, name, args, options = {}) {
|
|
91
95
|
context.signal.throwIfAborted();
|
|
92
|
-
|
|
96
|
+
// Structured writes (worktrees, automations, PR changes, etc.) are not covered
|
|
97
|
+
// by the file/shell gate. Only the explicitly read-only Git operations are exempt.
|
|
98
|
+
const assertAllowed = () => { if (name !== 'git_read')
|
|
99
|
+
assertPlanMutationAllowed(context); };
|
|
100
|
+
assertAllowed();
|
|
101
|
+
const liveMode = () => permissionMode(context) === 'full-access' && !options.requireUser ? 'yolo' : context.approvalMode ?? 'interactive';
|
|
93
102
|
while (true) {
|
|
94
103
|
context.signal.throwIfAborted();
|
|
104
|
+
assertAllowed();
|
|
95
105
|
await context.onApprovalEvent?.('node.tool.approval.requested', { name, arguments: args, mode: liveMode() });
|
|
106
|
+
assertAllowed();
|
|
96
107
|
// A prompt is a human wait: it gets the session signal so a wall clock cannot answer for
|
|
97
108
|
// the user, matching the built-in tools' path in `tools.ts`.
|
|
98
109
|
// Audit delivery can yield while the user changes the live permissions mode.
|
|
@@ -101,6 +112,7 @@ export async function approveOperation(context, name, args) {
|
|
|
101
112
|
while (mode === 'interactive') {
|
|
102
113
|
answer = await context.approve(name, args, context.userSignal ?? context.signal);
|
|
103
114
|
context.signal.throwIfAborted();
|
|
115
|
+
assertAllowed();
|
|
104
116
|
if (answer !== 'policy-changed')
|
|
105
117
|
break;
|
|
106
118
|
mode = liveMode();
|
|
@@ -109,12 +121,15 @@ export async function approveOperation(context, name, args) {
|
|
|
109
121
|
const actor = mode === 'yolo' ? 'yolo-policy' : mode === 'headless' ? 'headless-policy' : 'local-user';
|
|
110
122
|
await context.onApprovalEvent?.('node.tool.approval.decided', { name, mode, approved, actor });
|
|
111
123
|
context.signal.throwIfAborted();
|
|
124
|
+
assertAllowed();
|
|
112
125
|
if (!approved)
|
|
113
126
|
throw new Error('Permission denied');
|
|
114
127
|
// Policy grants can be revoked during either audit await. An explicit user's
|
|
115
128
|
// approval remains scoped to this operation; automatic approval must stay live.
|
|
116
|
-
if (mode !== 'yolo' || liveMode() === mode)
|
|
129
|
+
if (mode !== 'yolo' || liveMode() === mode) {
|
|
130
|
+
assertAllowed();
|
|
117
131
|
return;
|
|
132
|
+
}
|
|
118
133
|
}
|
|
119
134
|
}
|
|
120
135
|
/** Fixed Git operations disable diff/textconv, pager and hooks, but remain host processes. */
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
import type { Config } from './config.js';
|
|
2
|
+
/**
|
|
3
|
+
* A small CapSolver client: create a task, then poll its result.
|
|
4
|
+
*
|
|
5
|
+
* Only the proxyless task types the browser solve tool uses are modelled. The API key never leaves
|
|
6
|
+
* this module except in the request body sent to CapSolver; error messages never include it.
|
|
7
|
+
*/
|
|
8
|
+
export declare const CAPSOLVER_ENV = "CAPSOLVER_API_KEY";
|
|
9
|
+
export type CapsolverTask = {
|
|
10
|
+
type: 'ReCaptchaV2TaskProxyLess' | 'ReCaptchaV2EnterpriseTaskProxyLess';
|
|
11
|
+
websiteURL: string;
|
|
12
|
+
websiteKey: string;
|
|
13
|
+
isInvisible?: boolean;
|
|
14
|
+
pageAction?: string;
|
|
15
|
+
recaptchaDataSValue?: string;
|
|
16
|
+
enterprisePayload?: Record<string, string>;
|
|
17
|
+
} | {
|
|
18
|
+
type: 'ReCaptchaV3TaskProxyLess' | 'ReCaptchaV3EnterpriseTaskProxyLess';
|
|
19
|
+
websiteURL: string;
|
|
20
|
+
websiteKey: string;
|
|
21
|
+
pageAction?: string;
|
|
22
|
+
} | {
|
|
23
|
+
type: 'AntiTurnstileTaskProxyLess';
|
|
24
|
+
websiteURL: string;
|
|
25
|
+
websiteKey: string;
|
|
26
|
+
metadata?: {
|
|
27
|
+
action?: string;
|
|
28
|
+
cdata?: string;
|
|
29
|
+
};
|
|
30
|
+
} | {
|
|
31
|
+
type: 'ImageToTextTask';
|
|
32
|
+
body: string;
|
|
33
|
+
websiteURL?: string;
|
|
34
|
+
module?: string;
|
|
35
|
+
};
|
|
36
|
+
export interface CapsolverKey {
|
|
37
|
+
key: string;
|
|
38
|
+
source: 'config' | 'env';
|
|
39
|
+
}
|
|
40
|
+
/** The key the solve tool uses: the saved one, otherwise the environment's. */
|
|
41
|
+
export declare function resolveCapsolverKey(config: Pick<Config, 'browser'> | undefined, env?: NodeJS.ProcessEnv): CapsolverKey | undefined;
|
|
42
|
+
/**
|
|
43
|
+
* Where requests go. `ANDORRA_CAPSOLVER_BASE_URL` exists so a local stub can stand in for the
|
|
44
|
+
* service during verification; it must be HTTPS, or HTTP on a loopback address, so a stray setting
|
|
45
|
+
* cannot send the key in the clear.
|
|
46
|
+
*/
|
|
47
|
+
export declare function capsolverBaseUrl(env?: NodeJS.ProcessEnv): string;
|
|
48
|
+
export declare class CapsolverError extends Error {
|
|
49
|
+
readonly code?: string | undefined;
|
|
50
|
+
constructor(message: string, code?: string | undefined);
|
|
51
|
+
}
|
|
52
|
+
export interface CapsolverOptions {
|
|
53
|
+
signal: AbortSignal;
|
|
54
|
+
fetch?: typeof fetch;
|
|
55
|
+
baseUrl?: string;
|
|
56
|
+
pollIntervalMs?: number;
|
|
57
|
+
timeoutMs?: number;
|
|
58
|
+
}
|
|
59
|
+
/** Solve one task and return CapSolver's `solution` object. */
|
|
60
|
+
export declare function solveCapsolverTask(key: string, task: CapsolverTask, options: CapsolverOptions): Promise<Record<string, unknown>>;
|