@adhdev/daemon-core 0.9.82-rc.472 → 0.9.82-rc.474

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/dist/index.mjs CHANGED
@@ -404,10 +404,10 @@ function readInjected(value) {
404
404
  }
405
405
  function getDaemonBuildInfo() {
406
406
  if (cached) return cached;
407
- const commit = readInjected(true ? "3563c068056c972d63702c08865d51e377c78b53" : void 0) ?? "unknown";
408
- const commitShort = readInjected(true ? "3563c068" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
409
- const version = readInjected(true ? "0.9.82-rc.472" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
410
- const builtAt = readInjected(true ? "2026-07-06T00:24:19.478Z" : void 0);
407
+ const commit = readInjected(true ? "cfb46b13fb8f556e4cb7179c4503ac3c86923d92" : void 0) ?? "unknown";
408
+ const commitShort = readInjected(true ? "cfb46b13" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
409
+ const version = readInjected(true ? "0.9.82-rc.474" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
410
+ const builtAt = readInjected(true ? "2026-07-06T03:34:46.223Z" : void 0);
411
411
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
412
412
  return cached;
413
413
  }
@@ -9122,6 +9122,8 @@ var mesh_missions_exports = {};
9122
9122
  __export(mesh_missions_exports, {
9123
9123
  COMPACT_STATUS_GOAL_PREVIEW_MAX: () => COMPACT_STATUS_GOAL_PREVIEW_MAX,
9124
9124
  GOAL_PREVIEW_MAX: () => GOAL_PREVIEW_MAX,
9125
+ MESH_MISSION_LIST_HISTORY_ID_LIMIT: () => MESH_MISSION_LIST_HISTORY_ID_LIMIT,
9126
+ MESH_MISSION_LIST_STATUS_LIMIT: () => MESH_MISSION_LIST_STATUS_LIMIT,
9125
9127
  MESH_MISSION_STATUSES: () => MESH_MISSION_STATUSES,
9126
9128
  buildMissionPromptSection: () => buildMissionPromptSection,
9127
9129
  getActiveMeshMissionSummaries: () => getActiveMeshMissionSummaries,
@@ -9131,6 +9133,7 @@ __export(mesh_missions_exports, {
9131
9133
  getMeshStatusMissionsCompact: () => getMeshStatusMissionsCompact,
9132
9134
  isMissionAllTasksTerminal: () => isMissionAllTasksTerminal,
9133
9135
  listMeshMissionSummaries: () => listMeshMissionSummaries,
9136
+ listMeshMissionsForTool: () => listMeshMissionsForTool,
9134
9137
  maybeEmitMissionCloseCandidate: () => maybeEmitMissionCloseCandidate,
9135
9138
  summarizeMeshMission: () => summarizeMeshMission,
9136
9139
  summarizeMissionTasks: () => summarizeMissionTasks,
@@ -9364,6 +9367,61 @@ function listMeshMissionSummaries(meshId, options) {
9364
9367
  const full = missions.map((mission) => summarizeMeshMission(meshId, mission));
9365
9368
  return options?.verbose ? full : full.map((summary) => slimMissionSummary(summary));
9366
9369
  }
9370
+ function listMeshMissionsForTool(meshId, options) {
9371
+ const explicitStatuses = options?.statuses && options.statuses.length > 0 ? options.statuses : void 0;
9372
+ const includeMagi = options?.includeMagi === true;
9373
+ const verbose = options?.verbose === true;
9374
+ const withStats = options?.withStats === true;
9375
+ const limit = Math.max(1, options?.limit ?? MESH_MISSION_LIST_STATUS_LIMIT);
9376
+ const historyIdLimit = Math.max(0, options?.historyIdLimit ?? MESH_MISSION_LIST_HISTORY_ID_LIMIT);
9377
+ const passesMagi = (m) => includeMagi || !(m.source === "magi" && m.status === "completed");
9378
+ const byUpdatedDesc = (a, b) => (b.updatedAt || "").localeCompare(a.updatedAt || "");
9379
+ const project = (mission) => {
9380
+ let summary = summarizeMeshMission(meshId, mission);
9381
+ if (withStats) {
9382
+ try {
9383
+ summary = { ...summary, stats: computeMeshMissionStats(meshId, mission.id) };
9384
+ } catch {
9385
+ }
9386
+ }
9387
+ return verbose ? summary : slimMissionSummary(summary);
9388
+ };
9389
+ const foldHistory = (history2) => {
9390
+ if (history2.length === 0) return null;
9391
+ const byStatus = {};
9392
+ for (const m of history2) byStatus[m.status] = (byStatus[m.status] ?? 0) + 1;
9393
+ return {
9394
+ count: history2.length,
9395
+ byStatus,
9396
+ missionIds: history2.slice(0, historyIdLimit).map((m) => m.id),
9397
+ note: 'Completed/abandoned missions are folded to counts + ids. Pass status (e.g. status:["completed"]) to list them in detail.'
9398
+ };
9399
+ };
9400
+ if (explicitStatuses) {
9401
+ const matched = getMeshMissions(meshId, explicitStatuses).filter(passesMagi).sort(byUpdatedDesc);
9402
+ const shown2 = matched.slice(0, limit);
9403
+ const overflow2 = matched.slice(limit);
9404
+ return {
9405
+ missions: shown2.map(project),
9406
+ historyFold: null,
9407
+ truncated: overflow2.length > 0,
9408
+ matched: matched.length,
9409
+ ...overflow2.length > 0 ? { overflowIds: overflow2.map((m) => m.id) } : {}
9410
+ };
9411
+ }
9412
+ const all = getMeshMissions(meshId).filter(passesMagi);
9413
+ const live = all.filter((m) => m.status === "active" || m.status === "paused").sort(byUpdatedDesc);
9414
+ const history = all.filter((m) => m.status === "completed" || m.status === "abandoned").sort(byUpdatedDesc);
9415
+ const shown = live.slice(0, limit);
9416
+ const overflow = live.slice(limit);
9417
+ return {
9418
+ missions: shown.map(project),
9419
+ historyFold: foldHistory(history),
9420
+ truncated: overflow.length > 0,
9421
+ matched: live.length,
9422
+ ...overflow.length > 0 ? { overflowIds: overflow.map((m) => m.id) } : {}
9423
+ };
9424
+ }
9367
9425
  function buildMissionPromptSection(meshId) {
9368
9426
  const summaries = getActiveMeshMissionSummaries(meshId);
9369
9427
  if (summaries.length === 0) return "";
@@ -9382,7 +9440,7 @@ function buildMissionPromptSection(meshId) {
9382
9440
  );
9383
9441
  return lines.join("\n");
9384
9442
  }
9385
- var LEDGER_GOAL_SUMMARY_MAX, MESH_MISSION_STATUSES, GOAL_PREVIEW_MAX, COMPACT_STATUS_GOAL_PREVIEW_MAX;
9443
+ var LEDGER_GOAL_SUMMARY_MAX, MESH_MISSION_STATUSES, GOAL_PREVIEW_MAX, COMPACT_STATUS_GOAL_PREVIEW_MAX, MESH_MISSION_LIST_HISTORY_ID_LIMIT, MESH_MISSION_LIST_STATUS_LIMIT;
9386
9444
  var init_mesh_missions = __esm({
9387
9445
  "src/mesh/mesh-missions.ts"() {
9388
9446
  "use strict";
@@ -9396,6 +9454,8 @@ var init_mesh_missions = __esm({
9396
9454
  MESH_MISSION_STATUSES = ["active", "paused", "completed", "abandoned"];
9397
9455
  GOAL_PREVIEW_MAX = 120;
9398
9456
  COMPACT_STATUS_GOAL_PREVIEW_MAX = 80;
9457
+ MESH_MISSION_LIST_HISTORY_ID_LIMIT = 30;
9458
+ MESH_MISSION_LIST_STATUS_LIMIT = 50;
9399
9459
  }
9400
9460
  });
9401
9461
 
@@ -12878,6 +12938,7 @@ function reconcileDirectDispatchCompletionFromTranscript(args) {
12878
12938
  }
12879
12939
  };
12880
12940
  const targetCoordinatorSessionId = readNonEmptyString2(args.targetCoordinatorSessionId) || readNonEmptyString2(dispatch?.payload?.coordinatorSessionId);
12941
+ const targetCoordinatorDaemonId = readNonEmptyString2(dispatch?.payload?.coordinatorDaemonId) || readNonEmptyString2(args.targetCoordinatorDaemonId);
12881
12942
  queuePendingMeshCoordinatorEvent({
12882
12943
  event: eventName,
12883
12944
  meshId: args.meshId,
@@ -12886,7 +12947,7 @@ function reconcileDirectDispatchCompletionFromTranscript(args) {
12886
12947
  metadataEvent,
12887
12948
  coordinatorMessage: buildMeshSystemMessage({ event: eventName, nodeLabel, metadataEvent }),
12888
12949
  queuedAt: Date.now(),
12889
- ...readNonEmptyString2(args.targetCoordinatorDaemonId) ? { targetCoordinatorDaemonId: readNonEmptyString2(args.targetCoordinatorDaemonId) } : {},
12950
+ ...targetCoordinatorDaemonId ? { targetCoordinatorDaemonId } : {},
12890
12951
  ...targetCoordinatorSessionId ? { targetCoordinatorSessionId } : {}
12891
12952
  });
12892
12953
  recordSynthCompletionGateTrace("synth-fire", {
@@ -20617,7 +20678,11 @@ async function reconcileUnterminatedDirectDispatches(components, mesh, selfIds,
20617
20678
  continue;
20618
20679
  }
20619
20680
  const providerSessionId = readNonEmptyString2(payload.providerSessionId);
20620
- const coordinatorDaemonId = selfIds.find((id) => !!id);
20681
+ const workerSession = components.instanceManager.getInstance(sessionId);
20682
+ const workerCoordinatorDaemonId = readNonEmptyString2(
20683
+ workerSession?.getState()?.settings?.meshCoordinatorDaemonId
20684
+ );
20685
+ const coordinatorDaemonId = workerCoordinatorDaemonId || selfIds.find((id) => !!id);
20621
20686
  try {
20622
20687
  const result = reconcileDirectDispatchCompletionFromTranscript({
20623
20688
  meshId: mesh.id,
@@ -20628,6 +20693,8 @@ async function reconcileUnterminatedDirectDispatches(components, mesh, selfIds,
20628
20693
  taskId,
20629
20694
  finalSummary: evidence.finalSummary,
20630
20695
  ...evidence.transcriptMessageAt ? { transcriptMessageAt: evidence.transcriptMessageAt } : {},
20696
+ // The ledger-recovered dispatching-coordinator daemon (inside the reconcile fn)
20697
+ // takes PRIORITY over this arg; this remains the best-available fallback.
20631
20698
  ...coordinatorDaemonId ? { targetCoordinatorDaemonId: coordinatorDaemonId } : {},
20632
20699
  source: "daemon_reconcile_transcript_completion"
20633
20700
  });
@@ -28416,6 +28483,7 @@ init_mesh_magi_status();
28416
28483
  init_mesh_scheduling_runtime();
28417
28484
  init_mesh_host_ownership();
28418
28485
  init_mesh_events();
28486
+ init_contracts();
28419
28487
  init_mesh_events_utils();
28420
28488
  init_mesh_delivery_policy();
28421
28489
 
@@ -50034,6 +50102,35 @@ function historyJsonlPath() {
50034
50102
  function brainRoot() {
50035
50103
  return path32.join(antigravityRoot(), "brain");
50036
50104
  }
50105
+ function conversationsRoot() {
50106
+ return path32.join(antigravityRoot(), "conversations");
50107
+ }
50108
+ function resolvePathInside(root, ...segments) {
50109
+ const rootPath = path32.resolve(root);
50110
+ const targetPath = path32.resolve(rootPath, ...segments);
50111
+ if (targetPath !== rootPath && !targetPath.startsWith(rootPath + path32.sep)) return null;
50112
+ return targetPath;
50113
+ }
50114
+ function findBrainTranscriptPath(sessionId) {
50115
+ if (!isUuidLike(sessionId)) return null;
50116
+ const logsRoot = resolvePathInside(brainRoot(), sessionId, ".system_generated", "logs");
50117
+ if (!logsRoot || !fs24.existsSync(logsRoot)) return null;
50118
+ const candidates = ["transcript_full.jsonl", "transcript.jsonl"].map((file) => resolvePathInside(logsRoot, file)).filter((p) => p !== null && fs24.existsSync(p));
50119
+ if (candidates.length === 0) {
50120
+ let entries = [];
50121
+ try {
50122
+ entries = fs24.readdirSync(logsRoot, { withFileTypes: true });
50123
+ } catch {
50124
+ return null;
50125
+ }
50126
+ const transcriptFiles = entries.filter((e) => e.isFile() && /^transcript.*\.jsonl$/.test(e.name)).map((e) => path32.join(logsRoot, e.name));
50127
+ if (transcriptFiles.length === 0) return null;
50128
+ transcriptFiles.sort((a, b) => statMtimeMs3(b) - statMtimeMs3(a));
50129
+ return transcriptFiles[0];
50130
+ }
50131
+ candidates.sort((a, b) => statMtimeMs3(b) - statMtimeMs3(a));
50132
+ return candidates[0];
50133
+ }
50037
50134
  function extractUserRequestContent(content) {
50038
50135
  const raw = content.trim();
50039
50136
  const match = raw.match(/<USER_REQUEST>\s*([\s\S]*?)\s*<\/USER_REQUEST>/i);
@@ -50444,6 +50541,83 @@ function parseConversationDb(filePath, sessionId, workspace) {
50444
50541
  }
50445
50542
  return messages.length > 0 ? messages : null;
50446
50543
  }
50544
+ function readHistoryJsonlSession(resolvedSessionId, workspace) {
50545
+ if (!isUuidLike(resolvedSessionId)) return null;
50546
+ const rows = readHistoryRows().filter((r) => r.conversationId === resolvedSessionId);
50547
+ if (rows.length === 0) return null;
50548
+ rows.sort((a, b) => a.receivedAt - b.receivedAt);
50549
+ const firstWorkspace = workspace || rows.find((r) => r.workspace)?.workspace || "";
50550
+ const messages = [];
50551
+ if (firstWorkspace) {
50552
+ messages.push({
50553
+ ts: new Date(rows[0].receivedAt).toISOString(),
50554
+ receivedAt: rows[0].receivedAt,
50555
+ role: "system",
50556
+ content: firstWorkspace,
50557
+ kind: "session_start",
50558
+ agent: "antigravity-cli",
50559
+ historySessionId: resolvedSessionId,
50560
+ workspace: firstWorkspace
50561
+ });
50562
+ }
50563
+ for (const row of rows) {
50564
+ const msg = {
50565
+ ts: new Date(row.receivedAt).toISOString(),
50566
+ receivedAt: row.receivedAt,
50567
+ role: "user",
50568
+ content: row.display,
50569
+ kind: "standard",
50570
+ agent: "antigravity-cli",
50571
+ historySessionId: resolvedSessionId
50572
+ };
50573
+ if (row.workspace) msg.workspace = row.workspace;
50574
+ messages.push(msg);
50575
+ }
50576
+ return {
50577
+ messages,
50578
+ providerSessionId: resolvedSessionId,
50579
+ source: "provider-native",
50580
+ sourcePath: historyJsonlPath(),
50581
+ sourceMtimeMs: statMtimeMs3(historyJsonlPath()),
50582
+ nativeHistoryCoverage: "partial",
50583
+ partialReason: "antigravity_cli_history_jsonl_contains_user_prompts_only"
50584
+ };
50585
+ }
50586
+ function readAntigravitySiblingFallback(sessionId, workspace) {
50587
+ if (!isUuidLike(sessionId)) return null;
50588
+ const brainPath = findBrainTranscriptPath(sessionId);
50589
+ if (brainPath && statMtimeMs3(brainPath) > 0) {
50590
+ const brainMessages = parseBrainTranscript(brainPath, sessionId, workspace);
50591
+ if (brainMessages && brainMessages.length > 0) {
50592
+ return {
50593
+ messages: brainMessages,
50594
+ providerSessionId: sessionId,
50595
+ source: "provider-native",
50596
+ sourcePath: brainPath,
50597
+ sourceMtimeMs: statMtimeMs3(brainPath),
50598
+ nativeHistoryCoverage: "full",
50599
+ workspace
50600
+ };
50601
+ }
50602
+ }
50603
+ const pbPath = resolvePathInside(conversationsRoot(), `${sessionId}.pb`);
50604
+ if (pbPath && fs24.existsSync(pbPath)) {
50605
+ const pbMessages = parsePbFile(pbPath, sessionId);
50606
+ if (pbMessages && pbMessages.length > 0) {
50607
+ return {
50608
+ messages: pbMessages,
50609
+ providerSessionId: sessionId,
50610
+ source: "provider-native",
50611
+ sourcePath: pbPath,
50612
+ sourceMtimeMs: statMtimeMs3(pbPath),
50613
+ nativeHistoryCoverage: "best-effort",
50614
+ partialReason: "antigravity_cli_pb_raw_text_extraction",
50615
+ workspace
50616
+ };
50617
+ }
50618
+ }
50619
+ return readHistoryJsonlSession(sessionId, workspace);
50620
+ }
50447
50621
  function readSession3(sessionPath, sessionId, workspace) {
50448
50622
  if (!sessionPath || !path32.isAbsolute(sessionPath)) return null;
50449
50623
  if (!fs24.existsSync(sessionPath)) return null;
@@ -50470,16 +50644,20 @@ function readSession3(sessionPath, sessionId, workspace) {
50470
50644
  const dbSessionId = sessionId || path32.basename(sessionPath, ".db");
50471
50645
  if (!isUuidLike(dbSessionId)) return null;
50472
50646
  const messages = parseConversationDb(sessionPath, dbSessionId, workspace);
50473
- if (!messages || messages.length === 0) return null;
50474
- return {
50475
- messages,
50476
- providerSessionId: dbSessionId,
50477
- source: "provider-native",
50478
- sourcePath: sessionPath,
50479
- sourceMtimeMs,
50480
- nativeHistoryCoverage: "full",
50481
- workspace
50482
- };
50647
+ if (messages && messages.length > 0) {
50648
+ return {
50649
+ messages,
50650
+ providerSessionId: dbSessionId,
50651
+ source: "provider-native",
50652
+ sourcePath: sessionPath,
50653
+ sourceMtimeMs,
50654
+ nativeHistoryCoverage: "full",
50655
+ workspace
50656
+ };
50657
+ }
50658
+ const siblingFallback = readAntigravitySiblingFallback(dbSessionId, workspace);
50659
+ if (siblingFallback) return siblingFallback;
50660
+ return null;
50483
50661
  }
50484
50662
  if (sessionPath.endsWith(".pb")) {
50485
50663
  const pbSessionId = sessionId || path32.basename(sessionPath, ".pb");
@@ -50497,47 +50675,7 @@ function readSession3(sessionPath, sessionId, workspace) {
50497
50675
  };
50498
50676
  }
50499
50677
  if (path32.basename(sessionPath) === "history.jsonl") {
50500
- const resolvedSessionId = sessionId || "";
50501
- if (!resolvedSessionId || !isUuidLike(resolvedSessionId)) return null;
50502
- const rows = readHistoryRows().filter((r) => r.conversationId === resolvedSessionId);
50503
- if (rows.length === 0) return null;
50504
- rows.sort((a, b) => a.receivedAt - b.receivedAt);
50505
- const firstWorkspace = workspace || rows.find((r) => r.workspace)?.workspace || "";
50506
- const messages = [];
50507
- if (firstWorkspace) {
50508
- messages.push({
50509
- ts: new Date(rows[0].receivedAt).toISOString(),
50510
- receivedAt: rows[0].receivedAt,
50511
- role: "system",
50512
- content: firstWorkspace,
50513
- kind: "session_start",
50514
- agent: "antigravity-cli",
50515
- historySessionId: resolvedSessionId,
50516
- workspace: firstWorkspace
50517
- });
50518
- }
50519
- for (const row of rows) {
50520
- const msg = {
50521
- ts: new Date(row.receivedAt).toISOString(),
50522
- receivedAt: row.receivedAt,
50523
- role: "user",
50524
- content: row.display,
50525
- kind: "standard",
50526
- agent: "antigravity-cli",
50527
- historySessionId: resolvedSessionId
50528
- };
50529
- if (row.workspace) msg.workspace = row.workspace;
50530
- messages.push(msg);
50531
- }
50532
- return {
50533
- messages,
50534
- providerSessionId: resolvedSessionId,
50535
- source: "provider-native",
50536
- sourcePath: sessionPath,
50537
- sourceMtimeMs,
50538
- nativeHistoryCoverage: "partial",
50539
- partialReason: "antigravity_cli_history_jsonl_contains_user_prompts_only"
50540
- };
50678
+ return readHistoryJsonlSession(sessionId || "", workspace);
50541
50679
  }
50542
50680
  return null;
50543
50681
  }
@@ -68814,6 +68952,8 @@ export {
68814
68952
  MESH_CONVERGE_REFINE_TAG,
68815
68953
  MESH_MAX_PARALLEL_TASKS_MAX,
68816
68954
  MESH_MAX_PARALLEL_TASKS_MIN,
68955
+ MESH_MISSION_LIST_HISTORY_ID_LIMIT,
68956
+ MESH_MISSION_LIST_STATUS_LIMIT,
68817
68957
  MESH_MISSION_STATUSES,
68818
68958
  MESH_NODE_LIVE_TRUTH_MARKER,
68819
68959
  MESH_REFINE_CONFIG_LOCATIONS,
@@ -68903,6 +69043,7 @@ export {
68903
69043
  computeMeshTaskStats,
68904
69044
  configureDebugTraceStore,
68905
69045
  connectCdpManager,
69046
+ coordinatorIdentityFromEmitFields,
68906
69047
  createDebugTraceStore,
68907
69048
  createDefaultGitCommandServices,
68908
69049
  createDefaultMeshHostMetadata,
@@ -69019,6 +69160,7 @@ export {
69019
69160
  listMagiKindPanels,
69020
69161
  listMagiPanels,
69021
69162
  listMeshMissionSummaries,
69163
+ listMeshMissionsForTool,
69022
69164
  listMeshes,
69023
69165
  listWorktrees,
69024
69166
  loadChangeImpactConfig,