@adhdev/daemon-core 0.9.82-rc.114 → 0.9.82-rc.115
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/config/mesh-config.d.ts +2 -0
- package/dist/git/git-commands.d.ts +5 -1
- package/dist/index.d.ts +5 -2
- package/dist/index.js +956 -262
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +940 -253
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-active-work.d.ts +13 -0
- package/dist/mesh/mesh-refine-status.d.ts +27 -0
- package/dist/mesh/preview-freshness.d.ts +18 -0
- package/dist/mesh/refine-config.d.ts +17 -0
- package/dist/mesh/worktree-bootstrap-config.d.ts +115 -0
- package/dist/repo-mesh-types.d.ts +17 -0
- package/package.json +1 -1
- package/src/commands/router.ts +341 -5
- package/src/config/mesh-config.ts +4 -1
- package/src/git/git-commands.ts +17 -5
- package/src/index.ts +13 -2
- package/src/mesh/mesh-active-work.ts +37 -0
- package/src/mesh/mesh-refine-status.ts +145 -0
- package/src/mesh/preview-freshness.ts +118 -0
- package/src/mesh/refine-config.ts +17 -7
- package/src/mesh/worktree-bootstrap-config.ts +234 -0
- package/src/repo-mesh-types.ts +17 -0
package/dist/index.js
CHANGED
|
@@ -1055,6 +1055,7 @@ function addNode(meshId, opts) {
|
|
|
1055
1055
|
isLocalWorktree: opts.isLocalWorktree,
|
|
1056
1056
|
worktreeBranch: opts.worktreeBranch,
|
|
1057
1057
|
clonedFromNodeId: opts.clonedFromNodeId,
|
|
1058
|
+
worktreeBootstrap: opts.worktreeBootstrap,
|
|
1058
1059
|
role: opts.role
|
|
1059
1060
|
};
|
|
1060
1061
|
mesh.nodes.push(node);
|
|
@@ -1081,6 +1082,7 @@ function updateNode(meshId, nodeId, opts) {
|
|
|
1081
1082
|
if (!node) return void 0;
|
|
1082
1083
|
if (opts.userOverrides) node.userOverrides = { ...node.userOverrides, ...opts.userOverrides };
|
|
1083
1084
|
if (opts.policy) node.policy = { ...node.policy, ...opts.policy };
|
|
1085
|
+
if (opts.worktreeBootstrap) node.worktreeBootstrap = opts.worktreeBootstrap;
|
|
1084
1086
|
mesh.updatedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
1085
1087
|
saveMeshConfig(config);
|
|
1086
1088
|
return node;
|
|
@@ -1302,19 +1304,19 @@ function isIntentionalCleanupStopEntry(entry) {
|
|
|
1302
1304
|
return payload.intentional === true && (payload.reason === "operator_cleanup" || payload.intentionalStopReason === "operator_cleanup" || payload.source === "mesh_cleanup_sessions" || payload.source === "mesh_remove_node");
|
|
1303
1305
|
}
|
|
1304
1306
|
function getLedgerDir() {
|
|
1305
|
-
const dir = (0,
|
|
1306
|
-
if (!(0,
|
|
1307
|
-
(0,
|
|
1307
|
+
const dir = (0, import_path5.join)(getConfigDir(), LEDGER_DIR_NAME);
|
|
1308
|
+
if (!(0, import_fs5.existsSync)(dir)) {
|
|
1309
|
+
(0, import_fs5.mkdirSync)(dir, { recursive: true, mode: 448 });
|
|
1308
1310
|
}
|
|
1309
1311
|
return dir;
|
|
1310
1312
|
}
|
|
1311
1313
|
function getLedgerPath(meshId) {
|
|
1312
1314
|
const safe = meshId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
1313
|
-
return (0,
|
|
1315
|
+
return (0, import_path5.join)(getLedgerDir(), `${safe}.jsonl`);
|
|
1314
1316
|
}
|
|
1315
1317
|
function getRotatedPath(meshId, index) {
|
|
1316
1318
|
const safe = meshId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
1317
|
-
return (0,
|
|
1319
|
+
return (0, import_path5.join)(getLedgerDir(), `${safe}.${index}.jsonl`);
|
|
1318
1320
|
}
|
|
1319
1321
|
function readNonEmptyString(value) {
|
|
1320
1322
|
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
@@ -1436,9 +1438,9 @@ function appendLedgerEntry(meshId, partial) {
|
|
|
1436
1438
|
...partial
|
|
1437
1439
|
};
|
|
1438
1440
|
const filePath = getLedgerPath(meshId);
|
|
1439
|
-
if ((0,
|
|
1441
|
+
if ((0, import_fs5.existsSync)(filePath)) {
|
|
1440
1442
|
try {
|
|
1441
|
-
const stat2 = (0,
|
|
1443
|
+
const stat2 = (0, import_fs5.statSync)(filePath);
|
|
1442
1444
|
if (stat2.size >= MAX_FILE_SIZE_BYTES) {
|
|
1443
1445
|
rotateLedgerFile(meshId, filePath);
|
|
1444
1446
|
}
|
|
@@ -1447,7 +1449,7 @@ function appendLedgerEntry(meshId, partial) {
|
|
|
1447
1449
|
}
|
|
1448
1450
|
try {
|
|
1449
1451
|
const line = JSON.stringify(entry) + "\n";
|
|
1450
|
-
(0,
|
|
1452
|
+
(0, import_fs5.appendFileSync)(filePath, line, { encoding: "utf-8", mode: 384 });
|
|
1451
1453
|
meshLedgerEvents.emit("append", meshId, entry);
|
|
1452
1454
|
return entry;
|
|
1453
1455
|
} catch (e) {
|
|
@@ -1492,7 +1494,7 @@ function appendRemoteLedgerEntries(meshId, entries) {
|
|
|
1492
1494
|
}
|
|
1493
1495
|
try {
|
|
1494
1496
|
const lines = validEntries.map((e) => JSON.stringify(e)).join("\n") + "\n";
|
|
1495
|
-
(0,
|
|
1497
|
+
(0, import_fs5.appendFileSync)(ledgerPath, lines, { encoding: "utf-8", mode: 384 });
|
|
1496
1498
|
for (const entry of validEntries) {
|
|
1497
1499
|
meshLedgerEvents.emit("append", meshId, entry);
|
|
1498
1500
|
}
|
|
@@ -1503,10 +1505,10 @@ function appendRemoteLedgerEntries(meshId, entries) {
|
|
|
1503
1505
|
}
|
|
1504
1506
|
function readLedgerEntries(meshId, opts) {
|
|
1505
1507
|
const filePath = getLedgerPath(meshId);
|
|
1506
|
-
if (!(0,
|
|
1508
|
+
if (!(0, import_fs5.existsSync)(filePath)) return [];
|
|
1507
1509
|
let content;
|
|
1508
1510
|
try {
|
|
1509
|
-
content = (0,
|
|
1511
|
+
content = (0, import_fs5.readFileSync)(filePath, "utf-8");
|
|
1510
1512
|
} catch {
|
|
1511
1513
|
return [];
|
|
1512
1514
|
}
|
|
@@ -1678,22 +1680,22 @@ function getSessionRecoveryContext(meshId, opts) {
|
|
|
1678
1680
|
}
|
|
1679
1681
|
function rotateLedgerFile(meshId, currentPath) {
|
|
1680
1682
|
let index = 1;
|
|
1681
|
-
while ((0,
|
|
1683
|
+
while ((0, import_fs5.existsSync)(getRotatedPath(meshId, index))) {
|
|
1682
1684
|
index++;
|
|
1683
1685
|
if (index > 10) break;
|
|
1684
1686
|
}
|
|
1685
1687
|
if (index > 10) index = 10;
|
|
1686
1688
|
try {
|
|
1687
|
-
(0,
|
|
1689
|
+
(0, import_fs5.renameSync)(currentPath, getRotatedPath(meshId, index));
|
|
1688
1690
|
} catch {
|
|
1689
1691
|
}
|
|
1690
1692
|
}
|
|
1691
|
-
var
|
|
1693
|
+
var import_fs5, import_path5, import_crypto4, import_events, LEDGER_DIR_NAME, MAX_FILE_SIZE_BYTES, RECENT_FAILURE_WINDOW_MS, DEFAULT_LEDGER_SLICE_LIMIT, MAX_LEDGER_SLICE_LIMIT, meshLedgerEvents;
|
|
1692
1694
|
var init_mesh_ledger = __esm({
|
|
1693
1695
|
"src/mesh/mesh-ledger.ts"() {
|
|
1694
1696
|
"use strict";
|
|
1695
|
-
|
|
1696
|
-
|
|
1697
|
+
import_fs5 = require("fs");
|
|
1698
|
+
import_path5 = require("path");
|
|
1697
1699
|
import_crypto4 = require("crypto");
|
|
1698
1700
|
init_config();
|
|
1699
1701
|
import_events = require("events");
|
|
@@ -1717,14 +1719,14 @@ function safeMeshId(meshId) {
|
|
|
1717
1719
|
return meshId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
1718
1720
|
}
|
|
1719
1721
|
function legacyQueuePath(meshId) {
|
|
1720
|
-
return (0,
|
|
1722
|
+
return (0, import_path6.join)(getLedgerDir(), `${safeMeshId(meshId)}.queue.json`);
|
|
1721
1723
|
}
|
|
1722
|
-
var
|
|
1724
|
+
var import_fs6, import_path6, import_module, import_meta, DatabaseCtor, BeadsDB;
|
|
1723
1725
|
var init_beads_db = __esm({
|
|
1724
1726
|
"src/mesh/beads-db.ts"() {
|
|
1725
1727
|
"use strict";
|
|
1726
|
-
|
|
1727
|
-
|
|
1728
|
+
import_fs6 = require("fs");
|
|
1729
|
+
import_path6 = require("path");
|
|
1728
1730
|
import_module = require("module");
|
|
1729
1731
|
init_mesh_ledger();
|
|
1730
1732
|
import_meta = {};
|
|
@@ -1733,8 +1735,8 @@ var init_beads_db = __esm({
|
|
|
1733
1735
|
db;
|
|
1734
1736
|
migratedMeshIds = /* @__PURE__ */ new Set();
|
|
1735
1737
|
constructor(dbPath) {
|
|
1736
|
-
const dir = (0,
|
|
1737
|
-
if (!(0,
|
|
1738
|
+
const dir = (0, import_path6.dirname)(dbPath);
|
|
1739
|
+
if (!(0, import_fs6.existsSync)(dir)) (0, import_fs6.mkdirSync)(dir, { recursive: true });
|
|
1738
1740
|
this.db = new (loadDatabaseCtor())(dbPath);
|
|
1739
1741
|
this.db.pragma("journal_mode = WAL");
|
|
1740
1742
|
this.db.pragma("synchronous = NORMAL");
|
|
@@ -1744,7 +1746,7 @@ var init_beads_db = __esm({
|
|
|
1744
1746
|
}
|
|
1745
1747
|
static getInstance() {
|
|
1746
1748
|
if (!this.instance) {
|
|
1747
|
-
this.instance = new _BeadsDB((0,
|
|
1749
|
+
this.instance = new _BeadsDB((0, import_path6.join)(getLedgerDir(), "beads.db"));
|
|
1748
1750
|
}
|
|
1749
1751
|
return this.instance;
|
|
1750
1752
|
}
|
|
@@ -1785,9 +1787,9 @@ var init_beads_db = __esm({
|
|
|
1785
1787
|
const count = this.db.prepare("SELECT COUNT(*) AS count FROM mesh_queue WHERE mesh_id = ?").get(meshId);
|
|
1786
1788
|
if (count.count > 0) return;
|
|
1787
1789
|
const path28 = legacyQueuePath(meshId);
|
|
1788
|
-
if (!(0,
|
|
1790
|
+
if (!(0, import_fs6.existsSync)(path28)) return;
|
|
1789
1791
|
try {
|
|
1790
|
-
const entries = JSON.parse((0,
|
|
1792
|
+
const entries = JSON.parse((0, import_fs6.readFileSync)(path28, "utf-8"));
|
|
1791
1793
|
if (!Array.isArray(entries)) return;
|
|
1792
1794
|
const insert = this.db.prepare(`
|
|
1793
1795
|
INSERT OR REPLACE INTO mesh_queue (
|
|
@@ -2146,24 +2148,24 @@ function resolveCommandPath(command) {
|
|
|
2146
2148
|
if (isExplicitCommandPath(trimmed)) {
|
|
2147
2149
|
const expanded = expandHome(trimmed);
|
|
2148
2150
|
const candidate = path8.isAbsolute(expanded) ? expanded : path8.resolve(expanded);
|
|
2149
|
-
return (0,
|
|
2151
|
+
return (0, import_fs7.existsSync)(candidate) ? candidate : null;
|
|
2150
2152
|
}
|
|
2151
2153
|
return null;
|
|
2152
2154
|
}
|
|
2153
2155
|
function execAsync(cmd, timeoutMs = 5e3) {
|
|
2154
|
-
return new Promise((
|
|
2156
|
+
return new Promise((resolve17) => {
|
|
2155
2157
|
const child = (0, import_child_process.exec)(cmd, {
|
|
2156
2158
|
encoding: "utf-8",
|
|
2157
2159
|
timeout: timeoutMs,
|
|
2158
2160
|
...process.platform === "win32" ? { windowsHide: true } : {}
|
|
2159
2161
|
}, (err, stdout) => {
|
|
2160
2162
|
if (err || !stdout?.trim()) {
|
|
2161
|
-
|
|
2163
|
+
resolve17(null);
|
|
2162
2164
|
} else {
|
|
2163
|
-
|
|
2165
|
+
resolve17(stdout.trim());
|
|
2164
2166
|
}
|
|
2165
2167
|
});
|
|
2166
|
-
child.on("error", () =>
|
|
2168
|
+
child.on("error", () => resolve17(null));
|
|
2167
2169
|
});
|
|
2168
2170
|
}
|
|
2169
2171
|
async function detectCLIs(providerLoader, options) {
|
|
@@ -2246,14 +2248,14 @@ async function detectCLI(cliId, providerLoader, options) {
|
|
|
2246
2248
|
const all = await detectCLIs(providerLoader, options);
|
|
2247
2249
|
return all.find((c) => c.id === resolvedId && c.installed) || null;
|
|
2248
2250
|
}
|
|
2249
|
-
var import_child_process, os2, path8,
|
|
2251
|
+
var import_child_process, os2, path8, import_fs7;
|
|
2250
2252
|
var init_cli_detector = __esm({
|
|
2251
2253
|
"src/detection/cli-detector.ts"() {
|
|
2252
2254
|
"use strict";
|
|
2253
2255
|
import_child_process = require("child_process");
|
|
2254
2256
|
os2 = __toESM(require("os"));
|
|
2255
2257
|
path8 = __toESM(require("path"));
|
|
2256
|
-
|
|
2258
|
+
import_fs7 = require("fs");
|
|
2257
2259
|
}
|
|
2258
2260
|
});
|
|
2259
2261
|
|
|
@@ -2539,7 +2541,7 @@ __export(mesh_events_exports, {
|
|
|
2539
2541
|
tryAssignQueueTask: () => tryAssignQueueTask
|
|
2540
2542
|
});
|
|
2541
2543
|
function readWorkerResultMetadata(event) {
|
|
2542
|
-
return
|
|
2544
|
+
return readRecord2(event.workerResult) || readRecord2(event.meshWorkerResult) || readRecord2(event.structuredResult);
|
|
2543
2545
|
}
|
|
2544
2546
|
function sweepExpiredRemoteIdleSessions() {
|
|
2545
2547
|
const now = Date.now();
|
|
@@ -2548,9 +2550,9 @@ function sweepExpiredRemoteIdleSessions() {
|
|
|
2548
2550
|
}
|
|
2549
2551
|
}
|
|
2550
2552
|
function readRefineJobId(event) {
|
|
2551
|
-
const metadata =
|
|
2552
|
-
const result =
|
|
2553
|
-
const refineJob =
|
|
2553
|
+
const metadata = readRecord2(event.metadataEvent) || event;
|
|
2554
|
+
const result = readRecord2(metadata.result);
|
|
2555
|
+
const refineJob = readRecord2(result?.refineJob);
|
|
2554
2556
|
return readNonEmptyString2(metadata.jobId) || readNonEmptyString2(refineJob?.jobId);
|
|
2555
2557
|
}
|
|
2556
2558
|
function buildRefineTerminalEventFingerprint(meshId, eventName, metadataEvent) {
|
|
@@ -2566,10 +2568,10 @@ function hasPendingRefineTerminalEventDuplicate(event) {
|
|
|
2566
2568
|
);
|
|
2567
2569
|
}
|
|
2568
2570
|
function buildPendingEventFingerprint(event) {
|
|
2569
|
-
const metadata =
|
|
2571
|
+
const metadata = readRecord2(event.metadataEvent) || {};
|
|
2570
2572
|
const sessionId = resolveEventSessionId(metadata);
|
|
2571
2573
|
const providerSessionId = readNonEmptyString2(metadata.providerSessionId);
|
|
2572
|
-
const taskId = readNonEmptyString2(metadata.taskId) || readNonEmptyString2(
|
|
2574
|
+
const taskId = readNonEmptyString2(metadata.taskId) || readNonEmptyString2(readRecord2(metadata.payload)?.taskId);
|
|
2573
2575
|
const jobId = readRefineJobId(event);
|
|
2574
2576
|
const timestamp = metadata.timestamp !== void 0 && metadata.timestamp !== null ? String(metadata.timestamp) : "";
|
|
2575
2577
|
return [
|
|
@@ -2590,7 +2592,7 @@ function hasPendingCoordinatorEventDuplicate(event) {
|
|
|
2590
2592
|
}
|
|
2591
2593
|
function getPendingEventsPath(meshId) {
|
|
2592
2594
|
const safe = meshId.replace(/[^a-zA-Z0-9_-]/g, "_");
|
|
2593
|
-
return (0,
|
|
2595
|
+
return (0, import_path7.join)(getLedgerDir(), `${safe}.pending-events.jsonl`);
|
|
2594
2596
|
}
|
|
2595
2597
|
function queuePendingMeshCoordinatorEvent(event) {
|
|
2596
2598
|
try {
|
|
@@ -2602,7 +2604,7 @@ function queuePendingMeshCoordinatorEvent(event) {
|
|
|
2602
2604
|
LOG.info("MeshEvents", `Suppressed duplicate pending ${event.event} for mesh ${event.meshId}`);
|
|
2603
2605
|
return true;
|
|
2604
2606
|
}
|
|
2605
|
-
(0,
|
|
2607
|
+
(0, import_fs8.appendFileSync)(getPendingEventsPath(event.meshId), JSON.stringify(event) + "\n", "utf-8");
|
|
2606
2608
|
return true;
|
|
2607
2609
|
} catch (e) {
|
|
2608
2610
|
LOG.warn("MeshEvents", `Failed to persist pending coordinator event: ${e?.message || e}`);
|
|
@@ -2612,11 +2614,11 @@ function queuePendingMeshCoordinatorEvent(event) {
|
|
|
2612
2614
|
function drainPendingMeshCoordinatorEvents(meshId) {
|
|
2613
2615
|
if (!meshId) return [];
|
|
2614
2616
|
const path28 = getPendingEventsPath(meshId);
|
|
2615
|
-
if (!(0,
|
|
2617
|
+
if (!(0, import_fs8.existsSync)(path28)) return [];
|
|
2616
2618
|
try {
|
|
2617
|
-
const raw = (0,
|
|
2619
|
+
const raw = (0, import_fs8.readFileSync)(path28, "utf-8");
|
|
2618
2620
|
try {
|
|
2619
|
-
(0,
|
|
2621
|
+
(0, import_fs8.unlinkSync)(path28);
|
|
2620
2622
|
} catch {
|
|
2621
2623
|
}
|
|
2622
2624
|
return raw.split("\n").filter(Boolean).flatMap((line) => {
|
|
@@ -2633,9 +2635,9 @@ function drainPendingMeshCoordinatorEvents(meshId) {
|
|
|
2633
2635
|
function getPendingMeshCoordinatorEvents(meshId) {
|
|
2634
2636
|
if (!meshId) return [];
|
|
2635
2637
|
const path28 = getPendingEventsPath(meshId);
|
|
2636
|
-
if (!(0,
|
|
2638
|
+
if (!(0, import_fs8.existsSync)(path28)) return [];
|
|
2637
2639
|
try {
|
|
2638
|
-
const raw = (0,
|
|
2640
|
+
const raw = (0, import_fs8.readFileSync)(path28, "utf-8");
|
|
2639
2641
|
return raw.split("\n").filter(Boolean).flatMap((line) => {
|
|
2640
2642
|
try {
|
|
2641
2643
|
return [JSON.parse(line)];
|
|
@@ -2650,15 +2652,15 @@ function getPendingMeshCoordinatorEvents(meshId) {
|
|
|
2650
2652
|
function clearPendingMeshCoordinatorEvents(meshId) {
|
|
2651
2653
|
if (!meshId) return;
|
|
2652
2654
|
const path28 = getPendingEventsPath(meshId);
|
|
2653
|
-
if ((0,
|
|
2654
|
-
(0,
|
|
2655
|
+
if ((0, import_fs8.existsSync)(path28)) try {
|
|
2656
|
+
(0, import_fs8.unlinkSync)(path28);
|
|
2655
2657
|
} catch {
|
|
2656
2658
|
}
|
|
2657
2659
|
}
|
|
2658
2660
|
function readNonEmptyString2(value) {
|
|
2659
2661
|
return typeof value === "string" && value.trim() ? value.trim() : "";
|
|
2660
2662
|
}
|
|
2661
|
-
function
|
|
2663
|
+
function readRecord2(value) {
|
|
2662
2664
|
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
2663
2665
|
}
|
|
2664
2666
|
function resolveEventSessionId(event, fallback) {
|
|
@@ -3098,10 +3100,10 @@ Do NOT retry on this node. Consider reassigning to a different node or asking th
|
|
|
3098
3100
|
}
|
|
3099
3101
|
if (args.event === "refine:completed") {
|
|
3100
3102
|
const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
|
|
3101
|
-
const result =
|
|
3102
|
-
const validationSummary =
|
|
3103
|
-
const patchEquivalence =
|
|
3104
|
-
const finalConvergence =
|
|
3103
|
+
const result = readRecord2(args.metadataEvent.result);
|
|
3104
|
+
const validationSummary = readRecord2(result?.validationSummary);
|
|
3105
|
+
const patchEquivalence = readRecord2(result?.patchEquivalence);
|
|
3106
|
+
const finalConvergence = readRecord2(result?.finalBranchConvergenceState);
|
|
3105
3107
|
const validationStatus = readNonEmptyString2(validationSummary?.status);
|
|
3106
3108
|
const patchStatus = readNonEmptyString2(patchEquivalence?.status) || (patchEquivalence?.equivalent === true ? "passed" : "");
|
|
3107
3109
|
const into = readNonEmptyString2(result?.into);
|
|
@@ -3122,10 +3124,10 @@ Next step: ${nextStep}`;
|
|
|
3122
3124
|
}
|
|
3123
3125
|
if (args.event === "refine:failed") {
|
|
3124
3126
|
const jobId = readRefineJobId({ metadataEvent: args.metadataEvent });
|
|
3125
|
-
const result =
|
|
3126
|
-
const validationSummary =
|
|
3127
|
-
const patchEquivalence =
|
|
3128
|
-
const finalConvergence =
|
|
3127
|
+
const result = readRecord2(args.metadataEvent.result);
|
|
3128
|
+
const validationSummary = readRecord2(result?.validationSummary);
|
|
3129
|
+
const patchEquivalence = readRecord2(result?.patchEquivalence);
|
|
3130
|
+
const finalConvergence = readRecord2(result?.finalBranchConvergenceState);
|
|
3129
3131
|
const code = readNonEmptyString2(result?.code);
|
|
3130
3132
|
const error = readNonEmptyString2(result?.error);
|
|
3131
3133
|
const validationStatus = readNonEmptyString2(validationSummary?.status);
|
|
@@ -3493,12 +3495,12 @@ function setupMeshEventForwarding(components) {
|
|
|
3493
3495
|
});
|
|
3494
3496
|
});
|
|
3495
3497
|
}
|
|
3496
|
-
var
|
|
3498
|
+
var import_fs8, import_path7, REMOTE_IDLE_SESSION_TTL_MS, remoteIdleSessions, REFINE_TERMINAL_EVENTS, MESH_COORDINATOR_EVENTS, EVENT_TO_LEDGER_KIND, INTENTIONAL_CLEANUP_STOP_SUPPRESSION_MS, RECENT_COMPLETION_FINGERPRINT_TTL_MS, recentCompletionFingerprints, autoLaunchInProgress, autoLaunchCooldownUntil, AUTO_LAUNCH_COOLDOWN_MS;
|
|
3497
3499
|
var init_mesh_events = __esm({
|
|
3498
3500
|
"src/mesh/mesh-events.ts"() {
|
|
3499
3501
|
"use strict";
|
|
3500
|
-
|
|
3501
|
-
|
|
3502
|
+
import_fs8 = require("fs");
|
|
3503
|
+
import_path7 = require("path");
|
|
3502
3504
|
init_config();
|
|
3503
3505
|
init_mesh_config();
|
|
3504
3506
|
init_cli_detector();
|
|
@@ -5214,7 +5216,7 @@ ${lastSnapshot}`;
|
|
|
5214
5216
|
`[${this.cliType}] Waiting for interactive prompt: status=${status} stableMs=${stableMs} recentOutputMs=${recentlyOutput} screen=${JSON.stringify(summarizeCliTraceText(screenText, 220)).slice(0, 260)}`
|
|
5215
5217
|
);
|
|
5216
5218
|
}
|
|
5217
|
-
await new Promise((
|
|
5219
|
+
await new Promise((resolve17) => setTimeout(resolve17, 50));
|
|
5218
5220
|
}
|
|
5219
5221
|
const finalScreenText = this.terminalScreen.getText() || "";
|
|
5220
5222
|
LOG.warn(
|
|
@@ -6441,7 +6443,7 @@ ${lastSnapshot}`;
|
|
|
6441
6443
|
const deadline = Date.now() + 1e4;
|
|
6442
6444
|
while (this.startupParseGate && Date.now() < deadline) {
|
|
6443
6445
|
this.resolveStartupState("send_wait");
|
|
6444
|
-
await new Promise((
|
|
6446
|
+
await new Promise((resolve17) => setTimeout(resolve17, 50));
|
|
6445
6447
|
}
|
|
6446
6448
|
}
|
|
6447
6449
|
const parsedStatusBeforeSend = !allowInputDuringGeneration ? (() => {
|
|
@@ -6538,13 +6540,13 @@ ${lastSnapshot}`;
|
|
|
6538
6540
|
}
|
|
6539
6541
|
this.responseEpoch += 1;
|
|
6540
6542
|
this.responseSettleIgnoreUntil = Date.now() + submitDelayMs + this.timeouts.outputSettle + 250;
|
|
6541
|
-
await new Promise((
|
|
6543
|
+
await new Promise((resolve17, reject) => {
|
|
6542
6544
|
let resolved = false;
|
|
6543
6545
|
const completion = {
|
|
6544
6546
|
resolveOnce: () => {
|
|
6545
6547
|
if (resolved) return;
|
|
6546
6548
|
resolved = true;
|
|
6547
|
-
|
|
6549
|
+
resolve17();
|
|
6548
6550
|
},
|
|
6549
6551
|
rejectOnce: (error) => {
|
|
6550
6552
|
if (resolved) return;
|
|
@@ -6702,17 +6704,17 @@ ${lastSnapshot}`;
|
|
|
6702
6704
|
}
|
|
6703
6705
|
}
|
|
6704
6706
|
waitForStopped(timeoutMs) {
|
|
6705
|
-
return new Promise((
|
|
6707
|
+
return new Promise((resolve17) => {
|
|
6706
6708
|
const startedAt = Date.now();
|
|
6707
6709
|
const timer = setInterval(() => {
|
|
6708
6710
|
if (!this.ptyProcess || this.currentStatus === "stopped") {
|
|
6709
6711
|
clearInterval(timer);
|
|
6710
|
-
|
|
6712
|
+
resolve17(true);
|
|
6711
6713
|
return;
|
|
6712
6714
|
}
|
|
6713
6715
|
if (Date.now() - startedAt >= timeoutMs) {
|
|
6714
6716
|
clearInterval(timer);
|
|
6715
|
-
|
|
6717
|
+
resolve17(false);
|
|
6716
6718
|
}
|
|
6717
6719
|
}, 100);
|
|
6718
6720
|
});
|
|
@@ -7042,6 +7044,8 @@ __export(index_exports, {
|
|
|
7042
7044
|
MAX_LEDGER_SLICE_LIMIT: () => MAX_LEDGER_SLICE_LIMIT,
|
|
7043
7045
|
MESH_REFINE_CONFIG_LOCATIONS: () => MESH_REFINE_CONFIG_LOCATIONS,
|
|
7044
7046
|
MESH_REFINE_CONFIG_SCHEMA: () => MESH_REFINE_CONFIG_SCHEMA,
|
|
7047
|
+
MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS: () => MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS,
|
|
7048
|
+
MESH_WORKTREE_BOOTSTRAP_CONFIG_SCHEMA: () => MESH_WORKTREE_BOOTSTRAP_CONFIG_SCHEMA,
|
|
7045
7049
|
MIN_GIT_WORKSPACE_POLL_INTERVAL_MS: () => MIN_GIT_WORKSPACE_POLL_INTERVAL_MS,
|
|
7046
7050
|
MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS: () => MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS,
|
|
7047
7051
|
MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS: () => MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS,
|
|
@@ -7062,10 +7066,12 @@ __export(index_exports, {
|
|
|
7062
7066
|
buildChatMessage: () => buildChatMessage,
|
|
7063
7067
|
buildChatMessageSignature: () => buildChatMessageSignature,
|
|
7064
7068
|
buildChatTailDeliverySignature: () => buildChatTailDeliverySignature,
|
|
7069
|
+
buildCompactStaleDirectWorkSummary: () => buildCompactStaleDirectWorkSummary,
|
|
7065
7070
|
buildCoordinatorSystemPrompt: () => buildCoordinatorSystemPrompt,
|
|
7066
7071
|
buildMachineInfo: () => buildMachineInfo,
|
|
7067
7072
|
buildMeshActiveWork: () => buildMeshActiveWork,
|
|
7068
7073
|
buildMeshActiveWorkSummary: () => buildMeshActiveWorkSummary,
|
|
7074
|
+
buildMeshAsyncRefineJobs: () => buildMeshAsyncRefineJobs,
|
|
7069
7075
|
buildMeshHostRequiredFailure: () => buildMeshHostRequiredFailure,
|
|
7070
7076
|
buildMeshLedgerReconciliationEvidence: () => buildMeshLedgerReconciliationEvidence,
|
|
7071
7077
|
buildMeshLedgerReplicaEvidence: () => buildMeshLedgerReplicaEvidence,
|
|
@@ -7174,6 +7180,7 @@ __export(index_exports, {
|
|
|
7174
7180
|
listWorktrees: () => listWorktrees,
|
|
7175
7181
|
loadConfig: () => loadConfig,
|
|
7176
7182
|
loadMeshRefineConfig: () => loadMeshRefineConfig,
|
|
7183
|
+
loadMeshWorktreeBootstrapConfig: () => loadMeshWorktreeBootstrapConfig,
|
|
7177
7184
|
loadState: () => loadState,
|
|
7178
7185
|
logCommand: () => logCommand,
|
|
7179
7186
|
markSetupComplete: () => markSetupComplete,
|
|
@@ -7225,6 +7232,7 @@ __export(index_exports, {
|
|
|
7225
7232
|
resolveWorktreePath: () => resolveWorktreePath,
|
|
7226
7233
|
runAsyncBatch: () => runAsyncBatch,
|
|
7227
7234
|
runGit: () => runGit,
|
|
7235
|
+
runMeshWorktreeBootstrap: () => runMeshWorktreeBootstrap,
|
|
7228
7236
|
saveConfig: () => saveConfig,
|
|
7229
7237
|
saveState: () => saveState,
|
|
7230
7238
|
setDebugRuntimeConfig: () => setDebugRuntimeConfig,
|
|
@@ -7246,7 +7254,8 @@ __export(index_exports, {
|
|
|
7246
7254
|
updateTaskStatus: () => updateTaskStatus,
|
|
7247
7255
|
upsertSavedProviderSession: () => upsertSavedProviderSession,
|
|
7248
7256
|
validateMeshRefineConfig: () => validateMeshRefineConfig,
|
|
7249
|
-
validateMeshTaskModeRequest: () => validateMeshTaskModeRequest
|
|
7257
|
+
validateMeshTaskModeRequest: () => validateMeshTaskModeRequest,
|
|
7258
|
+
validateMeshWorktreeBootstrapConfig: () => validateMeshWorktreeBootstrapConfig
|
|
7250
7259
|
});
|
|
7251
7260
|
module.exports = __toCommonJS(index_exports);
|
|
7252
7261
|
init_repo_mesh_types();
|
|
@@ -8316,10 +8325,17 @@ async function gitCheckpoint(workspace, message, includeUntracked) {
|
|
|
8316
8325
|
} catch (err) {
|
|
8317
8326
|
const output = (err?.stdout || "") + (err?.stderr || "");
|
|
8318
8327
|
if (/nothing to commit/i.test(output)) {
|
|
8319
|
-
|
|
8320
|
-
|
|
8321
|
-
|
|
8322
|
-
|
|
8328
|
+
return {
|
|
8329
|
+
workspace: repo.workspace,
|
|
8330
|
+
repoRoot,
|
|
8331
|
+
isGitRepo: true,
|
|
8332
|
+
message: fullMsg,
|
|
8333
|
+
status: "skipped",
|
|
8334
|
+
skipped: true,
|
|
8335
|
+
noop: true,
|
|
8336
|
+
reason: "nothing_to_commit",
|
|
8337
|
+
lastCheckedAt: Date.now()
|
|
8338
|
+
};
|
|
8323
8339
|
}
|
|
8324
8340
|
throw err;
|
|
8325
8341
|
}
|
|
@@ -8329,6 +8345,7 @@ async function gitCheckpoint(workspace, message, includeUntracked) {
|
|
|
8329
8345
|
isGitRepo: true,
|
|
8330
8346
|
commit: commitSha,
|
|
8331
8347
|
message: fullMsg,
|
|
8348
|
+
status: "created",
|
|
8332
8349
|
lastCheckedAt: Date.now()
|
|
8333
8350
|
};
|
|
8334
8351
|
}
|
|
@@ -9032,6 +9049,7 @@ var MESH_REFINE_CONFIG_SCHEMA = {
|
|
|
9032
9049
|
category: { enum: [...MESH_REFINE_VALIDATION_CATEGORIES, "custom"] },
|
|
9033
9050
|
cwd: { type: "string" },
|
|
9034
9051
|
timeoutMs: { type: "number", minimum: 1e3, maximum: 6e5 },
|
|
9052
|
+
outputLimitBytes: { type: "number", minimum: 1024, maximum: 1048576 },
|
|
9035
9053
|
env: { type: "object", additionalProperties: { type: "string" } }
|
|
9036
9054
|
}
|
|
9037
9055
|
}
|
|
@@ -9049,6 +9067,7 @@ var MESH_REFINE_CONFIG_SCHEMA = {
|
|
|
9049
9067
|
category: { enum: [...MESH_REFINE_VALIDATION_CATEGORIES, "custom"] },
|
|
9050
9068
|
cwd: { type: "string" },
|
|
9051
9069
|
timeoutMs: { type: "number", minimum: 1e3, maximum: 6e5 },
|
|
9070
|
+
outputLimitBytes: { type: "number", minimum: 1024, maximum: 1048576 },
|
|
9052
9071
|
env: { type: "object", additionalProperties: { type: "string" } }
|
|
9053
9072
|
}
|
|
9054
9073
|
}
|
|
@@ -9057,7 +9076,7 @@ var MESH_REFINE_CONFIG_SCHEMA = {
|
|
|
9057
9076
|
}
|
|
9058
9077
|
}
|
|
9059
9078
|
};
|
|
9060
|
-
function
|
|
9079
|
+
function isMeshConfigRecord(value) {
|
|
9061
9080
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
9062
9081
|
}
|
|
9063
9082
|
function tokenizeCommandString(command) {
|
|
@@ -9072,8 +9091,8 @@ function tokenizeCommandString(command) {
|
|
|
9072
9091
|
function validateCategory(value) {
|
|
9073
9092
|
return typeof value === "string" && [...MESH_REFINE_VALIDATION_CATEGORIES, "custom"].includes(value) ? value : "custom";
|
|
9074
9093
|
}
|
|
9075
|
-
function
|
|
9076
|
-
if (!
|
|
9094
|
+
function normalizeMeshCommandConfig(entry, source) {
|
|
9095
|
+
if (!isMeshConfigRecord(entry) || typeof entry.command !== "string") {
|
|
9077
9096
|
return { rejected: { source, reason: "validation command must be an object with a command string" } };
|
|
9078
9097
|
}
|
|
9079
9098
|
const commandText = entry.command.trim();
|
|
@@ -9100,7 +9119,10 @@ function normalizeCommandConfig(entry, source) {
|
|
|
9100
9119
|
if (entry.timeoutMs !== void 0 && (typeof entry.timeoutMs !== "number" || !Number.isFinite(entry.timeoutMs) || entry.timeoutMs < 1e3 || entry.timeoutMs > 6e5)) {
|
|
9101
9120
|
return { rejected: { source, command: commandText, reason: "timeoutMs must be between 1000 and 600000" } };
|
|
9102
9121
|
}
|
|
9103
|
-
if (entry.
|
|
9122
|
+
if (entry.outputLimitBytes !== void 0 && (typeof entry.outputLimitBytes !== "number" || !Number.isFinite(entry.outputLimitBytes) || entry.outputLimitBytes < 1024 || entry.outputLimitBytes > 1048576)) {
|
|
9123
|
+
return { rejected: { source, command: commandText, reason: "outputLimitBytes must be between 1024 and 1048576" } };
|
|
9124
|
+
}
|
|
9125
|
+
if (entry.env !== void 0 && (!isMeshConfigRecord(entry.env) || !Object.values(entry.env).every((value) => typeof value === "string"))) {
|
|
9104
9126
|
return { rejected: { source, command: commandText, reason: "env must be an object of string values" } };
|
|
9105
9127
|
}
|
|
9106
9128
|
return {
|
|
@@ -9112,10 +9134,12 @@ function normalizeCommandConfig(entry, source) {
|
|
|
9112
9134
|
source,
|
|
9113
9135
|
...typeof entry.cwd === "string" && entry.cwd.trim() ? { cwd: entry.cwd.trim() } : {},
|
|
9114
9136
|
...typeof entry.timeoutMs === "number" ? { timeoutMs: entry.timeoutMs } : {},
|
|
9115
|
-
...
|
|
9137
|
+
...typeof entry.outputLimitBytes === "number" ? { outputLimitBytes: entry.outputLimitBytes } : {},
|
|
9138
|
+
...isMeshConfigRecord(entry.env) ? { env: entry.env } : {}
|
|
9116
9139
|
}
|
|
9117
9140
|
};
|
|
9118
9141
|
}
|
|
9142
|
+
var isRecord = isMeshConfigRecord;
|
|
9119
9143
|
function validateMeshRefineConfig(config, source = "inline") {
|
|
9120
9144
|
const errors = [];
|
|
9121
9145
|
const bootstrapCommands = [];
|
|
@@ -9134,14 +9158,14 @@ function validateMeshRefineConfig(config, source = "inline") {
|
|
|
9134
9158
|
if (rawBootstrapCommands !== void 0 && !Array.isArray(rawBootstrapCommands)) errors.push("validation.bootstrapCommands must be an array");
|
|
9135
9159
|
if (Array.isArray(rawBootstrapCommands)) {
|
|
9136
9160
|
rawBootstrapCommands.forEach((entry, index) => {
|
|
9137
|
-
const normalized =
|
|
9161
|
+
const normalized = normalizeMeshCommandConfig(entry, `${source}:validation.bootstrapCommands[${index}]`);
|
|
9138
9162
|
if (normalized.command) bootstrapCommands.push(normalized.command);
|
|
9139
9163
|
if (normalized.rejected) rejectedCommands.push(normalized.rejected);
|
|
9140
9164
|
});
|
|
9141
9165
|
}
|
|
9142
9166
|
if (Array.isArray(rawCommands)) {
|
|
9143
9167
|
rawCommands.forEach((entry, index) => {
|
|
9144
|
-
const normalized =
|
|
9168
|
+
const normalized = normalizeMeshCommandConfig(entry, `${source}:validation.commands[${index}]`);
|
|
9145
9169
|
if (normalized.command) commands.push(normalized.command);
|
|
9146
9170
|
if (normalized.rejected) rejectedCommands.push(normalized.rejected);
|
|
9147
9171
|
});
|
|
@@ -9253,6 +9277,190 @@ function resolveMeshRefineValidationPlan(mesh, workspace) {
|
|
|
9253
9277
|
};
|
|
9254
9278
|
}
|
|
9255
9279
|
|
|
9280
|
+
// src/mesh/worktree-bootstrap-config.ts
|
|
9281
|
+
var import_fs4 = require("fs");
|
|
9282
|
+
var import_path4 = require("path");
|
|
9283
|
+
var import_node_child_process3 = require("child_process");
|
|
9284
|
+
var import_node_util3 = require("util");
|
|
9285
|
+
var yaml2 = __toESM(require("js-yaml"));
|
|
9286
|
+
var MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS = [
|
|
9287
|
+
".adhdev/worktree_bootstrap.json",
|
|
9288
|
+
".adhdev/worktree_bootstrap.yaml",
|
|
9289
|
+
".adhdev/worktree_bootstrap.yml",
|
|
9290
|
+
".adhdev/worktree-bootstrap.json",
|
|
9291
|
+
".adhdev/worktree-bootstrap.yaml",
|
|
9292
|
+
".adhdev/worktree-bootstrap.yml"
|
|
9293
|
+
];
|
|
9294
|
+
var MESH_WORKTREE_BOOTSTRAP_CONFIG_SCHEMA = {
|
|
9295
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
9296
|
+
title: "ADHDev Repo Mesh Worktree Bootstrap Config",
|
|
9297
|
+
type: "object",
|
|
9298
|
+
additionalProperties: false,
|
|
9299
|
+
required: ["version"],
|
|
9300
|
+
properties: {
|
|
9301
|
+
version: { const: 1 },
|
|
9302
|
+
enabled: { type: "boolean", default: true },
|
|
9303
|
+
runOnClone: { type: "boolean", default: true },
|
|
9304
|
+
required: { type: "boolean", default: true },
|
|
9305
|
+
staleInputs: { type: "array", maxItems: 16, items: { type: "string", minLength: 1 } },
|
|
9306
|
+
commands: {
|
|
9307
|
+
type: "array",
|
|
9308
|
+
minItems: 1,
|
|
9309
|
+
maxItems: 4,
|
|
9310
|
+
items: {
|
|
9311
|
+
type: "object",
|
|
9312
|
+
additionalProperties: false,
|
|
9313
|
+
required: ["command"],
|
|
9314
|
+
properties: {
|
|
9315
|
+
command: { type: "string", minLength: 1 },
|
|
9316
|
+
args: { type: "array", items: { type: "string" } },
|
|
9317
|
+
category: { enum: ["typecheck", "test", "lint", "build", "custom"] },
|
|
9318
|
+
cwd: { type: "string" },
|
|
9319
|
+
timeoutMs: { type: "number", minimum: 1e3, maximum: 6e5 },
|
|
9320
|
+
outputLimitBytes: { type: "number", minimum: 1024, maximum: 1048576 },
|
|
9321
|
+
env: { type: "object", additionalProperties: { type: "string" } }
|
|
9322
|
+
}
|
|
9323
|
+
}
|
|
9324
|
+
}
|
|
9325
|
+
}
|
|
9326
|
+
};
|
|
9327
|
+
var DEFAULT_TIMEOUT_MS2 = 12e4;
|
|
9328
|
+
var DEFAULT_OUTPUT_LIMIT_BYTES = 128 * 1024;
|
|
9329
|
+
var OUTPUT_SUMMARY_CHARS = 2e3;
|
|
9330
|
+
function parseConfigText2(path28, text) {
|
|
9331
|
+
if (/\.json$/i.test(path28)) return JSON.parse(text);
|
|
9332
|
+
return yaml2.load(text);
|
|
9333
|
+
}
|
|
9334
|
+
function truncateOutput(value) {
|
|
9335
|
+
const text = typeof value === "string" ? value : value == null ? "" : String(value);
|
|
9336
|
+
if (text.length <= OUTPUT_SUMMARY_CHARS) return text;
|
|
9337
|
+
return `${text.slice(0, OUTPUT_SUMMARY_CHARS)}
|
|
9338
|
+
[truncated ${text.length - OUTPUT_SUMMARY_CHARS} chars]`;
|
|
9339
|
+
}
|
|
9340
|
+
function validateMeshWorktreeBootstrapConfig(config, source = "inline") {
|
|
9341
|
+
const errors = [];
|
|
9342
|
+
const commands = [];
|
|
9343
|
+
const rejectedCommands = [];
|
|
9344
|
+
if (!isMeshConfigRecord(config)) return { valid: false, errors: ["config must be an object"], commands, rejectedCommands };
|
|
9345
|
+
if (config.version !== 1) errors.push("version must be 1");
|
|
9346
|
+
if (config.enabled !== void 0 && typeof config.enabled !== "boolean") errors.push("enabled must be a boolean when provided");
|
|
9347
|
+
if (config.runOnClone !== void 0 && typeof config.runOnClone !== "boolean") errors.push("runOnClone must be a boolean when provided");
|
|
9348
|
+
if (config.required !== void 0 && typeof config.required !== "boolean") errors.push("required must be a boolean when provided");
|
|
9349
|
+
if (config.staleInputs !== void 0 && (!Array.isArray(config.staleInputs) || !config.staleInputs.every((input) => typeof input === "string" && input.trim()))) {
|
|
9350
|
+
errors.push("staleInputs must be an array of non-empty strings when provided");
|
|
9351
|
+
}
|
|
9352
|
+
if (config.commands !== void 0 && !Array.isArray(config.commands)) errors.push("commands must be an array");
|
|
9353
|
+
if (Array.isArray(config.commands)) {
|
|
9354
|
+
config.commands.forEach((entry, index) => {
|
|
9355
|
+
const normalized = normalizeMeshCommandConfig(entry, `${source}:commands[${index}]`);
|
|
9356
|
+
if (normalized.command) commands.push(normalized.command);
|
|
9357
|
+
if (normalized.rejected) rejectedCommands.push(normalized.rejected);
|
|
9358
|
+
});
|
|
9359
|
+
}
|
|
9360
|
+
if (config.enabled !== false && config.runOnClone !== false && commands.length === 0) errors.push("commands must contain at least one command when bootstrap is enabled");
|
|
9361
|
+
if (rejectedCommands.length) errors.push("one or more bootstrap commands are invalid");
|
|
9362
|
+
return { valid: errors.length === 0, errors, commands, rejectedCommands };
|
|
9363
|
+
}
|
|
9364
|
+
function loadMeshWorktreeBootstrapConfig(mesh, workspace) {
|
|
9365
|
+
const inline = mesh?.worktreeBootstrapConfig || mesh?.policy?.worktreeBootstrapConfig || mesh?.policy?.worktreeBootstrap;
|
|
9366
|
+
if (inline !== void 0) {
|
|
9367
|
+
const validation = validateMeshWorktreeBootstrapConfig(inline, "mesh.policy.worktreeBootstrapConfig");
|
|
9368
|
+
if (!validation.valid) return { source: "mesh.policy.worktreeBootstrapConfig", sourceType: "invalid", error: String(validation.rejectedCommands[0]?.reason || validation.errors.join("; ")) };
|
|
9369
|
+
return { config: inline, source: "mesh.policy.worktreeBootstrapConfig", sourceType: "mesh_policy" };
|
|
9370
|
+
}
|
|
9371
|
+
for (const relative3 of MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS) {
|
|
9372
|
+
const configPath = (0, import_path4.join)(workspace, relative3);
|
|
9373
|
+
if (!(0, import_fs4.existsSync)(configPath)) continue;
|
|
9374
|
+
try {
|
|
9375
|
+
const parsed = parseConfigText2(configPath, (0, import_fs4.readFileSync)(configPath, "utf-8"));
|
|
9376
|
+
const validation = validateMeshWorktreeBootstrapConfig(parsed, relative3);
|
|
9377
|
+
if (!validation.valid) return { source: relative3, sourceType: "invalid", path: configPath, error: String(validation.rejectedCommands[0]?.reason || validation.errors.join("; ")) };
|
|
9378
|
+
return { config: parsed, source: relative3, sourceType: "repo_file", path: configPath };
|
|
9379
|
+
} catch (error) {
|
|
9380
|
+
return { source: relative3, sourceType: "invalid", path: configPath, error: error?.message || String(error) };
|
|
9381
|
+
}
|
|
9382
|
+
}
|
|
9383
|
+
return { source: "unavailable", sourceType: "unavailable", error: `No worktree bootstrap config found. Checked: ${MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS.join(", ")}` };
|
|
9384
|
+
}
|
|
9385
|
+
async function runMeshWorktreeBootstrap(mesh, workspace) {
|
|
9386
|
+
const loaded = loadMeshWorktreeBootstrapConfig(mesh, workspace);
|
|
9387
|
+
if (!loaded.config) {
|
|
9388
|
+
return { status: "not_configured", required: false, configSource: loaded.source, configSourceType: loaded.sourceType, error: loaded.error };
|
|
9389
|
+
}
|
|
9390
|
+
const required = loaded.config.required !== false;
|
|
9391
|
+
if (loaded.config.enabled === false || loaded.config.runOnClone === false) {
|
|
9392
|
+
return { status: "disabled", required, configSource: loaded.path || loaded.source, configSourceType: loaded.sourceType };
|
|
9393
|
+
}
|
|
9394
|
+
const validation = validateMeshWorktreeBootstrapConfig(loaded.config, loaded.source);
|
|
9395
|
+
if (!validation.valid) {
|
|
9396
|
+
return { status: "failed", required, configSource: loaded.path || loaded.source, configSourceType: "invalid", error: String(validation.rejectedCommands[0]?.reason || validation.errors.join("; ")), commandsRun: [] };
|
|
9397
|
+
}
|
|
9398
|
+
const execFileAsync3 = (0, import_node_util3.promisify)(import_node_child_process3.execFile);
|
|
9399
|
+
const state = {
|
|
9400
|
+
status: "running",
|
|
9401
|
+
required,
|
|
9402
|
+
configSource: loaded.path || loaded.source,
|
|
9403
|
+
configSourceType: loaded.sourceType,
|
|
9404
|
+
startedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
9405
|
+
commandsRun: [],
|
|
9406
|
+
staleInputs: loaded.config.staleInputs
|
|
9407
|
+
};
|
|
9408
|
+
for (const command of validation.commands) {
|
|
9409
|
+
const cwd = command.cwd ? (0, import_path4.resolve)(workspace, command.cwd) : workspace;
|
|
9410
|
+
const startedAt = Date.now();
|
|
9411
|
+
state.lastCommand = command.displayCommand;
|
|
9412
|
+
try {
|
|
9413
|
+
const result = await execFileAsync3(command.command, command.args, {
|
|
9414
|
+
cwd,
|
|
9415
|
+
encoding: "utf8",
|
|
9416
|
+
timeout: command.timeoutMs || DEFAULT_TIMEOUT_MS2,
|
|
9417
|
+
maxBuffer: command.outputLimitBytes || DEFAULT_OUTPUT_LIMIT_BYTES,
|
|
9418
|
+
env: { ...process.env, CI: process.env.CI || "1", ...command.env || {} },
|
|
9419
|
+
windowsHide: true
|
|
9420
|
+
});
|
|
9421
|
+
state.commandsRun?.push({
|
|
9422
|
+
command: command.command,
|
|
9423
|
+
args: command.args,
|
|
9424
|
+
displayCommand: command.displayCommand,
|
|
9425
|
+
category: command.category,
|
|
9426
|
+
source: command.source,
|
|
9427
|
+
cwd,
|
|
9428
|
+
passed: true,
|
|
9429
|
+
durationMs: Date.now() - startedAt,
|
|
9430
|
+
exitCode: 0,
|
|
9431
|
+
stdout: truncateOutput(result.stdout),
|
|
9432
|
+
stderr: truncateOutput(result.stderr)
|
|
9433
|
+
});
|
|
9434
|
+
} catch (error) {
|
|
9435
|
+
const exitCode = typeof error?.code === "number" ? error.code : null;
|
|
9436
|
+
state.status = "failed";
|
|
9437
|
+
state.exitCode = exitCode;
|
|
9438
|
+
state.error = error?.message || String(error);
|
|
9439
|
+
state.completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
9440
|
+
state.commandsRun?.push({
|
|
9441
|
+
command: command.command,
|
|
9442
|
+
args: command.args,
|
|
9443
|
+
displayCommand: command.displayCommand,
|
|
9444
|
+
category: command.category,
|
|
9445
|
+
source: command.source,
|
|
9446
|
+
cwd,
|
|
9447
|
+
passed: false,
|
|
9448
|
+
durationMs: Date.now() - startedAt,
|
|
9449
|
+
exitCode,
|
|
9450
|
+
signal: typeof error?.signal === "string" ? error.signal : null,
|
|
9451
|
+
timedOut: error?.killed === true || /timed out/i.test(String(error?.message || "")),
|
|
9452
|
+
stdout: truncateOutput(error?.stdout),
|
|
9453
|
+
stderr: truncateOutput(error?.stderr || error?.message)
|
|
9454
|
+
});
|
|
9455
|
+
return state;
|
|
9456
|
+
}
|
|
9457
|
+
}
|
|
9458
|
+
state.status = "ready";
|
|
9459
|
+
state.exitCode = 0;
|
|
9460
|
+
state.completedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
9461
|
+
return state;
|
|
9462
|
+
}
|
|
9463
|
+
|
|
9256
9464
|
// src/mesh/mesh-sync.ts
|
|
9257
9465
|
init_mesh_config();
|
|
9258
9466
|
async function syncMeshes(transport) {
|
|
@@ -9904,6 +10112,134 @@ function buildMeshActiveWork(opts) {
|
|
|
9904
10112
|
}
|
|
9905
10113
|
return { activeWork: records, staleDirectWork, staleDirectWorkNote, terminalDirectWork, summary };
|
|
9906
10114
|
}
|
|
10115
|
+
function buildCompactStaleDirectWorkSummary(staleDirectWork, opts = {}) {
|
|
10116
|
+
const sampleLimit = Math.max(0, Math.min(10, Math.floor(opts.sampleLimit ?? 3)));
|
|
10117
|
+
const reasonCounts = {};
|
|
10118
|
+
for (const entry of staleDirectWork) {
|
|
10119
|
+
const reason = entry.staleReason || "unknown";
|
|
10120
|
+
reasonCounts[reason] = (reasonCounts[reason] || 0) + 1;
|
|
10121
|
+
}
|
|
10122
|
+
return {
|
|
10123
|
+
count: staleDirectWork.length,
|
|
10124
|
+
sampleLimit,
|
|
10125
|
+
sample: staleDirectWork.slice(0, sampleLimit).map((entry) => ({
|
|
10126
|
+
taskId: entry.taskId,
|
|
10127
|
+
status: entry.status,
|
|
10128
|
+
nodeId: entry.nodeId,
|
|
10129
|
+
sessionId: entry.sessionId,
|
|
10130
|
+
taskTitle: entry.taskTitle,
|
|
10131
|
+
createdAt: entry.createdAt,
|
|
10132
|
+
staleReason: entry.staleReason
|
|
10133
|
+
})),
|
|
10134
|
+
reasonCounts,
|
|
10135
|
+
detailHint: opts.detailHint || "Stale direct records are historical recovery evidence only. Use mesh_task_history for full ledger details, or request includeStaleDirectWorkDetails when supported by the caller.",
|
|
10136
|
+
...opts.note ? { note: opts.note } : {}
|
|
10137
|
+
};
|
|
10138
|
+
}
|
|
10139
|
+
|
|
10140
|
+
// src/mesh/mesh-refine-status.ts
|
|
10141
|
+
function readString3(value) {
|
|
10142
|
+
return typeof value === "string" && value.trim() ? value.trim() : void 0;
|
|
10143
|
+
}
|
|
10144
|
+
function readRecord(value) {
|
|
10145
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : void 0;
|
|
10146
|
+
}
|
|
10147
|
+
function eventStatus(event, fallback) {
|
|
10148
|
+
if (event === "refine:accepted") return "accepted";
|
|
10149
|
+
if (event === "refine:completed") return "completed";
|
|
10150
|
+
if (event === "refine:failed") return "failed";
|
|
10151
|
+
if (fallback === "completed" || fallback === "failed" || fallback === "accepted") return fallback;
|
|
10152
|
+
return void 0;
|
|
10153
|
+
}
|
|
10154
|
+
function ledgerStatus(kind, fallback) {
|
|
10155
|
+
if (kind === "task_completed") return "completed";
|
|
10156
|
+
if (kind === "task_failed") return "failed";
|
|
10157
|
+
if (fallback === "accepted") return "accepted";
|
|
10158
|
+
return "running";
|
|
10159
|
+
}
|
|
10160
|
+
function instructionForStatus(status) {
|
|
10161
|
+
if (status === "accepted") return "Refine job is accepted; wait for asyncRefineJobs or pendingCoordinatorEvents to report running/completed/failed.";
|
|
10162
|
+
if (status === "running") return "Refine job is running; do not poll the ledger repeatedly. Watch asyncRefineJobs or pendingCoordinatorEvents for the terminal result.";
|
|
10163
|
+
if (status === "completed") return "Refine job completed; inspect branch convergence and cleanup evidence before reporting final merge state.";
|
|
10164
|
+
return "Refine job failed; inspect result/finalBranchConvergenceState in mesh_task_history, fix the blocker, then rerun mesh_refine_node when ready.";
|
|
10165
|
+
}
|
|
10166
|
+
function mergeJob(jobs, patch) {
|
|
10167
|
+
const jobId = readString3(patch.jobId);
|
|
10168
|
+
if (!jobId) return;
|
|
10169
|
+
const previous = jobs.get(jobId);
|
|
10170
|
+
const status = patch.status || previous?.status || "running";
|
|
10171
|
+
const definedPatch = Object.fromEntries(
|
|
10172
|
+
Object.entries(patch).filter(([, value]) => value !== void 0)
|
|
10173
|
+
);
|
|
10174
|
+
jobs.set(jobId, {
|
|
10175
|
+
...previous,
|
|
10176
|
+
...definedPatch,
|
|
10177
|
+
jobId,
|
|
10178
|
+
status,
|
|
10179
|
+
instruction: instructionForStatus(status)
|
|
10180
|
+
});
|
|
10181
|
+
}
|
|
10182
|
+
function buildMeshAsyncRefineJobs(args) {
|
|
10183
|
+
const jobs = /* @__PURE__ */ new Map();
|
|
10184
|
+
for (const entry of args.ledgerEntries || []) {
|
|
10185
|
+
const payload = readRecord(entry.payload);
|
|
10186
|
+
if (payload?.source !== "refine_mesh_node_async_job") continue;
|
|
10187
|
+
const refineJob = readRecord(payload.refineJob);
|
|
10188
|
+
const result = readRecord(payload.result);
|
|
10189
|
+
const finalState = readRecord(payload.finalBranchConvergenceState) || readRecord(result?.finalBranchConvergenceState);
|
|
10190
|
+
const jobId = readString3(refineJob?.jobId);
|
|
10191
|
+
if (!jobId) continue;
|
|
10192
|
+
const status = ledgerStatus(entry.kind, readString3(refineJob?.status));
|
|
10193
|
+
mergeJob(jobs, {
|
|
10194
|
+
jobId,
|
|
10195
|
+
interactionId: readString3(refineJob?.interactionId),
|
|
10196
|
+
status,
|
|
10197
|
+
meshId: readString3(refineJob?.meshId) || args.meshId,
|
|
10198
|
+
nodeId: readString3(refineJob?.nodeId) || entry.nodeId,
|
|
10199
|
+
targetNodeId: readString3(refineJob?.nodeId) || entry.nodeId,
|
|
10200
|
+
targetDaemonId: readString3(refineJob?.targetDaemonId),
|
|
10201
|
+
workspace: readString3(refineJob?.workspace),
|
|
10202
|
+
branch: readString3(result?.branch) || readString3(finalState?.branch),
|
|
10203
|
+
into: readString3(result?.into) || readString3(finalState?.baseBranch),
|
|
10204
|
+
startedAt: readString3(refineJob?.startedAt),
|
|
10205
|
+
completedAt: readString3(refineJob?.completedAt),
|
|
10206
|
+
retryOfJobId: readString3(refineJob?.retryOfJobId) || readString3(payload.retryOfJobId),
|
|
10207
|
+
lastLedgerKind: entry.kind,
|
|
10208
|
+
lastUpdatedAt: entry.timestamp
|
|
10209
|
+
});
|
|
10210
|
+
}
|
|
10211
|
+
for (const event of args.pendingEvents || []) {
|
|
10212
|
+
const metadata = readRecord(event.metadataEvent);
|
|
10213
|
+
if (metadata?.source !== "refine_mesh_node_async_job") continue;
|
|
10214
|
+
const result = readRecord(metadata.result);
|
|
10215
|
+
const finalState = readRecord(result?.finalBranchConvergenceState);
|
|
10216
|
+
const jobId = readString3(metadata.jobId);
|
|
10217
|
+
if (!jobId) continue;
|
|
10218
|
+
const status = eventStatus(event.event, readString3(metadata.status));
|
|
10219
|
+
mergeJob(jobs, {
|
|
10220
|
+
jobId,
|
|
10221
|
+
interactionId: readString3(metadata.interactionId),
|
|
10222
|
+
...status ? { status } : {},
|
|
10223
|
+
meshId: readString3(metadata.meshId) || event.meshId || args.meshId,
|
|
10224
|
+
nodeId: readString3(metadata.nodeId) || event.nodeId,
|
|
10225
|
+
targetNodeId: readString3(metadata.nodeId) || event.nodeId,
|
|
10226
|
+
targetDaemonId: readString3(metadata.targetDaemonId),
|
|
10227
|
+
workspace: readString3(metadata.workspace) || event.workspace,
|
|
10228
|
+
branch: readString3(result?.branch) || readString3(finalState?.branch),
|
|
10229
|
+
into: readString3(result?.into) || readString3(finalState?.baseBranch),
|
|
10230
|
+
startedAt: readString3(metadata.startedAt),
|
|
10231
|
+
completedAt: readString3(metadata.completedAt),
|
|
10232
|
+
retryOfJobId: readString3(metadata.retryOfJobId),
|
|
10233
|
+
lastEvent: event.event,
|
|
10234
|
+
lastUpdatedAt: new Date(event.queuedAt).toISOString()
|
|
10235
|
+
});
|
|
10236
|
+
}
|
|
10237
|
+
return Array.from(jobs.values()).sort((a, b) => {
|
|
10238
|
+
const aTime = new Date(a.lastUpdatedAt || a.startedAt || "").getTime();
|
|
10239
|
+
const bTime = new Date(b.lastUpdatedAt || b.startedAt || "").getTime();
|
|
10240
|
+
return (Number.isFinite(bTime) ? bTime : 0) - (Number.isFinite(aTime) ? aTime : 0);
|
|
10241
|
+
});
|
|
10242
|
+
}
|
|
9907
10243
|
|
|
9908
10244
|
// src/index.ts
|
|
9909
10245
|
init_mesh_host_ownership();
|
|
@@ -10020,8 +10356,8 @@ var P2pRelayFailureError = class extends Error {
|
|
|
10020
10356
|
};
|
|
10021
10357
|
|
|
10022
10358
|
// src/config/state-store.ts
|
|
10023
|
-
var
|
|
10024
|
-
var
|
|
10359
|
+
var import_fs9 = require("fs");
|
|
10360
|
+
var import_path8 = require("path");
|
|
10025
10361
|
init_config();
|
|
10026
10362
|
var DEFAULT_STATE = {
|
|
10027
10363
|
recentActivity: [],
|
|
@@ -10035,7 +10371,7 @@ function isPlainObject2(value) {
|
|
|
10035
10371
|
return !!value && typeof value === "object" && !Array.isArray(value);
|
|
10036
10372
|
}
|
|
10037
10373
|
function getStatePath() {
|
|
10038
|
-
return (0,
|
|
10374
|
+
return (0, import_path8.join)(getConfigDir(), "state.json");
|
|
10039
10375
|
}
|
|
10040
10376
|
function normalizeState(raw) {
|
|
10041
10377
|
const parsed = isPlainObject2(raw) ? raw : {};
|
|
@@ -10071,11 +10407,11 @@ function normalizeState(raw) {
|
|
|
10071
10407
|
}
|
|
10072
10408
|
function loadState() {
|
|
10073
10409
|
const statePath = getStatePath();
|
|
10074
|
-
if (!(0,
|
|
10410
|
+
if (!(0, import_fs9.existsSync)(statePath)) {
|
|
10075
10411
|
return { ...DEFAULT_STATE };
|
|
10076
10412
|
}
|
|
10077
10413
|
try {
|
|
10078
|
-
const raw = (0,
|
|
10414
|
+
const raw = (0, import_fs9.readFileSync)(statePath, "utf-8");
|
|
10079
10415
|
return normalizeState(JSON.parse(raw));
|
|
10080
10416
|
} catch {
|
|
10081
10417
|
return { ...DEFAULT_STATE };
|
|
@@ -10084,7 +10420,7 @@ function loadState() {
|
|
|
10084
10420
|
function saveState(state) {
|
|
10085
10421
|
const statePath = getStatePath();
|
|
10086
10422
|
const normalized = normalizeState(state);
|
|
10087
|
-
(0,
|
|
10423
|
+
(0, import_fs9.writeFileSync)(statePath, JSON.stringify(normalized, null, 2), { encoding: "utf-8", mode: 384 });
|
|
10088
10424
|
}
|
|
10089
10425
|
function resetState() {
|
|
10090
10426
|
saveState({ ...DEFAULT_STATE });
|
|
@@ -10093,7 +10429,7 @@ function resetState() {
|
|
|
10093
10429
|
// src/detection/ide-detector.ts
|
|
10094
10430
|
var import_child_process2 = require("child_process");
|
|
10095
10431
|
var import_util = require("util");
|
|
10096
|
-
var
|
|
10432
|
+
var import_fs10 = require("fs");
|
|
10097
10433
|
var import_os2 = require("os");
|
|
10098
10434
|
var path10 = __toESM(require("path"));
|
|
10099
10435
|
var execAsync2 = (0, import_util.promisify)(import_child_process2.exec);
|
|
@@ -10118,7 +10454,7 @@ function findCliCommand(command) {
|
|
|
10118
10454
|
if (path10.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~")) {
|
|
10119
10455
|
const candidate = trimmed.startsWith("~") ? path10.join((0, import_os2.homedir)(), trimmed.slice(1)) : trimmed;
|
|
10120
10456
|
const resolved = path10.isAbsolute(candidate) ? candidate : path10.resolve(candidate);
|
|
10121
|
-
return (0,
|
|
10457
|
+
return (0, import_fs10.existsSync)(resolved) ? resolved : null;
|
|
10122
10458
|
}
|
|
10123
10459
|
const isWin = (0, import_os2.platform)() === "win32";
|
|
10124
10460
|
const paths = (process.env.PATH || "").split(isWin ? ";" : ":");
|
|
@@ -10128,8 +10464,8 @@ function findCliCommand(command) {
|
|
|
10128
10464
|
for (const ext of exes) {
|
|
10129
10465
|
const fullPath = path10.join(p, trimmed + ext);
|
|
10130
10466
|
try {
|
|
10131
|
-
if ((0,
|
|
10132
|
-
const stat2 = (0,
|
|
10467
|
+
if ((0, import_fs10.existsSync)(fullPath)) {
|
|
10468
|
+
const stat2 = (0, import_fs10.statSync)(fullPath);
|
|
10133
10469
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
10134
10470
|
return fullPath;
|
|
10135
10471
|
}
|
|
@@ -10158,9 +10494,9 @@ function checkPathExists(paths) {
|
|
|
10158
10494
|
if (normalized.includes("*")) {
|
|
10159
10495
|
const username = home.split(/[\\/]/).pop() || "";
|
|
10160
10496
|
const resolved = normalized.replace("*", username);
|
|
10161
|
-
if ((0,
|
|
10497
|
+
if ((0, import_fs10.existsSync)(resolved)) return resolved;
|
|
10162
10498
|
} else {
|
|
10163
|
-
if ((0,
|
|
10499
|
+
if ((0, import_fs10.existsSync)(normalized)) return normalized;
|
|
10164
10500
|
}
|
|
10165
10501
|
}
|
|
10166
10502
|
return null;
|
|
@@ -10174,7 +10510,7 @@ async function detectIDEs(providerLoader) {
|
|
|
10174
10510
|
let resolvedCli = cliPath;
|
|
10175
10511
|
if (!resolvedCli && appPath && os22 === "darwin") {
|
|
10176
10512
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
10177
|
-
if ((0,
|
|
10513
|
+
if ((0, import_fs10.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
10178
10514
|
}
|
|
10179
10515
|
if (!resolvedCli && appPath && os22 === "win32") {
|
|
10180
10516
|
const { dirname: dirname9 } = await import("path");
|
|
@@ -10187,7 +10523,7 @@ async function detectIDEs(providerLoader) {
|
|
|
10187
10523
|
`${appDir}\\\\resources\\\\app\\\\bin\\\\${def.cli}.cmd`
|
|
10188
10524
|
];
|
|
10189
10525
|
for (const c of candidates) {
|
|
10190
|
-
if ((0,
|
|
10526
|
+
if ((0, import_fs10.existsSync)(c)) {
|
|
10191
10527
|
resolvedCli = c;
|
|
10192
10528
|
break;
|
|
10193
10529
|
}
|
|
@@ -10503,7 +10839,7 @@ var DaemonCdpManager = class {
|
|
|
10503
10839
|
* Returns multiple entries if multiple IDE windows are open on same port
|
|
10504
10840
|
*/
|
|
10505
10841
|
static listAllTargets(port) {
|
|
10506
|
-
return new Promise((
|
|
10842
|
+
return new Promise((resolve17) => {
|
|
10507
10843
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
10508
10844
|
let data = "";
|
|
10509
10845
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -10519,16 +10855,16 @@ var DaemonCdpManager = class {
|
|
|
10519
10855
|
(t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
|
|
10520
10856
|
);
|
|
10521
10857
|
const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
|
|
10522
|
-
|
|
10858
|
+
resolve17(mainPages.length > 0 ? mainPages : fallbackPages);
|
|
10523
10859
|
} catch {
|
|
10524
|
-
|
|
10860
|
+
resolve17([]);
|
|
10525
10861
|
}
|
|
10526
10862
|
});
|
|
10527
10863
|
});
|
|
10528
|
-
req.on("error", () =>
|
|
10864
|
+
req.on("error", () => resolve17([]));
|
|
10529
10865
|
req.setTimeout(2e3, () => {
|
|
10530
10866
|
req.destroy();
|
|
10531
|
-
|
|
10867
|
+
resolve17([]);
|
|
10532
10868
|
});
|
|
10533
10869
|
});
|
|
10534
10870
|
}
|
|
@@ -10568,7 +10904,7 @@ var DaemonCdpManager = class {
|
|
|
10568
10904
|
}
|
|
10569
10905
|
}
|
|
10570
10906
|
findTargetOnPort(port) {
|
|
10571
|
-
return new Promise((
|
|
10907
|
+
return new Promise((resolve17) => {
|
|
10572
10908
|
const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
|
|
10573
10909
|
let data = "";
|
|
10574
10910
|
res.on("data", (chunk) => data += chunk.toString());
|
|
@@ -10579,7 +10915,7 @@ var DaemonCdpManager = class {
|
|
|
10579
10915
|
(t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
|
|
10580
10916
|
);
|
|
10581
10917
|
if (pages.length === 0) {
|
|
10582
|
-
|
|
10918
|
+
resolve17(targets.find((t) => t.webSocketDebuggerUrl) || null);
|
|
10583
10919
|
return;
|
|
10584
10920
|
}
|
|
10585
10921
|
const titleFilteredPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
|
|
@@ -10598,25 +10934,25 @@ var DaemonCdpManager = class {
|
|
|
10598
10934
|
this._targetId = selected.target.id;
|
|
10599
10935
|
}
|
|
10600
10936
|
this._pageTitle = selected.target.title || "";
|
|
10601
|
-
|
|
10937
|
+
resolve17(selected.target);
|
|
10602
10938
|
return;
|
|
10603
10939
|
}
|
|
10604
10940
|
if (previousTargetId) {
|
|
10605
10941
|
this.log(`[CDP] Target ${previousTargetId} not found in page list`);
|
|
10606
|
-
|
|
10942
|
+
resolve17(null);
|
|
10607
10943
|
return;
|
|
10608
10944
|
}
|
|
10609
10945
|
this._pageTitle = list[0]?.title || "";
|
|
10610
|
-
|
|
10946
|
+
resolve17(list[0]);
|
|
10611
10947
|
} catch {
|
|
10612
|
-
|
|
10948
|
+
resolve17(null);
|
|
10613
10949
|
}
|
|
10614
10950
|
});
|
|
10615
10951
|
});
|
|
10616
|
-
req.on("error", () =>
|
|
10952
|
+
req.on("error", () => resolve17(null));
|
|
10617
10953
|
req.setTimeout(2e3, () => {
|
|
10618
10954
|
req.destroy();
|
|
10619
|
-
|
|
10955
|
+
resolve17(null);
|
|
10620
10956
|
});
|
|
10621
10957
|
});
|
|
10622
10958
|
}
|
|
@@ -10627,7 +10963,7 @@ var DaemonCdpManager = class {
|
|
|
10627
10963
|
this.extensionProviders = providers;
|
|
10628
10964
|
}
|
|
10629
10965
|
connectToTarget(wsUrl) {
|
|
10630
|
-
return new Promise((
|
|
10966
|
+
return new Promise((resolve17) => {
|
|
10631
10967
|
this.ws = new import_ws.default(wsUrl);
|
|
10632
10968
|
this.ws.on("open", async () => {
|
|
10633
10969
|
this._connected = true;
|
|
@@ -10637,17 +10973,17 @@ var DaemonCdpManager = class {
|
|
|
10637
10973
|
}
|
|
10638
10974
|
this.connectBrowserWs().catch(() => {
|
|
10639
10975
|
});
|
|
10640
|
-
|
|
10976
|
+
resolve17(true);
|
|
10641
10977
|
});
|
|
10642
10978
|
this.ws.on("message", (data) => {
|
|
10643
10979
|
try {
|
|
10644
10980
|
const msg = JSON.parse(data.toString());
|
|
10645
10981
|
if (msg.id && this.pending.has(msg.id)) {
|
|
10646
|
-
const { resolve:
|
|
10982
|
+
const { resolve: resolve18, reject } = this.pending.get(msg.id);
|
|
10647
10983
|
this.pending.delete(msg.id);
|
|
10648
10984
|
this.failureCount = 0;
|
|
10649
10985
|
if (msg.error) reject(new Error(msg.error.message));
|
|
10650
|
-
else
|
|
10986
|
+
else resolve18(msg.result);
|
|
10651
10987
|
} else if (msg.method === "Runtime.executionContextCreated") {
|
|
10652
10988
|
this.contexts.add(msg.params.context.id);
|
|
10653
10989
|
} else if (msg.method === "Runtime.executionContextDestroyed") {
|
|
@@ -10670,7 +11006,7 @@ var DaemonCdpManager = class {
|
|
|
10670
11006
|
this.ws.on("error", (err) => {
|
|
10671
11007
|
this.log(`[CDP] WebSocket error: ${err.message}`);
|
|
10672
11008
|
this._connected = false;
|
|
10673
|
-
|
|
11009
|
+
resolve17(false);
|
|
10674
11010
|
});
|
|
10675
11011
|
});
|
|
10676
11012
|
}
|
|
@@ -10684,7 +11020,7 @@ var DaemonCdpManager = class {
|
|
|
10684
11020
|
return;
|
|
10685
11021
|
}
|
|
10686
11022
|
this.log(`[CDP] Connecting browser WS for target discovery...`);
|
|
10687
|
-
await new Promise((
|
|
11023
|
+
await new Promise((resolve17, reject) => {
|
|
10688
11024
|
this.browserWs = new import_ws.default(browserWsUrl);
|
|
10689
11025
|
this.browserWs.on("open", async () => {
|
|
10690
11026
|
this._browserConnected = true;
|
|
@@ -10694,16 +11030,16 @@ var DaemonCdpManager = class {
|
|
|
10694
11030
|
} catch (e) {
|
|
10695
11031
|
this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
|
|
10696
11032
|
}
|
|
10697
|
-
|
|
11033
|
+
resolve17();
|
|
10698
11034
|
});
|
|
10699
11035
|
this.browserWs.on("message", (data) => {
|
|
10700
11036
|
try {
|
|
10701
11037
|
const msg = JSON.parse(data.toString());
|
|
10702
11038
|
if (msg.id && this.browserPending.has(msg.id)) {
|
|
10703
|
-
const { resolve:
|
|
11039
|
+
const { resolve: resolve18, reject: reject2 } = this.browserPending.get(msg.id);
|
|
10704
11040
|
this.browserPending.delete(msg.id);
|
|
10705
11041
|
if (msg.error) reject2(new Error(msg.error.message));
|
|
10706
|
-
else
|
|
11042
|
+
else resolve18(msg.result);
|
|
10707
11043
|
}
|
|
10708
11044
|
} catch {
|
|
10709
11045
|
}
|
|
@@ -10723,31 +11059,31 @@ var DaemonCdpManager = class {
|
|
|
10723
11059
|
}
|
|
10724
11060
|
}
|
|
10725
11061
|
getBrowserWsUrl() {
|
|
10726
|
-
return new Promise((
|
|
11062
|
+
return new Promise((resolve17) => {
|
|
10727
11063
|
const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
|
|
10728
11064
|
let data = "";
|
|
10729
11065
|
res.on("data", (chunk) => data += chunk.toString());
|
|
10730
11066
|
res.on("end", () => {
|
|
10731
11067
|
try {
|
|
10732
11068
|
const info = JSON.parse(data);
|
|
10733
|
-
|
|
11069
|
+
resolve17(info.webSocketDebuggerUrl || null);
|
|
10734
11070
|
} catch {
|
|
10735
|
-
|
|
11071
|
+
resolve17(null);
|
|
10736
11072
|
}
|
|
10737
11073
|
});
|
|
10738
11074
|
});
|
|
10739
|
-
req.on("error", () =>
|
|
11075
|
+
req.on("error", () => resolve17(null));
|
|
10740
11076
|
req.setTimeout(3e3, () => {
|
|
10741
11077
|
req.destroy();
|
|
10742
|
-
|
|
11078
|
+
resolve17(null);
|
|
10743
11079
|
});
|
|
10744
11080
|
});
|
|
10745
11081
|
}
|
|
10746
11082
|
sendBrowser(method, params = {}, timeoutMs = 15e3) {
|
|
10747
|
-
return new Promise((
|
|
11083
|
+
return new Promise((resolve17, reject) => {
|
|
10748
11084
|
if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
|
|
10749
11085
|
const id = this.browserMsgId++;
|
|
10750
|
-
this.browserPending.set(id, { resolve:
|
|
11086
|
+
this.browserPending.set(id, { resolve: resolve17, reject });
|
|
10751
11087
|
this.browserWs.send(JSON.stringify({ id, method, params }));
|
|
10752
11088
|
setTimeout(() => {
|
|
10753
11089
|
if (this.browserPending.has(id)) {
|
|
@@ -10787,11 +11123,11 @@ var DaemonCdpManager = class {
|
|
|
10787
11123
|
}
|
|
10788
11124
|
// ─── CDP Protocol ────────────────────────────────────────
|
|
10789
11125
|
sendInternal(method, params = {}, timeoutMs = 15e3) {
|
|
10790
|
-
return new Promise((
|
|
11126
|
+
return new Promise((resolve17, reject) => {
|
|
10791
11127
|
if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
|
|
10792
11128
|
if (this.ws.readyState !== import_ws.default.OPEN) return reject(new Error("WebSocket not open"));
|
|
10793
11129
|
const id = this.msgId++;
|
|
10794
|
-
this.pending.set(id, { resolve:
|
|
11130
|
+
this.pending.set(id, { resolve: resolve17, reject });
|
|
10795
11131
|
this.ws.send(JSON.stringify({ id, method, params }));
|
|
10796
11132
|
setTimeout(() => {
|
|
10797
11133
|
if (this.pending.has(id)) {
|
|
@@ -11040,7 +11376,7 @@ var DaemonCdpManager = class {
|
|
|
11040
11376
|
const browserWs = this.browserWs;
|
|
11041
11377
|
let msgId = this.browserMsgId;
|
|
11042
11378
|
const sendWs = (method, params = {}, sessionId) => {
|
|
11043
|
-
return new Promise((
|
|
11379
|
+
return new Promise((resolve17, reject) => {
|
|
11044
11380
|
const mid = msgId++;
|
|
11045
11381
|
this.browserMsgId = msgId;
|
|
11046
11382
|
const handler = (raw) => {
|
|
@@ -11049,7 +11385,7 @@ var DaemonCdpManager = class {
|
|
|
11049
11385
|
if (msg.id === mid) {
|
|
11050
11386
|
browserWs.removeListener("message", handler);
|
|
11051
11387
|
if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
|
|
11052
|
-
else
|
|
11388
|
+
else resolve17(msg.result);
|
|
11053
11389
|
}
|
|
11054
11390
|
} catch {
|
|
11055
11391
|
}
|
|
@@ -11250,14 +11586,14 @@ var DaemonCdpManager = class {
|
|
|
11250
11586
|
if (!ws || ws.readyState !== import_ws.default.OPEN) {
|
|
11251
11587
|
throw new Error("CDP not connected");
|
|
11252
11588
|
}
|
|
11253
|
-
return new Promise((
|
|
11589
|
+
return new Promise((resolve17, reject) => {
|
|
11254
11590
|
const id = getNextId();
|
|
11255
11591
|
pendingMap.set(id, {
|
|
11256
11592
|
resolve: (result) => {
|
|
11257
11593
|
if (result?.result?.subtype === "error") {
|
|
11258
11594
|
reject(new Error(result.result.description));
|
|
11259
11595
|
} else {
|
|
11260
|
-
|
|
11596
|
+
resolve17(result?.result?.value);
|
|
11261
11597
|
}
|
|
11262
11598
|
},
|
|
11263
11599
|
reject
|
|
@@ -11289,10 +11625,10 @@ var DaemonCdpManager = class {
|
|
|
11289
11625
|
throw new Error("CDP not connected");
|
|
11290
11626
|
}
|
|
11291
11627
|
const sendViaSession = (method, params = {}) => {
|
|
11292
|
-
return new Promise((
|
|
11628
|
+
return new Promise((resolve17, reject) => {
|
|
11293
11629
|
const pendingMap = this._browserConnected ? this.browserPending : this.pending;
|
|
11294
11630
|
const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
|
|
11295
|
-
pendingMap.set(id, { resolve:
|
|
11631
|
+
pendingMap.set(id, { resolve: resolve17, reject });
|
|
11296
11632
|
ws.send(JSON.stringify({ id, sessionId, method, params }));
|
|
11297
11633
|
setTimeout(() => {
|
|
11298
11634
|
if (pendingMap.has(id)) {
|
|
@@ -16394,7 +16730,7 @@ function getSendChatInputEnvelope(args) {
|
|
|
16394
16730
|
return normalizeInputEnvelope(args?.input ? { input: args.input } : args);
|
|
16395
16731
|
}
|
|
16396
16732
|
function sleep(ms) {
|
|
16397
|
-
return new Promise((
|
|
16733
|
+
return new Promise((resolve17) => setTimeout(resolve17, ms));
|
|
16398
16734
|
}
|
|
16399
16735
|
async function waitOnceForFreshHermesCliStart(adapter, log) {
|
|
16400
16736
|
if (adapter.cliType !== "hermes-cli") return;
|
|
@@ -17181,7 +17517,7 @@ function getCliVisibleTranscriptCount(adapter) {
|
|
|
17181
17517
|
async function getStableExtensionBaseline(h) {
|
|
17182
17518
|
const first = await readExtensionChatState(h);
|
|
17183
17519
|
if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
|
|
17184
|
-
await new Promise((
|
|
17520
|
+
await new Promise((resolve17) => setTimeout(resolve17, 150));
|
|
17185
17521
|
const second = await readExtensionChatState(h);
|
|
17186
17522
|
return getStateMessageCount(second) >= getStateMessageCount(first) ? second : first;
|
|
17187
17523
|
}
|
|
@@ -17189,7 +17525,7 @@ async function verifyExtensionSendObserved(h, before) {
|
|
|
17189
17525
|
const beforeCount = getStateMessageCount(before);
|
|
17190
17526
|
const beforeSignature = getStateLastSignature(before);
|
|
17191
17527
|
for (let attempt = 0; attempt < 12; attempt += 1) {
|
|
17192
|
-
await new Promise((
|
|
17528
|
+
await new Promise((resolve17) => setTimeout(resolve17, 250));
|
|
17193
17529
|
const state = await readExtensionChatState(h);
|
|
17194
17530
|
if (state?.status === "waiting_approval") return true;
|
|
17195
17531
|
const afterCount = getStateMessageCount(state);
|
|
@@ -19078,7 +19414,7 @@ async function executeProviderScript(h, args, scriptName) {
|
|
|
19078
19414
|
const enterCount = cliCommand.enterCount || 1;
|
|
19079
19415
|
await adapter.writeRaw(cliCommand.text + "\r");
|
|
19080
19416
|
for (let i = 1; i < enterCount; i += 1) {
|
|
19081
|
-
await new Promise((
|
|
19417
|
+
await new Promise((resolve17) => setTimeout(resolve17, 50));
|
|
19082
19418
|
await adapter.writeRaw("\r");
|
|
19083
19419
|
}
|
|
19084
19420
|
}
|
|
@@ -19767,7 +20103,7 @@ var DaemonCommandHandler = class {
|
|
|
19767
20103
|
try {
|
|
19768
20104
|
const http3 = await import("http");
|
|
19769
20105
|
const postData = JSON.stringify(body);
|
|
19770
|
-
const result = await new Promise((
|
|
20106
|
+
const result = await new Promise((resolve17, reject) => {
|
|
19771
20107
|
const req = http3.request({
|
|
19772
20108
|
hostname: "127.0.0.1",
|
|
19773
20109
|
port: 19280,
|
|
@@ -19779,9 +20115,9 @@ var DaemonCommandHandler = class {
|
|
|
19779
20115
|
res.on("data", (chunk) => data += chunk);
|
|
19780
20116
|
res.on("end", () => {
|
|
19781
20117
|
try {
|
|
19782
|
-
|
|
20118
|
+
resolve17(JSON.parse(data));
|
|
19783
20119
|
} catch {
|
|
19784
|
-
|
|
20120
|
+
resolve17({ raw: data });
|
|
19785
20121
|
}
|
|
19786
20122
|
});
|
|
19787
20123
|
});
|
|
@@ -19799,15 +20135,15 @@ var DaemonCommandHandler = class {
|
|
|
19799
20135
|
if (!providerType) return { success: false, error: "providerType required" };
|
|
19800
20136
|
try {
|
|
19801
20137
|
const http3 = await import("http");
|
|
19802
|
-
const result = await new Promise((
|
|
20138
|
+
const result = await new Promise((resolve17, reject) => {
|
|
19803
20139
|
http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
|
|
19804
20140
|
let data = "";
|
|
19805
20141
|
res.on("data", (chunk) => data += chunk);
|
|
19806
20142
|
res.on("end", () => {
|
|
19807
20143
|
try {
|
|
19808
|
-
|
|
20144
|
+
resolve17(JSON.parse(data));
|
|
19809
20145
|
} catch {
|
|
19810
|
-
|
|
20146
|
+
resolve17({ raw: data });
|
|
19811
20147
|
}
|
|
19812
20148
|
});
|
|
19813
20149
|
}).on("error", reject);
|
|
@@ -19821,7 +20157,7 @@ var DaemonCommandHandler = class {
|
|
|
19821
20157
|
try {
|
|
19822
20158
|
const http3 = await import("http");
|
|
19823
20159
|
const postData = JSON.stringify(args || {});
|
|
19824
|
-
const result = await new Promise((
|
|
20160
|
+
const result = await new Promise((resolve17, reject) => {
|
|
19825
20161
|
const req = http3.request({
|
|
19826
20162
|
hostname: "127.0.0.1",
|
|
19827
20163
|
port: 19280,
|
|
@@ -19833,9 +20169,9 @@ var DaemonCommandHandler = class {
|
|
|
19833
20169
|
res.on("data", (chunk) => data += chunk);
|
|
19834
20170
|
res.on("end", () => {
|
|
19835
20171
|
try {
|
|
19836
|
-
|
|
20172
|
+
resolve17(JSON.parse(data));
|
|
19837
20173
|
} catch {
|
|
19838
|
-
|
|
20174
|
+
resolve17({ raw: data });
|
|
19839
20175
|
}
|
|
19840
20176
|
});
|
|
19841
20177
|
});
|
|
@@ -19854,7 +20190,7 @@ var DaemonCommandHandler = class {
|
|
|
19854
20190
|
var os13 = __toESM(require("os"));
|
|
19855
20191
|
var path18 = __toESM(require("path"));
|
|
19856
20192
|
var crypto4 = __toESM(require("crypto"));
|
|
19857
|
-
var
|
|
20193
|
+
var import_fs11 = require("fs");
|
|
19858
20194
|
var import_child_process5 = require("child_process");
|
|
19859
20195
|
var import_chalk = __toESM(require("chalk"));
|
|
19860
20196
|
init_provider_cli_adapter();
|
|
@@ -20079,7 +20415,7 @@ async function waitForCliAdapterReady(adapter, options) {
|
|
|
20079
20415
|
if (status === "stopped") {
|
|
20080
20416
|
throw new Error("CLI runtime stopped before it became ready");
|
|
20081
20417
|
}
|
|
20082
|
-
await new Promise((
|
|
20418
|
+
await new Promise((resolve17) => setTimeout(resolve17, pollMs));
|
|
20083
20419
|
}
|
|
20084
20420
|
throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
|
|
20085
20421
|
}
|
|
@@ -20456,7 +20792,7 @@ var CliProviderInstance = class {
|
|
|
20456
20792
|
const enterCount = cliCommand.enterCount || 1;
|
|
20457
20793
|
await this.adapter.writeRaw(cliCommand.text + "\r");
|
|
20458
20794
|
for (let i = 1; i < enterCount; i += 1) {
|
|
20459
|
-
await new Promise((
|
|
20795
|
+
await new Promise((resolve17) => setTimeout(resolve17, 50));
|
|
20460
20796
|
await this.adapter.writeRaw("\r");
|
|
20461
20797
|
}
|
|
20462
20798
|
}
|
|
@@ -21852,13 +22188,13 @@ var AcpProviderInstance = class {
|
|
|
21852
22188
|
}
|
|
21853
22189
|
this.currentStatus = "waiting_approval";
|
|
21854
22190
|
this.detectStatusTransition();
|
|
21855
|
-
const approved = await new Promise((
|
|
21856
|
-
this.permissionResolvers.push(
|
|
22191
|
+
const approved = await new Promise((resolve17) => {
|
|
22192
|
+
this.permissionResolvers.push(resolve17);
|
|
21857
22193
|
setTimeout(() => {
|
|
21858
|
-
const idx = this.permissionResolvers.indexOf(
|
|
22194
|
+
const idx = this.permissionResolvers.indexOf(resolve17);
|
|
21859
22195
|
if (idx >= 0) {
|
|
21860
22196
|
this.permissionResolvers.splice(idx, 1);
|
|
21861
|
-
|
|
22197
|
+
resolve17(false);
|
|
21862
22198
|
}
|
|
21863
22199
|
}, 3e5);
|
|
21864
22200
|
});
|
|
@@ -22469,7 +22805,7 @@ function commandExists(command) {
|
|
|
22469
22805
|
const trimmed = command.trim();
|
|
22470
22806
|
if (!trimmed) return false;
|
|
22471
22807
|
if (isExplicitCommand(trimmed)) {
|
|
22472
|
-
return (0,
|
|
22808
|
+
return (0, import_fs11.existsSync)(expandExecutable(trimmed));
|
|
22473
22809
|
}
|
|
22474
22810
|
try {
|
|
22475
22811
|
(0, import_child_process5.execFileSync)(process.platform === "win32" ? "where" : "which", [trimmed], {
|
|
@@ -22567,7 +22903,7 @@ async function waitForZeroMessageStartingLaunch(adapter) {
|
|
|
22567
22903
|
} catch {
|
|
22568
22904
|
return false;
|
|
22569
22905
|
}
|
|
22570
|
-
await new Promise((
|
|
22906
|
+
await new Promise((resolve17) => setTimeout(resolve17, ZERO_MESSAGE_STARTING_SEND_WAIT_MS));
|
|
22571
22907
|
try {
|
|
22572
22908
|
return hasZeroMessageStartingLaunch(adapter);
|
|
22573
22909
|
} catch {
|
|
@@ -22591,10 +22927,10 @@ function hasCliArg(args, flag) {
|
|
|
22591
22927
|
}
|
|
22592
22928
|
function ensureEmptyDelegatedMcpConfig(workspace) {
|
|
22593
22929
|
const baseDir = path18.join(os13.tmpdir(), "adhdev-delegated-agent-empty-mcp");
|
|
22594
|
-
(0,
|
|
22930
|
+
(0, import_fs11.mkdirSync)(baseDir, { recursive: true });
|
|
22595
22931
|
const workspaceHash = crypto4.createHash("sha256").update(path18.resolve(workspace || os13.tmpdir())).digest("hex").slice(0, 16);
|
|
22596
22932
|
const filePath = path18.join(baseDir, `${workspaceHash}.json`);
|
|
22597
|
-
(0,
|
|
22933
|
+
(0, import_fs11.writeFileSync)(filePath, JSON.stringify({ mcpServers: {} }, null, 2), "utf-8");
|
|
22598
22934
|
return filePath;
|
|
22599
22935
|
}
|
|
22600
22936
|
function buildCoordinatorDelegatedCliLaunchOptions(input) {
|
|
@@ -24640,8 +24976,8 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
24640
24976
|
}
|
|
24641
24977
|
const https = require("https");
|
|
24642
24978
|
const { exec: exec7 } = require("child_process");
|
|
24643
|
-
const { promisify:
|
|
24644
|
-
const execAsync5 =
|
|
24979
|
+
const { promisify: promisify7 } = require("util");
|
|
24980
|
+
const execAsync5 = promisify7(exec7);
|
|
24645
24981
|
const metaPath = path19.join(this.upstreamDir, _ProviderLoader.META_FILE);
|
|
24646
24982
|
let prevEtag = "";
|
|
24647
24983
|
let prevTimestamp = 0;
|
|
@@ -24659,7 +24995,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
24659
24995
|
return { updated: false };
|
|
24660
24996
|
}
|
|
24661
24997
|
try {
|
|
24662
|
-
const etag = await new Promise((
|
|
24998
|
+
const etag = await new Promise((resolve17, reject) => {
|
|
24663
24999
|
const options = {
|
|
24664
25000
|
method: "HEAD",
|
|
24665
25001
|
hostname: "github.com",
|
|
@@ -24677,7 +25013,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
24677
25013
|
headers: { "User-Agent": "adhdev-launcher" },
|
|
24678
25014
|
timeout: 1e4
|
|
24679
25015
|
}, (res2) => {
|
|
24680
|
-
|
|
25016
|
+
resolve17(res2.headers.etag || res2.headers["last-modified"] || "");
|
|
24681
25017
|
});
|
|
24682
25018
|
req2.on("error", reject);
|
|
24683
25019
|
req2.on("timeout", () => {
|
|
@@ -24686,7 +25022,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
24686
25022
|
});
|
|
24687
25023
|
req2.end();
|
|
24688
25024
|
} else {
|
|
24689
|
-
|
|
25025
|
+
resolve17(res.headers.etag || res.headers["last-modified"] || "");
|
|
24690
25026
|
}
|
|
24691
25027
|
});
|
|
24692
25028
|
req.on("error", reject);
|
|
@@ -24750,7 +25086,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
24750
25086
|
downloadFile(url, destPath) {
|
|
24751
25087
|
const https = require("https");
|
|
24752
25088
|
const http3 = require("http");
|
|
24753
|
-
return new Promise((
|
|
25089
|
+
return new Promise((resolve17, reject) => {
|
|
24754
25090
|
const doRequest = (reqUrl, redirectCount = 0) => {
|
|
24755
25091
|
if (redirectCount > 5) {
|
|
24756
25092
|
reject(new Error("Too many redirects"));
|
|
@@ -24770,7 +25106,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
24770
25106
|
res.pipe(ws);
|
|
24771
25107
|
ws.on("finish", () => {
|
|
24772
25108
|
ws.close();
|
|
24773
|
-
|
|
25109
|
+
resolve17();
|
|
24774
25110
|
});
|
|
24775
25111
|
ws.on("error", reject);
|
|
24776
25112
|
});
|
|
@@ -25273,10 +25609,10 @@ function findMacAppProcessPids(psOutput, appPaths) {
|
|
|
25273
25609
|
|
|
25274
25610
|
// src/launch.ts
|
|
25275
25611
|
async function execQuiet(command, options = {}) {
|
|
25276
|
-
return new Promise((
|
|
25612
|
+
return new Promise((resolve17) => {
|
|
25277
25613
|
(0, import_child_process6.exec)(command, options, (error, stdout) => {
|
|
25278
|
-
if (error) return
|
|
25279
|
-
|
|
25614
|
+
if (error) return resolve17("");
|
|
25615
|
+
resolve17(stdout.toString());
|
|
25280
25616
|
});
|
|
25281
25617
|
});
|
|
25282
25618
|
}
|
|
@@ -25357,17 +25693,17 @@ async function findFreePort(ports) {
|
|
|
25357
25693
|
throw new Error("No free port found");
|
|
25358
25694
|
}
|
|
25359
25695
|
function checkPortFree(port) {
|
|
25360
|
-
return new Promise((
|
|
25696
|
+
return new Promise((resolve17) => {
|
|
25361
25697
|
const server = net.createServer();
|
|
25362
25698
|
server.unref();
|
|
25363
|
-
server.on("error", () =>
|
|
25699
|
+
server.on("error", () => resolve17(false));
|
|
25364
25700
|
server.listen(port, "127.0.0.1", () => {
|
|
25365
|
-
server.close(() =>
|
|
25701
|
+
server.close(() => resolve17(true));
|
|
25366
25702
|
});
|
|
25367
25703
|
});
|
|
25368
25704
|
}
|
|
25369
25705
|
async function isCdpActive(port) {
|
|
25370
|
-
return new Promise((
|
|
25706
|
+
return new Promise((resolve17) => {
|
|
25371
25707
|
const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
|
|
25372
25708
|
timeout: 2e3
|
|
25373
25709
|
}, (res) => {
|
|
@@ -25376,16 +25712,16 @@ async function isCdpActive(port) {
|
|
|
25376
25712
|
res.on("end", () => {
|
|
25377
25713
|
try {
|
|
25378
25714
|
const info = JSON.parse(data);
|
|
25379
|
-
|
|
25715
|
+
resolve17(!!info["WebKit-Version"] || !!info["Browser"]);
|
|
25380
25716
|
} catch {
|
|
25381
|
-
|
|
25717
|
+
resolve17(false);
|
|
25382
25718
|
}
|
|
25383
25719
|
});
|
|
25384
25720
|
});
|
|
25385
|
-
req.on("error", () =>
|
|
25721
|
+
req.on("error", () => resolve17(false));
|
|
25386
25722
|
req.on("timeout", () => {
|
|
25387
25723
|
req.destroy();
|
|
25388
|
-
|
|
25724
|
+
resolve17(false);
|
|
25389
25725
|
});
|
|
25390
25726
|
});
|
|
25391
25727
|
}
|
|
@@ -25859,7 +26195,7 @@ function getRecentCommands(count = 50) {
|
|
|
25859
26195
|
cleanOldFiles();
|
|
25860
26196
|
|
|
25861
26197
|
// src/commands/router.ts
|
|
25862
|
-
var
|
|
26198
|
+
var yaml3 = __toESM(require("js-yaml"));
|
|
25863
26199
|
init_logger();
|
|
25864
26200
|
|
|
25865
26201
|
// src/commands/mesh-coordinator.ts
|
|
@@ -26047,6 +26383,88 @@ function resolveMcpPort(explicitPort) {
|
|
|
26047
26383
|
init_mesh_events();
|
|
26048
26384
|
init_mesh_host_ownership();
|
|
26049
26385
|
|
|
26386
|
+
// src/mesh/preview-freshness.ts
|
|
26387
|
+
var import_node_child_process4 = require("child_process");
|
|
26388
|
+
var import_node_fs3 = require("fs");
|
|
26389
|
+
var import_node_path2 = require("path");
|
|
26390
|
+
var PREVIEW_DEPLOY_RECORD = ".adhdev/preview-deploy.json";
|
|
26391
|
+
function runGit2(repoRoot, args) {
|
|
26392
|
+
try {
|
|
26393
|
+
return (0, import_node_child_process4.execFileSync)("git", args, {
|
|
26394
|
+
cwd: repoRoot,
|
|
26395
|
+
encoding: "utf8",
|
|
26396
|
+
stdio: ["ignore", "pipe", "ignore"],
|
|
26397
|
+
timeout: 5e3
|
|
26398
|
+
}).trim();
|
|
26399
|
+
} catch {
|
|
26400
|
+
return "";
|
|
26401
|
+
}
|
|
26402
|
+
}
|
|
26403
|
+
function readRecord3(repoRoot) {
|
|
26404
|
+
const path28 = (0, import_node_path2.resolve)(repoRoot, PREVIEW_DEPLOY_RECORD);
|
|
26405
|
+
if (!(0, import_node_fs3.existsSync)(path28)) return null;
|
|
26406
|
+
try {
|
|
26407
|
+
const parsed = JSON.parse((0, import_node_fs3.readFileSync)(path28, "utf8"));
|
|
26408
|
+
return parsed && typeof parsed === "object" && !Array.isArray(parsed) ? parsed : null;
|
|
26409
|
+
} catch {
|
|
26410
|
+
return null;
|
|
26411
|
+
}
|
|
26412
|
+
}
|
|
26413
|
+
function normalizeCommit(value) {
|
|
26414
|
+
return typeof value === "string" && /^[0-9a-f]{7,40}$/i.test(value.trim()) ? value.trim() : null;
|
|
26415
|
+
}
|
|
26416
|
+
function readTargetFreshness(record, currentCommit) {
|
|
26417
|
+
const targets = record?.targets && typeof record.targets === "object" && !Array.isArray(record.targets) ? record.targets : {};
|
|
26418
|
+
const result = {};
|
|
26419
|
+
for (const targetName of ["npm", "server", "web"]) {
|
|
26420
|
+
const targetRecord = targets[targetName] && typeof targets[targetName] === "object" && !Array.isArray(targets[targetName]) ? targets[targetName] : {};
|
|
26421
|
+
const commit = normalizeCommit(targetRecord.commit);
|
|
26422
|
+
result[targetName] = {
|
|
26423
|
+
commit,
|
|
26424
|
+
deployedAt: typeof targetRecord.deployedAt === "string" ? targetRecord.deployedAt : void 0,
|
|
26425
|
+
status: commit && currentCommit ? commit === currentCommit ? "fresh" : "stale" : "unknown"
|
|
26426
|
+
};
|
|
26427
|
+
}
|
|
26428
|
+
return result;
|
|
26429
|
+
}
|
|
26430
|
+
function readCurrentMainCommit(repoRoot) {
|
|
26431
|
+
const originMain = runGit2(repoRoot, ["rev-parse", "--verify", "origin/main^{commit}"]);
|
|
26432
|
+
if (originMain) {
|
|
26433
|
+
return { currentMainCommit: originMain, currentMainCommitSource: "origin/main" };
|
|
26434
|
+
}
|
|
26435
|
+
const head = runGit2(repoRoot, ["rev-parse", "--verify", "HEAD"]);
|
|
26436
|
+
if (head) {
|
|
26437
|
+
return { currentMainCommit: head, currentMainCommitSource: "HEAD" };
|
|
26438
|
+
}
|
|
26439
|
+
return { currentMainCommit: null, currentMainCommitSource: "unknown" };
|
|
26440
|
+
}
|
|
26441
|
+
function buildPreviewFreshness(repoRoot) {
|
|
26442
|
+
const current = readCurrentMainCommit(repoRoot);
|
|
26443
|
+
const record = readRecord3(repoRoot);
|
|
26444
|
+
const lastPreviewCommit = normalizeCommit(record?.lastPreviewCommit);
|
|
26445
|
+
const targets = readTargetFreshness(record, current.currentMainCommit);
|
|
26446
|
+
let status = "unknown";
|
|
26447
|
+
let nextAction = "Run npm run deploy:preview from the current main commit, then smoke preview.";
|
|
26448
|
+
if (lastPreviewCommit && current.currentMainCommit) {
|
|
26449
|
+
status = lastPreviewCommit === current.currentMainCommit ? "fresh" : "stale";
|
|
26450
|
+
nextAction = status === "fresh" ? "No preview deploy action needed." : "Run npm run deploy:preview from origin/main, then smoke preview.";
|
|
26451
|
+
} else if (!current.currentMainCommit) {
|
|
26452
|
+
nextAction = "Resolve the current main commit before judging preview freshness.";
|
|
26453
|
+
}
|
|
26454
|
+
return {
|
|
26455
|
+
status,
|
|
26456
|
+
lastPreviewCommit,
|
|
26457
|
+
currentMainCommit: current.currentMainCommit,
|
|
26458
|
+
currentMainCommitSource: current.currentMainCommitSource,
|
|
26459
|
+
recordPath: PREVIEW_DEPLOY_RECORD,
|
|
26460
|
+
lastDeployedAt: typeof record?.updatedAt === "string" ? record.updatedAt : void 0,
|
|
26461
|
+
lastTarget: typeof record?.target === "string" ? record.target : void 0,
|
|
26462
|
+
previewVersion: typeof record?.previewVersion === "string" ? record.previewVersion : void 0,
|
|
26463
|
+
targets,
|
|
26464
|
+
nextAction
|
|
26465
|
+
};
|
|
26466
|
+
}
|
|
26467
|
+
|
|
26050
26468
|
// src/status/snapshot.ts
|
|
26051
26469
|
var os18 = __toESM(require("os"));
|
|
26052
26470
|
init_config();
|
|
@@ -26553,7 +26971,7 @@ async function waitForPidExit(pid, timeoutMs) {
|
|
|
26553
26971
|
while (Date.now() - start < timeoutMs) {
|
|
26554
26972
|
try {
|
|
26555
26973
|
process.kill(pid, 0);
|
|
26556
|
-
await new Promise((
|
|
26974
|
+
await new Promise((resolve17) => setTimeout(resolve17, 250));
|
|
26557
26975
|
} catch {
|
|
26558
26976
|
return;
|
|
26559
26977
|
}
|
|
@@ -26664,7 +27082,7 @@ async function runDaemonUpgradeHelper(payload) {
|
|
|
26664
27082
|
appendUpgradeLog(installOutput.trim());
|
|
26665
27083
|
}
|
|
26666
27084
|
if (process.platform === "win32") {
|
|
26667
|
-
await new Promise((
|
|
27085
|
+
await new Promise((resolve17) => setTimeout(resolve17, 500));
|
|
26668
27086
|
cleanupStaleGlobalInstallDirs(payload.packageName, installCommand.surface);
|
|
26669
27087
|
appendUpgradeLog("Post-install staging cleanup complete");
|
|
26670
27088
|
}
|
|
@@ -26701,8 +27119,9 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
|
|
|
26701
27119
|
// src/commands/router.ts
|
|
26702
27120
|
init_mesh_work_queue();
|
|
26703
27121
|
var import_os3 = require("os");
|
|
26704
|
-
var
|
|
27122
|
+
var import_path9 = require("path");
|
|
26705
27123
|
var fs11 = __toESM(require("fs"));
|
|
27124
|
+
var import_node_child_process5 = require("child_process");
|
|
26706
27125
|
var CHANNEL_NPM_TAG = { stable: "latest", preview: "next" };
|
|
26707
27126
|
var CHANNEL_SERVER_URL = {
|
|
26708
27127
|
stable: "https://api.adhf.dev",
|
|
@@ -26848,7 +27267,7 @@ function buildMeshNodeDisplayLabel(node, nodeId, providerPriority) {
|
|
|
26848
27267
|
const explicit = readStringValue(node.machineLabel, node.machine_label, node.machineNickname, node.machine_nickname, node.alias);
|
|
26849
27268
|
if (explicit) return explicit;
|
|
26850
27269
|
const workspace = readStringValue(node.workspace, node.repoRoot, node.repo_root);
|
|
26851
|
-
const workspaceName = workspace ? (0,
|
|
27270
|
+
const workspaceName = workspace ? (0, import_path9.basename)(workspace) : void 0;
|
|
26852
27271
|
const host = readStringValue(node.machineName, node.machine_name, node.hostname, node.host, node.daemonId, node.daemon_id, node.machineId, node.machine_id);
|
|
26853
27272
|
const provider = providerPriority[0] || (Array.isArray(node.providers) ? readStringValue(...node.providers) : void 0);
|
|
26854
27273
|
const parts = [workspaceName, host, provider].filter(Boolean);
|
|
@@ -27414,6 +27833,16 @@ function finalizeMeshNodeStatus(args) {
|
|
|
27414
27833
|
if (machineStatus) status.machineStatus = machineStatus;
|
|
27415
27834
|
}
|
|
27416
27835
|
synthesizeMeshNodeFreshnessFromConnection(status);
|
|
27836
|
+
const bootstrap = readObjectRecord(node?.worktreeBootstrap);
|
|
27837
|
+
if (node?.isLocalWorktree && readStringValue(bootstrap.status)) {
|
|
27838
|
+
status.worktreeBootstrap = bootstrap;
|
|
27839
|
+
if (bootstrap.status === "failed" && bootstrap.required !== false) {
|
|
27840
|
+
status.launchReady = false;
|
|
27841
|
+
status.launchBlockedReason = "worktree_bootstrap_failed";
|
|
27842
|
+
status.launchBlockedMessage = readStringValue(bootstrap.error) || "Required worktree bootstrap failed; resolve it before launching an agent into this node.";
|
|
27843
|
+
return;
|
|
27844
|
+
}
|
|
27845
|
+
}
|
|
27417
27846
|
const connectionState = readStringValue(readObjectRecord(status.connection).state);
|
|
27418
27847
|
status.launchReady = !!daemonId && (readStringValue(status.machineStatus) === "online" || connectionState === "connected" || isSelfNode);
|
|
27419
27848
|
}
|
|
@@ -27555,6 +27984,40 @@ function collectLiveMeshSessionRecords(args) {
|
|
|
27555
27984
|
}
|
|
27556
27985
|
return matches;
|
|
27557
27986
|
}
|
|
27987
|
+
function buildHistoricalMeshSessions(args) {
|
|
27988
|
+
const liveNodeIds = /* @__PURE__ */ new Set();
|
|
27989
|
+
const liveWorkspaces = /* @__PURE__ */ new Set();
|
|
27990
|
+
for (const node of args.nodes || []) {
|
|
27991
|
+
const nodeId = readStringValue(node?.id, node?.nodeId);
|
|
27992
|
+
const workspace = readStringValue(node?.workspace);
|
|
27993
|
+
if (nodeId) liveNodeIds.add(nodeId);
|
|
27994
|
+
if (workspace) liveWorkspaces.add(workspace);
|
|
27995
|
+
}
|
|
27996
|
+
const sessions = [];
|
|
27997
|
+
for (const record of args.liveSessionRecords || []) {
|
|
27998
|
+
const meta = readObjectRecord(record?.meta);
|
|
27999
|
+
const recordMeshId = readStringValue(meta.meshNodeFor, meta.meshCoordinatorFor);
|
|
28000
|
+
if (recordMeshId !== args.meshId) continue;
|
|
28001
|
+
const recordNodeId = readStringValue(meta.meshNodeId);
|
|
28002
|
+
const workspace = readStringValue(record?.workspace);
|
|
28003
|
+
const removedNode = !!recordNodeId && !liveNodeIds.has(recordNodeId);
|
|
28004
|
+
const orphanedWorkspace = !!workspace && !liveWorkspaces.has(workspace) && meta.meshCoordinatorFor !== args.meshId;
|
|
28005
|
+
if (!removedNode && !orphanedWorkspace) continue;
|
|
28006
|
+
sessions.push({
|
|
28007
|
+
...summarizeMeshSessionRecord(record),
|
|
28008
|
+
classification: removedNode ? "removedNode" : "orphanedSession",
|
|
28009
|
+
historical: true,
|
|
28010
|
+
meshNodeId: recordNodeId || null,
|
|
28011
|
+
reason: removedNode ? "Session is tagged to a mesh node that is no longer in live membership." : "Session workspace is no longer attached to a live mesh node."
|
|
28012
|
+
});
|
|
28013
|
+
}
|
|
28014
|
+
if (sessions.length === 0) return void 0;
|
|
28015
|
+
return {
|
|
28016
|
+
count: sessions.length,
|
|
28017
|
+
sessions: sessions.slice(0, 5),
|
|
28018
|
+
instruction: "These sessions are separated from normal node activeSessions because their mesh node/workspace is no longer live. Use mesh_cleanup_sessions only if cleanup is intended."
|
|
28019
|
+
};
|
|
28020
|
+
}
|
|
27558
28021
|
function applyCachedInlineMeshNodeStatus(status, node, options) {
|
|
27559
28022
|
const cachedStatus = readObjectRecord(node?.cachedStatus);
|
|
27560
28023
|
const liveGit = buildInlineMeshTransitGitStatus(node);
|
|
@@ -27640,14 +28103,14 @@ function resolveRefineryAutoPublishSubmoduleMainCommits(mesh, workspace) {
|
|
|
27640
28103
|
return { enabled: false };
|
|
27641
28104
|
}
|
|
27642
28105
|
async function computeGitPatchId(cwd, fromRef, toRef) {
|
|
27643
|
-
const { execFileSync:
|
|
27644
|
-
const diff =
|
|
28106
|
+
const { execFileSync: execFileSync5 } = await import("child_process");
|
|
28107
|
+
const diff = execFileSync5("git", ["diff", "--patch", "--full-index", fromRef, toRef], {
|
|
27645
28108
|
cwd,
|
|
27646
28109
|
encoding: "utf8",
|
|
27647
28110
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
27648
28111
|
});
|
|
27649
28112
|
if (!diff.trim()) return "";
|
|
27650
|
-
const patchId =
|
|
28113
|
+
const patchId = execFileSync5("git", ["patch-id", "--stable"], {
|
|
27651
28114
|
cwd,
|
|
27652
28115
|
input: diff,
|
|
27653
28116
|
encoding: "utf8",
|
|
@@ -27658,8 +28121,8 @@ async function computeGitPatchId(cwd, fromRef, toRef) {
|
|
|
27658
28121
|
async function runMeshRefinePatchEquivalenceGate(repoRoot, baseHead, branchHead) {
|
|
27659
28122
|
const startedAt = Date.now();
|
|
27660
28123
|
try {
|
|
27661
|
-
const { execFileSync:
|
|
27662
|
-
const git = (args) =>
|
|
28124
|
+
const { execFileSync: execFileSync5 } = await import("child_process");
|
|
28125
|
+
const git = (args) => execFileSync5("git", args, {
|
|
27663
28126
|
cwd: repoRoot,
|
|
27664
28127
|
encoding: "utf8",
|
|
27665
28128
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -27703,6 +28166,135 @@ async function runMeshRefinePatchEquivalenceGate(repoRoot, baseHead, branchHead)
|
|
|
27703
28166
|
durationMs: Date.now() - startedAt,
|
|
27704
28167
|
error: e?.message || String(e),
|
|
27705
28168
|
stdout: truncateValidationOutput(e?.stdout),
|
|
28169
|
+
stderr: truncateValidationOutput(e?.stderr),
|
|
28170
|
+
actionableHint: buildPatchEquivalenceSubmoduleConflictHint(
|
|
28171
|
+
repoRoot,
|
|
28172
|
+
baseHead,
|
|
28173
|
+
branchHead,
|
|
28174
|
+
`${e?.message || ""}
|
|
28175
|
+
${e?.stdout || ""}
|
|
28176
|
+
${e?.stderr || ""}`
|
|
28177
|
+
)
|
|
28178
|
+
};
|
|
28179
|
+
}
|
|
28180
|
+
}
|
|
28181
|
+
function buildPatchEquivalenceSubmoduleConflictHint(repoRoot, baseHead, branchHead, output) {
|
|
28182
|
+
if (!/(submodule|160000)/i.test(output) || !/(conflict|failed to merge)/i.test(output)) return void 0;
|
|
28183
|
+
const conflicts = readChangedGitlinkPaths(repoRoot, baseHead, branchHead).map((path28) => ({
|
|
28184
|
+
path: path28,
|
|
28185
|
+
baseCommit: readTreeObject(repoRoot, baseHead, path28),
|
|
28186
|
+
branchCommit: readTreeObject(repoRoot, branchHead, path28)
|
|
28187
|
+
}));
|
|
28188
|
+
if (conflicts.length === 0) return void 0;
|
|
28189
|
+
return {
|
|
28190
|
+
kind: "submodule_conflict",
|
|
28191
|
+
message: "Refinery could not synthesize a safe merge tree because the branch and base point the same submodule path at different commits.",
|
|
28192
|
+
conflicts,
|
|
28193
|
+
nextSteps: [
|
|
28194
|
+
"Inspect the listed submodule path in both base and branch: baseCommit is the commit currently recorded by the base workspace, branchCommit is the commit recorded by the worktree branch.",
|
|
28195
|
+
"Resolve the submodule first by checking out or creating the intended submodule commit, then commit the chosen gitlink in the root branch.",
|
|
28196
|
+
"Ensure the chosen submodule commit is reachable from the configured submodule remote main branch, then rerun mesh_refine_node."
|
|
28197
|
+
]
|
|
28198
|
+
};
|
|
28199
|
+
}
|
|
28200
|
+
function readChangedGitlinkPaths(repoRoot, fromRef, toRef) {
|
|
28201
|
+
try {
|
|
28202
|
+
const output = (0, import_node_child_process5.execFileSync)("git", ["diff", "--raw", "--no-abbrev", fromRef, toRef], {
|
|
28203
|
+
cwd: repoRoot,
|
|
28204
|
+
encoding: "utf8",
|
|
28205
|
+
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
28206
|
+
});
|
|
28207
|
+
const paths = /* @__PURE__ */ new Set();
|
|
28208
|
+
for (const line of output.split("\n")) {
|
|
28209
|
+
if (!line.trim()) continue;
|
|
28210
|
+
const metaAndPath = line.split(" ");
|
|
28211
|
+
const meta = metaAndPath[0] || "";
|
|
28212
|
+
const path28 = metaAndPath[metaAndPath.length - 1]?.trim();
|
|
28213
|
+
if (!path28) continue;
|
|
28214
|
+
const parts = meta.split(/\s+/);
|
|
28215
|
+
if (parts[0]?.includes("160000") || parts[1]?.includes("160000")) {
|
|
28216
|
+
paths.add(path28);
|
|
28217
|
+
}
|
|
28218
|
+
}
|
|
28219
|
+
return [...paths].sort();
|
|
28220
|
+
} catch {
|
|
28221
|
+
return [];
|
|
28222
|
+
}
|
|
28223
|
+
}
|
|
28224
|
+
function readTreeObject(repoRoot, ref, path28) {
|
|
28225
|
+
try {
|
|
28226
|
+
const output = (0, import_node_child_process5.execFileSync)("git", ["ls-tree", ref, "--", path28], {
|
|
28227
|
+
cwd: repoRoot,
|
|
28228
|
+
encoding: "utf8",
|
|
28229
|
+
maxBuffer: 1024 * 1024
|
|
28230
|
+
}).trim();
|
|
28231
|
+
const match = output.match(/\bcommit\s+([0-9a-f]{40})\b/i);
|
|
28232
|
+
return match?.[1];
|
|
28233
|
+
} catch {
|
|
28234
|
+
return void 0;
|
|
28235
|
+
}
|
|
28236
|
+
}
|
|
28237
|
+
async function alignRefinerySubmodulesAfterMerge(repoRoot, previousBaseHead, currentHead, options = {}) {
|
|
28238
|
+
const startedAt = Date.now();
|
|
28239
|
+
const changedGitlinkPaths = readChangedGitlinkPaths(repoRoot, previousBaseHead, currentHead).filter((path28) => !(options.submoduleIgnorePaths || []).includes(path28));
|
|
28240
|
+
const preStatus = await getGitRepoStatus(repoRoot, {
|
|
28241
|
+
includeSubmodules: true,
|
|
28242
|
+
submoduleIgnorePaths: options.submoduleIgnorePaths,
|
|
28243
|
+
timeoutMs: 15e3
|
|
28244
|
+
});
|
|
28245
|
+
const outOfSyncPaths = (preStatus.submodules || []).filter((submodule) => submodule.dirty || submodule.outOfSync || !!submodule.error).map((submodule) => submodule.path);
|
|
28246
|
+
const updatePaths = [.../* @__PURE__ */ new Set([...changedGitlinkPaths, ...outOfSyncPaths])].sort();
|
|
28247
|
+
if (updatePaths.length === 0) {
|
|
28248
|
+
return {
|
|
28249
|
+
status: "skipped",
|
|
28250
|
+
changedGitlinkPaths,
|
|
28251
|
+
outOfSyncPaths,
|
|
28252
|
+
updatedPaths: [],
|
|
28253
|
+
verifiedPaths: [],
|
|
28254
|
+
durationMs: Date.now() - startedAt,
|
|
28255
|
+
reason: "no_changed_or_out_of_sync_submodules"
|
|
28256
|
+
};
|
|
28257
|
+
}
|
|
28258
|
+
const commandArgs = ["submodule", "update", "--init", "--recursive", "--", ...updatePaths];
|
|
28259
|
+
try {
|
|
28260
|
+
const { execFile: execFile4 } = await import("child_process");
|
|
28261
|
+
const { promisify: promisify7 } = await import("util");
|
|
28262
|
+
const execFileAsync3 = promisify7(execFile4);
|
|
28263
|
+
const result = await execFileAsync3("git", commandArgs, {
|
|
28264
|
+
cwd: repoRoot,
|
|
28265
|
+
encoding: "utf8",
|
|
28266
|
+
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES,
|
|
28267
|
+
timeout: 6e4
|
|
28268
|
+
});
|
|
28269
|
+
const postStatus = await getGitRepoStatus(repoRoot, {
|
|
28270
|
+
includeSubmodules: true,
|
|
28271
|
+
submoduleIgnorePaths: options.submoduleIgnorePaths,
|
|
28272
|
+
timeoutMs: 15e3
|
|
28273
|
+
});
|
|
28274
|
+
const remaining = (postStatus.submodules || []).filter((submodule) => updatePaths.includes(submodule.path) && (submodule.dirty || submodule.outOfSync || !!submodule.error));
|
|
28275
|
+
return {
|
|
28276
|
+
status: remaining.length === 0 ? "passed" : "failed",
|
|
28277
|
+
changedGitlinkPaths,
|
|
28278
|
+
outOfSyncPaths,
|
|
28279
|
+
updatedPaths: updatePaths,
|
|
28280
|
+
verifiedPaths: updatePaths.filter((path28) => !remaining.some((submodule) => submodule.path === path28)),
|
|
28281
|
+
durationMs: Date.now() - startedAt,
|
|
28282
|
+
command: `git ${commandArgs.join(" ")}`,
|
|
28283
|
+
stdout: truncateValidationOutput(result.stdout),
|
|
28284
|
+
stderr: truncateValidationOutput(result.stderr),
|
|
28285
|
+
...remaining.length > 0 ? { error: `Submodule checkout remained out of sync after update: ${remaining.map((entry) => entry.path).join(", ")}` } : {}
|
|
28286
|
+
};
|
|
28287
|
+
} catch (e) {
|
|
28288
|
+
return {
|
|
28289
|
+
status: "failed",
|
|
28290
|
+
changedGitlinkPaths,
|
|
28291
|
+
outOfSyncPaths,
|
|
28292
|
+
updatedPaths: updatePaths,
|
|
28293
|
+
verifiedPaths: [],
|
|
28294
|
+
durationMs: Date.now() - startedAt,
|
|
28295
|
+
command: `git ${commandArgs.join(" ")}`,
|
|
28296
|
+
error: e?.message || String(e),
|
|
28297
|
+
stdout: truncateValidationOutput(e?.stdout),
|
|
27706
28298
|
stderr: truncateValidationOutput(e?.stderr)
|
|
27707
28299
|
};
|
|
27708
28300
|
}
|
|
@@ -27711,10 +28303,10 @@ async function runMeshRefineSubmoduleReachabilityGate(repoRoot, mergedTree, opti
|
|
|
27711
28303
|
const startedAt = Date.now();
|
|
27712
28304
|
const entries = [];
|
|
27713
28305
|
try {
|
|
27714
|
-
const { execFile:
|
|
27715
|
-
const { promisify:
|
|
27716
|
-
const execFileAsync3 =
|
|
27717
|
-
const
|
|
28306
|
+
const { execFile: execFile4 } = await import("child_process");
|
|
28307
|
+
const { promisify: promisify7 } = await import("util");
|
|
28308
|
+
const execFileAsync3 = promisify7(execFile4);
|
|
28309
|
+
const runGit3 = async (cwd, args) => {
|
|
27718
28310
|
const { stdout } = await execFileAsync3("git", args, {
|
|
27719
28311
|
cwd,
|
|
27720
28312
|
encoding: "utf8",
|
|
@@ -27725,8 +28317,8 @@ async function runMeshRefineSubmoduleReachabilityGate(repoRoot, mergedTree, opti
|
|
|
27725
28317
|
return String(stdout || "");
|
|
27726
28318
|
};
|
|
27727
28319
|
const verifyRemoteMainContainsCommit = async (submodulePath, commit, branch = "main") => {
|
|
27728
|
-
await
|
|
27729
|
-
await
|
|
28320
|
+
await runGit3(submodulePath, ["-c", "protocol.file.allow=always", "fetch", "origin", `refs/heads/${branch}:refs/remotes/origin/${branch}`]);
|
|
28321
|
+
await runGit3(submodulePath, ["merge-base", "--is-ancestor", commit, `refs/remotes/origin/${branch}`]);
|
|
27730
28322
|
};
|
|
27731
28323
|
const publishCommitToRemoteMain = async (submodulePath, commit, branch = "main") => {
|
|
27732
28324
|
const refspec = `${commit}:refs/heads/${branch}`;
|
|
@@ -27742,21 +28334,21 @@ async function runMeshRefineSubmoduleReachabilityGate(repoRoot, mergedTree, opti
|
|
|
27742
28334
|
const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
|
|
27743
28335
|
if (!fs11.existsSync(worktreeSubmodulePath)) return false;
|
|
27744
28336
|
try {
|
|
27745
|
-
await
|
|
28337
|
+
await runGit3(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
|
|
27746
28338
|
} catch {
|
|
27747
28339
|
return false;
|
|
27748
28340
|
}
|
|
27749
|
-
await
|
|
27750
|
-
await
|
|
28341
|
+
await runGit3(submodulePath, ["-c", "protocol.file.allow=always", "fetch", worktreeSubmodulePath, commit]);
|
|
28342
|
+
await runGit3(submodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
|
|
27751
28343
|
return true;
|
|
27752
28344
|
};
|
|
27753
|
-
const treeOutput = await
|
|
28345
|
+
const treeOutput = await runGit3(repoRoot, ["ls-tree", "-r", "-z", mergedTree]);
|
|
27754
28346
|
const gitlinks = treeOutput.split("\0").filter(Boolean).map((record) => {
|
|
27755
28347
|
const match = /^160000\s+commit\s+([0-9a-f]{40})\t(.+)$/.exec(record);
|
|
27756
28348
|
return match ? { commit: match[1], path: match[2] } : null;
|
|
27757
28349
|
}).filter((entry) => !!entry);
|
|
27758
28350
|
for (const gitlink of gitlinks) {
|
|
27759
|
-
const submodulePath = (0,
|
|
28351
|
+
const submodulePath = (0, import_path9.resolve)(repoRoot, gitlink.path);
|
|
27760
28352
|
const entry = {
|
|
27761
28353
|
path: gitlink.path,
|
|
27762
28354
|
commit: gitlink.commit,
|
|
@@ -27776,7 +28368,7 @@ async function runMeshRefineSubmoduleReachabilityGate(repoRoot, mergedTree, opti
|
|
|
27776
28368
|
}
|
|
27777
28369
|
entry.checkedLocal = true;
|
|
27778
28370
|
try {
|
|
27779
|
-
await
|
|
28371
|
+
await runGit3(submodulePath, ["cat-file", "-e", `${gitlink.commit}^{commit}`]);
|
|
27780
28372
|
entry.localReachable = true;
|
|
27781
28373
|
} catch {
|
|
27782
28374
|
entry.localReachable = false;
|
|
@@ -27784,7 +28376,7 @@ async function runMeshRefineSubmoduleReachabilityGate(repoRoot, mergedTree, opti
|
|
|
27784
28376
|
try {
|
|
27785
28377
|
const imported = await importCommitFromWorktreeSubmodule(
|
|
27786
28378
|
submodulePath,
|
|
27787
|
-
(0,
|
|
28379
|
+
(0, import_path9.resolve)(options.worktreeRoot, gitlink.path),
|
|
27788
28380
|
gitlink.commit
|
|
27789
28381
|
);
|
|
27790
28382
|
if (imported) {
|
|
@@ -27800,7 +28392,7 @@ async function runMeshRefineSubmoduleReachabilityGate(repoRoot, mergedTree, opti
|
|
|
27800
28392
|
entry.remote = "origin";
|
|
27801
28393
|
let remoteUrl = "";
|
|
27802
28394
|
try {
|
|
27803
|
-
remoteUrl = (await
|
|
28395
|
+
remoteUrl = (await runGit3(submodulePath, ["remote", "get-url", "origin"])).trim();
|
|
27804
28396
|
if (!remoteUrl) throw new Error("origin remote has no URL");
|
|
27805
28397
|
entry.remoteUrl = remoteUrl;
|
|
27806
28398
|
} catch {
|
|
@@ -27915,9 +28507,9 @@ function buildMeshRefineValidationPlan(mesh, workspace) {
|
|
|
27915
28507
|
};
|
|
27916
28508
|
}
|
|
27917
28509
|
async function runMeshRefineValidationGate(mesh, workspace) {
|
|
27918
|
-
const { execFile:
|
|
27919
|
-
const { promisify:
|
|
27920
|
-
const execFileAsync3 =
|
|
28510
|
+
const { execFile: execFile4 } = await import("child_process");
|
|
28511
|
+
const { promisify: promisify7 } = await import("util");
|
|
28512
|
+
const execFileAsync3 = promisify7(execFile4);
|
|
27921
28513
|
const selection = resolveMeshRefineValidationPlan(mesh, workspace);
|
|
27922
28514
|
const summary = {
|
|
27923
28515
|
status: "skipped",
|
|
@@ -27951,24 +28543,24 @@ async function runMeshRefineValidationGate(mesh, workspace) {
|
|
|
27951
28543
|
...extras
|
|
27952
28544
|
});
|
|
27953
28545
|
const isPackageManagerValidation = (candidate) => {
|
|
27954
|
-
const command = (0,
|
|
28546
|
+
const command = (0, import_path9.basename)(candidate.command).replace(/\.(?:cmd|exe)$/i, "");
|
|
27955
28547
|
return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
|
|
27956
28548
|
};
|
|
27957
28549
|
const dependenciesLikelyMissing = (cwd) => {
|
|
27958
|
-
if (!fs11.existsSync((0,
|
|
27959
|
-
if (fs11.existsSync((0,
|
|
27960
|
-
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs11.existsSync((0,
|
|
28550
|
+
if (!fs11.existsSync((0, import_path9.join)(cwd, "package.json"))) return false;
|
|
28551
|
+
if (fs11.existsSync((0, import_path9.join)(cwd, "node_modules"))) return false;
|
|
28552
|
+
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs11.existsSync((0, import_path9.join)(cwd, lock)));
|
|
27961
28553
|
};
|
|
27962
28554
|
for (const candidate of selection.bootstrapCommands) {
|
|
27963
28555
|
const startedAt = Date.now();
|
|
27964
|
-
const cwd = candidate.cwd ? (0,
|
|
28556
|
+
const cwd = candidate.cwd ? (0, import_path9.resolve)(workspace, candidate.cwd) : workspace;
|
|
27965
28557
|
const timeout = candidate.timeoutMs || REFINE_VALIDATION_TIMEOUT_MS;
|
|
27966
28558
|
try {
|
|
27967
28559
|
const result = await execFileAsync3(candidate.command, candidate.args, {
|
|
27968
28560
|
cwd,
|
|
27969
28561
|
encoding: "utf8",
|
|
27970
28562
|
timeout,
|
|
27971
|
-
maxBuffer: REFINE_VALIDATION_OUTPUT_LIMIT_BYTES,
|
|
28563
|
+
maxBuffer: candidate.outputLimitBytes || REFINE_VALIDATION_OUTPUT_LIMIT_BYTES,
|
|
27972
28564
|
env: { ...process.env, CI: process.env.CI || "1", ...candidate.env || {} }
|
|
27973
28565
|
});
|
|
27974
28566
|
summary.bootstrapCommandsRun.push(commandRecord(candidate, cwd, startedAt, result, true, { exitCode: 0 }));
|
|
@@ -27987,7 +28579,7 @@ async function runMeshRefineValidationGate(mesh, workspace) {
|
|
|
27987
28579
|
}
|
|
27988
28580
|
for (const candidate of selection.commands) {
|
|
27989
28581
|
const startedAt = Date.now();
|
|
27990
|
-
const cwd = candidate.cwd ? (0,
|
|
28582
|
+
const cwd = candidate.cwd ? (0, import_path9.resolve)(workspace, candidate.cwd) : workspace;
|
|
27991
28583
|
const timeout = candidate.timeoutMs || REFINE_VALIDATION_TIMEOUT_MS;
|
|
27992
28584
|
if (selection.bootstrapCommands.length === 0 && isPackageManagerValidation(candidate) && dependenciesLikelyMissing(cwd)) {
|
|
27993
28585
|
summary.commandsRun.push(commandRecord(candidate, cwd, startedAt, {
|
|
@@ -28007,7 +28599,7 @@ async function runMeshRefineValidationGate(mesh, workspace) {
|
|
|
28007
28599
|
cwd,
|
|
28008
28600
|
encoding: "utf8",
|
|
28009
28601
|
timeout,
|
|
28010
|
-
maxBuffer: REFINE_VALIDATION_OUTPUT_LIMIT_BYTES,
|
|
28602
|
+
maxBuffer: candidate.outputLimitBytes || REFINE_VALIDATION_OUTPUT_LIMIT_BYTES,
|
|
28011
28603
|
env: { ...process.env, CI: process.env.CI || "1", ...candidate.env || {} }
|
|
28012
28604
|
});
|
|
28013
28605
|
summary.commandsRun.push(commandRecord(candidate, cwd, startedAt, result, true, { exitCode: 0 }));
|
|
@@ -28032,7 +28624,7 @@ async function runMeshRefineValidationGate(mesh, workspace) {
|
|
|
28032
28624
|
return summary;
|
|
28033
28625
|
}
|
|
28034
28626
|
function loadYamlModule() {
|
|
28035
|
-
return
|
|
28627
|
+
return yaml3;
|
|
28036
28628
|
}
|
|
28037
28629
|
function getMcpServersKey(format) {
|
|
28038
28630
|
return format === "hermes_config_yaml" ? "mcp_servers" : "mcpServers";
|
|
@@ -28049,13 +28641,13 @@ function serializeMeshCoordinatorMcpConfig(config, format) {
|
|
|
28049
28641
|
}
|
|
28050
28642
|
function resolveHermesUserHome() {
|
|
28051
28643
|
const explicitHome = process.env.HERMES_HOME?.trim();
|
|
28052
|
-
return explicitHome || (0,
|
|
28644
|
+
return explicitHome || (0, import_path9.join)((0, import_os3.homedir)(), ".hermes");
|
|
28053
28645
|
}
|
|
28054
28646
|
function loadHermesCoordinatorBaseConfig(targetConfigPath) {
|
|
28055
28647
|
const sourceHome = resolveHermesUserHome();
|
|
28056
|
-
const sourceConfigPath = (0,
|
|
28648
|
+
const sourceConfigPath = (0, import_path9.join)(sourceHome, "config.yaml");
|
|
28057
28649
|
if (!fs11.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
28058
|
-
if ((0,
|
|
28650
|
+
if ((0, import_path9.resolve)(sourceConfigPath) === (0, import_path9.resolve)(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
28059
28651
|
const parsed = parseMeshCoordinatorMcpConfig(fs11.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
|
|
28060
28652
|
const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
|
|
28061
28653
|
return { config: baseConfig, sourceHome, sourceConfigPath };
|
|
@@ -28089,10 +28681,10 @@ function stripHermesCoordinatorTempModelProviderOverrides(config) {
|
|
|
28089
28681
|
return sanitized;
|
|
28090
28682
|
}
|
|
28091
28683
|
function copyHermesCoordinatorCredentialFiles(sourceHome, targetHome) {
|
|
28092
|
-
if ((0,
|
|
28684
|
+
if ((0, import_path9.resolve)(sourceHome) === (0, import_path9.resolve)(targetHome)) return;
|
|
28093
28685
|
for (const fileName of [".env", "auth.json"]) {
|
|
28094
|
-
const sourcePath = (0,
|
|
28095
|
-
const targetPath = (0,
|
|
28686
|
+
const sourcePath = (0, import_path9.join)(sourceHome, fileName);
|
|
28687
|
+
const targetPath = (0, import_path9.join)(targetHome, fileName);
|
|
28096
28688
|
if (!fs11.existsSync(sourcePath)) continue;
|
|
28097
28689
|
try {
|
|
28098
28690
|
fs11.copyFileSync(sourcePath, targetPath);
|
|
@@ -28474,7 +29066,7 @@ var DaemonCommandRouter = class {
|
|
|
28474
29066
|
}
|
|
28475
29067
|
const { resolveWorktreePath: resolveWorktreePath2, listWorktrees: listWorktrees2, removeWorktree: removeWorktree2 } = await Promise.resolve().then(() => (init_git_worktree(), git_worktree_exports));
|
|
28476
29068
|
const normalizePath = (value) => {
|
|
28477
|
-
const resolved = (0,
|
|
29069
|
+
const resolved = (0, import_path9.resolve)(value);
|
|
28478
29070
|
try {
|
|
28479
29071
|
return fs11.realpathSync(resolved);
|
|
28480
29072
|
} catch {
|
|
@@ -28548,10 +29140,10 @@ var DaemonCommandRouter = class {
|
|
|
28548
29140
|
if (metadataStatus === "merged_to_main" || metadataStatus === "cleanup_candidate") {
|
|
28549
29141
|
return { allow: true, status: metadataStatus, source: "node_branch_convergence" };
|
|
28550
29142
|
}
|
|
28551
|
-
const { execFile:
|
|
28552
|
-
const { promisify:
|
|
28553
|
-
const execFileAsync3 =
|
|
28554
|
-
const
|
|
29143
|
+
const { execFile: execFile4 } = await import("child_process");
|
|
29144
|
+
const { promisify: promisify7 } = await import("util");
|
|
29145
|
+
const execFileAsync3 = promisify7(execFile4);
|
|
29146
|
+
const runGit3 = async (gitArgs, cwd) => {
|
|
28555
29147
|
const { stdout } = await execFileAsync3("git", gitArgs, {
|
|
28556
29148
|
cwd,
|
|
28557
29149
|
encoding: "utf8",
|
|
@@ -28563,14 +29155,14 @@ var DaemonCommandRouter = class {
|
|
|
28563
29155
|
};
|
|
28564
29156
|
let head = "";
|
|
28565
29157
|
try {
|
|
28566
|
-
head = await
|
|
29158
|
+
head = await runGit3(["rev-parse", "HEAD"], args.workspace);
|
|
28567
29159
|
} catch (e) {
|
|
28568
29160
|
return { allow: false, error: `could not resolve worktree HEAD: ${e?.message || e}` };
|
|
28569
29161
|
}
|
|
28570
29162
|
if (!head) return { allow: false, error: "worktree HEAD is empty" };
|
|
28571
29163
|
const candidateRefs = [];
|
|
28572
29164
|
try {
|
|
28573
|
-
const defaultBranch = await
|
|
29165
|
+
const defaultBranch = await runGit3(["branch", "--show-current"], args.repoRoot);
|
|
28574
29166
|
if (defaultBranch) {
|
|
28575
29167
|
candidateRefs.push(defaultBranch, `origin/${defaultBranch}`);
|
|
28576
29168
|
}
|
|
@@ -28584,13 +29176,13 @@ var DaemonCommandRouter = class {
|
|
|
28584
29176
|
seen.add(ref);
|
|
28585
29177
|
let commit = "";
|
|
28586
29178
|
try {
|
|
28587
|
-
commit = await
|
|
29179
|
+
commit = await runGit3(["rev-parse", "--verify", `${ref}^{commit}`], args.repoRoot);
|
|
28588
29180
|
} catch {
|
|
28589
29181
|
continue;
|
|
28590
29182
|
}
|
|
28591
29183
|
checkedRefs.push(ref);
|
|
28592
29184
|
try {
|
|
28593
|
-
await
|
|
29185
|
+
await runGit3(["merge-base", "--is-ancestor", head, commit], args.repoRoot);
|
|
28594
29186
|
return { allow: true, status: "merged_to_default_ref", source: "git_merge_base", ref };
|
|
28595
29187
|
} catch {
|
|
28596
29188
|
}
|
|
@@ -28982,9 +29574,9 @@ var DaemonCommandRouter = class {
|
|
|
28982
29574
|
const sourceNode = node.clonedFromNodeId ? mesh?.nodes.find((n) => n.id === node.clonedFromNodeId || n.nodeId === node.clonedFromNodeId) : mesh?.nodes.find((n) => !n.isLocalWorktree);
|
|
28983
29575
|
const repoRoot = sourceNode?.repoRoot || sourceNode?.workspace;
|
|
28984
29576
|
if (!repoRoot) return { success: false, error: "Source node repoRoot not found", refineStages };
|
|
28985
|
-
const { execFile:
|
|
28986
|
-
const { promisify:
|
|
28987
|
-
const execFileAsync3 =
|
|
29577
|
+
const { execFile: execFile4 } = await import("child_process");
|
|
29578
|
+
const { promisify: promisify7 } = await import("util");
|
|
29579
|
+
const execFileAsync3 = promisify7(execFile4);
|
|
28988
29580
|
const resolveStarted = Date.now();
|
|
28989
29581
|
const { stdout: branchStdout } = await execFileAsync3("git", ["branch", "--show-current"], { cwd: node.workspace, encoding: "utf8" });
|
|
28990
29582
|
const branch = branchStdout.trim();
|
|
@@ -29051,7 +29643,8 @@ var DaemonCommandRouter = class {
|
|
|
29051
29643
|
equivalent: patchEquivalence.equivalent,
|
|
29052
29644
|
expectedPatchId: patchEquivalence.expectedPatchId,
|
|
29053
29645
|
actualPatchId: patchEquivalence.actualPatchId,
|
|
29054
|
-
error: patchEquivalence.error
|
|
29646
|
+
error: patchEquivalence.error,
|
|
29647
|
+
actionableHint: patchEquivalence.actionableHint
|
|
29055
29648
|
});
|
|
29056
29649
|
if (!patchEquivalence.equivalent) {
|
|
29057
29650
|
return {
|
|
@@ -29210,6 +29803,49 @@ var DaemonCommandRouter = class {
|
|
|
29210
29803
|
}
|
|
29211
29804
|
};
|
|
29212
29805
|
}
|
|
29806
|
+
const submoduleAlignmentStarted = Date.now();
|
|
29807
|
+
const submoduleAlignment = await alignRefinerySubmodulesAfterMerge(repoRoot, baseHead, "HEAD", {
|
|
29808
|
+
submoduleIgnorePaths: Array.isArray(sourceNode?.policy?.submoduleIgnorePaths) ? sourceNode.policy.submoduleIgnorePaths.filter((value) => typeof value === "string") : void 0
|
|
29809
|
+
});
|
|
29810
|
+
if (submoduleAlignment.status !== "skipped") {
|
|
29811
|
+
recordMeshRefineStage(refineStages, "submodule_alignment", submoduleAlignment.status, submoduleAlignmentStarted, {
|
|
29812
|
+
changedGitlinkPaths: submoduleAlignment.changedGitlinkPaths,
|
|
29813
|
+
outOfSyncPaths: submoduleAlignment.outOfSyncPaths,
|
|
29814
|
+
updatedPaths: submoduleAlignment.updatedPaths,
|
|
29815
|
+
verifiedPaths: submoduleAlignment.verifiedPaths,
|
|
29816
|
+
command: submoduleAlignment.command,
|
|
29817
|
+
error: submoduleAlignment.error
|
|
29818
|
+
});
|
|
29819
|
+
}
|
|
29820
|
+
if (submoduleAlignment.status === "failed") {
|
|
29821
|
+
return {
|
|
29822
|
+
success: false,
|
|
29823
|
+
code: "post_merge_submodule_alignment_failed",
|
|
29824
|
+
error: "Refinery merge completed but post-merge submodule checkout alignment failed; run the reported git submodule update command and re-check base workspace status.",
|
|
29825
|
+
merged: true,
|
|
29826
|
+
branch,
|
|
29827
|
+
into: baseBranch,
|
|
29828
|
+
validationSummary,
|
|
29829
|
+
patchEquivalence,
|
|
29830
|
+
submoduleReachability,
|
|
29831
|
+
submoduleAlignment,
|
|
29832
|
+
mergeResult,
|
|
29833
|
+
refineStages,
|
|
29834
|
+
finalBranchConvergenceState: {
|
|
29835
|
+
branch: baseBranch,
|
|
29836
|
+
mergedBranch: branch,
|
|
29837
|
+
baseBranch,
|
|
29838
|
+
merged: true,
|
|
29839
|
+
removed: false,
|
|
29840
|
+
validation: "passed",
|
|
29841
|
+
patchEquivalence: "passed",
|
|
29842
|
+
submoduleReachability: "passed",
|
|
29843
|
+
submoduleAlignment: "failed",
|
|
29844
|
+
status: "post_merge_alignment_failed",
|
|
29845
|
+
nextStep: submoduleAlignment.command || "Run git submodule update --init --recursive for the reported path(s), then re-check base workspace status."
|
|
29846
|
+
}
|
|
29847
|
+
};
|
|
29848
|
+
}
|
|
29213
29849
|
const cleanupStarted = Date.now();
|
|
29214
29850
|
const removeResult = await this.execute("remove_mesh_node", {
|
|
29215
29851
|
meshId,
|
|
@@ -29229,7 +29865,7 @@ var DaemonCommandRouter = class {
|
|
|
29229
29865
|
appendLedgerEntry2(meshId, {
|
|
29230
29866
|
kind: "node_removed",
|
|
29231
29867
|
nodeId,
|
|
29232
|
-
payload: { refined: true, mergedBranch: branch, into: baseBranch, validationSummary, patchEquivalence, submoduleReachability }
|
|
29868
|
+
payload: { refined: true, mergedBranch: branch, into: baseBranch, validationSummary, patchEquivalence, submoduleReachability, submoduleAlignment }
|
|
29233
29869
|
});
|
|
29234
29870
|
recordMeshRefineStage(refineStages, "ledger", "passed", ledgerStarted);
|
|
29235
29871
|
} catch (e) {
|
|
@@ -29244,6 +29880,7 @@ var DaemonCommandRouter = class {
|
|
|
29244
29880
|
removed: removeResult?.success !== false,
|
|
29245
29881
|
validation: "passed",
|
|
29246
29882
|
patchEquivalence: "passed",
|
|
29883
|
+
submoduleAlignment: submoduleAlignment.status,
|
|
29247
29884
|
status: removeResult?.success === false ? "merged_cleanup_failed" : "merged"
|
|
29248
29885
|
};
|
|
29249
29886
|
if (removeResult?.success === false) {
|
|
@@ -29258,6 +29895,7 @@ var DaemonCommandRouter = class {
|
|
|
29258
29895
|
validationSummary,
|
|
29259
29896
|
patchEquivalence,
|
|
29260
29897
|
submoduleReachability,
|
|
29898
|
+
submoduleAlignment,
|
|
29261
29899
|
mergeResult,
|
|
29262
29900
|
refineStages,
|
|
29263
29901
|
...ledgerError ? { ledgerError } : {},
|
|
@@ -29273,6 +29911,7 @@ var DaemonCommandRouter = class {
|
|
|
29273
29911
|
validationSummary,
|
|
29274
29912
|
patchEquivalence,
|
|
29275
29913
|
submoduleReachability,
|
|
29914
|
+
submoduleAlignment,
|
|
29276
29915
|
mergeResult,
|
|
29277
29916
|
refineStages,
|
|
29278
29917
|
...ledgerError ? { ledgerError } : {},
|
|
@@ -30355,6 +30994,12 @@ var DaemonCommandRouter = class {
|
|
|
30355
30994
|
success: true,
|
|
30356
30995
|
schema: MESH_REFINE_CONFIG_SCHEMA,
|
|
30357
30996
|
locations: MESH_REFINE_CONFIG_LOCATIONS,
|
|
30997
|
+
worktreeBootstrap: {
|
|
30998
|
+
schema: MESH_WORKTREE_BOOTSTRAP_CONFIG_SCHEMA,
|
|
30999
|
+
locations: MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS,
|
|
31000
|
+
sourceOfTruth: "repo worktree bootstrap config",
|
|
31001
|
+
runBehavior: "When present and enabled, clone_mesh_node runs commands after submodule initialization and records status on the worktree node."
|
|
31002
|
+
},
|
|
30358
31003
|
sourceOfTruth: "repo mesh/refine config",
|
|
30359
31004
|
heuristicRole: "suggestions_only_not_execution_path"
|
|
30360
31005
|
};
|
|
@@ -30549,8 +31194,8 @@ var DaemonCommandRouter = class {
|
|
|
30549
31194
|
const initSubmodules = sourceNode.policy?.initSubmodulesOnClone !== false;
|
|
30550
31195
|
if (initSubmodules) {
|
|
30551
31196
|
try {
|
|
30552
|
-
const { runGit:
|
|
30553
|
-
await
|
|
31197
|
+
const { runGit: runGit3 } = await Promise.resolve().then(() => (init_git_executor(), git_executor_exports));
|
|
31198
|
+
await runGit3(
|
|
30554
31199
|
{ workspace: result.worktreePath, repoRoot: result.worktreePath, isGitRepo: true },
|
|
30555
31200
|
["submodule", "update", "--init", "--recursive"],
|
|
30556
31201
|
{ timeoutMs: 12e4 }
|
|
@@ -30559,12 +31204,35 @@ var DaemonCommandRouter = class {
|
|
|
30559
31204
|
console.warn("[mesh] Submodule init failed for worktree:", subErr.message);
|
|
30560
31205
|
}
|
|
30561
31206
|
}
|
|
31207
|
+
const bootstrapState = await runMeshWorktreeBootstrap(mesh, result.worktreePath);
|
|
31208
|
+
node.worktreeBootstrap = bootstrapState;
|
|
31209
|
+
if (!meshRecord.inline) {
|
|
31210
|
+
try {
|
|
31211
|
+
const { updateNode: updateNode2 } = await Promise.resolve().then(() => (init_mesh_config(), mesh_config_exports));
|
|
31212
|
+
updateNode2(meshId, node.id, { worktreeBootstrap: bootstrapState });
|
|
31213
|
+
this.invalidateAggregateMeshStatus(meshId);
|
|
31214
|
+
} catch {
|
|
31215
|
+
}
|
|
31216
|
+
}
|
|
30562
31217
|
try {
|
|
30563
31218
|
const { appendLedgerEntry: appendLedgerEntry2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
30564
31219
|
appendLedgerEntry2(meshId, {
|
|
30565
31220
|
kind: "node_cloned",
|
|
30566
31221
|
nodeId: node.id,
|
|
30567
|
-
payload: {
|
|
31222
|
+
payload: {
|
|
31223
|
+
sourceNodeId,
|
|
31224
|
+
branch: result.branch,
|
|
31225
|
+
worktreePath: result.worktreePath,
|
|
31226
|
+
submodulesInitialized: initSubmodules,
|
|
31227
|
+
worktreeBootstrap: {
|
|
31228
|
+
status: bootstrapState.status,
|
|
31229
|
+
required: bootstrapState.required,
|
|
31230
|
+
configSource: bootstrapState.configSource,
|
|
31231
|
+
configSourceType: bootstrapState.configSourceType,
|
|
31232
|
+
lastCommand: bootstrapState.lastCommand,
|
|
31233
|
+
exitCode: bootstrapState.exitCode
|
|
31234
|
+
}
|
|
31235
|
+
}
|
|
30568
31236
|
});
|
|
30569
31237
|
} catch {
|
|
30570
31238
|
}
|
|
@@ -30572,7 +31240,8 @@ var DaemonCommandRouter = class {
|
|
|
30572
31240
|
success: true,
|
|
30573
31241
|
node,
|
|
30574
31242
|
worktreePath: result.worktreePath,
|
|
30575
|
-
branch: result.branch
|
|
31243
|
+
branch: result.branch,
|
|
31244
|
+
worktreeBootstrap: bootstrapState
|
|
30576
31245
|
};
|
|
30577
31246
|
} catch (e) {
|
|
30578
31247
|
return { success: false, error: e.message };
|
|
@@ -30800,7 +31469,7 @@ ${block2}`);
|
|
|
30800
31469
|
workspace
|
|
30801
31470
|
};
|
|
30802
31471
|
}
|
|
30803
|
-
const { existsSync:
|
|
31472
|
+
const { existsSync: existsSync28, readFileSync: readFileSync21, writeFileSync: writeFileSync14, copyFileSync: copyFileSync4, mkdirSync: mkdirSync18 } = await import("fs");
|
|
30804
31473
|
const { dirname: dirname9 } = await import("path");
|
|
30805
31474
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
30806
31475
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
@@ -30843,14 +31512,14 @@ ${block2}`);
|
|
|
30843
31512
|
if (hermesManualFallback) return returnManualFallback(message);
|
|
30844
31513
|
return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
|
|
30845
31514
|
}
|
|
30846
|
-
const hadExistingMcpConfig =
|
|
31515
|
+
const hadExistingMcpConfig = existsSync28(mcpConfigPath);
|
|
30847
31516
|
let existingMcpConfig = hermesBaseConfig?.config || {};
|
|
30848
31517
|
if (hermesBaseConfig) {
|
|
30849
31518
|
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname9(mcpConfigPath));
|
|
30850
31519
|
}
|
|
30851
31520
|
if (hadExistingMcpConfig) {
|
|
30852
31521
|
try {
|
|
30853
|
-
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(
|
|
31522
|
+
const parsedExistingMcpConfig = parseMeshCoordinatorMcpConfig(readFileSync21(mcpConfigPath, "utf-8"), configFormat);
|
|
30854
31523
|
const existingCoordinatorConfig = hermesManualFallback ? stripHermesCoordinatorTempModelProviderOverrides(parsedExistingMcpConfig) : parsedExistingMcpConfig;
|
|
30855
31524
|
existingMcpConfig = { ...existingMcpConfig, ...existingCoordinatorConfig };
|
|
30856
31525
|
copyFileSync4(mcpConfigPath, mcpConfigPath + ".backup");
|
|
@@ -30962,6 +31631,7 @@ ${block2}`);
|
|
|
30962
31631
|
const queueSummary = getMeshQueueStats2(meshId);
|
|
30963
31632
|
const { readLedgerEntries: readLedgerEntries2, getLedgerSummary: getLedgerSummary2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
30964
31633
|
const ledgerEntries = readLedgerEntries2(meshId, { tail: 20 });
|
|
31634
|
+
const asyncRefineLedgerEntries = readLedgerEntries2(meshId, { tail: 100 });
|
|
30965
31635
|
const ledgerSummary = getLedgerSummary2(meshId);
|
|
30966
31636
|
const sessionHostRecords = this.deps.sessionHostControl?.listSessions ? await this.deps.sessionHostControl.listSessions().catch(() => []) : [];
|
|
30967
31637
|
const liveMeshSessions = partitionSessionHostRecords(Array.isArray(sessionHostRecords) ? sessionHostRecords : []).liveRuntimes;
|
|
@@ -31224,6 +31894,20 @@ ${block2}`);
|
|
|
31224
31894
|
nodeStatuses.push(status);
|
|
31225
31895
|
}
|
|
31226
31896
|
const pendingCoordinatorEvents = drainPendingMeshCoordinatorEvents(meshId);
|
|
31897
|
+
const previewFreshness = (() => {
|
|
31898
|
+
const localRepoRoot = nodeStatuses.map((node) => readStringValue(node?.git?.repoRoot, node?.repoRoot, node?.workspace)).find((candidate) => !!candidate && fs11.existsSync(candidate));
|
|
31899
|
+
return localRepoRoot ? buildPreviewFreshness(localRepoRoot) : void 0;
|
|
31900
|
+
})();
|
|
31901
|
+
const asyncRefineJobs = buildMeshAsyncRefineJobs({
|
|
31902
|
+
meshId,
|
|
31903
|
+
ledgerEntries: asyncRefineLedgerEntries,
|
|
31904
|
+
pendingEvents: pendingCoordinatorEvents
|
|
31905
|
+
});
|
|
31906
|
+
const historicalSessions = buildHistoricalMeshSessions({
|
|
31907
|
+
meshId,
|
|
31908
|
+
nodes: mesh.nodes || [],
|
|
31909
|
+
liveSessionRecords: liveMeshSessions
|
|
31910
|
+
});
|
|
31227
31911
|
const statusResult = {
|
|
31228
31912
|
success: true,
|
|
31229
31913
|
meshId: mesh.id,
|
|
@@ -31255,12 +31939,15 @@ ${block2}`);
|
|
|
31255
31939
|
partialNodeFailures: effectiveDirectTruth.unavailableNodeIds
|
|
31256
31940
|
}
|
|
31257
31941
|
} : {},
|
|
31258
|
-
historicalEvidenceOnly: ["recoveryHints", "ledger.summary", "queue.summary"]
|
|
31942
|
+
historicalEvidenceOnly: ["recoveryHints", "ledger.summary", "queue.summary", "historicalSessions"]
|
|
31259
31943
|
},
|
|
31260
31944
|
branchConvergenceSummary: summarizeInlineMeshBranchConvergence(nodeStatuses),
|
|
31945
|
+
...previewFreshness ? { previewFreshness, deployFreshness: previewFreshness } : {},
|
|
31261
31946
|
nodes: nodeStatuses,
|
|
31262
31947
|
queue: { tasks: queue, summary: queueSummary },
|
|
31263
31948
|
ledger: { entries: ledgerEntries, summary: ledgerSummary },
|
|
31949
|
+
...asyncRefineJobs.length > 0 ? { asyncRefineJobs } : {},
|
|
31950
|
+
...historicalSessions ? { historicalSessions } : {},
|
|
31264
31951
|
...pendingCoordinatorEvents.length > 0 ? { pendingCoordinatorEvents } : {}
|
|
31265
31952
|
};
|
|
31266
31953
|
const { pendingCoordinatorEvents: _pendingCoordinatorEvents, ...cacheableStatusResult } = statusResult;
|
|
@@ -31911,7 +32598,7 @@ var ProviderStreamAdapter = class {
|
|
|
31911
32598
|
const beforeCount = this.messageCount(before);
|
|
31912
32599
|
const beforeSignature = this.lastMessageSignature(before);
|
|
31913
32600
|
for (let attempt = 0; attempt < 12; attempt += 1) {
|
|
31914
|
-
await new Promise((
|
|
32601
|
+
await new Promise((resolve17) => setTimeout(resolve17, 250));
|
|
31915
32602
|
let state;
|
|
31916
32603
|
try {
|
|
31917
32604
|
state = await this.readChat(evaluate);
|
|
@@ -31933,7 +32620,7 @@ var ProviderStreamAdapter = class {
|
|
|
31933
32620
|
if (this.messageCount(first) > 0 || this.lastMessageSignature(first)) {
|
|
31934
32621
|
return first;
|
|
31935
32622
|
}
|
|
31936
|
-
await new Promise((
|
|
32623
|
+
await new Promise((resolve17) => setTimeout(resolve17, 150));
|
|
31937
32624
|
const second = await this.readChat(evaluate);
|
|
31938
32625
|
return this.messageCount(second) >= this.messageCount(first) ? second : first;
|
|
31939
32626
|
}
|
|
@@ -32084,7 +32771,7 @@ var ProviderStreamAdapter = class {
|
|
|
32084
32771
|
if (typeof data.error === "string" && data.error.trim()) return false;
|
|
32085
32772
|
}
|
|
32086
32773
|
for (let attempt = 0; attempt < 6; attempt += 1) {
|
|
32087
|
-
await new Promise((
|
|
32774
|
+
await new Promise((resolve17) => setTimeout(resolve17, 250));
|
|
32088
32775
|
const state = await this.readChat(evaluate);
|
|
32089
32776
|
const title = this.getStateTitle(state);
|
|
32090
32777
|
if (this.titlesMatch(title, sessionId)) return true;
|
|
@@ -33012,13 +33699,13 @@ var VersionArchive = class {
|
|
|
33012
33699
|
}
|
|
33013
33700
|
};
|
|
33014
33701
|
async function runCommand(cmd, timeout = 1e4) {
|
|
33015
|
-
return new Promise((
|
|
33702
|
+
return new Promise((resolve17) => {
|
|
33016
33703
|
(0, import_child_process9.exec)(cmd, {
|
|
33017
33704
|
encoding: "utf-8",
|
|
33018
33705
|
timeout
|
|
33019
33706
|
}, (error, stdout) => {
|
|
33020
|
-
if (error) return
|
|
33021
|
-
|
|
33707
|
+
if (error) return resolve17(null);
|
|
33708
|
+
resolve17(stdout.trim());
|
|
33022
33709
|
});
|
|
33023
33710
|
});
|
|
33024
33711
|
}
|
|
@@ -34707,7 +35394,7 @@ function getCliTargetBundle(ctx, type, instanceId) {
|
|
|
34707
35394
|
return { target, instance, adapter };
|
|
34708
35395
|
}
|
|
34709
35396
|
function sleep2(ms) {
|
|
34710
|
-
return new Promise((
|
|
35397
|
+
return new Promise((resolve17) => setTimeout(resolve17, ms));
|
|
34711
35398
|
}
|
|
34712
35399
|
async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
|
|
34713
35400
|
const startedAt = Date.now();
|
|
@@ -36962,15 +37649,15 @@ var DevServer = class _DevServer {
|
|
|
36962
37649
|
this.json(res, 500, { error: e.message });
|
|
36963
37650
|
}
|
|
36964
37651
|
});
|
|
36965
|
-
return new Promise((
|
|
37652
|
+
return new Promise((resolve17, reject) => {
|
|
36966
37653
|
this.server.listen(port, "127.0.0.1", () => {
|
|
36967
37654
|
this.log(`Dev server listening on http://127.0.0.1:${port}`);
|
|
36968
|
-
|
|
37655
|
+
resolve17();
|
|
36969
37656
|
});
|
|
36970
37657
|
this.server.on("error", (e) => {
|
|
36971
37658
|
if (e.code === "EADDRINUSE") {
|
|
36972
37659
|
this.log(`Port ${port} in use, skipping dev server`);
|
|
36973
|
-
|
|
37660
|
+
resolve17();
|
|
36974
37661
|
} else {
|
|
36975
37662
|
reject(e);
|
|
36976
37663
|
}
|
|
@@ -37052,20 +37739,20 @@ var DevServer = class _DevServer {
|
|
|
37052
37739
|
child.stderr?.on("data", (d) => {
|
|
37053
37740
|
stderr += d.toString().slice(0, 2e3);
|
|
37054
37741
|
});
|
|
37055
|
-
await new Promise((
|
|
37742
|
+
await new Promise((resolve17) => {
|
|
37056
37743
|
const timer = setTimeout(() => {
|
|
37057
37744
|
child.kill();
|
|
37058
|
-
|
|
37745
|
+
resolve17();
|
|
37059
37746
|
}, 3e3);
|
|
37060
37747
|
child.on("exit", () => {
|
|
37061
37748
|
clearTimeout(timer);
|
|
37062
|
-
|
|
37749
|
+
resolve17();
|
|
37063
37750
|
});
|
|
37064
37751
|
child.stdout?.once("data", () => {
|
|
37065
37752
|
setTimeout(() => {
|
|
37066
37753
|
child.kill();
|
|
37067
37754
|
clearTimeout(timer);
|
|
37068
|
-
|
|
37755
|
+
resolve17();
|
|
37069
37756
|
}, 500);
|
|
37070
37757
|
});
|
|
37071
37758
|
});
|
|
@@ -37568,14 +38255,14 @@ var DevServer = class _DevServer {
|
|
|
37568
38255
|
child.stderr?.on("data", (d) => {
|
|
37569
38256
|
stderr += d.toString();
|
|
37570
38257
|
});
|
|
37571
|
-
await new Promise((
|
|
38258
|
+
await new Promise((resolve17) => {
|
|
37572
38259
|
const timer = setTimeout(() => {
|
|
37573
38260
|
child.kill();
|
|
37574
|
-
|
|
38261
|
+
resolve17();
|
|
37575
38262
|
}, timeout);
|
|
37576
38263
|
child.on("exit", () => {
|
|
37577
38264
|
clearTimeout(timer);
|
|
37578
|
-
|
|
38265
|
+
resolve17();
|
|
37579
38266
|
});
|
|
37580
38267
|
});
|
|
37581
38268
|
const elapsed = Date.now() - start;
|
|
@@ -38245,14 +38932,14 @@ data: ${JSON.stringify(msg.data)}
|
|
|
38245
38932
|
res.end(JSON.stringify(data, null, 2));
|
|
38246
38933
|
}
|
|
38247
38934
|
async readBody(req) {
|
|
38248
|
-
return new Promise((
|
|
38935
|
+
return new Promise((resolve17) => {
|
|
38249
38936
|
let body = "";
|
|
38250
38937
|
req.on("data", (chunk) => body += chunk);
|
|
38251
38938
|
req.on("end", () => {
|
|
38252
38939
|
try {
|
|
38253
|
-
|
|
38940
|
+
resolve17(JSON.parse(body));
|
|
38254
38941
|
} catch {
|
|
38255
|
-
|
|
38942
|
+
resolve17({});
|
|
38256
38943
|
}
|
|
38257
38944
|
});
|
|
38258
38945
|
});
|
|
@@ -38790,7 +39477,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS, requiredRe
|
|
|
38790
39477
|
const deadline = Date.now() + timeoutMs;
|
|
38791
39478
|
while (Date.now() < deadline) {
|
|
38792
39479
|
if (await canConnect(endpoint, requiredRequestTypes)) return;
|
|
38793
|
-
await new Promise((
|
|
39480
|
+
await new Promise((resolve17) => setTimeout(resolve17, STARTUP_POLL_MS));
|
|
38794
39481
|
}
|
|
38795
39482
|
throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
|
|
38796
39483
|
}
|
|
@@ -38970,10 +39657,10 @@ async function installExtension(ide, extension) {
|
|
|
38970
39657
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
38971
39658
|
const fs17 = await import("fs");
|
|
38972
39659
|
fs17.writeFileSync(vsixPath, buffer);
|
|
38973
|
-
return new Promise((
|
|
39660
|
+
return new Promise((resolve17) => {
|
|
38974
39661
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
38975
39662
|
(0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error, _stdout, stderr) => {
|
|
38976
|
-
|
|
39663
|
+
resolve17({
|
|
38977
39664
|
extensionId: extension.id,
|
|
38978
39665
|
marketplaceId: extension.marketplaceId,
|
|
38979
39666
|
success: !error,
|
|
@@ -38986,11 +39673,11 @@ async function installExtension(ide, extension) {
|
|
|
38986
39673
|
} catch (e) {
|
|
38987
39674
|
}
|
|
38988
39675
|
}
|
|
38989
|
-
return new Promise((
|
|
39676
|
+
return new Promise((resolve17) => {
|
|
38990
39677
|
const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
|
|
38991
39678
|
(0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error, stdout, stderr) => {
|
|
38992
39679
|
if (error) {
|
|
38993
|
-
|
|
39680
|
+
resolve17({
|
|
38994
39681
|
extensionId: extension.id,
|
|
38995
39682
|
marketplaceId: extension.marketplaceId,
|
|
38996
39683
|
success: false,
|
|
@@ -38998,7 +39685,7 @@ async function installExtension(ide, extension) {
|
|
|
38998
39685
|
error: stderr || error.message
|
|
38999
39686
|
});
|
|
39000
39687
|
} else {
|
|
39001
|
-
|
|
39688
|
+
resolve17({
|
|
39002
39689
|
extensionId: extension.id,
|
|
39003
39690
|
marketplaceId: extension.marketplaceId,
|
|
39004
39691
|
success: true,
|
|
@@ -39373,6 +40060,8 @@ async function shutdownDaemonComponents(components) {
|
|
|
39373
40060
|
MAX_LEDGER_SLICE_LIMIT,
|
|
39374
40061
|
MESH_REFINE_CONFIG_LOCATIONS,
|
|
39375
40062
|
MESH_REFINE_CONFIG_SCHEMA,
|
|
40063
|
+
MESH_WORKTREE_BOOTSTRAP_CONFIG_LOCATIONS,
|
|
40064
|
+
MESH_WORKTREE_BOOTSTRAP_CONFIG_SCHEMA,
|
|
39376
40065
|
MIN_GIT_WORKSPACE_POLL_INTERVAL_MS,
|
|
39377
40066
|
MIN_MACHINE_RUNTIME_SUBSCRIPTION_INTERVAL_MS,
|
|
39378
40067
|
MIN_SESSION_HOST_DIAGNOSTICS_SUBSCRIPTION_INTERVAL_MS,
|
|
@@ -39393,10 +40082,12 @@ async function shutdownDaemonComponents(components) {
|
|
|
39393
40082
|
buildChatMessage,
|
|
39394
40083
|
buildChatMessageSignature,
|
|
39395
40084
|
buildChatTailDeliverySignature,
|
|
40085
|
+
buildCompactStaleDirectWorkSummary,
|
|
39396
40086
|
buildCoordinatorSystemPrompt,
|
|
39397
40087
|
buildMachineInfo,
|
|
39398
40088
|
buildMeshActiveWork,
|
|
39399
40089
|
buildMeshActiveWorkSummary,
|
|
40090
|
+
buildMeshAsyncRefineJobs,
|
|
39400
40091
|
buildMeshHostRequiredFailure,
|
|
39401
40092
|
buildMeshLedgerReconciliationEvidence,
|
|
39402
40093
|
buildMeshLedgerReplicaEvidence,
|
|
@@ -39505,6 +40196,7 @@ async function shutdownDaemonComponents(components) {
|
|
|
39505
40196
|
listWorktrees,
|
|
39506
40197
|
loadConfig,
|
|
39507
40198
|
loadMeshRefineConfig,
|
|
40199
|
+
loadMeshWorktreeBootstrapConfig,
|
|
39508
40200
|
loadState,
|
|
39509
40201
|
logCommand,
|
|
39510
40202
|
markSetupComplete,
|
|
@@ -39556,6 +40248,7 @@ async function shutdownDaemonComponents(components) {
|
|
|
39556
40248
|
resolveWorktreePath,
|
|
39557
40249
|
runAsyncBatch,
|
|
39558
40250
|
runGit,
|
|
40251
|
+
runMeshWorktreeBootstrap,
|
|
39559
40252
|
saveConfig,
|
|
39560
40253
|
saveState,
|
|
39561
40254
|
setDebugRuntimeConfig,
|
|
@@ -39577,6 +40270,7 @@ async function shutdownDaemonComponents(components) {
|
|
|
39577
40270
|
updateTaskStatus,
|
|
39578
40271
|
upsertSavedProviderSession,
|
|
39579
40272
|
validateMeshRefineConfig,
|
|
39580
|
-
validateMeshTaskModeRequest
|
|
40273
|
+
validateMeshTaskModeRequest,
|
|
40274
|
+
validateMeshWorktreeBootstrapConfig
|
|
39581
40275
|
});
|
|
39582
40276
|
//# sourceMappingURL=index.js.map
|