adhdev 0.9.82-rc.61 → 0.9.82-rc.63
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 +78 -3
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +78 -3
- 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/index.js
CHANGED
|
@@ -7664,12 +7664,34 @@ function sweepExpiredRemoteIdleSessions() {
|
|
|
7664
7664
|
if (session.expiresAt <= now) remoteIdleSessions.delete(key);
|
|
7665
7665
|
}
|
|
7666
7666
|
}
|
|
7667
|
+
function readRefineJobId(event) {
|
|
7668
|
+
const metadata = readRecord(event.metadataEvent) || event;
|
|
7669
|
+
const result = readRecord(metadata.result);
|
|
7670
|
+
const refineJob = readRecord(result?.refineJob);
|
|
7671
|
+
return readNonEmptyString2(metadata.jobId) || readNonEmptyString2(refineJob?.jobId);
|
|
7672
|
+
}
|
|
7673
|
+
function buildRefineTerminalEventFingerprint(meshId, eventName, metadataEvent) {
|
|
7674
|
+
const jobId = readRefineJobId({ metadataEvent });
|
|
7675
|
+
return jobId && REFINE_TERMINAL_EVENTS.has(eventName) ? `${meshId}::${eventName}::${jobId}` : "";
|
|
7676
|
+
}
|
|
7677
|
+
function hasPendingRefineTerminalEventDuplicate(event) {
|
|
7678
|
+
if (!REFINE_TERMINAL_EVENTS.has(event.event)) return false;
|
|
7679
|
+
const jobId = readRefineJobId(event);
|
|
7680
|
+
if (!jobId) return false;
|
|
7681
|
+
return getPendingMeshCoordinatorEvents(event.meshId).some(
|
|
7682
|
+
(pending) => pending.event === event.event && readRefineJobId(pending) === jobId
|
|
7683
|
+
);
|
|
7684
|
+
}
|
|
7667
7685
|
function getPendingEventsPath(meshId) {
|
|
7668
7686
|
const safe = meshId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
7669
7687
|
return (0, import_path6.join)(getLedgerDir(), `${safe}.pending-events.jsonl`);
|
|
7670
7688
|
}
|
|
7671
7689
|
function queuePendingMeshCoordinatorEvent(event) {
|
|
7672
7690
|
try {
|
|
7691
|
+
if (hasPendingRefineTerminalEventDuplicate(event)) {
|
|
7692
|
+
LOG.info("MeshEvents", `Suppressed duplicate pending ${event.event} for refine job ${readRefineJobId(event)}`);
|
|
7693
|
+
return true;
|
|
7694
|
+
}
|
|
7673
7695
|
(0, import_fs7.appendFileSync)(getPendingEventsPath(event.meshId), JSON.stringify(event) + "\n", "utf-8");
|
|
7674
7696
|
return true;
|
|
7675
7697
|
} catch (e) {
|
|
@@ -7807,6 +7829,17 @@ function isDuplicateMeshCompletionEvent(args) {
|
|
|
7807
7829
|
recentCompletionFingerprints.set(fingerprint, now);
|
|
7808
7830
|
return false;
|
|
7809
7831
|
}
|
|
7832
|
+
function isDuplicateRefineTerminalEvent(meshId, eventName, metadataEvent) {
|
|
7833
|
+
const fingerprint = buildRefineTerminalEventFingerprint(meshId, eventName, metadataEvent);
|
|
7834
|
+
if (!fingerprint) return false;
|
|
7835
|
+
const now = Date.now();
|
|
7836
|
+
for (const [key, seenAt] of recentCompletionFingerprints.entries()) {
|
|
7837
|
+
if (now - seenAt > RECENT_COMPLETION_FINGERPRINT_TTL_MS) recentCompletionFingerprints.delete(key);
|
|
7838
|
+
}
|
|
7839
|
+
if (recentCompletionFingerprints.has(fingerprint)) return true;
|
|
7840
|
+
recentCompletionFingerprints.set(fingerprint, now);
|
|
7841
|
+
return false;
|
|
7842
|
+
}
|
|
7810
7843
|
function tryAssignQueueTask(components, meshId, nodeId, sessionId, providerType) {
|
|
7811
7844
|
const task = claimNextTask(meshId, nodeId, sessionId);
|
|
7812
7845
|
if (!task) {
|
|
@@ -8149,6 +8182,32 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
8149
8182
|
if (args.event === "monitor:long_generating") {
|
|
8150
8183
|
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.`;
|
|
8151
8184
|
}
|
|
8185
|
+
if (args.event === "refine:accepted") {
|
|
8186
|
+
const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
|
|
8187
|
+
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.`;
|
|
8188
|
+
}
|
|
8189
|
+
if (args.event === "refine:completed") {
|
|
8190
|
+
const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
|
|
8191
|
+
const result = readRecord(args.metadataEvent.result);
|
|
8192
|
+
const validationSummary = readRecord(result?.validationSummary);
|
|
8193
|
+
const validationStatus = readNonEmptyString2(validationSummary?.status);
|
|
8194
|
+
const into = readNonEmptyString2(result?.into);
|
|
8195
|
+
const branch = readNonEmptyString2(result?.branch);
|
|
8196
|
+
const details = [
|
|
8197
|
+
jobId ? `job_id=${jobId}` : "",
|
|
8198
|
+
branch && into ? `${branch}\u2192${into}` : "",
|
|
8199
|
+
validationStatus ? `validation=${validationStatus}` : ""
|
|
8200
|
+
].filter(Boolean).join("; ");
|
|
8201
|
+
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.`;
|
|
8202
|
+
}
|
|
8203
|
+
if (args.event === "refine:failed") {
|
|
8204
|
+
const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
|
|
8205
|
+
const result = readRecord(args.metadataEvent.result);
|
|
8206
|
+
const code = readNonEmptyString2(result?.code);
|
|
8207
|
+
const error48 = readNonEmptyString2(result?.error);
|
|
8208
|
+
const details = [jobId ? `job_id=${jobId}` : "", code ? `code=${code}` : ""].filter(Boolean).join("; ");
|
|
8209
|
+
return `[System] Refinery async job for ${args.nodeLabel} failed${details ? ` (${details})` : ""}${error48 ? `: ${error48}` : "."} Review the terminal refine event/ledger before retrying.`;
|
|
8210
|
+
}
|
|
8152
8211
|
return "";
|
|
8153
8212
|
}
|
|
8154
8213
|
function injectMeshSystemMessage(components, args) {
|
|
@@ -8168,6 +8227,10 @@ function injectMeshSystemMessage(components, args) {
|
|
|
8168
8227
|
LOG.info("MeshEvents", `Suppressed ${args.event} for intentionally cleanup-stopped session ${eventSessionId || "(unknown session)"}`);
|
|
8169
8228
|
return { success: true, forwarded: 0, suppressed: true, intentionalCleanupStop: true };
|
|
8170
8229
|
}
|
|
8230
|
+
if (isDuplicateRefineTerminalEvent(args.meshId, args.event, args.metadataEvent)) {
|
|
8231
|
+
LOG.info("MeshEvents", `Suppressed duplicate ${args.event} for refine job ${readRefineJobId({ metadataEvent: args.metadataEvent })}`);
|
|
8232
|
+
return { success: true, forwarded: 0, suppressed: true, duplicateRefineTerminalEvent: true };
|
|
8233
|
+
}
|
|
8171
8234
|
const eventTimestamp = readEventTimestamp(args.metadataEvent.timestamp);
|
|
8172
8235
|
if (args.event === "agent:generating_completed" && eventSessionId) {
|
|
8173
8236
|
const duplicateCompletion = isDuplicateMeshCompletionEvent({
|
|
@@ -8417,6 +8480,14 @@ function handleMeshForwardEvent(components, payload) {
|
|
|
8417
8480
|
providerType: readNonEmptyString2(payload.providerType),
|
|
8418
8481
|
providerSessionId: readNonEmptyString2(payload.providerSessionId),
|
|
8419
8482
|
finalSummary: readNonEmptyString2(payload.finalSummary) || readNonEmptyString2(payload.summary),
|
|
8483
|
+
jobId: readNonEmptyString2(payload.jobId),
|
|
8484
|
+
interactionId: readNonEmptyString2(payload.interactionId),
|
|
8485
|
+
status: readNonEmptyString2(payload.status),
|
|
8486
|
+
targetDaemonId: readNonEmptyString2(payload.targetDaemonId),
|
|
8487
|
+
startedAt: readNonEmptyString2(payload.startedAt),
|
|
8488
|
+
completedAt: readNonEmptyString2(payload.completedAt),
|
|
8489
|
+
retryOfJobId: readNonEmptyString2(payload.retryOfJobId),
|
|
8490
|
+
...payload.result && typeof payload.result === "object" && !Array.isArray(payload.result) ? { result: payload.result } : {},
|
|
8420
8491
|
...payload.timestamp !== void 0 ? { timestamp: payload.timestamp } : {},
|
|
8421
8492
|
intentional: payload.intentional === true,
|
|
8422
8493
|
intentionalStop: payload.intentionalStop === true,
|
|
@@ -8460,7 +8531,7 @@ function setupMeshEventForwarding(components) {
|
|
|
8460
8531
|
});
|
|
8461
8532
|
});
|
|
8462
8533
|
}
|
|
8463
|
-
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;
|
|
8534
|
+
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;
|
|
8464
8535
|
var init_mesh_events = __esm({
|
|
8465
8536
|
"../../oss/packages/daemon-core/src/mesh/mesh-events.ts"() {
|
|
8466
8537
|
"use strict";
|
|
@@ -8474,13 +8545,17 @@ var init_mesh_events = __esm({
|
|
|
8474
8545
|
init_mesh_work_queue();
|
|
8475
8546
|
REMOTE_IDLE_SESSION_TTL_MS = 5 * 60 * 1e3;
|
|
8476
8547
|
remoteIdleSessions = /* @__PURE__ */ new Map();
|
|
8548
|
+
REFINE_TERMINAL_EVENTS = /* @__PURE__ */ new Set(["refine:completed", "refine:failed"]);
|
|
8477
8549
|
MESH_COORDINATOR_EVENTS = /* @__PURE__ */ new Set([
|
|
8478
8550
|
"agent:generating_started",
|
|
8479
8551
|
"agent:generating_completed",
|
|
8480
8552
|
"agent:waiting_approval",
|
|
8481
8553
|
"agent:stopped",
|
|
8482
8554
|
"agent:ready",
|
|
8483
|
-
"monitor:long_generating"
|
|
8555
|
+
"monitor:long_generating",
|
|
8556
|
+
"refine:accepted",
|
|
8557
|
+
"refine:completed",
|
|
8558
|
+
"refine:failed"
|
|
8484
8559
|
]);
|
|
8485
8560
|
EVENT_TO_LEDGER_KIND = {
|
|
8486
8561
|
"agent:generating_completed": "task_completed",
|
|
@@ -69843,7 +69918,7 @@ var init_adhdev_daemon = __esm({
|
|
|
69843
69918
|
init_version();
|
|
69844
69919
|
init_src();
|
|
69845
69920
|
init_runtime_defaults();
|
|
69846
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.
|
|
69921
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.82-rc.63" });
|
|
69847
69922
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
69848
69923
|
localHttpServer = null;
|
|
69849
69924
|
localWss = null;
|