@orion-agents/orion-code 0.4.8 → 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 +8 -0
- package/README.md +5 -5
- package/README.zh-CN.md +5 -5
- 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 +3 -1
- package/dist/framework/query.js +18 -3
- 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/harness/ledger.js +2 -1
- 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 +20 -8
- 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/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 +1 -0
- 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 +1 -0
- 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 +4 -1
- package/dist/runtime/subagents/presets.d.ts +1 -1
- package/dist/runtime/subagents/presets.js +1 -0
- package/dist/runtime/task-context-recovery.js +7 -0
- 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 +14 -8
- 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 +7 -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/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/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/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
|
@@ -1,74 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* v0.2.23 — TUI Input Ownership Controller.
|
|
4
|
-
*
|
|
5
|
-
* Manages capture/restore of prompt state across modal interactions
|
|
6
|
-
* (Inspector, session picker, permission prompt, history search).
|
|
7
|
-
* All modal paths restore the prior input state in finally.
|
|
8
|
-
*/
|
|
9
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
10
|
-
exports.TuiInputOwnershipController = void 0;
|
|
11
|
-
// ============================================================================
|
|
12
|
-
// Controller
|
|
13
|
-
// ============================================================================
|
|
14
|
-
class TuiInputOwnershipController {
|
|
15
|
-
constructor() {
|
|
16
|
-
this.state = {
|
|
17
|
-
current: 'prompt',
|
|
18
|
-
previous: null,
|
|
19
|
-
snapshot: null,
|
|
20
|
-
};
|
|
21
|
-
}
|
|
22
|
-
/** Current input owner. */
|
|
23
|
-
get owner() {
|
|
24
|
-
return this.state.current;
|
|
25
|
-
}
|
|
26
|
-
/** True when a modal interaction is active. */
|
|
27
|
-
get isModal() {
|
|
28
|
-
return this.state.current !== 'prompt';
|
|
29
|
-
}
|
|
30
|
-
/**
|
|
31
|
-
* Capture the current prompt state and activate a modal owner.
|
|
32
|
-
* If already in a modal, this is a no-op (no nesting).
|
|
33
|
-
*/
|
|
34
|
-
capture(owner, snapshot) {
|
|
35
|
-
if (this.state.current === owner)
|
|
36
|
-
return;
|
|
37
|
-
if (this.state.current !== 'prompt')
|
|
38
|
-
return; // Don't nest modals.
|
|
39
|
-
this.state = {
|
|
40
|
-
current: owner,
|
|
41
|
-
previous: 'prompt',
|
|
42
|
-
snapshot,
|
|
43
|
-
};
|
|
44
|
-
}
|
|
45
|
-
/**
|
|
46
|
-
* Restore the previous owner and return the saved snapshot.
|
|
47
|
-
* Idempotent: calling restore when owner is 'prompt' is a safe no-op.
|
|
48
|
-
*/
|
|
49
|
-
restore() {
|
|
50
|
-
if (this.state.current === 'prompt')
|
|
51
|
-
return null;
|
|
52
|
-
const snapshot = this.state.snapshot;
|
|
53
|
-
this.state = {
|
|
54
|
-
current: 'prompt',
|
|
55
|
-
previous: null,
|
|
56
|
-
snapshot: null,
|
|
57
|
-
};
|
|
58
|
-
return snapshot;
|
|
59
|
-
}
|
|
60
|
-
/** Check if a given key/action should be routed to the current owner. */
|
|
61
|
-
routesToOwner(owner) {
|
|
62
|
-
return this.state.current === owner;
|
|
63
|
-
}
|
|
64
|
-
/** Reset to default prompt owner (for error recovery). */
|
|
65
|
-
reset() {
|
|
66
|
-
this.state = {
|
|
67
|
-
current: 'prompt',
|
|
68
|
-
previous: null,
|
|
69
|
-
snapshot: null,
|
|
70
|
-
};
|
|
71
|
-
}
|
|
72
|
-
}
|
|
73
|
-
exports.TuiInputOwnershipController = TuiInputOwnershipController;
|
|
74
|
-
//# sourceMappingURL=input-ownership.js.map
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { type TuiFrame } from '../tui-core/frame';
|
|
2
|
-
import { type TuiTheme } from '../tui-core/style';
|
|
3
|
-
import type { ToolInspectorViewModel } from './transcript-inspector';
|
|
4
|
-
export declare function renderTranscriptInspectorFrame(view: ToolInspectorViewModel, options: {
|
|
5
|
-
width: number;
|
|
6
|
-
height: number;
|
|
7
|
-
theme?: TuiTheme;
|
|
8
|
-
}): TuiFrame;
|
|
9
|
-
//# sourceMappingURL=transcript-inspector-layout.d.ts.map
|
|
@@ -1,107 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
3
|
-
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
4
|
-
};
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.renderTranscriptInspectorFrame = renderTranscriptInspectorFrame;
|
|
7
|
-
const frame_1 = require("../tui-core/frame");
|
|
8
|
-
const style_1 = require("../tui-core/style");
|
|
9
|
-
const grapheme_1 = require("../runtime/composer/grapheme");
|
|
10
|
-
const string_width_1 = __importDefault(require("string-width"));
|
|
11
|
-
const theme_1 = require("./theme");
|
|
12
|
-
function renderTranscriptInspectorFrame(view, options) {
|
|
13
|
-
const frame = (0, frame_1.createTuiFrame)(options.width, options.height);
|
|
14
|
-
const theme = (0, theme_1.resolveTuiTheme)(options.theme);
|
|
15
|
-
const width = frame.width;
|
|
16
|
-
const height = frame.height;
|
|
17
|
-
(0, frame_1.writeFrameText)(frame, 0, 0, ' Orion Code Tool Inspector', theme.heading);
|
|
18
|
-
const search = view.searchQuery
|
|
19
|
-
? `search: ${sanitizeInlineIdentifier(view.searchQuery)}`
|
|
20
|
-
: `${view.entries.length} tools`;
|
|
21
|
-
(0, frame_1.writeFrameText)(frame, 1, 1, search, theme.toolMeta);
|
|
22
|
-
if (width < 60) {
|
|
23
|
-
const listRows = Math.max(2, Math.min(6, Math.floor((height - 4) / 3)));
|
|
24
|
-
renderList(frame, view, 2, listRows, width, theme);
|
|
25
|
-
renderDetail(frame, view, 2 + listRows, Math.max(0, height - listRows - 3), 0, width, theme);
|
|
26
|
-
}
|
|
27
|
-
else {
|
|
28
|
-
const listWidth = Math.max(24, Math.min(42, Math.floor(width * 0.36)));
|
|
29
|
-
renderList(frame, view, 2, Math.max(0, height - 3), listWidth, theme);
|
|
30
|
-
renderDetail(frame, view, 2, Math.max(0, height - 3), listWidth + 1, width - listWidth - 1, theme);
|
|
31
|
-
}
|
|
32
|
-
const footer = width < 40
|
|
33
|
-
? ' q exit j/k ↵ detail'
|
|
34
|
-
: ' q exit j/k select Enter/Space expand / search Ctrl+E all [ export v editor';
|
|
35
|
-
(0, frame_1.writeFrameText)(frame, height - 1, 0, footer, theme.statusText);
|
|
36
|
-
(0, frame_1.setFrameCursor)(frame, height - 1, Math.min(width - 1, footer.length), false);
|
|
37
|
-
return frame;
|
|
38
|
-
}
|
|
39
|
-
function renderList(frame, view, top, maxRows, width, theme) {
|
|
40
|
-
if (view.entries.length === 0) {
|
|
41
|
-
(0, frame_1.writeFrameText)(frame, top, 1, 'No tool output recorded.', theme.toolMeta);
|
|
42
|
-
return;
|
|
43
|
-
}
|
|
44
|
-
const start = Math.max(0, Math.min(view.selectedIndex, view.entries.length - maxRows));
|
|
45
|
-
for (let row = 0; row < maxRows && start + row < view.entries.length; row += 1) {
|
|
46
|
-
const index = start + row;
|
|
47
|
-
const entry = view.entries[index];
|
|
48
|
-
const selected = index === view.selectedIndex;
|
|
49
|
-
const marker = entry.state === 'success' ? '✓' : entry.state === 'error' ? '✗' : '-';
|
|
50
|
-
const text = `${selected ? '›' : ' '} ${marker} #${entry.sequence} ${sanitizeInlineIdentifier(entry.toolName)}`;
|
|
51
|
-
(0, frame_1.writeFrameText)(frame, top + row, 0, truncateWidth(text, Math.max(1, width - 1)), selected
|
|
52
|
-
? { ...theme.toolName, inverse: true }
|
|
53
|
-
: entry.state === 'error'
|
|
54
|
-
? theme.toolError
|
|
55
|
-
: theme.toolMeta);
|
|
56
|
-
}
|
|
57
|
-
}
|
|
58
|
-
function renderDetail(frame, view, top, maxRows, left, width, theme) {
|
|
59
|
-
if (maxRows <= 0 || width <= 0)
|
|
60
|
-
return;
|
|
61
|
-
const entry = view.selected;
|
|
62
|
-
if (!entry)
|
|
63
|
-
return;
|
|
64
|
-
const heading = ` ${sanitizeInlineIdentifier(entry.toolName)} · ${entry.artifactId ? formatBytes(entry.outputBytes) : 'summary only'}`;
|
|
65
|
-
(0, frame_1.writeFrameText)(frame, top, left, heading, theme.toolName);
|
|
66
|
-
const expanded = view.expandedCallIds.includes(entry.callId);
|
|
67
|
-
const detail = view.detail;
|
|
68
|
-
const body = !expanded
|
|
69
|
-
? (entry.summary ??
|
|
70
|
-
(entry.artifactId ? 'Press Enter to expand detail.' : 'Full output unavailable.'))
|
|
71
|
-
: detail?.loading
|
|
72
|
-
? 'Loading detail...'
|
|
73
|
-
: detail?.error
|
|
74
|
-
? `Detail error: ${detail.error}`
|
|
75
|
-
: (detail?.content ?? entry.summary ?? 'Press Enter to load detail.');
|
|
76
|
-
const lines = (0, style_1.sanitizeTerminalText)(body).split('\n');
|
|
77
|
-
const detailOffset = expanded ? Math.max(0, view.detailOffset) : 0;
|
|
78
|
-
for (let index = 0; index < maxRows - 1 && detailOffset + index < lines.length; index += 1) {
|
|
79
|
-
(0, frame_1.writeFrameText)(frame, top + 1 + index, left + 1, truncateWidth(lines[detailOffset + index], Math.max(1, width - 2)), theme.toolMeta);
|
|
80
|
-
}
|
|
81
|
-
if (expanded && detail?.nextOffsetBytes !== undefined && maxRows > 1) {
|
|
82
|
-
(0, frame_1.writeFrameText)(frame, top + maxRows - 1, left + 1, 'More available · PageDown', theme.warning);
|
|
83
|
-
}
|
|
84
|
-
}
|
|
85
|
-
function formatBytes(bytes) {
|
|
86
|
-
if (bytes < 1024)
|
|
87
|
-
return `${bytes} B`;
|
|
88
|
-
if (bytes < 1024 * 1024)
|
|
89
|
-
return `${(bytes / 1024).toFixed(1)} KB`;
|
|
90
|
-
return `${(bytes / (1024 * 1024)).toFixed(1)} MB`;
|
|
91
|
-
}
|
|
92
|
-
function sanitizeInlineIdentifier(value) {
|
|
93
|
-
return (0, style_1.sanitizeTerminalText)(value, 2).replace(/\s+/gu, ' ').trim();
|
|
94
|
-
}
|
|
95
|
-
function truncateWidth(value, maxWidth) {
|
|
96
|
-
let output = '';
|
|
97
|
-
let width = 0;
|
|
98
|
-
for (const grapheme of (0, grapheme_1.segmentGraphemes)(value)) {
|
|
99
|
-
const nextWidth = (0, string_width_1.default)(grapheme.segment);
|
|
100
|
-
if (width + nextWidth > maxWidth)
|
|
101
|
-
break;
|
|
102
|
-
output += grapheme.segment;
|
|
103
|
-
width += nextWidth;
|
|
104
|
-
}
|
|
105
|
-
return output;
|
|
106
|
-
}
|
|
107
|
-
//# sourceMappingURL=transcript-inspector-layout.js.map
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { type TuiFrame } from '../tui-core/frame';
|
|
2
|
-
import type { SurfaceOutput } from './inline-surface';
|
|
3
|
-
/** Temporary alternate-screen surface used only while Ctrl+O Inspector is open. */
|
|
4
|
-
export declare class TranscriptInspectorSurface {
|
|
5
|
-
private readonly output;
|
|
6
|
-
private mounted;
|
|
7
|
-
private chain;
|
|
8
|
-
private readonly suppressColor;
|
|
9
|
-
constructor(output: SurfaceOutput);
|
|
10
|
-
mount(frame: TuiFrame): Promise<void>;
|
|
11
|
-
paint(frame: TuiFrame): Promise<void>;
|
|
12
|
-
unmount(): Promise<void>;
|
|
13
|
-
get isMounted(): boolean;
|
|
14
|
-
private render;
|
|
15
|
-
private enqueue;
|
|
16
|
-
private writeRaw;
|
|
17
|
-
}
|
|
18
|
-
//# sourceMappingURL=transcript-inspector-surface.d.ts.map
|
|
@@ -1,91 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TranscriptInspectorSurface = void 0;
|
|
4
|
-
const frame_1 = require("../tui-core/frame");
|
|
5
|
-
const style_1 = require("../tui-core/style");
|
|
6
|
-
const ENTER_ALTERNATE_SCREEN = '\x1b[?1049h';
|
|
7
|
-
const EXIT_ALTERNATE_SCREEN = '\x1b[?1049l';
|
|
8
|
-
const HOME = '\x1b[H';
|
|
9
|
-
const CLEAR = '\x1b[2J';
|
|
10
|
-
const HIDE_CURSOR = '\x1b[?25l';
|
|
11
|
-
const SHOW_CURSOR = '\x1b[?25h';
|
|
12
|
-
/** Temporary alternate-screen surface used only while Ctrl+O Inspector is open. */
|
|
13
|
-
class TranscriptInspectorSurface {
|
|
14
|
-
constructor(output) {
|
|
15
|
-
this.output = output;
|
|
16
|
-
this.mounted = false;
|
|
17
|
-
this.chain = Promise.resolve();
|
|
18
|
-
this.suppressColor = (0, style_1.shouldSuppressColor)();
|
|
19
|
-
}
|
|
20
|
-
mount(frame) {
|
|
21
|
-
return this.enqueue(async () => {
|
|
22
|
-
if (!this.mounted) {
|
|
23
|
-
await this.writeRaw(`${ENTER_ALTERNATE_SCREEN}${HIDE_CURSOR}`);
|
|
24
|
-
this.mounted = true;
|
|
25
|
-
}
|
|
26
|
-
await this.writeRaw(this.render(frame));
|
|
27
|
-
});
|
|
28
|
-
}
|
|
29
|
-
paint(frame) {
|
|
30
|
-
if (!this.mounted)
|
|
31
|
-
return this.mount(frame);
|
|
32
|
-
return this.enqueue(() => this.writeRaw(this.render(frame)));
|
|
33
|
-
}
|
|
34
|
-
unmount() {
|
|
35
|
-
return this.enqueue(async () => {
|
|
36
|
-
if (!this.mounted)
|
|
37
|
-
return;
|
|
38
|
-
await this.writeRaw(`${style_1.SGR_RESET}${SHOW_CURSOR}${EXIT_ALTERNATE_SCREEN}`);
|
|
39
|
-
this.mounted = false;
|
|
40
|
-
});
|
|
41
|
-
}
|
|
42
|
-
get isMounted() {
|
|
43
|
-
return this.mounted;
|
|
44
|
-
}
|
|
45
|
-
render(frame) {
|
|
46
|
-
const chunks = [HOME, CLEAR];
|
|
47
|
-
for (let rowIndex = 0; rowIndex < frame.height; rowIndex += 1) {
|
|
48
|
-
const spans = (0, frame_1.renderStyledFrameRow)(frame.rows[rowIndex]);
|
|
49
|
-
for (const span of spans) {
|
|
50
|
-
const sgr = (0, style_1.encodeStyleToSgr)(span.style, this.suppressColor);
|
|
51
|
-
if (sgr)
|
|
52
|
-
chunks.push(sgr);
|
|
53
|
-
chunks.push(span.text, style_1.SGR_RESET);
|
|
54
|
-
}
|
|
55
|
-
if (rowIndex < frame.height - 1)
|
|
56
|
-
chunks.push('\r\n');
|
|
57
|
-
}
|
|
58
|
-
return chunks.join('');
|
|
59
|
-
}
|
|
60
|
-
enqueue(operation) {
|
|
61
|
-
this.chain = this.chain.then(operation, operation);
|
|
62
|
-
return this.chain;
|
|
63
|
-
}
|
|
64
|
-
async writeRaw(chunk) {
|
|
65
|
-
if (this.output.writable === false)
|
|
66
|
-
throw new Error('terminal output is not writable');
|
|
67
|
-
if (this.output.write(chunk) !== false)
|
|
68
|
-
return;
|
|
69
|
-
await new Promise((resolve, reject) => {
|
|
70
|
-
const cleanup = () => {
|
|
71
|
-
this.output.off('drain', onDrain);
|
|
72
|
-
this.output.off('error', onError);
|
|
73
|
-
this.output.off('close', onClose);
|
|
74
|
-
};
|
|
75
|
-
const onDrain = () => {
|
|
76
|
-
cleanup();
|
|
77
|
-
resolve();
|
|
78
|
-
};
|
|
79
|
-
const onError = (error) => {
|
|
80
|
-
cleanup();
|
|
81
|
-
reject(error instanceof Error ? error : new Error(String(error ?? 'terminal output error')));
|
|
82
|
-
};
|
|
83
|
-
const onClose = () => onError(new Error('terminal output closed before drain'));
|
|
84
|
-
this.output.on('drain', onDrain);
|
|
85
|
-
this.output.on('error', onError);
|
|
86
|
-
this.output.on('close', onClose);
|
|
87
|
-
});
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
exports.TranscriptInspectorSurface = TranscriptInspectorSurface;
|
|
91
|
-
//# sourceMappingURL=transcript-inspector-surface.js.map
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import type { ToolDetailRepository, ToolDetailPage } from '../runtime/tool-detail-repository';
|
|
2
|
-
import type { TuiToolDetailSummary, ToolInspectorState } from './state';
|
|
3
|
-
export interface InspectorDetailState {
|
|
4
|
-
content: string;
|
|
5
|
-
nextOffsetBytes?: number;
|
|
6
|
-
totalBytes: number;
|
|
7
|
-
redacted: boolean;
|
|
8
|
-
loading: boolean;
|
|
9
|
-
error?: string;
|
|
10
|
-
}
|
|
11
|
-
export interface ToolInspectorViewModel {
|
|
12
|
-
entries: TuiToolDetailSummary[];
|
|
13
|
-
selectedIndex: number;
|
|
14
|
-
selected?: TuiToolDetailSummary;
|
|
15
|
-
detail?: InspectorDetailState;
|
|
16
|
-
expandedCallIds: string[];
|
|
17
|
-
searchQuery: string;
|
|
18
|
-
detailOffset: number;
|
|
19
|
-
error?: string;
|
|
20
|
-
}
|
|
21
|
-
/** Controller for Inspector filtering and cancellable paged detail reads. */
|
|
22
|
-
export declare class TranscriptInspectorController {
|
|
23
|
-
private readonly repository;
|
|
24
|
-
private readonly projectPath;
|
|
25
|
-
private readonly details;
|
|
26
|
-
private requestGeneration;
|
|
27
|
-
constructor(repository: ToolDetailRepository, projectPath: string);
|
|
28
|
-
view(entries: TuiToolDetailSummary[], inspector: ToolInspectorState): ToolInspectorViewModel;
|
|
29
|
-
load(entry: TuiToolDetailSummary, append?: boolean): Promise<void>;
|
|
30
|
-
/** Stream a complete, redacted detail without retaining it in Inspector state. */
|
|
31
|
-
readPages(entry: TuiToolDetailSummary): AsyncGenerator<ToolDetailPage>;
|
|
32
|
-
writeDetailToFile(entry: TuiToolDetailSummary, filePath: string): Promise<void>;
|
|
33
|
-
cancel(): void;
|
|
34
|
-
reset(): void;
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=transcript-inspector.d.ts.map
|
|
@@ -1,129 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.TranscriptInspectorController = void 0;
|
|
4
|
-
const promises_1 = require("fs/promises");
|
|
5
|
-
const DETAIL_PAGE_BYTES = 64 * 1024;
|
|
6
|
-
/** Controller for Inspector filtering and cancellable paged detail reads. */
|
|
7
|
-
class TranscriptInspectorController {
|
|
8
|
-
constructor(repository, projectPath) {
|
|
9
|
-
this.repository = repository;
|
|
10
|
-
this.projectPath = projectPath;
|
|
11
|
-
this.details = new Map();
|
|
12
|
-
this.requestGeneration = 0;
|
|
13
|
-
}
|
|
14
|
-
view(entries, inspector) {
|
|
15
|
-
const query = inspector.searchQuery.trim().toLowerCase();
|
|
16
|
-
const filtered = query
|
|
17
|
-
? entries.filter(entry => [entry.toolName, entry.callId, entry.summary, this.details.get(entry.callId)?.content]
|
|
18
|
-
.filter(Boolean)
|
|
19
|
-
.some(value => String(value).toLowerCase().includes(query)))
|
|
20
|
-
: entries;
|
|
21
|
-
const selectedIndex = Math.max(0, Math.min(filtered.length - 1, inspector.selectedIndex));
|
|
22
|
-
const selected = filtered[selectedIndex];
|
|
23
|
-
return {
|
|
24
|
-
entries: filtered,
|
|
25
|
-
selectedIndex,
|
|
26
|
-
selected,
|
|
27
|
-
detail: selected ? this.details.get(selected.callId) : undefined,
|
|
28
|
-
expandedCallIds: inspector.expandedCallIds,
|
|
29
|
-
searchQuery: inspector.searchQuery,
|
|
30
|
-
detailOffset: inspector.detailOffset,
|
|
31
|
-
error: inspector.error,
|
|
32
|
-
};
|
|
33
|
-
}
|
|
34
|
-
async load(entry, append = false) {
|
|
35
|
-
const current = this.details.get(entry.callId);
|
|
36
|
-
const offsetBytes = append ? current?.nextOffsetBytes : 0;
|
|
37
|
-
if (append && offsetBytes === undefined)
|
|
38
|
-
return;
|
|
39
|
-
const generation = ++this.requestGeneration;
|
|
40
|
-
this.details.set(entry.callId, {
|
|
41
|
-
content: append ? (current?.content ?? '') : '',
|
|
42
|
-
totalBytes: current?.totalBytes ?? entry.outputBytes,
|
|
43
|
-
nextOffsetBytes: current?.nextOffsetBytes,
|
|
44
|
-
redacted: current?.redacted ?? false,
|
|
45
|
-
loading: true,
|
|
46
|
-
});
|
|
47
|
-
try {
|
|
48
|
-
const page = entry.artifactId
|
|
49
|
-
? await this.repository.read({
|
|
50
|
-
callId: entry.callId,
|
|
51
|
-
sequence: entry.sequence,
|
|
52
|
-
artifactId: entry.artifactId,
|
|
53
|
-
outputBytes: entry.outputBytes,
|
|
54
|
-
}, { offsetBytes: offsetBytes ?? 0, limitBytes: DETAIL_PAGE_BYTES }, this.projectPath)
|
|
55
|
-
: unavailablePage(entry);
|
|
56
|
-
if (generation !== this.requestGeneration)
|
|
57
|
-
return;
|
|
58
|
-
this.details.set(entry.callId, {
|
|
59
|
-
content: append ? `${current?.content ?? ''}${page.content}` : page.content,
|
|
60
|
-
nextOffsetBytes: page.nextOffsetBytes,
|
|
61
|
-
totalBytes: page.totalBytes,
|
|
62
|
-
redacted: Boolean(current?.redacted || page.redacted),
|
|
63
|
-
loading: false,
|
|
64
|
-
});
|
|
65
|
-
}
|
|
66
|
-
catch (error) {
|
|
67
|
-
if (generation !== this.requestGeneration)
|
|
68
|
-
return;
|
|
69
|
-
this.details.set(entry.callId, {
|
|
70
|
-
content: append ? (current?.content ?? '') : '',
|
|
71
|
-
totalBytes: current?.totalBytes ?? entry.outputBytes,
|
|
72
|
-
redacted: current?.redacted ?? false,
|
|
73
|
-
loading: false,
|
|
74
|
-
error: error instanceof Error ? error.message : String(error),
|
|
75
|
-
});
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/** Stream a complete, redacted detail without retaining it in Inspector state. */
|
|
79
|
-
async *readPages(entry) {
|
|
80
|
-
if (!entry.artifactId) {
|
|
81
|
-
yield unavailablePage(entry);
|
|
82
|
-
return;
|
|
83
|
-
}
|
|
84
|
-
let offsetBytes = 0;
|
|
85
|
-
while (true) {
|
|
86
|
-
const page = await this.repository.read({
|
|
87
|
-
callId: entry.callId,
|
|
88
|
-
sequence: entry.sequence,
|
|
89
|
-
artifactId: entry.artifactId,
|
|
90
|
-
outputBytes: entry.outputBytes,
|
|
91
|
-
}, { offsetBytes, limitBytes: DETAIL_PAGE_BYTES }, this.projectPath);
|
|
92
|
-
yield page;
|
|
93
|
-
if (page.nextOffsetBytes === undefined || page.nextOffsetBytes <= offsetBytes)
|
|
94
|
-
return;
|
|
95
|
-
offsetBytes = page.nextOffsetBytes;
|
|
96
|
-
}
|
|
97
|
-
}
|
|
98
|
-
async writeDetailToFile(entry, filePath) {
|
|
99
|
-
const file = await (0, promises_1.open)(filePath, 'w', 0o600);
|
|
100
|
-
try {
|
|
101
|
-
for await (const page of this.readPages(entry)) {
|
|
102
|
-
await file.write(page.content);
|
|
103
|
-
}
|
|
104
|
-
}
|
|
105
|
-
finally {
|
|
106
|
-
await file.close();
|
|
107
|
-
}
|
|
108
|
-
}
|
|
109
|
-
cancel() {
|
|
110
|
-
this.requestGeneration += 1;
|
|
111
|
-
}
|
|
112
|
-
reset() {
|
|
113
|
-
this.cancel();
|
|
114
|
-
this.details.clear();
|
|
115
|
-
}
|
|
116
|
-
}
|
|
117
|
-
exports.TranscriptInspectorController = TranscriptInspectorController;
|
|
118
|
-
function unavailablePage(entry) {
|
|
119
|
-
const content = entry.summary
|
|
120
|
-
? `${entry.summary}\nFull output unavailable.`
|
|
121
|
-
: 'Full output unavailable.';
|
|
122
|
-
return {
|
|
123
|
-
content,
|
|
124
|
-
offsetBytes: 0,
|
|
125
|
-
totalBytes: Buffer.byteLength(content, 'utf8'),
|
|
126
|
-
redacted: false,
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
//# sourceMappingURL=transcript-inspector.js.map
|