@adhdev/daemon-core 0.7.42 → 0.7.43

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 (34) hide show
  1. package/dist/cli-adapters/provider-cli-adapter.d.ts +2 -4
  2. package/dist/cli-adapters/pty-transport.d.ts +1 -0
  3. package/dist/cli-adapters/terminal-backends/ghostty-vt-backend.d.ts +4 -0
  4. package/dist/cli-adapters/terminal-backends/types.d.ts +4 -0
  5. package/dist/cli-adapters/terminal-backends/xterm-backend.d.ts +4 -0
  6. package/dist/cli-adapters/terminal-screen.d.ts +4 -0
  7. package/dist/config/chat-history.d.ts +0 -3
  8. package/dist/index.js +72 -116
  9. package/dist/index.js.map +1 -1
  10. package/dist/index.mjs +72 -116
  11. package/dist/index.mjs.map +1 -1
  12. package/dist/providers/provider-instance.d.ts +0 -1
  13. package/dist/status/normalize.js +0 -7
  14. package/dist/status/normalize.js.map +1 -1
  15. package/dist/status/normalize.mjs +0 -7
  16. package/dist/status/normalize.mjs.map +1 -1
  17. package/node_modules/@adhdev/session-host-core/dist/index.js +2 -2
  18. package/node_modules/@adhdev/session-host-core/dist/index.js.map +1 -1
  19. package/node_modules/@adhdev/session-host-core/dist/index.mjs +2 -2
  20. package/node_modules/@adhdev/session-host-core/dist/index.mjs.map +1 -1
  21. package/node_modules/@adhdev/session-host-core/package.json +1 -1
  22. package/package.json +1 -1
  23. package/src/cli-adapters/provider-cli-adapter.ts +79 -70
  24. package/src/cli-adapters/pty-transport.ts +2 -0
  25. package/src/cli-adapters/session-host-transport.ts +1 -0
  26. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +5 -0
  27. package/src/cli-adapters/terminal-backends/types.ts +1 -0
  28. package/src/cli-adapters/terminal-backends/xterm-backend.ts +10 -0
  29. package/src/cli-adapters/terminal-screen.ts +4 -0
  30. package/src/config/chat-history.ts +3 -55
  31. package/src/providers/cli-provider-instance.ts +1 -11
  32. package/src/providers/provider-instance.d.ts +0 -1
  33. package/src/providers/provider-instance.ts +0 -1
  34. package/src/status/normalize.ts +0 -4
@@ -64,7 +64,6 @@ export interface CliSessionStatus {
64
64
  messages: CliChatMessage[];
65
65
  workingDir: string;
66
66
  activeModal: { message: string; buttons: string[] } | null;
67
- terminalHistory?: string;
68
67
  }
69
68
 
70
69
  /**
@@ -90,7 +89,6 @@ export interface CliScriptInput {
90
89
  rawBuffer: string; // Raw PTY output (with ANSI)
91
90
  recentBuffer: string; // Recent 1000 chars (ANSI-stripped)
92
91
  screenText: string; // Current visible screen snapshot
93
- terminalHistory?: string; // Rolling append-only terminal transcript
94
92
  messages: CliChatMessage[]; // Previously parsed messages
95
93
  partialResponse: string; // Current partial response being generated
96
94
  }
@@ -100,7 +98,6 @@ interface TurnParseScope {
100
98
  startedAt: number;
101
99
  bufferStart: number;
102
100
  rawBufferStart: number;
103
- terminalHistoryStart: number;
104
101
  }
105
102
 
106
103
  export interface CliProviderModule {
@@ -173,6 +170,51 @@ function sanitizeTerminalText(str: string): string {
173
170
  return stripTerminalNoise(stripAnsi(str));
174
171
  }
175
172
 
173
+ function buildCliSpawnEnv(baseEnv: NodeJS.ProcessEnv, overrides?: Record<string, string>): Record<string, string> {
174
+ const env: Record<string, string> = {};
175
+ const source = { ...baseEnv, ...(overrides || {}) } as NodeJS.ProcessEnv;
176
+
177
+ for (const [key, value] of Object.entries(source)) {
178
+ if (typeof value !== 'string') continue;
179
+ env[key] = value;
180
+ }
181
+
182
+ for (const key of Object.keys(env)) {
183
+ if (
184
+ key === 'INIT_CWD'
185
+ || key === 'NO_COLOR'
186
+ || key === 'FORCE_COLOR'
187
+ || key === 'npm_command'
188
+ || key === 'npm_execpath'
189
+ || key === 'npm_node_execpath'
190
+ || key.startsWith('npm_')
191
+ || key.startsWith('npm_config_')
192
+ || key.startsWith('npm_package_')
193
+ || key.startsWith('npm_lifecycle_')
194
+ || key.startsWith('PNPM_')
195
+ || key.startsWith('YARN_')
196
+ || key.startsWith('BUN_')
197
+ ) {
198
+ delete env[key];
199
+ }
200
+ }
201
+
202
+ return env;
203
+ }
204
+
205
+ function computeTerminalQueryTail(buffer: string): string {
206
+ const prefixes = ['\x1b[6n', '\x1b[?6n'];
207
+ const maxLength = prefixes.reduce((n, value) => Math.max(n, value.length), 0) - 1;
208
+ const start = Math.max(0, buffer.length - maxLength);
209
+ for (let i = start; i < buffer.length; i++) {
210
+ const suffix = buffer.slice(i);
211
+ if (prefixes.some((pattern) => suffix.length < pattern.length && pattern.startsWith(suffix))) {
212
+ return suffix;
213
+ }
214
+ }
215
+ return '';
216
+ }
217
+
176
218
  function findBinary(name: string): string {
177
219
  const isWin = os.platform() === 'win32';
178
220
  try {
@@ -284,44 +326,6 @@ function promptLikelyVisible(screenText: string, promptSnippet: string): boolean
284
326
  return matched >= required;
285
327
  }
286
328
 
287
- function splitHistoryLines(text: string): string[] {
288
- return String(text || '')
289
- .split('\n')
290
- .map(line => line.replace(/\s+$/, ''));
291
- }
292
-
293
- function normalizeHistoryLine(line: string): string {
294
- return String(line || '').replace(/\s+/g, ' ').trim();
295
- }
296
-
297
- function mergeTerminalHistory(existing: string, snapshot: string): string {
298
- const next = String(snapshot || '').trim();
299
- if (!next) return existing;
300
- const prev = String(existing || '').trim();
301
- if (!prev) return next;
302
- if (prev === next || prev.endsWith(next)) return prev;
303
-
304
- const prevLines = splitHistoryLines(prev);
305
- const nextLines = splitHistoryLines(next);
306
- const prevNorm = prevLines.map(normalizeHistoryLine);
307
- const nextNorm = nextLines.map(normalizeHistoryLine);
308
-
309
- const maxOverlap = Math.min(prevLines.length, nextLines.length);
310
- for (let overlap = maxOverlap; overlap >= 1; overlap -= 1) {
311
- const prevTail = prevNorm.slice(prevNorm.length - overlap);
312
- const nextHead = nextNorm.slice(0, overlap);
313
- if (prevTail.every((line, index) => line === nextHead[index])) {
314
- return [...prevLines, ...nextLines.slice(overlap)].join('\n').trim();
315
- }
316
- }
317
-
318
- const compactPrev = prevNorm.join('\n');
319
- const compactNext = nextNorm.join('\n');
320
- if (compactPrev.includes(compactNext)) return prev;
321
-
322
- return `${prev}\n${next}`.trim();
323
- }
324
-
325
329
  /**
326
330
  * Normalize provider.json for auto-implement approval detection.
327
331
  * Kept for backward compat with dev-server auto-impl pipeline only.
@@ -390,6 +394,7 @@ export class ProviderCliAdapter implements CliAdapter {
390
394
  private pendingOutputParseTimer: NodeJS.Timeout | null = null;
391
395
  private ptyOutputBuffer = '';
392
396
  private ptyOutputFlushTimer: NodeJS.Timeout | null = null;
397
+ private pendingTerminalQueryTail = '';
393
398
 
394
399
  // Server log forwarding
395
400
  private serverConn: any = null;
@@ -428,9 +433,7 @@ export class ProviderCliAdapter implements CliAdapter {
428
433
  /** Full accumulated raw PTY output (with ANSI) */
429
434
  private accumulatedRawBuffer: string = '';
430
435
  /** Current visible terminal screen snapshot */
431
- private terminalScreen = new TerminalScreen(40, 120);
432
- /** Rolling append-only terminal transcript built from screen snapshots */
433
- private terminalHistory: string = '';
436
+ private terminalScreen = new TerminalScreen(30, 100);
434
437
  /** Max accumulated buffer size (last 50KB) */
435
438
  private static readonly MAX_ACCUMULATED_BUFFER = 50000;
436
439
  private currentTurnScope: TurnParseScope | null = null;
@@ -461,23 +464,17 @@ export class ProviderCliAdapter implements CliAdapter {
461
464
 
462
465
  private buildParseInput(baseMessages: CliChatMessage[], partialResponse: string, scope?: TurnParseScope | null): CliScriptInput {
463
466
  const buffer = scope
464
- ? (this.sliceFromOffset(this.terminalHistory, scope.terminalHistoryStart)
465
- || this.sliceFromOffset(this.accumulatedBuffer, scope.bufferStart)
466
- || this.accumulatedBuffer)
467
+ ? (this.sliceFromOffset(this.accumulatedBuffer, scope.bufferStart) || this.accumulatedBuffer)
467
468
  : this.accumulatedBuffer;
468
469
  const rawBuffer = scope
469
470
  ? (this.sliceFromOffset(this.accumulatedRawBuffer, scope.rawBufferStart) || this.accumulatedRawBuffer)
470
471
  : this.accumulatedRawBuffer;
471
- const terminalHistory = scope
472
- ? (this.sliceFromOffset(this.terminalHistory, scope.terminalHistoryStart) || this.terminalHistory)
473
- : this.terminalHistory;
474
472
 
475
473
  return {
476
474
  buffer,
477
475
  rawBuffer,
478
476
  recentBuffer: buffer.slice(-1000) || this.recentOutputBuffer,
479
477
  screenText: this.terminalScreen.getText(),
480
- terminalHistory,
481
478
  messages: [...baseMessages],
482
479
  partialResponse,
483
480
  };
@@ -623,13 +620,10 @@ export class ProviderCliAdapter implements CliAdapter {
623
620
  }
624
621
 
625
622
  const ptyOpts = {
626
- cols: 120,
627
- rows: 40,
623
+ cols: 100,
624
+ rows: 30,
628
625
  cwd: this.workingDir,
629
- env: {
630
- ...process.env,
631
- ...spawnConfig.env,
632
- } as Record<string, string>,
626
+ env: buildCliSpawnEnv(process.env, spawnConfig.env),
633
627
  };
634
628
 
635
629
  try {
@@ -650,9 +644,8 @@ export class ProviderCliAdapter implements CliAdapter {
650
644
  this.ptyProcess.onData((data: string) => {
651
645
  if (Date.now() < this.resizeSuppressUntil) return;
652
646
 
653
- if (data.includes('\x1b[6n') || data.includes('\x1b[?6n')) {
654
- // Some TUIs probe cursor position during startup; reply quickly even when batching parsing.
655
- this.ptyProcess?.write('\x1b[1;1R');
647
+ if (!this.ptyProcess?.terminalQueriesHandled) {
648
+ this.respondToTerminalQueries(data);
656
649
  }
657
650
 
658
651
  this.pendingOutputParseBuffer += data;
@@ -691,8 +684,8 @@ export class ProviderCliAdapter implements CliAdapter {
691
684
  this.spawnAt = Date.now();
692
685
  this.startupParseGate = true;
693
686
  this.startupBuffer = '';
694
- this.terminalScreen.reset(40, 120);
695
- this.terminalHistory = '';
687
+ this.terminalScreen.reset(30, 100);
688
+ this.pendingTerminalQueryTail = '';
696
689
  this.currentTurnScope = null;
697
690
  this.ready = false;
698
691
  await this.ptyProcess.ready;
@@ -704,7 +697,6 @@ export class ProviderCliAdapter implements CliAdapter {
704
697
 
705
698
  private handleOutput(rawData: string): void {
706
699
  this.terminalScreen.write(rawData);
707
- this.terminalHistory = mergeTerminalHistory(this.terminalHistory, this.terminalScreen.getText());
708
700
  const cleanData = sanitizeTerminalText(rawData);
709
701
 
710
702
  if (this.isWaitingForResponse && cleanData) {
@@ -1013,7 +1005,6 @@ export class ProviderCliAdapter implements CliAdapter {
1013
1005
  messages: [...this.committedMessages],
1014
1006
  workingDir: this.workingDir,
1015
1007
  activeModal: this.activeModal,
1016
- terminalHistory: this.terminalHistory,
1017
1008
  };
1018
1009
  }
1019
1010
 
@@ -1032,7 +1023,6 @@ export class ProviderCliAdapter implements CliAdapter {
1032
1023
  id: parsed.id || 'cli_session',
1033
1024
  status: parsed.status || this.currentStatus,
1034
1025
  title: parsed.title || this.cliName,
1035
- terminalHistory: this.terminalHistory,
1036
1026
  messages: parsed.messages,
1037
1027
  activeModal: parsed.activeModal ?? this.activeModal,
1038
1028
  };
@@ -1043,7 +1033,6 @@ export class ProviderCliAdapter implements CliAdapter {
1043
1033
  id: 'cli_session',
1044
1034
  status: this.currentStatus,
1045
1035
  title: this.cliName,
1046
- terminalHistory: this.terminalHistory,
1047
1036
  messages: messages.slice(-50).map((message, index) => ({
1048
1037
  id: `msg_${index}`,
1049
1038
  role: message.role,
@@ -1114,9 +1103,8 @@ export class ProviderCliAdapter implements CliAdapter {
1114
1103
  startedAt: Date.now(),
1115
1104
  bufferStart: this.accumulatedBuffer.length,
1116
1105
  rawBufferStart: this.accumulatedRawBuffer.length,
1117
- terminalHistoryStart: this.terminalHistory.length,
1118
1106
  };
1119
- LOG.info('CLI', `[${this.cliType}] sendMessage turn scope buffer=${this.currentTurnScope.bufferStart} raw=${this.currentTurnScope.rawBufferStart} terminal=${this.currentTurnScope.terminalHistoryStart} prompt=${JSON.stringify(text).slice(0, 120)}`);
1107
+ LOG.info('CLI', `[${this.cliType}] sendMessage turn scope buffer=${this.currentTurnScope.bufferStart} raw=${this.currentTurnScope.rawBufferStart} prompt=${JSON.stringify(text).slice(0, 120)}`);
1120
1108
  this.submitRetryUsed = false;
1121
1109
  this.submitRetryPromptSnippet = extractPromptRetrySnippet(text);
1122
1110
  const normalizedPromptSnippet = normalizePromptText(this.submitRetryPromptSnippet);
@@ -1304,6 +1292,7 @@ export class ProviderCliAdapter implements CliAdapter {
1304
1292
  if (this.submitRetryTimer) { clearTimeout(this.submitRetryTimer); this.submitRetryTimer = null; }
1305
1293
  if (this.pendingOutputParseTimer) { clearTimeout(this.pendingOutputParseTimer); this.pendingOutputParseTimer = null; }
1306
1294
  this.pendingOutputParseBuffer = '';
1295
+ this.pendingTerminalQueryTail = '';
1307
1296
  if (this.ptyOutputFlushTimer) { clearTimeout(this.ptyOutputFlushTimer); this.ptyOutputFlushTimer = null; }
1308
1297
  this.ptyOutputBuffer = '';
1309
1298
  if (this.ptyProcess) {
@@ -1326,6 +1315,7 @@ export class ProviderCliAdapter implements CliAdapter {
1326
1315
  if (this.submitRetryTimer) { clearTimeout(this.submitRetryTimer); this.submitRetryTimer = null; }
1327
1316
  if (this.pendingOutputParseTimer) { clearTimeout(this.pendingOutputParseTimer); this.pendingOutputParseTimer = null; }
1328
1317
  this.pendingOutputParseBuffer = '';
1318
+ this.pendingTerminalQueryTail = '';
1329
1319
  if (this.ptyOutputFlushTimer) { clearTimeout(this.ptyOutputFlushTimer); this.ptyOutputFlushTimer = null; }
1330
1320
  this.ptyOutputBuffer = '';
1331
1321
  if (this.ptyProcess) {
@@ -1349,12 +1339,12 @@ export class ProviderCliAdapter implements CliAdapter {
1349
1339
  this.syncMessageViews();
1350
1340
  this.accumulatedBuffer = '';
1351
1341
  this.accumulatedRawBuffer = '';
1352
- this.terminalHistory = '';
1353
1342
  this.currentTurnScope = null;
1354
1343
  this.submitRetryUsed = false;
1355
1344
  this.submitRetryPromptSnippet = '';
1356
1345
  if (this.pendingOutputParseTimer) { clearTimeout(this.pendingOutputParseTimer); this.pendingOutputParseTimer = null; }
1357
1346
  this.pendingOutputParseBuffer = '';
1347
+ this.pendingTerminalQueryTail = '';
1358
1348
  if (this.ptyOutputFlushTimer) { clearTimeout(this.ptyOutputFlushTimer); this.ptyOutputFlushTimer = null; }
1359
1349
  this.ptyOutputBuffer = '';
1360
1350
  this.terminalScreen.reset();
@@ -1413,7 +1403,6 @@ export class ProviderCliAdapter implements CliAdapter {
1413
1403
  structuredMessages: this.structuredMessages.slice(-20),
1414
1404
  messageCount: this.committedMessages.length,
1415
1405
  screenText: sanitizeTerminalText(this.terminalScreen.getText()).slice(-4000),
1416
- terminalHistory: this.terminalHistory.slice(-8000),
1417
1406
  currentTurnScope: this.currentTurnScope,
1418
1407
  startupBuffer: this.startupBuffer.slice(-4000),
1419
1408
  recentOutputBuffer: this.recentOutputBuffer.slice(-500),
@@ -1441,4 +1430,24 @@ export class ProviderCliAdapter implements CliAdapter {
1441
1430
  ptyAlive: !!this.ptyProcess,
1442
1431
  };
1443
1432
  }
1433
+
1434
+ private respondToTerminalQueries(data: string): void {
1435
+ if (!this.ptyProcess || !data) return;
1436
+
1437
+ const combined = this.pendingTerminalQueryTail + data;
1438
+ const regex = /\x1b\[(\?)?6n/g;
1439
+ let match: RegExpExecArray | null;
1440
+
1441
+ while ((match = regex.exec(combined)) !== null) {
1442
+ const cursor = this.terminalScreen.getCursorPosition();
1443
+ const row = Math.max(1, (cursor.row | 0) + 1);
1444
+ const col = Math.max(1, (cursor.col | 0) + 1);
1445
+ const response = match[1]
1446
+ ? `\x1b[?${row};${col}R`
1447
+ : `\x1b[${row};${col}R`;
1448
+ this.ptyProcess.write(response);
1449
+ }
1450
+
1451
+ this.pendingTerminalQueryTail = computeTerminalQueryTail(combined);
1452
+ }
1444
1453
  }
@@ -37,6 +37,7 @@ export interface PtyRuntimeMetadata {
37
37
  export interface PtyRuntimeTransport {
38
38
  readonly pid: number;
39
39
  readonly ready: Promise<void>;
40
+ readonly terminalQueriesHandled?: boolean;
40
41
  write(data: string): void;
41
42
  resize(cols: number, rows: number): void;
42
43
  kill(): void;
@@ -53,6 +54,7 @@ export interface PtyTransportFactory {
53
54
 
54
55
  class NodePtyRuntimeTransport implements PtyRuntimeTransport {
55
56
  readonly ready = Promise.resolve();
57
+ readonly terminalQueriesHandled = false;
56
58
 
57
59
  constructor(private readonly handle: any) {}
58
60
 
@@ -28,6 +28,7 @@ interface SessionHostRuntimeOptions extends SessionHostPtyTransportFactoryOption
28
28
 
29
29
  class SessionHostRuntimeTransport implements PtyRuntimeTransport {
30
30
  readonly ready: Promise<void>;
31
+ readonly terminalQueriesHandled = true;
31
32
 
32
33
  private readonly client: SessionHostClient;
33
34
  private readonly dataCallbacks = new Set<(data: string) => void>();
@@ -8,6 +8,7 @@ type GhosttyVtTerminal = {
8
8
  write(data: string | Uint8Array): void;
9
9
  resize(cols: number, rows: number): void;
10
10
  formatPlainText(options?: { trim?: boolean }): string;
11
+ getCursorPosition(): { col: number; row: number };
11
12
  dispose(): void;
12
13
  };
13
14
 
@@ -123,6 +124,10 @@ export class GhosttyVtTerminalBackend implements TerminalViewportBackend {
123
124
  return this.terminal.formatPlainText({ trim: true }) || '';
124
125
  }
125
126
 
127
+ getCursorPosition(): { col: number; row: number } {
128
+ return this.terminal.getCursorPosition();
129
+ }
130
+
126
131
  dispose(): void {
127
132
  this.terminal.dispose();
128
133
  }
@@ -13,5 +13,6 @@ export interface TerminalViewportBackend {
13
13
  resize(rows: number, cols: number): void;
14
14
  write(data: string): void;
15
15
  getText(): string;
16
+ getCursorPosition(): { col: number; row: number };
16
17
  dispose(): void;
17
18
  }
@@ -7,6 +7,8 @@ type XtermBufferLine = {
7
7
  type XtermBuffer = {
8
8
  length: number;
9
9
  viewportY: number;
10
+ cursorX?: number;
11
+ cursorY?: number;
10
12
  getLine(index: number): XtermBufferLine | undefined;
11
13
  };
12
14
 
@@ -72,6 +74,14 @@ export class XtermTerminalBackend implements TerminalViewportBackend {
72
74
  return lines.slice(first, last).join('\n');
73
75
  }
74
76
 
77
+ getCursorPosition(): { col: number; row: number } {
78
+ const buffer = this.terminal.buffer.active;
79
+ return {
80
+ col: Math.max(0, buffer.cursorX || 0),
81
+ row: Math.max(0, buffer.cursorY || 0),
82
+ };
83
+ }
84
+
75
85
  dispose(): void {
76
86
  this.terminal.dispose();
77
87
  }
@@ -106,6 +106,10 @@ export class TerminalScreen {
106
106
  return this.terminal.getText();
107
107
  }
108
108
 
109
+ getCursorPosition(): { col: number; row: number } {
110
+ return this.terminal.getCursorPosition();
111
+ }
112
+
109
113
  dispose(): void {
110
114
  this.terminal.dispose();
111
115
  }
@@ -27,12 +27,10 @@ interface HistoryMessage {
27
27
  }
28
28
 
29
29
  export class ChatHistoryWriter {
30
- /** Last seen message count per agent (deduplication) */
30
+ /** Last seen message count per agent (deduplication) */
31
31
  private lastSeenCounts = new Map<string, number>();
32
- /** Last seen message hash per agent (deduplication) */
32
+ /** Last seen message hash per agent (deduplication) */
33
33
  private lastSeenHashes = new Map<string, Set<string>>();
34
- /** Last seen append-only terminal transcript per agent */
35
- private lastSeenTerminal = new Map<string, string>();
36
34
  private rotated = false;
37
35
 
38
36
  /**
@@ -109,60 +107,10 @@ export class ChatHistoryWriter {
109
107
  }
110
108
  }
111
109
 
112
- appendTerminalHistory(
113
- agentType: string,
114
- terminalHistory: string,
115
- sessionTitle?: string,
116
- instanceId?: string,
117
- ): void {
118
- const next = String(terminalHistory || '');
119
- if (!next.trim()) return;
120
-
121
- try {
122
- const dedupKey = instanceId ? `${agentType}:${instanceId}:terminal` : `${agentType}:terminal`;
123
- const prev = this.lastSeenTerminal.get(dedupKey) || '';
124
- if (prev === next) return;
125
-
126
- let delta = '';
127
- if (!prev) {
128
- delta = next;
129
- } else if (next.startsWith(prev)) {
130
- delta = next.slice(prev.length);
131
- } else if (prev.includes(next)) {
132
- this.lastSeenTerminal.set(dedupKey, next);
133
- return;
134
- } else {
135
- delta = `\n\n[terminal snapshot reset ${new Date().toISOString()} | ${sessionTitle || agentType}]\n${next}`;
136
- }
137
-
138
- if (!delta) {
139
- this.lastSeenTerminal.set(dedupKey, next);
140
- return;
141
- }
142
-
143
- const dir = path.join(HISTORY_DIR, this.sanitize(agentType));
144
- fs.mkdirSync(dir, { recursive: true });
145
-
146
- const date = new Date().toISOString().slice(0, 10);
147
- const filePrefix = instanceId ? `${this.sanitize(instanceId)}_` : '';
148
- const filePath = path.join(dir, `${filePrefix}${date}.terminal.log`);
149
- fs.appendFileSync(filePath, delta, 'utf-8');
150
- this.lastSeenTerminal.set(dedupKey, next);
151
-
152
- if (!this.rotated) {
153
- this.rotated = true;
154
- this.rotateOldFiles().catch(() => {});
155
- }
156
- } catch {
157
- // Ignore terminal history save failures
158
- }
159
- }
160
-
161
- /** Called when agent session is explicitly changed */
110
+ /** Called when agent session is explicitly changed */
162
111
  onSessionChange(agentType: string): void {
163
112
  this.lastSeenHashes.delete(agentType);
164
113
  this.lastSeenCounts.delete(agentType);
165
- this.lastSeenTerminal.delete(`${agentType}:terminal`);
166
114
  }
167
115
 
168
116
  /** Delete history files older than 30 days */
@@ -44,7 +44,7 @@ export class CliProviderInstance implements ProviderInstance {
44
44
  ) {
45
45
  this.type = provider.type;
46
46
  this.instanceId = instanceId || crypto.randomUUID();
47
- this.presentationMode = 'terminal';
47
+ this.presentationMode = 'chat';
48
48
  this.adapter = new ProviderCliAdapter(provider as any as CliProviderModule, workingDir, cliArgs, transportFactory);
49
49
  this.monitor = new StatusMonitor();
50
50
  this.historyWriter = new ChatHistoryWriter();
@@ -92,15 +92,6 @@ export class CliProviderInstance implements ProviderInstance {
92
92
 
93
93
  const dirName = this.workingDir.split('/').filter(Boolean).pop() || 'session';
94
94
 
95
- if (adapterStatus.terminalHistory?.trim()) {
96
- this.historyWriter.appendTerminalHistory(
97
- this.type,
98
- adapterStatus.terminalHistory,
99
- `${this.provider.name} · ${dirName}`,
100
- this.instanceId,
101
- );
102
- }
103
-
104
95
  return {
105
96
  type: this.type,
106
97
  name: this.provider.name,
@@ -113,7 +104,6 @@ export class CliProviderInstance implements ProviderInstance {
113
104
  status: parsedStatus?.status || adapterStatus.status,
114
105
  messages: Array.isArray(parsedStatus?.messages) ? parsedStatus.messages : [],
115
106
  activeModal: parsedStatus?.activeModal ?? adapterStatus.activeModal,
116
- terminalHistory: adapterStatus.terminalHistory,
117
107
  inputContent: '',
118
108
  },
119
109
  workspace: this.workingDir,
@@ -37,7 +37,6 @@ export interface ActiveChatData {
37
37
  message: string;
38
38
  buttons: string[];
39
39
  } | null;
40
- terminalHistory?: string;
41
40
  inputContent?: string;
42
41
  }
43
42
  /** Standardized error reasons across all provider categories */
@@ -42,7 +42,6 @@ export interface ActiveChatData {
42
42
  status: string;
43
43
  messages: ChatMessage[];
44
44
  activeModal: { message: string; buttons: string[] } | null;
45
- terminalHistory?: string;
46
45
  inputContent?: string;
47
46
  }
48
47
 
@@ -26,7 +26,6 @@ const STATUS_ACTIVE_CHAT_MESSAGE_LIMIT = 60;
26
26
  const STATUS_ACTIVE_CHAT_TOTAL_BYTES_LIMIT = 96 * 1024;
27
27
  const STATUS_ACTIVE_CHAT_STRING_LIMIT = 4 * 1024;
28
28
  const STATUS_ACTIVE_CHAT_FALLBACK_STRING_LIMIT = 1024;
29
- const STATUS_TERMINAL_HISTORY_LIMIT = 8 * 1024;
30
29
  const STATUS_INPUT_CONTENT_LIMIT = 2 * 1024;
31
30
  const STATUS_MODAL_MESSAGE_LIMIT = 2 * 1024;
32
31
  const STATUS_MODAL_BUTTON_LIMIT = 120;
@@ -139,9 +138,6 @@ export function normalizeActiveChatData<T extends ActiveChatData | null | undefi
139
138
  truncateString(String(button || ''), STATUS_MODAL_BUTTON_LIMIT)
140
139
  ),
141
140
  } : activeChat.activeModal,
142
- terminalHistory: activeChat.terminalHistory
143
- ? truncateStringTail(activeChat.terminalHistory, STATUS_TERMINAL_HISTORY_LIMIT)
144
- : activeChat.terminalHistory,
145
141
  inputContent: activeChat.inputContent
146
142
  ? truncateString(activeChat.inputContent, STATUS_INPUT_CONTENT_LIMIT)
147
143
  : activeChat.inputContent,