@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
|
@@ -1,9 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* The tools the Andorra agent-control MCP server advertises, as plain data.
|
|
3
|
-
*
|
|
4
|
-
* Kept apart from `agent-mcp.ts` so the engine can describe its built-in `graphs` tool without
|
|
5
|
-
* loading the graph backend (and its sync, membership and subagent modules) until a graph action runs.
|
|
6
|
-
*/
|
|
7
1
|
export interface AgentMcpToolSpec {
|
|
8
2
|
name: string;
|
|
9
3
|
description: string;
|
|
@@ -15,7 +9,5 @@ export interface AgentMcpToolSpec {
|
|
|
15
9
|
};
|
|
16
10
|
}
|
|
17
11
|
export declare const AGENT_MCP_CATALOG: readonly AgentMcpToolSpec[];
|
|
18
|
-
/** The tool names this server advertises; bundled skills that drive it are checked against this list. */
|
|
19
12
|
export declare const AGENT_MCP_TOOL_NAMES: readonly string[];
|
|
20
|
-
/** Graph authoring: what the engine's built-in `graphs` tool offers. Session and subagent tools stay MCP-only. */
|
|
21
13
|
export declare const AGENT_MCP_GRAPH_TOOLS: readonly AgentMcpToolSpec[];
|
|
@@ -34,7 +34,5 @@ export const AGENT_MCP_CATALOG = [
|
|
|
34
34
|
{ name: 'andorra_subagent_result', description: 'Read the subagent run outcome. waitMs (0-60000) waits for completion within the call; otherwise returns running immediately when unfinished. The finished reply carries the full run result including completion summary and status. The runId must be the one the start returned.', inputSchema: obj({ waitMs: { type: 'integer', minimum: 0, maximum: 60000 }, runId: str }, ['runId']) },
|
|
35
35
|
{ name: 'andorra_subagent_cancel', description: 'Cancel the subagent run. The runId must be the one the start returned, so a delayed cancellation cannot stop a run that replaced it.', inputSchema: obj({ runId: str }, ['runId']) },
|
|
36
36
|
];
|
|
37
|
-
/** The tool names this server advertises; bundled skills that drive it are checked against this list. */
|
|
38
37
|
export const AGENT_MCP_TOOL_NAMES = AGENT_MCP_CATALOG.map(tool => tool.name);
|
|
39
|
-
/** Graph authoring: what the engine's built-in `graphs` tool offers. Session and subagent tools stay MCP-only. */
|
|
40
38
|
export const AGENT_MCP_GRAPH_TOOLS = AGENT_MCP_CATALOG.filter(tool => tool.name.startsWith('andorra_graph_') || tool.name === 'andorra_graphs_list' || tool.name === 'andorra_providers_list');
|
package/dist/src/agent-mcp.d.ts
CHANGED
|
@@ -27,33 +27,18 @@ export type AgentMcpReply = {
|
|
|
27
27
|
type GraphSyncClient = Pick<GraphSync, 'start' | 'waitForSync' | 'close' | 'sync' | 'status' | 'reviveGraph'>;
|
|
28
28
|
export interface AgentMcpBackendOptions {
|
|
29
29
|
directory?: string;
|
|
30
|
-
/** Test-only or embedded-host override. Production graph access enforces paid membership and account ownership. */
|
|
31
|
-
/** `free` holds the access to the free graph allowance; production reads it from membership. */
|
|
32
30
|
graphAccess?: () => Promise<{
|
|
33
31
|
directory: string;
|
|
34
32
|
subject?: string;
|
|
35
33
|
free?: boolean;
|
|
36
34
|
}>;
|
|
37
|
-
/** Test-only sync boundary for deterministic concurrency and initial-sync checks. */
|
|
38
35
|
graphSyncFactory?: (directory: string, subject: string) => GraphSyncClient;
|
|
39
|
-
/** Test-only stable store reader for reproducing inter-page session mutations. */
|
|
40
36
|
sessionStore?: Pick<SessionStore, 'list'>;
|
|
41
|
-
/** Test-only config reader for reproducing changes during the final provider reload. */
|
|
42
37
|
providerConfig?: () => ReturnType<typeof loadConfig>;
|
|
43
|
-
/** Test-only identity readers for reproducing cross-account auth races. */
|
|
44
38
|
authStatus?: typeof getAuthStatus;
|
|
45
39
|
membershipStatus?: typeof getMembership;
|
|
46
|
-
/** Embedded host override for subagent runs; production runs use the caller's working directory. */
|
|
47
40
|
subagentWorkspace?: string;
|
|
48
|
-
/** Test-only adapter so subagent runs stay offline and deterministic. */
|
|
49
41
|
subagentAdapterFactory?: (provider: import('./providers.js').ProviderConfig) => ModelAdapter;
|
|
50
|
-
/**
|
|
51
|
-
* Whether construction sweeps the home for runs a crashed process left `running` (default true).
|
|
52
|
-
*
|
|
53
|
-
* The stdio server needs it: a host that only talks to the server would otherwise never see its own
|
|
54
|
-
* crashed runs classified. The engine's built-in `graphs` tool passes false: it starts no subagent
|
|
55
|
-
* runs, and the run records of its home belong to the engine that hosts it.
|
|
56
|
-
*/
|
|
57
42
|
recoverRuns?: boolean;
|
|
58
43
|
}
|
|
59
44
|
export declare const GRAPH_AGENT_GUIDE: string;
|
|
@@ -74,13 +59,6 @@ export declare class AgentMcpError extends Error {
|
|
|
74
59
|
}[];
|
|
75
60
|
});
|
|
76
61
|
}
|
|
77
|
-
/**
|
|
78
|
-
* Where a node new to a graph goes on the canvas. A node placed in free space keeps its position. One
|
|
79
|
-
* with no position goes a stage to the right of the rightmost card, level with it; one that lands on
|
|
80
|
-
* another card moves to the nearest spot that keeps a clear margin around every card, preferring a
|
|
81
|
-
* spot below, then above, then to the right. Existing cards never move. Undefined when the asked-for
|
|
82
|
-
* position is already free.
|
|
83
|
-
*/
|
|
84
62
|
export declare function placeNewNode(node: GraphNode, others: GraphNode[]): {
|
|
85
63
|
x: number;
|
|
86
64
|
y: number;
|
|
@@ -91,60 +69,26 @@ export declare class AgentMcpBackend {
|
|
|
91
69
|
private drafts;
|
|
92
70
|
private sync?;
|
|
93
71
|
private accessKey?;
|
|
94
|
-
/** An account's first snapshot reconciliation must finish before any reader sees its graphs. */
|
|
95
72
|
private initialSync?;
|
|
96
|
-
/** Subagent runs this process owns; one at a time, like every other engine surface. */
|
|
97
73
|
private readonly subagent;
|
|
98
|
-
/**
|
|
99
|
-
* The starts that are preparing and have published no run id yet.
|
|
100
|
-
*
|
|
101
|
-
* A count, not a flag: a second start that is refused while the first is still preparing
|
|
102
|
-
* releases its own reservation, and a flag it cleared would take the first start's with it.
|
|
103
|
-
*/
|
|
104
74
|
private starting;
|
|
105
|
-
/** Set when the connection closed: a start that begins after it must not launch a run. */
|
|
106
75
|
private closed;
|
|
107
76
|
constructor(options?: AgentMcpBackendOptions);
|
|
108
|
-
/** The startup recovery, finished before the first subagent start is accepted. */
|
|
109
77
|
private readonly recovery;
|
|
110
|
-
/**
|
|
111
|
-
* The run a control call is about.
|
|
112
|
-
*
|
|
113
|
-
* One backend can serve several requesters, and a new run may start as soon as the previous one
|
|
114
|
-
* has finished. A call that names the run it means is refused when that run is no longer the
|
|
115
|
-
* current one: a delayed result would otherwise report the next run's state, and a delayed
|
|
116
|
-
* cancellation would stop it.
|
|
117
|
-
*/
|
|
118
78
|
private assertSubagentRun;
|
|
119
79
|
close(): Promise<void>;
|
|
120
80
|
private graphAccess;
|
|
121
|
-
/** Graph storage is account-owned. Verify identity again after filesystem awaits
|
|
122
|
-
* and before releasing any graph data to an MCP caller. */
|
|
123
81
|
private assertGraphIdentity;
|
|
124
82
|
private obtainDraft;
|
|
125
83
|
private providers;
|
|
126
|
-
/**
|
|
127
|
-
* Soft-delete or restore: publish the next revision with metadata.deletedAt set or removed.
|
|
128
|
-
*
|
|
129
|
-
* The revision goes through the same save path as a publish, so free-tier rules and the optimistic
|
|
130
|
-
* revision check apply unchanged, and cloud sync carries the marker to every machine.
|
|
131
|
-
*/
|
|
132
84
|
private setDeleted;
|
|
133
|
-
/** Missing graph identity is not a broken graph. Tell the agent to list or create it. */
|
|
134
85
|
private readGraph;
|
|
135
86
|
private upsertNode;
|
|
136
87
|
private upsertEdge;
|
|
137
|
-
/**
|
|
138
|
-
* Run one tool call. `beforeSave` runs synchronously immediately before a revision is written
|
|
139
|
-
* (publish, delete, restore), after every await that precedes the write; throwing from it abandons
|
|
140
|
-
* the save. An embedding host uses it to refuse a save its task may no longer make (cancelled, or
|
|
141
|
-
* switched to Plan) while the call was waiting on sign-in checks or cloud sync.
|
|
142
|
-
*/
|
|
143
88
|
call(name: string, rawArgs?: unknown, options?: {
|
|
144
89
|
beforeSave?: () => void;
|
|
145
90
|
}): Promise<AgentMcpReply>;
|
|
146
91
|
private dispatch;
|
|
147
92
|
}
|
|
148
|
-
/** The tool names this server advertises; bundled skills that drive it are checked against this list. */
|
|
149
93
|
export { AGENT_MCP_TOOL_NAMES };
|
|
150
94
|
export declare function runAgentMcpServer(): Promise<number>;
|
package/dist/src/agent-mcp.js
CHANGED
|
@@ -9,7 +9,7 @@ import { stampGraphProviderProfiles } from './graph-provider-portability.js';
|
|
|
9
9
|
import { getAuthStatus } from './auth/index.js';
|
|
10
10
|
import { getMembership, PaidMembershipRequiredError } from './membership.js';
|
|
11
11
|
import { FREE_CUSTOM_GRAPH_LIMIT, FREE_GRAPH_LIMIT_MESSAGE, FreeTierLimitError, readGraphQuota, saveFreeTierGraph } from './graph-quota.js';
|
|
12
|
-
import { GraphConflictError, isDeletedGraph, listGraphs, loadGraph, migrateGraphForEditor, nodeOutcomes, saveGraph, validateGraph, withoutDeletedGraphs } from './graphs.js';
|
|
12
|
+
import { GraphConflictError, isDeletedGraph, listGraphs, loadGraph, migrateGraphForEditor, nodeOutcomes, optionalOutcomes, saveGraph, validateGraph, withoutDeletedGraphs } from './graphs.js';
|
|
13
13
|
import { getAgentSession, listAgentProjects, queryAgentSessions, scanAgentSessions, SessionQueryError } from './session-monitor.js';
|
|
14
14
|
import { AutomationStore } from './automations.js';
|
|
15
15
|
import { canonicalWorkspace, MAX_SUBAGENT_TASK_CHARS, SubagentInvalidArgumentError, SubagentProviderNotSetError, SubagentRunInProgressError, SubagentRunner, SubagentSelectionError } from './subagent-run.js';
|
|
@@ -38,6 +38,11 @@ export const GRAPH_AGENT_GUIDE = [
|
|
|
38
38
|
' For multi-outcome agents supply completion: {mode: "outcomes", outcomes: ["pass", "fail"]}.',
|
|
39
39
|
' Every declared outcome must have an outgoing edge unless completion.requireRoutes is explicitly false.',
|
|
40
40
|
' Agents created or modified through MCP must set provider; never assume the active provider is inherited.',
|
|
41
|
+
' subagents {enabled, maxConcurrent, maxTotal, maxDepth, workspace, modelPolicy, toolInheritance, context, roles}:',
|
|
42
|
+
' workspace is shared-read-only (default; roles only read), shared-write (writes in place; maxConcurrent 1 when roles write)',
|
|
43
|
+
' or worktree (each child gets its own Git worktree; required for writing roles on an Orchestrator; needs parent git write).',
|
|
44
|
+
' modelPolicy: inherit | specific | per-role. toolInheritance: restricted | inherit. context: selected | task-only.',
|
|
45
|
+
' Validation messages name the field and the values to set. This guide and those messages are the whole reference: never search source code for them.',
|
|
41
46
|
'condition: requires condition {source, path, equals}; ports true and false; source must run before it on every path.',
|
|
42
47
|
'loop: requires loop {maxIterations}; ports body and done. A body edge may return to the loop.',
|
|
43
48
|
' Node visits are unlimited unless the graph sets graph.limits.maxNodeVisits; 0 means unlimited there too.',
|
|
@@ -133,22 +138,16 @@ function draftId(args) {
|
|
|
133
138
|
return value;
|
|
134
139
|
}
|
|
135
140
|
const knownTypes = ['agent', 'end', 'join', 'parallel', 'condition', 'loop', 'action', 'approval'];
|
|
136
|
-
/** The editor's card: 210 wide, 94 tall with one outcome, and one `.output-port` row (25px) taller for each further one. */
|
|
137
141
|
const CARD_WIDTH = 210, CARD_HEIGHT = 94, PORT_HEIGHT = 25;
|
|
138
|
-
/** Where the editor draws a card that has no position: in a row along the top, by its place in the graph (`position` in src/graph-ui/app.js). */
|
|
139
142
|
const UNPLACED_SPACING = 290;
|
|
140
|
-
/** The largest coordinate a saved position may have (`validateGraph` in src/graphs.ts). */
|
|
141
143
|
const COORDINATE_LIMIT = 100_000;
|
|
142
|
-
/** The space kept clear around a placed card, so its routes have room to pass. */
|
|
143
144
|
const CARD_GAP_X = 60, CARD_GAP_Y = 40;
|
|
144
|
-
/** Placement steps across the canvas, and how far from the asked-for spot a free one is looked for. */
|
|
145
145
|
const PLACE_STEP = 40, PLACE_RINGS = 25;
|
|
146
146
|
const STAGE_SPACING = 300;
|
|
147
|
-
/** How many output ports a card draws; a node still being built may not have a readable set yet. */
|
|
148
147
|
const portCount = (node) => {
|
|
149
148
|
try {
|
|
150
149
|
const ports = nodeOutcomes(node);
|
|
151
|
-
return Array.isArray(ports) ? ports.length : 1;
|
|
150
|
+
return Array.isArray(ports) ? ports.length + optionalOutcomes(node).length : 1;
|
|
152
151
|
}
|
|
153
152
|
catch {
|
|
154
153
|
return 1;
|
|
@@ -157,20 +156,9 @@ const portCount = (node) => {
|
|
|
157
156
|
const footprint = (node, at) => ({ x: at.x, y: at.y, width: CARD_WIDTH, height: CARD_HEIGHT + Math.max(0, portCount(node) - 1) * PORT_HEIGHT });
|
|
158
157
|
const collides = (a, b) => a.x < b.x + b.width + CARD_GAP_X && b.x < a.x + a.width + CARD_GAP_X && a.y < b.y + b.height + CARD_GAP_Y && b.y < a.y + a.height + CARD_GAP_Y;
|
|
159
158
|
const validPoint = (value) => record(value) && Number.isFinite(value.x) && Number.isFinite(value.y);
|
|
160
|
-
/**
|
|
161
|
-
* Where a node new to a graph goes on the canvas. A node placed in free space keeps its position. One
|
|
162
|
-
* with no position goes a stage to the right of the rightmost card, level with it; one that lands on
|
|
163
|
-
* another card moves to the nearest spot that keeps a clear margin around every card, preferring a
|
|
164
|
-
* spot below, then above, then to the right. Existing cards never move. Undefined when the asked-for
|
|
165
|
-
* position is already free.
|
|
166
|
-
*/
|
|
167
159
|
export function placeNewNode(node, others) {
|
|
168
|
-
// A card with no position is still on the canvas, where the editor draws it: by its place in the
|
|
169
|
-
// graph as it will be once this node is in it. An integer-like id is enumerated first, so the new
|
|
170
|
-
// node can move every unplaced card one slot along.
|
|
171
160
|
const order = Object.keys({ ...Object.fromEntries(others.map(other => [other.id, true])), [node.id]: true });
|
|
172
161
|
const cards = others.map(other => footprint(other, validPoint(other.position) ? other.position : { x: order.indexOf(other.id) * UNPLACED_SPACING, y: 0 }));
|
|
173
|
-
// A spot past the canvas's coordinate limit would make the graph unpublishable.
|
|
174
162
|
const inBounds = (at) => Math.abs(Math.round(at.x)) <= COORDINATE_LIMIT && Math.abs(Math.round(at.y)) <= COORDINATE_LIMIT;
|
|
175
163
|
const clamp = (value) => Math.round(Math.max(-COORDINATE_LIMIT, Math.min(COORDINATE_LIMIT, value)));
|
|
176
164
|
const free = (at) => inBounds(at) && !cards.some(card => collides(footprint(node, at), card));
|
|
@@ -182,7 +170,6 @@ export function placeNewNode(node, others) {
|
|
|
182
170
|
const origin = { x: clamp(wanted.x), y: clamp(wanted.y) };
|
|
183
171
|
if (free(origin))
|
|
184
172
|
return { x: Math.round(origin.x), y: Math.round(origin.y) };
|
|
185
|
-
// Spots nearest the origin first; among equally near ones, below before above before to the right.
|
|
186
173
|
const spots = [];
|
|
187
174
|
for (let dx = 0; dx <= PLACE_RINGS; dx++)
|
|
188
175
|
for (let dy = -PLACE_RINGS; dy <= PLACE_RINGS; dy++) {
|
|
@@ -194,15 +181,10 @@ export function placeNewNode(node, others) {
|
|
|
194
181
|
const spot = spots.find(free);
|
|
195
182
|
if (spot)
|
|
196
183
|
return { x: Math.round(spot.x), y: Math.round(spot.y) };
|
|
197
|
-
// A canvas packed all around the origin: the new card starts a stage of its own past every card.
|
|
198
|
-
// At the canvas's edge that stage is clamped inside it: a card on another beats a graph that cannot be saved.
|
|
199
184
|
const right = Math.max(...cards.map(card => card.x + card.width));
|
|
200
185
|
return { x: clamp(right + STAGE_SPACING - CARD_WIDTH), y: origin.y };
|
|
201
186
|
}
|
|
202
|
-
/** Used only inside the canonical graph validator's catch block. */
|
|
203
187
|
const graphValidationIssue = (error) => ({ code: 'GRAPH_INVALID', message: error instanceof Error ? error.message : 'Graph validation failed.' });
|
|
204
|
-
/** Ordinary backend and storage failures are not evidence of malformed graph topology.
|
|
205
|
-
* Do not echo raw OS exception messages: they can contain private local paths. */
|
|
206
188
|
function backendIssue(error) {
|
|
207
189
|
const code = error && typeof error === 'object' && 'code' in error
|
|
208
190
|
? error.code : undefined;
|
|
@@ -211,7 +193,6 @@ function backendIssue(error) {
|
|
|
211
193
|
? { code: 'STORAGE_ERROR', message: 'Andorra Code could not access its local data. Check the installation directory and filesystem permissions, then retry.' }
|
|
212
194
|
: { code: 'BACKEND_ERROR', message: 'Andorra Code could not complete this MCP request. Check the local configuration and logs, then retry.' };
|
|
213
195
|
}
|
|
214
|
-
/** Single source of truth: the published graph validator remains authoritative for all topology rules. */
|
|
215
196
|
function graphIssues(graph, providers, defaultProvider, authoredAgents = new Set()) {
|
|
216
197
|
const issues = [];
|
|
217
198
|
for (const [id, node] of Object.entries(graph.nodes)) {
|
|
@@ -233,7 +214,7 @@ function graphIssues(graph, providers, defaultProvider, authoredAgents = new Set
|
|
|
233
214
|
}
|
|
234
215
|
catch {
|
|
235
216
|
continue;
|
|
236
|
-
}
|
|
217
|
+
}
|
|
237
218
|
for (const port of ports) {
|
|
238
219
|
if (node.completion?.mode === 'outcomes' && node.completion.requireRoutes === false)
|
|
239
220
|
continue;
|
|
@@ -269,16 +250,11 @@ function graphIssues(graph, providers, defaultProvider, authoredAgents = new Set
|
|
|
269
250
|
if (Object.keys(graph.nodes).length > 0 && !Object.values(graph.nodes).some(node => node?.type === 'end')) {
|
|
270
251
|
issues.push({ code: 'END_NODE_MISSING', message: 'Graph must contain at least one End node. Add an End node and connect a valid path.' });
|
|
271
252
|
}
|
|
272
|
-
// The full validator also checks schemas, cycles and Join dependencies. Run it
|
|
273
|
-
// even while there are missing ports: otherwise the agent learns about an
|
|
274
|
-
// invalid schema only after another round trip to repair an unrelated edge.
|
|
275
253
|
try {
|
|
276
254
|
validateGraph(graph, { providers, defaultProvider, spawnAvailable: true });
|
|
277
255
|
}
|
|
278
256
|
catch (error) {
|
|
279
257
|
const issue = graphValidationIssue(error);
|
|
280
|
-
// Required routes have already been reported with nodeId/port above.
|
|
281
|
-
// Avoid burying a useful diagnosis under the validator's duplicate prose.
|
|
282
258
|
if (!issues.some(item => item.code === 'NODE_ROUTE_MISSING'
|
|
283
259
|
&& issue.message.includes(`node ${item.nodeId}: required outcome ${item.port} has no route`))
|
|
284
260
|
&& !(issues.some(item => item.code === 'ENTRY_NOT_FOUND') && /entry must reference an existing node/.test(issue.message))
|
|
@@ -293,69 +269,33 @@ export class AgentMcpBackend {
|
|
|
293
269
|
drafts = new Map();
|
|
294
270
|
sync;
|
|
295
271
|
accessKey;
|
|
296
|
-
/** An account's first snapshot reconciliation must finish before any reader sees its graphs. */
|
|
297
272
|
initialSync;
|
|
298
|
-
/** Subagent runs this process owns; one at a time, like every other engine surface. */
|
|
299
273
|
subagent;
|
|
300
|
-
/**
|
|
301
|
-
* The starts that are preparing and have published no run id yet.
|
|
302
|
-
*
|
|
303
|
-
* A count, not a flag: a second start that is refused while the first is still preparing
|
|
304
|
-
* releases its own reservation, and a flag it cleared would take the first start's with it.
|
|
305
|
-
*/
|
|
306
274
|
starting = 0;
|
|
307
|
-
/** Set when the connection closed: a start that begins after it must not launch a run. */
|
|
308
275
|
closed = false;
|
|
309
276
|
constructor(options = {}) {
|
|
310
277
|
this.options = options;
|
|
311
278
|
this.directory = options.directory ?? configDirectory();
|
|
312
|
-
// The run's records belong to the home this backend was built for, not to whichever
|
|
313
|
-
// installation happens to sit on the machine.
|
|
314
279
|
this.subagent = new SubagentRunner({
|
|
315
280
|
directory: this.directory,
|
|
316
|
-
// The injected provider reader keeps embedded hosts and tests on their own configuration;
|
|
317
|
-
// production reads the installation directory this backend was built for.
|
|
318
281
|
loadConfig: directory => this.options.providerConfig ? this.options.providerConfig() : loadConfig(directory),
|
|
319
282
|
});
|
|
320
|
-
// Attempts a previous process left in flight are classified before this one starts: a host
|
|
321
|
-
// that only ever talks to the MCP server would otherwise keep its own crashed runs marked
|
|
322
|
-
// `running` until an unrelated interactive CLI or app-server was opened. Best effort: a
|
|
323
|
-
// damaged home must not block the server.
|
|
324
|
-
// Another engine in this process may have a live run in this home — an app-server, or a
|
|
325
|
-
// second backend. A record this process is running is not this backend's to classify, so the
|
|
326
|
-
// sweep leaves it alone.
|
|
327
283
|
this.recovery = options.recoverRuns === false ? Promise.resolve()
|
|
328
284
|
: reconcileInterruptedRuns(this.directory, undefined, { skipOwnProcess: true }).then(() => undefined).catch(() => undefined);
|
|
329
285
|
}
|
|
330
|
-
/** The startup recovery, finished before the first subagent start is accepted. */
|
|
331
286
|
recovery;
|
|
332
|
-
/**
|
|
333
|
-
* The run a control call is about.
|
|
334
|
-
*
|
|
335
|
-
* One backend can serve several requesters, and a new run may start as soon as the previous one
|
|
336
|
-
* has finished. A call that names the run it means is refused when that run is no longer the
|
|
337
|
-
* current one: a delayed result would otherwise report the next run's state, and a delayed
|
|
338
|
-
* cancellation would stop it.
|
|
339
|
-
*/
|
|
340
287
|
assertSubagentRun(runId) {
|
|
341
288
|
if (typeof runId !== 'string' || !runId) {
|
|
342
289
|
throw new AgentMcpError('INVALID_ARGUMENTS', 'runId must be the id the start returned.');
|
|
343
290
|
}
|
|
344
291
|
const status = this.subagent.status();
|
|
345
292
|
const current = status.runId;
|
|
346
|
-
// A start that is still preparing has published no id: a control call cannot name the run it
|
|
347
|
-
// is about, and an id it made up would cancel a run whose id the caller never had.
|
|
348
293
|
if (current === undefined && this.starting > 0) {
|
|
349
294
|
throw new AgentMcpError('INVALID_ARGUMENTS', 'The run is still starting and has published no id yet.');
|
|
350
295
|
}
|
|
351
|
-
// A replacement is preparing while the run that was current has already finished. A control
|
|
352
|
-
// call that names the finished run is stale, and the runner would read it as a cancellation
|
|
353
|
-
// of the replacement — a run whose id the caller never received.
|
|
354
296
|
if (current !== undefined && this.starting > 0 && status.state !== 'running') {
|
|
355
297
|
throw new AgentMcpError('INVALID_ARGUMENTS', 'That run has finished and a replacement is starting; the run it named is not the one this process owns.');
|
|
356
298
|
}
|
|
357
|
-
// No run is live: the id the caller names cannot have come from a start, and answering about
|
|
358
|
-
// whatever the process happens to hold would let a stale caller read a different run's state.
|
|
359
299
|
if (current === undefined) {
|
|
360
300
|
throw new AgentMcpError('NO_RUN', 'No run is live in this process; the run it named has finished.');
|
|
361
301
|
}
|
|
@@ -364,12 +304,8 @@ export class AgentMcpBackend {
|
|
|
364
304
|
}
|
|
365
305
|
}
|
|
366
306
|
async close() {
|
|
367
|
-
// The connection is gone: a start that is still preparing must not become a run, and the
|
|
368
|
-
// runner refuses one from here on.
|
|
369
307
|
this.closed = true;
|
|
370
308
|
this.drafts.clear();
|
|
371
|
-
// The run this process owns ends with it: a provider request or a full-access tool call
|
|
372
|
-
// that outlived the connection would keep a supposedly closed process alive.
|
|
373
309
|
await this.subagent.shutdown();
|
|
374
310
|
await this.initialSync?.catch(() => { });
|
|
375
311
|
await this.sync?.close();
|
|
@@ -388,11 +324,7 @@ export class AgentMcpBackend {
|
|
|
388
324
|
throw new AgentMcpError('AUTH_REQUIRED', 'Sign in to your Andorra Code account to edit graphs.');
|
|
389
325
|
if (!/^[A-Za-z0-9-]{1,128}$/.test(before.subject))
|
|
390
326
|
throw new AgentMcpError('AUTH_REQUIRED', 'The signed-in account has an invalid graph storage identity. Sign in again.');
|
|
391
|
-
// A paid verdict is scoped to the exact subject returned by /me. Checking
|
|
392
|
-
// paid first and reading whichever account is current afterwards would let
|
|
393
|
-
// a concurrent login switch open another account's graph directory.
|
|
394
327
|
const membership = await (this.options.membershipStatus ?? getMembership)();
|
|
395
|
-
// A free account edits its one custom graph; the allowance is enforced when a draft is published.
|
|
396
328
|
if (!membership.paid && !membership.subject)
|
|
397
329
|
throw PaidMembershipRequiredError.for(membership);
|
|
398
330
|
if (!membership.subject || membership.subject !== before.subject)
|
|
@@ -408,9 +340,6 @@ export class AgentMcpBackend {
|
|
|
408
340
|
}
|
|
409
341
|
const key = access.directory + '\0' + (access.subject ?? '');
|
|
410
342
|
if (this.accessKey !== key) {
|
|
411
|
-
// Set up the *shared* initialization promise synchronously before any await.
|
|
412
|
-
// Concurrent list/get requests must all observe the same completed sync, not
|
|
413
|
-
// treat a matching accessKey as proof that cloud restore finished.
|
|
414
343
|
const previous = this.sync;
|
|
415
344
|
this.accessKey = key;
|
|
416
345
|
this.drafts.clear();
|
|
@@ -436,9 +365,6 @@ export class AgentMcpBackend {
|
|
|
436
365
|
await initialization;
|
|
437
366
|
}
|
|
438
367
|
catch (error) {
|
|
439
|
-
// An initialization failure must not poison this account for the lifetime
|
|
440
|
-
// of the MCP process. Concurrent callers share the same rejected promise,
|
|
441
|
-
// but only the owner of that promise clears it and closes the failed sync.
|
|
442
368
|
if (this.accessKey === key && this.initialSync === initialization) {
|
|
443
369
|
const failedSync = this.sync;
|
|
444
370
|
this.accessKey = undefined;
|
|
@@ -457,8 +383,6 @@ export class AgentMcpBackend {
|
|
|
457
383
|
}
|
|
458
384
|
return access;
|
|
459
385
|
}
|
|
460
|
-
/** Graph storage is account-owned. Verify identity again after filesystem awaits
|
|
461
|
-
* and before releasing any graph data to an MCP caller. */
|
|
462
386
|
async assertGraphIdentity(access) {
|
|
463
387
|
if (this.options.graphAccess)
|
|
464
388
|
return;
|
|
@@ -481,14 +405,10 @@ export class AgentMcpBackend {
|
|
|
481
405
|
}
|
|
482
406
|
async providers() {
|
|
483
407
|
const config = await (this.options.providerConfig ? this.options.providerConfig() : loadConfig(this.directory));
|
|
484
|
-
|
|
408
|
+
// `models` travels with the profile because a subagent may pin any model the profile lists,
|
|
409
|
+
// not only its default; without it validation rejects a graph the app itself runs.
|
|
410
|
+
return { providers: config.providers.map(({ id, model, type, models }) => ({ id, model, type, ...(models?.length ? { models: [...models] } : {}) })), active: config.provider };
|
|
485
411
|
}
|
|
486
|
-
/**
|
|
487
|
-
* Soft-delete or restore: publish the next revision with metadata.deletedAt set or removed.
|
|
488
|
-
*
|
|
489
|
-
* The revision goes through the same save path as a publish, so free-tier rules and the optimistic
|
|
490
|
-
* revision check apply unchanged, and cloud sync carries the marker to every machine.
|
|
491
|
-
*/
|
|
492
412
|
async setDeleted(deleting, args, access, beforeSave) {
|
|
493
413
|
const tool = deleting ? 'andorra_graph_delete' : 'andorra_graph_restore';
|
|
494
414
|
const id = field(args, 'id');
|
|
@@ -503,7 +423,6 @@ export class AgentMcpBackend {
|
|
|
503
423
|
throw new AgentMcpError('INVALID_ARGUMENTS', 'expectedRevision must be the positive revision andorra_graph_get or andorra_graphs_list reported.');
|
|
504
424
|
if (deleting && args.confirm !== id)
|
|
505
425
|
throw new AgentMcpError('CONFIRMATION_MISMATCH', 'confirm must repeat the graph id ' + id + '. Ask the user to confirm the deletion in chat first.');
|
|
506
|
-
// Bring in a revision another machine published, so the revision check compares against it.
|
|
507
426
|
await this.sync?.sync();
|
|
508
427
|
const latest = await this.readGraph(id, access.directory);
|
|
509
428
|
await this.assertGraphIdentity(access);
|
|
@@ -514,7 +433,6 @@ export class AgentMcpBackend {
|
|
|
514
433
|
if (!deleting && !isDeletedGraph(latest))
|
|
515
434
|
throw new AgentMcpError('GRAPH_NOT_DELETED', 'Graph ' + id + ' is not deleted, so there is nothing to restore.');
|
|
516
435
|
if (deleting) {
|
|
517
|
-
// An automation would fail at its next run; the user decides what it runs instead.
|
|
518
436
|
const users = (await new AutomationStore(this.directory).list()).filter(job => job.execution?.graph === id);
|
|
519
437
|
if (users.length)
|
|
520
438
|
throw new AgentMcpError('GRAPH_IN_USE', 'Graph ' + id + ' is run by automation'
|
|
@@ -533,7 +451,6 @@ export class AgentMcpBackend {
|
|
|
533
451
|
beforeSave?.();
|
|
534
452
|
const saved = freshAccess.free ? await saveFreeTierGraph(next, latest.revision, access.directory)
|
|
535
453
|
: await saveGraph(next, latest.revision, access.directory);
|
|
536
|
-
// A draft of a deleted graph could only publish over the deletion.
|
|
537
454
|
if (deleting)
|
|
538
455
|
for (const [key, draft] of this.drafts)
|
|
539
456
|
if (draft.graph.id === id && draft.directory === access.directory)
|
|
@@ -544,7 +461,6 @@ export class AgentMcpBackend {
|
|
|
544
461
|
? { id, revision: saved.revision, deletedAt, note: freshAccess.free ? note + ' A deleted graph still counts as this free account\'s one custom graph; restore it to use it again.' : note }
|
|
545
462
|
: { id, revision: saved.revision, note };
|
|
546
463
|
}
|
|
547
|
-
/** Missing graph identity is not a broken graph. Tell the agent to list or create it. */
|
|
548
464
|
async readGraph(id, directory, revision) {
|
|
549
465
|
try {
|
|
550
466
|
return await loadGraph(id, revision, directory);
|
|
@@ -572,8 +488,6 @@ export class AgentMcpBackend {
|
|
|
572
488
|
&& Object.values(proposedNodes).some(item => item.type === 'agent' && item.agentRole === 'orchestrator');
|
|
573
489
|
if (Object.keys(proposedNodes).length > (hasOrchestrator ? 101 : 100))
|
|
574
490
|
throw new AgentMcpError('NODE_LIMIT', 'A graph supports at most 100 nodes plus one version-3 Orchestrator. Remove a node before adding another.');
|
|
575
|
-
// A card the draft did not have yet is kept off the others; a card that exists stays where it is
|
|
576
|
-
// put, so an edit never moves the user's layout.
|
|
577
491
|
let placed;
|
|
578
492
|
if (!Object.hasOwn(draft.graph.nodes, node.id)) {
|
|
579
493
|
const spot = placeNewNode(node, Object.values(draft.graph.nodes));
|
|
@@ -600,8 +514,9 @@ export class AgentMcpBackend {
|
|
|
600
514
|
throw new AgentMcpError('EDGE_TARGET_MISSING', 'Target node ' + value.target + ' does not exist.', { nodeId: value.target });
|
|
601
515
|
const ports = nodeOutcomes(source);
|
|
602
516
|
const outcome = value.outcome === undefined ? ports.length === 1 ? ports[0] : undefined : value.outcome;
|
|
603
|
-
|
|
604
|
-
|
|
517
|
+
const routable = [...ports, ...optionalOutcomes(source)];
|
|
518
|
+
if (typeof outcome !== 'string' || !routable.includes(outcome))
|
|
519
|
+
throw new AgentMcpError('EDGE_OUTCOME_INVALID', 'Node ' + source.id + ': specify a valid outcome (' + routable.join(', ') + ').', { nodeId: source.id, port: typeof outcome === 'string' ? outcome : undefined });
|
|
605
520
|
const id = value.id === undefined ? randomUUID() : value.id;
|
|
606
521
|
if (!safeId(id))
|
|
607
522
|
throw new AgentMcpError('EDGE_INVALID', 'Edge id must be a safe identifier.');
|
|
@@ -616,12 +531,6 @@ export class AgentMcpBackend {
|
|
|
616
531
|
draft.graph.edges[index] = edge;
|
|
617
532
|
return { edge, edgeCount: draft.graph.edges.length };
|
|
618
533
|
}
|
|
619
|
-
/**
|
|
620
|
-
* Run one tool call. `beforeSave` runs synchronously immediately before a revision is written
|
|
621
|
-
* (publish, delete, restore), after every await that precedes the write; throwing from it abandons
|
|
622
|
-
* the save. An embedding host uses it to refuse a save its task may no longer make (cancelled, or
|
|
623
|
-
* switched to Plan) while the call was waiting on sign-in checks or cloud sync.
|
|
624
|
-
*/
|
|
625
534
|
async call(name, rawArgs = {}, options = {}) {
|
|
626
535
|
try {
|
|
627
536
|
return { ok: true, data: await this.dispatch(name, argsRecord(rawArgs), options.beforeSave) };
|
|
@@ -644,8 +553,6 @@ export class AgentMcpBackend {
|
|
|
644
553
|
return { ok: false, error: { code: error.code, message: error.message,
|
|
645
554
|
...error.info } };
|
|
646
555
|
}
|
|
647
|
-
// These failures can come from non-graph MCP tools (project/session/provider
|
|
648
|
-
// discovery). Only graphIssues should label a validation exception GRAPH_INVALID.
|
|
649
556
|
return { ok: false, error: backendIssue(error) };
|
|
650
557
|
}
|
|
651
558
|
}
|
|
@@ -660,8 +567,6 @@ export class AgentMcpBackend {
|
|
|
660
567
|
const query = { ...args };
|
|
661
568
|
if (args.status !== undefined)
|
|
662
569
|
throw new AgentMcpError('INVALID_ARGUMENTS', 'andorra_sessions_attention does not take status; it returns all sessions needing attention.');
|
|
663
|
-
// One locked snapshot and crash index for the entire paged scan. A
|
|
664
|
-
// concurrent query's pruning cannot change what later pages report.
|
|
665
570
|
const { sessions, truncated } = await scanAgentSessions(this.directory, query, {
|
|
666
571
|
...(this.options.sessionStore === undefined ? {} : { store: this.options.sessionStore }),
|
|
667
572
|
pageSize: 100, maxSessions: 500,
|
|
@@ -680,12 +585,8 @@ export class AgentMcpBackend {
|
|
|
680
585
|
}
|
|
681
586
|
if (name === 'andorra_providers_list')
|
|
682
587
|
return this.providers();
|
|
683
|
-
// Subagent runs need no account or membership: they execute the bundled Andorra Agent
|
|
684
|
-
// harness with a locally configured provider, the same tier as provider discovery.
|
|
685
588
|
if (name === 'andorra_subagent_start') {
|
|
686
589
|
const task = field(args, 'prompt');
|
|
687
|
-
// The prompt is bounded before the open record and the session are created: an accidentally
|
|
688
|
-
// enormous one would otherwise fill the installation's storage and the model's context.
|
|
689
590
|
if (task.length > MAX_SUBAGENT_TASK_CHARS) {
|
|
690
591
|
throw new AgentMcpError('INVALID_ARGUMENTS', `The task must be at most ${MAX_SUBAGENT_TASK_CHARS} characters.`);
|
|
691
592
|
}
|
|
@@ -706,11 +607,7 @@ export class AgentMcpBackend {
|
|
|
706
607
|
throw new AgentMcpError('INVALID_ARGUMENTS', error instanceof Error ? error.message : String(error));
|
|
707
608
|
}
|
|
708
609
|
try {
|
|
709
|
-
// The startup recovery finishes first: a start must not land beside a crashed attempt that
|
|
710
|
-
// still claims to be live.
|
|
711
610
|
await this.recovery;
|
|
712
|
-
// The connection may have closed while this call was preparing. A run that begins now
|
|
713
|
-
// would outlive the connection that asked for it.
|
|
714
611
|
if (this.closed)
|
|
715
612
|
throw new AgentMcpError('INVALID_ARGUMENTS', 'The connection to Andorra closed before the run started.');
|
|
716
613
|
this.starting += 1;
|
|
@@ -729,12 +626,8 @@ export class AgentMcpBackend {
|
|
|
729
626
|
catch (error) {
|
|
730
627
|
if (error instanceof SubagentProviderNotSetError)
|
|
731
628
|
throw new AgentMcpError('PROVIDER_NOT_SET', error.message, { providers: error.providers });
|
|
732
|
-
// The caller's own choice was wrong, and it can read that: a generic backend error
|
|
733
|
-
// would leave it guessing which identifier to correct.
|
|
734
629
|
if (error instanceof SubagentSelectionError)
|
|
735
630
|
throw new AgentMcpError('INVALID_ARGUMENTS', error.message);
|
|
736
|
-
// A value the run itself refuses — a permission outside the two modes, a model id longer
|
|
737
|
-
// than the configured ones may be — is the caller's own mistake, and the code says so.
|
|
738
631
|
if (error instanceof SubagentInvalidArgumentError)
|
|
739
632
|
throw new AgentMcpError('INVALID_ARGUMENTS', error.message);
|
|
740
633
|
if (error instanceof SubagentRunInProgressError)
|
|
@@ -754,8 +647,6 @@ export class AgentMcpBackend {
|
|
|
754
647
|
if (this.subagent.status().state === 'idle')
|
|
755
648
|
throw new AgentMcpError('NO_RUN', 'No subagent run has been started in this process. Call andorra_subagent_start first.');
|
|
756
649
|
const outcome = await this.subagent.result(waitMs);
|
|
757
|
-
// The id the caller asked about, not the one the process holds now: a run that started while
|
|
758
|
-
// this one was being awaited would label this answer with the wrong run.
|
|
759
650
|
return { ...outcome, runId: args.runId };
|
|
760
651
|
}
|
|
761
652
|
if (name === 'andorra_subagent_cancel') {
|
|
@@ -781,8 +672,6 @@ export class AgentMcpBackend {
|
|
|
781
672
|
if (revision !== undefined && (!Number.isSafeInteger(revision) || typeof revision !== 'number' || revision < 1))
|
|
782
673
|
throw new AgentMcpError('INVALID_ARGUMENTS', 'revision must be a positive safe integer when supplied.');
|
|
783
674
|
const graph = await this.readGraph(field(args, 'id'), access.directory, revision);
|
|
784
|
-
// Read tools return the exact published revision, not an editor migration.
|
|
785
|
-
// Recheck account identity *after* the awaited account-owned filesystem read.
|
|
786
675
|
await this.assertGraphIdentity(access);
|
|
787
676
|
return { graph, ...(isDeletedGraph(graph) ? { deletedAt: graph.metadata.deletedAt } : {}) };
|
|
788
677
|
}
|
|
@@ -821,7 +710,6 @@ export class AgentMcpBackend {
|
|
|
821
710
|
if (error.code !== 'ENOENT')
|
|
822
711
|
throw error;
|
|
823
712
|
}
|
|
824
|
-
// A free account at its graph limit learns so before it builds a draft it cannot publish.
|
|
825
713
|
if (access.free && (await readGraphQuota(access.directory)).customGraphs >= FREE_CUSTOM_GRAPH_LIMIT)
|
|
826
714
|
throw new FreeTierLimitError(FREE_GRAPH_LIMIT_MESSAGE);
|
|
827
715
|
graph = { schemaVersion: 3, id, name: nameValue, revision: 0, entry: '', nodes: {}, edges: [] };
|
|
@@ -829,11 +717,7 @@ export class AgentMcpBackend {
|
|
|
829
717
|
}
|
|
830
718
|
else
|
|
831
719
|
throw new AgentMcpError('INVALID_ARGUMENTS', 'mode must be create or edit.');
|
|
832
|
-
// Edit/create reads account-owned graph data too. A user who signs out
|
|
833
|
-
// during these awaits may not retain a draft containing that graph.
|
|
834
720
|
await this.assertGraphIdentity(access);
|
|
835
|
-
// Awaited graph reads can finish concurrently. Recheck immediately before
|
|
836
|
-
// insertion (no await between check and set) to enforce the 24-draft cap.
|
|
837
721
|
for (const [expiredId, draft] of this.drafts)
|
|
838
722
|
if (Date.now() - draft.touched > 60 * 60_000 && !draft.publishing)
|
|
839
723
|
this.drafts.delete(expiredId);
|
|
@@ -851,16 +735,12 @@ export class AgentMcpBackend {
|
|
|
851
735
|
return { discarded: true };
|
|
852
736
|
}
|
|
853
737
|
const draft = this.obtainDraft(draftId(args), access);
|
|
854
|
-
// Publishing becomes exclusive before the first async provider read. Concurrent mutation
|
|
855
|
-
// requests must never edit a draft while a snapshot is being validated or saved.
|
|
856
738
|
const publishing = name === 'andorra_graph_publish';
|
|
857
739
|
if (publishing)
|
|
858
740
|
draft.publishing = true;
|
|
859
741
|
try {
|
|
860
742
|
if (name === 'andorra_graph_node_upsert') {
|
|
861
743
|
const profiles = await this.providers();
|
|
862
|
-
// Recheck after the await: the draft may have been discarded or entered
|
|
863
|
-
// publication while provider config was loading.
|
|
864
744
|
const current = this.obtainDraft(draftId(args), access);
|
|
865
745
|
return this.upsertNode(current, args.node, profiles.providers.map(item => item.id));
|
|
866
746
|
}
|
|
@@ -869,9 +749,6 @@ export class AgentMcpBackend {
|
|
|
869
749
|
if (!record(args.patch) || Object.keys(args.patch).some(key => key === 'id' || key === 'type'))
|
|
870
750
|
throw new AgentMcpError('INVALID_ARGUMENTS', 'patch must be a node settings object without id or type.');
|
|
871
751
|
const profiles = await this.providers();
|
|
872
|
-
// Always reread the node after the asynchronous provider lookup. Two
|
|
873
|
-
// concurrently submitted patches then each merge with the latest node,
|
|
874
|
-
// preserving unrelated fields instead of overwriting a stale snapshot.
|
|
875
752
|
const currentDraft = this.obtainDraft(draftId(args), access);
|
|
876
753
|
const currentNode = currentDraft.graph.nodes[id];
|
|
877
754
|
if (!currentNode)
|
|
@@ -912,8 +789,6 @@ export class AgentMcpBackend {
|
|
|
912
789
|
return { graphId: draft.graph.id, entry: draft.graph.entry, name: draft.graph.name };
|
|
913
790
|
}
|
|
914
791
|
if (name === 'andorra_graph_validate' || name === 'andorra_graph_publish') {
|
|
915
|
-
// A draft opened before this rule, or a node patch, could still carry the marker; publishing it
|
|
916
|
-
// would delete the graph without the delete tool's confirmation and automation checks.
|
|
917
792
|
if (draft.graph.metadata && Object.hasOwn(draft.graph.metadata, 'deletedAt'))
|
|
918
793
|
throw new AgentMcpError('RESERVED_METADATA', 'metadata.deletedAt is reserved. Delete a graph with andorra_graph_delete and restore it with andorra_graph_restore.');
|
|
919
794
|
const profiles = await this.providers();
|
|
@@ -924,24 +799,15 @@ export class AgentMcpBackend {
|
|
|
924
799
|
throw new AgentMcpError(issues[0].code, issues[0].message, { nodeId: issues[0].nodeId, port: issues[0].port, edgeId: issues[0].edgeId, issues });
|
|
925
800
|
if (Buffer.byteLength(JSON.stringify(draft.graph)) > 512 * 1024)
|
|
926
801
|
throw new AgentMcpError('GRAPH_TOO_LARGE', 'Graph exceeds 512 KiB. Reduce prompt or schema size before publishing.');
|
|
927
|
-
// Refresh the account-scoped graph snapshots before the compare-and-swap. A remote
|
|
928
|
-
// editor may have published after the draft began; this lets its latest revision
|
|
929
|
-
// participate in the same local CAS that protects two editors on one machine.
|
|
930
802
|
await this.sync?.sync();
|
|
931
|
-
// Provider configuration can be edited by another process during a network
|
|
932
|
-
// sync. Validate again against the *current* provider list before publishing.
|
|
933
803
|
if (this.drafts.get(draftId(args)) !== draft)
|
|
934
804
|
throw new AgentMcpError('DRAFT_NOT_FOUND', 'Draft was closed during synchronization. Start a new graph draft.');
|
|
935
|
-
// An account switch can also happen during a long pre-publish cloud sync.
|
|
936
|
-
// Rebind entitlement before touching the immutable revision on disk.
|
|
937
805
|
const freshAccess = await this.graphAccess();
|
|
938
806
|
if (freshAccess.directory !== access.directory || freshAccess.subject !== access.subject)
|
|
939
807
|
throw new AgentMcpError('AUTH_CHANGED', 'Account changed during graph synchronization. Reopen the draft for the current account.');
|
|
940
808
|
if (this.drafts.get(draftId(args)) !== draft)
|
|
941
809
|
throw new AgentMcpError('DRAFT_NOT_FOUND', 'Draft was closed during synchronization. Start a new graph draft.');
|
|
942
810
|
const latestProfiles = await this.providers();
|
|
943
|
-
// Reloading provider config is asynchronous; another process can switch
|
|
944
|
-
// accounts during that read. Recheck immediately before the local save.
|
|
945
811
|
const finalAccess = await this.graphAccess();
|
|
946
812
|
if (finalAccess.directory !== access.directory || finalAccess.subject !== access.subject)
|
|
947
813
|
throw new AgentMcpError('AUTH_CHANGED', 'Account changed while verifying providers. Retry with the current account.');
|
|
@@ -953,16 +819,12 @@ export class AgentMcpBackend {
|
|
|
953
819
|
edgeId: currentIssues[0].edgeId, issues: currentIssues });
|
|
954
820
|
const normalized = validateGraph(draft.graph, { providers: latestProfiles.providers,
|
|
955
821
|
defaultProvider: latestProfiles.active, spawnAvailable: true });
|
|
956
|
-
// Stamping can add profile entries after the submitted graph already passed the size checks.
|
|
957
822
|
const stamped = stampGraphProviderProfiles(normalized, latestProfiles);
|
|
958
823
|
if (Buffer.byteLength(JSON.stringify(stamped)) > 512 * 1024)
|
|
959
824
|
throw new AgentMcpError('VALIDATION_FAILED', 'Graph exceeds 512 KiB after portable provider identities are recorded.');
|
|
960
825
|
beforeSave?.();
|
|
961
826
|
const saved = finalAccess.free ? await saveFreeTierGraph(stamped, draft.expectedRevision, access.directory)
|
|
962
827
|
: await saveGraph(stamped, draft.expectedRevision, access.directory);
|
|
963
|
-
// A re-created graph id must not stay deleted: the editor's save endpoint clears the
|
|
964
|
-
// tombstone after its save, and a publish that reuses a deleted id must too, or the
|
|
965
|
-
// replacement keeps refusing autosaves and its cloud snapshots never restore here.
|
|
966
828
|
await this.sync?.reviveGraph(saved.id);
|
|
967
829
|
draft.graph = saved;
|
|
968
830
|
draft.expectedRevision = saved.revision;
|
|
@@ -978,7 +840,6 @@ export class AgentMcpBackend {
|
|
|
978
840
|
}
|
|
979
841
|
}
|
|
980
842
|
}
|
|
981
|
-
/** The tool names this server advertises; bundled skills that drive it are checked against this list. */
|
|
982
843
|
export { AGENT_MCP_TOOL_NAMES };
|
|
983
844
|
export async function runAgentMcpServer() {
|
|
984
845
|
const backend = new AgentMcpBackend();
|