@adhdev/daemon-standalone 0.9.82-rc.366 → 0.9.82-rc.368
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 +220 -25
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/index-DqCY6Aye.js +113 -0
- package/public/index.html +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 ? "8cb6cfc5399f55c6b625095bacc9a27e1741df17" : void 0) ?? "unknown";
|
|
30040
|
+
const commitShort = readInjected(true ? "8cb6cfc5" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
30041
|
+
const version2 = readInjected(true ? "0.9.82-rc.368" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
30042
|
+
const builtAt = readInjected(true ? "2026-06-24T06:15:00.243Z" : void 0);
|
|
30043
30043
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
30044
30044
|
return cached2;
|
|
30045
30045
|
}
|
|
@@ -32634,6 +32634,16 @@ ${error48.message || ""}`;
|
|
|
32634
32634
|
if (!trimmed) return false;
|
|
32635
32635
|
return normalizeMeshNodeId(node) === trimmed;
|
|
32636
32636
|
}
|
|
32637
|
+
function normalizeMeshWorkspaceForCompare(dir) {
|
|
32638
|
+
if (typeof dir !== "string") return "";
|
|
32639
|
+
return dir.trim().replace(/[\\/]+/g, "/").replace(/\/+$/, "").toLowerCase();
|
|
32640
|
+
}
|
|
32641
|
+
function meshWorkspacesEquivalent(a, b) {
|
|
32642
|
+
const left = normalizeMeshWorkspaceForCompare(a);
|
|
32643
|
+
const right = normalizeMeshWorkspaceForCompare(b);
|
|
32644
|
+
if (!left || !right) return false;
|
|
32645
|
+
return left === right;
|
|
32646
|
+
}
|
|
32637
32647
|
function machineCoreFromDaemonId(id) {
|
|
32638
32648
|
const trimmed = readString3(id);
|
|
32639
32649
|
if (!trimmed) return void 0;
|
|
@@ -42642,21 +42652,29 @@ ${cleanBody}`;
|
|
|
42642
42652
|
}
|
|
42643
42653
|
});
|
|
42644
42654
|
}
|
|
42645
|
-
function normalizeMeshWorkspaceForCompare(dir) {
|
|
42646
|
-
if (typeof dir !== "string") return "";
|
|
42647
|
-
return dir.trim().replace(/[\\/]+/g, "/").replace(/\/+$/, "").toLowerCase();
|
|
42648
|
-
}
|
|
42649
42655
|
function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType) {
|
|
42650
42656
|
const mesh = getMeshWithCache(components, meshId);
|
|
42651
42657
|
const node = mesh?.nodes.find((n) => readMeshNodeId(n) === nodeId);
|
|
42652
42658
|
const localClaimAdapter = components.cliManager?.adapters?.get(sessionId);
|
|
42653
|
-
|
|
42654
|
-
|
|
42655
|
-
|
|
42656
|
-
|
|
42657
|
-
|
|
42659
|
+
let claimInstanceWorkspace = "";
|
|
42660
|
+
let claimStampedNodeId = "";
|
|
42661
|
+
try {
|
|
42662
|
+
const claimState = components.instanceManager?.getInstance?.(sessionId)?.getState?.();
|
|
42663
|
+
claimInstanceWorkspace = readNonEmptyString2(claimState?.workspace);
|
|
42664
|
+
const claimSettings = claimState?.settings || {};
|
|
42665
|
+
claimStampedNodeId = readNonEmptyString2(claimSettings.meshNodeId);
|
|
42666
|
+
} catch {
|
|
42667
|
+
}
|
|
42668
|
+
const nodeWorkspaceRaw = readNonEmptyString2(node?.workspace);
|
|
42669
|
+
const sessionWorkspaceRaw = readNonEmptyString2(localClaimAdapter?.workingDir) || claimInstanceWorkspace;
|
|
42670
|
+
if (claimStampedNodeId && nodeId) {
|
|
42671
|
+
if (!meshNodeIdMatches({ id: claimStampedNodeId }, nodeId)) {
|
|
42672
|
+
LOG2.info("MeshQueue", `WTDISPATCH: refusing claim for node ${nodeId} (${sessionId}) \u2014 session is bound to node "${claimStampedNodeId}" (cross-node claim blocked)`);
|
|
42658
42673
|
return false;
|
|
42659
42674
|
}
|
|
42675
|
+
} else if (sessionWorkspaceRaw && nodeWorkspaceRaw && !meshWorkspacesEquivalent(sessionWorkspaceRaw, nodeWorkspaceRaw)) {
|
|
42676
|
+
LOG2.info("MeshQueue", `WTCLAIM: refusing claim for node ${nodeId} (${sessionId}) \u2014 session workspace "${normalizeMeshWorkspaceForCompare(sessionWorkspaceRaw)}" \u2260 node workspace "${normalizeMeshWorkspaceForCompare(nodeWorkspaceRaw)}" (cross-workspace dispatch blocked)`);
|
|
42677
|
+
return false;
|
|
42660
42678
|
}
|
|
42661
42679
|
const capabilityTags = buildMeshNodeCapabilityTags(node, providerType);
|
|
42662
42680
|
const providerMaxParallel = resolveProviderMaxParallel(node?.policy, providerType);
|
|
@@ -43497,7 +43515,10 @@ ${cleanBody}`;
|
|
|
43497
43515
|
if (terminal?.kind === "task_completed" && !sessionHasActiveAssignment(args.meshId, eventSessionId)) {
|
|
43498
43516
|
const newDispatchAfterTerminal = hasDispatchAfterTerminal(args.meshId, eventSessionId, terminal.id);
|
|
43499
43517
|
const supersedesWeakTerminal = isWeakTerminalLedgerPayload(terminal.payload) && isGenuineCompletionEvidence(args.metadataEvent);
|
|
43500
|
-
|
|
43518
|
+
const terminalTaskId = readNonEmptyString2(terminal.payload.taskId);
|
|
43519
|
+
const eventTaskId = readNonEmptyString2(args.metadataEvent.taskId);
|
|
43520
|
+
const distinctTaskCompletion = !!eventTaskId && !!terminalTaskId && eventTaskId !== terminalTaskId;
|
|
43521
|
+
if (!newDispatchAfterTerminal && !supersedesWeakTerminal && !distinctTaskCompletion) {
|
|
43501
43522
|
const terminalProviderSessionId = readNonEmptyString2(terminal.payload.providerSessionId);
|
|
43502
43523
|
const terminalFinalSummary = readNonEmptyString2(terminal.payload.finalSummary);
|
|
43503
43524
|
const eventProviderSessionId = readNonEmptyString2(args.metadataEvent.providerSessionId);
|
|
@@ -43931,6 +43952,25 @@ ${cleanBody}`;
|
|
|
43931
43952
|
metadataEvent: buildRelayMetadataEvent(payload)
|
|
43932
43953
|
});
|
|
43933
43954
|
}
|
|
43955
|
+
function enqueueCoordinatorForwardPush(coordinatorDaemonId, run) {
|
|
43956
|
+
let lane = coordinatorForwardLanes.get(coordinatorDaemonId);
|
|
43957
|
+
if (!lane) {
|
|
43958
|
+
lane = { tail: Promise.resolve(), depth: 0 };
|
|
43959
|
+
coordinatorForwardLanes.set(coordinatorDaemonId, lane);
|
|
43960
|
+
}
|
|
43961
|
+
const wasIdle = lane.depth === 0;
|
|
43962
|
+
lane.depth += 1;
|
|
43963
|
+
const dec = () => {
|
|
43964
|
+
lane.depth -= 1;
|
|
43965
|
+
};
|
|
43966
|
+
if (wasIdle) {
|
|
43967
|
+
lane.tail = Promise.resolve(run()).catch(() => {
|
|
43968
|
+
}).then(dec, dec);
|
|
43969
|
+
} else {
|
|
43970
|
+
lane.tail = lane.tail.then(() => run()).catch(() => {
|
|
43971
|
+
}).then(dec, dec);
|
|
43972
|
+
}
|
|
43973
|
+
}
|
|
43934
43974
|
function forwardUnresolvedDelegateEvent(components, routing, event) {
|
|
43935
43975
|
const coordinatorDaemonId = readNonEmptyString2(routing.coordinatorDaemonId);
|
|
43936
43976
|
if (!coordinatorDaemonId) return false;
|
|
@@ -43943,6 +43983,16 @@ ${cleanBody}`;
|
|
|
43943
43983
|
nodeId: readNonEmptyString2(routing.nodeId) || readNonEmptyString2(event.meshNodeId) || void 0,
|
|
43944
43984
|
workspace: readNonEmptyString2(routing.workspace) || readNonEmptyString2(event.workspace) || void 0
|
|
43945
43985
|
};
|
|
43986
|
+
const selfDaemonIds = resolveCoordinatorDrainDaemonIds(components);
|
|
43987
|
+
if (selfDaemonIds.some((self) => daemonIdsEquivalent(self, coordinatorDaemonId))) {
|
|
43988
|
+
try {
|
|
43989
|
+
handleMeshForwardEvent(components, payload);
|
|
43990
|
+
LOG2.info("MeshEvents", `Self-addressed unresolved-delegate ${eventName} routed via local router (coordinator ${coordinatorDaemonId} is self) \u2014 outbox skipped`);
|
|
43991
|
+
} catch (e) {
|
|
43992
|
+
LOG2.warn("MeshEvents", `Local route of self-addressed unresolved-delegate ${eventName} failed: ${e?.message || e}`);
|
|
43993
|
+
}
|
|
43994
|
+
return true;
|
|
43995
|
+
}
|
|
43946
43996
|
const persisted = enqueueUnresolvedDelegateForward(coordinatorDaemonId, eventName, payload);
|
|
43947
43997
|
const fwdTraceCtx = {
|
|
43948
43998
|
taskId: payload.taskId,
|
|
@@ -43952,7 +44002,8 @@ ${cleanBody}`;
|
|
|
43952
44002
|
};
|
|
43953
44003
|
traceMeshEventStage("outbox_enqueue", fwdTraceCtx, `coordinatorDaemon=${coordinatorDaemonId} meshId=absent`);
|
|
43954
44004
|
traceMeshEventStage("forward_send", fwdTraceCtx, "immediate push");
|
|
43955
|
-
|
|
44005
|
+
const dispatchMeshCommand = components.dispatchMeshCommand;
|
|
44006
|
+
enqueueCoordinatorForwardPush(coordinatorDaemonId, () => Promise.resolve(dispatchMeshCommand(coordinatorDaemonId, "mesh_forward_event", payload)).then((result) => {
|
|
43956
44007
|
if (result && result.success === false) {
|
|
43957
44008
|
LOG2.warn("MeshEvents", `Immediate forward of ${eventName} to coordinator ${coordinatorDaemonId} rejected (${readNonEmptyString2(result.error) || "no reason"}) \u2014 left queued for retry`);
|
|
43958
44009
|
traceMeshEventDrop("immediate_forward_rejected", fwdTraceCtx, readNonEmptyString2(result.error) || "no reason");
|
|
@@ -43961,7 +44012,7 @@ ${cleanBody}`;
|
|
|
43961
44012
|
if (persisted) ackUnresolvedDelegateForwardByFingerprint(coordinatorDaemonId, eventName, payload);
|
|
43962
44013
|
}).catch((e) => {
|
|
43963
44014
|
LOG2.warn("MeshEvents", `Immediate forward of ${eventName} to coordinator ${coordinatorDaemonId} failed: ${e?.message || e} \u2014 left queued for retry`);
|
|
43964
|
-
});
|
|
44015
|
+
}));
|
|
43965
44016
|
LOG2.info("MeshEvents", `Durably forwarded ${eventName} for unresolved-mesh worker at ${routing.workspace || "(no workspace)"} to coordinator daemon ${coordinatorDaemonId}`);
|
|
43966
44017
|
return true;
|
|
43967
44018
|
}
|
|
@@ -44062,6 +44113,7 @@ ${cleanBody}`;
|
|
|
44062
44113
|
var MESH_COORDINATOR_EVENTS;
|
|
44063
44114
|
var EVENT_TO_LEDGER_KIND;
|
|
44064
44115
|
var MESH_FORCE_INJECT_EVENTS;
|
|
44116
|
+
var coordinatorForwardLanes;
|
|
44065
44117
|
var init_mesh_events_coordinator = __esm2({
|
|
44066
44118
|
"src/mesh/mesh-events-coordinator.ts"() {
|
|
44067
44119
|
"use strict";
|
|
@@ -44126,6 +44178,7 @@ ${cleanBody}`;
|
|
|
44126
44178
|
"worktree_bootstrap_complete",
|
|
44127
44179
|
"worktree_bootstrap_failed"
|
|
44128
44180
|
]);
|
|
44181
|
+
coordinatorForwardLanes = /* @__PURE__ */ new Map();
|
|
44129
44182
|
}
|
|
44130
44183
|
});
|
|
44131
44184
|
function resolveAutoPruneMinAgeMs() {
|
|
@@ -44466,6 +44519,8 @@ ${cleanBody}`;
|
|
|
44466
44519
|
expireStaleUnresolvedDelegateForwards();
|
|
44467
44520
|
const entries = peekUnresolvedDelegateForwards();
|
|
44468
44521
|
if (entries.length === 0) return;
|
|
44522
|
+
const selfIds = resolveCoordinatorDaemonIds(components);
|
|
44523
|
+
const isSelfCoordinatorId = (id) => selfIds.some((self) => daemonIdsEquivalent(self, id));
|
|
44469
44524
|
for (const entry of entries) {
|
|
44470
44525
|
const entryTraceCtx = {
|
|
44471
44526
|
taskId: entry.payload.taskId,
|
|
@@ -44473,6 +44528,23 @@ ${cleanBody}`;
|
|
|
44473
44528
|
nodeId: readNonEmptyString2(entry.payload.nodeId),
|
|
44474
44529
|
event: readNonEmptyString2(entry.payload.event)
|
|
44475
44530
|
};
|
|
44531
|
+
if (isSelfCoordinatorId(entry.coordinatorDaemonId)) {
|
|
44532
|
+
let localResult;
|
|
44533
|
+
try {
|
|
44534
|
+
traceMeshEventStage("forward_send", entryTraceCtx, `self \u2192 local router (${entry.coordinatorDaemonId})`);
|
|
44535
|
+
localResult = handleMeshForwardEvent(components, entry.payload);
|
|
44536
|
+
} catch (e) {
|
|
44537
|
+
LOG2.warn("MeshReconcile", `Local route of self-addressed forward to ${entry.coordinatorDaemonId} threw: ${e?.message || e} \u2014 draining anyway to break the retry loop`);
|
|
44538
|
+
}
|
|
44539
|
+
ackUnresolvedDelegateForward(entry.id);
|
|
44540
|
+
if (localResult && localResult.success === false) {
|
|
44541
|
+
LOG2.warn("MeshReconcile", `Self-addressed unresolved-delegate ${readNonEmptyString2(entry.payload.event)} rejected by local router (${readNonEmptyString2(localResult.error) || "no reason"}) \u2014 drained to break the self-forward retry loop`);
|
|
44542
|
+
traceMeshEventDrop("self_forward_local_rejected", entryTraceCtx, readNonEmptyString2(localResult.error) || "no reason");
|
|
44543
|
+
} else {
|
|
44544
|
+
LOG2.info("MeshReconcile", `Self-addressed unresolved-delegate ${readNonEmptyString2(entry.payload.event)} routed via local router (coordinator ${entry.coordinatorDaemonId} is self) \u2014 drained`);
|
|
44545
|
+
}
|
|
44546
|
+
continue;
|
|
44547
|
+
}
|
|
44476
44548
|
let result;
|
|
44477
44549
|
try {
|
|
44478
44550
|
traceMeshEventStage("forward_send", entryTraceCtx, `retry \u2192 ${entry.coordinatorDaemonId}`);
|
|
@@ -57924,6 +57996,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
57924
57996
|
}
|
|
57925
57997
|
var CHAT_SOURCE_REGISTRY = new ChatSourceRegistry();
|
|
57926
57998
|
init_chat_message_normalization();
|
|
57999
|
+
init_dist();
|
|
57927
58000
|
var RECENT_SEND_WINDOW_MS = 1200;
|
|
57928
58001
|
var READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS = 25e3;
|
|
57929
58002
|
var HOT_TAIL_MIN_LIMIT = 60;
|
|
@@ -58485,6 +58558,24 @@ ${effect.notification.body || ""}`.trim();
|
|
|
58485
58558
|
if (!text) return "";
|
|
58486
58559
|
return path16.resolve(text);
|
|
58487
58560
|
}
|
|
58561
|
+
function evaluateReadChatNodeWorkspaceScope(args) {
|
|
58562
|
+
const targetSessionId = typeof args.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
58563
|
+
if (!targetSessionId) return { scoped: false };
|
|
58564
|
+
const intended = normalizeMeshWorkspaceForCompare(args.intendedWorkspace);
|
|
58565
|
+
const actual = normalizeMeshWorkspaceForCompare(args.sessionWorkspace);
|
|
58566
|
+
if (!intended || !actual) return { scoped: false };
|
|
58567
|
+
if (intended === actual) return { scoped: false };
|
|
58568
|
+
return { scoped: true, intended, actual };
|
|
58569
|
+
}
|
|
58570
|
+
function resolveTargetSessionActualWorkspace(h, targetSessionId) {
|
|
58571
|
+
const registryWorkspace = h.ctx?.sessionRegistry?.get?.(targetSessionId)?.workspace;
|
|
58572
|
+
if (typeof registryWorkspace === "string" && registryWorkspace.trim()) return registryWorkspace;
|
|
58573
|
+
const adapter = h.getCliAdapter?.(targetSessionId);
|
|
58574
|
+
if (adapter && typeof adapter.workingDir === "string" && adapter.workingDir.trim()) return adapter.workingDir;
|
|
58575
|
+
const instanceWorkspace = getTargetInstance(h, { targetSessionId })?.getState?.()?.workspace;
|
|
58576
|
+
if (typeof instanceWorkspace === "string" && instanceWorkspace.trim()) return instanceWorkspace;
|
|
58577
|
+
return "";
|
|
58578
|
+
}
|
|
58488
58579
|
function isCurrentRuntimePtySafelyAttributed(args) {
|
|
58489
58580
|
if (args.adapter.cliType !== "codex-cli") return false;
|
|
58490
58581
|
if (!Array.isArray(args.ptyMessages) || args.ptyMessages.length === 0) return false;
|
|
@@ -59299,6 +59390,24 @@ ${effect.notification.body || ""}`.trim();
|
|
|
59299
59390
|
}
|
|
59300
59391
|
}
|
|
59301
59392
|
async function handleReadChat(h, args) {
|
|
59393
|
+
{
|
|
59394
|
+
const guardSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
59395
|
+
if (guardSessionId && typeof args?.workspace === "string" && args.workspace.trim()) {
|
|
59396
|
+
const verdict = evaluateReadChatNodeWorkspaceScope({
|
|
59397
|
+
targetSessionId: guardSessionId,
|
|
59398
|
+
intendedWorkspace: args.workspace,
|
|
59399
|
+
sessionWorkspace: resolveTargetSessionActualWorkspace(h, guardSessionId)
|
|
59400
|
+
});
|
|
59401
|
+
if (verdict.scoped) {
|
|
59402
|
+
LOG2.info("Command", `[read_chat] node scope mismatch: session ${guardSessionId} workspace "${verdict.actual}" \u2260 requested node workspace "${verdict.intended}" \u2014 refusing cross-worktree transcript`);
|
|
59403
|
+
return {
|
|
59404
|
+
success: false,
|
|
59405
|
+
code: "read_chat_session_node_scope_mismatch",
|
|
59406
|
+
error: `Session ${guardSessionId} belongs to a different worktree (workspace "${verdict.actual}") than the requested node (workspace "${verdict.intended}"). Refusing to return a cross-worktree transcript \u2014 target the node that owns this session.`
|
|
59407
|
+
};
|
|
59408
|
+
}
|
|
59409
|
+
}
|
|
59410
|
+
}
|
|
59302
59411
|
let providerHint = args?.agentType || args?.providerType;
|
|
59303
59412
|
if (!providerHint) {
|
|
59304
59413
|
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
@@ -59687,10 +59796,19 @@ ${effect.notification.body || ""}`.trim();
|
|
|
59687
59796
|
ptyStatusApprovalOnly: false
|
|
59688
59797
|
});
|
|
59689
59798
|
if (supportsNative && !decision.nativeSelected) {
|
|
59799
|
+
LOG2.debug("Command", `[read_chat] soft pending: no live adapter and native history not safely mappable target=${String(args?.targetSessionId || "")} provider=${agentStr} reason=native_history_not_safely_available`);
|
|
59690
59800
|
return {
|
|
59691
|
-
success:
|
|
59801
|
+
success: true,
|
|
59802
|
+
pending: true,
|
|
59803
|
+
// Both signals are true here: we reached the history-only path
|
|
59804
|
+
// because no live adapter was found (`live_adapter_not_found`),
|
|
59805
|
+
// and native history is not safely mappable
|
|
59806
|
+
// (`native_history_not_safely_available`).
|
|
59807
|
+
reason: "native_history_not_safely_available",
|
|
59808
|
+
reasons: ["live_adapter_not_found", "native_history_not_safely_available"],
|
|
59692
59809
|
code: "native_history_not_safely_available",
|
|
59693
|
-
|
|
59810
|
+
messages: [],
|
|
59811
|
+
status: "idle",
|
|
59694
59812
|
providerSessionId: historyProviderSessionId,
|
|
59695
59813
|
messageSource: decision.messageSource,
|
|
59696
59814
|
transcriptProvenance: decision.messageSource
|
|
@@ -71060,6 +71178,18 @@ ${rawInput}` : rawInput;
|
|
|
71060
71178
|
throw new Error(`Failed to start ${provider.displayName || provider.name || cliType}: ${spawnErr?.message}`);
|
|
71061
71179
|
}
|
|
71062
71180
|
this.adapters.set(key, cliInstance.getAdapter());
|
|
71181
|
+
const launchMeshNodeId = typeof settings?.meshNodeId === "string" ? settings.meshNodeId.trim() : "";
|
|
71182
|
+
const launchMeshNodeFor = typeof settings?.meshNodeFor === "string" ? settings.meshNodeFor.trim() : "";
|
|
71183
|
+
if (launchMeshNodeId || launchMeshNodeFor) {
|
|
71184
|
+
try {
|
|
71185
|
+
cliInstance.getAdapter().updateRuntimeMeta?.({
|
|
71186
|
+
...launchMeshNodeId ? { meshNodeId: launchMeshNodeId } : {},
|
|
71187
|
+
...launchMeshNodeFor ? { meshNodeFor: launchMeshNodeFor } : {},
|
|
71188
|
+
...settings?.launchedByCoordinator === true ? { launchedByCoordinator: true } : {}
|
|
71189
|
+
});
|
|
71190
|
+
} catch {
|
|
71191
|
+
}
|
|
71192
|
+
}
|
|
71063
71193
|
this.startCliExitMonitor(key, cliType);
|
|
71064
71194
|
}
|
|
71065
71195
|
// ─── Session start/management ──────────────────────────────
|
|
@@ -79034,6 +79164,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79034
79164
|
}
|
|
79035
79165
|
var MESH_DIRECT_PROBE_TIMEOUT_MS = readMeshTimeoutEnvMs("MESH_DIRECT_PROBE_TIMEOUT_MS", 25e3);
|
|
79036
79166
|
var MESH_DIRECT_PROBE_RETRY_TIMEOUT_MS = readMeshTimeoutEnvMs("MESH_DIRECT_PROBE_RETRY_TIMEOUT_MS", 25e3);
|
|
79167
|
+
var MESH_DIRECT_PROBE_CONNECT_TIMEOUT_MS = readMeshTimeoutEnvMs("MESH_DIRECT_PROBE_CONNECT_TIMEOUT_MS", 45e3);
|
|
79037
79168
|
var MESH_DIRECT_PROBE_REUSE_MS = readMeshTimeoutEnvMs("MESH_DIRECT_PROBE_REUSE_MS", 12e3);
|
|
79038
79169
|
var MeshGitProbeCache = class {
|
|
79039
79170
|
constructor(reuseMs, now = Date.now) {
|
|
@@ -79071,12 +79202,73 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79071
79202
|
}
|
|
79072
79203
|
}
|
|
79073
79204
|
};
|
|
79205
|
+
function awaitWithWarmupDeadline(work, opts) {
|
|
79206
|
+
const pollMs = Math.max(1, Math.min(opts.pollIntervalMs ?? 200, opts.connectTimeoutMs));
|
|
79207
|
+
return new Promise((resolve24, reject) => {
|
|
79208
|
+
let done = false;
|
|
79209
|
+
let poll;
|
|
79210
|
+
let responseTimer;
|
|
79211
|
+
const startedAt = Date.now();
|
|
79212
|
+
const cleanup = () => {
|
|
79213
|
+
if (poll) {
|
|
79214
|
+
clearInterval(poll);
|
|
79215
|
+
poll = void 0;
|
|
79216
|
+
}
|
|
79217
|
+
if (responseTimer) {
|
|
79218
|
+
clearTimeout(responseTimer);
|
|
79219
|
+
responseTimer = void 0;
|
|
79220
|
+
}
|
|
79221
|
+
};
|
|
79222
|
+
const settle = (fn) => {
|
|
79223
|
+
if (done) return;
|
|
79224
|
+
done = true;
|
|
79225
|
+
cleanup();
|
|
79226
|
+
fn();
|
|
79227
|
+
};
|
|
79228
|
+
const armResponse = () => {
|
|
79229
|
+
if (responseTimer || done) return;
|
|
79230
|
+
responseTimer = setTimeout(
|
|
79231
|
+
() => settle(() => reject(new Error("timeout"))),
|
|
79232
|
+
opts.responseTimeoutMs
|
|
79233
|
+
);
|
|
79234
|
+
if (typeof responseTimer.unref === "function") responseTimer.unref();
|
|
79235
|
+
};
|
|
79236
|
+
const onPoll = () => {
|
|
79237
|
+
if (done) return;
|
|
79238
|
+
if (opts.isConnected()) {
|
|
79239
|
+
if (poll) {
|
|
79240
|
+
clearInterval(poll);
|
|
79241
|
+
poll = void 0;
|
|
79242
|
+
}
|
|
79243
|
+
armResponse();
|
|
79244
|
+
return;
|
|
79245
|
+
}
|
|
79246
|
+
if (Date.now() - startedAt >= opts.connectTimeoutMs) {
|
|
79247
|
+
settle(() => reject(new Error("timeout")));
|
|
79248
|
+
}
|
|
79249
|
+
};
|
|
79250
|
+
if (opts.isConnected()) {
|
|
79251
|
+
armResponse();
|
|
79252
|
+
} else {
|
|
79253
|
+
poll = setInterval(onPoll, pollMs);
|
|
79254
|
+
if (typeof poll.unref === "function") poll.unref();
|
|
79255
|
+
}
|
|
79256
|
+
work.then(
|
|
79257
|
+
(val) => settle(() => resolve24(val)),
|
|
79258
|
+
(err) => settle(() => reject(err))
|
|
79259
|
+
);
|
|
79260
|
+
});
|
|
79261
|
+
}
|
|
79074
79262
|
async function probeRemoteMeshGitStatus(args) {
|
|
79075
79263
|
if (!args.dispatchMeshCommand) return null;
|
|
79076
|
-
const
|
|
79077
|
-
|
|
79078
|
-
|
|
79079
|
-
|
|
79264
|
+
const dispatch = args.dispatchMeshCommand(args.daemonId, "git_status", { workspace: args.workspace, refreshUpstream: true });
|
|
79265
|
+
const getConnection = args.getConnection;
|
|
79266
|
+
const isConnected = getConnection ? () => readMeshConnectionState(getConnection(args.daemonId)) === "connected" : () => true;
|
|
79267
|
+
const remoteResult = await awaitWithWarmupDeadline(dispatch, {
|
|
79268
|
+
isConnected,
|
|
79269
|
+
connectTimeoutMs: args.connectTimeoutMs,
|
|
79270
|
+
responseTimeoutMs: args.responseTimeoutMs
|
|
79271
|
+
});
|
|
79080
79272
|
const remoteGit = remoteResult?.status ?? remoteResult?.git ?? remoteResult;
|
|
79081
79273
|
if (!remoteGit || typeof remoteGit !== "object" || typeof remoteGit.isGitRepo !== "boolean") return null;
|
|
79082
79274
|
const reporterPlatform = readStringValue(remoteResult?.reporterPlatform);
|
|
@@ -79111,7 +79303,9 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79111
79303
|
dispatchMeshCommand: args.dispatchMeshCommand,
|
|
79112
79304
|
daemonId: args.daemonId,
|
|
79113
79305
|
workspace: args.workspace,
|
|
79114
|
-
|
|
79306
|
+
responseTimeoutMs: attempt === 0 ? args.timeoutMs : args.retryTimeoutMs ?? args.timeoutMs,
|
|
79307
|
+
connectTimeoutMs: args.connectTimeoutMs ?? MESH_DIRECT_PROBE_CONNECT_TIMEOUT_MS,
|
|
79308
|
+
getConnection: args.getConnection
|
|
79115
79309
|
});
|
|
79116
79310
|
if (remoteGit) return remoteGit;
|
|
79117
79311
|
} catch {
|
|
@@ -79194,6 +79388,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79194
79388
|
workspace,
|
|
79195
79389
|
timeoutMs: MESH_DIRECT_PROBE_TIMEOUT_MS,
|
|
79196
79390
|
retryTimeoutMs: MESH_DIRECT_PROBE_RETRY_TIMEOUT_MS,
|
|
79391
|
+
connectTimeoutMs: MESH_DIRECT_PROBE_CONNECT_TIMEOUT_MS,
|
|
79197
79392
|
getConnection: args.getMeshPeerConnectionStatus
|
|
79198
79393
|
});
|
|
79199
79394
|
const remoteGit = args.probeCache ? await args.probeCache.probe(daemonId, workspace, runProbe) : await runProbe();
|
|
@@ -79245,13 +79440,13 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79245
79440
|
if (!recordNodeId || recordNodeId !== nodeId) return false;
|
|
79246
79441
|
if (nodeIsMissingLocalWorktree) return false;
|
|
79247
79442
|
const recordWorkspace = readStringValue(record2?.workspace);
|
|
79248
|
-
if (nodeWorkspace && recordWorkspace && recordWorkspace
|
|
79443
|
+
if (nodeWorkspace && recordWorkspace && !meshWorkspacesEquivalent(recordWorkspace, nodeWorkspace)) return false;
|
|
79249
79444
|
const recordMeshId = readStringValue(record2?.meta?.meshNodeFor);
|
|
79250
79445
|
return !recordMeshId || recordMeshId === meshId;
|
|
79251
79446
|
}
|
|
79252
79447
|
function liveSessionRecordMatchesMeshWorkspace(record2, meshId, workspace) {
|
|
79253
79448
|
const recordWorkspace = readStringValue(record2?.workspace);
|
|
79254
|
-
if (!recordWorkspace || !workspace || recordWorkspace
|
|
79449
|
+
if (!recordWorkspace || !workspace || !meshWorkspacesEquivalent(recordWorkspace, workspace)) return false;
|
|
79255
79450
|
const recordMeshId = readStringValue(record2?.meta?.meshNodeFor);
|
|
79256
79451
|
if (recordMeshId) return recordMeshId === meshId;
|
|
79257
79452
|
return record2?.meta?.launchedByCoordinator === true || !!readStringValue(record2?.meta?.meshNodeId);
|