@adhdev/daemon-core 0.9.82-rc.124 → 0.9.82-rc.126

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.124",
3
+ "version": "0.9.82-rc.126",
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",
@@ -354,6 +354,9 @@ function buildCliMessageSourceProvenance(args: {
354
354
  selected: 'native-history' | 'pty-parser';
355
355
  provider: string;
356
356
  nativeHandle?: string;
357
+ sessionWorkspace?: string;
358
+ intendedWorkspace?: string;
359
+ transcriptWorkspace?: string;
357
360
  fallbackReason?: string;
358
361
  nativeSource?: string;
359
362
  sourcePath?: string;
@@ -373,12 +376,23 @@ function buildCliMessageSourceProvenance(args: {
373
376
  const nativeMessages = args.nativeMessages || [];
374
377
  const ptyMessages = args.ptyMessages || [];
375
378
  const returnedMessages = args.returnedMessages || [];
379
+ const identityStatus = args.selected === 'native-history'
380
+ ? 'safe'
381
+ : args.fallbackReason === 'native_history_not_safely_mapped'
382
+ ? 'ambiguous_session_identity'
383
+ : args.fallbackReason?.startsWith('native_history_unavailable')
384
+ ? 'transcript_unmapped'
385
+ : undefined;
376
386
  return {
377
387
  selected: args.selected,
378
388
  provider: args.provider,
379
389
  providerType: args.provider,
390
+ ...(identityStatus ? { identityStatus } : {}),
380
391
  ...(args.nativeHandle ? { nativeHandle: args.nativeHandle } : {}),
381
392
  ...(args.nativeHandle ? { nativeSessionId: args.nativeHandle } : {}),
393
+ ...(args.sessionWorkspace ? { sessionWorkspace: args.sessionWorkspace } : {}),
394
+ ...(args.intendedWorkspace ? { intendedWorkspace: args.intendedWorkspace } : {}),
395
+ ...(args.transcriptWorkspace ? { transcriptWorkspace: args.transcriptWorkspace } : {}),
382
396
  ...(args.fallbackReason ? { fallbackReason: args.fallbackReason } : {}),
383
397
  ...(args.nativeSource ? { nativeSource: args.nativeSource } : {}),
384
398
  ...(args.sourcePath ? { sourcePath: args.sourcePath } : {}),
@@ -398,6 +412,9 @@ function buildCliMessageSourceProvenance(args: {
398
412
  ptyMessageCount: ptyMessages.length,
399
413
  returnedMessageCount: returnedMessages.length,
400
414
  safeMapping: args.safeMapping === true,
415
+ // true when native-history was selected: PTY message bodies are suppressed and
416
+ // must not be treated as chat content. PTY only contributes status/approval/screen evidence.
417
+ ptyMessagesSuppressed: args.selected === 'native-history',
401
418
  },
402
419
  };
403
420
  }
@@ -1052,7 +1069,14 @@ export async function handleGetChatDebugBundle(h: CommandHelpers, args: any): Pr
1052
1069
  messagesTail: Array.isArray(readResult.messages) ? readResult.messages.slice(-20) : [],
1053
1070
  debugReadChat: readResult.debugReadChat,
1054
1071
  }
1055
- : { success: false, error: readResult.error };
1072
+ : {
1073
+ success: false,
1074
+ error: readResult.error,
1075
+ code: readResult.code,
1076
+ messageSource: readResult.messageSource,
1077
+ transcriptProvenance: readResult.transcriptProvenance,
1078
+ debugReadChat: readResult.debugReadChat,
1079
+ };
1056
1080
  } catch (error: any) {
1057
1081
  readChat = { success: false, error: error?.message || String(error) };
1058
1082
  }
@@ -1330,10 +1354,18 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
1330
1354
  let selectedProviderSessionId = providerSessionId;
1331
1355
  let selectedTranscriptAuthority = transcriptAuthority;
1332
1356
  let selectedCoverage = coverage;
1357
+ const sessionWorkspace = typeof (h.currentSession as any)?.workspace === 'string'
1358
+ ? (h.currentSession as any).workspace
1359
+ : typeof adapter.workingDir === 'string'
1360
+ ? adapter.workingDir
1361
+ : undefined;
1362
+ const intendedWorkspace = typeof args?.workspace === 'string' ? args.workspace : undefined;
1333
1363
  let messageSource = buildCliMessageSourceProvenance({
1334
1364
  selected: 'pty-parser',
1335
1365
  provider: adapter.cliType,
1336
1366
  fallbackReason: supportsCliNativeTranscript(providerType, provider) ? 'native_history_not_checked' : 'provider_native_transcript_not_supported',
1367
+ sessionWorkspace,
1368
+ intendedWorkspace,
1337
1369
  ptyMessages: returnedMessages,
1338
1370
  returnedMessages,
1339
1371
  ptyStatusApprovalOnly: false,
@@ -1341,13 +1373,7 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
1341
1373
 
1342
1374
  if (supportsCliNativeTranscript(providerType, provider) && isNativeSourceCanonicalHistory(provider?.canonicalHistory)) {
1343
1375
  const agentStr = provider?.type || args?.agentType || getCurrentProviderType(h, adapter.cliType);
1344
- const workspace = typeof args?.workspace === 'string'
1345
- ? args.workspace
1346
- : typeof (h.currentSession as any)?.workspace === 'string'
1347
- ? (h.currentSession as any).workspace
1348
- : typeof adapter.workingDir === 'string'
1349
- ? adapter.workingDir
1350
- : undefined;
1376
+ const workspace = sessionWorkspace;
1351
1377
  const nativeHistoryLimit = Math.max(
1352
1378
  normalizeReadChatTailLimit(args) || 0,
1353
1379
  returnedMessages.length,
@@ -1380,6 +1406,8 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
1380
1406
  selected: 'pty-parser',
1381
1407
  provider: adapter.cliType,
1382
1408
  fallbackReason,
1409
+ sessionWorkspace,
1410
+ intendedWorkspace,
1383
1411
  ptyMessages: returnedMessages,
1384
1412
  returnedMessages,
1385
1413
  ptyStatusApprovalOnly: false,
@@ -1404,6 +1432,9 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
1404
1432
  ? (nativeHistory as any).unavailableReason
1405
1433
  : undefined;
1406
1434
  const lookup = (nativeHistory as any).lookup === 'workspace' ? 'workspace' : 'session';
1435
+ const transcriptWorkspace = typeof (nativeHistory as any)?.workspace === 'string'
1436
+ ? (nativeHistory as any).workspace
1437
+ : nativeMessages.map((message: any) => typeof message?.workspace === 'string' ? message.workspace.trim() : '').find(Boolean);
1407
1438
  const nativeHistorySessionForMapping = adapter.cliType === 'antigravity-cli'
1408
1439
  && historyProviderSessionId
1409
1440
  && nativeHistorySessionId
@@ -1438,6 +1469,9 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
1438
1469
  selected: 'native-history',
1439
1470
  provider: adapter.cliType,
1440
1471
  nativeHandle: selectedProviderSessionId || nativeHistorySessionId || historySessionId,
1472
+ sessionWorkspace,
1473
+ intendedWorkspace,
1474
+ transcriptWorkspace,
1441
1475
  nativeSource: (nativeHistory as any).source,
1442
1476
  sourcePath: (nativeHistory as any).sourcePath,
1443
1477
  sourceMtimeMs: (nativeHistory as any).sourceMtimeMs,
@@ -1466,6 +1500,9 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
1466
1500
  selected: 'pty-parser',
1467
1501
  provider: adapter.cliType,
1468
1502
  nativeHandle: historyProviderSessionId || nativeHistorySessionId || historySessionId,
1503
+ sessionWorkspace,
1504
+ intendedWorkspace,
1505
+ transcriptWorkspace,
1469
1506
  fallbackReason,
1470
1507
  nativeSource: (nativeHistory as any).source,
1471
1508
  sourcePath: (nativeHistory as any).sourcePath,
@@ -1517,11 +1554,10 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
1517
1554
  const historyLimit = normalizeReadChatTailLimit(args);
1518
1555
  try {
1519
1556
  const agentStr = provider?.type || args?.agentType || getCurrentProviderType(h);
1520
- const workspace = typeof args?.workspace === 'string'
1521
- ? args.workspace
1522
- : typeof (h.currentSession as any)?.workspace === 'string'
1523
- ? (h.currentSession as any).workspace
1524
- : undefined;
1557
+ const workspace = typeof (h.currentSession as any)?.workspace === 'string'
1558
+ ? (h.currentSession as any).workspace
1559
+ : undefined;
1560
+ const intendedWorkspace = typeof args?.workspace === 'string' ? args.workspace : undefined;
1525
1561
  const exactNativeHistoryScope = Boolean(
1526
1562
  (typeof args?.targetSessionId === 'string' && args.targetSessionId.trim())
1527
1563
  || (typeof args?.historySessionId === 'string' && args.historySessionId.trim())
@@ -1565,6 +1601,9 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
1565
1601
  const unavailableReason = typeof (history as any)?.unavailableReason === 'string'
1566
1602
  ? (history as any).unavailableReason
1567
1603
  : undefined;
1604
+ const transcriptWorkspace = typeof (history as any)?.workspace === 'string'
1605
+ ? (history as any).workspace
1606
+ : historyMessages.map((message: any) => typeof message?.workspace === 'string' ? message.workspace.trim() : '').find(Boolean);
1568
1607
  const safeMapping = supportsCliNativeTranscript(agentStr, provider)
1569
1608
  ? hasSafeNativeHistoryMapping({
1570
1609
  historySessionId: lookup === 'workspace' ? undefined : historySessionId,
@@ -1583,6 +1622,9 @@ export async function handleReadChat(h: CommandHelpers, args: any): Promise<Comm
1583
1622
  selected: nativeSelected ? 'native-history' : 'pty-parser',
1584
1623
  provider: agentStr,
1585
1624
  nativeHandle: historyProviderSessionId || historySessionId,
1625
+ sessionWorkspace: workspace,
1626
+ intendedWorkspace,
1627
+ transcriptWorkspace,
1586
1628
  fallbackReason: nativeSelected
1587
1629
  ? undefined
1588
1630
  : buildNativeHistoryFallbackReason({
@@ -216,6 +216,9 @@ export function buildMeshActiveWork(opts: BuildMeshActiveWorkOptions): { activeW
216
216
  const live = sessionStatusFromNodes(opts.nodes, dispatch.nodeId, dispatch.sessionId);
217
217
  const status = terminalStatus || live.status || 'assigned';
218
218
  const terminalRow = Boolean(terminal && terminal.kind !== 'task_approval_needed');
219
+ const ledgerOnlyStaleReason = !terminalRow && (status === 'idle' || (!terminalStatus && !live.status))
220
+ ? 'direct task dispatch has no provider acknowledgement, transcript append, or active runtime transition'
221
+ : undefined;
219
222
  const message = readString(dispatch.payload?.message) || readString(dispatch.payload?.summary) || '';
220
223
  const { title, summary } = summarizeMessage(message);
221
224
  const record: MeshActiveWorkRecord = {
@@ -236,13 +239,13 @@ export function buildMeshActiveWork(opts: BuildMeshActiveWorkOptions): { activeW
236
239
  terminal: terminalRow,
237
240
  terminalKind: terminal?.kind,
238
241
  terminalAt: terminal?.timestamp,
239
- staleReason: live.staleReason,
242
+ staleReason: live.staleReason || ledgerOnlyStaleReason,
240
243
  };
241
244
  if (terminalRow) {
242
245
  terminalDirectWork.push(record);
243
246
  if (opts.includeTerminalDirect !== true) continue;
244
247
  }
245
- if (live.staleReason && !terminalRow) {
248
+ if ((live.staleReason || ledgerOnlyStaleReason) && !terminalRow) {
246
249
  staleDirectWork.push(record);
247
250
  continue;
248
251
  }