@andorra-labs/code 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +8 -2
- package/THIRD_PARTY_NOTICES.md +15 -0
- package/dist/src/account-presentation.d.ts +1 -37
- package/dist/src/account-presentation.js +2 -42
- package/dist/src/activity.d.ts +0 -25
- package/dist/src/activity.js +1 -23
- package/dist/src/agent-definitions.d.ts +0 -26
- package/dist/src/agent-definitions.js +0 -43
- package/dist/src/agent-execution.d.ts +0 -2
- package/dist/src/agent-execution.js +59 -414
- package/dist/src/agent-mcp-catalog.d.ts +0 -8
- package/dist/src/agent-mcp-catalog.js +0 -2
- package/dist/src/agent-mcp.d.ts +0 -56
- package/dist/src/agent-mcp.js +14 -153
- package/dist/src/agent-modifiers.d.ts +0 -1
- package/dist/src/agent-modifiers.js +25 -68
- package/dist/src/analytics.d.ts +0 -66
- package/dist/src/analytics.js +0 -45
- package/dist/src/anthropic-console-auth.d.ts +0 -24
- package/dist/src/anthropic-console-auth.js +0 -37
- package/dist/src/anthropic-credentials.d.ts +0 -25
- package/dist/src/anthropic-credentials.js +0 -28
- package/dist/src/app-server/protocol.d.ts +19 -244
- package/dist/src/app-server/protocol.js +1 -132
- package/dist/src/app-server/reasoning.d.ts +0 -31
- package/dist/src/app-server/reasoning.js +0 -54
- package/dist/src/app-server/terminal.d.ts +0 -36
- package/dist/src/app-server/terminal.js +3 -39
- package/dist/src/app-server/workspace.d.ts +0 -167
- package/dist/src/app-server/workspace.js +4 -406
- package/dist/src/app-server.d.ts +33 -918
- package/dist/src/app-server.js +608 -2984
- package/dist/src/artifacts.d.ts +0 -10
- package/dist/src/artifacts.js +1 -11
- package/dist/src/attachments.d.ts +4 -98
- package/dist/src/attachments.js +10 -130
- package/dist/src/auth/AuthManager.d.ts +0 -93
- package/dist/src/auth/AuthManager.js +3 -165
- package/dist/src/auth/callback-page.d.ts +0 -1
- package/dist/src/auth/callback-page.js +0 -4
- package/dist/src/auth/callback.d.ts +0 -25
- package/dist/src/auth/callback.js +1 -29
- package/dist/src/auth/deployment.d.ts +0 -16
- package/dist/src/auth/deployment.js +0 -16
- package/dist/src/auth/index.d.ts +0 -11
- package/dist/src/auth/index.js +0 -11
- package/dist/src/auth/lock.d.ts +0 -1
- package/dist/src/auth/lock.js +0 -1
- package/dist/src/auth/store.d.ts +7 -108
- package/dist/src/auth/store.js +21 -129
- package/dist/src/auth/types.d.ts +0 -8
- package/dist/src/auth-commands.d.ts +0 -5
- package/dist/src/auth-commands.js +0 -1
- package/dist/src/automation-runner.d.ts +0 -9
- package/dist/src/automation-runner.js +0 -11
- package/dist/src/automation-service.d.ts +0 -10
- package/dist/src/automation-service.js +3 -17
- package/dist/src/automation-tool.js +0 -5
- package/dist/src/automation-worker-shutdown.d.ts +0 -1
- package/dist/src/automation-worker-shutdown.js +0 -3
- package/dist/src/automations.d.ts +23 -2
- package/dist/src/automations.js +91 -12
- package/dist/src/background-tasks.d.ts +0 -23
- package/dist/src/background-tasks.js +0 -11
- package/dist/src/boot-trace.d.ts +0 -13
- package/dist/src/boot-trace.js +1 -14
- package/dist/src/browser-activity.js +0 -2
- package/dist/src/browser-bridge.d.ts +0 -2
- package/dist/src/browser-bridge.js +0 -27
- package/dist/src/browser-captcha-tool.d.ts +0 -13
- package/dist/src/browser-captcha-tool.js +3 -35
- package/dist/src/browser-extensions-tool.d.ts +24 -0
- package/dist/src/browser-extensions-tool.js +137 -0
- package/dist/src/browser-extensions.d.ts +127 -0
- package/dist/src/browser-extensions.js +729 -0
- package/dist/src/browser-observation.d.ts +0 -15
- package/dist/src/browser-observation.js +1 -22
- package/dist/src/browser-panel-tool.d.ts +10 -25
- package/dist/src/browser-panel-tool.js +64 -60
- package/dist/src/browser-runner.d.ts +0 -1
- package/dist/src/browser-runner.js +7 -46
- package/dist/src/browser-server.d.ts +0 -6
- package/dist/src/browser-server.js +6 -229
- package/dist/src/browser-session.d.ts +0 -25
- package/dist/src/browser-session.js +1 -71
- package/dist/src/browser-stealth.d.ts +0 -12
- package/dist/src/browser-stealth.js +0 -36
- package/dist/src/browser-ui/app.js +7 -174
- package/dist/src/browser-ui/style.css +0 -68
- package/dist/src/browser-ui/tokens.css +11 -93
- package/dist/src/browser-view.d.ts +52 -290
- package/dist/src/browser-view.js +354 -567
- package/dist/src/capabilities.d.ts +0 -8
- package/dist/src/capabilities.js +0 -29
- package/dist/src/capsolver.d.ts +0 -13
- package/dist/src/capsolver.js +0 -15
- package/dist/src/clarification-ui.d.ts +0 -7
- package/dist/src/clarification-ui.js +0 -8
- package/dist/src/claude-executable.d.ts +0 -1
- package/dist/src/claude-executable.js +1 -2
- package/dist/src/claude-provider.d.ts +6 -19
- package/dist/src/claude-provider.js +166 -61
- package/dist/src/cli-executable.d.ts +0 -16
- package/dist/src/cli-executable.js +0 -7
- package/dist/src/cli-process.d.ts +0 -26
- package/dist/src/cli-process.js +0 -18
- package/dist/src/cli-sign-in.d.ts +0 -20
- package/dist/src/cli-sign-in.js +1 -17
- package/dist/src/cli.d.ts +3 -56
- package/dist/src/cli.js +193 -702
- package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +4 -59
- package/dist/src/code-intelligence/CodeIntelligenceManager.js +27 -100
- package/dist/src/code-intelligence/ContextLedger.d.ts +0 -4
- package/dist/src/code-intelligence/ContextLedger.js +0 -10
- package/dist/src/code-intelligence/ContextRouter.d.ts +0 -6
- package/dist/src/code-intelligence/ContextRouter.js +0 -8
- package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.d.ts +0 -2
- package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.js +5 -12
- package/dist/src/code-intelligence/codegraph/CodeGraphProvider.d.ts +0 -6
- package/dist/src/code-intelligence/codegraph/CodeGraphProvider.js +0 -6
- package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.d.ts +0 -5
- package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.js +1 -17
- package/dist/src/code-intelligence/codegraph/repoExploreTool.d.ts +0 -5
- package/dist/src/code-intelligence/codegraph/repoExploreTool.js +0 -5
- package/dist/src/code-intelligence/repository.d.ts +0 -9
- package/dist/src/code-intelligence/repository.js +1 -11
- package/dist/src/code-intelligence/types.d.ts +0 -8
- package/dist/src/codex-auth.d.ts +0 -44
- package/dist/src/codex-auth.js +0 -45
- package/dist/src/codex-browser-auth.d.ts +0 -13
- package/dist/src/codex-browser-auth.js +3 -20
- package/dist/src/codex-errors.js +0 -2
- package/dist/src/codex-executable.d.ts +0 -2
- package/dist/src/codex-executable.js +1 -7
- package/dist/src/codex-provider.d.ts +0 -13
- package/dist/src/codex-provider.js +1 -26
- package/dist/src/codex-rpc.d.ts +0 -10
- package/dist/src/codex-rpc.js +0 -12
- package/dist/src/coding-tools.d.ts +6 -27
- package/dist/src/coding-tools.js +193 -205
- package/dist/src/command-metrics.d.ts +0 -4
- package/dist/src/command-output-tap.d.ts +0 -11
- package/dist/src/command-output-tap.js +0 -3
- package/dist/src/command-screens.d.ts +24 -0
- package/dist/src/command-screens.js +132 -100
- package/dist/src/commands.d.ts +6 -63
- package/dist/src/commands.js +20 -100
- package/dist/src/completion-gates.d.ts +0 -47
- package/dist/src/completion-gates.js +0 -14
- package/dist/src/completion.d.ts +2 -58
- package/dist/src/completion.js +90 -186
- package/dist/src/config.d.ts +12 -116
- package/dist/src/config.js +41 -171
- package/dist/src/context-budget.d.ts +0 -22
- package/dist/src/context-budget.js +0 -44
- package/dist/src/context-compaction.d.ts +29 -6
- package/dist/src/context-compaction.js +94 -25
- package/dist/src/context-selection.d.ts +0 -24
- package/dist/src/context-selection.js +0 -34
- package/dist/src/dashboard-view.d.ts +0 -2
- package/dist/src/dashboard-view.js +0 -35
- package/dist/src/dashboard.d.ts +0 -2
- package/dist/src/dashboard.js +0 -9
- package/dist/src/deadline.d.ts +0 -45
- package/dist/src/deadline.js +0 -54
- package/dist/src/decision/ContinuationAdapter.d.ts +0 -5
- package/dist/src/decision/ContinuationAdapter.js +0 -5
- package/dist/src/decision/DecisionEngine.d.ts +0 -4
- package/dist/src/decision/DecisionManager.d.ts +0 -1
- package/dist/src/decision/DecisionManager.js +2 -7
- package/dist/src/decision/DecisionPolicy.d.ts +0 -1
- package/dist/src/decision/DecisionPolicy.js +0 -1
- package/dist/src/decision/FactContinuations.d.ts +11 -43
- package/dist/src/decision/FactContinuations.js +126 -95
- package/dist/src/decision/FactServiceGate.d.ts +0 -1
- package/dist/src/decision/FactServiceGate.js +0 -4
- package/dist/src/decision/PreparedSteps.d.ts +0 -15
- package/dist/src/decision/PreparedSteps.js +1 -11
- package/dist/src/decision/applyToolMenu.d.ts +0 -1
- package/dist/src/decision/applyToolMenu.js +1 -5
- package/dist/src/decision/checks.d.ts +15 -28
- package/dist/src/decision/checks.js +118 -49
- package/dist/src/decision/facts.d.ts +0 -16
- package/dist/src/decision/facts.js +0 -30
- package/dist/src/decision/guidancePolicy.js +0 -1
- package/dist/src/decision/hostedPolicy.d.ts +0 -6
- package/dist/src/decision/hostedPolicy.js +0 -7
- package/dist/src/decision/hostedSkills.d.ts +0 -19
- package/dist/src/decision/hostedSkills.js +0 -19
- package/dist/src/decision/optimizationPolicy.d.ts +0 -3
- package/dist/src/decision/optimizationPolicy.js +1 -4
- package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +0 -7
- package/dist/src/decision/providers/AndorraDecisionProvider.js +4 -27
- package/dist/src/decision/providers/HttpDecisionProvider.d.ts +0 -2
- package/dist/src/decision/providers/HttpDecisionProvider.js +0 -6
- package/dist/src/decision/routeTools.d.ts +0 -8
- package/dist/src/decision/routeTools.js +1 -8
- package/dist/src/decision/toolFamilies.d.ts +0 -1
- package/dist/src/decision/toolFamilies.js +0 -1
- package/dist/src/decision/toolMenu.d.ts +0 -3
- package/dist/src/decision/toolMenu.js +0 -4
- package/dist/src/decision/types.d.ts +0 -6
- package/dist/src/default-graph.d.ts +0 -9
- package/dist/src/default-graph.js +0 -9
- package/dist/src/delegation-changes.d.ts +0 -56
- package/dist/src/delegation-changes.js +15 -124
- package/dist/src/diff-preview.d.ts +1 -1
- package/dist/src/diff-preview.js +4 -12
- package/dist/src/duration.d.ts +0 -50
- package/dist/src/duration.js +0 -50
- package/dist/src/efficiency.d.ts +0 -39
- package/dist/src/efficiency.js +0 -16
- package/dist/src/engine/protocol.d.ts +0 -2
- package/dist/src/engine/protocol.js +0 -2
- package/dist/src/engine-streams.d.ts +13 -0
- package/dist/src/engine-streams.js +16 -0
- package/dist/src/extensions.d.ts +3 -2
- package/dist/src/extensions.js +76 -37
- package/dist/src/favicons.d.ts +0 -26
- package/dist/src/favicons.js +0 -34
- package/dist/src/file-diff.d.ts +2 -58
- package/dist/src/file-diff.js +0 -32
- package/dist/src/file-read-key.d.ts +1 -0
- package/dist/src/file-read-key.js +5 -0
- package/dist/src/file-read-state.d.ts +0 -1
- package/dist/src/file-read-state.js +0 -4
- package/dist/src/firefox-cookies.d.ts +0 -34
- package/dist/src/firefox-cookies.js +1 -55
- package/dist/src/git-identity-audit.d.ts +27 -0
- package/dist/src/git-identity-audit.js +286 -0
- package/dist/src/git-identity-guard.d.ts +4 -0
- package/dist/src/git-identity-guard.js +998 -0
- package/dist/src/git-identity-hold.d.ts +12 -0
- package/dist/src/git-identity-hold.js +81 -0
- package/dist/src/git-summary.d.ts +0 -58
- package/dist/src/git-summary.js +2 -212
- package/dist/src/goal-completion-verification.d.ts +2 -2
- package/dist/src/goal-completion-verification.js +3 -6
- package/dist/src/graph-account.d.ts +0 -21
- package/dist/src/graph-account.js +0 -17
- package/dist/src/graph-editor-session.d.ts +0 -1
- package/dist/src/graph-editor-session.js +1 -3
- package/dist/src/graph-health.d.ts +7 -49
- package/dist/src/graph-health.js +35 -46
- package/dist/src/graph-manager-chat.d.ts +27 -128
- package/dist/src/graph-manager-chat.js +36 -166
- package/dist/src/graph-provider-portability.d.ts +1 -21
- package/dist/src/graph-provider-portability.js +6 -45
- package/dist/src/graph-quota.d.ts +0 -33
- package/dist/src/graph-quota.js +1 -44
- package/dist/src/graph-runner.d.ts +0 -1
- package/dist/src/graph-runner.js +47 -387
- package/dist/src/graph-selection.d.ts +0 -14
- package/dist/src/graph-selection.js +0 -14
- package/dist/src/graph-server.d.ts +3 -11
- package/dist/src/graph-server.js +70 -111
- package/dist/src/graph-studio-features.d.ts +0 -5
- package/dist/src/graph-studio-features.js +2 -42
- package/dist/src/graph-sync.d.ts +0 -78
- package/dist/src/graph-sync.js +5 -201
- package/dist/src/graph-tool.d.ts +0 -18
- package/dist/src/graph-tool.js +0 -27
- package/dist/src/graph-ui/app.js +229 -498
- package/dist/src/graph-ui/compat.js +0 -7
- package/dist/src/graph-ui/controls.css +47 -43
- package/dist/src/graph-ui/controls.js +0 -88
- package/dist/src/graph-ui/drafts.js +0 -12
- package/dist/src/graph-ui/edge-router.js +0 -62
- package/dist/src/graph-ui/embed.js +0 -59
- package/dist/src/graph-ui/icons.js +2 -7
- package/dist/src/graph-ui/index.html +2 -2
- package/dist/src/graph-ui/library.css +0 -5
- package/dist/src/graph-ui/manager-markdown.js +0 -11
- package/dist/src/graph-ui/manager-state.js +110 -49
- package/dist/src/graph-ui/manager.css +2 -20
- package/dist/src/graph-ui/manager.js +251 -166
- package/dist/src/graph-ui/model-picker.js +250 -0
- package/dist/src/graph-ui/provider-glyphs/alibaba-cloud.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/anthropic.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/aws-bedrock.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/claude.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/deepseek.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/fireworks.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/kimi.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/minimax.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/openai.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/opencode.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/openrouter.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/xai.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/xiaomi-mimo.png +0 -0
- package/dist/src/graph-ui/provider-glyphs/zai.png +0 -0
- package/dist/src/graph-ui/sidebar.js +2 -3
- package/dist/src/graph-ui/skill-picker.js +373 -39
- package/dist/src/graph-ui/studio-canvas.js +3 -38
- package/dist/src/graph-ui/studio.css +0 -18
- package/dist/src/graph-ui/studio.js +3 -71
- package/dist/src/graph-ui/style.css +11 -134
- package/dist/src/graph-ui/theme.js +1 -26
- package/dist/src/graph-ui/tokens.css +15 -114
- package/dist/src/graphs.d.ts +7 -156
- package/dist/src/graphs.js +72 -273
- package/dist/src/grep-regex-worker.js +0 -2
- package/dist/src/grep-regex.d.ts +1 -5
- package/dist/src/grep-regex.js +6 -8
- package/dist/src/grok-provider.d.ts +0 -17
- package/dist/src/grok-provider.js +1 -26
- package/dist/src/handoffs.d.ts +0 -11
- package/dist/src/handoffs.js +0 -13
- package/dist/src/hardened-runtime.d.ts +0 -10
- package/dist/src/hardened-runtime.js +8 -46
- package/dist/src/harness-home.d.ts +21 -0
- package/dist/src/harness-home.js +87 -0
- package/dist/src/host-process-guard.d.ts +0 -50
- package/dist/src/host-process-guard.js +0 -641
- package/dist/src/limits.d.ts +0 -64
- package/dist/src/limits.js +0 -62
- package/dist/src/managed-sign-in.d.ts +0 -12
- package/dist/src/managed-sign-in.js +0 -16
- package/dist/src/markdown.d.ts +0 -28
- package/dist/src/markdown.js +1 -175
- package/dist/src/mcp.d.ts +21 -82
- package/dist/src/mcp.js +228 -237
- package/dist/src/membership-errors.d.ts +0 -14
- package/dist/src/membership-errors.js +0 -13
- package/dist/src/membership.d.ts +2 -60
- package/dist/src/membership.js +0 -85
- package/dist/src/memory/LocalToolMemory.d.ts +0 -1
- package/dist/src/memory/LocalToolMemory.js +2 -7
- package/dist/src/memory/MemoryDistiller.js +0 -15
- package/dist/src/memory/MemoryManager.d.ts +0 -3
- package/dist/src/memory/MemoryManager.js +6 -18
- package/dist/src/memory/MemoryPolicy.d.ts +0 -2
- package/dist/src/memory/MemoryPolicy.js +0 -2
- package/dist/src/memory/MemoryProvider.d.ts +0 -6
- package/dist/src/memory/MemoryRetriever.js +0 -7
- package/dist/src/memory/PermissionMemoryProvider.d.ts +0 -1
- package/dist/src/memory/PermissionMemoryProvider.js +0 -1
- package/dist/src/memory/ProjectMemory.d.ts +42 -0
- package/dist/src/memory/ProjectMemory.js +285 -0
- package/dist/src/memory/ToolFailureLessons.d.ts +0 -3
- package/dist/src/memory/ToolFailureLessons.js +0 -6
- package/dist/src/memory/index.d.ts +1 -0
- package/dist/src/memory/index.js +1 -0
- package/dist/src/memory/providers/NoOpMemoryProvider.d.ts +0 -1
- package/dist/src/memory/providers/NoOpMemoryProvider.js +0 -1
- package/dist/src/memory/redaction.d.ts +0 -5
- package/dist/src/memory/redaction.js +0 -11
- package/dist/src/memory/repository.d.ts +0 -6
- package/dist/src/memory/repository.js +2 -12
- package/dist/src/memory/types.d.ts +0 -1
- package/dist/src/model-health-cache.d.ts +0 -38
- package/dist/src/model-health-cache.js +1 -49
- package/dist/src/model-metadata.d.ts +0 -18
- package/dist/src/model-metadata.js +2 -42
- package/dist/src/model-override.d.ts +0 -36
- package/dist/src/model-override.js +0 -43
- package/dist/src/model-tiers.d.ts +0 -13
- package/dist/src/model-tiers.js +0 -23
- package/dist/src/opencode-catalog.d.ts +0 -2
- package/dist/src/opencode-catalog.js +0 -11
- package/dist/src/opencode-cli-provider.d.ts +0 -35
- package/dist/src/opencode-cli-provider.js +1 -44
- package/dist/src/opencode-provider.d.ts +0 -2
- package/dist/src/opencode-provider.js +6 -22
- package/dist/src/package-name.d.ts +1 -0
- package/dist/src/package-name.js +1 -0
- package/dist/src/paged-transcript.d.ts +0 -11
- package/dist/src/paged-transcript.js +2 -20
- package/dist/src/palette.d.ts +0 -63
- package/dist/src/palette.js +0 -63
- package/dist/src/permissions.d.ts +0 -15
- package/dist/src/permissions.js +0 -17
- package/dist/src/powershell-pool.d.ts +0 -9
- package/dist/src/powershell-pool.js +3 -26
- package/dist/src/process-warnings.d.ts +4 -0
- package/dist/src/process-warnings.js +103 -0
- package/dist/src/profile.d.ts +0 -43
- package/dist/src/profile.js +0 -43
- package/dist/src/project-reservation.d.ts +11 -0
- package/dist/src/project-reservation.js +143 -0
- package/dist/src/provider-connection.d.ts +0 -18
- package/dist/src/provider-connection.js +0 -39
- package/dist/src/provider-engine.d.ts +0 -21
- package/dist/src/provider-engine.js +3 -98
- package/dist/src/provider-import.d.ts +0 -49
- package/dist/src/provider-import.js +0 -60
- package/dist/src/provider-keys.d.ts +1 -36
- package/dist/src/provider-keys.js +5 -48
- package/dist/src/provider-settings.d.ts +0 -2
- package/dist/src/provider-settings.js +0 -32
- package/dist/src/providers.d.ts +0 -217
- package/dist/src/providers.js +0 -315
- package/dist/src/pull-requests.d.ts +0 -173
- package/dist/src/pull-requests.js +5 -195
- package/dist/src/qa/browser/PlaywrightRunner.d.ts +0 -7
- package/dist/src/qa/browser/PlaywrightRunner.js +2 -16
- package/dist/src/qa/command-policy.d.ts +0 -23
- package/dist/src/qa/command-policy.js +0 -30
- package/dist/src/qa/guidance.d.ts +0 -21
- package/dist/src/qa/guidance.js +0 -20
- package/dist/src/qa/profile/ProjectInspector.d.ts +0 -4
- package/dist/src/qa/profile/ProjectInspector.js +0 -6
- package/dist/src/qa/profile/QaConfigLoader.d.ts +0 -7
- package/dist/src/qa/profile/QaConfigLoader.js +0 -6
- package/dist/src/qa/profile/QaProfile.d.ts +0 -7
- package/dist/src/qa/profile/QaProfile.js +0 -7
- package/dist/src/qa/profile/yaml.d.ts +0 -9
- package/dist/src/qa/profile/yaml.js +0 -13
- package/dist/src/qa/qa-authorize.d.ts +0 -19
- package/dist/src/qa/qa-authorize.js +4 -11
- package/dist/src/qa/runtime/ProcessManager.d.ts +0 -31
- package/dist/src/qa/runtime/ProcessManager.js +4 -41
- package/dist/src/qa/runtime/PtyManager.d.ts +0 -4
- package/dist/src/qa/runtime/PtyManager.js +2 -7
- package/dist/src/qa/runtime/changes.d.ts +0 -11
- package/dist/src/qa/runtime/changes.js +1 -3
- package/dist/src/qa/tools.d.ts +0 -10
- package/dist/src/qa/tools.js +0 -12
- package/dist/src/qa/types.d.ts +0 -13
- package/dist/src/react-runtime.d.ts +2 -21
- package/dist/src/react-runtime.js +106 -418
- package/dist/src/read-document-doc.d.ts +0 -6
- package/dist/src/read-document-doc.js +0 -55
- package/dist/src/read-document-docx.d.ts +0 -16
- package/dist/src/read-document-docx.js +2 -69
- package/dist/src/read-document-text.d.ts +0 -17
- package/dist/src/read-document-text.js +0 -22
- package/dist/src/read-document-tool.d.ts +0 -31
- package/dist/src/read-document-tool.js +0 -30
- package/dist/src/read-document.d.ts +0 -49
- package/dist/src/read-document.js +1 -67
- package/dist/src/read-image.d.ts +0 -32
- package/dist/src/read-image.js +0 -33
- package/dist/src/remote/cert.d.ts +1 -19
- package/dist/src/remote/cert.js +2 -51
- package/dist/src/remote/client.d.ts +0 -70
- package/dist/src/remote/client.js +2 -117
- package/dist/src/remote/command.js +0 -17
- package/dist/src/remote/engine-pool.d.ts +0 -152
- package/dist/src/remote/engine-pool.js +17 -335
- package/dist/src/remote/errors.d.ts +0 -15
- package/dist/src/remote/errors.js +0 -7
- package/dist/src/remote/network.d.ts +0 -26
- package/dist/src/remote/network.js +1 -34
- package/dist/src/remote/pairing.d.ts +16 -51
- package/dist/src/remote/pairing.js +50 -57
- package/dist/src/remote/pem.d.ts +2 -0
- package/dist/src/remote/pem.js +7 -0
- package/dist/src/remote/roots.d.ts +0 -20
- package/dist/src/remote/roots.js +0 -8
- package/dist/src/remote/serve.d.ts +0 -47
- package/dist/src/remote/serve.js +0 -30
- package/dist/src/remote/server.d.ts +0 -14
- package/dist/src/remote/server.js +1 -79
- package/dist/src/remote/types.d.ts +1 -32
- package/dist/src/remote/types.js +0 -10
- package/dist/src/run-control.d.ts +0 -7
- package/dist/src/run-control.js +0 -7
- package/dist/src/run-progress.d.ts +0 -170
- package/dist/src/run-progress.js +0 -285
- package/dist/src/run-records.d.ts +0 -443
- package/dist/src/run-records.js +44 -678
- package/dist/src/run-temp.d.ts +12 -0
- package/dist/src/run-temp.js +50 -0
- package/dist/src/runtime.d.ts +11 -227
- package/dist/src/runtime.js +0 -127
- package/dist/src/sandbox-child.js +0 -1
- package/dist/src/save-lock.d.ts +0 -12
- package/dist/src/save-lock.js +0 -28
- package/dist/src/screen-selection.d.ts +0 -23
- package/dist/src/screen-selection.js +0 -22
- package/dist/src/secret-redaction.d.ts +0 -12
- package/dist/src/secret-redaction.js +0 -45
- package/dist/src/session-changes.d.ts +4 -80
- package/dist/src/session-changes.js +25 -130
- package/dist/src/session-goal.d.ts +129 -0
- package/dist/src/session-goal.js +230 -0
- package/dist/src/session-monitor.d.ts +1 -10
- package/dist/src/session-monitor.js +2 -39
- package/dist/src/session-reaper.d.ts +0 -15
- package/dist/src/session-reaper.js +0 -14
- package/dist/src/session-skills.d.ts +15 -44
- package/dist/src/session-skills.js +75 -60
- package/dist/src/session-summary.d.ts +0 -26
- package/dist/src/session-summary.js +0 -32
- package/dist/src/session-title.d.ts +0 -1
- package/dist/src/session-title.js +0 -2
- package/dist/src/sessions.d.ts +2 -120
- package/dist/src/sessions.js +9 -178
- package/dist/src/shell.d.ts +3 -20
- package/dist/src/shell.js +8 -72
- package/dist/src/side-panel.d.ts +5 -99
- package/dist/src/side-panel.js +76 -133
- package/dist/src/sign-in-detection.d.ts +43 -0
- package/dist/src/sign-in-detection.js +154 -0
- package/dist/src/sign-in-offer.d.ts +17 -0
- package/dist/src/sign-in-offer.js +103 -0
- package/dist/src/skill-commands.d.ts +0 -1
- package/dist/src/skill-commands.js +1 -4
- package/dist/src/skills/bundled/control-browser/SKILL.md +1 -1
- package/dist/src/skills/bundled/graph-manager/SKILL.md +22 -4
- package/dist/src/skills/bundled/provenance.json +2 -2
- package/dist/src/skills/invocable-skills.d.ts +0 -18
- package/dist/src/skills/invocable-skills.js +0 -17
- package/dist/src/skills/project-skills.d.ts +0 -1
- package/dist/src/skills/project-skills.js +0 -3
- package/dist/src/skills/prompt-skills.js +0 -14
- package/dist/src/skills/runtime-skills.d.ts +1 -8
- package/dist/src/skills/runtime-skills.js +8 -32
- package/dist/src/stall-recovery.d.ts +0 -25
- package/dist/src/stall-recovery.js +0 -38
- package/dist/src/stray-files.d.ts +5 -0
- package/dist/src/stray-files.js +65 -0
- package/dist/src/structured-step.d.ts +0 -22
- package/dist/src/structured-step.js +0 -22
- package/dist/src/subagent-run.d.ts +0 -163
- package/dist/src/subagent-run.js +10 -374
- package/dist/src/subagent-tree.d.ts +32 -0
- package/dist/src/subagent-tree.js +128 -0
- package/dist/src/telemetry/aggregate.d.ts +0 -37
- package/dist/src/telemetry/aggregate.js +0 -40
- package/dist/src/telemetry/capture-core.d.ts +0 -87
- package/dist/src/telemetry/capture-core.js +0 -67
- package/dist/src/telemetry/capture.d.ts +0 -1
- package/dist/src/telemetry/capture.js +0 -3
- package/dist/src/telemetry/classify.d.ts +0 -58
- package/dist/src/telemetry/classify.js +0 -60
- package/dist/src/telemetry/decision-capture.d.ts +0 -1
- package/dist/src/telemetry/emitter.d.ts +0 -30
- package/dist/src/telemetry/emitter.js +1 -62
- package/dist/src/telemetry/gate.d.ts +0 -29
- package/dist/src/telemetry/gate.js +0 -22
- package/dist/src/telemetry/identity.d.ts +0 -13
- package/dist/src/telemetry/identity.js +0 -29
- package/dist/src/telemetry/outbox.d.ts +0 -64
- package/dist/src/telemetry/outbox.js +1 -108
- package/dist/src/telemetry/schema.d.ts +1 -49
- package/dist/src/telemetry/schema.js +1 -82
- package/dist/src/telemetry/state.d.ts +0 -53
- package/dist/src/telemetry/state.js +0 -64
- package/dist/src/telemetry/surface.d.ts +0 -31
- package/dist/src/telemetry/surface.js +1 -39
- package/dist/src/telemetry/uploader.d.ts +0 -11
- package/dist/src/telemetry/uploader.js +0 -46
- package/dist/src/telemetry/uploads.d.ts +0 -11
- package/dist/src/telemetry/uploads.js +0 -11
- package/dist/src/telemetry/version.d.ts +0 -4
- package/dist/src/telemetry/version.js +0 -14
- package/dist/src/telemetry/workspace.d.ts +0 -7
- package/dist/src/telemetry/workspace.js +1 -22
- package/dist/src/terminal-ui.d.ts +15 -524
- package/dist/src/terminal-ui.js +80 -876
- package/dist/src/test-edit-guard.d.ts +74 -0
- package/dist/src/test-edit-guard.js +269 -0
- package/dist/src/text.d.ts +0 -1
- package/dist/src/text.js +0 -1
- package/dist/src/time-limit.d.ts +0 -36
- package/dist/src/time-limit.js +0 -37
- package/dist/src/timers.d.ts +0 -161
- package/dist/src/timers.js +0 -126
- package/dist/src/todos.d.ts +0 -1
- package/dist/src/todos.js +0 -3
- package/dist/src/token-rate.d.ts +0 -94
- package/dist/src/token-rate.js +0 -154
- package/dist/src/tool-activity.d.ts +0 -6
- package/dist/src/tool-activity.js +1 -8
- package/dist/src/tool-availability.d.ts +0 -13
- package/dist/src/tool-availability.js +1 -14
- package/dist/src/tool-call-clock.d.ts +1 -4
- package/dist/src/tool-call-clock.js +0 -13
- package/dist/src/tool-catalog.d.ts +0 -11
- package/dist/src/tool-catalog.js +0 -23
- package/dist/src/tool-dependencies.d.ts +0 -5
- package/dist/src/tool-dependencies.js +0 -4
- package/dist/src/tool-diff-stats.d.ts +0 -23
- package/dist/src/tool-diff-stats.js +0 -49
- package/dist/src/tool-errors.d.ts +9 -7
- package/dist/src/tool-errors.js +13 -6
- package/dist/src/tool-failure-tracker.d.ts +3 -11
- package/dist/src/tool-failure-tracker.js +19 -27
- package/dist/src/tool-names.d.ts +0 -16
- package/dist/src/tool-names.js +0 -12
- package/dist/src/tool-profile.d.ts +6 -0
- package/dist/src/tool-profile.js +23 -0
- package/dist/src/tool-result-filter.d.ts +0 -19
- package/dist/src/tool-result-filter.js +1 -66
- package/dist/src/tool-schema-compatibility.d.ts +1 -2
- package/dist/src/tool-schema-compatibility.js +2 -7
- package/dist/src/tools.d.ts +0 -4
- package/dist/src/tools.js +11 -114
- package/dist/src/trajectory.d.ts +0 -13
- package/dist/src/trajectory.js +23 -79
- package/dist/src/transcript.d.ts +1 -37
- package/dist/src/transcript.js +11 -61
- package/dist/src/types.d.ts +2 -167
- package/dist/src/untracked-file-removal.d.ts +3 -0
- package/dist/src/untracked-file-removal.js +105 -0
- package/dist/src/update-check.d.ts +0 -14
- package/dist/src/update-check.js +2 -16
- package/dist/src/update.d.ts +4 -29
- package/dist/src/update.js +20 -98
- package/dist/src/usage-analytics.d.ts +17 -17
- package/dist/src/usage-analytics.js +168 -209
- package/dist/src/web-search.d.ts +0 -23
- package/dist/src/web-search.js +1 -27
- package/dist/src/widgets.d.ts +0 -25
- package/dist/src/widgets.js +0 -24
- package/dist/src/workspace-facts.d.ts +0 -12
- package/dist/src/workspace-facts.js +1 -18
- package/dist/src/workspace-git-metadata.d.ts +4 -5
- package/dist/src/workspace-git-metadata.js +37 -9
- package/dist/src/workspace-instructions.d.ts +3 -15
- package/dist/src/workspace-instructions.js +7 -20
- package/package.json +2 -2
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,10 +139,18 @@ export async function runGraph(graph, options) {
|
|
|
199
139
|
}
|
|
200
140
|
}
|
|
201
141
|
const budget = createRuntimeBudget(options.context.signal, limits.wallTimeMs, options.context.runControl);
|
|
142
|
+
const handedWallMs = new Map();
|
|
143
|
+
const runClockBounds = (bounds, reason, nodeId) => {
|
|
144
|
+
if (reason !== 'wallTimeMs')
|
|
145
|
+
return bounds;
|
|
146
|
+
const own = pinned.nodes[nodeId]?.limits?.wallTimeMs || undefined;
|
|
147
|
+
const handed = handedWallMs.get(nodeId);
|
|
148
|
+
if (own !== undefined && (handed === undefined || own <= handed))
|
|
149
|
+
return { ...bounds, wallTimeMs: own };
|
|
150
|
+
return limits.wallTimeMs ? { ...bounds, wallTimeMs: limits.wallTimeMs } : bounds;
|
|
151
|
+
};
|
|
202
152
|
const signal = budget.signal;
|
|
203
153
|
const confirmedClarifications = [];
|
|
204
|
-
// Bind before queueing: the queue must serialize the budget-aware `approve`, or a wait
|
|
205
|
-
// that only enters the queue would still be charged to the run's clock.
|
|
206
154
|
const awaiting = bindUserWaits(options.context, budget, signal);
|
|
207
155
|
const askUser = awaiting.askUser;
|
|
208
156
|
const context = {
|
|
@@ -211,8 +159,6 @@ export async function runGraph(graph, options) {
|
|
|
211
159
|
approve: serializeApprovals((...args) => awaiting.approve(...args), () => permissionMode(awaiting)),
|
|
212
160
|
...(askUser ? { askUser: async (...args) => {
|
|
213
161
|
const answer = await askUser(...args);
|
|
214
|
-
// A plan presentation is not a clarification pair to distill: the plan body rides its own
|
|
215
|
-
// journal events, and the verdict ('Approve plan') carries no reusable requirement.
|
|
216
162
|
if (typeof answer === 'string' && answer.trim() && !args[0].includes(PLAN_DECISION_MARKER))
|
|
217
163
|
confirmedClarifications.push({ question: args[0], answer });
|
|
218
164
|
return answer;
|
|
@@ -224,12 +170,7 @@ export async function runGraph(graph, options) {
|
|
|
224
170
|
limits: { ...limits }, telemetry: createRunTelemetry(),
|
|
225
171
|
};
|
|
226
172
|
const todoStore = options.todoStore ?? new TodoStore();
|
|
227
|
-
// Widgets belong to the run, not to a branch: every node and every parallel copy updates the
|
|
228
|
-
// same values, exactly as they all keep the one plan.
|
|
229
173
|
const widgetStore = options.widgetStore ?? new WidgetStore(pinned.widgets);
|
|
230
|
-
// A resumed run's plan is seeded into the store where it is read, but announced only after
|
|
231
|
-
// `graph.started`: the browser activity sink clears its checklist on that event, so publishing
|
|
232
|
-
// earlier would have the resume erase the very plan it carried.
|
|
233
174
|
let seededPlan;
|
|
234
175
|
const artifactStore = options.artifactStore ?? new ArtifactStore(result.id);
|
|
235
176
|
options.codeIntel?.beginRun(result.id);
|
|
@@ -238,18 +179,11 @@ export async function runGraph(graph, options) {
|
|
|
238
179
|
options.commandMemory?.observe(event);
|
|
239
180
|
await options.onEvent?.(event);
|
|
240
181
|
};
|
|
241
|
-
// Skill activation is run-wide and independent of conversation reuse or provider identity.
|
|
242
|
-
// Journal replay restores it before any resumed frontier node starts.
|
|
243
182
|
const activeSkills = new Set(options.resumeFrom?.progress.activeSkills ?? []);
|
|
244
|
-
// A run-level skill the stopped attempt inherited is decided again by this caller: the user may have
|
|
245
|
-
// paused, removed or replaced the session's skill since the stop. Skills a node loaded stay restored.
|
|
246
183
|
for (const skillId of options.resumeFrom?.progress.runSkills ?? []) {
|
|
247
184
|
if (!(options.inheritedSkills ?? []).includes(skillId))
|
|
248
185
|
activeSkills.delete(skillId);
|
|
249
186
|
}
|
|
250
|
-
// A fresh run normally starts at the entry. A wake addressed to a node (an Auto-fix prompt goes to the node that
|
|
251
|
-
// switched Auto-fix on) starts at that node instead, when it is still an agent of this graph and can start with
|
|
252
|
-
// only what the run itself supplies: a node that needs its predecessor's handoff would fail its own input checks.
|
|
253
187
|
const startNode = (() => {
|
|
254
188
|
const requested = options.resumeFrom === undefined ? options.startNode : undefined;
|
|
255
189
|
const node = requested === undefined ? undefined : pinned.nodes[requested];
|
|
@@ -263,9 +197,6 @@ export async function runGraph(graph, options) {
|
|
|
263
197
|
return pinned.entry;
|
|
264
198
|
}
|
|
265
199
|
}
|
|
266
|
-
// A join that waits for every branch can complete only when each branch it waits for can run from here. A node
|
|
267
|
-
// on one branch of a fork reaches the join without its siblings, and the run would end at the join with the
|
|
268
|
-
// rest of the graph skipped; starting at the entry runs every branch, as before.
|
|
269
200
|
const reachable = new Set();
|
|
270
201
|
for (const frontier = [requested]; frontier.length > 0;) {
|
|
271
202
|
const nodeId = frontier.pop();
|
|
@@ -292,28 +223,11 @@ export async function runGraph(graph, options) {
|
|
|
292
223
|
let currentNode = startNode;
|
|
293
224
|
let lastCompletion;
|
|
294
225
|
if (options.resumeFrom) {
|
|
295
|
-
// Rehydrate the scheduler from the journal replay of a stopped attempt. The frontier is
|
|
296
|
-
// assembled first and only installed when the journal proved something worth continuing.
|
|
297
|
-
// Every frontier entry carries the mapped inputs and predecessors its activation had —
|
|
298
|
-
// replay proves those queued but unfinished, and re-entering one with empty inputs would
|
|
299
|
-
// fail the node's own schema checks for work its predecessor already paid for. A captured
|
|
300
|
-
// checkpoint re-enters its node's conversation too (the same continuation the pause/resume
|
|
301
|
-
// control uses), one per unfinished branch. With nothing proven, nothing is seeded at all —
|
|
302
|
-
// running the task from entry is the safe restart, and an empty seeded frontier would only
|
|
303
|
-
// trip `maxNodeVisits`.
|
|
304
226
|
const { progress, checkpoints: captured } = options.resumeFrom;
|
|
305
|
-
// Draw fresh generation numbers from where the stopped attempt left them: the executed set
|
|
306
|
-
// below is seeded with the journal's generation-keyed entries, so a resumed revisit must draw
|
|
307
|
-
// a number that has never run rather than reissue one the journal already used.
|
|
308
227
|
nextGeneration = Math.max(nextGeneration, progress.generation ?? 0);
|
|
309
228
|
const resumable = [];
|
|
310
|
-
// The seeded activation of every `(generation, node)` identity the frontier carried: a cycle can
|
|
311
|
-
// hold the same node at two generations, and a checkpoint, a predecessor handoff, or a second
|
|
312
|
-
// activation of that node must address the one its own visit belongs to.
|
|
313
229
|
const byIdentity = new Map();
|
|
314
230
|
const generationsPerNode = new Map();
|
|
315
|
-
// The seeded re-entry of each node — the one unfinished visit it can have — for the legacy
|
|
316
|
-
// checkpoint shape that carries no visit stamp to look itself up by.
|
|
317
231
|
const reentryByNode = new Map();
|
|
318
232
|
const seededByNode = new Map();
|
|
319
233
|
const reentry = new Set();
|
|
@@ -321,29 +235,12 @@ export async function runGraph(graph, options) {
|
|
|
321
235
|
for (const activation of progress.pending) {
|
|
322
236
|
const node = pinned.nodes[activation.nodeId];
|
|
323
237
|
if (!node) {
|
|
324
|
-
// The graph was edited between the stop and this resume. The activation cannot be seeded,
|
|
325
|
-
// and a frontier that vanishes silently would restart the whole task from the entry —
|
|
326
|
-
// rerunning nodes `progress.nodeResults` already proves completed (and their tool effects
|
|
327
|
-
// with them). Refuse below when nothing else is left to continue.
|
|
328
238
|
droppedNodes.add(activation.nodeId);
|
|
329
239
|
continue;
|
|
330
240
|
}
|
|
331
241
|
if (activation.interrupted && node.type === 'action') {
|
|
332
|
-
// The stopped attempt was inside the shell command when it died: the journal cannot show
|
|
333
|
-
// how far the command got, and re-running it could duplicate effects that already fully
|
|
334
|
-
// or partially applied. An action node is the one node type whose work the replay cannot
|
|
335
|
-
// safely put back on the executable frontier, so the whole resume is refused and the
|
|
336
|
-
// workspace stays as the crash left it, for a human to inspect and re-start fresh.
|
|
337
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.`);
|
|
338
243
|
}
|
|
339
|
-
// The replay carried the generation and path this activation had at the stop: seeding them
|
|
340
|
-
// is what lets a resumed cycle classify its outgoing back-edge as a revisit instead of an
|
|
341
|
-
// already-executed suppression, and lets a later-generation activation avoid colliding with
|
|
342
|
-
// the generation-zero executed set.
|
|
343
|
-
// The parallel-group identity rides along: a branch-mode source that dispatched these
|
|
344
|
-
// successors before dying had them on the prefetch path sharing its tool-budget slice, and
|
|
345
|
-
// seeding them groupless would run the first branch on the FULL remaining allowance and
|
|
346
|
-
// starve the rest of the group.
|
|
347
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),
|
|
348
245
|
...(activation.parallelGroup === undefined ? {} : { parallelGroup: activation.parallelGroup, ...(activation.concurrency === undefined ? {} : { concurrency: activation.concurrency }) }) };
|
|
349
246
|
if (activation.interrupted) {
|
|
@@ -357,27 +254,10 @@ export async function runGraph(graph, options) {
|
|
|
357
254
|
generationsPerNode.set(seeded.nodeId, seen);
|
|
358
255
|
resumable.push(seeded);
|
|
359
256
|
}
|
|
360
|
-
// The frontier nodes the journal shows as unfinished re-entries, used below to tell a
|
|
361
|
-
// completed node apart from a node that completed an earlier visit and was interrupted during
|
|
362
|
-
// a later one.
|
|
363
257
|
const interruptedFrontier = new Set(progress.pending.filter(entry => entry.interrupted).map(entry => entry.nodeId));
|
|
364
258
|
for (const checkpoint of captured ?? []) {
|
|
365
|
-
// Parallel branches each checkpoint their own conversation, and each unfinished one gets
|
|
366
|
-
// it back. A checkpoint naming a node the current graph no longer has (the graph was
|
|
367
|
-
// edited since), or one whose node already completed, cannot re-enter anything — except a
|
|
368
|
-
// node that completed an earlier visit and was interrupted on a later one: the completion
|
|
369
|
-
// describes the earlier pass, while the checkpoint holds the unfinished revisit's own
|
|
370
|
-
// conversation, which is exactly what resume must not throw away.
|
|
371
259
|
if ((Object.hasOwn(progress.nodeResults, checkpoint.nodeId) && !interruptedFrontier.has(checkpoint.nodeId)) || !pinned.nodes[checkpoint.nodeId])
|
|
372
260
|
continue;
|
|
373
|
-
// The stamped visit is the only activation this conversation can continue, so the file is
|
|
374
|
-
// addressed by the identity it carries. A stamp naming a visit this resume did not seed
|
|
375
|
-
// belongs to a visit that already ended (or to a generation the node ran at before): attaching
|
|
376
|
-
// it to whatever activation the node happens to hold instead would continue a finished
|
|
377
|
-
// conversation as if it were the unfinished one, with counters that disagree with the graph
|
|
378
|
-
// being replayed. A file from before the stamp carries no visit identity at all, so it goes to
|
|
379
|
-
// the node's unfinished visit — the only conversation an unstamped file can belong to — and
|
|
380
|
-
// otherwise to the activation the node was seeded with.
|
|
381
261
|
const stamped = checkpoint.generation === undefined ? undefined : byIdentity.get(`${checkpoint.generation}:${checkpoint.nodeId}`);
|
|
382
262
|
if (checkpoint.generation !== undefined && stamped === undefined && generationsPerNode.has(checkpoint.nodeId))
|
|
383
263
|
continue;
|
|
@@ -386,22 +266,10 @@ export async function runGraph(graph, options) {
|
|
|
386
266
|
?? { nodeId: checkpoint.nodeId, generation: checkpoint.generation ?? 0, path: [], inputs: {}, predecessors: {} };
|
|
387
267
|
if (!continuableByThisRun(checkpoint.nodeId, checkpoint))
|
|
388
268
|
continue;
|
|
389
|
-
// A checkpoint older than the node's newest journaled effectful tool boundary does not cover
|
|
390
|
-
// that call: the resumed visit would re-enter the conversation from before it and can issue
|
|
391
|
-
// the same mutation again (the observation the tool produced is nowhere in the conversation).
|
|
392
|
-
// Effect-free calls — reads, run-scoped metadata, an unanswered ask_user — keep no boundary,
|
|
393
|
-
// so a crash between a checkpoint and one of those re-enters safely. The same reasoning that
|
|
394
|
-
// refuses an interrupted action node refuses this re-entry — the workspace is left as the
|
|
395
|
-
// crash left it for a human to inspect.
|
|
396
269
|
const toolEvent = progress.lastEffectfulToolEvent?.[checkpoint.nodeId];
|
|
397
270
|
if (toolEvent !== undefined && Date.parse(checkpoint.savedAt) < Date.parse(toolEvent)) {
|
|
398
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.`);
|
|
399
272
|
}
|
|
400
|
-
// A routed checkpoint re-enters its visit on the pair that wrote the conversation, so the
|
|
401
|
-
// restored transcript continues on the model that produced it. The pair is resolved here,
|
|
402
|
-
// before anything is seeded: an unresolvable target becomes a clean refusal instead of a
|
|
403
|
-
// mid-run failure after `run.started`, and dropping the checkpoint instead would restart
|
|
404
|
-
// the node fresh and repeat the mutations the conversation's transcript already observed.
|
|
405
273
|
const routed = routedContinuation(checkpoint.nodeId, checkpoint);
|
|
406
274
|
if (routed) {
|
|
407
275
|
const routedResolved = await (options.resolveModel
|
|
@@ -416,27 +284,16 @@ export async function runGraph(graph, options) {
|
|
|
416
284
|
}
|
|
417
285
|
seeded.continuation = { messages: checkpoint.messages, state: checkpoint.state, revision: checkpoint.revision };
|
|
418
286
|
if (!byIdentity.has(`${seeded.generation}:${seeded.nodeId}`)) {
|
|
419
|
-
// A checkpoint whose node never reached the journal (the process died before the start
|
|
420
|
-
// line appended) still owns the conversation: re-enter it ahead of the rest.
|
|
421
287
|
resumable.unshift(seeded);
|
|
422
288
|
byIdentity.set(`${seeded.generation}:${seeded.nodeId}`, seeded);
|
|
423
289
|
reentry.add(checkpoint.nodeId);
|
|
424
290
|
}
|
|
425
291
|
reentry.add(checkpoint.nodeId);
|
|
426
292
|
}
|
|
427
|
-
// Nothing left to continue although the journal proved queued work: the graph no longer carries
|
|
428
|
-
// the nodes that work named. Seeding nothing would run `queue`'s entry activation and redo
|
|
429
|
-
// every node already completed, so the resume is refused instead.
|
|
430
293
|
if (resumable.length === 0 && droppedNodes.size > 0) {
|
|
431
294
|
const missing = [...droppedNodes].map(nodeId => `"${nodeId}"`).join(', ');
|
|
432
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.`);
|
|
433
296
|
}
|
|
434
|
-
// The live scheduler hands a routed successor the completing predecessor's model transcript
|
|
435
|
-
// (unless the predecessor asked for isolation), and a stop between the edge being journaled and
|
|
436
|
-
// the successor starting loses that handoff: the checkpoint loop above only re-attaches
|
|
437
|
-
// conversations to unfinished nodes, and a completed source's checkpoint would otherwise be
|
|
438
|
-
// discarded with it. Rebuild the handoff from the completed predecessor's durable checkpoint —
|
|
439
|
-
// its provider/model stamp is what the runtime's continue-in-place gate requires.
|
|
440
297
|
const checkpointsPerNode = new Map();
|
|
441
298
|
for (const checkpoint of captured ?? []) {
|
|
442
299
|
const list = checkpointsPerNode.get(checkpoint.nodeId) ?? [];
|
|
@@ -444,7 +301,9 @@ export async function runGraph(graph, options) {
|
|
|
444
301
|
checkpointsPerNode.set(checkpoint.nodeId, list);
|
|
445
302
|
}
|
|
446
303
|
for (const seeded of resumable) {
|
|
447
|
-
if (seeded.
|
|
304
|
+
if (seeded.conversation !== undefined)
|
|
305
|
+
continue;
|
|
306
|
+
if (seeded.continuation !== undefined && pinned.nodes[seeded.nodeId]?.modifiers?.loop === undefined)
|
|
448
307
|
continue;
|
|
449
308
|
if (pinned.nodes[seeded.nodeId]?.type !== 'agent')
|
|
450
309
|
continue;
|
|
@@ -452,13 +311,6 @@ export async function runGraph(graph, options) {
|
|
|
452
311
|
const sourceNode = pinned.nodes[sourceId];
|
|
453
312
|
if (!sourceNode || sourceNode.type !== 'agent' || sourceNode.contextPolicy?.conversation === 'isolate')
|
|
454
313
|
continue;
|
|
455
|
-
// ... and only when the file still holds the conversation of the visit that routed this
|
|
456
|
-
// activation. A cyclic source can complete again after routing it — its checkpoint file is
|
|
457
|
-
// replaced per visit and now carries that later transcript — and handing the later
|
|
458
|
-
// conversation to this successor would give it context that did not exist when its edge was
|
|
459
|
-
// routed. The generation stamp is what tells the visits apart, so a file stamped for another
|
|
460
|
-
// visit hands off nothing at all: the successor keeps the completion as its input and
|
|
461
|
-
// starts its own conversation.
|
|
462
314
|
const checkpoint = (checkpointsPerNode.get(sourceId) ?? []).find(candidate => (candidate.generation ?? 0) === (seeded.sourceGeneration ?? 0));
|
|
463
315
|
if (!checkpoint || typeof checkpoint.provider !== 'string' || typeof checkpoint.model !== 'string' || checkpoint.messages.length === 0)
|
|
464
316
|
continue;
|
|
@@ -466,10 +318,6 @@ export async function runGraph(graph, options) {
|
|
|
466
318
|
}
|
|
467
319
|
}
|
|
468
320
|
for (const waitingJoin of progress.waitingJoins ?? []) {
|
|
469
|
-
// Partial arrivals of an all-mode join go back into the scheduler's waiting state, not the
|
|
470
|
-
// queue: the join must not run on the completed branches alone while the branches that never
|
|
471
|
-
// completed still have their work to do. It fires when the resumed completions bring the
|
|
472
|
-
// arrival for every remaining member edge, exactly as an uninterrupted run would.
|
|
473
321
|
if (!pinned.nodes[waitingJoin.nodeId] || Object.hasOwn(progress.nodeResults, waitingJoin.nodeId))
|
|
474
322
|
continue;
|
|
475
323
|
const targetKey = `${waitingJoin.generation}:${waitingJoin.nodeId}`;
|
|
@@ -486,15 +334,6 @@ export async function runGraph(graph, options) {
|
|
|
486
334
|
pendingJoins.set(targetKey, held);
|
|
487
335
|
}
|
|
488
336
|
if (resumable.length === 0) {
|
|
489
|
-
// The journal can prove a whole finished graph whose final record never landed: every
|
|
490
|
-
// node completed, End among them, and no unfired arrival left to seed. Replaying nothing
|
|
491
|
-
// would restart from the entry node and re-run every completed mutation the journal
|
|
492
|
-
// already proved done. Re-enter End alone instead: its pass performs no work, the seeded
|
|
493
|
-
// completions stand, and the scheduler finalizes on the completion that routed into End.
|
|
494
|
-
// (A proven-done frontier with NO completed End never reaches here — the refusal above
|
|
495
|
-
// rejects that shape before any of the run's resources are opened.)
|
|
496
|
-
// A graph may hold several End nodes — pick the one the journal proves completed; the
|
|
497
|
-
// first End in object order may belong to a branch that never ran.
|
|
498
337
|
const endNode = Object.values(pinned.nodes).find(node => node.type === 'end' && progress.nodeResults[node.id])
|
|
499
338
|
?? Object.values(pinned.nodes).find(node => node.type === 'end');
|
|
500
339
|
const endResult = endNode ? progress.nodeResults[endNode.id] : undefined;
|
|
@@ -503,8 +342,6 @@ export async function runGraph(graph, options) {
|
|
|
503
342
|
result.nodeResults[nodeId] = structuredClone(completion);
|
|
504
343
|
for (const [nodeId, count] of Object.entries(progress.visits))
|
|
505
344
|
visits.set(nodeId, count);
|
|
506
|
-
// End's journaled visit belongs to the stopped attempt; entering it here completes that
|
|
507
|
-
// pass, it is not a second visit.
|
|
508
345
|
visits.set(endNode.id, 0);
|
|
509
346
|
if (progress.toolCalls !== undefined)
|
|
510
347
|
result.toolCalls = progress.toolCalls;
|
|
@@ -520,10 +357,6 @@ export async function runGraph(graph, options) {
|
|
|
520
357
|
queue.length = 0;
|
|
521
358
|
queue.push({ nodeId: endNode.id, generation: 0, path: [], inputs: {}, predecessors: {} });
|
|
522
359
|
currentNode = endNode.id;
|
|
523
|
-
// The seeded plan is seeded here too, exactly as the resumable path below does, and announced
|
|
524
|
-
// once `graph.started` has passed: a client builds its checklist from the event, and this
|
|
525
|
-
// attempt has nothing else to report — but a sink that clears its checklist on the start
|
|
526
|
-
// event would swallow a plan announced before it.
|
|
527
360
|
if (progress.todos?.length) {
|
|
528
361
|
todoStore.update(progress.todos);
|
|
529
362
|
seededPlan = todoStore.snapshot();
|
|
@@ -536,25 +369,13 @@ export async function runGraph(graph, options) {
|
|
|
536
369
|
for (const [nodeId, completion] of Object.entries(progress.nodeResults)) {
|
|
537
370
|
result.nodeResults[nodeId] = structuredClone(completion);
|
|
538
371
|
}
|
|
539
|
-
// Key the executed set the way the stopped attempt keyed it — every `(generation, node)` the
|
|
540
|
-
// journal proves, not only each node's latest generation: a cycle can complete one node at two
|
|
541
|
-
// generations while older-generation work is still queued, and seeding only the later key lets
|
|
542
|
-
// the delayed earlier-generation activation run again, repeating effects the stopped attempt
|
|
543
|
-
// already paid for. A caller that carries only the per-node map (an older reader, or a test
|
|
544
|
-
// fixture) keeps its last-generation keys.
|
|
545
372
|
const executedKeys = progress.executed ?? Object.keys(progress.nodeResults).map(nodeId => `${progress.generations?.[nodeId] ?? 0}:${nodeId}`);
|
|
546
373
|
for (const key of executedKeys)
|
|
547
374
|
executed.add(key);
|
|
548
375
|
for (const [nodeId, count] of Object.entries(progress.visits))
|
|
549
376
|
visits.set(nodeId, count);
|
|
550
|
-
// The stopped attempt's tool spend carries over: a run capped at N calls had spent some (or
|
|
551
|
-
// all) of the graph-level allowance before the crash, and the resumed scheduler must budget
|
|
552
|
-
// from what is left, not hand the allowance out again.
|
|
553
377
|
if (progress.toolCalls !== undefined)
|
|
554
378
|
result.toolCalls = progress.toolCalls;
|
|
555
|
-
// Re-entry completes the stopped attempt's unfinished pass rather than costing a new visit:
|
|
556
|
-
// the node that started there already spent the visit its journal recorded, so that spend
|
|
557
|
-
// is given back or the re-entry would trip `maxNodeVisits` before it could finish.
|
|
558
379
|
for (const nodeId of reentry) {
|
|
559
380
|
const spent = visits.get(nodeId) ?? 0;
|
|
560
381
|
if (spent > 0)
|
|
@@ -563,17 +384,9 @@ export async function runGraph(graph, options) {
|
|
|
563
384
|
queue.length = 0;
|
|
564
385
|
queue.push(...resumable);
|
|
565
386
|
currentNode = resumable[0].nodeId;
|
|
566
|
-
// A run resumed straight into End: an uninterrupted run finalizes on the completion of the
|
|
567
|
-
// node that routed into End, but nothing runs between the seed and End's own completion to
|
|
568
|
-
// set `lastCompletion`. Seed it from the routing source the replay carried.
|
|
569
387
|
const endSeed = resumable.find(item => pinned.nodes[item.nodeId]?.type === 'end' && item.source !== undefined);
|
|
570
388
|
if (endSeed?.source)
|
|
571
389
|
lastCompletion = structuredClone(endSeed.source);
|
|
572
|
-
// The stopped attempt's plan comes back with the position it was written for, and it is
|
|
573
|
-
// announced rather than only seeded: the runtime reads the snapshot out of the todo store on
|
|
574
|
-
// its own, but every client's checklist is built from the event, and a continuation that stayed
|
|
575
|
-
// silent until the model happened to update the plan would look like the plan was lost. The
|
|
576
|
-
// announcement waits for after `graph.started` — see `seededPlan`.
|
|
577
390
|
if (progress.todos?.length) {
|
|
578
391
|
todoStore.update(progress.todos);
|
|
579
392
|
seededPlan = todoStore.snapshot();
|
|
@@ -583,12 +396,7 @@ export async function runGraph(graph, options) {
|
|
|
583
396
|
}
|
|
584
397
|
}
|
|
585
398
|
const liveUsage = { inputTokens: 0, outputTokens: 0, requests: 0 };
|
|
586
|
-
// Per-node token accounting, kept separate from `liveUsage` (which is run-cumulative): the
|
|
587
|
-
// timeline's node chips show each node's own input/output tokens and decode-window throughput.
|
|
588
|
-
// A node that runs twice (a cycle) accumulates across visits, which is what the chip shows.
|
|
589
399
|
const nodeUsageTotals = new Map();
|
|
590
|
-
// Cache splits stay sparse through every graph aggregation: a node or provider
|
|
591
|
-
// that reports no cache traffic never materializes explicit zeros downstream.
|
|
592
400
|
const addUsage = (target, delta) => {
|
|
593
401
|
target.inputTokens += delta.inputTokens;
|
|
594
402
|
target.outputTokens += delta.outputTokens;
|
|
@@ -602,13 +410,6 @@ export async function runGraph(graph, options) {
|
|
|
602
410
|
if (delta.decodeMs !== undefined)
|
|
603
411
|
target.decodeMs = (target.decodeMs ?? 0) + delta.decodeMs;
|
|
604
412
|
};
|
|
605
|
-
// The measured aggregation for the chips' aggregates only: the decode windows of a node's
|
|
606
|
-
// requests sum — the throughput divides the covered tokens by this total, so prefill and tool
|
|
607
|
-
// gaps never enter the figure — and the numerator records how many tokens those windows
|
|
608
|
-
// actually generated. Sparse like the cache splits: a request that measured no window covers
|
|
609
|
-
// nothing, and its tokens stay out of the numerator the way its time stays out of the
|
|
610
|
-
// denominator. The field never reaches the plain `Usage` of the run record — only the chips
|
|
611
|
-
// pair a numerator with a denominator, and only these two aggregates are read by the stamp.
|
|
612
413
|
const addMeasuredUsage = (target, delta) => {
|
|
613
414
|
addUsage(target, delta);
|
|
614
415
|
if (delta.decodeMs !== undefined)
|
|
@@ -616,8 +417,6 @@ export async function runGraph(graph, options) {
|
|
|
616
417
|
};
|
|
617
418
|
const prefetched = new Map();
|
|
618
419
|
const prefetchedStarted = new Set();
|
|
619
|
-
// Branches whose completion was already announced when their invocation returned: the queue's
|
|
620
|
-
// later pass must not announce them a second time.
|
|
621
420
|
const prefetchedCompleted = new Set();
|
|
622
421
|
const accounted = new Set();
|
|
623
422
|
const checkpoints = new Map();
|
|
@@ -628,8 +427,6 @@ export async function runGraph(graph, options) {
|
|
|
628
427
|
controlEvents = controlEvents.then(() => emit(paused ? 'graph.paused' : 'graph.resumed', { nodeId: currentNode }));
|
|
629
428
|
void controlEvents.catch(() => { });
|
|
630
429
|
});
|
|
631
|
-
// Read-only graph work can be retried after its interrupted request settles. Never
|
|
632
|
-
// use this helper for mutations or memory persistence, which may partially apply.
|
|
633
430
|
const readWhileRunning = async (operation) => {
|
|
634
431
|
for (;;) {
|
|
635
432
|
await context.runControl?.wait(signal);
|
|
@@ -670,26 +467,8 @@ export async function runGraph(graph, options) {
|
|
|
670
467
|
providers.set(provider, { ...resolved });
|
|
671
468
|
}
|
|
672
469
|
}
|
|
673
|
-
// A run that switched the session onto this graph hands the session's history to the first agent
|
|
674
|
-
// it starts — the entry node, or the first agent after an entry that is not one (an Action or an
|
|
675
|
-
// Approval cannot take model history) — whatever that agent's own history policy says. A resumed
|
|
676
|
-
// attempt in which an agent already completed is past that point and gets nothing more.
|
|
677
470
|
let entryHistoryPending = options.entryHistory === true
|
|
678
471
|
&& !Object.keys(result.nodeResults ?? {}).some(nodeId => pinned.nodes[nodeId]?.type === 'agent');
|
|
679
|
-
/**
|
|
680
|
-
* @param steerSource - the steering callback this invocation may poll, or undefined to
|
|
681
|
-
* run without steering. Steering is a single destructive queue, so handing the same
|
|
682
|
-
* callback to concurrent branches turns delivery into a race: whichever branch polls
|
|
683
|
-
* first consumes the message and the others never see it. Parallel groups therefore
|
|
684
|
-
* pass a wrapper that admits one branch at a time.
|
|
685
|
-
*
|
|
686
|
-
* Passed explicitly at every call site rather than defaulted: a default would apply
|
|
687
|
-
* when `undefined` is passed, so "no steering" would silently become "use the shared
|
|
688
|
-
* source" and every branch would race again.
|
|
689
|
-
*/
|
|
690
|
-
// A node reads the shared queue (when its branch owns it) and, beside it, whatever is meant for that node
|
|
691
|
-
// alone. Both sources are called before either is awaited: each removes what it hands over synchronously,
|
|
692
|
-
// and the poll races the answer against the abort signal, so nothing may sit taken but not yet returned.
|
|
693
472
|
const nodeSteering = options.getNodeSteeringMessages;
|
|
694
473
|
const withNodeSteering = (shared, nodeId) => nodeSteering === undefined ? shared : async (signal) => {
|
|
695
474
|
const common = shared?.(signal);
|
|
@@ -699,17 +478,13 @@ export async function runGraph(graph, options) {
|
|
|
699
478
|
const invoke = async (activation, maxToolCalls, wallTimeMs, concurrencyBudget, steerSource, continuation) => {
|
|
700
479
|
const nodeId = activation.nodeId;
|
|
701
480
|
const node = pinned.nodes[nodeId];
|
|
702
|
-
// A seeded activation carries its own continuation (the re-entered node's captured
|
|
703
|
-
// conversation); the explicit argument keeps the pause/resume control path unchanged.
|
|
704
481
|
continuation = continuation ?? activation.continuation;
|
|
705
|
-
// Only agent nodes are invoked, so the first invocation is the first agent the run starts, and
|
|
706
|
-
// it takes the seed. A visit that re-enters a saved conversation already holds whatever it was
|
|
707
|
-
// given; every later invocation, a loop back to the entry included, keeps its own policy.
|
|
708
482
|
const seedsEntryHistory = entryHistoryPending && !continuation;
|
|
709
483
|
entryHistoryPending = false;
|
|
710
484
|
const narrow = (run, remaining) => remaining === undefined ? run : run === undefined ? remaining : Math.min(run, remaining);
|
|
711
485
|
maxToolCalls = narrow(maxToolCalls, continuation?.state.remainingToolCalls);
|
|
712
486
|
wallTimeMs = narrow(wallTimeMs, continuation?.state.remainingWallTimeMs);
|
|
487
|
+
handedWallMs.set(nodeId, wallTimeMs);
|
|
713
488
|
if (wallTimeMs !== undefined && wallTimeMs <= 0)
|
|
714
489
|
return { id: result.id, graph: pinned, provider: result.provider, model: result.model, status: 'exhausted', reason: 'wallTimeMs', toolCalls: 0, usage: { inputTokens: 0, outputTokens: 0, requests: 0 } };
|
|
715
490
|
const branchTodos = new TodoStore();
|
|
@@ -724,15 +499,9 @@ export async function runGraph(graph, options) {
|
|
|
724
499
|
const memoryEligible = !!runMemory && runMemory.automaticRetrieval && node.agentRole !== 'orchestrator';
|
|
725
500
|
const decisionManager = options.decisionNodeOptIn && node.jevEnabled !== true
|
|
726
501
|
? new DecisionManager({ config: { mode: 'off', provider: 'none' } }) : options.decisionManager;
|
|
727
|
-
// An empty workspace has no repository history to recall: under context selection the
|
|
728
|
-
// baseline retrieval is skipped on that fact alone, and the node learns the same facts.
|
|
729
|
-
// The facts are recollected per activation: an implementation node can create the very
|
|
730
|
-
// files a later node needs to retrieve, and a run-started snapshot would keep gating that
|
|
731
|
-
// retrieval on the empty workspace the run began in.
|
|
732
502
|
const facts = efficiency.contextSelection || efficiency.catalogSelection
|
|
733
503
|
? await collectWorkspaceFacts(context.workspace, { signal: context.signal }) : undefined;
|
|
734
504
|
const retrievalGated = efficiency.contextSelection && facts?.empty === true;
|
|
735
|
-
// Disabled preflight cannot replace baseline memory retrieval.
|
|
736
505
|
const baselineMemoryRetrieval = !decisionManager?.active || options.efficiency?.jevPreflight === false;
|
|
737
506
|
if (retrievalGated && baselineMemoryRetrieval && runMemory && node.agentRole !== 'orchestrator') {
|
|
738
507
|
await emit('efficiency.context.retrieval_skipped', { nodeId, reason: 'empty_workspace', source: 'memory' });
|
|
@@ -741,25 +510,20 @@ export async function runGraph(graph, options) {
|
|
|
741
510
|
? await readWhileRunning(operationSignal => runMemory.retrieve({ task: memoryTask, nodeId, runId: result.id, signal: operationSignal }))
|
|
742
511
|
: undefined;
|
|
743
512
|
const invocationTools = runMemory ? [...options.tools, memorySearchTool(runMemory, result.id)] : options.tools;
|
|
744
|
-
const
|
|
513
|
+
const projectMemory = options.projectMemory && node.contextPolicy?.projectMemory !== false
|
|
514
|
+
? await readWhileRunning(() => options.projectMemory.context()) : undefined;
|
|
515
|
+
const invocationTask = [options.task, memory?.block, options.commandMemory?.context(), projectMemory].filter(Boolean).join('\n\n');
|
|
745
516
|
const instrument = (provider, resolved) => ({
|
|
746
517
|
...resolved, adapter: dashboardAdapter(resolved.adapter, provider, event => options.onEvent?.(event), { runId: result.id, nodeId, nodeName: node.name, nodeType: node.type }),
|
|
747
518
|
});
|
|
748
519
|
let completedConversation;
|
|
749
|
-
// A routed continuation runs on the pair its conversation was written with: the visit is
|
|
750
|
-
// pinned (its routing already served it), so re-deciding could move the model out from
|
|
751
|
-
// under the restored transcript mid-visit. Routing decides again on the visit's next
|
|
752
|
-
// fresh activation, exactly as it would for any new node entry. The override rides the
|
|
753
|
-
// node, so both executor paths resolve the routed pair through their normal machinery.
|
|
754
520
|
const routed = activation.routedModel ? { ...node, provider: activation.routedModel.provider, model: activation.routedModel.model } : node;
|
|
755
521
|
const routedNode = seedsEntryHistory ? { ...routed, contextPolicy: { ...routed.contextPolicy, history: true } } : routed;
|
|
756
|
-
const outcome = await (continuation && !continuation.state.copies ? executeAgentNode : executeModifiedAgent)(routedNode, {
|
|
522
|
+
const outcome = await (continuation && !continuation.state.copies && !routedNode.modifiers?.loop ? executeAgentNode : executeModifiedAgent)(routedNode, {
|
|
757
523
|
...options,
|
|
758
524
|
...(activation.routedModel ? { modelPinned: true } : {}),
|
|
759
525
|
adapter: instrument(options.provider, { model: options.model, adapter: options.adapter }).adapter,
|
|
760
526
|
...(options.resolveModel ? { resolveModel: async (provider, model, signal) => instrument(provider, await options.resolveModel(provider, model, signal)) } : {}),
|
|
761
|
-
// A live replacement enters through getLiveModel rather than resolveModel. Keep the
|
|
762
|
-
// same per-node request boundaries and duration events after the switch.
|
|
763
527
|
...(options.getLiveModel ? { getLiveModel: async (id, provider, model, signal) => {
|
|
764
528
|
const live = await options.getLiveModel(id, provider, model, signal);
|
|
765
529
|
return live ? { ...instrument(live.provider, live), provider: live.provider } : undefined;
|
|
@@ -775,30 +539,15 @@ export async function runGraph(graph, options) {
|
|
|
775
539
|
await emit('graph.skill.activated', { nodeId, skillId });
|
|
776
540
|
},
|
|
777
541
|
...(continuation ? { resumeMessages: continuation.messages, resumeState: continuation.state, resumeDirectionRevision: continuation.revision } : {}),
|
|
778
|
-
previousConversation: !continuation && node.contextPolicy?.conversation !== 'isolate' && node.contextPolicy?.skillInheritance !== 'none' ? activation.conversation : undefined,
|
|
542
|
+
previousConversation: (!continuation || node.modifiers?.loop !== undefined) && node.contextPolicy?.conversation !== 'isolate' && node.contextPolicy?.skillInheritance !== 'none' ? activation.conversation : undefined,
|
|
779
543
|
onConversationCheckpoint: async (messages, state, conversation) => {
|
|
780
544
|
if (context.runControl)
|
|
781
545
|
checkpoints.set(nodeId, { messages, state, revision: state.directionRevision });
|
|
782
546
|
completedConversation = conversation;
|
|
783
|
-
// Published per node so the caller can persist the run's furthest conversation: unlike the
|
|
784
|
-
// in-memory `checkpoints` map, which only fills while a pause control exists, durability
|
|
785
|
-
// has to hold for every run, including one that is killed with no control ever armed. The
|
|
786
|
-
// generation stamp tells a later resume which visit this conversation belongs to. The
|
|
787
|
-
// identity stamp names the model the handed-off conversation ran on: continuing a
|
|
788
|
-
// conversation requires the same provider and model, so a resume that restores this
|
|
789
|
-
// transcript to a pending successor must know what it was built against.
|
|
790
|
-
// The write is awaited: the checkpoint is the conversation a resume re-enters the node
|
|
791
|
-
// with, so a run that advanced past a mutating tool call while its checkpoint was still
|
|
792
|
-
// queued could be killed with that conversation unwritten — and the resume would re-enter
|
|
793
|
-
// the node from its opening task and repeat the work it had already done.
|
|
794
547
|
const identity = nodeIdentity(nodeId);
|
|
795
548
|
await options.onNodeCheckpoint?.(nodeId, messages, state, {
|
|
796
549
|
generation: activation.generation,
|
|
797
550
|
...(conversation ? { provider: conversation.provider, model: conversation.model } : {}),
|
|
798
|
-
// The baseline this run had configured for the node: a resume whose recomputed
|
|
799
|
-
// baseline still matches knows the conversation's own pair (if it differs) was this
|
|
800
|
-
// configuration's routing decision, and continues the visit on it instead of
|
|
801
|
-
// restarting the node from its opening task.
|
|
802
551
|
routedFrom: { provider: identity.provider, ...(identity.model === undefined ? {} : { model: identity.model }) },
|
|
803
552
|
});
|
|
804
553
|
await options.onConversationCheckpoint?.(messages, state, conversation);
|
|
@@ -825,14 +574,7 @@ export async function runGraph(graph, options) {
|
|
|
825
574
|
options.onUsage?.(usage, origin);
|
|
826
575
|
},
|
|
827
576
|
onEvent: async (event) => {
|
|
828
|
-
// The agent's own events name the invocation but never the run; every graph event
|
|
829
|
-
// carries one. Seeding it here too is what lets the desktop key each node chip's
|
|
830
|
-
// figures by run, so a second task in the same session that reuses a node id
|
|
831
|
-
// cannot repaint the first task's chips with its spend.
|
|
832
577
|
event = { ...event, data: { runId: result.id, ...event.data, nodeName: node.name, nodeType: node.type } };
|
|
833
|
-
// `graphUsage` stays the run-cumulative reading it always was — the plain `Usage`,
|
|
834
|
-
// without the chips' internal measured-token pairing; `nodeUsage` is the same event's
|
|
835
|
-
// per-node figure for the chip — this activation's node so far, pairing included.
|
|
836
578
|
if (event.type === 'agent.model.completed') {
|
|
837
579
|
const { measuredOutputTokens: _chipsOnly, ...runUsage } = liveUsage;
|
|
838
580
|
event = { ...event, data: { ...event.data, graphUsage: runUsage,
|
|
@@ -851,15 +593,8 @@ export async function runGraph(graph, options) {
|
|
|
851
593
|
return outcome;
|
|
852
594
|
};
|
|
853
595
|
await emit('graph.started', { graph: pinned });
|
|
854
|
-
// The resumed run's plan is published here, not at the seed: the browser activity sink clears its
|
|
855
|
-
// checklist on `graph.started`, so an earlier announcement would be erased by the event that
|
|
856
|
-
// announces the very run carrying it. The store already holds it, so nothing reading the store in
|
|
857
|
-
// between sees a gap — only the event stream had to wait for the reset.
|
|
858
596
|
if (seededPlan !== undefined)
|
|
859
597
|
await emit('graph.todos.updated', { todos: seededPlan });
|
|
860
|
-
// Widgets are announced on every run that defines them, resumed or not: the definitions
|
|
861
|
-
// themselves are part of what the user watches, so the panel appears with empty values the
|
|
862
|
-
// moment the run starts rather than waiting for the first update.
|
|
863
598
|
if (widgetStore.definitionsList().length)
|
|
864
599
|
await emit('graph.widgets.updated', { widgets: widgetStore.snapshot() });
|
|
865
600
|
if (options.memory) {
|
|
@@ -880,9 +615,6 @@ export async function runGraph(graph, options) {
|
|
|
880
615
|
if (queue[0].parallelGroup && !prefetched.has(queue[0])) {
|
|
881
616
|
const group = queue.filter(item => item.parallelGroup === queue[0].parallelGroup);
|
|
882
617
|
const maxToolCalls = shareToolBudget(limits.maxToolCalls, result.toolCalls, group.length);
|
|
883
|
-
// A zero share is a valid budget: a branch that needs no tool still returns a
|
|
884
|
-
// completion, and the runtime rejects any tool call it cannot afford. Only an
|
|
885
|
-
// already-exhausted allowance stops the group.
|
|
886
618
|
const remaining = remainingToolBudget(limits.maxToolCalls, result.toolCalls);
|
|
887
619
|
if (remaining !== undefined && remaining < 0) {
|
|
888
620
|
result.reason = 'maxToolCalls';
|
|
@@ -903,10 +635,6 @@ export async function runGraph(graph, options) {
|
|
|
903
635
|
if (node.inputSchema)
|
|
904
636
|
validateValue(node.inputSchema, item.inputs, `Node ${item.nodeId} inputs`);
|
|
905
637
|
}
|
|
906
|
-
// One branch at a time owns the queue, and ownership transfers as branches come and go.
|
|
907
|
-
// Pinning it to a fixed branch would starve every later branch of a serial group: with
|
|
908
|
-
// maxConcurrent 1 the first branch finishes and the next runs with steering disabled,
|
|
909
|
-
// so a steer submitted then would stay queued and could reach no one.
|
|
910
638
|
const activeBranches = [];
|
|
911
639
|
const steeringFor = (item) => {
|
|
912
640
|
const source = options.getSteeringMessages;
|
|
@@ -921,31 +649,14 @@ export async function runGraph(graph, options) {
|
|
|
921
649
|
await Promise.all(Array.from({ length: workers }, async () => {
|
|
922
650
|
while (index < group.length && !signal.aborted && !failures.length) {
|
|
923
651
|
const item = group[index++];
|
|
924
|
-
// Registered before the first await so leadership follows the deterministic
|
|
925
|
-
// start order rather than async scheduling.
|
|
926
652
|
activeBranches.push(item);
|
|
927
653
|
try {
|
|
928
654
|
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) });
|
|
929
655
|
prefetchedStarted.add(item);
|
|
930
|
-
// Agent executions count their own attempts in the agent runtime; every other node
|
|
931
|
-
// type executes only here, and the ADR counts attempts across all nodes.
|
|
932
656
|
if (pinned.nodes[item.nodeId]?.type !== 'agent')
|
|
933
657
|
recordAttempt(result.telemetry, (visits.get(item.nodeId) ?? 0) > 0);
|
|
934
658
|
const outcome = await invoke(item, maxToolCalls, budget.remainingMs(), concurrencyPerBranch, steeringFor(item));
|
|
935
659
|
prefetched.set(item, outcome);
|
|
936
|
-
// A branch that finished while a sibling still runs answers for itself now. Waiting
|
|
937
|
-
// for the whole Promise.all would report its completion only when the slowest sibling
|
|
938
|
-
// returned, leaving every surface that reads liveness off this event — the TUI's
|
|
939
|
-
// active set, the desktop rail, run progress — calling a done branch working for the
|
|
940
|
-
// sibling's full duration. The queue's later pass skips the second announcement. An
|
|
941
|
-
// outcome the sequential path would reject (unknown, or missing on an agent) is left
|
|
942
|
-
// unannounced so the failure still surfaces from the same place it does today, and a
|
|
943
|
-
// completion the queue's own output-schema validation will reject is left unannounced
|
|
944
|
-
// too (checked below): the event is persisted in the journal, and a replay would read
|
|
945
|
-
// a completion that validation refuses as authoritative, letting a resumed attempt
|
|
946
|
-
// skip the invalid branch entirely. Validating here keeps the journal honest; a
|
|
947
|
-
// violation falls through to the queue pass, which raises it at its deterministic
|
|
948
|
-
// point and never announces the completion either.
|
|
949
660
|
const branch = pinned.nodes[item.nodeId];
|
|
950
661
|
if (branch?.type === 'agent' && outcome.status === 'succeeded' && outcome.completion) {
|
|
951
662
|
const completion = outcome.completion;
|
|
@@ -1003,9 +714,8 @@ export async function runGraph(graph, options) {
|
|
|
1003
714
|
result.model = failed.model;
|
|
1004
715
|
result.status = failed.status;
|
|
1005
716
|
result.reason = failed.reason ?? failed.status;
|
|
1006
|
-
// Report the failing branch's effective bounds, which a node limit can tighten.
|
|
1007
717
|
if (failed.limits)
|
|
1008
|
-
result.limits = failed.limits;
|
|
718
|
+
result.limits = runClockBounds(failed.limits, result.reason, failedActivation.nodeId);
|
|
1009
719
|
break;
|
|
1010
720
|
}
|
|
1011
721
|
}
|
|
@@ -1018,13 +728,9 @@ export async function runGraph(graph, options) {
|
|
|
1018
728
|
break;
|
|
1019
729
|
}
|
|
1020
730
|
visits.set(nodeId, count);
|
|
1021
|
-
// See the parallel path: an agent counts its own attempts, and every other node type is
|
|
1022
|
-
// counted here so `attempts` reflects the run's real node executions.
|
|
1023
731
|
if (node.type !== 'agent')
|
|
1024
732
|
recordAttempt(result.telemetry, count > 1);
|
|
1025
733
|
executed.add(`${activation.generation}:${nodeId}`);
|
|
1026
|
-
// The remaining budget comes from the run's own clock, so time a node spent waiting on
|
|
1027
|
-
// the user is not charged to the nodes that follow it.
|
|
1028
734
|
const wallTimeMs = budget.remainingMs();
|
|
1029
735
|
if (wallTimeMs !== undefined && wallTimeMs <= 0) {
|
|
1030
736
|
result.reason = 'wallTimeMs';
|
|
@@ -1036,22 +742,14 @@ export async function runGraph(graph, options) {
|
|
|
1036
742
|
if (node.inputSchema)
|
|
1037
743
|
validateValue(node.inputSchema, activation.inputs, `Node ${nodeId} inputs`);
|
|
1038
744
|
let completion = { summary: node.name, tests: [], outcome: 'completed', output: {} };
|
|
1039
|
-
// The activation's generation and trail are journalled with the start line: they exist in
|
|
1040
|
-
// memory only, and a resume that re-enters this visit journals no routing for it, so a replay
|
|
1041
|
-
// has nothing else to reconstruct them from. A second crash would otherwise read the re-entry
|
|
1042
|
-
// as a generation-zero, ancestry-free activation — rejecting the checkpoint this visit wrote
|
|
1043
|
-
// and losing the revisit its outgoing back-edge owes.
|
|
1044
745
|
if (!prefetchedStarted.has(activation))
|
|
1045
746
|
await emit('graph.node.started', { nodeId, visit: count, generation: activation.generation, path: [...activation.path], ...startIdentity(nodeId, activation.routedModel) });
|
|
1046
747
|
if (node.type === 'agent') {
|
|
1047
748
|
const maxToolCalls = remainingToolBudget(limits.maxToolCalls, result.toolCalls);
|
|
1048
|
-
// Only an already-overspent allowance stops the node: a zero remainder is a valid
|
|
1049
|
-
// budget, since a node that needs no tool still returns a completion.
|
|
1050
749
|
if (!prefetched.has(activation) && maxToolCalls !== undefined && maxToolCalls < 0) {
|
|
1051
750
|
result.reason = 'maxToolCalls';
|
|
1052
751
|
break;
|
|
1053
752
|
}
|
|
1054
|
-
// A node outside a parallel group runs alone, so it polls the shared source directly.
|
|
1055
753
|
const outcome = prefetched.get(activation) ?? await invoke(activation, maxToolCalls, wallTimeMs, pinned.limits?.maxConcurrency ?? 32, options.getSteeringMessages);
|
|
1056
754
|
prefetched.delete(activation);
|
|
1057
755
|
result.provider = outcome.provider;
|
|
@@ -1059,19 +757,14 @@ export async function runGraph(graph, options) {
|
|
|
1059
757
|
if (!accounted.has(activation)) {
|
|
1060
758
|
result.toolCalls += outcome.toolCalls;
|
|
1061
759
|
addUsage(result.usage, outcome.usage);
|
|
1062
|
-
// A prefetched parallel outcome was merged, telemetry included, when its group settled;
|
|
1063
|
-
// absorbing it again would double the run's attempts, tokens and tool counts.
|
|
1064
760
|
absorbTelemetry(result, outcome);
|
|
1065
761
|
}
|
|
1066
762
|
if (outcome.status !== 'succeeded') {
|
|
1067
|
-
// Cancellation is judged from the session signal: the run signal may be fused with
|
|
1068
|
-
// this run's own clock, and a deadline must never be reported as a cancellation.
|
|
1069
763
|
const cancelled = (options.context.userSignal ?? options.context.signal).aborted;
|
|
1070
764
|
result.status = cancelled ? 'cancelled' : budget.expired() ? 'exhausted' : outcome.status;
|
|
1071
765
|
result.reason = cancelled ? 'cancelled' : budget.expired() ? 'wallTimeMs' : outcome.reason ?? outcome.status;
|
|
1072
|
-
// Report the node's effective bounds, which a node limit can tighten.
|
|
1073
766
|
if (outcome.limits)
|
|
1074
|
-
result.limits = outcome.limits;
|
|
767
|
+
result.limits = runClockBounds(outcome.limits, result.reason, nodeId);
|
|
1075
768
|
break;
|
|
1076
769
|
}
|
|
1077
770
|
if (!outcome.completion)
|
|
@@ -1098,8 +791,6 @@ export async function runGraph(graph, options) {
|
|
|
1098
791
|
}
|
|
1099
792
|
else if (node.type === 'approval') {
|
|
1100
793
|
await emit('approval.requested', { nodeId, name: node.name });
|
|
1101
|
-
// The approval prompt is a human wait, so it gets the session signal: the run's
|
|
1102
|
-
// wall clock must not answer for the user.
|
|
1103
794
|
let approved = false;
|
|
1104
795
|
for (;;) {
|
|
1105
796
|
await context.runControl?.wait(signal);
|
|
@@ -1123,7 +814,6 @@ export async function runGraph(graph, options) {
|
|
|
1123
814
|
await emit(approved ? 'approval.approved' : 'approval.denied', { nodeId, name: node.name });
|
|
1124
815
|
}
|
|
1125
816
|
else if (node.type === 'action') {
|
|
1126
|
-
// This node consumes one call below, so being already at the ceiling is a stop.
|
|
1127
817
|
if (!withinToolBudget(result.toolCalls + 1, limits.maxToolCalls)) {
|
|
1128
818
|
result.reason = 'maxToolCalls';
|
|
1129
819
|
break;
|
|
@@ -1133,8 +823,6 @@ export async function runGraph(graph, options) {
|
|
|
1133
823
|
if (!tool)
|
|
1134
824
|
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.`);
|
|
1135
825
|
result.toolCalls++;
|
|
1136
|
-
// The action path runs the shell outside the hardened runtime, so it records its own
|
|
1137
|
-
// capture entry: otherwise an action-only graph reports no tool call or per-tool row.
|
|
1138
826
|
if (result.telemetry)
|
|
1139
827
|
recordToolUse(result.telemetry, shellName, false);
|
|
1140
828
|
const toolCallId = randomUUID();
|
|
@@ -1143,9 +831,6 @@ export async function runGraph(graph, options) {
|
|
|
1143
831
|
let output;
|
|
1144
832
|
let durationMs;
|
|
1145
833
|
const startedAt = monotonicNow();
|
|
1146
|
-
// The shell's approval prompt is a human wait inside `execute`, and the action node has no
|
|
1147
|
-
// hardened-runtime wrapper to subtract it: measured here the same way, so the terminal
|
|
1148
|
-
// `durationMs` — and the ToolCallClock reading it accepts — never charge the deciding.
|
|
1149
834
|
let userWaitMs = 0;
|
|
1150
835
|
let waitSince;
|
|
1151
836
|
const closeUserWait = () => {
|
|
@@ -1156,6 +841,7 @@ export async function runGraph(graph, options) {
|
|
|
1156
841
|
return userWaitMs;
|
|
1157
842
|
};
|
|
1158
843
|
let interrupted = false;
|
|
844
|
+
let exitFailure = false;
|
|
1159
845
|
try {
|
|
1160
846
|
actionSignal.throwIfAborted();
|
|
1161
847
|
output = await tool.execute({ command: node.action.command }, { ...context, signal: actionSignal, userSignal: actionSignal, onApprovalEvent: (type, data) => {
|
|
@@ -1170,35 +856,42 @@ export async function runGraph(graph, options) {
|
|
|
1170
856
|
durationMs = workedMs === undefined ? undefined : Math.max(0, workedMs - waitedMs);
|
|
1171
857
|
}
|
|
1172
858
|
catch (error) {
|
|
1173
|
-
// A pause that aborts the approval mid-prompt leaves the open wait unbilled too.
|
|
1174
859
|
const workedMs = elapsedMs(startedAt);
|
|
1175
860
|
const waitedMs = closeUserWait();
|
|
1176
861
|
durationMs = workedMs === undefined ? undefined : Math.max(0, workedMs - waitedMs);
|
|
1177
|
-
|
|
862
|
+
// The command ran to the end and reported failure through its exit code. That is a result of the
|
|
863
|
+
// step, not a broken run: its output is shown as it is and the graph may route it.
|
|
864
|
+
const exit = error instanceof CommandExitError && !actionSignal.aborted ? error : undefined;
|
|
865
|
+
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 } : {}) });
|
|
1178
866
|
if (!actionSignal.aborted || signal.aborted) {
|
|
1179
|
-
// A real shell failure: the call was counted above, and this records the failure. A
|
|
1180
|
-
// suite that ran and failed is still test evidence, so it is recorded before the throw.
|
|
1181
867
|
if (result.telemetry) {
|
|
1182
868
|
recordToolFailure(result.telemetry, shellName);
|
|
1183
869
|
if (isTestCommandLine(node.action.command))
|
|
1184
870
|
recordTestCommand(result.telemetry);
|
|
1185
871
|
}
|
|
1186
|
-
|
|
872
|
+
if (!exit)
|
|
873
|
+
throw error;
|
|
874
|
+
completion.summary = `${node.name} failed: its command exited with code ${exit.exitCode}.`;
|
|
875
|
+
if (!pinned.edges.some(edge => edge.source === nodeId && edge.outcome === ACTION_FAILED_OUTCOME))
|
|
876
|
+
throw new Error(completion.summary);
|
|
877
|
+
exitFailure = true;
|
|
878
|
+
completion.outcome = ACTION_FAILED_OUTCOME;
|
|
879
|
+
output = exit.message;
|
|
880
|
+
}
|
|
881
|
+
else {
|
|
882
|
+
interrupted = true;
|
|
883
|
+
output = `Interrupted by user; effects may be partial. Not replayed. ${error instanceof Error ? error.message : String(error)}`;
|
|
884
|
+
completion.summary = `${node.name} was interrupted; its effects may be partial and were not replayed.`;
|
|
885
|
+
await context.runControl?.wait(signal);
|
|
1187
886
|
}
|
|
1188
|
-
interrupted = true;
|
|
1189
|
-
output = `Interrupted by user; effects may be partial. Not replayed. ${error instanceof Error ? error.message : String(error)}`;
|
|
1190
|
-
completion.summary = `${node.name} was interrupted; its effects may be partial and were not replayed.`;
|
|
1191
|
-
await context.runControl?.wait(signal);
|
|
1192
887
|
}
|
|
1193
888
|
finally {
|
|
1194
889
|
options.codeIntel?.notePotentialMutation(context.workspace, '(graph action shell)');
|
|
1195
890
|
}
|
|
1196
891
|
completion.output = { result: output };
|
|
1197
|
-
|
|
1198
|
-
// its name looks like a test command; the same rule the hardened runtime applies.
|
|
1199
|
-
if (!interrupted && result.telemetry && isTestCommandLine(node.action.command))
|
|
892
|
+
if (!interrupted && !exitFailure && result.telemetry && isTestCommandLine(node.action.command))
|
|
1200
893
|
recordTestCommand(result.telemetry);
|
|
1201
|
-
if (!interrupted)
|
|
894
|
+
if (!interrupted && !exitFailure)
|
|
1202
895
|
await emit('node.tool.completed', { nodeId, name: shellName, toolCallId, durationMs, output });
|
|
1203
896
|
}
|
|
1204
897
|
else if (node.type === 'parallel' || node.type === 'join')
|
|
@@ -1209,8 +902,6 @@ export async function runGraph(graph, options) {
|
|
|
1209
902
|
result.nodeResults[nodeId] = completion;
|
|
1210
903
|
if (node.type !== 'end')
|
|
1211
904
|
lastCompletion = completion;
|
|
1212
|
-
// A prefetched branch already announced its completion when its invocation returned; the
|
|
1213
|
-
// queue reaching it is bookkeeping, not a second completion.
|
|
1214
905
|
if (!prefetchedCompleted.has(activation))
|
|
1215
906
|
await emit('graph.node.completed', { nodeId, completion });
|
|
1216
907
|
const next = [];
|
|
@@ -1229,8 +920,6 @@ export async function runGraph(graph, options) {
|
|
|
1229
920
|
delete queued.conversation;
|
|
1230
921
|
if (executed.has(targetKey) || queued)
|
|
1231
922
|
continue;
|
|
1232
|
-
// An optional input whose source field was omitted stays absent (see resolveMapping): the
|
|
1233
|
-
// graph's validation accepted that mapping, so the target runs without it.
|
|
1234
923
|
const inputs = resolveMapping(edge.inputMapping, { source: completion, run: { input: runInput, state: runState, loop: { iteration: count } } }, target.inputSchema);
|
|
1235
924
|
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 } };
|
|
1236
925
|
if (node.type === 'agent' && target.type === 'agent' && node.contextPolicy?.conversation !== 'isolate')
|
|
@@ -1243,10 +932,6 @@ export async function runGraph(graph, options) {
|
|
|
1243
932
|
if (!dependencies.every(index => pending.has(index)))
|
|
1244
933
|
continue;
|
|
1245
934
|
const members = [...pending.values()];
|
|
1246
|
-
// Journal every branch's own activation, not one event for whichever branch completed
|
|
1247
|
-
// last: recovery rebuilds a queued join from the journal, and a single final event would
|
|
1248
|
-
// replay the join holding only the last branch's result — the merged inputs and
|
|
1249
|
-
// predecessors the in-memory activation carried would exist nowhere a resume can read.
|
|
1250
935
|
for (const member of members) {
|
|
1251
936
|
const memberSource = Object.keys(member.predecessors)[0];
|
|
1252
937
|
await emit('graph.edge.activated', { source: memberSource, target: edge.target, outcome: member.predecessors[memberSource].outcome });
|
|
@@ -1285,8 +970,6 @@ export async function runGraph(graph, options) {
|
|
|
1285
970
|
finalizationRevision = context.runControl.revision;
|
|
1286
971
|
const checkpoint = lastAgentActivation && checkpoints.get(lastAgentActivation.nodeId);
|
|
1287
972
|
if (lastAgentActivation && checkpoint) {
|
|
1288
|
-
// Routing is complete. Resume the last node's checkpointed conversation
|
|
1289
|
-
// (or each indexed copy) without replaying completed graph actions.
|
|
1290
973
|
await emit('graph.finalization.resumed', { nodeId: lastAgentActivation.nodeId });
|
|
1291
974
|
const continuation = await invoke(lastAgentActivation, remainingToolBudget(limits.maxToolCalls, result.toolCalls), budget.remainingMs(), pinned.limits?.maxConcurrency ?? 32, options.getSteeringMessages, checkpoint);
|
|
1292
975
|
result.toolCalls += continuation.toolCalls;
|
|
@@ -1308,13 +991,9 @@ export async function runGraph(graph, options) {
|
|
|
1308
991
|
finalizationRevision = checkpoints.get(lastAgentActivation.nodeId)?.revision ?? finalizationRevision;
|
|
1309
992
|
}
|
|
1310
993
|
else {
|
|
1311
|
-
// Fixed graphs have no model conversation that could act on new prose.
|
|
1312
|
-
// Acknowledge explicitly rather than silently discarding accepted input.
|
|
1313
994
|
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.` });
|
|
1314
995
|
}
|
|
1315
996
|
}
|
|
1316
|
-
// Memory distillation no longer gates on token headroom: the cumulative ceiling
|
|
1317
|
-
// was removed, and distillation is bounded by its own adapter request instead.
|
|
1318
997
|
if (options.memory?.activeFor(result.id)) {
|
|
1319
998
|
const nodeOutputs = Object.fromEntries(Object.entries(result.nodeResults ?? {}).map(([id, item]) => [id, item.output]));
|
|
1320
999
|
const orchestratorOutputs = Object.entries(pinned.nodes).filter(([, node]) => node.agentRole === 'orchestrator').map(([id]) => result.nodeResults?.[id]?.output);
|
|
@@ -1339,23 +1018,13 @@ export async function runGraph(graph, options) {
|
|
|
1339
1018
|
await emit('memory.error', { operation: 'distill-model-resolution', detail: error instanceof Error ? error.message : 'model resolution failed' });
|
|
1340
1019
|
}
|
|
1341
1020
|
}
|
|
1342
|
-
// A resumed direction invalidates the old completion before any new
|
|
1343
|
-
// persistence attempt, including pauses during model metadata resolution.
|
|
1344
1021
|
if (context.runControl && context.runControl.revision > finalizationRevision)
|
|
1345
1022
|
continue;
|
|
1346
|
-
// Capture the operation generation before starting graph-owned finalization.
|
|
1347
|
-
// MemoryManager may swallow abort and return partial persisted IDs, so the
|
|
1348
|
-
// checkpoint below is mandatory even when distillation resolves successfully.
|
|
1349
1023
|
const distillSignal = context.runControl ? AbortSignal.any([signal, context.runControl.signal]) : signal;
|
|
1350
1024
|
try {
|
|
1351
1025
|
await options.memory.distillRun({
|
|
1352
1026
|
task: options.task, status: result.status, outcome: result.completion?.outcome,
|
|
1353
1027
|
completionSummary, tests, nodeOutputs, orchestratorOutputs, confirmedClarifications,
|
|
1354
|
-
// The distillation is a billed model request like any node's, so it goes through the
|
|
1355
|
-
// same instrumented generation path: without that it reported its tokens in the run
|
|
1356
|
-
// totals while contributing no model tuple, and a run whose only model call was the
|
|
1357
|
-
// distillation published no model at all. Its own `onUsage` is therefore not supplied
|
|
1358
|
-
// here — `generateWithUsage` is the single accounting path for this request.
|
|
1359
1028
|
adapter: distillAdapter ? dashboardAdapter({
|
|
1360
1029
|
generate: request => generateWithUsage({
|
|
1361
1030
|
...options,
|
|
@@ -1364,8 +1033,6 @@ export async function runGraph(graph, options) {
|
|
|
1364
1033
|
...(distillProviderType === undefined ? {} : { providerType: distillProviderType }),
|
|
1365
1034
|
...(distillBaseUrl === undefined ? {} : { baseUrl: distillBaseUrl }),
|
|
1366
1035
|
},
|
|
1367
|
-
// `generateWithUsage` has already added this delta to `result.usage`; adding it
|
|
1368
|
-
// again here would double the run totals against the tuple and the provider.
|
|
1369
1036
|
onUsage: (usage, origin) => options.onUsage?.(usage, origin),
|
|
1370
1037
|
}, result, request),
|
|
1371
1038
|
}, result.provider, event => options.onEvent?.(event), { runId: result.id, operation: 'memory.distillation' }) : undefined,
|
|
@@ -1389,22 +1056,15 @@ export async function runGraph(graph, options) {
|
|
|
1389
1056
|
}
|
|
1390
1057
|
}
|
|
1391
1058
|
catch (error) {
|
|
1392
|
-
// Cancellation is judged from the session signal; every other abort that reached the run
|
|
1393
|
-
// signal is a deadline.
|
|
1394
1059
|
const cancelled = (options.context.userSignal ?? options.context.signal).aborted;
|
|
1395
1060
|
const deadline = budget.expired() || signal.aborted;
|
|
1396
1061
|
result.status = cancelled ? 'cancelled' : deadline ? 'exhausted' : 'infrastructure_error';
|
|
1397
1062
|
result.reason = cancelled ? 'cancelled' : deadline ? 'wallTimeMs' : error instanceof Error ? error.message : 'Graph runtime failure';
|
|
1398
1063
|
}
|
|
1399
|
-
// Cleanup must be unconditional: both the stop event and the Code Intelligence handoff await
|
|
1400
|
-
// sinks that can reject, and a rejection would otherwise skip disposal and leave the run's
|
|
1401
|
-
// timer retained until its original deadline.
|
|
1402
1064
|
try {
|
|
1403
1065
|
await options.commandMemory?.flush(options.context.userSignal ?? options.context.signal);
|
|
1404
1066
|
if (result.status !== 'succeeded') {
|
|
1405
1067
|
delete result.completion;
|
|
1406
|
-
// The event carries the raw code for a machine and the finished sentence for a person, so a
|
|
1407
|
-
// client that reads only the journal shows the same words as the command line.
|
|
1408
1068
|
await emit('graph.stopped', { nodeId: currentNode, status: result.status, reason: result.reason, reasonText: stopReasonSentence(result.reason, result.limits), usage: { ...result.usage }, toolCalls: result.toolCalls });
|
|
1409
1069
|
}
|
|
1410
1070
|
result.todos = todoStore.snapshot();
|