adhdev 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/cli/index.js +85 -6
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +85 -6
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
- package/vendor/mcp-server/index.js +8 -0
- package/vendor/mcp-server/index.js.map +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -8184,12 +8184,34 @@ function sweepExpiredRemoteIdleSessions() {
|
|
|
8184
8184
|
if (session.expiresAt <= now) remoteIdleSessions.delete(key);
|
|
8185
8185
|
}
|
|
8186
8186
|
}
|
|
8187
|
+
function readRefineJobId(event) {
|
|
8188
|
+
const metadata = readRecord(event.metadataEvent) || event;
|
|
8189
|
+
const result = readRecord(metadata.result);
|
|
8190
|
+
const refineJob = readRecord(result?.refineJob);
|
|
8191
|
+
return readNonEmptyString2(metadata.jobId) || readNonEmptyString2(refineJob?.jobId);
|
|
8192
|
+
}
|
|
8193
|
+
function buildRefineTerminalEventFingerprint(meshId, eventName, metadataEvent) {
|
|
8194
|
+
const jobId = readRefineJobId({ metadataEvent });
|
|
8195
|
+
return jobId && REFINE_TERMINAL_EVENTS.has(eventName) ? `${meshId}::${eventName}::${jobId}` : "";
|
|
8196
|
+
}
|
|
8197
|
+
function hasPendingRefineTerminalEventDuplicate(event) {
|
|
8198
|
+
if (!REFINE_TERMINAL_EVENTS.has(event.event)) return false;
|
|
8199
|
+
const jobId = readRefineJobId(event);
|
|
8200
|
+
if (!jobId) return false;
|
|
8201
|
+
return getPendingMeshCoordinatorEvents(event.meshId).some(
|
|
8202
|
+
(pending) => pending.event === event.event && readRefineJobId(pending) === jobId
|
|
8203
|
+
);
|
|
8204
|
+
}
|
|
8187
8205
|
function getPendingEventsPath(meshId) {
|
|
8188
8206
|
const safe = meshId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
8189
8207
|
return (0, import_path6.join)(getLedgerDir(), `${safe}.pending-events.jsonl`);
|
|
8190
8208
|
}
|
|
8191
8209
|
function queuePendingMeshCoordinatorEvent(event) {
|
|
8192
8210
|
try {
|
|
8211
|
+
if (hasPendingRefineTerminalEventDuplicate(event)) {
|
|
8212
|
+
LOG.info("MeshEvents", `Suppressed duplicate pending ${event.event} for refine job ${readRefineJobId(event)}`);
|
|
8213
|
+
return true;
|
|
8214
|
+
}
|
|
8193
8215
|
(0, import_fs7.appendFileSync)(getPendingEventsPath(event.meshId), JSON.stringify(event) + "\n", "utf-8");
|
|
8194
8216
|
return true;
|
|
8195
8217
|
} catch (e) {
|
|
@@ -8327,6 +8349,17 @@ function isDuplicateMeshCompletionEvent(args) {
|
|
|
8327
8349
|
recentCompletionFingerprints.set(fingerprint, now);
|
|
8328
8350
|
return false;
|
|
8329
8351
|
}
|
|
8352
|
+
function isDuplicateRefineTerminalEvent(meshId, eventName, metadataEvent) {
|
|
8353
|
+
const fingerprint = buildRefineTerminalEventFingerprint(meshId, eventName, metadataEvent);
|
|
8354
|
+
if (!fingerprint) return false;
|
|
8355
|
+
const now = Date.now();
|
|
8356
|
+
for (const [key, seenAt] of recentCompletionFingerprints.entries()) {
|
|
8357
|
+
if (now - seenAt > RECENT_COMPLETION_FINGERPRINT_TTL_MS) recentCompletionFingerprints.delete(key);
|
|
8358
|
+
}
|
|
8359
|
+
if (recentCompletionFingerprints.has(fingerprint)) return true;
|
|
8360
|
+
recentCompletionFingerprints.set(fingerprint, now);
|
|
8361
|
+
return false;
|
|
8362
|
+
}
|
|
8330
8363
|
function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType) {
|
|
8331
8364
|
const task = claimNextTask(meshId, nodeId, sessionId);
|
|
8332
8365
|
if (!task) {
|
|
@@ -8669,6 +8702,32 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
8669
8702
|
if (args.event === "monitor:long_generating") {
|
|
8670
8703
|
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.`;
|
|
8671
8704
|
}
|
|
8705
|
+
if (args.event === "refine:accepted") {
|
|
8706
|
+
const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
|
|
8707
|
+
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.`;
|
|
8708
|
+
}
|
|
8709
|
+
if (args.event === "refine:completed") {
|
|
8710
|
+
const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
|
|
8711
|
+
const result = readRecord(args.metadataEvent.result);
|
|
8712
|
+
const validationSummary = readRecord(result?.validationSummary);
|
|
8713
|
+
const validationStatus = readNonEmptyString2(validationSummary?.status);
|
|
8714
|
+
const into = readNonEmptyString2(result?.into);
|
|
8715
|
+
const branch = readNonEmptyString2(result?.branch);
|
|
8716
|
+
const details = [
|
|
8717
|
+
jobId ? `job_id=${jobId}` : "",
|
|
8718
|
+
branch && into ? `${branch}\u2192${into}` : "",
|
|
8719
|
+
validationStatus ? `validation=${validationStatus}` : ""
|
|
8720
|
+
].filter(Boolean).join("; ");
|
|
8721
|
+
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.`;
|
|
8722
|
+
}
|
|
8723
|
+
if (args.event === "refine:failed") {
|
|
8724
|
+
const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
|
|
8725
|
+
const result = readRecord(args.metadataEvent.result);
|
|
8726
|
+
const code = readNonEmptyString2(result?.code);
|
|
8727
|
+
const error48 = readNonEmptyString2(result?.error);
|
|
8728
|
+
const details = [jobId ? `job_id=${jobId}` : "", code ? `code=${code}` : ""].filter(Boolean).join("; ");
|
|
8729
|
+
return `[System] Refinery async job for ${args.nodeLabel} failed${details ? ` (${details})` : ""}${error48 ? `: ${error48}` : "."} Review the terminal refine event/ledger before retrying.`;
|
|
8730
|
+
}
|
|
8672
8731
|
return "";
|
|
8673
8732
|
}
|
|
8674
8733
|
function injectMeshSystemMessage(components, args) {
|
|
@@ -8688,6 +8747,10 @@ function injectMeshSystemMessage(components, args) {
|
|
|
8688
8747
|
LOG.info("MeshEvents", `Suppressed ${args.event} for intentionally cleanup-stopped session ${eventSessionId || "(unknown session)"}`);
|
|
8689
8748
|
return { success: true, forwarded: 0, suppressed: true, intentionalCleanupStop: true };
|
|
8690
8749
|
}
|
|
8750
|
+
if (isDuplicateRefineTerminalEvent(args.meshId, args.event, args.metadataEvent)) {
|
|
8751
|
+
LOG.info("MeshEvents", `Suppressed duplicate ${args.event} for refine job ${readRefineJobId({ metadataEvent: args.metadataEvent })}`);
|
|
8752
|
+
return { success: true, forwarded: 0, suppressed: true, duplicateRefineTerminalEvent: true };
|
|
8753
|
+
}
|
|
8691
8754
|
const eventTimestamp = readEventTimestamp(args.metadataEvent.timestamp);
|
|
8692
8755
|
if (args.event === "agent:generating_completed" && eventSessionId) {
|
|
8693
8756
|
const duplicateCompletion = isDuplicateMeshCompletionEvent({
|
|
@@ -8937,6 +9000,14 @@ function handleMeshForwardEvent(components, payload) {
|
|
|
8937
9000
|
providerType: readNonEmptyString2(payload.providerType),
|
|
8938
9001
|
providerSessionId: readNonEmptyString2(payload.providerSessionId),
|
|
8939
9002
|
finalSummary: readNonEmptyString2(payload.finalSummary) || readNonEmptyString2(payload.summary),
|
|
9003
|
+
jobId: readNonEmptyString2(payload.jobId),
|
|
9004
|
+
interactionId: readNonEmptyString2(payload.interactionId),
|
|
9005
|
+
status: readNonEmptyString2(payload.status),
|
|
9006
|
+
targetDaemonId: readNonEmptyString2(payload.targetDaemonId),
|
|
9007
|
+
startedAt: readNonEmptyString2(payload.startedAt),
|
|
9008
|
+
completedAt: readNonEmptyString2(payload.completedAt),
|
|
9009
|
+
retryOfJobId: readNonEmptyString2(payload.retryOfJobId),
|
|
9010
|
+
...payload.result && typeof payload.result === "object" && !Array.isArray(payload.result) ? { result: payload.result } : {},
|
|
8940
9011
|
...payload.timestamp !== void 0 ? { timestamp: payload.timestamp } : {},
|
|
8941
9012
|
intentional: payload.intentional === true,
|
|
8942
9013
|
intentionalStop: payload.intentionalStop === true,
|
|
@@ -8980,7 +9051,7 @@ function setupMeshEventForwarding(components) {
|
|
|
8980
9051
|
});
|
|
8981
9052
|
});
|
|
8982
9053
|
}
|
|
8983
|
-
var import_fs7, import_path6, REMOTE_IDLE_SESSION_TTL_MS, remoteIdleSessions, MESH_COORDINATOR_EVENTS, EVENT_TO_LEDGER_KIND, INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS, RECENT_COMPLETION_FINGERPRINT_TTL_MS, recentCompletionFingerprints, autoLaunchInProgress, autoLaunchCooldownUntil, AUTO_LAUNCH_COOLDOWN_MS;
|
|
9054
|
+
var import_fs7, import_path6, REMOTE_IDLE_SESSION_TTL_MS, remoteIdleSessions, REFINE_TERMINAL_EVENTS, MESH_COORDINATOR_EVENTS, EVENT_TO_LEDGER_KIND, INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS, RECENT_COMPLETION_FINGERPRINT_TTL_MS, recentCompletionFingerprints, autoLaunchInProgress, autoLaunchCooldownUntil, AUTO_LAUNCH_COOLDOWN_MS;
|
|
8984
9055
|
var init_mesh_events = __esm({
|
|
8985
9056
|
"../../oss/packages/daemon-core/src/mesh/mesh-events.ts"() {
|
|
8986
9057
|
"use strict";
|
|
@@ -8994,13 +9065,17 @@ var init_mesh_events = __esm({
|
|
|
8994
9065
|
init_mesh_work_queue();
|
|
8995
9066
|
REMOTE_IDLE_SESSION_TTL_MS = 5 * 60 * 1e3;
|
|
8996
9067
|
remoteIdleSessions = /* @__PURE__ */ new Map();
|
|
9068
|
+
REFINE_TERMINAL_EVENTS = /* @__PURE__ */ new Set(["refine:completed", "refine:failed"]);
|
|
8997
9069
|
MESH_COORDINATOR_EVENTS = /* @__PURE__ */ new Set([
|
|
8998
9070
|
"agent:generating_started",
|
|
8999
9071
|
"agent:generating_completed",
|
|
9000
9072
|
"agent:waiting_approval",
|
|
9001
9073
|
"agent:stopped",
|
|
9002
9074
|
"agent:ready",
|
|
9003
|
-
"monitor:long_generating"
|
|
9075
|
+
"monitor:long_generating",
|
|
9076
|
+
"refine:accepted",
|
|
9077
|
+
"refine:completed",
|
|
9078
|
+
"refine:failed"
|
|
9004
9079
|
]);
|
|
9005
9080
|
EVENT_TO_LEDGER_KIND = {
|
|
9006
9081
|
"agent:generating_completed": "task_completed",
|
|
@@ -49506,6 +49581,7 @@ var init_router = __esm({
|
|
|
49506
49581
|
workspace: readStringValue(args.node?.workspace),
|
|
49507
49582
|
startedAt: args.startedAt || (/* @__PURE__ */ new Date()).toISOString(),
|
|
49508
49583
|
...args.completedAt ? { completedAt: args.completedAt } : {},
|
|
49584
|
+
...args.retryOfJobId ? { retryOfJobId: args.retryOfJobId } : {},
|
|
49509
49585
|
eventDelivery: { pendingEvents: true, ledger: true },
|
|
49510
49586
|
evidence: {
|
|
49511
49587
|
pendingEventsCommand: "get_pending_mesh_events",
|
|
@@ -49532,6 +49608,7 @@ var init_router = __esm({
|
|
|
49532
49608
|
status: handle.status,
|
|
49533
49609
|
startedAt: handle.startedAt,
|
|
49534
49610
|
completedAt: handle.completedAt,
|
|
49611
|
+
retryOfJobId: handle.retryOfJobId,
|
|
49535
49612
|
...result ? { result } : {}
|
|
49536
49613
|
},
|
|
49537
49614
|
queuedAt: Date.now()
|
|
@@ -49554,9 +49631,11 @@ var init_router = __esm({
|
|
|
49554
49631
|
targetDaemonId: handle.targetDaemonId,
|
|
49555
49632
|
workspace: handle.workspace,
|
|
49556
49633
|
startedAt: handle.startedAt,
|
|
49557
|
-
completedAt: handle.completedAt
|
|
49634
|
+
completedAt: handle.completedAt,
|
|
49635
|
+
retryOfJobId: handle.retryOfJobId
|
|
49558
49636
|
},
|
|
49559
49637
|
async: true,
|
|
49638
|
+
retryOfJobId: handle.retryOfJobId,
|
|
49560
49639
|
...result ? {
|
|
49561
49640
|
success: result.success === true,
|
|
49562
49641
|
result,
|
|
@@ -49794,6 +49873,7 @@ var init_router = __esm({
|
|
|
49794
49873
|
completedAt,
|
|
49795
49874
|
jobId: handle.jobId,
|
|
49796
49875
|
interactionId: handle.interactionId,
|
|
49876
|
+
retryOfJobId: handle.retryOfJobId,
|
|
49797
49877
|
node: { daemonId: handle.targetDaemonId, workspace: handle.workspace }
|
|
49798
49878
|
});
|
|
49799
49879
|
const terminal2 = { ...terminalHandle, result };
|
|
@@ -49808,13 +49888,12 @@ var init_router = __esm({
|
|
|
49808
49888
|
const running = this.runningRefineJobs.get(key);
|
|
49809
49889
|
if (running) return { ...running, duplicate: true };
|
|
49810
49890
|
const terminal2 = this.terminalRefineJobs.get(key);
|
|
49811
|
-
if (terminal2) return { ...terminal2, duplicate: true };
|
|
49812
49891
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh);
|
|
49813
49892
|
const mesh = meshRecord?.mesh;
|
|
49814
49893
|
const node = mesh?.nodes?.find((n) => n.id === nodeId || n.nodeId === nodeId);
|
|
49815
49894
|
if (!node) return { success: false, error: `Node '${nodeId}' not found in mesh` };
|
|
49816
49895
|
if (!node.isLocalWorktree || !node.workspace) return { success: false, error: `Refinery requires a local worktree node` };
|
|
49817
|
-
const handle = this.buildRefineJobHandle({ meshId, nodeId, node });
|
|
49896
|
+
const handle = this.buildRefineJobHandle({ meshId, nodeId, node, retryOfJobId: terminal2?.jobId });
|
|
49818
49897
|
this.runningRefineJobs.set(key, handle);
|
|
49819
49898
|
await this.appendRefineJobLedger("task_dispatched", handle);
|
|
49820
49899
|
this.queueRefineJobEvent("refine:accepted", handle);
|
|
@@ -101012,7 +101091,7 @@ var init_adhdev_daemon = __esm({
|
|
|
101012
101091
|
init_version();
|
|
101013
101092
|
init_src();
|
|
101014
101093
|
init_runtime_defaults();
|
|
101015
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.
|
|
101094
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.62" });
|
|
101016
101095
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
101017
101096
|
localHttpServer = null;
|
|
101018
101097
|
localWss = null;
|