@adhdev/daemon-core 0.7.46 → 0.8.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.
@@ -11,6 +11,7 @@ import type { PtyRuntimeMetadata, PtyRuntimeTransport, PtySpawnOptions, PtyTrans
11
11
  interface SessionHostPtyTransportFactoryOptions {
12
12
  endpoint?: SessionHostEndpoint;
13
13
  appName?: string;
14
+ ensureReady?: () => Promise<void>;
14
15
  clientId: string;
15
16
  runtimeId: string;
16
17
  providerType: string;
@@ -191,7 +192,18 @@ class SessionHostRuntimeTransport implements PtyRuntimeTransport {
191
192
  }
192
193
 
193
194
  private async boot(): Promise<void> {
194
- await this.client.connect();
195
+ if (typeof this.options.ensureReady === 'function') {
196
+ await this.options.ensureReady();
197
+ }
198
+ try {
199
+ await this.client.connect();
200
+ } catch (error) {
201
+ if (typeof this.options.ensureReady !== 'function') {
202
+ throw error;
203
+ }
204
+ await this.options.ensureReady();
205
+ await this.client.connect();
206
+ }
195
207
  this.unsubscribe = this.client.onEvent((event: SessionHostEvent) => this.handleEvent(event));
196
208
 
197
209
  let record: SessionHostRecord | null = null;
@@ -23,6 +23,13 @@ function getTargetedCliAdapter(h: CommandHelpers, args: any, providerType?: stri
23
23
  return h.getCliAdapter(args?.targetSessionId || providerType || h.currentSession?.providerType || h.currentManagerKey);
24
24
  }
25
25
 
26
+ function getTargetInstance(h: CommandHelpers, args: any) {
27
+ const targetSessionId = typeof args?.targetSessionId === 'string' ? args.targetSessionId.trim() : '';
28
+ const sessionId = targetSessionId || h.currentSession?.sessionId || '';
29
+ if (!sessionId) return null;
30
+ return h.ctx.instanceManager?.getInstance(sessionId) as any;
31
+ }
32
+
26
33
  function getTargetTransport(h: CommandHelpers, provider?: any): SessionTransport | null {
27
34
  if (h.currentSession?.transport) return h.currentSession.transport;
28
35
  switch (provider?.category) {
@@ -781,6 +788,7 @@ export async function handleResolveAction(h: CommandHelpers, args: any): Promise
781
788
  (adapter as any).writeRaw?.(keys);
782
789
  }
783
790
  LOG.info('Command', `[resolveAction] CLI PTY → buttonIndex=${buttonIndex} "${buttons[buttonIndex] ?? '?'}"`);
791
+ getTargetInstance(h, args)?.recordApprovalSelection?.(buttons[buttonIndex] ?? button);
784
792
  return { success: true, buttonIndex, button: buttons[buttonIndex] ?? button };
785
793
  }
786
794
 
@@ -22,6 +22,7 @@ interface HistoryMessage {
22
22
  role: 'user' | 'assistant' | 'system';
23
23
  content: string;
24
24
  kind?: string;
25
+ senderName?: string;
25
26
  agent: string; // e.g. 'antigravity', 'cursor', 'gemini-cli'
26
27
  instanceId?: string; // IDE instance UUID (distinguishes windows of the same agent type)
27
28
  historySessionId?: string; // Persistent provider-side conversation/session key
@@ -54,7 +55,7 @@ export class ChatHistoryWriter {
54
55
  */
55
56
  appendNewMessages(
56
57
  agentType: string,
57
- messages: Array<{ role: string; content: string; receivedAt?: number; kind?: string; historyDedupKey?: string }>,
58
+ messages: Array<{ role: string; content: string; receivedAt?: number; kind?: string; senderName?: string; historyDedupKey?: string }>,
58
59
  sessionTitle?: string,
59
60
  instanceId?: string,
60
61
  historySessionId?: string,
@@ -83,6 +84,7 @@ export class ChatHistoryWriter {
83
84
  role: msg.role as 'user' | 'assistant' | 'system',
84
85
  content: msg.content || '',
85
86
  kind: typeof msg.kind === 'string' ? msg.kind : undefined,
87
+ senderName: typeof msg.senderName === 'string' ? msg.senderName : undefined,
86
88
  agent: agentType,
87
89
  instanceId,
88
90
  historySessionId: effectiveHistoryKey,
@@ -131,6 +133,7 @@ export class ChatHistoryWriter {
131
133
  historySessionId?: string;
132
134
  dedupKey?: string;
133
135
  receivedAt?: number;
136
+ senderName?: string;
134
137
  } = {},
135
138
  ): void {
136
139
  this.appendNewMessages(
@@ -140,6 +143,7 @@ export class ChatHistoryWriter {
140
143
  kind: 'system',
141
144
  content,
142
145
  receivedAt: options.receivedAt,
146
+ senderName: options.senderName,
143
147
  historyDedupKey: options.dedupKey,
144
148
  }],
145
149
  options.sessionTitle,
@@ -69,7 +69,7 @@ export interface ADHDevConfig {
69
69
  * Server-side D1 `machines.id` — the row ID assigned when daemon registers via
70
70
  * `POST /cli/complete`. Used as fallback for machine lookup on re-auth.
71
71
  *
72
- * @deprecated Legacy bridge field — will be removed after 2026-04-06.
72
+ * @deprecated Legacy bridge field — will be removed after 2026-05-01.
73
73
  * Modern auth flow uses `machineSecret` (adm_) to identify machines.
74
74
  */
75
75
  registeredMachineId?: string;
@@ -193,7 +193,7 @@ function ensureMachineId(config: ADHDevConfig): { config: ADHDevConfig; changed:
193
193
  return { config, changed: false };
194
194
  }
195
195
 
196
- // TODO(2026-04-06): Remove this legacy bridge after cloud clients have had
196
+ // TODO(2026-05-01): Remove this legacy bridge after cloud clients have had
197
197
  // time to persist registeredMachineId from the upgraded setup/login flow.
198
198
  const legacyRegisteredMachineId = (!config.registeredMachineId && config.machineSecret && config.machineId)
199
199
  ? config.machineId