@adhdev/daemon-core 0.9.82-rc.368 → 0.9.82-rc.369

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
@@ -311,10 +311,10 @@ function readInjected(value) {
311
311
  }
312
312
  function getDaemonBuildInfo() {
313
313
  if (cached) return cached;
314
- const commit = readInjected(true ? "8cb6cfc5399f55c6b625095bacc9a27e1741df17" : void 0) ?? "unknown";
315
- const commitShort = readInjected(true ? "8cb6cfc5" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
316
- const version = readInjected(true ? "0.9.82-rc.368" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
317
- const builtAt = readInjected(true ? "2026-06-24T06:14:32.255Z" : void 0);
314
+ const commit = readInjected(true ? "4464cd9f1effac841aa1fbef3b1691d2f06d64e4" : void 0) ?? "unknown";
315
+ const commitShort = readInjected(true ? "4464cd9f" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
316
+ const version = readInjected(true ? "0.9.82-rc.369" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
317
+ const builtAt = readInjected(true ? "2026-06-24T08:22:14.501Z" : void 0);
318
318
  cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
319
319
  return cached;
320
320
  }
@@ -10377,6 +10377,90 @@ var init_mesh_event_trace = __esm({
10377
10377
  }
10378
10378
  });
10379
10379
 
10380
+ // src/mesh/mesh-warmup-deadline.ts
10381
+ function awaitWithWarmupDeadline(work, opts) {
10382
+ const pollMs = Math.max(1, Math.min(opts.pollIntervalMs ?? 200, opts.connectTimeoutMs));
10383
+ return new Promise((resolve24, reject) => {
10384
+ let done = false;
10385
+ let poll;
10386
+ let responseTimer;
10387
+ const startedAt = Date.now();
10388
+ const cleanup = () => {
10389
+ if (poll) {
10390
+ clearInterval(poll);
10391
+ poll = void 0;
10392
+ }
10393
+ if (responseTimer) {
10394
+ clearTimeout(responseTimer);
10395
+ responseTimer = void 0;
10396
+ }
10397
+ };
10398
+ const settle = (fn) => {
10399
+ if (done) return;
10400
+ done = true;
10401
+ cleanup();
10402
+ fn();
10403
+ };
10404
+ const armResponse = () => {
10405
+ if (responseTimer || done) return;
10406
+ responseTimer = setTimeout(
10407
+ () => settle(() => reject(new Error("timeout"))),
10408
+ opts.responseTimeoutMs
10409
+ );
10410
+ if (typeof responseTimer.unref === "function") responseTimer.unref();
10411
+ };
10412
+ const onPoll = () => {
10413
+ if (done) return;
10414
+ if (opts.isConnected()) {
10415
+ if (poll) {
10416
+ clearInterval(poll);
10417
+ poll = void 0;
10418
+ }
10419
+ armResponse();
10420
+ return;
10421
+ }
10422
+ if (Date.now() - startedAt >= opts.connectTimeoutMs) {
10423
+ settle(() => reject(new Error("timeout")));
10424
+ }
10425
+ };
10426
+ if (opts.isConnected()) {
10427
+ armResponse();
10428
+ } else {
10429
+ poll = setInterval(onPoll, pollMs);
10430
+ if (typeof poll.unref === "function") poll.unref();
10431
+ }
10432
+ work.then(
10433
+ (val) => settle(() => resolve24(val)),
10434
+ (err) => settle(() => reject(err))
10435
+ );
10436
+ });
10437
+ }
10438
+ function readWarmupConnectionState(connection) {
10439
+ const state = connection?.state;
10440
+ return typeof state === "string" && state.length > 0 ? state : void 0;
10441
+ }
10442
+ function resolveWarmupDeadlineOpts(opts) {
10443
+ const { getConnection, daemonId, connectTimeoutMs, responseTimeoutMs } = opts;
10444
+ if (getConnection) {
10445
+ return {
10446
+ isConnected: () => readWarmupConnectionState(getConnection(daemonId)) === "connected",
10447
+ connectTimeoutMs,
10448
+ responseTimeoutMs
10449
+ };
10450
+ }
10451
+ opts.onMissingGetter?.(daemonId);
10452
+ return {
10453
+ isConnected: () => false,
10454
+ connectTimeoutMs: connectTimeoutMs + responseTimeoutMs,
10455
+ responseTimeoutMs
10456
+ };
10457
+ }
10458
+ var init_mesh_warmup_deadline = __esm({
10459
+ "src/mesh/mesh-warmup-deadline.ts"() {
10460
+ "use strict";
10461
+ }
10462
+ });
10463
+
10380
10464
  // src/config/state-store.ts
10381
10465
  import { existsSync as existsSync16, readFileSync as readFileSync12, writeFileSync as writeFileSync7 } from "fs";
10382
10466
  import { join as join18 } from "path";
@@ -12813,7 +12897,12 @@ function resolveActiveDirectDispatchTaskId(meshId, sessionId) {
12813
12897
  return void 0;
12814
12898
  }
12815
12899
  }
12816
- function deliverTaskToSession(dispatchThunk, ctx) {
12900
+ function warnDispatchWarmupGetterMissingOnce(daemonId) {
12901
+ if (dispatchWarmupGetterMissingWarned.has(daemonId)) return;
12902
+ dispatchWarmupGetterMissingWarned.add(daemonId);
12903
+ LOG.warn("MeshQueue", `Mesh peer connection getter unavailable for ${String(daemonId).slice(0, 12)}; remote task-dispatch warmup deadline degraded to the combined connect+response window. Avoids a cold-open false-timeout but loses warm/cold precision \u2014 wire getMeshPeerConnectionStatus on this daemon.`);
12904
+ }
12905
+ function deliverTaskToSession(dispatchThunk, ctx, warmup) {
12817
12906
  const delivery = createSessionDelivery({
12818
12907
  meshId: ctx.meshId,
12819
12908
  nodeId: ctx.nodeId,
@@ -12833,16 +12922,27 @@ function deliverTaskToSession(dispatchThunk, ctx) {
12833
12922
  dispatchPromise = Promise.reject(e);
12834
12923
  }
12835
12924
  let timer;
12836
- const guarded = Promise.race([
12837
- dispatchPromise,
12838
- new Promise((_, reject) => {
12839
- timer = setTimeout(
12840
- () => reject(new Error(`dispatch_confirm_timeout after ${DISPATCH_CONFIRM_TIMEOUT_MS}ms`)),
12841
- DISPATCH_CONFIRM_TIMEOUT_MS
12842
- );
12843
- if (typeof timer?.unref === "function") timer.unref();
12844
- })
12845
- ]);
12925
+ let guarded;
12926
+ if (warmup) {
12927
+ guarded = awaitWithWarmupDeadline(dispatchPromise, resolveWarmupDeadlineOpts({
12928
+ getConnection: warmup.getConnection,
12929
+ daemonId: warmup.daemonId,
12930
+ connectTimeoutMs: DISPATCH_CONNECT_TIMEOUT_MS,
12931
+ responseTimeoutMs: DISPATCH_CONFIRM_TIMEOUT_MS,
12932
+ onMissingGetter: warnDispatchWarmupGetterMissingOnce
12933
+ }));
12934
+ } else {
12935
+ guarded = Promise.race([
12936
+ dispatchPromise,
12937
+ new Promise((_, reject) => {
12938
+ timer = setTimeout(
12939
+ () => reject(new Error(`dispatch_confirm_timeout after ${DISPATCH_CONFIRM_TIMEOUT_MS}ms`)),
12940
+ DISPATCH_CONFIRM_TIMEOUT_MS
12941
+ );
12942
+ if (typeof timer?.unref === "function") timer.unref();
12943
+ })
12944
+ ]);
12945
+ }
12846
12946
  guarded.then(() => {
12847
12947
  if (timer) clearTimeout(timer);
12848
12948
  updateSessionDeliveryStatus(delivery.id, "delivered");
@@ -12926,7 +13026,11 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
12926
13026
  transport: "remote",
12927
13027
  ...sourceCoordinatorSessionId ? { sourceCoordinatorSessionId } : {},
12928
13028
  ...localDaemonIdForDispatch ? { sourceCoordinatorDaemonId: localDaemonIdForDispatch } : {}
12929
- }
13029
+ },
13030
+ // Warmup-aware deadline: this dispatch can be the FIRST command to a
13031
+ // peer whose mesh DataChannel is still opening — charge the cold-open
13032
+ // handshake to the connect budget, not the response budget.
13033
+ { daemonId: remoteDaemonId, getConnection: components.getMeshPeerConnectionStatus }
12930
13034
  );
12931
13035
  return true;
12932
13036
  }
@@ -14305,7 +14409,7 @@ function setupMeshEventForwarding(components) {
14305
14409
  });
14306
14410
  });
14307
14411
  }
14308
- var REMOTE_IDLE_SESSION_TTL_MS, meshByWorkspaceCache, MESH_WORKSPACE_CACHE_TTL_MS, IDLE_AUTO_FAST_FORWARD_THROTTLE_MS, idleAutoFastForwardLastAttempt, INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS, RECENT_COMPLETION_FINGERPRINT_TTL_MS, DISPATCH_CONFIRM_TIMEOUT_MS, autoLaunchInProgress, autoLaunchCooldownUntil, AUTO_LAUNCH_COOLDOWN_MS, AUTO_LAUNCH_AWAIT_CLAIM_MS, lastAutoLaunchLedgerKey, AUTO_LAUNCH_LEDGER_DEDUP_MAX, MESH_COORDINATOR_EVENTS, EVENT_TO_LEDGER_KIND, MESH_FORCE_INJECT_EVENTS, coordinatorForwardLanes;
14412
+ var REMOTE_IDLE_SESSION_TTL_MS, meshByWorkspaceCache, MESH_WORKSPACE_CACHE_TTL_MS, IDLE_AUTO_FAST_FORWARD_THROTTLE_MS, idleAutoFastForwardLastAttempt, INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS, RECENT_COMPLETION_FINGERPRINT_TTL_MS, DISPATCH_CONFIRM_TIMEOUT_MS, DISPATCH_CONNECT_TIMEOUT_MS, dispatchWarmupGetterMissingWarned, autoLaunchInProgress, autoLaunchCooldownUntil, AUTO_LAUNCH_COOLDOWN_MS, AUTO_LAUNCH_AWAIT_CLAIM_MS, lastAutoLaunchLedgerKey, AUTO_LAUNCH_LEDGER_DEDUP_MAX, MESH_COORDINATOR_EVENTS, EVENT_TO_LEDGER_KIND, MESH_FORCE_INJECT_EVENTS, coordinatorForwardLanes;
14309
14413
  var init_mesh_events_coordinator = __esm({
14310
14414
  "src/mesh/mesh-events-coordinator.ts"() {
14311
14415
  "use strict";
@@ -14322,6 +14426,7 @@ var init_mesh_events_coordinator = __esm({
14322
14426
  init_mesh_routing();
14323
14427
  init_mesh_unresolved_forward_outbox();
14324
14428
  init_mesh_event_trace();
14429
+ init_mesh_warmup_deadline();
14325
14430
  init_snapshot();
14326
14431
  init_repo_mesh_types();
14327
14432
  init_dist();
@@ -14335,6 +14440,8 @@ var init_mesh_events_coordinator = __esm({
14335
14440
  INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS = 30 * 60 * 1e3;
14336
14441
  RECENT_COMPLETION_FINGERPRINT_TTL_MS = 10 * 60 * 1e3;
14337
14442
  DISPATCH_CONFIRM_TIMEOUT_MS = 12e4;
14443
+ DISPATCH_CONNECT_TIMEOUT_MS = 45e3;
14444
+ dispatchWarmupGetterMissingWarned = /* @__PURE__ */ new Set();
14338
14445
  autoLaunchInProgress = /* @__PURE__ */ new Set();
14339
14446
  autoLaunchCooldownUntil = /* @__PURE__ */ new Map();
14340
14447
  AUTO_LAUNCH_COOLDOWN_MS = 5e3;
@@ -41485,6 +41592,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
41485
41592
  let restored = 0;
41486
41593
  const restoredBindings = /* @__PURE__ */ new Set();
41487
41594
  const managerTag = this.deps.hostedRuntimeManagerTag;
41595
+ const restoredRuntimeIds = /* @__PURE__ */ new Set();
41596
+ const workspaceTypeCounts = /* @__PURE__ */ new Map();
41597
+ for (const r of sessions) {
41598
+ if (!r?.runtimeId || !r?.cliType || !r?.workspace) continue;
41599
+ restoredRuntimeIds.add(r.runtimeId);
41600
+ const key = `${r.workspace}::${r.cliType}`;
41601
+ workspaceTypeCounts.set(key, (workspaceTypeCounts.get(key) || 0) + 1);
41602
+ }
41488
41603
  for (const record of sessions) {
41489
41604
  if (!record?.runtimeId || !record?.cliType || !record?.workspace) continue;
41490
41605
  if (!shouldRestoreHostedRuntime(record, managerTag)) {
@@ -41522,11 +41637,21 @@ Run 'adhdev doctor' for detailed diagnostics.`
41522
41637
  if (!coordinatorEntry?.meshId && record.workspace) {
41523
41638
  const workspaceCoordinators = listCoordinatorsForWorkspace(record.workspace).filter((e) => e.meshId && (!e.cliType || e.cliType === record.cliType));
41524
41639
  if (workspaceCoordinators.length === 1) {
41525
- coordinatorEntry = workspaceCoordinators[0];
41526
- LOG.info(
41527
- "CLI",
41528
- `\u21BB Rebound coordinator mark by workspace for ${record.runtimeKey || record.runtimeId} (mesh ${coordinatorEntry.meshId} @ ${record.workspace}); registry key did not match runtimeId`
41529
- );
41640
+ const candidate = workspaceCoordinators[0];
41641
+ const coordinatorPresentById = !!candidate.sessionId && restoredRuntimeIds.has(candidate.sessionId);
41642
+ const siblingCount = workspaceTypeCounts.get(`${record.workspace}::${record.cliType}`) || 1;
41643
+ if (!coordinatorPresentById && siblingCount === 1) {
41644
+ coordinatorEntry = candidate;
41645
+ LOG.info(
41646
+ "CLI",
41647
+ `\u21BB Rebound coordinator mark by workspace for ${record.runtimeKey || record.runtimeId} (mesh ${candidate.meshId} @ ${record.workspace}); registry key did not match runtimeId`
41648
+ );
41649
+ } else {
41650
+ LOG.info(
41651
+ "CLI",
41652
+ `\u21B7 Skipping workspace coordinator rebind for ${record.runtimeKey || record.runtimeId} (${record.cliType} @ ${record.workspace}): ${coordinatorPresentById ? "registered coordinator is restoring under its own id \u2014 this is a delegated worker" : `ambiguous (${siblingCount} sessions share this workspace+cliType)`}`
41653
+ );
41654
+ }
41530
41655
  }
41531
41656
  }
41532
41657
  if (coordinatorEntry?.meshId) {
@@ -48008,6 +48133,7 @@ var meshStatusHandlers = {
48008
48133
  const remoteGit = await meshGitProbeCache.probe(daemonId, workspace, runNodeProbe);
48009
48134
  if (remoteGit) {
48010
48135
  status.git = remoteGit;
48136
+ status[MESH_NODE_LIVE_TRUTH_MARKER] = true;
48011
48137
  status.health = remoteGit.isGitRepo ? deriveMeshNodeHealthFromGit(remoteGit) : "degraded";
48012
48138
  const connection = readObjectRecord(status.connection);
48013
48139
  const connectionState = readStringValue(connection.state);
@@ -48033,13 +48159,13 @@ var meshStatusHandlers = {
48033
48159
  pendingPeerGitProbe ? { skipGit: true, skipError: true, skipHealth: true } : void 0
48034
48160
  )) {
48035
48161
  applyInlineMeshBranchConvergence(mesh, node, status);
48036
- finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode });
48162
+ finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode, directTruthUnavailable: directTruthUnavailableNodeIds.has(nodeId) });
48037
48163
  nodeStatuses.push(status);
48038
48164
  continue;
48039
48165
  }
48040
48166
  if (meshRecord?.source === "inline_cache" && !isSelfNode) {
48041
48167
  applyInlineMeshBranchConvergence(mesh, node, status);
48042
- finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode });
48168
+ finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode, directTruthUnavailable: directTruthUnavailableNodeIds.has(nodeId) });
48043
48169
  nodeStatuses.push(status);
48044
48170
  continue;
48045
48171
  }
@@ -48048,6 +48174,7 @@ var meshStatusHandlers = {
48048
48174
  try {
48049
48175
  const gitStatus = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
48050
48176
  status.git = gitStatus;
48177
+ status[MESH_NODE_LIVE_TRUTH_MARKER] = true;
48051
48178
  const reporter = recordInlineMeshDirectGitTruth(node, gitStatus, "selected_coordinator_local_git");
48052
48179
  persistNodeReporterPlatform(meshRecord.source, mesh, nodeId, reporter);
48053
48180
  if (gitStatus.isGitRepo) {
@@ -48066,7 +48193,7 @@ var meshStatusHandlers = {
48066
48193
  applyCachedInlineMeshNodeStatus(status, node);
48067
48194
  }
48068
48195
  applyInlineMeshBranchConvergence(mesh, node, status);
48069
- finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode });
48196
+ finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode, directTruthUnavailable: directTruthUnavailableNodeIds.has(nodeId) });
48070
48197
  nodeStatuses.push(status);
48071
48198
  }
48072
48199
  const callerCoordinatorDaemonId = typeof args?.coordinatorDaemonId === "string" && args.coordinatorDaemonId.trim() ? args.coordinatorDaemonId.trim() : ctx.deps.statusInstanceId || void 0;
@@ -48480,6 +48607,7 @@ function orderMeshRefineBatchNodes(changeAreas) {
48480
48607
 
48481
48608
  // src/commands/router.ts
48482
48609
  init_mesh_work_queue();
48610
+ init_mesh_warmup_deadline();
48483
48611
  init_repo_mesh_types();
48484
48612
  import { homedir as homedir26 } from "os";
48485
48613
  import { basename as pathBasename, join as pathJoin2, resolve as pathResolve2 } from "path";
@@ -49221,14 +49349,92 @@ function synthesizeMeshNodeFreshnessFromConnection(status) {
49221
49349
  status.updatedAt = gitCheckedAt ?? connectionFreshAt;
49222
49350
  }
49223
49351
  }
49352
+ var MESH_NODE_LIVE_TRUTH_MARKER = "__liveTruthProbed";
49353
+ var MESH_FRESHNESS_FRESH_MS = 3e4;
49354
+ var MESH_FRESHNESS_RECENT_MS = 3e5;
49355
+ function classifyMeshNodeStaleness(dataSource, ageMs) {
49356
+ if (dataSource === "self" || dataSource === "live") return "fresh";
49357
+ if (ageMs === null) return "unknown";
49358
+ if (ageMs < MESH_FRESHNESS_FRESH_MS) return "fresh";
49359
+ if (ageMs < MESH_FRESHNESS_RECENT_MS) return "recent";
49360
+ return "stale";
49361
+ }
49362
+ function buildMeshNodeDataFreshness(args) {
49363
+ const { status, node, isSelfNode, daemonId, liveTruthProbed, directTruthUnavailable } = args;
49364
+ const now = args.now ?? Date.now;
49365
+ const connection = readObjectRecord(status.connection);
49366
+ const connectionState = readStringValue(connection.state);
49367
+ const git = readObjectRecord(status.git);
49368
+ const hasGit = readBooleanValue(git.isGitRepo) === true || !!readStringValue(git.branch, git.headCommit, git.head, git.upstream);
49369
+ const connectionFreshAt = toIsoTimestamp(connection.lastCommandAt ?? connection.lastConnectedAt ?? connection.lastStateChangeAt);
49370
+ const liveGitCheckedAt = liveTruthProbed ? toIsoTimestamp(git.lastCheckedAt) : null;
49371
+ const heldGit = readObjectRecord(node?.lastGit ?? node?.last_git);
49372
+ const heldCheckedAt = toIsoTimestamp(heldGit.checkedAt ?? heldGit.checked_at);
49373
+ const cachedStatus = readObjectRecord(node?.cachedStatus);
49374
+ const cachedGitCheckedAt = toIsoTimestamp(readObjectRecord(cachedStatus.git).lastCheckedAt);
49375
+ const lastProbeAt = liveGitCheckedAt ?? heldCheckedAt ?? cachedGitCheckedAt ?? toIsoTimestamp(git.lastCheckedAt) ?? connectionFreshAt ?? toIsoTimestamp(status.updatedAt) ?? toIsoTimestamp(status.lastSeenAt);
49376
+ const connectionReachable = connectionState === "connected" ? true : !connectionState || connectionState === "unknown" || connectionState === "connecting" ? connectionState === "connecting" ? true : null : false;
49377
+ let dataSource;
49378
+ let reachable;
49379
+ if (isSelfNode) {
49380
+ dataSource = "self";
49381
+ reachable = true;
49382
+ } else if (liveTruthProbed) {
49383
+ dataSource = "live";
49384
+ reachable = true;
49385
+ } else if (readBooleanValue(status.gitProbePending) === true) {
49386
+ dataSource = "pending";
49387
+ reachable = connectionReachable;
49388
+ } else if (directTruthUnavailable) {
49389
+ dataSource = "unreachable";
49390
+ reachable = false;
49391
+ } else if (hasGit) {
49392
+ dataSource = "cached";
49393
+ reachable = connectionReachable;
49394
+ } else if (!daemonId) {
49395
+ dataSource = "unconfigured";
49396
+ reachable = null;
49397
+ } else if (connectionState === "connected") {
49398
+ dataSource = "empty";
49399
+ reachable = true;
49400
+ } else {
49401
+ dataSource = "unreachable";
49402
+ reachable = false;
49403
+ }
49404
+ const probeOk = dataSource === "live" || dataSource === "self";
49405
+ let ageMs = null;
49406
+ if (lastProbeAt) {
49407
+ const parsed = Date.parse(lastProbeAt);
49408
+ if (Number.isFinite(parsed)) ageMs = Math.max(0, now() - parsed);
49409
+ }
49410
+ const staleness = classifyMeshNodeStaleness(dataSource, ageMs);
49411
+ return {
49412
+ dataSource,
49413
+ probeOk,
49414
+ reachable,
49415
+ lastProbeAt: lastProbeAt ?? null,
49416
+ ageMs,
49417
+ staleness
49418
+ };
49419
+ }
49224
49420
  function finalizeMeshNodeStatus(args) {
49225
- const { status, node, daemonId, isSelfNode } = args;
49421
+ const { status, node, daemonId, isSelfNode, directTruthUnavailable } = args;
49226
49422
  if (!readStringValue(status.machineStatus)) {
49227
49423
  const cachedStatus = readObjectRecord(node?.cachedStatus);
49228
49424
  const machineStatus = readStringValue(cachedStatus.machineStatus, cachedStatus.machine_status, node?.machineStatus);
49229
49425
  if (machineStatus) status.machineStatus = machineStatus;
49230
49426
  }
49231
49427
  synthesizeMeshNodeFreshnessFromConnection(status);
49428
+ const liveTruthProbed = readBooleanValue(status[MESH_NODE_LIVE_TRUTH_MARKER]) === true;
49429
+ delete status[MESH_NODE_LIVE_TRUTH_MARKER];
49430
+ status.dataFreshness = buildMeshNodeDataFreshness({
49431
+ status,
49432
+ node,
49433
+ isSelfNode,
49434
+ daemonId,
49435
+ liveTruthProbed,
49436
+ directTruthUnavailable
49437
+ });
49232
49438
  const bootstrap = readObjectRecord(node?.worktreeBootstrap);
49233
49439
  if (node?.isLocalWorktree && readStringValue(bootstrap.status)) {
49234
49440
  status.worktreeBootstrap = bootstrap;
@@ -49296,73 +49502,16 @@ var MeshGitProbeCache = class {
49296
49502
  }
49297
49503
  }
49298
49504
  };
49299
- function awaitWithWarmupDeadline(work, opts) {
49300
- const pollMs = Math.max(1, Math.min(opts.pollIntervalMs ?? 200, opts.connectTimeoutMs));
49301
- return new Promise((resolve24, reject) => {
49302
- let done = false;
49303
- let poll;
49304
- let responseTimer;
49305
- const startedAt = Date.now();
49306
- const cleanup = () => {
49307
- if (poll) {
49308
- clearInterval(poll);
49309
- poll = void 0;
49310
- }
49311
- if (responseTimer) {
49312
- clearTimeout(responseTimer);
49313
- responseTimer = void 0;
49314
- }
49315
- };
49316
- const settle = (fn) => {
49317
- if (done) return;
49318
- done = true;
49319
- cleanup();
49320
- fn();
49321
- };
49322
- const armResponse = () => {
49323
- if (responseTimer || done) return;
49324
- responseTimer = setTimeout(
49325
- () => settle(() => reject(new Error("timeout"))),
49326
- opts.responseTimeoutMs
49327
- );
49328
- if (typeof responseTimer.unref === "function") responseTimer.unref();
49329
- };
49330
- const onPoll = () => {
49331
- if (done) return;
49332
- if (opts.isConnected()) {
49333
- if (poll) {
49334
- clearInterval(poll);
49335
- poll = void 0;
49336
- }
49337
- armResponse();
49338
- return;
49339
- }
49340
- if (Date.now() - startedAt >= opts.connectTimeoutMs) {
49341
- settle(() => reject(new Error("timeout")));
49342
- }
49343
- };
49344
- if (opts.isConnected()) {
49345
- armResponse();
49346
- } else {
49347
- poll = setInterval(onPoll, pollMs);
49348
- if (typeof poll.unref === "function") poll.unref();
49349
- }
49350
- work.then(
49351
- (val) => settle(() => resolve24(val)),
49352
- (err) => settle(() => reject(err))
49353
- );
49354
- });
49355
- }
49356
49505
  async function probeRemoteMeshGitStatus(args) {
49357
49506
  if (!args.dispatchMeshCommand) return null;
49358
49507
  const dispatch = args.dispatchMeshCommand(args.daemonId, "git_status", { workspace: args.workspace, refreshUpstream: true });
49359
- const getConnection = args.getConnection;
49360
- const isConnected = getConnection ? () => readMeshConnectionState(getConnection(args.daemonId)) === "connected" : () => true;
49361
- const remoteResult = await awaitWithWarmupDeadline(dispatch, {
49362
- isConnected,
49508
+ const remoteResult = await awaitWithWarmupDeadline(dispatch, resolveWarmupDeadlineOpts({
49509
+ getConnection: args.getConnection,
49510
+ daemonId: args.daemonId,
49363
49511
  connectTimeoutMs: args.connectTimeoutMs,
49364
- responseTimeoutMs: args.responseTimeoutMs
49365
- });
49512
+ responseTimeoutMs: args.responseTimeoutMs,
49513
+ onMissingGetter: warnMeshWarmupGetterMissingOnce
49514
+ }));
49366
49515
  const remoteGit = remoteResult?.status ?? remoteResult?.git ?? remoteResult;
49367
49516
  if (!remoteGit || typeof remoteGit !== "object" || typeof remoteGit.isGitRepo !== "boolean") return null;
49368
49517
  const reporterPlatform = readStringValue(remoteResult?.reporterPlatform);
@@ -49376,6 +49525,12 @@ var MESH_DIRECT_PROBE_MAX_RETRIES = 2;
49376
49525
  function readMeshConnectionState(connection) {
49377
49526
  return readStringValue(connection?.state);
49378
49527
  }
49528
+ var meshWarmupGetterMissingWarned = /* @__PURE__ */ new Set();
49529
+ function warnMeshWarmupGetterMissingOnce(daemonId) {
49530
+ if (meshWarmupGetterMissingWarned.has(daemonId)) return;
49531
+ meshWarmupGetterMissingWarned.add(daemonId);
49532
+ LOG.warn("Mesh", `Mesh peer connection getter unavailable for ${String(daemonId).slice(0, 12)}; warmup deadline degraded to the combined connect+response window (cannot observe DataChannel open). This avoids a cold-open false-timeout but loses warm/cold precision \u2014 wire getMeshPeerConnectionStatus on this daemon.`);
49533
+ }
49379
49534
  function isMeshConnectionDefinitivelyDown(connection) {
49380
49535
  if (!connection) return true;
49381
49536
  const state = readMeshConnectionState(connection);
@@ -61459,6 +61614,7 @@ async function initDaemonComponents(config) {
61459
61614
  detectedIdes: detectedIdesRef,
61460
61615
  refreshProviderAvailability,
61461
61616
  dispatchMeshCommand: config.dispatchMeshCommand,
61617
+ getMeshPeerConnectionStatus: config.getMeshPeerConnectionStatus,
61462
61618
  onMeshCoordinatorEventForwarded: config.onMeshCoordinatorEventForwarded,
61463
61619
  statusInstanceId: config.statusInstanceId
61464
61620
  };