@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,25 +2,24 @@
|
|
|
2
2
|
/**
|
|
3
3
|
* Orion Code - global configuration management.
|
|
4
4
|
*
|
|
5
|
-
* Config stored in ~/.orion-code/orion.
|
|
6
|
-
*
|
|
5
|
+
* Config stored in ~/.orion-code/orion.yaml
|
|
6
|
+
* ORION_CODE_CONFIG_DIR selects an isolated configuration root.
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.updateTokenStats = exports.incrementSessionCount = exports.GlobalConfigDocumentValidationError = void 0;
|
|
10
10
|
exports.validateGlobalConfigDocumentStrict = validateGlobalConfigDocumentStrict;
|
|
11
11
|
exports.parseGlobalConfigDocumentStrict = parseGlobalConfigDocumentStrict;
|
|
12
|
+
exports.serializeGlobalConfigDocumentStrict = serializeGlobalConfigDocumentStrict;
|
|
12
13
|
exports.loadGlobalConfig = loadGlobalConfig;
|
|
13
14
|
exports.saveGlobalConfig = saveGlobalConfig;
|
|
14
15
|
exports.updateGlobalConfig = updateGlobalConfig;
|
|
15
16
|
exports.getProjectConfig = getProjectConfig;
|
|
16
17
|
exports.saveProjectConfig = saveProjectConfig;
|
|
17
|
-
exports.getOrCreateUserId = getOrCreateUserId;
|
|
18
|
-
exports.recordFirstStartTime = recordFirstStartTime;
|
|
19
18
|
exports.getInputHistory = getInputHistory;
|
|
20
19
|
exports.addToInputHistory = addToInputHistory;
|
|
21
20
|
exports.searchInputHistory = searchInputHistory;
|
|
22
21
|
const fs_1 = require("fs");
|
|
23
|
-
const
|
|
22
|
+
const js_yaml_1 = require("js-yaml");
|
|
24
23
|
const path_1 = require("path");
|
|
25
24
|
const config_dir_1 = require("./config-dir");
|
|
26
25
|
const atomic_write_1 = require("./atomic-write");
|
|
@@ -33,14 +32,15 @@ const model_registry_1 = require("./model-registry");
|
|
|
33
32
|
const DEFAULT_CONFIG = {
|
|
34
33
|
schemaVersion: 1,
|
|
35
34
|
defaultModel: 'gpt-4o',
|
|
36
|
-
toolConfirmation: 'allow',
|
|
37
35
|
};
|
|
38
36
|
const CONFIG_SCHEMA_VERSION = 1;
|
|
39
|
-
/**
|
|
37
|
+
/** Safe field/position diagnostics, never YAML source lines or configuration values. */
|
|
40
38
|
class GlobalConfigDocumentValidationError extends Error {
|
|
41
|
-
constructor(field) {
|
|
42
|
-
super(`Invalid Orion configuration field: ${field}`);
|
|
39
|
+
constructor(field, configPath, yamlReason) {
|
|
40
|
+
super(`Invalid Orion configuration field: ${field}${configPath ? ` in ${configPath}` : ''}${yamlReason ? ` (${yamlReason})` : ''}`);
|
|
43
41
|
this.field = field;
|
|
42
|
+
this.configPath = configPath;
|
|
43
|
+
this.yamlReason = yamlReason;
|
|
44
44
|
this.name = 'GlobalConfigDocumentValidationError';
|
|
45
45
|
}
|
|
46
46
|
}
|
|
@@ -51,6 +51,36 @@ function isRecord(value) {
|
|
|
51
51
|
function invalidField(field) {
|
|
52
52
|
throw new GlobalConfigDocumentValidationError(field);
|
|
53
53
|
}
|
|
54
|
+
function validateKnownKeys(record, keys, field = '') {
|
|
55
|
+
for (const key of Object.keys(record)) {
|
|
56
|
+
if (!keys.includes(key)) {
|
|
57
|
+
// Unknown keys can themselves contain secrets. Only display identifier-like names.
|
|
58
|
+
const safeKey = /^[A-Za-z_][A-Za-z0-9_-]{0,63}$/u.test(key) ? key : '$unknown';
|
|
59
|
+
invalidField(field ? `${field}.${safeKey}` : safeKey);
|
|
60
|
+
}
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
function validateDocumentTree(value, ancestors = new Set(), depth = 0, budget = { remaining: 20000 }) {
|
|
64
|
+
if (--budget.remaining < 0)
|
|
65
|
+
invalidField('$size');
|
|
66
|
+
if (depth > 100)
|
|
67
|
+
invalidField('$depth');
|
|
68
|
+
if (typeof value === 'number' && !Number.isFinite(value))
|
|
69
|
+
invalidField('$number');
|
|
70
|
+
if (value === null || typeof value !== 'object')
|
|
71
|
+
return;
|
|
72
|
+
if (ancestors.has(value))
|
|
73
|
+
invalidField('$cycle');
|
|
74
|
+
if (!Array.isArray(value) &&
|
|
75
|
+
Object.getPrototypeOf(value) !== Object.prototype &&
|
|
76
|
+
Object.getPrototypeOf(value) !== null) {
|
|
77
|
+
invalidField('$type');
|
|
78
|
+
}
|
|
79
|
+
ancestors.add(value);
|
|
80
|
+
for (const child of Object.values(value))
|
|
81
|
+
validateDocumentTree(child, ancestors, depth + 1, budget);
|
|
82
|
+
ancestors.delete(value);
|
|
83
|
+
}
|
|
54
84
|
function validateOptionalString(record, key, field, allowEmpty = true) {
|
|
55
85
|
const value = record[key];
|
|
56
86
|
if (value === undefined)
|
|
@@ -81,6 +111,7 @@ function validateSandboxDocument(value, field) {
|
|
|
81
111
|
return;
|
|
82
112
|
if (!isRecord(value))
|
|
83
113
|
invalidField(field);
|
|
114
|
+
validateKnownKeys(value, ['profile', 'backend', 'allowNetwork', 'writableRoots', 'image'], field);
|
|
84
115
|
if (value.profile !== undefined &&
|
|
85
116
|
value.profile !== 'none' &&
|
|
86
117
|
value.profile !== 'read-only' &&
|
|
@@ -101,12 +132,9 @@ function validateSandboxDocument(value, field) {
|
|
|
101
132
|
function validateProjectDocument(value) {
|
|
102
133
|
if (!isRecord(value))
|
|
103
134
|
invalidField('projects.*');
|
|
104
|
-
|
|
135
|
+
validateKnownKeys(value, ['compactInstructions', 'sandbox', 'defaultEffort'], 'projects.*');
|
|
105
136
|
validateOptionalString(value, 'compactInstructions', 'projects.*.compactInstructions');
|
|
106
137
|
validateSandboxDocument(value.sandbox, 'projects.*.sandbox');
|
|
107
|
-
validateOptionalString(value, 'lastSessionId', 'projects.*.lastSessionId');
|
|
108
|
-
validateOptionalString(value, 'lastModel', 'projects.*.lastModel');
|
|
109
|
-
validateOptionalBoolean(value, 'hasTrustDialogAccepted', 'projects.*.hasTrustDialogAccepted');
|
|
110
138
|
if (value.defaultEffort !== undefined && !(0, effort_1.isEffortPreference)(value.defaultEffort)) {
|
|
111
139
|
invalidField('projects.*.defaultEffort');
|
|
112
140
|
}
|
|
@@ -114,6 +142,7 @@ function validateProjectDocument(value) {
|
|
|
114
142
|
function validatePricing(value, field) {
|
|
115
143
|
if (!isRecord(value))
|
|
116
144
|
invalidField(field);
|
|
145
|
+
validateKnownKeys(value, ['input', 'output', 'cachedInput'], field);
|
|
117
146
|
for (const key of ['input', 'output']) {
|
|
118
147
|
if (typeof value[key] !== 'number' || !Number.isFinite(value[key]) || value[key] < 0) {
|
|
119
148
|
invalidField(`${field}.${key}`);
|
|
@@ -127,28 +156,33 @@ function validatePricing(value, field) {
|
|
|
127
156
|
}
|
|
128
157
|
}
|
|
129
158
|
/**
|
|
130
|
-
* Validate the
|
|
131
|
-
* fields. Settings mutations must call this before writing their raw clone.
|
|
159
|
+
* Validate the v0.4 schema without silently normalizing misspelled or retired fields.
|
|
132
160
|
*/
|
|
133
161
|
function validateGlobalConfigDocumentStrict(value) {
|
|
134
162
|
if (!isRecord(value))
|
|
135
163
|
invalidField('$');
|
|
164
|
+
validateDocumentTree(value);
|
|
165
|
+
validateKnownKeys(value, [
|
|
166
|
+
'schemaVersion',
|
|
167
|
+
'providers',
|
|
168
|
+
'models',
|
|
169
|
+
'defaultModel',
|
|
170
|
+
'fallbackModel',
|
|
171
|
+
'defaultEffort',
|
|
172
|
+
'webSearch',
|
|
173
|
+
'ui',
|
|
174
|
+
'skills',
|
|
175
|
+
'agentLoop',
|
|
176
|
+
'subagents',
|
|
177
|
+
'cost',
|
|
178
|
+
'sandbox',
|
|
179
|
+
'projects',
|
|
180
|
+
]);
|
|
136
181
|
if (value.schemaVersion !== undefined && value.schemaVersion !== CONFIG_SCHEMA_VERSION) {
|
|
137
182
|
invalidField('schemaVersion');
|
|
138
183
|
}
|
|
139
|
-
validateOptionalString(value, 'apiKey', 'apiKey');
|
|
140
|
-
validateOptionalString(value, 'apiBaseUrl', 'apiBaseUrl');
|
|
141
184
|
validateOptionalString(value, 'defaultModel', 'defaultModel', false);
|
|
142
185
|
validateOptionalString(value, 'fallbackModel', 'fallbackModel', false);
|
|
143
|
-
validateOptionalString(value, 'userId', 'userId', false);
|
|
144
|
-
validateOptionalString(value, 'firstStartTime', 'firstStartTime', false);
|
|
145
|
-
validateOptionalStringArray(value, 'allowedTools', 'allowedTools');
|
|
146
|
-
if (value.toolConfirmation !== undefined &&
|
|
147
|
-
value.toolConfirmation !== 'ask' &&
|
|
148
|
-
value.toolConfirmation !== 'allow' &&
|
|
149
|
-
value.toolConfirmation !== 'deny') {
|
|
150
|
-
invalidField('toolConfirmation');
|
|
151
|
-
}
|
|
152
186
|
if (value.defaultEffort !== undefined && !(0, effort_1.isEffortPreference)(value.defaultEffort)) {
|
|
153
187
|
invalidField('defaultEffort');
|
|
154
188
|
}
|
|
@@ -159,36 +193,11 @@ function validateGlobalConfigDocumentStrict(value) {
|
|
|
159
193
|
for (const project of Object.values(value.projects))
|
|
160
194
|
validateProjectDocument(project);
|
|
161
195
|
}
|
|
162
|
-
if (value.web !== undefined) {
|
|
163
|
-
if (!isRecord(value.web))
|
|
164
|
-
invalidField('web');
|
|
165
|
-
if (value.web.appearance !== undefined) {
|
|
166
|
-
if (!isRecord(value.web.appearance))
|
|
167
|
-
invalidField('web.appearance');
|
|
168
|
-
const { style, theme, motion } = value.web.appearance;
|
|
169
|
-
if (style !== undefined && style !== 'classic' && style !== 'orion-blocksmith') {
|
|
170
|
-
invalidField('web.appearance.style');
|
|
171
|
-
}
|
|
172
|
-
if (theme !== undefined && theme !== 'system' && theme !== 'light' && theme !== 'dark') {
|
|
173
|
-
invalidField('web.appearance.theme');
|
|
174
|
-
}
|
|
175
|
-
if (motion !== undefined && motion !== 'system' && motion !== 'reduced') {
|
|
176
|
-
invalidField('web.appearance.motion');
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
}
|
|
180
196
|
if (value.ui !== undefined) {
|
|
181
197
|
if (!isRecord(value.ui))
|
|
182
198
|
invalidField('ui');
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
invalidField('ui.renderer');
|
|
186
|
-
}
|
|
187
|
-
if (confirmations !== undefined &&
|
|
188
|
-
confirmations !== 'config' &&
|
|
189
|
-
confirmations !== 'interactive') {
|
|
190
|
-
invalidField('ui.confirmations');
|
|
191
|
-
}
|
|
199
|
+
validateKnownKeys(value.ui, ['theme', 'motion', 'mascot', 'statusLine', 'keymap'], 'ui');
|
|
200
|
+
const { theme, motion } = value.ui;
|
|
192
201
|
if (theme !== undefined && !TUI_THEME_PREFERENCES.has(theme)) {
|
|
193
202
|
invalidField('ui.theme');
|
|
194
203
|
}
|
|
@@ -197,12 +206,41 @@ function validateGlobalConfigDocumentStrict(value) {
|
|
|
197
206
|
}
|
|
198
207
|
validateOptionalBoolean(value.ui, 'mascot', 'ui.mascot');
|
|
199
208
|
validateOptionalStringArray(value.ui, 'statusLine', 'ui.statusLine');
|
|
200
|
-
if (
|
|
201
|
-
|
|
209
|
+
if (Array.isArray(value.ui.statusLine) &&
|
|
210
|
+
!value.ui.statusLine.every(item => TUI_STATUS_ITEMS.has(item)))
|
|
211
|
+
invalidField('ui.statusLine');
|
|
212
|
+
if (value.ui.keymap !== undefined) {
|
|
213
|
+
if (!isRecord(value.ui.keymap))
|
|
214
|
+
invalidField('ui.keymap');
|
|
215
|
+
validateKnownKeys(value.ui.keymap, [...TUI_KEYMAP_ACTIONS], 'ui.keymap');
|
|
216
|
+
const claimedBindings = new Set();
|
|
217
|
+
for (const [action, bindings] of Object.entries(value.ui.keymap)) {
|
|
218
|
+
if (!Array.isArray(bindings) ||
|
|
219
|
+
!bindings.every(binding => typeof binding === 'string' && TUI_KEY_BINDINGS.has(binding.trim().toLowerCase())))
|
|
220
|
+
invalidField(`ui.keymap.${action}`);
|
|
221
|
+
for (const binding of bindings) {
|
|
222
|
+
const normalized = binding.trim().toLowerCase();
|
|
223
|
+
if (claimedBindings.has(normalized))
|
|
224
|
+
invalidField(`ui.keymap.${action}`);
|
|
225
|
+
claimedBindings.add(normalized);
|
|
226
|
+
}
|
|
227
|
+
}
|
|
228
|
+
}
|
|
202
229
|
}
|
|
203
230
|
if (value.webSearch !== undefined) {
|
|
204
231
|
if (!isRecord(value.webSearch))
|
|
205
232
|
invalidField('webSearch');
|
|
233
|
+
validateKnownKeys(value.webSearch, [
|
|
234
|
+
'provider',
|
|
235
|
+
'endpoint',
|
|
236
|
+
'apiKey',
|
|
237
|
+
'toolName',
|
|
238
|
+
'timeoutMs',
|
|
239
|
+
'authType',
|
|
240
|
+
'apiKeyHeader',
|
|
241
|
+
'apiKeyQueryParam',
|
|
242
|
+
'headers',
|
|
243
|
+
], 'webSearch');
|
|
206
244
|
for (const key of [
|
|
207
245
|
'provider',
|
|
208
246
|
'endpoint',
|
|
@@ -228,27 +266,49 @@ function validateGlobalConfigDocumentStrict(value) {
|
|
|
228
266
|
if (value.skills !== undefined) {
|
|
229
267
|
if (!isRecord(value.skills))
|
|
230
268
|
invalidField('skills');
|
|
269
|
+
validateKnownKeys(value.skills, ['paths'], 'skills');
|
|
231
270
|
validateOptionalStringArray(value.skills, 'paths', 'skills.paths');
|
|
232
271
|
}
|
|
233
272
|
if (value.agentLoop !== undefined) {
|
|
234
273
|
if (!isRecord(value.agentLoop))
|
|
235
274
|
invalidField('agentLoop');
|
|
275
|
+
validateKnownKeys(value.agentLoop, ['budget', 'continuation', 'goalBudget'], 'agentLoop');
|
|
276
|
+
if (value.agentLoop.continuation !== undefined &&
|
|
277
|
+
value.agentLoop.continuation !== 'agent' &&
|
|
278
|
+
value.agentLoop.continuation !== 'manual') {
|
|
279
|
+
invalidField('agentLoop.continuation');
|
|
280
|
+
}
|
|
281
|
+
if (value.agentLoop.goalBudget !== undefined) {
|
|
282
|
+
if (!isRecord(value.agentLoop.goalBudget))
|
|
283
|
+
invalidField('agentLoop.goalBudget');
|
|
284
|
+
validateKnownKeys(value.agentLoop.goalBudget, ['maxTokens', 'maxElapsedMs'], 'agentLoop.goalBudget');
|
|
285
|
+
for (const key of ['maxTokens', 'maxElapsedMs']) {
|
|
286
|
+
validateOptionalPositiveInteger(value.agentLoop.goalBudget, key, `agentLoop.goalBudget.${key}`);
|
|
287
|
+
if (value.agentLoop.goalBudget[key] !== undefined &&
|
|
288
|
+
!Number.isSafeInteger(value.agentLoop.goalBudget[key]))
|
|
289
|
+
invalidField(`agentLoop.goalBudget.${key}`);
|
|
290
|
+
}
|
|
291
|
+
}
|
|
236
292
|
if (value.agentLoop.budget !== undefined) {
|
|
237
293
|
if (!isRecord(value.agentLoop.budget))
|
|
238
294
|
invalidField('agentLoop.budget');
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
'maxToolCallsPerUserTurn',
|
|
242
|
-
'maxReadOnlyFragmentation',
|
|
243
|
-
'maxModelVisibleToolBytes',
|
|
244
|
-
]) {
|
|
245
|
-
validateOptionalPositiveInteger(value.agentLoop.budget, key, `agentLoop.budget.${key}`);
|
|
246
|
-
}
|
|
295
|
+
validateKnownKeys(value.agentLoop.budget, ['maxModelVisibleToolBytes'], 'agentLoop.budget');
|
|
296
|
+
validateOptionalPositiveInteger(value.agentLoop.budget, 'maxModelVisibleToolBytes', 'agentLoop.budget.maxModelVisibleToolBytes');
|
|
247
297
|
}
|
|
248
298
|
}
|
|
249
299
|
if (value.subagents !== undefined) {
|
|
250
300
|
if (!isRecord(value.subagents))
|
|
251
301
|
invalidField('subagents');
|
|
302
|
+
validateKnownKeys(value.subagents, [
|
|
303
|
+
'mode',
|
|
304
|
+
'maxParallel',
|
|
305
|
+
'maxTasksPerTurn',
|
|
306
|
+
'maxModelRequestsPerTask',
|
|
307
|
+
'maxModelRequestsPerTurn',
|
|
308
|
+
'maxToolCallsPerTask',
|
|
309
|
+
'timeoutMs',
|
|
310
|
+
'roles',
|
|
311
|
+
], 'subagents');
|
|
252
312
|
if (value.subagents.mode !== undefined &&
|
|
253
313
|
value.subagents.mode !== 'off' &&
|
|
254
314
|
value.subagents.mode !== 'explicit' &&
|
|
@@ -258,7 +318,6 @@ function validateGlobalConfigDocumentStrict(value) {
|
|
|
258
318
|
for (const key of [
|
|
259
319
|
'maxParallel',
|
|
260
320
|
'maxTasksPerTurn',
|
|
261
|
-
'maxTurnsPerTask',
|
|
262
321
|
'maxModelRequestsPerTask',
|
|
263
322
|
'maxModelRequestsPerTurn',
|
|
264
323
|
'maxToolCallsPerTask',
|
|
@@ -276,6 +335,7 @@ function validateGlobalConfigDocumentStrict(value) {
|
|
|
276
335
|
if (value.cost !== undefined) {
|
|
277
336
|
if (!isRecord(value.cost))
|
|
278
337
|
invalidField('cost');
|
|
338
|
+
validateKnownKeys(value.cost, ['modelPricing', 'defaultPricing'], 'cost');
|
|
279
339
|
if (value.cost.defaultPricing !== undefined) {
|
|
280
340
|
validatePricing(value.cost.defaultPricing, 'cost.defaultPricing');
|
|
281
341
|
}
|
|
@@ -296,6 +356,7 @@ function validateGlobalConfigDocumentStrict(value) {
|
|
|
296
356
|
if (!Array.isArray(value.models) || !value.models.every(isRecord))
|
|
297
357
|
invalidField('models');
|
|
298
358
|
for (const provider of value.providers) {
|
|
359
|
+
validateKnownKeys(provider, ['id', 'baseUrl', 'apiKey', 'protocol', 'displayName'], 'providers.*');
|
|
299
360
|
validateOptionalString(provider, 'id', 'providers.*.id', false);
|
|
300
361
|
validateOptionalString(provider, 'baseUrl', 'providers.*.baseUrl', false);
|
|
301
362
|
validateOptionalString(provider, 'apiKey', 'providers.*.apiKey', false);
|
|
@@ -305,12 +366,27 @@ function validateGlobalConfigDocumentStrict(value) {
|
|
|
305
366
|
typeof provider.apiKey !== 'string') {
|
|
306
367
|
invalidField('providers');
|
|
307
368
|
}
|
|
308
|
-
if (provider.protocol !== 'openai-completions'
|
|
309
|
-
provider.protocol !== 'anthropic-messages') {
|
|
369
|
+
if (provider.protocol !== 'openai-completions') {
|
|
310
370
|
invalidField('providers.*.protocol');
|
|
311
371
|
}
|
|
312
372
|
}
|
|
313
373
|
for (const model of value.models) {
|
|
374
|
+
validateKnownKeys(model, [
|
|
375
|
+
'id',
|
|
376
|
+
'displayName',
|
|
377
|
+
'provider',
|
|
378
|
+
'model',
|
|
379
|
+
'contextWindow',
|
|
380
|
+
'maxOutputTokens',
|
|
381
|
+
'aliases',
|
|
382
|
+
'enabled',
|
|
383
|
+
'reasoningEffort',
|
|
384
|
+
], 'models.*');
|
|
385
|
+
if (model.reasoningEffort !== undefined) {
|
|
386
|
+
if (!isRecord(model.reasoningEffort))
|
|
387
|
+
invalidField('models.*.reasoningEffort');
|
|
388
|
+
validateKnownKeys(model.reasoningEffort, ['supportedLevels', 'defaultLevel'], 'models.*.reasoningEffort');
|
|
389
|
+
}
|
|
314
390
|
validateOptionalString(model, 'id', 'models.*.id', false);
|
|
315
391
|
validateOptionalString(model, 'displayName', 'models.*.displayName');
|
|
316
392
|
validateOptionalString(model, 'provider', 'models.*.provider', false);
|
|
@@ -324,14 +400,6 @@ function validateGlobalConfigDocumentStrict(value) {
|
|
|
324
400
|
validateOptionalPositiveInteger(model, 'maxOutputTokens', 'models.*.maxOutputTokens');
|
|
325
401
|
validateOptionalStringArray(model, 'aliases', 'models.*.aliases');
|
|
326
402
|
validateOptionalBoolean(model, 'enabled', 'models.*.enabled');
|
|
327
|
-
validateOptionalBoolean(model, 'reasoning', 'models.*.reasoning');
|
|
328
|
-
if (model.temperatureMode !== undefined &&
|
|
329
|
-
model.temperatureMode !== 'supported' &&
|
|
330
|
-
model.temperatureMode !== 'unsupported') {
|
|
331
|
-
invalidField('models.*.temperatureMode');
|
|
332
|
-
}
|
|
333
|
-
if (model.cost !== undefined)
|
|
334
|
-
validatePricing(model.cost, 'models.*.cost');
|
|
335
403
|
}
|
|
336
404
|
let validation;
|
|
337
405
|
try {
|
|
@@ -344,17 +412,78 @@ function validateGlobalConfigDocumentStrict(value) {
|
|
|
344
412
|
invalidField('providers/models');
|
|
345
413
|
}
|
|
346
414
|
}
|
|
415
|
+
/** Make retired turn counters inert while retaining supported settings and strict tree checks. */
|
|
416
|
+
function withoutRetiredAgentLoopSettings(document) {
|
|
417
|
+
if (!isRecord(document) || !isRecord(document.agentLoop))
|
|
418
|
+
return document;
|
|
419
|
+
validateDocumentTree(document);
|
|
420
|
+
const agentLoop = { ...document.agentLoop };
|
|
421
|
+
delete agentLoop.budgetPolicy;
|
|
422
|
+
if (isRecord(agentLoop.budget)) {
|
|
423
|
+
const budget = { ...agentLoop.budget };
|
|
424
|
+
delete budget.maxLlmRequestsPerUserTurn;
|
|
425
|
+
delete budget.maxToolCallsPerUserTurn;
|
|
426
|
+
delete budget.maxReadOnlyFragmentation;
|
|
427
|
+
if (Object.keys(budget).length > 0)
|
|
428
|
+
agentLoop.budget = budget;
|
|
429
|
+
else
|
|
430
|
+
delete agentLoop.budget;
|
|
431
|
+
}
|
|
432
|
+
const normalized = { ...document };
|
|
433
|
+
if (Object.keys(agentLoop).length > 0)
|
|
434
|
+
normalized.agentLoop = agentLoop;
|
|
435
|
+
else
|
|
436
|
+
delete normalized.agentLoop;
|
|
437
|
+
return normalized;
|
|
438
|
+
}
|
|
347
439
|
/** Parse exact file bytes through the strict Settings validator. */
|
|
348
440
|
function parseGlobalConfigDocumentStrict(content) {
|
|
441
|
+
const text = typeof content === 'string' ? content : content.toString('utf8');
|
|
349
442
|
let parsed;
|
|
350
443
|
try {
|
|
351
|
-
|
|
352
|
-
|
|
353
|
-
|
|
354
|
-
|
|
444
|
+
// CORE_SCHEMA keeps dates as strings and refuses executable/custom tags.
|
|
445
|
+
// The default duplicate-key rejection applies at every mapping depth.
|
|
446
|
+
parsed = (0, js_yaml_1.load)(text, { schema: js_yaml_1.CORE_SCHEMA });
|
|
447
|
+
}
|
|
448
|
+
catch (error) {
|
|
449
|
+
if (!(error instanceof js_yaml_1.YAMLException))
|
|
450
|
+
invalidField('$yaml');
|
|
451
|
+
// Some parser reasons interpolate raw tags or values. Expose only fixed diagnostics.
|
|
452
|
+
const safeReasons = new Set([
|
|
453
|
+
'bad indentation of a mapping entry',
|
|
454
|
+
'bad indentation of a sequence entry',
|
|
455
|
+
'duplicated mapping key',
|
|
456
|
+
'end of the stream or a document separator is expected',
|
|
457
|
+
'missed comma between flow collection entries',
|
|
458
|
+
'unexpected end of the stream within a flow collection',
|
|
459
|
+
'unexpected end of the stream within a quoted scalar',
|
|
460
|
+
]);
|
|
461
|
+
const reason = safeReasons.has(error.reason) ? error.reason : 'invalid YAML syntax';
|
|
462
|
+
throw new GlobalConfigDocumentValidationError(`yaml:${(error.mark?.line ?? 0) + 1}:${(error.mark?.column ?? 0) + 1}`, undefined, reason);
|
|
463
|
+
}
|
|
464
|
+
// A retired YAML pointer cannot select a session. Strip it before exposing
|
|
465
|
+
// the document to configuration editors, including their next save.
|
|
466
|
+
if (isRecord(parsed) && isRecord(parsed.projects)) {
|
|
467
|
+
parsed = {
|
|
468
|
+
...parsed,
|
|
469
|
+
projects: Object.fromEntries(Object.entries(parsed.projects).map(([path, project]) => {
|
|
470
|
+
if (!isRecord(project))
|
|
471
|
+
return [path, project];
|
|
472
|
+
const settings = { ...project };
|
|
473
|
+
delete settings.lastSessionId;
|
|
474
|
+
return [path, settings];
|
|
475
|
+
})),
|
|
476
|
+
};
|
|
355
477
|
}
|
|
356
|
-
|
|
357
|
-
|
|
478
|
+
const document = withoutRetiredAgentLoopSettings(parsed);
|
|
479
|
+
validateGlobalConfigDocumentStrict(document);
|
|
480
|
+
return document;
|
|
481
|
+
}
|
|
482
|
+
/** Canonical YAML write path. Comments are not retained after a settings mutation. */
|
|
483
|
+
function serializeGlobalConfigDocumentStrict(document) {
|
|
484
|
+
const normalized = withoutRetiredAgentLoopSettings(document);
|
|
485
|
+
validateGlobalConfigDocumentStrict(normalized);
|
|
486
|
+
return (0, js_yaml_1.dump)(normalized, { noRefs: true, lineWidth: -1, sortKeys: false });
|
|
358
487
|
}
|
|
359
488
|
const TUI_THEME_PREFERENCES = new Set([
|
|
360
489
|
'orion-pixel',
|
|
@@ -369,7 +498,6 @@ const TUI_STATUS_ITEMS = new Set([
|
|
|
369
498
|
'model',
|
|
370
499
|
'effort',
|
|
371
500
|
'context',
|
|
372
|
-
'permission',
|
|
373
501
|
'queue',
|
|
374
502
|
'activity',
|
|
375
503
|
]);
|
|
@@ -399,9 +527,6 @@ function sanitizeUiConfig(value) {
|
|
|
399
527
|
return undefined;
|
|
400
528
|
const raw = value;
|
|
401
529
|
const ui = {};
|
|
402
|
-
if (raw.confirmations === 'config' || raw.confirmations === 'interactive') {
|
|
403
|
-
ui.confirmations = raw.confirmations;
|
|
404
|
-
}
|
|
405
530
|
if (typeof raw.theme === 'string' && TUI_THEME_PREFERENCES.has(raw.theme)) {
|
|
406
531
|
ui.theme = raw.theme;
|
|
407
532
|
}
|
|
@@ -437,35 +562,6 @@ function sanitizeUiConfig(value) {
|
|
|
437
562
|
}
|
|
438
563
|
return Object.keys(ui).length > 0 ? ui : undefined;
|
|
439
564
|
}
|
|
440
|
-
function sanitizeWebConfig(value) {
|
|
441
|
-
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
442
|
-
return undefined;
|
|
443
|
-
const raw = value;
|
|
444
|
-
// Preserve forward-compatible Web fields while sanitizing the owned subtree.
|
|
445
|
-
const sanitized = { ...raw };
|
|
446
|
-
if (raw.appearance && typeof raw.appearance === 'object' && !Array.isArray(raw.appearance)) {
|
|
447
|
-
const appearance = { ...raw.appearance };
|
|
448
|
-
if (appearance.style !== 'classic' && appearance.style !== 'orion-blocksmith') {
|
|
449
|
-
delete appearance.style;
|
|
450
|
-
}
|
|
451
|
-
if (appearance.theme !== 'system' &&
|
|
452
|
-
appearance.theme !== 'light' &&
|
|
453
|
-
appearance.theme !== 'dark') {
|
|
454
|
-
delete appearance.theme;
|
|
455
|
-
}
|
|
456
|
-
if (appearance.motion !== 'system' && appearance.motion !== 'reduced') {
|
|
457
|
-
delete appearance.motion;
|
|
458
|
-
}
|
|
459
|
-
if (Object.keys(appearance).length > 0)
|
|
460
|
-
sanitized.appearance = appearance;
|
|
461
|
-
else
|
|
462
|
-
delete sanitized.appearance;
|
|
463
|
-
}
|
|
464
|
-
else {
|
|
465
|
-
delete sanitized.appearance;
|
|
466
|
-
}
|
|
467
|
-
return sanitized;
|
|
468
|
-
}
|
|
469
565
|
function sanitizeSandboxConfig(value) {
|
|
470
566
|
if (!value || typeof value !== 'object' || Array.isArray(value))
|
|
471
567
|
return undefined;
|
|
@@ -495,9 +591,6 @@ function sanitizeProjectConfig(value) {
|
|
|
495
591
|
return {};
|
|
496
592
|
const raw = value;
|
|
497
593
|
const sanitized = {};
|
|
498
|
-
if (Array.isArray(raw.allowedTools) && raw.allowedTools.every(item => typeof item === 'string')) {
|
|
499
|
-
sanitized.allowedTools = [...raw.allowedTools];
|
|
500
|
-
}
|
|
501
594
|
if (typeof raw.compactInstructions === 'string') {
|
|
502
595
|
const compactInstructions = raw.compactInstructions
|
|
503
596
|
.replace(/\r\n?/gu, '\n')
|
|
@@ -509,30 +602,13 @@ function sanitizeProjectConfig(value) {
|
|
|
509
602
|
const sandbox = sanitizeSandboxConfig(raw.sandbox);
|
|
510
603
|
if (sandbox)
|
|
511
604
|
sanitized.sandbox = sandbox;
|
|
512
|
-
if (typeof raw.lastSessionId === 'string')
|
|
513
|
-
sanitized.lastSessionId = raw.lastSessionId;
|
|
514
|
-
if (typeof raw.lastModel === 'string')
|
|
515
|
-
sanitized.lastModel = raw.lastModel;
|
|
516
|
-
if (typeof raw.hasTrustDialogAccepted === 'boolean') {
|
|
517
|
-
sanitized.hasTrustDialogAccepted = raw.hasTrustDialogAccepted;
|
|
518
|
-
}
|
|
519
605
|
if ((0, effort_1.isEffortPreference)(raw.defaultEffort))
|
|
520
606
|
sanitized.defaultEffort = raw.defaultEffort;
|
|
521
607
|
return sanitized;
|
|
522
608
|
}
|
|
523
609
|
function sanitizeGlobalConfig(config) {
|
|
524
|
-
const { ui,
|
|
525
|
-
void _totalSessions;
|
|
526
|
-
void _totalTokens;
|
|
527
|
-
void _totalCost;
|
|
610
|
+
const { ui, ...rest } = config;
|
|
528
611
|
const sanitized = { ...rest, schemaVersion: CONFIG_SCHEMA_VERSION };
|
|
529
|
-
if (Array.isArray(rest.allowedTools) &&
|
|
530
|
-
rest.allowedTools.every(item => typeof item === 'string')) {
|
|
531
|
-
sanitized.allowedTools = [...new Set(rest.allowedTools)];
|
|
532
|
-
}
|
|
533
|
-
else {
|
|
534
|
-
delete sanitized.allowedTools;
|
|
535
|
-
}
|
|
536
612
|
if (!(0, effort_1.isEffortPreference)(rest.defaultEffort))
|
|
537
613
|
delete sanitized.defaultEffort;
|
|
538
614
|
const sandbox = sanitizeSandboxConfig(rest.sandbox);
|
|
@@ -550,9 +626,6 @@ function sanitizeGlobalConfig(config) {
|
|
|
550
626
|
const persistedUi = sanitizeUiConfig(ui);
|
|
551
627
|
if (persistedUi)
|
|
552
628
|
sanitized.ui = persistedUi;
|
|
553
|
-
const persistedWeb = sanitizeWebConfig(web);
|
|
554
|
-
if (persistedWeb)
|
|
555
|
-
sanitized.web = persistedWeb;
|
|
556
629
|
return sanitized;
|
|
557
630
|
}
|
|
558
631
|
// ============================================================================
|
|
@@ -570,11 +643,21 @@ function loadGlobalConfig() {
|
|
|
570
643
|
}
|
|
571
644
|
try {
|
|
572
645
|
const content = (0, fs_1.readFileSync)(path, 'utf-8');
|
|
573
|
-
const parsed =
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
577
|
-
return sanitizeGlobalConfig({
|
|
646
|
+
const parsed = parseGlobalConfigDocumentStrict(content);
|
|
647
|
+
const defaultModel = parsed.defaultModel === undefined && Array.isArray(parsed.models)
|
|
648
|
+
? (0, model_registry_1.buildRegistry)(parsed).registry?.defaultProfile?.id
|
|
649
|
+
: undefined;
|
|
650
|
+
return sanitizeGlobalConfig({
|
|
651
|
+
...DEFAULT_CONFIG,
|
|
652
|
+
...(defaultModel ? { defaultModel } : {}),
|
|
653
|
+
...parsed,
|
|
654
|
+
});
|
|
655
|
+
}
|
|
656
|
+
catch (error) {
|
|
657
|
+
if (error instanceof GlobalConfigDocumentValidationError) {
|
|
658
|
+
throw new GlobalConfigDocumentValidationError(error.field, path, error.yamlReason);
|
|
659
|
+
}
|
|
660
|
+
throw new GlobalConfigDocumentValidationError('$read', path);
|
|
578
661
|
}
|
|
579
662
|
}
|
|
580
663
|
/**
|
|
@@ -583,15 +666,16 @@ function loadGlobalConfig() {
|
|
|
583
666
|
function saveGlobalConfig(config) {
|
|
584
667
|
(0, config_dir_1.ensureConfigDir)();
|
|
585
668
|
const path = (0, config_dir_1.getGlobalConfigPath)();
|
|
586
|
-
(0, file_lock_1.withFileLockSync)(path, () =>
|
|
669
|
+
(0, file_lock_1.withFileLockSync)(path, () => {
|
|
670
|
+
if ((0, fs_1.existsSync)(path))
|
|
671
|
+
parseGlobalConfigDocumentStrict((0, fs_1.readFileSync)(path));
|
|
672
|
+
saveGlobalConfigUnlocked(path, config);
|
|
673
|
+
}, { waitMs: 10000 });
|
|
587
674
|
}
|
|
588
675
|
function saveGlobalConfigUnlocked(path, config) {
|
|
589
|
-
|
|
590
|
-
|
|
591
|
-
(0, atomic_write_1.atomicWriteFileSync)(path,
|
|
592
|
-
mode: 0o600,
|
|
593
|
-
fsync: true,
|
|
594
|
-
});
|
|
676
|
+
const document = withoutRetiredAgentLoopSettings(config);
|
|
677
|
+
validateGlobalConfigDocumentStrict(document);
|
|
678
|
+
(0, atomic_write_1.atomicWriteFileSync)(path, serializeGlobalConfigDocumentStrict(sanitizeGlobalConfig(document)), { mode: 0o600, fsync: true });
|
|
595
679
|
}
|
|
596
680
|
/**
|
|
597
681
|
* 更新全局配置(部分更新)
|
|
@@ -625,50 +709,6 @@ function saveProjectConfig(projectPath, projectConfig) {
|
|
|
625
709
|
saveGlobalConfigUnlocked(path, config);
|
|
626
710
|
}, { waitMs: 10000 });
|
|
627
711
|
}
|
|
628
|
-
// ============================================================================
|
|
629
|
-
// 用户 ID
|
|
630
|
-
// ============================================================================
|
|
631
|
-
function getOrCreateUserId() {
|
|
632
|
-
(0, config_dir_1.ensureConfigDir)();
|
|
633
|
-
const path = (0, config_dir_1.getGlobalConfigPath)();
|
|
634
|
-
return (0, file_lock_1.withFileLockSync)(path, () => {
|
|
635
|
-
const config = loadGlobalConfig();
|
|
636
|
-
if (config.userId)
|
|
637
|
-
return config.userId;
|
|
638
|
-
const userId = (0, crypto_1.randomBytes)(16).toString('hex');
|
|
639
|
-
saveGlobalConfigUnlocked(path, { ...config, userId });
|
|
640
|
-
return userId;
|
|
641
|
-
}, { waitMs: 10000 });
|
|
642
|
-
}
|
|
643
|
-
function recordFirstStartTime() {
|
|
644
|
-
(0, config_dir_1.ensureConfigDir)();
|
|
645
|
-
const path = (0, config_dir_1.getGlobalConfigPath)();
|
|
646
|
-
(0, file_lock_1.withFileLockSync)(path, () => {
|
|
647
|
-
let document;
|
|
648
|
-
if ((0, fs_1.existsSync)(path)) {
|
|
649
|
-
try {
|
|
650
|
-
document = parseGlobalConfigDocumentStrict((0, fs_1.readFileSync)(path));
|
|
651
|
-
}
|
|
652
|
-
catch {
|
|
653
|
-
// Startup metadata is optional. Never let the tolerant compatibility
|
|
654
|
-
// loader turn an invalid user document into defaults and overwrite it.
|
|
655
|
-
return;
|
|
656
|
-
}
|
|
657
|
-
}
|
|
658
|
-
else {
|
|
659
|
-
document = { schemaVersion: CONFIG_SCHEMA_VERSION };
|
|
660
|
-
}
|
|
661
|
-
if (typeof document.firstStartTime === 'string' && document.firstStartTime.trim())
|
|
662
|
-
return;
|
|
663
|
-
const candidate = {
|
|
664
|
-
...document,
|
|
665
|
-
schemaVersion: document.schemaVersion ?? CONFIG_SCHEMA_VERSION,
|
|
666
|
-
firstStartTime: new Date().toISOString(),
|
|
667
|
-
};
|
|
668
|
-
validateGlobalConfigDocumentStrict(candidate);
|
|
669
|
-
(0, atomic_write_1.atomicWriteFileSync)(path, JSON.stringify(candidate, null, 2), { mode: 0o600, fsync: true });
|
|
670
|
-
}, { waitMs: 10000 });
|
|
671
|
-
}
|
|
672
712
|
var usage_state_1 = require("./usage-state");
|
|
673
713
|
Object.defineProperty(exports, "incrementSessionCount", { enumerable: true, get: function () { return usage_state_1.incrementSessionCount; } });
|
|
674
714
|
Object.defineProperty(exports, "updateTokenStats", { enumerable: true, get: function () { return usage_state_1.updateTokenStats; } });
|