@adhdev/daemon-core 0.9.82-rc.377 → 0.9.82-rc.379
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/cli-adapters/provider-cli-adapter.d.ts +5 -0
- package/dist/cli-adapters/pty-write-chunking.d.ts +34 -0
- package/dist/commands/router.d.ts +3 -470
- package/dist/index.js +298 -218
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +299 -219
- package/dist/index.mjs.map +1 -1
- package/dist/mesh/mesh-coordinator-config.d.ts +21 -0
- package/dist/mesh/mesh-node-identity.d.ts +289 -0
- package/dist/mesh/mesh-refine-gates.d.ts +428 -0
- package/dist/providers/spec/fsm-driver.d.ts +6 -4
- package/package.json +2 -2
- package/src/cli-adapters/provider-cli-adapter.ts +62 -1
- package/src/cli-adapters/pty-write-chunking.ts +106 -0
- package/src/commands/med-family/mesh-crud.ts +28 -1
- package/src/commands/router.ts +104 -3650
- package/src/mesh/mesh-coordinator-config.ts +97 -0
- package/src/mesh/mesh-node-identity.ts +1887 -0
- package/src/mesh/mesh-queue-assignment.ts +34 -0
- package/src/mesh/mesh-refine-gates.ts +1652 -0
- package/src/providers/spec/fsm-driver.ts +13 -26
package/dist/index.js
CHANGED
|
@@ -316,10 +316,10 @@ function readInjected(value) {
|
|
|
316
316
|
}
|
|
317
317
|
function getDaemonBuildInfo() {
|
|
318
318
|
if (cached) return cached;
|
|
319
|
-
const commit = readInjected(true ? "
|
|
320
|
-
const commitShort = readInjected(true ? "
|
|
321
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
322
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
319
|
+
const commit = readInjected(true ? "7b74c2c74e315b3fa6eb9f18d694b79eeb561184" : void 0) ?? "unknown";
|
|
320
|
+
const commitShort = readInjected(true ? "7b74c2c7" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
321
|
+
const version = readInjected(true ? "0.9.82-rc.379" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
322
|
+
const builtAt = readInjected(true ? "2026-06-25T09:33:17.234Z" : void 0);
|
|
323
323
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
324
324
|
return cached;
|
|
325
325
|
}
|
|
@@ -7271,8 +7271,8 @@ function stripCoordinatorWrapperFile(filePath) {
|
|
|
7271
7271
|
const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length)).replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
|
|
7272
7272
|
if (!remaining.trim()) {
|
|
7273
7273
|
try {
|
|
7274
|
-
const
|
|
7275
|
-
|
|
7274
|
+
const fs38 = require("fs");
|
|
7275
|
+
fs38.unlinkSync(filePath);
|
|
7276
7276
|
} catch {
|
|
7277
7277
|
}
|
|
7278
7278
|
} else {
|
|
@@ -9800,9 +9800,9 @@ function findBinary(name) {
|
|
|
9800
9800
|
for (const ext of exes) {
|
|
9801
9801
|
const fullPath = path11.join(p, trimmed + ext);
|
|
9802
9802
|
try {
|
|
9803
|
-
const
|
|
9804
|
-
if (
|
|
9805
|
-
const stat2 =
|
|
9803
|
+
const fs38 = require("fs");
|
|
9804
|
+
if (fs38.existsSync(fullPath)) {
|
|
9805
|
+
const stat2 = fs38.statSync(fullPath);
|
|
9806
9806
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
9807
9807
|
return fullPath;
|
|
9808
9808
|
}
|
|
@@ -9816,12 +9816,12 @@ function findBinary(name) {
|
|
|
9816
9816
|
function isScriptBinary(binaryPath) {
|
|
9817
9817
|
if (!path11.isAbsolute(binaryPath)) return false;
|
|
9818
9818
|
try {
|
|
9819
|
-
const
|
|
9820
|
-
const resolved =
|
|
9819
|
+
const fs38 = require("fs");
|
|
9820
|
+
const resolved = fs38.realpathSync(binaryPath);
|
|
9821
9821
|
const head = Buffer.alloc(8);
|
|
9822
|
-
const fd =
|
|
9823
|
-
|
|
9824
|
-
|
|
9822
|
+
const fd = fs38.openSync(resolved, "r");
|
|
9823
|
+
fs38.readSync(fd, head, 0, 8, 0);
|
|
9824
|
+
fs38.closeSync(fd);
|
|
9825
9825
|
let i = 0;
|
|
9826
9826
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
9827
9827
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -9832,12 +9832,12 @@ function isScriptBinary(binaryPath) {
|
|
|
9832
9832
|
function looksLikeMachOOrElf(filePath) {
|
|
9833
9833
|
if (!path11.isAbsolute(filePath)) return false;
|
|
9834
9834
|
try {
|
|
9835
|
-
const
|
|
9836
|
-
const resolved =
|
|
9835
|
+
const fs38 = require("fs");
|
|
9836
|
+
const resolved = fs38.realpathSync(filePath);
|
|
9837
9837
|
const buf = Buffer.alloc(8);
|
|
9838
|
-
const fd =
|
|
9839
|
-
|
|
9840
|
-
|
|
9838
|
+
const fd = fs38.openSync(resolved, "r");
|
|
9839
|
+
fs38.readSync(fd, buf, 0, 8, 0);
|
|
9840
|
+
fs38.closeSync(fd);
|
|
9841
9841
|
let i = 0;
|
|
9842
9842
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
9843
9843
|
const b = buf.subarray(i);
|
|
@@ -10371,6 +10371,16 @@ function warnDispatchWarmupGetterMissingOnce(daemonId) {
|
|
|
10371
10371
|
dispatchWarmupGetterMissingWarned.add(daemonId);
|
|
10372
10372
|
LOG.warn("MeshQueue", `Mesh peer connection getter unavailable for ${String(daemonId).slice(0, 12)}; remote task-dispatch warmup deadline degraded to the combined connect+response window. Avoids a cold-open false-timeout but loses warm/cold precision \u2014 wire getMeshPeerConnectionStatus on this daemon.`);
|
|
10373
10373
|
}
|
|
10374
|
+
async function waitForLocalSessionReady(components, sessionId) {
|
|
10375
|
+
const adapter = components.cliManager?.adapters?.get(sessionId);
|
|
10376
|
+
if (!adapter || typeof adapter.isReady !== "function") return;
|
|
10377
|
+
const deadline = Date.now() + LOCAL_LAUNCH_READY_TIMEOUT_MS;
|
|
10378
|
+
while (Date.now() < deadline) {
|
|
10379
|
+
if (adapter.isReady() || adapter.currentStatus === "idle") return;
|
|
10380
|
+
await new Promise((resolve24) => setTimeout(resolve24, LOCAL_LAUNCH_READY_POLL_MS));
|
|
10381
|
+
}
|
|
10382
|
+
LOG.warn("MeshQueue", `Auto-launched session ${sessionId} not interactive after ${LOCAL_LAUNCH_READY_TIMEOUT_MS}ms; dispatching anyway (adapter queue-until-ready will buffer)`);
|
|
10383
|
+
}
|
|
10374
10384
|
function deliverTaskToSession(dispatchThunk, ctx, warmup) {
|
|
10375
10385
|
const delivery = createSessionDelivery({
|
|
10376
10386
|
meshId: ctx.meshId,
|
|
@@ -10967,6 +10977,7 @@ async function maybeAutoLaunchOneQueueSession(components, meshId, mesh) {
|
|
|
10967
10977
|
return false;
|
|
10968
10978
|
}
|
|
10969
10979
|
markAutoLaunch(meshId, task.id, { status: "completed", nodeId, providerType: resolved.providerType, sessionId });
|
|
10980
|
+
await waitForLocalSessionReady(components, sessionId);
|
|
10970
10981
|
tryAssignQueueTask(components, meshId, nodeId, sessionId, resolved.providerType);
|
|
10971
10982
|
return true;
|
|
10972
10983
|
} catch (e) {
|
|
@@ -11188,7 +11199,7 @@ function runIdleMaintenanceThenAssignQueue(components, args) {
|
|
|
11188
11199
|
});
|
|
11189
11200
|
});
|
|
11190
11201
|
}
|
|
11191
|
-
var import_fs12, IDLE_AUTO_FAST_FORWARD_THROTTLE_MS, idleAutoFastForwardLastAttempt, DISPATCH_CONFIRM_TIMEOUT_MS, DISPATCH_CONNECT_TIMEOUT_MS, dispatchWarmupGetterMissingWarned, autoLaunchInProgress, autoLaunchCooldownUntil, AUTO_LAUNCH_COOLDOWN_MS, AUTO_LAUNCH_AWAIT_CLAIM_MS, lastAutoLaunchLedgerKey, AUTO_LAUNCH_LEDGER_DEDUP_MAX;
|
|
11202
|
+
var import_fs12, IDLE_AUTO_FAST_FORWARD_THROTTLE_MS, idleAutoFastForwardLastAttempt, DISPATCH_CONFIRM_TIMEOUT_MS, DISPATCH_CONNECT_TIMEOUT_MS, dispatchWarmupGetterMissingWarned, LOCAL_LAUNCH_READY_TIMEOUT_MS, LOCAL_LAUNCH_READY_POLL_MS, autoLaunchInProgress, autoLaunchCooldownUntil, AUTO_LAUNCH_COOLDOWN_MS, AUTO_LAUNCH_AWAIT_CLAIM_MS, lastAutoLaunchLedgerKey, AUTO_LAUNCH_LEDGER_DEDUP_MAX;
|
|
11192
11203
|
var init_mesh_queue_assignment = __esm({
|
|
11193
11204
|
"src/mesh/mesh-queue-assignment.ts"() {
|
|
11194
11205
|
"use strict";
|
|
@@ -11214,6 +11225,8 @@ var init_mesh_queue_assignment = __esm({
|
|
|
11214
11225
|
DISPATCH_CONFIRM_TIMEOUT_MS = 12e4;
|
|
11215
11226
|
DISPATCH_CONNECT_TIMEOUT_MS = MESH_CONNECT_TIMEOUT_MS;
|
|
11216
11227
|
dispatchWarmupGetterMissingWarned = /* @__PURE__ */ new Set();
|
|
11228
|
+
LOCAL_LAUNCH_READY_TIMEOUT_MS = 15e3;
|
|
11229
|
+
LOCAL_LAUNCH_READY_POLL_MS = 100;
|
|
11217
11230
|
autoLaunchInProgress = /* @__PURE__ */ new Set();
|
|
11218
11231
|
autoLaunchCooldownUntil = /* @__PURE__ */ new Map();
|
|
11219
11232
|
AUTO_LAUNCH_COOLDOWN_MS = 5e3;
|
|
@@ -16977,8 +16990,8 @@ var init_pty_transport = __esm({
|
|
|
16977
16990
|
let cwd = options.cwd;
|
|
16978
16991
|
if (cwd) {
|
|
16979
16992
|
try {
|
|
16980
|
-
const
|
|
16981
|
-
const stat2 =
|
|
16993
|
+
const fs38 = require("fs");
|
|
16994
|
+
const stat2 = fs38.statSync(cwd);
|
|
16982
16995
|
if (!stat2.isDirectory()) cwd = os14.homedir();
|
|
16983
16996
|
} catch {
|
|
16984
16997
|
cwd = os14.homedir();
|
|
@@ -16997,6 +17010,34 @@ var init_pty_transport = __esm({
|
|
|
16997
17010
|
}
|
|
16998
17011
|
});
|
|
16999
17012
|
|
|
17013
|
+
// src/cli-adapters/pty-write-chunking.ts
|
|
17014
|
+
function chunkPreservingSurrogates(text, size) {
|
|
17015
|
+
const chunks = [];
|
|
17016
|
+
let offset = 0;
|
|
17017
|
+
while (offset < text.length) {
|
|
17018
|
+
let end = Math.min(text.length, offset + size);
|
|
17019
|
+
if (end < text.length) {
|
|
17020
|
+
const code = text.charCodeAt(end - 1);
|
|
17021
|
+
if (code >= 55296 && code <= 56319) end -= 1;
|
|
17022
|
+
}
|
|
17023
|
+
if (end <= offset) end = Math.min(text.length, offset + size);
|
|
17024
|
+
chunks.push(text.slice(offset, end));
|
|
17025
|
+
offset = end;
|
|
17026
|
+
}
|
|
17027
|
+
return chunks;
|
|
17028
|
+
}
|
|
17029
|
+
function shouldChunkWin32Write(length) {
|
|
17030
|
+
return length > WIN32_PTY_WRITE_CHUNK_CHARS;
|
|
17031
|
+
}
|
|
17032
|
+
var WIN32_PTY_WRITE_CHUNK_CHARS, WIN32_PTY_WRITE_CHUNK_GAP_MS;
|
|
17033
|
+
var init_pty_write_chunking = __esm({
|
|
17034
|
+
"src/cli-adapters/pty-write-chunking.ts"() {
|
|
17035
|
+
"use strict";
|
|
17036
|
+
WIN32_PTY_WRITE_CHUNK_CHARS = 1024;
|
|
17037
|
+
WIN32_PTY_WRITE_CHUNK_GAP_MS = 8;
|
|
17038
|
+
}
|
|
17039
|
+
});
|
|
17040
|
+
|
|
17000
17041
|
// src/providers/sdk/v1/builders/cli/visible-region.ts
|
|
17001
17042
|
function compile(re, flags) {
|
|
17002
17043
|
try {
|
|
@@ -18948,6 +18989,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
18948
18989
|
init_terminal_screen();
|
|
18949
18990
|
import_session_host_core5 = require("@adhdev/session-host-core");
|
|
18950
18991
|
init_pty_transport();
|
|
18992
|
+
init_pty_write_chunking();
|
|
18951
18993
|
init_provider_cli_shared();
|
|
18952
18994
|
init_cli_script_runner();
|
|
18953
18995
|
init_cli_state_engine();
|
|
@@ -19426,6 +19468,7 @@ ${lastSnapshot}`;
|
|
|
19426
19468
|
`[${this.cliType}] Startup settled (${trigger}, stableMs=${stableMs}, modal=${!!startupModal}) providerDir=${this.providerResolutionMeta.providerDir || "-"} scriptDir=${this.providerResolutionMeta.scriptDir || "-"} scriptsPath=${this.providerResolutionMeta.scriptsPath || "-"}`
|
|
19427
19469
|
);
|
|
19428
19470
|
this.onStatusChange?.();
|
|
19471
|
+
if (!startupModal) this.schedulePendingOutboundFlush();
|
|
19429
19472
|
}
|
|
19430
19473
|
scheduleStartupSettleCheck() {
|
|
19431
19474
|
if (!this.startupParseGate) return;
|
|
@@ -19746,8 +19789,26 @@ ${lastSnapshot}`;
|
|
|
19746
19789
|
}
|
|
19747
19790
|
async writeToPty(data) {
|
|
19748
19791
|
if (!this.ptyProcess) throw new Error(`${this.cliName} is not running`);
|
|
19792
|
+
if (process.platform === "win32" && shouldChunkWin32Write(data.length)) {
|
|
19793
|
+
await this.writeWin32Chunked(data);
|
|
19794
|
+
return;
|
|
19795
|
+
}
|
|
19749
19796
|
await this.ptyProcess.write(data);
|
|
19750
19797
|
}
|
|
19798
|
+
/** Write `data` to the PTY in bounded, surrogate-safe chunks with a short
|
|
19799
|
+
* inter-chunk gap (win32 paced write). Awaits each chunk's write and the gap
|
|
19800
|
+
* so the returned promise resolves only after the FINAL chunk (carrying any
|
|
19801
|
+
* trailing submit key) has been written. */
|
|
19802
|
+
async writeWin32Chunked(data) {
|
|
19803
|
+
const chunks = chunkPreservingSurrogates(data, WIN32_PTY_WRITE_CHUNK_CHARS);
|
|
19804
|
+
for (let i = 0; i < chunks.length; i += 1) {
|
|
19805
|
+
if (!this.ptyProcess) throw new Error(`${this.cliName} is not running`);
|
|
19806
|
+
await this.ptyProcess.write(chunks[i]);
|
|
19807
|
+
if (i + 1 < chunks.length) {
|
|
19808
|
+
await new Promise((resolve24) => setTimeout(resolve24, WIN32_PTY_WRITE_CHUNK_GAP_MS));
|
|
19809
|
+
}
|
|
19810
|
+
}
|
|
19811
|
+
}
|
|
19751
19812
|
resetPendingSendState(reason) {
|
|
19752
19813
|
this.responseBuffer = "";
|
|
19753
19814
|
if (this.responseTimeout) {
|
|
@@ -19995,7 +20056,13 @@ ${lastSnapshot}`;
|
|
|
19995
20056
|
LOG.info("CLI", `[${this.cliType}] sendMessage recovered idle prompt readiness`);
|
|
19996
20057
|
}
|
|
19997
20058
|
}
|
|
19998
|
-
if (!this.ready)
|
|
20059
|
+
if (!this.ready) {
|
|
20060
|
+
if (allowQueue) {
|
|
20061
|
+
this.enqueuePendingOutboundMessage(text, "not_ready_pending_prompt");
|
|
20062
|
+
return;
|
|
20063
|
+
}
|
|
20064
|
+
throw new Error(`${this.cliName} not ready (status: ${this.engine.currentStatus})`);
|
|
20065
|
+
}
|
|
19999
20066
|
const parsedSessionStatus = typeof parsedStatusBeforeSend?.status === "string" ? String(parsedStatusBeforeSend.status) : "";
|
|
20000
20067
|
if (!allowInputDuringGeneration && (parsedSessionStatus === "generating" || parsedSessionStatus === "no_progress" || parsedSessionStatus === "long_generating")) {
|
|
20001
20068
|
const parsedModal = parsedStatusBeforeSend?.activeModal ?? parsedStatusBeforeSend?.modal ?? null;
|
|
@@ -32922,7 +32989,7 @@ var DaemonCommandHandler = class {
|
|
|
32922
32989
|
return { success: false, error: "invalid type" };
|
|
32923
32990
|
}
|
|
32924
32991
|
const https = require("https");
|
|
32925
|
-
const
|
|
32992
|
+
const fs38 = require("fs");
|
|
32926
32993
|
const path43 = require("path");
|
|
32927
32994
|
const REGISTRY = "https://api.adhf.dev/api/v1/registry";
|
|
32928
32995
|
function fetchText(url, timeoutMs) {
|
|
@@ -32965,7 +33032,7 @@ var DaemonCommandHandler = class {
|
|
|
32965
33032
|
if (!targetDir.startsWith(installRootResolved + path43.sep)) {
|
|
32966
33033
|
return { success: false, error: "install path escaped upstream root" };
|
|
32967
33034
|
}
|
|
32968
|
-
|
|
33035
|
+
fs38.mkdirSync(targetDir, { recursive: true });
|
|
32969
33036
|
let manifestProbe = {};
|
|
32970
33037
|
try {
|
|
32971
33038
|
manifestProbe = JSON.parse(manifestBody);
|
|
@@ -32990,7 +33057,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
32990
33057
|
}
|
|
32991
33058
|
const targetFile = isV1 ? "provider.v1.json" : "provider.json";
|
|
32992
33059
|
const targetPath = path43.join(targetDir, targetFile);
|
|
32993
|
-
|
|
33060
|
+
fs38.writeFileSync(targetPath, manifestBody, "utf-8");
|
|
32994
33061
|
const manifestJson = JSON.parse(manifestBody);
|
|
32995
33062
|
const scriptFetch = await this.fetchProviderSources(
|
|
32996
33063
|
manifestJson,
|
|
@@ -33060,7 +33127,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33060
33127
|
const repo = source.repo;
|
|
33061
33128
|
const ref = source.ref;
|
|
33062
33129
|
const https = require("https");
|
|
33063
|
-
const
|
|
33130
|
+
const fs38 = require("fs");
|
|
33064
33131
|
const path43 = require("path");
|
|
33065
33132
|
function fetchJson(url, timeoutMs) {
|
|
33066
33133
|
return new Promise((resolve24, reject) => {
|
|
@@ -33144,8 +33211,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33144
33211
|
const relInside = entry.path.startsWith(sharedDirRel + "/") ? entry.path.slice(sharedDirRel.length + 1) : entry.path;
|
|
33145
33212
|
const outPath = path43.resolve(path43.join(sharedTargetDir, relInside));
|
|
33146
33213
|
if (!outPath.startsWith(path43.resolve(sharedTargetDir) + path43.sep)) continue;
|
|
33147
|
-
|
|
33148
|
-
|
|
33214
|
+
fs38.mkdirSync(path43.dirname(outPath), { recursive: true });
|
|
33215
|
+
fs38.writeFileSync(outPath, body);
|
|
33149
33216
|
fetchedCount++;
|
|
33150
33217
|
} catch (e) {
|
|
33151
33218
|
errors.push(`fetch shared ${entry.path}: ${e?.message ?? e}`);
|
|
@@ -33183,8 +33250,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33183
33250
|
errors.push(`refusing to write outside targetDir: ${entry.path}`);
|
|
33184
33251
|
continue;
|
|
33185
33252
|
}
|
|
33186
|
-
|
|
33187
|
-
|
|
33253
|
+
fs38.mkdirSync(path43.dirname(outPath), { recursive: true });
|
|
33254
|
+
fs38.writeFileSync(outPath, body);
|
|
33188
33255
|
fetchedCount++;
|
|
33189
33256
|
} catch (e) {
|
|
33190
33257
|
errors.push(`fetch ${entry.path}: ${e?.message ?? e}`);
|
|
@@ -33212,7 +33279,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33212
33279
|
if (!["cli", "ide", "extension", "acp"].includes(category)) {
|
|
33213
33280
|
return { success: false, error: `unknown category: ${category}` };
|
|
33214
33281
|
}
|
|
33215
|
-
const
|
|
33282
|
+
const fs38 = require("fs");
|
|
33216
33283
|
const path43 = require("path");
|
|
33217
33284
|
try {
|
|
33218
33285
|
const installRoot = this.getUpstreamInstallRoot();
|
|
@@ -33221,10 +33288,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33221
33288
|
if (!targetDir.startsWith(installRootResolved + path43.sep)) {
|
|
33222
33289
|
return { success: false, error: "refusing to delete outside upstream root" };
|
|
33223
33290
|
}
|
|
33224
|
-
if (!
|
|
33291
|
+
if (!fs38.existsSync(targetDir)) {
|
|
33225
33292
|
return { success: false, error: "not installed" };
|
|
33226
33293
|
}
|
|
33227
|
-
|
|
33294
|
+
fs38.rmSync(targetDir, { recursive: true, force: true });
|
|
33228
33295
|
if (this._ctx.providerLoader) {
|
|
33229
33296
|
this._ctx.providerLoader.reload();
|
|
33230
33297
|
this._ctx.providerLoader.registerToDetector();
|
|
@@ -33240,28 +33307,28 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33240
33307
|
* the UI and by the update checker.
|
|
33241
33308
|
*/
|
|
33242
33309
|
handleListInstalledProviders(_args) {
|
|
33243
|
-
const
|
|
33310
|
+
const fs38 = require("fs");
|
|
33244
33311
|
const path43 = require("path");
|
|
33245
33312
|
const installRoot = this.getUpstreamInstallRoot();
|
|
33246
|
-
if (!
|
|
33313
|
+
if (!fs38.existsSync(installRoot)) return { success: true, providers: [] };
|
|
33247
33314
|
const CATEGORIES = ["cli", "ide", "extension", "acp"];
|
|
33248
33315
|
const items = [];
|
|
33249
33316
|
for (const category of CATEGORIES) {
|
|
33250
33317
|
const categoryDir = path43.join(installRoot, category);
|
|
33251
|
-
if (!
|
|
33318
|
+
if (!fs38.existsSync(categoryDir)) continue;
|
|
33252
33319
|
let entries;
|
|
33253
33320
|
try {
|
|
33254
|
-
entries =
|
|
33321
|
+
entries = fs38.readdirSync(categoryDir);
|
|
33255
33322
|
} catch {
|
|
33256
33323
|
continue;
|
|
33257
33324
|
}
|
|
33258
33325
|
for (const type of entries) {
|
|
33259
33326
|
const v1Path = path43.join(categoryDir, type, "provider.v1.json");
|
|
33260
33327
|
const v0Path = path43.join(categoryDir, type, "provider.json");
|
|
33261
|
-
const manifestPath =
|
|
33328
|
+
const manifestPath = fs38.existsSync(v1Path) ? v1Path : fs38.existsSync(v0Path) ? v0Path : null;
|
|
33262
33329
|
if (!manifestPath) continue;
|
|
33263
33330
|
try {
|
|
33264
|
-
const m = JSON.parse(
|
|
33331
|
+
const m = JSON.parse(fs38.readFileSync(manifestPath, "utf-8"));
|
|
33265
33332
|
items.push({
|
|
33266
33333
|
type,
|
|
33267
33334
|
category,
|
|
@@ -33372,7 +33439,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33372
33439
|
if (!/^@[a-z0-9_-]+$/i.test(requestedName)) {
|
|
33373
33440
|
return { success: false, error: "name must match @[a-z0-9_-]+" };
|
|
33374
33441
|
}
|
|
33375
|
-
const
|
|
33442
|
+
const fs38 = require("fs");
|
|
33376
33443
|
const path43 = require("path");
|
|
33377
33444
|
const { spawnSync: spawnSync2 } = require("child_process");
|
|
33378
33445
|
const file = ext.loadExternalSources();
|
|
@@ -33383,8 +33450,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33383
33450
|
return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
|
|
33384
33451
|
}
|
|
33385
33452
|
const sourceDir = path43.join(ext.externalRoot(), requestedName);
|
|
33386
|
-
if (!
|
|
33387
|
-
if (
|
|
33453
|
+
if (!fs38.existsSync(ext.externalRoot())) fs38.mkdirSync(ext.externalRoot(), { recursive: true });
|
|
33454
|
+
if (fs38.existsSync(sourceDir)) {
|
|
33388
33455
|
return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
|
|
33389
33456
|
}
|
|
33390
33457
|
const clone = spawnSync2("git", ["clone", "--depth=1", "--branch", ref, "--", url, sourceDir], {
|
|
@@ -33394,7 +33461,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33394
33461
|
});
|
|
33395
33462
|
if (clone.status !== 0) {
|
|
33396
33463
|
try {
|
|
33397
|
-
|
|
33464
|
+
fs38.rmSync(sourceDir, { recursive: true, force: true });
|
|
33398
33465
|
} catch {
|
|
33399
33466
|
}
|
|
33400
33467
|
return { success: false, error: `git clone failed: ${(clone.stderr || clone.stdout || "").trim() || "unknown error"}` };
|
|
@@ -33438,15 +33505,15 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33438
33505
|
const name = typeof args?.name === "string" ? args.name.trim() : "";
|
|
33439
33506
|
if (!name) return { success: false, error: "name is required" };
|
|
33440
33507
|
const ext = (init_external_sources(), __toCommonJS(external_sources_exports));
|
|
33441
|
-
const
|
|
33508
|
+
const fs38 = require("fs");
|
|
33442
33509
|
const path43 = require("path");
|
|
33443
33510
|
const file = ext.loadExternalSources();
|
|
33444
33511
|
const match = file.sources.find((s2) => s2.name === name);
|
|
33445
33512
|
if (!match) return { success: false, error: `source "${name}" not registered` };
|
|
33446
33513
|
const sourceDir = path43.join(ext.externalRoot(), name);
|
|
33447
|
-
if (
|
|
33514
|
+
if (fs38.existsSync(sourceDir)) {
|
|
33448
33515
|
try {
|
|
33449
|
-
|
|
33516
|
+
fs38.rmSync(sourceDir, { recursive: true, force: true });
|
|
33450
33517
|
} catch (e) {
|
|
33451
33518
|
return { success: false, error: `failed to delete ${sourceDir}: ${e?.message || e}` };
|
|
33452
33519
|
}
|
|
@@ -34227,14 +34294,14 @@ var statusMetaHandlers = {
|
|
|
34227
34294
|
// src/commands/low-family/coordinator-prompt.ts
|
|
34228
34295
|
var coordinatorPromptHandlers = {
|
|
34229
34296
|
list_coordinator_prompts: async (_ctx, _args) => {
|
|
34230
|
-
const
|
|
34297
|
+
const fs38 = await import("fs");
|
|
34231
34298
|
const path43 = await import("path");
|
|
34232
34299
|
const os30 = await import("os");
|
|
34233
34300
|
const dir = path43.join(os30.homedir(), ".adhdev", "coordinator-prompts");
|
|
34234
34301
|
const entries = {};
|
|
34235
34302
|
try {
|
|
34236
|
-
if (
|
|
34237
|
-
for (const name of
|
|
34303
|
+
if (fs38.existsSync(dir)) {
|
|
34304
|
+
for (const name of fs38.readdirSync(dir)) {
|
|
34238
34305
|
const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
|
|
34239
34306
|
const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
|
|
34240
34307
|
const m = matchAppend || matchOverride;
|
|
@@ -34244,7 +34311,7 @@ var coordinatorPromptHandlers = {
|
|
|
34244
34311
|
const full = path43.join(dir, name);
|
|
34245
34312
|
let content = "";
|
|
34246
34313
|
try {
|
|
34247
|
-
content =
|
|
34314
|
+
content = fs38.readFileSync(full, "utf8");
|
|
34248
34315
|
} catch {
|
|
34249
34316
|
}
|
|
34250
34317
|
if (!entries[key]) entries[key] = { override: "", append: "" };
|
|
@@ -34258,7 +34325,7 @@ var coordinatorPromptHandlers = {
|
|
|
34258
34325
|
return { success: true, dir, entries };
|
|
34259
34326
|
},
|
|
34260
34327
|
write_coordinator_prompt: async (_ctx, args) => {
|
|
34261
|
-
const
|
|
34328
|
+
const fs38 = await import("fs");
|
|
34262
34329
|
const path43 = await import("path");
|
|
34263
34330
|
const os30 = await import("os");
|
|
34264
34331
|
const key = typeof args?.key === "string" ? args.key.trim() : "";
|
|
@@ -34271,11 +34338,11 @@ var coordinatorPromptHandlers = {
|
|
|
34271
34338
|
const filename = kind === "append" ? `${key}.append.md` : `${key}.md`;
|
|
34272
34339
|
const full = path43.join(dir, filename);
|
|
34273
34340
|
try {
|
|
34274
|
-
|
|
34341
|
+
fs38.mkdirSync(dir, { recursive: true });
|
|
34275
34342
|
if (content.trim()) {
|
|
34276
|
-
|
|
34277
|
-
} else if (
|
|
34278
|
-
|
|
34343
|
+
fs38.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
|
|
34344
|
+
} else if (fs38.existsSync(full)) {
|
|
34345
|
+
fs38.unlinkSync(full);
|
|
34279
34346
|
}
|
|
34280
34347
|
return { success: true, path: full, kind, key };
|
|
34281
34348
|
} catch (error) {
|
|
@@ -35606,6 +35673,7 @@ function applyPreLaunchTrust(trust, workingDir) {
|
|
|
35606
35673
|
|
|
35607
35674
|
// src/providers/spec/fsm-driver.ts
|
|
35608
35675
|
init_logger();
|
|
35676
|
+
init_pty_write_chunking();
|
|
35609
35677
|
function countNewlines(s2) {
|
|
35610
35678
|
let n = 0;
|
|
35611
35679
|
for (let i = 0; i < s2.length; i += 1) if (s2.charCodeAt(i) === 10) n += 1;
|
|
@@ -35616,8 +35684,6 @@ var WIN32_SUBMIT_RESEND_GAP_MS = 350;
|
|
|
35616
35684
|
var WIN32_SUBMIT_MAX_RESENDS = 14;
|
|
35617
35685
|
var WIN32_SUBMIT_SETTLE_MS = 500;
|
|
35618
35686
|
var WIN32_SUBMIT_SETTLE_POLL_MS = 120;
|
|
35619
|
-
var WIN32_PTY_WRITE_CHUNK_CHARS = 1024;
|
|
35620
|
-
var WIN32_PTY_WRITE_CHUNK_GAP_MS = 8;
|
|
35621
35687
|
var WIN32_ECHO_PROBE_CHARS = 16;
|
|
35622
35688
|
var WIN32_ECHO_MAX_WAIT_MS = 2e4;
|
|
35623
35689
|
function normalizeForEcho(s2) {
|
|
@@ -35629,21 +35695,7 @@ function resolveSubmitDelayMs(specBeforeSubmit, text) {
|
|
|
35629
35695
|
const spec = typeof specBeforeSubmit === "number" && specBeforeSubmit > 0 ? specBeforeSubmit : 0;
|
|
35630
35696
|
return Math.max(spec, SUBMIT_DELAY_FLOOR_MS + linesBonus);
|
|
35631
35697
|
}
|
|
35632
|
-
|
|
35633
|
-
const chunks = [];
|
|
35634
|
-
let offset = 0;
|
|
35635
|
-
while (offset < text.length) {
|
|
35636
|
-
let end = Math.min(text.length, offset + size);
|
|
35637
|
-
if (end < text.length) {
|
|
35638
|
-
const code = text.charCodeAt(end - 1);
|
|
35639
|
-
if (code >= 55296 && code <= 56319) end -= 1;
|
|
35640
|
-
}
|
|
35641
|
-
if (end <= offset) end = Math.min(text.length, offset + size);
|
|
35642
|
-
chunks.push(text.slice(offset, end));
|
|
35643
|
-
offset = end;
|
|
35644
|
-
}
|
|
35645
|
-
return chunks;
|
|
35646
|
-
}
|
|
35698
|
+
var chunkPreservingSurrogates2 = chunkPreservingSurrogates;
|
|
35647
35699
|
function guessExt(mime) {
|
|
35648
35700
|
if (/png/i.test(mime)) return ".png";
|
|
35649
35701
|
if (/jpe?g/i.test(mime)) return ".jpg";
|
|
@@ -36314,7 +36366,7 @@ var FsmDriver = class {
|
|
|
36314
36366
|
this.adapter.send_keys(text);
|
|
36315
36367
|
return;
|
|
36316
36368
|
}
|
|
36317
|
-
const chunks =
|
|
36369
|
+
const chunks = chunkPreservingSurrogates2(text, WIN32_PTY_WRITE_CHUNK_CHARS);
|
|
36318
36370
|
let idx = 0;
|
|
36319
36371
|
const writeNext = () => {
|
|
36320
36372
|
this.win32WriteTimer = null;
|
|
@@ -45359,7 +45411,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
45359
45411
|
}
|
|
45360
45412
|
if (providerDir) {
|
|
45361
45413
|
try {
|
|
45362
|
-
const
|
|
45414
|
+
const fs38 = require("fs");
|
|
45363
45415
|
const path43 = require("path");
|
|
45364
45416
|
const candidates = [];
|
|
45365
45417
|
if (Array.isArray(base.compatibility)) {
|
|
@@ -45371,13 +45423,13 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
45371
45423
|
}
|
|
45372
45424
|
candidates.push(path43.join(providerDir, "specs", "default.json"));
|
|
45373
45425
|
candidates.push(path43.join(providerDir, "spec.json"));
|
|
45374
|
-
const specPath = candidates.find((p) =>
|
|
45426
|
+
const specPath = candidates.find((p) => fs38.existsSync(p));
|
|
45375
45427
|
if (specPath) {
|
|
45376
45428
|
resolved._resolvedSpecPath = specPath;
|
|
45377
45429
|
let specControls;
|
|
45378
45430
|
let nh;
|
|
45379
45431
|
try {
|
|
45380
|
-
const rawSpec = JSON.parse(
|
|
45432
|
+
const rawSpec = JSON.parse(fs38.readFileSync(specPath, "utf8"));
|
|
45381
45433
|
specControls = rawSpec.control_bar;
|
|
45382
45434
|
nh = rawSpec.native_history;
|
|
45383
45435
|
} catch {
|
|
@@ -45409,7 +45461,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
45409
45461
|
reader = (input) => executeNativeHistory(nh, input);
|
|
45410
45462
|
} else if (nh.override_path) {
|
|
45411
45463
|
const overrideFile = path43.resolve(providerDir, nh.override_path);
|
|
45412
|
-
if (
|
|
45464
|
+
if (fs38.existsSync(overrideFile)) {
|
|
45413
45465
|
try {
|
|
45414
45466
|
registerProviderScriptRootSafely(path43.dirname(path43.dirname(providerDir)));
|
|
45415
45467
|
delete require.cache[require.resolve(overrideFile)];
|
|
@@ -46591,7 +46643,7 @@ async function detectCurrentWorkspace(ideId) {
|
|
|
46591
46643
|
}
|
|
46592
46644
|
} else if (plat === "win32") {
|
|
46593
46645
|
try {
|
|
46594
|
-
const
|
|
46646
|
+
const fs38 = require("fs");
|
|
46595
46647
|
const appNameMap = getMacAppIdentifiers();
|
|
46596
46648
|
const appName = appNameMap[ideId];
|
|
46597
46649
|
if (appName) {
|
|
@@ -46600,8 +46652,8 @@ async function detectCurrentWorkspace(ideId) {
|
|
|
46600
46652
|
appName,
|
|
46601
46653
|
"storage.json"
|
|
46602
46654
|
);
|
|
46603
|
-
if (
|
|
46604
|
-
const data = JSON.parse(
|
|
46655
|
+
if (fs38.existsSync(storagePath)) {
|
|
46656
|
+
const data = JSON.parse(fs38.readFileSync(storagePath, "utf-8"));
|
|
46605
46657
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
46606
46658
|
if (workspaces.length > 0) {
|
|
46607
46659
|
const recent = workspaces[0];
|
|
@@ -47148,8 +47200,9 @@ var meshCrudHandlers = {
|
|
|
47148
47200
|
};
|
|
47149
47201
|
}
|
|
47150
47202
|
}
|
|
47203
|
+
const explicitCleanupMode = args?.sessionCleanupMode ?? args?.session_cleanup_mode;
|
|
47151
47204
|
const sessionCleanupMode = ctx.normalizeMeshSessionCleanupMode(
|
|
47152
|
-
|
|
47205
|
+
explicitCleanupMode ?? (node?.isLocalWorktree === true ? "stop_and_delete" : void 0) ?? mesh?.policy?.sessionCleanupOnNodeRemove
|
|
47153
47206
|
);
|
|
47154
47207
|
const explicitSessionIds = Array.isArray(args?.sessionIds) ? args.sessionIds.filter((v) => typeof v === "string" && v.trim().length > 0).map((v) => v.trim()) : void 0;
|
|
47155
47208
|
let sessionCleanup;
|
|
@@ -47221,12 +47274,16 @@ var meshCrudHandlers = {
|
|
|
47221
47274
|
}
|
|
47222
47275
|
}
|
|
47223
47276
|
const residueWarning = worktreeCleanup?.residue === true && typeof worktreeCleanup?.residueWarning === "string" ? worktreeCleanup.residueWarning : void 0;
|
|
47277
|
+
const skippedLiveSessionIds = Array.isArray(sessionCleanup?.skippedLiveSessionIds) ? sessionCleanup.skippedLiveSessionIds.filter((v) => typeof v === "string") : [];
|
|
47278
|
+
const orphanedSessionsRemaining = skippedLiveSessionIds.length > 0;
|
|
47279
|
+
const orphanNextAction = orphanedSessionsRemaining ? `Live session(s) [${skippedLiveSessionIds.join(", ")}] were skipped and still survive this node removal. Run mesh_cleanup_sessions with mode:'stop_and_delete' and sessionIds:[${skippedLiveSessionIds.map((id) => `'${id}'`).join(", ")}] to release them.` : void 0;
|
|
47224
47280
|
return {
|
|
47225
47281
|
success: true,
|
|
47226
47282
|
removed,
|
|
47227
47283
|
...residueWarning ? { residueWarning } : {},
|
|
47228
47284
|
...sessionCleanup ? { sessionCleanup } : {},
|
|
47229
|
-
...worktreeCleanup ? { worktreeCleanup } : {}
|
|
47285
|
+
...worktreeCleanup ? { worktreeCleanup } : {},
|
|
47286
|
+
...orphanedSessionsRemaining ? { orphanedSessionsRemaining: true, nextAction: orphanNextAction } : {}
|
|
47230
47287
|
};
|
|
47231
47288
|
} catch (e) {
|
|
47232
47289
|
return { success: false, error: e.message };
|
|
@@ -48559,7 +48616,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
48559
48616
|
workspace
|
|
48560
48617
|
};
|
|
48561
48618
|
}
|
|
48562
|
-
const { existsSync:
|
|
48619
|
+
const { existsSync: existsSync52, readFileSync: readFileSync40, writeFileSync: writeFileSync24, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
|
|
48563
48620
|
const { dirname: dirname17 } = await import("path");
|
|
48564
48621
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
48565
48622
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
@@ -48602,7 +48659,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
48602
48659
|
if (hermesManualFallback) return returnManualFallback(message);
|
|
48603
48660
|
return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
|
|
48604
48661
|
}
|
|
48605
|
-
const hadExistingMcpConfig =
|
|
48662
|
+
const hadExistingMcpConfig = existsSync52(mcpConfigPath);
|
|
48606
48663
|
let existingMcpConfig = hermesBaseConfig?.config || {};
|
|
48607
48664
|
if (hermesBaseConfig) {
|
|
48608
48665
|
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname17(mcpConfigPath));
|
|
@@ -49207,7 +49264,7 @@ var meshStatusHandlers = {
|
|
|
49207
49264
|
const { deriveMeshReviewInboxItems: deriveMeshReviewInboxItems2 } = await Promise.resolve().then(() => (init_mesh_review_inbox(), mesh_review_inbox_exports));
|
|
49208
49265
|
const { readLedgerEntries: readLedgerEntries2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
49209
49266
|
const { getGitDiffSummary: getGitDiffSummary2 } = await Promise.resolve().then(() => (init_git_diff(), git_diff_exports));
|
|
49210
|
-
const { existsSync:
|
|
49267
|
+
const { existsSync: existsSync52 } = await import("fs");
|
|
49211
49268
|
const meshRecord = await ctx.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
49212
49269
|
const mesh = meshRecord?.mesh;
|
|
49213
49270
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
@@ -49226,7 +49283,7 @@ var meshStatusHandlers = {
|
|
|
49226
49283
|
const derivation = deriveMeshReviewInboxItems2({ nodes: nodeStatuses, ledgerEntries });
|
|
49227
49284
|
for (const item of derivation.items) {
|
|
49228
49285
|
const workspace = item.workspace;
|
|
49229
|
-
if (!workspace || !
|
|
49286
|
+
if (!workspace || !existsSync52(workspace)) continue;
|
|
49230
49287
|
const baseRef = item.defaultBranch ? `origin/${item.defaultBranch}` : "origin/main";
|
|
49231
49288
|
try {
|
|
49232
49289
|
const diffResult = await getGitDiffSummary2(workspace, { baseRef, maxFiles: 100 });
|
|
@@ -49275,8 +49332,6 @@ var highFamilyRegistry = new Map(
|
|
|
49275
49332
|
);
|
|
49276
49333
|
|
|
49277
49334
|
// src/commands/router.ts
|
|
49278
|
-
init_cli_detector();
|
|
49279
|
-
init_git_status();
|
|
49280
49335
|
init_dist();
|
|
49281
49336
|
init_logger();
|
|
49282
49337
|
|
|
@@ -49426,7 +49481,6 @@ function getRecentCommands(count = 50) {
|
|
|
49426
49481
|
cleanOldFiles();
|
|
49427
49482
|
|
|
49428
49483
|
// src/commands/router.ts
|
|
49429
|
-
var yaml4 = __toESM(require("js-yaml"));
|
|
49430
49484
|
init_mesh_events();
|
|
49431
49485
|
init_mesh_host_ownership();
|
|
49432
49486
|
|
|
@@ -49519,13 +49573,18 @@ function orderMeshRefineBatchNodes(changeAreas) {
|
|
|
49519
49573
|
|
|
49520
49574
|
// src/commands/router.ts
|
|
49521
49575
|
init_mesh_work_queue();
|
|
49522
|
-
init_mesh_warmup_deadline();
|
|
49523
49576
|
init_repo_mesh_types();
|
|
49524
|
-
var
|
|
49525
|
-
var
|
|
49577
|
+
var import_path15 = require("path");
|
|
49578
|
+
var fs32 = __toESM(require("fs"));
|
|
49579
|
+
var import_node_child_process7 = require("child_process");
|
|
49580
|
+
|
|
49581
|
+
// src/mesh/mesh-node-identity.ts
|
|
49582
|
+
init_cli_detector();
|
|
49583
|
+
init_git_status();
|
|
49584
|
+
init_dist();
|
|
49585
|
+
init_logger();
|
|
49586
|
+
init_mesh_warmup_deadline();
|
|
49526
49587
|
var fs29 = __toESM(require("fs"));
|
|
49527
|
-
var import_node_child_process6 = require("child_process");
|
|
49528
|
-
init_resolve_executable();
|
|
49529
49588
|
init_runtime_defaults();
|
|
49530
49589
|
function readProviderPriorityFromPolicy(policy) {
|
|
49531
49590
|
const record = policy && typeof policy === "object" && !Array.isArray(policy) ? policy : {};
|
|
@@ -50746,6 +50805,13 @@ async function resolveProviderTypeFromPriority(args) {
|
|
|
50746
50805
|
}
|
|
50747
50806
|
return { error: `No usable provider detected for node '${args.nodeId}' from providerPriority: ${failed.join("; ")}` };
|
|
50748
50807
|
}
|
|
50808
|
+
|
|
50809
|
+
// src/mesh/mesh-refine-gates.ts
|
|
50810
|
+
init_git_status();
|
|
50811
|
+
var import_path13 = require("path");
|
|
50812
|
+
var fs30 = __toESM(require("fs"));
|
|
50813
|
+
var import_node_child_process6 = require("child_process");
|
|
50814
|
+
init_resolve_executable();
|
|
50749
50815
|
var REFINE_VALIDATION_TIMEOUT_MS = 12e4;
|
|
50750
50816
|
var REFINE_VALIDATION_OUTPUT_LIMIT_BYTES = 128 * 1024;
|
|
50751
50817
|
var REFINE_VALIDATION_SUMMARY_CHARS = 2e3;
|
|
@@ -50799,18 +50865,18 @@ function resolveRefineryAutoPublishSubmoduleMainCommits(mesh, workspace) {
|
|
|
50799
50865
|
return { enabled: false };
|
|
50800
50866
|
}
|
|
50801
50867
|
async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
|
|
50802
|
-
const { execFileSync:
|
|
50868
|
+
const { execFileSync: execFileSync8 } = await import("child_process");
|
|
50803
50869
|
const diffArgs = ["diff", "--patch", "--full-index", fromRef, toRef];
|
|
50804
50870
|
if (excludePaths.length > 0) {
|
|
50805
50871
|
diffArgs.push("--", ".", ...excludePaths.map((path43) => `:(exclude)${path43}`));
|
|
50806
50872
|
}
|
|
50807
|
-
const diff =
|
|
50873
|
+
const diff = execFileSync8("git", diffArgs, {
|
|
50808
50874
|
cwd,
|
|
50809
50875
|
encoding: "utf8",
|
|
50810
50876
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
50811
50877
|
});
|
|
50812
50878
|
if (!diff.trim()) return "";
|
|
50813
|
-
const patchId =
|
|
50879
|
+
const patchId = execFileSync8("git", ["patch-id", "--stable"], {
|
|
50814
50880
|
cwd,
|
|
50815
50881
|
input: diff,
|
|
50816
50882
|
encoding: "utf8",
|
|
@@ -50821,8 +50887,8 @@ async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
|
|
|
50821
50887
|
async function runMeshRefinePatchEquivalenceGate(repoRoot, baseHead, branchHead) {
|
|
50822
50888
|
const startedAt = Date.now();
|
|
50823
50889
|
try {
|
|
50824
|
-
const { execFileSync:
|
|
50825
|
-
const git = (args) =>
|
|
50890
|
+
const { execFileSync: execFileSync8 } = await import("child_process");
|
|
50891
|
+
const git = (args) => execFileSync8("git", args, {
|
|
50826
50892
|
cwd: repoRoot,
|
|
50827
50893
|
encoding: "utf8",
|
|
50828
50894
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -50913,8 +50979,8 @@ ${e?.stderr || ""}`
|
|
|
50913
50979
|
async function checkWorktreeChangesPatchEquivalentInRef(repoRoot, ref, worktreeHead) {
|
|
50914
50980
|
const startedAt = Date.now();
|
|
50915
50981
|
try {
|
|
50916
|
-
const { execFileSync:
|
|
50917
|
-
const git = (gitArgs) =>
|
|
50982
|
+
const { execFileSync: execFileSync8 } = await import("child_process");
|
|
50983
|
+
const git = (gitArgs) => execFileSync8("git", gitArgs, {
|
|
50918
50984
|
cwd: repoRoot,
|
|
50919
50985
|
encoding: "utf8",
|
|
50920
50986
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -50977,8 +51043,8 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
50977
51043
|
async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
|
|
50978
51044
|
const startedAt = Date.now();
|
|
50979
51045
|
try {
|
|
50980
|
-
const { execFileSync:
|
|
50981
|
-
const git = (args, opts) =>
|
|
51046
|
+
const { execFileSync: execFileSync8 } = await import("child_process");
|
|
51047
|
+
const git = (args, opts) => execFileSync8("git", args, {
|
|
50982
51048
|
cwd: opts?.cwd || repoRoot,
|
|
50983
51049
|
encoding: "utf8",
|
|
50984
51050
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -51101,7 +51167,7 @@ function isSubmoduleFastForward(submoduleRepoPath, baseCommit, branchCommit) {
|
|
|
51101
51167
|
if (!baseCommit || !branchCommit) return false;
|
|
51102
51168
|
if (baseCommit === branchCommit) return true;
|
|
51103
51169
|
try {
|
|
51104
|
-
if (!
|
|
51170
|
+
if (!fs30.existsSync(submoduleRepoPath)) return false;
|
|
51105
51171
|
(0, import_node_child_process6.execFileSync)("git", ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
51106
51172
|
(0, import_node_child_process6.execFileSync)("git", ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
51107
51173
|
(0, import_node_child_process6.execFileSync)("git", ["merge-base", "--is-ancestor", baseCommit, branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
@@ -51218,7 +51284,7 @@ function buildTreeWithGitlinksEqualized(repoRoot, commitish, paths, placeholderC
|
|
|
51218
51284
|
return newTree || void 0;
|
|
51219
51285
|
} finally {
|
|
51220
51286
|
try {
|
|
51221
|
-
|
|
51287
|
+
fs30.rmSync(tmpIndex, { force: true });
|
|
51222
51288
|
} catch {
|
|
51223
51289
|
}
|
|
51224
51290
|
}
|
|
@@ -51293,7 +51359,7 @@ function synthesizeTrivialFastForwardMergeTree(repoRoot, baseHead, branchHead, g
|
|
|
51293
51359
|
return newTree || void 0;
|
|
51294
51360
|
} finally {
|
|
51295
51361
|
try {
|
|
51296
|
-
|
|
51362
|
+
fs30.rmSync(tmpIndex, { force: true });
|
|
51297
51363
|
} catch {
|
|
51298
51364
|
}
|
|
51299
51365
|
}
|
|
@@ -51399,7 +51465,7 @@ async function runMeshRefineSubmoduleReachabilityGate(repoRoot, mergedTree, opti
|
|
|
51399
51465
|
return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
|
|
51400
51466
|
};
|
|
51401
51467
|
const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
|
|
51402
|
-
if (!
|
|
51468
|
+
if (!fs30.existsSync(worktreeSubmodulePath)) return false;
|
|
51403
51469
|
try {
|
|
51404
51470
|
await runGit3(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
|
|
51405
51471
|
} catch {
|
|
@@ -51422,7 +51488,7 @@ async function runMeshRefineSubmoduleReachabilityGate(repoRoot, mergedTree, opti
|
|
|
51422
51488
|
reachable: false
|
|
51423
51489
|
};
|
|
51424
51490
|
try {
|
|
51425
|
-
if (!
|
|
51491
|
+
if (!fs30.existsSync(submodulePath)) {
|
|
51426
51492
|
entry.error = `Submodule checkout missing at ${gitlink.path}`;
|
|
51427
51493
|
entry.publishRequired = true;
|
|
51428
51494
|
if (options.allowAutoPublishSubmoduleMainCommits === true) {
|
|
@@ -51659,9 +51725,9 @@ async function runMeshRefineValidationGate(mesh, workspace, opts) {
|
|
|
51659
51725
|
return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
|
|
51660
51726
|
};
|
|
51661
51727
|
const dependenciesLikelyMissing = (cwd) => {
|
|
51662
|
-
if (!
|
|
51663
|
-
if (
|
|
51664
|
-
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) =>
|
|
51728
|
+
if (!fs30.existsSync((0, import_path13.join)(cwd, "package.json"))) return false;
|
|
51729
|
+
if (fs30.existsSync((0, import_path13.join)(cwd, "node_modules"))) return false;
|
|
51730
|
+
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs30.existsSync((0, import_path13.join)(cwd, lock)));
|
|
51665
51731
|
};
|
|
51666
51732
|
if (runLegacyBootstrapCommands) {
|
|
51667
51733
|
summary.bootstrap = { stage: "legacy" };
|
|
@@ -51748,6 +51814,13 @@ async function runMeshRefineValidationGate(mesh, workspace, opts) {
|
|
|
51748
51814
|
summary.status = "passed";
|
|
51749
51815
|
return summary;
|
|
51750
51816
|
}
|
|
51817
|
+
|
|
51818
|
+
// src/mesh/mesh-coordinator-config.ts
|
|
51819
|
+
init_logger();
|
|
51820
|
+
var yaml4 = __toESM(require("js-yaml"));
|
|
51821
|
+
var import_os4 = require("os");
|
|
51822
|
+
var import_path14 = require("path");
|
|
51823
|
+
var fs31 = __toESM(require("fs"));
|
|
51751
51824
|
function loadYamlModule() {
|
|
51752
51825
|
return yaml4;
|
|
51753
51826
|
}
|
|
@@ -51766,14 +51839,14 @@ function serializeMeshCoordinatorMcpConfig(config, format) {
|
|
|
51766
51839
|
}
|
|
51767
51840
|
function resolveHermesUserHome() {
|
|
51768
51841
|
const explicitHome = process.env.HERMES_HOME?.trim();
|
|
51769
|
-
return explicitHome || (0,
|
|
51842
|
+
return explicitHome || (0, import_path14.join)((0, import_os4.homedir)(), ".hermes");
|
|
51770
51843
|
}
|
|
51771
51844
|
function loadHermesCoordinatorBaseConfig(targetConfigPath) {
|
|
51772
51845
|
const sourceHome = resolveHermesUserHome();
|
|
51773
|
-
const sourceConfigPath = (0,
|
|
51774
|
-
if (!
|
|
51775
|
-
if ((0,
|
|
51776
|
-
const parsed = parseMeshCoordinatorMcpConfig(
|
|
51846
|
+
const sourceConfigPath = (0, import_path14.join)(sourceHome, "config.yaml");
|
|
51847
|
+
if (!fs31.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
51848
|
+
if ((0, import_path14.resolve)(sourceConfigPath) === (0, import_path14.resolve)(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
51849
|
+
const parsed = parseMeshCoordinatorMcpConfig(fs31.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
|
|
51777
51850
|
const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
|
|
51778
51851
|
return { config: baseConfig, sourceHome, sourceConfigPath };
|
|
51779
51852
|
}
|
|
@@ -51806,18 +51879,20 @@ function stripHermesCoordinatorTempModelProviderOverrides(config) {
|
|
|
51806
51879
|
return sanitized;
|
|
51807
51880
|
}
|
|
51808
51881
|
function copyHermesCoordinatorCredentialFiles(sourceHome, targetHome) {
|
|
51809
|
-
if ((0,
|
|
51882
|
+
if ((0, import_path14.resolve)(sourceHome) === (0, import_path14.resolve)(targetHome)) return;
|
|
51810
51883
|
for (const fileName of [".env", "auth.json"]) {
|
|
51811
|
-
const sourcePath = (0,
|
|
51812
|
-
const targetPath = (0,
|
|
51813
|
-
if (!
|
|
51884
|
+
const sourcePath = (0, import_path14.join)(sourceHome, fileName);
|
|
51885
|
+
const targetPath = (0, import_path14.join)(targetHome, fileName);
|
|
51886
|
+
if (!fs31.existsSync(sourcePath)) continue;
|
|
51814
51887
|
try {
|
|
51815
|
-
|
|
51888
|
+
fs31.copyFileSync(sourcePath, targetPath);
|
|
51816
51889
|
} catch (error) {
|
|
51817
51890
|
LOG.warn("MeshCoordinator", `Could not copy Hermes ${fileName} into isolated coordinator home: ${error?.message || error}`);
|
|
51818
51891
|
}
|
|
51819
51892
|
}
|
|
51820
51893
|
}
|
|
51894
|
+
|
|
51895
|
+
// src/commands/router.ts
|
|
51821
51896
|
var CHAT_COMMANDS = [
|
|
51822
51897
|
"send_chat",
|
|
51823
51898
|
"new_chat",
|
|
@@ -52284,7 +52359,7 @@ var DaemonCommandRouter = class {
|
|
|
52284
52359
|
const nodeId = readInlineMeshNodeId(node);
|
|
52285
52360
|
if (!nodeId || !tombstones.has(nodeId)) return true;
|
|
52286
52361
|
const workspace = readStringValue(node?.workspace);
|
|
52287
|
-
if (workspace &&
|
|
52362
|
+
if (workspace && fs32.existsSync(workspace)) {
|
|
52288
52363
|
tombstones.delete(nodeId);
|
|
52289
52364
|
return true;
|
|
52290
52365
|
}
|
|
@@ -52319,14 +52394,14 @@ var DaemonCommandRouter = class {
|
|
|
52319
52394
|
* to give handles time to release, and reports whether residue remains.
|
|
52320
52395
|
*/
|
|
52321
52396
|
async bestEffortRemoveWorktreeDir(dir) {
|
|
52322
|
-
if (!dir || !
|
|
52397
|
+
if (!dir || !fs32.existsSync(dir)) return { removed: true, residue: false };
|
|
52323
52398
|
const sleep3 = (ms) => new Promise((resolve24) => setTimeout(resolve24, ms));
|
|
52324
52399
|
const ABSORB = /* @__PURE__ */ new Set(["EINVAL", "EPERM", "EBUSY", "ENOTEMPTY", "EACCES", "EMFILE", "ENFILE"]);
|
|
52325
52400
|
let lastErr;
|
|
52326
52401
|
for (let attempt = 0; attempt < 4; attempt++) {
|
|
52327
52402
|
try {
|
|
52328
|
-
|
|
52329
|
-
if (!
|
|
52403
|
+
fs32.rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
52404
|
+
if (!fs32.existsSync(dir)) return { removed: true, residue: false };
|
|
52330
52405
|
lastErr = new Error("directory still present after rmSync");
|
|
52331
52406
|
} catch (e) {
|
|
52332
52407
|
lastErr = e;
|
|
@@ -52337,7 +52412,7 @@ var DaemonCommandRouter = class {
|
|
|
52337
52412
|
}
|
|
52338
52413
|
await sleep3(150 * (attempt + 1));
|
|
52339
52414
|
}
|
|
52340
|
-
return
|
|
52415
|
+
return fs32.existsSync(dir) ? { removed: false, residue: true, error: String(lastErr?.message || lastErr || "unknown rm error") } : { removed: true, residue: false };
|
|
52341
52416
|
}
|
|
52342
52417
|
async cleanupLocalWorktreeNode(args) {
|
|
52343
52418
|
const workspace = typeof args.node?.workspace === "string" ? args.node.workspace.trim() : "";
|
|
@@ -52349,13 +52424,13 @@ var DaemonCommandRouter = class {
|
|
|
52349
52424
|
recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains."
|
|
52350
52425
|
};
|
|
52351
52426
|
}
|
|
52352
|
-
const worktreeExists =
|
|
52427
|
+
const worktreeExists = fs32.existsSync(workspace);
|
|
52353
52428
|
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
52354
52429
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
52355
52430
|
if (!worktreeExists) {
|
|
52356
52431
|
return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
|
|
52357
52432
|
}
|
|
52358
|
-
if (!repoRoot || !
|
|
52433
|
+
if (!repoRoot || !fs32.existsSync(repoRoot)) {
|
|
52359
52434
|
return {
|
|
52360
52435
|
success: false,
|
|
52361
52436
|
code: "mesh_worktree_cleanup_missing_source_repo",
|
|
@@ -52373,9 +52448,9 @@ var DaemonCommandRouter = class {
|
|
|
52373
52448
|
}
|
|
52374
52449
|
const { resolveWorktreePath: resolveWorktreePath2, listWorktrees: listWorktrees2, removeWorktree: removeWorktree2 } = await Promise.resolve().then(() => (init_git_worktree(), git_worktree_exports));
|
|
52375
52450
|
const normalizePath = (value) => {
|
|
52376
|
-
const resolved = (0,
|
|
52451
|
+
const resolved = (0, import_path15.resolve)(value);
|
|
52377
52452
|
try {
|
|
52378
|
-
return
|
|
52453
|
+
return fs32.realpathSync(resolved);
|
|
52379
52454
|
} catch {
|
|
52380
52455
|
return resolved;
|
|
52381
52456
|
}
|
|
@@ -52672,14 +52747,19 @@ var DaemonCommandRouter = class {
|
|
|
52672
52747
|
skippedCoordinatorSessionIds.push(sessionId);
|
|
52673
52748
|
continue;
|
|
52674
52749
|
}
|
|
52675
|
-
|
|
52750
|
+
const matchedByWorkspaceOnly = !recordNodeId;
|
|
52751
|
+
const isWorktreeNodeRemoval = cleanupSource === "mesh_remove_node" && args.node?.isLocalWorktree === true;
|
|
52752
|
+
const cleanWorkspaceOnlyForWorktree = isWorktreeNodeRemoval && matchedByWorkspaceOnly;
|
|
52753
|
+
if (!hasExplicitSessionIds && liveRuntime && !delegateBoundToThisNode && !cleanWorkspaceOnlyForWorktree) {
|
|
52676
52754
|
skippedSessionIds.push(sessionId);
|
|
52677
52755
|
skippedLiveSessionIds.push(sessionId);
|
|
52678
|
-
const matchedByWorkspaceOnly = !recordNodeId;
|
|
52679
52756
|
const reason = recordNodeId && recordNodeId !== args.nodeId ? `live_delegate_bound_to_other_node:${recordNodeId}` : matchedByWorkspaceOnly ? "live_session_matched_by_workspace_only_no_node_binding" : "live_session_not_bound_to_this_node";
|
|
52680
52757
|
skippedLiveSessionReasons.push({ sessionId, reason });
|
|
52681
52758
|
continue;
|
|
52682
52759
|
}
|
|
52760
|
+
if (cleanWorkspaceOnlyForWorktree && !delegateBoundToThisNode) {
|
|
52761
|
+
actedLiveDelegateSessionIds.push(sessionId);
|
|
52762
|
+
}
|
|
52683
52763
|
if (!hasExplicitSessionIds && liveRuntime && delegateBoundToThisNode && args.mode === "delete_stopped") {
|
|
52684
52764
|
skippedSessionIds.push(sessionId);
|
|
52685
52765
|
skippedLiveSessionIds.push(sessionId);
|
|
@@ -53169,7 +53249,7 @@ ${tail}` : ""
|
|
|
53169
53249
|
let didAutoRebase = false;
|
|
53170
53250
|
let isBehindBase = false;
|
|
53171
53251
|
try {
|
|
53172
|
-
(0,
|
|
53252
|
+
(0, import_node_child_process7.execFileSync)("git", ["merge-base", "--is-ancestor", branchHead, baseHead], {
|
|
53173
53253
|
cwd: node.workspace,
|
|
53174
53254
|
stdio: "ignore"
|
|
53175
53255
|
});
|
|
@@ -53179,7 +53259,7 @@ ${tail}` : ""
|
|
|
53179
53259
|
if (isBehindBase) {
|
|
53180
53260
|
const autoRebaseStarted = Date.now();
|
|
53181
53261
|
try {
|
|
53182
|
-
(0,
|
|
53262
|
+
(0, import_node_child_process7.execFileSync)("git", ["rebase", baseHead], {
|
|
53183
53263
|
cwd: node.workspace,
|
|
53184
53264
|
stdio: ["ignore", "pipe", "pipe"]
|
|
53185
53265
|
});
|
|
@@ -53220,7 +53300,7 @@ ${tail}` : ""
|
|
|
53220
53300
|
}
|
|
53221
53301
|
} catch (rebaseErr) {
|
|
53222
53302
|
try {
|
|
53223
|
-
(0,
|
|
53303
|
+
(0, import_node_child_process7.execFileSync)("git", ["rebase", "--abort"], { cwd: node.workspace, stdio: "ignore" });
|
|
53224
53304
|
} catch {
|
|
53225
53305
|
}
|
|
53226
53306
|
recordMeshRefineStage(refineStages, "patch_equivalence_after_auto_rebase", "failed", autoRebaseStarted, {
|
|
@@ -55983,7 +56063,7 @@ init_io_contracts();
|
|
|
55983
56063
|
init_chat_message_normalization();
|
|
55984
56064
|
|
|
55985
56065
|
// src/providers/version-archive.ts
|
|
55986
|
-
var
|
|
56066
|
+
var fs33 = __toESM(require("fs"));
|
|
55987
56067
|
var path38 = __toESM(require("path"));
|
|
55988
56068
|
var os28 = __toESM(require("os"));
|
|
55989
56069
|
var import_os5 = require("os");
|
|
@@ -55997,8 +56077,8 @@ var VersionArchive = class {
|
|
|
55997
56077
|
}
|
|
55998
56078
|
load() {
|
|
55999
56079
|
try {
|
|
56000
|
-
if (
|
|
56001
|
-
this.history = JSON.parse(
|
|
56080
|
+
if (fs33.existsSync(ARCHIVE_PATH)) {
|
|
56081
|
+
this.history = JSON.parse(fs33.readFileSync(ARCHIVE_PATH, "utf-8"));
|
|
56002
56082
|
}
|
|
56003
56083
|
} catch {
|
|
56004
56084
|
this.history = {};
|
|
@@ -56035,8 +56115,8 @@ var VersionArchive = class {
|
|
|
56035
56115
|
}
|
|
56036
56116
|
save() {
|
|
56037
56117
|
try {
|
|
56038
|
-
|
|
56039
|
-
|
|
56118
|
+
fs33.mkdirSync(path38.dirname(ARCHIVE_PATH), { recursive: true });
|
|
56119
|
+
fs33.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
56040
56120
|
} catch {
|
|
56041
56121
|
}
|
|
56042
56122
|
}
|
|
@@ -56061,8 +56141,8 @@ function findBinary2(name) {
|
|
|
56061
56141
|
for (const ext of exes) {
|
|
56062
56142
|
const fullPath = path38.join(p, name + ext);
|
|
56063
56143
|
try {
|
|
56064
|
-
if (
|
|
56065
|
-
const stat2 =
|
|
56144
|
+
if (fs33.existsSync(fullPath)) {
|
|
56145
|
+
const stat2 = fs33.statSync(fullPath);
|
|
56066
56146
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
56067
56147
|
return fullPath;
|
|
56068
56148
|
}
|
|
@@ -56109,9 +56189,9 @@ function checkPathExists2(paths) {
|
|
|
56109
56189
|
if (p.includes("*")) {
|
|
56110
56190
|
const home = os28.homedir();
|
|
56111
56191
|
const resolved = p.replace(/\*/g, home.split(path38.sep).pop() || "");
|
|
56112
|
-
if (
|
|
56192
|
+
if (fs33.existsSync(resolved)) return resolved;
|
|
56113
56193
|
} else {
|
|
56114
|
-
if (
|
|
56194
|
+
if (fs33.existsSync(p)) return p;
|
|
56115
56195
|
}
|
|
56116
56196
|
}
|
|
56117
56197
|
return null;
|
|
@@ -56119,7 +56199,7 @@ function checkPathExists2(paths) {
|
|
|
56119
56199
|
async function getMacAppVersion(appPath) {
|
|
56120
56200
|
if ((0, import_os5.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
56121
56201
|
const plistPath = path38.join(appPath, "Contents", "Info.plist");
|
|
56122
|
-
if (!
|
|
56202
|
+
if (!fs33.existsSync(plistPath)) return null;
|
|
56123
56203
|
const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
56124
56204
|
return raw || null;
|
|
56125
56205
|
}
|
|
@@ -56146,7 +56226,7 @@ async function detectAllVersions(loader, archive) {
|
|
|
56146
56226
|
let resolvedBin = cliBin;
|
|
56147
56227
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
56148
56228
|
const bundled = path38.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
56149
|
-
if (provider.cli &&
|
|
56229
|
+
if (provider.cli && fs33.existsSync(bundled)) resolvedBin = bundled;
|
|
56150
56230
|
}
|
|
56151
56231
|
info.installed = !!(appPath || resolvedBin);
|
|
56152
56232
|
info.path = appPath || null;
|
|
@@ -56194,7 +56274,7 @@ async function detectAllVersions(loader, archive) {
|
|
|
56194
56274
|
|
|
56195
56275
|
// src/daemon/dev-server.ts
|
|
56196
56276
|
var http2 = __toESM(require("http"));
|
|
56197
|
-
var
|
|
56277
|
+
var fs37 = __toESM(require("fs"));
|
|
56198
56278
|
var path42 = __toESM(require("path"));
|
|
56199
56279
|
init_config();
|
|
56200
56280
|
|
|
@@ -56546,7 +56626,7 @@ init_logger();
|
|
|
56546
56626
|
init_builders();
|
|
56547
56627
|
|
|
56548
56628
|
// src/daemon/dev-cdp-handlers.ts
|
|
56549
|
-
var
|
|
56629
|
+
var fs34 = __toESM(require("fs"));
|
|
56550
56630
|
var path39 = __toESM(require("path"));
|
|
56551
56631
|
init_logger();
|
|
56552
56632
|
async function handleCdpEvaluate(ctx, req, res) {
|
|
@@ -56727,17 +56807,17 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
56727
56807
|
}
|
|
56728
56808
|
let scriptsPath = "";
|
|
56729
56809
|
const directScripts = path39.join(dir, "scripts.js");
|
|
56730
|
-
if (
|
|
56810
|
+
if (fs34.existsSync(directScripts)) {
|
|
56731
56811
|
scriptsPath = directScripts;
|
|
56732
56812
|
} else {
|
|
56733
56813
|
const scriptsDir = path39.join(dir, "scripts");
|
|
56734
|
-
if (
|
|
56735
|
-
const versions =
|
|
56736
|
-
return
|
|
56814
|
+
if (fs34.existsSync(scriptsDir)) {
|
|
56815
|
+
const versions = fs34.readdirSync(scriptsDir).filter((d) => {
|
|
56816
|
+
return fs34.statSync(path39.join(scriptsDir, d)).isDirectory();
|
|
56737
56817
|
}).sort().reverse();
|
|
56738
56818
|
for (const ver of versions) {
|
|
56739
56819
|
const p = path39.join(scriptsDir, ver, "scripts.js");
|
|
56740
|
-
if (
|
|
56820
|
+
if (fs34.existsSync(p)) {
|
|
56741
56821
|
scriptsPath = p;
|
|
56742
56822
|
break;
|
|
56743
56823
|
}
|
|
@@ -56749,7 +56829,7 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
56749
56829
|
return;
|
|
56750
56830
|
}
|
|
56751
56831
|
try {
|
|
56752
|
-
const source =
|
|
56832
|
+
const source = fs34.readFileSync(scriptsPath, "utf-8");
|
|
56753
56833
|
const hints = {};
|
|
56754
56834
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
56755
56835
|
let match;
|
|
@@ -57564,7 +57644,7 @@ async function handleDomContext(ctx, type, req, res) {
|
|
|
57564
57644
|
}
|
|
57565
57645
|
|
|
57566
57646
|
// src/daemon/dev-cli-debug.ts
|
|
57567
|
-
var
|
|
57647
|
+
var fs35 = __toESM(require("fs"));
|
|
57568
57648
|
var path40 = __toESM(require("path"));
|
|
57569
57649
|
function slugifyFixtureName(value) {
|
|
57570
57650
|
const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -57580,10 +57660,10 @@ function getCliFixtureDir(ctx, type) {
|
|
|
57580
57660
|
function readCliFixture(ctx, type, name) {
|
|
57581
57661
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
57582
57662
|
const filePath = path40.join(fixtureDir, `${name}.json`);
|
|
57583
|
-
if (!
|
|
57663
|
+
if (!fs35.existsSync(filePath)) {
|
|
57584
57664
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
57585
57665
|
}
|
|
57586
|
-
return JSON.parse(
|
|
57666
|
+
return JSON.parse(fs35.readFileSync(filePath, "utf-8"));
|
|
57587
57667
|
}
|
|
57588
57668
|
function getExerciseTranscriptText(result) {
|
|
57589
57669
|
const parts = [];
|
|
@@ -58328,7 +58408,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
58328
58408
|
return;
|
|
58329
58409
|
}
|
|
58330
58410
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
58331
|
-
|
|
58411
|
+
fs35.mkdirSync(fixtureDir, { recursive: true });
|
|
58332
58412
|
const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
|
|
58333
58413
|
const result = await runCliExerciseInternal(ctx, { ...request, type });
|
|
58334
58414
|
const fixture = {
|
|
@@ -58356,7 +58436,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
58356
58436
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
58357
58437
|
};
|
|
58358
58438
|
const filePath = path40.join(fixtureDir, `${name}.json`);
|
|
58359
|
-
|
|
58439
|
+
fs35.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
58360
58440
|
ctx.json(res, 200, {
|
|
58361
58441
|
saved: true,
|
|
58362
58442
|
name,
|
|
@@ -58374,14 +58454,14 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
58374
58454
|
async function handleCliFixtureList(ctx, type, _req, res) {
|
|
58375
58455
|
try {
|
|
58376
58456
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
58377
|
-
if (!
|
|
58457
|
+
if (!fs35.existsSync(fixtureDir)) {
|
|
58378
58458
|
ctx.json(res, 200, { fixtures: [], count: 0 });
|
|
58379
58459
|
return;
|
|
58380
58460
|
}
|
|
58381
|
-
const fixtures =
|
|
58461
|
+
const fixtures = fs35.readdirSync(fixtureDir).filter((file) => file.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file) => {
|
|
58382
58462
|
const fullPath = path40.join(fixtureDir, file);
|
|
58383
58463
|
try {
|
|
58384
|
-
const raw = JSON.parse(
|
|
58464
|
+
const raw = JSON.parse(fs35.readFileSync(fullPath, "utf-8"));
|
|
58385
58465
|
return {
|
|
58386
58466
|
name: raw.name || file.replace(/\.json$/i, ""),
|
|
58387
58467
|
path: fullPath,
|
|
@@ -58514,7 +58594,7 @@ async function handleCliRaw(ctx, req, res) {
|
|
|
58514
58594
|
}
|
|
58515
58595
|
|
|
58516
58596
|
// src/daemon/dev-auto-implement.ts
|
|
58517
|
-
var
|
|
58597
|
+
var fs36 = __toESM(require("fs"));
|
|
58518
58598
|
var path41 = __toESM(require("path"));
|
|
58519
58599
|
var os29 = __toESM(require("os"));
|
|
58520
58600
|
var import_session_host_core8 = require("@adhdev/session-host-core");
|
|
@@ -58563,10 +58643,10 @@ function resolveAutoImplReference(ctx, category, requestedReference, targetType)
|
|
|
58563
58643
|
return fallback?.type || null;
|
|
58564
58644
|
}
|
|
58565
58645
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
58566
|
-
if (!
|
|
58567
|
-
const versions =
|
|
58646
|
+
if (!fs36.existsSync(scriptsDir)) return null;
|
|
58647
|
+
const versions = fs36.readdirSync(scriptsDir).filter((d) => {
|
|
58568
58648
|
try {
|
|
58569
|
-
return
|
|
58649
|
+
return fs36.statSync(path41.join(scriptsDir, d)).isDirectory();
|
|
58570
58650
|
} catch {
|
|
58571
58651
|
return false;
|
|
58572
58652
|
}
|
|
@@ -58588,13 +58668,13 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
58588
58668
|
if (!sourceDir) {
|
|
58589
58669
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
58590
58670
|
}
|
|
58591
|
-
if (!
|
|
58592
|
-
|
|
58593
|
-
|
|
58671
|
+
if (!fs36.existsSync(desiredDir)) {
|
|
58672
|
+
fs36.mkdirSync(path41.dirname(desiredDir), { recursive: true });
|
|
58673
|
+
fs36.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
58594
58674
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
58595
58675
|
}
|
|
58596
58676
|
const providerJson = path41.join(desiredDir, "provider.json");
|
|
58597
|
-
if (!
|
|
58677
|
+
if (!fs36.existsSync(providerJson)) {
|
|
58598
58678
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
58599
58679
|
}
|
|
58600
58680
|
return { dir: desiredDir };
|
|
@@ -58602,15 +58682,15 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
58602
58682
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
58603
58683
|
if (!referenceType) return {};
|
|
58604
58684
|
const refDir = ctx.findProviderDir(referenceType);
|
|
58605
|
-
if (!refDir || !
|
|
58685
|
+
if (!refDir || !fs36.existsSync(refDir)) return {};
|
|
58606
58686
|
const referenceScripts = {};
|
|
58607
58687
|
const scriptsDir = path41.join(refDir, "scripts");
|
|
58608
58688
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
58609
58689
|
if (!latestDir) return referenceScripts;
|
|
58610
|
-
for (const file of
|
|
58690
|
+
for (const file of fs36.readdirSync(latestDir)) {
|
|
58611
58691
|
if (!file.endsWith(".js")) continue;
|
|
58612
58692
|
try {
|
|
58613
|
-
referenceScripts[file] =
|
|
58693
|
+
referenceScripts[file] = fs36.readFileSync(path41.join(latestDir, file), "utf-8");
|
|
58614
58694
|
} catch {
|
|
58615
58695
|
}
|
|
58616
58696
|
}
|
|
@@ -58719,15 +58799,15 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
58719
58799
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
58720
58800
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
58721
58801
|
const tmpDir = path41.join(os29.tmpdir(), "adhdev-autoimpl");
|
|
58722
|
-
if (!
|
|
58802
|
+
if (!fs36.existsSync(tmpDir)) fs36.mkdirSync(tmpDir, { recursive: true });
|
|
58723
58803
|
const promptFile = path41.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
58724
|
-
|
|
58804
|
+
fs36.writeFileSync(promptFile, prompt, "utf-8");
|
|
58725
58805
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
58726
58806
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
58727
58807
|
const spawn4 = agentProvider?.spawn;
|
|
58728
58808
|
if (!spawn4?.command) {
|
|
58729
58809
|
try {
|
|
58730
|
-
|
|
58810
|
+
fs36.unlinkSync(promptFile);
|
|
58731
58811
|
} catch {
|
|
58732
58812
|
}
|
|
58733
58813
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -58829,7 +58909,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
58829
58909
|
} catch {
|
|
58830
58910
|
}
|
|
58831
58911
|
try {
|
|
58832
|
-
|
|
58912
|
+
fs36.unlinkSync(promptFile);
|
|
58833
58913
|
} catch {
|
|
58834
58914
|
}
|
|
58835
58915
|
ctx.log(`Auto-implement (ACP) ${success ? "completed" : "failed"}: ${type} (exit: ${code})`);
|
|
@@ -59055,7 +59135,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
59055
59135
|
}
|
|
59056
59136
|
});
|
|
59057
59137
|
try {
|
|
59058
|
-
|
|
59138
|
+
fs36.unlinkSync(promptFile);
|
|
59059
59139
|
} catch {
|
|
59060
59140
|
}
|
|
59061
59141
|
ctx.log(`Auto-implement ${success ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
|
|
@@ -59160,10 +59240,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
59160
59240
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
59161
59241
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
59162
59242
|
lines.push("");
|
|
59163
|
-
for (const file of
|
|
59243
|
+
for (const file of fs36.readdirSync(latestScriptsDir)) {
|
|
59164
59244
|
if (file.endsWith(".js") && targetFileNames.has(file)) {
|
|
59165
59245
|
try {
|
|
59166
|
-
const content =
|
|
59246
|
+
const content = fs36.readFileSync(path41.join(latestScriptsDir, file), "utf-8");
|
|
59167
59247
|
lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
|
|
59168
59248
|
lines.push("```javascript");
|
|
59169
59249
|
lines.push(content);
|
|
@@ -59173,14 +59253,14 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
59173
59253
|
}
|
|
59174
59254
|
}
|
|
59175
59255
|
}
|
|
59176
|
-
const refFiles =
|
|
59256
|
+
const refFiles = fs36.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
59177
59257
|
if (refFiles.length > 0) {
|
|
59178
59258
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
59179
59259
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
59180
59260
|
lines.push("");
|
|
59181
59261
|
for (const file of refFiles) {
|
|
59182
59262
|
try {
|
|
59183
|
-
const content =
|
|
59263
|
+
const content = fs36.readFileSync(path41.join(latestScriptsDir, file), "utf-8");
|
|
59184
59264
|
lines.push(`### \`${file}\` \u{1F512}`);
|
|
59185
59265
|
lines.push("```javascript");
|
|
59186
59266
|
lines.push(content);
|
|
@@ -59225,7 +59305,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
59225
59305
|
const loadGuide = (name) => {
|
|
59226
59306
|
try {
|
|
59227
59307
|
const p = path41.join(docsDir, name);
|
|
59228
|
-
if (
|
|
59308
|
+
if (fs36.existsSync(p)) return fs36.readFileSync(p, "utf-8");
|
|
59229
59309
|
} catch {
|
|
59230
59310
|
}
|
|
59231
59311
|
return null;
|
|
@@ -59469,11 +59549,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
59469
59549
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
59470
59550
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
59471
59551
|
lines.push("");
|
|
59472
|
-
for (const file of
|
|
59552
|
+
for (const file of fs36.readdirSync(latestScriptsDir)) {
|
|
59473
59553
|
if (!file.endsWith(".js")) continue;
|
|
59474
59554
|
if (!targetFileNames.has(file)) continue;
|
|
59475
59555
|
try {
|
|
59476
|
-
const content =
|
|
59556
|
+
const content = fs36.readFileSync(path41.join(latestScriptsDir, file), "utf-8");
|
|
59477
59557
|
lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
|
|
59478
59558
|
lines.push("```javascript");
|
|
59479
59559
|
lines.push(content);
|
|
@@ -59482,14 +59562,14 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
59482
59562
|
} catch {
|
|
59483
59563
|
}
|
|
59484
59564
|
}
|
|
59485
|
-
const refFiles =
|
|
59565
|
+
const refFiles = fs36.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
59486
59566
|
if (refFiles.length > 0) {
|
|
59487
59567
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
59488
59568
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
59489
59569
|
lines.push("");
|
|
59490
59570
|
for (const file of refFiles) {
|
|
59491
59571
|
try {
|
|
59492
|
-
const content =
|
|
59572
|
+
const content = fs36.readFileSync(path41.join(latestScriptsDir, file), "utf-8");
|
|
59493
59573
|
lines.push(`### \`${file}\` \u{1F512}`);
|
|
59494
59574
|
lines.push("```javascript");
|
|
59495
59575
|
lines.push(content);
|
|
@@ -59526,7 +59606,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
59526
59606
|
const loadGuide = (name) => {
|
|
59527
59607
|
try {
|
|
59528
59608
|
const p = path41.join(docsDir, name);
|
|
59529
|
-
if (
|
|
59609
|
+
if (fs36.existsSync(p)) return fs36.readFileSync(p, "utf-8");
|
|
59530
59610
|
} catch {
|
|
59531
59611
|
}
|
|
59532
59612
|
return null;
|
|
@@ -60266,7 +60346,7 @@ var DevServer = class _DevServer {
|
|
|
60266
60346
|
path42.join(process.cwd(), "packages/web-devconsole/dist")
|
|
60267
60347
|
];
|
|
60268
60348
|
for (const dir of candidates) {
|
|
60269
|
-
if (
|
|
60349
|
+
if (fs37.existsSync(path42.join(dir, "index.html"))) return dir;
|
|
60270
60350
|
}
|
|
60271
60351
|
return null;
|
|
60272
60352
|
}
|
|
@@ -60278,7 +60358,7 @@ var DevServer = class _DevServer {
|
|
|
60278
60358
|
}
|
|
60279
60359
|
const htmlPath = path42.join(distDir, "index.html");
|
|
60280
60360
|
try {
|
|
60281
|
-
const html =
|
|
60361
|
+
const html = fs37.readFileSync(htmlPath, "utf-8");
|
|
60282
60362
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
60283
60363
|
res.end(html);
|
|
60284
60364
|
} catch (e) {
|
|
@@ -60308,7 +60388,7 @@ var DevServer = class _DevServer {
|
|
|
60308
60388
|
return;
|
|
60309
60389
|
}
|
|
60310
60390
|
try {
|
|
60311
|
-
const content =
|
|
60391
|
+
const content = fs37.readFileSync(filePath);
|
|
60312
60392
|
const ext = path42.extname(filePath);
|
|
60313
60393
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
60314
60394
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
@@ -60417,14 +60497,14 @@ var DevServer = class _DevServer {
|
|
|
60417
60497
|
const files = [];
|
|
60418
60498
|
const scan = (d, prefix) => {
|
|
60419
60499
|
try {
|
|
60420
|
-
for (const entry of
|
|
60500
|
+
for (const entry of fs37.readdirSync(d, { withFileTypes: true })) {
|
|
60421
60501
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
60422
60502
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
60423
60503
|
if (entry.isDirectory()) {
|
|
60424
60504
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
60425
60505
|
scan(path42.join(d, entry.name), rel);
|
|
60426
60506
|
} else {
|
|
60427
|
-
const stat2 =
|
|
60507
|
+
const stat2 = fs37.statSync(path42.join(d, entry.name));
|
|
60428
60508
|
files.push({ path: rel, size: stat2.size, type: "file" });
|
|
60429
60509
|
}
|
|
60430
60510
|
}
|
|
@@ -60452,11 +60532,11 @@ var DevServer = class _DevServer {
|
|
|
60452
60532
|
this.json(res, 403, { error: "Forbidden" });
|
|
60453
60533
|
return;
|
|
60454
60534
|
}
|
|
60455
|
-
if (!
|
|
60535
|
+
if (!fs37.existsSync(fullPath) || fs37.statSync(fullPath).isDirectory()) {
|
|
60456
60536
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
60457
60537
|
return;
|
|
60458
60538
|
}
|
|
60459
|
-
const content =
|
|
60539
|
+
const content = fs37.readFileSync(fullPath, "utf-8");
|
|
60460
60540
|
this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
|
|
60461
60541
|
}
|
|
60462
60542
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -60478,9 +60558,9 @@ var DevServer = class _DevServer {
|
|
|
60478
60558
|
return;
|
|
60479
60559
|
}
|
|
60480
60560
|
try {
|
|
60481
|
-
if (
|
|
60482
|
-
|
|
60483
|
-
|
|
60561
|
+
if (fs37.existsSync(fullPath)) fs37.copyFileSync(fullPath, fullPath + ".bak");
|
|
60562
|
+
fs37.mkdirSync(path42.dirname(fullPath), { recursive: true });
|
|
60563
|
+
fs37.writeFileSync(fullPath, content, "utf-8");
|
|
60484
60564
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
60485
60565
|
this.providerLoader.reload();
|
|
60486
60566
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -60497,8 +60577,8 @@ var DevServer = class _DevServer {
|
|
|
60497
60577
|
}
|
|
60498
60578
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
60499
60579
|
const p = path42.join(dir, name);
|
|
60500
|
-
if (
|
|
60501
|
-
const source =
|
|
60580
|
+
if (fs37.existsSync(p)) {
|
|
60581
|
+
const source = fs37.readFileSync(p, "utf-8");
|
|
60502
60582
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
60503
60583
|
return;
|
|
60504
60584
|
}
|
|
@@ -60517,11 +60597,11 @@ var DevServer = class _DevServer {
|
|
|
60517
60597
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
60518
60598
|
return;
|
|
60519
60599
|
}
|
|
60520
|
-
const target =
|
|
60600
|
+
const target = fs37.existsSync(path42.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
60521
60601
|
const targetPath = path42.join(dir, target);
|
|
60522
60602
|
try {
|
|
60523
|
-
if (
|
|
60524
|
-
|
|
60603
|
+
if (fs37.existsSync(targetPath)) fs37.copyFileSync(targetPath, targetPath + ".bak");
|
|
60604
|
+
fs37.writeFileSync(targetPath, source, "utf-8");
|
|
60525
60605
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
60526
60606
|
this.providerLoader.reload();
|
|
60527
60607
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -60666,20 +60746,20 @@ var DevServer = class _DevServer {
|
|
|
60666
60746
|
let targetDir;
|
|
60667
60747
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
60668
60748
|
const jsonPath = path42.join(targetDir, "provider.json");
|
|
60669
|
-
if (
|
|
60749
|
+
if (fs37.existsSync(jsonPath)) {
|
|
60670
60750
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
60671
60751
|
return;
|
|
60672
60752
|
}
|
|
60673
60753
|
try {
|
|
60674
60754
|
const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version, osPaths, processNames });
|
|
60675
|
-
|
|
60676
|
-
|
|
60755
|
+
fs37.mkdirSync(targetDir, { recursive: true });
|
|
60756
|
+
fs37.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
60677
60757
|
const createdFiles = ["provider.json"];
|
|
60678
60758
|
if (result.files) {
|
|
60679
60759
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
60680
60760
|
const fullPath = path42.join(targetDir, relPath);
|
|
60681
|
-
|
|
60682
|
-
|
|
60761
|
+
fs37.mkdirSync(path42.dirname(fullPath), { recursive: true });
|
|
60762
|
+
fs37.writeFileSync(fullPath, content, "utf-8");
|
|
60683
60763
|
createdFiles.push(relPath);
|
|
60684
60764
|
}
|
|
60685
60765
|
}
|
|
@@ -60728,10 +60808,10 @@ var DevServer = class _DevServer {
|
|
|
60728
60808
|
}
|
|
60729
60809
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
60730
60810
|
getLatestScriptVersionDir(scriptsDir) {
|
|
60731
|
-
if (!
|
|
60732
|
-
const versions =
|
|
60811
|
+
if (!fs37.existsSync(scriptsDir)) return null;
|
|
60812
|
+
const versions = fs37.readdirSync(scriptsDir).filter((d) => {
|
|
60733
60813
|
try {
|
|
60734
|
-
return
|
|
60814
|
+
return fs37.statSync(path42.join(scriptsDir, d)).isDirectory();
|
|
60735
60815
|
} catch {
|
|
60736
60816
|
return false;
|
|
60737
60817
|
}
|
|
@@ -60753,13 +60833,13 @@ var DevServer = class _DevServer {
|
|
|
60753
60833
|
if (!sourceDir) {
|
|
60754
60834
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
60755
60835
|
}
|
|
60756
|
-
if (!
|
|
60757
|
-
|
|
60758
|
-
|
|
60836
|
+
if (!fs37.existsSync(desiredDir)) {
|
|
60837
|
+
fs37.mkdirSync(path42.dirname(desiredDir), { recursive: true });
|
|
60838
|
+
fs37.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
60759
60839
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
60760
60840
|
}
|
|
60761
60841
|
const providerJson = path42.join(desiredDir, "provider.json");
|
|
60762
|
-
if (!
|
|
60842
|
+
if (!fs37.existsSync(providerJson)) {
|
|
60763
60843
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
60764
60844
|
}
|
|
60765
60845
|
return { dir: desiredDir };
|
|
@@ -61736,8 +61816,8 @@ async function installExtension(ide, extension) {
|
|
|
61736
61816
|
const res = await fetch(extension.vsixUrl);
|
|
61737
61817
|
if (res.ok) {
|
|
61738
61818
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
61739
|
-
const
|
|
61740
|
-
|
|
61819
|
+
const fs38 = await import("fs");
|
|
61820
|
+
fs38.writeFileSync(vsixPath, buffer);
|
|
61741
61821
|
return new Promise((resolve24) => {
|
|
61742
61822
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
61743
61823
|
(0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error, _stdout, stderr) => {
|