@andorra-labs/code 0.1.11 → 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/README.md +8 -2
- package/THIRD_PARTY_NOTICES.md +15 -0
- 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 +59 -414
- 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 +14 -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 +19 -244
- 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 +33 -918
- package/dist/src/app-server.js +608 -2984
- 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 +10 -25
- package/dist/src/browser-panel-tool.js +64 -60
- package/dist/src/browser-runner.d.ts +0 -1
- package/dist/src/browser-runner.js +7 -46
- 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 +52 -290
- package/dist/src/browser-view.js +354 -567
- 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 +166 -61
- 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 +3 -56
- package/dist/src/cli.js +193 -702
- package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +4 -59
- package/dist/src/code-intelligence/CodeIntelligenceManager.js +27 -100
- 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 +1 -26
- package/dist/src/codex-rpc.d.ts +0 -10
- package/dist/src/codex-rpc.js +0 -12
- package/dist/src/coding-tools.d.ts +6 -27
- package/dist/src/coding-tools.js +193 -205
- 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 +2 -58
- package/dist/src/completion.js +90 -186
- package/dist/src/config.d.ts +12 -116
- package/dist/src/config.js +41 -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 +1 -11
- 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 +15 -124
- package/dist/src/diff-preview.d.ts +1 -1
- package/dist/src/diff-preview.js +4 -12
- 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 +13 -0
- package/dist/src/engine-streams.js +16 -0
- package/dist/src/extensions.d.ts +3 -2
- package/dist/src/extensions.js +76 -37
- 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 +1 -0
- package/dist/src/file-read-key.js +5 -0
- 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 +1 -3
- package/dist/src/graph-health.d.ts +7 -49
- package/dist/src/graph-health.js +35 -46
- package/dist/src/graph-manager-chat.d.ts +27 -128
- package/dist/src/graph-manager-chat.js +36 -166
- 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 +47 -387
- package/dist/src/graph-selection.d.ts +0 -14
- package/dist/src/graph-selection.js +0 -14
- package/dist/src/graph-server.d.ts +3 -11
- package/dist/src/graph-server.js +70 -111
- 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 +229 -498
- package/dist/src/graph-ui/compat.js +0 -7
- package/dist/src/graph-ui/controls.css +47 -43
- 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 +2 -7
- package/dist/src/graph-ui/index.html +2 -2
- 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 +110 -49
- package/dist/src/graph-ui/manager.css +2 -20
- package/dist/src/graph-ui/manager.js +251 -166
- package/dist/src/graph-ui/model-picker.js +250 -0
- package/dist/src/graph-ui/provider-glyphs/alibaba-cloud.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/anthropic.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/aws-bedrock.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/claude.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/deepseek.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/fireworks.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/kimi.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/minimax.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/openai.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/opencode.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/openrouter.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/xai.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/xiaomi-mimo.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/zai.png +0 -0
- 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 +7 -156
- package/dist/src/graphs.js +72 -273
- 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 +21 -82
- package/dist/src/mcp.js +228 -237
- 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 +42 -0
- package/dist/src/memory/ProjectMemory.js +285 -0
- package/dist/src/memory/ToolFailureLessons.d.ts +0 -3
- package/dist/src/memory/ToolFailureLessons.js +0 -6
- package/dist/src/memory/index.d.ts +1 -0
- package/dist/src/memory/index.js +1 -0
- 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 +6 -22
- package/dist/src/package-name.d.ts +1 -0
- package/dist/src/package-name.js +1 -0
- 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 +3 -98
- 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 +2 -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 +106 -418
- 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 +1 -19
- package/dist/src/remote/cert.js +2 -51
- package/dist/src/remote/client.d.ts +0 -70
- package/dist/src/remote/client.js +2 -117
- 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 +2 -0
- package/dist/src/remote/pem.js +7 -0
- 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 +44 -678
- package/dist/src/run-temp.d.ts +12 -0
- package/dist/src/run-temp.js +50 -0
- package/dist/src/runtime.d.ts +11 -227
- 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 -120
- package/dist/src/sessions.js +9 -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 +43 -0
- package/dist/src/sign-in-detection.js +154 -0
- package/dist/src/sign-in-offer.d.ts +17 -0
- package/dist/src/sign-in-offer.js +103 -0
- 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/graph-manager/SKILL.md +22 -4
- package/dist/src/skills/bundled/provenance.json +2 -2
- 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 +1 -8
- package/dist/src/skills/runtime-skills.js +8 -32
- package/dist/src/stall-recovery.d.ts +0 -25
- package/dist/src/stall-recovery.js +0 -38
- package/dist/src/stray-files.d.ts +5 -0
- package/dist/src/stray-files.js +65 -0
- 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 +10 -374
- 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 +15 -524
- package/dist/src/terminal-ui.js +80 -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 +1 -8
- 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 +1 -2
- package/dist/src/tool-schema-compatibility.js +2 -7
- 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 +1 -37
- package/dist/src/transcript.js +11 -61
- package/dist/src/types.d.ts +2 -167
- package/dist/src/untracked-file-removal.d.ts +3 -0
- package/dist/src/untracked-file-removal.js +105 -0
- package/dist/src/update-check.d.ts +0 -14
- package/dist/src/update-check.js +2 -16
- package/dist/src/update.d.ts +4 -29
- package/dist/src/update.js +20 -98
- 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 +4 -5
- package/dist/src/workspace-git-metadata.js +37 -9
- package/dist/src/workspace-instructions.d.ts +3 -15
- package/dist/src/workspace-instructions.js +7 -20
- package/package.json +2 -2
|
@@ -6,15 +6,13 @@ import { join } from 'node:path';
|
|
|
6
6
|
import { isDeepStrictEqual, promisify } from 'node:util';
|
|
7
7
|
import { resolveClaudeExecutable } from './claude-executable.js';
|
|
8
8
|
import { resolveTrustedTaskkill } from './shell.js';
|
|
9
|
+
import { createDecodeWindow } from './providers.js';
|
|
9
10
|
const executeFile = promisify(execFile);
|
|
10
11
|
const OUTPUT_LIMIT = 8 * 1024 * 1024;
|
|
11
|
-
// Stop after the first paid response, including the CLI's otherwise automatic length recovery.
|
|
12
12
|
const AUXILIARY_BUDGET_USD = '0.000000001';
|
|
13
13
|
const signInMessage = 'Sign in with the Claude CLI (claude auth login), then retry the Claude subscription provider.';
|
|
14
14
|
const systemPrompt = 'You are the model component of Andorra Code. The supplied conversation is the complete context. Return one structured response with text and toolCalls. To request an Andorra tool, return its name and its arguments as a JSON object in toolCalls. Andorra authorizes and executes tools and supplies observations in the next conversation. Do not use built-in tools. Otherwise return text and an empty toolCalls array.';
|
|
15
15
|
const auxiliarySystemPrompt = 'You are the text-only model component of Andorra Code. The supplied conversation is the complete context. Follow its instructions and return only the requested text. Do not call tools.';
|
|
16
|
-
// Arguments are an object, never a JSON-encoded string: a string makes the model escape every quote
|
|
17
|
-
// twice by hand, and one slip in a long shell command discards the whole step.
|
|
18
16
|
const outputSchema = {
|
|
19
17
|
type: 'object', additionalProperties: false, required: ['text', 'toolCalls'],
|
|
20
18
|
properties: {
|
|
@@ -25,18 +23,14 @@ const outputSchema = {
|
|
|
25
23
|
} },
|
|
26
24
|
},
|
|
27
25
|
};
|
|
28
|
-
/** Keep managed authentication at its existing home, excluding credential/provider overrides. */
|
|
29
26
|
export function claudeEnvironment(source = process.env) {
|
|
30
27
|
return Object.fromEntries(Object.entries(source).filter(([key]) => key.toUpperCase() === 'CLAUDE_CONFIG_DIR' || !/^(?:ANTHROPIC_|CLAUDE_|NODE_OPTIONS$|NODE_PATH$)/i.test(key)));
|
|
31
28
|
}
|
|
32
|
-
// Safe mode retains managed policy and authentication while disabling customizations, including
|
|
33
|
-
// hooks, CLAUDE.md, plugins, skills and agents. Empty setting sources prevent apiKeyHelper execution.
|
|
34
29
|
export const claudeIsolationArgs = [
|
|
35
30
|
'--safe-mode', '--setting-sources', '', '--settings', '{}', '--tools', '',
|
|
36
31
|
'--strict-mcp-config', '--mcp-config', '{"mcpServers":{}}',
|
|
37
32
|
'--disable-slash-commands', '--no-chrome', '--no-session-persistence',
|
|
38
33
|
];
|
|
39
|
-
/** Bounded subprocess transport. Prompts and images travel only on stdin, never through a shell. */
|
|
40
34
|
export const runClaudeProcess = async (args, input, signal, options = {}) => {
|
|
41
35
|
signal.throwIfAborted();
|
|
42
36
|
if (options.maxTokens !== undefined && (!Number.isSafeInteger(options.maxTokens) || options.maxTokens < 1))
|
|
@@ -48,7 +42,6 @@ export const runClaudeProcess = async (args, input, signal, options = {}) => {
|
|
|
48
42
|
try {
|
|
49
43
|
const env = claudeEnvironment(options.env);
|
|
50
44
|
if (options.maxTokens !== undefined) {
|
|
51
|
-
// Apply only after sanitization, to this child. Managed auth and parent environment survive.
|
|
52
45
|
env.CLAUDE_CODE_MAX_OUTPUT_TOKENS = String(options.maxTokens);
|
|
53
46
|
env.MAX_THINKING_TOKENS = '0';
|
|
54
47
|
}
|
|
@@ -106,22 +99,24 @@ export const runClaudeProcess = async (args, input, signal, options = {}) => {
|
|
|
106
99
|
if (!count(text))
|
|
107
100
|
return;
|
|
108
101
|
output += text;
|
|
109
|
-
if (!options.catalogRequestId)
|
|
102
|
+
if (!options.catalogRequestId && !options.onLine)
|
|
110
103
|
return;
|
|
111
104
|
bufferedLine += text;
|
|
112
105
|
let newline;
|
|
113
106
|
while ((newline = bufferedLine.indexOf('\n')) >= 0) {
|
|
114
107
|
const line = bufferedLine.slice(0, newline);
|
|
115
108
|
bufferedLine = bufferedLine.slice(newline + 1);
|
|
109
|
+
options.onLine?.(line);
|
|
110
|
+
if (!options.catalogRequestId)
|
|
111
|
+
continue;
|
|
116
112
|
try {
|
|
117
113
|
const value = JSON.parse(line);
|
|
118
114
|
if (value.type === 'control_response' && value.response?.request_id === options.catalogRequestId)
|
|
119
115
|
child.stdin.end();
|
|
120
116
|
}
|
|
121
|
-
catch {
|
|
117
|
+
catch { }
|
|
122
118
|
}
|
|
123
119
|
});
|
|
124
|
-
// Never include stderr in diagnostics: it can contain account details or credential values.
|
|
125
120
|
child.stderr.on('data', (chunk) => { count(chunk); });
|
|
126
121
|
child.stdin.on('error', () => { failure ??= new Error('Claude CLI closed its input unexpectedly'); void stop(); });
|
|
127
122
|
signal.addEventListener('abort', abort, { once: true });
|
|
@@ -135,9 +130,6 @@ export const runClaudeProcess = async (args, input, signal, options = {}) => {
|
|
|
135
130
|
return output;
|
|
136
131
|
}
|
|
137
132
|
finally {
|
|
138
|
-
// Claude Code's print mode starts short-lived helpers (tasklist, PowerShell, git) in this cwd that
|
|
139
|
-
// can outlive it, and Windows refuses to remove a directory a running process is using. Retry for a
|
|
140
|
-
// few seconds, and never let cleanup of an empty scratch directory replace the CLI's answer or error.
|
|
141
133
|
await rm(cwd, { recursive: true, force: true, maxRetries: 10, retryDelay: 100 }).catch(() => { });
|
|
142
134
|
}
|
|
143
135
|
};
|
|
@@ -159,7 +151,6 @@ function subscriptionLogin(status) {
|
|
|
159
151
|
async function signedIn(run, signal) {
|
|
160
152
|
return subscriptionLogin(await readStatus(run, signal));
|
|
161
153
|
}
|
|
162
|
-
/** Whether the CLI holds a Claude subscription login, and the display fields it reports for it. */
|
|
163
154
|
export async function readClaudeSignIn(signal, dependencies = {}) {
|
|
164
155
|
const status = await readStatus(dependencies.run ?? runClaudeProcess, AbortSignal.any([signal, AbortSignal.timeout(30_000)]));
|
|
165
156
|
if (!subscriptionLogin(status))
|
|
@@ -169,7 +160,6 @@ export async function readClaudeSignIn(signal, dependencies = {}) {
|
|
|
169
160
|
const planType = text(status.subscriptionType, 100);
|
|
170
161
|
return { signedIn: true, ...(email ? { email } : {}), ...(planType ? { planType } : {}) };
|
|
171
162
|
}
|
|
172
|
-
/** Read the CLI's managed login status and its current supported model catalog without inference. */
|
|
173
163
|
export async function readClaudeCatalog(signal, dependencies = {}) {
|
|
174
164
|
const run = dependencies.run ?? runClaudeProcess;
|
|
175
165
|
const bounded = AbortSignal.any([signal, AbortSignal.timeout(30_000)]);
|
|
@@ -183,7 +173,6 @@ export async function readClaudeCatalog(signal, dependencies = {}) {
|
|
|
183
173
|
const models = response.response.models.map((model) => {
|
|
184
174
|
if (!model || typeof model !== 'object' || Array.isArray(model))
|
|
185
175
|
throw new Error('Claude CLI returned an invalid model catalog');
|
|
186
|
-
// Context selectors can resolve to the same base model while changing effective context.
|
|
187
176
|
const suffix = typeof model.value === 'string' ? model.value.match(/\[[^\]]+\]$/)?.[0] : undefined;
|
|
188
177
|
const resolved = model.resolvedModel ?? model.value;
|
|
189
178
|
return suffix && typeof resolved === 'string' && !resolved.endsWith(suffix) ? `${resolved}${suffix}` : resolved;
|
|
@@ -192,21 +181,20 @@ export async function readClaudeCatalog(signal, dependencies = {}) {
|
|
|
192
181
|
throw new Error('Claude CLI returned an invalid model catalog');
|
|
193
182
|
return { signedIn: true, models: [...new Set(models)] };
|
|
194
183
|
}
|
|
195
|
-
/**
|
|
196
|
-
* A step the model shaped wrongly. Nothing from it has run, so the same request can be asked again:
|
|
197
|
-
* the CLI would have told the model to correct itself, but one turn is all a step is given.
|
|
198
|
-
*/
|
|
199
184
|
class MalformedClaudeStep extends Error {
|
|
200
|
-
|
|
185
|
+
unparsedReply;
|
|
186
|
+
constructor(message, unparsedReply) {
|
|
187
|
+
super(message);
|
|
188
|
+
this.unparsedReply = unparsedReply;
|
|
189
|
+
this.name = 'Error';
|
|
190
|
+
}
|
|
201
191
|
}
|
|
202
|
-
/** Attempts at one step before a wrongly shaped reply ends it. */
|
|
203
192
|
const STEP_ATTEMPTS = 3;
|
|
204
193
|
function argumentObject(value) {
|
|
205
194
|
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
206
195
|
throw new MalformedClaudeStep('Claude returned invalid Andorra tool arguments');
|
|
207
196
|
return value;
|
|
208
197
|
}
|
|
209
|
-
/** What was wrong with a reply, as types and counts only: its content never reaches a diagnostic. */
|
|
210
198
|
function replyShape(value) {
|
|
211
199
|
const kind = (field) => field === undefined ? 'missing' : field === null ? 'null'
|
|
212
200
|
: Array.isArray(field) ? `a list of ${field.length}` : `a ${typeof field}`;
|
|
@@ -217,16 +205,73 @@ function replyShape(value) {
|
|
|
217
205
|
const extra = Object.keys(value).filter(key => key !== 'text' && key !== 'toolCalls').length;
|
|
218
206
|
return `text was ${kind(value.text)}, toolCalls was ${kind(value.toolCalls)}${extra ? `, with ${extra} unexpected field${extra > 1 ? 's' : ''}` : ''}`;
|
|
219
207
|
}
|
|
220
|
-
/**
|
|
221
|
-
* Close a tool input whose only fault is its final brackets.
|
|
222
|
-
*
|
|
223
|
-
* A step that carries a long tool call nests four levels deep, and the model sometimes ends it one
|
|
224
|
-
* bracket short or one over. Everything before that tail is intact, so the tail is rewritten to close
|
|
225
|
-
* exactly what is open. Input that fails to parse for any other reason is left refused.
|
|
226
|
-
*/
|
|
227
208
|
export function closeToolInput(raw) {
|
|
209
|
+
if (raw.replace(/[\]}\s]+$/, '').length === raw.length)
|
|
210
|
+
return undefined;
|
|
211
|
+
let text = raw;
|
|
212
|
+
for (let edits = 0;; edits++) {
|
|
213
|
+
const closed = closeTail(text);
|
|
214
|
+
if (closed !== undefined)
|
|
215
|
+
return closed;
|
|
216
|
+
const at = parseFailure(text);
|
|
217
|
+
if (at === undefined)
|
|
218
|
+
return JSON.parse(text);
|
|
219
|
+
if (edits >= CLOSER_EDITS)
|
|
220
|
+
return undefined;
|
|
221
|
+
const next = closerEdit(text, at);
|
|
222
|
+
if (next === undefined)
|
|
223
|
+
return undefined;
|
|
224
|
+
text = next;
|
|
225
|
+
}
|
|
226
|
+
}
|
|
227
|
+
const CLOSER_EDITS = 4;
|
|
228
|
+
function parseFailure(text) {
|
|
229
|
+
try {
|
|
230
|
+
JSON.parse(text);
|
|
231
|
+
return undefined;
|
|
232
|
+
}
|
|
233
|
+
catch (error) {
|
|
234
|
+
const at = /position (\d+)/.exec(error.message);
|
|
235
|
+
return at ? Number(at[1]) : text.length;
|
|
236
|
+
}
|
|
237
|
+
}
|
|
238
|
+
function closerEdit(text, at) {
|
|
239
|
+
const outside = [];
|
|
240
|
+
let inString = false;
|
|
241
|
+
let escaped = false;
|
|
242
|
+
for (let index = 0; index <= at && index < text.length; index++) {
|
|
243
|
+
outside[index] = !inString;
|
|
244
|
+
const char = text[index];
|
|
245
|
+
if (inString) {
|
|
246
|
+
if (escaped)
|
|
247
|
+
escaped = false;
|
|
248
|
+
else if (char === '\\')
|
|
249
|
+
escaped = true;
|
|
250
|
+
else if (char === '"')
|
|
251
|
+
inString = false;
|
|
252
|
+
}
|
|
253
|
+
else if (char === '"')
|
|
254
|
+
inString = true;
|
|
255
|
+
}
|
|
256
|
+
outside[text.length] = !inString;
|
|
257
|
+
let best;
|
|
258
|
+
for (let index = at; index >= Math.max(0, at - 8); index--) {
|
|
259
|
+
if (!outside[index])
|
|
260
|
+
continue;
|
|
261
|
+
const char = text[index];
|
|
262
|
+
const candidates = [text.slice(0, index) + '}' + text.slice(index), text.slice(0, index) + ']' + text.slice(index)];
|
|
263
|
+
if (char === '}' || char === ']')
|
|
264
|
+
candidates.push(text.slice(0, index) + text.slice(index + 1), text.slice(0, index) + (char === '}' ? ']' : '}') + text.slice(index + 1));
|
|
265
|
+
for (const candidate of candidates) {
|
|
266
|
+
const reach = parseFailure(candidate) ?? Infinity;
|
|
267
|
+
if (reach > at && (best === undefined || reach > best.reach))
|
|
268
|
+
best = { text: candidate, reach };
|
|
269
|
+
}
|
|
270
|
+
}
|
|
271
|
+
return best?.text;
|
|
272
|
+
}
|
|
273
|
+
function closeTail(raw) {
|
|
228
274
|
const head = raw.replace(/[\]}\s]+$/, '');
|
|
229
|
-
// The model has to have ended the input itself; output that merely stopped is not completed here.
|
|
230
275
|
if (head.length === raw.length)
|
|
231
276
|
return undefined;
|
|
232
277
|
const open = [];
|
|
@@ -259,10 +304,6 @@ export function closeToolInput(raw) {
|
|
|
259
304
|
return undefined;
|
|
260
305
|
}
|
|
261
306
|
}
|
|
262
|
-
/**
|
|
263
|
-
* The whole text of a tool input Claude Code could not parse. Its assistant frame keeps only the
|
|
264
|
-
* first 2048 characters, so the rest is read from the partial-message stream of the same block.
|
|
265
|
-
*/
|
|
266
307
|
function unparsedToolInput(events, block) {
|
|
267
308
|
const kept = block.input?.__unparsedToolInput;
|
|
268
309
|
if (!kept || typeof kept.raw !== 'string' || Object.keys(block.input).length !== 1)
|
|
@@ -275,7 +316,44 @@ function unparsedToolInput(events, block) {
|
|
|
275
316
|
&& frame.event.delta?.type === 'input_json_delta' && typeof frame.event.delta.partial_json === 'string').map(frame => frame.event.delta.partial_json).join('');
|
|
276
317
|
return whole.startsWith(kept.raw) ? whole : undefined;
|
|
277
318
|
}
|
|
319
|
+
function keptToolInput(events, block) {
|
|
320
|
+
const kept = block.input?.__unparsedToolInput;
|
|
321
|
+
if (!kept || typeof kept.raw !== 'string')
|
|
322
|
+
return undefined;
|
|
323
|
+
return unparsedToolInput(events, block) ?? kept.raw;
|
|
324
|
+
}
|
|
325
|
+
export function retryNote(reason) {
|
|
326
|
+
return `Andorra could not use your previous reply to this exact conversation: ${reason}. Send the complete structured response again. `
|
|
327
|
+
+ 'It must be one valid JSON object: inside every string, escape double quotes as \\" and backslashes as \\\\, write line breaks as \\n, close every object with } and every array with ] in the reverse order you opened them, and add nothing outside the object. '
|
|
328
|
+
+ 'Keep long text fields, such as subagent assignments, as short as the work allows.';
|
|
329
|
+
}
|
|
278
330
|
const UNPARSED_REJECTION = '<tool_use_error>InputValidationError: StructuredOutput was called with input that could not be parsed as JSON.';
|
|
331
|
+
function declaredShape(value, tools) {
|
|
332
|
+
if (!Array.isArray(value?.toolCalls))
|
|
333
|
+
return value;
|
|
334
|
+
for (const call of value.toolCalls) {
|
|
335
|
+
if (!call || typeof call !== 'object' || Object.keys(call).some(key => key !== 'name' && key !== 'arguments'))
|
|
336
|
+
return undefined;
|
|
337
|
+
const tool = tools.find(entry => entry.name === call.name);
|
|
338
|
+
if (tool?.parameters && !fitsSchema(tool.parameters, call.arguments))
|
|
339
|
+
return undefined;
|
|
340
|
+
}
|
|
341
|
+
return value;
|
|
342
|
+
}
|
|
343
|
+
function fitsSchema(schema, value) {
|
|
344
|
+
if (!schema || typeof schema !== 'object')
|
|
345
|
+
return true;
|
|
346
|
+
if (schema.type === 'array')
|
|
347
|
+
return Array.isArray(value) && (!schema.items || value.every((item) => fitsSchema(schema.items, item)));
|
|
348
|
+
if (schema.type !== 'object')
|
|
349
|
+
return true;
|
|
350
|
+
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
351
|
+
return false;
|
|
352
|
+
const properties = schema.properties ?? {};
|
|
353
|
+
if ((schema.required ?? []).some((key) => !Object.hasOwn(value, key)))
|
|
354
|
+
return false;
|
|
355
|
+
return Object.entries(value).every(([key, item]) => Object.hasOwn(properties, key) ? fitsSchema(properties[key], item) : schema.additionalProperties !== false);
|
|
356
|
+
}
|
|
279
357
|
function structuredResponse(value, names) {
|
|
280
358
|
if (!value || typeof value.text !== 'string' || !Array.isArray(value.toolCalls) || value.toolCalls.length > 100
|
|
281
359
|
|| Object.keys(value).some(key => key !== 'text' && key !== 'toolCalls'))
|
|
@@ -285,7 +363,6 @@ function structuredResponse(value, names) {
|
|
|
285
363
|
throw new MalformedClaudeStep('Claude returned a malformed Andorra tool call');
|
|
286
364
|
if (!names.has(call.name))
|
|
287
365
|
throw new MalformedClaudeStep('Claude requested a tool outside the Andorra manifest');
|
|
288
|
-
// A JSON-encoded string is still read, for a reply shaped the way the schema used to ask.
|
|
289
366
|
let input;
|
|
290
367
|
try {
|
|
291
368
|
input = argumentObject(typeof call.arguments === 'string' ? JSON.parse(call.arguments) : call.arguments);
|
|
@@ -303,7 +380,6 @@ function structuredResponse(value, names) {
|
|
|
303
380
|
function sameCalls(first, second) {
|
|
304
381
|
return isDeepStrictEqual(first.map(call => ({ name: call.name, arguments: JSON.parse(call.arguments) })), second.map(call => ({ name: call.name, arguments: JSON.parse(call.arguments) })));
|
|
305
382
|
}
|
|
306
|
-
/** Accept one model step only. Native-shaped Andorra calls never gain native tool access. */
|
|
307
383
|
export function parseClaudeResponse(output, tools = []) {
|
|
308
384
|
const events = frames(output);
|
|
309
385
|
const results = events.filter(frame => frame?.type === 'result');
|
|
@@ -337,7 +413,6 @@ export function parseClaudeResponse(output, tools = []) {
|
|
|
337
413
|
messageIds.add(event.message.id);
|
|
338
414
|
if (messageIds.size > 1)
|
|
339
415
|
throw new Error('Claude returned multiple assistant steps');
|
|
340
|
-
// Claude emits separate complete blocks bearing one message ID, including thinking blocks.
|
|
341
416
|
for (const block of event.message.content) {
|
|
342
417
|
if (block?.type === 'text' && typeof block.text === 'string')
|
|
343
418
|
texts.push(block.text);
|
|
@@ -350,8 +425,14 @@ export function parseClaudeResponse(output, tools = []) {
|
|
|
350
425
|
if (schemaResponse)
|
|
351
426
|
throw new MalformedClaudeStep('Claude returned multiple structured responses');
|
|
352
427
|
const unparsed = result.stop_reason === 'tool_use' ? unparsedToolInput(events, block) : undefined;
|
|
353
|
-
const closed = unparsed === undefined ? undefined : closeToolInput(unparsed);
|
|
354
|
-
|
|
428
|
+
const closed = unparsed === undefined ? undefined : declaredShape(closeToolInput(unparsed), tools);
|
|
429
|
+
try {
|
|
430
|
+
schemaResponse = structuredResponse(closed ?? block.input, names);
|
|
431
|
+
}
|
|
432
|
+
catch (error) {
|
|
433
|
+
const raw = closed === undefined ? unparsed ?? keptToolInput(events, block) : undefined;
|
|
434
|
+
throw error instanceof MalformedClaudeStep && raw !== undefined ? new MalformedClaudeStep(error.message, raw) : error;
|
|
435
|
+
}
|
|
355
436
|
schemaId = block.id;
|
|
356
437
|
reclosed = closed !== undefined;
|
|
357
438
|
}
|
|
@@ -368,7 +449,6 @@ export function parseClaudeResponse(output, tools = []) {
|
|
|
368
449
|
`<tool_use_error>Error: No such tool available: ${block.name}</tool_use_error>`,
|
|
369
450
|
`<tool_use_error>Error: No such tool available: ${block.name}.</tool_use_error>`,
|
|
370
451
|
`<tool_use_error>Error: No such tool available: ${block.name}. ${block.name} is disabled for this session, in subagents as well as here.</tool_use_error>`,
|
|
371
|
-
// Claude Code 2.1.177 words it this way for a native tool name it ships but this session disabled.
|
|
372
452
|
`<tool_use_error>Error: No such tool available: ${block.name}. ${block.name} exists but is not enabled in this context. Use one of the available tools instead.</tool_use_error>`,
|
|
373
453
|
];
|
|
374
454
|
if (observations.length !== 1 || observations[0].is_error !== true || typeof observations[0].content !== 'string'
|
|
@@ -383,13 +463,9 @@ export function parseClaudeResponse(output, tools = []) {
|
|
|
383
463
|
throw new MalformedClaudeStep('Claude returned conflicting structured responses');
|
|
384
464
|
if (direct.length && structured && !sameCalls(direct, structured.toolCalls))
|
|
385
465
|
throw new MalformedClaudeStep('Claude returned conflicting Andorra tool requests');
|
|
386
|
-
// Claude Code counts acknowledging StructuredOutput as a turn, so under --max-turns 1 a complete
|
|
387
|
-
// structured step can end at the turn limit without result.structured_output. Accept that step only
|
|
388
|
-
// when the CLI acknowledged that one StructuredOutput call exactly once and without an error.
|
|
389
466
|
const acknowledgements = schemaId === undefined ? [] : events.filter(frame => frame?.type === 'user')
|
|
390
467
|
.flatMap(frame => Array.isArray(frame.message?.content) ? frame.message.content : [])
|
|
391
468
|
.filter((item) => item?.type === 'tool_result' && item.tool_use_id === schemaId);
|
|
392
|
-
// A step whose brackets were closed here was refused by the CLI as unparseable, and only as that.
|
|
393
469
|
const acknowledged = acknowledgements.length === 1 && (reclosed
|
|
394
470
|
? acknowledgements[0].is_error === true && typeof acknowledgements[0].content === 'string' && acknowledgements[0].content.startsWith(UNPARSED_REJECTION)
|
|
395
471
|
: acknowledgements[0].is_error !== true);
|
|
@@ -401,11 +477,21 @@ export function parseClaudeResponse(output, tools = []) {
|
|
|
401
477
|
else if (turnLimit && direct.length && !structured)
|
|
402
478
|
response = { text: texts.join('\n'), toolCalls: direct };
|
|
403
479
|
else
|
|
404
|
-
throw new MalformedClaudeStep(
|
|
480
|
+
throw new MalformedClaudeStep(`Claude did not return a complete Andorra model step (${incompleteStep(result, Boolean(structured), texts.length > 0, acknowledgements)})`);
|
|
405
481
|
if (result.usage)
|
|
406
482
|
response.usage = claudeUsage(result.usage);
|
|
407
483
|
return response;
|
|
408
484
|
}
|
|
485
|
+
function incompleteStep(result, structured, answeredInText, acknowledgements) {
|
|
486
|
+
const stop = typeof result.stop_reason === 'string' && /^[a-z_]{1,40}$/.test(result.stop_reason) ? `, stop reason ${result.stop_reason}` : '';
|
|
487
|
+
if (!structured)
|
|
488
|
+
return `${answeredInText ? 'it answered in text with no structured reply' : 'it sent no structured reply'}${stop}`;
|
|
489
|
+
if (acknowledgements.length !== 1)
|
|
490
|
+
return `the CLI acknowledged the structured reply ${acknowledgements.length} times${stop}`;
|
|
491
|
+
if (acknowledgements[0].is_error === true)
|
|
492
|
+
return `the CLI refused the structured reply${stop}`;
|
|
493
|
+
return `the structured reply and the CLI result disagreed${stop}`;
|
|
494
|
+
}
|
|
409
495
|
function claudeUsage(usage) {
|
|
410
496
|
const token = (name) => typeof usage[name] === 'number' && Number.isSafeInteger(usage[name]) && usage[name] >= 0 ? usage[name] : undefined;
|
|
411
497
|
const input = token('input_tokens');
|
|
@@ -417,11 +503,6 @@ function claudeUsage(usage) {
|
|
|
417
503
|
...(output === undefined ? {} : { outputTokens: output }),
|
|
418
504
|
...(read === undefined ? {} : { cacheRead: read }), ...(created === undefined ? {} : { cacheWrite: created }) };
|
|
419
505
|
}
|
|
420
|
-
/**
|
|
421
|
-
* Bounded auxiliaries require CLI support for the documented child output/budget controls and
|
|
422
|
-
* partial-message metadata. The output cap alone permits automatic continuations. The positive
|
|
423
|
-
* budget stops after one paid response; verify that single response and its real stream usage.
|
|
424
|
-
*/
|
|
425
506
|
export function parseClaudeAuxiliaryResponse(output, maxTokens) {
|
|
426
507
|
if (!Number.isSafeInteger(maxTokens) || maxTokens < 1)
|
|
427
508
|
throw new Error('Invalid auxiliary output allowance.');
|
|
@@ -477,7 +558,28 @@ export function parseClaudeAuxiliaryResponse(output, maxTokens) {
|
|
|
477
558
|
throw new Error('Claude returned conflicting auxiliary text blocks');
|
|
478
559
|
return { text: texts.join(''), toolCalls: [], usage: claudeUsage(usage), stopReason };
|
|
479
560
|
}
|
|
480
|
-
|
|
561
|
+
function stampClaudeDelta(decode, line) {
|
|
562
|
+
if (!line.includes('content_block_delta'))
|
|
563
|
+
return;
|
|
564
|
+
let frame;
|
|
565
|
+
try {
|
|
566
|
+
frame = JSON.parse(line);
|
|
567
|
+
}
|
|
568
|
+
catch {
|
|
569
|
+
return;
|
|
570
|
+
}
|
|
571
|
+
if (frame?.type !== 'stream_event' || frame.parent_tool_use_id || frame.event?.type !== 'content_block_delta')
|
|
572
|
+
return;
|
|
573
|
+
const delta = frame.event.delta;
|
|
574
|
+
const text = delta?.text ?? delta?.partial_json ?? delta?.thinking;
|
|
575
|
+
if (typeof text === 'string' && text)
|
|
576
|
+
decode.stamp(text);
|
|
577
|
+
}
|
|
578
|
+
function withDecodeMs(response, decodeMs) {
|
|
579
|
+
if (decodeMs !== undefined && response.usage && response.usage.outputTokens !== undefined)
|
|
580
|
+
response.usage.decodeMs = decodeMs;
|
|
581
|
+
return response;
|
|
582
|
+
}
|
|
481
583
|
export function createClaudeAdapter(_config, dependencies = {}) {
|
|
482
584
|
const run = dependencies.run ?? runClaudeProcess;
|
|
483
585
|
return {
|
|
@@ -503,27 +605,30 @@ export function createClaudeAdapter(_config, dependencies = {}) {
|
|
|
503
605
|
'--max-turns', '1',
|
|
504
606
|
'--model', request.model, ...(auxiliary
|
|
505
607
|
? ['--include-partial-messages', '--max-budget-usd', AUXILIARY_BUDGET_USD, '--system-prompt', auxiliarySystemPrompt]
|
|
506
|
-
// Partial messages carry the whole of a tool input the CLI could not parse.
|
|
507
608
|
: ['--include-partial-messages', '--json-schema', JSON.stringify(outputSchema), '--system-prompt', systemPrompt])];
|
|
508
|
-
const
|
|
609
|
+
const compose = (note) => `${JSON.stringify({ type: 'user', client_composed: true,
|
|
610
|
+
message: { role: 'user', content: note ? [...content, { type: 'text', text: note }] : content } })}\n`;
|
|
611
|
+
let input = compose();
|
|
509
612
|
for (let attempt = 1;; attempt++) {
|
|
510
613
|
request.onRequest?.();
|
|
511
|
-
const
|
|
614
|
+
const decode = createDecodeWindow(dependencies.now);
|
|
615
|
+
const output = await run(args, input, signal, { acceptedExitCodes: [0, 1], onLine: line => stampClaudeDelta(decode, line),
|
|
616
|
+
...(auxiliary ? { maxTokens: request.maxTokens } : {}) });
|
|
512
617
|
signal.throwIfAborted();
|
|
513
618
|
if (auxiliary)
|
|
514
|
-
return parseClaudeAuxiliaryResponse(output, request.maxTokens);
|
|
619
|
+
return withDecodeMs(parseClaudeAuxiliaryResponse(output, request.maxTokens), decode.measure());
|
|
515
620
|
try {
|
|
516
|
-
const response = parseClaudeResponse(output, request.tools);
|
|
621
|
+
const response = withDecodeMs(parseClaudeResponse(output, request.tools), decode.measure());
|
|
517
622
|
if (response.usage)
|
|
518
623
|
response.usage.requests = attempt;
|
|
519
624
|
return response;
|
|
520
625
|
}
|
|
521
626
|
catch (error) {
|
|
522
|
-
// A wrongly shaped step is the model's slip, not an outage, and it rarely repeats. Ending
|
|
523
|
-
// the run on the first one throws away everything the run had done up to that step.
|
|
524
627
|
if (!(error instanceof MalformedClaudeStep) || attempt >= STEP_ATTEMPTS)
|
|
525
628
|
throw error;
|
|
526
|
-
await request.onRetry?.({ retry: attempt, maxRetries: STEP_ATTEMPTS - 1, delayMs: 0, reason: `${error.message}. Asking again
|
|
629
|
+
await request.onRetry?.({ retry: attempt, maxRetries: STEP_ATTEMPTS - 1, delayMs: 0, reason: `${error.message}. Asking again.`, quiet: true,
|
|
630
|
+
...(error.unparsedReply === undefined ? {} : { unparsedReply: error.unparsedReply }) });
|
|
631
|
+
input = compose(retryNote(error.message));
|
|
527
632
|
}
|
|
528
633
|
}
|
|
529
634
|
},
|
|
@@ -1,29 +1,13 @@
|
|
|
1
|
-
/** How to find one vendor CLI that Andorra drives as a subprocess. */
|
|
2
1
|
export interface CliExecutableSpec {
|
|
3
|
-
/** Command names without an extension, tried in order. */
|
|
4
2
|
names: readonly string[];
|
|
5
|
-
/** Names an explicit executable, as a path or as a name looked up on PATH. */
|
|
6
3
|
overrideEnv: string;
|
|
7
|
-
/** Install directories under the user's home that the vendor's own installer uses. */
|
|
8
4
|
homeDirectories?: readonly string[];
|
|
9
|
-
/**
|
|
10
|
-
* The native binary behind a Windows npm shim, relative to the shim's directory. A `.cmd` shim is
|
|
11
|
-
* never executed: it would run through `cmd.exe`, where arguments are reinterpreted.
|
|
12
|
-
*/
|
|
13
5
|
shimTargets?: readonly string[];
|
|
14
|
-
/** What the user is told when nothing runnable is found. */
|
|
15
6
|
installMessage: string;
|
|
16
7
|
}
|
|
17
|
-
/** The vendor CLI could not be found; the message says how to install it. */
|
|
18
8
|
export declare class CliUnavailableError extends Error {
|
|
19
9
|
constructor(message: string);
|
|
20
10
|
}
|
|
21
|
-
/**
|
|
22
|
-
* Locate a vendor CLI without ever executing a Windows command shim.
|
|
23
|
-
*
|
|
24
|
-
* The override wins when it is set. A `.js` or `.mjs` override runs with this Node, which is how
|
|
25
|
-
* tests stand a scripted CLI in for the real one.
|
|
26
|
-
*/
|
|
27
11
|
export declare function resolveCliExecutable(spec: CliExecutableSpec, options?: {
|
|
28
12
|
platform?: NodeJS.Platform;
|
|
29
13
|
env?: NodeJS.ProcessEnv;
|
|
@@ -9,16 +9,9 @@ async function exists(path) {
|
|
|
9
9
|
return false;
|
|
10
10
|
}
|
|
11
11
|
}
|
|
12
|
-
/** The vendor CLI could not be found; the message says how to install it. */
|
|
13
12
|
export class CliUnavailableError extends Error {
|
|
14
13
|
constructor(message) { super(message); this.name = 'CliUnavailableError'; }
|
|
15
14
|
}
|
|
16
|
-
/**
|
|
17
|
-
* Locate a vendor CLI without ever executing a Windows command shim.
|
|
18
|
-
*
|
|
19
|
-
* The override wins when it is set. A `.js` or `.mjs` override runs with this Node, which is how
|
|
20
|
-
* tests stand a scripted CLI in for the real one.
|
|
21
|
-
*/
|
|
22
15
|
export async function resolveCliExecutable(spec, options = {}) {
|
|
23
16
|
const platform = options.platform ?? process.platform;
|
|
24
17
|
const env = options.env ?? process.env;
|
|
@@ -1,31 +1,12 @@
|
|
|
1
1
|
import { type ChildProcess } from 'node:child_process';
|
|
2
|
-
/**
|
|
3
|
-
* Stop a child and everything it started.
|
|
4
|
-
*
|
|
5
|
-
* Vendor CLIs ship as launchers that start a native binary, so killing the direct child alone leaves
|
|
6
|
-
* the binary running and holding its port or its lock. Windows needs `taskkill /T`; elsewhere the
|
|
7
|
-
* child leads its own process group, which can outlive the launcher: the group is signalled even
|
|
8
|
-
* when the direct child has already exited, or a descendant keeps the pipes open.
|
|
9
|
-
*
|
|
10
|
-
* Every pipe is then closed on this side, so a caller waiting for `close` settles even when a
|
|
11
|
-
* descendant survived (on Windows, `taskkill /T` cannot reach one whose parent already exited).
|
|
12
|
-
*/
|
|
13
2
|
export declare function stopProcessTree(child: ChildProcess, taskkill: string | undefined): Promise<void>;
|
|
14
3
|
export interface BoundedCliOptions {
|
|
15
|
-
/** The complete child environment; callers build it from their own sanitizer. */
|
|
16
4
|
env: NodeJS.ProcessEnv;
|
|
17
|
-
/** The product name errors name, e.g. `Grok CLI`. */
|
|
18
5
|
label: string;
|
|
19
|
-
/** Written to stdin, then stdin is closed. */
|
|
20
6
|
input?: string;
|
|
21
|
-
/** Files written into the private working directory before the child starts. */
|
|
22
7
|
files?: Record<string, string>;
|
|
23
8
|
outputLimit?: number;
|
|
24
9
|
acceptedExitCodes?: number[];
|
|
25
|
-
/**
|
|
26
|
-
* Return stderr alongside stdout. Off by default: CLIs print account details and credential
|
|
27
|
-
* fragments there, so only callers that parse a known status line ask for it.
|
|
28
|
-
*/
|
|
29
10
|
captureStderr?: boolean;
|
|
30
11
|
}
|
|
31
12
|
export interface BoundedCliResult {
|
|
@@ -34,13 +15,6 @@ export interface BoundedCliResult {
|
|
|
34
15
|
code: number | null;
|
|
35
16
|
cwd: string;
|
|
36
17
|
}
|
|
37
|
-
/**
|
|
38
|
-
* Run one vendor CLI command in a private, empty working directory under a byte bound.
|
|
39
|
-
*
|
|
40
|
-
* Arguments never pass through a shell. The directory is removed afterwards, so a prompt written
|
|
41
|
-
* there for `--prompt-file` does not outlive the request. Cancellation and the output bound stop the
|
|
42
|
-
* whole process tree.
|
|
43
|
-
*/
|
|
44
18
|
export declare function runBoundedCli(executable: {
|
|
45
19
|
command: string;
|
|
46
20
|
args: string[];
|
package/dist/src/cli-process.js
CHANGED
|
@@ -6,17 +6,6 @@ import { promisify } from 'node:util';
|
|
|
6
6
|
import { resolveTrustedTaskkill } from './shell.js';
|
|
7
7
|
const executeFile = promisify(execFile);
|
|
8
8
|
const DEFAULT_OUTPUT_LIMIT = 8 * 1024 * 1024;
|
|
9
|
-
/**
|
|
10
|
-
* Stop a child and everything it started.
|
|
11
|
-
*
|
|
12
|
-
* Vendor CLIs ship as launchers that start a native binary, so killing the direct child alone leaves
|
|
13
|
-
* the binary running and holding its port or its lock. Windows needs `taskkill /T`; elsewhere the
|
|
14
|
-
* child leads its own process group, which can outlive the launcher: the group is signalled even
|
|
15
|
-
* when the direct child has already exited, or a descendant keeps the pipes open.
|
|
16
|
-
*
|
|
17
|
-
* Every pipe is then closed on this side, so a caller waiting for `close` settles even when a
|
|
18
|
-
* descendant survived (on Windows, `taskkill /T` cannot reach one whose parent already exited).
|
|
19
|
-
*/
|
|
20
9
|
export async function stopProcessTree(child, taskkill) {
|
|
21
10
|
if (child.pid) {
|
|
22
11
|
const exited = child.exitCode !== null || child.signalCode !== null;
|
|
@@ -43,13 +32,6 @@ export async function stopProcessTree(child, taskkill) {
|
|
|
43
32
|
for (const stream of [child.stdin, child.stdout, child.stderr])
|
|
44
33
|
stream?.destroy();
|
|
45
34
|
}
|
|
46
|
-
/**
|
|
47
|
-
* Run one vendor CLI command in a private, empty working directory under a byte bound.
|
|
48
|
-
*
|
|
49
|
-
* Arguments never pass through a shell. The directory is removed afterwards, so a prompt written
|
|
50
|
-
* there for `--prompt-file` does not outlive the request. Cancellation and the output bound stop the
|
|
51
|
-
* whole process tree.
|
|
52
|
-
*/
|
|
53
35
|
export async function runBoundedCli(executable, args, signal, options) {
|
|
54
36
|
signal.throwIfAborted();
|
|
55
37
|
const cwd = await mkdtemp(join(tmpdir(), 'andorra-cli-'));
|
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
/** What a sign-in panel shows; every field is display data, never a credential. */
|
|
2
1
|
export interface ManagedSignInState {
|
|
3
2
|
state: 'signedOut' | 'starting' | 'waiting' | 'signedIn' | 'cancelled' | 'error';
|
|
4
3
|
reason?: 'unavailable' | 'timeout' | 'denied' | 'unsupported' | 'busy' | 'unverified' | 'logoutFailed';
|
|
@@ -6,16 +5,11 @@ export interface ManagedSignInState {
|
|
|
6
5
|
message?: string;
|
|
7
6
|
email?: string;
|
|
8
7
|
planType?: string;
|
|
9
|
-
/** The vendor's sign-in page. Only the start request that began the attempt carries it. */
|
|
10
8
|
authUrl?: string;
|
|
11
|
-
/** A device code the person confirms on that page. */
|
|
12
9
|
userCode?: string;
|
|
13
|
-
/** The vendor may show a code the person pastes back here instead of redirecting. */
|
|
14
10
|
acceptsCode?: boolean;
|
|
15
11
|
}
|
|
16
|
-
/** One vendor CLI whose own login command Andorra runs and whose stored login it reads back. */
|
|
17
12
|
export interface CliSignInSpec {
|
|
18
|
-
/** The product name messages use, e.g. `Claude` or `Grok`. */
|
|
19
13
|
product: string;
|
|
20
14
|
resolveExecutable(): Promise<{
|
|
21
15
|
command: string;
|
|
@@ -24,32 +18,20 @@ export interface CliSignInSpec {
|
|
|
24
18
|
env(): NodeJS.ProcessEnv;
|
|
25
19
|
loginArgs: readonly string[];
|
|
26
20
|
logoutArgs: readonly string[];
|
|
27
|
-
/** Read the CLI's stored login, without inference. */
|
|
28
21
|
status(signal: AbortSignal): Promise<{
|
|
29
22
|
signedIn: boolean;
|
|
30
23
|
email?: string;
|
|
31
24
|
planType?: string;
|
|
32
25
|
}>;
|
|
33
|
-
/** Hosts a sign-in page may be on; any other URL the CLI prints is withheld. */
|
|
34
26
|
pageHosts: readonly string[];
|
|
35
|
-
/** The CLI prints a device code the person confirms on the page. */
|
|
36
27
|
deviceCode?: boolean;
|
|
37
|
-
/** Whether the CLI reads a pasted code from stdin while it waits. */
|
|
38
28
|
acceptsCode?: boolean;
|
|
39
29
|
timeoutMs?: number;
|
|
40
30
|
}
|
|
41
|
-
/** The first sign-in page and device code in what the CLI printed, held to the allowed hosts. */
|
|
42
31
|
export declare function readSignInPrompt(output: string, pageHosts: readonly string[]): {
|
|
43
32
|
authUrl?: string;
|
|
44
33
|
userCode?: string;
|
|
45
34
|
};
|
|
46
|
-
/**
|
|
47
|
-
* Runs one vendor CLI's own login command and reports what it left behind.
|
|
48
|
-
*
|
|
49
|
-
* The browser ceremony and the tokens belong to the vendor CLI, which stores them where it always
|
|
50
|
-
* does; Andorra never reads or copies them. This class starts the command, surfaces the page and
|
|
51
|
-
* code it prints, forwards a pasted code, stops it on cancel, and asks the CLI who is signed in.
|
|
52
|
-
*/
|
|
53
35
|
export declare class CliSignIn {
|
|
54
36
|
private readonly spec;
|
|
55
37
|
private attempt?;
|
|
@@ -57,11 +39,9 @@ export declare class CliSignIn {
|
|
|
57
39
|
constructor(spec: CliSignInSpec);
|
|
58
40
|
private failed;
|
|
59
41
|
start(attemptId: string): Promise<ManagedSignInState>;
|
|
60
|
-
/** Forward a code the sign-in page showed to the waiting CLI. */
|
|
61
42
|
submitCode(attemptId: string, code: string): Promise<ManagedSignInState>;
|
|
62
43
|
status(attemptId?: string): Promise<ManagedSignInState>;
|
|
63
44
|
cancel(attemptId: string): Promise<ManagedSignInState>;
|
|
64
|
-
/** Run the CLI's own sign-out, then report what its stored login now says. */
|
|
65
45
|
logout(): Promise<ManagedSignInState>;
|
|
66
46
|
private stop;
|
|
67
47
|
close(): Promise<void>;
|