@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.mjs
CHANGED
|
@@ -311,10 +311,10 @@ function readInjected(value) {
|
|
|
311
311
|
}
|
|
312
312
|
function getDaemonBuildInfo() {
|
|
313
313
|
if (cached) return cached;
|
|
314
|
-
const commit = readInjected(true ? "
|
|
315
|
-
const commitShort = readInjected(true ? "
|
|
316
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
317
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
314
|
+
const commit = readInjected(true ? "47e042dcb10c9ca07c30ac4bf8e0d5a4153a63c6" : void 0) ?? "unknown";
|
|
315
|
+
const commitShort = readInjected(true ? "47e042dc" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
316
|
+
const version = readInjected(true ? "0.9.82-rc.374" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
317
|
+
const builtAt = readInjected(true ? "2026-06-25T00:33:05.038Z" : void 0);
|
|
318
318
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
319
319
|
return cached;
|
|
320
320
|
}
|
|
@@ -8742,7 +8742,7 @@ var init_mesh_events_utils = __esm({
|
|
|
8742
8742
|
"src/mesh/mesh-events-utils.ts"() {
|
|
8743
8743
|
"use strict";
|
|
8744
8744
|
MESH_SURFACED_PREVIEW_MAX_CHARS = 512;
|
|
8745
|
-
MESH_COMPLETION_SURFACE_MAX_CHARS =
|
|
8745
|
+
MESH_COMPLETION_SURFACE_MAX_CHARS = 16e3;
|
|
8746
8746
|
}
|
|
8747
8747
|
});
|
|
8748
8748
|
|
|
@@ -9382,6 +9382,22 @@ function isWeakCompletionLedgerPayload(payload) {
|
|
|
9382
9382
|
const diag = readRecord4(payload.completionDiagnostic);
|
|
9383
9383
|
return diag?.finalAssistantPresent === false || diag?.blockReason === "missing_final_assistant";
|
|
9384
9384
|
}
|
|
9385
|
+
function findTerminalLedgerEvidenceForTask(args) {
|
|
9386
|
+
const taskId = readNonEmptyString2(args.taskId);
|
|
9387
|
+
if (!taskId) return null;
|
|
9388
|
+
const entries = readLedgerEntries(args.meshId, { tail: args.tail ?? 500 });
|
|
9389
|
+
for (let i = entries.length - 1; i >= 0; i--) {
|
|
9390
|
+
const entry = entries[i];
|
|
9391
|
+
if (entry.kind !== "task_completed" && entry.kind !== "task_failed" && entry.kind !== "task_stalled") continue;
|
|
9392
|
+
const terminalTaskId = readNonEmptyString2(entry.payload?.taskId);
|
|
9393
|
+
if (terminalTaskId !== taskId) continue;
|
|
9394
|
+
if (entry.kind === "task_completed" && isWeakCompletionLedgerPayload(entry.payload)) continue;
|
|
9395
|
+
if (args.sessionId && entry.sessionId && entry.sessionId !== args.sessionId) continue;
|
|
9396
|
+
if (!args.sessionId && args.nodeId && entry.nodeId && !meshNodeIdMatches(entry, args.nodeId)) continue;
|
|
9397
|
+
return { id: entry.id, kind: entry.kind, payload: entry.payload || {}, timestamp: entry.timestamp };
|
|
9398
|
+
}
|
|
9399
|
+
return null;
|
|
9400
|
+
}
|
|
9385
9401
|
function findDirectDispatchLedgerEntry(args) {
|
|
9386
9402
|
const entries = readLedgerEntries(args.meshId, { tail: 500 });
|
|
9387
9403
|
for (let i = entries.length - 1; i >= 0; i--) {
|
|
@@ -11512,7 +11528,7 @@ var init_chat_message_normalization = __esm({
|
|
|
11512
11528
|
"src/providers/chat-message-normalization.ts"() {
|
|
11513
11529
|
"use strict";
|
|
11514
11530
|
init_contracts();
|
|
11515
|
-
DEFAULT_FINAL_SUMMARY_MAX_CHARS =
|
|
11531
|
+
DEFAULT_FINAL_SUMMARY_MAX_CHARS = 16e3;
|
|
11516
11532
|
BUILTIN_CHAT_MESSAGE_KINDS = ["standard", "thought", "tool", "terminal", "system"];
|
|
11517
11533
|
CHAT_MESSAGE_VISIBILITIES = ["user", "debug", "internal", "hidden"];
|
|
11518
11534
|
CHAT_MESSAGE_TRANSCRIPT_VISIBILITIES = ["visible", "chat", "user", "debug", "internal", "hidden"];
|
|
@@ -13029,6 +13045,23 @@ function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType)
|
|
|
13029
13045
|
if (!task) {
|
|
13030
13046
|
return false;
|
|
13031
13047
|
}
|
|
13048
|
+
const terminal = findTerminalLedgerEvidenceForTask({
|
|
13049
|
+
meshId,
|
|
13050
|
+
taskId: task.id
|
|
13051
|
+
});
|
|
13052
|
+
if (terminal) {
|
|
13053
|
+
const status = terminal.kind === "task_completed" ? "completed" : "failed";
|
|
13054
|
+
updateTaskStatus(meshId, task.id, status);
|
|
13055
|
+
LOG.info("MeshQueue", `Skipped dispatch for terminal task ${task.id} on mesh ${meshId}; ${terminal.kind} ledger evidence already exists`);
|
|
13056
|
+
traceMeshEventDrop("dispatch_terminal_ledger", {
|
|
13057
|
+
taskId: task.id,
|
|
13058
|
+
sessionId,
|
|
13059
|
+
nodeId,
|
|
13060
|
+
meshId,
|
|
13061
|
+
event: "agent_command"
|
|
13062
|
+
}, terminal.kind);
|
|
13063
|
+
return false;
|
|
13064
|
+
}
|
|
13032
13065
|
LOG.info("MeshQueue", `Node ${nodeId} (${sessionId}) pulled task ${task.id}`);
|
|
13033
13066
|
if (node?.daemonId && components.dispatchMeshCommand) {
|
|
13034
13067
|
const isLocalNode = components.cliManager.adapters.has(sessionId);
|
|
@@ -14565,20 +14598,24 @@ function daemonHostsMesh(mesh, daemonIds) {
|
|
|
14565
14598
|
if (host.role && host.role !== "host") return false;
|
|
14566
14599
|
const hostDaemonId = readNonEmptyString2(host.hostDaemonId);
|
|
14567
14600
|
if (!hostDaemonId) return true;
|
|
14568
|
-
return daemonIds
|
|
14601
|
+
return daemonIdListIncludes(daemonIds, hostDaemonId);
|
|
14602
|
+
}
|
|
14603
|
+
function daemonIdListIncludes(ids, id) {
|
|
14604
|
+
if (!id) return false;
|
|
14605
|
+
return ids.some((candidate) => candidate === id || daemonIdsEquivalent(candidate, id));
|
|
14569
14606
|
}
|
|
14570
14607
|
function resolveCoordinatorSelfIds(mesh, drainDaemonIds) {
|
|
14571
14608
|
const ids = new Set(drainDaemonIds);
|
|
14572
14609
|
for (const node of mesh.nodes) {
|
|
14573
14610
|
const nodeDaemonId = readNonEmptyString2(node.daemonId);
|
|
14574
14611
|
const nodeMachineId = readNonEmptyString2(node.machineId);
|
|
14575
|
-
const isSelf = nodeDaemonId && drainDaemonIds
|
|
14612
|
+
const isSelf = nodeDaemonId && daemonIdListIncludes(drainDaemonIds, nodeDaemonId) || nodeMachineId && daemonIdListIncludes(drainDaemonIds, nodeMachineId);
|
|
14576
14613
|
if (!isSelf) continue;
|
|
14577
14614
|
if (nodeDaemonId) ids.add(nodeDaemonId);
|
|
14578
14615
|
if (nodeMachineId) ids.add(nodeMachineId);
|
|
14579
14616
|
}
|
|
14580
14617
|
const hostDaemonId = readNonEmptyString2(mesh.meshHost?.hostDaemonId);
|
|
14581
|
-
if (hostDaemonId && ids
|
|
14618
|
+
if (hostDaemonId && daemonIdListIncludes([...ids], hostDaemonId)) ids.add(hostDaemonId);
|
|
14582
14619
|
return [...ids];
|
|
14583
14620
|
}
|
|
14584
14621
|
function findLiveCoordinators(components) {
|
|
@@ -14656,6 +14693,23 @@ function recoverStrandedAssignedDispatches(meshId, store) {
|
|
|
14656
14693
|
const dispatchedAtMs = Date.parse(row.dispatchTimestamp ?? "");
|
|
14657
14694
|
if (!Number.isFinite(dispatchedAtMs)) continue;
|
|
14658
14695
|
if (nowMs - dispatchedAtMs < ASSIGNED_STRANDED_DEADLINE_MS) continue;
|
|
14696
|
+
const terminal = findTerminalLedgerEvidenceForTask({
|
|
14697
|
+
meshId,
|
|
14698
|
+
taskId: row.id
|
|
14699
|
+
});
|
|
14700
|
+
if (terminal) {
|
|
14701
|
+
const status = terminal.kind === "task_completed" ? "completed" : "failed";
|
|
14702
|
+
updateTaskStatus(meshId, row.id, status);
|
|
14703
|
+
LOG.warn("MeshReconcile", `Skipped stranded reclaim redispatch for terminal task ${row.id} on mesh ${meshId}; ${terminal.kind} ledger evidence already exists`);
|
|
14704
|
+
traceMeshEventDrop("assigned_stranded_terminal_ledger", {
|
|
14705
|
+
taskId: row.id,
|
|
14706
|
+
sessionId: row.assignedSessionId,
|
|
14707
|
+
nodeId: row.assignedNodeId,
|
|
14708
|
+
meshId,
|
|
14709
|
+
event: "agent:generating_completed"
|
|
14710
|
+
}, terminal.kind);
|
|
14711
|
+
continue;
|
|
14712
|
+
}
|
|
14659
14713
|
if (store.taskHasConfirmedDelivery(meshId, row.id)) continue;
|
|
14660
14714
|
const reclaimed = reclaimStrandedAssignedTask(meshId, row.id, {
|
|
14661
14715
|
reason: "assigned_stranded_dispatch_unconfirmed",
|
|
@@ -14952,7 +15006,7 @@ async function pullRemoteNodeQueues(components, mesh, localDaemonId, candidateDa
|
|
|
14952
15006
|
const nodeDaemonId = readNonEmptyString2(node.daemonId);
|
|
14953
15007
|
if (!nodeDaemonId) continue;
|
|
14954
15008
|
if (daemonIdsEquivalent(nodeDaemonId, localDaemonId)) continue;
|
|
14955
|
-
if (candidateDaemonIds
|
|
15009
|
+
if (daemonIdListIncludes(candidateDaemonIds, nodeDaemonId)) continue;
|
|
14956
15010
|
for (const pendingEventArgs of pulls) {
|
|
14957
15011
|
let events;
|
|
14958
15012
|
try {
|
|
@@ -15008,7 +15062,7 @@ async function reconcileUnterminatedDirectDispatches(components, mesh, selfIds,
|
|
|
15008
15062
|
if (!sessionId || !nodeId || !taskId) continue;
|
|
15009
15063
|
const node = nodeById.get(nodeId);
|
|
15010
15064
|
const nodeDaemonId = readNonEmptyString2(node?.daemonId);
|
|
15011
|
-
const isLocalNode = !nodeDaemonId || selfIds
|
|
15065
|
+
const isLocalNode = !nodeDaemonId || daemonIdListIncludes(selfIds, nodeDaemonId) || daemonIdsEquivalent(nodeDaemonId, localDaemonId) || !!components.instanceManager.getInstance(sessionId);
|
|
15012
15066
|
const providerType = readNonEmptyString2(dispatch.providerType);
|
|
15013
15067
|
const readArgs = {
|
|
15014
15068
|
sessionId,
|
|
@@ -15083,7 +15137,7 @@ async function collectLiveNodesWithSessions(components, mesh, selfIds, localDaem
|
|
|
15083
15137
|
const dispatchMeshCommand = components.dispatchMeshCommand;
|
|
15084
15138
|
return Promise.all(mesh.nodes.map(async (node) => {
|
|
15085
15139
|
const nodeDaemonId = readNonEmptyString2(node.daemonId);
|
|
15086
|
-
const isLocalNode = !nodeDaemonId || selfIds
|
|
15140
|
+
const isLocalNode = !nodeDaemonId || daemonIdListIncludes(selfIds, nodeDaemonId) || daemonIdsEquivalent(nodeDaemonId, localDaemonId);
|
|
15087
15141
|
let statusResult;
|
|
15088
15142
|
try {
|
|
15089
15143
|
if (isLocalNode) {
|
|
@@ -46502,7 +46556,7 @@ var meshCrudHandlers = {
|
|
|
46502
46556
|
return "";
|
|
46503
46557
|
}
|
|
46504
46558
|
})();
|
|
46505
|
-
const isCoordinatorBaseNode = !!selfDaemonId && (nodeDaemonId
|
|
46559
|
+
const isCoordinatorBaseNode = !!selfDaemonId && (daemonIdsEquivalent(nodeDaemonId, selfDaemonId) || daemonIdsEquivalent(nodeMachineId, selfDaemonId)) || !!selfMachineId && (daemonIdsEquivalent(nodeDaemonId, selfMachineId) || daemonIdsEquivalent(nodeMachineId, selfMachineId));
|
|
46506
46560
|
if (isCoordinatorBaseNode) {
|
|
46507
46561
|
return {
|
|
46508
46562
|
success: false,
|