@adhdev/daemon-standalone 0.9.82-rc.39 → 0.9.82-rc.40
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
CHANGED
|
@@ -46981,9 +46981,56 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
|
|
|
46981
46981
|
* Allows the MCP server to query mesh data via get_mesh even when
|
|
46982
46982
|
* the mesh doesn't exist in the local meshes.json file. */
|
|
46983
46983
|
inlineMeshCache = /* @__PURE__ */ new Map();
|
|
46984
|
+
/** Coordinator-owned whole-mesh aggregate status snapshots. Browser callers read this by default. */
|
|
46985
|
+
aggregateMeshStatusCache = /* @__PURE__ */ new Map();
|
|
46984
46986
|
constructor(deps) {
|
|
46985
46987
|
this.deps = deps;
|
|
46986
46988
|
}
|
|
46989
|
+
cloneJsonValue(value) {
|
|
46990
|
+
if (typeof structuredClone === "function") return structuredClone(value);
|
|
46991
|
+
return JSON.parse(JSON.stringify(value));
|
|
46992
|
+
}
|
|
46993
|
+
getCachedAggregateMeshStatus(meshId) {
|
|
46994
|
+
const cached2 = this.aggregateMeshStatusCache.get(meshId);
|
|
46995
|
+
if (!cached2?.snapshot || cached2.snapshot.success !== true || !Array.isArray(cached2.snapshot.nodes)) return null;
|
|
46996
|
+
const snapshot = this.cloneJsonValue(cached2.snapshot);
|
|
46997
|
+
const ageMs = Math.max(0, Date.now() - cached2.builtAt);
|
|
46998
|
+
const sourceOfTruth = snapshot.sourceOfTruth && typeof snapshot.sourceOfTruth === "object" ? snapshot.sourceOfTruth : {};
|
|
46999
|
+
snapshot.sourceOfTruth = {
|
|
47000
|
+
...sourceOfTruth,
|
|
47001
|
+
aggregateSnapshot: {
|
|
47002
|
+
...sourceOfTruth.aggregateSnapshot && typeof sourceOfTruth.aggregateSnapshot === "object" ? sourceOfTruth.aggregateSnapshot : {},
|
|
47003
|
+
owner: "coordinator_daemon_memory",
|
|
47004
|
+
cached: true,
|
|
47005
|
+
source: "memory",
|
|
47006
|
+
refreshReason: "memory_cache_hit",
|
|
47007
|
+
ageMs,
|
|
47008
|
+
cachedAt: new Date(cached2.builtAt).toISOString(),
|
|
47009
|
+
returnedAt: (/* @__PURE__ */ new Date()).toISOString()
|
|
47010
|
+
}
|
|
47011
|
+
};
|
|
47012
|
+
return snapshot;
|
|
47013
|
+
}
|
|
47014
|
+
rememberAggregateMeshStatus(meshId, snapshot, refreshReason) {
|
|
47015
|
+
if (!snapshot || typeof snapshot !== "object" || snapshot.success !== true || !Array.isArray(snapshot.nodes)) return snapshot;
|
|
47016
|
+
const builtAt = Date.now();
|
|
47017
|
+
const next = this.cloneJsonValue(snapshot);
|
|
47018
|
+
const sourceOfTruth = next.sourceOfTruth && typeof next.sourceOfTruth === "object" ? next.sourceOfTruth : {};
|
|
47019
|
+
next.sourceOfTruth = {
|
|
47020
|
+
...sourceOfTruth,
|
|
47021
|
+
aggregateSnapshot: {
|
|
47022
|
+
owner: "coordinator_daemon_memory",
|
|
47023
|
+
cached: false,
|
|
47024
|
+
source: "live_refresh",
|
|
47025
|
+
refreshReason,
|
|
47026
|
+
ageMs: 0,
|
|
47027
|
+
cachedAt: new Date(builtAt).toISOString(),
|
|
47028
|
+
returnedAt: new Date(builtAt).toISOString()
|
|
47029
|
+
}
|
|
47030
|
+
};
|
|
47031
|
+
this.aggregateMeshStatusCache.set(meshId, { builtAt, snapshot: this.cloneJsonValue(next) });
|
|
47032
|
+
return next;
|
|
47033
|
+
}
|
|
46987
47034
|
getCachedInlineMesh(meshId, inlineMesh) {
|
|
46988
47035
|
if (inlineMesh && typeof inlineMesh === "object") {
|
|
46989
47036
|
return this.warmInlineMeshCache(meshId, inlineMesh);
|
|
@@ -47023,6 +47070,9 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
|
|
|
47023
47070
|
const warmedInline = this.warmInlineMeshCache(meshId, inlineMesh);
|
|
47024
47071
|
return warmedInline ? { mesh: warmedInline, inline: true, source: "inline_bootstrap" } : null;
|
|
47025
47072
|
}
|
|
47073
|
+
invalidateAggregateMeshStatus(meshId) {
|
|
47074
|
+
this.aggregateMeshStatusCache.delete(meshId);
|
|
47075
|
+
}
|
|
47026
47076
|
updateInlineMeshNode(meshId, mesh, node) {
|
|
47027
47077
|
if (!mesh || !Array.isArray(mesh.nodes) || !node?.id) return;
|
|
47028
47078
|
const idx = mesh.nodes.findIndex((entry) => entry?.id === node.id || entry?.nodeId === node.id);
|
|
@@ -47030,6 +47080,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
|
|
|
47030
47080
|
else mesh.nodes.push(node);
|
|
47031
47081
|
mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
47032
47082
|
this.inlineMeshCache.set(meshId, mesh);
|
|
47083
|
+
this.invalidateAggregateMeshStatus(meshId);
|
|
47033
47084
|
}
|
|
47034
47085
|
removeInlineMeshNode(meshId, mesh, nodeId) {
|
|
47035
47086
|
if (!mesh || !Array.isArray(mesh.nodes)) return false;
|
|
@@ -47038,6 +47089,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
|
|
|
47038
47089
|
mesh.nodes.splice(idx, 1);
|
|
47039
47090
|
mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
47040
47091
|
this.inlineMeshCache.set(meshId, mesh);
|
|
47092
|
+
this.invalidateAggregateMeshStatus(meshId);
|
|
47041
47093
|
return true;
|
|
47042
47094
|
}
|
|
47043
47095
|
normalizeMeshSessionCleanupMode(value) {
|
|
@@ -48079,6 +48131,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
|
|
|
48079
48131
|
const mesh = updateMesh2(meshId, patch);
|
|
48080
48132
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
48081
48133
|
this.inlineMeshCache.set(meshId, mesh);
|
|
48134
|
+
this.invalidateAggregateMeshStatus(meshId);
|
|
48082
48135
|
return { success: true, mesh };
|
|
48083
48136
|
} catch (e) {
|
|
48084
48137
|
return { success: false, error: e.message };
|
|
@@ -48514,6 +48567,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
|
|
|
48514
48567
|
} else {
|
|
48515
48568
|
const { removeNode: removeNode3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
48516
48569
|
removed = removeNode3(meshId, nodeId);
|
|
48570
|
+
if (removed) this.invalidateAggregateMeshStatus(meshId);
|
|
48517
48571
|
}
|
|
48518
48572
|
if (removed) {
|
|
48519
48573
|
try {
|
|
@@ -48592,6 +48646,7 @@ ${(0, import_node_path.resolve)(workspace || os17.tmpdir())}`;
|
|
|
48592
48646
|
policy: { ...sourceNode.policy || {} }
|
|
48593
48647
|
});
|
|
48594
48648
|
if (!node) return { success: false, error: "Failed to register worktree node" };
|
|
48649
|
+
this.invalidateAggregateMeshStatus(meshId);
|
|
48595
48650
|
}
|
|
48596
48651
|
const initSubmodules = sourceNode.policy?.initSubmodulesOnClone !== false;
|
|
48597
48652
|
if (initSubmodules) {
|
|
@@ -48976,6 +49031,12 @@ ${block}`);
|
|
|
48976
49031
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
48977
49032
|
const mesh = meshRecord?.mesh;
|
|
48978
49033
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
49034
|
+
const refreshRequested = args?.refresh === true || args?.forceRefresh === true;
|
|
49035
|
+
if (!refreshRequested) {
|
|
49036
|
+
const cachedStatus = this.getCachedAggregateMeshStatus(meshId);
|
|
49037
|
+
if (cachedStatus) return cachedStatus;
|
|
49038
|
+
}
|
|
49039
|
+
const refreshReason = refreshRequested ? "explicit_refresh" : "cold_cache_miss";
|
|
48979
49040
|
const { getMeshQueueStats: getMeshQueueStats2, getQueue: getQueue2 } = await Promise.resolve().then(() => (init_mesh_work_queue(), mesh_work_queue_exports));
|
|
48980
49041
|
const queue = getQueue2(meshId);
|
|
48981
49042
|
const queueSummary = getMeshQueueStats2(meshId);
|
|
@@ -49199,13 +49260,13 @@ ${block}`);
|
|
|
49199
49260
|
finalizeMeshNodeStatus({ status, node, daemonId, isSelfNode });
|
|
49200
49261
|
nodeStatuses.push(status);
|
|
49201
49262
|
}
|
|
49202
|
-
|
|
49263
|
+
const statusResult = {
|
|
49203
49264
|
success: true,
|
|
49204
49265
|
meshId: mesh.id,
|
|
49205
49266
|
meshName: mesh.name,
|
|
49206
49267
|
repoIdentity: mesh.repoIdentity,
|
|
49207
49268
|
defaultBranch: mesh.defaultBranch,
|
|
49208
|
-
refreshedAt
|
|
49269
|
+
refreshedAt,
|
|
49209
49270
|
sourceOfTruth: {
|
|
49210
49271
|
membership: meshRecord?.source === "inline_cache" ? "coordinator_inline_mesh_cache" : meshRecord?.source === "local_config" ? "local_mesh_config" : "inline_bootstrap_snapshot",
|
|
49211
49272
|
coordinatorOwnsLiveTruth: directTruthSatisfied,
|
|
@@ -49227,6 +49288,7 @@ ${block}`);
|
|
|
49227
49288
|
queue: { tasks: queue, summary: queueSummary },
|
|
49228
49289
|
ledger: { entries: ledgerEntries, summary: ledgerSummary }
|
|
49229
49290
|
};
|
|
49291
|
+
return this.rememberAggregateMeshStatus(meshId, statusResult, refreshReason);
|
|
49230
49292
|
} catch (e) {
|
|
49231
49293
|
return { success: false, error: e.message };
|
|
49232
49294
|
}
|