@orion-agents/orion-code 0.1.8 → 0.2.0
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 +495 -0
- package/README.md +142 -314
- package/README.zh-CN.md +117 -559
- package/dist/cli.js +71 -90
- 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 +174 -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 +2 -2
- package/dist/commands/model-command-handlers.d.ts.map +1 -1
- package/dist/commands/model-command-handlers.js +168 -3
- 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.map +1 -1
- package/dist/commands/session-command-handlers.js +35 -119
- 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 +2 -50
- 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 +14 -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 +8 -6
- package/dist/framework/index.d.ts.map +1 -1
- package/dist/framework/index.js +14 -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 +71 -26
- package/dist/framework/query.d.ts.map +1 -1
- package/dist/framework/query.js +371 -102
- package/dist/framework/query.js.map +1 -1
- package/dist/framework/stop-decision.d.ts +56 -0
- package/dist/framework/stop-decision.d.ts.map +1 -0
- package/dist/framework/stop-decision.js +36 -0
- package/dist/framework/stop-decision.js.map +1 -0
- 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/harness/assembler.d.ts.map +1 -1
- package/dist/harness/assembler.js +77 -19
- package/dist/harness/assembler.js.map +1 -1
- package/dist/harness/capability-profile.d.ts +3 -0
- package/dist/harness/capability-profile.d.ts.map +1 -0
- package/dist/harness/capability-profile.js +44 -0
- package/dist/harness/capability-profile.js.map +1 -0
- package/dist/harness/capsule.d.ts.map +1 -1
- package/dist/harness/capsule.js +22 -3
- package/dist/harness/capsule.js.map +1 -1
- package/dist/harness/compact-benchmark-corpus.d.ts +10 -0
- package/dist/harness/compact-benchmark-corpus.d.ts.map +1 -0
- package/dist/harness/compact-benchmark-corpus.js +56 -0
- package/dist/harness/compact-benchmark-corpus.js.map +1 -0
- package/dist/harness/context-harness.d.ts +23 -3
- package/dist/harness/context-harness.d.ts.map +1 -1
- package/dist/harness/context-harness.js +183 -11
- package/dist/harness/context-harness.js.map +1 -1
- package/dist/harness/contract.d.ts.map +1 -1
- package/dist/harness/contract.js +106 -11
- package/dist/harness/contract.js.map +1 -1
- package/dist/harness/drift-guard.d.ts +2 -1
- package/dist/harness/drift-guard.d.ts.map +1 -1
- package/dist/harness/drift-guard.js +315 -20
- package/dist/harness/drift-guard.js.map +1 -1
- package/dist/harness/evidence.d.ts.map +1 -1
- package/dist/harness/evidence.js +25 -12
- package/dist/harness/evidence.js.map +1 -1
- package/dist/harness/index.d.ts +7 -2
- package/dist/harness/index.d.ts.map +1 -1
- package/dist/harness/index.js +19 -1
- package/dist/harness/index.js.map +1 -1
- package/dist/harness/ledger.d.ts.map +1 -1
- package/dist/harness/ledger.js +44 -14
- package/dist/harness/ledger.js.map +1 -1
- package/dist/harness/progress-controller.d.ts +14 -0
- package/dist/harness/progress-controller.d.ts.map +1 -0
- package/dist/harness/progress-controller.js +110 -0
- package/dist/harness/progress-controller.js.map +1 -0
- package/dist/harness/state.d.ts.map +1 -1
- package/dist/harness/state.js +5 -2
- package/dist/harness/state.js.map +1 -1
- package/dist/harness/stop-controller.d.ts +15 -0
- package/dist/harness/stop-controller.d.ts.map +1 -0
- package/dist/harness/stop-controller.js +87 -0
- package/dist/harness/stop-controller.js.map +1 -0
- package/dist/harness/types.d.ts +137 -0
- package/dist/harness/types.d.ts.map +1 -1
- package/dist/harness/verification.d.ts +7 -0
- package/dist/harness/verification.d.ts.map +1 -0
- package/dist/harness/verification.js +122 -0
- package/dist/harness/verification.js.map +1 -0
- package/dist/index.d.ts +70 -26
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +64 -59
- package/dist/index.js.map +1 -1
- package/dist/memory/index.d.ts +1 -0
- package/dist/memory/index.d.ts.map +1 -1
- package/dist/memory/index.js +1 -0
- package/dist/memory/index.js.map +1 -1
- package/dist/memory/prompt-context.d.ts +42 -0
- package/dist/memory/prompt-context.d.ts.map +1 -0
- package/dist/memory/prompt-context.js +129 -0
- package/dist/memory/prompt-context.js.map +1 -0
- 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 +78 -0
- package/dist/runtime/agent-loop.d.ts.map +1 -0
- package/dist/runtime/agent-loop.js +418 -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 +265 -1215
- 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 +34 -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 +105 -0
- package/dist/runtime/goal-runtime-coordinator.d.ts.map +1 -0
- package/dist/runtime/goal-runtime-coordinator.js +506 -0
- package/dist/runtime/goal-runtime-coordinator.js.map +1 -0
- package/dist/runtime/goals/types.d.ts +0 -1
- package/dist/runtime/goals/types.d.ts.map +1 -1
- package/dist/runtime/goals/types.js +0 -1
- package/dist/runtime/goals/types.js.map +1 -1
- 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/model-coordinator.d.ts +44 -1
- package/dist/runtime/model-coordinator.d.ts.map +1 -1
- package/dist/runtime/model-coordinator.js +161 -19
- package/dist/runtime/model-coordinator.js.map +1 -1
- package/dist/runtime/orion-runtime-v1.d.ts +321 -0
- package/dist/runtime/orion-runtime-v1.d.ts.map +1 -0
- package/dist/runtime/orion-runtime-v1.js +958 -0
- package/dist/runtime/orion-runtime-v1.js.map +1 -0
- package/dist/runtime/orion-session-runner.d.ts +37 -0
- package/dist/runtime/orion-session-runner.d.ts.map +1 -0
- package/dist/runtime/orion-session-runner.js +146 -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 +1019 -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 +109 -0
- package/dist/runtime/release-receipts.d.ts.map +1 -0
- package/dist/runtime/release-receipts.js +304 -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/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 +5 -2
- 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 -42
- package/dist/runtime/subagents/production.d.ts.map +1 -1
- package/dist/runtime/subagents/production.js +494 -151
- 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/runner.d.ts +12 -1
- package/dist/runtime/subagents/runner.d.ts.map +1 -1
- package/dist/runtime/subagents/runner.js +62 -1
- package/dist/runtime/subagents/runner.js.map +1 -1
- 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 -197
- 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 +88 -39
- package/dist/runtime/subagents/supervisor.js.map +1 -1
- package/dist/runtime/subagents/types.d.ts +5 -2
- package/dist/runtime/subagents/types.d.ts.map +1 -1
- package/dist/runtime/subagents/types.js +1 -1
- package/dist/runtime/subagents/types.js.map +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-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 +85 -0
- package/dist/runtime/thread-ui-adapter.d.ts.map +1 -0
- package/dist/runtime/thread-ui-adapter.js +514 -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 +1 -1
- package/dist/runtime/ui-view-model.d.ts.map +1 -1
- package/dist/runtime/ui-view-model.js +3 -5
- package/dist/runtime/ui-view-model.js.map +1 -1
- package/dist/services/compact/auto-compact.d.ts +82 -2
- package/dist/services/compact/auto-compact.d.ts.map +1 -1
- package/dist/services/compact/auto-compact.js +226 -44
- package/dist/services/compact/auto-compact.js.map +1 -1
- package/dist/services/compact/compact.d.ts +54 -37
- package/dist/services/compact/compact.d.ts.map +1 -1
- package/dist/services/compact/compact.js +512 -127
- package/dist/services/compact/compact.js.map +1 -1
- package/dist/services/compact/coordinator.d.ts +5 -1
- package/dist/services/compact/coordinator.d.ts.map +1 -1
- package/dist/services/compact/coordinator.js +10 -1
- package/dist/services/compact/coordinator.js.map +1 -1
- package/dist/services/compact/fingerprint.d.ts +27 -0
- package/dist/services/compact/fingerprint.d.ts.map +1 -0
- package/dist/services/compact/fingerprint.js +69 -0
- package/dist/services/compact/fingerprint.js.map +1 -0
- package/dist/services/compact/index.d.ts +7 -5
- package/dist/services/compact/index.d.ts.map +1 -1
- package/dist/services/compact/index.js +19 -6
- package/dist/services/compact/index.js.map +1 -1
- package/dist/services/compact/planner.d.ts +41 -0
- package/dist/services/compact/planner.d.ts.map +1 -0
- package/dist/services/compact/planner.js +102 -0
- package/dist/services/compact/planner.js.map +1 -0
- package/dist/services/compact/semantic-summary.d.ts +93 -0
- package/dist/services/compact/semantic-summary.d.ts.map +1 -0
- package/dist/services/compact/semantic-summary.js +158 -0
- package/dist/services/compact/semantic-summary.js.map +1 -0
- package/dist/services/compact/summary-generator.d.ts +23 -0
- package/dist/services/compact/summary-generator.d.ts.map +1 -1
- package/dist/services/compact/summary-generator.js +173 -39
- package/dist/services/compact/summary-generator.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-context.d.ts.map +1 -1
- package/dist/services/file-context.js +29 -33
- package/dist/services/file-context.js.map +1 -1
- package/dist/services/global-config.d.ts +8 -2
- package/dist/services/global-config.d.ts.map +1 -1
- package/dist/services/global-config.js +8 -0
- package/dist/services/global-config.js.map +1 -1
- package/dist/services/llm.d.ts +3 -0
- package/dist/services/llm.d.ts.map +1 -1
- package/dist/services/llm.js +7 -0
- package/dist/services/llm.js.map +1 -1
- package/dist/services/project-instructions.d.ts.map +1 -1
- package/dist/services/project-instructions.js +10 -17
- package/dist/services/project-instructions.js.map +1 -1
- package/dist/services/safe-project-reader.d.ts +30 -0
- package/dist/services/safe-project-reader.d.ts.map +1 -0
- package/dist/services/safe-project-reader.js +141 -0
- package/dist/services/safe-project-reader.js.map +1 -0
- package/dist/services/session-storage.d.ts +134 -5
- package/dist/services/session-storage.d.ts.map +1 -1
- package/dist/services/session-storage.js +727 -57
- package/dist/services/session-storage.js.map +1 -1
- package/dist/services/usage-state.d.ts +7 -0
- package/dist/services/usage-state.d.ts.map +1 -1
- package/dist/services/usage-state.js +117 -16
- package/dist/services/usage-state.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 +19 -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/tui-ui/chrome-view-model.js +1 -1
- package/dist/tui-ui/chrome-view-model.js.map +1 -1
- package/dist/tui-ui/layout.js +1 -1
- package/dist/tui-ui/layout.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 +27 -0
- package/npm-shrinkwrap.json +9 -438
- package/package.json +19 -11
- 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 -251
- package/dist/agents/coordinator.js.map +0 -1
- package/dist/agents/fork.d.ts +0 -69
- package/dist/agents/fork.d.ts.map +0 -1
- package/dist/agents/fork.js +0 -164
- 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 -224
- 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 -186
- package/dist/framework/tool-scheduler.d.ts.map +0 -1
- package/dist/framework/tool-scheduler.js +0 -558
- 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 -24
- package/dist/ink-ui/screens/ReplScreen.d.ts.map +0 -1
- package/dist/ink-ui/screens/ReplScreen.js +0 -756
- 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-controller.d.ts +0 -62
- package/dist/runtime/chat-controller.d.ts.map +0 -1
- package/dist/runtime/chat-controller.js +0 -1630
- 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 -89
- package/dist/runtime/goals/coordinator.d.ts.map +0 -1
- package/dist/runtime/goals/coordinator.js +0 -1481
- 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/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/compact/micro-compact.d.ts +0 -21
- package/dist/services/compact/micro-compact.d.ts.map +0 -1
- package/dist/services/compact/micro-compact.js +0 -99
- package/dist/services/compact/micro-compact.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 -364
- 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
|
@@ -0,0 +1,958 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.OrionRuntimeV1 = exports.OrionRuntimeV1Error = void 0;
|
|
4
|
+
exports.createOrionRuntimeV1 = createOrionRuntimeV1;
|
|
5
|
+
const path_1 = require("path");
|
|
6
|
+
const agent_loop_1 = require("./agent-loop");
|
|
7
|
+
const batch_read_service_1 = require("./batch-read-service");
|
|
8
|
+
const capability_receipt_journal_1 = require("./capability-receipt-journal");
|
|
9
|
+
const capability_step_factory_1 = require("./capability-step-factory");
|
|
10
|
+
const first_party_tool_services_1 = require("./first-party-tool-services");
|
|
11
|
+
const goal_runtime_coordinator_1 = require("./goal-runtime-coordinator");
|
|
12
|
+
const mcp_1 = require("./mcp");
|
|
13
|
+
const prompts_1 = require("./prompts");
|
|
14
|
+
const canonical_1 = require("./protocol/canonical");
|
|
15
|
+
const harness_metrics_1 = require("./harness-metrics");
|
|
16
|
+
const resource_scope_1 = require("./resource-scope");
|
|
17
|
+
const runtime_services_1 = require("./runtime-services");
|
|
18
|
+
const skills_1 = require("./skills");
|
|
19
|
+
const step_snapshot_1 = require("./step-snapshot");
|
|
20
|
+
const thread_compact_persistence_1 = require("./thread-compact-persistence");
|
|
21
|
+
const task_context_service_1 = require("./task-context-service");
|
|
22
|
+
const thread_event_store_1 = require("./thread-event-store");
|
|
23
|
+
const thread_runtime_1 = require("./thread-runtime");
|
|
24
|
+
const thread_tool_journal_1 = require("./thread-tool-journal");
|
|
25
|
+
const tool_gateway_1 = require("./tool-gateway");
|
|
26
|
+
const turn_commit_1 = require("./turn-commit");
|
|
27
|
+
class OrionRuntimeV1Error extends Error {
|
|
28
|
+
constructor(code, message) {
|
|
29
|
+
super(message);
|
|
30
|
+
this.code = code;
|
|
31
|
+
this.name = 'OrionRuntimeV1Error';
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.OrionRuntimeV1Error = OrionRuntimeV1Error;
|
|
35
|
+
const SERVICE_IDS = Object.freeze({
|
|
36
|
+
models: 'model-executor-v1',
|
|
37
|
+
threads: 'thread-runtime-v1',
|
|
38
|
+
policy: 'turn-routed-first-party-tool-policy-v1',
|
|
39
|
+
execution: 'execution-service-v1',
|
|
40
|
+
tools: 'tool-gateway-v1',
|
|
41
|
+
prompts: 'prompt-registry-v1',
|
|
42
|
+
skills: 'lazy-skill-runtime-v1',
|
|
43
|
+
mcp: 'lazy-mcp-runtime-v1',
|
|
44
|
+
goals: 'goal-runtime-v2',
|
|
45
|
+
taskContext: 'task-context',
|
|
46
|
+
capabilities: 'capability-step-factory-v1',
|
|
47
|
+
events: 'thread-event-store-v1',
|
|
48
|
+
compaction: 'compact-transaction-v1',
|
|
49
|
+
});
|
|
50
|
+
/** Process-local guard; it is an ownership check, never a service lookup path. */
|
|
51
|
+
const ACTIVE_RUNTIME_OWNERS = new Map();
|
|
52
|
+
/**
|
|
53
|
+
* Explicit first-party production composition root for exactly one ThreadRuntime.
|
|
54
|
+
* Construction is side-effect free; start() owns resources and close() releases them.
|
|
55
|
+
*/
|
|
56
|
+
class OrionRuntimeV1 {
|
|
57
|
+
constructor(options) {
|
|
58
|
+
this.stateValue = 'created';
|
|
59
|
+
this.closeRequested = false;
|
|
60
|
+
this.options = validateOptions(options);
|
|
61
|
+
this.ownerKey = ownerKey(this.options.eventStore);
|
|
62
|
+
this.scope = new resource_scope_1.ResourceScope({ deadlineMs: options.closeDeadlineMs });
|
|
63
|
+
}
|
|
64
|
+
get state() {
|
|
65
|
+
return this.stateValue;
|
|
66
|
+
}
|
|
67
|
+
get graph() {
|
|
68
|
+
return this.requireGraph();
|
|
69
|
+
}
|
|
70
|
+
get services() {
|
|
71
|
+
return this.requireGraph().services;
|
|
72
|
+
}
|
|
73
|
+
get contributors() {
|
|
74
|
+
return this.requireGraph().contributors;
|
|
75
|
+
}
|
|
76
|
+
get thread() {
|
|
77
|
+
return this.requireGraph().thread;
|
|
78
|
+
}
|
|
79
|
+
/** Safe control-plane projection. It never loads Skill bodies or connects MCP servers. */
|
|
80
|
+
diagnostics() {
|
|
81
|
+
const graph = this.requireGraph();
|
|
82
|
+
const projection = graph.thread.getProjection();
|
|
83
|
+
const admission = graph.thread.getAdmissionSnapshot();
|
|
84
|
+
const eventCursor = graph.eventStore.getCursor();
|
|
85
|
+
const recent = graph.eventStore.replay(Math.max(0, eventCursor - 256), 256).events;
|
|
86
|
+
const latestCapabilityEvent = [...recent]
|
|
87
|
+
.reverse()
|
|
88
|
+
.find(event => event.payload.type === 'capability.receipt');
|
|
89
|
+
const latestSnapshotEvent = [...recent]
|
|
90
|
+
.reverse()
|
|
91
|
+
.find(event => event.payload.type === 'step.snapshot');
|
|
92
|
+
const latestCommitEvent = [...recent]
|
|
93
|
+
.reverse()
|
|
94
|
+
.find(event => event.payload.type === 'turn.committed');
|
|
95
|
+
const latestCompactEvent = [...recent]
|
|
96
|
+
.reverse()
|
|
97
|
+
.find(event => event.payload.type.startsWith('compact.'));
|
|
98
|
+
const capability = parseCapabilityDiagnostics(latestCapabilityEvent, latestSnapshotEvent);
|
|
99
|
+
const latestCommit = latestCommitEvent?.payload.type === 'turn.committed'
|
|
100
|
+
? (0, turn_commit_1.parseTurnCommitV1)(latestCommitEvent.payload.data.receipt)
|
|
101
|
+
: undefined;
|
|
102
|
+
const task = graph.taskContext.snapshot();
|
|
103
|
+
const activeTurn = projection.activeTurnId
|
|
104
|
+
? projection.turns[projection.activeTurnId]
|
|
105
|
+
: undefined;
|
|
106
|
+
const serviceEntries = Object.entries(graph.services)
|
|
107
|
+
.map(([slot, service]) => ({ slot, serviceId: service.serviceId }))
|
|
108
|
+
.sort((left, right) => (left.slot < right.slot ? -1 : left.slot > right.slot ? 1 : 0));
|
|
109
|
+
const contributorEntries = Object.entries(graph.contributors).map(([lane, contributors]) => ({
|
|
110
|
+
lane,
|
|
111
|
+
ids: contributors.map(contributor => contributor.id),
|
|
112
|
+
}));
|
|
113
|
+
const criteria = task.state.contract?.criteria ?? [];
|
|
114
|
+
const evidenceRefs = (task.state.evidenceIndex ?? [])
|
|
115
|
+
.slice(-20)
|
|
116
|
+
.map(item => `${item.id}:${item.kind}:${item.verificationStatus ?? 'unknown'}`);
|
|
117
|
+
return Object.freeze({
|
|
118
|
+
version: 1,
|
|
119
|
+
runtime: {
|
|
120
|
+
state: this.stateValue,
|
|
121
|
+
services: serviceEntries,
|
|
122
|
+
contributors: contributorEntries,
|
|
123
|
+
scope: {
|
|
124
|
+
id: graph.scope.id,
|
|
125
|
+
state: graph.scope.state,
|
|
126
|
+
epoch: graph.scope.epoch,
|
|
127
|
+
activeResources: graph.scope.activeResourceCount,
|
|
128
|
+
activeLeases: graph.scope.activeLeaseCount,
|
|
129
|
+
},
|
|
130
|
+
},
|
|
131
|
+
thread: {
|
|
132
|
+
threadId: projection.threadId,
|
|
133
|
+
status: projection.status,
|
|
134
|
+
cursor: projection.cursor,
|
|
135
|
+
projectionDigest: projection.digest,
|
|
136
|
+
projectionLag: Math.max(0, eventCursor - projection.cursor),
|
|
137
|
+
...(projection.activeTurnId ? { activeTurnId: projection.activeTurnId } : {}),
|
|
138
|
+
activeItemIds: activeTurn
|
|
139
|
+
? activeTurn.itemIds.filter(itemId => projection.items[itemId]?.status === 'started')
|
|
140
|
+
: [],
|
|
141
|
+
queuedTurns: admission.queue.length,
|
|
142
|
+
queuedBytes: admission.queuedBytes,
|
|
143
|
+
interruptRequested: Boolean(admission.activeTurn?.interruptIntentId),
|
|
144
|
+
},
|
|
145
|
+
taskContext: {
|
|
146
|
+
revision: task.revision,
|
|
147
|
+
taskEpoch: task.taskEpoch,
|
|
148
|
+
stateDigest: (0, canonical_1.digestRuntimeValue)(task.state),
|
|
149
|
+
criteria: criteria.length,
|
|
150
|
+
evidenceRefs,
|
|
151
|
+
},
|
|
152
|
+
...(capability ? { capability } : {}),
|
|
153
|
+
skills: graph.skills.stats(),
|
|
154
|
+
mcp: graph.mcp.snapshot(),
|
|
155
|
+
latest: {
|
|
156
|
+
...(latestCommit?.stopDecision
|
|
157
|
+
? { stopDecision: JSON.parse(latestCommit.stopDecision) }
|
|
158
|
+
: {}),
|
|
159
|
+
...(latestCompactEvent ? { compactEvent: latestCompactEvent.payload.type } : {}),
|
|
160
|
+
compactRecoveryDigest: graph.compactRecovery.digest,
|
|
161
|
+
eventCursor,
|
|
162
|
+
},
|
|
163
|
+
});
|
|
164
|
+
}
|
|
165
|
+
/**
|
|
166
|
+
* Apply Goal lifecycle control through an internal durable Thread turn.
|
|
167
|
+
* Status is a pure snapshot; every mutation receives its own TurnCommit.
|
|
168
|
+
*/
|
|
169
|
+
async controlGoal(control) {
|
|
170
|
+
const graph = this.requireGraph();
|
|
171
|
+
if (control.action === 'status')
|
|
172
|
+
return graph.goal.control(control, 'status');
|
|
173
|
+
let resolveExecution;
|
|
174
|
+
let rejectExecution;
|
|
175
|
+
const execution = new Promise((resolvePromise, rejectPromise) => {
|
|
176
|
+
resolveExecution = resolvePromise;
|
|
177
|
+
rejectExecution = rejectPromise;
|
|
178
|
+
});
|
|
179
|
+
const admission = graph.thread.startGoalControl({
|
|
180
|
+
type: 'goal_control',
|
|
181
|
+
input: goalControlInput(control),
|
|
182
|
+
onRejected: reason => rejectExecution(new Error(`Goal control was rejected: ${reason}.`)),
|
|
183
|
+
run: async (context) => {
|
|
184
|
+
try {
|
|
185
|
+
if (context.abortSignal.aborted)
|
|
186
|
+
throw new Error('Goal control was interrupted.');
|
|
187
|
+
const result = graph.goal.control(control, context.turnId, fields => {
|
|
188
|
+
const previous = restoreLatestTurnCommit(graph.eventStore);
|
|
189
|
+
const committed = graph.services.events.turnCommits.commit({
|
|
190
|
+
turnId: context.turnId,
|
|
191
|
+
history: previous ? parseCommittedHistory(previous) : [],
|
|
192
|
+
taskContextState: graph.taskContext.exportState(),
|
|
193
|
+
taskContextRevision: graph.taskContext.revision,
|
|
194
|
+
terminal: { status: 'completed', outcome: `goal_control:${control.action}` },
|
|
195
|
+
...(fields.goalState ? { goalState: fields.goalState } : {}),
|
|
196
|
+
...(fields.stopDecision ? { stopDecision: fields.stopDecision } : {}),
|
|
197
|
+
});
|
|
198
|
+
return committed;
|
|
199
|
+
});
|
|
200
|
+
resolveExecution({ turnId: context.turnId, result });
|
|
201
|
+
return { status: 'completed', outcome: `goal_control:${control.action}` };
|
|
202
|
+
}
|
|
203
|
+
catch (error) {
|
|
204
|
+
rejectExecution(error);
|
|
205
|
+
throw error;
|
|
206
|
+
}
|
|
207
|
+
},
|
|
208
|
+
});
|
|
209
|
+
if (admission.status === 'rejected') {
|
|
210
|
+
throw new Error(`Goal control was rejected: ${admission.reason}.`);
|
|
211
|
+
}
|
|
212
|
+
const deadlineTimer = admission.status === 'queued'
|
|
213
|
+
? setTimeout(() => rejectExecution(new Error('Goal control was rejected: deadline_expired.')), Math.max(1, admission.deadline - Date.now()))
|
|
214
|
+
: undefined;
|
|
215
|
+
deadlineTimer?.unref();
|
|
216
|
+
let completed;
|
|
217
|
+
try {
|
|
218
|
+
completed = await execution;
|
|
219
|
+
}
|
|
220
|
+
finally {
|
|
221
|
+
if (deadlineTimer)
|
|
222
|
+
clearTimeout(deadlineTimer);
|
|
223
|
+
}
|
|
224
|
+
const terminal = await graph.thread.waitForTurnTerminal(completed.turnId);
|
|
225
|
+
if (terminal !== 'completed') {
|
|
226
|
+
throw new Error(`Goal control turn ended as ${terminal}.`);
|
|
227
|
+
}
|
|
228
|
+
return completed.result;
|
|
229
|
+
}
|
|
230
|
+
/** Schedule an explicit Compact transaction as a non-steerable maintenance turn. */
|
|
231
|
+
compact(input = {}) {
|
|
232
|
+
const graph = this.requireGraph();
|
|
233
|
+
const coordinator = this.options.loop?.compactCoordinator;
|
|
234
|
+
if (!coordinator) {
|
|
235
|
+
throw new OrionRuntimeV1Error('ORION_RUNTIME_INVALID_CONFIGURATION', 'Explicit compact requires a runtime-owned CompactCoordinator.');
|
|
236
|
+
}
|
|
237
|
+
const maxMessages = input.maxMessages ?? 20;
|
|
238
|
+
if (!Number.isSafeInteger(maxMessages) || maxMessages <= 0) {
|
|
239
|
+
throw new OrionRuntimeV1Error('ORION_RUNTIME_INVALID_CONFIGURATION', 'Explicit compact maxMessages must be a positive integer.');
|
|
240
|
+
}
|
|
241
|
+
const request = Object.freeze({
|
|
242
|
+
type: 'compact',
|
|
243
|
+
source: 'explicit',
|
|
244
|
+
prepare: async ({ source, history, }, signal) => {
|
|
245
|
+
throwIfAborted(signal);
|
|
246
|
+
const messages = parseModelVisibleHistory(history);
|
|
247
|
+
const result = await coordinator.compactManual(messages, maxMessages, input.focus);
|
|
248
|
+
throwIfAborted(signal);
|
|
249
|
+
return (0, thread_compact_persistence_1.createThreadCompactCandidateDraftV1)({
|
|
250
|
+
source: 'explicit',
|
|
251
|
+
sourceHistoryDigest: source.historyDigest,
|
|
252
|
+
modelVisibleHistory: result.messages,
|
|
253
|
+
payload: {
|
|
254
|
+
version: 1,
|
|
255
|
+
mode: 'explicit',
|
|
256
|
+
summary: result.summary,
|
|
257
|
+
summarySource: result.summarySource,
|
|
258
|
+
summaryGeneratedAt: result.summaryGeneratedAt,
|
|
259
|
+
fingerprint: result.fingerprint,
|
|
260
|
+
beforeTokens: result.beforeTokens,
|
|
261
|
+
afterTokens: result.afterTokens,
|
|
262
|
+
plan: result.plan,
|
|
263
|
+
semanticSummary: result.semanticSummary,
|
|
264
|
+
diagnostics: result.diagnostics,
|
|
265
|
+
},
|
|
266
|
+
});
|
|
267
|
+
},
|
|
268
|
+
});
|
|
269
|
+
return graph.thread.startCompactMaintenance(request, 'compact:explicit');
|
|
270
|
+
}
|
|
271
|
+
start() {
|
|
272
|
+
if (this.stateValue === 'started')
|
|
273
|
+
return Promise.resolve(this);
|
|
274
|
+
if (this.startFlight)
|
|
275
|
+
return this.startFlight;
|
|
276
|
+
if (this.stateValue === 'closing' || this.stateValue === 'closed') {
|
|
277
|
+
return Promise.reject(new OrionRuntimeV1Error('ORION_RUNTIME_CLOSED', 'Closed OrionRuntime cannot start.'));
|
|
278
|
+
}
|
|
279
|
+
this.stateValue = 'starting';
|
|
280
|
+
this.startFlight = this.performStart();
|
|
281
|
+
return this.startFlight;
|
|
282
|
+
}
|
|
283
|
+
close(reason = 'orion_runtime_closed') {
|
|
284
|
+
if (this.closeFlight)
|
|
285
|
+
return this.closeFlight;
|
|
286
|
+
this.closeRequested = true;
|
|
287
|
+
this.stateValue = 'closing';
|
|
288
|
+
this.closeFlight = this.performClose(reason);
|
|
289
|
+
return this.closeFlight;
|
|
290
|
+
}
|
|
291
|
+
async performStart() {
|
|
292
|
+
try {
|
|
293
|
+
this.acquireOwnership();
|
|
294
|
+
const eventStore = new thread_event_store_1.ThreadEventStore(this.options.eventStore.rootDir, this.options.eventStore.threadId, this.options.eventStore.options);
|
|
295
|
+
const compactPersistence = new thread_compact_persistence_1.ThreadCompactTransactionPersistenceV1(eventStore);
|
|
296
|
+
const compactRunner = new thread_compact_persistence_1.ThreadCompactMaintenanceRunnerV1(eventStore, this.options.compact);
|
|
297
|
+
const compactRecovery = await compactRunner.recoverOrphans();
|
|
298
|
+
const restored = restoreLatestTurnCommit(eventStore);
|
|
299
|
+
const taskContext = (0, task_context_service_1.createTaskContextService)(mergeTaskContextOptions(this.options.taskContext, restored));
|
|
300
|
+
const goal = new goal_runtime_coordinator_1.GoalRuntimeCoordinatorV2({
|
|
301
|
+
...(this.options.goal ? { definition: this.options.goal } : {}),
|
|
302
|
+
...(restored ? { restoredCommit: restored } : {}),
|
|
303
|
+
});
|
|
304
|
+
const prompts = new prompts_1.PromptRegistryV1();
|
|
305
|
+
const contributors = (0, runtime_services_1.createRuntimeContributors)(this.options.contributors ?? (0, runtime_services_1.emptyRuntimeContributorSlots)());
|
|
306
|
+
const skills = await this.scope.activate({
|
|
307
|
+
id: 'lazy-skills',
|
|
308
|
+
activate: () => {
|
|
309
|
+
const runtime = new skills_1.LazySkillRuntime({
|
|
310
|
+
...this.options.skills,
|
|
311
|
+
signal: this.scope.signal,
|
|
312
|
+
});
|
|
313
|
+
return { value: runtime, dispose: () => runtime.dispose() };
|
|
314
|
+
},
|
|
315
|
+
});
|
|
316
|
+
const mcp = await this.scope.activate({
|
|
317
|
+
id: 'lazy-mcp',
|
|
318
|
+
activate: () => {
|
|
319
|
+
const runtime = new mcp_1.LazyMcpRuntime({ ...this.options.mcp, signal: this.scope.signal });
|
|
320
|
+
return {
|
|
321
|
+
value: runtime,
|
|
322
|
+
dispose: context => runtime.dispose(context.reason),
|
|
323
|
+
};
|
|
324
|
+
},
|
|
325
|
+
});
|
|
326
|
+
const basePolicy = new first_party_tool_services_1.FirstPartyToolPolicyServiceV1(this.options.toolCatalog, this.options.toolContext);
|
|
327
|
+
const subagentTurns = new Map();
|
|
328
|
+
const subagentTurnFlights = new Map();
|
|
329
|
+
const subagentUnavailableTurns = new Set();
|
|
330
|
+
const subagentPolicies = new Map();
|
|
331
|
+
const subagentAuthorityDigests = new Map();
|
|
332
|
+
const policy = Object.freeze({
|
|
333
|
+
serviceId: 'turn-routed-first-party-tool-policy-v1',
|
|
334
|
+
decide: (input) => {
|
|
335
|
+
if (input.descriptor.name === 'subtask') {
|
|
336
|
+
const turnPolicy = subagentPolicies.get(input.snapshot.turnId);
|
|
337
|
+
if (!turnPolicy) {
|
|
338
|
+
return Object.freeze({
|
|
339
|
+
behavior: 'deny',
|
|
340
|
+
source: 'subagent-turn',
|
|
341
|
+
reason: 'No active turn-owned subagent policy exists for this snapshot.',
|
|
342
|
+
digest: (0, canonical_1.digestRuntimeValue)({
|
|
343
|
+
behavior: 'deny',
|
|
344
|
+
source: 'subagent-turn',
|
|
345
|
+
reason: 'No active turn-owned subagent policy exists for this snapshot.',
|
|
346
|
+
}),
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
return turnPolicy.decide(input);
|
|
350
|
+
}
|
|
351
|
+
return basePolicy.decide(input);
|
|
352
|
+
},
|
|
353
|
+
});
|
|
354
|
+
const approval = new first_party_tool_services_1.FirstPartyToolApprovalServiceV1(this.options.approvalHandler);
|
|
355
|
+
const sandbox = new first_party_tool_services_1.FirstPartySandboxServiceV1();
|
|
356
|
+
const execution = new step_snapshot_1.ExecutionService();
|
|
357
|
+
const toolJournal = new thread_tool_journal_1.ThreadToolInvocationJournalV1(eventStore);
|
|
358
|
+
const gateway = new tool_gateway_1.ToolGateway({
|
|
359
|
+
policy,
|
|
360
|
+
approval,
|
|
361
|
+
sandbox,
|
|
362
|
+
execution,
|
|
363
|
+
nested: new batch_read_service_1.BatchReadExecutionServiceV1(),
|
|
364
|
+
journal: toolJournal,
|
|
365
|
+
});
|
|
366
|
+
const capabilityJournal = new capability_receipt_journal_1.CapabilityReceiptJournalV1(eventStore);
|
|
367
|
+
const subagents = this.options.subagents ?? Object.freeze({ serviceId: 'subagents-disabled-v1' });
|
|
368
|
+
const runtimeServicesDigest = (0, canonical_1.digestRuntimeValue)({
|
|
369
|
+
version: 1,
|
|
370
|
+
services: { ...SERVICE_IDS, subagents: subagents.serviceId },
|
|
371
|
+
});
|
|
372
|
+
const resolveSubagentTurn = async (input, authority) => {
|
|
373
|
+
if (!this.options.subagents)
|
|
374
|
+
return undefined;
|
|
375
|
+
if (subagentUnavailableTurns.has(input.turnId))
|
|
376
|
+
return undefined;
|
|
377
|
+
const existing = subagentTurns.get(input.turnId);
|
|
378
|
+
if (existing) {
|
|
379
|
+
assertSubagentAuthorityStable(input.turnId, authority, subagentAuthorityDigests);
|
|
380
|
+
return existing;
|
|
381
|
+
}
|
|
382
|
+
const pending = subagentTurnFlights.get(input.turnId);
|
|
383
|
+
if (pending)
|
|
384
|
+
return pending;
|
|
385
|
+
const flight = Promise.resolve(this.options.subagents.createTurn({
|
|
386
|
+
store: eventStore,
|
|
387
|
+
threadId: input.threadId,
|
|
388
|
+
turnId: input.turnId,
|
|
389
|
+
input: input.input,
|
|
390
|
+
mode: input.mode,
|
|
391
|
+
authority,
|
|
392
|
+
abortSignal: input.abortSignal,
|
|
393
|
+
flush: () => undefined,
|
|
394
|
+
})).then(async (capability) => {
|
|
395
|
+
if (!capability) {
|
|
396
|
+
subagentUnavailableTurns.add(input.turnId);
|
|
397
|
+
return undefined;
|
|
398
|
+
}
|
|
399
|
+
try {
|
|
400
|
+
validateSubagentTurnCapability(input, capability);
|
|
401
|
+
subagentTurns.set(input.turnId, capability);
|
|
402
|
+
subagentPolicies.set(input.turnId, new first_party_tool_services_1.FirstPartyToolPolicyServiceV1(capability.catalog, this.options.toolContext));
|
|
403
|
+
subagentAuthorityDigests.set(input.turnId, authority.digest);
|
|
404
|
+
return capability;
|
|
405
|
+
}
|
|
406
|
+
catch (error) {
|
|
407
|
+
await capability.close('subagent_turn_start_failed');
|
|
408
|
+
throw error;
|
|
409
|
+
}
|
|
410
|
+
});
|
|
411
|
+
subagentTurnFlights.set(input.turnId, flight);
|
|
412
|
+
try {
|
|
413
|
+
return await flight;
|
|
414
|
+
}
|
|
415
|
+
finally {
|
|
416
|
+
subagentTurnFlights.delete(input.turnId);
|
|
417
|
+
}
|
|
418
|
+
};
|
|
419
|
+
const preparedRegistries = new Map();
|
|
420
|
+
const preparationKey = (input) => `${input.turnId}:${input.requestIndex}`;
|
|
421
|
+
const stepFactory = new capability_step_factory_1.CapabilityAgentLoopStepFactoryV1({
|
|
422
|
+
resolveConfiguration: async (input) => {
|
|
423
|
+
const configured = await this.options.resolveCapabilityConfiguration(input, Object.freeze({
|
|
424
|
+
runtimeServicesDigest,
|
|
425
|
+
toolCatalog: this.options.toolCatalog,
|
|
426
|
+
taskContext,
|
|
427
|
+
skills,
|
|
428
|
+
mcp,
|
|
429
|
+
mcpCatalog: mcp.getCatalog(),
|
|
430
|
+
prompts,
|
|
431
|
+
}));
|
|
432
|
+
const subagentTurn = await resolveSubagentTurn(input, configured.compiler.authority);
|
|
433
|
+
const dynamic = mergeDynamicTools(configured.dynamicTools, subagentTurn?.catalog);
|
|
434
|
+
const registry = new Map(this.options.toolCatalog.bindings);
|
|
435
|
+
for (const [bindingId, binding] of dynamic?.bindings ?? []) {
|
|
436
|
+
if (registry.has(bindingId)) {
|
|
437
|
+
throw new OrionRuntimeV1Error('ORION_RUNTIME_INVALID_CONFIGURATION', `Dynamic tool binding collides with ${bindingId}.`);
|
|
438
|
+
}
|
|
439
|
+
registry.set(bindingId, binding);
|
|
440
|
+
}
|
|
441
|
+
preparedRegistries.set(preparationKey(input), registry);
|
|
442
|
+
return {
|
|
443
|
+
...configured,
|
|
444
|
+
dynamicTools: undefined,
|
|
445
|
+
compiler: {
|
|
446
|
+
...configured.compiler,
|
|
447
|
+
tools: [...this.options.toolCatalog.candidates, ...(dynamic?.candidates ?? [])],
|
|
448
|
+
runtimeServicesDigest,
|
|
449
|
+
mcpCatalogDigest: mcp.getCatalog().digest,
|
|
450
|
+
},
|
|
451
|
+
};
|
|
452
|
+
},
|
|
453
|
+
resolveToolRegistry: input => {
|
|
454
|
+
const key = preparationKey(input);
|
|
455
|
+
const registry = preparedRegistries.get(key);
|
|
456
|
+
preparedRegistries.delete(key);
|
|
457
|
+
if (!registry) {
|
|
458
|
+
throw new OrionRuntimeV1Error('ORION_RUNTIME_INVALID_CONFIGURATION', `No frozen tool registry exists for ${key}.`);
|
|
459
|
+
}
|
|
460
|
+
return registry;
|
|
461
|
+
},
|
|
462
|
+
onCaptured: async (bundle) => {
|
|
463
|
+
const commit = capabilityJournal.commit(bundle);
|
|
464
|
+
await subagentTurns.get(bundle.snapshot.turnId)?.publishCommitted(bundle, commit);
|
|
465
|
+
},
|
|
466
|
+
});
|
|
467
|
+
const turnCommits = new turn_commit_1.ThreadTurnCommitJournalV1(eventStore);
|
|
468
|
+
const agentLoop = new agent_loop_1.AgentLoopV1({
|
|
469
|
+
llm: this.options.modelExecutor,
|
|
470
|
+
taskContext,
|
|
471
|
+
steps: stepFactory,
|
|
472
|
+
gateway,
|
|
473
|
+
loadBaseMessages: context => loadRuntimeBaseMessages(compactPersistence, this.options.loadBaseMessages?.(eventStore, context, prompts, {
|
|
474
|
+
taskContext,
|
|
475
|
+
goal,
|
|
476
|
+
skills,
|
|
477
|
+
mcp,
|
|
478
|
+
})),
|
|
479
|
+
toolContext: () => this.options.toolContext,
|
|
480
|
+
streamCallbacks: this.options.loop?.streamCallbacks,
|
|
481
|
+
loopBudget: this.options.loop?.loopBudget,
|
|
482
|
+
compactCoordinator: this.options.loop?.compactCoordinator,
|
|
483
|
+
commitTurn: commit => {
|
|
484
|
+
const prepared = this.options.loop?.prepareTurnCommit?.(commit);
|
|
485
|
+
const committed = prepared?.stopDecision
|
|
486
|
+
? withStopDecision(commit, prepared.stopDecision)
|
|
487
|
+
: commit;
|
|
488
|
+
let durableCommit;
|
|
489
|
+
goal.commitTurn(committed, fields => {
|
|
490
|
+
durableCommit = turnCommits.commit({
|
|
491
|
+
turnId: committed.turnId,
|
|
492
|
+
history: committed.history,
|
|
493
|
+
taskContextState: committed.taskContextState,
|
|
494
|
+
taskContextRevision: committed.taskContextRevision,
|
|
495
|
+
terminal: terminalFromAgentCommit(committed.queryComplete),
|
|
496
|
+
...(fields.goalState ? { goalState: fields.goalState } : {}),
|
|
497
|
+
...(fields.stopDecision ? { stopDecision: fields.stopDecision } : {}),
|
|
498
|
+
...(prepared?.plan ? { plan: prepared.plan } : {}),
|
|
499
|
+
});
|
|
500
|
+
return durableCommit;
|
|
501
|
+
});
|
|
502
|
+
if (!durableCommit) {
|
|
503
|
+
throw new OrionRuntimeV1Error('ORION_RUNTIME_INVALID_CONFIGURATION', `Turn ${commit.turnId} completed without an authoritative TurnCommit.`);
|
|
504
|
+
}
|
|
505
|
+
try {
|
|
506
|
+
const projected = this.options.loop?.onTurnCommitted?.(committed, durableCommit);
|
|
507
|
+
return projected && typeof projected.then === 'function'
|
|
508
|
+
? projected.catch(() => undefined)
|
|
509
|
+
: undefined;
|
|
510
|
+
}
|
|
511
|
+
catch {
|
|
512
|
+
// UI/metrics projections cannot veto an already durable TurnCommit.
|
|
513
|
+
return undefined;
|
|
514
|
+
}
|
|
515
|
+
},
|
|
516
|
+
});
|
|
517
|
+
const thread = await this.scope.activate({
|
|
518
|
+
id: 'thread-runtime',
|
|
519
|
+
activate: () => {
|
|
520
|
+
const runtime = new thread_runtime_1.ThreadRuntimeV1({
|
|
521
|
+
...this.options.thread,
|
|
522
|
+
store: eventStore,
|
|
523
|
+
runner: agentLoop,
|
|
524
|
+
maintenanceRunner: compactRunner,
|
|
525
|
+
projectPath: this.options.projectPath,
|
|
526
|
+
requireTurnCommit: true,
|
|
527
|
+
onTurnStarted: turn => {
|
|
528
|
+
goal.markTurnStarted(turn.turnId, turn.startedAt);
|
|
529
|
+
this.options.thread?.onTurnStarted?.(turn);
|
|
530
|
+
},
|
|
531
|
+
onTurnDurablyTerminal: terminal => goal.afterDurableTerminal(terminal.turnId, terminal.terminal) ??
|
|
532
|
+
this.options.thread?.onTurnDurablyTerminal?.(terminal),
|
|
533
|
+
onTurnSettled: async (turnId) => {
|
|
534
|
+
for (const key of [...preparedRegistries.keys()]) {
|
|
535
|
+
if (key.startsWith(`${turnId}:`))
|
|
536
|
+
preparedRegistries.delete(key);
|
|
537
|
+
}
|
|
538
|
+
const turnCapability = subagentTurns.get(turnId);
|
|
539
|
+
subagentTurns.delete(turnId);
|
|
540
|
+
subagentTurnFlights.delete(turnId);
|
|
541
|
+
subagentUnavailableTurns.delete(turnId);
|
|
542
|
+
subagentPolicies.delete(turnId);
|
|
543
|
+
subagentAuthorityDigests.delete(turnId);
|
|
544
|
+
try {
|
|
545
|
+
await turnCapability?.close('parent_turn_settled');
|
|
546
|
+
}
|
|
547
|
+
finally {
|
|
548
|
+
await mcp.releaseOwner(turnId);
|
|
549
|
+
await this.options.thread?.onTurnSettled?.(turnId);
|
|
550
|
+
}
|
|
551
|
+
},
|
|
552
|
+
});
|
|
553
|
+
return {
|
|
554
|
+
value: runtime,
|
|
555
|
+
dispose: async (context) => {
|
|
556
|
+
goal.close();
|
|
557
|
+
runtime.close(context.reason);
|
|
558
|
+
await runtime.waitForIdle();
|
|
559
|
+
},
|
|
560
|
+
};
|
|
561
|
+
},
|
|
562
|
+
});
|
|
563
|
+
const services = (0, runtime_services_1.createRuntimeServices)({
|
|
564
|
+
models: servicePort(SERVICE_IDS.models, { executor: this.options.modelExecutor }),
|
|
565
|
+
threads: servicePort(SERVICE_IDS.threads, { runtime: thread }),
|
|
566
|
+
policy,
|
|
567
|
+
execution: servicePort(SERVICE_IDS.execution, { execution }),
|
|
568
|
+
tools: servicePort(SERVICE_IDS.tools, {
|
|
569
|
+
catalog: this.options.toolCatalog,
|
|
570
|
+
gateway,
|
|
571
|
+
approval,
|
|
572
|
+
sandbox,
|
|
573
|
+
journal: toolJournal,
|
|
574
|
+
}),
|
|
575
|
+
prompts: servicePort(SERVICE_IDS.prompts, { registry: prompts }),
|
|
576
|
+
skills: servicePort(SERVICE_IDS.skills, { runtime: skills }),
|
|
577
|
+
mcp: servicePort(SERVICE_IDS.mcp, { runtime: mcp }),
|
|
578
|
+
goals: servicePort(SERVICE_IDS.goals, { runtime: goal }),
|
|
579
|
+
taskContext,
|
|
580
|
+
capabilities: servicePort(SERVICE_IDS.capabilities, {
|
|
581
|
+
steps: stepFactory,
|
|
582
|
+
journal: capabilityJournal,
|
|
583
|
+
}),
|
|
584
|
+
events: servicePort(SERVICE_IDS.events, { store: eventStore, turnCommits }),
|
|
585
|
+
compaction: servicePort(SERVICE_IDS.compaction, {
|
|
586
|
+
persistence: compactPersistence,
|
|
587
|
+
runner: compactRunner,
|
|
588
|
+
recovery: compactRecovery,
|
|
589
|
+
}),
|
|
590
|
+
subagents,
|
|
591
|
+
});
|
|
592
|
+
this.graphValue = Object.freeze({
|
|
593
|
+
services,
|
|
594
|
+
contributors,
|
|
595
|
+
scope: this.scope,
|
|
596
|
+
eventStore,
|
|
597
|
+
taskContext,
|
|
598
|
+
prompts,
|
|
599
|
+
skills,
|
|
600
|
+
mcp,
|
|
601
|
+
goal,
|
|
602
|
+
execution,
|
|
603
|
+
gateway,
|
|
604
|
+
capabilityJournal,
|
|
605
|
+
compactPersistence,
|
|
606
|
+
compactRunner,
|
|
607
|
+
compactRecovery,
|
|
608
|
+
stepFactory,
|
|
609
|
+
agentLoop,
|
|
610
|
+
thread,
|
|
611
|
+
});
|
|
612
|
+
const restoredTurn = restored
|
|
613
|
+
? eventStore.loadProjection().turns[restored.turnId]
|
|
614
|
+
: undefined;
|
|
615
|
+
if (!this.closeRequested &&
|
|
616
|
+
restoredTurn?.status === 'completed' &&
|
|
617
|
+
eventStore.loadProjection().queue.length === 0) {
|
|
618
|
+
const continuation = goal.takeRestoredContinuation();
|
|
619
|
+
if (continuation)
|
|
620
|
+
thread.startGoalContinuation(continuation);
|
|
621
|
+
}
|
|
622
|
+
if (this.closeRequested) {
|
|
623
|
+
throw new OrionRuntimeV1Error('ORION_RUNTIME_CLOSED', 'OrionRuntime was closed while starting.');
|
|
624
|
+
}
|
|
625
|
+
this.stateValue = 'started';
|
|
626
|
+
await this.options.loop?.onRuntimeStarted?.({
|
|
627
|
+
...(restored ? { restoredCommit: restored } : {}),
|
|
628
|
+
thread,
|
|
629
|
+
eventStore,
|
|
630
|
+
});
|
|
631
|
+
return this;
|
|
632
|
+
}
|
|
633
|
+
catch (error) {
|
|
634
|
+
await this.scope.close({ reason: 'orion_runtime_start_failed' });
|
|
635
|
+
this.releaseOwnership();
|
|
636
|
+
this.stateValue = 'closed';
|
|
637
|
+
throw error;
|
|
638
|
+
}
|
|
639
|
+
}
|
|
640
|
+
async performClose(reason) {
|
|
641
|
+
if (this.startFlight) {
|
|
642
|
+
try {
|
|
643
|
+
await this.startFlight;
|
|
644
|
+
}
|
|
645
|
+
catch {
|
|
646
|
+
// Failed start already rolled back the same ResourceScope.
|
|
647
|
+
}
|
|
648
|
+
}
|
|
649
|
+
const report = await this.scope.close({ reason });
|
|
650
|
+
this.releaseOwnership();
|
|
651
|
+
this.stateValue = 'closed';
|
|
652
|
+
return report;
|
|
653
|
+
}
|
|
654
|
+
acquireOwnership() {
|
|
655
|
+
const existing = ACTIVE_RUNTIME_OWNERS.get(this.ownerKey);
|
|
656
|
+
if (existing && existing !== this) {
|
|
657
|
+
throw new OrionRuntimeV1Error('ORION_RUNTIME_OWNER_CONFLICT', `Thread ${this.options.eventStore.threadId} already has an active OrionRuntime owner.`);
|
|
658
|
+
}
|
|
659
|
+
ACTIVE_RUNTIME_OWNERS.set(this.ownerKey, this);
|
|
660
|
+
}
|
|
661
|
+
releaseOwnership() {
|
|
662
|
+
if (ACTIVE_RUNTIME_OWNERS.get(this.ownerKey) === this) {
|
|
663
|
+
ACTIVE_RUNTIME_OWNERS.delete(this.ownerKey);
|
|
664
|
+
}
|
|
665
|
+
}
|
|
666
|
+
requireGraph() {
|
|
667
|
+
if (!this.graphValue || this.stateValue !== 'started') {
|
|
668
|
+
throw new OrionRuntimeV1Error('ORION_RUNTIME_NOT_STARTED', 'OrionRuntime services are available only after start().');
|
|
669
|
+
}
|
|
670
|
+
return this.graphValue;
|
|
671
|
+
}
|
|
672
|
+
}
|
|
673
|
+
exports.OrionRuntimeV1 = OrionRuntimeV1;
|
|
674
|
+
function createOrionRuntimeV1(options) {
|
|
675
|
+
return new OrionRuntimeV1(options);
|
|
676
|
+
}
|
|
677
|
+
function mergeDynamicTools(configured, subagentCatalog) {
|
|
678
|
+
if (!subagentCatalog)
|
|
679
|
+
return configured;
|
|
680
|
+
const candidates = [...(configured?.candidates ?? [])];
|
|
681
|
+
const bindings = new Map(configured?.bindings ?? []);
|
|
682
|
+
const candidateNames = new Set(candidates.map(candidate => candidate.descriptor.name));
|
|
683
|
+
const candidateBindingIds = new Set(candidates.map(candidate => candidate.bindingId));
|
|
684
|
+
for (const candidate of subagentCatalog.candidates) {
|
|
685
|
+
if (candidateNames.has(candidate.descriptor.name)) {
|
|
686
|
+
invalidConfiguration(`Turn subagent tool collides with dynamic tool ${candidate.descriptor.name}.`);
|
|
687
|
+
}
|
|
688
|
+
if (candidateBindingIds.has(candidate.bindingId) || bindings.has(candidate.bindingId)) {
|
|
689
|
+
invalidConfiguration(`Turn subagent binding collides with dynamic binding ${candidate.bindingId}.`);
|
|
690
|
+
}
|
|
691
|
+
candidates.push(candidate);
|
|
692
|
+
candidateNames.add(candidate.descriptor.name);
|
|
693
|
+
candidateBindingIds.add(candidate.bindingId);
|
|
694
|
+
}
|
|
695
|
+
for (const [bindingId, binding] of subagentCatalog.bindings) {
|
|
696
|
+
if (bindings.has(bindingId)) {
|
|
697
|
+
invalidConfiguration(`Turn subagent binding collides with dynamic binding ${bindingId}.`);
|
|
698
|
+
}
|
|
699
|
+
bindings.set(bindingId, binding);
|
|
700
|
+
}
|
|
701
|
+
return Object.freeze({ candidates: Object.freeze(candidates), bindings });
|
|
702
|
+
}
|
|
703
|
+
function validateSubagentTurnCapability(input, capability) {
|
|
704
|
+
const catalog = capability.catalog;
|
|
705
|
+
const candidate = catalog?.candidates[0];
|
|
706
|
+
const binding = candidate ? catalog.bindings.get(candidate.bindingId) : undefined;
|
|
707
|
+
if (!capability.serviceId?.trim() ||
|
|
708
|
+
capability.turnId !== input.turnId ||
|
|
709
|
+
typeof capability.publishCommitted !== 'function' ||
|
|
710
|
+
typeof capability.close !== 'function' ||
|
|
711
|
+
!catalog ||
|
|
712
|
+
catalog.entries.length !== 1 ||
|
|
713
|
+
catalog.candidates.length !== 1 ||
|
|
714
|
+
catalog.bindings.size !== 1 ||
|
|
715
|
+
candidate?.descriptor.name !== 'subtask' ||
|
|
716
|
+
candidate.descriptor.risk.readOnly !== true ||
|
|
717
|
+
candidate.descriptor.risk.destructive ||
|
|
718
|
+
!binding ||
|
|
719
|
+
binding.descriptor.executorId !== candidate.descriptor.executorId ||
|
|
720
|
+
binding.descriptor.schemaDigest !== candidate.descriptor.schemaDigest) {
|
|
721
|
+
invalidConfiguration(`Subagent turn ${input.turnId} must expose exactly one read-only exact subtask binding.`);
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
function assertSubagentAuthorityStable(turnId, authority, digests) {
|
|
725
|
+
const expected = digests.get(turnId);
|
|
726
|
+
if (expected && expected !== authority.digest) {
|
|
727
|
+
invalidConfiguration(`Subagent authority drifted within root turn ${turnId}.`);
|
|
728
|
+
}
|
|
729
|
+
}
|
|
730
|
+
function parseCapabilityDiagnostics(capabilityEvent, snapshotEvent) {
|
|
731
|
+
if (!capabilityEvent || capabilityEvent.payload.type !== 'capability.receipt') {
|
|
732
|
+
return undefined;
|
|
733
|
+
}
|
|
734
|
+
let parsed;
|
|
735
|
+
try {
|
|
736
|
+
parsed = JSON.parse(capabilityEvent.payload.data.receipt);
|
|
737
|
+
}
|
|
738
|
+
catch {
|
|
739
|
+
invalidConfiguration('Durable CapabilityReceipt is not valid JSON.');
|
|
740
|
+
}
|
|
741
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
742
|
+
invalidConfiguration('Durable CapabilityReceipt is not an object.');
|
|
743
|
+
}
|
|
744
|
+
const receipt = parsed;
|
|
745
|
+
const { digest, ...content } = receipt;
|
|
746
|
+
if (typeof digest !== 'string' ||
|
|
747
|
+
(0, canonical_1.digestRuntimeValue)(content) !== digest ||
|
|
748
|
+
digest !== capabilityEvent.payload.data.digest ||
|
|
749
|
+
receipt.threadId !== capabilityEvent.threadId ||
|
|
750
|
+
receipt.turnId !== capabilityEvent.turnId ||
|
|
751
|
+
receipt.stepId !== capabilityEvent.stepId ||
|
|
752
|
+
receipt.requestId !== capabilityEvent.payload.data.receiptId) {
|
|
753
|
+
invalidConfiguration('Durable CapabilityReceipt failed identity or integrity validation.');
|
|
754
|
+
}
|
|
755
|
+
let stepSnapshotDigest = 'unavailable';
|
|
756
|
+
if (snapshotEvent?.payload.type === 'step.snapshot' &&
|
|
757
|
+
snapshotEvent.threadId === receipt.threadId &&
|
|
758
|
+
snapshotEvent.turnId === receipt.turnId &&
|
|
759
|
+
snapshotEvent.stepId === receipt.stepId) {
|
|
760
|
+
stepSnapshotDigest = snapshotEvent.payload.data.digest;
|
|
761
|
+
}
|
|
762
|
+
const fullSchemaBytes = harness_metrics_1.CURRENT_TOOL_SCHEMA_BASELINE_V1.bytes;
|
|
763
|
+
const schemaReductionPercent = Number(((1 - receipt.toolSchemaBytes / fullSchemaBytes) * 100).toFixed(3));
|
|
764
|
+
return Object.freeze({
|
|
765
|
+
requestId: receipt.requestId,
|
|
766
|
+
stepId: receipt.stepId,
|
|
767
|
+
direct: [...receipt.directToolNames],
|
|
768
|
+
deferred: [...receipt.deferredToolNames],
|
|
769
|
+
hidden: { ...receipt.hiddenToolReasons },
|
|
770
|
+
omitted: receipt.omitted.map(item => ({ id: item.id, reason: item.reason })),
|
|
771
|
+
schemaBytes: receipt.toolSchemaBytes,
|
|
772
|
+
fullSchemaBytes,
|
|
773
|
+
schemaReductionPercent,
|
|
774
|
+
stepSnapshotDigest,
|
|
775
|
+
toolRouterDigest: receipt.toolRouterDigest,
|
|
776
|
+
authorityDigest: receipt.authorityDigest,
|
|
777
|
+
executionPolicyDigest: receipt.executionPolicyDigest,
|
|
778
|
+
skillCatalogDigest: receipt.skillCatalogDigest,
|
|
779
|
+
selectedSkillIds: [...receipt.selectedSkillIds],
|
|
780
|
+
mcpCatalogDigest: receipt.mcpCatalogDigest,
|
|
781
|
+
selectedMcpBindings: receipt.selectedMcpBindings.map(binding => `${binding.serverId}:${binding.toolName}`),
|
|
782
|
+
promptSections: receipt.promptManifest.map(section => ({
|
|
783
|
+
id: section.id,
|
|
784
|
+
digest: section.digest,
|
|
785
|
+
selected: section.selected,
|
|
786
|
+
...(section.reason ? { reason: section.reason } : {}),
|
|
787
|
+
})),
|
|
788
|
+
receiptDigest: receipt.digest,
|
|
789
|
+
});
|
|
790
|
+
}
|
|
791
|
+
function validateOptions(options) {
|
|
792
|
+
if (!options || typeof options !== 'object')
|
|
793
|
+
invalidConfiguration('Options are required.');
|
|
794
|
+
if (!options.modelExecutor)
|
|
795
|
+
invalidConfiguration('modelExecutor is required.');
|
|
796
|
+
if (!options.toolCatalog)
|
|
797
|
+
invalidConfiguration('toolCatalog is required.');
|
|
798
|
+
if (!options.toolContext?.cwd?.trim())
|
|
799
|
+
invalidConfiguration('toolContext.cwd is required.');
|
|
800
|
+
if (!options.eventStore?.rootDir?.trim()) {
|
|
801
|
+
invalidConfiguration('eventStore.rootDir is required.');
|
|
802
|
+
}
|
|
803
|
+
if (!options.eventStore?.threadId?.trim()) {
|
|
804
|
+
invalidConfiguration('eventStore.threadId is required.');
|
|
805
|
+
}
|
|
806
|
+
if (!options.projectPath?.trim())
|
|
807
|
+
invalidConfiguration('projectPath is required.');
|
|
808
|
+
if (typeof options.resolveCapabilityConfiguration !== 'function') {
|
|
809
|
+
invalidConfiguration('resolveCapabilityConfiguration is required.');
|
|
810
|
+
}
|
|
811
|
+
if (!options.skills || !Array.isArray(options.skills.providers)) {
|
|
812
|
+
invalidConfiguration('skills.providers must be an array.');
|
|
813
|
+
}
|
|
814
|
+
if (!options.mcp || !Array.isArray(options.mcp.descriptors) || !options.mcp.connector) {
|
|
815
|
+
invalidConfiguration('MCP descriptors and connector are required.');
|
|
816
|
+
}
|
|
817
|
+
if (options.subagents &&
|
|
818
|
+
(!options.subagents.serviceId?.trim() || typeof options.subagents.createTurn !== 'function')) {
|
|
819
|
+
invalidConfiguration('subagents must provide a serviceId and createTurn factory.');
|
|
820
|
+
}
|
|
821
|
+
return Object.freeze({
|
|
822
|
+
...options,
|
|
823
|
+
eventStore: Object.freeze({
|
|
824
|
+
...options.eventStore,
|
|
825
|
+
rootDir: (0, path_1.resolve)(options.eventStore.rootDir),
|
|
826
|
+
}),
|
|
827
|
+
projectPath: (0, path_1.resolve)(options.projectPath),
|
|
828
|
+
});
|
|
829
|
+
}
|
|
830
|
+
function ownerKey(roots) {
|
|
831
|
+
return `${(0, path_1.resolve)(roots.rootDir)}\u0000${roots.threadId}`;
|
|
832
|
+
}
|
|
833
|
+
function goalControlInput(control) {
|
|
834
|
+
return `goal-control:${control.action}:${(0, canonical_1.digestRuntimeValue)(control)}`;
|
|
835
|
+
}
|
|
836
|
+
function parseCommittedHistory(commit) {
|
|
837
|
+
let parsed;
|
|
838
|
+
try {
|
|
839
|
+
parsed = JSON.parse(commit.history);
|
|
840
|
+
}
|
|
841
|
+
catch {
|
|
842
|
+
invalidConfiguration('Durable TurnCommit history is not valid JSON.');
|
|
843
|
+
}
|
|
844
|
+
if (!Array.isArray(parsed)) {
|
|
845
|
+
invalidConfiguration('Durable TurnCommit history is not an array.');
|
|
846
|
+
}
|
|
847
|
+
return parseModelVisibleHistory(parsed);
|
|
848
|
+
}
|
|
849
|
+
function mergeTaskContextOptions(configured, restored) {
|
|
850
|
+
if (!restored)
|
|
851
|
+
return configured;
|
|
852
|
+
const durableState = parseTaskContextState(restored);
|
|
853
|
+
if (configured.state &&
|
|
854
|
+
(0, canonical_1.digestRuntimeValue)(configured.state) !== (0, canonical_1.digestRuntimeValue)(durableState)) {
|
|
855
|
+
invalidConfiguration('Configured TaskContext state conflicts with the durable TurnCommit.');
|
|
856
|
+
}
|
|
857
|
+
if (configured.revision !== undefined && configured.revision !== restored.taskContextRevision) {
|
|
858
|
+
invalidConfiguration('Configured TaskContext revision conflicts with the durable TurnCommit.');
|
|
859
|
+
}
|
|
860
|
+
return {
|
|
861
|
+
...configured,
|
|
862
|
+
state: durableState,
|
|
863
|
+
revision: restored.taskContextRevision,
|
|
864
|
+
};
|
|
865
|
+
}
|
|
866
|
+
function restoreLatestTurnCommit(store) {
|
|
867
|
+
const commits = Object.values(store.loadProjection().turns)
|
|
868
|
+
.map(turn => turn.commit)
|
|
869
|
+
.filter((commit) => Boolean(commit))
|
|
870
|
+
.sort((left, right) => left.seq - right.seq);
|
|
871
|
+
return commits.length > 0 ? (0, turn_commit_1.parseTurnCommitV1)(commits[commits.length - 1].receipt) : undefined;
|
|
872
|
+
}
|
|
873
|
+
function parseTaskContextState(commit) {
|
|
874
|
+
try {
|
|
875
|
+
return JSON.parse(commit.taskContext);
|
|
876
|
+
}
|
|
877
|
+
catch {
|
|
878
|
+
invalidConfiguration('Durable TurnCommit TaskContext is not valid JSON.');
|
|
879
|
+
}
|
|
880
|
+
}
|
|
881
|
+
async function loadRuntimeBaseMessages(compact, configured) {
|
|
882
|
+
const authoritative = compact.loadModelVisibleHistory();
|
|
883
|
+
const configuredMessages = configured ? await configured : undefined;
|
|
884
|
+
if (!authoritative)
|
|
885
|
+
return configuredMessages?.map(message => ({ ...message })) ?? [];
|
|
886
|
+
const durable = parseModelVisibleHistory(authoritative);
|
|
887
|
+
if (!configuredMessages)
|
|
888
|
+
return durable;
|
|
889
|
+
// Product loaders own current system/prompt assembly, but never the durable
|
|
890
|
+
// conversation tail. A committed Compact pointer replaces that tail here.
|
|
891
|
+
return [
|
|
892
|
+
...configuredMessages
|
|
893
|
+
.filter(message => message.role === 'system')
|
|
894
|
+
.map(message => ({ ...message })),
|
|
895
|
+
...durable.filter(message => message.role !== 'system').map(message => ({ ...message })),
|
|
896
|
+
];
|
|
897
|
+
}
|
|
898
|
+
function parseModelVisibleHistory(history) {
|
|
899
|
+
if (!history.every(isMessage)) {
|
|
900
|
+
invalidConfiguration('Durable model-visible history has an invalid message shape.');
|
|
901
|
+
}
|
|
902
|
+
return history.map(message => ({ ...message }));
|
|
903
|
+
}
|
|
904
|
+
function isMessage(value) {
|
|
905
|
+
if (!value || typeof value !== 'object')
|
|
906
|
+
return false;
|
|
907
|
+
const message = value;
|
|
908
|
+
return (['system', 'user', 'assistant', 'tool'].includes(message.role ?? '') &&
|
|
909
|
+
typeof message.content === 'string');
|
|
910
|
+
}
|
|
911
|
+
function throwIfAborted(signal) {
|
|
912
|
+
if (signal.aborted) {
|
|
913
|
+
throw signal.reason instanceof Error ? signal.reason : new Error('Compact was aborted.');
|
|
914
|
+
}
|
|
915
|
+
}
|
|
916
|
+
function withStopDecision(commit, stopDecision) {
|
|
917
|
+
const stats = commit.queryComplete.stats;
|
|
918
|
+
if (!stats)
|
|
919
|
+
invalidConfiguration('A prepared StopDecision requires terminal loop statistics.');
|
|
920
|
+
const queryComplete = {
|
|
921
|
+
...commit.queryComplete,
|
|
922
|
+
stats: { ...stats, stopDecision },
|
|
923
|
+
};
|
|
924
|
+
const content = {
|
|
925
|
+
threadId: commit.threadId,
|
|
926
|
+
turnId: commit.turnId,
|
|
927
|
+
queryComplete,
|
|
928
|
+
taskContextState: commit.taskContextState,
|
|
929
|
+
taskContextRevision: commit.taskContextRevision,
|
|
930
|
+
...(commit.taskContextCompletion
|
|
931
|
+
? { taskContextCompletion: commit.taskContextCompletion }
|
|
932
|
+
: {}),
|
|
933
|
+
history: commit.history,
|
|
934
|
+
};
|
|
935
|
+
return Object.freeze({ ...content, digest: (0, canonical_1.digestRuntimeValue)(content) });
|
|
936
|
+
}
|
|
937
|
+
function terminalFromAgentCommit(complete) {
|
|
938
|
+
if (complete.stats?.finishReason === 'cancelled') {
|
|
939
|
+
return { status: 'interrupted', reason: complete.content || 'AgentLoop interrupted' };
|
|
940
|
+
}
|
|
941
|
+
if (complete.stats?.finishReason === 'failed') {
|
|
942
|
+
return { status: 'failed', error: complete.content || 'AgentLoop failed' };
|
|
943
|
+
}
|
|
944
|
+
return {
|
|
945
|
+
status: 'completed',
|
|
946
|
+
outcome: (0, canonical_1.canonicalRuntimeJson)({
|
|
947
|
+
finishReason: complete.stats?.finishReason ?? 'completed',
|
|
948
|
+
stopDecision: complete.stats?.stopDecision,
|
|
949
|
+
}),
|
|
950
|
+
};
|
|
951
|
+
}
|
|
952
|
+
function servicePort(serviceId, value) {
|
|
953
|
+
return Object.freeze({ serviceId, ...value });
|
|
954
|
+
}
|
|
955
|
+
function invalidConfiguration(message) {
|
|
956
|
+
throw new OrionRuntimeV1Error('ORION_RUNTIME_INVALID_CONFIGURATION', message);
|
|
957
|
+
}
|
|
958
|
+
//# sourceMappingURL=orion-runtime-v1.js.map
|