@adhdev/daemon-core 0.9.82-rc.371 → 0.9.82-rc.373
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/commands/router.d.ts +28 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +218 -64
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +221 -68
- package/dist/index.mjs.map +1 -1
- package/dist/logging/log-tail-reader.d.ts +40 -5
- package/dist/mesh/mesh-events-coordinator.d.ts +1 -0
- package/dist/mesh/mesh-reconcile-loop.d.ts +1 -0
- package/dist/mesh/mesh-runtime-store.d.ts +1 -0
- package/dist/mesh/mesh-work-queue.d.ts +1 -0
- package/package.json +2 -2
- package/src/commands/cli-manager.ts +11 -2
- package/src/commands/low-family/mesh-node-logs.ts +6 -0
- package/src/commands/router.ts +45 -0
- package/src/index.ts +1 -1
- package/src/logging/log-tail-reader.ts +187 -66
- package/src/mesh/mesh-events-coordinator.ts +67 -3
- package/src/mesh/mesh-reconcile-loop.ts +58 -6
- package/src/mesh/mesh-runtime-store.ts +26 -1
- package/src/mesh/mesh-work-queue.ts +1 -1
|
@@ -112,6 +112,34 @@ export declare function buildMeshNodeDataFreshness(args: {
|
|
|
112
112
|
directTruthUnavailable?: boolean;
|
|
113
113
|
now?: () => number;
|
|
114
114
|
}): Record<string, unknown>;
|
|
115
|
+
/**
|
|
116
|
+
* Canonical live-probe → freshness adapter. The coordinator-facing mesh_status
|
|
117
|
+
* (mcp-server `meshStatus`) builds each node entry from a SINGLE fresh git_status
|
|
118
|
+
* probe that either returns (live truth) or throws (peer unreachable). It used to
|
|
119
|
+
* hand-reconstruct the freshness INPUT inline — a synthetic `{ git, connection }`
|
|
120
|
+
* status plus the directTruthUnavailable/liveTruthProbed wiring — which is exactly
|
|
121
|
+
* how a field added to `buildMeshNodeDataFreshness`'s input contract ends up "wired
|
|
122
|
+
* on the daemon surface, null on the coordinator surface" (the rc.371
|
|
123
|
+
* null-everywhere regression). Routing every live-probe surface through this one
|
|
124
|
+
* adapter keeps the marker derivation canonical: there is a SINGLE place that turns
|
|
125
|
+
* a probe outcome into freshness args, so the two mesh_status surfaces cannot drift.
|
|
126
|
+
*
|
|
127
|
+
* `liveTruthProbed` true → the probe returned (live/self truth); false → it threw,
|
|
128
|
+
* so a configured peer is unreachable while an unconfigured node (no daemonId) falls
|
|
129
|
+
* through to the classifier's `unconfigured` branch.
|
|
130
|
+
*/
|
|
131
|
+
export declare function buildMeshNodeProbeFreshness(args: {
|
|
132
|
+
/** The git snapshot this probe stamped on the node entry (entry.git). */
|
|
133
|
+
git: unknown;
|
|
134
|
+
/** True when the fresh git_status probe RETURNED (live truth); false when it threw. */
|
|
135
|
+
liveTruthProbed: boolean;
|
|
136
|
+
isSelfNode: boolean;
|
|
137
|
+
/** The node's resolved daemonId; absent → unconfigured node. */
|
|
138
|
+
daemonId?: string;
|
|
139
|
+
/** The mesh node record, for held-git fallback when the probe did not return live. */
|
|
140
|
+
node?: any;
|
|
141
|
+
now?: () => number;
|
|
142
|
+
}): Record<string, unknown>;
|
|
115
143
|
export declare function finalizeMeshNodeStatus(args: {
|
|
116
144
|
status: Record<string, unknown>;
|
|
117
145
|
node: any;
|
package/dist/index.d.ts
CHANGED
|
@@ -84,7 +84,7 @@ export { DaemonCdpInitializer } from './cdp/initializer.js';
|
|
|
84
84
|
export type { CdpInitializerConfig } from './cdp/initializer.js';
|
|
85
85
|
export { DaemonCommandHandler } from './commands/handler.js';
|
|
86
86
|
export type { CommandResult, CommandContext } from './commands/handler.js';
|
|
87
|
-
export { DaemonCommandRouter, readCachedInlineMeshActiveSessionDetails, resolveMeshNodeAttribution, buildMeshNodeDataFreshness, MESH_NODE_LIVE_TRUTH_MARKER } from './commands/router.js';
|
|
87
|
+
export { DaemonCommandRouter, readCachedInlineMeshActiveSessionDetails, resolveMeshNodeAttribution, buildMeshNodeDataFreshness, buildMeshNodeProbeFreshness, MESH_NODE_LIVE_TRUTH_MARKER } from './commands/router.js';
|
|
88
88
|
export type { CommandRouterDeps, CommandRouterResult } from './commands/router.js';
|
|
89
89
|
export { maybeRunDaemonUpgradeHelperFromEnv, spawnDetachedDaemonUpgradeHelper, resolveCurrentGlobalInstallSurface, buildPinnedGlobalInstallCommand, execNpmCommandSync, getNpmExecOptions, } from './commands/upgrade-helper.js';
|
|
90
90
|
export type { DaemonUpgradeHelperPayload, CurrentGlobalInstallSurface, PinnedGlobalInstallCommand, NpmExecOptions, } from './commands/upgrade-helper.js';
|
package/dist/index.js
CHANGED
|
@@ -316,10 +316,10 @@ function readInjected(value) {
|
|
|
316
316
|
}
|
|
317
317
|
function getDaemonBuildInfo() {
|
|
318
318
|
if (cached) return cached;
|
|
319
|
-
const commit = readInjected(true ? "
|
|
320
|
-
const commitShort = readInjected(true ? "
|
|
321
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
322
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
319
|
+
const commit = readInjected(true ? "f16b5e6cdf653b4258f8f44cb11fb6ad8c13329f" : void 0) ?? "unknown";
|
|
320
|
+
const commitShort = readInjected(true ? "f16b5e6c" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
321
|
+
const version = readInjected(true ? "0.9.82-rc.373" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
322
|
+
const builtAt = readInjected(true ? "2026-06-24T16:28:52.547Z" : void 0);
|
|
323
323
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
324
324
|
return cached;
|
|
325
325
|
}
|
|
@@ -5542,7 +5542,14 @@ var init_mesh_runtime_store = __esm({
|
|
|
5542
5542
|
if (candidate.taskMode === "live_debug_readonly") return true;
|
|
5543
5543
|
return !nodeBusy;
|
|
5544
5544
|
};
|
|
5545
|
-
const
|
|
5545
|
+
const nodeIsWorktree = opts?.nodeIsWorktree === true;
|
|
5546
|
+
const convergenceAllows = (candidate) => candidate.taskMode !== "convergence" || !nodeIsWorktree;
|
|
5547
|
+
const targetMatches = (candidate) => {
|
|
5548
|
+
if (candidate.targetSessionId && candidate.targetSessionId !== sessionId) return false;
|
|
5549
|
+
if (candidate.targetNodeId && candidate.targetNodeId !== nodeId) return false;
|
|
5550
|
+
return true;
|
|
5551
|
+
};
|
|
5552
|
+
const entry = candidates.find((candidate) => nodeSatisfiesRequiredTags(candidate.requiredTags, capabilityTags) && dependenciesSatisfied(candidate) && convergenceAllows(candidate) && targetMatches(candidate) && nodeConflictAllows(candidate));
|
|
5546
5553
|
if (!entry) return null;
|
|
5547
5554
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
5548
5555
|
entry.status = "assigned";
|
|
@@ -12746,6 +12753,31 @@ function recoverMeshIdByNodeId(nodeId) {
|
|
|
12746
12753
|
}
|
|
12747
12754
|
return "";
|
|
12748
12755
|
}
|
|
12756
|
+
function resolveForwardEventMeshId(components, payload) {
|
|
12757
|
+
const direct = readNonEmptyString2(payload.meshId);
|
|
12758
|
+
if (direct) return direct;
|
|
12759
|
+
const workspace = readNonEmptyString2(payload.workspace);
|
|
12760
|
+
const byWorkspace = workspace ? readNonEmptyString2(getCachedMeshByWorkspace(workspace)?.id) : "";
|
|
12761
|
+
if (byWorkspace) return byWorkspace;
|
|
12762
|
+
const byNode = recoverMeshIdByNodeId(readNonEmptyString2(payload.nodeId));
|
|
12763
|
+
if (byNode) return byNode;
|
|
12764
|
+
const sessionId = readNonEmptyString2(payload.targetSessionId) || readNonEmptyString2(payload.sessionId) || readNonEmptyString2(payload.instanceId);
|
|
12765
|
+
if (sessionId) {
|
|
12766
|
+
try {
|
|
12767
|
+
const state = components.instanceManager?.getInstance?.(sessionId)?.getState?.();
|
|
12768
|
+
const settings = state?.settings || {};
|
|
12769
|
+
const meshNodeFor = readNonEmptyString2(settings.meshNodeFor);
|
|
12770
|
+
if (meshNodeFor) return meshNodeFor;
|
|
12771
|
+
const byStamp = recoverMeshIdByNodeId(readNonEmptyString2(settings.meshNodeId));
|
|
12772
|
+
if (byStamp) return byStamp;
|
|
12773
|
+
const sessionWorkspace = readNonEmptyString2(state?.workspace);
|
|
12774
|
+
const bySessionWorkspace = sessionWorkspace ? readNonEmptyString2(getCachedMeshByWorkspace(sessionWorkspace)?.id) : "";
|
|
12775
|
+
if (bySessionWorkspace) return bySessionWorkspace;
|
|
12776
|
+
} catch {
|
|
12777
|
+
}
|
|
12778
|
+
}
|
|
12779
|
+
return "";
|
|
12780
|
+
}
|
|
12749
12781
|
function __resetIdleAutoFastForwardForTests() {
|
|
12750
12782
|
idleAutoFastForwardLastAttempt.clear();
|
|
12751
12783
|
}
|
|
@@ -12992,9 +13024,11 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
|
|
|
12992
13024
|
}
|
|
12993
13025
|
const capabilityTags = buildMeshNodeCapabilityTags(node, providerType);
|
|
12994
13026
|
const providerMaxParallel = resolveProviderMaxParallel(node?.policy, providerType);
|
|
13027
|
+
const nodeIsWorktree = node?.isLocalWorktree === true;
|
|
12995
13028
|
const task = claimNextTask(meshId, nodeId, sessionId, capabilityTags, {
|
|
12996
13029
|
providerType,
|
|
12997
|
-
...providerMaxParallel !== void 0 ? { providerMaxParallel } : {}
|
|
13030
|
+
...providerMaxParallel !== void 0 ? { providerMaxParallel } : {},
|
|
13031
|
+
nodeIsWorktree
|
|
12998
13032
|
});
|
|
12999
13033
|
if (!task) {
|
|
13000
13034
|
return false;
|
|
@@ -13338,6 +13372,7 @@ async function maybeAutoLaunchOneQueueSession(components, meshId, mesh) {
|
|
|
13338
13372
|
}
|
|
13339
13373
|
const candidateNodes = Array.isArray(mesh?.nodes) ? mesh.nodes.filter((node) => {
|
|
13340
13374
|
if (task.targetNodeId && !meshNodeIdMatches(node, task.targetNodeId)) return false;
|
|
13375
|
+
if (task.taskMode === "convergence" && node?.isLocalWorktree === true) return false;
|
|
13341
13376
|
if (task.requiredTags?.length) {
|
|
13342
13377
|
const priorities = normalizeProviderPriority(node?.policy);
|
|
13343
13378
|
const providerCandidates = priorities.length ? priorities : [void 0];
|
|
@@ -14321,6 +14356,8 @@ function forwardUnresolvedDelegateEvent(components, routing, event) {
|
|
|
14321
14356
|
nodeId: readNonEmptyString2(routing.nodeId) || readNonEmptyString2(event.meshNodeId) || void 0,
|
|
14322
14357
|
workspace: readNonEmptyString2(routing.workspace) || readNonEmptyString2(event.workspace) || void 0
|
|
14323
14358
|
};
|
|
14359
|
+
const resolvedMeshId = resolveForwardEventMeshId(components, payload);
|
|
14360
|
+
if (resolvedMeshId) payload.meshId = resolvedMeshId;
|
|
14324
14361
|
const selfDaemonIds = resolveCoordinatorDrainDaemonIds(components);
|
|
14325
14362
|
if (selfDaemonIds.some((self) => daemonIdsEquivalent(self, coordinatorDaemonId))) {
|
|
14326
14363
|
try {
|
|
@@ -14843,7 +14880,10 @@ async function retryUnresolvedDelegateForwards(components) {
|
|
|
14843
14880
|
if (!dispatchMeshCommand) return;
|
|
14844
14881
|
expireStaleUnresolvedDelegateForwards();
|
|
14845
14882
|
const entries = peekUnresolvedDelegateForwards();
|
|
14846
|
-
if (entries.length === 0)
|
|
14883
|
+
if (entries.length === 0) {
|
|
14884
|
+
if (unresolvedForwardRejectionCounts.size > 0) unresolvedForwardRejectionCounts.clear();
|
|
14885
|
+
return;
|
|
14886
|
+
}
|
|
14847
14887
|
const selfIds = resolveCoordinatorDaemonIds(components);
|
|
14848
14888
|
const isSelfCoordinatorId = (id) => selfIds.some((self) => daemonIdsEquivalent(self, id));
|
|
14849
14889
|
for (const entry of entries) {
|
|
@@ -14862,6 +14902,7 @@ async function retryUnresolvedDelegateForwards(components) {
|
|
|
14862
14902
|
LOG.warn("MeshReconcile", `Local route of self-addressed forward to ${entry.coordinatorDaemonId} threw: ${e?.message || e} \u2014 draining anyway to break the retry loop`);
|
|
14863
14903
|
}
|
|
14864
14904
|
ackUnresolvedDelegateForward(entry.id);
|
|
14905
|
+
unresolvedForwardRejectionCounts.delete(entry.id);
|
|
14865
14906
|
if (localResult && localResult.success === false) {
|
|
14866
14907
|
LOG.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`);
|
|
14867
14908
|
traceMeshEventDrop("self_forward_local_rejected", entryTraceCtx, readNonEmptyString2(localResult.error) || "no reason");
|
|
@@ -14870,21 +14911,40 @@ async function retryUnresolvedDelegateForwards(components) {
|
|
|
14870
14911
|
}
|
|
14871
14912
|
continue;
|
|
14872
14913
|
}
|
|
14914
|
+
let pushPayload = entry.payload;
|
|
14915
|
+
if (!readNonEmptyString2(pushPayload.meshId)) {
|
|
14916
|
+
const recoveredMeshId = resolveForwardEventMeshId(components, pushPayload);
|
|
14917
|
+
if (recoveredMeshId) {
|
|
14918
|
+
pushPayload = { ...pushPayload, meshId: recoveredMeshId };
|
|
14919
|
+
traceMeshEventStage("forward_meshid_recovered", entryTraceCtx, `meshId=${recoveredMeshId}`);
|
|
14920
|
+
}
|
|
14921
|
+
}
|
|
14873
14922
|
let result;
|
|
14874
14923
|
try {
|
|
14875
14924
|
traceMeshEventStage("forward_send", entryTraceCtx, `retry \u2192 ${entry.coordinatorDaemonId}`);
|
|
14876
|
-
result = await dispatchMeshCommand(entry.coordinatorDaemonId, "mesh_forward_event",
|
|
14925
|
+
result = await dispatchMeshCommand(entry.coordinatorDaemonId, "mesh_forward_event", pushPayload);
|
|
14877
14926
|
} catch (e) {
|
|
14878
14927
|
LOG.warn("MeshReconcile", `Retry forward to coordinator ${entry.coordinatorDaemonId} failed: ${e?.message || e} \u2014 left queued`);
|
|
14879
14928
|
traceMeshEventDrop("retry_forward_failed", entryTraceCtx, e?.message || String(e));
|
|
14880
14929
|
continue;
|
|
14881
14930
|
}
|
|
14882
14931
|
if (result && result.success === false) {
|
|
14883
|
-
|
|
14884
|
-
|
|
14932
|
+
const rejections = (unresolvedForwardRejectionCounts.get(entry.id) || 0) + 1;
|
|
14933
|
+
unresolvedForwardRejectionCounts.set(entry.id, rejections);
|
|
14934
|
+
const reason = readNonEmptyString2(result.error) || "no reason";
|
|
14935
|
+
if (rejections >= MAX_FORWARD_REJECTIONS) {
|
|
14936
|
+
ackUnresolvedDelegateForward(entry.id);
|
|
14937
|
+
unresolvedForwardRejectionCounts.delete(entry.id);
|
|
14938
|
+
LOG.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`);
|
|
14939
|
+
traceMeshEventDrop("retry_forward_exhausted", entryTraceCtx, `${reason} (${rejections} rejections)`);
|
|
14940
|
+
} else {
|
|
14941
|
+
LOG.warn("MeshReconcile", `Retry forward to coordinator ${entry.coordinatorDaemonId} rejected (${reason}) \u2014 left queued (attempt ${rejections}/${MAX_FORWARD_REJECTIONS})`);
|
|
14942
|
+
traceMeshEventDrop("retry_forward_rejected", entryTraceCtx, reason);
|
|
14943
|
+
}
|
|
14885
14944
|
continue;
|
|
14886
14945
|
}
|
|
14887
14946
|
ackUnresolvedDelegateForward(entry.id);
|
|
14947
|
+
unresolvedForwardRejectionCounts.delete(entry.id);
|
|
14888
14948
|
LOG.info("MeshReconcile", `Retried+delivered unresolved-delegate ${readNonEmptyString2(entry.payload.event)} to coordinator ${entry.coordinatorDaemonId}`);
|
|
14889
14949
|
}
|
|
14890
14950
|
}
|
|
@@ -15110,7 +15170,7 @@ function setupMeshReconcileLoop(components) {
|
|
|
15110
15170
|
}
|
|
15111
15171
|
};
|
|
15112
15172
|
}
|
|
15113
|
-
var DEFAULT_RECONCILE_INTERVAL_MS, DEFAULT_AUTO_PRUNE_MIN_AGE_MS, heldEventLedgerRecorded, ASSIGNED_STRANDED_DEADLINE_MS, STRICT_SESSION_MATCH_TTL_MS;
|
|
15173
|
+
var DEFAULT_RECONCILE_INTERVAL_MS, DEFAULT_AUTO_PRUNE_MIN_AGE_MS, heldEventLedgerRecorded, ASSIGNED_STRANDED_DEADLINE_MS, STRICT_SESSION_MATCH_TTL_MS, unresolvedForwardRejectionCounts, MAX_FORWARD_REJECTIONS;
|
|
15114
15174
|
var init_mesh_reconcile_loop = __esm({
|
|
15115
15175
|
"src/mesh/mesh-reconcile-loop.ts"() {
|
|
15116
15176
|
"use strict";
|
|
@@ -15135,6 +15195,8 @@ var init_mesh_reconcile_loop = __esm({
|
|
|
15135
15195
|
heldEventLedgerRecorded = /* @__PURE__ */ new Set();
|
|
15136
15196
|
ASSIGNED_STRANDED_DEADLINE_MS = 5 * 6e4;
|
|
15137
15197
|
STRICT_SESSION_MATCH_TTL_MS = 6e4;
|
|
15198
|
+
unresolvedForwardRejectionCounts = /* @__PURE__ */ new Map();
|
|
15199
|
+
MAX_FORWARD_REJECTIONS = 5;
|
|
15138
15200
|
}
|
|
15139
15201
|
});
|
|
15140
15202
|
|
|
@@ -20760,6 +20822,7 @@ __export(index_exports, {
|
|
|
20760
20822
|
buildMeshLedgerReplicaEvidence: () => buildMeshLedgerReplicaEvidence,
|
|
20761
20823
|
buildMeshNodeCapabilityTags: () => buildMeshNodeCapabilityTags,
|
|
20762
20824
|
buildMeshNodeDataFreshness: () => buildMeshNodeDataFreshness,
|
|
20825
|
+
buildMeshNodeProbeFreshness: () => buildMeshNodeProbeFreshness,
|
|
20763
20826
|
buildMissionPromptSection: () => buildMissionPromptSection,
|
|
20764
20827
|
buildP2pRelayFailurePayload: () => buildP2pRelayFailurePayload,
|
|
20765
20828
|
buildPinnedGlobalInstallCommand: () => buildPinnedGlobalInstallCommand,
|
|
@@ -34762,6 +34825,27 @@ function readByteBoundedTail(filePath, limitBytes) {
|
|
|
34762
34825
|
fs13.closeSync(fd);
|
|
34763
34826
|
}
|
|
34764
34827
|
}
|
|
34828
|
+
function splitLogLines(text) {
|
|
34829
|
+
const lines = text.split("\n");
|
|
34830
|
+
if (lines.length && lines[lines.length - 1] === "") lines.pop();
|
|
34831
|
+
return lines;
|
|
34832
|
+
}
|
|
34833
|
+
function takeLastLinesWithinBytes(lines, limitBytes) {
|
|
34834
|
+
if (lines.length === 0) return { kept: [], truncated: false, bytesReturned: 0 };
|
|
34835
|
+
let total = 0;
|
|
34836
|
+
let firstKept = lines.length;
|
|
34837
|
+
for (let i = lines.length - 1; i >= 0; i--) {
|
|
34838
|
+
const lineBytes = Buffer.byteLength(lines[i], "utf-8") + 1;
|
|
34839
|
+
if (firstKept !== lines.length && total + lineBytes > limitBytes) break;
|
|
34840
|
+
total += lineBytes;
|
|
34841
|
+
firstKept = i;
|
|
34842
|
+
}
|
|
34843
|
+
return {
|
|
34844
|
+
kept: lines.slice(firstKept),
|
|
34845
|
+
truncated: firstKept > 0,
|
|
34846
|
+
bytesReturned: total
|
|
34847
|
+
};
|
|
34848
|
+
}
|
|
34765
34849
|
function parseLineEpochMs(line, fileDate) {
|
|
34766
34850
|
const m = line.match(/^\[(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?\]/);
|
|
34767
34851
|
if (!m) {
|
|
@@ -34776,47 +34860,97 @@ function parseLineEpochMs(line, fileDate) {
|
|
|
34776
34860
|
d.setHours(Number(m[1]), Number(m[2]), Number(m[3]), m[4] ? Number(m[4].padEnd(3, "0")) : 0);
|
|
34777
34861
|
return d.getTime();
|
|
34778
34862
|
}
|
|
34863
|
+
function buildGrepPredicate(grepSource) {
|
|
34864
|
+
let re = null;
|
|
34865
|
+
try {
|
|
34866
|
+
re = new RegExp(grepSource, "i");
|
|
34867
|
+
} catch {
|
|
34868
|
+
re = null;
|
|
34869
|
+
}
|
|
34870
|
+
if (re) {
|
|
34871
|
+
const compiled = re;
|
|
34872
|
+
return (line) => compiled.test(line);
|
|
34873
|
+
}
|
|
34874
|
+
const needle = grepSource.toLowerCase();
|
|
34875
|
+
return (line) => line.toLowerCase().includes(needle);
|
|
34876
|
+
}
|
|
34877
|
+
function fileDateFor(date) {
|
|
34878
|
+
if (date instanceof Date) return date;
|
|
34879
|
+
if (typeof date === "string" && date.trim()) return /* @__PURE__ */ new Date(`${date.trim()}T00:00:00.000Z`);
|
|
34880
|
+
return /* @__PURE__ */ new Date();
|
|
34881
|
+
}
|
|
34882
|
+
function errorResult(error, logPath, platform10) {
|
|
34883
|
+
return {
|
|
34884
|
+
success: false,
|
|
34885
|
+
error,
|
|
34886
|
+
lines: [],
|
|
34887
|
+
truncated: false,
|
|
34888
|
+
logPath,
|
|
34889
|
+
platform: platform10,
|
|
34890
|
+
bytesReturned: 0,
|
|
34891
|
+
filtered: false,
|
|
34892
|
+
fullScan: false,
|
|
34893
|
+
scannedBytes: 0,
|
|
34894
|
+
matchedLineCount: 0,
|
|
34895
|
+
excludedByFilter: 0
|
|
34896
|
+
};
|
|
34897
|
+
}
|
|
34779
34898
|
function readDaemonLogTail(args = {}) {
|
|
34780
34899
|
const platform10 = process.platform;
|
|
34781
34900
|
const limitBytes = clampTailBytes(args.tailBytes);
|
|
34782
|
-
|
|
34783
|
-
|
|
34784
|
-
|
|
34785
|
-
|
|
34786
|
-
|
|
34787
|
-
|
|
34788
|
-
|
|
34789
|
-
|
|
34790
|
-
|
|
34791
|
-
|
|
34792
|
-
truncated: false,
|
|
34793
|
-
logPath,
|
|
34794
|
-
platform: platform10,
|
|
34795
|
-
bytesReturned: 0,
|
|
34796
|
-
filtered: false
|
|
34797
|
-
};
|
|
34798
|
-
}
|
|
34901
|
+
const primaryPath = resolveLogPath(args.date);
|
|
34902
|
+
const backupPath = primaryPath.replace(/\.log$/, ".1.log");
|
|
34903
|
+
const primaryExists = fs13.existsSync(primaryPath);
|
|
34904
|
+
const backupExists = fs13.existsSync(backupPath);
|
|
34905
|
+
if (!primaryExists && !backupExists) {
|
|
34906
|
+
return errorResult(
|
|
34907
|
+
`No daemon log file at ${primaryPath} (dir: ${getDaemonLogDir()})`,
|
|
34908
|
+
primaryPath,
|
|
34909
|
+
platform10
|
|
34910
|
+
);
|
|
34799
34911
|
}
|
|
34800
|
-
|
|
34801
|
-
|
|
34802
|
-
|
|
34803
|
-
|
|
34912
|
+
const logPath = primaryExists ? primaryPath : backupPath;
|
|
34913
|
+
const hasGrep = typeof args.grep === "string" && args.grep.trim().length > 0;
|
|
34914
|
+
const hasSince = Number.isFinite(args.sinceMs);
|
|
34915
|
+
const filterMode = hasGrep || hasSince;
|
|
34916
|
+
if (!filterMode) {
|
|
34917
|
+
let raw;
|
|
34918
|
+
try {
|
|
34919
|
+
raw = readByteBoundedTail(logPath, limitBytes);
|
|
34920
|
+
} catch (e) {
|
|
34921
|
+
return errorResult(`Failed to read ${logPath}: ${e?.message ?? String(e)}`, logPath, platform10);
|
|
34922
|
+
}
|
|
34923
|
+
const lines2 = splitLogLines(raw.text);
|
|
34804
34924
|
return {
|
|
34805
|
-
success:
|
|
34806
|
-
|
|
34807
|
-
|
|
34808
|
-
truncated: false,
|
|
34925
|
+
success: true,
|
|
34926
|
+
lines: lines2,
|
|
34927
|
+
truncated: raw.truncated,
|
|
34809
34928
|
logPath,
|
|
34810
34929
|
platform: platform10,
|
|
34811
|
-
bytesReturned:
|
|
34812
|
-
filtered: false
|
|
34930
|
+
bytesReturned: raw.bytesReturned,
|
|
34931
|
+
filtered: false,
|
|
34932
|
+
fullScan: false,
|
|
34933
|
+
scannedBytes: raw.bytesReturned,
|
|
34934
|
+
matchedLineCount: lines2.length,
|
|
34935
|
+
excludedByFilter: 0
|
|
34813
34936
|
};
|
|
34814
34937
|
}
|
|
34815
|
-
let
|
|
34816
|
-
|
|
34817
|
-
|
|
34818
|
-
|
|
34819
|
-
|
|
34938
|
+
let scannedBytes = 0;
|
|
34939
|
+
let allLines = [];
|
|
34940
|
+
try {
|
|
34941
|
+
for (const p of [backupExists ? backupPath : null, primaryExists ? primaryPath : null]) {
|
|
34942
|
+
if (!p) continue;
|
|
34943
|
+
const buf = fs13.readFileSync(p);
|
|
34944
|
+
scannedBytes += buf.length;
|
|
34945
|
+
allLines = allLines.concat(splitLogLines(buf.toString("utf-8")));
|
|
34946
|
+
}
|
|
34947
|
+
} catch (e) {
|
|
34948
|
+
return errorResult(`Failed to read ${logPath}: ${e?.message ?? String(e)}`, logPath, platform10);
|
|
34949
|
+
}
|
|
34950
|
+
const scannedLineCount = allLines.length;
|
|
34951
|
+
let lines = allLines;
|
|
34952
|
+
if (hasSince) {
|
|
34953
|
+
const fileDate = fileDateFor(args.date);
|
|
34820
34954
|
const floor = args.sinceMs;
|
|
34821
34955
|
lines = lines.filter((line) => {
|
|
34822
34956
|
const ts2 = parseLineEpochMs(line, fileDate);
|
|
@@ -34824,30 +34958,26 @@ function readDaemonLogTail(args = {}) {
|
|
|
34824
34958
|
});
|
|
34825
34959
|
}
|
|
34826
34960
|
let appliedGrep;
|
|
34827
|
-
if (
|
|
34961
|
+
if (hasGrep) {
|
|
34828
34962
|
appliedGrep = args.grep.trim();
|
|
34829
|
-
|
|
34830
|
-
|
|
34831
|
-
re = new RegExp(appliedGrep, "i");
|
|
34832
|
-
} catch {
|
|
34833
|
-
re = null;
|
|
34834
|
-
}
|
|
34835
|
-
if (re) {
|
|
34836
|
-
const compiled = re;
|
|
34837
|
-
lines = lines.filter((line) => compiled.test(line));
|
|
34838
|
-
} else {
|
|
34839
|
-
const needle = appliedGrep.toLowerCase();
|
|
34840
|
-
lines = lines.filter((line) => line.toLowerCase().includes(needle));
|
|
34841
|
-
}
|
|
34963
|
+
const matches = buildGrepPredicate(appliedGrep);
|
|
34964
|
+
lines = lines.filter(matches);
|
|
34842
34965
|
}
|
|
34966
|
+
const matchedLineCount = lines.length;
|
|
34967
|
+
const excludedByFilter = scannedLineCount - matchedLineCount;
|
|
34968
|
+
const capped = takeLastLinesWithinBytes(lines, limitBytes);
|
|
34843
34969
|
return {
|
|
34844
34970
|
success: true,
|
|
34845
|
-
lines,
|
|
34846
|
-
truncated:
|
|
34971
|
+
lines: capped.kept,
|
|
34972
|
+
truncated: capped.truncated,
|
|
34847
34973
|
logPath,
|
|
34848
34974
|
platform: platform10,
|
|
34849
|
-
bytesReturned:
|
|
34850
|
-
filtered:
|
|
34975
|
+
bytesReturned: capped.bytesReturned,
|
|
34976
|
+
filtered: excludedByFilter > 0,
|
|
34977
|
+
fullScan: true,
|
|
34978
|
+
scannedBytes,
|
|
34979
|
+
matchedLineCount,
|
|
34980
|
+
excludedByFilter,
|
|
34851
34981
|
...appliedGrep ? { grep: appliedGrep } : {}
|
|
34852
34982
|
};
|
|
34853
34983
|
}
|
|
@@ -34964,6 +35094,12 @@ var meshNodeLogsHandlers = {
|
|
|
34964
35094
|
truncated: tail.truncated,
|
|
34965
35095
|
filtered: tail.filtered,
|
|
34966
35096
|
bytesReturned: tail.bytesReturned,
|
|
35097
|
+
// Transparency meta — lets the coordinator see that a full-file grep
|
|
35098
|
+
// ran past the recent tail window, and how much was scanned/excluded.
|
|
35099
|
+
fullScan: tail.fullScan,
|
|
35100
|
+
scannedBytes: tail.scannedBytes,
|
|
35101
|
+
matchedLineCount: tail.matchedLineCount,
|
|
35102
|
+
excludedByFilter: tail.excludedByFilter,
|
|
34967
35103
|
...tail.grep ? { grep: tail.grep } : {}
|
|
34968
35104
|
};
|
|
34969
35105
|
}
|
|
@@ -42091,7 +42227,7 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
42091
42227
|
const adapter = this.adapters.get(ik);
|
|
42092
42228
|
if (adapter) return { adapter, key: ik };
|
|
42093
42229
|
}
|
|
42094
|
-
if (opts?.dir) {
|
|
42230
|
+
if (opts?.dir && !opts?.instanceKey) {
|
|
42095
42231
|
for (const [k, a] of this.adapters) {
|
|
42096
42232
|
if (a.cliType === agentType && a.workingDir === opts.dir) {
|
|
42097
42233
|
return { adapter: a, key: k };
|
|
@@ -48084,7 +48220,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
48084
48220
|
workspace
|
|
48085
48221
|
};
|
|
48086
48222
|
}
|
|
48087
|
-
const { existsSync: existsSync49, readFileSync:
|
|
48223
|
+
const { existsSync: existsSync49, readFileSync: readFileSync40, writeFileSync: writeFileSync24, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
|
|
48088
48224
|
const { dirname: dirname17 } = await import("path");
|
|
48089
48225
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
48090
48226
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
@@ -48134,7 +48270,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
48134
48270
|
}
|
|
48135
48271
|
if (hadExistingMcpConfig) {
|
|
48136
48272
|
try {
|
|
48137
|
-
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(
|
|
48273
|
+
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync40(mcpConfigPath, "utf-8"), configFormat);
|
|
48138
48274
|
const existingCoordinatorConfig = hermesManualFallback ? stripHermesCoordinatorTempModelProviderOverrides(parsedExistingMcpConfig) : parsedExistingMcpConfig;
|
|
48139
48275
|
existingMcpConfig = { ...existingMcpConfig, ...existingCoordinatorConfig };
|
|
48140
48276
|
copyFileSync4(mcpConfigPath, mcpConfigPath + ".backup");
|
|
@@ -49854,6 +49990,23 @@ function buildMeshNodeDataFreshness(args) {
|
|
|
49854
49990
|
staleness
|
|
49855
49991
|
};
|
|
49856
49992
|
}
|
|
49993
|
+
function buildMeshNodeProbeFreshness(args) {
|
|
49994
|
+
const { git, liveTruthProbed, isSelfNode, daemonId, node, now } = args;
|
|
49995
|
+
const status = {
|
|
49996
|
+
git,
|
|
49997
|
+
connection: { state: liveTruthProbed ? "connected" : "disconnected" }
|
|
49998
|
+
};
|
|
49999
|
+
if (liveTruthProbed) status[MESH_NODE_LIVE_TRUTH_MARKER] = true;
|
|
50000
|
+
return buildMeshNodeDataFreshness({
|
|
50001
|
+
status,
|
|
50002
|
+
node,
|
|
50003
|
+
isSelfNode,
|
|
50004
|
+
daemonId,
|
|
50005
|
+
liveTruthProbed,
|
|
50006
|
+
directTruthUnavailable: !liveTruthProbed && !!daemonId,
|
|
50007
|
+
now
|
|
50008
|
+
});
|
|
50009
|
+
}
|
|
49857
50010
|
function finalizeMeshNodeStatus(args) {
|
|
49858
50011
|
const { status, node, daemonId, isSelfNode, directTruthUnavailable } = args;
|
|
49859
50012
|
if (!readStringValue(status.machineStatus)) {
|
|
@@ -62007,6 +62160,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
62007
62160
|
buildMeshLedgerReplicaEvidence,
|
|
62008
62161
|
buildMeshNodeCapabilityTags,
|
|
62009
62162
|
buildMeshNodeDataFreshness,
|
|
62163
|
+
buildMeshNodeProbeFreshness,
|
|
62010
62164
|
buildMissionPromptSection,
|
|
62011
62165
|
buildP2pRelayFailurePayload,
|
|
62012
62166
|
buildPinnedGlobalInstallCommand,
|