@adhdev/daemon-core 0.9.77-rc.33 → 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 +75 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +73 -1
- 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-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;
|
|
@@ -4829,6 +4866,7 @@ __export(index_exports, {
|
|
|
4829
4866
|
buildThoughtChatMessage: () => buildThoughtChatMessage,
|
|
4830
4867
|
buildToolChatMessage: () => buildToolChatMessage,
|
|
4831
4868
|
buildUserChatMessage: () => buildUserChatMessage,
|
|
4869
|
+
cancelTask: () => cancelTask,
|
|
4832
4870
|
claimNextTask: () => claimNextTask,
|
|
4833
4871
|
classifyChatMessageVisibility: () => classifyChatMessageVisibility,
|
|
4834
4872
|
classifyHotChatSessionsForSubscriptionFlush: () => classifyHotChatSessionsForSubscriptionFlush,
|
|
@@ -4940,6 +4978,7 @@ __export(index_exports, {
|
|
|
4940
4978
|
registerExtensionProviders: () => registerExtensionProviders,
|
|
4941
4979
|
removeNode: () => removeNode,
|
|
4942
4980
|
removeWorktree: () => removeWorktree,
|
|
4981
|
+
requeueTask: () => requeueTask,
|
|
4943
4982
|
resetConfig: () => resetConfig,
|
|
4944
4983
|
resetDebugRuntimeConfig: () => resetDebugRuntimeConfig,
|
|
4945
4984
|
resetState: () => resetState,
|
|
@@ -23916,6 +23955,39 @@ var DaemonCommandRouter = class {
|
|
|
23916
23955
|
return { success: false, error: e.message };
|
|
23917
23956
|
}
|
|
23918
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
|
+
}
|
|
23919
23991
|
case "add_mesh_node": {
|
|
23920
23992
|
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
23921
23993
|
const workspace = typeof args?.workspace === "string" ? args.workspace.trim() : "";
|
|
@@ -32562,6 +32634,7 @@ async function shutdownDaemonComponents(components) {
|
|
|
32562
32634
|
buildThoughtChatMessage,
|
|
32563
32635
|
buildToolChatMessage,
|
|
32564
32636
|
buildUserChatMessage,
|
|
32637
|
+
cancelTask,
|
|
32565
32638
|
claimNextTask,
|
|
32566
32639
|
classifyChatMessageVisibility,
|
|
32567
32640
|
classifyHotChatSessionsForSubscriptionFlush,
|
|
@@ -32673,6 +32746,7 @@ async function shutdownDaemonComponents(components) {
|
|
|
32673
32746
|
registerExtensionProviders,
|
|
32674
32747
|
removeNode,
|
|
32675
32748
|
removeWorktree,
|
|
32749
|
+
requeueTask,
|
|
32676
32750
|
resetConfig,
|
|
32677
32751
|
resetDebugRuntimeConfig,
|
|
32678
32752
|
resetState,
|