@adhdev/daemon-standalone 1.0.58-rc.11 → 1.0.58-rc.12
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 +95 -9
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
package/dist/index.js
CHANGED
|
@@ -36882,10 +36882,10 @@ var require_dist3 = __commonJS({
|
|
|
36882
36882
|
}
|
|
36883
36883
|
function getDaemonBuildInfo() {
|
|
36884
36884
|
if (cached2) return cached2;
|
|
36885
|
-
const commit = readInjected(true ? "
|
|
36886
|
-
const commitShort = readInjected(true ? "
|
|
36887
|
-
const version2 = readInjected(true ? "1.0.58-rc.
|
|
36888
|
-
const builtAt = readInjected(true ? "2026-08-
|
|
36885
|
+
const commit = readInjected(true ? "530605d8d33a09d5e072b440a9634ba8dc909737" : void 0) ?? "unknown";
|
|
36886
|
+
const commitShort = readInjected(true ? "530605d8" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
36887
|
+
const version2 = readInjected(true ? "1.0.58-rc.12" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
36888
|
+
const builtAt = readInjected(true ? "2026-08-25T05:36:54.741Z" : void 0);
|
|
36889
36889
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
36890
36890
|
return cached2;
|
|
36891
36891
|
}
|
|
@@ -44929,6 +44929,7 @@ ${error48.message || ""}`;
|
|
|
44929
44929
|
normalizeCapabilityTags: () => normalizeCapabilityTags,
|
|
44930
44930
|
normalizeMagiSlots: () => normalizeMagiSlots,
|
|
44931
44931
|
normalizeRepoIdentity: () => normalizeRepoIdentity,
|
|
44932
|
+
readMeshConfigFromDisk: () => readMeshConfigFromDisk,
|
|
44932
44933
|
removeMagiKindPanel: () => removeMagiKindPanel,
|
|
44933
44934
|
removeNode: () => removeNode,
|
|
44934
44935
|
resolveScopedMeshId: () => resolveScopedMeshId,
|
|
@@ -44936,6 +44937,7 @@ ${error48.message || ""}`;
|
|
|
44936
44937
|
setMagiKindPanel: () => setMagiKindPanel,
|
|
44937
44938
|
setMeshHostPin: () => setMeshHostPin,
|
|
44938
44939
|
setMeshQuotaRouting: () => setMeshQuotaRouting,
|
|
44940
|
+
statMeshConfigFile: () => statMeshConfigFile,
|
|
44939
44941
|
tokenIdForManualPairing: () => tokenIdForManualPairing,
|
|
44940
44942
|
updateMesh: () => updateMesh,
|
|
44941
44943
|
updateNode: () => updateNode
|
|
@@ -44987,17 +44989,28 @@ ${error48.message || ""}`;
|
|
|
44987
44989
|
release2();
|
|
44988
44990
|
}
|
|
44989
44991
|
}
|
|
44990
|
-
function
|
|
44992
|
+
function readMeshConfigFromDisk() {
|
|
44991
44993
|
const path63 = getMeshConfigPath();
|
|
44992
|
-
if (!(0, import_fs5.existsSync)(path63)) return
|
|
44994
|
+
if (!(0, import_fs5.existsSync)(path63)) return null;
|
|
44993
44995
|
try {
|
|
44994
44996
|
const raw = JSON.parse((0, import_fs5.readFileSync)(path63, "utf-8"));
|
|
44995
|
-
if (!raw || !Array.isArray(raw.meshes)) return
|
|
44997
|
+
if (!raw || !Array.isArray(raw.meshes)) return null;
|
|
44996
44998
|
return raw;
|
|
44997
44999
|
} catch {
|
|
44998
|
-
return
|
|
45000
|
+
return null;
|
|
45001
|
+
}
|
|
45002
|
+
}
|
|
45003
|
+
function statMeshConfigFile() {
|
|
45004
|
+
try {
|
|
45005
|
+
const stat2 = (0, import_fs5.statSync)(getMeshConfigPath());
|
|
45006
|
+
return { mtimeMs: stat2.mtimeMs, size: stat2.size };
|
|
45007
|
+
} catch {
|
|
45008
|
+
return null;
|
|
44999
45009
|
}
|
|
45000
45010
|
}
|
|
45011
|
+
function readMeshConfigFile() {
|
|
45012
|
+
return readMeshConfigFromDisk() ?? { meshes: [] };
|
|
45013
|
+
}
|
|
45001
45014
|
function loadMeshConfig(options = {}) {
|
|
45002
45015
|
const config2 = readMeshConfigFile();
|
|
45003
45016
|
const migrated = migrateLoadedMeshConfig(config2);
|
|
@@ -127755,6 +127768,8 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
127755
127768
|
}
|
|
127756
127769
|
init_debug_trace();
|
|
127757
127770
|
init_mesh_host_ownership();
|
|
127771
|
+
init_repo_mesh_types();
|
|
127772
|
+
init_mesh_config();
|
|
127758
127773
|
var fs58 = __toESM2(require("fs"));
|
|
127759
127774
|
init_mesh_node_identity();
|
|
127760
127775
|
init_router_refine();
|
|
@@ -128904,7 +128919,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
128904
128919
|
role: "member"
|
|
128905
128920
|
};
|
|
128906
128921
|
}
|
|
128907
|
-
var DaemonCommandRouter = class {
|
|
128922
|
+
var DaemonCommandRouter = class _DaemonCommandRouter {
|
|
128908
128923
|
/** Public (not private) so the extracted ./router-refine.ts orchestration can reach it via `self`. */
|
|
128909
128924
|
deps;
|
|
128910
128925
|
/** In-memory cache for cloud-originating meshes passed via inlineMesh.
|
|
@@ -128923,6 +128938,15 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
128923
128938
|
/** Coordinator-owned whole-mesh aggregate status snapshots. Browser callers read this by default.
|
|
128924
128939
|
* Public (not private) so the extracted ./router-aggregate-status.ts orchestration can reach it via `self`. */
|
|
128925
128940
|
aggregateMeshStatusCache = /* @__PURE__ */ new Map();
|
|
128941
|
+
/**
|
|
128942
|
+
* meshes.json policy resync state (see syncInlineMeshPoliciesFromDisk).
|
|
128943
|
+
* checkedAtMs throttles the stat; mtimeMs/size are the last-seen file
|
|
128944
|
+
* identity. -1 = no baseline recorded yet: the first check RECORDS the
|
|
128945
|
+
* baseline without applying, so a stale local file mirror can never
|
|
128946
|
+
* regress a fresher inline (cloud-coordinator) policy — only edits made
|
|
128947
|
+
* while this daemon is alive and watching are pulled into memory.
|
|
128948
|
+
*/
|
|
128949
|
+
meshPolicyDiskSync = { checkedAtMs: 0, mtimeMs: -1, size: -1 };
|
|
128926
128950
|
/** Shared per-peer git_status probe dedup + recently-probed reuse gate.
|
|
128927
128951
|
* Spans separate mesh_status/get_mesh calls so the dashboard auto-retry
|
|
128928
128952
|
* loop cannot storm a slow peer with back-to-back refreshUpstream probes. */
|
|
@@ -128966,7 +128990,67 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
128966
128990
|
rememberAggregateMeshStatus(meshId, snapshot, refreshReason) {
|
|
128967
128991
|
return rememberAggregateMeshStatus(this, meshId, snapshot, refreshReason);
|
|
128968
128992
|
}
|
|
128993
|
+
/**
|
|
128994
|
+
* meshes.json → inline-cache policy resync (mtime-triggered lazy reload).
|
|
128995
|
+
*
|
|
128996
|
+
* Out-of-band edits to meshes.json (an operator hand-editing a policy flag)
|
|
128997
|
+
* never reached the inline mesh cache: command-path updates (update_mesh)
|
|
128998
|
+
* rewrite BOTH disk and cache, but a direct file edit changed nothing in
|
|
128999
|
+
* memory, so mesh_status / refine gating kept serving the boot-time policy
|
|
129000
|
+
* until a daemon restart (live evidence 2026-08-25: requireApprovalForPush
|
|
129001
|
+
* flipped to false on disk 92 min after daemon boot; the daemon kept
|
|
129002
|
+
* reporting and enforcing true).
|
|
129003
|
+
*
|
|
129004
|
+
* Fix: on inline-cache reads, stat meshes.json (throttled — routing and
|
|
129005
|
+
* status polling are hot paths); when the file changed, re-apply ONLY each
|
|
129006
|
+
* cached mesh's `policy` block from disk. Policy-only, never nodes/meshHost:
|
|
129007
|
+
* the inline cache is the coordinator's live node truth, and the daemon's
|
|
129008
|
+
* own mutators read-modify-write through disk, so they already carry the
|
|
129009
|
+
* edit forward — overwriting the whole cached mesh here would clobber
|
|
129010
|
+
* in-flight node truth for zero benefit. A changed policy also busts the
|
|
129011
|
+
* aggregate status snapshot, whose scheduling projection is derived from it.
|
|
129012
|
+
*
|
|
129013
|
+
* Safety rules:
|
|
129014
|
+
* - unparseable file (torn mid-edit write) → keep the in-memory policy,
|
|
129015
|
+
* log only. Never fall back to defaults: that would silently LOOSEN
|
|
129016
|
+
* security flags (requireApprovalForPush / requireApprovalForDestructiveGit).
|
|
129017
|
+
* - mesh absent from disk (deleted, or inline-only cloud mesh) → keep the
|
|
129018
|
+
* cache entry untouched.
|
|
129019
|
+
*/
|
|
129020
|
+
syncInlineMeshPoliciesFromDisk() {
|
|
129021
|
+
if (this.inlineMeshCache.size === 0) return;
|
|
129022
|
+
const now = Date.now();
|
|
129023
|
+
const sync = this.meshPolicyDiskSync;
|
|
129024
|
+
if (now - sync.checkedAtMs < _DaemonCommandRouter.MESH_POLICY_DISK_SYNC_THROTTLE_MS) return;
|
|
129025
|
+
sync.checkedAtMs = now;
|
|
129026
|
+
const stat2 = statMeshConfigFile();
|
|
129027
|
+
if (!stat2) return;
|
|
129028
|
+
if (stat2.mtimeMs === sync.mtimeMs && stat2.size === sync.size) return;
|
|
129029
|
+
const hadBaseline = sync.mtimeMs >= 0;
|
|
129030
|
+
sync.mtimeMs = stat2.mtimeMs;
|
|
129031
|
+
sync.size = stat2.size;
|
|
129032
|
+
if (!hadBaseline) return;
|
|
129033
|
+
const disk = readMeshConfigFromDisk();
|
|
129034
|
+
if (!disk) {
|
|
129035
|
+
console.warn("[mesh-config] meshes.json changed but is unparseable (mid-edit?) \u2014 keeping in-memory mesh policies");
|
|
129036
|
+
return;
|
|
129037
|
+
}
|
|
129038
|
+
const diskPolicyByMeshId = /* @__PURE__ */ new Map();
|
|
129039
|
+
for (const mesh of disk.meshes) {
|
|
129040
|
+
if (mesh?.id && mesh.policy && typeof mesh.policy === "object") diskPolicyByMeshId.set(mesh.id, mesh.policy);
|
|
129041
|
+
}
|
|
129042
|
+
for (const [meshId, cached5] of this.inlineMeshCache) {
|
|
129043
|
+
const diskPolicy = diskPolicyByMeshId.get(meshId);
|
|
129044
|
+
if (!diskPolicy) continue;
|
|
129045
|
+
const nextPolicy = mergeAndNormalizePolicy(void 0, diskPolicy);
|
|
129046
|
+
if (JSON.stringify(cached5?.policy ?? null) === JSON.stringify(nextPolicy)) continue;
|
|
129047
|
+
cached5.policy = nextPolicy;
|
|
129048
|
+
this.invalidateAggregateMeshStatus(meshId);
|
|
129049
|
+
}
|
|
129050
|
+
}
|
|
129051
|
+
static MESH_POLICY_DISK_SYNC_THROTTLE_MS = 250;
|
|
128969
129052
|
getCachedInlineMeshNodes() {
|
|
129053
|
+
this.syncInlineMeshPoliciesFromDisk();
|
|
128970
129054
|
const nodes = [];
|
|
128971
129055
|
for (const mesh of this.inlineMeshCache.values()) {
|
|
128972
129056
|
if (Array.isArray(mesh?.nodes)) {
|
|
@@ -128986,6 +129070,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
128986
129070
|
* the mesh policy is absent, matching the worker-launch stamp.
|
|
128987
129071
|
*/
|
|
128988
129072
|
getCachedInlineMeshNodesWithVisibility() {
|
|
129073
|
+
this.syncInlineMeshPoliciesFromDisk();
|
|
128989
129074
|
const out = [];
|
|
128990
129075
|
for (const mesh of this.inlineMeshCache.values()) {
|
|
128991
129076
|
const spawnedSessionVisibility = mesh?.policy?.spawnedSessionVisibility === "visible" ? "visible" : "hidden";
|
|
@@ -129006,6 +129091,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
129006
129091
|
return resolveRemoteMeshSessionOwnerDaemonId(this, sessionId, ownerNodeIdHint);
|
|
129007
129092
|
}
|
|
129008
129093
|
getCachedInlineMesh(meshId, inlineMesh) {
|
|
129094
|
+
this.syncInlineMeshPoliciesFromDisk();
|
|
129009
129095
|
if (inlineMesh && typeof inlineMesh === "object") {
|
|
129010
129096
|
return this.warmInlineMeshCache(meshId, inlineMesh);
|
|
129011
129097
|
}
|