@orion-agents/orion-code 0.4.8 → 0.5.0

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.
Files changed (124) hide show
  1. package/CHANGELOG.md +13 -0
  2. package/README.md +5 -5
  3. package/README.zh-CN.md +5 -5
  4. package/dist/acp/sessions.js +1 -1
  5. package/dist/acp/stdio.js +17 -2
  6. package/dist/cli.js +45 -4
  7. package/dist/commands/session-command-handlers.js +8 -3
  8. package/dist/commands/system-commands.js +3 -3
  9. package/dist/commands/types.d.ts +3 -0
  10. package/dist/framework/loop-progress.js +3 -1
  11. package/dist/framework/query.d.ts +3 -1
  12. package/dist/framework/query.js +18 -3
  13. package/dist/framework/tool-serializer.d.ts +12 -0
  14. package/dist/framework/tool-serializer.js +35 -0
  15. package/dist/framework/tool.d.ts +2 -0
  16. package/dist/harness/ledger.js +2 -1
  17. package/dist/print-ui/delivery.d.ts +15 -0
  18. package/dist/print-ui/delivery.js +131 -0
  19. package/dist/print-ui/event-stream.d.ts +6 -1
  20. package/dist/print-ui/event-stream.js +56 -10
  21. package/dist/print-ui/launch.d.ts +5 -0
  22. package/dist/print-ui/launch.js +66 -9
  23. package/dist/runtime/agent-loop.d.ts +3 -1
  24. package/dist/runtime/agent-loop.js +20 -8
  25. package/dist/runtime/agent-runtime-controller.d.ts +4 -1
  26. package/dist/runtime/agent-runtime-controller.js +36 -22
  27. package/dist/runtime/agent-runtime-runner.d.ts +4 -0
  28. package/dist/runtime/agent-runtime-runner.js +9 -0
  29. package/dist/runtime/builtin-tool-provider.js +6 -5
  30. package/dist/runtime/composer/layout.d.ts +1 -1
  31. package/dist/runtime/composer/layout.js +5 -5
  32. package/dist/runtime/core-tools/descriptors.d.ts +1 -1
  33. package/dist/runtime/core-tools/descriptors.js +39 -1
  34. package/dist/runtime/first-party-core-provider.js +1 -0
  35. package/dist/runtime/first-party-tool-services.js +10 -0
  36. package/dist/runtime/goals/evidence.js +2 -0
  37. package/dist/runtime/legacy-thread-materializer.d.ts +7 -0
  38. package/dist/runtime/legacy-thread-materializer.js +32 -6
  39. package/dist/runtime/orion-runtime-v1.d.ts +2 -1
  40. package/dist/runtime/orion-runtime-v1.js +1 -0
  41. package/dist/runtime/product-bootstrap.d.ts +2 -0
  42. package/dist/runtime/product-bootstrap.js +1 -0
  43. package/dist/runtime/product-orion-runtime.d.ts +2 -1
  44. package/dist/runtime/product-orion-runtime.js +1 -0
  45. package/dist/runtime/release-receipts.d.ts +0 -1
  46. package/dist/runtime/release-receipts.js +8 -3
  47. package/dist/runtime/rich-text/layout.d.ts +3 -1
  48. package/dist/runtime/rich-text/layout.js +37 -22
  49. package/dist/runtime/shell-process-sessions.d.ts +41 -0
  50. package/dist/runtime/shell-process-sessions.js +258 -0
  51. package/dist/runtime/step-snapshot.js +4 -1
  52. package/dist/runtime/subagents/presets.d.ts +1 -1
  53. package/dist/runtime/subagents/presets.js +1 -0
  54. package/dist/runtime/task-context-recovery.js +7 -0
  55. package/dist/runtime/thread-event-store.d.ts +3 -0
  56. package/dist/runtime/thread-event-store.js +35 -22
  57. package/dist/runtime/thread-session-index.d.ts +15 -3
  58. package/dist/runtime/thread-session-index.js +152 -45
  59. package/dist/runtime/thread-session-view.js +1 -1
  60. package/dist/runtime/thread-ui-adapter.d.ts +1 -1
  61. package/dist/runtime/thread-ui-adapter.js +14 -8
  62. package/dist/runtime/tool-gateway.d.ts +1 -0
  63. package/dist/runtime/tool-gateway.js +1 -0
  64. package/dist/runtime/tool-transcript-entry.d.ts +8 -1
  65. package/dist/runtime/tool-transcript-entry.js +35 -7
  66. package/dist/runtime/ui-events.d.ts +7 -0
  67. package/dist/services/global-config.d.ts +1 -1
  68. package/dist/services/global-config.js +2 -0
  69. package/dist/services/llm.d.ts +3 -0
  70. package/dist/services/llm.js +48 -4
  71. package/dist/terminal-ui/raw-editor.js +2 -1
  72. package/dist/tools/core/exec-command.js +51 -42
  73. package/dist/tools/core/index.d.ts +2 -1
  74. package/dist/tools/core/index.js +4 -1
  75. package/dist/tools/core/process-session.d.ts +2 -0
  76. package/dist/tools/core/process-session.js +54 -0
  77. package/dist/tui-core/frame.d.ts +2 -0
  78. package/dist/tui-core/frame.js +19 -0
  79. package/dist/tui-core/input-parser.d.ts +4 -1
  80. package/dist/tui-core/input-parser.js +22 -0
  81. package/dist/tui-ui/chrome-view-model.d.ts +0 -2
  82. package/dist/tui-ui/chrome-view-model.js +54 -56
  83. package/dist/tui-ui/launch.js +133 -202
  84. package/dist/tui-ui/layout.d.ts +16 -41
  85. package/dist/tui-ui/layout.js +408 -295
  86. package/dist/tui-ui/render-scheduler.d.ts +2 -5
  87. package/dist/tui-ui/render-scheduler.js +10 -10
  88. package/dist/tui-ui/response-clipboard.d.ts +17 -0
  89. package/dist/tui-ui/response-clipboard.js +201 -0
  90. package/dist/tui-ui/runner.d.ts +65 -80
  91. package/dist/tui-ui/runner.js +545 -738
  92. package/dist/tui-ui/session-picker-preview.d.ts +8 -0
  93. package/dist/tui-ui/session-picker-preview.js +119 -0
  94. package/dist/tui-ui/session-picker.d.ts +20 -0
  95. package/dist/tui-ui/session-picker.js +42 -0
  96. package/dist/tui-ui/state.d.ts +34 -81
  97. package/dist/tui-ui/state.js +155 -288
  98. package/dist/tui-ui/terminal-image.d.ts +3 -7
  99. package/dist/tui-ui/terminal-image.js +18 -47
  100. package/dist/tui-ui/terminal-viewport.d.ts +55 -0
  101. package/dist/tui-ui/terminal-viewport.js +221 -0
  102. package/dist/tui-ui/transcript-layout.d.ts +5 -0
  103. package/dist/tui-ui/transcript-layout.js +43 -28
  104. package/dist/tui-ui/transcript-pager.d.ts +39 -0
  105. package/dist/tui-ui/transcript-pager.js +278 -0
  106. package/dist/tui-ui/transcript-tool-output.d.ts +16 -0
  107. package/dist/tui-ui/transcript-tool-output.js +102 -0
  108. package/dist/utils/bounded-file.d.ts +4 -0
  109. package/dist/utils/bounded-file.js +30 -0
  110. package/dist/utils/command-process.d.ts +4 -0
  111. package/dist/utils/command-process.js +23 -0
  112. package/docs/cli-guide.md +50 -6
  113. package/npm-shrinkwrap.json +115 -15
  114. package/package.json +4 -1
  115. package/dist/tui-ui/inline-surface.d.ts +0 -191
  116. package/dist/tui-ui/inline-surface.js +0 -644
  117. package/dist/tui-ui/input-ownership.d.ts +0 -46
  118. package/dist/tui-ui/input-ownership.js +0 -74
  119. package/dist/tui-ui/transcript-inspector-layout.d.ts +0 -9
  120. package/dist/tui-ui/transcript-inspector-layout.js +0 -107
  121. package/dist/tui-ui/transcript-inspector-surface.d.ts +0 -18
  122. package/dist/tui-ui/transcript-inspector-surface.js +0 -91
  123. package/dist/tui-ui/transcript-inspector.d.ts +0 -36
  124. package/dist/tui-ui/transcript-inspector.js +0 -129
@@ -2,14 +2,11 @@
2
2
  * TuiRenderScheduler — coalesces redundant renders and caps stream paint rate.
3
3
  *
4
4
  * Priority model:
5
- * - `immediate`: input, permission, cursor, overlay, resize. At most one
5
+ * - `immediate`: input, permission, cursor, overlay. At most one
6
6
  * paint per event-loop tick (multiple immediate requests merge).
7
- * - `stream`: streaming assistant/tool deltas. Capped at ~30 FPS; multiple
7
+ * - `stream`: resize and streaming assistant/tool deltas. Capped at ~30 FPS; multiple
8
8
  * deltas between frames are merged (latest state wins).
9
9
  *
10
- * Commit effects bypass the scheduler entirely; they go through the surface
11
- * FIFO queue. After a commit, an immediate live paint is requested.
12
- *
13
10
  * Timer deps are injectable for fake-timer testing. No real sleeps.
14
11
  */
15
12
  export interface TuiRenderSchedulerDeps {
@@ -3,14 +3,11 @@
3
3
  * TuiRenderScheduler — coalesces redundant renders and caps stream paint rate.
4
4
  *
5
5
  * Priority model:
6
- * - `immediate`: input, permission, cursor, overlay, resize. At most one
6
+ * - `immediate`: input, permission, cursor, overlay. At most one
7
7
  * paint per event-loop tick (multiple immediate requests merge).
8
- * - `stream`: streaming assistant/tool deltas. Capped at ~30 FPS; multiple
8
+ * - `stream`: resize and streaming assistant/tool deltas. Capped at ~30 FPS; multiple
9
9
  * deltas between frames are merged (latest state wins).
10
10
  *
11
- * Commit effects bypass the scheduler entirely; they go through the surface
12
- * FIFO queue. After a commit, an immediate live paint is requested.
13
- *
14
11
  * Timer deps are injectable for fake-timer testing. No real sleeps.
15
12
  */
16
13
  Object.defineProperty(exports, "__esModule", { value: true });
@@ -24,7 +21,7 @@ function createTuiRenderScheduler(paint, deps) {
24
21
  const clearTimeoutFn = deps?.clearTimeout ?? ((timer) => clearTimeout(timer));
25
22
  let pendingImmediate = false;
26
23
  let pendingStreamTimer = null;
27
- let lastStreamPaintTime = 0;
24
+ let lastPaintTime = 0;
28
25
  let stopped = false;
29
26
  const counters = {
30
27
  paintCount: 0,
@@ -34,8 +31,11 @@ function createTuiRenderScheduler(paint, deps) {
34
31
  function doPaint() {
35
32
  counters.paintCount += 1;
36
33
  paint();
34
+ lastPaintTime = now();
37
35
  }
38
36
  function executeImmediate() {
37
+ if (!pendingImmediate || stopped)
38
+ return;
39
39
  pendingImmediate = false;
40
40
  // Cancel any pending stream paint — immediate supersedes it.
41
41
  if (pendingStreamTimer !== null) {
@@ -46,8 +46,8 @@ function createTuiRenderScheduler(paint, deps) {
46
46
  }
47
47
  function executeStream() {
48
48
  pendingStreamTimer = null;
49
- lastStreamPaintTime = now();
50
- doPaint();
49
+ if (!stopped)
50
+ doPaint();
51
51
  }
52
52
  const scheduler = {
53
53
  request(priority) {
@@ -75,10 +75,10 @@ function createTuiRenderScheduler(paint, deps) {
75
75
  counters.coalescedCount += 1;
76
76
  return;
77
77
  }
78
- const elapsed = now() - lastStreamPaintTime;
78
+ const elapsed = now() - lastPaintTime;
79
79
  const remaining = STREAM_FRAME_MS - elapsed;
80
80
  if (remaining <= 0) {
81
- // Enough time has passed; paint on next microtask.
81
+ // Enough time has passed; paint on the next timer tick.
82
82
  pendingStreamTimer = setTimeoutFn(executeStream, 0);
83
83
  }
84
84
  else {
@@ -0,0 +1,17 @@
1
+ interface ClipboardCommand {
2
+ executable: string;
3
+ args: string[];
4
+ input?: string;
5
+ capture?: boolean;
6
+ }
7
+ type RunClipboardCommand = (command: ClipboardCommand, env: NodeJS.ProcessEnv) => Promise<string | undefined>;
8
+ interface ResponseClipboardOptions {
9
+ env: NodeJS.ProcessEnv;
10
+ writeTerminal: (sequence: string) => Promise<void>;
11
+ platform?: NodeJS.Platform;
12
+ runCommand?: RunClipboardCommand;
13
+ }
14
+ /** Copy completed Markdown through the clipboard belonging to this terminal session. */
15
+ export declare function copyResponseToClipboard(markdown: string, options: ResponseClipboardOptions): Promise<void>;
16
+ export {};
17
+ //# sourceMappingURL=response-clipboard.d.ts.map
@@ -0,0 +1,201 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.copyResponseToClipboard = copyResponseToClipboard;
4
+ const node_child_process_1 = require("node:child_process");
5
+ const node_os_1 = require("node:os");
6
+ const marked_1 = require("marked");
7
+ const OSC52_MAX_RAW_BYTES = 100000;
8
+ const MAX_LINK_BYTES = 8 * 1024;
9
+ const COMMAND_TIMEOUT_MS = 3000;
10
+ const MAX_PROBE_OUTPUT_BYTES = 64 * 1024;
11
+ // The reply only travels over stdin. Prepare both formats before touching the pasteboard.
12
+ const APPKIT_COPY_SCRIPT = `
13
+ ObjC.import('AppKit');
14
+ function run() {
15
+ const bytes = $.NSFileHandle.fileHandleWithStandardInput.readDataToEndOfFile;
16
+ const json = $.NSString.alloc.initWithDataEncoding(bytes, $.NSUTF8StringEncoding);
17
+ const formats = JSON.parse(ObjC.unwrap(json));
18
+ const item = $.NSPasteboardItem.alloc.init;
19
+ const wroteText = item.setStringForType($(formats.text), $.NSPasteboardTypeString);
20
+ const wroteHtml = item.setStringForType($(formats.html), $.NSPasteboardTypeHTML);
21
+ if (!wroteText || !wroteHtml) throw new Error('Unable to prepare pasteboard item');
22
+ const board = $.NSPasteboard.generalPasteboard;
23
+ board.clearContents;
24
+ if (!board.writeObjects($.NSArray.arrayWithObject(item))) {
25
+ throw new Error('Unable to update pasteboard');
26
+ }
27
+ }
28
+ `;
29
+ const POWERSHELL_COPY_SCRIPT = [
30
+ "$ErrorActionPreference = 'Stop'",
31
+ '[Console]::InputEncoding = [System.Text.UTF8Encoding]::new($false)',
32
+ 'Set-Clipboard -Value ([Console]::In.ReadToEnd())',
33
+ ].join('; ');
34
+ /** Copy completed Markdown through the clipboard belonging to this terminal session. */
35
+ async function copyResponseToClipboard(markdown, options) {
36
+ if (!markdown)
37
+ throw new Error('No agent response to copy');
38
+ const { env, writeTerminal } = options;
39
+ const run = (command) => (options.runCommand ?? runClipboardCommand)(command, env);
40
+ const ssh = env.SSH_TTY !== undefined || env.SSH_CONNECTION !== undefined;
41
+ if (!ssh &&
42
+ (await copyToNativeClipboard(markdown, options.platform ?? process.platform, env, run))) {
43
+ return;
44
+ }
45
+ if ((env.TMUX !== undefined || env.TMUX_PANE !== undefined) &&
46
+ (await copyWithTmux(markdown, run))) {
47
+ return;
48
+ }
49
+ const rawBytes = Buffer.byteLength(markdown, 'utf8');
50
+ if (rawBytes > OSC52_MAX_RAW_BYTES) {
51
+ throw new Error(`OSC 52 payload too large (${rawBytes} bytes; max ${OSC52_MAX_RAW_BYTES})`);
52
+ }
53
+ const sequence = `\x1b]52;c;${Buffer.from(markdown, 'utf8').toString('base64')}\x07`;
54
+ await writeTerminal(env.TMUX === undefined ? sequence : `\x1bPtmux;\x1b${sequence}\x1b\\`);
55
+ }
56
+ async function copyToNativeClipboard(markdown, platform, env, run) {
57
+ if (platform === 'darwin') {
58
+ // Plain Markdown remains available even if the rich-text renderer or AppKit fails.
59
+ try {
60
+ const html = await renderClipboardHtml(markdown);
61
+ if ((await run({
62
+ executable: '/usr/bin/osascript',
63
+ args: ['-l', 'JavaScript', '-e', APPKIT_COPY_SCRIPT],
64
+ input: JSON.stringify({ text: markdown, html }),
65
+ })) !== undefined) {
66
+ return true;
67
+ }
68
+ }
69
+ catch {
70
+ // Fall back to the system text helper.
71
+ }
72
+ return (await run({ executable: '/usr/bin/pbcopy', args: [], input: markdown })) !== undefined;
73
+ }
74
+ if (platform === 'linux') {
75
+ if (env.WAYLAND_DISPLAY &&
76
+ (await run({
77
+ executable: 'wl-copy',
78
+ args: ['--type', 'text/plain;charset=utf-8'],
79
+ input: markdown,
80
+ })) !== undefined) {
81
+ return true;
82
+ }
83
+ if (env.DISPLAY) {
84
+ if ((await run({
85
+ executable: 'xclip',
86
+ args: ['-selection', 'clipboard', '-in'],
87
+ input: markdown,
88
+ })) !== undefined) {
89
+ return true;
90
+ }
91
+ if ((await run({ executable: 'xsel', args: ['--clipboard', '--input'], input: markdown })) !==
92
+ undefined) {
93
+ return true;
94
+ }
95
+ }
96
+ }
97
+ const wsl = platform === 'linux' &&
98
+ (env.WSL_DISTRO_NAME !== undefined ||
99
+ env.WSL_INTEROP !== undefined ||
100
+ /microsoft/iu.test((0, node_os_1.release)()));
101
+ if (platform === 'win32' || wsl) {
102
+ return ((await run({
103
+ executable: 'powershell.exe',
104
+ args: ['-NoProfile', '-NonInteractive', '-Command', POWERSHELL_COPY_SCRIPT],
105
+ input: markdown,
106
+ })) !== undefined);
107
+ }
108
+ return false;
109
+ }
110
+ async function copyWithTmux(markdown, run) {
111
+ const clipboard = await run({
112
+ executable: 'tmux',
113
+ args: ['show-options', '-gv', 'set-clipboard'],
114
+ capture: true,
115
+ });
116
+ if (clipboard === undefined || clipboard.trim() === 'off')
117
+ return false;
118
+ const info = await run({ executable: 'tmux', args: ['info'], capture: true });
119
+ if (info === undefined || info.includes('Ms: [missing]'))
120
+ return false;
121
+ return ((await run({ executable: 'tmux', args: ['load-buffer', '-w', '-'], input: markdown })) !==
122
+ undefined);
123
+ }
124
+ async function renderClipboardHtml(markdown) {
125
+ const renderer = new marked_1.Renderer();
126
+ renderer.html = escapeHtml;
127
+ // Marked already supplies escaped image alt text. Leave out the remote image itself.
128
+ renderer.image = (_href, _title, alt) => alt;
129
+ renderer.link = (href, _title, text) => {
130
+ let destination;
131
+ try {
132
+ if (Buffer.byteLength(href) <= MAX_LINK_BYTES)
133
+ destination = new URL(href);
134
+ }
135
+ catch {
136
+ // Preserve non-web destinations as visible text below.
137
+ }
138
+ if (destination?.protocol === 'https:' || destination?.protocol === 'http:') {
139
+ return `<a href="${escapeHtml(destination.href)}">${text}</a>`;
140
+ }
141
+ return `${text} (${escapeHtml(href)})`;
142
+ };
143
+ // Keep these HTML rules independent of Marked's process-wide terminal renderer.
144
+ return new marked_1.Marked().parse(markdown, { async: false, gfm: true, renderer });
145
+ }
146
+ function escapeHtml(text) {
147
+ return text.replace(/[&<>"']/gu, char => {
148
+ switch (char) {
149
+ case '&':
150
+ return '&amp;';
151
+ case '<':
152
+ return '&lt;';
153
+ case '>':
154
+ return '&gt;';
155
+ case '"':
156
+ return '&quot;';
157
+ default:
158
+ return '&#39;';
159
+ }
160
+ });
161
+ }
162
+ /** An empty string means success without stdout. Undefined means the backend failed. */
163
+ function runClipboardCommand(command, env) {
164
+ return new Promise(resolve => {
165
+ const child = (0, node_child_process_1.spawn)(command.executable, command.args, {
166
+ env,
167
+ stdio: [
168
+ command.input === undefined ? 'ignore' : 'pipe',
169
+ command.capture ? 'pipe' : 'ignore',
170
+ 'ignore',
171
+ ],
172
+ windowsHide: true,
173
+ });
174
+ const timer = setTimeout(abort, COMMAND_TIMEOUT_MS);
175
+ const chunks = [];
176
+ let size = 0;
177
+ function settle(output) {
178
+ clearTimeout(timer);
179
+ resolve(output);
180
+ }
181
+ function abort() {
182
+ child.kill('SIGKILL');
183
+ settle(undefined);
184
+ }
185
+ child.on('error', () => settle(undefined));
186
+ child.once(command.capture ? 'close' : 'exit', code => {
187
+ settle(code === 0 ? Buffer.concat(chunks, size).toString('utf8') : undefined);
188
+ });
189
+ child.stdout?.on('data', (chunk) => {
190
+ if (size + chunk.length > MAX_PROBE_OUTPUT_BYTES) {
191
+ abort();
192
+ return;
193
+ }
194
+ size += chunk.length;
195
+ chunks.push(chunk);
196
+ });
197
+ child.stdin?.on('error', abort);
198
+ child.stdin?.end(command.input, 'utf8');
199
+ });
200
+ }
201
+ //# sourceMappingURL=response-clipboard.js.map
@@ -1,14 +1,31 @@
1
1
  import { type TuiFrame } from '../tui-core/frame';
2
- import type { TuiTheme } from '../tui-core/style';
2
+ import type { StyledRow, TuiTheme } from '../tui-core/style';
3
3
  import { type TuiInputEvent } from '../tui-core/input-parser';
4
4
  import type { UiEventSink } from '../runtime/ui-events';
5
+ import type { ThreadTranscriptHistorySource } from '../runtime/thread-session-index';
5
6
  import type { ToolDetailRepository } from '../runtime/tool-detail-repository';
6
7
  import type { TuiMotionPreference, TuiStatusItem, UIConfig } from '../services/global-config';
7
- import { InlineTerminalSurface } from './inline-surface';
8
+ import type { TerminalViewport } from './terminal-viewport';
8
9
  import { type TuiRenderScheduler, type TuiRenderSchedulerDeps } from './render-scheduler';
9
10
  import { type TuiUiAction, type TuiUiState } from './state';
10
- import { TranscriptInspectorSurface } from './transcript-inspector-surface';
11
11
  import type { AgentModeSnapshot } from '../framework/agent-mode';
12
+ import type { SessionMeta } from '../services/session-storage';
13
+ import type { SessionPickerPreviewMessage } from './session-picker-preview';
14
+ export type FollowupMutation = {
15
+ type: 'edit';
16
+ itemId: string;
17
+ revision: number;
18
+ text: string;
19
+ } | {
20
+ type: 'move';
21
+ itemId: string;
22
+ revision: number;
23
+ index: number;
24
+ } | {
25
+ type: 'remove';
26
+ itemId: string;
27
+ revision: number;
28
+ };
12
29
  export interface TuiRunnerOptions {
13
30
  output: Pick<NodeJS.WriteStream, 'write'>;
14
31
  width: number;
@@ -21,69 +38,73 @@ export interface TuiRunnerOptions {
21
38
  onExit?: () => void | Promise<void>;
22
39
  onQueueClear?: () => void | Promise<void>;
23
40
  onQueueResume?: () => void;
41
+ onQueueMutation?: (mutation: FollowupMutation) => string | undefined;
42
+ onSelectSession?: (sessionId: string, allProjects: boolean) => boolean;
43
+ loadSessionPreview?: (session: SessionMeta) => Promise<readonly SessionPickerPreviewMessage[]>;
24
44
  onPermissionDecision?: (requestId: string, approved: boolean, scope: 'once') => void | Promise<void>;
25
45
  /** Fixed Shift+Tab shortcut. Deliberately not remappable. */
26
46
  onCycleAgentMode?: () => void | Promise<void>;
27
47
  initialAgentMode?: AgentModeSnapshot;
28
48
  /** Inject scheduler deps for testing (fake timers). */
29
49
  schedulerDeps?: Partial<TuiRenderSchedulerDeps>;
30
- /** Inline surface for committed scrollback + live region rendering. */
31
- surface?: InlineTerminalSurface;
50
+ /** Single terminal viewport for chat, history and details. */
51
+ surface?: TerminalViewport;
32
52
  /** Fatal surface failures must restore terminal ownership and stop the renderer. */
33
53
  onSurfaceError?: (error: unknown) => void;
34
54
  /** Immutable transcript theme for this runner instance. */
35
55
  theme?: TuiTheme;
36
56
  themeId?: string;
37
57
  detailRepository?: ToolDetailRepository;
38
- inspectorSurface?: TranscriptInspectorSurface;
58
+ copyToClipboard?: (markdown: string) => Promise<void>;
39
59
  onOpenExternalEditor?: (filePath: string) => void | Promise<void>;
40
60
  statusLine?: readonly TuiStatusItem[];
41
- mascot?: boolean;
61
+ startupRows?: (width: number) => StyledRow[];
42
62
  keymap?: UIConfig['keymap'];
43
63
  motion?: TuiMotionPreference;
44
64
  }
45
65
  export interface TuiRunnerCounters {
46
66
  layoutCount: number;
47
67
  paintCount: number;
48
- changedRows: number;
49
- commitCount: number;
50
68
  }
51
69
  export declare class TuiRunner {
52
70
  private readonly options;
53
71
  readonly events: UiEventSink;
54
72
  private readonly parser;
55
73
  private escapeTimer?;
56
- private readonly inputOwnership;
74
+ private previewTimer?;
75
+ private previewGeneration;
57
76
  private readonly scheduler;
58
77
  private readonly surface;
59
78
  private readonly transcriptCache;
60
79
  private readonly theme;
61
80
  private readonly themeId;
62
- private readonly inspectorController;
63
- private readonly inspectorSurface;
81
+ private readonly historyLayoutCache;
82
+ private readonly now;
83
+ private readonly toolOutput;
84
+ private readonly chatPager;
85
+ private readonly transcriptPager;
86
+ private historySource?;
87
+ private earlierCursor;
88
+ private pendingHistoryPage?;
89
+ private restoredCompletionOrder;
90
+ private earlierRecords;
64
91
  private history;
65
92
  private historySearchQuery;
66
93
  private historySearchIndex;
67
94
  private historySearchMatch;
68
95
  private dismissedCommandToken?;
69
96
  private animationFrame;
70
- private animationTimer;
97
+ private activityStartedAt?;
98
+ private activityTimer;
71
99
  private surfaceFailed;
72
- private inspectorReady;
73
- private inspectorSearchActive;
100
+ private stopped;
101
+ private showingTranscript;
102
+ private clipboardQueue;
74
103
  private modalTransition;
75
- private commitSequence;
76
- private commitInFlight;
77
- private flushAllTranscript;
78
- private commitMismatchRetries;
79
104
  private state;
80
105
  private width;
81
106
  private height;
82
107
  private lastFrame;
83
- private surfaceResizePending;
84
- private transcriptChangedDuringResize;
85
- private resizeEpoch;
86
- private surfaceResizeGeneration;
87
108
  readonly counters: TuiRunnerCounters;
88
109
  constructor(options: TuiRunnerOptions);
89
110
  getState(): TuiUiState;
@@ -92,41 +113,26 @@ export declare class TuiRunner {
92
113
  /** Get the scheduler for external lifecycle management (flush, stop). */
93
114
  getScheduler(): TuiRenderScheduler;
94
115
  stop(): void;
95
- /** Stop stale-width paints as soon as the terminal reports SIGWINCH. */
96
- beginResize(width?: number): void;
97
116
  resize(width: number, height: number): void;
98
117
  dispatch(action: TuiUiAction): void;
118
+ private updateSessionPreview;
99
119
  feedInput(chunk: Buffer | string): TuiInputEvent[];
100
- /**
101
- * Render the full frame (legacy path for tests without surface).
102
- * Uses renderTuiUiFrame which includes both static and live transcript.
103
- */
120
+ setTranscriptHistorySource(source?: ThreadTranscriptHistorySource): void;
104
121
  renderFullFrame(): TuiFrame;
105
- /**
106
- * Render the live region via InlineTerminalSurface.
107
- * In inline mode, recent transcript entries stay in the live region so
108
- * their source can be laid out again after a resize.
109
- * When no surface (test mode), renders the full frame including committed
110
- * transcript so tests can inspect complete content via getLastFrame().
111
- */
112
- private renderLive;
113
- /** Build a compact live-region frame that grows only for active content. */
114
- private buildLiveFrame;
115
- /**
116
- * Try to commit any newly-finalized transcript entries to scrollback.
117
- * Called after each dispatch. Only commits entries that are committable
118
- * but not yet queued.
119
- */
120
- private tryCommit;
121
- private historyOverflowStart;
122
+ private paint;
123
+ /** Project only completed records onto the shell once when the UI releases the terminal. */
124
+ completedHistoryRows(width?: number): StyledRow[];
122
125
  /** Layout a transcript record once per revision/width/theme combination. */
123
126
  private layoutTranscriptRecord;
124
- private get transcriptWidth();
125
127
  private transcriptLayoutOptions;
126
- private startAnimation;
127
- private stopAnimation;
128
+ private startActivity;
129
+ private stopActivity;
128
130
  private handleSurfaceError;
129
131
  private applyInputEvent;
132
+ private applyWorkbenchModalInput;
133
+ private applySessionPickerInput;
134
+ private applyFollowupQueueInput;
135
+ private mutateFollowupQueue;
130
136
  private applyKey;
131
137
  private configuredActionForKey;
132
138
  private queuePrompt;
@@ -136,45 +142,24 @@ export declare class TuiRunner {
136
142
  private historyBack;
137
143
  /** Navigate to next history entry (or back to draft). */
138
144
  private historyForward;
139
- /**
140
- * Up in a multi-line prompt moves the cursor to the previous visual line;
141
- * only at the first line does it fall back to command history (matching
142
- * shell/editor behaviour). Single-line prompts behave exactly as before.
143
- */
144
- private moveCursorUpOrHistory;
145
- /**
146
- * Down in a multi-line prompt moves the cursor to the next visual line;
147
- * only at the last line does it fall back to command history.
148
- */
149
- private moveCursorDownOrHistory;
150
- /** Home: move to the start of the current visual line (not whole buffer). */
151
- private moveCursorLineHome;
152
- /** End: move to the end of the current visual line (not whole buffer). */
153
- private moveCursorLineEnd;
145
+ private moveCursorVertically;
154
146
  private submitPrompt;
155
147
  private reportSubmitFailure;
156
148
  private handleLocalCommand;
157
- private forceOwnedRedraw;
149
+ redraw(): void;
158
150
  private updatePrompt;
159
151
  private syncPromptOverlay;
160
152
  private completeCommand;
161
153
  private completeFile;
162
154
  private answerPermission;
163
- /** Restore any temporary Inspector terminal ownership before shutdown. */
164
- closeModalSurface(): Promise<void>;
165
- /** Wait until the current Inspector ownership transition is complete. */
155
+ /** Wait for an editor or clipboard action and the resulting paint. */
166
156
  waitForModalSurface(): Promise<void>;
167
- /** Flush every finalized transcript batch, including batches queued by acknowledgements. */
168
- flushTranscriptCommits(): Promise<void>;
169
- private openToolInspector;
170
- private closeToolInspector;
171
- private applyInspectorInput;
172
- private loadSelectedInspectorDetail;
173
- private moveInspectorSelection;
174
- private moveInspectorSelectionTo;
175
- private exportInspectorResults;
176
- private openSelectedInspectorDetailInEditor;
177
- private paintInspector;
178
- private buildInspectorFrame;
157
+ private openTranscriptPager;
158
+ private closeTranscriptPager;
159
+ private loadEarlierTranscript;
160
+ private readEarlierPage;
161
+ private loadTranscriptBeginning;
162
+ private applyTranscriptInput;
163
+ private copyLastResponse;
179
164
  }
180
165
  //# sourceMappingURL=runner.d.ts.map