@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
|
@@ -11,8 +11,11 @@ exports.projectTranscriptMessages = projectTranscriptMessages;
|
|
|
11
11
|
const fs_1 = require("fs");
|
|
12
12
|
const path_1 = require("path");
|
|
13
13
|
const atomic_write_1 = require("../services/atomic-write");
|
|
14
|
+
const bounded_file_1 = require("../utils/bounded-file");
|
|
15
|
+
const terminal_text_1 = require("../utils/terminal-text");
|
|
14
16
|
const canonical_1 = require("./protocol/canonical");
|
|
15
17
|
const tool_transcript_entry_1 = require("./tool-transcript-entry");
|
|
18
|
+
const tool_receipt_validator_1 = require("./tool-receipt-validator");
|
|
16
19
|
const TRANSCRIPT_PAGE_ITEMS = 100;
|
|
17
20
|
const MAX_MANIFEST_PAGES = 100000;
|
|
18
21
|
const threadSessionIndexPerformance = {
|
|
@@ -26,52 +29,148 @@ function threadSessionIndexPerformanceCountersV1() {
|
|
|
26
29
|
return Object.freeze({ ...threadSessionIndexPerformance });
|
|
27
30
|
}
|
|
28
31
|
exports.RESUME_TRANSCRIPT_WINDOW_MESSAGES = 50;
|
|
29
|
-
/** UI-only window
|
|
30
|
-
function projectThreadResumeDisplay(items) {
|
|
32
|
+
/** UI-only window and lazy history pages. Model recovery uses its own durable history. */
|
|
33
|
+
function projectThreadResumeDisplay(items, events = []) {
|
|
31
34
|
const ordered = Object.values(items)
|
|
32
35
|
.filter(item => {
|
|
33
36
|
if (item.status === 'started')
|
|
34
37
|
return false;
|
|
35
38
|
return ((item.kind === 'message' && isMessageRole(item.role)) ||
|
|
36
39
|
item.kind === 'reasoning' ||
|
|
40
|
+
item.kind === 'plan' ||
|
|
37
41
|
(0, tool_transcript_entry_1.isToolTranscriptItem)(item.kind));
|
|
38
42
|
})
|
|
39
43
|
.sort((left, right) => left.startedSeq - right.startedSeq);
|
|
44
|
+
const readBefore = cursor => {
|
|
45
|
+
if (!Number.isSafeInteger(cursor) || cursor < 0 || cursor > ordered.length) {
|
|
46
|
+
throw new RangeError('Transcript history cursor is outside the restored snapshot.');
|
|
47
|
+
}
|
|
48
|
+
const before = Math.max(0, cursor - exports.RESUME_TRANSCRIPT_WINDOW_MESSAGES);
|
|
49
|
+
const entries = ordered
|
|
50
|
+
.slice(before, cursor)
|
|
51
|
+
.map(item => projectResumeTranscriptEntry(item, events));
|
|
52
|
+
return { entries, before };
|
|
53
|
+
};
|
|
54
|
+
const { entries, before } = readBefore(ordered.length);
|
|
55
|
+
const latestCompletedReply = findLatestCompletedReply(ordered);
|
|
40
56
|
return {
|
|
41
57
|
totalEntries: ordered.length,
|
|
42
|
-
entries
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
...(role === 'user' ? { title: 'you' } : {}),
|
|
51
|
-
};
|
|
52
|
-
}
|
|
53
|
-
if (item.kind === 'reasoning') {
|
|
54
|
-
return {
|
|
55
|
-
id: item.itemId,
|
|
56
|
-
role: 'assistant',
|
|
57
|
-
title: 'reasoning',
|
|
58
|
-
content: item.content ?? item.summary ?? '',
|
|
59
|
-
};
|
|
60
|
-
}
|
|
61
|
-
return {
|
|
62
|
-
id: item.itemId,
|
|
63
|
-
...(0, tool_transcript_entry_1.toolTranscriptEntry)({
|
|
64
|
-
name: item.name ?? item.kind,
|
|
65
|
-
callId: item.itemId,
|
|
66
|
-
sequence: item.startedSeq,
|
|
67
|
-
success: item.status === 'completed',
|
|
68
|
-
command: (0, tool_transcript_entry_1.toolCommandFromIntent)(item.intent),
|
|
69
|
-
output: item.summary ?? item.error,
|
|
58
|
+
entries,
|
|
59
|
+
...(ordered.length > 0
|
|
60
|
+
? {
|
|
61
|
+
historySource: Object.freeze({
|
|
62
|
+
before,
|
|
63
|
+
recentEntries: entries,
|
|
64
|
+
readBefore,
|
|
65
|
+
latestCompletedReply,
|
|
70
66
|
}),
|
|
71
|
-
}
|
|
67
|
+
}
|
|
68
|
+
: {}),
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
function findLatestCompletedReply(items) {
|
|
72
|
+
let latest;
|
|
73
|
+
for (let index = items.length - 1; index >= 0; index -= 1) {
|
|
74
|
+
const item = items[index];
|
|
75
|
+
if (item.status !== 'completed' ||
|
|
76
|
+
(item.kind !== 'plan' && (item.kind !== 'message' || item.role !== 'assistant'))) {
|
|
77
|
+
continue;
|
|
78
|
+
}
|
|
79
|
+
const sequence = item.terminalSeq ?? item.startedSeq;
|
|
80
|
+
if (latest && sequence <= latest.sequence)
|
|
81
|
+
continue;
|
|
82
|
+
const legacy = item.kind === 'message' ? parseLegacyTranscriptReceipt(item.receipt) : undefined;
|
|
83
|
+
if (legacy && legacy.role !== 'assistant')
|
|
84
|
+
continue;
|
|
85
|
+
const content = legacy?.content ?? item.content ?? item.summary ?? '';
|
|
86
|
+
if ((0, terminal_text_1.hasVisibleAssistantText)(content))
|
|
87
|
+
latest = { sequence, content };
|
|
88
|
+
}
|
|
89
|
+
return latest?.content;
|
|
90
|
+
}
|
|
91
|
+
function projectResumeTranscriptEntry(item, events) {
|
|
92
|
+
const failure = item.status !== 'completed';
|
|
93
|
+
const failurePresentation = failure ? { errorLayer: 'runtime' } : {};
|
|
94
|
+
if (item.kind === 'message') {
|
|
95
|
+
const legacy = parseLegacyTranscriptReceipt(item.receipt);
|
|
96
|
+
const role = legacy?.role ?? item.role;
|
|
97
|
+
const source = legacy?.content ?? item.content ?? item.summary ?? item.error ?? '';
|
|
98
|
+
return {
|
|
99
|
+
id: item.itemId,
|
|
100
|
+
role,
|
|
101
|
+
content: failure ? item.error || source : source,
|
|
102
|
+
...(role === 'user' ? { title: 'you' } : {}),
|
|
103
|
+
...failurePresentation,
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
if (item.kind === 'reasoning' || item.kind === 'plan') {
|
|
107
|
+
return {
|
|
108
|
+
id: item.itemId,
|
|
109
|
+
role: 'assistant',
|
|
110
|
+
title: item.kind,
|
|
111
|
+
content: item.content ?? item.summary ?? '',
|
|
112
|
+
...failurePresentation,
|
|
113
|
+
};
|
|
114
|
+
}
|
|
115
|
+
const receipt = restoredToolReceipt(item, events);
|
|
116
|
+
return {
|
|
117
|
+
id: item.itemId,
|
|
118
|
+
...(0, tool_transcript_entry_1.toolTranscriptEntry)({
|
|
119
|
+
name: item.name ?? item.kind,
|
|
120
|
+
callId: item.itemId,
|
|
121
|
+
turnId: item.turnId,
|
|
122
|
+
sequence: item.startedSeq,
|
|
123
|
+
success: receipt?.success ?? !failure,
|
|
124
|
+
command: (0, tool_transcript_entry_1.toolCommandFromIntent)(item.intent),
|
|
125
|
+
output: item.summary ?? item.error,
|
|
126
|
+
historyOutput: item.content || receipt?.result.output || item.summary || item.error,
|
|
127
|
+
artifactRef: receipt?.result.artifactRef,
|
|
72
128
|
}),
|
|
73
129
|
};
|
|
74
130
|
}
|
|
131
|
+
function resumeEventAt(events, sequence) {
|
|
132
|
+
const candidate = events[sequence - 1];
|
|
133
|
+
if (candidate?.seq === sequence)
|
|
134
|
+
return candidate;
|
|
135
|
+
// The captured replay is contiguous. A caller may also pass an ordered subset.
|
|
136
|
+
let first = 0;
|
|
137
|
+
let last = events.length - 1;
|
|
138
|
+
while (first <= last) {
|
|
139
|
+
const index = Math.floor((first + last) / 2);
|
|
140
|
+
const event = events[index];
|
|
141
|
+
if (event.seq === sequence)
|
|
142
|
+
return event;
|
|
143
|
+
if (event.seq < sequence) {
|
|
144
|
+
first = index + 1;
|
|
145
|
+
}
|
|
146
|
+
else {
|
|
147
|
+
last = index - 1;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
return undefined;
|
|
151
|
+
}
|
|
152
|
+
function restoredToolReceipt(item, events) {
|
|
153
|
+
const sequence = item.terminalSeq;
|
|
154
|
+
if (sequence === undefined || !item.receipt || !item.name)
|
|
155
|
+
return undefined;
|
|
156
|
+
const terminalEvent = resumeEventAt(events, sequence);
|
|
157
|
+
const factEvent = resumeEventAt(events, sequence - 1);
|
|
158
|
+
if (!terminalEvent || !factEvent)
|
|
159
|
+
return undefined;
|
|
160
|
+
try {
|
|
161
|
+
return (0, tool_receipt_validator_1.validateDurableToolInvocationReceiptV1)({
|
|
162
|
+
terminalEvent,
|
|
163
|
+
factEvent,
|
|
164
|
+
item: { itemId: item.itemId, toolName: item.name },
|
|
165
|
+
});
|
|
166
|
+
}
|
|
167
|
+
catch (error) {
|
|
168
|
+
if (!(error instanceof tool_receipt_validator_1.DurableToolReceiptValidationError))
|
|
169
|
+
throw error;
|
|
170
|
+
// The bounded transcript can still show the projected summary without the unverified reference.
|
|
171
|
+
return undefined;
|
|
172
|
+
}
|
|
173
|
+
}
|
|
75
174
|
class ThreadSessionIndexError extends Error {
|
|
76
175
|
constructor(code, message) {
|
|
77
176
|
super(message);
|
|
@@ -162,8 +261,8 @@ function advanceThreadSessionIndexV1(input) {
|
|
|
162
261
|
writeManifest(input.rootDir, manifest);
|
|
163
262
|
return true;
|
|
164
263
|
}
|
|
165
|
-
function loadThreadSessionIndexManifestV1(rootDir, threadId, head) {
|
|
166
|
-
const manifest = readManifest(manifestPath(rootDir, threadId), threadId);
|
|
264
|
+
function loadThreadSessionIndexManifestV1(rootDir, threadId, head, maxFileBytes) {
|
|
265
|
+
const manifest = readManifest(manifestPath(rootDir, threadId), threadId, maxFileBytes);
|
|
167
266
|
return manifest && manifestMatchesHead(manifest, head) ? manifest : undefined;
|
|
168
267
|
}
|
|
169
268
|
function loadThreadSessionIndexedPageV1(input) {
|
|
@@ -171,7 +270,7 @@ function loadThreadSessionIndexedPageV1(input) {
|
|
|
171
270
|
if (!Number.isSafeInteger(pageSize) || pageSize < 1 || pageSize > TRANSCRIPT_PAGE_ITEMS) {
|
|
172
271
|
throw new ThreadSessionIndexError('ORION_THREAD_SESSION_CURSOR_INVALID', 'Transcript pageSize must be an integer from 1 through 100.');
|
|
173
272
|
}
|
|
174
|
-
const manifest = loadThreadSessionIndexManifestV1(input.rootDir, input.threadId, input.head);
|
|
273
|
+
const manifest = loadThreadSessionIndexManifestV1(input.rootDir, input.threadId, input.head, input.maxFileBytes);
|
|
175
274
|
if (!manifest)
|
|
176
275
|
return undefined;
|
|
177
276
|
const end = input.cursor ? decodeCursor(input.cursor, manifest) : manifest.messageCount;
|
|
@@ -180,7 +279,7 @@ function loadThreadSessionIndexedPageV1(input) {
|
|
|
180
279
|
for (const pointer of manifest.pages) {
|
|
181
280
|
if (pointer.end <= offset || pointer.start >= end)
|
|
182
281
|
continue;
|
|
183
|
-
const page = readPage(input.rootDir, input.threadId, pointer);
|
|
282
|
+
const page = readPage(input.rootDir, input.threadId, pointer, input.maxFileBytes);
|
|
184
283
|
const from = Math.max(offset, pointer.start) - pointer.start;
|
|
185
284
|
const to = Math.min(end, pointer.end) - pointer.start;
|
|
186
285
|
items.push(...page.items.slice(from, to));
|
|
@@ -302,8 +401,8 @@ function writeManifest(rootDir, manifest) {
|
|
|
302
401
|
(0, atomic_write_1.atomicWriteFileSync)(manifestPath(rootDir, manifest.threadId), `${(0, canonical_1.canonicalRuntimeJson)(manifest)}\n`, { mode: 0o600, fsync: true });
|
|
303
402
|
fsyncDirectory(rootDir);
|
|
304
403
|
}
|
|
305
|
-
function readManifest(path, threadId) {
|
|
306
|
-
const value = readRegularJson(path, 'manifest');
|
|
404
|
+
function readManifest(path, threadId, maxFileBytes) {
|
|
405
|
+
const value = readRegularJson(path, 'manifest', maxFileBytes);
|
|
307
406
|
if (!isRecord(value))
|
|
308
407
|
return null;
|
|
309
408
|
const { digest: _digest, ...content } = value;
|
|
@@ -371,10 +470,10 @@ function isLatestTurn(value) {
|
|
|
371
470
|
positiveSafeInteger(value.startedSeq) &&
|
|
372
471
|
(value.terminalSeq === undefined || positiveSafeInteger(value.terminalSeq)));
|
|
373
472
|
}
|
|
374
|
-
function readPage(rootDir, threadId, pointer) {
|
|
473
|
+
function readPage(rootDir, threadId, pointer, maxFileBytes) {
|
|
375
474
|
if ((0, path_1.basename)(pointer.file) !== pointer.file)
|
|
376
475
|
throw indexCorrupt('Transcript page path escaped.');
|
|
377
|
-
const page = readStoredPage((0, path_1.join)(pagesDir(rootDir, threadId), pointer.file), threadId);
|
|
476
|
+
const page = readStoredPage((0, path_1.join)(pagesDir(rootDir, threadId), pointer.file), threadId, maxFileBytes);
|
|
378
477
|
if (!page ||
|
|
379
478
|
page.start !== pointer.start ||
|
|
380
479
|
page.end !== pointer.end ||
|
|
@@ -383,8 +482,8 @@ function readPage(rootDir, threadId, pointer) {
|
|
|
383
482
|
}
|
|
384
483
|
return page;
|
|
385
484
|
}
|
|
386
|
-
function readStoredPage(path, threadId) {
|
|
387
|
-
const value = readRegularJson(path, 'page');
|
|
485
|
+
function readStoredPage(path, threadId, maxFileBytes) {
|
|
486
|
+
const value = readRegularJson(path, 'page', maxFileBytes);
|
|
388
487
|
if (!isRecord(value))
|
|
389
488
|
return null;
|
|
390
489
|
const { digest: _digest, ...content } = value;
|
|
@@ -561,13 +660,21 @@ function isItemTerminalEvent(event) {
|
|
|
561
660
|
function isMessageRole(value) {
|
|
562
661
|
return value === 'system' || value === 'user' || value === 'assistant' || value === 'tool';
|
|
563
662
|
}
|
|
564
|
-
function readRegularJson(path, kind) {
|
|
663
|
+
function readRegularJson(path, kind, maxFileBytes) {
|
|
565
664
|
let fd;
|
|
566
665
|
try {
|
|
567
|
-
|
|
568
|
-
if (
|
|
666
|
+
let bytes;
|
|
667
|
+
if (maxFileBytes === undefined) {
|
|
668
|
+
fd = (0, fs_1.openSync)(path, fs_1.constants.O_RDONLY | (typeof fs_1.constants.O_NOFOLLOW === 'number' ? fs_1.constants.O_NOFOLLOW : 0));
|
|
669
|
+
if (!(0, fs_1.fstatSync)(fd).isFile())
|
|
670
|
+
return undefined;
|
|
671
|
+
bytes = (0, fs_1.readFileSync)(fd);
|
|
672
|
+
}
|
|
673
|
+
else {
|
|
674
|
+
bytes = (0, bounded_file_1.readBoundedRegularFileSync)(path, maxFileBytes);
|
|
675
|
+
}
|
|
676
|
+
if (!bytes)
|
|
569
677
|
return undefined;
|
|
570
|
-
const bytes = (0, fs_1.readFileSync)(fd);
|
|
571
678
|
threadSessionIndexPerformance.bytesRead += bytes.byteLength;
|
|
572
679
|
if (kind === 'manifest')
|
|
573
680
|
threadSessionIndexPerformance.manifestReads += 1;
|
|
@@ -203,7 +203,7 @@ function captureThreadSessionV1(projectPath, sessionId, includeDurableHistory) {
|
|
|
203
203
|
}),
|
|
204
204
|
durableHistory,
|
|
205
205
|
...(includeDurableHistory
|
|
206
|
-
? { resumeDisplay: (0, thread_session_index_1.projectThreadResumeDisplay)(projection.items) }
|
|
206
|
+
? { resumeDisplay: (0, thread_session_index_1.projectThreadResumeDisplay)(projection.items, events) }
|
|
207
207
|
: {}),
|
|
208
208
|
store,
|
|
209
209
|
cutoverGeneration: resolution.generation,
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import type
|
|
1
|
+
import { type AgentRuntimeRunnerV1, type AgentRuntimeRunInputOptionsV1 } from './agent-runtime-runner';
|
|
2
2
|
import { type AgentRuntimeEventSink } from './agent-runtime-protocol';
|
|
3
3
|
import type { AgentTurnRequest } from './goals/types';
|
|
4
4
|
import type { RuntimeEventBufferOptionsV1 } from './runtime-event-buffer';
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.ThreadUiAdmissionError = exports.ThreadUiAdapterError = exports.ThreadUiAdapterV1 = exports.THREAD_UI_ADAPTER_VERSION = void 0;
|
|
4
|
+
const verification_command_1 = require("../framework/verification-command");
|
|
5
|
+
const agent_runtime_runner_1 = require("./agent-runtime-runner");
|
|
4
6
|
const agent_runtime_protocol_1 = require("./agent-runtime-protocol");
|
|
5
7
|
const goal_runtime_coordinator_1 = require("./goal-runtime-coordinator");
|
|
6
8
|
const runtime_protocol_v1_1 = require("./protocol/runtime-protocol-v1");
|
|
@@ -162,7 +164,7 @@ class ThreadUiAdapterV1 {
|
|
|
162
164
|
this.assertOpen();
|
|
163
165
|
throwIfAborted(signal);
|
|
164
166
|
if (!pending.isPending())
|
|
165
|
-
throw new
|
|
167
|
+
throw new agent_runtime_runner_1.PendingFollowupChangedError();
|
|
166
168
|
return this.runtime.startPendingFollowup(pending.id, input, mode);
|
|
167
169
|
}
|
|
168
170
|
async waitForIdleAndFlush() {
|
|
@@ -457,6 +459,13 @@ class ThreadUiAdapterV1 {
|
|
|
457
459
|
}
|
|
458
460
|
this.toolReceiptFacts.delete(presentation.itemId);
|
|
459
461
|
const success = receipt?.success ?? event.payload.type === 'item.completed';
|
|
462
|
+
const output = presentation.content || terminal.error;
|
|
463
|
+
const verification = receipt?.toolName === 'exec_command'
|
|
464
|
+
? (0, verification_command_1.verificationToolStatus)(receipt.result.metadata?.verification)
|
|
465
|
+
: undefined;
|
|
466
|
+
const verificationNote = verification?.status === 'unverified'
|
|
467
|
+
? `Verification unavailable (${verification.reason?.replace(/_/gu, ' ') ?? 'missing evidence'}).`
|
|
468
|
+
: undefined;
|
|
460
469
|
this.emit({
|
|
461
470
|
type: 'tool_finished',
|
|
462
471
|
event: {
|
|
@@ -469,9 +478,13 @@ class ThreadUiAdapterV1 {
|
|
|
469
478
|
sequence: presentation.sequence,
|
|
470
479
|
...(terminal.summary ? { summary: terminal.summary } : {}),
|
|
471
480
|
...(terminal.error ? { error: terminal.error } : {}),
|
|
472
|
-
...(
|
|
473
|
-
|
|
474
|
-
|
|
481
|
+
...(verification ? { verification } : {}),
|
|
482
|
+
...(receipt?.result.artifactRef ? { artifactRef: receipt.result.artifactRef } : {}),
|
|
483
|
+
...(receipt?.result.outputBytes !== undefined
|
|
484
|
+
? { outputBytes: receipt.result.outputBytes }
|
|
485
|
+
: presentation.content
|
|
486
|
+
? { outputBytes: Buffer.byteLength(presentation.content, 'utf8') }
|
|
487
|
+
: {}),
|
|
475
488
|
...(receipt
|
|
476
489
|
? {
|
|
477
490
|
authorization: projectToolAuthorization(receipt),
|
|
@@ -486,11 +499,16 @@ class ThreadUiAdapterV1 {
|
|
|
486
499
|
entry: {
|
|
487
500
|
...(0, tool_transcript_entry_1.toolTranscriptEntry)({
|
|
488
501
|
callId: presentation.itemId,
|
|
502
|
+
turnId: event.turnId,
|
|
489
503
|
sequence: presentation.sequence,
|
|
490
504
|
name: presentation.name,
|
|
491
505
|
success,
|
|
492
506
|
command: presentation.command,
|
|
493
|
-
output:
|
|
507
|
+
output: verificationNote
|
|
508
|
+
? [output, verificationNote].filter(Boolean).join('\n')
|
|
509
|
+
: output,
|
|
510
|
+
historyOutput: receipt?.result.output || output,
|
|
511
|
+
artifactRef: receipt?.result.artifactRef,
|
|
494
512
|
}),
|
|
495
513
|
live: false,
|
|
496
514
|
},
|
|
@@ -55,6 +55,7 @@ export interface SandboxServiceV1 {
|
|
|
55
55
|
readonly snapshot: StepSnapshotV1;
|
|
56
56
|
readonly descriptor: ToolBindingDescriptorV1;
|
|
57
57
|
readonly args: Readonly<Record<string, unknown>>;
|
|
58
|
+
readonly context?: ToolContext;
|
|
58
59
|
readonly abortSignal?: AbortSignal;
|
|
59
60
|
}): Promise<SandboxPreparationV1> | SandboxPreparationV1;
|
|
60
61
|
}
|
|
@@ -1,16 +1,23 @@
|
|
|
1
1
|
import type { TranscriptAppendEntry } from './ui-events';
|
|
2
|
+
export declare const MAX_TOOL_TRANSCRIPT_OUTPUT_BYTES: number;
|
|
2
3
|
/** Bounded display text only. Credential-bearing invocations retain the tool name. */
|
|
3
4
|
export declare function toolCommandForDisplay(command: unknown): string | undefined;
|
|
4
5
|
/** Read the optional display label in a durable intent; older records have none. */
|
|
5
6
|
export declare function toolCommandFromIntent(intent: string | undefined): string | undefined;
|
|
6
7
|
export declare function isToolTranscriptItem(kind: string): boolean;
|
|
7
|
-
/** A
|
|
8
|
+
/** A compact chat row with a separate, bounded source for expanded history. */
|
|
8
9
|
export declare function toolTranscriptEntry(input: {
|
|
9
10
|
callId: string;
|
|
11
|
+
turnId?: string;
|
|
10
12
|
sequence: number;
|
|
11
13
|
name: string;
|
|
12
14
|
success: boolean;
|
|
13
15
|
command?: string;
|
|
14
16
|
output?: string;
|
|
17
|
+
historyOutput?: string;
|
|
18
|
+
artifactRef?: {
|
|
19
|
+
id: string;
|
|
20
|
+
outputBytes: number;
|
|
21
|
+
};
|
|
15
22
|
}): TranscriptAppendEntry;
|
|
16
23
|
//# sourceMappingURL=tool-transcript-entry.d.ts.map
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.MAX_TOOL_TRANSCRIPT_OUTPUT_BYTES = void 0;
|
|
3
4
|
exports.toolCommandForDisplay = toolCommandForDisplay;
|
|
4
5
|
exports.toolCommandFromIntent = toolCommandFromIntent;
|
|
5
6
|
exports.isToolTranscriptItem = isToolTranscriptItem;
|
|
@@ -7,6 +8,8 @@ exports.toolTranscriptEntry = toolTranscriptEntry;
|
|
|
7
8
|
const redaction_1 = require("../services/redaction");
|
|
8
9
|
const style_1 = require("../tui-core/style");
|
|
9
10
|
const SENSITIVE_COMMAND_ARGUMENT = /(?:^|\s)--(?:password|passphrase|token|api[-_]?key|secret|authorization|cookie|credentials?)(?:[=\s]|$)/iu;
|
|
11
|
+
exports.MAX_TOOL_TRANSCRIPT_OUTPUT_BYTES = 64 * 1024;
|
|
12
|
+
const TRANSCRIPT_OMISSION = '\n… tool output omitted …\n';
|
|
10
13
|
/** Bounded display text only. Credential-bearing invocations retain the tool name. */
|
|
11
14
|
function toolCommandForDisplay(command) {
|
|
12
15
|
if (typeof command !== 'string')
|
|
@@ -37,17 +40,20 @@ function toolCommandFromIntent(intent) {
|
|
|
37
40
|
function isToolTranscriptItem(kind) {
|
|
38
41
|
return kind === 'command' || kind === 'file_change' || kind === 'mcp';
|
|
39
42
|
}
|
|
40
|
-
/** A
|
|
43
|
+
/** A compact chat row with a separate, bounded source for expanded history. */
|
|
41
44
|
function toolTranscriptEntry(input) {
|
|
42
45
|
const name = /^[A-Za-z0-9_.:/-]{1,120}$/u.test(input.name) ? input.name : 'tool';
|
|
43
46
|
const command = toolCommandForDisplay(input.command);
|
|
44
|
-
const
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
:
|
|
47
|
+
const displayOutput = input.command === undefined || command !== undefined;
|
|
48
|
+
const compactOutput = command && input.output ? sanitizeToolOutput(input.output) : '';
|
|
49
|
+
const history = displayOutput ? (input.historyOutput ?? input.output) : undefined;
|
|
50
|
+
const transcriptOutput = history
|
|
51
|
+
? boundToolTranscriptOutput(command && history === input.output ? compactOutput : sanitizeToolOutput(history))
|
|
52
|
+
: undefined;
|
|
49
53
|
// Prefer the final lines, where test runners usually print their verdict.
|
|
50
|
-
const body =
|
|
54
|
+
const body = compactOutput
|
|
55
|
+
.split('\n')
|
|
56
|
+
.filter(line => line.trim())
|
|
51
57
|
.slice(-2)
|
|
52
58
|
.map(line => clipDisplayText(line, 120))
|
|
53
59
|
.join('\n');
|
|
@@ -61,11 +67,33 @@ function toolTranscriptEntry(input) {
|
|
|
61
67
|
detail: '',
|
|
62
68
|
...(command ? { command } : {}),
|
|
63
69
|
body,
|
|
70
|
+
...(transcriptOutput ? { transcriptOutput } : {}),
|
|
71
|
+
...(displayOutput && input.artifactRef ? { artifactRef: { ...input.artifactRef } } : {}),
|
|
64
72
|
callId: input.callId,
|
|
73
|
+
...(input.turnId ? { turnId: input.turnId } : {}),
|
|
65
74
|
seq: input.sequence,
|
|
66
75
|
},
|
|
67
76
|
};
|
|
68
77
|
}
|
|
78
|
+
function sanitizeToolOutput(text) {
|
|
79
|
+
return (0, redaction_1.redactTraceText)((0, style_1.sanitizeTerminalText)(text));
|
|
80
|
+
}
|
|
81
|
+
function boundToolTranscriptOutput(text) {
|
|
82
|
+
if (Buffer.byteLength(text, 'utf8') <= exports.MAX_TOOL_TRANSCRIPT_OUTPUT_BYTES)
|
|
83
|
+
return text;
|
|
84
|
+
const output = Buffer.from(text, 'utf8');
|
|
85
|
+
const bodyBudget = exports.MAX_TOOL_TRANSCRIPT_OUTPUT_BYTES - Buffer.byteLength(TRANSCRIPT_OMISSION);
|
|
86
|
+
let headEnd = Math.floor(bodyBudget / 2);
|
|
87
|
+
let tailStart = output.length - (bodyBudget - headEnd);
|
|
88
|
+
// Both ends must land before the lead byte of a complete UTF-8 character.
|
|
89
|
+
while ((output[headEnd] & 0xc0) === 0x80)
|
|
90
|
+
headEnd -= 1;
|
|
91
|
+
while ((output[tailStart] & 0xc0) === 0x80)
|
|
92
|
+
tailStart += 1;
|
|
93
|
+
return (output.subarray(0, headEnd).toString('utf8') +
|
|
94
|
+
TRANSCRIPT_OMISSION +
|
|
95
|
+
output.subarray(tailStart).toString('utf8'));
|
|
96
|
+
}
|
|
69
97
|
function clipDisplayText(text, limit) {
|
|
70
98
|
const characters = [...text];
|
|
71
99
|
return characters.length > limit ? `${characters.slice(0, limit - 1).join('')}…` : text;
|
|
@@ -14,6 +14,7 @@ import type { GoalRuntimeEvent } from './goals/types';
|
|
|
14
14
|
import type { McpServerDescriptorInputV1 } from './mcp';
|
|
15
15
|
import type { SkillDescriptorV1 } from './skills';
|
|
16
16
|
import type { ToolExternalAssertion } from '../framework/external-assertion';
|
|
17
|
+
import type { VerificationToolStatus } from '../framework/verification-command';
|
|
17
18
|
import type { EffortLevel, EffortPreference, EffortScope } from '../services/effort';
|
|
18
19
|
import type { AgentRuntimeRunnerV1 } from './agent-runtime-runner';
|
|
19
20
|
import type { FirstPartyApprovalHandlerV1 } from './first-party-tool-services';
|
|
@@ -56,6 +57,13 @@ export interface StructuredToolActivity {
|
|
|
56
57
|
outputBytes?: number;
|
|
57
58
|
/** Structured display body. When present, TUI ignores legacy TranscriptEntry.content. */
|
|
58
59
|
body?: string;
|
|
60
|
+
/** Bounded, terminal-safe output for the expanded transcript view. */
|
|
61
|
+
transcriptOutput?: string;
|
|
62
|
+
/** Project-local sanitized artifact, obtained from a validated durable receipt. */
|
|
63
|
+
artifactRef?: {
|
|
64
|
+
id: string;
|
|
65
|
+
outputBytes: number;
|
|
66
|
+
};
|
|
59
67
|
error?: string;
|
|
60
68
|
seq?: number;
|
|
61
69
|
artifactHint?: string;
|
|
@@ -213,6 +221,8 @@ export interface RuntimeToolFinishedEvent {
|
|
|
213
221
|
};
|
|
214
222
|
/** Runtime-produced external assertion; never inferred from display text. */
|
|
215
223
|
externalAssertion?: ToolExternalAssertion;
|
|
224
|
+
/** Verification status from the validated command receipt. */
|
|
225
|
+
verification?: VerificationToolStatus;
|
|
216
226
|
/** Authorization provenance carried to every renderer and protocol consumer. */
|
|
217
227
|
authorization?: ToolAuthorizationView;
|
|
218
228
|
/** Exact ExecutionPolicy digest embedded in the validated durable ToolInvocationReceipt. */
|
|
@@ -0,0 +1,4 @@
|
|
|
1
|
+
import { type VerificationToolFeedback } from '../framework/verification-command';
|
|
2
|
+
/** Describe an identifiable check whose Shell composition hides its individual exit status. */
|
|
3
|
+
export declare function describeCompoundVerification(command: string, args: Readonly<Record<string, unknown>>): VerificationToolFeedback | undefined;
|
|
4
|
+
//# sourceMappingURL=verification-feedback.d.ts.map
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.describeCompoundVerification = describeCompoundVerification;
|
|
4
|
+
const verification_command_1 = require("../framework/verification-command");
|
|
5
|
+
const redaction_1 = require("../services/redaction");
|
|
6
|
+
const shell_command_1 = require("../utils/shell-command");
|
|
7
|
+
const displayCommand = /^(?:head|tail)(?:[ \t]+-(?:[0-9]+|n[ \t]*[0-9]+))?$/u;
|
|
8
|
+
const retryOutputLimit = 4096;
|
|
9
|
+
/** Describe an identifiable check whose Shell composition hides its individual exit status. */
|
|
10
|
+
function describeCompoundVerification(command, args) {
|
|
11
|
+
if (!verification_command_1.SHELL_CONTROL_OPERATOR.test(command))
|
|
12
|
+
return;
|
|
13
|
+
const operators = [];
|
|
14
|
+
const scan = (0, shell_command_1.scanShellCommand)(command, operator => operators.push(operator));
|
|
15
|
+
if (!operators.length)
|
|
16
|
+
return;
|
|
17
|
+
const commands = scan.segments.map(segment => segment.replace(/[ \t]+2>&1$/u, ''));
|
|
18
|
+
const kind = commands.map(verification_command_1.identifyVerificationRunner).find(check => check !== undefined);
|
|
19
|
+
if (!kind)
|
|
20
|
+
return;
|
|
21
|
+
const pipe = operators.includes('|');
|
|
22
|
+
const retryCommand = scan.supported &&
|
|
23
|
+
!scan.writesFile &&
|
|
24
|
+
operators.length === 1 &&
|
|
25
|
+
operators[0] === '|' &&
|
|
26
|
+
commands.length === 2 &&
|
|
27
|
+
(0, verification_command_1.classifyDirectVerificationCommand)(commands[0]) === kind &&
|
|
28
|
+
displayCommand.test(commands[1]) &&
|
|
29
|
+
!scan.segments[0].includes('\\') &&
|
|
30
|
+
!/[<>&]/u.test(commands[0])
|
|
31
|
+
? commands[0]
|
|
32
|
+
: undefined;
|
|
33
|
+
const cwd = typeof args.cwd === 'string' ? args.cwd : '.';
|
|
34
|
+
const maxOutput = typeof args.maxOutput === 'number' && args.maxOutput >= 1024
|
|
35
|
+
? Math.min(args.maxOutput, retryOutputLimit)
|
|
36
|
+
: retryOutputLimit;
|
|
37
|
+
const retryArgs = retryCommand
|
|
38
|
+
? {
|
|
39
|
+
command: retryCommand,
|
|
40
|
+
cwd,
|
|
41
|
+
maxOutput,
|
|
42
|
+
...(typeof args.timeout === 'number' ? { timeout: args.timeout } : {}),
|
|
43
|
+
}
|
|
44
|
+
: undefined;
|
|
45
|
+
const retry = retryArgs &&
|
|
46
|
+
(0, redaction_1.redactTraceText)(retryArgs.command) === retryArgs.command &&
|
|
47
|
+
(0, redaction_1.redactTraceText)(cwd) === cwd &&
|
|
48
|
+
Buffer.byteLength(JSON.stringify(retryArgs), 'utf8') <= 768
|
|
49
|
+
? { tool: 'exec_command', args: retryArgs }
|
|
50
|
+
: undefined;
|
|
51
|
+
return {
|
|
52
|
+
kind,
|
|
53
|
+
status: 'unverified',
|
|
54
|
+
reason: pipe ? 'shell_pipeline' : 'compound_shell',
|
|
55
|
+
message: pipe
|
|
56
|
+
? 'The shell status can come from the final pipeline command. This execution supplied no verification receipt.'
|
|
57
|
+
: 'The compound shell status does not establish the individual check result. No verification receipt was recorded.',
|
|
58
|
+
...(retry ? { retry } : {}),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
//# sourceMappingURL=verification-feedback.js.map
|
|
@@ -56,7 +56,7 @@ export type TuiThemePreference = 'orion-pixel' | 'classic' | 'high-contrast' | '
|
|
|
56
56
|
export type TuiMotionPreference = 'full' | 'reduced' | 'off';
|
|
57
57
|
export type TuiStatusItem = 'mode' | 'goal' | 'model' | 'effort' | 'context' | 'queue' | 'activity';
|
|
58
58
|
/** Semantic keymap actions. Raw escape sequences are deliberately unsupported. */
|
|
59
|
-
export type TuiKeymapAction = 'submit' | 'queue' | 'interrupt' | 'history-search' | 'external-editor' | 'transcript' | 'redraw' | 'exit';
|
|
59
|
+
export type TuiKeymapAction = 'submit' | 'queue' | 'interrupt' | 'history-search' | 'external-editor' | 'transcript' | 'copy' | 'redraw' | 'exit';
|
|
60
60
|
/** UI configuration that is safe to persist globally. */
|
|
61
61
|
export interface UIConfig {
|
|
62
62
|
/** Runtime-only renderer override; rejected in persisted orion.yaml. */
|
|
@@ -508,6 +508,7 @@ const TUI_KEYMAP_ACTIONS = new Set([
|
|
|
508
508
|
'history-search',
|
|
509
509
|
'external-editor',
|
|
510
510
|
'transcript',
|
|
511
|
+
'copy',
|
|
511
512
|
'redraw',
|
|
512
513
|
'exit',
|
|
513
514
|
]);
|
|
@@ -521,6 +522,7 @@ const TUI_KEY_BINDINGS = new Set([
|
|
|
521
522
|
'ctrl+l',
|
|
522
523
|
'ctrl+o',
|
|
523
524
|
'ctrl+r',
|
|
525
|
+
'ctrl+t',
|
|
524
526
|
]);
|
|
525
527
|
function sanitizeUiConfig(value) {
|
|
526
528
|
if (!value || typeof value !== 'object' || Array.isArray(value))
|
package/dist/services/llm.d.ts
CHANGED
|
@@ -185,8 +185,10 @@ export interface StreamCallbacks {
|
|
|
185
185
|
*/
|
|
186
186
|
onThinkingText?: StreamCallback;
|
|
187
187
|
}
|
|
188
|
+
export type StructuredOutputSchema = boolean | Readonly<Record<string, unknown>>;
|
|
188
189
|
export interface StreamOptions {
|
|
189
190
|
abortSignal?: AbortSignal;
|
|
191
|
+
outputSchema?: StructuredOutputSchema;
|
|
190
192
|
}
|
|
191
193
|
export interface ProviderRequestPreflightContext {
|
|
192
194
|
operation: 'chat' | 'chat_stream';
|
|
@@ -212,6 +214,7 @@ export declare class LLMService {
|
|
|
212
214
|
private consecutive529Errors;
|
|
213
215
|
private usingFallback;
|
|
214
216
|
private lastRequestDiagnostics;
|
|
217
|
+
private readonly structuredOutputFallbackRoutes;
|
|
215
218
|
private usageObservers;
|
|
216
219
|
private providerRequestPreflight?;
|
|
217
220
|
private effortContext;
|