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

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.
@@ -3,5 +3,13 @@
3
3
  * native-history / source-resolution / normalization helpers they use.
4
4
  */
5
5
  import type { CommandResult, CommandHelpers } from './handler.js';
6
+ /**
7
+ * Test-only: clear the in-memory read-pin map and re-arm cold-start hydration so
8
+ * each test starts from a clean pin state. The on-disk mirror is isolated per
9
+ * test process via ADHDEV_CONFIG_DIR (test/helpers/setup-env.ts); this resets the
10
+ * module-level cache that would otherwise leak a pin across tests sharing the
11
+ * worker. Not part of the runtime contract.
12
+ */
13
+ export declare function __resetProviderSessionPinsForTest(): void;
6
14
  export declare function handleChatHistory(h: CommandHelpers, args: any): Promise<CommandResult>;
7
15
  export declare function handleReadChat(h: CommandHelpers, args: any): Promise<CommandResult>;
@@ -10,5 +10,5 @@
10
10
  export { READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, buildSendInputSignature } from './chat-commands-shared.js';
11
11
  export { evaluateReadChatNodeWorkspaceScope } from './chat-commands-scope.js';
12
12
  export { sanitizeDebugBundleValue, handleGetChatDebugBundle } from './chat-commands-debug-bundle.js';
13
- export { handleChatHistory, handleReadChat } from './chat-commands-read.js';
13
+ export { handleChatHistory, handleReadChat, __resetProviderSessionPinsForTest } from './chat-commands-read.js';
14
14
  export { handleSendChat, handleListChats, handleNewChat, handleSwitchChat, handleSetMode, handleChangeModel, handleSetThoughtLevel, handleResolveAction, } from './chat-commands-write.js';
@@ -114,6 +114,7 @@ export declare function readProviderChatHistory(agentType: string, options?: {
114
114
  sessionStartedAtMs?: number;
115
115
  envOverrides?: Record<string, string>;
116
116
  forceRefresh?: boolean;
117
+ instanceId?: string;
117
118
  }): {
118
119
  messages: HistoryMessage[];
119
120
  hasMore: boolean;
@@ -21,6 +21,17 @@ export interface DaemonState {
21
21
  sessionNotificationDismissals: Record<string, string>;
22
22
  /** Current notification unread override ids keyed by stable session target */
23
23
  sessionNotificationUnreadOverrides: Record<string, string>;
24
+ /**
25
+ * Resolved provider-native conversation id for a live session, keyed by the
26
+ * ADHDev/mesh session id. Persisted so it survives a daemon restart: a
27
+ * provider whose on-disk store is keyed by an internally-generated id it
28
+ * never exposes on the CLI (antigravity — no --session-id) can then exact-bind
29
+ * its conversation .db after restart instead of re-running the mtime/recency
30
+ * heuristic, which drops the store once idle and collapses read_chat to the
31
+ * PTY parse (user echo only, assistant tail lost). Mirrors the in-memory read
32
+ * pin (chat-commands-read lastBoundProviderSessionIdByMeshSession).
33
+ */
34
+ sessionProviderSessionPins: Record<string, string>;
24
35
  }
25
36
  /**
26
37
  * Load runtime state from disk
@@ -34,3 +45,22 @@ export declare function saveState(state: DaemonState): void;
34
45
  * Reset runtime state
35
46
  */
36
47
  export declare function resetState(): void;
48
+ /**
49
+ * Load the full persisted session→provider-conversation pin map (sessionId →
50
+ * provider-native conversation id). Survives daemon restart. Empty object when
51
+ * none recorded or the state file is unreadable.
52
+ */
53
+ export declare function loadPersistedProviderSessionPins(): Record<string, string>;
54
+ /**
55
+ * Persist one session→provider-conversation pin. Load-mutate-save against the
56
+ * on-disk state so it survives a daemon restart; a no-op when the value already
57
+ * matches (avoids rewriting state.json on every read). Never clears a pin with an
58
+ * empty value.
59
+ */
60
+ export declare function recordPersistedProviderSessionPin(sessionId: string, providerSessionId: string): void;
61
+ /**
62
+ * Test-only: drop all persisted session→provider-conversation pins from disk.
63
+ * Used by tests that assert a clean "no pin" state so a sibling test's write to
64
+ * the shared per-process ADHDEV_CONFIG_DIR does not leak in.
65
+ */
66
+ export declare function clearPersistedProviderSessionPins(): void;
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 ? "cfb46b13fb8f556e4cb7179c4503ac3c86923d92" : void 0) ?? "unknown";
413
- const commitShort = readInjected(true ? "cfb46b13" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
414
- const version = readInjected(true ? "0.9.82-rc.474" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
415
- const builtAt = readInjected(true ? "2026-07-06T03:34:46.223Z" : void 0);
412
+ const commit = readInjected(true ? "f3bc279bf108da3a23da4e0e33ebdc41d851930c" : void 0) ?? "unknown";
413
+ const commitShort = readInjected(true ? "f3bc279b" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
414
+ const version = readInjected(true ? "0.9.82-rc.476" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
415
+ const builtAt = readInjected(true ? "2026-07-06T08:19:57.539Z" : void 0);
416
416
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
417
417
  return cached;
418
418
  }
@@ -16694,13 +16694,17 @@ function normalizeState(raw) {
16694
16694
  const sessionNotificationUnreadOverrides = Object.fromEntries(
16695
16695
  Object.entries(isPlainObject2(parsed.sessionNotificationUnreadOverrides) ? parsed.sessionNotificationUnreadOverrides : {}).filter(([, value]) => typeof value === "string" && value.length > 0)
16696
16696
  );
16697
+ const sessionProviderSessionPins = Object.fromEntries(
16698
+ Object.entries(isPlainObject2(parsed.sessionProviderSessionPins) ? parsed.sessionProviderSessionPins : {}).filter(([key2, value]) => typeof key2 === "string" && key2.length > 0 && typeof value === "string" && value.length > 0)
16699
+ );
16697
16700
  return {
16698
16701
  recentActivity,
16699
16702
  savedProviderSessions,
16700
16703
  sessionReads,
16701
16704
  sessionReadMarkers,
16702
16705
  sessionNotificationDismissals,
16703
- sessionNotificationUnreadOverrides
16706
+ sessionNotificationUnreadOverrides,
16707
+ sessionProviderSessionPins
16704
16708
  };
16705
16709
  }
16706
16710
  function loadState() {
@@ -16723,6 +16727,20 @@ function saveState(state) {
16723
16727
  function resetState() {
16724
16728
  saveState({ ...DEFAULT_STATE });
16725
16729
  }
16730
+ function loadPersistedProviderSessionPins() {
16731
+ return { ...loadState().sessionProviderSessionPins };
16732
+ }
16733
+ function recordPersistedProviderSessionPin(sessionId, providerSessionId) {
16734
+ const key2 = typeof sessionId === "string" ? sessionId.trim() : "";
16735
+ const value = typeof providerSessionId === "string" ? providerSessionId.trim() : "";
16736
+ if (!key2 || !value) return;
16737
+ const state = loadState();
16738
+ if (state.sessionProviderSessionPins[key2] === value) return;
16739
+ saveState({
16740
+ ...state,
16741
+ sessionProviderSessionPins: { ...state.sessionProviderSessionPins, [key2]: value }
16742
+ });
16743
+ }
16726
16744
  var import_fs14, import_path11, DEFAULT_STATE;
16727
16745
  var init_state_store = __esm({
16728
16746
  "src/config/state-store.ts"() {
@@ -16736,7 +16754,8 @@ var init_state_store = __esm({
16736
16754
  sessionReads: {},
16737
16755
  sessionReadMarkers: {},
16738
16756
  sessionNotificationDismissals: {},
16739
- sessionNotificationUnreadOverrides: {}
16757
+ sessionNotificationUnreadOverrides: {},
16758
+ sessionProviderSessionPins: {}
16740
16759
  };
16741
16760
  }
16742
16761
  });
@@ -32034,10 +32053,11 @@ function normalizeProviderNativeHistoryRecords(agentType, historySessionId, reco
32034
32053
  return sanitizeHistoryMessage(agentType, base);
32035
32054
  }).filter(Boolean);
32036
32055
  }
32037
- function callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, historySessionId, workspace, excludeInProgressTurn, sessionStartedAtMs, envOverrides, forceRefresh) {
32056
+ function callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, historySessionId, workspace, excludeInProgressTurn, sessionStartedAtMs, envOverrides, forceRefresh, instanceId) {
32038
32057
  const fn = getProviderNativeHistoryScript(scripts, canonicalHistory, "readSession");
32039
32058
  if (!fn) return null;
32040
32059
  const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId || "");
32060
+ const normalizedInstanceId = typeof instanceId === "string" ? instanceId.trim() : "";
32041
32061
  const result = fn({
32042
32062
  agentType,
32043
32063
  sessionId: normalizedSessionId,
@@ -32052,6 +32072,12 @@ function callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, his
32052
32072
  // which leaves the guard disarmed so discovery still works.
32053
32073
  providerSessionId: normalizedSessionId,
32054
32074
  historySessionId: normalizedSessionId,
32075
+ // Stable per-session owner key for the antigravity conversation-claim
32076
+ // registry (see dispatcher.resolveAntigravityPath / antigravityOwnerToken).
32077
+ // Equals the session registry's sessionId and the provider instance's
32078
+ // instanceId, so read side and instance side derive the identical claim
32079
+ // owner token and two concurrent antigravity sessions never cross-bind.
32080
+ instanceId: normalizedInstanceId || void 0,
32055
32081
  workspace,
32056
32082
  format: canonicalHistory?.format,
32057
32083
  watchPath: canonicalHistory?.watchPath,
@@ -32059,7 +32085,7 @@ function callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, his
32059
32085
  sessionStartedAtMs,
32060
32086
  envOverrides,
32061
32087
  forceRefresh: forceRefresh === true,
32062
- args: { sessionId: normalizedSessionId, historySessionId: normalizedSessionId, workspace, excludeInProgressTurn: excludeInProgressTurn === true, sessionStartedAtMs, envOverrides, forceRefresh: forceRefresh === true }
32088
+ args: { sessionId: normalizedSessionId, historySessionId: normalizedSessionId, instanceId: normalizedInstanceId || void 0, workspace, excludeInProgressTurn: excludeInProgressTurn === true, sessionStartedAtMs, envOverrides, forceRefresh: forceRefresh === true }
32063
32089
  });
32064
32090
  if (!result || typeof result !== "object") return null;
32065
32091
  const records = normalizeProviderNativeHistoryRecords(agentType, normalizedSessionId, result.messages || result.records);
@@ -32075,11 +32101,11 @@ function callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, his
32075
32101
  unavailableReason: typeof result.unavailableReason === "string" ? result.unavailableReason.trim() : void 0
32076
32102
  };
32077
32103
  }
32078
- function buildNativeHistoryReadResult(agentType, canonicalHistory, scripts, historySessionId, workspace, excludeInProgressTurn, sessionStartedAtMs, envOverrides, forceRefresh) {
32104
+ function buildNativeHistoryReadResult(agentType, canonicalHistory, scripts, historySessionId, workspace, excludeInProgressTurn, sessionStartedAtMs, envOverrides, forceRefresh, instanceId) {
32079
32105
  const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId || "");
32080
32106
  const normalizedWorkspace = typeof workspace === "string" ? workspace.trim() : "";
32081
32107
  if (!canonicalHistory || !normalizedSessionId && !normalizedWorkspace || !isNativeSourceCanonicalHistory(canonicalHistory)) return null;
32082
- return callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, normalizedSessionId, workspace, excludeInProgressTurn, sessionStartedAtMs, envOverrides, forceRefresh);
32108
+ return callProviderNativeHistoryRead(agentType, canonicalHistory, scripts, normalizedSessionId, workspace, excludeInProgressTurn, sessionStartedAtMs, envOverrides, forceRefresh, instanceId);
32083
32109
  }
32084
32110
  function materializeNativeHistoryToMirror(agentType, canonicalHistory, historySessionId, workspace, scripts) {
32085
32111
  const normalizedSessionId = normalizeSavedHistorySessionId(historySessionId);
@@ -32108,7 +32134,7 @@ function isNativeSourceCanonicalHistory(canonicalHistory) {
32108
32134
  }
32109
32135
  function readProviderChatHistory(agentType, options = {}) {
32110
32136
  if (isNativeSourceCanonicalHistory(options.canonicalHistory) && (options.historySessionId || options.workspace)) {
32111
- const nativeResult = buildNativeHistoryReadResult(agentType, options.canonicalHistory, options.scripts, options.historySessionId, options.workspace, options.excludeInProgressTurn, options.sessionStartedAtMs, options.envOverrides, options.forceRefresh);
32137
+ const nativeResult = buildNativeHistoryReadResult(agentType, options.canonicalHistory, options.scripts, options.historySessionId, options.workspace, options.excludeInProgressTurn, options.sessionStartedAtMs, options.envOverrides, options.forceRefresh, options.instanceId);
32112
32138
  if (!nativeResult) return { messages: [], hasMore: false, source: "native-unavailable" };
32113
32139
  return {
32114
32140
  ...pageHistoryRecords(agentType, nativeResult.records, options.offset || 0, options.limit || 30, options.excludeRecentCount || 0, options.historyBehavior),
@@ -34079,6 +34105,7 @@ init_debug_trace();
34079
34105
  // src/commands/chat-commands-read.ts
34080
34106
  var path16 = __toESM(require("path"));
34081
34107
  init_contracts2();
34108
+ init_state_store();
34082
34109
  init_coordinator_registry();
34083
34110
  init_logger();
34084
34111
  init_debug_trace();
@@ -34434,15 +34461,33 @@ init_chat_message_normalization();
34434
34461
  var HOT_TAIL_MIN_LIMIT = 60;
34435
34462
  var CLI_NATIVE_TRANSCRIPT_PROVIDERS = /* @__PURE__ */ new Set(["codex-cli", "claude-cli", "hermes-cli", "antigravity-cli"]);
34436
34463
  var lastBoundProviderSessionIdByMeshSession = /* @__PURE__ */ new Map();
34464
+ var persistedProviderSessionPinsHydrated = false;
34465
+ function hydratePersistedProviderSessionPinsOnce() {
34466
+ if (persistedProviderSessionPinsHydrated) return;
34467
+ persistedProviderSessionPinsHydrated = true;
34468
+ try {
34469
+ for (const [key2, value] of Object.entries(loadPersistedProviderSessionPins())) {
34470
+ if (!lastBoundProviderSessionIdByMeshSession.has(key2)) {
34471
+ lastBoundProviderSessionIdByMeshSession.set(key2, value);
34472
+ }
34473
+ }
34474
+ } catch {
34475
+ }
34476
+ }
34437
34477
  function recordBoundProviderSessionId(meshSessionId, providerSessionId) {
34438
34478
  const key2 = typeof meshSessionId === "string" ? meshSessionId.trim() : "";
34439
34479
  const value = typeof providerSessionId === "string" ? providerSessionId.trim() : "";
34440
34480
  if (!key2 || !value) return;
34441
34481
  lastBoundProviderSessionIdByMeshSession.set(key2, value);
34482
+ try {
34483
+ recordPersistedProviderSessionPin(key2, value);
34484
+ } catch {
34485
+ }
34442
34486
  }
34443
34487
  function getBoundProviderSessionIdPin(meshSessionId) {
34444
34488
  const key2 = typeof meshSessionId === "string" ? meshSessionId.trim() : "";
34445
34489
  if (!key2) return void 0;
34490
+ hydratePersistedProviderSessionPinsOnce();
34446
34491
  const pinned = lastBoundProviderSessionIdByMeshSession.get(key2);
34447
34492
  return pinned && pinned.trim() ? pinned.trim() : void 0;
34448
34493
  }
@@ -35043,7 +35088,8 @@ function readCliProviderNativeHistory(agentStr, args) {
35043
35088
  scripts: args.scripts,
35044
35089
  excludeInProgressTurn: args.excludeInProgressTurn,
35045
35090
  sessionStartedAtMs: args.sessionStartedAtMs,
35046
- envOverrides: args.envOverrides
35091
+ envOverrides: args.envOverrides,
35092
+ instanceId: args.instanceId
35047
35093
  });
35048
35094
  const boundProviderSessionId = typeof sessionHistory?.providerSessionId === "string" ? sessionHistory.providerSessionId.trim() : "";
35049
35095
  return {
@@ -35302,6 +35348,7 @@ async function handleChatHistory(h, args) {
35302
35348
  scripts: provider?.scripts,
35303
35349
  sessionStartedAtMs: sessionStartedAtMsFromRegistry(h, args?.targetSessionId),
35304
35350
  envOverrides: sessionSpawnEnvFromAdapter(h, args?.targetSessionId),
35351
+ instanceId: typeof args?.targetSessionId === "string" ? args.targetSessionId : void 0,
35305
35352
  pinnedProviderSessionId: getBoundProviderSessionIdPin(args?.targetSessionId)
35306
35353
  }) : readProviderChatHistory(agentStr, {
35307
35354
  canonicalHistory: provider?.nativeHistory,
@@ -35442,10 +35489,15 @@ async function handleReadChat(h, args) {
35442
35489
  let nativeHistory = null;
35443
35490
  let nativeHistoryError;
35444
35491
  if (supportsNative) {
35492
+ const pinnedProviderSessionIdForRead = getBoundProviderSessionIdPin(targetSessionId);
35493
+ const nativeReadSessionIdIsRuntimeFallback = Boolean(
35494
+ targetSessionId && nativeHistoryReadSessionId === targetSessionId && !getExplicitHistorySessionId(args)
35495
+ );
35496
+ const effectiveNativeReadSessionId = nativeReadSessionIdIsRuntimeFallback ? pinnedProviderSessionIdForRead || void 0 : nativeHistoryReadSessionId;
35445
35497
  try {
35446
35498
  nativeHistory = readCliProviderNativeHistory(agentStr, {
35447
35499
  canonicalHistory: provider?.nativeHistory,
35448
- historySessionId: nativeHistoryReadSessionId,
35500
+ historySessionId: effectiveNativeReadSessionId,
35449
35501
  workspace,
35450
35502
  offset: 0,
35451
35503
  limit: nativeHistoryLimit,
@@ -35455,11 +35507,14 @@ async function handleReadChat(h, args) {
35455
35507
  excludeInProgressTurn: returnedStatus === "waiting_approval",
35456
35508
  sessionStartedAtMs: sessionStartedAtMsFromRegistry(h, args?.targetSessionId),
35457
35509
  envOverrides: sessionSpawnEnvFromAdapter(h, args?.targetSessionId),
35458
- pinnedProviderSessionId: getBoundProviderSessionIdPin(targetSessionId),
35510
+ // Stable per-session identity for antigravity's conversation-claim
35511
+ // owner token (== session registry sessionId == instance instanceId).
35512
+ instanceId: typeof args?.targetSessionId === "string" ? args.targetSessionId : void 0,
35513
+ pinnedProviderSessionId: pinnedProviderSessionIdForRead,
35459
35514
  // Last-resort only when no pin was ever recorded for this
35460
35515
  // session; the downstream workspace-overlap safety gate
35461
35516
  // still filters an aliased session out.
35462
- allowWorkspaceLatestFallback: !getBoundProviderSessionIdPin(targetSessionId)
35517
+ allowWorkspaceLatestFallback: !pinnedProviderSessionIdForRead
35463
35518
  });
35464
35519
  const resolvedProviderSessionId = typeof nativeHistory?.providerSessionId === "string" ? nativeHistory.providerSessionId.trim() : "";
35465
35520
  if (resolvedProviderSessionId) {
@@ -35504,7 +35559,8 @@ async function handleReadChat(h, args) {
35504
35559
  scripts: provider?.scripts,
35505
35560
  excludeInProgressTurn: returnedStatus === "waiting_approval",
35506
35561
  sessionStartedAtMs,
35507
- envOverrides: sessionSpawnEnvFromAdapter(h, args?.targetSessionId)
35562
+ envOverrides: sessionSpawnEnvFromAdapter(h, args?.targetSessionId),
35563
+ instanceId: typeof args?.targetSessionId === "string" ? args.targetSessionId : void 0
35508
35564
  });
35509
35565
  nativeHistoryError = void 0;
35510
35566
  nativeMessages = nativeHistory && Array.isArray(nativeHistory.messages) ? normalizeAndFilterNativeHistory(h, agentStr, args, nativeHistory.messages, nativeHistory.providerSessionId) : [];
@@ -35726,6 +35782,7 @@ async function handleReadChat(h, args) {
35726
35782
  scripts: provider?.scripts,
35727
35783
  sessionStartedAtMs: sessionStartedAtMsFromRegistry(h, args?.targetSessionId),
35728
35784
  envOverrides: sessionSpawnEnvFromAdapter(h, args?.targetSessionId),
35785
+ instanceId: typeof args?.targetSessionId === "string" ? args.targetSessionId : void 0,
35729
35786
  pinnedProviderSessionId: pinnedProviderSessionIdForHistory,
35730
35787
  // Last-resort only when no pin was ever recorded AND the
35731
35788
  // runtime fallback did not resolve a real provider session.
@@ -45396,12 +45453,24 @@ var CliProviderInstance = class _CliProviderInstance {
45396
45453
  }
45397
45454
  /**
45398
45455
  * Owner token for this session in the antigravity conversation-claim
45399
- * registry. Derived identically to the dispatcher's read-side token
45400
- * (workspace + spawn time) so the claims the dispatcher records under this
45401
- * session are the ones dispose() releases.
45456
+ * registry. Keyed on the daemon instance id — the SAME value the session
45457
+ * registry stores as this session's `sessionId` (see cli-manager
45458
+ * `sessionRegistry.register({ sessionId: cliInstance.instanceId })`) and the
45459
+ * read side hands the dispatcher as `instanceId`. Both sides therefore
45460
+ * derive the identical `iid:<instanceId>` token, so the claims the
45461
+ * dispatcher records under this session are exactly the ones dispose()
45462
+ * releases.
45463
+ *
45464
+ * This must NOT be derived from a spawn timestamp: the instance's
45465
+ * `startedAt`, the adapter's `spawnedAtMs`, and the session registry's
45466
+ * `spawnedAtMs` are three INDEPENDENT `Date.now()` samples for the one
45467
+ * session, so a workspace+spawn-time token computed here would never equal
45468
+ * the read side's — the claim isolation then silently collapses and two
45469
+ * concurrent antigravity sessions cross-bind each other's conversation .db
45470
+ * (coordinator+worker chat crosswire).
45402
45471
  */
45403
45472
  antigravityClaimOwner() {
45404
- return antigravityOwnerToken(this.workingDir, this.startedAt);
45473
+ return antigravityOwnerToken(this.workingDir, this.startedAt, this.instanceId);
45405
45474
  }
45406
45475
  dispose() {
45407
45476
  if (this.type === "antigravity-cli") {
@@ -51274,6 +51343,13 @@ function createNativeHistoryDispatcher(reader) {
51274
51343
  if (requestedProviderSid && session.providerSessionId && session.providerSessionId !== requestedProviderSid) {
51275
51344
  return null;
51276
51345
  }
51346
+ let resolvedProviderSessionId = session.providerSessionId;
51347
+ if (reader === "antigravity-cli") {
51348
+ const onDiskUuid = extractAntigravityConversationUuid(session.sourcePath || sourcePath);
51349
+ if (onDiskUuid && (!resolvedProviderSessionId || resolvedProviderSessionId === sessionId)) {
51350
+ resolvedProviderSessionId = onDiskUuid;
51351
+ }
51352
+ }
51277
51353
  return {
51278
51354
  messages: session.messages.map((m) => ({
51279
51355
  role: normalizeRole2(m.role),
@@ -51282,7 +51358,7 @@ function createNativeHistoryDispatcher(reader) {
51282
51358
  kind: typeof m.kind === "string" ? m.kind : "standard",
51283
51359
  workspace: typeof m.workspace === "string" ? m.workspace : workspace || void 0
51284
51360
  })),
51285
- providerSessionId: session.providerSessionId,
51361
+ providerSessionId: resolvedProviderSessionId,
51286
51362
  sourcePath: session.sourcePath,
51287
51363
  sourceMtimeMs: session.sourceMtimeMs,
51288
51364
  nativeHistoryCoverage: session.nativeHistoryCoverage || "full"
@@ -51411,6 +51487,17 @@ function resolveRealPath(value) {
51411
51487
  return value;
51412
51488
  }
51413
51489
  }
51490
+ function extractAntigravityConversationUuid(sourcePath) {
51491
+ if (!sourcePath) return "";
51492
+ const segments = sourcePath.split(/[\\/]/);
51493
+ const base = segments[segments.length - 1] || "";
51494
+ const baseMatch = /^([0-9a-f-]+)\.(?:db|pb)$/i.exec(base);
51495
+ if (baseMatch && isUuidLikeSessionId2(baseMatch[1])) return baseMatch[1];
51496
+ for (const seg of segments) {
51497
+ if (isUuidLikeSessionId2(seg)) return seg;
51498
+ }
51499
+ return "";
51500
+ }
51414
51501
  var AGY_SPAWN_CLAIM_GRACE_MS = 2e3;
51415
51502
  function resolveAntigravityPath(workspace, sessionId, sessionStartedAtMs, instanceId) {
51416
51503
  const agyRoot = path34.join(os25.homedir(), ".gemini", "antigravity-cli");
@@ -51449,6 +51536,7 @@ function pickUnboundConversationDb(convRoot, sessionFloorMs, owner) {
51449
51536
  } catch {
51450
51537
  return null;
51451
51538
  }
51539
+ const applyRecencyCutoff = !(sessionFloorMs > 0);
51452
51540
  const recencyCutoff = Date.now() - RECENT_WINDOW_MS;
51453
51541
  const candidates = [];
51454
51542
  for (const entry of entries) {
@@ -51459,7 +51547,7 @@ function pickUnboundConversationDb(convRoot, sessionFloorMs, owner) {
51459
51547
  if (isAntigravityConversationClaimedByOther(uuid, owner)) continue;
51460
51548
  const p = path34.join(convRoot, entry.name);
51461
51549
  const mtime = safeMtime(p);
51462
- if (mtime < recencyCutoff) continue;
51550
+ if (applyRecencyCutoff && mtime < recencyCutoff) continue;
51463
51551
  candidates.push({ path: p, uuid, mtime, birth: safeBirthtime(p) });
51464
51552
  }
51465
51553
  if (candidates.length === 0) return null;