@adhdev/daemon-core 0.9.82-rc.372 → 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 +148 -56
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +151 -60
- package/dist/index.mjs.map +1 -1
- package/dist/logging/log-tail-reader.d.ts +40 -5
- package/package.json +2 -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
|
@@ -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
|
}
|
|
@@ -20822,6 +20822,7 @@ __export(index_exports, {
|
|
|
20822
20822
|
buildMeshLedgerReplicaEvidence: () => buildMeshLedgerReplicaEvidence,
|
|
20823
20823
|
buildMeshNodeCapabilityTags: () => buildMeshNodeCapabilityTags,
|
|
20824
20824
|
buildMeshNodeDataFreshness: () => buildMeshNodeDataFreshness,
|
|
20825
|
+
buildMeshNodeProbeFreshness: () => buildMeshNodeProbeFreshness,
|
|
20825
20826
|
buildMissionPromptSection: () => buildMissionPromptSection,
|
|
20826
20827
|
buildP2pRelayFailurePayload: () => buildP2pRelayFailurePayload,
|
|
20827
20828
|
buildPinnedGlobalInstallCommand: () => buildPinnedGlobalInstallCommand,
|
|
@@ -34824,6 +34825,27 @@ function readByteBoundedTail(filePath, limitBytes) {
|
|
|
34824
34825
|
fs13.closeSync(fd);
|
|
34825
34826
|
}
|
|
34826
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
|
+
}
|
|
34827
34849
|
function parseLineEpochMs(line, fileDate) {
|
|
34828
34850
|
const m = line.match(/^\[(\d{2}):(\d{2}):(\d{2})(?:\.(\d{1,3}))?\]/);
|
|
34829
34851
|
if (!m) {
|
|
@@ -34838,47 +34860,97 @@ function parseLineEpochMs(line, fileDate) {
|
|
|
34838
34860
|
d.setHours(Number(m[1]), Number(m[2]), Number(m[3]), m[4] ? Number(m[4].padEnd(3, "0")) : 0);
|
|
34839
34861
|
return d.getTime();
|
|
34840
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
|
+
}
|
|
34841
34898
|
function readDaemonLogTail(args = {}) {
|
|
34842
34899
|
const platform10 = process.platform;
|
|
34843
34900
|
const limitBytes = clampTailBytes(args.tailBytes);
|
|
34844
|
-
|
|
34845
|
-
|
|
34846
|
-
|
|
34847
|
-
|
|
34848
|
-
|
|
34849
|
-
|
|
34850
|
-
|
|
34851
|
-
|
|
34852
|
-
|
|
34853
|
-
|
|
34854
|
-
truncated: false,
|
|
34855
|
-
logPath,
|
|
34856
|
-
platform: platform10,
|
|
34857
|
-
bytesReturned: 0,
|
|
34858
|
-
filtered: false
|
|
34859
|
-
};
|
|
34860
|
-
}
|
|
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
|
+
);
|
|
34861
34911
|
}
|
|
34862
|
-
|
|
34863
|
-
|
|
34864
|
-
|
|
34865
|
-
|
|
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);
|
|
34866
34924
|
return {
|
|
34867
|
-
success:
|
|
34868
|
-
|
|
34869
|
-
|
|
34870
|
-
truncated: false,
|
|
34925
|
+
success: true,
|
|
34926
|
+
lines: lines2,
|
|
34927
|
+
truncated: raw.truncated,
|
|
34871
34928
|
logPath,
|
|
34872
34929
|
platform: platform10,
|
|
34873
|
-
bytesReturned:
|
|
34874
|
-
filtered: false
|
|
34930
|
+
bytesReturned: raw.bytesReturned,
|
|
34931
|
+
filtered: false,
|
|
34932
|
+
fullScan: false,
|
|
34933
|
+
scannedBytes: raw.bytesReturned,
|
|
34934
|
+
matchedLineCount: lines2.length,
|
|
34935
|
+
excludedByFilter: 0
|
|
34875
34936
|
};
|
|
34876
34937
|
}
|
|
34877
|
-
let
|
|
34878
|
-
|
|
34879
|
-
|
|
34880
|
-
|
|
34881
|
-
|
|
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);
|
|
34882
34954
|
const floor = args.sinceMs;
|
|
34883
34955
|
lines = lines.filter((line) => {
|
|
34884
34956
|
const ts2 = parseLineEpochMs(line, fileDate);
|
|
@@ -34886,30 +34958,26 @@ function readDaemonLogTail(args = {}) {
|
|
|
34886
34958
|
});
|
|
34887
34959
|
}
|
|
34888
34960
|
let appliedGrep;
|
|
34889
|
-
if (
|
|
34961
|
+
if (hasGrep) {
|
|
34890
34962
|
appliedGrep = args.grep.trim();
|
|
34891
|
-
|
|
34892
|
-
|
|
34893
|
-
re = new RegExp(appliedGrep, "i");
|
|
34894
|
-
} catch {
|
|
34895
|
-
re = null;
|
|
34896
|
-
}
|
|
34897
|
-
if (re) {
|
|
34898
|
-
const compiled = re;
|
|
34899
|
-
lines = lines.filter((line) => compiled.test(line));
|
|
34900
|
-
} else {
|
|
34901
|
-
const needle = appliedGrep.toLowerCase();
|
|
34902
|
-
lines = lines.filter((line) => line.toLowerCase().includes(needle));
|
|
34903
|
-
}
|
|
34963
|
+
const matches = buildGrepPredicate(appliedGrep);
|
|
34964
|
+
lines = lines.filter(matches);
|
|
34904
34965
|
}
|
|
34966
|
+
const matchedLineCount = lines.length;
|
|
34967
|
+
const excludedByFilter = scannedLineCount - matchedLineCount;
|
|
34968
|
+
const capped = takeLastLinesWithinBytes(lines, limitBytes);
|
|
34905
34969
|
return {
|
|
34906
34970
|
success: true,
|
|
34907
|
-
lines,
|
|
34908
|
-
truncated:
|
|
34971
|
+
lines: capped.kept,
|
|
34972
|
+
truncated: capped.truncated,
|
|
34909
34973
|
logPath,
|
|
34910
34974
|
platform: platform10,
|
|
34911
|
-
bytesReturned:
|
|
34912
|
-
filtered:
|
|
34975
|
+
bytesReturned: capped.bytesReturned,
|
|
34976
|
+
filtered: excludedByFilter > 0,
|
|
34977
|
+
fullScan: true,
|
|
34978
|
+
scannedBytes,
|
|
34979
|
+
matchedLineCount,
|
|
34980
|
+
excludedByFilter,
|
|
34913
34981
|
...appliedGrep ? { grep: appliedGrep } : {}
|
|
34914
34982
|
};
|
|
34915
34983
|
}
|
|
@@ -35026,6 +35094,12 @@ var meshNodeLogsHandlers = {
|
|
|
35026
35094
|
truncated: tail.truncated,
|
|
35027
35095
|
filtered: tail.filtered,
|
|
35028
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,
|
|
35029
35103
|
...tail.grep ? { grep: tail.grep } : {}
|
|
35030
35104
|
};
|
|
35031
35105
|
}
|
|
@@ -48146,7 +48220,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
48146
48220
|
workspace
|
|
48147
48221
|
};
|
|
48148
48222
|
}
|
|
48149
|
-
const { existsSync: existsSync49, readFileSync:
|
|
48223
|
+
const { existsSync: existsSync49, readFileSync: readFileSync40, writeFileSync: writeFileSync24, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
|
|
48150
48224
|
const { dirname: dirname17 } = await import("path");
|
|
48151
48225
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
48152
48226
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
@@ -48196,7 +48270,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
48196
48270
|
}
|
|
48197
48271
|
if (hadExistingMcpConfig) {
|
|
48198
48272
|
try {
|
|
48199
|
-
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(
|
|
48273
|
+
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync40(mcpConfigPath, "utf-8"), configFormat);
|
|
48200
48274
|
const existingCoordinatorConfig = hermesManualFallback ? stripHermesCoordinatorTempModelProviderOverrides(parsedExistingMcpConfig) : parsedExistingMcpConfig;
|
|
48201
48275
|
existingMcpConfig = { ...existingMcpConfig, ...existingCoordinatorConfig };
|
|
48202
48276
|
copyFileSync4(mcpConfigPath, mcpConfigPath + ".backup");
|
|
@@ -49916,6 +49990,23 @@ function buildMeshNodeDataFreshness(args) {
|
|
|
49916
49990
|
staleness
|
|
49917
49991
|
};
|
|
49918
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
|
+
}
|
|
49919
50010
|
function finalizeMeshNodeStatus(args) {
|
|
49920
50011
|
const { status, node, daemonId, isSelfNode, directTruthUnavailable } = args;
|
|
49921
50012
|
if (!readStringValue(status.machineStatus)) {
|
|
@@ -62069,6 +62160,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
62069
62160
|
buildMeshLedgerReplicaEvidence,
|
|
62070
62161
|
buildMeshNodeCapabilityTags,
|
|
62071
62162
|
buildMeshNodeDataFreshness,
|
|
62163
|
+
buildMeshNodeProbeFreshness,
|
|
62072
62164
|
buildMissionPromptSection,
|
|
62073
62165
|
buildP2pRelayFailurePayload,
|
|
62074
62166
|
buildPinnedGlobalInstallCommand,
|