@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/graph-runner.js
CHANGED
|
@@ -4,8 +4,10 @@ import { randomUUID } from 'node:crypto';
|
|
|
4
4
|
import { TodoStore } from './todos.js';
|
|
5
5
|
import { WidgetStore } from './widgets.js';
|
|
6
6
|
import { isDeepStrictEqual } from 'node:util';
|
|
7
|
-
import { validateGraph, nodeOutcomes, maxNodeVisitsOf } from './graphs.js';
|
|
7
|
+
import { validateGraph, nodeOutcomes, maxNodeVisitsOf, ACTION_FAILED_OUTCOME } from './graphs.js';
|
|
8
|
+
import { CommandExitError } from './tool-errors.js';
|
|
8
9
|
import { executeModifiedAgent, matchesOutput } from './agent-modifiers.js';
|
|
10
|
+
import { GOAL_NEEDS_AGENT, graphCanCheckGoal } from './session-goal.js';
|
|
9
11
|
import { executeAgentNode, PLAN_DECISION_MARKER } from './agent-execution.js';
|
|
10
12
|
import { resolveLimits, stopReasonSentence, withinToolBudget, generateWithUsage } from './runtime.js';
|
|
11
13
|
import { bindUserWaits, createRuntimeBudget } from './deadline.js';
|
|
@@ -23,13 +25,6 @@ import { elapsedMs, monotonicNow } from './duration.js';
|
|
|
23
25
|
import { dashboardAdapter } from './dashboard.js';
|
|
24
26
|
import { createRunTelemetry, mergeRunTelemetry, recordAttempt, recordTestCommand, recordToolFailure, recordToolUse } from './telemetry/capture.js';
|
|
25
27
|
import { isTestCommandLine } from './telemetry/classify.js';
|
|
26
|
-
/**
|
|
27
|
-
* Fold one node's telemetry and failure classification into the run.
|
|
28
|
-
*
|
|
29
|
-
* A graph run loses the structured provider-failure marker unless it is copied here, which would
|
|
30
|
-
* report every provider outage as `infrastructure`. The same is true of the context-overflow
|
|
31
|
-
* classification: copying it keeps an over-window input out of the provider-failure rate.
|
|
32
|
-
*/
|
|
33
28
|
function absorbTelemetry(result, outcome) {
|
|
34
29
|
if (outcome.telemetry)
|
|
35
30
|
mergeRunTelemetry(result.telemetry, outcome.telemetry);
|
|
@@ -44,24 +39,9 @@ const freeze = (value) => {
|
|
|
44
39
|
freeze(child);
|
|
45
40
|
Object.freeze(value);
|
|
46
41
|
};
|
|
47
|
-
/**
|
|
48
|
-
* Tool calls still available to one node when the run ceiling is optional.
|
|
49
|
-
* Unlimited stays undefined; subtracting from an absent ceiling would produce NaN
|
|
50
|
-
* and hand every downstream branch a meaningless budget.
|
|
51
|
-
* @param maxToolCalls - run ceiling, or undefined for unlimited.
|
|
52
|
-
* @param used - tool calls the run has already consumed.
|
|
53
|
-
* @returns the remaining allowance, or undefined for unlimited.
|
|
54
|
-
*/
|
|
55
42
|
function remainingToolBudget(maxToolCalls, used) {
|
|
56
43
|
return maxToolCalls === undefined ? undefined : maxToolCalls - used;
|
|
57
44
|
}
|
|
58
|
-
/**
|
|
59
|
-
* Split the remaining run allowance across concurrent branches.
|
|
60
|
-
* @param maxToolCalls - run ceiling, or undefined for unlimited.
|
|
61
|
-
* @param used - tool calls the run has already consumed.
|
|
62
|
-
* @param branches - number of branches sharing the remaining allowance.
|
|
63
|
-
* @returns each branch's share, or undefined when the run is unlimited.
|
|
64
|
-
*/
|
|
65
45
|
function shareToolBudget(maxToolCalls, used, branches) {
|
|
66
46
|
const remaining = remainingToolBudget(maxToolCalls, used);
|
|
67
47
|
return remaining === undefined ? undefined : Math.floor(remaining / branches);
|
|
@@ -74,9 +54,9 @@ function mergeInputs(target, incoming, nodeId) {
|
|
|
74
54
|
target[key] = value;
|
|
75
55
|
}
|
|
76
56
|
}
|
|
77
|
-
/** Graph stages route validated completions only. Internal delegation remains inside executeAgentNode. */
|
|
78
57
|
export async function runGraph(graph, options) {
|
|
79
|
-
|
|
58
|
+
if (options.goalCompletionVerification && !graphCanCheckGoal(graph))
|
|
59
|
+
throw new Error(GOAL_NEEDS_AGENT);
|
|
80
60
|
const removedMemorySettings = [];
|
|
81
61
|
if (!options.memory || !options.decisionManager) {
|
|
82
62
|
const config = await loadConfig();
|
|
@@ -96,8 +76,6 @@ export async function runGraph(graph, options) {
|
|
|
96
76
|
if (!Number.isSafeInteger(value) || value < (name === 'maxCompletionRepairs' || name === 'maxToolCalls' ? 0 : 1))
|
|
97
77
|
throw new Error(`Invalid limit: ${name}`);
|
|
98
78
|
}
|
|
99
|
-
// Only an explicit graph ceiling can tighten the run allowance; when neither is set
|
|
100
|
-
// the run is unbounded and stays undefined rather than becoming a fabricated number.
|
|
101
79
|
for (const key of ['maxToolCalls', 'wallTimeMs']) {
|
|
102
80
|
const pinnedLimit = pinned.limits?.[key];
|
|
103
81
|
if (pinnedLimit === undefined)
|
|
@@ -110,10 +88,6 @@ export async function runGraph(graph, options) {
|
|
|
110
88
|
validateValue(pinned.inputSchema, runInput, 'Run inputs');
|
|
111
89
|
if (pinned.stateSchema)
|
|
112
90
|
validateValue(pinned.stateSchema, runState, 'Run state');
|
|
113
|
-
// The model identity this run would execute a node with, mirroring the runtime's own resolution
|
|
114
|
-
// (`node.provider ?? run provider`, and the model the node declares or the resolved provider's
|
|
115
|
-
// configured one). A per-provider model the runtime resolves later is unknowable here, so only
|
|
116
|
-
// the identities this build can prove are compared.
|
|
117
91
|
const nodeIdentity = (nodeId) => {
|
|
118
92
|
const node = pinned.nodes[nodeId];
|
|
119
93
|
const provider = node?.provider ?? options.provider;
|
|
@@ -128,16 +102,7 @@ export async function runGraph(graph, options) {
|
|
|
128
102
|
return { provider };
|
|
129
103
|
}
|
|
130
104
|
};
|
|
131
|
-
// Only an agent node runs a model, so only its start line names one: an action or routing node
|
|
132
|
-
// has no model identity, and claiming the run's inherited one would tell a surface reading the
|
|
133
|
-
// rail that the node ran on a model it never called.
|
|
134
105
|
const startIdentity = (nodeId, routed) => routed ?? (pinned.nodes[nodeId]?.type === 'agent' ? nodeIdentity(nodeId) : {});
|
|
135
|
-
// A checkpoint's conversation is the NODE's own transcript — system prompt, tool definitions,
|
|
136
|
-
// continuation counters — and the runtime installs it as the resumed visit's history without
|
|
137
|
-
// checking who wrote it (unlike a predecessor handoff, which is gated on the same identity).
|
|
138
|
-
// Handing it to a node the graph or profile now resolves to another provider/model would give
|
|
139
|
-
// the new model instructions and counters from a different one: restart that visit fresh.
|
|
140
|
-
// `undefined` on either side of a comparison means unknowable, not different.
|
|
141
106
|
const sameIdentity = (candidate, identity) => {
|
|
142
107
|
if (!candidate)
|
|
143
108
|
return false;
|
|
@@ -149,19 +114,10 @@ export async function runGraph(graph, options) {
|
|
|
149
114
|
if (checkpoint.provider === undefined && checkpoint.model === undefined)
|
|
150
115
|
return true;
|
|
151
116
|
const identity = nodeIdentity(nodeId);
|
|
152
|
-
// The conversation's own pair matching the configured one is the unchanged rule. Adaptive
|
|
153
|
-
// routing adds a second way: the checkpoint carries the baseline it was routed FROM, and a
|
|
154
|
-
// baseline this run still computes proves the routed pair was this configuration's own
|
|
155
|
-
// decision — so the conversation may continue on the model that actually ran. A baseline
|
|
156
|
-
// that no longer matches (the graph or provider configuration changed) keeps the old rule
|
|
157
|
-
// and the visit restarts fresh.
|
|
158
117
|
if (sameIdentity(checkpoint, identity))
|
|
159
118
|
return true;
|
|
160
119
|
return sameIdentity(checkpoint.routedFrom, identity);
|
|
161
120
|
};
|
|
162
|
-
// The pair a continuable checkpoint's conversation ran on when it is NOT the configured one:
|
|
163
|
-
// the routed pair this run's own routing decision produced. The re-entered visit is pinned to
|
|
164
|
-
// it (see the seeding below), so the transcript continues on the model that wrote it.
|
|
165
121
|
const routedContinuation = (nodeId, checkpoint) => {
|
|
166
122
|
if (checkpoint.provider === undefined || checkpoint.model === undefined)
|
|
167
123
|
return undefined;
|
|
@@ -173,22 +129,6 @@ export async function runGraph(graph, options) {
|
|
|
173
129
|
return { provider: checkpoint.provider, model: checkpoint.model };
|
|
174
130
|
};
|
|
175
131
|
if (options.resumeFrom) {
|
|
176
|
-
// The journal replay can prove the stopped attempt already ran its whole graph with nothing
|
|
177
|
-
// left to continue: an empty frontier alongside nodes or visits the journal proves (visits
|
|
178
|
-
// included, because a node removed from the edited graph keeps its visit count but can never
|
|
179
|
-
// re-enter), no completed End whose bare re-entry would finalize the attempt instead, and no
|
|
180
|
-
// checkpoint still owning a conversation to re-enter. Seeding that position would leave only
|
|
181
|
-
// the entry queue: every completed node run again, its tool effects and token spend paid a
|
|
182
|
-
// second time. That is not continuing an invocation, so the refusal lands here — before the
|
|
183
|
-
// budget timer, the user-wait binding, and telemetry open — and nothing opened needs
|
|
184
|
-
// unwinding. The follow-up the user sends carries the finished work as session context.
|
|
185
|
-
// The exemption mirrors the seeding below exactly: a checkpoint the seeding would install
|
|
186
|
-
// (its node in the graph, no recorded completion — an interrupted frontier is impossible
|
|
187
|
-
// with a pending array this code has already proven empty — and the provider/model stamp
|
|
188
|
-
// this run may continue) means the journal's empty frontier only says the node's start line
|
|
189
|
-
// never reached it: the attempt is recoverable, not finished. And an End completed on one
|
|
190
|
-
// branch cannot finalize while a join another branch owes still sits unresolved — the
|
|
191
|
-
// re-entry would throw after `run.started`, so the request is refused instead.
|
|
192
132
|
const stopped = options.resumeFrom.progress;
|
|
193
133
|
const provenWork = Object.keys(stopped.nodeResults).length > 0 || Object.values(stopped.visits).some(count => count > 0);
|
|
194
134
|
const unresolvedJoins = (stopped.waitingJoins ?? []).some(join => pinned.nodes[join.nodeId] !== undefined && !Object.hasOwn(stopped.nodeResults, join.nodeId));
|
|
@@ -199,13 +139,6 @@ export async function runGraph(graph, options) {
|
|
|
199
139
|
}
|
|
200
140
|
}
|
|
201
141
|
const budget = createRuntimeBudget(options.context.signal, limits.wallTimeMs, options.context.runControl);
|
|
202
|
-
// A node is handed only the run's remaining time, so its own wall bound is a slice of the run's.
|
|
203
|
-
// When the run's clock is what ran out, the stop names the run's limit: a node that started with a
|
|
204
|
-
// minute left otherwise reports a two-hour run as having "run out of time after about 1 minute".
|
|
205
|
-
// Ownership is decided from what the node was handed when it STARTED, not from the bound its last
|
|
206
|
-
// inner invocation reports: the slice and the run's clock share one deadline, so either timer can
|
|
207
|
-
// be the one that notices, and a node with loop or copy modifiers hands each later pass only the
|
|
208
|
-
// time it has left, so its final slice is smaller than its own limit even when that limit expired.
|
|
209
142
|
const handedWallMs = new Map();
|
|
210
143
|
const runClockBounds = (bounds, reason, nodeId) => {
|
|
211
144
|
if (reason !== 'wallTimeMs')
|
|
@@ -218,8 +151,6 @@ export async function runGraph(graph, options) {
|
|
|
218
151
|
};
|
|
219
152
|
const signal = budget.signal;
|
|
220
153
|
const confirmedClarifications = [];
|
|
221
|
-
// Bind before queueing: the queue must serialize the budget-aware `approve`, or a wait
|
|
222
|
-
// that only enters the queue would still be charged to the run's clock.
|
|
223
154
|
const awaiting = bindUserWaits(options.context, budget, signal);
|
|
224
155
|
const askUser = awaiting.askUser;
|
|
225
156
|
const context = {
|
|
@@ -228,8 +159,6 @@ export async function runGraph(graph, options) {
|
|
|
228
159
|
approve: serializeApprovals((...args) => awaiting.approve(...args), () => permissionMode(awaiting)),
|
|
229
160
|
...(askUser ? { askUser: async (...args) => {
|
|
230
161
|
const answer = await askUser(...args);
|
|
231
|
-
// A plan presentation is not a clarification pair to distill: the plan body rides its own
|
|
232
|
-
// journal events, and the verdict ('Approve plan') carries no reusable requirement.
|
|
233
162
|
if (typeof answer === 'string' && answer.trim() && !args[0].includes(PLAN_DECISION_MARKER))
|
|
234
163
|
confirmedClarifications.push({ question: args[0], answer });
|
|
235
164
|
return answer;
|
|
@@ -241,12 +170,7 @@ export async function runGraph(graph, options) {
|
|
|
241
170
|
limits: { ...limits }, telemetry: createRunTelemetry(),
|
|
242
171
|
};
|
|
243
172
|
const todoStore = options.todoStore ?? new TodoStore();
|
|
244
|
-
// Widgets belong to the run, not to a branch: every node and every parallel copy updates the
|
|
245
|
-
// same values, exactly as they all keep the one plan.
|
|
246
173
|
const widgetStore = options.widgetStore ?? new WidgetStore(pinned.widgets);
|
|
247
|
-
// A resumed run's plan is seeded into the store where it is read, but announced only after
|
|
248
|
-
// `graph.started`: the browser activity sink clears its checklist on that event, so publishing
|
|
249
|
-
// earlier would have the resume erase the very plan it carried.
|
|
250
174
|
let seededPlan;
|
|
251
175
|
const artifactStore = options.artifactStore ?? new ArtifactStore(result.id);
|
|
252
176
|
options.codeIntel?.beginRun(result.id);
|
|
@@ -255,18 +179,11 @@ export async function runGraph(graph, options) {
|
|
|
255
179
|
options.commandMemory?.observe(event);
|
|
256
180
|
await options.onEvent?.(event);
|
|
257
181
|
};
|
|
258
|
-
// Skill activation is run-wide and independent of conversation reuse or provider identity.
|
|
259
|
-
// Journal replay restores it before any resumed frontier node starts.
|
|
260
182
|
const activeSkills = new Set(options.resumeFrom?.progress.activeSkills ?? []);
|
|
261
|
-
// A run-level skill the stopped attempt inherited is decided again by this caller: the user may have
|
|
262
|
-
// paused, removed or replaced the session's skill since the stop. Skills a node loaded stay restored.
|
|
263
183
|
for (const skillId of options.resumeFrom?.progress.runSkills ?? []) {
|
|
264
184
|
if (!(options.inheritedSkills ?? []).includes(skillId))
|
|
265
185
|
activeSkills.delete(skillId);
|
|
266
186
|
}
|
|
267
|
-
// A fresh run normally starts at the entry. A wake addressed to a node (an Auto-fix prompt goes to the node that
|
|
268
|
-
// switched Auto-fix on) starts at that node instead, when it is still an agent of this graph and can start with
|
|
269
|
-
// only what the run itself supplies: a node that needs its predecessor's handoff would fail its own input checks.
|
|
270
187
|
const startNode = (() => {
|
|
271
188
|
const requested = options.resumeFrom === undefined ? options.startNode : undefined;
|
|
272
189
|
const node = requested === undefined ? undefined : pinned.nodes[requested];
|
|
@@ -280,9 +197,6 @@ export async function runGraph(graph, options) {
|
|
|
280
197
|
return pinned.entry;
|
|
281
198
|
}
|
|
282
199
|
}
|
|
283
|
-
// A join that waits for every branch can complete only when each branch it waits for can run from here. A node
|
|
284
|
-
// on one branch of a fork reaches the join without its siblings, and the run would end at the join with the
|
|
285
|
-
// rest of the graph skipped; starting at the entry runs every branch, as before.
|
|
286
200
|
const reachable = new Set();
|
|
287
201
|
for (const frontier = [requested]; frontier.length > 0;) {
|
|
288
202
|
const nodeId = frontier.pop();
|
|
@@ -309,28 +223,11 @@ export async function runGraph(graph, options) {
|
|
|
309
223
|
let currentNode = startNode;
|
|
310
224
|
let lastCompletion;
|
|
311
225
|
if (options.resumeFrom) {
|
|
312
|
-
// Rehydrate the scheduler from the journal replay of a stopped attempt. The frontier is
|
|
313
|
-
// assembled first and only installed when the journal proved something worth continuing.
|
|
314
|
-
// Every frontier entry carries the mapped inputs and predecessors its activation had —
|
|
315
|
-
// replay proves those queued but unfinished, and re-entering one with empty inputs would
|
|
316
|
-
// fail the node's own schema checks for work its predecessor already paid for. A captured
|
|
317
|
-
// checkpoint re-enters its node's conversation too (the same continuation the pause/resume
|
|
318
|
-
// control uses), one per unfinished branch. With nothing proven, nothing is seeded at all —
|
|
319
|
-
// running the task from entry is the safe restart, and an empty seeded frontier would only
|
|
320
|
-
// trip `maxNodeVisits`.
|
|
321
226
|
const { progress, checkpoints: captured } = options.resumeFrom;
|
|
322
|
-
// Draw fresh generation numbers from where the stopped attempt left them: the executed set
|
|
323
|
-
// below is seeded with the journal's generation-keyed entries, so a resumed revisit must draw
|
|
324
|
-
// a number that has never run rather than reissue one the journal already used.
|
|
325
227
|
nextGeneration = Math.max(nextGeneration, progress.generation ?? 0);
|
|
326
228
|
const resumable = [];
|
|
327
|
-
// The seeded activation of every `(generation, node)` identity the frontier carried: a cycle can
|
|
328
|
-
// hold the same node at two generations, and a checkpoint, a predecessor handoff, or a second
|
|
329
|
-
// activation of that node must address the one its own visit belongs to.
|
|
330
229
|
const byIdentity = new Map();
|
|
331
230
|
const generationsPerNode = new Map();
|
|
332
|
-
// The seeded re-entry of each node — the one unfinished visit it can have — for the legacy
|
|
333
|
-
// checkpoint shape that carries no visit stamp to look itself up by.
|
|
334
231
|
const reentryByNode = new Map();
|
|
335
232
|
const seededByNode = new Map();
|
|
336
233
|
const reentry = new Set();
|
|
@@ -338,29 +235,12 @@ export async function runGraph(graph, options) {
|
|
|
338
235
|
for (const activation of progress.pending) {
|
|
339
236
|
const node = pinned.nodes[activation.nodeId];
|
|
340
237
|
if (!node) {
|
|
341
|
-
// The graph was edited between the stop and this resume. The activation cannot be seeded,
|
|
342
|
-
// and a frontier that vanishes silently would restart the whole task from the entry —
|
|
343
|
-
// rerunning nodes `progress.nodeResults` already proves completed (and their tool effects
|
|
344
|
-
// with them). Refuse below when nothing else is left to continue.
|
|
345
238
|
droppedNodes.add(activation.nodeId);
|
|
346
239
|
continue;
|
|
347
240
|
}
|
|
348
241
|
if (activation.interrupted && node.type === 'action') {
|
|
349
|
-
// The stopped attempt was inside the shell command when it died: the journal cannot show
|
|
350
|
-
// how far the command got, and re-running it could duplicate effects that already fully
|
|
351
|
-
// or partially applied. An action node is the one node type whose work the replay cannot
|
|
352
|
-
// safely put back on the executable frontier, so the whole resume is refused and the
|
|
353
|
-
// workspace stays as the crash left it, for a human to inspect and re-start fresh.
|
|
354
242
|
throw new Error(`Cannot resume into the "${node.name}" action: the stopped attempt died while its shell command was running, and replaying it could repeat its effects. Check what the command already changed, then start a new run.`);
|
|
355
243
|
}
|
|
356
|
-
// The replay carried the generation and path this activation had at the stop: seeding them
|
|
357
|
-
// is what lets a resumed cycle classify its outgoing back-edge as a revisit instead of an
|
|
358
|
-
// already-executed suppression, and lets a later-generation activation avoid colliding with
|
|
359
|
-
// the generation-zero executed set.
|
|
360
|
-
// The parallel-group identity rides along: a branch-mode source that dispatched these
|
|
361
|
-
// successors before dying had them on the prefetch path sharing its tool-budget slice, and
|
|
362
|
-
// seeding them groupless would run the first branch on the FULL remaining allowance and
|
|
363
|
-
// starve the rest of the group.
|
|
364
244
|
const seeded = { nodeId: activation.nodeId, generation: activation.generation ?? 0, path: activation.path ?? [], inputs: structuredClone(activation.inputs), ...(activation.source ? { source: structuredClone(activation.source) } : {}), ...(activation.sourceGeneration === undefined ? {} : { sourceGeneration: activation.sourceGeneration }), predecessors: structuredClone(activation.predecessors),
|
|
365
245
|
...(activation.parallelGroup === undefined ? {} : { parallelGroup: activation.parallelGroup, ...(activation.concurrency === undefined ? {} : { concurrency: activation.concurrency }) }) };
|
|
366
246
|
if (activation.interrupted) {
|
|
@@ -374,27 +254,10 @@ export async function runGraph(graph, options) {
|
|
|
374
254
|
generationsPerNode.set(seeded.nodeId, seen);
|
|
375
255
|
resumable.push(seeded);
|
|
376
256
|
}
|
|
377
|
-
// The frontier nodes the journal shows as unfinished re-entries, used below to tell a
|
|
378
|
-
// completed node apart from a node that completed an earlier visit and was interrupted during
|
|
379
|
-
// a later one.
|
|
380
257
|
const interruptedFrontier = new Set(progress.pending.filter(entry => entry.interrupted).map(entry => entry.nodeId));
|
|
381
258
|
for (const checkpoint of captured ?? []) {
|
|
382
|
-
// Parallel branches each checkpoint their own conversation, and each unfinished one gets
|
|
383
|
-
// it back. A checkpoint naming a node the current graph no longer has (the graph was
|
|
384
|
-
// edited since), or one whose node already completed, cannot re-enter anything — except a
|
|
385
|
-
// node that completed an earlier visit and was interrupted on a later one: the completion
|
|
386
|
-
// describes the earlier pass, while the checkpoint holds the unfinished revisit's own
|
|
387
|
-
// conversation, which is exactly what resume must not throw away.
|
|
388
259
|
if ((Object.hasOwn(progress.nodeResults, checkpoint.nodeId) && !interruptedFrontier.has(checkpoint.nodeId)) || !pinned.nodes[checkpoint.nodeId])
|
|
389
260
|
continue;
|
|
390
|
-
// The stamped visit is the only activation this conversation can continue, so the file is
|
|
391
|
-
// addressed by the identity it carries. A stamp naming a visit this resume did not seed
|
|
392
|
-
// belongs to a visit that already ended (or to a generation the node ran at before): attaching
|
|
393
|
-
// it to whatever activation the node happens to hold instead would continue a finished
|
|
394
|
-
// conversation as if it were the unfinished one, with counters that disagree with the graph
|
|
395
|
-
// being replayed. A file from before the stamp carries no visit identity at all, so it goes to
|
|
396
|
-
// the node's unfinished visit — the only conversation an unstamped file can belong to — and
|
|
397
|
-
// otherwise to the activation the node was seeded with.
|
|
398
261
|
const stamped = checkpoint.generation === undefined ? undefined : byIdentity.get(`${checkpoint.generation}:${checkpoint.nodeId}`);
|
|
399
262
|
if (checkpoint.generation !== undefined && stamped === undefined && generationsPerNode.has(checkpoint.nodeId))
|
|
400
263
|
continue;
|
|
@@ -403,22 +266,10 @@ export async function runGraph(graph, options) {
|
|
|
403
266
|
?? { nodeId: checkpoint.nodeId, generation: checkpoint.generation ?? 0, path: [], inputs: {}, predecessors: {} };
|
|
404
267
|
if (!continuableByThisRun(checkpoint.nodeId, checkpoint))
|
|
405
268
|
continue;
|
|
406
|
-
// A checkpoint older than the node's newest journaled effectful tool boundary does not cover
|
|
407
|
-
// that call: the resumed visit would re-enter the conversation from before it and can issue
|
|
408
|
-
// the same mutation again (the observation the tool produced is nowhere in the conversation).
|
|
409
|
-
// Effect-free calls — reads, run-scoped metadata, an unanswered ask_user — keep no boundary,
|
|
410
|
-
// so a crash between a checkpoint and one of those re-enters safely. The same reasoning that
|
|
411
|
-
// refuses an interrupted action node refuses this re-entry — the workspace is left as the
|
|
412
|
-
// crash left it for a human to inspect.
|
|
413
269
|
const toolEvent = progress.lastEffectfulToolEvent?.[checkpoint.nodeId];
|
|
414
270
|
if (toolEvent !== undefined && Date.parse(checkpoint.savedAt) < Date.parse(toolEvent)) {
|
|
415
271
|
throw new Error(`Cannot resume the "${pinned.nodes[checkpoint.nodeId]?.name ?? checkpoint.nodeId}" node: the stopped attempt ran a tool call after the conversation this checkpoint saved, so re-entering it could repeat an effect the checkpoint does not cover. Check what the call changed, then start a new run.`);
|
|
416
272
|
}
|
|
417
|
-
// A routed checkpoint re-enters its visit on the pair that wrote the conversation, so the
|
|
418
|
-
// restored transcript continues on the model that produced it. The pair is resolved here,
|
|
419
|
-
// before anything is seeded: an unresolvable target becomes a clean refusal instead of a
|
|
420
|
-
// mid-run failure after `run.started`, and dropping the checkpoint instead would restart
|
|
421
|
-
// the node fresh and repeat the mutations the conversation's transcript already observed.
|
|
422
273
|
const routed = routedContinuation(checkpoint.nodeId, checkpoint);
|
|
423
274
|
if (routed) {
|
|
424
275
|
const routedResolved = await (options.resolveModel
|
|
@@ -433,27 +284,16 @@ export async function runGraph(graph, options) {
|
|
|
433
284
|
}
|
|
434
285
|
seeded.continuation = { messages: checkpoint.messages, state: checkpoint.state, revision: checkpoint.revision };
|
|
435
286
|
if (!byIdentity.has(`${seeded.generation}:${seeded.nodeId}`)) {
|
|
436
|
-
// A checkpoint whose node never reached the journal (the process died before the start
|
|
437
|
-
// line appended) still owns the conversation: re-enter it ahead of the rest.
|
|
438
287
|
resumable.unshift(seeded);
|
|
439
288
|
byIdentity.set(`${seeded.generation}:${seeded.nodeId}`, seeded);
|
|
440
289
|
reentry.add(checkpoint.nodeId);
|
|
441
290
|
}
|
|
442
291
|
reentry.add(checkpoint.nodeId);
|
|
443
292
|
}
|
|
444
|
-
// Nothing left to continue although the journal proved queued work: the graph no longer carries
|
|
445
|
-
// the nodes that work named. Seeding nothing would run `queue`'s entry activation and redo
|
|
446
|
-
// every node already completed, so the resume is refused instead.
|
|
447
293
|
if (resumable.length === 0 && droppedNodes.size > 0) {
|
|
448
294
|
const missing = [...droppedNodes].map(nodeId => `"${nodeId}"`).join(', ');
|
|
449
295
|
throw new Error(`Cannot resume: the graph no longer contains the node${droppedNodes.size > 1 ? 's' : ''} ${missing} the stopped attempt still had queued. Restore the graph as it was, or start a new run.`);
|
|
450
296
|
}
|
|
451
|
-
// The live scheduler hands a routed successor the completing predecessor's model transcript
|
|
452
|
-
// (unless the predecessor asked for isolation), and a stop between the edge being journaled and
|
|
453
|
-
// the successor starting loses that handoff: the checkpoint loop above only re-attaches
|
|
454
|
-
// conversations to unfinished nodes, and a completed source's checkpoint would otherwise be
|
|
455
|
-
// discarded with it. Rebuild the handoff from the completed predecessor's durable checkpoint —
|
|
456
|
-
// its provider/model stamp is what the runtime's continue-in-place gate requires.
|
|
457
297
|
const checkpointsPerNode = new Map();
|
|
458
298
|
for (const checkpoint of captured ?? []) {
|
|
459
299
|
const list = checkpointsPerNode.get(checkpoint.nodeId) ?? [];
|
|
@@ -461,7 +301,9 @@ export async function runGraph(graph, options) {
|
|
|
461
301
|
checkpointsPerNode.set(checkpoint.nodeId, list);
|
|
462
302
|
}
|
|
463
303
|
for (const seeded of resumable) {
|
|
464
|
-
if (seeded.
|
|
304
|
+
if (seeded.conversation !== undefined)
|
|
305
|
+
continue;
|
|
306
|
+
if (seeded.continuation !== undefined && pinned.nodes[seeded.nodeId]?.modifiers?.loop === undefined)
|
|
465
307
|
continue;
|
|
466
308
|
if (pinned.nodes[seeded.nodeId]?.type !== 'agent')
|
|
467
309
|
continue;
|
|
@@ -469,13 +311,6 @@ export async function runGraph(graph, options) {
|
|
|
469
311
|
const sourceNode = pinned.nodes[sourceId];
|
|
470
312
|
if (!sourceNode || sourceNode.type !== 'agent' || sourceNode.contextPolicy?.conversation === 'isolate')
|
|
471
313
|
continue;
|
|
472
|
-
// ... and only when the file still holds the conversation of the visit that routed this
|
|
473
|
-
// activation. A cyclic source can complete again after routing it — its checkpoint file is
|
|
474
|
-
// replaced per visit and now carries that later transcript — and handing the later
|
|
475
|
-
// conversation to this successor would give it context that did not exist when its edge was
|
|
476
|
-
// routed. The generation stamp is what tells the visits apart, so a file stamped for another
|
|
477
|
-
// visit hands off nothing at all: the successor keeps the completion as its input and
|
|
478
|
-
// starts its own conversation.
|
|
479
314
|
const checkpoint = (checkpointsPerNode.get(sourceId) ?? []).find(candidate => (candidate.generation ?? 0) === (seeded.sourceGeneration ?? 0));
|
|
480
315
|
if (!checkpoint || typeof checkpoint.provider !== 'string' || typeof checkpoint.model !== 'string' || checkpoint.messages.length === 0)
|
|
481
316
|
continue;
|
|
@@ -483,10 +318,6 @@ export async function runGraph(graph, options) {
|
|
|
483
318
|
}
|
|
484
319
|
}
|
|
485
320
|
for (const waitingJoin of progress.waitingJoins ?? []) {
|
|
486
|
-
// Partial arrivals of an all-mode join go back into the scheduler's waiting state, not the
|
|
487
|
-
// queue: the join must not run on the completed branches alone while the branches that never
|
|
488
|
-
// completed still have their work to do. It fires when the resumed completions bring the
|
|
489
|
-
// arrival for every remaining member edge, exactly as an uninterrupted run would.
|
|
490
321
|
if (!pinned.nodes[waitingJoin.nodeId] || Object.hasOwn(progress.nodeResults, waitingJoin.nodeId))
|
|
491
322
|
continue;
|
|
492
323
|
const targetKey = `${waitingJoin.generation}:${waitingJoin.nodeId}`;
|
|
@@ -503,15 +334,6 @@ export async function runGraph(graph, options) {
|
|
|
503
334
|
pendingJoins.set(targetKey, held);
|
|
504
335
|
}
|
|
505
336
|
if (resumable.length === 0) {
|
|
506
|
-
// The journal can prove a whole finished graph whose final record never landed: every
|
|
507
|
-
// node completed, End among them, and no unfired arrival left to seed. Replaying nothing
|
|
508
|
-
// would restart from the entry node and re-run every completed mutation the journal
|
|
509
|
-
// already proved done. Re-enter End alone instead: its pass performs no work, the seeded
|
|
510
|
-
// completions stand, and the scheduler finalizes on the completion that routed into End.
|
|
511
|
-
// (A proven-done frontier with NO completed End never reaches here — the refusal above
|
|
512
|
-
// rejects that shape before any of the run's resources are opened.)
|
|
513
|
-
// A graph may hold several End nodes — pick the one the journal proves completed; the
|
|
514
|
-
// first End in object order may belong to a branch that never ran.
|
|
515
337
|
const endNode = Object.values(pinned.nodes).find(node => node.type === 'end' && progress.nodeResults[node.id])
|
|
516
338
|
?? Object.values(pinned.nodes).find(node => node.type === 'end');
|
|
517
339
|
const endResult = endNode ? progress.nodeResults[endNode.id] : undefined;
|
|
@@ -520,8 +342,6 @@ export async function runGraph(graph, options) {
|
|
|
520
342
|
result.nodeResults[nodeId] = structuredClone(completion);
|
|
521
343
|
for (const [nodeId, count] of Object.entries(progress.visits))
|
|
522
344
|
visits.set(nodeId, count);
|
|
523
|
-
// End's journaled visit belongs to the stopped attempt; entering it here completes that
|
|
524
|
-
// pass, it is not a second visit.
|
|
525
345
|
visits.set(endNode.id, 0);
|
|
526
346
|
if (progress.toolCalls !== undefined)
|
|
527
347
|
result.toolCalls = progress.toolCalls;
|
|
@@ -537,10 +357,6 @@ export async function runGraph(graph, options) {
|
|
|
537
357
|
queue.length = 0;
|
|
538
358
|
queue.push({ nodeId: endNode.id, generation: 0, path: [], inputs: {}, predecessors: {} });
|
|
539
359
|
currentNode = endNode.id;
|
|
540
|
-
// The seeded plan is seeded here too, exactly as the resumable path below does, and announced
|
|
541
|
-
// once `graph.started` has passed: a client builds its checklist from the event, and this
|
|
542
|
-
// attempt has nothing else to report — but a sink that clears its checklist on the start
|
|
543
|
-
// event would swallow a plan announced before it.
|
|
544
360
|
if (progress.todos?.length) {
|
|
545
361
|
todoStore.update(progress.todos);
|
|
546
362
|
seededPlan = todoStore.snapshot();
|
|
@@ -553,25 +369,13 @@ export async function runGraph(graph, options) {
|
|
|
553
369
|
for (const [nodeId, completion] of Object.entries(progress.nodeResults)) {
|
|
554
370
|
result.nodeResults[nodeId] = structuredClone(completion);
|
|
555
371
|
}
|
|
556
|
-
// Key the executed set the way the stopped attempt keyed it — every `(generation, node)` the
|
|
557
|
-
// journal proves, not only each node's latest generation: a cycle can complete one node at two
|
|
558
|
-
// generations while older-generation work is still queued, and seeding only the later key lets
|
|
559
|
-
// the delayed earlier-generation activation run again, repeating effects the stopped attempt
|
|
560
|
-
// already paid for. A caller that carries only the per-node map (an older reader, or a test
|
|
561
|
-
// fixture) keeps its last-generation keys.
|
|
562
372
|
const executedKeys = progress.executed ?? Object.keys(progress.nodeResults).map(nodeId => `${progress.generations?.[nodeId] ?? 0}:${nodeId}`);
|
|
563
373
|
for (const key of executedKeys)
|
|
564
374
|
executed.add(key);
|
|
565
375
|
for (const [nodeId, count] of Object.entries(progress.visits))
|
|
566
376
|
visits.set(nodeId, count);
|
|
567
|
-
// The stopped attempt's tool spend carries over: a run capped at N calls had spent some (or
|
|
568
|
-
// all) of the graph-level allowance before the crash, and the resumed scheduler must budget
|
|
569
|
-
// from what is left, not hand the allowance out again.
|
|
570
377
|
if (progress.toolCalls !== undefined)
|
|
571
378
|
result.toolCalls = progress.toolCalls;
|
|
572
|
-
// Re-entry completes the stopped attempt's unfinished pass rather than costing a new visit:
|
|
573
|
-
// the node that started there already spent the visit its journal recorded, so that spend
|
|
574
|
-
// is given back or the re-entry would trip `maxNodeVisits` before it could finish.
|
|
575
379
|
for (const nodeId of reentry) {
|
|
576
380
|
const spent = visits.get(nodeId) ?? 0;
|
|
577
381
|
if (spent > 0)
|
|
@@ -580,17 +384,9 @@ export async function runGraph(graph, options) {
|
|
|
580
384
|
queue.length = 0;
|
|
581
385
|
queue.push(...resumable);
|
|
582
386
|
currentNode = resumable[0].nodeId;
|
|
583
|
-
// A run resumed straight into End: an uninterrupted run finalizes on the completion of the
|
|
584
|
-
// node that routed into End, but nothing runs between the seed and End's own completion to
|
|
585
|
-
// set `lastCompletion`. Seed it from the routing source the replay carried.
|
|
586
387
|
const endSeed = resumable.find(item => pinned.nodes[item.nodeId]?.type === 'end' && item.source !== undefined);
|
|
587
388
|
if (endSeed?.source)
|
|
588
389
|
lastCompletion = structuredClone(endSeed.source);
|
|
589
|
-
// The stopped attempt's plan comes back with the position it was written for, and it is
|
|
590
|
-
// announced rather than only seeded: the runtime reads the snapshot out of the todo store on
|
|
591
|
-
// its own, but every client's checklist is built from the event, and a continuation that stayed
|
|
592
|
-
// silent until the model happened to update the plan would look like the plan was lost. The
|
|
593
|
-
// announcement waits for after `graph.started` — see `seededPlan`.
|
|
594
390
|
if (progress.todos?.length) {
|
|
595
391
|
todoStore.update(progress.todos);
|
|
596
392
|
seededPlan = todoStore.snapshot();
|
|
@@ -600,12 +396,11 @@ export async function runGraph(graph, options) {
|
|
|
600
396
|
}
|
|
601
397
|
}
|
|
602
398
|
const liveUsage = { inputTokens: 0, outputTokens: 0, requests: 0 };
|
|
603
|
-
// Per-node token accounting, kept separate from `liveUsage` (which is run-cumulative): the
|
|
604
|
-
// timeline's node chips show each node's own input/output tokens and decode-window throughput.
|
|
605
|
-
// A node that runs twice (a cycle) accumulates across visits, which is what the chip shows.
|
|
606
399
|
const nodeUsageTotals = new Map();
|
|
607
|
-
//
|
|
608
|
-
// that
|
|
400
|
+
// A node's total includes what its subagents spent, so a subagent's own figures are kept apart: usage
|
|
401
|
+
// arrives per model invocation, and the events that name both ids say which invocations are whose.
|
|
402
|
+
const invocationUsageTotals = new Map();
|
|
403
|
+
const subagentInvocations = new Map();
|
|
609
404
|
const addUsage = (target, delta) => {
|
|
610
405
|
target.inputTokens += delta.inputTokens;
|
|
611
406
|
target.outputTokens += delta.outputTokens;
|
|
@@ -619,13 +414,6 @@ export async function runGraph(graph, options) {
|
|
|
619
414
|
if (delta.decodeMs !== undefined)
|
|
620
415
|
target.decodeMs = (target.decodeMs ?? 0) + delta.decodeMs;
|
|
621
416
|
};
|
|
622
|
-
// The measured aggregation for the chips' aggregates only: the decode windows of a node's
|
|
623
|
-
// requests sum — the throughput divides the covered tokens by this total, so prefill and tool
|
|
624
|
-
// gaps never enter the figure — and the numerator records how many tokens those windows
|
|
625
|
-
// actually generated. Sparse like the cache splits: a request that measured no window covers
|
|
626
|
-
// nothing, and its tokens stay out of the numerator the way its time stays out of the
|
|
627
|
-
// denominator. The field never reaches the plain `Usage` of the run record — only the chips
|
|
628
|
-
// pair a numerator with a denominator, and only these two aggregates are read by the stamp.
|
|
629
417
|
const addMeasuredUsage = (target, delta) => {
|
|
630
418
|
addUsage(target, delta);
|
|
631
419
|
if (delta.decodeMs !== undefined)
|
|
@@ -633,8 +421,6 @@ export async function runGraph(graph, options) {
|
|
|
633
421
|
};
|
|
634
422
|
const prefetched = new Map();
|
|
635
423
|
const prefetchedStarted = new Set();
|
|
636
|
-
// Branches whose completion was already announced when their invocation returned: the queue's
|
|
637
|
-
// later pass must not announce them a second time.
|
|
638
424
|
const prefetchedCompleted = new Set();
|
|
639
425
|
const accounted = new Set();
|
|
640
426
|
const checkpoints = new Map();
|
|
@@ -645,8 +431,6 @@ export async function runGraph(graph, options) {
|
|
|
645
431
|
controlEvents = controlEvents.then(() => emit(paused ? 'graph.paused' : 'graph.resumed', { nodeId: currentNode }));
|
|
646
432
|
void controlEvents.catch(() => { });
|
|
647
433
|
});
|
|
648
|
-
// Read-only graph work can be retried after its interrupted request settles. Never
|
|
649
|
-
// use this helper for mutations or memory persistence, which may partially apply.
|
|
650
434
|
const readWhileRunning = async (operation) => {
|
|
651
435
|
for (;;) {
|
|
652
436
|
await context.runControl?.wait(signal);
|
|
@@ -687,26 +471,8 @@ export async function runGraph(graph, options) {
|
|
|
687
471
|
providers.set(provider, { ...resolved });
|
|
688
472
|
}
|
|
689
473
|
}
|
|
690
|
-
// A run that switched the session onto this graph hands the session's history to the first agent
|
|
691
|
-
// it starts — the entry node, or the first agent after an entry that is not one (an Action or an
|
|
692
|
-
// Approval cannot take model history) — whatever that agent's own history policy says. A resumed
|
|
693
|
-
// attempt in which an agent already completed is past that point and gets nothing more.
|
|
694
474
|
let entryHistoryPending = options.entryHistory === true
|
|
695
475
|
&& !Object.keys(result.nodeResults ?? {}).some(nodeId => pinned.nodes[nodeId]?.type === 'agent');
|
|
696
|
-
/**
|
|
697
|
-
* @param steerSource - the steering callback this invocation may poll, or undefined to
|
|
698
|
-
* run without steering. Steering is a single destructive queue, so handing the same
|
|
699
|
-
* callback to concurrent branches turns delivery into a race: whichever branch polls
|
|
700
|
-
* first consumes the message and the others never see it. Parallel groups therefore
|
|
701
|
-
* pass a wrapper that admits one branch at a time.
|
|
702
|
-
*
|
|
703
|
-
* Passed explicitly at every call site rather than defaulted: a default would apply
|
|
704
|
-
* when `undefined` is passed, so "no steering" would silently become "use the shared
|
|
705
|
-
* source" and every branch would race again.
|
|
706
|
-
*/
|
|
707
|
-
// A node reads the shared queue (when its branch owns it) and, beside it, whatever is meant for that node
|
|
708
|
-
// alone. Both sources are called before either is awaited: each removes what it hands over synchronously,
|
|
709
|
-
// and the poll races the answer against the abort signal, so nothing may sit taken but not yet returned.
|
|
710
476
|
const nodeSteering = options.getNodeSteeringMessages;
|
|
711
477
|
const withNodeSteering = (shared, nodeId) => nodeSteering === undefined ? shared : async (signal) => {
|
|
712
478
|
const common = shared?.(signal);
|
|
@@ -716,12 +482,7 @@ export async function runGraph(graph, options) {
|
|
|
716
482
|
const invoke = async (activation, maxToolCalls, wallTimeMs, concurrencyBudget, steerSource, continuation) => {
|
|
717
483
|
const nodeId = activation.nodeId;
|
|
718
484
|
const node = pinned.nodes[nodeId];
|
|
719
|
-
// A seeded activation carries its own continuation (the re-entered node's captured
|
|
720
|
-
// conversation); the explicit argument keeps the pause/resume control path unchanged.
|
|
721
485
|
continuation = continuation ?? activation.continuation;
|
|
722
|
-
// Only agent nodes are invoked, so the first invocation is the first agent the run starts, and
|
|
723
|
-
// it takes the seed. A visit that re-enters a saved conversation already holds whatever it was
|
|
724
|
-
// given; every later invocation, a loop back to the entry included, keeps its own policy.
|
|
725
486
|
const seedsEntryHistory = entryHistoryPending && !continuation;
|
|
726
487
|
entryHistoryPending = false;
|
|
727
488
|
const narrow = (run, remaining) => remaining === undefined ? run : run === undefined ? remaining : Math.min(run, remaining);
|
|
@@ -742,15 +503,9 @@ export async function runGraph(graph, options) {
|
|
|
742
503
|
const memoryEligible = !!runMemory && runMemory.automaticRetrieval && node.agentRole !== 'orchestrator';
|
|
743
504
|
const decisionManager = options.decisionNodeOptIn && node.jevEnabled !== true
|
|
744
505
|
? new DecisionManager({ config: { mode: 'off', provider: 'none' } }) : options.decisionManager;
|
|
745
|
-
// An empty workspace has no repository history to recall: under context selection the
|
|
746
|
-
// baseline retrieval is skipped on that fact alone, and the node learns the same facts.
|
|
747
|
-
// The facts are recollected per activation: an implementation node can create the very
|
|
748
|
-
// files a later node needs to retrieve, and a run-started snapshot would keep gating that
|
|
749
|
-
// retrieval on the empty workspace the run began in.
|
|
750
506
|
const facts = efficiency.contextSelection || efficiency.catalogSelection
|
|
751
507
|
? await collectWorkspaceFacts(context.workspace, { signal: context.signal }) : undefined;
|
|
752
508
|
const retrievalGated = efficiency.contextSelection && facts?.empty === true;
|
|
753
|
-
// Disabled preflight cannot replace baseline memory retrieval.
|
|
754
509
|
const baselineMemoryRetrieval = !decisionManager?.active || options.efficiency?.jevPreflight === false;
|
|
755
510
|
if (retrievalGated && baselineMemoryRetrieval && runMemory && node.agentRole !== 'orchestrator') {
|
|
756
511
|
await emit('efficiency.context.retrieval_skipped', { nodeId, reason: 'empty_workspace', source: 'memory' });
|
|
@@ -766,20 +521,13 @@ export async function runGraph(graph, options) {
|
|
|
766
521
|
...resolved, adapter: dashboardAdapter(resolved.adapter, provider, event => options.onEvent?.(event), { runId: result.id, nodeId, nodeName: node.name, nodeType: node.type }),
|
|
767
522
|
});
|
|
768
523
|
let completedConversation;
|
|
769
|
-
// A routed continuation runs on the pair its conversation was written with: the visit is
|
|
770
|
-
// pinned (its routing already served it), so re-deciding could move the model out from
|
|
771
|
-
// under the restored transcript mid-visit. Routing decides again on the visit's next
|
|
772
|
-
// fresh activation, exactly as it would for any new node entry. The override rides the
|
|
773
|
-
// node, so both executor paths resolve the routed pair through their normal machinery.
|
|
774
524
|
const routed = activation.routedModel ? { ...node, provider: activation.routedModel.provider, model: activation.routedModel.model } : node;
|
|
775
525
|
const routedNode = seedsEntryHistory ? { ...routed, contextPolicy: { ...routed.contextPolicy, history: true } } : routed;
|
|
776
|
-
const outcome = await (continuation && !continuation.state.copies ? executeAgentNode : executeModifiedAgent)(routedNode, {
|
|
526
|
+
const outcome = await (continuation && !continuation.state.copies && !routedNode.modifiers?.loop ? executeAgentNode : executeModifiedAgent)(routedNode, {
|
|
777
527
|
...options,
|
|
778
528
|
...(activation.routedModel ? { modelPinned: true } : {}),
|
|
779
529
|
adapter: instrument(options.provider, { model: options.model, adapter: options.adapter }).adapter,
|
|
780
530
|
...(options.resolveModel ? { resolveModel: async (provider, model, signal) => instrument(provider, await options.resolveModel(provider, model, signal)) } : {}),
|
|
781
|
-
// A live replacement enters through getLiveModel rather than resolveModel. Keep the
|
|
782
|
-
// same per-node request boundaries and duration events after the switch.
|
|
783
531
|
...(options.getLiveModel ? { getLiveModel: async (id, provider, model, signal) => {
|
|
784
532
|
const live = await options.getLiveModel(id, provider, model, signal);
|
|
785
533
|
return live ? { ...instrument(live.provider, live), provider: live.provider } : undefined;
|
|
@@ -795,30 +543,15 @@ export async function runGraph(graph, options) {
|
|
|
795
543
|
await emit('graph.skill.activated', { nodeId, skillId });
|
|
796
544
|
},
|
|
797
545
|
...(continuation ? { resumeMessages: continuation.messages, resumeState: continuation.state, resumeDirectionRevision: continuation.revision } : {}),
|
|
798
|
-
previousConversation: !continuation && node.contextPolicy?.conversation !== 'isolate' && node.contextPolicy?.skillInheritance !== 'none' ? activation.conversation : undefined,
|
|
546
|
+
previousConversation: (!continuation || node.modifiers?.loop !== undefined) && node.contextPolicy?.conversation !== 'isolate' && node.contextPolicy?.skillInheritance !== 'none' ? activation.conversation : undefined,
|
|
799
547
|
onConversationCheckpoint: async (messages, state, conversation) => {
|
|
800
548
|
if (context.runControl)
|
|
801
549
|
checkpoints.set(nodeId, { messages, state, revision: state.directionRevision });
|
|
802
550
|
completedConversation = conversation;
|
|
803
|
-
// Published per node so the caller can persist the run's furthest conversation: unlike the
|
|
804
|
-
// in-memory `checkpoints` map, which only fills while a pause control exists, durability
|
|
805
|
-
// has to hold for every run, including one that is killed with no control ever armed. The
|
|
806
|
-
// generation stamp tells a later resume which visit this conversation belongs to. The
|
|
807
|
-
// identity stamp names the model the handed-off conversation ran on: continuing a
|
|
808
|
-
// conversation requires the same provider and model, so a resume that restores this
|
|
809
|
-
// transcript to a pending successor must know what it was built against.
|
|
810
|
-
// The write is awaited: the checkpoint is the conversation a resume re-enters the node
|
|
811
|
-
// with, so a run that advanced past a mutating tool call while its checkpoint was still
|
|
812
|
-
// queued could be killed with that conversation unwritten — and the resume would re-enter
|
|
813
|
-
// the node from its opening task and repeat the work it had already done.
|
|
814
551
|
const identity = nodeIdentity(nodeId);
|
|
815
552
|
await options.onNodeCheckpoint?.(nodeId, messages, state, {
|
|
816
553
|
generation: activation.generation,
|
|
817
554
|
...(conversation ? { provider: conversation.provider, model: conversation.model } : {}),
|
|
818
|
-
// The baseline this run had configured for the node: a resume whose recomputed
|
|
819
|
-
// baseline still matches knows the conversation's own pair (if it differs) was this
|
|
820
|
-
// configuration's routing decision, and continues the visit on it instead of
|
|
821
|
-
// restarting the node from its opening task.
|
|
822
555
|
routedFrom: { provider: identity.provider, ...(identity.model === undefined ? {} : { model: identity.model }) },
|
|
823
556
|
});
|
|
824
557
|
await options.onConversationCheckpoint?.(messages, state, conversation);
|
|
@@ -842,21 +575,37 @@ export async function runGraph(graph, options) {
|
|
|
842
575
|
const total = nodeUsageTotals.get(nodeId) ?? { inputTokens: 0, outputTokens: 0, requests: 0 };
|
|
843
576
|
addMeasuredUsage(total, usage);
|
|
844
577
|
nodeUsageTotals.set(nodeId, total);
|
|
578
|
+
if (origin?.invocationId) {
|
|
579
|
+
const own = invocationUsageTotals.get(origin.invocationId) ?? { inputTokens: 0, outputTokens: 0, requests: 0 };
|
|
580
|
+
addMeasuredUsage(own, usage);
|
|
581
|
+
invocationUsageTotals.set(origin.invocationId, own);
|
|
582
|
+
}
|
|
845
583
|
options.onUsage?.(usage, origin);
|
|
846
584
|
},
|
|
847
585
|
onEvent: async (event) => {
|
|
848
|
-
// The agent's own events name the invocation but never the run; every graph event
|
|
849
|
-
// carries one. Seeding it here too is what lets the desktop key each node chip's
|
|
850
|
-
// figures by run, so a second task in the same session that reuses a node id
|
|
851
|
-
// cannot repaint the first task's chips with its spend.
|
|
852
586
|
event = { ...event, data: { runId: result.id, ...event.data, nodeName: node.name, nodeType: node.type } };
|
|
853
|
-
|
|
854
|
-
|
|
855
|
-
|
|
587
|
+
const { subagentId, invocationId } = event.data;
|
|
588
|
+
if (typeof subagentId === 'string' && subagentId && typeof invocationId === 'string' && invocationId) {
|
|
589
|
+
const own = subagentInvocations.get(subagentId) ?? new Set();
|
|
590
|
+
own.add(invocationId);
|
|
591
|
+
subagentInvocations.set(subagentId, own);
|
|
592
|
+
}
|
|
856
593
|
if (event.type === 'agent.model.completed') {
|
|
857
594
|
const { measuredOutputTokens: _chipsOnly, ...runUsage } = liveUsage;
|
|
858
595
|
event = { ...event, data: { ...event.data, graphUsage: runUsage,
|
|
859
596
|
nodeUsage: { ...(nodeUsageTotals.get(nodeId) ?? { inputTokens: 0, outputTokens: 0, requests: 0 }) } } };
|
|
597
|
+
if (typeof subagentId === 'string' && subagentId) {
|
|
598
|
+
const subagentUsage = { inputTokens: 0, outputTokens: 0, requests: 0 };
|
|
599
|
+
for (const id of subagentInvocations.get(subagentId) ?? []) {
|
|
600
|
+
const part = invocationUsageTotals.get(id);
|
|
601
|
+
if (part === undefined)
|
|
602
|
+
continue;
|
|
603
|
+
addUsage(subagentUsage, part);
|
|
604
|
+
if (part.measuredOutputTokens !== undefined)
|
|
605
|
+
subagentUsage.measuredOutputTokens = (subagentUsage.measuredOutputTokens ?? 0) + part.measuredOutputTokens;
|
|
606
|
+
}
|
|
607
|
+
event = { ...event, data: { ...event.data, subagentUsage } };
|
|
608
|
+
}
|
|
860
609
|
}
|
|
861
610
|
if (activation.parallelGroup && event.type === 'graph.todos.updated')
|
|
862
611
|
event = { ...event, type: 'agent.modifier.todos.updated' };
|
|
@@ -871,15 +620,8 @@ export async function runGraph(graph, options) {
|
|
|
871
620
|
return outcome;
|
|
872
621
|
};
|
|
873
622
|
await emit('graph.started', { graph: pinned });
|
|
874
|
-
// The resumed run's plan is published here, not at the seed: the browser activity sink clears its
|
|
875
|
-
// checklist on `graph.started`, so an earlier announcement would be erased by the event that
|
|
876
|
-
// announces the very run carrying it. The store already holds it, so nothing reading the store in
|
|
877
|
-
// between sees a gap — only the event stream had to wait for the reset.
|
|
878
623
|
if (seededPlan !== undefined)
|
|
879
624
|
await emit('graph.todos.updated', { todos: seededPlan });
|
|
880
|
-
// Widgets are announced on every run that defines them, resumed or not: the definitions
|
|
881
|
-
// themselves are part of what the user watches, so the panel appears with empty values the
|
|
882
|
-
// moment the run starts rather than waiting for the first update.
|
|
883
625
|
if (widgetStore.definitionsList().length)
|
|
884
626
|
await emit('graph.widgets.updated', { widgets: widgetStore.snapshot() });
|
|
885
627
|
if (options.memory) {
|
|
@@ -900,9 +642,6 @@ export async function runGraph(graph, options) {
|
|
|
900
642
|
if (queue[0].parallelGroup && !prefetched.has(queue[0])) {
|
|
901
643
|
const group = queue.filter(item => item.parallelGroup === queue[0].parallelGroup);
|
|
902
644
|
const maxToolCalls = shareToolBudget(limits.maxToolCalls, result.toolCalls, group.length);
|
|
903
|
-
// A zero share is a valid budget: a branch that needs no tool still returns a
|
|
904
|
-
// completion, and the runtime rejects any tool call it cannot afford. Only an
|
|
905
|
-
// already-exhausted allowance stops the group.
|
|
906
645
|
const remaining = remainingToolBudget(limits.maxToolCalls, result.toolCalls);
|
|
907
646
|
if (remaining !== undefined && remaining < 0) {
|
|
908
647
|
result.reason = 'maxToolCalls';
|
|
@@ -923,10 +662,6 @@ export async function runGraph(graph, options) {
|
|
|
923
662
|
if (node.inputSchema)
|
|
924
663
|
validateValue(node.inputSchema, item.inputs, `Node ${item.nodeId} inputs`);
|
|
925
664
|
}
|
|
926
|
-
// One branch at a time owns the queue, and ownership transfers as branches come and go.
|
|
927
|
-
// Pinning it to a fixed branch would starve every later branch of a serial group: with
|
|
928
|
-
// maxConcurrent 1 the first branch finishes and the next runs with steering disabled,
|
|
929
|
-
// so a steer submitted then would stay queued and could reach no one.
|
|
930
665
|
const activeBranches = [];
|
|
931
666
|
const steeringFor = (item) => {
|
|
932
667
|
const source = options.getSteeringMessages;
|
|
@@ -941,31 +676,14 @@ export async function runGraph(graph, options) {
|
|
|
941
676
|
await Promise.all(Array.from({ length: workers }, async () => {
|
|
942
677
|
while (index < group.length && !signal.aborted && !failures.length) {
|
|
943
678
|
const item = group[index++];
|
|
944
|
-
// Registered before the first await so leadership follows the deterministic
|
|
945
|
-
// start order rather than async scheduling.
|
|
946
679
|
activeBranches.push(item);
|
|
947
680
|
try {
|
|
948
681
|
await emit('graph.node.started', { nodeId: item.nodeId, visit: (visits.get(item.nodeId) ?? 0) + 1, generation: item.generation, path: [...item.path], ...startIdentity(item.nodeId, item.routedModel) });
|
|
949
682
|
prefetchedStarted.add(item);
|
|
950
|
-
// Agent executions count their own attempts in the agent runtime; every other node
|
|
951
|
-
// type executes only here, and the ADR counts attempts across all nodes.
|
|
952
683
|
if (pinned.nodes[item.nodeId]?.type !== 'agent')
|
|
953
684
|
recordAttempt(result.telemetry, (visits.get(item.nodeId) ?? 0) > 0);
|
|
954
685
|
const outcome = await invoke(item, maxToolCalls, budget.remainingMs(), concurrencyPerBranch, steeringFor(item));
|
|
955
686
|
prefetched.set(item, outcome);
|
|
956
|
-
// A branch that finished while a sibling still runs answers for itself now. Waiting
|
|
957
|
-
// for the whole Promise.all would report its completion only when the slowest sibling
|
|
958
|
-
// returned, leaving every surface that reads liveness off this event — the TUI's
|
|
959
|
-
// active set, the desktop rail, run progress — calling a done branch working for the
|
|
960
|
-
// sibling's full duration. The queue's later pass skips the second announcement. An
|
|
961
|
-
// outcome the sequential path would reject (unknown, or missing on an agent) is left
|
|
962
|
-
// unannounced so the failure still surfaces from the same place it does today, and a
|
|
963
|
-
// completion the queue's own output-schema validation will reject is left unannounced
|
|
964
|
-
// too (checked below): the event is persisted in the journal, and a replay would read
|
|
965
|
-
// a completion that validation refuses as authoritative, letting a resumed attempt
|
|
966
|
-
// skip the invalid branch entirely. Validating here keeps the journal honest; a
|
|
967
|
-
// violation falls through to the queue pass, which raises it at its deterministic
|
|
968
|
-
// point and never announces the completion either.
|
|
969
687
|
const branch = pinned.nodes[item.nodeId];
|
|
970
688
|
if (branch?.type === 'agent' && outcome.status === 'succeeded' && outcome.completion) {
|
|
971
689
|
const completion = outcome.completion;
|
|
@@ -1023,7 +741,6 @@ export async function runGraph(graph, options) {
|
|
|
1023
741
|
result.model = failed.model;
|
|
1024
742
|
result.status = failed.status;
|
|
1025
743
|
result.reason = failed.reason ?? failed.status;
|
|
1026
|
-
// Report the failing branch's effective bounds, which a node limit can tighten.
|
|
1027
744
|
if (failed.limits)
|
|
1028
745
|
result.limits = runClockBounds(failed.limits, result.reason, failedActivation.nodeId);
|
|
1029
746
|
break;
|
|
@@ -1038,13 +755,9 @@ export async function runGraph(graph, options) {
|
|
|
1038
755
|
break;
|
|
1039
756
|
}
|
|
1040
757
|
visits.set(nodeId, count);
|
|
1041
|
-
// See the parallel path: an agent counts its own attempts, and every other node type is
|
|
1042
|
-
// counted here so `attempts` reflects the run's real node executions.
|
|
1043
758
|
if (node.type !== 'agent')
|
|
1044
759
|
recordAttempt(result.telemetry, count > 1);
|
|
1045
760
|
executed.add(`${activation.generation}:${nodeId}`);
|
|
1046
|
-
// The remaining budget comes from the run's own clock, so time a node spent waiting on
|
|
1047
|
-
// the user is not charged to the nodes that follow it.
|
|
1048
761
|
const wallTimeMs = budget.remainingMs();
|
|
1049
762
|
if (wallTimeMs !== undefined && wallTimeMs <= 0) {
|
|
1050
763
|
result.reason = 'wallTimeMs';
|
|
@@ -1056,22 +769,14 @@ export async function runGraph(graph, options) {
|
|
|
1056
769
|
if (node.inputSchema)
|
|
1057
770
|
validateValue(node.inputSchema, activation.inputs, `Node ${nodeId} inputs`);
|
|
1058
771
|
let completion = { summary: node.name, tests: [], outcome: 'completed', output: {} };
|
|
1059
|
-
// The activation's generation and trail are journalled with the start line: they exist in
|
|
1060
|
-
// memory only, and a resume that re-enters this visit journals no routing for it, so a replay
|
|
1061
|
-
// has nothing else to reconstruct them from. A second crash would otherwise read the re-entry
|
|
1062
|
-
// as a generation-zero, ancestry-free activation — rejecting the checkpoint this visit wrote
|
|
1063
|
-
// and losing the revisit its outgoing back-edge owes.
|
|
1064
772
|
if (!prefetchedStarted.has(activation))
|
|
1065
773
|
await emit('graph.node.started', { nodeId, visit: count, generation: activation.generation, path: [...activation.path], ...startIdentity(nodeId, activation.routedModel) });
|
|
1066
774
|
if (node.type === 'agent') {
|
|
1067
775
|
const maxToolCalls = remainingToolBudget(limits.maxToolCalls, result.toolCalls);
|
|
1068
|
-
// Only an already-overspent allowance stops the node: a zero remainder is a valid
|
|
1069
|
-
// budget, since a node that needs no tool still returns a completion.
|
|
1070
776
|
if (!prefetched.has(activation) && maxToolCalls !== undefined && maxToolCalls < 0) {
|
|
1071
777
|
result.reason = 'maxToolCalls';
|
|
1072
778
|
break;
|
|
1073
779
|
}
|
|
1074
|
-
// A node outside a parallel group runs alone, so it polls the shared source directly.
|
|
1075
780
|
const outcome = prefetched.get(activation) ?? await invoke(activation, maxToolCalls, wallTimeMs, pinned.limits?.maxConcurrency ?? 32, options.getSteeringMessages);
|
|
1076
781
|
prefetched.delete(activation);
|
|
1077
782
|
result.provider = outcome.provider;
|
|
@@ -1079,17 +784,12 @@ export async function runGraph(graph, options) {
|
|
|
1079
784
|
if (!accounted.has(activation)) {
|
|
1080
785
|
result.toolCalls += outcome.toolCalls;
|
|
1081
786
|
addUsage(result.usage, outcome.usage);
|
|
1082
|
-
// A prefetched parallel outcome was merged, telemetry included, when its group settled;
|
|
1083
|
-
// absorbing it again would double the run's attempts, tokens and tool counts.
|
|
1084
787
|
absorbTelemetry(result, outcome);
|
|
1085
788
|
}
|
|
1086
789
|
if (outcome.status !== 'succeeded') {
|
|
1087
|
-
// Cancellation is judged from the session signal: the run signal may be fused with
|
|
1088
|
-
// this run's own clock, and a deadline must never be reported as a cancellation.
|
|
1089
790
|
const cancelled = (options.context.userSignal ?? options.context.signal).aborted;
|
|
1090
791
|
result.status = cancelled ? 'cancelled' : budget.expired() ? 'exhausted' : outcome.status;
|
|
1091
792
|
result.reason = cancelled ? 'cancelled' : budget.expired() ? 'wallTimeMs' : outcome.reason ?? outcome.status;
|
|
1092
|
-
// Report the node's effective bounds, which a node limit can tighten.
|
|
1093
793
|
if (outcome.limits)
|
|
1094
794
|
result.limits = runClockBounds(outcome.limits, result.reason, nodeId);
|
|
1095
795
|
break;
|
|
@@ -1118,8 +818,6 @@ export async function runGraph(graph, options) {
|
|
|
1118
818
|
}
|
|
1119
819
|
else if (node.type === 'approval') {
|
|
1120
820
|
await emit('approval.requested', { nodeId, name: node.name });
|
|
1121
|
-
// The approval prompt is a human wait, so it gets the session signal: the run's
|
|
1122
|
-
// wall clock must not answer for the user.
|
|
1123
821
|
let approved = false;
|
|
1124
822
|
for (;;) {
|
|
1125
823
|
await context.runControl?.wait(signal);
|
|
@@ -1143,7 +841,6 @@ export async function runGraph(graph, options) {
|
|
|
1143
841
|
await emit(approved ? 'approval.approved' : 'approval.denied', { nodeId, name: node.name });
|
|
1144
842
|
}
|
|
1145
843
|
else if (node.type === 'action') {
|
|
1146
|
-
// This node consumes one call below, so being already at the ceiling is a stop.
|
|
1147
844
|
if (!withinToolBudget(result.toolCalls + 1, limits.maxToolCalls)) {
|
|
1148
845
|
result.reason = 'maxToolCalls';
|
|
1149
846
|
break;
|
|
@@ -1153,8 +850,6 @@ export async function runGraph(graph, options) {
|
|
|
1153
850
|
if (!tool)
|
|
1154
851
|
throw new Error(`Action ${nodeId}: ${shellName} is unavailable under this node capability policy. Explicitly allow shell, filesystem and Git writes and the shell tool, or remove this action.`);
|
|
1155
852
|
result.toolCalls++;
|
|
1156
|
-
// The action path runs the shell outside the hardened runtime, so it records its own
|
|
1157
|
-
// capture entry: otherwise an action-only graph reports no tool call or per-tool row.
|
|
1158
853
|
if (result.telemetry)
|
|
1159
854
|
recordToolUse(result.telemetry, shellName, false);
|
|
1160
855
|
const toolCallId = randomUUID();
|
|
@@ -1163,9 +858,6 @@ export async function runGraph(graph, options) {
|
|
|
1163
858
|
let output;
|
|
1164
859
|
let durationMs;
|
|
1165
860
|
const startedAt = monotonicNow();
|
|
1166
|
-
// The shell's approval prompt is a human wait inside `execute`, and the action node has no
|
|
1167
|
-
// hardened-runtime wrapper to subtract it: measured here the same way, so the terminal
|
|
1168
|
-
// `durationMs` — and the ToolCallClock reading it accepts — never charge the deciding.
|
|
1169
861
|
let userWaitMs = 0;
|
|
1170
862
|
let waitSince;
|
|
1171
863
|
const closeUserWait = () => {
|
|
@@ -1176,6 +868,7 @@ export async function runGraph(graph, options) {
|
|
|
1176
868
|
return userWaitMs;
|
|
1177
869
|
};
|
|
1178
870
|
let interrupted = false;
|
|
871
|
+
let exitFailure = false;
|
|
1179
872
|
try {
|
|
1180
873
|
actionSignal.throwIfAborted();
|
|
1181
874
|
output = await tool.execute({ command: node.action.command }, { ...context, signal: actionSignal, userSignal: actionSignal, onApprovalEvent: (type, data) => {
|
|
@@ -1190,35 +883,42 @@ export async function runGraph(graph, options) {
|
|
|
1190
883
|
durationMs = workedMs === undefined ? undefined : Math.max(0, workedMs - waitedMs);
|
|
1191
884
|
}
|
|
1192
885
|
catch (error) {
|
|
1193
|
-
// A pause that aborts the approval mid-prompt leaves the open wait unbilled too.
|
|
1194
886
|
const workedMs = elapsedMs(startedAt);
|
|
1195
887
|
const waitedMs = closeUserWait();
|
|
1196
888
|
durationMs = workedMs === undefined ? undefined : Math.max(0, workedMs - waitedMs);
|
|
1197
|
-
|
|
889
|
+
// The command ran to the end and reported failure through its exit code. That is a result of the
|
|
890
|
+
// step, not a broken run: its output is shown as it is and the graph may route it.
|
|
891
|
+
const exit = error instanceof CommandExitError && !actionSignal.aborted ? error : undefined;
|
|
892
|
+
await emit('node.tool.failed', { nodeId, name: shellName, toolCallId, durationMs, output: exit ? exit.message : `Tool error: ${error instanceof Error ? error.message : String(error)}`, ...(exit ? { exitCode: exit.exitCode } : {}) });
|
|
1198
893
|
if (!actionSignal.aborted || signal.aborted) {
|
|
1199
|
-
// A real shell failure: the call was counted above, and this records the failure. A
|
|
1200
|
-
// suite that ran and failed is still test evidence, so it is recorded before the throw.
|
|
1201
894
|
if (result.telemetry) {
|
|
1202
895
|
recordToolFailure(result.telemetry, shellName);
|
|
1203
896
|
if (isTestCommandLine(node.action.command))
|
|
1204
897
|
recordTestCommand(result.telemetry);
|
|
1205
898
|
}
|
|
1206
|
-
|
|
899
|
+
if (!exit)
|
|
900
|
+
throw error;
|
|
901
|
+
completion.summary = `${node.name} failed: its command exited with code ${exit.exitCode}.`;
|
|
902
|
+
if (!pinned.edges.some(edge => edge.source === nodeId && edge.outcome === ACTION_FAILED_OUTCOME))
|
|
903
|
+
throw new Error(completion.summary);
|
|
904
|
+
exitFailure = true;
|
|
905
|
+
completion.outcome = ACTION_FAILED_OUTCOME;
|
|
906
|
+
output = exit.message;
|
|
907
|
+
}
|
|
908
|
+
else {
|
|
909
|
+
interrupted = true;
|
|
910
|
+
output = `Interrupted by user; effects may be partial. Not replayed. ${error instanceof Error ? error.message : String(error)}`;
|
|
911
|
+
completion.summary = `${node.name} was interrupted; its effects may be partial and were not replayed.`;
|
|
912
|
+
await context.runControl?.wait(signal);
|
|
1207
913
|
}
|
|
1208
|
-
interrupted = true;
|
|
1209
|
-
output = `Interrupted by user; effects may be partial. Not replayed. ${error instanceof Error ? error.message : String(error)}`;
|
|
1210
|
-
completion.summary = `${node.name} was interrupted; its effects may be partial and were not replayed.`;
|
|
1211
|
-
await context.runControl?.wait(signal);
|
|
1212
914
|
}
|
|
1213
915
|
finally {
|
|
1214
916
|
options.codeIntel?.notePotentialMutation(context.workspace, '(graph action shell)');
|
|
1215
917
|
}
|
|
1216
918
|
completion.output = { result: output };
|
|
1217
|
-
|
|
1218
|
-
// its name looks like a test command; the same rule the hardened runtime applies.
|
|
1219
|
-
if (!interrupted && result.telemetry && isTestCommandLine(node.action.command))
|
|
919
|
+
if (!interrupted && !exitFailure && result.telemetry && isTestCommandLine(node.action.command))
|
|
1220
920
|
recordTestCommand(result.telemetry);
|
|
1221
|
-
if (!interrupted)
|
|
921
|
+
if (!interrupted && !exitFailure)
|
|
1222
922
|
await emit('node.tool.completed', { nodeId, name: shellName, toolCallId, durationMs, output });
|
|
1223
923
|
}
|
|
1224
924
|
else if (node.type === 'parallel' || node.type === 'join')
|
|
@@ -1229,8 +929,6 @@ export async function runGraph(graph, options) {
|
|
|
1229
929
|
result.nodeResults[nodeId] = completion;
|
|
1230
930
|
if (node.type !== 'end')
|
|
1231
931
|
lastCompletion = completion;
|
|
1232
|
-
// A prefetched branch already announced its completion when its invocation returned; the
|
|
1233
|
-
// queue reaching it is bookkeeping, not a second completion.
|
|
1234
932
|
if (!prefetchedCompleted.has(activation))
|
|
1235
933
|
await emit('graph.node.completed', { nodeId, completion });
|
|
1236
934
|
const next = [];
|
|
@@ -1249,8 +947,6 @@ export async function runGraph(graph, options) {
|
|
|
1249
947
|
delete queued.conversation;
|
|
1250
948
|
if (executed.has(targetKey) || queued)
|
|
1251
949
|
continue;
|
|
1252
|
-
// An optional input whose source field was omitted stays absent (see resolveMapping): the
|
|
1253
|
-
// graph's validation accepted that mapping, so the target runs without it.
|
|
1254
950
|
const inputs = resolveMapping(edge.inputMapping, { source: completion, run: { input: runInput, state: runState, loop: { iteration: count } } }, target.inputSchema);
|
|
1255
951
|
const incoming = { ...(node.modifiers?.parallel?.mode === 'branches' ? { parallelGroup: `${nodeId}:${activation.generation}:${count}`, concurrency: node.modifiers.parallel.maxConcurrent } : {}), nodeId: edge.target, generation, path, inputs, source: completion, predecessors: { [nodeId]: completion } };
|
|
1256
952
|
if (node.type === 'agent' && target.type === 'agent' && node.contextPolicy?.conversation !== 'isolate')
|
|
@@ -1263,10 +959,6 @@ export async function runGraph(graph, options) {
|
|
|
1263
959
|
if (!dependencies.every(index => pending.has(index)))
|
|
1264
960
|
continue;
|
|
1265
961
|
const members = [...pending.values()];
|
|
1266
|
-
// Journal every branch's own activation, not one event for whichever branch completed
|
|
1267
|
-
// last: recovery rebuilds a queued join from the journal, and a single final event would
|
|
1268
|
-
// replay the join holding only the last branch's result — the merged inputs and
|
|
1269
|
-
// predecessors the in-memory activation carried would exist nowhere a resume can read.
|
|
1270
962
|
for (const member of members) {
|
|
1271
963
|
const memberSource = Object.keys(member.predecessors)[0];
|
|
1272
964
|
await emit('graph.edge.activated', { source: memberSource, target: edge.target, outcome: member.predecessors[memberSource].outcome });
|
|
@@ -1305,8 +997,6 @@ export async function runGraph(graph, options) {
|
|
|
1305
997
|
finalizationRevision = context.runControl.revision;
|
|
1306
998
|
const checkpoint = lastAgentActivation && checkpoints.get(lastAgentActivation.nodeId);
|
|
1307
999
|
if (lastAgentActivation && checkpoint) {
|
|
1308
|
-
// Routing is complete. Resume the last node's checkpointed conversation
|
|
1309
|
-
// (or each indexed copy) without replaying completed graph actions.
|
|
1310
1000
|
await emit('graph.finalization.resumed', { nodeId: lastAgentActivation.nodeId });
|
|
1311
1001
|
const continuation = await invoke(lastAgentActivation, remainingToolBudget(limits.maxToolCalls, result.toolCalls), budget.remainingMs(), pinned.limits?.maxConcurrency ?? 32, options.getSteeringMessages, checkpoint);
|
|
1312
1002
|
result.toolCalls += continuation.toolCalls;
|
|
@@ -1328,13 +1018,9 @@ export async function runGraph(graph, options) {
|
|
|
1328
1018
|
finalizationRevision = checkpoints.get(lastAgentActivation.nodeId)?.revision ?? finalizationRevision;
|
|
1329
1019
|
}
|
|
1330
1020
|
else {
|
|
1331
|
-
// Fixed graphs have no model conversation that could act on new prose.
|
|
1332
|
-
// Acknowledge explicitly rather than silently discarding accepted input.
|
|
1333
1021
|
await emit('agent.message', { text: `Direction received after fixed graph actions finished: ${directions.join('\n')}\nThis graph has no resumable agent; completed actions were not replayed.` });
|
|
1334
1022
|
}
|
|
1335
1023
|
}
|
|
1336
|
-
// Memory distillation no longer gates on token headroom: the cumulative ceiling
|
|
1337
|
-
// was removed, and distillation is bounded by its own adapter request instead.
|
|
1338
1024
|
if (options.memory?.activeFor(result.id)) {
|
|
1339
1025
|
const nodeOutputs = Object.fromEntries(Object.entries(result.nodeResults ?? {}).map(([id, item]) => [id, item.output]));
|
|
1340
1026
|
const orchestratorOutputs = Object.entries(pinned.nodes).filter(([, node]) => node.agentRole === 'orchestrator').map(([id]) => result.nodeResults?.[id]?.output);
|
|
@@ -1359,23 +1045,13 @@ export async function runGraph(graph, options) {
|
|
|
1359
1045
|
await emit('memory.error', { operation: 'distill-model-resolution', detail: error instanceof Error ? error.message : 'model resolution failed' });
|
|
1360
1046
|
}
|
|
1361
1047
|
}
|
|
1362
|
-
// A resumed direction invalidates the old completion before any new
|
|
1363
|
-
// persistence attempt, including pauses during model metadata resolution.
|
|
1364
1048
|
if (context.runControl && context.runControl.revision > finalizationRevision)
|
|
1365
1049
|
continue;
|
|
1366
|
-
// Capture the operation generation before starting graph-owned finalization.
|
|
1367
|
-
// MemoryManager may swallow abort and return partial persisted IDs, so the
|
|
1368
|
-
// checkpoint below is mandatory even when distillation resolves successfully.
|
|
1369
1050
|
const distillSignal = context.runControl ? AbortSignal.any([signal, context.runControl.signal]) : signal;
|
|
1370
1051
|
try {
|
|
1371
1052
|
await options.memory.distillRun({
|
|
1372
1053
|
task: options.task, status: result.status, outcome: result.completion?.outcome,
|
|
1373
1054
|
completionSummary, tests, nodeOutputs, orchestratorOutputs, confirmedClarifications,
|
|
1374
|
-
// The distillation is a billed model request like any node's, so it goes through the
|
|
1375
|
-
// same instrumented generation path: without that it reported its tokens in the run
|
|
1376
|
-
// totals while contributing no model tuple, and a run whose only model call was the
|
|
1377
|
-
// distillation published no model at all. Its own `onUsage` is therefore not supplied
|
|
1378
|
-
// here — `generateWithUsage` is the single accounting path for this request.
|
|
1379
1055
|
adapter: distillAdapter ? dashboardAdapter({
|
|
1380
1056
|
generate: request => generateWithUsage({
|
|
1381
1057
|
...options,
|
|
@@ -1384,8 +1060,6 @@ export async function runGraph(graph, options) {
|
|
|
1384
1060
|
...(distillProviderType === undefined ? {} : { providerType: distillProviderType }),
|
|
1385
1061
|
...(distillBaseUrl === undefined ? {} : { baseUrl: distillBaseUrl }),
|
|
1386
1062
|
},
|
|
1387
|
-
// `generateWithUsage` has already added this delta to `result.usage`; adding it
|
|
1388
|
-
// again here would double the run totals against the tuple and the provider.
|
|
1389
1063
|
onUsage: (usage, origin) => options.onUsage?.(usage, origin),
|
|
1390
1064
|
}, result, request),
|
|
1391
1065
|
}, result.provider, event => options.onEvent?.(event), { runId: result.id, operation: 'memory.distillation' }) : undefined,
|
|
@@ -1409,22 +1083,15 @@ export async function runGraph(graph, options) {
|
|
|
1409
1083
|
}
|
|
1410
1084
|
}
|
|
1411
1085
|
catch (error) {
|
|
1412
|
-
// Cancellation is judged from the session signal; every other abort that reached the run
|
|
1413
|
-
// signal is a deadline.
|
|
1414
1086
|
const cancelled = (options.context.userSignal ?? options.context.signal).aborted;
|
|
1415
1087
|
const deadline = budget.expired() || signal.aborted;
|
|
1416
1088
|
result.status = cancelled ? 'cancelled' : deadline ? 'exhausted' : 'infrastructure_error';
|
|
1417
1089
|
result.reason = cancelled ? 'cancelled' : deadline ? 'wallTimeMs' : error instanceof Error ? error.message : 'Graph runtime failure';
|
|
1418
1090
|
}
|
|
1419
|
-
// Cleanup must be unconditional: both the stop event and the Code Intelligence handoff await
|
|
1420
|
-
// sinks that can reject, and a rejection would otherwise skip disposal and leave the run's
|
|
1421
|
-
// timer retained until its original deadline.
|
|
1422
1091
|
try {
|
|
1423
1092
|
await options.commandMemory?.flush(options.context.userSignal ?? options.context.signal);
|
|
1424
1093
|
if (result.status !== 'succeeded') {
|
|
1425
1094
|
delete result.completion;
|
|
1426
|
-
// The event carries the raw code for a machine and the finished sentence for a person, so a
|
|
1427
|
-
// client that reads only the journal shows the same words as the command line.
|
|
1428
1095
|
await emit('graph.stopped', { nodeId: currentNode, status: result.status, reason: result.reason, reasonText: stopReasonSentence(result.reason, result.limits), usage: { ...result.usage }, toolCalls: result.toolCalls });
|
|
1429
1096
|
}
|
|
1430
1097
|
result.todos = todoStore.snapshot();
|