@adhdev/daemon-standalone 0.9.77-rc.30 → 0.9.77-rc.32
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 +60 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/vendor/mcp-server/index.js +96 -14
- package/vendor/mcp-server/index.js.map +1 -1
package/dist/index.js
CHANGED
|
@@ -32176,6 +32176,15 @@ Follow these recovery rules:
|
|
|
32176
32176
|
meshLedgerEvents = new import_events.EventEmitter();
|
|
32177
32177
|
}
|
|
32178
32178
|
});
|
|
32179
|
+
var mesh_work_queue_exports = {};
|
|
32180
|
+
__export2(mesh_work_queue_exports, {
|
|
32181
|
+
claimNextTask: () => claimNextTask,
|
|
32182
|
+
enqueueTask: () => enqueueTask,
|
|
32183
|
+
getMeshQueueStats: () => getMeshQueueStats,
|
|
32184
|
+
getQueue: () => getQueue,
|
|
32185
|
+
updateSessionTaskStatus: () => updateSessionTaskStatus,
|
|
32186
|
+
updateTaskStatus: () => updateTaskStatus
|
|
32187
|
+
});
|
|
32179
32188
|
function getQueuePath(meshId) {
|
|
32180
32189
|
const safe = meshId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
32181
32190
|
return (0, import_path4.join)(getLedgerDir(), `${safe}.queue.json`);
|
|
@@ -32202,6 +32211,7 @@ Follow these recovery rules:
|
|
|
32202
32211
|
message,
|
|
32203
32212
|
status: "pending",
|
|
32204
32213
|
targetNodeId: opts?.targetNodeId,
|
|
32214
|
+
targetSessionId: opts?.targetSessionId,
|
|
32205
32215
|
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
32206
32216
|
updatedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
32207
32217
|
};
|
|
@@ -32219,9 +32229,14 @@ Follow these recovery rules:
|
|
|
32219
32229
|
}
|
|
32220
32230
|
function claimNextTask(meshId, nodeId, sessionId) {
|
|
32221
32231
|
const queue = readQueue(meshId);
|
|
32222
|
-
|
|
32232
|
+
const hasActiveAssignment = queue.some((q2) => q2.status === "assigned" && (q2.assignedSessionId === sessionId || q2.assignedNodeId === nodeId));
|
|
32233
|
+
if (hasActiveAssignment) return null;
|
|
32234
|
+
let targetIdx = queue.findIndex((q2) => q2.status === "pending" && q2.targetSessionId === sessionId);
|
|
32235
|
+
if (targetIdx === -1) {
|
|
32236
|
+
targetIdx = queue.findIndex((q2) => q2.status === "pending" && q2.targetNodeId === nodeId && !q2.targetSessionId);
|
|
32237
|
+
}
|
|
32223
32238
|
if (targetIdx === -1) {
|
|
32224
|
-
targetIdx = queue.findIndex((q2) => q2.status === "pending" && !q2.targetNodeId);
|
|
32239
|
+
targetIdx = queue.findIndex((q2) => q2.status === "pending" && !q2.targetNodeId && !q2.targetSessionId);
|
|
32225
32240
|
}
|
|
32226
32241
|
if (targetIdx === -1) return null;
|
|
32227
32242
|
const entry = queue[targetIdx];
|
|
@@ -32519,6 +32534,9 @@ Follow these recovery rules:
|
|
|
32519
32534
|
function readNonEmptyString(value) {
|
|
32520
32535
|
return typeof value === "string" && value.trim() ? value.trim() : "";
|
|
32521
32536
|
}
|
|
32537
|
+
function resolveEventSessionId(event, fallback) {
|
|
32538
|
+
return readNonEmptyString(event.targetSessionId) || readNonEmptyString(event.sessionId) || readNonEmptyString(event.instanceId) || readNonEmptyString(fallback);
|
|
32539
|
+
}
|
|
32522
32540
|
function isMeshCoordinatorEvent(eventName) {
|
|
32523
32541
|
return typeof eventName === "string" && MESH_COORDINATOR_EVENTS.has(eventName);
|
|
32524
32542
|
}
|
|
@@ -32643,7 +32661,7 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
32643
32661
|
}
|
|
32644
32662
|
function injectMeshSystemMessage(components, args) {
|
|
32645
32663
|
if (args.event === "agent:generating_completed") {
|
|
32646
|
-
const sessionId =
|
|
32664
|
+
const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
|
|
32647
32665
|
const nodeId = readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId);
|
|
32648
32666
|
const providerType = readNonEmptyString(args.metadataEvent.providerType);
|
|
32649
32667
|
if (sessionId) {
|
|
@@ -32655,9 +32673,29 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
32655
32673
|
}
|
|
32656
32674
|
}
|
|
32657
32675
|
} else if (args.event === "agent:ready") {
|
|
32658
|
-
const sessionId =
|
|
32676
|
+
const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
|
|
32659
32677
|
const nodeId = readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId);
|
|
32660
32678
|
const providerType = readNonEmptyString(args.metadataEvent.providerType);
|
|
32679
|
+
const completedTask = sessionId ? updateSessionTaskStatus(args.meshId, sessionId, "completed") : null;
|
|
32680
|
+
if (completedTask) {
|
|
32681
|
+
try {
|
|
32682
|
+
appendLedgerEntry(args.meshId, {
|
|
32683
|
+
kind: "task_completed",
|
|
32684
|
+
nodeId: nodeId || void 0,
|
|
32685
|
+
sessionId,
|
|
32686
|
+
providerType: providerType || void 0,
|
|
32687
|
+
payload: {
|
|
32688
|
+
event: args.event,
|
|
32689
|
+
nodeLabel: args.nodeLabel,
|
|
32690
|
+
taskId: completedTask.id,
|
|
32691
|
+
completedViaReady: true,
|
|
32692
|
+
providerSessionId: readNonEmptyString(args.metadataEvent.providerSessionId) || void 0
|
|
32693
|
+
}
|
|
32694
|
+
});
|
|
32695
|
+
} catch (e) {
|
|
32696
|
+
LOG2.warn("MeshLedger", `Failed to record task_completed from ready: ${e?.message || e}`);
|
|
32697
|
+
}
|
|
32698
|
+
}
|
|
32661
32699
|
if (sessionId && nodeId && providerType) {
|
|
32662
32700
|
remoteIdleSessions.set(`${nodeId}:${sessionId}`, { nodeId, sessionId, providerType });
|
|
32663
32701
|
setTimeout(() => {
|
|
@@ -32668,13 +32706,13 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
32668
32706
|
}, 500);
|
|
32669
32707
|
}
|
|
32670
32708
|
} else if (args.event === "agent:generating_started") {
|
|
32671
|
-
const sessionId =
|
|
32709
|
+
const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
|
|
32672
32710
|
const nodeId = readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId);
|
|
32673
32711
|
if (sessionId && nodeId) {
|
|
32674
32712
|
remoteIdleSessions.delete(`${nodeId}:${sessionId}`);
|
|
32675
32713
|
}
|
|
32676
32714
|
} else if (args.event === "agent:stopped") {
|
|
32677
|
-
const sessionId =
|
|
32715
|
+
const sessionId = resolveEventSessionId(args.metadataEvent, args.sourceInstanceId);
|
|
32678
32716
|
const nodeId = readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId);
|
|
32679
32717
|
if (sessionId && nodeId) {
|
|
32680
32718
|
remoteIdleSessions.delete(`${nodeId}:${sessionId}`);
|
|
@@ -32689,7 +32727,7 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
32689
32727
|
appendLedgerEntry(args.meshId, {
|
|
32690
32728
|
kind: ledgerKind,
|
|
32691
32729
|
nodeId: readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId) || void 0,
|
|
32692
|
-
sessionId:
|
|
32730
|
+
sessionId: resolveEventSessionId(args.metadataEvent, args.sourceInstanceId) || void 0,
|
|
32693
32731
|
providerType: readNonEmptyString(args.metadataEvent.providerType) || void 0,
|
|
32694
32732
|
payload: {
|
|
32695
32733
|
event: args.event,
|
|
@@ -32707,7 +32745,7 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
32707
32745
|
const mesh = getMesh(args.meshId);
|
|
32708
32746
|
const maxRetries = mesh?.policy?.maxTaskRetries ?? 1;
|
|
32709
32747
|
recoveryContext = getSessionRecoveryContext(args.meshId, {
|
|
32710
|
-
sessionId:
|
|
32748
|
+
sessionId: resolveEventSessionId(args.metadataEvent, args.sourceInstanceId) || void 0,
|
|
32711
32749
|
nodeId: readNonEmptyString(args.nodeId) || readNonEmptyString(args.metadataEvent.meshNodeId) || void 0,
|
|
32712
32750
|
maxRetries
|
|
32713
32751
|
});
|
|
@@ -32807,7 +32845,7 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
32807
32845
|
nodeLabel,
|
|
32808
32846
|
event: eventName,
|
|
32809
32847
|
metadataEvent: {
|
|
32810
|
-
targetSessionId: readNonEmptyString(payload.targetSessionId) || readNonEmptyString(payload.sessionId),
|
|
32848
|
+
targetSessionId: readNonEmptyString(payload.targetSessionId) || readNonEmptyString(payload.sessionId) || readNonEmptyString(payload.instanceId),
|
|
32811
32849
|
providerType: readNonEmptyString(payload.providerType),
|
|
32812
32850
|
providerSessionId: readNonEmptyString(payload.providerSessionId)
|
|
32813
32851
|
}
|
|
@@ -32861,6 +32899,7 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
32861
32899
|
MAX_PENDING_EVENTS = 50;
|
|
32862
32900
|
pendingMeshCoordinatorEvents = [];
|
|
32863
32901
|
MESH_COORDINATOR_EVENTS = /* @__PURE__ */ new Set([
|
|
32902
|
+
"agent:generating_started",
|
|
32864
32903
|
"agent:generating_completed",
|
|
32865
32904
|
"agent:waiting_approval",
|
|
32866
32905
|
"agent:stopped",
|
|
@@ -54907,6 +54946,18 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
|
|
|
54907
54946
|
return { success: false, error: e.message };
|
|
54908
54947
|
}
|
|
54909
54948
|
}
|
|
54949
|
+
case "get_mesh_queue": {
|
|
54950
|
+
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
54951
|
+
if (!meshId) return { success: false, error: "meshId required" };
|
|
54952
|
+
try {
|
|
54953
|
+
const { getQueue: getQueue2 } = await Promise.resolve().then(() => (init_mesh_work_queue(), mesh_work_queue_exports));
|
|
54954
|
+
const status = Array.isArray(args?.status) ? args.status.map((s15) => typeof s15 === "string" ? s15.trim() : "").filter(Boolean) : void 0;
|
|
54955
|
+
const queue = getQueue2(meshId, { status });
|
|
54956
|
+
return { success: true, queue };
|
|
54957
|
+
} catch (e) {
|
|
54958
|
+
return { success: false, error: e.message };
|
|
54959
|
+
}
|
|
54960
|
+
}
|
|
54910
54961
|
case "add_mesh_node": {
|
|
54911
54962
|
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
54912
54963
|
const workspace = typeof args?.workspace === "string" ? args.workspace.trim() : "";
|