@adhdev/daemon-core 0.9.82-rc.373 → 0.9.82-rc.374
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 +67 -13
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +67 -13
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-events-stale.d.ts +12 -0
- package/dist/providers/chat-message-normalization.d.ts +1 -1
- package/package.json +2 -2
- package/src/commands/med-family/mesh-crud.ts +12 -2
- package/src/mesh/mesh-events-coordinator.ts +19 -0
- package/src/mesh/mesh-events-stale.ts +23 -0
- package/src/mesh/mesh-events-utils.ts +1 -1
- package/src/mesh/mesh-reconcile-loop.ts +31 -9
- package/src/providers/chat-message-normalization.ts +1 -1
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 ? "47e042dcb10c9ca07c30ac4bf8e0d5a4153a63c6" : void 0) ?? "unknown";
|
|
320
|
+
const commitShort = readInjected(true ? "47e042dc" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
321
|
+
const version = readInjected(true ? "0.9.82-rc.374" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
322
|
+
const builtAt = readInjected(true ? "2026-06-25T00:33:05.038Z" : void 0);
|
|
323
323
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
324
324
|
return cached;
|
|
325
325
|
}
|
|
@@ -8749,7 +8749,7 @@ var init_mesh_events_utils = __esm({
|
|
|
8749
8749
|
"src/mesh/mesh-events-utils.ts"() {
|
|
8750
8750
|
"use strict";
|
|
8751
8751
|
MESH_SURFACED_PREVIEW_MAX_CHARS = 512;
|
|
8752
|
-
MESH_COMPLETION_SURFACE_MAX_CHARS =
|
|
8752
|
+
MESH_COMPLETION_SURFACE_MAX_CHARS = 16e3;
|
|
8753
8753
|
}
|
|
8754
8754
|
});
|
|
8755
8755
|
|
|
@@ -9389,6 +9389,22 @@ function isWeakCompletionLedgerPayload(payload) {
|
|
|
9389
9389
|
const diag = readRecord4(payload.completionDiagnostic);
|
|
9390
9390
|
return diag?.finalAssistantPresent === false || diag?.blockReason === "missing_final_assistant";
|
|
9391
9391
|
}
|
|
9392
|
+
function findTerminalLedgerEvidenceForTask(args) {
|
|
9393
|
+
const taskId = readNonEmptyString2(args.taskId);
|
|
9394
|
+
if (!taskId) return null;
|
|
9395
|
+
const entries = readLedgerEntries(args.meshId, { tail: args.tail ?? 500 });
|
|
9396
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
9397
|
+
const entry = entries[i];
|
|
9398
|
+
if (entry.kind !== "task_completed" && entry.kind !== "task_failed" && entry.kind !== "task_stalled") continue;
|
|
9399
|
+
const terminalTaskId = readNonEmptyString2(entry.payload?.taskId);
|
|
9400
|
+
if (terminalTaskId !== taskId) continue;
|
|
9401
|
+
if (entry.kind === "task_completed" && isWeakCompletionLedgerPayload(entry.payload)) continue;
|
|
9402
|
+
if (args.sessionId && entry.sessionId && entry.sessionId !== args.sessionId) continue;
|
|
9403
|
+
if (!args.sessionId && args.nodeId && entry.nodeId && !meshNodeIdMatches(entry, args.nodeId)) continue;
|
|
9404
|
+
return { id: entry.id, kind: entry.kind, payload: entry.payload || {}, timestamp: entry.timestamp };
|
|
9405
|
+
}
|
|
9406
|
+
return null;
|
|
9407
|
+
}
|
|
9392
9408
|
function findDirectDispatchLedgerEntry(args) {
|
|
9393
9409
|
const entries = readLedgerEntries(args.meshId, { tail: 500 });
|
|
9394
9410
|
for (let i = entries.length - 1; i >= 0; i--) {
|
|
@@ -11517,7 +11533,7 @@ var init_chat_message_normalization = __esm({
|
|
|
11517
11533
|
"src/providers/chat-message-normalization.ts"() {
|
|
11518
11534
|
"use strict";
|
|
11519
11535
|
init_contracts();
|
|
11520
|
-
DEFAULT_FINAL_SUMMARY_MAX_CHARS =
|
|
11536
|
+
DEFAULT_FINAL_SUMMARY_MAX_CHARS = 16e3;
|
|
11521
11537
|
BUILTIN_CHAT_MESSAGE_KINDS = ["standard", "thought", "tool", "terminal", "system"];
|
|
11522
11538
|
CHAT_MESSAGE_VISIBILITIES = ["user", "debug", "internal", "hidden"];
|
|
11523
11539
|
CHAT_MESSAGE_TRANSCRIPT_VISIBILITIES = ["visible", "chat", "user", "debug", "internal", "hidden"];
|
|
@@ -13033,6 +13049,23 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
|
|
|
13033
13049
|
if (!task) {
|
|
13034
13050
|
return false;
|
|
13035
13051
|
}
|
|
13052
|
+
const terminal = findTerminalLedgerEvidenceForTask({
|
|
13053
|
+
meshId,
|
|
13054
|
+
taskId: task.id
|
|
13055
|
+
});
|
|
13056
|
+
if (terminal) {
|
|
13057
|
+
const status = terminal.kind === "task_completed" ? "completed" : "failed";
|
|
13058
|
+
updateTaskStatus(meshId, task.id, status);
|
|
13059
|
+
LOG.info("MeshQueue", `Skipped dispatch for terminal task ${task.id} on mesh ${meshId}; ${terminal.kind} ledger evidence already exists`);
|
|
13060
|
+
traceMeshEventDrop("dispatch_terminal_ledger", {
|
|
13061
|
+
taskId: task.id,
|
|
13062
|
+
sessionId,
|
|
13063
|
+
nodeId,
|
|
13064
|
+
meshId,
|
|
13065
|
+
event: "agent_command"
|
|
13066
|
+
}, terminal.kind);
|
|
13067
|
+
return false;
|
|
13068
|
+
}
|
|
13036
13069
|
LOG.info("MeshQueue", `Node ${nodeId} (${sessionId}) pulled task ${task.id}`);
|
|
13037
13070
|
if (node?.daemonId && components.dispatchMeshCommand) {
|
|
13038
13071
|
const isLocalNode = components.cliManager.adapters.has(sessionId);
|
|
@@ -14570,20 +14603,24 @@ function daemonHostsMesh(mesh, daemonIds) {
|
|
|
14570
14603
|
if (host.role && host.role !== "host") return false;
|
|
14571
14604
|
const hostDaemonId = readNonEmptyString2(host.hostDaemonId);
|
|
14572
14605
|
if (!hostDaemonId) return true;
|
|
14573
|
-
return daemonIds
|
|
14606
|
+
return daemonIdListIncludes(daemonIds, hostDaemonId);
|
|
14607
|
+
}
|
|
14608
|
+
function daemonIdListIncludes(ids, id) {
|
|
14609
|
+
if (!id) return false;
|
|
14610
|
+
return ids.some((candidate) => candidate === id || daemonIdsEquivalent(candidate, id));
|
|
14574
14611
|
}
|
|
14575
14612
|
function resolveCoordinatorSelfIds(mesh, drainDaemonIds) {
|
|
14576
14613
|
const ids = new Set(drainDaemonIds);
|
|
14577
14614
|
for (const node of mesh.nodes) {
|
|
14578
14615
|
const nodeDaemonId = readNonEmptyString2(node.daemonId);
|
|
14579
14616
|
const nodeMachineId = readNonEmptyString2(node.machineId);
|
|
14580
|
-
const isSelf = nodeDaemonId && drainDaemonIds
|
|
14617
|
+
const isSelf = nodeDaemonId && daemonIdListIncludes(drainDaemonIds, nodeDaemonId) || nodeMachineId && daemonIdListIncludes(drainDaemonIds, nodeMachineId);
|
|
14581
14618
|
if (!isSelf) continue;
|
|
14582
14619
|
if (nodeDaemonId) ids.add(nodeDaemonId);
|
|
14583
14620
|
if (nodeMachineId) ids.add(nodeMachineId);
|
|
14584
14621
|
}
|
|
14585
14622
|
const hostDaemonId = readNonEmptyString2(mesh.meshHost?.hostDaemonId);
|
|
14586
|
-
if (hostDaemonId && ids
|
|
14623
|
+
if (hostDaemonId && daemonIdListIncludes([...ids], hostDaemonId)) ids.add(hostDaemonId);
|
|
14587
14624
|
return [...ids];
|
|
14588
14625
|
}
|
|
14589
14626
|
function findLiveCoordinators(components) {
|
|
@@ -14661,6 +14698,23 @@ function recoverStrandedAssignedDispatches(meshId, store) {
|
|
|
14661
14698
|
const dispatchedAtMs = Date.parse(row.dispatchTimestamp ?? "");
|
|
14662
14699
|
if (!Number.isFinite(dispatchedAtMs)) continue;
|
|
14663
14700
|
if (nowMs - dispatchedAtMs < ASSIGNED_STRANDED_DEADLINE_MS) continue;
|
|
14701
|
+
const terminal = findTerminalLedgerEvidenceForTask({
|
|
14702
|
+
meshId,
|
|
14703
|
+
taskId: row.id
|
|
14704
|
+
});
|
|
14705
|
+
if (terminal) {
|
|
14706
|
+
const status = terminal.kind === "task_completed" ? "completed" : "failed";
|
|
14707
|
+
updateTaskStatus(meshId, row.id, status);
|
|
14708
|
+
LOG.warn("MeshReconcile", `Skipped stranded reclaim redispatch for terminal task ${row.id} on mesh ${meshId}; ${terminal.kind} ledger evidence already exists`);
|
|
14709
|
+
traceMeshEventDrop("assigned_stranded_terminal_ledger", {
|
|
14710
|
+
taskId: row.id,
|
|
14711
|
+
sessionId: row.assignedSessionId,
|
|
14712
|
+
nodeId: row.assignedNodeId,
|
|
14713
|
+
meshId,
|
|
14714
|
+
event: "agent:generating_completed"
|
|
14715
|
+
}, terminal.kind);
|
|
14716
|
+
continue;
|
|
14717
|
+
}
|
|
14664
14718
|
if (store.taskHasConfirmedDelivery(meshId, row.id)) continue;
|
|
14665
14719
|
const reclaimed = reclaimStrandedAssignedTask(meshId, row.id, {
|
|
14666
14720
|
reason: "assigned_stranded_dispatch_unconfirmed",
|
|
@@ -14957,7 +15011,7 @@ async function pullRemoteNodeQueues(components, mesh, localDaemonId, candidateDa
|
|
|
14957
15011
|
const nodeDaemonId = readNonEmptyString2(node.daemonId);
|
|
14958
15012
|
if (!nodeDaemonId) continue;
|
|
14959
15013
|
if (daemonIdsEquivalent(nodeDaemonId, localDaemonId)) continue;
|
|
14960
|
-
if (candidateDaemonIds
|
|
15014
|
+
if (daemonIdListIncludes(candidateDaemonIds, nodeDaemonId)) continue;
|
|
14961
15015
|
for (const pendingEventArgs of pulls) {
|
|
14962
15016
|
let events;
|
|
14963
15017
|
try {
|
|
@@ -15013,7 +15067,7 @@ async function reconcileUnterminatedDirectDispatches(components, mesh, selfIds,
|
|
|
15013
15067
|
if (!sessionId || !nodeId || !taskId) continue;
|
|
15014
15068
|
const node = nodeById.get(nodeId);
|
|
15015
15069
|
const nodeDaemonId = readNonEmptyString2(node?.daemonId);
|
|
15016
|
-
const isLocalNode = !nodeDaemonId || selfIds
|
|
15070
|
+
const isLocalNode = !nodeDaemonId || daemonIdListIncludes(selfIds, nodeDaemonId) || daemonIdsEquivalent(nodeDaemonId, localDaemonId) || !!components.instanceManager.getInstance(sessionId);
|
|
15017
15071
|
const providerType = readNonEmptyString2(dispatch.providerType);
|
|
15018
15072
|
const readArgs = {
|
|
15019
15073
|
sessionId,
|
|
@@ -15088,7 +15142,7 @@ async function collectLiveNodesWithSessions(components, mesh, selfIds, localDaem
|
|
|
15088
15142
|
const dispatchMeshCommand = components.dispatchMeshCommand;
|
|
15089
15143
|
return Promise.all(mesh.nodes.map(async (node) => {
|
|
15090
15144
|
const nodeDaemonId = readNonEmptyString2(node.daemonId);
|
|
15091
|
-
const isLocalNode = !nodeDaemonId || selfIds
|
|
15145
|
+
const isLocalNode = !nodeDaemonId || daemonIdListIncludes(selfIds, nodeDaemonId) || daemonIdsEquivalent(nodeDaemonId, localDaemonId);
|
|
15092
15146
|
let statusResult;
|
|
15093
15147
|
try {
|
|
15094
15148
|
if (isLocalNode) {
|
|
@@ -46871,7 +46925,7 @@ var meshCrudHandlers = {
|
|
|
46871
46925
|
return "";
|
|
46872
46926
|
}
|
|
46873
46927
|
})();
|
|
46874
|
-
const isCoordinatorBaseNode = !!selfDaemonId && (nodeDaemonId
|
|
46928
|
+
const isCoordinatorBaseNode = !!selfDaemonId && (daemonIdsEquivalent(nodeDaemonId, selfDaemonId) || daemonIdsEquivalent(nodeMachineId, selfDaemonId)) || !!selfMachineId && (daemonIdsEquivalent(nodeDaemonId, selfMachineId) || daemonIdsEquivalent(nodeMachineId, selfMachineId));
|
|
46875
46929
|
if (isCoordinatorBaseNode) {
|
|
46876
46930
|
return {
|
|
46877
46931
|
success: false,
|