@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,876 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SubagentThreadRuntimeError = exports.SubagentThreadRuntimeV1 = exports.SubagentThreadTreeScopeV1 = exports.SUBAGENT_THREAD_RUNTIME_VERSION = void 0;
|
|
4
|
+
exports.intersectSubagentAuthorityV1 = intersectSubagentAuthorityV1;
|
|
5
|
+
exports.createSubagentThreadReceiptV1 = createSubagentThreadReceiptV1;
|
|
6
|
+
exports.assertSubagentThreadReceiptV1 = assertSubagentThreadReceiptV1;
|
|
7
|
+
const path_1 = require("path");
|
|
8
|
+
const stop_decision_1 = require("../framework/stop-decision");
|
|
9
|
+
const canonical_1 = require("./protocol/canonical");
|
|
10
|
+
const runtime_protocol_v1_1 = require("./protocol/runtime-protocol-v1");
|
|
11
|
+
const step_snapshot_1 = require("./step-snapshot");
|
|
12
|
+
const thread_event_store_1 = require("./thread-event-store");
|
|
13
|
+
const thread_runtime_1 = require("./thread-runtime");
|
|
14
|
+
const turn_commit_1 = require("./turn-commit");
|
|
15
|
+
exports.SUBAGENT_THREAD_RUNTIME_VERSION = 1;
|
|
16
|
+
/** Root-tree owner for concurrency, provider/tool budgets and cancellation. */
|
|
17
|
+
class SubagentThreadTreeScopeV1 {
|
|
18
|
+
constructor(limits, parentSignal) {
|
|
19
|
+
this.controller = new AbortController();
|
|
20
|
+
this.waiters = [];
|
|
21
|
+
this.active = 0;
|
|
22
|
+
this.modelUsed = 0;
|
|
23
|
+
this.modelReserved = 0;
|
|
24
|
+
this.toolUsed = 0;
|
|
25
|
+
this.toolReserved = 0;
|
|
26
|
+
this.limits = {
|
|
27
|
+
maxConcurrent: positiveInteger(limits.maxConcurrent, 'maxConcurrent'),
|
|
28
|
+
maxQueued: nonNegativeInteger(limits.maxQueued ?? limits.maxConcurrent * 4, 'maxQueued'),
|
|
29
|
+
maxModelRequests: positiveInteger(limits.maxModelRequests, 'maxModelRequests'),
|
|
30
|
+
maxToolCalls: nonNegativeInteger(limits.maxToolCalls, 'maxToolCalls'),
|
|
31
|
+
};
|
|
32
|
+
this.signal = this.controller.signal;
|
|
33
|
+
this.detachParentAbort = forwardAbort(parentSignal, this.controller);
|
|
34
|
+
}
|
|
35
|
+
async acquire(signal) {
|
|
36
|
+
this.assertOpen();
|
|
37
|
+
throwIfAborted(signal);
|
|
38
|
+
if (this.active < this.limits.maxConcurrent) {
|
|
39
|
+
this.active += 1;
|
|
40
|
+
return this.releaseHandle();
|
|
41
|
+
}
|
|
42
|
+
if (this.waiters.length >= this.limits.maxQueued) {
|
|
43
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_TREE_OVERLOADED', `Subagent tree queue is full (${this.limits.maxQueued}).`);
|
|
44
|
+
}
|
|
45
|
+
return new Promise((resolveWaiter, rejectWaiter) => {
|
|
46
|
+
const waiter = {
|
|
47
|
+
signal,
|
|
48
|
+
resolve: resolveWaiter,
|
|
49
|
+
reject: rejectWaiter,
|
|
50
|
+
onAbort: () => {
|
|
51
|
+
const index = this.waiters.indexOf(waiter);
|
|
52
|
+
if (index >= 0)
|
|
53
|
+
this.waiters.splice(index, 1);
|
|
54
|
+
rejectWaiter(abortError(signal));
|
|
55
|
+
},
|
|
56
|
+
};
|
|
57
|
+
signal.addEventListener('abort', waiter.onAbort, { once: true });
|
|
58
|
+
this.waiters.push(waiter);
|
|
59
|
+
});
|
|
60
|
+
}
|
|
61
|
+
reserveBudget(ownerId, request) {
|
|
62
|
+
this.assertOpen();
|
|
63
|
+
const limits = validateBudgetRequest(request);
|
|
64
|
+
if (this.modelUsed + this.modelReserved + limits.maxModelRequests >
|
|
65
|
+
this.limits.maxModelRequests ||
|
|
66
|
+
this.toolUsed + this.toolReserved + limits.maxToolCalls > this.limits.maxToolCalls) {
|
|
67
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_TREE_BUDGET_EXCEEDED', 'The root-tree model/tool budget cannot satisfy this child reservation.');
|
|
68
|
+
}
|
|
69
|
+
this.modelReserved += limits.maxModelRequests;
|
|
70
|
+
this.toolReserved += limits.maxToolCalls;
|
|
71
|
+
return new SubagentThreadBudgetLeaseV1(this, ownerId, limits);
|
|
72
|
+
}
|
|
73
|
+
/** Charge work already performed by the root loop against the same tree budget. */
|
|
74
|
+
recordRootUsage(usage) {
|
|
75
|
+
this.assertOpen();
|
|
76
|
+
const modelRequests = nonNegativeInteger(usage.modelRequests, 'root modelRequests');
|
|
77
|
+
const toolCalls = nonNegativeInteger(usage.toolCalls, 'root toolCalls');
|
|
78
|
+
if (this.modelUsed + this.modelReserved + modelRequests > this.limits.maxModelRequests ||
|
|
79
|
+
this.toolUsed + this.toolReserved + toolCalls > this.limits.maxToolCalls) {
|
|
80
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_TREE_BUDGET_EXCEEDED', 'Root usage exceeds the remaining shared subagent-tree budget.');
|
|
81
|
+
}
|
|
82
|
+
this.modelUsed += modelRequests;
|
|
83
|
+
this.toolUsed += toolCalls;
|
|
84
|
+
return this.snapshot();
|
|
85
|
+
}
|
|
86
|
+
snapshot() {
|
|
87
|
+
return deepFreeze({
|
|
88
|
+
version: exports.SUBAGENT_THREAD_RUNTIME_VERSION,
|
|
89
|
+
active: this.active,
|
|
90
|
+
queued: this.waiters.length,
|
|
91
|
+
maxConcurrent: this.limits.maxConcurrent,
|
|
92
|
+
maxQueued: this.limits.maxQueued,
|
|
93
|
+
modelRequests: {
|
|
94
|
+
used: this.modelUsed,
|
|
95
|
+
reserved: this.modelReserved,
|
|
96
|
+
limit: this.limits.maxModelRequests,
|
|
97
|
+
},
|
|
98
|
+
toolCalls: {
|
|
99
|
+
used: this.toolUsed,
|
|
100
|
+
reserved: this.toolReserved,
|
|
101
|
+
limit: this.limits.maxToolCalls,
|
|
102
|
+
},
|
|
103
|
+
closed: this.signal.aborted,
|
|
104
|
+
});
|
|
105
|
+
}
|
|
106
|
+
close(reason = 'subagent thread tree closed') {
|
|
107
|
+
if (!this.signal.aborted)
|
|
108
|
+
this.controller.abort(reason);
|
|
109
|
+
this.detachParentAbort();
|
|
110
|
+
for (const waiter of this.waiters.splice(0)) {
|
|
111
|
+
waiter.signal.removeEventListener('abort', waiter.onAbort);
|
|
112
|
+
waiter.reject(abortError(this.signal));
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
consume(lease, resource, count) {
|
|
116
|
+
this.assertOpen();
|
|
117
|
+
const amount = positiveInteger(count, `${resource} budget charge`);
|
|
118
|
+
if (resource === 'model') {
|
|
119
|
+
if (lease.modelRequests + amount > lease.limits.maxModelRequests) {
|
|
120
|
+
throw lease.fail(childBudgetError(lease.ownerId, 'model requests', lease.limits.maxModelRequests));
|
|
121
|
+
}
|
|
122
|
+
lease.modelRequests += amount;
|
|
123
|
+
this.modelReserved -= amount;
|
|
124
|
+
this.modelUsed += amount;
|
|
125
|
+
}
|
|
126
|
+
else {
|
|
127
|
+
if (lease.toolCalls + amount > lease.limits.maxToolCalls) {
|
|
128
|
+
throw lease.fail(childBudgetError(lease.ownerId, 'tool calls', lease.limits.maxToolCalls));
|
|
129
|
+
}
|
|
130
|
+
lease.toolCalls += amount;
|
|
131
|
+
this.toolReserved -= amount;
|
|
132
|
+
this.toolUsed += amount;
|
|
133
|
+
}
|
|
134
|
+
return lease.snapshot();
|
|
135
|
+
}
|
|
136
|
+
releaseBudget(lease) {
|
|
137
|
+
this.modelReserved -= lease.limits.maxModelRequests - lease.modelRequests;
|
|
138
|
+
this.toolReserved -= lease.limits.maxToolCalls - lease.toolCalls;
|
|
139
|
+
}
|
|
140
|
+
assertOpen() {
|
|
141
|
+
if (this.signal.aborted)
|
|
142
|
+
throw abortError(this.signal);
|
|
143
|
+
}
|
|
144
|
+
releaseHandle() {
|
|
145
|
+
let released = false;
|
|
146
|
+
return () => {
|
|
147
|
+
if (released)
|
|
148
|
+
return;
|
|
149
|
+
released = true;
|
|
150
|
+
this.active -= 1;
|
|
151
|
+
this.promote();
|
|
152
|
+
};
|
|
153
|
+
}
|
|
154
|
+
promote() {
|
|
155
|
+
while (this.active < this.limits.maxConcurrent && this.waiters.length > 0) {
|
|
156
|
+
const waiter = this.waiters.shift();
|
|
157
|
+
waiter.signal.removeEventListener('abort', waiter.onAbort);
|
|
158
|
+
if (waiter.signal.aborted) {
|
|
159
|
+
waiter.reject(abortError(waiter.signal));
|
|
160
|
+
continue;
|
|
161
|
+
}
|
|
162
|
+
this.active += 1;
|
|
163
|
+
waiter.resolve(this.releaseHandle());
|
|
164
|
+
}
|
|
165
|
+
}
|
|
166
|
+
}
|
|
167
|
+
exports.SubagentThreadTreeScopeV1 = SubagentThreadTreeScopeV1;
|
|
168
|
+
class SubagentThreadBudgetLeaseV1 {
|
|
169
|
+
constructor(tree, ownerId, limits) {
|
|
170
|
+
this.tree = tree;
|
|
171
|
+
this.ownerId = ownerId;
|
|
172
|
+
this.limits = limits;
|
|
173
|
+
this.modelRequests = 0;
|
|
174
|
+
this.toolCalls = 0;
|
|
175
|
+
this.released = false;
|
|
176
|
+
}
|
|
177
|
+
consumeModelRequests(count = 1) {
|
|
178
|
+
this.assertOpen();
|
|
179
|
+
return this.tree.consume(this, 'model', count);
|
|
180
|
+
}
|
|
181
|
+
consumeToolCalls(count = 1) {
|
|
182
|
+
this.assertOpen();
|
|
183
|
+
return this.tree.consume(this, 'tool', count);
|
|
184
|
+
}
|
|
185
|
+
snapshot() {
|
|
186
|
+
return Object.freeze({ modelRequests: this.modelRequests, toolCalls: this.toolCalls });
|
|
187
|
+
}
|
|
188
|
+
release() {
|
|
189
|
+
if (this.released)
|
|
190
|
+
return;
|
|
191
|
+
this.released = true;
|
|
192
|
+
this.tree.releaseBudget(this);
|
|
193
|
+
}
|
|
194
|
+
fail(error) {
|
|
195
|
+
this.failure ?? (this.failure = error);
|
|
196
|
+
return this.failure;
|
|
197
|
+
}
|
|
198
|
+
assertOpen() {
|
|
199
|
+
if (this.released) {
|
|
200
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_TREE_CLOSED', `Budget lease ${this.ownerId} is closed.`);
|
|
201
|
+
}
|
|
202
|
+
}
|
|
203
|
+
}
|
|
204
|
+
/** Durable child-Thread orchestration; it never returns the child's transcript. */
|
|
205
|
+
class SubagentThreadRuntimeV1 {
|
|
206
|
+
constructor(options) {
|
|
207
|
+
this.options = validateOptions(options);
|
|
208
|
+
}
|
|
209
|
+
async run(request) {
|
|
210
|
+
const objective = request.objective.trim();
|
|
211
|
+
if (!objective || Buffer.byteLength(objective, 'utf8') > this.options.maxObjectiveBytes) {
|
|
212
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_INVALID_REQUEST', `Child objective must be non-empty and at most ${this.options.maxObjectiveBytes} bytes.`);
|
|
213
|
+
}
|
|
214
|
+
throwIfAborted(this.options.tree.signal);
|
|
215
|
+
throwIfAborted(request.abortSignal);
|
|
216
|
+
const parent = await flushAndCaptureParent(request.parent);
|
|
217
|
+
throwIfAborted(this.options.tree.signal);
|
|
218
|
+
throwIfAborted(request.abortSignal);
|
|
219
|
+
const rolePolicy = this.options.rolePolicies[request.role];
|
|
220
|
+
if (!rolePolicy) {
|
|
221
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_ROLE_DENIED', `Subagent role ${request.role} has no configured authority policy.`);
|
|
222
|
+
}
|
|
223
|
+
const authority = intersectSubagentAuthorityV1(request.parentAuthority, rolePolicy);
|
|
224
|
+
const childThreadId = this.options.threadIdFactory();
|
|
225
|
+
if (!(0, runtime_protocol_v1_1.isRuntimeId)(childThreadId) || childThreadId === parent.threadId) {
|
|
226
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_INVALID_REQUEST', 'Child Thread ID factory must return a UUID distinct from the parent Thread.');
|
|
227
|
+
}
|
|
228
|
+
const linked = linkAbortSignals([this.options.tree.signal, request.abortSignal]);
|
|
229
|
+
let releaseConcurrency;
|
|
230
|
+
let budget;
|
|
231
|
+
let runtime;
|
|
232
|
+
try {
|
|
233
|
+
releaseConcurrency = await this.options.tree.acquire(linked.signal);
|
|
234
|
+
throwIfAborted(linked.signal);
|
|
235
|
+
budget = this.options.tree.reserveBudget(childThreadId, request.budget ?? this.options.defaultBudget);
|
|
236
|
+
const evidence = new BoundedEvidenceCollectorV1(this.options.maxEvidenceItems, this.options.maxEvidenceBytes);
|
|
237
|
+
const store = new thread_event_store_1.ThreadEventStore(this.options.childStoreRootDir, childThreadId, this.options.eventStoreOptions);
|
|
238
|
+
const runner = await this.options.createAgentLoop({
|
|
239
|
+
role: request.role,
|
|
240
|
+
objective,
|
|
241
|
+
childThreadId,
|
|
242
|
+
childStore: store,
|
|
243
|
+
parent,
|
|
244
|
+
authority,
|
|
245
|
+
budget,
|
|
246
|
+
evidence,
|
|
247
|
+
abortSignal: linked.signal,
|
|
248
|
+
});
|
|
249
|
+
const captured = new CapturingTurnRunnerV1(runner, linked.signal);
|
|
250
|
+
runtime = new thread_runtime_1.ThreadRuntimeV1({
|
|
251
|
+
store,
|
|
252
|
+
runner: captured,
|
|
253
|
+
projectPath: authority.projectRoot,
|
|
254
|
+
requireTurnCommit: true,
|
|
255
|
+
});
|
|
256
|
+
store.appendDurable({
|
|
257
|
+
payload: {
|
|
258
|
+
type: 'thread.forked',
|
|
259
|
+
data: {
|
|
260
|
+
sourceThreadId: parent.threadId,
|
|
261
|
+
sourceSeq: parent.capabilityReceiptSeq,
|
|
262
|
+
},
|
|
263
|
+
},
|
|
264
|
+
});
|
|
265
|
+
const admission = runtime.dispatch({
|
|
266
|
+
type: 'turn.start',
|
|
267
|
+
data: { input: objective, mode: request.mode ?? 'build' },
|
|
268
|
+
});
|
|
269
|
+
if (admission.status !== 'started') {
|
|
270
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_CHILD_START_FAILED', `Child Thread start was ${admission.status}.`);
|
|
271
|
+
}
|
|
272
|
+
const onAbort = () => {
|
|
273
|
+
runtime?.dispatch({
|
|
274
|
+
type: 'turn.interrupt',
|
|
275
|
+
data: { reason: abortMessage(linked.signal) },
|
|
276
|
+
});
|
|
277
|
+
};
|
|
278
|
+
linked.signal.addEventListener('abort', onAbort, { once: true });
|
|
279
|
+
if (linked.signal.aborted)
|
|
280
|
+
onAbort();
|
|
281
|
+
try {
|
|
282
|
+
await runtime.waitForIdle();
|
|
283
|
+
}
|
|
284
|
+
finally {
|
|
285
|
+
linked.signal.removeEventListener('abort', onAbort);
|
|
286
|
+
}
|
|
287
|
+
const projection = store.loadProjection();
|
|
288
|
+
const turn = projection.turns[admission.turnId];
|
|
289
|
+
if (budget.failure)
|
|
290
|
+
throw budget.failure;
|
|
291
|
+
if (!turn || turn.status === 'active' || !turn.commit) {
|
|
292
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_CHILD_COMMIT_MISSING', 'Child AgentLoop did not durably publish a terminal TurnCommitV1.');
|
|
293
|
+
}
|
|
294
|
+
const childCommit = (0, turn_commit_1.parseTurnCommitV1)(turn.commit.receipt);
|
|
295
|
+
assertIndependentStepSnapshots(parent.stepSnapshotDigest, childCommit, turn.status);
|
|
296
|
+
const usage = budget.snapshot();
|
|
297
|
+
const stopDecision = childStopDecision(childCommit, turn.status, usage, budget.limits, parent);
|
|
298
|
+
const summary = boundedChildSummary(projection, admission.turnId, childCommit, this.options.maxSummaryBytes);
|
|
299
|
+
const evidenceItems = boundedEvidence(evidence.snapshot(), childCommit, this.options.maxEvidenceItems, this.options.maxEvidenceBytes);
|
|
300
|
+
const receipt = createSubagentThreadReceiptV1({
|
|
301
|
+
receiptId: (0, runtime_protocol_v1_1.createRuntimeId)(),
|
|
302
|
+
parent,
|
|
303
|
+
childThreadId,
|
|
304
|
+
childTurnId: admission.turnId,
|
|
305
|
+
childCursor: projection.cursor,
|
|
306
|
+
childProjectionDigest: projection.digest,
|
|
307
|
+
childCommit,
|
|
308
|
+
role: request.role,
|
|
309
|
+
authority,
|
|
310
|
+
usage,
|
|
311
|
+
turnTerminal: turn.status,
|
|
312
|
+
stopDecision,
|
|
313
|
+
summary,
|
|
314
|
+
evidence: evidenceItems,
|
|
315
|
+
createdAt: this.options.clock(),
|
|
316
|
+
});
|
|
317
|
+
try {
|
|
318
|
+
await this.options.onReceipt?.(receipt);
|
|
319
|
+
}
|
|
320
|
+
catch (error) {
|
|
321
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_RECEIPT_WRITE_FAILED', `Subagent receipt sink failed: ${errorMessage(error)}`);
|
|
322
|
+
}
|
|
323
|
+
return deepFreeze({
|
|
324
|
+
version: exports.SUBAGENT_THREAD_RUNTIME_VERSION,
|
|
325
|
+
parentThreadId: parent.threadId,
|
|
326
|
+
parentTurnId: parent.turnId,
|
|
327
|
+
childThreadId,
|
|
328
|
+
childTurnId: admission.turnId,
|
|
329
|
+
role: request.role,
|
|
330
|
+
authority,
|
|
331
|
+
status: stopDecision.status,
|
|
332
|
+
turnTerminal: turn.status,
|
|
333
|
+
summary,
|
|
334
|
+
evidence: evidenceItems,
|
|
335
|
+
usage,
|
|
336
|
+
stopDecision,
|
|
337
|
+
receipt,
|
|
338
|
+
});
|
|
339
|
+
}
|
|
340
|
+
finally {
|
|
341
|
+
runtime?.close('subagent child finished');
|
|
342
|
+
budget?.release();
|
|
343
|
+
releaseConcurrency?.();
|
|
344
|
+
linked.dispose();
|
|
345
|
+
}
|
|
346
|
+
}
|
|
347
|
+
}
|
|
348
|
+
exports.SubagentThreadRuntimeV1 = SubagentThreadRuntimeV1;
|
|
349
|
+
class CapturingTurnRunnerV1 {
|
|
350
|
+
constructor(runner, treeSignal) {
|
|
351
|
+
this.runner = runner;
|
|
352
|
+
this.treeSignal = treeSignal;
|
|
353
|
+
}
|
|
354
|
+
async run(context) {
|
|
355
|
+
const linked = linkAbortSignals([context.abortSignal, this.treeSignal]);
|
|
356
|
+
try {
|
|
357
|
+
return await this.runner.run({ ...context, abortSignal: linked.signal });
|
|
358
|
+
}
|
|
359
|
+
finally {
|
|
360
|
+
linked.dispose();
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
}
|
|
364
|
+
class BoundedEvidenceCollectorV1 {
|
|
365
|
+
constructor(maxItems, maxBytes) {
|
|
366
|
+
this.maxItems = maxItems;
|
|
367
|
+
this.maxBytes = maxBytes;
|
|
368
|
+
this.items = [];
|
|
369
|
+
}
|
|
370
|
+
record(evidence) {
|
|
371
|
+
if (this.items.length >= this.maxItems)
|
|
372
|
+
return false;
|
|
373
|
+
const source = truncateUtf8(evidence.source.trim(), this.maxBytes);
|
|
374
|
+
const detail = truncateUtf8(evidence.detail.trim(), this.maxBytes);
|
|
375
|
+
const reference = evidence.reference
|
|
376
|
+
? truncateUtf8(evidence.reference.trim(), this.maxBytes)
|
|
377
|
+
: undefined;
|
|
378
|
+
if (!source || !detail)
|
|
379
|
+
return false;
|
|
380
|
+
this.items.push(deepFreeze({
|
|
381
|
+
kind: evidence.kind,
|
|
382
|
+
source,
|
|
383
|
+
detail,
|
|
384
|
+
...(reference ? { reference } : {}),
|
|
385
|
+
}));
|
|
386
|
+
return true;
|
|
387
|
+
}
|
|
388
|
+
snapshot() {
|
|
389
|
+
return deepFreeze(this.items.map(item => ({ ...item })));
|
|
390
|
+
}
|
|
391
|
+
}
|
|
392
|
+
function intersectSubagentAuthorityV1(parent, rolePolicy) {
|
|
393
|
+
assertAuthority(parent, 'parent');
|
|
394
|
+
assertAuthority(rolePolicy, 'role');
|
|
395
|
+
const projectRoot = intersectProjectRoots(parent.projectRoot, rolePolicy.projectRoot);
|
|
396
|
+
const confirmation = moreRestrictive(parent.confirmation, rolePolicy.confirmation, [
|
|
397
|
+
'allow',
|
|
398
|
+
'ask',
|
|
399
|
+
'deny',
|
|
400
|
+
]);
|
|
401
|
+
const filesystem = moreRestrictive(parent.filesystem, rolePolicy.filesystem, [
|
|
402
|
+
'full',
|
|
403
|
+
'workspace',
|
|
404
|
+
]);
|
|
405
|
+
const network = moreRestrictive(parent.network, rolePolicy.network, [
|
|
406
|
+
'write',
|
|
407
|
+
'read',
|
|
408
|
+
'deny',
|
|
409
|
+
]);
|
|
410
|
+
return (0, step_snapshot_1.createAuthoritySnapshotV1)({
|
|
411
|
+
authorityId: `subagent:${(0, canonical_1.digestRuntimeValue)({ parent: parent.digest, role: rolePolicy.digest })}`,
|
|
412
|
+
projectRoot,
|
|
413
|
+
confirmation,
|
|
414
|
+
filesystem,
|
|
415
|
+
network,
|
|
416
|
+
});
|
|
417
|
+
}
|
|
418
|
+
function createSubagentThreadReceiptV1(input) {
|
|
419
|
+
const content = {
|
|
420
|
+
version: exports.SUBAGENT_THREAD_RUNTIME_VERSION,
|
|
421
|
+
receiptId: input.receiptId,
|
|
422
|
+
parentThreadId: input.parent.threadId,
|
|
423
|
+
parentTurnId: input.parent.turnId,
|
|
424
|
+
parentStepId: input.parent.stepId,
|
|
425
|
+
parentRequestId: input.parent.requestId,
|
|
426
|
+
parentStepSnapshotSeq: input.parent.stepSnapshotSeq,
|
|
427
|
+
parentCapabilityReceiptSeq: input.parent.capabilityReceiptSeq,
|
|
428
|
+
parentStepSnapshotDigest: input.parent.stepSnapshotDigest,
|
|
429
|
+
parentCapabilityReceiptDigest: input.parent.capabilityReceiptDigest,
|
|
430
|
+
parentProjectionCursor: input.parent.projectionCursor,
|
|
431
|
+
parentProjectionDigest: input.parent.projectionDigest,
|
|
432
|
+
childThreadId: input.childThreadId,
|
|
433
|
+
childTurnId: input.childTurnId,
|
|
434
|
+
childCursor: input.childCursor,
|
|
435
|
+
childProjectionDigest: input.childProjectionDigest,
|
|
436
|
+
childCommitDigest: input.childCommit.digest,
|
|
437
|
+
childStepSnapshotDigests: [...input.childCommit.stepSnapshotDigests],
|
|
438
|
+
role: input.role,
|
|
439
|
+
authorityDigest: input.authority.digest,
|
|
440
|
+
usage: { ...input.usage },
|
|
441
|
+
turnTerminal: input.turnTerminal,
|
|
442
|
+
stopDecisionDigest: (0, canonical_1.digestRuntimeValue)(input.stopDecision),
|
|
443
|
+
resultDigest: (0, canonical_1.digestRuntimeValue)({
|
|
444
|
+
status: input.stopDecision.status,
|
|
445
|
+
turnTerminal: input.turnTerminal,
|
|
446
|
+
summary: input.summary,
|
|
447
|
+
}),
|
|
448
|
+
evidenceDigest: (0, canonical_1.digestRuntimeValue)(input.evidence),
|
|
449
|
+
createdAt: input.createdAt,
|
|
450
|
+
};
|
|
451
|
+
return deepFreeze({ ...content, digest: (0, canonical_1.digestRuntimeValue)(content) });
|
|
452
|
+
}
|
|
453
|
+
function assertSubagentThreadReceiptV1(receipt) {
|
|
454
|
+
const { digest, ...content } = receipt;
|
|
455
|
+
if (receipt.version !== exports.SUBAGENT_THREAD_RUNTIME_VERSION ||
|
|
456
|
+
!(0, runtime_protocol_v1_1.isRuntimeId)(receipt.receiptId) ||
|
|
457
|
+
!(0, runtime_protocol_v1_1.isRuntimeId)(receipt.parentThreadId) ||
|
|
458
|
+
!(0, runtime_protocol_v1_1.isRuntimeId)(receipt.parentTurnId) ||
|
|
459
|
+
!(0, runtime_protocol_v1_1.isRuntimeId)(receipt.parentStepId) ||
|
|
460
|
+
!(0, runtime_protocol_v1_1.isRuntimeId)(receipt.parentRequestId) ||
|
|
461
|
+
!(0, runtime_protocol_v1_1.isRuntimeId)(receipt.childThreadId) ||
|
|
462
|
+
!(0, runtime_protocol_v1_1.isRuntimeId)(receipt.childTurnId) ||
|
|
463
|
+
!Number.isSafeInteger(receipt.parentStepSnapshotSeq) ||
|
|
464
|
+
receipt.parentStepSnapshotSeq < 1 ||
|
|
465
|
+
receipt.parentCapabilityReceiptSeq !== receipt.parentStepSnapshotSeq + 1 ||
|
|
466
|
+
!Number.isSafeInteger(receipt.parentProjectionCursor) ||
|
|
467
|
+
receipt.parentCapabilityReceiptSeq > receipt.parentProjectionCursor ||
|
|
468
|
+
!receipt.parentStepSnapshotDigest.trim() ||
|
|
469
|
+
!receipt.parentCapabilityReceiptDigest.trim() ||
|
|
470
|
+
(0, canonical_1.digestRuntimeValue)(content) !== digest) {
|
|
471
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_RECEIPT_INVALID', 'Subagent Thread receipt failed identity or digest validation.');
|
|
472
|
+
}
|
|
473
|
+
}
|
|
474
|
+
class SubagentThreadRuntimeError extends Error {
|
|
475
|
+
constructor(code, message) {
|
|
476
|
+
super(message);
|
|
477
|
+
this.code = code;
|
|
478
|
+
this.name = 'SubagentThreadRuntimeError';
|
|
479
|
+
}
|
|
480
|
+
}
|
|
481
|
+
exports.SubagentThreadRuntimeError = SubagentThreadRuntimeError;
|
|
482
|
+
async function flushAndCaptureParent(input) {
|
|
483
|
+
assertParentForkRequest(input);
|
|
484
|
+
try {
|
|
485
|
+
await input.flush();
|
|
486
|
+
}
|
|
487
|
+
catch (error) {
|
|
488
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_PARENT_FLUSH_FAILED', `Parent step receipt flush failed: ${errorMessage(error)}`);
|
|
489
|
+
}
|
|
490
|
+
const events = replayAllEvents(input.store);
|
|
491
|
+
const projection = input.store.loadProjection();
|
|
492
|
+
const turn = projection.turns[input.turnId];
|
|
493
|
+
if (!turn ||
|
|
494
|
+
turn.status !== 'active' ||
|
|
495
|
+
projection.activeTurnId !== input.turnId ||
|
|
496
|
+
turn.commit) {
|
|
497
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_PARENT_NOT_ACTIVE', `Parent turn ${input.turnId} must remain active at the child fork boundary.`);
|
|
498
|
+
}
|
|
499
|
+
const replayCursor = events.at(-1)?.seq ?? 0;
|
|
500
|
+
if (projection.cursor !== replayCursor || input.store.getCursor() !== projection.cursor) {
|
|
501
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_PARENT_DRIFT', 'Parent durable projection changed while capturing the child fork boundary.');
|
|
502
|
+
}
|
|
503
|
+
const snapshots = events.filter(event => event.payload.type === 'step.snapshot' &&
|
|
504
|
+
(event.stepId === input.stepId || event.payload.data.snapshotId === input.stepId));
|
|
505
|
+
const capabilities = events.filter(event => event.payload.type === 'capability.receipt' &&
|
|
506
|
+
(event.stepId === input.stepId || event.payload.data.receiptId === input.requestId));
|
|
507
|
+
if (snapshots.length !== 1 || capabilities.length !== 1) {
|
|
508
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_PARENT_STEP_NOT_DURABLE', `Parent step ${input.stepId} does not have exactly one durable StepSnapshot/CapabilityReceipt pair.`);
|
|
509
|
+
}
|
|
510
|
+
const snapshotEvent = snapshots[0];
|
|
511
|
+
const capabilityEvent = capabilities[0];
|
|
512
|
+
if (snapshotEvent.payload.type !== 'step.snapshot' ||
|
|
513
|
+
capabilityEvent.payload.type !== 'capability.receipt' ||
|
|
514
|
+
snapshotEvent.seq + 1 !== capabilityEvent.seq ||
|
|
515
|
+
snapshotEvent.threadId !== input.threadId ||
|
|
516
|
+
capabilityEvent.threadId !== input.threadId ||
|
|
517
|
+
snapshotEvent.turnId !== input.turnId ||
|
|
518
|
+
capabilityEvent.turnId !== input.turnId ||
|
|
519
|
+
snapshotEvent.stepId !== input.stepId ||
|
|
520
|
+
capabilityEvent.stepId !== input.stepId ||
|
|
521
|
+
snapshotEvent.payload.data.snapshotId !== input.stepId ||
|
|
522
|
+
capabilityEvent.payload.data.receiptId !== input.requestId ||
|
|
523
|
+
snapshotEvent.payload.data.digest !== input.stepSnapshotDigest ||
|
|
524
|
+
capabilityEvent.payload.data.digest !== input.capabilityReceiptDigest) {
|
|
525
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_PARENT_DRIFT', 'Parent StepSnapshot/CapabilityReceipt envelope differs from the requested fork anchor.');
|
|
526
|
+
}
|
|
527
|
+
const laterStep = events.find(event => event.payload.type === 'step.snapshot' &&
|
|
528
|
+
event.turnId === input.turnId &&
|
|
529
|
+
event.seq > capabilityEvent.seq);
|
|
530
|
+
if (laterStep) {
|
|
531
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_PARENT_DRIFT', `Parent advanced beyond step ${input.stepId} before the child fork boundary.`);
|
|
532
|
+
}
|
|
533
|
+
assertParentReceiptChain(input, snapshotEvent, capabilityEvent);
|
|
534
|
+
return deepFreeze({
|
|
535
|
+
threadId: input.threadId,
|
|
536
|
+
turnId: input.turnId,
|
|
537
|
+
stepId: input.stepId,
|
|
538
|
+
requestId: input.requestId,
|
|
539
|
+
stepSnapshotSeq: snapshotEvent.seq,
|
|
540
|
+
capabilityReceiptSeq: capabilityEvent.seq,
|
|
541
|
+
stepSnapshotDigest: input.stepSnapshotDigest,
|
|
542
|
+
capabilityReceiptDigest: input.capabilityReceiptDigest,
|
|
543
|
+
projectionCursor: projection.cursor,
|
|
544
|
+
projectionDigest: projection.digest,
|
|
545
|
+
});
|
|
546
|
+
}
|
|
547
|
+
function assertParentForkRequest(input) {
|
|
548
|
+
if (!input?.store ||
|
|
549
|
+
!(0, runtime_protocol_v1_1.isRuntimeId)(input.threadId) ||
|
|
550
|
+
!(0, runtime_protocol_v1_1.isRuntimeId)(input.turnId) ||
|
|
551
|
+
!(0, runtime_protocol_v1_1.isRuntimeId)(input.stepId) ||
|
|
552
|
+
!(0, runtime_protocol_v1_1.isRuntimeId)(input.requestId) ||
|
|
553
|
+
input.store.threadId !== input.threadId ||
|
|
554
|
+
!input.stepSnapshotDigest.trim() ||
|
|
555
|
+
!input.capabilityReceiptDigest.trim() ||
|
|
556
|
+
typeof input.flush !== 'function') {
|
|
557
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_INVALID_REQUEST', 'Parent fork requires matching thread/turn/step/request identities and both receipt digests.');
|
|
558
|
+
}
|
|
559
|
+
}
|
|
560
|
+
function assertParentReceiptChain(input, snapshotEvent, capabilityEvent) {
|
|
561
|
+
if (snapshotEvent.payload.type !== 'step.snapshot' ||
|
|
562
|
+
capabilityEvent.payload.type !== 'capability.receipt') {
|
|
563
|
+
parentDrift('Parent fork events are not a StepSnapshot/CapabilityReceipt pair.');
|
|
564
|
+
}
|
|
565
|
+
const persistedSnapshot = parseReceiptObject(snapshotEvent.payload.data.receipt, 'StepSnapshot');
|
|
566
|
+
const capabilityReceipt = parseReceiptObject(capabilityEvent.payload.data.receipt, 'CapabilityReceipt');
|
|
567
|
+
const stepReceipt = persistedSnapshot.stepReceipt;
|
|
568
|
+
if (!isRecord(stepReceipt))
|
|
569
|
+
parentDrift('Parent StepSnapshot is missing its step receipt.');
|
|
570
|
+
assertReceiptDigest(persistedSnapshot, 'Parent StepSnapshot receipt');
|
|
571
|
+
assertReceiptDigest(stepReceipt, 'Parent CapabilityStep receipt');
|
|
572
|
+
assertReceiptDigest(capabilityReceipt, 'Parent Capability receipt');
|
|
573
|
+
if (persistedSnapshot.version !== 1 ||
|
|
574
|
+
persistedSnapshot.snapshotId !== input.stepId ||
|
|
575
|
+
persistedSnapshot.threadId !== input.threadId ||
|
|
576
|
+
persistedSnapshot.turnId !== input.turnId ||
|
|
577
|
+
persistedSnapshot.stepId !== input.stepId ||
|
|
578
|
+
persistedSnapshot.snapshotDigest !== input.stepSnapshotDigest ||
|
|
579
|
+
persistedSnapshot.capabilityReceiptDigest !== input.capabilityReceiptDigest ||
|
|
580
|
+
stepReceipt.version !== 1 ||
|
|
581
|
+
stepReceipt.threadId !== input.threadId ||
|
|
582
|
+
stepReceipt.turnId !== input.turnId ||
|
|
583
|
+
stepReceipt.stepId !== input.stepId ||
|
|
584
|
+
stepReceipt.snapshotDigest !== input.stepSnapshotDigest ||
|
|
585
|
+
stepReceipt.capabilityReceiptDigest !== input.capabilityReceiptDigest ||
|
|
586
|
+
capabilityReceipt.version !== 1 ||
|
|
587
|
+
capabilityReceipt.requestId !== input.requestId ||
|
|
588
|
+
capabilityReceipt.threadId !== input.threadId ||
|
|
589
|
+
capabilityReceipt.turnId !== input.turnId ||
|
|
590
|
+
capabilityReceipt.stepId !== input.stepId ||
|
|
591
|
+
capabilityReceipt.digest !== input.capabilityReceiptDigest) {
|
|
592
|
+
parentDrift('Parent step receipt identity or digest chain is inconsistent.');
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
function assertReceiptDigest(value, label) {
|
|
596
|
+
const record = value;
|
|
597
|
+
const digest = record.digest;
|
|
598
|
+
if (typeof digest !== 'string')
|
|
599
|
+
parentDrift(`${label} has no digest.`);
|
|
600
|
+
const content = { ...record };
|
|
601
|
+
delete content.digest;
|
|
602
|
+
if ((0, canonical_1.digestRuntimeValue)(content) !== digest)
|
|
603
|
+
parentDrift(`${label} digest is invalid.`);
|
|
604
|
+
}
|
|
605
|
+
function parseReceiptObject(serialized, label) {
|
|
606
|
+
let value;
|
|
607
|
+
try {
|
|
608
|
+
value = JSON.parse(serialized);
|
|
609
|
+
}
|
|
610
|
+
catch {
|
|
611
|
+
parentDrift(`${label} is not valid JSON.`);
|
|
612
|
+
}
|
|
613
|
+
if (!isRecord(value))
|
|
614
|
+
parentDrift(`${label} is not an object.`);
|
|
615
|
+
return value;
|
|
616
|
+
}
|
|
617
|
+
function isRecord(value) {
|
|
618
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
619
|
+
}
|
|
620
|
+
function parentDrift(message) {
|
|
621
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_PARENT_DRIFT', message);
|
|
622
|
+
}
|
|
623
|
+
function replayAllEvents(store) {
|
|
624
|
+
const events = [];
|
|
625
|
+
let cursor = 0;
|
|
626
|
+
while (true) {
|
|
627
|
+
const page = store.replay(cursor);
|
|
628
|
+
events.push(...page.events);
|
|
629
|
+
if (!page.hasMore)
|
|
630
|
+
return events;
|
|
631
|
+
if (page.nextCursor <= cursor)
|
|
632
|
+
parentDrift('Parent event replay cursor did not advance.');
|
|
633
|
+
cursor = page.nextCursor;
|
|
634
|
+
}
|
|
635
|
+
}
|
|
636
|
+
function validateOptions(options) {
|
|
637
|
+
if (!options.childStoreRootDir.trim()) {
|
|
638
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_INVALID_REQUEST', 'childStoreRootDir is required.');
|
|
639
|
+
}
|
|
640
|
+
const childStoreRootDir = (0, path_1.resolve)(options.childStoreRootDir);
|
|
641
|
+
return {
|
|
642
|
+
childStoreRootDir,
|
|
643
|
+
tree: options.tree,
|
|
644
|
+
rolePolicies: options.rolePolicies,
|
|
645
|
+
createAgentLoop: options.createAgentLoop,
|
|
646
|
+
eventStoreOptions: options.eventStoreOptions,
|
|
647
|
+
defaultBudget: validateBudgetRequest(options.defaultBudget ?? { maxModelRequests: 6, maxToolCalls: 24 }),
|
|
648
|
+
maxObjectiveBytes: positiveInteger(options.maxObjectiveBytes ?? 64 * 1024, 'maxObjectiveBytes'),
|
|
649
|
+
maxSummaryBytes: positiveInteger(options.maxSummaryBytes ?? 16 * 1024, 'maxSummaryBytes'),
|
|
650
|
+
maxEvidenceItems: positiveInteger(options.maxEvidenceItems ?? 32, 'maxEvidenceItems'),
|
|
651
|
+
maxEvidenceBytes: positiveInteger(options.maxEvidenceBytes ?? 2 * 1024, 'maxEvidenceBytes'),
|
|
652
|
+
threadIdFactory: options.threadIdFactory ?? runtime_protocol_v1_1.createRuntimeId,
|
|
653
|
+
clock: options.clock ?? Date.now,
|
|
654
|
+
onReceipt: options.onReceipt,
|
|
655
|
+
};
|
|
656
|
+
}
|
|
657
|
+
function validateBudgetRequest(input) {
|
|
658
|
+
return Object.freeze({
|
|
659
|
+
maxModelRequests: positiveInteger(input.maxModelRequests, 'child maxModelRequests'),
|
|
660
|
+
maxToolCalls: nonNegativeInteger(input.maxToolCalls, 'child maxToolCalls'),
|
|
661
|
+
});
|
|
662
|
+
}
|
|
663
|
+
function assertAuthority(authority, label) {
|
|
664
|
+
const { digest, ...content } = authority;
|
|
665
|
+
if (!authority.authorityId.trim() ||
|
|
666
|
+
!authority.projectRoot.trim() ||
|
|
667
|
+
!['allow', 'ask', 'deny'].includes(authority.confirmation) ||
|
|
668
|
+
!['workspace', 'full'].includes(authority.filesystem) ||
|
|
669
|
+
!['deny', 'read', 'write'].includes(authority.network) ||
|
|
670
|
+
(0, canonical_1.digestRuntimeValue)(content) !== digest) {
|
|
671
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_AUTHORITY_INVALID', `${label} AuthoritySnapshotV1 failed integrity validation.`);
|
|
672
|
+
}
|
|
673
|
+
}
|
|
674
|
+
function intersectProjectRoots(parentRoot, roleRoot) {
|
|
675
|
+
const parent = (0, path_1.resolve)(parentRoot);
|
|
676
|
+
const role = (0, path_1.resolve)(roleRoot);
|
|
677
|
+
if (isWithin(parent, role))
|
|
678
|
+
return role;
|
|
679
|
+
if (isWithin(role, parent))
|
|
680
|
+
return parent;
|
|
681
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_AUTHORITY_INVALID', 'Parent and role project roots do not overlap.');
|
|
682
|
+
}
|
|
683
|
+
function isWithin(root, candidate) {
|
|
684
|
+
const path = (0, path_1.relative)(root, candidate);
|
|
685
|
+
return path === '' || (path !== '..' && !path.startsWith(`..${path_1.sep}`) && !(0, path_1.isAbsolute)(path));
|
|
686
|
+
}
|
|
687
|
+
function moreRestrictive(left, right, order) {
|
|
688
|
+
return order[Math.max(order.indexOf(left), order.indexOf(right))];
|
|
689
|
+
}
|
|
690
|
+
function assertIndependentStepSnapshots(parentStepSnapshotDigest, child, terminal) {
|
|
691
|
+
if (terminal === 'completed' && child.stepSnapshotDigests.length === 0) {
|
|
692
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_CHILD_SNAPSHOT_INVALID', 'A completed child AgentLoop must persist an independent StepSnapshotV1.');
|
|
693
|
+
}
|
|
694
|
+
if (child.stepSnapshotDigests.includes(parentStepSnapshotDigest)) {
|
|
695
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_CHILD_SNAPSHOT_INVALID', 'Child StepSnapshotV1 aliases a parent snapshot digest.');
|
|
696
|
+
}
|
|
697
|
+
}
|
|
698
|
+
function childStopDecision(commit, terminal, usage, limits, parent) {
|
|
699
|
+
const parsed = parseStopDecision(commit);
|
|
700
|
+
const status = terminal === 'interrupted' ? 'cancelled' : terminal === 'failed' ? 'failed' : 'completed';
|
|
701
|
+
const base = parsed ??
|
|
702
|
+
(0, stop_decision_1.createStopDecision)({
|
|
703
|
+
scope: 'subagent',
|
|
704
|
+
status,
|
|
705
|
+
disposition: status === 'completed' ? 'finish_scope' : 'resume_allowed',
|
|
706
|
+
reason: {
|
|
707
|
+
code: `subagent_${status}`,
|
|
708
|
+
message: status === 'completed'
|
|
709
|
+
? 'Child Thread completed its assigned scope.'
|
|
710
|
+
: `Child Thread ended with ${status}.`,
|
|
711
|
+
},
|
|
712
|
+
evidence: [],
|
|
713
|
+
nextActions: status === 'completed'
|
|
714
|
+
? [{ kind: 'inspect', label: 'Inspect and reconcile child evidence.' }]
|
|
715
|
+
: [{ kind: 'retry', label: 'Retry only after inspecting the child receipt.' }],
|
|
716
|
+
resources: {},
|
|
717
|
+
});
|
|
718
|
+
return (0, stop_decision_1.createStopDecision)({
|
|
719
|
+
...base,
|
|
720
|
+
scope: 'subagent',
|
|
721
|
+
evidence: [
|
|
722
|
+
...base.evidence,
|
|
723
|
+
{
|
|
724
|
+
kind: 'runtime',
|
|
725
|
+
source: 'subagent-thread-runtime',
|
|
726
|
+
detail: `Forked from durable parent step ${parent.stepId} (${parent.capabilityReceiptDigest}).`,
|
|
727
|
+
},
|
|
728
|
+
],
|
|
729
|
+
resources: {
|
|
730
|
+
...base.resources,
|
|
731
|
+
llmRequests: { used: usage.modelRequests, limit: limits.maxModelRequests },
|
|
732
|
+
toolCalls: { used: usage.toolCalls, limit: limits.maxToolCalls },
|
|
733
|
+
},
|
|
734
|
+
});
|
|
735
|
+
}
|
|
736
|
+
function parseStopDecision(commit) {
|
|
737
|
+
if (!commit.stopDecision)
|
|
738
|
+
return undefined;
|
|
739
|
+
let value;
|
|
740
|
+
try {
|
|
741
|
+
value = JSON.parse(commit.stopDecision);
|
|
742
|
+
}
|
|
743
|
+
catch {
|
|
744
|
+
throw childResultError('Child TurnCommit stopDecision is not JSON.');
|
|
745
|
+
}
|
|
746
|
+
if (value.schemaVersion !== 1 ||
|
|
747
|
+
!['completed', 'stopped', 'blocked', 'cancelled', 'failed'].includes(value.status) ||
|
|
748
|
+
!['finish_scope', 'pause_scope', 'resume_allowed'].includes(value.disposition) ||
|
|
749
|
+
!value.reason ||
|
|
750
|
+
!Array.isArray(value.evidence) ||
|
|
751
|
+
!Array.isArray(value.nextActions) ||
|
|
752
|
+
!value.resources ||
|
|
753
|
+
(0, canonical_1.digestRuntimeValue)(value) !== commit.stopDecisionDigest) {
|
|
754
|
+
throw childResultError('Child TurnCommit stopDecision failed schema or digest validation.');
|
|
755
|
+
}
|
|
756
|
+
return value;
|
|
757
|
+
}
|
|
758
|
+
function boundedChildSummary(projection, turnId, commit, maxBytes) {
|
|
759
|
+
const turn = projection.turns[turnId];
|
|
760
|
+
const assistant = turn?.itemIds
|
|
761
|
+
.map(itemId => projection.items[itemId])
|
|
762
|
+
.filter(item => item.kind === 'message' && item.role === 'assistant' && item.content)
|
|
763
|
+
.at(-1)?.content;
|
|
764
|
+
const fallback = commit.outcome ||
|
|
765
|
+
commit.error ||
|
|
766
|
+
commit.reason ||
|
|
767
|
+
`Child Thread ended with ${commit.terminal}.`;
|
|
768
|
+
return truncateUtf8((assistant || fallback).trim(), maxBytes);
|
|
769
|
+
}
|
|
770
|
+
function boundedEvidence(collected, commit, maxItems, maxBytes) {
|
|
771
|
+
const items = collected.slice(0, maxItems).map(item => ({ ...item }));
|
|
772
|
+
if (items.length === 0) {
|
|
773
|
+
items.push({
|
|
774
|
+
kind: 'runtime',
|
|
775
|
+
source: 'subagent-thread-runtime',
|
|
776
|
+
detail: truncateUtf8('Child completed without separately reported task evidence.', maxBytes),
|
|
777
|
+
reference: truncateUtf8(commit.digest, maxBytes),
|
|
778
|
+
});
|
|
779
|
+
}
|
|
780
|
+
return deepFreeze(items);
|
|
781
|
+
}
|
|
782
|
+
function linkAbortSignals(signals) {
|
|
783
|
+
const controller = new AbortController();
|
|
784
|
+
const listeners = [];
|
|
785
|
+
for (const signal of signals) {
|
|
786
|
+
if (!signal)
|
|
787
|
+
continue;
|
|
788
|
+
const listener = () => {
|
|
789
|
+
if (!controller.signal.aborted)
|
|
790
|
+
controller.abort(signal.reason);
|
|
791
|
+
};
|
|
792
|
+
if (signal.aborted)
|
|
793
|
+
listener();
|
|
794
|
+
else {
|
|
795
|
+
signal.addEventListener('abort', listener, { once: true });
|
|
796
|
+
listeners.push({ signal, listener });
|
|
797
|
+
}
|
|
798
|
+
}
|
|
799
|
+
return {
|
|
800
|
+
signal: controller.signal,
|
|
801
|
+
dispose: () => {
|
|
802
|
+
for (const entry of listeners) {
|
|
803
|
+
entry.signal.removeEventListener('abort', entry.listener);
|
|
804
|
+
}
|
|
805
|
+
},
|
|
806
|
+
};
|
|
807
|
+
}
|
|
808
|
+
function forwardAbort(signal, target) {
|
|
809
|
+
if (!signal)
|
|
810
|
+
return () => undefined;
|
|
811
|
+
const listener = () => {
|
|
812
|
+
if (!target.signal.aborted)
|
|
813
|
+
target.abort(signal.reason);
|
|
814
|
+
};
|
|
815
|
+
if (signal.aborted)
|
|
816
|
+
listener();
|
|
817
|
+
else
|
|
818
|
+
signal.addEventListener('abort', listener, { once: true });
|
|
819
|
+
return () => signal.removeEventListener('abort', listener);
|
|
820
|
+
}
|
|
821
|
+
function throwIfAborted(signal) {
|
|
822
|
+
if (signal?.aborted)
|
|
823
|
+
throw abortError(signal);
|
|
824
|
+
}
|
|
825
|
+
function abortError(signal) {
|
|
826
|
+
return new SubagentThreadRuntimeError('ORION_SUBAGENT_ABORTED', abortMessage(signal));
|
|
827
|
+
}
|
|
828
|
+
function abortMessage(signal) {
|
|
829
|
+
return signal.reason instanceof Error
|
|
830
|
+
? signal.reason.message
|
|
831
|
+
: String(signal.reason || 'Subagent Thread was aborted.');
|
|
832
|
+
}
|
|
833
|
+
function childBudgetError(ownerId, resource, limit) {
|
|
834
|
+
return new SubagentThreadRuntimeError('ORION_SUBAGENT_TREE_BUDGET_EXCEEDED', `Child ${ownerId} exceeded its ${resource} reservation (${limit}).`);
|
|
835
|
+
}
|
|
836
|
+
function childResultError(message) {
|
|
837
|
+
return new SubagentThreadRuntimeError('ORION_SUBAGENT_CHILD_RESULT_INVALID', message);
|
|
838
|
+
}
|
|
839
|
+
function truncateUtf8(value, maxBytes) {
|
|
840
|
+
if (Buffer.byteLength(value, 'utf8') <= maxBytes)
|
|
841
|
+
return value;
|
|
842
|
+
let result = '';
|
|
843
|
+
let bytes = 0;
|
|
844
|
+
for (const character of value) {
|
|
845
|
+
const next = Buffer.byteLength(character, 'utf8');
|
|
846
|
+
if (bytes + next > maxBytes)
|
|
847
|
+
break;
|
|
848
|
+
result += character;
|
|
849
|
+
bytes += next;
|
|
850
|
+
}
|
|
851
|
+
return result;
|
|
852
|
+
}
|
|
853
|
+
function positiveInteger(value, name) {
|
|
854
|
+
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
855
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_INVALID_REQUEST', `${name} must be a positive safe integer.`);
|
|
856
|
+
}
|
|
857
|
+
return value;
|
|
858
|
+
}
|
|
859
|
+
function nonNegativeInteger(value, name) {
|
|
860
|
+
if (!Number.isSafeInteger(value) || value < 0) {
|
|
861
|
+
throw new SubagentThreadRuntimeError('ORION_SUBAGENT_INVALID_REQUEST', `${name} must be a non-negative safe integer.`);
|
|
862
|
+
}
|
|
863
|
+
return value;
|
|
864
|
+
}
|
|
865
|
+
function errorMessage(error) {
|
|
866
|
+
return error instanceof Error ? error.message : String(error);
|
|
867
|
+
}
|
|
868
|
+
function deepFreeze(value) {
|
|
869
|
+
if (typeof value !== 'object' || value === null || Object.isFrozen(value))
|
|
870
|
+
return value;
|
|
871
|
+
Object.freeze(value);
|
|
872
|
+
for (const child of Object.values(value))
|
|
873
|
+
deepFreeze(child);
|
|
874
|
+
return value;
|
|
875
|
+
}
|
|
876
|
+
//# sourceMappingURL=subagent-thread-runtime.js.map
|