@orion-agents/orion-code 0.3.66 → 0.4.4
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 +87 -0
- package/README.md +78 -361
- package/README.zh-CN.md +71 -262
- package/bin/orion +4 -1
- package/dist/acp/session-updates.d.ts +35 -0
- package/dist/acp/session-updates.js +183 -0
- package/dist/acp/sessions.d.ts +32 -0
- package/dist/acp/sessions.js +328 -0
- package/dist/acp/stdio.d.ts +3 -0
- package/dist/acp/stdio.js +59 -0
- package/dist/cli.js +136 -185
- package/dist/commands/context-tool-command-handlers.d.ts +1 -1
- package/dist/commands/context-tool-command-handlers.js +24 -3
- package/dist/commands/core-command-handlers.js +10 -18
- package/dist/commands/diagnostic-command-handlers.js +58 -48
- package/dist/commands/diagnostic-commands.js +0 -12
- package/dist/commands/init-command.d.ts +3 -0
- package/dist/commands/init-command.js +131 -0
- package/dist/commands/model-command-handlers.d.ts +1 -2
- package/dist/commands/model-command-handlers.js +15 -100
- package/dist/commands/model-commands.js +0 -11
- package/dist/commands/registry.js +1 -19
- package/dist/commands/rsi-command.d.ts +2 -0
- package/dist/commands/rsi-command.js +180 -0
- package/dist/commands/session-command-handlers.js +28 -19
- package/dist/commands/system-commands.js +0 -1
- package/dist/commands/target-command.js +49 -6
- package/dist/commands/tool-commands.js +1 -1
- package/dist/commands/types.d.ts +4 -10
- package/dist/commands/types.js +1 -21
- package/dist/commands/workflow-command-handlers.js +13 -4
- package/dist/commands/workflow-commands.js +2 -2
- package/dist/framework/loop-budget-contract.d.ts +2 -8
- package/dist/framework/loop-budget-contract.js +0 -3
- package/dist/framework/loop-progress.d.ts +18 -0
- package/dist/framework/loop-progress.js +63 -0
- package/dist/framework/prompt.d.ts +0 -2
- package/dist/framework/prompt.js +9 -27
- package/dist/framework/query.d.ts +26 -31
- package/dist/framework/query.js +451 -292
- package/dist/framework/store.d.ts +6 -10
- package/dist/framework/store.js +2 -21
- package/dist/framework/tool-call-orchestrator.d.ts +7 -0
- package/dist/framework/tool-call-orchestrator.js +8 -3
- package/dist/framework/tool-state.d.ts +2 -0
- package/dist/framework/tool.d.ts +0 -23
- package/dist/framework/verification-command.d.ts +15 -0
- package/dist/framework/verification-command.js +32 -0
- package/dist/harness/assembler.d.ts +1 -0
- package/dist/harness/assembler.js +24 -0
- package/dist/harness/capsule.d.ts +1 -1
- package/dist/harness/capsule.js +33 -14
- package/dist/harness/context-harness.d.ts +37 -12
- package/dist/harness/context-harness.js +545 -35
- package/dist/harness/contract.js +1 -1
- package/dist/harness/drift-guard.d.ts +4 -0
- package/dist/harness/drift-guard.js +68 -16
- package/dist/harness/index.d.ts +1 -1
- package/dist/harness/intent.js +21 -0
- package/dist/harness/ledger.d.ts +7 -11
- package/dist/harness/ledger.js +50 -9
- package/dist/harness/progress-controller.d.ts +12 -7
- package/dist/harness/progress-controller.js +96 -29
- package/dist/harness/state.js +10 -1
- package/dist/harness/stop-controller.d.ts +0 -5
- package/dist/harness/stop-controller.js +11 -31
- package/dist/harness/task-checklist.d.ts +16 -0
- package/dist/harness/task-checklist.js +92 -0
- package/dist/harness/types.d.ts +78 -1
- package/dist/harness/verification.d.ts +19 -1
- package/dist/harness/verification.js +116 -29
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -3
- package/dist/print-ui/event-stream.d.ts +43 -0
- package/dist/print-ui/event-stream.js +204 -0
- package/dist/print-ui/launch.d.ts +12 -1
- package/dist/print-ui/launch.js +173 -11
- package/dist/product/environment.d.ts +1 -1
- package/dist/product/environment.js +1 -1
- package/dist/product/identity.d.ts +1 -1
- package/dist/product/identity.js +1 -1
- package/dist/product/paths.d.ts +3 -2
- package/dist/product/paths.js +6 -2
- package/dist/runtime/agent-loop.d.ts +12 -2
- package/dist/runtime/agent-loop.js +172 -29
- package/dist/runtime/agent-runtime-controller.d.ts +14 -4
- package/dist/runtime/agent-runtime-controller.js +366 -192
- package/dist/runtime/agent-runtime-protocol.d.ts +10 -18
- package/dist/runtime/agent-runtime-runner.d.ts +10 -0
- package/dist/runtime/builtin-tool-provider.js +5 -1
- package/dist/runtime/capability-receipt-journal.js +1 -0
- package/dist/runtime/durable-tool-receipt-reader.js +2 -1
- package/dist/runtime/first-party-tool-services.d.ts +1 -0
- package/dist/runtime/first-party-tool-services.js +2 -12
- package/dist/runtime/first-party-tool-universe.d.ts +1 -0
- package/dist/runtime/first-party-tool-universe.js +1 -1
- package/dist/runtime/followup-queue-store.d.ts +16 -0
- package/dist/runtime/followup-queue-store.js +75 -0
- package/dist/runtime/goal-lifecycle-v2.d.ts +16 -4
- package/dist/runtime/goal-lifecycle-v2.js +217 -39
- package/dist/runtime/goal-runtime-coordinator.d.ts +14 -2
- package/dist/runtime/goal-runtime-coordinator.js +147 -36
- package/dist/runtime/goals/presentation.js +3 -1
- package/dist/runtime/goals/types.d.ts +1 -3
- package/dist/runtime/goals/types.js +0 -3
- package/dist/runtime/loop-budget.d.ts +0 -7
- package/dist/runtime/loop-budget.js +8 -52
- package/dist/runtime/mcp/first-party-mcp-adapter.d.ts +2 -0
- package/dist/runtime/mcp/first-party-mcp-adapter.js +23 -19
- package/dist/runtime/model-coordinator.js +2 -5
- package/dist/runtime/orion-runtime-v1.d.ts +18 -2
- package/dist/runtime/orion-runtime-v1.js +183 -46
- package/dist/runtime/orion-session-runner.d.ts +7 -0
- package/dist/runtime/orion-session-runner.js +82 -0
- package/dist/runtime/plan-review.d.ts +1 -0
- package/dist/runtime/plan-review.js +8 -4
- package/dist/runtime/product-bootstrap.d.ts +6 -0
- package/dist/runtime/product-bootstrap.js +41 -51
- package/dist/runtime/product-orion-runtime.js +129 -58
- package/dist/runtime/release-receipts.d.ts +24 -133
- package/dist/runtime/release-receipts.js +129 -693
- package/dist/runtime/rich-text/layout.js +108 -65
- package/dist/runtime/rsi/contracts.d.ts +50 -0
- package/dist/runtime/rsi/contracts.js +17 -0
- package/dist/runtime/rsi/diagnosis.d.ts +46 -0
- package/dist/runtime/rsi/diagnosis.js +98 -0
- package/dist/runtime/rsi/evaluation-suite.d.ts +25 -0
- package/dist/runtime/rsi/evaluation-suite.js +141 -0
- package/dist/runtime/rsi/evaluation-worker.d.ts +19 -0
- package/dist/runtime/rsi/evaluation-worker.js +64 -0
- package/dist/runtime/rsi/evaluation.d.ts +49 -0
- package/dist/runtime/rsi/evaluation.js +345 -0
- package/dist/runtime/rsi/lifecycle.d.ts +54 -0
- package/dist/runtime/rsi/lifecycle.js +279 -0
- package/dist/runtime/rsi/proposal.d.ts +39 -0
- package/dist/runtime/rsi/proposal.js +312 -0
- package/dist/runtime/rsi/receipt.d.ts +28 -0
- package/dist/runtime/rsi/receipt.js +138 -0
- package/dist/runtime/rsi/skill-state.d.ts +7 -0
- package/dist/runtime/rsi/skill-state.js +50 -0
- package/dist/runtime/rsi/trajectory.d.ts +19 -0
- package/dist/runtime/rsi/trajectory.js +314 -0
- package/dist/runtime/rsi/triage.d.ts +274 -0
- package/dist/runtime/rsi/triage.js +58 -0
- package/dist/runtime/session-composer-control.d.ts +5 -24
- package/dist/runtime/session-composer-control.js +27 -189
- package/dist/runtime/step-snapshot.d.ts +4 -1
- package/dist/runtime/step-snapshot.js +11 -1
- package/dist/runtime/subagent-thread-runtime.js +27 -5
- package/dist/runtime/subagents/policy.js +0 -1
- package/dist/runtime/subagents/production.js +1 -5
- package/dist/runtime/subagents/runtime-integration.js +2 -4
- package/dist/runtime/subagents/types.d.ts +0 -5
- package/dist/runtime/subagents/types.js +0 -2
- package/dist/runtime/task-context-recovery.d.ts +55 -0
- package/dist/runtime/task-context-recovery.js +349 -0
- package/dist/runtime/task-context-service.d.ts +20 -10
- package/dist/runtime/task-context-service.js +69 -9
- package/dist/runtime/thread-admission.d.ts +3 -1
- package/dist/runtime/thread-admission.js +21 -7
- package/dist/runtime/thread-event-store.d.ts +2 -2
- package/dist/runtime/thread-event-store.js +7 -2
- package/dist/runtime/thread-projection.js +4 -2
- package/dist/runtime/thread-runtime.d.ts +10 -0
- package/dist/runtime/thread-runtime.js +85 -3
- package/dist/runtime/thread-session-index.d.ts +8 -0
- package/dist/runtime/thread-session-index.js +50 -1
- package/dist/runtime/thread-session-view.d.ts +2 -1
- package/dist/runtime/thread-session-view.js +4 -0
- package/dist/runtime/thread-tool-journal.d.ts +1 -0
- package/dist/runtime/thread-tool-journal.js +6 -2
- package/dist/runtime/thread-ui-adapter.d.ts +1 -0
- package/dist/runtime/thread-ui-adapter.js +89 -22
- package/dist/runtime/tool-gateway.d.ts +9 -0
- package/dist/runtime/tool-gateway.js +24 -0
- package/dist/runtime/tool-receipt-validator.js +4 -0
- package/dist/runtime/tool-transcript-entry.d.ts +16 -0
- package/dist/runtime/tool-transcript-entry.js +73 -0
- package/dist/runtime/turn-commit.d.ts +4 -1
- package/dist/runtime/turn-commit.js +19 -15
- package/dist/runtime/ui-events.d.ts +15 -1
- package/dist/runtime/ui-view-model.d.ts +6 -5
- package/dist/runtime/ui-view-model.js +78 -61
- package/dist/runtime/workspace-runtime-kernel.js +0 -1
- package/dist/runtime/workspace-verification.d.ts +7 -0
- package/dist/runtime/workspace-verification.js +83 -0
- package/dist/services/atomic-write.d.ts +2 -0
- package/dist/services/atomic-write.js +12 -1
- package/dist/services/code-review/format.d.ts +4 -1
- package/dist/services/code-review/format.js +5 -1
- package/dist/services/code-review/runner.d.ts +2 -2
- package/dist/services/code-review/runner.js +86 -64
- package/dist/services/code-review/snapshot.d.ts +9 -9
- package/dist/services/code-review/snapshot.js +182 -166
- package/dist/services/compact/auto-compact.d.ts +21 -6
- package/dist/services/compact/auto-compact.js +148 -22
- package/dist/services/compact/background-candidate.d.ts +33 -0
- package/dist/services/compact/background-candidate.js +184 -0
- package/dist/services/compact/compact.d.ts +4 -1
- package/dist/services/compact/compact.js +30 -3
- package/dist/services/compact/coordinator.d.ts +10 -4
- package/dist/services/compact/coordinator.js +17 -7
- package/dist/services/compact/summary-generator.d.ts +4 -2
- package/dist/services/compact/summary-generator.js +17 -3
- package/dist/services/config.d.ts +5 -5
- package/dist/services/config.js +29 -48
- package/dist/services/doctor.js +85 -13
- package/dist/services/effort.d.ts +5 -5
- package/dist/services/effort.js +5 -11
- package/dist/services/file-lock.d.ts +9 -3
- package/dist/services/file-lock.js +92 -26
- package/dist/services/global-config.d.ts +26 -64
- package/dist/services/global-config.js +233 -193
- package/dist/services/llm.d.ts +42 -4
- package/dist/services/llm.js +177 -45
- package/dist/services/model-client-pool.d.ts +15 -9
- package/dist/services/model-client-pool.js +62 -33
- package/dist/services/model-context.d.ts +2 -1
- package/dist/services/model-context.js +15 -9
- package/dist/services/model-registry.d.ts +4 -15
- package/dist/services/model-registry.js +32 -101
- package/dist/services/provider-diagnostics.d.ts +8 -0
- package/dist/services/provider-diagnostics.js +17 -12
- package/dist/services/provider-resilience/coordinator.d.ts +1 -1
- package/dist/services/provider-resilience/coordinator.js +10 -6
- package/dist/services/provider-resilience/request-gate.d.ts +3 -0
- package/dist/services/provider-resilience/request-gate.js +29 -18
- package/dist/services/provider-resilience/types.d.ts +2 -0
- package/dist/services/session-storage.d.ts +7 -10
- package/dist/services/session-storage.js +57 -30
- package/dist/services/settings-coordinator.d.ts +0 -6
- package/dist/services/settings-coordinator.js +19 -56
- package/dist/services/settings-document-repository.d.ts +3 -10
- package/dist/services/settings-document-repository.js +7 -85
- package/dist/services/usage-state.d.ts +3 -3
- package/dist/services/usage-state.js +11 -42
- package/dist/terminal-ui/answer-format.d.ts +14 -0
- package/dist/terminal-ui/answer-format.js +119 -0
- package/dist/terminal-ui/launch.d.ts +7 -6
- package/dist/terminal-ui/launch.js +160 -70
- package/dist/terminal-ui/output-queue.d.ts +2 -1
- package/dist/terminal-ui/output-queue.js +1 -1
- package/dist/terminal-ui/raw-editor.d.ts +2 -1
- package/dist/terminal-ui/raw-editor.js +56 -15
- package/dist/tools/core/edit-file.js +6 -2
- package/dist/tools/core/write-file.js +9 -2
- package/dist/tools/lsp.d.ts +16 -1
- package/dist/tools/lsp.js +60 -19
- package/dist/tools/sandbox.d.ts +1 -1
- package/dist/tools/sandbox.js +3 -16
- package/dist/tools/todo.d.ts +4 -2
- package/dist/tools/todo.js +91 -30
- package/dist/tui-core/input-parser.d.ts +1 -0
- package/dist/tui-core/input-parser.js +6 -0
- package/dist/tui-core/style.d.ts +1 -8
- package/dist/tui-core/style.js +3 -110
- package/dist/tui-ui/chrome-view-model.d.ts +1 -1
- package/dist/tui-ui/chrome-view-model.js +36 -32
- package/dist/tui-ui/launch.js +14 -14
- package/dist/tui-ui/layout.d.ts +5 -7
- package/dist/tui-ui/layout.js +129 -124
- package/dist/tui-ui/runner.d.ts +11 -12
- package/dist/tui-ui/runner.js +88 -67
- package/dist/tui-ui/state.d.ts +0 -11
- package/dist/tui-ui/state.js +22 -33
- package/dist/tui-ui/terminal-image.js +22 -4
- package/dist/tui-ui/transcript-inspector-layout.js +6 -3
- package/dist/tui-ui/transcript-inspector.d.ts +1 -0
- package/dist/tui-ui/transcript-inspector.js +7 -1
- package/dist/tui-ui/transcript-layout.js +42 -6
- package/dist/utils/terminal-text.d.ts +11 -0
- package/dist/utils/terminal-text.js +114 -0
- package/docs/cli-guide.md +575 -0
- package/docs/orion.example.yaml +43 -0
- package/docs/readme.md +12 -57
- package/npm-shrinkwrap.json +484 -1855
- package/package.json +13 -63
- package/dist/migration/command.d.ts +0 -9
- package/dist/migration/command.js +0 -100
- package/dist/migration/index.d.ts +0 -7
- package/dist/migration/index.js +0 -14
- package/dist/migration/migrate.d.ts +0 -19
- package/dist/migration/migrate.js +0 -406
- package/dist/migration/types.d.ts +0 -55
- package/dist/migration/types.js +0 -6
- package/dist/services/tool-allowlist.d.ts +0 -110
- package/dist/services/tool-allowlist.js +0 -299
- package/dist/services/yaml-config.d.ts +0 -57
- package/dist/services/yaml-config.js +0 -178
- package/dist/web/cli-options.d.ts +0 -17
- package/dist/web/cli-options.js +0 -51
- package/dist/web/code-review-run-service.d.ts +0 -68
- package/dist/web/code-review-run-service.js +0 -228
- package/dist/web/context-text.d.ts +0 -17
- package/dist/web/context-text.js +0 -40
- package/dist/web/errors.d.ts +0 -6
- package/dist/web/errors.js +0 -13
- package/dist/web/event-hub.d.ts +0 -45
- package/dist/web/event-hub.js +0 -370
- package/dist/web/file-read-service.d.ts +0 -101
- package/dist/web/file-read-service.js +0 -593
- package/dist/web/file-write-service.d.ts +0 -16
- package/dist/web/file-write-service.js +0 -103
- package/dist/web/git-compare-service.d.ts +0 -45
- package/dist/web/git-compare-service.js +0 -160
- package/dist/web/git-diff-document.d.ts +0 -102
- package/dist/web/git-diff-document.js +0 -258
- package/dist/web/git-file-source.d.ts +0 -25
- package/dist/web/git-file-source.js +0 -21
- package/dist/web/git-history-service.d.ts +0 -151
- package/dist/web/git-history-service.js +0 -619
- package/dist/web/git-index-transaction.d.ts +0 -45
- package/dist/web/git-index-transaction.js +0 -174
- package/dist/web/git-patch-builder.d.ts +0 -30
- package/dist/web/git-patch-builder.js +0 -138
- package/dist/web/git-read-model-service.d.ts +0 -452
- package/dist/web/git-read-model-service.js +0 -1833
- package/dist/web/git-version-service.d.ts +0 -79
- package/dist/web/git-version-service.js +0 -279
- package/dist/web/host-daemon.d.ts +0 -70
- package/dist/web/host-daemon.js +0 -237
- package/dist/web/index.d.ts +0 -6
- package/dist/web/index.js +0 -28
- package/dist/web/launch.d.ts +0 -12
- package/dist/web/launch.js +0 -89
- package/dist/web/native-directory-picker.d.ts +0 -63
- package/dist/web/native-directory-picker.js +0 -169
- package/dist/web/protocol.d.ts +0 -705
- package/dist/web/protocol.js +0 -639
- package/dist/web/review-service.d.ts +0 -22
- package/dist/web/review-service.js +0 -68
- package/dist/web/server.d.ts +0 -20
- package/dist/web/server.js +0 -1453
- package/dist/web/session-runtime-registry.d.ts +0 -138
- package/dist/web/session-runtime-registry.js +0 -471
- package/dist/web/terminal-manager.d.ts +0 -156
- package/dist/web/terminal-manager.js +0 -779
- package/dist/web/terminal-server.d.ts +0 -8
- package/dist/web/terminal-server.js +0 -304
- package/dist/web/workbench-controller.d.ts +0 -395
- package/dist/web/workbench-controller.js +0 -3077
- package/dist/web/workspace-discovery.d.ts +0 -92
- package/dist/web/workspace-discovery.js +0 -324
- package/dist/web/workspace-mutation-arbiter.d.ts +0 -54
- package/dist/web/workspace-mutation-arbiter.js +0 -267
- package/dist/web/workspace-open-telemetry.d.ts +0 -55
- package/dist/web/workspace-open-telemetry.js +0 -73
- package/dist/web-client/assets/FilesPanel-CPDovK_K.js +0 -1
- package/dist/web-client/assets/GitPanel-DtU_TD61.js +0 -4
- package/dist/web-client/assets/ReviewPanel-vMO7BEA3.js +0 -6
- package/dist/web-client/assets/TerminalPanel-C9vDTAlS.js +0 -23
- package/dist/web-client/assets/TerminalPanel-DLuoa74B.css +0 -1
- package/dist/web-client/assets/index-CABdwh4l.css +0 -1
- package/dist/web-client/assets/index-KvshfEbl.js +0 -20
- package/dist/web-client/assets/useAutoNotice-IE1g2wcb.js +0 -1
- package/dist/web-client/favicon.svg +0 -9
- package/dist/web-client/index.html +0 -17
- package/docs/architecture/agent-mode-permission-contract.md +0 -87
- package/docs/architecture/v0.3.0-web-api.yaml +0 -1340
- package/docs/architecture/v0.3.1-web-api.yaml +0 -2338
- package/docs/architecture/v0.3.2-web-api.yaml +0 -3029
- package/docs/architecture/v0.3.3-web-api.yaml +0 -3205
- package/docs/architecture/v0.3.4-stabilization-contract.md +0 -32
- package/docs/migration/v0.1.9-to-v0.2.0.md +0 -98
- package/docs/migration/v0.2.2-to-v0.3.0-settings.md +0 -114
- package/docs/migration/v0.2.2-to-v0.3.0.md +0 -55
- package/docs/migration/v0.3.0-to-v0.3.1.md +0 -88
- package/docs/migration/v0.3.1-to-v0.3.2.md +0 -94
- package/docs/migration/v0.3.2-to-v0.3.3.md +0 -62
- package/docs/migration/v0.3.3-to-v0.3.4.md +0 -36
- package/docs/orion.example.json +0 -86
- package/docs/plan/v0.2.0-dsh-harness-redesign-plan.md +0 -1234
- package/docs/plan/v0.2.0-release-checklist.md +0 -91
- package/docs/plan/v0.3.0-node-runtime-compatibility-plan.md +0 -57
- package/docs/plan/v0.3.0-settings-integration-plan.md +0 -740
- package/docs/plan/v0.3.0-web-workbench-plan.md +0 -376
- package/docs/plan/v0.3.1-web-workbench-professional-shell-plan.md +0 -848
- package/docs/plan/v0.3.2-web-workbench-layout-and-composer-plan.md +0 -869
- package/docs/plan/v0.3.3-plan.md +0 -1113
- package/docs/plan/v0.3.4-stabilization-plan.md +0 -89
- package/docs/test/v0.3.1-web-workbench-e2e-plan.md +0 -140
- package/docs/test/v0.3.2-web-workbench-e2e-plan.md +0 -100
- package/docs/test/v0.3.3-web-workbench-e2e-plan.md +0 -79
- package/docs/test/v0.3.4-stabilization-e2e-plan.md +0 -54
|
@@ -2,17 +2,18 @@
|
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.createWorkspaceRuntimeKernelV1 = createWorkspaceRuntimeKernelV1;
|
|
4
4
|
exports.createProductUiRuntime = createProductUiRuntime;
|
|
5
|
+
const followup_queue_store_1 = require("./followup-queue-store");
|
|
5
6
|
const path_1 = require("path");
|
|
6
7
|
const prompt_context_1 = require("../memory/prompt-context");
|
|
7
8
|
const store_1 = require("../framework/store");
|
|
8
9
|
const compact_1 = require("../services/compact");
|
|
9
10
|
const config_1 = require("../services/config");
|
|
10
|
-
const config_dir_1 = require("../services/config-dir");
|
|
11
11
|
const global_config_1 = require("../services/global-config");
|
|
12
12
|
const llm_1 = require("../services/llm");
|
|
13
13
|
const effort_1 = require("../services/effort");
|
|
14
14
|
const model_context_1 = require("../services/model-context");
|
|
15
15
|
const model_registry_1 = require("../services/model-registry");
|
|
16
|
+
const model_client_pool_1 = require("../services/model-client-pool");
|
|
16
17
|
const project_instructions_1 = require("../services/project-instructions");
|
|
17
18
|
const settings_coordinator_1 = require("../services/settings-coordinator");
|
|
18
19
|
const session_storage_1 = require("../services/session-storage");
|
|
@@ -34,10 +35,9 @@ const workspace_runtime_kernel_1 = require("./workspace-runtime-kernel");
|
|
|
34
35
|
*/
|
|
35
36
|
function createWorkspaceRuntimeKernelV1(options) {
|
|
36
37
|
const canonicalCwd = (0, path_1.resolve)(options.cwd);
|
|
37
|
-
(0, config_dir_1.ensureConfigDir)();
|
|
38
|
-
(0, global_config_1.recordFirstStartTime)();
|
|
39
38
|
const kernelConfig = (0, config_1.loadConfig)(options.uiRenderer ? { ui: { renderer: options.uiRenderer } } : {});
|
|
40
39
|
const kernelTools = (0, first_party_tool_universe_1.createProductionFirstPartyToolUniverseV1)({
|
|
40
|
+
include: options.toolNames,
|
|
41
41
|
context: {
|
|
42
42
|
cwd: canonicalCwd,
|
|
43
43
|
config: { name: kernelConfig.name, mode: kernelConfig.mode },
|
|
@@ -50,6 +50,7 @@ function createWorkspaceRuntimeKernelV1(options) {
|
|
|
50
50
|
const kernelMcpAdapter = (0, mcp_1.createFirstPartyMcpAdapterV1)({
|
|
51
51
|
config: (0, mcp_1.loadFirstPartyMcpConfigurationV1)(),
|
|
52
52
|
baseDirectory: canonicalCwd,
|
|
53
|
+
sessionServers: options.sessionMcpServers,
|
|
53
54
|
});
|
|
54
55
|
return new workspace_runtime_kernel_1.WorkspaceRuntimeKernelV1({
|
|
55
56
|
cwd: canonicalCwd,
|
|
@@ -75,6 +76,7 @@ async function createProductUiRuntime(options) {
|
|
|
75
76
|
workspaceRuntimeKernel = createWorkspaceRuntimeKernelV1({
|
|
76
77
|
cwd: canonicalCwd,
|
|
77
78
|
uiRenderer: options.uiRenderer,
|
|
79
|
+
sessionMcpServers: options.sessionMcpServers,
|
|
78
80
|
onSettingsInvalidated: options.onSettingsInvalidated,
|
|
79
81
|
});
|
|
80
82
|
}
|
|
@@ -98,11 +100,14 @@ async function createProductUiRuntime(options) {
|
|
|
98
100
|
const internalDefaultModelSelector = 'gpt-4o';
|
|
99
101
|
const initialProfile = profileFor(config.model) ?? config.modelRegistry?.defaultProfile ?? undefined;
|
|
100
102
|
let defaultModelSelector = config.modelRegistry?.defaultProfile?.id ?? config.model;
|
|
101
|
-
const resolveRuntimeEffort = (session) =>
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
103
|
+
const resolveRuntimeEffort = (session) => {
|
|
104
|
+
const settings = (0, global_config_1.loadGlobalConfig)();
|
|
105
|
+
return (0, effort_1.resolveProfileEffort)(profileFor(session?.model ?? defaultModelSelector) ?? initialProfile, {
|
|
106
|
+
session: session?.effortPreference,
|
|
107
|
+
project: settings.projects?.[cwd]?.defaultEffort,
|
|
108
|
+
global: settings.defaultEffort ?? config.defaultEffort,
|
|
109
|
+
});
|
|
110
|
+
};
|
|
106
111
|
const initialEffort = resolveRuntimeEffort();
|
|
107
112
|
const store = new store_1.Store({
|
|
108
113
|
config,
|
|
@@ -116,19 +121,13 @@ async function createProductUiRuntime(options) {
|
|
|
116
121
|
});
|
|
117
122
|
let llm = null;
|
|
118
123
|
let modelCoordinator;
|
|
119
|
-
const configured = config
|
|
120
|
-
? config.modelRegistry.defaultProfile !== null
|
|
121
|
-
: (0, config_1.isConfigured)(config);
|
|
124
|
+
const configured = (0, config_1.isConfigured)(config);
|
|
122
125
|
if (configured) {
|
|
123
126
|
const defaultProvider = initialProfile
|
|
124
127
|
? config.modelRegistry?.providers.get(initialProfile.provider)
|
|
125
128
|
: null;
|
|
126
129
|
llm = new llm_1.LLMService({
|
|
127
|
-
apiKey: defaultProvider
|
|
128
|
-
? defaultProvider.apiKey.startsWith('$')
|
|
129
|
-
? (process.env[defaultProvider.apiKey.slice(1)] ?? '')
|
|
130
|
-
: defaultProvider.apiKey
|
|
131
|
-
: config.apiKey,
|
|
130
|
+
apiKey: (0, model_client_pool_1.resolveProviderCredential)(defaultProvider?.apiKey ?? config.apiKey).apiKey,
|
|
132
131
|
baseUrl: defaultProvider?.baseUrl ?? config.apiBaseUrl,
|
|
133
132
|
model: initialProfile?.model ?? config.model,
|
|
134
133
|
fallbackModel: config.modelRegistry?.fallbackProfile?.model ?? config.fallbackModel,
|
|
@@ -140,6 +139,9 @@ async function createProductUiRuntime(options) {
|
|
|
140
139
|
llm.resilience = workspaceRuntimeKernel.providerResilience;
|
|
141
140
|
modelCoordinator = new model_coordinator_1.ModelCoordinator();
|
|
142
141
|
if (config.modelRegistry && config.modelClientPool) {
|
|
142
|
+
if (initialProfile) {
|
|
143
|
+
config.modelClientPool.bindModel(llm, config.modelRegistry, initialProfile, initialEffort.requested);
|
|
144
|
+
}
|
|
143
145
|
modelCoordinator.bind(config.modelRegistry, config.modelClientPool);
|
|
144
146
|
modelCoordinator.initModel(initialProfile?.id ?? config.model);
|
|
145
147
|
}
|
|
@@ -152,6 +154,10 @@ async function createProductUiRuntime(options) {
|
|
|
152
154
|
llm,
|
|
153
155
|
outputReserveTokens: llm?.getMaxTokens?.(),
|
|
154
156
|
compactInstructions: (0, global_config_1.getProjectConfig)(cwd).compactInstructions,
|
|
157
|
+
backgroundSummaryTransport: llm
|
|
158
|
+
? () => llm?.captureCompactSummaryTransport(workspaceRuntimeKernel.providerRequestGate)
|
|
159
|
+
: undefined,
|
|
160
|
+
onBackgroundStatus: backgroundCompact => store.setState({ backgroundCompact }),
|
|
155
161
|
getContextCapsule: () => store.getSnapshot().harnessState?.capsule,
|
|
156
162
|
getHarnessState: () => store.getSnapshot().harnessState,
|
|
157
163
|
});
|
|
@@ -159,31 +165,19 @@ async function createProductUiRuntime(options) {
|
|
|
159
165
|
let sessionRunner;
|
|
160
166
|
let settingsRuntimeIdleProbe = () => true;
|
|
161
167
|
let shutdownResult;
|
|
162
|
-
let projectToolConfirmation = config.toolConfirmation;
|
|
163
168
|
const applySessionState = (session, resolvedEffortOverride) => {
|
|
164
169
|
const selector = session?.model ?? defaultModelSelector;
|
|
165
170
|
const profile = profileFor(selector);
|
|
166
|
-
const provider = profile ? config.modelRegistry?.providers.get(profile.provider) : undefined;
|
|
167
171
|
const effort = resolvedEffortOverride ?? resolveRuntimeEffort(session);
|
|
168
|
-
config.toolConfirmation = session?.toolConfirmationOverride ?? projectToolConfirmation;
|
|
169
172
|
if (profile) {
|
|
170
173
|
modelCoordinator?.initModel(profile.id);
|
|
171
|
-
if (
|
|
172
|
-
|
|
174
|
+
if (llm && config.modelClientPool && config.modelRegistry) {
|
|
175
|
+
config.modelClientPool.bindModel(llm, config.modelRegistry, profile, effort.requested);
|
|
173
176
|
}
|
|
174
|
-
llm?.setModel(profile.model);
|
|
175
177
|
}
|
|
176
178
|
else {
|
|
177
179
|
llm?.setModel(selector);
|
|
178
180
|
}
|
|
179
|
-
if (provider) {
|
|
180
|
-
llm?.setEffortContext({
|
|
181
|
-
preference: effort.requested,
|
|
182
|
-
protocol: provider.protocol,
|
|
183
|
-
capability: profile?.reasoningCapability,
|
|
184
|
-
fallbackCapability: config.modelRegistry?.fallbackProfile?.reasoningCapability,
|
|
185
|
-
});
|
|
186
|
-
}
|
|
187
181
|
store.setState({ currentModel: profile?.id ?? selector });
|
|
188
182
|
store.setEffort(effort.requested, effort);
|
|
189
183
|
compactCoordinator.configure({
|
|
@@ -193,6 +187,10 @@ async function createProductUiRuntime(options) {
|
|
|
193
187
|
});
|
|
194
188
|
};
|
|
195
189
|
const setSession = (session) => {
|
|
190
|
+
if (currentSession?.id !== session?.id) {
|
|
191
|
+
compactCoordinator.cancelBackground('session_changed');
|
|
192
|
+
store.setState({ backgroundCompact: undefined });
|
|
193
|
+
}
|
|
196
194
|
applySessionState(session);
|
|
197
195
|
currentSession = session;
|
|
198
196
|
};
|
|
@@ -210,7 +208,7 @@ async function createProductUiRuntime(options) {
|
|
|
210
208
|
defaultModelSelector =
|
|
211
209
|
settingsCoordinator?.describe().sections.defaults.model.effectiveValue ??
|
|
212
210
|
defaultModelSelector;
|
|
213
|
-
const created = (0, session_storage_1.createSession)(cwd, defaultModelSelector);
|
|
211
|
+
const created = (0, session_storage_1.createSession)(cwd, defaultModelSelector, options.sessionSource ? { source: options.sessionSource } : undefined);
|
|
214
212
|
(0, global_config_1.incrementSessionCount)();
|
|
215
213
|
setSession(created);
|
|
216
214
|
return created;
|
|
@@ -249,8 +247,6 @@ async function createProductUiRuntime(options) {
|
|
|
249
247
|
const previousDefaultModel = defaultModelSelector;
|
|
250
248
|
const previousConfigModel = config.model;
|
|
251
249
|
const previousGlobalEffort = config.defaultEffort;
|
|
252
|
-
const previousToolConfirmation = config.toolConfirmation;
|
|
253
|
-
const previousProjectToolConfirmation = projectToolConfirmation;
|
|
254
250
|
const previousEffortField = context.before.sections.defaults.effort;
|
|
255
251
|
const previousResolvedEffort = (0, effort_1.resolveProfileEffort)(profileFor(currentSession?.model ?? previousDefaultModel) ?? initialProfile, {
|
|
256
252
|
session: currentSession?.effortPreference,
|
|
@@ -262,7 +258,6 @@ async function createProductUiRuntime(options) {
|
|
|
262
258
|
});
|
|
263
259
|
const changesDefaultModel = context.operations.some(operation => operation.key === 'defaults.model');
|
|
264
260
|
const changesEffort = context.operations.some(operation => operation.key === 'defaults.effort' || operation.key === 'defaults.globalEffort');
|
|
265
|
-
const changesToolConfirmation = context.operations.some(operation => operation.key === 'permissions.toolConfirmation');
|
|
266
261
|
let restored = false;
|
|
267
262
|
const restore = async () => {
|
|
268
263
|
if (restored)
|
|
@@ -271,14 +266,9 @@ async function createProductUiRuntime(options) {
|
|
|
271
266
|
defaultModelSelector = previousDefaultModel;
|
|
272
267
|
config.model = previousConfigModel;
|
|
273
268
|
config.defaultEffort = previousGlobalEffort;
|
|
274
|
-
projectToolConfirmation = previousProjectToolConfirmation;
|
|
275
|
-
config.toolConfirmation = previousToolConfirmation;
|
|
276
269
|
// Restore the live effort from the pre-write view instead of rereading
|
|
277
270
|
// the still-new project/global bytes during the coordinator rollback.
|
|
278
271
|
applySessionState(currentSession, previousResolvedEffort);
|
|
279
|
-
if (changesToolConfirmation && sessionRunner && currentSession) {
|
|
280
|
-
await sessionRunner.restoreSession().catch(() => undefined);
|
|
281
|
-
}
|
|
282
272
|
};
|
|
283
273
|
try {
|
|
284
274
|
if (changesDefaultModel) {
|
|
@@ -290,16 +280,9 @@ async function createProductUiRuntime(options) {
|
|
|
290
280
|
config.defaultEffort =
|
|
291
281
|
globalEffortOperation.op === 'set' ? globalEffortOperation.value : undefined;
|
|
292
282
|
}
|
|
293
|
-
if (
|
|
294
|
-
projectToolConfirmation =
|
|
295
|
-
context.document.sections.permissions.toolConfirmation.effectiveValue;
|
|
296
|
-
}
|
|
297
|
-
if (changesDefaultModel || changesEffort || changesToolConfirmation) {
|
|
283
|
+
if (changesDefaultModel || changesEffort) {
|
|
298
284
|
applySessionState(currentSession);
|
|
299
285
|
}
|
|
300
|
-
if (changesToolConfirmation && sessionRunner && currentSession) {
|
|
301
|
-
await sessionRunner.restoreSession();
|
|
302
|
-
}
|
|
303
286
|
return restore;
|
|
304
287
|
}
|
|
305
288
|
catch (error) {
|
|
@@ -320,9 +303,6 @@ async function createProductUiRuntime(options) {
|
|
|
320
303
|
});
|
|
321
304
|
const initialSettingsDocument = settingsCoordinator.describe();
|
|
322
305
|
defaultModelSelector = initialSettingsDocument.sections.defaults.model.effectiveValue;
|
|
323
|
-
projectToolConfirmation =
|
|
324
|
-
initialSettingsDocument.sections.permissions.toolConfirmation.effectiveValue;
|
|
325
|
-
config.toolConfirmation = projectToolConfirmation;
|
|
326
306
|
const describeSettings = () => settingsCoordinator.describe({
|
|
327
307
|
currentSession: currentSessionSettings(),
|
|
328
308
|
runtime: { busy: !workspaceRuntimeKernel.runtimeIdle() },
|
|
@@ -355,6 +335,7 @@ async function createProductUiRuntime(options) {
|
|
|
355
335
|
return shutdownResult;
|
|
356
336
|
shutdownResult = (async () => {
|
|
357
337
|
releaseSettingsRuntime?.();
|
|
338
|
+
compactCoordinator.cancelBackground('shutdown');
|
|
358
339
|
try {
|
|
359
340
|
await sessionRunner?.close(options.shutdownReason ?? 'Orion product runtime shutdown');
|
|
360
341
|
if (currentSession) {
|
|
@@ -421,10 +402,18 @@ async function createProductUiRuntime(options) {
|
|
|
421
402
|
modelCoordinator,
|
|
422
403
|
getSession,
|
|
423
404
|
ensureSession,
|
|
424
|
-
projectToolConfirmation: () => projectToolConfirmation,
|
|
425
405
|
applySessionState,
|
|
426
406
|
rebindSessionRuntime,
|
|
427
407
|
runtimeIdle: () => settingsRuntimeIdleProbe(),
|
|
408
|
+
compactForModelSwitch: request => {
|
|
409
|
+
if (!sessionRunner) {
|
|
410
|
+
return Promise.resolve({
|
|
411
|
+
status: 'rejected',
|
|
412
|
+
error: 'The Session runtime is unavailable.',
|
|
413
|
+
});
|
|
414
|
+
}
|
|
415
|
+
return sessionRunner.compactForModelSwitch(request);
|
|
416
|
+
},
|
|
428
417
|
});
|
|
429
418
|
return {
|
|
430
419
|
cwd,
|
|
@@ -436,6 +425,7 @@ async function createProductUiRuntime(options) {
|
|
|
436
425
|
modelCoordinator,
|
|
437
426
|
sessionComposerControls,
|
|
438
427
|
workspaceRuntimeKernel,
|
|
428
|
+
followupQueueStore: followup_queue_store_1.sessionFollowupQueueStore,
|
|
439
429
|
createAgentRunner,
|
|
440
430
|
getHarnessDiagnostics: async () => sessionRunner?.diagnostics(),
|
|
441
431
|
inspectSkills,
|
|
@@ -15,11 +15,13 @@ const token_estimate_1 = require("../utils/token-estimate");
|
|
|
15
15
|
const debug_log_1 = require("../utils/debug-log");
|
|
16
16
|
const paths_1 = require("../product/paths");
|
|
17
17
|
const builtin_tool_provider_1 = require("./builtin-tool-provider");
|
|
18
|
+
const loop_budget_1 = require("./loop-budget");
|
|
18
19
|
const legacy_thread_materializer_1 = require("./legacy-thread-materializer");
|
|
19
20
|
const orion_runtime_v1_1 = require("./orion-runtime-v1");
|
|
20
21
|
const prompts_1 = require("./prompts");
|
|
21
22
|
const canonical_1 = require("./protocol/canonical");
|
|
22
23
|
const plan_review_1 = require("./plan-review");
|
|
24
|
+
const todo_1 = require("../tools/todo");
|
|
23
25
|
const session_history_recovery_1 = require("./session-history-recovery");
|
|
24
26
|
const step_snapshot_1 = require("./step-snapshot");
|
|
25
27
|
const production_1 = require("./subagents/production");
|
|
@@ -45,16 +47,7 @@ function createProductOrionRuntimeV1(options, sessionId, activation) {
|
|
|
45
47
|
}
|
|
46
48
|
const existingProjection = openedStorage.store.loadProjection();
|
|
47
49
|
const hasDurableTurnCommit = Object.values(existingProjection.turns).some(turn => turn.commit);
|
|
48
|
-
const
|
|
49
|
-
const profile = options.config.modelRegistry
|
|
50
|
-
? ((0, model_registry_1.lookupProfile)(options.config.modelRegistry, selectedModel) ??
|
|
51
|
-
options.config.modelRegistry.defaultProfile)
|
|
52
|
-
: undefined;
|
|
53
|
-
const provider = profile
|
|
54
|
-
? options.config.modelRegistry?.providers.get(profile.provider)
|
|
55
|
-
: undefined;
|
|
56
|
-
const modelId = profile?.model ?? options.llm.getModel();
|
|
57
|
-
const contextWindow = profile?.contextWindow ?? 128000;
|
|
50
|
+
const initialModel = resolveProductModel(options);
|
|
58
51
|
// Legacy sidecars are migration seeds only. Once a TurnCommit exists, its
|
|
59
52
|
// TaskContext and Goal state are the sole durable authority on restart.
|
|
60
53
|
const taskState = hasDurableTurnCommit
|
|
@@ -71,15 +64,10 @@ function createProductOrionRuntimeV1(options, sessionId, activation) {
|
|
|
71
64
|
sandboxBackend: 'configured-first-party',
|
|
72
65
|
timeoutMs: 120000,
|
|
73
66
|
});
|
|
74
|
-
const subagents = createProductSubagentCompositionV1(options
|
|
75
|
-
modelId,
|
|
76
|
-
providerId: profile?.provider ?? 'configured-provider',
|
|
77
|
-
protocol: provider?.protocol ?? 'openai-compatible',
|
|
78
|
-
providerProtocol: provider?.protocol,
|
|
79
|
-
contextWindow,
|
|
80
|
-
});
|
|
67
|
+
const subagents = createProductSubagentCompositionV1(options);
|
|
81
68
|
const runtime = (0, orion_runtime_v1_1.createOrionRuntimeV1)({
|
|
82
69
|
modelExecutor: options.llm,
|
|
70
|
+
enableTaskTodos: true,
|
|
83
71
|
toolCatalog: options.toolCatalog,
|
|
84
72
|
toolContext: {
|
|
85
73
|
cwd: options.cwd,
|
|
@@ -91,12 +79,17 @@ function createProductOrionRuntimeV1(options, sessionId, activation) {
|
|
|
91
79
|
store: openedStorage.store,
|
|
92
80
|
},
|
|
93
81
|
projectPath: options.cwd,
|
|
82
|
+
loadImportedHistory: () => legacyHistory(sessionId).filter(message => message.role !== 'system'),
|
|
94
83
|
taskContext: {
|
|
95
84
|
cwd: options.cwd,
|
|
96
|
-
modelId,
|
|
85
|
+
modelId: initialModel.modelId,
|
|
97
86
|
...(taskState ? { state: taskState } : {}),
|
|
98
87
|
},
|
|
99
88
|
...(goalSeed ? { goal: goalSeed } : {}),
|
|
89
|
+
goalPolicy: {
|
|
90
|
+
continuation: options.config.agentLoop?.continuation ?? 'agent',
|
|
91
|
+
defaultBudget: options.config.agentLoop?.goalBudget,
|
|
92
|
+
},
|
|
100
93
|
skills: { providers: [...(options.skillProviders ?? [])] },
|
|
101
94
|
mcp: {
|
|
102
95
|
descriptors: [...(options.mcpDescriptors ?? [])],
|
|
@@ -113,10 +106,7 @@ function createProductOrionRuntimeV1(options, sessionId, activation) {
|
|
|
113
106
|
return capabilityConfiguration({
|
|
114
107
|
options,
|
|
115
108
|
input,
|
|
116
|
-
|
|
117
|
-
contextWindow,
|
|
118
|
-
providerId: profile?.provider ?? 'configured-provider',
|
|
119
|
-
protocol: provider?.protocol ?? 'openai-compatible',
|
|
109
|
+
...promptState.model,
|
|
120
110
|
executionPolicy,
|
|
121
111
|
skillCatalog: promptState.skillCatalog,
|
|
122
112
|
loadedSkills: promptState.loadedSkills,
|
|
@@ -126,7 +116,18 @@ function createProductOrionRuntimeV1(options, sessionId, activation) {
|
|
|
126
116
|
});
|
|
127
117
|
},
|
|
128
118
|
loadBaseMessages: async (store, context, prompts, composition) => {
|
|
129
|
-
const
|
|
119
|
+
const model = resolveProductModel(options);
|
|
120
|
+
if (context.mode === 'build' && !composition.taskContext.hasTaskTodos()) {
|
|
121
|
+
const projection = store.loadProjection();
|
|
122
|
+
const review = projection.planReview;
|
|
123
|
+
if (review?.status === 'approved' && context.input === (0, plan_review_1.planReviewTurnInput)(review)) {
|
|
124
|
+
const plan = (0, plan_review_1.findPlanReceiptForReviewV1)(projection, review).plan;
|
|
125
|
+
const steps = planExecutionChecklist(plan);
|
|
126
|
+
if (steps.length)
|
|
127
|
+
composition.taskContext.updateTaskTodos(steps);
|
|
128
|
+
}
|
|
129
|
+
}
|
|
130
|
+
const assembled = await buildProductMessages(options, sessionId, store, prompts, composition, context.input, context.mode, model.contextWindow);
|
|
130
131
|
promptState = {
|
|
131
132
|
turnId: context.turnId,
|
|
132
133
|
mode: context.mode,
|
|
@@ -135,15 +136,20 @@ function createProductOrionRuntimeV1(options, sessionId, activation) {
|
|
|
135
136
|
skillCatalog: assembled.skillCatalog,
|
|
136
137
|
loadedSkills: assembled.loadedSkills,
|
|
137
138
|
explicitSkillIds: assembled.explicitSkillIds,
|
|
139
|
+
model,
|
|
138
140
|
};
|
|
139
141
|
return assembled.messages;
|
|
140
142
|
},
|
|
141
143
|
loop: {
|
|
144
|
+
resolveLoopBudget: (context, goal) => (0, loop_budget_1.resolveRuntimeLoopBudget)(context.mode === 'goal' ? (goal.state?.objective ?? '') : context.input, options.config),
|
|
142
145
|
...(options.compactCoordinator ? { compactCoordinator: options.compactCoordinator } : {}),
|
|
143
146
|
onContextUsage: usage => options.store.setContextUsage(usage),
|
|
144
147
|
prepareTurnCommit: commit => {
|
|
145
148
|
const active = promptState;
|
|
146
|
-
if (!active ||
|
|
149
|
+
if (!active ||
|
|
150
|
+
active.turnId !== commit.turnId ||
|
|
151
|
+
active.mode !== 'plan' ||
|
|
152
|
+
commit.queryComplete.stats?.finishReason !== 'completed')
|
|
147
153
|
return {};
|
|
148
154
|
const plan = extractDecisionCompletePlan(commit);
|
|
149
155
|
return {
|
|
@@ -158,8 +164,14 @@ function createProductOrionRuntimeV1(options, sessionId, activation) {
|
|
|
158
164
|
onTurnCommitted: (commit, durableCommit) => {
|
|
159
165
|
if (promptState?.turnId === commit.turnId)
|
|
160
166
|
promptState = undefined;
|
|
161
|
-
if (commit.queryComplete.stats)
|
|
162
|
-
options.store.setLastLoopStats(
|
|
167
|
+
if (commit.queryComplete.stats) {
|
|
168
|
+
options.store.setLastLoopStats({
|
|
169
|
+
...commit.queryComplete.stats,
|
|
170
|
+
...(durableCommit.stopDecision
|
|
171
|
+
? { stopDecision: JSON.parse(durableCommit.stopDecision) }
|
|
172
|
+
: {}),
|
|
173
|
+
});
|
|
174
|
+
}
|
|
163
175
|
options.store.setState({
|
|
164
176
|
harnessState: commit.taskContextState,
|
|
165
177
|
conversationHistory: commit.history.map(message => ({ ...message })),
|
|
@@ -170,14 +182,28 @@ function createProductOrionRuntimeV1(options, sessionId, activation) {
|
|
|
170
182
|
const review = (0, plan_review_1.ensurePlanReviewRequestedV1)(runtime.graph.eventStore, planReceipt, options.store.getSnapshot().currentModel);
|
|
171
183
|
projectPlanReceipt(options.store, planReceipt, review.status);
|
|
172
184
|
}
|
|
185
|
+
else {
|
|
186
|
+
const projection = runtime.graph.eventStore.loadProjection();
|
|
187
|
+
const review = projection.planReview;
|
|
188
|
+
const currentPlan = review && review.status !== 'cancelled'
|
|
189
|
+
? (0, plan_review_1.findPlanReceiptForReviewV1)(projection, review).plan
|
|
190
|
+
: null;
|
|
191
|
+
if (options.store.getSnapshot().currentPlan !== currentPlan) {
|
|
192
|
+
options.store.setState({ currentPlan });
|
|
193
|
+
}
|
|
194
|
+
}
|
|
173
195
|
},
|
|
174
196
|
onRuntimeStarted: ({ restoredCommit, eventStore }) => {
|
|
175
197
|
synchronizeSessionThreadReadModel(sessionId, storage.generation, eventStore);
|
|
176
198
|
if (restoredCommit)
|
|
177
199
|
projectRestoredTurnCommit(options.store, restoredCommit);
|
|
178
200
|
const planReceipt = latestDurablePlanReceipt(eventStore);
|
|
179
|
-
if (!planReceipt)
|
|
201
|
+
if (!planReceipt) {
|
|
202
|
+
if (options.store.getSnapshot().currentPlan !== null) {
|
|
203
|
+
options.store.setState({ currentPlan: null });
|
|
204
|
+
}
|
|
180
205
|
return;
|
|
206
|
+
}
|
|
181
207
|
const review = (0, plan_review_1.ensurePlanReviewRequestedV1)(eventStore, planReceipt, options.store.getSnapshot().currentModel);
|
|
182
208
|
projectPlanReceipt(options.store, planReceipt, review.status);
|
|
183
209
|
(0, plan_review_1.recoverResolvedPlanReviewV1)(runtime);
|
|
@@ -240,14 +266,25 @@ function synchronizeSessionThreadReadModel(sessionId, cutoverGeneration, eventSt
|
|
|
240
266
|
(0, debug_log_1.debugError)('product-orion-runtime.sessionReadModel', error, sessionId);
|
|
241
267
|
}
|
|
242
268
|
}
|
|
243
|
-
function
|
|
269
|
+
function resolveProductModel(options) {
|
|
270
|
+
const registry = options.config.modelRegistry;
|
|
271
|
+
const selector = options.store.getSnapshot().currentModel;
|
|
272
|
+
const profile = registry ? ((0, model_registry_1.lookupProfile)(registry, selector) ?? registry.defaultProfile) : null;
|
|
273
|
+
const provider = profile ? registry?.providers.get(profile.provider) : undefined;
|
|
274
|
+
return {
|
|
275
|
+
profile,
|
|
276
|
+
selector,
|
|
277
|
+
modelId: profile?.model ?? options.llm.getModel(),
|
|
278
|
+
providerId: provider?.id ?? 'configured-provider',
|
|
279
|
+
protocol: provider?.protocol ?? 'openai-compatible',
|
|
280
|
+
providerProtocol: provider?.protocol,
|
|
281
|
+
contextWindow: profile?.resolvedContextWindow ?? options.llm.getContextWindow?.() ?? 128000,
|
|
282
|
+
maxOutputTokens: profile?.resolvedMaxOutputTokens ?? options.llm.getMaxTokens?.(),
|
|
283
|
+
};
|
|
284
|
+
}
|
|
285
|
+
function createProductSubagentCompositionV1(options) {
|
|
244
286
|
const config = (0, policy_1.clampSubagentConfig)(options.config.subagents ?? types_1.DEFAULT_SUBAGENT_CONFIG);
|
|
245
|
-
|
|
246
|
-
const selectedProfile = options.config.modelRegistry
|
|
247
|
-
? (0, model_registry_1.lookupProfile)(options.config.modelRegistry, selectedProfileId)
|
|
248
|
-
: null;
|
|
249
|
-
const rootLlmConfig = (0, runtime_integration_1.deriveRootLlmConfig)(options.config, selectedProfileId);
|
|
250
|
-
if (config.mode === 'off' || !rootLlmConfig.apiKey)
|
|
287
|
+
if (config.mode === 'off')
|
|
251
288
|
return undefined;
|
|
252
289
|
const allowedNames = new Set(presets_1.READ_ONLY_INVESTIGATION_TOOLS);
|
|
253
290
|
const childTools = options.toolCatalog.entries
|
|
@@ -284,6 +321,10 @@ function createProductSubagentCompositionV1(options, model) {
|
|
|
284
321
|
createTurn: async (input) => {
|
|
285
322
|
if (input.abortSignal.aborted)
|
|
286
323
|
return null;
|
|
324
|
+
const model = resolveProductModel(options);
|
|
325
|
+
const rootLlmConfig = (0, runtime_integration_1.deriveRootLlmConfig)(options.config, model.selector);
|
|
326
|
+
if (!rootLlmConfig.apiKey)
|
|
327
|
+
return null;
|
|
287
328
|
const parentForkSource = new parent_step_fork_1.ParentThreadStepForkSourceV1({
|
|
288
329
|
store: input.store,
|
|
289
330
|
flush: input.flush,
|
|
@@ -304,7 +345,7 @@ function createProductSubagentCompositionV1(options, model) {
|
|
|
304
345
|
createModelExecutor: childInput => {
|
|
305
346
|
const executor = options.createSubagentModelExecutor
|
|
306
347
|
? options.createSubagentModelExecutor(childInput)
|
|
307
|
-
: createProductChildModelExecutor(options, rootLlmConfig, model
|
|
348
|
+
: createProductChildModelExecutor(options, rootLlmConfig, model);
|
|
308
349
|
if (executor === options.llm || issuedModels.has(executor)) {
|
|
309
350
|
throw new Error('Subagent model factory must return a distinct LLMService for every child request.');
|
|
310
351
|
}
|
|
@@ -318,6 +359,9 @@ function createProductSubagentCompositionV1(options, model) {
|
|
|
318
359
|
modelId: context.modelId,
|
|
319
360
|
protocol: model.protocol,
|
|
320
361
|
contextWindow: model.contextWindow,
|
|
362
|
+
...(model.maxOutputTokens === undefined
|
|
363
|
+
? {}
|
|
364
|
+
: { maxOutputTokens: model.maxOutputTokens }),
|
|
321
365
|
},
|
|
322
366
|
executionPolicy: childExecutionPolicy,
|
|
323
367
|
environment: {
|
|
@@ -406,13 +450,17 @@ function createProductSubagentRolePolicies(options, config) {
|
|
|
406
450
|
]);
|
|
407
451
|
return Object.freeze(Object.fromEntries(entries));
|
|
408
452
|
}
|
|
409
|
-
function createProductChildModelExecutor(options, rootConfig,
|
|
453
|
+
function createProductChildModelExecutor(options, rootConfig, model) {
|
|
410
454
|
const executor = new llm_1.LLMService({
|
|
411
455
|
...(0, production_1.createChildLlmConfig)(rootConfig),
|
|
412
|
-
providerProtocol,
|
|
413
|
-
reasoningCapability,
|
|
414
|
-
fallbackReasoningCapability:
|
|
456
|
+
providerProtocol: model.providerProtocol,
|
|
457
|
+
reasoningCapability: model.profile?.reasoningCapability,
|
|
458
|
+
fallbackReasoningCapability: rootConfig.fallbackModel
|
|
459
|
+
? options.config.modelRegistry?.fallbackProfile?.reasoningCapability
|
|
460
|
+
: undefined,
|
|
415
461
|
effortPreference: options.config.defaultEffort,
|
|
462
|
+
maxOutputTokens: model.profile?.resolvedMaxOutputTokens,
|
|
463
|
+
contextWindow: model.profile?.resolvedContextWindow,
|
|
416
464
|
});
|
|
417
465
|
executor.resilience = options.llm.resilience;
|
|
418
466
|
return executor;
|
|
@@ -427,6 +475,7 @@ function capabilityConfiguration(input) {
|
|
|
427
475
|
modelId: input.modelId,
|
|
428
476
|
protocol: input.protocol,
|
|
429
477
|
contextWindow: input.contextWindow,
|
|
478
|
+
...(input.maxOutputTokens === undefined ? {} : { maxOutputTokens: input.maxOutputTokens }),
|
|
430
479
|
},
|
|
431
480
|
executionPolicy: input.executionPolicy,
|
|
432
481
|
environment: {
|
|
@@ -486,10 +535,9 @@ function loadProductGoalSeed(projectPath, sessionId) {
|
|
|
486
535
|
throw new Error(`Cannot start Goal runtime: ${loaded.message}`);
|
|
487
536
|
}
|
|
488
537
|
const legacy = loaded.value;
|
|
489
|
-
const status = legacy.status === '
|
|
538
|
+
const status = legacy.status === 'complete' ? 'completed' : legacy.status;
|
|
490
539
|
const budget = {
|
|
491
|
-
maxTokens: legacy.tokenBudget
|
|
492
|
-
maxElapsedMs: Number.MAX_SAFE_INTEGER,
|
|
540
|
+
...(legacy.tokenBudget == null ? {} : { maxTokens: legacy.tokenBudget }),
|
|
493
541
|
};
|
|
494
542
|
const content = {
|
|
495
543
|
version: 2,
|
|
@@ -527,20 +575,24 @@ function buildGoalRuntimeContext(state) {
|
|
|
527
575
|
`- Status: ${state.status}`,
|
|
528
576
|
`- Generation: ${state.generation}`,
|
|
529
577
|
`- Continuations: ${state.continuationCount}`,
|
|
530
|
-
`- Tokens: ${state.tokensUsed}/${state.budget.maxTokens}`,
|
|
531
|
-
`- Elapsed ms: ${state.elapsedMs}/${state.budget.maxElapsedMs}`,
|
|
578
|
+
`- Tokens: ${state.tokensUsed}/${state.budget.maxTokens ?? 'unlimited'}`,
|
|
579
|
+
`- Elapsed ms: ${state.elapsedMs}/${state.budget.maxElapsedMs ?? 'unlimited'}`,
|
|
532
580
|
state.status === 'active'
|
|
533
581
|
? '- Continue autonomously; only TaskContext may verify completion.'
|
|
534
582
|
: '- Do not autonomously continue this Goal unless the user explicitly resumes it.',
|
|
535
583
|
].join('\n');
|
|
536
584
|
}
|
|
537
585
|
async function buildProductMessages(options, sessionId, eventStore, prompts, composition, input, mode, contextWindow) {
|
|
538
|
-
const
|
|
586
|
+
const projection = eventStore.loadProjection();
|
|
587
|
+
const durable = latestDurableHistory(projection);
|
|
539
588
|
const history = durable ?? legacyHistory(sessionId);
|
|
540
589
|
const withoutOldSystem = history.filter(message => message.role !== 'system');
|
|
541
590
|
const snapshot = options.store.getSnapshot();
|
|
542
|
-
const goalContent = buildGoalRuntimeContext(composition.goal.state);
|
|
543
|
-
const
|
|
591
|
+
const goalContent = mode === 'goal' ? buildGoalRuntimeContext(composition.goal.state) : undefined;
|
|
592
|
+
const review = projection.planReview;
|
|
593
|
+
const planReceipt = mode !== 'plan' && review?.status === 'approved'
|
|
594
|
+
? (0, plan_review_1.findPlanReceiptForReviewV1)(projection, review)
|
|
595
|
+
: undefined;
|
|
544
596
|
const memory = (0, prompt_context_1.buildMemoryPromptContext)(input, options.cwd).content;
|
|
545
597
|
const skillCatalog = await composition.skills.observe({ id: `project:${(0, canonical_1.digestRuntimeValue)(options.cwd)}` }, undefined);
|
|
546
598
|
const skillSelection = await loadSelectedSkills(input, skillCatalog, composition, createProductAuthority(options, mode));
|
|
@@ -551,7 +603,6 @@ async function buildProductMessages(options, sessionId, eventStore, prompts, com
|
|
|
551
603
|
tools: options.toolCatalog.entries
|
|
552
604
|
.filter(entry => entry.candidate.tier === 'core')
|
|
553
605
|
.map(entry => entry.tool),
|
|
554
|
-
planMode: mode === 'plan',
|
|
555
606
|
agentMode: mode === 'goal'
|
|
556
607
|
? snapshot.agentMode
|
|
557
608
|
: mode === 'build'
|
|
@@ -724,7 +775,7 @@ function productPromptSections(input) {
|
|
|
724
775
|
`Receipt: ${input.plan.digest}`,
|
|
725
776
|
`Planning turn: ${input.plan.turnId}`,
|
|
726
777
|
`Execution mode: ${input.plan.returnMode.toUpperCase()}`,
|
|
727
|
-
'
|
|
778
|
+
'When the current request continues this approved plan, use the recorded evidence and remaining steps. Do not repeat completed work.',
|
|
728
779
|
'',
|
|
729
780
|
input.plan.plan,
|
|
730
781
|
].join('\n')
|
|
@@ -748,8 +799,8 @@ function productPromptSections(input) {
|
|
|
748
799
|
],
|
|
749
800
|
};
|
|
750
801
|
}
|
|
751
|
-
function latestDurableHistory(
|
|
752
|
-
const commits = Object.values(
|
|
802
|
+
function latestDurableHistory(projection) {
|
|
803
|
+
const commits = Object.values(projection.turns)
|
|
753
804
|
.map(turn => turn.commit)
|
|
754
805
|
.filter((commit) => Boolean(commit))
|
|
755
806
|
.sort((left, right) => left.seq - right.seq);
|
|
@@ -781,14 +832,17 @@ function projectRestoredTurnCommit(store, commit) {
|
|
|
781
832
|
});
|
|
782
833
|
}
|
|
783
834
|
function latestDurablePlanReceipt(store) {
|
|
784
|
-
const
|
|
835
|
+
const commits = Object.values(store.loadProjection().turns)
|
|
836
|
+
.filter(turn => turn.mode === 'plan')
|
|
785
837
|
.map(turn => turn.commit)
|
|
786
838
|
.filter((commit) => Boolean(commit))
|
|
787
|
-
.sort((left, right) =>
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
839
|
+
.sort((left, right) => right.seq - left.seq);
|
|
840
|
+
for (const commit of commits) {
|
|
841
|
+
const receipt = planReceiptFromCommit((0, turn_commit_1.parseTurnCommitV1)(commit.receipt));
|
|
842
|
+
if (receipt)
|
|
843
|
+
return receipt;
|
|
844
|
+
}
|
|
845
|
+
return undefined;
|
|
792
846
|
}
|
|
793
847
|
function planReceiptFromCommit(commit) {
|
|
794
848
|
if (!commit.planReceipt)
|
|
@@ -811,6 +865,23 @@ function extractDecisionCompletePlan(commit) {
|
|
|
811
865
|
}
|
|
812
866
|
return plan;
|
|
813
867
|
}
|
|
868
|
+
/** Convert the explicitly reviewed checklist into the same steps used by todo_write. */
|
|
869
|
+
function planExecutionChecklist(plan) {
|
|
870
|
+
const sections = plan.split(/^#{1,6}[ \t]+/mu);
|
|
871
|
+
const checklist = sections.find(section => /^(?:Execution checklist|执行清单)[ \t]*\r?\n/iu.test(section));
|
|
872
|
+
if (!checklist)
|
|
873
|
+
return [];
|
|
874
|
+
const contents = Array.from(checklist.matchAll(/^[ \t]*[-*][ \t]+\[ \][ \t]+(.+?)[ \t]*$/gmu), match => match[1].replace(/\s+/gu, ' ').trim());
|
|
875
|
+
if (contents.length > todo_1.MAX_TODOS ||
|
|
876
|
+
new Set(contents).size !== contents.length ||
|
|
877
|
+
contents.some(step => !step || step.length > todo_1.MAX_TODO_TEXT))
|
|
878
|
+
return [];
|
|
879
|
+
return contents.map((content, index) => ({
|
|
880
|
+
content,
|
|
881
|
+
activeForm: content,
|
|
882
|
+
status: index === 0 ? 'in_progress' : 'pending',
|
|
883
|
+
}));
|
|
884
|
+
}
|
|
814
885
|
function createPlanStopDecision(commit, promptReceiptDigest) {
|
|
815
886
|
const stats = commit.queryComplete.stats;
|
|
816
887
|
const completion = commit.taskContextCompletion;
|
|
@@ -880,7 +951,7 @@ function projectPlanReceipt(store, receipt, reviewStatus) {
|
|
|
880
951
|
agentMode,
|
|
881
952
|
planMode: agentMode === 'plan',
|
|
882
953
|
planReturnMode: receipt.returnMode === 'auto' ? 'auto' : 'interactive',
|
|
883
|
-
currentPlan: receipt.plan,
|
|
954
|
+
currentPlan: reviewStatus === 'cancelled' ? null : receipt.plan,
|
|
884
955
|
});
|
|
885
956
|
}
|
|
886
957
|
function legacyHistory(sessionId) {
|