@adhdev/daemon-standalone 0.9.82-rc.60 → 0.9.82-rc.62
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 +84 -4
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/vendor/mcp-server/index.js +8 -0
- package/vendor/mcp-server/index.js.map +1 -1
package/dist/index.js
CHANGED
|
@@ -24492,12 +24492,34 @@ Follow these recovery rules:
|
|
|
24492
24492
|
if (session.expiresAt <= now) remoteIdleSessions.delete(key);
|
|
24493
24493
|
}
|
|
24494
24494
|
}
|
|
24495
|
+
function readRefineJobId(event) {
|
|
24496
|
+
const metadata = readRecord(event.metadataEvent) || event;
|
|
24497
|
+
const result = readRecord(metadata.result);
|
|
24498
|
+
const refineJob = readRecord(result?.refineJob);
|
|
24499
|
+
return readNonEmptyString2(metadata.jobId) || readNonEmptyString2(refineJob?.jobId);
|
|
24500
|
+
}
|
|
24501
|
+
function buildRefineTerminalEventFingerprint(meshId, eventName, metadataEvent) {
|
|
24502
|
+
const jobId = readRefineJobId({ metadataEvent });
|
|
24503
|
+
return jobId && REFINE_TERMINAL_EVENTS.has(eventName) ? `${meshId}::${eventName}::${jobId}` : "";
|
|
24504
|
+
}
|
|
24505
|
+
function hasPendingRefineTerminalEventDuplicate(event) {
|
|
24506
|
+
if (!REFINE_TERMINAL_EVENTS.has(event.event)) return false;
|
|
24507
|
+
const jobId = readRefineJobId(event);
|
|
24508
|
+
if (!jobId) return false;
|
|
24509
|
+
return getPendingMeshCoordinatorEvents(event.meshId).some(
|
|
24510
|
+
(pending) => pending.event === event.event && readRefineJobId(pending) === jobId
|
|
24511
|
+
);
|
|
24512
|
+
}
|
|
24495
24513
|
function getPendingEventsPath(meshId) {
|
|
24496
24514
|
const safe = meshId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
24497
24515
|
return (0, import_path6.join)(getLedgerDir(), `${safe}.pending-events.jsonl`);
|
|
24498
24516
|
}
|
|
24499
24517
|
function queuePendingMeshCoordinatorEvent(event) {
|
|
24500
24518
|
try {
|
|
24519
|
+
if (hasPendingRefineTerminalEventDuplicate(event)) {
|
|
24520
|
+
LOG2.info("MeshEvents", `Suppressed duplicate pending ${event.event} for refine job ${readRefineJobId(event)}`);
|
|
24521
|
+
return true;
|
|
24522
|
+
}
|
|
24501
24523
|
(0, import_fs7.appendFileSync)(getPendingEventsPath(event.meshId), JSON.stringify(event) + "\n", "utf-8");
|
|
24502
24524
|
return true;
|
|
24503
24525
|
} catch (e) {
|
|
@@ -24635,6 +24657,17 @@ Follow these recovery rules:
|
|
|
24635
24657
|
recentCompletionFingerprints.set(fingerprint, now);
|
|
24636
24658
|
return false;
|
|
24637
24659
|
}
|
|
24660
|
+
function isDuplicateRefineTerminalEvent(meshId, eventName, metadataEvent) {
|
|
24661
|
+
const fingerprint = buildRefineTerminalEventFingerprint(meshId, eventName, metadataEvent);
|
|
24662
|
+
if (!fingerprint) return false;
|
|
24663
|
+
const now = Date.now();
|
|
24664
|
+
for (const [key, seenAt] of recentCompletionFingerprints.entries()) {
|
|
24665
|
+
if (now - seenAt > RECENT_COMPLETION_FINGERPRINT_TTL_MS) recentCompletionFingerprints.delete(key);
|
|
24666
|
+
}
|
|
24667
|
+
if (recentCompletionFingerprints.has(fingerprint)) return true;
|
|
24668
|
+
recentCompletionFingerprints.set(fingerprint, now);
|
|
24669
|
+
return false;
|
|
24670
|
+
}
|
|
24638
24671
|
function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType) {
|
|
24639
24672
|
const task = claimNextTask(meshId, nodeId, sessionId);
|
|
24640
24673
|
if (!task) {
|
|
@@ -24977,6 +25010,32 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
24977
25010
|
if (args.event === "monitor:long_generating") {
|
|
24978
25011
|
return `[System] ${args.nodeLabel} has been generating for a long time${metadata}. Use mesh_read_chat once for a status check, but do not poll repeatedly.`;
|
|
24979
25012
|
}
|
|
25013
|
+
if (args.event === "refine:accepted") {
|
|
25014
|
+
const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
|
|
25015
|
+
return `[System] Refinery accepted async job${jobId ? ` ${jobId}` : ""} for ${args.nodeLabel}. Completion/failure will be delivered as a terminal refine event; do not poll repeatedly.`;
|
|
25016
|
+
}
|
|
25017
|
+
if (args.event === "refine:completed") {
|
|
25018
|
+
const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
|
|
25019
|
+
const result = readRecord(args.metadataEvent.result);
|
|
25020
|
+
const validationSummary = readRecord(result?.validationSummary);
|
|
25021
|
+
const validationStatus = readNonEmptyString2(validationSummary?.status);
|
|
25022
|
+
const into = readNonEmptyString2(result?.into);
|
|
25023
|
+
const branch = readNonEmptyString2(result?.branch);
|
|
25024
|
+
const details = [
|
|
25025
|
+
jobId ? `job_id=${jobId}` : "",
|
|
25026
|
+
branch && into ? `${branch}\u2192${into}` : "",
|
|
25027
|
+
validationStatus ? `validation=${validationStatus}` : ""
|
|
25028
|
+
].filter(Boolean).join("; ");
|
|
25029
|
+
return `[System] Refinery async job for ${args.nodeLabel} completed successfully${details ? ` (${details})` : ""}. The worktree was merged and cleanup completed; continue from the updated mesh state.`;
|
|
25030
|
+
}
|
|
25031
|
+
if (args.event === "refine:failed") {
|
|
25032
|
+
const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
|
|
25033
|
+
const result = readRecord(args.metadataEvent.result);
|
|
25034
|
+
const code = readNonEmptyString2(result?.code);
|
|
25035
|
+
const error48 = readNonEmptyString2(result?.error);
|
|
25036
|
+
const details = [jobId ? `job_id=${jobId}` : "", code ? `code=${code}` : ""].filter(Boolean).join("; ");
|
|
25037
|
+
return `[System] Refinery async job for ${args.nodeLabel} failed${details ? ` (${details})` : ""}${error48 ? `: ${error48}` : "."} Review the terminal refine event/ledger before retrying.`;
|
|
25038
|
+
}
|
|
24980
25039
|
return "";
|
|
24981
25040
|
}
|
|
24982
25041
|
function injectMeshSystemMessage(components, args) {
|
|
@@ -24996,6 +25055,10 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
24996
25055
|
LOG2.info("MeshEvents", `Suppressed ${args.event} for intentionally cleanup-stopped session ${eventSessionId || "(unknown session)"}`);
|
|
24997
25056
|
return { success: true, forwarded: 0, suppressed: true, intentionalCleanupStop: true };
|
|
24998
25057
|
}
|
|
25058
|
+
if (isDuplicateRefineTerminalEvent(args.meshId, args.event, args.metadataEvent)) {
|
|
25059
|
+
LOG2.info("MeshEvents", `Suppressed duplicate ${args.event} for refine job ${readRefineJobId({ metadataEvent: args.metadataEvent })}`);
|
|
25060
|
+
return { success: true, forwarded: 0, suppressed: true, duplicateRefineTerminalEvent: true };
|
|
25061
|
+
}
|
|
24999
25062
|
const eventTimestamp = readEventTimestamp(args.metadataEvent.timestamp);
|
|
25000
25063
|
if (args.event === "agent:generating_completed" && eventSessionId) {
|
|
25001
25064
|
const duplicateCompletion = isDuplicateMeshCompletionEvent({
|
|
@@ -25245,6 +25308,14 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
25245
25308
|
providerType: readNonEmptyString2(payload.providerType),
|
|
25246
25309
|
providerSessionId: readNonEmptyString2(payload.providerSessionId),
|
|
25247
25310
|
finalSummary: readNonEmptyString2(payload.finalSummary) || readNonEmptyString2(payload.summary),
|
|
25311
|
+
jobId: readNonEmptyString2(payload.jobId),
|
|
25312
|
+
interactionId: readNonEmptyString2(payload.interactionId),
|
|
25313
|
+
status: readNonEmptyString2(payload.status),
|
|
25314
|
+
targetDaemonId: readNonEmptyString2(payload.targetDaemonId),
|
|
25315
|
+
startedAt: readNonEmptyString2(payload.startedAt),
|
|
25316
|
+
completedAt: readNonEmptyString2(payload.completedAt),
|
|
25317
|
+
retryOfJobId: readNonEmptyString2(payload.retryOfJobId),
|
|
25318
|
+
...payload.result && typeof payload.result === "object" && !Array.isArray(payload.result) ? { result: payload.result } : {},
|
|
25248
25319
|
...payload.timestamp !== void 0 ? { timestamp: payload.timestamp } : {},
|
|
25249
25320
|
intentional: payload.intentional === true,
|
|
25250
25321
|
intentionalStop: payload.intentionalStop === true,
|
|
@@ -25292,6 +25363,7 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
25292
25363
|
var import_path6;
|
|
25293
25364
|
var REMOTE_IDLE_SESSION_TTL_MS;
|
|
25294
25365
|
var remoteIdleSessions;
|
|
25366
|
+
var REFINE_TERMINAL_EVENTS;
|
|
25295
25367
|
var MESH_COORDINATOR_EVENTS;
|
|
25296
25368
|
var EVENT_TO_LEDGER_KIND;
|
|
25297
25369
|
var INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS;
|
|
@@ -25313,13 +25385,17 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
25313
25385
|
init_mesh_work_queue();
|
|
25314
25386
|
REMOTE_IDLE_SESSION_TTL_MS = 5 * 60 * 1e3;
|
|
25315
25387
|
remoteIdleSessions = /* @__PURE__ */ new Map();
|
|
25388
|
+
REFINE_TERMINAL_EVENTS = /* @__PURE__ */ new Set(["refine:completed", "refine:failed"]);
|
|
25316
25389
|
MESH_COORDINATOR_EVENTS = /* @__PURE__ */ new Set([
|
|
25317
25390
|
"agent:generating_started",
|
|
25318
25391
|
"agent:generating_completed",
|
|
25319
25392
|
"agent:waiting_approval",
|
|
25320
25393
|
"agent:stopped",
|
|
25321
25394
|
"agent:ready",
|
|
25322
|
-
"monitor:long_generating"
|
|
25395
|
+
"monitor:long_generating",
|
|
25396
|
+
"refine:accepted",
|
|
25397
|
+
"refine:completed",
|
|
25398
|
+
"refine:failed"
|
|
25323
25399
|
]);
|
|
25324
25400
|
EVENT_TO_LEDGER_KIND = {
|
|
25325
25401
|
"agent:generating_completed": "task_completed",
|
|
@@ -48876,6 +48952,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
|
|
|
48876
48952
|
workspace: readStringValue(args.node?.workspace),
|
|
48877
48953
|
startedAt: args.startedAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
48878
48954
|
...args.completedAt ? { completedAt: args.completedAt } : {},
|
|
48955
|
+
...args.retryOfJobId ? { retryOfJobId: args.retryOfJobId } : {},
|
|
48879
48956
|
eventDelivery: { pendingEvents: true, ledger: true },
|
|
48880
48957
|
evidence: {
|
|
48881
48958
|
pendingEventsCommand: "get_pending_mesh_events",
|
|
@@ -48902,6 +48979,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
|
|
|
48902
48979
|
status: handle.status,
|
|
48903
48980
|
startedAt: handle.startedAt,
|
|
48904
48981
|
completedAt: handle.completedAt,
|
|
48982
|
+
retryOfJobId: handle.retryOfJobId,
|
|
48905
48983
|
...result ? { result } : {}
|
|
48906
48984
|
},
|
|
48907
48985
|
queuedAt: Date.now()
|
|
@@ -48924,9 +49002,11 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
|
|
|
48924
49002
|
targetDaemonId: handle.targetDaemonId,
|
|
48925
49003
|
workspace: handle.workspace,
|
|
48926
49004
|
startedAt: handle.startedAt,
|
|
48927
|
-
completedAt: handle.completedAt
|
|
49005
|
+
completedAt: handle.completedAt,
|
|
49006
|
+
retryOfJobId: handle.retryOfJobId
|
|
48928
49007
|
},
|
|
48929
49008
|
async: true,
|
|
49009
|
+
retryOfJobId: handle.retryOfJobId,
|
|
48930
49010
|
...result ? {
|
|
48931
49011
|
success: result.success === true,
|
|
48932
49012
|
result,
|
|
@@ -49164,6 +49244,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
|
|
|
49164
49244
|
completedAt,
|
|
49165
49245
|
jobId: handle.jobId,
|
|
49166
49246
|
interactionId: handle.interactionId,
|
|
49247
|
+
retryOfJobId: handle.retryOfJobId,
|
|
49167
49248
|
node: { daemonId: handle.targetDaemonId, workspace: handle.workspace }
|
|
49168
49249
|
});
|
|
49169
49250
|
const terminal = { ...terminalHandle, result };
|
|
@@ -49178,13 +49259,12 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
|
|
|
49178
49259
|
const running = this.runningRefineJobs.get(key);
|
|
49179
49260
|
if (running) return { ...running, duplicate: true };
|
|
49180
49261
|
const terminal = this.terminalRefineJobs.get(key);
|
|
49181
|
-
if (terminal) return { ...terminal, duplicate: true };
|
|
49182
49262
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh);
|
|
49183
49263
|
const mesh = meshRecord?.mesh;
|
|
49184
49264
|
const node = mesh?.nodes?.find((n) => n.id === nodeId || n.nodeId === nodeId);
|
|
49185
49265
|
if (!node) return { success: false, error: `Node '${nodeId}' not found in mesh` };
|
|
49186
49266
|
if (!node.isLocalWorktree || !node.workspace) return { success: false, error: `Refinery requires a local worktree node` };
|
|
49187
|
-
const handle = this.buildRefineJobHandle({ meshId, nodeId, node });
|
|
49267
|
+
const handle = this.buildRefineJobHandle({ meshId, nodeId, node, retryOfJobId: terminal?.jobId });
|
|
49188
49268
|
this.runningRefineJobs.set(key, handle);
|
|
49189
49269
|
await this.appendRefineJobLedger("task_dispatched", handle);
|
|
49190
49270
|
this.queueRefineJobEvent("refine:accepted", handle);
|