@adhdev/daemon-core 0.9.81 → 0.9.82-rc.2
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 +125 -3
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +125 -3
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/commands/router.ts +150 -3
package/dist/index.js
CHANGED
|
@@ -23814,6 +23814,115 @@ function readProviderPriorityFromPolicy(policy) {
|
|
|
23814
23814
|
return true;
|
|
23815
23815
|
});
|
|
23816
23816
|
}
|
|
23817
|
+
function readObjectRecord(value) {
|
|
23818
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
23819
|
+
}
|
|
23820
|
+
function readStringValue(...values) {
|
|
23821
|
+
for (const value of values) {
|
|
23822
|
+
if (typeof value === "string" && value.trim()) return value.trim();
|
|
23823
|
+
}
|
|
23824
|
+
return void 0;
|
|
23825
|
+
}
|
|
23826
|
+
function readNumberValue(...values) {
|
|
23827
|
+
for (const value of values) {
|
|
23828
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
23829
|
+
}
|
|
23830
|
+
return void 0;
|
|
23831
|
+
}
|
|
23832
|
+
function readBooleanValue(...values) {
|
|
23833
|
+
for (const value of values) {
|
|
23834
|
+
if (typeof value === "boolean") return value;
|
|
23835
|
+
}
|
|
23836
|
+
return void 0;
|
|
23837
|
+
}
|
|
23838
|
+
function buildCachedInlineMeshGitStatus(node) {
|
|
23839
|
+
const cachedStatus = readObjectRecord(node?.cachedStatus);
|
|
23840
|
+
const cachedGit = readObjectRecord(cachedStatus.git);
|
|
23841
|
+
if (Object.keys(cachedGit).length) {
|
|
23842
|
+
const conflictFiles2 = Array.isArray(cachedGit.conflictFiles) ? cachedGit.conflictFiles.filter((value) => typeof value === "string") : [];
|
|
23843
|
+
const conflictCount2 = readNumberValue(cachedGit.conflicts) ?? conflictFiles2.length;
|
|
23844
|
+
const hasConflicts2 = readBooleanValue(cachedGit.hasConflicts) ?? conflictCount2 > 0;
|
|
23845
|
+
const isGitRepo2 = readBooleanValue(cachedGit.isGitRepo);
|
|
23846
|
+
if (isGitRepo2 !== void 0) {
|
|
23847
|
+
return {
|
|
23848
|
+
workspace: readStringValue(cachedGit.workspace, node?.workspace) || "",
|
|
23849
|
+
repoRoot: readStringValue(cachedGit.repoRoot, node?.repoRoot, node?.workspace) || null,
|
|
23850
|
+
isGitRepo: isGitRepo2,
|
|
23851
|
+
branch: readStringValue(cachedGit.branch) ?? null,
|
|
23852
|
+
headCommit: readStringValue(cachedGit.headCommit) ?? null,
|
|
23853
|
+
headMessage: readStringValue(cachedGit.headMessage) ?? null,
|
|
23854
|
+
upstream: readStringValue(cachedGit.upstream) ?? null,
|
|
23855
|
+
ahead: readNumberValue(cachedGit.ahead) ?? 0,
|
|
23856
|
+
behind: readNumberValue(cachedGit.behind) ?? 0,
|
|
23857
|
+
staged: readNumberValue(cachedGit.staged) ?? 0,
|
|
23858
|
+
modified: readNumberValue(cachedGit.modified) ?? 0,
|
|
23859
|
+
untracked: readNumberValue(cachedGit.untracked) ?? 0,
|
|
23860
|
+
deleted: readNumberValue(cachedGit.deleted) ?? 0,
|
|
23861
|
+
renamed: readNumberValue(cachedGit.renamed) ?? 0,
|
|
23862
|
+
hasConflicts: hasConflicts2,
|
|
23863
|
+
conflictFiles: conflictFiles2,
|
|
23864
|
+
stashCount: readNumberValue(cachedGit.stashCount) ?? 0,
|
|
23865
|
+
lastCheckedAt: readNumberValue(cachedGit.lastCheckedAt) ?? Date.now()
|
|
23866
|
+
};
|
|
23867
|
+
}
|
|
23868
|
+
}
|
|
23869
|
+
const rawGit = readObjectRecord(node?.lastGit ?? node?.last_git);
|
|
23870
|
+
const gitResult = readObjectRecord(rawGit.result);
|
|
23871
|
+
const directStatus = readObjectRecord(rawGit.status);
|
|
23872
|
+
const nestedStatus = readObjectRecord(gitResult.status);
|
|
23873
|
+
const rawProbe = readObjectRecord(node?.lastProbe ?? node?.last_probe);
|
|
23874
|
+
const probeGit = readObjectRecord(rawProbe.git);
|
|
23875
|
+
const probeGitResult = readObjectRecord(probeGit.result);
|
|
23876
|
+
const probeDirectStatus = readObjectRecord(probeGit.status);
|
|
23877
|
+
const probeNestedStatus = readObjectRecord(probeGitResult.status);
|
|
23878
|
+
const status = Object.keys(directStatus).length ? directStatus : Object.keys(nestedStatus).length ? nestedStatus : Object.keys(probeDirectStatus).length ? probeDirectStatus : Object.keys(probeNestedStatus).length ? probeNestedStatus : {};
|
|
23879
|
+
const isGitRepo = readBooleanValue(status.isGitRepo);
|
|
23880
|
+
if (!Object.keys(status).length || isGitRepo === void 0) return void 0;
|
|
23881
|
+
const conflictFiles = Array.isArray(status.conflictFiles) ? status.conflictFiles.filter((value) => typeof value === "string") : [];
|
|
23882
|
+
const conflictCount = readNumberValue(status.conflicts) ?? conflictFiles.length;
|
|
23883
|
+
const hasConflicts = readBooleanValue(status.hasConflicts) ?? conflictCount > 0;
|
|
23884
|
+
return {
|
|
23885
|
+
workspace: readStringValue(status.workspace, node?.workspace) || "",
|
|
23886
|
+
repoRoot: readStringValue(status.repoRoot, node?.repoRoot, node?.workspace) || null,
|
|
23887
|
+
isGitRepo,
|
|
23888
|
+
branch: readStringValue(status.branch) ?? null,
|
|
23889
|
+
headCommit: readStringValue(status.headCommit) ?? null,
|
|
23890
|
+
headMessage: readStringValue(status.headMessage) ?? null,
|
|
23891
|
+
upstream: readStringValue(status.upstream) ?? null,
|
|
23892
|
+
ahead: readNumberValue(status.ahead) ?? 0,
|
|
23893
|
+
behind: readNumberValue(status.behind) ?? 0,
|
|
23894
|
+
staged: readNumberValue(status.staged) ?? 0,
|
|
23895
|
+
modified: readNumberValue(status.modified) ?? 0,
|
|
23896
|
+
untracked: readNumberValue(status.untracked) ?? 0,
|
|
23897
|
+
deleted: readNumberValue(status.deleted) ?? 0,
|
|
23898
|
+
renamed: readNumberValue(status.renamed) ?? 0,
|
|
23899
|
+
hasConflicts,
|
|
23900
|
+
conflictFiles,
|
|
23901
|
+
stashCount: readNumberValue(status.stashCount) ?? 0,
|
|
23902
|
+
lastCheckedAt: Date.now()
|
|
23903
|
+
};
|
|
23904
|
+
}
|
|
23905
|
+
function applyCachedInlineMeshNodeStatus(status, node) {
|
|
23906
|
+
const cachedStatus = readObjectRecord(node?.cachedStatus);
|
|
23907
|
+
const git = buildCachedInlineMeshGitStatus(node);
|
|
23908
|
+
const error = readStringValue(cachedStatus.error, node?.error);
|
|
23909
|
+
const health = readStringValue(cachedStatus.health, node?.health);
|
|
23910
|
+
const machineStatus = readStringValue(cachedStatus.machineStatus, node?.machineStatus);
|
|
23911
|
+
if (!git && !error && !health) return false;
|
|
23912
|
+
if (!machineStatus && !git && !error) return false;
|
|
23913
|
+
if (git) status.git = git;
|
|
23914
|
+
if (error) status.error = error;
|
|
23915
|
+
if (health) {
|
|
23916
|
+
status.health = health;
|
|
23917
|
+
return true;
|
|
23918
|
+
}
|
|
23919
|
+
if (git) {
|
|
23920
|
+
const dirty = Number(git.staged || 0) + Number(git.modified || 0) + Number(git.untracked || 0) + Number(git.deleted || 0) + Number(git.renamed || 0) > 0;
|
|
23921
|
+
status.health = git.isGitRepo === false ? "degraded" : dirty ? "dirty" : "online";
|
|
23922
|
+
return true;
|
|
23923
|
+
}
|
|
23924
|
+
return false;
|
|
23925
|
+
}
|
|
23817
23926
|
async function resolveProviderTypeFromPriority(args) {
|
|
23818
23927
|
if (!args.providerPriority.length) {
|
|
23819
23928
|
return { error: `Node '${args.nodeId}' has no providerPriority policy; pass cliType explicitly or configure node.policy.providerPriority` };
|
|
@@ -24215,7 +24324,12 @@ var DaemonCommandRouter = class {
|
|
|
24215
24324
|
}
|
|
24216
24325
|
return this.inlineMeshCache.get(meshId);
|
|
24217
24326
|
}
|
|
24218
|
-
async getMeshForCommand(meshId, inlineMesh) {
|
|
24327
|
+
async getMeshForCommand(meshId, inlineMesh, options) {
|
|
24328
|
+
const preferInline = options?.preferInline === true;
|
|
24329
|
+
if (preferInline) {
|
|
24330
|
+
const cached2 = this.getCachedInlineMesh(meshId, inlineMesh);
|
|
24331
|
+
if (cached2) return { mesh: cached2, inline: true };
|
|
24332
|
+
}
|
|
24219
24333
|
try {
|
|
24220
24334
|
const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
24221
24335
|
const mesh = getMesh3(meshId);
|
|
@@ -26038,7 +26152,7 @@ ${block}`);
|
|
|
26038
26152
|
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
26039
26153
|
if (!meshId) return { success: false, error: "meshId required" };
|
|
26040
26154
|
try {
|
|
26041
|
-
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh);
|
|
26155
|
+
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
26042
26156
|
const mesh = meshRecord?.mesh;
|
|
26043
26157
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
26044
26158
|
const { getMeshQueueStats: getMeshQueueStats2, getQueue: getQueue2 } = await Promise.resolve().then(() => (init_mesh_work_queue(), mesh_work_queue_exports));
|
|
@@ -26063,6 +26177,10 @@ ${block}`);
|
|
|
26063
26177
|
activeSessions: []
|
|
26064
26178
|
};
|
|
26065
26179
|
if (node.workspace && typeof node.workspace === "string") {
|
|
26180
|
+
if (!fs10.existsSync(node.workspace) && applyCachedInlineMeshNodeStatus(status, node)) {
|
|
26181
|
+
nodeStatuses.push(status);
|
|
26182
|
+
continue;
|
|
26183
|
+
}
|
|
26066
26184
|
try {
|
|
26067
26185
|
const { execFile: execFile3 } = await import("child_process");
|
|
26068
26186
|
const { promisify: promisify3 } = await import("util");
|
|
@@ -26122,8 +26240,12 @@ ${block}`);
|
|
|
26122
26240
|
};
|
|
26123
26241
|
status.health = branch ? dirty ? "dirty" : "online" : "degraded";
|
|
26124
26242
|
} catch {
|
|
26125
|
-
status
|
|
26243
|
+
if (!applyCachedInlineMeshNodeStatus(status, node)) {
|
|
26244
|
+
status.health = "degraded";
|
|
26245
|
+
}
|
|
26126
26246
|
}
|
|
26247
|
+
} else {
|
|
26248
|
+
applyCachedInlineMeshNodeStatus(status, node);
|
|
26127
26249
|
}
|
|
26128
26250
|
nodeStatuses.push(status);
|
|
26129
26251
|
}
|