@adhdev/daemon-standalone 1.0.28-rc.24 → 1.0.28-rc.25
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 +128 -26
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -33311,10 +33311,10 @@ var require_dist3 = __commonJS({
|
|
|
33311
33311
|
}
|
|
33312
33312
|
function getDaemonBuildInfo() {
|
|
33313
33313
|
if (cached2) return cached2;
|
|
33314
|
-
const commit = readInjected(true ? "
|
|
33315
|
-
const commitShort = readInjected(true ? "
|
|
33316
|
-
const version2 = readInjected(true ? "1.0.28-rc.
|
|
33317
|
-
const builtAt = readInjected(true ? "2026-07-
|
|
33314
|
+
const commit = readInjected(true ? "ebb85401b79dca73fefef3c6d25259dd39a4f894" : void 0) ?? "unknown";
|
|
33315
|
+
const commitShort = readInjected(true ? "ebb85401" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
33316
|
+
const version2 = readInjected(true ? "1.0.28-rc.25" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
33317
|
+
const builtAt = readInjected(true ? "2026-07-29T12:45:19.679Z" : void 0);
|
|
33318
33318
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
33319
33319
|
return cached2;
|
|
33320
33320
|
}
|
|
@@ -36902,16 +36902,31 @@ ${error48.message || ""}`;
|
|
|
36902
36902
|
} catch {
|
|
36903
36903
|
}
|
|
36904
36904
|
}
|
|
36905
|
+
function sizeRotationPath(logFile, generation) {
|
|
36906
|
+
return logFile.replace(/\.log$/, `.${generation}.log`);
|
|
36907
|
+
}
|
|
36908
|
+
function rotateSizeGenerations(logFile, maxGenerations = MAX_SIZE_ROTATION_GENERATIONS) {
|
|
36909
|
+
if (maxGenerations < 1) return;
|
|
36910
|
+
const oldest = sizeRotationPath(logFile, maxGenerations);
|
|
36911
|
+
try {
|
|
36912
|
+
fs32.unlinkSync(oldest);
|
|
36913
|
+
} catch {
|
|
36914
|
+
}
|
|
36915
|
+
for (let generation = maxGenerations - 1; generation >= 1; generation--) {
|
|
36916
|
+
const source = sizeRotationPath(logFile, generation);
|
|
36917
|
+
const destination = sizeRotationPath(logFile, generation + 1);
|
|
36918
|
+
try {
|
|
36919
|
+
fs32.renameSync(source, destination);
|
|
36920
|
+
} catch {
|
|
36921
|
+
}
|
|
36922
|
+
}
|
|
36923
|
+
fs32.renameSync(logFile, sizeRotationPath(logFile, 1));
|
|
36924
|
+
}
|
|
36905
36925
|
function rotateSizeIfNeeded() {
|
|
36906
36926
|
try {
|
|
36907
36927
|
const stat2 = fs32.statSync(currentLogFile);
|
|
36908
36928
|
if (stat2.size > MAX_LOG_SIZE) {
|
|
36909
|
-
|
|
36910
|
-
try {
|
|
36911
|
-
fs32.unlinkSync(backup);
|
|
36912
|
-
} catch {
|
|
36913
|
-
}
|
|
36914
|
-
fs32.renameSync(currentLogFile, backup);
|
|
36929
|
+
rotateSizeGenerations(currentLogFile);
|
|
36915
36930
|
}
|
|
36916
36931
|
} catch {
|
|
36917
36932
|
}
|
|
@@ -37020,6 +37035,7 @@ ${error48.message || ""}`;
|
|
|
37020
37035
|
var LOG_DIR;
|
|
37021
37036
|
var MAX_LOG_SIZE;
|
|
37022
37037
|
var MAX_LOG_DAYS;
|
|
37038
|
+
var MAX_SIZE_ROTATION_GENERATIONS;
|
|
37023
37039
|
var currentDate;
|
|
37024
37040
|
var currentLogFile;
|
|
37025
37041
|
var writeCount;
|
|
@@ -37045,6 +37061,7 @@ ${error48.message || ""}`;
|
|
|
37045
37061
|
LOG_DIR = path9.join(ADHDEV_HOME, "logs");
|
|
37046
37062
|
MAX_LOG_SIZE = 5 * 1024 * 1024;
|
|
37047
37063
|
MAX_LOG_DAYS = 7;
|
|
37064
|
+
MAX_SIZE_ROTATION_GENERATIONS = 3;
|
|
37048
37065
|
try {
|
|
37049
37066
|
fs32.mkdirSync(LOG_DIR, { recursive: true });
|
|
37050
37067
|
} catch {
|
|
@@ -48671,6 +48688,9 @@ ${rendered}`, "utf-8");
|
|
|
48671
48688
|
state: "connected",
|
|
48672
48689
|
transport: transport && transport !== "unknown" ? transport : "direct",
|
|
48673
48690
|
reported: true,
|
|
48691
|
+
directPeerTruthSatisfied: true,
|
|
48692
|
+
authority: "live_peer",
|
|
48693
|
+
cached: false,
|
|
48674
48694
|
reason: "Live peer git snapshot reported by the selected coordinator.",
|
|
48675
48695
|
lastStateChangeAt: readStringValue(connection.lastStateChangeAt) ?? timestamp2
|
|
48676
48696
|
};
|
|
@@ -49344,6 +49364,7 @@ ${rendered}`, "utf-8");
|
|
|
49344
49364
|
const now = args.now ?? Date.now;
|
|
49345
49365
|
const connection = readObjectRecord(status.connection);
|
|
49346
49366
|
const connectionState = readStringValue(connection.state);
|
|
49367
|
+
const directPeerTruthSatisfied = readBooleanValue(connection.directPeerTruthSatisfied);
|
|
49347
49368
|
const git = readObjectRecord(status.git);
|
|
49348
49369
|
const hasGit = readBooleanValue(git.isGitRepo) === true || !!readStringValue(git.branch, git.headCommit, git.head, git.upstream);
|
|
49349
49370
|
const connectionFreshAt = toIsoTimestamp(connection.lastCommandAt ?? connection.lastConnectedAt ?? connection.lastStateChangeAt);
|
|
@@ -49365,12 +49386,12 @@ ${rendered}`, "utf-8");
|
|
|
49365
49386
|
} else if (readBooleanValue(status.gitProbePending) === true) {
|
|
49366
49387
|
dataSource = "pending";
|
|
49367
49388
|
reachable = connectionReachable;
|
|
49389
|
+
} else if (hasGit) {
|
|
49390
|
+
dataSource = "cached";
|
|
49391
|
+
reachable = directTruthUnavailable ? false : connectionReachable;
|
|
49368
49392
|
} else if (directTruthUnavailable) {
|
|
49369
49393
|
dataSource = "unreachable";
|
|
49370
49394
|
reachable = false;
|
|
49371
|
-
} else if (hasGit) {
|
|
49372
|
-
dataSource = "cached";
|
|
49373
|
-
reachable = connectionReachable;
|
|
49374
49395
|
} else if (!daemonId) {
|
|
49375
49396
|
dataSource = "unconfigured";
|
|
49376
49397
|
reachable = null;
|
|
@@ -49392,6 +49413,8 @@ ${rendered}`, "utf-8");
|
|
|
49392
49413
|
dataSource,
|
|
49393
49414
|
probeOk,
|
|
49394
49415
|
reachable,
|
|
49416
|
+
directPeerTruthSatisfied: isSelfNode || liveTruthProbed ? true : directPeerTruthSatisfied ?? false,
|
|
49417
|
+
projection: dataSource === "cached" ? "cached" : "live_or_absent",
|
|
49395
49418
|
lastProbeAt: lastProbeAt ?? null,
|
|
49396
49419
|
ageMs: ageMs2,
|
|
49397
49420
|
staleness
|
|
@@ -67877,6 +67900,7 @@ ${lastSnapshot}`;
|
|
|
67877
67900
|
MAGI_NEEDS_VERIFICATION_PREVIEW_CAP: () => MAGI_NEEDS_VERIFICATION_PREVIEW_CAP,
|
|
67878
67901
|
MAGI_RAW_ANSWER_CAP: () => MAGI_RAW_ANSWER_CAP,
|
|
67879
67902
|
MAX_LEDGER_SLICE_LIMIT: () => MAX_LEDGER_SLICE_LIMIT,
|
|
67903
|
+
MAX_SIZE_ROTATION_GENERATIONS: () => MAX_SIZE_ROTATION_GENERATIONS,
|
|
67880
67904
|
MESH_CONVERGE_FAST_FORWARD_TAG: () => MESH_CONVERGE_FAST_FORWARD_TAG,
|
|
67881
67905
|
MESH_CONVERGE_REFINE_TAG: () => MESH_CONVERGE_REFINE_TAG,
|
|
67882
67906
|
MESH_JSON_CONFIG_LOCATIONS: () => MESH_JSON_CONFIG_LOCATIONS,
|
|
@@ -69800,10 +69824,57 @@ ${lastSnapshot}`;
|
|
|
69800
69824
|
}
|
|
69801
69825
|
return String(error48 || "mesh relay command failed");
|
|
69802
69826
|
}
|
|
69827
|
+
function readStructuredFailure(error48) {
|
|
69828
|
+
if (!error48 || typeof error48 !== "object") return {};
|
|
69829
|
+
const value = error48;
|
|
69830
|
+
return {
|
|
69831
|
+
...typeof value.code === "string" ? { code: value.code } : {},
|
|
69832
|
+
...typeof value.reason === "string" ? { reason: value.reason } : {},
|
|
69833
|
+
...value.transport === "p2p" || value.transport === "unknown" ? { transport: value.transport } : {},
|
|
69834
|
+
...typeof value.recoverable === "boolean" ? { recoverable: value.recoverable } : {},
|
|
69835
|
+
...typeof value.retryRecommended === "boolean" ? { retryRecommended: value.retryRecommended } : {},
|
|
69836
|
+
...typeof value.nextAction === "string" ? { nextAction: value.nextAction } : {},
|
|
69837
|
+
...typeof value.noFallbackReason === "string" ? { noFallbackReason: value.noFallbackReason } : {},
|
|
69838
|
+
...typeof value.meshCode === "string" ? { meshCode: value.meshCode } : {},
|
|
69839
|
+
...typeof value.connectionState === "string" ? { connectionState: value.connectionState } : {},
|
|
69840
|
+
...typeof value.nextRetryAt === "string" ? { nextRetryAt: value.nextRetryAt } : {},
|
|
69841
|
+
...typeof value.authEpoch === "number" ? { authEpoch: value.authEpoch } : {}
|
|
69842
|
+
};
|
|
69843
|
+
}
|
|
69844
|
+
function reasonForCode(code) {
|
|
69845
|
+
switch (code) {
|
|
69846
|
+
case "p2p_timeout":
|
|
69847
|
+
return "daemon_mesh_p2p_timeout";
|
|
69848
|
+
case "p2p_not_connected":
|
|
69849
|
+
return "daemon_mesh_p2p_not_connected";
|
|
69850
|
+
case "p2p_datachannel_closed":
|
|
69851
|
+
return "daemon_mesh_p2p_datachannel_closed";
|
|
69852
|
+
case "p2p_no_route":
|
|
69853
|
+
return "daemon_mesh_p2p_no_route";
|
|
69854
|
+
case "p2p_daemon_offline":
|
|
69855
|
+
return "daemon_mesh_target_offline";
|
|
69856
|
+
case "p2p_unavailable":
|
|
69857
|
+
return "daemon_mesh_p2p_transport_unavailable";
|
|
69858
|
+
case "mesh_logic_or_provider_failure":
|
|
69859
|
+
return "mesh_logic_or_provider_failure";
|
|
69860
|
+
}
|
|
69861
|
+
}
|
|
69803
69862
|
function classifyP2pRelayFailure(error48, _context = {}) {
|
|
69804
69863
|
const message = messageFromError(error48);
|
|
69805
69864
|
const lower = message.toLowerCase();
|
|
69806
|
-
const
|
|
69865
|
+
const structured = readStructuredFailure(error48);
|
|
69866
|
+
if (structured.code && structured.code !== "mesh_logic_or_provider_failure" && structured.transport === "p2p") {
|
|
69867
|
+
return {
|
|
69868
|
+
code: structured.code,
|
|
69869
|
+
reason: structured.reason || reasonForCode(structured.code),
|
|
69870
|
+
transport: "p2p",
|
|
69871
|
+
recoverable: structured.recoverable ?? true,
|
|
69872
|
+
retryRecommended: structured.retryRecommended ?? true,
|
|
69873
|
+
nextAction: structured.nextAction || P2P_NEXT_ACTION,
|
|
69874
|
+
noFallbackReason: structured.noFallbackReason || NO_FALLBACK_REASON
|
|
69875
|
+
};
|
|
69876
|
+
}
|
|
69877
|
+
const hasP2pSignal = /p2p|peer|datachannel|node-datachannel|webrtc|ice|mesh_relay_command|daemon_mesh_p2p_transport/i.test(message);
|
|
69807
69878
|
const hasFailureSignal = /unavailable|missing|failed|failure|timeout|timed out|not connected|closed|disconnected|offline|no route|route unavailable|cannot send|cannot establish/i.test(message);
|
|
69808
69879
|
if (/requires targetdaemonid and command|providerpriority|no inference provider|permission denied|read-only|not a member/i.test(message)) {
|
|
69809
69880
|
return {
|
|
@@ -69830,7 +69901,7 @@ ${lastSnapshot}`;
|
|
|
69830
69901
|
} else if (/closed|disconnected/i.test(message) && (hasP2pSignal || /state changed/i.test(message))) {
|
|
69831
69902
|
code = "p2p_datachannel_closed";
|
|
69832
69903
|
reason = "daemon_mesh_p2p_datachannel_closed";
|
|
69833
|
-
} else if (/not connected|cannot send|cannot establish/i.test(message) && hasP2pSignal) {
|
|
69904
|
+
} else if (/not connected|cannot send|cannot establish|probe gave up/i.test(message) && hasP2pSignal) {
|
|
69834
69905
|
code = "p2p_not_connected";
|
|
69835
69906
|
reason = "daemon_mesh_p2p_not_connected";
|
|
69836
69907
|
} else if (hasP2pSignal && hasFailureSignal) {
|
|
@@ -69863,12 +69934,17 @@ ${lastSnapshot}`;
|
|
|
69863
69934
|
}
|
|
69864
69935
|
function buildP2pRelayFailurePayload(error48, context = {}) {
|
|
69865
69936
|
const classification = classifyP2pRelayFailure(error48, context);
|
|
69937
|
+
const structured = readStructuredFailure(error48);
|
|
69866
69938
|
return {
|
|
69867
69939
|
success: false,
|
|
69868
69940
|
...classification,
|
|
69869
69941
|
error: messageFromError(error48),
|
|
69870
69942
|
...context.command ? { command: context.command } : {},
|
|
69871
|
-
...context.targetDaemonId ? { targetDaemonId: context.targetDaemonId } : {}
|
|
69943
|
+
...context.targetDaemonId ? { targetDaemonId: context.targetDaemonId } : {},
|
|
69944
|
+
...context.meshCode || structured.meshCode ? { meshCode: context.meshCode || structured.meshCode } : {},
|
|
69945
|
+
...context.connectionState || structured.connectionState ? { connectionState: context.connectionState || structured.connectionState } : {},
|
|
69946
|
+
...context.nextRetryAt || structured.nextRetryAt ? { nextRetryAt: context.nextRetryAt || structured.nextRetryAt } : {},
|
|
69947
|
+
...(context.authEpoch ?? structured.authEpoch) !== void 0 ? { authEpoch: context.authEpoch ?? structured.authEpoch } : {}
|
|
69872
69948
|
};
|
|
69873
69949
|
}
|
|
69874
69950
|
var P2pRelayFailureError = class extends Error {
|
|
@@ -69881,19 +69957,37 @@ ${lastSnapshot}`;
|
|
|
69881
69957
|
noFallbackReason;
|
|
69882
69958
|
command;
|
|
69883
69959
|
targetDaemonId;
|
|
69960
|
+
meshCode;
|
|
69961
|
+
connectionState;
|
|
69962
|
+
nextRetryAt;
|
|
69963
|
+
authEpoch;
|
|
69884
69964
|
constructor(message, context = {}) {
|
|
69885
69965
|
super(message);
|
|
69886
69966
|
this.name = "P2pRelayFailureError";
|
|
69887
|
-
const payload = buildP2pRelayFailurePayload(
|
|
69888
|
-
|
|
69967
|
+
const payload = buildP2pRelayFailurePayload({
|
|
69968
|
+
message,
|
|
69969
|
+
...context.code ? { code: context.code } : {},
|
|
69970
|
+
...context.recoverable !== void 0 ? { recoverable: context.recoverable } : {},
|
|
69971
|
+
...context.retryRecommended !== void 0 ? { retryRecommended: context.retryRecommended } : {},
|
|
69972
|
+
transport: context.code ? "p2p" : void 0,
|
|
69973
|
+
meshCode: context.meshCode,
|
|
69974
|
+
connectionState: context.connectionState,
|
|
69975
|
+
nextRetryAt: context.nextRetryAt,
|
|
69976
|
+
authEpoch: context.authEpoch
|
|
69977
|
+
}, context);
|
|
69978
|
+
this.code = context.code ?? payload.code;
|
|
69889
69979
|
this.reason = payload.reason;
|
|
69890
69980
|
this.transport = payload.transport;
|
|
69891
|
-
this.recoverable = payload.recoverable;
|
|
69892
|
-
this.retryRecommended = payload.retryRecommended;
|
|
69981
|
+
this.recoverable = context.recoverable ?? payload.recoverable;
|
|
69982
|
+
this.retryRecommended = context.retryRecommended ?? payload.retryRecommended;
|
|
69893
69983
|
this.nextAction = payload.nextAction;
|
|
69894
69984
|
this.noFallbackReason = payload.noFallbackReason;
|
|
69895
69985
|
this.command = context.command;
|
|
69896
69986
|
this.targetDaemonId = context.targetDaemonId;
|
|
69987
|
+
this.meshCode = context.meshCode;
|
|
69988
|
+
this.connectionState = context.connectionState;
|
|
69989
|
+
this.nextRetryAt = context.nextRetryAt;
|
|
69990
|
+
this.authEpoch = context.authEpoch;
|
|
69897
69991
|
}
|
|
69898
69992
|
};
|
|
69899
69993
|
init_state_store();
|
|
@@ -81195,6 +81289,12 @@ ${body}
|
|
|
81195
81289
|
}
|
|
81196
81290
|
return getCurrentDaemonLogPath();
|
|
81197
81291
|
}
|
|
81292
|
+
function sizeRotationPaths(primaryPath) {
|
|
81293
|
+
return Array.from(
|
|
81294
|
+
{ length: MAX_SIZE_ROTATION_GENERATIONS },
|
|
81295
|
+
(_, index) => primaryPath.replace(/\.log$/, `.${index + 1}.log`)
|
|
81296
|
+
);
|
|
81297
|
+
}
|
|
81198
81298
|
function clampTailBytes(tailBytes) {
|
|
81199
81299
|
if (!Number.isFinite(tailBytes) || tailBytes <= 0) return DEFAULT_TAIL_BYTES;
|
|
81200
81300
|
return Math.min(Math.floor(tailBytes), MAX_TAIL_BYTES);
|
|
@@ -81303,17 +81403,17 @@ ${body}
|
|
|
81303
81403
|
const platform10 = process.platform;
|
|
81304
81404
|
const limitBytes = clampTailBytes(args.tailBytes);
|
|
81305
81405
|
const primaryPath = resolveLogPath(args.date);
|
|
81306
|
-
const
|
|
81406
|
+
const backupPaths = sizeRotationPaths(primaryPath);
|
|
81307
81407
|
const primaryExists = fs16.existsSync(primaryPath);
|
|
81308
|
-
const
|
|
81309
|
-
if (!primaryExists &&
|
|
81408
|
+
const existingBackupPaths = backupPaths.filter((backupPath) => fs16.existsSync(backupPath));
|
|
81409
|
+
if (!primaryExists && existingBackupPaths.length === 0) {
|
|
81310
81410
|
return errorResult(
|
|
81311
81411
|
`No daemon log file at ${primaryPath} (dir: ${getDaemonLogDir()})`,
|
|
81312
81412
|
primaryPath,
|
|
81313
81413
|
platform10
|
|
81314
81414
|
);
|
|
81315
81415
|
}
|
|
81316
|
-
const logPath = primaryExists ? primaryPath :
|
|
81416
|
+
const logPath = primaryExists ? primaryPath : existingBackupPaths[0];
|
|
81317
81417
|
const hasGrep = typeof args.grep === "string" && args.grep.trim().length > 0;
|
|
81318
81418
|
const hasSince = Number.isFinite(args.sinceMs);
|
|
81319
81419
|
const filterMode = hasGrep || hasSince;
|
|
@@ -81342,7 +81442,7 @@ ${body}
|
|
|
81342
81442
|
let scannedBytes = 0;
|
|
81343
81443
|
let allLines = [];
|
|
81344
81444
|
try {
|
|
81345
|
-
for (const p of [
|
|
81445
|
+
for (const p of [...existingBackupPaths].reverse().concat(primaryExists ? [primaryPath] : [])) {
|
|
81346
81446
|
if (!p) continue;
|
|
81347
81447
|
const buf = fs16.readFileSync(p);
|
|
81348
81448
|
scannedBytes += buf.length;
|
|
@@ -101132,6 +101232,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
101132
101232
|
finalizeMeshNodeStatus({ status: fallback, node, daemonId, isSelfNode: false, directTruthUnavailable: directTruthUnavailableNodeIds.has(nodeId) });
|
|
101133
101233
|
return fallback;
|
|
101134
101234
|
});
|
|
101235
|
+
const cachedProjectionNodeIds = nodeStatuses.filter((status) => status?.dataFreshness?.projection === "cached" && status?.dataFreshness?.directPeerTruthSatisfied === false).map((status) => readStringValue(status?.nodeId)).filter(Boolean);
|
|
101135
101236
|
const callerCoordinatorDaemonId = typeof args?.coordinatorDaemonId === "string" && args.coordinatorDaemonId.trim() ? args.coordinatorDaemonId.trim() : ctx.deps.statusInstanceId || void 0;
|
|
101136
101237
|
const pendingCoordinatorEvents = getPendingMeshCoordinatorEvents(meshId, callerCoordinatorDaemonId);
|
|
101137
101238
|
const unroutableDeliveries = getRecentUnroutableDeliveries();
|
|
@@ -101192,7 +101293,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
101192
101293
|
peerAttemptedCount: effectiveDirectTruth.peerAttemptedCount,
|
|
101193
101294
|
peerConfirmedCount: effectiveDirectTruth.peerConfirmedCount,
|
|
101194
101295
|
unavailableNodeIds: effectiveDirectTruth.unavailableNodeIds,
|
|
101195
|
-
partialNodeFailures: effectiveDirectTruth.unavailableNodeIds
|
|
101296
|
+
partialNodeFailures: effectiveDirectTruth.unavailableNodeIds,
|
|
101297
|
+
cachedProjectionNodeIds
|
|
101196
101298
|
}
|
|
101197
101299
|
} : {},
|
|
101198
101300
|
historicalEvidenceOnly: ["recoveryHints", "ledger.summary", "queue.summary", "historicalSessions"]
|