@adhdev/daemon-core 0.9.77-rc.32 → 0.9.77-rc.34
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.d.ts +1 -1
- package/dist/index.js +79 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +77 -3
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-work-queue.d.ts +26 -1
- package/package.json +1 -1
- package/src/commands/router.ts +35 -0
- package/src/index.ts +1 -1
- package/src/mesh/mesh-events.ts +7 -3
- package/src/mesh/mesh-work-queue.ts +69 -1
package/dist/index.d.ts
CHANGED
|
@@ -33,7 +33,7 @@ export { syncMeshes } from './mesh/mesh-sync.js';
|
|
|
33
33
|
export type { MeshSyncTransport, MeshSyncResult, RemoteMeshRecord } from './mesh/mesh-sync.js';
|
|
34
34
|
export { appendLedgerEntry, readLedgerEntries, getLedgerSummary, getLedgerDir, getSessionRecoveryContext } from './mesh/mesh-ledger.js';
|
|
35
35
|
export type { MeshLedgerEntry, MeshLedgerKind, MeshLedgerSummary, ReadLedgerOptions, SessionRecoveryContext } from './mesh/mesh-ledger.js';
|
|
36
|
-
export { enqueueTask, getQueue, claimNextTask, updateTaskStatus, updateSessionTaskStatus } from './mesh/mesh-work-queue.js';
|
|
36
|
+
export { enqueueTask, getQueue, claimNextTask, updateTaskStatus, updateSessionTaskStatus, cancelTask, requeueTask } from './mesh/mesh-work-queue.js';
|
|
37
37
|
export type { MeshWorkQueueEntry, MeshTaskStatus } from './mesh/mesh-work-queue.js';
|
|
38
38
|
export { triggerMeshQueue } from './mesh/mesh-events.js';
|
|
39
39
|
export { loadState, saveState, resetState } from './config/state-store.js';
|
package/dist/index.js
CHANGED
|
@@ -980,10 +980,12 @@ var init_mesh_ledger = __esm({
|
|
|
980
980
|
// src/mesh/mesh-work-queue.ts
|
|
981
981
|
var mesh_work_queue_exports = {};
|
|
982
982
|
__export(mesh_work_queue_exports, {
|
|
983
|
+
cancelTask: () => cancelTask,
|
|
983
984
|
claimNextTask: () => claimNextTask,
|
|
984
985
|
enqueueTask: () => enqueueTask,
|
|
985
986
|
getMeshQueueStats: () => getMeshQueueStats,
|
|
986
987
|
getQueue: () => getQueue,
|
|
988
|
+
requeueTask: () => requeueTask,
|
|
987
989
|
updateSessionTaskStatus: () => updateSessionTaskStatus,
|
|
988
990
|
updateTaskStatus: () => updateTaskStatus
|
|
989
991
|
});
|
|
@@ -1058,6 +1060,40 @@ function updateTaskStatus(meshId, taskId, status) {
|
|
|
1058
1060
|
writeQueue(meshId, queue);
|
|
1059
1061
|
return queue[idx];
|
|
1060
1062
|
}
|
|
1063
|
+
function cancelTask(meshId, taskId, opts) {
|
|
1064
|
+
const queue = readQueue(meshId);
|
|
1065
|
+
const idx = queue.findIndex((q) => q.id === taskId);
|
|
1066
|
+
if (idx === -1) return null;
|
|
1067
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1068
|
+
queue[idx].status = "cancelled";
|
|
1069
|
+
queue[idx].updatedAt = now;
|
|
1070
|
+
queue[idx].cancelledAt = now;
|
|
1071
|
+
if (opts?.reason) queue[idx].cancelReason = opts.reason;
|
|
1072
|
+
writeQueue(meshId, queue);
|
|
1073
|
+
return queue[idx];
|
|
1074
|
+
}
|
|
1075
|
+
function requeueTask(meshId, taskId, opts) {
|
|
1076
|
+
const queue = readQueue(meshId);
|
|
1077
|
+
const idx = queue.findIndex((q) => q.id === taskId);
|
|
1078
|
+
if (idx === -1) return null;
|
|
1079
|
+
const entry = queue[idx];
|
|
1080
|
+
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
1081
|
+
entry.status = "pending";
|
|
1082
|
+
delete entry.assignedNodeId;
|
|
1083
|
+
delete entry.assignedSessionId;
|
|
1084
|
+
delete entry.cancelledAt;
|
|
1085
|
+
delete entry.cancelReason;
|
|
1086
|
+
if (opts?.clearTargetNode) delete entry.targetNodeId;
|
|
1087
|
+
if (typeof opts?.targetNodeId === "string") entry.targetNodeId = opts.targetNodeId;
|
|
1088
|
+
if (opts?.clearTargetSession !== false) delete entry.targetSessionId;
|
|
1089
|
+
if (typeof opts?.targetSessionId === "string") entry.targetSessionId = opts.targetSessionId;
|
|
1090
|
+
entry.updatedAt = now;
|
|
1091
|
+
entry.requeuedAt = now;
|
|
1092
|
+
entry.requeueCount = (entry.requeueCount || 0) + 1;
|
|
1093
|
+
if (opts?.reason) entry.requeueReason = opts.reason;
|
|
1094
|
+
writeQueue(meshId, queue);
|
|
1095
|
+
return entry;
|
|
1096
|
+
}
|
|
1061
1097
|
function updateSessionTaskStatus(meshId, sessionId, status) {
|
|
1062
1098
|
const queue = readQueue(meshId);
|
|
1063
1099
|
for (let i = queue.length - 1; i >= 0; i--) {
|
|
@@ -1076,7 +1112,8 @@ function getMeshQueueStats(meshId) {
|
|
|
1076
1112
|
pending: queue.filter((q) => q.status === "pending").length,
|
|
1077
1113
|
assigned: queue.filter((q) => q.status === "assigned").length,
|
|
1078
1114
|
completed: queue.filter((q) => q.status === "completed").length,
|
|
1079
|
-
failed: queue.filter((q) => q.status === "failed").length
|
|
1115
|
+
failed: queue.filter((q) => q.status === "failed").length,
|
|
1116
|
+
cancelled: queue.filter((q) => q.status === "cancelled").length
|
|
1080
1117
|
};
|
|
1081
1118
|
}
|
|
1082
1119
|
var import_fs4, import_path4, import_crypto5;
|
|
@@ -1380,10 +1417,12 @@ function triggerMeshQueue(components, meshId) {
|
|
|
1380
1417
|
const state = inst.getState();
|
|
1381
1418
|
const settings = state.settings || {};
|
|
1382
1419
|
const instMeshId = readNonEmptyString(settings.meshNodeFor);
|
|
1383
|
-
if (instMeshId !== meshId
|
|
1420
|
+
if (instMeshId !== meshId) continue;
|
|
1384
1421
|
const nodeId = readNonEmptyString(settings.meshNodeId) || readNonEmptyString(settings.nodeId);
|
|
1385
1422
|
if (!nodeId) continue;
|
|
1386
|
-
|
|
1423
|
+
const status = readNonEmptyString(state.status).toLowerCase();
|
|
1424
|
+
if (["stopped", "failed", "terminated", "exited", "closed"].includes(status)) continue;
|
|
1425
|
+
if (status !== "idle" && state.activeChat?.status !== "waiting_input") continue;
|
|
1387
1426
|
const sessionId = state.instanceId;
|
|
1388
1427
|
const providerType = state.type || readNonEmptyString(settings.providerType);
|
|
1389
1428
|
if (providerType) {
|
|
@@ -4827,6 +4866,7 @@ __export(index_exports, {
|
|
|
4827
4866
|
buildThoughtChatMessage: () => buildThoughtChatMessage,
|
|
4828
4867
|
buildToolChatMessage: () => buildToolChatMessage,
|
|
4829
4868
|
buildUserChatMessage: () => buildUserChatMessage,
|
|
4869
|
+
cancelTask: () => cancelTask,
|
|
4830
4870
|
claimNextTask: () => claimNextTask,
|
|
4831
4871
|
classifyChatMessageVisibility: () => classifyChatMessageVisibility,
|
|
4832
4872
|
classifyHotChatSessionsForSubscriptionFlush: () => classifyHotChatSessionsForSubscriptionFlush,
|
|
@@ -4938,6 +4978,7 @@ __export(index_exports, {
|
|
|
4938
4978
|
registerExtensionProviders: () => registerExtensionProviders,
|
|
4939
4979
|
removeNode: () => removeNode,
|
|
4940
4980
|
removeWorktree: () => removeWorktree,
|
|
4981
|
+
requeueTask: () => requeueTask,
|
|
4941
4982
|
resetConfig: () => resetConfig,
|
|
4942
4983
|
resetDebugRuntimeConfig: () => resetDebugRuntimeConfig,
|
|
4943
4984
|
resetState: () => resetState,
|
|
@@ -23914,6 +23955,39 @@ var DaemonCommandRouter = class {
|
|
|
23914
23955
|
return { success: false, error: e.message };
|
|
23915
23956
|
}
|
|
23916
23957
|
}
|
|
23958
|
+
case "cancel_mesh_queue_task": {
|
|
23959
|
+
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
23960
|
+
const taskId = typeof args?.taskId === "string" ? args.taskId.trim() : "";
|
|
23961
|
+
if (!meshId || !taskId) return { success: false, error: "meshId and taskId required" };
|
|
23962
|
+
try {
|
|
23963
|
+
const { cancelTask: cancelTask2 } = await Promise.resolve().then(() => (init_mesh_work_queue(), mesh_work_queue_exports));
|
|
23964
|
+
const reason = typeof args?.reason === "string" ? args.reason : void 0;
|
|
23965
|
+
const task = cancelTask2(meshId, taskId, { reason });
|
|
23966
|
+
if (!task) return { success: false, error: `Queue task '${taskId}' not found` };
|
|
23967
|
+
return { success: true, task };
|
|
23968
|
+
} catch (e) {
|
|
23969
|
+
return { success: false, error: e.message };
|
|
23970
|
+
}
|
|
23971
|
+
}
|
|
23972
|
+
case "requeue_mesh_queue_task": {
|
|
23973
|
+
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
23974
|
+
const taskId = typeof args?.taskId === "string" ? args.taskId.trim() : "";
|
|
23975
|
+
if (!meshId || !taskId) return { success: false, error: "meshId and taskId required" };
|
|
23976
|
+
try {
|
|
23977
|
+
const { requeueTask: requeueTask2 } = await Promise.resolve().then(() => (init_mesh_work_queue(), mesh_work_queue_exports));
|
|
23978
|
+
const task = requeueTask2(meshId, taskId, {
|
|
23979
|
+
reason: typeof args?.reason === "string" ? args.reason : void 0,
|
|
23980
|
+
targetNodeId: typeof args?.targetNodeId === "string" ? args.targetNodeId.trim() : void 0,
|
|
23981
|
+
targetSessionId: typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : void 0,
|
|
23982
|
+
clearTargetNode: args?.clearTargetNode === true,
|
|
23983
|
+
clearTargetSession: args?.clearTargetSession !== false
|
|
23984
|
+
});
|
|
23985
|
+
if (!task) return { success: false, error: `Queue task '${taskId}' not found` };
|
|
23986
|
+
return { success: true, task };
|
|
23987
|
+
} catch (e) {
|
|
23988
|
+
return { success: false, error: e.message };
|
|
23989
|
+
}
|
|
23990
|
+
}
|
|
23917
23991
|
case "add_mesh_node": {
|
|
23918
23992
|
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
23919
23993
|
const workspace = typeof args?.workspace === "string" ? args.workspace.trim() : "";
|
|
@@ -32560,6 +32634,7 @@ async function shutdownDaemonComponents(components) {
|
|
|
32560
32634
|
buildThoughtChatMessage,
|
|
32561
32635
|
buildToolChatMessage,
|
|
32562
32636
|
buildUserChatMessage,
|
|
32637
|
+
cancelTask,
|
|
32563
32638
|
claimNextTask,
|
|
32564
32639
|
classifyChatMessageVisibility,
|
|
32565
32640
|
classifyHotChatSessionsForSubscriptionFlush,
|
|
@@ -32671,6 +32746,7 @@ async function shutdownDaemonComponents(components) {
|
|
|
32671
32746
|
registerExtensionProviders,
|
|
32672
32747
|
removeNode,
|
|
32673
32748
|
removeWorktree,
|
|
32749
|
+
requeueTask,
|
|
32674
32750
|
resetConfig,
|
|
32675
32751
|
resetDebugRuntimeConfig,
|
|
32676
32752
|
resetState,
|