@adhdev/daemon-core 0.9.77-rc.59 → 0.9.77-rc.60
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.d.ts +0 -2
- package/dist/index.js +63 -227
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +63 -226
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
- package/src/commands/router.ts +68 -0
- package/src/index.ts +5 -2
package/dist/index.mjs
CHANGED
|
@@ -7388,231 +7388,6 @@ function buildMeshLedgerReconciliationEvidence(meshId, replicas) {
|
|
|
7388
7388
|
|
|
7389
7389
|
// src/index.ts
|
|
7390
7390
|
init_mesh_work_queue();
|
|
7391
|
-
|
|
7392
|
-
// src/mesh/mesh-visualization.ts
|
|
7393
|
-
function isDirty(git) {
|
|
7394
|
-
if (!git) return false;
|
|
7395
|
-
return git.staged + git.modified + git.untracked + git.deleted + git.renamed > 0;
|
|
7396
|
-
}
|
|
7397
|
-
function dirtyFileCount(git) {
|
|
7398
|
-
if (!git) return 0;
|
|
7399
|
-
return git.staged + git.modified + git.untracked + git.deleted + git.renamed;
|
|
7400
|
-
}
|
|
7401
|
-
function detectOrphanReasons(node, defaultBranch) {
|
|
7402
|
-
const reasons = [];
|
|
7403
|
-
const git = node.git;
|
|
7404
|
-
if (!git) {
|
|
7405
|
-
reasons.push("No git status available");
|
|
7406
|
-
return reasons;
|
|
7407
|
-
}
|
|
7408
|
-
if (!git.isGitRepo) {
|
|
7409
|
-
reasons.push("Not a git repository");
|
|
7410
|
-
return reasons;
|
|
7411
|
-
}
|
|
7412
|
-
if (git.branch === null && git.headCommit) {
|
|
7413
|
-
reasons.push("Detached HEAD");
|
|
7414
|
-
}
|
|
7415
|
-
if (git.branch && !git.upstream) {
|
|
7416
|
-
if (defaultBranch && git.branch !== defaultBranch) {
|
|
7417
|
-
reasons.push(`No upstream: ${git.branch}`);
|
|
7418
|
-
}
|
|
7419
|
-
}
|
|
7420
|
-
if (git.branch && git.upstream === null && defaultBranch && git.branch !== defaultBranch) {
|
|
7421
|
-
if (!reasons.includes(`No upstream: ${git.branch}`)) {
|
|
7422
|
-
reasons.push(`No upstream: ${git.branch}`);
|
|
7423
|
-
}
|
|
7424
|
-
}
|
|
7425
|
-
if (node.error) {
|
|
7426
|
-
reasons.push(`Error: ${node.error}`);
|
|
7427
|
-
}
|
|
7428
|
-
return reasons;
|
|
7429
|
-
}
|
|
7430
|
-
function nodeHealthPriority(health) {
|
|
7431
|
-
switch (health) {
|
|
7432
|
-
case "online":
|
|
7433
|
-
return 0;
|
|
7434
|
-
case "dirty":
|
|
7435
|
-
return 1;
|
|
7436
|
-
case "degraded":
|
|
7437
|
-
return 2;
|
|
7438
|
-
case "wrong_branch":
|
|
7439
|
-
return 3;
|
|
7440
|
-
case "offline":
|
|
7441
|
-
return 4;
|
|
7442
|
-
case "unknown":
|
|
7443
|
-
return 5;
|
|
7444
|
-
default:
|
|
7445
|
-
return 5;
|
|
7446
|
-
}
|
|
7447
|
-
}
|
|
7448
|
-
function pickDominantHealth(healths) {
|
|
7449
|
-
if (healths.length === 0) return "unknown";
|
|
7450
|
-
return healths.reduce(
|
|
7451
|
-
(best, h) => nodeHealthPriority(h) > nodeHealthPriority(best) ? h : best
|
|
7452
|
-
);
|
|
7453
|
-
}
|
|
7454
|
-
function buildMeshGraph(status) {
|
|
7455
|
-
const nodes = [];
|
|
7456
|
-
const edges = [];
|
|
7457
|
-
const warnings = [];
|
|
7458
|
-
const branchToNodeIds = /* @__PURE__ */ new Map();
|
|
7459
|
-
for (const nodeStatus of status.nodes) {
|
|
7460
|
-
const git = nodeStatus.git;
|
|
7461
|
-
const branch = git?.branch || null;
|
|
7462
|
-
const orphanReasons = detectOrphanReasons(nodeStatus, null);
|
|
7463
|
-
const dirty = isDirty(git);
|
|
7464
|
-
const dfc = dirtyFileCount(git);
|
|
7465
|
-
let type = "worktreeNode";
|
|
7466
|
-
if (orphanReasons.length > 0) {
|
|
7467
|
-
type = "orphanNode";
|
|
7468
|
-
}
|
|
7469
|
-
const graphNode = {
|
|
7470
|
-
id: nodeStatus.nodeId,
|
|
7471
|
-
type,
|
|
7472
|
-
label: nodeStatus.machineLabel || nodeStatus.nodeId.slice(0, 8),
|
|
7473
|
-
workspace: nodeStatus.workspace,
|
|
7474
|
-
branch,
|
|
7475
|
-
health: nodeStatus.health,
|
|
7476
|
-
ahead: git?.ahead ?? 0,
|
|
7477
|
-
behind: git?.behind ?? 0,
|
|
7478
|
-
dirty,
|
|
7479
|
-
dirtyFiles: dfc,
|
|
7480
|
-
hasConflicts: git?.hasConflicts ?? false,
|
|
7481
|
-
activeSessionCount: nodeStatus.activeSessions?.length ?? 0,
|
|
7482
|
-
activeSessions: nodeStatus.activeSessions ?? [],
|
|
7483
|
-
providers: nodeStatus.providers ?? [],
|
|
7484
|
-
isOrphan: orphanReasons.length > 0,
|
|
7485
|
-
orphanReasons,
|
|
7486
|
-
source: nodeStatus
|
|
7487
|
-
};
|
|
7488
|
-
nodes.push(graphNode);
|
|
7489
|
-
if (branch) {
|
|
7490
|
-
const list = branchToNodeIds.get(branch) ?? [];
|
|
7491
|
-
list.push(graphNode.id);
|
|
7492
|
-
branchToNodeIds.set(branch, list);
|
|
7493
|
-
}
|
|
7494
|
-
}
|
|
7495
|
-
const branchUpstreamCounts = /* @__PURE__ */ new Map();
|
|
7496
|
-
for (const n of status.nodes) {
|
|
7497
|
-
const b = n.git?.branch;
|
|
7498
|
-
const upstream = n.git?.upstream;
|
|
7499
|
-
if (b && upstream) {
|
|
7500
|
-
branchUpstreamCounts.set(b, (branchUpstreamCounts.get(b) ?? 0) + 1);
|
|
7501
|
-
}
|
|
7502
|
-
}
|
|
7503
|
-
let inferredDefaultBranch = null;
|
|
7504
|
-
let bestCount = 0;
|
|
7505
|
-
for (const [b, count] of branchUpstreamCounts) {
|
|
7506
|
-
if (count > bestCount) {
|
|
7507
|
-
bestCount = count;
|
|
7508
|
-
inferredDefaultBranch = b;
|
|
7509
|
-
}
|
|
7510
|
-
}
|
|
7511
|
-
const defaultBranchNodeId = inferredDefaultBranch ? `__branch_${inferredDefaultBranch}` : null;
|
|
7512
|
-
if (defaultBranchNodeId && inferredDefaultBranch) {
|
|
7513
|
-
const branchNodes = branchToNodeIds.get(inferredDefaultBranch) ?? [];
|
|
7514
|
-
const branchHealths = branchNodes.map(
|
|
7515
|
-
(id) => nodes.find((n) => n.id === id).health
|
|
7516
|
-
);
|
|
7517
|
-
const defaultNode = {
|
|
7518
|
-
id: defaultBranchNodeId,
|
|
7519
|
-
type: "defaultBranchNode",
|
|
7520
|
-
label: inferredDefaultBranch,
|
|
7521
|
-
workspace: "",
|
|
7522
|
-
branch: inferredDefaultBranch,
|
|
7523
|
-
health: pickDominantHealth(branchHealths),
|
|
7524
|
-
ahead: 0,
|
|
7525
|
-
behind: 0,
|
|
7526
|
-
dirty: false,
|
|
7527
|
-
dirtyFiles: 0,
|
|
7528
|
-
hasConflicts: false,
|
|
7529
|
-
activeSessionCount: 0,
|
|
7530
|
-
activeSessions: [],
|
|
7531
|
-
providers: [],
|
|
7532
|
-
isOrphan: false,
|
|
7533
|
-
orphanReasons: [],
|
|
7534
|
-
nextStepHint: branchNodes.length > 0 ? `${branchNodes.length} node(s) on default branch` : void 0,
|
|
7535
|
-
source: {
|
|
7536
|
-
nodeId: defaultBranchNodeId,
|
|
7537
|
-
machineLabel: inferredDefaultBranch,
|
|
7538
|
-
workspace: "",
|
|
7539
|
-
health: "online",
|
|
7540
|
-
providers: [],
|
|
7541
|
-
activeSessions: []
|
|
7542
|
-
}
|
|
7543
|
-
};
|
|
7544
|
-
nodes.push(defaultNode);
|
|
7545
|
-
const seenBranches = /* @__PURE__ */ new Set();
|
|
7546
|
-
for (const n of nodes) {
|
|
7547
|
-
if (n.type === "defaultBranchNode") continue;
|
|
7548
|
-
if (!n.branch) continue;
|
|
7549
|
-
if (n.branch === inferredDefaultBranch) {
|
|
7550
|
-
edges.push({
|
|
7551
|
-
id: `${defaultBranchNodeId}--${n.id}`,
|
|
7552
|
-
source: defaultBranchNodeId,
|
|
7553
|
-
target: n.id,
|
|
7554
|
-
type: "parentBranch",
|
|
7555
|
-
label: "default"
|
|
7556
|
-
});
|
|
7557
|
-
continue;
|
|
7558
|
-
}
|
|
7559
|
-
if (seenBranches.has(n.branch)) continue;
|
|
7560
|
-
seenBranches.add(n.branch);
|
|
7561
|
-
edges.push({
|
|
7562
|
-
id: `${defaultBranchNodeId}--branch_${n.branch}`,
|
|
7563
|
-
source: defaultBranchNodeId,
|
|
7564
|
-
target: n.branch,
|
|
7565
|
-
type: "parentBranch",
|
|
7566
|
-
label: n.branch
|
|
7567
|
-
});
|
|
7568
|
-
}
|
|
7569
|
-
}
|
|
7570
|
-
for (const [branch, ids] of branchToNodeIds) {
|
|
7571
|
-
if (ids.length < 2) continue;
|
|
7572
|
-
for (let i = 1; i < ids.length; i++) {
|
|
7573
|
-
edges.push({
|
|
7574
|
-
id: `wt_${ids[0]}--${ids[i]}`,
|
|
7575
|
-
source: ids[0],
|
|
7576
|
-
target: ids[i],
|
|
7577
|
-
type: "worktreeLink",
|
|
7578
|
-
label: branch
|
|
7579
|
-
});
|
|
7580
|
-
}
|
|
7581
|
-
}
|
|
7582
|
-
const orphanCount = nodes.filter((n) => n.isOrphan).length;
|
|
7583
|
-
if (orphanCount > 0) {
|
|
7584
|
-
warnings.push(`${orphanCount} orphan node(s) detected`);
|
|
7585
|
-
}
|
|
7586
|
-
const conflictCount = nodes.filter((n) => n.hasConflicts).length;
|
|
7587
|
-
if (conflictCount > 0) {
|
|
7588
|
-
warnings.push(`${conflictCount} node(s) with merge conflicts`);
|
|
7589
|
-
}
|
|
7590
|
-
const offlineCount = nodes.filter((n) => n.health === "offline").length;
|
|
7591
|
-
if (offlineCount > 0) {
|
|
7592
|
-
warnings.push(`${offlineCount} node(s) offline`);
|
|
7593
|
-
}
|
|
7594
|
-
const stats = {
|
|
7595
|
-
totalNodes: status.nodes.length,
|
|
7596
|
-
onlineNodes: status.nodes.filter((n) => n.health === "online").length,
|
|
7597
|
-
dirtyNodes: nodes.filter((n) => n.dirty).length,
|
|
7598
|
-
orphanNodes: orphanCount,
|
|
7599
|
-
errorNodes: status.nodes.filter((n) => !!n.error).length,
|
|
7600
|
-
offlineNodes: offlineCount,
|
|
7601
|
-
totalActiveSessions: status.nodes.reduce((sum, n) => sum + (n.activeSessions?.length ?? 0), 0)
|
|
7602
|
-
};
|
|
7603
|
-
return {
|
|
7604
|
-
meshId: status.meshId,
|
|
7605
|
-
meshName: status.meshName,
|
|
7606
|
-
repoIdentity: status.repoIdentity,
|
|
7607
|
-
refreshedAt: status.refreshedAt,
|
|
7608
|
-
nodes,
|
|
7609
|
-
edges,
|
|
7610
|
-
stats,
|
|
7611
|
-
warnings
|
|
7612
|
-
};
|
|
7613
|
-
}
|
|
7614
|
-
|
|
7615
|
-
// src/index.ts
|
|
7616
7391
|
init_mesh_events();
|
|
7617
7392
|
|
|
7618
7393
|
// src/mesh/p2p-relay-failure.ts
|
|
@@ -25957,6 +25732,69 @@ ${block}`);
|
|
|
25957
25732
|
return { success: false, error: e.message };
|
|
25958
25733
|
}
|
|
25959
25734
|
}
|
|
25735
|
+
case "mesh_status": {
|
|
25736
|
+
const meshId = typeof args?.meshId === "string" ? args.meshId.trim() : "";
|
|
25737
|
+
if (!meshId) return { success: false, error: "meshId required" };
|
|
25738
|
+
try {
|
|
25739
|
+
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh);
|
|
25740
|
+
const mesh = meshRecord?.mesh;
|
|
25741
|
+
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
25742
|
+
const { getMeshQueueStats: getMeshQueueStats2, getQueue: getQueue2 } = await Promise.resolve().then(() => (init_mesh_work_queue(), mesh_work_queue_exports));
|
|
25743
|
+
const queue = getQueue2(meshId);
|
|
25744
|
+
const queueSummary = getMeshQueueStats2(meshId);
|
|
25745
|
+
const { readLedgerEntries: readLedgerEntries2, getLedgerSummary: getLedgerSummary2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
25746
|
+
const ledgerEntries = readLedgerEntries2(meshId, { tail: 20 });
|
|
25747
|
+
const ledgerSummary = getLedgerSummary2(meshId);
|
|
25748
|
+
const nodeStatuses = [];
|
|
25749
|
+
for (const node of mesh.nodes || []) {
|
|
25750
|
+
const status = {
|
|
25751
|
+
nodeId: node.id || node.nodeId,
|
|
25752
|
+
workspace: node.workspace,
|
|
25753
|
+
repoRoot: node.repoRoot,
|
|
25754
|
+
isLocalWorktree: node.isLocalWorktree,
|
|
25755
|
+
worktreeBranch: node.worktreeBranch,
|
|
25756
|
+
daemonId: node.daemonId,
|
|
25757
|
+
machineId: node.machineId,
|
|
25758
|
+
health: "unknown"
|
|
25759
|
+
};
|
|
25760
|
+
if (node.workspace && typeof node.workspace === "string") {
|
|
25761
|
+
try {
|
|
25762
|
+
const { execFile: execFile3 } = await import("child_process");
|
|
25763
|
+
const { promisify: promisify3 } = await import("util");
|
|
25764
|
+
const execFileAsync3 = promisify3(execFile3);
|
|
25765
|
+
const branch = await execFileAsync3("git", ["-C", node.workspace, "branch", "--show-current"], {
|
|
25766
|
+
encoding: "utf8",
|
|
25767
|
+
timeout: 1e4
|
|
25768
|
+
}).then((r) => r.stdout.trim()).catch(() => "");
|
|
25769
|
+
const porc = await execFileAsync3("git", ["-C", node.workspace, "status", "--porcelain"], {
|
|
25770
|
+
encoding: "utf8",
|
|
25771
|
+
timeout: 1e4
|
|
25772
|
+
}).then((r) => r.stdout.trim()).catch(() => "");
|
|
25773
|
+
const dirty = porc.length > 0;
|
|
25774
|
+
status.branch = branch;
|
|
25775
|
+
status.isDirty = dirty;
|
|
25776
|
+
status.uncommittedChanges = porc ? porc.split("\n").filter(Boolean).length : 0;
|
|
25777
|
+
status.health = branch ? dirty ? "dirty" : "online" : "degraded";
|
|
25778
|
+
} catch {
|
|
25779
|
+
status.health = "degraded";
|
|
25780
|
+
}
|
|
25781
|
+
}
|
|
25782
|
+
nodeStatuses.push(status);
|
|
25783
|
+
}
|
|
25784
|
+
return {
|
|
25785
|
+
success: true,
|
|
25786
|
+
meshId: mesh.id,
|
|
25787
|
+
meshName: mesh.name,
|
|
25788
|
+
repoIdentity: mesh.repoIdentity,
|
|
25789
|
+
defaultBranch: mesh.defaultBranch,
|
|
25790
|
+
nodes: nodeStatuses,
|
|
25791
|
+
queue: { tasks: queue, summary: queueSummary },
|
|
25792
|
+
ledger: { entries: ledgerEntries, summary: ledgerSummary }
|
|
25793
|
+
};
|
|
25794
|
+
} catch (e) {
|
|
25795
|
+
return { success: false, error: e.message };
|
|
25796
|
+
}
|
|
25797
|
+
}
|
|
25960
25798
|
default:
|
|
25961
25799
|
break;
|
|
25962
25800
|
}
|
|
@@ -34032,7 +33870,6 @@ export {
|
|
|
34032
33870
|
buildChatTailDeliverySignature,
|
|
34033
33871
|
buildCoordinatorSystemPrompt,
|
|
34034
33872
|
buildMachineInfo,
|
|
34035
|
-
buildMeshGraph,
|
|
34036
33873
|
buildMeshLedgerReconciliationEvidence,
|
|
34037
33874
|
buildMeshLedgerReplicaEvidence,
|
|
34038
33875
|
buildP2pRelayFailurePayload,
|