@adhdev/daemon-core 0.9.82-rc.291 → 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.mjs
CHANGED
|
@@ -270,10 +270,10 @@ function readInjected(value) {
|
|
|
270
270
|
}
|
|
271
271
|
function getDaemonBuildInfo() {
|
|
272
272
|
if (cached) return cached;
|
|
273
|
-
const commit = readInjected(true ? "
|
|
274
|
-
const commitShort = readInjected(true ? "
|
|
275
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
276
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
273
|
+
const commit = readInjected(true ? "7b5b620e2df42c7c3beb8a2983e3cc076c25f832" : void 0) ?? "unknown";
|
|
274
|
+
const commitShort = readInjected(true ? "7b5b620e" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
275
|
+
const version = readInjected(true ? "0.9.82-rc.292" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
276
|
+
const builtAt = readInjected(true ? "2026-06-16T09:16:23.646Z" : void 0);
|
|
277
277
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
278
278
|
return cached;
|
|
279
279
|
}
|
|
@@ -6178,11 +6178,225 @@ var init_mesh_fast_forward = __esm({
|
|
|
6178
6178
|
}
|
|
6179
6179
|
});
|
|
6180
6180
|
|
|
6181
|
+
// ../mesh-shared/dist/index.mjs
|
|
6182
|
+
function readRecord3(value) {
|
|
6183
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
6184
|
+
}
|
|
6185
|
+
function readString5(...values) {
|
|
6186
|
+
for (const value of values) {
|
|
6187
|
+
if (typeof value !== "string") continue;
|
|
6188
|
+
const trimmed = value.trim();
|
|
6189
|
+
if (trimmed) return trimmed;
|
|
6190
|
+
}
|
|
6191
|
+
return void 0;
|
|
6192
|
+
}
|
|
6193
|
+
function readNumber(...values) {
|
|
6194
|
+
for (const value of values) {
|
|
6195
|
+
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
6196
|
+
}
|
|
6197
|
+
return void 0;
|
|
6198
|
+
}
|
|
6199
|
+
function readBoolean(...values) {
|
|
6200
|
+
for (const value of values) {
|
|
6201
|
+
if (typeof value === "boolean") return value;
|
|
6202
|
+
}
|
|
6203
|
+
return void 0;
|
|
6204
|
+
}
|
|
6205
|
+
function joinRepoPath(root, relativePath) {
|
|
6206
|
+
const normalizedRoot = typeof root === "string" ? root.trim().replace(/[\\/]+$/, "") : "";
|
|
6207
|
+
const normalizedPath = typeof relativePath === "string" ? relativePath.trim() : "";
|
|
6208
|
+
if (!normalizedPath) return void 0;
|
|
6209
|
+
if (/^(?:[A-Za-z]:[\\/]|\/)/.test(normalizedPath)) return normalizedPath;
|
|
6210
|
+
if (!normalizedRoot) return void 0;
|
|
6211
|
+
return `${normalizedRoot}/${normalizedPath.replace(/^[\\/]+/, "")}`;
|
|
6212
|
+
}
|
|
6213
|
+
function scoreGitUpstreamFreshness(status) {
|
|
6214
|
+
switch (status) {
|
|
6215
|
+
case "fresh":
|
|
6216
|
+
return 30;
|
|
6217
|
+
case "no_upstream":
|
|
6218
|
+
return 4;
|
|
6219
|
+
case "unchecked":
|
|
6220
|
+
case void 0:
|
|
6221
|
+
return 0;
|
|
6222
|
+
case "stale":
|
|
6223
|
+
return -10;
|
|
6224
|
+
case "unavailable":
|
|
6225
|
+
return -15;
|
|
6226
|
+
default:
|
|
6227
|
+
return 0;
|
|
6228
|
+
}
|
|
6229
|
+
}
|
|
6230
|
+
function readGitSubmodules(value, parentRepoRoot) {
|
|
6231
|
+
if (!Array.isArray(value)) return void 0;
|
|
6232
|
+
const submodules = value.map((entry) => {
|
|
6233
|
+
const submodule = readRecord3(entry);
|
|
6234
|
+
const path40 = readString5(submodule.path);
|
|
6235
|
+
const commit = readString5(submodule.commit);
|
|
6236
|
+
const repoPath = readString5(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path40);
|
|
6237
|
+
if (!path40 || !commit) return null;
|
|
6238
|
+
const result = {
|
|
6239
|
+
path: path40,
|
|
6240
|
+
commit,
|
|
6241
|
+
dirty: readBoolean(submodule.dirty) ?? false,
|
|
6242
|
+
outOfSync: readBoolean(submodule.outOfSync, submodule.out_of_sync) ?? false,
|
|
6243
|
+
lastCheckedAt: readNumber(submodule.lastCheckedAt, submodule.last_checked_at) ?? Date.now()
|
|
6244
|
+
};
|
|
6245
|
+
if (repoPath) result.repoPath = repoPath;
|
|
6246
|
+
const error = readString5(submodule.error);
|
|
6247
|
+
if (error) result.error = error;
|
|
6248
|
+
return result;
|
|
6249
|
+
}).filter((entry) => entry !== null);
|
|
6250
|
+
return submodules.length > 0 ? submodules : void 0;
|
|
6251
|
+
}
|
|
6252
|
+
function hasGitStatusEvidence(status) {
|
|
6253
|
+
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(
|
|
6254
|
+
status.ahead,
|
|
6255
|
+
status.behind,
|
|
6256
|
+
status.staged,
|
|
6257
|
+
status.modified,
|
|
6258
|
+
status.untracked,
|
|
6259
|
+
status.deleted,
|
|
6260
|
+
status.renamed,
|
|
6261
|
+
status.lastCheckedAt,
|
|
6262
|
+
status.last_checked_at
|
|
6263
|
+
) !== void 0 || Array.isArray(status.submodules) && status.submodules.length > 0;
|
|
6264
|
+
}
|
|
6265
|
+
function normalizeGitStatus(status, node, options) {
|
|
6266
|
+
const explicitIsGitRepo = readBoolean(status.isGitRepo);
|
|
6267
|
+
if (!Object.keys(status).length || !hasGitStatusEvidence(status)) return void 0;
|
|
6268
|
+
const isGitRepo = explicitIsGitRepo ?? true;
|
|
6269
|
+
const conflictFiles = Array.isArray(status.conflictFiles) ? status.conflictFiles.filter((entry) => typeof entry === "string") : [];
|
|
6270
|
+
const conflictCount = readNumber(status.conflicts) ?? conflictFiles.length;
|
|
6271
|
+
const hasConflicts = readBoolean(status.hasConflicts) ?? conflictCount > 0;
|
|
6272
|
+
const repoRoot = readString5(status.repoRoot, status.repo_root, node.repoRoot, node.repo_root, status.workspace, node.workspace) || void 0;
|
|
6273
|
+
const submodules = readGitSubmodules(status.submodules, repoRoot);
|
|
6274
|
+
const upstreamStatus = readString5(status.upstreamStatus, status.upstream_status);
|
|
6275
|
+
const upstreamFetchedAt = readNumber(status.upstreamFetchedAt, status.upstream_fetched_at);
|
|
6276
|
+
const upstreamFetchError = readString5(status.upstreamFetchError, status.upstream_fetch_error);
|
|
6277
|
+
const error = readString5(status.error);
|
|
6278
|
+
const staged = readNumber(status.staged) ?? 0;
|
|
6279
|
+
const modified = readNumber(status.modified) ?? 0;
|
|
6280
|
+
const untracked = readNumber(status.untracked) ?? 0;
|
|
6281
|
+
const deleted = readNumber(status.deleted) ?? 0;
|
|
6282
|
+
const renamed = readNumber(status.renamed) ?? 0;
|
|
6283
|
+
return {
|
|
6284
|
+
workspace: readString5(status.workspace, node.workspace) || "",
|
|
6285
|
+
repoRoot: repoRoot ?? null,
|
|
6286
|
+
isGitRepo,
|
|
6287
|
+
branch: readString5(status.branch) ?? null,
|
|
6288
|
+
headCommit: readString5(status.headCommit) ?? null,
|
|
6289
|
+
headMessage: readString5(status.headMessage) ?? null,
|
|
6290
|
+
upstream: readString5(status.upstream) ?? null,
|
|
6291
|
+
upstreamStatus: upstreamStatus ?? "unchecked",
|
|
6292
|
+
...upstreamFetchedAt !== void 0 ? { upstreamFetchedAt } : {},
|
|
6293
|
+
...upstreamFetchError ? { upstreamFetchError } : {},
|
|
6294
|
+
ahead: readNumber(status.ahead) ?? 0,
|
|
6295
|
+
behind: readNumber(status.behind) ?? 0,
|
|
6296
|
+
staged,
|
|
6297
|
+
modified,
|
|
6298
|
+
untracked,
|
|
6299
|
+
deleted,
|
|
6300
|
+
renamed,
|
|
6301
|
+
dirty: readBoolean(status.dirty, status.isDirty, status.is_dirty) ?? (staged + modified + untracked + deleted + renamed > 0 || hasConflicts),
|
|
6302
|
+
hasConflicts,
|
|
6303
|
+
conflictFiles,
|
|
6304
|
+
stashCount: readNumber(status.stashCount, status.stash_count) ?? 0,
|
|
6305
|
+
lastCheckedAt: options?.lastCheckedAt ?? readNumber(status.lastCheckedAt, status.last_checked_at) ?? Date.now(),
|
|
6306
|
+
...submodules ? { submodules } : {},
|
|
6307
|
+
...error ? { error } : {}
|
|
6308
|
+
};
|
|
6309
|
+
}
|
|
6310
|
+
function scoreGitStatusCandidate(git) {
|
|
6311
|
+
if (!git) return Number.NEGATIVE_INFINITY;
|
|
6312
|
+
let score = 0;
|
|
6313
|
+
if (git.isGitRepo === true) score += 50;
|
|
6314
|
+
if (git.isGitRepo === false) score -= 10;
|
|
6315
|
+
if (git.branch) score += 20;
|
|
6316
|
+
if (git.headCommit) score += 20;
|
|
6317
|
+
if (git.upstream) score += 10;
|
|
6318
|
+
score += scoreGitUpstreamFreshness(git.upstreamStatus);
|
|
6319
|
+
if (typeof git.ahead === "number") score += 2;
|
|
6320
|
+
if (typeof git.behind === "number") score += 2;
|
|
6321
|
+
if (Array.isArray(git.submodules) && git.submodules.length > 0) score += 4 + git.submodules.length;
|
|
6322
|
+
if (git.error) score -= 20;
|
|
6323
|
+
return score;
|
|
6324
|
+
}
|
|
6325
|
+
function pickBestTransitGitStatus(node, options) {
|
|
6326
|
+
const rawGit = readRecord3(node.lastGit ?? node.last_git);
|
|
6327
|
+
const gitResult = readRecord3(rawGit.result);
|
|
6328
|
+
const directStatus = readRecord3(rawGit.status);
|
|
6329
|
+
const nestedStatus = readRecord3(gitResult.status);
|
|
6330
|
+
const rawProbe = readRecord3(node.lastProbe ?? node.last_probe);
|
|
6331
|
+
const probeGit = readRecord3(rawProbe.git);
|
|
6332
|
+
const probeGitResult = readRecord3(probeGit.result);
|
|
6333
|
+
const probeDirectStatus = readRecord3(probeGit.status);
|
|
6334
|
+
const probeNestedStatus = readRecord3(probeGitResult.status);
|
|
6335
|
+
const lastCheckedAt = options?.lastCheckedAt;
|
|
6336
|
+
let best = null;
|
|
6337
|
+
for (const status of [directStatus, nestedStatus, probeDirectStatus, probeNestedStatus]) {
|
|
6338
|
+
const normalized = normalizeGitStatus(status, node, { lastCheckedAt: lastCheckedAt ?? Date.now() });
|
|
6339
|
+
if (!normalized) continue;
|
|
6340
|
+
const score = scoreGitStatusCandidate(normalized);
|
|
6341
|
+
if (!best || score > best.score) best = { git: normalized, score };
|
|
6342
|
+
}
|
|
6343
|
+
return best?.git;
|
|
6344
|
+
}
|
|
6345
|
+
function normalizeMeshNodeId(node) {
|
|
6346
|
+
const record = node && typeof node === "object" ? node : {};
|
|
6347
|
+
return readString5(record.id, record.nodeId, record.node_id);
|
|
6348
|
+
}
|
|
6349
|
+
function meshNodeIdMatches(node, candidateId) {
|
|
6350
|
+
if (!candidateId) return false;
|
|
6351
|
+
const trimmed = candidateId.trim();
|
|
6352
|
+
if (!trimmed) return false;
|
|
6353
|
+
return normalizeMeshNodeId(node) === trimmed;
|
|
6354
|
+
}
|
|
6355
|
+
function summarizeGitShape(status) {
|
|
6356
|
+
const record = readRecord3(status);
|
|
6357
|
+
if (!Object.keys(record).length) return null;
|
|
6358
|
+
const submodules = Array.isArray(record.submodules) ? record.submodules.map((entry) => {
|
|
6359
|
+
const sub = readRecord3(entry);
|
|
6360
|
+
return {
|
|
6361
|
+
path: readString5(sub.path) ?? null,
|
|
6362
|
+
commit: readString5(sub.commit)?.slice(0, 12) ?? null,
|
|
6363
|
+
dirty: readBoolean(sub.dirty) ?? false,
|
|
6364
|
+
outOfSync: readBoolean(sub.outOfSync, sub.out_of_sync) ?? false
|
|
6365
|
+
};
|
|
6366
|
+
}) : [];
|
|
6367
|
+
return {
|
|
6368
|
+
isGitRepo: readBoolean(record.isGitRepo),
|
|
6369
|
+
workspace: readString5(record.workspace) ?? null,
|
|
6370
|
+
repoRoot: readString5(record.repoRoot, record.repo_root) ?? null,
|
|
6371
|
+
branch: readString5(record.branch) ?? null,
|
|
6372
|
+
upstream: readString5(record.upstream) ?? null,
|
|
6373
|
+
upstreamStatus: readString5(record.upstreamStatus, record.upstream_status) ?? null,
|
|
6374
|
+
headCommit: readString5(record.headCommit, record.head_commit)?.slice(0, 12) ?? null,
|
|
6375
|
+
ahead: readNumber(record.ahead) ?? null,
|
|
6376
|
+
behind: readNumber(record.behind) ?? null,
|
|
6377
|
+
dirtyCounts: {
|
|
6378
|
+
staged: readNumber(record.staged) ?? 0,
|
|
6379
|
+
modified: readNumber(record.modified) ?? 0,
|
|
6380
|
+
untracked: readNumber(record.untracked) ?? 0,
|
|
6381
|
+
deleted: readNumber(record.deleted) ?? 0,
|
|
6382
|
+
renamed: readNumber(record.renamed) ?? 0
|
|
6383
|
+
},
|
|
6384
|
+
lastCheckedAt: readNumber(record.lastCheckedAt, record.last_checked_at) ?? null,
|
|
6385
|
+
submoduleCount: submodules.length,
|
|
6386
|
+
submodules
|
|
6387
|
+
};
|
|
6388
|
+
}
|
|
6389
|
+
var init_dist = __esm({
|
|
6390
|
+
"../mesh-shared/dist/index.mjs"() {
|
|
6391
|
+
"use strict";
|
|
6392
|
+
}
|
|
6393
|
+
});
|
|
6394
|
+
|
|
6181
6395
|
// src/mesh/mesh-events-utils.ts
|
|
6182
6396
|
function readNonEmptyString2(value) {
|
|
6183
6397
|
return typeof value === "string" && value.trim() ? value.trim() : "";
|
|
6184
6398
|
}
|
|
6185
|
-
function
|
|
6399
|
+
function readRecord4(value) {
|
|
6186
6400
|
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
6187
6401
|
}
|
|
6188
6402
|
function buildMeshWorkerRelayStamp(currentSettings, meshContext) {
|
|
@@ -6206,13 +6420,13 @@ function resolveEventSessionId(event, fallback) {
|
|
|
6206
6420
|
return readNonEmptyString2(event.targetSessionId) || readNonEmptyString2(event.sessionId) || readNonEmptyString2(event.instanceId) || readNonEmptyString2(fallback);
|
|
6207
6421
|
}
|
|
6208
6422
|
function readRefineJobId(event) {
|
|
6209
|
-
const metadata =
|
|
6210
|
-
const result =
|
|
6211
|
-
const refineJob =
|
|
6423
|
+
const metadata = readRecord4(event.metadataEvent) || event;
|
|
6424
|
+
const result = readRecord4(metadata.result);
|
|
6425
|
+
const refineJob = readRecord4(result?.refineJob);
|
|
6212
6426
|
return readNonEmptyString2(metadata.jobId) || readNonEmptyString2(refineJob?.jobId);
|
|
6213
6427
|
}
|
|
6214
6428
|
function readWorkerResultMetadata(event) {
|
|
6215
|
-
return
|
|
6429
|
+
return readRecord4(event.workerResult) || readRecord4(event.meshWorkerResult) || readRecord4(event.structuredResult);
|
|
6216
6430
|
}
|
|
6217
6431
|
function formatCompletionMetadata(event) {
|
|
6218
6432
|
const completionDiagnostic = event.completionDiagnostic && typeof event.completionDiagnostic === "object" ? event.completionDiagnostic : null;
|
|
@@ -6290,10 +6504,10 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
6290
6504
|
}
|
|
6291
6505
|
if (args.event === "refine:completed") {
|
|
6292
6506
|
const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
|
|
6293
|
-
const result =
|
|
6294
|
-
const validationSummary =
|
|
6295
|
-
const patchEquivalence =
|
|
6296
|
-
const finalConvergence =
|
|
6507
|
+
const result = readRecord4(args.metadataEvent.result);
|
|
6508
|
+
const validationSummary = readRecord4(result?.validationSummary);
|
|
6509
|
+
const patchEquivalence = readRecord4(result?.patchEquivalence);
|
|
6510
|
+
const finalConvergence = readRecord4(result?.finalBranchConvergenceState);
|
|
6297
6511
|
const validationStatus = readNonEmptyString2(validationSummary?.status);
|
|
6298
6512
|
const patchStatus = readNonEmptyString2(patchEquivalence?.status) || (patchEquivalence?.equivalent === true ? "passed" : "");
|
|
6299
6513
|
const into = readNonEmptyString2(result?.into);
|
|
@@ -6314,10 +6528,10 @@ Next step: ${nextStep}`;
|
|
|
6314
6528
|
}
|
|
6315
6529
|
if (args.event === "refine:failed") {
|
|
6316
6530
|
const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
|
|
6317
|
-
const result =
|
|
6318
|
-
const validationSummary =
|
|
6319
|
-
const patchEquivalence =
|
|
6320
|
-
const finalConvergence =
|
|
6531
|
+
const result = readRecord4(args.metadataEvent.result);
|
|
6532
|
+
const validationSummary = readRecord4(result?.validationSummary);
|
|
6533
|
+
const patchEquivalence = readRecord4(result?.patchEquivalence);
|
|
6534
|
+
const finalConvergence = readRecord4(result?.finalBranchConvergenceState);
|
|
6321
6535
|
const code = readNonEmptyString2(result?.code);
|
|
6322
6536
|
const error = readNonEmptyString2(result?.error);
|
|
6323
6537
|
const validationStatus = readNonEmptyString2(validationSummary?.status);
|
|
@@ -6367,9 +6581,9 @@ function normalizeCoordinatorDaemonIds(coordinatorDaemonId) {
|
|
|
6367
6581
|
return out;
|
|
6368
6582
|
}
|
|
6369
6583
|
function readRefineJobId2(event) {
|
|
6370
|
-
const metadata =
|
|
6371
|
-
const result =
|
|
6372
|
-
const refineJob =
|
|
6584
|
+
const metadata = readRecord4(event.metadataEvent) || event;
|
|
6585
|
+
const result = readRecord4(metadata.result);
|
|
6586
|
+
const refineJob = readRecord4(result?.refineJob);
|
|
6373
6587
|
return readNonEmptyString2(metadata.jobId) || readNonEmptyString2(refineJob?.jobId);
|
|
6374
6588
|
}
|
|
6375
6589
|
function hasPendingRefineTerminalEventDuplicate(event) {
|
|
@@ -6381,13 +6595,13 @@ function hasPendingRefineTerminalEventDuplicate(event) {
|
|
|
6381
6595
|
);
|
|
6382
6596
|
}
|
|
6383
6597
|
function buildPendingEventFingerprint(event) {
|
|
6384
|
-
const metadata =
|
|
6598
|
+
const metadata = readRecord4(event.metadataEvent) || {};
|
|
6385
6599
|
if (event.event === "worktree_bootstrap_complete" || event.event === "worktree_bootstrap_failed") {
|
|
6386
6600
|
return [event.meshId, event.event, event.nodeId || ""].join("::");
|
|
6387
6601
|
}
|
|
6388
6602
|
const sessionId = resolveEventSessionId(metadata);
|
|
6389
6603
|
const providerSessionId = readNonEmptyString2(metadata.providerSessionId);
|
|
6390
|
-
const taskId = readNonEmptyString2(metadata.taskId) || readNonEmptyString2(
|
|
6604
|
+
const taskId = readNonEmptyString2(metadata.taskId) || readNonEmptyString2(readRecord4(metadata.payload)?.taskId);
|
|
6391
6605
|
const jobId = readRefineJobId2(event);
|
|
6392
6606
|
const timestamp = metadata.timestamp !== void 0 && metadata.timestamp !== null ? String(metadata.timestamp) : "";
|
|
6393
6607
|
return [
|
|
@@ -6455,15 +6669,15 @@ function refineTerminalEventFromLedger(meshId, pending) {
|
|
|
6455
6669
|
for (let i = entries.length - 1; i >= 0; i--) {
|
|
6456
6670
|
const entry = entries[i];
|
|
6457
6671
|
if (entry.kind !== "task_completed" && entry.kind !== "task_failed") continue;
|
|
6458
|
-
const payload =
|
|
6672
|
+
const payload = readRecord4(entry.payload);
|
|
6459
6673
|
if (payload?.source !== "refine_mesh_node_async_job") continue;
|
|
6460
|
-
const refineJob =
|
|
6674
|
+
const refineJob = readRecord4(payload.refineJob);
|
|
6461
6675
|
const jobId = readNonEmptyString2(refineJob?.jobId);
|
|
6462
6676
|
if (!jobId || !acceptedJobIds.has(jobId)) continue;
|
|
6463
6677
|
const eventName = entry.kind === "task_completed" ? "refine:completed" : "refine:failed";
|
|
6464
6678
|
if (existingTerminalJobIds.has(`${eventName}:${jobId}`)) continue;
|
|
6465
6679
|
existingTerminalJobIds.add(`${eventName}:${jobId}`);
|
|
6466
|
-
const result =
|
|
6680
|
+
const result = readRecord4(payload.result);
|
|
6467
6681
|
const metadataEvent = {
|
|
6468
6682
|
source: "refine_mesh_node_async_job",
|
|
6469
6683
|
jobId,
|
|
@@ -7068,7 +7282,7 @@ function buildLongGeneratingCompletionReconciliation(args) {
|
|
|
7068
7282
|
const providerType = readNonEmptyString2(args.metadataEvent.providerType);
|
|
7069
7283
|
const providerSessionId = readNonEmptyString2(args.metadataEvent.providerSessionId);
|
|
7070
7284
|
const workerResult = readWorkerResultMetadata(args.metadataEvent);
|
|
7071
|
-
const completionDiagnostic =
|
|
7285
|
+
const completionDiagnostic = readRecord4(args.metadataEvent.completionDiagnostic);
|
|
7072
7286
|
const finalSummary = readNonEmptyString2(args.metadataEvent.finalSummary);
|
|
7073
7287
|
const status = readNonEmptyString2(args.metadataEvent.status).toLowerCase();
|
|
7074
7288
|
const explicitCompletionEvidence = Boolean(
|
|
@@ -7788,7 +8002,7 @@ async function resolveUsableProvider(components, nodeId, node, requiredTags) {
|
|
|
7788
8002
|
return { reason: `provider_priority_unusable: ${failed.join("; ") || nodeId}` };
|
|
7789
8003
|
}
|
|
7790
8004
|
function readMeshNodeId(node) {
|
|
7791
|
-
return
|
|
8005
|
+
return normalizeMeshNodeId(node) ?? "";
|
|
7792
8006
|
}
|
|
7793
8007
|
async function maybeAutoLaunchOneQueueSession(components, meshId, mesh) {
|
|
7794
8008
|
const queue = getQueue(meshId);
|
|
@@ -8017,7 +8231,7 @@ async function triggerMeshQueue(components, meshId) {
|
|
|
8017
8231
|
}
|
|
8018
8232
|
async function maybeAutoFastForwardIdleNode(components, args) {
|
|
8019
8233
|
const mesh = getMeshWithCache(components, args.meshId);
|
|
8020
|
-
const node = mesh?.nodes?.find((candidate) => candidate
|
|
8234
|
+
const node = mesh?.nodes?.find((candidate) => meshNodeIdMatches(candidate, args.nodeId));
|
|
8021
8235
|
const workspace = readNonEmptyString2(node?.workspace);
|
|
8022
8236
|
if (!workspace) return;
|
|
8023
8237
|
if (!existsSync14(workspace)) return;
|
|
@@ -8605,6 +8819,7 @@ var init_mesh_events_coordinator = __esm({
|
|
|
8605
8819
|
init_mesh_events_pending();
|
|
8606
8820
|
init_mesh_routing();
|
|
8607
8821
|
init_repo_mesh_types();
|
|
8822
|
+
init_dist();
|
|
8608
8823
|
init_mesh_events_stale();
|
|
8609
8824
|
init_mesh_events_utils();
|
|
8610
8825
|
REMOTE_IDLE_SESSION_TTL_MS = 5 * 60 * 1e3;
|
|
@@ -17191,9 +17406,10 @@ function buildMeshLedgerReconciliationEvidence(meshId, replicas) {
|
|
|
17191
17406
|
init_mesh_work_queue();
|
|
17192
17407
|
|
|
17193
17408
|
// src/mesh/mesh-active-work.ts
|
|
17409
|
+
init_dist();
|
|
17194
17410
|
var DIRECT_DISPATCH_VIA = /* @__PURE__ */ new Set(["p2p_direct", "local_direct", "mesh_send_task"]);
|
|
17195
17411
|
var TERMINAL_LEDGER_KINDS = /* @__PURE__ */ new Set(["task_completed", "task_failed", "task_stalled"]);
|
|
17196
|
-
function
|
|
17412
|
+
function readString6(value) {
|
|
17197
17413
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
17198
17414
|
}
|
|
17199
17415
|
function summarizeMessage(message) {
|
|
@@ -17208,7 +17424,7 @@ function elapsedSince(value, now) {
|
|
|
17208
17424
|
function sessionStatusFromNodes(nodes, nodeId, sessionId) {
|
|
17209
17425
|
if (!Array.isArray(nodes)) return {};
|
|
17210
17426
|
if (!nodeId) return { staleReason: "direct task has no node id" };
|
|
17211
|
-
const node = nodes.find((item) =>
|
|
17427
|
+
const node = nodes.find((item) => meshNodeIdMatches(item, nodeId));
|
|
17212
17428
|
if (!node) return { staleReason: "direct task node is no longer in the live mesh" };
|
|
17213
17429
|
if (!sessionId) return {};
|
|
17214
17430
|
const candidates = [];
|
|
@@ -17232,12 +17448,12 @@ function sessionStatusFromNodes(nodes, nodeId, sessionId) {
|
|
|
17232
17448
|
}
|
|
17233
17449
|
const session = candidates.find((item) => {
|
|
17234
17450
|
if (typeof item === "string") return item === sessionId;
|
|
17235
|
-
const id =
|
|
17451
|
+
const id = readString6(item?.id) || readString6(item?.sessionId) || readString6(item?.session_id) || readString6(item?.runtimeSessionId) || readString6(item?.instanceId);
|
|
17236
17452
|
return id === sessionId;
|
|
17237
17453
|
});
|
|
17238
17454
|
if (!session) return { staleReason: "direct task session is not present in live session records" };
|
|
17239
17455
|
if (typeof session === "string") return {};
|
|
17240
|
-
const raw = `${
|
|
17456
|
+
const raw = `${readString6(session.status) || ""} ${readString6(session.lifecycle) || ""} ${readString6(session.state) || ""} ${readString6(session.activeChat?.status) || ""}`.toLowerCase();
|
|
17241
17457
|
if (raw.includes("approval")) return { status: "awaiting_approval" };
|
|
17242
17458
|
if (raw.includes("generating") || raw.includes("running") || raw.includes("busy")) return { status: "generating" };
|
|
17243
17459
|
if (raw.includes("failed") || raw.includes("stopped") || raw.includes("terminated") || raw.includes("exited")) return { status: "failed" };
|
|
@@ -17248,14 +17464,14 @@ function isDirectDispatch(entry) {
|
|
|
17248
17464
|
if (entry.kind !== "task_dispatched") return false;
|
|
17249
17465
|
const payload = entry.payload || {};
|
|
17250
17466
|
if (payload.source === "direct") return true;
|
|
17251
|
-
const via =
|
|
17467
|
+
const via = readString6(payload.via);
|
|
17252
17468
|
return Boolean(via && DIRECT_DISPATCH_VIA.has(via) && payload.source !== "queue");
|
|
17253
17469
|
}
|
|
17254
17470
|
function directDispatchTaskId(entry) {
|
|
17255
|
-
return
|
|
17471
|
+
return readString6(entry.payload?.taskId) || entry.id;
|
|
17256
17472
|
}
|
|
17257
17473
|
function terminalMatchesDispatch(terminal, dispatch, taskId) {
|
|
17258
|
-
const terminalTaskId =
|
|
17474
|
+
const terminalTaskId = readString6(terminal.payload?.taskId);
|
|
17259
17475
|
if (terminalTaskId && terminalTaskId === taskId) return true;
|
|
17260
17476
|
if (terminalTaskId && terminalTaskId !== taskId) return false;
|
|
17261
17477
|
if (dispatch.sessionId && terminal.sessionId === dispatch.sessionId) return true;
|
|
@@ -17378,7 +17594,7 @@ function buildMeshActiveWork(opts) {
|
|
|
17378
17594
|
const isNoTransition = !terminalStatus && !live.status;
|
|
17379
17595
|
const isIdleUnacknowledged = status === "idle";
|
|
17380
17596
|
const ledgerOnlyStaleReason = !terminalRow && (isIdleUnacknowledged || isNoTransition || dispatchedToIdleSession && isIdleUnacknowledged) ? "direct task dispatch has no provider acknowledgement, transcript append, or active runtime transition" : void 0;
|
|
17381
|
-
const message =
|
|
17597
|
+
const message = readString6(dispatch.payload?.message) || readString6(dispatch.payload?.summary) || "";
|
|
17382
17598
|
const { title, summary: summary2 } = summarizeMessage(message);
|
|
17383
17599
|
const isFreshUnacknowledged = Boolean(ledgerOnlyStaleReason && !live.staleReason);
|
|
17384
17600
|
const record = {
|
|
@@ -17387,11 +17603,11 @@ function buildMeshActiveWork(opts) {
|
|
|
17387
17603
|
status,
|
|
17388
17604
|
nodeId: dispatch.nodeId,
|
|
17389
17605
|
sessionId: dispatch.sessionId,
|
|
17390
|
-
providerType: dispatch.providerType ||
|
|
17391
|
-
taskTitle:
|
|
17392
|
-
taskSummary:
|
|
17606
|
+
providerType: dispatch.providerType || readString6(dispatch.payload?.providerType),
|
|
17607
|
+
taskTitle: readString6(dispatch.payload?.taskTitle) || title,
|
|
17608
|
+
taskSummary: readString6(dispatch.payload?.taskSummary) || summary2,
|
|
17393
17609
|
message,
|
|
17394
|
-
taskMode:
|
|
17610
|
+
taskMode: readString6(dispatch.payload?.taskMode),
|
|
17395
17611
|
createdAt: dispatch.timestamp,
|
|
17396
17612
|
updatedAt: terminal?.timestamp || dispatch.timestamp,
|
|
17397
17613
|
dispatchedAt: dispatch.timestamp,
|
|
@@ -17426,7 +17642,7 @@ function buildMeshActiveWork(opts) {
|
|
|
17426
17642
|
const isNoTransition = !terminalStatus && !live.status;
|
|
17427
17643
|
const isIdleUnacknowledged = status === "idle";
|
|
17428
17644
|
const ledgerOnlyStaleReason = !terminalRow && (isIdleUnacknowledged || isNoTransition || dispatchedToIdleSession && isIdleUnacknowledged) ? "direct task dispatch has no provider acknowledgement, transcript append, or active runtime transition" : void 0;
|
|
17429
|
-
const message =
|
|
17645
|
+
const message = readString6(dispatch.payload?.message) || readString6(dispatch.payload?.summary) || "";
|
|
17430
17646
|
const { title, summary: summary2 } = summarizeMessage(message);
|
|
17431
17647
|
const isFreshUnacknowledged = Boolean(ledgerOnlyStaleReason && !live.staleReason);
|
|
17432
17648
|
const record = {
|
|
@@ -17435,11 +17651,11 @@ function buildMeshActiveWork(opts) {
|
|
|
17435
17651
|
status,
|
|
17436
17652
|
nodeId: dispatch.nodeId,
|
|
17437
17653
|
sessionId: dispatch.sessionId,
|
|
17438
|
-
providerType: dispatch.providerType ||
|
|
17439
|
-
taskTitle:
|
|
17440
|
-
taskSummary:
|
|
17654
|
+
providerType: dispatch.providerType || readString6(dispatch.payload?.providerType),
|
|
17655
|
+
taskTitle: readString6(dispatch.payload?.taskTitle) || title,
|
|
17656
|
+
taskSummary: readString6(dispatch.payload?.taskSummary) || summary2,
|
|
17441
17657
|
message,
|
|
17442
|
-
taskMode:
|
|
17658
|
+
taskMode: readString6(dispatch.payload?.taskMode),
|
|
17443
17659
|
createdAt: dispatch.timestamp,
|
|
17444
17660
|
updatedAt: terminal?.timestamp || dispatch.timestamp,
|
|
17445
17661
|
dispatchedAt: dispatch.timestamp,
|
|
@@ -39345,207 +39561,7 @@ function getAvailableIdeIds() {
|
|
|
39345
39561
|
init_config();
|
|
39346
39562
|
init_cli_detector();
|
|
39347
39563
|
init_git_status();
|
|
39348
|
-
|
|
39349
|
-
// ../mesh-shared/dist/index.mjs
|
|
39350
|
-
function readRecord5(value) {
|
|
39351
|
-
return value && typeof value === "object" && !Array.isArray(value) ? value : {};
|
|
39352
|
-
}
|
|
39353
|
-
function readString6(...values) {
|
|
39354
|
-
for (const value of values) {
|
|
39355
|
-
if (typeof value !== "string") continue;
|
|
39356
|
-
const trimmed = value.trim();
|
|
39357
|
-
if (trimmed) return trimmed;
|
|
39358
|
-
}
|
|
39359
|
-
return void 0;
|
|
39360
|
-
}
|
|
39361
|
-
function readNumber(...values) {
|
|
39362
|
-
for (const value of values) {
|
|
39363
|
-
if (typeof value === "number" && Number.isFinite(value)) return value;
|
|
39364
|
-
}
|
|
39365
|
-
return void 0;
|
|
39366
|
-
}
|
|
39367
|
-
function readBoolean(...values) {
|
|
39368
|
-
for (const value of values) {
|
|
39369
|
-
if (typeof value === "boolean") return value;
|
|
39370
|
-
}
|
|
39371
|
-
return void 0;
|
|
39372
|
-
}
|
|
39373
|
-
function joinRepoPath(root, relativePath) {
|
|
39374
|
-
const normalizedRoot = typeof root === "string" ? root.trim().replace(/[\\/]+$/, "") : "";
|
|
39375
|
-
const normalizedPath = typeof relativePath === "string" ? relativePath.trim() : "";
|
|
39376
|
-
if (!normalizedPath) return void 0;
|
|
39377
|
-
if (/^(?:[A-Za-z]:[\\/]|\/)/.test(normalizedPath)) return normalizedPath;
|
|
39378
|
-
if (!normalizedRoot) return void 0;
|
|
39379
|
-
return `${normalizedRoot}/${normalizedPath.replace(/^[\\/]+/, "")}`;
|
|
39380
|
-
}
|
|
39381
|
-
function scoreGitUpstreamFreshness(status) {
|
|
39382
|
-
switch (status) {
|
|
39383
|
-
case "fresh":
|
|
39384
|
-
return 30;
|
|
39385
|
-
case "no_upstream":
|
|
39386
|
-
return 4;
|
|
39387
|
-
case "unchecked":
|
|
39388
|
-
case void 0:
|
|
39389
|
-
return 0;
|
|
39390
|
-
case "stale":
|
|
39391
|
-
return -10;
|
|
39392
|
-
case "unavailable":
|
|
39393
|
-
return -15;
|
|
39394
|
-
default:
|
|
39395
|
-
return 0;
|
|
39396
|
-
}
|
|
39397
|
-
}
|
|
39398
|
-
function readGitSubmodules(value, parentRepoRoot) {
|
|
39399
|
-
if (!Array.isArray(value)) return void 0;
|
|
39400
|
-
const submodules = value.map((entry) => {
|
|
39401
|
-
const submodule = readRecord5(entry);
|
|
39402
|
-
const path40 = readString6(submodule.path);
|
|
39403
|
-
const commit = readString6(submodule.commit);
|
|
39404
|
-
const repoPath = readString6(submodule.repoPath, submodule.repo_root) ?? joinRepoPath(parentRepoRoot, path40);
|
|
39405
|
-
if (!path40 || !commit) return null;
|
|
39406
|
-
const result = {
|
|
39407
|
-
path: path40,
|
|
39408
|
-
commit,
|
|
39409
|
-
dirty: readBoolean(submodule.dirty) ?? false,
|
|
39410
|
-
outOfSync: readBoolean(submodule.outOfSync, submodule.out_of_sync) ?? false,
|
|
39411
|
-
lastCheckedAt: readNumber(submodule.lastCheckedAt, submodule.last_checked_at) ?? Date.now()
|
|
39412
|
-
};
|
|
39413
|
-
if (repoPath) result.repoPath = repoPath;
|
|
39414
|
-
const error = readString6(submodule.error);
|
|
39415
|
-
if (error) result.error = error;
|
|
39416
|
-
return result;
|
|
39417
|
-
}).filter((entry) => entry !== null);
|
|
39418
|
-
return submodules.length > 0 ? submodules : void 0;
|
|
39419
|
-
}
|
|
39420
|
-
function hasGitStatusEvidence(status) {
|
|
39421
|
-
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(
|
|
39422
|
-
status.ahead,
|
|
39423
|
-
status.behind,
|
|
39424
|
-
status.staged,
|
|
39425
|
-
status.modified,
|
|
39426
|
-
status.untracked,
|
|
39427
|
-
status.deleted,
|
|
39428
|
-
status.renamed,
|
|
39429
|
-
status.lastCheckedAt,
|
|
39430
|
-
status.last_checked_at
|
|
39431
|
-
) !== void 0 || Array.isArray(status.submodules) && status.submodules.length > 0;
|
|
39432
|
-
}
|
|
39433
|
-
function normalizeGitStatus(status, node, options) {
|
|
39434
|
-
const explicitIsGitRepo = readBoolean(status.isGitRepo);
|
|
39435
|
-
if (!Object.keys(status).length || !hasGitStatusEvidence(status)) return void 0;
|
|
39436
|
-
const isGitRepo = explicitIsGitRepo ?? true;
|
|
39437
|
-
const conflictFiles = Array.isArray(status.conflictFiles) ? status.conflictFiles.filter((entry) => typeof entry === "string") : [];
|
|
39438
|
-
const conflictCount = readNumber(status.conflicts) ?? conflictFiles.length;
|
|
39439
|
-
const hasConflicts = readBoolean(status.hasConflicts) ?? conflictCount > 0;
|
|
39440
|
-
const repoRoot = readString6(status.repoRoot, status.repo_root, node.repoRoot, node.repo_root, status.workspace, node.workspace) || void 0;
|
|
39441
|
-
const submodules = readGitSubmodules(status.submodules, repoRoot);
|
|
39442
|
-
const upstreamStatus = readString6(status.upstreamStatus, status.upstream_status);
|
|
39443
|
-
const upstreamFetchedAt = readNumber(status.upstreamFetchedAt, status.upstream_fetched_at);
|
|
39444
|
-
const upstreamFetchError = readString6(status.upstreamFetchError, status.upstream_fetch_error);
|
|
39445
|
-
const error = readString6(status.error);
|
|
39446
|
-
const staged = readNumber(status.staged) ?? 0;
|
|
39447
|
-
const modified = readNumber(status.modified) ?? 0;
|
|
39448
|
-
const untracked = readNumber(status.untracked) ?? 0;
|
|
39449
|
-
const deleted = readNumber(status.deleted) ?? 0;
|
|
39450
|
-
const renamed = readNumber(status.renamed) ?? 0;
|
|
39451
|
-
return {
|
|
39452
|
-
workspace: readString6(status.workspace, node.workspace) || "",
|
|
39453
|
-
repoRoot: repoRoot ?? null,
|
|
39454
|
-
isGitRepo,
|
|
39455
|
-
branch: readString6(status.branch) ?? null,
|
|
39456
|
-
headCommit: readString6(status.headCommit) ?? null,
|
|
39457
|
-
headMessage: readString6(status.headMessage) ?? null,
|
|
39458
|
-
upstream: readString6(status.upstream) ?? null,
|
|
39459
|
-
upstreamStatus: upstreamStatus ?? "unchecked",
|
|
39460
|
-
...upstreamFetchedAt !== void 0 ? { upstreamFetchedAt } : {},
|
|
39461
|
-
...upstreamFetchError ? { upstreamFetchError } : {},
|
|
39462
|
-
ahead: readNumber(status.ahead) ?? 0,
|
|
39463
|
-
behind: readNumber(status.behind) ?? 0,
|
|
39464
|
-
staged,
|
|
39465
|
-
modified,
|
|
39466
|
-
untracked,
|
|
39467
|
-
deleted,
|
|
39468
|
-
renamed,
|
|
39469
|
-
dirty: readBoolean(status.dirty, status.isDirty, status.is_dirty) ?? (staged + modified + untracked + deleted + renamed > 0 || hasConflicts),
|
|
39470
|
-
hasConflicts,
|
|
39471
|
-
conflictFiles,
|
|
39472
|
-
stashCount: readNumber(status.stashCount, status.stash_count) ?? 0,
|
|
39473
|
-
lastCheckedAt: options?.lastCheckedAt ?? readNumber(status.lastCheckedAt, status.last_checked_at) ?? Date.now(),
|
|
39474
|
-
...submodules ? { submodules } : {},
|
|
39475
|
-
...error ? { error } : {}
|
|
39476
|
-
};
|
|
39477
|
-
}
|
|
39478
|
-
function scoreGitStatusCandidate(git) {
|
|
39479
|
-
if (!git) return Number.NEGATIVE_INFINITY;
|
|
39480
|
-
let score = 0;
|
|
39481
|
-
if (git.isGitRepo === true) score += 50;
|
|
39482
|
-
if (git.isGitRepo === false) score -= 10;
|
|
39483
|
-
if (git.branch) score += 20;
|
|
39484
|
-
if (git.headCommit) score += 20;
|
|
39485
|
-
if (git.upstream) score += 10;
|
|
39486
|
-
score += scoreGitUpstreamFreshness(git.upstreamStatus);
|
|
39487
|
-
if (typeof git.ahead === "number") score += 2;
|
|
39488
|
-
if (typeof git.behind === "number") score += 2;
|
|
39489
|
-
if (Array.isArray(git.submodules) && git.submodules.length > 0) score += 4 + git.submodules.length;
|
|
39490
|
-
if (git.error) score -= 20;
|
|
39491
|
-
return score;
|
|
39492
|
-
}
|
|
39493
|
-
function pickBestTransitGitStatus(node, options) {
|
|
39494
|
-
const rawGit = readRecord5(node.lastGit ?? node.last_git);
|
|
39495
|
-
const gitResult = readRecord5(rawGit.result);
|
|
39496
|
-
const directStatus = readRecord5(rawGit.status);
|
|
39497
|
-
const nestedStatus = readRecord5(gitResult.status);
|
|
39498
|
-
const rawProbe = readRecord5(node.lastProbe ?? node.last_probe);
|
|
39499
|
-
const probeGit = readRecord5(rawProbe.git);
|
|
39500
|
-
const probeGitResult = readRecord5(probeGit.result);
|
|
39501
|
-
const probeDirectStatus = readRecord5(probeGit.status);
|
|
39502
|
-
const probeNestedStatus = readRecord5(probeGitResult.status);
|
|
39503
|
-
const lastCheckedAt = options?.lastCheckedAt;
|
|
39504
|
-
let best = null;
|
|
39505
|
-
for (const status of [directStatus, nestedStatus, probeDirectStatus, probeNestedStatus]) {
|
|
39506
|
-
const normalized = normalizeGitStatus(status, node, { lastCheckedAt: lastCheckedAt ?? Date.now() });
|
|
39507
|
-
if (!normalized) continue;
|
|
39508
|
-
const score = scoreGitStatusCandidate(normalized);
|
|
39509
|
-
if (!best || score > best.score) best = { git: normalized, score };
|
|
39510
|
-
}
|
|
39511
|
-
return best?.git;
|
|
39512
|
-
}
|
|
39513
|
-
function summarizeGitShape(status) {
|
|
39514
|
-
const record = readRecord5(status);
|
|
39515
|
-
if (!Object.keys(record).length) return null;
|
|
39516
|
-
const submodules = Array.isArray(record.submodules) ? record.submodules.map((entry) => {
|
|
39517
|
-
const sub = readRecord5(entry);
|
|
39518
|
-
return {
|
|
39519
|
-
path: readString6(sub.path) ?? null,
|
|
39520
|
-
commit: readString6(sub.commit)?.slice(0, 12) ?? null,
|
|
39521
|
-
dirty: readBoolean(sub.dirty) ?? false,
|
|
39522
|
-
outOfSync: readBoolean(sub.outOfSync, sub.out_of_sync) ?? false
|
|
39523
|
-
};
|
|
39524
|
-
}) : [];
|
|
39525
|
-
return {
|
|
39526
|
-
isGitRepo: readBoolean(record.isGitRepo),
|
|
39527
|
-
workspace: readString6(record.workspace) ?? null,
|
|
39528
|
-
repoRoot: readString6(record.repoRoot, record.repo_root) ?? null,
|
|
39529
|
-
branch: readString6(record.branch) ?? null,
|
|
39530
|
-
upstream: readString6(record.upstream) ?? null,
|
|
39531
|
-
upstreamStatus: readString6(record.upstreamStatus, record.upstream_status) ?? null,
|
|
39532
|
-
headCommit: readString6(record.headCommit, record.head_commit)?.slice(0, 12) ?? null,
|
|
39533
|
-
ahead: readNumber(record.ahead) ?? null,
|
|
39534
|
-
behind: readNumber(record.behind) ?? null,
|
|
39535
|
-
dirtyCounts: {
|
|
39536
|
-
staged: readNumber(record.staged) ?? 0,
|
|
39537
|
-
modified: readNumber(record.modified) ?? 0,
|
|
39538
|
-
untracked: readNumber(record.untracked) ?? 0,
|
|
39539
|
-
deleted: readNumber(record.deleted) ?? 0,
|
|
39540
|
-
renamed: readNumber(record.renamed) ?? 0
|
|
39541
|
-
},
|
|
39542
|
-
lastCheckedAt: readNumber(record.lastCheckedAt, record.last_checked_at) ?? null,
|
|
39543
|
-
submoduleCount: submodules.length,
|
|
39544
|
-
submodules
|
|
39545
|
-
};
|
|
39546
|
-
}
|
|
39547
|
-
|
|
39548
|
-
// src/commands/router.ts
|
|
39564
|
+
init_dist();
|
|
39549
39565
|
init_logger();
|
|
39550
39566
|
|
|
39551
39567
|
// src/logging/command-log.ts
|
|
@@ -40625,7 +40641,10 @@ function summarizeRepoMeshStatusDebug(status) {
|
|
|
40625
40641
|
branchConvergenceSummary: status?.branchConvergenceSummary ?? status?.branch_convergence_summary ?? null,
|
|
40626
40642
|
nodeCount: nodes.length,
|
|
40627
40643
|
nodes: nodes.map((node) => ({
|
|
40628
|
-
nodeId
|
|
40644
|
+
// Status emits the id under `nodeId` (3-way input absorbed). The
|
|
40645
|
+
// inline cache keeps `id` and `nodeId` equal, so this serialized form
|
|
40646
|
+
// round-trips back through the cache without flipping shape.
|
|
40647
|
+
nodeId: normalizeMeshNodeId(node) ?? null,
|
|
40629
40648
|
daemonId: readStringValue(node?.daemonId, node?.daemon_id) ?? null,
|
|
40630
40649
|
workspace: readStringValue(node?.workspace, node?.git?.workspace) ?? null,
|
|
40631
40650
|
health: readStringValue(node?.health) ?? null,
|
|
@@ -40870,7 +40889,23 @@ function inlineMeshCarriesTransientNodeTruth(inlineMesh) {
|
|
|
40870
40889
|
return inlineMesh.nodes.some((node) => hasInlineMeshTransientNodeState(node));
|
|
40871
40890
|
}
|
|
40872
40891
|
function readInlineMeshNodeId(node) {
|
|
40873
|
-
return
|
|
40892
|
+
return normalizeMeshNodeId(node) ?? "";
|
|
40893
|
+
}
|
|
40894
|
+
function foldMeshNodeIdentityToCanonical(node) {
|
|
40895
|
+
if (!node || typeof node !== "object" || Array.isArray(node)) return node;
|
|
40896
|
+
const canonical = normalizeMeshNodeId(node);
|
|
40897
|
+
if (canonical === void 0) return node;
|
|
40898
|
+
if (node.id === canonical && node.nodeId === canonical && node.node_id === void 0) return node;
|
|
40899
|
+
node.id = canonical;
|
|
40900
|
+
node.nodeId = canonical;
|
|
40901
|
+
if ("node_id" in node) delete node.node_id;
|
|
40902
|
+
return node;
|
|
40903
|
+
}
|
|
40904
|
+
function normalizeInlineMeshNodeIdentity(inlineMesh) {
|
|
40905
|
+
if (!inlineMesh || typeof inlineMesh !== "object" || Array.isArray(inlineMesh)) return inlineMesh;
|
|
40906
|
+
if (!Array.isArray(inlineMesh.nodes) || inlineMesh.nodes.length === 0) return inlineMesh;
|
|
40907
|
+
for (const node of inlineMesh.nodes) foldMeshNodeIdentityToCanonical(node);
|
|
40908
|
+
return inlineMesh;
|
|
40874
40909
|
}
|
|
40875
40910
|
function sanitizeInlineMesh(inlineMesh) {
|
|
40876
40911
|
if (!inlineMesh || typeof inlineMesh !== "object" || Array.isArray(inlineMesh)) return inlineMesh;
|
|
@@ -40972,7 +41007,7 @@ function deriveMeshNodeHealthFromGit(git) {
|
|
|
40972
41007
|
return "online";
|
|
40973
41008
|
}
|
|
40974
41009
|
function readMeshNodeLabel(status, node) {
|
|
40975
|
-
return readStringValue(status.nodeId, node
|
|
41010
|
+
return readStringValue(status.nodeId, normalizeMeshNodeId(node)) ?? "unknown";
|
|
40976
41011
|
}
|
|
40977
41012
|
function buildInlineMeshBranchConvergence(args) {
|
|
40978
41013
|
const git = readObjectRecord(args.status.git);
|
|
@@ -41251,7 +41286,7 @@ async function hydrateInlineMeshDirectTruth(args) {
|
|
|
41251
41286
|
let peerConfirmedCount = 0;
|
|
41252
41287
|
const unavailableNodeIds = [];
|
|
41253
41288
|
for (const [nodeIndex, node] of nodes.entries()) {
|
|
41254
|
-
const nodeId =
|
|
41289
|
+
const nodeId = normalizeMeshNodeId(node) || `node_${nodeIndex}`;
|
|
41255
41290
|
const workspace = readStringValue(node?.workspace);
|
|
41256
41291
|
const daemonId = readStringValue(node?.daemonId);
|
|
41257
41292
|
const isSelfNode = Boolean(
|
|
@@ -41382,7 +41417,7 @@ function buildHistoricalMeshSessions(args) {
|
|
|
41382
41417
|
const liveWorkspaces = /* @__PURE__ */ new Set();
|
|
41383
41418
|
const missingLocalWorktreeNodeIds = /* @__PURE__ */ new Set();
|
|
41384
41419
|
for (const node of args.nodes || []) {
|
|
41385
|
-
const nodeId =
|
|
41420
|
+
const nodeId = normalizeMeshNodeId(node);
|
|
41386
41421
|
const workspace = readStringValue(node?.workspace);
|
|
41387
41422
|
if (nodeId) liveNodeIds.add(nodeId);
|
|
41388
41423
|
if (workspace) liveWorkspaces.add(workspace);
|
|
@@ -41507,9 +41542,13 @@ function resolveRefineryAutoPublishSubmoduleMainCommits(mesh, workspace) {
|
|
|
41507
41542
|
}
|
|
41508
41543
|
return { enabled: false };
|
|
41509
41544
|
}
|
|
41510
|
-
async function computeGitPatchId(cwd, fromRef, toRef) {
|
|
41545
|
+
async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
|
|
41511
41546
|
const { execFileSync: execFileSync6 } = await import("child_process");
|
|
41512
|
-
const
|
|
41547
|
+
const diffArgs = ["diff", "--patch", "--full-index", fromRef, toRef];
|
|
41548
|
+
if (excludePaths.length > 0) {
|
|
41549
|
+
diffArgs.push("--", ".", ...excludePaths.map((path40) => `:(exclude)${path40}`));
|
|
41550
|
+
}
|
|
41551
|
+
const diff = execFileSync6("git", diffArgs, {
|
|
41513
41552
|
cwd,
|
|
41514
41553
|
encoding: "utf8",
|
|
41515
41554
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -41578,8 +41617,9 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
41578
41617
|
gitlinkTrivialFastForward
|
|
41579
41618
|
};
|
|
41580
41619
|
}
|
|
41581
|
-
const
|
|
41582
|
-
const
|
|
41620
|
+
const ffGitlinkExcludePaths = collectFastForwardGitlinkPaths(repoRoot, baseHead, branchHead);
|
|
41621
|
+
const expectedPatchId = await computeGitPatchId(repoRoot, mergeBase, branchHead, ffGitlinkExcludePaths);
|
|
41622
|
+
const actualPatchId = await computeGitPatchId(repoRoot, baseHead, mergedTree, ffGitlinkExcludePaths);
|
|
41583
41623
|
const equivalent = expectedPatchId === actualPatchId;
|
|
41584
41624
|
return {
|
|
41585
41625
|
status: equivalent ? "passed" : "failed",
|
|
@@ -41775,6 +41815,14 @@ function readChangedPathKinds(repoRoot, fromRef, toRef) {
|
|
|
41775
41815
|
return [];
|
|
41776
41816
|
}
|
|
41777
41817
|
}
|
|
41818
|
+
function collectFastForwardGitlinkPaths(repoRoot, baseHead, branchHead) {
|
|
41819
|
+
return readChangedGitlinkPaths(repoRoot, baseHead, branchHead).filter((path40) => {
|
|
41820
|
+
const baseCommit = readTreeObject(repoRoot, baseHead, path40);
|
|
41821
|
+
const branchCommit = readTreeObject(repoRoot, branchHead, path40);
|
|
41822
|
+
if (!baseCommit || !branchCommit) return false;
|
|
41823
|
+
return isSubmoduleFastForward(pathResolve2(repoRoot, path40), baseCommit, branchCommit);
|
|
41824
|
+
});
|
|
41825
|
+
}
|
|
41778
41826
|
function evaluateGitlinkTrivialFastForward(repoRoot, baseHead, branchHead) {
|
|
41779
41827
|
const changedGitlinks = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path40) => {
|
|
41780
41828
|
const baseCommit = readTreeObject(repoRoot, baseHead, path40);
|
|
@@ -41824,20 +41872,95 @@ function evaluateGitlinkTrivialFastForward(repoRoot, baseHead, branchHead) {
|
|
|
41824
41872
|
}
|
|
41825
41873
|
return { trivial: true, gitlinks: changedGitlinks };
|
|
41826
41874
|
}
|
|
41875
|
+
function buildTreeWithGitlinksEqualized(repoRoot, commitish, paths, placeholderCommit) {
|
|
41876
|
+
try {
|
|
41877
|
+
const tree = execFileSync5("git", ["rev-parse", `${commitish}^{tree}`], {
|
|
41878
|
+
cwd: repoRoot,
|
|
41879
|
+
encoding: "utf8",
|
|
41880
|
+
maxBuffer: 1024 * 1024
|
|
41881
|
+
}).trim();
|
|
41882
|
+
if (!tree) return void 0;
|
|
41883
|
+
const updates = paths.map((path40) => `160000 commit ${placeholderCommit} ${path40}`).join("\n");
|
|
41884
|
+
if (!updates) return tree;
|
|
41885
|
+
const tmpIndex = pathJoin(resolveGitDir(repoRoot), `adhdev-refine-eq-${commitish.slice(0, 12)}.index`);
|
|
41886
|
+
const env = { ...process.env, GIT_INDEX_FILE: tmpIndex };
|
|
41887
|
+
try {
|
|
41888
|
+
execFileSync5("git", ["read-tree", tree], { cwd: repoRoot, env, stdio: "ignore" });
|
|
41889
|
+
execFileSync5("git", ["update-index", "--index-info"], {
|
|
41890
|
+
cwd: repoRoot,
|
|
41891
|
+
env,
|
|
41892
|
+
input: `${updates}
|
|
41893
|
+
`,
|
|
41894
|
+
encoding: "utf8",
|
|
41895
|
+
stdio: ["pipe", "ignore", "ignore"]
|
|
41896
|
+
});
|
|
41897
|
+
const newTree = execFileSync5("git", ["write-tree"], { cwd: repoRoot, env, encoding: "utf8" }).trim();
|
|
41898
|
+
return newTree || void 0;
|
|
41899
|
+
} finally {
|
|
41900
|
+
try {
|
|
41901
|
+
fs24.rmSync(tmpIndex, { force: true });
|
|
41902
|
+
} catch {
|
|
41903
|
+
}
|
|
41904
|
+
}
|
|
41905
|
+
} catch {
|
|
41906
|
+
return void 0;
|
|
41907
|
+
}
|
|
41908
|
+
}
|
|
41827
41909
|
function synthesizeTrivialFastForwardMergeTree(repoRoot, baseHead, branchHead, gitlinks) {
|
|
41828
41910
|
try {
|
|
41829
|
-
const
|
|
41911
|
+
const branchGitlinks = gitlinks.filter((entry) => entry.branchCommit);
|
|
41912
|
+
const gitlinkPaths = branchGitlinks.map((entry) => entry.path);
|
|
41913
|
+
const mergeBase = execFileSync5("git", ["merge-base", baseHead, branchHead], {
|
|
41914
|
+
cwd: repoRoot,
|
|
41915
|
+
encoding: "utf8",
|
|
41916
|
+
maxBuffer: 1024 * 1024
|
|
41917
|
+
}).trim();
|
|
41918
|
+
let mergedContentTree;
|
|
41919
|
+
if (mergeBase && gitlinkPaths.length > 0) {
|
|
41920
|
+
const placeholder = readTreeObject(repoRoot, mergeBase, gitlinkPaths[0]) || branchGitlinks[0].branchCommit;
|
|
41921
|
+
const baseEqTree = buildTreeWithGitlinksEqualized(repoRoot, mergeBase, gitlinkPaths, placeholder);
|
|
41922
|
+
const oursEqTree = buildTreeWithGitlinksEqualized(repoRoot, baseHead, gitlinkPaths, placeholder);
|
|
41923
|
+
const theirsEqTree = buildTreeWithGitlinksEqualized(repoRoot, branchHead, gitlinkPaths, placeholder);
|
|
41924
|
+
if (baseEqTree && oursEqTree && theirsEqTree) {
|
|
41925
|
+
try {
|
|
41926
|
+
const baseEqCommit = execFileSync5("git", ["commit-tree", baseEqTree, "-m", "refine-ff-base"], {
|
|
41927
|
+
cwd: repoRoot,
|
|
41928
|
+
encoding: "utf8",
|
|
41929
|
+
maxBuffer: 1024 * 1024
|
|
41930
|
+
}).trim();
|
|
41931
|
+
const oursEqCommit = execFileSync5("git", ["commit-tree", oursEqTree, "-p", baseEqCommit, "-m", "refine-ff-ours"], {
|
|
41932
|
+
cwd: repoRoot,
|
|
41933
|
+
encoding: "utf8",
|
|
41934
|
+
maxBuffer: 1024 * 1024
|
|
41935
|
+
}).trim();
|
|
41936
|
+
const theirsEqCommit = execFileSync5("git", ["commit-tree", theirsEqTree, "-p", baseEqCommit, "-m", "refine-ff-theirs"], {
|
|
41937
|
+
cwd: repoRoot,
|
|
41938
|
+
encoding: "utf8",
|
|
41939
|
+
maxBuffer: 1024 * 1024
|
|
41940
|
+
}).trim();
|
|
41941
|
+
const mergeOut = execFileSync5("git", ["merge-tree", "--write-tree", oursEqCommit, theirsEqCommit], {
|
|
41942
|
+
cwd: repoRoot,
|
|
41943
|
+
encoding: "utf8",
|
|
41944
|
+
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
41945
|
+
}).trim();
|
|
41946
|
+
mergedContentTree = mergeOut.split(/\s+/)[0] || void 0;
|
|
41947
|
+
} catch {
|
|
41948
|
+
mergedContentTree = void 0;
|
|
41949
|
+
}
|
|
41950
|
+
}
|
|
41951
|
+
}
|
|
41952
|
+
const contentTree = mergedContentTree || execFileSync5("git", ["rev-parse", `${baseHead}^{tree}`], {
|
|
41830
41953
|
cwd: repoRoot,
|
|
41831
41954
|
encoding: "utf8",
|
|
41832
41955
|
maxBuffer: 1024 * 1024
|
|
41833
41956
|
}).trim();
|
|
41834
|
-
if (!
|
|
41835
|
-
const updates =
|
|
41836
|
-
if (!updates) return
|
|
41957
|
+
if (!contentTree) return void 0;
|
|
41958
|
+
const updates = branchGitlinks.map((entry) => `160000 commit ${entry.branchCommit} ${entry.path}`).join("\n");
|
|
41959
|
+
if (!updates) return contentTree;
|
|
41837
41960
|
const tmpIndex = pathJoin(resolveGitDir(repoRoot), `adhdev-refine-ff-${baseHead.slice(0, 12)}-${branchHead.slice(0, 12)}.index`);
|
|
41838
41961
|
const env = { ...process.env, GIT_INDEX_FILE: tmpIndex };
|
|
41839
41962
|
try {
|
|
41840
|
-
execFileSync5("git", ["read-tree",
|
|
41963
|
+
execFileSync5("git", ["read-tree", contentTree], { cwd: repoRoot, env, stdio: "ignore" });
|
|
41841
41964
|
execFileSync5("git", ["update-index", "--index-info"], {
|
|
41842
41965
|
cwd: repoRoot,
|
|
41843
41966
|
env,
|
|
@@ -42497,7 +42620,7 @@ function normalizeStandaloneHostCommandUrl(hostAddress) {
|
|
|
42497
42620
|
function buildMemberJoinNode(mesh, args, fallbackDaemonId) {
|
|
42498
42621
|
const requestedNodeId = typeof args?.memberNodeId === "string" ? args.memberNodeId.trim() : "";
|
|
42499
42622
|
const explicit = args?.memberNode && typeof args.memberNode === "object" && !Array.isArray(args.memberNode) ? args.memberNode : null;
|
|
42500
|
-
const configured = Array.isArray(mesh?.nodes) ? requestedNodeId ? mesh.nodes.find((node) => node
|
|
42623
|
+
const configured = Array.isArray(mesh?.nodes) ? requestedNodeId ? mesh.nodes.find((node) => meshNodeIdMatches(node, requestedNodeId)) : mesh.nodes[0] : null;
|
|
42501
42624
|
const source = explicit || configured;
|
|
42502
42625
|
const workspace = typeof source?.workspace === "string" && source.workspace.trim() ? source.workspace.trim() : typeof args?.workspace === "string" && args.workspace.trim() ? args.workspace.trim() : process.cwd();
|
|
42503
42626
|
if (!workspace) return null;
|
|
@@ -42553,7 +42676,7 @@ var DaemonCommandRouter = class {
|
|
|
42553
42676
|
if (nodeId) unavailableNodeIds.add(nodeId);
|
|
42554
42677
|
}
|
|
42555
42678
|
const nodes = snapshot.nodes.map((statusNode) => {
|
|
42556
|
-
const nodeId =
|
|
42679
|
+
const nodeId = normalizeMeshNodeId(statusNode);
|
|
42557
42680
|
const inlineNode = nodeId ? inlineNodesById.get(nodeId) : void 0;
|
|
42558
42681
|
if (!inlineNode) return statusNode;
|
|
42559
42682
|
const liveGit = buildInlineMeshTransitGitStatus(inlineNode);
|
|
@@ -42666,7 +42789,7 @@ var DaemonCommandRouter = class {
|
|
|
42666
42789
|
}
|
|
42667
42790
|
warmInlineMeshCache(meshId, inlineMesh) {
|
|
42668
42791
|
if (!inlineMesh || typeof inlineMesh !== "object") return void 0;
|
|
42669
|
-
const sanitizedInlineMesh = sanitizeInlineMesh(inlineMesh);
|
|
42792
|
+
const sanitizedInlineMesh = sanitizeInlineMesh(normalizeInlineMeshNodeIdentity(inlineMesh));
|
|
42670
42793
|
const cached2 = this.inlineMeshCache.get(meshId);
|
|
42671
42794
|
if (cached2) {
|
|
42672
42795
|
const merged = reconcileInlineMeshCache(cached2, sanitizedInlineMesh);
|
|
@@ -42683,7 +42806,7 @@ var DaemonCommandRouter = class {
|
|
|
42683
42806
|
if (cached3) {
|
|
42684
42807
|
if (inlineMeshCarriesTransientNodeTruth(inlineMesh)) {
|
|
42685
42808
|
const merged = reconcileInlineMeshCache(cached3, inlineMesh);
|
|
42686
|
-
this.inlineMeshCache.set(meshId, sanitizeInlineMesh(merged));
|
|
42809
|
+
this.inlineMeshCache.set(meshId, sanitizeInlineMesh(normalizeInlineMeshNodeIdentity(merged)));
|
|
42687
42810
|
return { mesh: merged, inline: true, source: "inline_cache" };
|
|
42688
42811
|
}
|
|
42689
42812
|
return { mesh: cached3, inline: true, source: "inline_cache" };
|
|
@@ -42719,17 +42842,19 @@ var DaemonCommandRouter = class {
|
|
|
42719
42842
|
return null;
|
|
42720
42843
|
}
|
|
42721
42844
|
updateInlineMeshNode(meshId, mesh, node) {
|
|
42722
|
-
|
|
42723
|
-
|
|
42845
|
+
const incomingId = normalizeMeshNodeId(node);
|
|
42846
|
+
if (!mesh || !Array.isArray(mesh.nodes) || !incomingId) return;
|
|
42847
|
+
const idx = mesh.nodes.findIndex((entry) => meshNodeIdMatches(entry, incomingId));
|
|
42724
42848
|
if (idx >= 0) mesh.nodes[idx] = node;
|
|
42725
42849
|
else mesh.nodes.push(node);
|
|
42726
42850
|
mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
42851
|
+
for (const entry of mesh.nodes) foldMeshNodeIdentityToCanonical(entry);
|
|
42727
42852
|
this.inlineMeshCache.set(meshId, mesh);
|
|
42728
42853
|
this.invalidateAggregateMeshStatus(meshId);
|
|
42729
42854
|
}
|
|
42730
42855
|
removeInlineMeshNode(meshId, mesh, nodeId) {
|
|
42731
42856
|
if (!mesh || !Array.isArray(mesh.nodes)) return false;
|
|
42732
|
-
const idx = mesh.nodes.findIndex((entry) => entry
|
|
42857
|
+
const idx = mesh.nodes.findIndex((entry) => meshNodeIdMatches(entry, nodeId));
|
|
42733
42858
|
if (idx === -1) return false;
|
|
42734
42859
|
mesh.nodes.splice(idx, 1);
|
|
42735
42860
|
mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
@@ -42760,7 +42885,7 @@ var DaemonCommandRouter = class {
|
|
|
42760
42885
|
};
|
|
42761
42886
|
}
|
|
42762
42887
|
const worktreeExists = fs24.existsSync(workspace);
|
|
42763
|
-
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => n
|
|
42888
|
+
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
42764
42889
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
42765
42890
|
if (!worktreeExists) {
|
|
42766
42891
|
return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
|
|
@@ -43403,12 +43528,12 @@ var DaemonCommandRouter = class {
|
|
|
43403
43528
|
try {
|
|
43404
43529
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
43405
43530
|
const mesh = meshRecord?.mesh;
|
|
43406
|
-
const node = mesh?.nodes?.find((n) => n
|
|
43531
|
+
const node = mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
|
|
43407
43532
|
if (!node) return { success: false, error: `Node '${nodeId}' not found in mesh`, refineStages };
|
|
43408
43533
|
if (!node.isLocalWorktree || !node.workspace) {
|
|
43409
43534
|
return { success: false, error: `Refinery requires a local worktree node`, refineStages };
|
|
43410
43535
|
}
|
|
43411
|
-
const sourceNode = node.clonedFromNodeId ? mesh?.nodes.find((n) => n
|
|
43536
|
+
const sourceNode = node.clonedFromNodeId ? mesh?.nodes.find((n) => meshNodeIdMatches(n, node.clonedFromNodeId)) : mesh?.nodes.find((n) => !n.isLocalWorktree);
|
|
43412
43537
|
const repoRoot = sourceNode?.repoRoot || sourceNode?.workspace;
|
|
43413
43538
|
if (!repoRoot) return { success: false, error: "Source node repoRoot not found", refineStages };
|
|
43414
43539
|
const { execFile: execFile5 } = await import("child_process");
|
|
@@ -44043,7 +44168,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
44043
44168
|
const missing = [];
|
|
44044
44169
|
const nonWorktree = [];
|
|
44045
44170
|
for (const nodeId of requestedNodeIds) {
|
|
44046
|
-
const node = allNodes.find((n) => n
|
|
44171
|
+
const node = allNodes.find((n) => meshNodeIdMatches(n, nodeId));
|
|
44047
44172
|
if (!node) {
|
|
44048
44173
|
missing.push(nodeId);
|
|
44049
44174
|
continue;
|
|
@@ -44072,7 +44197,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
44072
44197
|
const { promisify: promisify8 } = await import("util");
|
|
44073
44198
|
const execFileAsync4 = promisify8(execFile5);
|
|
44074
44199
|
const resolveRepoRootFor = (node) => {
|
|
44075
|
-
const sourceNode = node.clonedFromNodeId ? allNodes.find((n) => n
|
|
44200
|
+
const sourceNode = node.clonedFromNodeId ? allNodes.find((n) => meshNodeIdMatches(n, node.clonedFromNodeId)) : allNodes.find((n) => !n.isLocalWorktree);
|
|
44076
44201
|
return sourceNode?.repoRoot || sourceNode?.workspace;
|
|
44077
44202
|
};
|
|
44078
44203
|
const repoRootBaseRef = /* @__PURE__ */ new Map();
|
|
@@ -44161,7 +44286,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
44161
44286
|
}));
|
|
44162
44287
|
}
|
|
44163
44288
|
const ordering = orderMeshRefineBatchNodes(changeAreas);
|
|
44164
|
-
const orderedNodes = ordering.order.map((nodeId) => targetNodes.find((n) => n
|
|
44289
|
+
const orderedNodes = ordering.order.map((nodeId) => targetNodes.find((n) => meshNodeIdMatches(n, nodeId))).filter((n) => !!n);
|
|
44165
44290
|
const dryRun = args?.dryRun !== false && args?.execute !== true;
|
|
44166
44291
|
if (dryRun) {
|
|
44167
44292
|
return {
|
|
@@ -44420,7 +44545,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
44420
44545
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
44421
44546
|
const mesh = meshRecord?.mesh;
|
|
44422
44547
|
const allNodes = Array.isArray(mesh?.nodes) ? mesh.nodes : [];
|
|
44423
|
-
const orderedNodes = nodeIds.map((id) => allNodes.find((n) => n
|
|
44548
|
+
const orderedNodes = nodeIds.map((id) => allNodes.find((n) => meshNodeIdMatches(n, id))).filter((n) => !!n);
|
|
44424
44549
|
if (orderedNodes.length === 0) {
|
|
44425
44550
|
return { success: false, error: "Batch nodes no longer resolvable in mesh", batch: true };
|
|
44426
44551
|
}
|
|
@@ -44526,7 +44651,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
44526
44651
|
const terminal = this.terminalRefineJobs.get(key);
|
|
44527
44652
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
44528
44653
|
const mesh = meshRecord?.mesh;
|
|
44529
|
-
const node = mesh?.nodes?.find((n) => n
|
|
44654
|
+
const node = mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
|
|
44530
44655
|
if (!node) return { success: false, error: `Node '${nodeId}' not found in mesh` };
|
|
44531
44656
|
if (!node.isLocalWorktree || !node.workspace) return { success: false, error: `Refinery requires a local worktree node` };
|
|
44532
44657
|
const coordinatorDaemonId = typeof args?.coordinatorDaemonId === "string" && args.coordinatorDaemonId.trim() ? args.coordinatorDaemonId.trim() : this.deps.statusInstanceId || void 0;
|
|
@@ -44573,7 +44698,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
44573
44698
|
try {
|
|
44574
44699
|
const { getMesh: getMesh2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
44575
44700
|
const meshObj = getMesh2(meshId) ?? this.getCachedInlineMesh(meshId);
|
|
44576
|
-
const nodeObj = Array.isArray(meshObj?.nodes) ? meshObj.nodes.find((n) => n
|
|
44701
|
+
const nodeObj = Array.isArray(meshObj?.nodes) ? meshObj.nodes.find((n) => meshNodeIdMatches(n, meshNodeId)) : void 0;
|
|
44577
44702
|
const bootstrapStatus = readStringValue(nodeObj?.worktreeBootstrap?.status);
|
|
44578
44703
|
if (bootstrapStatus === "running") {
|
|
44579
44704
|
return { success: true, ...launchResult, bootstrapPending: true };
|
|
@@ -44618,7 +44743,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
44618
44743
|
try {
|
|
44619
44744
|
const { getMesh: getMesh2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
44620
44745
|
const meshObj = getMesh2(dispatchMeshId) ?? this.getCachedInlineMesh(dispatchMeshId);
|
|
44621
|
-
const nodeObj = Array.isArray(meshObj?.nodes) ? meshObj.nodes.find((n) => n
|
|
44746
|
+
const nodeObj = Array.isArray(meshObj?.nodes) ? meshObj.nodes.find((n) => meshNodeIdMatches(n, dispatchNodeId)) : void 0;
|
|
44622
44747
|
const bootstrapStatus = readStringValue(nodeObj?.worktreeBootstrap?.status);
|
|
44623
44748
|
if (bootstrapStatus === "running") {
|
|
44624
44749
|
return {
|
|
@@ -45883,7 +46008,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
45883
46008
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
45884
46009
|
const mesh = meshRecord?.mesh;
|
|
45885
46010
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
45886
|
-
const node = mesh?.nodes?.find((n) => n
|
|
46011
|
+
const node = mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
|
|
45887
46012
|
if (!node) return { success: false, error: `Node '${nodeId}' not found in mesh` };
|
|
45888
46013
|
const mode = this.normalizeMeshSessionCleanupMode(args?.mode ?? mesh?.policy?.sessionCleanupOnNodeRemove);
|
|
45889
46014
|
const sessionIds = Array.isArray(args?.sessionIds) ? args.sessionIds.map((id) => typeof id === "string" ? id.trim() : "").filter(Boolean) : void 0;
|
|
@@ -45938,7 +46063,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
45938
46063
|
if (!meshId || !nodeId) return { success: false, error: "meshId and nodeId required" };
|
|
45939
46064
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
45940
46065
|
const mesh = meshRecord?.mesh;
|
|
45941
|
-
const node = mesh?.nodes?.find((n) => n
|
|
46066
|
+
const node = mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
|
|
45942
46067
|
if (!node?.workspace) return { success: false, error: `Node '${nodeId}' workspace not found` };
|
|
45943
46068
|
return {
|
|
45944
46069
|
success: true,
|
|
@@ -45960,7 +46085,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
45960
46085
|
if (meshId && nodeId) {
|
|
45961
46086
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
45962
46087
|
const mesh = meshRecord?.mesh;
|
|
45963
|
-
const node = mesh?.nodes?.find((n) => n
|
|
46088
|
+
const node = mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
|
|
45964
46089
|
if (!workspace) {
|
|
45965
46090
|
workspace = typeof node?.workspace === "string" ? node.workspace.trim() : "";
|
|
45966
46091
|
}
|
|
@@ -46003,7 +46128,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
46003
46128
|
if (isDryRun) {
|
|
46004
46129
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
46005
46130
|
const mesh = meshRecord?.mesh;
|
|
46006
|
-
const node = mesh?.nodes?.find((n) => n
|
|
46131
|
+
const node = mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
|
|
46007
46132
|
if (!node?.workspace) return { success: false, error: `Node '${nodeId}' workspace not found` };
|
|
46008
46133
|
return {
|
|
46009
46134
|
success: true,
|
|
@@ -46033,7 +46158,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
46033
46158
|
try {
|
|
46034
46159
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
46035
46160
|
const mesh = meshRecord?.mesh;
|
|
46036
|
-
const node = mesh?.nodes?.find((n) => n
|
|
46161
|
+
const node = mesh?.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
|
|
46037
46162
|
if (node && !args?._meshDirectDispatch && node.isLocalWorktree !== true && args?.force !== true) {
|
|
46038
46163
|
const nodeDaemonId = typeof node.daemonId === "string" ? node.daemonId.trim() : "";
|
|
46039
46164
|
const nodeMachineId = readMeshNodeMachineId(node) || "";
|
|
@@ -46147,7 +46272,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
46147
46272
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
46148
46273
|
const mesh = meshRecord?.mesh;
|
|
46149
46274
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
46150
|
-
const sourceNode = mesh.nodes?.find((n) => n
|
|
46275
|
+
const sourceNode = mesh.nodes?.find((n) => meshNodeIdMatches(n, sourceNodeId));
|
|
46151
46276
|
if (!sourceNode) return { success: false, error: `Source node '${sourceNodeId}' not found in mesh` };
|
|
46152
46277
|
const sourceDaemonId = typeof sourceNode.daemonId === "string" ? sourceNode.daemonId.trim() : void 0;
|
|
46153
46278
|
if (sourceDaemonId && sourceDaemonId !== this.deps.statusInstanceId && this.deps.dispatchMeshCommand && !args?._meshDirectDispatch) {
|
|
@@ -46388,7 +46513,7 @@ ${hintLines.join("\n")}` : "",
|
|
|
46388
46513
|
const meshRecord = await this.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
46389
46514
|
const mesh = meshRecord?.mesh;
|
|
46390
46515
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
46391
|
-
const node = mesh.nodes?.find((n) => n
|
|
46516
|
+
const node = mesh.nodes?.find((n) => meshNodeIdMatches(n, nodeId));
|
|
46392
46517
|
if (!node) return { success: false, error: `Node '${nodeId}' not found in mesh` };
|
|
46393
46518
|
if (!node.isLocalWorktree) return { success: false, error: "Node is not a local worktree node" };
|
|
46394
46519
|
const nodeDaemonId = typeof node.daemonId === "string" ? node.daemonId.trim() : void 0;
|
|
@@ -46525,14 +46650,14 @@ ${hintLines.join("\n")}` : "",
|
|
|
46525
46650
|
const liveMeshSessions = partitionSessionHostRecords(Array.isArray(sessionHostRecords) ? sessionHostRecords : []).liveRuntimes;
|
|
46526
46651
|
const workspace = readLiveMeshNodeWorkspace({
|
|
46527
46652
|
meshId,
|
|
46528
|
-
nodeId: String(coordinatorNode
|
|
46653
|
+
nodeId: String(normalizeMeshNodeId(coordinatorNode) || preferredCoordinatorNodeId || ""),
|
|
46529
46654
|
liveSessionRecords: liveMeshSessions,
|
|
46530
46655
|
allowCoordinatorSession: true
|
|
46531
46656
|
}) || (typeof coordinatorNode.workspace === "string" ? coordinatorNode.workspace.trim() : "");
|
|
46532
46657
|
if (!workspace) return { success: false, error: "Coordinator node workspace required", meshId, cliType };
|
|
46533
46658
|
if (!cliType) {
|
|
46534
46659
|
const resolved = await resolveProviderTypeFromPriority({
|
|
46535
|
-
nodeId: String(coordinatorNode
|
|
46660
|
+
nodeId: String(normalizeMeshNodeId(coordinatorNode) || preferredCoordinatorNodeId || "coordinator"),
|
|
46536
46661
|
providerPriority: readProviderPriorityFromPolicy(coordinatorNode.policy),
|
|
46537
46662
|
providerLoader: this.deps.providerLoader,
|
|
46538
46663
|
onStatusChange: this.deps.onStatusChange
|
|
@@ -46986,7 +47111,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
46986
47111
|
const passivePeerTruthNotAttempted = requireDirectPeerTruth && !refreshRequested && directTruth.directEvidenceCount > 0 && directTruth.peerAttemptedCount === 0;
|
|
46987
47112
|
const effectiveDirectTruth = passivePeerTruthNotAttempted ? { ...directTruth, unavailableNodeIds: [] } : directTruth;
|
|
46988
47113
|
const unavailableDirectTruthNodeIds = new Set(effectiveDirectTruth.unavailableNodeIds);
|
|
46989
|
-
const unavailableNodesAreOnlyRemovedWorktrees = unavailableDirectTruthNodeIds.size > 0 && Array.isArray(mesh.nodes) && mesh.nodes.filter((node) => unavailableDirectTruthNodeIds.has(
|
|
47114
|
+
const unavailableNodesAreOnlyRemovedWorktrees = unavailableDirectTruthNodeIds.size > 0 && Array.isArray(mesh.nodes) && mesh.nodes.filter((node) => unavailableDirectTruthNodeIds.has(normalizeMeshNodeId(node) ?? "")).every((node) => node?.isLocalWorktree === true);
|
|
46990
47115
|
const directTruthSatisfied = !requireDirectPeerTruth || effectiveDirectTruth.directEvidenceCount > 0 && (effectiveDirectTruth.unavailableNodeIds.length === 0 || unavailableNodesAreOnlyRemovedWorktrees);
|
|
46991
47116
|
if (requireDirectPeerTruth && !directTruthSatisfied) {
|
|
46992
47117
|
const failureResult = {
|
|
@@ -47021,14 +47146,13 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
47021
47146
|
const coordinatorHostname = osHostname();
|
|
47022
47147
|
const selectedCoordinatorNodeId = readStringValue(
|
|
47023
47148
|
mesh.coordinator?.preferredNodeId,
|
|
47024
|
-
mesh.nodes?.[0]
|
|
47025
|
-
mesh.nodes?.[0]?.nodeId
|
|
47149
|
+
normalizeMeshNodeId(mesh.nodes?.[0])
|
|
47026
47150
|
);
|
|
47027
47151
|
const inlineCoordinatorNodeId = meshRecord?.inline && Array.isArray(mesh.nodes) ? selectedCoordinatorNodeId : void 0;
|
|
47028
47152
|
const refreshedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
47029
47153
|
const nodeStatuses = [];
|
|
47030
47154
|
for (const [nodeIndex, node] of (mesh.nodes || []).entries()) {
|
|
47031
|
-
const nodeId =
|
|
47155
|
+
const nodeId = normalizeMeshNodeId(node) ?? "";
|
|
47032
47156
|
const daemonId = readStringValue(node.daemonId);
|
|
47033
47157
|
const nodeMachineId = readMeshNodeMachineId(node);
|
|
47034
47158
|
const nodeHostname = readMeshNodeHostname(node);
|