@andorra-labs/code 0.1.12 → 0.1.13
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.d.ts +1 -37
- package/dist/src/account-presentation.js +2 -42
- package/dist/src/activity.d.ts +0 -25
- package/dist/src/activity.js +1 -23
- package/dist/src/agent-definitions.d.ts +0 -26
- package/dist/src/agent-definitions.js +0 -43
- package/dist/src/agent-execution.d.ts +0 -2
- package/dist/src/agent-execution.js +49 -416
- package/dist/src/agent-mcp-catalog.d.ts +0 -8
- package/dist/src/agent-mcp-catalog.js +0 -2
- package/dist/src/agent-mcp.d.ts +0 -56
- package/dist/src/agent-mcp.js +9 -153
- package/dist/src/agent-modifiers.d.ts +0 -1
- package/dist/src/agent-modifiers.js +25 -68
- package/dist/src/analytics.d.ts +0 -66
- package/dist/src/analytics.js +0 -45
- package/dist/src/anthropic-console-auth.d.ts +0 -24
- package/dist/src/anthropic-console-auth.js +0 -37
- package/dist/src/anthropic-credentials.d.ts +0 -25
- package/dist/src/anthropic-credentials.js +0 -28
- package/dist/src/app-server/protocol.d.ts +13 -245
- package/dist/src/app-server/protocol.js +1 -132
- package/dist/src/app-server/reasoning.d.ts +0 -31
- package/dist/src/app-server/reasoning.js +0 -54
- package/dist/src/app-server/terminal.d.ts +0 -36
- package/dist/src/app-server/terminal.js +3 -39
- package/dist/src/app-server/workspace.d.ts +0 -167
- package/dist/src/app-server/workspace.js +4 -406
- package/dist/src/app-server.d.ts +27 -927
- package/dist/src/app-server.js +537 -2992
- package/dist/src/artifacts.d.ts +0 -10
- package/dist/src/artifacts.js +1 -11
- package/dist/src/attachments.d.ts +4 -98
- package/dist/src/attachments.js +10 -130
- package/dist/src/auth/AuthManager.d.ts +0 -93
- package/dist/src/auth/AuthManager.js +3 -165
- package/dist/src/auth/callback-page.d.ts +0 -1
- package/dist/src/auth/callback-page.js +0 -4
- package/dist/src/auth/callback.d.ts +0 -25
- package/dist/src/auth/callback.js +1 -29
- package/dist/src/auth/deployment.d.ts +0 -16
- package/dist/src/auth/deployment.js +0 -16
- package/dist/src/auth/index.d.ts +0 -11
- package/dist/src/auth/index.js +0 -11
- package/dist/src/auth/lock.d.ts +0 -1
- package/dist/src/auth/lock.js +0 -1
- package/dist/src/auth/store.d.ts +7 -108
- package/dist/src/auth/store.js +21 -129
- package/dist/src/auth/types.d.ts +0 -8
- package/dist/src/auth-commands.d.ts +0 -5
- package/dist/src/auth-commands.js +0 -1
- package/dist/src/automation-runner.d.ts +0 -9
- package/dist/src/automation-runner.js +0 -11
- package/dist/src/automation-service.d.ts +0 -10
- package/dist/src/automation-service.js +3 -17
- package/dist/src/automation-tool.js +0 -5
- package/dist/src/automation-worker-shutdown.d.ts +0 -1
- package/dist/src/automation-worker-shutdown.js +0 -3
- package/dist/src/automations.d.ts +23 -2
- package/dist/src/automations.js +91 -12
- package/dist/src/background-tasks.d.ts +0 -23
- package/dist/src/background-tasks.js +0 -11
- package/dist/src/boot-trace.d.ts +0 -13
- package/dist/src/boot-trace.js +1 -14
- package/dist/src/browser-activity.js +0 -2
- package/dist/src/browser-bridge.d.ts +0 -2
- package/dist/src/browser-bridge.js +0 -27
- package/dist/src/browser-captcha-tool.d.ts +0 -13
- package/dist/src/browser-captcha-tool.js +3 -35
- package/dist/src/browser-extensions-tool.d.ts +24 -0
- package/dist/src/browser-extensions-tool.js +137 -0
- package/dist/src/browser-extensions.d.ts +127 -0
- package/dist/src/browser-extensions.js +729 -0
- package/dist/src/browser-observation.d.ts +0 -15
- package/dist/src/browser-observation.js +1 -22
- package/dist/src/browser-panel-tool.d.ts +1 -37
- package/dist/src/browser-panel-tool.js +3 -73
- package/dist/src/browser-runner.d.ts +0 -1
- package/dist/src/browser-runner.js +4 -45
- package/dist/src/browser-server.d.ts +0 -6
- package/dist/src/browser-server.js +6 -229
- package/dist/src/browser-session.d.ts +0 -25
- package/dist/src/browser-session.js +1 -71
- package/dist/src/browser-stealth.d.ts +0 -12
- package/dist/src/browser-stealth.js +0 -36
- package/dist/src/browser-ui/app.js +7 -174
- package/dist/src/browser-ui/style.css +0 -68
- package/dist/src/browser-ui/tokens.css +11 -93
- package/dist/src/browser-view.d.ts +47 -301
- package/dist/src/browser-view.js +333 -582
- package/dist/src/capabilities.d.ts +0 -8
- package/dist/src/capabilities.js +0 -29
- package/dist/src/capsolver.d.ts +0 -13
- package/dist/src/capsolver.js +0 -15
- package/dist/src/clarification-ui.d.ts +0 -7
- package/dist/src/clarification-ui.js +0 -8
- package/dist/src/claude-executable.d.ts +0 -1
- package/dist/src/claude-executable.js +1 -2
- package/dist/src/claude-provider.d.ts +6 -19
- package/dist/src/claude-provider.js +155 -63
- package/dist/src/cli-executable.d.ts +0 -16
- package/dist/src/cli-executable.js +0 -7
- package/dist/src/cli-process.d.ts +0 -26
- package/dist/src/cli-process.js +0 -18
- package/dist/src/cli-sign-in.d.ts +0 -20
- package/dist/src/cli-sign-in.js +1 -17
- package/dist/src/cli.d.ts +1 -55
- package/dist/src/cli.js +80 -721
- package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +4 -59
- package/dist/src/code-intelligence/CodeIntelligenceManager.js +26 -99
- package/dist/src/code-intelligence/ContextLedger.d.ts +0 -4
- package/dist/src/code-intelligence/ContextLedger.js +0 -10
- package/dist/src/code-intelligence/ContextRouter.d.ts +0 -6
- package/dist/src/code-intelligence/ContextRouter.js +0 -8
- package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.d.ts +0 -2
- package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.js +5 -12
- package/dist/src/code-intelligence/codegraph/CodeGraphProvider.d.ts +0 -6
- package/dist/src/code-intelligence/codegraph/CodeGraphProvider.js +0 -6
- package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.d.ts +0 -5
- package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.js +1 -17
- package/dist/src/code-intelligence/codegraph/repoExploreTool.d.ts +0 -5
- package/dist/src/code-intelligence/codegraph/repoExploreTool.js +0 -5
- package/dist/src/code-intelligence/repository.d.ts +0 -9
- package/dist/src/code-intelligence/repository.js +1 -11
- package/dist/src/code-intelligence/types.d.ts +0 -8
- package/dist/src/codex-auth.d.ts +0 -44
- package/dist/src/codex-auth.js +0 -45
- package/dist/src/codex-browser-auth.d.ts +0 -13
- package/dist/src/codex-browser-auth.js +3 -20
- package/dist/src/codex-errors.js +0 -2
- package/dist/src/codex-executable.d.ts +0 -2
- package/dist/src/codex-executable.js +1 -7
- package/dist/src/codex-provider.d.ts +0 -13
- package/dist/src/codex-provider.js +0 -28
- package/dist/src/codex-rpc.d.ts +0 -10
- package/dist/src/codex-rpc.js +0 -12
- package/dist/src/coding-tools.d.ts +4 -26
- package/dist/src/coding-tools.js +161 -181
- package/dist/src/command-metrics.d.ts +0 -4
- package/dist/src/command-output-tap.d.ts +0 -11
- package/dist/src/command-output-tap.js +0 -3
- package/dist/src/command-screens.d.ts +24 -0
- package/dist/src/command-screens.js +132 -100
- package/dist/src/commands.d.ts +6 -63
- package/dist/src/commands.js +20 -100
- package/dist/src/completion-gates.d.ts +0 -47
- package/dist/src/completion-gates.js +0 -14
- package/dist/src/completion.d.ts +0 -98
- package/dist/src/completion.js +2 -239
- package/dist/src/config.d.ts +11 -116
- package/dist/src/config.js +39 -171
- package/dist/src/context-budget.d.ts +0 -22
- package/dist/src/context-budget.js +0 -44
- package/dist/src/context-compaction.d.ts +29 -6
- package/dist/src/context-compaction.js +94 -25
- package/dist/src/context-selection.d.ts +0 -24
- package/dist/src/context-selection.js +0 -34
- package/dist/src/dashboard-view.d.ts +0 -2
- package/dist/src/dashboard-view.js +0 -35
- package/dist/src/dashboard.d.ts +0 -2
- package/dist/src/dashboard.js +0 -9
- package/dist/src/deadline.d.ts +0 -45
- package/dist/src/deadline.js +0 -54
- package/dist/src/decision/ContinuationAdapter.d.ts +0 -5
- package/dist/src/decision/ContinuationAdapter.js +0 -5
- package/dist/src/decision/DecisionEngine.d.ts +0 -4
- package/dist/src/decision/DecisionManager.d.ts +0 -1
- package/dist/src/decision/DecisionManager.js +2 -7
- package/dist/src/decision/DecisionPolicy.d.ts +0 -1
- package/dist/src/decision/DecisionPolicy.js +0 -1
- package/dist/src/decision/FactContinuations.d.ts +11 -43
- package/dist/src/decision/FactContinuations.js +126 -95
- package/dist/src/decision/FactServiceGate.d.ts +0 -1
- package/dist/src/decision/FactServiceGate.js +0 -4
- package/dist/src/decision/PreparedSteps.d.ts +0 -15
- package/dist/src/decision/PreparedSteps.js +0 -10
- package/dist/src/decision/applyToolMenu.d.ts +0 -1
- package/dist/src/decision/applyToolMenu.js +1 -5
- package/dist/src/decision/checks.d.ts +15 -28
- package/dist/src/decision/checks.js +118 -49
- package/dist/src/decision/facts.d.ts +0 -16
- package/dist/src/decision/facts.js +0 -30
- package/dist/src/decision/guidancePolicy.js +0 -1
- package/dist/src/decision/hostedPolicy.d.ts +0 -6
- package/dist/src/decision/hostedPolicy.js +0 -7
- package/dist/src/decision/hostedSkills.d.ts +0 -19
- package/dist/src/decision/hostedSkills.js +0 -19
- package/dist/src/decision/optimizationPolicy.d.ts +0 -3
- package/dist/src/decision/optimizationPolicy.js +1 -4
- package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +0 -7
- package/dist/src/decision/providers/AndorraDecisionProvider.js +4 -27
- package/dist/src/decision/providers/HttpDecisionProvider.d.ts +0 -2
- package/dist/src/decision/providers/HttpDecisionProvider.js +0 -6
- package/dist/src/decision/routeTools.d.ts +0 -8
- package/dist/src/decision/routeTools.js +1 -8
- package/dist/src/decision/toolFamilies.d.ts +0 -1
- package/dist/src/decision/toolFamilies.js +0 -1
- package/dist/src/decision/toolMenu.d.ts +0 -3
- package/dist/src/decision/toolMenu.js +0 -4
- package/dist/src/decision/types.d.ts +0 -6
- package/dist/src/default-graph.d.ts +0 -9
- package/dist/src/default-graph.js +0 -9
- package/dist/src/delegation-changes.d.ts +0 -56
- package/dist/src/delegation-changes.js +4 -130
- package/dist/src/diff-preview.d.ts +0 -1
- package/dist/src/diff-preview.js +0 -17
- package/dist/src/duration.d.ts +0 -50
- package/dist/src/duration.js +0 -50
- package/dist/src/efficiency.d.ts +0 -39
- package/dist/src/efficiency.js +0 -16
- package/dist/src/engine/protocol.d.ts +0 -2
- package/dist/src/engine/protocol.js +0 -2
- package/dist/src/engine-streams.d.ts +0 -9
- package/dist/src/extensions.d.ts +3 -2
- package/dist/src/extensions.js +63 -35
- package/dist/src/favicons.d.ts +0 -26
- package/dist/src/favicons.js +0 -34
- package/dist/src/file-diff.d.ts +2 -58
- package/dist/src/file-diff.js +0 -32
- package/dist/src/file-read-key.d.ts +0 -7
- package/dist/src/file-read-key.js +0 -7
- package/dist/src/file-read-state.d.ts +0 -1
- package/dist/src/file-read-state.js +0 -4
- package/dist/src/firefox-cookies.d.ts +0 -34
- package/dist/src/firefox-cookies.js +1 -55
- package/dist/src/git-identity-audit.d.ts +27 -0
- package/dist/src/git-identity-audit.js +286 -0
- package/dist/src/git-identity-guard.d.ts +4 -0
- package/dist/src/git-identity-guard.js +998 -0
- package/dist/src/git-identity-hold.d.ts +12 -0
- package/dist/src/git-identity-hold.js +81 -0
- package/dist/src/git-summary.d.ts +0 -58
- package/dist/src/git-summary.js +2 -212
- package/dist/src/goal-completion-verification.d.ts +2 -2
- package/dist/src/goal-completion-verification.js +3 -6
- package/dist/src/graph-account.d.ts +0 -21
- package/dist/src/graph-account.js +0 -17
- package/dist/src/graph-editor-session.d.ts +0 -1
- package/dist/src/graph-editor-session.js +0 -3
- package/dist/src/graph-health.d.ts +0 -63
- package/dist/src/graph-health.js +0 -57
- package/dist/src/graph-manager-chat.d.ts +5 -155
- package/dist/src/graph-manager-chat.js +2 -177
- package/dist/src/graph-provider-portability.d.ts +1 -21
- package/dist/src/graph-provider-portability.js +6 -45
- package/dist/src/graph-quota.d.ts +0 -33
- package/dist/src/graph-quota.js +1 -44
- package/dist/src/graph-runner.d.ts +0 -1
- package/dist/src/graph-runner.js +31 -391
- package/dist/src/graph-selection.d.ts +0 -14
- package/dist/src/graph-selection.js +0 -14
- package/dist/src/graph-server.d.ts +2 -10
- package/dist/src/graph-server.js +39 -101
- package/dist/src/graph-studio-features.d.ts +0 -5
- package/dist/src/graph-studio-features.js +2 -42
- package/dist/src/graph-sync.d.ts +0 -78
- package/dist/src/graph-sync.js +5 -201
- package/dist/src/graph-tool.d.ts +0 -18
- package/dist/src/graph-tool.js +0 -27
- package/dist/src/graph-ui/app.js +152 -491
- package/dist/src/graph-ui/compat.js +0 -7
- package/dist/src/graph-ui/controls.css +0 -48
- package/dist/src/graph-ui/controls.js +0 -88
- package/dist/src/graph-ui/drafts.js +0 -12
- package/dist/src/graph-ui/edge-router.js +0 -62
- package/dist/src/graph-ui/embed.js +0 -59
- package/dist/src/graph-ui/icons.js +0 -8
- package/dist/src/graph-ui/library.css +0 -5
- package/dist/src/graph-ui/manager-markdown.js +0 -11
- package/dist/src/graph-ui/manager-state.js +1 -78
- package/dist/src/graph-ui/manager.css +0 -18
- package/dist/src/graph-ui/manager.js +3 -180
- package/dist/src/graph-ui/model-picker.js +0 -29
- package/dist/src/graph-ui/sidebar.js +2 -3
- package/dist/src/graph-ui/skill-picker.js +373 -39
- package/dist/src/graph-ui/studio-canvas.js +3 -38
- package/dist/src/graph-ui/studio.css +0 -18
- package/dist/src/graph-ui/studio.js +3 -71
- package/dist/src/graph-ui/style.css +11 -134
- package/dist/src/graph-ui/theme.js +1 -26
- package/dist/src/graph-ui/tokens.css +15 -114
- package/dist/src/graphs.d.ts +6 -157
- package/dist/src/graphs.js +65 -266
- package/dist/src/grep-regex-worker.js +0 -2
- package/dist/src/grep-regex.d.ts +1 -5
- package/dist/src/grep-regex.js +6 -8
- package/dist/src/grok-provider.d.ts +0 -17
- package/dist/src/grok-provider.js +1 -26
- package/dist/src/handoffs.d.ts +0 -11
- package/dist/src/handoffs.js +0 -13
- package/dist/src/hardened-runtime.d.ts +0 -10
- package/dist/src/hardened-runtime.js +8 -46
- package/dist/src/harness-home.d.ts +21 -0
- package/dist/src/harness-home.js +87 -0
- package/dist/src/host-process-guard.d.ts +0 -50
- package/dist/src/host-process-guard.js +0 -641
- package/dist/src/limits.d.ts +0 -64
- package/dist/src/limits.js +0 -62
- package/dist/src/managed-sign-in.d.ts +0 -12
- package/dist/src/managed-sign-in.js +0 -16
- package/dist/src/markdown.d.ts +0 -28
- package/dist/src/markdown.js +1 -175
- package/dist/src/mcp.d.ts +0 -99
- package/dist/src/mcp.js +4 -170
- package/dist/src/membership-errors.d.ts +0 -14
- package/dist/src/membership-errors.js +0 -13
- package/dist/src/membership.d.ts +2 -60
- package/dist/src/membership.js +0 -85
- package/dist/src/memory/LocalToolMemory.d.ts +0 -1
- package/dist/src/memory/LocalToolMemory.js +2 -7
- package/dist/src/memory/MemoryDistiller.js +0 -15
- package/dist/src/memory/MemoryManager.d.ts +0 -3
- package/dist/src/memory/MemoryManager.js +6 -18
- package/dist/src/memory/MemoryPolicy.d.ts +0 -2
- package/dist/src/memory/MemoryPolicy.js +0 -2
- package/dist/src/memory/MemoryProvider.d.ts +0 -6
- package/dist/src/memory/MemoryRetriever.js +0 -7
- package/dist/src/memory/PermissionMemoryProvider.d.ts +0 -1
- package/dist/src/memory/PermissionMemoryProvider.js +0 -1
- package/dist/src/memory/ProjectMemory.d.ts +5 -40
- package/dist/src/memory/ProjectMemory.js +22 -47
- package/dist/src/memory/ToolFailureLessons.d.ts +0 -3
- package/dist/src/memory/ToolFailureLessons.js +0 -6
- package/dist/src/memory/providers/NoOpMemoryProvider.d.ts +0 -1
- package/dist/src/memory/providers/NoOpMemoryProvider.js +0 -1
- package/dist/src/memory/redaction.d.ts +0 -5
- package/dist/src/memory/redaction.js +0 -11
- package/dist/src/memory/repository.d.ts +0 -6
- package/dist/src/memory/repository.js +2 -12
- package/dist/src/memory/types.d.ts +0 -1
- package/dist/src/model-health-cache.d.ts +0 -38
- package/dist/src/model-health-cache.js +1 -49
- package/dist/src/model-metadata.d.ts +0 -18
- package/dist/src/model-metadata.js +2 -42
- package/dist/src/model-override.d.ts +0 -36
- package/dist/src/model-override.js +0 -43
- package/dist/src/model-tiers.d.ts +0 -13
- package/dist/src/model-tiers.js +0 -23
- package/dist/src/opencode-catalog.d.ts +0 -2
- package/dist/src/opencode-catalog.js +0 -11
- package/dist/src/opencode-cli-provider.d.ts +0 -35
- package/dist/src/opencode-cli-provider.js +1 -44
- package/dist/src/opencode-provider.d.ts +0 -2
- package/dist/src/opencode-provider.js +1 -16
- package/dist/src/package-name.d.ts +0 -2
- package/dist/src/package-name.js +0 -2
- package/dist/src/paged-transcript.d.ts +0 -11
- package/dist/src/paged-transcript.js +2 -20
- package/dist/src/palette.d.ts +0 -63
- package/dist/src/palette.js +0 -63
- package/dist/src/permissions.d.ts +0 -15
- package/dist/src/permissions.js +0 -17
- package/dist/src/powershell-pool.d.ts +0 -9
- package/dist/src/powershell-pool.js +3 -26
- package/dist/src/process-warnings.d.ts +4 -0
- package/dist/src/process-warnings.js +103 -0
- package/dist/src/profile.d.ts +0 -43
- package/dist/src/profile.js +0 -43
- package/dist/src/project-reservation.d.ts +11 -0
- package/dist/src/project-reservation.js +143 -0
- package/dist/src/provider-connection.d.ts +0 -18
- package/dist/src/provider-connection.js +0 -39
- package/dist/src/provider-engine.d.ts +0 -21
- package/dist/src/provider-engine.js +1 -96
- package/dist/src/provider-import.d.ts +0 -49
- package/dist/src/provider-import.js +0 -60
- package/dist/src/provider-keys.d.ts +1 -36
- package/dist/src/provider-keys.js +5 -48
- package/dist/src/provider-settings.d.ts +0 -2
- package/dist/src/provider-settings.js +0 -32
- package/dist/src/providers.d.ts +0 -217
- package/dist/src/providers.js +0 -315
- package/dist/src/pull-requests.d.ts +0 -173
- package/dist/src/pull-requests.js +5 -195
- package/dist/src/qa/browser/PlaywrightRunner.d.ts +0 -7
- package/dist/src/qa/browser/PlaywrightRunner.js +2 -16
- package/dist/src/qa/command-policy.d.ts +0 -23
- package/dist/src/qa/command-policy.js +0 -30
- package/dist/src/qa/guidance.d.ts +0 -21
- package/dist/src/qa/guidance.js +0 -20
- package/dist/src/qa/profile/ProjectInspector.d.ts +0 -4
- package/dist/src/qa/profile/ProjectInspector.js +0 -6
- package/dist/src/qa/profile/QaConfigLoader.d.ts +0 -7
- package/dist/src/qa/profile/QaConfigLoader.js +0 -6
- package/dist/src/qa/profile/QaProfile.d.ts +0 -7
- package/dist/src/qa/profile/QaProfile.js +0 -7
- package/dist/src/qa/profile/yaml.d.ts +0 -9
- package/dist/src/qa/profile/yaml.js +0 -13
- package/dist/src/qa/qa-authorize.d.ts +0 -19
- package/dist/src/qa/qa-authorize.js +4 -11
- package/dist/src/qa/runtime/ProcessManager.d.ts +0 -31
- package/dist/src/qa/runtime/ProcessManager.js +4 -41
- package/dist/src/qa/runtime/PtyManager.d.ts +0 -4
- package/dist/src/qa/runtime/PtyManager.js +1 -7
- package/dist/src/qa/runtime/changes.d.ts +0 -11
- package/dist/src/qa/runtime/changes.js +1 -3
- package/dist/src/qa/tools.d.ts +0 -10
- package/dist/src/qa/tools.js +0 -12
- package/dist/src/qa/types.d.ts +0 -13
- package/dist/src/react-runtime.d.ts +2 -21
- package/dist/src/react-runtime.js +95 -415
- package/dist/src/read-document-doc.d.ts +0 -6
- package/dist/src/read-document-doc.js +0 -55
- package/dist/src/read-document-docx.d.ts +0 -16
- package/dist/src/read-document-docx.js +2 -69
- package/dist/src/read-document-text.d.ts +0 -17
- package/dist/src/read-document-text.js +0 -22
- package/dist/src/read-document-tool.d.ts +0 -31
- package/dist/src/read-document-tool.js +0 -30
- package/dist/src/read-document.d.ts +0 -49
- package/dist/src/read-document.js +1 -67
- package/dist/src/read-image.d.ts +0 -32
- package/dist/src/read-image.js +0 -33
- package/dist/src/remote/cert.d.ts +0 -18
- package/dist/src/remote/cert.js +0 -44
- package/dist/src/remote/client.d.ts +0 -70
- package/dist/src/remote/client.js +1 -116
- package/dist/src/remote/command.js +0 -17
- package/dist/src/remote/engine-pool.d.ts +0 -152
- package/dist/src/remote/engine-pool.js +17 -335
- package/dist/src/remote/errors.d.ts +0 -15
- package/dist/src/remote/errors.js +0 -7
- package/dist/src/remote/network.d.ts +0 -26
- package/dist/src/remote/network.js +1 -34
- package/dist/src/remote/pairing.d.ts +16 -51
- package/dist/src/remote/pairing.js +50 -57
- package/dist/src/remote/pem.d.ts +0 -4
- package/dist/src/remote/pem.js +0 -4
- package/dist/src/remote/roots.d.ts +0 -20
- package/dist/src/remote/roots.js +0 -8
- package/dist/src/remote/serve.d.ts +0 -47
- package/dist/src/remote/serve.js +0 -30
- package/dist/src/remote/server.d.ts +0 -14
- package/dist/src/remote/server.js +1 -79
- package/dist/src/remote/types.d.ts +1 -32
- package/dist/src/remote/types.js +0 -10
- package/dist/src/run-control.d.ts +0 -7
- package/dist/src/run-control.js +0 -7
- package/dist/src/run-progress.d.ts +0 -170
- package/dist/src/run-progress.js +0 -285
- package/dist/src/run-records.d.ts +0 -443
- package/dist/src/run-records.js +14 -687
- package/dist/src/run-temp.d.ts +12 -0
- package/dist/src/run-temp.js +50 -0
- package/dist/src/runtime.d.ts +10 -228
- package/dist/src/runtime.js +0 -127
- package/dist/src/sandbox-child.js +0 -1
- package/dist/src/save-lock.d.ts +0 -12
- package/dist/src/save-lock.js +0 -28
- package/dist/src/screen-selection.d.ts +0 -23
- package/dist/src/screen-selection.js +0 -22
- package/dist/src/secret-redaction.d.ts +0 -12
- package/dist/src/secret-redaction.js +0 -45
- package/dist/src/session-changes.d.ts +4 -80
- package/dist/src/session-changes.js +25 -130
- package/dist/src/session-goal.d.ts +129 -0
- package/dist/src/session-goal.js +230 -0
- package/dist/src/session-monitor.d.ts +1 -10
- package/dist/src/session-monitor.js +2 -39
- package/dist/src/session-reaper.d.ts +0 -15
- package/dist/src/session-reaper.js +0 -14
- package/dist/src/session-skills.d.ts +15 -44
- package/dist/src/session-skills.js +75 -60
- package/dist/src/session-summary.d.ts +0 -26
- package/dist/src/session-summary.js +0 -32
- package/dist/src/session-title.d.ts +0 -1
- package/dist/src/session-title.js +0 -2
- package/dist/src/sessions.d.ts +2 -122
- package/dist/src/sessions.js +7 -178
- package/dist/src/shell.d.ts +3 -20
- package/dist/src/shell.js +8 -72
- package/dist/src/side-panel.d.ts +5 -99
- package/dist/src/side-panel.js +76 -133
- package/dist/src/sign-in-detection.d.ts +0 -39
- package/dist/src/sign-in-detection.js +0 -43
- package/dist/src/sign-in-offer.d.ts +1 -19
- package/dist/src/sign-in-offer.js +0 -13
- package/dist/src/skill-commands.d.ts +0 -1
- package/dist/src/skill-commands.js +1 -4
- package/dist/src/skills/bundled/control-browser/SKILL.md +1 -1
- package/dist/src/skills/bundled/provenance.json +1 -1
- package/dist/src/skills/invocable-skills.d.ts +0 -18
- package/dist/src/skills/invocable-skills.js +0 -17
- package/dist/src/skills/project-skills.d.ts +0 -1
- package/dist/src/skills/project-skills.js +0 -3
- package/dist/src/skills/prompt-skills.js +0 -14
- package/dist/src/skills/runtime-skills.d.ts +0 -13
- package/dist/src/skills/runtime-skills.js +0 -37
- package/dist/src/stall-recovery.d.ts +0 -25
- package/dist/src/stall-recovery.js +0 -38
- package/dist/src/stray-files.d.ts +0 -9
- package/dist/src/stray-files.js +0 -16
- package/dist/src/structured-step.d.ts +0 -22
- package/dist/src/structured-step.js +0 -22
- package/dist/src/subagent-run.d.ts +0 -163
- package/dist/src/subagent-run.js +4 -373
- package/dist/src/subagent-tree.d.ts +32 -0
- package/dist/src/subagent-tree.js +128 -0
- package/dist/src/telemetry/aggregate.d.ts +0 -37
- package/dist/src/telemetry/aggregate.js +0 -40
- package/dist/src/telemetry/capture-core.d.ts +0 -87
- package/dist/src/telemetry/capture-core.js +0 -67
- package/dist/src/telemetry/capture.d.ts +0 -1
- package/dist/src/telemetry/capture.js +0 -3
- package/dist/src/telemetry/classify.d.ts +0 -58
- package/dist/src/telemetry/classify.js +0 -60
- package/dist/src/telemetry/decision-capture.d.ts +0 -1
- package/dist/src/telemetry/emitter.d.ts +0 -30
- package/dist/src/telemetry/emitter.js +1 -62
- package/dist/src/telemetry/gate.d.ts +0 -29
- package/dist/src/telemetry/gate.js +0 -22
- package/dist/src/telemetry/identity.d.ts +0 -13
- package/dist/src/telemetry/identity.js +0 -29
- package/dist/src/telemetry/outbox.d.ts +0 -64
- package/dist/src/telemetry/outbox.js +1 -108
- package/dist/src/telemetry/schema.d.ts +1 -49
- package/dist/src/telemetry/schema.js +1 -82
- package/dist/src/telemetry/state.d.ts +0 -53
- package/dist/src/telemetry/state.js +0 -64
- package/dist/src/telemetry/surface.d.ts +0 -31
- package/dist/src/telemetry/surface.js +1 -39
- package/dist/src/telemetry/uploader.d.ts +0 -11
- package/dist/src/telemetry/uploader.js +0 -46
- package/dist/src/telemetry/uploads.d.ts +0 -11
- package/dist/src/telemetry/uploads.js +0 -11
- package/dist/src/telemetry/version.d.ts +0 -4
- package/dist/src/telemetry/version.js +0 -14
- package/dist/src/telemetry/workspace.d.ts +0 -7
- package/dist/src/telemetry/workspace.js +1 -22
- package/dist/src/terminal-ui.d.ts +14 -523
- package/dist/src/terminal-ui.js +74 -876
- package/dist/src/test-edit-guard.d.ts +74 -0
- package/dist/src/test-edit-guard.js +269 -0
- package/dist/src/text.d.ts +0 -1
- package/dist/src/text.js +0 -1
- package/dist/src/time-limit.d.ts +0 -36
- package/dist/src/time-limit.js +0 -37
- package/dist/src/timers.d.ts +0 -161
- package/dist/src/timers.js +0 -126
- package/dist/src/todos.d.ts +0 -1
- package/dist/src/todos.js +0 -3
- package/dist/src/token-rate.d.ts +0 -94
- package/dist/src/token-rate.js +0 -154
- package/dist/src/tool-activity.d.ts +0 -6
- package/dist/src/tool-activity.js +0 -7
- package/dist/src/tool-availability.d.ts +0 -13
- package/dist/src/tool-availability.js +1 -14
- package/dist/src/tool-call-clock.d.ts +1 -4
- package/dist/src/tool-call-clock.js +0 -13
- package/dist/src/tool-catalog.d.ts +0 -11
- package/dist/src/tool-catalog.js +0 -23
- package/dist/src/tool-dependencies.d.ts +0 -5
- package/dist/src/tool-dependencies.js +0 -4
- package/dist/src/tool-diff-stats.d.ts +0 -23
- package/dist/src/tool-diff-stats.js +0 -49
- package/dist/src/tool-errors.d.ts +9 -7
- package/dist/src/tool-errors.js +13 -6
- package/dist/src/tool-failure-tracker.d.ts +3 -11
- package/dist/src/tool-failure-tracker.js +19 -27
- package/dist/src/tool-names.d.ts +0 -16
- package/dist/src/tool-names.js +0 -12
- package/dist/src/tool-profile.d.ts +6 -0
- package/dist/src/tool-profile.js +23 -0
- package/dist/src/tool-result-filter.d.ts +0 -19
- package/dist/src/tool-result-filter.js +1 -66
- package/dist/src/tool-schema-compatibility.d.ts +0 -6
- package/dist/src/tool-schema-compatibility.js +0 -9
- package/dist/src/tools.d.ts +0 -4
- package/dist/src/tools.js +11 -114
- package/dist/src/trajectory.d.ts +0 -13
- package/dist/src/trajectory.js +23 -79
- package/dist/src/transcript.d.ts +0 -41
- package/dist/src/transcript.js +2 -60
- package/dist/src/types.d.ts +1 -168
- package/dist/src/untracked-file-removal.js +0 -20
- package/dist/src/update-check.d.ts +0 -14
- package/dist/src/update-check.js +1 -15
- package/dist/src/update.d.ts +0 -35
- package/dist/src/update.js +0 -100
- package/dist/src/usage-analytics.d.ts +17 -17
- package/dist/src/usage-analytics.js +168 -209
- package/dist/src/web-search.d.ts +0 -23
- package/dist/src/web-search.js +1 -27
- package/dist/src/widgets.d.ts +0 -25
- package/dist/src/widgets.js +0 -24
- package/dist/src/workspace-facts.d.ts +0 -12
- package/dist/src/workspace-facts.js +1 -18
- package/dist/src/workspace-git-metadata.d.ts +0 -16
- package/dist/src/workspace-git-metadata.js +0 -21
- package/dist/src/workspace-instructions.d.ts +3 -15
- package/dist/src/workspace-instructions.js +6 -19
- package/package.json +2 -2
package/dist/src/automations.js
CHANGED
|
@@ -1,11 +1,21 @@
|
|
|
1
1
|
import { randomUUID } from 'node:crypto';
|
|
2
2
|
import { readFile, realpath, rename, stat, unlink, writeFile } from 'node:fs/promises';
|
|
3
|
-
import {
|
|
3
|
+
import { hostname } from 'node:os';
|
|
4
|
+
import { isAbsolute, join, resolve } from 'node:path';
|
|
4
5
|
import { setTimeout as delay } from 'node:timers/promises';
|
|
5
6
|
import { CronExpressionParser } from 'cron-parser';
|
|
6
7
|
import { configDirectory } from './config.js';
|
|
7
8
|
import { acquireSaveLock, SaveLockBusyError } from './save-lock.js';
|
|
8
9
|
import { isPermissionMode } from './permissions.js';
|
|
10
|
+
import { folderChangeBusy, folderChangeHeld } from './project-reservation.js';
|
|
11
|
+
const HOLD_MS = 10 * 60_000;
|
|
12
|
+
function holdIsLive(hold) {
|
|
13
|
+
if (Date.now() - hold.at >= HOLD_MS)
|
|
14
|
+
return false;
|
|
15
|
+
if (hold.host !== hostname())
|
|
16
|
+
return true;
|
|
17
|
+
return alive(hold.pid);
|
|
18
|
+
}
|
|
9
19
|
const object = (value) => !!value && typeof value === 'object' && !Array.isArray(value);
|
|
10
20
|
function text(value, name, max) {
|
|
11
21
|
if (typeof value !== 'string' || !value.trim() || value.length > max || value.includes('\0'))
|
|
@@ -31,7 +41,6 @@ export function validateAutomationSchedule(value) {
|
|
|
31
41
|
}
|
|
32
42
|
else if (value.kind === 'cron') {
|
|
33
43
|
const expression = text(value.expression, 'expression', 200).trim();
|
|
34
|
-
// Five fields keep all schedules minute-grained. Disallow random hash fields for deterministic restarts.
|
|
35
44
|
if (expression.split(/\s+/).length !== 5 || /\?|(?:^|[,\s])H(?:\(|\/|[,\s]|$)/i.test(expression))
|
|
36
45
|
throw new Error('CRON must have five deterministic fields: minute hour day month weekday');
|
|
37
46
|
schedule = { kind: 'cron', expression, timeZone };
|
|
@@ -61,7 +70,7 @@ function execution(value) {
|
|
|
61
70
|
}
|
|
62
71
|
return result;
|
|
63
72
|
}
|
|
64
|
-
function publicJob(job) { const { claim: _claim, ...result } = job; return result; }
|
|
73
|
+
function publicJob(job) { const { claim: _claim, relink: _relink, ...result } = job; return result; }
|
|
65
74
|
function assertPermissionCeiling(job, ceiling) {
|
|
66
75
|
const ranks = { 'read-only': 0, 'plan': 0, 'ask-for-approval': 1, 'approve-for-me': 2, 'full-access': 3 };
|
|
67
76
|
if (ceiling && ranks[job.execution?.permissions ?? 'read-only'] > ranks[ceiling])
|
|
@@ -74,10 +83,10 @@ function alive(pid) { try {
|
|
|
74
83
|
catch (error) {
|
|
75
84
|
return error.code !== 'ESRCH';
|
|
76
85
|
} }
|
|
77
|
-
/** One installation-wide store, shared by desktop engines, agent tools and the optional daemon. */
|
|
78
86
|
export class AutomationStore {
|
|
79
87
|
folder;
|
|
80
|
-
|
|
88
|
+
directory;
|
|
89
|
+
constructor(directory = configDirectory()) { this.directory = directory; this.folder = join(directory, 'automations'); }
|
|
81
90
|
async read() {
|
|
82
91
|
let raw;
|
|
83
92
|
try {
|
|
@@ -91,7 +100,6 @@ export class AutomationStore {
|
|
|
91
100
|
const value = JSON.parse(raw);
|
|
92
101
|
if (!object(value) || value.version !== 1 || !Array.isArray(value.jobs))
|
|
93
102
|
throw new Error('Invalid automation store; jobs.json was preserved');
|
|
94
|
-
// Fail closed rather than overwrite unknown/corrupt records.
|
|
95
103
|
for (const job of value.jobs) {
|
|
96
104
|
if (!object(job) || typeof job.id !== 'string' || !/^[a-f0-9-]{36}$/.test(job.id) || typeof job.nextRunAt !== 'string' || !Number.isFinite(Date.parse(job.nextRunAt)) || typeof job.project !== 'string' || !isAbsolute(job.project) || typeof job.enabled !== 'boolean' || !['user', 'agent'].includes(String(job.source)))
|
|
97
105
|
throw new Error('Invalid automation record; jobs.json was preserved');
|
|
@@ -101,6 +109,10 @@ export class AutomationStore {
|
|
|
101
109
|
execution(job.execution);
|
|
102
110
|
if (job.claim !== undefined && (!object(job.claim) || typeof job.claim.token !== 'string' || !Number.isSafeInteger(job.claim.pid) || Number(job.claim.pid) <= 0))
|
|
103
111
|
throw new Error('Invalid automation claim; jobs.json was preserved');
|
|
112
|
+
if (job.relink !== undefined && (!object(job.relink) || !Number.isSafeInteger(Number(job.relink.pid)) || Number(job.relink.pid) <= 0 || typeof job.relink.project !== 'string' || !Number.isFinite(Number(job.relink.at))))
|
|
113
|
+
throw new Error('Invalid automation folder hold; jobs.json was preserved');
|
|
114
|
+
if (job.relink !== undefined && !holdIsLive(job.relink))
|
|
115
|
+
delete job.relink;
|
|
104
116
|
if (object(job.claim) && !alive(Number(job.claim.pid))) {
|
|
105
117
|
const previous = object(job.lastRun) ? job.lastRun : {};
|
|
106
118
|
job.lastRun = { ...previous, at: typeof previous.at === 'string' ? previous.at : new Date().toISOString(), status: 'interrupted', error: 'The scheduler process exited before reporting completion.' };
|
|
@@ -155,6 +167,10 @@ export class AutomationStore {
|
|
|
155
167
|
}
|
|
156
168
|
async create(value, source = 'user') {
|
|
157
169
|
const input = await this.input(value);
|
|
170
|
+
// A change has already moved the jobs it found, so a job added to that folder while it is still held would keep the
|
|
171
|
+
// path the project is leaving. The folder's own reservation is what makes the caller wait the change out.
|
|
172
|
+
if (await folderChangeHeld(this.directory, input.project))
|
|
173
|
+
throw new Error('This project folder is changing. Wait for it to finish, then create the automation.');
|
|
158
174
|
return this.mutate(jobs => {
|
|
159
175
|
if (jobs.length >= 500)
|
|
160
176
|
throw new Error('At most 500 automations can be stored');
|
|
@@ -170,7 +186,14 @@ export class AutomationStore {
|
|
|
170
186
|
if (!job)
|
|
171
187
|
throw new Error('Automation not found');
|
|
172
188
|
assertPermissionCeiling(job, maxPermissions);
|
|
189
|
+
if (job.relink)
|
|
190
|
+
throw new Error('This project folder is changing. Wait for it to finish, then edit the automation.');
|
|
173
191
|
const input = await this.input(value, job);
|
|
192
|
+
// Moving a job into a folder that is being changed leaves it pointing at the path that project is leaving, for the
|
|
193
|
+
// same reason a newly created one would.
|
|
194
|
+
if (resolve(input.project) !== resolve(job.project) && await folderChangeHeld(this.directory, input.project)) {
|
|
195
|
+
throw new Error('This project folder is changing. Wait for it to finish, then move the automation there.');
|
|
196
|
+
}
|
|
174
197
|
const changedSchedule = JSON.stringify(input.schedule) !== JSON.stringify(job.schedule) || (!job.enabled && input.enabled);
|
|
175
198
|
Object.assign(job, input, { updatedAt: new Date().toISOString() }, changedSchedule ? { nextRunAt: nextAutomationRun(input.schedule) } : {});
|
|
176
199
|
if (input.enabled)
|
|
@@ -181,7 +204,58 @@ export class AutomationStore {
|
|
|
181
204
|
async delete(id) {
|
|
182
205
|
await this.mutate(jobs => { const index = jobs.findIndex(job => job.id === id); if (index < 0)
|
|
183
206
|
throw new Error('Automation not found'); if (jobs[index].claim && alive(jobs[index].claim.pid))
|
|
184
|
-
throw new Error('Wait for the running automation to finish before deleting it'); jobs.
|
|
207
|
+
throw new Error('Wait for the running automation to finish before deleting it'); if (jobs[index].relink)
|
|
208
|
+
throw new Error('This project folder is changing. Wait for it to finish, then delete the automation.'); jobs.splice(index, 1); });
|
|
209
|
+
}
|
|
210
|
+
/** True while a job that runs in `project` holds a live claim, meaning one of its runs is still in flight. */
|
|
211
|
+
async isRunningFor(project) {
|
|
212
|
+
return (await this.read()).some(job => resolve(job.project) === resolve(project) && job.claim !== undefined && alive(job.claim.pid));
|
|
213
|
+
}
|
|
214
|
+
/**
|
|
215
|
+
* Holds every automation scheduled in `project` so the scheduler cannot start one while its folder changes, and keeps
|
|
216
|
+
* holding until relinkProject or releaseProject gives it back. The hold is written in the same mutation that checks for
|
|
217
|
+
* an occurrence already running, so a claim cannot slip in between the look and the hold: from this point a claim of a
|
|
218
|
+
* held job gets nothing, which is what stops an occurrence from executing against the folder being left behind.
|
|
219
|
+
* Returns 'running' when one is already in flight, which is the caller's cue to defer the change.
|
|
220
|
+
*/
|
|
221
|
+
async reserveProject(project) {
|
|
222
|
+
return this.mutate(jobs => {
|
|
223
|
+
const matching = jobs.filter(job => resolve(job.project) === resolve(project));
|
|
224
|
+
if (matching.some(job => job.claim !== undefined && alive(job.claim.pid)))
|
|
225
|
+
return 'running';
|
|
226
|
+
const at = Date.now();
|
|
227
|
+
for (const job of matching)
|
|
228
|
+
job.relink = { pid: process.pid, host: hostname(), at, project };
|
|
229
|
+
return matching.length;
|
|
230
|
+
});
|
|
231
|
+
}
|
|
232
|
+
/**
|
|
233
|
+
* Points the automations scheduled in a moved folder at its new location, so a scheduled run follows the project
|
|
234
|
+
* instead of failing against a folder that no longer exists. Runs under the store's save lock, the same one a claim
|
|
235
|
+
* takes, so a rewrite and a claim never interleave.
|
|
236
|
+
*
|
|
237
|
+
* The hold outlives this write on purpose. A moved job is claimable again only when its change calls releaseProject,
|
|
238
|
+
* which happens after the folder itself is free. Lifting both here would let the scheduler start a run the app then
|
|
239
|
+
* refuses as busy, and a refused run pauses its job until someone opens Automations and resumes it.
|
|
240
|
+
*/
|
|
241
|
+
async relinkProject(from, to) {
|
|
242
|
+
return this.mutate(jobs => {
|
|
243
|
+
let moved = 0;
|
|
244
|
+
for (const job of jobs) {
|
|
245
|
+
if (resolve(job.project) !== resolve(from))
|
|
246
|
+
continue;
|
|
247
|
+
job.project = to;
|
|
248
|
+
job.updatedAt = new Date().toISOString();
|
|
249
|
+
moved += 1;
|
|
250
|
+
}
|
|
251
|
+
return moved;
|
|
252
|
+
});
|
|
253
|
+
}
|
|
254
|
+
/** Gives back a hold when a folder change could not finish, so an abandoned attempt never freezes the scheduler. */
|
|
255
|
+
async releaseProject(project) {
|
|
256
|
+
await this.mutate(jobs => { for (const job of jobs)
|
|
257
|
+
if (job.relink !== undefined && resolve(job.relink.project) === resolve(project))
|
|
258
|
+
delete job.relink; });
|
|
185
259
|
}
|
|
186
260
|
async runNow(id, executor, signal = new AbortController().signal, maxPermissions) {
|
|
187
261
|
const started = await this.startNow(id, executor, signal, maxPermissions);
|
|
@@ -207,6 +281,11 @@ export class AutomationStore {
|
|
|
207
281
|
return;
|
|
208
282
|
}
|
|
209
283
|
assertPermissionCeiling(job, maxPermissions);
|
|
284
|
+
if (job.relink) {
|
|
285
|
+
if (manual)
|
|
286
|
+
throw new Error('This project folder is changing. Wait for it to finish, then run the automation.');
|
|
287
|
+
return;
|
|
288
|
+
}
|
|
210
289
|
if (job.claim && alive(job.claim.pid))
|
|
211
290
|
return;
|
|
212
291
|
if (jobs.filter(item => item.claim && alive(item.claim.pid)).length >= 16) {
|
|
@@ -247,11 +326,12 @@ export class AutomationStore {
|
|
|
247
326
|
const job = jobs.find(item => item.id === claimed.id);
|
|
248
327
|
if (!job || job.claim?.token !== claimed.claim?.token)
|
|
249
328
|
return;
|
|
250
|
-
|
|
329
|
+
// A run the app refused because its folder is mid-change never started, so it is this occurrence that is spent, not
|
|
330
|
+
// the job: the next one runs normally. Counting it as a failure would pause an enabled automation over a folder
|
|
331
|
+
// change, which is a temporary state of the machine rather than something the automation did wrong.
|
|
332
|
+
const deferred = failure === folderChangeBusy;
|
|
333
|
+
job.lastRun = { at: claimed.lastRun.at, status: deferred ? 'skipped' : failure ? (signal.aborted ? 'interrupted' : 'failed') : 'completed', ...result, ...(failure ? { error: failure.slice(0, 4000) } : {}) };
|
|
251
334
|
delete job.claim;
|
|
252
|
-
// A failed run (a failed health check, an engine that never started, a question nobody can
|
|
253
|
-
// answer, a run that did not succeed) would fail the same way at every later occurrence, so
|
|
254
|
-
// the job pauses until the user resumes it. A cancelled or shut-down run is not a failure.
|
|
255
335
|
if (job.lastRun.status === 'failed' && job.enabled) {
|
|
256
336
|
job.enabled = false;
|
|
257
337
|
job.pausedAfterFailure = { at: new Date().toISOString(), error: job.lastRun.error ?? 'Automation run failed.' };
|
|
@@ -261,7 +341,6 @@ export class AutomationStore {
|
|
|
261
341
|
}
|
|
262
342
|
async tick(executor, signal = new AbortController().signal, now = Date.now()) {
|
|
263
343
|
const due = (await this.list()).filter(job => job.enabled && Date.parse(job.nextRunAt) <= now);
|
|
264
|
-
// A pass starts at most four jobs. Every engine competes for the same persisted occurrence.
|
|
265
344
|
const running = [];
|
|
266
345
|
for (const job of due) {
|
|
267
346
|
if (signal.aborted || running.length >= 4)
|
|
@@ -1,40 +1,17 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The background work an engine holds, as a client lists it.
|
|
3
|
-
*
|
|
4
|
-
* Two registries keep work that outlives the tool call that started it: `AsyncProcess` jobs (and
|
|
5
|
-
* QA dev servers) in the process manager, and `qa.terminal` sessions in the PTY manager. Both are
|
|
6
|
-
* keyed by workspace, not by session, so this module adds the one fact neither holds: which
|
|
7
|
-
* session's run started each of them.
|
|
8
|
-
*/
|
|
9
1
|
export type BackgroundTaskKind = 'process' | 'terminal';
|
|
10
2
|
export interface BackgroundTaskView {
|
|
11
|
-
/** The id its own manager knows it by; unique only together with `kind` and `workspace`. */
|
|
12
3
|
id: string;
|
|
13
4
|
kind: BackgroundTaskKind;
|
|
14
|
-
/** The folder whose manager owns it, exactly as the manager is keyed: `background.stop` names it back. */
|
|
15
5
|
workspace: string;
|
|
16
6
|
command: string;
|
|
17
7
|
running: boolean;
|
|
18
|
-
/** Epoch milliseconds. */
|
|
19
8
|
startedAt: number;
|
|
20
9
|
endedAt?: number;
|
|
21
|
-
/** Absent while running, and for a process a signal ended. */
|
|
22
10
|
exitCode?: number;
|
|
23
|
-
/** The session whose run started it. Absent when it started outside any run. */
|
|
24
11
|
sessionId?: string;
|
|
25
12
|
}
|
|
26
13
|
export declare class BackgroundTasks {
|
|
27
|
-
/** The session each listed task was first seen under. A reused id is a new task: the key holds its start. */
|
|
28
14
|
private readonly owners;
|
|
29
|
-
/**
|
|
30
|
-
* Everything both managers hold right now.
|
|
31
|
-
*
|
|
32
|
-
* A task seen for the first time belongs to `activeSessionId`: one engine runs one task at a
|
|
33
|
-
* time, and the managers signal a start synchronously, so the run that is live when a task first
|
|
34
|
-
* appears is the run whose tool started it. Owners of tasks that are gone are forgotten here, so
|
|
35
|
-
* the map is bounded by what the managers still hold.
|
|
36
|
-
*/
|
|
37
15
|
snapshot(activeSessionId: string | undefined): BackgroundTaskView[];
|
|
38
|
-
/** Stop one task and forget it. Returns whether it was there to stop. */
|
|
39
16
|
stop(kind: unknown, workspace: unknown, id: unknown): Promise<boolean>;
|
|
40
17
|
}
|
|
@@ -1,18 +1,8 @@
|
|
|
1
1
|
import { listQaProcesses, listQaPtys, stopQaProcess, stopQaPty } from './qa/index.js';
|
|
2
|
-
/** Commands are model-authored and can be up to 32000 characters; a list row needs a line of it. */
|
|
3
2
|
const COMMAND_LIMIT = 2_000;
|
|
4
3
|
const key = (kind, workspace, id, startedAt) => `${kind}\0${workspace}\0${id}\0${startedAt}`;
|
|
5
4
|
export class BackgroundTasks {
|
|
6
|
-
/** The session each listed task was first seen under. A reused id is a new task: the key holds its start. */
|
|
7
5
|
owners = new Map();
|
|
8
|
-
/**
|
|
9
|
-
* Everything both managers hold right now.
|
|
10
|
-
*
|
|
11
|
-
* A task seen for the first time belongs to `activeSessionId`: one engine runs one task at a
|
|
12
|
-
* time, and the managers signal a start synchronously, so the run that is live when a task first
|
|
13
|
-
* appears is the run whose tool started it. Owners of tasks that are gone are forgotten here, so
|
|
14
|
-
* the map is bounded by what the managers still hold.
|
|
15
|
-
*/
|
|
16
6
|
snapshot(activeSessionId) {
|
|
17
7
|
const tasks = [];
|
|
18
8
|
const seen = new Set();
|
|
@@ -41,7 +31,6 @@ export class BackgroundTasks {
|
|
|
41
31
|
this.owners.delete(known);
|
|
42
32
|
return tasks;
|
|
43
33
|
}
|
|
44
|
-
/** Stop one task and forget it. Returns whether it was there to stop. */
|
|
45
34
|
async stop(kind, workspace, id) {
|
|
46
35
|
if (kind !== 'process' && kind !== 'terminal')
|
|
47
36
|
throw new Error('kind must be "process" or "terminal"');
|
package/dist/src/boot-trace.d.ts
CHANGED
|
@@ -1,15 +1,2 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Boot checkpoints for the engine, from process start to the first graph node.
|
|
3
|
-
*
|
|
4
|
-
* Enabled by `ANDORRA_BOOT_TRACE=1` in the engine's environment; otherwise every mark is a no-op.
|
|
5
|
-
* Each line goes to stderr, which the desktop shell forwards to the renderer, so one stream can
|
|
6
|
-
* carry the shell's, the renderer's and the engine's checkpoints side by side:
|
|
7
|
-
*
|
|
8
|
-
* [boot-trace] engine pid=1234 t=1761900000123 +2210ms cli.main
|
|
9
|
-
*
|
|
10
|
-
* `t` is the wall clock (epoch milliseconds), comparable across processes; the `+ms` column is the
|
|
11
|
-
* time since this process started, so the first mark also measures module loading.
|
|
12
|
-
*/
|
|
13
1
|
export declare const bootTraceEnabled: boolean;
|
|
14
|
-
/** Record one checkpoint. Cheap enough to leave in place: a no-op unless tracing is on. */
|
|
15
2
|
export declare function bootMark(label: string, detail?: string): void;
|
package/dist/src/boot-trace.js
CHANGED
|
@@ -1,18 +1,5 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Boot checkpoints for the engine, from process start to the first graph node.
|
|
3
|
-
*
|
|
4
|
-
* Enabled by `ANDORRA_BOOT_TRACE=1` in the engine's environment; otherwise every mark is a no-op.
|
|
5
|
-
* Each line goes to stderr, which the desktop shell forwards to the renderer, so one stream can
|
|
6
|
-
* carry the shell's, the renderer's and the engine's checkpoints side by side:
|
|
7
|
-
*
|
|
8
|
-
* [boot-trace] engine pid=1234 t=1761900000123 +2210ms cli.main
|
|
9
|
-
*
|
|
10
|
-
* `t` is the wall clock (epoch milliseconds), comparable across processes; the `+ms` column is the
|
|
11
|
-
* time since this process started, so the first mark also measures module loading.
|
|
12
|
-
*/
|
|
13
1
|
export const bootTraceEnabled = process.env.ANDORRA_BOOT_TRACE === '1';
|
|
14
2
|
const processStartedAt = Date.now() - Math.round(process.uptime() * 1000);
|
|
15
|
-
/** Record one checkpoint. Cheap enough to leave in place: a no-op unless tracing is on. */
|
|
16
3
|
export function bootMark(label, detail) {
|
|
17
4
|
if (!bootTraceEnabled)
|
|
18
5
|
return;
|
|
@@ -21,5 +8,5 @@ export function bootMark(label, detail) {
|
|
|
21
8
|
try {
|
|
22
9
|
process.stderr.write(line);
|
|
23
10
|
}
|
|
24
|
-
catch {
|
|
11
|
+
catch { }
|
|
25
12
|
}
|
|
@@ -1,5 +1,3 @@
|
|
|
1
|
-
// Activity is a recent diagnostic window; durable conversation turns and the
|
|
2
|
-
// append-only trajectory are retained independently of this display budget.
|
|
3
1
|
export const BROWSER_ACTIVITY_EVENTS = 200;
|
|
4
2
|
export const BROWSER_ACTIVITY_BYTES = 256 * 1024;
|
|
5
3
|
export function boundBrowserActivity(events) {
|
|
@@ -38,7 +38,6 @@ export interface BrowserBridgeActions {
|
|
|
38
38
|
cancel(): void;
|
|
39
39
|
answer(answer: string): void;
|
|
40
40
|
}
|
|
41
|
-
/** Each CLI owns its authenticated endpoint. A random descriptor gives other local instances discovery without sharing run ownership. */
|
|
42
41
|
export declare function createBrowserBridge(directory: string, snapshot: () => BrowserSession, actions: BrowserBridgeActions, cancellation?: AbortSignal): Promise<{
|
|
43
42
|
startRun(): void;
|
|
44
43
|
event(event: RuntimeEvent): void;
|
|
@@ -51,6 +50,5 @@ export interface LiveEndpoint {
|
|
|
51
50
|
token: string;
|
|
52
51
|
state: BrowserSession;
|
|
53
52
|
}
|
|
54
|
-
/** Discovery failure is not evidence that a CLI released its session. */
|
|
55
53
|
export declare function assertBrowserSessionUnowned(directory: string, sessionId: string): Promise<void>;
|
|
56
54
|
export declare function discoverBrowserSessions(directory: string): Promise<LiveEndpoint[]>;
|
|
@@ -40,7 +40,6 @@ export function browserAuthorized(req, token, origin) {
|
|
|
40
40
|
const expected = Buffer.from(`Bearer ${token}`);
|
|
41
41
|
return req.headers.host === new URL(origin).host && (!req.headers.origin || req.headers.origin === origin) && supplied.length === expected.length && timingSafeEqual(supplied, expected);
|
|
42
42
|
}
|
|
43
|
-
/** Each CLI owns its authenticated endpoint. A random descriptor gives other local instances discovery without sharing run ownership. */
|
|
44
43
|
export async function createBrowserBridge(directory, snapshot, actions, cancellation) {
|
|
45
44
|
const token = randomBytes(32).toString('hex');
|
|
46
45
|
const id = randomUUID();
|
|
@@ -88,16 +87,11 @@ export async function createBrowserBridge(directory, snapshot, actions, cancella
|
|
|
88
87
|
if (error.code !== 'ENOENT')
|
|
89
88
|
throw error;
|
|
90
89
|
}
|
|
91
|
-
// Archive first, with the exact primary predecessor. Hydration can recover
|
|
92
|
-
// this generation if the primary commit fails, or reject it after a newer
|
|
93
|
-
// primary-only update. Queue both writes to exclude older event checkpoints.
|
|
94
90
|
await writeSessionSnapshot(join(folder, `${value.id}.json`), JSON.stringify({ ...JSON.parse(content), previousPrimaryDigest: previous && primaryDigest(previous) }));
|
|
95
91
|
}
|
|
96
92
|
catch (error) {
|
|
97
93
|
archiveError = error;
|
|
98
94
|
}
|
|
99
|
-
// Browser storage failure must not suppress ordinary CLI persistence.
|
|
100
|
-
// Acceptance still rejects unless both records were committed successfully.
|
|
101
95
|
try {
|
|
102
96
|
writes.assert();
|
|
103
97
|
await commitPrimary?.();
|
|
@@ -138,8 +132,6 @@ export async function createBrowserBridge(directory, snapshot, actions, cancella
|
|
|
138
132
|
return;
|
|
139
133
|
}
|
|
140
134
|
const body = await browserBody(req);
|
|
141
|
-
// The CLI can resume another session while an HTTP body is arriving.
|
|
142
|
-
// Bind every mutation to the identity the caller originally selected.
|
|
143
135
|
if (body.sessionId !== snapshot().id) {
|
|
144
136
|
browserReply(res, 409, { error: 'Session identity changed. Refresh to reconnect.' });
|
|
145
137
|
return;
|
|
@@ -153,9 +145,6 @@ export async function createBrowserBridge(directory, snapshot, actions, cancella
|
|
|
153
145
|
throw new Error('Session already running');
|
|
154
146
|
await actions.prompt(body.text);
|
|
155
147
|
}
|
|
156
|
-
// Steering authority lives in actions.steer: the snapshot status is a
|
|
157
|
-
// display value (command screens read idle) and must not shadow the
|
|
158
|
-
// actionable guard with a generic transport error.
|
|
159
148
|
else
|
|
160
149
|
actions.steer(body.text);
|
|
161
150
|
}
|
|
@@ -181,8 +170,6 @@ export async function createBrowserBridge(directory, snapshot, actions, cancella
|
|
|
181
170
|
});
|
|
182
171
|
await new Promise((resolve, reject) => { server.once('error', reject); server.listen(0, '127.0.0.1', resolve); });
|
|
183
172
|
origin = `http://127.0.0.1:${server.address().port}`;
|
|
184
|
-
// The listener starts before descriptor publication. A cancellation lets
|
|
185
|
-
// shutdown close it even when a stalled filesystem op never settles.
|
|
186
173
|
if (cancellation?.aborted) {
|
|
187
174
|
server.closeAllConnections();
|
|
188
175
|
await new Promise(resolve => server.close(() => resolve()));
|
|
@@ -194,8 +181,6 @@ export async function createBrowserBridge(directory, snapshot, actions, cancella
|
|
|
194
181
|
const descriptor = join(folder, `${id}.json`);
|
|
195
182
|
try {
|
|
196
183
|
await mkdir(folder, { recursive: true, mode: 0o700 });
|
|
197
|
-
// Publish atomically: a takeover scan reading a plain in-place write could
|
|
198
|
-
// see truncated JSON. Rename lands the descriptor whole or not at all.
|
|
199
184
|
const staged = join(folder, `.${id}.json.tmp`);
|
|
200
185
|
try {
|
|
201
186
|
await writeFile(staged, JSON.stringify({ origin, token, pid: process.pid }), { mode: 0o600 });
|
|
@@ -213,7 +198,6 @@ export async function createBrowserBridge(directory, snapshot, actions, cancella
|
|
|
213
198
|
}
|
|
214
199
|
cancellation?.removeEventListener('abort', onCancellation);
|
|
215
200
|
return {
|
|
216
|
-
// Clear the visible plan before preflight, which may fail without emitting events.
|
|
217
201
|
startRun() { syncIdentity(); runId = undefined; todos = []; void persist().catch(() => { }); },
|
|
218
202
|
event(event) {
|
|
219
203
|
syncIdentity();
|
|
@@ -244,11 +228,6 @@ export async function createBrowserBridge(directory, snapshot, actions, cancella
|
|
|
244
228
|
clearTimeout(timer);
|
|
245
229
|
writes.close();
|
|
246
230
|
}
|
|
247
|
-
// A submitted rename cannot be cancelled. Keep discovery fail-closed
|
|
248
|
-
// until it settles. The listener closes before descriptor deletion so
|
|
249
|
-
// a stalled removal on an unresponsive filesystem never holds the
|
|
250
|
-
// endpoint or the caller's shutdown; a surviving descriptor then
|
|
251
|
-
// blocks takeover conservatively until cleanup settles.
|
|
252
231
|
const cleanup = () => rm(descriptor, { force: true });
|
|
253
232
|
server.closeAllConnections();
|
|
254
233
|
await new Promise(resolve => server.close(() => resolve()));
|
|
@@ -272,7 +251,6 @@ export async function createBrowserBridge(directory, snapshot, actions, cancella
|
|
|
272
251
|
},
|
|
273
252
|
};
|
|
274
253
|
}
|
|
275
|
-
/** Only ESRCH proves that the recorded owner exited; permission errors are unknown. */
|
|
276
254
|
async function pruneExitedOwner(path, pid) {
|
|
277
255
|
if (!Number.isInteger(pid) || Number(pid) <= 0)
|
|
278
256
|
return false;
|
|
@@ -287,7 +265,6 @@ async function pruneExitedOwner(path, pid) {
|
|
|
287
265
|
}
|
|
288
266
|
return false;
|
|
289
267
|
}
|
|
290
|
-
/** Discovery failure is not evidence that a CLI released its session. */
|
|
291
268
|
export async function assertBrowserSessionUnowned(directory, sessionId) {
|
|
292
269
|
const folder = join(directory, 'browser-live');
|
|
293
270
|
let names;
|
|
@@ -312,8 +289,6 @@ export async function assertBrowserSessionUnowned(directory, sessionId) {
|
|
|
312
289
|
throw unavailable;
|
|
313
290
|
throw error;
|
|
314
291
|
}
|
|
315
|
-
// Partial writes and legacy descriptors without a PID cannot prove that the
|
|
316
|
-
// owner exited. Keep their protection until the descriptor is repaired or removed.
|
|
317
292
|
if (!descriptor || !Number.isInteger(descriptor.pid) || Number(descriptor.pid) <= 0)
|
|
318
293
|
throw unavailable;
|
|
319
294
|
if (await pruneExitedOwner(join(folder, name), descriptor.pid))
|
|
@@ -332,8 +307,6 @@ export async function assertBrowserSessionUnowned(directory, sessionId) {
|
|
|
332
307
|
catch {
|
|
333
308
|
throw unavailable;
|
|
334
309
|
}
|
|
335
|
-
// Query the current identity rather than caching it: a CLI can resume another
|
|
336
|
-
// session. A stalled live process therefore conservatively blocks takeover.
|
|
337
310
|
if (state.id === sessionId)
|
|
338
311
|
throw new Error('Session is owned by another application. Refresh to reconnect.');
|
|
339
312
|
}));
|
|
@@ -3,7 +3,6 @@ import { type CapsolverKey, type CapsolverOptions, type CapsolverTask } from './
|
|
|
3
3
|
export declare const SOLVE_CAPTCHA_TOOL = "browser.solve_captcha";
|
|
4
4
|
declare const TYPES: readonly ["auto", "recaptcha_v2", "recaptcha_v3", "turnstile", "image"];
|
|
5
5
|
type CaptchaType = typeof TYPES[number];
|
|
6
|
-
/** Captchas found on a page, read from its markup only. Keys are public values the page publishes. */
|
|
7
6
|
export interface DetectedCaptchas {
|
|
8
7
|
recaptcha: {
|
|
9
8
|
websiteKey: string;
|
|
@@ -19,34 +18,22 @@ export interface DetectedCaptchas {
|
|
|
19
18
|
cdata?: string;
|
|
20
19
|
}[];
|
|
21
20
|
}
|
|
22
|
-
/** Runs in the page. Self-contained: Playwright serializes it, so it may not reference module scope. */
|
|
23
21
|
export declare const detectCaptchas: () => DetectedCaptchas;
|
|
24
22
|
export interface InjectionReport {
|
|
25
23
|
fields: number;
|
|
26
24
|
callbacks: number;
|
|
27
25
|
patchedApi: boolean;
|
|
28
26
|
}
|
|
29
|
-
/**
|
|
30
|
-
* Runs in the page: put a solved token where the solved widget would have, then tell the page.
|
|
31
|
-
*
|
|
32
|
-
* Only that widget is touched: its own response field, its own callback, its own loader clients.
|
|
33
|
-
* Other widgets on the page, of either provider, keep their fields, callbacks and API answers.
|
|
34
|
-
*
|
|
35
|
-
* The response fields are what a form submits; the callbacks are what script-driven pages wait for;
|
|
36
|
-
* and the patched `execute`/`getResponse` answer pages that ask the widget for the token later.
|
|
37
|
-
*/
|
|
38
27
|
export declare const injectCaptchaToken: (input: {
|
|
39
28
|
kind: "recaptcha" | "turnstile";
|
|
40
29
|
token: string;
|
|
41
30
|
websiteKey: string;
|
|
42
31
|
}) => InjectionReport;
|
|
43
|
-
/** Pick the CapSolver task for what the page shows and what the caller asked for. */
|
|
44
32
|
export declare function chooseCaptchaTask(found: DetectedCaptchas, requested: Exclude<CaptchaType, 'image'>, websiteURL: string, websiteKey?: string, pageAction?: string): {
|
|
45
33
|
type: Exclude<CaptchaType, 'auto' | 'image'>;
|
|
46
34
|
task: CapsolverTask;
|
|
47
35
|
};
|
|
48
36
|
export interface SolveCaptchaDependencies {
|
|
49
|
-
/** The key to use; defaults to the saved configuration, then `CAPSOLVER_API_KEY`. */
|
|
50
37
|
resolveKey?: () => Promise<CapsolverKey | undefined>;
|
|
51
38
|
capsolver?: Omit<CapsolverOptions, 'signal'>;
|
|
52
39
|
}
|
|
@@ -5,9 +5,7 @@ import { CAPSOLVER_ENV, resolveCapsolverKey, solveCapsolverTask } from './capsol
|
|
|
5
5
|
export const SOLVE_CAPTCHA_TOOL = 'browser.solve_captcha';
|
|
6
6
|
const TYPES = ['auto', 'recaptcha_v2', 'recaptcha_v3', 'turnstile', 'image'];
|
|
7
7
|
const ARGUMENTS = ['sessionId', 'tabId', 'type', 'websiteKey', 'pageAction', 'imageSelector', 'inputSelector'];
|
|
8
|
-
/** CapSolver documents no size limit for ImageToText; a captcha image is small, so cap what is sent. */
|
|
9
8
|
const IMAGE_BYTES_LIMIT = 1024 * 1024;
|
|
10
|
-
/** Runs in the page. Self-contained: Playwright serializes it, so it may not reference module scope. */
|
|
11
9
|
export const detectCaptchas = () => {
|
|
12
10
|
const recaptcha = [];
|
|
13
11
|
const turnstile = [];
|
|
@@ -64,7 +62,6 @@ export const detectCaptchas = () => {
|
|
|
64
62
|
addTurnstile({ websiteKey: key });
|
|
65
63
|
}
|
|
66
64
|
}
|
|
67
|
-
// A score-based (v3) key is the one the loader script renders with, not "explicit".
|
|
68
65
|
for (const script of Array.from(document.querySelectorAll('script[src]')).slice(0, 200)) {
|
|
69
66
|
let url;
|
|
70
67
|
try {
|
|
@@ -81,15 +78,6 @@ export const detectCaptchas = () => {
|
|
|
81
78
|
}
|
|
82
79
|
return { recaptcha: recaptcha.slice(0, 10), turnstile: turnstile.slice(0, 10) };
|
|
83
80
|
};
|
|
84
|
-
/**
|
|
85
|
-
* Runs in the page: put a solved token where the solved widget would have, then tell the page.
|
|
86
|
-
*
|
|
87
|
-
* Only that widget is touched: its own response field, its own callback, its own loader clients.
|
|
88
|
-
* Other widgets on the page, of either provider, keep their fields, callbacks and API answers.
|
|
89
|
-
*
|
|
90
|
-
* The response fields are what a form submits; the callbacks are what script-driven pages wait for;
|
|
91
|
-
* and the patched `execute`/`getResponse` answer pages that ask the widget for the token later.
|
|
92
|
-
*/
|
|
93
81
|
export const injectCaptchaToken = (input) => {
|
|
94
82
|
const { kind, token, websiteKey } = input;
|
|
95
83
|
const report = { fields: 0, callbacks: 0, patchedApi: false };
|
|
@@ -112,9 +100,8 @@ export const injectCaptchaToken = (input) => {
|
|
|
112
100
|
fn(token);
|
|
113
101
|
report.callbacks++;
|
|
114
102
|
}
|
|
115
|
-
catch {
|
|
103
|
+
catch { }
|
|
116
104
|
};
|
|
117
|
-
// Every captcha widget on the page, as the element that roots it and the key it names.
|
|
118
105
|
const frameKey = (element) => {
|
|
119
106
|
let url;
|
|
120
107
|
try {
|
|
@@ -136,7 +123,6 @@ export const injectCaptchaToken = (input) => {
|
|
|
136
123
|
const key = element.getAttribute('data-sitekey') ?? '';
|
|
137
124
|
return [{ element, key, kind: element.classList.contains('cf-turnstile') || key.startsWith('0x4') ? 'turnstile' : 'recaptcha' }];
|
|
138
125
|
}
|
|
139
|
-
// A frame inside a keyed container is that container's widget, not a second one.
|
|
140
126
|
const frame = frameKey(element);
|
|
141
127
|
return frame && !element.parentElement?.closest('[data-sitekey]') ? [{ element, key: frame.key ?? '', kind: frame.kind }] : [];
|
|
142
128
|
});
|
|
@@ -145,16 +131,12 @@ export const injectCaptchaToken = (input) => {
|
|
|
145
131
|
const sameKind = widgets.filter(widget => widget.kind === kind);
|
|
146
132
|
const fieldSelector = kind === 'recaptcha' ? 'textarea[name="g-recaptcha-response"], textarea[id^="g-recaptcha-response"]' : 'input[name="cf-turnstile-response"]';
|
|
147
133
|
const ownedByOther = (field) => others.some(widget => widget.element.contains(field));
|
|
148
|
-
// The widget's response field sits in its container, beside the frame. Walk up from the widget
|
|
149
|
-
// until a field turns up, but never into an ancestor that holds another widget.
|
|
150
134
|
let fields = [];
|
|
151
135
|
for (let scope = target?.element ?? null; scope && scope !== document.body && !fields.length; scope = scope.parentElement) {
|
|
152
136
|
if (others.some(widget => scope.contains(widget.element)))
|
|
153
137
|
break;
|
|
154
138
|
fields = Array.from(scope.querySelectorAll(fieldSelector));
|
|
155
139
|
}
|
|
156
|
-
// A key the page shows no widget for (reCAPTCHA v3, or a key passed explicitly) may still have a
|
|
157
|
-
// page-level field, as long as no other widget owns it.
|
|
158
140
|
if (!target)
|
|
159
141
|
fields = Array.from(document.querySelectorAll(fieldSelector)).filter(field => !ownedByOther(field));
|
|
160
142
|
if (!fields.length && target && target.element.matches('[data-sitekey]')) {
|
|
@@ -170,10 +152,8 @@ export const injectCaptchaToken = (input) => {
|
|
|
170
152
|
fields.forEach(setField);
|
|
171
153
|
if (target?.element.matches('[data-callback]'))
|
|
172
154
|
invoke(target.element.getAttribute('data-callback'));
|
|
173
|
-
// Calls that name no widget mean the page's only (or first) one.
|
|
174
155
|
const onlyWidget = sameKind.length <= 1 && (!target || sameKind[0] === target);
|
|
175
156
|
if (kind === 'recaptcha') {
|
|
176
|
-
// Widgets rendered from script keep their callback in the loader's client table, keyed by widget id.
|
|
177
157
|
const clients = w.___grecaptcha_cfg?.clients;
|
|
178
158
|
const ours = new Set();
|
|
179
159
|
const walk = (value, depth, seen, onEntry) => {
|
|
@@ -218,12 +198,10 @@ export const injectCaptchaToken = (input) => {
|
|
|
218
198
|
api.getResponse = function (widget, ...rest) { return mine(widget) ? token : getResponse?.call(this, widget, ...rest); };
|
|
219
199
|
report.patchedApi = true;
|
|
220
200
|
}
|
|
221
|
-
catch {
|
|
201
|
+
catch { }
|
|
222
202
|
}
|
|
223
203
|
}
|
|
224
204
|
else {
|
|
225
|
-
// Turnstile's widget ids cannot be tied to a key from outside, so its API answers for the
|
|
226
|
-
// solved widget only when it is the page's only one.
|
|
227
205
|
const api = w.turnstile;
|
|
228
206
|
if (onlyWidget && api && typeof api === 'object') {
|
|
229
207
|
try {
|
|
@@ -231,7 +209,7 @@ export const injectCaptchaToken = (input) => {
|
|
|
231
209
|
api.isExpired = () => false;
|
|
232
210
|
report.patchedApi = true;
|
|
233
211
|
}
|
|
234
|
-
catch {
|
|
212
|
+
catch { }
|
|
235
213
|
}
|
|
236
214
|
}
|
|
237
215
|
return report;
|
|
@@ -242,7 +220,6 @@ function text(args, name, max) {
|
|
|
242
220
|
throw new Error(`${name} must be a nonempty string of at most ${max} characters`);
|
|
243
221
|
return value;
|
|
244
222
|
}
|
|
245
|
-
/** Pick the CapSolver task for what the page shows and what the caller asked for. */
|
|
246
223
|
export function chooseCaptchaTask(found, requested, websiteURL, websiteKey, pageAction) {
|
|
247
224
|
const v2 = found.recaptcha.filter(item => !item.v3);
|
|
248
225
|
const v3 = found.recaptcha.filter(item => item.v3);
|
|
@@ -275,7 +252,6 @@ export function chooseCaptchaTask(found, requested, websiteURL, websiteKey, page
|
|
|
275
252
|
} };
|
|
276
253
|
}
|
|
277
254
|
async function configuredKey() {
|
|
278
|
-
// An unreadable configuration still leaves the environment's key usable.
|
|
279
255
|
return resolveCapsolverKey(await loadConfig().catch(() => undefined));
|
|
280
256
|
}
|
|
281
257
|
export function createSolveCaptchaTool(authorize, dependencies = {}) {
|
|
@@ -291,7 +267,6 @@ export function createSolveCaptchaTool(authorize, dependencies = {}) {
|
|
|
291
267
|
imageSelector: { type: 'string', description: 'Observed CSS selector of the captcha image (type image)' },
|
|
292
268
|
inputSelector: { type: 'string', description: 'Observed CSS selector of the answer input (type image)' },
|
|
293
269
|
}, required: ['sessionId'], additionalProperties: false },
|
|
294
|
-
// The recognized text is page content; events keep only what happened.
|
|
295
270
|
eventOutput: output => {
|
|
296
271
|
try {
|
|
297
272
|
const data = JSON.parse(output);
|
|
@@ -320,7 +295,6 @@ export function createSolveCaptchaTool(authorize, dependencies = {}) {
|
|
|
320
295
|
const pageAction = args.pageAction === undefined ? undefined : text(args, 'pageAction', 100);
|
|
321
296
|
if (type === 'turnstile' && pageAction !== undefined)
|
|
322
297
|
throw new Error('pageAction applies only to reCAPTCHA');
|
|
323
|
-
// Plan mode refuses before anything is spent or changed; a per-tool approval is not a plan approval.
|
|
324
298
|
assertPlanMutationAllowed(context);
|
|
325
299
|
const borrowed = borrowBrowserSession(args, context);
|
|
326
300
|
const key = await (dependencies.resolveKey ?? configuredKey)();
|
|
@@ -330,10 +304,7 @@ export function createSolveCaptchaTool(authorize, dependencies = {}) {
|
|
|
330
304
|
context.signal.throwIfAborted();
|
|
331
305
|
assertPlanMutationAllowed(context);
|
|
332
306
|
const options = { ...dependencies.capsolver, signal: context.signal };
|
|
333
|
-
// The page is held for the whole solve, so nothing navigates it between reading the widget
|
|
334
|
-
// and writing its answer.
|
|
335
307
|
return await borrowed.use(async (page, tabId, bounded) => {
|
|
336
|
-
// The session queue may have waited across a live switch into Plan mode.
|
|
337
308
|
assertPlanMutationAllowed(context);
|
|
338
309
|
const websiteURL = page.url();
|
|
339
310
|
if (!/^https?:/.test(websiteURL))
|
|
@@ -346,8 +317,6 @@ export function createSolveCaptchaTool(authorize, dependencies = {}) {
|
|
|
346
317
|
const answer = typeof solution.text === 'string' ? solution.text : '';
|
|
347
318
|
if (!answer)
|
|
348
319
|
throw new Error('CapSolver returned no text for the image');
|
|
349
|
-
// A run paused or cancelled during the solve must not type into the page afterwards, and a
|
|
350
|
-
// fill waiting for its input must stop with the run rather than at Playwright's timeout.
|
|
351
320
|
context.signal.throwIfAborted();
|
|
352
321
|
assertPlanMutationAllowed(context);
|
|
353
322
|
await bounded(page.locator(inputSelector).fill(answer, { timeout: 10_000 }), 'Captcha answer entry exceeded the 10-second timeout; session closed.');
|
|
@@ -360,7 +329,6 @@ export function createSolveCaptchaTool(authorize, dependencies = {}) {
|
|
|
360
329
|
if (typeof token !== 'string' || !token)
|
|
361
330
|
throw new Error('CapSolver returned no token');
|
|
362
331
|
context.signal.throwIfAborted();
|
|
363
|
-
// A solve takes seconds to minutes; a run switched to Plan mode meanwhile must not write the answer.
|
|
364
332
|
assertPlanMutationAllowed(context);
|
|
365
333
|
const injected = await bounded(page.evaluate(injectCaptchaToken, { kind: chosen.type === 'turnstile' ? 'turnstile' : 'recaptcha', token, websiteKey: chosen.task.websiteKey }), 'Captcha token injection exceeded the 10-second timeout; session closed.');
|
|
366
334
|
return JSON.stringify({
|