@andorra-labs/code 0.1.12 → 0.1.14
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/src/account-presentation.d.ts +1 -37
- package/dist/src/account-presentation.js +6 -43
- package/dist/src/activity.d.ts +0 -25
- package/dist/src/activity.js +1 -23
- package/dist/src/agent-definitions.d.ts +0 -26
- package/dist/src/agent-definitions.js +0 -43
- package/dist/src/agent-execution.d.ts +0 -2
- package/dist/src/agent-execution.js +347 -554
- package/dist/src/agent-mcp-catalog.d.ts +0 -8
- package/dist/src/agent-mcp-catalog.js +0 -2
- package/dist/src/agent-mcp.d.ts +0 -56
- package/dist/src/agent-mcp.js +11 -155
- package/dist/src/agent-modifiers.d.ts +0 -1
- package/dist/src/agent-modifiers.js +25 -68
- package/dist/src/analytics.d.ts +0 -66
- package/dist/src/analytics.js +0 -45
- package/dist/src/andorra/endpoint.d.ts +7 -0
- package/dist/src/andorra/endpoint.js +46 -0
- package/dist/src/andorra/entry.d.ts +21 -0
- package/dist/src/andorra/entry.js +100 -0
- package/dist/src/andorra/errors.d.ts +2 -0
- package/dist/src/andorra/errors.js +39 -0
- package/dist/src/andorra/hosted.d.ts +52 -0
- package/dist/src/andorra/hosted.js +126 -0
- package/dist/src/andorra/monitor.d.ts +151 -0
- package/dist/src/andorra/monitor.js +393 -0
- package/dist/src/andorra/notices.d.ts +7 -0
- package/dist/src/andorra/notices.js +15 -0
- package/dist/src/andorra/opt-in.d.ts +58 -0
- package/dist/src/andorra/opt-in.js +112 -0
- package/dist/src/andorra/request-watch.d.ts +6 -0
- package/dist/src/andorra/request-watch.js +10 -0
- package/dist/src/andorra/state.d.ts +86 -0
- package/dist/src/andorra/state.js +238 -0
- package/dist/src/andorra/terminal.d.ts +68 -0
- package/dist/src/andorra/terminal.js +125 -0
- package/dist/src/andorra/usage-format.d.ts +9 -0
- package/dist/src/andorra/usage-format.js +19 -0
- package/dist/src/anthropic-console-auth.d.ts +0 -24
- package/dist/src/anthropic-console-auth.js +0 -37
- package/dist/src/anthropic-credentials.d.ts +0 -25
- package/dist/src/anthropic-credentials.js +9 -29
- package/dist/src/app-server/protocol.d.ts +18 -246
- package/dist/src/app-server/protocol.js +1 -132
- package/dist/src/app-server/reasoning.d.ts +0 -31
- package/dist/src/app-server/reasoning.js +0 -54
- package/dist/src/app-server/terminal.d.ts +0 -36
- package/dist/src/app-server/terminal.js +3 -39
- package/dist/src/app-server/workspace.d.ts +0 -167
- package/dist/src/app-server/workspace.js +4 -406
- package/dist/src/app-server.d.ts +52 -925
- package/dist/src/app-server.js +828 -3076
- package/dist/src/artifacts.d.ts +0 -10
- package/dist/src/artifacts.js +1 -11
- package/dist/src/attachments.d.ts +4 -98
- package/dist/src/attachments.js +10 -130
- package/dist/src/auth/AuthManager.d.ts +9 -93
- package/dist/src/auth/AuthManager.js +164 -186
- package/dist/src/auth/callback-page.d.ts +0 -1
- package/dist/src/auth/callback-page.js +0 -4
- package/dist/src/auth/callback.d.ts +0 -25
- package/dist/src/auth/callback.js +1 -29
- package/dist/src/auth/deployment.d.ts +1 -16
- package/dist/src/auth/deployment.js +1 -16
- package/dist/src/auth/index.d.ts +1 -12
- package/dist/src/auth/index.js +1 -12
- package/dist/src/auth/lock.d.ts +0 -1
- package/dist/src/auth/lock.js +0 -1
- package/dist/src/auth/store.d.ts +33 -108
- package/dist/src/auth/store.js +55 -130
- package/dist/src/auth/types.d.ts +0 -8
- package/dist/src/auth-commands.d.ts +0 -5
- package/dist/src/auth-commands.js +0 -1
- package/dist/src/automation-runner.d.ts +0 -9
- package/dist/src/automation-runner.js +0 -11
- package/dist/src/automation-service.d.ts +0 -10
- package/dist/src/automation-service.js +3 -17
- package/dist/src/automation-tool.js +0 -5
- package/dist/src/automation-worker-shutdown.d.ts +0 -1
- package/dist/src/automation-worker-shutdown.js +0 -3
- package/dist/src/automations.d.ts +23 -2
- package/dist/src/automations.js +91 -12
- package/dist/src/background-tasks.d.ts +0 -23
- package/dist/src/background-tasks.js +0 -11
- package/dist/src/boot-trace.d.ts +0 -13
- package/dist/src/boot-trace.js +1 -14
- package/dist/src/browser-activity.js +0 -2
- package/dist/src/browser-bridge.d.ts +0 -2
- package/dist/src/browser-bridge.js +0 -27
- package/dist/src/browser-captcha-tool.d.ts +0 -13
- package/dist/src/browser-captcha-tool.js +3 -35
- package/dist/src/browser-extensions-tool.d.ts +24 -0
- package/dist/src/browser-extensions-tool.js +137 -0
- package/dist/src/browser-extensions.d.ts +127 -0
- package/dist/src/browser-extensions.js +729 -0
- package/dist/src/browser-observation.d.ts +0 -15
- package/dist/src/browser-observation.js +1 -22
- package/dist/src/browser-panel-tool.d.ts +1 -37
- package/dist/src/browser-panel-tool.js +3 -73
- package/dist/src/browser-runner.d.ts +0 -1
- package/dist/src/browser-runner.js +5 -46
- package/dist/src/browser-server.d.ts +0 -6
- package/dist/src/browser-server.js +6 -229
- package/dist/src/browser-session.d.ts +0 -25
- package/dist/src/browser-session.js +1 -71
- package/dist/src/browser-stealth.d.ts +19 -13
- package/dist/src/browser-stealth.js +22 -38
- package/dist/src/browser-ui/app.js +7 -174
- package/dist/src/browser-ui/style.css +0 -68
- package/dist/src/browser-ui/tokens.css +15 -97
- package/dist/src/browser-view.d.ts +106 -295
- package/dist/src/browser-view.js +551 -587
- package/dist/src/capabilities.d.ts +0 -8
- package/dist/src/capabilities.js +0 -29
- package/dist/src/capsolver.d.ts +0 -13
- package/dist/src/capsolver.js +0 -15
- package/dist/src/clarification-ui.d.ts +0 -7
- package/dist/src/clarification-ui.js +0 -8
- package/dist/src/claude-executable.d.ts +0 -1
- package/dist/src/claude-executable.js +1 -2
- package/dist/src/claude-provider.d.ts +6 -19
- package/dist/src/claude-provider.js +155 -63
- package/dist/src/cli-executable.d.ts +0 -16
- package/dist/src/cli-executable.js +0 -7
- package/dist/src/cli-process.d.ts +0 -26
- package/dist/src/cli-process.js +0 -18
- package/dist/src/cli-sign-in.d.ts +0 -20
- package/dist/src/cli-sign-in.js +1 -17
- package/dist/src/cli.d.ts +1 -55
- package/dist/src/cli.js +118 -742
- package/dist/src/code-intelligence/CodeIntelligenceManager.d.ts +4 -59
- package/dist/src/code-intelligence/CodeIntelligenceManager.js +26 -99
- package/dist/src/code-intelligence/ContextLedger.d.ts +0 -4
- package/dist/src/code-intelligence/ContextLedger.js +0 -10
- package/dist/src/code-intelligence/ContextRouter.d.ts +0 -6
- package/dist/src/code-intelligence/ContextRouter.js +0 -8
- package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.d.ts +0 -2
- package/dist/src/code-intelligence/codegraph/CodeGraphProjectSession.js +5 -12
- package/dist/src/code-intelligence/codegraph/CodeGraphProvider.d.ts +0 -6
- package/dist/src/code-intelligence/codegraph/CodeGraphProvider.js +0 -6
- package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.d.ts +0 -5
- package/dist/src/code-intelligence/codegraph/CodeGraphSyncBarrier.js +1 -17
- package/dist/src/code-intelligence/codegraph/repoExploreTool.d.ts +0 -5
- package/dist/src/code-intelligence/codegraph/repoExploreTool.js +0 -5
- package/dist/src/code-intelligence/repository.d.ts +0 -9
- package/dist/src/code-intelligence/repository.js +1 -11
- package/dist/src/code-intelligence/types.d.ts +0 -8
- package/dist/src/codex-auth.d.ts +0 -44
- package/dist/src/codex-auth.js +0 -45
- package/dist/src/codex-browser-auth.d.ts +0 -13
- package/dist/src/codex-browser-auth.js +3 -20
- package/dist/src/codex-errors.js +0 -2
- package/dist/src/codex-executable.d.ts +0 -2
- package/dist/src/codex-executable.js +1 -7
- package/dist/src/codex-provider.d.ts +0 -13
- package/dist/src/codex-provider.js +0 -28
- package/dist/src/codex-rpc.d.ts +0 -10
- package/dist/src/codex-rpc.js +0 -12
- package/dist/src/coding-tools.d.ts +4 -26
- package/dist/src/coding-tools.js +161 -181
- package/dist/src/command-metrics.d.ts +0 -4
- package/dist/src/command-output-tap.d.ts +0 -11
- package/dist/src/command-output-tap.js +0 -3
- package/dist/src/command-screens.d.ts +41 -1
- package/dist/src/command-screens.js +316 -113
- package/dist/src/commands.d.ts +12 -63
- package/dist/src/commands.js +98 -127
- package/dist/src/completion-gates.d.ts +0 -47
- package/dist/src/completion-gates.js +0 -14
- package/dist/src/completion.d.ts +0 -98
- package/dist/src/completion.js +2 -239
- package/dist/src/config.d.ts +15 -115
- package/dist/src/config.js +123 -172
- package/dist/src/context-budget.d.ts +0 -22
- package/dist/src/context-budget.js +0 -44
- package/dist/src/context-compaction.d.ts +29 -6
- package/dist/src/context-compaction.js +94 -25
- package/dist/src/context-selection.d.ts +0 -24
- package/dist/src/context-selection.js +0 -34
- package/dist/src/dashboard-view.d.ts +2 -2
- package/dist/src/dashboard-view.js +11 -37
- package/dist/src/dashboard.d.ts +0 -2
- package/dist/src/dashboard.js +0 -9
- package/dist/src/deadline.d.ts +0 -45
- package/dist/src/deadline.js +0 -54
- package/dist/src/decision/ContinuationAdapter.d.ts +0 -5
- package/dist/src/decision/ContinuationAdapter.js +0 -5
- package/dist/src/decision/DecisionEngine.d.ts +0 -4
- package/dist/src/decision/DecisionManager.d.ts +0 -1
- package/dist/src/decision/DecisionManager.js +2 -7
- package/dist/src/decision/DecisionPolicy.d.ts +0 -1
- package/dist/src/decision/DecisionPolicy.js +0 -1
- package/dist/src/decision/FactContinuations.d.ts +11 -43
- package/dist/src/decision/FactContinuations.js +126 -95
- package/dist/src/decision/FactServiceGate.d.ts +0 -1
- package/dist/src/decision/FactServiceGate.js +0 -4
- package/dist/src/decision/PreparedSteps.d.ts +0 -15
- package/dist/src/decision/PreparedSteps.js +1 -11
- package/dist/src/decision/applyToolMenu.d.ts +0 -1
- package/dist/src/decision/applyToolMenu.js +2 -6
- package/dist/src/decision/checks.d.ts +15 -28
- package/dist/src/decision/checks.js +118 -49
- package/dist/src/decision/facts.d.ts +0 -16
- package/dist/src/decision/facts.js +0 -30
- package/dist/src/decision/guidancePolicy.js +0 -1
- package/dist/src/decision/hostedPolicy.d.ts +0 -6
- package/dist/src/decision/hostedPolicy.js +0 -7
- package/dist/src/decision/hostedSkills.d.ts +0 -19
- package/dist/src/decision/hostedSkills.js +0 -19
- package/dist/src/decision/optimizationPolicy.d.ts +0 -3
- package/dist/src/decision/optimizationPolicy.js +1 -4
- package/dist/src/decision/providers/AndorraDecisionProvider.d.ts +0 -7
- package/dist/src/decision/providers/AndorraDecisionProvider.js +4 -27
- package/dist/src/decision/providers/HttpDecisionProvider.d.ts +0 -2
- package/dist/src/decision/providers/HttpDecisionProvider.js +0 -6
- package/dist/src/decision/routeTools.d.ts +0 -8
- package/dist/src/decision/routeTools.js +1 -8
- package/dist/src/decision/toolFamilies.d.ts +0 -1
- package/dist/src/decision/toolFamilies.js +1 -2
- package/dist/src/decision/toolMenu.d.ts +0 -3
- package/dist/src/decision/toolMenu.js +0 -4
- package/dist/src/decision/types.d.ts +1 -6
- package/dist/src/default-graph.d.ts +0 -9
- package/dist/src/default-graph.js +0 -9
- package/dist/src/delegation-changes.d.ts +0 -56
- package/dist/src/delegation-changes.js +4 -130
- package/dist/src/diff-preview.d.ts +0 -1
- package/dist/src/diff-preview.js +0 -17
- package/dist/src/duration.d.ts +0 -50
- package/dist/src/duration.js +0 -50
- package/dist/src/efficiency.d.ts +0 -39
- package/dist/src/efficiency.js +0 -16
- package/dist/src/engine/protocol.d.ts +0 -2
- package/dist/src/engine/protocol.js +0 -2
- package/dist/src/engine-streams.d.ts +0 -9
- package/dist/src/extensions.d.ts +3 -2
- package/dist/src/extensions.js +63 -35
- package/dist/src/favicons.d.ts +0 -26
- package/dist/src/favicons.js +0 -34
- package/dist/src/file-diff.d.ts +2 -58
- package/dist/src/file-diff.js +0 -32
- package/dist/src/file-read-key.d.ts +0 -7
- package/dist/src/file-read-key.js +0 -7
- package/dist/src/file-read-state.d.ts +0 -1
- package/dist/src/file-read-state.js +0 -4
- package/dist/src/firefox-cookies.d.ts +0 -34
- package/dist/src/firefox-cookies.js +1 -55
- package/dist/src/git-identity-audit.d.ts +27 -0
- package/dist/src/git-identity-audit.js +286 -0
- package/dist/src/git-identity-guard.d.ts +4 -0
- package/dist/src/git-identity-guard.js +998 -0
- package/dist/src/git-identity-hold.d.ts +12 -0
- package/dist/src/git-identity-hold.js +81 -0
- package/dist/src/git-summary.d.ts +0 -58
- package/dist/src/git-summary.js +2 -212
- package/dist/src/goal-completion-verification.d.ts +2 -2
- package/dist/src/goal-completion-verification.js +3 -6
- package/dist/src/graph-account.d.ts +0 -21
- package/dist/src/graph-account.js +0 -17
- package/dist/src/graph-editor-session.d.ts +0 -1
- package/dist/src/graph-editor-session.js +0 -3
- package/dist/src/graph-health.d.ts +9 -61
- package/dist/src/graph-health.js +34 -59
- package/dist/src/graph-manager-chat.d.ts +36 -153
- package/dist/src/graph-manager-chat.js +161 -182
- package/dist/src/graph-provider-portability.d.ts +1 -21
- package/dist/src/graph-provider-portability.js +6 -45
- package/dist/src/graph-quota.d.ts +0 -33
- package/dist/src/graph-quota.js +1 -44
- package/dist/src/graph-runner.d.ts +0 -1
- package/dist/src/graph-runner.js +58 -391
- package/dist/src/graph-selection.d.ts +0 -14
- package/dist/src/graph-selection.js +2 -15
- package/dist/src/graph-server.d.ts +2 -10
- package/dist/src/graph-server.js +39 -101
- package/dist/src/graph-studio-features.d.ts +0 -5
- package/dist/src/graph-studio-features.js +2 -42
- package/dist/src/graph-sync.d.ts +0 -78
- package/dist/src/graph-sync.js +5 -201
- package/dist/src/graph-tool.d.ts +0 -18
- package/dist/src/graph-tool.js +0 -27
- package/dist/src/graph-ui/app.js +176 -492
- package/dist/src/graph-ui/compat.js +0 -7
- package/dist/src/graph-ui/controls.css +0 -48
- package/dist/src/graph-ui/controls.js +0 -88
- package/dist/src/graph-ui/drafts.js +0 -12
- package/dist/src/graph-ui/edge-router.js +0 -62
- package/dist/src/graph-ui/embed.js +0 -59
- package/dist/src/graph-ui/icons.js +0 -8
- package/dist/src/graph-ui/library.css +0 -5
- package/dist/src/graph-ui/manager-markdown.js +0 -11
- package/dist/src/graph-ui/manager-state.js +1 -78
- package/dist/src/graph-ui/manager.css +0 -18
- package/dist/src/graph-ui/manager.js +43 -185
- package/dist/src/graph-ui/model-picker.js +0 -29
- package/dist/src/graph-ui/sidebar.js +2 -3
- package/dist/src/graph-ui/skill-picker.js +373 -39
- package/dist/src/graph-ui/studio-canvas.js +3 -38
- package/dist/src/graph-ui/studio.css +0 -18
- package/dist/src/graph-ui/studio.js +3 -71
- package/dist/src/graph-ui/style.css +16 -136
- package/dist/src/graph-ui/theme.js +1 -26
- package/dist/src/graph-ui/tokens.css +19 -118
- package/dist/src/graphs.d.ts +6 -157
- package/dist/src/graphs.js +66 -269
- package/dist/src/grep-regex-worker.js +0 -2
- package/dist/src/grep-regex.d.ts +1 -5
- package/dist/src/grep-regex.js +6 -8
- package/dist/src/grok-provider.d.ts +0 -17
- package/dist/src/grok-provider.js +1 -26
- package/dist/src/handoffs.d.ts +0 -11
- package/dist/src/handoffs.js +0 -13
- package/dist/src/hardened-runtime.d.ts +0 -10
- package/dist/src/hardened-runtime.js +9 -47
- package/dist/src/harness-home.d.ts +21 -0
- package/dist/src/harness-home.js +87 -0
- package/dist/src/host-process-guard.d.ts +0 -50
- package/dist/src/host-process-guard.js +0 -641
- package/dist/src/limits.d.ts +0 -64
- package/dist/src/limits.js +0 -62
- package/dist/src/managed-sign-in.d.ts +0 -12
- package/dist/src/managed-sign-in.js +0 -16
- package/dist/src/markdown.d.ts +0 -28
- package/dist/src/markdown.js +1 -175
- package/dist/src/mcp.d.ts +0 -99
- package/dist/src/mcp.js +4 -170
- package/dist/src/membership-errors.d.ts +0 -14
- package/dist/src/membership-errors.js +1 -14
- package/dist/src/membership.d.ts +9 -59
- package/dist/src/membership.js +20 -91
- package/dist/src/memory/LocalToolMemory.d.ts +0 -1
- package/dist/src/memory/LocalToolMemory.js +2 -7
- package/dist/src/memory/MemoryDistiller.js +0 -15
- package/dist/src/memory/MemoryManager.d.ts +0 -3
- package/dist/src/memory/MemoryManager.js +6 -18
- package/dist/src/memory/MemoryPolicy.d.ts +0 -2
- package/dist/src/memory/MemoryPolicy.js +0 -2
- package/dist/src/memory/MemoryProvider.d.ts +0 -6
- package/dist/src/memory/MemoryRetriever.js +0 -7
- package/dist/src/memory/PermissionMemoryProvider.d.ts +0 -1
- package/dist/src/memory/PermissionMemoryProvider.js +0 -1
- package/dist/src/memory/ProjectMemory.d.ts +5 -40
- package/dist/src/memory/ProjectMemory.js +22 -47
- package/dist/src/memory/ToolFailureLessons.d.ts +0 -3
- package/dist/src/memory/ToolFailureLessons.js +0 -6
- package/dist/src/memory/providers/NoOpMemoryProvider.d.ts +0 -1
- package/dist/src/memory/providers/NoOpMemoryProvider.js +0 -1
- package/dist/src/memory/redaction.d.ts +0 -5
- package/dist/src/memory/redaction.js +0 -11
- package/dist/src/memory/repository.d.ts +0 -6
- package/dist/src/memory/repository.js +2 -12
- package/dist/src/memory/types.d.ts +0 -1
- package/dist/src/model-context-windows.d.ts +2 -0
- package/dist/src/model-context-windows.js +24 -0
- package/dist/src/model-health-cache.d.ts +0 -38
- package/dist/src/model-health-cache.js +2 -50
- package/dist/src/model-metadata.d.ts +1 -18
- package/dist/src/model-metadata.js +42 -45
- package/dist/src/model-override.d.ts +0 -36
- package/dist/src/model-override.js +0 -43
- package/dist/src/model-tiers.d.ts +0 -13
- package/dist/src/model-tiers.js +0 -23
- package/dist/src/opencode-catalog.d.ts +0 -2
- package/dist/src/opencode-catalog.js +0 -11
- package/dist/src/opencode-cli-provider.d.ts +0 -35
- package/dist/src/opencode-cli-provider.js +1 -44
- package/dist/src/opencode-provider.d.ts +0 -2
- package/dist/src/opencode-provider.js +1 -16
- package/dist/src/package-name.d.ts +0 -2
- package/dist/src/package-name.js +0 -2
- package/dist/src/paged-transcript.d.ts +0 -11
- package/dist/src/paged-transcript.js +2 -20
- package/dist/src/palette.d.ts +1 -63
- package/dist/src/palette.js +1 -64
- package/dist/src/permissions.d.ts +0 -15
- package/dist/src/permissions.js +17 -21
- package/dist/src/powershell-pool.d.ts +0 -9
- package/dist/src/powershell-pool.js +3 -26
- package/dist/src/process-warnings.d.ts +4 -0
- package/dist/src/process-warnings.js +103 -0
- package/dist/src/profile.d.ts +0 -43
- package/dist/src/profile.js +0 -43
- package/dist/src/project-reservation.d.ts +11 -0
- package/dist/src/project-reservation.js +143 -0
- package/dist/src/provider-connection.d.ts +0 -18
- package/dist/src/provider-connection.js +15 -39
- package/dist/src/provider-engine.d.ts +0 -21
- package/dist/src/provider-engine.js +1 -96
- package/dist/src/provider-import.d.ts +0 -49
- package/dist/src/provider-import.js +0 -60
- package/dist/src/provider-keys.d.ts +1 -36
- package/dist/src/provider-keys.js +5 -48
- package/dist/src/provider-settings.d.ts +16 -3
- package/dist/src/provider-settings.js +36 -52
- package/dist/src/providers.d.ts +14 -219
- package/dist/src/providers.js +69 -326
- package/dist/src/pull-requests.d.ts +0 -173
- package/dist/src/pull-requests.js +5 -195
- package/dist/src/qa/browser/PlaywrightRunner.d.ts +0 -7
- package/dist/src/qa/browser/PlaywrightRunner.js +2 -16
- package/dist/src/qa/command-policy.d.ts +0 -23
- package/dist/src/qa/command-policy.js +0 -30
- package/dist/src/qa/guidance.d.ts +0 -21
- package/dist/src/qa/guidance.js +0 -20
- package/dist/src/qa/profile/ProjectInspector.d.ts +0 -4
- package/dist/src/qa/profile/ProjectInspector.js +0 -6
- package/dist/src/qa/profile/QaConfigLoader.d.ts +0 -7
- package/dist/src/qa/profile/QaConfigLoader.js +0 -6
- package/dist/src/qa/profile/QaProfile.d.ts +0 -7
- package/dist/src/qa/profile/QaProfile.js +0 -7
- package/dist/src/qa/profile/yaml.d.ts +0 -9
- package/dist/src/qa/profile/yaml.js +0 -13
- package/dist/src/qa/qa-authorize.d.ts +0 -19
- package/dist/src/qa/qa-authorize.js +4 -11
- package/dist/src/qa/runtime/ProcessManager.d.ts +0 -31
- package/dist/src/qa/runtime/ProcessManager.js +4 -41
- package/dist/src/qa/runtime/PtyManager.d.ts +0 -4
- package/dist/src/qa/runtime/PtyManager.js +1 -7
- package/dist/src/qa/runtime/changes.d.ts +0 -11
- package/dist/src/qa/runtime/changes.js +1 -3
- package/dist/src/qa/tools.d.ts +0 -10
- package/dist/src/qa/tools.js +0 -12
- package/dist/src/qa/types.d.ts +0 -13
- package/dist/src/react-runtime.d.ts +2 -21
- package/dist/src/react-runtime.js +107 -422
- package/dist/src/read-document-doc.d.ts +0 -6
- package/dist/src/read-document-doc.js +0 -55
- package/dist/src/read-document-docx.d.ts +0 -16
- package/dist/src/read-document-docx.js +2 -69
- package/dist/src/read-document-text.d.ts +0 -17
- package/dist/src/read-document-text.js +0 -22
- package/dist/src/read-document-tool.d.ts +0 -31
- package/dist/src/read-document-tool.js +0 -30
- package/dist/src/read-document.d.ts +0 -49
- package/dist/src/read-document.js +1 -67
- package/dist/src/read-image.d.ts +0 -32
- package/dist/src/read-image.js +0 -33
- package/dist/src/remote/cert.d.ts +0 -18
- package/dist/src/remote/cert.js +0 -44
- package/dist/src/remote/client.d.ts +0 -70
- package/dist/src/remote/client.js +1 -116
- package/dist/src/remote/command.js +0 -17
- package/dist/src/remote/engine-pool.d.ts +0 -152
- package/dist/src/remote/engine-pool.js +22 -339
- package/dist/src/remote/errors.d.ts +0 -15
- package/dist/src/remote/errors.js +0 -7
- package/dist/src/remote/network.d.ts +0 -26
- package/dist/src/remote/network.js +1 -34
- package/dist/src/remote/pairing.d.ts +16 -51
- package/dist/src/remote/pairing.js +50 -57
- package/dist/src/remote/pem.d.ts +0 -4
- package/dist/src/remote/pem.js +0 -4
- package/dist/src/remote/roots.d.ts +0 -20
- package/dist/src/remote/roots.js +0 -8
- package/dist/src/remote/serve.d.ts +0 -47
- package/dist/src/remote/serve.js +0 -30
- package/dist/src/remote/server.d.ts +0 -14
- package/dist/src/remote/server.js +1 -79
- package/dist/src/remote/types.d.ts +1 -32
- package/dist/src/remote/types.js +0 -10
- package/dist/src/run-control.d.ts +2 -9
- package/dist/src/run-control.js +9 -13
- package/dist/src/run-progress.d.ts +0 -170
- package/dist/src/run-progress.js +0 -285
- package/dist/src/run-records.d.ts +0 -443
- package/dist/src/run-records.js +14 -687
- package/dist/src/run-temp.d.ts +12 -0
- package/dist/src/run-temp.js +50 -0
- package/dist/src/runtime.d.ts +12 -228
- package/dist/src/runtime.js +2 -128
- package/dist/src/sandbox-child.js +0 -1
- package/dist/src/save-lock.d.ts +0 -12
- package/dist/src/save-lock.js +0 -28
- package/dist/src/screen-selection.d.ts +0 -23
- package/dist/src/screen-selection.js +0 -22
- package/dist/src/secret-redaction.d.ts +0 -12
- package/dist/src/secret-redaction.js +0 -45
- package/dist/src/session-changes.d.ts +4 -80
- package/dist/src/session-changes.js +25 -130
- package/dist/src/session-goal.d.ts +129 -0
- package/dist/src/session-goal.js +230 -0
- package/dist/src/session-monitor.d.ts +1 -10
- package/dist/src/session-monitor.js +2 -39
- package/dist/src/session-reaper.d.ts +0 -15
- package/dist/src/session-reaper.js +0 -14
- package/dist/src/session-skills.d.ts +15 -44
- package/dist/src/session-skills.js +75 -60
- package/dist/src/session-summary.d.ts +0 -26
- package/dist/src/session-summary.js +0 -32
- package/dist/src/session-title.d.ts +0 -1
- package/dist/src/session-title.js +0 -2
- package/dist/src/sessions.d.ts +3 -122
- package/dist/src/sessions.js +9 -178
- package/dist/src/shell.d.ts +3 -20
- package/dist/src/shell.js +8 -72
- package/dist/src/side-panel.d.ts +5 -99
- package/dist/src/side-panel.js +76 -133
- package/dist/src/sign-in-detection.d.ts +0 -39
- package/dist/src/sign-in-detection.js +0 -43
- package/dist/src/sign-in-offer.d.ts +1 -19
- package/dist/src/sign-in-offer.js +0 -13
- package/dist/src/skill-commands.d.ts +0 -1
- package/dist/src/skill-commands.js +1 -4
- package/dist/src/skills/bundled/control-browser/SKILL.md +1 -1
- package/dist/src/skills/bundled/graph-manager/errors.md +1 -1
- package/dist/src/skills/bundled/provenance.json +738 -738
- package/dist/src/skills/invocable-skills.d.ts +0 -18
- package/dist/src/skills/invocable-skills.js +0 -17
- package/dist/src/skills/project-skills.d.ts +0 -1
- package/dist/src/skills/project-skills.js +0 -3
- package/dist/src/skills/prompt-skills.js +0 -14
- package/dist/src/skills/runtime-skills.d.ts +0 -13
- package/dist/src/skills/runtime-skills.js +0 -37
- package/dist/src/stall-recovery.d.ts +0 -25
- package/dist/src/stall-recovery.js +0 -38
- package/dist/src/stray-files.d.ts +0 -9
- package/dist/src/stray-files.js +0 -16
- package/dist/src/structured-step.d.ts +0 -22
- package/dist/src/structured-step.js +0 -22
- package/dist/src/subagent-run.d.ts +2 -163
- package/dist/src/subagent-run.js +18 -376
- package/dist/src/subagent-tree.d.ts +32 -0
- package/dist/src/subagent-tree.js +128 -0
- package/dist/src/telemetry/aggregate.d.ts +0 -37
- package/dist/src/telemetry/aggregate.js +0 -40
- package/dist/src/telemetry/capture-core.d.ts +0 -87
- package/dist/src/telemetry/capture-core.js +0 -67
- package/dist/src/telemetry/capture.d.ts +0 -1
- package/dist/src/telemetry/capture.js +0 -3
- package/dist/src/telemetry/classify.d.ts +0 -58
- package/dist/src/telemetry/classify.js +0 -60
- package/dist/src/telemetry/decision-capture.d.ts +0 -1
- package/dist/src/telemetry/emitter.d.ts +0 -30
- package/dist/src/telemetry/emitter.js +1 -62
- package/dist/src/telemetry/gate.d.ts +0 -29
- package/dist/src/telemetry/gate.js +0 -22
- package/dist/src/telemetry/identity.d.ts +0 -13
- package/dist/src/telemetry/identity.js +0 -29
- package/dist/src/telemetry/outbox.d.ts +0 -64
- package/dist/src/telemetry/outbox.js +1 -108
- package/dist/src/telemetry/schema.d.ts +1 -49
- package/dist/src/telemetry/schema.js +3 -84
- package/dist/src/telemetry/state.d.ts +0 -53
- package/dist/src/telemetry/state.js +0 -64
- package/dist/src/telemetry/surface.d.ts +0 -31
- package/dist/src/telemetry/surface.js +1 -39
- package/dist/src/telemetry/uploader.d.ts +0 -11
- package/dist/src/telemetry/uploader.js +0 -46
- package/dist/src/telemetry/uploads.d.ts +0 -11
- package/dist/src/telemetry/uploads.js +0 -11
- package/dist/src/telemetry/version.d.ts +0 -4
- package/dist/src/telemetry/version.js +0 -14
- package/dist/src/telemetry/workspace.d.ts +0 -7
- package/dist/src/telemetry/workspace.js +1 -22
- package/dist/src/terminal-ui.d.ts +33 -521
- package/dist/src/terminal-ui.js +145 -884
- package/dist/src/test-edit-guard.d.ts +74 -0
- package/dist/src/test-edit-guard.js +269 -0
- package/dist/src/text.d.ts +0 -1
- package/dist/src/text.js +0 -1
- package/dist/src/time-limit.d.ts +0 -36
- package/dist/src/time-limit.js +0 -37
- package/dist/src/timers.d.ts +0 -161
- package/dist/src/timers.js +0 -126
- package/dist/src/todos.d.ts +0 -1
- package/dist/src/todos.js +0 -3
- package/dist/src/token-rate.d.ts +0 -94
- package/dist/src/token-rate.js +0 -154
- package/dist/src/tool-activity.d.ts +0 -6
- package/dist/src/tool-activity.js +0 -7
- package/dist/src/tool-availability.d.ts +0 -13
- package/dist/src/tool-availability.js +1 -14
- package/dist/src/tool-call-clock.d.ts +1 -4
- package/dist/src/tool-call-clock.js +0 -13
- package/dist/src/tool-catalog.d.ts +0 -11
- package/dist/src/tool-catalog.js +0 -23
- package/dist/src/tool-dependencies.d.ts +0 -5
- package/dist/src/tool-dependencies.js +0 -4
- package/dist/src/tool-diff-stats.d.ts +0 -23
- package/dist/src/tool-diff-stats.js +0 -49
- package/dist/src/tool-errors.d.ts +9 -7
- package/dist/src/tool-errors.js +13 -6
- package/dist/src/tool-failure-tracker.d.ts +3 -11
- package/dist/src/tool-failure-tracker.js +19 -27
- package/dist/src/tool-names.d.ts +0 -16
- package/dist/src/tool-names.js +0 -12
- package/dist/src/tool-profile.d.ts +6 -0
- package/dist/src/tool-profile.js +23 -0
- package/dist/src/tool-result-filter.d.ts +0 -19
- package/dist/src/tool-result-filter.js +1 -66
- package/dist/src/tool-schema-compatibility.d.ts +0 -6
- package/dist/src/tool-schema-compatibility.js +0 -9
- package/dist/src/tools.d.ts +0 -4
- package/dist/src/tools.js +11 -114
- package/dist/src/trajectory.d.ts +0 -13
- package/dist/src/trajectory.js +23 -79
- package/dist/src/transcript.d.ts +0 -41
- package/dist/src/transcript.js +5 -60
- package/dist/src/types.d.ts +4 -168
- package/dist/src/untracked-file-removal.js +0 -20
- package/dist/src/update-check.d.ts +0 -14
- package/dist/src/update-check.js +1 -15
- package/dist/src/update.d.ts +0 -35
- package/dist/src/update.js +0 -100
- package/dist/src/usage-analytics.d.ts +17 -17
- package/dist/src/usage-analytics.js +168 -209
- package/dist/src/web-search.d.ts +0 -23
- package/dist/src/web-search.js +1 -27
- package/dist/src/widgets.d.ts +0 -25
- package/dist/src/widgets.js +0 -24
- package/dist/src/workspace-facts.d.ts +0 -12
- package/dist/src/workspace-facts.js +1 -18
- package/dist/src/workspace-git-metadata.d.ts +0 -16
- package/dist/src/workspace-git-metadata.js +0 -21
- package/dist/src/workspace-instructions.d.ts +3 -15
- package/dist/src/workspace-instructions.js +6 -19
- package/package.json +13 -2
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { spawn } from 'node:child_process';
|
|
2
|
-
import { createHash } from 'node:crypto';
|
|
2
|
+
import { createHash, randomUUID } from 'node:crypto';
|
|
3
3
|
import { mkdir } from 'node:fs/promises';
|
|
4
4
|
import { tmpdir } from 'node:os';
|
|
5
5
|
import { isAbsolute, join, resolve } from 'node:path';
|
|
@@ -11,33 +11,53 @@ import { GRAPH_MANAGER_GRAPH_ID } from './graphs.js';
|
|
|
11
11
|
import { clipText } from './text.js';
|
|
12
12
|
import { describeTool } from './transcript.js';
|
|
13
13
|
const STARTUP_MS = 60_000;
|
|
14
|
-
/** How long a new chat waits for a cancelled run to end before it stops the engine instead. */
|
|
15
14
|
const RESET_WAIT_MS = 10_000;
|
|
16
|
-
/** How long a message waits for a run that is already ending before it is reported instead of sent. */
|
|
17
15
|
const ENDING_WAIT_MS = 30_000;
|
|
18
|
-
/** Mirrors `MAX_TASK_CHARS` in `app-server.ts`: the engine refuses a longer `run.start` task or `run.steer` text. */
|
|
19
16
|
export const MANAGER_TASK_MAX_CHARS = 100_000;
|
|
20
17
|
const UPDATE_MESSAGE = 'Update Andorra Code to use Graph Manager.';
|
|
21
18
|
const TOO_LARGE_MESSAGE = 'This graph is too large to send to Graph Manager.';
|
|
22
|
-
/** The longest tool or approval line the panel is given. */
|
|
23
19
|
const TOOL_LINE_MAX = 120;
|
|
24
|
-
/** How many draft-to-graph pairings are remembered; an agent holds a handful of drafts at most. */
|
|
25
20
|
const DRAFTS_MAX = 64;
|
|
26
|
-
|
|
21
|
+
const LIVE_EDITS_MAX = 500;
|
|
27
22
|
const BUNDLED_GRAPH_ID = 'default';
|
|
28
|
-
|
|
23
|
+
const same = (a, b) => JSON.stringify(a) === JSON.stringify(b);
|
|
24
|
+
const clone = (value) => JSON.parse(JSON.stringify(value));
|
|
25
|
+
/** `current` with the named fields, and those that changed between `before` and `after`, taken from `after`. */
|
|
26
|
+
function overlay(current, before, after, named) {
|
|
27
|
+
const out = clone(current);
|
|
28
|
+
for (const key of new Set([...Object.keys(before), ...Object.keys(after), ...named])) {
|
|
29
|
+
if (!named.includes(key) && same(before[key], after[key]))
|
|
30
|
+
continue;
|
|
31
|
+
if (Object.hasOwn(after, key))
|
|
32
|
+
out[key] = clone(after[key]);
|
|
33
|
+
else
|
|
34
|
+
delete out[key];
|
|
35
|
+
}
|
|
36
|
+
return out;
|
|
37
|
+
}
|
|
38
|
+
function draftState(output) {
|
|
39
|
+
try {
|
|
40
|
+
const graph = record(record(record(JSON.parse(String(output ?? ''))).data).graph);
|
|
41
|
+
const nodes = record(graph.nodes);
|
|
42
|
+
if (graph.nodes !== nodes || !Array.isArray(graph.edges))
|
|
43
|
+
return undefined;
|
|
44
|
+
const edges = new Map();
|
|
45
|
+
for (const edge of graph.edges)
|
|
46
|
+
if (typeof record(edge).id === 'string')
|
|
47
|
+
edges.set(record(edge).id, clone(record(edge)));
|
|
48
|
+
return { nodes: clone(nodes), edges };
|
|
49
|
+
}
|
|
50
|
+
catch {
|
|
51
|
+
return undefined;
|
|
52
|
+
}
|
|
53
|
+
}
|
|
29
54
|
const DRAFT_EDIT_ACTIONS = new Set(['andorra_graph_node_upsert', 'andorra_graph_node_patch', 'andorra_graph_node_remove', 'andorra_graph_edge_upsert', 'andorra_graph_edge_remove', 'andorra_graph_patch']);
|
|
30
|
-
/**
|
|
31
|
-
* The change a successful draft call made, read from its reply where the backend decided something
|
|
32
|
-
* (a new card's placement, a connection's generated id) and from its arguments otherwise. Undefined
|
|
33
|
-
* when the reply cannot be read, so the canvas is never shown a guess.
|
|
34
|
-
*/
|
|
35
55
|
export function draftEdit(action, args, output) {
|
|
36
56
|
let reply = {};
|
|
37
57
|
try {
|
|
38
58
|
reply = record(record(JSON.parse(String(output ?? ''))).data);
|
|
39
59
|
}
|
|
40
|
-
catch {
|
|
60
|
+
catch { }
|
|
41
61
|
const node = record(reply.node), edge = record(reply.edge), patch = record(args.patch);
|
|
42
62
|
if (action === 'andorra_graph_node_upsert' || action === 'andorra_graph_node_patch')
|
|
43
63
|
return typeof node.id === 'string' ? { kind: 'node', node } : undefined;
|
|
@@ -51,10 +71,8 @@ export function draftEdit(action, args, output) {
|
|
|
51
71
|
return Object.keys(patch).length ? { kind: 'graph', patch } : undefined;
|
|
52
72
|
return undefined;
|
|
53
73
|
}
|
|
54
|
-
/** The engine went away, deliberately or not; whoever stopped it has already said what there is to say. */
|
|
55
74
|
class EngineStopped extends Error {
|
|
56
75
|
}
|
|
57
|
-
/** The engine answered a request with an error; `code` is its own classification. */
|
|
58
76
|
class EngineRefusal extends Error {
|
|
59
77
|
code;
|
|
60
78
|
constructor(message, code) {
|
|
@@ -73,15 +91,8 @@ const toolArguments = (value) => {
|
|
|
73
91
|
return {};
|
|
74
92
|
}
|
|
75
93
|
};
|
|
76
|
-
/** Plain text on one line: control characters and line breaks become single spaces. */
|
|
77
94
|
const oneLine = (value) => typeof value === 'string' ? value.replace(/[\x00-\x1f\x7f-\x9f\u202a-\u202e\u2066-\u2069\s]+/g, ' ').trim() : '';
|
|
78
95
|
const toolLine = (...parts) => clipText(parts.map(oneLine).filter(Boolean).join(' \u00b7 '), TOOL_LINE_MAX);
|
|
79
|
-
/**
|
|
80
|
-
* One line saying what a tool call or an approval is about, for the tools Graph Manager works with:
|
|
81
|
-
* the `graphs` action and the graph it names, the skill being read, the server being connected.
|
|
82
|
-
* A publish names only its draft, so `graphOfDraft` supplies the graph when the caller knows it.
|
|
83
|
-
* Every other tool keeps the transcript's wording. The line is at most 120 characters.
|
|
84
|
-
*/
|
|
85
96
|
export function describeManagerTool(name, value, graphOfDraft = () => undefined) {
|
|
86
97
|
const args = toolArguments(value);
|
|
87
98
|
if (name === 'graphs') {
|
|
@@ -97,7 +108,6 @@ export function describeManagerTool(name, value, graphOfDraft = () => undefined)
|
|
|
97
108
|
return toolLine(name, args.server);
|
|
98
109
|
return clipText(describeTool(name, value), TOOL_LINE_MAX);
|
|
99
110
|
}
|
|
100
|
-
/** What each `graphs` action does, as the row's verb. An action not named here shows its own name. */
|
|
101
111
|
const GRAPH_ACTION_VERBS = {
|
|
102
112
|
andorra_graph_begin: 'Open draft', andorra_graph_get: 'Read graph', andorra_graph_guide: 'Read guide',
|
|
103
113
|
andorra_graph_node_upsert: 'Set step', andorra_graph_node_patch: 'Edit step', andorra_graph_node_remove: 'Remove step',
|
|
@@ -105,12 +115,6 @@ const GRAPH_ACTION_VERBS = {
|
|
|
105
115
|
andorra_graph_validate: 'Validate draft', andorra_graph_publish: 'Save version', andorra_graph_discard: 'Discard draft',
|
|
106
116
|
andorra_graph_delete: 'Delete graph', andorra_graph_restore: 'Restore graph',
|
|
107
117
|
};
|
|
108
|
-
/**
|
|
109
|
-
* A tool call split the way the app's transcript draws it: the verb, and the thing it acted on.
|
|
110
|
-
* A node is named by its name when the call carries one; a connection reads `source → target`
|
|
111
|
-
* with its outcome. The graph the call is about is left out when it is the open one, which every
|
|
112
|
-
* call of a conversation usually is. Any other tool keeps the transcript's one line as its verb.
|
|
113
|
-
*/
|
|
114
118
|
export function managerToolParts(name, value, openGraphId) {
|
|
115
119
|
const args = toolArguments(value);
|
|
116
120
|
const clip = (text) => text ? clipText(text, TOOL_LINE_MAX) : undefined;
|
|
@@ -144,25 +148,8 @@ export function managerToolParts(name, value, openGraphId) {
|
|
|
144
148
|
return parts('Connect server', oneLine(args.server));
|
|
145
149
|
return { verb: clipText(describeTool(name, value), TOOL_LINE_MAX) };
|
|
146
150
|
}
|
|
147
|
-
/** Bookkeeping calls the runtime handles itself; a conversation shows what the agent did, not these. */
|
|
148
151
|
const HIDDEN_TOOLS = new Set(['update_todos', 'update_widget', 'prepare_steps', 'restore_tools', 'complete_agent']);
|
|
149
152
|
const STOPPED_UNREAD_MESSAGE = 'Graph Manager was stopped before it read your last message. Send it again to continue.';
|
|
150
|
-
/**
|
|
151
|
-
* The environment the chat's engine starts in: the parent's own, so the engine is signed in as the
|
|
152
|
-
* parent is. Stored credentials are scoped to an explicitly named home (`credentialIdentity`), so
|
|
153
|
-
* naming even the default home would move the engine to an empty credential slot. The home is
|
|
154
|
-
* named only when the chat runs against a different one than the environment already selects.
|
|
155
|
-
*
|
|
156
|
-
* The engine is marked as a worker, as the automation runner marks its own. An unmarked engine is a
|
|
157
|
-
* window's: it runs the user's automations, watches their pull requests and archives old sessions.
|
|
158
|
-
* This one is stopped when idle and when the editor closes, which would interrupt an automation it
|
|
159
|
-
* had claimed. The mark switches off those three background services and nothing else.
|
|
160
|
-
*
|
|
161
|
-
* A relative inherited home means the parent's working directory, and the engine starts in its own
|
|
162
|
-
* workspace, where the same words would name another folder with another configuration and another
|
|
163
|
-
* credential slot. It is handed the absolute path instead, which `credentialIdentity` resolves to
|
|
164
|
-
* the scope the parent reads.
|
|
165
|
-
*/
|
|
166
153
|
export function managerEngineEnvironment(directory, environment = process.env) {
|
|
167
154
|
const inherited = environment.ANDORRACODE_HOME;
|
|
168
155
|
const worker = { ...environment, ...(inherited && !isAbsolute(inherited) ? { ANDORRACODE_HOME: resolve(inherited) } : {}), ANDORRA_AUTOMATION_WORKER: '1' };
|
|
@@ -170,27 +157,16 @@ export function managerEngineEnvironment(directory, environment = process.env) {
|
|
|
170
157
|
return worker;
|
|
171
158
|
return { ...worker, ANDORRACODE_HOME: resolve(directory) };
|
|
172
159
|
}
|
|
173
|
-
/**
|
|
174
|
-
* The empty folder Graph Manager's engine runs in: one per config home, outside it. The config home
|
|
175
|
-
* is protected runtime metadata, so a workspace inside it made every read the agent tried (a Grep, a
|
|
176
|
-
* Glob) ask the user for approval. Outside it, reads run freely in an empty folder and the only
|
|
177
|
-
* prompts left are the ones that change something: publishing, deleting or restoring a graph.
|
|
178
|
-
*/
|
|
179
160
|
export function managerWorkspace(directory) {
|
|
180
161
|
return join(tmpdir(), 'andorra-graph-manager', createHash('sha256').update(resolve(directory)).digest('hex').slice(0, 16));
|
|
181
162
|
}
|
|
182
|
-
/**
|
|
183
|
-
* What the agent is given with every message: which graph is open, the canvas as the user sees it
|
|
184
|
-
* now (unsaved edits included), the model the panel has selected, and the user's own words.
|
|
185
|
-
*/
|
|
186
163
|
export function managerTask(turn) {
|
|
187
164
|
const saved = !turn.saved ? 'not saved yet' : turn.revision === undefined ? 'saved' : `saved revision ${turn.revision}`;
|
|
188
165
|
return [
|
|
189
166
|
`You are helping in Graph Studio. Open graph: "${graphName(turn.graph)}", id ${graphId(turn.graph)} (${saved}).`,
|
|
190
|
-
// A save under the preset's id is refused, so the agent is told before it tries.
|
|
191
167
|
graphId(turn.graph) === BUNDLED_GRAPH_ID
|
|
192
168
|
? `The open graph is the bundled preset, which cannot be changed: nothing can be saved under the id "${BUNDLED_GRAPH_ID}". The canvas below is what the user sees now. Do not edit this graph; create a new graph with a new id and its own name (mode "create"), based on the canvas, and make your changes there.`
|
|
193
|
-
: 'The canvas below is what the user sees now, including edits not yet saved. Work from it
|
|
169
|
+
: 'The canvas below is what the user sees now, including edits not yet saved. Work from it: open a draft of this same graph id (mode "create" when it is not saved yet, "edit" otherwise) and make the changes there, upserting from the canvas anything the draft lacks. Each draft edit shows on the canvas at once as an unsaved change. Do not publish this graph: the user reviews your changes and saves them from the editor, and a publish of it is declined.',
|
|
194
170
|
`Selected model: ${turn.provider}/${turn.model}. Use it for new agent nodes unless the user asks otherwise.`,
|
|
195
171
|
'',
|
|
196
172
|
'Canvas:',
|
|
@@ -202,18 +178,6 @@ export function managerTask(turn) {
|
|
|
202
178
|
turn.text,
|
|
203
179
|
].join('\n');
|
|
204
180
|
}
|
|
205
|
-
/**
|
|
206
|
-
* One Graph Manager conversation, run on an engine of its own.
|
|
207
|
-
*
|
|
208
|
-
* The engine that hosts Graph Studio may be busy with the user's task and runs one task at a time,
|
|
209
|
-
* so the chat spawns a dedicated `app-server --stdio` child in an empty workspace and speaks the
|
|
210
|
-
* same line protocol the automation runner does. The graph server keeps one chat per graph, and every
|
|
211
|
-
* panel open on that graph shares it: each subscriber is caught up with a snapshot and then receives
|
|
212
|
-
* the stream.
|
|
213
|
-
*
|
|
214
|
-
* Failures on the engine's side are reported as `error` events rather than rejections, because the
|
|
215
|
-
* message that failed is already on every panel's transcript and the stream is where panels listen.
|
|
216
|
-
*/
|
|
217
181
|
export class GraphManagerChat {
|
|
218
182
|
options;
|
|
219
183
|
directory;
|
|
@@ -225,55 +189,45 @@ export class GraphManagerChat {
|
|
|
225
189
|
engine;
|
|
226
190
|
sessionId;
|
|
227
191
|
runId;
|
|
228
|
-
/** The run whose terminal event has been handled; its late `run.start` answer must not revive it. */
|
|
229
192
|
finishedRunId;
|
|
230
|
-
/** Approvals and questions the panel has been shown and nobody has settled yet. */
|
|
231
193
|
prompts = new Set();
|
|
232
|
-
/** `graphs` calls in flight, by tool call id: the line shown for each, and the graph a begin opens or a publish saves. */
|
|
233
194
|
graphCalls = new Map();
|
|
234
|
-
/** Which graph each draft is of, learned from `andorra_graph_begin`, so a publish can name its graph. */
|
|
235
195
|
drafts = new Map();
|
|
236
|
-
/** The latest revision reported for each graph the agent saved other than the open one. */
|
|
237
196
|
otherRevisions = new Map();
|
|
238
|
-
/** The model the latest message chose, for a steering message that has to be sent again as a run. */
|
|
239
197
|
lastModel;
|
|
240
|
-
/**
|
|
241
|
-
* Messages a run ended without reading, oldest first, each already a whole task. The engine keeps
|
|
242
|
-
* them out of the session's history, so they stay here until an engine has accepted them.
|
|
243
|
-
*/
|
|
244
198
|
unread = [];
|
|
245
|
-
/** The pair the latest run was started on or last switched to, to tell when a message changes it. */
|
|
246
199
|
runModel;
|
|
247
200
|
openGraphId;
|
|
248
201
|
lastRevision = 0;
|
|
249
202
|
revisionCheck = Promise.resolve();
|
|
250
203
|
cancelling = false;
|
|
251
|
-
/** How many times Stop was pressed, so a message still waiting to be sent can tell it was stopped too. */
|
|
252
204
|
stops = 0;
|
|
253
205
|
closed = false;
|
|
254
|
-
/** Messages and resets are delivered one at a time, in the order they were asked for. */
|
|
255
206
|
queue = Promise.resolve();
|
|
256
207
|
idleTimer;
|
|
257
208
|
idleWaiters = [];
|
|
258
209
|
now;
|
|
259
|
-
/** Names the rows of tool calls the engine reported without an id of their own. */
|
|
260
210
|
toolRows = 0;
|
|
211
|
+
liveEdits = [];
|
|
212
|
+
editSeq = 0;
|
|
213
|
+
/** Names this chat's edit numbering, so a panel never compares numbers from two conversations. */
|
|
214
|
+
editStream = randomUUID();
|
|
215
|
+
/** The open graph as the panel holds it: the canvas sent with the last message plus the edits since. */
|
|
216
|
+
canvas;
|
|
217
|
+
draftStates = new Map();
|
|
261
218
|
constructor(options) {
|
|
262
219
|
this.options = options;
|
|
263
|
-
// Resolved now: the engine is started in another working directory.
|
|
264
220
|
this.directory = resolve(options.directory);
|
|
265
221
|
this.workspace = resolve(options.workspace ?? managerWorkspace(this.directory));
|
|
266
222
|
this.idleMs = options.idleMs ?? 600_000;
|
|
267
223
|
this.now = options.now ?? Date.now;
|
|
268
224
|
}
|
|
269
|
-
/** The listener is first handed the conversation so far as one snapshot, then every later event. */
|
|
270
225
|
subscribe(listener) {
|
|
271
226
|
this.listeners.add(listener);
|
|
272
227
|
this.armIdleStop();
|
|
273
|
-
this.deliverTo(listener, { type: 'snapshot', events: [...this.transcript], state: this.state });
|
|
228
|
+
this.deliverTo(listener, { type: 'snapshot', events: [...this.transcript], state: this.state, edits: [...this.liveEdits], stream: this.editStream });
|
|
274
229
|
return () => { this.listeners.delete(listener); this.armIdleStop(); };
|
|
275
230
|
}
|
|
276
|
-
/** Start the conversation, continue it, or steer the run that is working. */
|
|
277
231
|
send(turn) {
|
|
278
232
|
if (this.closed)
|
|
279
233
|
return Promise.resolve();
|
|
@@ -284,7 +238,6 @@ export class GraphManagerChat {
|
|
|
284
238
|
async approve(id, approved) {
|
|
285
239
|
if (!this.engine || !this.prompts.has(id))
|
|
286
240
|
return;
|
|
287
|
-
// A refusal means the engine no longer holds the prompt, which settles it just the same.
|
|
288
241
|
await this.request(this.engine, 'run.approve', { id, approved }).catch(() => { });
|
|
289
242
|
this.resolvePrompt(id);
|
|
290
243
|
}
|
|
@@ -295,23 +248,18 @@ export class GraphManagerChat {
|
|
|
295
248
|
this.resolvePrompt(id);
|
|
296
249
|
}
|
|
297
250
|
async cancel() {
|
|
298
|
-
// A live run is cancelled at once, whatever is queued behind it. A start still on its way has
|
|
299
|
-
// no run to name yet, so the cancel follows it; every queued step is bounded, so this ends.
|
|
300
251
|
this.stops++;
|
|
301
|
-
// Stop covers a message no run has read yet, as it covers one still waiting to be sent.
|
|
302
252
|
if (this.unread.splice(0).length)
|
|
303
253
|
this.emit({ type: 'error', message: STOPPED_UNREAD_MESSAGE });
|
|
304
254
|
if (this.runId === undefined)
|
|
305
255
|
await this.queue;
|
|
306
256
|
await this.cancelRun();
|
|
307
257
|
}
|
|
308
|
-
/** Forget the session and the transcript. The engine stays for the next conversation. */
|
|
309
258
|
reset() {
|
|
310
259
|
if (this.closed)
|
|
311
260
|
return Promise.resolve();
|
|
312
261
|
return this.enqueue(async () => {
|
|
313
262
|
await this.cancelRun();
|
|
314
|
-
// The engine runs one task at a time, so the next conversation waits for this one to end.
|
|
315
263
|
if (this.state !== 'idle')
|
|
316
264
|
await this.whenIdle(RESET_WAIT_MS);
|
|
317
265
|
if (this.state !== 'idle') {
|
|
@@ -326,6 +274,9 @@ export class GraphManagerChat {
|
|
|
326
274
|
this.graphCalls.clear();
|
|
327
275
|
this.drafts.clear();
|
|
328
276
|
this.otherRevisions.clear();
|
|
277
|
+
this.liveEdits = [];
|
|
278
|
+
this.draftStates.clear();
|
|
279
|
+
this.canvas = undefined;
|
|
329
280
|
this.openGraphId = undefined;
|
|
330
281
|
this.lastRevision = 0;
|
|
331
282
|
const snapshot = { type: 'snapshot', events: [], state: this.state };
|
|
@@ -333,7 +284,6 @@ export class GraphManagerChat {
|
|
|
333
284
|
this.deliverTo(listener, snapshot);
|
|
334
285
|
});
|
|
335
286
|
}
|
|
336
|
-
/** Cancel the run, stop the child and clear the timers. Nothing is started afterwards. */
|
|
337
287
|
async close() {
|
|
338
288
|
if (this.closed)
|
|
339
289
|
return;
|
|
@@ -350,7 +300,6 @@ export class GraphManagerChat {
|
|
|
350
300
|
await this.stopEngine(engine);
|
|
351
301
|
}
|
|
352
302
|
enqueue(step) {
|
|
353
|
-
// A step reports its own failures, so the chain never rejects and never stalls.
|
|
354
303
|
const next = this.queue.then(step).catch(() => { });
|
|
355
304
|
this.queue = next;
|
|
356
305
|
return next;
|
|
@@ -358,8 +307,6 @@ export class GraphManagerChat {
|
|
|
358
307
|
async deliver(turn, stops) {
|
|
359
308
|
if (this.closed)
|
|
360
309
|
return;
|
|
361
|
-
// Stop was pressed after this message was sent, while it waited its turn behind another. Stop
|
|
362
|
-
// covers everything sent before it: delivering it now would start a run the user just stopped.
|
|
363
310
|
if (this.stops !== stops) {
|
|
364
311
|
this.emit({ type: 'error', message: STOPPED_UNREAD_MESSAGE });
|
|
365
312
|
return;
|
|
@@ -368,19 +315,18 @@ export class GraphManagerChat {
|
|
|
368
315
|
const known = turn.saved ? turn.revision ?? 0 : 0;
|
|
369
316
|
this.lastRevision = id === this.openGraphId ? Math.max(this.lastRevision, known) : known;
|
|
370
317
|
this.openGraphId = id;
|
|
318
|
+
const nodes = record(turn.graph.nodes);
|
|
319
|
+
this.canvas = turn.graph.nodes === nodes && Array.isArray(turn.graph.edges)
|
|
320
|
+
? { nodes: clone(nodes), edges: clone(turn.graph.edges), fields: clone(turn.graph) }
|
|
321
|
+
: undefined;
|
|
371
322
|
this.lastModel = { provider: turn.provider, model: turn.model };
|
|
372
323
|
const task = managerTask(turn);
|
|
373
|
-
// The canvas travels inside the task, so a large graph can pass the engine's limit. Refused here,
|
|
374
|
-
// before anything is sent, with words about the graph rather than the engine's about a field.
|
|
375
324
|
if (task.length > MANAGER_TASK_MAX_CHARS) {
|
|
376
325
|
this.emit({ type: 'error', message: TOO_LARGE_MESSAGE });
|
|
377
326
|
return;
|
|
378
327
|
}
|
|
379
328
|
if (this.runId !== undefined && this.state !== 'idle' && this.engine) {
|
|
380
329
|
const engine = this.engine, runId = this.runId;
|
|
381
|
-
// A steer carries words only, so a model chosen since the run began is applied to the run first.
|
|
382
|
-
// A refusal is held until the steer is answered: a run that is ending refuses both, and the
|
|
383
|
-
// message then starts the next run on the new model with nothing to report.
|
|
384
330
|
const keptModel = await this.switchRunModel(engine, runId, turn.provider, turn.model);
|
|
385
331
|
if (keptModel === 'stopped')
|
|
386
332
|
return;
|
|
@@ -393,20 +339,14 @@ export class GraphManagerChat {
|
|
|
393
339
|
catch (error) {
|
|
394
340
|
if (error instanceof EngineStopped)
|
|
395
341
|
return;
|
|
396
|
-
// `not-found` and `busy` are how the engine says the run is already ending and will not read
|
|
397
|
-
// another message. Anything else is a refusal of the message itself, with the run still live.
|
|
398
342
|
const ending = error instanceof EngineRefusal && (error.code === 'not-found' || error.code === 'busy');
|
|
399
343
|
if (!ending) {
|
|
400
344
|
this.emit({ type: 'error', message: error instanceof Error ? error.message : String(error) });
|
|
401
345
|
return;
|
|
402
346
|
}
|
|
403
|
-
// The message becomes the next run. The wait ends with the run, with the engine (an exit sets
|
|
404
|
-
// idle), or at the bound, so nothing queued behind it is held indefinitely.
|
|
405
347
|
await this.whenIdle(ENDING_WAIT_MS);
|
|
406
348
|
if (this.closed)
|
|
407
349
|
return;
|
|
408
|
-
// Stop was pressed after this message was sent. It covers the message too: starting a run for
|
|
409
|
-
// it now would set Graph Manager working again right after the user stopped it.
|
|
410
350
|
if (this.stops !== stops) {
|
|
411
351
|
this.emit({ type: 'error', message: STOPPED_UNREAD_MESSAGE });
|
|
412
352
|
return;
|
|
@@ -417,9 +357,6 @@ export class GraphManagerChat {
|
|
|
417
357
|
}
|
|
418
358
|
}
|
|
419
359
|
}
|
|
420
|
-
// Messages the last run never read come first, so the agent takes them in the order they were
|
|
421
|
-
// sent. When they do not fit in one task with this one they stay queued, and are steered into
|
|
422
|
-
// the run this message starts.
|
|
423
360
|
const carried = [...this.unread, task].join('\n\n');
|
|
424
361
|
if (this.unread.length && carried.length <= MANAGER_TASK_MAX_CHARS) {
|
|
425
362
|
this.unread = [];
|
|
@@ -428,18 +365,12 @@ export class GraphManagerChat {
|
|
|
428
365
|
}
|
|
429
366
|
await this.start(task, turn.provider, turn.model, graphName(turn.graph));
|
|
430
367
|
}
|
|
431
|
-
/**
|
|
432
|
-
* Hands the engine every message a run ended without reading. A message leaves `unread` only when
|
|
433
|
-
* it is on its way to an engine: as the next run when nothing is working, else steered into the run
|
|
434
|
-
* that is. A run that is itself ending refuses the steer, and the message then waits for the run after it.
|
|
435
|
-
*/
|
|
436
368
|
async deliverUnread() {
|
|
437
369
|
while (this.unread.length && !this.closed) {
|
|
438
370
|
const chosen = this.lastModel;
|
|
439
371
|
if (!chosen)
|
|
440
372
|
return;
|
|
441
373
|
if (this.isIdle()) {
|
|
442
|
-
// As many as one task holds, and always at least the oldest.
|
|
443
374
|
let taken = 1;
|
|
444
375
|
while (taken < this.unread.length && this.unread.slice(0, taken + 1).join('\n\n').length <= MANAGER_TASK_MAX_CHARS)
|
|
445
376
|
taken++;
|
|
@@ -449,7 +380,6 @@ export class GraphManagerChat {
|
|
|
449
380
|
const text = this.unread[0];
|
|
450
381
|
const engine = this.engine;
|
|
451
382
|
if (this.runId === undefined || !engine) {
|
|
452
|
-
// A run is starting or its engine is going: the message waits for whichever comes of it.
|
|
453
383
|
await this.whenIdle(ENDING_WAIT_MS);
|
|
454
384
|
if (!this.isIdle())
|
|
455
385
|
return;
|
|
@@ -457,7 +387,6 @@ export class GraphManagerChat {
|
|
|
457
387
|
}
|
|
458
388
|
try {
|
|
459
389
|
await this.request(engine, 'run.steer', { runId: this.runId, sessionId: this.sessionId, text });
|
|
460
|
-
// Stop may have taken the message while the engine was answering.
|
|
461
390
|
if (this.unread[0] === text)
|
|
462
391
|
this.unread.shift();
|
|
463
392
|
}
|
|
@@ -465,30 +394,21 @@ export class GraphManagerChat {
|
|
|
465
394
|
if (this.unread[0] !== text)
|
|
466
395
|
continue;
|
|
467
396
|
if (error instanceof EngineStopped) {
|
|
468
|
-
// A deliberate stop keeps the message for the next run; a crash has set the chat idle.
|
|
469
397
|
if (!this.isIdle())
|
|
470
398
|
return;
|
|
471
399
|
continue;
|
|
472
400
|
}
|
|
473
401
|
if (!(error instanceof EngineRefusal && (error.code === 'not-found' || error.code === 'busy'))) {
|
|
474
|
-
// A refusal of the message itself: no engine will take it, and the user is told.
|
|
475
402
|
this.unread.shift();
|
|
476
403
|
this.emit({ type: 'error', message: error instanceof Error ? error.message : String(error) });
|
|
477
404
|
continue;
|
|
478
405
|
}
|
|
479
406
|
await this.whenIdle(ENDING_WAIT_MS);
|
|
480
|
-
// Still not over at the bound: the message stays for the next message's run to carry.
|
|
481
407
|
if (!this.isIdle())
|
|
482
408
|
return;
|
|
483
409
|
}
|
|
484
410
|
}
|
|
485
411
|
}
|
|
486
|
-
/**
|
|
487
|
-
* Moves the working run to the pair a message chose, when it differs from the pair the run is on.
|
|
488
|
-
* `overrideAllNodes: false` is the scope `run.start` gave the first pair: the run's own, which
|
|
489
|
-
* Graph Manager's one agent node (it names no model) and whatever it delegates to answer from.
|
|
490
|
-
* Undefined when the run is on the pair; otherwise why it is not.
|
|
491
|
-
*/
|
|
492
412
|
async switchRunModel(engine, runId, provider, model) {
|
|
493
413
|
const running = this.runModel;
|
|
494
414
|
if (running === undefined || (running.provider === provider && running.model === model))
|
|
@@ -516,12 +436,9 @@ export class GraphManagerChat {
|
|
|
516
436
|
const id = record(created.session).id;
|
|
517
437
|
if (typeof id !== 'string')
|
|
518
438
|
throw new Error('Graph Manager could not start its conversation.');
|
|
519
|
-
// The rename pins the name, so the engine's automatic titling leaves it alone.
|
|
520
439
|
await this.request(engine, 'sessions.rename', { id, name: title });
|
|
521
440
|
this.sessionId = id;
|
|
522
441
|
}
|
|
523
|
-
// `continueSession` extends the session just created instead of forking it, which a start
|
|
524
|
-
// that only names a session would do, leaving an empty copy behind for every conversation.
|
|
525
442
|
const started = await this.request(engine, 'run.start', {
|
|
526
443
|
workspace: this.workspace, sessionId: this.sessionId, continueSession: true, task,
|
|
527
444
|
provider, model, graph: GRAPH_MANAGER_GRAPH_ID, runPermissions: 'ask-for-approval',
|
|
@@ -529,7 +446,6 @@ export class GraphManagerChat {
|
|
|
529
446
|
if (typeof started.sessionId === 'string')
|
|
530
447
|
this.sessionId = started.sessionId;
|
|
531
448
|
this.runModel = { provider, model };
|
|
532
|
-
// A run that already ended has reported it; only a live one is still working.
|
|
533
449
|
if (typeof started.runId === 'string' && started.runId !== this.finishedRunId) {
|
|
534
450
|
this.runId = started.runId;
|
|
535
451
|
if (this.state === 'starting')
|
|
@@ -573,7 +489,6 @@ export class GraphManagerChat {
|
|
|
573
489
|
let failReady;
|
|
574
490
|
let markClosed;
|
|
575
491
|
const ready = new Promise((done, fail) => { markReady = done; failReady = fail; });
|
|
576
|
-
// Awaited by whoever starts a run; a stop nobody is waiting on must not be an unhandled rejection.
|
|
577
492
|
ready.catch(() => { });
|
|
578
493
|
const engine = {
|
|
579
494
|
child, lines: createInterface({ input: child.stdout }), ready,
|
|
@@ -602,15 +517,12 @@ export class GraphManagerChat {
|
|
|
602
517
|
this.engine = undefined;
|
|
603
518
|
if (engine.stopping || this.closed)
|
|
604
519
|
return;
|
|
605
|
-
// The run died with the engine, and its session may still carry that run's claim, so the next
|
|
606
|
-
// message begins a new session on a new engine.
|
|
607
520
|
this.sessionId = undefined;
|
|
608
521
|
const tail = engine.stderr.trim().split('\n').at(-1)?.trim();
|
|
609
522
|
this.emit({ type: 'error', message: `Graph Manager stopped unexpectedly (${detail}). Send your message again to restart it.${tail ? `\n${tail}` : ''}` });
|
|
610
523
|
this.finish(this.runId);
|
|
611
524
|
};
|
|
612
525
|
child.stderr.on('data', chunk => { engine.stderr = (engine.stderr + String(chunk)).slice(-8_192); });
|
|
613
|
-
// A write into a pipe whose reader has gone is followed by the close that reports it.
|
|
614
526
|
child.stdin.on('error', () => { });
|
|
615
527
|
child.on('error', error => gone(error.message));
|
|
616
528
|
child.once('close', code => gone(`exit ${code ?? 'signal'}`));
|
|
@@ -638,7 +550,6 @@ export class GraphManagerChat {
|
|
|
638
550
|
const data = record(message.data);
|
|
639
551
|
if (message.event === 'ready') {
|
|
640
552
|
clearTimeout(startup);
|
|
641
|
-
// Without run-scoped permissions the run would take the workspace's saved mode, not Ask for approval.
|
|
642
553
|
if (Array.isArray(data.capabilities) && data.capabilities.includes('run.start.runPermissions'))
|
|
643
554
|
markReady();
|
|
644
555
|
else
|
|
@@ -661,7 +572,6 @@ export class GraphManagerChat {
|
|
|
661
572
|
engine.child.stdin.write(JSON.stringify({ id, method, params }) + '\n');
|
|
662
573
|
});
|
|
663
574
|
}
|
|
664
|
-
/** A deliberate stop: EOF lets the engine finish its own cleanup, and it is reaped if it does not. */
|
|
665
575
|
async stopEngine(engine) {
|
|
666
576
|
engine.stopping = true;
|
|
667
577
|
if (this.engine === engine)
|
|
@@ -674,6 +584,12 @@ export class GraphManagerChat {
|
|
|
674
584
|
else if (event === 'run.event')
|
|
675
585
|
this.onRunEvent(record(data.event));
|
|
676
586
|
else if (event === 'run.approval' && typeof data.id === 'string') {
|
|
587
|
+
if (this.publishesOpenGraph(data)) {
|
|
588
|
+
// In the editor Graph Manager's edits stay on the canvas unsaved; the user saves them.
|
|
589
|
+
if (this.engine)
|
|
590
|
+
void this.request(this.engine, 'run.approve', { id: data.id, approved: false }).catch(() => { });
|
|
591
|
+
return;
|
|
592
|
+
}
|
|
677
593
|
this.prompts.add(data.id);
|
|
678
594
|
this.emit({ type: 'approval', id: data.id, text: this.describe(String(data.name), data.arguments) });
|
|
679
595
|
}
|
|
@@ -686,7 +602,6 @@ export class GraphManagerChat {
|
|
|
686
602
|
if (data.state === 'awaiting-approval' || data.state === 'awaiting-input')
|
|
687
603
|
this.setState('awaiting');
|
|
688
604
|
else if (data.state === 'running') {
|
|
689
|
-
// The engine reports running again only once nothing is pending, however each prompt was settled.
|
|
690
605
|
this.resolvePrompts();
|
|
691
606
|
this.setState('working');
|
|
692
607
|
}
|
|
@@ -698,13 +613,10 @@ export class GraphManagerChat {
|
|
|
698
613
|
if (event === 'run.failed' && !cancelled)
|
|
699
614
|
this.emit({ type: 'error', message: String(data.message ?? 'The run failed.') });
|
|
700
615
|
this.finish(runId);
|
|
701
|
-
// A message queued too late for the run to read is still the user's request: it becomes the next run.
|
|
702
616
|
const unread = Array.isArray(data.undeliveredSteers)
|
|
703
617
|
? data.undeliveredSteers.map(entry => record(entry).text).filter((text) => typeof text === 'string')
|
|
704
618
|
: [];
|
|
705
619
|
if (unread.length && !cancelled && !this.closed) {
|
|
706
|
-
// Queued behind whatever is already being delivered. A message whose steer this run refused
|
|
707
|
-
// starts the next run first, and takes these with it.
|
|
708
620
|
this.unread.push(...unread);
|
|
709
621
|
void this.enqueue(() => this.deliverUnread());
|
|
710
622
|
}
|
|
@@ -725,7 +637,6 @@ export class GraphManagerChat {
|
|
|
725
637
|
return;
|
|
726
638
|
const line = this.describe(String(data.name), data.arguments);
|
|
727
639
|
const id = typeof data.toolCallId === 'string' && data.toolCallId ? data.toolCallId : `tool-${++this.toolRows}`;
|
|
728
|
-
// A call id the engine reuses (a resumed call) reopens its row rather than adding a second one.
|
|
729
640
|
const opened = { type: 'tool', id, text: line, ...managerToolParts(String(data.name), data.arguments, this.openGraphId), status: 'running', startedAt: this.now() };
|
|
730
641
|
if (!this.replace(entry => entry.type === 'tool' && entry.id === id, () => opened, opened))
|
|
731
642
|
this.emit(opened);
|
|
@@ -752,23 +663,123 @@ export class GraphManagerChat {
|
|
|
752
663
|
else if (event.type === 'node.tool.completed') {
|
|
753
664
|
this.settleTool(data.toolCallId, 'done');
|
|
754
665
|
const call = this.endGraphCall(data.toolCallId);
|
|
755
|
-
// The reply may be clipped, or quoted inside a preview, so the draft id is found rather than parsed.
|
|
756
666
|
const draft = call?.begins === undefined ? undefined : /\\*"draftId\\*"\s*:\s*\\*"([a-f0-9-]{36})\\*"/i.exec(String(data.output ?? ''))?.[1];
|
|
757
667
|
if (draft !== undefined && call?.begins !== undefined) {
|
|
758
668
|
this.drafts.delete(draft);
|
|
759
669
|
this.drafts.set(draft, call.begins);
|
|
760
670
|
if (this.drafts.size > DRAFTS_MAX)
|
|
761
671
|
this.drafts.delete(this.drafts.keys().next().value);
|
|
672
|
+
const known = draftState(data.output);
|
|
673
|
+
this.draftStates.delete(draft);
|
|
674
|
+
if (known)
|
|
675
|
+
this.draftStates.set(draft, known);
|
|
676
|
+
if (this.draftStates.size > DRAFTS_MAX)
|
|
677
|
+
this.draftStates.delete(this.draftStates.keys().next().value);
|
|
762
678
|
}
|
|
763
679
|
if (call?.edits) {
|
|
764
|
-
const edit = draftEdit(call.edits.action, call.edits.args, data.output);
|
|
680
|
+
const edit = draftEdit(call.edits.action, call.edits.args, data.output) ?? this.editFromArguments(call.edits.action, call.edits.args);
|
|
765
681
|
if (edit)
|
|
766
|
-
this.
|
|
682
|
+
this.liveEdit(call.edits.graphId, call.edits.action, call.edits.args, edit);
|
|
767
683
|
}
|
|
768
684
|
this.checkRevision(call?.publishes ?? call?.removes);
|
|
769
685
|
}
|
|
770
686
|
}
|
|
771
|
-
|
|
687
|
+
publishesOpenGraph(data) {
|
|
688
|
+
if (data.name !== 'graphs' || !this.openGraphId || this.openGraphId === BUNDLED_GRAPH_ID)
|
|
689
|
+
return false;
|
|
690
|
+
const args = toolArguments(data.arguments);
|
|
691
|
+
if (args.action !== 'andorra_graph_publish')
|
|
692
|
+
return false;
|
|
693
|
+
const draftId = record(args.args).draftId;
|
|
694
|
+
return typeof draftId === 'string' && this.drafts.get(draftId)?.id === this.openGraphId;
|
|
695
|
+
}
|
|
696
|
+
/**
|
|
697
|
+
* The engine clips a tool's output at 24,000 characters, so the reply to a call that set a long prompt
|
|
698
|
+
* is not readable JSON. The call succeeded, so its own arguments say what the draft now holds: an
|
|
699
|
+
* upsert's whole node or connection, or a patch over the draft's (or else the canvas's) copy of the step.
|
|
700
|
+
*/
|
|
701
|
+
editFromArguments(action, args) {
|
|
702
|
+
const node = record(args.node), edge = record(args.edge), patch = record(args.patch);
|
|
703
|
+
if (action === 'andorra_graph_node_upsert')
|
|
704
|
+
return typeof node.id === 'string' && node.id ? { kind: 'node', node: clone(node) } : undefined;
|
|
705
|
+
if (action === 'andorra_graph_edge_upsert')
|
|
706
|
+
return typeof edge.id === 'string' && typeof edge.source === 'string' && typeof edge.target === 'string' ? { kind: 'edge', edge: clone(edge) } : undefined;
|
|
707
|
+
if (action !== 'andorra_graph_node_patch' || typeof args.nodeId !== 'string' || !Object.keys(patch).length)
|
|
708
|
+
return undefined;
|
|
709
|
+
const draftId = typeof args.draftId === 'string' ? args.draftId : '';
|
|
710
|
+
const base = this.draftStates.get(draftId)?.nodes[args.nodeId] ?? this.canvas?.nodes[args.nodeId];
|
|
711
|
+
return base ? { kind: 'node', node: { ...clone(base), ...clone(patch), id: args.nodeId } } : undefined;
|
|
712
|
+
}
|
|
713
|
+
liveEdit(graphId, action, args, edit) {
|
|
714
|
+
const patched = action === 'andorra_graph_node_patch' ? Object.keys(record(args.patch)) : undefined;
|
|
715
|
+
const shown = graphId === this.openGraphId ? this.reconcile(typeof args.draftId === 'string' ? args.draftId : '', edit, patched) : edit;
|
|
716
|
+
if (!shown)
|
|
717
|
+
return;
|
|
718
|
+
const entry = { seq: ++this.editSeq, graphId, edit: shown, stream: this.editStream };
|
|
719
|
+
this.liveEdits.push(entry);
|
|
720
|
+
if (this.liveEdits.length > LIVE_EDITS_MAX)
|
|
721
|
+
this.liveEdits.splice(0, this.liveEdits.length - LIVE_EDITS_MAX);
|
|
722
|
+
this.broadcast({ type: 'graph.edit', ...entry });
|
|
723
|
+
}
|
|
724
|
+
/**
|
|
725
|
+
* A draft opened in edit mode starts from the latest saved revision, which lacks the unsaved changes on
|
|
726
|
+
* the canvas. A patched node from that draft would put stale fields back, so a patch of a step the
|
|
727
|
+
* canvas holds carries only the fields it names, plus any the backend changed with them. An upsert
|
|
728
|
+
* states the whole step or connection, so it is shown as given.
|
|
729
|
+
*/
|
|
730
|
+
reconcile(draftId, edit, patched) {
|
|
731
|
+
const draft = this.draftStates.get(draftId), canvas = this.canvas;
|
|
732
|
+
if (edit.kind === 'node') {
|
|
733
|
+
const id = String(edit.node.id);
|
|
734
|
+
const before = draft?.nodes[id], current = canvas?.nodes[id];
|
|
735
|
+
if (draft)
|
|
736
|
+
draft.nodes[id] = clone(edit.node);
|
|
737
|
+
let node = edit.node;
|
|
738
|
+
if (patched) {
|
|
739
|
+
// The draft still had a step the canvas no longer has: it was removed after the draft opened.
|
|
740
|
+
if (canvas && !current)
|
|
741
|
+
return undefined;
|
|
742
|
+
if (current)
|
|
743
|
+
node = overlay(current, before ?? edit.node, edit.node, patched);
|
|
744
|
+
}
|
|
745
|
+
if (canvas)
|
|
746
|
+
canvas.nodes[id] = clone(node);
|
|
747
|
+
return { kind: 'node', node };
|
|
748
|
+
}
|
|
749
|
+
if (edit.kind === 'edge') {
|
|
750
|
+
const id = String(edit.edge.id);
|
|
751
|
+
draft?.edges.set(id, clone(edit.edge));
|
|
752
|
+
if (canvas) {
|
|
753
|
+
const index = canvas.edges.findIndex(item => record(item).id === id);
|
|
754
|
+
if (index >= 0)
|
|
755
|
+
canvas.edges[index] = clone(edit.edge);
|
|
756
|
+
else
|
|
757
|
+
canvas.edges.push(clone(edit.edge));
|
|
758
|
+
}
|
|
759
|
+
return edit;
|
|
760
|
+
}
|
|
761
|
+
if (edit.kind === 'node.remove') {
|
|
762
|
+
const touches = (item) => item.source === edit.nodeId || item.target === edit.nodeId;
|
|
763
|
+
if (draft) {
|
|
764
|
+
delete draft.nodes[edit.nodeId];
|
|
765
|
+
for (const [key, item] of draft.edges)
|
|
766
|
+
if (touches(item))
|
|
767
|
+
draft.edges.delete(key);
|
|
768
|
+
}
|
|
769
|
+
if (canvas) {
|
|
770
|
+
delete canvas.nodes[edit.nodeId];
|
|
771
|
+
canvas.edges = canvas.edges.filter(item => !touches(item));
|
|
772
|
+
}
|
|
773
|
+
}
|
|
774
|
+
else if (edit.kind === 'edge.remove') {
|
|
775
|
+
draft?.edges.delete(edit.edgeId);
|
|
776
|
+
if (canvas)
|
|
777
|
+
canvas.edges = canvas.edges.filter(item => record(item).id !== edit.edgeId);
|
|
778
|
+
}
|
|
779
|
+
else if (canvas)
|
|
780
|
+
Object.assign(canvas.fields, clone(edit.patch));
|
|
781
|
+
return edit;
|
|
782
|
+
}
|
|
772
783
|
settleTool(toolCallId, status, reason) {
|
|
773
784
|
if (typeof toolCallId !== 'string' || !toolCallId)
|
|
774
785
|
return;
|
|
@@ -778,11 +789,6 @@ export class GraphManagerChat {
|
|
|
778
789
|
const detail = reason ? { reason } : {};
|
|
779
790
|
this.replace(entry => entry.type === 'tool' && entry.id === toolCallId && entry.status === 'running', entry => ({ ...entry, status, ...detail, endedAt }), { type: 'tool.settled', id: toolCallId, status, ...detail, endedAt });
|
|
780
791
|
}
|
|
781
|
-
/**
|
|
782
|
-
* One model call's reasoning, folded into a single row the way the app's transcript folds it: a
|
|
783
|
-
* retried request restarts the row, deltas grow it, and the completion settles it with the
|
|
784
|
-
* authoritative text, or takes it away when the call streamed no reasoning at all.
|
|
785
|
-
*/
|
|
786
792
|
onReasoning(type, data) {
|
|
787
793
|
const reasoningId = typeof data.reasoningId === 'string' && data.reasoningId ? data.reasoningId : undefined;
|
|
788
794
|
if (!reasoningId)
|
|
@@ -798,7 +804,6 @@ export class GraphManagerChat {
|
|
|
798
804
|
else if (type === 'agent.reasoning.delta') {
|
|
799
805
|
if (!text)
|
|
800
806
|
return;
|
|
801
|
-
// A delta past the row's completion belongs to a stream the engine already closed.
|
|
802
807
|
if (!this.replace(entry => mine(entry) && entry.type === 'thought' && entry.status === 'thinking', entry => ({ ...entry, text: entry.text + text }), { type: 'thought.delta', id, text })) {
|
|
803
808
|
if (!this.transcript.some(mine))
|
|
804
809
|
this.emit({ type: 'thought', id, text, status: 'thinking', startedAt: this.now() });
|
|
@@ -827,10 +832,6 @@ export class GraphManagerChat {
|
|
|
827
832
|
this.emit(settled);
|
|
828
833
|
}
|
|
829
834
|
}
|
|
830
|
-
/**
|
|
831
|
-
* Rows a run left open when it ended: a call it never reported the end of is stopped, a thought
|
|
832
|
-
* still streaming keeps what it streamed, and one that streamed nothing is taken away.
|
|
833
|
-
*/
|
|
834
835
|
settleOpenRows() {
|
|
835
836
|
const endedAt = this.now();
|
|
836
837
|
for (const entry of [...this.transcript]) {
|
|
@@ -859,16 +860,6 @@ export class GraphManagerChat {
|
|
|
859
860
|
this.graphCalls.delete(toolCallId);
|
|
860
861
|
return call;
|
|
861
862
|
}
|
|
862
|
-
/**
|
|
863
|
-
* The `graphs` tool also lists and reads, so a save is told by the stored revision rising. The
|
|
864
|
-
* open graph is checked after every call. A publish of another graph (the only way the agent can
|
|
865
|
-
* save its work on the bundled preset) is checked under that graph's id, and reported with the
|
|
866
|
-
* name it was begun with so the panel can offer to open it; so is a delete or a restore of one.
|
|
867
|
-
*
|
|
868
|
-
* Deleting a graph also raises its revision: the new one carries `metadata.deletedAt`. That is
|
|
869
|
-
* reported as `graph.deleted`, never as a save, so no panel loads a deleted graph as an editable
|
|
870
|
-
* one. A restore publishes a live revision above it, which is a save like any other.
|
|
871
|
-
*/
|
|
872
863
|
checkRevision(published) {
|
|
873
864
|
const other = published !== undefined && published.id !== this.openGraphId ? published : undefined;
|
|
874
865
|
const id = other?.id ?? this.openGraphId;
|
|
@@ -880,7 +871,6 @@ export class GraphManagerChat {
|
|
|
880
871
|
return;
|
|
881
872
|
const { revision } = latest;
|
|
882
873
|
if (other) {
|
|
883
|
-
// The user may have opened that graph since: its saves are then the open graph's to report.
|
|
884
874
|
if (id === this.openGraphId || revision <= (this.otherRevisions.get(id) ?? 0))
|
|
885
875
|
return;
|
|
886
876
|
this.otherRevisions.set(id, revision);
|
|
@@ -893,11 +883,9 @@ export class GraphManagerChat {
|
|
|
893
883
|
this.emit(latest.deleted ? { type: 'graph.deleted', graphId: id } : { type: 'graph.saved', graphId: id, revision });
|
|
894
884
|
});
|
|
895
885
|
}
|
|
896
|
-
/** The run is over, however it ended. */
|
|
897
886
|
finish(runId) {
|
|
898
887
|
if (runId !== undefined)
|
|
899
888
|
this.finishedRunId = runId;
|
|
900
|
-
// A call the run never reported the end of ended with the run.
|
|
901
889
|
this.graphCalls.clear();
|
|
902
890
|
this.settleOpenRows();
|
|
903
891
|
this.runId = undefined;
|
|
@@ -923,7 +911,6 @@ export class GraphManagerChat {
|
|
|
923
911
|
wake();
|
|
924
912
|
this.armIdleStop();
|
|
925
913
|
}
|
|
926
|
-
/** Read through a call so a check after an await sees the state as it is then. */
|
|
927
914
|
isIdle() { return this.state === 'idle'; }
|
|
928
915
|
whenIdle(ms) {
|
|
929
916
|
if (this.state === 'idle' || this.closed)
|
|
@@ -934,7 +921,6 @@ export class GraphManagerChat {
|
|
|
934
921
|
this.idleWaiters.push(() => { clearTimeout(timer); done(); });
|
|
935
922
|
});
|
|
936
923
|
}
|
|
937
|
-
/** An engine is kept while a run is working or waiting on the user, and while any panel is connected. */
|
|
938
924
|
armIdleStop() {
|
|
939
925
|
clearTimeout(this.idleTimer);
|
|
940
926
|
this.idleTimer = undefined;
|
|
@@ -942,7 +928,6 @@ export class GraphManagerChat {
|
|
|
942
928
|
return;
|
|
943
929
|
const engine = this.engine;
|
|
944
930
|
this.idleTimer = setTimeout(() => {
|
|
945
|
-
// The session is on disk, so the conversation continues on the next engine.
|
|
946
931
|
if (this.engine === engine && this.state === 'idle' && this.listeners.size === 0)
|
|
947
932
|
void this.stopEngine(engine);
|
|
948
933
|
}, this.idleMs);
|
|
@@ -954,17 +939,12 @@ export class GraphManagerChat {
|
|
|
954
939
|
this.transcript.push(event);
|
|
955
940
|
this.broadcast(event);
|
|
956
941
|
}
|
|
957
|
-
/** Sends an event without adding a row: it changes a row the transcript already holds. */
|
|
958
942
|
broadcast(event) {
|
|
959
943
|
if (this.closed)
|
|
960
944
|
return;
|
|
961
945
|
for (const listener of [...this.listeners])
|
|
962
946
|
this.deliverTo(listener, event);
|
|
963
947
|
}
|
|
964
|
-
/**
|
|
965
|
-
* Replaces the latest row `match` finds with `next` of it, and tells the panels with `event`.
|
|
966
|
-
* False when no row matches, so the caller can add one instead.
|
|
967
|
-
*/
|
|
968
948
|
replace(match, next, event) {
|
|
969
949
|
for (let index = this.transcript.length - 1; index >= 0; index--) {
|
|
970
950
|
if (!match(this.transcript[index]))
|
|
@@ -976,10 +956,9 @@ export class GraphManagerChat {
|
|
|
976
956
|
return false;
|
|
977
957
|
}
|
|
978
958
|
deliverTo(listener, event) {
|
|
979
|
-
// One panel's broken connection must not cost the others the event.
|
|
980
959
|
try {
|
|
981
960
|
listener(event);
|
|
982
961
|
}
|
|
983
|
-
catch {
|
|
962
|
+
catch { }
|
|
984
963
|
}
|
|
985
964
|
}
|