@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.mjs
CHANGED
|
@@ -311,10 +311,10 @@ function readInjected(value) {
|
|
|
311
311
|
}
|
|
312
312
|
function getDaemonBuildInfo() {
|
|
313
313
|
if (cached) return cached;
|
|
314
|
-
const commit = readInjected(true ? "
|
|
315
|
-
const commitShort = readInjected(true ? "
|
|
316
|
-
const version = readInjected(true ? "0.9.82-rc.
|
|
317
|
-
const builtAt = readInjected(true ? "2026-06-
|
|
314
|
+
const commit = readInjected(true ? "7b74c2c74e315b3fa6eb9f18d694b79eeb561184" : void 0) ?? "unknown";
|
|
315
|
+
const commitShort = readInjected(true ? "7b74c2c7" : void 0) ?? (commit !== "unknown" ? commit.slice(0, 7) : "unknown");
|
|
316
|
+
const version = readInjected(true ? "0.9.82-rc.379" : void 0) ?? readInjected(typeof process !== "undefined" ? process.env?.ADHDEV_PKG_VERSION : void 0) ?? "unknown";
|
|
317
|
+
const builtAt = readInjected(true ? "2026-06-25T09:33:17.234Z" : void 0);
|
|
318
318
|
cached = builtAt ? { commit, commitShort, version, builtAt } : { commit, commitShort, version };
|
|
319
319
|
return cached;
|
|
320
320
|
}
|
|
@@ -7268,8 +7268,8 @@ function stripCoordinatorWrapperFile(filePath) {
|
|
|
7268
7268
|
const remaining = (existing.slice(0, openIdx) + existing.slice(closeIdx + CLOSE.length)).replace(/^\s*\n+/, "").replace(/\n+\s*$/, "");
|
|
7269
7269
|
if (!remaining.trim()) {
|
|
7270
7270
|
try {
|
|
7271
|
-
const
|
|
7272
|
-
|
|
7271
|
+
const fs38 = __require("fs");
|
|
7272
|
+
fs38.unlinkSync(filePath);
|
|
7273
7273
|
} catch {
|
|
7274
7274
|
}
|
|
7275
7275
|
} else {
|
|
@@ -9798,9 +9798,9 @@ function findBinary(name) {
|
|
|
9798
9798
|
for (const ext of exes) {
|
|
9799
9799
|
const fullPath = path11.join(p, trimmed + ext);
|
|
9800
9800
|
try {
|
|
9801
|
-
const
|
|
9802
|
-
if (
|
|
9803
|
-
const stat2 =
|
|
9801
|
+
const fs38 = __require("fs");
|
|
9802
|
+
if (fs38.existsSync(fullPath)) {
|
|
9803
|
+
const stat2 = fs38.statSync(fullPath);
|
|
9804
9804
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
9805
9805
|
return fullPath;
|
|
9806
9806
|
}
|
|
@@ -9814,12 +9814,12 @@ function findBinary(name) {
|
|
|
9814
9814
|
function isScriptBinary(binaryPath) {
|
|
9815
9815
|
if (!path11.isAbsolute(binaryPath)) return false;
|
|
9816
9816
|
try {
|
|
9817
|
-
const
|
|
9818
|
-
const resolved =
|
|
9817
|
+
const fs38 = __require("fs");
|
|
9818
|
+
const resolved = fs38.realpathSync(binaryPath);
|
|
9819
9819
|
const head = Buffer.alloc(8);
|
|
9820
|
-
const fd =
|
|
9821
|
-
|
|
9822
|
-
|
|
9820
|
+
const fd = fs38.openSync(resolved, "r");
|
|
9821
|
+
fs38.readSync(fd, head, 0, 8, 0);
|
|
9822
|
+
fs38.closeSync(fd);
|
|
9823
9823
|
let i = 0;
|
|
9824
9824
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
9825
9825
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -9830,12 +9830,12 @@ function isScriptBinary(binaryPath) {
|
|
|
9830
9830
|
function looksLikeMachOOrElf(filePath) {
|
|
9831
9831
|
if (!path11.isAbsolute(filePath)) return false;
|
|
9832
9832
|
try {
|
|
9833
|
-
const
|
|
9834
|
-
const resolved =
|
|
9833
|
+
const fs38 = __require("fs");
|
|
9834
|
+
const resolved = fs38.realpathSync(filePath);
|
|
9835
9835
|
const buf = Buffer.alloc(8);
|
|
9836
|
-
const fd =
|
|
9837
|
-
|
|
9838
|
-
|
|
9836
|
+
const fd = fs38.openSync(resolved, "r");
|
|
9837
|
+
fs38.readSync(fd, buf, 0, 8, 0);
|
|
9838
|
+
fs38.closeSync(fd);
|
|
9839
9839
|
let i = 0;
|
|
9840
9840
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
9841
9841
|
const b = buf.subarray(i);
|
|
@@ -10367,6 +10367,16 @@ function warnDispatchWarmupGetterMissingOnce(daemonId) {
|
|
|
10367
10367
|
dispatchWarmupGetterMissingWarned.add(daemonId);
|
|
10368
10368
|
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.`);
|
|
10369
10369
|
}
|
|
10370
|
+
async function waitForLocalSessionReady(components, sessionId) {
|
|
10371
|
+
const adapter = components.cliManager?.adapters?.get(sessionId);
|
|
10372
|
+
if (!adapter || typeof adapter.isReady !== "function") return;
|
|
10373
|
+
const deadline = Date.now() + LOCAL_LAUNCH_READY_TIMEOUT_MS;
|
|
10374
|
+
while (Date.now() < deadline) {
|
|
10375
|
+
if (adapter.isReady() || adapter.currentStatus === "idle") return;
|
|
10376
|
+
await new Promise((resolve24) => setTimeout(resolve24, LOCAL_LAUNCH_READY_POLL_MS));
|
|
10377
|
+
}
|
|
10378
|
+
LOG.warn("MeshQueue", `Auto-launched session ${sessionId} not interactive after ${LOCAL_LAUNCH_READY_TIMEOUT_MS}ms; dispatching anyway (adapter queue-until-ready will buffer)`);
|
|
10379
|
+
}
|
|
10370
10380
|
function deliverTaskToSession(dispatchThunk, ctx, warmup) {
|
|
10371
10381
|
const delivery = createSessionDelivery({
|
|
10372
10382
|
meshId: ctx.meshId,
|
|
@@ -10963,6 +10973,7 @@ async function maybeAutoLaunchOneQueueSession(components, meshId, mesh) {
|
|
|
10963
10973
|
return false;
|
|
10964
10974
|
}
|
|
10965
10975
|
markAutoLaunch(meshId, task.id, { status: "completed", nodeId, providerType: resolved.providerType, sessionId });
|
|
10976
|
+
await waitForLocalSessionReady(components, sessionId);
|
|
10966
10977
|
tryAssignQueueTask(components, meshId, nodeId, sessionId, resolved.providerType);
|
|
10967
10978
|
return true;
|
|
10968
10979
|
} catch (e) {
|
|
@@ -11184,7 +11195,7 @@ function runIdleMaintenanceThenAssignQueue(components, args) {
|
|
|
11184
11195
|
});
|
|
11185
11196
|
});
|
|
11186
11197
|
}
|
|
11187
|
-
var 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;
|
|
11198
|
+
var 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;
|
|
11188
11199
|
var init_mesh_queue_assignment = __esm({
|
|
11189
11200
|
"src/mesh/mesh-queue-assignment.ts"() {
|
|
11190
11201
|
"use strict";
|
|
@@ -11209,6 +11220,8 @@ var init_mesh_queue_assignment = __esm({
|
|
|
11209
11220
|
DISPATCH_CONFIRM_TIMEOUT_MS = 12e4;
|
|
11210
11221
|
DISPATCH_CONNECT_TIMEOUT_MS = MESH_CONNECT_TIMEOUT_MS;
|
|
11211
11222
|
dispatchWarmupGetterMissingWarned = /* @__PURE__ */ new Set();
|
|
11223
|
+
LOCAL_LAUNCH_READY_TIMEOUT_MS = 15e3;
|
|
11224
|
+
LOCAL_LAUNCH_READY_POLL_MS = 100;
|
|
11212
11225
|
autoLaunchInProgress = /* @__PURE__ */ new Set();
|
|
11213
11226
|
autoLaunchCooldownUntil = /* @__PURE__ */ new Map();
|
|
11214
11227
|
AUTO_LAUNCH_COOLDOWN_MS = 5e3;
|
|
@@ -16971,8 +16984,8 @@ var init_pty_transport = __esm({
|
|
|
16971
16984
|
let cwd = options.cwd;
|
|
16972
16985
|
if (cwd) {
|
|
16973
16986
|
try {
|
|
16974
|
-
const
|
|
16975
|
-
const stat2 =
|
|
16987
|
+
const fs38 = __require("fs");
|
|
16988
|
+
const stat2 = fs38.statSync(cwd);
|
|
16976
16989
|
if (!stat2.isDirectory()) cwd = os14.homedir();
|
|
16977
16990
|
} catch {
|
|
16978
16991
|
cwd = os14.homedir();
|
|
@@ -16991,6 +17004,34 @@ var init_pty_transport = __esm({
|
|
|
16991
17004
|
}
|
|
16992
17005
|
});
|
|
16993
17006
|
|
|
17007
|
+
// src/cli-adapters/pty-write-chunking.ts
|
|
17008
|
+
function chunkPreservingSurrogates(text, size) {
|
|
17009
|
+
const chunks = [];
|
|
17010
|
+
let offset = 0;
|
|
17011
|
+
while (offset < text.length) {
|
|
17012
|
+
let end = Math.min(text.length, offset + size);
|
|
17013
|
+
if (end < text.length) {
|
|
17014
|
+
const code = text.charCodeAt(end - 1);
|
|
17015
|
+
if (code >= 55296 && code <= 56319) end -= 1;
|
|
17016
|
+
}
|
|
17017
|
+
if (end <= offset) end = Math.min(text.length, offset + size);
|
|
17018
|
+
chunks.push(text.slice(offset, end));
|
|
17019
|
+
offset = end;
|
|
17020
|
+
}
|
|
17021
|
+
return chunks;
|
|
17022
|
+
}
|
|
17023
|
+
function shouldChunkWin32Write(length) {
|
|
17024
|
+
return length > WIN32_PTY_WRITE_CHUNK_CHARS;
|
|
17025
|
+
}
|
|
17026
|
+
var WIN32_PTY_WRITE_CHUNK_CHARS, WIN32_PTY_WRITE_CHUNK_GAP_MS;
|
|
17027
|
+
var init_pty_write_chunking = __esm({
|
|
17028
|
+
"src/cli-adapters/pty-write-chunking.ts"() {
|
|
17029
|
+
"use strict";
|
|
17030
|
+
WIN32_PTY_WRITE_CHUNK_CHARS = 1024;
|
|
17031
|
+
WIN32_PTY_WRITE_CHUNK_GAP_MS = 8;
|
|
17032
|
+
}
|
|
17033
|
+
});
|
|
17034
|
+
|
|
16994
17035
|
// src/providers/sdk/v1/builders/cli/visible-region.ts
|
|
16995
17036
|
function compile(re, flags) {
|
|
16996
17037
|
try {
|
|
@@ -18941,6 +18982,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
18941
18982
|
init_debug_config();
|
|
18942
18983
|
init_terminal_screen();
|
|
18943
18984
|
init_pty_transport();
|
|
18985
|
+
init_pty_write_chunking();
|
|
18944
18986
|
init_provider_cli_shared();
|
|
18945
18987
|
init_cli_script_runner();
|
|
18946
18988
|
init_cli_state_engine();
|
|
@@ -19419,6 +19461,7 @@ ${lastSnapshot}`;
|
|
|
19419
19461
|
`[${this.cliType}] Startup settled (${trigger}, stableMs=${stableMs}, modal=${!!startupModal}) providerDir=${this.providerResolutionMeta.providerDir || "-"} scriptDir=${this.providerResolutionMeta.scriptDir || "-"} scriptsPath=${this.providerResolutionMeta.scriptsPath || "-"}`
|
|
19420
19462
|
);
|
|
19421
19463
|
this.onStatusChange?.();
|
|
19464
|
+
if (!startupModal) this.schedulePendingOutboundFlush();
|
|
19422
19465
|
}
|
|
19423
19466
|
scheduleStartupSettleCheck() {
|
|
19424
19467
|
if (!this.startupParseGate) return;
|
|
@@ -19739,8 +19782,26 @@ ${lastSnapshot}`;
|
|
|
19739
19782
|
}
|
|
19740
19783
|
async writeToPty(data) {
|
|
19741
19784
|
if (!this.ptyProcess) throw new Error(`${this.cliName} is not running`);
|
|
19785
|
+
if (process.platform === "win32" && shouldChunkWin32Write(data.length)) {
|
|
19786
|
+
await this.writeWin32Chunked(data);
|
|
19787
|
+
return;
|
|
19788
|
+
}
|
|
19742
19789
|
await this.ptyProcess.write(data);
|
|
19743
19790
|
}
|
|
19791
|
+
/** Write `data` to the PTY in bounded, surrogate-safe chunks with a short
|
|
19792
|
+
* inter-chunk gap (win32 paced write). Awaits each chunk's write and the gap
|
|
19793
|
+
* so the returned promise resolves only after the FINAL chunk (carrying any
|
|
19794
|
+
* trailing submit key) has been written. */
|
|
19795
|
+
async writeWin32Chunked(data) {
|
|
19796
|
+
const chunks = chunkPreservingSurrogates(data, WIN32_PTY_WRITE_CHUNK_CHARS);
|
|
19797
|
+
for (let i = 0; i < chunks.length; i += 1) {
|
|
19798
|
+
if (!this.ptyProcess) throw new Error(`${this.cliName} is not running`);
|
|
19799
|
+
await this.ptyProcess.write(chunks[i]);
|
|
19800
|
+
if (i + 1 < chunks.length) {
|
|
19801
|
+
await new Promise((resolve24) => setTimeout(resolve24, WIN32_PTY_WRITE_CHUNK_GAP_MS));
|
|
19802
|
+
}
|
|
19803
|
+
}
|
|
19804
|
+
}
|
|
19744
19805
|
resetPendingSendState(reason) {
|
|
19745
19806
|
this.responseBuffer = "";
|
|
19746
19807
|
if (this.responseTimeout) {
|
|
@@ -19988,7 +20049,13 @@ ${lastSnapshot}`;
|
|
|
19988
20049
|
LOG.info("CLI", `[${this.cliType}] sendMessage recovered idle prompt readiness`);
|
|
19989
20050
|
}
|
|
19990
20051
|
}
|
|
19991
|
-
if (!this.ready)
|
|
20052
|
+
if (!this.ready) {
|
|
20053
|
+
if (allowQueue) {
|
|
20054
|
+
this.enqueuePendingOutboundMessage(text, "not_ready_pending_prompt");
|
|
20055
|
+
return;
|
|
20056
|
+
}
|
|
20057
|
+
throw new Error(`${this.cliName} not ready (status: ${this.engine.currentStatus})`);
|
|
20058
|
+
}
|
|
19992
20059
|
const parsedSessionStatus = typeof parsedStatusBeforeSend?.status === "string" ? String(parsedStatusBeforeSend.status) : "";
|
|
19993
20060
|
if (!allowInputDuringGeneration && (parsedSessionStatus === "generating" || parsedSessionStatus === "no_progress" || parsedSessionStatus === "long_generating")) {
|
|
19994
20061
|
const parsedModal = parsedStatusBeforeSend?.activeModal ?? parsedStatusBeforeSend?.modal ?? null;
|
|
@@ -32548,7 +32615,7 @@ var DaemonCommandHandler = class {
|
|
|
32548
32615
|
return { success: false, error: "invalid type" };
|
|
32549
32616
|
}
|
|
32550
32617
|
const https = __require("https");
|
|
32551
|
-
const
|
|
32618
|
+
const fs38 = __require("fs");
|
|
32552
32619
|
const path43 = __require("path");
|
|
32553
32620
|
const REGISTRY = "https://api.adhf.dev/api/v1/registry";
|
|
32554
32621
|
function fetchText(url, timeoutMs) {
|
|
@@ -32591,7 +32658,7 @@ var DaemonCommandHandler = class {
|
|
|
32591
32658
|
if (!targetDir.startsWith(installRootResolved + path43.sep)) {
|
|
32592
32659
|
return { success: false, error: "install path escaped upstream root" };
|
|
32593
32660
|
}
|
|
32594
|
-
|
|
32661
|
+
fs38.mkdirSync(targetDir, { recursive: true });
|
|
32595
32662
|
let manifestProbe = {};
|
|
32596
32663
|
try {
|
|
32597
32664
|
manifestProbe = JSON.parse(manifestBody);
|
|
@@ -32616,7 +32683,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
32616
32683
|
}
|
|
32617
32684
|
const targetFile = isV1 ? "provider.v1.json" : "provider.json";
|
|
32618
32685
|
const targetPath = path43.join(targetDir, targetFile);
|
|
32619
|
-
|
|
32686
|
+
fs38.writeFileSync(targetPath, manifestBody, "utf-8");
|
|
32620
32687
|
const manifestJson = JSON.parse(manifestBody);
|
|
32621
32688
|
const scriptFetch = await this.fetchProviderSources(
|
|
32622
32689
|
manifestJson,
|
|
@@ -32686,7 +32753,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
32686
32753
|
const repo = source.repo;
|
|
32687
32754
|
const ref = source.ref;
|
|
32688
32755
|
const https = __require("https");
|
|
32689
|
-
const
|
|
32756
|
+
const fs38 = __require("fs");
|
|
32690
32757
|
const path43 = __require("path");
|
|
32691
32758
|
function fetchJson(url, timeoutMs) {
|
|
32692
32759
|
return new Promise((resolve24, reject) => {
|
|
@@ -32770,8 +32837,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
32770
32837
|
const relInside = entry.path.startsWith(sharedDirRel + "/") ? entry.path.slice(sharedDirRel.length + 1) : entry.path;
|
|
32771
32838
|
const outPath = path43.resolve(path43.join(sharedTargetDir, relInside));
|
|
32772
32839
|
if (!outPath.startsWith(path43.resolve(sharedTargetDir) + path43.sep)) continue;
|
|
32773
|
-
|
|
32774
|
-
|
|
32840
|
+
fs38.mkdirSync(path43.dirname(outPath), { recursive: true });
|
|
32841
|
+
fs38.writeFileSync(outPath, body);
|
|
32775
32842
|
fetchedCount++;
|
|
32776
32843
|
} catch (e) {
|
|
32777
32844
|
errors.push(`fetch shared ${entry.path}: ${e?.message ?? e}`);
|
|
@@ -32809,8 +32876,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
32809
32876
|
errors.push(`refusing to write outside targetDir: ${entry.path}`);
|
|
32810
32877
|
continue;
|
|
32811
32878
|
}
|
|
32812
|
-
|
|
32813
|
-
|
|
32879
|
+
fs38.mkdirSync(path43.dirname(outPath), { recursive: true });
|
|
32880
|
+
fs38.writeFileSync(outPath, body);
|
|
32814
32881
|
fetchedCount++;
|
|
32815
32882
|
} catch (e) {
|
|
32816
32883
|
errors.push(`fetch ${entry.path}: ${e?.message ?? e}`);
|
|
@@ -32838,7 +32905,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
32838
32905
|
if (!["cli", "ide", "extension", "acp"].includes(category)) {
|
|
32839
32906
|
return { success: false, error: `unknown category: ${category}` };
|
|
32840
32907
|
}
|
|
32841
|
-
const
|
|
32908
|
+
const fs38 = __require("fs");
|
|
32842
32909
|
const path43 = __require("path");
|
|
32843
32910
|
try {
|
|
32844
32911
|
const installRoot = this.getUpstreamInstallRoot();
|
|
@@ -32847,10 +32914,10 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
32847
32914
|
if (!targetDir.startsWith(installRootResolved + path43.sep)) {
|
|
32848
32915
|
return { success: false, error: "refusing to delete outside upstream root" };
|
|
32849
32916
|
}
|
|
32850
|
-
if (!
|
|
32917
|
+
if (!fs38.existsSync(targetDir)) {
|
|
32851
32918
|
return { success: false, error: "not installed" };
|
|
32852
32919
|
}
|
|
32853
|
-
|
|
32920
|
+
fs38.rmSync(targetDir, { recursive: true, force: true });
|
|
32854
32921
|
if (this._ctx.providerLoader) {
|
|
32855
32922
|
this._ctx.providerLoader.reload();
|
|
32856
32923
|
this._ctx.providerLoader.registerToDetector();
|
|
@@ -32866,28 +32933,28 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
32866
32933
|
* the UI and by the update checker.
|
|
32867
32934
|
*/
|
|
32868
32935
|
handleListInstalledProviders(_args) {
|
|
32869
|
-
const
|
|
32936
|
+
const fs38 = __require("fs");
|
|
32870
32937
|
const path43 = __require("path");
|
|
32871
32938
|
const installRoot = this.getUpstreamInstallRoot();
|
|
32872
|
-
if (!
|
|
32939
|
+
if (!fs38.existsSync(installRoot)) return { success: true, providers: [] };
|
|
32873
32940
|
const CATEGORIES = ["cli", "ide", "extension", "acp"];
|
|
32874
32941
|
const items = [];
|
|
32875
32942
|
for (const category of CATEGORIES) {
|
|
32876
32943
|
const categoryDir = path43.join(installRoot, category);
|
|
32877
|
-
if (!
|
|
32944
|
+
if (!fs38.existsSync(categoryDir)) continue;
|
|
32878
32945
|
let entries;
|
|
32879
32946
|
try {
|
|
32880
|
-
entries =
|
|
32947
|
+
entries = fs38.readdirSync(categoryDir);
|
|
32881
32948
|
} catch {
|
|
32882
32949
|
continue;
|
|
32883
32950
|
}
|
|
32884
32951
|
for (const type of entries) {
|
|
32885
32952
|
const v1Path = path43.join(categoryDir, type, "provider.v1.json");
|
|
32886
32953
|
const v0Path = path43.join(categoryDir, type, "provider.json");
|
|
32887
|
-
const manifestPath =
|
|
32954
|
+
const manifestPath = fs38.existsSync(v1Path) ? v1Path : fs38.existsSync(v0Path) ? v0Path : null;
|
|
32888
32955
|
if (!manifestPath) continue;
|
|
32889
32956
|
try {
|
|
32890
|
-
const m = JSON.parse(
|
|
32957
|
+
const m = JSON.parse(fs38.readFileSync(manifestPath, "utf-8"));
|
|
32891
32958
|
items.push({
|
|
32892
32959
|
type,
|
|
32893
32960
|
category,
|
|
@@ -32998,7 +33065,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
32998
33065
|
if (!/^@[a-z0-9_-]+$/i.test(requestedName)) {
|
|
32999
33066
|
return { success: false, error: "name must match @[a-z0-9_-]+" };
|
|
33000
33067
|
}
|
|
33001
|
-
const
|
|
33068
|
+
const fs38 = __require("fs");
|
|
33002
33069
|
const path43 = __require("path");
|
|
33003
33070
|
const { spawnSync: spawnSync2 } = __require("child_process");
|
|
33004
33071
|
const file = ext.loadExternalSources();
|
|
@@ -33009,8 +33076,8 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33009
33076
|
return { success: false, error: `source url+ref already registered (use a different name to track another ref)` };
|
|
33010
33077
|
}
|
|
33011
33078
|
const sourceDir = path43.join(ext.externalRoot(), requestedName);
|
|
33012
|
-
if (!
|
|
33013
|
-
if (
|
|
33079
|
+
if (!fs38.existsSync(ext.externalRoot())) fs38.mkdirSync(ext.externalRoot(), { recursive: true });
|
|
33080
|
+
if (fs38.existsSync(sourceDir)) {
|
|
33014
33081
|
return { success: false, error: `directory already exists: ${sourceDir} (rename or remove first)` };
|
|
33015
33082
|
}
|
|
33016
33083
|
const clone = spawnSync2("git", ["clone", "--depth=1", "--branch", ref, "--", url, sourceDir], {
|
|
@@ -33020,7 +33087,7 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33020
33087
|
});
|
|
33021
33088
|
if (clone.status !== 0) {
|
|
33022
33089
|
try {
|
|
33023
|
-
|
|
33090
|
+
fs38.rmSync(sourceDir, { recursive: true, force: true });
|
|
33024
33091
|
} catch {
|
|
33025
33092
|
}
|
|
33026
33093
|
return { success: false, error: `git clone failed: ${(clone.stderr || clone.stdout || "").trim() || "unknown error"}` };
|
|
@@ -33064,15 +33131,15 @@ ${formatManifestValidationIssues2(validation.issues)}`,
|
|
|
33064
33131
|
const name = typeof args?.name === "string" ? args.name.trim() : "";
|
|
33065
33132
|
if (!name) return { success: false, error: "name is required" };
|
|
33066
33133
|
const ext = (init_external_sources(), __toCommonJS(external_sources_exports));
|
|
33067
|
-
const
|
|
33134
|
+
const fs38 = __require("fs");
|
|
33068
33135
|
const path43 = __require("path");
|
|
33069
33136
|
const file = ext.loadExternalSources();
|
|
33070
33137
|
const match = file.sources.find((s2) => s2.name === name);
|
|
33071
33138
|
if (!match) return { success: false, error: `source "${name}" not registered` };
|
|
33072
33139
|
const sourceDir = path43.join(ext.externalRoot(), name);
|
|
33073
|
-
if (
|
|
33140
|
+
if (fs38.existsSync(sourceDir)) {
|
|
33074
33141
|
try {
|
|
33075
|
-
|
|
33142
|
+
fs38.rmSync(sourceDir, { recursive: true, force: true });
|
|
33076
33143
|
} catch (e) {
|
|
33077
33144
|
return { success: false, error: `failed to delete ${sourceDir}: ${e?.message || e}` };
|
|
33078
33145
|
}
|
|
@@ -33853,14 +33920,14 @@ var statusMetaHandlers = {
|
|
|
33853
33920
|
// src/commands/low-family/coordinator-prompt.ts
|
|
33854
33921
|
var coordinatorPromptHandlers = {
|
|
33855
33922
|
list_coordinator_prompts: async (_ctx, _args) => {
|
|
33856
|
-
const
|
|
33923
|
+
const fs38 = await import("fs");
|
|
33857
33924
|
const path43 = await import("path");
|
|
33858
33925
|
const os30 = await import("os");
|
|
33859
33926
|
const dir = path43.join(os30.homedir(), ".adhdev", "coordinator-prompts");
|
|
33860
33927
|
const entries = {};
|
|
33861
33928
|
try {
|
|
33862
|
-
if (
|
|
33863
|
-
for (const name of
|
|
33929
|
+
if (fs38.existsSync(dir)) {
|
|
33930
|
+
for (const name of fs38.readdirSync(dir)) {
|
|
33864
33931
|
const matchOverride = name.match(/^([a-zA-Z0-9_.-]+)\.md$/);
|
|
33865
33932
|
const matchAppend = name.match(/^([a-zA-Z0-9_.-]+)\.append\.md$/);
|
|
33866
33933
|
const m = matchAppend || matchOverride;
|
|
@@ -33870,7 +33937,7 @@ var coordinatorPromptHandlers = {
|
|
|
33870
33937
|
const full = path43.join(dir, name);
|
|
33871
33938
|
let content = "";
|
|
33872
33939
|
try {
|
|
33873
|
-
content =
|
|
33940
|
+
content = fs38.readFileSync(full, "utf8");
|
|
33874
33941
|
} catch {
|
|
33875
33942
|
}
|
|
33876
33943
|
if (!entries[key]) entries[key] = { override: "", append: "" };
|
|
@@ -33884,7 +33951,7 @@ var coordinatorPromptHandlers = {
|
|
|
33884
33951
|
return { success: true, dir, entries };
|
|
33885
33952
|
},
|
|
33886
33953
|
write_coordinator_prompt: async (_ctx, args) => {
|
|
33887
|
-
const
|
|
33954
|
+
const fs38 = await import("fs");
|
|
33888
33955
|
const path43 = await import("path");
|
|
33889
33956
|
const os30 = await import("os");
|
|
33890
33957
|
const key = typeof args?.key === "string" ? args.key.trim() : "";
|
|
@@ -33897,11 +33964,11 @@ var coordinatorPromptHandlers = {
|
|
|
33897
33964
|
const filename = kind === "append" ? `${key}.append.md` : `${key}.md`;
|
|
33898
33965
|
const full = path43.join(dir, filename);
|
|
33899
33966
|
try {
|
|
33900
|
-
|
|
33967
|
+
fs38.mkdirSync(dir, { recursive: true });
|
|
33901
33968
|
if (content.trim()) {
|
|
33902
|
-
|
|
33903
|
-
} else if (
|
|
33904
|
-
|
|
33969
|
+
fs38.writeFileSync(full, content, { encoding: "utf8", mode: 384 });
|
|
33970
|
+
} else if (fs38.existsSync(full)) {
|
|
33971
|
+
fs38.unlinkSync(full);
|
|
33905
33972
|
}
|
|
33906
33973
|
return { success: true, path: full, kind, key };
|
|
33907
33974
|
} catch (error) {
|
|
@@ -35232,6 +35299,7 @@ function applyPreLaunchTrust(trust, workingDir) {
|
|
|
35232
35299
|
|
|
35233
35300
|
// src/providers/spec/fsm-driver.ts
|
|
35234
35301
|
init_logger();
|
|
35302
|
+
init_pty_write_chunking();
|
|
35235
35303
|
function countNewlines(s2) {
|
|
35236
35304
|
let n = 0;
|
|
35237
35305
|
for (let i = 0; i < s2.length; i += 1) if (s2.charCodeAt(i) === 10) n += 1;
|
|
@@ -35242,8 +35310,6 @@ var WIN32_SUBMIT_RESEND_GAP_MS = 350;
|
|
|
35242
35310
|
var WIN32_SUBMIT_MAX_RESENDS = 14;
|
|
35243
35311
|
var WIN32_SUBMIT_SETTLE_MS = 500;
|
|
35244
35312
|
var WIN32_SUBMIT_SETTLE_POLL_MS = 120;
|
|
35245
|
-
var WIN32_PTY_WRITE_CHUNK_CHARS = 1024;
|
|
35246
|
-
var WIN32_PTY_WRITE_CHUNK_GAP_MS = 8;
|
|
35247
35313
|
var WIN32_ECHO_PROBE_CHARS = 16;
|
|
35248
35314
|
var WIN32_ECHO_MAX_WAIT_MS = 2e4;
|
|
35249
35315
|
function normalizeForEcho(s2) {
|
|
@@ -35255,21 +35321,7 @@ function resolveSubmitDelayMs(specBeforeSubmit, text) {
|
|
|
35255
35321
|
const spec = typeof specBeforeSubmit === "number" && specBeforeSubmit > 0 ? specBeforeSubmit : 0;
|
|
35256
35322
|
return Math.max(spec, SUBMIT_DELAY_FLOOR_MS + linesBonus);
|
|
35257
35323
|
}
|
|
35258
|
-
|
|
35259
|
-
const chunks = [];
|
|
35260
|
-
let offset = 0;
|
|
35261
|
-
while (offset < text.length) {
|
|
35262
|
-
let end = Math.min(text.length, offset + size);
|
|
35263
|
-
if (end < text.length) {
|
|
35264
|
-
const code = text.charCodeAt(end - 1);
|
|
35265
|
-
if (code >= 55296 && code <= 56319) end -= 1;
|
|
35266
|
-
}
|
|
35267
|
-
if (end <= offset) end = Math.min(text.length, offset + size);
|
|
35268
|
-
chunks.push(text.slice(offset, end));
|
|
35269
|
-
offset = end;
|
|
35270
|
-
}
|
|
35271
|
-
return chunks;
|
|
35272
|
-
}
|
|
35324
|
+
var chunkPreservingSurrogates2 = chunkPreservingSurrogates;
|
|
35273
35325
|
function guessExt(mime) {
|
|
35274
35326
|
if (/png/i.test(mime)) return ".png";
|
|
35275
35327
|
if (/jpe?g/i.test(mime)) return ".jpg";
|
|
@@ -35940,7 +35992,7 @@ var FsmDriver = class {
|
|
|
35940
35992
|
this.adapter.send_keys(text);
|
|
35941
35993
|
return;
|
|
35942
35994
|
}
|
|
35943
|
-
const chunks =
|
|
35995
|
+
const chunks = chunkPreservingSurrogates2(text, WIN32_PTY_WRITE_CHUNK_CHARS);
|
|
35944
35996
|
let idx = 0;
|
|
35945
35997
|
const writeNext = () => {
|
|
35946
35998
|
this.win32WriteTimer = null;
|
|
@@ -44990,7 +45042,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
44990
45042
|
}
|
|
44991
45043
|
if (providerDir) {
|
|
44992
45044
|
try {
|
|
44993
|
-
const
|
|
45045
|
+
const fs38 = __require("fs");
|
|
44994
45046
|
const path43 = __require("path");
|
|
44995
45047
|
const candidates = [];
|
|
44996
45048
|
if (Array.isArray(base.compatibility)) {
|
|
@@ -45002,13 +45054,13 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
45002
45054
|
}
|
|
45003
45055
|
candidates.push(path43.join(providerDir, "specs", "default.json"));
|
|
45004
45056
|
candidates.push(path43.join(providerDir, "spec.json"));
|
|
45005
|
-
const specPath = candidates.find((p) =>
|
|
45057
|
+
const specPath = candidates.find((p) => fs38.existsSync(p));
|
|
45006
45058
|
if (specPath) {
|
|
45007
45059
|
resolved._resolvedSpecPath = specPath;
|
|
45008
45060
|
let specControls;
|
|
45009
45061
|
let nh;
|
|
45010
45062
|
try {
|
|
45011
|
-
const rawSpec = JSON.parse(
|
|
45063
|
+
const rawSpec = JSON.parse(fs38.readFileSync(specPath, "utf8"));
|
|
45012
45064
|
specControls = rawSpec.control_bar;
|
|
45013
45065
|
nh = rawSpec.native_history;
|
|
45014
45066
|
} catch {
|
|
@@ -45040,7 +45092,7 @@ var ProviderLoader = class _ProviderLoader {
|
|
|
45040
45092
|
reader = (input) => executeNativeHistory(nh, input);
|
|
45041
45093
|
} else if (nh.override_path) {
|
|
45042
45094
|
const overrideFile = path43.resolve(providerDir, nh.override_path);
|
|
45043
|
-
if (
|
|
45095
|
+
if (fs38.existsSync(overrideFile)) {
|
|
45044
45096
|
try {
|
|
45045
45097
|
registerProviderScriptRootSafely(path43.dirname(path43.dirname(providerDir)));
|
|
45046
45098
|
delete __require.cache[__require.resolve(overrideFile)];
|
|
@@ -46222,7 +46274,7 @@ async function detectCurrentWorkspace(ideId) {
|
|
|
46222
46274
|
}
|
|
46223
46275
|
} else if (plat === "win32") {
|
|
46224
46276
|
try {
|
|
46225
|
-
const
|
|
46277
|
+
const fs38 = __require("fs");
|
|
46226
46278
|
const appNameMap = getMacAppIdentifiers();
|
|
46227
46279
|
const appName = appNameMap[ideId];
|
|
46228
46280
|
if (appName) {
|
|
@@ -46231,8 +46283,8 @@ async function detectCurrentWorkspace(ideId) {
|
|
|
46231
46283
|
appName,
|
|
46232
46284
|
"storage.json"
|
|
46233
46285
|
);
|
|
46234
|
-
if (
|
|
46235
|
-
const data = JSON.parse(
|
|
46286
|
+
if (fs38.existsSync(storagePath)) {
|
|
46287
|
+
const data = JSON.parse(fs38.readFileSync(storagePath, "utf-8"));
|
|
46236
46288
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
46237
46289
|
if (workspaces.length > 0) {
|
|
46238
46290
|
const recent = workspaces[0];
|
|
@@ -46779,8 +46831,9 @@ var meshCrudHandlers = {
|
|
|
46779
46831
|
};
|
|
46780
46832
|
}
|
|
46781
46833
|
}
|
|
46834
|
+
const explicitCleanupMode = args?.sessionCleanupMode ?? args?.session_cleanup_mode;
|
|
46782
46835
|
const sessionCleanupMode = ctx.normalizeMeshSessionCleanupMode(
|
|
46783
|
-
|
|
46836
|
+
explicitCleanupMode ?? (node?.isLocalWorktree === true ? "stop_and_delete" : void 0) ?? mesh?.policy?.sessionCleanupOnNodeRemove
|
|
46784
46837
|
);
|
|
46785
46838
|
const explicitSessionIds = Array.isArray(args?.sessionIds) ? args.sessionIds.filter((v) => typeof v === "string" && v.trim().length > 0).map((v) => v.trim()) : void 0;
|
|
46786
46839
|
let sessionCleanup;
|
|
@@ -46852,12 +46905,16 @@ var meshCrudHandlers = {
|
|
|
46852
46905
|
}
|
|
46853
46906
|
}
|
|
46854
46907
|
const residueWarning = worktreeCleanup?.residue === true && typeof worktreeCleanup?.residueWarning === "string" ? worktreeCleanup.residueWarning : void 0;
|
|
46908
|
+
const skippedLiveSessionIds = Array.isArray(sessionCleanup?.skippedLiveSessionIds) ? sessionCleanup.skippedLiveSessionIds.filter((v) => typeof v === "string") : [];
|
|
46909
|
+
const orphanedSessionsRemaining = skippedLiveSessionIds.length > 0;
|
|
46910
|
+
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;
|
|
46855
46911
|
return {
|
|
46856
46912
|
success: true,
|
|
46857
46913
|
removed,
|
|
46858
46914
|
...residueWarning ? { residueWarning } : {},
|
|
46859
46915
|
...sessionCleanup ? { sessionCleanup } : {},
|
|
46860
|
-
...worktreeCleanup ? { worktreeCleanup } : {}
|
|
46916
|
+
...worktreeCleanup ? { worktreeCleanup } : {},
|
|
46917
|
+
...orphanedSessionsRemaining ? { orphanedSessionsRemaining: true, nextAction: orphanNextAction } : {}
|
|
46861
46918
|
};
|
|
46862
46919
|
} catch (e) {
|
|
46863
46920
|
return { success: false, error: e.message };
|
|
@@ -48190,7 +48247,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
48190
48247
|
workspace
|
|
48191
48248
|
};
|
|
48192
48249
|
}
|
|
48193
|
-
const { existsSync:
|
|
48250
|
+
const { existsSync: existsSync52, readFileSync: readFileSync40, writeFileSync: writeFileSync24, copyFileSync: copyFileSync4, mkdirSync: mkdirSync21 } = await import("fs");
|
|
48194
48251
|
const { dirname: dirname17 } = await import("path");
|
|
48195
48252
|
const mcpConfigPath = coordinatorSetup.configPath;
|
|
48196
48253
|
const hermesManualFallback = cliType === "hermes-cli" && configFormat === "hermes_config_yaml" ? createHermesManualMeshCoordinatorSetup(meshId, workspace) : null;
|
|
@@ -48233,7 +48290,7 @@ ${ptyResult.output.slice(-2e3)}`);
|
|
|
48233
48290
|
if (hermesManualFallback) return returnManualFallback(message);
|
|
48234
48291
|
return { success: false, code: "mesh_coordinator_config_write_failed", error: message, meshId, cliType, workspace };
|
|
48235
48292
|
}
|
|
48236
|
-
const hadExistingMcpConfig =
|
|
48293
|
+
const hadExistingMcpConfig = existsSync52(mcpConfigPath);
|
|
48237
48294
|
let existingMcpConfig = hermesBaseConfig?.config || {};
|
|
48238
48295
|
if (hermesBaseConfig) {
|
|
48239
48296
|
copyHermesCoordinatorCredentialFiles(hermesBaseConfig.sourceHome, dirname17(mcpConfigPath));
|
|
@@ -48838,7 +48895,7 @@ var meshStatusHandlers = {
|
|
|
48838
48895
|
const { deriveMeshReviewInboxItems: deriveMeshReviewInboxItems2 } = await Promise.resolve().then(() => (init_mesh_review_inbox(), mesh_review_inbox_exports));
|
|
48839
48896
|
const { readLedgerEntries: readLedgerEntries2 } = await Promise.resolve().then(() => (init_mesh_ledger(), mesh_ledger_exports));
|
|
48840
48897
|
const { getGitDiffSummary: getGitDiffSummary2 } = await Promise.resolve().then(() => (init_git_diff(), git_diff_exports));
|
|
48841
|
-
const { existsSync:
|
|
48898
|
+
const { existsSync: existsSync52 } = await import("fs");
|
|
48842
48899
|
const meshRecord = await ctx.getMeshForCommand(meshId, args?.inlineMesh, { preferInline: true });
|
|
48843
48900
|
const mesh = meshRecord?.mesh;
|
|
48844
48901
|
if (!mesh) return { success: false, error: "Mesh not found" };
|
|
@@ -48857,7 +48914,7 @@ var meshStatusHandlers = {
|
|
|
48857
48914
|
const derivation = deriveMeshReviewInboxItems2({ nodes: nodeStatuses, ledgerEntries });
|
|
48858
48915
|
for (const item of derivation.items) {
|
|
48859
48916
|
const workspace = item.workspace;
|
|
48860
|
-
if (!workspace || !
|
|
48917
|
+
if (!workspace || !existsSync52(workspace)) continue;
|
|
48861
48918
|
const baseRef = item.defaultBranch ? `origin/${item.defaultBranch}` : "origin/main";
|
|
48862
48919
|
try {
|
|
48863
48920
|
const diffResult = await getGitDiffSummary2(workspace, { baseRef, maxFiles: 100 });
|
|
@@ -48906,8 +48963,6 @@ var highFamilyRegistry = new Map(
|
|
|
48906
48963
|
);
|
|
48907
48964
|
|
|
48908
48965
|
// src/commands/router.ts
|
|
48909
|
-
init_cli_detector();
|
|
48910
|
-
init_git_status();
|
|
48911
48966
|
init_dist();
|
|
48912
48967
|
init_logger();
|
|
48913
48968
|
|
|
@@ -49057,7 +49112,6 @@ function getRecentCommands(count = 50) {
|
|
|
49057
49112
|
cleanOldFiles();
|
|
49058
49113
|
|
|
49059
49114
|
// src/commands/router.ts
|
|
49060
|
-
import * as yaml4 from "js-yaml";
|
|
49061
49115
|
init_mesh_events();
|
|
49062
49116
|
init_mesh_host_ownership();
|
|
49063
49117
|
|
|
@@ -49150,13 +49204,18 @@ function orderMeshRefineBatchNodes(changeAreas) {
|
|
|
49150
49204
|
|
|
49151
49205
|
// src/commands/router.ts
|
|
49152
49206
|
init_mesh_work_queue();
|
|
49153
|
-
init_mesh_warmup_deadline();
|
|
49154
49207
|
init_repo_mesh_types();
|
|
49155
|
-
import {
|
|
49156
|
-
import
|
|
49208
|
+
import { resolve as pathResolve4 } from "path";
|
|
49209
|
+
import * as fs32 from "fs";
|
|
49210
|
+
import { execFileSync as execFileSync7 } from "child_process";
|
|
49211
|
+
|
|
49212
|
+
// src/mesh/mesh-node-identity.ts
|
|
49213
|
+
init_cli_detector();
|
|
49214
|
+
init_git_status();
|
|
49215
|
+
init_dist();
|
|
49216
|
+
init_logger();
|
|
49217
|
+
init_mesh_warmup_deadline();
|
|
49157
49218
|
import * as fs29 from "fs";
|
|
49158
|
-
import { execFileSync as execFileSync6 } from "child_process";
|
|
49159
|
-
init_resolve_executable();
|
|
49160
49219
|
init_runtime_defaults();
|
|
49161
49220
|
function readProviderPriorityFromPolicy(policy) {
|
|
49162
49221
|
const record = policy && typeof policy === "object" && !Array.isArray(policy) ? policy : {};
|
|
@@ -50377,6 +50436,13 @@ async function resolveProviderTypeFromPriority(args) {
|
|
|
50377
50436
|
}
|
|
50378
50437
|
return { error: `No usable provider detected for node '${args.nodeId}' from providerPriority: ${failed.join("; ")}` };
|
|
50379
50438
|
}
|
|
50439
|
+
|
|
50440
|
+
// src/mesh/mesh-refine-gates.ts
|
|
50441
|
+
init_git_status();
|
|
50442
|
+
init_resolve_executable();
|
|
50443
|
+
import { basename as pathBasename, join as pathJoin2, resolve as pathResolve2 } from "path";
|
|
50444
|
+
import * as fs30 from "fs";
|
|
50445
|
+
import { execFileSync as execFileSync6 } from "child_process";
|
|
50380
50446
|
var REFINE_VALIDATION_TIMEOUT_MS = 12e4;
|
|
50381
50447
|
var REFINE_VALIDATION_OUTPUT_LIMIT_BYTES = 128 * 1024;
|
|
50382
50448
|
var REFINE_VALIDATION_SUMMARY_CHARS = 2e3;
|
|
@@ -50430,18 +50496,18 @@ function resolveRefineryAutoPublishSubmoduleMainCommits(mesh, workspace) {
|
|
|
50430
50496
|
return { enabled: false };
|
|
50431
50497
|
}
|
|
50432
50498
|
async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
|
|
50433
|
-
const { execFileSync:
|
|
50499
|
+
const { execFileSync: execFileSync8 } = await import("child_process");
|
|
50434
50500
|
const diffArgs = ["diff", "--patch", "--full-index", fromRef, toRef];
|
|
50435
50501
|
if (excludePaths.length > 0) {
|
|
50436
50502
|
diffArgs.push("--", ".", ...excludePaths.map((path43) => `:(exclude)${path43}`));
|
|
50437
50503
|
}
|
|
50438
|
-
const diff =
|
|
50504
|
+
const diff = execFileSync8("git", diffArgs, {
|
|
50439
50505
|
cwd,
|
|
50440
50506
|
encoding: "utf8",
|
|
50441
50507
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
50442
50508
|
});
|
|
50443
50509
|
if (!diff.trim()) return "";
|
|
50444
|
-
const patchId =
|
|
50510
|
+
const patchId = execFileSync8("git", ["patch-id", "--stable"], {
|
|
50445
50511
|
cwd,
|
|
50446
50512
|
input: diff,
|
|
50447
50513
|
encoding: "utf8",
|
|
@@ -50452,8 +50518,8 @@ async function computeGitPatchId(cwd, fromRef, toRef, excludePaths = []) {
|
|
|
50452
50518
|
async function runMeshRefinePatchEquivalenceGate(repoRoot, baseHead, branchHead) {
|
|
50453
50519
|
const startedAt = Date.now();
|
|
50454
50520
|
try {
|
|
50455
|
-
const { execFileSync:
|
|
50456
|
-
const git = (args) =>
|
|
50521
|
+
const { execFileSync: execFileSync8 } = await import("child_process");
|
|
50522
|
+
const git = (args) => execFileSync8("git", args, {
|
|
50457
50523
|
cwd: repoRoot,
|
|
50458
50524
|
encoding: "utf8",
|
|
50459
50525
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -50544,8 +50610,8 @@ ${e?.stderr || ""}`
|
|
|
50544
50610
|
async function checkWorktreeChangesPatchEquivalentInRef(repoRoot, ref, worktreeHead) {
|
|
50545
50611
|
const startedAt = Date.now();
|
|
50546
50612
|
try {
|
|
50547
|
-
const { execFileSync:
|
|
50548
|
-
const git = (gitArgs) =>
|
|
50613
|
+
const { execFileSync: execFileSync8 } = await import("child_process");
|
|
50614
|
+
const git = (gitArgs) => execFileSync8("git", gitArgs, {
|
|
50549
50615
|
cwd: repoRoot,
|
|
50550
50616
|
encoding: "utf8",
|
|
50551
50617
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -50608,8 +50674,8 @@ ${mergeTreeErr?.stderr || ""}`;
|
|
|
50608
50674
|
async function runMeshRefineEffectiveDiffGate(repoRoot, baseHead, branchHead) {
|
|
50609
50675
|
const startedAt = Date.now();
|
|
50610
50676
|
try {
|
|
50611
|
-
const { execFileSync:
|
|
50612
|
-
const git = (args, opts) =>
|
|
50677
|
+
const { execFileSync: execFileSync8 } = await import("child_process");
|
|
50678
|
+
const git = (args, opts) => execFileSync8("git", args, {
|
|
50613
50679
|
cwd: opts?.cwd || repoRoot,
|
|
50614
50680
|
encoding: "utf8",
|
|
50615
50681
|
maxBuffer: REFINE_PATCH_EQUIVALENCE_OUTPUT_LIMIT_BYTES
|
|
@@ -50732,7 +50798,7 @@ function isSubmoduleFastForward(submoduleRepoPath, baseCommit, branchCommit) {
|
|
|
50732
50798
|
if (!baseCommit || !branchCommit) return false;
|
|
50733
50799
|
if (baseCommit === branchCommit) return true;
|
|
50734
50800
|
try {
|
|
50735
|
-
if (!
|
|
50801
|
+
if (!fs30.existsSync(submoduleRepoPath)) return false;
|
|
50736
50802
|
execFileSync6("git", ["cat-file", "-e", `${baseCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
50737
50803
|
execFileSync6("git", ["cat-file", "-e", `${branchCommit}^{commit}`], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
50738
50804
|
execFileSync6("git", ["merge-base", "--is-ancestor", baseCommit, branchCommit], { cwd: submoduleRepoPath, stdio: "ignore" });
|
|
@@ -50849,7 +50915,7 @@ function buildTreeWithGitlinksEqualized(repoRoot, commitish, paths, placeholderC
|
|
|
50849
50915
|
return newTree || void 0;
|
|
50850
50916
|
} finally {
|
|
50851
50917
|
try {
|
|
50852
|
-
|
|
50918
|
+
fs30.rmSync(tmpIndex, { force: true });
|
|
50853
50919
|
} catch {
|
|
50854
50920
|
}
|
|
50855
50921
|
}
|
|
@@ -50924,7 +50990,7 @@ function synthesizeTrivialFastForwardMergeTree(repoRoot, baseHead, branchHead, g
|
|
|
50924
50990
|
return newTree || void 0;
|
|
50925
50991
|
} finally {
|
|
50926
50992
|
try {
|
|
50927
|
-
|
|
50993
|
+
fs30.rmSync(tmpIndex, { force: true });
|
|
50928
50994
|
} catch {
|
|
50929
50995
|
}
|
|
50930
50996
|
}
|
|
@@ -51030,7 +51096,7 @@ async function runMeshRefineSubmoduleReachabilityGate(repoRoot, mergedTree, opti
|
|
|
51030
51096
|
return { stdout: String(stdout || ""), stderr: String(stderr || ""), refspec };
|
|
51031
51097
|
};
|
|
51032
51098
|
const importCommitFromWorktreeSubmodule = async (submodulePath, worktreeSubmodulePath, commit) => {
|
|
51033
|
-
if (!
|
|
51099
|
+
if (!fs30.existsSync(worktreeSubmodulePath)) return false;
|
|
51034
51100
|
try {
|
|
51035
51101
|
await runGit3(worktreeSubmodulePath, ["cat-file", "-e", `${commit}^{commit}`]);
|
|
51036
51102
|
} catch {
|
|
@@ -51053,7 +51119,7 @@ async function runMeshRefineSubmoduleReachabilityGate(repoRoot, mergedTree, opti
|
|
|
51053
51119
|
reachable: false
|
|
51054
51120
|
};
|
|
51055
51121
|
try {
|
|
51056
|
-
if (!
|
|
51122
|
+
if (!fs30.existsSync(submodulePath)) {
|
|
51057
51123
|
entry.error = `Submodule checkout missing at ${gitlink.path}`;
|
|
51058
51124
|
entry.publishRequired = true;
|
|
51059
51125
|
if (options.allowAutoPublishSubmoduleMainCommits === true) {
|
|
@@ -51290,9 +51356,9 @@ async function runMeshRefineValidationGate(mesh, workspace, opts) {
|
|
|
51290
51356
|
return ["npm", "pnpm", "yarn", "bun"].includes(command) && candidate.args.some((arg) => arg === "run" || arg === "test" || arg === "exec");
|
|
51291
51357
|
};
|
|
51292
51358
|
const dependenciesLikelyMissing = (cwd) => {
|
|
51293
|
-
if (!
|
|
51294
|
-
if (
|
|
51295
|
-
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) =>
|
|
51359
|
+
if (!fs30.existsSync(pathJoin2(cwd, "package.json"))) return false;
|
|
51360
|
+
if (fs30.existsSync(pathJoin2(cwd, "node_modules"))) return false;
|
|
51361
|
+
return ["package-lock.json", "npm-shrinkwrap.json", "pnpm-lock.yaml", "yarn.lock", "bun.lockb", "bun.lock"].some((lock) => fs30.existsSync(pathJoin2(cwd, lock)));
|
|
51296
51362
|
};
|
|
51297
51363
|
if (runLegacyBootstrapCommands) {
|
|
51298
51364
|
summary.bootstrap = { stage: "legacy" };
|
|
@@ -51379,6 +51445,13 @@ async function runMeshRefineValidationGate(mesh, workspace, opts) {
|
|
|
51379
51445
|
summary.status = "passed";
|
|
51380
51446
|
return summary;
|
|
51381
51447
|
}
|
|
51448
|
+
|
|
51449
|
+
// src/mesh/mesh-coordinator-config.ts
|
|
51450
|
+
init_logger();
|
|
51451
|
+
import * as yaml4 from "js-yaml";
|
|
51452
|
+
import { homedir as homedir26 } from "os";
|
|
51453
|
+
import { join as pathJoin3, resolve as pathResolve3 } from "path";
|
|
51454
|
+
import * as fs31 from "fs";
|
|
51382
51455
|
function loadYamlModule() {
|
|
51383
51456
|
return yaml4;
|
|
51384
51457
|
}
|
|
@@ -51397,14 +51470,14 @@ function serializeMeshCoordinatorMcpConfig(config, format) {
|
|
|
51397
51470
|
}
|
|
51398
51471
|
function resolveHermesUserHome() {
|
|
51399
51472
|
const explicitHome = process.env.HERMES_HOME?.trim();
|
|
51400
|
-
return explicitHome ||
|
|
51473
|
+
return explicitHome || pathJoin3(homedir26(), ".hermes");
|
|
51401
51474
|
}
|
|
51402
51475
|
function loadHermesCoordinatorBaseConfig(targetConfigPath) {
|
|
51403
51476
|
const sourceHome = resolveHermesUserHome();
|
|
51404
|
-
const sourceConfigPath =
|
|
51405
|
-
if (!
|
|
51406
|
-
if (
|
|
51407
|
-
const parsed = parseMeshCoordinatorMcpConfig(
|
|
51477
|
+
const sourceConfigPath = pathJoin3(sourceHome, "config.yaml");
|
|
51478
|
+
if (!fs31.existsSync(sourceConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
51479
|
+
if (pathResolve3(sourceConfigPath) === pathResolve3(targetConfigPath)) return { config: {}, sourceHome, sourceConfigPath };
|
|
51480
|
+
const parsed = parseMeshCoordinatorMcpConfig(fs31.readFileSync(sourceConfigPath, "utf-8"), "hermes_config_yaml");
|
|
51408
51481
|
const { mcp_servers: _mcpServers, ...baseConfig } = parsed;
|
|
51409
51482
|
return { config: baseConfig, sourceHome, sourceConfigPath };
|
|
51410
51483
|
}
|
|
@@ -51437,18 +51510,20 @@ function stripHermesCoordinatorTempModelProviderOverrides(config) {
|
|
|
51437
51510
|
return sanitized;
|
|
51438
51511
|
}
|
|
51439
51512
|
function copyHermesCoordinatorCredentialFiles(sourceHome, targetHome) {
|
|
51440
|
-
if (
|
|
51513
|
+
if (pathResolve3(sourceHome) === pathResolve3(targetHome)) return;
|
|
51441
51514
|
for (const fileName of [".env", "auth.json"]) {
|
|
51442
|
-
const sourcePath =
|
|
51443
|
-
const targetPath =
|
|
51444
|
-
if (!
|
|
51515
|
+
const sourcePath = pathJoin3(sourceHome, fileName);
|
|
51516
|
+
const targetPath = pathJoin3(targetHome, fileName);
|
|
51517
|
+
if (!fs31.existsSync(sourcePath)) continue;
|
|
51445
51518
|
try {
|
|
51446
|
-
|
|
51519
|
+
fs31.copyFileSync(sourcePath, targetPath);
|
|
51447
51520
|
} catch (error) {
|
|
51448
51521
|
LOG.warn("MeshCoordinator", `Could not copy Hermes ${fileName} into isolated coordinator home: ${error?.message || error}`);
|
|
51449
51522
|
}
|
|
51450
51523
|
}
|
|
51451
51524
|
}
|
|
51525
|
+
|
|
51526
|
+
// src/commands/router.ts
|
|
51452
51527
|
var CHAT_COMMANDS = [
|
|
51453
51528
|
"send_chat",
|
|
51454
51529
|
"new_chat",
|
|
@@ -51915,7 +51990,7 @@ var DaemonCommandRouter = class {
|
|
|
51915
51990
|
const nodeId = readInlineMeshNodeId(node);
|
|
51916
51991
|
if (!nodeId || !tombstones.has(nodeId)) return true;
|
|
51917
51992
|
const workspace = readStringValue(node?.workspace);
|
|
51918
|
-
if (workspace &&
|
|
51993
|
+
if (workspace && fs32.existsSync(workspace)) {
|
|
51919
51994
|
tombstones.delete(nodeId);
|
|
51920
51995
|
return true;
|
|
51921
51996
|
}
|
|
@@ -51950,14 +52025,14 @@ var DaemonCommandRouter = class {
|
|
|
51950
52025
|
* to give handles time to release, and reports whether residue remains.
|
|
51951
52026
|
*/
|
|
51952
52027
|
async bestEffortRemoveWorktreeDir(dir) {
|
|
51953
|
-
if (!dir || !
|
|
52028
|
+
if (!dir || !fs32.existsSync(dir)) return { removed: true, residue: false };
|
|
51954
52029
|
const sleep3 = (ms) => new Promise((resolve24) => setTimeout(resolve24, ms));
|
|
51955
52030
|
const ABSORB = /* @__PURE__ */ new Set(["EINVAL", "EPERM", "EBUSY", "ENOTEMPTY", "EACCES", "EMFILE", "ENFILE"]);
|
|
51956
52031
|
let lastErr;
|
|
51957
52032
|
for (let attempt = 0; attempt < 4; attempt++) {
|
|
51958
52033
|
try {
|
|
51959
|
-
|
|
51960
|
-
if (!
|
|
52034
|
+
fs32.rmSync(dir, { recursive: true, force: true, maxRetries: 3, retryDelay: 100 });
|
|
52035
|
+
if (!fs32.existsSync(dir)) return { removed: true, residue: false };
|
|
51961
52036
|
lastErr = new Error("directory still present after rmSync");
|
|
51962
52037
|
} catch (e) {
|
|
51963
52038
|
lastErr = e;
|
|
@@ -51968,7 +52043,7 @@ var DaemonCommandRouter = class {
|
|
|
51968
52043
|
}
|
|
51969
52044
|
await sleep3(150 * (attempt + 1));
|
|
51970
52045
|
}
|
|
51971
|
-
return
|
|
52046
|
+
return fs32.existsSync(dir) ? { removed: false, residue: true, error: String(lastErr?.message || lastErr || "unknown rm error") } : { removed: true, residue: false };
|
|
51972
52047
|
}
|
|
51973
52048
|
async cleanupLocalWorktreeNode(args) {
|
|
51974
52049
|
const workspace = typeof args.node?.workspace === "string" ? args.node.workspace.trim() : "";
|
|
@@ -51980,13 +52055,13 @@ var DaemonCommandRouter = class {
|
|
|
51980
52055
|
recoveryHint: "Inspect the mesh node record before removing it, or remove stale metadata manually only after confirming no managed worktree remains."
|
|
51981
52056
|
};
|
|
51982
52057
|
}
|
|
51983
|
-
const worktreeExists =
|
|
52058
|
+
const worktreeExists = fs32.existsSync(workspace);
|
|
51984
52059
|
const sourceNode = args.node?.clonedFromNodeId ? args.mesh?.nodes?.find((n) => meshNodeIdMatches(n, args.node.clonedFromNodeId)) : args.mesh?.nodes?.find((n) => !n.isLocalWorktree);
|
|
51985
52060
|
const repoRoot = typeof sourceNode?.repoRoot === "string" && sourceNode.repoRoot.trim() ? sourceNode.repoRoot.trim() : typeof sourceNode?.workspace === "string" && sourceNode.workspace.trim() ? sourceNode.workspace.trim() : "";
|
|
51986
52061
|
if (!worktreeExists) {
|
|
51987
52062
|
return { success: true, skipped: true, removedPath: workspace, repoRoot: repoRoot || void 0, reason: "worktree_path_missing" };
|
|
51988
52063
|
}
|
|
51989
|
-
if (!repoRoot || !
|
|
52064
|
+
if (!repoRoot || !fs32.existsSync(repoRoot)) {
|
|
51990
52065
|
return {
|
|
51991
52066
|
success: false,
|
|
51992
52067
|
code: "mesh_worktree_cleanup_missing_source_repo",
|
|
@@ -52004,9 +52079,9 @@ var DaemonCommandRouter = class {
|
|
|
52004
52079
|
}
|
|
52005
52080
|
const { resolveWorktreePath: resolveWorktreePath2, listWorktrees: listWorktrees2, removeWorktree: removeWorktree2 } = await Promise.resolve().then(() => (init_git_worktree(), git_worktree_exports));
|
|
52006
52081
|
const normalizePath = (value) => {
|
|
52007
|
-
const resolved =
|
|
52082
|
+
const resolved = pathResolve4(value);
|
|
52008
52083
|
try {
|
|
52009
|
-
return
|
|
52084
|
+
return fs32.realpathSync(resolved);
|
|
52010
52085
|
} catch {
|
|
52011
52086
|
return resolved;
|
|
52012
52087
|
}
|
|
@@ -52303,14 +52378,19 @@ var DaemonCommandRouter = class {
|
|
|
52303
52378
|
skippedCoordinatorSessionIds.push(sessionId);
|
|
52304
52379
|
continue;
|
|
52305
52380
|
}
|
|
52306
|
-
|
|
52381
|
+
const matchedByWorkspaceOnly = !recordNodeId;
|
|
52382
|
+
const isWorktreeNodeRemoval = cleanupSource === "mesh_remove_node" && args.node?.isLocalWorktree === true;
|
|
52383
|
+
const cleanWorkspaceOnlyForWorktree = isWorktreeNodeRemoval && matchedByWorkspaceOnly;
|
|
52384
|
+
if (!hasExplicitSessionIds && liveRuntime && !delegateBoundToThisNode && !cleanWorkspaceOnlyForWorktree) {
|
|
52307
52385
|
skippedSessionIds.push(sessionId);
|
|
52308
52386
|
skippedLiveSessionIds.push(sessionId);
|
|
52309
|
-
const matchedByWorkspaceOnly = !recordNodeId;
|
|
52310
52387
|
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";
|
|
52311
52388
|
skippedLiveSessionReasons.push({ sessionId, reason });
|
|
52312
52389
|
continue;
|
|
52313
52390
|
}
|
|
52391
|
+
if (cleanWorkspaceOnlyForWorktree && !delegateBoundToThisNode) {
|
|
52392
|
+
actedLiveDelegateSessionIds.push(sessionId);
|
|
52393
|
+
}
|
|
52314
52394
|
if (!hasExplicitSessionIds && liveRuntime && delegateBoundToThisNode && args.mode === "delete_stopped") {
|
|
52315
52395
|
skippedSessionIds.push(sessionId);
|
|
52316
52396
|
skippedLiveSessionIds.push(sessionId);
|
|
@@ -52800,7 +52880,7 @@ ${tail}` : ""
|
|
|
52800
52880
|
let didAutoRebase = false;
|
|
52801
52881
|
let isBehindBase = false;
|
|
52802
52882
|
try {
|
|
52803
|
-
|
|
52883
|
+
execFileSync7("git", ["merge-base", "--is-ancestor", branchHead, baseHead], {
|
|
52804
52884
|
cwd: node.workspace,
|
|
52805
52885
|
stdio: "ignore"
|
|
52806
52886
|
});
|
|
@@ -52810,7 +52890,7 @@ ${tail}` : ""
|
|
|
52810
52890
|
if (isBehindBase) {
|
|
52811
52891
|
const autoRebaseStarted = Date.now();
|
|
52812
52892
|
try {
|
|
52813
|
-
|
|
52893
|
+
execFileSync7("git", ["rebase", baseHead], {
|
|
52814
52894
|
cwd: node.workspace,
|
|
52815
52895
|
stdio: ["ignore", "pipe", "pipe"]
|
|
52816
52896
|
});
|
|
@@ -52851,7 +52931,7 @@ ${tail}` : ""
|
|
|
52851
52931
|
}
|
|
52852
52932
|
} catch (rebaseErr) {
|
|
52853
52933
|
try {
|
|
52854
|
-
|
|
52934
|
+
execFileSync7("git", ["rebase", "--abort"], { cwd: node.workspace, stdio: "ignore" });
|
|
52855
52935
|
} catch {
|
|
52856
52936
|
}
|
|
52857
52937
|
recordMeshRefineStage(refineStages, "patch_equivalence_after_auto_rebase", "failed", autoRebaseStarted, {
|
|
@@ -55614,7 +55694,7 @@ init_io_contracts();
|
|
|
55614
55694
|
init_chat_message_normalization();
|
|
55615
55695
|
|
|
55616
55696
|
// src/providers/version-archive.ts
|
|
55617
|
-
import * as
|
|
55697
|
+
import * as fs33 from "fs";
|
|
55618
55698
|
import * as path38 from "path";
|
|
55619
55699
|
import * as os28 from "os";
|
|
55620
55700
|
import { platform as platform8 } from "os";
|
|
@@ -55628,8 +55708,8 @@ var VersionArchive = class {
|
|
|
55628
55708
|
}
|
|
55629
55709
|
load() {
|
|
55630
55710
|
try {
|
|
55631
|
-
if (
|
|
55632
|
-
this.history = JSON.parse(
|
|
55711
|
+
if (fs33.existsSync(ARCHIVE_PATH)) {
|
|
55712
|
+
this.history = JSON.parse(fs33.readFileSync(ARCHIVE_PATH, "utf-8"));
|
|
55633
55713
|
}
|
|
55634
55714
|
} catch {
|
|
55635
55715
|
this.history = {};
|
|
@@ -55666,8 +55746,8 @@ var VersionArchive = class {
|
|
|
55666
55746
|
}
|
|
55667
55747
|
save() {
|
|
55668
55748
|
try {
|
|
55669
|
-
|
|
55670
|
-
|
|
55749
|
+
fs33.mkdirSync(path38.dirname(ARCHIVE_PATH), { recursive: true });
|
|
55750
|
+
fs33.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
55671
55751
|
} catch {
|
|
55672
55752
|
}
|
|
55673
55753
|
}
|
|
@@ -55692,8 +55772,8 @@ function findBinary2(name) {
|
|
|
55692
55772
|
for (const ext of exes) {
|
|
55693
55773
|
const fullPath = path38.join(p, name + ext);
|
|
55694
55774
|
try {
|
|
55695
|
-
if (
|
|
55696
|
-
const stat2 =
|
|
55775
|
+
if (fs33.existsSync(fullPath)) {
|
|
55776
|
+
const stat2 = fs33.statSync(fullPath);
|
|
55697
55777
|
if (stat2.isFile() && (isWin || stat2.mode & 73)) {
|
|
55698
55778
|
return fullPath;
|
|
55699
55779
|
}
|
|
@@ -55740,9 +55820,9 @@ function checkPathExists2(paths) {
|
|
|
55740
55820
|
if (p.includes("*")) {
|
|
55741
55821
|
const home = os28.homedir();
|
|
55742
55822
|
const resolved = p.replace(/\*/g, home.split(path38.sep).pop() || "");
|
|
55743
|
-
if (
|
|
55823
|
+
if (fs33.existsSync(resolved)) return resolved;
|
|
55744
55824
|
} else {
|
|
55745
|
-
if (
|
|
55825
|
+
if (fs33.existsSync(p)) return p;
|
|
55746
55826
|
}
|
|
55747
55827
|
}
|
|
55748
55828
|
return null;
|
|
@@ -55750,7 +55830,7 @@ function checkPathExists2(paths) {
|
|
|
55750
55830
|
async function getMacAppVersion(appPath) {
|
|
55751
55831
|
if (platform8() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
55752
55832
|
const plistPath = path38.join(appPath, "Contents", "Info.plist");
|
|
55753
|
-
if (!
|
|
55833
|
+
if (!fs33.existsSync(plistPath)) return null;
|
|
55754
55834
|
const raw = await runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
55755
55835
|
return raw || null;
|
|
55756
55836
|
}
|
|
@@ -55777,7 +55857,7 @@ async function detectAllVersions(loader, archive) {
|
|
|
55777
55857
|
let resolvedBin = cliBin;
|
|
55778
55858
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
55779
55859
|
const bundled = path38.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
55780
|
-
if (provider.cli &&
|
|
55860
|
+
if (provider.cli && fs33.existsSync(bundled)) resolvedBin = bundled;
|
|
55781
55861
|
}
|
|
55782
55862
|
info.installed = !!(appPath || resolvedBin);
|
|
55783
55863
|
info.path = appPath || null;
|
|
@@ -55825,7 +55905,7 @@ async function detectAllVersions(loader, archive) {
|
|
|
55825
55905
|
|
|
55826
55906
|
// src/daemon/dev-server.ts
|
|
55827
55907
|
import * as http2 from "http";
|
|
55828
|
-
import * as
|
|
55908
|
+
import * as fs37 from "fs";
|
|
55829
55909
|
import * as path42 from "path";
|
|
55830
55910
|
init_config();
|
|
55831
55911
|
|
|
@@ -56178,7 +56258,7 @@ init_builders();
|
|
|
56178
56258
|
|
|
56179
56259
|
// src/daemon/dev-cdp-handlers.ts
|
|
56180
56260
|
init_logger();
|
|
56181
|
-
import * as
|
|
56261
|
+
import * as fs34 from "fs";
|
|
56182
56262
|
import * as path39 from "path";
|
|
56183
56263
|
async function handleCdpEvaluate(ctx, req, res) {
|
|
56184
56264
|
const body = await ctx.readBody(req);
|
|
@@ -56358,17 +56438,17 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
56358
56438
|
}
|
|
56359
56439
|
let scriptsPath = "";
|
|
56360
56440
|
const directScripts = path39.join(dir, "scripts.js");
|
|
56361
|
-
if (
|
|
56441
|
+
if (fs34.existsSync(directScripts)) {
|
|
56362
56442
|
scriptsPath = directScripts;
|
|
56363
56443
|
} else {
|
|
56364
56444
|
const scriptsDir = path39.join(dir, "scripts");
|
|
56365
|
-
if (
|
|
56366
|
-
const versions =
|
|
56367
|
-
return
|
|
56445
|
+
if (fs34.existsSync(scriptsDir)) {
|
|
56446
|
+
const versions = fs34.readdirSync(scriptsDir).filter((d) => {
|
|
56447
|
+
return fs34.statSync(path39.join(scriptsDir, d)).isDirectory();
|
|
56368
56448
|
}).sort().reverse();
|
|
56369
56449
|
for (const ver of versions) {
|
|
56370
56450
|
const p = path39.join(scriptsDir, ver, "scripts.js");
|
|
56371
|
-
if (
|
|
56451
|
+
if (fs34.existsSync(p)) {
|
|
56372
56452
|
scriptsPath = p;
|
|
56373
56453
|
break;
|
|
56374
56454
|
}
|
|
@@ -56380,7 +56460,7 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
56380
56460
|
return;
|
|
56381
56461
|
}
|
|
56382
56462
|
try {
|
|
56383
|
-
const source =
|
|
56463
|
+
const source = fs34.readFileSync(scriptsPath, "utf-8");
|
|
56384
56464
|
const hints = {};
|
|
56385
56465
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
56386
56466
|
let match;
|
|
@@ -57195,7 +57275,7 @@ async function handleDomContext(ctx, type, req, res) {
|
|
|
57195
57275
|
}
|
|
57196
57276
|
|
|
57197
57277
|
// src/daemon/dev-cli-debug.ts
|
|
57198
|
-
import * as
|
|
57278
|
+
import * as fs35 from "fs";
|
|
57199
57279
|
import * as path40 from "path";
|
|
57200
57280
|
function slugifyFixtureName(value) {
|
|
57201
57281
|
const normalized = String(value || "").trim().toLowerCase().replace(/[^a-z0-9._-]+/g, "-").replace(/^-+|-+$/g, "");
|
|
@@ -57211,10 +57291,10 @@ function getCliFixtureDir(ctx, type) {
|
|
|
57211
57291
|
function readCliFixture(ctx, type, name) {
|
|
57212
57292
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
57213
57293
|
const filePath = path40.join(fixtureDir, `${name}.json`);
|
|
57214
|
-
if (!
|
|
57294
|
+
if (!fs35.existsSync(filePath)) {
|
|
57215
57295
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
57216
57296
|
}
|
|
57217
|
-
return JSON.parse(
|
|
57297
|
+
return JSON.parse(fs35.readFileSync(filePath, "utf-8"));
|
|
57218
57298
|
}
|
|
57219
57299
|
function getExerciseTranscriptText(result) {
|
|
57220
57300
|
const parts = [];
|
|
@@ -57959,7 +58039,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
57959
58039
|
return;
|
|
57960
58040
|
}
|
|
57961
58041
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
57962
|
-
|
|
58042
|
+
fs35.mkdirSync(fixtureDir, { recursive: true });
|
|
57963
58043
|
const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
|
|
57964
58044
|
const result = await runCliExerciseInternal(ctx, { ...request, type });
|
|
57965
58045
|
const fixture = {
|
|
@@ -57987,7 +58067,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
57987
58067
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
57988
58068
|
};
|
|
57989
58069
|
const filePath = path40.join(fixtureDir, `${name}.json`);
|
|
57990
|
-
|
|
58070
|
+
fs35.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
57991
58071
|
ctx.json(res, 200, {
|
|
57992
58072
|
saved: true,
|
|
57993
58073
|
name,
|
|
@@ -58005,14 +58085,14 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
58005
58085
|
async function handleCliFixtureList(ctx, type, _req, res) {
|
|
58006
58086
|
try {
|
|
58007
58087
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
58008
|
-
if (!
|
|
58088
|
+
if (!fs35.existsSync(fixtureDir)) {
|
|
58009
58089
|
ctx.json(res, 200, { fixtures: [], count: 0 });
|
|
58010
58090
|
return;
|
|
58011
58091
|
}
|
|
58012
|
-
const fixtures =
|
|
58092
|
+
const fixtures = fs35.readdirSync(fixtureDir).filter((file) => file.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file) => {
|
|
58013
58093
|
const fullPath = path40.join(fixtureDir, file);
|
|
58014
58094
|
try {
|
|
58015
|
-
const raw = JSON.parse(
|
|
58095
|
+
const raw = JSON.parse(fs35.readFileSync(fullPath, "utf-8"));
|
|
58016
58096
|
return {
|
|
58017
58097
|
name: raw.name || file.replace(/\.json$/i, ""),
|
|
58018
58098
|
path: fullPath,
|
|
@@ -58145,7 +58225,7 @@ async function handleCliRaw(ctx, req, res) {
|
|
|
58145
58225
|
}
|
|
58146
58226
|
|
|
58147
58227
|
// src/daemon/dev-auto-implement.ts
|
|
58148
|
-
import * as
|
|
58228
|
+
import * as fs36 from "fs";
|
|
58149
58229
|
import * as path41 from "path";
|
|
58150
58230
|
import * as os29 from "os";
|
|
58151
58231
|
import { DEFAULT_SESSION_HOST_COLS as DEFAULT_SESSION_HOST_COLS7, DEFAULT_SESSION_HOST_ROWS as DEFAULT_SESSION_HOST_ROWS7 } from "@adhdev/session-host-core";
|
|
@@ -58194,10 +58274,10 @@ function resolveAutoImplReference(ctx, category, requestedReference, targetType)
|
|
|
58194
58274
|
return fallback?.type || null;
|
|
58195
58275
|
}
|
|
58196
58276
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
58197
|
-
if (!
|
|
58198
|
-
const versions =
|
|
58277
|
+
if (!fs36.existsSync(scriptsDir)) return null;
|
|
58278
|
+
const versions = fs36.readdirSync(scriptsDir).filter((d) => {
|
|
58199
58279
|
try {
|
|
58200
|
-
return
|
|
58280
|
+
return fs36.statSync(path41.join(scriptsDir, d)).isDirectory();
|
|
58201
58281
|
} catch {
|
|
58202
58282
|
return false;
|
|
58203
58283
|
}
|
|
@@ -58219,13 +58299,13 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
58219
58299
|
if (!sourceDir) {
|
|
58220
58300
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
58221
58301
|
}
|
|
58222
|
-
if (!
|
|
58223
|
-
|
|
58224
|
-
|
|
58302
|
+
if (!fs36.existsSync(desiredDir)) {
|
|
58303
|
+
fs36.mkdirSync(path41.dirname(desiredDir), { recursive: true });
|
|
58304
|
+
fs36.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
58225
58305
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
58226
58306
|
}
|
|
58227
58307
|
const providerJson = path41.join(desiredDir, "provider.json");
|
|
58228
|
-
if (!
|
|
58308
|
+
if (!fs36.existsSync(providerJson)) {
|
|
58229
58309
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
58230
58310
|
}
|
|
58231
58311
|
return { dir: desiredDir };
|
|
@@ -58233,15 +58313,15 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
58233
58313
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
58234
58314
|
if (!referenceType) return {};
|
|
58235
58315
|
const refDir = ctx.findProviderDir(referenceType);
|
|
58236
|
-
if (!refDir || !
|
|
58316
|
+
if (!refDir || !fs36.existsSync(refDir)) return {};
|
|
58237
58317
|
const referenceScripts = {};
|
|
58238
58318
|
const scriptsDir = path41.join(refDir, "scripts");
|
|
58239
58319
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
58240
58320
|
if (!latestDir) return referenceScripts;
|
|
58241
|
-
for (const file of
|
|
58321
|
+
for (const file of fs36.readdirSync(latestDir)) {
|
|
58242
58322
|
if (!file.endsWith(".js")) continue;
|
|
58243
58323
|
try {
|
|
58244
|
-
referenceScripts[file] =
|
|
58324
|
+
referenceScripts[file] = fs36.readFileSync(path41.join(latestDir, file), "utf-8");
|
|
58245
58325
|
} catch {
|
|
58246
58326
|
}
|
|
58247
58327
|
}
|
|
@@ -58350,15 +58430,15 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
58350
58430
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
58351
58431
|
const prompt = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
58352
58432
|
const tmpDir = path41.join(os29.tmpdir(), "adhdev-autoimpl");
|
|
58353
|
-
if (!
|
|
58433
|
+
if (!fs36.existsSync(tmpDir)) fs36.mkdirSync(tmpDir, { recursive: true });
|
|
58354
58434
|
const promptFile = path41.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
58355
|
-
|
|
58435
|
+
fs36.writeFileSync(promptFile, prompt, "utf-8");
|
|
58356
58436
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt.length} chars)`);
|
|
58357
58437
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
58358
58438
|
const spawn4 = agentProvider?.spawn;
|
|
58359
58439
|
if (!spawn4?.command) {
|
|
58360
58440
|
try {
|
|
58361
|
-
|
|
58441
|
+
fs36.unlinkSync(promptFile);
|
|
58362
58442
|
} catch {
|
|
58363
58443
|
}
|
|
58364
58444
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -58460,7 +58540,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
58460
58540
|
} catch {
|
|
58461
58541
|
}
|
|
58462
58542
|
try {
|
|
58463
|
-
|
|
58543
|
+
fs36.unlinkSync(promptFile);
|
|
58464
58544
|
} catch {
|
|
58465
58545
|
}
|
|
58466
58546
|
ctx.log(`Auto-implement (ACP) ${success ? "completed" : "failed"}: ${type} (exit: ${code})`);
|
|
@@ -58686,7 +58766,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
58686
58766
|
}
|
|
58687
58767
|
});
|
|
58688
58768
|
try {
|
|
58689
|
-
|
|
58769
|
+
fs36.unlinkSync(promptFile);
|
|
58690
58770
|
} catch {
|
|
58691
58771
|
}
|
|
58692
58772
|
ctx.log(`Auto-implement ${success ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
|
|
@@ -58791,10 +58871,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
58791
58871
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
58792
58872
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
58793
58873
|
lines.push("");
|
|
58794
|
-
for (const file of
|
|
58874
|
+
for (const file of fs36.readdirSync(latestScriptsDir)) {
|
|
58795
58875
|
if (file.endsWith(".js") && targetFileNames.has(file)) {
|
|
58796
58876
|
try {
|
|
58797
|
-
const content =
|
|
58877
|
+
const content = fs36.readFileSync(path41.join(latestScriptsDir, file), "utf-8");
|
|
58798
58878
|
lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
|
|
58799
58879
|
lines.push("```javascript");
|
|
58800
58880
|
lines.push(content);
|
|
@@ -58804,14 +58884,14 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
58804
58884
|
}
|
|
58805
58885
|
}
|
|
58806
58886
|
}
|
|
58807
|
-
const refFiles =
|
|
58887
|
+
const refFiles = fs36.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
58808
58888
|
if (refFiles.length > 0) {
|
|
58809
58889
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
58810
58890
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
58811
58891
|
lines.push("");
|
|
58812
58892
|
for (const file of refFiles) {
|
|
58813
58893
|
try {
|
|
58814
|
-
const content =
|
|
58894
|
+
const content = fs36.readFileSync(path41.join(latestScriptsDir, file), "utf-8");
|
|
58815
58895
|
lines.push(`### \`${file}\` \u{1F512}`);
|
|
58816
58896
|
lines.push("```javascript");
|
|
58817
58897
|
lines.push(content);
|
|
@@ -58856,7 +58936,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
58856
58936
|
const loadGuide = (name) => {
|
|
58857
58937
|
try {
|
|
58858
58938
|
const p = path41.join(docsDir, name);
|
|
58859
|
-
if (
|
|
58939
|
+
if (fs36.existsSync(p)) return fs36.readFileSync(p, "utf-8");
|
|
58860
58940
|
} catch {
|
|
58861
58941
|
}
|
|
58862
58942
|
return null;
|
|
@@ -59100,11 +59180,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
59100
59180
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
59101
59181
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
59102
59182
|
lines.push("");
|
|
59103
|
-
for (const file of
|
|
59183
|
+
for (const file of fs36.readdirSync(latestScriptsDir)) {
|
|
59104
59184
|
if (!file.endsWith(".js")) continue;
|
|
59105
59185
|
if (!targetFileNames.has(file)) continue;
|
|
59106
59186
|
try {
|
|
59107
|
-
const content =
|
|
59187
|
+
const content = fs36.readFileSync(path41.join(latestScriptsDir, file), "utf-8");
|
|
59108
59188
|
lines.push(`### \`${file}\` \u270F\uFE0F EDIT`);
|
|
59109
59189
|
lines.push("```javascript");
|
|
59110
59190
|
lines.push(content);
|
|
@@ -59113,14 +59193,14 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
59113
59193
|
} catch {
|
|
59114
59194
|
}
|
|
59115
59195
|
}
|
|
59116
|
-
const refFiles =
|
|
59196
|
+
const refFiles = fs36.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
59117
59197
|
if (refFiles.length > 0) {
|
|
59118
59198
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
59119
59199
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
59120
59200
|
lines.push("");
|
|
59121
59201
|
for (const file of refFiles) {
|
|
59122
59202
|
try {
|
|
59123
|
-
const content =
|
|
59203
|
+
const content = fs36.readFileSync(path41.join(latestScriptsDir, file), "utf-8");
|
|
59124
59204
|
lines.push(`### \`${file}\` \u{1F512}`);
|
|
59125
59205
|
lines.push("```javascript");
|
|
59126
59206
|
lines.push(content);
|
|
@@ -59157,7 +59237,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
59157
59237
|
const loadGuide = (name) => {
|
|
59158
59238
|
try {
|
|
59159
59239
|
const p = path41.join(docsDir, name);
|
|
59160
|
-
if (
|
|
59240
|
+
if (fs36.existsSync(p)) return fs36.readFileSync(p, "utf-8");
|
|
59161
59241
|
} catch {
|
|
59162
59242
|
}
|
|
59163
59243
|
return null;
|
|
@@ -59897,7 +59977,7 @@ var DevServer = class _DevServer {
|
|
|
59897
59977
|
path42.join(process.cwd(), "packages/web-devconsole/dist")
|
|
59898
59978
|
];
|
|
59899
59979
|
for (const dir of candidates) {
|
|
59900
|
-
if (
|
|
59980
|
+
if (fs37.existsSync(path42.join(dir, "index.html"))) return dir;
|
|
59901
59981
|
}
|
|
59902
59982
|
return null;
|
|
59903
59983
|
}
|
|
@@ -59909,7 +59989,7 @@ var DevServer = class _DevServer {
|
|
|
59909
59989
|
}
|
|
59910
59990
|
const htmlPath = path42.join(distDir, "index.html");
|
|
59911
59991
|
try {
|
|
59912
|
-
const html =
|
|
59992
|
+
const html = fs37.readFileSync(htmlPath, "utf-8");
|
|
59913
59993
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
59914
59994
|
res.end(html);
|
|
59915
59995
|
} catch (e) {
|
|
@@ -59939,7 +60019,7 @@ var DevServer = class _DevServer {
|
|
|
59939
60019
|
return;
|
|
59940
60020
|
}
|
|
59941
60021
|
try {
|
|
59942
|
-
const content =
|
|
60022
|
+
const content = fs37.readFileSync(filePath);
|
|
59943
60023
|
const ext = path42.extname(filePath);
|
|
59944
60024
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
59945
60025
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
@@ -60048,14 +60128,14 @@ var DevServer = class _DevServer {
|
|
|
60048
60128
|
const files = [];
|
|
60049
60129
|
const scan = (d, prefix) => {
|
|
60050
60130
|
try {
|
|
60051
|
-
for (const entry of
|
|
60131
|
+
for (const entry of fs37.readdirSync(d, { withFileTypes: true })) {
|
|
60052
60132
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
60053
60133
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
60054
60134
|
if (entry.isDirectory()) {
|
|
60055
60135
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
60056
60136
|
scan(path42.join(d, entry.name), rel);
|
|
60057
60137
|
} else {
|
|
60058
|
-
const stat2 =
|
|
60138
|
+
const stat2 = fs37.statSync(path42.join(d, entry.name));
|
|
60059
60139
|
files.push({ path: rel, size: stat2.size, type: "file" });
|
|
60060
60140
|
}
|
|
60061
60141
|
}
|
|
@@ -60083,11 +60163,11 @@ var DevServer = class _DevServer {
|
|
|
60083
60163
|
this.json(res, 403, { error: "Forbidden" });
|
|
60084
60164
|
return;
|
|
60085
60165
|
}
|
|
60086
|
-
if (!
|
|
60166
|
+
if (!fs37.existsSync(fullPath) || fs37.statSync(fullPath).isDirectory()) {
|
|
60087
60167
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
60088
60168
|
return;
|
|
60089
60169
|
}
|
|
60090
|
-
const content =
|
|
60170
|
+
const content = fs37.readFileSync(fullPath, "utf-8");
|
|
60091
60171
|
this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
|
|
60092
60172
|
}
|
|
60093
60173
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -60109,9 +60189,9 @@ var DevServer = class _DevServer {
|
|
|
60109
60189
|
return;
|
|
60110
60190
|
}
|
|
60111
60191
|
try {
|
|
60112
|
-
if (
|
|
60113
|
-
|
|
60114
|
-
|
|
60192
|
+
if (fs37.existsSync(fullPath)) fs37.copyFileSync(fullPath, fullPath + ".bak");
|
|
60193
|
+
fs37.mkdirSync(path42.dirname(fullPath), { recursive: true });
|
|
60194
|
+
fs37.writeFileSync(fullPath, content, "utf-8");
|
|
60115
60195
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
60116
60196
|
this.providerLoader.reload();
|
|
60117
60197
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -60128,8 +60208,8 @@ var DevServer = class _DevServer {
|
|
|
60128
60208
|
}
|
|
60129
60209
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
60130
60210
|
const p = path42.join(dir, name);
|
|
60131
|
-
if (
|
|
60132
|
-
const source =
|
|
60211
|
+
if (fs37.existsSync(p)) {
|
|
60212
|
+
const source = fs37.readFileSync(p, "utf-8");
|
|
60133
60213
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
60134
60214
|
return;
|
|
60135
60215
|
}
|
|
@@ -60148,11 +60228,11 @@ var DevServer = class _DevServer {
|
|
|
60148
60228
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
60149
60229
|
return;
|
|
60150
60230
|
}
|
|
60151
|
-
const target =
|
|
60231
|
+
const target = fs37.existsSync(path42.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
60152
60232
|
const targetPath = path42.join(dir, target);
|
|
60153
60233
|
try {
|
|
60154
|
-
if (
|
|
60155
|
-
|
|
60234
|
+
if (fs37.existsSync(targetPath)) fs37.copyFileSync(targetPath, targetPath + ".bak");
|
|
60235
|
+
fs37.writeFileSync(targetPath, source, "utf-8");
|
|
60156
60236
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
60157
60237
|
this.providerLoader.reload();
|
|
60158
60238
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -60297,20 +60377,20 @@ var DevServer = class _DevServer {
|
|
|
60297
60377
|
let targetDir;
|
|
60298
60378
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
60299
60379
|
const jsonPath = path42.join(targetDir, "provider.json");
|
|
60300
|
-
if (
|
|
60380
|
+
if (fs37.existsSync(jsonPath)) {
|
|
60301
60381
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
60302
60382
|
return;
|
|
60303
60383
|
}
|
|
60304
60384
|
try {
|
|
60305
60385
|
const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version, osPaths, processNames });
|
|
60306
|
-
|
|
60307
|
-
|
|
60386
|
+
fs37.mkdirSync(targetDir, { recursive: true });
|
|
60387
|
+
fs37.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
60308
60388
|
const createdFiles = ["provider.json"];
|
|
60309
60389
|
if (result.files) {
|
|
60310
60390
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
60311
60391
|
const fullPath = path42.join(targetDir, relPath);
|
|
60312
|
-
|
|
60313
|
-
|
|
60392
|
+
fs37.mkdirSync(path42.dirname(fullPath), { recursive: true });
|
|
60393
|
+
fs37.writeFileSync(fullPath, content, "utf-8");
|
|
60314
60394
|
createdFiles.push(relPath);
|
|
60315
60395
|
}
|
|
60316
60396
|
}
|
|
@@ -60359,10 +60439,10 @@ var DevServer = class _DevServer {
|
|
|
60359
60439
|
}
|
|
60360
60440
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
60361
60441
|
getLatestScriptVersionDir(scriptsDir) {
|
|
60362
|
-
if (!
|
|
60363
|
-
const versions =
|
|
60442
|
+
if (!fs37.existsSync(scriptsDir)) return null;
|
|
60443
|
+
const versions = fs37.readdirSync(scriptsDir).filter((d) => {
|
|
60364
60444
|
try {
|
|
60365
|
-
return
|
|
60445
|
+
return fs37.statSync(path42.join(scriptsDir, d)).isDirectory();
|
|
60366
60446
|
} catch {
|
|
60367
60447
|
return false;
|
|
60368
60448
|
}
|
|
@@ -60384,13 +60464,13 @@ var DevServer = class _DevServer {
|
|
|
60384
60464
|
if (!sourceDir) {
|
|
60385
60465
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
60386
60466
|
}
|
|
60387
|
-
if (!
|
|
60388
|
-
|
|
60389
|
-
|
|
60467
|
+
if (!fs37.existsSync(desiredDir)) {
|
|
60468
|
+
fs37.mkdirSync(path42.dirname(desiredDir), { recursive: true });
|
|
60469
|
+
fs37.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
60390
60470
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
60391
60471
|
}
|
|
60392
60472
|
const providerJson = path42.join(desiredDir, "provider.json");
|
|
60393
|
-
if (!
|
|
60473
|
+
if (!fs37.existsSync(providerJson)) {
|
|
60394
60474
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
60395
60475
|
}
|
|
60396
60476
|
return { dir: desiredDir };
|
|
@@ -61374,8 +61454,8 @@ async function installExtension(ide, extension) {
|
|
|
61374
61454
|
const res = await fetch(extension.vsixUrl);
|
|
61375
61455
|
if (res.ok) {
|
|
61376
61456
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
61377
|
-
const
|
|
61378
|
-
|
|
61457
|
+
const fs38 = await import("fs");
|
|
61458
|
+
fs38.writeFileSync(vsixPath, buffer);
|
|
61379
61459
|
return new Promise((resolve24) => {
|
|
61380
61460
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
61381
61461
|
exec6(cmd, { timeout: 6e4 }, (error, _stdout, stderr) => {
|
|
@@ -61958,7 +62038,7 @@ import { readFileSync as readFileSync38 } from "fs";
|
|
|
61958
62038
|
import { dirname as dirname15, resolve as resolve22 } from "path";
|
|
61959
62039
|
|
|
61960
62040
|
// src/providers/sdk/v1/validators/taint.ts
|
|
61961
|
-
import { readFileSync as readFileSync39, existsSync as
|
|
62041
|
+
import { readFileSync as readFileSync39, existsSync as existsSync51 } from "fs";
|
|
61962
62042
|
import { resolve as resolve23, dirname as dirname16, join as join47 } from "path";
|
|
61963
62043
|
|
|
61964
62044
|
// src/providers/sdk/v1/validators/index.ts
|