@orion-agents/orion-code 0.4.7 → 0.4.9
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 +17 -1
- package/README.md +8 -9
- package/README.zh-CN.md +8 -8
- package/dist/acp/session-updates.js +1 -0
- package/dist/cli.js +42 -3
- package/dist/commands/session-command-handlers.js +8 -3
- package/dist/commands/system-commands.js +3 -3
- package/dist/commands/types.d.ts +3 -0
- package/dist/framework/loop-progress.js +3 -1
- package/dist/framework/query.d.ts +6 -8
- package/dist/framework/query.js +39 -76
- package/dist/framework/tool-serializer.d.ts +12 -0
- package/dist/framework/tool-serializer.js +35 -0
- package/dist/framework/tool.d.ts +2 -0
- package/dist/framework/verification-command.d.ts +21 -0
- package/dist/framework/verification-command.js +53 -4
- package/dist/harness/context-harness.d.ts +3 -9
- package/dist/harness/context-harness.js +43 -163
- package/dist/harness/ledger.js +2 -1
- package/dist/harness/state.d.ts +3 -0
- package/dist/harness/state.js +37 -4
- package/dist/harness/task-checklist.d.ts +1 -1
- package/dist/harness/task-checklist.js +1 -1
- package/dist/harness/types.d.ts +1 -0
- package/dist/harness/verification.js +5 -4
- package/dist/print-ui/delivery.d.ts +15 -0
- package/dist/print-ui/delivery.js +131 -0
- package/dist/print-ui/event-stream.d.ts +6 -1
- package/dist/print-ui/event-stream.js +56 -10
- package/dist/print-ui/launch.d.ts +5 -0
- package/dist/print-ui/launch.js +66 -9
- package/dist/runtime/agent-loop.d.ts +3 -1
- package/dist/runtime/agent-loop.js +26 -41
- package/dist/runtime/agent-runtime-controller.d.ts +4 -1
- package/dist/runtime/agent-runtime-controller.js +36 -22
- package/dist/runtime/agent-runtime-runner.d.ts +4 -0
- package/dist/runtime/agent-runtime-runner.js +9 -0
- package/dist/runtime/builtin-tool-provider.js +6 -5
- package/dist/runtime/composer/layout.d.ts +1 -1
- package/dist/runtime/composer/layout.js +5 -5
- package/dist/runtime/core-tools/descriptors.d.ts +1 -1
- package/dist/runtime/core-tools/descriptors.js +39 -1
- package/dist/runtime/first-party-core-provider.js +1 -0
- package/dist/runtime/first-party-tool-services.js +10 -0
- package/dist/runtime/goal-lifecycle-v2.js +5 -0
- package/dist/runtime/goal-runtime-coordinator.js +6 -2
- package/dist/runtime/goals/evidence.js +2 -0
- package/dist/runtime/legacy-thread-materializer.d.ts +7 -0
- package/dist/runtime/legacy-thread-materializer.js +32 -6
- package/dist/runtime/orion-runtime-v1.d.ts +2 -1
- package/dist/runtime/orion-runtime-v1.js +34 -6
- package/dist/runtime/product-bootstrap.d.ts +2 -0
- package/dist/runtime/product-bootstrap.js +1 -0
- package/dist/runtime/product-orion-runtime.d.ts +2 -1
- package/dist/runtime/product-orion-runtime.js +7 -2
- package/dist/runtime/rich-text/layout.d.ts +3 -1
- package/dist/runtime/rich-text/layout.js +37 -22
- package/dist/runtime/shell-process-sessions.d.ts +41 -0
- package/dist/runtime/shell-process-sessions.js +258 -0
- package/dist/runtime/step-snapshot.js +61 -11
- package/dist/runtime/subagents/presets.d.ts +1 -1
- package/dist/runtime/subagents/presets.js +1 -0
- package/dist/runtime/task-context-recovery.js +14 -3
- package/dist/runtime/task-context-service.d.ts +2 -6
- package/dist/runtime/task-context-service.js +3 -12
- package/dist/runtime/thread-event-store.d.ts +3 -0
- package/dist/runtime/thread-event-store.js +35 -22
- package/dist/runtime/thread-session-index.d.ts +15 -3
- package/dist/runtime/thread-session-index.js +152 -45
- package/dist/runtime/thread-session-view.js +1 -1
- package/dist/runtime/thread-ui-adapter.d.ts +1 -1
- package/dist/runtime/thread-ui-adapter.js +23 -5
- package/dist/runtime/tool-gateway.d.ts +1 -0
- package/dist/runtime/tool-gateway.js +1 -0
- package/dist/runtime/tool-transcript-entry.d.ts +8 -1
- package/dist/runtime/tool-transcript-entry.js +35 -7
- package/dist/runtime/ui-events.d.ts +10 -0
- package/dist/runtime/verification-feedback.d.ts +4 -0
- package/dist/runtime/verification-feedback.js +61 -0
- package/dist/services/global-config.d.ts +1 -1
- package/dist/services/global-config.js +2 -0
- package/dist/services/llm.d.ts +3 -0
- package/dist/services/llm.js +48 -4
- package/dist/terminal-ui/raw-editor.js +2 -1
- package/dist/tools/bash_security.d.ts +1 -24
- package/dist/tools/bash_security.js +7 -124
- package/dist/tools/core/exec-command.js +51 -42
- package/dist/tools/core/index.d.ts +2 -1
- package/dist/tools/core/index.js +4 -1
- package/dist/tools/core/process-session.d.ts +2 -0
- package/dist/tools/core/process-session.js +54 -0
- package/dist/tools/todo.js +9 -13
- package/dist/tui-core/frame.d.ts +2 -0
- package/dist/tui-core/frame.js +19 -0
- package/dist/tui-core/input-parser.d.ts +4 -1
- package/dist/tui-core/input-parser.js +22 -0
- package/dist/tui-ui/chrome-view-model.d.ts +0 -2
- package/dist/tui-ui/chrome-view-model.js +54 -56
- package/dist/tui-ui/launch.js +133 -202
- package/dist/tui-ui/layout.d.ts +16 -41
- package/dist/tui-ui/layout.js +408 -295
- package/dist/tui-ui/render-scheduler.d.ts +2 -5
- package/dist/tui-ui/render-scheduler.js +10 -10
- package/dist/tui-ui/response-clipboard.d.ts +17 -0
- package/dist/tui-ui/response-clipboard.js +201 -0
- package/dist/tui-ui/runner.d.ts +65 -80
- package/dist/tui-ui/runner.js +545 -738
- package/dist/tui-ui/session-picker-preview.d.ts +8 -0
- package/dist/tui-ui/session-picker-preview.js +119 -0
- package/dist/tui-ui/session-picker.d.ts +20 -0
- package/dist/tui-ui/session-picker.js +42 -0
- package/dist/tui-ui/state.d.ts +34 -81
- package/dist/tui-ui/state.js +155 -288
- package/dist/tui-ui/terminal-image.d.ts +3 -7
- package/dist/tui-ui/terminal-image.js +18 -47
- package/dist/tui-ui/terminal-viewport.d.ts +55 -0
- package/dist/tui-ui/terminal-viewport.js +221 -0
- package/dist/tui-ui/transcript-layout.d.ts +5 -0
- package/dist/tui-ui/transcript-layout.js +43 -28
- package/dist/tui-ui/transcript-pager.d.ts +39 -0
- package/dist/tui-ui/transcript-pager.js +278 -0
- package/dist/tui-ui/transcript-tool-output.d.ts +16 -0
- package/dist/tui-ui/transcript-tool-output.js +102 -0
- package/dist/utils/bounded-file.d.ts +4 -0
- package/dist/utils/bounded-file.js +30 -0
- package/dist/utils/command-process.d.ts +4 -0
- package/dist/utils/command-process.js +23 -0
- package/dist/utils/shell-command.d.ts +29 -0
- package/dist/utils/shell-command.js +185 -0
- package/docs/cli-guide.md +50 -6
- package/npm-shrinkwrap.json +115 -15
- package/package.json +4 -1
- package/dist/tui-ui/inline-surface.d.ts +0 -191
- package/dist/tui-ui/inline-surface.js +0 -644
- package/dist/tui-ui/input-ownership.d.ts +0 -46
- package/dist/tui-ui/input-ownership.js +0 -74
- package/dist/tui-ui/transcript-inspector-layout.d.ts +0 -9
- package/dist/tui-ui/transcript-inspector-layout.js +0 -107
- package/dist/tui-ui/transcript-inspector-surface.d.ts +0 -18
- package/dist/tui-ui/transcript-inspector-surface.js +0 -91
- package/dist/tui-ui/transcript-inspector.d.ts +0 -36
- package/dist/tui-ui/transcript-inspector.js +0 -129
package/CHANGELOG.md
CHANGED
|
@@ -22,7 +22,23 @@ which is **not** a pass.
|
|
|
22
22
|
|
|
23
23
|
## [Unreleased]
|
|
24
24
|
|
|
25
|
-
## [0.4.
|
|
25
|
+
## [0.4.9] — UNRELEASED
|
|
26
|
+
|
|
27
|
+
- Rebuild TUI history from retained conversation records across terminal resizes. Keep the full-width composer, tool activity, and live Thinking on an app-owned screen while preserving shell scrollback.
|
|
28
|
+
- Use Ctrl+T for conversation history with reasoning summaries and tool output. Ctrl+O copies the latest completed reply as Markdown. Exit appends the completed conversation tail to the shell scrollback.
|
|
29
|
+
- Use a compact TUI composer with its suggestions and status below the draft. A single activity row shows the current work and interrupt shortcut while a turn is running.
|
|
30
|
+
- Let an agent write to, poll, or cancel the same shell process within a turn and report its actual exit independently of interactive tool receipts (#410).
|
|
31
|
+
- Let Print validate the final reply against a JSON Schema and atomically save it with `--output-last-message` or `-o` (#411).
|
|
32
|
+
|
|
33
|
+
## [0.4.8] — UNRELEASED
|
|
34
|
+
|
|
35
|
+
- Report the shell exit status separately from verification. Recognizable checks in pipelines show why the result is unverified and suggest a direct, bounded command for simple output filters (#408).
|
|
36
|
+
- Deliver final model replies with missing evidence across CLI, TUI, Terminal and ACP. Checklist updates report verification gaps, and a Goal with outstanding evidence can be resumed.
|
|
37
|
+
- Filter generated completion instructions from restored v0.4.7 sessions while retaining the user transcript and real verification evidence.
|
|
38
|
+
|
|
39
|
+
## [0.4.7] — npm-published
|
|
40
|
+
|
|
41
|
+
Version 0.4.7 was published to npm on 2026-12-04.
|
|
26
42
|
|
|
27
43
|
- Answer read-only explanations and status questions within existing sessions while retaining their task checklists and verification requirements (#405).
|
|
28
44
|
- Match custom workflow verification against the requested command, working directory, and fresh executor receipt. Ask for an exact check when a requirement lacks one (#406).
|
package/README.md
CHANGED
|
@@ -2,9 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
Local-first, goal-driven coding agent for the terminal (CLI/TUI).
|
|
4
4
|
|
|
5
|
-
> v0.4.
|
|
6
|
-
>
|
|
7
|
-
> old-version data compatibility and migration are not part of this release.
|
|
5
|
+
> v0.4.9 is a candidate for reliable TUI transcript and composer reflow during terminal resizing.
|
|
6
|
+
> Orion uses `orion.yaml` and can resume sessions created by v0.4.7.
|
|
8
7
|
> A version number or local installation is not proof of release qualification or npm publication.
|
|
9
8
|
|
|
10
9
|
[中文说明](README.zh-CN.md) · [CLI guide](docs/cli-guide.md) ·
|
|
@@ -15,9 +14,9 @@ Local-first, goal-driven coding agent for the terminal (CLI/TUI).
|
|
|
15
14
|
- Explore and change local repositories through a shared Agent Runtime and ToolGateway.
|
|
16
15
|
- Use the default TUI for input, streaming activity, approvals and review.
|
|
17
16
|
- Drive Orion from an [ACP v1 client](docs/cli-guide.md#acp-接入) with `orion acp`.
|
|
18
|
-
- Save sessions, plans and Goals
|
|
17
|
+
- Save sessions, plans and Goals and recover them after restart.
|
|
19
18
|
- Load Model, Skills and MCP capabilities on demand; inspect configuration with `orion doctor`.
|
|
20
|
-
-
|
|
19
|
+
- Deliver the model's final reply and report verification evidence separately.
|
|
21
20
|
|
|
22
21
|
This is a coding agent, not a general-purpose IDE or plugin marketplace. Supporting a provider
|
|
23
22
|
does not prove that a particular model or coding task passed quality evaluation.
|
|
@@ -30,15 +29,15 @@ The exact package qualification floors are 22.12.0 / 24.0.0 / 26.0.0.
|
|
|
30
29
|
Install the exact candidate tarball from the path where it was built.
|
|
31
30
|
|
|
32
31
|
```bash
|
|
33
|
-
npm install -g /absolute/path/orion-agents-orion-code-0.4.
|
|
32
|
+
npm install -g /absolute/path/orion-agents-orion-code-0.4.9.tgz
|
|
34
33
|
orion --version
|
|
35
34
|
orion doctor
|
|
36
35
|
```
|
|
37
36
|
|
|
38
|
-
Use the following command once version 0.4.
|
|
37
|
+
Use the following command once version 0.4.9 is available on npm.
|
|
39
38
|
|
|
40
39
|
```bash
|
|
41
|
-
npm install -g @orion-agents/orion-code@0.4.
|
|
40
|
+
npm install -g @orion-agents/orion-code@0.4.9
|
|
42
41
|
```
|
|
43
42
|
|
|
44
43
|
From a source checkout:
|
|
@@ -108,7 +107,7 @@ npm run format:check
|
|
|
108
107
|
npm run build
|
|
109
108
|
npm run test:coverage -- --runInBand
|
|
110
109
|
npm run test:harness-confluence
|
|
111
|
-
npm run release:check -- --expected-version 0.4.
|
|
110
|
+
npm run release:check -- --expected-version 0.4.9
|
|
112
111
|
```
|
|
113
112
|
|
|
114
113
|
Qualification binds one exact tarball's SHA-256 and source identity to installed CLI, TUI, terminal,
|
package/README.zh-CN.md
CHANGED
|
@@ -2,8 +2,8 @@
|
|
|
2
2
|
|
|
3
3
|
面向终端、本地优先的目标驱动 Coding Agent(CLI/TUI)。
|
|
4
4
|
|
|
5
|
-
> v0.4.
|
|
6
|
-
>
|
|
5
|
+
> v0.4.9 候选版修复终端缩放时 TUI 回复重复及输入框重绘问题。
|
|
6
|
+
> 全局配置使用 `orion.yaml`,可恢复 v0.4.7 创建的会话。
|
|
7
7
|
> 源码版本号、本地可运行、候选包验收与 npm 发布分别记录,不互相替代。
|
|
8
8
|
|
|
9
9
|
[English](README.md) · [CLI 使用与验收](docs/cli-guide.md) ·
|
|
@@ -14,9 +14,9 @@
|
|
|
14
14
|
- 通过共享 Agent Runtime 与 ToolGateway 理解、修改和验证本地仓库。
|
|
15
15
|
- 默认 TUI 承载输入、流式活动、审批、审查和任务接管。
|
|
16
16
|
- 通过 `orion acp` 让 [ACP v1 客户端](docs/cli-guide.md#acp-接入) 驱动编码任务。
|
|
17
|
-
-
|
|
17
|
+
- 保存 Session、Plan 与 Goal,重启后可继续原会话。
|
|
18
18
|
- 按需使用模型、Skills 与 MCP,通过 `orion doctor` 检查配置。
|
|
19
|
-
-
|
|
19
|
+
- 交付模型的最终答复,并独立呈现工具和验证证据。
|
|
20
20
|
|
|
21
21
|
本产品不是通用 IDE 或插件市场;支持某个模型,不代表任意编码任务已通过质量评测。
|
|
22
22
|
|
|
@@ -28,15 +28,15 @@
|
|
|
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.9.tgz
|
|
32
32
|
orion --version
|
|
33
33
|
orion doctor
|
|
34
34
|
```
|
|
35
35
|
|
|
36
|
-
确认 npm 已有 0.4.
|
|
36
|
+
确认 npm 已有 0.4.9 后,可按固定版本安装。
|
|
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.9
|
|
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.9
|
|
108
108
|
```
|
|
109
109
|
|
|
110
110
|
准出需绑定同一 tarball 的 SHA-256 与源码身份,在三个 Node floor 验证安装后的 CLI、TUI、
|
|
@@ -122,6 +122,7 @@ class AcpSessionUpdates {
|
|
|
122
122
|
sessionUpdate: 'tool_call_update',
|
|
123
123
|
toolCallId: event.callId,
|
|
124
124
|
status: event.success ? 'completed' : 'failed',
|
|
125
|
+
...(event.verification ? { _meta: { orion: { verification: event.verification } } } : {}),
|
|
125
126
|
...(text ? { content: [{ type: 'content', content: { type: 'text', text } }] } : {}),
|
|
126
127
|
});
|
|
127
128
|
}
|
package/dist/cli.js
CHANGED
|
@@ -76,6 +76,8 @@ function showCliHelp() {
|
|
|
76
76
|
console.log(' --output-format <text|json|jsonl> Print-mode output format');
|
|
77
77
|
console.log(' --strict-exit Use the JSONL exit-code contract with text or JSON');
|
|
78
78
|
console.log(' --resume <session-id> Load a saved session before the print prompt');
|
|
79
|
+
console.log(' --output-schema <file> Validate the final Print reply against a JSON Schema');
|
|
80
|
+
console.log(' -o, --output-last-message <file> Write the final Print reply to a file');
|
|
79
81
|
console.log();
|
|
80
82
|
console.log(DIM('tui is the default product UI. terminal is the technical fallback.'));
|
|
81
83
|
console.log();
|
|
@@ -86,6 +88,9 @@ function parseCliOptions(args) {
|
|
|
86
88
|
let outputFormat = 'text';
|
|
87
89
|
let strictExit = false;
|
|
88
90
|
let resumeSessionId;
|
|
91
|
+
let outputSchemaPath;
|
|
92
|
+
let lastMessagePath;
|
|
93
|
+
let outputOptionError;
|
|
89
94
|
const promptArgs = [];
|
|
90
95
|
for (let i = 0; i < args.length; i++) {
|
|
91
96
|
const arg = args[i];
|
|
@@ -105,6 +110,22 @@ function parseCliOptions(args) {
|
|
|
105
110
|
resumeSessionId = arg === '--resume' ? (args[++i] ?? '') : arg.slice('--resume='.length);
|
|
106
111
|
continue;
|
|
107
112
|
}
|
|
113
|
+
const equals = arg.indexOf('=');
|
|
114
|
+
const flag = equals === -1 ? arg : arg.slice(0, equals);
|
|
115
|
+
if (flag === '--output-schema' || flag === '--output-last-message' || flag === '-o') {
|
|
116
|
+
const next = args[i + 1];
|
|
117
|
+
const path = equals >= 0 ? arg.slice(equals + 1) : next && !next.startsWith('-') ? args[++i] : '';
|
|
118
|
+
if (!path.trim()) {
|
|
119
|
+
outputOptionError ?? (outputOptionError = `Specify a file path for ${flag}.`);
|
|
120
|
+
}
|
|
121
|
+
else if (flag === '--output-schema') {
|
|
122
|
+
outputSchemaPath = path;
|
|
123
|
+
}
|
|
124
|
+
else {
|
|
125
|
+
lastMessagePath = path;
|
|
126
|
+
}
|
|
127
|
+
continue;
|
|
128
|
+
}
|
|
108
129
|
const uiValue = arg === '--ui'
|
|
109
130
|
? (args[i + 1] ?? '')
|
|
110
131
|
: arg.startsWith('--ui=')
|
|
@@ -142,7 +163,17 @@ function parseCliOptions(args) {
|
|
|
142
163
|
}
|
|
143
164
|
promptArgs.push(arg);
|
|
144
165
|
}
|
|
145
|
-
return {
|
|
166
|
+
return {
|
|
167
|
+
uiRenderer,
|
|
168
|
+
printMode,
|
|
169
|
+
outputFormat,
|
|
170
|
+
strictExit,
|
|
171
|
+
resumeSessionId,
|
|
172
|
+
outputSchemaPath,
|
|
173
|
+
lastMessagePath,
|
|
174
|
+
outputOptionError,
|
|
175
|
+
promptArgs,
|
|
176
|
+
};
|
|
146
177
|
}
|
|
147
178
|
async function bootstrapRuntime(uiRenderer) {
|
|
148
179
|
const { createProductUiRuntime } = await Promise.resolve().then(() => __importStar(require('./runtime/product-bootstrap')));
|
|
@@ -173,11 +204,13 @@ async function main() {
|
|
|
173
204
|
}
|
|
174
205
|
return;
|
|
175
206
|
}
|
|
176
|
-
|
|
207
|
+
const separator = args.indexOf('--');
|
|
208
|
+
const optionArgs = separator === -1 ? args : args.slice(0, separator);
|
|
209
|
+
if (optionArgs.includes('--help') || optionArgs.includes('-h')) {
|
|
177
210
|
showCliHelp();
|
|
178
211
|
process.exit(0);
|
|
179
212
|
}
|
|
180
|
-
if (
|
|
213
|
+
if (optionArgs.includes('--version') || optionArgs.includes('-v')) {
|
|
181
214
|
console.log(`orion v${VERSION}`);
|
|
182
215
|
process.exit(0);
|
|
183
216
|
}
|
|
@@ -193,6 +226,12 @@ async function main() {
|
|
|
193
226
|
}
|
|
194
227
|
const options = parseCliOptions(args);
|
|
195
228
|
const command = options.printMode ? undefined : options.promptArgs[0];
|
|
229
|
+
if (!options.printMode &&
|
|
230
|
+
(options.outputSchemaPath || options.lastMessagePath || options.outputOptionError)) {
|
|
231
|
+
console.error(ERROR('Final output options require --print.'));
|
|
232
|
+
process.exitCode = 1;
|
|
233
|
+
return;
|
|
234
|
+
}
|
|
196
235
|
if (!options.printMode &&
|
|
197
236
|
(options.outputFormat === 'jsonl' ||
|
|
198
237
|
options.strictExit ||
|
|
@@ -51,11 +51,11 @@ function createResumeTranscriptWindow(sessionId, messages, totalEntries = messag
|
|
|
51
51
|
contentTruncated || (contentTruncated = projected.truncated);
|
|
52
52
|
const display = 'id' in message ? message : undefined;
|
|
53
53
|
const entry = {
|
|
54
|
-
|
|
54
|
+
...display,
|
|
55
|
+
id: display?.id ?? `resume:${sessionId}:${index + 1}`,
|
|
55
56
|
role: message.role,
|
|
56
57
|
content: projected.value,
|
|
57
58
|
title: display?.title ?? (message.role === 'user' ? 'you' : undefined),
|
|
58
|
-
...(display?.toolActivity ? { toolActivity: display.toolActivity } : {}),
|
|
59
59
|
};
|
|
60
60
|
entries.unshift(entry);
|
|
61
61
|
bytes += Buffer.byteLength(projected.value, 'utf8') + RESUME_TRANSCRIPT_ENTRY_OVERHEAD_BYTES;
|
|
@@ -357,7 +357,7 @@ async function handleResume(ctx, args) {
|
|
|
357
357
|
error: 'No previous session found for this project. Use /session list --all to list all sessions.',
|
|
358
358
|
};
|
|
359
359
|
}
|
|
360
|
-
if (scope.last || scopedSessions.length === 1) {
|
|
360
|
+
if (scope.last || (scopedSessions.length === 1 && ctx.uiRenderer !== 'tui')) {
|
|
361
361
|
return restoreSession(ctx, lastSession, true);
|
|
362
362
|
}
|
|
363
363
|
const picker = {
|
|
@@ -462,6 +462,11 @@ async function restoreSession(ctx, session, isLast) {
|
|
|
462
462
|
const resumed = (0, session_storage_1.resumeSession)(selected.id) ?? selected;
|
|
463
463
|
Object.assign(selected, resumed);
|
|
464
464
|
ctx.replaceTranscript?.(transcriptWindow.entries);
|
|
465
|
+
if (ctx.onRestoreTranscriptHistory) {
|
|
466
|
+
const source = restoredView.resumeDisplay?.historySource;
|
|
467
|
+
const before = transcriptDisplayCount - transcriptWindow.entries.length;
|
|
468
|
+
ctx.onRestoreTranscriptHistory(source && before !== source.before ? { ...source, before } : source);
|
|
469
|
+
}
|
|
465
470
|
if (history.length > 0) {
|
|
466
471
|
const eventSummary = checkpoint?.summary.text ?? generateRestoredSessionEventSummary(history);
|
|
467
472
|
ctx.sessionRestored?.({
|
|
@@ -63,7 +63,7 @@ function createSystemCommands(getVisibleCommands) {
|
|
|
63
63
|
rendererScope: ['tui'],
|
|
64
64
|
execute: () => ({
|
|
65
65
|
success: true,
|
|
66
|
-
output: 'Enter send/steer · Tab queue while working · Esc stop · Ctrl+R history · Ctrl+E editor · Ctrl+O
|
|
66
|
+
output: 'Enter send/steer · Tab queue while working · Esc stop · Ctrl+R history · Ctrl+E editor · Ctrl+T transcript · Ctrl+O copy reply · Ctrl+L redraw · Ctrl+D exit',
|
|
67
67
|
}),
|
|
68
68
|
},
|
|
69
69
|
{
|
|
@@ -90,8 +90,8 @@ function createSystemCommands(getVisibleCommands) {
|
|
|
90
90
|
},
|
|
91
91
|
{
|
|
92
92
|
name: 'queue',
|
|
93
|
-
description: '
|
|
94
|
-
argumentHint: '[clear]',
|
|
93
|
+
description: 'Edit, reorder, or remove queued follow-up messages',
|
|
94
|
+
argumentHint: '[resume|clear]',
|
|
95
95
|
category: 'system',
|
|
96
96
|
priority: 34,
|
|
97
97
|
type: 'builtin',
|
package/dist/commands/types.d.ts
CHANGED
|
@@ -13,6 +13,7 @@ import type { ModelCoordinator } from '../runtime/model-coordinator';
|
|
|
13
13
|
import type { SessionComposerControlServiceV1 } from '../runtime/session-composer-control';
|
|
14
14
|
import type { SessionGoalV1 } from '../runtime/goals/types';
|
|
15
15
|
import type { OrionRuntimeDiagnosticsV1 } from '../runtime/orion-runtime-v1';
|
|
16
|
+
import type { ThreadTranscriptHistorySource } from '../runtime/thread-session-index';
|
|
16
17
|
import type { ThreadSessionRuntimeActivationV1 } from '../runtime/thread-session-view';
|
|
17
18
|
import type { EditPreviewRequest, ModelPickerRequest, RuntimeSessionRestoredEvent, RuntimeSettingsMutationV1, SessionPickerRequest, TranscriptEntry, UiRendererCapabilities } from '../runtime/ui-events';
|
|
18
19
|
import type { SettingsCoordinatorV1, SettingsDocumentViewV1, SettingsUpdateResultV1 } from '../services/settings-coordinator';
|
|
@@ -44,6 +45,8 @@ export interface CommandContext {
|
|
|
44
45
|
sessionRestored?: (event: RuntimeSessionRestoredEvent) => void;
|
|
45
46
|
/** Replace only the renderer's bounded transcript window; model context remains authoritative. */
|
|
46
47
|
replaceTranscript?: (entries: readonly TranscriptEntry[]) => void;
|
|
48
|
+
/** Attach a TUI history reader after the foreground transcript has been replaced. */
|
|
49
|
+
onRestoreTranscriptHistory?: (source: ThreadTranscriptHistorySource | undefined) => void;
|
|
47
50
|
/** Return the active session if one exists. */
|
|
48
51
|
getSession?: () => SessionMeta | null;
|
|
49
52
|
/** Current durable Goal state for compact checkpoint binding. */
|
|
@@ -19,7 +19,9 @@ class LoopProgress {
|
|
|
19
19
|
}
|
|
20
20
|
observe(observation) {
|
|
21
21
|
const { name, args, output, fileEdit, assertion } = observation;
|
|
22
|
-
if (name === 'todo_write'
|
|
22
|
+
if (name === 'todo_write' ||
|
|
23
|
+
name === 'process_session' ||
|
|
24
|
+
(name === 'exec_command' && args.interactive === true))
|
|
23
25
|
return;
|
|
24
26
|
const verified = assertion?.status === 'passed' ? assertion : undefined;
|
|
25
27
|
const command = typeof args.command === 'string' ? args.command.trim() : '';
|
|
@@ -8,7 +8,7 @@
|
|
|
8
8
|
* not yielded as events (callbacks cannot yield). The handleChat consumer writes
|
|
9
9
|
* chunks directly to stdout via the callback.
|
|
10
10
|
*/
|
|
11
|
-
import type { LLMRequestDiagnostics, LLMService, Message, StreamCallbacks } from '../services/llm';
|
|
11
|
+
import type { LLMRequestDiagnostics, LLMService, Message, StreamCallbacks, StructuredOutputSchema } from '../services/llm';
|
|
12
12
|
import type { ProviderErrorType } from '../services/provider-diagnostics';
|
|
13
13
|
import type { OrionCodeTool, ToolContext } from './tool';
|
|
14
14
|
import type { CostTracker } from '../core/cost-tracker';
|
|
@@ -18,7 +18,7 @@ import type { CompactResult } from '../services/compact/compact';
|
|
|
18
18
|
import type { CompactCoordinator } from '../services/compact/coordinator';
|
|
19
19
|
import type { CompactPrepareSourceReceipt } from '../services/session-storage';
|
|
20
20
|
import type { ContextHarness, HarnessState } from '../harness';
|
|
21
|
-
import type { PromptAssemblyStats
|
|
21
|
+
import type { PromptAssemblyStats } from '../harness/types';
|
|
22
22
|
import { type AuthoritativeToolExecutor, type ToolPermissionDecision } from './tool-call-orchestrator';
|
|
23
23
|
import { type ContextUsageSnapshot } from '../services/model-context';
|
|
24
24
|
import type { ToolExternalAssertion } from './external-assertion';
|
|
@@ -222,21 +222,19 @@ export interface QueryParams {
|
|
|
222
222
|
resolveStep?: (input: QueryStepResolveInput) => QueryStepRuntime | Promise<QueryStepRuntime>;
|
|
223
223
|
/** LLM service instance */
|
|
224
224
|
llm: LLMService;
|
|
225
|
+
/** Request-local format of the final model reply for Print. */
|
|
226
|
+
outputSchema?: StructuredOutputSchema;
|
|
225
227
|
/** Abort signal for cancellation */
|
|
226
228
|
abortSignal?: AbortSignal;
|
|
227
229
|
/** Streaming callbacks (onChunk writes to stdout, etc.) */
|
|
228
230
|
streamCallbacks?: StreamCallbacks;
|
|
229
|
-
/** Stage answer text for checklist-driven work until the completion gate passes. */
|
|
230
|
-
holdAssistantUntilCompletionCheck?: () => boolean;
|
|
231
|
-
/** Check a persisted checklist's step recovery or explicit deferral before sampling. */
|
|
232
|
-
checkTaskPlanStop?: () => TaskPlanStop | undefined;
|
|
233
231
|
/** Tool execution context */
|
|
234
232
|
toolContext?: ToolContext;
|
|
235
233
|
/** Cost tracker for recording usage */
|
|
236
234
|
costTracker?: CostTracker;
|
|
237
235
|
/** Strategy tracker for alternative approaches */
|
|
238
236
|
strategyTracker?: StrategyTracker;
|
|
239
|
-
/** Optional Context Harness for turn-level context
|
|
237
|
+
/** Optional Context Harness for turn-level context and evidence. */
|
|
240
238
|
harness?: QueryTaskContext;
|
|
241
239
|
/** Current user input, used by Context Harness for evidence ranking */
|
|
242
240
|
input?: string;
|
|
@@ -289,7 +287,7 @@ export interface QueryModelRequestBinding {
|
|
|
289
287
|
readonly toolExecutor: QueryParams['toolExecutor'];
|
|
290
288
|
readonly receiptDigest?: string;
|
|
291
289
|
}
|
|
292
|
-
export type QueryTaskContext = Pick<ContextHarness, 'updateCapabilityProfile' | 'assembleMessages' | 'getCapsule' | 'toJSON' | 'recordAssistantResponse' | 'beforeToolUse' | 'asToolBlockedResult' | 'recordToolResult' | 'beforeComplete'
|
|
290
|
+
export type QueryTaskContext = Pick<ContextHarness, 'updateCapabilityProfile' | 'assembleMessages' | 'getCapsule' | 'toJSON' | 'recordAssistantResponse' | 'beforeToolUse' | 'asToolBlockedResult' | 'recordToolResult' | 'beforeComplete'>;
|
|
293
291
|
export interface AutoCompactNotice {
|
|
294
292
|
mode: 'predictive' | 'threshold';
|
|
295
293
|
before: ContextUsageSnapshot;
|
package/dist/framework/query.js
CHANGED
|
@@ -26,6 +26,7 @@ const tool_call_orchestrator_1 = require("./tool-call-orchestrator");
|
|
|
26
26
|
const token_estimate_1 = require("../utils/token-estimate");
|
|
27
27
|
const terminal_text_1 = require("../utils/terminal-text");
|
|
28
28
|
const tool_serializer_1 = require("./tool-serializer");
|
|
29
|
+
const verification_command_1 = require("./verification-command");
|
|
29
30
|
const model_context_1 = require("../services/model-context");
|
|
30
31
|
const stop_decision_1 = require("./stop-decision");
|
|
31
32
|
const loop_progress_1 = require("./loop-progress");
|
|
@@ -602,6 +603,13 @@ function summarizeModelVisibleToolResult(executed, maxBytes, budgetRemainingByte
|
|
|
602
603
|
}
|
|
603
604
|
// Keep a real excerpt, status and a budget signal even after exhaustion. An
|
|
604
605
|
// untrusted tool's arbitrarily large metadata must not displace the excerpt.
|
|
606
|
+
const toolName = executed.prepared.tc.function.name;
|
|
607
|
+
const shellMetadata = toolName === 'exec_command' || toolName === 'process_session' ? envelope.metadata : undefined;
|
|
608
|
+
const feedback = shellMetadata?.verification;
|
|
609
|
+
const exitCode = shellMetadata?.exitCode;
|
|
610
|
+
const processMetadata = (0, tool_serializer_1.projectProcessMetadata)(shellMetadata);
|
|
611
|
+
const verification = (0, verification_command_1.verificationToolStatus)(feedback);
|
|
612
|
+
const detailedVerification = verification && byteLength(JSON.stringify(feedback)) <= 1024 ? feedback : verification;
|
|
605
613
|
const compactError = rawError ? truncateModelField(rawError, 192) : undefined;
|
|
606
614
|
const minimalError = rawError ? truncateModelField(rawError, 64) : undefined;
|
|
607
615
|
const compactSummary = summary ? truncateModelField(summary, 192) : undefined;
|
|
@@ -616,6 +624,11 @@ function summarizeModelVisibleToolResult(executed, maxBytes, budgetRemainingByte
|
|
|
616
624
|
modelVisibleCompressed: true,
|
|
617
625
|
originalResultBytes: rawBytes,
|
|
618
626
|
...budgetMetadata,
|
|
627
|
+
...processMetadata,
|
|
628
|
+
...(verification
|
|
629
|
+
? { verification: includeDetails ? detailedVerification : verification }
|
|
630
|
+
: {}),
|
|
631
|
+
...(typeof exitCode === 'number' && Number.isSafeInteger(exitCode) ? { exitCode } : {}),
|
|
619
632
|
},
|
|
620
633
|
});
|
|
621
634
|
const includeDetails = byteLength(serializeCompact(truncateForModel(output, 128), true)) <= maxBytes;
|
|
@@ -791,7 +804,6 @@ async function* query(params) {
|
|
|
791
804
|
const interrupted = () => isAborted(abortSignal) || (goalDeadlineAt !== undefined && Date.now() >= goalDeadlineAt);
|
|
792
805
|
let input = params.input;
|
|
793
806
|
let turn = 0;
|
|
794
|
-
const rejectedCompletionStates = new Set();
|
|
795
807
|
let successfulToolCalls = 0;
|
|
796
808
|
const stats = createLoopStats();
|
|
797
809
|
let pendingCompact;
|
|
@@ -854,22 +866,6 @@ async function* query(params) {
|
|
|
854
866
|
return;
|
|
855
867
|
}
|
|
856
868
|
appendSteering(params.takePendingSteering?.() ?? []);
|
|
857
|
-
const planStop = params.checkTaskPlanStop?.();
|
|
858
|
-
if (planStop) {
|
|
859
|
-
const finish = cloneLoopStats(stats, planStop.code === 'task_step_blocked' ? 'blocked' : 'completion_gate');
|
|
860
|
-
const decision = finish.stopDecision;
|
|
861
|
-
finish.stopDecision = {
|
|
862
|
-
...decision,
|
|
863
|
-
status: planStop.code === 'task_step_blocked' ? 'blocked' : 'stopped',
|
|
864
|
-
reason: { code: planStop.code, message: planStop.message },
|
|
865
|
-
nextActions: [
|
|
866
|
-
{ kind: 'inspect', label: 'Inspect the current checklist', command: '/context explain' },
|
|
867
|
-
{ kind: 'continue', label: 'Continue the current task', command: '继续' },
|
|
868
|
-
],
|
|
869
|
-
};
|
|
870
|
-
yield attachCompactCommit({ type: 'complete', content: planStop.message, model: llm.getModel(), stats: finish }, pendingCompact, messages, aggregateUsage);
|
|
871
|
-
return;
|
|
872
|
-
}
|
|
873
869
|
const toolOutputPressure = params.allowToolPressureCompaction === true &&
|
|
874
870
|
successfulToolCalls > 0 &&
|
|
875
871
|
stats.modelVisibleToolBytes >=
|
|
@@ -918,7 +914,19 @@ async function* query(params) {
|
|
|
918
914
|
name: tool.name,
|
|
919
915
|
description: tool.description,
|
|
920
916
|
}));
|
|
921
|
-
const
|
|
917
|
+
const outputSchema = params.outputSchema;
|
|
918
|
+
const assembleRequest = () => {
|
|
919
|
+
const assembled = harness?.assembleMessages(messages, { input, tools: compactToolDescriptions }) ?? messages;
|
|
920
|
+
if (outputSchema === undefined)
|
|
921
|
+
return assembled;
|
|
922
|
+
const instruction = 'Return the final answer as one JSON value matching the following JSON Schema. ' +
|
|
923
|
+
'Do not wrap the final JSON in Markdown or include prose with it. Use tools normally.\n' +
|
|
924
|
+
JSON.stringify(outputSchema);
|
|
925
|
+
const [system, ...rest] = assembled;
|
|
926
|
+
return system?.role === 'system'
|
|
927
|
+
? [{ ...system, content: `${system.content}\n\n${instruction}` }, ...rest]
|
|
928
|
+
: [{ role: 'system', content: instruction }, ...assembled];
|
|
929
|
+
};
|
|
922
930
|
let requestMessages = assembleRequest();
|
|
923
931
|
let requestEstimatedTokens = (0, token_estimate_1.estimateMessagesTokens)(requestMessages);
|
|
924
932
|
const predictedTokens = autoCompact.adjustTokenEstimate(requestEstimatedTokens, llm.getModel());
|
|
@@ -1043,17 +1051,18 @@ async function* query(params) {
|
|
|
1043
1051
|
}
|
|
1044
1052
|
let response;
|
|
1045
1053
|
let sawReasoning = false;
|
|
1046
|
-
|
|
1054
|
+
// A response crossing a configured Goal allowance may be rejected as a whole.
|
|
1055
|
+
const bufferGoalResponse = params.remainingGoalTokens !== undefined || goalDeadlineAt !== undefined;
|
|
1047
1056
|
try {
|
|
1048
1057
|
stats.llmRequests++;
|
|
1049
1058
|
response = await llm.chatStream(requestMessages, {
|
|
1050
1059
|
...streamCallbacks,
|
|
1051
|
-
...(
|
|
1060
|
+
...(bufferGoalResponse ? { onChunk: undefined } : {}),
|
|
1052
1061
|
onThinkingText: text => {
|
|
1053
1062
|
sawReasoning || (sawReasoning = text.trim().length > 0);
|
|
1054
1063
|
streamCallbacks?.onThinkingText?.(text);
|
|
1055
1064
|
},
|
|
1056
|
-
}, openaiTools, { abortSignal });
|
|
1065
|
+
}, openaiTools, { abortSignal, ...(outputSchema === undefined ? {} : { outputSchema }) });
|
|
1057
1066
|
applyLlmRequestDiagnostics(stats, getLlmRequestDiagnostics(llm));
|
|
1058
1067
|
if (response.usage) {
|
|
1059
1068
|
autoCompact.recordProviderUsage(requestEstimatedTokens, response.usage.promptTokens, response.model || llm.getModel());
|
|
@@ -1112,7 +1121,7 @@ async function* query(params) {
|
|
|
1112
1121
|
response.finishReason === 'incomplete') {
|
|
1113
1122
|
if (visibleContent) {
|
|
1114
1123
|
appendMessage({ role: 'assistant', content: visibleContent });
|
|
1115
|
-
if (
|
|
1124
|
+
if (bufferGoalResponse)
|
|
1116
1125
|
streamCallbacks?.onChunk?.(visibleContent);
|
|
1117
1126
|
yield { type: 'message', role: 'assistant', content: visibleContent };
|
|
1118
1127
|
}
|
|
@@ -1155,7 +1164,7 @@ async function* query(params) {
|
|
|
1155
1164
|
};
|
|
1156
1165
|
appendMessage(assistantMsg);
|
|
1157
1166
|
harness?.recordAssistantResponse({ ...response, content: visibleContent });
|
|
1158
|
-
if (
|
|
1167
|
+
if (bufferGoalResponse && visibleContent)
|
|
1159
1168
|
streamCallbacks?.onChunk?.(visibleContent);
|
|
1160
1169
|
yield {
|
|
1161
1170
|
type: 'assistant_tool_calls',
|
|
@@ -1375,7 +1384,7 @@ async function* query(params) {
|
|
|
1375
1384
|
if (visibleContent) {
|
|
1376
1385
|
appendMessage({ role: 'assistant', content: visibleContent });
|
|
1377
1386
|
harness?.recordAssistantResponse({ ...response, content: visibleContent });
|
|
1378
|
-
if (
|
|
1387
|
+
if (bufferGoalResponse)
|
|
1379
1388
|
streamCallbacks?.onChunk?.(visibleContent);
|
|
1380
1389
|
yield { type: 'message', role: 'assistant', content: visibleContent };
|
|
1381
1390
|
}
|
|
@@ -1383,7 +1392,7 @@ async function* query(params) {
|
|
|
1383
1392
|
continue;
|
|
1384
1393
|
}
|
|
1385
1394
|
// A clean provider stop may consist entirely of reasoning or invisible text.
|
|
1386
|
-
//
|
|
1395
|
+
// Preserve a typed provider failure instead of emitting a blank final answer.
|
|
1387
1396
|
if (!visibleContent) {
|
|
1388
1397
|
stats.missingAssistantOutput =
|
|
1389
1398
|
response.content.length === 0 && !sawReasoning ? 'empty_output' : 'no_visible_output';
|
|
@@ -1395,58 +1404,12 @@ async function* query(params) {
|
|
|
1395
1404
|
}, pendingCompact, messages, aggregateUsage);
|
|
1396
1405
|
return;
|
|
1397
1406
|
}
|
|
1398
|
-
|
|
1399
|
-
|
|
1400
|
-
|
|
1401
|
-
};
|
|
1402
|
-
if (!holdAssistant) {
|
|
1403
|
-
appendMessage(assistantMsg);
|
|
1404
|
-
harness?.recordAssistantResponse(response);
|
|
1405
|
-
}
|
|
1406
|
-
// No tool calls — done, unless the harness requires one more pass.
|
|
1407
|
-
const completionGate = harness?.beforeComplete();
|
|
1408
|
-
if (completionGate && !completionGate.canComplete) {
|
|
1409
|
-
const rejectedState = JSON.stringify([
|
|
1410
|
-
completionGate.missing,
|
|
1411
|
-
completionGate.progressDelta?.workspaceStateHash,
|
|
1412
|
-
completionGate.criterionResults?.map(result => [
|
|
1413
|
-
result.criterionId,
|
|
1414
|
-
result.status,
|
|
1415
|
-
result.verificationProblems,
|
|
1416
|
-
]),
|
|
1417
|
-
]);
|
|
1418
|
-
if (rejectedCompletionStates.has(rejectedState)) {
|
|
1419
|
-
const missing = completionGate.missing?.length
|
|
1420
|
-
? completionGate.missing.join('; ')
|
|
1421
|
-
: 'required verification evidence is missing';
|
|
1422
|
-
const stoppedStats = cloneLoopStats(stats, 'completion_gate');
|
|
1423
|
-
if (completionGate.stopDecision) {
|
|
1424
|
-
stoppedStats.stopDecision = {
|
|
1425
|
-
...completionGate.stopDecision,
|
|
1426
|
-
resources: {
|
|
1427
|
-
...stoppedStats.stopDecision?.resources,
|
|
1428
|
-
...completionGate.stopDecision.resources,
|
|
1429
|
-
},
|
|
1430
|
-
};
|
|
1431
|
-
}
|
|
1432
|
-
yield attachCompactCommit({
|
|
1433
|
-
type: 'complete',
|
|
1434
|
-
content: `Completion gate stopped this turn: ${missing}\nRun the required verification, then continue.`,
|
|
1435
|
-
model: response.model || llm.getModel(),
|
|
1436
|
-
stats: stoppedStats,
|
|
1437
|
-
}, pendingCompact, messages, aggregateUsage);
|
|
1438
|
-
return;
|
|
1439
|
-
}
|
|
1440
|
-
rejectedCompletionStates.add(rejectedState);
|
|
1441
|
-
appendMessage(harness.asCompletionBlockedMessage(completionGate));
|
|
1442
|
-
stats.finishReason = 'completion_gate';
|
|
1443
|
-
continue;
|
|
1444
|
-
}
|
|
1445
|
-
if (holdAssistant) {
|
|
1446
|
-
appendMessage(assistantMsg);
|
|
1447
|
-
harness?.recordAssistantResponse(response);
|
|
1407
|
+
appendMessage({ role: 'assistant', content: response.content });
|
|
1408
|
+
harness?.recordAssistantResponse(response);
|
|
1409
|
+
if (bufferGoalResponse)
|
|
1448
1410
|
streamCallbacks?.onChunk?.(response.content);
|
|
1449
|
-
|
|
1411
|
+
// Record verification independently of the model's end-of-turn signal.
|
|
1412
|
+
harness?.beforeComplete();
|
|
1450
1413
|
yield { type: 'message', role: 'assistant', content: response.content };
|
|
1451
1414
|
// Keep the next request safe by compacting the current durable history at
|
|
1452
1415
|
// 95%. This uses current-message context, not cumulative session tokens.
|
|
@@ -6,6 +6,17 @@
|
|
|
6
6
|
*/
|
|
7
7
|
import type { ToolResult } from '../framework/tool';
|
|
8
8
|
export declare const TOOL_RESULT_SCHEMA_VERSION = 1;
|
|
9
|
+
declare const PROCESS_STATUSES: readonly ["running", "exited", "failed", "cancelled", "timed_out", "aborted"];
|
|
10
|
+
export interface ProcessToolMetadata {
|
|
11
|
+
processId: string;
|
|
12
|
+
processStatus: (typeof PROCESS_STATUSES)[number];
|
|
13
|
+
outputTruncated: boolean;
|
|
14
|
+
exitCode?: number;
|
|
15
|
+
signal?: string;
|
|
16
|
+
inputQueued?: true;
|
|
17
|
+
}
|
|
18
|
+
/** Keep only bounded lifecycle fields when projecting a first-party process receipt. */
|
|
19
|
+
export declare function projectProcessMetadata(metadata?: Record<string, unknown>): ProcessToolMetadata | undefined;
|
|
9
20
|
/**
|
|
10
21
|
* Serialize a ToolResult to a JSON string with schema version.
|
|
11
22
|
*/
|
|
@@ -18,4 +29,5 @@ export declare function serializeToolResult(result: ToolResult): string;
|
|
|
18
29
|
export declare function parseToolResultEnvelope(raw: string): ToolResult & {
|
|
19
30
|
schemaVersion?: number;
|
|
20
31
|
};
|
|
32
|
+
export {};
|
|
21
33
|
//# sourceMappingURL=tool-serializer.d.ts.map
|
|
@@ -7,10 +7,45 @@
|
|
|
7
7
|
*/
|
|
8
8
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
9
|
exports.TOOL_RESULT_SCHEMA_VERSION = void 0;
|
|
10
|
+
exports.projectProcessMetadata = projectProcessMetadata;
|
|
10
11
|
exports.serializeToolResult = serializeToolResult;
|
|
11
12
|
exports.parseToolResultEnvelope = parseToolResultEnvelope;
|
|
12
13
|
const external_assertion_1 = require("./external-assertion");
|
|
13
14
|
exports.TOOL_RESULT_SCHEMA_VERSION = 1;
|
|
15
|
+
const PROCESS_STATUSES = [
|
|
16
|
+
'running',
|
|
17
|
+
'exited',
|
|
18
|
+
'failed',
|
|
19
|
+
'cancelled',
|
|
20
|
+
'timed_out',
|
|
21
|
+
'aborted',
|
|
22
|
+
];
|
|
23
|
+
/** Keep only bounded lifecycle fields when projecting a first-party process receipt. */
|
|
24
|
+
function projectProcessMetadata(metadata) {
|
|
25
|
+
if (!metadata)
|
|
26
|
+
return undefined;
|
|
27
|
+
const { processId, processStatus, outputTruncated, exitCode, signal, inputQueued } = metadata;
|
|
28
|
+
if (typeof processId !== 'string' ||
|
|
29
|
+
!/^[\da-f]{8}(?:-[\da-f]{4}){3}-[\da-f]{12}$/u.test(processId) ||
|
|
30
|
+
!PROCESS_STATUSES.includes(processStatus))
|
|
31
|
+
return undefined;
|
|
32
|
+
return {
|
|
33
|
+
processId,
|
|
34
|
+
processStatus: processStatus,
|
|
35
|
+
outputTruncated: outputTruncated === true,
|
|
36
|
+
...(processStatus !== 'running' &&
|
|
37
|
+
typeof exitCode === 'number' &&
|
|
38
|
+
Number.isSafeInteger(exitCode)
|
|
39
|
+
? { exitCode }
|
|
40
|
+
: {}),
|
|
41
|
+
...(processStatus !== 'running' &&
|
|
42
|
+
typeof signal === 'string' &&
|
|
43
|
+
/^SIG[A-Z0-9]{1,12}$/u.test(signal)
|
|
44
|
+
? { signal }
|
|
45
|
+
: {}),
|
|
46
|
+
...(inputQueued === true ? { inputQueued } : {}),
|
|
47
|
+
};
|
|
48
|
+
}
|
|
14
49
|
/**
|
|
15
50
|
* Serialize a ToolResult to a JSON string with schema version.
|
|
16
51
|
*/
|
package/dist/framework/tool.d.ts
CHANGED
|
@@ -50,6 +50,8 @@ export interface ToolContext {
|
|
|
50
50
|
cwd: string;
|
|
51
51
|
config: ToolConfig;
|
|
52
52
|
abortSignal?: AbortSignal;
|
|
53
|
+
/** Pipe-backed command handles owned by the active runtime turn. */
|
|
54
|
+
shellProcesses?: import('../runtime/shell-process-sessions').TurnShellProcesses;
|
|
53
55
|
/** Optional current session id for turn-level tool state tracking */
|
|
54
56
|
sessionId?: string;
|
|
55
57
|
/** Optional turn identifier for per-turn tool bookkeeping */
|