@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
package/dist/web/protocol.js
DELETED
|
@@ -1,639 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.WebProtocolError = exports.WEB_MAX_BODY_BYTES = exports.WEB_USER_GESTURE_HEADER = exports.WEB_NONCE_HEADER = exports.WEB_API_VERSION = void 0;
|
|
4
|
-
exports.parseWebSettingsUpdate = parseWebSettingsUpdate;
|
|
5
|
-
exports.parseWebOpenSettingsDocument = parseWebOpenSettingsDocument;
|
|
6
|
-
exports.parseWebContextActivate = parseWebContextActivate;
|
|
7
|
-
exports.parseWebComposerAction = parseWebComposerAction;
|
|
8
|
-
exports.parseWebCommand = parseWebCommand;
|
|
9
|
-
exports.toAgentRuntimeInput = toAgentRuntimeInput;
|
|
10
|
-
exports.projectSessionSummary = projectSessionSummary;
|
|
11
|
-
const canonical_1 = require("../runtime/protocol/canonical");
|
|
12
|
-
exports.WEB_API_VERSION = 1;
|
|
13
|
-
exports.WEB_NONCE_HEADER = 'x-orion-web-nonce';
|
|
14
|
-
exports.WEB_USER_GESTURE_HEADER = 'x-orion-user-gesture';
|
|
15
|
-
exports.WEB_MAX_BODY_BYTES = 1024 * 1024;
|
|
16
|
-
class WebProtocolError extends Error {
|
|
17
|
-
constructor(message, code = 'invalid_request') {
|
|
18
|
-
super(message);
|
|
19
|
-
this.code = code;
|
|
20
|
-
this.status = 400;
|
|
21
|
-
this.name = 'WebProtocolError';
|
|
22
|
-
}
|
|
23
|
-
}
|
|
24
|
-
exports.WebProtocolError = WebProtocolError;
|
|
25
|
-
const SETTINGS_REVISION_PATTERN = /^hmac-sha256:[a-f0-9]{64}$/u;
|
|
26
|
-
const UUID_PATTERN = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/iu;
|
|
27
|
-
const SETTINGS_MAX_OPERATIONS = 20;
|
|
28
|
-
const SETTINGS_MAX_BODY_BYTES = 64 * 1024;
|
|
29
|
-
function parseWebSettingsUpdate(value) {
|
|
30
|
-
try {
|
|
31
|
-
return parseWebSettingsUpdateValue(value);
|
|
32
|
-
}
|
|
33
|
-
catch (error) {
|
|
34
|
-
if (error instanceof WebProtocolError) {
|
|
35
|
-
throw new WebProtocolError(error.message, 'settings_invalid_operation');
|
|
36
|
-
}
|
|
37
|
-
throw error;
|
|
38
|
-
}
|
|
39
|
-
}
|
|
40
|
-
function parseWebOpenSettingsDocument(value) {
|
|
41
|
-
const row = requireRecord(value, 'Open Settings request');
|
|
42
|
-
assertOnlyKeys(row, ['requestId'], 'open Settings request');
|
|
43
|
-
const requestId = requireBoundedString(row.requestId, 'requestId', 128);
|
|
44
|
-
if (!UUID_PATTERN.test(requestId))
|
|
45
|
-
throw new WebProtocolError('requestId must be a UUID');
|
|
46
|
-
return Object.freeze({ requestId });
|
|
47
|
-
}
|
|
48
|
-
function parseWebContextActivate(value) {
|
|
49
|
-
const row = requireRecord(value, 'Context activation request');
|
|
50
|
-
assertOnlyKeys(row, ['requestId', 'expectedContextRevision', 'workspaceId', 'sessionId'], 'context activation request');
|
|
51
|
-
const requestId = requireBoundedString(row.requestId, 'requestId', 128);
|
|
52
|
-
if (!UUID_PATTERN.test(requestId))
|
|
53
|
-
throw new WebProtocolError('requestId must be a UUID');
|
|
54
|
-
const expectedContextRevision = requireBoundedString(row.expectedContextRevision, 'expectedContextRevision', 128);
|
|
55
|
-
if (!UUID_PATTERN.test(expectedContextRevision)) {
|
|
56
|
-
throw new WebProtocolError('expectedContextRevision must be a UUID');
|
|
57
|
-
}
|
|
58
|
-
const workspaceId = requireBoundedString(row.workspaceId, 'workspaceId', 128);
|
|
59
|
-
if (!UUID_PATTERN.test(workspaceId))
|
|
60
|
-
throw new WebProtocolError('workspaceId must be a UUID');
|
|
61
|
-
const sessionId = row.sessionId === null ? null : requireBoundedString(row.sessionId, 'sessionId', 256);
|
|
62
|
-
return Object.freeze({ requestId, expectedContextRevision, workspaceId, sessionId });
|
|
63
|
-
}
|
|
64
|
-
function parseWebComposerAction(value) {
|
|
65
|
-
const row = requireRecord(value, 'Composer action request');
|
|
66
|
-
const type = requireEnum(row.type, 'type', [
|
|
67
|
-
'set_agent_mode',
|
|
68
|
-
'set_permission_override',
|
|
69
|
-
'clear_permission_override',
|
|
70
|
-
'select_model',
|
|
71
|
-
'compact_context',
|
|
72
|
-
'review_plan',
|
|
73
|
-
'edit_queue_item',
|
|
74
|
-
'move_queue_item',
|
|
75
|
-
'remove_queue_item',
|
|
76
|
-
]);
|
|
77
|
-
const baseKeys = [
|
|
78
|
-
'requestId',
|
|
79
|
-
'workspaceId',
|
|
80
|
-
'expectedContextRevision',
|
|
81
|
-
'expectedSessionId',
|
|
82
|
-
'expectedSessionRuntimeRevision',
|
|
83
|
-
'expectedControlRevision',
|
|
84
|
-
'type',
|
|
85
|
-
];
|
|
86
|
-
const keysByType = {
|
|
87
|
-
set_agent_mode: ['mode'],
|
|
88
|
-
set_permission_override: ['value'],
|
|
89
|
-
clear_permission_override: [],
|
|
90
|
-
select_model: ['modelId', 'effort'],
|
|
91
|
-
compact_context: [],
|
|
92
|
-
review_plan: ['planDigest', 'action', 'feedback'],
|
|
93
|
-
edit_queue_item: ['itemId', 'expectedItemRevision', 'text'],
|
|
94
|
-
move_queue_item: ['itemId', 'expectedItemRevision', 'targetIndex'],
|
|
95
|
-
remove_queue_item: ['itemId', 'expectedItemRevision'],
|
|
96
|
-
};
|
|
97
|
-
assertOnlyKeys(row, [...baseKeys, ...keysByType[type]], 'Composer action');
|
|
98
|
-
const requestId = requireUuidString(row.requestId, 'requestId');
|
|
99
|
-
const workspaceId = requireUuidString(row.workspaceId, 'workspaceId');
|
|
100
|
-
const expectedContextRevision = requireUuidString(row.expectedContextRevision, 'expectedContextRevision');
|
|
101
|
-
const expectedSessionId = requireUuidString(row.expectedSessionId, 'expectedSessionId');
|
|
102
|
-
const expectedSessionRuntimeRevision = requireUuidString(row.expectedSessionRuntimeRevision, 'expectedSessionRuntimeRevision');
|
|
103
|
-
const expectedControlRevision = requireUuidString(row.expectedControlRevision, 'expectedControlRevision');
|
|
104
|
-
const base = {
|
|
105
|
-
requestId,
|
|
106
|
-
workspaceId,
|
|
107
|
-
expectedContextRevision,
|
|
108
|
-
expectedSessionId,
|
|
109
|
-
expectedSessionRuntimeRevision,
|
|
110
|
-
expectedControlRevision,
|
|
111
|
-
};
|
|
112
|
-
switch (type) {
|
|
113
|
-
case 'set_agent_mode':
|
|
114
|
-
return Object.freeze({
|
|
115
|
-
...base,
|
|
116
|
-
type,
|
|
117
|
-
mode: requireEnum(row.mode, 'mode', ['interactive', 'plan', 'auto']),
|
|
118
|
-
});
|
|
119
|
-
case 'set_permission_override':
|
|
120
|
-
return Object.freeze({
|
|
121
|
-
...base,
|
|
122
|
-
type,
|
|
123
|
-
value: requireEnum(row.value, 'value', ['ask', 'allow', 'deny']),
|
|
124
|
-
});
|
|
125
|
-
case 'clear_permission_override':
|
|
126
|
-
case 'compact_context':
|
|
127
|
-
return Object.freeze({ ...base, type });
|
|
128
|
-
case 'select_model':
|
|
129
|
-
return Object.freeze({
|
|
130
|
-
...base,
|
|
131
|
-
type,
|
|
132
|
-
modelId: requireBoundedString(row.modelId, 'modelId', 256),
|
|
133
|
-
...(row.effort === undefined
|
|
134
|
-
? {}
|
|
135
|
-
: {
|
|
136
|
-
effort: requireEnum(row.effort, 'effort', [
|
|
137
|
-
'auto',
|
|
138
|
-
'none',
|
|
139
|
-
'minimal',
|
|
140
|
-
'low',
|
|
141
|
-
'medium',
|
|
142
|
-
'high',
|
|
143
|
-
'xhigh',
|
|
144
|
-
'max',
|
|
145
|
-
]),
|
|
146
|
-
}),
|
|
147
|
-
});
|
|
148
|
-
case 'review_plan': {
|
|
149
|
-
const action = requireEnum(row.action, 'action', ['approve', 'continue', 'cancel']);
|
|
150
|
-
const feedback = row.feedback === undefined
|
|
151
|
-
? undefined
|
|
152
|
-
: requireBoundedString(row.feedback, 'feedback', exports.WEB_MAX_BODY_BYTES);
|
|
153
|
-
if (action === 'continue' && !feedback) {
|
|
154
|
-
throw new WebProtocolError('continue plan review requires feedback');
|
|
155
|
-
}
|
|
156
|
-
if (action !== 'continue' && feedback) {
|
|
157
|
-
throw new WebProtocolError('feedback is accepted only when continuing plan review');
|
|
158
|
-
}
|
|
159
|
-
return Object.freeze({
|
|
160
|
-
...base,
|
|
161
|
-
type,
|
|
162
|
-
planDigest: requireBoundedString(row.planDigest, 'planDigest', 128),
|
|
163
|
-
action,
|
|
164
|
-
...(feedback ? { feedback } : {}),
|
|
165
|
-
});
|
|
166
|
-
}
|
|
167
|
-
case 'edit_queue_item':
|
|
168
|
-
return Object.freeze({
|
|
169
|
-
...base,
|
|
170
|
-
type,
|
|
171
|
-
itemId: requireBoundedString(row.itemId, 'itemId', 256),
|
|
172
|
-
expectedItemRevision: requirePositiveInteger(row.expectedItemRevision, 'expectedItemRevision'),
|
|
173
|
-
text: requireBoundedString(row.text, 'text', exports.WEB_MAX_BODY_BYTES),
|
|
174
|
-
});
|
|
175
|
-
case 'move_queue_item':
|
|
176
|
-
return Object.freeze({
|
|
177
|
-
...base,
|
|
178
|
-
type,
|
|
179
|
-
itemId: requireBoundedString(row.itemId, 'itemId', 256),
|
|
180
|
-
expectedItemRevision: requirePositiveInteger(row.expectedItemRevision, 'expectedItemRevision'),
|
|
181
|
-
targetIndex: requireNonNegativeInteger(row.targetIndex, 'targetIndex'),
|
|
182
|
-
});
|
|
183
|
-
case 'remove_queue_item':
|
|
184
|
-
return Object.freeze({
|
|
185
|
-
...base,
|
|
186
|
-
type,
|
|
187
|
-
itemId: requireBoundedString(row.itemId, 'itemId', 256),
|
|
188
|
-
expectedItemRevision: requirePositiveInteger(row.expectedItemRevision, 'expectedItemRevision'),
|
|
189
|
-
});
|
|
190
|
-
}
|
|
191
|
-
}
|
|
192
|
-
function parseWebSettingsUpdateValue(value) {
|
|
193
|
-
const row = requireRecord(value, 'Settings request');
|
|
194
|
-
assertOnlyKeys(row, ['requestId', 'workspaceId', 'expectedContextRevision', 'expectedRevision', 'operations'], 'settings');
|
|
195
|
-
if (Buffer.byteLength(JSON.stringify(row), 'utf8') > SETTINGS_MAX_BODY_BYTES) {
|
|
196
|
-
throw new WebProtocolError(`Settings request exceeds ${SETTINGS_MAX_BODY_BYTES} bytes`);
|
|
197
|
-
}
|
|
198
|
-
const requestId = requireBoundedString(row.requestId, 'requestId', 128);
|
|
199
|
-
if (!UUID_PATTERN.test(requestId))
|
|
200
|
-
throw new WebProtocolError('requestId must be a UUID');
|
|
201
|
-
const workspaceId = requireUuidString(row.workspaceId, 'workspaceId');
|
|
202
|
-
const expectedContextRevision = requireUuidString(row.expectedContextRevision, 'expectedContextRevision');
|
|
203
|
-
const expectedRevision = requireBoundedString(row.expectedRevision, 'expectedRevision', 128);
|
|
204
|
-
if (!SETTINGS_REVISION_PATTERN.test(expectedRevision)) {
|
|
205
|
-
throw new WebProtocolError('expectedRevision is not a valid Settings revision');
|
|
206
|
-
}
|
|
207
|
-
if (!Array.isArray(row.operations) ||
|
|
208
|
-
row.operations.length < 1 ||
|
|
209
|
-
row.operations.length > SETTINGS_MAX_OPERATIONS) {
|
|
210
|
-
throw new WebProtocolError(`operations must contain between 1 and ${SETTINGS_MAX_OPERATIONS} entries`);
|
|
211
|
-
}
|
|
212
|
-
const seen = new Set();
|
|
213
|
-
const operations = row.operations.map((entry, index) => {
|
|
214
|
-
const operation = parseSettingsOperation(entry, index);
|
|
215
|
-
if (seen.has(operation.key)) {
|
|
216
|
-
throw new WebProtocolError(`Settings key appears more than once: ${operation.key}`);
|
|
217
|
-
}
|
|
218
|
-
seen.add(operation.key);
|
|
219
|
-
return operation;
|
|
220
|
-
});
|
|
221
|
-
return Object.freeze({
|
|
222
|
-
requestId,
|
|
223
|
-
workspaceId,
|
|
224
|
-
expectedContextRevision,
|
|
225
|
-
expectedRevision,
|
|
226
|
-
operations: Object.freeze(operations),
|
|
227
|
-
});
|
|
228
|
-
}
|
|
229
|
-
function parseSettingsOperation(value, index) {
|
|
230
|
-
const row = requireRecord(value, `operations[${index}]`);
|
|
231
|
-
const op = requireEnum(row.op, `operations[${index}].op`, ['set', 'unset']);
|
|
232
|
-
const key = requireEnum(row.key, `operations[${index}].key`, [
|
|
233
|
-
'appearance.style',
|
|
234
|
-
'appearance.theme',
|
|
235
|
-
'appearance.motion',
|
|
236
|
-
'defaults.model',
|
|
237
|
-
'defaults.effort',
|
|
238
|
-
'permissions.toolConfirmation',
|
|
239
|
-
]);
|
|
240
|
-
assertOnlyKeys(row, op === 'set' ? ['op', 'key', 'value'] : ['op', 'key'], 'settings operation');
|
|
241
|
-
if (op === 'unset')
|
|
242
|
-
return { op, key };
|
|
243
|
-
if (row.value === undefined) {
|
|
244
|
-
throw new WebProtocolError(`operations[${index}].value is required for set`);
|
|
245
|
-
}
|
|
246
|
-
switch (key) {
|
|
247
|
-
case 'appearance.style':
|
|
248
|
-
return {
|
|
249
|
-
op,
|
|
250
|
-
key,
|
|
251
|
-
value: requireEnum(row.value, `operations[${index}].value`, [
|
|
252
|
-
'classic',
|
|
253
|
-
'orion-blocksmith',
|
|
254
|
-
]),
|
|
255
|
-
};
|
|
256
|
-
case 'appearance.theme':
|
|
257
|
-
return {
|
|
258
|
-
op,
|
|
259
|
-
key,
|
|
260
|
-
value: requireEnum(row.value, `operations[${index}].value`, [
|
|
261
|
-
'system',
|
|
262
|
-
'light',
|
|
263
|
-
'dark',
|
|
264
|
-
]),
|
|
265
|
-
};
|
|
266
|
-
case 'appearance.motion':
|
|
267
|
-
return {
|
|
268
|
-
op,
|
|
269
|
-
key,
|
|
270
|
-
value: requireEnum(row.value, `operations[${index}].value`, ['system', 'reduced']),
|
|
271
|
-
};
|
|
272
|
-
case 'defaults.model':
|
|
273
|
-
return { op, key, value: requireBoundedString(row.value, 'model', 200) };
|
|
274
|
-
case 'defaults.effort':
|
|
275
|
-
return {
|
|
276
|
-
op,
|
|
277
|
-
key,
|
|
278
|
-
value: requireEnum(row.value, `operations[${index}].value`, [
|
|
279
|
-
'auto',
|
|
280
|
-
'none',
|
|
281
|
-
'minimal',
|
|
282
|
-
'low',
|
|
283
|
-
'medium',
|
|
284
|
-
'high',
|
|
285
|
-
'xhigh',
|
|
286
|
-
'max',
|
|
287
|
-
]),
|
|
288
|
-
};
|
|
289
|
-
case 'permissions.toolConfirmation':
|
|
290
|
-
return {
|
|
291
|
-
op,
|
|
292
|
-
key,
|
|
293
|
-
value: requireEnum(row.value, `operations[${index}].value`, [
|
|
294
|
-
'allow',
|
|
295
|
-
'ask',
|
|
296
|
-
'deny',
|
|
297
|
-
]),
|
|
298
|
-
};
|
|
299
|
-
}
|
|
300
|
-
}
|
|
301
|
-
function parseWebCommand(value) {
|
|
302
|
-
const row = requireRecord(value, 'Command body');
|
|
303
|
-
assertOnlyKeys(row, [
|
|
304
|
-
'requestId',
|
|
305
|
-
'workspaceId',
|
|
306
|
-
'expectedContextRevision',
|
|
307
|
-
'expectedSessionId',
|
|
308
|
-
'expectedSessionRuntimeRevision',
|
|
309
|
-
'type',
|
|
310
|
-
'text',
|
|
311
|
-
'queueId',
|
|
312
|
-
'itemId',
|
|
313
|
-
'requestPermissionId',
|
|
314
|
-
'approved',
|
|
315
|
-
'scope',
|
|
316
|
-
'goalAction',
|
|
317
|
-
'objective',
|
|
318
|
-
'toolConfirmation',
|
|
319
|
-
'agentMode',
|
|
320
|
-
'contextReferences',
|
|
321
|
-
]);
|
|
322
|
-
const requestId = requireBoundedString(row.requestId, 'requestId', 128);
|
|
323
|
-
if (!UUID_PATTERN.test(requestId))
|
|
324
|
-
throw new WebProtocolError('requestId must be a UUID');
|
|
325
|
-
const workspaceId = requireUuidString(row.workspaceId, 'workspaceId');
|
|
326
|
-
const expectedContextRevision = requireUuidString(row.expectedContextRevision, 'expectedContextRevision');
|
|
327
|
-
const expectedSessionId = requireUuidString(row.expectedSessionId, 'expectedSessionId');
|
|
328
|
-
const expectedSessionRuntimeRevision = requireUuidString(row.expectedSessionRuntimeRevision, 'expectedSessionRuntimeRevision');
|
|
329
|
-
const type = requireEnum(row.type, 'type', [
|
|
330
|
-
'submit',
|
|
331
|
-
'cancel_queued_turn',
|
|
332
|
-
'queue_followup',
|
|
333
|
-
'remove_followup',
|
|
334
|
-
'clear_followups',
|
|
335
|
-
'interrupt',
|
|
336
|
-
'permission_decision',
|
|
337
|
-
'goal_control',
|
|
338
|
-
'permission_mode_change',
|
|
339
|
-
'cycle_agent_mode',
|
|
340
|
-
'set_agent_mode',
|
|
341
|
-
]);
|
|
342
|
-
const command = {
|
|
343
|
-
requestId,
|
|
344
|
-
workspaceId,
|
|
345
|
-
expectedContextRevision,
|
|
346
|
-
expectedSessionId,
|
|
347
|
-
expectedSessionRuntimeRevision,
|
|
348
|
-
type,
|
|
349
|
-
...(row.text === undefined
|
|
350
|
-
? {}
|
|
351
|
-
: { text: requireBoundedString(row.text, 'text', exports.WEB_MAX_BODY_BYTES) }),
|
|
352
|
-
...(row.queueId === undefined ? {} : { queueId: requireUuidString(row.queueId, 'queueId') }),
|
|
353
|
-
...(row.itemId === undefined
|
|
354
|
-
? {}
|
|
355
|
-
: { itemId: requireBoundedString(row.itemId, 'itemId', 256) }),
|
|
356
|
-
...(row.requestPermissionId === undefined
|
|
357
|
-
? {}
|
|
358
|
-
: {
|
|
359
|
-
requestPermissionId: requireBoundedString(row.requestPermissionId, 'requestPermissionId', 256),
|
|
360
|
-
}),
|
|
361
|
-
...(row.approved === undefined ? {} : { approved: requireBoolean(row.approved, 'approved') }),
|
|
362
|
-
...(row.scope === undefined
|
|
363
|
-
? {}
|
|
364
|
-
: { scope: requireEnum(row.scope, 'scope', ['once', 'project', 'global']) }),
|
|
365
|
-
...(row.goalAction === undefined
|
|
366
|
-
? {}
|
|
367
|
-
: {
|
|
368
|
-
goalAction: requireEnum(row.goalAction, 'goalAction', [
|
|
369
|
-
'create',
|
|
370
|
-
'status',
|
|
371
|
-
'pause',
|
|
372
|
-
'resume',
|
|
373
|
-
'clear',
|
|
374
|
-
]),
|
|
375
|
-
}),
|
|
376
|
-
...(row.objective === undefined
|
|
377
|
-
? {}
|
|
378
|
-
: { objective: requireBoundedString(row.objective, 'objective', exports.WEB_MAX_BODY_BYTES) }),
|
|
379
|
-
...(row.toolConfirmation === undefined
|
|
380
|
-
? {}
|
|
381
|
-
: {
|
|
382
|
-
toolConfirmation: requireEnum(row.toolConfirmation, 'toolConfirmation', [
|
|
383
|
-
'allow',
|
|
384
|
-
'ask',
|
|
385
|
-
'deny',
|
|
386
|
-
]),
|
|
387
|
-
}),
|
|
388
|
-
...(row.agentMode === undefined
|
|
389
|
-
? {}
|
|
390
|
-
: {
|
|
391
|
-
agentMode: requireEnum(row.agentMode, 'agentMode', [
|
|
392
|
-
'interactive',
|
|
393
|
-
'plan',
|
|
394
|
-
'auto',
|
|
395
|
-
]),
|
|
396
|
-
}),
|
|
397
|
-
...(row.contextReferences === undefined
|
|
398
|
-
? {}
|
|
399
|
-
: { contextReferences: parseContextReferences(row.contextReferences) }),
|
|
400
|
-
};
|
|
401
|
-
validateCommandFields(command);
|
|
402
|
-
return Object.freeze(command);
|
|
403
|
-
}
|
|
404
|
-
function toAgentRuntimeInput(command) {
|
|
405
|
-
switch (command.type) {
|
|
406
|
-
case 'submit':
|
|
407
|
-
return { type: 'submit', text: command.text, source: 'programmatic' };
|
|
408
|
-
case 'cancel_queued_turn':
|
|
409
|
-
throw new WebProtocolError('cancel_queued_turn is handled by the Web Session registry');
|
|
410
|
-
case 'queue_followup':
|
|
411
|
-
return { type: 'queue_followup', text: command.text, source: 'programmatic' };
|
|
412
|
-
case 'remove_followup':
|
|
413
|
-
return {
|
|
414
|
-
type: 'manage_followup_queue',
|
|
415
|
-
action: 'remove',
|
|
416
|
-
itemId: command.itemId,
|
|
417
|
-
source: 'programmatic',
|
|
418
|
-
};
|
|
419
|
-
case 'clear_followups':
|
|
420
|
-
return { type: 'manage_followup_queue', action: 'clear', source: 'programmatic' };
|
|
421
|
-
case 'interrupt':
|
|
422
|
-
return { type: 'interrupt', source: 'programmatic' };
|
|
423
|
-
case 'permission_decision':
|
|
424
|
-
return {
|
|
425
|
-
type: 'permission_decision',
|
|
426
|
-
requestId: command.requestPermissionId,
|
|
427
|
-
approved: command.approved,
|
|
428
|
-
scope: command.scope,
|
|
429
|
-
source: 'programmatic',
|
|
430
|
-
};
|
|
431
|
-
case 'goal_control':
|
|
432
|
-
return goalControlInput(command);
|
|
433
|
-
case 'permission_mode_change':
|
|
434
|
-
return {
|
|
435
|
-
type: 'permission_mode_change',
|
|
436
|
-
value: command.toolConfirmation,
|
|
437
|
-
source: 'programmatic',
|
|
438
|
-
};
|
|
439
|
-
case 'cycle_agent_mode':
|
|
440
|
-
return { type: 'cycle_agent_mode', source: 'programmatic' };
|
|
441
|
-
case 'set_agent_mode':
|
|
442
|
-
return {
|
|
443
|
-
type: 'set_agent_mode',
|
|
444
|
-
mode: command.agentMode,
|
|
445
|
-
source: 'programmatic',
|
|
446
|
-
};
|
|
447
|
-
}
|
|
448
|
-
}
|
|
449
|
-
function projectSessionSummary(session) {
|
|
450
|
-
const createdAt = session.createdAt ?? new Date(session.startTime).toISOString();
|
|
451
|
-
const updatedAt = session.updatedAtIso ?? new Date(session.updatedAt ?? session.startTime).toISOString();
|
|
452
|
-
return Object.freeze({
|
|
453
|
-
id: session.id,
|
|
454
|
-
projectPath: session.projectPath,
|
|
455
|
-
...(session.name ? { name: session.name } : {}),
|
|
456
|
-
model: session.model,
|
|
457
|
-
createdAt,
|
|
458
|
-
updatedAt,
|
|
459
|
-
messageCount: session.messageCount ?? 0,
|
|
460
|
-
contextDigest: session.threadReadModel?.projectionDigest ??
|
|
461
|
-
(0, canonical_1.digestRuntimeValue)({
|
|
462
|
-
sessionId: session.id,
|
|
463
|
-
updatedAt,
|
|
464
|
-
messageCount: session.messageCount ?? 0,
|
|
465
|
-
}),
|
|
466
|
-
...(session.taskSummary ? { taskSummary: session.taskSummary } : {}),
|
|
467
|
-
...(session.tags && session.tags.length > 0 ? { tags: Object.freeze([...session.tags]) } : {}),
|
|
468
|
-
...(session.activeGoalId ? { activeGoalId: session.activeGoalId } : {}),
|
|
469
|
-
...(session.activeGoalObjective ? { activeGoalObjective: session.activeGoalObjective } : {}),
|
|
470
|
-
});
|
|
471
|
-
}
|
|
472
|
-
function goalControlInput(command) {
|
|
473
|
-
const action = command.goalAction;
|
|
474
|
-
if (action === 'create') {
|
|
475
|
-
return {
|
|
476
|
-
type: 'goal_control',
|
|
477
|
-
action,
|
|
478
|
-
objective: command.objective,
|
|
479
|
-
source: 'programmatic',
|
|
480
|
-
};
|
|
481
|
-
}
|
|
482
|
-
return { type: 'goal_control', action, source: 'programmatic' };
|
|
483
|
-
}
|
|
484
|
-
function validateCommandFields(command) {
|
|
485
|
-
if (command.contextReferences?.length &&
|
|
486
|
-
command.type !== 'submit' &&
|
|
487
|
-
command.type !== 'queue_followup') {
|
|
488
|
-
throw new WebProtocolError('contextReferences are only valid for submit or queue_followup');
|
|
489
|
-
}
|
|
490
|
-
if ((command.type === 'submit' || command.type === 'queue_followup') && !command.text?.trim()) {
|
|
491
|
-
throw new WebProtocolError(`${command.type} requires non-empty text`);
|
|
492
|
-
}
|
|
493
|
-
if (command.type === 'cancel_queued_turn' && !command.queueId) {
|
|
494
|
-
throw new WebProtocolError('cancel_queued_turn requires queueId');
|
|
495
|
-
}
|
|
496
|
-
if (command.type === 'remove_followup' && !command.itemId) {
|
|
497
|
-
throw new WebProtocolError('remove_followup requires itemId');
|
|
498
|
-
}
|
|
499
|
-
if (command.type === 'permission_decision' &&
|
|
500
|
-
(!command.requestPermissionId || typeof command.approved !== 'boolean')) {
|
|
501
|
-
throw new WebProtocolError('permission_decision requires requestPermissionId and approved');
|
|
502
|
-
}
|
|
503
|
-
if (command.type === 'goal_control') {
|
|
504
|
-
if (!command.goalAction)
|
|
505
|
-
throw new WebProtocolError('goal_control requires goalAction');
|
|
506
|
-
if (command.goalAction === 'create' && !command.objective?.trim()) {
|
|
507
|
-
throw new WebProtocolError('Goal creation requires a non-empty objective');
|
|
508
|
-
}
|
|
509
|
-
}
|
|
510
|
-
if (command.type === 'permission_mode_change' && !command.toolConfirmation) {
|
|
511
|
-
throw new WebProtocolError('permission_mode_change requires toolConfirmation');
|
|
512
|
-
}
|
|
513
|
-
if (command.type === 'set_agent_mode' && !command.agentMode) {
|
|
514
|
-
throw new WebProtocolError('set_agent_mode requires agentMode');
|
|
515
|
-
}
|
|
516
|
-
}
|
|
517
|
-
function parseContextReferences(value) {
|
|
518
|
-
if (!Array.isArray(value) || value.length > 20) {
|
|
519
|
-
throw new WebProtocolError('contextReferences must contain at most 20 entries');
|
|
520
|
-
}
|
|
521
|
-
const seen = new Set();
|
|
522
|
-
return Object.freeze(value.map((entry, index) => {
|
|
523
|
-
const row = requireRecord(entry, `contextReferences[${index}]`);
|
|
524
|
-
const kind = requireEnum(row.kind, `contextReferences[${index}].kind`, [
|
|
525
|
-
'file',
|
|
526
|
-
'file_range',
|
|
527
|
-
'folder',
|
|
528
|
-
'review',
|
|
529
|
-
'session',
|
|
530
|
-
'skill',
|
|
531
|
-
]);
|
|
532
|
-
const id = requireBoundedString(row.id, `contextReferences[${index}].id`, 256);
|
|
533
|
-
if (seen.has(`${kind}:${id}`)) {
|
|
534
|
-
throw new WebProtocolError(`Duplicate Context reference: ${kind}:${id}`);
|
|
535
|
-
}
|
|
536
|
-
seen.add(`${kind}:${id}`);
|
|
537
|
-
const label = requireBoundedString(row.label, `contextReferences[${index}].label`, 200);
|
|
538
|
-
if (kind === 'file_range') {
|
|
539
|
-
assertOnlyKeys(row, ['kind', 'id', 'label', 'revision', 'startLine', 'endLine'], 'Context reference');
|
|
540
|
-
const startLine = requireLineNumber(row.startLine, `contextReferences[${index}].startLine`);
|
|
541
|
-
const endLine = requireLineNumber(row.endLine, `contextReferences[${index}].endLine`);
|
|
542
|
-
if (endLine < startLine) {
|
|
543
|
-
throw new WebProtocolError('file_range endLine must not precede startLine');
|
|
544
|
-
}
|
|
545
|
-
return Object.freeze({
|
|
546
|
-
kind,
|
|
547
|
-
id,
|
|
548
|
-
label,
|
|
549
|
-
revision: requireBoundedString(row.revision, `contextReferences[${index}].revision`, 256),
|
|
550
|
-
startLine,
|
|
551
|
-
endLine,
|
|
552
|
-
});
|
|
553
|
-
}
|
|
554
|
-
if (kind === 'file' || kind === 'folder') {
|
|
555
|
-
assertOnlyKeys(row, ['kind', 'id', 'label', 'revision'], 'Context reference');
|
|
556
|
-
return Object.freeze({
|
|
557
|
-
kind,
|
|
558
|
-
id,
|
|
559
|
-
label,
|
|
560
|
-
revision: requireBoundedString(row.revision, `contextReferences[${index}].revision`, 256),
|
|
561
|
-
});
|
|
562
|
-
}
|
|
563
|
-
if (kind === 'review') {
|
|
564
|
-
assertOnlyKeys(row, ['kind', 'id', 'label', 'gitRevision'], 'Context reference');
|
|
565
|
-
return Object.freeze({
|
|
566
|
-
kind,
|
|
567
|
-
id,
|
|
568
|
-
label,
|
|
569
|
-
gitRevision: requireBoundedString(row.gitRevision, `contextReferences[${index}].gitRevision`, 256),
|
|
570
|
-
});
|
|
571
|
-
}
|
|
572
|
-
assertOnlyKeys(row, ['kind', 'id', 'label', 'digest'], 'Context reference');
|
|
573
|
-
return Object.freeze({
|
|
574
|
-
kind,
|
|
575
|
-
id,
|
|
576
|
-
label,
|
|
577
|
-
digest: requireBoundedString(row.digest, `contextReferences[${index}].digest`, 128),
|
|
578
|
-
});
|
|
579
|
-
}));
|
|
580
|
-
}
|
|
581
|
-
function requireRecord(value, name) {
|
|
582
|
-
if (!value || typeof value !== 'object' || Array.isArray(value)) {
|
|
583
|
-
throw new WebProtocolError(`${name} must be an object`);
|
|
584
|
-
}
|
|
585
|
-
return value;
|
|
586
|
-
}
|
|
587
|
-
function assertOnlyKeys(row, keys, subject = 'command') {
|
|
588
|
-
const allowed = new Set(keys);
|
|
589
|
-
const unknown = Object.keys(row).find(key => !allowed.has(key));
|
|
590
|
-
if (unknown)
|
|
591
|
-
throw new WebProtocolError(`Unknown ${subject} field: ${unknown}`);
|
|
592
|
-
}
|
|
593
|
-
function requireLineNumber(value, name) {
|
|
594
|
-
if (typeof value !== 'number' ||
|
|
595
|
-
!Number.isSafeInteger(value) ||
|
|
596
|
-
value < 1 ||
|
|
597
|
-
value > 100000000) {
|
|
598
|
-
throw new WebProtocolError(`${name} must be an integer line number from 1 through 100000000`);
|
|
599
|
-
}
|
|
600
|
-
return value;
|
|
601
|
-
}
|
|
602
|
-
function requireBoundedString(value, name, maxLength) {
|
|
603
|
-
if (typeof value !== 'string' || !value.trim()) {
|
|
604
|
-
throw new WebProtocolError(`${name} must be a non-empty string`);
|
|
605
|
-
}
|
|
606
|
-
if (value.length > maxLength)
|
|
607
|
-
throw new WebProtocolError(`${name} exceeds ${maxLength} bytes`);
|
|
608
|
-
return value;
|
|
609
|
-
}
|
|
610
|
-
function requireUuidString(value, name) {
|
|
611
|
-
const result = requireBoundedString(value, name, 128);
|
|
612
|
-
if (!UUID_PATTERN.test(result))
|
|
613
|
-
throw new WebProtocolError(`${name} must be a UUID`);
|
|
614
|
-
return result;
|
|
615
|
-
}
|
|
616
|
-
function requireNonNegativeInteger(value, name) {
|
|
617
|
-
if (!Number.isSafeInteger(value) || value < 0) {
|
|
618
|
-
throw new WebProtocolError(`${name} must be a non-negative safe integer`);
|
|
619
|
-
}
|
|
620
|
-
return value;
|
|
621
|
-
}
|
|
622
|
-
function requirePositiveInteger(value, name) {
|
|
623
|
-
if (!Number.isSafeInteger(value) || value <= 0) {
|
|
624
|
-
throw new WebProtocolError(`${name} must be a positive safe integer`);
|
|
625
|
-
}
|
|
626
|
-
return value;
|
|
627
|
-
}
|
|
628
|
-
function requireBoolean(value, name) {
|
|
629
|
-
if (typeof value !== 'boolean')
|
|
630
|
-
throw new WebProtocolError(`${name} must be a boolean`);
|
|
631
|
-
return value;
|
|
632
|
-
}
|
|
633
|
-
function requireEnum(value, name, allowed) {
|
|
634
|
-
if (typeof value !== 'string' || !allowed.includes(value)) {
|
|
635
|
-
throw new WebProtocolError(`${name} must be one of: ${allowed.join(', ')}`);
|
|
636
|
-
}
|
|
637
|
-
return value;
|
|
638
|
-
}
|
|
639
|
-
//# sourceMappingURL=protocol.js.map
|
|
@@ -1,22 +0,0 @@
|
|
|
1
|
-
import type { GitReadModelServiceV1, WebGitDiffPageV1, WebGitFileV1 } from './git-read-model-service';
|
|
2
|
-
export interface WebReviewSnapshotV1 {
|
|
3
|
-
readonly revision: string;
|
|
4
|
-
readonly repositoryRevision: string;
|
|
5
|
-
readonly isRepository: boolean;
|
|
6
|
-
readonly clean: boolean;
|
|
7
|
-
readonly changedFiles: readonly WebGitFileV1[];
|
|
8
|
-
readonly totalChangedFiles: number;
|
|
9
|
-
readonly stagedCount: number;
|
|
10
|
-
readonly unstagedCount: number;
|
|
11
|
-
readonly untrackedCount: number;
|
|
12
|
-
readonly conflictCount: number;
|
|
13
|
-
readonly truncated: boolean;
|
|
14
|
-
}
|
|
15
|
-
/** Review overview composed only from Git facts. */
|
|
16
|
-
export declare class ReviewServiceV1 {
|
|
17
|
-
private readonly git;
|
|
18
|
-
constructor(git: GitReadModelServiceV1);
|
|
19
|
-
snapshot(): Promise<WebReviewSnapshotV1>;
|
|
20
|
-
diff(input: Parameters<GitReadModelServiceV1['diff']>[0]): Promise<WebGitDiffPageV1>;
|
|
21
|
-
}
|
|
22
|
-
//# sourceMappingURL=review-service.d.ts.map
|