@adhdev/daemon-standalone 0.9.82-rc.367 → 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.js +297 -95
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -30036,10 +30036,10 @@ var require_dist3 = __commonJS({
|
|
|
30036
30036
|
}
|
|
30037
30037
|
function getDaemonBuildInfo() {
|
|
30038
30038
|
if (cached2) return cached2;
|
|
30039
|
-
const commit = readInjected(true ? "
|
|
30040
|
-
const commitShort = readInjected(true ? "
|
|
30041
|
-
const version2 = readInjected(true ? "0.9.82-rc.
|
|
30042
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
30039
|
+
const commit = readInjected(true ? "4464cd9f1effac841aa1fbef3b1691d2f06d64e4" : void 0) ?? "unknown";
|
|
30040
|
+
const commitShort = readInjected(true ? "4464cd9f" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
30041
|
+
const version2 = readInjected(true ? "0.9.82-rc.369" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
30042
|
+
const builtAt = readInjected(true ? "2026-06-24T08:22:41.172Z" : void 0);
|
|
30043
30043
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
30044
30044
|
return cached2;
|
|
30045
30045
|
}
|
|
@@ -40160,6 +40160,88 @@ Next step: ${nextStep}`;
|
|
|
40160
40160
|
CAT = "EvtTrace";
|
|
40161
40161
|
}
|
|
40162
40162
|
});
|
|
40163
|
+
function awaitWithWarmupDeadline(work, opts) {
|
|
40164
|
+
const pollMs = Math.max(1, Math.min(opts.pollIntervalMs ?? 200, opts.connectTimeoutMs));
|
|
40165
|
+
return new Promise((resolve24, reject) => {
|
|
40166
|
+
let done = false;
|
|
40167
|
+
let poll;
|
|
40168
|
+
let responseTimer;
|
|
40169
|
+
const startedAt = Date.now();
|
|
40170
|
+
const cleanup = () => {
|
|
40171
|
+
if (poll) {
|
|
40172
|
+
clearInterval(poll);
|
|
40173
|
+
poll = void 0;
|
|
40174
|
+
}
|
|
40175
|
+
if (responseTimer) {
|
|
40176
|
+
clearTimeout(responseTimer);
|
|
40177
|
+
responseTimer = void 0;
|
|
40178
|
+
}
|
|
40179
|
+
};
|
|
40180
|
+
const settle = (fn) => {
|
|
40181
|
+
if (done) return;
|
|
40182
|
+
done = true;
|
|
40183
|
+
cleanup();
|
|
40184
|
+
fn();
|
|
40185
|
+
};
|
|
40186
|
+
const armResponse = () => {
|
|
40187
|
+
if (responseTimer || done) return;
|
|
40188
|
+
responseTimer = setTimeout(
|
|
40189
|
+
() => settle(() => reject(new Error("timeout"))),
|
|
40190
|
+
opts.responseTimeoutMs
|
|
40191
|
+
);
|
|
40192
|
+
if (typeof responseTimer.unref === "function") responseTimer.unref();
|
|
40193
|
+
};
|
|
40194
|
+
const onPoll = () => {
|
|
40195
|
+
if (done) return;
|
|
40196
|
+
if (opts.isConnected()) {
|
|
40197
|
+
if (poll) {
|
|
40198
|
+
clearInterval(poll);
|
|
40199
|
+
poll = void 0;
|
|
40200
|
+
}
|
|
40201
|
+
armResponse();
|
|
40202
|
+
return;
|
|
40203
|
+
}
|
|
40204
|
+
if (Date.now() - startedAt >= opts.connectTimeoutMs) {
|
|
40205
|
+
settle(() => reject(new Error("timeout")));
|
|
40206
|
+
}
|
|
40207
|
+
};
|
|
40208
|
+
if (opts.isConnected()) {
|
|
40209
|
+
armResponse();
|
|
40210
|
+
} else {
|
|
40211
|
+
poll = setInterval(onPoll, pollMs);
|
|
40212
|
+
if (typeof poll.unref === "function") poll.unref();
|
|
40213
|
+
}
|
|
40214
|
+
work.then(
|
|
40215
|
+
(val) => settle(() => resolve24(val)),
|
|
40216
|
+
(err) => settle(() => reject(err))
|
|
40217
|
+
);
|
|
40218
|
+
});
|
|
40219
|
+
}
|
|
40220
|
+
function readWarmupConnectionState(connection) {
|
|
40221
|
+
const state = connection?.state;
|
|
40222
|
+
return typeof state === "string" && state.length > 0 ? state : void 0;
|
|
40223
|
+
}
|
|
40224
|
+
function resolveWarmupDeadlineOpts(opts) {
|
|
40225
|
+
const { getConnection, daemonId, connectTimeoutMs, responseTimeoutMs } = opts;
|
|
40226
|
+
if (getConnection) {
|
|
40227
|
+
return {
|
|
40228
|
+
isConnected: () => readWarmupConnectionState(getConnection(daemonId)) === "connected",
|
|
40229
|
+
connectTimeoutMs,
|
|
40230
|
+
responseTimeoutMs
|
|
40231
|
+
};
|
|
40232
|
+
}
|
|
40233
|
+
opts.onMissingGetter?.(daemonId);
|
|
40234
|
+
return {
|
|
40235
|
+
isConnected: () => false,
|
|
40236
|
+
connectTimeoutMs: connectTimeoutMs + responseTimeoutMs,
|
|
40237
|
+
responseTimeoutMs
|
|
40238
|
+
};
|
|
40239
|
+
}
|
|
40240
|
+
var init_mesh_warmup_deadline = __esm2({
|
|
40241
|
+
"src/mesh/mesh-warmup-deadline.ts"() {
|
|
40242
|
+
"use strict";
|
|
40243
|
+
}
|
|
40244
|
+
});
|
|
40163
40245
|
function isPlainObject22(value) {
|
|
40164
40246
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
40165
40247
|
}
|
|
@@ -42603,7 +42685,12 @@ ${cleanBody}`;
|
|
|
42603
42685
|
return void 0;
|
|
42604
42686
|
}
|
|
42605
42687
|
}
|
|
42606
|
-
function
|
|
42688
|
+
function warnDispatchWarmupGetterMissingOnce(daemonId) {
|
|
42689
|
+
if (dispatchWarmupGetterMissingWarned.has(daemonId)) return;
|
|
42690
|
+
dispatchWarmupGetterMissingWarned.add(daemonId);
|
|
42691
|
+
LOG2.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.`);
|
|
42692
|
+
}
|
|
42693
|
+
function deliverTaskToSession(dispatchThunk, ctx, warmup) {
|
|
42607
42694
|
const delivery = createSessionDelivery({
|
|
42608
42695
|
meshId: ctx.meshId,
|
|
42609
42696
|
nodeId: ctx.nodeId,
|
|
@@ -42623,16 +42710,27 @@ ${cleanBody}`;
|
|
|
42623
42710
|
dispatchPromise = Promise.reject(e);
|
|
42624
42711
|
}
|
|
42625
42712
|
let timer;
|
|
42626
|
-
|
|
42627
|
-
|
|
42628
|
-
|
|
42629
|
-
|
|
42630
|
-
|
|
42631
|
-
|
|
42632
|
-
|
|
42633
|
-
|
|
42634
|
-
})
|
|
42635
|
-
|
|
42713
|
+
let guarded;
|
|
42714
|
+
if (warmup) {
|
|
42715
|
+
guarded = awaitWithWarmupDeadline(dispatchPromise, resolveWarmupDeadlineOpts({
|
|
42716
|
+
getConnection: warmup.getConnection,
|
|
42717
|
+
daemonId: warmup.daemonId,
|
|
42718
|
+
connectTimeoutMs: DISPATCH_CONNECT_TIMEOUT_MS,
|
|
42719
|
+
responseTimeoutMs: DISPATCH_CONFIRM_TIMEOUT_MS,
|
|
42720
|
+
onMissingGetter: warnDispatchWarmupGetterMissingOnce
|
|
42721
|
+
}));
|
|
42722
|
+
} else {
|
|
42723
|
+
guarded = Promise.race([
|
|
42724
|
+
dispatchPromise,
|
|
42725
|
+
new Promise((_, reject) => {
|
|
42726
|
+
timer = setTimeout(
|
|
42727
|
+
() => reject(new Error(`dispatch_confirm_timeout after ${DISPATCH_CONFIRM_TIMEOUT_MS}ms`)),
|
|
42728
|
+
DISPATCH_CONFIRM_TIMEOUT_MS
|
|
42729
|
+
);
|
|
42730
|
+
if (typeof timer?.unref === "function") timer.unref();
|
|
42731
|
+
})
|
|
42732
|
+
]);
|
|
42733
|
+
}
|
|
42636
42734
|
guarded.then(() => {
|
|
42637
42735
|
if (timer) clearTimeout(timer);
|
|
42638
42736
|
updateSessionDeliveryStatus(delivery.id, "delivered");
|
|
@@ -42656,13 +42754,25 @@ ${cleanBody}`;
|
|
|
42656
42754
|
const mesh = getMeshWithCache(components, meshId);
|
|
42657
42755
|
const node = mesh?.nodes.find((n) => readMeshNodeId(n) === nodeId);
|
|
42658
42756
|
const localClaimAdapter = components.cliManager?.adapters?.get(sessionId);
|
|
42659
|
-
|
|
42660
|
-
|
|
42661
|
-
|
|
42662
|
-
|
|
42663
|
-
|
|
42757
|
+
let claimInstanceWorkspace = "";
|
|
42758
|
+
let claimStampedNodeId = "";
|
|
42759
|
+
try {
|
|
42760
|
+
const claimState = components.instanceManager?.getInstance?.(sessionId)?.getState?.();
|
|
42761
|
+
claimInstanceWorkspace = readNonEmptyString2(claimState?.workspace);
|
|
42762
|
+
const claimSettings = claimState?.settings || {};
|
|
42763
|
+
claimStampedNodeId = readNonEmptyString2(claimSettings.meshNodeId);
|
|
42764
|
+
} catch {
|
|
42765
|
+
}
|
|
42766
|
+
const nodeWorkspaceRaw = readNonEmptyString2(node?.workspace);
|
|
42767
|
+
const sessionWorkspaceRaw = readNonEmptyString2(localClaimAdapter?.workingDir) || claimInstanceWorkspace;
|
|
42768
|
+
if (claimStampedNodeId && nodeId) {
|
|
42769
|
+
if (!meshNodeIdMatches({ id: claimStampedNodeId }, nodeId)) {
|
|
42770
|
+
LOG2.info("MeshQueue", `WTDISPATCH: refusing claim for node ${nodeId} (${sessionId}) \u2014 session is bound to node "${claimStampedNodeId}" (cross-node claim blocked)`);
|
|
42664
42771
|
return false;
|
|
42665
42772
|
}
|
|
42773
|
+
} else if (sessionWorkspaceRaw && nodeWorkspaceRaw && !meshWorkspacesEquivalent(sessionWorkspaceRaw, nodeWorkspaceRaw)) {
|
|
42774
|
+
LOG2.info("MeshQueue", `WTCLAIM: refusing claim for node ${nodeId} (${sessionId}) \u2014 session workspace "${normalizeMeshWorkspaceForCompare(sessionWorkspaceRaw)}" \u2260 node workspace "${normalizeMeshWorkspaceForCompare(nodeWorkspaceRaw)}" (cross-workspace dispatch blocked)`);
|
|
42775
|
+
return false;
|
|
42666
42776
|
}
|
|
42667
42777
|
const capabilityTags = buildMeshNodeCapabilityTags(node, providerType);
|
|
42668
42778
|
const providerMaxParallel = resolveProviderMaxParallel(node?.policy, providerType);
|
|
@@ -42704,7 +42814,11 @@ ${cleanBody}`;
|
|
|
42704
42814
|
transport: "remote",
|
|
42705
42815
|
...sourceCoordinatorSessionId ? { sourceCoordinatorSessionId } : {},
|
|
42706
42816
|
...localDaemonIdForDispatch ? { sourceCoordinatorDaemonId: localDaemonIdForDispatch } : {}
|
|
42707
|
-
}
|
|
42817
|
+
},
|
|
42818
|
+
// Warmup-aware deadline: this dispatch can be the FIRST command to a
|
|
42819
|
+
// peer whose mesh DataChannel is still opening — charge the cold-open
|
|
42820
|
+
// handshake to the connect budget, not the response budget.
|
|
42821
|
+
{ daemonId: remoteDaemonId, getConnection: components.getMeshPeerConnectionStatus }
|
|
42708
42822
|
);
|
|
42709
42823
|
return true;
|
|
42710
42824
|
}
|
|
@@ -43940,6 +44054,25 @@ ${cleanBody}`;
|
|
|
43940
44054
|
metadataEvent: buildRelayMetadataEvent(payload)
|
|
43941
44055
|
});
|
|
43942
44056
|
}
|
|
44057
|
+
function enqueueCoordinatorForwardPush(coordinatorDaemonId, run) {
|
|
44058
|
+
let lane = coordinatorForwardLanes.get(coordinatorDaemonId);
|
|
44059
|
+
if (!lane) {
|
|
44060
|
+
lane = { tail: Promise.resolve(), depth: 0 };
|
|
44061
|
+
coordinatorForwardLanes.set(coordinatorDaemonId, lane);
|
|
44062
|
+
}
|
|
44063
|
+
const wasIdle = lane.depth === 0;
|
|
44064
|
+
lane.depth += 1;
|
|
44065
|
+
const dec = () => {
|
|
44066
|
+
lane.depth -= 1;
|
|
44067
|
+
};
|
|
44068
|
+
if (wasIdle) {
|
|
44069
|
+
lane.tail = Promise.resolve(run()).catch(() => {
|
|
44070
|
+
}).then(dec, dec);
|
|
44071
|
+
} else {
|
|
44072
|
+
lane.tail = lane.tail.then(() => run()).catch(() => {
|
|
44073
|
+
}).then(dec, dec);
|
|
44074
|
+
}
|
|
44075
|
+
}
|
|
43943
44076
|
function forwardUnresolvedDelegateEvent(components, routing, event) {
|
|
43944
44077
|
const coordinatorDaemonId = readNonEmptyString2(routing.coordinatorDaemonId);
|
|
43945
44078
|
if (!coordinatorDaemonId) return false;
|
|
@@ -43971,7 +44104,8 @@ ${cleanBody}`;
|
|
|
43971
44104
|
};
|
|
43972
44105
|
traceMeshEventStage("outbox_enqueue", fwdTraceCtx, `coordinatorDaemon=${coordinatorDaemonId} meshId=absent`);
|
|
43973
44106
|
traceMeshEventStage("forward_send", fwdTraceCtx, "immediate push");
|
|
43974
|
-
|
|
44107
|
+
const dispatchMeshCommand = components.dispatchMeshCommand;
|
|
44108
|
+
enqueueCoordinatorForwardPush(coordinatorDaemonId, () => Promise.resolve(dispatchMeshCommand(coordinatorDaemonId, "mesh_forward_event", payload)).then((result) => {
|
|
43975
44109
|
if (result && result.success === false) {
|
|
43976
44110
|
LOG2.warn("MeshEvents", `Immediate forward of ${eventName} to coordinator ${coordinatorDaemonId} rejected (${readNonEmptyString2(result.error) || "no reason"}) \u2014 left queued for retry`);
|
|
43977
44111
|
traceMeshEventDrop("immediate_forward_rejected", fwdTraceCtx, readNonEmptyString2(result.error) || "no reason");
|
|
@@ -43980,7 +44114,7 @@ ${cleanBody}`;
|
|
|
43980
44114
|
if (persisted) ackUnresolvedDelegateForwardByFingerprint(coordinatorDaemonId, eventName, payload);
|
|
43981
44115
|
}).catch((e) => {
|
|
43982
44116
|
LOG2.warn("MeshEvents", `Immediate forward of ${eventName} to coordinator ${coordinatorDaemonId} failed: ${e?.message || e} \u2014 left queued for retry`);
|
|
43983
|
-
});
|
|
44117
|
+
}));
|
|
43984
44118
|
LOG2.info("MeshEvents", `Durably forwarded ${eventName} for unresolved-mesh worker at ${routing.workspace || "(no workspace)"} to coordinator daemon ${coordinatorDaemonId}`);
|
|
43985
44119
|
return true;
|
|
43986
44120
|
}
|
|
@@ -44072,6 +44206,8 @@ ${cleanBody}`;
|
|
|
44072
44206
|
var INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS;
|
|
44073
44207
|
var RECENT_COMPLETION_FINGERPRINT_TTL_MS;
|
|
44074
44208
|
var DISPATCH_CONFIRM_TIMEOUT_MS;
|
|
44209
|
+
var DISPATCH_CONNECT_TIMEOUT_MS;
|
|
44210
|
+
var dispatchWarmupGetterMissingWarned;
|
|
44075
44211
|
var autoLaunchInProgress;
|
|
44076
44212
|
var autoLaunchCooldownUntil;
|
|
44077
44213
|
var AUTO_LAUNCH_COOLDOWN_MS;
|
|
@@ -44081,6 +44217,7 @@ ${cleanBody}`;
|
|
|
44081
44217
|
var MESH_COORDINATOR_EVENTS;
|
|
44082
44218
|
var EVENT_TO_LEDGER_KIND;
|
|
44083
44219
|
var MESH_FORCE_INJECT_EVENTS;
|
|
44220
|
+
var coordinatorForwardLanes;
|
|
44084
44221
|
var init_mesh_events_coordinator = __esm2({
|
|
44085
44222
|
"src/mesh/mesh-events-coordinator.ts"() {
|
|
44086
44223
|
"use strict";
|
|
@@ -44098,6 +44235,7 @@ ${cleanBody}`;
|
|
|
44098
44235
|
init_mesh_routing();
|
|
44099
44236
|
init_mesh_unresolved_forward_outbox();
|
|
44100
44237
|
init_mesh_event_trace();
|
|
44238
|
+
init_mesh_warmup_deadline();
|
|
44101
44239
|
init_snapshot();
|
|
44102
44240
|
init_repo_mesh_types();
|
|
44103
44241
|
init_dist();
|
|
@@ -44111,6 +44249,8 @@ ${cleanBody}`;
|
|
|
44111
44249
|
INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS = 30 * 60 * 1e3;
|
|
44112
44250
|
RECENT_COMPLETION_FINGERPRINT_TTL_MS = 10 * 60 * 1e3;
|
|
44113
44251
|
DISPATCH_CONFIRM_TIMEOUT_MS = 12e4;
|
|
44252
|
+
DISPATCH_CONNECT_TIMEOUT_MS = 45e3;
|
|
44253
|
+
dispatchWarmupGetterMissingWarned = /* @__PURE__ */ new Set();
|
|
44114
44254
|
autoLaunchInProgress = /* @__PURE__ */ new Set();
|
|
44115
44255
|
autoLaunchCooldownUntil = /* @__PURE__ */ new Map();
|
|
44116
44256
|
AUTO_LAUNCH_COOLDOWN_MS = 5e3;
|
|
@@ -44145,6 +44285,7 @@ ${cleanBody}`;
|
|
|
44145
44285
|
"worktree_bootstrap_complete",
|
|
44146
44286
|
"worktree_bootstrap_failed"
|
|
44147
44287
|
]);
|
|
44288
|
+
coordinatorForwardLanes = /* @__PURE__ */ new Map();
|
|
44148
44289
|
}
|
|
44149
44290
|
});
|
|
44150
44291
|
function resolveAutoPruneMinAgeMs() {
|
|
@@ -71144,6 +71285,18 @@ ${rawInput}` : rawInput;
|
|
|
71144
71285
|
throw new Error(`Failed to start ${provider.displayName || provider.name || cliType}: ${spawnErr?.message}`);
|
|
71145
71286
|
}
|
|
71146
71287
|
this.adapters.set(key, cliInstance.getAdapter());
|
|
71288
|
+
const launchMeshNodeId = typeof settings?.meshNodeId === "string" ? settings.meshNodeId.trim() : "";
|
|
71289
|
+
const launchMeshNodeFor = typeof settings?.meshNodeFor === "string" ? settings.meshNodeFor.trim() : "";
|
|
71290
|
+
if (launchMeshNodeId || launchMeshNodeFor) {
|
|
71291
|
+
try {
|
|
71292
|
+
cliInstance.getAdapter().updateRuntimeMeta?.({
|
|
71293
|
+
...launchMeshNodeId ? { meshNodeId: launchMeshNodeId } : {},
|
|
71294
|
+
...launchMeshNodeFor ? { meshNodeFor: launchMeshNodeFor } : {},
|
|
71295
|
+
...settings?.launchedByCoordinator === true ? { launchedByCoordinator: true } : {}
|
|
71296
|
+
});
|
|
71297
|
+
} catch {
|
|
71298
|
+
}
|
|
71299
|
+
}
|
|
71147
71300
|
this.startCliExitMonitor(key, cliType);
|
|
71148
71301
|
}
|
|
71149
71302
|
// ─── Session start/management ──────────────────────────────
|
|
@@ -71411,6 +71564,14 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
71411
71564
|
let restored = 0;
|
|
71412
71565
|
const restoredBindings = /* @__PURE__ */ new Set();
|
|
71413
71566
|
const managerTag = this.deps.hostedRuntimeManagerTag;
|
|
71567
|
+
const restoredRuntimeIds = /* @__PURE__ */ new Set();
|
|
71568
|
+
const workspaceTypeCounts = /* @__PURE__ */ new Map();
|
|
71569
|
+
for (const r of sessions) {
|
|
71570
|
+
if (!r?.runtimeId || !r?.cliType || !r?.workspace) continue;
|
|
71571
|
+
restoredRuntimeIds.add(r.runtimeId);
|
|
71572
|
+
const key = `${r.workspace}::${r.cliType}`;
|
|
71573
|
+
workspaceTypeCounts.set(key, (workspaceTypeCounts.get(key) || 0) + 1);
|
|
71574
|
+
}
|
|
71414
71575
|
for (const record2 of sessions) {
|
|
71415
71576
|
if (!record2?.runtimeId || !record2?.cliType || !record2?.workspace) continue;
|
|
71416
71577
|
if (!shouldRestoreHostedRuntime(record2, managerTag)) {
|
|
@@ -71448,11 +71609,21 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
71448
71609
|
if (!coordinatorEntry?.meshId && record2.workspace) {
|
|
71449
71610
|
const workspaceCoordinators = listCoordinatorsForWorkspace(record2.workspace).filter((e) => e.meshId && (!e.cliType || e.cliType === record2.cliType));
|
|
71450
71611
|
if (workspaceCoordinators.length === 1) {
|
|
71451
|
-
|
|
71452
|
-
|
|
71453
|
-
|
|
71454
|
-
|
|
71455
|
-
|
|
71612
|
+
const candidate = workspaceCoordinators[0];
|
|
71613
|
+
const coordinatorPresentById = !!candidate.sessionId && restoredRuntimeIds.has(candidate.sessionId);
|
|
71614
|
+
const siblingCount = workspaceTypeCounts.get(`${record2.workspace}::${record2.cliType}`) || 1;
|
|
71615
|
+
if (!coordinatorPresentById && siblingCount === 1) {
|
|
71616
|
+
coordinatorEntry = candidate;
|
|
71617
|
+
LOG2.info(
|
|
71618
|
+
"CLI",
|
|
71619
|
+
`\u21BB Rebound coordinator mark by workspace for ${record2.runtimeKey || record2.runtimeId} (mesh ${candidate.meshId} @ ${record2.workspace}); registry key did not match runtimeId`
|
|
71620
|
+
);
|
|
71621
|
+
} else {
|
|
71622
|
+
LOG2.info(
|
|
71623
|
+
"CLI",
|
|
71624
|
+
`\u21B7 Skipping workspace coordinator rebind for ${record2.runtimeKey || record2.runtimeId} (${record2.cliType} @ ${record2.workspace}): ${coordinatorPresentById ? "registered coordinator is restoring under its own id \u2014 this is a delegated worker" : `ambiguous (${siblingCount} sessions share this workspace+cliType)`}`
|
|
71625
|
+
);
|
|
71626
|
+
}
|
|
71456
71627
|
}
|
|
71457
71628
|
}
|
|
71458
71629
|
if (coordinatorEntry?.meshId) {
|
|
@@ -77880,6 +78051,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
77880
78051
|
const remoteGit = await meshGitProbeCache.probe(daemonId, workspace, runNodeProbe);
|
|
77881
78052
|
if (remoteGit) {
|
|
77882
78053
|
status.git = remoteGit;
|
|
78054
|
+
status[MESH_NODE_LIVE_TRUTH_MARKER] = true;
|
|
77883
78055
|
status.health = remoteGit.isGitRepo ? deriveMeshNodeHealthFromGit(remoteGit) : "degraded";
|
|
77884
78056
|
const connection = readObjectRecord(status.connection);
|
|
77885
78057
|
const connectionState = readStringValue(connection.state);
|
|
@@ -77905,13 +78077,13 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
77905
78077
|
pendingPeerGitProbe ? { skipGit: true, skipError: true, skipHealth: true } : void 0
|
|
77906
78078
|
)) {
|
|
77907
78079
|
applyInlineMeshBranchConvergence(mesh, node, status);
|
|
77908
|
-
finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode });
|
|
78080
|
+
finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode, directTruthUnavailable: directTruthUnavailableNodeIds.has(nodeId) });
|
|
77909
78081
|
nodeStatuses.push(status);
|
|
77910
78082
|
continue;
|
|
77911
78083
|
}
|
|
77912
78084
|
if (meshRecord?.source === "inline_cache" && !isSelfNode) {
|
|
77913
78085
|
applyInlineMeshBranchConvergence(mesh, node, status);
|
|
77914
|
-
finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode });
|
|
78086
|
+
finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode, directTruthUnavailable: directTruthUnavailableNodeIds.has(nodeId) });
|
|
77915
78087
|
nodeStatuses.push(status);
|
|
77916
78088
|
continue;
|
|
77917
78089
|
}
|
|
@@ -77920,6 +78092,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
77920
78092
|
try {
|
|
77921
78093
|
const gitStatus = await getGitRepoStatus(workspace, { timeoutMs: 1e4, refreshUpstream: true });
|
|
77922
78094
|
status.git = gitStatus;
|
|
78095
|
+
status[MESH_NODE_LIVE_TRUTH_MARKER] = true;
|
|
77923
78096
|
const reporter = recordInlineMeshDirectGitTruth(node, gitStatus, "selected_coordinator_local_git");
|
|
77924
78097
|
persistNodeReporterPlatform(meshRecord.source, mesh, nodeId, reporter);
|
|
77925
78098
|
if (gitStatus.isGitRepo) {
|
|
@@ -77938,7 +78111,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
77938
78111
|
applyCachedInlineMeshNodeStatus(status, node);
|
|
77939
78112
|
}
|
|
77940
78113
|
applyInlineMeshBranchConvergence(mesh, node, status);
|
|
77941
|
-
finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode });
|
|
78114
|
+
finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode, directTruthUnavailable: directTruthUnavailableNodeIds.has(nodeId) });
|
|
77942
78115
|
nodeStatuses.push(status);
|
|
77943
78116
|
}
|
|
77944
78117
|
const callerCoordinatorDaemonId = typeof args?.coordinatorDaemonId === "string" && args.coordinatorDaemonId.trim() ? args.coordinatorDaemonId.trim() : ctx.deps.statusInstanceId || void 0;
|
|
@@ -78340,6 +78513,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
78340
78513
|
return { order: ranked.map((a) => a.nodeId), changeAreas: areaById, rationale };
|
|
78341
78514
|
}
|
|
78342
78515
|
init_mesh_work_queue();
|
|
78516
|
+
init_mesh_warmup_deadline();
|
|
78343
78517
|
init_repo_mesh_types();
|
|
78344
78518
|
var import_os4 = require("os");
|
|
78345
78519
|
var import_path13 = require("path");
|
|
@@ -79081,14 +79255,92 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79081
79255
|
status.updatedAt = gitCheckedAt ?? connectionFreshAt;
|
|
79082
79256
|
}
|
|
79083
79257
|
}
|
|
79258
|
+
var MESH_NODE_LIVE_TRUTH_MARKER = "__liveTruthProbed";
|
|
79259
|
+
var MESH_FRESHNESS_FRESH_MS = 3e4;
|
|
79260
|
+
var MESH_FRESHNESS_RECENT_MS = 3e5;
|
|
79261
|
+
function classifyMeshNodeStaleness(dataSource, ageMs) {
|
|
79262
|
+
if (dataSource === "self" || dataSource === "live") return "fresh";
|
|
79263
|
+
if (ageMs === null) return "unknown";
|
|
79264
|
+
if (ageMs < MESH_FRESHNESS_FRESH_MS) return "fresh";
|
|
79265
|
+
if (ageMs < MESH_FRESHNESS_RECENT_MS) return "recent";
|
|
79266
|
+
return "stale";
|
|
79267
|
+
}
|
|
79268
|
+
function buildMeshNodeDataFreshness(args) {
|
|
79269
|
+
const { status, node, isSelfNode, daemonId, liveTruthProbed, directTruthUnavailable } = args;
|
|
79270
|
+
const now = args.now ?? Date.now;
|
|
79271
|
+
const connection = readObjectRecord(status.connection);
|
|
79272
|
+
const connectionState = readStringValue(connection.state);
|
|
79273
|
+
const git = readObjectRecord(status.git);
|
|
79274
|
+
const hasGit = readBooleanValue(git.isGitRepo) === true || !!readStringValue(git.branch, git.headCommit, git.head, git.upstream);
|
|
79275
|
+
const connectionFreshAt = toIsoTimestamp(connection.lastCommandAt ?? connection.lastConnectedAt ?? connection.lastStateChangeAt);
|
|
79276
|
+
const liveGitCheckedAt = liveTruthProbed ? toIsoTimestamp(git.lastCheckedAt) : null;
|
|
79277
|
+
const heldGit = readObjectRecord(node?.lastGit ?? node?.last_git);
|
|
79278
|
+
const heldCheckedAt = toIsoTimestamp(heldGit.checkedAt ?? heldGit.checked_at);
|
|
79279
|
+
const cachedStatus = readObjectRecord(node?.cachedStatus);
|
|
79280
|
+
const cachedGitCheckedAt = toIsoTimestamp(readObjectRecord(cachedStatus.git).lastCheckedAt);
|
|
79281
|
+
const lastProbeAt = liveGitCheckedAt ?? heldCheckedAt ?? cachedGitCheckedAt ?? toIsoTimestamp(git.lastCheckedAt) ?? connectionFreshAt ?? toIsoTimestamp(status.updatedAt) ?? toIsoTimestamp(status.lastSeenAt);
|
|
79282
|
+
const connectionReachable = connectionState === "connected" ? true : !connectionState || connectionState === "unknown" || connectionState === "connecting" ? connectionState === "connecting" ? true : null : false;
|
|
79283
|
+
let dataSource;
|
|
79284
|
+
let reachable;
|
|
79285
|
+
if (isSelfNode) {
|
|
79286
|
+
dataSource = "self";
|
|
79287
|
+
reachable = true;
|
|
79288
|
+
} else if (liveTruthProbed) {
|
|
79289
|
+
dataSource = "live";
|
|
79290
|
+
reachable = true;
|
|
79291
|
+
} else if (readBooleanValue(status.gitProbePending) === true) {
|
|
79292
|
+
dataSource = "pending";
|
|
79293
|
+
reachable = connectionReachable;
|
|
79294
|
+
} else if (directTruthUnavailable) {
|
|
79295
|
+
dataSource = "unreachable";
|
|
79296
|
+
reachable = false;
|
|
79297
|
+
} else if (hasGit) {
|
|
79298
|
+
dataSource = "cached";
|
|
79299
|
+
reachable = connectionReachable;
|
|
79300
|
+
} else if (!daemonId) {
|
|
79301
|
+
dataSource = "unconfigured";
|
|
79302
|
+
reachable = null;
|
|
79303
|
+
} else if (connectionState === "connected") {
|
|
79304
|
+
dataSource = "empty";
|
|
79305
|
+
reachable = true;
|
|
79306
|
+
} else {
|
|
79307
|
+
dataSource = "unreachable";
|
|
79308
|
+
reachable = false;
|
|
79309
|
+
}
|
|
79310
|
+
const probeOk = dataSource === "live" || dataSource === "self";
|
|
79311
|
+
let ageMs = null;
|
|
79312
|
+
if (lastProbeAt) {
|
|
79313
|
+
const parsed = Date.parse(lastProbeAt);
|
|
79314
|
+
if (Number.isFinite(parsed)) ageMs = Math.max(0, now() - parsed);
|
|
79315
|
+
}
|
|
79316
|
+
const staleness = classifyMeshNodeStaleness(dataSource, ageMs);
|
|
79317
|
+
return {
|
|
79318
|
+
dataSource,
|
|
79319
|
+
probeOk,
|
|
79320
|
+
reachable,
|
|
79321
|
+
lastProbeAt: lastProbeAt ?? null,
|
|
79322
|
+
ageMs,
|
|
79323
|
+
staleness
|
|
79324
|
+
};
|
|
79325
|
+
}
|
|
79084
79326
|
function finalizeMeshNodeStatus(args) {
|
|
79085
|
-
const { status, node, daemonId, isSelfNode } = args;
|
|
79327
|
+
const { status, node, daemonId, isSelfNode, directTruthUnavailable } = args;
|
|
79086
79328
|
if (!readStringValue(status.machineStatus)) {
|
|
79087
79329
|
const cachedStatus = readObjectRecord(node?.cachedStatus);
|
|
79088
79330
|
const machineStatus = readStringValue(cachedStatus.machineStatus, cachedStatus.machine_status, node?.machineStatus);
|
|
79089
79331
|
if (machineStatus) status.machineStatus = machineStatus;
|
|
79090
79332
|
}
|
|
79091
79333
|
synthesizeMeshNodeFreshnessFromConnection(status);
|
|
79334
|
+
const liveTruthProbed = readBooleanValue(status[MESH_NODE_LIVE_TRUTH_MARKER]) === true;
|
|
79335
|
+
delete status[MESH_NODE_LIVE_TRUTH_MARKER];
|
|
79336
|
+
status.dataFreshness = buildMeshNodeDataFreshness({
|
|
79337
|
+
status,
|
|
79338
|
+
node,
|
|
79339
|
+
isSelfNode,
|
|
79340
|
+
daemonId,
|
|
79341
|
+
liveTruthProbed,
|
|
79342
|
+
directTruthUnavailable
|
|
79343
|
+
});
|
|
79092
79344
|
const bootstrap = readObjectRecord(node?.worktreeBootstrap);
|
|
79093
79345
|
if (node?.isLocalWorktree && readStringValue(bootstrap.status)) {
|
|
79094
79346
|
status.worktreeBootstrap = bootstrap;
|
|
@@ -79156,73 +79408,16 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79156
79408
|
}
|
|
79157
79409
|
}
|
|
79158
79410
|
};
|
|
79159
|
-
function awaitWithWarmupDeadline(work, opts) {
|
|
79160
|
-
const pollMs = Math.max(1, Math.min(opts.pollIntervalMs ?? 200, opts.connectTimeoutMs));
|
|
79161
|
-
return new Promise((resolve24, reject) => {
|
|
79162
|
-
let done = false;
|
|
79163
|
-
let poll;
|
|
79164
|
-
let responseTimer;
|
|
79165
|
-
const startedAt = Date.now();
|
|
79166
|
-
const cleanup = () => {
|
|
79167
|
-
if (poll) {
|
|
79168
|
-
clearInterval(poll);
|
|
79169
|
-
poll = void 0;
|
|
79170
|
-
}
|
|
79171
|
-
if (responseTimer) {
|
|
79172
|
-
clearTimeout(responseTimer);
|
|
79173
|
-
responseTimer = void 0;
|
|
79174
|
-
}
|
|
79175
|
-
};
|
|
79176
|
-
const settle = (fn) => {
|
|
79177
|
-
if (done) return;
|
|
79178
|
-
done = true;
|
|
79179
|
-
cleanup();
|
|
79180
|
-
fn();
|
|
79181
|
-
};
|
|
79182
|
-
const armResponse = () => {
|
|
79183
|
-
if (responseTimer || done) return;
|
|
79184
|
-
responseTimer = setTimeout(
|
|
79185
|
-
() => settle(() => reject(new Error("timeout"))),
|
|
79186
|
-
opts.responseTimeoutMs
|
|
79187
|
-
);
|
|
79188
|
-
if (typeof responseTimer.unref === "function") responseTimer.unref();
|
|
79189
|
-
};
|
|
79190
|
-
const onPoll = () => {
|
|
79191
|
-
if (done) return;
|
|
79192
|
-
if (opts.isConnected()) {
|
|
79193
|
-
if (poll) {
|
|
79194
|
-
clearInterval(poll);
|
|
79195
|
-
poll = void 0;
|
|
79196
|
-
}
|
|
79197
|
-
armResponse();
|
|
79198
|
-
return;
|
|
79199
|
-
}
|
|
79200
|
-
if (Date.now() - startedAt >= opts.connectTimeoutMs) {
|
|
79201
|
-
settle(() => reject(new Error("timeout")));
|
|
79202
|
-
}
|
|
79203
|
-
};
|
|
79204
|
-
if (opts.isConnected()) {
|
|
79205
|
-
armResponse();
|
|
79206
|
-
} else {
|
|
79207
|
-
poll = setInterval(onPoll, pollMs);
|
|
79208
|
-
if (typeof poll.unref === "function") poll.unref();
|
|
79209
|
-
}
|
|
79210
|
-
work.then(
|
|
79211
|
-
(val) => settle(() => resolve24(val)),
|
|
79212
|
-
(err) => settle(() => reject(err))
|
|
79213
|
-
);
|
|
79214
|
-
});
|
|
79215
|
-
}
|
|
79216
79411
|
async function probeRemoteMeshGitStatus(args) {
|
|
79217
79412
|
if (!args.dispatchMeshCommand) return null;
|
|
79218
79413
|
const dispatch = args.dispatchMeshCommand(args.daemonId, "git_status", { workspace: args.workspace, refreshUpstream: true });
|
|
79219
|
-
const
|
|
79220
|
-
|
|
79221
|
-
|
|
79222
|
-
isConnected,
|
|
79414
|
+
const remoteResult = await awaitWithWarmupDeadline(dispatch, resolveWarmupDeadlineOpts({
|
|
79415
|
+
getConnection: args.getConnection,
|
|
79416
|
+
daemonId: args.daemonId,
|
|
79223
79417
|
connectTimeoutMs: args.connectTimeoutMs,
|
|
79224
|
-
responseTimeoutMs: args.responseTimeoutMs
|
|
79225
|
-
|
|
79418
|
+
responseTimeoutMs: args.responseTimeoutMs,
|
|
79419
|
+
onMissingGetter: warnMeshWarmupGetterMissingOnce
|
|
79420
|
+
}));
|
|
79226
79421
|
const remoteGit = remoteResult?.status ?? remoteResult?.git ?? remoteResult;
|
|
79227
79422
|
if (!remoteGit || typeof remoteGit !== "object" || typeof remoteGit.isGitRepo !== "boolean") return null;
|
|
79228
79423
|
const reporterPlatform = readStringValue(remoteResult?.reporterPlatform);
|
|
@@ -79236,6 +79431,12 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79236
79431
|
function readMeshConnectionState(connection) {
|
|
79237
79432
|
return readStringValue(connection?.state);
|
|
79238
79433
|
}
|
|
79434
|
+
var meshWarmupGetterMissingWarned = /* @__PURE__ */ new Set();
|
|
79435
|
+
function warnMeshWarmupGetterMissingOnce(daemonId) {
|
|
79436
|
+
if (meshWarmupGetterMissingWarned.has(daemonId)) return;
|
|
79437
|
+
meshWarmupGetterMissingWarned.add(daemonId);
|
|
79438
|
+
LOG2.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.`);
|
|
79439
|
+
}
|
|
79239
79440
|
function isMeshConnectionDefinitivelyDown(connection) {
|
|
79240
79441
|
if (!connection) return true;
|
|
79241
79442
|
const state = readMeshConnectionState(connection);
|
|
@@ -91250,6 +91451,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
91250
91451
|
detectedIdes: detectedIdesRef,
|
|
91251
91452
|
refreshProviderAvailability,
|
|
91252
91453
|
dispatchMeshCommand: config2.dispatchMeshCommand,
|
|
91454
|
+
getMeshPeerConnectionStatus: config2.getMeshPeerConnectionStatus,
|
|
91253
91455
|
onMeshCoordinatorEventForwarded: config2.onMeshCoordinatorEventForwarded,
|
|
91254
91456
|
statusInstanceId: config2.statusInstanceId
|
|
91255
91457
|
};
|