@orion-agents/orion-code 0.1.9 → 0.2.2
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/CHANGELOG.md +85 -0
- package/README.md +142 -323
- package/README.zh-CN.md +118 -578
- package/dist/cli.js +65 -84
- package/dist/cli.js.map +1 -1
- package/dist/commands/context-commands.d.ts.map +1 -1
- package/dist/commands/context-commands.js +14 -7
- package/dist/commands/context-commands.js.map +1 -1
- package/dist/commands/context-tool-command-handlers.d.ts +4 -5
- package/dist/commands/context-tool-command-handlers.d.ts.map +1 -1
- package/dist/commands/context-tool-command-handlers.js +132 -208
- package/dist/commands/context-tool-command-handlers.js.map +1 -1
- package/dist/commands/core-command-handlers.d.ts +3 -6
- package/dist/commands/core-command-handlers.d.ts.map +1 -1
- package/dist/commands/core-command-handlers.js +66 -664
- package/dist/commands/core-command-handlers.js.map +1 -1
- package/dist/commands/diagnostic-command-handlers.d.ts +1 -2
- package/dist/commands/diagnostic-command-handlers.d.ts.map +1 -1
- package/dist/commands/diagnostic-command-handlers.js +3 -17
- package/dist/commands/diagnostic-command-handlers.js.map +1 -1
- package/dist/commands/diagnostic-commands.d.ts.map +1 -1
- package/dist/commands/diagnostic-commands.js +0 -45
- package/dist/commands/diagnostic-commands.js.map +1 -1
- package/dist/commands/index.d.ts +1 -1
- package/dist/commands/index.d.ts.map +1 -1
- package/dist/commands/index.js +2 -7
- package/dist/commands/index.js.map +1 -1
- package/dist/commands/model-command-handlers.d.ts +1 -1
- package/dist/commands/model-command-handlers.js +2 -2
- package/dist/commands/model-command-handlers.js.map +1 -1
- package/dist/commands/model-commands.d.ts.map +1 -1
- package/dist/commands/model-commands.js +0 -11
- package/dist/commands/model-commands.js.map +1 -1
- package/dist/commands/registry.d.ts.map +1 -1
- package/dist/commands/registry.js +1 -139
- package/dist/commands/registry.js.map +1 -1
- package/dist/commands/session-command-handlers.d.ts +1 -1
- package/dist/commands/session-command-handlers.d.ts.map +1 -1
- package/dist/commands/session-command-handlers.js +52 -214
- package/dist/commands/session-command-handlers.js.map +1 -1
- package/dist/commands/session-commands.d.ts.map +1 -1
- package/dist/commands/session-commands.js +0 -48
- package/dist/commands/session-commands.js.map +1 -1
- package/dist/commands/target-command.d.ts +9 -15
- package/dist/commands/target-command.d.ts.map +1 -1
- package/dist/commands/target-command.js +16 -130
- package/dist/commands/target-command.js.map +1 -1
- package/dist/commands/tool-commands.d.ts.map +1 -1
- package/dist/commands/tool-commands.js +0 -10
- package/dist/commands/tool-commands.js.map +1 -1
- package/dist/commands/types.d.ts +10 -14
- package/dist/commands/types.d.ts.map +1 -1
- package/dist/commands/types.js +1 -1
- package/dist/commands/types.js.map +1 -1
- package/dist/commands/workflow-command-handlers.d.ts.map +1 -1
- package/dist/commands/workflow-command-handlers.js +1 -3
- package/dist/commands/workflow-command-handlers.js.map +1 -1
- package/dist/commands/workflow-commands.d.ts.map +1 -1
- package/dist/commands/workflow-commands.js +2 -24
- package/dist/commands/workflow-commands.js.map +1 -1
- package/dist/framework/agent-mode.d.ts +2 -3
- package/dist/framework/agent-mode.d.ts.map +1 -1
- package/dist/framework/agent-mode.js +8 -31
- package/dist/framework/agent-mode.js.map +1 -1
- package/dist/framework/index.d.ts +3 -3
- package/dist/framework/index.d.ts.map +1 -1
- package/dist/framework/index.js +6 -9
- package/dist/framework/index.js.map +1 -1
- package/dist/framework/loop-budget-contract.d.ts +20 -0
- package/dist/framework/loop-budget-contract.d.ts.map +1 -0
- package/dist/framework/loop-budget-contract.js +13 -0
- package/dist/framework/loop-budget-contract.js.map +1 -0
- package/dist/framework/prompt.d.ts.map +1 -1
- package/dist/framework/prompt.js +5 -4
- package/dist/framework/prompt.js.map +1 -1
- package/dist/framework/query.d.ts +45 -22
- package/dist/framework/query.d.ts.map +1 -1
- package/dist/framework/query.js +64 -52
- package/dist/framework/query.js.map +1 -1
- package/dist/framework/store.d.ts +4 -2
- package/dist/framework/store.d.ts.map +1 -1
- package/dist/framework/store.js +1 -0
- package/dist/framework/store.js.map +1 -1
- package/dist/framework/tool-call-orchestrator.d.ts +80 -0
- package/dist/framework/tool-call-orchestrator.d.ts.map +1 -0
- package/dist/framework/tool-call-orchestrator.js +192 -0
- package/dist/framework/tool-call-orchestrator.js.map +1 -0
- package/dist/framework/tool-state.d.ts +12 -11
- package/dist/framework/tool-state.d.ts.map +1 -1
- package/dist/framework/tool-state.js +36 -28
- package/dist/framework/tool-state.js.map +1 -1
- package/dist/framework/tool.d.ts +0 -9
- package/dist/framework/tool.d.ts.map +1 -1
- package/dist/framework/tool.js.map +1 -1
- package/dist/index.d.ts +70 -26
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +64 -65
- package/dist/index.js.map +1 -1
- package/dist/print-ui/launch.d.ts.map +1 -1
- package/dist/print-ui/launch.js +9 -2
- package/dist/print-ui/launch.js.map +1 -1
- package/dist/product/paths.d.ts +7 -0
- package/dist/product/paths.d.ts.map +1 -1
- package/dist/product/paths.js +19 -0
- package/dist/product/paths.js.map +1 -1
- package/dist/runtime/agent-loop.d.ts +80 -0
- package/dist/runtime/agent-loop.d.ts.map +1 -0
- package/dist/runtime/agent-loop.js +419 -0
- package/dist/runtime/agent-loop.js.map +1 -0
- package/dist/runtime/agent-runtime-controller.d.ts +10 -57
- package/dist/runtime/agent-runtime-controller.d.ts.map +1 -1
- package/dist/runtime/agent-runtime-controller.js +270 -1216
- package/dist/runtime/agent-runtime-controller.js.map +1 -1
- package/dist/runtime/agent-runtime-protocol.d.ts +4 -5
- package/dist/runtime/agent-runtime-protocol.d.ts.map +1 -1
- package/dist/runtime/agent-runtime-protocol.js.map +1 -1
- package/dist/runtime/agent-runtime-runner.d.ts +36 -0
- package/dist/runtime/agent-runtime-runner.d.ts.map +1 -0
- package/dist/runtime/agent-runtime-runner.js +3 -0
- package/dist/runtime/agent-runtime-runner.js.map +1 -0
- package/dist/runtime/batch-read-service.d.ts +29 -0
- package/dist/runtime/batch-read-service.d.ts.map +1 -0
- package/dist/runtime/batch-read-service.js +212 -0
- package/dist/runtime/batch-read-service.js.map +1 -0
- package/dist/runtime/builtin-tool-provider.d.ts +30 -0
- package/dist/runtime/builtin-tool-provider.d.ts.map +1 -0
- package/dist/runtime/builtin-tool-provider.js +233 -0
- package/dist/runtime/builtin-tool-provider.js.map +1 -0
- package/dist/runtime/capabilities/compiler.d.ts +11 -0
- package/dist/runtime/capabilities/compiler.d.ts.map +1 -0
- package/dist/runtime/capabilities/compiler.js +719 -0
- package/dist/runtime/capabilities/compiler.js.map +1 -0
- package/dist/runtime/capabilities/index.d.ts +3 -0
- package/dist/runtime/capabilities/index.d.ts.map +1 -0
- package/dist/runtime/capabilities/index.js +9 -0
- package/dist/runtime/capabilities/index.js.map +1 -0
- package/dist/runtime/capabilities/types.d.ts +175 -0
- package/dist/runtime/capabilities/types.d.ts.map +1 -0
- package/dist/runtime/capabilities/types.js +3 -0
- package/dist/runtime/capabilities/types.js.map +1 -0
- package/dist/runtime/capability-receipt-journal.d.ts +29 -0
- package/dist/runtime/capability-receipt-journal.d.ts.map +1 -0
- package/dist/runtime/capability-receipt-journal.js +264 -0
- package/dist/runtime/capability-receipt-journal.js.map +1 -0
- package/dist/runtime/capability-step-factory.d.ts +73 -0
- package/dist/runtime/capability-step-factory.d.ts.map +1 -0
- package/dist/runtime/capability-step-factory.js +302 -0
- package/dist/runtime/capability-step-factory.js.map +1 -0
- package/dist/runtime/compact-transaction.d.ts +225 -0
- package/dist/runtime/compact-transaction.d.ts.map +1 -0
- package/dist/runtime/compact-transaction.js +622 -0
- package/dist/runtime/compact-transaction.js.map +1 -0
- package/dist/runtime/composer/buffer.d.ts +3 -4
- package/dist/runtime/composer/buffer.d.ts.map +1 -1
- package/dist/runtime/composer/buffer.js +3 -4
- package/dist/runtime/composer/buffer.js.map +1 -1
- package/dist/runtime/composer/grapheme.d.ts +2 -4
- package/dist/runtime/composer/grapheme.d.ts.map +1 -1
- package/dist/runtime/composer/grapheme.js +2 -4
- package/dist/runtime/composer/grapheme.js.map +1 -1
- package/dist/runtime/composer/layout.d.ts +1 -3
- package/dist/runtime/composer/layout.d.ts.map +1 -1
- package/dist/runtime/composer/layout.js +1 -3
- package/dist/runtime/composer/layout.js.map +1 -1
- package/dist/runtime/core-tools/descriptors.d.ts +17 -0
- package/dist/runtime/core-tools/descriptors.d.ts.map +1 -0
- package/dist/runtime/core-tools/descriptors.js +185 -0
- package/dist/runtime/core-tools/descriptors.js.map +1 -0
- package/dist/runtime/first-party-core-provider.d.ts +55 -0
- package/dist/runtime/first-party-core-provider.d.ts.map +1 -0
- package/dist/runtime/first-party-core-provider.js +197 -0
- package/dist/runtime/first-party-core-provider.js.map +1 -0
- package/dist/runtime/first-party-long-tail-provider.d.ts +57 -0
- package/dist/runtime/first-party-long-tail-provider.d.ts.map +1 -0
- package/dist/runtime/first-party-long-tail-provider.js +238 -0
- package/dist/runtime/first-party-long-tail-provider.js.map +1 -0
- package/dist/runtime/first-party-tool-services.d.ts +43 -0
- package/dist/runtime/first-party-tool-services.d.ts.map +1 -0
- package/dist/runtime/first-party-tool-services.js +200 -0
- package/dist/runtime/first-party-tool-services.js.map +1 -0
- package/dist/runtime/first-party-tool-universe.d.ts +14 -0
- package/dist/runtime/first-party-tool-universe.d.ts.map +1 -0
- package/dist/runtime/first-party-tool-universe.js +20 -0
- package/dist/runtime/first-party-tool-universe.js.map +1 -0
- package/dist/runtime/goal-lifecycle-v2.d.ts +63 -0
- package/dist/runtime/goal-lifecycle-v2.d.ts.map +1 -0
- package/dist/runtime/goal-lifecycle-v2.js +253 -0
- package/dist/runtime/goal-lifecycle-v2.js.map +1 -0
- package/dist/runtime/goal-runtime-coordinator.d.ts +111 -0
- package/dist/runtime/goal-runtime-coordinator.d.ts.map +1 -0
- package/dist/runtime/goal-runtime-coordinator.js +511 -0
- package/dist/runtime/goal-runtime-coordinator.js.map +1 -0
- package/dist/runtime/harness-confluence.d.ts +165 -0
- package/dist/runtime/harness-confluence.d.ts.map +1 -0
- package/dist/runtime/harness-confluence.js +807 -0
- package/dist/runtime/harness-confluence.js.map +1 -0
- package/dist/runtime/harness-eval.d.ts +96 -0
- package/dist/runtime/harness-eval.d.ts.map +1 -0
- package/dist/runtime/harness-eval.js +181 -0
- package/dist/runtime/harness-eval.js.map +1 -0
- package/dist/runtime/harness-metrics.d.ts +202 -0
- package/dist/runtime/harness-metrics.d.ts.map +1 -0
- package/dist/runtime/harness-metrics.js +415 -0
- package/dist/runtime/harness-metrics.js.map +1 -0
- package/dist/runtime/legacy-session-importer.d.ts +99 -0
- package/dist/runtime/legacy-session-importer.d.ts.map +1 -0
- package/dist/runtime/legacy-session-importer.js +455 -0
- package/dist/runtime/legacy-session-importer.js.map +1 -0
- package/dist/runtime/legacy-thread-materializer.d.ts +72 -0
- package/dist/runtime/legacy-thread-materializer.d.ts.map +1 -0
- package/dist/runtime/legacy-thread-materializer.js +553 -0
- package/dist/runtime/legacy-thread-materializer.js.map +1 -0
- package/dist/runtime/long-tail-tools/descriptors.d.ts +23 -0
- package/dist/runtime/long-tail-tools/descriptors.d.ts.map +1 -0
- package/dist/runtime/long-tail-tools/descriptors.js +423 -0
- package/dist/runtime/long-tail-tools/descriptors.js.map +1 -0
- package/dist/runtime/loop-budget.d.ts +1 -1
- package/dist/runtime/loop-budget.d.ts.map +1 -1
- package/dist/runtime/loop-budget.js +2 -2
- package/dist/runtime/loop-budget.js.map +1 -1
- package/dist/runtime/mcp/first-party-mcp-adapter.d.ts +75 -0
- package/dist/runtime/mcp/first-party-mcp-adapter.d.ts.map +1 -0
- package/dist/runtime/mcp/first-party-mcp-adapter.js +484 -0
- package/dist/runtime/mcp/first-party-mcp-adapter.js.map +1 -0
- package/dist/runtime/mcp/first-party-mcp-config.d.ts +13 -0
- package/dist/runtime/mcp/first-party-mcp-config.d.ts.map +1 -0
- package/dist/runtime/mcp/first-party-mcp-config.js +139 -0
- package/dist/runtime/mcp/first-party-mcp-config.js.map +1 -0
- package/dist/runtime/mcp/index.d.ts +5 -0
- package/dist/runtime/mcp/index.d.ts.map +1 -0
- package/dist/{skills → runtime/mcp}/index.js +3 -9
- package/dist/runtime/mcp/index.js.map +1 -0
- package/dist/runtime/mcp/lazy-mcp-runtime.d.ts +95 -0
- package/dist/runtime/mcp/lazy-mcp-runtime.d.ts.map +1 -0
- package/dist/runtime/mcp/lazy-mcp-runtime.js +854 -0
- package/dist/runtime/mcp/lazy-mcp-runtime.js.map +1 -0
- package/dist/runtime/mcp/types.d.ts +128 -0
- package/dist/runtime/mcp/types.d.ts.map +1 -0
- package/dist/runtime/mcp/types.js +5 -0
- package/dist/runtime/mcp/types.js.map +1 -0
- package/dist/runtime/orion-runtime-v1.d.ts +322 -0
- package/dist/runtime/orion-runtime-v1.d.ts.map +1 -0
- package/dist/runtime/orion-runtime-v1.js +959 -0
- package/dist/runtime/orion-runtime-v1.js.map +1 -0
- package/dist/runtime/orion-session-runner.d.ts +38 -0
- package/dist/runtime/orion-session-runner.d.ts.map +1 -0
- package/dist/runtime/orion-session-runner.js +168 -0
- package/dist/runtime/orion-session-runner.js.map +1 -0
- package/dist/runtime/product-orion-runtime.d.ts +35 -0
- package/dist/runtime/product-orion-runtime.d.ts.map +1 -0
- package/dist/runtime/product-orion-runtime.js +1047 -0
- package/dist/runtime/product-orion-runtime.js.map +1 -0
- package/dist/runtime/prompts/index.d.ts +3 -0
- package/dist/runtime/prompts/index.d.ts.map +1 -0
- package/dist/{ink-ui/types.js → runtime/prompts/index.js} +3 -2
- package/dist/runtime/prompts/index.js.map +1 -0
- package/dist/runtime/prompts/prompt-registry.d.ts +22 -0
- package/dist/runtime/prompts/prompt-registry.d.ts.map +1 -0
- package/dist/runtime/prompts/prompt-registry.js +356 -0
- package/dist/runtime/prompts/prompt-registry.js.map +1 -0
- package/dist/runtime/prompts/types.d.ts +111 -0
- package/dist/runtime/prompts/types.d.ts.map +1 -0
- package/dist/runtime/prompts/types.js +5 -0
- package/dist/runtime/prompts/types.js.map +1 -0
- package/dist/runtime/protocol/canonical.d.ts +3 -0
- package/dist/runtime/protocol/canonical.d.ts.map +1 -0
- package/dist/runtime/protocol/canonical.js +21 -0
- package/dist/runtime/protocol/canonical.js.map +1 -0
- package/dist/runtime/protocol/index.d.ts +4 -0
- package/dist/runtime/protocol/index.d.ts.map +1 -0
- package/dist/runtime/protocol/index.js +16 -0
- package/dist/runtime/protocol/index.js.map +1 -0
- package/dist/runtime/protocol/runtime-protocol-v1.d.ts +671 -0
- package/dist/runtime/protocol/runtime-protocol-v1.d.ts.map +1 -0
- package/dist/runtime/protocol/runtime-protocol-v1.js +557 -0
- package/dist/runtime/protocol/runtime-protocol-v1.js.map +1 -0
- package/dist/runtime/release-receipts.d.ts +110 -0
- package/dist/runtime/release-receipts.d.ts.map +1 -0
- package/dist/runtime/release-receipts.js +305 -0
- package/dist/runtime/release-receipts.js.map +1 -0
- package/dist/runtime/resource-scope.d.ts +123 -0
- package/dist/runtime/resource-scope.d.ts.map +1 -0
- package/dist/runtime/resource-scope.js +363 -0
- package/dist/runtime/resource-scope.js.map +1 -0
- package/dist/runtime/runtime-event-buffer.d.ts +78 -0
- package/dist/runtime/runtime-event-buffer.d.ts.map +1 -0
- package/dist/runtime/runtime-event-buffer.js +237 -0
- package/dist/runtime/runtime-event-buffer.js.map +1 -0
- package/dist/runtime/runtime-services.d.ts +87 -0
- package/dist/runtime/runtime-services.d.ts.map +1 -0
- package/dist/runtime/runtime-services.js +180 -0
- package/dist/runtime/runtime-services.js.map +1 -0
- package/dist/runtime/session-history-recovery.d.ts +19 -0
- package/dist/runtime/session-history-recovery.d.ts.map +1 -0
- package/dist/runtime/session-history-recovery.js +45 -0
- package/dist/runtime/session-history-recovery.js.map +1 -0
- package/dist/runtime/skills/bounded-lru-cache.d.ts +34 -0
- package/dist/runtime/skills/bounded-lru-cache.d.ts.map +1 -0
- package/dist/runtime/skills/bounded-lru-cache.js +100 -0
- package/dist/runtime/skills/bounded-lru-cache.js.map +1 -0
- package/dist/runtime/skills/filesystem-skill-provider.d.ts +96 -0
- package/dist/runtime/skills/filesystem-skill-provider.d.ts.map +1 -0
- package/dist/runtime/skills/filesystem-skill-provider.js +829 -0
- package/dist/runtime/skills/filesystem-skill-provider.js.map +1 -0
- package/dist/runtime/skills/index.d.ts +5 -0
- package/dist/runtime/skills/index.d.ts.map +1 -0
- package/dist/{ink-ui/controllers/chat-controller.js → runtime/skills/index.js} +5 -2
- package/dist/runtime/skills/index.js.map +1 -0
- package/dist/runtime/skills/lazy-skill-runtime.d.ts +77 -0
- package/dist/runtime/skills/lazy-skill-runtime.d.ts.map +1 -0
- package/dist/runtime/skills/lazy-skill-runtime.js +673 -0
- package/dist/runtime/skills/lazy-skill-runtime.js.map +1 -0
- package/dist/runtime/skills/types.d.ts +137 -0
- package/dist/runtime/skills/types.d.ts.map +1 -0
- package/dist/runtime/skills/types.js +13 -0
- package/dist/runtime/skills/types.js.map +1 -0
- package/dist/runtime/step-snapshot.d.ts +183 -0
- package/dist/runtime/step-snapshot.d.ts.map +1 -0
- package/dist/runtime/step-snapshot.js +286 -0
- package/dist/runtime/step-snapshot.js.map +1 -0
- package/dist/runtime/subagent-thread-runtime.d.ts +239 -0
- package/dist/runtime/subagent-thread-runtime.d.ts.map +1 -0
- package/dist/runtime/subagent-thread-runtime.js +876 -0
- package/dist/runtime/subagent-thread-runtime.js.map +1 -0
- package/dist/runtime/subagents/index.d.ts +4 -1
- package/dist/runtime/subagents/index.d.ts.map +1 -1
- package/dist/runtime/subagents/index.js +10 -2
- package/dist/runtime/subagents/index.js.map +1 -1
- package/dist/runtime/subagents/parent-step-fork.d.ts +36 -0
- package/dist/runtime/subagents/parent-step-fork.d.ts.map +1 -0
- package/dist/runtime/subagents/parent-step-fork.js +83 -0
- package/dist/runtime/subagents/parent-step-fork.js.map +1 -0
- package/dist/runtime/subagents/production.d.ts +65 -46
- package/dist/runtime/subagents/production.d.ts.map +1 -1
- package/dist/runtime/subagents/production.js +494 -170
- package/dist/runtime/subagents/production.js.map +1 -1
- package/dist/runtime/subagents/receipt-journal.d.ts +20 -0
- package/dist/runtime/subagents/receipt-journal.d.ts.map +1 -0
- package/dist/runtime/subagents/receipt-journal.js +74 -0
- package/dist/runtime/subagents/receipt-journal.js.map +1 -0
- package/dist/runtime/subagents/runtime-contract.d.ts +29 -0
- package/dist/runtime/subagents/runtime-contract.d.ts.map +1 -0
- package/dist/runtime/subagents/runtime-contract.js +3 -0
- package/dist/runtime/subagents/runtime-contract.js.map +1 -0
- package/dist/runtime/subagents/runtime-integration.d.ts +41 -56
- package/dist/runtime/subagents/runtime-integration.d.ts.map +1 -1
- package/dist/runtime/subagents/runtime-integration.js +34 -198
- package/dist/runtime/subagents/runtime-integration.js.map +1 -1
- package/dist/runtime/subagents/supervisor.d.ts +19 -7
- package/dist/runtime/subagents/supervisor.d.ts.map +1 -1
- package/dist/runtime/subagents/supervisor.js +83 -40
- package/dist/runtime/subagents/supervisor.js.map +1 -1
- package/dist/runtime/subagents/types.d.ts +1 -1
- package/dist/runtime/subagents/types.js +1 -1
- package/dist/runtime/task-context-service.d.ts +91 -0
- package/dist/runtime/task-context-service.d.ts.map +1 -0
- package/dist/runtime/task-context-service.js +122 -0
- package/dist/runtime/task-context-service.js.map +1 -0
- package/dist/runtime/thread-admission.d.ts +130 -0
- package/dist/runtime/thread-admission.d.ts.map +1 -0
- package/dist/runtime/thread-admission.js +276 -0
- package/dist/runtime/thread-admission.js.map +1 -0
- package/dist/runtime/thread-compact-persistence.d.ts +50 -0
- package/dist/runtime/thread-compact-persistence.d.ts.map +1 -0
- package/dist/runtime/thread-compact-persistence.js +176 -0
- package/dist/runtime/thread-compact-persistence.js.map +1 -0
- package/dist/runtime/thread-event-store.d.ts +98 -0
- package/dist/runtime/thread-event-store.d.ts.map +1 -0
- package/dist/runtime/thread-event-store.js +737 -0
- package/dist/runtime/thread-event-store.js.map +1 -0
- package/dist/runtime/thread-projection.d.ts +91 -0
- package/dist/runtime/thread-projection.d.ts.map +1 -0
- package/dist/runtime/thread-projection.js +407 -0
- package/dist/runtime/thread-projection.js.map +1 -0
- package/dist/runtime/thread-runtime.d.ts +165 -0
- package/dist/runtime/thread-runtime.d.ts.map +1 -0
- package/dist/runtime/thread-runtime.js +704 -0
- package/dist/runtime/thread-runtime.js.map +1 -0
- package/dist/runtime/thread-session-view.d.ts +45 -0
- package/dist/runtime/thread-session-view.d.ts.map +1 -0
- package/dist/runtime/thread-session-view.js +264 -0
- package/dist/runtime/thread-session-view.js.map +1 -0
- package/dist/runtime/thread-tool-journal.d.ts +11 -0
- package/dist/runtime/thread-tool-journal.d.ts.map +1 -0
- package/dist/runtime/thread-tool-journal.js +131 -0
- package/dist/runtime/thread-tool-journal.js.map +1 -0
- package/dist/runtime/thread-ui-adapter.d.ts +87 -0
- package/dist/runtime/thread-ui-adapter.d.ts.map +1 -0
- package/dist/runtime/thread-ui-adapter.js +580 -0
- package/dist/runtime/thread-ui-adapter.js.map +1 -0
- package/dist/runtime/tool-gateway.d.ts +159 -0
- package/dist/runtime/tool-gateway.d.ts.map +1 -0
- package/dist/runtime/tool-gateway.js +311 -0
- package/dist/runtime/tool-gateway.js.map +1 -0
- package/dist/runtime/turn-commit.d.ts +103 -0
- package/dist/runtime/turn-commit.d.ts.map +1 -0
- package/dist/runtime/turn-commit.js +321 -0
- package/dist/runtime/turn-commit.js.map +1 -0
- package/dist/runtime/ui-events.d.ts +15 -5
- package/dist/runtime/ui-events.d.ts.map +1 -1
- package/dist/runtime/ui-events.js +0 -1
- package/dist/runtime/ui-events.js.map +1 -1
- package/dist/runtime/ui-view-model.d.ts +2 -1
- package/dist/runtime/ui-view-model.d.ts.map +1 -1
- package/dist/runtime/ui-view-model.js +6 -5
- package/dist/runtime/ui-view-model.js.map +1 -1
- package/dist/services/config-dir.d.ts +1 -1
- package/dist/services/config-dir.d.ts.map +1 -1
- package/dist/services/config-dir.js +2 -1
- package/dist/services/config-dir.js.map +1 -1
- package/dist/services/config.d.ts +2 -16
- package/dist/services/config.d.ts.map +1 -1
- package/dist/services/config.js +2 -29
- package/dist/services/config.js.map +1 -1
- package/dist/services/doctor.d.ts +0 -2
- package/dist/services/doctor.d.ts.map +1 -1
- package/dist/services/doctor.js +39 -64
- package/dist/services/doctor.js.map +1 -1
- package/dist/services/file-lock.d.ts.map +1 -1
- package/dist/services/file-lock.js +42 -17
- package/dist/services/file-lock.js.map +1 -1
- package/dist/services/global-config.d.ts +2 -2
- package/dist/services/global-config.d.ts.map +1 -1
- package/dist/services/session-storage.d.ts +8 -0
- package/dist/services/session-storage.d.ts.map +1 -1
- package/dist/services/session-storage.js +76 -12
- package/dist/services/session-storage.js.map +1 -1
- package/dist/skills/builtin/code-review/SKILL.md +51 -0
- package/dist/skills/builtin/security-check/SKILL.md +54 -0
- package/dist/skills/builtin/test-gen/SKILL.md +49 -0
- package/dist/terminal-ui/launch.d.ts +3 -1
- package/dist/terminal-ui/launch.d.ts.map +1 -1
- package/dist/terminal-ui/launch.js +21 -3
- package/dist/terminal-ui/launch.js.map +1 -1
- package/dist/tools/core/common.d.ts +34 -0
- package/dist/tools/core/common.d.ts.map +1 -0
- package/dist/tools/core/common.js +164 -0
- package/dist/tools/core/common.js.map +1 -0
- package/dist/tools/core/edit-file.d.ts +10 -0
- package/dist/tools/core/edit-file.d.ts.map +1 -0
- package/dist/tools/core/edit-file.js +301 -0
- package/dist/tools/core/edit-file.js.map +1 -0
- package/dist/tools/core/exec-command.d.ts +2 -0
- package/dist/tools/core/exec-command.d.ts.map +1 -0
- package/dist/tools/core/exec-command.js +347 -0
- package/dist/tools/core/exec-command.js.map +1 -0
- package/dist/tools/core/glob.d.ts +2 -0
- package/dist/tools/core/glob.d.ts.map +1 -0
- package/dist/tools/core/glob.js +133 -0
- package/dist/tools/core/glob.js.map +1 -0
- package/dist/tools/core/grep.d.ts +12 -0
- package/dist/tools/core/grep.d.ts.map +1 -0
- package/dist/tools/core/grep.js +223 -0
- package/dist/tools/core/grep.js.map +1 -0
- package/dist/tools/core/index.d.ts +15 -0
- package/dist/tools/core/index.d.ts.map +1 -0
- package/dist/tools/core/index.js +31 -0
- package/dist/tools/core/index.js.map +1 -0
- package/dist/tools/core/list-files.d.ts +2 -0
- package/dist/tools/core/list-files.d.ts.map +1 -0
- package/dist/tools/core/list-files.js +87 -0
- package/dist/tools/core/list-files.js.map +1 -0
- package/dist/tools/core/read-file.d.ts +2 -0
- package/dist/tools/core/read-file.d.ts.map +1 -0
- package/dist/tools/core/read-file.js +129 -0
- package/dist/tools/core/read-file.js.map +1 -0
- package/dist/tools/core/write-file.d.ts +2 -0
- package/dist/tools/core/write-file.d.ts.map +1 -0
- package/dist/tools/core/write-file.js +65 -0
- package/dist/tools/core/write-file.js.map +1 -0
- package/dist/tools/todo.d.ts +3 -4
- package/dist/tools/todo.d.ts.map +1 -1
- package/dist/tools/todo.js +80 -79
- package/dist/tools/todo.js.map +1 -1
- package/dist/tools/web.js +1 -1
- package/dist/tools/web.js.map +1 -1
- package/dist/tui-ui/chrome-view-model.d.ts.map +1 -1
- package/dist/tui-ui/chrome-view-model.js +22 -8
- package/dist/tui-ui/chrome-view-model.js.map +1 -1
- package/dist/tui-ui/launch.d.ts.map +1 -1
- package/dist/tui-ui/launch.js +13 -0
- package/dist/tui-ui/launch.js.map +1 -1
- package/dist/tui-ui/layout.js +1 -1
- package/dist/tui-ui/layout.js.map +1 -1
- package/dist/tui-ui/state.d.ts.map +1 -1
- package/dist/tui-ui/state.js +2 -0
- package/dist/tui-ui/state.js.map +1 -1
- package/docs/migration/v0.1.9-to-v0.2.0.md +98 -0
- package/docs/orion.example.json +79 -0
- package/docs/plan/v0.2.0-dsh-harness-redesign-plan.md +1234 -0
- package/docs/plan/v0.2.0-release-checklist.md +91 -0
- package/docs/readme.md +8 -8
- package/npm-shrinkwrap.json +45 -450
- package/package.json +17 -13
- package/dist/agents/coder.d.ts +0 -12
- package/dist/agents/coder.d.ts.map +0 -1
- package/dist/agents/coder.js +0 -48
- package/dist/agents/coder.js.map +0 -1
- package/dist/agents/coordinator.d.ts +0 -86
- package/dist/agents/coordinator.d.ts.map +0 -1
- package/dist/agents/coordinator.js +0 -291
- package/dist/agents/coordinator.js.map +0 -1
- package/dist/agents/fork.d.ts +0 -73
- package/dist/agents/fork.d.ts.map +0 -1
- package/dist/agents/fork.js +0 -163
- package/dist/agents/fork.js.map +0 -1
- package/dist/agents/leader.d.ts +0 -12
- package/dist/agents/leader.d.ts.map +0 -1
- package/dist/agents/leader.js +0 -49
- package/dist/agents/leader.js.map +0 -1
- package/dist/agents/router.d.ts +0 -59
- package/dist/agents/router.d.ts.map +0 -1
- package/dist/agents/router.js +0 -193
- package/dist/agents/router.js.map +0 -1
- package/dist/agents/worker-pool.d.ts +0 -72
- package/dist/agents/worker-pool.d.ts.map +0 -1
- package/dist/agents/worker-pool.js +0 -229
- package/dist/agents/worker-pool.js.map +0 -1
- package/dist/commands/legacy-commands.d.ts +0 -4
- package/dist/commands/legacy-commands.d.ts.map +0 -1
- package/dist/commands/legacy-commands.js +0 -44
- package/dist/commands/legacy-commands.js.map +0 -1
- package/dist/core/agent.d.ts +0 -84
- package/dist/core/agent.d.ts.map +0 -1
- package/dist/core/agent.js +0 -58
- package/dist/core/agent.js.map +0 -1
- package/dist/core/brain.d.ts +0 -50
- package/dist/core/brain.d.ts.map +0 -1
- package/dist/core/brain.js +0 -95
- package/dist/core/brain.js.map +0 -1
- package/dist/framework/tool-scheduler.d.ts +0 -191
- package/dist/framework/tool-scheduler.d.ts.map +0 -1
- package/dist/framework/tool-scheduler.js +0 -573
- package/dist/framework/tool-scheduler.js.map +0 -1
- package/dist/harness/harness.d.ts +0 -58
- package/dist/harness/harness.d.ts.map +0 -1
- package/dist/harness/harness.js +0 -195
- package/dist/harness/harness.js.map +0 -1
- package/dist/harness/safety.d.ts +0 -101
- package/dist/harness/safety.d.ts.map +0 -1
- package/dist/harness/safety.js +0 -322
- package/dist/harness/safety.js.map +0 -1
- package/dist/init.d.ts +0 -108
- package/dist/init.d.ts.map +0 -1
- package/dist/init.js +0 -393
- package/dist/init.js.map +0 -1
- package/dist/ink-ui/App.d.ts +0 -9
- package/dist/ink-ui/App.d.ts.map +0 -1
- package/dist/ink-ui/App.js +0 -12
- package/dist/ink-ui/App.js.map +0 -1
- package/dist/ink-ui/components/Markdown.d.ts +0 -10
- package/dist/ink-ui/components/Markdown.d.ts.map +0 -1
- package/dist/ink-ui/components/Markdown.js +0 -210
- package/dist/ink-ui/components/Markdown.js.map +0 -1
- package/dist/ink-ui/components/NativeCursor.d.ts +0 -12
- package/dist/ink-ui/components/NativeCursor.d.ts.map +0 -1
- package/dist/ink-ui/components/NativeCursor.js +0 -35
- package/dist/ink-ui/components/NativeCursor.js.map +0 -1
- package/dist/ink-ui/components/PixelHorseBanner.d.ts +0 -8
- package/dist/ink-ui/components/PixelHorseBanner.d.ts.map +0 -1
- package/dist/ink-ui/components/PixelHorseBanner.js +0 -97
- package/dist/ink-ui/components/PixelHorseBanner.js.map +0 -1
- package/dist/ink-ui/components/PromptInput.d.ts +0 -13
- package/dist/ink-ui/components/PromptInput.d.ts.map +0 -1
- package/dist/ink-ui/components/PromptInput.js +0 -30
- package/dist/ink-ui/components/PromptInput.js.map +0 -1
- package/dist/ink-ui/components/RunningHorseIndicator.d.ts +0 -13
- package/dist/ink-ui/components/RunningHorseIndicator.d.ts.map +0 -1
- package/dist/ink-ui/components/RunningHorseIndicator.js +0 -53
- package/dist/ink-ui/components/RunningHorseIndicator.js.map +0 -1
- package/dist/ink-ui/components/SelectList.d.ts +0 -16
- package/dist/ink-ui/components/SelectList.d.ts.map +0 -1
- package/dist/ink-ui/components/SelectList.js +0 -60
- package/dist/ink-ui/components/SelectList.js.map +0 -1
- package/dist/ink-ui/components/StatusLine.d.ts +0 -11
- package/dist/ink-ui/components/StatusLine.d.ts.map +0 -1
- package/dist/ink-ui/components/StatusLine.js +0 -70
- package/dist/ink-ui/components/StatusLine.js.map +0 -1
- package/dist/ink-ui/components/ToolActivity.d.ts +0 -19
- package/dist/ink-ui/components/ToolActivity.d.ts.map +0 -1
- package/dist/ink-ui/components/ToolActivity.js +0 -134
- package/dist/ink-ui/components/ToolActivity.js.map +0 -1
- package/dist/ink-ui/components/Transcript.d.ts +0 -14
- package/dist/ink-ui/components/Transcript.d.ts.map +0 -1
- package/dist/ink-ui/components/Transcript.js +0 -66
- package/dist/ink-ui/components/Transcript.js.map +0 -1
- package/dist/ink-ui/controllers/chat-controller.d.ts +0 -2
- package/dist/ink-ui/controllers/chat-controller.d.ts.map +0 -1
- package/dist/ink-ui/controllers/chat-controller.js.map +0 -1
- package/dist/ink-ui/hooks/use-raw-input-bridge.d.ts +0 -6
- package/dist/ink-ui/hooks/use-raw-input-bridge.d.ts.map +0 -1
- package/dist/ink-ui/hooks/use-raw-input-bridge.js +0 -27
- package/dist/ink-ui/hooks/use-raw-input-bridge.js.map +0 -1
- package/dist/ink-ui/hooks/use-terminal-size.d.ts +0 -7
- package/dist/ink-ui/hooks/use-terminal-size.d.ts.map +0 -1
- package/dist/ink-ui/hooks/use-terminal-size.js +0 -34
- package/dist/ink-ui/hooks/use-terminal-size.js.map +0 -1
- package/dist/ink-ui/launch.d.ts +0 -9
- package/dist/ink-ui/launch.d.ts.map +0 -1
- package/dist/ink-ui/launch.js +0 -101
- package/dist/ink-ui/launch.js.map +0 -1
- package/dist/ink-ui/runtime/grapheme.d.ts +0 -10
- package/dist/ink-ui/runtime/grapheme.d.ts.map +0 -1
- package/dist/ink-ui/runtime/grapheme.js +0 -17
- package/dist/ink-ui/runtime/grapheme.js.map +0 -1
- package/dist/ink-ui/runtime/input-buffer.d.ts +0 -10
- package/dist/ink-ui/runtime/input-buffer.d.ts.map +0 -1
- package/dist/ink-ui/runtime/input-buffer.js +0 -18
- package/dist/ink-ui/runtime/input-buffer.js.map +0 -1
- package/dist/ink-ui/runtime/layout-budget.d.ts +0 -13
- package/dist/ink-ui/runtime/layout-budget.d.ts.map +0 -1
- package/dist/ink-ui/runtime/layout-budget.js +0 -25
- package/dist/ink-ui/runtime/layout-budget.js.map +0 -1
- package/dist/ink-ui/runtime/native-cursor.d.ts +0 -62
- package/dist/ink-ui/runtime/native-cursor.d.ts.map +0 -1
- package/dist/ink-ui/runtime/native-cursor.js +0 -398
- package/dist/ink-ui/runtime/native-cursor.js.map +0 -1
- package/dist/ink-ui/runtime/prompt-layout.d.ts +0 -10
- package/dist/ink-ui/runtime/prompt-layout.d.ts.map +0 -1
- package/dist/ink-ui/runtime/prompt-layout.js +0 -21
- package/dist/ink-ui/runtime/prompt-layout.js.map +0 -1
- package/dist/ink-ui/runtime/raw-input.d.ts +0 -4
- package/dist/ink-ui/runtime/raw-input.d.ts.map +0 -1
- package/dist/ink-ui/runtime/raw-input.js +0 -15
- package/dist/ink-ui/runtime/raw-input.js.map +0 -1
- package/dist/ink-ui/runtime/transcript-state.d.ts +0 -37
- package/dist/ink-ui/runtime/transcript-state.d.ts.map +0 -1
- package/dist/ink-ui/runtime/transcript-state.js +0 -91
- package/dist/ink-ui/runtime/transcript-state.js.map +0 -1
- package/dist/ink-ui/screens/ReplScreen.d.ts +0 -27
- package/dist/ink-ui/screens/ReplScreen.d.ts.map +0 -1
- package/dist/ink-ui/screens/ReplScreen.js +0 -781
- package/dist/ink-ui/screens/ReplScreen.js.map +0 -1
- package/dist/ink-ui/types.d.ts +0 -2
- package/dist/ink-ui/types.d.ts.map +0 -1
- package/dist/ink-ui/types.js.map +0 -1
- package/dist/runtime/chat-checkpoint.d.ts +0 -17
- package/dist/runtime/chat-checkpoint.d.ts.map +0 -1
- package/dist/runtime/chat-checkpoint.js +0 -105
- package/dist/runtime/chat-checkpoint.js.map +0 -1
- package/dist/runtime/chat-command-scope.d.ts +0 -5
- package/dist/runtime/chat-command-scope.d.ts.map +0 -1
- package/dist/runtime/chat-command-scope.js +0 -22
- package/dist/runtime/chat-command-scope.js.map +0 -1
- package/dist/runtime/chat-compact.d.ts +0 -26
- package/dist/runtime/chat-compact.d.ts.map +0 -1
- package/dist/runtime/chat-compact.js +0 -132
- package/dist/runtime/chat-compact.js.map +0 -1
- package/dist/runtime/chat-controller.d.ts +0 -62
- package/dist/runtime/chat-controller.d.ts.map +0 -1
- package/dist/runtime/chat-controller.js +0 -1620
- package/dist/runtime/chat-controller.js.map +0 -1
- package/dist/runtime/chat-effort.d.ts +0 -5
- package/dist/runtime/chat-effort.d.ts.map +0 -1
- package/dist/runtime/chat-effort.js +0 -47
- package/dist/runtime/chat-effort.js.map +0 -1
- package/dist/runtime/chat-presentation.d.ts +0 -63
- package/dist/runtime/chat-presentation.d.ts.map +0 -1
- package/dist/runtime/chat-presentation.js +0 -561
- package/dist/runtime/chat-presentation.js.map +0 -1
- package/dist/runtime/chat-trace.d.ts +0 -52
- package/dist/runtime/chat-trace.d.ts.map +0 -1
- package/dist/runtime/chat-trace.js +0 -234
- package/dist/runtime/chat-trace.js.map +0 -1
- package/dist/runtime/chat-workspace.d.ts +0 -22
- package/dist/runtime/chat-workspace.d.ts.map +0 -1
- package/dist/runtime/chat-workspace.js +0 -154
- package/dist/runtime/chat-workspace.js.map +0 -1
- package/dist/runtime/goals/accounting.d.ts +0 -45
- package/dist/runtime/goals/accounting.d.ts.map +0 -1
- package/dist/runtime/goals/accounting.js +0 -114
- package/dist/runtime/goals/accounting.js.map +0 -1
- package/dist/runtime/goals/coordinator.d.ts +0 -92
- package/dist/runtime/goals/coordinator.d.ts.map +0 -1
- package/dist/runtime/goals/coordinator.js +0 -1471
- package/dist/runtime/goals/coordinator.js.map +0 -1
- package/dist/runtime/goals/lifecycle.d.ts +0 -13
- package/dist/runtime/goals/lifecycle.d.ts.map +0 -1
- package/dist/runtime/goals/lifecycle.js +0 -46
- package/dist/runtime/goals/lifecycle.js.map +0 -1
- package/dist/runtime/goals/prompt.d.ts +0 -16
- package/dist/runtime/goals/prompt.d.ts.map +0 -1
- package/dist/runtime/goals/prompt.js +0 -88
- package/dist/runtime/goals/prompt.js.map +0 -1
- package/dist/runtime/goals/stop-policy.d.ts +0 -9
- package/dist/runtime/goals/stop-policy.d.ts.map +0 -1
- package/dist/runtime/goals/stop-policy.js +0 -83
- package/dist/runtime/goals/stop-policy.js.map +0 -1
- package/dist/runtime/goals/tools.d.ts +0 -61
- package/dist/runtime/goals/tools.d.ts.map +0 -1
- package/dist/runtime/goals/tools.js +0 -568
- package/dist/runtime/goals/tools.js.map +0 -1
- package/dist/sdk/index.d.ts +0 -10
- package/dist/sdk/index.d.ts.map +0 -1
- package/dist/sdk/index.js +0 -23
- package/dist/sdk/index.js.map +0 -1
- package/dist/sdk/init.d.ts +0 -24
- package/dist/sdk/init.d.ts.map +0 -1
- package/dist/sdk/init.js +0 -48
- package/dist/sdk/init.js.map +0 -1
- package/dist/sdk/query.d.ts +0 -19
- package/dist/sdk/query.d.ts.map +0 -1
- package/dist/sdk/query.js +0 -42
- package/dist/sdk/query.js.map +0 -1
- package/dist/sdk/sessions.d.ts +0 -19
- package/dist/sdk/sessions.d.ts.map +0 -1
- package/dist/sdk/sessions.js +0 -57
- package/dist/sdk/sessions.js.map +0 -1
- package/dist/sdk/types.d.ts +0 -47
- package/dist/sdk/types.d.ts.map +0 -1
- package/dist/sdk/types.js +0 -8
- package/dist/sdk/types.js.map +0 -1
- package/dist/services/agent-runner.d.ts +0 -71
- package/dist/services/agent-runner.d.ts.map +0 -1
- package/dist/services/agent-runner.js +0 -185
- package/dist/services/agent-runner.js.map +0 -1
- package/dist/services/task-manager.d.ts +0 -161
- package/dist/services/task-manager.d.ts.map +0 -1
- package/dist/services/task-manager.js +0 -315
- package/dist/services/task-manager.js.map +0 -1
- package/dist/skills/discovery.d.ts +0 -22
- package/dist/skills/discovery.d.ts.map +0 -1
- package/dist/skills/discovery.js +0 -75
- package/dist/skills/discovery.js.map +0 -1
- package/dist/skills/index.d.ts +0 -11
- package/dist/skills/index.d.ts.map +0 -1
- package/dist/skills/index.js.map +0 -1
- package/dist/skills/loader.d.ts +0 -53
- package/dist/skills/loader.d.ts.map +0 -1
- package/dist/skills/loader.js +0 -421
- package/dist/skills/loader.js.map +0 -1
- package/dist/skills/registry.d.ts +0 -41
- package/dist/skills/registry.d.ts.map +0 -1
- package/dist/skills/registry.js +0 -157
- package/dist/skills/registry.js.map +0 -1
- package/dist/skills/runtime.d.ts +0 -46
- package/dist/skills/runtime.d.ts.map +0 -1
- package/dist/skills/runtime.js +0 -363
- package/dist/skills/runtime.js.map +0 -1
- package/dist/skills/types.d.ts +0 -112
- package/dist/skills/types.d.ts.map +0 -1
- package/dist/skills/types.js +0 -24
- package/dist/skills/types.js.map +0 -1
- package/dist/tools/index.d.ts +0 -52
- package/dist/tools/index.d.ts.map +0 -1
- package/dist/tools/index.js +0 -2268
- package/dist/tools/index.js.map +0 -1
- package/dist/tools/mcp.d.ts +0 -99
- package/dist/tools/mcp.d.ts.map +0 -1
- package/dist/tools/mcp.js +0 -695
- package/dist/tools/mcp.js.map +0 -1
- package/dist/tools/plan.d.ts +0 -17
- package/dist/tools/plan.d.ts.map +0 -1
- package/dist/tools/plan.js +0 -84
- package/dist/tools/plan.js.map +0 -1
- package/docs/migration/v0.1.8-to-v0.1.9.md +0 -60
- package/docs/plan/v0.1.9-release-checklist.md +0 -64
|
@@ -0,0 +1,854 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.LazyMcpRuntime = exports.StaleMcpToolResultError = exports.McpToolBindingUnavailableError = exports.StaleMcpActivationError = exports.McpServerDrainingError = exports.StaleMcpCatalogError = exports.LazyMcpRuntimeError = void 0;
|
|
4
|
+
const canonical_1 = require("../protocol/canonical");
|
|
5
|
+
const types_1 = require("./types");
|
|
6
|
+
const DEFAULT_IDLE_TIMEOUT_MS = 30000;
|
|
7
|
+
const DEFAULT_MAX_SERVERS = 64;
|
|
8
|
+
const DEFAULT_MAX_TOOLS_PER_SERVER = 256;
|
|
9
|
+
const MAX_DESCRIPTION_CHARS = 320;
|
|
10
|
+
const VALID_TRANSPORTS = new Set([
|
|
11
|
+
'stdio',
|
|
12
|
+
'sse',
|
|
13
|
+
'http',
|
|
14
|
+
'streamable-http',
|
|
15
|
+
'websocket',
|
|
16
|
+
]);
|
|
17
|
+
class LazyMcpRuntimeError extends Error {
|
|
18
|
+
constructor(message) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.code = 'ORION_LAZY_MCP_RUNTIME_ERROR';
|
|
21
|
+
this.name = 'LazyMcpRuntimeError';
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.LazyMcpRuntimeError = LazyMcpRuntimeError;
|
|
25
|
+
class StaleMcpCatalogError extends LazyMcpRuntimeError {
|
|
26
|
+
constructor(serverId) {
|
|
27
|
+
super(serverId
|
|
28
|
+
? `MCP catalog is stale for server ${serverId}; capture the descriptor catalog again.`
|
|
29
|
+
: 'MCP catalog is stale; capture the descriptor catalog again.');
|
|
30
|
+
this.code = 'ORION_STALE_MCP_CATALOG';
|
|
31
|
+
this.name = 'StaleMcpCatalogError';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.StaleMcpCatalogError = StaleMcpCatalogError;
|
|
35
|
+
class McpServerDrainingError extends LazyMcpRuntimeError {
|
|
36
|
+
constructor(serverId) {
|
|
37
|
+
super(`MCP server ${serverId} is draining and cannot accept a new lease.`);
|
|
38
|
+
this.code = 'ORION_MCP_SERVER_DRAINING';
|
|
39
|
+
this.name = 'McpServerDrainingError';
|
|
40
|
+
}
|
|
41
|
+
}
|
|
42
|
+
exports.McpServerDrainingError = McpServerDrainingError;
|
|
43
|
+
class StaleMcpActivationError extends LazyMcpRuntimeError {
|
|
44
|
+
constructor(serverId) {
|
|
45
|
+
super(`MCP server ${serverId} changed while connect/tools-list was in flight.`);
|
|
46
|
+
this.code = 'ORION_STALE_MCP_ACTIVATION';
|
|
47
|
+
this.name = 'StaleMcpActivationError';
|
|
48
|
+
}
|
|
49
|
+
}
|
|
50
|
+
exports.StaleMcpActivationError = StaleMcpActivationError;
|
|
51
|
+
class McpToolBindingUnavailableError extends LazyMcpRuntimeError {
|
|
52
|
+
constructor(ownerId, toolName) {
|
|
53
|
+
super(`Owner ${ownerId} has no active MCP lease for tool ${toolName}.`);
|
|
54
|
+
this.code = 'ORION_MCP_TOOL_BINDING_UNAVAILABLE';
|
|
55
|
+
this.name = 'McpToolBindingUnavailableError';
|
|
56
|
+
}
|
|
57
|
+
}
|
|
58
|
+
exports.McpToolBindingUnavailableError = McpToolBindingUnavailableError;
|
|
59
|
+
class StaleMcpToolResultError extends LazyMcpRuntimeError {
|
|
60
|
+
constructor(toolName) {
|
|
61
|
+
super(`MCP tool result for ${toolName} was discarded after its owner binding changed.`);
|
|
62
|
+
this.code = 'ORION_STALE_MCP_TOOL_RESULT';
|
|
63
|
+
this.name = 'StaleMcpToolResultError';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.StaleMcpToolResultError = StaleMcpToolResultError;
|
|
67
|
+
/**
|
|
68
|
+
* Descriptor-first, owner-leased MCP lifecycle.
|
|
69
|
+
*
|
|
70
|
+
* The constructor performs only deterministic descriptor normalization. The
|
|
71
|
+
* injected connector is not touched until acquire() selects one exact server.
|
|
72
|
+
*/
|
|
73
|
+
class LazyMcpRuntime {
|
|
74
|
+
constructor(options) {
|
|
75
|
+
this.version = types_1.LAZY_MCP_RUNTIME_VERSION;
|
|
76
|
+
this.lifecycleController = new AbortController();
|
|
77
|
+
this.records = new Map();
|
|
78
|
+
this.operations = new Set();
|
|
79
|
+
this.leaseSequence = 0;
|
|
80
|
+
this.disposed = false;
|
|
81
|
+
this.connector = options.connector;
|
|
82
|
+
this.idleTimeoutMs = validateBoundedInteger(options.idleTimeoutMs ?? DEFAULT_IDLE_TIMEOUT_MS, 'MCP idle timeout', 0);
|
|
83
|
+
this.maxServers = validateBoundedInteger(options.maxServers ?? DEFAULT_MAX_SERVERS, 'MCP server limit', 1);
|
|
84
|
+
this.maxToolsPerServer = validateBoundedInteger(options.maxToolsPerServer ?? DEFAULT_MAX_TOOLS_PER_SERVER, 'MCP per-server tool limit', 1);
|
|
85
|
+
this.catalogValue = composeCatalog(options.descriptors, this.maxServers);
|
|
86
|
+
for (const descriptor of this.catalogValue.descriptors) {
|
|
87
|
+
this.records.set(descriptor.id, createRecord(descriptor));
|
|
88
|
+
}
|
|
89
|
+
if (options.signal) {
|
|
90
|
+
const abortFromParent = () => {
|
|
91
|
+
void this.dispose(options.signal?.reason).catch(() => undefined);
|
|
92
|
+
};
|
|
93
|
+
options.signal.addEventListener('abort', abortFromParent, { once: true });
|
|
94
|
+
this.detachParentSignal = () => options.signal?.removeEventListener('abort', abortFromParent);
|
|
95
|
+
if (options.signal.aborted)
|
|
96
|
+
abortFromParent();
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
/** Safe, immutable server descriptors; this call performs no IO. */
|
|
100
|
+
getCatalog() {
|
|
101
|
+
return this.catalogValue;
|
|
102
|
+
}
|
|
103
|
+
/**
|
|
104
|
+
* Replace descriptor metadata and invalidate changed generations. Existing
|
|
105
|
+
* owners retain their frozen binding until release; new owners are rejected
|
|
106
|
+
* while the old transport drains.
|
|
107
|
+
*/
|
|
108
|
+
replaceDescriptors(descriptors) {
|
|
109
|
+
this.assertActive();
|
|
110
|
+
const nextCatalog = composeCatalog(descriptors, this.maxServers);
|
|
111
|
+
const nextById = new Map(nextCatalog.descriptors.map(descriptor => [descriptor.id, descriptor]));
|
|
112
|
+
this.catalogValue = nextCatalog;
|
|
113
|
+
for (const [serverId, record] of this.records) {
|
|
114
|
+
const next = nextById.get(serverId);
|
|
115
|
+
nextById.delete(serverId);
|
|
116
|
+
if (next && record.descriptor?.digest === next.digest) {
|
|
117
|
+
record.descriptor = next;
|
|
118
|
+
continue;
|
|
119
|
+
}
|
|
120
|
+
record.descriptor = next;
|
|
121
|
+
this.requestDrain(record, next ? 'descriptor_changed' : 'descriptor_removed');
|
|
122
|
+
}
|
|
123
|
+
for (const descriptor of nextById.values()) {
|
|
124
|
+
this.records.set(descriptor.id, createRecord(descriptor));
|
|
125
|
+
}
|
|
126
|
+
return this.catalogValue;
|
|
127
|
+
}
|
|
128
|
+
/** Explicit or Capability-Compiler selection activates exactly one server. */
|
|
129
|
+
async acquire(request) {
|
|
130
|
+
this.assertActive();
|
|
131
|
+
const ownerId = validateIdentifier(request.ownerId, 'MCP lease owner id');
|
|
132
|
+
const serverId = validateIdentifier(request.serverId, 'MCP server id');
|
|
133
|
+
validateSelectionReason(request.reason);
|
|
134
|
+
const descriptor = this.assertCatalogCurrent(request.catalog, serverId);
|
|
135
|
+
if (descriptor.disabled) {
|
|
136
|
+
throw new LazyMcpRuntimeError(`MCP server ${serverId} is disabled.`);
|
|
137
|
+
}
|
|
138
|
+
this.assertOwnerCatalog(ownerId, request.catalog.digest);
|
|
139
|
+
const record = this.records.get(serverId);
|
|
140
|
+
if (!record || !record.descriptor) {
|
|
141
|
+
throw new LazyMcpRuntimeError(`Unknown MCP server: ${serverId}`);
|
|
142
|
+
}
|
|
143
|
+
if (record.state === 'draining' || record.drainReason) {
|
|
144
|
+
throw new McpServerDrainingError(serverId);
|
|
145
|
+
}
|
|
146
|
+
record.pendingAcquires++;
|
|
147
|
+
this.clearIdleTimer(record);
|
|
148
|
+
try {
|
|
149
|
+
const binding = await waitForPromise(this.ensureActivated(record, descriptor), request.signal);
|
|
150
|
+
throwIfAborted(request.signal);
|
|
151
|
+
this.assertActive();
|
|
152
|
+
this.assertCatalogCurrent(request.catalog, serverId);
|
|
153
|
+
if (record.drainReason || record.binding?.bindingDigest !== binding.bindingDigest) {
|
|
154
|
+
throw new StaleMcpActivationError(serverId);
|
|
155
|
+
}
|
|
156
|
+
const leaseId = `mcp-lease:${serverId}:${++this.leaseSequence}`;
|
|
157
|
+
const active = {
|
|
158
|
+
leaseId,
|
|
159
|
+
ownerId,
|
|
160
|
+
reason: request.reason,
|
|
161
|
+
binding,
|
|
162
|
+
};
|
|
163
|
+
record.leases.set(leaseId, active);
|
|
164
|
+
record.state = 'connected';
|
|
165
|
+
record.failure = undefined;
|
|
166
|
+
let released = false;
|
|
167
|
+
return Object.freeze({
|
|
168
|
+
version: types_1.LAZY_MCP_RUNTIME_VERSION,
|
|
169
|
+
leaseId,
|
|
170
|
+
ownerId,
|
|
171
|
+
serverId,
|
|
172
|
+
reason: request.reason,
|
|
173
|
+
binding,
|
|
174
|
+
release: async () => {
|
|
175
|
+
if (released)
|
|
176
|
+
return;
|
|
177
|
+
released = true;
|
|
178
|
+
this.releaseLease(serverId, leaseId);
|
|
179
|
+
},
|
|
180
|
+
});
|
|
181
|
+
}
|
|
182
|
+
finally {
|
|
183
|
+
record.pendingAcquires--;
|
|
184
|
+
this.settleRecord(record);
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
/** Release every lease owned by a turn, step, or sub-agent scope. */
|
|
188
|
+
async releaseOwner(ownerId) {
|
|
189
|
+
const normalized = validateIdentifier(ownerId, 'MCP lease owner id');
|
|
190
|
+
for (const [serverId, record] of this.records) {
|
|
191
|
+
for (const lease of [...record.leases.values()]) {
|
|
192
|
+
if (lease.ownerId === normalized)
|
|
193
|
+
this.releaseLease(serverId, lease.leaseId);
|
|
194
|
+
}
|
|
195
|
+
}
|
|
196
|
+
}
|
|
197
|
+
/**
|
|
198
|
+
* Serializable binding pinned to the owner's leases. Once the owner releases
|
|
199
|
+
* them, this becomes empty immediately even while a transport idles/drains.
|
|
200
|
+
*/
|
|
201
|
+
bindingSnapshotForOwner(ownerId) {
|
|
202
|
+
this.assertActive();
|
|
203
|
+
const normalized = validateIdentifier(ownerId, 'MCP lease owner id');
|
|
204
|
+
const byServer = this.ownerBindings(normalized);
|
|
205
|
+
const servers = [...byServer.values()].sort((left, right) => left.serverId.localeCompare(right.serverId));
|
|
206
|
+
const catalogDigest = servers.length === 0 ? this.catalogValue.digest : servers[0].catalogDigest;
|
|
207
|
+
if (servers.some(binding => binding.catalogDigest !== catalogDigest)) {
|
|
208
|
+
throw new LazyMcpRuntimeError(`Owner ${normalized} has mixed MCP catalog generations.`);
|
|
209
|
+
}
|
|
210
|
+
const selected = servers
|
|
211
|
+
.flatMap(binding => binding.tools.map(tool => ({
|
|
212
|
+
serverId: binding.serverId,
|
|
213
|
+
toolName: tool.qualifiedName,
|
|
214
|
+
bindingDigest: tool.bindingDigest,
|
|
215
|
+
})))
|
|
216
|
+
.sort((left, right) => left.toolName.localeCompare(right.toolName) || left.serverId.localeCompare(right.serverId));
|
|
217
|
+
const stepBase = {
|
|
218
|
+
version: types_1.LAZY_MCP_RUNTIME_VERSION,
|
|
219
|
+
selected,
|
|
220
|
+
catalogDigest,
|
|
221
|
+
};
|
|
222
|
+
const step = deepFreeze({
|
|
223
|
+
...stepBase,
|
|
224
|
+
digest: (0, canonical_1.digestRuntimeValue)(stepBase),
|
|
225
|
+
});
|
|
226
|
+
const base = {
|
|
227
|
+
version: types_1.LAZY_MCP_RUNTIME_VERSION,
|
|
228
|
+
ownerId: normalized,
|
|
229
|
+
servers,
|
|
230
|
+
step,
|
|
231
|
+
};
|
|
232
|
+
return deepFreeze({ ...base, digest: (0, canonical_1.digestRuntimeValue)(base) });
|
|
233
|
+
}
|
|
234
|
+
/** Executable owner bindings for a Step factory; no global connected-tool view exists. */
|
|
235
|
+
toolBindingsForOwner(ownerId) {
|
|
236
|
+
this.assertActive();
|
|
237
|
+
const normalized = validateIdentifier(ownerId, 'MCP lease owner id');
|
|
238
|
+
const descriptors = [...this.ownerBindings(normalized).values()]
|
|
239
|
+
.flatMap(binding => binding.tools)
|
|
240
|
+
.sort((left, right) => left.qualifiedName.localeCompare(right.qualifiedName));
|
|
241
|
+
return Object.freeze(descriptors.map(descriptor => Object.freeze({
|
|
242
|
+
descriptor,
|
|
243
|
+
invoke: (args, signal) => this.invoke(normalized, descriptor.qualifiedName, args, signal),
|
|
244
|
+
})));
|
|
245
|
+
}
|
|
246
|
+
/** Execute only through an active owner lease. */
|
|
247
|
+
async invoke(ownerId, qualifiedToolName, args, signal) {
|
|
248
|
+
this.assertActive();
|
|
249
|
+
const normalizedOwner = validateIdentifier(ownerId, 'MCP lease owner id');
|
|
250
|
+
const normalizedTool = validateIdentifier(qualifiedToolName, 'MCP qualified tool name');
|
|
251
|
+
const selected = this.findOwnerTool(normalizedOwner, normalizedTool);
|
|
252
|
+
if (!selected)
|
|
253
|
+
throw new McpToolBindingUnavailableError(normalizedOwner, normalizedTool);
|
|
254
|
+
const { record, binding, tool } = selected;
|
|
255
|
+
const connection = record.connection;
|
|
256
|
+
if (!connection)
|
|
257
|
+
throw new McpToolBindingUnavailableError(normalizedOwner, normalizedTool);
|
|
258
|
+
record.activeCalls++;
|
|
259
|
+
this.clearIdleTimer(record);
|
|
260
|
+
const linked = linkSignals(this.lifecycleController.signal, signal);
|
|
261
|
+
const operation = (async () => {
|
|
262
|
+
throwIfAborted(linked.signal);
|
|
263
|
+
const result = await connection.callTool(tool.name, args, linked.signal);
|
|
264
|
+
throwIfAborted(linked.signal);
|
|
265
|
+
if (record.connection !== connection ||
|
|
266
|
+
!this.ownerHasBinding(record, normalizedOwner, binding.bindingDigest)) {
|
|
267
|
+
throw new StaleMcpToolResultError(normalizedTool);
|
|
268
|
+
}
|
|
269
|
+
return result;
|
|
270
|
+
})();
|
|
271
|
+
this.track(operation);
|
|
272
|
+
try {
|
|
273
|
+
return await operation;
|
|
274
|
+
}
|
|
275
|
+
finally {
|
|
276
|
+
linked.dispose();
|
|
277
|
+
record.activeCalls--;
|
|
278
|
+
this.settleRecord(record);
|
|
279
|
+
}
|
|
280
|
+
}
|
|
281
|
+
/** Begin a generation-safe explicit drain. Active lease owners finish first. */
|
|
282
|
+
beginDrain(serverId, reason = 'explicit_drain') {
|
|
283
|
+
this.assertActive();
|
|
284
|
+
const normalized = validateIdentifier(serverId, 'MCP server id');
|
|
285
|
+
const record = this.records.get(normalized);
|
|
286
|
+
if (!record)
|
|
287
|
+
throw new LazyMcpRuntimeError(`Unknown MCP server: ${normalized}`);
|
|
288
|
+
this.requestDrain(record, validateIdentifier(reason, 'MCP drain reason'));
|
|
289
|
+
}
|
|
290
|
+
snapshot() {
|
|
291
|
+
const servers = [...this.records.entries()]
|
|
292
|
+
.map(([serverId, record]) => {
|
|
293
|
+
const leaseOwners = [
|
|
294
|
+
...new Set([...record.leases.values()].map(lease => lease.ownerId)),
|
|
295
|
+
].sort();
|
|
296
|
+
return deepFreeze({
|
|
297
|
+
serverId,
|
|
298
|
+
...(record.descriptor ? { descriptorDigest: record.descriptor.digest } : {}),
|
|
299
|
+
generation: record.generation,
|
|
300
|
+
state: record.state,
|
|
301
|
+
leaseOwners,
|
|
302
|
+
activeLeaseCount: record.leases.size,
|
|
303
|
+
activeCallCount: record.activeCalls,
|
|
304
|
+
pendingAcquireCount: record.pendingAcquires,
|
|
305
|
+
toolCount: record.binding?.tools.length ?? 0,
|
|
306
|
+
...(record.binding ? { toolsDigest: record.binding.toolsDigest } : {}),
|
|
307
|
+
...(record.failure ? { failure: record.failure } : {}),
|
|
308
|
+
});
|
|
309
|
+
})
|
|
310
|
+
.sort((left, right) => left.serverId.localeCompare(right.serverId));
|
|
311
|
+
const base = {
|
|
312
|
+
version: types_1.LAZY_MCP_RUNTIME_VERSION,
|
|
313
|
+
catalog: this.catalogValue,
|
|
314
|
+
servers,
|
|
315
|
+
};
|
|
316
|
+
return deepFreeze({ ...base, digest: (0, canonical_1.digestRuntimeValue)(base) });
|
|
317
|
+
}
|
|
318
|
+
dispose(reason = new Error('Lazy MCP runtime disposed.')) {
|
|
319
|
+
if (this.disposeFlight)
|
|
320
|
+
return this.disposeFlight;
|
|
321
|
+
const flight = this.performDispose(reason);
|
|
322
|
+
this.disposeFlight = flight;
|
|
323
|
+
return flight;
|
|
324
|
+
}
|
|
325
|
+
async performDispose(reason) {
|
|
326
|
+
this.disposed = true;
|
|
327
|
+
this.detachParentSignal?.();
|
|
328
|
+
if (!this.lifecycleController.signal.aborted)
|
|
329
|
+
this.lifecycleController.abort(reason);
|
|
330
|
+
for (const record of this.records.values()) {
|
|
331
|
+
record.leases.clear();
|
|
332
|
+
this.requestDrain(record, 'runtime_disposed');
|
|
333
|
+
}
|
|
334
|
+
await Promise.allSettled([...this.operations]);
|
|
335
|
+
for (const record of this.records.values())
|
|
336
|
+
this.maybeStartDrain(record);
|
|
337
|
+
await Promise.allSettled([...this.records.values()]
|
|
338
|
+
.map(record => record.drainPromise)
|
|
339
|
+
.filter((promise) => Boolean(promise)));
|
|
340
|
+
for (const record of this.records.values())
|
|
341
|
+
this.clearIdleTimer(record);
|
|
342
|
+
this.records.clear();
|
|
343
|
+
}
|
|
344
|
+
ensureActivated(record, descriptor) {
|
|
345
|
+
if (record.connection &&
|
|
346
|
+
record.binding &&
|
|
347
|
+
record.binding.serverDigest === descriptor.digest &&
|
|
348
|
+
!record.drainReason) {
|
|
349
|
+
if (record.binding.catalogDigest !== this.catalogValue.digest) {
|
|
350
|
+
record.binding = rebindToCatalog(record.binding, this.catalogValue.digest);
|
|
351
|
+
}
|
|
352
|
+
record.state = 'connected';
|
|
353
|
+
return Promise.resolve(record.binding);
|
|
354
|
+
}
|
|
355
|
+
if (record.activation) {
|
|
356
|
+
if (record.activation.token.generation === record.generation &&
|
|
357
|
+
record.activation.token.descriptorDigest === descriptor.digest) {
|
|
358
|
+
return record.activation.promise;
|
|
359
|
+
}
|
|
360
|
+
throw new StaleMcpActivationError(descriptor.id);
|
|
361
|
+
}
|
|
362
|
+
if (record.state === 'draining' || record.drainReason) {
|
|
363
|
+
throw new McpServerDrainingError(descriptor.id);
|
|
364
|
+
}
|
|
365
|
+
const token = {
|
|
366
|
+
generation: record.generation,
|
|
367
|
+
descriptorDigest: descriptor.digest,
|
|
368
|
+
controller: new AbortController(),
|
|
369
|
+
};
|
|
370
|
+
record.state = 'activating';
|
|
371
|
+
record.failure = undefined;
|
|
372
|
+
const promise = this.activate(record, descriptor, token);
|
|
373
|
+
const flight = { token, promise };
|
|
374
|
+
record.activation = flight;
|
|
375
|
+
this.track(promise);
|
|
376
|
+
void promise.then(() => this.activationSettled(record, flight), () => this.activationSettled(record, flight));
|
|
377
|
+
return promise;
|
|
378
|
+
}
|
|
379
|
+
async activate(record, descriptor, token) {
|
|
380
|
+
let connection;
|
|
381
|
+
try {
|
|
382
|
+
throwIfAborted(token.controller.signal);
|
|
383
|
+
connection = await this.connector.connect(descriptor, token.controller.signal);
|
|
384
|
+
this.assertActivationCurrent(record, descriptor, token);
|
|
385
|
+
const listed = await connection.listTools(token.controller.signal);
|
|
386
|
+
this.assertActivationCurrent(record, descriptor, token);
|
|
387
|
+
const tools = normalizeTools(descriptor, record.generation, listed, this.maxToolsPerServer);
|
|
388
|
+
const toolsDigest = (0, canonical_1.digestRuntimeValue)(tools);
|
|
389
|
+
const bindingBase = {
|
|
390
|
+
version: types_1.LAZY_MCP_RUNTIME_VERSION,
|
|
391
|
+
serverId: descriptor.id,
|
|
392
|
+
serverDigest: descriptor.digest,
|
|
393
|
+
catalogDigest: this.catalogValue.digest,
|
|
394
|
+
generation: record.generation,
|
|
395
|
+
tools,
|
|
396
|
+
toolsDigest,
|
|
397
|
+
};
|
|
398
|
+
const binding = deepFreeze({
|
|
399
|
+
...bindingBase,
|
|
400
|
+
bindingDigest: (0, canonical_1.digestRuntimeValue)(bindingBase),
|
|
401
|
+
});
|
|
402
|
+
this.assertActivationCurrent(record, descriptor, token);
|
|
403
|
+
record.connection = connection;
|
|
404
|
+
record.binding = binding;
|
|
405
|
+
record.failure = undefined;
|
|
406
|
+
record.state = record.pendingAcquires > 0 ? 'connected' : 'idle';
|
|
407
|
+
this.watchConnection(record, connection, binding);
|
|
408
|
+
return binding;
|
|
409
|
+
}
|
|
410
|
+
catch (error) {
|
|
411
|
+
if (connection && record.connection !== connection) {
|
|
412
|
+
await closeIgnoringFailure(connection, 'activation_not_published');
|
|
413
|
+
}
|
|
414
|
+
if (!this.isActivationCurrent(record, descriptor, token)) {
|
|
415
|
+
throw new StaleMcpActivationError(descriptor.id);
|
|
416
|
+
}
|
|
417
|
+
record.connection = undefined;
|
|
418
|
+
record.binding = undefined;
|
|
419
|
+
record.state = 'failed';
|
|
420
|
+
record.failure = errorMessage(error);
|
|
421
|
+
throw toError(error, `MCP server ${descriptor.id} activation failed.`);
|
|
422
|
+
}
|
|
423
|
+
}
|
|
424
|
+
activationSettled(record, flight) {
|
|
425
|
+
if (record.activation !== flight)
|
|
426
|
+
return;
|
|
427
|
+
record.activation = undefined;
|
|
428
|
+
this.settleRecord(record);
|
|
429
|
+
}
|
|
430
|
+
watchConnection(record, connection, binding) {
|
|
431
|
+
if (!connection.closed)
|
|
432
|
+
return;
|
|
433
|
+
void connection.closed.then(reason => this.handleUnexpectedClose(record, connection, binding, reason), error => this.handleUnexpectedClose(record, connection, binding, error));
|
|
434
|
+
}
|
|
435
|
+
handleUnexpectedClose(record, connection, binding, reason) {
|
|
436
|
+
if (this.disposed ||
|
|
437
|
+
record.drainReason ||
|
|
438
|
+
record.connection !== connection ||
|
|
439
|
+
record.binding?.bindingDigest !== binding.bindingDigest) {
|
|
440
|
+
return;
|
|
441
|
+
}
|
|
442
|
+
this.clearIdleTimer(record);
|
|
443
|
+
record.generation++;
|
|
444
|
+
record.connection = undefined;
|
|
445
|
+
record.binding = undefined;
|
|
446
|
+
record.leases.clear();
|
|
447
|
+
record.state = 'failed';
|
|
448
|
+
record.failure = `connection closed: ${errorMessage(reason || 'transport terminated')}`.slice(0, MAX_DESCRIPTION_CHARS);
|
|
449
|
+
}
|
|
450
|
+
assertActivationCurrent(record, descriptor, token) {
|
|
451
|
+
if (!this.isActivationCurrent(record, descriptor, token)) {
|
|
452
|
+
throw new StaleMcpActivationError(descriptor.id);
|
|
453
|
+
}
|
|
454
|
+
throwIfAborted(token.controller.signal);
|
|
455
|
+
}
|
|
456
|
+
isActivationCurrent(record, descriptor, token) {
|
|
457
|
+
return (!this.disposed &&
|
|
458
|
+
!record.drainReason &&
|
|
459
|
+
record.generation === token.generation &&
|
|
460
|
+
record.descriptor?.digest === descriptor.digest &&
|
|
461
|
+
token.descriptorDigest === descriptor.digest);
|
|
462
|
+
}
|
|
463
|
+
requestDrain(record, reason) {
|
|
464
|
+
this.clearIdleTimer(record);
|
|
465
|
+
record.generation++;
|
|
466
|
+
record.drainReason = reason;
|
|
467
|
+
record.state = 'draining';
|
|
468
|
+
record.failure = undefined;
|
|
469
|
+
if (record.activation && !record.activation.token.controller.signal.aborted) {
|
|
470
|
+
record.activation.token.controller.abort(new Error(`MCP server draining: ${reason}`));
|
|
471
|
+
}
|
|
472
|
+
this.maybeStartDrain(record);
|
|
473
|
+
}
|
|
474
|
+
maybeStartDrain(record) {
|
|
475
|
+
if (!record.drainReason ||
|
|
476
|
+
record.drainPromise ||
|
|
477
|
+
record.activation ||
|
|
478
|
+
record.leases.size > 0 ||
|
|
479
|
+
record.pendingAcquires > 0 ||
|
|
480
|
+
record.activeCalls > 0) {
|
|
481
|
+
return;
|
|
482
|
+
}
|
|
483
|
+
const connection = record.connection;
|
|
484
|
+
record.binding = undefined;
|
|
485
|
+
if (!connection) {
|
|
486
|
+
this.finishDrain(record);
|
|
487
|
+
return;
|
|
488
|
+
}
|
|
489
|
+
const reason = record.drainReason;
|
|
490
|
+
const drain = Promise.resolve().then(() => connection.close(reason));
|
|
491
|
+
record.drainPromise = drain;
|
|
492
|
+
this.track(drain);
|
|
493
|
+
void drain.then(() => {
|
|
494
|
+
if (record.connection === connection)
|
|
495
|
+
record.connection = undefined;
|
|
496
|
+
record.drainPromise = undefined;
|
|
497
|
+
this.finishDrain(record);
|
|
498
|
+
}, error => {
|
|
499
|
+
record.drainPromise = undefined;
|
|
500
|
+
record.state = 'failed';
|
|
501
|
+
record.failure = `close failed: ${errorMessage(error)}`;
|
|
502
|
+
});
|
|
503
|
+
}
|
|
504
|
+
finishDrain(record) {
|
|
505
|
+
record.connection = undefined;
|
|
506
|
+
record.binding = undefined;
|
|
507
|
+
record.drainReason = undefined;
|
|
508
|
+
record.failure = undefined;
|
|
509
|
+
if (this.disposed || !record.descriptor) {
|
|
510
|
+
for (const [serverId, candidate] of this.records) {
|
|
511
|
+
if (candidate === record)
|
|
512
|
+
this.records.delete(serverId);
|
|
513
|
+
}
|
|
514
|
+
return;
|
|
515
|
+
}
|
|
516
|
+
record.state = 'dormant';
|
|
517
|
+
}
|
|
518
|
+
settleRecord(record) {
|
|
519
|
+
if (record.drainReason) {
|
|
520
|
+
this.maybeStartDrain(record);
|
|
521
|
+
return;
|
|
522
|
+
}
|
|
523
|
+
if (record.connection && record.binding) {
|
|
524
|
+
if (record.leases.size > 0 || record.pendingAcquires > 0 || record.activeCalls > 0) {
|
|
525
|
+
this.clearIdleTimer(record);
|
|
526
|
+
record.state = 'connected';
|
|
527
|
+
}
|
|
528
|
+
else {
|
|
529
|
+
this.scheduleIdle(record);
|
|
530
|
+
}
|
|
531
|
+
}
|
|
532
|
+
}
|
|
533
|
+
scheduleIdle(record) {
|
|
534
|
+
if (record.idleTimer || record.drainReason || !record.connection)
|
|
535
|
+
return;
|
|
536
|
+
record.state = 'idle';
|
|
537
|
+
if (this.idleTimeoutMs === 0) {
|
|
538
|
+
this.requestDrain(record, 'idle_timeout');
|
|
539
|
+
return;
|
|
540
|
+
}
|
|
541
|
+
const timer = setTimeout(() => {
|
|
542
|
+
if (record.idleTimer !== timer)
|
|
543
|
+
return;
|
|
544
|
+
record.idleTimer = undefined;
|
|
545
|
+
this.requestDrain(record, 'idle_timeout');
|
|
546
|
+
}, this.idleTimeoutMs);
|
|
547
|
+
timer.unref?.();
|
|
548
|
+
record.idleTimer = timer;
|
|
549
|
+
}
|
|
550
|
+
clearIdleTimer(record) {
|
|
551
|
+
if (!record.idleTimer)
|
|
552
|
+
return;
|
|
553
|
+
clearTimeout(record.idleTimer);
|
|
554
|
+
record.idleTimer = undefined;
|
|
555
|
+
}
|
|
556
|
+
releaseLease(serverId, leaseId) {
|
|
557
|
+
const record = this.records.get(serverId);
|
|
558
|
+
if (!record || !record.leases.delete(leaseId))
|
|
559
|
+
return;
|
|
560
|
+
this.settleRecord(record);
|
|
561
|
+
}
|
|
562
|
+
ownerBindings(ownerId) {
|
|
563
|
+
const bindings = new Map();
|
|
564
|
+
for (const [serverId, record] of this.records) {
|
|
565
|
+
for (const lease of record.leases.values()) {
|
|
566
|
+
if (lease.ownerId !== ownerId)
|
|
567
|
+
continue;
|
|
568
|
+
const existing = bindings.get(serverId);
|
|
569
|
+
if (existing && existing.bindingDigest !== lease.binding.bindingDigest) {
|
|
570
|
+
throw new LazyMcpRuntimeError(`Owner ${ownerId} has mixed bindings for ${serverId}.`);
|
|
571
|
+
}
|
|
572
|
+
bindings.set(serverId, lease.binding);
|
|
573
|
+
}
|
|
574
|
+
}
|
|
575
|
+
return bindings;
|
|
576
|
+
}
|
|
577
|
+
assertOwnerCatalog(ownerId, catalogDigest) {
|
|
578
|
+
for (const binding of this.ownerBindings(ownerId).values()) {
|
|
579
|
+
if (binding.catalogDigest !== catalogDigest)
|
|
580
|
+
throw new StaleMcpCatalogError(binding.serverId);
|
|
581
|
+
}
|
|
582
|
+
}
|
|
583
|
+
findOwnerTool(ownerId, qualifiedToolName) {
|
|
584
|
+
for (const record of this.records.values()) {
|
|
585
|
+
for (const lease of record.leases.values()) {
|
|
586
|
+
if (lease.ownerId !== ownerId)
|
|
587
|
+
continue;
|
|
588
|
+
const tool = lease.binding.tools.find(item => item.qualifiedName === qualifiedToolName);
|
|
589
|
+
if (tool)
|
|
590
|
+
return { record, binding: lease.binding, tool };
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
return undefined;
|
|
594
|
+
}
|
|
595
|
+
ownerHasBinding(record, ownerId, bindingDigest) {
|
|
596
|
+
return [...record.leases.values()].some(lease => lease.ownerId === ownerId && lease.binding.bindingDigest === bindingDigest);
|
|
597
|
+
}
|
|
598
|
+
assertCatalogCurrent(catalog, serverId) {
|
|
599
|
+
const requested = catalog.descriptors.find(descriptor => descriptor.id === serverId);
|
|
600
|
+
const current = this.catalogValue.descriptors.find(descriptor => descriptor.id === serverId);
|
|
601
|
+
if (catalog.version !== types_1.LAZY_MCP_RUNTIME_VERSION ||
|
|
602
|
+
catalog.digest !== this.catalogValue.digest ||
|
|
603
|
+
!requested ||
|
|
604
|
+
!current ||
|
|
605
|
+
requested.digest !== current.digest) {
|
|
606
|
+
throw new StaleMcpCatalogError(serverId);
|
|
607
|
+
}
|
|
608
|
+
return current;
|
|
609
|
+
}
|
|
610
|
+
track(promise) {
|
|
611
|
+
this.operations.add(promise);
|
|
612
|
+
void promise.then(() => this.operations.delete(promise), () => this.operations.delete(promise));
|
|
613
|
+
return promise;
|
|
614
|
+
}
|
|
615
|
+
assertActive() {
|
|
616
|
+
if (this.disposed || this.lifecycleController.signal.aborted) {
|
|
617
|
+
throw new LazyMcpRuntimeError('Lazy MCP runtime is disposed.');
|
|
618
|
+
}
|
|
619
|
+
}
|
|
620
|
+
}
|
|
621
|
+
exports.LazyMcpRuntime = LazyMcpRuntime;
|
|
622
|
+
function createRecord(descriptor) {
|
|
623
|
+
return {
|
|
624
|
+
descriptor,
|
|
625
|
+
generation: 0,
|
|
626
|
+
state: 'dormant',
|
|
627
|
+
leases: new Map(),
|
|
628
|
+
pendingAcquires: 0,
|
|
629
|
+
activeCalls: 0,
|
|
630
|
+
};
|
|
631
|
+
}
|
|
632
|
+
function composeCatalog(inputs, maxServers) {
|
|
633
|
+
if (inputs.length > maxServers) {
|
|
634
|
+
throw new LazyMcpRuntimeError(`MCP descriptor count ${inputs.length} exceeds configured limit ${maxServers}.`);
|
|
635
|
+
}
|
|
636
|
+
const ids = new Set();
|
|
637
|
+
const namespaces = new Set();
|
|
638
|
+
const descriptors = inputs
|
|
639
|
+
.map(input => normalizeServerDescriptor(input))
|
|
640
|
+
.sort((left, right) => left.id.localeCompare(right.id));
|
|
641
|
+
for (const descriptor of descriptors) {
|
|
642
|
+
if (ids.has(descriptor.id)) {
|
|
643
|
+
throw new LazyMcpRuntimeError(`Duplicate MCP server id: ${descriptor.id}`);
|
|
644
|
+
}
|
|
645
|
+
ids.add(descriptor.id);
|
|
646
|
+
const namespace = sanitizeMcpNamePart(descriptor.id, 'server');
|
|
647
|
+
if (namespaces.has(namespace)) {
|
|
648
|
+
throw new LazyMcpRuntimeError(`MCP server ids collide after tool-name normalization: ${descriptor.id}`);
|
|
649
|
+
}
|
|
650
|
+
namespaces.add(namespace);
|
|
651
|
+
}
|
|
652
|
+
const base = { version: types_1.LAZY_MCP_RUNTIME_VERSION, descriptors };
|
|
653
|
+
return deepFreeze({ ...base, digest: (0, canonical_1.digestRuntimeValue)(base) });
|
|
654
|
+
}
|
|
655
|
+
function normalizeServerDescriptor(input) {
|
|
656
|
+
const id = validateIdentifier(input.id, 'MCP server id');
|
|
657
|
+
const name = validateIdentifier(input.name, `MCP server ${id} name`);
|
|
658
|
+
if (!VALID_TRANSPORTS.has(input.transport)) {
|
|
659
|
+
throw new LazyMcpRuntimeError(`MCP server ${id} has unsupported transport.`);
|
|
660
|
+
}
|
|
661
|
+
const description = (input.description ?? '').trim().slice(0, MAX_DESCRIPTION_CHARS);
|
|
662
|
+
const configDigest = validateIdentifier(input.configDigest, `MCP server ${id} config digest`);
|
|
663
|
+
const tags = Object.freeze([...new Set((input.tags ?? []).map(tag => tag.trim()).filter(Boolean))].sort());
|
|
664
|
+
const base = {
|
|
665
|
+
version: types_1.LAZY_MCP_RUNTIME_VERSION,
|
|
666
|
+
id,
|
|
667
|
+
name,
|
|
668
|
+
...(description ? { description } : {}),
|
|
669
|
+
transport: input.transport,
|
|
670
|
+
configDigest,
|
|
671
|
+
tags,
|
|
672
|
+
disabled: input.disabled === true,
|
|
673
|
+
};
|
|
674
|
+
return deepFreeze({ ...base, digest: (0, canonical_1.digestRuntimeValue)(base) });
|
|
675
|
+
}
|
|
676
|
+
function normalizeTools(descriptor, generation, listed, maxTools) {
|
|
677
|
+
if (!Array.isArray(listed)) {
|
|
678
|
+
throw new LazyMcpRuntimeError(`MCP server ${descriptor.id} returned a non-array tools list.`);
|
|
679
|
+
}
|
|
680
|
+
if (listed.length > maxTools) {
|
|
681
|
+
throw new LazyMcpRuntimeError(`MCP server ${descriptor.id} returned ${listed.length} tools; limit is ${maxTools}.`);
|
|
682
|
+
}
|
|
683
|
+
const nativeNames = new Set();
|
|
684
|
+
const qualifiedNames = new Set();
|
|
685
|
+
const tools = listed
|
|
686
|
+
.map(raw => {
|
|
687
|
+
const name = validateIdentifier(raw.name, `MCP server ${descriptor.id} tool name`);
|
|
688
|
+
if (nativeNames.has(name)) {
|
|
689
|
+
throw new LazyMcpRuntimeError(`MCP server ${descriptor.id} returned duplicate tool ${name}.`);
|
|
690
|
+
}
|
|
691
|
+
nativeNames.add(name);
|
|
692
|
+
const qualifiedName = buildQualifiedToolName(descriptor.id, name);
|
|
693
|
+
if (qualifiedNames.has(qualifiedName)) {
|
|
694
|
+
throw new LazyMcpRuntimeError(`MCP server ${descriptor.id} tool names collide after normalization: ${name}`);
|
|
695
|
+
}
|
|
696
|
+
qualifiedNames.add(qualifiedName);
|
|
697
|
+
const description = (raw.description ?? name).trim().slice(0, MAX_DESCRIPTION_CHARS) || name;
|
|
698
|
+
const inputSchema = normalizeInputSchema(raw.inputSchema);
|
|
699
|
+
const schemaDigest = (0, canonical_1.digestRuntimeValue)(inputSchema);
|
|
700
|
+
const bindingBase = {
|
|
701
|
+
version: types_1.LAZY_MCP_RUNTIME_VERSION,
|
|
702
|
+
serverId: descriptor.id,
|
|
703
|
+
serverDigest: descriptor.digest,
|
|
704
|
+
generation,
|
|
705
|
+
name,
|
|
706
|
+
qualifiedName,
|
|
707
|
+
description,
|
|
708
|
+
schemaDigest,
|
|
709
|
+
};
|
|
710
|
+
return deepFreeze({
|
|
711
|
+
version: types_1.LAZY_MCP_RUNTIME_VERSION,
|
|
712
|
+
serverId: descriptor.id,
|
|
713
|
+
name,
|
|
714
|
+
qualifiedName,
|
|
715
|
+
description,
|
|
716
|
+
inputSchema,
|
|
717
|
+
schemaDigest,
|
|
718
|
+
bindingDigest: (0, canonical_1.digestRuntimeValue)(bindingBase),
|
|
719
|
+
});
|
|
720
|
+
})
|
|
721
|
+
.sort((left, right) => left.qualifiedName.localeCompare(right.qualifiedName));
|
|
722
|
+
return deepFreeze(tools);
|
|
723
|
+
}
|
|
724
|
+
function rebindToCatalog(binding, catalogDigest) {
|
|
725
|
+
const base = {
|
|
726
|
+
version: types_1.LAZY_MCP_RUNTIME_VERSION,
|
|
727
|
+
serverId: binding.serverId,
|
|
728
|
+
serverDigest: binding.serverDigest,
|
|
729
|
+
catalogDigest,
|
|
730
|
+
generation: binding.generation,
|
|
731
|
+
tools: binding.tools,
|
|
732
|
+
toolsDigest: binding.toolsDigest,
|
|
733
|
+
};
|
|
734
|
+
return deepFreeze({ ...base, bindingDigest: (0, canonical_1.digestRuntimeValue)(base) });
|
|
735
|
+
}
|
|
736
|
+
function normalizeInputSchema(value) {
|
|
737
|
+
if (!isRecord(value) || value.type !== 'object') {
|
|
738
|
+
return deepFreeze({ type: 'object', properties: {} });
|
|
739
|
+
}
|
|
740
|
+
const cloned = structuredClone(value);
|
|
741
|
+
cloned.type = 'object';
|
|
742
|
+
if (!isRecord(cloned.properties))
|
|
743
|
+
cloned.properties = {};
|
|
744
|
+
if (cloned.required !== undefined && !Array.isArray(cloned.required))
|
|
745
|
+
delete cloned.required;
|
|
746
|
+
return deepFreeze(cloned);
|
|
747
|
+
}
|
|
748
|
+
function buildQualifiedToolName(serverId, toolName) {
|
|
749
|
+
return `mcp__${sanitizeMcpNamePart(serverId, 'server')}__${sanitizeMcpNamePart(toolName, 'tool')}`;
|
|
750
|
+
}
|
|
751
|
+
function sanitizeMcpNamePart(name, fallback) {
|
|
752
|
+
const sanitized = name
|
|
753
|
+
.replace(/[^A-Za-z0-9_-]/g, '_')
|
|
754
|
+
.replace(/_+/g, '_')
|
|
755
|
+
.replace(/^_+|_+$/g, '');
|
|
756
|
+
return sanitized || fallback;
|
|
757
|
+
}
|
|
758
|
+
function validateSelectionReason(reason) {
|
|
759
|
+
if (reason !== 'explicit' && reason !== 'capability') {
|
|
760
|
+
throw new LazyMcpRuntimeError(`Unsupported MCP selection reason: ${String(reason)}`);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
function validateIdentifier(value, label) {
|
|
764
|
+
const normalized = value.trim();
|
|
765
|
+
if (!normalized || normalized.includes('\u0000')) {
|
|
766
|
+
throw new LazyMcpRuntimeError(`${label} must be non-empty and contain no null bytes.`);
|
|
767
|
+
}
|
|
768
|
+
return normalized;
|
|
769
|
+
}
|
|
770
|
+
function validateBoundedInteger(value, label, minimum) {
|
|
771
|
+
if (!Number.isSafeInteger(value) || value < minimum) {
|
|
772
|
+
throw new LazyMcpRuntimeError(`${label} must be a safe integer >= ${minimum}.`);
|
|
773
|
+
}
|
|
774
|
+
return value;
|
|
775
|
+
}
|
|
776
|
+
function throwIfAborted(signal) {
|
|
777
|
+
if (!signal?.aborted)
|
|
778
|
+
return;
|
|
779
|
+
throw toError(signal.reason, 'MCP operation aborted.');
|
|
780
|
+
}
|
|
781
|
+
function linkSignals(primary, secondary) {
|
|
782
|
+
if (!secondary)
|
|
783
|
+
return { signal: primary, dispose: () => undefined };
|
|
784
|
+
const controller = new AbortController();
|
|
785
|
+
const abort = (signal) => {
|
|
786
|
+
if (!controller.signal.aborted)
|
|
787
|
+
controller.abort(signal.reason);
|
|
788
|
+
};
|
|
789
|
+
const onPrimary = () => abort(primary);
|
|
790
|
+
const onSecondary = () => abort(secondary);
|
|
791
|
+
primary.addEventListener('abort', onPrimary, { once: true });
|
|
792
|
+
secondary.addEventListener('abort', onSecondary, { once: true });
|
|
793
|
+
if (primary.aborted)
|
|
794
|
+
abort(primary);
|
|
795
|
+
if (secondary.aborted)
|
|
796
|
+
abort(secondary);
|
|
797
|
+
return {
|
|
798
|
+
signal: controller.signal,
|
|
799
|
+
dispose: () => {
|
|
800
|
+
primary.removeEventListener('abort', onPrimary);
|
|
801
|
+
secondary.removeEventListener('abort', onSecondary);
|
|
802
|
+
},
|
|
803
|
+
};
|
|
804
|
+
}
|
|
805
|
+
function waitForPromise(promise, signal) {
|
|
806
|
+
if (!signal)
|
|
807
|
+
return promise;
|
|
808
|
+
throwIfAborted(signal);
|
|
809
|
+
return new Promise((resolve, reject) => {
|
|
810
|
+
const cleanup = () => signal.removeEventListener('abort', onAbort);
|
|
811
|
+
const onAbort = () => {
|
|
812
|
+
cleanup();
|
|
813
|
+
reject(toError(signal.reason, 'MCP lease acquisition aborted.'));
|
|
814
|
+
};
|
|
815
|
+
signal.addEventListener('abort', onAbort, { once: true });
|
|
816
|
+
void promise.then(value => {
|
|
817
|
+
cleanup();
|
|
818
|
+
resolve(value);
|
|
819
|
+
}, error => {
|
|
820
|
+
cleanup();
|
|
821
|
+
reject(error);
|
|
822
|
+
});
|
|
823
|
+
});
|
|
824
|
+
}
|
|
825
|
+
async function closeIgnoringFailure(connection, reason) {
|
|
826
|
+
try {
|
|
827
|
+
await connection.close(reason);
|
|
828
|
+
}
|
|
829
|
+
catch {
|
|
830
|
+
// The stale connection is never published even if its best-effort close fails.
|
|
831
|
+
}
|
|
832
|
+
}
|
|
833
|
+
function errorMessage(error) {
|
|
834
|
+
return error instanceof Error ? error.message : String(error);
|
|
835
|
+
}
|
|
836
|
+
function toError(error, fallback) {
|
|
837
|
+
if (error instanceof Error)
|
|
838
|
+
return error;
|
|
839
|
+
const message = String(error ?? '').trim();
|
|
840
|
+
return new Error(message || fallback);
|
|
841
|
+
}
|
|
842
|
+
function isRecord(value) {
|
|
843
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
844
|
+
}
|
|
845
|
+
function deepFreeze(value) {
|
|
846
|
+
if (value === null || typeof value !== 'object' || Object.isFrozen(value))
|
|
847
|
+
return value;
|
|
848
|
+
if (ArrayBuffer.isView(value))
|
|
849
|
+
return value;
|
|
850
|
+
for (const nested of Object.values(value))
|
|
851
|
+
deepFreeze(nested);
|
|
852
|
+
return Object.freeze(value);
|
|
853
|
+
}
|
|
854
|
+
//# sourceMappingURL=lazy-mcp-runtime.js.map
|