@adhdev/daemon-core 0.7.42 → 0.7.44

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 (39) 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/commands/upgrade-helper.d.ts +10 -0
  8. package/dist/config/chat-history.d.ts +0 -3
  9. package/dist/index.d.ts +1 -0
  10. package/dist/index.js +509 -364
  11. package/dist/index.js.map +1 -1
  12. package/dist/index.mjs +497 -353
  13. package/dist/index.mjs.map +1 -1
  14. package/dist/providers/provider-instance.d.ts +0 -1
  15. package/dist/status/normalize.js +0 -7
  16. package/dist/status/normalize.js.map +1 -1
  17. package/dist/status/normalize.mjs +0 -7
  18. package/dist/status/normalize.mjs.map +1 -1
  19. package/node_modules/@adhdev/session-host-core/dist/index.js +2 -2
  20. package/node_modules/@adhdev/session-host-core/dist/index.js.map +1 -1
  21. package/node_modules/@adhdev/session-host-core/dist/index.mjs +2 -2
  22. package/node_modules/@adhdev/session-host-core/dist/index.mjs.map +1 -1
  23. package/node_modules/@adhdev/session-host-core/package.json +1 -1
  24. package/package.json +1 -1
  25. package/src/cli-adapters/provider-cli-adapter.ts +79 -70
  26. package/src/cli-adapters/pty-transport.ts +2 -0
  27. package/src/cli-adapters/session-host-transport.ts +1 -0
  28. package/src/cli-adapters/terminal-backends/ghostty-vt-backend.ts +5 -0
  29. package/src/cli-adapters/terminal-backends/types.ts +1 -0
  30. package/src/cli-adapters/terminal-backends/xterm-backend.ts +10 -0
  31. package/src/cli-adapters/terminal-screen.ts +4 -0
  32. package/src/commands/router.ts +29 -23
  33. package/src/commands/upgrade-helper.ts +214 -0
  34. package/src/config/chat-history.ts +3 -55
  35. package/src/index.ts +1 -0
  36. package/src/providers/cli-provider-instance.ts +1 -11
  37. package/src/providers/provider-instance.d.ts +0 -1
  38. package/src/providers/provider-instance.ts +0 -1
  39. package/src/status/normalize.ts +0 -4
@@ -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 */
package/src/index.ts CHANGED
@@ -89,6 +89,7 @@ export { DaemonCommandHandler } from './commands/handler.js';
89
89
  export type { CommandResult, CommandContext } from './commands/handler.js';
90
90
  export { DaemonCommandRouter } from './commands/router.js';
91
91
  export type { CommandRouterDeps, CommandRouterResult } from './commands/router.js';
92
+ export { maybeRunDaemonUpgradeHelperFromEnv } from './commands/upgrade-helper.js';
92
93
 
93
94
  // ── Status ──
94
95
  export { DaemonStatusReporter } from './status/reporter.js';
@@ -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,