@adhdev/daemon-core 0.9.82-rc.406 → 0.9.82-rc.407
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 +71 -8
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +71 -8
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/mesh/mesh-reconcile-loop.ts +129 -14
package/dist/index.js
CHANGED
|
@@ -399,10 +399,10 @@ function readInjected(value) {
|
|
|
399
399
|
}
|
|
400
400
|
function getDaemonBuildInfo() {
|
|
401
401
|
if (cached) return cached;
|
|
402
|
-
const commit = readInjected(true ? "
|
|
403
|
-
const commitShort = readInjected(true ? "
|
|
404
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
405
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
402
|
+
const commit = readInjected(true ? "bfd7d9b1d38a7d1f4709fbad2627c56b5a1ae342" : void 0) ?? "unknown";
|
|
403
|
+
const commitShort = readInjected(true ? "bfd7d9b1" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
404
|
+
const version = readInjected(true ? "0.9.82-rc.407" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
405
|
+
const builtAt = readInjected(true ? "2026-06-28T06:12:15.473Z" : void 0);
|
|
406
406
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
407
407
|
return cached;
|
|
408
408
|
}
|
|
@@ -16371,6 +16371,20 @@ function resolveReconcileIntervalMs() {
|
|
|
16371
16371
|
}
|
|
16372
16372
|
return DEFAULT_RECONCILE_INTERVAL_MS;
|
|
16373
16373
|
}
|
|
16374
|
+
function resolveTunedReconcileMs(envName, def, min, max) {
|
|
16375
|
+
const raw = readNonEmptyString2(process.env[envName]);
|
|
16376
|
+
if (raw) {
|
|
16377
|
+
const parsed = Number.parseInt(raw, 10);
|
|
16378
|
+
if (Number.isFinite(parsed) && parsed >= min && parsed <= max) return parsed;
|
|
16379
|
+
}
|
|
16380
|
+
return def;
|
|
16381
|
+
}
|
|
16382
|
+
function resolveMinIdleSettleMs() {
|
|
16383
|
+
return resolveTunedReconcileMs("MESH_INFLIGHT_MIN_IDLE_SETTLE_MS", 16e3, 0, 12e4);
|
|
16384
|
+
}
|
|
16385
|
+
function resolveAckedTurnSettleMs() {
|
|
16386
|
+
return resolveTunedReconcileMs("MESH_INFLIGHT_ACKED_TURN_SETTLE_MS", 2e4, 0, 18e4);
|
|
16387
|
+
}
|
|
16374
16388
|
function inFlightSynthKey(meshId, taskId) {
|
|
16375
16389
|
return `${meshId}::${taskId}`;
|
|
16376
16390
|
}
|
|
@@ -16947,6 +16961,33 @@ function unwrapReadChatPayload(raw) {
|
|
|
16947
16961
|
function readChatPayloadStatus(payload) {
|
|
16948
16962
|
return readNonEmptyString2(payload?.status).toLowerCase();
|
|
16949
16963
|
}
|
|
16964
|
+
function realTerminalEmitPendingForTask(meshId, taskId) {
|
|
16965
|
+
let pending;
|
|
16966
|
+
try {
|
|
16967
|
+
pending = getPendingMeshCoordinatorEvents(meshId);
|
|
16968
|
+
} catch {
|
|
16969
|
+
return false;
|
|
16970
|
+
}
|
|
16971
|
+
return pending.some((e) => readNonEmptyString2(e.metadataEvent?.taskId) === taskId && (e.event === "agent:generating_completed" || e.event === "agent:stopped"));
|
|
16972
|
+
}
|
|
16973
|
+
async function reprobeWorkerStatus(components, args) {
|
|
16974
|
+
try {
|
|
16975
|
+
if (args.isLocalNode) {
|
|
16976
|
+
const r = await components.commandHandler.handle("read_chat", args.readArgs);
|
|
16977
|
+
if (r && r.success === false) return null;
|
|
16978
|
+
return readChatPayloadStatus(unwrapReadChatPayload(r));
|
|
16979
|
+
}
|
|
16980
|
+
if (components.dispatchMeshCommand) {
|
|
16981
|
+
const r = await components.dispatchMeshCommand(args.nodeDaemonId, "read_chat", args.readArgs);
|
|
16982
|
+
const p = unwrapReadChatPayload(r);
|
|
16983
|
+
if (p && p.success === false) return null;
|
|
16984
|
+
return readChatPayloadStatus(p);
|
|
16985
|
+
}
|
|
16986
|
+
} catch {
|
|
16987
|
+
return null;
|
|
16988
|
+
}
|
|
16989
|
+
return null;
|
|
16990
|
+
}
|
|
16950
16991
|
async function reconcileUnterminatedDirectDispatches(components, mesh, selfIds, localDaemonId) {
|
|
16951
16992
|
const dispatches = getActiveDirectDispatches(mesh.id);
|
|
16952
16993
|
if (dispatches.length === 0) return;
|
|
@@ -16994,18 +17035,34 @@ async function reconcileUnterminatedDirectDispatches(components, mesh, selfIds,
|
|
|
16994
17035
|
}
|
|
16995
17036
|
if (!payload) continue;
|
|
16996
17037
|
const synthKey = inFlightSynthKey(mesh.id, taskId);
|
|
17038
|
+
const nowMs = Date.now();
|
|
16997
17039
|
if (readChatPayloadStatus(payload) !== "idle") {
|
|
16998
17040
|
inFlightIdleObservationCounts.delete(synthKey);
|
|
16999
17041
|
continue;
|
|
17000
17042
|
}
|
|
17001
17043
|
if (dispatch.status === "acked") {
|
|
17002
|
-
const
|
|
17003
|
-
|
|
17004
|
-
|
|
17005
|
-
|
|
17044
|
+
const prior = inFlightIdleObservationCounts.get(synthKey);
|
|
17045
|
+
const firstIdleAtMs = prior?.firstIdleAtMs ?? nowMs;
|
|
17046
|
+
const idleStreak = (prior?.count ?? 0) + 1;
|
|
17047
|
+
inFlightIdleObservationCounts.set(synthKey, { count: idleStreak, firstIdleAtMs });
|
|
17048
|
+
const idleSettleMs = nowMs - firstIdleAtMs;
|
|
17049
|
+
const minIdleSettleMs = resolveMinIdleSettleMs();
|
|
17050
|
+
const ackedTurnSettleMs = resolveAckedTurnSettleMs();
|
|
17051
|
+
const ackedAtMs = Date.parse(readNonEmptyString2(dispatch.updatedAt));
|
|
17052
|
+
const sinceAckMs = Number.isFinite(ackedAtMs) ? nowMs - ackedAtMs : Number.POSITIVE_INFINITY;
|
|
17053
|
+
const tickGuardMet = idleStreak >= REQUIRED_CONSECUTIVE_IDLE_TICKS_FOR_INFLIGHT_SYNTH;
|
|
17054
|
+
const settleGuardMet = idleSettleMs >= minIdleSettleMs;
|
|
17055
|
+
const ackGuardMet = sinceAckMs >= ackedTurnSettleMs;
|
|
17056
|
+
if (!tickGuardMet || !settleGuardMet || !ackGuardMet) {
|
|
17057
|
+
LOG.info("MeshReconcile", `In-flight synth hold: task ${taskId} on node ${nodeId} (mesh ${mesh.id}) idle ${idleStreak}/${REQUIRED_CONSECUTIVE_IDLE_TICKS_FOR_INFLIGHT_SYNTH} tick(s), settle ${Math.round(idleSettleMs / 1e3)}s/${Math.round(minIdleSettleMs / 1e3)}s, since-ack ${Number.isFinite(sinceAckMs) ? Math.round(sinceAckMs / 1e3) + "s" : "\u221E"}/${Math.round(ackedTurnSettleMs / 1e3)}s \u2014 deferring completion synth until the worker's turn genuinely settles (guards against a mid-turn idle window pre-empting the real completion)`);
|
|
17006
17058
|
continue;
|
|
17007
17059
|
}
|
|
17008
17060
|
}
|
|
17061
|
+
if (realTerminalEmitPendingForTask(mesh.id, taskId)) {
|
|
17062
|
+
inFlightIdleObservationCounts.delete(synthKey);
|
|
17063
|
+
LOG.info("MeshReconcile", `Worker-emit priority: task ${taskId} on node ${nodeId} (mesh ${mesh.id}) has a real terminal completion already queued \u2014 yielding synth to the worker's own emit`);
|
|
17064
|
+
continue;
|
|
17065
|
+
}
|
|
17009
17066
|
const messages = Array.isArray(payload.messages) ? payload.messages : [];
|
|
17010
17067
|
const evidence = extractFinalAssistantSummaryEvidence(messages);
|
|
17011
17068
|
if (!evidence.finalSummary) continue;
|
|
@@ -17022,6 +17079,12 @@ async function reconcileUnterminatedDirectDispatches(components, mesh, selfIds,
|
|
|
17022
17079
|
}, `transcriptAt=${evidence.transcriptMessageAt} < dispatchedAt=${dispatch.dispatchedAt}`);
|
|
17023
17080
|
continue;
|
|
17024
17081
|
}
|
|
17082
|
+
const reprobeStatus = await reprobeWorkerStatus(components, { isLocalNode, nodeDaemonId, readArgs });
|
|
17083
|
+
if (reprobeStatus && reprobeStatus !== "idle") {
|
|
17084
|
+
inFlightIdleObservationCounts.delete(synthKey);
|
|
17085
|
+
LOG.info("MeshReconcile", `Live re-probe defer: task ${taskId} on node ${nodeId} (mesh ${mesh.id}) read '${reprobeStatus}' at synth-commit time \u2014 worker resumed generating; deferring synth to a later tick`);
|
|
17086
|
+
continue;
|
|
17087
|
+
}
|
|
17025
17088
|
const providerSessionId = readNonEmptyString2(payload.providerSessionId);
|
|
17026
17089
|
const coordinatorDaemonId = selfIds.find((id) => !!id);
|
|
17027
17090
|
try {
|