@causyne/agent 1.20.45 → 1.20.53

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/src/tui/prompt.js CHANGED
@@ -667,9 +667,9 @@ export class ChatPrompt {
667
667
  if (this.surface?.homeInfo) this.surface.leaveHome();
668
668
  if (this.renderer?.renderUserMessage) this.renderer.renderUserMessage(text);
669
669
  else this.commit('user', (width) => {
670
- const blockWidth = Math.max(8, width - 1);
670
+ const blockWidth = Math.max(8, width);
671
671
  return barBlock(
672
- wrapBlock(safeDisplay(text), Math.max(8, blockWidth - visibleWidth(GLYPHS.bar) - GUTTER)),
672
+ wrapBlock(safeDisplay(text), Math.max(8, blockWidth - visibleWidth(GLYPHS.barHeavy || GLYPHS.bar) - GUTTER)),
673
673
  { width: blockWidth, role: 'user', filled: true, surface: 'surfaceHi' }
674
674
  );
675
675
  });
@@ -1389,7 +1389,7 @@ export class ChatPrompt {
1389
1389
  role: this.busy ? 'accent' : 'user',
1390
1390
  filled: true,
1391
1391
  surface: 'surface',
1392
- punctuate: true
1392
+ punctuate: false
1393
1393
  });
1394
1394
 
1395
1395
  const planRows = this.planRows(width);
@@ -1414,8 +1414,11 @@ export class ChatPrompt {
1414
1414
  if (this.pickerLayout) this.pickerLayout.totalPromptRows = all.length;
1415
1415
 
1416
1416
  // Park the cursor where the user is typing, not at the end of the picker.
1417
+ const availableWidth = this.surface?.composeAvailableWidth
1418
+ ? this.surface.composeAvailableWidth()
1419
+ : sessionMainWidth(this.surface?.width || terminalWidth());
1417
1420
  const positioned = this.surface
1418
- ? (this.surface.homeInfo ? centerRows(all, this.surface.width) : sessionRows(all, sessionMainWidth(this.surface.width)))
1421
+ ? (this.surface.homeInfo ? centerRows(all, this.surface.width) : sessionRows(all, availableWidth))
1419
1422
  : { rows: all, inset: 0 };
1420
1423
  this.present(positioned.rows, planRows.length + caretRow + padTop, layout.cursorCol + inset + positioned.inset);
1421
1424
  }
@@ -34,7 +34,7 @@ import { composerWidth } from './layout.js';
34
34
  import { placeHome, placeDialog } from './homeView.js';
35
35
  import { sidebarVisible, sessionMainWidth, sessionComposerWidth, sessionSidebarRows, joinSessionSidebar } from './sessionSidebar.js';
36
36
  import { sessionStageHeight, alignTranscriptRows } from './sessionLayout.js';
37
- import { collectSessionTurns, buildTurnRailCells, renderTurnPreviewCard, overlayTurnPreviewCard, resolveActiveTurnIndex } from './turnRail.js';
37
+ import { hasSessionTurns, collectSessionTurns, buildTurnRailCells, renderTurnPreviewCard, overlayTurnPreviewCard, resolveActiveTurnIndex } from './turnRail.js';
38
38
 
39
39
  // Rows of evicted transcript held for the exit log. Eviction only happens after
40
40
  // MAX_FRAMES, so this is a bound on a pathological session, not a working limit.
@@ -199,11 +199,25 @@ export class StageSurface {
199
199
  return this.stage.width();
200
200
  }
201
201
 
202
+ composeAvailableWidth() {
203
+ if (this.homeInfo) return this.width;
204
+ const mainWidth = sessionMainWidth(this.width);
205
+ const rail = this.railEnabled(mainWidth);
206
+ const hasTurns = hasSessionTurns(this.transcript);
207
+ const turnRailBudget = (rail && hasTurns) ? 3 : 0;
208
+ return rail ? Math.max(20, mainWidth - RAIL_BUDGET - turnRailBudget) : mainWidth;
209
+ }
210
+
202
211
  /** Home is compact; a session uses its full conversation column. */
203
212
  composeWidth() {
204
- return this.homeInfo
205
- ? composerWidth(this.width)
206
- : sessionComposerWidth(sessionMainWidth(this.width));
213
+ if (this.homeInfo) return composerWidth(this.width);
214
+ const mainWidth = sessionMainWidth(this.width);
215
+ const rail = this.railEnabled(mainWidth);
216
+ const hasTurns = hasSessionTurns(this.transcript);
217
+ if (!hasTurns) return sessionComposerWidth(mainWidth);
218
+ const turnRailBudget = rail ? 3 : 0;
219
+ const contentWidth = rail ? Math.max(20, mainWidth - RAIL_BUDGET - turnRailBudget) : mainWidth;
220
+ return sessionComposerWidth(contentWidth);
207
221
  }
208
222
 
209
223
  /** Keep Home distinct from a selected or newly started conversation. */
@@ -395,12 +409,19 @@ export class StageSurface {
395
409
  const sidebar = sidebarVisible(width);
396
410
  const mainWidth = sessionMainWidth(width);
397
411
  const rail = this.railEnabled(mainWidth);
398
- const hasTurns = this.transcript && collectSessionTurns(this.transcript, mainWidth).length > 0;
412
+ const hasTurns = hasSessionTurns(this.transcript);
399
413
  const turnRailBudget = (rail && hasTurns) ? 3 : 0;
400
414
  const contentWidth = rail ? Math.max(20, mainWidth - RAIL_BUDGET - turnRailBudget) : mainWidth;
401
415
 
402
416
  let block = promptRows;
403
417
  let caretRow = caret && Number.isFinite(caret.row) ? caret.row : Math.max(0, block.length - 1);
418
+ let caretCol = caret ? caret.col : 0;
419
+
420
+ if (turnRailBudget > 0) {
421
+ const railGutter = ' '.repeat(turnRailBudget);
422
+ block = block.map(row => (row ? railGutter + row : row));
423
+ caretCol += turnRailBudget;
424
+ }
404
425
 
405
426
  // Grow the band to what there is to show, before deciding anything else.
406
427
  //
@@ -485,7 +506,7 @@ export class StageSurface {
485
506
  const painted = sidebar ? joinSessionSidebar(mainRows, panelRows, mainWidth) : mainRows;
486
507
  return this.stage.paint(painted, {
487
508
  row: rows.length + caretRow,
488
- col: caret ? caret.col : 0
509
+ col: caretCol
489
510
  });
490
511
  }
491
512
 
package/src/tui/theme.js CHANGED
@@ -250,10 +250,9 @@ export const GLYPHS = HAS_UNICODE
250
250
  arrow: '▸', check: '✓', cross: '✕', dot: '·', bullet: '•',
251
251
  spinner: ['⠋', '⠙', '⠹', '⠸', '⠼', '⠴', '⠦', '⠧', '⠇', '⠏'],
252
252
  hLine: '─', vLine: '│', corner: '└', tee: '├', ellipsis: '…',
253
- // The left accent bar of a block. A half-width bar sits INSIDE its column
254
- // rather than filling it, so it reads as an edge instead of as a wall —
255
- // the same weight opencode's border={["left"]} carries.
256
- bar: '▌', step: '▪',
253
+ // The left accent bar of a block. Uses box-drawing heavy vertical ('┃')
254
+ // so it joins seamlessly from row to row without font line-height leading gaps.
255
+ bar: '┃', step: '▪',
257
256
  // The permission marker. opencode shows a warning triangle and NO risk
258
257
  // word — the level is internal plumbing, and printing 'DANGEROUS' at
259
258
  // someone just makes them numb to it. Colour still carries the tier.
@@ -21,6 +21,58 @@ export function calculateThinkingLineCount(content, width) {
21
21
  const contentBudget = Math.max(10, safeWidth - 4);
22
22
  return wrapBlock(text, contentBudget).length;
23
23
  }
24
+ /**
25
+ * Resolves dynamic contextual activity labels for streaming and completed badges.
26
+ */
27
+ export function resolveActivityLabels(options) {
28
+ const raw = (options.activity || options.title || 'thinking')
29
+ .replace(/…|\.\.\.$/, '')
30
+ .trim()
31
+ .toLowerCase();
32
+ let active = options.title ? options.title.trim() : `${raw}…`;
33
+ if (!options.title) {
34
+ if (raw === 'thinking')
35
+ active = 'thinking…';
36
+ else if (raw === 'analyzing')
37
+ active = 'analyzing…';
38
+ else if (raw === 'executing')
39
+ active = 'executing…';
40
+ else if (raw === 'editing')
41
+ active = 'editing…';
42
+ else if (raw === 'planning')
43
+ active = 'planning…';
44
+ else if (raw === 'researching')
45
+ active = 'researching…';
46
+ else if (raw === 'synthesizing')
47
+ active = 'synthesizing…';
48
+ else if (raw === 'processing')
49
+ active = 'processing…';
50
+ else
51
+ active = `${raw}…`;
52
+ }
53
+ let completed = options.completedTitle ? options.completedTitle.trim() : '';
54
+ if (!completed) {
55
+ if (raw === 'thinking')
56
+ completed = 'Thought';
57
+ else if (raw === 'analyzing')
58
+ completed = 'Analyzed';
59
+ else if (raw === 'executing')
60
+ completed = 'Executed';
61
+ else if (raw === 'editing')
62
+ completed = 'Edited';
63
+ else if (raw === 'planning')
64
+ completed = 'Planned';
65
+ else if (raw === 'researching')
66
+ completed = 'Researched';
67
+ else if (raw === 'synthesizing')
68
+ completed = 'Synthesized';
69
+ else if (raw === 'processing')
70
+ completed = 'Processed';
71
+ else
72
+ completed = raw.charAt(0).toUpperCase() + raw.slice(1);
73
+ }
74
+ return { activeLabel: active, completedLabel: completed };
75
+ }
24
76
  /**
25
77
  * Single-line compact badge for collapsed reasoning frames.
26
78
  */
@@ -28,13 +80,14 @@ export function renderCollapsedThinkingBadge(options, totalLines) {
28
80
  const isStreaming = Boolean(options.streaming);
29
81
  const durationText = options.durationText ? String(options.durationText).trim() : '';
30
82
  const arrow = HAS_UNICODE ? '▸' : '>';
83
+ const { activeLabel, completedLabel } = resolveActivityLabels(options);
31
84
  if (isStreaming) {
32
85
  const timePart = durationText ? ` · ${durationText}` : '';
33
- return ` ${paint('warn', arrow)} ${bold(paint('warn', 'thinking…'))}${dim(timePart)} ${dim('· click to expand')}`;
86
+ return ` ${paint('warn', arrow)} ${bold(paint('warn', activeLabel))}${dim(timePart)} ${dim('· click to expand')}`;
34
87
  }
35
88
  const timePart = durationText ? ` for ${durationText}` : '';
36
89
  const lineWord = totalLines === 1 ? 'line' : 'lines';
37
- return ` ${paint('muted', arrow)} ${dim(`Thought${timePart}`)} ${dim(`(${totalLines} ${lineWord})`)} ${dim('· click to expand')}`;
90
+ return ` ${paint('muted', arrow)} ${dim(`${completedLabel}${timePart}`)} ${dim(`(${totalLines} ${lineWord})`)} ${dim('· click to expand')}`;
38
91
  }
39
92
  /**
40
93
  * Builds the top, bottom, and side frame borders for the thinking box.
@@ -105,14 +158,16 @@ export function renderThinkingFrame(content, options = {}) {
105
158
  if (isStreaming) {
106
159
  const maxLines = options.maxVisibleLines ?? DEFAULT_MAX_STREAMING_LINES;
107
160
  const timePart = durationText ? ` · ${durationText}` : '';
108
- const title = `${bold(paint('warn', 'thinking…'))}${dim(timePart)}`;
161
+ const { activeLabel } = resolveActivityLabels(options);
162
+ const title = `${bold(paint('warn', activeLabel))}${dim(timePart)}`;
109
163
  const footer = collapseHint;
110
164
  const { top, bottom, wrapRow } = buildThinkingBoxBorders(title, footer, width, role);
111
165
  const rows = [top];
112
166
  if (totalLines > maxLines) {
113
167
  const hiddenCount = totalLines - (maxLines - 1);
114
168
  const scrollIndicator = HAS_UNICODE ? '↑' : '^';
115
- const hiddenNotice = `${paint('rule', scrollIndicator)} ${dim(`${hiddenCount} earlier thinking line${hiddenCount === 1 ? '' : 's'} scrolled`)}`;
169
+ const activityWord = options.activity || options.title ? `${(options.activity || options.title || '').replace(/…|\.\.\.$/, '').trim()} ` : 'thinking ';
170
+ const hiddenNotice = `${paint('rule', scrollIndicator)} ${dim(`${hiddenCount} earlier ${activityWord}line${hiddenCount === 1 ? '' : 's'} scrolled`)}`;
116
171
  rows.push(wrapRow(hiddenNotice));
117
172
  const tailRows = allRows.slice(totalLines - (maxLines - 1));
118
173
  for (const row of tailRows) {
@@ -130,7 +185,14 @@ export function renderThinkingFrame(content, options = {}) {
130
185
  // Completed Expanded Mode
131
186
  const maxLines = options.maxVisibleLines ?? DEFAULT_MAX_EXPANDED_LINES;
132
187
  const timePart = durationText ? ` · ${durationText}` : '';
133
- const title = `${paint('muted', 'thinking')}${dim(timePart)} ${dim(`(${totalLines} line${totalLines === 1 ? '' : 's'})`)}`;
188
+ const raw = (options.activity || options.title || 'thinking')
189
+ .replace(/…|\.\.\.$/, '')
190
+ .trim()
191
+ .toLowerCase();
192
+ const expandedTitleLabel = options.completedTitle
193
+ ? options.completedTitle.toLowerCase()
194
+ : (raw === 'thinking' ? 'thinking' : raw);
195
+ const title = `${paint('muted', expandedTitleLabel)}${dim(timePart)} ${dim(`(${totalLines} line${totalLines === 1 ? '' : 's'})`)}`;
134
196
  const { top, bottom, wrapRow } = buildThinkingBoxBorders(title, collapseHint, width, 'rule');
135
197
  const rows = [top];
136
198
  if (totalLines > maxLines) {
@@ -18,6 +18,9 @@ export interface ThinkingFrameOptions {
18
18
  maxVisibleLines?: number;
19
19
  role?: string;
20
20
  startLine?: number;
21
+ activity?: string;
22
+ title?: string;
23
+ completedTitle?: string;
21
24
  }
22
25
 
23
26
  export const DEFAULT_MAX_STREAMING_LINES = 8;
@@ -34,6 +37,47 @@ export function calculateThinkingLineCount(content: string, width: number): numb
34
37
  return wrapBlock(text, contentBudget).length;
35
38
  }
36
39
 
40
+ /**
41
+ * Resolves dynamic contextual activity labels for streaming and completed badges.
42
+ */
43
+ export function resolveActivityLabels(options: ThinkingFrameOptions): {
44
+ activeLabel: string;
45
+ completedLabel: string;
46
+ } {
47
+ const raw = (options.activity || options.title || 'thinking')
48
+ .replace(/…|\.\.\.$/, '')
49
+ .trim()
50
+ .toLowerCase();
51
+
52
+ let active = options.title ? options.title.trim() : `${raw}…`;
53
+ if (!options.title) {
54
+ if (raw === 'thinking') active = 'thinking…';
55
+ else if (raw === 'analyzing') active = 'analyzing…';
56
+ else if (raw === 'executing') active = 'executing…';
57
+ else if (raw === 'editing') active = 'editing…';
58
+ else if (raw === 'planning') active = 'planning…';
59
+ else if (raw === 'researching') active = 'researching…';
60
+ else if (raw === 'synthesizing') active = 'synthesizing…';
61
+ else if (raw === 'processing') active = 'processing…';
62
+ else active = `${raw}…`;
63
+ }
64
+
65
+ let completed = options.completedTitle ? options.completedTitle.trim() : '';
66
+ if (!completed) {
67
+ if (raw === 'thinking') completed = 'Thought';
68
+ else if (raw === 'analyzing') completed = 'Analyzed';
69
+ else if (raw === 'executing') completed = 'Executed';
70
+ else if (raw === 'editing') completed = 'Edited';
71
+ else if (raw === 'planning') completed = 'Planned';
72
+ else if (raw === 'researching') completed = 'Researched';
73
+ else if (raw === 'synthesizing') completed = 'Synthesized';
74
+ else if (raw === 'processing') completed = 'Processed';
75
+ else completed = raw.charAt(0).toUpperCase() + raw.slice(1);
76
+ }
77
+
78
+ return { activeLabel: active, completedLabel: completed };
79
+ }
80
+
37
81
  /**
38
82
  * Single-line compact badge for collapsed reasoning frames.
39
83
  */
@@ -44,15 +88,16 @@ export function renderCollapsedThinkingBadge(
44
88
  const isStreaming = Boolean(options.streaming);
45
89
  const durationText = options.durationText ? String(options.durationText).trim() : '';
46
90
  const arrow = HAS_UNICODE ? '▸' : '>';
91
+ const { activeLabel, completedLabel } = resolveActivityLabels(options);
47
92
 
48
93
  if (isStreaming) {
49
94
  const timePart = durationText ? ` · ${durationText}` : '';
50
- return ` ${paint('warn', arrow)} ${bold(paint('warn', 'thinking…'))}${dim(timePart)} ${dim('· click to expand')}`;
95
+ return ` ${paint('warn', arrow)} ${bold(paint('warn', activeLabel))}${dim(timePart)} ${dim('· click to expand')}`;
51
96
  }
52
97
 
53
98
  const timePart = durationText ? ` for ${durationText}` : '';
54
99
  const lineWord = totalLines === 1 ? 'line' : 'lines';
55
- return ` ${paint('muted', arrow)} ${dim(`Thought${timePart}`)} ${dim(`(${totalLines} ${lineWord})`)} ${dim('· click to expand')}`;
100
+ return ` ${paint('muted', arrow)} ${dim(`${completedLabel}${timePart}`)} ${dim(`(${totalLines} ${lineWord})`)} ${dim('· click to expand')}`;
56
101
  }
57
102
 
58
103
  /**
@@ -149,7 +194,8 @@ export function renderThinkingFrame(
149
194
  if (isStreaming) {
150
195
  const maxLines = options.maxVisibleLines ?? DEFAULT_MAX_STREAMING_LINES;
151
196
  const timePart = durationText ? ` · ${durationText}` : '';
152
- const title = `${bold(paint('warn', 'thinking…'))}${dim(timePart)}`;
197
+ const { activeLabel } = resolveActivityLabels(options);
198
+ const title = `${bold(paint('warn', activeLabel))}${dim(timePart)}`;
153
199
  const footer = collapseHint;
154
200
 
155
201
  const { top, bottom, wrapRow } = buildThinkingBoxBorders(title, footer, width, role);
@@ -158,7 +204,8 @@ export function renderThinkingFrame(
158
204
  if (totalLines > maxLines) {
159
205
  const hiddenCount = totalLines - (maxLines - 1);
160
206
  const scrollIndicator = HAS_UNICODE ? '↑' : '^';
161
- const hiddenNotice = `${paint('rule', scrollIndicator)} ${dim(`${hiddenCount} earlier thinking line${hiddenCount === 1 ? '' : 's'} scrolled`)}`;
207
+ const activityWord = options.activity || options.title ? `${(options.activity || options.title || '').replace(/…|\.\.\.$/, '').trim()} ` : 'thinking ';
208
+ const hiddenNotice = `${paint('rule', scrollIndicator)} ${dim(`${hiddenCount} earlier ${activityWord}line${hiddenCount === 1 ? '' : 's'} scrolled`)}`;
162
209
  rows.push(wrapRow(hiddenNotice));
163
210
 
164
211
  const tailRows = allRows.slice(totalLines - (maxLines - 1));
@@ -178,7 +225,14 @@ export function renderThinkingFrame(
178
225
  // Completed Expanded Mode
179
226
  const maxLines = options.maxVisibleLines ?? DEFAULT_MAX_EXPANDED_LINES;
180
227
  const timePart = durationText ? ` · ${durationText}` : '';
181
- const title = `${paint('muted', 'thinking')}${dim(timePart)} ${dim(`(${totalLines} line${totalLines === 1 ? '' : 's'})`)}`;
228
+ const raw = (options.activity || options.title || 'thinking')
229
+ .replace(/…|\.\.\.$/, '')
230
+ .trim()
231
+ .toLowerCase();
232
+ const expandedTitleLabel = options.completedTitle
233
+ ? options.completedTitle.toLowerCase()
234
+ : (raw === 'thinking' ? 'thinking' : raw);
235
+ const title = `${paint('muted', expandedTitleLabel)}${dim(timePart)} ${dim(`(${totalLines} line${totalLines === 1 ? '' : 's'})`)}`;
182
236
 
183
237
  const { top, bottom, wrapRow } = buildThinkingBoxBorders(title, collapseHint, width, 'rule');
184
238
  const rows: string[] = [top];
@@ -1,4 +1,33 @@
1
1
  import fs from 'node:fs';
2
+ /**
3
+ * Normalizes an external/native action record for historical transcript restoration,
4
+ * reconstructing arguments and ensuring verified success/failure status.
5
+ */
6
+ export function normalizeHistoricalExternalAction(ext) {
7
+ const toolName = typeof ext?.name === 'string' && ext.name.trim() ? ext.name.trim() : 'tool';
8
+ const detail = typeof ext?.detail === 'string' ? ext.detail.trim() : '';
9
+ const status = typeof ext?.status === 'string' ? ext.status.toLowerCase().trim() : '';
10
+ const isFailed = status === 'failed' || status === 'error';
11
+ const success = !isFailed;
12
+ const rawParams = ext?.parameters && typeof ext.parameters === 'object' && !Array.isArray(ext.parameters)
13
+ ? { ...ext.parameters }
14
+ : {};
15
+ const lowerTool = toolName.toLowerCase();
16
+ const isFileTool = ['read_file', 'write_file', 'edit_file', 'fs_read', 'fs_write', 'fs_edit', 'view_file'].includes(lowerTool);
17
+ const isCommandTool = ['run_command', 'bash', 'terminal', 'sh', 'zsh', 'sysrun', 'sysrunbg'].includes(lowerTool);
18
+ const args = {
19
+ ...rawParams,
20
+ ...(detail ? { detail } : {}),
21
+ ...(detail && isFileTool && !rawParams.path && !rawParams.file_path && !rawParams.filePath ? { path: detail } : {}),
22
+ ...(detail && isCommandTool && !rawParams.command && !rawParams.cmd ? { command: detail } : {})
23
+ };
24
+ const result = {
25
+ success,
26
+ output: '',
27
+ ...(isFailed ? { error: typeof ext?.error === 'string' && ext.error ? ext.error : (detail || 'failed') } : {})
28
+ };
29
+ return { toolName, args, result };
30
+ }
2
31
  const DECAY_MARKER = '[decayed]';
3
32
  const SPILL_HEADER_PREFIX = '=== CAUSYNE TOOL OUTPUT';
4
33
  /**
@@ -14,6 +14,59 @@ export interface NormalizedHistoricalToolResult {
14
14
  plan?: Array<Record<string, unknown>> | undefined;
15
15
  }
16
16
 
17
+ export interface HistoricalExternalAction {
18
+ id?: string | undefined;
19
+ name?: string | undefined;
20
+ status?: string | undefined;
21
+ detail?: string | undefined;
22
+ parameters?: Record<string, unknown> | undefined;
23
+ error?: string | undefined;
24
+ }
25
+
26
+ export interface NormalizedExternalActionResult {
27
+ toolName: string;
28
+ args: Record<string, unknown>;
29
+ result: {
30
+ success: boolean;
31
+ output: string;
32
+ error?: string | undefined;
33
+ };
34
+ }
35
+
36
+ /**
37
+ * Normalizes an external/native action record for historical transcript restoration,
38
+ * reconstructing arguments and ensuring verified success/failure status.
39
+ */
40
+ export function normalizeHistoricalExternalAction(ext: HistoricalExternalAction | null | undefined): NormalizedExternalActionResult {
41
+ const toolName = typeof ext?.name === 'string' && ext.name.trim() ? ext.name.trim() : 'tool';
42
+ const detail = typeof ext?.detail === 'string' ? ext.detail.trim() : '';
43
+ const status = typeof ext?.status === 'string' ? ext.status.toLowerCase().trim() : '';
44
+ const isFailed = status === 'failed' || status === 'error';
45
+ const success = !isFailed;
46
+
47
+ const rawParams = ext?.parameters && typeof ext.parameters === 'object' && !Array.isArray(ext.parameters)
48
+ ? { ...ext.parameters }
49
+ : {};
50
+ const lowerTool = toolName.toLowerCase();
51
+ const isFileTool = ['read_file', 'write_file', 'edit_file', 'fs_read', 'fs_write', 'fs_edit', 'view_file'].includes(lowerTool);
52
+ const isCommandTool = ['run_command', 'bash', 'terminal', 'sh', 'zsh', 'sysrun', 'sysrunbg'].includes(lowerTool);
53
+
54
+ const args: Record<string, unknown> = {
55
+ ...rawParams,
56
+ ...(detail ? { detail } : {}),
57
+ ...(detail && isFileTool && !rawParams.path && !rawParams.file_path && !rawParams.filePath ? { path: detail } : {}),
58
+ ...(detail && isCommandTool && !rawParams.command && !rawParams.cmd ? { command: detail } : {})
59
+ };
60
+
61
+ const result: { success: boolean; output: string; error?: string | undefined } = {
62
+ success,
63
+ output: '',
64
+ ...(isFailed ? { error: typeof ext?.error === 'string' && ext.error ? ext.error : (detail || 'failed') } : {})
65
+ };
66
+
67
+ return { toolName, args, result };
68
+ }
69
+
17
70
  const DECAY_MARKER = '[decayed]';
18
71
  const SPILL_HEADER_PREFIX = '=== CAUSYNE TOOL OUTPUT';
19
72
 
@@ -16,6 +16,15 @@ export function formatTurnTimestamp(ts) {
16
16
  const dateStr = date.toLocaleDateString('en-US', { month: 'long', day: 'numeric', year: 'numeric' });
17
17
  return `${dateStr} at ${timeStr}`;
18
18
  }
19
+ /**
20
+ * Fast O(N) check for whether user turns exist without flattening or rendering frames.
21
+ */
22
+ export function hasSessionTurns(transcript) {
23
+ if (!transcript || !Array.isArray(transcript.frames) || transcript.frames.length === 0) {
24
+ return false;
25
+ }
26
+ return transcript.frames.some((f) => f && f.kind === 'user');
27
+ }
19
28
  /**
20
29
  * Collect all user turns from transcript frames.
21
30
  */
@@ -36,6 +36,16 @@ export function formatTurnTimestamp(ts: number): string {
36
36
  return `${dateStr} at ${timeStr}`;
37
37
  }
38
38
 
39
+ /**
40
+ * Fast O(N) check for whether user turns exist without flattening or rendering frames.
41
+ */
42
+ export function hasSessionTurns(transcript: any): boolean {
43
+ if (!transcript || !Array.isArray(transcript.frames) || transcript.frames.length === 0) {
44
+ return false;
45
+ }
46
+ return transcript.frames.some((f: any) => f && f.kind === 'user');
47
+ }
48
+
39
49
  /**
40
50
  * Collect all user turns from transcript frames.
41
51
  */
@@ -1 +0,0 @@
1
- export function panel(rows: string[], options?: { width?: number; title?: string; role?: string }): string[];