@adhdev/daemon-standalone 0.9.82-rc.371 → 0.9.82-rc.374
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 +281 -72
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/vendor/mcp-server/index.js +1878 -1857
- package/vendor/mcp-server/index.js.map +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 ? "47e042dcb10c9ca07c30ac4bf8e0d5a4153a63c6" : void 0) ?? "unknown";
|
|
30040
|
+
const commitShort = readInjected(true ? "47e042dc" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
30041
|
+
const version2 = readInjected(true ? "0.9.82-rc.374" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
30042
|
+
const builtAt = readInjected(true ? "2026-06-25T00:33:32.738Z" : void 0);
|
|
30043
30043
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
30044
30044
|
return cached2;
|
|
30045
30045
|
}
|
|
@@ -35318,7 +35318,14 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
35318
35318
|
if (candidate.taskMode === "live_debug_readonly") return true;
|
|
35319
35319
|
return !nodeBusy;
|
|
35320
35320
|
};
|
|
35321
|
-
const
|
|
35321
|
+
const nodeIsWorktree = opts?.nodeIsWorktree === true;
|
|
35322
|
+
const convergenceAllows = (candidate) => candidate.taskMode !== "convergence" || !nodeIsWorktree;
|
|
35323
|
+
const targetMatches = (candidate) => {
|
|
35324
|
+
if (candidate.targetSessionId && candidate.targetSessionId !== sessionId) return false;
|
|
35325
|
+
if (candidate.targetNodeId && candidate.targetNodeId !== nodeId) return false;
|
|
35326
|
+
return true;
|
|
35327
|
+
};
|
|
35328
|
+
const entry = candidates.find((candidate) => nodeSatisfiesRequiredTags(candidate.requiredTags, capabilityTags) && dependenciesSatisfied(candidate) && convergenceAllows(candidate) && targetMatches(candidate) && nodeConflictAllows(candidate));
|
|
35322
35329
|
if (!entry) return null;
|
|
35323
35330
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
35324
35331
|
entry.status = "assigned";
|
|
@@ -38520,7 +38527,7 @@ Next step: ${nextStep}`;
|
|
|
38520
38527
|
"src/mesh/mesh-events-utils.ts"() {
|
|
38521
38528
|
"use strict";
|
|
38522
38529
|
MESH_SURFACED_PREVIEW_MAX_CHARS = 512;
|
|
38523
|
-
MESH_COMPLETION_SURFACE_MAX_CHARS =
|
|
38530
|
+
MESH_COMPLETION_SURFACE_MAX_CHARS = 16e3;
|
|
38524
38531
|
}
|
|
38525
38532
|
});
|
|
38526
38533
|
function normalizeCoordinatorDaemonIds(coordinatorDaemonId) {
|
|
@@ -39163,6 +39170,22 @@ Next step: ${nextStep}`;
|
|
|
39163
39170
|
const diag = readRecord4(payload.completionDiagnostic);
|
|
39164
39171
|
return diag?.finalAssistantPresent === false || diag?.blockReason === "missing_final_assistant";
|
|
39165
39172
|
}
|
|
39173
|
+
function findTerminalLedgerEvidenceForTask(args) {
|
|
39174
|
+
const taskId = readNonEmptyString2(args.taskId);
|
|
39175
|
+
if (!taskId) return null;
|
|
39176
|
+
const entries = readLedgerEntries(args.meshId, { tail: args.tail ?? 500 });
|
|
39177
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
39178
|
+
const entry = entries[i];
|
|
39179
|
+
if (entry.kind !== "task_completed" && entry.kind !== "task_failed" && entry.kind !== "task_stalled") continue;
|
|
39180
|
+
const terminalTaskId = readNonEmptyString2(entry.payload?.taskId);
|
|
39181
|
+
if (terminalTaskId !== taskId) continue;
|
|
39182
|
+
if (entry.kind === "task_completed" && isWeakCompletionLedgerPayload(entry.payload)) continue;
|
|
39183
|
+
if (args.sessionId && entry.sessionId && entry.sessionId !== args.sessionId) continue;
|
|
39184
|
+
if (!args.sessionId && args.nodeId && entry.nodeId && !meshNodeIdMatches(entry, args.nodeId)) continue;
|
|
39185
|
+
return { id: entry.id, kind: entry.kind, payload: entry.payload || {}, timestamp: entry.timestamp };
|
|
39186
|
+
}
|
|
39187
|
+
return null;
|
|
39188
|
+
}
|
|
39166
39189
|
function findDirectDispatchLedgerEntry(args) {
|
|
39167
39190
|
const entries = readLedgerEntries(args.meshId, { tail: 500 });
|
|
39168
39191
|
for (let i = entries.length - 1; i >= 0; i--) {
|
|
@@ -41301,7 +41324,7 @@ Next step: ${nextStep}`;
|
|
|
41301
41324
|
"src/providers/chat-message-normalization.ts"() {
|
|
41302
41325
|
"use strict";
|
|
41303
41326
|
init_contracts();
|
|
41304
|
-
DEFAULT_FINAL_SUMMARY_MAX_CHARS =
|
|
41327
|
+
DEFAULT_FINAL_SUMMARY_MAX_CHARS = 16e3;
|
|
41305
41328
|
BUILTIN_CHAT_MESSAGE_KINDS = ["standard", "thought", "tool", "terminal", "system"];
|
|
41306
41329
|
CHAT_MESSAGE_VISIBILITIES = ["user", "debug", "internal", "hidden"];
|
|
41307
41330
|
CHAT_MESSAGE_TRANSCRIPT_VISIBILITIES = ["visible", "chat", "user", "debug", "internal", "hidden"];
|
|
@@ -42530,6 +42553,31 @@ ${cleanBody}`;
|
|
|
42530
42553
|
}
|
|
42531
42554
|
return "";
|
|
42532
42555
|
}
|
|
42556
|
+
function resolveForwardEventMeshId(components, payload) {
|
|
42557
|
+
const direct = readNonEmptyString2(payload.meshId);
|
|
42558
|
+
if (direct) return direct;
|
|
42559
|
+
const workspace = readNonEmptyString2(payload.workspace);
|
|
42560
|
+
const byWorkspace = workspace ? readNonEmptyString2(getCachedMeshByWorkspace(workspace)?.id) : "";
|
|
42561
|
+
if (byWorkspace) return byWorkspace;
|
|
42562
|
+
const byNode = recoverMeshIdByNodeId(readNonEmptyString2(payload.nodeId));
|
|
42563
|
+
if (byNode) return byNode;
|
|
42564
|
+
const sessionId = readNonEmptyString2(payload.targetSessionId) || readNonEmptyString2(payload.sessionId) || readNonEmptyString2(payload.instanceId);
|
|
42565
|
+
if (sessionId) {
|
|
42566
|
+
try {
|
|
42567
|
+
const state = components.instanceManager?.getInstance?.(sessionId)?.getState?.();
|
|
42568
|
+
const settings = state?.settings || {};
|
|
42569
|
+
const meshNodeFor = readNonEmptyString2(settings.meshNodeFor);
|
|
42570
|
+
if (meshNodeFor) return meshNodeFor;
|
|
42571
|
+
const byStamp = recoverMeshIdByNodeId(readNonEmptyString2(settings.meshNodeId));
|
|
42572
|
+
if (byStamp) return byStamp;
|
|
42573
|
+
const sessionWorkspace = readNonEmptyString2(state?.workspace);
|
|
42574
|
+
const bySessionWorkspace = sessionWorkspace ? readNonEmptyString2(getCachedMeshByWorkspace(sessionWorkspace)?.id) : "";
|
|
42575
|
+
if (bySessionWorkspace) return bySessionWorkspace;
|
|
42576
|
+
} catch {
|
|
42577
|
+
}
|
|
42578
|
+
}
|
|
42579
|
+
return "";
|
|
42580
|
+
}
|
|
42533
42581
|
function __resetIdleAutoFastForwardForTests() {
|
|
42534
42582
|
idleAutoFastForwardLastAttempt.clear();
|
|
42535
42583
|
}
|
|
@@ -42776,13 +42824,32 @@ ${cleanBody}`;
|
|
|
42776
42824
|
}
|
|
42777
42825
|
const capabilityTags = buildMeshNodeCapabilityTags(node, providerType);
|
|
42778
42826
|
const providerMaxParallel = resolveProviderMaxParallel(node?.policy, providerType);
|
|
42827
|
+
const nodeIsWorktree = node?.isLocalWorktree === true;
|
|
42779
42828
|
const task = claimNextTask(meshId, nodeId, sessionId, capabilityTags, {
|
|
42780
42829
|
providerType,
|
|
42781
|
-
...providerMaxParallel !== void 0 ? { providerMaxParallel } : {}
|
|
42830
|
+
...providerMaxParallel !== void 0 ? { providerMaxParallel } : {},
|
|
42831
|
+
nodeIsWorktree
|
|
42782
42832
|
});
|
|
42783
42833
|
if (!task) {
|
|
42784
42834
|
return false;
|
|
42785
42835
|
}
|
|
42836
|
+
const terminal = findTerminalLedgerEvidenceForTask({
|
|
42837
|
+
meshId,
|
|
42838
|
+
taskId: task.id
|
|
42839
|
+
});
|
|
42840
|
+
if (terminal) {
|
|
42841
|
+
const status = terminal.kind === "task_completed" ? "completed" : "failed";
|
|
42842
|
+
updateTaskStatus(meshId, task.id, status);
|
|
42843
|
+
LOG2.info("MeshQueue", `Skipped dispatch for terminal task ${task.id} on mesh ${meshId}; ${terminal.kind} ledger evidence already exists`);
|
|
42844
|
+
traceMeshEventDrop("dispatch_terminal_ledger", {
|
|
42845
|
+
taskId: task.id,
|
|
42846
|
+
sessionId,
|
|
42847
|
+
nodeId,
|
|
42848
|
+
meshId,
|
|
42849
|
+
event: "agent_command"
|
|
42850
|
+
}, terminal.kind);
|
|
42851
|
+
return false;
|
|
42852
|
+
}
|
|
42786
42853
|
LOG2.info("MeshQueue", `Node ${nodeId} (${sessionId}) pulled task ${task.id}`);
|
|
42787
42854
|
if (node?.daemonId && components.dispatchMeshCommand) {
|
|
42788
42855
|
const isLocalNode = components.cliManager.adapters.has(sessionId);
|
|
@@ -43122,6 +43189,7 @@ ${cleanBody}`;
|
|
|
43122
43189
|
}
|
|
43123
43190
|
const candidateNodes = Array.isArray(mesh?.nodes) ? mesh.nodes.filter((node) => {
|
|
43124
43191
|
if (task.targetNodeId && !meshNodeIdMatches(node, task.targetNodeId)) return false;
|
|
43192
|
+
if (task.taskMode === "convergence" && node?.isLocalWorktree === true) return false;
|
|
43125
43193
|
if (task.requiredTags?.length) {
|
|
43126
43194
|
const priorities = normalizeProviderPriority(node?.policy);
|
|
43127
43195
|
const providerCandidates = priorities.length ? priorities : [void 0];
|
|
@@ -44105,6 +44173,8 @@ ${cleanBody}`;
|
|
|
44105
44173
|
nodeId: readNonEmptyString2(routing.nodeId) || readNonEmptyString2(event.meshNodeId) || void 0,
|
|
44106
44174
|
workspace: readNonEmptyString2(routing.workspace) || readNonEmptyString2(event.workspace) || void 0
|
|
44107
44175
|
};
|
|
44176
|
+
const resolvedMeshId = resolveForwardEventMeshId(components, payload);
|
|
44177
|
+
if (resolvedMeshId) payload.meshId = resolvedMeshId;
|
|
44108
44178
|
const selfDaemonIds = resolveCoordinatorDrainDaemonIds(components);
|
|
44109
44179
|
if (selfDaemonIds.some((self) => daemonIdsEquivalent(self, coordinatorDaemonId))) {
|
|
44110
44180
|
try {
|
|
@@ -44335,20 +44405,24 @@ ${cleanBody}`;
|
|
|
44335
44405
|
if (host.role && host.role !== "host") return false;
|
|
44336
44406
|
const hostDaemonId = readNonEmptyString2(host.hostDaemonId);
|
|
44337
44407
|
if (!hostDaemonId) return true;
|
|
44338
|
-
return daemonIds
|
|
44408
|
+
return daemonIdListIncludes(daemonIds, hostDaemonId);
|
|
44409
|
+
}
|
|
44410
|
+
function daemonIdListIncludes(ids, id) {
|
|
44411
|
+
if (!id) return false;
|
|
44412
|
+
return ids.some((candidate) => candidate === id || daemonIdsEquivalent(candidate, id));
|
|
44339
44413
|
}
|
|
44340
44414
|
function resolveCoordinatorSelfIds(mesh, drainDaemonIds) {
|
|
44341
44415
|
const ids = new Set(drainDaemonIds);
|
|
44342
44416
|
for (const node of mesh.nodes) {
|
|
44343
44417
|
const nodeDaemonId = readNonEmptyString2(node.daemonId);
|
|
44344
44418
|
const nodeMachineId = readNonEmptyString2(node.machineId);
|
|
44345
|
-
const isSelf = nodeDaemonId && drainDaemonIds
|
|
44419
|
+
const isSelf = nodeDaemonId && daemonIdListIncludes(drainDaemonIds, nodeDaemonId) || nodeMachineId && daemonIdListIncludes(drainDaemonIds, nodeMachineId);
|
|
44346
44420
|
if (!isSelf) continue;
|
|
44347
44421
|
if (nodeDaemonId) ids.add(nodeDaemonId);
|
|
44348
44422
|
if (nodeMachineId) ids.add(nodeMachineId);
|
|
44349
44423
|
}
|
|
44350
44424
|
const hostDaemonId = readNonEmptyString2(mesh.meshHost?.hostDaemonId);
|
|
44351
|
-
if (hostDaemonId && ids
|
|
44425
|
+
if (hostDaemonId && daemonIdListIncludes([...ids], hostDaemonId)) ids.add(hostDaemonId);
|
|
44352
44426
|
return [...ids];
|
|
44353
44427
|
}
|
|
44354
44428
|
function findLiveCoordinators(components) {
|
|
@@ -44426,6 +44500,23 @@ ${cleanBody}`;
|
|
|
44426
44500
|
const dispatchedAtMs = Date.parse(row.dispatchTimestamp ?? "");
|
|
44427
44501
|
if (!Number.isFinite(dispatchedAtMs)) continue;
|
|
44428
44502
|
if (nowMs - dispatchedAtMs < ASSIGNED_STRANDED_DEADLINE_MS) continue;
|
|
44503
|
+
const terminal = findTerminalLedgerEvidenceForTask({
|
|
44504
|
+
meshId,
|
|
44505
|
+
taskId: row.id
|
|
44506
|
+
});
|
|
44507
|
+
if (terminal) {
|
|
44508
|
+
const status = terminal.kind === "task_completed" ? "completed" : "failed";
|
|
44509
|
+
updateTaskStatus(meshId, row.id, status);
|
|
44510
|
+
LOG2.warn("MeshReconcile", `Skipped stranded reclaim redispatch for terminal task ${row.id} on mesh ${meshId}; ${terminal.kind} ledger evidence already exists`);
|
|
44511
|
+
traceMeshEventDrop("assigned_stranded_terminal_ledger", {
|
|
44512
|
+
taskId: row.id,
|
|
44513
|
+
sessionId: row.assignedSessionId,
|
|
44514
|
+
nodeId: row.assignedNodeId,
|
|
44515
|
+
meshId,
|
|
44516
|
+
event: "agent:generating_completed"
|
|
44517
|
+
}, terminal.kind);
|
|
44518
|
+
continue;
|
|
44519
|
+
}
|
|
44429
44520
|
if (store.taskHasConfirmedDelivery(meshId, row.id)) continue;
|
|
44430
44521
|
const reclaimed = reclaimStrandedAssignedTask(meshId, row.id, {
|
|
44431
44522
|
reason: "assigned_stranded_dispatch_unconfirmed",
|
|
@@ -44645,7 +44736,10 @@ ${cleanBody}`;
|
|
|
44645
44736
|
if (!dispatchMeshCommand) return;
|
|
44646
44737
|
expireStaleUnresolvedDelegateForwards();
|
|
44647
44738
|
const entries = peekUnresolvedDelegateForwards();
|
|
44648
|
-
if (entries.length === 0)
|
|
44739
|
+
if (entries.length === 0) {
|
|
44740
|
+
if (unresolvedForwardRejectionCounts.size > 0) unresolvedForwardRejectionCounts.clear();
|
|
44741
|
+
return;
|
|
44742
|
+
}
|
|
44649
44743
|
const selfIds = resolveCoordinatorDaemonIds(components);
|
|
44650
44744
|
const isSelfCoordinatorId = (id) => selfIds.some((self) => daemonIdsEquivalent(self, id));
|
|
44651
44745
|
for (const entry of entries) {
|
|
@@ -44664,6 +44758,7 @@ ${cleanBody}`;
|
|
|
44664
44758
|
LOG2.warn("MeshReconcile", `Local route of self-addressed forward to ${entry.coordinatorDaemonId} threw: ${e?.message || e} \u2014 draining anyway to break the retry loop`);
|
|
44665
44759
|
}
|
|
44666
44760
|
ackUnresolvedDelegateForward(entry.id);
|
|
44761
|
+
unresolvedForwardRejectionCounts.delete(entry.id);
|
|
44667
44762
|
if (localResult && localResult.success === false) {
|
|
44668
44763
|
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`);
|
|
44669
44764
|
traceMeshEventDrop("self_forward_local_rejected", entryTraceCtx, readNonEmptyString2(localResult.error) || "no reason");
|
|
@@ -44672,21 +44767,40 @@ ${cleanBody}`;
|
|
|
44672
44767
|
}
|
|
44673
44768
|
continue;
|
|
44674
44769
|
}
|
|
44770
|
+
let pushPayload = entry.payload;
|
|
44771
|
+
if (!readNonEmptyString2(pushPayload.meshId)) {
|
|
44772
|
+
const recoveredMeshId = resolveForwardEventMeshId(components, pushPayload);
|
|
44773
|
+
if (recoveredMeshId) {
|
|
44774
|
+
pushPayload = { ...pushPayload, meshId: recoveredMeshId };
|
|
44775
|
+
traceMeshEventStage("forward_meshid_recovered", entryTraceCtx, `meshId=${recoveredMeshId}`);
|
|
44776
|
+
}
|
|
44777
|
+
}
|
|
44675
44778
|
let result;
|
|
44676
44779
|
try {
|
|
44677
44780
|
traceMeshEventStage("forward_send", entryTraceCtx, `retry \u2192 ${entry.coordinatorDaemonId}`);
|
|
44678
|
-
result = await dispatchMeshCommand(entry.coordinatorDaemonId, "mesh_forward_event",
|
|
44781
|
+
result = await dispatchMeshCommand(entry.coordinatorDaemonId, "mesh_forward_event", pushPayload);
|
|
44679
44782
|
} catch (e) {
|
|
44680
44783
|
LOG2.warn("MeshReconcile", `Retry forward to coordinator ${entry.coordinatorDaemonId} failed: ${e?.message || e} \u2014 left queued`);
|
|
44681
44784
|
traceMeshEventDrop("retry_forward_failed", entryTraceCtx, e?.message || String(e));
|
|
44682
44785
|
continue;
|
|
44683
44786
|
}
|
|
44684
44787
|
if (result && result.success === false) {
|
|
44685
|
-
|
|
44686
|
-
|
|
44788
|
+
const rejections = (unresolvedForwardRejectionCounts.get(entry.id) || 0) + 1;
|
|
44789
|
+
unresolvedForwardRejectionCounts.set(entry.id, rejections);
|
|
44790
|
+
const reason = readNonEmptyString2(result.error) || "no reason";
|
|
44791
|
+
if (rejections >= MAX_FORWARD_REJECTIONS) {
|
|
44792
|
+
ackUnresolvedDelegateForward(entry.id);
|
|
44793
|
+
unresolvedForwardRejectionCounts.delete(entry.id);
|
|
44794
|
+
LOG2.warn("MeshReconcile", `Retry forward to coordinator ${entry.coordinatorDaemonId} rejected ${rejections}x (${reason}) \u2014 dropping unresolved-delegate ${readNonEmptyString2(entry.payload.event)} (sess=${readNonEmptyString2(entry.payload.targetSessionId) || readNonEmptyString2(entry.payload.sessionId) || "-"}) to stop the retry loop`);
|
|
44795
|
+
traceMeshEventDrop("retry_forward_exhausted", entryTraceCtx, `${reason} (${rejections} rejections)`);
|
|
44796
|
+
} else {
|
|
44797
|
+
LOG2.warn("MeshReconcile", `Retry forward to coordinator ${entry.coordinatorDaemonId} rejected (${reason}) \u2014 left queued (attempt ${rejections}/${MAX_FORWARD_REJECTIONS})`);
|
|
44798
|
+
traceMeshEventDrop("retry_forward_rejected", entryTraceCtx, reason);
|
|
44799
|
+
}
|
|
44687
44800
|
continue;
|
|
44688
44801
|
}
|
|
44689
44802
|
ackUnresolvedDelegateForward(entry.id);
|
|
44803
|
+
unresolvedForwardRejectionCounts.delete(entry.id);
|
|
44690
44804
|
LOG2.info("MeshReconcile", `Retried+delivered unresolved-delegate ${readNonEmptyString2(entry.payload.event)} to coordinator ${entry.coordinatorDaemonId}`);
|
|
44691
44805
|
}
|
|
44692
44806
|
}
|
|
@@ -44699,7 +44813,7 @@ ${cleanBody}`;
|
|
|
44699
44813
|
const nodeDaemonId = readNonEmptyString2(node.daemonId);
|
|
44700
44814
|
if (!nodeDaemonId) continue;
|
|
44701
44815
|
if (daemonIdsEquivalent(nodeDaemonId, localDaemonId)) continue;
|
|
44702
|
-
if (candidateDaemonIds
|
|
44816
|
+
if (daemonIdListIncludes(candidateDaemonIds, nodeDaemonId)) continue;
|
|
44703
44817
|
for (const pendingEventArgs of pulls) {
|
|
44704
44818
|
let events;
|
|
44705
44819
|
try {
|
|
@@ -44755,7 +44869,7 @@ ${cleanBody}`;
|
|
|
44755
44869
|
if (!sessionId || !nodeId || !taskId) continue;
|
|
44756
44870
|
const node = nodeById.get(nodeId);
|
|
44757
44871
|
const nodeDaemonId = readNonEmptyString2(node?.daemonId);
|
|
44758
|
-
const isLocalNode = !nodeDaemonId || selfIds
|
|
44872
|
+
const isLocalNode = !nodeDaemonId || daemonIdListIncludes(selfIds, nodeDaemonId) || daemonIdsEquivalent(nodeDaemonId, localDaemonId) || !!components.instanceManager.getInstance(sessionId);
|
|
44759
44873
|
const providerType = readNonEmptyString2(dispatch.providerType);
|
|
44760
44874
|
const readArgs = {
|
|
44761
44875
|
sessionId,
|
|
@@ -44830,7 +44944,7 @@ ${cleanBody}`;
|
|
|
44830
44944
|
const dispatchMeshCommand = components.dispatchMeshCommand;
|
|
44831
44945
|
return Promise.all(mesh.nodes.map(async (node) => {
|
|
44832
44946
|
const nodeDaemonId = readNonEmptyString2(node.daemonId);
|
|
44833
|
-
const isLocalNode = !nodeDaemonId || selfIds
|
|
44947
|
+
const isLocalNode = !nodeDaemonId || daemonIdListIncludes(selfIds, nodeDaemonId) || daemonIdsEquivalent(nodeDaemonId, localDaemonId);
|
|
44834
44948
|
let statusResult;
|
|
44835
44949
|
try {
|
|
44836
44950
|
if (isLocalNode) {
|
|
@@ -44917,6 +45031,8 @@ ${cleanBody}`;
|
|
|
44917
45031
|
var heldEventLedgerRecorded;
|
|
44918
45032
|
var ASSIGNED_STRANDED_DEADLINE_MS;
|
|
44919
45033
|
var STRICT_SESSION_MATCH_TTL_MS;
|
|
45034
|
+
var unresolvedForwardRejectionCounts;
|
|
45035
|
+
var MAX_FORWARD_REJECTIONS;
|
|
44920
45036
|
var init_mesh_reconcile_loop = __esm2({
|
|
44921
45037
|
"src/mesh/mesh-reconcile-loop.ts"() {
|
|
44922
45038
|
"use strict";
|
|
@@ -44941,6 +45057,8 @@ ${cleanBody}`;
|
|
|
44941
45057
|
heldEventLedgerRecorded = /* @__PURE__ */ new Set();
|
|
44942
45058
|
ASSIGNED_STRANDED_DEADLINE_MS = 5 * 6e4;
|
|
44943
45059
|
STRICT_SESSION_MATCH_TTL_MS = 6e4;
|
|
45060
|
+
unresolvedForwardRejectionCounts = /* @__PURE__ */ new Map();
|
|
45061
|
+
MAX_FORWARD_REJECTIONS = 5;
|
|
44944
45062
|
}
|
|
44945
45063
|
});
|
|
44946
45064
|
var mesh_events_exports = {};
|
|
@@ -50566,6 +50684,7 @@ ${lastSnapshot}`;
|
|
|
50566
50684
|
buildMeshLedgerReplicaEvidence: () => buildMeshLedgerReplicaEvidence,
|
|
50567
50685
|
buildMeshNodeCapabilityTags: () => buildMeshNodeCapabilityTags,
|
|
50568
50686
|
buildMeshNodeDataFreshness: () => buildMeshNodeDataFreshness,
|
|
50687
|
+
buildMeshNodeProbeFreshness: () => buildMeshNodeProbeFreshness,
|
|
50569
50688
|
buildMissionPromptSection: () => buildMissionPromptSection,
|
|
50570
50689
|
buildP2pRelayFailurePayload: () => buildP2pRelayFailurePayload,
|
|
50571
50690
|
buildPinnedGlobalInstallCommand: () => buildPinnedGlobalInstallCommand,
|
|
@@ -64418,6 +64537,27 @@ ${body}
|
|
|
64418
64537
|
fs13.closeSync(fd);
|
|
64419
64538
|
}
|
|
64420
64539
|
}
|
|
64540
|
+
function splitLogLines(text) {
|
|
64541
|
+
const lines = text.split("\n");
|
|
64542
|
+
if (lines.length && lines[lines.length - 1] === "") lines.pop();
|
|
64543
|
+
return lines;
|
|
64544
|
+
}
|
|
64545
|
+
function takeLastLinesWithinBytes(lines, limitBytes) {
|
|
64546
|
+
if (lines.length === 0) return { kept: [], truncated: false, bytesReturned: 0 };
|
|
64547
|
+
let total = 0;
|
|
64548
|
+
let firstKept = lines.length;
|
|
64549
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
64550
|
+
const lineBytes = Buffer.byteLength(lines[i], "utf-8") + 1;
|
|
64551
|
+
if (firstKept !== lines.length && total + lineBytes > limitBytes) break;
|
|
64552
|
+
total += lineBytes;
|
|
64553
|
+
firstKept = i;
|
|
64554
|
+
}
|
|
64555
|
+
return {
|
|
64556
|
+
kept: lines.slice(firstKept),
|
|
64557
|
+
truncated: firstKept > 0,
|
|
64558
|
+
bytesReturned: total
|
|
64559
|
+
};
|
|
64560
|
+
}
|
|
64421
64561
|
function parseLineEpochMs(line, fileDate) {
|
|
64422
64562
|
const m = line.match(/^\[(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?\]/);
|
|
64423
64563
|
if (!m) {
|
|
@@ -64432,47 +64572,97 @@ ${body}
|
|
|
64432
64572
|
d.setHours(Number(m[1]), Number(m[2]), Number(m[3]), m[4] ? Number(m[4].padEnd(3, "0")) : 0);
|
|
64433
64573
|
return d.getTime();
|
|
64434
64574
|
}
|
|
64575
|
+
function buildGrepPredicate(grepSource) {
|
|
64576
|
+
let re = null;
|
|
64577
|
+
try {
|
|
64578
|
+
re = new RegExp(grepSource, "i");
|
|
64579
|
+
} catch {
|
|
64580
|
+
re = null;
|
|
64581
|
+
}
|
|
64582
|
+
if (re) {
|
|
64583
|
+
const compiled = re;
|
|
64584
|
+
return (line) => compiled.test(line);
|
|
64585
|
+
}
|
|
64586
|
+
const needle = grepSource.toLowerCase();
|
|
64587
|
+
return (line) => line.toLowerCase().includes(needle);
|
|
64588
|
+
}
|
|
64589
|
+
function fileDateFor(date5) {
|
|
64590
|
+
if (date5 instanceof Date) return date5;
|
|
64591
|
+
if (typeof date5 === "string" && date5.trim()) return /* @__PURE__ */ new Date(`${date5.trim()}T00:00:00.000Z`);
|
|
64592
|
+
return /* @__PURE__ */ new Date();
|
|
64593
|
+
}
|
|
64594
|
+
function errorResult(error48, logPath, platform10) {
|
|
64595
|
+
return {
|
|
64596
|
+
success: false,
|
|
64597
|
+
error: error48,
|
|
64598
|
+
lines: [],
|
|
64599
|
+
truncated: false,
|
|
64600
|
+
logPath,
|
|
64601
|
+
platform: platform10,
|
|
64602
|
+
bytesReturned: 0,
|
|
64603
|
+
filtered: false,
|
|
64604
|
+
fullScan: false,
|
|
64605
|
+
scannedBytes: 0,
|
|
64606
|
+
matchedLineCount: 0,
|
|
64607
|
+
excludedByFilter: 0
|
|
64608
|
+
};
|
|
64609
|
+
}
|
|
64435
64610
|
function readDaemonLogTail(args = {}) {
|
|
64436
64611
|
const platform10 = process.platform;
|
|
64437
64612
|
const limitBytes = clampTailBytes(args.tailBytes);
|
|
64438
|
-
|
|
64439
|
-
|
|
64440
|
-
|
|
64441
|
-
|
|
64442
|
-
|
|
64443
|
-
|
|
64444
|
-
|
|
64445
|
-
|
|
64446
|
-
|
|
64447
|
-
|
|
64448
|
-
truncated: false,
|
|
64449
|
-
logPath,
|
|
64450
|
-
platform: platform10,
|
|
64451
|
-
bytesReturned: 0,
|
|
64452
|
-
filtered: false
|
|
64453
|
-
};
|
|
64454
|
-
}
|
|
64613
|
+
const primaryPath = resolveLogPath(args.date);
|
|
64614
|
+
const backupPath = primaryPath.replace(/\.log$/, ".1.log");
|
|
64615
|
+
const primaryExists = fs13.existsSync(primaryPath);
|
|
64616
|
+
const backupExists = fs13.existsSync(backupPath);
|
|
64617
|
+
if (!primaryExists && !backupExists) {
|
|
64618
|
+
return errorResult(
|
|
64619
|
+
`No daemon log file at ${primaryPath} (dir: ${getDaemonLogDir()})`,
|
|
64620
|
+
primaryPath,
|
|
64621
|
+
platform10
|
|
64622
|
+
);
|
|
64455
64623
|
}
|
|
64456
|
-
|
|
64457
|
-
|
|
64458
|
-
|
|
64459
|
-
|
|
64624
|
+
const logPath = primaryExists ? primaryPath : backupPath;
|
|
64625
|
+
const hasGrep = typeof args.grep === "string" && args.grep.trim().length > 0;
|
|
64626
|
+
const hasSince = Number.isFinite(args.sinceMs);
|
|
64627
|
+
const filterMode = hasGrep || hasSince;
|
|
64628
|
+
if (!filterMode) {
|
|
64629
|
+
let raw;
|
|
64630
|
+
try {
|
|
64631
|
+
raw = readByteBoundedTail(logPath, limitBytes);
|
|
64632
|
+
} catch (e) {
|
|
64633
|
+
return errorResult(`Failed to read ${logPath}: ${e?.message ?? String(e)}`, logPath, platform10);
|
|
64634
|
+
}
|
|
64635
|
+
const lines2 = splitLogLines(raw.text);
|
|
64460
64636
|
return {
|
|
64461
|
-
success:
|
|
64462
|
-
|
|
64463
|
-
|
|
64464
|
-
truncated: false,
|
|
64637
|
+
success: true,
|
|
64638
|
+
lines: lines2,
|
|
64639
|
+
truncated: raw.truncated,
|
|
64465
64640
|
logPath,
|
|
64466
64641
|
platform: platform10,
|
|
64467
|
-
bytesReturned:
|
|
64468
|
-
filtered: false
|
|
64642
|
+
bytesReturned: raw.bytesReturned,
|
|
64643
|
+
filtered: false,
|
|
64644
|
+
fullScan: false,
|
|
64645
|
+
scannedBytes: raw.bytesReturned,
|
|
64646
|
+
matchedLineCount: lines2.length,
|
|
64647
|
+
excludedByFilter: 0
|
|
64469
64648
|
};
|
|
64470
64649
|
}
|
|
64471
|
-
let
|
|
64472
|
-
|
|
64473
|
-
|
|
64474
|
-
|
|
64475
|
-
|
|
64650
|
+
let scannedBytes = 0;
|
|
64651
|
+
let allLines = [];
|
|
64652
|
+
try {
|
|
64653
|
+
for (const p of [backupExists ? backupPath : null, primaryExists ? primaryPath : null]) {
|
|
64654
|
+
if (!p) continue;
|
|
64655
|
+
const buf = fs13.readFileSync(p);
|
|
64656
|
+
scannedBytes += buf.length;
|
|
64657
|
+
allLines = allLines.concat(splitLogLines(buf.toString("utf-8")));
|
|
64658
|
+
}
|
|
64659
|
+
} catch (e) {
|
|
64660
|
+
return errorResult(`Failed to read ${logPath}: ${e?.message ?? String(e)}`, logPath, platform10);
|
|
64661
|
+
}
|
|
64662
|
+
const scannedLineCount = allLines.length;
|
|
64663
|
+
let lines = allLines;
|
|
64664
|
+
if (hasSince) {
|
|
64665
|
+
const fileDate = fileDateFor(args.date);
|
|
64476
64666
|
const floor = args.sinceMs;
|
|
64477
64667
|
lines = lines.filter((line) => {
|
|
64478
64668
|
const ts2 = parseLineEpochMs(line, fileDate);
|
|
@@ -64480,30 +64670,26 @@ ${body}
|
|
|
64480
64670
|
});
|
|
64481
64671
|
}
|
|
64482
64672
|
let appliedGrep;
|
|
64483
|
-
if (
|
|
64673
|
+
if (hasGrep) {
|
|
64484
64674
|
appliedGrep = args.grep.trim();
|
|
64485
|
-
|
|
64486
|
-
|
|
64487
|
-
re = new RegExp(appliedGrep, "i");
|
|
64488
|
-
} catch {
|
|
64489
|
-
re = null;
|
|
64490
|
-
}
|
|
64491
|
-
if (re) {
|
|
64492
|
-
const compiled = re;
|
|
64493
|
-
lines = lines.filter((line) => compiled.test(line));
|
|
64494
|
-
} else {
|
|
64495
|
-
const needle = appliedGrep.toLowerCase();
|
|
64496
|
-
lines = lines.filter((line) => line.toLowerCase().includes(needle));
|
|
64497
|
-
}
|
|
64675
|
+
const matches = buildGrepPredicate(appliedGrep);
|
|
64676
|
+
lines = lines.filter(matches);
|
|
64498
64677
|
}
|
|
64678
|
+
const matchedLineCount = lines.length;
|
|
64679
|
+
const excludedByFilter = scannedLineCount - matchedLineCount;
|
|
64680
|
+
const capped = takeLastLinesWithinBytes(lines, limitBytes);
|
|
64499
64681
|
return {
|
|
64500
64682
|
success: true,
|
|
64501
|
-
lines,
|
|
64502
|
-
truncated:
|
|
64683
|
+
lines: capped.kept,
|
|
64684
|
+
truncated: capped.truncated,
|
|
64503
64685
|
logPath,
|
|
64504
64686
|
platform: platform10,
|
|
64505
|
-
bytesReturned:
|
|
64506
|
-
filtered:
|
|
64687
|
+
bytesReturned: capped.bytesReturned,
|
|
64688
|
+
filtered: excludedByFilter > 0,
|
|
64689
|
+
fullScan: true,
|
|
64690
|
+
scannedBytes,
|
|
64691
|
+
matchedLineCount,
|
|
64692
|
+
excludedByFilter,
|
|
64507
64693
|
...appliedGrep ? { grep: appliedGrep } : {}
|
|
64508
64694
|
};
|
|
64509
64695
|
}
|
|
@@ -64616,6 +64802,12 @@ ${body}
|
|
|
64616
64802
|
truncated: tail.truncated,
|
|
64617
64803
|
filtered: tail.filtered,
|
|
64618
64804
|
bytesReturned: tail.bytesReturned,
|
|
64805
|
+
// Transparency meta — lets the coordinator see that a full-file grep
|
|
64806
|
+
// ran past the recent tail window, and how much was scanned/excluded.
|
|
64807
|
+
fullScan: tail.fullScan,
|
|
64808
|
+
scannedBytes: tail.scannedBytes,
|
|
64809
|
+
matchedLineCount: tail.matchedLineCount,
|
|
64810
|
+
excludedByFilter: tail.excludedByFilter,
|
|
64619
64811
|
...tail.grep ? { grep: tail.grep } : {}
|
|
64620
64812
|
};
|
|
64621
64813
|
}
|
|
@@ -71697,7 +71889,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
71697
71889
|
const adapter = this.adapters.get(ik);
|
|
71698
71890
|
if (adapter) return { adapter, key: ik };
|
|
71699
71891
|
}
|
|
71700
|
-
if (opts?.dir) {
|
|
71892
|
+
if (opts?.dir && !opts?.instanceKey) {
|
|
71701
71893
|
for (const [k, a] of this.adapters) {
|
|
71702
71894
|
if (a.cliType === agentType && a.workingDir === opts.dir) {
|
|
71703
71895
|
return { adapter: a, key: k };
|
|
@@ -76309,7 +76501,7 @@ ${formatManifestValidationIssues2(validation2.issues)}`);
|
|
|
76309
76501
|
return "";
|
|
76310
76502
|
}
|
|
76311
76503
|
})();
|
|
76312
|
-
const isCoordinatorBaseNode = !!selfDaemonId && (nodeDaemonId
|
|
76504
|
+
const isCoordinatorBaseNode = !!selfDaemonId && (daemonIdsEquivalent(nodeDaemonId, selfDaemonId) || daemonIdsEquivalent(nodeMachineId, selfDaemonId)) || !!selfMachineId && (daemonIdsEquivalent(nodeDaemonId, selfMachineId) || daemonIdsEquivalent(nodeMachineId, selfMachineId));
|
|
76313
76505
|
if (isCoordinatorBaseNode) {
|
|
76314
76506
|
return {
|
|
76315
76507
|
success: false,
|
|
@@ -77640,7 +77832,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
77640
77832
|
workspace
|
|
77641
77833
|
};
|
|
77642
77834
|
}
|
|
77643
|
-
const { existsSync: existsSync49, readFileSync:
|
|
77835
|
+
const { existsSync: existsSync49, readFileSync: readFileSync40, writeFileSync: writeFileSync24, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
|
|
77644
77836
|
const { dirname: dirname17 } = await import("path");
|
|
77645
77837
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
77646
77838
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
@@ -77690,7 +77882,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
77690
77882
|
}
|
|
77691
77883
|
if (hadExistingMcpConfig) {
|
|
77692
77884
|
try {
|
|
77693
|
-
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(
|
|
77885
|
+
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync40(mcpConfigPath, "utf-8"), configFormat);
|
|
77694
77886
|
const existingCoordinatorConfig = hermesManualFallback ? stripHermesCoordinatorTempModelProviderOverrides(parsedExistingMcpConfig) : parsedExistingMcpConfig;
|
|
77695
77887
|
existingMcpConfig = { ...existingMcpConfig, ...existingCoordinatorConfig };
|
|
77696
77888
|
copyFileSync4(mcpConfigPath, mcpConfigPath + ".backup");
|
|
@@ -79392,6 +79584,23 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
79392
79584
|
staleness
|
|
79393
79585
|
};
|
|
79394
79586
|
}
|
|
79587
|
+
function buildMeshNodeProbeFreshness(args) {
|
|
79588
|
+
const { git, liveTruthProbed, isSelfNode, daemonId, node, now } = args;
|
|
79589
|
+
const status = {
|
|
79590
|
+
git,
|
|
79591
|
+
connection: { state: liveTruthProbed ? "connected" : "disconnected" }
|
|
79592
|
+
};
|
|
79593
|
+
if (liveTruthProbed) status[MESH_NODE_LIVE_TRUTH_MARKER] = true;
|
|
79594
|
+
return buildMeshNodeDataFreshness({
|
|
79595
|
+
status,
|
|
79596
|
+
node,
|
|
79597
|
+
isSelfNode,
|
|
79598
|
+
daemonId,
|
|
79599
|
+
liveTruthProbed,
|
|
79600
|
+
directTruthUnavailable: !liveTruthProbed && !!daemonId,
|
|
79601
|
+
now
|
|
79602
|
+
});
|
|
79603
|
+
}
|
|
79395
79604
|
function finalizeMeshNodeStatus(args) {
|
|
79396
79605
|
const { status, node, daemonId, isSelfNode, directTruthUnavailable } = args;
|
|
79397
79606
|
if (!readStringValue(status.machineStatus)) {
|