@orion-agents/orion-code 0.3.65 → 0.4.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +128 -2
- package/README.md +78 -361
- package/README.zh-CN.md +71 -263
- package/bin/orion +4 -1
- package/dist/acp/session-updates.d.ts +34 -0
- package/dist/acp/session-updates.js +162 -0
- package/dist/acp/sessions.d.ts +32 -0
- package/dist/acp/sessions.js +315 -0
- package/dist/acp/stdio.d.ts +3 -0
- package/dist/acp/stdio.js +59 -0
- package/dist/cli.js +136 -185
- package/dist/commands/context-tool-command-handlers.d.ts +1 -1
- package/dist/commands/context-tool-command-handlers.js +24 -3
- package/dist/commands/core-command-handlers.js +5 -1
- package/dist/commands/diagnostic-command-handlers.js +20 -6
- package/dist/commands/diagnostic-commands.js +0 -12
- package/dist/commands/init-command.d.ts +3 -0
- package/dist/commands/init-command.js +131 -0
- package/dist/commands/model-command-handlers.d.ts +1 -2
- package/dist/commands/model-command-handlers.js +15 -100
- package/dist/commands/model-commands.js +0 -11
- package/dist/commands/registry.js +0 -18
- package/dist/commands/rsi-command.d.ts +2 -0
- package/dist/commands/rsi-command.js +180 -0
- package/dist/commands/session-command-handlers.js +28 -19
- package/dist/commands/system-commands.js +0 -1
- package/dist/commands/tool-commands.js +1 -1
- package/dist/commands/types.d.ts +4 -10
- package/dist/commands/types.js +1 -21
- package/dist/commands/workflow-command-handlers.js +13 -4
- package/dist/framework/loop-budget-contract.d.ts +7 -2
- package/dist/framework/loop-budget-contract.js +4 -1
- package/dist/framework/loop-progress.d.ts +22 -0
- package/dist/framework/loop-progress.js +79 -0
- package/dist/framework/prompt.d.ts +0 -2
- package/dist/framework/prompt.js +9 -27
- package/dist/framework/query.d.ts +27 -20
- package/dist/framework/query.js +453 -153
- package/dist/framework/store.d.ts +6 -10
- package/dist/framework/store.js +2 -21
- package/dist/framework/tool-call-orchestrator.d.ts +7 -0
- package/dist/framework/tool-call-orchestrator.js +8 -3
- package/dist/framework/tool-state.d.ts +2 -0
- package/dist/framework/tool.d.ts +0 -23
- package/dist/framework/verification-command.d.ts +15 -0
- package/dist/framework/verification-command.js +32 -0
- package/dist/harness/assembler.d.ts +1 -0
- package/dist/harness/assembler.js +24 -0
- package/dist/harness/capsule.d.ts +1 -1
- package/dist/harness/capsule.js +33 -14
- package/dist/harness/context-harness.d.ts +31 -12
- package/dist/harness/context-harness.js +491 -35
- package/dist/harness/contract.js +1 -1
- package/dist/harness/drift-guard.d.ts +4 -0
- package/dist/harness/drift-guard.js +68 -16
- package/dist/harness/intent.js +21 -0
- package/dist/harness/ledger.d.ts +6 -11
- package/dist/harness/ledger.js +39 -9
- package/dist/harness/progress-controller.d.ts +12 -7
- package/dist/harness/progress-controller.js +66 -21
- package/dist/harness/state.js +9 -1
- package/dist/harness/task-checklist.d.ts +16 -0
- package/dist/harness/task-checklist.js +95 -0
- package/dist/harness/types.d.ts +73 -1
- package/dist/harness/verification.d.ts +19 -1
- package/dist/harness/verification.js +116 -29
- package/dist/index.d.ts +1 -1
- package/dist/index.js +1 -3
- package/dist/print-ui/event-stream.d.ts +38 -0
- package/dist/print-ui/event-stream.js +187 -0
- package/dist/print-ui/launch.d.ts +12 -1
- package/dist/print-ui/launch.js +173 -11
- package/dist/product/environment.d.ts +1 -1
- package/dist/product/environment.js +1 -1
- package/dist/product/identity.d.ts +1 -1
- package/dist/product/identity.js +1 -1
- package/dist/product/paths.d.ts +3 -2
- package/dist/product/paths.js +6 -2
- package/dist/runtime/agent-loop.d.ts +11 -2
- package/dist/runtime/agent-loop.js +165 -25
- package/dist/runtime/agent-runtime-controller.d.ts +13 -3
- package/dist/runtime/agent-runtime-controller.js +347 -183
- package/dist/runtime/agent-runtime-protocol.d.ts +10 -18
- package/dist/runtime/agent-runtime-runner.d.ts +10 -0
- package/dist/runtime/builtin-tool-provider.js +5 -1
- package/dist/runtime/capability-receipt-journal.js +1 -0
- package/dist/runtime/durable-tool-receipt-reader.js +2 -1
- package/dist/runtime/first-party-tool-services.d.ts +1 -0
- package/dist/runtime/first-party-tool-services.js +2 -12
- package/dist/runtime/first-party-tool-universe.d.ts +1 -0
- package/dist/runtime/first-party-tool-universe.js +1 -1
- package/dist/runtime/followup-queue-store.d.ts +16 -0
- package/dist/runtime/followup-queue-store.js +75 -0
- package/dist/runtime/goal-lifecycle-v2.d.ts +11 -1
- package/dist/runtime/goal-lifecycle-v2.js +85 -15
- package/dist/runtime/goal-runtime-coordinator.d.ts +10 -1
- package/dist/runtime/goal-runtime-coordinator.js +81 -24
- package/dist/runtime/loop-budget.js +7 -5
- package/dist/runtime/mcp/first-party-mcp-adapter.d.ts +2 -0
- package/dist/runtime/mcp/first-party-mcp-adapter.js +23 -19
- package/dist/runtime/model-coordinator.js +2 -5
- package/dist/runtime/orion-runtime-v1.d.ts +18 -2
- package/dist/runtime/orion-runtime-v1.js +135 -39
- package/dist/runtime/orion-session-runner.d.ts +7 -0
- package/dist/runtime/orion-session-runner.js +82 -0
- package/dist/runtime/plan-review.d.ts +1 -0
- package/dist/runtime/plan-review.js +8 -4
- package/dist/runtime/product-bootstrap.d.ts +6 -0
- package/dist/runtime/product-bootstrap.js +41 -51
- package/dist/runtime/product-orion-runtime.js +128 -52
- package/dist/runtime/release-receipts.d.ts +24 -124
- package/dist/runtime/release-receipts.js +129 -683
- package/dist/runtime/rich-text/layout.js +108 -65
- package/dist/runtime/rsi/contracts.d.ts +50 -0
- package/dist/runtime/rsi/contracts.js +17 -0
- package/dist/runtime/rsi/diagnosis.d.ts +46 -0
- package/dist/runtime/rsi/diagnosis.js +98 -0
- package/dist/runtime/rsi/evaluation-suite.d.ts +25 -0
- package/dist/runtime/rsi/evaluation-suite.js +141 -0
- package/dist/runtime/rsi/evaluation-worker.d.ts +19 -0
- package/dist/runtime/rsi/evaluation-worker.js +64 -0
- package/dist/runtime/rsi/evaluation.d.ts +49 -0
- package/dist/runtime/rsi/evaluation.js +351 -0
- package/dist/runtime/rsi/lifecycle.d.ts +54 -0
- package/dist/runtime/rsi/lifecycle.js +279 -0
- package/dist/runtime/rsi/proposal.d.ts +39 -0
- package/dist/runtime/rsi/proposal.js +312 -0
- package/dist/runtime/rsi/receipt.d.ts +28 -0
- package/dist/runtime/rsi/receipt.js +138 -0
- package/dist/runtime/rsi/skill-state.d.ts +7 -0
- package/dist/runtime/rsi/skill-state.js +50 -0
- package/dist/runtime/rsi/trajectory.d.ts +19 -0
- package/dist/runtime/rsi/trajectory.js +314 -0
- package/dist/runtime/rsi/triage.d.ts +274 -0
- package/dist/runtime/rsi/triage.js +58 -0
- package/dist/runtime/session-composer-control.d.ts +5 -24
- package/dist/runtime/session-composer-control.js +27 -189
- package/dist/runtime/step-snapshot.d.ts +1 -0
- package/dist/runtime/subagents/policy.js +0 -1
- package/dist/runtime/subagents/production.js +1 -1
- package/dist/runtime/subagents/runtime-integration.js +2 -4
- package/dist/runtime/subagents/types.d.ts +0 -5
- package/dist/runtime/subagents/types.js +0 -2
- package/dist/runtime/task-context-recovery.d.ts +55 -0
- package/dist/runtime/task-context-recovery.js +342 -0
- package/dist/runtime/task-context-service.d.ts +16 -10
- package/dist/runtime/task-context-service.js +35 -4
- package/dist/runtime/thread-admission.d.ts +1 -1
- package/dist/runtime/thread-admission.js +12 -6
- package/dist/runtime/thread-event-store.d.ts +2 -2
- package/dist/runtime/thread-event-store.js +7 -2
- package/dist/runtime/thread-projection.js +4 -2
- package/dist/runtime/thread-runtime.d.ts +7 -0
- package/dist/runtime/thread-runtime.js +43 -0
- package/dist/runtime/thread-session-index.d.ts +8 -0
- package/dist/runtime/thread-session-index.js +50 -1
- package/dist/runtime/thread-session-view.d.ts +2 -1
- package/dist/runtime/thread-session-view.js +4 -0
- package/dist/runtime/thread-tool-journal.d.ts +1 -0
- package/dist/runtime/thread-tool-journal.js +6 -2
- package/dist/runtime/thread-ui-adapter.d.ts +1 -0
- package/dist/runtime/thread-ui-adapter.js +88 -11
- package/dist/runtime/tool-gateway.d.ts +7 -0
- package/dist/runtime/tool-gateway.js +20 -0
- package/dist/runtime/tool-transcript-entry.d.ts +16 -0
- package/dist/runtime/tool-transcript-entry.js +73 -0
- package/dist/runtime/turn-commit.d.ts +4 -1
- package/dist/runtime/turn-commit.js +19 -15
- package/dist/runtime/ui-events.d.ts +12 -0
- package/dist/runtime/ui-view-model.d.ts +6 -5
- package/dist/runtime/ui-view-model.js +33 -19
- package/dist/runtime/workspace-runtime-kernel.js +0 -1
- package/dist/services/atomic-write.d.ts +2 -0
- package/dist/services/atomic-write.js +12 -1
- package/dist/services/code-review/format.d.ts +4 -1
- package/dist/services/code-review/format.js +5 -1
- package/dist/services/code-review/runner.d.ts +2 -2
- package/dist/services/code-review/runner.js +86 -64
- package/dist/services/code-review/snapshot.d.ts +9 -9
- package/dist/services/code-review/snapshot.js +182 -166
- package/dist/services/compact/auto-compact.d.ts +21 -6
- package/dist/services/compact/auto-compact.js +148 -22
- package/dist/services/compact/background-candidate.d.ts +33 -0
- package/dist/services/compact/background-candidate.js +184 -0
- package/dist/services/compact/compact.d.ts +4 -1
- package/dist/services/compact/compact.js +30 -3
- package/dist/services/compact/coordinator.d.ts +10 -4
- package/dist/services/compact/coordinator.js +17 -7
- package/dist/services/compact/summary-generator.d.ts +4 -2
- package/dist/services/compact/summary-generator.js +17 -3
- package/dist/services/config.d.ts +5 -5
- package/dist/services/config.js +30 -45
- package/dist/services/doctor.js +85 -13
- package/dist/services/effort.d.ts +5 -5
- package/dist/services/effort.js +5 -11
- package/dist/services/file-lock.d.ts +9 -3
- package/dist/services/file-lock.js +92 -26
- package/dist/services/global-config.d.ts +26 -56
- package/dist/services/global-config.js +213 -183
- package/dist/services/llm.d.ts +40 -4
- package/dist/services/llm.js +164 -45
- package/dist/services/model-client-pool.d.ts +15 -9
- package/dist/services/model-client-pool.js +62 -33
- package/dist/services/model-context.d.ts +2 -1
- package/dist/services/model-context.js +15 -9
- package/dist/services/model-registry.d.ts +4 -15
- package/dist/services/model-registry.js +32 -101
- package/dist/services/provider-diagnostics.d.ts +7 -0
- package/dist/services/provider-diagnostics.js +9 -10
- package/dist/services/provider-resilience/coordinator.d.ts +1 -1
- package/dist/services/provider-resilience/coordinator.js +10 -6
- package/dist/services/provider-resilience/request-gate.d.ts +3 -0
- package/dist/services/provider-resilience/request-gate.js +29 -18
- package/dist/services/provider-resilience/types.d.ts +2 -0
- package/dist/services/session-storage.d.ts +7 -10
- package/dist/services/session-storage.js +57 -30
- package/dist/services/settings-coordinator.d.ts +0 -6
- package/dist/services/settings-coordinator.js +19 -56
- package/dist/services/settings-document-repository.d.ts +3 -10
- package/dist/services/settings-document-repository.js +7 -85
- package/dist/services/usage-state.d.ts +3 -3
- package/dist/services/usage-state.js +11 -42
- package/dist/terminal-ui/answer-format.d.ts +14 -0
- package/dist/terminal-ui/answer-format.js +119 -0
- package/dist/terminal-ui/launch.d.ts +7 -6
- package/dist/terminal-ui/launch.js +160 -70
- package/dist/terminal-ui/output-queue.d.ts +2 -1
- package/dist/terminal-ui/output-queue.js +1 -1
- package/dist/terminal-ui/raw-editor.d.ts +2 -1
- package/dist/terminal-ui/raw-editor.js +56 -15
- package/dist/tools/core/edit-file.js +2 -0
- package/dist/tools/core/write-file.js +5 -0
- package/dist/tools/lsp.d.ts +16 -1
- package/dist/tools/lsp.js +60 -19
- package/dist/tools/sandbox.d.ts +1 -1
- package/dist/tools/sandbox.js +3 -16
- package/dist/tools/todo.d.ts +4 -2
- package/dist/tools/todo.js +76 -31
- package/dist/tui-core/input-parser.d.ts +1 -0
- package/dist/tui-core/input-parser.js +6 -0
- package/dist/tui-core/style.d.ts +1 -8
- package/dist/tui-core/style.js +3 -110
- package/dist/tui-ui/chrome-view-model.d.ts +1 -1
- package/dist/tui-ui/chrome-view-model.js +22 -27
- package/dist/tui-ui/launch.js +14 -14
- package/dist/tui-ui/layout.d.ts +5 -7
- package/dist/tui-ui/layout.js +129 -124
- package/dist/tui-ui/runner.d.ts +11 -12
- package/dist/tui-ui/runner.js +88 -67
- package/dist/tui-ui/state.d.ts +0 -11
- package/dist/tui-ui/state.js +22 -33
- package/dist/tui-ui/terminal-image.js +22 -4
- package/dist/tui-ui/transcript-inspector-layout.js +6 -3
- package/dist/tui-ui/transcript-inspector.d.ts +1 -0
- package/dist/tui-ui/transcript-inspector.js +7 -1
- package/dist/tui-ui/transcript-layout.js +42 -6
- package/dist/utils/terminal-text.d.ts +11 -0
- package/dist/utils/terminal-text.js +114 -0
- package/docs/cli-guide.md +562 -0
- package/docs/orion.example.yaml +42 -0
- package/docs/readme.md +12 -57
- package/npm-shrinkwrap.json +484 -1855
- package/package.json +13 -63
- package/dist/migration/command.d.ts +0 -9
- package/dist/migration/command.js +0 -100
- package/dist/migration/index.d.ts +0 -7
- package/dist/migration/index.js +0 -14
- package/dist/migration/migrate.d.ts +0 -19
- package/dist/migration/migrate.js +0 -406
- package/dist/migration/types.d.ts +0 -55
- package/dist/migration/types.js +0 -6
- package/dist/services/tool-allowlist.d.ts +0 -110
- package/dist/services/tool-allowlist.js +0 -299
- package/dist/services/yaml-config.d.ts +0 -57
- package/dist/services/yaml-config.js +0 -178
- package/dist/web/cli-options.d.ts +0 -17
- package/dist/web/cli-options.js +0 -51
- package/dist/web/code-review-run-service.d.ts +0 -68
- package/dist/web/code-review-run-service.js +0 -228
- package/dist/web/context-text.d.ts +0 -17
- package/dist/web/context-text.js +0 -40
- package/dist/web/errors.d.ts +0 -6
- package/dist/web/errors.js +0 -13
- package/dist/web/event-hub.d.ts +0 -45
- package/dist/web/event-hub.js +0 -370
- package/dist/web/file-read-service.d.ts +0 -101
- package/dist/web/file-read-service.js +0 -593
- package/dist/web/file-write-service.d.ts +0 -16
- package/dist/web/file-write-service.js +0 -103
- package/dist/web/git-compare-service.d.ts +0 -45
- package/dist/web/git-compare-service.js +0 -160
- package/dist/web/git-diff-document.d.ts +0 -102
- package/dist/web/git-diff-document.js +0 -258
- package/dist/web/git-file-source.d.ts +0 -25
- package/dist/web/git-file-source.js +0 -21
- package/dist/web/git-history-service.d.ts +0 -151
- package/dist/web/git-history-service.js +0 -619
- package/dist/web/git-index-transaction.d.ts +0 -45
- package/dist/web/git-index-transaction.js +0 -174
- package/dist/web/git-patch-builder.d.ts +0 -30
- package/dist/web/git-patch-builder.js +0 -138
- package/dist/web/git-read-model-service.d.ts +0 -452
- package/dist/web/git-read-model-service.js +0 -1833
- package/dist/web/git-version-service.d.ts +0 -79
- package/dist/web/git-version-service.js +0 -279
- package/dist/web/host-daemon.d.ts +0 -70
- package/dist/web/host-daemon.js +0 -237
- package/dist/web/index.d.ts +0 -6
- package/dist/web/index.js +0 -28
- package/dist/web/launch.d.ts +0 -12
- package/dist/web/launch.js +0 -89
- package/dist/web/native-directory-picker.d.ts +0 -63
- package/dist/web/native-directory-picker.js +0 -169
- package/dist/web/protocol.d.ts +0 -705
- package/dist/web/protocol.js +0 -639
- package/dist/web/review-service.d.ts +0 -22
- package/dist/web/review-service.js +0 -68
- package/dist/web/server.d.ts +0 -20
- package/dist/web/server.js +0 -1453
- package/dist/web/session-runtime-registry.d.ts +0 -138
- package/dist/web/session-runtime-registry.js +0 -471
- package/dist/web/terminal-manager.d.ts +0 -156
- package/dist/web/terminal-manager.js +0 -779
- package/dist/web/terminal-server.d.ts +0 -8
- package/dist/web/terminal-server.js +0 -304
- package/dist/web/workbench-controller.d.ts +0 -395
- package/dist/web/workbench-controller.js +0 -3077
- package/dist/web/workspace-discovery.d.ts +0 -92
- package/dist/web/workspace-discovery.js +0 -324
- package/dist/web/workspace-mutation-arbiter.d.ts +0 -54
- package/dist/web/workspace-mutation-arbiter.js +0 -267
- package/dist/web/workspace-open-telemetry.d.ts +0 -55
- package/dist/web/workspace-open-telemetry.js +0 -73
- package/dist/web-client/assets/FilesPanel-iBYj9ZRf.js +0 -1
- package/dist/web-client/assets/GitPanel-D33R_bZr.js +0 -4
- package/dist/web-client/assets/ReviewPanel-C_0upsDk.js +0 -6
- package/dist/web-client/assets/TerminalPanel-C7A8dMNf.js +0 -23
- package/dist/web-client/assets/TerminalPanel-DLuoa74B.css +0 -1
- package/dist/web-client/assets/index-BaOxrwGB.css +0 -1
- package/dist/web-client/assets/index-CqCgJ2ov.js +0 -20
- package/dist/web-client/assets/useAutoNotice-C1qM-_Sg.js +0 -1
- package/dist/web-client/favicon.svg +0 -9
- package/dist/web-client/index.html +0 -17
- package/docs/architecture/agent-mode-permission-contract.md +0 -87
- package/docs/architecture/v0.3.0-web-api.yaml +0 -1340
- package/docs/architecture/v0.3.1-web-api.yaml +0 -2338
- package/docs/architecture/v0.3.2-web-api.yaml +0 -3029
- package/docs/architecture/v0.3.3-web-api.yaml +0 -3205
- package/docs/architecture/v0.3.4-stabilization-contract.md +0 -32
- package/docs/migration/v0.1.9-to-v0.2.0.md +0 -98
- package/docs/migration/v0.2.2-to-v0.3.0-settings.md +0 -114
- package/docs/migration/v0.2.2-to-v0.3.0.md +0 -55
- package/docs/migration/v0.3.0-to-v0.3.1.md +0 -88
- package/docs/migration/v0.3.1-to-v0.3.2.md +0 -94
- package/docs/migration/v0.3.2-to-v0.3.3.md +0 -62
- package/docs/migration/v0.3.3-to-v0.3.4.md +0 -36
- package/docs/orion.example.json +0 -86
- package/docs/plan/v0.2.0-dsh-harness-redesign-plan.md +0 -1234
- package/docs/plan/v0.2.0-release-checklist.md +0 -91
- package/docs/plan/v0.3.0-node-runtime-compatibility-plan.md +0 -57
- package/docs/plan/v0.3.0-settings-integration-plan.md +0 -740
- package/docs/plan/v0.3.0-web-workbench-plan.md +0 -376
- package/docs/plan/v0.3.1-web-workbench-professional-shell-plan.md +0 -848
- package/docs/plan/v0.3.2-web-workbench-layout-and-composer-plan.md +0 -869
- package/docs/plan/v0.3.3-plan.md +0 -1113
- package/docs/plan/v0.3.4-stabilization-plan.md +0 -89
- package/docs/test/v0.3.1-web-workbench-e2e-plan.md +0 -140
- package/docs/test/v0.3.2-web-workbench-e2e-plan.md +0 -100
- package/docs/test/v0.3.3-web-workbench-e2e-plan.md +0 -79
- package/docs/test/v0.3.4-stabilization-e2e-plan.md +0 -54
|
@@ -7,6 +7,7 @@ const runtime_protocol_v1_1 = require("./protocol/runtime-protocol-v1");
|
|
|
7
7
|
class ThreadRuntimeV1 {
|
|
8
8
|
constructor(options) {
|
|
9
9
|
this.consumers = new Map();
|
|
10
|
+
this.liveObservers = new Set();
|
|
10
11
|
this.compactMaintenance = new Map();
|
|
11
12
|
this.goalControlTurns = new Map();
|
|
12
13
|
this.queuedGoalControls = new Map();
|
|
@@ -152,6 +153,32 @@ class ThreadRuntimeV1 {
|
|
|
152
153
|
throw error;
|
|
153
154
|
}
|
|
154
155
|
}
|
|
156
|
+
/** A pending user input and its admitted turn share one identity across crashes. */
|
|
157
|
+
startPendingFollowup(turnId, input, mode) {
|
|
158
|
+
if (this.closed)
|
|
159
|
+
return { status: 'rejected', reason: 'shutdown' };
|
|
160
|
+
if (!(0, runtime_protocol_v1_1.isRuntimeId)(turnId))
|
|
161
|
+
return { status: 'rejected', reason: 'invalid_input' };
|
|
162
|
+
if (Object.prototype.hasOwnProperty.call(this.getProjection().turns, turnId)) {
|
|
163
|
+
return { status: 'already_admitted' };
|
|
164
|
+
}
|
|
165
|
+
if (this.activeRun)
|
|
166
|
+
return { status: 'rejected', reason: 'overloaded' };
|
|
167
|
+
const before = this.admission.getSnapshot();
|
|
168
|
+
const result = this.admission.start({ input, mode, kind: 'regular' }, turnId);
|
|
169
|
+
if (result.status !== 'started')
|
|
170
|
+
return result;
|
|
171
|
+
try {
|
|
172
|
+
const active = this.requiredActiveTurn(result.turnId);
|
|
173
|
+
this.persistTurnStart(active);
|
|
174
|
+
this.scheduleTurn(active);
|
|
175
|
+
return result;
|
|
176
|
+
}
|
|
177
|
+
catch (error) {
|
|
178
|
+
this.admission.restore(before);
|
|
179
|
+
throw error;
|
|
180
|
+
}
|
|
181
|
+
}
|
|
155
182
|
startMaintenance(input) {
|
|
156
183
|
if (this.closed)
|
|
157
184
|
return { status: 'rejected', reason: 'shutdown' };
|
|
@@ -252,6 +279,13 @@ class ThreadRuntimeV1 {
|
|
|
252
279
|
throw new Error('Closed Thread runtime cannot be observed');
|
|
253
280
|
return this.store.subscribeCommitted(listener);
|
|
254
281
|
}
|
|
282
|
+
/** Observe newly published durable events and ephemeral deltas, without replay. */
|
|
283
|
+
observeLiveEvents(listener) {
|
|
284
|
+
if (this.closed)
|
|
285
|
+
throw new Error('Closed Thread runtime cannot be observed');
|
|
286
|
+
this.liveObservers.add(listener);
|
|
287
|
+
return () => this.liveObservers.delete(listener);
|
|
288
|
+
}
|
|
255
289
|
replay(cursor = 0, limit, reason) {
|
|
256
290
|
return this.store.replay(cursor, limit, reason);
|
|
257
291
|
}
|
|
@@ -305,6 +339,7 @@ class ThreadRuntimeV1 {
|
|
|
305
339
|
this.admission.close();
|
|
306
340
|
this.activeAbort?.abort(reason);
|
|
307
341
|
this.consumers.clear();
|
|
342
|
+
this.liveObservers.clear();
|
|
308
343
|
this.unsubscribeStore();
|
|
309
344
|
}
|
|
310
345
|
/** Runtime-owned entry for a recovered Goal; public input still uses dispatch(). */
|
|
@@ -662,6 +697,14 @@ class ThreadRuntimeV1 {
|
|
|
662
697
|
for (const buffer of this.consumers.values())
|
|
663
698
|
buffer.offer(event);
|
|
664
699
|
}
|
|
700
|
+
for (const observer of this.liveObservers) {
|
|
701
|
+
try {
|
|
702
|
+
observer(events);
|
|
703
|
+
}
|
|
704
|
+
catch {
|
|
705
|
+
// Observers cannot interrupt Thread execution or change committed facts.
|
|
706
|
+
}
|
|
707
|
+
}
|
|
665
708
|
}
|
|
666
709
|
resolveIdleIfNeeded() {
|
|
667
710
|
if (this.activeRun || this.admission.getSnapshot().activeTurn)
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { Message } from '../services/llm';
|
|
2
2
|
import type { RuntimeEventEnvelopeV1 } from './protocol/runtime-protocol-v1';
|
|
3
3
|
import type { ThreadLogIdentityV1 } from './thread-event-store';
|
|
4
|
+
import type { TranscriptEntry } from './ui-events';
|
|
4
5
|
import type { ItemProjectionV1, PlanReviewProjectionV1, ThreadProjectionV1, TurnProjectionStatusV1 } from './thread-projection';
|
|
5
6
|
export interface ThreadSessionIndexPerformanceCountersV1 {
|
|
6
7
|
readonly indexBuilds: number;
|
|
@@ -19,6 +20,13 @@ export interface ThreadSessionTranscriptMessageV1 {
|
|
|
19
20
|
readonly tool_calls?: NonNullable<Message['tool_calls']>;
|
|
20
21
|
readonly appliedSkills?: readonly string[];
|
|
21
22
|
}
|
|
23
|
+
export declare const RESUME_TRANSCRIPT_WINDOW_MESSAGES = 50;
|
|
24
|
+
export interface ThreadResumeDisplayV1 {
|
|
25
|
+
readonly entries: readonly TranscriptEntry[];
|
|
26
|
+
readonly totalEntries: number;
|
|
27
|
+
}
|
|
28
|
+
/** UI-only window. These entries must never be used for model history recovery. */
|
|
29
|
+
export declare function projectThreadResumeDisplay(items: Readonly<Record<string, ItemProjectionV1>>): ThreadResumeDisplayV1;
|
|
22
30
|
export interface ThreadSessionTurnCommitV1 {
|
|
23
31
|
readonly seq: number;
|
|
24
32
|
readonly receipt: string;
|
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ThreadSessionIndexError = void 0;
|
|
3
|
+
exports.ThreadSessionIndexError = exports.RESUME_TRANSCRIPT_WINDOW_MESSAGES = void 0;
|
|
4
4
|
exports.threadSessionIndexPerformanceCountersV1 = threadSessionIndexPerformanceCountersV1;
|
|
5
|
+
exports.projectThreadResumeDisplay = projectThreadResumeDisplay;
|
|
5
6
|
exports.buildThreadSessionIndexV1 = buildThreadSessionIndexV1;
|
|
6
7
|
exports.advanceThreadSessionIndexV1 = advanceThreadSessionIndexV1;
|
|
7
8
|
exports.loadThreadSessionIndexManifestV1 = loadThreadSessionIndexManifestV1;
|
|
@@ -11,6 +12,7 @@ const fs_1 = require("fs");
|
|
|
11
12
|
const path_1 = require("path");
|
|
12
13
|
const atomic_write_1 = require("../services/atomic-write");
|
|
13
14
|
const canonical_1 = require("./protocol/canonical");
|
|
15
|
+
const tool_transcript_entry_1 = require("./tool-transcript-entry");
|
|
14
16
|
const TRANSCRIPT_PAGE_ITEMS = 100;
|
|
15
17
|
const MAX_MANIFEST_PAGES = 100000;
|
|
16
18
|
const threadSessionIndexPerformance = {
|
|
@@ -23,6 +25,53 @@ const threadSessionIndexPerformance = {
|
|
|
23
25
|
function threadSessionIndexPerformanceCountersV1() {
|
|
24
26
|
return Object.freeze({ ...threadSessionIndexPerformance });
|
|
25
27
|
}
|
|
28
|
+
exports.RESUME_TRANSCRIPT_WINDOW_MESSAGES = 50;
|
|
29
|
+
/** UI-only window. These entries must never be used for model history recovery. */
|
|
30
|
+
function projectThreadResumeDisplay(items) {
|
|
31
|
+
const ordered = Object.values(items)
|
|
32
|
+
.filter(item => {
|
|
33
|
+
if (item.status === 'started')
|
|
34
|
+
return false;
|
|
35
|
+
return ((item.kind === 'message' && isMessageRole(item.role)) ||
|
|
36
|
+
item.kind === 'reasoning' ||
|
|
37
|
+
(0, tool_transcript_entry_1.isToolTranscriptItem)(item.kind));
|
|
38
|
+
})
|
|
39
|
+
.sort((left, right) => left.startedSeq - right.startedSeq);
|
|
40
|
+
return {
|
|
41
|
+
totalEntries: ordered.length,
|
|
42
|
+
entries: ordered.slice(-exports.RESUME_TRANSCRIPT_WINDOW_MESSAGES).map(item => {
|
|
43
|
+
if (item.kind === 'message') {
|
|
44
|
+
const legacy = parseLegacyTranscriptReceipt(item.receipt);
|
|
45
|
+
const role = legacy?.role ?? item.role;
|
|
46
|
+
return {
|
|
47
|
+
id: item.itemId,
|
|
48
|
+
role,
|
|
49
|
+
content: legacy?.content ?? item.content ?? item.summary ?? item.error ?? '',
|
|
50
|
+
...(role === 'user' ? { title: 'you' } : {}),
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
if (item.kind === 'reasoning') {
|
|
54
|
+
return {
|
|
55
|
+
id: item.itemId,
|
|
56
|
+
role: 'assistant',
|
|
57
|
+
title: 'reasoning',
|
|
58
|
+
content: item.content ?? item.summary ?? '',
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
return {
|
|
62
|
+
id: item.itemId,
|
|
63
|
+
...(0, tool_transcript_entry_1.toolTranscriptEntry)({
|
|
64
|
+
name: item.name ?? item.kind,
|
|
65
|
+
callId: item.itemId,
|
|
66
|
+
sequence: item.startedSeq,
|
|
67
|
+
success: item.status === 'completed',
|
|
68
|
+
command: (0, tool_transcript_entry_1.toolCommandFromIntent)(item.intent),
|
|
69
|
+
output: item.summary ?? item.error,
|
|
70
|
+
}),
|
|
71
|
+
};
|
|
72
|
+
}),
|
|
73
|
+
};
|
|
74
|
+
}
|
|
26
75
|
class ThreadSessionIndexError extends Error {
|
|
27
76
|
constructor(code, message) {
|
|
28
77
|
super(message);
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Message } from '../services/llm';
|
|
2
2
|
import { type SessionHistoryRecoveryDiagnosticV1, type SessionHistoryResolvedSourceV1 } from './session-history-recovery';
|
|
3
3
|
import { ThreadEventStore, type ThreadReadModelHeadV1 } from './thread-event-store';
|
|
4
|
-
import { type ThreadSessionLatestTurnV1, type ThreadSessionTranscriptMessageV1, type ThreadSessionTurnCommitV1 } from './thread-session-index';
|
|
4
|
+
import { type ThreadSessionLatestTurnV1, type ThreadSessionTranscriptMessageV1, type ThreadSessionTurnCommitV1, type ThreadResumeDisplayV1 } from './thread-session-index';
|
|
5
5
|
import type { PlanReviewProjectionV1 } from './thread-projection';
|
|
6
6
|
export type { ThreadSessionTranscriptMessageV1, ThreadSessionTurnCommitV1, } from './thread-session-index';
|
|
7
7
|
/** Metadata/transcript projection that never needs to decode model history. */
|
|
@@ -29,6 +29,7 @@ export interface ThreadSessionViewV1 extends ThreadSessionSummaryV1 {
|
|
|
29
29
|
readonly diagnostics: readonly SessionHistoryRecoveryDiagnosticV1[];
|
|
30
30
|
readonly latestTurnCommit?: ThreadSessionTurnCommitV1;
|
|
31
31
|
readonly latestPlanTurnCommit?: ThreadSessionTurnCommitV1;
|
|
32
|
+
readonly resumeDisplay?: ThreadResumeDisplayV1;
|
|
32
33
|
}
|
|
33
34
|
/**
|
|
34
35
|
* A verified, process-local hand-off from Session restore into the sole
|
|
@@ -62,6 +62,7 @@ function openThreadSessionViewV1(projectPath, sessionId) {
|
|
|
62
62
|
modelHistory: recovery.messages,
|
|
63
63
|
modelHistorySource: recovery.source,
|
|
64
64
|
diagnostics: recovery.diagnostics,
|
|
65
|
+
...(captured.resumeDisplay ? { resumeDisplay: captured.resumeDisplay } : {}),
|
|
65
66
|
...(captured.latestTurnCommit ? { latestTurnCommit: captured.latestTurnCommit } : {}),
|
|
66
67
|
...(captured.latestPlanTurnCommit
|
|
67
68
|
? { latestPlanTurnCommit: captured.latestPlanTurnCommit }
|
|
@@ -201,6 +202,9 @@ function captureThreadSessionV1(projectPath, sessionId, includeDurableHistory) {
|
|
|
201
202
|
},
|
|
202
203
|
}),
|
|
203
204
|
durableHistory,
|
|
205
|
+
...(includeDurableHistory
|
|
206
|
+
? { resumeDisplay: (0, thread_session_index_1.projectThreadResumeDisplay)(projection.items) }
|
|
207
|
+
: {}),
|
|
204
208
|
store,
|
|
205
209
|
cutoverGeneration: resolution.generation,
|
|
206
210
|
...(latestTurnCommit ? { latestTurnCommit: Object.freeze(latestTurnCommit) } : {}),
|
|
@@ -8,4 +8,5 @@ export declare class ThreadToolInvocationJournalV1 implements ToolInvocationJour
|
|
|
8
8
|
begin(intent: ToolInvocationIntentV1): Promise<void>;
|
|
9
9
|
complete(receipt: ToolInvocationReceiptV1): Promise<void>;
|
|
10
10
|
}
|
|
11
|
+
export declare function parseToolInvocationIntentV1(value: string): ToolInvocationIntentV1;
|
|
11
12
|
//# sourceMappingURL=thread-tool-journal.d.ts.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ThreadToolInvocationJournalV1 = void 0;
|
|
4
|
+
exports.parseToolInvocationIntentV1 = parseToolInvocationIntentV1;
|
|
4
5
|
const canonical_1 = require("./protocol/canonical");
|
|
5
6
|
/** Durable ToolGateway journal backed by the canonical Thread event log. */
|
|
6
7
|
class ThreadToolInvocationJournalV1 {
|
|
@@ -14,7 +15,7 @@ class ThreadToolInvocationJournalV1 {
|
|
|
14
15
|
if (item.kind !== 'command' || !item.intent) {
|
|
15
16
|
throw new Error(`Thread item ${invocationId} is not a durable tool invocation intent`);
|
|
16
17
|
}
|
|
17
|
-
const intent =
|
|
18
|
+
const intent = parseToolInvocationIntentV1(item.intent);
|
|
18
19
|
const receipt = item.receipt ? parseReceipt(item.receipt) : undefined;
|
|
19
20
|
if (receipt && receipt.intentDigest !== intent.digest) {
|
|
20
21
|
throw new Error(`Tool receipt ${invocationId} does not match its durable intent`);
|
|
@@ -108,8 +109,11 @@ function toTerminalPayload(receipt, receiptJson) {
|
|
|
108
109
|
};
|
|
109
110
|
}
|
|
110
111
|
}
|
|
111
|
-
function
|
|
112
|
+
function parseToolInvocationIntentV1(value) {
|
|
112
113
|
const parsed = JSON.parse(value);
|
|
114
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
115
|
+
throw new Error('Durable tool invocation intent must be an object');
|
|
116
|
+
}
|
|
113
117
|
const { digest, ...content } = parsed;
|
|
114
118
|
if (parsed?.version !== 1 ||
|
|
115
119
|
typeof digest !== 'string' ||
|
|
@@ -61,6 +61,7 @@ export declare class ThreadUiAdapterV1 implements AgentRuntimeRunnerV1 {
|
|
|
61
61
|
close(reason?: string): void;
|
|
62
62
|
snapshot(): ThreadUiAdapterSnapshotV1;
|
|
63
63
|
private runTurn;
|
|
64
|
+
private admitPendingFollowup;
|
|
64
65
|
private waitForIdleAndFlush;
|
|
65
66
|
private replayInitialHistory;
|
|
66
67
|
private replayRequired;
|
|
@@ -4,9 +4,29 @@ exports.ThreadUiAdmissionError = exports.ThreadUiAdapterError = exports.ThreadUi
|
|
|
4
4
|
const agent_runtime_protocol_1 = require("./agent-runtime-protocol");
|
|
5
5
|
const goal_runtime_coordinator_1 = require("./goal-runtime-coordinator");
|
|
6
6
|
const runtime_protocol_v1_1 = require("./protocol/runtime-protocol-v1");
|
|
7
|
+
const tool_transcript_entry_1 = require("./tool-transcript-entry");
|
|
7
8
|
const tool_receipt_validator_1 = require("./tool-receipt-validator");
|
|
8
9
|
const turn_commit_1 = require("./turn-commit");
|
|
10
|
+
const ui_view_model_1 = require("./ui-view-model");
|
|
9
11
|
exports.THREAD_UI_ADAPTER_VERSION = 1;
|
|
12
|
+
function budgetStopFromOutcome(outcome) {
|
|
13
|
+
if (!outcome?.startsWith('{'))
|
|
14
|
+
return undefined;
|
|
15
|
+
try {
|
|
16
|
+
const parsed = JSON.parse(outcome);
|
|
17
|
+
const stop = parsed.budgetStop;
|
|
18
|
+
if (stop?.schemaVersion === 1 &&
|
|
19
|
+
typeof stop.reason === 'string' &&
|
|
20
|
+
Number.isSafeInteger(stop.llmRequests?.current) &&
|
|
21
|
+
Number.isSafeInteger(stop.toolCalls?.current)) {
|
|
22
|
+
return stop;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
// Outcomes from other Thread runners need not use the agent-loop format.
|
|
27
|
+
}
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
10
30
|
/**
|
|
11
31
|
* Transitional projection from the durable Thread runtime to existing UI
|
|
12
32
|
* contracts. ThreadRuntime remains the sole owner of turn/item state; this
|
|
@@ -110,7 +130,16 @@ class ThreadUiAdapterV1 {
|
|
|
110
130
|
async runTurn(input, mode, options) {
|
|
111
131
|
this.assertOpen();
|
|
112
132
|
throwIfAborted(options.abortSignal);
|
|
113
|
-
const
|
|
133
|
+
const pending = options.followup;
|
|
134
|
+
// Maintenance reports a terminal fact before releasing the execution
|
|
135
|
+
// lease. The pending input must wait for that release before handoff.
|
|
136
|
+
const admission = pending
|
|
137
|
+
? await this.admitPendingFollowup(pending, input, mode, options.abortSignal)
|
|
138
|
+
: this.runtime.dispatch({ type: 'turn.start', data: { input, mode } });
|
|
139
|
+
if (admission.status === 'already_admitted') {
|
|
140
|
+
pending?.onAdmitted();
|
|
141
|
+
return;
|
|
142
|
+
}
|
|
114
143
|
if (admission.status === 'rejected') {
|
|
115
144
|
throw new ThreadUiAdmissionError(admission.reason);
|
|
116
145
|
}
|
|
@@ -119,12 +148,23 @@ class ThreadUiAdapterV1 {
|
|
|
119
148
|
}
|
|
120
149
|
const detachAbort = forwardAbort(options.abortSignal, reason => this.interrupt(reason));
|
|
121
150
|
try {
|
|
151
|
+
pending?.onAdmitted();
|
|
122
152
|
await this.waitForIdleAndFlush();
|
|
123
153
|
}
|
|
124
154
|
finally {
|
|
125
155
|
detachAbort();
|
|
126
156
|
}
|
|
127
157
|
}
|
|
158
|
+
async admitPendingFollowup(pending, input, mode, signal) {
|
|
159
|
+
if (mode === 'goal')
|
|
160
|
+
throw new ThreadUiAdapterError('A pending follow-up must be user input.');
|
|
161
|
+
await this.runtime.waitForIdle();
|
|
162
|
+
this.assertOpen();
|
|
163
|
+
throwIfAborted(signal);
|
|
164
|
+
if (!pending.isPending())
|
|
165
|
+
throw new ThreadUiAdmissionError('pending follow-up changed');
|
|
166
|
+
return this.runtime.startPendingFollowup(pending.id, input, mode);
|
|
167
|
+
}
|
|
128
168
|
async waitForIdleAndFlush() {
|
|
129
169
|
let idle = false;
|
|
130
170
|
const idlePromise = this.runtime.waitForIdle().finally(() => {
|
|
@@ -199,14 +239,27 @@ class ThreadUiAdapterV1 {
|
|
|
199
239
|
case 'turn.interrupt_requested':
|
|
200
240
|
this.emit({ type: 'status_changed', message: 'Interrupt requested…' });
|
|
201
241
|
return;
|
|
202
|
-
case 'turn.completed':
|
|
242
|
+
case 'turn.completed': {
|
|
203
243
|
this.emit({ type: 'processing_changed', processing: false });
|
|
244
|
+
const budgetStop = budgetStopFromOutcome(event.payload.data.outcome);
|
|
245
|
+
if (budgetStop) {
|
|
246
|
+
this.emit({
|
|
247
|
+
type: 'transcript_append',
|
|
248
|
+
entry: {
|
|
249
|
+
role: 'status',
|
|
250
|
+
title: 'execution budget',
|
|
251
|
+
content: (0, ui_view_model_1.formatLoopBudgetStopView)(budgetStop),
|
|
252
|
+
budgetStop,
|
|
253
|
+
},
|
|
254
|
+
});
|
|
255
|
+
}
|
|
204
256
|
this.emit({
|
|
205
257
|
type: 'status_changed',
|
|
206
|
-
message: event.payload.data.outcome?.trim() || 'Ready',
|
|
258
|
+
message: budgetStop?.reason ?? (event.payload.data.outcome?.trim() || 'Ready'),
|
|
207
259
|
});
|
|
208
260
|
this.projectCompletedPlanMode(event);
|
|
209
261
|
return;
|
|
262
|
+
}
|
|
210
263
|
case 'turn.failed':
|
|
211
264
|
this.emit({
|
|
212
265
|
type: 'transcript_append',
|
|
@@ -332,17 +385,19 @@ class ThreadUiAdapterV1 {
|
|
|
332
385
|
role: data.role,
|
|
333
386
|
name: data.name?.trim() || defaultItemName(data.kind),
|
|
334
387
|
args: data.inputDigest ? { inputDigest: data.inputDigest } : {},
|
|
388
|
+
command: (0, tool_transcript_entry_1.toolCommandFromIntent)(data.intent),
|
|
335
389
|
sequence: event.seq,
|
|
336
390
|
startedAt: event.timestamp,
|
|
337
391
|
content: '',
|
|
338
392
|
};
|
|
339
|
-
if (
|
|
393
|
+
if ((0, tool_transcript_entry_1.isToolTranscriptItem)(presentation.kind)) {
|
|
340
394
|
this.emit({
|
|
341
395
|
type: 'tool_started',
|
|
342
396
|
event: {
|
|
343
397
|
callId: presentation.itemId,
|
|
344
398
|
name: presentation.name,
|
|
345
399
|
args: presentation.args,
|
|
400
|
+
...(presentation.command ? { command: presentation.command } : {}),
|
|
346
401
|
sequence: presentation.sequence,
|
|
347
402
|
},
|
|
348
403
|
});
|
|
@@ -362,7 +417,7 @@ class ThreadUiAdapterV1 {
|
|
|
362
417
|
return;
|
|
363
418
|
const presentation = this.ensurePresentation(event);
|
|
364
419
|
presentation.content += event.payload.data.delta;
|
|
365
|
-
if (!
|
|
420
|
+
if (!(0, tool_transcript_entry_1.isToolTranscriptItem)(presentation.kind) && presentation.transcriptId) {
|
|
366
421
|
this.emit({
|
|
367
422
|
type: 'transcript_update',
|
|
368
423
|
id: presentation.transcriptId,
|
|
@@ -373,16 +428,25 @@ class ThreadUiAdapterV1 {
|
|
|
373
428
|
finishItem(event) {
|
|
374
429
|
const presentation = this.ensurePresentation(event);
|
|
375
430
|
const terminal = terminalItemData(event);
|
|
376
|
-
|
|
431
|
+
// The compact item owns a durable receipt. Its short summary keeps the
|
|
432
|
+
// preceding result or budget pause visible in an interactive transcript.
|
|
433
|
+
if (presentation.kind === 'compact' && terminal.summary) {
|
|
434
|
+
presentation.content = terminal.summary;
|
|
435
|
+
}
|
|
436
|
+
else if (terminal.content !== undefined) {
|
|
377
437
|
presentation.content = terminal.content;
|
|
438
|
+
}
|
|
378
439
|
if (!presentation.content && terminal.summary)
|
|
379
440
|
presentation.content = terminal.summary;
|
|
380
|
-
if (
|
|
441
|
+
if ((0, tool_transcript_entry_1.isToolTranscriptItem)(presentation.kind)) {
|
|
381
442
|
const durableReceiptFact = this.toolReceiptFacts.get(presentation.itemId);
|
|
382
443
|
let receipt;
|
|
383
444
|
const hasTerminalReceipt = terminal.receipt !== undefined;
|
|
384
445
|
const hasDurableReceiptFact = durableReceiptFact !== undefined;
|
|
385
|
-
|
|
446
|
+
// A torn journal batch can leave a receipt fact without its terminal
|
|
447
|
+
// pair. Recovery publishes an indeterminate Item, never a receipt.
|
|
448
|
+
const abandonedReceipt = event.payload.type === 'item.indeterminate' && !hasTerminalReceipt;
|
|
449
|
+
if (!abandonedReceipt && hasTerminalReceipt !== hasDurableReceiptFact) {
|
|
386
450
|
throw new ThreadUiAdapterError(hasTerminalReceipt
|
|
387
451
|
? `Tool item ${presentation.itemId} has a canonical receipt without its durable receipt fact.`
|
|
388
452
|
: `Tool item ${presentation.itemId} has a durable receipt fact without its canonical terminal receipt.`);
|
|
@@ -410,6 +474,7 @@ class ThreadUiAdapterV1 {
|
|
|
410
474
|
callId: presentation.itemId,
|
|
411
475
|
name: presentation.name,
|
|
412
476
|
args: presentation.args,
|
|
477
|
+
...(presentation.command ? { command: presentation.command } : {}),
|
|
413
478
|
success,
|
|
414
479
|
duration: Math.max(0, event.timestamp - presentation.startedAt),
|
|
415
480
|
sequence: presentation.sequence,
|
|
@@ -427,6 +492,20 @@ class ThreadUiAdapterV1 {
|
|
|
427
492
|
: {}),
|
|
428
493
|
},
|
|
429
494
|
});
|
|
495
|
+
this.emit({
|
|
496
|
+
type: 'transcript_append',
|
|
497
|
+
entry: {
|
|
498
|
+
...(0, tool_transcript_entry_1.toolTranscriptEntry)({
|
|
499
|
+
callId: presentation.itemId,
|
|
500
|
+
sequence: presentation.sequence,
|
|
501
|
+
name: presentation.name,
|
|
502
|
+
success,
|
|
503
|
+
command: presentation.command,
|
|
504
|
+
output: presentation.content || terminal.error,
|
|
505
|
+
}),
|
|
506
|
+
live: false,
|
|
507
|
+
},
|
|
508
|
+
});
|
|
430
509
|
}
|
|
431
510
|
else if (presentation.transcriptId) {
|
|
432
511
|
const success = event.payload.type === 'item.completed';
|
|
@@ -472,6 +551,7 @@ class ThreadUiAdapterV1 {
|
|
|
472
551
|
...(isItemRole(projected.role) ? { role: projected.role } : {}),
|
|
473
552
|
...(projected.name ? { name: projected.name } : {}),
|
|
474
553
|
...(projected.inputDigest ? { inputDigest: projected.inputDigest } : {}),
|
|
554
|
+
...(projected.intent ? { intent: projected.intent } : {}),
|
|
475
555
|
},
|
|
476
556
|
},
|
|
477
557
|
});
|
|
@@ -570,9 +650,6 @@ function transcriptTitle(presentation) {
|
|
|
570
650
|
return presentation.name;
|
|
571
651
|
}
|
|
572
652
|
}
|
|
573
|
-
function isToolItem(kind) {
|
|
574
|
-
return kind === 'command' || kind === 'file_change' || kind === 'mcp';
|
|
575
|
-
}
|
|
576
653
|
function defaultItemName(kind) {
|
|
577
654
|
switch (kind) {
|
|
578
655
|
case 'file_change':
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ToolContext, ToolResult } from '../framework/tool';
|
|
2
|
+
import type { TaskToolRecoveryBindingV1 } from './task-context-recovery';
|
|
2
3
|
import { ExecutionService, type BoundToolExecutionResultV1, type StepSnapshotV1, type ToolBindingDescriptorV1 } from './step-snapshot';
|
|
3
4
|
export type ToolPolicyBehaviorV1 = 'allow' | 'ask' | 'deny';
|
|
4
5
|
export type ToolTerminalV1 = 'completed' | 'failed' | 'interrupted' | 'indeterminate';
|
|
@@ -10,6 +11,9 @@ export interface ToolInvocationV1 {
|
|
|
10
11
|
readonly args: Readonly<Record<string, unknown>>;
|
|
11
12
|
readonly context: ToolContext;
|
|
12
13
|
readonly abortSignal?: AbortSignal;
|
|
14
|
+
/** Workflow prerequisites are recoverable tool failures, independent of approval. */
|
|
15
|
+
readonly prerequisiteFailure?: string;
|
|
16
|
+
readonly taskRecovery?: TaskToolRecoveryBindingV1;
|
|
13
17
|
}
|
|
14
18
|
export interface ToolPolicyDecisionV1 {
|
|
15
19
|
readonly behavior: ToolPolicyBehaviorV1;
|
|
@@ -38,6 +42,7 @@ export interface ToolPolicyServiceV1 {
|
|
|
38
42
|
}
|
|
39
43
|
export interface ToolApprovalServiceV1 {
|
|
40
44
|
decide(input: {
|
|
45
|
+
readonly invocationId?: string;
|
|
41
46
|
readonly snapshot: StepSnapshotV1;
|
|
42
47
|
readonly descriptor: ToolBindingDescriptorV1;
|
|
43
48
|
readonly args: Readonly<Record<string, unknown>>;
|
|
@@ -64,6 +69,8 @@ export interface ToolInvocationIntentV1 {
|
|
|
64
69
|
readonly snapshotDigest: string;
|
|
65
70
|
readonly argsDigest: string;
|
|
66
71
|
readonly requestDigest: string;
|
|
72
|
+
readonly displayCommand?: string;
|
|
73
|
+
readonly taskRecovery?: TaskToolRecoveryBindingV1;
|
|
67
74
|
readonly startedAt: number;
|
|
68
75
|
readonly digest: string;
|
|
69
76
|
}
|
|
@@ -6,6 +6,7 @@ exports.createStaticApprovalDecisionV1 = createStaticApprovalDecisionV1;
|
|
|
6
6
|
exports.createSandboxPreparationV1 = createSandboxPreparationV1;
|
|
7
7
|
const canonical_1 = require("./protocol/canonical");
|
|
8
8
|
const runtime_protocol_v1_1 = require("./protocol/runtime-protocol-v1");
|
|
9
|
+
const tool_transcript_entry_1 = require("./tool-transcript-entry");
|
|
9
10
|
class ToolGatewayError extends Error {
|
|
10
11
|
constructor(code, message, invocationId) {
|
|
11
12
|
super(message);
|
|
@@ -75,6 +76,13 @@ class ToolGateway {
|
|
|
75
76
|
result: failure(`Tool is not direct in this StepSnapshot: ${invocation.toolName}`),
|
|
76
77
|
});
|
|
77
78
|
}
|
|
79
|
+
if (invocation.prerequisiteFailure) {
|
|
80
|
+
return this.commitTerminal(invocation, intent, {
|
|
81
|
+
terminal: 'failed',
|
|
82
|
+
terminalPhase: 'policy',
|
|
83
|
+
result: failure(invocation.prerequisiteFailure),
|
|
84
|
+
});
|
|
85
|
+
}
|
|
78
86
|
let policy;
|
|
79
87
|
try {
|
|
80
88
|
policy = validatePolicyDecision(await this.services.policy.decide({
|
|
@@ -102,6 +110,7 @@ class ToolGateway {
|
|
|
102
110
|
if (policy.behavior === 'ask') {
|
|
103
111
|
try {
|
|
104
112
|
approval = validateApprovalDecision(await this.services.approval.decide({
|
|
113
|
+
invocationId: invocation.invocationId,
|
|
105
114
|
snapshot: invocation.snapshot,
|
|
106
115
|
descriptor,
|
|
107
116
|
args: invocation.args,
|
|
@@ -274,10 +283,19 @@ function computeRequestDigest(invocation) {
|
|
|
274
283
|
toolName: invocation.toolName,
|
|
275
284
|
snapshotDigest: invocation.snapshot.digest,
|
|
276
285
|
argsDigest: (0, canonical_1.digestRuntimeValue)(invocation.args),
|
|
286
|
+
...(invocation.taskRecovery
|
|
287
|
+
? { taskRecoveryDigest: (0, canonical_1.digestRuntimeValue)(invocation.taskRecovery) }
|
|
288
|
+
: {}),
|
|
289
|
+
...(invocation.prerequisiteFailure
|
|
290
|
+
? { prerequisiteFailure: invocation.prerequisiteFailure }
|
|
291
|
+
: {}),
|
|
277
292
|
});
|
|
278
293
|
}
|
|
279
294
|
function createIntent(invocation, startedAt) {
|
|
280
295
|
const requestDigest = computeRequestDigest(invocation);
|
|
296
|
+
const displayCommand = invocation.toolName === 'exec_command'
|
|
297
|
+
? (0, tool_transcript_entry_1.toolCommandForDisplay)(invocation.args.command)
|
|
298
|
+
: undefined;
|
|
281
299
|
const content = {
|
|
282
300
|
version: 1,
|
|
283
301
|
invocationId: invocation.invocationId,
|
|
@@ -289,6 +307,8 @@ function createIntent(invocation, startedAt) {
|
|
|
289
307
|
snapshotDigest: invocation.snapshot.digest,
|
|
290
308
|
argsDigest: (0, canonical_1.digestRuntimeValue)(invocation.args),
|
|
291
309
|
requestDigest,
|
|
310
|
+
...(displayCommand ? { displayCommand } : {}),
|
|
311
|
+
...(invocation.taskRecovery ? { taskRecovery: invocation.taskRecovery } : {}),
|
|
292
312
|
startedAt,
|
|
293
313
|
};
|
|
294
314
|
return deepFreeze({ ...content, digest: (0, canonical_1.digestRuntimeValue)(content) });
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
import type { TranscriptAppendEntry } from './ui-events';
|
|
2
|
+
/** Bounded display text only. Credential-bearing invocations retain the tool name. */
|
|
3
|
+
export declare function toolCommandForDisplay(command: unknown): string | undefined;
|
|
4
|
+
/** Read the optional display label in a durable intent; older records have none. */
|
|
5
|
+
export declare function toolCommandFromIntent(intent: string | undefined): string | undefined;
|
|
6
|
+
export declare function isToolTranscriptItem(kind: string): boolean;
|
|
7
|
+
/** A bounded transcript row. Tool details and output stay on their existing surfaces. */
|
|
8
|
+
export declare function toolTranscriptEntry(input: {
|
|
9
|
+
callId: string;
|
|
10
|
+
sequence: number;
|
|
11
|
+
name: string;
|
|
12
|
+
success: boolean;
|
|
13
|
+
command?: string;
|
|
14
|
+
output?: string;
|
|
15
|
+
}): TranscriptAppendEntry;
|
|
16
|
+
//# sourceMappingURL=tool-transcript-entry.d.ts.map
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.toolCommandForDisplay = toolCommandForDisplay;
|
|
4
|
+
exports.toolCommandFromIntent = toolCommandFromIntent;
|
|
5
|
+
exports.isToolTranscriptItem = isToolTranscriptItem;
|
|
6
|
+
exports.toolTranscriptEntry = toolTranscriptEntry;
|
|
7
|
+
const redaction_1 = require("../services/redaction");
|
|
8
|
+
const style_1 = require("../tui-core/style");
|
|
9
|
+
const SENSITIVE_COMMAND_ARGUMENT = /(?:^|\s)--(?:password|passphrase|token|api[-_]?key|secret|authorization|cookie|credentials?)(?:[=\s]|$)/iu;
|
|
10
|
+
/** Bounded display text only. Credential-bearing invocations retain the tool name. */
|
|
11
|
+
function toolCommandForDisplay(command) {
|
|
12
|
+
if (typeof command !== 'string')
|
|
13
|
+
return undefined;
|
|
14
|
+
const clean = (0, style_1.sanitizeTerminalText)(command).replace(/\n/gu, ' ⏎ ').trim();
|
|
15
|
+
if (!clean ||
|
|
16
|
+
SENSITIVE_COMMAND_ARGUMENT.test(clean) ||
|
|
17
|
+
(0, redaction_1.redactTraceText)(clean) !== clean ||
|
|
18
|
+
clean.split(/[\s"'<>|;]+/u).some(redaction_1.isSensitiveFilePath)) {
|
|
19
|
+
return undefined;
|
|
20
|
+
}
|
|
21
|
+
return clipDisplayText(clean, 160);
|
|
22
|
+
}
|
|
23
|
+
/** Read the optional display label in a durable intent; older records have none. */
|
|
24
|
+
function toolCommandFromIntent(intent) {
|
|
25
|
+
if (!intent)
|
|
26
|
+
return undefined;
|
|
27
|
+
try {
|
|
28
|
+
const record = JSON.parse(intent);
|
|
29
|
+
return record?.toolName === 'exec_command'
|
|
30
|
+
? toolCommandForDisplay(record.displayCommand)
|
|
31
|
+
: undefined;
|
|
32
|
+
}
|
|
33
|
+
catch {
|
|
34
|
+
return undefined;
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
function isToolTranscriptItem(kind) {
|
|
38
|
+
return kind === 'command' || kind === 'file_change' || kind === 'mcp';
|
|
39
|
+
}
|
|
40
|
+
/** A bounded transcript row. Tool details and output stay on their existing surfaces. */
|
|
41
|
+
function toolTranscriptEntry(input) {
|
|
42
|
+
const name = /^[A-Za-z0-9_.:/-]{1,120}$/u.test(input.name) ? input.name : 'tool';
|
|
43
|
+
const command = toolCommandForDisplay(input.command);
|
|
44
|
+
const lines = command && input.output
|
|
45
|
+
? (0, style_1.sanitizeTerminalText)((0, redaction_1.redactTraceText)(input.output))
|
|
46
|
+
.split('\n')
|
|
47
|
+
.filter(line => line.trim())
|
|
48
|
+
: [];
|
|
49
|
+
// Prefer the final lines, where test runners usually print their verdict.
|
|
50
|
+
const body = lines
|
|
51
|
+
.slice(-2)
|
|
52
|
+
.map(line => clipDisplayText(line, 120))
|
|
53
|
+
.join('\n');
|
|
54
|
+
return {
|
|
55
|
+
role: 'tool',
|
|
56
|
+
title: name,
|
|
57
|
+
content: `${input.success ? 'Completed' : 'Failed'} ${name}`,
|
|
58
|
+
toolActivity: {
|
|
59
|
+
name,
|
|
60
|
+
state: input.success ? 'success' : 'error',
|
|
61
|
+
detail: '',
|
|
62
|
+
...(command ? { command } : {}),
|
|
63
|
+
body,
|
|
64
|
+
callId: input.callId,
|
|
65
|
+
seq: input.sequence,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
}
|
|
69
|
+
function clipDisplayText(text, limit) {
|
|
70
|
+
const characters = [...text];
|
|
71
|
+
return characters.length > limit ? `${characters.slice(0, limit - 1).join('')}…` : text;
|
|
72
|
+
}
|
|
73
|
+
//# sourceMappingURL=tool-transcript-entry.js.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import type { Message } from '../services/llm';
|
|
2
2
|
import type { HarnessState } from '../harness/types';
|
|
3
3
|
import type { StopDecision } from '../framework/stop-decision';
|
|
4
|
-
import { ThreadEventStore } from './thread-event-store';
|
|
4
|
+
import { ThreadEventStore, type AppendRuntimeEventV1 } from './thread-event-store';
|
|
5
5
|
export type TurnCommitTerminalV1 = {
|
|
6
6
|
readonly status: 'completed';
|
|
7
7
|
readonly outcome?: string;
|
|
@@ -96,6 +96,9 @@ export declare class ThreadTurnCommitJournalV1 {
|
|
|
96
96
|
constructor(store: ThreadEventStore, clock?: () => number);
|
|
97
97
|
commit(input: ThreadTurnCommitInputV1): TurnCommitV1;
|
|
98
98
|
}
|
|
99
|
+
export declare function turnCommitEventV1(commit: TurnCommitV1): AppendRuntimeEventV1<Extract<import('./protocol/runtime-protocol-v1').RuntimeEventV1, {
|
|
100
|
+
type: 'turn.committed';
|
|
101
|
+
}>>;
|
|
99
102
|
export declare function createTurnCommitV1(input: Omit<TurnCommitV1, 'version' | 'terminal' | 'history' | 'historyDigest' | 'taskContext' | 'taskContextDigest' | 'goalState' | 'goalStateDigest' | 'compactPointer' | 'compactPointerDigest' | 'stopDecision' | 'stopDecisionDigest' | 'planReceipt' | 'planReceiptDigest' | 'digest'> & Pick<ThreadTurnCommitInputV1, 'history' | 'taskContextState' | 'goalState' | 'compactPointer' | 'stopDecision' | 'plan' | 'terminal'>): TurnCommitV1;
|
|
100
103
|
export declare function parseTurnCommitV1(receipt: string): TurnCommitV1;
|
|
101
104
|
export declare function createPlanReceiptV1(input: Omit<PlanReceiptV1, 'version' | 'planDigest' | 'digest'>): PlanReceiptV1;
|