@adhdev/daemon-standalone 0.9.82-rc.272 → 0.9.82-rc.274
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 +196 -128
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/public/assets/index--LjGeSoY.js +113 -0
- package/public/assets/index-CRoMHXE0.css +1 -0
- package/public/assets/index-NSq-hUrT.js +113 -0
- package/public/index.html +2 -2
- package/vendor/mcp-server/index.js +3 -8
- package/vendor/mcp-server/index.js.map +1 -1
package/dist/index.js
CHANGED
|
@@ -29983,10 +29983,10 @@ var require_dist3 = __commonJS({
|
|
|
29983
29983
|
}
|
|
29984
29984
|
function getDaemonBuildInfo() {
|
|
29985
29985
|
if (cached2) return cached2;
|
|
29986
|
-
const commit = readInjected(true ? "
|
|
29987
|
-
const commitShort = readInjected(true ? "
|
|
29988
|
-
const version2 = readInjected(true ? "0.9.82-rc.
|
|
29989
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
29986
|
+
const commit = readInjected(true ? "89d1ac61612c1dfe7fac53be61ec5dbfa67d00b2" : void 0) ?? "unknown";
|
|
29987
|
+
const commitShort = readInjected(true ? "89d1ac61" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
29988
|
+
const version2 = readInjected(true ? "0.9.82-rc.274" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
29989
|
+
const builtAt = readInjected(true ? "2026-06-15T07:05:20.920Z" : void 0);
|
|
29990
29990
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
29991
29991
|
return cached2;
|
|
29992
29992
|
}
|
|
@@ -34125,6 +34125,7 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
34125
34125
|
getActiveMeshMissionSummaries: () => getActiveMeshMissionSummaries,
|
|
34126
34126
|
getMeshMission: () => getMeshMission,
|
|
34127
34127
|
getMeshMissions: () => getMeshMissions,
|
|
34128
|
+
getMeshStatusMissionSummaries: () => getMeshStatusMissionSummaries,
|
|
34128
34129
|
summarizeMeshMission: () => summarizeMeshMission,
|
|
34129
34130
|
summarizeMissionTasks: () => summarizeMissionTasks,
|
|
34130
34131
|
upsertMeshMission: () => upsertMeshMission
|
|
@@ -34190,6 +34191,13 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
34190
34191
|
function getActiveMeshMissionSummaries(meshId) {
|
|
34191
34192
|
return getMeshMissions(meshId, ["active"]).map((mission) => summarizeMeshMission(meshId, mission));
|
|
34192
34193
|
}
|
|
34194
|
+
function getMeshStatusMissionSummaries(meshId, options) {
|
|
34195
|
+
const historyLimit = Math.max(0, options?.historyLimit ?? 10);
|
|
34196
|
+
const all = getMeshMissions(meshId);
|
|
34197
|
+
const live = all.filter((m) => m.status === "active" || m.status === "paused");
|
|
34198
|
+
const history = all.filter((m) => m.status === "completed" || m.status === "abandoned").sort((a, b) => (b.updatedAt || "").localeCompare(a.updatedAt || "")).slice(0, historyLimit);
|
|
34199
|
+
return [...live, ...history].map((mission) => summarizeMeshMission(meshId, mission));
|
|
34200
|
+
}
|
|
34193
34201
|
function buildMissionPromptSection(meshId) {
|
|
34194
34202
|
const summaries = getActiveMeshMissionSummaries(meshId);
|
|
34195
34203
|
if (summaries.length === 0) return "";
|
|
@@ -35919,16 +35927,6 @@ ${rendered}`, "utf-8");
|
|
|
35919
35927
|
function readRecord3(value) {
|
|
35920
35928
|
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
35921
35929
|
}
|
|
35922
|
-
function canonicalDaemonId(value) {
|
|
35923
|
-
const id = readNonEmptyString2(value);
|
|
35924
|
-
if (!id) return "";
|
|
35925
|
-
return id.replace(/^(?:daemon|standalone)_/, "");
|
|
35926
|
-
}
|
|
35927
|
-
function sameDaemonId(a, b) {
|
|
35928
|
-
const ca = canonicalDaemonId(a);
|
|
35929
|
-
const cb = canonicalDaemonId(b);
|
|
35930
|
-
return ca !== "" && ca === cb;
|
|
35931
|
-
}
|
|
35932
35930
|
function buildMeshWorkerRelayStamp(currentSettings, meshContext) {
|
|
35933
35931
|
if (!meshContext) return void 0;
|
|
35934
35932
|
const settings = currentSettings && typeof currentSettings === "object" ? currentSettings : {};
|
|
@@ -36127,29 +36125,6 @@ Next step: ${nextStep}`;
|
|
|
36127
36125
|
timestamp || ""
|
|
36128
36126
|
].join("::");
|
|
36129
36127
|
}
|
|
36130
|
-
function markMeshCoordinatorEventDirectDelivered(coordinatorDaemonId, event) {
|
|
36131
|
-
const canonical = canonicalDaemonId(coordinatorDaemonId);
|
|
36132
|
-
if (!canonical) return;
|
|
36133
|
-
const fingerprint = buildPendingEventFingerprint(event);
|
|
36134
|
-
if (!fingerprint.trim()) return;
|
|
36135
|
-
try {
|
|
36136
|
-
const store = MeshRuntimeStore.getInstance();
|
|
36137
|
-
store.recordDirectDelivered(canonical, fingerprint, DIRECT_DELIVERED_TTL_MS);
|
|
36138
|
-
store.sweepExpiredDirectDelivered();
|
|
36139
|
-
} catch {
|
|
36140
|
-
}
|
|
36141
|
-
}
|
|
36142
|
-
function wasDirectDeliveredToCoordinator(coordinatorDaemonId, event) {
|
|
36143
|
-
const canonical = canonicalDaemonId(coordinatorDaemonId);
|
|
36144
|
-
if (!canonical) return false;
|
|
36145
|
-
const fingerprint = buildPendingEventFingerprint(event);
|
|
36146
|
-
if (!fingerprint.trim()) return false;
|
|
36147
|
-
try {
|
|
36148
|
-
return MeshRuntimeStore.getInstance().wasDirectDelivered(canonical, fingerprint);
|
|
36149
|
-
} catch {
|
|
36150
|
-
return false;
|
|
36151
|
-
}
|
|
36152
|
-
}
|
|
36153
36128
|
function hasPendingCoordinatorEventDuplicate(event) {
|
|
36154
36129
|
const fingerprint = buildPendingEventFingerprint(event);
|
|
36155
36130
|
if (!fingerprint.trim()) return false;
|
|
@@ -36348,9 +36323,7 @@ Next step: ${nextStep}`;
|
|
|
36348
36323
|
for (const event of filtered) pushUnique(event);
|
|
36349
36324
|
}
|
|
36350
36325
|
if (merged.length === 0) return [];
|
|
36351
|
-
|
|
36352
|
-
if (deliverable.length === 0) return [];
|
|
36353
|
-
return reconcilePendingMeshCoordinatorEvents(meshId, deliverable);
|
|
36326
|
+
return reconcilePendingMeshCoordinatorEvents(meshId, merged);
|
|
36354
36327
|
}
|
|
36355
36328
|
function getPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId) {
|
|
36356
36329
|
if (!meshId) return [];
|
|
@@ -36377,8 +36350,7 @@ Next step: ${nextStep}`;
|
|
|
36377
36350
|
for (const event of readPendingMeshCoordinatorEventsFromDisk(meshId, coordinatorDaemonId)) {
|
|
36378
36351
|
pushUnique(event);
|
|
36379
36352
|
}
|
|
36380
|
-
|
|
36381
|
-
return reconcilePendingMeshCoordinatorEvents(meshId, deliverable);
|
|
36353
|
+
return reconcilePendingMeshCoordinatorEvents(meshId, merged);
|
|
36382
36354
|
}
|
|
36383
36355
|
function clearPendingMeshCoordinatorEvents(meshId, coordinatorDaemonId) {
|
|
36384
36356
|
if (!meshId) return;
|
|
@@ -36398,7 +36370,6 @@ Next step: ${nextStep}`;
|
|
|
36398
36370
|
var import_path8;
|
|
36399
36371
|
var import_crypto7;
|
|
36400
36372
|
var REFINE_TERMINAL_EVENTS;
|
|
36401
|
-
var DIRECT_DELIVERED_TTL_MS;
|
|
36402
36373
|
var MAX_PENDING_EVENTS_BYTES;
|
|
36403
36374
|
var MAX_PENDING_EVENTS_KEEP;
|
|
36404
36375
|
var init_mesh_events_pending = __esm2({
|
|
@@ -36412,7 +36383,6 @@ Next step: ${nextStep}`;
|
|
|
36412
36383
|
init_mesh_runtime_store();
|
|
36413
36384
|
init_mesh_events_utils();
|
|
36414
36385
|
REFINE_TERMINAL_EVENTS = /* @__PURE__ */ new Set(["refine:completed", "refine:failed"]);
|
|
36415
|
-
DIRECT_DELIVERED_TTL_MS = 10 * 60 * 1e3;
|
|
36416
36386
|
MAX_PENDING_EVENTS_BYTES = 100 * 1024;
|
|
36417
36387
|
MAX_PENDING_EVENTS_KEEP = 50;
|
|
36418
36388
|
}
|
|
@@ -37772,7 +37742,6 @@ Next step: ${nextStep}`;
|
|
|
37772
37742
|
const workerCoordinatorDaemonId = readNonEmptyString2(
|
|
37773
37743
|
sourceSession?.getState()?.settings?.meshCoordinatorDaemonId
|
|
37774
37744
|
);
|
|
37775
|
-
const localDaemonId = readNonEmptyString2(loadConfig2().machineId);
|
|
37776
37745
|
if (components.onMeshCoordinatorEventForwarded) {
|
|
37777
37746
|
try {
|
|
37778
37747
|
components.onMeshCoordinatorEventForwarded({
|
|
@@ -38127,60 +38096,6 @@ Next step: ${nextStep}`;
|
|
|
38127
38096
|
recoveryContext
|
|
38128
38097
|
});
|
|
38129
38098
|
if (!messageText) return { success: false, error: "unsupported mesh event" };
|
|
38130
|
-
const coordinatorInstances = components.instanceManager.getByCategory("cli").filter((inst) => {
|
|
38131
|
-
const instState = inst.getState();
|
|
38132
|
-
if (instState.settings?.meshCoordinatorFor !== args.meshId) return false;
|
|
38133
|
-
if (args.sourceInstanceId && instState.instanceId === args.sourceInstanceId) return false;
|
|
38134
|
-
if (workerCoordinatorDaemonId && localDaemonId && !sameDaemonId(workerCoordinatorDaemonId, localDaemonId)) return false;
|
|
38135
|
-
return true;
|
|
38136
|
-
});
|
|
38137
|
-
if (coordinatorInstances.length === 0) {
|
|
38138
|
-
const remoteCoordinatorDaemonId = workerCoordinatorDaemonId && localDaemonId && !sameDaemonId(workerCoordinatorDaemonId, localDaemonId) ? workerCoordinatorDaemonId : "";
|
|
38139
|
-
if (remoteCoordinatorDaemonId && components.dispatchMeshCommand) {
|
|
38140
|
-
const forwardPayload = {
|
|
38141
|
-
event: args.event,
|
|
38142
|
-
meshId: args.meshId,
|
|
38143
|
-
nodeId: args.nodeId || void 0,
|
|
38144
|
-
workspace: readNonEmptyString2(args.metadataEvent.workspace),
|
|
38145
|
-
...args.metadataEvent,
|
|
38146
|
-
...recoveryContext ? { recoveryContext } : {}
|
|
38147
|
-
};
|
|
38148
|
-
components.dispatchMeshCommand(remoteCoordinatorDaemonId, "mesh_forward_event", forwardPayload).then(() => {
|
|
38149
|
-
LOG2.info("MeshEvents", `Forwarded ${args.event} for mesh ${args.meshId} to remote coordinator daemon ${remoteCoordinatorDaemonId.slice(0, 12)}\u2026`);
|
|
38150
|
-
}).catch((error48) => {
|
|
38151
|
-
LOG2.warn("MeshEvents", `Remote forward of ${args.event} failed (${error48?.message || error48}); queuing for backfill`);
|
|
38152
|
-
queuePendingMeshCoordinatorEvent({
|
|
38153
|
-
event: args.event,
|
|
38154
|
-
meshId: args.meshId,
|
|
38155
|
-
nodeLabel: args.nodeLabel,
|
|
38156
|
-
nodeId: args.nodeId || void 0,
|
|
38157
|
-
workspace: readNonEmptyString2(args.metadataEvent.workspace),
|
|
38158
|
-
metadataEvent: { ...args.metadataEvent, ...recoveryContext ? { recoveryContext } : {} },
|
|
38159
|
-
coordinatorMessage: messageText,
|
|
38160
|
-
queuedAt: Date.now(),
|
|
38161
|
-
targetCoordinatorDaemonId: remoteCoordinatorDaemonId
|
|
38162
|
-
});
|
|
38163
|
-
});
|
|
38164
|
-
return { success: true, forwarded: 0, remoteForwarded: true };
|
|
38165
|
-
}
|
|
38166
|
-
if (queuePendingMeshCoordinatorEvent({
|
|
38167
|
-
event: args.event,
|
|
38168
|
-
meshId: args.meshId,
|
|
38169
|
-
nodeLabel: args.nodeLabel,
|
|
38170
|
-
nodeId: args.nodeId || void 0,
|
|
38171
|
-
workspace: readNonEmptyString2(args.metadataEvent.workspace),
|
|
38172
|
-
metadataEvent: {
|
|
38173
|
-
...args.metadataEvent,
|
|
38174
|
-
...recoveryContext ? { recoveryContext } : {}
|
|
38175
|
-
},
|
|
38176
|
-
coordinatorMessage: messageText,
|
|
38177
|
-
queuedAt: Date.now(),
|
|
38178
|
-
...workerCoordinatorDaemonId ? { targetCoordinatorDaemonId: workerCoordinatorDaemonId } : {}
|
|
38179
|
-
})) {
|
|
38180
|
-
LOG2.info("MeshEvents", `Queued ${args.event} for MCP coordinator (mesh ${args.meshId}${workerCoordinatorDaemonId ? `, coordinator daemon ${workerCoordinatorDaemonId}` : ""})`);
|
|
38181
|
-
}
|
|
38182
|
-
return { success: true, forwarded: 0 };
|
|
38183
|
-
}
|
|
38184
38099
|
const pendingEvent = {
|
|
38185
38100
|
event: args.event,
|
|
38186
38101
|
meshId: args.meshId,
|
|
@@ -38196,21 +38111,9 @@ Next step: ${nextStep}`;
|
|
|
38196
38111
|
...workerCoordinatorDaemonId ? { targetCoordinatorDaemonId: workerCoordinatorDaemonId } : {}
|
|
38197
38112
|
};
|
|
38198
38113
|
if (queuePendingMeshCoordinatorEvent(pendingEvent)) {
|
|
38199
|
-
LOG2.info("MeshEvents", `Queued ${args.event} for
|
|
38200
|
-
}
|
|
38201
|
-
if (localDaemonId) {
|
|
38202
|
-
markMeshCoordinatorEventDirectDelivered(localDaemonId, pendingEvent);
|
|
38203
|
-
}
|
|
38204
|
-
const forceInject = shouldForceInjectMeshEvent(args.event);
|
|
38205
|
-
for (const coord of coordinatorInstances) {
|
|
38206
|
-
const coordState = coord.getState();
|
|
38207
|
-
LOG2.info("MeshEvents", `Forwarding mesh event to coordinator ${coordState.instanceId}${forceInject ? " (force)" : ""}`);
|
|
38208
|
-
coord.onEvent("send_message", {
|
|
38209
|
-
input: { text: messageText, textFallback: messageText },
|
|
38210
|
-
...forceInject ? { force: true } : {}
|
|
38211
|
-
});
|
|
38114
|
+
LOG2.info("MeshEvents", `Queued ${args.event} for coordinator (mesh ${args.meshId}${workerCoordinatorDaemonId ? `, coordinator daemon ${workerCoordinatorDaemonId}` : ""})`);
|
|
38212
38115
|
}
|
|
38213
|
-
return { success: true, forwarded:
|
|
38116
|
+
return { success: true, forwarded: 0 };
|
|
38214
38117
|
}
|
|
38215
38118
|
function handleMeshForwardEvent(components, payload) {
|
|
38216
38119
|
const eventName = readNonEmptyString2(payload.event);
|
|
@@ -38393,6 +38296,167 @@ Next step: ${nextStep}`;
|
|
|
38393
38296
|
]);
|
|
38394
38297
|
}
|
|
38395
38298
|
});
|
|
38299
|
+
function resolveReconcileIntervalMs() {
|
|
38300
|
+
const raw = readNonEmptyString2(process.env.MESH_RECONCILE_INTERVAL_MS);
|
|
38301
|
+
if (raw) {
|
|
38302
|
+
const parsed = Number.parseInt(raw, 10);
|
|
38303
|
+
if (Number.isFinite(parsed) && parsed >= 1e3 && parsed <= 6e4) return parsed;
|
|
38304
|
+
}
|
|
38305
|
+
return DEFAULT_RECONCILE_INTERVAL_MS;
|
|
38306
|
+
}
|
|
38307
|
+
function findLiveCoordinators(components) {
|
|
38308
|
+
const out = [];
|
|
38309
|
+
for (const inst of components.instanceManager.getByCategory("cli")) {
|
|
38310
|
+
const state = inst.getState();
|
|
38311
|
+
const settings = state.settings && typeof state.settings === "object" ? state.settings : {};
|
|
38312
|
+
const meshId = readNonEmptyString2(settings.meshCoordinatorFor);
|
|
38313
|
+
if (!meshId) continue;
|
|
38314
|
+
const status = readNonEmptyString2(state.status).toLowerCase();
|
|
38315
|
+
out.push({ meshId, instance: inst, idle: status === "idle" });
|
|
38316
|
+
}
|
|
38317
|
+
return out;
|
|
38318
|
+
}
|
|
38319
|
+
function injectPendingIntoCoordinator(coordinator, pending) {
|
|
38320
|
+
if (!coordinator || !pending.coordinatorMessage) return;
|
|
38321
|
+
const force = shouldForceInjectMeshEvent(pending.event);
|
|
38322
|
+
coordinator.onEvent("send_message", {
|
|
38323
|
+
input: { text: pending.coordinatorMessage, textFallback: pending.coordinatorMessage },
|
|
38324
|
+
...force ? { force: true } : {}
|
|
38325
|
+
});
|
|
38326
|
+
}
|
|
38327
|
+
async function runMeshReconcileTick(components) {
|
|
38328
|
+
const coordinators = findLiveCoordinators(components);
|
|
38329
|
+
if (coordinators.length === 0) {
|
|
38330
|
+
return;
|
|
38331
|
+
}
|
|
38332
|
+
const byMesh = /* @__PURE__ */ new Map();
|
|
38333
|
+
for (const c of coordinators) {
|
|
38334
|
+
const list = byMesh.get(c.meshId);
|
|
38335
|
+
if (list) list.push(c);
|
|
38336
|
+
else byMesh.set(c.meshId, [c]);
|
|
38337
|
+
}
|
|
38338
|
+
const localDaemonId = readNonEmptyString2(loadConfig2().machineId) || void 0;
|
|
38339
|
+
const dispatchMeshCommand = components.dispatchMeshCommand;
|
|
38340
|
+
const store = (() => {
|
|
38341
|
+
try {
|
|
38342
|
+
return MeshRuntimeStore.getInstance();
|
|
38343
|
+
} catch {
|
|
38344
|
+
return void 0;
|
|
38345
|
+
}
|
|
38346
|
+
})();
|
|
38347
|
+
for (const [meshId, meshCoordinators] of byMesh) {
|
|
38348
|
+
if (dispatchMeshCommand) {
|
|
38349
|
+
try {
|
|
38350
|
+
await pullRemoteNodeQueues(components, meshId, localDaemonId);
|
|
38351
|
+
} catch (e) {
|
|
38352
|
+
LOG2.warn("MeshReconcile", `Remote node pull failed for mesh ${meshId}: ${e?.message || e}`);
|
|
38353
|
+
}
|
|
38354
|
+
}
|
|
38355
|
+
const idleCoordinators = meshCoordinators.filter((c) => c.idle);
|
|
38356
|
+
if (idleCoordinators.length === 0) continue;
|
|
38357
|
+
if (store) {
|
|
38358
|
+
try {
|
|
38359
|
+
if (store.pendingEventCount(meshId) === 0) continue;
|
|
38360
|
+
} catch {
|
|
38361
|
+
}
|
|
38362
|
+
}
|
|
38363
|
+
let pendingEvents = [];
|
|
38364
|
+
try {
|
|
38365
|
+
pendingEvents = drainPendingMeshCoordinatorEvents(meshId, localDaemonId);
|
|
38366
|
+
} catch (e) {
|
|
38367
|
+
LOG2.warn("MeshReconcile", `Drain failed for mesh ${meshId}: ${e?.message || e}`);
|
|
38368
|
+
continue;
|
|
38369
|
+
}
|
|
38370
|
+
if (pendingEvents.length === 0) continue;
|
|
38371
|
+
LOG2.info("MeshReconcile", `Reconcile inject: ${pendingEvents.length} pending event(s) \u2192 ${idleCoordinators.length} idle coordinator(s) for mesh ${meshId}`);
|
|
38372
|
+
for (const pending of pendingEvents) {
|
|
38373
|
+
for (const c of idleCoordinators) {
|
|
38374
|
+
injectPendingIntoCoordinator(c.instance, pending);
|
|
38375
|
+
}
|
|
38376
|
+
}
|
|
38377
|
+
}
|
|
38378
|
+
}
|
|
38379
|
+
async function pullRemoteNodeQueues(components, meshId, localDaemonId) {
|
|
38380
|
+
const dispatchMeshCommand = components.dispatchMeshCommand;
|
|
38381
|
+
if (!dispatchMeshCommand) return;
|
|
38382
|
+
const mesh = listMeshes().find((m) => m.id === meshId);
|
|
38383
|
+
if (!mesh) return;
|
|
38384
|
+
const pendingEventArgs = {
|
|
38385
|
+
meshId,
|
|
38386
|
+
...localDaemonId ? { coordinatorDaemonId: localDaemonId } : {}
|
|
38387
|
+
};
|
|
38388
|
+
for (const node of mesh.nodes) {
|
|
38389
|
+
const nodeDaemonId = readNonEmptyString2(node.daemonId);
|
|
38390
|
+
if (!nodeDaemonId) continue;
|
|
38391
|
+
if (localDaemonId && nodeDaemonId === localDaemonId) continue;
|
|
38392
|
+
let events;
|
|
38393
|
+
try {
|
|
38394
|
+
events = await dispatchMeshCommand(nodeDaemonId, "get_pending_mesh_events", pendingEventArgs);
|
|
38395
|
+
} catch {
|
|
38396
|
+
continue;
|
|
38397
|
+
}
|
|
38398
|
+
const list = extractPendingEvents(events).filter((e) => readNonEmptyString2(e?.meshId) === meshId);
|
|
38399
|
+
for (const event of list) {
|
|
38400
|
+
const payload = buildForwardPayloadFromPending(event);
|
|
38401
|
+
if (!payload.event || !payload.meshId) continue;
|
|
38402
|
+
try {
|
|
38403
|
+
handleMeshForwardEvent(components, payload);
|
|
38404
|
+
} catch {
|
|
38405
|
+
}
|
|
38406
|
+
}
|
|
38407
|
+
}
|
|
38408
|
+
}
|
|
38409
|
+
function extractPendingEvents(raw) {
|
|
38410
|
+
if (Array.isArray(raw)) return raw;
|
|
38411
|
+
if (raw && typeof raw === "object") {
|
|
38412
|
+
const events = raw.events;
|
|
38413
|
+
if (Array.isArray(events)) return events;
|
|
38414
|
+
}
|
|
38415
|
+
return [];
|
|
38416
|
+
}
|
|
38417
|
+
function buildForwardPayloadFromPending(event) {
|
|
38418
|
+
const metadata = event?.metadataEvent && typeof event.metadataEvent === "object" ? event.metadataEvent : {};
|
|
38419
|
+
return {
|
|
38420
|
+
event: readNonEmptyString2(event?.event),
|
|
38421
|
+
meshId: readNonEmptyString2(event?.meshId),
|
|
38422
|
+
nodeId: readNonEmptyString2(event?.nodeId) || readNonEmptyString2(metadata.meshNodeId),
|
|
38423
|
+
workspace: readNonEmptyString2(event?.workspace) || readNonEmptyString2(metadata.workspace),
|
|
38424
|
+
...metadata
|
|
38425
|
+
};
|
|
38426
|
+
}
|
|
38427
|
+
function setupMeshReconcileLoop(components) {
|
|
38428
|
+
const intervalMs = resolveReconcileIntervalMs();
|
|
38429
|
+
let running = false;
|
|
38430
|
+
const timer = setInterval(() => {
|
|
38431
|
+
if (running) return;
|
|
38432
|
+
running = true;
|
|
38433
|
+
void runMeshReconcileTick(components).catch((e) => LOG2.warn("MeshReconcile", `Reconcile tick error: ${e?.message || e}`)).finally(() => {
|
|
38434
|
+
running = false;
|
|
38435
|
+
});
|
|
38436
|
+
}, intervalMs);
|
|
38437
|
+
if (typeof timer.unref === "function") timer.unref();
|
|
38438
|
+
LOG2.info("MeshReconcile", `Mesh reconcile loop started (interval ${intervalMs}ms)`);
|
|
38439
|
+
return {
|
|
38440
|
+
stop() {
|
|
38441
|
+
clearInterval(timer);
|
|
38442
|
+
LOG2.info("MeshReconcile", "Mesh reconcile loop stopped");
|
|
38443
|
+
}
|
|
38444
|
+
};
|
|
38445
|
+
}
|
|
38446
|
+
var DEFAULT_RECONCILE_INTERVAL_MS;
|
|
38447
|
+
var init_mesh_reconcile_loop = __esm2({
|
|
38448
|
+
"src/mesh/mesh-reconcile-loop.ts"() {
|
|
38449
|
+
"use strict";
|
|
38450
|
+
init_config();
|
|
38451
|
+
init_mesh_config();
|
|
38452
|
+
init_logger();
|
|
38453
|
+
init_mesh_events_pending();
|
|
38454
|
+
init_mesh_runtime_store();
|
|
38455
|
+
init_mesh_events_coordinator();
|
|
38456
|
+
init_mesh_events_utils();
|
|
38457
|
+
DEFAULT_RECONCILE_INTERVAL_MS = 4e3;
|
|
38458
|
+
}
|
|
38459
|
+
});
|
|
38396
38460
|
var mesh_events_exports = {};
|
|
38397
38461
|
__export2(mesh_events_exports, {
|
|
38398
38462
|
__resetIdleAutoFastForwardForTests: () => __resetIdleAutoFastForwardForTests,
|
|
@@ -38402,10 +38466,11 @@ Next step: ${nextStep}`;
|
|
|
38402
38466
|
getPendingMeshCoordinatorEvents: () => getPendingMeshCoordinatorEvents,
|
|
38403
38467
|
handleMeshForwardEvent: () => handleMeshForwardEvent,
|
|
38404
38468
|
isMeshCoordinatorEvent: () => isMeshCoordinatorEvent,
|
|
38405
|
-
markMeshCoordinatorEventDirectDelivered: () => markMeshCoordinatorEventDirectDelivered,
|
|
38406
38469
|
queuePendingMeshCoordinatorEvent: () => queuePendingMeshCoordinatorEvent,
|
|
38407
38470
|
reconcileDirectDispatchCompletionFromTranscript: () => reconcileDirectDispatchCompletionFromTranscript,
|
|
38471
|
+
runMeshReconcileTick: () => runMeshReconcileTick,
|
|
38408
38472
|
setupMeshEventForwarding: () => setupMeshEventForwarding,
|
|
38473
|
+
setupMeshReconcileLoop: () => setupMeshReconcileLoop,
|
|
38409
38474
|
triggerMeshQueue: () => triggerMeshQueue,
|
|
38410
38475
|
tryAssignQueueTask: () => tryAssignQueueTask
|
|
38411
38476
|
});
|
|
@@ -38414,6 +38479,7 @@ Next step: ${nextStep}`;
|
|
|
38414
38479
|
"use strict";
|
|
38415
38480
|
init_mesh_events_pending();
|
|
38416
38481
|
init_mesh_events_stale();
|
|
38482
|
+
init_mesh_reconcile_loop();
|
|
38417
38483
|
init_mesh_events_coordinator();
|
|
38418
38484
|
}
|
|
38419
38485
|
});
|
|
@@ -62243,9 +62309,11 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62243
62309
|
if (!this.generatingStartedAt) this.generatingStartedAt = now;
|
|
62244
62310
|
const modal = adapterStatus.activeModal;
|
|
62245
62311
|
LOG2.info("CLI", `[${this.type}] approval modal: "${modal?.message?.slice(0, 80) ?? "none"}"`);
|
|
62312
|
+
const approvalEntrySeq = typeof adapterStatus?.approvalEntrySeq === "number" ? adapterStatus.approvalEntrySeq : 0;
|
|
62246
62313
|
const approvalFingerprint = JSON.stringify({
|
|
62247
62314
|
message: typeof modal?.message === "string" ? modal.message.trim() : "",
|
|
62248
|
-
buttons: Array.isArray(modal?.buttons) ? modal.buttons.map((button) => String(button).trim()) : []
|
|
62315
|
+
buttons: Array.isArray(modal?.buttons) ? modal.buttons.map((button) => String(button).trim()) : [],
|
|
62316
|
+
seq: approvalEntrySeq
|
|
62249
62317
|
});
|
|
62250
62318
|
if (approvalFingerprint !== this.lastApprovalEventFingerprint) {
|
|
62251
62319
|
this.lastApprovalEventFingerprint = approvalFingerprint;
|
|
@@ -62262,6 +62330,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
62262
62330
|
modalButtons: modal?.buttons
|
|
62263
62331
|
});
|
|
62264
62332
|
}
|
|
62333
|
+
} else if (newStatus === "generating" && this.lastStatus === "waiting_approval") {
|
|
62334
|
+
this.lastApprovalEventFingerprint = "";
|
|
62265
62335
|
} else if (newStatus === "idle" && (this.lastStatus === "generating" || this.lastStatus === "waiting_approval")) {
|
|
62266
62336
|
const duration3 = this.generatingStartedAt ? Math.round((now - this.generatingStartedAt) / 1e3) : 0;
|
|
62267
62337
|
if (!this.generatingStartedAt && !this.generatingDebouncePending) {
|
|
@@ -74119,18 +74189,6 @@ ${hintLines.join("\n")}` : "",
|
|
|
74119
74189
|
return { success: true };
|
|
74120
74190
|
}
|
|
74121
74191
|
case "launch_cli": {
|
|
74122
|
-
{
|
|
74123
|
-
const launchSettings = args?.settings && typeof args.settings === "object" ? args.settings : void 0;
|
|
74124
|
-
const isMeshWorkerLaunch = !!launchSettings && (readStringValue(launchSettings.meshNodeFor) || launchSettings.launchedByCoordinator === true);
|
|
74125
|
-
const hasCoordinatorDaemonId = !!launchSettings && !!readStringValue(launchSettings.meshCoordinatorDaemonId);
|
|
74126
|
-
if (launchSettings && isMeshWorkerLaunch && !hasCoordinatorDaemonId) {
|
|
74127
|
-
try {
|
|
74128
|
-
const localDaemonId = readStringValue(loadConfig2().machineId);
|
|
74129
|
-
if (localDaemonId) launchSettings.meshCoordinatorDaemonId = localDaemonId;
|
|
74130
|
-
} catch {
|
|
74131
|
-
}
|
|
74132
|
-
}
|
|
74133
|
-
}
|
|
74134
74192
|
const launchResult = await this.deps.cliManager.handleCliCommand(cmd, args);
|
|
74135
74193
|
const meshNodeId = readStringValue(args?.settings?.meshNodeId);
|
|
74136
74194
|
const meshId = readStringValue(args?.settings?.meshNodeFor);
|
|
@@ -76792,6 +76850,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
76792
76850
|
nodes: mesh.nodes || [],
|
|
76793
76851
|
liveSessionRecords: liveMeshSessions
|
|
76794
76852
|
});
|
|
76853
|
+
const { getMeshStatusMissionSummaries: getMeshStatusMissionSummaries2 } = await Promise.resolve().then(() => (init_mesh_missions(), mesh_missions_exports));
|
|
76854
|
+
const missions = getMeshStatusMissionSummaries2(meshId);
|
|
76795
76855
|
const statusResult = {
|
|
76796
76856
|
success: true,
|
|
76797
76857
|
meshId: mesh.id,
|
|
@@ -76830,6 +76890,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
76830
76890
|
nodes: nodeStatuses,
|
|
76831
76891
|
queue: { tasks: queue, summary: queueSummary },
|
|
76832
76892
|
ledger: { entries: ledgerEntries, summary: ledgerSummary },
|
|
76893
|
+
...missions.length > 0 ? { missions } : {},
|
|
76833
76894
|
...asyncRefineJobs.length > 0 ? { asyncRefineJobs } : {},
|
|
76834
76895
|
...historicalSessions ? { historicalSessions } : {},
|
|
76835
76896
|
...pendingCoordinatorEvents.length > 0 ? { pendingCoordinatorEvents } : {},
|
|
@@ -84919,6 +84980,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
84919
84980
|
init_logger();
|
|
84920
84981
|
init_config();
|
|
84921
84982
|
init_mesh_events();
|
|
84983
|
+
init_mesh_reconcile_loop();
|
|
84922
84984
|
var _hardened = false;
|
|
84923
84985
|
var HARDENED_PROTOS = [
|
|
84924
84986
|
{ name: "Object", proto: Object.prototype },
|
|
@@ -85116,6 +85178,7 @@ data: ${JSON.stringify(msg.data)}
|
|
|
85116
85178
|
onMeshCoordinatorEventForwarded: config2.onMeshCoordinatorEventForwarded
|
|
85117
85179
|
};
|
|
85118
85180
|
setupMeshEventForwarding(components);
|
|
85181
|
+
components.meshReconcileLoop = setupMeshReconcileLoop(components);
|
|
85119
85182
|
setImmediate(() => void router.resumePendingRefineJobsOnStartup());
|
|
85120
85183
|
return components;
|
|
85121
85184
|
}
|
|
@@ -85141,10 +85204,15 @@ data: ${JSON.stringify(msg.data)}
|
|
|
85141
85204
|
agentStreamManager,
|
|
85142
85205
|
cliManager,
|
|
85143
85206
|
instanceManager,
|
|
85144
|
-
cdpManagers
|
|
85207
|
+
cdpManagers,
|
|
85208
|
+
meshReconcileLoop
|
|
85145
85209
|
} = components;
|
|
85146
85210
|
poller.stop();
|
|
85147
85211
|
cdpInitializer.stop();
|
|
85212
|
+
try {
|
|
85213
|
+
meshReconcileLoop?.stop();
|
|
85214
|
+
} catch {
|
|
85215
|
+
}
|
|
85148
85216
|
try {
|
|
85149
85217
|
if (agentStreamManager) {
|
|
85150
85218
|
await agentStreamManager.dispose(cdpManagers);
|