@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.mjs
CHANGED
|
@@ -311,10 +311,10 @@ function readInjected(value) {
|
|
|
311
311
|
}
|
|
312
312
|
function getDaemonBuildInfo() {
|
|
313
313
|
if (cached) return cached;
|
|
314
|
-
const commit = readInjected(true ? "
|
|
315
|
-
const commitShort = readInjected(true ? "
|
|
316
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
317
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
314
|
+
const commit = readInjected(true ? "a680b74d9b940b82f691ebb85a725a1a72445bfc" : void 0) ?? "unknown";
|
|
315
|
+
const commitShort = readInjected(true ? "a680b74d" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
316
|
+
const version = readInjected(true ? "0.9.82-rc.353" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
317
|
+
const builtAt = readInjected(true ? "2026-06-22T09:11:13.499Z" : void 0);
|
|
318
318
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
319
319
|
return cached;
|
|
320
320
|
}
|
|
@@ -2703,6 +2703,257 @@ var init_mesh_config = __esm({
|
|
|
2703
2703
|
}
|
|
2704
2704
|
});
|
|
2705
2705
|
|
|
2706
|
+
// ../mesh-shared/dist/index.mjs
|
|
2707
|
+
function readRecord(value) {
|
|
2708
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
2709
|
+
}
|
|
2710
|
+
function readString3(...values) {
|
|
2711
|
+
for (const value of values) {
|
|
2712
|
+
if (typeof value !== "string") continue;
|
|
2713
|
+
const trimmed = value.trim();
|
|
2714
|
+
if (trimmed) return trimmed;
|
|
2715
|
+
}
|
|
2716
|
+
return void 0;
|
|
2717
|
+
}
|
|
2718
|
+
function readNumber(...values) {
|
|
2719
|
+
for (const value of values) {
|
|
2720
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
2721
|
+
}
|
|
2722
|
+
return void 0;
|
|
2723
|
+
}
|
|
2724
|
+
function readBoolean(...values) {
|
|
2725
|
+
for (const value of values) {
|
|
2726
|
+
if (typeof value === "boolean") return value;
|
|
2727
|
+
}
|
|
2728
|
+
return void 0;
|
|
2729
|
+
}
|
|
2730
|
+
function joinRepoPath(root, relativePath) {
|
|
2731
|
+
const normalizedRoot = typeof root === "string" ? root.trim().replace(/[\\/]+$/, "") : "";
|
|
2732
|
+
const normalizedPath = typeof relativePath === "string" ? relativePath.trim() : "";
|
|
2733
|
+
if (!normalizedPath) return void 0;
|
|
2734
|
+
if (/^(?:[A-Za-z]:[\\/]|\/)/.test(normalizedPath)) return normalizedPath;
|
|
2735
|
+
if (!normalizedRoot) return void 0;
|
|
2736
|
+
return `${normalizedRoot}/${normalizedPath.replace(/^[\\/]+/, "")}`;
|
|
2737
|
+
}
|
|
2738
|
+
function scoreGitUpstreamFreshness(status) {
|
|
2739
|
+
switch (status) {
|
|
2740
|
+
case "fresh":
|
|
2741
|
+
return 30;
|
|
2742
|
+
case "no_upstream":
|
|
2743
|
+
return 4;
|
|
2744
|
+
case "unchecked":
|
|
2745
|
+
case void 0:
|
|
2746
|
+
return 0;
|
|
2747
|
+
case "stale":
|
|
2748
|
+
return -10;
|
|
2749
|
+
case "unavailable":
|
|
2750
|
+
return -15;
|
|
2751
|
+
default:
|
|
2752
|
+
return 0;
|
|
2753
|
+
}
|
|
2754
|
+
}
|
|
2755
|
+
function readGitSubmodules(value, parentRepoRoot) {
|
|
2756
|
+
if (!Array.isArray(value)) return void 0;
|
|
2757
|
+
const submodules = value.map((entry) => {
|
|
2758
|
+
const submodule = readRecord(entry);
|
|
2759
|
+
const path42 = readString3(submodule.path);
|
|
2760
|
+
const commit = readString3(submodule.commit);
|
|
2761
|
+
const repoPath = readString3(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path42);
|
|
2762
|
+
if (!path42 || !commit) return null;
|
|
2763
|
+
const result = {
|
|
2764
|
+
path: path42,
|
|
2765
|
+
commit,
|
|
2766
|
+
dirty: readBoolean(submodule.dirty) ?? false,
|
|
2767
|
+
outOfSync: readBoolean(submodule.outOfSync, submodule.out_of_sync) ?? false,
|
|
2768
|
+
lastCheckedAt: readNumber(submodule.lastCheckedAt, submodule.last_checked_at) ?? Date.now()
|
|
2769
|
+
};
|
|
2770
|
+
if (repoPath) result.repoPath = repoPath;
|
|
2771
|
+
const error = readString3(submodule.error);
|
|
2772
|
+
if (error) result.error = error;
|
|
2773
|
+
return result;
|
|
2774
|
+
}).filter((entry) => entry !== null);
|
|
2775
|
+
return submodules.length > 0 ? submodules : void 0;
|
|
2776
|
+
}
|
|
2777
|
+
function hasGitStatusEvidence(status) {
|
|
2778
|
+
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(
|
|
2779
|
+
status.ahead,
|
|
2780
|
+
status.behind,
|
|
2781
|
+
status.staged,
|
|
2782
|
+
status.modified,
|
|
2783
|
+
status.untracked,
|
|
2784
|
+
status.deleted,
|
|
2785
|
+
status.renamed,
|
|
2786
|
+
status.lastCheckedAt,
|
|
2787
|
+
status.last_checked_at
|
|
2788
|
+
) !== void 0 || Array.isArray(status.submodules) && status.submodules.length > 0;
|
|
2789
|
+
}
|
|
2790
|
+
function normalizeGitStatus(status, node, options) {
|
|
2791
|
+
const explicitIsGitRepo = readBoolean(status.isGitRepo);
|
|
2792
|
+
if (!Object.keys(status).length || !hasGitStatusEvidence(status)) return void 0;
|
|
2793
|
+
const isGitRepo = explicitIsGitRepo ?? true;
|
|
2794
|
+
const conflictFiles = Array.isArray(status.conflictFiles) ? status.conflictFiles.filter((entry) => typeof entry === "string") : [];
|
|
2795
|
+
const conflictCount = readNumber(status.conflicts) ?? conflictFiles.length;
|
|
2796
|
+
const hasConflicts = readBoolean(status.hasConflicts) ?? conflictCount > 0;
|
|
2797
|
+
const repoRoot = readString3(status.repoRoot, status.repo_root, node.repoRoot, node.repo_root, status.workspace, node.workspace) || void 0;
|
|
2798
|
+
const submodules = readGitSubmodules(status.submodules, repoRoot);
|
|
2799
|
+
const upstreamStatus = readString3(status.upstreamStatus, status.upstream_status);
|
|
2800
|
+
const upstreamFetchedAt = readNumber(status.upstreamFetchedAt, status.upstream_fetched_at);
|
|
2801
|
+
const upstreamFetchError = readString3(status.upstreamFetchError, status.upstream_fetch_error);
|
|
2802
|
+
const error = readString3(status.error);
|
|
2803
|
+
const staged = readNumber(status.staged) ?? 0;
|
|
2804
|
+
const modified = readNumber(status.modified) ?? 0;
|
|
2805
|
+
const untracked = readNumber(status.untracked) ?? 0;
|
|
2806
|
+
const deleted = readNumber(status.deleted) ?? 0;
|
|
2807
|
+
const renamed = readNumber(status.renamed) ?? 0;
|
|
2808
|
+
return {
|
|
2809
|
+
workspace: readString3(status.workspace, node.workspace) || "",
|
|
2810
|
+
repoRoot: repoRoot ?? null,
|
|
2811
|
+
isGitRepo,
|
|
2812
|
+
branch: readString3(status.branch) ?? null,
|
|
2813
|
+
headCommit: readString3(status.headCommit) ?? null,
|
|
2814
|
+
headMessage: readString3(status.headMessage) ?? null,
|
|
2815
|
+
upstream: readString3(status.upstream) ?? null,
|
|
2816
|
+
upstreamStatus: upstreamStatus ?? "unchecked",
|
|
2817
|
+
...upstreamFetchedAt !== void 0 ? { upstreamFetchedAt } : {},
|
|
2818
|
+
...upstreamFetchError ? { upstreamFetchError } : {},
|
|
2819
|
+
ahead: readNumber(status.ahead) ?? 0,
|
|
2820
|
+
behind: readNumber(status.behind) ?? 0,
|
|
2821
|
+
staged,
|
|
2822
|
+
modified,
|
|
2823
|
+
untracked,
|
|
2824
|
+
deleted,
|
|
2825
|
+
renamed,
|
|
2826
|
+
dirty: readBoolean(status.dirty, status.isDirty, status.is_dirty) ?? (staged + modified + untracked + deleted + renamed > 0 || hasConflicts),
|
|
2827
|
+
hasConflicts,
|
|
2828
|
+
conflictFiles,
|
|
2829
|
+
stashCount: readNumber(status.stashCount, status.stash_count) ?? 0,
|
|
2830
|
+
lastCheckedAt: options?.lastCheckedAt ?? readNumber(status.lastCheckedAt, status.last_checked_at) ?? Date.now(),
|
|
2831
|
+
...submodules ? { submodules } : {},
|
|
2832
|
+
...error ? { error } : {}
|
|
2833
|
+
};
|
|
2834
|
+
}
|
|
2835
|
+
function scoreGitStatusCandidate(git) {
|
|
2836
|
+
if (!git) return Number.NEGATIVE_INFINITY;
|
|
2837
|
+
let score = 0;
|
|
2838
|
+
if (git.isGitRepo === true) score += 50;
|
|
2839
|
+
if (git.isGitRepo === false) score -= 10;
|
|
2840
|
+
if (git.branch) score += 20;
|
|
2841
|
+
if (git.headCommit) score += 20;
|
|
2842
|
+
if (git.upstream) score += 10;
|
|
2843
|
+
score += scoreGitUpstreamFreshness(git.upstreamStatus);
|
|
2844
|
+
if (typeof git.ahead === "number") score += 2;
|
|
2845
|
+
if (typeof git.behind === "number") score += 2;
|
|
2846
|
+
if (Array.isArray(git.submodules) && git.submodules.length > 0) score += 4 + git.submodules.length;
|
|
2847
|
+
if (git.error) score -= 20;
|
|
2848
|
+
return score;
|
|
2849
|
+
}
|
|
2850
|
+
function pickBestTransitGitStatus(node, options) {
|
|
2851
|
+
const rawGit = readRecord(node.lastGit ?? node.last_git);
|
|
2852
|
+
const gitResult = readRecord(rawGit.result);
|
|
2853
|
+
const directStatus = readRecord(rawGit.status);
|
|
2854
|
+
const nestedStatus = readRecord(gitResult.status);
|
|
2855
|
+
const rawProbe = readRecord(node.lastProbe ?? node.last_probe);
|
|
2856
|
+
const probeGit = readRecord(rawProbe.git);
|
|
2857
|
+
const probeGitResult = readRecord(probeGit.result);
|
|
2858
|
+
const probeDirectStatus = readRecord(probeGit.status);
|
|
2859
|
+
const probeNestedStatus = readRecord(probeGitResult.status);
|
|
2860
|
+
const lastCheckedAt = options?.lastCheckedAt;
|
|
2861
|
+
let best = null;
|
|
2862
|
+
for (const status of [directStatus, nestedStatus, probeDirectStatus, probeNestedStatus]) {
|
|
2863
|
+
const normalized = normalizeGitStatus(status, node, { lastCheckedAt: lastCheckedAt ?? Date.now() });
|
|
2864
|
+
if (!normalized) continue;
|
|
2865
|
+
const score = scoreGitStatusCandidate(normalized);
|
|
2866
|
+
if (!best || score > best.score) best = { git: normalized, score };
|
|
2867
|
+
}
|
|
2868
|
+
return best?.git;
|
|
2869
|
+
}
|
|
2870
|
+
function normalizeMeshNodeId(node) {
|
|
2871
|
+
const record = node && typeof node === "object" ? node : {};
|
|
2872
|
+
return readString3(record.id, record.nodeId, record.node_id);
|
|
2873
|
+
}
|
|
2874
|
+
function meshNodeIdMatches(node, candidateId) {
|
|
2875
|
+
if (!candidateId) return false;
|
|
2876
|
+
const trimmed = candidateId.trim();
|
|
2877
|
+
if (!trimmed) return false;
|
|
2878
|
+
return normalizeMeshNodeId(node) === trimmed;
|
|
2879
|
+
}
|
|
2880
|
+
function machineCoreFromDaemonId(id) {
|
|
2881
|
+
const trimmed = readString3(id);
|
|
2882
|
+
if (!trimmed) return void 0;
|
|
2883
|
+
for (const prefix of DAEMON_ID_PREFIXES) {
|
|
2884
|
+
if (trimmed.startsWith(prefix)) {
|
|
2885
|
+
const core = trimmed.slice(prefix.length).trim();
|
|
2886
|
+
return core || void 0;
|
|
2887
|
+
}
|
|
2888
|
+
}
|
|
2889
|
+
return trimmed;
|
|
2890
|
+
}
|
|
2891
|
+
function daemonIdsEquivalent(a, b) {
|
|
2892
|
+
const coreA = machineCoreFromDaemonId(a);
|
|
2893
|
+
const coreB = machineCoreFromDaemonId(b);
|
|
2894
|
+
if (!coreA || !coreB) return false;
|
|
2895
|
+
return coreA === coreB;
|
|
2896
|
+
}
|
|
2897
|
+
function expandDaemonIdForms(ids) {
|
|
2898
|
+
const list = Array.isArray(ids) ? ids : ids != null ? [ids] : [];
|
|
2899
|
+
const out = [];
|
|
2900
|
+
const seen = /* @__PURE__ */ new Set();
|
|
2901
|
+
const add = (value) => {
|
|
2902
|
+
if (!value || seen.has(value)) return;
|
|
2903
|
+
seen.add(value);
|
|
2904
|
+
out.push(value);
|
|
2905
|
+
};
|
|
2906
|
+
for (const raw of list) add(readString3(raw));
|
|
2907
|
+
for (const raw of list) {
|
|
2908
|
+
const core = machineCoreFromDaemonId(readString3(raw));
|
|
2909
|
+
if (!core || !core.startsWith("mach_")) continue;
|
|
2910
|
+
add(core);
|
|
2911
|
+
for (const prefix of DAEMON_ID_PREFIXES) add(`${prefix}${core}`);
|
|
2912
|
+
}
|
|
2913
|
+
return out;
|
|
2914
|
+
}
|
|
2915
|
+
function summarizeGitShape(status) {
|
|
2916
|
+
const record = readRecord(status);
|
|
2917
|
+
if (!Object.keys(record).length) return null;
|
|
2918
|
+
const submodules = Array.isArray(record.submodules) ? record.submodules.map((entry) => {
|
|
2919
|
+
const sub = readRecord(entry);
|
|
2920
|
+
return {
|
|
2921
|
+
path: readString3(sub.path) ?? null,
|
|
2922
|
+
commit: readString3(sub.commit)?.slice(0, 12) ?? null,
|
|
2923
|
+
dirty: readBoolean(sub.dirty) ?? false,
|
|
2924
|
+
outOfSync: readBoolean(sub.outOfSync, sub.out_of_sync) ?? false
|
|
2925
|
+
};
|
|
2926
|
+
}) : [];
|
|
2927
|
+
return {
|
|
2928
|
+
isGitRepo: readBoolean(record.isGitRepo),
|
|
2929
|
+
workspace: readString3(record.workspace) ?? null,
|
|
2930
|
+
repoRoot: readString3(record.repoRoot, record.repo_root) ?? null,
|
|
2931
|
+
branch: readString3(record.branch) ?? null,
|
|
2932
|
+
upstream: readString3(record.upstream) ?? null,
|
|
2933
|
+
upstreamStatus: readString3(record.upstreamStatus, record.upstream_status) ?? null,
|
|
2934
|
+
headCommit: readString3(record.headCommit, record.head_commit)?.slice(0, 12) ?? null,
|
|
2935
|
+
ahead: readNumber(record.ahead) ?? null,
|
|
2936
|
+
behind: readNumber(record.behind) ?? null,
|
|
2937
|
+
dirtyCounts: {
|
|
2938
|
+
staged: readNumber(record.staged) ?? 0,
|
|
2939
|
+
modified: readNumber(record.modified) ?? 0,
|
|
2940
|
+
untracked: readNumber(record.untracked) ?? 0,
|
|
2941
|
+
deleted: readNumber(record.deleted) ?? 0,
|
|
2942
|
+
renamed: readNumber(record.renamed) ?? 0
|
|
2943
|
+
},
|
|
2944
|
+
lastCheckedAt: readNumber(record.lastCheckedAt, record.last_checked_at) ?? null,
|
|
2945
|
+
submoduleCount: submodules.length,
|
|
2946
|
+
submodules
|
|
2947
|
+
};
|
|
2948
|
+
}
|
|
2949
|
+
var DAEMON_ID_PREFIXES;
|
|
2950
|
+
var init_dist = __esm({
|
|
2951
|
+
"../mesh-shared/dist/index.mjs"() {
|
|
2952
|
+
"use strict";
|
|
2953
|
+
DAEMON_ID_PREFIXES = ["daemon_", "standalone_"];
|
|
2954
|
+
}
|
|
2955
|
+
});
|
|
2956
|
+
|
|
2706
2957
|
// src/mesh/coordinator-prompt.ts
|
|
2707
2958
|
var coordinator_prompt_exports = {};
|
|
2708
2959
|
__export(coordinator_prompt_exports, {
|
|
@@ -6310,10 +6561,10 @@ var init_mesh_missions = __esm({
|
|
|
6310
6561
|
});
|
|
6311
6562
|
|
|
6312
6563
|
// src/mesh/mesh-refine-status.ts
|
|
6313
|
-
function
|
|
6564
|
+
function readString4(value) {
|
|
6314
6565
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
6315
6566
|
}
|
|
6316
|
-
function
|
|
6567
|
+
function readRecord2(value) {
|
|
6317
6568
|
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
6318
6569
|
}
|
|
6319
6570
|
function eventStatus(event, fallback) {
|
|
@@ -6336,7 +6587,7 @@ function instructionForStatus(status) {
|
|
|
6336
6587
|
return "Refine job failed; inspect result/finalBranchConvergenceState in mesh_task_history, fix the blocker, then rerun mesh_refine_node when ready.";
|
|
6337
6588
|
}
|
|
6338
6589
|
function mergeJob(jobs, patch) {
|
|
6339
|
-
const jobId =
|
|
6590
|
+
const jobId = readString4(patch.jobId);
|
|
6340
6591
|
if (!jobId) return;
|
|
6341
6592
|
const previous = jobs.get(jobId);
|
|
6342
6593
|
const status = patch.status || previous?.status || "running";
|
|
@@ -6354,54 +6605,54 @@ function mergeJob(jobs, patch) {
|
|
|
6354
6605
|
function buildMeshAsyncRefineJobs(args) {
|
|
6355
6606
|
const jobs = /* @__PURE__ */ new Map();
|
|
6356
6607
|
for (const entry of args.ledgerEntries || []) {
|
|
6357
|
-
const payload =
|
|
6608
|
+
const payload = readRecord2(entry.payload);
|
|
6358
6609
|
if (payload?.source !== "refine_mesh_node_async_job") continue;
|
|
6359
|
-
const refineJob =
|
|
6360
|
-
const result =
|
|
6361
|
-
const finalState =
|
|
6362
|
-
const jobId =
|
|
6610
|
+
const refineJob = readRecord2(payload.refineJob);
|
|
6611
|
+
const result = readRecord2(payload.result);
|
|
6612
|
+
const finalState = readRecord2(payload.finalBranchConvergenceState) || readRecord2(result?.finalBranchConvergenceState);
|
|
6613
|
+
const jobId = readString4(refineJob?.jobId);
|
|
6363
6614
|
if (!jobId) continue;
|
|
6364
|
-
const status = ledgerStatus(entry.kind,
|
|
6615
|
+
const status = ledgerStatus(entry.kind, readString4(refineJob?.status));
|
|
6365
6616
|
mergeJob(jobs, {
|
|
6366
6617
|
jobId,
|
|
6367
|
-
interactionId:
|
|
6618
|
+
interactionId: readString4(refineJob?.interactionId),
|
|
6368
6619
|
status,
|
|
6369
|
-
meshId:
|
|
6370
|
-
nodeId:
|
|
6371
|
-
targetNodeId:
|
|
6372
|
-
targetDaemonId:
|
|
6373
|
-
workspace:
|
|
6374
|
-
branch:
|
|
6375
|
-
into:
|
|
6376
|
-
startedAt:
|
|
6377
|
-
completedAt:
|
|
6378
|
-
retryOfJobId:
|
|
6620
|
+
meshId: readString4(refineJob?.meshId) || args.meshId,
|
|
6621
|
+
nodeId: readString4(refineJob?.nodeId) || entry.nodeId,
|
|
6622
|
+
targetNodeId: readString4(refineJob?.nodeId) || entry.nodeId,
|
|
6623
|
+
targetDaemonId: readString4(refineJob?.targetDaemonId),
|
|
6624
|
+
workspace: readString4(refineJob?.workspace),
|
|
6625
|
+
branch: readString4(result?.branch) || readString4(finalState?.branch),
|
|
6626
|
+
into: readString4(result?.into) || readString4(finalState?.baseBranch),
|
|
6627
|
+
startedAt: readString4(refineJob?.startedAt),
|
|
6628
|
+
completedAt: readString4(refineJob?.completedAt),
|
|
6629
|
+
retryOfJobId: readString4(refineJob?.retryOfJobId) || readString4(payload.retryOfJobId),
|
|
6379
6630
|
lastLedgerKind: entry.kind,
|
|
6380
6631
|
lastUpdatedAt: entry.timestamp
|
|
6381
6632
|
});
|
|
6382
6633
|
}
|
|
6383
6634
|
for (const event of args.pendingEvents || []) {
|
|
6384
|
-
const metadata =
|
|
6635
|
+
const metadata = readRecord2(event.metadataEvent);
|
|
6385
6636
|
if (metadata?.source !== "refine_mesh_node_async_job") continue;
|
|
6386
|
-
const result =
|
|
6387
|
-
const finalState =
|
|
6388
|
-
const jobId =
|
|
6637
|
+
const result = readRecord2(metadata.result);
|
|
6638
|
+
const finalState = readRecord2(result?.finalBranchConvergenceState);
|
|
6639
|
+
const jobId = readString4(metadata.jobId);
|
|
6389
6640
|
if (!jobId) continue;
|
|
6390
|
-
const status = eventStatus(event.event,
|
|
6641
|
+
const status = eventStatus(event.event, readString4(metadata.status));
|
|
6391
6642
|
mergeJob(jobs, {
|
|
6392
6643
|
jobId,
|
|
6393
|
-
interactionId:
|
|
6644
|
+
interactionId: readString4(metadata.interactionId),
|
|
6394
6645
|
...status ? { status } : {},
|
|
6395
|
-
meshId:
|
|
6396
|
-
nodeId:
|
|
6397
|
-
targetNodeId:
|
|
6398
|
-
targetDaemonId:
|
|
6399
|
-
workspace:
|
|
6400
|
-
branch:
|
|
6401
|
-
into:
|
|
6402
|
-
startedAt:
|
|
6403
|
-
completedAt:
|
|
6404
|
-
retryOfJobId:
|
|
6646
|
+
meshId: readString4(metadata.meshId) || event.meshId || args.meshId,
|
|
6647
|
+
nodeId: readString4(metadata.nodeId) || event.nodeId,
|
|
6648
|
+
targetNodeId: readString4(metadata.nodeId) || event.nodeId,
|
|
6649
|
+
targetDaemonId: readString4(metadata.targetDaemonId),
|
|
6650
|
+
workspace: readString4(metadata.workspace) || event.workspace,
|
|
6651
|
+
branch: readString4(result?.branch) || readString4(finalState?.branch),
|
|
6652
|
+
into: readString4(result?.into) || readString4(finalState?.baseBranch),
|
|
6653
|
+
startedAt: readString4(metadata.startedAt),
|
|
6654
|
+
completedAt: readString4(metadata.completedAt),
|
|
6655
|
+
retryOfJobId: readString4(metadata.retryOfJobId),
|
|
6405
6656
|
lastEvent: event.event,
|
|
6406
6657
|
lastUpdatedAt: new Date(event.queuedAt).toISOString()
|
|
6407
6658
|
});
|
|
@@ -6462,10 +6713,10 @@ var mesh_review_inbox_exports = {};
|
|
|
6462
6713
|
__export(mesh_review_inbox_exports, {
|
|
6463
6714
|
deriveMeshReviewInboxItems: () => deriveMeshReviewInboxItems
|
|
6464
6715
|
});
|
|
6465
|
-
function
|
|
6716
|
+
function readString5(value) {
|
|
6466
6717
|
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
6467
6718
|
}
|
|
6468
|
-
function
|
|
6719
|
+
function readRecord3(value) {
|
|
6469
6720
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
6470
6721
|
}
|
|
6471
6722
|
function readStringArray3(value, max) {
|
|
@@ -6475,20 +6726,20 @@ function readStringArray3(value, max) {
|
|
|
6475
6726
|
}
|
|
6476
6727
|
function isLocalNodeStatus(node) {
|
|
6477
6728
|
if (node.isLocalWorktree === true) return true;
|
|
6478
|
-
const connection =
|
|
6479
|
-
return
|
|
6729
|
+
const connection = readRecord3(node.connection);
|
|
6730
|
+
return readString5(connection?.state) === "self";
|
|
6480
6731
|
}
|
|
6481
6732
|
function readNodeConvergence(node) {
|
|
6482
|
-
const convergence =
|
|
6483
|
-
const status =
|
|
6733
|
+
const convergence = readRecord3(node.branchConvergence);
|
|
6734
|
+
const status = readString5(convergence?.status);
|
|
6484
6735
|
if (!convergence || !status) return null;
|
|
6485
6736
|
return {
|
|
6486
6737
|
status,
|
|
6487
|
-
reason:
|
|
6488
|
-
nextStep:
|
|
6738
|
+
reason: readString5(convergence.reason),
|
|
6739
|
+
nextStep: readString5(convergence.nextStep),
|
|
6489
6740
|
needsConvergence: convergence.needsConvergence === true,
|
|
6490
|
-
branch:
|
|
6491
|
-
defaultBranch:
|
|
6741
|
+
branch: readString5(convergence.branch),
|
|
6742
|
+
defaultBranch: readString5(convergence.defaultBranch)
|
|
6492
6743
|
};
|
|
6493
6744
|
}
|
|
6494
6745
|
function isMergeCandidate(convergence) {
|
|
@@ -6496,15 +6747,15 @@ function isMergeCandidate(convergence) {
|
|
|
6496
6747
|
return convergence.status === "cleanup_candidate" && convergence.reason === "clean_non_default_worktree_branch";
|
|
6497
6748
|
}
|
|
6498
6749
|
function readWorkerArtifact(value) {
|
|
6499
|
-
const worker =
|
|
6750
|
+
const worker = readRecord3(value);
|
|
6500
6751
|
if (!worker) return null;
|
|
6501
6752
|
const changed = readStringArray3(worker.changedFiles, MAX_CHANGED_FILES);
|
|
6502
6753
|
return {
|
|
6503
|
-
status:
|
|
6504
|
-
...
|
|
6754
|
+
status: readString5(worker.status) ?? "unknown",
|
|
6755
|
+
...readString5(worker.classification) ? { classification: readString5(worker.classification) } : {},
|
|
6505
6756
|
changedFiles: changed.values,
|
|
6506
6757
|
...changed.truncated ? { changedFilesTruncated: true } : {},
|
|
6507
|
-
validationResults: Array.isArray(worker.validationResults) ? worker.validationResults.map((item) =>
|
|
6758
|
+
validationResults: Array.isArray(worker.validationResults) ? worker.validationResults.map((item) => readRecord3(item)).filter((item) => item !== null) : [],
|
|
6508
6759
|
errors: readStringArray3(worker.errors, 20).values,
|
|
6509
6760
|
requiresUserAction: worker.requiresUserAction === true
|
|
6510
6761
|
};
|
|
@@ -6518,43 +6769,43 @@ function resolveNodeEvidence(nodeId, ledgerEntries) {
|
|
|
6518
6769
|
for (let i = ledgerEntries.length - 1; i >= 0; i--) {
|
|
6519
6770
|
const entry = ledgerEntries[i];
|
|
6520
6771
|
if (entry.nodeId !== nodeId || !isTerminalLedgerKind(entry.kind)) continue;
|
|
6521
|
-
const payload =
|
|
6772
|
+
const payload = readRecord3(entry.payload) ?? {};
|
|
6522
6773
|
if (!evidence.available) {
|
|
6523
6774
|
if (payload.source === "refine_mesh_node_async_job") {
|
|
6524
|
-
const result =
|
|
6525
|
-
const validationSummary =
|
|
6775
|
+
const result = readRecord3(payload.result);
|
|
6776
|
+
const validationSummary = readRecord3(result?.validationSummary);
|
|
6526
6777
|
evidence = {
|
|
6527
6778
|
available: true,
|
|
6528
6779
|
kind: entry.kind,
|
|
6529
6780
|
source: "refine_job",
|
|
6530
6781
|
timestamp: entry.timestamp,
|
|
6531
6782
|
...entry.sessionId ? { sessionId: entry.sessionId } : {},
|
|
6532
|
-
bootstrap:
|
|
6783
|
+
bootstrap: readRecord3(validationSummary?.bootstrap),
|
|
6533
6784
|
validation: validationSummary ? Object.fromEntries(Object.entries(validationSummary).filter(([key]) => key !== "bootstrap")) : null,
|
|
6534
|
-
checkpoint:
|
|
6785
|
+
checkpoint: readRecord3(result?.checkpoint),
|
|
6535
6786
|
worker: null,
|
|
6536
|
-
...
|
|
6537
|
-
...
|
|
6787
|
+
...readRecord3(payload.finalBranchConvergenceState) ?? readRecord3(result?.finalBranchConvergenceState) ? { finalBranchConvergenceState: readRecord3(payload.finalBranchConvergenceState) ?? readRecord3(result?.finalBranchConvergenceState) } : {},
|
|
6788
|
+
...readRecord3(payload.refineJob) ? { refineJob: readRecord3(payload.refineJob) } : {}
|
|
6538
6789
|
};
|
|
6539
6790
|
} else {
|
|
6540
|
-
const envelope =
|
|
6791
|
+
const envelope = readRecord3(payload.evidence);
|
|
6541
6792
|
evidence = {
|
|
6542
6793
|
available: true,
|
|
6543
6794
|
kind: entry.kind,
|
|
6544
6795
|
source: "task_completion",
|
|
6545
6796
|
timestamp: entry.timestamp,
|
|
6546
|
-
...
|
|
6797
|
+
...readString5(payload.taskId) ? { taskId: readString5(payload.taskId) } : {},
|
|
6547
6798
|
...entry.sessionId ? { sessionId: entry.sessionId } : {},
|
|
6548
6799
|
bootstrap: null,
|
|
6549
|
-
validation:
|
|
6550
|
-
checkpoint:
|
|
6800
|
+
validation: readRecord3(envelope?.validation),
|
|
6801
|
+
checkpoint: readRecord3(envelope?.checkpoint),
|
|
6551
6802
|
worker: readWorkerArtifact(envelope?.workerResult ?? payload.workerResult)
|
|
6552
6803
|
};
|
|
6553
6804
|
}
|
|
6554
6805
|
}
|
|
6555
6806
|
if (!transcriptHandle) {
|
|
6556
|
-
const envelope =
|
|
6557
|
-
transcriptHandle =
|
|
6807
|
+
const envelope = readRecord3(payload.evidence);
|
|
6808
|
+
transcriptHandle = readRecord3(envelope?.transcriptHandle);
|
|
6558
6809
|
}
|
|
6559
6810
|
if (evidence.available && transcriptHandle) break;
|
|
6560
6811
|
}
|
|
@@ -6564,11 +6815,11 @@ function hasBlockedReviewRefineResult(nodeId, ledgerEntries) {
|
|
|
6564
6815
|
for (let i = ledgerEntries.length - 1; i >= 0; i--) {
|
|
6565
6816
|
const entry = ledgerEntries[i];
|
|
6566
6817
|
if (entry.nodeId !== nodeId || !isTerminalLedgerKind(entry.kind)) continue;
|
|
6567
|
-
const payload =
|
|
6818
|
+
const payload = readRecord3(entry.payload) ?? {};
|
|
6568
6819
|
if (payload.source !== "refine_mesh_node_async_job") continue;
|
|
6569
|
-
const result =
|
|
6570
|
-
const finalState =
|
|
6571
|
-
return
|
|
6820
|
+
const result = readRecord3(payload.result);
|
|
6821
|
+
const finalState = readRecord3(payload.finalBranchConvergenceState) ?? readRecord3(result?.finalBranchConvergenceState);
|
|
6822
|
+
return readString5(finalState?.status) === "blocked_review" || readString5(result?.code) === "blocked_review";
|
|
6572
6823
|
}
|
|
6573
6824
|
return false;
|
|
6574
6825
|
}
|
|
@@ -6577,7 +6828,7 @@ function deriveMeshReviewInboxItems(args) {
|
|
|
6577
6828
|
const excludedRemoteNodeIds = [];
|
|
6578
6829
|
const refineJobs = buildMeshAsyncRefineJobs({ ledgerEntries: args.ledgerEntries });
|
|
6579
6830
|
for (const node of args.nodes) {
|
|
6580
|
-
const nodeId =
|
|
6831
|
+
const nodeId = readString5(node.nodeId) ?? readString5(node.id);
|
|
6581
6832
|
if (!nodeId) continue;
|
|
6582
6833
|
if (!isLocalNodeStatus(node)) {
|
|
6583
6834
|
excludedRemoteNodeIds.push(nodeId);
|
|
@@ -6599,8 +6850,8 @@ function deriveMeshReviewInboxItems(args) {
|
|
|
6599
6850
|
) ?? null;
|
|
6600
6851
|
items.push({
|
|
6601
6852
|
nodeId,
|
|
6602
|
-
workspace:
|
|
6603
|
-
branch: convergence.branch ??
|
|
6853
|
+
workspace: readString5(node.workspace),
|
|
6854
|
+
branch: convergence.branch ?? readString5(node.worktreeBranch),
|
|
6604
6855
|
defaultBranch: convergence.defaultBranch,
|
|
6605
6856
|
isLocalWorktree: node.isLocalWorktree === true,
|
|
6606
6857
|
reviewReason,
|
|
@@ -7811,251 +8062,6 @@ var init_mesh_fast_forward = __esm({
|
|
|
7811
8062
|
}
|
|
7812
8063
|
});
|
|
7813
8064
|
|
|
7814
|
-
// ../mesh-shared/dist/index.mjs
|
|
7815
|
-
function readRecord3(value) {
|
|
7816
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
7817
|
-
}
|
|
7818
|
-
function readString5(...values) {
|
|
7819
|
-
for (const value of values) {
|
|
7820
|
-
if (typeof value !== "string") continue;
|
|
7821
|
-
const trimmed = value.trim();
|
|
7822
|
-
if (trimmed) return trimmed;
|
|
7823
|
-
}
|
|
7824
|
-
return void 0;
|
|
7825
|
-
}
|
|
7826
|
-
function readNumber(...values) {
|
|
7827
|
-
for (const value of values) {
|
|
7828
|
-
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
7829
|
-
}
|
|
7830
|
-
return void 0;
|
|
7831
|
-
}
|
|
7832
|
-
function readBoolean(...values) {
|
|
7833
|
-
for (const value of values) {
|
|
7834
|
-
if (typeof value === "boolean") return value;
|
|
7835
|
-
}
|
|
7836
|
-
return void 0;
|
|
7837
|
-
}
|
|
7838
|
-
function joinRepoPath(root, relativePath) {
|
|
7839
|
-
const normalizedRoot = typeof root === "string" ? root.trim().replace(/[\\/]+$/, "") : "";
|
|
7840
|
-
const normalizedPath = typeof relativePath === "string" ? relativePath.trim() : "";
|
|
7841
|
-
if (!normalizedPath) return void 0;
|
|
7842
|
-
if (/^(?:[A-Za-z]:[\\/]|\/)/.test(normalizedPath)) return normalizedPath;
|
|
7843
|
-
if (!normalizedRoot) return void 0;
|
|
7844
|
-
return `${normalizedRoot}/${normalizedPath.replace(/^[\\/]+/, "")}`;
|
|
7845
|
-
}
|
|
7846
|
-
function scoreGitUpstreamFreshness(status) {
|
|
7847
|
-
switch (status) {
|
|
7848
|
-
case "fresh":
|
|
7849
|
-
return 30;
|
|
7850
|
-
case "no_upstream":
|
|
7851
|
-
return 4;
|
|
7852
|
-
case "unchecked":
|
|
7853
|
-
case void 0:
|
|
7854
|
-
return 0;
|
|
7855
|
-
case "stale":
|
|
7856
|
-
return -10;
|
|
7857
|
-
case "unavailable":
|
|
7858
|
-
return -15;
|
|
7859
|
-
default:
|
|
7860
|
-
return 0;
|
|
7861
|
-
}
|
|
7862
|
-
}
|
|
7863
|
-
function readGitSubmodules(value, parentRepoRoot) {
|
|
7864
|
-
if (!Array.isArray(value)) return void 0;
|
|
7865
|
-
const submodules = value.map((entry) => {
|
|
7866
|
-
const submodule = readRecord3(entry);
|
|
7867
|
-
const path42 = readString5(submodule.path);
|
|
7868
|
-
const commit = readString5(submodule.commit);
|
|
7869
|
-
const repoPath = readString5(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path42);
|
|
7870
|
-
if (!path42 || !commit) return null;
|
|
7871
|
-
const result = {
|
|
7872
|
-
path: path42,
|
|
7873
|
-
commit,
|
|
7874
|
-
dirty: readBoolean(submodule.dirty) ?? false,
|
|
7875
|
-
outOfSync: readBoolean(submodule.outOfSync, submodule.out_of_sync) ?? false,
|
|
7876
|
-
lastCheckedAt: readNumber(submodule.lastCheckedAt, submodule.last_checked_at) ?? Date.now()
|
|
7877
|
-
};
|
|
7878
|
-
if (repoPath) result.repoPath = repoPath;
|
|
7879
|
-
const error = readString5(submodule.error);
|
|
7880
|
-
if (error) result.error = error;
|
|
7881
|
-
return result;
|
|
7882
|
-
}).filter((entry) => entry !== null);
|
|
7883
|
-
return submodules.length > 0 ? submodules : void 0;
|
|
7884
|
-
}
|
|
7885
|
-
function hasGitStatusEvidence(status) {
|
|
7886
|
-
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(
|
|
7887
|
-
status.ahead,
|
|
7888
|
-
status.behind,
|
|
7889
|
-
status.staged,
|
|
7890
|
-
status.modified,
|
|
7891
|
-
status.untracked,
|
|
7892
|
-
status.deleted,
|
|
7893
|
-
status.renamed,
|
|
7894
|
-
status.lastCheckedAt,
|
|
7895
|
-
status.last_checked_at
|
|
7896
|
-
) !== void 0 || Array.isArray(status.submodules) && status.submodules.length > 0;
|
|
7897
|
-
}
|
|
7898
|
-
function normalizeGitStatus(status, node, options) {
|
|
7899
|
-
const explicitIsGitRepo = readBoolean(status.isGitRepo);
|
|
7900
|
-
if (!Object.keys(status).length || !hasGitStatusEvidence(status)) return void 0;
|
|
7901
|
-
const isGitRepo = explicitIsGitRepo ?? true;
|
|
7902
|
-
const conflictFiles = Array.isArray(status.conflictFiles) ? status.conflictFiles.filter((entry) => typeof entry === "string") : [];
|
|
7903
|
-
const conflictCount = readNumber(status.conflicts) ?? conflictFiles.length;
|
|
7904
|
-
const hasConflicts = readBoolean(status.hasConflicts) ?? conflictCount > 0;
|
|
7905
|
-
const repoRoot = readString5(status.repoRoot, status.repo_root, node.repoRoot, node.repo_root, status.workspace, node.workspace) || void 0;
|
|
7906
|
-
const submodules = readGitSubmodules(status.submodules, repoRoot);
|
|
7907
|
-
const upstreamStatus = readString5(status.upstreamStatus, status.upstream_status);
|
|
7908
|
-
const upstreamFetchedAt = readNumber(status.upstreamFetchedAt, status.upstream_fetched_at);
|
|
7909
|
-
const upstreamFetchError = readString5(status.upstreamFetchError, status.upstream_fetch_error);
|
|
7910
|
-
const error = readString5(status.error);
|
|
7911
|
-
const staged = readNumber(status.staged) ?? 0;
|
|
7912
|
-
const modified = readNumber(status.modified) ?? 0;
|
|
7913
|
-
const untracked = readNumber(status.untracked) ?? 0;
|
|
7914
|
-
const deleted = readNumber(status.deleted) ?? 0;
|
|
7915
|
-
const renamed = readNumber(status.renamed) ?? 0;
|
|
7916
|
-
return {
|
|
7917
|
-
workspace: readString5(status.workspace, node.workspace) || "",
|
|
7918
|
-
repoRoot: repoRoot ?? null,
|
|
7919
|
-
isGitRepo,
|
|
7920
|
-
branch: readString5(status.branch) ?? null,
|
|
7921
|
-
headCommit: readString5(status.headCommit) ?? null,
|
|
7922
|
-
headMessage: readString5(status.headMessage) ?? null,
|
|
7923
|
-
upstream: readString5(status.upstream) ?? null,
|
|
7924
|
-
upstreamStatus: upstreamStatus ?? "unchecked",
|
|
7925
|
-
...upstreamFetchedAt !== void 0 ? { upstreamFetchedAt } : {},
|
|
7926
|
-
...upstreamFetchError ? { upstreamFetchError } : {},
|
|
7927
|
-
ahead: readNumber(status.ahead) ?? 0,
|
|
7928
|
-
behind: readNumber(status.behind) ?? 0,
|
|
7929
|
-
staged,
|
|
7930
|
-
modified,
|
|
7931
|
-
untracked,
|
|
7932
|
-
deleted,
|
|
7933
|
-
renamed,
|
|
7934
|
-
dirty: readBoolean(status.dirty, status.isDirty, status.is_dirty) ?? (staged + modified + untracked + deleted + renamed > 0 || hasConflicts),
|
|
7935
|
-
hasConflicts,
|
|
7936
|
-
conflictFiles,
|
|
7937
|
-
stashCount: readNumber(status.stashCount, status.stash_count) ?? 0,
|
|
7938
|
-
lastCheckedAt: options?.lastCheckedAt ?? readNumber(status.lastCheckedAt, status.last_checked_at) ?? Date.now(),
|
|
7939
|
-
...submodules ? { submodules } : {},
|
|
7940
|
-
...error ? { error } : {}
|
|
7941
|
-
};
|
|
7942
|
-
}
|
|
7943
|
-
function scoreGitStatusCandidate(git) {
|
|
7944
|
-
if (!git) return Number.NEGATIVE_INFINITY;
|
|
7945
|
-
let score = 0;
|
|
7946
|
-
if (git.isGitRepo === true) score += 50;
|
|
7947
|
-
if (git.isGitRepo === false) score -= 10;
|
|
7948
|
-
if (git.branch) score += 20;
|
|
7949
|
-
if (git.headCommit) score += 20;
|
|
7950
|
-
if (git.upstream) score += 10;
|
|
7951
|
-
score += scoreGitUpstreamFreshness(git.upstreamStatus);
|
|
7952
|
-
if (typeof git.ahead === "number") score += 2;
|
|
7953
|
-
if (typeof git.behind === "number") score += 2;
|
|
7954
|
-
if (Array.isArray(git.submodules) && git.submodules.length > 0) score += 4 + git.submodules.length;
|
|
7955
|
-
if (git.error) score -= 20;
|
|
7956
|
-
return score;
|
|
7957
|
-
}
|
|
7958
|
-
function pickBestTransitGitStatus(node, options) {
|
|
7959
|
-
const rawGit = readRecord3(node.lastGit ?? node.last_git);
|
|
7960
|
-
const gitResult = readRecord3(rawGit.result);
|
|
7961
|
-
const directStatus = readRecord3(rawGit.status);
|
|
7962
|
-
const nestedStatus = readRecord3(gitResult.status);
|
|
7963
|
-
const rawProbe = readRecord3(node.lastProbe ?? node.last_probe);
|
|
7964
|
-
const probeGit = readRecord3(rawProbe.git);
|
|
7965
|
-
const probeGitResult = readRecord3(probeGit.result);
|
|
7966
|
-
const probeDirectStatus = readRecord3(probeGit.status);
|
|
7967
|
-
const probeNestedStatus = readRecord3(probeGitResult.status);
|
|
7968
|
-
const lastCheckedAt = options?.lastCheckedAt;
|
|
7969
|
-
let best = null;
|
|
7970
|
-
for (const status of [directStatus, nestedStatus, probeDirectStatus, probeNestedStatus]) {
|
|
7971
|
-
const normalized = normalizeGitStatus(status, node, { lastCheckedAt: lastCheckedAt ?? Date.now() });
|
|
7972
|
-
if (!normalized) continue;
|
|
7973
|
-
const score = scoreGitStatusCandidate(normalized);
|
|
7974
|
-
if (!best || score > best.score) best = { git: normalized, score };
|
|
7975
|
-
}
|
|
7976
|
-
return best?.git;
|
|
7977
|
-
}
|
|
7978
|
-
function normalizeMeshNodeId(node) {
|
|
7979
|
-
const record = node && typeof node === "object" ? node : {};
|
|
7980
|
-
return readString5(record.id, record.nodeId, record.node_id);
|
|
7981
|
-
}
|
|
7982
|
-
function meshNodeIdMatches(node, candidateId) {
|
|
7983
|
-
if (!candidateId) return false;
|
|
7984
|
-
const trimmed = candidateId.trim();
|
|
7985
|
-
if (!trimmed) return false;
|
|
7986
|
-
return normalizeMeshNodeId(node) === trimmed;
|
|
7987
|
-
}
|
|
7988
|
-
function machineCoreFromDaemonId(id) {
|
|
7989
|
-
const trimmed = readString5(id);
|
|
7990
|
-
if (!trimmed) return void 0;
|
|
7991
|
-
for (const prefix of DAEMON_ID_PREFIXES) {
|
|
7992
|
-
if (trimmed.startsWith(prefix)) {
|
|
7993
|
-
const core = trimmed.slice(prefix.length).trim();
|
|
7994
|
-
return core || void 0;
|
|
7995
|
-
}
|
|
7996
|
-
}
|
|
7997
|
-
return trimmed;
|
|
7998
|
-
}
|
|
7999
|
-
function expandDaemonIdForms(ids) {
|
|
8000
|
-
const list = Array.isArray(ids) ? ids : ids != null ? [ids] : [];
|
|
8001
|
-
const out = [];
|
|
8002
|
-
const seen = /* @__PURE__ */ new Set();
|
|
8003
|
-
const add = (value) => {
|
|
8004
|
-
if (!value || seen.has(value)) return;
|
|
8005
|
-
seen.add(value);
|
|
8006
|
-
out.push(value);
|
|
8007
|
-
};
|
|
8008
|
-
for (const raw of list) add(readString5(raw));
|
|
8009
|
-
for (const raw of list) {
|
|
8010
|
-
const core = machineCoreFromDaemonId(readString5(raw));
|
|
8011
|
-
if (!core || !core.startsWith("mach_")) continue;
|
|
8012
|
-
add(core);
|
|
8013
|
-
for (const prefix of DAEMON_ID_PREFIXES) add(`${prefix}${core}`);
|
|
8014
|
-
}
|
|
8015
|
-
return out;
|
|
8016
|
-
}
|
|
8017
|
-
function summarizeGitShape(status) {
|
|
8018
|
-
const record = readRecord3(status);
|
|
8019
|
-
if (!Object.keys(record).length) return null;
|
|
8020
|
-
const submodules = Array.isArray(record.submodules) ? record.submodules.map((entry) => {
|
|
8021
|
-
const sub = readRecord3(entry);
|
|
8022
|
-
return {
|
|
8023
|
-
path: readString5(sub.path) ?? null,
|
|
8024
|
-
commit: readString5(sub.commit)?.slice(0, 12) ?? null,
|
|
8025
|
-
dirty: readBoolean(sub.dirty) ?? false,
|
|
8026
|
-
outOfSync: readBoolean(sub.outOfSync, sub.out_of_sync) ?? false
|
|
8027
|
-
};
|
|
8028
|
-
}) : [];
|
|
8029
|
-
return {
|
|
8030
|
-
isGitRepo: readBoolean(record.isGitRepo),
|
|
8031
|
-
workspace: readString5(record.workspace) ?? null,
|
|
8032
|
-
repoRoot: readString5(record.repoRoot, record.repo_root) ?? null,
|
|
8033
|
-
branch: readString5(record.branch) ?? null,
|
|
8034
|
-
upstream: readString5(record.upstream) ?? null,
|
|
8035
|
-
upstreamStatus: readString5(record.upstreamStatus, record.upstream_status) ?? null,
|
|
8036
|
-
headCommit: readString5(record.headCommit, record.head_commit)?.slice(0, 12) ?? null,
|
|
8037
|
-
ahead: readNumber(record.ahead) ?? null,
|
|
8038
|
-
behind: readNumber(record.behind) ?? null,
|
|
8039
|
-
dirtyCounts: {
|
|
8040
|
-
staged: readNumber(record.staged) ?? 0,
|
|
8041
|
-
modified: readNumber(record.modified) ?? 0,
|
|
8042
|
-
untracked: readNumber(record.untracked) ?? 0,
|
|
8043
|
-
deleted: readNumber(record.deleted) ?? 0,
|
|
8044
|
-
renamed: readNumber(record.renamed) ?? 0
|
|
8045
|
-
},
|
|
8046
|
-
lastCheckedAt: readNumber(record.lastCheckedAt, record.last_checked_at) ?? null,
|
|
8047
|
-
submoduleCount: submodules.length,
|
|
8048
|
-
submodules
|
|
8049
|
-
};
|
|
8050
|
-
}
|
|
8051
|
-
var DAEMON_ID_PREFIXES;
|
|
8052
|
-
var init_dist = __esm({
|
|
8053
|
-
"../mesh-shared/dist/index.mjs"() {
|
|
8054
|
-
"use strict";
|
|
8055
|
-
DAEMON_ID_PREFIXES = ["daemon_", "standalone_"];
|
|
8056
|
-
}
|
|
8057
|
-
});
|
|
8058
|
-
|
|
8059
8065
|
// src/mesh/mesh-active-work.ts
|
|
8060
8066
|
function readString6(value) {
|
|
8061
8067
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
@@ -21435,6 +21441,7 @@ function getSavedProviderSessions(state, filters) {
|
|
|
21435
21441
|
|
|
21436
21442
|
// src/index.ts
|
|
21437
21443
|
init_mesh_config();
|
|
21444
|
+
init_dist();
|
|
21438
21445
|
init_coordinator_prompt();
|
|
21439
21446
|
init_mesh_missions();
|
|
21440
21447
|
init_mesh_task_stats();
|
|
@@ -39031,9 +39038,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
39031
39038
|
}
|
|
39032
39039
|
}
|
|
39033
39040
|
}
|
|
39034
|
-
|
|
39035
|
-
|
|
39036
|
-
|
|
39041
|
+
if (!opts?.instanceKey) {
|
|
39042
|
+
for (const [k, a] of this.adapters) {
|
|
39043
|
+
if (a.cliType === agentType) {
|
|
39044
|
+
return { adapter: a, key: k };
|
|
39045
|
+
}
|
|
39037
39046
|
}
|
|
39038
39047
|
}
|
|
39039
39048
|
return null;
|
|
@@ -46390,7 +46399,14 @@ var MESH_FORWARDABLE_SESSION_COMMANDS = /* @__PURE__ */ new Set([
|
|
|
46390
46399
|
"resolve_action",
|
|
46391
46400
|
"set_mode",
|
|
46392
46401
|
"change_model",
|
|
46393
|
-
"set_thought_level"
|
|
46402
|
+
"set_thought_level",
|
|
46403
|
+
// agent_command (send_chat / clear_history / stop) is session-scoped too: a command
|
|
46404
|
+
// explicitly naming a targetSessionId MUST reach that session wherever it lives, never a
|
|
46405
|
+
// different local session. Without forwarding, a misrouted/relayed send_chat for a REMOTE
|
|
46406
|
+
// worker session that reaches the wrong daemon used to fuzzy-inject the task body into that
|
|
46407
|
+
// daemon's own CLI session (TASKECHO coordinator self-echo). Forwarding to the owning daemon
|
|
46408
|
+
// delivers it to the real worker instead. (findAdapter is also fail-closed as the backstop.)
|
|
46409
|
+
"agent_command"
|
|
46394
46410
|
]);
|
|
46395
46411
|
var READ_DEBUG_ENABLED2 = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
|
|
46396
46412
|
function normalizeCommandSource(source) {
|
|
@@ -46743,7 +46759,7 @@ var DaemonCommandRouter = class {
|
|
|
46743
46759
|
if (!collectMeshNodeHostedSessionIds(node).has(trimmed)) continue;
|
|
46744
46760
|
const nodeDaemonId = readMeshNodeDaemonId(readObjectRecord(node));
|
|
46745
46761
|
if (!nodeDaemonId) continue;
|
|
46746
|
-
if (selfDaemonId && nodeDaemonId
|
|
46762
|
+
if (selfDaemonId && daemonIdsEquivalent(nodeDaemonId, selfDaemonId)) return void 0;
|
|
46747
46763
|
return nodeDaemonId;
|
|
46748
46764
|
}
|
|
46749
46765
|
return void 0;
|
|
@@ -46898,6 +46914,38 @@ var DaemonCommandRouter = class {
|
|
|
46898
46914
|
if (record?.meta?.meshNodeId === nodeId) return true;
|
|
46899
46915
|
return false;
|
|
46900
46916
|
}
|
|
46917
|
+
/**
|
|
46918
|
+
* Best-effort recursive removal of a managed worktree directory.
|
|
46919
|
+
*
|
|
46920
|
+
* The git-registry de-registration is the safety-critical step of worktree
|
|
46921
|
+
* teardown; a leftover directory must never gate dropping the node from the
|
|
46922
|
+
* mesh. On Windows, `fs.rmSync` can throw EINVAL/EPERM/EBUSY on submodule
|
|
46923
|
+
* gitlink (`.git`) files, long paths, junctions, or while a just-stopped
|
|
46924
|
+
* delegate session is still releasing a handle/cwd on the directory. This
|
|
46925
|
+
* helper absorbs those errors (never throws), with bounded retries + backoff
|
|
46926
|
+
* to give handles time to release, and reports whether residue remains.
|
|
46927
|
+
*/
|
|
46928
|
+
async bestEffortRemoveWorktreeDir(dir) {
|
|
46929
|
+
if (!dir || !fs26.existsSync(dir)) return { removed: true, residue: false };
|
|
46930
|
+
const sleep3 = (ms) => new Promise((resolve24) => setTimeout(resolve24, ms));
|
|
46931
|
+
const ABSORB = /* @__PURE__ */ new Set(["EINVAL", "EPERM", "EBUSY", "ENOTEMPTY", "EACCES", "EMFILE", "ENFILE"]);
|
|
46932
|
+
let lastErr;
|
|
46933
|
+
for (let attempt = 0; attempt < 4; attempt++) {
|
|
46934
|
+
try {
|
|
46935
|
+
fs26.rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
46936
|
+
if (!fs26.existsSync(dir)) return { removed: true, residue: false };
|
|
46937
|
+
lastErr = new Error("directory still present after rmSync");
|
|
46938
|
+
} catch (e) {
|
|
46939
|
+
lastErr = e;
|
|
46940
|
+
const code = typeof e?.code === "string" ? e.code : "";
|
|
46941
|
+
if (code && !ABSORB.has(code)) {
|
|
46942
|
+
break;
|
|
46943
|
+
}
|
|
46944
|
+
}
|
|
46945
|
+
await sleep3(150 * (attempt + 1));
|
|
46946
|
+
}
|
|
46947
|
+
return fs26.existsSync(dir) ? { removed: false, residue: true, error: String(lastErr?.message || lastErr || "unknown rm error") } : { removed: true, residue: false };
|
|
46948
|
+
}
|
|
46901
46949
|
async cleanupLocalWorktreeNode(args) {
|
|
46902
46950
|
const workspace = typeof args.node?.workspace === "string" ? args.node.workspace.trim() : "";
|
|
46903
46951
|
if (!workspace) {
|
|
@@ -46952,11 +47000,31 @@ var DaemonCommandRouter = class {
|
|
|
46952
47000
|
const entries = await listWorktrees2(repoRoot);
|
|
46953
47001
|
const managedEntry = entries.find((entry) => normalizePath(entry.path) === actualPath);
|
|
46954
47002
|
if (!managedEntry) {
|
|
47003
|
+
try {
|
|
47004
|
+
const { execFile: execFile5 } = await import("child_process");
|
|
47005
|
+
const { promisify: promisify8 } = await import("util");
|
|
47006
|
+
const execFileAsync4 = promisify8(execFile5);
|
|
47007
|
+
await execFileAsync4("git", ["worktree", "prune"], {
|
|
47008
|
+
cwd: repoRoot,
|
|
47009
|
+
encoding: "utf8",
|
|
47010
|
+
timeout: 3e4,
|
|
47011
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
47012
|
+
windowsHide: true
|
|
47013
|
+
});
|
|
47014
|
+
} catch {
|
|
47015
|
+
}
|
|
47016
|
+
const rm = await this.bestEffortRemoveWorktreeDir(workspace);
|
|
46955
47017
|
return {
|
|
46956
|
-
success:
|
|
46957
|
-
|
|
46958
|
-
|
|
46959
|
-
|
|
47018
|
+
success: true,
|
|
47019
|
+
removedPath: workspace,
|
|
47020
|
+
repoRoot,
|
|
47021
|
+
reason: "worktree_unregistered_residue_recovered",
|
|
47022
|
+
recovered: true,
|
|
47023
|
+
...rm.residue ? {
|
|
47024
|
+
residue: true,
|
|
47025
|
+
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.`,
|
|
47026
|
+
residueError: rm.error
|
|
47027
|
+
} : {}
|
|
46960
47028
|
};
|
|
46961
47029
|
}
|
|
46962
47030
|
if (managedEntry.branch && managedEntry.branch !== args.node.worktreeBranch) {
|
|
@@ -47019,8 +47087,8 @@ var DaemonCommandRouter = class {
|
|
|
47019
47087
|
convergence: forceFallbackConvergence
|
|
47020
47088
|
};
|
|
47021
47089
|
} catch (deinitError) {
|
|
47090
|
+
const rm = await this.bestEffortRemoveWorktreeDir(workspace);
|
|
47022
47091
|
try {
|
|
47023
|
-
fs26.rmSync(workspace, { recursive: true, force: true });
|
|
47024
47092
|
await execFileAsync4("git", ["worktree", "prune"], {
|
|
47025
47093
|
cwd: repoRoot,
|
|
47026
47094
|
encoding: "utf8",
|
|
@@ -47028,23 +47096,22 @@ var DaemonCommandRouter = class {
|
|
|
47028
47096
|
maxBuffer: GIT_MAX_BUFFER_CLEANUP,
|
|
47029
47097
|
windowsHide: true
|
|
47030
47098
|
});
|
|
47031
|
-
|
|
47032
|
-
success: true,
|
|
47033
|
-
removedPath: workspace,
|
|
47034
|
-
repoRoot,
|
|
47035
|
-
fallback: "fs_rm_worktree_prune",
|
|
47036
|
-
forced: true,
|
|
47037
|
-
reason: "working_trees_containing_submodules",
|
|
47038
|
-
convergence: forceFallbackConvergence
|
|
47039
|
-
};
|
|
47040
|
-
} catch (rmError) {
|
|
47041
|
-
return {
|
|
47042
|
-
success: false,
|
|
47043
|
-
code: "mesh_worktree_cleanup_failed",
|
|
47044
|
-
error: `All removal fallbacks exhausted. deinit+remove: ${deinitError?.message || deinitError}; rmSync+prune: ${rmError?.message || rmError}`,
|
|
47045
|
-
recoveryHint: "Manually remove the worktree directory and run git worktree prune from the source repo."
|
|
47046
|
-
};
|
|
47099
|
+
} catch {
|
|
47047
47100
|
}
|
|
47101
|
+
return {
|
|
47102
|
+
success: true,
|
|
47103
|
+
removedPath: workspace,
|
|
47104
|
+
repoRoot,
|
|
47105
|
+
fallback: "fs_rm_worktree_prune",
|
|
47106
|
+
forced: true,
|
|
47107
|
+
reason: "working_trees_containing_submodules",
|
|
47108
|
+
convergence: forceFallbackConvergence,
|
|
47109
|
+
...rm.residue ? {
|
|
47110
|
+
residue: true,
|
|
47111
|
+
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.`,
|
|
47112
|
+
residueError: rm.error
|
|
47113
|
+
} : {}
|
|
47114
|
+
};
|
|
47048
47115
|
}
|
|
47049
47116
|
}
|
|
47050
47117
|
return {
|
|
@@ -50443,7 +50510,14 @@ ${hintLines.join("\n")}` : "",
|
|
|
50443
50510
|
} catch {
|
|
50444
50511
|
}
|
|
50445
50512
|
}
|
|
50446
|
-
|
|
50513
|
+
const residueWarning = worktreeCleanup?.residue === true && typeof worktreeCleanup?.residueWarning === "string" ? worktreeCleanup.residueWarning : void 0;
|
|
50514
|
+
return {
|
|
50515
|
+
success: true,
|
|
50516
|
+
removed,
|
|
50517
|
+
...residueWarning ? { residueWarning } : {},
|
|
50518
|
+
...sessionCleanup ? { sessionCleanup } : {},
|
|
50519
|
+
...worktreeCleanup ? { worktreeCleanup } : {}
|
|
50520
|
+
};
|
|
50447
50521
|
} catch (e) {
|
|
50448
50522
|
return { success: false, error: e.message };
|
|
50449
50523
|
}
|
|
@@ -60443,6 +60517,7 @@ export {
|
|
|
60443
60517
|
createNativeHistoryDispatcher,
|
|
60444
60518
|
createSessionDelivery,
|
|
60445
60519
|
createWorktree,
|
|
60520
|
+
daemonIdsEquivalent,
|
|
60446
60521
|
deleteDirectDispatchesByTaskId,
|
|
60447
60522
|
deleteMesh,
|
|
60448
60523
|
deriveMeshReviewInboxItems,
|
|
@@ -60456,6 +60531,7 @@ export {
|
|
|
60456
60531
|
ensureSessionHostReady,
|
|
60457
60532
|
evaluateFsm,
|
|
60458
60533
|
execNpmCommandSync,
|
|
60534
|
+
expandDaemonIdForms,
|
|
60459
60535
|
fastForwardMeshNode,
|
|
60460
60536
|
filterActivityChatMessages,
|
|
60461
60537
|
filterChatMessagesByVisibility,
|
|
@@ -60546,6 +60622,7 @@ export {
|
|
|
60546
60622
|
loadMeshWorktreeBootstrapConfig,
|
|
60547
60623
|
loadState,
|
|
60548
60624
|
logCommand,
|
|
60625
|
+
machineCoreFromDaemonId,
|
|
60549
60626
|
markSessionDeliveriesTerminal,
|
|
60550
60627
|
markSetupComplete,
|
|
60551
60628
|
markStaleDirectDispatches,
|