@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.
Files changed (142) hide show
  1. package/CHANGELOG.md +17 -1
  2. package/README.md +8 -9
  3. package/README.zh-CN.md +8 -8
  4. package/dist/acp/session-updates.js +1 -0
  5. package/dist/cli.js +42 -3
  6. package/dist/commands/session-command-handlers.js +8 -3
  7. package/dist/commands/system-commands.js +3 -3
  8. package/dist/commands/types.d.ts +3 -0
  9. package/dist/framework/loop-progress.js +3 -1
  10. package/dist/framework/query.d.ts +6 -8
  11. package/dist/framework/query.js +39 -76
  12. package/dist/framework/tool-serializer.d.ts +12 -0
  13. package/dist/framework/tool-serializer.js +35 -0
  14. package/dist/framework/tool.d.ts +2 -0
  15. package/dist/framework/verification-command.d.ts +21 -0
  16. package/dist/framework/verification-command.js +53 -4
  17. package/dist/harness/context-harness.d.ts +3 -9
  18. package/dist/harness/context-harness.js +43 -163
  19. package/dist/harness/ledger.js +2 -1
  20. package/dist/harness/state.d.ts +3 -0
  21. package/dist/harness/state.js +37 -4
  22. package/dist/harness/task-checklist.d.ts +1 -1
  23. package/dist/harness/task-checklist.js +1 -1
  24. package/dist/harness/types.d.ts +1 -0
  25. package/dist/harness/verification.js +5 -4
  26. package/dist/print-ui/delivery.d.ts +15 -0
  27. package/dist/print-ui/delivery.js +131 -0
  28. package/dist/print-ui/event-stream.d.ts +6 -1
  29. package/dist/print-ui/event-stream.js +56 -10
  30. package/dist/print-ui/launch.d.ts +5 -0
  31. package/dist/print-ui/launch.js +66 -9
  32. package/dist/runtime/agent-loop.d.ts +3 -1
  33. package/dist/runtime/agent-loop.js +26 -41
  34. package/dist/runtime/agent-runtime-controller.d.ts +4 -1
  35. package/dist/runtime/agent-runtime-controller.js +36 -22
  36. package/dist/runtime/agent-runtime-runner.d.ts +4 -0
  37. package/dist/runtime/agent-runtime-runner.js +9 -0
  38. package/dist/runtime/builtin-tool-provider.js +6 -5
  39. package/dist/runtime/composer/layout.d.ts +1 -1
  40. package/dist/runtime/composer/layout.js +5 -5
  41. package/dist/runtime/core-tools/descriptors.d.ts +1 -1
  42. package/dist/runtime/core-tools/descriptors.js +39 -1
  43. package/dist/runtime/first-party-core-provider.js +1 -0
  44. package/dist/runtime/first-party-tool-services.js +10 -0
  45. package/dist/runtime/goal-lifecycle-v2.js +5 -0
  46. package/dist/runtime/goal-runtime-coordinator.js +6 -2
  47. package/dist/runtime/goals/evidence.js +2 -0
  48. package/dist/runtime/legacy-thread-materializer.d.ts +7 -0
  49. package/dist/runtime/legacy-thread-materializer.js +32 -6
  50. package/dist/runtime/orion-runtime-v1.d.ts +2 -1
  51. package/dist/runtime/orion-runtime-v1.js +34 -6
  52. package/dist/runtime/product-bootstrap.d.ts +2 -0
  53. package/dist/runtime/product-bootstrap.js +1 -0
  54. package/dist/runtime/product-orion-runtime.d.ts +2 -1
  55. package/dist/runtime/product-orion-runtime.js +7 -2
  56. package/dist/runtime/rich-text/layout.d.ts +3 -1
  57. package/dist/runtime/rich-text/layout.js +37 -22
  58. package/dist/runtime/shell-process-sessions.d.ts +41 -0
  59. package/dist/runtime/shell-process-sessions.js +258 -0
  60. package/dist/runtime/step-snapshot.js +61 -11
  61. package/dist/runtime/subagents/presets.d.ts +1 -1
  62. package/dist/runtime/subagents/presets.js +1 -0
  63. package/dist/runtime/task-context-recovery.js +14 -3
  64. package/dist/runtime/task-context-service.d.ts +2 -6
  65. package/dist/runtime/task-context-service.js +3 -12
  66. package/dist/runtime/thread-event-store.d.ts +3 -0
  67. package/dist/runtime/thread-event-store.js +35 -22
  68. package/dist/runtime/thread-session-index.d.ts +15 -3
  69. package/dist/runtime/thread-session-index.js +152 -45
  70. package/dist/runtime/thread-session-view.js +1 -1
  71. package/dist/runtime/thread-ui-adapter.d.ts +1 -1
  72. package/dist/runtime/thread-ui-adapter.js +23 -5
  73. package/dist/runtime/tool-gateway.d.ts +1 -0
  74. package/dist/runtime/tool-gateway.js +1 -0
  75. package/dist/runtime/tool-transcript-entry.d.ts +8 -1
  76. package/dist/runtime/tool-transcript-entry.js +35 -7
  77. package/dist/runtime/ui-events.d.ts +10 -0
  78. package/dist/runtime/verification-feedback.d.ts +4 -0
  79. package/dist/runtime/verification-feedback.js +61 -0
  80. package/dist/services/global-config.d.ts +1 -1
  81. package/dist/services/global-config.js +2 -0
  82. package/dist/services/llm.d.ts +3 -0
  83. package/dist/services/llm.js +48 -4
  84. package/dist/terminal-ui/raw-editor.js +2 -1
  85. package/dist/tools/bash_security.d.ts +1 -24
  86. package/dist/tools/bash_security.js +7 -124
  87. package/dist/tools/core/exec-command.js +51 -42
  88. package/dist/tools/core/index.d.ts +2 -1
  89. package/dist/tools/core/index.js +4 -1
  90. package/dist/tools/core/process-session.d.ts +2 -0
  91. package/dist/tools/core/process-session.js +54 -0
  92. package/dist/tools/todo.js +9 -13
  93. package/dist/tui-core/frame.d.ts +2 -0
  94. package/dist/tui-core/frame.js +19 -0
  95. package/dist/tui-core/input-parser.d.ts +4 -1
  96. package/dist/tui-core/input-parser.js +22 -0
  97. package/dist/tui-ui/chrome-view-model.d.ts +0 -2
  98. package/dist/tui-ui/chrome-view-model.js +54 -56
  99. package/dist/tui-ui/launch.js +133 -202
  100. package/dist/tui-ui/layout.d.ts +16 -41
  101. package/dist/tui-ui/layout.js +408 -295
  102. package/dist/tui-ui/render-scheduler.d.ts +2 -5
  103. package/dist/tui-ui/render-scheduler.js +10 -10
  104. package/dist/tui-ui/response-clipboard.d.ts +17 -0
  105. package/dist/tui-ui/response-clipboard.js +201 -0
  106. package/dist/tui-ui/runner.d.ts +65 -80
  107. package/dist/tui-ui/runner.js +545 -738
  108. package/dist/tui-ui/session-picker-preview.d.ts +8 -0
  109. package/dist/tui-ui/session-picker-preview.js +119 -0
  110. package/dist/tui-ui/session-picker.d.ts +20 -0
  111. package/dist/tui-ui/session-picker.js +42 -0
  112. package/dist/tui-ui/state.d.ts +34 -81
  113. package/dist/tui-ui/state.js +155 -288
  114. package/dist/tui-ui/terminal-image.d.ts +3 -7
  115. package/dist/tui-ui/terminal-image.js +18 -47
  116. package/dist/tui-ui/terminal-viewport.d.ts +55 -0
  117. package/dist/tui-ui/terminal-viewport.js +221 -0
  118. package/dist/tui-ui/transcript-layout.d.ts +5 -0
  119. package/dist/tui-ui/transcript-layout.js +43 -28
  120. package/dist/tui-ui/transcript-pager.d.ts +39 -0
  121. package/dist/tui-ui/transcript-pager.js +278 -0
  122. package/dist/tui-ui/transcript-tool-output.d.ts +16 -0
  123. package/dist/tui-ui/transcript-tool-output.js +102 -0
  124. package/dist/utils/bounded-file.d.ts +4 -0
  125. package/dist/utils/bounded-file.js +30 -0
  126. package/dist/utils/command-process.d.ts +4 -0
  127. package/dist/utils/command-process.js +23 -0
  128. package/dist/utils/shell-command.d.ts +29 -0
  129. package/dist/utils/shell-command.js +185 -0
  130. package/docs/cli-guide.md +50 -6
  131. package/npm-shrinkwrap.json +115 -15
  132. package/package.json +4 -1
  133. package/dist/tui-ui/inline-surface.d.ts +0 -191
  134. package/dist/tui-ui/inline-surface.js +0 -644
  135. package/dist/tui-ui/input-ownership.d.ts +0 -46
  136. package/dist/tui-ui/input-ownership.js +0 -74
  137. package/dist/tui-ui/transcript-inspector-layout.d.ts +0 -9
  138. package/dist/tui-ui/transcript-inspector-layout.js +0 -107
  139. package/dist/tui-ui/transcript-inspector-surface.d.ts +0 -18
  140. package/dist/tui-ui/transcript-inspector-surface.js +0 -91
  141. package/dist/tui-ui/transcript-inspector.d.ts +0 -36
  142. package/dist/tui-ui/transcript-inspector.js +0 -129
@@ -2,21 +2,13 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.initialTuiUiState = void 0;
4
4
  exports.tuiUiReducer = tuiUiReducer;
5
- exports.staticTuiTranscriptEntries = staticTuiTranscriptEntries;
6
- exports.liveTuiTranscriptEntries = liveTuiTranscriptEntries;
7
- exports.pendingCommitEntries = pendingCommitEntries;
8
- exports.staticTuiTranscriptRecords = staticTuiTranscriptRecords;
9
- exports.liveTuiTranscriptRecords = liveTuiTranscriptRecords;
10
- exports.pendingCommitRecords = pendingCommitRecords;
11
- exports.markTranscriptQueued = markTranscriptQueued;
12
- exports.markTranscriptCommitted = markTranscriptCommitted;
13
- exports.acknowledgeTranscriptCommit = acknowledgeTranscriptCommit;
14
5
  exports.createTuiUiEventSink = createTuiUiEventSink;
15
6
  const presentation_1 = require("../runtime/goals/presentation");
16
7
  const ui_view_model_1 = require("../runtime/ui-view-model");
8
+ const session_picker_1 = require("./session-picker");
17
9
  /** Maximum subtask timeline entries (bounded for long-session safety). */
18
10
  const MAX_SUBTASK_TIMELINE = 100;
19
- const MAX_RECENT_TOOL_DETAILS = 512;
11
+ const MAX_RUNTIME_TOOL_EVENTS = 1024;
20
12
  /**
21
13
  * Streaming updates normally touch the last live transcript record. A regular
22
14
  * `Array#map` clones every retained, already-finalized entry for each token.
@@ -24,7 +16,7 @@ const MAX_RECENT_TOOL_DETAILS = 512;
24
16
  * in the shared base and only the handful of live indexes are copied.
25
17
  *
26
18
  * The proxy target is still an Array, so existing read-only consumers (`slice`,
27
- * `map`, iteration, Jest assertions) keep the public contract. Append/evict
19
+ * `map`, iteration, Jest assertions) keep the public contract. Structural
28
20
  * operations materialize a flat array at their existing lifecycle boundaries.
29
21
  */
30
22
  const transcriptOverlays = new WeakMap();
@@ -73,15 +65,20 @@ function overlayTranscriptRecord(transcript, index, record) {
73
65
  transcriptOverlays.set(proxy, { base, patches });
74
66
  return proxy;
75
67
  }
68
+ function materializeTranscript(transcript) {
69
+ const overlay = transcriptOverlays.get(transcript);
70
+ const records = (overlay?.base ?? transcript).slice();
71
+ for (const [index, record] of overlay?.patches ?? [])
72
+ records[index] = record;
73
+ return records;
74
+ }
76
75
  function findTranscriptRecordIndex(state, id) {
77
- // Live records are always at/after the committable boundary. Search that
78
- // small tail first so a delayed surface acknowledgement cannot make token
79
- // updates scan thousands of finalized prefix records.
80
- for (let index = state.transcript.length - 1; index >= state.committableTranscriptCount; index--) {
76
+ // Look in the active tail first so streaming updates do not scan history.
77
+ for (let index = state.transcript.length - 1; index >= state.completedTranscriptCount; index--) {
81
78
  if (state.transcript[index]?.id === id)
82
79
  return index;
83
80
  }
84
- for (let index = state.committableTranscriptCount - 1; index >= 0; index--) {
81
+ for (let index = state.completedTranscriptCount - 1; index >= 0; index--) {
85
82
  if (state.transcript[index]?.id === id)
86
83
  return index;
87
84
  }
@@ -95,9 +92,8 @@ exports.initialTuiUiState = {
95
92
  research: null,
96
93
  effort: null,
97
94
  followupQueue: { items: [], limit: 16 },
98
- committableTranscriptCount: 0,
99
- queuedTranscriptCount: 0,
100
- committedTranscriptCount: 0,
95
+ completedTranscriptCount: 0,
96
+ latestCompletionOrder: 0,
101
97
  transcriptGeneration: 0,
102
98
  prompt: { value: '', cursor: 0 },
103
99
  statusMessage: '',
@@ -106,15 +102,12 @@ exports.initialTuiUiState = {
106
102
  snapshot: null,
107
103
  activeTools: 0,
108
104
  activeSubtasks: 0,
109
- committedTranscriptEntries: 0,
110
105
  },
111
106
  processing: false,
112
107
  overlay: null,
113
108
  agentMode: { baseMode: 'interactive', pendingBaseMode: null },
114
109
  // v0.2.23
115
110
  toolOutputViewMode: 'adaptive',
116
- recentToolDetails: [],
117
- inspector: null,
118
111
  goal: null,
119
112
  };
120
113
  function tuiUiReducer(state, action) {
@@ -122,17 +115,16 @@ function tuiUiReducer(state, action) {
122
115
  case 'appendTranscript': {
123
116
  const { live: _live, ...entry } = action.entry;
124
117
  void _live;
125
- return commitStaticTranscriptPrefix({
126
- ...state,
127
- transcript: [
128
- ...state.transcript,
129
- {
130
- ...entry,
131
- finalized: !isLiveTranscriptAppend(action.entry),
132
- revision: 1,
133
- },
134
- ],
118
+ const transcript = materializeTranscript(state.transcript);
119
+ const finalized = !isLiveTranscriptAppend(action.entry);
120
+ const latestCompletionOrder = state.latestCompletionOrder + Number(finalized);
121
+ transcript.push({
122
+ ...entry,
123
+ finalized,
124
+ revision: 1,
125
+ ...(finalized ? { completedOrder: latestCompletionOrder } : {}),
135
126
  });
127
+ return advanceCompletedTranscriptPrefix({ ...state, transcript, latestCompletionOrder });
136
128
  }
137
129
  case 'updateTranscript': {
138
130
  const index = findTranscriptRecordIndex(state, action.id);
@@ -153,36 +145,38 @@ function tuiUiReducer(state, action) {
153
145
  if (index < 0)
154
146
  return state;
155
147
  const entry = state.transcript[index];
156
- return commitStaticTranscriptPrefix({
148
+ const completedOrder = entry.completedOrder ?? state.latestCompletionOrder + 1;
149
+ return advanceCompletedTranscriptPrefix({
157
150
  ...state,
151
+ latestCompletionOrder: Math.max(completedOrder, state.latestCompletionOrder),
158
152
  transcript: overlayTranscriptRecord(state.transcript, index, {
159
153
  ...entry,
160
154
  ...action.patch,
161
155
  finalized: true,
156
+ completedOrder,
162
157
  revision: entry.revision + 1,
163
158
  }),
164
159
  });
165
160
  }
166
161
  case 'removeTranscript':
167
- return recomputeStaticTranscriptPrefix({
162
+ return recomputeCompletedTranscriptPrefix({
168
163
  ...state,
169
- transcript: state.transcript.filter(entry => entry.id !== action.id),
164
+ transcript: materializeTranscript(state.transcript).filter(entry => entry.id !== action.id),
170
165
  });
171
166
  case 'replaceTranscript': {
172
167
  // Restore the target session's finalized history and tool activity together.
173
168
  return updateStatusCounts({
174
169
  ...state,
175
- transcript: action.entries.map(entry => ({
170
+ transcript: action.entries.map((entry, index) => ({
176
171
  ...entry,
177
172
  finalized: true,
178
173
  revision: 1,
174
+ completedOrder: index + 1,
179
175
  })),
180
- committableTranscriptCount: action.entries.length,
181
- queuedTranscriptCount: 0,
182
- committedTranscriptCount: 0,
176
+ completedTranscriptCount: action.entries.length,
177
+ latestCompletionOrder: action.entries.length,
183
178
  transcriptGeneration: state.transcriptGeneration + 1,
184
179
  runtimeToolEvents: [],
185
- recentToolDetails: mergeRecentToolDetails([], action.entries.flatMap(toolDetailsFromTranscriptEntry)),
186
180
  });
187
181
  }
188
182
  case 'startSession':
@@ -207,9 +201,8 @@ function tuiUiReducer(state, action) {
207
201
  return {
208
202
  ...state,
209
203
  transcript: [],
210
- committableTranscriptCount: 0,
211
- queuedTranscriptCount: 0,
212
- committedTranscriptCount: 0,
204
+ completedTranscriptCount: 0,
205
+ latestCompletionOrder: 0,
213
206
  transcriptGeneration: state.transcriptGeneration + 1,
214
207
  };
215
208
  case 'setPrompt': {
@@ -270,7 +263,6 @@ function tuiUiReducer(state, action) {
270
263
  message: action.message ?? state.statusState.message,
271
264
  activeTools,
272
265
  activeSubtasks,
273
- committedTranscriptEntries: state.committedTranscriptCount,
274
266
  },
275
267
  };
276
268
  }
@@ -284,10 +276,61 @@ function tuiUiReducer(state, action) {
284
276
  },
285
277
  };
286
278
  case 'showSessionPicker':
279
+ return { ...state, overlay: (0, session_picker_1.openSessionPicker)(action.request) };
280
+ case 'setSessionPreview': {
281
+ const overlay = state.overlay;
282
+ if (overlay?.type !== 'sessions' ||
283
+ overlay.matches[overlay.selectedIndex]?.id !== action.sessionId) {
284
+ return state;
285
+ }
286
+ return { ...state, overlay: { ...overlay, preview: action.messages } };
287
+ }
288
+ case 'setModalPrompt': {
289
+ const overlay = state.overlay;
290
+ if (overlay?.type === 'sessions') {
291
+ return { ...state, overlay: (0, session_picker_1.searchSessionPicker)(overlay, action.prompt) };
292
+ }
293
+ if (overlay?.type === 'queue' && overlay.editor) {
294
+ return {
295
+ ...state,
296
+ overlay: { ...overlay, editor: { ...overlay.editor, draft: action.prompt } },
297
+ };
298
+ }
299
+ return state;
300
+ }
301
+ case 'showFollowupQueue':
287
302
  return {
288
303
  ...state,
289
- overlay: { type: 'sessions', request: action.request, selectedIndex: 0 },
304
+ overlay: { type: 'queue', selectedIndex: action.selectedIndex ?? 0 },
290
305
  };
306
+ case 'beginFollowupEdit': {
307
+ const overlay = state.overlay;
308
+ if (overlay?.type !== 'queue')
309
+ return state;
310
+ const item = state.followupQueue.items[overlay.selectedIndex];
311
+ if (!item)
312
+ return state;
313
+ return {
314
+ ...state,
315
+ overlay: {
316
+ ...overlay,
317
+ notice: undefined,
318
+ editor: {
319
+ itemId: item.id,
320
+ revision: item.revision,
321
+ draft: { value: item.text, cursor: item.text.length },
322
+ },
323
+ },
324
+ };
325
+ }
326
+ case 'endFollowupEdit':
327
+ return state.overlay?.type === 'queue'
328
+ ? { ...state, overlay: { ...state.overlay, editor: undefined, notice: undefined } }
329
+ : state;
330
+ case 'setFollowupNotice':
331
+ return state.overlay?.type === 'queue'
332
+ ? { ...state, overlay: { ...state.overlay, notice: action.message } }
333
+ : state;
291
334
  case 'showModelPicker':
292
335
  return {
293
336
  ...state,
@@ -301,7 +344,16 @@ function tuiUiReducer(state, action) {
301
344
  case 'showPermissionRequest':
302
345
  return {
303
346
  ...state,
304
- overlay: { type: 'permission', request: action.request, selectedIndex: 0 },
347
+ overlay: {
348
+ type: 'permission',
349
+ request: action.request,
350
+ selectedIndex: 0,
351
+ resumeQueue: state.overlay?.type === 'queue'
352
+ ? state.overlay
353
+ : state.overlay?.type === 'permission'
354
+ ? state.overlay.resumeQueue
355
+ : undefined,
356
+ },
305
357
  };
306
358
  case 'agentModeChanged':
307
359
  return { ...state, agentMode: action.snapshot };
@@ -309,23 +361,8 @@ function tuiUiReducer(state, action) {
309
361
  const next = appendRuntimeToolEvent(state, { type: 'started', ...action.event });
310
362
  return updateStatusCounts(next);
311
363
  }
312
- case 'toolFinished': {
313
- const event = action.event;
314
- const detail = {
315
- callId: event.callId,
316
- sequence: event.sequence,
317
- toolName: event.name,
318
- outputBytes: event.outputBytes ?? 0,
319
- state: event.skipped ? 'skipped' : event.success ? 'success' : 'error',
320
- summary: event.summary ?? event.error,
321
- artifactId: event.artifactRef?.id,
322
- };
323
- const next = appendRuntimeToolEvent({
324
- ...state,
325
- recentToolDetails: mergeRecentToolDetails(state.recentToolDetails, [detail]),
326
- }, { type: 'finished', ...event });
327
- return updateStatusCounts(next);
328
- }
364
+ case 'toolFinished':
365
+ return updateStatusCounts(appendRuntimeToolEvent(state, { type: 'finished', ...action.event }));
329
366
  case 'subtaskEvent': {
330
367
  // R8: update the typed timeline, keyed by taskId (last write wins so
331
368
  // state advances queued -> running -> terminal without duplicates).
@@ -361,8 +398,22 @@ function tuiUiReducer(state, action) {
361
398
  statusState: { ...state.statusState, message: statusMessage },
362
399
  };
363
400
  }
364
- case 'followupQueueChanged':
365
- return { ...state, followupQueue: action.snapshot };
401
+ case 'followupQueueChanged': {
402
+ const overlay = state.overlay;
403
+ const queue = overlay?.type === 'queue'
404
+ ? overlay
405
+ : overlay?.type === 'permission'
406
+ ? overlay.resumeQueue
407
+ : undefined;
408
+ if (!queue)
409
+ return { ...state, followupQueue: action.snapshot };
410
+ const next = retainQueueSelection(queue, state.followupQueue.items, action.snapshot.items);
411
+ return {
412
+ ...state,
413
+ followupQueue: action.snapshot,
414
+ overlay: overlay?.type === 'permission' ? { ...overlay, resumeQueue: next } : next,
415
+ };
416
+ }
366
417
  case 'showCommandPalette': {
367
418
  const previous = state.overlay;
368
419
  const previousValue = previous?.type === 'commands' && previous.query === action.query
@@ -392,186 +443,30 @@ function tuiUiReducer(state, action) {
392
443
  case 'showShortcuts':
393
444
  return { ...state, overlay: { type: 'shortcuts' } };
394
445
  case 'moveOverlaySelection': {
395
- if (!state.overlay || state.overlay.type === 'shortcuts')
396
- return state;
397
- const lastIndex = Math.max(0, overlayItemCount(state.overlay) - 1);
398
- const selectedIndex = clampNumber(state.overlay.selectedIndex + action.delta, 0, lastIndex);
399
- return {
400
- ...state,
401
- overlay: { ...state.overlay, selectedIndex },
402
- };
403
- }
404
- case 'closeOverlay':
405
- return { ...state, overlay: null };
406
- // --- v0.2.23: Tool Inspector actions ---
407
- case 'setToolOutputViewMode':
408
- return { ...state, toolOutputViewMode: action.mode };
409
- case 'openToolInspector':
410
- return {
411
- ...state,
412
- inspector: {
413
- selectedIndex: Math.max(0, state.recentToolDetails.length - 1),
414
- expandedCallIds: [],
415
- listOffset: 0,
416
- detailOffset: 0,
417
- searchQuery: '',
418
- searchDirection: 1,
419
- loadingCallIds: [],
420
- },
421
- };
422
- case 'closeToolInspector':
423
- return { ...state, inspector: null };
424
- case 'moveToolInspectorSelection': {
425
- if (!state.inspector)
426
- return state;
427
- const newIndex = clampNumber(state.inspector.selectedIndex + action.delta, 0, Math.max(0, state.recentToolDetails.length - 1));
428
- return {
429
- ...state,
430
- inspector: { ...state.inspector, selectedIndex: newIndex, detailOffset: 0 },
431
- };
432
- }
433
- case 'setToolInspectorSelection': {
434
- if (!state.inspector)
435
- return state;
436
- return {
437
- ...state,
438
- inspector: {
439
- ...state.inspector,
440
- selectedIndex: Math.max(0, action.index),
441
- detailOffset: 0,
442
- },
443
- };
444
- }
445
- case 'toggleToolInspectorEntry': {
446
- if (!state.inspector)
447
- return state;
448
- const expanded = state.inspector.expandedCallIds.includes(action.callId)
449
- ? state.inspector.expandedCallIds.filter(id => id !== action.callId)
450
- : [...state.inspector.expandedCallIds, action.callId];
451
- return {
452
- ...state,
453
- inspector: { ...state.inspector, expandedCallIds: expanded },
454
- };
455
- }
456
- case 'toggleAllToolInspectorEntries': {
457
- if (!state.inspector)
446
+ const overlay = state.overlay;
447
+ if (!overlay || overlay.type === 'shortcuts')
458
448
  return state;
459
- const allExpanded = state.inspector.expandedCallIds.length === state.recentToolDetails.length;
460
- return {
461
- ...state,
462
- inspector: {
463
- ...state.inspector,
464
- expandedCallIds: allExpanded ? [] : state.recentToolDetails.map(e => e.callId),
465
- },
466
- };
467
- }
468
- case 'scrollToolInspector': {
469
- if (!state.inspector)
449
+ const lastIndex = Math.max(0, overlayItemCount(overlay, state.followupQueue.items.length) - 1);
450
+ const selectedIndex = clampNumber(overlay.selectedIndex + action.delta, 0, lastIndex);
451
+ if (selectedIndex === overlay.selectedIndex)
470
452
  return state;
471
453
  return {
472
454
  ...state,
473
- inspector: {
474
- ...state.inspector,
475
- detailOffset: Math.max(0, state.inspector.detailOffset + action.delta),
476
- },
455
+ overlay: overlay.type === 'sessions'
456
+ ? { ...overlay, selectedIndex, preview: undefined }
457
+ : overlay.type === 'queue'
458
+ ? { ...overlay, selectedIndex, notice: undefined }
459
+ : { ...overlay, selectedIndex },
477
460
  };
478
461
  }
479
- case 'setToolInspectorSearch': {
480
- if (!state.inspector)
481
- return state;
482
- return {
483
- ...state,
484
- inspector: {
485
- ...state.inspector,
486
- searchQuery: action.query,
487
- searchDirection: action.query === state.inspector.searchQuery
488
- ? (state.inspector.searchDirection === 1 ? -1 : 1)
489
- : 1,
490
- selectedIndex: 0,
491
- detailOffset: 0,
492
- },
493
- };
494
- }
495
- case 'toolDetailLoaded': {
496
- if (!state.inspector)
497
- return state;
498
- return {
499
- ...state,
500
- inspector: {
501
- ...state.inspector,
502
- loadingCallIds: state.inspector.loadingCallIds.filter(id => id !== action.callId),
503
- error: undefined,
504
- },
505
- };
506
- }
507
- case 'toolDetailLoadFailed': {
508
- if (!state.inspector)
509
- return state;
462
+ case 'closeOverlay':
510
463
  return {
511
464
  ...state,
512
- inspector: {
513
- ...state.inspector,
514
- loadingCallIds: state.inspector.loadingCallIds.filter(id => id !== action.callId),
515
- error: action.error,
516
- },
465
+ overlay: (state.overlay?.type === 'permission' && state.overlay.resumeQueue) || null,
517
466
  };
518
- }
519
- }
520
- }
521
- function staticTuiTranscriptEntries(state) {
522
- return staticTuiTranscriptRecords(state).map(stripRecord);
523
- }
524
- function liveTuiTranscriptEntries(state) {
525
- return liveTuiTranscriptRecords(state).map(stripRecord);
526
- }
527
- /** Entries ready to commit (committable but not yet queued). */
528
- function pendingCommitEntries(state) {
529
- return pendingCommitRecords(state).map(stripRecord);
530
- }
531
- /** Renderer-local records retain revision/finalized metadata for styled layout and caching. */
532
- function staticTuiTranscriptRecords(state) {
533
- return state.transcript.slice(0, state.committableTranscriptCount);
534
- }
535
- function liveTuiTranscriptRecords(state) {
536
- return state.transcript.slice(state.committableTranscriptCount);
537
- }
538
- /** Renderer-local records ready to commit (committable but not yet queued). */
539
- function pendingCommitRecords(state) {
540
- return state.transcript.slice(state.queuedTranscriptCount, state.committableTranscriptCount);
541
- }
542
- /** Advance the queued boundary after enqueueing a commit batch. */
543
- function markTranscriptQueued(state, count) {
544
- return { ...state, queuedTranscriptCount: state.queuedTranscriptCount + count };
545
- }
546
- /** Advance the committed boundary after successful surface write. */
547
- function markTranscriptCommitted(state, count) {
548
- return { ...state, committedTranscriptCount: state.committedTranscriptCount + count };
549
- }
550
- /** Release only the exact finalized prefix confirmed by the surface write. */
551
- function acknowledgeTranscriptCommit(state, acknowledgement) {
552
- if (acknowledgement.generation !== state.transcriptGeneration) {
553
- return { state, accepted: false };
554
- }
555
- const count = acknowledgement.recordIds.length;
556
- if (count === 0 ||
557
- count > state.queuedTranscriptCount ||
558
- count > state.committableTranscriptCount) {
559
- return { state, accepted: false };
560
- }
561
- const prefix = state.transcript.slice(0, count);
562
- if (prefix.some((entry, index) => !entry.finalized || entry.id !== acknowledgement.recordIds[index])) {
563
- return { state, accepted: false };
467
+ case 'setToolOutputViewMode':
468
+ return { ...state, toolOutputViewMode: action.mode };
564
469
  }
565
- return {
566
- accepted: true,
567
- state: {
568
- ...state,
569
- transcript: state.transcript.slice(count),
570
- committableTranscriptCount: state.committableTranscriptCount - count,
571
- queuedTranscriptCount: state.queuedTranscriptCount - count,
572
- committedTranscriptCount: 0,
573
- },
574
- };
575
470
  }
576
471
  function createTuiUiEventSink(dispatch, options = {}) {
577
472
  let nextId = 1;
@@ -654,40 +549,9 @@ function appendRuntimeToolEvent(state, event) {
654
549
  const next = [...withoutDuplicate, event];
655
550
  return {
656
551
  ...state,
657
- runtimeToolEvents: next.slice(-MAX_RECENT_TOOL_DETAILS * 2),
552
+ runtimeToolEvents: next.slice(-MAX_RUNTIME_TOOL_EVENTS),
658
553
  };
659
554
  }
660
- function mergeRecentToolDetails(current, incoming) {
661
- const byCallId = new Map(current.map(detail => [detail.callId, detail]));
662
- for (const detail of incoming) {
663
- byCallId.delete(detail.callId);
664
- byCallId.set(detail.callId, detail);
665
- }
666
- return Array.from(byCallId.values()).slice(-MAX_RECENT_TOOL_DETAILS);
667
- }
668
- function toolDetailsFromTranscriptEntry(entry) {
669
- const activity = entry.toolActivity;
670
- if (!activity ||
671
- (activity.state !== 'success' && activity.state !== 'error' && activity.state !== 'skipped')) {
672
- return [];
673
- }
674
- const detailRef = activity.outputView?.detailRef;
675
- const callId = detailRef?.callId ?? activity.callId;
676
- const sequence = detailRef?.sequence ?? activity.seq;
677
- if (!callId || sequence === undefined)
678
- return [];
679
- return [
680
- {
681
- callId,
682
- sequence,
683
- toolName: activity.name,
684
- outputBytes: detailRef?.outputBytes ?? activity.outputBytes ?? 0,
685
- state: activity.state,
686
- summary: activity.summary ?? activity.outputView?.summary ?? (activity.body || undefined),
687
- artifactId: detailRef?.artifactId,
688
- },
689
- ];
690
- }
691
555
  /** Count tools with a 'started' event but no matching 'finished' event. */
692
556
  function countActiveTools(events) {
693
557
  const finished = new Set();
@@ -716,41 +580,44 @@ function updateStatusCounts(state) {
716
580
  ...state.statusState,
717
581
  activeTools: countActiveTools(state.runtimeToolEvents),
718
582
  activeSubtasks: countActiveSubtasks(state.subtaskTimeline),
719
- committedTranscriptEntries: state.committedTranscriptCount,
720
583
  },
721
584
  };
722
585
  }
723
586
  function isLiveTranscriptAppend(entry) {
724
587
  return entry.live ?? entry.role === 'tool';
725
588
  }
726
- function commitStaticTranscriptPrefix(state) {
727
- let committableTranscriptCount = state.committableTranscriptCount;
728
- while (committableTranscriptCount < state.transcript.length &&
729
- state.transcript[committableTranscriptCount]?.finalized) {
730
- committableTranscriptCount += 1;
589
+ function advanceCompletedTranscriptPrefix(state) {
590
+ let completedTranscriptCount = state.completedTranscriptCount;
591
+ while (completedTranscriptCount < state.transcript.length &&
592
+ state.transcript[completedTranscriptCount]?.finalized) {
593
+ completedTranscriptCount += 1;
731
594
  }
732
- return committableTranscriptCount === state.committableTranscriptCount
595
+ return completedTranscriptCount === state.completedTranscriptCount
733
596
  ? state
734
- : { ...state, committableTranscriptCount };
597
+ : { ...state, completedTranscriptCount };
735
598
  }
736
- function recomputeStaticTranscriptPrefix(state) {
737
- let committableTranscriptCount = 0;
738
- while (committableTranscriptCount < state.transcript.length &&
739
- state.transcript[committableTranscriptCount]?.finalized) {
740
- committableTranscriptCount += 1;
599
+ function recomputeCompletedTranscriptPrefix(state) {
600
+ let completedTranscriptCount = 0;
601
+ while (completedTranscriptCount < state.transcript.length &&
602
+ state.transcript[completedTranscriptCount]?.finalized) {
603
+ completedTranscriptCount += 1;
741
604
  }
742
- return { ...state, committableTranscriptCount };
605
+ return { ...state, completedTranscriptCount };
743
606
  }
744
- function stripRecord(entry) {
745
- const { finalized: _finalized, revision: _revision, ...rest } = entry;
746
- void _finalized;
747
- void _revision;
748
- return rest;
607
+ function retainQueueSelection(overlay, before, after) {
608
+ const focusedId = before[overlay.selectedIndex]?.id;
609
+ const index = after.findIndex(item => item.id === focusedId);
610
+ return {
611
+ ...overlay,
612
+ selectedIndex: index < 0 ? Math.max(0, Math.min(overlay.selectedIndex, after.length - 1)) : index,
613
+ };
749
614
  }
750
- function overlayItemCount(overlay) {
615
+ function overlayItemCount(overlay, queueLength) {
751
616
  switch (overlay.type) {
752
617
  case 'sessions':
753
- return overlay.request.sessions.length;
618
+ return overlay.matches.length;
619
+ case 'queue':
620
+ return queueLength;
754
621
  case 'model':
755
622
  return overlay.request.models.length;
756
623
  case 'edit':
@@ -1,8 +1,8 @@
1
1
  import type { TuiThemePreference } from '../services/global-config';
2
+ import { type StyledRow } from '../tui-core/style';
2
3
  export interface TuiStartupBannerOptions {
3
4
  cwd: string;
4
5
  version: string;
5
- model: string;
6
6
  terminalWidth: number;
7
7
  suppressColor?: boolean;
8
8
  mascot?: boolean;
@@ -13,12 +13,8 @@ export interface TuiMascotVisibilityOptions {
13
13
  mascot?: boolean;
14
14
  theme?: TuiThemePreference;
15
15
  }
16
- /**
17
- * Render the startup banner as safe terminal text. Orion Pixel uses a bounded
18
- * character-grid hunter on wide terminals and degrades to details-only output
19
- * for classic, narrow, and color-suppressed environments.
20
- */
21
- export declare function renderTuiStartupBanner(options: TuiStartupBannerOptions): string;
16
+ /** Build startup rows in the same cell model as the conversation. */
17
+ export declare function layoutTuiStartupBanner(options: TuiStartupBannerOptions): StyledRow[];
22
18
  /** Keep the brand character optional and textual in accessibility/fallback modes. */
23
19
  export declare function shouldRenderTuiMascot(options: TuiMascotVisibilityOptions): boolean;
24
20
  //# sourceMappingURL=terminal-image.d.ts.map