@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.mjs
CHANGED
|
@@ -23582,6 +23582,115 @@ function readProviderPriorityFromPolicy(policy) {
|
|
|
23582
23582
|
return true;
|
|
23583
23583
|
});
|
|
23584
23584
|
}
|
|
23585
|
+
function readObjectRecord(value) {
|
|
23586
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
23587
|
+
}
|
|
23588
|
+
function readStringValue(...values) {
|
|
23589
|
+
for (const value of values) {
|
|
23590
|
+
if (typeof value === "string" && value.trim()) return value.trim();
|
|
23591
|
+
}
|
|
23592
|
+
return void 0;
|
|
23593
|
+
}
|
|
23594
|
+
function readNumberValue(...values) {
|
|
23595
|
+
for (const value of values) {
|
|
23596
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
23597
|
+
}
|
|
23598
|
+
return void 0;
|
|
23599
|
+
}
|
|
23600
|
+
function readBooleanValue(...values) {
|
|
23601
|
+
for (const value of values) {
|
|
23602
|
+
if (typeof value === "boolean") return value;
|
|
23603
|
+
}
|
|
23604
|
+
return void 0;
|
|
23605
|
+
}
|
|
23606
|
+
function buildCachedInlineMeshGitStatus(node) {
|
|
23607
|
+
const cachedStatus = readObjectRecord(node?.cachedStatus);
|
|
23608
|
+
const cachedGit = readObjectRecord(cachedStatus.git);
|
|
23609
|
+
if (Object.keys(cachedGit).length) {
|
|
23610
|
+
const conflictFiles2 = Array.isArray(cachedGit.conflictFiles) ? cachedGit.conflictFiles.filter((value) => typeof value === "string") : [];
|
|
23611
|
+
const conflictCount2 = readNumberValue(cachedGit.conflicts) ?? conflictFiles2.length;
|
|
23612
|
+
const hasConflicts2 = readBooleanValue(cachedGit.hasConflicts) ?? conflictCount2 > 0;
|
|
23613
|
+
const isGitRepo2 = readBooleanValue(cachedGit.isGitRepo);
|
|
23614
|
+
if (isGitRepo2 !== void 0) {
|
|
23615
|
+
return {
|
|
23616
|
+
workspace: readStringValue(cachedGit.workspace, node?.workspace) || "",
|
|
23617
|
+
repoRoot: readStringValue(cachedGit.repoRoot, node?.repoRoot, node?.workspace) || null,
|
|
23618
|
+
isGitRepo: isGitRepo2,
|
|
23619
|
+
branch: readStringValue(cachedGit.branch) ?? null,
|
|
23620
|
+
headCommit: readStringValue(cachedGit.headCommit) ?? null,
|
|
23621
|
+
headMessage: readStringValue(cachedGit.headMessage) ?? null,
|
|
23622
|
+
upstream: readStringValue(cachedGit.upstream) ?? null,
|
|
23623
|
+
ahead: readNumberValue(cachedGit.ahead) ?? 0,
|
|
23624
|
+
behind: readNumberValue(cachedGit.behind) ?? 0,
|
|
23625
|
+
staged: readNumberValue(cachedGit.staged) ?? 0,
|
|
23626
|
+
modified: readNumberValue(cachedGit.modified) ?? 0,
|
|
23627
|
+
untracked: readNumberValue(cachedGit.untracked) ?? 0,
|
|
23628
|
+
deleted: readNumberValue(cachedGit.deleted) ?? 0,
|
|
23629
|
+
renamed: readNumberValue(cachedGit.renamed) ?? 0,
|
|
23630
|
+
hasConflicts: hasConflicts2,
|
|
23631
|
+
conflictFiles: conflictFiles2,
|
|
23632
|
+
stashCount: readNumberValue(cachedGit.stashCount) ?? 0,
|
|
23633
|
+
lastCheckedAt: readNumberValue(cachedGit.lastCheckedAt) ?? Date.now()
|
|
23634
|
+
};
|
|
23635
|
+
}
|
|
23636
|
+
}
|
|
23637
|
+
const rawGit = readObjectRecord(node?.lastGit ?? node?.last_git);
|
|
23638
|
+
const gitResult = readObjectRecord(rawGit.result);
|
|
23639
|
+
const directStatus = readObjectRecord(rawGit.status);
|
|
23640
|
+
const nestedStatus = readObjectRecord(gitResult.status);
|
|
23641
|
+
const rawProbe = readObjectRecord(node?.lastProbe ?? node?.last_probe);
|
|
23642
|
+
const probeGit = readObjectRecord(rawProbe.git);
|
|
23643
|
+
const probeGitResult = readObjectRecord(probeGit.result);
|
|
23644
|
+
const probeDirectStatus = readObjectRecord(probeGit.status);
|
|
23645
|
+
const probeNestedStatus = readObjectRecord(probeGitResult.status);
|
|
23646
|
+
const status = Object.keys(directStatus).length ? directStatus : Object.keys(nestedStatus).length ? nestedStatus : Object.keys(probeDirectStatus).length ? probeDirectStatus : Object.keys(probeNestedStatus).length ? probeNestedStatus : {};
|
|
23647
|
+
const isGitRepo = readBooleanValue(status.isGitRepo);
|
|
23648
|
+
if (!Object.keys(status).length || isGitRepo === void 0) return void 0;
|
|
23649
|
+
const conflictFiles = Array.isArray(status.conflictFiles) ? status.conflictFiles.filter((value) => typeof value === "string") : [];
|
|
23650
|
+
const conflictCount = readNumberValue(status.conflicts) ?? conflictFiles.length;
|
|
23651
|
+
const hasConflicts = readBooleanValue(status.hasConflicts) ?? conflictCount > 0;
|
|
23652
|
+
return {
|
|
23653
|
+
workspace: readStringValue(status.workspace, node?.workspace) || "",
|
|
23654
|
+
repoRoot: readStringValue(status.repoRoot, node?.repoRoot, node?.workspace) || null,
|
|
23655
|
+
isGitRepo,
|
|
23656
|
+
branch: readStringValue(status.branch) ?? null,
|
|
23657
|
+
headCommit: readStringValue(status.headCommit) ?? null,
|
|
23658
|
+
headMessage: readStringValue(status.headMessage) ?? null,
|
|
23659
|
+
upstream: readStringValue(status.upstream) ?? null,
|
|
23660
|
+
ahead: readNumberValue(status.ahead) ?? 0,
|
|
23661
|
+
behind: readNumberValue(status.behind) ?? 0,
|
|
23662
|
+
staged: readNumberValue(status.staged) ?? 0,
|
|
23663
|
+
modified: readNumberValue(status.modified) ?? 0,
|
|
23664
|
+
untracked: readNumberValue(status.untracked) ?? 0,
|
|
23665
|
+
deleted: readNumberValue(status.deleted) ?? 0,
|
|
23666
|
+
renamed: readNumberValue(status.renamed) ?? 0,
|
|
23667
|
+
hasConflicts,
|
|
23668
|
+
conflictFiles,
|
|
23669
|
+
stashCount: readNumberValue(status.stashCount) ?? 0,
|
|
23670
|
+
lastCheckedAt: Date.now()
|
|
23671
|
+
};
|
|
23672
|
+
}
|
|
23673
|
+
function applyCachedInlineMeshNodeStatus(status, node) {
|
|
23674
|
+
const cachedStatus = readObjectRecord(node?.cachedStatus);
|
|
23675
|
+
const git = buildCachedInlineMeshGitStatus(node);
|
|
23676
|
+
const error = readStringValue(cachedStatus.error, node?.error);
|
|
23677
|
+
const health = readStringValue(cachedStatus.health, node?.health);
|
|
23678
|
+
const machineStatus = readStringValue(cachedStatus.machineStatus, node?.machineStatus);
|
|
23679
|
+
if (!git && !error && !health) return false;
|
|
23680
|
+
if (!machineStatus && !git && !error) return false;
|
|
23681
|
+
if (git) status.git = git;
|
|
23682
|
+
if (error) status.error = error;
|
|
23683
|
+
if (health) {
|
|
23684
|
+
status.health = health;
|
|
23685
|
+
return true;
|
|
23686
|
+
}
|
|
23687
|
+
if (git) {
|
|
23688
|
+
const dirty = Number(git.staged || 0) + Number(git.modified || 0) + Number(git.untracked || 0) + Number(git.deleted || 0) + Number(git.renamed || 0) > 0;
|
|
23689
|
+
status.health = git.isGitRepo === false ? "degraded" : dirty ? "dirty" : "online";
|
|
23690
|
+
return true;
|
|
23691
|
+
}
|
|
23692
|
+
return false;
|
|
23693
|
+
}
|
|
23585
23694
|
async function resolveProviderTypeFromPriority(args) {
|
|
23586
23695
|
if (!args.providerPriority.length) {
|
|
23587
23696
|
return { error: `Node '${args.nodeId}' has no providerPriority policy; pass cliType explicitly or configure node.policy.providerPriority` };
|
|
@@ -23983,7 +24092,12 @@ var DaemonCommandRouter = class {
|
|
|
23983
24092
|
}
|
|
23984
24093
|
return this.inlineMeshCache.get(meshId);
|
|
23985
24094
|
}
|
|
23986
|
-
async getMeshForCommand(meshId, inlineMesh) {
|
|
24095
|
+
async getMeshForCommand(meshId, inlineMesh, options) {
|
|
24096
|
+
const preferInline = options?.preferInline === true;
|
|
24097
|
+
if (preferInline) {
|
|
24098
|
+
const cached2 = this.getCachedInlineMesh(meshId, inlineMesh);
|
|
24099
|
+
if (cached2) return { mesh: cached2, inline: true };
|
|
24100
|
+
}
|
|
23987
24101
|
try {
|
|
23988
24102
|
const { getMesh: getMesh3 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
23989
24103
|
const mesh = getMesh3(meshId);
|
|
@@ -25806,7 +25920,7 @@ ${block}`);
|
|
|
25806
25920
|
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
25807
25921
|
if (!meshId) return { success: false, error: "meshId required" };
|
|
25808
25922
|
try {
|
|
25809
|
-
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh);
|
|
25923
|
+
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
25810
25924
|
const mesh = meshRecord?.mesh;
|
|
25811
25925
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
25812
25926
|
const { getMeshQueueStats: getMeshQueueStats2, getQueue: getQueue2 } = await Promise.resolve().then(() => (init_mesh_work_queue(), mesh_work_queue_exports));
|
|
@@ -25831,6 +25945,10 @@ ${block}`);
|
|
|
25831
25945
|
activeSessions: []
|
|
25832
25946
|
};
|
|
25833
25947
|
if (node.workspace && typeof node.workspace === "string") {
|
|
25948
|
+
if (!fs10.existsSync(node.workspace) && applyCachedInlineMeshNodeStatus(status, node)) {
|
|
25949
|
+
nodeStatuses.push(status);
|
|
25950
|
+
continue;
|
|
25951
|
+
}
|
|
25834
25952
|
try {
|
|
25835
25953
|
const { execFile: execFile3 } = await import("child_process");
|
|
25836
25954
|
const { promisify: promisify3 } = await import("util");
|
|
@@ -25890,8 +26008,12 @@ ${block}`);
|
|
|
25890
26008
|
};
|
|
25891
26009
|
status.health = branch ? dirty ? "dirty" : "online" : "degraded";
|
|
25892
26010
|
} catch {
|
|
25893
|
-
status
|
|
26011
|
+
if (!applyCachedInlineMeshNodeStatus(status, node)) {
|
|
26012
|
+
status.health = "degraded";
|
|
26013
|
+
}
|
|
25894
26014
|
}
|
|
26015
|
+
} else {
|
|
26016
|
+
applyCachedInlineMeshNodeStatus(status, node);
|
|
25895
26017
|
}
|
|
25896
26018
|
nodeStatuses.push(status);
|
|
25897
26019
|
}
|