@adhdev/daemon-core 0.9.82-rc.90 → 0.9.82-rc.91

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@adhdev/daemon-core",
3
- "version": "0.9.82-rc.90",
3
+ "version": "0.9.82-rc.91",
4
4
  "description": "ADHDev daemon core — CDP, IDE detection, providers, command execution",
5
5
  "main": "dist/index.js",
6
6
  "types": "dist/index.d.ts",
@@ -396,6 +396,7 @@ function readCliProviderNativeHistory(agentStr: string, args: {
396
396
  excludeRecentCount: number;
397
397
  historyBehavior?: ProviderModule['historyBehavior'];
398
398
  scripts?: ProviderScripts;
399
+ exactSessionScoped?: boolean;
399
400
  }): ReturnType<typeof readProviderChatHistory> & { lookup: 'session' | 'workspace' } {
400
401
  const sessionHistory = readProviderChatHistory(agentStr, {
401
402
  canonicalHistory: args.canonicalHistory,
@@ -407,8 +408,12 @@ function readCliProviderNativeHistory(agentStr: string, args: {
407
408
  historyBehavior: args.historyBehavior,
408
409
  scripts: args.scripts as any,
409
410
  });
410
- if ((sessionHistory as any).source !== 'native-unavailable' || !args.historySessionId || !args.workspace) {
411
- return { ...(sessionHistory as any), lookup: 'session' };
411
+ // Exact runtime/provider transcript reads must not silently fall back to the
412
+ // workspace's active or most recent native transcript: multiple Hermes/Gemini/
413
+ // Codex sessions can run in the same workspace, and workspace fallback can make
414
+ // read_chat/completion evidence point at a different runtime's prompt.
415
+ if ((sessionHistory as any).source !== 'native-unavailable' || args.exactSessionScoped || !args.historySessionId || !args.workspace) {
416
+ return { ...(sessionHistory as any), lookup: args.historySessionId ? 'session' : 'workspace' };
412
417
  }
413
418
  const workspaceHistory = readProviderChatHistory(agentStr, {
414
419
  canonicalHistory: args.canonicalHistory,
@@ -1163,6 +1168,12 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
1163
1168
  returnedMessages.length,
1164
1169
  200,
1165
1170
  );
1171
+ const exactNativeHistoryScope = Boolean(
1172
+ (typeof args?.historySessionId === 'string' && args.historySessionId.trim())
1173
+ || (typeof args?.providerSessionId === 'string' && args.providerSessionId.trim())
1174
+ || providerSessionId
1175
+ || ((h.currentSession as any)?.sessionId === args?.targetSessionId && typeof (h.currentSession as any)?.providerSessionId === 'string' && (h.currentSession as any).providerSessionId.trim())
1176
+ );
1166
1177
  let nativeHistory: (ReturnType<typeof readProviderChatHistory> & { lookup?: 'session' | 'workspace' }) | null = null;
1167
1178
  try {
1168
1179
  nativeHistory = readCliProviderNativeHistory(agentStr, {
@@ -1174,6 +1185,7 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
1174
1185
  excludeRecentCount: 0,
1175
1186
  historyBehavior: provider?.historyBehavior,
1176
1187
  scripts: provider?.scripts as any,
1188
+ exactSessionScoped: exactNativeHistoryScope,
1177
1189
  });
1178
1190
  } catch (error: any) {
1179
1191
  const fallbackReason = `native_history_error:${error?.message || String(error)}`;
@@ -1286,6 +1298,11 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
1286
1298
  : typeof (h.currentSession as any)?.workspace === 'string'
1287
1299
  ? (h.currentSession as any).workspace
1288
1300
  : undefined;
1301
+ const exactNativeHistoryScope = Boolean(
1302
+ (typeof args?.historySessionId === 'string' && args.historySessionId.trim())
1303
+ || (typeof args?.providerSessionId === 'string' && args.providerSessionId.trim())
1304
+ || ((h.currentSession as any)?.sessionId === args?.targetSessionId && typeof (h.currentSession as any)?.providerSessionId === 'string' && (h.currentSession as any).providerSessionId.trim())
1305
+ );
1289
1306
  const history = supportsCliNativeTranscript(agentStr, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory)
1290
1307
  ? readCliProviderNativeHistory(agentStr, {
1291
1308
  canonicalHistory: provider?.canonicalHistory,
@@ -1296,6 +1313,7 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
1296
1313
  excludeRecentCount: 0,
1297
1314
  historyBehavior: provider?.historyBehavior,
1298
1315
  scripts: provider?.scripts as any,
1316
+ exactSessionScoped: exactNativeHistoryScope,
1299
1317
  })
1300
1318
  : readProviderChatHistory(agentStr, {
1301
1319
  canonicalHistory: provider?.canonicalHistory,
@@ -80,7 +80,19 @@ function sessionStatusFromNodes(nodes: any[] | undefined, nodeId?: string, sessi
80
80
  if (!node) return { staleReason: 'direct task node is no longer in the live mesh' };
81
81
  if (!sessionId) return {};
82
82
  const candidates: any[] = [];
83
- for (const value of [node.sessions, node.activeSessions, node.active_sessions, node.lastProbe?.sessions, node.last_probe?.sessions, node.lastProbe?.status?.sessions, node.last_probe?.status?.sessions]) {
83
+ for (const value of [
84
+ node.sessions,
85
+ node.activeSessions,
86
+ node.active_sessions,
87
+ node.activeSessionDetails,
88
+ node.active_session_details,
89
+ node.sessionDetails,
90
+ node.session_details,
91
+ node.lastProbe?.sessions,
92
+ node.last_probe?.sessions,
93
+ node.lastProbe?.status?.sessions,
94
+ node.last_probe?.status?.sessions,
95
+ ]) {
84
96
  if (Array.isArray(value)) candidates.push(...value);
85
97
  }
86
98
  for (const value of [node.activeSession, node.active_session, node.currentSession, node.current_session, node.runtimeSession, node.runtime_session, node.session]) {
@@ -20,17 +20,10 @@ export function extractFinalSummaryFromMessages(
20
20
  }
21
21
  }
22
22
 
23
- // Fallback: last user-facing message of any role
24
- for (let i = messages.length - 1; i >= 0; i--) {
25
- const msg = messages[i];
26
- if (!msg) continue;
27
- const classification = classifyChatMessageVisibility(msg);
28
- if (classification.isUserFacing) {
29
- const text = flattenContent(msg.content).trim();
30
- if (text) return text.slice(0, maxChars);
31
- }
32
- }
33
-
23
+ // Completion summaries must describe the assistant/model result. If no
24
+ // user-facing assistant/model message exists yet (for example, only the
25
+ // dispatched user prompt is visible), return empty instead of echoing the
26
+ // prompt as a misleading finalSummary.
34
27
  return '';
35
28
  }
36
29
 
@@ -521,6 +521,7 @@ export class CliProviderInstance implements ProviderInstance {
521
521
  }
522
522
  const runtime = this.adapter.getRuntimeMetadata();
523
523
  this.maybeAppendRuntimeRecoveryMessage(runtime);
524
+ const activeChatId = this.providerSessionId || runtime?.runtimeId || this.instanceId;
524
525
  let parsedMessages = Array.isArray(parsedStatus?.messages)
525
526
  ? parsedStatus.messages
526
527
  : [];
@@ -597,7 +598,7 @@ export class CliProviderInstance implements ProviderInstance {
597
598
  status: visibleStatus,
598
599
  mode: this.presentationMode,
599
600
  activeChat: {
600
- id: `${this.type}_${this.workingDir}`,
601
+ id: activeChatId,
601
602
  title: parsedStatus?.title || dirName,
602
603
  status: activeChatStatus,
603
604
  messages: mergedMessages,