@andorra-labs/code 0.1.12 → 0.1.14
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 +6 -43
- 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 +347 -554
- 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 +11 -155
- 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/andorra/endpoint.d.ts +7 -0
- package/dist/src/andorra/endpoint.js +46 -0
- package/dist/src/andorra/entry.d.ts +21 -0
- package/dist/src/andorra/entry.js +100 -0
- package/dist/src/andorra/errors.d.ts +2 -0
- package/dist/src/andorra/errors.js +39 -0
- package/dist/src/andorra/hosted.d.ts +52 -0
- package/dist/src/andorra/hosted.js +126 -0
- package/dist/src/andorra/monitor.d.ts +151 -0
- package/dist/src/andorra/monitor.js +393 -0
- package/dist/src/andorra/notices.d.ts +7 -0
- package/dist/src/andorra/notices.js +15 -0
- package/dist/src/andorra/opt-in.d.ts +58 -0
- package/dist/src/andorra/opt-in.js +112 -0
- package/dist/src/andorra/request-watch.d.ts +6 -0
- package/dist/src/andorra/request-watch.js +10 -0
- package/dist/src/andorra/state.d.ts +86 -0
- package/dist/src/andorra/state.js +238 -0
- package/dist/src/andorra/terminal.d.ts +68 -0
- package/dist/src/andorra/terminal.js +125 -0
- package/dist/src/andorra/usage-format.d.ts +9 -0
- package/dist/src/andorra/usage-format.js +19 -0
- 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 +9 -29
- package/dist/src/app-server/protocol.d.ts +18 -246
- 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 +52 -925
- package/dist/src/app-server.js +828 -3076
- 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 +9 -93
- package/dist/src/auth/AuthManager.js +164 -186
- 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 +1 -16
- package/dist/src/auth/deployment.js +1 -16
- package/dist/src/auth/index.d.ts +1 -12
- package/dist/src/auth/index.js +1 -12
- package/dist/src/auth/lock.d.ts +0 -1
- package/dist/src/auth/lock.js +0 -1
- package/dist/src/auth/store.d.ts +33 -108
- package/dist/src/auth/store.js +55 -130
- 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 +5 -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 +19 -13
- package/dist/src/browser-stealth.js +22 -38
- 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 +15 -97
- package/dist/src/browser-view.d.ts +106 -295
- package/dist/src/browser-view.js +551 -587
- 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 +118 -742
- 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 +41 -1
- package/dist/src/command-screens.js +316 -113
- package/dist/src/commands.d.ts +12 -63
- package/dist/src/commands.js +98 -127
- 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 +15 -115
- package/dist/src/config.js +123 -172
- 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 +2 -2
- package/dist/src/dashboard-view.js +11 -37
- 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 +2 -6
- 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 +1 -2
- package/dist/src/decision/toolMenu.d.ts +0 -3
- package/dist/src/decision/toolMenu.js +0 -4
- package/dist/src/decision/types.d.ts +1 -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 +9 -61
- package/dist/src/graph-health.js +34 -59
- package/dist/src/graph-manager-chat.d.ts +36 -153
- package/dist/src/graph-manager-chat.js +161 -182
- 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 +58 -391
- package/dist/src/graph-selection.d.ts +0 -14
- package/dist/src/graph-selection.js +2 -15
- 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 +176 -492
- 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 +43 -185
- 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 +16 -136
- package/dist/src/graph-ui/theme.js +1 -26
- package/dist/src/graph-ui/tokens.css +19 -118
- package/dist/src/graphs.d.ts +6 -157
- package/dist/src/graphs.js +66 -269
- 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 +9 -47
- 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 +1 -14
- package/dist/src/membership.d.ts +9 -59
- package/dist/src/membership.js +20 -91
- 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-context-windows.d.ts +2 -0
- package/dist/src/model-context-windows.js +24 -0
- package/dist/src/model-health-cache.d.ts +0 -38
- package/dist/src/model-health-cache.js +2 -50
- package/dist/src/model-metadata.d.ts +1 -18
- package/dist/src/model-metadata.js +42 -45
- 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 +1 -63
- package/dist/src/palette.js +1 -64
- package/dist/src/permissions.d.ts +0 -15
- package/dist/src/permissions.js +17 -21
- 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 +15 -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 +16 -3
- package/dist/src/provider-settings.js +36 -52
- package/dist/src/providers.d.ts +14 -219
- package/dist/src/providers.js +69 -326
- 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 +107 -422
- 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 +22 -339
- 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 +2 -9
- package/dist/src/run-control.js +9 -13
- 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 +12 -228
- package/dist/src/runtime.js +2 -128
- 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 +3 -122
- 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 +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/graph-manager/errors.md +1 -1
- package/dist/src/skills/bundled/provenance.json +738 -738
- 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 +2 -163
- package/dist/src/subagent-run.js +18 -376
- 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 +3 -84
- 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 +33 -521
- package/dist/src/terminal-ui.js +145 -884
- 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 +5 -60
- package/dist/src/types.d.ts +4 -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 +13 -2
package/dist/src/subagent-run.js
CHANGED
|
@@ -8,11 +8,12 @@ import { configuredContextWindow, createAdapter, providerModels } from './provid
|
|
|
8
8
|
import { getMembership, loadAccessibleGraph } from './membership.js';
|
|
9
9
|
import { currentGraphSubject } from './graph-selection.js';
|
|
10
10
|
import { createRunTelemetry, recordModelUse } from './telemetry/capture.js';
|
|
11
|
-
import {
|
|
11
|
+
import { hostedGate } from './andorra/hosted.js';
|
|
12
|
+
import { checkGraphModelHealth, plainHealthFailure } from './graph-health.js';
|
|
12
13
|
import { validateGraph } from './graphs.js';
|
|
13
14
|
import { runGraph } from './runtime.js';
|
|
14
|
-
import { loadWorkspaceInstructions } from './workspace-instructions.js';
|
|
15
|
-
import { extensionSnapshot } from './extensions.js';
|
|
15
|
+
import { loadWorkspaceInstructions, systemPromptOverrideFor } from './workspace-instructions.js';
|
|
16
|
+
import { effectiveExtensionConfig, extensionSnapshot } from './extensions.js';
|
|
16
17
|
import { resolveModelContext } from './model-metadata.js';
|
|
17
18
|
import { MemoryManager } from './memory/MemoryManager.js';
|
|
18
19
|
import { LocalToolMemory } from './memory/LocalToolMemory.js';
|
|
@@ -24,46 +25,16 @@ import { permissionMode } from './permissions.js';
|
|
|
24
25
|
import { TodoStore } from './todos.js';
|
|
25
26
|
import { claimProcessWorkspace, clearOpenRunClaim, createCheckpointFailureTracker, createRunJournalWriter, releaseProcessWorkspace, removeOpenRunRecord, removeRunCheckpoint, repairSessionMarkers, RUNNING_TURN_SUMMARY, runRecordPath, summaryForStoppedRecord, writeOpenRunRecord, writeRunCheckpoint, writeStudioRunSummary } from './run-records.js';
|
|
26
27
|
import { SessionStore, projectIdentity, sessionName } from './sessions.js';
|
|
27
|
-
/**
|
|
28
|
-
* External subagent mode: the only graph an external host (Claude CLI, Codex CLI) may run.
|
|
29
|
-
*
|
|
30
|
-
* The restriction is structural — the id is a constant here, never a parameter on any surface —
|
|
31
|
-
* and the id is `default`, which `loadAccessibleGraph` resolves to the bundled single-agent
|
|
32
|
-
* Andorra Agent harness: no Orchestrator intake, no per-node provider pins, no account
|
|
33
|
-
* membership. That is what makes a one-shot external run headless-safe and lets the caller's
|
|
34
|
-
* provider/model choice reach every request the run makes.
|
|
35
|
-
*/
|
|
36
28
|
export const SUBAGENT_GRAPH_ID = 'default';
|
|
37
|
-
/**
|
|
38
|
-
* The longest task a subagent run accepts.
|
|
39
|
-
*
|
|
40
|
-
* The bound is the engine's own, and it is enforced here rather than in each entry point: a task
|
|
41
|
-
* this long is not a task a host meant to ask for, and it is persisted and turned into model
|
|
42
|
-
* context before anything else looks at it. Every surface that starts a run goes through this
|
|
43
|
-
* check, so the CLI and the MCP tools refuse the same task the same way.
|
|
44
|
-
*/
|
|
45
29
|
export const MAX_SUBAGENT_TASK_CHARS = 100_000;
|
|
46
|
-
/**
|
|
47
|
-
* The longest model identifier a subagent run accepts.
|
|
48
|
-
*
|
|
49
|
-
* It is the bound the configuration holds a saved model id to, and a per-call model is held to
|
|
50
|
-
* the same one: the value is written into the open run record and carried through the preflight
|
|
51
|
-
* and the model resolution, so an unbounded one would fill the installation's storage and the
|
|
52
|
-
* provider's request with what is only ever a caller's typo.
|
|
53
|
-
*/
|
|
54
30
|
export const MAX_SUBAGENT_MODEL_CHARS = 500;
|
|
55
|
-
/** A task the caller may not ask for: too long for the run to carry. */
|
|
56
31
|
export class SubagentInvalidArgumentError extends Error {
|
|
57
32
|
constructor(message) { super(message); this.name = 'SubagentInvalidArgumentError'; }
|
|
58
33
|
}
|
|
59
|
-
/**
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
* mistake, and answering it with `full-access` would grant the filesystem and shell mutations the
|
|
64
|
-
* caller was trying to withhold — so it is refused instead of rounded up. An absent permission
|
|
65
|
-
* keeps the default, which is what the CLI and the MCP wrappers mean by not naming one.
|
|
66
|
-
*/
|
|
34
|
+
/** The adapters a subagent run talks to: each request names the run's session, so Andorra can keep it on one machine. */
|
|
35
|
+
export function subagentAdapterFactory(sessionId) {
|
|
36
|
+
return provider => createAdapter(provider, { sessionId });
|
|
37
|
+
}
|
|
67
38
|
export function resolveSubagentPermissions(requested) {
|
|
68
39
|
if (requested === undefined)
|
|
69
40
|
return 'full-access';
|
|
@@ -71,14 +42,6 @@ export function resolveSubagentPermissions(requested) {
|
|
|
71
42
|
return requested;
|
|
72
43
|
throw new SubagentInvalidArgumentError(`The permission must be "read-only" or "full-access"; "${String(requested)}" is not a permission.`);
|
|
73
44
|
}
|
|
74
|
-
/**
|
|
75
|
-
* The provider snapshot a run's own model is invoked with.
|
|
76
|
-
*
|
|
77
|
-
* The saved reasoning effort and context window belong to the provider's *configured* model, so a
|
|
78
|
-
* run on a different one does not carry them: an adapter that honours them would send a
|
|
79
|
-
* reasoning setting the model does not take, or compact against the wrong limit. The window the
|
|
80
|
-
* provider lists for the selected model is applied instead, when it lists one.
|
|
81
|
-
*/
|
|
82
45
|
function providerForModel(provider, model) {
|
|
83
46
|
const selected = { ...provider, model };
|
|
84
47
|
if (model !== provider.model) {
|
|
@@ -90,35 +53,15 @@ function providerForModel(provider, model) {
|
|
|
90
53
|
selected.contextWindow = savedWindow;
|
|
91
54
|
return selected;
|
|
92
55
|
}
|
|
93
|
-
/** Fold one account of spend into another. */
|
|
94
56
|
function foldUsage(target, delta) {
|
|
95
57
|
target.requests += delta.requests ?? 0;
|
|
96
58
|
target.inputTokens += delta.inputTokens ?? 0;
|
|
97
59
|
target.outputTokens += delta.outputTokens ?? 0;
|
|
98
|
-
// Presence, not magnitude: a counter the provider reported as zero is a measurement, and a
|
|
99
|
-
// session that is reloaded shows it as one. Only an unreported counter stays absent.
|
|
100
60
|
if (delta.cacheRead !== undefined)
|
|
101
61
|
target.cacheRead = (target.cacheRead ?? 0) + delta.cacheRead;
|
|
102
62
|
if (delta.cacheWrite !== undefined)
|
|
103
63
|
target.cacheWrite = (target.cacheWrite ?? 0) + delta.cacheWrite;
|
|
104
64
|
}
|
|
105
|
-
/**
|
|
106
|
-
* The workspaces this process is running a subagent in.
|
|
107
|
-
*
|
|
108
|
-
* The reservation is process-wide rather than a runner's own: an embedded host can build several
|
|
109
|
-
* backends — or a runner of its own — in one process, and each of them held a slot of its own,
|
|
110
|
-
* so two full-access runs could work the same workspace at once. The unit the slot reserves is
|
|
111
|
-
* the workspace, because that is what two overlapping runs would both write to.
|
|
112
|
-
*/
|
|
113
|
-
/**
|
|
114
|
-
* The workspace a run works in, resolved to a real directory.
|
|
115
|
-
*
|
|
116
|
-
* Both public wrappers canonicalize the path before they call the runner, and the runner is
|
|
117
|
-
* exported for embedded use: a relative, empty or file-valued path would create the open record
|
|
118
|
-
* and the session — and spend the health probe — before the tools failed. A relative alias would
|
|
119
|
-
* also give one workspace two project identities, and a later resume would resolve the stored
|
|
120
|
-
* path against whatever working directory it happened to run in.
|
|
121
|
-
*/
|
|
122
65
|
export async function canonicalWorkspace(requested) {
|
|
123
66
|
let resolved;
|
|
124
67
|
try {
|
|
@@ -145,21 +88,6 @@ export class SubagentRunInProgressError extends Error {
|
|
|
145
88
|
export function listSubagentProviders(config) {
|
|
146
89
|
return config.providers.map(provider => ({ id: provider.id, type: provider.type, models: providerModels(provider) }));
|
|
147
90
|
}
|
|
148
|
-
/**
|
|
149
|
-
* Resolve the provider/model a subagent run uses: the caller's explicit pick wins, the saved
|
|
150
|
-
* `externalSubagent` setting is next, and anything else is the self-describing PROVIDER_NOT_SET
|
|
151
|
-
* error the calling agent is expected to take back to its user.
|
|
152
|
-
*
|
|
153
|
-
* A per-call model is accepted on the same terms as the CLI's `--model` (any nonempty id), while
|
|
154
|
-
* the saved setting is held to the stricter config validation: a persisted pair names a provider
|
|
155
|
-
* that must still exist and, when the provider carries an explicit model list, a model on it.
|
|
156
|
-
*/
|
|
157
|
-
/**
|
|
158
|
-
* The caller named a provider or a model the installation does not have.
|
|
159
|
-
*
|
|
160
|
-
* It is a selection failure rather than a backend failure, so a host can tell that its own
|
|
161
|
-
* choice was wrong and correct the identifier without a second diagnostic path.
|
|
162
|
-
*/
|
|
163
91
|
export class SubagentSelectionError extends Error {
|
|
164
92
|
}
|
|
165
93
|
export function resolveSubagentProvider(config, call = {}) {
|
|
@@ -172,9 +100,6 @@ export function resolveSubagentProvider(config, call = {}) {
|
|
|
172
100
|
if (typeof call.model !== 'string' || !call.model.trim()) {
|
|
173
101
|
throw new SubagentSelectionError('A provider was supplied without a model. Retry with both provider and model.');
|
|
174
102
|
}
|
|
175
|
-
// The bound a configured model id is held to. A per-call model is persisted in the open run
|
|
176
|
-
// record and carried through the preflight and the model resolution, so it is held to the
|
|
177
|
-
// same length before any of that happens.
|
|
178
103
|
if (call.model.trim().length > MAX_SUBAGENT_MODEL_CHARS) {
|
|
179
104
|
throw new SubagentInvalidArgumentError(`The model must be at most ${MAX_SUBAGENT_MODEL_CHARS} characters.`);
|
|
180
105
|
}
|
|
@@ -189,38 +114,15 @@ export function resolveSubagentProvider(config, call = {}) {
|
|
|
189
114
|
throw new SubagentProviderNotSetError(listSubagentProviders(config));
|
|
190
115
|
}
|
|
191
116
|
const delay = (ms) => new Promise(resolve => setTimeout(resolve, ms));
|
|
192
|
-
/**
|
|
193
|
-
* The health failure a subagent caller is given.
|
|
194
|
-
*
|
|
195
|
-
* A subagent always runs the built-in Andorra Agent graph, whose node has no editable model
|
|
196
|
-
* selection, so the ordinary remedy — edit the graph's model selections — cannot be followed. The
|
|
197
|
-
* caller has to pick another provider and model, or repair that provider's credentials.
|
|
198
|
-
*/
|
|
199
117
|
function subagentHealthFailure(health) {
|
|
118
|
+
const plain = plainHealthFailure(health.failures);
|
|
119
|
+
if (plain !== undefined)
|
|
120
|
+
return plain;
|
|
200
121
|
return ['The provider/model this subagent run would use is not usable:',
|
|
201
122
|
...health.failures.map(failure => `- ${failure.provider}/${failure.model}: ${failure.reason}`),
|
|
202
123
|
'A subagent run always uses the built-in Andorra Agent graph, whose model is the one you picked, so there is no graph to edit: retry with another provider and model, or repair that provider credentials.',
|
|
203
124
|
].join('\n');
|
|
204
125
|
}
|
|
205
|
-
/**
|
|
206
|
-
* One subagent run at a time per process, mirroring the engine's own one-run rule: the MCP server
|
|
207
|
-
* is a single process, so a second start while one run is live is refused rather than queued.
|
|
208
|
-
*
|
|
209
|
-
* The reservation is the process's rather than this runner's, because an embedded host can build
|
|
210
|
-
* several backends in one process: two of them would otherwise each hold a slot of their own and
|
|
211
|
-
* work the same workspace at once. What the slot reserves is the workspace, because that is what
|
|
212
|
-
* two overlapping runs would both write to.
|
|
213
|
-
*
|
|
214
|
-
* Records follow the installation's own lifecycle — an open run record before any preflight, run
|
|
215
|
-
* events appended to `runs/<id>.jsonl`, a session record and a terminal run record on finalize —
|
|
216
|
-
* so a crashed subagent run is classified by the same startup recovery as any other attempt and
|
|
217
|
-
* stays visible in the Runs view instead of vanishing with its host.
|
|
218
|
-
*/
|
|
219
|
-
/**
|
|
220
|
-
* The decision service an external subagent run uses: the one this installation configured, never a
|
|
221
|
-
* hosted default, and only for a signed-in account. The account is asked only when the answer could
|
|
222
|
-
* matter, so a run with decisions off stays free of an account request.
|
|
223
|
-
*/
|
|
224
126
|
export async function subagentDecisionConfig(config, membership) {
|
|
225
127
|
const decisions = config.decisions;
|
|
226
128
|
if (config.jevEnabled === false || !decisions || decisions.provider === 'none' || decisions.mode === 'off')
|
|
@@ -230,22 +132,11 @@ export async function subagentDecisionConfig(config, membership) {
|
|
|
230
132
|
export class SubagentRunner {
|
|
231
133
|
defaults;
|
|
232
134
|
active;
|
|
233
|
-
/** Set when the runner was shut down: a start that begins after it must not launch a run. */
|
|
234
135
|
closed = false;
|
|
235
|
-
/** A start that is preparing its run holds the slot before it is assigned. */
|
|
236
136
|
starting = false;
|
|
237
|
-
/** The workspace this runner holds the process-wide reservation for, when it holds one. */
|
|
238
137
|
reservedWorkspace;
|
|
239
|
-
/** A cancellation that arrived while the run was still starting. */
|
|
240
138
|
pendingCancel = false;
|
|
241
|
-
/** The start that is preparing a run, so a shutdown can wait for it instead of racing it. */
|
|
242
139
|
startPromise;
|
|
243
|
-
/**
|
|
244
|
-
* This runner's identity in the process-wide workspace reservation.
|
|
245
|
-
*
|
|
246
|
-
* The reservation is the process's, so two runners over one workspace cannot both hold it, and
|
|
247
|
-
* only the holder gives it back.
|
|
248
|
-
*/
|
|
249
140
|
reservationId = randomUUID();
|
|
250
141
|
constructor(defaults = {}) {
|
|
251
142
|
this.defaults = defaults;
|
|
@@ -253,39 +144,22 @@ export class SubagentRunner {
|
|
|
253
144
|
async start(options) {
|
|
254
145
|
if (!options.task.trim())
|
|
255
146
|
throw new Error('The subagent task must not be empty.');
|
|
256
|
-
// The bound is checked before anything is written: an oversized task must not leave a record,
|
|
257
|
-
// a claim or a session behind, whichever surface asked for it.
|
|
258
147
|
if (options.task.length > MAX_SUBAGENT_TASK_CHARS) {
|
|
259
148
|
throw new SubagentInvalidArgumentError(`The task must be at most ${MAX_SUBAGENT_TASK_CHARS} characters.`);
|
|
260
149
|
}
|
|
261
|
-
// The permission is read before anything is written too: a caller that meant to withhold the
|
|
262
|
-
// mutations must not be given them by a value this runner could not read.
|
|
263
150
|
const permissions = resolveSubagentPermissions(options.permissions);
|
|
264
|
-
// The connection that owned this runner closed while the start was still preparing. A run that
|
|
265
|
-
// begins now would outlive the connection that asked for it, with nothing left to cancel it.
|
|
266
151
|
if (this.closed)
|
|
267
152
|
throw new Error('The connection to Andorra closed before the run started.');
|
|
268
|
-
// The slot is taken before the first await: two overlapping starts would otherwise both
|
|
269
|
-
// pass the check, and the later assignment would hide the first run from every reader.
|
|
270
153
|
if (this.starting || (this.active !== undefined && !this.active.outcome))
|
|
271
154
|
throw new SubagentRunInProgressError();
|
|
272
155
|
this.starting = true;
|
|
273
|
-
// The run takes the reservation over from the start: a start that failed leaves nothing
|
|
274
|
-
// behind, and a start that reached its run hands the reservation to it.
|
|
275
156
|
let handedOver = false;
|
|
276
157
|
const pending = this.begin(options, permissions).then(reply => { handedOver = true; return reply; });
|
|
277
|
-
// The start is tracked while it prepares, so a shutdown can wait for it: a start that has
|
|
278
|
-
// not reached its run yet has nothing to abort, and it would otherwise go on to launch a
|
|
279
|
-
// full-access run after the connection that asked for it has closed.
|
|
280
158
|
this.startPromise = pending;
|
|
281
159
|
try {
|
|
282
160
|
return await pending;
|
|
283
161
|
}
|
|
284
162
|
finally {
|
|
285
|
-
// The reservation is the slot until the run itself holds it, and it is released when the
|
|
286
|
-
// start failed, so the next caller is not refused for a run that never began. A
|
|
287
|
-
// cancellation that belonged to that start goes with it: it was never a cancellation of
|
|
288
|
-
// the next run.
|
|
289
163
|
this.starting = false;
|
|
290
164
|
this.pendingCancel = false;
|
|
291
165
|
if (this.startPromise === pending)
|
|
@@ -294,26 +168,15 @@ export class SubagentRunner {
|
|
|
294
168
|
this.releaseWorkspace();
|
|
295
169
|
}
|
|
296
170
|
}
|
|
297
|
-
/** The run itself, once the slot is held. */
|
|
298
171
|
async begin(options, permissions) {
|
|
299
172
|
const directory = options.directory ?? this.defaults.directory ?? configDirectory();
|
|
300
|
-
// The workspace is resolved before anything is written: the records name the directory the
|
|
301
|
-
// run really works in, and a path that is not one would be recorded before the tools failed.
|
|
302
173
|
const workspace = await canonicalWorkspace(options.workspace);
|
|
303
174
|
const config = await (this.defaults.loadConfig ?? loadConfig)(directory);
|
|
304
175
|
const { provider, model } = resolveSubagentProvider(config, options);
|
|
305
|
-
// The process-wide reservation: another engine in this process — a second backend of an
|
|
306
|
-
// embedded host, or the app server over the same project — is already working in this
|
|
307
|
-
// workspace, and two full-access runs would write to the same files at once. It is taken
|
|
308
|
-
// here, once the workspace is known, and the check and the claim are one step, so two starts
|
|
309
|
-
// cannot both pass it.
|
|
310
176
|
if (!claimProcessWorkspace(workspace, this.reservationId))
|
|
311
177
|
throw new SubagentRunInProgressError();
|
|
312
178
|
this.reservedWorkspace = workspace;
|
|
313
179
|
const telemetryRunId = randomUUID();
|
|
314
|
-
// Resolved once, before the record is written: the start, the finish and the drains must all
|
|
315
|
-
// ask the gate for the account that owns this run, or a shared installation answers with
|
|
316
|
-
// whichever account most recently confirmed a plan.
|
|
317
180
|
const accountSubject = await currentGraphSubject().catch(() => undefined);
|
|
318
181
|
const runId = randomUUID();
|
|
319
182
|
const run = {
|
|
@@ -326,37 +189,20 @@ export class SubagentRunner {
|
|
|
326
189
|
probeUsage: { requests: 0, inputTokens: 0, outputTokens: 0 }, probeModels: new Map(),
|
|
327
190
|
providerType: provider.type, baseUrl: provider.baseUrl,
|
|
328
191
|
};
|
|
329
|
-
// The claim lands before any preflight: a crash between here and finalize leaves exactly the
|
|
330
|
-
// record recovery knows how to classify.
|
|
331
192
|
const openRecord = {
|
|
332
193
|
id: run.runId, status: 'running', sessionId: run.sessionId, startedAt: run.startedAt, pid: process.pid,
|
|
333
194
|
graphSelection: SUBAGENT_GRAPH_ID, graph: { id: SUBAGENT_GRAPH_ID }, provider: provider.id, model,
|
|
334
|
-
// The account this attempt was started under travels with the record: recovery on a shared
|
|
335
|
-
// installation would otherwise gate the finish with whichever cached account is newest.
|
|
336
195
|
...(accountSubject === undefined ? {} : { accountSubject }),
|
|
337
|
-
// A CLI or app-server recovery may find this record in the shared home; the finish it
|
|
338
|
-
// reports must still be labeled with the subagent surface that produced the start.
|
|
339
196
|
surface: 'subagent',
|
|
340
|
-
// `startSent` stays false until the start is queued below; a crash in between owes the
|
|
341
|
-
// missing start as well as the finish, and recovery reads this flag to decide that.
|
|
342
197
|
telemetry: { runId: telemetryRunId, nodes: 1, subagents: false, jevEnabled: config.jevEnabled !== false, decisionRouting: config.decisions?.mode ?? 'off', startSent: false },
|
|
343
|
-
// The marker travels with the open record as well as the terminal one: a crash before
|
|
344
|
-
// the finalization rewrites this record as interrupted, and it must still say that the
|
|
345
|
-
// attempt was a subagent run.
|
|
346
198
|
subagent: true,
|
|
347
|
-
// The permission the host bound this attempt to. A read-only subagent that is later
|
|
348
|
-
// resumed must not come back as a full-access run: the workspace's own setting is not
|
|
349
|
-
// the host's instruction, and the host is the one that prohibited the mutations.
|
|
350
199
|
permissions: run.permissions,
|
|
351
200
|
};
|
|
352
201
|
try {
|
|
353
202
|
await writeOpenRunRecord(directory, openRecord);
|
|
354
203
|
}
|
|
355
204
|
catch (error) {
|
|
356
|
-
// A partial claim would be classified as an interrupted attempt that never ran.
|
|
357
205
|
await removeOpenRunRecord(directory, run.runId).catch(() => { });
|
|
358
|
-
// The filesystem code travels with the message: a storage failure is told to the host as a
|
|
359
|
-
// storage problem, and a plain error would answer as a general backend one.
|
|
360
206
|
const code = error && typeof error === 'object' && 'code' in error ? error.code : undefined;
|
|
361
207
|
throw Object.assign(new Error(`Could not write the subagent run record: ${error instanceof Error ? error.message : String(error)}`), typeof code === 'string' ? { code } : {}, error instanceof Error ? { cause: error } : {});
|
|
362
208
|
}
|
|
@@ -365,34 +211,22 @@ export class SubagentRunner {
|
|
|
365
211
|
jevEnabled: run.jevEnabled, decisionRouting: run.decisionRouting,
|
|
366
212
|
}, workspace);
|
|
367
213
|
run.telemetryStart = reportRunStarted({ home: directory, config, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) }, run.telemetryHandle).catch(() => { });
|
|
368
|
-
// Stamp the queue result into the record before the work starts: after this point a crash is
|
|
369
|
-
// recovered from a start that exists, and recovery must not synthesize a second one.
|
|
370
214
|
await run.telemetryStart;
|
|
371
215
|
await writeOpenRunRecord(directory, {
|
|
372
216
|
...openRecord,
|
|
373
217
|
telemetry: { ...openRecord.telemetry, startSent: run.telemetryHandle.started !== false },
|
|
374
218
|
}).catch(() => { });
|
|
375
|
-
// The session exists before the work does: a crash between here and the finalization
|
|
376
|
-
// leaves a session with a running turn, which is what the recovery repairs.
|
|
377
219
|
try {
|
|
378
220
|
await this.saveSession(run, { summary: RUNNING_TURN_SUMMARY, tests: [], status: 'running' });
|
|
379
221
|
}
|
|
380
222
|
catch (error) {
|
|
381
|
-
// The claim and the record both name a process that never ran, and nothing else would clear
|
|
382
|
-
// either: a record left behind is an attempt the Runs view lists, and its live pid tells the
|
|
383
|
-
// recovery that another process owns it.
|
|
384
223
|
await removeOpenRunRecord(directory, run.runId).catch(() => { });
|
|
385
|
-
// The start already left; the run is accepted but ended before executing, so it owes the
|
|
386
|
-
// finish that joins it rather than leaving an unmatched start on the spool.
|
|
387
224
|
await run.telemetryStart;
|
|
388
|
-
// Same account and dimensions as the start: a shared installation must not let a newer
|
|
389
|
-
// account's cached plan decide whether this run's finish is queued.
|
|
390
225
|
await reportRunFinished({ home: directory, config, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) }, run.telemetryHandle ?? createRunHandle(run.telemetryRunId, run.startedAt, { graphId: SUBAGENT_GRAPH_ID, nodes: 1, subagents: false, permissionMode: run.permissions,
|
|
391
226
|
jevEnabled: run.jevEnabled, decisionRouting: run.decisionRouting }), { status: 'infrastructure_error', reason: 'The subagent session record could not be saved.' }).catch(() => { });
|
|
392
227
|
throw error;
|
|
393
228
|
}
|
|
394
229
|
this.active = run;
|
|
395
|
-
// A cancellation that arrived while the run was starting applies to it now.
|
|
396
230
|
if (this.pendingCancel) {
|
|
397
231
|
this.pendingCancel = false;
|
|
398
232
|
run.controller.abort(new Error('Cancelled by the calling agent'));
|
|
@@ -412,7 +246,6 @@ export class SubagentRunner {
|
|
|
412
246
|
...(run.outcome?.reason !== undefined ? { reason: run.outcome.reason } : {}),
|
|
413
247
|
};
|
|
414
248
|
}
|
|
415
|
-
/** Wait up to `waitMs` for the run; a finished run stays answerable until the next start. */
|
|
416
249
|
async result(waitMs = 0) {
|
|
417
250
|
const run = this.active;
|
|
418
251
|
if (!run)
|
|
@@ -431,32 +264,14 @@ export class SubagentRunner {
|
|
|
431
264
|
run.controller.abort(new Error('Cancelled by the calling agent'));
|
|
432
265
|
return true;
|
|
433
266
|
}
|
|
434
|
-
// A cancellation that arrives while a start is preparing belongs to that start: it has no run
|
|
435
|
-
// to abort yet, and it would otherwise go on to spend tokens. A run that has already finished
|
|
436
|
-
// is not the one being cancelled either — the replacement that is preparing is, and a
|
|
437
|
-
// cancellation dropped here would leave it to go on with billable, full-access work after the
|
|
438
|
-
// caller asked it to stop.
|
|
439
267
|
if ((!run || run.outcome !== undefined) && this.starting) {
|
|
440
268
|
this.pendingCancel = true;
|
|
441
269
|
return true;
|
|
442
270
|
}
|
|
443
271
|
return false;
|
|
444
272
|
}
|
|
445
|
-
/**
|
|
446
|
-
* End the run this process owns and wait for it to finish.
|
|
447
|
-
*
|
|
448
|
-
* The run finalizes itself: it writes the session and the terminal record, and clears the
|
|
449
|
-
* open-run claim. A caller that closes while the run works waits for that, so the records it
|
|
450
|
-
* leaves behind are the ones of a finished attempt rather than of a half-written one.
|
|
451
|
-
*/
|
|
452
273
|
async shutdown() {
|
|
453
|
-
// A start that has not reached the runner yet must not begin: the connection that asked for it
|
|
454
|
-
// is gone, and nothing would ever cancel the run it launches.
|
|
455
274
|
this.closed = true;
|
|
456
|
-
// A start that is still preparing has no run to abort yet, and it would otherwise launch a
|
|
457
|
-
// run after the connection that asked for it is gone. The start is awaited here, marked
|
|
458
|
-
// cancelled while it waits, and the run it produces is cancelled and awaited in turn, so no
|
|
459
|
-
// provider request or tool call outlives the controlling connection.
|
|
460
275
|
if (this.startPromise) {
|
|
461
276
|
this.pendingCancel = true;
|
|
462
277
|
await this.startPromise.catch(() => { });
|
|
@@ -465,17 +280,9 @@ export class SubagentRunner {
|
|
|
465
280
|
if (!run)
|
|
466
281
|
return;
|
|
467
282
|
this.cancel();
|
|
468
|
-
// A run that already finished still owns what it spawned: a QA terminal it left behind keeps
|
|
469
|
-
// the process alive behind that child, and closing the connection does not close it.
|
|
470
283
|
this.release(run);
|
|
471
284
|
await run.finished.catch(() => { });
|
|
472
285
|
}
|
|
473
|
-
/**
|
|
474
|
-
* Wait for the run, up to `waitMs`.
|
|
475
|
-
*
|
|
476
|
-
* The timer is cleared when the run wins, so a run that finished early does not keep the
|
|
477
|
-
* process alive for the rest of the wait, and repeated waits do not pile timers up.
|
|
478
|
-
*/
|
|
479
286
|
async awaitOutcome(run, waitMs) {
|
|
480
287
|
let timer;
|
|
481
288
|
const timeout = new Promise(resolve => {
|
|
@@ -490,16 +297,6 @@ export class SubagentRunner {
|
|
|
490
297
|
clearTimeout(timer);
|
|
491
298
|
}
|
|
492
299
|
}
|
|
493
|
-
/**
|
|
494
|
-
* Record one runtime event, and hand back the journal write that carries it.
|
|
495
|
-
*
|
|
496
|
-
* The returned promise is what makes the event durable before the run moves on: the runtime
|
|
497
|
-
* awaits the callback it was given, so a caller that awaits this waits for the append — and for
|
|
498
|
-
* every append queued before it — to land. Without that the runtime would advance past a
|
|
499
|
-
* mutating tool call whose event was still queued, and a kill in that window would leave a
|
|
500
|
-
* journal that omits the completed call: a resume of that attempt would replay to a position
|
|
501
|
-
* before the call and repeat its effects.
|
|
502
|
-
*/
|
|
503
300
|
observe(run, event) {
|
|
504
301
|
const data = event.data;
|
|
505
302
|
const node = typeof data.nodeId === 'string' ? data.nodeId : typeof data.node === 'string' ? data.node : undefined;
|
|
@@ -508,20 +305,9 @@ export class SubagentRunner {
|
|
|
508
305
|
run.events.splice(0, run.events.length - 200);
|
|
509
306
|
if (event.type === 'graph.node.started' && typeof data.nodeId === 'string')
|
|
510
307
|
run.currentNode = data.nodeId;
|
|
511
|
-
// The journal keeps the order the events happened in, and the runtime awaits the callback for
|
|
512
|
-
// exactly that reason: the writer chains its appends rather than launching them side by side,
|
|
513
|
-
// because the filesystem does not finish them in the order they were started. The run keeps
|
|
514
|
-
// going when an append fails (a storage hiccup must not kill the work): the writer holds the
|
|
515
|
-
// event and writes it once the file accepts appends again.
|
|
516
308
|
run.journal = run.journalWriter.append(event);
|
|
517
309
|
return run.journal;
|
|
518
310
|
}
|
|
519
|
-
/**
|
|
520
|
-
* Record what the run could not set up, and publish it.
|
|
521
|
-
*
|
|
522
|
-
* The notice is a fact about the attempt, not a log line: the run continues without the
|
|
523
|
-
* capability, and the caller can only see that from the run's own observable path.
|
|
524
|
-
*/
|
|
525
311
|
notice(run, message) {
|
|
526
312
|
run.notices.push(message);
|
|
527
313
|
if (run.notices.length > 50)
|
|
@@ -534,34 +320,25 @@ export class SubagentRunner {
|
|
|
534
320
|
let failure;
|
|
535
321
|
let mcp;
|
|
536
322
|
let codeIntel;
|
|
537
|
-
/** The repository's learned command guidance, when the installation keeps it. */
|
|
538
323
|
let commandMemory;
|
|
539
324
|
let projectMemory;
|
|
540
|
-
/** The checkpoint writes, chained so the newest conversation is the file's content. */
|
|
541
325
|
let checkpointWrites = Promise.resolve();
|
|
542
326
|
try {
|
|
543
327
|
const graph = validateGraph(await (options.loadGraph ?? loadAccessibleGraph)(SUBAGENT_GRAPH_ID, signal), { providers: config.providers, defaultProvider: config.provider, spawnAvailable: true });
|
|
544
|
-
// The preflight must probe the model the run will call: the node pins no model, so it
|
|
545
|
-
// runs on this run provider and model, not on the installation default.
|
|
546
328
|
const healthConfig = {
|
|
547
329
|
...config,
|
|
548
330
|
provider: run.providerId,
|
|
549
331
|
providers: config.providers.map(item => {
|
|
550
332
|
if (item.id !== run.providerId)
|
|
551
333
|
return item;
|
|
552
|
-
// The selected model is not the provider's configured one, so the default model's saved
|
|
553
|
-
// reasoning and window belong to that model and not to this one: a model that refuses the
|
|
554
|
-
// default model's reasoning parameter would fail the probe for a reason the run does not
|
|
555
|
-
// have.
|
|
556
334
|
return providerForModel(item, run.model);
|
|
557
335
|
}),
|
|
558
336
|
};
|
|
559
337
|
const health = await checkGraphModelHealth(graph, healthConfig, signal, {
|
|
338
|
+
// A subagent run has no monitor of its own: it asks the router once, so an Andorra that is off or signed out
|
|
339
|
+
// refuses the run with its sentence and no model request.
|
|
340
|
+
andorra: hostedGate(),
|
|
560
341
|
...(options.adapterFactory ? { createAdapter: options.adapterFactory } : options.healthDependencies),
|
|
561
|
-
// The probes are model calls this run pays for, and they happen outside `runGraph`: the
|
|
562
|
-
// result carries the graph's own calls only, so a run whose totals left the probes out
|
|
563
|
-
// would report less than it spent — and a probe that reached the provider and failed
|
|
564
|
-
// would be recorded as having cost nothing at all.
|
|
565
342
|
onUsage: (delta, reference) => {
|
|
566
343
|
foldUsage(run.probeUsage, delta);
|
|
567
344
|
options.healthDependencies?.onUsage?.(delta, reference);
|
|
@@ -580,14 +357,10 @@ export class SubagentRunner {
|
|
|
580
357
|
throw new Error(subagentHealthFailure(health));
|
|
581
358
|
}
|
|
582
359
|
const runProvider = config.providers.find(item => item.id === run.providerId);
|
|
583
|
-
// An embedded adapter keeps the run offline; the default path resolves model metadata the
|
|
584
|
-
// same way the CLI does, so context-window and effort handling match an ordinary session.
|
|
585
360
|
const resolvedProvider = options.adapterFactory ? { ...runProvider, model: run.model } : await resolveModelContext(runProvider, run.model, signal);
|
|
586
|
-
const adapterFor = options.adapterFactory ??
|
|
587
|
-
const snapshot = await extensionSnapshot(config, signal, run.directory);
|
|
588
|
-
const instructions = `${await loadWorkspaceInstructions(run.workspace, signal, config.systemPromptOverride)}${snapshot.instructions}`;
|
|
589
|
-
// The harness needs no hosted membership, and asking for it only adds the delay of a token
|
|
590
|
-
// refresh and a membership request before a run that is entirely local.
|
|
361
|
+
const adapterFor = options.adapterFactory ?? subagentAdapterFactory(run.sessionId);
|
|
362
|
+
const snapshot = await extensionSnapshot(effectiveExtensionConfig(config, run.workspace), signal, run.directory);
|
|
363
|
+
const instructions = `${await loadWorkspaceInstructions(run.workspace, signal, systemPromptOverrideFor(graph, config.systemPromptOverride))}${snapshot.instructions}`;
|
|
591
364
|
const context = {
|
|
592
365
|
workspace: run.workspace, signal,
|
|
593
366
|
yolo: run.permissions === 'full-access', permissions: run.permissions, approvalMode: 'headless',
|
|
@@ -595,31 +368,18 @@ export class SubagentRunner {
|
|
|
595
368
|
};
|
|
596
369
|
if (Object.keys(snapshot.servers).length) {
|
|
597
370
|
const { connectMcpServers } = await import('./mcp.js');
|
|
598
|
-
// A server that could not connect, or a catalog that was refused, is told to the
|
|
599
|
-
// caller: the run continues without those tools, and the host has to know that its
|
|
600
|
-
// task is running with less than it configured.
|
|
601
371
|
mcp = await connectMcpServers(snapshot.servers, context, message => this.notice(run, message), signal);
|
|
602
372
|
}
|
|
603
|
-
// The run's memory and its decision policy come from the configuration of the home it
|
|
604
|
-
// runs in: the runner falls back to the process-wide installation otherwise, and the run
|
|
605
|
-
// would read and write another installation's memory.
|
|
606
373
|
const memory = await MemoryManager.create({
|
|
607
374
|
config: resolveMemoryConfig(config, process.env, detail => { void this.observe(run, { type: 'memory.error', time: new Date().toISOString(), data: { runId: run.runId, operation: 'Graphiti', detail } }); }), workspace: run.workspace,
|
|
608
375
|
onEvent: event => this.observe(run, event), getPermissions: () => permissionMode(context),
|
|
609
376
|
});
|
|
610
377
|
codeIntel = await this.codeIntelligence(run, config, signal);
|
|
611
|
-
// The artifacts belong to the home the run works in: the process-wide installation would
|
|
612
|
-
// hold files the run's own records cannot find.
|
|
613
378
|
const artifactStore = new ArtifactStore(run.runId, run.directory);
|
|
614
|
-
// The repository's learned command guidance is the installation's setting, and a subagent
|
|
615
|
-
// run honours it like any other run.
|
|
616
379
|
if (config.commandMemory !== false)
|
|
617
380
|
commandMemory = await LocalToolMemory.open({ workspace: run.workspace, directory: run.directory });
|
|
618
381
|
if (config.projectMemory !== false)
|
|
619
382
|
projectMemory = await ProjectMemory.open({ home: run.directory, workspace: run.workspace });
|
|
620
|
-
// The checkpoints land one at a time, newest last: the runner calls back synchronously from
|
|
621
|
-
// several nodes, and an unserialized write could leave an older conversation as the file's
|
|
622
|
-
// final content.
|
|
623
383
|
const persistCheckpoint = (nodeId, messages, state, meta) => {
|
|
624
384
|
checkpointWrites = checkpointWrites
|
|
625
385
|
.then(() => writeRunCheckpoint(run.directory, run.runId, {
|
|
@@ -628,22 +388,13 @@ export class SubagentRunner {
|
|
|
628
388
|
...(meta?.provider === undefined ? {} : { provider: meta.provider }),
|
|
629
389
|
...(meta?.model === undefined ? {} : { model: meta.model }),
|
|
630
390
|
}))
|
|
631
|
-
// The run keeps going — durability is a convenience, never the run's outcome. But a
|
|
632
|
-
// checkpoint that could not be written is the conversation a resume re-enters the node
|
|
633
|
-
// with, so the node stays marked until one of its later writes lands; a resume of an
|
|
634
|
-
// attempt that stopped while it was marked warns that the node may repeat work.
|
|
635
391
|
.then(() => run.checkpoints.succeeded({ nodeId, generation: meta?.generation }), error => run.checkpoints.failed({ nodeId, generation: meta?.generation }, error));
|
|
636
|
-
// The write is handed back so the runtime can await it: the checkpoint is the conversation
|
|
637
|
-
// a resume re-enters the node with, and a run that advanced past a mutating tool call
|
|
638
|
-
// while its checkpoint was still queued could be killed with that conversation unwritten.
|
|
639
392
|
return checkpointWrites;
|
|
640
393
|
};
|
|
641
394
|
const { createTools } = await import('./tools.js');
|
|
642
395
|
const graphOptions = {
|
|
643
396
|
task: run.task, runId: run.runId, provider: run.providerId, model: run.model,
|
|
644
397
|
adapter: adapterFor(resolvedProvider),
|
|
645
|
-
// The model context window the registry resolved, so the run compacts against the
|
|
646
|
-
// provider limit rather than the generic one.
|
|
647
398
|
...(resolvedProvider.contextWindow === undefined ? {} : { contextWindow: resolvedProvider.contextWindow }),
|
|
648
399
|
tools: [...createTools(), ...snapshot.tools, ...(mcp?.tools ?? [])],
|
|
649
400
|
instructions, limits: resolveConfiguredLimits(config), todoStore: new TodoStore(),
|
|
@@ -651,26 +402,17 @@ export class SubagentRunner {
|
|
|
651
402
|
const provider = config.providers.find(item => item.id === id);
|
|
652
403
|
if (!provider)
|
|
653
404
|
throw new Error(`Unknown provider: ${id}. Use /providers to add or edit providers.`);
|
|
654
|
-
// A node that names no model takes the run's own model when it runs on the run's own
|
|
655
|
-
// provider: the host chose that pair, and the provider's configured default is a model
|
|
656
|
-
// nobody asked for. The preflight and the reported result already use it, so the request
|
|
657
|
-
// has to bill the same one.
|
|
658
405
|
const wanted = model ?? (id === run.providerId ? run.model : provider.model);
|
|
659
406
|
if (options.adapterFactory) {
|
|
660
|
-
// The same normalization the preflight and the ordinary path apply: the saved
|
|
661
|
-
// reasoning effort and context window belong to the provider's configured model, so an
|
|
662
|
-
// embedded adapter is not handed the default model's settings for another one.
|
|
663
407
|
return Promise.resolve({ model: wanted, adapter: options.adapterFactory(providerForModel(provider, wanted)), providerType: provider.type, baseUrl: provider.baseUrl });
|
|
664
408
|
}
|
|
665
409
|
return resolveModelContext(provider, wanted, modelSignal)
|
|
666
|
-
.then(resolved => ({ model: resolved.model, adapter:
|
|
410
|
+
.then(resolved => ({ model: resolved.model, adapter: subagentAdapterFactory(run.sessionId)(resolved), contextWindow: resolved.contextWindow, providerType: provider.type, baseUrl: provider.baseUrl }));
|
|
667
411
|
},
|
|
668
412
|
resolveProvider: id => {
|
|
669
413
|
const provider = config.providers.find(item => item.id === id);
|
|
670
414
|
if (!provider)
|
|
671
415
|
throw new Error(`Unknown provider: ${id}. Use /providers to add or edit providers.`);
|
|
672
|
-
// The node pins no model, so it runs on the model this run selected: a provider's
|
|
673
|
-
// own default is a model the host never asked for.
|
|
674
416
|
const selected = providerForModel(provider, run.model);
|
|
675
417
|
return { model: run.model, adapter: adapterFor(selected), contextWindow: selected.contextWindow, providerType: selected.type, baseUrl: selected.baseUrl };
|
|
676
418
|
},
|
|
@@ -681,11 +423,7 @@ export class SubagentRunner {
|
|
|
681
423
|
memory,
|
|
682
424
|
decisionManager: new DecisionManager({ config: await subagentDecisionConfig(config, () => (options.membership ?? getMembership)(signal)), onEvent: event => this.observe(run, event) }),
|
|
683
425
|
decisionNodeOptIn: true,
|
|
684
|
-
// The code intelligence of the installation this run works in, so the run has the same
|
|
685
|
-
// repository coverage an ordinary Andorra Agent run has.
|
|
686
426
|
...(codeIntel ? { codeIntel } : {}),
|
|
687
|
-
// The checkpoints a resume reads: without them a replay re-enters the node from its
|
|
688
|
-
// opening task and repeats the writes and shell calls that already ran.
|
|
689
427
|
onNodeCheckpoint: persistCheckpoint,
|
|
690
428
|
onEvent: event => this.observe(run, event),
|
|
691
429
|
};
|
|
@@ -695,18 +433,13 @@ export class SubagentRunner {
|
|
|
695
433
|
failure = error;
|
|
696
434
|
}
|
|
697
435
|
finally {
|
|
698
|
-
// The work is over: from here the run only writes its records, and a cancellation would be
|
|
699
|
-
// reported as accepted while the run publishes what it did.
|
|
700
436
|
run.executed = true;
|
|
701
|
-
// The checkpoints are drained before the attempt is published: a resume that reads a
|
|
702
|
-
// half-written checkpoint would replay the node from its opening task.
|
|
703
437
|
await checkpointWrites.catch(() => { });
|
|
704
438
|
await mcp?.close().catch(() => { });
|
|
705
439
|
await codeIntel?.dispose().catch(() => { });
|
|
706
440
|
await this.finalize(run, result, failure);
|
|
707
441
|
}
|
|
708
442
|
}
|
|
709
|
-
/** The session record for a run: the turn it is running, or the one it finished. */
|
|
710
443
|
async saveSession(run, completion, usage = { requests: 0, inputTokens: 0, outputTokens: 0 }, updatedAt = new Date().toISOString()) {
|
|
711
444
|
await new SessionStore(run.directory).save({
|
|
712
445
|
version: 1, id: run.sessionId, name: sessionName(run.task), workspace: run.workspace, updatedAt,
|
|
@@ -716,23 +449,16 @@ export class SubagentRunner {
|
|
|
716
449
|
async finalize(run, result, failure) {
|
|
717
450
|
const status = result?.status ?? (run.controller.signal.aborted ? 'cancelled' : 'infrastructure_error');
|
|
718
451
|
const reason = result?.reason ?? (failure !== undefined ? (failure instanceof Error ? failure.message : String(failure)) : undefined);
|
|
719
|
-
// The start's own dimensions and account are repeated: the configuration may have changed
|
|
720
|
-
// while the run was in flight, and a joined pair that reported different JEV/routing settings
|
|
721
|
-
// would attribute the run to settings it never used.
|
|
722
452
|
const telemetrySurface = { home: run.directory, surface: 'subagent', ...(run.accountSubject === undefined ? {} : { subject: run.accountSubject }) };
|
|
723
453
|
const telemetryHandle = run.telemetryHandle ?? createRunHandle(run.telemetryRunId, run.startedAt, {
|
|
724
454
|
graphId: SUBAGENT_GRAPH_ID, nodes: 1, subagents: false, permissionMode: run.permissions,
|
|
725
455
|
jevEnabled: run.jevEnabled, decisionRouting: run.decisionRouting,
|
|
726
456
|
}, run.workspace);
|
|
727
457
|
let telemetryFinished = false;
|
|
728
|
-
// The finish is returned so the caller can wait for it: a drain that starts before the finish
|
|
729
|
-
// is queued exits with the event still on the spool.
|
|
730
458
|
const settleTelemetry = (settled, why) => {
|
|
731
459
|
if (telemetryFinished)
|
|
732
460
|
return Promise.resolve();
|
|
733
461
|
telemetryFinished = true;
|
|
734
|
-
// The finish waits for the start: a short run can otherwise drain before the start is queued.
|
|
735
|
-
// The health probes precede the graph, so their tuples join the capture the finish reports.
|
|
736
462
|
const finishedTelemetry = result?.telemetry ?? createRunTelemetry();
|
|
737
463
|
for (const probe of run.probeModels.values()) {
|
|
738
464
|
recordModelUse(finishedTelemetry, { providerType: run.providerType, baseUrl: run.baseUrl, model: probe.model, role: 'other', usage: probe.usage });
|
|
@@ -747,62 +473,31 @@ export class SubagentRunner {
|
|
|
747
473
|
};
|
|
748
474
|
const endedAt = new Date().toISOString();
|
|
749
475
|
const usage = result?.usage ?? { requests: 0, inputTokens: 0, outputTokens: 0 };
|
|
750
|
-
// The preflight ran outside `runGraph`, so its spend is folded in here: the result carries
|
|
751
|
-
// the graph's own calls only, and the record and the session report what the attempt cost.
|
|
752
476
|
foldUsage(usage, run.probeUsage);
|
|
753
|
-
// The record holds the run's own result, so the Runs view reports its graph, its
|
|
754
|
-
// completion, its tool calls and its todos, and the subagent identity is laid over it.
|
|
755
477
|
const record = {
|
|
756
478
|
...(result ?? {}),
|
|
757
479
|
id: run.runId, status, ...(reason !== undefined ? { reason } : {}), graphSelection: SUBAGENT_GRAPH_ID,
|
|
758
480
|
subagent: true, usage, sessionId: run.sessionId, startedAt: run.startedAt, endedAt,
|
|
759
481
|
provider: run.providerId, model: run.model,
|
|
760
|
-
// The permission the host bound the attempt to, so a later resume of it inherits the
|
|
761
|
-
// restriction rather than the workspace's own current setting.
|
|
762
482
|
permissions: run.permissions,
|
|
763
483
|
};
|
|
764
|
-
// The journal is drained before the record that says the run finished: a record that reports a
|
|
765
|
-
// completed run while its last events are still being written is a record whose journal tail
|
|
766
|
-
// may never land.
|
|
767
|
-
// Settling also retries whatever the file refused earlier, so space freed since then lets the
|
|
768
|
-
// journal finish whole.
|
|
769
484
|
await run.journal.catch(() => { });
|
|
770
485
|
const journalIntact = await run.journalWriter.settle();
|
|
771
|
-
// The record carries the flag the resume reads when the marker file could not be written: a
|
|
772
|
-
// resume of an attempt whose journal has a hole warns that a step may repeat.
|
|
773
486
|
if (!journalIntact)
|
|
774
487
|
record.journalIntegrity = 'failed';
|
|
775
|
-
// The same flag for a node whose newest checkpoint could not be written: a resume re-enters
|
|
776
|
-
// that node from an older conversation, and warns that it may repeat work.
|
|
777
488
|
if (!run.checkpoints.intact) {
|
|
778
489
|
record.checkpointIntegrity = 'failed';
|
|
779
490
|
record.checkpointFailures = run.checkpoints.failures;
|
|
780
491
|
}
|
|
781
|
-
// The terminal record is written before the session is finalized. A crash between the two
|
|
782
|
-
// leaves a session whose turn is still marked running, which the startup recovery repairs
|
|
783
|
-
// from the record; the other order would leave a session that reports the completion while
|
|
784
|
-
// the recovery still rewrites the still-open record as interrupted, and a completed turn is
|
|
785
|
-
// not one the recovery reconciles.
|
|
786
492
|
try {
|
|
787
493
|
await writeFile(runRecordPath(run.directory, run.runId, 'json'), JSON.stringify(record, null, 2) + '\n', { mode: 0o600 });
|
|
788
494
|
}
|
|
789
495
|
catch (error) {
|
|
790
496
|
process.stderr.write(`Could not record the stopped subagent run: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
791
|
-
// The terminal record did not land, and the attempt is still open: the record says the run
|
|
792
|
-
// is live and the claim holds the session against it. A long-lived server would keep the
|
|
793
|
-
// attempt in the Runs view and the session locked until the process exited, so the record is
|
|
794
|
-
// terminalized here, and the claim released once that record landed: the attempt failed,
|
|
795
|
-
// and it says so.
|
|
796
497
|
const detail = error instanceof Error ? error.message : String(error);
|
|
797
498
|
const terminalized = await writeFile(runRecordPath(run.directory, run.runId, 'json'), JSON.stringify({
|
|
798
499
|
...record, status: 'infrastructure_error', reason: `The run record could not be written: ${detail}`, endedAt,
|
|
799
500
|
}, null, 2) + '\n', { mode: 0o600 }).then(() => true, () => false);
|
|
800
|
-
// The sidecar carries the same projection the ordinary finalizer writes: it is newer than the
|
|
801
|
-
// record, and Graph Studio prefers it, so a sidecar without the graph and the tool calls
|
|
802
|
-
// would report a null for both.
|
|
803
|
-
// The sidecar is published only when the terminal record landed: it is newer than the
|
|
804
|
-
// record, and a sidecar that says the attempt is terminal while the record still says the
|
|
805
|
-
// run is live would make Graph Studio report an attempt that is not.
|
|
806
501
|
if (terminalized) {
|
|
807
502
|
await writeStudioRunSummary(run.directory, {
|
|
808
503
|
id: run.runId, status: 'infrastructure_error', startedAt: run.startedAt, graphSelection: SUBAGENT_GRAPH_ID,
|
|
@@ -810,25 +505,14 @@ export class SubagentRunner {
|
|
|
810
505
|
...(typeof result?.toolCalls === 'number' ? { toolCalls: result.toolCalls } : {}),
|
|
811
506
|
}).catch(() => { });
|
|
812
507
|
}
|
|
813
|
-
// The session is landed before the claim is given back. The claim is what holds the session
|
|
814
|
-
// against a mutation, and a rename, archive or delete accepted in that window would be
|
|
815
|
-
// overwritten by the save below — or, if that save fails, left behind with the session
|
|
816
|
-
// still marked running. A save that fails is repaired from the record, the way the normal
|
|
817
|
-
// path repairs it.
|
|
818
508
|
try {
|
|
819
509
|
await this.saveSession(run, { summary: `The run finished, but its record could not be written: ${detail}`, tests: [], status: 'infrastructure_error' }, usage, endedAt);
|
|
820
510
|
}
|
|
821
511
|
catch {
|
|
822
512
|
await repairSessionMarkers(run.directory, run.sessionId).catch(() => { });
|
|
823
513
|
}
|
|
824
|
-
// The claim is released only when the terminal record landed. A record that still says the
|
|
825
|
-
// run is live, with no claim to say so, is a history that contradicts itself — and when
|
|
826
|
-
// even that write fails, the claim stays and the recovery classifies the attempt once
|
|
827
|
-
// this process is gone, which is the answer that is true rather than one that reads well.
|
|
828
514
|
if (terminalized)
|
|
829
515
|
await clearOpenRunClaim(run.directory, run.runId).catch(() => { });
|
|
830
|
-
// The reservation is given back before the outcome is published: a caller that reads the
|
|
831
|
-
// outcome must be able to start the next run in the same workspace.
|
|
832
516
|
this.releaseWorkspace();
|
|
833
517
|
this.release(run);
|
|
834
518
|
await settleTelemetry('infrastructure_error', `The run record could not be written: ${detail}`);
|
|
@@ -836,15 +520,9 @@ export class SubagentRunner {
|
|
|
836
520
|
run.outcome = { status: 'infrastructure_error', reason: `The run record could not be written: ${detail}` };
|
|
837
521
|
return;
|
|
838
522
|
}
|
|
839
|
-
// A finished run has nothing to resume, so its durable conversation goes with it: a checkpoint
|
|
840
|
-
// file holds the node's whole message history — tool outputs included — and repeated subagent
|
|
841
|
-
// runs would accumulate all of it under `runs/` for ever. The ordinary CLI and app-server
|
|
842
|
-
// finalizers delete it for the same reason. A stopped attempt keeps its checkpoint: that one
|
|
843
|
-
// is what a resume re-enters the node with.
|
|
844
523
|
if (status === 'succeeded')
|
|
845
524
|
await removeRunCheckpoint(run.directory, run.runId).catch(() => { });
|
|
846
525
|
try {
|
|
847
|
-
// A stopped run's completion says how it stopped: an absent status is read as a success.
|
|
848
526
|
const completion = result?.completion ?? {
|
|
849
527
|
summary: summaryForStoppedRecord(record),
|
|
850
528
|
tests: [],
|
|
@@ -853,54 +531,24 @@ export class SubagentRunner {
|
|
|
853
531
|
await this.saveSession(run, completion, usage, endedAt);
|
|
854
532
|
}
|
|
855
533
|
catch (error) {
|
|
856
|
-
// The record says how the attempt ended and the session's turn is still marked running. The
|
|
857
|
-
// repair belongs to the session now, not to the next start: a long-lived server would leave
|
|
858
|
-
// the turn unfinished until it was restarted.
|
|
859
534
|
await repairSessionMarkers(run.directory, run.sessionId).catch(() => { });
|
|
860
535
|
process.stderr.write(`Could not save the subagent session: ${error instanceof Error ? error.message : String(error)}\n`);
|
|
861
536
|
}
|
|
862
|
-
// The studio sidecar carries the same projection the ordinary run finalizers write, so Graph
|
|
863
|
-
// Studio reports the run's graph and its tool calls rather than a null for both.
|
|
864
537
|
await writeStudioRunSummary(run.directory, {
|
|
865
538
|
id: run.runId, status, startedAt: run.startedAt, graphSelection: SUBAGENT_GRAPH_ID,
|
|
866
539
|
...(result?.graph ? { graph: result.graph } : {}),
|
|
867
540
|
...(typeof result?.toolCalls === 'number' ? { toolCalls: result.toolCalls } : {}),
|
|
868
541
|
}).catch(() => { });
|
|
869
542
|
await clearOpenRunClaim(run.directory, run.runId).catch(() => { });
|
|
870
|
-
// The reservation is given back before the outcome is published: a caller that reads the
|
|
871
|
-
// outcome must be able to start the next run in the same workspace.
|
|
872
543
|
this.releaseWorkspace();
|
|
873
|
-
// The run is over, and what it owns is tied to its signal: a QA terminal it spawned and did
|
|
874
|
-
// not kill keeps the process alive behind that child, so the CLI would print its result and
|
|
875
|
-
// never exit. Releasing the signal closes them, and the outcome is already decided.
|
|
876
544
|
this.release(run);
|
|
877
545
|
await settleTelemetry(status, reason);
|
|
878
546
|
await drainTelemetry(telemetrySurface).catch(() => { });
|
|
879
547
|
run.outcome = { status, ...(result !== undefined ? { result } : {}), ...(reason !== undefined ? { reason } : {}) };
|
|
880
548
|
}
|
|
881
|
-
/**
|
|
882
|
-
* The signal the run's own resources are tied to.
|
|
883
|
-
*
|
|
884
|
-
* A run releases it when it ends: a QA terminal it spawned and did not kill stays open behind
|
|
885
|
-
* its child, and the process would not exit. The signal is what closes it, so this is how a
|
|
886
|
-
* caller sees that the run has let go of what it owned.
|
|
887
|
-
*/
|
|
888
549
|
runSignal() {
|
|
889
550
|
return this.active?.controller.signal;
|
|
890
551
|
}
|
|
891
|
-
/**
|
|
892
|
-
* Release what the run owns.
|
|
893
|
-
*
|
|
894
|
-
* The run's signal is what its QA terminals and other run-scoped resources are tied to, and a
|
|
895
|
-
* finished run never releases it on its own: only a cancellation aborts it. A run that succeeded
|
|
896
|
-
* with a terminal still open would keep the process alive behind that child.
|
|
897
|
-
*/
|
|
898
|
-
/**
|
|
899
|
-
* The code intelligence the run works with.
|
|
900
|
-
*
|
|
901
|
-
* The manager takes its own read-only branch and its own disabled branch, so it is always
|
|
902
|
-
* created; what matters is that both guards reach it rather than indexing by default.
|
|
903
|
-
*/
|
|
904
552
|
async codeIntelligence(run, config, signal) {
|
|
905
553
|
if (signal.aborted)
|
|
906
554
|
return undefined;
|
|
@@ -914,12 +562,6 @@ export class SubagentRunner {
|
|
|
914
562
|
return;
|
|
915
563
|
run.controller.abort(new Error('The subagent run has finished.'));
|
|
916
564
|
}
|
|
917
|
-
/**
|
|
918
|
-
* Give the process-wide reservation back.
|
|
919
|
-
*
|
|
920
|
-
* Only the holder gives it back: a runner whose start failed releases nothing that another
|
|
921
|
-
* runner has taken since.
|
|
922
|
-
*/
|
|
923
565
|
releaseWorkspace() {
|
|
924
566
|
const workspace = this.reservedWorkspace;
|
|
925
567
|
if (workspace === undefined)
|