@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
|
@@ -1,13 +1,36 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ThreadStepSnapshotJournalV1 = exports.AgentLoopV1 = void 0;
|
|
4
|
+
exports.isFailedLoopStats = isFailedLoopStats;
|
|
5
|
+
exports.serializeAgentLoopOutcome = serializeAgentLoopOutcome;
|
|
4
6
|
exports.deterministicRuntimeId = deterministicRuntimeId;
|
|
5
7
|
const crypto_1 = require("crypto");
|
|
6
8
|
const query_1 = require("../framework/query");
|
|
9
|
+
const terminal_text_1 = require("../utils/terminal-text");
|
|
10
|
+
const task_checklist_1 = require("../harness/task-checklist");
|
|
11
|
+
const ui_view_model_1 = require("./ui-view-model");
|
|
7
12
|
const tool_serializer_1 = require("../framework/tool-serializer");
|
|
13
|
+
const redaction_1 = require("../services/redaction");
|
|
14
|
+
const bash_security_1 = require("../tools/bash_security");
|
|
8
15
|
const canonical_1 = require("./protocol/canonical");
|
|
9
16
|
const thread_compact_persistence_1 = require("./thread-compact-persistence");
|
|
17
|
+
const task_context_recovery_1 = require("./task-context-recovery");
|
|
10
18
|
const step_snapshot_1 = require("./step-snapshot");
|
|
19
|
+
const MAX_REASONING_TRANSCRIPT_CHARS = 16 * 1024;
|
|
20
|
+
function isFailedLoopStats(stats) {
|
|
21
|
+
return stats?.finishReason === 'failed' || stats?.stopDecision?.status === 'failed';
|
|
22
|
+
}
|
|
23
|
+
function serializeAgentLoopOutcome(stats, showBudgetStop) {
|
|
24
|
+
return (0, canonical_1.canonicalRuntimeJson)({
|
|
25
|
+
finishReason: stats?.finishReason ?? 'completed',
|
|
26
|
+
stopDecision: stats?.stopDecision,
|
|
27
|
+
...(showBudgetStop &&
|
|
28
|
+
stats?.finishReason === 'budget_exceeded' &&
|
|
29
|
+
stats.stopDecision?.status === 'stopped'
|
|
30
|
+
? { budgetStop: (0, ui_view_model_1.createLoopBudgetStopView)(stats) }
|
|
31
|
+
: {}),
|
|
32
|
+
});
|
|
33
|
+
}
|
|
11
34
|
/**
|
|
12
35
|
* The single production model -> tool recursion adapter.
|
|
13
36
|
*
|
|
@@ -21,7 +44,12 @@ class AgentLoopV1 {
|
|
|
21
44
|
this.serviceId = 'agent-loop';
|
|
22
45
|
}
|
|
23
46
|
async run(context) {
|
|
24
|
-
this.options.taskContext.
|
|
47
|
+
const progressAtAdmission = this.options.taskContext.progressState();
|
|
48
|
+
const bindRecovery = this.options.previousCommitDigest
|
|
49
|
+
? (0, task_context_recovery_1.createTaskRecoveryBinder)(this.options.taskContext, this.options.previousCommitDigest, progressAtAdmission)
|
|
50
|
+
: undefined;
|
|
51
|
+
const goal = context.mode === 'goal' ? this.options.resolveGoalTask?.() : undefined;
|
|
52
|
+
this.options.taskContext.observeUserInput(goal?.objective ?? context.input, goal?.goalId);
|
|
25
53
|
const messages = (await this.options.loadBaseMessages(context)).map(message => ({
|
|
26
54
|
...message,
|
|
27
55
|
}));
|
|
@@ -30,13 +58,24 @@ class AgentLoopV1 {
|
|
|
30
58
|
let assistantItem;
|
|
31
59
|
let assistantContent = '';
|
|
32
60
|
let reasoningItem;
|
|
61
|
+
let reasoningText = '';
|
|
33
62
|
let completeEvent;
|
|
34
63
|
let taskContextCompletion;
|
|
35
64
|
const finishReasoning = () => {
|
|
36
65
|
if (!reasoningItem)
|
|
37
66
|
return;
|
|
38
|
-
|
|
67
|
+
const text = (0, redaction_1.redactTraceText)(reasoningText.trim());
|
|
68
|
+
// Reasoning is display-only. Bound the durable item without losing the
|
|
69
|
+
// final text that the renderer receives from ephemeral stream events.
|
|
70
|
+
const content = text.length > MAX_REASONING_TRANSCRIPT_CHARS
|
|
71
|
+
? text.slice(0, MAX_REASONING_TRANSCRIPT_CHARS - 1).replace(/[\uD800-\uDBFF]$/u, '') + '…'
|
|
72
|
+
: text;
|
|
73
|
+
context.completeItem(reasoningItem, {
|
|
74
|
+
...(content ? { content } : {}),
|
|
75
|
+
summary: content ? compactSummary(content) : 'Model reasoning started',
|
|
76
|
+
});
|
|
39
77
|
reasoningItem = undefined;
|
|
78
|
+
reasoningText = '';
|
|
40
79
|
};
|
|
41
80
|
const ensureAssistantItem = () => {
|
|
42
81
|
if (assistantItem)
|
|
@@ -49,12 +88,12 @@ class AgentLoopV1 {
|
|
|
49
88
|
return assistantItem;
|
|
50
89
|
};
|
|
51
90
|
const completeAssistant = (content) => {
|
|
52
|
-
|
|
91
|
+
assistantContent = '';
|
|
92
|
+
if (!assistantItem && !(0, terminal_text_1.hasVisibleAssistantText)(content))
|
|
53
93
|
return;
|
|
54
94
|
const item = ensureAssistantItem();
|
|
55
95
|
context.completeItem(item, { content, summary: compactSummary(content) });
|
|
56
96
|
assistantItem = undefined;
|
|
57
|
-
assistantContent = '';
|
|
58
97
|
};
|
|
59
98
|
const streamCallbacks = {
|
|
60
99
|
onThinking: () => {
|
|
@@ -63,16 +102,29 @@ class AgentLoopV1 {
|
|
|
63
102
|
reasoningItem = context.startItem({ kind: 'reasoning', stepId: activeStep?.stepId });
|
|
64
103
|
}
|
|
65
104
|
},
|
|
105
|
+
onThinkingText: text => {
|
|
106
|
+
this.options.streamCallbacks?.onThinkingText?.(text);
|
|
107
|
+
if (!reasoningItem) {
|
|
108
|
+
reasoningItem = context.startItem({ kind: 'reasoning', stepId: activeStep?.stepId });
|
|
109
|
+
}
|
|
110
|
+
reasoningText += text;
|
|
111
|
+
context.emitDelta(reasoningItem, text, 'reasoning');
|
|
112
|
+
},
|
|
66
113
|
onChunk: chunk => {
|
|
67
114
|
finishReasoning();
|
|
68
115
|
assistantContent += chunk;
|
|
69
|
-
|
|
70
|
-
|
|
116
|
+
if (!assistantItem &&
|
|
117
|
+
(!(0, terminal_text_1.hasVisibleAssistantText)(chunk) || !(0, terminal_text_1.hasVisibleAssistantText)(assistantContent)))
|
|
118
|
+
return;
|
|
119
|
+
const text = assistantItem ? chunk : assistantContent;
|
|
120
|
+
context.emitDelta(ensureAssistantItem(), text, 'content');
|
|
121
|
+
this.options.streamCallbacks?.onChunk?.(text);
|
|
71
122
|
},
|
|
72
123
|
};
|
|
124
|
+
const executionChecklist = this.options.enableTaskTodos === true && (0, task_checklist_1.supportsExecutionChecklist)(context.mode);
|
|
73
125
|
const harness = createQueryTaskContextAdapter(this.options.taskContext, decision => {
|
|
74
126
|
taskContextCompletion = decision;
|
|
75
|
-
}, context.mode === 'plan');
|
|
127
|
+
}, context.mode === 'plan', executionChecklist, context.mode === 'goal');
|
|
76
128
|
try {
|
|
77
129
|
for await (const event of (0, query_1.query)({
|
|
78
130
|
messages,
|
|
@@ -102,7 +154,7 @@ class AgentLoopV1 {
|
|
|
102
154
|
activeStep = await this.bindStep(context, prepared, router, bindingInput);
|
|
103
155
|
return {
|
|
104
156
|
receiptDigest: activeStep.digest,
|
|
105
|
-
toolExecutor: (name, args, abortSignal, metadata) => this.invokeTool(context, activeStep, name, args, abortSignal, metadata),
|
|
157
|
+
toolExecutor: (name, args, abortSignal, metadata) => this.invokeTool(context, activeStep, name, args, bindRecovery, abortSignal, metadata),
|
|
106
158
|
};
|
|
107
159
|
},
|
|
108
160
|
};
|
|
@@ -110,6 +162,15 @@ class AgentLoopV1 {
|
|
|
110
162
|
llm: this.options.llm,
|
|
111
163
|
abortSignal: context.abortSignal,
|
|
112
164
|
streamCallbacks,
|
|
165
|
+
holdAssistantUntilCompletionCheck: () => context.mode !== 'plan' &&
|
|
166
|
+
(context.mode === 'goal' ||
|
|
167
|
+
this.options.taskContext.requiresVerification() ||
|
|
168
|
+
(executionChecklist &&
|
|
169
|
+
(this.options.taskContext.hasTaskTodos() ||
|
|
170
|
+
!!this.options.taskContext.missingExecutionChecklist()))),
|
|
171
|
+
...(executionChecklist
|
|
172
|
+
? { checkTaskPlanStop: this.options.taskContext.prepareTaskPlanStopCheck() }
|
|
173
|
+
: {}),
|
|
113
174
|
harness,
|
|
114
175
|
input: context.input,
|
|
115
176
|
toolContext: {
|
|
@@ -117,6 +178,9 @@ class AgentLoopV1 {
|
|
|
117
178
|
config: { name: 'orion-code', mode: context.mode },
|
|
118
179
|
},
|
|
119
180
|
loopBudget: this.options.loopBudget,
|
|
181
|
+
remainingGoalTokens: this.options.remainingGoalTokens,
|
|
182
|
+
allowBudgetRecovery: this.options.allowBudgetRecovery === true &&
|
|
183
|
+
(context.mode === 'build' || context.mode === 'auto'),
|
|
120
184
|
onContextUsage: this.options.onContextUsage,
|
|
121
185
|
compactCoordinator: this.options.compactCoordinator,
|
|
122
186
|
})) {
|
|
@@ -127,13 +191,18 @@ class AgentLoopV1 {
|
|
|
127
191
|
activeStep = undefined;
|
|
128
192
|
break;
|
|
129
193
|
case 'assistant_tool_calls':
|
|
130
|
-
finishReasoning();
|
|
131
|
-
completeAssistant(assistantContent || event.content);
|
|
132
|
-
break;
|
|
133
194
|
case 'message':
|
|
134
195
|
finishReasoning();
|
|
135
|
-
completeAssistant(
|
|
196
|
+
completeAssistant(event.content);
|
|
197
|
+
break;
|
|
198
|
+
case 'budget_recovery': {
|
|
199
|
+
const content = event.reason === 'progress'
|
|
200
|
+
? 'Observed new tool evidence. Continuing the task.'
|
|
201
|
+
: 'No new tool evidence yet. Trying a different step before pausing.';
|
|
202
|
+
const item = context.startItem({ kind: 'reasoning', name: 'loop:progress-checkpoint' });
|
|
203
|
+
context.completeItem(item, { content, summary: content });
|
|
136
204
|
break;
|
|
205
|
+
}
|
|
137
206
|
case 'warning':
|
|
138
207
|
case 'strategy_exhausted': {
|
|
139
208
|
const content = event.type === 'warning' ? event.message : event.suggestion;
|
|
@@ -142,6 +211,13 @@ class AgentLoopV1 {
|
|
|
142
211
|
break;
|
|
143
212
|
}
|
|
144
213
|
case 'complete':
|
|
214
|
+
if (executionChecklist && event.stats?.finishReason === 'completion_gate') {
|
|
215
|
+
const item = context.startItem({ kind: 'message', role: 'system' });
|
|
216
|
+
context.completeItem(item, {
|
|
217
|
+
content: event.content,
|
|
218
|
+
summary: compactSummary(event.content),
|
|
219
|
+
});
|
|
220
|
+
}
|
|
145
221
|
completeEvent = event;
|
|
146
222
|
break;
|
|
147
223
|
case 'prompt_assembly':
|
|
@@ -161,12 +237,35 @@ class AgentLoopV1 {
|
|
|
161
237
|
: { status: 'failed', error: errorMessage(error) };
|
|
162
238
|
}
|
|
163
239
|
finishReasoning();
|
|
164
|
-
|
|
240
|
+
const stats = completeEvent?.stats;
|
|
241
|
+
// Commit the same terminal result that ThreadRuntime will publish.
|
|
242
|
+
if (completeEvent &&
|
|
243
|
+
stats &&
|
|
244
|
+
context.abortSignal.aborted &&
|
|
245
|
+
stats.finishReason !== 'cancelled') {
|
|
246
|
+
completeEvent = {
|
|
247
|
+
...completeEvent,
|
|
248
|
+
content: 'Operation cancelled.',
|
|
249
|
+
stats: (0, query_1.withLoopFinishReason)(stats, 'cancelled'),
|
|
250
|
+
};
|
|
251
|
+
}
|
|
252
|
+
const failed = isFailedLoopStats(completeEvent?.stats);
|
|
253
|
+
const failureMessage = completeEvent?.content || 'AgentLoop failed';
|
|
254
|
+
if (failed && assistantItem)
|
|
255
|
+
context.failItem(assistantItem, failureMessage);
|
|
256
|
+
else
|
|
257
|
+
completeAssistant(assistantContent);
|
|
165
258
|
if (!completeEvent) {
|
|
166
259
|
return context.abortSignal.aborted
|
|
167
260
|
? { status: 'interrupted', reason: abortReason(context.abortSignal) }
|
|
168
261
|
: { status: 'failed', error: 'AgentLoop ended without a terminal Query event' };
|
|
169
262
|
}
|
|
263
|
+
if (completeEvent.stats?.finishReason === 'budget_exceeded') {
|
|
264
|
+
// A completion gate may have run before the last tools, or not at all.
|
|
265
|
+
// Record progress for the whole turn without running another completion audit.
|
|
266
|
+
this.options.taskContext.recordProgress(progressAtAdmission);
|
|
267
|
+
taskContextCompletion = undefined;
|
|
268
|
+
}
|
|
170
269
|
const commitContent = {
|
|
171
270
|
threadId: context.threadId,
|
|
172
271
|
turnId: context.turnId,
|
|
@@ -182,21 +281,18 @@ class AgentLoopV1 {
|
|
|
182
281
|
...commitContent,
|
|
183
282
|
digest: (0, canonical_1.digestRuntimeValue)(commitContent),
|
|
184
283
|
});
|
|
185
|
-
if (
|
|
284
|
+
if (completeEvent.stats?.finishReason === 'cancelled') {
|
|
186
285
|
return { status: 'interrupted', reason: abortReason(context.abortSignal) };
|
|
187
286
|
}
|
|
188
|
-
if (
|
|
189
|
-
return { status: 'failed', error:
|
|
287
|
+
if (failed) {
|
|
288
|
+
return { status: 'failed', error: failureMessage };
|
|
190
289
|
}
|
|
191
290
|
const maintenance = completeEvent.compact
|
|
192
291
|
? createAutomaticCompactMaintenance(completeEvent.compact)
|
|
193
292
|
: undefined;
|
|
194
293
|
return {
|
|
195
294
|
status: 'completed',
|
|
196
|
-
outcome: (
|
|
197
|
-
finishReason: completeEvent.stats?.finishReason ?? 'completed',
|
|
198
|
-
stopDecision: completeEvent.stats?.stopDecision,
|
|
199
|
-
}),
|
|
295
|
+
outcome: serializeAgentLoopOutcome(completeEvent.stats, context.mode !== 'goal'),
|
|
200
296
|
...(maintenance ? { maintenance } : {}),
|
|
201
297
|
};
|
|
202
298
|
}
|
|
@@ -220,9 +316,22 @@ class AgentLoopV1 {
|
|
|
220
316
|
await this.options.onStepCaptured?.(snapshot);
|
|
221
317
|
return snapshot;
|
|
222
318
|
}
|
|
223
|
-
async invokeTool(context, snapshot, name, args, abortSignal, metadata) {
|
|
319
|
+
async invokeTool(context, snapshot, name, args, bindRecovery, abortSignal, metadata) {
|
|
224
320
|
if (!metadata)
|
|
225
321
|
throw new Error('ToolGateway execution requires provider call identity');
|
|
322
|
+
const executionChecklist = this.options.enableTaskTodos === true && (0, task_checklist_1.supportsExecutionChecklist)(context.mode);
|
|
323
|
+
const descriptor = snapshot.toolRouter.resolveDescriptor(name);
|
|
324
|
+
const prerequisiteFailure = executionChecklist && mayChangeWorkspace(descriptor, args)
|
|
325
|
+
? this.options.taskContext.missingExecutionChecklist({
|
|
326
|
+
path: (name === 'write_file' || name === 'edit_file') && typeof args.path === 'string'
|
|
327
|
+
? args.path
|
|
328
|
+
: undefined,
|
|
329
|
+
command: name === 'exec_command' && typeof args.command === 'string'
|
|
330
|
+
? args.command
|
|
331
|
+
: undefined,
|
|
332
|
+
cwd: typeof args.cwd === 'string' ? args.cwd : undefined,
|
|
333
|
+
})
|
|
334
|
+
: undefined;
|
|
226
335
|
const invocationId = deterministicRuntimeId([
|
|
227
336
|
context.threadId,
|
|
228
337
|
context.turnId,
|
|
@@ -234,6 +343,9 @@ class AgentLoopV1 {
|
|
|
234
343
|
cwd: snapshot.environment.cwd,
|
|
235
344
|
config: { name: 'orion-code', mode: context.mode },
|
|
236
345
|
};
|
|
346
|
+
const activeTodo = executionChecklist && name !== 'todo_write'
|
|
347
|
+
? this.options.taskContext.activeTaskTodo()
|
|
348
|
+
: undefined;
|
|
237
349
|
const invoked = await this.options.gateway.invoke({
|
|
238
350
|
invocationId,
|
|
239
351
|
snapshot,
|
|
@@ -241,15 +353,40 @@ class AgentLoopV1 {
|
|
|
241
353
|
args,
|
|
242
354
|
context: toolContext,
|
|
243
355
|
abortSignal,
|
|
356
|
+
prerequisiteFailure,
|
|
357
|
+
taskRecovery: bindRecovery?.({
|
|
358
|
+
descriptor,
|
|
359
|
+
name,
|
|
360
|
+
args,
|
|
361
|
+
cwd: toolContext.cwd,
|
|
362
|
+
activeTodoId: activeTodo,
|
|
363
|
+
}),
|
|
244
364
|
});
|
|
365
|
+
const receipt = invoked.receipt;
|
|
366
|
+
const evidence = (0, task_context_recovery_1.projectTaskToolEvidence)(receipt, args, toolContext.cwd);
|
|
367
|
+
(0, task_context_recovery_1.recordTaskTodoToolReceipt)(this.options.taskContext, activeTodo, receipt, evidence);
|
|
368
|
+
const { changedFile, verification } = evidence;
|
|
245
369
|
const permissionDecision = projectPermissionDecision(invoked.receipt);
|
|
246
370
|
return {
|
|
247
371
|
result: (0, tool_serializer_1.serializeToolResult)(invoked.result),
|
|
248
372
|
...(permissionDecision ? { permissionDecision } : {}),
|
|
373
|
+
...(verification ? { verification } : {}),
|
|
374
|
+
...(receipt.terminalPhase === 'execute' ? { toolReceiptDigest: receipt.digest } : {}),
|
|
375
|
+
...(changedFile ? { changedFile } : {}),
|
|
249
376
|
};
|
|
250
377
|
}
|
|
251
378
|
}
|
|
252
379
|
exports.AgentLoopV1 = AgentLoopV1;
|
|
380
|
+
function mayChangeWorkspace(descriptor, args) {
|
|
381
|
+
if (descriptor?.risk.effect !== 'workspace_write')
|
|
382
|
+
return false;
|
|
383
|
+
if (descriptor.name === 'edit_file' && args.preview === true)
|
|
384
|
+
return false;
|
|
385
|
+
if (descriptor.name === 'exec_command' && typeof args.command === 'string') {
|
|
386
|
+
return !(0, bash_security_1.isReadOnlyCommand)(args.command);
|
|
387
|
+
}
|
|
388
|
+
return true;
|
|
389
|
+
}
|
|
253
390
|
function projectPermissionDecision(receipt) {
|
|
254
391
|
const policy = receipt.policy;
|
|
255
392
|
if (!policy)
|
|
@@ -379,10 +516,10 @@ function createSnapshotToolFacade(descriptor) {
|
|
|
379
516
|
isFileEdit: () => descriptor.risk.fileEdit,
|
|
380
517
|
};
|
|
381
518
|
}
|
|
382
|
-
function createQueryTaskContextAdapter(taskContext, onCompletion, planningPhase
|
|
519
|
+
function createQueryTaskContextAdapter(taskContext, onCompletion, planningPhase, enforceTaskTodos, requireEveryCriterion) {
|
|
383
520
|
return {
|
|
384
521
|
updateCapabilityProfile: input => structuredClone(taskContext.observeCapability(input)),
|
|
385
|
-
assembleMessages: (messages, options) => taskContext.assembleMessages(messages, options),
|
|
522
|
+
assembleMessages: (messages, options) => taskContext.assembleMessages(messages, { ...options, includeTaskTodos: enforceTaskTodos }),
|
|
386
523
|
getCapsule: () => {
|
|
387
524
|
const capsule = taskContext.getCapsule();
|
|
388
525
|
return capsule
|
|
@@ -393,9 +530,12 @@ function createQueryTaskContextAdapter(taskContext, onCompletion, planningPhase
|
|
|
393
530
|
recordAssistantResponse: response => taskContext.observeAssistantResponse(response),
|
|
394
531
|
beforeToolUse: input => structuredClone(taskContext.checkToolUse(input)),
|
|
395
532
|
asToolBlockedResult: result => taskContext.toolBlockedResult(result),
|
|
396
|
-
recordToolResult: input =>
|
|
533
|
+
recordToolResult: input => {
|
|
534
|
+
if (input.name !== 'todo_write')
|
|
535
|
+
taskContext.observeToolResult(input);
|
|
536
|
+
},
|
|
397
537
|
beforeComplete: () => {
|
|
398
|
-
const decision = taskContext.auditCompletion();
|
|
538
|
+
const decision = taskContext.auditCompletion(enforceTaskTodos, requireEveryCriterion);
|
|
399
539
|
onCompletion(decision);
|
|
400
540
|
// PLAN completes a planning phase, not the parent implementation task.
|
|
401
541
|
// Persist the unmodified audit for the PlanReceipt, while allowing the
|
|
@@ -74,16 +74,20 @@ export declare class AgentRuntimeController {
|
|
|
74
74
|
private readonly agentModeLifecycle;
|
|
75
75
|
private readonly pendingPermissions;
|
|
76
76
|
private activeRun;
|
|
77
|
+
private activeReview?;
|
|
77
78
|
private pendingAgentMode;
|
|
78
79
|
private readonly goalControlRuns;
|
|
79
80
|
private activeGoalRuntimeTransitions;
|
|
80
81
|
private goalRuntimeActive;
|
|
81
82
|
private settingsBoundarySynchronizations;
|
|
83
|
+
private reportedInvalidConfigRevision?;
|
|
82
84
|
private stopping;
|
|
83
85
|
private nextPermissionRequestId;
|
|
84
86
|
private readonly queuedCommands;
|
|
85
|
-
private
|
|
86
|
-
private
|
|
87
|
+
private followupQueue;
|
|
88
|
+
private followupSessionId?;
|
|
89
|
+
private followupsPaused;
|
|
90
|
+
private compacting;
|
|
87
91
|
private nextFollowupId;
|
|
88
92
|
constructor(options: AgentRuntimeControllerOptions);
|
|
89
93
|
hasActiveTurn(): boolean;
|
|
@@ -117,9 +121,15 @@ export declare class AgentRuntimeController {
|
|
|
117
121
|
/** Set an exact mode immediately while idle, or at the next logical-request boundary. */
|
|
118
122
|
setAgentMode(mode: AgentMode): AgentRuntimeInputResult;
|
|
119
123
|
private queueFollowup;
|
|
124
|
+
private checkFollowupSize;
|
|
125
|
+
private loadFollowupQueue;
|
|
126
|
+
private saveFollowupQueue;
|
|
127
|
+
private reportFollowupFailure;
|
|
128
|
+
private nextPendingFollowup;
|
|
120
129
|
private manageFollowupQueue;
|
|
121
130
|
submit(input: string): AgentRuntimeSubmitResult;
|
|
122
131
|
private emitImmediateCommandSnapshot;
|
|
132
|
+
private runTrackedReview;
|
|
123
133
|
private runCommand;
|
|
124
134
|
private createCommandContext;
|
|
125
135
|
private submitTurnRequest;
|
|
@@ -127,6 +137,7 @@ export declare class AgentRuntimeController {
|
|
|
127
137
|
stopActiveTurn(): Promise<void>;
|
|
128
138
|
waitForIdle(): Promise<void>;
|
|
129
139
|
compactContext(): Promise<import('./agent-runtime-runner').AgentRuntimeCompactResultV1>;
|
|
140
|
+
private runTrackedCompact;
|
|
130
141
|
canCompactContext(): boolean;
|
|
131
142
|
planReviewState(): Promise<import('./thread-projection').PlanReviewProjectionV1 | undefined>;
|
|
132
143
|
reviewPlan(input: Parameters<NonNullable<import('./agent-runtime-runner').AgentRuntimeRunnerV1['reviewPlan']>>[0]): Promise<import('./plan-review').PlanReviewResolutionReceiptV1>;
|
|
@@ -149,7 +160,6 @@ export declare class AgentRuntimeController {
|
|
|
149
160
|
private observeGoalControlResult;
|
|
150
161
|
private observeGoalRuntimeEvent;
|
|
151
162
|
private recordPermissionDecision;
|
|
152
|
-
private applyPermissionModeChange;
|
|
153
163
|
private rejectPendingPermissions;
|
|
154
164
|
}
|
|
155
165
|
//# sourceMappingURL=agent-runtime-controller.d.ts.map
|