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

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.d.ts CHANGED
@@ -49,7 +49,7 @@ export { MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS, MESH_WORKTREE_BOOTSTRAP_CONFI
49
49
  export type { MeshRefineValidationCategory, MeshRefineValidationCommandPlan, MeshRefineValidationPlan, RepoMeshRefineConfig, RepoMeshRefineValidationCommandConfig, } from './mesh/refine-config.js';
50
50
  export { loadRepoSettings } from './config/repo-settings.js';
51
51
  export type { RepoSettings, LoadRepoSettingsOptions } from './config/repo-settings.js';
52
- export { appendLedgerEntry, appendRemoteLedgerEntries, buildTaskCompletionEvidence, normalizeMeshWorkerResult, readLedgerEntries, readLedgerSlice, readLedgerSliceFromStore, getLedgerSummary, getLedgerDir, getSessionRecoveryContext, MAX_LEDGER_SLICE_LIMIT } from './mesh/mesh-ledger.js';
52
+ export { appendLedgerEntry, appendRemoteLedgerEntries, buildTaskCompletionEvidence, normalizeMeshWorkerResult, readLedgerEntries, readLedgerSlice, readLedgerSliceFromStore, getLedgerSummary, getLedgerDir, getSessionRecoveryContext, MAX_LEDGER_SLICE_LIMIT, tombstoneOperatingNote, readOperatingNotes, pruneOperatingNotes, isOperatingNoteTombstoned, OPERATING_NOTE_KIND, OPERATING_NOTE_TOMBSTONE_KIND, OPERATING_NOTE_DEDUPE_WINDOW, OPERATING_NOTE_KEEP_LATEST } from './mesh/mesh-ledger.js';
53
53
  export type { AppendRemoteLedgerResult, MeshLedgerEntry, MeshLedgerKind, MeshLedgerSlice, MeshLedgerSummary, ReadLedgerOptions, ReadLedgerSliceOptions, SessionRecoveryContext, MeshTaskCompletionEvidence, MeshWorkerResultArtifact, MeshProcessArtifact, MeshValidationResultArtifact } from './mesh/mesh-ledger.js';
54
54
  export { fastForwardMeshNode } from './mesh/mesh-fast-forward.js';
55
55
  export type { MeshFastForwardNodeArgs, MeshFastForwardPlannedStep, MeshFastForwardResult } from './mesh/mesh-fast-forward.js';
package/dist/index.js CHANGED
@@ -409,10 +409,10 @@ function readInjected(value) {
409
409
  }
410
410
  function getDaemonBuildInfo() {
411
411
  if (cached) return cached;
412
- const commit = readInjected(true ? "21c6fe269d621db0b4841be14c111d4d656d6996" : void 0) ?? "unknown";
413
- const commitShort = readInjected(true ? "21c6fe26" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
414
- const version = readInjected(true ? "0.9.82-rc.443" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
415
- const builtAt = readInjected(true ? "2026-07-01T10:41:15.424Z" : void 0);
412
+ const commit = readInjected(true ? "fafdde138250b2edcbf2e42c643e3cabd1b8bda0" : void 0) ?? "unknown";
413
+ const commitShort = readInjected(true ? "fafdde13" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
414
+ const version = readInjected(true ? "0.9.82-rc.444" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
415
+ const builtAt = readInjected(true ? "2026-07-01T12:06:17.132Z" : void 0);
416
416
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
417
417
  return cached;
418
418
  }
@@ -3717,6 +3717,7 @@ var init_coordinator_prompt = __esm({
3717
3717
  | \`mesh_read_debug\` | Collect a daemon-side chat/parser debug bundle for a session |
3718
3718
  | \`mesh_task_history\` | Read the task ledger \u2014 dispatches, completions, failures. Use to understand what has been done before deciding next steps |
3719
3719
  | \`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 |
3720
+ | \`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) |
3720
3721
  | \`mesh_git_status\` | Check git status on a specific node |
3721
3722
  | \`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 |
3722
3723
  | \`mesh_fast_forward_node\` | Safely dry-run or explicitly execute an obvious clean fast-forward without launching an agent session |
@@ -4103,6 +4104,10 @@ var init_load_better_sqlite3 = __esm({
4103
4104
  var mesh_ledger_exports = {};
4104
4105
  __export(mesh_ledger_exports, {
4105
4106
  MAX_LEDGER_SLICE_LIMIT: () => MAX_LEDGER_SLICE_LIMIT,
4107
+ OPERATING_NOTE_DEDUPE_WINDOW: () => OPERATING_NOTE_DEDUPE_WINDOW,
4108
+ OPERATING_NOTE_KEEP_LATEST: () => OPERATING_NOTE_KEEP_LATEST,
4109
+ OPERATING_NOTE_KIND: () => OPERATING_NOTE_KIND,
4110
+ OPERATING_NOTE_TOMBSTONE_KIND: () => OPERATING_NOTE_TOMBSTONE_KIND,
4106
4111
  __clearMeshLedgerForTests: () => __clearMeshLedgerForTests,
4107
4112
  appendLedgerEntry: () => appendLedgerEntry,
4108
4113
  appendRemoteLedgerEntries: () => appendRemoteLedgerEntries,
@@ -4113,11 +4118,15 @@ __export(mesh_ledger_exports, {
4113
4118
  getLedgerSummary: () => getLedgerSummary,
4114
4119
  getSessionRecoveryContext: () => getSessionRecoveryContext,
4115
4120
  isIntentionalCleanupStopEntry: () => isIntentionalCleanupStopEntry,
4121
+ isOperatingNoteTombstoned: () => isOperatingNoteTombstoned,
4116
4122
  meshLedgerEvents: () => meshLedgerEvents,
4117
4123
  normalizeMeshWorkerResult: () => normalizeMeshWorkerResult,
4124
+ pruneOperatingNotes: () => pruneOperatingNotes,
4118
4125
  readLedgerEntries: () => readLedgerEntries,
4119
4126
  readLedgerSlice: () => readLedgerSlice,
4120
- readLedgerSliceFromStore: () => readLedgerSliceFromStore
4127
+ readLedgerSliceFromStore: () => readLedgerSliceFromStore,
4128
+ readOperatingNotes: () => readOperatingNotes,
4129
+ tombstoneOperatingNote: () => tombstoneOperatingNote
4121
4130
  });
4122
4131
  function isIntentionalCleanupStopEntry(entry) {
4123
4132
  if (entry.kind !== "session_stopped" && entry.kind !== "task_failed" && entry.kind !== "task_stalled") return false;
@@ -4387,6 +4396,17 @@ function buildTaskCompletionEvidence(opts) {
4387
4396
  };
4388
4397
  }
4389
4398
  function appendLedgerEntry(meshId, partial) {
4399
+ if (partial.kind === OPERATING_NOTE_KIND) {
4400
+ const text = operatingNoteText(partial.payload);
4401
+ if (text) {
4402
+ const recentNotes = readLedgerEntries(meshId, {
4403
+ kind: [OPERATING_NOTE_KIND],
4404
+ tail: OPERATING_NOTE_DEDUPE_WINDOW
4405
+ });
4406
+ const existing = recentNotes.find((e) => operatingNoteText(e.payload) === text);
4407
+ if (existing) return existing;
4408
+ }
4409
+ }
4390
4410
  const entry = {
4391
4411
  id: (0, import_crypto4.randomUUID)(),
4392
4412
  meshId,
@@ -4424,11 +4444,101 @@ function appendLedgerEntry(meshId, partial) {
4424
4444
  (0, import_fs4.appendFileSync)(filePath, line, { encoding: "utf-8", mode: 384 });
4425
4445
  invalidateLedgerCache(meshId);
4426
4446
  meshLedgerEvents.emit("append", meshId, entry);
4447
+ if (entry.kind === OPERATING_NOTE_KIND || entry.kind === OPERATING_NOTE_TOMBSTONE_KIND) {
4448
+ try {
4449
+ pruneOperatingNotes(meshId);
4450
+ } catch {
4451
+ }
4452
+ }
4427
4453
  return entry;
4428
4454
  } catch (e) {
4429
4455
  throw new Error(`Failed to append to ledger for mesh ${meshId}: ${e.message}`);
4430
4456
  }
4431
4457
  }
4458
+ function operatingNoteText(payload) {
4459
+ const text = payload && typeof payload.text === "string" ? payload.text.trim() : "";
4460
+ return text || void 0;
4461
+ }
4462
+ function collectOperatingNoteTombstones(entries) {
4463
+ const ids = /* @__PURE__ */ new Set();
4464
+ const fingerprints = /* @__PURE__ */ new Set();
4465
+ for (const e of entries) {
4466
+ if (e.kind !== OPERATING_NOTE_TOMBSTONE_KIND) continue;
4467
+ const p = e.payload || {};
4468
+ const targetId = typeof p.targetNoteId === "string" ? p.targetNoteId.trim() : "";
4469
+ const targetFp = typeof p.targetFingerprint === "string" ? p.targetFingerprint.trim() : "";
4470
+ if (targetId) ids.add(targetId);
4471
+ if (targetFp) fingerprints.add(targetFp);
4472
+ }
4473
+ return { ids, fingerprints };
4474
+ }
4475
+ function isOperatingNoteTombstoned(entry, tombstones) {
4476
+ if (tombstones.ids.has(entry.id)) return true;
4477
+ const text = operatingNoteText(entry.payload);
4478
+ return text ? tombstones.fingerprints.has(text) : false;
4479
+ }
4480
+ function tombstoneOperatingNote(meshId, target) {
4481
+ const noteId = typeof target.noteId === "string" ? target.noteId.trim() : "";
4482
+ const fingerprint = typeof target.text === "string" ? target.text.trim() : "";
4483
+ if (!noteId && !fingerprint) {
4484
+ throw new Error("tombstoneOperatingNote requires a noteId or text target");
4485
+ }
4486
+ const notes = readOperatingNotes(meshId);
4487
+ const matched = notes.filter(
4488
+ (n) => noteId && n.id === noteId || fingerprint && operatingNoteText(n.payload) === fingerprint
4489
+ ).length;
4490
+ const tombstone = appendLedgerEntry(meshId, {
4491
+ kind: OPERATING_NOTE_TOMBSTONE_KIND,
4492
+ payload: {
4493
+ ...noteId ? { targetNoteId: noteId } : {},
4494
+ ...fingerprint ? { targetFingerprint: fingerprint } : {},
4495
+ ...target.reason && target.reason.trim() ? { reason: target.reason.trim() } : {},
4496
+ forgottenAt: (/* @__PURE__ */ new Date()).toISOString()
4497
+ }
4498
+ });
4499
+ return { tombstone, matched };
4500
+ }
4501
+ function readOperatingNotes(meshId, opts) {
4502
+ const raw = getCachedRawEntries(meshId);
4503
+ const tombstones = collectOperatingNoteTombstones(raw);
4504
+ let notes = raw.filter((e) => e.kind === OPERATING_NOTE_KIND && !isOperatingNoteTombstoned(e, tombstones));
4505
+ if (opts?.tail && opts.tail > 0 && notes.length > opts.tail) {
4506
+ notes = notes.slice(-opts.tail);
4507
+ }
4508
+ return notes;
4509
+ }
4510
+ function pruneOperatingNotes(meshId, keepLatest = OPERATING_NOTE_KEEP_LATEST) {
4511
+ const raw = getCachedRawEntries(meshId);
4512
+ const tombstones = collectOperatingNoteTombstones(raw);
4513
+ const removeIds = [];
4514
+ const liveNotes = [];
4515
+ for (const e of raw) {
4516
+ if (e.kind !== OPERATING_NOTE_KIND) continue;
4517
+ if (isOperatingNoteTombstoned(e, tombstones)) {
4518
+ removeIds.push(e.id);
4519
+ } else {
4520
+ liveNotes.push(e);
4521
+ }
4522
+ }
4523
+ const bound = Math.max(0, Math.floor(keepLatest));
4524
+ if (liveNotes.length > bound) {
4525
+ for (const e of liveNotes.slice(0, liveNotes.length - bound)) removeIds.push(e.id);
4526
+ }
4527
+ if (removeIds.length === 0) return 0;
4528
+ try {
4529
+ MeshRuntimeStore.getInstance().deleteLedgerEntries(meshId, removeIds);
4530
+ } catch {
4531
+ }
4532
+ try {
4533
+ const remaining = readLedgerFile(meshId).filter((e) => !removeIds.includes(e.id));
4534
+ const filePath = getLedgerPath(meshId);
4535
+ const lines = remaining.length ? remaining.map((e) => JSON.stringify(e)).join("\n") + "\n" : "";
4536
+ (0, import_fs4.writeFileSync)(filePath, lines, { encoding: "utf-8", mode: 384 });
4537
+ } catch {
4538
+ }
4539
+ invalidateLedgerCache(meshId);
4540
+ return removeIds.length;
4541
+ }
4432
4542
  function clampLedgerSliceLimit(limit) {
4433
4543
  if (typeof limit !== "number" || !Number.isFinite(limit)) return DEFAULT_LEDGER_SLICE_LIMIT;
4434
4544
  return Math.max(1, Math.min(MAX_LEDGER_SLICE_LIMIT, Math.floor(limit)));
@@ -4768,7 +4878,7 @@ function rotateLedgerFile(meshId, currentPath) {
4768
4878
  `);
4769
4879
  }
4770
4880
  }
4771
- var import_fs4, import_path4, import_crypto4, import_events, 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;
4881
+ var import_fs4, import_path4, import_crypto4, import_events, 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;
4772
4882
  var init_mesh_ledger = __esm({
4773
4883
  "src/mesh/mesh-ledger.ts"() {
4774
4884
  "use strict";
@@ -4791,6 +4901,10 @@ var init_mesh_ledger = __esm({
4791
4901
  ]);
4792
4902
  DEFAULT_LEDGER_SLICE_LIMIT = 100;
4793
4903
  MAX_LEDGER_SLICE_LIMIT = 500;
4904
+ OPERATING_NOTE_KIND = "coordinator_operating_note";
4905
+ OPERATING_NOTE_TOMBSTONE_KIND = "coordinator_operating_note_tombstone";
4906
+ OPERATING_NOTE_DEDUPE_WINDOW = 40;
4907
+ OPERATING_NOTE_KEEP_LATEST = 100;
4794
4908
  meshLedgerEvents = new import_events.EventEmitter();
4795
4909
  ledgerReadCache = /* @__PURE__ */ new Map();
4796
4910
  LEDGER_CACHE_TTL_MS = 100;
@@ -23812,6 +23926,10 @@ __export(index_exports, {
23812
23926
  MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS: () => MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS,
23813
23927
  MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS: () => MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS,
23814
23928
  NodePtyTransportFactory: () => NodePtyTransportFactory,
23929
+ OPERATING_NOTE_DEDUPE_WINDOW: () => OPERATING_NOTE_DEDUPE_WINDOW,
23930
+ OPERATING_NOTE_KEEP_LATEST: () => OPERATING_NOTE_KEEP_LATEST,
23931
+ OPERATING_NOTE_KIND: () => OPERATING_NOTE_KIND,
23932
+ OPERATING_NOTE_TOMBSTONE_KIND: () => OPERATING_NOTE_TOMBSTONE_KIND,
23815
23933
  P2pRelayFailureError: () => P2pRelayFailureError,
23816
23934
  PRUNABLE_ORPHAN_STALE_REASONS: () => PRUNABLE_ORPHAN_STALE_REASONS,
23817
23935
  ProviderCliAdapter: () => ProviderCliAdapter,
@@ -23981,6 +24099,7 @@ __export(index_exports, {
23981
24099
  isManagedStatusWaiting: () => isManagedStatusWaiting,
23982
24100
  isManagedStatusWorking: () => isManagedStatusWorking,
23983
24101
  isMeshHostOwner: () => isMeshHostOwner,
24102
+ isOperatingNoteTombstoned: () => isOperatingNoteTombstoned,
23984
24103
  isP2pRelayTransportFailure: () => isP2pRelayTransportFailure,
23985
24104
  isPathInside: () => isPathInside,
23986
24105
  isSessionHostLiveRuntime: () => isSessionHostLiveRuntime,
@@ -24049,6 +24168,7 @@ __export(index_exports, {
24049
24168
  prepareSessionChatTailUpdate: () => prepareSessionChatTailUpdate,
24050
24169
  prepareSessionModalUpdate: () => prepareSessionModalUpdate,
24051
24170
  probeCdpPort: () => probeCdpPort,
24171
+ pruneOperatingNotes: () => pruneOperatingNotes,
24052
24172
  pruneStaleDirectDispatches: () => pruneStaleDirectDispatches,
24053
24173
  queuePendingMeshCoordinatorEvent: () => queuePendingMeshCoordinatorEvent,
24054
24174
  readAntigravityCliSession: () => readSession3,
@@ -24061,6 +24181,7 @@ __export(index_exports, {
24061
24181
  readLedgerSlice: () => readLedgerSlice,
24062
24182
  readLedgerSliceFromStore: () => readLedgerSliceFromStore,
24063
24183
  readMeshCompletionSummary: () => readMeshCompletionSummary,
24184
+ readOperatingNotes: () => readOperatingNotes,
24064
24185
  reconcileDirectDispatchCompletionFromTranscript: () => reconcileDirectDispatchCompletionFromTranscript,
24065
24186
  recordCompletionConflict: () => recordCompletionConflict,
24066
24187
  recordDebugTrace: () => recordDebugTrace,
@@ -24118,6 +24239,7 @@ __export(index_exports, {
24118
24239
  summarizeMeshMagiActivity: () => summarizeMeshMagiActivity,
24119
24240
  summarizeMeshMission: () => summarizeMeshMission,
24120
24241
  summarizeMissionTasks: () => summarizeMissionTasks,
24242
+ tombstoneOperatingNote: () => tombstoneOperatingNote,
24121
24243
  triggerMeshQueue: () => triggerMeshQueue,
24122
24244
  unregisterMeshCoordinator: () => unregisterMeshCoordinator,
24123
24245
  updateConfig: () => updateConfig,
@@ -41558,8 +41680,7 @@ var CliProviderInstance = class _CliProviderInstance {
41558
41680
  * to the genuine-modal classification.
41559
41681
  */
41560
41682
  isTransientToolConsent(now = Date.now()) {
41561
- const isAutonomousMeshSession = this.isMeshWorkerSession() || !!this.settings.meshCoordinatorFor;
41562
- return isAutonomousMeshSession && this.hasAdapterPendingResponse() && !this.manualAttendance.isAttended(now);
41683
+ return this.isAutonomousMeshSession() && this.hasAdapterPendingResponse() && !this.manualAttendance.isAttended(now);
41563
41684
  }
41564
41685
  /** True when this session is parked on a modal awaiting a human answer. */
41565
41686
  isModalParked() {
@@ -42042,6 +42163,19 @@ var CliProviderInstance = class _CliProviderInstance {
42042
42163
  isMeshWorkerSession() {
42043
42164
  return !!(this.settings.meshNodeFor || this.settings.meshActiveTaskId || this.settings.meshNodeId || this.settings.launchedByCoordinator);
42044
42165
  }
42166
+ // FALSE-IDLE (self-coordinator settle): an autonomously-progressing mesh session
42167
+ // is either a delegated worker (isMeshWorkerSession) OR the coordinator's OWN
42168
+ // claude-cli session (meshCoordinatorFor). Both run auto-approved tool turns whose
42169
+ // inter-approval valley (busy→idle blip→generating re-entry ~0.5s later) must be
42170
+ // absorbed by the completedDebounce settle window, not flushed on the first idle
42171
+ // sample. The worker branch already gets NATIVE_HISTORY_MESH_IDLE_SETTLE_MS; the
42172
+ // self-coordinator session (worker markers absent, meshCoordinatorFor present) was
42173
+ // taking flushDelay=0 — no settle window — so its busyEpoch/lastOutputAt continuity
42174
+ // guard had no window to observe the valley and fired mid-turn "next-step" previews
42175
+ // as a finalSummary. Mirrors the isAutonomousMeshSession notion in isTransientToolConsent.
42176
+ isAutonomousMeshSession() {
42177
+ return this.isMeshWorkerSession() || !!this.settings.meshCoordinatorFor;
42178
+ }
42045
42179
  /**
42046
42180
  * ARCH-REFACTOR R1: the taskId to attribute the CURRENTLY-completing turn to.
42047
42181
  * Prefers the per-turn binding (engine.currentTurnTaskId, set when the turn was
@@ -42535,9 +42669,9 @@ var CliProviderInstance = class _CliProviderInstance {
42535
42669
  ...typeof adapterStatus?.lastOutputAt === "number" && Number.isFinite(adapterStatus.lastOutputAt) ? { lastOutputAtArm: adapterStatus.lastOutputAt } : {}
42536
42670
  };
42537
42671
  const ownsExternalHistory = !!this.adapter?.chatMessagesOwnedExternally;
42538
- const meshWorkerSession = this.isMeshWorkerSession();
42539
- const flushDelay = ownsExternalHistory ? meshWorkerSession ? NATIVE_HISTORY_MESH_IDLE_SETTLE_MS : 0 : 3e3;
42540
- LOG.debug("CLI", `[${this.type}] set completedDebouncePending duration=${duration}s ownsExternalHistory=${ownsExternalHistory} meshWorker=${meshWorkerSession} flushDelay=${flushDelay}ms generatingStartedAt=${this.generatingStartedAt}`);
42672
+ const meshSettleSession = this.isAutonomousMeshSession();
42673
+ const flushDelay = ownsExternalHistory ? meshSettleSession ? NATIVE_HISTORY_MESH_IDLE_SETTLE_MS : 0 : 3e3;
42674
+ LOG.debug("CLI", `[${this.type}] set completedDebouncePending duration=${duration}s ownsExternalHistory=${ownsExternalHistory} meshSettle=${meshSettleSession} flushDelay=${flushDelay}ms generatingStartedAt=${this.generatingStartedAt}`);
42541
42675
  this.scheduleCompletedDebounceFlush(flushDelay);
42542
42676
  }
42543
42677
  } else if (newStatus === "idle" && this.lastStatus === "starting") {
@@ -46595,6 +46729,7 @@ function readSession2(sessionPath) {
46595
46729
  var fs22 = __toESM(require("fs"));
46596
46730
  var path31 = __toESM(require("path"));
46597
46731
  var os22 = __toESM(require("os"));
46732
+ init_load_better_sqlite3();
46598
46733
  function extractTimestampValue3(value) {
46599
46734
  if (typeof value === "number" && Number.isFinite(value) && value > 0) return value;
46600
46735
  if (typeof value === "string") {
@@ -46768,6 +46903,151 @@ function parsePbFile(filePath, sessionId) {
46768
46903
  }
46769
46904
  ];
46770
46905
  }
46906
+ var AGY_STEP_TYPE_USER = 14;
46907
+ var AGY_STEP_TYPE_MODEL = 15;
46908
+ function readVarint(buf, offset) {
46909
+ let result = 0;
46910
+ let shift = 0;
46911
+ let i = offset;
46912
+ while (i < buf.length) {
46913
+ const byte = buf[i];
46914
+ i += 1;
46915
+ result += (byte & 127) * Math.pow(2, shift);
46916
+ if ((byte & 128) === 0) return [result, i];
46917
+ shift += 7;
46918
+ if (shift > 63) break;
46919
+ }
46920
+ return [result, i];
46921
+ }
46922
+ function decodeProtoFields(buf) {
46923
+ const fields = [];
46924
+ let i = 0;
46925
+ while (i < buf.length) {
46926
+ const [key2, afterKey] = readVarint(buf, i);
46927
+ if (afterKey === i) break;
46928
+ i = afterKey;
46929
+ const field = Math.floor(key2 / 8);
46930
+ const wireType = key2 & 7;
46931
+ if (field <= 0) break;
46932
+ if (wireType === 0) {
46933
+ const [value, next] = readVarint(buf, i);
46934
+ if (next === i) break;
46935
+ i = next;
46936
+ fields.push({ field, wireType, varint: value });
46937
+ } else if (wireType === 2) {
46938
+ const [len, afterLen] = readVarint(buf, i);
46939
+ i = afterLen;
46940
+ if (len < 0 || i + len > buf.length) break;
46941
+ fields.push({ field, wireType, bytes: buf.subarray(i, i + len) });
46942
+ i += len;
46943
+ } else if (wireType === 5) {
46944
+ i += 4;
46945
+ } else if (wireType === 1) {
46946
+ i += 8;
46947
+ } else {
46948
+ break;
46949
+ }
46950
+ }
46951
+ return fields;
46952
+ }
46953
+ function firstLenField(buf, field) {
46954
+ for (const f of decodeProtoFields(buf)) {
46955
+ if (f.field === field && f.wireType === 2 && f.bytes) return f.bytes;
46956
+ }
46957
+ return null;
46958
+ }
46959
+ function looksLikeText(buf) {
46960
+ if (buf.length === 0) return false;
46961
+ let printable = 0;
46962
+ for (let i = 0; i < buf.length; i++) {
46963
+ const b = buf[i];
46964
+ if (b >= 32 && b <= 126 || b === 9 || b === 10 || b === 13 || b >= 128) printable += 1;
46965
+ }
46966
+ return printable / buf.length >= 0.9;
46967
+ }
46968
+ function stripAnswerMarker(text) {
46969
+ return text.replace(/^\s*MARKER_V1\s*/, "");
46970
+ }
46971
+ function extractModelAnswer(payload) {
46972
+ const inner = firstLenField(payload, 20);
46973
+ if (!inner) return "";
46974
+ const answer = firstLenField(inner, 1) ?? firstLenField(inner, 8);
46975
+ if (!answer || !looksLikeText(answer)) return "";
46976
+ return stripAnswerMarker(answer.toString("utf-8")).trim();
46977
+ }
46978
+ function extractUserPrompt(payload) {
46979
+ const inner = firstLenField(payload, 19);
46980
+ if (!inner) return "";
46981
+ const raw = firstLenField(inner, 2) ?? firstLenField(inner, 3);
46982
+ if (!raw || !looksLikeText(raw)) return "";
46983
+ const text = raw.toString("utf-8").trim();
46984
+ if (!text) return "";
46985
+ return extractUserRequestContent(text);
46986
+ }
46987
+ function parseConversationDb(filePath, sessionId, workspace) {
46988
+ let db;
46989
+ try {
46990
+ const Database = loadBetterSqlite3();
46991
+ db = new Database(filePath, { readonly: true, fileMustExist: true });
46992
+ } catch {
46993
+ return null;
46994
+ }
46995
+ let rows;
46996
+ try {
46997
+ rows = db.prepare(
46998
+ `SELECT idx, step_type, step_payload
46999
+ FROM steps
47000
+ WHERE step_type IN (${AGY_STEP_TYPE_USER}, ${AGY_STEP_TYPE_MODEL})
47001
+ ORDER BY idx ASC`
47002
+ ).all();
47003
+ } catch {
47004
+ return null;
47005
+ } finally {
47006
+ try {
47007
+ db.close();
47008
+ } catch {
47009
+ }
47010
+ }
47011
+ if (!Array.isArray(rows) || rows.length === 0) return null;
47012
+ const normalizedWorkspace = typeof workspace === "string" ? workspace.trim() : "";
47013
+ const baseTs = statMtimeMs3(filePath) || Date.now();
47014
+ const messages = [];
47015
+ for (const row of rows) {
47016
+ const payload = row.step_payload;
47017
+ if (!payload || !Buffer.isBuffer(payload) || payload.length === 0) continue;
47018
+ const receivedAt = baseTs + messages.length;
47019
+ if (row.step_type === AGY_STEP_TYPE_USER) {
47020
+ const content = extractUserPrompt(payload);
47021
+ if (!content) continue;
47022
+ const msg = {
47023
+ ts: new Date(receivedAt).toISOString(),
47024
+ receivedAt,
47025
+ role: "user",
47026
+ content,
47027
+ kind: "standard",
47028
+ agent: "antigravity-cli",
47029
+ historySessionId: sessionId
47030
+ };
47031
+ if (normalizedWorkspace) msg.workspace = normalizedWorkspace;
47032
+ messages.push(msg);
47033
+ } else if (row.step_type === AGY_STEP_TYPE_MODEL) {
47034
+ const content = extractModelAnswer(payload);
47035
+ if (!content) continue;
47036
+ const msg = {
47037
+ ts: new Date(receivedAt).toISOString(),
47038
+ receivedAt,
47039
+ role: "assistant",
47040
+ content,
47041
+ kind: "standard",
47042
+ agent: "antigravity-cli",
47043
+ historySessionId: sessionId
47044
+ };
47045
+ if (normalizedWorkspace) msg.workspace = normalizedWorkspace;
47046
+ messages.push(msg);
47047
+ }
47048
+ }
47049
+ return messages.length > 0 ? messages : null;
47050
+ }
46771
47051
  function readSession3(sessionPath, sessionId, workspace) {
46772
47052
  if (!sessionPath || !path31.isAbsolute(sessionPath)) return null;
46773
47053
  if (!fs22.existsSync(sessionPath)) return null;
@@ -46790,6 +47070,21 @@ function readSession3(sessionPath, sessionId, workspace) {
46790
47070
  workspace
46791
47071
  };
46792
47072
  }
47073
+ if (sessionPath.endsWith(".db")) {
47074
+ const dbSessionId = sessionId || path31.basename(sessionPath, ".db");
47075
+ if (!isUuidLike(dbSessionId)) return null;
47076
+ const messages = parseConversationDb(sessionPath, dbSessionId, workspace);
47077
+ if (!messages || messages.length === 0) return null;
47078
+ return {
47079
+ messages,
47080
+ providerSessionId: dbSessionId,
47081
+ source: "provider-native",
47082
+ sourcePath: sessionPath,
47083
+ sourceMtimeMs,
47084
+ nativeHistoryCoverage: "full",
47085
+ workspace
47086
+ };
47087
+ }
46793
47088
  if (sessionPath.endsWith(".pb")) {
46794
47089
  const pbSessionId = sessionId || path31.basename(sessionPath, ".pb");
46795
47090
  if (!isUuidLike(pbSessionId)) return null;
@@ -47018,7 +47313,7 @@ function resolveSourcePath(reader, workspace, sessionId, sessionStartedAtMs) {
47018
47313
  case "codex-cli":
47019
47314
  return resolveCodexPath(workspace, sessionId, sessionStartedAtMs);
47020
47315
  case "antigravity-cli":
47021
- return resolveAntigravityPath(workspace);
47316
+ return resolveAntigravityPath(workspace, sessionId);
47022
47317
  case "hermes-cli":
47023
47318
  return resolveHermesPath(workspace, sessionId);
47024
47319
  }
@@ -47133,16 +47428,25 @@ function resolveRealPath(value) {
47133
47428
  return value;
47134
47429
  }
47135
47430
  }
47136
- function resolveAntigravityPath(workspace) {
47431
+ function resolveAntigravityPath(workspace, sessionId) {
47137
47432
  void workspace;
47138
- const brainRoot2 = path33.join(os24.homedir(), ".gemini", "antigravity-cli", "brain");
47139
- if (!fs24.existsSync(brainRoot2)) return null;
47140
- const cutoff = Date.now() - RECENT_WINDOW_MS;
47141
- 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);
47142
- for (const e of entries) {
47143
- const t = path33.join(e.p, ".system_generated", "logs", "transcript.jsonl");
47144
- if (fs24.existsSync(t)) return t;
47433
+ const agyRoot = path33.join(os24.homedir(), ".gemini", "antigravity-cli");
47434
+ if (sessionId && isUuidLikeSessionId2(sessionId)) {
47435
+ const dbPath = path33.join(agyRoot, "conversations", `${sessionId}.db`);
47436
+ if (fs24.existsSync(dbPath)) return dbPath;
47437
+ }
47438
+ const brainRoot2 = path33.join(agyRoot, "brain");
47439
+ if (fs24.existsSync(brainRoot2)) {
47440
+ const cutoff = Date.now() - RECENT_WINDOW_MS;
47441
+ 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);
47442
+ for (const e of entries) {
47443
+ const t = path33.join(e.p, ".system_generated", "logs", "transcript.jsonl");
47444
+ if (fs24.existsSync(t)) return t;
47445
+ }
47145
47446
  }
47447
+ const convRoot = path33.join(agyRoot, "conversations");
47448
+ const newestDb = newestRecentFile2(convRoot, /^[0-9a-f-]+\.db$/i);
47449
+ if (newestDb) return newestDb;
47146
47450
  return null;
47147
47451
  }
47148
47452
  function resolveHermesPath(workspace, sessionId) {
@@ -51414,8 +51718,8 @@ var meshCoordinatorLaunchHandlers = {
51414
51718
  };
51415
51719
  const buildOperatingNotesBestEffort = async (id) => {
51416
51720
  try {
51417
- const { readLedgerEntries: readLedgerEntries2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
51418
- const noteEntries = readLedgerEntries2(id, { kind: ["coordinator_operating_note"], tail: 20 });
51721
+ const { readOperatingNotes: readOperatingNotes2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
51722
+ const noteEntries = readOperatingNotes2(id, { tail: 20 });
51419
51723
  const notes = noteEntries.map((e) => {
51420
51724
  const p = e.payload || {};
51421
51725
  const text = typeof p.text === "string" ? p.text.trim() : "";
@@ -66110,6 +66414,10 @@ var V1_CONTRACT_VERSION = "1.0.0";
66110
66414
  MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS,
66111
66415
  MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS,
66112
66416
  NodePtyTransportFactory,
66417
+ OPERATING_NOTE_DEDUPE_WINDOW,
66418
+ OPERATING_NOTE_KEEP_LATEST,
66419
+ OPERATING_NOTE_KIND,
66420
+ OPERATING_NOTE_TOMBSTONE_KIND,
66113
66421
  P2pRelayFailureError,
66114
66422
  PRUNABLE_ORPHAN_STALE_REASONS,
66115
66423
  ProviderCliAdapter,
@@ -66279,6 +66587,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
66279
66587
  isManagedStatusWaiting,
66280
66588
  isManagedStatusWorking,
66281
66589
  isMeshHostOwner,
66590
+ isOperatingNoteTombstoned,
66282
66591
  isP2pRelayTransportFailure,
66283
66592
  isPathInside,
66284
66593
  isSessionHostLiveRuntime,
@@ -66347,6 +66656,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
66347
66656
  prepareSessionChatTailUpdate,
66348
66657
  prepareSessionModalUpdate,
66349
66658
  probeCdpPort,
66659
+ pruneOperatingNotes,
66350
66660
  pruneStaleDirectDispatches,
66351
66661
  queuePendingMeshCoordinatorEvent,
66352
66662
  readAntigravityCliSession,
@@ -66359,6 +66669,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
66359
66669
  readLedgerSlice,
66360
66670
  readLedgerSliceFromStore,
66361
66671
  readMeshCompletionSummary,
66672
+ readOperatingNotes,
66362
66673
  reconcileDirectDispatchCompletionFromTranscript,
66363
66674
  recordCompletionConflict,
66364
66675
  recordDebugTrace,
@@ -66416,6 +66727,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
66416
66727
  summarizeMeshMagiActivity,
66417
66728
  summarizeMeshMission,
66418
66729
  summarizeMissionTasks,
66730
+ tombstoneOperatingNote,
66419
66731
  triggerMeshQueue,
66420
66732
  unregisterMeshCoordinator,
66421
66733
  updateConfig,