@adhdev/daemon-core 0.9.82-rc.443 → 0.9.82-rc.445

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 ? "21c6fe269d621db0b4841be14c111d4d656d6996" : void 0) ?? "unknown";
408
- const commitShort = readInjected(true ? "21c6fe26" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
409
- const version = readInjected(true ? "0.9.82-rc.443" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
410
- const builtAt = readInjected(true ? "2026-07-01T10:41:15.424Z" : void 0);
407
+ const commit = readInjected(true ? "92b0714a88a4e1e253a40fa5a8c49602d087a5b3" : void 0) ?? "unknown";
408
+ const commitShort = readInjected(true ? "92b0714a" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
409
+ const version = readInjected(true ? "0.9.82-rc.445" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
410
+ const builtAt = readInjected(true ? "2026-07-01T12:57:54.212Z" : void 0);
411
411
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
412
412
  return cached;
413
413
  }
@@ -3711,6 +3711,7 @@ var init_coordinator_prompt = __esm({
3711
3711
  | \`mesh_read_debug\` | Collect a daemon-side chat/parser debug bundle for a session |
3712
3712
  | \`mesh_task_history\` | Read the task ledger \u2014 dispatches, completions, failures. Use to understand what has been done before deciding next steps |
3713
3713
  | \`mesh_record_note\` | Record a durable, provider-neutral operating note (provider quirk / pattern to avoid / recovery lesson). Future coordinators see it under "## Operating Notes" at launch |
3714
+ | \`mesh_forget_note\` | Retract a stale/wrong operating note by note_id or exact text so it stops riding into future coordinators' prompts (append-only tombstone; history preserved) |
3714
3715
  | \`mesh_git_status\` | Check git status on a specific node |
3715
3716
  | \`mesh_read_node_logs\` | Fetch a remote node's daemon log tail directly over P2P (grep/since/byte-bounded, secrets redacted) \u2014 no session/PowerShell needed to debug a node's daemon |
3716
3717
  | \`mesh_fast_forward_node\` | Safely dry-run or explicitly execute an obvious clean fast-forward without launching an agent session |
@@ -4096,6 +4097,10 @@ var init_load_better_sqlite3 = __esm({
4096
4097
  var mesh_ledger_exports = {};
4097
4098
  __export(mesh_ledger_exports, {
4098
4099
  MAX_LEDGER_SLICE_LIMIT: () => MAX_LEDGER_SLICE_LIMIT,
4100
+ OPERATING_NOTE_DEDUPE_WINDOW: () => OPERATING_NOTE_DEDUPE_WINDOW,
4101
+ OPERATING_NOTE_KEEP_LATEST: () => OPERATING_NOTE_KEEP_LATEST,
4102
+ OPERATING_NOTE_KIND: () => OPERATING_NOTE_KIND,
4103
+ OPERATING_NOTE_TOMBSTONE_KIND: () => OPERATING_NOTE_TOMBSTONE_KIND,
4099
4104
  __clearMeshLedgerForTests: () => __clearMeshLedgerForTests,
4100
4105
  appendLedgerEntry: () => appendLedgerEntry,
4101
4106
  appendRemoteLedgerEntries: () => appendRemoteLedgerEntries,
@@ -4106,11 +4111,15 @@ __export(mesh_ledger_exports, {
4106
4111
  getLedgerSummary: () => getLedgerSummary,
4107
4112
  getSessionRecoveryContext: () => getSessionRecoveryContext,
4108
4113
  isIntentionalCleanupStopEntry: () => isIntentionalCleanupStopEntry,
4114
+ isOperatingNoteTombstoned: () => isOperatingNoteTombstoned,
4109
4115
  meshLedgerEvents: () => meshLedgerEvents,
4110
4116
  normalizeMeshWorkerResult: () => normalizeMeshWorkerResult,
4117
+ pruneOperatingNotes: () => pruneOperatingNotes,
4111
4118
  readLedgerEntries: () => readLedgerEntries,
4112
4119
  readLedgerSlice: () => readLedgerSlice,
4113
- readLedgerSliceFromStore: () => readLedgerSliceFromStore
4120
+ readLedgerSliceFromStore: () => readLedgerSliceFromStore,
4121
+ readOperatingNotes: () => readOperatingNotes,
4122
+ tombstoneOperatingNote: () => tombstoneOperatingNote
4114
4123
  });
4115
4124
  import { appendFileSync, existsSync as existsSync7, mkdirSync as mkdirSync4, readFileSync as readFileSync5, statSync as statSync4, renameSync as renameSync2, writeFileSync as writeFileSync3 } from "fs";
4116
4125
  import { join as join8 } from "path";
@@ -4384,6 +4393,17 @@ function buildTaskCompletionEvidence(opts) {
4384
4393
  };
4385
4394
  }
4386
4395
  function appendLedgerEntry(meshId, partial) {
4396
+ if (partial.kind === OPERATING_NOTE_KIND) {
4397
+ const text = operatingNoteText(partial.payload);
4398
+ if (text) {
4399
+ const recentNotes = readLedgerEntries(meshId, {
4400
+ kind: [OPERATING_NOTE_KIND],
4401
+ tail: OPERATING_NOTE_DEDUPE_WINDOW
4402
+ });
4403
+ const existing = recentNotes.find((e) => operatingNoteText(e.payload) === text);
4404
+ if (existing) return existing;
4405
+ }
4406
+ }
4387
4407
  const entry = {
4388
4408
  id: randomUUID4(),
4389
4409
  meshId,
@@ -4421,11 +4441,101 @@ function appendLedgerEntry(meshId, partial) {
4421
4441
  appendFileSync(filePath, line, { encoding: "utf-8", mode: 384 });
4422
4442
  invalidateLedgerCache(meshId);
4423
4443
  meshLedgerEvents.emit("append", meshId, entry);
4444
+ if (entry.kind === OPERATING_NOTE_KIND || entry.kind === OPERATING_NOTE_TOMBSTONE_KIND) {
4445
+ try {
4446
+ pruneOperatingNotes(meshId);
4447
+ } catch {
4448
+ }
4449
+ }
4424
4450
  return entry;
4425
4451
  } catch (e) {
4426
4452
  throw new Error(`Failed to append to ledger for mesh ${meshId}: ${e.message}`);
4427
4453
  }
4428
4454
  }
4455
+ function operatingNoteText(payload) {
4456
+ const text = payload && typeof payload.text === "string" ? payload.text.trim() : "";
4457
+ return text || void 0;
4458
+ }
4459
+ function collectOperatingNoteTombstones(entries) {
4460
+ const ids = /* @__PURE__ */ new Set();
4461
+ const fingerprints = /* @__PURE__ */ new Set();
4462
+ for (const e of entries) {
4463
+ if (e.kind !== OPERATING_NOTE_TOMBSTONE_KIND) continue;
4464
+ const p = e.payload || {};
4465
+ const targetId = typeof p.targetNoteId === "string" ? p.targetNoteId.trim() : "";
4466
+ const targetFp = typeof p.targetFingerprint === "string" ? p.targetFingerprint.trim() : "";
4467
+ if (targetId) ids.add(targetId);
4468
+ if (targetFp) fingerprints.add(targetFp);
4469
+ }
4470
+ return { ids, fingerprints };
4471
+ }
4472
+ function isOperatingNoteTombstoned(entry, tombstones) {
4473
+ if (tombstones.ids.has(entry.id)) return true;
4474
+ const text = operatingNoteText(entry.payload);
4475
+ return text ? tombstones.fingerprints.has(text) : false;
4476
+ }
4477
+ function tombstoneOperatingNote(meshId, target) {
4478
+ const noteId = typeof target.noteId === "string" ? target.noteId.trim() : "";
4479
+ const fingerprint = typeof target.text === "string" ? target.text.trim() : "";
4480
+ if (!noteId && !fingerprint) {
4481
+ throw new Error("tombstoneOperatingNote requires a noteId or text target");
4482
+ }
4483
+ const notes = readOperatingNotes(meshId);
4484
+ const matched = notes.filter(
4485
+ (n) => noteId && n.id === noteId || fingerprint && operatingNoteText(n.payload) === fingerprint
4486
+ ).length;
4487
+ const tombstone = appendLedgerEntry(meshId, {
4488
+ kind: OPERATING_NOTE_TOMBSTONE_KIND,
4489
+ payload: {
4490
+ ...noteId ? { targetNoteId: noteId } : {},
4491
+ ...fingerprint ? { targetFingerprint: fingerprint } : {},
4492
+ ...target.reason && target.reason.trim() ? { reason: target.reason.trim() } : {},
4493
+ forgottenAt: (/* @__PURE__ */ new Date()).toISOString()
4494
+ }
4495
+ });
4496
+ return { tombstone, matched };
4497
+ }
4498
+ function readOperatingNotes(meshId, opts) {
4499
+ const raw = getCachedRawEntries(meshId);
4500
+ const tombstones = collectOperatingNoteTombstones(raw);
4501
+ let notes = raw.filter((e) => e.kind === OPERATING_NOTE_KIND && !isOperatingNoteTombstoned(e, tombstones));
4502
+ if (opts?.tail && opts.tail > 0 && notes.length > opts.tail) {
4503
+ notes = notes.slice(-opts.tail);
4504
+ }
4505
+ return notes;
4506
+ }
4507
+ function pruneOperatingNotes(meshId, keepLatest = OPERATING_NOTE_KEEP_LATEST) {
4508
+ const raw = getCachedRawEntries(meshId);
4509
+ const tombstones = collectOperatingNoteTombstones(raw);
4510
+ const removeIds = [];
4511
+ const liveNotes = [];
4512
+ for (const e of raw) {
4513
+ if (e.kind !== OPERATING_NOTE_KIND) continue;
4514
+ if (isOperatingNoteTombstoned(e, tombstones)) {
4515
+ removeIds.push(e.id);
4516
+ } else {
4517
+ liveNotes.push(e);
4518
+ }
4519
+ }
4520
+ const bound = Math.max(0, Math.floor(keepLatest));
4521
+ if (liveNotes.length > bound) {
4522
+ for (const e of liveNotes.slice(0, liveNotes.length - bound)) removeIds.push(e.id);
4523
+ }
4524
+ if (removeIds.length === 0) return 0;
4525
+ try {
4526
+ MeshRuntimeStore.getInstance().deleteLedgerEntries(meshId, removeIds);
4527
+ } catch {
4528
+ }
4529
+ try {
4530
+ const remaining = readLedgerFile(meshId).filter((e) => !removeIds.includes(e.id));
4531
+ const filePath = getLedgerPath(meshId);
4532
+ const lines = remaining.length ? remaining.map((e) => JSON.stringify(e)).join("\n") + "\n" : "";
4533
+ writeFileSync3(filePath, lines, { encoding: "utf-8", mode: 384 });
4534
+ } catch {
4535
+ }
4536
+ invalidateLedgerCache(meshId);
4537
+ return removeIds.length;
4538
+ }
4429
4539
  function clampLedgerSliceLimit(limit) {
4430
4540
  if (typeof limit !== "number" || !Number.isFinite(limit)) return DEFAULT_LEDGER_SLICE_LIMIT;
4431
4541
  return Math.max(1, Math.min(MAX_LEDGER_SLICE_LIMIT, Math.floor(limit)));
@@ -4765,7 +4875,7 @@ function rotateLedgerFile(meshId, currentPath) {
4765
4875
  `);
4766
4876
  }
4767
4877
  }
4768
- var LEDGER_DIR_NAME, MAX_FILE_SIZE_BYTES, COMPACT_THRESHOLD_BYTES, ARCHIVE_TERMINAL_OLDER_THAN_MS, RECENT_FAILURE_WINDOW_MS, ARCHIVABLE_KINDS, DEFAULT_LEDGER_SLICE_LIMIT, MAX_LEDGER_SLICE_LIMIT, meshLedgerEvents, ledgerReadCache, LEDGER_CACHE_TTL_MS, ledgerImportStoreRef, ledgerImportDone;
4878
+ var LEDGER_DIR_NAME, MAX_FILE_SIZE_BYTES, COMPACT_THRESHOLD_BYTES, ARCHIVE_TERMINAL_OLDER_THAN_MS, RECENT_FAILURE_WINDOW_MS, ARCHIVABLE_KINDS, DEFAULT_LEDGER_SLICE_LIMIT, MAX_LEDGER_SLICE_LIMIT, OPERATING_NOTE_KIND, OPERATING_NOTE_TOMBSTONE_KIND, OPERATING_NOTE_DEDUPE_WINDOW, OPERATING_NOTE_KEEP_LATEST, meshLedgerEvents, ledgerReadCache, LEDGER_CACHE_TTL_MS, ledgerImportStoreRef, ledgerImportDone;
4769
4879
  var init_mesh_ledger = __esm({
4770
4880
  "src/mesh/mesh-ledger.ts"() {
4771
4881
  "use strict";
@@ -4784,6 +4894,10 @@ var init_mesh_ledger = __esm({
4784
4894
  ]);
4785
4895
  DEFAULT_LEDGER_SLICE_LIMIT = 100;
4786
4896
  MAX_LEDGER_SLICE_LIMIT = 500;
4897
+ OPERATING_NOTE_KIND = "coordinator_operating_note";
4898
+ OPERATING_NOTE_TOMBSTONE_KIND = "coordinator_operating_note_tombstone";
4899
+ OPERATING_NOTE_DEDUPE_WINDOW = 40;
4900
+ OPERATING_NOTE_KEEP_LATEST = 100;
4787
4901
  meshLedgerEvents = new EventEmitter();
4788
4902
  ledgerReadCache = /* @__PURE__ */ new Map();
4789
4903
  LEDGER_CACHE_TTL_MS = 100;
@@ -41154,8 +41268,7 @@ var CliProviderInstance = class _CliProviderInstance {
41154
41268
  * to the genuine-modal classification.
41155
41269
  */
41156
41270
  isTransientToolConsent(now = Date.now()) {
41157
- const isAutonomousMeshSession = this.isMeshWorkerSession() || !!this.settings.meshCoordinatorFor;
41158
- return isAutonomousMeshSession && this.hasAdapterPendingResponse() && !this.manualAttendance.isAttended(now);
41271
+ return this.isAutonomousMeshSession() && this.hasAdapterPendingResponse() && !this.manualAttendance.isAttended(now);
41159
41272
  }
41160
41273
  /** True when this session is parked on a modal awaiting a human answer. */
41161
41274
  isModalParked() {
@@ -41638,6 +41751,19 @@ var CliProviderInstance = class _CliProviderInstance {
41638
41751
  isMeshWorkerSession() {
41639
41752
  return !!(this.settings.meshNodeFor || this.settings.meshActiveTaskId || this.settings.meshNodeId || this.settings.launchedByCoordinator);
41640
41753
  }
41754
+ // FALSE-IDLE (self-coordinator settle): an autonomously-progressing mesh session
41755
+ // is either a delegated worker (isMeshWorkerSession) OR the coordinator's OWN
41756
+ // claude-cli session (meshCoordinatorFor). Both run auto-approved tool turns whose
41757
+ // inter-approval valley (busy→idle blip→generating re-entry ~0.5s later) must be
41758
+ // absorbed by the completedDebounce settle window, not flushed on the first idle
41759
+ // sample. The worker branch already gets NATIVE_HISTORY_MESH_IDLE_SETTLE_MS; the
41760
+ // self-coordinator session (worker markers absent, meshCoordinatorFor present) was
41761
+ // taking flushDelay=0 — no settle window — so its busyEpoch/lastOutputAt continuity
41762
+ // guard had no window to observe the valley and fired mid-turn "next-step" previews
41763
+ // as a finalSummary. Mirrors the isAutonomousMeshSession notion in isTransientToolConsent.
41764
+ isAutonomousMeshSession() {
41765
+ return this.isMeshWorkerSession() || !!this.settings.meshCoordinatorFor;
41766
+ }
41641
41767
  /**
41642
41768
  * ARCH-REFACTOR R1: the taskId to attribute the CURRENTLY-completing turn to.
41643
41769
  * Prefers the per-turn binding (engine.currentTurnTaskId, set when the turn was
@@ -42131,9 +42257,9 @@ var CliProviderInstance = class _CliProviderInstance {
42131
42257
  ...typeof adapterStatus?.lastOutputAt === "number" && Number.isFinite(adapterStatus.lastOutputAt) ? { lastOutputAtArm: adapterStatus.lastOutputAt } : {}
42132
42258
  };
42133
42259
  const ownsExternalHistory = !!this.adapter?.chatMessagesOwnedExternally;
42134
- const meshWorkerSession = this.isMeshWorkerSession();
42135
- const flushDelay = ownsExternalHistory ? meshWorkerSession ? NATIVE_HISTORY_MESH_IDLE_SETTLE_MS : 0 : 3e3;
42136
- LOG.debug("CLI", `[${this.type}] set completedDebouncePending duration=${duration}s ownsExternalHistory=${ownsExternalHistory} meshWorker=${meshWorkerSession} flushDelay=${flushDelay}ms generatingStartedAt=${this.generatingStartedAt}`);
42260
+ const meshSettleSession = this.isAutonomousMeshSession();
42261
+ const flushDelay = ownsExternalHistory ? meshSettleSession ? NATIVE_HISTORY_MESH_IDLE_SETTLE_MS : 0 : 3e3;
42262
+ LOG.debug("CLI", `[${this.type}] set completedDebouncePending duration=${duration}s ownsExternalHistory=${ownsExternalHistory} meshSettle=${meshSettleSession} flushDelay=${flushDelay}ms generatingStartedAt=${this.generatingStartedAt}`);
42137
42263
  this.scheduleCompletedDebounceFlush(flushDelay);
42138
42264
  }
42139
42265
  } else if (newStatus === "idle" && this.lastStatus === "starting") {
@@ -46193,6 +46319,8 @@ function readSession2(sessionPath) {
46193
46319
  }
46194
46320
 
46195
46321
  // src/providers/native-history/antigravity-cli-transcript.ts
46322
+ init_load_better_sqlite3();
46323
+ init_logger();
46196
46324
  import * as fs22 from "fs";
46197
46325
  import * as path31 from "path";
46198
46326
  import * as os22 from "os";
@@ -46369,6 +46497,159 @@ function parsePbFile(filePath, sessionId) {
46369
46497
  }
46370
46498
  ];
46371
46499
  }
46500
+ var AGY_STEP_TYPE_USER = 14;
46501
+ var AGY_STEP_TYPE_MODEL = 15;
46502
+ function readVarint(buf, offset) {
46503
+ let result = 0;
46504
+ let shift = 0;
46505
+ let i = offset;
46506
+ while (i < buf.length) {
46507
+ const byte = buf[i];
46508
+ i += 1;
46509
+ result += (byte & 127) * Math.pow(2, shift);
46510
+ if ((byte & 128) === 0) return [result, i];
46511
+ shift += 7;
46512
+ if (shift > 63) break;
46513
+ }
46514
+ return [result, i];
46515
+ }
46516
+ function decodeProtoFields(buf) {
46517
+ const fields = [];
46518
+ let i = 0;
46519
+ while (i < buf.length) {
46520
+ const [key2, afterKey] = readVarint(buf, i);
46521
+ if (afterKey === i) break;
46522
+ i = afterKey;
46523
+ const field = Math.floor(key2 / 8);
46524
+ const wireType = key2 & 7;
46525
+ if (field <= 0) break;
46526
+ if (wireType === 0) {
46527
+ const [value, next] = readVarint(buf, i);
46528
+ if (next === i) break;
46529
+ i = next;
46530
+ fields.push({ field, wireType, varint: value });
46531
+ } else if (wireType === 2) {
46532
+ const [len, afterLen] = readVarint(buf, i);
46533
+ i = afterLen;
46534
+ if (len < 0 || i + len > buf.length) break;
46535
+ fields.push({ field, wireType, bytes: buf.subarray(i, i + len) });
46536
+ i += len;
46537
+ } else if (wireType === 5) {
46538
+ i += 4;
46539
+ } else if (wireType === 1) {
46540
+ i += 8;
46541
+ } else {
46542
+ break;
46543
+ }
46544
+ }
46545
+ return fields;
46546
+ }
46547
+ function firstLenField(buf, field) {
46548
+ for (const f of decodeProtoFields(buf)) {
46549
+ if (f.field === field && f.wireType === 2 && f.bytes) return f.bytes;
46550
+ }
46551
+ return null;
46552
+ }
46553
+ function looksLikeText(buf) {
46554
+ if (buf.length === 0) return false;
46555
+ let printable = 0;
46556
+ for (let i = 0; i < buf.length; i++) {
46557
+ const b = buf[i];
46558
+ if (b >= 32 && b <= 126 || b === 9 || b === 10 || b === 13 || b >= 128) printable += 1;
46559
+ }
46560
+ return printable / buf.length >= 0.9;
46561
+ }
46562
+ function stripAnswerMarker(text) {
46563
+ return text.replace(/^\s*MARKER_V1\s*/, "");
46564
+ }
46565
+ function extractModelAnswer(payload) {
46566
+ const inner = firstLenField(payload, 20);
46567
+ if (!inner) return "";
46568
+ const answer = firstLenField(inner, 1) ?? firstLenField(inner, 8);
46569
+ if (!answer || !looksLikeText(answer)) return "";
46570
+ return stripAnswerMarker(answer.toString("utf-8")).trim();
46571
+ }
46572
+ function extractUserPrompt(payload) {
46573
+ const inner = firstLenField(payload, 19);
46574
+ if (!inner) return "";
46575
+ const raw = firstLenField(inner, 2) ?? firstLenField(inner, 3);
46576
+ if (!raw || !looksLikeText(raw)) return "";
46577
+ const text = raw.toString("utf-8").trim();
46578
+ if (!text) return "";
46579
+ return extractUserRequestContent(text);
46580
+ }
46581
+ function parseConversationDb(filePath, sessionId, workspace) {
46582
+ let db;
46583
+ try {
46584
+ const Database = loadBetterSqlite3();
46585
+ db = new Database(filePath, { readonly: true, fileMustExist: true });
46586
+ } catch (err) {
46587
+ LOG.warn(
46588
+ "NativeHistory",
46589
+ `antigravity .db reader could not open ${path31.basename(filePath)}: ${err instanceof Error ? err.message : String(err)} (better-sqlite3 load/open failed \u2014 assistant answers in this .db will not surface)`
46590
+ );
46591
+ return null;
46592
+ }
46593
+ let rows;
46594
+ try {
46595
+ rows = db.prepare(
46596
+ `SELECT idx, step_type, step_payload
46597
+ FROM steps
46598
+ WHERE step_type IN (${AGY_STEP_TYPE_USER}, ${AGY_STEP_TYPE_MODEL})
46599
+ ORDER BY idx ASC`
46600
+ ).all();
46601
+ } catch (err) {
46602
+ LOG.debug(
46603
+ "NativeHistory",
46604
+ `antigravity .db ${path31.basename(filePath)} has no readable steps table: ${err instanceof Error ? err.message : String(err)}`
46605
+ );
46606
+ return null;
46607
+ } finally {
46608
+ try {
46609
+ db.close();
46610
+ } catch {
46611
+ }
46612
+ }
46613
+ if (!Array.isArray(rows) || rows.length === 0) return null;
46614
+ const normalizedWorkspace = typeof workspace === "string" ? workspace.trim() : "";
46615
+ const baseTs = statMtimeMs3(filePath) || Date.now();
46616
+ const messages = [];
46617
+ for (const row of rows) {
46618
+ const payload = row.step_payload;
46619
+ if (!payload || !Buffer.isBuffer(payload) || payload.length === 0) continue;
46620
+ const receivedAt = baseTs + messages.length;
46621
+ if (row.step_type === AGY_STEP_TYPE_USER) {
46622
+ const content = extractUserPrompt(payload);
46623
+ if (!content) continue;
46624
+ const msg = {
46625
+ ts: new Date(receivedAt).toISOString(),
46626
+ receivedAt,
46627
+ role: "user",
46628
+ content,
46629
+ kind: "standard",
46630
+ agent: "antigravity-cli",
46631
+ historySessionId: sessionId
46632
+ };
46633
+ if (normalizedWorkspace) msg.workspace = normalizedWorkspace;
46634
+ messages.push(msg);
46635
+ } else if (row.step_type === AGY_STEP_TYPE_MODEL) {
46636
+ const content = extractModelAnswer(payload);
46637
+ if (!content) continue;
46638
+ const msg = {
46639
+ ts: new Date(receivedAt).toISOString(),
46640
+ receivedAt,
46641
+ role: "assistant",
46642
+ content,
46643
+ kind: "standard",
46644
+ agent: "antigravity-cli",
46645
+ historySessionId: sessionId
46646
+ };
46647
+ if (normalizedWorkspace) msg.workspace = normalizedWorkspace;
46648
+ messages.push(msg);
46649
+ }
46650
+ }
46651
+ return messages.length > 0 ? messages : null;
46652
+ }
46372
46653
  function readSession3(sessionPath, sessionId, workspace) {
46373
46654
  if (!sessionPath || !path31.isAbsolute(sessionPath)) return null;
46374
46655
  if (!fs22.existsSync(sessionPath)) return null;
@@ -46391,6 +46672,21 @@ function readSession3(sessionPath, sessionId, workspace) {
46391
46672
  workspace
46392
46673
  };
46393
46674
  }
46675
+ if (sessionPath.endsWith(".db")) {
46676
+ const dbSessionId = sessionId || path31.basename(sessionPath, ".db");
46677
+ if (!isUuidLike(dbSessionId)) return null;
46678
+ const messages = parseConversationDb(sessionPath, dbSessionId, workspace);
46679
+ if (!messages || messages.length === 0) return null;
46680
+ return {
46681
+ messages,
46682
+ providerSessionId: dbSessionId,
46683
+ source: "provider-native",
46684
+ sourcePath: sessionPath,
46685
+ sourceMtimeMs,
46686
+ nativeHistoryCoverage: "full",
46687
+ workspace
46688
+ };
46689
+ }
46394
46690
  if (sessionPath.endsWith(".pb")) {
46395
46691
  const pbSessionId = sessionId || path31.basename(sessionPath, ".pb");
46396
46692
  if (!isUuidLike(pbSessionId)) return null;
@@ -46619,7 +46915,7 @@ function resolveSourcePath(reader, workspace, sessionId, sessionStartedAtMs) {
46619
46915
  case "codex-cli":
46620
46916
  return resolveCodexPath(workspace, sessionId, sessionStartedAtMs);
46621
46917
  case "antigravity-cli":
46622
- return resolveAntigravityPath(workspace);
46918
+ return resolveAntigravityPath(workspace, sessionId);
46623
46919
  case "hermes-cli":
46624
46920
  return resolveHermesPath(workspace, sessionId);
46625
46921
  }
@@ -46734,16 +47030,25 @@ function resolveRealPath(value) {
46734
47030
  return value;
46735
47031
  }
46736
47032
  }
46737
- function resolveAntigravityPath(workspace) {
47033
+ function resolveAntigravityPath(workspace, sessionId) {
46738
47034
  void workspace;
46739
- const brainRoot2 = path33.join(os24.homedir(), ".gemini", "antigravity-cli", "brain");
46740
- if (!fs24.existsSync(brainRoot2)) return null;
46741
- const cutoff = Date.now() - RECENT_WINDOW_MS;
46742
- const entries = fs24.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => ({ p: path33.join(brainRoot2, e.name), mtime: safeMtime(path33.join(brainRoot2, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
46743
- for (const e of entries) {
46744
- const t = path33.join(e.p, ".system_generated", "logs", "transcript.jsonl");
46745
- if (fs24.existsSync(t)) return t;
47035
+ const agyRoot = path33.join(os24.homedir(), ".gemini", "antigravity-cli");
47036
+ if (sessionId && isUuidLikeSessionId2(sessionId)) {
47037
+ const dbPath = path33.join(agyRoot, "conversations", `${sessionId}.db`);
47038
+ if (fs24.existsSync(dbPath)) return dbPath;
46746
47039
  }
47040
+ const brainRoot2 = path33.join(agyRoot, "brain");
47041
+ if (fs24.existsSync(brainRoot2)) {
47042
+ const cutoff = Date.now() - RECENT_WINDOW_MS;
47043
+ const entries = fs24.readdirSync(brainRoot2, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => ({ p: path33.join(brainRoot2, e.name), mtime: safeMtime(path33.join(brainRoot2, e.name)) })).filter((e) => e.mtime >= cutoff).sort((a, b) => b.mtime - a.mtime);
47044
+ for (const e of entries) {
47045
+ const t = path33.join(e.p, ".system_generated", "logs", "transcript.jsonl");
47046
+ if (fs24.existsSync(t) && safeSize(t) > 0) return t;
47047
+ }
47048
+ }
47049
+ const convRoot = path33.join(agyRoot, "conversations");
47050
+ const newestDb = newestRecentFile2(convRoot, /^[0-9a-f-]+\.db$/i);
47051
+ if (newestDb) return newestDb;
46747
47052
  return null;
46748
47053
  }
46749
47054
  function resolveHermesPath(workspace, sessionId) {
@@ -46802,6 +47107,13 @@ function safeMtime(p) {
46802
47107
  return 0;
46803
47108
  }
46804
47109
  }
47110
+ function safeSize(p) {
47111
+ try {
47112
+ return fs24.statSync(p).size;
47113
+ } catch {
47114
+ return 0;
47115
+ }
47116
+ }
46805
47117
  function normalizeRole2(r) {
46806
47118
  const s2 = String(r ?? "").toLowerCase();
46807
47119
  if (s2 === "user" || s2 === "human") return "user";
@@ -51015,8 +51327,8 @@ var meshCoordinatorLaunchHandlers = {
51015
51327
  };
51016
51328
  const buildOperatingNotesBestEffort = async (id) => {
51017
51329
  try {
51018
- const { readLedgerEntries: readLedgerEntries2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
51019
- const noteEntries = readLedgerEntries2(id, { kind: ["coordinator_operating_note"], tail: 20 });
51330
+ const { readOperatingNotes: readOperatingNotes2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
51331
+ const noteEntries = readOperatingNotes2(id, { tail: 20 });
51020
51332
  const notes = noteEntries.map((e) => {
51021
51333
  const p = e.payload || {};
51022
51334
  const text = typeof p.text === "string" ? p.text.trim() : "";
@@ -65717,6 +66029,10 @@ export {
65717
66029
  MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS,
65718
66030
  MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS,
65719
66031
  NodePtyTransportFactory,
66032
+ OPERATING_NOTE_DEDUPE_WINDOW,
66033
+ OPERATING_NOTE_KEEP_LATEST,
66034
+ OPERATING_NOTE_KIND,
66035
+ OPERATING_NOTE_TOMBSTONE_KIND,
65720
66036
  P2pRelayFailureError,
65721
66037
  PRUNABLE_ORPHAN_STALE_REASONS,
65722
66038
  ProviderCliAdapter,
@@ -65886,6 +66202,7 @@ export {
65886
66202
  isManagedStatusWaiting,
65887
66203
  isManagedStatusWorking,
65888
66204
  isMeshHostOwner,
66205
+ isOperatingNoteTombstoned,
65889
66206
  isP2pRelayTransportFailure,
65890
66207
  isPathInside,
65891
66208
  isSessionHostLiveRuntime,
@@ -65954,6 +66271,7 @@ export {
65954
66271
  prepareSessionChatTailUpdate,
65955
66272
  prepareSessionModalUpdate,
65956
66273
  probeCdpPort,
66274
+ pruneOperatingNotes,
65957
66275
  pruneStaleDirectDispatches,
65958
66276
  queuePendingMeshCoordinatorEvent,
65959
66277
  readSession3 as readAntigravityCliSession,
@@ -65966,6 +66284,7 @@ export {
65966
66284
  readLedgerSlice,
65967
66285
  readLedgerSliceFromStore,
65968
66286
  readMeshCompletionSummary,
66287
+ readOperatingNotes,
65969
66288
  reconcileDirectDispatchCompletionFromTranscript,
65970
66289
  recordCompletionConflict,
65971
66290
  recordDebugTrace,
@@ -66023,6 +66342,7 @@ export {
66023
66342
  summarizeMeshMagiActivity,
66024
66343
  summarizeMeshMission,
66025
66344
  summarizeMissionTasks,
66345
+ tombstoneOperatingNote,
66026
66346
  triggerMeshQueue,
66027
66347
  unregisterMeshCoordinator,
66028
66348
  updateConfig,