@adhdev/daemon-core 0.9.82-rc.118 → 0.9.82-rc.119

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.118",
3
+ "version": "0.9.82-rc.119",
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",
@@ -26,6 +26,11 @@ const RECENT_SEND_WINDOW_MS = 1200;
26
26
  export const READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25_000;
27
27
  const HERMES_CLI_STARTING_SEND_SETTLE_MS = 2_000;
28
28
  const CLI_NATIVE_HISTORY_FRESH_MS = 5 * 60_000;
29
+ // Fallback list for supportsCliNativeTranscript() when the ProviderModule is
30
+ // unavailable (e.g. provider config not yet loaded). The authoritative check is
31
+ // provider.canonicalHistory via isNativeSourceCanonicalHistory(). New providers
32
+ // with native transcripts should set canonicalHistory in their provider.json
33
+ // rather than adding entries here.
29
34
  const CLI_NATIVE_TRANSCRIPT_PROVIDERS = new Set(['codex-cli', 'claude-cli', 'hermes-cli', 'antigravity-cli']);
30
35
  const recentSendByTarget = new Map<string, number>();
31
36
 
@@ -471,15 +476,20 @@ function hasSafeNativeHistoryMapping(args: {
471
476
  return messageSessionIds.some((id) => id === explicitSessionId);
472
477
  }
473
478
 
479
+ // Messages carry no historySessionId — cannot confirm they belong to the requested session.
480
+ // Only allow a coordinator transcript that is also confirmed by the PTY side; otherwise
481
+ // fail closed so a same-workspace session's history is never silently accepted.
474
482
  if (isCoordinatorTranscript && args.ptyMessages && args.ptyMessages.length > 0) {
475
483
  const ptyHasCoordinator = args.ptyMessages.some((m: any) => {
476
484
  const text = typeof m?.content === 'string' ? m.content : JSON.stringify(m?.content || '');
477
485
  return text.includes('mesh_send_task') || text.includes('mesh_status') || text.includes('mesh_read_chat');
478
486
  });
479
- if (!ptyHasCoordinator) {
480
- return false;
481
- }
487
+ return ptyHasCoordinator;
482
488
  }
489
+
490
+ // No historySessionId in messages and no coordinator cross-check: fail closed.
491
+ // Workspace-only matching must not override an explicit session identity.
492
+ return false;
483
493
  }
484
494
  const workspace = String(args.workspace || '').trim();
485
495
  if (!workspace) return false;
@@ -500,6 +510,11 @@ function hasSafeNativeHistoryMapping(args: {
500
510
  return hasOverlappingVisibleConversationText(args.nativeMessages, args.ptyMessages || []);
501
511
  }
502
512
 
513
+ // Provenance boundary: workspace-only native history lookup is never safe
514
+ // because multiple concurrent sessions sharing the same cwd would alias each
515
+ // other. historySessionId (the provider-native session key) is required to
516
+ // establish ownership. hasSafeNativeHistoryMapping() enforces the same
517
+ // invariant after the read; both guards must hold for native history to be used.
503
518
  function readCliProviderNativeHistory(agentStr: string, args: {
504
519
  canonicalHistory?: ProviderModule['canonicalHistory'];
505
520
  historySessionId?: string;
@@ -509,7 +524,6 @@ function readCliProviderNativeHistory(agentStr: string, args: {
509
524
  excludeRecentCount: number;
510
525
  historyBehavior?: ProviderModule['historyBehavior'];
511
526
  scripts?: ProviderScripts;
512
- exactSessionScoped?: boolean;
513
527
  }): ReturnType<typeof readProviderChatHistory> & { lookup: 'session' | 'workspace' } {
514
528
  if (!args.historySessionId) {
515
529
  return {
@@ -1220,7 +1234,6 @@ export async function handleChatHistory(h: CommandHelpers, args: any): Promise<C
1220
1234
  excludeRecentCount,
1221
1235
  historyBehavior: provider?.historyBehavior,
1222
1236
  scripts: provider?.scripts as any,
1223
- exactSessionScoped: exactNativeHistoryScope,
1224
1237
  })
1225
1238
  : readProviderChatHistory(agentStr, {
1226
1239
  canonicalHistory: provider?.canonicalHistory,
@@ -1360,7 +1373,6 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
1360
1373
  excludeRecentCount: 0,
1361
1374
  historyBehavior: provider?.historyBehavior,
1362
1375
  scripts: provider?.scripts as any,
1363
- exactSessionScoped: exactNativeHistoryScope,
1364
1376
  });
1365
1377
  } catch (error: any) {
1366
1378
  const fallbackReason = `native_history_error:${error?.message || String(error)}`;
@@ -1526,7 +1538,6 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
1526
1538
  excludeRecentCount: 0,
1527
1539
  historyBehavior: provider?.historyBehavior,
1528
1540
  scripts: provider?.scripts as any,
1529
- exactSessionScoped: exactNativeHistoryScope,
1530
1541
  })
1531
1542
  : readProviderChatHistory(agentStr, {
1532
1543
  canonicalHistory: provider?.canonicalHistory,