@adhdev/daemon-standalone 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/index.js +421 -344
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/vendor/mcp-server/index.js +3 -3
- package/vendor/mcp-server/index.js.map +1 -1
package/dist/index.js
CHANGED
|
@@ -30036,10 +30036,10 @@ var require_dist3 = __commonJS({
|
|
|
30036
30036
|
}
|
|
30037
30037
|
function getDaemonBuildInfo() {
|
|
30038
30038
|
if (cached2) return cached2;
|
|
30039
|
-
const commit = readInjected(true ? "
|
|
30040
|
-
const commitShort = readInjected(true ? "
|
|
30041
|
-
const version2 = readInjected(true ? "0.9.82-rc.
|
|
30042
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
30039
|
+
const commit = readInjected(true ? "a680b74d9b940b82f691ebb85a725a1a72445bfc" : void 0) ?? "unknown";
|
|
30040
|
+
const commitShort = readInjected(true ? "a680b74d" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
30041
|
+
const version2 = readInjected(true ? "0.9.82-rc.353" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
30042
|
+
const builtAt = readInjected(true ? "2026-06-22T09:11:41.749Z" : void 0);
|
|
30043
30043
|
cached2 = builtAt ? { commit, commitShort, version: version2, builtAt } : { commit, commitShort, version: version2 };
|
|
30044
30044
|
return cached2;
|
|
30045
30045
|
}
|
|
@@ -32442,6 +32442,255 @@ ${error48.message || ""}`;
|
|
|
32442
32442
|
SPAWNED_SESSION_VISIBILITY_MODES = /* @__PURE__ */ new Set(["visible", "hidden"]);
|
|
32443
32443
|
}
|
|
32444
32444
|
});
|
|
32445
|
+
function readRecord(value) {
|
|
32446
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
32447
|
+
}
|
|
32448
|
+
function readString3(...values) {
|
|
32449
|
+
for (const value of values) {
|
|
32450
|
+
if (typeof value !== "string") continue;
|
|
32451
|
+
const trimmed = value.trim();
|
|
32452
|
+
if (trimmed) return trimmed;
|
|
32453
|
+
}
|
|
32454
|
+
return void 0;
|
|
32455
|
+
}
|
|
32456
|
+
function readNumber(...values) {
|
|
32457
|
+
for (const value of values) {
|
|
32458
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
32459
|
+
}
|
|
32460
|
+
return void 0;
|
|
32461
|
+
}
|
|
32462
|
+
function readBoolean(...values) {
|
|
32463
|
+
for (const value of values) {
|
|
32464
|
+
if (typeof value === "boolean") return value;
|
|
32465
|
+
}
|
|
32466
|
+
return void 0;
|
|
32467
|
+
}
|
|
32468
|
+
function joinRepoPath(root, relativePath) {
|
|
32469
|
+
const normalizedRoot = typeof root === "string" ? root.trim().replace(/[\\/]+$/, "") : "";
|
|
32470
|
+
const normalizedPath = typeof relativePath === "string" ? relativePath.trim() : "";
|
|
32471
|
+
if (!normalizedPath) return void 0;
|
|
32472
|
+
if (/^(?:[A-Za-z]:[\\/]|\/)/.test(normalizedPath)) return normalizedPath;
|
|
32473
|
+
if (!normalizedRoot) return void 0;
|
|
32474
|
+
return `${normalizedRoot}/${normalizedPath.replace(/^[\\/]+/, "")}`;
|
|
32475
|
+
}
|
|
32476
|
+
function scoreGitUpstreamFreshness(status) {
|
|
32477
|
+
switch (status) {
|
|
32478
|
+
case "fresh":
|
|
32479
|
+
return 30;
|
|
32480
|
+
case "no_upstream":
|
|
32481
|
+
return 4;
|
|
32482
|
+
case "unchecked":
|
|
32483
|
+
case void 0:
|
|
32484
|
+
return 0;
|
|
32485
|
+
case "stale":
|
|
32486
|
+
return -10;
|
|
32487
|
+
case "unavailable":
|
|
32488
|
+
return -15;
|
|
32489
|
+
default:
|
|
32490
|
+
return 0;
|
|
32491
|
+
}
|
|
32492
|
+
}
|
|
32493
|
+
function readGitSubmodules(value, parentRepoRoot) {
|
|
32494
|
+
if (!Array.isArray(value)) return void 0;
|
|
32495
|
+
const submodules = value.map((entry) => {
|
|
32496
|
+
const submodule = readRecord(entry);
|
|
32497
|
+
const path422 = readString3(submodule.path);
|
|
32498
|
+
const commit = readString3(submodule.commit);
|
|
32499
|
+
const repoPath = readString3(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path422);
|
|
32500
|
+
if (!path422 || !commit) return null;
|
|
32501
|
+
const result = {
|
|
32502
|
+
path: path422,
|
|
32503
|
+
commit,
|
|
32504
|
+
dirty: readBoolean(submodule.dirty) ?? false,
|
|
32505
|
+
outOfSync: readBoolean(submodule.outOfSync, submodule.out_of_sync) ?? false,
|
|
32506
|
+
lastCheckedAt: readNumber(submodule.lastCheckedAt, submodule.last_checked_at) ?? Date.now()
|
|
32507
|
+
};
|
|
32508
|
+
if (repoPath) result.repoPath = repoPath;
|
|
32509
|
+
const error48 = readString3(submodule.error);
|
|
32510
|
+
if (error48) result.error = error48;
|
|
32511
|
+
return result;
|
|
32512
|
+
}).filter((entry) => entry !== null);
|
|
32513
|
+
return submodules.length > 0 ? submodules : void 0;
|
|
32514
|
+
}
|
|
32515
|
+
function hasGitStatusEvidence(status) {
|
|
32516
|
+
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(
|
|
32517
|
+
status.ahead,
|
|
32518
|
+
status.behind,
|
|
32519
|
+
status.staged,
|
|
32520
|
+
status.modified,
|
|
32521
|
+
status.untracked,
|
|
32522
|
+
status.deleted,
|
|
32523
|
+
status.renamed,
|
|
32524
|
+
status.lastCheckedAt,
|
|
32525
|
+
status.last_checked_at
|
|
32526
|
+
) !== void 0 || Array.isArray(status.submodules) && status.submodules.length > 0;
|
|
32527
|
+
}
|
|
32528
|
+
function normalizeGitStatus(status, node, options) {
|
|
32529
|
+
const explicitIsGitRepo = readBoolean(status.isGitRepo);
|
|
32530
|
+
if (!Object.keys(status).length || !hasGitStatusEvidence(status)) return void 0;
|
|
32531
|
+
const isGitRepo = explicitIsGitRepo ?? true;
|
|
32532
|
+
const conflictFiles = Array.isArray(status.conflictFiles) ? status.conflictFiles.filter((entry) => typeof entry === "string") : [];
|
|
32533
|
+
const conflictCount = readNumber(status.conflicts) ?? conflictFiles.length;
|
|
32534
|
+
const hasConflicts = readBoolean(status.hasConflicts) ?? conflictCount > 0;
|
|
32535
|
+
const repoRoot = readString3(status.repoRoot, status.repo_root, node.repoRoot, node.repo_root, status.workspace, node.workspace) || void 0;
|
|
32536
|
+
const submodules = readGitSubmodules(status.submodules, repoRoot);
|
|
32537
|
+
const upstreamStatus = readString3(status.upstreamStatus, status.upstream_status);
|
|
32538
|
+
const upstreamFetchedAt = readNumber(status.upstreamFetchedAt, status.upstream_fetched_at);
|
|
32539
|
+
const upstreamFetchError = readString3(status.upstreamFetchError, status.upstream_fetch_error);
|
|
32540
|
+
const error48 = readString3(status.error);
|
|
32541
|
+
const staged = readNumber(status.staged) ?? 0;
|
|
32542
|
+
const modified = readNumber(status.modified) ?? 0;
|
|
32543
|
+
const untracked = readNumber(status.untracked) ?? 0;
|
|
32544
|
+
const deleted = readNumber(status.deleted) ?? 0;
|
|
32545
|
+
const renamed = readNumber(status.renamed) ?? 0;
|
|
32546
|
+
return {
|
|
32547
|
+
workspace: readString3(status.workspace, node.workspace) || "",
|
|
32548
|
+
repoRoot: repoRoot ?? null,
|
|
32549
|
+
isGitRepo,
|
|
32550
|
+
branch: readString3(status.branch) ?? null,
|
|
32551
|
+
headCommit: readString3(status.headCommit) ?? null,
|
|
32552
|
+
headMessage: readString3(status.headMessage) ?? null,
|
|
32553
|
+
upstream: readString3(status.upstream) ?? null,
|
|
32554
|
+
upstreamStatus: upstreamStatus ?? "unchecked",
|
|
32555
|
+
...upstreamFetchedAt !== void 0 ? { upstreamFetchedAt } : {},
|
|
32556
|
+
...upstreamFetchError ? { upstreamFetchError } : {},
|
|
32557
|
+
ahead: readNumber(status.ahead) ?? 0,
|
|
32558
|
+
behind: readNumber(status.behind) ?? 0,
|
|
32559
|
+
staged,
|
|
32560
|
+
modified,
|
|
32561
|
+
untracked,
|
|
32562
|
+
deleted,
|
|
32563
|
+
renamed,
|
|
32564
|
+
dirty: readBoolean(status.dirty, status.isDirty, status.is_dirty) ?? (staged + modified + untracked + deleted + renamed > 0 || hasConflicts),
|
|
32565
|
+
hasConflicts,
|
|
32566
|
+
conflictFiles,
|
|
32567
|
+
stashCount: readNumber(status.stashCount, status.stash_count) ?? 0,
|
|
32568
|
+
lastCheckedAt: options?.lastCheckedAt ?? readNumber(status.lastCheckedAt, status.last_checked_at) ?? Date.now(),
|
|
32569
|
+
...submodules ? { submodules } : {},
|
|
32570
|
+
...error48 ? { error: error48 } : {}
|
|
32571
|
+
};
|
|
32572
|
+
}
|
|
32573
|
+
function scoreGitStatusCandidate(git) {
|
|
32574
|
+
if (!git) return Number.NEGATIVE_INFINITY;
|
|
32575
|
+
let score = 0;
|
|
32576
|
+
if (git.isGitRepo === true) score += 50;
|
|
32577
|
+
if (git.isGitRepo === false) score -= 10;
|
|
32578
|
+
if (git.branch) score += 20;
|
|
32579
|
+
if (git.headCommit) score += 20;
|
|
32580
|
+
if (git.upstream) score += 10;
|
|
32581
|
+
score += scoreGitUpstreamFreshness(git.upstreamStatus);
|
|
32582
|
+
if (typeof git.ahead === "number") score += 2;
|
|
32583
|
+
if (typeof git.behind === "number") score += 2;
|
|
32584
|
+
if (Array.isArray(git.submodules) && git.submodules.length > 0) score += 4 + git.submodules.length;
|
|
32585
|
+
if (git.error) score -= 20;
|
|
32586
|
+
return score;
|
|
32587
|
+
}
|
|
32588
|
+
function pickBestTransitGitStatus(node, options) {
|
|
32589
|
+
const rawGit = readRecord(node.lastGit ?? node.last_git);
|
|
32590
|
+
const gitResult = readRecord(rawGit.result);
|
|
32591
|
+
const directStatus = readRecord(rawGit.status);
|
|
32592
|
+
const nestedStatus = readRecord(gitResult.status);
|
|
32593
|
+
const rawProbe = readRecord(node.lastProbe ?? node.last_probe);
|
|
32594
|
+
const probeGit = readRecord(rawProbe.git);
|
|
32595
|
+
const probeGitResult = readRecord(probeGit.result);
|
|
32596
|
+
const probeDirectStatus = readRecord(probeGit.status);
|
|
32597
|
+
const probeNestedStatus = readRecord(probeGitResult.status);
|
|
32598
|
+
const lastCheckedAt = options?.lastCheckedAt;
|
|
32599
|
+
let best = null;
|
|
32600
|
+
for (const status of [directStatus, nestedStatus, probeDirectStatus, probeNestedStatus]) {
|
|
32601
|
+
const normalized = normalizeGitStatus(status, node, { lastCheckedAt: lastCheckedAt ?? Date.now() });
|
|
32602
|
+
if (!normalized) continue;
|
|
32603
|
+
const score = scoreGitStatusCandidate(normalized);
|
|
32604
|
+
if (!best || score > best.score) best = { git: normalized, score };
|
|
32605
|
+
}
|
|
32606
|
+
return best?.git;
|
|
32607
|
+
}
|
|
32608
|
+
function normalizeMeshNodeId(node) {
|
|
32609
|
+
const record2 = node && typeof node === "object" ? node : {};
|
|
32610
|
+
return readString3(record2.id, record2.nodeId, record2.node_id);
|
|
32611
|
+
}
|
|
32612
|
+
function meshNodeIdMatches(node, candidateId) {
|
|
32613
|
+
if (!candidateId) return false;
|
|
32614
|
+
const trimmed = candidateId.trim();
|
|
32615
|
+
if (!trimmed) return false;
|
|
32616
|
+
return normalizeMeshNodeId(node) === trimmed;
|
|
32617
|
+
}
|
|
32618
|
+
function machineCoreFromDaemonId(id) {
|
|
32619
|
+
const trimmed = readString3(id);
|
|
32620
|
+
if (!trimmed) return void 0;
|
|
32621
|
+
for (const prefix of DAEMON_ID_PREFIXES) {
|
|
32622
|
+
if (trimmed.startsWith(prefix)) {
|
|
32623
|
+
const core = trimmed.slice(prefix.length).trim();
|
|
32624
|
+
return core || void 0;
|
|
32625
|
+
}
|
|
32626
|
+
}
|
|
32627
|
+
return trimmed;
|
|
32628
|
+
}
|
|
32629
|
+
function daemonIdsEquivalent(a, b) {
|
|
32630
|
+
const coreA = machineCoreFromDaemonId(a);
|
|
32631
|
+
const coreB = machineCoreFromDaemonId(b);
|
|
32632
|
+
if (!coreA || !coreB) return false;
|
|
32633
|
+
return coreA === coreB;
|
|
32634
|
+
}
|
|
32635
|
+
function expandDaemonIdForms(ids) {
|
|
32636
|
+
const list = Array.isArray(ids) ? ids : ids != null ? [ids] : [];
|
|
32637
|
+
const out = [];
|
|
32638
|
+
const seen = /* @__PURE__ */ new Set();
|
|
32639
|
+
const add = (value) => {
|
|
32640
|
+
if (!value || seen.has(value)) return;
|
|
32641
|
+
seen.add(value);
|
|
32642
|
+
out.push(value);
|
|
32643
|
+
};
|
|
32644
|
+
for (const raw of list) add(readString3(raw));
|
|
32645
|
+
for (const raw of list) {
|
|
32646
|
+
const core = machineCoreFromDaemonId(readString3(raw));
|
|
32647
|
+
if (!core || !core.startsWith("mach_")) continue;
|
|
32648
|
+
add(core);
|
|
32649
|
+
for (const prefix of DAEMON_ID_PREFIXES) add(`${prefix}${core}`);
|
|
32650
|
+
}
|
|
32651
|
+
return out;
|
|
32652
|
+
}
|
|
32653
|
+
function summarizeGitShape(status) {
|
|
32654
|
+
const record2 = readRecord(status);
|
|
32655
|
+
if (!Object.keys(record2).length) return null;
|
|
32656
|
+
const submodules = Array.isArray(record2.submodules) ? record2.submodules.map((entry) => {
|
|
32657
|
+
const sub = readRecord(entry);
|
|
32658
|
+
return {
|
|
32659
|
+
path: readString3(sub.path) ?? null,
|
|
32660
|
+
commit: readString3(sub.commit)?.slice(0, 12) ?? null,
|
|
32661
|
+
dirty: readBoolean(sub.dirty) ?? false,
|
|
32662
|
+
outOfSync: readBoolean(sub.outOfSync, sub.out_of_sync) ?? false
|
|
32663
|
+
};
|
|
32664
|
+
}) : [];
|
|
32665
|
+
return {
|
|
32666
|
+
isGitRepo: readBoolean(record2.isGitRepo),
|
|
32667
|
+
workspace: readString3(record2.workspace) ?? null,
|
|
32668
|
+
repoRoot: readString3(record2.repoRoot, record2.repo_root) ?? null,
|
|
32669
|
+
branch: readString3(record2.branch) ?? null,
|
|
32670
|
+
upstream: readString3(record2.upstream) ?? null,
|
|
32671
|
+
upstreamStatus: readString3(record2.upstreamStatus, record2.upstream_status) ?? null,
|
|
32672
|
+
headCommit: readString3(record2.headCommit, record2.head_commit)?.slice(0, 12) ?? null,
|
|
32673
|
+
ahead: readNumber(record2.ahead) ?? null,
|
|
32674
|
+
behind: readNumber(record2.behind) ?? null,
|
|
32675
|
+
dirtyCounts: {
|
|
32676
|
+
staged: readNumber(record2.staged) ?? 0,
|
|
32677
|
+
modified: readNumber(record2.modified) ?? 0,
|
|
32678
|
+
untracked: readNumber(record2.untracked) ?? 0,
|
|
32679
|
+
deleted: readNumber(record2.deleted) ?? 0,
|
|
32680
|
+
renamed: readNumber(record2.renamed) ?? 0
|
|
32681
|
+
},
|
|
32682
|
+
lastCheckedAt: readNumber(record2.lastCheckedAt, record2.last_checked_at) ?? null,
|
|
32683
|
+
submoduleCount: submodules.length,
|
|
32684
|
+
submodules
|
|
32685
|
+
};
|
|
32686
|
+
}
|
|
32687
|
+
var DAEMON_ID_PREFIXES;
|
|
32688
|
+
var init_dist = __esm2({
|
|
32689
|
+
"../mesh-shared/dist/index.mjs"() {
|
|
32690
|
+
"use strict";
|
|
32691
|
+
DAEMON_ID_PREFIXES = ["daemon_", "standalone_"];
|
|
32692
|
+
}
|
|
32693
|
+
});
|
|
32445
32694
|
var coordinator_prompt_exports = {};
|
|
32446
32695
|
__export2(coordinator_prompt_exports, {
|
|
32447
32696
|
buildCoordinatorSystemPrompt: () => buildCoordinatorSystemPrompt
|
|
@@ -36093,10 +36342,10 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
36093
36342
|
COMPACT_STATUS_GOAL_PREVIEW_MAX = 80;
|
|
36094
36343
|
}
|
|
36095
36344
|
});
|
|
36096
|
-
function
|
|
36345
|
+
function readString4(value) {
|
|
36097
36346
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
36098
36347
|
}
|
|
36099
|
-
function
|
|
36348
|
+
function readRecord2(value) {
|
|
36100
36349
|
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
36101
36350
|
}
|
|
36102
36351
|
function eventStatus(event, fallback) {
|
|
@@ -36119,7 +36368,7 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
36119
36368
|
return "Refine job failed; inspect result/finalBranchConvergenceState in mesh_task_history, fix the blocker, then rerun mesh_refine_node when ready.";
|
|
36120
36369
|
}
|
|
36121
36370
|
function mergeJob(jobs, patch) {
|
|
36122
|
-
const jobId =
|
|
36371
|
+
const jobId = readString4(patch.jobId);
|
|
36123
36372
|
if (!jobId) return;
|
|
36124
36373
|
const previous = jobs.get(jobId);
|
|
36125
36374
|
const status = patch.status || previous?.status || "running";
|
|
@@ -36137,54 +36386,54 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
36137
36386
|
function buildMeshAsyncRefineJobs(args) {
|
|
36138
36387
|
const jobs = /* @__PURE__ */ new Map();
|
|
36139
36388
|
for (const entry of args.ledgerEntries || []) {
|
|
36140
|
-
const payload =
|
|
36389
|
+
const payload = readRecord2(entry.payload);
|
|
36141
36390
|
if (payload?.source !== "refine_mesh_node_async_job") continue;
|
|
36142
|
-
const refineJob =
|
|
36143
|
-
const result =
|
|
36144
|
-
const finalState =
|
|
36145
|
-
const jobId =
|
|
36391
|
+
const refineJob = readRecord2(payload.refineJob);
|
|
36392
|
+
const result = readRecord2(payload.result);
|
|
36393
|
+
const finalState = readRecord2(payload.finalBranchConvergenceState) || readRecord2(result?.finalBranchConvergenceState);
|
|
36394
|
+
const jobId = readString4(refineJob?.jobId);
|
|
36146
36395
|
if (!jobId) continue;
|
|
36147
|
-
const status = ledgerStatus(entry.kind,
|
|
36396
|
+
const status = ledgerStatus(entry.kind, readString4(refineJob?.status));
|
|
36148
36397
|
mergeJob(jobs, {
|
|
36149
36398
|
jobId,
|
|
36150
|
-
interactionId:
|
|
36399
|
+
interactionId: readString4(refineJob?.interactionId),
|
|
36151
36400
|
status,
|
|
36152
|
-
meshId:
|
|
36153
|
-
nodeId:
|
|
36154
|
-
targetNodeId:
|
|
36155
|
-
targetDaemonId:
|
|
36156
|
-
workspace:
|
|
36157
|
-
branch:
|
|
36158
|
-
into:
|
|
36159
|
-
startedAt:
|
|
36160
|
-
completedAt:
|
|
36161
|
-
retryOfJobId:
|
|
36401
|
+
meshId: readString4(refineJob?.meshId) || args.meshId,
|
|
36402
|
+
nodeId: readString4(refineJob?.nodeId) || entry.nodeId,
|
|
36403
|
+
targetNodeId: readString4(refineJob?.nodeId) || entry.nodeId,
|
|
36404
|
+
targetDaemonId: readString4(refineJob?.targetDaemonId),
|
|
36405
|
+
workspace: readString4(refineJob?.workspace),
|
|
36406
|
+
branch: readString4(result?.branch) || readString4(finalState?.branch),
|
|
36407
|
+
into: readString4(result?.into) || readString4(finalState?.baseBranch),
|
|
36408
|
+
startedAt: readString4(refineJob?.startedAt),
|
|
36409
|
+
completedAt: readString4(refineJob?.completedAt),
|
|
36410
|
+
retryOfJobId: readString4(refineJob?.retryOfJobId) || readString4(payload.retryOfJobId),
|
|
36162
36411
|
lastLedgerKind: entry.kind,
|
|
36163
36412
|
lastUpdatedAt: entry.timestamp
|
|
36164
36413
|
});
|
|
36165
36414
|
}
|
|
36166
36415
|
for (const event of args.pendingEvents || []) {
|
|
36167
|
-
const metadata =
|
|
36416
|
+
const metadata = readRecord2(event.metadataEvent);
|
|
36168
36417
|
if (metadata?.source !== "refine_mesh_node_async_job") continue;
|
|
36169
|
-
const result =
|
|
36170
|
-
const finalState =
|
|
36171
|
-
const jobId =
|
|
36418
|
+
const result = readRecord2(metadata.result);
|
|
36419
|
+
const finalState = readRecord2(result?.finalBranchConvergenceState);
|
|
36420
|
+
const jobId = readString4(metadata.jobId);
|
|
36172
36421
|
if (!jobId) continue;
|
|
36173
|
-
const status = eventStatus(event.event,
|
|
36422
|
+
const status = eventStatus(event.event, readString4(metadata.status));
|
|
36174
36423
|
mergeJob(jobs, {
|
|
36175
36424
|
jobId,
|
|
36176
|
-
interactionId:
|
|
36425
|
+
interactionId: readString4(metadata.interactionId),
|
|
36177
36426
|
...status ? { status } : {},
|
|
36178
|
-
meshId:
|
|
36179
|
-
nodeId:
|
|
36180
|
-
targetNodeId:
|
|
36181
|
-
targetDaemonId:
|
|
36182
|
-
workspace:
|
|
36183
|
-
branch:
|
|
36184
|
-
into:
|
|
36185
|
-
startedAt:
|
|
36186
|
-
completedAt:
|
|
36187
|
-
retryOfJobId:
|
|
36427
|
+
meshId: readString4(metadata.meshId) || event.meshId || args.meshId,
|
|
36428
|
+
nodeId: readString4(metadata.nodeId) || event.nodeId,
|
|
36429
|
+
targetNodeId: readString4(metadata.nodeId) || event.nodeId,
|
|
36430
|
+
targetDaemonId: readString4(metadata.targetDaemonId),
|
|
36431
|
+
workspace: readString4(metadata.workspace) || event.workspace,
|
|
36432
|
+
branch: readString4(result?.branch) || readString4(finalState?.branch),
|
|
36433
|
+
into: readString4(result?.into) || readString4(finalState?.baseBranch),
|
|
36434
|
+
startedAt: readString4(metadata.startedAt),
|
|
36435
|
+
completedAt: readString4(metadata.completedAt),
|
|
36436
|
+
retryOfJobId: readString4(metadata.retryOfJobId),
|
|
36188
36437
|
lastEvent: event.event,
|
|
36189
36438
|
lastUpdatedAt: new Date(event.queuedAt).toISOString()
|
|
36190
36439
|
});
|
|
@@ -36245,10 +36494,10 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
36245
36494
|
__export2(mesh_review_inbox_exports, {
|
|
36246
36495
|
deriveMeshReviewInboxItems: () => deriveMeshReviewInboxItems
|
|
36247
36496
|
});
|
|
36248
|
-
function
|
|
36497
|
+
function readString5(value) {
|
|
36249
36498
|
return typeof value === "string" && value.trim() ? value.trim() : null;
|
|
36250
36499
|
}
|
|
36251
|
-
function
|
|
36500
|
+
function readRecord3(value) {
|
|
36252
36501
|
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
36253
36502
|
}
|
|
36254
36503
|
function readStringArray3(value, max) {
|
|
@@ -36258,20 +36507,20 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
36258
36507
|
}
|
|
36259
36508
|
function isLocalNodeStatus(node) {
|
|
36260
36509
|
if (node.isLocalWorktree === true) return true;
|
|
36261
|
-
const connection =
|
|
36262
|
-
return
|
|
36510
|
+
const connection = readRecord3(node.connection);
|
|
36511
|
+
return readString5(connection?.state) === "self";
|
|
36263
36512
|
}
|
|
36264
36513
|
function readNodeConvergence(node) {
|
|
36265
|
-
const convergence =
|
|
36266
|
-
const status =
|
|
36514
|
+
const convergence = readRecord3(node.branchConvergence);
|
|
36515
|
+
const status = readString5(convergence?.status);
|
|
36267
36516
|
if (!convergence || !status) return null;
|
|
36268
36517
|
return {
|
|
36269
36518
|
status,
|
|
36270
|
-
reason:
|
|
36271
|
-
nextStep:
|
|
36519
|
+
reason: readString5(convergence.reason),
|
|
36520
|
+
nextStep: readString5(convergence.nextStep),
|
|
36272
36521
|
needsConvergence: convergence.needsConvergence === true,
|
|
36273
|
-
branch:
|
|
36274
|
-
defaultBranch:
|
|
36522
|
+
branch: readString5(convergence.branch),
|
|
36523
|
+
defaultBranch: readString5(convergence.defaultBranch)
|
|
36275
36524
|
};
|
|
36276
36525
|
}
|
|
36277
36526
|
function isMergeCandidate(convergence) {
|
|
@@ -36279,15 +36528,15 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
36279
36528
|
return convergence.status === "cleanup_candidate" && convergence.reason === "clean_non_default_worktree_branch";
|
|
36280
36529
|
}
|
|
36281
36530
|
function readWorkerArtifact(value) {
|
|
36282
|
-
const worker =
|
|
36531
|
+
const worker = readRecord3(value);
|
|
36283
36532
|
if (!worker) return null;
|
|
36284
36533
|
const changed = readStringArray3(worker.changedFiles, MAX_CHANGED_FILES);
|
|
36285
36534
|
return {
|
|
36286
|
-
status:
|
|
36287
|
-
...
|
|
36535
|
+
status: readString5(worker.status) ?? "unknown",
|
|
36536
|
+
...readString5(worker.classification) ? { classification: readString5(worker.classification) } : {},
|
|
36288
36537
|
changedFiles: changed.values,
|
|
36289
36538
|
...changed.truncated ? { changedFilesTruncated: true } : {},
|
|
36290
|
-
validationResults: Array.isArray(worker.validationResults) ? worker.validationResults.map((item) =>
|
|
36539
|
+
validationResults: Array.isArray(worker.validationResults) ? worker.validationResults.map((item) => readRecord3(item)).filter((item) => item !== null) : [],
|
|
36291
36540
|
errors: readStringArray3(worker.errors, 20).values,
|
|
36292
36541
|
requiresUserAction: worker.requiresUserAction === true
|
|
36293
36542
|
};
|
|
@@ -36301,43 +36550,43 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
36301
36550
|
for (let i = ledgerEntries.length - 1; i >= 0; i--) {
|
|
36302
36551
|
const entry = ledgerEntries[i];
|
|
36303
36552
|
if (entry.nodeId !== nodeId || !isTerminalLedgerKind(entry.kind)) continue;
|
|
36304
|
-
const payload =
|
|
36553
|
+
const payload = readRecord3(entry.payload) ?? {};
|
|
36305
36554
|
if (!evidence.available) {
|
|
36306
36555
|
if (payload.source === "refine_mesh_node_async_job") {
|
|
36307
|
-
const result =
|
|
36308
|
-
const validationSummary =
|
|
36556
|
+
const result = readRecord3(payload.result);
|
|
36557
|
+
const validationSummary = readRecord3(result?.validationSummary);
|
|
36309
36558
|
evidence = {
|
|
36310
36559
|
available: true,
|
|
36311
36560
|
kind: entry.kind,
|
|
36312
36561
|
source: "refine_job",
|
|
36313
36562
|
timestamp: entry.timestamp,
|
|
36314
36563
|
...entry.sessionId ? { sessionId: entry.sessionId } : {},
|
|
36315
|
-
bootstrap:
|
|
36564
|
+
bootstrap: readRecord3(validationSummary?.bootstrap),
|
|
36316
36565
|
validation: validationSummary ? Object.fromEntries(Object.entries(validationSummary).filter(([key]) => key !== "bootstrap")) : null,
|
|
36317
|
-
checkpoint:
|
|
36566
|
+
checkpoint: readRecord3(result?.checkpoint),
|
|
36318
36567
|
worker: null,
|
|
36319
|
-
...
|
|
36320
|
-
...
|
|
36568
|
+
...readRecord3(payload.finalBranchConvergenceState) ?? readRecord3(result?.finalBranchConvergenceState) ? { finalBranchConvergenceState: readRecord3(payload.finalBranchConvergenceState) ?? readRecord3(result?.finalBranchConvergenceState) } : {},
|
|
36569
|
+
...readRecord3(payload.refineJob) ? { refineJob: readRecord3(payload.refineJob) } : {}
|
|
36321
36570
|
};
|
|
36322
36571
|
} else {
|
|
36323
|
-
const envelope =
|
|
36572
|
+
const envelope = readRecord3(payload.evidence);
|
|
36324
36573
|
evidence = {
|
|
36325
36574
|
available: true,
|
|
36326
36575
|
kind: entry.kind,
|
|
36327
36576
|
source: "task_completion",
|
|
36328
36577
|
timestamp: entry.timestamp,
|
|
36329
|
-
...
|
|
36578
|
+
...readString5(payload.taskId) ? { taskId: readString5(payload.taskId) } : {},
|
|
36330
36579
|
...entry.sessionId ? { sessionId: entry.sessionId } : {},
|
|
36331
36580
|
bootstrap: null,
|
|
36332
|
-
validation:
|
|
36333
|
-
checkpoint:
|
|
36581
|
+
validation: readRecord3(envelope?.validation),
|
|
36582
|
+
checkpoint: readRecord3(envelope?.checkpoint),
|
|
36334
36583
|
worker: readWorkerArtifact(envelope?.workerResult ?? payload.workerResult)
|
|
36335
36584
|
};
|
|
36336
36585
|
}
|
|
36337
36586
|
}
|
|
36338
36587
|
if (!transcriptHandle) {
|
|
36339
|
-
const envelope =
|
|
36340
|
-
transcriptHandle =
|
|
36588
|
+
const envelope = readRecord3(payload.evidence);
|
|
36589
|
+
transcriptHandle = readRecord3(envelope?.transcriptHandle);
|
|
36341
36590
|
}
|
|
36342
36591
|
if (evidence.available && transcriptHandle) break;
|
|
36343
36592
|
}
|
|
@@ -36347,11 +36596,11 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
36347
36596
|
for (let i = ledgerEntries.length - 1; i >= 0; i--) {
|
|
36348
36597
|
const entry = ledgerEntries[i];
|
|
36349
36598
|
if (entry.nodeId !== nodeId || !isTerminalLedgerKind(entry.kind)) continue;
|
|
36350
|
-
const payload =
|
|
36599
|
+
const payload = readRecord3(entry.payload) ?? {};
|
|
36351
36600
|
if (payload.source !== "refine_mesh_node_async_job") continue;
|
|
36352
|
-
const result =
|
|
36353
|
-
const finalState =
|
|
36354
|
-
return
|
|
36601
|
+
const result = readRecord3(payload.result);
|
|
36602
|
+
const finalState = readRecord3(payload.finalBranchConvergenceState) ?? readRecord3(result?.finalBranchConvergenceState);
|
|
36603
|
+
return readString5(finalState?.status) === "blocked_review" || readString5(result?.code) === "blocked_review";
|
|
36355
36604
|
}
|
|
36356
36605
|
return false;
|
|
36357
36606
|
}
|
|
@@ -36360,7 +36609,7 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
36360
36609
|
const excludedRemoteNodeIds = [];
|
|
36361
36610
|
const refineJobs = buildMeshAsyncRefineJobs({ ledgerEntries: args.ledgerEntries });
|
|
36362
36611
|
for (const node of args.nodes) {
|
|
36363
|
-
const nodeId =
|
|
36612
|
+
const nodeId = readString5(node.nodeId) ?? readString5(node.id);
|
|
36364
36613
|
if (!nodeId) continue;
|
|
36365
36614
|
if (!isLocalNodeStatus(node)) {
|
|
36366
36615
|
excludedRemoteNodeIds.push(nodeId);
|
|
@@ -36382,8 +36631,8 @@ Valid status values: \`completed\` | \`failed\` | \`blocked\` | \`partial\`.`;
|
|
|
36382
36631
|
) ?? null;
|
|
36383
36632
|
items.push({
|
|
36384
36633
|
nodeId,
|
|
36385
|
-
workspace:
|
|
36386
|
-
branch: convergence.branch ??
|
|
36634
|
+
workspace: readString5(node.workspace),
|
|
36635
|
+
branch: convergence.branch ?? readString5(node.worktreeBranch),
|
|
36387
36636
|
defaultBranch: convergence.defaultBranch,
|
|
36388
36637
|
isLocalWorktree: node.isLocalWorktree === true,
|
|
36389
36638
|
reviewReason,
|
|
@@ -37599,249 +37848,6 @@ ${rendered}`, "utf-8");
|
|
|
37599
37848
|
STATUS_OPTIONS = { refreshUpstream: true, includeSubmodules: true, timeoutMs: 15e3 };
|
|
37600
37849
|
}
|
|
37601
37850
|
});
|
|
37602
|
-
function readRecord3(value) {
|
|
37603
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
37604
|
-
}
|
|
37605
|
-
function readString5(...values) {
|
|
37606
|
-
for (const value of values) {
|
|
37607
|
-
if (typeof value !== "string") continue;
|
|
37608
|
-
const trimmed = value.trim();
|
|
37609
|
-
if (trimmed) return trimmed;
|
|
37610
|
-
}
|
|
37611
|
-
return void 0;
|
|
37612
|
-
}
|
|
37613
|
-
function readNumber(...values) {
|
|
37614
|
-
for (const value of values) {
|
|
37615
|
-
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
37616
|
-
}
|
|
37617
|
-
return void 0;
|
|
37618
|
-
}
|
|
37619
|
-
function readBoolean(...values) {
|
|
37620
|
-
for (const value of values) {
|
|
37621
|
-
if (typeof value === "boolean") return value;
|
|
37622
|
-
}
|
|
37623
|
-
return void 0;
|
|
37624
|
-
}
|
|
37625
|
-
function joinRepoPath(root, relativePath) {
|
|
37626
|
-
const normalizedRoot = typeof root === "string" ? root.trim().replace(/[\\/]+$/, "") : "";
|
|
37627
|
-
const normalizedPath = typeof relativePath === "string" ? relativePath.trim() : "";
|
|
37628
|
-
if (!normalizedPath) return void 0;
|
|
37629
|
-
if (/^(?:[A-Za-z]:[\\/]|\/)/.test(normalizedPath)) return normalizedPath;
|
|
37630
|
-
if (!normalizedRoot) return void 0;
|
|
37631
|
-
return `${normalizedRoot}/${normalizedPath.replace(/^[\\/]+/, "")}`;
|
|
37632
|
-
}
|
|
37633
|
-
function scoreGitUpstreamFreshness(status) {
|
|
37634
|
-
switch (status) {
|
|
37635
|
-
case "fresh":
|
|
37636
|
-
return 30;
|
|
37637
|
-
case "no_upstream":
|
|
37638
|
-
return 4;
|
|
37639
|
-
case "unchecked":
|
|
37640
|
-
case void 0:
|
|
37641
|
-
return 0;
|
|
37642
|
-
case "stale":
|
|
37643
|
-
return -10;
|
|
37644
|
-
case "unavailable":
|
|
37645
|
-
return -15;
|
|
37646
|
-
default:
|
|
37647
|
-
return 0;
|
|
37648
|
-
}
|
|
37649
|
-
}
|
|
37650
|
-
function readGitSubmodules(value, parentRepoRoot) {
|
|
37651
|
-
if (!Array.isArray(value)) return void 0;
|
|
37652
|
-
const submodules = value.map((entry) => {
|
|
37653
|
-
const submodule = readRecord3(entry);
|
|
37654
|
-
const path422 = readString5(submodule.path);
|
|
37655
|
-
const commit = readString5(submodule.commit);
|
|
37656
|
-
const repoPath = readString5(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path422);
|
|
37657
|
-
if (!path422 || !commit) return null;
|
|
37658
|
-
const result = {
|
|
37659
|
-
path: path422,
|
|
37660
|
-
commit,
|
|
37661
|
-
dirty: readBoolean(submodule.dirty) ?? false,
|
|
37662
|
-
outOfSync: readBoolean(submodule.outOfSync, submodule.out_of_sync) ?? false,
|
|
37663
|
-
lastCheckedAt: readNumber(submodule.lastCheckedAt, submodule.last_checked_at) ?? Date.now()
|
|
37664
|
-
};
|
|
37665
|
-
if (repoPath) result.repoPath = repoPath;
|
|
37666
|
-
const error48 = readString5(submodule.error);
|
|
37667
|
-
if (error48) result.error = error48;
|
|
37668
|
-
return result;
|
|
37669
|
-
}).filter((entry) => entry !== null);
|
|
37670
|
-
return submodules.length > 0 ? submodules : void 0;
|
|
37671
|
-
}
|
|
37672
|
-
function hasGitStatusEvidence(status) {
|
|
37673
|
-
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(
|
|
37674
|
-
status.ahead,
|
|
37675
|
-
status.behind,
|
|
37676
|
-
status.staged,
|
|
37677
|
-
status.modified,
|
|
37678
|
-
status.untracked,
|
|
37679
|
-
status.deleted,
|
|
37680
|
-
status.renamed,
|
|
37681
|
-
status.lastCheckedAt,
|
|
37682
|
-
status.last_checked_at
|
|
37683
|
-
) !== void 0 || Array.isArray(status.submodules) && status.submodules.length > 0;
|
|
37684
|
-
}
|
|
37685
|
-
function normalizeGitStatus(status, node, options) {
|
|
37686
|
-
const explicitIsGitRepo = readBoolean(status.isGitRepo);
|
|
37687
|
-
if (!Object.keys(status).length || !hasGitStatusEvidence(status)) return void 0;
|
|
37688
|
-
const isGitRepo = explicitIsGitRepo ?? true;
|
|
37689
|
-
const conflictFiles = Array.isArray(status.conflictFiles) ? status.conflictFiles.filter((entry) => typeof entry === "string") : [];
|
|
37690
|
-
const conflictCount = readNumber(status.conflicts) ?? conflictFiles.length;
|
|
37691
|
-
const hasConflicts = readBoolean(status.hasConflicts) ?? conflictCount > 0;
|
|
37692
|
-
const repoRoot = readString5(status.repoRoot, status.repo_root, node.repoRoot, node.repo_root, status.workspace, node.workspace) || void 0;
|
|
37693
|
-
const submodules = readGitSubmodules(status.submodules, repoRoot);
|
|
37694
|
-
const upstreamStatus = readString5(status.upstreamStatus, status.upstream_status);
|
|
37695
|
-
const upstreamFetchedAt = readNumber(status.upstreamFetchedAt, status.upstream_fetched_at);
|
|
37696
|
-
const upstreamFetchError = readString5(status.upstreamFetchError, status.upstream_fetch_error);
|
|
37697
|
-
const error48 = readString5(status.error);
|
|
37698
|
-
const staged = readNumber(status.staged) ?? 0;
|
|
37699
|
-
const modified = readNumber(status.modified) ?? 0;
|
|
37700
|
-
const untracked = readNumber(status.untracked) ?? 0;
|
|
37701
|
-
const deleted = readNumber(status.deleted) ?? 0;
|
|
37702
|
-
const renamed = readNumber(status.renamed) ?? 0;
|
|
37703
|
-
return {
|
|
37704
|
-
workspace: readString5(status.workspace, node.workspace) || "",
|
|
37705
|
-
repoRoot: repoRoot ?? null,
|
|
37706
|
-
isGitRepo,
|
|
37707
|
-
branch: readString5(status.branch) ?? null,
|
|
37708
|
-
headCommit: readString5(status.headCommit) ?? null,
|
|
37709
|
-
headMessage: readString5(status.headMessage) ?? null,
|
|
37710
|
-
upstream: readString5(status.upstream) ?? null,
|
|
37711
|
-
upstreamStatus: upstreamStatus ?? "unchecked",
|
|
37712
|
-
...upstreamFetchedAt !== void 0 ? { upstreamFetchedAt } : {},
|
|
37713
|
-
...upstreamFetchError ? { upstreamFetchError } : {},
|
|
37714
|
-
ahead: readNumber(status.ahead) ?? 0,
|
|
37715
|
-
behind: readNumber(status.behind) ?? 0,
|
|
37716
|
-
staged,
|
|
37717
|
-
modified,
|
|
37718
|
-
untracked,
|
|
37719
|
-
deleted,
|
|
37720
|
-
renamed,
|
|
37721
|
-
dirty: readBoolean(status.dirty, status.isDirty, status.is_dirty) ?? (staged + modified + untracked + deleted + renamed > 0 || hasConflicts),
|
|
37722
|
-
hasConflicts,
|
|
37723
|
-
conflictFiles,
|
|
37724
|
-
stashCount: readNumber(status.stashCount, status.stash_count) ?? 0,
|
|
37725
|
-
lastCheckedAt: options?.lastCheckedAt ?? readNumber(status.lastCheckedAt, status.last_checked_at) ?? Date.now(),
|
|
37726
|
-
...submodules ? { submodules } : {},
|
|
37727
|
-
...error48 ? { error: error48 } : {}
|
|
37728
|
-
};
|
|
37729
|
-
}
|
|
37730
|
-
function scoreGitStatusCandidate(git) {
|
|
37731
|
-
if (!git) return Number.NEGATIVE_INFINITY;
|
|
37732
|
-
let score = 0;
|
|
37733
|
-
if (git.isGitRepo === true) score += 50;
|
|
37734
|
-
if (git.isGitRepo === false) score -= 10;
|
|
37735
|
-
if (git.branch) score += 20;
|
|
37736
|
-
if (git.headCommit) score += 20;
|
|
37737
|
-
if (git.upstream) score += 10;
|
|
37738
|
-
score += scoreGitUpstreamFreshness(git.upstreamStatus);
|
|
37739
|
-
if (typeof git.ahead === "number") score += 2;
|
|
37740
|
-
if (typeof git.behind === "number") score += 2;
|
|
37741
|
-
if (Array.isArray(git.submodules) && git.submodules.length > 0) score += 4 + git.submodules.length;
|
|
37742
|
-
if (git.error) score -= 20;
|
|
37743
|
-
return score;
|
|
37744
|
-
}
|
|
37745
|
-
function pickBestTransitGitStatus(node, options) {
|
|
37746
|
-
const rawGit = readRecord3(node.lastGit ?? node.last_git);
|
|
37747
|
-
const gitResult = readRecord3(rawGit.result);
|
|
37748
|
-
const directStatus = readRecord3(rawGit.status);
|
|
37749
|
-
const nestedStatus = readRecord3(gitResult.status);
|
|
37750
|
-
const rawProbe = readRecord3(node.lastProbe ?? node.last_probe);
|
|
37751
|
-
const probeGit = readRecord3(rawProbe.git);
|
|
37752
|
-
const probeGitResult = readRecord3(probeGit.result);
|
|
37753
|
-
const probeDirectStatus = readRecord3(probeGit.status);
|
|
37754
|
-
const probeNestedStatus = readRecord3(probeGitResult.status);
|
|
37755
|
-
const lastCheckedAt = options?.lastCheckedAt;
|
|
37756
|
-
let best = null;
|
|
37757
|
-
for (const status of [directStatus, nestedStatus, probeDirectStatus, probeNestedStatus]) {
|
|
37758
|
-
const normalized = normalizeGitStatus(status, node, { lastCheckedAt: lastCheckedAt ?? Date.now() });
|
|
37759
|
-
if (!normalized) continue;
|
|
37760
|
-
const score = scoreGitStatusCandidate(normalized);
|
|
37761
|
-
if (!best || score > best.score) best = { git: normalized, score };
|
|
37762
|
-
}
|
|
37763
|
-
return best?.git;
|
|
37764
|
-
}
|
|
37765
|
-
function normalizeMeshNodeId(node) {
|
|
37766
|
-
const record2 = node && typeof node === "object" ? node : {};
|
|
37767
|
-
return readString5(record2.id, record2.nodeId, record2.node_id);
|
|
37768
|
-
}
|
|
37769
|
-
function meshNodeIdMatches(node, candidateId) {
|
|
37770
|
-
if (!candidateId) return false;
|
|
37771
|
-
const trimmed = candidateId.trim();
|
|
37772
|
-
if (!trimmed) return false;
|
|
37773
|
-
return normalizeMeshNodeId(node) === trimmed;
|
|
37774
|
-
}
|
|
37775
|
-
function machineCoreFromDaemonId(id) {
|
|
37776
|
-
const trimmed = readString5(id);
|
|
37777
|
-
if (!trimmed) return void 0;
|
|
37778
|
-
for (const prefix of DAEMON_ID_PREFIXES) {
|
|
37779
|
-
if (trimmed.startsWith(prefix)) {
|
|
37780
|
-
const core = trimmed.slice(prefix.length).trim();
|
|
37781
|
-
return core || void 0;
|
|
37782
|
-
}
|
|
37783
|
-
}
|
|
37784
|
-
return trimmed;
|
|
37785
|
-
}
|
|
37786
|
-
function expandDaemonIdForms(ids) {
|
|
37787
|
-
const list = Array.isArray(ids) ? ids : ids != null ? [ids] : [];
|
|
37788
|
-
const out = [];
|
|
37789
|
-
const seen = /* @__PURE__ */ new Set();
|
|
37790
|
-
const add = (value) => {
|
|
37791
|
-
if (!value || seen.has(value)) return;
|
|
37792
|
-
seen.add(value);
|
|
37793
|
-
out.push(value);
|
|
37794
|
-
};
|
|
37795
|
-
for (const raw of list) add(readString5(raw));
|
|
37796
|
-
for (const raw of list) {
|
|
37797
|
-
const core = machineCoreFromDaemonId(readString5(raw));
|
|
37798
|
-
if (!core || !core.startsWith("mach_")) continue;
|
|
37799
|
-
add(core);
|
|
37800
|
-
for (const prefix of DAEMON_ID_PREFIXES) add(`${prefix}${core}`);
|
|
37801
|
-
}
|
|
37802
|
-
return out;
|
|
37803
|
-
}
|
|
37804
|
-
function summarizeGitShape(status) {
|
|
37805
|
-
const record2 = readRecord3(status);
|
|
37806
|
-
if (!Object.keys(record2).length) return null;
|
|
37807
|
-
const submodules = Array.isArray(record2.submodules) ? record2.submodules.map((entry) => {
|
|
37808
|
-
const sub = readRecord3(entry);
|
|
37809
|
-
return {
|
|
37810
|
-
path: readString5(sub.path) ?? null,
|
|
37811
|
-
commit: readString5(sub.commit)?.slice(0, 12) ?? null,
|
|
37812
|
-
dirty: readBoolean(sub.dirty) ?? false,
|
|
37813
|
-
outOfSync: readBoolean(sub.outOfSync, sub.out_of_sync) ?? false
|
|
37814
|
-
};
|
|
37815
|
-
}) : [];
|
|
37816
|
-
return {
|
|
37817
|
-
isGitRepo: readBoolean(record2.isGitRepo),
|
|
37818
|
-
workspace: readString5(record2.workspace) ?? null,
|
|
37819
|
-
repoRoot: readString5(record2.repoRoot, record2.repo_root) ?? null,
|
|
37820
|
-
branch: readString5(record2.branch) ?? null,
|
|
37821
|
-
upstream: readString5(record2.upstream) ?? null,
|
|
37822
|
-
upstreamStatus: readString5(record2.upstreamStatus, record2.upstream_status) ?? null,
|
|
37823
|
-
headCommit: readString5(record2.headCommit, record2.head_commit)?.slice(0, 12) ?? null,
|
|
37824
|
-
ahead: readNumber(record2.ahead) ?? null,
|
|
37825
|
-
behind: readNumber(record2.behind) ?? null,
|
|
37826
|
-
dirtyCounts: {
|
|
37827
|
-
staged: readNumber(record2.staged) ?? 0,
|
|
37828
|
-
modified: readNumber(record2.modified) ?? 0,
|
|
37829
|
-
untracked: readNumber(record2.untracked) ?? 0,
|
|
37830
|
-
deleted: readNumber(record2.deleted) ?? 0,
|
|
37831
|
-
renamed: readNumber(record2.renamed) ?? 0
|
|
37832
|
-
},
|
|
37833
|
-
lastCheckedAt: readNumber(record2.lastCheckedAt, record2.last_checked_at) ?? null,
|
|
37834
|
-
submoduleCount: submodules.length,
|
|
37835
|
-
submodules
|
|
37836
|
-
};
|
|
37837
|
-
}
|
|
37838
|
-
var DAEMON_ID_PREFIXES;
|
|
37839
|
-
var init_dist = __esm2({
|
|
37840
|
-
"../mesh-shared/dist/index.mjs"() {
|
|
37841
|
-
"use strict";
|
|
37842
|
-
DAEMON_ID_PREFIXES = ["daemon_", "standalone_"];
|
|
37843
|
-
}
|
|
37844
|
-
});
|
|
37845
37851
|
function readString6(value) {
|
|
37846
37852
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
37847
37853
|
}
|
|
@@ -50148,6 +50154,7 @@ ${lastSnapshot}`;
|
|
|
50148
50154
|
createNativeHistoryDispatcher: () => createNativeHistoryDispatcher,
|
|
50149
50155
|
createSessionDelivery: () => createSessionDelivery,
|
|
50150
50156
|
createWorktree: () => createWorktree,
|
|
50157
|
+
daemonIdsEquivalent: () => daemonIdsEquivalent,
|
|
50151
50158
|
deleteDirectDispatchesByTaskId: () => deleteDirectDispatchesByTaskId,
|
|
50152
50159
|
deleteMesh: () => deleteMesh,
|
|
50153
50160
|
deriveMeshReviewInboxItems: () => deriveMeshReviewInboxItems,
|
|
@@ -50161,6 +50168,7 @@ ${lastSnapshot}`;
|
|
|
50161
50168
|
ensureSessionHostReady: () => ensureSessionHostReady2,
|
|
50162
50169
|
evaluateFsm: () => evaluateFsm,
|
|
50163
50170
|
execNpmCommandSync: () => execNpmCommandSync,
|
|
50171
|
+
expandDaemonIdForms: () => expandDaemonIdForms,
|
|
50164
50172
|
fastForwardMeshNode: () => fastForwardMeshNode,
|
|
50165
50173
|
filterActivityChatMessages: () => filterActivityChatMessages,
|
|
50166
50174
|
filterChatMessagesByVisibility: () => filterChatMessagesByVisibility,
|
|
@@ -50251,6 +50259,7 @@ ${lastSnapshot}`;
|
|
|
50251
50259
|
loadMeshWorktreeBootstrapConfig: () => loadMeshWorktreeBootstrapConfig,
|
|
50252
50260
|
loadState: () => loadState,
|
|
50253
50261
|
logCommand: () => logCommand,
|
|
50262
|
+
machineCoreFromDaemonId: () => machineCoreFromDaemonId,
|
|
50254
50263
|
markSessionDeliveriesTerminal: () => markSessionDeliveriesTerminal,
|
|
50255
50264
|
markSetupComplete: () => markSetupComplete,
|
|
50256
50265
|
markStaleDirectDispatches: () => markStaleDirectDispatches,
|
|
@@ -51585,6 +51594,7 @@ ${lastSnapshot}`;
|
|
|
51585
51594
|
})).sort((a, b) => b.lastUsedAt - a.lastUsedAt);
|
|
51586
51595
|
}
|
|
51587
51596
|
init_mesh_config();
|
|
51597
|
+
init_dist();
|
|
51588
51598
|
init_coordinator_prompt();
|
|
51589
51599
|
init_mesh_missions();
|
|
51590
51600
|
init_mesh_task_stats();
|
|
@@ -69040,9 +69050,11 @@ Run 'adhdev doctor' for detailed diagnostics.`
|
|
|
69040
69050
|
}
|
|
69041
69051
|
}
|
|
69042
69052
|
}
|
|
69043
|
-
|
|
69044
|
-
|
|
69045
|
-
|
|
69053
|
+
if (!opts?.instanceKey) {
|
|
69054
|
+
for (const [k, a] of this.adapters) {
|
|
69055
|
+
if (a.cliType === agentType) {
|
|
69056
|
+
return { adapter: a, key: k };
|
|
69057
|
+
}
|
|
69046
69058
|
}
|
|
69047
69059
|
}
|
|
69048
69060
|
return null;
|
|
@@ -76347,7 +76359,14 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
76347
76359
|
"resolve_action",
|
|
76348
76360
|
"set_mode",
|
|
76349
76361
|
"change_model",
|
|
76350
|
-
"set_thought_level"
|
|
76362
|
+
"set_thought_level",
|
|
76363
|
+
// agent_command (send_chat / clear_history / stop) is session-scoped too: a command
|
|
76364
|
+
// explicitly naming a targetSessionId MUST reach that session wherever it lives, never a
|
|
76365
|
+
// different local session. Without forwarding, a misrouted/relayed send_chat for a REMOTE
|
|
76366
|
+
// worker session that reaches the wrong daemon used to fuzzy-inject the task body into that
|
|
76367
|
+
// daemon's own CLI session (TASKECHO coordinator self-echo). Forwarding to the owning daemon
|
|
76368
|
+
// delivers it to the real worker instead. (findAdapter is also fail-closed as the backstop.)
|
|
76369
|
+
"agent_command"
|
|
76351
76370
|
]);
|
|
76352
76371
|
var READ_DEBUG_ENABLED2 = process.argv.includes("--dev") || process.env.ADHDEV_READ_DEBUG === "1";
|
|
76353
76372
|
function normalizeCommandSource(source) {
|
|
@@ -76700,7 +76719,7 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
76700
76719
|
if (!collectMeshNodeHostedSessionIds(node).has(trimmed)) continue;
|
|
76701
76720
|
const nodeDaemonId = readMeshNodeDaemonId(readObjectRecord(node));
|
|
76702
76721
|
if (!nodeDaemonId) continue;
|
|
76703
|
-
if (selfDaemonId && nodeDaemonId
|
|
76722
|
+
if (selfDaemonId && daemonIdsEquivalent(nodeDaemonId, selfDaemonId)) return void 0;
|
|
76704
76723
|
return nodeDaemonId;
|
|
76705
76724
|
}
|
|
76706
76725
|
return void 0;
|
|
@@ -76855,6 +76874,38 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
76855
76874
|
if (record2?.meta?.meshNodeId === nodeId) return true;
|
|
76856
76875
|
return false;
|
|
76857
76876
|
}
|
|
76877
|
+
/**
|
|
76878
|
+
* Best-effort recursive removal of a managed worktree directory.
|
|
76879
|
+
*
|
|
76880
|
+
* The git-registry de-registration is the safety-critical step of worktree
|
|
76881
|
+
* teardown; a leftover directory must never gate dropping the node from the
|
|
76882
|
+
* mesh. On Windows, `fs.rmSync` can throw EINVAL/EPERM/EBUSY on submodule
|
|
76883
|
+
* gitlink (`.git`) files, long paths, junctions, or while a just-stopped
|
|
76884
|
+
* delegate session is still releasing a handle/cwd on the directory. This
|
|
76885
|
+
* helper absorbs those errors (never throws), with bounded retries + backoff
|
|
76886
|
+
* to give handles time to release, and reports whether residue remains.
|
|
76887
|
+
*/
|
|
76888
|
+
async bestEffortRemoveWorktreeDir(dir) {
|
|
76889
|
+
if (!dir || !fs26.existsSync(dir)) return { removed: true, residue: false };
|
|
76890
|
+
const sleep3 = (ms) => new Promise((resolve24) => setTimeout(resolve24, ms));
|
|
76891
|
+
const ABSORB = /* @__PURE__ */ new Set(["EINVAL", "EPERM", "EBUSY", "ENOTEMPTY", "EACCES", "EMFILE", "ENFILE"]);
|
|
76892
|
+
let lastErr;
|
|
76893
|
+
for (let attempt = 0; attempt < 4; attempt++) {
|
|
76894
|
+
try {
|
|
76895
|
+
fs26.rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
76896
|
+
if (!fs26.existsSync(dir)) return { removed: true, residue: false };
|
|
76897
|
+
lastErr = new Error("directory still present after rmSync");
|
|
76898
|
+
} catch (e) {
|
|
76899
|
+
lastErr = e;
|
|
76900
|
+
const code = typeof e?.code === "string" ? e.code : "";
|
|
76901
|
+
if (code && !ABSORB.has(code)) {
|
|
76902
|
+
break;
|
|
76903
|
+
}
|
|
76904
|
+
}
|
|
76905
|
+
await sleep3(150 * (attempt + 1));
|
|
76906
|
+
}
|
|
76907
|
+
return fs26.existsSync(dir) ? { removed: false, residue: true, error: String(lastErr?.message || lastErr || "unknown rm error") } : { removed: true, residue: false };
|
|
76908
|
+
}
|
|
76858
76909
|
async cleanupLocalWorktreeNode(args) {
|
|
76859
76910
|
const workspace = typeof args.node?.workspace === "string" ? args.node.workspace.trim() : "";
|
|
76860
76911
|
if (!workspace) {
|
|
@@ -76909,11 +76960,31 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
76909
76960
|
const entries = await listWorktrees2(repoRoot);
|
|
76910
76961
|
const managedEntry = entries.find((entry) => normalizePath(entry.path) === actualPath);
|
|
76911
76962
|
if (!managedEntry) {
|
|
76963
|
+
try {
|
|
76964
|
+
const { execFile: execFile5 } = await import("child_process");
|
|
76965
|
+
const { promisify: promisify8 } = await import("util");
|
|
76966
|
+
const execFileAsync4 = promisify8(execFile5);
|
|
76967
|
+
await execFileAsync4("git", ["worktree", "prune"], {
|
|
76968
|
+
cwd: repoRoot,
|
|
76969
|
+
encoding: "utf8",
|
|
76970
|
+
timeout: 3e4,
|
|
76971
|
+
maxBuffer: 4 * 1024 * 1024,
|
|
76972
|
+
windowsHide: true
|
|
76973
|
+
});
|
|
76974
|
+
} catch {
|
|
76975
|
+
}
|
|
76976
|
+
const rm = await this.bestEffortRemoveWorktreeDir(workspace);
|
|
76912
76977
|
return {
|
|
76913
|
-
success:
|
|
76914
|
-
|
|
76915
|
-
|
|
76916
|
-
|
|
76978
|
+
success: true,
|
|
76979
|
+
removedPath: workspace,
|
|
76980
|
+
repoRoot,
|
|
76981
|
+
reason: "worktree_unregistered_residue_recovered",
|
|
76982
|
+
recovered: true,
|
|
76983
|
+
...rm.residue ? {
|
|
76984
|
+
residue: true,
|
|
76985
|
+
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.`,
|
|
76986
|
+
residueError: rm.error
|
|
76987
|
+
} : {}
|
|
76917
76988
|
};
|
|
76918
76989
|
}
|
|
76919
76990
|
if (managedEntry.branch && managedEntry.branch !== args.node.worktreeBranch) {
|
|
@@ -76976,8 +77047,8 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
76976
77047
|
convergence: forceFallbackConvergence
|
|
76977
77048
|
};
|
|
76978
77049
|
} catch (deinitError) {
|
|
77050
|
+
const rm = await this.bestEffortRemoveWorktreeDir(workspace);
|
|
76979
77051
|
try {
|
|
76980
|
-
fs26.rmSync(workspace, { recursive: true, force: true });
|
|
76981
77052
|
await execFileAsync4("git", ["worktree", "prune"], {
|
|
76982
77053
|
cwd: repoRoot,
|
|
76983
77054
|
encoding: "utf8",
|
|
@@ -76985,23 +77056,22 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
76985
77056
|
maxBuffer: GIT_MAX_BUFFER_CLEANUP,
|
|
76986
77057
|
windowsHide: true
|
|
76987
77058
|
});
|
|
76988
|
-
|
|
76989
|
-
success: true,
|
|
76990
|
-
removedPath: workspace,
|
|
76991
|
-
repoRoot,
|
|
76992
|
-
fallback: "fs_rm_worktree_prune",
|
|
76993
|
-
forced: true,
|
|
76994
|
-
reason: "working_trees_containing_submodules",
|
|
76995
|
-
convergence: forceFallbackConvergence
|
|
76996
|
-
};
|
|
76997
|
-
} catch (rmError) {
|
|
76998
|
-
return {
|
|
76999
|
-
success: false,
|
|
77000
|
-
code: "mesh_worktree_cleanup_failed",
|
|
77001
|
-
error: `All removal fallbacks exhausted. deinit+remove: ${deinitError?.message || deinitError}; rmSync+prune: ${rmError?.message || rmError}`,
|
|
77002
|
-
recoveryHint: "Manually remove the worktree directory and run git worktree prune from the source repo."
|
|
77003
|
-
};
|
|
77059
|
+
} catch {
|
|
77004
77060
|
}
|
|
77061
|
+
return {
|
|
77062
|
+
success: true,
|
|
77063
|
+
removedPath: workspace,
|
|
77064
|
+
repoRoot,
|
|
77065
|
+
fallback: "fs_rm_worktree_prune",
|
|
77066
|
+
forced: true,
|
|
77067
|
+
reason: "working_trees_containing_submodules",
|
|
77068
|
+
convergence: forceFallbackConvergence,
|
|
77069
|
+
...rm.residue ? {
|
|
77070
|
+
residue: true,
|
|
77071
|
+
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.`,
|
|
77072
|
+
residueError: rm.error
|
|
77073
|
+
} : {}
|
|
77074
|
+
};
|
|
77005
77075
|
}
|
|
77006
77076
|
}
|
|
77007
77077
|
return {
|
|
@@ -80400,7 +80470,14 @@ ${hintLines.join("\n")}` : "",
|
|
|
80400
80470
|
} catch {
|
|
80401
80471
|
}
|
|
80402
80472
|
}
|
|
80403
|
-
|
|
80473
|
+
const residueWarning = worktreeCleanup?.residue === true && typeof worktreeCleanup?.residueWarning === "string" ? worktreeCleanup.residueWarning : void 0;
|
|
80474
|
+
return {
|
|
80475
|
+
success: true,
|
|
80476
|
+
removed,
|
|
80477
|
+
...residueWarning ? { residueWarning } : {},
|
|
80478
|
+
...sessionCleanup ? { sessionCleanup } : {},
|
|
80479
|
+
...worktreeCleanup ? { worktreeCleanup } : {}
|
|
80480
|
+
};
|
|
80404
80481
|
} catch (e) {
|
|
80405
80482
|
return { success: false, error: e.message };
|
|
80406
80483
|
}
|