@adhdev/daemon-core 0.9.82-rc.290 → 0.9.82-rc.292
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 +50 -0
- package/dist/index.js +414 -290
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +414 -290
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/commands/router.ts +259 -55
- package/src/mesh/mesh-active-work.ts +2 -1
- package/src/mesh/mesh-events-coordinator.ts +7 -4
package/dist/index.js
CHANGED
|
@@ -275,10 +275,10 @@ function readInjected(value) {
|
|
|
275
275
|
}
|
|
276
276
|
function getDaemonBuildInfo() {
|
|
277
277
|
if (cached) return cached;
|
|
278
|
-
const commit = readInjected(true ? "
|
|
279
|
-
const commitShort = readInjected(true ? "
|
|
280
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
281
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
278
|
+
const commit = readInjected(true ? "7b5b620e2df42c7c3beb8a2983e3cc076c25f832" : void 0) ?? "unknown";
|
|
279
|
+
const commitShort = readInjected(true ? "7b5b620e" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
280
|
+
const version = readInjected(true ? "0.9.82-rc.292" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
281
|
+
const builtAt = readInjected(true ? "2026-06-16T09:16:23.646Z" : void 0);
|
|
282
282
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
283
283
|
return cached;
|
|
284
284
|
}
|
|
@@ -6184,11 +6184,225 @@ var init_mesh_fast_forward = __esm({
|
|
|
6184
6184
|
}
|
|
6185
6185
|
});
|
|
6186
6186
|
|
|
6187
|
+
// ../mesh-shared/dist/index.mjs
|
|
6188
|
+
function readRecord3(value) {
|
|
6189
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
6190
|
+
}
|
|
6191
|
+
function readString5(...values) {
|
|
6192
|
+
for (const value of values) {
|
|
6193
|
+
if (typeof value !== "string") continue;
|
|
6194
|
+
const trimmed = value.trim();
|
|
6195
|
+
if (trimmed) return trimmed;
|
|
6196
|
+
}
|
|
6197
|
+
return void 0;
|
|
6198
|
+
}
|
|
6199
|
+
function readNumber(...values) {
|
|
6200
|
+
for (const value of values) {
|
|
6201
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
6202
|
+
}
|
|
6203
|
+
return void 0;
|
|
6204
|
+
}
|
|
6205
|
+
function readBoolean(...values) {
|
|
6206
|
+
for (const value of values) {
|
|
6207
|
+
if (typeof value === "boolean") return value;
|
|
6208
|
+
}
|
|
6209
|
+
return void 0;
|
|
6210
|
+
}
|
|
6211
|
+
function joinRepoPath(root, relativePath) {
|
|
6212
|
+
const normalizedRoot = typeof root === "string" ? root.trim().replace(/[\\/]+$/, "") : "";
|
|
6213
|
+
const normalizedPath = typeof relativePath === "string" ? relativePath.trim() : "";
|
|
6214
|
+
if (!normalizedPath) return void 0;
|
|
6215
|
+
if (/^(?:[A-Za-z]:[\\/]|\/)/.test(normalizedPath)) return normalizedPath;
|
|
6216
|
+
if (!normalizedRoot) return void 0;
|
|
6217
|
+
return `${normalizedRoot}/${normalizedPath.replace(/^[\\/]+/, "")}`;
|
|
6218
|
+
}
|
|
6219
|
+
function scoreGitUpstreamFreshness(status) {
|
|
6220
|
+
switch (status) {
|
|
6221
|
+
case "fresh":
|
|
6222
|
+
return 30;
|
|
6223
|
+
case "no_upstream":
|
|
6224
|
+
return 4;
|
|
6225
|
+
case "unchecked":
|
|
6226
|
+
case void 0:
|
|
6227
|
+
return 0;
|
|
6228
|
+
case "stale":
|
|
6229
|
+
return -10;
|
|
6230
|
+
case "unavailable":
|
|
6231
|
+
return -15;
|
|
6232
|
+
default:
|
|
6233
|
+
return 0;
|
|
6234
|
+
}
|
|
6235
|
+
}
|
|
6236
|
+
function readGitSubmodules(value, parentRepoRoot) {
|
|
6237
|
+
if (!Array.isArray(value)) return void 0;
|
|
6238
|
+
const submodules = value.map((entry) => {
|
|
6239
|
+
const submodule = readRecord3(entry);
|
|
6240
|
+
const path40 = readString5(submodule.path);
|
|
6241
|
+
const commit = readString5(submodule.commit);
|
|
6242
|
+
const repoPath = readString5(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path40);
|
|
6243
|
+
if (!path40 || !commit) return null;
|
|
6244
|
+
const result = {
|
|
6245
|
+
path: path40,
|
|
6246
|
+
commit,
|
|
6247
|
+
dirty: readBoolean(submodule.dirty) ?? false,
|
|
6248
|
+
outOfSync: readBoolean(submodule.outOfSync, submodule.out_of_sync) ?? false,
|
|
6249
|
+
lastCheckedAt: readNumber(submodule.lastCheckedAt, submodule.last_checked_at) ?? Date.now()
|
|
6250
|
+
};
|
|
6251
|
+
if (repoPath) result.repoPath = repoPath;
|
|
6252
|
+
const error = readString5(submodule.error);
|
|
6253
|
+
if (error) result.error = error;
|
|
6254
|
+
return result;
|
|
6255
|
+
}).filter((entry) => entry !== null);
|
|
6256
|
+
return submodules.length > 0 ? submodules : void 0;
|
|
6257
|
+
}
|
|
6258
|
+
function hasGitStatusEvidence(status) {
|
|
6259
|
+
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(
|
|
6260
|
+
status.ahead,
|
|
6261
|
+
status.behind,
|
|
6262
|
+
status.staged,
|
|
6263
|
+
status.modified,
|
|
6264
|
+
status.untracked,
|
|
6265
|
+
status.deleted,
|
|
6266
|
+
status.renamed,
|
|
6267
|
+
status.lastCheckedAt,
|
|
6268
|
+
status.last_checked_at
|
|
6269
|
+
) !== void 0 || Array.isArray(status.submodules) && status.submodules.length > 0;
|
|
6270
|
+
}
|
|
6271
|
+
function normalizeGitStatus(status, node, options) {
|
|
6272
|
+
const explicitIsGitRepo = readBoolean(status.isGitRepo);
|
|
6273
|
+
if (!Object.keys(status).length || !hasGitStatusEvidence(status)) return void 0;
|
|
6274
|
+
const isGitRepo = explicitIsGitRepo ?? true;
|
|
6275
|
+
const conflictFiles = Array.isArray(status.conflictFiles) ? status.conflictFiles.filter((entry) => typeof entry === "string") : [];
|
|
6276
|
+
const conflictCount = readNumber(status.conflicts) ?? conflictFiles.length;
|
|
6277
|
+
const hasConflicts = readBoolean(status.hasConflicts) ?? conflictCount > 0;
|
|
6278
|
+
const repoRoot = readString5(status.repoRoot, status.repo_root, node.repoRoot, node.repo_root, status.workspace, node.workspace) || void 0;
|
|
6279
|
+
const submodules = readGitSubmodules(status.submodules, repoRoot);
|
|
6280
|
+
const upstreamStatus = readString5(status.upstreamStatus, status.upstream_status);
|
|
6281
|
+
const upstreamFetchedAt = readNumber(status.upstreamFetchedAt, status.upstream_fetched_at);
|
|
6282
|
+
const upstreamFetchError = readString5(status.upstreamFetchError, status.upstream_fetch_error);
|
|
6283
|
+
const error = readString5(status.error);
|
|
6284
|
+
const staged = readNumber(status.staged) ?? 0;
|
|
6285
|
+
const modified = readNumber(status.modified) ?? 0;
|
|
6286
|
+
const untracked = readNumber(status.untracked) ?? 0;
|
|
6287
|
+
const deleted = readNumber(status.deleted) ?? 0;
|
|
6288
|
+
const renamed = readNumber(status.renamed) ?? 0;
|
|
6289
|
+
return {
|
|
6290
|
+
workspace: readString5(status.workspace, node.workspace) || "",
|
|
6291
|
+
repoRoot: repoRoot ?? null,
|
|
6292
|
+
isGitRepo,
|
|
6293
|
+
branch: readString5(status.branch) ?? null,
|
|
6294
|
+
headCommit: readString5(status.headCommit) ?? null,
|
|
6295
|
+
headMessage: readString5(status.headMessage) ?? null,
|
|
6296
|
+
upstream: readString5(status.upstream) ?? null,
|
|
6297
|
+
upstreamStatus: upstreamStatus ?? "unchecked",
|
|
6298
|
+
...upstreamFetchedAt !== void 0 ? { upstreamFetchedAt } : {},
|
|
6299
|
+
...upstreamFetchError ? { upstreamFetchError } : {},
|
|
6300
|
+
ahead: readNumber(status.ahead) ?? 0,
|
|
6301
|
+
behind: readNumber(status.behind) ?? 0,
|
|
6302
|
+
staged,
|
|
6303
|
+
modified,
|
|
6304
|
+
untracked,
|
|
6305
|
+
deleted,
|
|
6306
|
+
renamed,
|
|
6307
|
+
dirty: readBoolean(status.dirty, status.isDirty, status.is_dirty) ?? (staged + modified + untracked + deleted + renamed > 0 || hasConflicts),
|
|
6308
|
+
hasConflicts,
|
|
6309
|
+
conflictFiles,
|
|
6310
|
+
stashCount: readNumber(status.stashCount, status.stash_count) ?? 0,
|
|
6311
|
+
lastCheckedAt: options?.lastCheckedAt ?? readNumber(status.lastCheckedAt, status.last_checked_at) ?? Date.now(),
|
|
6312
|
+
...submodules ? { submodules } : {},
|
|
6313
|
+
...error ? { error } : {}
|
|
6314
|
+
};
|
|
6315
|
+
}
|
|
6316
|
+
function scoreGitStatusCandidate(git) {
|
|
6317
|
+
if (!git) return Number.NEGATIVE_INFINITY;
|
|
6318
|
+
let score = 0;
|
|
6319
|
+
if (git.isGitRepo === true) score += 50;
|
|
6320
|
+
if (git.isGitRepo === false) score -= 10;
|
|
6321
|
+
if (git.branch) score += 20;
|
|
6322
|
+
if (git.headCommit) score += 20;
|
|
6323
|
+
if (git.upstream) score += 10;
|
|
6324
|
+
score += scoreGitUpstreamFreshness(git.upstreamStatus);
|
|
6325
|
+
if (typeof git.ahead === "number") score += 2;
|
|
6326
|
+
if (typeof git.behind === "number") score += 2;
|
|
6327
|
+
if (Array.isArray(git.submodules) && git.submodules.length > 0) score += 4 + git.submodules.length;
|
|
6328
|
+
if (git.error) score -= 20;
|
|
6329
|
+
return score;
|
|
6330
|
+
}
|
|
6331
|
+
function pickBestTransitGitStatus(node, options) {
|
|
6332
|
+
const rawGit = readRecord3(node.lastGit ?? node.last_git);
|
|
6333
|
+
const gitResult = readRecord3(rawGit.result);
|
|
6334
|
+
const directStatus = readRecord3(rawGit.status);
|
|
6335
|
+
const nestedStatus = readRecord3(gitResult.status);
|
|
6336
|
+
const rawProbe = readRecord3(node.lastProbe ?? node.last_probe);
|
|
6337
|
+
const probeGit = readRecord3(rawProbe.git);
|
|
6338
|
+
const probeGitResult = readRecord3(probeGit.result);
|
|
6339
|
+
const probeDirectStatus = readRecord3(probeGit.status);
|
|
6340
|
+
const probeNestedStatus = readRecord3(probeGitResult.status);
|
|
6341
|
+
const lastCheckedAt = options?.lastCheckedAt;
|
|
6342
|
+
let best = null;
|
|
6343
|
+
for (const status of [directStatus, nestedStatus, probeDirectStatus, probeNestedStatus]) {
|
|
6344
|
+
const normalized = normalizeGitStatus(status, node, { lastCheckedAt: lastCheckedAt ?? Date.now() });
|
|
6345
|
+
if (!normalized) continue;
|
|
6346
|
+
const score = scoreGitStatusCandidate(normalized);
|
|
6347
|
+
if (!best || score > best.score) best = { git: normalized, score };
|
|
6348
|
+
}
|
|
6349
|
+
return best?.git;
|
|
6350
|
+
}
|
|
6351
|
+
function normalizeMeshNodeId(node) {
|
|
6352
|
+
const record = node && typeof node === "object" ? node : {};
|
|
6353
|
+
return readString5(record.id, record.nodeId, record.node_id);
|
|
6354
|
+
}
|
|
6355
|
+
function meshNodeIdMatches(node, candidateId) {
|
|
6356
|
+
if (!candidateId) return false;
|
|
6357
|
+
const trimmed = candidateId.trim();
|
|
6358
|
+
if (!trimmed) return false;
|
|
6359
|
+
return normalizeMeshNodeId(node) === trimmed;
|
|
6360
|
+
}
|
|
6361
|
+
function summarizeGitShape(status) {
|
|
6362
|
+
const record = readRecord3(status);
|
|
6363
|
+
if (!Object.keys(record).length) return null;
|
|
6364
|
+
const submodules = Array.isArray(record.submodules) ? record.submodules.map((entry) => {
|
|
6365
|
+
const sub = readRecord3(entry);
|
|
6366
|
+
return {
|
|
6367
|
+
path: readString5(sub.path) ?? null,
|
|
6368
|
+
commit: readString5(sub.commit)?.slice(0, 12) ?? null,
|
|
6369
|
+
dirty: readBoolean(sub.dirty) ?? false,
|
|
6370
|
+
outOfSync: readBoolean(sub.outOfSync, sub.out_of_sync) ?? false
|
|
6371
|
+
};
|
|
6372
|
+
}) : [];
|
|
6373
|
+
return {
|
|
6374
|
+
isGitRepo: readBoolean(record.isGitRepo),
|
|
6375
|
+
workspace: readString5(record.workspace) ?? null,
|
|
6376
|
+
repoRoot: readString5(record.repoRoot, record.repo_root) ?? null,
|
|
6377
|
+
branch: readString5(record.branch) ?? null,
|
|
6378
|
+
upstream: readString5(record.upstream) ?? null,
|
|
6379
|
+
upstreamStatus: readString5(record.upstreamStatus, record.upstream_status) ?? null,
|
|
6380
|
+
headCommit: readString5(record.headCommit, record.head_commit)?.slice(0, 12) ?? null,
|
|
6381
|
+
ahead: readNumber(record.ahead) ?? null,
|
|
6382
|
+
behind: readNumber(record.behind) ?? null,
|
|
6383
|
+
dirtyCounts: {
|
|
6384
|
+
staged: readNumber(record.staged) ?? 0,
|
|
6385
|
+
modified: readNumber(record.modified) ?? 0,
|
|
6386
|
+
untracked: readNumber(record.untracked) ?? 0,
|
|
6387
|
+
deleted: readNumber(record.deleted) ?? 0,
|
|
6388
|
+
renamed: readNumber(record.renamed) ?? 0
|
|
6389
|
+
},
|
|
6390
|
+
lastCheckedAt: readNumber(record.lastCheckedAt, record.last_checked_at) ?? null,
|
|
6391
|
+
submoduleCount: submodules.length,
|
|
6392
|
+
submodules
|
|
6393
|
+
};
|
|
6394
|
+
}
|
|
6395
|
+
var init_dist = __esm({
|
|
6396
|
+
"../mesh-shared/dist/index.mjs"() {
|
|
6397
|
+
"use strict";
|
|
6398
|
+
}
|
|
6399
|
+
});
|
|
6400
|
+
|
|
6187
6401
|
// src/mesh/mesh-events-utils.ts
|
|
6188
6402
|
function readNonEmptyString2(value) {
|
|
6189
6403
|
return typeof value === "string" && value.trim() ? value.trim() : "";
|
|
6190
6404
|
}
|
|
6191
|
-
function
|
|
6405
|
+
function readRecord4(value) {
|
|
6192
6406
|
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
6193
6407
|
}
|
|
6194
6408
|
function buildMeshWorkerRelayStamp(currentSettings, meshContext) {
|
|
@@ -6212,13 +6426,13 @@ function resolveEventSessionId(event, fallback) {
|
|
|
6212
6426
|
return readNonEmptyString2(event.targetSessionId) || readNonEmptyString2(event.sessionId) || readNonEmptyString2(event.instanceId) || readNonEmptyString2(fallback);
|
|
6213
6427
|
}
|
|
6214
6428
|
function readRefineJobId(event) {
|
|
6215
|
-
const metadata =
|
|
6216
|
-
const result =
|
|
6217
|
-
const refineJob =
|
|
6429
|
+
const metadata = readRecord4(event.metadataEvent) || event;
|
|
6430
|
+
const result = readRecord4(metadata.result);
|
|
6431
|
+
const refineJob = readRecord4(result?.refineJob);
|
|
6218
6432
|
return readNonEmptyString2(metadata.jobId) || readNonEmptyString2(refineJob?.jobId);
|
|
6219
6433
|
}
|
|
6220
6434
|
function readWorkerResultMetadata(event) {
|
|
6221
|
-
return
|
|
6435
|
+
return readRecord4(event.workerResult) || readRecord4(event.meshWorkerResult) || readRecord4(event.structuredResult);
|
|
6222
6436
|
}
|
|
6223
6437
|
function formatCompletionMetadata(event) {
|
|
6224
6438
|
const completionDiagnostic = event.completionDiagnostic && typeof event.completionDiagnostic === "object" ? event.completionDiagnostic : null;
|
|
@@ -6296,10 +6510,10 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
6296
6510
|
}
|
|
6297
6511
|
if (args.event === "refine:completed") {
|
|
6298
6512
|
const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
|
|
6299
|
-
const result =
|
|
6300
|
-
const validationSummary =
|
|
6301
|
-
const patchEquivalence =
|
|
6302
|
-
const finalConvergence =
|
|
6513
|
+
const result = readRecord4(args.metadataEvent.result);
|
|
6514
|
+
const validationSummary = readRecord4(result?.validationSummary);
|
|
6515
|
+
const patchEquivalence = readRecord4(result?.patchEquivalence);
|
|
6516
|
+
const finalConvergence = readRecord4(result?.finalBranchConvergenceState);
|
|
6303
6517
|
const validationStatus = readNonEmptyString2(validationSummary?.status);
|
|
6304
6518
|
const patchStatus = readNonEmptyString2(patchEquivalence?.status) || (patchEquivalence?.equivalent === true ? "passed" : "");
|
|
6305
6519
|
const into = readNonEmptyString2(result?.into);
|
|
@@ -6320,10 +6534,10 @@ Next step: ${nextStep}`;
|
|
|
6320
6534
|
}
|
|
6321
6535
|
if (args.event === "refine:failed") {
|
|
6322
6536
|
const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
|
|
6323
|
-
const result =
|
|
6324
|
-
const validationSummary =
|
|
6325
|
-
const patchEquivalence =
|
|
6326
|
-
const finalConvergence =
|
|
6537
|
+
const result = readRecord4(args.metadataEvent.result);
|
|
6538
|
+
const validationSummary = readRecord4(result?.validationSummary);
|
|
6539
|
+
const patchEquivalence = readRecord4(result?.patchEquivalence);
|
|
6540
|
+
const finalConvergence = readRecord4(result?.finalBranchConvergenceState);
|
|
6327
6541
|
const code = readNonEmptyString2(result?.code);
|
|
6328
6542
|
const error = readNonEmptyString2(result?.error);
|
|
6329
6543
|
const validationStatus = readNonEmptyString2(validationSummary?.status);
|
|
@@ -6370,9 +6584,9 @@ function normalizeCoordinatorDaemonIds(coordinatorDaemonId) {
|
|
|
6370
6584
|
return out;
|
|
6371
6585
|
}
|
|
6372
6586
|
function readRefineJobId2(event) {
|
|
6373
|
-
const metadata =
|
|
6374
|
-
const result =
|
|
6375
|
-
const refineJob =
|
|
6587
|
+
const metadata = readRecord4(event.metadataEvent) || event;
|
|
6588
|
+
const result = readRecord4(metadata.result);
|
|
6589
|
+
const refineJob = readRecord4(result?.refineJob);
|
|
6376
6590
|
return readNonEmptyString2(metadata.jobId) || readNonEmptyString2(refineJob?.jobId);
|
|
6377
6591
|
}
|
|
6378
6592
|
function hasPendingRefineTerminalEventDuplicate(event) {
|
|
@@ -6384,13 +6598,13 @@ function hasPendingRefineTerminalEventDuplicate(event) {
|
|
|
6384
6598
|
);
|
|
6385
6599
|
}
|
|
6386
6600
|
function buildPendingEventFingerprint(event) {
|
|
6387
|
-
const metadata =
|
|
6601
|
+
const metadata = readRecord4(event.metadataEvent) || {};
|
|
6388
6602
|
if (event.event === "worktree_bootstrap_complete" || event.event === "worktree_bootstrap_failed") {
|
|
6389
6603
|
return [event.meshId, event.event, event.nodeId || ""].join("::");
|
|
6390
6604
|
}
|
|
6391
6605
|
const sessionId = resolveEventSessionId(metadata);
|
|
6392
6606
|
const providerSessionId = readNonEmptyString2(metadata.providerSessionId);
|
|
6393
|
-
const taskId = readNonEmptyString2(metadata.taskId) || readNonEmptyString2(
|
|
6607
|
+
const taskId = readNonEmptyString2(metadata.taskId) || readNonEmptyString2(readRecord4(metadata.payload)?.taskId);
|
|
6394
6608
|
const jobId = readRefineJobId2(event);
|
|
6395
6609
|
const timestamp = metadata.timestamp !== void 0 && metadata.timestamp !== null ? String(metadata.timestamp) : "";
|
|
6396
6610
|
return [
|
|
@@ -6458,15 +6672,15 @@ function refineTerminalEventFromLedger(meshId, pending) {
|
|
|
6458
6672
|
for (let i = entries.length - 1; i >= 0; i--) {
|
|
6459
6673
|
const entry = entries[i];
|
|
6460
6674
|
if (entry.kind !== "task_completed" && entry.kind !== "task_failed") continue;
|
|
6461
|
-
const payload =
|
|
6675
|
+
const payload = readRecord4(entry.payload);
|
|
6462
6676
|
if (payload?.source !== "refine_mesh_node_async_job") continue;
|
|
6463
|
-
const refineJob =
|
|
6677
|
+
const refineJob = readRecord4(payload.refineJob);
|
|
6464
6678
|
const jobId = readNonEmptyString2(refineJob?.jobId);
|
|
6465
6679
|
if (!jobId || !acceptedJobIds.has(jobId)) continue;
|
|
6466
6680
|
const eventName = entry.kind === "task_completed" ? "refine:completed" : "refine:failed";
|
|
6467
6681
|
if (existingTerminalJobIds.has(`${eventName}:${jobId}`)) continue;
|
|
6468
6682
|
existingTerminalJobIds.add(`${eventName}:${jobId}`);
|
|
6469
|
-
const result =
|
|
6683
|
+
const result = readRecord4(payload.result);
|
|
6470
6684
|
const metadataEvent = {
|
|
6471
6685
|
source: "refine_mesh_node_async_job",
|
|
6472
6686
|
jobId,
|
|
@@ -7074,7 +7288,7 @@ function buildLongGeneratingCompletionReconciliation(args) {
|
|
|
7074
7288
|
const providerType = readNonEmptyString2(args.metadataEvent.providerType);
|
|
7075
7289
|
const providerSessionId = readNonEmptyString2(args.metadataEvent.providerSessionId);
|
|
7076
7290
|
const workerResult = readWorkerResultMetadata(args.metadataEvent);
|
|
7077
|
-
const completionDiagnostic =
|
|
7291
|
+
const completionDiagnostic = readRecord4(args.metadataEvent.completionDiagnostic);
|
|
7078
7292
|
const finalSummary = readNonEmptyString2(args.metadataEvent.finalSummary);
|
|
7079
7293
|
const status = readNonEmptyString2(args.metadataEvent.status).toLowerCase();
|
|
7080
7294
|
const explicitCompletionEvidence = Boolean(
|
|
@@ -7794,7 +8008,7 @@ async function resolveUsableProvider(components, nodeId, node, requiredTags) {
|
|
|
7794
8008
|
return { reason: `provider_priority_unusable: ${failed.join("; ") || nodeId}` };
|
|
7795
8009
|
}
|
|
7796
8010
|
function readMeshNodeId(node) {
|
|
7797
|
-
return
|
|
8011
|
+
return normalizeMeshNodeId(node) ?? "";
|
|
7798
8012
|
}
|
|
7799
8013
|
async function maybeAutoLaunchOneQueueSession(components, meshId, mesh) {
|
|
7800
8014
|
const queue = getQueue(meshId);
|
|
@@ -8023,7 +8237,7 @@ async function triggerMeshQueue(components, meshId) {
|
|
|
8023
8237
|
}
|
|
8024
8238
|
async function maybeAutoFastForwardIdleNode(components, args) {
|
|
8025
8239
|
const mesh = getMeshWithCache(components, args.meshId);
|
|
8026
|
-
const node = mesh?.nodes?.find((candidate) => candidate
|
|
8240
|
+
const node = mesh?.nodes?.find((candidate) => meshNodeIdMatches(candidate, args.nodeId));
|
|
8027
8241
|
const workspace = readNonEmptyString2(node?.workspace);
|
|
8028
8242
|
if (!workspace) return;
|
|
8029
8243
|
if (!(0, import_fs10.existsSync)(workspace)) return;
|
|
@@ -8612,6 +8826,7 @@ var init_mesh_events_coordinator = __esm({
|
|
|
8612
8826
|
init_mesh_events_pending();
|
|
8613
8827
|
init_mesh_routing();
|
|
8614
8828
|
init_repo_mesh_types();
|
|
8829
|
+
init_dist();
|
|
8615
8830
|
init_mesh_events_stale();
|
|
8616
8831
|
init_mesh_events_utils();
|
|
8617
8832
|
REMOTE_IDLE_SESSION_TTL_MS = 5 * 60 * 1e3;
|
|
@@ -17532,9 +17747,10 @@ function buildMeshLedgerReconciliationEvidence(meshId, replicas) {
|
|
|
17532
17747
|
init_mesh_work_queue();
|
|
17533
17748
|
|
|
17534
17749
|
// src/mesh/mesh-active-work.ts
|
|
17750
|
+
init_dist();
|
|
17535
17751
|
var DIRECT_DISPATCH_VIA = /* @__PURE__ */ new Set(["p2p_direct", "local_direct", "mesh_send_task"]);
|
|
17536
17752
|
var TERMINAL_LEDGER_KINDS = /* @__PURE__ */ new Set(["task_completed", "task_failed", "task_stalled"]);
|
|
17537
|
-
function
|
|
17753
|
+
function readString6(value) {
|
|
17538
17754
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
17539
17755
|
}
|
|
17540
17756
|
function summarizeMessage(message) {
|
|
@@ -17549,7 +17765,7 @@ function elapsedSince(value, now) {
|
|
|
17549
17765
|
function sessionStatusFromNodes(nodes, nodeId, sessionId) {
|
|
17550
17766
|
if (!Array.isArray(nodes)) return {};
|
|
17551
17767
|
if (!nodeId) return { staleReason: "direct task has no node id" };
|
|
17552
|
-
const node = nodes.find((item) =>
|
|
17768
|
+
const node = nodes.find((item) => meshNodeIdMatches(item, nodeId));
|
|
17553
17769
|
if (!node) return { staleReason: "direct task node is no longer in the live mesh" };
|
|
17554
17770
|
if (!sessionId) return {};
|
|
17555
17771
|
const candidates = [];
|
|
@@ -17573,12 +17789,12 @@ function sessionStatusFromNodes(nodes, nodeId, sessionId) {
|
|
|
17573
17789
|
}
|
|
17574
17790
|
const session = candidates.find((item) => {
|
|
17575
17791
|
if (typeof item === "string") return item === sessionId;
|
|
17576
|
-
const id =
|
|
17792
|
+
const id = readString6(item?.id) || readString6(item?.sessionId) || readString6(item?.session_id) || readString6(item?.runtimeSessionId) || readString6(item?.instanceId);
|
|
17577
17793
|
return id === sessionId;
|
|
17578
17794
|
});
|
|
17579
17795
|
if (!session) return { staleReason: "direct task session is not present in live session records" };
|
|
17580
17796
|
if (typeof session === "string") return {};
|
|
17581
|
-
const raw = `${
|
|
17797
|
+
const raw = `${readString6(session.status) || ""} ${readString6(session.lifecycle) || ""} ${readString6(session.state) || ""} ${readString6(session.activeChat?.status) || ""}`.toLowerCase();
|
|
17582
17798
|
if (raw.includes("approval")) return { status: "awaiting_approval" };
|
|
17583
17799
|
if (raw.includes("generating") || raw.includes("running") || raw.includes("busy")) return { status: "generating" };
|
|
17584
17800
|
if (raw.includes("failed") || raw.includes("stopped") || raw.includes("terminated") || raw.includes("exited")) return { status: "failed" };
|
|
@@ -17589,14 +17805,14 @@ function isDirectDispatch(entry) {
|
|
|
17589
17805
|
if (entry.kind !== "task_dispatched") return false;
|
|
17590
17806
|
const payload = entry.payload || {};
|
|
17591
17807
|
if (payload.source === "direct") return true;
|
|
17592
|
-
const via =
|
|
17808
|
+
const via = readString6(payload.via);
|
|
17593
17809
|
return Boolean(via && DIRECT_DISPATCH_VIA.has(via) && payload.source !== "queue");
|
|
17594
17810
|
}
|
|
17595
17811
|
function directDispatchTaskId(entry) {
|
|
17596
|
-
return
|
|
17812
|
+
return readString6(entry.payload?.taskId) || entry.id;
|
|
17597
17813
|
}
|
|
17598
17814
|
function terminalMatchesDispatch(terminal, dispatch, taskId) {
|
|
17599
|
-
const terminalTaskId =
|
|
17815
|
+
const terminalTaskId = readString6(terminal.payload?.taskId);
|
|
17600
17816
|
if (terminalTaskId && terminalTaskId === taskId) return true;
|
|
17601
17817
|
if (terminalTaskId && terminalTaskId !== taskId) return false;
|
|
17602
17818
|
if (dispatch.sessionId && terminal.sessionId === dispatch.sessionId) return true;
|
|
@@ -17719,7 +17935,7 @@ function buildMeshActiveWork(opts) {
|
|
|
17719
17935
|
const isNoTransition = !terminalStatus && !live.status;
|
|
17720
17936
|
const isIdleUnacknowledged = status === "idle";
|
|
17721
17937
|
const ledgerOnlyStaleReason = !terminalRow && (isIdleUnacknowledged || isNoTransition || dispatchedToIdleSession && isIdleUnacknowledged) ? "direct task dispatch has no provider acknowledgement, transcript append, or active runtime transition" : void 0;
|
|
17722
|
-
const message =
|
|
17938
|
+
const message = readString6(dispatch.payload?.message) || readString6(dispatch.payload?.summary) || "";
|
|
17723
17939
|
const { title, summary: summary2 } = summarizeMessage(message);
|
|
17724
17940
|
const isFreshUnacknowledged = Boolean(ledgerOnlyStaleReason && !live.staleReason);
|
|
17725
17941
|
const record = {
|
|
@@ -17728,11 +17944,11 @@ function buildMeshActiveWork(opts) {
|
|
|
17728
17944
|
status,
|
|
17729
17945
|
nodeId: dispatch.nodeId,
|
|
17730
17946
|
sessionId: dispatch.sessionId,
|
|
17731
|
-
providerType: dispatch.providerType ||
|
|
17732
|
-
taskTitle:
|
|
17733
|
-
taskSummary:
|
|
17947
|
+
providerType: dispatch.providerType || readString6(dispatch.payload?.providerType),
|
|
17948
|
+
taskTitle: readString6(dispatch.payload?.taskTitle) || title,
|
|
17949
|
+
taskSummary: readString6(dispatch.payload?.taskSummary) || summary2,
|
|
17734
17950
|
message,
|
|
17735
|
-
taskMode:
|
|
17951
|
+
taskMode: readString6(dispatch.payload?.taskMode),
|
|
17736
17952
|
createdAt: dispatch.timestamp,
|
|
17737
17953
|
updatedAt: terminal?.timestamp || dispatch.timestamp,
|
|
17738
17954
|
dispatchedAt: dispatch.timestamp,
|
|
@@ -17767,7 +17983,7 @@ function buildMeshActiveWork(opts) {
|
|
|
17767
17983
|
const isNoTransition = !terminalStatus && !live.status;
|
|
17768
17984
|
const isIdleUnacknowledged = status === "idle";
|
|
17769
17985
|
const ledgerOnlyStaleReason = !terminalRow && (isIdleUnacknowledged || isNoTransition || dispatchedToIdleSession && isIdleUnacknowledged) ? "direct task dispatch has no provider acknowledgement, transcript append, or active runtime transition" : void 0;
|
|
17770
|
-
const message =
|
|
17986
|
+
const message = readString6(dispatch.payload?.message) || readString6(dispatch.payload?.summary) || "";
|
|
17771
17987
|
const { title, summary: summary2 } = summarizeMessage(message);
|
|
17772
17988
|
const isFreshUnacknowledged = Boolean(ledgerOnlyStaleReason && !live.staleReason);
|
|
17773
17989
|
const record = {
|
|
@@ -17776,11 +17992,11 @@ function buildMeshActiveWork(opts) {
|
|
|
17776
17992
|
status,
|
|
17777
17993
|
nodeId: dispatch.nodeId,
|
|
17778
17994
|
sessionId: dispatch.sessionId,
|
|
17779
|
-
providerType: dispatch.providerType ||
|
|
17780
|
-
taskTitle:
|
|
17781
|
-
taskSummary:
|
|
17995
|
+
providerType: dispatch.providerType || readString6(dispatch.payload?.providerType),
|
|
17996
|
+
taskTitle: readString6(dispatch.payload?.taskTitle) || title,
|
|
17997
|
+
taskSummary: readString6(dispatch.payload?.taskSummary) || summary2,
|
|
17782
17998
|
message,
|
|
17783
|
-
taskMode:
|
|
17999
|
+
taskMode: readString6(dispatch.payload?.taskMode),
|
|
17784
18000
|
createdAt: dispatch.timestamp,
|
|
17785
18001
|
updatedAt: terminal?.timestamp || dispatch.timestamp,
|
|
17786
18002
|
dispatchedAt: dispatch.timestamp,
|
|
@@ -39681,207 +39897,7 @@ function getAvailableIdeIds() {
|
|
|
39681
39897
|
init_config();
|
|
39682
39898
|
init_cli_detector();
|
|
39683
39899
|
init_git_status();
|
|
39684
|
-
|
|
39685
|
-
// ../mesh-shared/dist/index.mjs
|
|
39686
|
-
function readRecord5(value) {
|
|
39687
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
39688
|
-
}
|
|
39689
|
-
function readString6(...values) {
|
|
39690
|
-
for (const value of values) {
|
|
39691
|
-
if (typeof value !== "string") continue;
|
|
39692
|
-
const trimmed = value.trim();
|
|
39693
|
-
if (trimmed) return trimmed;
|
|
39694
|
-
}
|
|
39695
|
-
return void 0;
|
|
39696
|
-
}
|
|
39697
|
-
function readNumber(...values) {
|
|
39698
|
-
for (const value of values) {
|
|
39699
|
-
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
39700
|
-
}
|
|
39701
|
-
return void 0;
|
|
39702
|
-
}
|
|
39703
|
-
function readBoolean(...values) {
|
|
39704
|
-
for (const value of values) {
|
|
39705
|
-
if (typeof value === "boolean") return value;
|
|
39706
|
-
}
|
|
39707
|
-
return void 0;
|
|
39708
|
-
}
|
|
39709
|
-
function joinRepoPath(root, relativePath) {
|
|
39710
|
-
const normalizedRoot = typeof root === "string" ? root.trim().replace(/[\\/]+$/, "") : "";
|
|
39711
|
-
const normalizedPath = typeof relativePath === "string" ? relativePath.trim() : "";
|
|
39712
|
-
if (!normalizedPath) return void 0;
|
|
39713
|
-
if (/^(?:[A-Za-z]:[\\/]|\/)/.test(normalizedPath)) return normalizedPath;
|
|
39714
|
-
if (!normalizedRoot) return void 0;
|
|
39715
|
-
return `${normalizedRoot}/${normalizedPath.replace(/^[\\/]+/, "")}`;
|
|
39716
|
-
}
|
|
39717
|
-
function scoreGitUpstreamFreshness(status) {
|
|
39718
|
-
switch (status) {
|
|
39719
|
-
case "fresh":
|
|
39720
|
-
return 30;
|
|
39721
|
-
case "no_upstream":
|
|
39722
|
-
return 4;
|
|
39723
|
-
case "unchecked":
|
|
39724
|
-
case void 0:
|
|
39725
|
-
return 0;
|
|
39726
|
-
case "stale":
|
|
39727
|
-
return -10;
|
|
39728
|
-
case "unavailable":
|
|
39729
|
-
return -15;
|
|
39730
|
-
default:
|
|
39731
|
-
return 0;
|
|
39732
|
-
}
|
|
39733
|
-
}
|
|
39734
|
-
function readGitSubmodules(value, parentRepoRoot) {
|
|
39735
|
-
if (!Array.isArray(value)) return void 0;
|
|
39736
|
-
const submodules = value.map((entry) => {
|
|
39737
|
-
const submodule = readRecord5(entry);
|
|
39738
|
-
const path40 = readString6(submodule.path);
|
|
39739
|
-
const commit = readString6(submodule.commit);
|
|
39740
|
-
const repoPath = readString6(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path40);
|
|
39741
|
-
if (!path40 || !commit) return null;
|
|
39742
|
-
const result = {
|
|
39743
|
-
path: path40,
|
|
39744
|
-
commit,
|
|
39745
|
-
dirty: readBoolean(submodule.dirty) ?? false,
|
|
39746
|
-
outOfSync: readBoolean(submodule.outOfSync, submodule.out_of_sync) ?? false,
|
|
39747
|
-
lastCheckedAt: readNumber(submodule.lastCheckedAt, submodule.last_checked_at) ?? Date.now()
|
|
39748
|
-
};
|
|
39749
|
-
if (repoPath) result.repoPath = repoPath;
|
|
39750
|
-
const error = readString6(submodule.error);
|
|
39751
|
-
if (error) result.error = error;
|
|
39752
|
-
return result;
|
|
39753
|
-
}).filter((entry) => entry !== null);
|
|
39754
|
-
return submodules.length > 0 ? submodules : void 0;
|
|
39755
|
-
}
|
|
39756
|
-
function hasGitStatusEvidence(status) {
|
|
39757
|
-
return readBoolean(status.isGitRepo) !== void 0 || Boolean(readString6(status.branch, status.upstream, status.upstreamStatus, status.upstream_status, status.headCommit)) || Boolean(readString6(status.repoRoot, status.repo_root, status.workspace)) || readNumber(
|
|
39758
|
-
status.ahead,
|
|
39759
|
-
status.behind,
|
|
39760
|
-
status.staged,
|
|
39761
|
-
status.modified,
|
|
39762
|
-
status.untracked,
|
|
39763
|
-
status.deleted,
|
|
39764
|
-
status.renamed,
|
|
39765
|
-
status.lastCheckedAt,
|
|
39766
|
-
status.last_checked_at
|
|
39767
|
-
) !== void 0 || Array.isArray(status.submodules) && status.submodules.length > 0;
|
|
39768
|
-
}
|
|
39769
|
-
function normalizeGitStatus(status, node, options) {
|
|
39770
|
-
const explicitIsGitRepo = readBoolean(status.isGitRepo);
|
|
39771
|
-
if (!Object.keys(status).length || !hasGitStatusEvidence(status)) return void 0;
|
|
39772
|
-
const isGitRepo = explicitIsGitRepo ?? true;
|
|
39773
|
-
const conflictFiles = Array.isArray(status.conflictFiles) ? status.conflictFiles.filter((entry) => typeof entry === "string") : [];
|
|
39774
|
-
const conflictCount = readNumber(status.conflicts) ?? conflictFiles.length;
|
|
39775
|
-
const hasConflicts = readBoolean(status.hasConflicts) ?? conflictCount > 0;
|
|
39776
|
-
const repoRoot = readString6(status.repoRoot, status.repo_root, node.repoRoot, node.repo_root, status.workspace, node.workspace) || void 0;
|
|
39777
|
-
const submodules = readGitSubmodules(status.submodules, repoRoot);
|
|
39778
|
-
const upstreamStatus = readString6(status.upstreamStatus, status.upstream_status);
|
|
39779
|
-
const upstreamFetchedAt = readNumber(status.upstreamFetchedAt, status.upstream_fetched_at);
|
|
39780
|
-
const upstreamFetchError = readString6(status.upstreamFetchError, status.upstream_fetch_error);
|
|
39781
|
-
const error = readString6(status.error);
|
|
39782
|
-
const staged = readNumber(status.staged) ?? 0;
|
|
39783
|
-
const modified = readNumber(status.modified) ?? 0;
|
|
39784
|
-
const untracked = readNumber(status.untracked) ?? 0;
|
|
39785
|
-
const deleted = readNumber(status.deleted) ?? 0;
|
|
39786
|
-
const renamed = readNumber(status.renamed) ?? 0;
|
|
39787
|
-
return {
|
|
39788
|
-
workspace: readString6(status.workspace, node.workspace) || "",
|
|
39789
|
-
repoRoot: repoRoot ?? null,
|
|
39790
|
-
isGitRepo,
|
|
39791
|
-
branch: readString6(status.branch) ?? null,
|
|
39792
|
-
headCommit: readString6(status.headCommit) ?? null,
|
|
39793
|
-
headMessage: readString6(status.headMessage) ?? null,
|
|
39794
|
-
upstream: readString6(status.upstream) ?? null,
|
|
39795
|
-
upstreamStatus: upstreamStatus ?? "unchecked",
|
|
39796
|
-
...upstreamFetchedAt !== void 0 ? { upstreamFetchedAt } : {},
|
|
39797
|
-
...upstreamFetchError ? { upstreamFetchError } : {},
|
|
39798
|
-
ahead: readNumber(status.ahead) ?? 0,
|
|
39799
|
-
behind: readNumber(status.behind) ?? 0,
|
|
39800
|
-
staged,
|
|
39801
|
-
modified,
|
|
39802
|
-
untracked,
|
|
39803
|
-
deleted,
|
|
39804
|
-
renamed,
|
|
39805
|
-
dirty: readBoolean(status.dirty, status.isDirty, status.is_dirty) ?? (staged + modified + untracked + deleted + renamed > 0 || hasConflicts),
|
|
39806
|
-
hasConflicts,
|
|
39807
|
-
conflictFiles,
|
|
39808
|
-
stashCount: readNumber(status.stashCount, status.stash_count) ?? 0,
|
|
39809
|
-
lastCheckedAt: options?.lastCheckedAt ?? readNumber(status.lastCheckedAt, status.last_checked_at) ?? Date.now(),
|
|
39810
|
-
...submodules ? { submodules } : {},
|
|
39811
|
-
...error ? { error } : {}
|
|
39812
|
-
};
|
|
39813
|
-
}
|
|
39814
|
-
function scoreGitStatusCandidate(git) {
|
|
39815
|
-
if (!git) return Number.NEGATIVE_INFINITY;
|
|
39816
|
-
let score = 0;
|
|
39817
|
-
if (git.isGitRepo === true) score += 50;
|
|
39818
|
-
if (git.isGitRepo === false) score -= 10;
|
|
39819
|
-
if (git.branch) score += 20;
|
|
39820
|
-
if (git.headCommit) score += 20;
|
|
39821
|
-
if (git.upstream) score += 10;
|
|
39822
|
-
score += scoreGitUpstreamFreshness(git.upstreamStatus);
|
|
39823
|
-
if (typeof git.ahead === "number") score += 2;
|
|
39824
|
-
if (typeof git.behind === "number") score += 2;
|
|
39825
|
-
if (Array.isArray(git.submodules) && git.submodules.length > 0) score += 4 + git.submodules.length;
|
|
39826
|
-
if (git.error) score -= 20;
|
|
39827
|
-
return score;
|
|
39828
|
-
}
|
|
39829
|
-
function pickBestTransitGitStatus(node, options) {
|
|
39830
|
-
const rawGit = readRecord5(node.lastGit ?? node.last_git);
|
|
39831
|
-
const gitResult = readRecord5(rawGit.result);
|
|
39832
|
-
const directStatus = readRecord5(rawGit.status);
|
|
39833
|
-
const nestedStatus = readRecord5(gitResult.status);
|
|
39834
|
-
const rawProbe = readRecord5(node.lastProbe ?? node.last_probe);
|
|
39835
|
-
const probeGit = readRecord5(rawProbe.git);
|
|
39836
|
-
const probeGitResult = readRecord5(probeGit.result);
|
|
39837
|
-
const probeDirectStatus = readRecord5(probeGit.status);
|
|
39838
|
-
const probeNestedStatus = readRecord5(probeGitResult.status);
|
|
39839
|
-
const lastCheckedAt = options?.lastCheckedAt;
|
|
39840
|
-
let best = null;
|
|
39841
|
-
for (const status of [directStatus, nestedStatus, probeDirectStatus, probeNestedStatus]) {
|
|
39842
|
-
const normalized = normalizeGitStatus(status, node, { lastCheckedAt: lastCheckedAt ?? Date.now() });
|
|
39843
|
-
if (!normalized) continue;
|
|
39844
|
-
const score = scoreGitStatusCandidate(normalized);
|
|
39845
|
-
if (!best || score > best.score) best = { git: normalized, score };
|
|
39846
|
-
}
|
|
39847
|
-
return best?.git;
|
|
39848
|
-
}
|
|
39849
|
-
function summarizeGitShape(status) {
|
|
39850
|
-
const record = readRecord5(status);
|
|
39851
|
-
if (!Object.keys(record).length) return null;
|
|
39852
|
-
const submodules = Array.isArray(record.submodules) ? record.submodules.map((entry) => {
|
|
39853
|
-
const sub = readRecord5(entry);
|
|
39854
|
-
return {
|
|
39855
|
-
path: readString6(sub.path) ?? null,
|
|
39856
|
-
commit: readString6(sub.commit)?.slice(0, 12) ?? null,
|
|
39857
|
-
dirty: readBoolean(sub.dirty) ?? false,
|
|
39858
|
-
outOfSync: readBoolean(sub.outOfSync, sub.out_of_sync) ?? false
|
|
39859
|
-
};
|
|
39860
|
-
}) : [];
|
|
39861
|
-
return {
|
|
39862
|
-
isGitRepo: readBoolean(record.isGitRepo),
|
|
39863
|
-
workspace: readString6(record.workspace) ?? null,
|
|
39864
|
-
repoRoot: readString6(record.repoRoot, record.repo_root) ?? null,
|
|
39865
|
-
branch: readString6(record.branch) ?? null,
|
|
39866
|
-
upstream: readString6(record.upstream) ?? null,
|
|
39867
|
-
upstreamStatus: readString6(record.upstreamStatus, record.upstream_status) ?? null,
|
|
39868
|
-
headCommit: readString6(record.headCommit, record.head_commit)?.slice(0, 12) ?? null,
|
|
39869
|
-
ahead: readNumber(record.ahead) ?? null,
|
|
39870
|
-
behind: readNumber(record.behind) ?? null,
|
|
39871
|
-
dirtyCounts: {
|
|
39872
|
-
staged: readNumber(record.staged) ?? 0,
|
|
39873
|
-
modified: readNumber(record.modified) ?? 0,
|
|
39874
|
-
untracked: readNumber(record.untracked) ?? 0,
|
|
39875
|
-
deleted: readNumber(record.deleted) ?? 0,
|
|
39876
|
-
renamed: readNumber(record.renamed) ?? 0
|
|
39877
|
-
},
|
|
39878
|
-
lastCheckedAt: readNumber(record.lastCheckedAt, record.last_checked_at) ?? null,
|
|
39879
|
-
submoduleCount: submodules.length,
|
|
39880
|
-
submodules
|
|
39881
|
-
};
|
|
39882
|
-
}
|
|
39883
|
-
|
|
39884
|
-
// src/commands/router.ts
|
|
39900
|
+
init_dist();
|
|
39885
39901
|
init_logger();
|
|
39886
39902
|
|
|
39887
39903
|
// src/logging/command-log.ts
|
|
@@ -40961,7 +40977,10 @@ function summarizeRepoMeshStatusDebug(status) {
|
|
|
40961
40977
|
branchConvergenceSummary: status?.branchConvergenceSummary ?? status?.branch_convergence_summary ?? null,
|
|
40962
40978
|
nodeCount: nodes.length,
|
|
40963
40979
|
nodes: nodes.map((node) => ({
|
|
40964
|
-
nodeId
|
|
40980
|
+
// Status emits the id under `nodeId` (3-way input absorbed). The
|
|
40981
|
+
// inline cache keeps `id` and `nodeId` equal, so this serialized form
|
|
40982
|
+
// round-trips back through the cache without flipping shape.
|
|
40983
|
+
nodeId: normalizeMeshNodeId(node) ?? null,
|
|
40965
40984
|
daemonId: readStringValue(node?.daemonId, node?.daemon_id) ?? null,
|
|
40966
40985
|
workspace: readStringValue(node?.workspace, node?.git?.workspace) ?? null,
|
|
40967
40986
|
health: readStringValue(node?.health) ?? null,
|
|
@@ -41206,7 +41225,23 @@ function inlineMeshCarriesTransientNodeTruth(inlineMesh) {
|
|
|
41206
41225
|
return inlineMesh.nodes.some((node) => hasInlineMeshTransientNodeState(node));
|
|
41207
41226
|
}
|
|
41208
41227
|
function readInlineMeshNodeId(node) {
|
|
41209
|
-
return
|
|
41228
|
+
return normalizeMeshNodeId(node) ?? "";
|
|
41229
|
+
}
|
|
41230
|
+
function foldMeshNodeIdentityToCanonical(node) {
|
|
41231
|
+
if (!node || typeof node !== "object" || Array.isArray(node)) return node;
|
|
41232
|
+
const canonical = normalizeMeshNodeId(node);
|
|
41233
|
+
if (canonical === void 0) return node;
|
|
41234
|
+
if (node.id === canonical && node.nodeId === canonical && node.node_id === void 0) return node;
|
|
41235
|
+
node.id = canonical;
|
|
41236
|
+
node.nodeId = canonical;
|
|
41237
|
+
if ("node_id" in node) delete node.node_id;
|
|
41238
|
+
return node;
|
|
41239
|
+
}
|
|
41240
|
+
function normalizeInlineMeshNodeIdentity(inlineMesh) {
|
|
41241
|
+
if (!inlineMesh || typeof inlineMesh !== "object" || Array.isArray(inlineMesh)) return inlineMesh;
|
|
41242
|
+
if (!Array.isArray(inlineMesh.nodes) || inlineMesh.nodes.length === 0) return inlineMesh;
|
|
41243
|
+
for (const node of inlineMesh.nodes) foldMeshNodeIdentityToCanonical(node);
|
|
41244
|
+
return inlineMesh;
|
|
41210
41245
|
}
|
|
41211
41246
|
function sanitizeInlineMesh(inlineMesh) {
|
|
41212
41247
|
if (!inlineMesh || typeof inlineMesh !== "object" || Array.isArray(inlineMesh)) return inlineMesh;
|
|
@@ -41308,7 +41343,7 @@ function deriveMeshNodeHealthFromGit(git) {
|
|
|
41308
41343
|
return "online";
|
|
41309
41344
|
}
|
|
41310
41345
|
function readMeshNodeLabel(status, node) {
|
|
41311
|
-
return readStringValue(status.nodeId, node
|
|
41346
|
+
return readStringValue(status.nodeId, normalizeMeshNodeId(node)) ?? "unknown";
|
|
41312
41347
|
}
|
|
41313
41348
|
function buildInlineMeshBranchConvergence(args) {
|
|
41314
41349
|
const git = readObjectRecord(args.status.git);
|
|
@@ -41587,7 +41622,7 @@ async function hydrateInlineMeshDirectTruth(args) {
|
|
|
41587
41622
|
let peerConfirmedCount = 0;
|
|
41588
41623
|
const unavailableNodeIds = [];
|
|
41589
41624
|
for (const [nodeIndex, node] of nodes.entries()) {
|
|
41590
|
-
const nodeId =
|
|
41625
|
+
const nodeId = normalizeMeshNodeId(node) || `node_${nodeIndex}`;
|
|
41591
41626
|
const workspace = readStringValue(node?.workspace);
|
|
41592
41627
|
const daemonId = readStringValue(node?.daemonId);
|
|
41593
41628
|
const isSelfNode = Boolean(
|
|
@@ -41718,7 +41753,7 @@ function buildHistoricalMeshSessions(args) {
|
|
|
41718
41753
|
const liveWorkspaces = /* @__PURE__ */ new Set();
|
|
41719
41754
|
const missingLocalWorktreeNodeIds = /* @__PURE__ */ new Set();
|
|
41720
41755
|
for (const node of args.nodes || []) {
|
|
41721
|
-
const nodeId =
|
|
41756
|
+
const nodeId = normalizeMeshNodeId(node);
|
|
41722
41757
|
const workspace = readStringValue(node?.workspace);
|
|
41723
41758
|
if (nodeId) liveNodeIds.add(nodeId);
|
|
41724
41759
|
if (workspace) liveWorkspaces.add(workspace);
|
|
@@ -41843,9 +41878,13 @@ function resolveRefineryAutoPublishSubmoduleMainCommits(mesh, workspace) {
|
|
|
41843
41878
|
}
|
|
41844
41879
|
return { enabled: false };
|
|
41845
41880
|
}
|
|
41846
|
-
async function computeGitPatchId(cwd, fromRef, toRef) {
|
|
41881
|
+
async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
|
|
41847
41882
|
const { execFileSync: execFileSync6 } = await import("child_process");
|
|
41848
|
-
const
|
|
41883
|
+
const diffArgs = ["diff", "--patch", "--full-index", fromRef, toRef];
|
|
41884
|
+
if (excludePaths.length > 0) {
|
|
41885
|
+
diffArgs.push("--", ".", ...excludePaths.map((path40) => `:(exclude)${path40}`));
|
|
41886
|
+
}
|
|
41887
|
+
const diff = execFileSync6("git", diffArgs, {
|
|
41849
41888
|
cwd,
|
|
41850
41889
|
encoding: "utf8",
|
|
41851
41890
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -41914,8 +41953,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
41914
41953
|
gitlinkTrivialFastForward
|
|
41915
41954
|
};
|
|
41916
41955
|
}
|
|
41917
|
-
const
|
|
41918
|
-
const
|
|
41956
|
+
const ffGitlinkExcludePaths = collectFastForwardGitlinkPaths(repoRoot, baseHead, branchHead);
|
|
41957
|
+
const expectedPatchId = await computeGitPatchId(repoRoot, mergeBase, branchHead, ffGitlinkExcludePaths);
|
|
41958
|
+
const actualPatchId = await computeGitPatchId(repoRoot, baseHead, mergedTree, ffGitlinkExcludePaths);
|
|
41919
41959
|
const equivalent = expectedPatchId === actualPatchId;
|
|
41920
41960
|
return {
|
|
41921
41961
|
status: equivalent ? "passed" : "failed",
|
|
@@ -42111,6 +42151,14 @@ function readChangedPathKinds(repoRoot, fromRef, toRef) {
|
|
|
42111
42151
|
return [];
|
|
42112
42152
|
}
|
|
42113
42153
|
}
|
|
42154
|
+
function collectFastForwardGitlinkPaths(repoRoot, baseHead, branchHead) {
|
|
42155
|
+
return readChangedGitlinkPaths(repoRoot, baseHead, branchHead).filter((path40) => {
|
|
42156
|
+
const baseCommit = readTreeObject(repoRoot, baseHead, path40);
|
|
42157
|
+
const branchCommit = readTreeObject(repoRoot, branchHead, path40);
|
|
42158
|
+
if (!baseCommit || !branchCommit) return false;
|
|
42159
|
+
return isSubmoduleFastForward((0, import_path10.resolve)(repoRoot, path40), baseCommit, branchCommit);
|
|
42160
|
+
});
|
|
42161
|
+
}
|
|
42114
42162
|
function evaluateGitlinkTrivialFastForward(repoRoot, baseHead, branchHead) {
|
|
42115
42163
|
const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path40) => {
|
|
42116
42164
|
const baseCommit = readTreeObject(repoRoot, baseHead, path40);
|
|
@@ -42160,20 +42208,95 @@ function evaluateGitlinkTrivialFastForward(repoRoot, baseHead, branchHead) {
|
|
|
42160
42208
|
}
|
|
42161
42209
|
return { trivial: true, gitlinks: changedGitlinks };
|
|
42162
42210
|
}
|
|
42211
|
+
function buildTreeWithGitlinksEqualized(repoRoot, commitish, paths, placeholderCommit) {
|
|
42212
|
+
try {
|
|
42213
|
+
const tree = (0, import_node_child_process6.execFileSync)("git", ["rev-parse", `${commitish}^{tree}`], {
|
|
42214
|
+
cwd: repoRoot,
|
|
42215
|
+
encoding: "utf8",
|
|
42216
|
+
maxBuffer: 1024 * 1024
|
|
42217
|
+
}).trim();
|
|
42218
|
+
if (!tree) return void 0;
|
|
42219
|
+
const updates = paths.map((path40) => `160000 commit ${placeholderCommit} ${path40}`).join("\n");
|
|
42220
|
+
if (!updates) return tree;
|
|
42221
|
+
const tmpIndex = (0, import_path10.join)(resolveGitDir(repoRoot), `adhdev-refine-eq-${commitish.slice(0, 12)}.index`);
|
|
42222
|
+
const env = { ...process.env, GIT_INDEX_FILE: tmpIndex };
|
|
42223
|
+
try {
|
|
42224
|
+
(0, import_node_child_process6.execFileSync)("git", ["read-tree", tree], { cwd: repoRoot, env, stdio: "ignore" });
|
|
42225
|
+
(0, import_node_child_process6.execFileSync)("git", ["update-index", "--index-info"], {
|
|
42226
|
+
cwd: repoRoot,
|
|
42227
|
+
env,
|
|
42228
|
+
input: `${updates}
|
|
42229
|
+
`,
|
|
42230
|
+
encoding: "utf8",
|
|
42231
|
+
stdio: ["pipe", "ignore", "ignore"]
|
|
42232
|
+
});
|
|
42233
|
+
const newTree = (0, import_node_child_process6.execFileSync)("git", ["write-tree"], { cwd: repoRoot, env, encoding: "utf8" }).trim();
|
|
42234
|
+
return newTree || void 0;
|
|
42235
|
+
} finally {
|
|
42236
|
+
try {
|
|
42237
|
+
fs24.rmSync(tmpIndex, { force: true });
|
|
42238
|
+
} catch {
|
|
42239
|
+
}
|
|
42240
|
+
}
|
|
42241
|
+
} catch {
|
|
42242
|
+
return void 0;
|
|
42243
|
+
}
|
|
42244
|
+
}
|
|
42163
42245
|
function synthesizeTrivialFastForwardMergeTree(repoRoot, baseHead, branchHead, gitlinks) {
|
|
42164
42246
|
try {
|
|
42165
|
-
const
|
|
42247
|
+
const branchGitlinks = gitlinks.filter((entry) => entry.branchCommit);
|
|
42248
|
+
const gitlinkPaths = branchGitlinks.map((entry) => entry.path);
|
|
42249
|
+
const mergeBase = (0, import_node_child_process6.execFileSync)("git", ["merge-base", baseHead, branchHead], {
|
|
42250
|
+
cwd: repoRoot,
|
|
42251
|
+
encoding: "utf8",
|
|
42252
|
+
maxBuffer: 1024 * 1024
|
|
42253
|
+
}).trim();
|
|
42254
|
+
let mergedContentTree;
|
|
42255
|
+
if (mergeBase && gitlinkPaths.length > 0) {
|
|
42256
|
+
const placeholder = readTreeObject(repoRoot, mergeBase, gitlinkPaths[0]) || branchGitlinks[0].branchCommit;
|
|
42257
|
+
const baseEqTree = buildTreeWithGitlinksEqualized(repoRoot, mergeBase, gitlinkPaths, placeholder);
|
|
42258
|
+
const oursEqTree = buildTreeWithGitlinksEqualized(repoRoot, baseHead, gitlinkPaths, placeholder);
|
|
42259
|
+
const theirsEqTree = buildTreeWithGitlinksEqualized(repoRoot, branchHead, gitlinkPaths, placeholder);
|
|
42260
|
+
if (baseEqTree && oursEqTree && theirsEqTree) {
|
|
42261
|
+
try {
|
|
42262
|
+
const baseEqCommit = (0, import_node_child_process6.execFileSync)("git", ["commit-tree", baseEqTree, "-m", "refine-ff-base"], {
|
|
42263
|
+
cwd: repoRoot,
|
|
42264
|
+
encoding: "utf8",
|
|
42265
|
+
maxBuffer: 1024 * 1024
|
|
42266
|
+
}).trim();
|
|
42267
|
+
const oursEqCommit = (0, import_node_child_process6.execFileSync)("git", ["commit-tree", oursEqTree, "-p", baseEqCommit, "-m", "refine-ff-ours"], {
|
|
42268
|
+
cwd: repoRoot,
|
|
42269
|
+
encoding: "utf8",
|
|
42270
|
+
maxBuffer: 1024 * 1024
|
|
42271
|
+
}).trim();
|
|
42272
|
+
const theirsEqCommit = (0, import_node_child_process6.execFileSync)("git", ["commit-tree", theirsEqTree, "-p", baseEqCommit, "-m", "refine-ff-theirs"], {
|
|
42273
|
+
cwd: repoRoot,
|
|
42274
|
+
encoding: "utf8",
|
|
42275
|
+
maxBuffer: 1024 * 1024
|
|
42276
|
+
}).trim();
|
|
42277
|
+
const mergeOut = (0, import_node_child_process6.execFileSync)("git", ["merge-tree", "--write-tree", oursEqCommit, theirsEqCommit], {
|
|
42278
|
+
cwd: repoRoot,
|
|
42279
|
+
encoding: "utf8",
|
|
42280
|
+
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
42281
|
+
}).trim();
|
|
42282
|
+
mergedContentTree = mergeOut.split(/\s+/)[0] || void 0;
|
|
42283
|
+
} catch {
|
|
42284
|
+
mergedContentTree = void 0;
|
|
42285
|
+
}
|
|
42286
|
+
}
|
|
42287
|
+
}
|
|
42288
|
+
const contentTree = mergedContentTree || (0, import_node_child_process6.execFileSync)("git", ["rev-parse", `${baseHead}^{tree}`], {
|
|
42166
42289
|
cwd: repoRoot,
|
|
42167
42290
|
encoding: "utf8",
|
|
42168
42291
|
maxBuffer: 1024 * 1024
|
|
42169
42292
|
}).trim();
|
|
42170
|
-
if (!
|
|
42171
|
-
const updates =
|
|
42172
|
-
if (!updates) return
|
|
42293
|
+
if (!contentTree) return void 0;
|
|
42294
|
+
const updates = branchGitlinks.map((entry) => `160000 commit ${entry.branchCommit} ${entry.path}`).join("\n");
|
|
42295
|
+
if (!updates) return contentTree;
|
|
42173
42296
|
const tmpIndex = (0, import_path10.join)(resolveGitDir(repoRoot), `adhdev-refine-ff-${baseHead.slice(0, 12)}-${branchHead.slice(0, 12)}.index`);
|
|
42174
42297
|
const env = { ...process.env, GIT_INDEX_FILE: tmpIndex };
|
|
42175
42298
|
try {
|
|
42176
|
-
(0, import_node_child_process6.execFileSync)("git", ["read-tree",
|
|
42299
|
+
(0, import_node_child_process6.execFileSync)("git", ["read-tree", contentTree], { cwd: repoRoot, env, stdio: "ignore" });
|
|
42177
42300
|
(0, import_node_child_process6.execFileSync)("git", ["update-index", "--index-info"], {
|
|
42178
42301
|
cwd: repoRoot,
|
|
42179
42302
|
env,
|
|
@@ -42833,7 +42956,7 @@ function normalizeStandaloneHostCommandUrl(hostAddress) {
|
|
|
42833
42956
|
function buildMemberJoinNode(mesh, args, fallbackDaemonId) {
|
|
42834
42957
|
const requestedNodeId = typeof args?.memberNodeId === "string" ? args.memberNodeId.trim() : "";
|
|
42835
42958
|
const explicit = args?.memberNode && typeof args.memberNode === "object" && !Array.isArray(args.memberNode) ? args.memberNode : null;
|
|
42836
|
-
const configured = Array.isArray(mesh?.nodes) ? requestedNodeId ? mesh.nodes.find((node) => node
|
|
42959
|
+
const configured = Array.isArray(mesh?.nodes) ? requestedNodeId ? mesh.nodes.find((node) => meshNodeIdMatches(node, requestedNodeId)) : mesh.nodes[0] : null;
|
|
42837
42960
|
const source = explicit || configured;
|
|
42838
42961
|
const workspace = typeof source?.workspace === "string" && source.workspace.trim() ? source.workspace.trim() : typeof args?.workspace === "string" && args.workspace.trim() ? args.workspace.trim() : process.cwd();
|
|
42839
42962
|
if (!workspace) return null;
|
|
@@ -42889,7 +43012,7 @@ var DaemonCommandRouter = class {
|
|
|
42889
43012
|
if (nodeId) unavailableNodeIds.add(nodeId);
|
|
42890
43013
|
}
|
|
42891
43014
|
const nodes = snapshot.nodes.map((statusNode) => {
|
|
42892
|
-
const nodeId =
|
|
43015
|
+
const nodeId = normalizeMeshNodeId(statusNode);
|
|
42893
43016
|
const inlineNode = nodeId ? inlineNodesById.get(nodeId) : void 0;
|
|
42894
43017
|
if (!inlineNode) return statusNode;
|
|
42895
43018
|
const liveGit = buildInlineMeshTransitGitStatus(inlineNode);
|
|
@@ -43002,7 +43125,7 @@ var DaemonCommandRouter = class {
|
|
|
43002
43125
|
}
|
|
43003
43126
|
warmInlineMeshCache(meshId, inlineMesh) {
|
|
43004
43127
|
if (!inlineMesh || typeof inlineMesh !== "object") return void 0;
|
|
43005
|
-
const sanitizedInlineMesh = sanitizeInlineMesh(inlineMesh);
|
|
43128
|
+
const sanitizedInlineMesh = sanitizeInlineMesh(normalizeInlineMeshNodeIdentity(inlineMesh));
|
|
43006
43129
|
const cached2 = this.inlineMeshCache.get(meshId);
|
|
43007
43130
|
if (cached2) {
|
|
43008
43131
|
const merged = reconcileInlineMeshCache(cached2, sanitizedInlineMesh);
|
|
@@ -43019,7 +43142,7 @@ var DaemonCommandRouter = class {
|
|
|
43019
43142
|
if (cached3) {
|
|
43020
43143
|
if (inlineMeshCarriesTransientNodeTruth(inlineMesh)) {
|
|
43021
43144
|
const merged = reconcileInlineMeshCache(cached3, inlineMesh);
|
|
43022
|
-
this.inlineMeshCache.set(meshId, sanitizeInlineMesh(merged));
|
|
43145
|
+
this.inlineMeshCache.set(meshId, sanitizeInlineMesh(normalizeInlineMeshNodeIdentity(merged)));
|
|
43023
43146
|
return { mesh: merged, inline: true, source: "inline_cache" };
|
|
43024
43147
|
}
|
|
43025
43148
|
return { mesh: cached3, inline: true, source: "inline_cache" };
|
|
@@ -43055,17 +43178,19 @@ var DaemonCommandRouter = class {
|
|
|
43055
43178
|
return null;
|
|
43056
43179
|
}
|
|
43057
43180
|
updateInlineMeshNode(meshId, mesh, node) {
|
|
43058
|
-
|
|
43059
|
-
|
|
43181
|
+
const incomingId = normalizeMeshNodeId(node);
|
|
43182
|
+
if (!mesh || !Array.isArray(mesh.nodes) || !incomingId) return;
|
|
43183
|
+
const idx = mesh.nodes.findIndex((entry) => meshNodeIdMatches(entry, incomingId));
|
|
43060
43184
|
if (idx >= 0) mesh.nodes[idx] = node;
|
|
43061
43185
|
else mesh.nodes.push(node);
|
|
43062
43186
|
mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
43187
|
+
for (const entry of mesh.nodes) foldMeshNodeIdentityToCanonical(entry);
|
|
43063
43188
|
this.inlineMeshCache.set(meshId, mesh);
|
|
43064
43189
|
this.invalidateAggregateMeshStatus(meshId);
|
|
43065
43190
|
}
|
|
43066
43191
|
removeInlineMeshNode(meshId, mesh, nodeId) {
|
|
43067
43192
|
if (!mesh || !Array.isArray(mesh.nodes)) return false;
|
|
43068
|
-
const idx = mesh.nodes.findIndex((entry) => entry
|
|
43193
|
+
const idx = mesh.nodes.findIndex((entry) => meshNodeIdMatches(entry, nodeId));
|
|
43069
43194
|
if (idx === -1) return false;
|
|
43070
43195
|
mesh.nodes.splice(idx, 1);
|
|
43071
43196
|
mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -43096,7 +43221,7 @@ var DaemonCommandRouter = class {
|
|
|
43096
43221
|
};
|
|
43097
43222
|
}
|
|
43098
43223
|
const worktreeExists = fs24.existsSync(workspace);
|
|
43099
|
-
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => n
|
|
43224
|
+
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
43100
43225
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
43101
43226
|
if (!worktreeExists) {
|
|
43102
43227
|
return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
|
|
@@ -43739,12 +43864,12 @@ var DaemonCommandRouter = class {
|
|
|
43739
43864
|
try {
|
|
43740
43865
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
43741
43866
|
const mesh = meshRecord?.mesh;
|
|
43742
|
-
const node = mesh?.nodes?.find((n) => n
|
|
43867
|
+
const node = mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
|
|
43743
43868
|
if (!node) return { success: false, error: `Node '${nodeId}' not found in mesh`, refineStages };
|
|
43744
43869
|
if (!node.isLocalWorktree || !node.workspace) {
|
|
43745
43870
|
return { success: false, error: `Refinery requires a local worktree node`, refineStages };
|
|
43746
43871
|
}
|
|
43747
|
-
const sourceNode = node.clonedFromNodeId ? mesh?.nodes.find((n) => n
|
|
43872
|
+
const sourceNode = node.clonedFromNodeId ? mesh?.nodes.find((n) => meshNodeIdMatches(n, node.clonedFromNodeId)) : mesh?.nodes.find((n) => !n.isLocalWorktree);
|
|
43748
43873
|
const repoRoot = sourceNode?.repoRoot || sourceNode?.workspace;
|
|
43749
43874
|
if (!repoRoot) return { success: false, error: "Source node repoRoot not found", refineStages };
|
|
43750
43875
|
const { execFile: execFile5 } = await import("child_process");
|
|
@@ -44379,7 +44504,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
44379
44504
|
const missing = [];
|
|
44380
44505
|
const nonWorktree = [];
|
|
44381
44506
|
for (const nodeId of requestedNodeIds) {
|
|
44382
|
-
const node = allNodes.find((n) => n
|
|
44507
|
+
const node = allNodes.find((n) => meshNodeIdMatches(n, nodeId));
|
|
44383
44508
|
if (!node) {
|
|
44384
44509
|
missing.push(nodeId);
|
|
44385
44510
|
continue;
|
|
@@ -44408,7 +44533,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
44408
44533
|
const { promisify: promisify8 } = await import("util");
|
|
44409
44534
|
const execFileAsync4 = promisify8(execFile5);
|
|
44410
44535
|
const resolveRepoRootFor = (node) => {
|
|
44411
|
-
const sourceNode = node.clonedFromNodeId ? allNodes.find((n) => n
|
|
44536
|
+
const sourceNode = node.clonedFromNodeId ? allNodes.find((n) => meshNodeIdMatches(n, node.clonedFromNodeId)) : allNodes.find((n) => !n.isLocalWorktree);
|
|
44412
44537
|
return sourceNode?.repoRoot || sourceNode?.workspace;
|
|
44413
44538
|
};
|
|
44414
44539
|
const repoRootBaseRef = /* @__PURE__ */ new Map();
|
|
@@ -44497,7 +44622,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
44497
44622
|
}));
|
|
44498
44623
|
}
|
|
44499
44624
|
const ordering = orderMeshRefineBatchNodes(changeAreas);
|
|
44500
|
-
const orderedNodes = ordering.order.map((nodeId) => targetNodes.find((n) => n
|
|
44625
|
+
const orderedNodes = ordering.order.map((nodeId) => targetNodes.find((n) => meshNodeIdMatches(n, nodeId))).filter((n) => !!n);
|
|
44501
44626
|
const dryRun = args?.dryRun !== false && args?.execute !== true;
|
|
44502
44627
|
if (dryRun) {
|
|
44503
44628
|
return {
|
|
@@ -44756,7 +44881,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
44756
44881
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
44757
44882
|
const mesh = meshRecord?.mesh;
|
|
44758
44883
|
const allNodes = Array.isArray(mesh?.nodes) ? mesh.nodes : [];
|
|
44759
|
-
const orderedNodes = nodeIds.map((id) => allNodes.find((n) => n
|
|
44884
|
+
const orderedNodes = nodeIds.map((id) => allNodes.find((n) => meshNodeIdMatches(n, id))).filter((n) => !!n);
|
|
44760
44885
|
if (orderedNodes.length === 0) {
|
|
44761
44886
|
return { success: false, error: "Batch nodes no longer resolvable in mesh", batch: true };
|
|
44762
44887
|
}
|
|
@@ -44862,7 +44987,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
44862
44987
|
const terminal = this.terminalRefineJobs.get(key);
|
|
44863
44988
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
44864
44989
|
const mesh = meshRecord?.mesh;
|
|
44865
|
-
const node = mesh?.nodes?.find((n) => n
|
|
44990
|
+
const node = mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
|
|
44866
44991
|
if (!node) return { success: false, error: `Node '${nodeId}' not found in mesh` };
|
|
44867
44992
|
if (!node.isLocalWorktree || !node.workspace) return { success: false, error: `Refinery requires a local worktree node` };
|
|
44868
44993
|
const coordinatorDaemonId = typeof args?.coordinatorDaemonId === "string" && args.coordinatorDaemonId.trim() ? args.coordinatorDaemonId.trim() : this.deps.statusInstanceId || void 0;
|
|
@@ -44909,7 +45034,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
44909
45034
|
try {
|
|
44910
45035
|
const { getMesh: getMesh2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
44911
45036
|
const meshObj = getMesh2(meshId) ?? this.getCachedInlineMesh(meshId);
|
|
44912
|
-
const nodeObj = Array.isArray(meshObj?.nodes) ? meshObj.nodes.find((n) => n
|
|
45037
|
+
const nodeObj = Array.isArray(meshObj?.nodes) ? meshObj.nodes.find((n) => meshNodeIdMatches(n, meshNodeId)) : void 0;
|
|
44913
45038
|
const bootstrapStatus = readStringValue(nodeObj?.worktreeBootstrap?.status);
|
|
44914
45039
|
if (bootstrapStatus === "running") {
|
|
44915
45040
|
return { success: true, ...launchResult, bootstrapPending: true };
|
|
@@ -44954,7 +45079,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
44954
45079
|
try {
|
|
44955
45080
|
const { getMesh: getMesh2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
44956
45081
|
const meshObj = getMesh2(dispatchMeshId) ?? this.getCachedInlineMesh(dispatchMeshId);
|
|
44957
|
-
const nodeObj = Array.isArray(meshObj?.nodes) ? meshObj.nodes.find((n) => n
|
|
45082
|
+
const nodeObj = Array.isArray(meshObj?.nodes) ? meshObj.nodes.find((n) => meshNodeIdMatches(n, dispatchNodeId)) : void 0;
|
|
44958
45083
|
const bootstrapStatus = readStringValue(nodeObj?.worktreeBootstrap?.status);
|
|
44959
45084
|
if (bootstrapStatus === "running") {
|
|
44960
45085
|
return {
|
|
@@ -46219,7 +46344,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
46219
46344
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
46220
46345
|
const mesh = meshRecord?.mesh;
|
|
46221
46346
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
46222
|
-
const node = mesh?.nodes?.find((n) => n
|
|
46347
|
+
const node = mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
|
|
46223
46348
|
if (!node) return { success: false, error: `Node '${nodeId}' not found in mesh` };
|
|
46224
46349
|
const mode = this.normalizeMeshSessionCleanupMode(args?.mode ?? mesh?.policy?.sessionCleanupOnNodeRemove);
|
|
46225
46350
|
const sessionIds = Array.isArray(args?.sessionIds) ? args.sessionIds.map((id) => typeof id === "string" ? id.trim() : "").filter(Boolean) : void 0;
|
|
@@ -46274,7 +46399,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
46274
46399
|
if (!meshId || !nodeId) return { success: false, error: "meshId and nodeId required" };
|
|
46275
46400
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
46276
46401
|
const mesh = meshRecord?.mesh;
|
|
46277
|
-
const node = mesh?.nodes?.find((n) => n
|
|
46402
|
+
const node = mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
|
|
46278
46403
|
if (!node?.workspace) return { success: false, error: `Node '${nodeId}' workspace not found` };
|
|
46279
46404
|
return {
|
|
46280
46405
|
success: true,
|
|
@@ -46296,7 +46421,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
46296
46421
|
if (meshId && nodeId) {
|
|
46297
46422
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
46298
46423
|
const mesh = meshRecord?.mesh;
|
|
46299
|
-
const node = mesh?.nodes?.find((n) => n
|
|
46424
|
+
const node = mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
|
|
46300
46425
|
if (!workspace) {
|
|
46301
46426
|
workspace = typeof node?.workspace === "string" ? node.workspace.trim() : "";
|
|
46302
46427
|
}
|
|
@@ -46339,7 +46464,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
46339
46464
|
if (isDryRun) {
|
|
46340
46465
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
46341
46466
|
const mesh = meshRecord?.mesh;
|
|
46342
|
-
const node = mesh?.nodes?.find((n) => n
|
|
46467
|
+
const node = mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
|
|
46343
46468
|
if (!node?.workspace) return { success: false, error: `Node '${nodeId}' workspace not found` };
|
|
46344
46469
|
return {
|
|
46345
46470
|
success: true,
|
|
@@ -46369,7 +46494,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
46369
46494
|
try {
|
|
46370
46495
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
46371
46496
|
const mesh = meshRecord?.mesh;
|
|
46372
|
-
const node = mesh?.nodes?.find((n) => n
|
|
46497
|
+
const node = mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
|
|
46373
46498
|
if (node && !args?._meshDirectDispatch && node.isLocalWorktree !== true && args?.force !== true) {
|
|
46374
46499
|
const nodeDaemonId = typeof node.daemonId === "string" ? node.daemonId.trim() : "";
|
|
46375
46500
|
const nodeMachineId = readMeshNodeMachineId(node) || "";
|
|
@@ -46483,7 +46608,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
46483
46608
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
46484
46609
|
const mesh = meshRecord?.mesh;
|
|
46485
46610
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
46486
|
-
const sourceNode = mesh.nodes?.find((n) => n
|
|
46611
|
+
const sourceNode = mesh.nodes?.find((n) => meshNodeIdMatches(n, sourceNodeId));
|
|
46487
46612
|
if (!sourceNode) return { success: false, error: `Source node '${sourceNodeId}' not found in mesh` };
|
|
46488
46613
|
const sourceDaemonId = typeof sourceNode.daemonId === "string" ? sourceNode.daemonId.trim() : void 0;
|
|
46489
46614
|
if (sourceDaemonId && sourceDaemonId !== this.deps.statusInstanceId && this.deps.dispatchMeshCommand && !args?._meshDirectDispatch) {
|
|
@@ -46724,7 +46849,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
46724
46849
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
46725
46850
|
const mesh = meshRecord?.mesh;
|
|
46726
46851
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
46727
|
-
const node = mesh.nodes?.find((n) => n
|
|
46852
|
+
const node = mesh.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
|
|
46728
46853
|
if (!node) return { success: false, error: `Node '${nodeId}' not found in mesh` };
|
|
46729
46854
|
if (!node.isLocalWorktree) return { success: false, error: "Node is not a local worktree node" };
|
|
46730
46855
|
const nodeDaemonId = typeof node.daemonId === "string" ? node.daemonId.trim() : void 0;
|
|
@@ -46861,14 +46986,14 @@ ${hintLines.join("\n")}` : "",
|
|
|
46861
46986
|
const liveMeshSessions = partitionSessionHostRecords(Array.isArray(sessionHostRecords) ? sessionHostRecords : []).liveRuntimes;
|
|
46862
46987
|
const workspace = readLiveMeshNodeWorkspace({
|
|
46863
46988
|
meshId,
|
|
46864
|
-
nodeId: String(coordinatorNode
|
|
46989
|
+
nodeId: String(normalizeMeshNodeId(coordinatorNode) || preferredCoordinatorNodeId || ""),
|
|
46865
46990
|
liveSessionRecords: liveMeshSessions,
|
|
46866
46991
|
allowCoordinatorSession: true
|
|
46867
46992
|
}) || (typeof coordinatorNode.workspace === "string" ? coordinatorNode.workspace.trim() : "");
|
|
46868
46993
|
if (!workspace) return { success: false, error: "Coordinator node workspace required", meshId, cliType };
|
|
46869
46994
|
if (!cliType) {
|
|
46870
46995
|
const resolved = await resolveProviderTypeFromPriority({
|
|
46871
|
-
nodeId: String(coordinatorNode
|
|
46996
|
+
nodeId: String(normalizeMeshNodeId(coordinatorNode) || preferredCoordinatorNodeId || "coordinator"),
|
|
46872
46997
|
providerPriority: readProviderPriorityFromPolicy(coordinatorNode.policy),
|
|
46873
46998
|
providerLoader: this.deps.providerLoader,
|
|
46874
46999
|
onStatusChange: this.deps.onStatusChange
|
|
@@ -47322,7 +47447,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
47322
47447
|
const passivePeerTruthNotAttempted = requireDirectPeerTruth && !refreshRequested && directTruth.directEvidenceCount > 0 && directTruth.peerAttemptedCount === 0;
|
|
47323
47448
|
const effectiveDirectTruth = passivePeerTruthNotAttempted ? { ...directTruth, unavailableNodeIds: [] } : directTruth;
|
|
47324
47449
|
const unavailableDirectTruthNodeIds = new Set(effectiveDirectTruth.unavailableNodeIds);
|
|
47325
|
-
const unavailableNodesAreOnlyRemovedWorktrees = unavailableDirectTruthNodeIds.size > 0 && Array.isArray(mesh.nodes) && mesh.nodes.filter((node) => unavailableDirectTruthNodeIds.has(
|
|
47450
|
+
const unavailableNodesAreOnlyRemovedWorktrees = unavailableDirectTruthNodeIds.size > 0 && Array.isArray(mesh.nodes) && mesh.nodes.filter((node) => unavailableDirectTruthNodeIds.has(normalizeMeshNodeId(node) ?? "")).every((node) => node?.isLocalWorktree === true);
|
|
47326
47451
|
const directTruthSatisfied = !requireDirectPeerTruth || effectiveDirectTruth.directEvidenceCount > 0 && (effectiveDirectTruth.unavailableNodeIds.length === 0 || unavailableNodesAreOnlyRemovedWorktrees);
|
|
47327
47452
|
if (requireDirectPeerTruth && !directTruthSatisfied) {
|
|
47328
47453
|
const failureResult = {
|
|
@@ -47357,14 +47482,13 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
47357
47482
|
const coordinatorHostname = (0, import_os3.hostname)();
|
|
47358
47483
|
const selectedCoordinatorNodeId = readStringValue(
|
|
47359
47484
|
mesh.coordinator?.preferredNodeId,
|
|
47360
|
-
mesh.nodes?.[0]
|
|
47361
|
-
mesh.nodes?.[0]?.nodeId
|
|
47485
|
+
normalizeMeshNodeId(mesh.nodes?.[0])
|
|
47362
47486
|
);
|
|
47363
47487
|
const inlineCoordinatorNodeId = meshRecord?.inline && Array.isArray(mesh.nodes) ? selectedCoordinatorNodeId : void 0;
|
|
47364
47488
|
const refreshedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
47365
47489
|
const nodeStatuses = [];
|
|
47366
47490
|
for (const [nodeIndex, node] of (mesh.nodes || []).entries()) {
|
|
47367
|
-
const nodeId =
|
|
47491
|
+
const nodeId = normalizeMeshNodeId(node) ?? "";
|
|
47368
47492
|
const daemonId = readStringValue(node.daemonId);
|
|
47369
47493
|
const nodeMachineId = readMeshNodeMachineId(node);
|
|
47370
47494
|
const nodeHostname = readMeshNodeHostname(node);
|