@orion-agents/orion-code 0.3.65 → 0.4.3
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 +128 -2
- package/README.md +78 -361
- package/README.zh-CN.md +71 -263
- package/bin/orion +4 -1
- package/dist/acp/session-updates.d.ts +34 -0
- package/dist/acp/session-updates.js +162 -0
- package/dist/acp/sessions.d.ts +32 -0
- package/dist/acp/sessions.js +315 -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 +5 -1
- package/dist/commands/diagnostic-command-handlers.js +20 -6
- 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 +0 -18
- 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/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/framework/loop-budget-contract.d.ts +7 -2
- package/dist/framework/loop-budget-contract.js +4 -1
- package/dist/framework/loop-progress.d.ts +22 -0
- package/dist/framework/loop-progress.js +79 -0
- package/dist/framework/prompt.d.ts +0 -2
- package/dist/framework/prompt.js +9 -27
- package/dist/framework/query.d.ts +27 -20
- package/dist/framework/query.js +453 -153
- 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 +31 -12
- package/dist/harness/context-harness.js +491 -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/intent.js +21 -0
- package/dist/harness/ledger.d.ts +6 -11
- package/dist/harness/ledger.js +39 -9
- package/dist/harness/progress-controller.d.ts +12 -7
- package/dist/harness/progress-controller.js +66 -21
- package/dist/harness/state.js +9 -1
- package/dist/harness/task-checklist.d.ts +16 -0
- package/dist/harness/task-checklist.js +95 -0
- package/dist/harness/types.d.ts +73 -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 +38 -0
- package/dist/print-ui/event-stream.js +187 -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 +11 -2
- package/dist/runtime/agent-loop.js +165 -25
- package/dist/runtime/agent-runtime-controller.d.ts +13 -3
- package/dist/runtime/agent-runtime-controller.js +347 -183
- 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 +11 -1
- package/dist/runtime/goal-lifecycle-v2.js +85 -15
- package/dist/runtime/goal-runtime-coordinator.d.ts +10 -1
- package/dist/runtime/goal-runtime-coordinator.js +81 -24
- package/dist/runtime/loop-budget.js +7 -5
- 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 +135 -39
- 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 +128 -52
- package/dist/runtime/release-receipts.d.ts +24 -124
- package/dist/runtime/release-receipts.js +129 -683
- 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 +351 -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 +1 -0
- package/dist/runtime/subagents/policy.js +0 -1
- package/dist/runtime/subagents/production.js +1 -1
- 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 +342 -0
- package/dist/runtime/task-context-service.d.ts +16 -10
- package/dist/runtime/task-context-service.js +35 -4
- package/dist/runtime/thread-admission.d.ts +1 -1
- package/dist/runtime/thread-admission.js +12 -6
- 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 +7 -0
- package/dist/runtime/thread-runtime.js +43 -0
- 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 +88 -11
- package/dist/runtime/tool-gateway.d.ts +7 -0
- package/dist/runtime/tool-gateway.js +20 -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 +12 -0
- package/dist/runtime/ui-view-model.d.ts +6 -5
- package/dist/runtime/ui-view-model.js +33 -19
- package/dist/runtime/workspace-runtime-kernel.js +0 -1
- 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 +30 -45
- 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 -56
- package/dist/services/global-config.js +213 -183
- package/dist/services/llm.d.ts +40 -4
- package/dist/services/llm.js +164 -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 +7 -0
- package/dist/services/provider-diagnostics.js +9 -10
- 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 +2 -0
- package/dist/tools/core/write-file.js +5 -0
- 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 +76 -31
- 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 +22 -27
- 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 +562 -0
- package/docs/orion.example.yaml +42 -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-iBYj9ZRf.js +0 -1
- package/dist/web-client/assets/GitPanel-D33R_bZr.js +0 -4
- package/dist/web-client/assets/ReviewPanel-C_0upsDk.js +0 -6
- package/dist/web-client/assets/TerminalPanel-C7A8dMNf.js +0 -23
- package/dist/web-client/assets/TerminalPanel-DLuoa74B.css +0 -1
- package/dist/web-client/assets/index-BaOxrwGB.css +0 -1
- package/dist/web-client/assets/index-CqCgJ2ov.js +0 -20
- package/dist/web-client/assets/useAutoNotice-C1qM-_Sg.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,14 @@ 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 goal_runtime_coordinator_1 = require("./goal-runtime-coordinator");
|
|
19
|
+
const loop_budget_1 = require("./loop-budget");
|
|
18
20
|
const legacy_thread_materializer_1 = require("./legacy-thread-materializer");
|
|
19
21
|
const orion_runtime_v1_1 = require("./orion-runtime-v1");
|
|
20
22
|
const prompts_1 = require("./prompts");
|
|
21
23
|
const canonical_1 = require("./protocol/canonical");
|
|
22
24
|
const plan_review_1 = require("./plan-review");
|
|
25
|
+
const todo_1 = require("../tools/todo");
|
|
23
26
|
const session_history_recovery_1 = require("./session-history-recovery");
|
|
24
27
|
const step_snapshot_1 = require("./step-snapshot");
|
|
25
28
|
const production_1 = require("./subagents/production");
|
|
@@ -45,16 +48,7 @@ function createProductOrionRuntimeV1(options, sessionId, activation) {
|
|
|
45
48
|
}
|
|
46
49
|
const existingProjection = openedStorage.store.loadProjection();
|
|
47
50
|
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;
|
|
51
|
+
const initialModel = resolveProductModel(options);
|
|
58
52
|
// Legacy sidecars are migration seeds only. Once a TurnCommit exists, its
|
|
59
53
|
// TaskContext and Goal state are the sole durable authority on restart.
|
|
60
54
|
const taskState = hasDurableTurnCommit
|
|
@@ -71,15 +65,10 @@ function createProductOrionRuntimeV1(options, sessionId, activation) {
|
|
|
71
65
|
sandboxBackend: 'configured-first-party',
|
|
72
66
|
timeoutMs: 120000,
|
|
73
67
|
});
|
|
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
|
-
});
|
|
68
|
+
const subagents = createProductSubagentCompositionV1(options);
|
|
81
69
|
const runtime = (0, orion_runtime_v1_1.createOrionRuntimeV1)({
|
|
82
70
|
modelExecutor: options.llm,
|
|
71
|
+
enableTaskTodos: true,
|
|
83
72
|
toolCatalog: options.toolCatalog,
|
|
84
73
|
toolContext: {
|
|
85
74
|
cwd: options.cwd,
|
|
@@ -91,12 +80,20 @@ function createProductOrionRuntimeV1(options, sessionId, activation) {
|
|
|
91
80
|
store: openedStorage.store,
|
|
92
81
|
},
|
|
93
82
|
projectPath: options.cwd,
|
|
83
|
+
loadImportedHistory: () => legacyHistory(sessionId).filter(message => message.role !== 'system'),
|
|
94
84
|
taskContext: {
|
|
95
85
|
cwd: options.cwd,
|
|
96
|
-
modelId,
|
|
86
|
+
modelId: initialModel.modelId,
|
|
97
87
|
...(taskState ? { state: taskState } : {}),
|
|
98
88
|
},
|
|
99
89
|
...(goalSeed ? { goal: goalSeed } : {}),
|
|
90
|
+
goalPolicy: {
|
|
91
|
+
continuation: options.config.agentLoop?.continuation ?? 'agent',
|
|
92
|
+
defaultBudget: {
|
|
93
|
+
...goal_runtime_coordinator_1.DEFAULT_GOAL_RUNTIME_BUDGET_V2,
|
|
94
|
+
...options.config.agentLoop?.goalBudget,
|
|
95
|
+
},
|
|
96
|
+
},
|
|
100
97
|
skills: { providers: [...(options.skillProviders ?? [])] },
|
|
101
98
|
mcp: {
|
|
102
99
|
descriptors: [...(options.mcpDescriptors ?? [])],
|
|
@@ -113,10 +110,7 @@ function createProductOrionRuntimeV1(options, sessionId, activation) {
|
|
|
113
110
|
return capabilityConfiguration({
|
|
114
111
|
options,
|
|
115
112
|
input,
|
|
116
|
-
|
|
117
|
-
contextWindow,
|
|
118
|
-
providerId: profile?.provider ?? 'configured-provider',
|
|
119
|
-
protocol: provider?.protocol ?? 'openai-compatible',
|
|
113
|
+
...promptState.model,
|
|
120
114
|
executionPolicy,
|
|
121
115
|
skillCatalog: promptState.skillCatalog,
|
|
122
116
|
loadedSkills: promptState.loadedSkills,
|
|
@@ -126,7 +120,18 @@ function createProductOrionRuntimeV1(options, sessionId, activation) {
|
|
|
126
120
|
});
|
|
127
121
|
},
|
|
128
122
|
loadBaseMessages: async (store, context, prompts, composition) => {
|
|
129
|
-
const
|
|
123
|
+
const model = resolveProductModel(options);
|
|
124
|
+
if (context.mode === 'build' && !composition.taskContext.hasTaskTodos()) {
|
|
125
|
+
const projection = store.loadProjection();
|
|
126
|
+
const review = projection.planReview;
|
|
127
|
+
if (review?.status === 'approved' && context.input === (0, plan_review_1.planReviewTurnInput)(review)) {
|
|
128
|
+
const plan = (0, plan_review_1.findPlanReceiptForReviewV1)(projection, review).plan;
|
|
129
|
+
const steps = planExecutionChecklist(plan);
|
|
130
|
+
if (steps.length)
|
|
131
|
+
composition.taskContext.updateTaskTodos(steps);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
const assembled = await buildProductMessages(options, sessionId, store, prompts, composition, context.input, context.mode, model.contextWindow);
|
|
130
135
|
promptState = {
|
|
131
136
|
turnId: context.turnId,
|
|
132
137
|
mode: context.mode,
|
|
@@ -135,15 +140,20 @@ function createProductOrionRuntimeV1(options, sessionId, activation) {
|
|
|
135
140
|
skillCatalog: assembled.skillCatalog,
|
|
136
141
|
loadedSkills: assembled.loadedSkills,
|
|
137
142
|
explicitSkillIds: assembled.explicitSkillIds,
|
|
143
|
+
model,
|
|
138
144
|
};
|
|
139
145
|
return assembled.messages;
|
|
140
146
|
},
|
|
141
147
|
loop: {
|
|
148
|
+
resolveLoopBudget: (context, goal) => (0, loop_budget_1.resolveRuntimeLoopBudget)(context.mode === 'goal' ? (goal.state?.objective ?? '') : context.input, options.config),
|
|
142
149
|
...(options.compactCoordinator ? { compactCoordinator: options.compactCoordinator } : {}),
|
|
143
150
|
onContextUsage: usage => options.store.setContextUsage(usage),
|
|
144
151
|
prepareTurnCommit: commit => {
|
|
145
152
|
const active = promptState;
|
|
146
|
-
if (!active ||
|
|
153
|
+
if (!active ||
|
|
154
|
+
active.turnId !== commit.turnId ||
|
|
155
|
+
active.mode !== 'plan' ||
|
|
156
|
+
commit.queryComplete.stats?.finishReason !== 'completed')
|
|
147
157
|
return {};
|
|
148
158
|
const plan = extractDecisionCompletePlan(commit);
|
|
149
159
|
return {
|
|
@@ -158,8 +168,14 @@ function createProductOrionRuntimeV1(options, sessionId, activation) {
|
|
|
158
168
|
onTurnCommitted: (commit, durableCommit) => {
|
|
159
169
|
if (promptState?.turnId === commit.turnId)
|
|
160
170
|
promptState = undefined;
|
|
161
|
-
if (commit.queryComplete.stats)
|
|
162
|
-
options.store.setLastLoopStats(
|
|
171
|
+
if (commit.queryComplete.stats) {
|
|
172
|
+
options.store.setLastLoopStats({
|
|
173
|
+
...commit.queryComplete.stats,
|
|
174
|
+
...(durableCommit.stopDecision
|
|
175
|
+
? { stopDecision: JSON.parse(durableCommit.stopDecision) }
|
|
176
|
+
: {}),
|
|
177
|
+
});
|
|
178
|
+
}
|
|
163
179
|
options.store.setState({
|
|
164
180
|
harnessState: commit.taskContextState,
|
|
165
181
|
conversationHistory: commit.history.map(message => ({ ...message })),
|
|
@@ -170,14 +186,28 @@ function createProductOrionRuntimeV1(options, sessionId, activation) {
|
|
|
170
186
|
const review = (0, plan_review_1.ensurePlanReviewRequestedV1)(runtime.graph.eventStore, planReceipt, options.store.getSnapshot().currentModel);
|
|
171
187
|
projectPlanReceipt(options.store, planReceipt, review.status);
|
|
172
188
|
}
|
|
189
|
+
else {
|
|
190
|
+
const projection = runtime.graph.eventStore.loadProjection();
|
|
191
|
+
const review = projection.planReview;
|
|
192
|
+
const currentPlan = review && review.status !== 'cancelled'
|
|
193
|
+
? (0, plan_review_1.findPlanReceiptForReviewV1)(projection, review).plan
|
|
194
|
+
: null;
|
|
195
|
+
if (options.store.getSnapshot().currentPlan !== currentPlan) {
|
|
196
|
+
options.store.setState({ currentPlan });
|
|
197
|
+
}
|
|
198
|
+
}
|
|
173
199
|
},
|
|
174
200
|
onRuntimeStarted: ({ restoredCommit, eventStore }) => {
|
|
175
201
|
synchronizeSessionThreadReadModel(sessionId, storage.generation, eventStore);
|
|
176
202
|
if (restoredCommit)
|
|
177
203
|
projectRestoredTurnCommit(options.store, restoredCommit);
|
|
178
204
|
const planReceipt = latestDurablePlanReceipt(eventStore);
|
|
179
|
-
if (!planReceipt)
|
|
205
|
+
if (!planReceipt) {
|
|
206
|
+
if (options.store.getSnapshot().currentPlan !== null) {
|
|
207
|
+
options.store.setState({ currentPlan: null });
|
|
208
|
+
}
|
|
180
209
|
return;
|
|
210
|
+
}
|
|
181
211
|
const review = (0, plan_review_1.ensurePlanReviewRequestedV1)(eventStore, planReceipt, options.store.getSnapshot().currentModel);
|
|
182
212
|
projectPlanReceipt(options.store, planReceipt, review.status);
|
|
183
213
|
(0, plan_review_1.recoverResolvedPlanReviewV1)(runtime);
|
|
@@ -240,14 +270,25 @@ function synchronizeSessionThreadReadModel(sessionId, cutoverGeneration, eventSt
|
|
|
240
270
|
(0, debug_log_1.debugError)('product-orion-runtime.sessionReadModel', error, sessionId);
|
|
241
271
|
}
|
|
242
272
|
}
|
|
243
|
-
function
|
|
273
|
+
function resolveProductModel(options) {
|
|
274
|
+
const registry = options.config.modelRegistry;
|
|
275
|
+
const selector = options.store.getSnapshot().currentModel;
|
|
276
|
+
const profile = registry ? ((0, model_registry_1.lookupProfile)(registry, selector) ?? registry.defaultProfile) : null;
|
|
277
|
+
const provider = profile ? registry?.providers.get(profile.provider) : undefined;
|
|
278
|
+
return {
|
|
279
|
+
profile,
|
|
280
|
+
selector,
|
|
281
|
+
modelId: profile?.model ?? options.llm.getModel(),
|
|
282
|
+
providerId: provider?.id ?? 'configured-provider',
|
|
283
|
+
protocol: provider?.protocol ?? 'openai-compatible',
|
|
284
|
+
providerProtocol: provider?.protocol,
|
|
285
|
+
contextWindow: profile?.resolvedContextWindow ?? options.llm.getContextWindow?.() ?? 128000,
|
|
286
|
+
maxOutputTokens: profile?.resolvedMaxOutputTokens ?? options.llm.getMaxTokens?.(),
|
|
287
|
+
};
|
|
288
|
+
}
|
|
289
|
+
function createProductSubagentCompositionV1(options) {
|
|
244
290
|
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)
|
|
291
|
+
if (config.mode === 'off')
|
|
251
292
|
return undefined;
|
|
252
293
|
const allowedNames = new Set(presets_1.READ_ONLY_INVESTIGATION_TOOLS);
|
|
253
294
|
const childTools = options.toolCatalog.entries
|
|
@@ -284,6 +325,10 @@ function createProductSubagentCompositionV1(options, model) {
|
|
|
284
325
|
createTurn: async (input) => {
|
|
285
326
|
if (input.abortSignal.aborted)
|
|
286
327
|
return null;
|
|
328
|
+
const model = resolveProductModel(options);
|
|
329
|
+
const rootLlmConfig = (0, runtime_integration_1.deriveRootLlmConfig)(options.config, model.selector);
|
|
330
|
+
if (!rootLlmConfig.apiKey)
|
|
331
|
+
return null;
|
|
287
332
|
const parentForkSource = new parent_step_fork_1.ParentThreadStepForkSourceV1({
|
|
288
333
|
store: input.store,
|
|
289
334
|
flush: input.flush,
|
|
@@ -304,7 +349,7 @@ function createProductSubagentCompositionV1(options, model) {
|
|
|
304
349
|
createModelExecutor: childInput => {
|
|
305
350
|
const executor = options.createSubagentModelExecutor
|
|
306
351
|
? options.createSubagentModelExecutor(childInput)
|
|
307
|
-
: createProductChildModelExecutor(options, rootLlmConfig, model
|
|
352
|
+
: createProductChildModelExecutor(options, rootLlmConfig, model);
|
|
308
353
|
if (executor === options.llm || issuedModels.has(executor)) {
|
|
309
354
|
throw new Error('Subagent model factory must return a distinct LLMService for every child request.');
|
|
310
355
|
}
|
|
@@ -318,6 +363,9 @@ function createProductSubagentCompositionV1(options, model) {
|
|
|
318
363
|
modelId: context.modelId,
|
|
319
364
|
protocol: model.protocol,
|
|
320
365
|
contextWindow: model.contextWindow,
|
|
366
|
+
...(model.maxOutputTokens === undefined
|
|
367
|
+
? {}
|
|
368
|
+
: { maxOutputTokens: model.maxOutputTokens }),
|
|
321
369
|
},
|
|
322
370
|
executionPolicy: childExecutionPolicy,
|
|
323
371
|
environment: {
|
|
@@ -406,13 +454,17 @@ function createProductSubagentRolePolicies(options, config) {
|
|
|
406
454
|
]);
|
|
407
455
|
return Object.freeze(Object.fromEntries(entries));
|
|
408
456
|
}
|
|
409
|
-
function createProductChildModelExecutor(options, rootConfig,
|
|
457
|
+
function createProductChildModelExecutor(options, rootConfig, model) {
|
|
410
458
|
const executor = new llm_1.LLMService({
|
|
411
459
|
...(0, production_1.createChildLlmConfig)(rootConfig),
|
|
412
|
-
providerProtocol,
|
|
413
|
-
reasoningCapability,
|
|
414
|
-
fallbackReasoningCapability:
|
|
460
|
+
providerProtocol: model.providerProtocol,
|
|
461
|
+
reasoningCapability: model.profile?.reasoningCapability,
|
|
462
|
+
fallbackReasoningCapability: rootConfig.fallbackModel
|
|
463
|
+
? options.config.modelRegistry?.fallbackProfile?.reasoningCapability
|
|
464
|
+
: undefined,
|
|
415
465
|
effortPreference: options.config.defaultEffort,
|
|
466
|
+
maxOutputTokens: model.profile?.resolvedMaxOutputTokens,
|
|
467
|
+
contextWindow: model.profile?.resolvedContextWindow,
|
|
416
468
|
});
|
|
417
469
|
executor.resilience = options.llm.resilience;
|
|
418
470
|
return executor;
|
|
@@ -427,6 +479,7 @@ function capabilityConfiguration(input) {
|
|
|
427
479
|
modelId: input.modelId,
|
|
428
480
|
protocol: input.protocol,
|
|
429
481
|
contextWindow: input.contextWindow,
|
|
482
|
+
...(input.maxOutputTokens === undefined ? {} : { maxOutputTokens: input.maxOutputTokens }),
|
|
430
483
|
},
|
|
431
484
|
executionPolicy: input.executionPolicy,
|
|
432
485
|
environment: {
|
|
@@ -535,12 +588,16 @@ function buildGoalRuntimeContext(state) {
|
|
|
535
588
|
].join('\n');
|
|
536
589
|
}
|
|
537
590
|
async function buildProductMessages(options, sessionId, eventStore, prompts, composition, input, mode, contextWindow) {
|
|
538
|
-
const
|
|
591
|
+
const projection = eventStore.loadProjection();
|
|
592
|
+
const durable = latestDurableHistory(projection);
|
|
539
593
|
const history = durable ?? legacyHistory(sessionId);
|
|
540
594
|
const withoutOldSystem = history.filter(message => message.role !== 'system');
|
|
541
595
|
const snapshot = options.store.getSnapshot();
|
|
542
596
|
const goalContent = buildGoalRuntimeContext(composition.goal.state);
|
|
543
|
-
const
|
|
597
|
+
const review = projection.planReview;
|
|
598
|
+
const planReceipt = mode !== 'plan' && review?.status === 'approved'
|
|
599
|
+
? (0, plan_review_1.findPlanReceiptForReviewV1)(projection, review)
|
|
600
|
+
: undefined;
|
|
544
601
|
const memory = (0, prompt_context_1.buildMemoryPromptContext)(input, options.cwd).content;
|
|
545
602
|
const skillCatalog = await composition.skills.observe({ id: `project:${(0, canonical_1.digestRuntimeValue)(options.cwd)}` }, undefined);
|
|
546
603
|
const skillSelection = await loadSelectedSkills(input, skillCatalog, composition, createProductAuthority(options, mode));
|
|
@@ -551,7 +608,6 @@ async function buildProductMessages(options, sessionId, eventStore, prompts, com
|
|
|
551
608
|
tools: options.toolCatalog.entries
|
|
552
609
|
.filter(entry => entry.candidate.tier === 'core')
|
|
553
610
|
.map(entry => entry.tool),
|
|
554
|
-
planMode: mode === 'plan',
|
|
555
611
|
agentMode: mode === 'goal'
|
|
556
612
|
? snapshot.agentMode
|
|
557
613
|
: mode === 'build'
|
|
@@ -724,7 +780,7 @@ function productPromptSections(input) {
|
|
|
724
780
|
`Receipt: ${input.plan.digest}`,
|
|
725
781
|
`Planning turn: ${input.plan.turnId}`,
|
|
726
782
|
`Execution mode: ${input.plan.returnMode.toUpperCase()}`,
|
|
727
|
-
'
|
|
783
|
+
'When the current request continues this approved plan, use the recorded evidence and remaining steps. Do not repeat completed work.',
|
|
728
784
|
'',
|
|
729
785
|
input.plan.plan,
|
|
730
786
|
].join('\n')
|
|
@@ -748,8 +804,8 @@ function productPromptSections(input) {
|
|
|
748
804
|
],
|
|
749
805
|
};
|
|
750
806
|
}
|
|
751
|
-
function latestDurableHistory(
|
|
752
|
-
const commits = Object.values(
|
|
807
|
+
function latestDurableHistory(projection) {
|
|
808
|
+
const commits = Object.values(projection.turns)
|
|
753
809
|
.map(turn => turn.commit)
|
|
754
810
|
.filter((commit) => Boolean(commit))
|
|
755
811
|
.sort((left, right) => left.seq - right.seq);
|
|
@@ -781,14 +837,17 @@ function projectRestoredTurnCommit(store, commit) {
|
|
|
781
837
|
});
|
|
782
838
|
}
|
|
783
839
|
function latestDurablePlanReceipt(store) {
|
|
784
|
-
const
|
|
840
|
+
const commits = Object.values(store.loadProjection().turns)
|
|
841
|
+
.filter(turn => turn.mode === 'plan')
|
|
785
842
|
.map(turn => turn.commit)
|
|
786
843
|
.filter((commit) => Boolean(commit))
|
|
787
|
-
.sort((left, right) =>
|
|
788
|
-
|
|
789
|
-
|
|
790
|
-
|
|
791
|
-
|
|
844
|
+
.sort((left, right) => right.seq - left.seq);
|
|
845
|
+
for (const commit of commits) {
|
|
846
|
+
const receipt = planReceiptFromCommit((0, turn_commit_1.parseTurnCommitV1)(commit.receipt));
|
|
847
|
+
if (receipt)
|
|
848
|
+
return receipt;
|
|
849
|
+
}
|
|
850
|
+
return undefined;
|
|
792
851
|
}
|
|
793
852
|
function planReceiptFromCommit(commit) {
|
|
794
853
|
if (!commit.planReceipt)
|
|
@@ -811,6 +870,23 @@ function extractDecisionCompletePlan(commit) {
|
|
|
811
870
|
}
|
|
812
871
|
return plan;
|
|
813
872
|
}
|
|
873
|
+
/** Convert the explicitly reviewed checklist into the same steps used by todo_write. */
|
|
874
|
+
function planExecutionChecklist(plan) {
|
|
875
|
+
const sections = plan.split(/^#{1,6}[ \t]+/mu);
|
|
876
|
+
const checklist = sections.find(section => /^(?:Execution checklist|执行清单)[ \t]*\r?\n/iu.test(section));
|
|
877
|
+
if (!checklist)
|
|
878
|
+
return [];
|
|
879
|
+
const contents = Array.from(checklist.matchAll(/^[ \t]*[-*][ \t]+\[ \][ \t]+(.+?)[ \t]*$/gmu), match => match[1].replace(/\s+/gu, ' ').trim());
|
|
880
|
+
if (contents.length > todo_1.MAX_TODOS ||
|
|
881
|
+
new Set(contents).size !== contents.length ||
|
|
882
|
+
contents.some(step => !step || step.length > todo_1.MAX_TODO_TEXT))
|
|
883
|
+
return [];
|
|
884
|
+
return contents.map((content, index) => ({
|
|
885
|
+
content,
|
|
886
|
+
activeForm: content,
|
|
887
|
+
status: index === 0 ? 'in_progress' : 'pending',
|
|
888
|
+
}));
|
|
889
|
+
}
|
|
814
890
|
function createPlanStopDecision(commit, promptReceiptDigest) {
|
|
815
891
|
const stats = commit.queryComplete.stats;
|
|
816
892
|
const completion = commit.taskContextCompletion;
|
|
@@ -880,7 +956,7 @@ function projectPlanReceipt(store, receipt, reviewStatus) {
|
|
|
880
956
|
agentMode,
|
|
881
957
|
planMode: agentMode === 'plan',
|
|
882
958
|
planReturnMode: receipt.returnMode === 'auto' ? 'auto' : 'interactive',
|
|
883
|
-
currentPlan: receipt.plan,
|
|
959
|
+
currentPlan: reviewStatus === 'cancelled' ? null : receipt.plan,
|
|
884
960
|
});
|
|
885
961
|
}
|
|
886
962
|
function legacyHistory(sessionId) {
|