@orion-agents/orion-code 0.3.66 → 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 +81 -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 +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 -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 +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-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
|
@@ -0,0 +1,342 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.createTaskRecoveryBinder = createTaskRecoveryBinder;
|
|
4
|
+
exports.projectTaskToolEvidence = projectTaskToolEvidence;
|
|
5
|
+
exports.recordTaskTodoToolReceipt = recordTaskTodoToolReceipt;
|
|
6
|
+
exports.recoverInterruptedTaskContext = recoverInterruptedTaskContext;
|
|
7
|
+
const crypto_1 = require("crypto");
|
|
8
|
+
const path_1 = require("path");
|
|
9
|
+
const tool_serializer_1 = require("../framework/tool-serializer");
|
|
10
|
+
const verification_command_1 = require("../framework/verification-command");
|
|
11
|
+
const verification_1 = require("../harness/verification");
|
|
12
|
+
const redaction_1 = require("../services/redaction");
|
|
13
|
+
const common_1 = require("../tools/core/common");
|
|
14
|
+
const canonical_1 = require("./protocol/canonical");
|
|
15
|
+
const task_context_service_1 = require("./task-context-service");
|
|
16
|
+
const thread_tool_journal_1 = require("./thread-tool-journal");
|
|
17
|
+
const tool_receipt_validator_1 = require("./tool-receipt-validator");
|
|
18
|
+
const turn_commit_1 = require("./turn-commit");
|
|
19
|
+
const interrupted = 'runtime_restarted_before_terminal_commit';
|
|
20
|
+
function createTaskRecoveryBinder(taskContext, previousCommitDigest, progressAtAdmission) {
|
|
21
|
+
let checkpoint;
|
|
22
|
+
return (input) => {
|
|
23
|
+
const { descriptor, name, args, cwd, activeTodoId } = input;
|
|
24
|
+
if (descriptor?.executorId !== `builtin:${name}:v1`)
|
|
25
|
+
return undefined;
|
|
26
|
+
if (!activeTodoId &&
|
|
27
|
+
!['write_file', 'edit_file', 'read_file', 'todo_write', 'exec_command'].includes(name)) {
|
|
28
|
+
return undefined;
|
|
29
|
+
}
|
|
30
|
+
let seed;
|
|
31
|
+
if (!checkpoint) {
|
|
32
|
+
const state = taskContext.exportState();
|
|
33
|
+
seed = {
|
|
34
|
+
priorCommitDigest: previousCommitDigest() ?? null,
|
|
35
|
+
cwd: (0, path_1.resolve)(cwd),
|
|
36
|
+
revision: taskContext.revision,
|
|
37
|
+
state,
|
|
38
|
+
progressAtAdmission,
|
|
39
|
+
};
|
|
40
|
+
checkpoint = { digest: (0, canonical_1.digestRuntimeValue)(seed), epoch: state.taskEpoch ?? 1 };
|
|
41
|
+
}
|
|
42
|
+
const command = name === 'exec_command' &&
|
|
43
|
+
typeof args.command === 'string' &&
|
|
44
|
+
(0, verification_command_1.classifyDirectVerificationCommand)(args.command) &&
|
|
45
|
+
(0, redaction_1.redactTraceText)(args.command) === args.command
|
|
46
|
+
? args.command
|
|
47
|
+
: undefined;
|
|
48
|
+
const path = typeof args.path === 'string'
|
|
49
|
+
? (0, verification_1.workspaceArtifactPath)(cwd, (0, common_1.normalizeToolPath)(args.path))
|
|
50
|
+
: undefined;
|
|
51
|
+
return {
|
|
52
|
+
version: 1,
|
|
53
|
+
seedDigest: checkpoint.digest,
|
|
54
|
+
...(seed ? { seed } : {}),
|
|
55
|
+
taskContractId: taskContext.getContract()?.id ?? null,
|
|
56
|
+
taskEpoch: checkpoint.epoch,
|
|
57
|
+
activeTodoId,
|
|
58
|
+
readOnly: descriptor.risk.readOnly,
|
|
59
|
+
...((name === 'write_file' || name === 'edit_file') && path && args.preview !== true
|
|
60
|
+
? { workspaceWrite: true }
|
|
61
|
+
: {}),
|
|
62
|
+
args: {
|
|
63
|
+
path,
|
|
64
|
+
command,
|
|
65
|
+
cwd: command && typeof args.cwd === 'string' ? (0, common_1.normalizeToolPath)(args.cwd) : undefined,
|
|
66
|
+
},
|
|
67
|
+
};
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
/** Derive evidence from the executor's committed outcome, not its display text. */
|
|
71
|
+
function projectTaskToolEvidence(receipt, args, cwd) {
|
|
72
|
+
if (receipt.terminalPhase !== 'execute')
|
|
73
|
+
return {};
|
|
74
|
+
const reportedWritePath = receipt.result.metadata?.workspaceWritePath;
|
|
75
|
+
const changedFile = receipt.success &&
|
|
76
|
+
(receipt.toolName === 'write_file' || receipt.toolName === 'edit_file') &&
|
|
77
|
+
typeof reportedWritePath === 'string'
|
|
78
|
+
? (0, verification_1.workspaceArtifactPath)(cwd, reportedWritePath)
|
|
79
|
+
: undefined;
|
|
80
|
+
const command = receipt.toolName === 'exec_command' && typeof args.command === 'string'
|
|
81
|
+
? args.command
|
|
82
|
+
: undefined;
|
|
83
|
+
const kind = command && (0, verification_command_1.classifyDirectVerificationCommand)(command);
|
|
84
|
+
const verification = command && kind
|
|
85
|
+
? {
|
|
86
|
+
kind,
|
|
87
|
+
toolReceiptDigest: receipt.digest,
|
|
88
|
+
command,
|
|
89
|
+
cwd: (0, path_1.resolve)(cwd, typeof args.cwd === 'string' ? (0, common_1.normalizeToolPath)(args.cwd) : '.'),
|
|
90
|
+
passed: receipt.success,
|
|
91
|
+
}
|
|
92
|
+
: undefined;
|
|
93
|
+
return { changedFile, verification };
|
|
94
|
+
}
|
|
95
|
+
function recordTaskTodoToolReceipt(taskContext, todo, receipt, { changedFile, verification }) {
|
|
96
|
+
if (!todo || receipt.terminalPhase !== 'execute' || (!receipt.success && !verification))
|
|
97
|
+
return;
|
|
98
|
+
taskContext.recordTaskTodoReceipt(todo, {
|
|
99
|
+
digest: receipt.digest,
|
|
100
|
+
passed: receipt.success,
|
|
101
|
+
kind: (0, verification_command_1.isLocalVerificationKind)(verification?.kind) ? verification.kind : undefined,
|
|
102
|
+
changedFile,
|
|
103
|
+
command: verification?.command,
|
|
104
|
+
cwd: verification?.cwd,
|
|
105
|
+
});
|
|
106
|
+
}
|
|
107
|
+
/** Restore already-made effects. This never dispatches a model request or reexecutes a tool. */
|
|
108
|
+
function recoverInterruptedTaskContext(input) {
|
|
109
|
+
const { store, previousCommit, taskOptions, restoreGoalState } = input;
|
|
110
|
+
const projection = store.loadProjection();
|
|
111
|
+
const turnId = projection.activeTurnId;
|
|
112
|
+
if (!turnId)
|
|
113
|
+
return;
|
|
114
|
+
const turn = projection.turns[turnId];
|
|
115
|
+
if (turn.commit || turn.mode === 'maintenance')
|
|
116
|
+
return;
|
|
117
|
+
const events = [];
|
|
118
|
+
let cursor = turn.startedSeq;
|
|
119
|
+
while (cursor < projection.cursor) {
|
|
120
|
+
const page = store.replay(cursor, undefined, 'task_context_recovery');
|
|
121
|
+
events.push(...page.events.filter(event => event.turnId === turnId && event.seq <= projection.cursor));
|
|
122
|
+
cursor = page.nextCursor;
|
|
123
|
+
}
|
|
124
|
+
const steps = new Map();
|
|
125
|
+
const intents = new Map();
|
|
126
|
+
let checkpoint;
|
|
127
|
+
for (const event of events) {
|
|
128
|
+
if (event.payload.type === 'step.snapshot' && event.stepId) {
|
|
129
|
+
steps.set(event.stepId, event);
|
|
130
|
+
}
|
|
131
|
+
const entry = readBoundIntent(event, steps);
|
|
132
|
+
if (!entry)
|
|
133
|
+
continue;
|
|
134
|
+
intents.set(entry.intent.invocationId, entry);
|
|
135
|
+
if (!checkpoint &&
|
|
136
|
+
entry.binding.seed &&
|
|
137
|
+
validSeed(entry.binding, previousCommit, taskOptions.cwd)) {
|
|
138
|
+
checkpoint = entry;
|
|
139
|
+
}
|
|
140
|
+
}
|
|
141
|
+
const goalState = restoreGoalState();
|
|
142
|
+
const goalInterruptedBeforeTools = turn.mode === 'goal' &&
|
|
143
|
+
goalState &&
|
|
144
|
+
'status' in goalState &&
|
|
145
|
+
goalState.status === 'paused' &&
|
|
146
|
+
turn.itemIds.every(itemId => projection.items[itemId].kind !== 'command');
|
|
147
|
+
// A Goal can crash on its first provider request, before a task seed is
|
|
148
|
+
// bound to any tool. Persist its pause or a later reopen will see only the
|
|
149
|
+
// older active Goal state and start another request.
|
|
150
|
+
if (!checkpoint?.binding.seed && !goalInterruptedBeforeTools)
|
|
151
|
+
return;
|
|
152
|
+
const receipts = new Map();
|
|
153
|
+
for (const [index, fact] of events.entries()) {
|
|
154
|
+
if (fact.payload.type !== 'tool.receipt' || !fact.itemId)
|
|
155
|
+
continue;
|
|
156
|
+
const item = projection.items[fact.itemId];
|
|
157
|
+
const terminal = events[index + 1];
|
|
158
|
+
if (!item?.name || !item.intent || !terminal || receipts.has(item.itemId))
|
|
159
|
+
continue;
|
|
160
|
+
const receipt = linkedReceipt(fact, terminal, item.itemId, item.name, item.intent);
|
|
161
|
+
if (!receipt)
|
|
162
|
+
continue;
|
|
163
|
+
receipts.set(item.itemId, { seq: fact.seq, value: receipt });
|
|
164
|
+
}
|
|
165
|
+
let taskContextState = taskOptions.state;
|
|
166
|
+
let taskContextRevision = taskOptions.revision;
|
|
167
|
+
if (checkpoint?.binding.seed) {
|
|
168
|
+
const { seed, seedDigest, taskContractId, taskEpoch } = checkpoint.binding;
|
|
169
|
+
const taskContext = (0, task_context_service_1.createTaskContextService)({
|
|
170
|
+
...taskOptions,
|
|
171
|
+
state: seed.state,
|
|
172
|
+
revision: seed.revision,
|
|
173
|
+
requireLocalVerificationReceipt: true,
|
|
174
|
+
});
|
|
175
|
+
let unconfirmedWorkspaceRevisions = 0;
|
|
176
|
+
for (const event of events) {
|
|
177
|
+
if (!event.itemId || event.seq < checkpoint.event.seq)
|
|
178
|
+
continue;
|
|
179
|
+
const bound = intents.get(event.itemId);
|
|
180
|
+
if (!bound ||
|
|
181
|
+
bound.binding.seedDigest !== seedDigest ||
|
|
182
|
+
bound.binding.taskContractId !== taskContractId ||
|
|
183
|
+
bound.binding.taskEpoch !== taskEpoch) {
|
|
184
|
+
continue;
|
|
185
|
+
}
|
|
186
|
+
const receipt = receipts.get(event.itemId);
|
|
187
|
+
if (receipt?.seq === event.seq && receipt.value.terminalPhase === 'execute') {
|
|
188
|
+
restoreToolObservation(taskContext, receipt.value, bound.binding, seed.cwd);
|
|
189
|
+
}
|
|
190
|
+
else if (event.payload.type === 'item.started' &&
|
|
191
|
+
!receipt &&
|
|
192
|
+
bound.binding.workspaceWrite) {
|
|
193
|
+
// The filesystem effect is unknown. Invalidate earlier test results
|
|
194
|
+
// without adding file-change evidence for this invocation.
|
|
195
|
+
taskContext.noteIndeterminateWorkspaceChange();
|
|
196
|
+
unconfirmedWorkspaceRevisions++;
|
|
197
|
+
}
|
|
198
|
+
}
|
|
199
|
+
taskContext.recordProgress(seed.progressAtAdmission, unconfirmedWorkspaceRevisions);
|
|
200
|
+
taskContextState = taskContext.exportState();
|
|
201
|
+
taskContextRevision = taskContext.revision;
|
|
202
|
+
}
|
|
203
|
+
if (!taskContextState || taskContextRevision === undefined)
|
|
204
|
+
return;
|
|
205
|
+
const openItems = turn.itemIds
|
|
206
|
+
.map(itemId => projection.items[itemId])
|
|
207
|
+
.filter(item => item.status === 'started')
|
|
208
|
+
.map(item => ({
|
|
209
|
+
turnId,
|
|
210
|
+
itemId: item.itemId,
|
|
211
|
+
stepId: item.stepId,
|
|
212
|
+
payload: { type: 'item.indeterminate', data: { reason: interrupted } },
|
|
213
|
+
}));
|
|
214
|
+
// On a newly cut-over Session the provider still uses its imported transcript
|
|
215
|
+
// until the first TurnCommit. Preserve that same base on recovery.
|
|
216
|
+
const history = (store.loadAuthoritativeModelHistory() ??
|
|
217
|
+
input.loadImportedHistory?.() ??
|
|
218
|
+
[]);
|
|
219
|
+
const commit = (0, turn_commit_1.createTurnCommitV1)({
|
|
220
|
+
commitId: (0, crypto_1.randomUUID)(),
|
|
221
|
+
threadId: store.threadId,
|
|
222
|
+
turnId,
|
|
223
|
+
sourceCursor: projection.cursor + openItems.length,
|
|
224
|
+
createdAt: Date.now(),
|
|
225
|
+
history,
|
|
226
|
+
taskContextState,
|
|
227
|
+
taskContextRevision,
|
|
228
|
+
terminal: { status: 'interrupted', reason: interrupted },
|
|
229
|
+
goalState,
|
|
230
|
+
stepSnapshotDigests: events.flatMap(event => event.payload.type === 'step.snapshot' ? [event.payload.data.digest] : []),
|
|
231
|
+
capabilityReceiptDigests: events.flatMap(event => event.payload.type === 'capability.receipt' ? [event.payload.data.digest] : []),
|
|
232
|
+
toolReceiptDigests: [...receipts.values()].map(receipt => receipt.value.digest),
|
|
233
|
+
});
|
|
234
|
+
store.appendDurableBatch([
|
|
235
|
+
...openItems,
|
|
236
|
+
(0, turn_commit_1.turnCommitEventV1)(commit),
|
|
237
|
+
{ turnId, payload: { type: 'turn.interrupted', data: { reason: interrupted } } },
|
|
238
|
+
], projection.cursor);
|
|
239
|
+
return commit;
|
|
240
|
+
}
|
|
241
|
+
function readBoundIntent(event, steps) {
|
|
242
|
+
if (event.payload.type !== 'item.started' ||
|
|
243
|
+
event.payload.data.kind !== 'command' ||
|
|
244
|
+
!event.payload.data.intent ||
|
|
245
|
+
!event.stepId)
|
|
246
|
+
return;
|
|
247
|
+
const step = steps.get(event.stepId);
|
|
248
|
+
if (step?.payload.type !== 'step.snapshot')
|
|
249
|
+
return;
|
|
250
|
+
const intent = tryParseIntent(event.payload.data.intent);
|
|
251
|
+
const binding = intent?.taskRecovery;
|
|
252
|
+
if (!intent ||
|
|
253
|
+
!binding ||
|
|
254
|
+
binding.version !== 1 ||
|
|
255
|
+
!binding.args ||
|
|
256
|
+
intent.parentInvocationId ||
|
|
257
|
+
intent.invocationId !== event.itemId ||
|
|
258
|
+
intent.threadId !== event.threadId ||
|
|
259
|
+
intent.turnId !== event.turnId ||
|
|
260
|
+
intent.stepId !== event.stepId ||
|
|
261
|
+
intent.toolName !== event.payload.data.name ||
|
|
262
|
+
intent.requestDigest !== event.payload.data.inputDigest ||
|
|
263
|
+
intent.snapshotDigest !== step.payload.data.digest)
|
|
264
|
+
return;
|
|
265
|
+
return { event, intent, binding };
|
|
266
|
+
}
|
|
267
|
+
function validSeed(binding, previousCommit, workspace) {
|
|
268
|
+
const seed = binding.seed;
|
|
269
|
+
return Boolean(seed &&
|
|
270
|
+
seed.cwd === (0, path_1.resolve)(workspace) &&
|
|
271
|
+
Array.isArray(seed.state?.ledger) &&
|
|
272
|
+
seed.progressAtAdmission &&
|
|
273
|
+
Number.isSafeInteger(seed.revision) &&
|
|
274
|
+
seed.revision >= (previousCommit?.taskContextRevision ?? 0) &&
|
|
275
|
+
seed.priorCommitDigest === (previousCommit?.digest ?? null) &&
|
|
276
|
+
(seed.state.contract?.id ?? null) === binding.taskContractId &&
|
|
277
|
+
(seed.state.taskEpoch ?? 1) === binding.taskEpoch &&
|
|
278
|
+
(0, canonical_1.digestRuntimeValue)(seed) === binding.seedDigest);
|
|
279
|
+
}
|
|
280
|
+
function linkedReceipt(factEvent, terminalEvent, itemId, toolName, storedIntent) {
|
|
281
|
+
const intent = tryParseIntent(storedIntent);
|
|
282
|
+
if (!intent)
|
|
283
|
+
return;
|
|
284
|
+
try {
|
|
285
|
+
const receipt = (0, tool_receipt_validator_1.validateDurableToolInvocationReceiptV1)({
|
|
286
|
+
factEvent,
|
|
287
|
+
terminalEvent,
|
|
288
|
+
item: { itemId, toolName },
|
|
289
|
+
});
|
|
290
|
+
return receipt.intentDigest === intent.digest &&
|
|
291
|
+
receipt.invocationId === intent.invocationId &&
|
|
292
|
+
receipt.threadId === intent.threadId &&
|
|
293
|
+
receipt.turnId === intent.turnId &&
|
|
294
|
+
receipt.stepId === intent.stepId &&
|
|
295
|
+
receipt.parentInvocationId === intent.parentInvocationId &&
|
|
296
|
+
receipt.snapshotDigest === intent.snapshotDigest &&
|
|
297
|
+
receipt.toolName === intent.toolName
|
|
298
|
+
? receipt
|
|
299
|
+
: undefined;
|
|
300
|
+
}
|
|
301
|
+
catch (error) {
|
|
302
|
+
if (!(error instanceof tool_receipt_validator_1.DurableToolReceiptValidationError))
|
|
303
|
+
throw error;
|
|
304
|
+
return undefined;
|
|
305
|
+
}
|
|
306
|
+
}
|
|
307
|
+
function tryParseIntent(value) {
|
|
308
|
+
try {
|
|
309
|
+
return (0, thread_tool_journal_1.parseToolInvocationIntentV1)(value);
|
|
310
|
+
}
|
|
311
|
+
catch {
|
|
312
|
+
return undefined;
|
|
313
|
+
}
|
|
314
|
+
}
|
|
315
|
+
function restoreToolObservation(taskContext, receipt, binding, cwd) {
|
|
316
|
+
if (receipt.toolName === 'todo_write') {
|
|
317
|
+
const todos = receipt.result.metadata?.taskTodos;
|
|
318
|
+
if (receipt.success &&
|
|
319
|
+
Array.isArray(todos) &&
|
|
320
|
+
todos.length > 0 &&
|
|
321
|
+
todos.every(todo => typeof todo?.content === 'string' &&
|
|
322
|
+
typeof todo.activeForm === 'string' &&
|
|
323
|
+
['pending', 'in_progress', 'completed'].includes(todo.status)))
|
|
324
|
+
taskContext.updateTaskTodos(todos);
|
|
325
|
+
return;
|
|
326
|
+
}
|
|
327
|
+
const evidence = projectTaskToolEvidence(receipt, binding.args, cwd);
|
|
328
|
+
recordTaskTodoToolReceipt(taskContext, binding.activeTodoId, receipt, evidence);
|
|
329
|
+
taskContext.observeToolResult({
|
|
330
|
+
name: receipt.toolName,
|
|
331
|
+
args: { ...binding.args },
|
|
332
|
+
result: (0, tool_serializer_1.serializeToolResult)(receipt.result),
|
|
333
|
+
duration: receipt.durationMs,
|
|
334
|
+
success: receipt.success,
|
|
335
|
+
error: receipt.result.error,
|
|
336
|
+
summary: receipt.result.summary,
|
|
337
|
+
toolReceiptDigest: receipt.digest,
|
|
338
|
+
readOnly: binding.readOnly,
|
|
339
|
+
...evidence,
|
|
340
|
+
});
|
|
341
|
+
}
|
|
342
|
+
//# sourceMappingURL=task-context-recovery.js.map
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
+
import { HarnessKernel } from '../harness/context-harness';
|
|
1
2
|
import type { PromptAssemblyOptions } from '../harness/assembler';
|
|
2
3
|
import type { CreateTurnSummaryInput } from '../harness/turn-summary';
|
|
3
|
-
import type { CapabilityProfileInput, CompletionGateResult, ContextCapsule, DriftCheckResult, HarnessConfig, HarnessState, IntentUpdate, TaskContract, TurnSummary } from '../harness/types';
|
|
4
|
+
import type { CapabilityProfileInput, CompletionGateResult, ContextCapsule, DriftCheckResult, HarnessConfig, HarnessProgressState, HarnessState, IntentUpdate, TaskContract, TaskTodoObservation, TaskWorkspaceAction, ToolResultObservation, TurnSummary } from '../harness/types';
|
|
4
5
|
import type { LLMResponse, Message } from '../services/llm';
|
|
5
6
|
export type DeepReadonly<T> = T extends (...args: never[]) => unknown ? T : T extends readonly (infer U)[] ? readonly DeepReadonly<U>[] : T extends object ? {
|
|
6
7
|
readonly [K in keyof T]: DeepReadonly<T[K]>;
|
|
@@ -11,18 +12,13 @@ export interface TaskContextServiceOptions {
|
|
|
11
12
|
readonly state?: HarnessState;
|
|
12
13
|
readonly config?: HarnessConfig;
|
|
13
14
|
readonly revision?: number;
|
|
15
|
+
readonly requireLocalVerificationReceipt?: boolean;
|
|
14
16
|
}
|
|
15
17
|
export interface TaskContextToolInput {
|
|
16
18
|
readonly name: string;
|
|
17
19
|
readonly args: Record<string, unknown>;
|
|
18
20
|
}
|
|
19
|
-
export
|
|
20
|
-
readonly result: string;
|
|
21
|
-
readonly duration: number;
|
|
22
|
-
readonly success: boolean;
|
|
23
|
-
readonly error?: string;
|
|
24
|
-
readonly summary?: string;
|
|
25
|
-
}
|
|
21
|
+
export type TaskContextToolResultInput = ToolResultObservation;
|
|
26
22
|
export interface TaskContextAppliedSkill {
|
|
27
23
|
readonly name: string;
|
|
28
24
|
readonly source?: string;
|
|
@@ -65,7 +61,7 @@ export interface TaskContextExplanation {
|
|
|
65
61
|
export interface TaskContextService {
|
|
66
62
|
readonly serviceId: 'task-context';
|
|
67
63
|
readonly revision: number;
|
|
68
|
-
observeUserInput(input: string): DeepReadonly<IntentUpdate> | undefined;
|
|
64
|
+
observeUserInput(input: string, goalTaskId?: string): DeepReadonly<IntentUpdate> | undefined;
|
|
69
65
|
classifyIntent(input: string): DeepReadonly<IntentUpdate>;
|
|
70
66
|
observeCapability(input: CapabilityProfileInput): DeepReadonly<HarnessState['capabilityProfile']>;
|
|
71
67
|
assembleMessages(messages: Message[], options?: PromptAssemblyOptions): Message[];
|
|
@@ -73,8 +69,18 @@ export interface TaskContextService {
|
|
|
73
69
|
observeAppliedSkills(skills: TaskContextAppliedSkill[]): void;
|
|
74
70
|
checkToolUse(input: TaskContextToolInput): DeepReadonly<DriftCheckResult>;
|
|
75
71
|
observeToolResult(input: TaskContextToolResultInput): void;
|
|
72
|
+
noteIndeterminateWorkspaceChange(): void;
|
|
76
73
|
observeTurn(input: TaskContextTurnInput): DeepReadonly<TurnSummary> | undefined;
|
|
77
|
-
|
|
74
|
+
activeTaskTodo(): string | undefined;
|
|
75
|
+
hasTaskTodos(): boolean;
|
|
76
|
+
missingExecutionChecklist(action?: TaskWorkspaceAction): string | undefined;
|
|
77
|
+
prepareTaskPlanStopCheck(): ReturnType<HarnessKernel['prepareTaskPlanStopCheck']>;
|
|
78
|
+
requiresVerification(): boolean;
|
|
79
|
+
recordTaskTodoReceipt(step: string, observation: TaskTodoObservation): void;
|
|
80
|
+
updateTaskTodos(todos: NonNullable<HarnessState['taskTodos']>): string | undefined;
|
|
81
|
+
progressState(): HarnessProgressState;
|
|
82
|
+
recordProgress(baseline: HarnessProgressState, unconfirmedWorkspaceRevisions?: number): void;
|
|
83
|
+
auditCompletion(enforceTaskTodos?: boolean, requireEveryCriterion?: boolean): TaskContextCompletionDecisionV1;
|
|
78
84
|
completionBlockedMessage(result: CompletionGateResult): Message;
|
|
79
85
|
toolBlockedResult(result: DriftCheckResult): string;
|
|
80
86
|
linkEvidence(criterionId: string, evidenceRef: string): boolean;
|
|
@@ -26,13 +26,14 @@ class HarnessKernelTaskContextService {
|
|
|
26
26
|
modelId: options.modelId,
|
|
27
27
|
state: options.state ? structuredClone(options.state) : undefined,
|
|
28
28
|
config: { completionGate: 'block', ...options.config },
|
|
29
|
+
requireLocalVerificationReceipt: options.requireLocalVerificationReceipt,
|
|
29
30
|
});
|
|
30
31
|
}
|
|
31
32
|
get revision() {
|
|
32
33
|
return this.revisionValue;
|
|
33
34
|
}
|
|
34
|
-
observeUserInput(input) {
|
|
35
|
-
const result = this.mutate(() => this.kernel.updateContractFromUserInput(input));
|
|
35
|
+
observeUserInput(input, goalTaskId) {
|
|
36
|
+
const result = this.mutate(() => this.kernel.updateContractFromUserInput(input, goalTaskId));
|
|
36
37
|
return result ? immutableClone(result) : undefined;
|
|
37
38
|
}
|
|
38
39
|
classifyIntent(input) {
|
|
@@ -56,12 +57,42 @@ class HarnessKernelTaskContextService {
|
|
|
56
57
|
observeToolResult(input) {
|
|
57
58
|
this.mutate(() => this.kernel.recordToolResult(input));
|
|
58
59
|
}
|
|
60
|
+
noteIndeterminateWorkspaceChange() {
|
|
61
|
+
this.mutate(() => this.kernel.noteIndeterminateWorkspaceChange());
|
|
62
|
+
}
|
|
59
63
|
observeTurn(input) {
|
|
60
64
|
const result = this.mutate(() => this.kernel.ingestTurn(input));
|
|
61
65
|
return result ? immutableClone(result) : undefined;
|
|
62
66
|
}
|
|
63
|
-
|
|
64
|
-
|
|
67
|
+
activeTaskTodo() {
|
|
68
|
+
return this.kernel.activeTaskTodo();
|
|
69
|
+
}
|
|
70
|
+
hasTaskTodos() {
|
|
71
|
+
return this.kernel.hasTaskTodos();
|
|
72
|
+
}
|
|
73
|
+
missingExecutionChecklist(action) {
|
|
74
|
+
return this.kernel.missingExecutionChecklist(action);
|
|
75
|
+
}
|
|
76
|
+
prepareTaskPlanStopCheck() {
|
|
77
|
+
return this.kernel.prepareTaskPlanStopCheck();
|
|
78
|
+
}
|
|
79
|
+
requiresVerification() {
|
|
80
|
+
return this.kernel.requiresVerification();
|
|
81
|
+
}
|
|
82
|
+
recordTaskTodoReceipt(step, observation) {
|
|
83
|
+
this.mutate(() => this.kernel.recordTaskTodoReceipt(step, observation));
|
|
84
|
+
}
|
|
85
|
+
updateTaskTodos(todos) {
|
|
86
|
+
return this.mutate(() => this.kernel.updateTaskTodos(todos));
|
|
87
|
+
}
|
|
88
|
+
progressState() {
|
|
89
|
+
return this.kernel.progressState();
|
|
90
|
+
}
|
|
91
|
+
recordProgress(baseline, unconfirmedWorkspaceRevisions) {
|
|
92
|
+
this.mutate(() => this.kernel.recordProgress(baseline, unconfirmedWorkspaceRevisions));
|
|
93
|
+
}
|
|
94
|
+
auditCompletion(enforceTaskTodos = false, requireEveryCriterion = false) {
|
|
95
|
+
const result = this.mutate(() => this.kernel.beforeComplete(enforceTaskTodos, requireEveryCriterion));
|
|
65
96
|
return immutableClone({
|
|
66
97
|
...result,
|
|
67
98
|
version: 1,
|
|
@@ -104,7 +104,7 @@ export declare class ThreadAdmissionControllerV1 {
|
|
|
104
104
|
admit(command: Extract<AgentRuntimeCommandV1, {
|
|
105
105
|
type: 'turn.start' | 'turn.steer' | 'turn.follow_up' | 'turn.interrupt';
|
|
106
106
|
}>): ThreadCommandAdmissionV1;
|
|
107
|
-
start(request: ThreadTurnRequestV1): TurnAdmissionV1;
|
|
107
|
+
start(request: ThreadTurnRequestV1, pendingFollowupId?: string): TurnAdmissionV1;
|
|
108
108
|
followUp(request: ThreadTurnRequestV1): TurnAdmissionV1;
|
|
109
109
|
steer(input: string): TurnAdmissionV1;
|
|
110
110
|
interrupt(): InterruptAdmissionV1;
|
|
@@ -46,8 +46,8 @@ class ThreadAdmissionControllerV1 {
|
|
|
46
46
|
return this.interrupt();
|
|
47
47
|
}
|
|
48
48
|
}
|
|
49
|
-
start(request) {
|
|
50
|
-
return this.admitTurn(request, 'start');
|
|
49
|
+
start(request, pendingFollowupId) {
|
|
50
|
+
return this.admitTurn(request, 'start', pendingFollowupId);
|
|
51
51
|
}
|
|
52
52
|
followUp(request) {
|
|
53
53
|
return this.admitTurn(request, 'follow_up');
|
|
@@ -175,9 +175,15 @@ class ThreadAdmissionControllerV1 {
|
|
|
175
175
|
this.continuationMode = snapshot.continuationMode;
|
|
176
176
|
this.shutdown = snapshot.shutdown;
|
|
177
177
|
}
|
|
178
|
-
admitTurn(request, source) {
|
|
178
|
+
admitTurn(request, source, pendingFollowupId) {
|
|
179
179
|
if (this.shutdown)
|
|
180
180
|
return rejected('shutdown');
|
|
181
|
+
if (pendingFollowupId !== undefined) {
|
|
182
|
+
if (!(0, runtime_protocol_v1_1.isRuntimeId)(pendingFollowupId))
|
|
183
|
+
return rejected('invalid_input');
|
|
184
|
+
if (this.activeTurn || this.queue.length > 0)
|
|
185
|
+
return rejected('overloaded');
|
|
186
|
+
}
|
|
181
187
|
const now = this.clock();
|
|
182
188
|
this.dropExpired(now);
|
|
183
189
|
const inputBytes = Buffer.byteLength(request.input, 'utf8');
|
|
@@ -188,7 +194,7 @@ class ThreadAdmissionControllerV1 {
|
|
|
188
194
|
}
|
|
189
195
|
const kind = request.kind ?? (request.mode === 'maintenance' ? 'maintenance' : 'regular');
|
|
190
196
|
if (!this.activeTurn) {
|
|
191
|
-
const active = this.begin({ ...request, kind }, now);
|
|
197
|
+
const active = this.begin({ ...request, kind }, now, pendingFollowupId);
|
|
192
198
|
return { status: 'started', turnId: active.turnId };
|
|
193
199
|
}
|
|
194
200
|
if (this.queue.length >= this.maxQueuedItems ||
|
|
@@ -212,9 +218,9 @@ class ThreadAdmissionControllerV1 {
|
|
|
212
218
|
this.queuedBytes += inputBytes;
|
|
213
219
|
return { status: 'queued', queueId, position: this.queue.length, deadline };
|
|
214
220
|
}
|
|
215
|
-
begin(request, now) {
|
|
221
|
+
begin(request, now, pendingFollowupId) {
|
|
216
222
|
const active = {
|
|
217
|
-
turnId: this.nextId('turn'),
|
|
223
|
+
turnId: pendingFollowupId ?? this.nextId('turn'),
|
|
218
224
|
input: request.input,
|
|
219
225
|
mode: request.mode,
|
|
220
226
|
kind: request.kind,
|
|
@@ -14,7 +14,7 @@ export interface ThreadEventReplayV1 {
|
|
|
14
14
|
readonly nextCursor: number;
|
|
15
15
|
readonly hasMore: boolean;
|
|
16
16
|
}
|
|
17
|
-
export type ThreadEventReplayReasonV1 = 'direct' | 'capability_receipt_journal' | 'durable_tool_receipt' | 'legacy_materializer' | 'projection_schema_upgrade' | 'runtime_diagnostics_legacy' | 'subagent_receipt_journal' | 'thread_session_view' | 'turn_commit_journal' | 'ui_gap_recovery' | 'ui_initial_history';
|
|
17
|
+
export type ThreadEventReplayReasonV1 = 'direct' | 'capability_receipt_journal' | 'durable_tool_receipt' | 'legacy_materializer' | 'projection_schema_upgrade' | 'runtime_diagnostics_legacy' | 'subagent_receipt_journal' | 'task_context_recovery' | 'thread_session_view' | 'turn_commit_journal' | 'ui_gap_recovery' | 'ui_initial_history';
|
|
18
18
|
export interface ThreadEventCommitV1 {
|
|
19
19
|
readonly events: readonly RuntimeEventEnvelopeV1[];
|
|
20
20
|
readonly projection: ThreadProjectionV1;
|
|
@@ -125,7 +125,7 @@ export declare class ThreadEventStore {
|
|
|
125
125
|
private cachedHead?;
|
|
126
126
|
constructor(rootDir: string, threadId: string, options?: ThreadEventStoreOptionsV1);
|
|
127
127
|
appendDurable<T extends RuntimeEventV1>(input: AppendRuntimeEventV1<T>): RuntimeEventEnvelopeV1<T>;
|
|
128
|
-
appendDurableBatch(inputs: readonly AppendRuntimeEventV1[]): ThreadEventCommitV1;
|
|
128
|
+
appendDurableBatch(inputs: readonly AppendRuntimeEventV1[], expectedCursor?: number): ThreadEventCommitV1;
|
|
129
129
|
/** Observe locally committed durable facts after log and projection fsync. */
|
|
130
130
|
subscribeCommitted(listener: (events: readonly RuntimeEventEnvelopeV1[]) => void): () => void;
|
|
131
131
|
createEphemeral<T extends Extract<RuntimeEventV1, {
|
|
@@ -65,13 +65,16 @@ class ThreadEventStore {
|
|
|
65
65
|
appendDurable(input) {
|
|
66
66
|
return this.appendDurableBatch([input]).events[0];
|
|
67
67
|
}
|
|
68
|
-
appendDurableBatch(inputs) {
|
|
68
|
+
appendDurableBatch(inputs, expectedCursor) {
|
|
69
69
|
if (inputs.length === 0) {
|
|
70
70
|
return { events: [], projection: this.loadProjection() };
|
|
71
71
|
}
|
|
72
72
|
const commit = this.withLogLock(() => {
|
|
73
73
|
ensurePrivateDirectory(this.rootDir);
|
|
74
74
|
let head = this.loadVerifiedHead();
|
|
75
|
+
if (expectedCursor !== undefined && head.projection.cursor !== expectedCursor) {
|
|
76
|
+
throw new ThreadEventStoreError('ORION_THREAD_EVENT_CURSOR', `Thread changed before append (expected cursor ${expectedCursor}, found ${head.projection.cursor})`);
|
|
77
|
+
}
|
|
75
78
|
if (!(0, thread_projection_1.hasCurrentThreadProjectionShapeV1)(head.projection)) {
|
|
76
79
|
// An older projection cannot be incrementally advanced because it did
|
|
77
80
|
// not retain all diagnostic/compact history. Rebuild from facts once.
|
|
@@ -535,7 +538,9 @@ class ThreadEventStore {
|
|
|
535
538
|
});
|
|
536
539
|
}
|
|
537
540
|
}
|
|
538
|
-
return inputs.length > 0
|
|
541
|
+
return inputs.length > 0
|
|
542
|
+
? this.appendDurableBatch(inputs, projection.cursor).projection
|
|
543
|
+
: projection;
|
|
539
544
|
}
|
|
540
545
|
/**
|
|
541
546
|
* Return the last verified log head. A fresh process may adopt the persisted
|
|
@@ -425,8 +425,10 @@ function resolvePlanReview(state, event) {
|
|
|
425
425
|
}
|
|
426
426
|
const current = state.planReview;
|
|
427
427
|
const data = event.payload.data;
|
|
428
|
-
if (!current ||
|
|
429
|
-
|
|
428
|
+
if (!current ||
|
|
429
|
+
current.status === 'cancelled' ||
|
|
430
|
+
(data.action !== 'cancel' && current.status !== 'awaiting_review')) {
|
|
431
|
+
throw invariant('no plan accepts this review action', event);
|
|
430
432
|
}
|
|
431
433
|
if (current.reviewId !== data.reviewId ||
|
|
432
434
|
current.revision !== data.previousRevision ||
|
|
@@ -115,6 +115,7 @@ export declare class ThreadRuntimeV1 {
|
|
|
115
115
|
private readonly onTurnDurablyTerminal?;
|
|
116
116
|
private readonly onTurnSettled?;
|
|
117
117
|
private readonly consumers;
|
|
118
|
+
private readonly liveObservers;
|
|
118
119
|
private readonly compactMaintenance;
|
|
119
120
|
private readonly goalControlTurns;
|
|
120
121
|
private readonly queuedGoalControls;
|
|
@@ -130,6 +131,10 @@ export declare class ThreadRuntimeV1 {
|
|
|
130
131
|
dispatch(command: Extract<AgentRuntimeCommandV1, {
|
|
131
132
|
type: 'turn.start' | 'turn.steer' | 'turn.follow_up' | 'turn.interrupt';
|
|
132
133
|
}>): ThreadCommandAdmissionV1;
|
|
134
|
+
/** A pending user input and its admitted turn share one identity across crashes. */
|
|
135
|
+
startPendingFollowup(turnId: string, input: string, mode: Exclude<ThreadTurnRequestV1['mode'], 'goal' | 'maintenance'>): ThreadCommandAdmissionV1 | {
|
|
136
|
+
status: 'already_admitted';
|
|
137
|
+
};
|
|
133
138
|
startMaintenance(input: string): ThreadCommandAdmissionV1;
|
|
134
139
|
/**
|
|
135
140
|
* Serialize a Goal control mutation through the same bounded admission and
|
|
@@ -143,6 +148,8 @@ export declare class ThreadRuntimeV1 {
|
|
|
143
148
|
unsubscribe(consumerId: string): void;
|
|
144
149
|
/** Observe committed durable facts without acquiring ownership of the Thread lifecycle. */
|
|
145
150
|
observeCommittedEvents(listener: (events: readonly RuntimeEventEnvelopeV1[]) => void): () => void;
|
|
151
|
+
/** Observe newly published durable events and ephemeral deltas, without replay. */
|
|
152
|
+
observeLiveEvents(listener: (events: readonly RuntimeEventEnvelopeV1[]) => void): () => void;
|
|
146
153
|
replay(cursor?: number, limit?: number, reason?: ThreadEventReplayReasonV1): import("./thread-event-store").ThreadEventReplayV1;
|
|
147
154
|
getProjection(): import("./thread-projection").ThreadProjectionV1;
|
|
148
155
|
getAdmissionSnapshot(): import("./thread-admission").ThreadAdmissionSnapshotV1;
|