@adhdev/daemon-core 0.9.82-rc.352 → 0.9.82-rc.353
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/commands/router.d.ts +12 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +426 -346
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +423 -346
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/commands/cli-manager.ts +13 -4
- package/src/commands/router.ts +133 -33
- package/src/index.ts +5 -0
package/dist/index.js
CHANGED
|
@@ -316,10 +316,10 @@ function readInjected(value) {
|
|
|
316
316
|
}
|
|
317
317
|
function getDaemonBuildInfo() {
|
|
318
318
|
if (cached) return cached;
|
|
319
|
-
const commit = readInjected(true ? "
|
|
320
|
-
const commitShort = readInjected(true ? "
|
|
321
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
322
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
319
|
+
const commit = readInjected(true ? "a680b74d9b940b82f691ebb85a725a1a72445bfc" : void 0) ?? "unknown";
|
|
320
|
+
const commitShort = readInjected(true ? "a680b74d" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
321
|
+
const version = readInjected(true ? "0.9.82-rc.353" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
322
|
+
const builtAt = readInjected(true ? "2026-06-22T09:11:13.499Z" : void 0);
|
|
323
323
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
324
324
|
return cached;
|
|
325
325
|
}
|
|
@@ -2708,6 +2708,257 @@ var init_mesh_config = __esm({
|
|
|
2708
2708
|
}
|
|
2709
2709
|
});
|
|
2710
2710
|
|
|
2711
|
+
// ../mesh-shared/dist/index.mjs
|
|
2712
|
+
function readRecord(value) {
|
|
2713
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
2714
|
+
}
|
|
2715
|
+
function readString3(...values) {
|
|
2716
|
+
for (const value of values) {
|
|
2717
|
+
if (typeof value !== "string") continue;
|
|
2718
|
+
const trimmed = value.trim();
|
|
2719
|
+
if (trimmed) return trimmed;
|
|
2720
|
+
}
|
|
2721
|
+
return void 0;
|
|
2722
|
+
}
|
|
2723
|
+
function readNumber(...values) {
|
|
2724
|
+
for (const value of values) {
|
|
2725
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
2726
|
+
}
|
|
2727
|
+
return void 0;
|
|
2728
|
+
}
|
|
2729
|
+
function readBoolean(...values) {
|
|
2730
|
+
for (const value of values) {
|
|
2731
|
+
if (typeof value === "boolean") return value;
|
|
2732
|
+
}
|
|
2733
|
+
return void 0;
|
|
2734
|
+
}
|
|
2735
|
+
function joinRepoPath(root, relativePath) {
|
|
2736
|
+
const normalizedRoot = typeof root === "string" ? root.trim().replace(/[\\/]+$/, "") : "";
|
|
2737
|
+
const normalizedPath = typeof relativePath === "string" ? relativePath.trim() : "";
|
|
2738
|
+
if (!normalizedPath) return void 0;
|
|
2739
|
+
if (/^(?:[A-Za-z]:[\\/]|\/)/.test(normalizedPath)) return normalizedPath;
|
|
2740
|
+
if (!normalizedRoot) return void 0;
|
|
2741
|
+
return `${normalizedRoot}/${normalizedPath.replace(/^[\\/]+/, "")}`;
|
|
2742
|
+
}
|
|
2743
|
+
function scoreGitUpstreamFreshness(status) {
|
|
2744
|
+
switch (status) {
|
|
2745
|
+
case "fresh":
|
|
2746
|
+
return 30;
|
|
2747
|
+
case "no_upstream":
|
|
2748
|
+
return 4;
|
|
2749
|
+
case "unchecked":
|
|
2750
|
+
case void 0:
|
|
2751
|
+
return 0;
|
|
2752
|
+
case "stale":
|
|
2753
|
+
return -10;
|
|
2754
|
+
case "unavailable":
|
|
2755
|
+
return -15;
|
|
2756
|
+
default:
|
|
2757
|
+
return 0;
|
|
2758
|
+
}
|
|
2759
|
+
}
|
|
2760
|
+
function readGitSubmodules(value, parentRepoRoot) {
|
|
2761
|
+
if (!Array.isArray(value)) return void 0;
|
|
2762
|
+
const submodules = value.map((entry) => {
|
|
2763
|
+
const submodule = readRecord(entry);
|
|
2764
|
+
const path42 = readString3(submodule.path);
|
|
2765
|
+
const commit = readString3(submodule.commit);
|
|
2766
|
+
const repoPath = readString3(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path42);
|
|
2767
|
+
if (!path42 || !commit) return null;
|
|
2768
|
+
const result = {
|
|
2769
|
+
path: path42,
|
|
2770
|
+
commit,
|
|
2771
|
+
dirty: readBoolean(submodule.dirty) ?? false,
|
|
2772
|
+
outOfSync: readBoolean(submodule.outOfSync, submodule.out_of_sync) ?? false,
|
|
2773
|
+
lastCheckedAt: readNumber(submodule.lastCheckedAt, submodule.last_checked_at) ?? Date.now()
|
|
2774
|
+
};
|
|
2775
|
+
if (repoPath) result.repoPath = repoPath;
|
|
2776
|
+
const error = readString3(submodule.error);
|
|
2777
|
+
if (error) result.error = error;
|
|
2778
|
+
return result;
|
|
2779
|
+
}).filter((entry) => entry !== null);
|
|
2780
|
+
return submodules.length > 0 ? submodules : void 0;
|
|
2781
|
+
}
|
|
2782
|
+
function hasGitStatusEvidence(status) {
|
|
2783
|
+
return readBoolean(status.isGitRepo) !== void 0 || Boolean(readString3(status.branch, status.upstream, status.upstreamStatus, status.upstream_status, status.headCommit)) || Boolean(readString3(status.repoRoot, status.repo_root, status.workspace)) || readNumber(
|
|
2784
|
+
status.ahead,
|
|
2785
|
+
status.behind,
|
|
2786
|
+
status.staged,
|
|
2787
|
+
status.modified,
|
|
2788
|
+
status.untracked,
|
|
2789
|
+
status.deleted,
|
|
2790
|
+
status.renamed,
|
|
2791
|
+
status.lastCheckedAt,
|
|
2792
|
+
status.last_checked_at
|
|
2793
|
+
) !== void 0 || Array.isArray(status.submodules) && status.submodules.length > 0;
|
|
2794
|
+
}
|
|
2795
|
+
function normalizeGitStatus(status, node, options) {
|
|
2796
|
+
const explicitIsGitRepo = readBoolean(status.isGitRepo);
|
|
2797
|
+
if (!Object.keys(status).length || !hasGitStatusEvidence(status)) return void 0;
|
|
2798
|
+
const isGitRepo = explicitIsGitRepo ?? true;
|
|
2799
|
+
const conflictFiles = Array.isArray(status.conflictFiles) ? status.conflictFiles.filter((entry) => typeof entry === "string") : [];
|
|
2800
|
+
const conflictCount = readNumber(status.conflicts) ?? conflictFiles.length;
|
|
2801
|
+
const hasConflicts = readBoolean(status.hasConflicts) ?? conflictCount > 0;
|
|
2802
|
+
const repoRoot = readString3(status.repoRoot, status.repo_root, node.repoRoot, node.repo_root, status.workspace, node.workspace) || void 0;
|
|
2803
|
+
const submodules = readGitSubmodules(status.submodules, repoRoot);
|
|
2804
|
+
const upstreamStatus = readString3(status.upstreamStatus, status.upstream_status);
|
|
2805
|
+
const upstreamFetchedAt = readNumber(status.upstreamFetchedAt, status.upstream_fetched_at);
|
|
2806
|
+
const upstreamFetchError = readString3(status.upstreamFetchError, status.upstream_fetch_error);
|
|
2807
|
+
const error = readString3(status.error);
|
|
2808
|
+
const staged = readNumber(status.staged) ?? 0;
|
|
2809
|
+
const modified = readNumber(status.modified) ?? 0;
|
|
2810
|
+
const untracked = readNumber(status.untracked) ?? 0;
|
|
2811
|
+
const deleted = readNumber(status.deleted) ?? 0;
|
|
2812
|
+
const renamed = readNumber(status.renamed) ?? 0;
|
|
2813
|
+
return {
|
|
2814
|
+
workspace: readString3(status.workspace, node.workspace) || "",
|
|
2815
|
+
repoRoot: repoRoot ?? null,
|
|
2816
|
+
isGitRepo,
|
|
2817
|
+
branch: readString3(status.branch) ?? null,
|
|
2818
|
+
headCommit: readString3(status.headCommit) ?? null,
|
|
2819
|
+
headMessage: readString3(status.headMessage) ?? null,
|
|
2820
|
+
upstream: readString3(status.upstream) ?? null,
|
|
2821
|
+
upstreamStatus: upstreamStatus ?? "unchecked",
|
|
2822
|
+
...upstreamFetchedAt !== void 0 ? { upstreamFetchedAt } : {},
|
|
2823
|
+
...upstreamFetchError ? { upstreamFetchError } : {},
|
|
2824
|
+
ahead: readNumber(status.ahead) ?? 0,
|
|
2825
|
+
behind: readNumber(status.behind) ?? 0,
|
|
2826
|
+
staged,
|
|
2827
|
+
modified,
|
|
2828
|
+
untracked,
|
|
2829
|
+
deleted,
|
|
2830
|
+
renamed,
|
|
2831
|
+
dirty: readBoolean(status.dirty, status.isDirty, status.is_dirty) ?? (staged + modified + untracked + deleted + renamed > 0 || hasConflicts),
|
|
2832
|
+
hasConflicts,
|
|
2833
|
+
conflictFiles,
|
|
2834
|
+
stashCount: readNumber(status.stashCount, status.stash_count) ?? 0,
|
|
2835
|
+
lastCheckedAt: options?.lastCheckedAt ?? readNumber(status.lastCheckedAt, status.last_checked_at) ?? Date.now(),
|
|
2836
|
+
...submodules ? { submodules } : {},
|
|
2837
|
+
...error ? { error } : {}
|
|
2838
|
+
};
|
|
2839
|
+
}
|
|
2840
|
+
function scoreGitStatusCandidate(git) {
|
|
2841
|
+
if (!git) return Number.NEGATIVE_INFINITY;
|
|
2842
|
+
let score = 0;
|
|
2843
|
+
if (git.isGitRepo === true) score += 50;
|
|
2844
|
+
if (git.isGitRepo === false) score -= 10;
|
|
2845
|
+
if (git.branch) score += 20;
|
|
2846
|
+
if (git.headCommit) score += 20;
|
|
2847
|
+
if (git.upstream) score += 10;
|
|
2848
|
+
score += scoreGitUpstreamFreshness(git.upstreamStatus);
|
|
2849
|
+
if (typeof git.ahead === "number") score += 2;
|
|
2850
|
+
if (typeof git.behind === "number") score += 2;
|
|
2851
|
+
if (Array.isArray(git.submodules) && git.submodules.length > 0) score += 4 + git.submodules.length;
|
|
2852
|
+
if (git.error) score -= 20;
|
|
2853
|
+
return score;
|
|
2854
|
+
}
|
|
2855
|
+
function pickBestTransitGitStatus(node, options) {
|
|
2856
|
+
const rawGit = readRecord(node.lastGit ?? node.last_git);
|
|
2857
|
+
const gitResult = readRecord(rawGit.result);
|
|
2858
|
+
const directStatus = readRecord(rawGit.status);
|
|
2859
|
+
const nestedStatus = readRecord(gitResult.status);
|
|
2860
|
+
const rawProbe = readRecord(node.lastProbe ?? node.last_probe);
|
|
2861
|
+
const probeGit = readRecord(rawProbe.git);
|
|
2862
|
+
const probeGitResult = readRecord(probeGit.result);
|
|
2863
|
+
const probeDirectStatus = readRecord(probeGit.status);
|
|
2864
|
+
const probeNestedStatus = readRecord(probeGitResult.status);
|
|
2865
|
+
const lastCheckedAt = options?.lastCheckedAt;
|
|
2866
|
+
let best = null;
|
|
2867
|
+
for (const status of [directStatus, nestedStatus, probeDirectStatus, probeNestedStatus]) {
|
|
2868
|
+
const normalized = normalizeGitStatus(status, node, { lastCheckedAt: lastCheckedAt ?? Date.now() });
|
|
2869
|
+
if (!normalized) continue;
|
|
2870
|
+
const score = scoreGitStatusCandidate(normalized);
|
|
2871
|
+
if (!best || score > best.score) best = { git: normalized, score };
|
|
2872
|
+
}
|
|
2873
|
+
return best?.git;
|
|
2874
|
+
}
|
|
2875
|
+
function normalizeMeshNodeId(node) {
|
|
2876
|
+
const record = node && typeof node === "object" ? node : {};
|
|
2877
|
+
return readString3(record.id, record.nodeId, record.node_id);
|
|
2878
|
+
}
|
|
2879
|
+
function meshNodeIdMatches(node, candidateId) {
|
|
2880
|
+
if (!candidateId) return false;
|
|
2881
|
+
const trimmed = candidateId.trim();
|
|
2882
|
+
if (!trimmed) return false;
|
|
2883
|
+
return normalizeMeshNodeId(node) === trimmed;
|
|
2884
|
+
}
|
|
2885
|
+
function machineCoreFromDaemonId(id) {
|
|
2886
|
+
const trimmed = readString3(id);
|
|
2887
|
+
if (!trimmed) return void 0;
|
|
2888
|
+
for (const prefix of DAEMON_ID_PREFIXES) {
|
|
2889
|
+
if (trimmed.startsWith(prefix)) {
|
|
2890
|
+
const core = trimmed.slice(prefix.length).trim();
|
|
2891
|
+
return core || void 0;
|
|
2892
|
+
}
|
|
2893
|
+
}
|
|
2894
|
+
return trimmed;
|
|
2895
|
+
}
|
|
2896
|
+
function daemonIdsEquivalent(a, b) {
|
|
2897
|
+
const coreA = machineCoreFromDaemonId(a);
|
|
2898
|
+
const coreB = machineCoreFromDaemonId(b);
|
|
2899
|
+
if (!coreA || !coreB) return false;
|
|
2900
|
+
return coreA === coreB;
|
|
2901
|
+
}
|
|
2902
|
+
function expandDaemonIdForms(ids) {
|
|
2903
|
+
const list = Array.isArray(ids) ? ids : ids != null ? [ids] : [];
|
|
2904
|
+
const out = [];
|
|
2905
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2906
|
+
const add = (value) => {
|
|
2907
|
+
if (!value || seen.has(value)) return;
|
|
2908
|
+
seen.add(value);
|
|
2909
|
+
out.push(value);
|
|
2910
|
+
};
|
|
2911
|
+
for (const raw of list) add(readString3(raw));
|
|
2912
|
+
for (const raw of list) {
|
|
2913
|
+
const core = machineCoreFromDaemonId(readString3(raw));
|
|
2914
|
+
if (!core || !core.startsWith("mach_")) continue;
|
|
2915
|
+
add(core);
|
|
2916
|
+
for (const prefix of DAEMON_ID_PREFIXES) add(`${prefix}${core}`);
|
|
2917
|
+
}
|
|
2918
|
+
return out;
|
|
2919
|
+
}
|
|
2920
|
+
function summarizeGitShape(status) {
|
|
2921
|
+
const record = readRecord(status);
|
|
2922
|
+
if (!Object.keys(record).length) return null;
|
|
2923
|
+
const submodules = Array.isArray(record.submodules) ? record.submodules.map((entry) => {
|
|
2924
|
+
const sub = readRecord(entry);
|
|
2925
|
+
return {
|
|
2926
|
+
path: readString3(sub.path) ?? null,
|
|
2927
|
+
commit: readString3(sub.commit)?.slice(0, 12) ?? null,
|
|
2928
|
+
dirty: readBoolean(sub.dirty) ?? false,
|
|
2929
|
+
outOfSync: readBoolean(sub.outOfSync, sub.out_of_sync) ?? false
|
|
2930
|
+
};
|
|
2931
|
+
}) : [];
|
|
2932
|
+
return {
|
|
2933
|
+
isGitRepo: readBoolean(record.isGitRepo),
|
|
2934
|
+
workspace: readString3(record.workspace) ?? null,
|
|
2935
|
+
repoRoot: readString3(record.repoRoot, record.repo_root) ?? null,
|
|
2936
|
+
branch: readString3(record.branch) ?? null,
|
|
2937
|
+
upstream: readString3(record.upstream) ?? null,
|
|
2938
|
+
upstreamStatus: readString3(record.upstreamStatus, record.upstream_status) ?? null,
|
|
2939
|
+
headCommit: readString3(record.headCommit, record.head_commit)?.slice(0, 12) ?? null,
|
|
2940
|
+
ahead: readNumber(record.ahead) ?? null,
|
|
2941
|
+
behind: readNumber(record.behind) ?? null,
|
|
2942
|
+
dirtyCounts: {
|
|
2943
|
+
staged: readNumber(record.staged) ?? 0,
|
|
2944
|
+
modified: readNumber(record.modified) ?? 0,
|
|
2945
|
+
untracked: readNumber(record.untracked) ?? 0,
|
|
2946
|
+
deleted: readNumber(record.deleted) ?? 0,
|
|
2947
|
+
renamed: readNumber(record.renamed) ?? 0
|
|
2948
|
+
},
|
|
2949
|
+
lastCheckedAt: readNumber(record.lastCheckedAt, record.last_checked_at) ?? null,
|
|
2950
|
+
submoduleCount: submodules.length,
|
|
2951
|
+
submodules
|
|
2952
|
+
};
|
|
2953
|
+
}
|
|
2954
|
+
var DAEMON_ID_PREFIXES;
|
|
2955
|
+
var init_dist = __esm({
|
|
2956
|
+
"../mesh-shared/dist/index.mjs"() {
|
|
2957
|
+
"use strict";
|
|
2958
|
+
DAEMON_ID_PREFIXES = ["daemon_", "standalone_"];
|
|
2959
|
+
}
|
|
2960
|
+
});
|
|
2961
|
+
|
|
2711
2962
|
// src/mesh/coordinator-prompt.ts
|
|
2712
2963
|
var coordinator_prompt_exports = {};
|
|
2713
2964
|
__export(coordinator_prompt_exports, {
|
|
@@ -6316,10 +6567,10 @@ var init_mesh_missions = __esm({
|
|
|
6316
6567
|
});
|
|
6317
6568
|
|
|
6318
6569
|
// src/mesh/mesh-refine-status.ts
|
|
6319
|
-
function
|
|
6570
|
+
function readString4(value) {
|
|
6320
6571
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
6321
6572
|
}
|
|
6322
|
-
function
|
|
6573
|
+
function readRecord2(value) {
|
|
6323
6574
|
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
6324
6575
|
}
|
|
6325
6576
|
function eventStatus(event, fallback) {
|
|
@@ -6342,7 +6593,7 @@ function instructionForStatus(status) {
|
|
|
6342
6593
|
return "Refine job failed; inspect result/finalBranchConvergenceState in mesh_task_history, fix the blocker, then rerun mesh_refine_node when ready.";
|
|
6343
6594
|
}
|
|
6344
6595
|
function mergeJob(jobs, patch) {
|
|
6345
|
-
const jobId =
|
|
6596
|
+
const jobId = readString4(patch.jobId);
|
|
6346
6597
|
if (!jobId) return;
|
|
6347
6598
|
const previous = jobs.get(jobId);
|
|
6348
6599
|
const status = patch.status || previous?.status || "running";
|
|
@@ -6360,54 +6611,54 @@ function mergeJob(jobs, patch) {
|
|
|
6360
6611
|
function buildMeshAsyncRefineJobs(args) {
|
|
6361
6612
|
const jobs = /* @__PURE__ */ new Map();
|
|
6362
6613
|
for (const entry of args.ledgerEntries || []) {
|
|
6363
|
-
const payload =
|
|
6614
|
+
const payload = readRecord2(entry.payload);
|
|
6364
6615
|
if (payload?.source !== "refine_mesh_node_async_job") continue;
|
|
6365
|
-
const refineJob =
|
|
6366
|
-
const result =
|
|
6367
|
-
const finalState =
|
|
6368
|
-
const jobId =
|
|
6616
|
+
const refineJob = readRecord2(payload.refineJob);
|
|
6617
|
+
const result = readRecord2(payload.result);
|
|
6618
|
+
const finalState = readRecord2(payload.finalBranchConvergenceState) || readRecord2(result?.finalBranchConvergenceState);
|
|
6619
|
+
const jobId = readString4(refineJob?.jobId);
|
|
6369
6620
|
if (!jobId) continue;
|
|
6370
|
-
const status = ledgerStatus(entry.kind,
|
|
6621
|
+
const status = ledgerStatus(entry.kind, readString4(refineJob?.status));
|
|
6371
6622
|
mergeJob(jobs, {
|
|
6372
6623
|
jobId,
|
|
6373
|
-
interactionId:
|
|
6624
|
+
interactionId: readString4(refineJob?.interactionId),
|
|
6374
6625
|
status,
|
|
6375
|
-
meshId:
|
|
6376
|
-
nodeId:
|
|
6377
|
-
targetNodeId:
|
|
6378
|
-
targetDaemonId:
|
|
6379
|
-
workspace:
|
|
6380
|
-
branch:
|
|
6381
|
-
into:
|
|
6382
|
-
startedAt:
|
|
6383
|
-
completedAt:
|
|
6384
|
-
retryOfJobId:
|
|
6626
|
+
meshId: readString4(refineJob?.meshId) || args.meshId,
|
|
6627
|
+
nodeId: readString4(refineJob?.nodeId) || entry.nodeId,
|
|
6628
|
+
targetNodeId: readString4(refineJob?.nodeId) || entry.nodeId,
|
|
6629
|
+
targetDaemonId: readString4(refineJob?.targetDaemonId),
|
|
6630
|
+
workspace: readString4(refineJob?.workspace),
|
|
6631
|
+
branch: readString4(result?.branch) || readString4(finalState?.branch),
|
|
6632
|
+
into: readString4(result?.into) || readString4(finalState?.baseBranch),
|
|
6633
|
+
startedAt: readString4(refineJob?.startedAt),
|
|
6634
|
+
completedAt: readString4(refineJob?.completedAt),
|
|
6635
|
+
retryOfJobId: readString4(refineJob?.retryOfJobId) || readString4(payload.retryOfJobId),
|
|
6385
6636
|
lastLedgerKind: entry.kind,
|
|
6386
6637
|
lastUpdatedAt: entry.timestamp
|
|
6387
6638
|
});
|
|
6388
6639
|
}
|
|
6389
6640
|
for (const event of args.pendingEvents || []) {
|
|
6390
|
-
const metadata =
|
|
6641
|
+
const metadata = readRecord2(event.metadataEvent);
|
|
6391
6642
|
if (metadata?.source !== "refine_mesh_node_async_job") continue;
|
|
6392
|
-
const result =
|
|
6393
|
-
const finalState =
|
|
6394
|
-
const jobId =
|
|
6643
|
+
const result = readRecord2(metadata.result);
|
|
6644
|
+
const finalState = readRecord2(result?.finalBranchConvergenceState);
|
|
6645
|
+
const jobId = readString4(metadata.jobId);
|
|
6395
6646
|
if (!jobId) continue;
|
|
6396
|
-
const status = eventStatus(event.event,
|
|
6647
|
+
const status = eventStatus(event.event, readString4(metadata.status));
|
|
6397
6648
|
mergeJob(jobs, {
|
|
6398
6649
|
jobId,
|
|
6399
|
-
interactionId:
|
|
6650
|
+
interactionId: readString4(metadata.interactionId),
|
|
6400
6651
|
...status ? { status } : {},
|
|
6401
|
-
meshId:
|
|
6402
|
-
nodeId:
|
|
6403
|
-
targetNodeId:
|
|
6404
|
-
targetDaemonId:
|
|
6405
|
-
workspace:
|
|
6406
|
-
branch:
|
|
6407
|
-
into:
|
|
6408
|
-
startedAt:
|
|
6409
|
-
completedAt:
|
|
6410
|
-
retryOfJobId:
|
|
6652
|
+
meshId: readString4(metadata.meshId) || event.meshId || args.meshId,
|
|
6653
|
+
nodeId: readString4(metadata.nodeId) || event.nodeId,
|
|
6654
|
+
targetNodeId: readString4(metadata.nodeId) || event.nodeId,
|
|
6655
|
+
targetDaemonId: readString4(metadata.targetDaemonId),
|
|
6656
|
+
workspace: readString4(metadata.workspace) || event.workspace,
|
|
6657
|
+
branch: readString4(result?.branch) || readString4(finalState?.branch),
|
|
6658
|
+
into: readString4(result?.into) || readString4(finalState?.baseBranch),
|
|
6659
|
+
startedAt: readString4(metadata.startedAt),
|
|
6660
|
+
completedAt: readString4(metadata.completedAt),
|
|
6661
|
+
retryOfJobId: readString4(metadata.retryOfJobId),
|
|
6411
6662
|
lastEvent: event.event,
|
|
6412
6663
|
lastUpdatedAt: new Date(event.queuedAt).toISOString()
|
|
6413
6664
|
});
|
|
@@ -6468,10 +6719,10 @@ var mesh_review_inbox_exports = {};
|
|
|
6468
6719
|
__export(mesh_review_inbox_exports, {
|
|
6469
6720
|
deriveMeshReviewInboxItems: () => deriveMeshReviewInboxItems
|
|
6470
6721
|
});
|
|
6471
|
-
function
|
|
6722
|
+
function readString5(value) {
|
|
6472
6723
|
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
6473
6724
|
}
|
|
6474
|
-
function
|
|
6725
|
+
function readRecord3(value) {
|
|
6475
6726
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
6476
6727
|
}
|
|
6477
6728
|
function readStringArray3(value, max) {
|
|
@@ -6481,20 +6732,20 @@ function readStringArray3(value, max) {
|
|
|
6481
6732
|
}
|
|
6482
6733
|
function isLocalNodeStatus(node) {
|
|
6483
6734
|
if (node.isLocalWorktree === true) return true;
|
|
6484
|
-
const connection =
|
|
6485
|
-
return
|
|
6735
|
+
const connection = readRecord3(node.connection);
|
|
6736
|
+
return readString5(connection?.state) === "self";
|
|
6486
6737
|
}
|
|
6487
6738
|
function readNodeConvergence(node) {
|
|
6488
|
-
const convergence =
|
|
6489
|
-
const status =
|
|
6739
|
+
const convergence = readRecord3(node.branchConvergence);
|
|
6740
|
+
const status = readString5(convergence?.status);
|
|
6490
6741
|
if (!convergence || !status) return null;
|
|
6491
6742
|
return {
|
|
6492
6743
|
status,
|
|
6493
|
-
reason:
|
|
6494
|
-
nextStep:
|
|
6744
|
+
reason: readString5(convergence.reason),
|
|
6745
|
+
nextStep: readString5(convergence.nextStep),
|
|
6495
6746
|
needsConvergence: convergence.needsConvergence === true,
|
|
6496
|
-
branch:
|
|
6497
|
-
defaultBranch:
|
|
6747
|
+
branch: readString5(convergence.branch),
|
|
6748
|
+
defaultBranch: readString5(convergence.defaultBranch)
|
|
6498
6749
|
};
|
|
6499
6750
|
}
|
|
6500
6751
|
function isMergeCandidate(convergence) {
|
|
@@ -6502,15 +6753,15 @@ function isMergeCandidate(convergence) {
|
|
|
6502
6753
|
return convergence.status === "cleanup_candidate" && convergence.reason === "clean_non_default_worktree_branch";
|
|
6503
6754
|
}
|
|
6504
6755
|
function readWorkerArtifact(value) {
|
|
6505
|
-
const worker =
|
|
6756
|
+
const worker = readRecord3(value);
|
|
6506
6757
|
if (!worker) return null;
|
|
6507
6758
|
const changed = readStringArray3(worker.changedFiles, MAX_CHANGED_FILES);
|
|
6508
6759
|
return {
|
|
6509
|
-
status:
|
|
6510
|
-
...
|
|
6760
|
+
status: readString5(worker.status) ?? "unknown",
|
|
6761
|
+
...readString5(worker.classification) ? { classification: readString5(worker.classification) } : {},
|
|
6511
6762
|
changedFiles: changed.values,
|
|
6512
6763
|
...changed.truncated ? { changedFilesTruncated: true } : {},
|
|
6513
|
-
validationResults: Array.isArray(worker.validationResults) ? worker.validationResults.map((item) =>
|
|
6764
|
+
validationResults: Array.isArray(worker.validationResults) ? worker.validationResults.map((item) => readRecord3(item)).filter((item) => item !== null) : [],
|
|
6514
6765
|
errors: readStringArray3(worker.errors, 20).values,
|
|
6515
6766
|
requiresUserAction: worker.requiresUserAction === true
|
|
6516
6767
|
};
|
|
@@ -6524,43 +6775,43 @@ function resolveNodeEvidence(nodeId, ledgerEntries) {
|
|
|
6524
6775
|
for (let i = ledgerEntries.length - 1; i >= 0; i--) {
|
|
6525
6776
|
const entry = ledgerEntries[i];
|
|
6526
6777
|
if (entry.nodeId !== nodeId || !isTerminalLedgerKind(entry.kind)) continue;
|
|
6527
|
-
const payload =
|
|
6778
|
+
const payload = readRecord3(entry.payload) ?? {};
|
|
6528
6779
|
if (!evidence.available) {
|
|
6529
6780
|
if (payload.source === "refine_mesh_node_async_job") {
|
|
6530
|
-
const result =
|
|
6531
|
-
const validationSummary =
|
|
6781
|
+
const result = readRecord3(payload.result);
|
|
6782
|
+
const validationSummary = readRecord3(result?.validationSummary);
|
|
6532
6783
|
evidence = {
|
|
6533
6784
|
available: true,
|
|
6534
6785
|
kind: entry.kind,
|
|
6535
6786
|
source: "refine_job",
|
|
6536
6787
|
timestamp: entry.timestamp,
|
|
6537
6788
|
...entry.sessionId ? { sessionId: entry.sessionId } : {},
|
|
6538
|
-
bootstrap:
|
|
6789
|
+
bootstrap: readRecord3(validationSummary?.bootstrap),
|
|
6539
6790
|
validation: validationSummary ? Object.fromEntries(Object.entries(validationSummary).filter(([key]) => key !== "bootstrap")) : null,
|
|
6540
|
-
checkpoint:
|
|
6791
|
+
checkpoint: readRecord3(result?.checkpoint),
|
|
6541
6792
|
worker: null,
|
|
6542
|
-
...
|
|
6543
|
-
...
|
|
6793
|
+
...readRecord3(payload.finalBranchConvergenceState) ?? readRecord3(result?.finalBranchConvergenceState) ? { finalBranchConvergenceState: readRecord3(payload.finalBranchConvergenceState) ?? readRecord3(result?.finalBranchConvergenceState) } : {},
|
|
6794
|
+
...readRecord3(payload.refineJob) ? { refineJob: readRecord3(payload.refineJob) } : {}
|
|
6544
6795
|
};
|
|
6545
6796
|
} else {
|
|
6546
|
-
const envelope =
|
|
6797
|
+
const envelope = readRecord3(payload.evidence);
|
|
6547
6798
|
evidence = {
|
|
6548
6799
|
available: true,
|
|
6549
6800
|
kind: entry.kind,
|
|
6550
6801
|
source: "task_completion",
|
|
6551
6802
|
timestamp: entry.timestamp,
|
|
6552
|
-
...
|
|
6803
|
+
...readString5(payload.taskId) ? { taskId: readString5(payload.taskId) } : {},
|
|
6553
6804
|
...entry.sessionId ? { sessionId: entry.sessionId } : {},
|
|
6554
6805
|
bootstrap: null,
|
|
6555
|
-
validation:
|
|
6556
|
-
checkpoint:
|
|
6806
|
+
validation: readRecord3(envelope?.validation),
|
|
6807
|
+
checkpoint: readRecord3(envelope?.checkpoint),
|
|
6557
6808
|
worker: readWorkerArtifact(envelope?.workerResult ?? payload.workerResult)
|
|
6558
6809
|
};
|
|
6559
6810
|
}
|
|
6560
6811
|
}
|
|
6561
6812
|
if (!transcriptHandle) {
|
|
6562
|
-
const envelope =
|
|
6563
|
-
transcriptHandle =
|
|
6813
|
+
const envelope = readRecord3(payload.evidence);
|
|
6814
|
+
transcriptHandle = readRecord3(envelope?.transcriptHandle);
|
|
6564
6815
|
}
|
|
6565
6816
|
if (evidence.available && transcriptHandle) break;
|
|
6566
6817
|
}
|
|
@@ -6570,11 +6821,11 @@ function hasBlockedReviewRefineResult(nodeId, ledgerEntries) {
|
|
|
6570
6821
|
for (let i = ledgerEntries.length - 1; i >= 0; i--) {
|
|
6571
6822
|
const entry = ledgerEntries[i];
|
|
6572
6823
|
if (entry.nodeId !== nodeId || !isTerminalLedgerKind(entry.kind)) continue;
|
|
6573
|
-
const payload =
|
|
6824
|
+
const payload = readRecord3(entry.payload) ?? {};
|
|
6574
6825
|
if (payload.source !== "refine_mesh_node_async_job") continue;
|
|
6575
|
-
const result =
|
|
6576
|
-
const finalState =
|
|
6577
|
-
return
|
|
6826
|
+
const result = readRecord3(payload.result);
|
|
6827
|
+
const finalState = readRecord3(payload.finalBranchConvergenceState) ?? readRecord3(result?.finalBranchConvergenceState);
|
|
6828
|
+
return readString5(finalState?.status) === "blocked_review" || readString5(result?.code) === "blocked_review";
|
|
6578
6829
|
}
|
|
6579
6830
|
return false;
|
|
6580
6831
|
}
|
|
@@ -6583,7 +6834,7 @@ function deriveMeshReviewInboxItems(args) {
|
|
|
6583
6834
|
const excludedRemoteNodeIds = [];
|
|
6584
6835
|
const refineJobs = buildMeshAsyncRefineJobs({ ledgerEntries: args.ledgerEntries });
|
|
6585
6836
|
for (const node of args.nodes) {
|
|
6586
|
-
const nodeId =
|
|
6837
|
+
const nodeId = readString5(node.nodeId) ?? readString5(node.id);
|
|
6587
6838
|
if (!nodeId) continue;
|
|
6588
6839
|
if (!isLocalNodeStatus(node)) {
|
|
6589
6840
|
excludedRemoteNodeIds.push(nodeId);
|
|
@@ -6605,8 +6856,8 @@ function deriveMeshReviewInboxItems(args) {
|
|
|
6605
6856
|
) ?? null;
|
|
6606
6857
|
items.push({
|
|
6607
6858
|
nodeId,
|
|
6608
|
-
workspace:
|
|
6609
|
-
branch: convergence.branch ??
|
|
6859
|
+
workspace: readString5(node.workspace),
|
|
6860
|
+
branch: convergence.branch ?? readString5(node.worktreeBranch),
|
|
6610
6861
|
defaultBranch: convergence.defaultBranch,
|
|
6611
6862
|
isLocalWorktree: node.isLocalWorktree === true,
|
|
6612
6863
|
reviewReason,
|
|
@@ -7817,251 +8068,6 @@ var init_mesh_fast_forward = __esm({
|
|
|
7817
8068
|
}
|
|
7818
8069
|
});
|
|
7819
8070
|
|
|
7820
|
-
// ../mesh-shared/dist/index.mjs
|
|
7821
|
-
function readRecord3(value) {
|
|
7822
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
7823
|
-
}
|
|
7824
|
-
function readString5(...values) {
|
|
7825
|
-
for (const value of values) {
|
|
7826
|
-
if (typeof value !== "string") continue;
|
|
7827
|
-
const trimmed = value.trim();
|
|
7828
|
-
if (trimmed) return trimmed;
|
|
7829
|
-
}
|
|
7830
|
-
return void 0;
|
|
7831
|
-
}
|
|
7832
|
-
function readNumber(...values) {
|
|
7833
|
-
for (const value of values) {
|
|
7834
|
-
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
7835
|
-
}
|
|
7836
|
-
return void 0;
|
|
7837
|
-
}
|
|
7838
|
-
function readBoolean(...values) {
|
|
7839
|
-
for (const value of values) {
|
|
7840
|
-
if (typeof value === "boolean") return value;
|
|
7841
|
-
}
|
|
7842
|
-
return void 0;
|
|
7843
|
-
}
|
|
7844
|
-
function joinRepoPath(root, relativePath) {
|
|
7845
|
-
const normalizedRoot = typeof root === "string" ? root.trim().replace(/[\\/]+$/, "") : "";
|
|
7846
|
-
const normalizedPath = typeof relativePath === "string" ? relativePath.trim() : "";
|
|
7847
|
-
if (!normalizedPath) return void 0;
|
|
7848
|
-
if (/^(?:[A-Za-z]:[\\/]|\/)/.test(normalizedPath)) return normalizedPath;
|
|
7849
|
-
if (!normalizedRoot) return void 0;
|
|
7850
|
-
return `${normalizedRoot}/${normalizedPath.replace(/^[\\/]+/, "")}`;
|
|
7851
|
-
}
|
|
7852
|
-
function scoreGitUpstreamFreshness(status) {
|
|
7853
|
-
switch (status) {
|
|
7854
|
-
case "fresh":
|
|
7855
|
-
return 30;
|
|
7856
|
-
case "no_upstream":
|
|
7857
|
-
return 4;
|
|
7858
|
-
case "unchecked":
|
|
7859
|
-
case void 0:
|
|
7860
|
-
return 0;
|
|
7861
|
-
case "stale":
|
|
7862
|
-
return -10;
|
|
7863
|
-
case "unavailable":
|
|
7864
|
-
return -15;
|
|
7865
|
-
default:
|
|
7866
|
-
return 0;
|
|
7867
|
-
}
|
|
7868
|
-
}
|
|
7869
|
-
function readGitSubmodules(value, parentRepoRoot) {
|
|
7870
|
-
if (!Array.isArray(value)) return void 0;
|
|
7871
|
-
const submodules = value.map((entry) => {
|
|
7872
|
-
const submodule = readRecord3(entry);
|
|
7873
|
-
const path42 = readString5(submodule.path);
|
|
7874
|
-
const commit = readString5(submodule.commit);
|
|
7875
|
-
const repoPath = readString5(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path42);
|
|
7876
|
-
if (!path42 || !commit) return null;
|
|
7877
|
-
const result = {
|
|
7878
|
-
path: path42,
|
|
7879
|
-
commit,
|
|
7880
|
-
dirty: readBoolean(submodule.dirty) ?? false,
|
|
7881
|
-
outOfSync: readBoolean(submodule.outOfSync, submodule.out_of_sync) ?? false,
|
|
7882
|
-
lastCheckedAt: readNumber(submodule.lastCheckedAt, submodule.last_checked_at) ?? Date.now()
|
|
7883
|
-
};
|
|
7884
|
-
if (repoPath) result.repoPath = repoPath;
|
|
7885
|
-
const error = readString5(submodule.error);
|
|
7886
|
-
if (error) result.error = error;
|
|
7887
|
-
return result;
|
|
7888
|
-
}).filter((entry) => entry !== null);
|
|
7889
|
-
return submodules.length > 0 ? submodules : void 0;
|
|
7890
|
-
}
|
|
7891
|
-
function hasGitStatusEvidence(status) {
|
|
7892
|
-
return readBoolean(status.isGitRepo) !== void 0 || Boolean(readString5(status.branch, status.upstream, status.upstreamStatus, status.upstream_status, status.headCommit)) || Boolean(readString5(status.repoRoot, status.repo_root, status.workspace)) || readNumber(
|
|
7893
|
-
status.ahead,
|
|
7894
|
-
status.behind,
|
|
7895
|
-
status.staged,
|
|
7896
|
-
status.modified,
|
|
7897
|
-
status.untracked,
|
|
7898
|
-
status.deleted,
|
|
7899
|
-
status.renamed,
|
|
7900
|
-
status.lastCheckedAt,
|
|
7901
|
-
status.last_checked_at
|
|
7902
|
-
) !== void 0 || Array.isArray(status.submodules) && status.submodules.length > 0;
|
|
7903
|
-
}
|
|
7904
|
-
function normalizeGitStatus(status, node, options) {
|
|
7905
|
-
const explicitIsGitRepo = readBoolean(status.isGitRepo);
|
|
7906
|
-
if (!Object.keys(status).length || !hasGitStatusEvidence(status)) return void 0;
|
|
7907
|
-
const isGitRepo = explicitIsGitRepo ?? true;
|
|
7908
|
-
const conflictFiles = Array.isArray(status.conflictFiles) ? status.conflictFiles.filter((entry) => typeof entry === "string") : [];
|
|
7909
|
-
const conflictCount = readNumber(status.conflicts) ?? conflictFiles.length;
|
|
7910
|
-
const hasConflicts = readBoolean(status.hasConflicts) ?? conflictCount > 0;
|
|
7911
|
-
const repoRoot = readString5(status.repoRoot, status.repo_root, node.repoRoot, node.repo_root, status.workspace, node.workspace) || void 0;
|
|
7912
|
-
const submodules = readGitSubmodules(status.submodules, repoRoot);
|
|
7913
|
-
const upstreamStatus = readString5(status.upstreamStatus, status.upstream_status);
|
|
7914
|
-
const upstreamFetchedAt = readNumber(status.upstreamFetchedAt, status.upstream_fetched_at);
|
|
7915
|
-
const upstreamFetchError = readString5(status.upstreamFetchError, status.upstream_fetch_error);
|
|
7916
|
-
const error = readString5(status.error);
|
|
7917
|
-
const staged = readNumber(status.staged) ?? 0;
|
|
7918
|
-
const modified = readNumber(status.modified) ?? 0;
|
|
7919
|
-
const untracked = readNumber(status.untracked) ?? 0;
|
|
7920
|
-
const deleted = readNumber(status.deleted) ?? 0;
|
|
7921
|
-
const renamed = readNumber(status.renamed) ?? 0;
|
|
7922
|
-
return {
|
|
7923
|
-
workspace: readString5(status.workspace, node.workspace) || "",
|
|
7924
|
-
repoRoot: repoRoot ?? null,
|
|
7925
|
-
isGitRepo,
|
|
7926
|
-
branch: readString5(status.branch) ?? null,
|
|
7927
|
-
headCommit: readString5(status.headCommit) ?? null,
|
|
7928
|
-
headMessage: readString5(status.headMessage) ?? null,
|
|
7929
|
-
upstream: readString5(status.upstream) ?? null,
|
|
7930
|
-
upstreamStatus: upstreamStatus ?? "unchecked",
|
|
7931
|
-
...upstreamFetchedAt !== void 0 ? { upstreamFetchedAt } : {},
|
|
7932
|
-
...upstreamFetchError ? { upstreamFetchError } : {},
|
|
7933
|
-
ahead: readNumber(status.ahead) ?? 0,
|
|
7934
|
-
behind: readNumber(status.behind) ?? 0,
|
|
7935
|
-
staged,
|
|
7936
|
-
modified,
|
|
7937
|
-
untracked,
|
|
7938
|
-
deleted,
|
|
7939
|
-
renamed,
|
|
7940
|
-
dirty: readBoolean(status.dirty, status.isDirty, status.is_dirty) ?? (staged + modified + untracked + deleted + renamed > 0 || hasConflicts),
|
|
7941
|
-
hasConflicts,
|
|
7942
|
-
conflictFiles,
|
|
7943
|
-
stashCount: readNumber(status.stashCount, status.stash_count) ?? 0,
|
|
7944
|
-
lastCheckedAt: options?.lastCheckedAt ?? readNumber(status.lastCheckedAt, status.last_checked_at) ?? Date.now(),
|
|
7945
|
-
...submodules ? { submodules } : {},
|
|
7946
|
-
...error ? { error } : {}
|
|
7947
|
-
};
|
|
7948
|
-
}
|
|
7949
|
-
function scoreGitStatusCandidate(git) {
|
|
7950
|
-
if (!git) return Number.NEGATIVE_INFINITY;
|
|
7951
|
-
let score = 0;
|
|
7952
|
-
if (git.isGitRepo === true) score += 50;
|
|
7953
|
-
if (git.isGitRepo === false) score -= 10;
|
|
7954
|
-
if (git.branch) score += 20;
|
|
7955
|
-
if (git.headCommit) score += 20;
|
|
7956
|
-
if (git.upstream) score += 10;
|
|
7957
|
-
score += scoreGitUpstreamFreshness(git.upstreamStatus);
|
|
7958
|
-
if (typeof git.ahead === "number") score += 2;
|
|
7959
|
-
if (typeof git.behind === "number") score += 2;
|
|
7960
|
-
if (Array.isArray(git.submodules) && git.submodules.length > 0) score += 4 + git.submodules.length;
|
|
7961
|
-
if (git.error) score -= 20;
|
|
7962
|
-
return score;
|
|
7963
|
-
}
|
|
7964
|
-
function pickBestTransitGitStatus(node, options) {
|
|
7965
|
-
const rawGit = readRecord3(node.lastGit ?? node.last_git);
|
|
7966
|
-
const gitResult = readRecord3(rawGit.result);
|
|
7967
|
-
const directStatus = readRecord3(rawGit.status);
|
|
7968
|
-
const nestedStatus = readRecord3(gitResult.status);
|
|
7969
|
-
const rawProbe = readRecord3(node.lastProbe ?? node.last_probe);
|
|
7970
|
-
const probeGit = readRecord3(rawProbe.git);
|
|
7971
|
-
const probeGitResult = readRecord3(probeGit.result);
|
|
7972
|
-
const probeDirectStatus = readRecord3(probeGit.status);
|
|
7973
|
-
const probeNestedStatus = readRecord3(probeGitResult.status);
|
|
7974
|
-
const lastCheckedAt = options?.lastCheckedAt;
|
|
7975
|
-
let best = null;
|
|
7976
|
-
for (const status of [directStatus, nestedStatus, probeDirectStatus, probeNestedStatus]) {
|
|
7977
|
-
const normalized = normalizeGitStatus(status, node, { lastCheckedAt: lastCheckedAt ?? Date.now() });
|
|
7978
|
-
if (!normalized) continue;
|
|
7979
|
-
const score = scoreGitStatusCandidate(normalized);
|
|
7980
|
-
if (!best || score > best.score) best = { git: normalized, score };
|
|
7981
|
-
}
|
|
7982
|
-
return best?.git;
|
|
7983
|
-
}
|
|
7984
|
-
function normalizeMeshNodeId(node) {
|
|
7985
|
-
const record = node && typeof node === "object" ? node : {};
|
|
7986
|
-
return readString5(record.id, record.nodeId, record.node_id);
|
|
7987
|
-
}
|
|
7988
|
-
function meshNodeIdMatches(node, candidateId) {
|
|
7989
|
-
if (!candidateId) return false;
|
|
7990
|
-
const trimmed = candidateId.trim();
|
|
7991
|
-
if (!trimmed) return false;
|
|
7992
|
-
return normalizeMeshNodeId(node) === trimmed;
|
|
7993
|
-
}
|
|
7994
|
-
function machineCoreFromDaemonId(id) {
|
|
7995
|
-
const trimmed = readString5(id);
|
|
7996
|
-
if (!trimmed) return void 0;
|
|
7997
|
-
for (const prefix of DAEMON_ID_PREFIXES) {
|
|
7998
|
-
if (trimmed.startsWith(prefix)) {
|
|
7999
|
-
const core = trimmed.slice(prefix.length).trim();
|
|
8000
|
-
return core || void 0;
|
|
8001
|
-
}
|
|
8002
|
-
}
|
|
8003
|
-
return trimmed;
|
|
8004
|
-
}
|
|
8005
|
-
function expandDaemonIdForms(ids) {
|
|
8006
|
-
const list = Array.isArray(ids) ? ids : ids != null ? [ids] : [];
|
|
8007
|
-
const out = [];
|
|
8008
|
-
const seen = /* @__PURE__ */ new Set();
|
|
8009
|
-
const add = (value) => {
|
|
8010
|
-
if (!value || seen.has(value)) return;
|
|
8011
|
-
seen.add(value);
|
|
8012
|
-
out.push(value);
|
|
8013
|
-
};
|
|
8014
|
-
for (const raw of list) add(readString5(raw));
|
|
8015
|
-
for (const raw of list) {
|
|
8016
|
-
const core = machineCoreFromDaemonId(readString5(raw));
|
|
8017
|
-
if (!core || !core.startsWith("mach_")) continue;
|
|
8018
|
-
add(core);
|
|
8019
|
-
for (const prefix of DAEMON_ID_PREFIXES) add(`${prefix}${core}`);
|
|
8020
|
-
}
|
|
8021
|
-
return out;
|
|
8022
|
-
}
|
|
8023
|
-
function summarizeGitShape(status) {
|
|
8024
|
-
const record = readRecord3(status);
|
|
8025
|
-
if (!Object.keys(record).length) return null;
|
|
8026
|
-
const submodules = Array.isArray(record.submodules) ? record.submodules.map((entry) => {
|
|
8027
|
-
const sub = readRecord3(entry);
|
|
8028
|
-
return {
|
|
8029
|
-
path: readString5(sub.path) ?? null,
|
|
8030
|
-
commit: readString5(sub.commit)?.slice(0, 12) ?? null,
|
|
8031
|
-
dirty: readBoolean(sub.dirty) ?? false,
|
|
8032
|
-
outOfSync: readBoolean(sub.outOfSync, sub.out_of_sync) ?? false
|
|
8033
|
-
};
|
|
8034
|
-
}) : [];
|
|
8035
|
-
return {
|
|
8036
|
-
isGitRepo: readBoolean(record.isGitRepo),
|
|
8037
|
-
workspace: readString5(record.workspace) ?? null,
|
|
8038
|
-
repoRoot: readString5(record.repoRoot, record.repo_root) ?? null,
|
|
8039
|
-
branch: readString5(record.branch) ?? null,
|
|
8040
|
-
upstream: readString5(record.upstream) ?? null,
|
|
8041
|
-
upstreamStatus: readString5(record.upstreamStatus, record.upstream_status) ?? null,
|
|
8042
|
-
headCommit: readString5(record.headCommit, record.head_commit)?.slice(0, 12) ?? null,
|
|
8043
|
-
ahead: readNumber(record.ahead) ?? null,
|
|
8044
|
-
behind: readNumber(record.behind) ?? null,
|
|
8045
|
-
dirtyCounts: {
|
|
8046
|
-
staged: readNumber(record.staged) ?? 0,
|
|
8047
|
-
modified: readNumber(record.modified) ?? 0,
|
|
8048
|
-
untracked: readNumber(record.untracked) ?? 0,
|
|
8049
|
-
deleted: readNumber(record.deleted) ?? 0,
|
|
8050
|
-
renamed: readNumber(record.renamed) ?? 0
|
|
8051
|
-
},
|
|
8052
|
-
lastCheckedAt: readNumber(record.lastCheckedAt, record.last_checked_at) ?? null,
|
|
8053
|
-
submoduleCount: submodules.length,
|
|
8054
|
-
submodules
|
|
8055
|
-
};
|
|
8056
|
-
}
|
|
8057
|
-
var DAEMON_ID_PREFIXES;
|
|
8058
|
-
var init_dist = __esm({
|
|
8059
|
-
"../mesh-shared/dist/index.mjs"() {
|
|
8060
|
-
"use strict";
|
|
8061
|
-
DAEMON_ID_PREFIXES = ["daemon_", "standalone_"];
|
|
8062
|
-
}
|
|
8063
|
-
});
|
|
8064
|
-
|
|
8065
8071
|
// src/mesh/mesh-active-work.ts
|
|
8066
8072
|
function readString6(value) {
|
|
8067
8073
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
@@ -20339,6 +20345,7 @@ __export(index_exports, {
|
|
|
20339
20345
|
createNativeHistoryDispatcher: () => createNativeHistoryDispatcher,
|
|
20340
20346
|
createSessionDelivery: () => createSessionDelivery,
|
|
20341
20347
|
createWorktree: () => createWorktree,
|
|
20348
|
+
daemonIdsEquivalent: () => daemonIdsEquivalent,
|
|
20342
20349
|
deleteDirectDispatchesByTaskId: () => deleteDirectDispatchesByTaskId,
|
|
20343
20350
|
deleteMesh: () => deleteMesh,
|
|
20344
20351
|
deriveMeshReviewInboxItems: () => deriveMeshReviewInboxItems,
|
|
@@ -20352,6 +20359,7 @@ __export(index_exports, {
|
|
|
20352
20359
|
ensureSessionHostReady: () => ensureSessionHostReady,
|
|
20353
20360
|
evaluateFsm: () => evaluateFsm,
|
|
20354
20361
|
execNpmCommandSync: () => execNpmCommandSync,
|
|
20362
|
+
expandDaemonIdForms: () => expandDaemonIdForms,
|
|
20355
20363
|
fastForwardMeshNode: () => fastForwardMeshNode,
|
|
20356
20364
|
filterActivityChatMessages: () => filterActivityChatMessages,
|
|
20357
20365
|
filterChatMessagesByVisibility: () => filterChatMessagesByVisibility,
|
|
@@ -20442,6 +20450,7 @@ __export(index_exports, {
|
|
|
20442
20450
|
loadMeshWorktreeBootstrapConfig: () => loadMeshWorktreeBootstrapConfig,
|
|
20443
20451
|
loadState: () => loadState,
|
|
20444
20452
|
logCommand: () => logCommand,
|
|
20453
|
+
machineCoreFromDaemonId: () => machineCoreFromDaemonId,
|
|
20445
20454
|
markSessionDeliveriesTerminal: () => markSessionDeliveriesTerminal,
|
|
20446
20455
|
markSetupComplete: () => markSetupComplete,
|
|
20447
20456
|
markStaleDirectDispatches: () => markStaleDirectDispatches,
|
|
@@ -21800,6 +21809,7 @@ function getSavedProviderSessions(state, filters) {
|
|
|
21800
21809
|
|
|
21801
21810
|
// src/index.ts
|
|
21802
21811
|
init_mesh_config();
|
|
21812
|
+
init_dist();
|
|
21803
21813
|
init_coordinator_prompt();
|
|
21804
21814
|
init_mesh_missions();
|
|
21805
21815
|
init_mesh_task_stats();
|
|
@@ -39391,9 +39401,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
39391
39401
|
}
|
|
39392
39402
|
}
|
|
39393
39403
|
}
|
|
39394
|
-
|
|
39395
|
-
|
|
39396
|
-
|
|
39404
|
+
if (!opts?.instanceKey) {
|
|
39405
|
+
for (const [k, a] of this.adapters) {
|
|
39406
|
+
if (a.cliType === agentType) {
|
|
39407
|
+
return { adapter: a, key: k };
|
|
39408
|
+
}
|
|
39397
39409
|
}
|
|
39398
39410
|
}
|
|
39399
39411
|
return null;
|
|
@@ -46750,7 +46762,14 @@ var MESH_FORWARDABLE_SESSION_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
46750
46762
|
"resolve_action",
|
|
46751
46763
|
"set_mode",
|
|
46752
46764
|
"change_model",
|
|
46753
|
-
"set_thought_level"
|
|
46765
|
+
"set_thought_level",
|
|
46766
|
+
// agent_command (send_chat / clear_history / stop) is session-scoped too: a command
|
|
46767
|
+
// explicitly naming a targetSessionId MUST reach that session wherever it lives, never a
|
|
46768
|
+
// different local session. Without forwarding, a misrouted/relayed send_chat for a REMOTE
|
|
46769
|
+
// worker session that reaches the wrong daemon used to fuzzy-inject the task body into that
|
|
46770
|
+
// daemon's own CLI session (TASKECHO coordinator self-echo). Forwarding to the owning daemon
|
|
46771
|
+
// delivers it to the real worker instead. (findAdapter is also fail-closed as the backstop.)
|
|
46772
|
+
"agent_command"
|
|
46754
46773
|
]);
|
|
46755
46774
|
var READ_DEBUG_ENABLED2 = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
|
|
46756
46775
|
function normalizeCommandSource(source) {
|
|
@@ -47103,7 +47122,7 @@ var DaemonCommandRouter = class {
|
|
|
47103
47122
|
if (!collectMeshNodeHostedSessionIds(node).has(trimmed)) continue;
|
|
47104
47123
|
const nodeDaemonId = readMeshNodeDaemonId(readObjectRecord(node));
|
|
47105
47124
|
if (!nodeDaemonId) continue;
|
|
47106
|
-
if (selfDaemonId && nodeDaemonId
|
|
47125
|
+
if (selfDaemonId && daemonIdsEquivalent(nodeDaemonId, selfDaemonId)) return void 0;
|
|
47107
47126
|
return nodeDaemonId;
|
|
47108
47127
|
}
|
|
47109
47128
|
return void 0;
|
|
@@ -47258,6 +47277,38 @@ var DaemonCommandRouter = class {
|
|
|
47258
47277
|
if (record?.meta?.meshNodeId === nodeId) return true;
|
|
47259
47278
|
return false;
|
|
47260
47279
|
}
|
|
47280
|
+
/**
|
|
47281
|
+
* Best-effort recursive removal of a managed worktree directory.
|
|
47282
|
+
*
|
|
47283
|
+
* The git-registry de-registration is the safety-critical step of worktree
|
|
47284
|
+
* teardown; a leftover directory must never gate dropping the node from the
|
|
47285
|
+
* mesh. On Windows, `fs.rmSync` can throw EINVAL/EPERM/EBUSY on submodule
|
|
47286
|
+
* gitlink (`.git`) files, long paths, junctions, or while a just-stopped
|
|
47287
|
+
* delegate session is still releasing a handle/cwd on the directory. This
|
|
47288
|
+
* helper absorbs those errors (never throws), with bounded retries + backoff
|
|
47289
|
+
* to give handles time to release, and reports whether residue remains.
|
|
47290
|
+
*/
|
|
47291
|
+
async bestEffortRemoveWorktreeDir(dir) {
|
|
47292
|
+
if (!dir || !fs26.existsSync(dir)) return { removed: true, residue: false };
|
|
47293
|
+
const sleep3 = (ms) => new Promise((resolve24) => setTimeout(resolve24, ms));
|
|
47294
|
+
const ABSORB = /* @__PURE__ */ new Set(["EINVAL", "EPERM", "EBUSY", "ENOTEMPTY", "EACCES", "EMFILE", "ENFILE"]);
|
|
47295
|
+
let lastErr;
|
|
47296
|
+
for (let attempt = 0; attempt < 4; attempt++) {
|
|
47297
|
+
try {
|
|
47298
|
+
fs26.rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
47299
|
+
if (!fs26.existsSync(dir)) return { removed: true, residue: false };
|
|
47300
|
+
lastErr = new Error("directory still present after rmSync");
|
|
47301
|
+
} catch (e) {
|
|
47302
|
+
lastErr = e;
|
|
47303
|
+
const code = typeof e?.code === "string" ? e.code : "";
|
|
47304
|
+
if (code && !ABSORB.has(code)) {
|
|
47305
|
+
break;
|
|
47306
|
+
}
|
|
47307
|
+
}
|
|
47308
|
+
await sleep3(150 * (attempt + 1));
|
|
47309
|
+
}
|
|
47310
|
+
return fs26.existsSync(dir) ? { removed: false, residue: true, error: String(lastErr?.message || lastErr || "unknown rm error") } : { removed: true, residue: false };
|
|
47311
|
+
}
|
|
47261
47312
|
async cleanupLocalWorktreeNode(args) {
|
|
47262
47313
|
const workspace = typeof args.node?.workspace === "string" ? args.node.workspace.trim() : "";
|
|
47263
47314
|
if (!workspace) {
|
|
@@ -47312,11 +47363,31 @@ var DaemonCommandRouter = class {
|
|
|
47312
47363
|
const entries = await listWorktrees2(repoRoot);
|
|
47313
47364
|
const managedEntry = entries.find((entry) => normalizePath(entry.path) === actualPath);
|
|
47314
47365
|
if (!managedEntry) {
|
|
47366
|
+
try {
|
|
47367
|
+
const { execFile: execFile5 } = await import("child_process");
|
|
47368
|
+
const { promisify: promisify8 } = await import("util");
|
|
47369
|
+
const execFileAsync4 = promisify8(execFile5);
|
|
47370
|
+
await execFileAsync4("git", ["worktree", "prune"], {
|
|
47371
|
+
cwd: repoRoot,
|
|
47372
|
+
encoding: "utf8",
|
|
47373
|
+
timeout: 3e4,
|
|
47374
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
47375
|
+
windowsHide: true
|
|
47376
|
+
});
|
|
47377
|
+
} catch {
|
|
47378
|
+
}
|
|
47379
|
+
const rm = await this.bestEffortRemoveWorktreeDir(workspace);
|
|
47315
47380
|
return {
|
|
47316
|
-
success:
|
|
47317
|
-
|
|
47318
|
-
|
|
47319
|
-
|
|
47381
|
+
success: true,
|
|
47382
|
+
removedPath: workspace,
|
|
47383
|
+
repoRoot,
|
|
47384
|
+
reason: "worktree_unregistered_residue_recovered",
|
|
47385
|
+
recovered: true,
|
|
47386
|
+
...rm.residue ? {
|
|
47387
|
+
residue: true,
|
|
47388
|
+
residueWarning: `Worktree was already de-registered from git but the directory could not be fully removed (leftover residue at '${workspace}'): ${rm.error || "unknown error"}. The node will be dropped from the mesh; remove the directory manually if needed.`,
|
|
47389
|
+
residueError: rm.error
|
|
47390
|
+
} : {}
|
|
47320
47391
|
};
|
|
47321
47392
|
}
|
|
47322
47393
|
if (managedEntry.branch && managedEntry.branch !== args.node.worktreeBranch) {
|
|
@@ -47379,8 +47450,8 @@ var DaemonCommandRouter = class {
|
|
|
47379
47450
|
convergence: forceFallbackConvergence
|
|
47380
47451
|
};
|
|
47381
47452
|
} catch (deinitError) {
|
|
47453
|
+
const rm = await this.bestEffortRemoveWorktreeDir(workspace);
|
|
47382
47454
|
try {
|
|
47383
|
-
fs26.rmSync(workspace, { recursive: true, force: true });
|
|
47384
47455
|
await execFileAsync4("git", ["worktree", "prune"], {
|
|
47385
47456
|
cwd: repoRoot,
|
|
47386
47457
|
encoding: "utf8",
|
|
@@ -47388,23 +47459,22 @@ var DaemonCommandRouter = class {
|
|
|
47388
47459
|
maxBuffer: GIT_MAX_BUFFER_CLEANUP,
|
|
47389
47460
|
windowsHide: true
|
|
47390
47461
|
});
|
|
47391
|
-
|
|
47392
|
-
success: true,
|
|
47393
|
-
removedPath: workspace,
|
|
47394
|
-
repoRoot,
|
|
47395
|
-
fallback: "fs_rm_worktree_prune",
|
|
47396
|
-
forced: true,
|
|
47397
|
-
reason: "working_trees_containing_submodules",
|
|
47398
|
-
convergence: forceFallbackConvergence
|
|
47399
|
-
};
|
|
47400
|
-
} catch (rmError) {
|
|
47401
|
-
return {
|
|
47402
|
-
success: false,
|
|
47403
|
-
code: "mesh_worktree_cleanup_failed",
|
|
47404
|
-
error: `All removal fallbacks exhausted. deinit+remove: ${deinitError?.message || deinitError}; rmSync+prune: ${rmError?.message || rmError}`,
|
|
47405
|
-
recoveryHint: "Manually remove the worktree directory and run git worktree prune from the source repo."
|
|
47406
|
-
};
|
|
47462
|
+
} catch {
|
|
47407
47463
|
}
|
|
47464
|
+
return {
|
|
47465
|
+
success: true,
|
|
47466
|
+
removedPath: workspace,
|
|
47467
|
+
repoRoot,
|
|
47468
|
+
fallback: "fs_rm_worktree_prune",
|
|
47469
|
+
forced: true,
|
|
47470
|
+
reason: "working_trees_containing_submodules",
|
|
47471
|
+
convergence: forceFallbackConvergence,
|
|
47472
|
+
...rm.residue ? {
|
|
47473
|
+
residue: true,
|
|
47474
|
+
residueWarning: `Worktree was de-registered from git but the directory could not be fully removed (leftover residue at '${workspace}'): ${rm.error || "unknown error"}; deinit+remove first failed with: ${deinitError?.message || deinitError}. The node will be dropped from the mesh; remove the directory manually if needed.`,
|
|
47475
|
+
residueError: rm.error
|
|
47476
|
+
} : {}
|
|
47477
|
+
};
|
|
47408
47478
|
}
|
|
47409
47479
|
}
|
|
47410
47480
|
return {
|
|
@@ -50803,7 +50873,14 @@ ${hintLines.join("\n")}` : "",
|
|
|
50803
50873
|
} catch {
|
|
50804
50874
|
}
|
|
50805
50875
|
}
|
|
50806
|
-
|
|
50876
|
+
const residueWarning = worktreeCleanup?.residue === true && typeof worktreeCleanup?.residueWarning === "string" ? worktreeCleanup.residueWarning : void 0;
|
|
50877
|
+
return {
|
|
50878
|
+
success: true,
|
|
50879
|
+
removed,
|
|
50880
|
+
...residueWarning ? { residueWarning } : {},
|
|
50881
|
+
...sessionCleanup ? { sessionCleanup } : {},
|
|
50882
|
+
...worktreeCleanup ? { worktreeCleanup } : {}
|
|
50883
|
+
};
|
|
50807
50884
|
} catch (e) {
|
|
50808
50885
|
return { success: false, error: e.message };
|
|
50809
50886
|
}
|
|
@@ -60797,6 +60874,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
60797
60874
|
createNativeHistoryDispatcher,
|
|
60798
60875
|
createSessionDelivery,
|
|
60799
60876
|
createWorktree,
|
|
60877
|
+
daemonIdsEquivalent,
|
|
60800
60878
|
deleteDirectDispatchesByTaskId,
|
|
60801
60879
|
deleteMesh,
|
|
60802
60880
|
deriveMeshReviewInboxItems,
|
|
@@ -60810,6 +60888,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
60810
60888
|
ensureSessionHostReady,
|
|
60811
60889
|
evaluateFsm,
|
|
60812
60890
|
execNpmCommandSync,
|
|
60891
|
+
expandDaemonIdForms,
|
|
60813
60892
|
fastForwardMeshNode,
|
|
60814
60893
|
filterActivityChatMessages,
|
|
60815
60894
|
filterChatMessagesByVisibility,
|
|
@@ -60900,6 +60979,7 @@ var V1_CONTRACT_VERSION = "1.0.0";
|
|
|
60900
60979
|
loadMeshWorktreeBootstrapConfig,
|
|
60901
60980
|
loadState,
|
|
60902
60981
|
logCommand,
|
|
60982
|
+
machineCoreFromDaemonId,
|
|
60903
60983
|
markSessionDeliveriesTerminal,
|
|
60904
60984
|
markSetupComplete,
|
|
60905
60985
|
markStaleDirectDispatches,
|