@orion-agents/orion-code 0.4.3 → 0.4.4
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +6 -0
- package/README.md +4 -4
- package/README.zh-CN.md +4 -4
- package/dist/acp/session-updates.d.ts +4 -3
- package/dist/acp/session-updates.js +23 -2
- package/dist/acp/sessions.js +19 -6
- package/dist/commands/core-command-handlers.js +10 -22
- package/dist/commands/diagnostic-command-handlers.js +48 -52
- package/dist/commands/registry.js +1 -1
- package/dist/commands/target-command.js +49 -6
- package/dist/commands/workflow-commands.js +2 -2
- package/dist/framework/loop-budget-contract.d.ts +1 -12
- package/dist/framework/loop-budget-contract.js +1 -7
- package/dist/framework/loop-progress.d.ts +3 -7
- package/dist/framework/loop-progress.js +7 -23
- package/dist/framework/query.d.ts +12 -24
- package/dist/framework/query.js +146 -287
- package/dist/harness/assembler.js +1 -1
- package/dist/harness/context-harness.d.ts +7 -1
- package/dist/harness/context-harness.js +68 -14
- package/dist/harness/index.d.ts +1 -1
- package/dist/harness/ledger.d.ts +1 -0
- package/dist/harness/ledger.js +12 -1
- package/dist/harness/progress-controller.js +57 -35
- package/dist/harness/state.js +1 -0
- package/dist/harness/stop-controller.d.ts +0 -5
- package/dist/harness/stop-controller.js +11 -31
- package/dist/harness/task-checklist.d.ts +1 -1
- package/dist/harness/task-checklist.js +2 -5
- package/dist/harness/types.d.ts +5 -0
- package/dist/print-ui/event-stream.d.ts +5 -0
- package/dist/print-ui/event-stream.js +22 -5
- package/dist/runtime/agent-loop.d.ts +2 -1
- package/dist/runtime/agent-loop.js +20 -17
- package/dist/runtime/agent-runtime-controller.d.ts +1 -1
- package/dist/runtime/agent-runtime-controller.js +21 -11
- package/dist/runtime/goal-lifecycle-v2.d.ts +6 -4
- package/dist/runtime/goal-lifecycle-v2.js +164 -56
- package/dist/runtime/goal-runtime-coordinator.d.ts +6 -3
- package/dist/runtime/goal-runtime-coordinator.js +90 -36
- package/dist/runtime/goals/presentation.js +3 -1
- package/dist/runtime/goals/types.d.ts +1 -3
- package/dist/runtime/goals/types.js +0 -3
- package/dist/runtime/loop-budget.d.ts +0 -7
- package/dist/runtime/loop-budget.js +8 -54
- package/dist/runtime/orion-runtime-v1.js +55 -14
- package/dist/runtime/product-orion-runtime.js +6 -11
- package/dist/runtime/rsi/evaluation.js +1 -7
- package/dist/runtime/step-snapshot.d.ts +3 -1
- package/dist/runtime/step-snapshot.js +11 -1
- package/dist/runtime/subagent-thread-runtime.js +27 -5
- package/dist/runtime/subagents/production.js +0 -4
- package/dist/runtime/task-context-recovery.js +9 -2
- package/dist/runtime/task-context-service.d.ts +5 -1
- package/dist/runtime/task-context-service.js +37 -8
- package/dist/runtime/thread-admission.d.ts +2 -0
- package/dist/runtime/thread-admission.js +9 -1
- package/dist/runtime/thread-runtime.d.ts +3 -0
- package/dist/runtime/thread-runtime.js +42 -3
- package/dist/runtime/thread-ui-adapter.js +1 -11
- package/dist/runtime/tool-gateway.d.ts +2 -0
- package/dist/runtime/tool-gateway.js +4 -0
- package/dist/runtime/tool-receipt-validator.js +4 -0
- package/dist/runtime/ui-events.d.ts +3 -1
- package/dist/runtime/ui-view-model.js +62 -59
- package/dist/runtime/workspace-verification.d.ts +7 -0
- package/dist/runtime/workspace-verification.js +83 -0
- package/dist/services/config.js +3 -7
- package/dist/services/global-config.d.ts +3 -11
- package/dist/services/global-config.js +36 -26
- package/dist/services/llm.d.ts +2 -0
- package/dist/services/llm.js +13 -0
- package/dist/services/provider-diagnostics.d.ts +1 -0
- package/dist/services/provider-diagnostics.js +8 -2
- package/dist/tools/core/edit-file.js +4 -2
- package/dist/tools/core/write-file.js +5 -3
- package/dist/tools/todo.d.ts +1 -1
- package/dist/tools/todo.js +17 -1
- package/dist/tui-ui/chrome-view-model.js +15 -6
- package/docs/cli-guide.md +53 -40
- package/docs/orion.example.yaml +4 -3
- package/npm-shrinkwrap.json +2 -2
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -22,6 +22,12 @@ which is **not** a pass.
|
|
|
22
22
|
|
|
23
23
|
## [Unreleased]
|
|
24
24
|
|
|
25
|
+
## [0.4.4] — UNRELEASED
|
|
26
|
+
|
|
27
|
+
- Invalidate verification after shell or external edits. A matching fresh check is required to complete the task (#372).
|
|
28
|
+
- Show separate durable counts for workspace changes, verification, task state, read-only findings, and model output in `/usage` (#373).
|
|
29
|
+
- Restore a Goal in place after a token, active-time, or provider quota stop. New Goals only use explicitly configured or specified totals. Queued user turns run before automatic continuation (#385).
|
|
30
|
+
|
|
25
31
|
## [0.4.3] — UNRELEASED
|
|
26
32
|
|
|
27
33
|
- Serve ACP v1 over stdio with `orion acp`, using the shared Runtime for coding tasks.
|
package/README.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
Local-first, goal-driven coding agent for the terminal (CLI/TUI).
|
|
4
4
|
|
|
5
|
-
> v0.4.
|
|
5
|
+
> v0.4.4 is a candidate for Goal recovery and Harness evidence fixes.
|
|
6
6
|
> Web Workbench and desktop product surfaces are retired. Configuration is `orion.yaml`;
|
|
7
7
|
> old-version data compatibility and migration are not part of this release.
|
|
8
8
|
> A version number or local installation is not proof of release qualification or npm publication.
|
|
@@ -30,7 +30,7 @@ The exact package qualification floors are 22.12.0 / 24.0.0 / 26.0.0.
|
|
|
30
30
|
Install a local candidate from the exact tested tarball, substituting its actual path:
|
|
31
31
|
|
|
32
32
|
```bash
|
|
33
|
-
npm install -g /absolute/path/orion-agents-orion-code-0.4.
|
|
33
|
+
npm install -g /absolute/path/orion-agents-orion-code-0.4.4.tgz
|
|
34
34
|
orion --version
|
|
35
35
|
orion doctor
|
|
36
36
|
```
|
|
@@ -38,7 +38,7 @@ orion doctor
|
|
|
38
38
|
Only after npm publication has been separately verified, use the pinned registry install:
|
|
39
39
|
|
|
40
40
|
```bash
|
|
41
|
-
npm install -g @orion-agents/orion-code@0.4.
|
|
41
|
+
npm install -g @orion-agents/orion-code@0.4.4
|
|
42
42
|
```
|
|
43
43
|
|
|
44
44
|
From a checkout of the candidate branch:
|
|
@@ -108,7 +108,7 @@ npm run format:check
|
|
|
108
108
|
npm run build
|
|
109
109
|
npm run test:coverage -- --runInBand
|
|
110
110
|
npm run test:harness-confluence
|
|
111
|
-
npm run release:check -- --expected-version 0.4.
|
|
111
|
+
npm run release:check -- --expected-version 0.4.4
|
|
112
112
|
```
|
|
113
113
|
|
|
114
114
|
Qualification binds one exact tarball's SHA-256 and source identity to installed CLI, TUI, terminal,
|
package/README.zh-CN.md
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
|
|
3
3
|
面向终端、本地优先的目标驱动 Coding Agent(CLI/TUI)。
|
|
4
4
|
|
|
5
|
-
> v0.4.
|
|
5
|
+
> v0.4.4 是 Goal 续跑与 Harness 证据修复的候选版本。
|
|
6
6
|
> Web Workbench 与桌面产品链已退役,全局配置统一为 `orion.yaml`。
|
|
7
7
|
> 源码版本号、本地可运行、候选包验收与 npm 发布分别记录,不互相替代。
|
|
8
8
|
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
本地候选使用实际被测的同一包安装,请替换为实际路径:
|
|
29
29
|
|
|
30
30
|
```bash
|
|
31
|
-
npm install -g /absolute/path/orion-agents-orion-code-0.4.
|
|
31
|
+
npm install -g /absolute/path/orion-agents-orion-code-0.4.4.tgz
|
|
32
32
|
orion --version
|
|
33
33
|
orion doctor
|
|
34
34
|
```
|
|
@@ -36,7 +36,7 @@ orion doctor
|
|
|
36
36
|
仅在另行确认 npm 已发布后,固定 registry 版本安装:
|
|
37
37
|
|
|
38
38
|
```bash
|
|
39
|
-
npm install -g @orion-agents/orion-code@0.4.
|
|
39
|
+
npm install -g @orion-agents/orion-code@0.4.4
|
|
40
40
|
```
|
|
41
41
|
|
|
42
42
|
从候选分支源码运行:
|
|
@@ -104,7 +104,7 @@ npm run format:check
|
|
|
104
104
|
npm run build
|
|
105
105
|
npm run test:coverage -- --runInBand
|
|
106
106
|
npm run test:harness-confluence
|
|
107
|
-
npm run release:check -- --expected-version 0.4.
|
|
107
|
+
npm run release:check -- --expected-version 0.4.4
|
|
108
108
|
```
|
|
109
109
|
|
|
110
110
|
准出需绑定同一 tarball 的 SHA-256 与源码身份,在三个 Node floor 验证安装后的 CLI、TUI、
|
|
@@ -1,6 +1,7 @@
|
|
|
1
|
-
import type { AgentContext,
|
|
1
|
+
import type { AgentContext, PromptResponse } from '@agentclientprotocol/sdk';
|
|
2
2
|
import type { FirstPartyApprovalRequestV1 } from '../runtime/first-party-tool-services';
|
|
3
|
-
import type { RuntimeToolFinishedEvent, RuntimeToolStartedEvent, TranscriptAppendEntry, UiEventSink } from '../runtime/ui-events';
|
|
3
|
+
import type { LoopBudgetStopView, RuntimeToolFinishedEvent, RuntimeToolStartedEvent, TranscriptAppendEntry, UiEventSink } from '../runtime/ui-events';
|
|
4
|
+
export declare function acpPausedOutcome(reasonCode?: string, historicalKind?: LoopBudgetStopView['kind']): PromptResponse;
|
|
4
5
|
/** ACP's append-only text and tool updates over the shared Thread UI projection. */
|
|
5
6
|
export declare class AcpSessionUpdates implements UiEventSink {
|
|
6
7
|
private readonly sessionId;
|
|
@@ -11,7 +12,7 @@ export declare class AcpSessionUpdates implements UiEventSink {
|
|
|
11
12
|
private pending;
|
|
12
13
|
private messageSequence;
|
|
13
14
|
private replaying;
|
|
14
|
-
budgetStop?:
|
|
15
|
+
budgetStop?: PromptResponse;
|
|
15
16
|
constructor(sessionId: string, client: AgentContext, onWriteFailure: () => void);
|
|
16
17
|
setReplaying(replaying: boolean): void;
|
|
17
18
|
flush(): Promise<void>;
|
|
@@ -1,8 +1,30 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.AcpSessionUpdates = void 0;
|
|
4
|
+
exports.acpPausedOutcome = acpPausedOutcome;
|
|
4
5
|
const redaction_1 = require("../services/redaction");
|
|
5
6
|
const ALLOW_ONCE = 'allow-once';
|
|
7
|
+
function acpPausedOutcome(reasonCode, historicalKind) {
|
|
8
|
+
switch (reasonCode) {
|
|
9
|
+
case 'goal_token_budget':
|
|
10
|
+
return { stopReason: 'max_tokens', _meta: { orion: { reasonCode } } };
|
|
11
|
+
case 'goal_time_budget':
|
|
12
|
+
case 'provider_preflight_budget':
|
|
13
|
+
// ACP v1 has no elapsed-time or provider preflight stop reason.
|
|
14
|
+
return { stopReason: 'refusal', _meta: { orion: { reasonCode } } };
|
|
15
|
+
case 'llm_request_budget':
|
|
16
|
+
case 'request_safety_limit':
|
|
17
|
+
case 'budget_paused_compact_pending':
|
|
18
|
+
return { stopReason: 'max_turn_requests' };
|
|
19
|
+
default:
|
|
20
|
+
if (historicalKind === 'llm_request_limit')
|
|
21
|
+
return { stopReason: 'max_turn_requests' };
|
|
22
|
+
return {
|
|
23
|
+
stopReason: 'refusal',
|
|
24
|
+
...(reasonCode ? { _meta: { orion: { reasonCode } } } : {}),
|
|
25
|
+
};
|
|
26
|
+
}
|
|
27
|
+
}
|
|
6
28
|
function toolKind(name) {
|
|
7
29
|
switch (name) {
|
|
8
30
|
case 'exec_command':
|
|
@@ -47,8 +69,7 @@ class AcpSessionUpdates {
|
|
|
47
69
|
append(entry) {
|
|
48
70
|
const id = 'message-' + ++this.messageSequence;
|
|
49
71
|
if (!this.replaying && entry.budgetStop) {
|
|
50
|
-
this.budgetStop =
|
|
51
|
-
entry.budgetStop.kind === 'llm_request_limit' ? 'max_turn_requests' : 'refusal';
|
|
72
|
+
this.budgetStop = acpPausedOutcome(entry.budgetStop.reasonCode, entry.budgetStop.kind);
|
|
52
73
|
}
|
|
53
74
|
if ((entry.role === 'assistant' && entry.title !== 'reasoning') ||
|
|
54
75
|
(entry.role === 'user' && this.replaying)) {
|
package/dist/acp/sessions.js
CHANGED
|
@@ -9,6 +9,7 @@ const paths_1 = require("../product/paths");
|
|
|
9
9
|
const orion_runtime_v1_1 = require("../runtime/orion-runtime-v1");
|
|
10
10
|
const mcp_1 = require("../runtime/mcp");
|
|
11
11
|
const product_bootstrap_1 = require("../runtime/product-bootstrap");
|
|
12
|
+
const turn_commit_1 = require("../runtime/turn-commit");
|
|
12
13
|
const file_lock_1 = require("../services/file-lock");
|
|
13
14
|
const redaction_1 = require("../services/redaction");
|
|
14
15
|
const session_storage_1 = require("../services/session-storage");
|
|
@@ -119,11 +120,18 @@ class AcpSession {
|
|
|
119
120
|
if (!turn)
|
|
120
121
|
return;
|
|
121
122
|
for (const { turnId, payload } of events) {
|
|
122
|
-
if (payload.type === 'turn.started' && !turn.id)
|
|
123
|
+
if (payload.type === 'turn.started' && payload.data.mode !== 'maintenance' && !turn.id) {
|
|
123
124
|
turn.id = turnId;
|
|
125
|
+
}
|
|
124
126
|
if (turn.id !== turnId)
|
|
125
127
|
continue;
|
|
126
128
|
switch (payload.type) {
|
|
129
|
+
case 'turn.committed': {
|
|
130
|
+
const commit = (0, turn_commit_1.parseTurnCommitV1)(payload.data.receipt);
|
|
131
|
+
if (commit.stopDecision)
|
|
132
|
+
turn.stopDecision = JSON.parse(commit.stopDecision);
|
|
133
|
+
break;
|
|
134
|
+
}
|
|
127
135
|
case 'turn.completed':
|
|
128
136
|
turn.terminal = 'completed';
|
|
129
137
|
break;
|
|
@@ -156,16 +164,21 @@ class AcpSession {
|
|
|
156
164
|
throw error;
|
|
157
165
|
}
|
|
158
166
|
await this.updates.flush();
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
if (signal.aborted && (turn.terminal === 'interrupted' || !turn.id)) {
|
|
167
|
+
const decision = turn.stopDecision;
|
|
168
|
+
if (decision?.status === 'cancelled' ||
|
|
169
|
+
(signal.aborted && (turn.terminal === 'interrupted' || !turn.id))) {
|
|
163
170
|
return { stopReason: 'cancelled' };
|
|
164
171
|
}
|
|
172
|
+
if (turn.terminal && (decision?.status === 'stopped' || decision?.status === 'blocked')) {
|
|
173
|
+
return (0, session_updates_1.acpPausedOutcome)(decision.reason.code);
|
|
174
|
+
}
|
|
175
|
+
if (turn.terminal === 'completed')
|
|
176
|
+
return this.updates.budgetStop ?? { stopReason: 'end_turn' };
|
|
165
177
|
throw new Error(turn.error ?? 'The Runtime did not commit a terminal result');
|
|
166
178
|
}
|
|
167
179
|
catch (error) {
|
|
168
|
-
|
|
180
|
+
const reasonCode = turn.stopDecision?.reason.code;
|
|
181
|
+
throw sdk_1.RequestError.internalError(reasonCode ? { reasonCode } : undefined, diagnostic(error));
|
|
169
182
|
}
|
|
170
183
|
finally {
|
|
171
184
|
this.active = undefined;
|
|
@@ -76,10 +76,13 @@ function formatLoopBudgetSource(stats) {
|
|
|
76
76
|
: source;
|
|
77
77
|
}
|
|
78
78
|
function formatLoopStatsLines(stats) {
|
|
79
|
+
const decision = stats.stopDecision;
|
|
80
|
+
const requests = decision?.resources.llmRequests?.used ?? stats.llmRequests;
|
|
81
|
+
const calls = decision?.resources.toolCalls?.used ?? stats.toolCalls;
|
|
79
82
|
const lines = [
|
|
80
83
|
`Finish ${stats.finishReason}`,
|
|
81
|
-
`Requests ${
|
|
82
|
-
`Tools ${
|
|
84
|
+
`Requests ${requests} LLM / ${stats.turnsStarted} turns`,
|
|
85
|
+
`Tools ${calls} total (${stats.readOnlyToolCalls} read-only, ${stats.unsafeToolCalls} unsafe)`,
|
|
83
86
|
`Tool bytes ${(0, format_1.formatBytes)(stats.modelVisibleToolBytes)} model-visible / ${(0, format_1.formatBytes)(stats.toolResultBytes)} total`,
|
|
84
87
|
];
|
|
85
88
|
if (stats.summarizedBytes > 0) {
|
|
@@ -87,30 +90,15 @@ function formatLoopStatsLines(stats) {
|
|
|
87
90
|
}
|
|
88
91
|
if (stats.compactTrigger)
|
|
89
92
|
lines.push(`Compact ${stats.compactTrigger}`);
|
|
90
|
-
if (
|
|
93
|
+
if (decision)
|
|
94
|
+
lines.push(`Stop ${decision.reason.code}`);
|
|
95
|
+
else if (stats.budgetExceededReason)
|
|
91
96
|
lines.push(`Budget ${stats.budgetExceededReason}`);
|
|
92
|
-
if (stats.loopBudgetRequestPolicy)
|
|
93
|
-
lines.push(`Policy ${stats.loopBudgetRequestPolicy}`);
|
|
94
|
-
if (stats.stopDecision)
|
|
95
|
-
lines.push(`Stop ${stats.stopDecision.reason.code}`);
|
|
96
97
|
if ((stats.providerRetryCount ?? 0) > 0) {
|
|
97
98
|
lines.push(`Provider ${stats.providerRetryCount} retries, delay ${formatDurationMs(stats.providerRetryDelayMs ?? 0)}`);
|
|
98
99
|
}
|
|
99
|
-
if (typeof stats.
|
|
100
|
-
|
|
101
|
-
typeof stats.loopBudgetMaxModelVisibleBytes === 'number') {
|
|
102
|
-
const caps = [
|
|
103
|
-
typeof stats.loopBudgetMaxLlmRequests === 'number'
|
|
104
|
-
? `${stats.llmRequests}/${stats.loopBudgetMaxLlmRequests} LLM${stats.loopBudgetRequestPolicy === 'adaptive' ? ' (safety)' : ''}`
|
|
105
|
-
: undefined,
|
|
106
|
-
typeof stats.loopBudgetMaxToolCalls === 'number'
|
|
107
|
-
? `${stats.toolCalls}/${stats.loopBudgetMaxToolCalls} tools`
|
|
108
|
-
: undefined,
|
|
109
|
-
typeof stats.loopBudgetMaxModelVisibleBytes === 'number'
|
|
110
|
-
? `${(0, format_1.formatBytes)(stats.modelVisibleToolBytes)}/${(0, format_1.formatBytes)(stats.loopBudgetMaxModelVisibleBytes)} visible`
|
|
111
|
-
: undefined,
|
|
112
|
-
].filter(Boolean);
|
|
113
|
-
lines.push(`Budget cap ${caps.join(', ')} (${formatLoopBudgetSource(stats)})`);
|
|
100
|
+
if (typeof stats.loopBudgetMaxModelVisibleBytes === 'number') {
|
|
101
|
+
lines.push(`Output allowance ${(0, format_1.formatBytes)(stats.loopBudgetMaxModelVisibleBytes)} model-visible (${formatLoopBudgetSource(stats)})`);
|
|
114
102
|
}
|
|
115
103
|
return lines;
|
|
116
104
|
}
|
|
@@ -44,10 +44,13 @@ function formatLoopBudgetSource(stats) {
|
|
|
44
44
|
return source;
|
|
45
45
|
}
|
|
46
46
|
function formatLoopStatsLines(stats, detail = false) {
|
|
47
|
+
const decision = stats.stopDecision;
|
|
48
|
+
const requests = decision?.resources.llmRequests?.used ?? stats.llmRequests;
|
|
49
|
+
const calls = decision?.resources.toolCalls?.used ?? stats.toolCalls;
|
|
47
50
|
const lines = [
|
|
48
51
|
`Finish ${stats.finishReason}`,
|
|
49
|
-
`Requests ${
|
|
50
|
-
`Tools ${
|
|
52
|
+
`Requests ${requests} LLM / ${stats.turnsStarted} turns`,
|
|
53
|
+
`Tools ${calls} total (${stats.readOnlyToolCalls} read-only, ${stats.unsafeToolCalls} unsafe)`,
|
|
51
54
|
`Tool bytes ${(0, format_1.formatBytes)(stats.modelVisibleToolBytes)} model-visible / ${(0, format_1.formatBytes)(stats.toolResultBytes)} total`,
|
|
52
55
|
];
|
|
53
56
|
if (stats.summarizedBytes > 0) {
|
|
@@ -59,16 +62,24 @@ function formatLoopStatsLines(stats, detail = false) {
|
|
|
59
62
|
if (stats.localFastPathUsed) {
|
|
60
63
|
lines.push('Fast path yes');
|
|
61
64
|
}
|
|
62
|
-
if (
|
|
63
|
-
lines.push(`
|
|
65
|
+
if (decision) {
|
|
66
|
+
lines.push(`Stop ${decision.reason.code} — ${decision.reason.message}`);
|
|
67
|
+
const { tokens, elapsedMs } = decision.resources;
|
|
68
|
+
if (tokens) {
|
|
69
|
+
lines.push(`Tokens ${tokens.used}${tokens.limit === undefined ? '' : ` / ${tokens.limit}`}`);
|
|
70
|
+
}
|
|
71
|
+
if (elapsedMs) {
|
|
72
|
+
const limit = elapsedMs.limit === undefined ? '' : ` / ${formatDurationMs(elapsedMs.limit)}`;
|
|
73
|
+
lines.push(`Elapsed ${formatDurationMs(elapsedMs.used)}${limit}`);
|
|
74
|
+
}
|
|
64
75
|
}
|
|
65
|
-
if (stats.
|
|
66
|
-
lines.push(`
|
|
76
|
+
else if (stats.budgetExceededReason) {
|
|
77
|
+
lines.push(`Budget ${stats.budgetExceededReason}`);
|
|
67
78
|
}
|
|
68
|
-
if (
|
|
69
|
-
lines.push(`
|
|
79
|
+
if (decision?.nextActions.length) {
|
|
80
|
+
lines.push(`Next ${decision.nextActions.map(action => action.label).join(', ')}`);
|
|
70
81
|
}
|
|
71
|
-
if (stats.continuationActions
|
|
82
|
+
else if (stats.continuationActions?.length) {
|
|
72
83
|
lines.push(`Next ${stats.continuationActions.join(', ')}`);
|
|
73
84
|
}
|
|
74
85
|
if (stats.lastToolName) {
|
|
@@ -103,32 +114,14 @@ function formatLoopStatsLines(stats, detail = false) {
|
|
|
103
114
|
];
|
|
104
115
|
lines.push(`Verify ${verificationParts.join(' ')}`);
|
|
105
116
|
}
|
|
106
|
-
if (typeof stats.
|
|
107
|
-
|
|
108
|
-
typeof stats.loopBudgetMaxModelVisibleBytes === 'number') {
|
|
109
|
-
const caps = [
|
|
110
|
-
typeof stats.loopBudgetMaxLlmRequests === 'number'
|
|
111
|
-
? `${stats.llmRequests}/${stats.loopBudgetMaxLlmRequests} LLM${stats.loopBudgetRequestPolicy === 'adaptive' ? ' (safety)' : ''}`
|
|
112
|
-
: undefined,
|
|
113
|
-
typeof stats.loopBudgetMaxToolCalls === 'number'
|
|
114
|
-
? `${stats.toolCalls}/${stats.loopBudgetMaxToolCalls} tools`
|
|
115
|
-
: undefined,
|
|
116
|
-
typeof stats.loopBudgetMaxModelVisibleBytes === 'number'
|
|
117
|
-
? `${(0, format_1.formatBytes)(stats.modelVisibleToolBytes)}/${(0, format_1.formatBytes)(stats.loopBudgetMaxModelVisibleBytes)} visible`
|
|
118
|
-
: undefined,
|
|
119
|
-
typeof stats.loopBudgetMaxReadOnlyFragmentation === 'number'
|
|
120
|
-
? `fragment ${stats.singleReadOnlyStreak}/${stats.loopBudgetMaxReadOnlyFragmentation}`
|
|
121
|
-
: undefined,
|
|
122
|
-
].filter(Boolean);
|
|
123
|
-
lines.push(`Budget cap ${caps.join(', ')} (${formatLoopBudgetSource(stats)})`);
|
|
124
|
-
}
|
|
125
|
-
if (stats.loopBudgetBaseLlmRequests !== undefined) {
|
|
126
|
-
lines.push(`Budget recovery ${stats.loopBudgetBaseLlmRequests} → ${stats.loopBudgetMaxLlmRequests} LLM after compaction`);
|
|
117
|
+
if (typeof stats.loopBudgetMaxModelVisibleBytes === 'number') {
|
|
118
|
+
lines.push(`Output allowance ${(0, format_1.formatBytes)(stats.loopBudgetMaxModelVisibleBytes)} model-visible (${formatLoopBudgetSource(stats)})`);
|
|
127
119
|
}
|
|
128
120
|
if (stats.budgetCompaction)
|
|
129
121
|
lines.push(`Tool-output compact ${stats.budgetCompaction}`);
|
|
130
|
-
|
|
131
|
-
|
|
122
|
+
const observations = stats.toolProgressObservations;
|
|
123
|
+
if (observations !== undefined) {
|
|
124
|
+
lines.push(`Tool evidence ${observations} distinct ${observations === 1 ? 'observation' : 'observations'}`);
|
|
132
125
|
}
|
|
133
126
|
if (detail) {
|
|
134
127
|
lines.push(`Unsafe ${stats.unsafeToolCalls}`);
|
|
@@ -256,36 +249,29 @@ function formatTraceEventLine(event) {
|
|
|
256
249
|
case 'strategy_exhausted':
|
|
257
250
|
return `${prefix}${event.note ? ` ${WARN(event.note)}` : ''}`;
|
|
258
251
|
case 'complete': {
|
|
252
|
+
const decision = event.stopDecision;
|
|
253
|
+
const requests = decision?.resources.llmRequests?.used ?? event.llmRequests;
|
|
254
|
+
const calls = decision?.resources.toolCalls?.used ?? event.toolCalls;
|
|
259
255
|
const stats = [
|
|
260
256
|
`finish=${event.finishReason ?? 'unknown'}`,
|
|
261
|
-
`llm=${
|
|
262
|
-
`tools=${
|
|
257
|
+
`llm=${requests ?? 'unknown'}`,
|
|
258
|
+
`tools=${calls ?? 'unknown'}`,
|
|
263
259
|
];
|
|
264
|
-
if (event.loopBudgetSource ||
|
|
265
|
-
typeof event.loopBudgetMaxLlmRequests === 'number' ||
|
|
266
|
-
typeof event.loopBudgetMaxToolCalls === 'number' ||
|
|
267
|
-
typeof event.loopBudgetMaxModelVisibleBytes === 'number') {
|
|
260
|
+
if (event.loopBudgetSource || typeof event.loopBudgetMaxModelVisibleBytes === 'number') {
|
|
268
261
|
const source = event.loopBudgetSource === 'config' && event.loopBudgetBaseProfile
|
|
269
262
|
? `config/${event.loopBudgetBaseProfile}`
|
|
270
263
|
: (event.loopBudgetSource ?? 'unknown');
|
|
271
|
-
const
|
|
272
|
-
typeof event.loopBudgetMaxLlmRequests === 'number'
|
|
273
|
-
? `${typeof event.llmRequests === 'number' ? event.llmRequests : '?'}/${event.loopBudgetMaxLlmRequests}llm`
|
|
274
|
-
: undefined,
|
|
275
|
-
typeof event.loopBudgetMaxToolCalls === 'number'
|
|
276
|
-
? `${typeof event.toolCalls === 'number' ? event.toolCalls : '?'}/${event.loopBudgetMaxToolCalls}tools`
|
|
277
|
-
: undefined,
|
|
264
|
+
const toolOutput = [
|
|
278
265
|
typeof event.loopBudgetMaxModelVisibleBytes === 'number'
|
|
279
|
-
? `${(0, format_1.formatBytes)(event.loopBudgetMaxModelVisibleBytes)}visible`
|
|
280
|
-
: undefined,
|
|
281
|
-
typeof event.loopBudgetMaxReadOnlyFragmentation === 'number'
|
|
282
|
-
? `frag=${event.loopBudgetMaxReadOnlyFragmentation}`
|
|
266
|
+
? `${(0, format_1.formatBytes)(event.loopBudgetMaxModelVisibleBytes)} visible`
|
|
283
267
|
: undefined,
|
|
284
268
|
event.loopBudgetConfigOverride ? 'override=yes' : undefined,
|
|
285
269
|
].filter(Boolean);
|
|
286
|
-
stats.push(`
|
|
270
|
+
stats.push(`toolOutputProfile=${source}${toolOutput.length ? `(${toolOutput.join(',')})` : ''}`);
|
|
287
271
|
}
|
|
288
|
-
if (
|
|
272
|
+
if (decision)
|
|
273
|
+
stats.push(`stop=${decision.reason.code}`);
|
|
274
|
+
else if (event.budgetExceededReason)
|
|
289
275
|
stats.push(`budget=${event.budgetExceededReason}`);
|
|
290
276
|
if (event.continuationActions?.length)
|
|
291
277
|
stats.push(`next=${event.continuationActions.join(',')}`);
|
|
@@ -1037,7 +1023,17 @@ function handleUsage(ctx) {
|
|
|
1037
1023
|
}
|
|
1038
1024
|
console.log();
|
|
1039
1025
|
handleLoopStats(ctx);
|
|
1040
|
-
const
|
|
1026
|
+
const progress = snapshot.harnessState?.progressState;
|
|
1027
|
+
const counts = progress?.progressCountedByReason;
|
|
1028
|
+
if (counts) {
|
|
1029
|
+
console.log(HEADER(' Recorded task progress:'));
|
|
1030
|
+
console.log(` Workspace changes ${DIM(counts.workspace_change.toLocaleString())}`);
|
|
1031
|
+
console.log(` Verification ${DIM(counts.verification_change.toLocaleString())}`);
|
|
1032
|
+
console.log(` Task state ${DIM(counts.explicit_task_state.toLocaleString())}`);
|
|
1033
|
+
console.log(` Read-only findings ${DIM(counts.readonly_exploration.toLocaleString())}`);
|
|
1034
|
+
console.log(` Visible output ${DIM(counts.agent_output.toLocaleString())}`);
|
|
1035
|
+
}
|
|
1036
|
+
const lastProgress = progress?.lastDelta?.reason;
|
|
1041
1037
|
if (lastProgress)
|
|
1042
1038
|
console.log(DIM(' Last recorded task progress: ' + lastProgress));
|
|
1043
1039
|
handleCost(ctx);
|
|
@@ -23,7 +23,7 @@ const BUILTIN_METADATA = {
|
|
|
23
23
|
busyPolicy: 'queue-next',
|
|
24
24
|
defaultAction: 'show-status',
|
|
25
25
|
lifecycle: stable(),
|
|
26
|
-
argumentSchema: raw(['status', 'pause', 'resume', 'clear']),
|
|
26
|
+
argumentSchema: raw(['status', 'pause', 'resume', 'budget', 'clear']),
|
|
27
27
|
},
|
|
28
28
|
plan: {
|
|
29
29
|
id: 'builtin.workflow.plan',
|
|
@@ -3,11 +3,13 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
3
3
|
exports.parseTargetCommand = parseTargetCommand;
|
|
4
4
|
exports.isTargetCommand = isTargetCommand;
|
|
5
5
|
const MAX_GOAL_OBJECTIVE_CHARS = 4000;
|
|
6
|
+
const GOAL_USAGE = 'Usage: /goal [objective|status|pause|resume|budget|clear]';
|
|
7
|
+
const BUDGET_USAGE = 'Usage: /goal budget [--max-tokens N] [--max-elapsed-ms N]';
|
|
6
8
|
/** Parse the v0.2 Goal surface. `/target` and legacy mutations are breaking-cut removed. */
|
|
7
9
|
function parseTargetCommand(rawInput) {
|
|
8
10
|
const input = rawInput.trim();
|
|
9
11
|
if (!/^\/goal(?:\s|$)/u.test(input)) {
|
|
10
|
-
return { ok: false, error:
|
|
12
|
+
return { ok: false, error: GOAL_USAGE };
|
|
11
13
|
}
|
|
12
14
|
const rest = input.slice('/goal'.length).trim();
|
|
13
15
|
if (!rest || rest === 'status') {
|
|
@@ -16,20 +18,61 @@ function parseTargetCommand(rawInput) {
|
|
|
16
18
|
if (rest === 'pause' || rest === 'resume' || rest === 'clear') {
|
|
17
19
|
return { ok: true, input: { type: 'goal_control', action: rest } };
|
|
18
20
|
}
|
|
19
|
-
|
|
21
|
+
if (/^budget(?:\s|$)/u.test(rest)) {
|
|
22
|
+
const budget = parseBudgetFlags(rest.slice('budget'.length));
|
|
23
|
+
return budget
|
|
24
|
+
? { ok: true, input: { type: 'goal_control', action: 'budget', budget } }
|
|
25
|
+
: { ok: false, error: BUDGET_USAGE };
|
|
26
|
+
}
|
|
27
|
+
const removed = /^(?:exit|confirm|edit|replace)(?:\s|$)|^clear\s+/u.test(rest);
|
|
20
28
|
if (removed) {
|
|
21
29
|
return {
|
|
22
30
|
ok: false,
|
|
23
|
-
error:
|
|
31
|
+
error: `Unsupported Goal command. ${GOAL_USAGE}`,
|
|
24
32
|
};
|
|
25
33
|
}
|
|
26
|
-
|
|
34
|
+
const withBudget = /^(--(?:max-tokens|max-elapsed-ms)\b[\s\S]*?)\s+--\s+([\s\S]+)$/u.exec(rest);
|
|
35
|
+
const budget = withBudget && parseBudgetFlags(withBudget[1]);
|
|
36
|
+
if (/^--(?:max-tokens|max-elapsed-ms)\b/u.test(rest) && !budget) {
|
|
27
37
|
return {
|
|
28
38
|
ok: false,
|
|
29
|
-
error:
|
|
39
|
+
error: 'Usage: /goal [--max-tokens N] [--max-elapsed-ms N] -- <objective>',
|
|
30
40
|
};
|
|
31
41
|
}
|
|
32
|
-
|
|
42
|
+
const objective = withBudget?.[2].trim() ?? rest;
|
|
43
|
+
if (objective.length > MAX_GOAL_OBJECTIVE_CHARS) {
|
|
44
|
+
return {
|
|
45
|
+
ok: false,
|
|
46
|
+
error: `Objective too long (${objective.length} chars, max ${MAX_GOAL_OBJECTIVE_CHARS}).`,
|
|
47
|
+
};
|
|
48
|
+
}
|
|
49
|
+
return {
|
|
50
|
+
ok: true,
|
|
51
|
+
input: { type: 'goal_control', action: 'create', objective, ...(budget ? { budget } : {}) },
|
|
52
|
+
};
|
|
53
|
+
}
|
|
54
|
+
function parseBudgetFlags(raw) {
|
|
55
|
+
const parts = raw.trim().split(/\s+/u);
|
|
56
|
+
if (parts.length !== 2 && parts.length !== 4)
|
|
57
|
+
return undefined;
|
|
58
|
+
const budget = {};
|
|
59
|
+
for (let i = 0; i < parts.length; i += 2) {
|
|
60
|
+
const flag = parts[i];
|
|
61
|
+
const key = flag === '--max-tokens'
|
|
62
|
+
? 'maxTokens'
|
|
63
|
+
: flag === '--max-elapsed-ms'
|
|
64
|
+
? 'maxElapsedMs'
|
|
65
|
+
: undefined;
|
|
66
|
+
const amount = Number(parts[i + 1]);
|
|
67
|
+
if (!key ||
|
|
68
|
+
budget[key] !== undefined ||
|
|
69
|
+
!/^[0-9]+$/u.test(parts[i + 1]) ||
|
|
70
|
+
!Number.isSafeInteger(amount) ||
|
|
71
|
+
amount < 1)
|
|
72
|
+
return undefined;
|
|
73
|
+
budget[key] = amount;
|
|
74
|
+
}
|
|
75
|
+
return budget;
|
|
33
76
|
}
|
|
34
77
|
function isTargetCommand(input) {
|
|
35
78
|
return /^\/goal(?:\s|$)/u.test(input.trimStart());
|
|
@@ -7,8 +7,8 @@ const context_tool_command_handlers_1 = require("./context-tool-command-handlers
|
|
|
7
7
|
exports.WORKFLOW_COMMANDS = [
|
|
8
8
|
{
|
|
9
9
|
name: 'goal',
|
|
10
|
-
description: 'Create, inspect,
|
|
11
|
-
argumentHint: '[objective | status | pause | resume | clear]',
|
|
10
|
+
description: 'Create, inspect, resume, or adjust the budget of a durable Goal',
|
|
11
|
+
argumentHint: '[objective | status | pause | resume | budget | clear]',
|
|
12
12
|
category: 'workflow',
|
|
13
13
|
priority: 3,
|
|
14
14
|
type: 'builtin',
|
|
@@ -1,22 +1,11 @@
|
|
|
1
1
|
export type LoopBudgetBaseProfile = 'default' | 'complex' | 'release';
|
|
2
2
|
export type LoopBudgetSource = LoopBudgetBaseProfile | 'config';
|
|
3
|
-
export type RequestBudgetPolicy = 'adaptive' | 'fixed';
|
|
4
|
-
/** A last-resort foreground guard, independent of normal request checkpoints. */
|
|
5
|
-
export declare const ADAPTIVE_REQUEST_SAFETY_LIMIT = 256;
|
|
6
3
|
export interface LoopBudget {
|
|
7
|
-
/** Strict maximum in fixed mode, initial review checkpoint in adaptive mode. */
|
|
8
|
-
maxLlmRequestsPerUserTurn: number;
|
|
9
|
-
/** Fixed for explicitly configured request caps and non-foreground owners. */
|
|
10
|
-
requestPolicy?: RequestBudgetPolicy;
|
|
11
|
-
/** Maximum tool calls allowed for one user turn before stopping. */
|
|
12
|
-
maxToolCallsPerUserTurn: number;
|
|
13
|
-
/** Consecutive single read-only tool turns before injecting a batch_read hint. */
|
|
14
|
-
maxReadOnlyFragmentation: number;
|
|
15
4
|
/** Shared compression allowance; each result retains up to 2 KiB recovery visibility after exhaustion. */
|
|
16
5
|
maxModelVisibleToolBytes: number;
|
|
17
6
|
/** Budget source after config overrides are applied. */
|
|
18
7
|
profile?: LoopBudgetSource;
|
|
19
|
-
/**
|
|
8
|
+
/** Profile selected before config overrides, when applicable. */
|
|
20
9
|
baseProfile?: LoopBudgetBaseProfile;
|
|
21
10
|
/** Whether user/global/env config changed one or more numeric budget fields. */
|
|
22
11
|
configOverride?: boolean;
|
|
@@ -1,13 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.DEFAULT_LOOP_BUDGET =
|
|
4
|
-
/** A last-resort foreground guard, independent of normal request checkpoints. */
|
|
5
|
-
exports.ADAPTIVE_REQUEST_SAFETY_LIMIT = 256;
|
|
3
|
+
exports.DEFAULT_LOOP_BUDGET = void 0;
|
|
6
4
|
exports.DEFAULT_LOOP_BUDGET = Object.freeze({
|
|
7
|
-
maxLlmRequestsPerUserTurn: 24,
|
|
8
|
-
requestPolicy: 'adaptive',
|
|
9
|
-
maxToolCallsPerUserTurn: 120,
|
|
10
|
-
maxReadOnlyFragmentation: 3,
|
|
11
5
|
maxModelVisibleToolBytes: 64 * 1024,
|
|
12
6
|
profile: 'default',
|
|
13
7
|
baseProfile: 'default',
|
|
@@ -1,5 +1,4 @@
|
|
|
1
1
|
import type { ToolExternalAssertion } from './external-assertion';
|
|
2
|
-
export declare const ADAPTIVE_CHECKPOINT_REQUESTS = 8;
|
|
3
2
|
interface LoopObservation {
|
|
4
3
|
readonly name: string;
|
|
5
4
|
readonly args: Readonly<Record<string, unknown>>;
|
|
@@ -7,16 +6,13 @@ interface LoopObservation {
|
|
|
7
6
|
readonly fileEdit?: boolean;
|
|
8
7
|
readonly assertion?: ToolExternalAssertion;
|
|
9
8
|
}
|
|
10
|
-
/**
|
|
9
|
+
/** Distinct evidence observations for diagnostics. They do not govern sampling or tool execution. */
|
|
11
10
|
export declare class LoopProgress {
|
|
12
11
|
private readonly cwd;
|
|
13
12
|
private readonly seen;
|
|
14
|
-
private lastProgress;
|
|
15
|
-
private recoveryAt;
|
|
16
13
|
constructor(cwd: string);
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
recentlyAdvanced(requests: number): boolean;
|
|
14
|
+
get observations(): number;
|
|
15
|
+
observe(observation: LoopObservation): void;
|
|
20
16
|
}
|
|
21
17
|
export {};
|
|
22
18
|
//# sourceMappingURL=loop-progress.d.ts.map
|
|
@@ -1,22 +1,23 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.LoopProgress =
|
|
3
|
+
exports.LoopProgress = void 0;
|
|
4
4
|
const path_1 = require("path");
|
|
5
5
|
const canonical_1 = require("../runtime/protocol/canonical");
|
|
6
6
|
const verification_command_1 = require("./verification-command");
|
|
7
|
-
exports.ADAPTIVE_CHECKPOINT_REQUESTS = 8;
|
|
8
7
|
const DIRECT_REPOSITORY_READ = /^(?:(?:rg|grep|cat|head|tail|ls)|git\s+(?:grep|show|log|status|diff|ls-files))(?=\s|$)/u;
|
|
9
8
|
// Credit bounded line printing, without interpreting arbitrary sed programs as reads.
|
|
10
9
|
const SED_LINE_PRINT = /^sed\s+-n\s+(?:-e\s+)?(['"]?)\d+(?:,\d+)?p\1\s+(?:--\s+)?(?:'[^'-][^']*'|"[^"-][^"]*"|[^-\s'"<>][^\s'"<>]*)$/u;
|
|
11
10
|
const READ_TRUNCATION_NOTE = /\n\n\[\.\.\. truncated(?:, \d+ more lines; showing lines \d+-\d+ of \d+| at \d+B(?: of \d+B)?)\]$/u;
|
|
12
|
-
/**
|
|
11
|
+
/** Distinct evidence observations for diagnostics. They do not govern sampling or tool execution. */
|
|
13
12
|
class LoopProgress {
|
|
14
13
|
constructor(cwd) {
|
|
15
14
|
this.cwd = cwd;
|
|
16
15
|
this.seen = new Set();
|
|
17
|
-
this.lastProgress = 0;
|
|
18
16
|
}
|
|
19
|
-
|
|
17
|
+
get observations() {
|
|
18
|
+
return this.seen.size;
|
|
19
|
+
}
|
|
20
|
+
observe(observation) {
|
|
20
21
|
const { name, args, output, fileEdit, assertion } = observation;
|
|
21
22
|
if (name === 'todo_write')
|
|
22
23
|
return;
|
|
@@ -55,24 +56,7 @@ class LoopProgress {
|
|
|
55
56
|
name === 'git_diff'
|
|
56
57
|
? [name, observed]
|
|
57
58
|
: [name, args];
|
|
58
|
-
|
|
59
|
-
if (this.seen.has(digest))
|
|
60
|
-
return;
|
|
61
|
-
this.seen.add(digest);
|
|
62
|
-
this.lastProgress = requests;
|
|
63
|
-
this.recoveryAt = undefined;
|
|
64
|
-
}
|
|
65
|
-
checkpoint(requests) {
|
|
66
|
-
if (requests - this.lastProgress < exports.ADAPTIVE_CHECKPOINT_REQUESTS)
|
|
67
|
-
return 'working';
|
|
68
|
-
if (this.recoveryAt !== undefined) {
|
|
69
|
-
return requests - this.recoveryAt < exports.ADAPTIVE_CHECKPOINT_REQUESTS ? 'working' : 'stop';
|
|
70
|
-
}
|
|
71
|
-
this.recoveryAt = requests;
|
|
72
|
-
return 'recover';
|
|
73
|
-
}
|
|
74
|
-
recentlyAdvanced(requests) {
|
|
75
|
-
return this.lastProgress > 0 && requests - this.lastProgress < exports.ADAPTIVE_CHECKPOINT_REQUESTS;
|
|
59
|
+
this.seen.add((0, canonical_1.digestRuntimeValue)(identity));
|
|
76
60
|
}
|
|
77
61
|
}
|
|
78
62
|
exports.LoopProgress = LoopProgress;
|