@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.mjs
CHANGED
|
@@ -394,10 +394,10 @@ function readInjected(value) {
|
|
|
394
394
|
}
|
|
395
395
|
function getDaemonBuildInfo() {
|
|
396
396
|
if (cached) return cached;
|
|
397
|
-
const commit = readInjected(true ? "
|
|
398
|
-
const commitShort = readInjected(true ? "
|
|
399
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
400
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
397
|
+
const commit = readInjected(true ? "bfd7d9b1d38a7d1f4709fbad2627c56b5a1ae342" : void 0) ?? "unknown";
|
|
398
|
+
const commitShort = readInjected(true ? "bfd7d9b1" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
399
|
+
const version = readInjected(true ? "0.9.82-rc.407" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
400
|
+
const builtAt = readInjected(true ? "2026-06-28T06:12:15.473Z" : void 0);
|
|
401
401
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
402
402
|
return cached;
|
|
403
403
|
}
|
|
@@ -16366,6 +16366,20 @@ function resolveReconcileIntervalMs() {
|
|
|
16366
16366
|
}
|
|
16367
16367
|
return DEFAULT_RECONCILE_INTERVAL_MS;
|
|
16368
16368
|
}
|
|
16369
|
+
function resolveTunedReconcileMs(envName, def, min, max) {
|
|
16370
|
+
const raw = readNonEmptyString2(process.env[envName]);
|
|
16371
|
+
if (raw) {
|
|
16372
|
+
const parsed = Number.parseInt(raw, 10);
|
|
16373
|
+
if (Number.isFinite(parsed) && parsed >= min && parsed <= max) return parsed;
|
|
16374
|
+
}
|
|
16375
|
+
return def;
|
|
16376
|
+
}
|
|
16377
|
+
function resolveMinIdleSettleMs() {
|
|
16378
|
+
return resolveTunedReconcileMs("MESH_INFLIGHT_MIN_IDLE_SETTLE_MS", 16e3, 0, 12e4);
|
|
16379
|
+
}
|
|
16380
|
+
function resolveAckedTurnSettleMs() {
|
|
16381
|
+
return resolveTunedReconcileMs("MESH_INFLIGHT_ACKED_TURN_SETTLE_MS", 2e4, 0, 18e4);
|
|
16382
|
+
}
|
|
16369
16383
|
function inFlightSynthKey(meshId, taskId) {
|
|
16370
16384
|
return `${meshId}::${taskId}`;
|
|
16371
16385
|
}
|
|
@@ -16942,6 +16956,33 @@ function unwrapReadChatPayload(raw) {
|
|
|
16942
16956
|
function readChatPayloadStatus(payload) {
|
|
16943
16957
|
return readNonEmptyString2(payload?.status).toLowerCase();
|
|
16944
16958
|
}
|
|
16959
|
+
function realTerminalEmitPendingForTask(meshId, taskId) {
|
|
16960
|
+
let pending;
|
|
16961
|
+
try {
|
|
16962
|
+
pending = getPendingMeshCoordinatorEvents(meshId);
|
|
16963
|
+
} catch {
|
|
16964
|
+
return false;
|
|
16965
|
+
}
|
|
16966
|
+
return pending.some((e) => readNonEmptyString2(e.metadataEvent?.taskId) === taskId && (e.event === "agent:generating_completed" || e.event === "agent:stopped"));
|
|
16967
|
+
}
|
|
16968
|
+
async function reprobeWorkerStatus(components, args) {
|
|
16969
|
+
try {
|
|
16970
|
+
if (args.isLocalNode) {
|
|
16971
|
+
const r = await components.commandHandler.handle("read_chat", args.readArgs);
|
|
16972
|
+
if (r && r.success === false) return null;
|
|
16973
|
+
return readChatPayloadStatus(unwrapReadChatPayload(r));
|
|
16974
|
+
}
|
|
16975
|
+
if (components.dispatchMeshCommand) {
|
|
16976
|
+
const r = await components.dispatchMeshCommand(args.nodeDaemonId, "read_chat", args.readArgs);
|
|
16977
|
+
const p = unwrapReadChatPayload(r);
|
|
16978
|
+
if (p && p.success === false) return null;
|
|
16979
|
+
return readChatPayloadStatus(p);
|
|
16980
|
+
}
|
|
16981
|
+
} catch {
|
|
16982
|
+
return null;
|
|
16983
|
+
}
|
|
16984
|
+
return null;
|
|
16985
|
+
}
|
|
16945
16986
|
async function reconcileUnterminatedDirectDispatches(components, mesh, selfIds, localDaemonId) {
|
|
16946
16987
|
const dispatches = getActiveDirectDispatches(mesh.id);
|
|
16947
16988
|
if (dispatches.length === 0) return;
|
|
@@ -16989,18 +17030,34 @@ async function reconcileUnterminatedDirectDispatches(components, mesh, selfIds,
|
|
|
16989
17030
|
}
|
|
16990
17031
|
if (!payload) continue;
|
|
16991
17032
|
const synthKey = inFlightSynthKey(mesh.id, taskId);
|
|
17033
|
+
const nowMs = Date.now();
|
|
16992
17034
|
if (readChatPayloadStatus(payload) !== "idle") {
|
|
16993
17035
|
inFlightIdleObservationCounts.delete(synthKey);
|
|
16994
17036
|
continue;
|
|
16995
17037
|
}
|
|
16996
17038
|
if (dispatch.status === "acked") {
|
|
16997
|
-
const
|
|
16998
|
-
|
|
16999
|
-
|
|
17000
|
-
|
|
17039
|
+
const prior = inFlightIdleObservationCounts.get(synthKey);
|
|
17040
|
+
const firstIdleAtMs = prior?.firstIdleAtMs ?? nowMs;
|
|
17041
|
+
const idleStreak = (prior?.count ?? 0) + 1;
|
|
17042
|
+
inFlightIdleObservationCounts.set(synthKey, { count: idleStreak, firstIdleAtMs });
|
|
17043
|
+
const idleSettleMs = nowMs - firstIdleAtMs;
|
|
17044
|
+
const minIdleSettleMs = resolveMinIdleSettleMs();
|
|
17045
|
+
const ackedTurnSettleMs = resolveAckedTurnSettleMs();
|
|
17046
|
+
const ackedAtMs = Date.parse(readNonEmptyString2(dispatch.updatedAt));
|
|
17047
|
+
const sinceAckMs = Number.isFinite(ackedAtMs) ? nowMs - ackedAtMs : Number.POSITIVE_INFINITY;
|
|
17048
|
+
const tickGuardMet = idleStreak >= REQUIRED_CONSECUTIVE_IDLE_TICKS_FOR_INFLIGHT_SYNTH;
|
|
17049
|
+
const settleGuardMet = idleSettleMs >= minIdleSettleMs;
|
|
17050
|
+
const ackGuardMet = sinceAckMs >= ackedTurnSettleMs;
|
|
17051
|
+
if (!tickGuardMet || !settleGuardMet || !ackGuardMet) {
|
|
17052
|
+
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)`);
|
|
17001
17053
|
continue;
|
|
17002
17054
|
}
|
|
17003
17055
|
}
|
|
17056
|
+
if (realTerminalEmitPendingForTask(mesh.id, taskId)) {
|
|
17057
|
+
inFlightIdleObservationCounts.delete(synthKey);
|
|
17058
|
+
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`);
|
|
17059
|
+
continue;
|
|
17060
|
+
}
|
|
17004
17061
|
const messages = Array.isArray(payload.messages) ? payload.messages : [];
|
|
17005
17062
|
const evidence = extractFinalAssistantSummaryEvidence(messages);
|
|
17006
17063
|
if (!evidence.finalSummary) continue;
|
|
@@ -17017,6 +17074,12 @@ async function reconcileUnterminatedDirectDispatches(components, mesh, selfIds,
|
|
|
17017
17074
|
}, `transcriptAt=${evidence.transcriptMessageAt} < dispatchedAt=${dispatch.dispatchedAt}`);
|
|
17018
17075
|
continue;
|
|
17019
17076
|
}
|
|
17077
|
+
const reprobeStatus = await reprobeWorkerStatus(components, { isLocalNode, nodeDaemonId, readArgs });
|
|
17078
|
+
if (reprobeStatus && reprobeStatus !== "idle") {
|
|
17079
|
+
inFlightIdleObservationCounts.delete(synthKey);
|
|
17080
|
+
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`);
|
|
17081
|
+
continue;
|
|
17082
|
+
}
|
|
17020
17083
|
const providerSessionId = readNonEmptyString2(payload.providerSessionId);
|
|
17021
17084
|
const coordinatorDaemonId = selfIds.find((id) => !!id);
|
|
17022
17085
|
try {
|