adhdev 0.9.50 → 0.9.52
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/index.js +853 -761
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +791 -699
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -1410,17 +1410,17 @@ function checkPathExists(paths) {
|
|
|
1410
1410
|
return null;
|
|
1411
1411
|
}
|
|
1412
1412
|
async function detectIDEs(providerLoader) {
|
|
1413
|
-
const
|
|
1413
|
+
const os31 = (0, import_os2.platform)();
|
|
1414
1414
|
const results = [];
|
|
1415
1415
|
for (const def of getMergedDefinitions()) {
|
|
1416
1416
|
const cliPath = findCliCommand(providerLoader?.getIdeCliCommand(def.id, def.cli) || def.cli);
|
|
1417
|
-
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[
|
|
1417
|
+
const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os31] || []) || []);
|
|
1418
1418
|
let resolvedCli = cliPath;
|
|
1419
|
-
if (!resolvedCli && appPath &&
|
|
1419
|
+
if (!resolvedCli && appPath && os31 === "darwin") {
|
|
1420
1420
|
const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
|
|
1421
1421
|
if ((0, import_fs3.existsSync)(bundledCli)) resolvedCli = bundledCli;
|
|
1422
1422
|
}
|
|
1423
|
-
if (!resolvedCli && appPath &&
|
|
1423
|
+
if (!resolvedCli && appPath && os31 === "win32") {
|
|
1424
1424
|
const { dirname: dirname11 } = await import("path");
|
|
1425
1425
|
const appDir = dirname11(appPath);
|
|
1426
1426
|
const candidates = [
|
|
@@ -1437,7 +1437,7 @@ async function detectIDEs(providerLoader) {
|
|
|
1437
1437
|
}
|
|
1438
1438
|
}
|
|
1439
1439
|
}
|
|
1440
|
-
const installed =
|
|
1440
|
+
const installed = os31 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
|
|
1441
1441
|
const version2 = resolvedCli ? getIdeVersion(resolvedCli) : null;
|
|
1442
1442
|
results.push({
|
|
1443
1443
|
id: def.id,
|
|
@@ -8228,6 +8228,50 @@ function buildDebugBundleText(bundle) {
|
|
|
8228
8228
|
"```"
|
|
8229
8229
|
].join("\n");
|
|
8230
8230
|
}
|
|
8231
|
+
function getChatDebugBundleDir() {
|
|
8232
|
+
const override = typeof process.env.ADHDEV_DEBUG_BUNDLE_DIR === "string" ? process.env.ADHDEV_DEBUG_BUNDLE_DIR.trim() : "";
|
|
8233
|
+
return override || path8.join(os7.homedir(), ".adhdev", "debug-bundles", "chat");
|
|
8234
|
+
}
|
|
8235
|
+
function safeBundleIdSegment(value, fallback2) {
|
|
8236
|
+
const normalized = String(value || fallback2).trim().replace(/[^A-Za-z0-9_.-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
|
|
8237
|
+
return normalized || fallback2;
|
|
8238
|
+
}
|
|
8239
|
+
function createChatDebugBundleId(targetSessionId) {
|
|
8240
|
+
const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:.]/g, "").replace("T", "T").replace("Z", "Z");
|
|
8241
|
+
const sessionSegment = safeBundleIdSegment(targetSessionId, "unknown-session");
|
|
8242
|
+
return `chat-debug-${timestamp}-${sessionSegment}-${(0, import_node_crypto.randomUUID)().slice(0, 8)}`;
|
|
8243
|
+
}
|
|
8244
|
+
function buildChatDebugBundleSummary(bundle) {
|
|
8245
|
+
const target = bundle.target && typeof bundle.target === "object" ? bundle.target : {};
|
|
8246
|
+
const readChat = bundle.readChat && typeof bundle.readChat === "object" ? bundle.readChat : {};
|
|
8247
|
+
const cli = bundle.cli && typeof bundle.cli === "object" ? bundle.cli : null;
|
|
8248
|
+
const frontend = bundle.frontend && typeof bundle.frontend === "object" ? bundle.frontend : null;
|
|
8249
|
+
return {
|
|
8250
|
+
createdAt: bundle.createdAt,
|
|
8251
|
+
targetSessionId: target.targetSessionId,
|
|
8252
|
+
providerType: target.providerType,
|
|
8253
|
+
transport: target.transport,
|
|
8254
|
+
readChatSuccess: readChat.success,
|
|
8255
|
+
readChatStatus: readChat.status,
|
|
8256
|
+
readChatTotalMessages: readChat.totalMessages,
|
|
8257
|
+
cliStatus: cli?.status,
|
|
8258
|
+
cliMessageCount: cli?.messageCount,
|
|
8259
|
+
hasFrontendSnapshot: !!frontend
|
|
8260
|
+
};
|
|
8261
|
+
}
|
|
8262
|
+
function storeChatDebugBundleOnDaemon(bundle, targetSessionId) {
|
|
8263
|
+
const bundleId = createChatDebugBundleId(targetSessionId);
|
|
8264
|
+
const dir = getChatDebugBundleDir();
|
|
8265
|
+
fs4.mkdirSync(dir, { recursive: true });
|
|
8266
|
+
const savedPath = path8.join(dir, `${bundleId}.json`);
|
|
8267
|
+
const json2 = `${JSON.stringify(bundle, null, 2)}
|
|
8268
|
+
`;
|
|
8269
|
+
fs4.writeFileSync(savedPath, json2, { encoding: "utf8", mode: 384 });
|
|
8270
|
+
return { bundleId, savedPath, sizeBytes: Buffer.byteLength(json2, "utf8") };
|
|
8271
|
+
}
|
|
8272
|
+
function isDaemonFileDebugDelivery(args) {
|
|
8273
|
+
return args?.delivery === "daemon_file" || args?.delivery === "file";
|
|
8274
|
+
}
|
|
8231
8275
|
async function handleGetChatDebugBundle(h, args) {
|
|
8232
8276
|
const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
|
|
8233
8277
|
if (!targetSessionId && !h.currentSession) {
|
|
@@ -8339,6 +8383,20 @@ async function handleGetChatDebugBundle(h, args) {
|
|
|
8339
8383
|
recentDebugTrace: getRecentDebugTrace({ limit: 120 })
|
|
8340
8384
|
};
|
|
8341
8385
|
const bundle = sanitizeDebugBundleValue(rawBundle);
|
|
8386
|
+
if (isDaemonFileDebugDelivery(args)) {
|
|
8387
|
+
const summary = buildChatDebugBundleSummary(bundle);
|
|
8388
|
+
const stored = storeChatDebugBundleOnDaemon(bundle, targetSessionId || String(summary.targetSessionId || "unknown-session"));
|
|
8389
|
+
LOG.info("Command", `[get_chat_debug_bundle] saved daemon_file bundle id=${stored.bundleId} path=${stored.savedPath} sizeBytes=${stored.sizeBytes} targetSessionId=${summary.targetSessionId || ""} providerType=${summary.providerType || ""} transport=${summary.transport || ""}`);
|
|
8390
|
+
return {
|
|
8391
|
+
success: true,
|
|
8392
|
+
delivery: "daemon_file",
|
|
8393
|
+
bundleId: stored.bundleId,
|
|
8394
|
+
savedPath: stored.savedPath,
|
|
8395
|
+
sizeBytes: stored.sizeBytes,
|
|
8396
|
+
createdAt: bundle.createdAt,
|
|
8397
|
+
summary
|
|
8398
|
+
};
|
|
8399
|
+
}
|
|
8342
8400
|
return {
|
|
8343
8401
|
success: true,
|
|
8344
8402
|
bundle,
|
|
@@ -9318,10 +9376,14 @@ async function handleResolveAction(h, args) {
|
|
|
9318
9376
|
}
|
|
9319
9377
|
return { success: false, error: "resolveAction script not available for this provider" };
|
|
9320
9378
|
}
|
|
9321
|
-
var RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget, DEFAULT_DEBUG_SANITIZE_OPTIONS, SECRET_KEY_PATTERN;
|
|
9379
|
+
var fs4, os7, path8, import_node_crypto, RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget, DEFAULT_DEBUG_SANITIZE_OPTIONS, SECRET_KEY_PATTERN;
|
|
9322
9380
|
var init_chat_commands = __esm({
|
|
9323
9381
|
"../../oss/packages/daemon-core/src/commands/chat-commands.ts"() {
|
|
9324
9382
|
"use strict";
|
|
9383
|
+
fs4 = __toESM(require("fs"));
|
|
9384
|
+
os7 = __toESM(require("os"));
|
|
9385
|
+
path8 = __toESM(require("path"));
|
|
9386
|
+
import_node_crypto = require("crypto");
|
|
9325
9387
|
init_contracts();
|
|
9326
9388
|
init_provider_input_support();
|
|
9327
9389
|
init_read_chat_contract();
|
|
@@ -9562,27 +9624,27 @@ function normalizeWindowsRequestedPath(requestedPath) {
|
|
|
9562
9624
|
function resolveSafePath(requestedPath) {
|
|
9563
9625
|
const rawPath = typeof requestedPath === "string" ? requestedPath.trim() : "";
|
|
9564
9626
|
const inputPath = rawPath || ".";
|
|
9565
|
-
const home =
|
|
9627
|
+
const home = os8.homedir();
|
|
9566
9628
|
if (inputPath.startsWith("~")) {
|
|
9567
|
-
return
|
|
9629
|
+
return path9.resolve(path9.join(home, inputPath.slice(1)));
|
|
9568
9630
|
}
|
|
9569
9631
|
if (process.platform === "win32") {
|
|
9570
9632
|
const normalized = normalizeWindowsRequestedPath(inputPath);
|
|
9571
|
-
if (
|
|
9572
|
-
return
|
|
9633
|
+
if (path9.win32.isAbsolute(normalized)) {
|
|
9634
|
+
return path9.win32.normalize(normalized);
|
|
9573
9635
|
}
|
|
9574
|
-
return
|
|
9636
|
+
return path9.win32.resolve(normalized);
|
|
9575
9637
|
}
|
|
9576
|
-
if (
|
|
9577
|
-
return
|
|
9638
|
+
if (path9.isAbsolute(inputPath)) {
|
|
9639
|
+
return path9.normalize(inputPath);
|
|
9578
9640
|
}
|
|
9579
|
-
return
|
|
9641
|
+
return path9.resolve(inputPath);
|
|
9580
9642
|
}
|
|
9581
9643
|
function listDirectoryEntriesSafe(dirPath) {
|
|
9582
|
-
const entries =
|
|
9644
|
+
const entries = fs5.readdirSync(dirPath, { withFileTypes: true });
|
|
9583
9645
|
const files = [];
|
|
9584
9646
|
for (const entry of entries) {
|
|
9585
|
-
const entryPath =
|
|
9647
|
+
const entryPath = path9.join(dirPath, entry.name);
|
|
9586
9648
|
try {
|
|
9587
9649
|
if (entry.isDirectory()) {
|
|
9588
9650
|
files.push({ name: entry.name, type: "directory" });
|
|
@@ -9591,14 +9653,14 @@ function listDirectoryEntriesSafe(dirPath) {
|
|
|
9591
9653
|
if (entry.isFile()) {
|
|
9592
9654
|
let size;
|
|
9593
9655
|
try {
|
|
9594
|
-
size =
|
|
9656
|
+
size = fs5.statSync(entryPath).size;
|
|
9595
9657
|
} catch {
|
|
9596
9658
|
size = void 0;
|
|
9597
9659
|
}
|
|
9598
9660
|
files.push({ name: entry.name, type: "file", size });
|
|
9599
9661
|
continue;
|
|
9600
9662
|
}
|
|
9601
|
-
const stat4 =
|
|
9663
|
+
const stat4 = fs5.statSync(entryPath);
|
|
9602
9664
|
files.push({
|
|
9603
9665
|
name: entry.name,
|
|
9604
9666
|
type: stat4.isDirectory() ? "directory" : "file",
|
|
@@ -9616,7 +9678,7 @@ function listWindowsDriveEntries(excludePath) {
|
|
|
9616
9678
|
const letter = String.fromCharCode(code);
|
|
9617
9679
|
const root = `${letter}:\\`;
|
|
9618
9680
|
try {
|
|
9619
|
-
if (!
|
|
9681
|
+
if (!fs5.existsSync(root)) continue;
|
|
9620
9682
|
if (excluded && root.toLowerCase() === excluded) continue;
|
|
9621
9683
|
drives.push({ name: `${letter}:`, type: "directory", path: root });
|
|
9622
9684
|
} catch {
|
|
@@ -9627,7 +9689,7 @@ function listWindowsDriveEntries(excludePath) {
|
|
|
9627
9689
|
async function handleFileRead(h, args) {
|
|
9628
9690
|
try {
|
|
9629
9691
|
const filePath = resolveSafePath(args?.path);
|
|
9630
|
-
const content =
|
|
9692
|
+
const content = fs5.readFileSync(filePath, "utf-8");
|
|
9631
9693
|
return { success: true, content, path: filePath };
|
|
9632
9694
|
} catch (e) {
|
|
9633
9695
|
return { success: false, error: e.message };
|
|
@@ -9636,8 +9698,8 @@ async function handleFileRead(h, args) {
|
|
|
9636
9698
|
async function handleFileWrite(h, args) {
|
|
9637
9699
|
try {
|
|
9638
9700
|
const filePath = resolveSafePath(args?.path);
|
|
9639
|
-
|
|
9640
|
-
|
|
9701
|
+
fs5.mkdirSync(path9.dirname(filePath), { recursive: true });
|
|
9702
|
+
fs5.writeFileSync(filePath, args?.content || "", "utf-8");
|
|
9641
9703
|
return { success: true, path: filePath };
|
|
9642
9704
|
} catch (e) {
|
|
9643
9705
|
return { success: false, error: e.message };
|
|
@@ -9669,13 +9731,13 @@ async function handleFileListBrowse(h, args) {
|
|
|
9669
9731
|
return { success: false, error: e.message };
|
|
9670
9732
|
}
|
|
9671
9733
|
}
|
|
9672
|
-
var
|
|
9734
|
+
var fs5, path9, os8, KEY_TO_VK;
|
|
9673
9735
|
var init_cdp_commands = __esm({
|
|
9674
9736
|
"../../oss/packages/daemon-core/src/commands/cdp-commands.ts"() {
|
|
9675
9737
|
"use strict";
|
|
9676
|
-
|
|
9677
|
-
|
|
9678
|
-
|
|
9738
|
+
fs5 = __toESM(require("fs"));
|
|
9739
|
+
path9 = __toESM(require("path"));
|
|
9740
|
+
os8 = __toESM(require("os"));
|
|
9679
9741
|
KEY_TO_VK = {
|
|
9680
9742
|
Backspace: 8,
|
|
9681
9743
|
Tab: 9,
|
|
@@ -9920,12 +9982,13 @@ async function handleSetProviderSourceConfig(h, args) {
|
|
|
9920
9982
|
});
|
|
9921
9983
|
loader.reload();
|
|
9922
9984
|
loader.registerToDetector();
|
|
9985
|
+
const refreshedInstances = h.ctx.instanceManager ? h.ctx.instanceManager.refreshProviderDefinitions((providerType) => loader.resolve(providerType)) : 0;
|
|
9923
9986
|
await h.ctx.onProviderSourceConfigChanged?.();
|
|
9924
9987
|
LOG.info(
|
|
9925
9988
|
"Command",
|
|
9926
9989
|
`[set_provider_source_config] mode=${sourceConfig.sourceMode} explicitProviderDir=${sourceConfig.explicitProviderDir || "-"} userDir=${sourceConfig.userDir}`
|
|
9927
9990
|
);
|
|
9928
|
-
return { success: true, reloaded: true, ...sourceConfig };
|
|
9991
|
+
return { success: true, reloaded: true, refreshedInstances, ...sourceConfig };
|
|
9929
9992
|
}
|
|
9930
9993
|
function normalizeProviderScriptArgs(args, scriptName) {
|
|
9931
9994
|
const normalizedArgs = { ...args || {} };
|
|
@@ -11656,7 +11719,7 @@ function getWorkspaceLabel(workspace) {
|
|
|
11656
11719
|
const trimmed = workspace.trim();
|
|
11657
11720
|
if (!trimmed) return "workspace";
|
|
11658
11721
|
const normalized = trimmed.replace(/[\\/]+$/, "");
|
|
11659
|
-
const base =
|
|
11722
|
+
const base = path10.basename(normalized);
|
|
11660
11723
|
return base || normalized;
|
|
11661
11724
|
}
|
|
11662
11725
|
function buildRuntimeDisplayName(payload) {
|
|
@@ -11765,7 +11828,7 @@ function getDefaultSessionHostEndpoint(appName = "adhdev") {
|
|
|
11765
11828
|
}
|
|
11766
11829
|
return {
|
|
11767
11830
|
kind: "unix",
|
|
11768
|
-
path: path22.join(
|
|
11831
|
+
path: path22.join(os10.tmpdir(), `${appName}-session-host.sock`)
|
|
11769
11832
|
};
|
|
11770
11833
|
}
|
|
11771
11834
|
function serializeEnvelope(envelope) {
|
|
@@ -11828,27 +11891,27 @@ function applyTerminalColorEnv(env3) {
|
|
|
11828
11891
|
function ensureNodePtySpawnHelperPermissions(logFn) {
|
|
11829
11892
|
if (os22.platform() === "win32") return;
|
|
11830
11893
|
try {
|
|
11831
|
-
const
|
|
11894
|
+
const fs23 = __require("fs");
|
|
11832
11895
|
const ptyDir = path32.resolve(path32.dirname(__require.resolve("node-pty")), "..");
|
|
11833
11896
|
const platformArch = `${os22.platform()}-${os22.arch()}`;
|
|
11834
11897
|
const helper = path32.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
|
|
11835
|
-
if (
|
|
11836
|
-
const stat4 =
|
|
11898
|
+
if (fs23.existsSync(helper)) {
|
|
11899
|
+
const stat4 = fs23.statSync(helper);
|
|
11837
11900
|
if (!(stat4.mode & 73)) {
|
|
11838
|
-
|
|
11901
|
+
fs23.chmodSync(helper, stat4.mode | 493);
|
|
11839
11902
|
logFn?.(`Fixed spawn-helper permissions: ${helper}`);
|
|
11840
11903
|
}
|
|
11841
11904
|
}
|
|
11842
11905
|
} catch {
|
|
11843
11906
|
}
|
|
11844
11907
|
}
|
|
11845
|
-
var import_crypto3,
|
|
11908
|
+
var import_crypto3, path10, os10, path22, net, import_crypto4, os22, path32, __require, DEFAULT_SESSION_RING_BUFFER_MAX_BYTES, SessionRingBuffer, DEFAULT_SESSION_HOST_COLS, DEFAULT_SESSION_HOST_ROWS, LIVE_LIFECYCLES2, SessionHostRegistry, SessionHostClient;
|
|
11846
11909
|
var init_dist = __esm({
|
|
11847
11910
|
"../../oss/packages/session-host-core/dist/index.mjs"() {
|
|
11848
11911
|
"use strict";
|
|
11849
11912
|
import_crypto3 = require("crypto");
|
|
11850
|
-
|
|
11851
|
-
|
|
11913
|
+
path10 = __toESM(require("path"), 1);
|
|
11914
|
+
os10 = __toESM(require("os"), 1);
|
|
11852
11915
|
path22 = __toESM(require("path"), 1);
|
|
11853
11916
|
net = __toESM(require("net"), 1);
|
|
11854
11917
|
import_crypto4 = require("crypto");
|
|
@@ -12267,11 +12330,11 @@ function loadNodePty() {
|
|
|
12267
12330
|
}
|
|
12268
12331
|
return cachedPty;
|
|
12269
12332
|
}
|
|
12270
|
-
var
|
|
12333
|
+
var os11, cachedPty, NodePtyRuntimeTransport, NodePtyTransportFactory;
|
|
12271
12334
|
var init_pty_transport = __esm({
|
|
12272
12335
|
"../../oss/packages/daemon-core/src/cli-adapters/pty-transport.ts"() {
|
|
12273
12336
|
"use strict";
|
|
12274
|
-
|
|
12337
|
+
os11 = __toESM(require("os"));
|
|
12275
12338
|
init_spawn_env();
|
|
12276
12339
|
NodePtyRuntimeTransport = class {
|
|
12277
12340
|
constructor(handle) {
|
|
@@ -12308,11 +12371,11 @@ var init_pty_transport = __esm({
|
|
|
12308
12371
|
let cwd = options.cwd;
|
|
12309
12372
|
if (cwd) {
|
|
12310
12373
|
try {
|
|
12311
|
-
const
|
|
12312
|
-
const stat4 =
|
|
12313
|
-
if (!stat4.isDirectory()) cwd =
|
|
12374
|
+
const fs23 = require("fs");
|
|
12375
|
+
const stat4 = fs23.statSync(cwd);
|
|
12376
|
+
if (!stat4.isDirectory()) cwd = os11.homedir();
|
|
12314
12377
|
} catch {
|
|
12315
|
-
cwd =
|
|
12378
|
+
cwd = os11.homedir();
|
|
12316
12379
|
}
|
|
12317
12380
|
}
|
|
12318
12381
|
const handle = pty.spawn(command, args, {
|
|
@@ -12392,11 +12455,11 @@ function buildCliScreenSnapshot(text) {
|
|
|
12392
12455
|
function findBinary(name) {
|
|
12393
12456
|
const trimmed = String(name || "").trim();
|
|
12394
12457
|
if (!trimmed) return trimmed;
|
|
12395
|
-
const expanded = trimmed.startsWith("~") ?
|
|
12396
|
-
if (
|
|
12397
|
-
return
|
|
12458
|
+
const expanded = trimmed.startsWith("~") ? path11.join(os12.homedir(), trimmed.slice(1)) : trimmed;
|
|
12459
|
+
if (path11.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
|
|
12460
|
+
return path11.isAbsolute(expanded) ? expanded : path11.resolve(expanded);
|
|
12398
12461
|
}
|
|
12399
|
-
const isWin =
|
|
12462
|
+
const isWin = os12.platform() === "win32";
|
|
12400
12463
|
try {
|
|
12401
12464
|
const cmd = isWin ? `where ${trimmed}` : `which ${trimmed}`;
|
|
12402
12465
|
return (0, import_child_process4.execSync)(cmd, {
|
|
@@ -12410,14 +12473,14 @@ function findBinary(name) {
|
|
|
12410
12473
|
}
|
|
12411
12474
|
}
|
|
12412
12475
|
function isScriptBinary(binaryPath) {
|
|
12413
|
-
if (!
|
|
12476
|
+
if (!path11.isAbsolute(binaryPath)) return false;
|
|
12414
12477
|
try {
|
|
12415
|
-
const
|
|
12416
|
-
const resolved =
|
|
12478
|
+
const fs23 = require("fs");
|
|
12479
|
+
const resolved = fs23.realpathSync(binaryPath);
|
|
12417
12480
|
const head = Buffer.alloc(8);
|
|
12418
|
-
const fd =
|
|
12419
|
-
|
|
12420
|
-
|
|
12481
|
+
const fd = fs23.openSync(resolved, "r");
|
|
12482
|
+
fs23.readSync(fd, head, 0, 8, 0);
|
|
12483
|
+
fs23.closeSync(fd);
|
|
12421
12484
|
let i = 0;
|
|
12422
12485
|
if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
|
|
12423
12486
|
return head[i] === 35 && head[i + 1] === 33;
|
|
@@ -12426,14 +12489,14 @@ function isScriptBinary(binaryPath) {
|
|
|
12426
12489
|
}
|
|
12427
12490
|
}
|
|
12428
12491
|
function looksLikeMachOOrElf(filePath) {
|
|
12429
|
-
if (!
|
|
12492
|
+
if (!path11.isAbsolute(filePath)) return false;
|
|
12430
12493
|
try {
|
|
12431
|
-
const
|
|
12432
|
-
const resolved =
|
|
12494
|
+
const fs23 = require("fs");
|
|
12495
|
+
const resolved = fs23.realpathSync(filePath);
|
|
12433
12496
|
const buf = Buffer.alloc(8);
|
|
12434
|
-
const fd =
|
|
12435
|
-
|
|
12436
|
-
|
|
12497
|
+
const fd = fs23.openSync(resolved, "r");
|
|
12498
|
+
fs23.readSync(fd, buf, 0, 8, 0);
|
|
12499
|
+
fs23.closeSync(fd);
|
|
12437
12500
|
let i = 0;
|
|
12438
12501
|
if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
|
|
12439
12502
|
const b = buf.subarray(i);
|
|
@@ -12449,7 +12512,7 @@ function looksLikeMachOOrElf(filePath) {
|
|
|
12449
12512
|
}
|
|
12450
12513
|
function shSingleQuote(arg) {
|
|
12451
12514
|
if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
|
|
12452
|
-
if (
|
|
12515
|
+
if (os12.platform() === "win32") {
|
|
12453
12516
|
return `"${arg.replace(/"/g, '""')}"`;
|
|
12454
12517
|
}
|
|
12455
12518
|
return `'${arg.replace(/'/g, `'\\''`)}'`;
|
|
@@ -12576,12 +12639,12 @@ function normalizeCliProviderForRuntime(raw) {
|
|
|
12576
12639
|
}
|
|
12577
12640
|
};
|
|
12578
12641
|
}
|
|
12579
|
-
var
|
|
12642
|
+
var os12, path11, import_child_process4, buildCliSpawnEnv, COMMON_COMPARABLE_WRAP_WORDS;
|
|
12580
12643
|
var init_provider_cli_shared = __esm({
|
|
12581
12644
|
"../../oss/packages/daemon-core/src/cli-adapters/provider-cli-shared.ts"() {
|
|
12582
12645
|
"use strict";
|
|
12583
|
-
|
|
12584
|
-
|
|
12646
|
+
os12 = __toESM(require("os"));
|
|
12647
|
+
path11 = __toESM(require("path"));
|
|
12585
12648
|
import_child_process4 = require("child_process");
|
|
12586
12649
|
init_spawn_env();
|
|
12587
12650
|
buildCliSpawnEnv = sanitizeSpawnEnv;
|
|
@@ -12894,13 +12957,13 @@ function resolveCliSpawnPlan(options) {
|
|
|
12894
12957
|
const { spawn: spawnConfig } = provider;
|
|
12895
12958
|
const configuredCommand = typeof runtimeSettings.executablePath === "string" && runtimeSettings.executablePath.trim() ? runtimeSettings.executablePath.trim() : spawnConfig.command;
|
|
12896
12959
|
const binaryPath = findBinary(configuredCommand);
|
|
12897
|
-
const isWin =
|
|
12960
|
+
const isWin = os13.platform() === "win32";
|
|
12898
12961
|
const allArgs = [...spawnConfig.args, ...extraArgs];
|
|
12899
12962
|
let shellCmd;
|
|
12900
12963
|
let shellArgs;
|
|
12901
|
-
const useShellUnix = !isWin && (!!spawnConfig.shell || !
|
|
12964
|
+
const useShellUnix = !isWin && (!!spawnConfig.shell || !path12.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
|
|
12902
12965
|
const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
|
|
12903
|
-
const useShellWin = !!spawnConfig.shell || isCmdShim || !
|
|
12966
|
+
const useShellWin = !!spawnConfig.shell || isCmdShim || !path12.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
|
|
12904
12967
|
const useShell = isWin ? useShellWin : useShellUnix;
|
|
12905
12968
|
if (useShell) {
|
|
12906
12969
|
shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
|
|
@@ -12976,12 +13039,12 @@ function respondToCliTerminalQueries(options) {
|
|
|
12976
13039
|
}
|
|
12977
13040
|
return "";
|
|
12978
13041
|
}
|
|
12979
|
-
var
|
|
13042
|
+
var os13, path12;
|
|
12980
13043
|
var init_provider_cli_runtime = __esm({
|
|
12981
13044
|
"../../oss/packages/daemon-core/src/cli-adapters/provider-cli-runtime.ts"() {
|
|
12982
13045
|
"use strict";
|
|
12983
|
-
|
|
12984
|
-
|
|
13046
|
+
os13 = __toESM(require("os"));
|
|
13047
|
+
path12 = __toESM(require("path"));
|
|
12985
13048
|
init_dist();
|
|
12986
13049
|
init_provider_cli_shared();
|
|
12987
13050
|
}
|
|
@@ -13103,11 +13166,11 @@ function trimLastAssistantEchoForCliMessages(messages, prompt2) {
|
|
|
13103
13166
|
return;
|
|
13104
13167
|
}
|
|
13105
13168
|
}
|
|
13106
|
-
var
|
|
13169
|
+
var os14, COMMITTED_ACTIVITY_PREFIX_BLOCK_RE, ProviderCliAdapter;
|
|
13107
13170
|
var init_provider_cli_adapter = __esm({
|
|
13108
13171
|
"../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts"() {
|
|
13109
13172
|
"use strict";
|
|
13110
|
-
|
|
13173
|
+
os14 = __toESM(require("os"));
|
|
13111
13174
|
init_logger();
|
|
13112
13175
|
init_debug_config();
|
|
13113
13176
|
init_terminal_screen();
|
|
@@ -13127,7 +13190,7 @@ var init_provider_cli_adapter = __esm({
|
|
|
13127
13190
|
this.transportFactory = transportFactory;
|
|
13128
13191
|
this.cliType = provider.type;
|
|
13129
13192
|
this.cliName = provider.name;
|
|
13130
|
-
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/,
|
|
13193
|
+
this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os14.homedir()) : workingDir;
|
|
13131
13194
|
const resolvedConfig = resolveCliAdapterConfig(provider);
|
|
13132
13195
|
this.timeouts = resolvedConfig.timeouts;
|
|
13133
13196
|
this.approvalKeys = resolvedConfig.approvalKeys;
|
|
@@ -15510,7 +15573,7 @@ function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages
|
|
|
15510
15573
|
}
|
|
15511
15574
|
function getDatabaseSync() {
|
|
15512
15575
|
if (CachedDatabaseSync) return CachedDatabaseSync;
|
|
15513
|
-
const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(
|
|
15576
|
+
const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(path13.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
|
|
15514
15577
|
const sqliteModule = requireFn(`node:${"sqlite"}`);
|
|
15515
15578
|
CachedDatabaseSync = sqliteModule.DatabaseSync;
|
|
15516
15579
|
if (!CachedDatabaseSync) {
|
|
@@ -15552,14 +15615,14 @@ async function waitForCliAdapterReady(adapter, options) {
|
|
|
15552
15615
|
}
|
|
15553
15616
|
throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
|
|
15554
15617
|
}
|
|
15555
|
-
var
|
|
15618
|
+
var os15, path13, crypto3, fs6, import_node_module, CachedDatabaseSync, CliProviderInstance;
|
|
15556
15619
|
var init_cli_provider_instance = __esm({
|
|
15557
15620
|
"../../oss/packages/daemon-core/src/providers/cli-provider-instance.ts"() {
|
|
15558
15621
|
"use strict";
|
|
15559
|
-
|
|
15560
|
-
|
|
15622
|
+
os15 = __toESM(require("os"));
|
|
15623
|
+
path13 = __toESM(require("path"));
|
|
15561
15624
|
crypto3 = __toESM(require("crypto"));
|
|
15562
|
-
|
|
15625
|
+
fs6 = __toESM(require("fs"));
|
|
15563
15626
|
import_node_module = require("module");
|
|
15564
15627
|
init_contracts();
|
|
15565
15628
|
init_provider_input_support();
|
|
@@ -15682,10 +15745,10 @@ var init_cli_provider_instance = __esm({
|
|
|
15682
15745
|
* Replaces the previously duplicated probeOpenCode/Codex/Goose functions.
|
|
15683
15746
|
*/
|
|
15684
15747
|
probeSessionIdFromConfig(probe) {
|
|
15685
|
-
const resolvedDbPath = probe.dbPath.replace(/^~/,
|
|
15748
|
+
const resolvedDbPath = probe.dbPath.replace(/^~/, os15.homedir());
|
|
15686
15749
|
const now = Date.now();
|
|
15687
15750
|
if (this.cachedSqliteDbMissingUntil > now) return null;
|
|
15688
|
-
if (!
|
|
15751
|
+
if (!fs6.existsSync(resolvedDbPath)) {
|
|
15689
15752
|
this.cachedSqliteDbMissingUntil = now + 1e4;
|
|
15690
15753
|
return null;
|
|
15691
15754
|
}
|
|
@@ -16417,7 +16480,7 @@ ${effect.notification.body || ""}`.trim();
|
|
|
16417
16480
|
};
|
|
16418
16481
|
addDir(this.workingDir);
|
|
16419
16482
|
try {
|
|
16420
|
-
addDir(
|
|
16483
|
+
addDir(fs6.realpathSync.native(this.workingDir));
|
|
16421
16484
|
} catch {
|
|
16422
16485
|
}
|
|
16423
16486
|
return Array.from(dirs);
|
|
@@ -16708,10 +16771,10 @@ function mergeDefs(...defs) {
|
|
|
16708
16771
|
function cloneDef(schema) {
|
|
16709
16772
|
return mergeDefs(schema._zod.def);
|
|
16710
16773
|
}
|
|
16711
|
-
function getElementAtPath(obj,
|
|
16712
|
-
if (!
|
|
16774
|
+
function getElementAtPath(obj, path36) {
|
|
16775
|
+
if (!path36)
|
|
16713
16776
|
return obj;
|
|
16714
|
-
return
|
|
16777
|
+
return path36.reduce((acc, key) => acc?.[key], obj);
|
|
16715
16778
|
}
|
|
16716
16779
|
function promiseAllObject(promisesObj) {
|
|
16717
16780
|
const keys = Object.keys(promisesObj);
|
|
@@ -17023,11 +17086,11 @@ function aborted(x, startIndex = 0) {
|
|
|
17023
17086
|
}
|
|
17024
17087
|
return false;
|
|
17025
17088
|
}
|
|
17026
|
-
function prefixIssues(
|
|
17089
|
+
function prefixIssues(path36, issues) {
|
|
17027
17090
|
return issues.map((iss) => {
|
|
17028
17091
|
var _a2;
|
|
17029
17092
|
(_a2 = iss).path ?? (_a2.path = []);
|
|
17030
|
-
iss.path.unshift(
|
|
17093
|
+
iss.path.unshift(path36);
|
|
17031
17094
|
return iss;
|
|
17032
17095
|
});
|
|
17033
17096
|
}
|
|
@@ -17270,7 +17333,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
|
|
|
17270
17333
|
}
|
|
17271
17334
|
function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
17272
17335
|
const result = { errors: [] };
|
|
17273
|
-
const processError = (error49,
|
|
17336
|
+
const processError = (error49, path36 = []) => {
|
|
17274
17337
|
var _a2, _b;
|
|
17275
17338
|
for (const issue2 of error49.issues) {
|
|
17276
17339
|
if (issue2.code === "invalid_union" && issue2.errors.length) {
|
|
@@ -17280,7 +17343,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
17280
17343
|
} else if (issue2.code === "invalid_element") {
|
|
17281
17344
|
processError({ issues: issue2.issues }, issue2.path);
|
|
17282
17345
|
} else {
|
|
17283
|
-
const fullpath = [...
|
|
17346
|
+
const fullpath = [...path36, ...issue2.path];
|
|
17284
17347
|
if (fullpath.length === 0) {
|
|
17285
17348
|
result.errors.push(mapper(issue2));
|
|
17286
17349
|
continue;
|
|
@@ -17312,8 +17375,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
|
|
|
17312
17375
|
}
|
|
17313
17376
|
function toDotPath(_path) {
|
|
17314
17377
|
const segs = [];
|
|
17315
|
-
const
|
|
17316
|
-
for (const seg of
|
|
17378
|
+
const path36 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
|
|
17379
|
+
for (const seg of path36) {
|
|
17317
17380
|
if (typeof seg === "number")
|
|
17318
17381
|
segs.push(`[${seg}]`);
|
|
17319
17382
|
else if (typeof seg === "symbol")
|
|
@@ -30077,13 +30140,13 @@ function resolveRef(ref, ctx) {
|
|
|
30077
30140
|
if (!ref.startsWith("#")) {
|
|
30078
30141
|
throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
|
|
30079
30142
|
}
|
|
30080
|
-
const
|
|
30081
|
-
if (
|
|
30143
|
+
const path36 = ref.slice(1).split("/").filter(Boolean);
|
|
30144
|
+
if (path36.length === 0) {
|
|
30082
30145
|
return ctx.rootSchema;
|
|
30083
30146
|
}
|
|
30084
30147
|
const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
|
|
30085
|
-
if (
|
|
30086
|
-
const key =
|
|
30148
|
+
if (path36[0] === defsKey) {
|
|
30149
|
+
const key = path36[1];
|
|
30087
30150
|
if (!key || !ctx.defs[key]) {
|
|
30088
30151
|
throw new Error(`Reference not found: ${ref}`);
|
|
30089
30152
|
}
|
|
@@ -33929,11 +33992,11 @@ var init_hosted_runtime_restore = __esm({
|
|
|
33929
33992
|
// ../../oss/packages/daemon-core/src/commands/cli-manager.ts
|
|
33930
33993
|
function isExplicitCommand(command) {
|
|
33931
33994
|
const trimmed = command.trim();
|
|
33932
|
-
return
|
|
33995
|
+
return path14.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
|
|
33933
33996
|
}
|
|
33934
33997
|
function expandExecutable(command) {
|
|
33935
33998
|
const trimmed = command.trim();
|
|
33936
|
-
return trimmed.startsWith("~") ?
|
|
33999
|
+
return trimmed.startsWith("~") ? path14.join(os16.homedir(), trimmed.slice(1)) : trimmed;
|
|
33937
34000
|
}
|
|
33938
34001
|
function commandExists(command) {
|
|
33939
34002
|
const trimmed = command.trim();
|
|
@@ -34070,12 +34133,12 @@ function resolveCliSessionBinding(provider, normalizedType, cliArgs, requestedRe
|
|
|
34070
34133
|
launchMode: "new"
|
|
34071
34134
|
};
|
|
34072
34135
|
}
|
|
34073
|
-
var
|
|
34136
|
+
var os16, path14, crypto4, import_fs5, import_child_process6, chalkModule, chalkApi, DaemonCliManager;
|
|
34074
34137
|
var init_cli_manager = __esm({
|
|
34075
34138
|
"../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
|
|
34076
34139
|
"use strict";
|
|
34077
|
-
|
|
34078
|
-
|
|
34140
|
+
os16 = __toESM(require("os"));
|
|
34141
|
+
path14 = __toESM(require("path"));
|
|
34079
34142
|
crypto4 = __toESM(require("crypto"));
|
|
34080
34143
|
import_fs5 = require("fs");
|
|
34081
34144
|
import_child_process6 = require("child_process");
|
|
@@ -34238,7 +34301,7 @@ var init_cli_manager = __esm({
|
|
|
34238
34301
|
async startSession(cliType, workingDir, cliArgs, initialModel, options) {
|
|
34239
34302
|
const trimmed = (workingDir || "").trim();
|
|
34240
34303
|
if (!trimmed) throw new Error("working directory required");
|
|
34241
|
-
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/,
|
|
34304
|
+
const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os16.homedir()) : path14.resolve(trimmed);
|
|
34242
34305
|
const normalizedType = this.providerLoader.resolveAlias(cliType);
|
|
34243
34306
|
const rawProvider = this.providerLoader.getByAlias(cliType);
|
|
34244
34307
|
const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
|
|
@@ -34841,7 +34904,7 @@ var init_readdirp = __esm({
|
|
|
34841
34904
|
this._directoryFilter = normalizeFilter(opts.directoryFilter);
|
|
34842
34905
|
const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
|
|
34843
34906
|
if (wantBigintFsStats) {
|
|
34844
|
-
this._stat = (
|
|
34907
|
+
this._stat = (path36) => statMethod(path36, { bigint: true });
|
|
34845
34908
|
} else {
|
|
34846
34909
|
this._stat = statMethod;
|
|
34847
34910
|
}
|
|
@@ -34866,8 +34929,8 @@ var init_readdirp = __esm({
|
|
|
34866
34929
|
const par = this.parent;
|
|
34867
34930
|
const fil = par && par.files;
|
|
34868
34931
|
if (fil && fil.length > 0) {
|
|
34869
|
-
const { path:
|
|
34870
|
-
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent,
|
|
34932
|
+
const { path: path36, depth } = par;
|
|
34933
|
+
const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path36));
|
|
34871
34934
|
const awaited = await Promise.all(slice);
|
|
34872
34935
|
for (const entry of awaited) {
|
|
34873
34936
|
if (!entry)
|
|
@@ -34907,20 +34970,20 @@ var init_readdirp = __esm({
|
|
|
34907
34970
|
this.reading = false;
|
|
34908
34971
|
}
|
|
34909
34972
|
}
|
|
34910
|
-
async _exploreDir(
|
|
34973
|
+
async _exploreDir(path36, depth) {
|
|
34911
34974
|
let files;
|
|
34912
34975
|
try {
|
|
34913
|
-
files = await (0, import_promises.readdir)(
|
|
34976
|
+
files = await (0, import_promises.readdir)(path36, this._rdOptions);
|
|
34914
34977
|
} catch (error48) {
|
|
34915
34978
|
this._onError(error48);
|
|
34916
34979
|
}
|
|
34917
|
-
return { files, depth, path:
|
|
34980
|
+
return { files, depth, path: path36 };
|
|
34918
34981
|
}
|
|
34919
|
-
async _formatEntry(dirent,
|
|
34982
|
+
async _formatEntry(dirent, path36) {
|
|
34920
34983
|
let entry;
|
|
34921
34984
|
const basename10 = this._isDirent ? dirent.name : dirent;
|
|
34922
34985
|
try {
|
|
34923
|
-
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(
|
|
34986
|
+
const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path36, basename10));
|
|
34924
34987
|
entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename10 };
|
|
34925
34988
|
entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
|
|
34926
34989
|
} catch (err) {
|
|
@@ -34977,16 +35040,16 @@ var init_readdirp = __esm({
|
|
|
34977
35040
|
});
|
|
34978
35041
|
|
|
34979
35042
|
// ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
|
|
34980
|
-
function createFsWatchInstance(
|
|
35043
|
+
function createFsWatchInstance(path36, options, listener, errHandler, emitRaw) {
|
|
34981
35044
|
const handleEvent = (rawEvent, evPath) => {
|
|
34982
|
-
listener(
|
|
34983
|
-
emitRaw(rawEvent, evPath, { watchedPath:
|
|
34984
|
-
if (evPath &&
|
|
34985
|
-
fsWatchBroadcast(sp.resolve(
|
|
35045
|
+
listener(path36);
|
|
35046
|
+
emitRaw(rawEvent, evPath, { watchedPath: path36 });
|
|
35047
|
+
if (evPath && path36 !== evPath) {
|
|
35048
|
+
fsWatchBroadcast(sp.resolve(path36, evPath), KEY_LISTENERS, sp.join(path36, evPath));
|
|
34986
35049
|
}
|
|
34987
35050
|
};
|
|
34988
35051
|
try {
|
|
34989
|
-
return (0, import_node_fs.watch)(
|
|
35052
|
+
return (0, import_node_fs.watch)(path36, {
|
|
34990
35053
|
persistent: options.persistent
|
|
34991
35054
|
}, handleEvent);
|
|
34992
35055
|
} catch (error48) {
|
|
@@ -35335,12 +35398,12 @@ var init_handler2 = __esm({
|
|
|
35335
35398
|
listener(val1, val2, val3);
|
|
35336
35399
|
});
|
|
35337
35400
|
};
|
|
35338
|
-
setFsWatchListener = (
|
|
35401
|
+
setFsWatchListener = (path36, fullPath, options, handlers) => {
|
|
35339
35402
|
const { listener, errHandler, rawEmitter } = handlers;
|
|
35340
35403
|
let cont = FsWatchInstances.get(fullPath);
|
|
35341
35404
|
let watcher;
|
|
35342
35405
|
if (!options.persistent) {
|
|
35343
|
-
watcher = createFsWatchInstance(
|
|
35406
|
+
watcher = createFsWatchInstance(path36, options, listener, errHandler, rawEmitter);
|
|
35344
35407
|
if (!watcher)
|
|
35345
35408
|
return;
|
|
35346
35409
|
return watcher.close.bind(watcher);
|
|
@@ -35351,7 +35414,7 @@ var init_handler2 = __esm({
|
|
|
35351
35414
|
addAndConvert(cont, KEY_RAW, rawEmitter);
|
|
35352
35415
|
} else {
|
|
35353
35416
|
watcher = createFsWatchInstance(
|
|
35354
|
-
|
|
35417
|
+
path36,
|
|
35355
35418
|
options,
|
|
35356
35419
|
fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
|
|
35357
35420
|
errHandler,
|
|
@@ -35366,7 +35429,7 @@ var init_handler2 = __esm({
|
|
|
35366
35429
|
cont.watcherUnusable = true;
|
|
35367
35430
|
if (isWindows && error48.code === "EPERM") {
|
|
35368
35431
|
try {
|
|
35369
|
-
const fd = await (0, import_promises2.open)(
|
|
35432
|
+
const fd = await (0, import_promises2.open)(path36, "r");
|
|
35370
35433
|
await fd.close();
|
|
35371
35434
|
broadcastErr(error48);
|
|
35372
35435
|
} catch (err) {
|
|
@@ -35397,7 +35460,7 @@ var init_handler2 = __esm({
|
|
|
35397
35460
|
};
|
|
35398
35461
|
};
|
|
35399
35462
|
FsWatchFileInstances = /* @__PURE__ */ new Map();
|
|
35400
|
-
setFsWatchFileListener = (
|
|
35463
|
+
setFsWatchFileListener = (path36, fullPath, options, handlers) => {
|
|
35401
35464
|
const { listener, rawEmitter } = handlers;
|
|
35402
35465
|
let cont = FsWatchFileInstances.get(fullPath);
|
|
35403
35466
|
const copts = cont && cont.options;
|
|
@@ -35419,7 +35482,7 @@ var init_handler2 = __esm({
|
|
|
35419
35482
|
});
|
|
35420
35483
|
const currmtime = curr.mtimeMs;
|
|
35421
35484
|
if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
|
|
35422
|
-
foreach(cont.listeners, (listener2) => listener2(
|
|
35485
|
+
foreach(cont.listeners, (listener2) => listener2(path36, curr));
|
|
35423
35486
|
}
|
|
35424
35487
|
})
|
|
35425
35488
|
};
|
|
@@ -35449,13 +35512,13 @@ var init_handler2 = __esm({
|
|
|
35449
35512
|
* @param listener on fs change
|
|
35450
35513
|
* @returns closer for the watcher instance
|
|
35451
35514
|
*/
|
|
35452
|
-
_watchWithNodeFs(
|
|
35515
|
+
_watchWithNodeFs(path36, listener) {
|
|
35453
35516
|
const opts = this.fsw.options;
|
|
35454
|
-
const directory = sp.dirname(
|
|
35455
|
-
const basename10 = sp.basename(
|
|
35517
|
+
const directory = sp.dirname(path36);
|
|
35518
|
+
const basename10 = sp.basename(path36);
|
|
35456
35519
|
const parent = this.fsw._getWatchedDir(directory);
|
|
35457
35520
|
parent.add(basename10);
|
|
35458
|
-
const absolutePath = sp.resolve(
|
|
35521
|
+
const absolutePath = sp.resolve(path36);
|
|
35459
35522
|
const options = {
|
|
35460
35523
|
persistent: opts.persistent
|
|
35461
35524
|
};
|
|
@@ -35465,12 +35528,12 @@ var init_handler2 = __esm({
|
|
|
35465
35528
|
if (opts.usePolling) {
|
|
35466
35529
|
const enableBin = opts.interval !== opts.binaryInterval;
|
|
35467
35530
|
options.interval = enableBin && isBinaryPath(basename10) ? opts.binaryInterval : opts.interval;
|
|
35468
|
-
closer = setFsWatchFileListener(
|
|
35531
|
+
closer = setFsWatchFileListener(path36, absolutePath, options, {
|
|
35469
35532
|
listener,
|
|
35470
35533
|
rawEmitter: this.fsw._emitRaw
|
|
35471
35534
|
});
|
|
35472
35535
|
} else {
|
|
35473
|
-
closer = setFsWatchListener(
|
|
35536
|
+
closer = setFsWatchListener(path36, absolutePath, options, {
|
|
35474
35537
|
listener,
|
|
35475
35538
|
errHandler: this._boundHandleError,
|
|
35476
35539
|
rawEmitter: this.fsw._emitRaw
|
|
@@ -35492,7 +35555,7 @@ var init_handler2 = __esm({
|
|
|
35492
35555
|
let prevStats = stats;
|
|
35493
35556
|
if (parent.has(basename10))
|
|
35494
35557
|
return;
|
|
35495
|
-
const listener = async (
|
|
35558
|
+
const listener = async (path36, newStats) => {
|
|
35496
35559
|
if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
|
|
35497
35560
|
return;
|
|
35498
35561
|
if (!newStats || newStats.mtimeMs === 0) {
|
|
@@ -35506,11 +35569,11 @@ var init_handler2 = __esm({
|
|
|
35506
35569
|
this.fsw._emit(EV.CHANGE, file2, newStats2);
|
|
35507
35570
|
}
|
|
35508
35571
|
if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
|
|
35509
|
-
this.fsw._closeFile(
|
|
35572
|
+
this.fsw._closeFile(path36);
|
|
35510
35573
|
prevStats = newStats2;
|
|
35511
35574
|
const closer2 = this._watchWithNodeFs(file2, listener);
|
|
35512
35575
|
if (closer2)
|
|
35513
|
-
this.fsw._addPathCloser(
|
|
35576
|
+
this.fsw._addPathCloser(path36, closer2);
|
|
35514
35577
|
} else {
|
|
35515
35578
|
prevStats = newStats2;
|
|
35516
35579
|
}
|
|
@@ -35542,7 +35605,7 @@ var init_handler2 = __esm({
|
|
|
35542
35605
|
* @param item basename of this item
|
|
35543
35606
|
* @returns true if no more processing is needed for this entry.
|
|
35544
35607
|
*/
|
|
35545
|
-
async _handleSymlink(entry, directory,
|
|
35608
|
+
async _handleSymlink(entry, directory, path36, item) {
|
|
35546
35609
|
if (this.fsw.closed) {
|
|
35547
35610
|
return;
|
|
35548
35611
|
}
|
|
@@ -35552,7 +35615,7 @@ var init_handler2 = __esm({
|
|
|
35552
35615
|
this.fsw._incrReadyCount();
|
|
35553
35616
|
let linkPath;
|
|
35554
35617
|
try {
|
|
35555
|
-
linkPath = await (0, import_promises2.realpath)(
|
|
35618
|
+
linkPath = await (0, import_promises2.realpath)(path36);
|
|
35556
35619
|
} catch (e) {
|
|
35557
35620
|
this.fsw._emitReady();
|
|
35558
35621
|
return true;
|
|
@@ -35562,12 +35625,12 @@ var init_handler2 = __esm({
|
|
|
35562
35625
|
if (dir.has(item)) {
|
|
35563
35626
|
if (this.fsw._symlinkPaths.get(full) !== linkPath) {
|
|
35564
35627
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
35565
|
-
this.fsw._emit(EV.CHANGE,
|
|
35628
|
+
this.fsw._emit(EV.CHANGE, path36, entry.stats);
|
|
35566
35629
|
}
|
|
35567
35630
|
} else {
|
|
35568
35631
|
dir.add(item);
|
|
35569
35632
|
this.fsw._symlinkPaths.set(full, linkPath);
|
|
35570
|
-
this.fsw._emit(EV.ADD,
|
|
35633
|
+
this.fsw._emit(EV.ADD, path36, entry.stats);
|
|
35571
35634
|
}
|
|
35572
35635
|
this.fsw._emitReady();
|
|
35573
35636
|
return true;
|
|
@@ -35597,9 +35660,9 @@ var init_handler2 = __esm({
|
|
|
35597
35660
|
return;
|
|
35598
35661
|
}
|
|
35599
35662
|
const item = entry.path;
|
|
35600
|
-
let
|
|
35663
|
+
let path36 = sp.join(directory, item);
|
|
35601
35664
|
current.add(item);
|
|
35602
|
-
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory,
|
|
35665
|
+
if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path36, item)) {
|
|
35603
35666
|
return;
|
|
35604
35667
|
}
|
|
35605
35668
|
if (this.fsw.closed) {
|
|
@@ -35608,8 +35671,8 @@ var init_handler2 = __esm({
|
|
|
35608
35671
|
}
|
|
35609
35672
|
if (item === target || !target && !previous.has(item)) {
|
|
35610
35673
|
this.fsw._incrReadyCount();
|
|
35611
|
-
|
|
35612
|
-
this._addToNodeFs(
|
|
35674
|
+
path36 = sp.join(dir, sp.relative(dir, path36));
|
|
35675
|
+
this._addToNodeFs(path36, initialAdd, wh, depth + 1);
|
|
35613
35676
|
}
|
|
35614
35677
|
}).on(EV.ERROR, this._boundHandleError);
|
|
35615
35678
|
return new Promise((resolve18, reject) => {
|
|
@@ -35678,13 +35741,13 @@ var init_handler2 = __esm({
|
|
|
35678
35741
|
* @param depth Child path actually targeted for watch
|
|
35679
35742
|
* @param target Child path actually targeted for watch
|
|
35680
35743
|
*/
|
|
35681
|
-
async _addToNodeFs(
|
|
35744
|
+
async _addToNodeFs(path36, initialAdd, priorWh, depth, target) {
|
|
35682
35745
|
const ready = this.fsw._emitReady;
|
|
35683
|
-
if (this.fsw._isIgnored(
|
|
35746
|
+
if (this.fsw._isIgnored(path36) || this.fsw.closed) {
|
|
35684
35747
|
ready();
|
|
35685
35748
|
return false;
|
|
35686
35749
|
}
|
|
35687
|
-
const wh = this.fsw._getWatchHelpers(
|
|
35750
|
+
const wh = this.fsw._getWatchHelpers(path36);
|
|
35688
35751
|
if (priorWh) {
|
|
35689
35752
|
wh.filterPath = (entry) => priorWh.filterPath(entry);
|
|
35690
35753
|
wh.filterDir = (entry) => priorWh.filterDir(entry);
|
|
@@ -35700,8 +35763,8 @@ var init_handler2 = __esm({
|
|
|
35700
35763
|
const follow = this.fsw.options.followSymlinks;
|
|
35701
35764
|
let closer;
|
|
35702
35765
|
if (stats.isDirectory()) {
|
|
35703
|
-
const absPath = sp.resolve(
|
|
35704
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
35766
|
+
const absPath = sp.resolve(path36);
|
|
35767
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path36) : path36;
|
|
35705
35768
|
if (this.fsw.closed)
|
|
35706
35769
|
return;
|
|
35707
35770
|
closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
|
|
@@ -35711,29 +35774,29 @@ var init_handler2 = __esm({
|
|
|
35711
35774
|
this.fsw._symlinkPaths.set(absPath, targetPath);
|
|
35712
35775
|
}
|
|
35713
35776
|
} else if (stats.isSymbolicLink()) {
|
|
35714
|
-
const targetPath = follow ? await (0, import_promises2.realpath)(
|
|
35777
|
+
const targetPath = follow ? await (0, import_promises2.realpath)(path36) : path36;
|
|
35715
35778
|
if (this.fsw.closed)
|
|
35716
35779
|
return;
|
|
35717
35780
|
const parent = sp.dirname(wh.watchPath);
|
|
35718
35781
|
this.fsw._getWatchedDir(parent).add(wh.watchPath);
|
|
35719
35782
|
this.fsw._emit(EV.ADD, wh.watchPath, stats);
|
|
35720
|
-
closer = await this._handleDir(parent, stats, initialAdd, depth,
|
|
35783
|
+
closer = await this._handleDir(parent, stats, initialAdd, depth, path36, wh, targetPath);
|
|
35721
35784
|
if (this.fsw.closed)
|
|
35722
35785
|
return;
|
|
35723
35786
|
if (targetPath !== void 0) {
|
|
35724
|
-
this.fsw._symlinkPaths.set(sp.resolve(
|
|
35787
|
+
this.fsw._symlinkPaths.set(sp.resolve(path36), targetPath);
|
|
35725
35788
|
}
|
|
35726
35789
|
} else {
|
|
35727
35790
|
closer = this._handleFile(wh.watchPath, stats, initialAdd);
|
|
35728
35791
|
}
|
|
35729
35792
|
ready();
|
|
35730
35793
|
if (closer)
|
|
35731
|
-
this.fsw._addPathCloser(
|
|
35794
|
+
this.fsw._addPathCloser(path36, closer);
|
|
35732
35795
|
return false;
|
|
35733
35796
|
} catch (error48) {
|
|
35734
35797
|
if (this.fsw._handleError(error48)) {
|
|
35735
35798
|
ready();
|
|
35736
|
-
return
|
|
35799
|
+
return path36;
|
|
35737
35800
|
}
|
|
35738
35801
|
}
|
|
35739
35802
|
}
|
|
@@ -35768,24 +35831,24 @@ function createPattern(matcher) {
|
|
|
35768
35831
|
}
|
|
35769
35832
|
return () => false;
|
|
35770
35833
|
}
|
|
35771
|
-
function normalizePath(
|
|
35772
|
-
if (typeof
|
|
35834
|
+
function normalizePath(path36) {
|
|
35835
|
+
if (typeof path36 !== "string")
|
|
35773
35836
|
throw new Error("string expected");
|
|
35774
|
-
|
|
35775
|
-
|
|
35837
|
+
path36 = sp2.normalize(path36);
|
|
35838
|
+
path36 = path36.replace(/\\/g, "/");
|
|
35776
35839
|
let prepend = false;
|
|
35777
|
-
if (
|
|
35840
|
+
if (path36.startsWith("//"))
|
|
35778
35841
|
prepend = true;
|
|
35779
|
-
|
|
35842
|
+
path36 = path36.replace(DOUBLE_SLASH_RE, "/");
|
|
35780
35843
|
if (prepend)
|
|
35781
|
-
|
|
35782
|
-
return
|
|
35844
|
+
path36 = "/" + path36;
|
|
35845
|
+
return path36;
|
|
35783
35846
|
}
|
|
35784
35847
|
function matchPatterns(patterns, testString, stats) {
|
|
35785
|
-
const
|
|
35848
|
+
const path36 = normalizePath(testString);
|
|
35786
35849
|
for (let index = 0; index < patterns.length; index++) {
|
|
35787
35850
|
const pattern = patterns[index];
|
|
35788
|
-
if (pattern(
|
|
35851
|
+
if (pattern(path36, stats)) {
|
|
35789
35852
|
return true;
|
|
35790
35853
|
}
|
|
35791
35854
|
}
|
|
@@ -35848,19 +35911,19 @@ var init_chokidar = __esm({
|
|
|
35848
35911
|
}
|
|
35849
35912
|
return str;
|
|
35850
35913
|
};
|
|
35851
|
-
normalizePathToUnix = (
|
|
35852
|
-
normalizeIgnored = (cwd = "") => (
|
|
35853
|
-
if (typeof
|
|
35854
|
-
return normalizePathToUnix(sp2.isAbsolute(
|
|
35914
|
+
normalizePathToUnix = (path36) => toUnix(sp2.normalize(toUnix(path36)));
|
|
35915
|
+
normalizeIgnored = (cwd = "") => (path36) => {
|
|
35916
|
+
if (typeof path36 === "string") {
|
|
35917
|
+
return normalizePathToUnix(sp2.isAbsolute(path36) ? path36 : sp2.join(cwd, path36));
|
|
35855
35918
|
} else {
|
|
35856
|
-
return
|
|
35919
|
+
return path36;
|
|
35857
35920
|
}
|
|
35858
35921
|
};
|
|
35859
|
-
getAbsolutePath = (
|
|
35860
|
-
if (sp2.isAbsolute(
|
|
35861
|
-
return
|
|
35922
|
+
getAbsolutePath = (path36, cwd) => {
|
|
35923
|
+
if (sp2.isAbsolute(path36)) {
|
|
35924
|
+
return path36;
|
|
35862
35925
|
}
|
|
35863
|
-
return sp2.join(cwd,
|
|
35926
|
+
return sp2.join(cwd, path36);
|
|
35864
35927
|
};
|
|
35865
35928
|
EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
|
|
35866
35929
|
DirEntry = class {
|
|
@@ -35925,10 +35988,10 @@ var init_chokidar = __esm({
|
|
|
35925
35988
|
dirParts;
|
|
35926
35989
|
followSymlinks;
|
|
35927
35990
|
statMethod;
|
|
35928
|
-
constructor(
|
|
35991
|
+
constructor(path36, follow, fsw) {
|
|
35929
35992
|
this.fsw = fsw;
|
|
35930
|
-
const watchPath =
|
|
35931
|
-
this.path =
|
|
35993
|
+
const watchPath = path36;
|
|
35994
|
+
this.path = path36 = path36.replace(REPLACER_RE, "");
|
|
35932
35995
|
this.watchPath = watchPath;
|
|
35933
35996
|
this.fullWatchPath = sp2.resolve(watchPath);
|
|
35934
35997
|
this.dirParts = [];
|
|
@@ -36068,20 +36131,20 @@ var init_chokidar = __esm({
|
|
|
36068
36131
|
this._closePromise = void 0;
|
|
36069
36132
|
let paths = unifyPaths(paths_);
|
|
36070
36133
|
if (cwd) {
|
|
36071
|
-
paths = paths.map((
|
|
36072
|
-
const absPath = getAbsolutePath(
|
|
36134
|
+
paths = paths.map((path36) => {
|
|
36135
|
+
const absPath = getAbsolutePath(path36, cwd);
|
|
36073
36136
|
return absPath;
|
|
36074
36137
|
});
|
|
36075
36138
|
}
|
|
36076
|
-
paths.forEach((
|
|
36077
|
-
this._removeIgnoredPath(
|
|
36139
|
+
paths.forEach((path36) => {
|
|
36140
|
+
this._removeIgnoredPath(path36);
|
|
36078
36141
|
});
|
|
36079
36142
|
this._userIgnored = void 0;
|
|
36080
36143
|
if (!this._readyCount)
|
|
36081
36144
|
this._readyCount = 0;
|
|
36082
36145
|
this._readyCount += paths.length;
|
|
36083
|
-
Promise.all(paths.map(async (
|
|
36084
|
-
const res = await this._nodeFsHandler._addToNodeFs(
|
|
36146
|
+
Promise.all(paths.map(async (path36) => {
|
|
36147
|
+
const res = await this._nodeFsHandler._addToNodeFs(path36, !_internal, void 0, 0, _origAdd);
|
|
36085
36148
|
if (res)
|
|
36086
36149
|
this._emitReady();
|
|
36087
36150
|
return res;
|
|
@@ -36103,17 +36166,17 @@ var init_chokidar = __esm({
|
|
|
36103
36166
|
return this;
|
|
36104
36167
|
const paths = unifyPaths(paths_);
|
|
36105
36168
|
const { cwd } = this.options;
|
|
36106
|
-
paths.forEach((
|
|
36107
|
-
if (!sp2.isAbsolute(
|
|
36169
|
+
paths.forEach((path36) => {
|
|
36170
|
+
if (!sp2.isAbsolute(path36) && !this._closers.has(path36)) {
|
|
36108
36171
|
if (cwd)
|
|
36109
|
-
|
|
36110
|
-
|
|
36172
|
+
path36 = sp2.join(cwd, path36);
|
|
36173
|
+
path36 = sp2.resolve(path36);
|
|
36111
36174
|
}
|
|
36112
|
-
this._closePath(
|
|
36113
|
-
this._addIgnoredPath(
|
|
36114
|
-
if (this._watched.has(
|
|
36175
|
+
this._closePath(path36);
|
|
36176
|
+
this._addIgnoredPath(path36);
|
|
36177
|
+
if (this._watched.has(path36)) {
|
|
36115
36178
|
this._addIgnoredPath({
|
|
36116
|
-
path:
|
|
36179
|
+
path: path36,
|
|
36117
36180
|
recursive: true
|
|
36118
36181
|
});
|
|
36119
36182
|
}
|
|
@@ -36177,38 +36240,38 @@ var init_chokidar = __esm({
|
|
|
36177
36240
|
* @param stats arguments to be passed with event
|
|
36178
36241
|
* @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
|
|
36179
36242
|
*/
|
|
36180
|
-
async _emit(event,
|
|
36243
|
+
async _emit(event, path36, stats) {
|
|
36181
36244
|
if (this.closed)
|
|
36182
36245
|
return;
|
|
36183
36246
|
const opts = this.options;
|
|
36184
36247
|
if (isWindows)
|
|
36185
|
-
|
|
36248
|
+
path36 = sp2.normalize(path36);
|
|
36186
36249
|
if (opts.cwd)
|
|
36187
|
-
|
|
36188
|
-
const args = [
|
|
36250
|
+
path36 = sp2.relative(opts.cwd, path36);
|
|
36251
|
+
const args = [path36];
|
|
36189
36252
|
if (stats != null)
|
|
36190
36253
|
args.push(stats);
|
|
36191
36254
|
const awf = opts.awaitWriteFinish;
|
|
36192
36255
|
let pw;
|
|
36193
|
-
if (awf && (pw = this._pendingWrites.get(
|
|
36256
|
+
if (awf && (pw = this._pendingWrites.get(path36))) {
|
|
36194
36257
|
pw.lastChange = /* @__PURE__ */ new Date();
|
|
36195
36258
|
return this;
|
|
36196
36259
|
}
|
|
36197
36260
|
if (opts.atomic) {
|
|
36198
36261
|
if (event === EVENTS.UNLINK) {
|
|
36199
|
-
this._pendingUnlinks.set(
|
|
36262
|
+
this._pendingUnlinks.set(path36, [event, ...args]);
|
|
36200
36263
|
setTimeout(() => {
|
|
36201
|
-
this._pendingUnlinks.forEach((entry,
|
|
36264
|
+
this._pendingUnlinks.forEach((entry, path37) => {
|
|
36202
36265
|
this.emit(...entry);
|
|
36203
36266
|
this.emit(EVENTS.ALL, ...entry);
|
|
36204
|
-
this._pendingUnlinks.delete(
|
|
36267
|
+
this._pendingUnlinks.delete(path37);
|
|
36205
36268
|
});
|
|
36206
36269
|
}, typeof opts.atomic === "number" ? opts.atomic : 100);
|
|
36207
36270
|
return this;
|
|
36208
36271
|
}
|
|
36209
|
-
if (event === EVENTS.ADD && this._pendingUnlinks.has(
|
|
36272
|
+
if (event === EVENTS.ADD && this._pendingUnlinks.has(path36)) {
|
|
36210
36273
|
event = EVENTS.CHANGE;
|
|
36211
|
-
this._pendingUnlinks.delete(
|
|
36274
|
+
this._pendingUnlinks.delete(path36);
|
|
36212
36275
|
}
|
|
36213
36276
|
}
|
|
36214
36277
|
if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
|
|
@@ -36226,16 +36289,16 @@ var init_chokidar = __esm({
|
|
|
36226
36289
|
this.emitWithAll(event, args);
|
|
36227
36290
|
}
|
|
36228
36291
|
};
|
|
36229
|
-
this._awaitWriteFinish(
|
|
36292
|
+
this._awaitWriteFinish(path36, awf.stabilityThreshold, event, awfEmit);
|
|
36230
36293
|
return this;
|
|
36231
36294
|
}
|
|
36232
36295
|
if (event === EVENTS.CHANGE) {
|
|
36233
|
-
const isThrottled = !this._throttle(EVENTS.CHANGE,
|
|
36296
|
+
const isThrottled = !this._throttle(EVENTS.CHANGE, path36, 50);
|
|
36234
36297
|
if (isThrottled)
|
|
36235
36298
|
return this;
|
|
36236
36299
|
}
|
|
36237
36300
|
if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
|
|
36238
|
-
const fullPath = opts.cwd ? sp2.join(opts.cwd,
|
|
36301
|
+
const fullPath = opts.cwd ? sp2.join(opts.cwd, path36) : path36;
|
|
36239
36302
|
let stats2;
|
|
36240
36303
|
try {
|
|
36241
36304
|
stats2 = await (0, import_promises3.stat)(fullPath);
|
|
@@ -36266,23 +36329,23 @@ var init_chokidar = __esm({
|
|
|
36266
36329
|
* @param timeout duration of time to suppress duplicate actions
|
|
36267
36330
|
* @returns tracking object or false if action should be suppressed
|
|
36268
36331
|
*/
|
|
36269
|
-
_throttle(actionType,
|
|
36332
|
+
_throttle(actionType, path36, timeout) {
|
|
36270
36333
|
if (!this._throttled.has(actionType)) {
|
|
36271
36334
|
this._throttled.set(actionType, /* @__PURE__ */ new Map());
|
|
36272
36335
|
}
|
|
36273
36336
|
const action = this._throttled.get(actionType);
|
|
36274
36337
|
if (!action)
|
|
36275
36338
|
throw new Error("invalid throttle");
|
|
36276
|
-
const actionPath = action.get(
|
|
36339
|
+
const actionPath = action.get(path36);
|
|
36277
36340
|
if (actionPath) {
|
|
36278
36341
|
actionPath.count++;
|
|
36279
36342
|
return false;
|
|
36280
36343
|
}
|
|
36281
36344
|
let timeoutObject;
|
|
36282
36345
|
const clear = () => {
|
|
36283
|
-
const item = action.get(
|
|
36346
|
+
const item = action.get(path36);
|
|
36284
36347
|
const count = item ? item.count : 0;
|
|
36285
|
-
action.delete(
|
|
36348
|
+
action.delete(path36);
|
|
36286
36349
|
clearTimeout(timeoutObject);
|
|
36287
36350
|
if (item)
|
|
36288
36351
|
clearTimeout(item.timeoutObject);
|
|
@@ -36290,7 +36353,7 @@ var init_chokidar = __esm({
|
|
|
36290
36353
|
};
|
|
36291
36354
|
timeoutObject = setTimeout(clear, timeout);
|
|
36292
36355
|
const thr = { timeoutObject, clear, count: 0 };
|
|
36293
|
-
action.set(
|
|
36356
|
+
action.set(path36, thr);
|
|
36294
36357
|
return thr;
|
|
36295
36358
|
}
|
|
36296
36359
|
_incrReadyCount() {
|
|
@@ -36304,44 +36367,44 @@ var init_chokidar = __esm({
|
|
|
36304
36367
|
* @param event
|
|
36305
36368
|
* @param awfEmit Callback to be called when ready for event to be emitted.
|
|
36306
36369
|
*/
|
|
36307
|
-
_awaitWriteFinish(
|
|
36370
|
+
_awaitWriteFinish(path36, threshold, event, awfEmit) {
|
|
36308
36371
|
const awf = this.options.awaitWriteFinish;
|
|
36309
36372
|
if (typeof awf !== "object")
|
|
36310
36373
|
return;
|
|
36311
36374
|
const pollInterval = awf.pollInterval;
|
|
36312
36375
|
let timeoutHandler;
|
|
36313
|
-
let fullPath =
|
|
36314
|
-
if (this.options.cwd && !sp2.isAbsolute(
|
|
36315
|
-
fullPath = sp2.join(this.options.cwd,
|
|
36376
|
+
let fullPath = path36;
|
|
36377
|
+
if (this.options.cwd && !sp2.isAbsolute(path36)) {
|
|
36378
|
+
fullPath = sp2.join(this.options.cwd, path36);
|
|
36316
36379
|
}
|
|
36317
36380
|
const now = /* @__PURE__ */ new Date();
|
|
36318
36381
|
const writes = this._pendingWrites;
|
|
36319
36382
|
function awaitWriteFinishFn(prevStat) {
|
|
36320
36383
|
(0, import_node_fs2.stat)(fullPath, (err, curStat) => {
|
|
36321
|
-
if (err || !writes.has(
|
|
36384
|
+
if (err || !writes.has(path36)) {
|
|
36322
36385
|
if (err && err.code !== "ENOENT")
|
|
36323
36386
|
awfEmit(err);
|
|
36324
36387
|
return;
|
|
36325
36388
|
}
|
|
36326
36389
|
const now2 = Number(/* @__PURE__ */ new Date());
|
|
36327
36390
|
if (prevStat && curStat.size !== prevStat.size) {
|
|
36328
|
-
writes.get(
|
|
36391
|
+
writes.get(path36).lastChange = now2;
|
|
36329
36392
|
}
|
|
36330
|
-
const pw = writes.get(
|
|
36393
|
+
const pw = writes.get(path36);
|
|
36331
36394
|
const df = now2 - pw.lastChange;
|
|
36332
36395
|
if (df >= threshold) {
|
|
36333
|
-
writes.delete(
|
|
36396
|
+
writes.delete(path36);
|
|
36334
36397
|
awfEmit(void 0, curStat);
|
|
36335
36398
|
} else {
|
|
36336
36399
|
timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
|
|
36337
36400
|
}
|
|
36338
36401
|
});
|
|
36339
36402
|
}
|
|
36340
|
-
if (!writes.has(
|
|
36341
|
-
writes.set(
|
|
36403
|
+
if (!writes.has(path36)) {
|
|
36404
|
+
writes.set(path36, {
|
|
36342
36405
|
lastChange: now,
|
|
36343
36406
|
cancelWait: () => {
|
|
36344
|
-
writes.delete(
|
|
36407
|
+
writes.delete(path36);
|
|
36345
36408
|
clearTimeout(timeoutHandler);
|
|
36346
36409
|
return event;
|
|
36347
36410
|
}
|
|
@@ -36352,8 +36415,8 @@ var init_chokidar = __esm({
|
|
|
36352
36415
|
/**
|
|
36353
36416
|
* Determines whether user has asked to ignore this path.
|
|
36354
36417
|
*/
|
|
36355
|
-
_isIgnored(
|
|
36356
|
-
if (this.options.atomic && DOT_RE.test(
|
|
36418
|
+
_isIgnored(path36, stats) {
|
|
36419
|
+
if (this.options.atomic && DOT_RE.test(path36))
|
|
36357
36420
|
return true;
|
|
36358
36421
|
if (!this._userIgnored) {
|
|
36359
36422
|
const { cwd } = this.options;
|
|
@@ -36363,17 +36426,17 @@ var init_chokidar = __esm({
|
|
|
36363
36426
|
const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
|
|
36364
36427
|
this._userIgnored = anymatch(list, void 0);
|
|
36365
36428
|
}
|
|
36366
|
-
return this._userIgnored(
|
|
36429
|
+
return this._userIgnored(path36, stats);
|
|
36367
36430
|
}
|
|
36368
|
-
_isntIgnored(
|
|
36369
|
-
return !this._isIgnored(
|
|
36431
|
+
_isntIgnored(path36, stat4) {
|
|
36432
|
+
return !this._isIgnored(path36, stat4);
|
|
36370
36433
|
}
|
|
36371
36434
|
/**
|
|
36372
36435
|
* Provides a set of common helpers and properties relating to symlink handling.
|
|
36373
36436
|
* @param path file or directory pattern being watched
|
|
36374
36437
|
*/
|
|
36375
|
-
_getWatchHelpers(
|
|
36376
|
-
return new WatchHelper(
|
|
36438
|
+
_getWatchHelpers(path36) {
|
|
36439
|
+
return new WatchHelper(path36, this.options.followSymlinks, this);
|
|
36377
36440
|
}
|
|
36378
36441
|
// Directory helpers
|
|
36379
36442
|
// -----------------
|
|
@@ -36405,63 +36468,63 @@ var init_chokidar = __esm({
|
|
|
36405
36468
|
* @param item base path of item/directory
|
|
36406
36469
|
*/
|
|
36407
36470
|
_remove(directory, item, isDirectory) {
|
|
36408
|
-
const
|
|
36409
|
-
const fullPath = sp2.resolve(
|
|
36410
|
-
isDirectory = isDirectory != null ? isDirectory : this._watched.has(
|
|
36411
|
-
if (!this._throttle("remove",
|
|
36471
|
+
const path36 = sp2.join(directory, item);
|
|
36472
|
+
const fullPath = sp2.resolve(path36);
|
|
36473
|
+
isDirectory = isDirectory != null ? isDirectory : this._watched.has(path36) || this._watched.has(fullPath);
|
|
36474
|
+
if (!this._throttle("remove", path36, 100))
|
|
36412
36475
|
return;
|
|
36413
36476
|
if (!isDirectory && this._watched.size === 1) {
|
|
36414
36477
|
this.add(directory, item, true);
|
|
36415
36478
|
}
|
|
36416
|
-
const wp = this._getWatchedDir(
|
|
36479
|
+
const wp = this._getWatchedDir(path36);
|
|
36417
36480
|
const nestedDirectoryChildren = wp.getChildren();
|
|
36418
|
-
nestedDirectoryChildren.forEach((nested) => this._remove(
|
|
36481
|
+
nestedDirectoryChildren.forEach((nested) => this._remove(path36, nested));
|
|
36419
36482
|
const parent = this._getWatchedDir(directory);
|
|
36420
36483
|
const wasTracked = parent.has(item);
|
|
36421
36484
|
parent.remove(item);
|
|
36422
36485
|
if (this._symlinkPaths.has(fullPath)) {
|
|
36423
36486
|
this._symlinkPaths.delete(fullPath);
|
|
36424
36487
|
}
|
|
36425
|
-
let relPath =
|
|
36488
|
+
let relPath = path36;
|
|
36426
36489
|
if (this.options.cwd)
|
|
36427
|
-
relPath = sp2.relative(this.options.cwd,
|
|
36490
|
+
relPath = sp2.relative(this.options.cwd, path36);
|
|
36428
36491
|
if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
|
|
36429
36492
|
const event = this._pendingWrites.get(relPath).cancelWait();
|
|
36430
36493
|
if (event === EVENTS.ADD)
|
|
36431
36494
|
return;
|
|
36432
36495
|
}
|
|
36433
|
-
this._watched.delete(
|
|
36496
|
+
this._watched.delete(path36);
|
|
36434
36497
|
this._watched.delete(fullPath);
|
|
36435
36498
|
const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
|
|
36436
|
-
if (wasTracked && !this._isIgnored(
|
|
36437
|
-
this._emit(eventName,
|
|
36438
|
-
this._closePath(
|
|
36499
|
+
if (wasTracked && !this._isIgnored(path36))
|
|
36500
|
+
this._emit(eventName, path36);
|
|
36501
|
+
this._closePath(path36);
|
|
36439
36502
|
}
|
|
36440
36503
|
/**
|
|
36441
36504
|
* Closes all watchers for a path
|
|
36442
36505
|
*/
|
|
36443
|
-
_closePath(
|
|
36444
|
-
this._closeFile(
|
|
36445
|
-
const dir = sp2.dirname(
|
|
36446
|
-
this._getWatchedDir(dir).remove(sp2.basename(
|
|
36506
|
+
_closePath(path36) {
|
|
36507
|
+
this._closeFile(path36);
|
|
36508
|
+
const dir = sp2.dirname(path36);
|
|
36509
|
+
this._getWatchedDir(dir).remove(sp2.basename(path36));
|
|
36447
36510
|
}
|
|
36448
36511
|
/**
|
|
36449
36512
|
* Closes only file-specific watchers
|
|
36450
36513
|
*/
|
|
36451
|
-
_closeFile(
|
|
36452
|
-
const closers = this._closers.get(
|
|
36514
|
+
_closeFile(path36) {
|
|
36515
|
+
const closers = this._closers.get(path36);
|
|
36453
36516
|
if (!closers)
|
|
36454
36517
|
return;
|
|
36455
36518
|
closers.forEach((closer) => closer());
|
|
36456
|
-
this._closers.delete(
|
|
36519
|
+
this._closers.delete(path36);
|
|
36457
36520
|
}
|
|
36458
|
-
_addPathCloser(
|
|
36521
|
+
_addPathCloser(path36, closer) {
|
|
36459
36522
|
if (!closer)
|
|
36460
36523
|
return;
|
|
36461
|
-
let list = this._closers.get(
|
|
36524
|
+
let list = this._closers.get(path36);
|
|
36462
36525
|
if (!list) {
|
|
36463
36526
|
list = [];
|
|
36464
|
-
this._closers.set(
|
|
36527
|
+
this._closers.set(path36, list);
|
|
36465
36528
|
}
|
|
36466
36529
|
list.push(closer);
|
|
36467
36530
|
}
|
|
@@ -36722,13 +36785,13 @@ var init_provider_schema = __esm({
|
|
|
36722
36785
|
});
|
|
36723
36786
|
|
|
36724
36787
|
// ../../oss/packages/daemon-core/src/providers/provider-loader.ts
|
|
36725
|
-
var
|
|
36788
|
+
var fs7, path15, os17, ProviderLoader;
|
|
36726
36789
|
var init_provider_loader = __esm({
|
|
36727
36790
|
"../../oss/packages/daemon-core/src/providers/provider-loader.ts"() {
|
|
36728
36791
|
"use strict";
|
|
36729
|
-
|
|
36730
|
-
|
|
36731
|
-
|
|
36792
|
+
fs7 = __toESM(require("fs"));
|
|
36793
|
+
path15 = __toESM(require("path"));
|
|
36794
|
+
os17 = __toESM(require("os"));
|
|
36732
36795
|
init_chokidar();
|
|
36733
36796
|
init_ide_detector();
|
|
36734
36797
|
init_logger();
|
|
@@ -36762,9 +36825,9 @@ var init_provider_loader = __esm({
|
|
|
36762
36825
|
static siblingStderrLogged = /* @__PURE__ */ new Set();
|
|
36763
36826
|
static looksLikeProviderRoot(candidate) {
|
|
36764
36827
|
try {
|
|
36765
|
-
if (!
|
|
36828
|
+
if (!fs7.existsSync(candidate) || !fs7.statSync(candidate).isDirectory()) return false;
|
|
36766
36829
|
return ["ide", "extension", "cli", "acp"].some(
|
|
36767
|
-
(category) =>
|
|
36830
|
+
(category) => fs7.existsSync(path15.join(candidate, category))
|
|
36768
36831
|
);
|
|
36769
36832
|
} catch {
|
|
36770
36833
|
return false;
|
|
@@ -36772,20 +36835,20 @@ var init_provider_loader = __esm({
|
|
|
36772
36835
|
}
|
|
36773
36836
|
static hasProviderRootMarker(candidate) {
|
|
36774
36837
|
try {
|
|
36775
|
-
return
|
|
36838
|
+
return fs7.existsSync(path15.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
|
|
36776
36839
|
} catch {
|
|
36777
36840
|
return false;
|
|
36778
36841
|
}
|
|
36779
36842
|
}
|
|
36780
36843
|
detectDefaultUserDir() {
|
|
36781
|
-
const fallback2 =
|
|
36844
|
+
const fallback2 = path15.join(os17.homedir(), ".adhdev", "providers");
|
|
36782
36845
|
const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
|
|
36783
36846
|
const visited = /* @__PURE__ */ new Set();
|
|
36784
36847
|
for (const start of this.probeStarts) {
|
|
36785
|
-
let current =
|
|
36848
|
+
let current = path15.resolve(start);
|
|
36786
36849
|
while (!visited.has(current)) {
|
|
36787
36850
|
visited.add(current);
|
|
36788
|
-
const siblingCandidate =
|
|
36851
|
+
const siblingCandidate = path15.join(path15.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
|
|
36789
36852
|
if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
|
|
36790
36853
|
const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
|
|
36791
36854
|
if (envOptIn || hasMarker) {
|
|
@@ -36807,7 +36870,7 @@ var init_provider_loader = __esm({
|
|
|
36807
36870
|
return { path: siblingCandidate, source };
|
|
36808
36871
|
}
|
|
36809
36872
|
}
|
|
36810
|
-
const parent =
|
|
36873
|
+
const parent = path15.dirname(current);
|
|
36811
36874
|
if (parent === current) break;
|
|
36812
36875
|
current = parent;
|
|
36813
36876
|
}
|
|
@@ -36817,11 +36880,11 @@ var init_provider_loader = __esm({
|
|
|
36817
36880
|
constructor(options) {
|
|
36818
36881
|
this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
|
|
36819
36882
|
this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
|
|
36820
|
-
this.defaultProvidersDir =
|
|
36883
|
+
this.defaultProvidersDir = path15.join(os17.homedir(), ".adhdev", "providers");
|
|
36821
36884
|
const detected = this.detectDefaultUserDir();
|
|
36822
36885
|
this.userDir = detected.path;
|
|
36823
36886
|
this.userDirSource = detected.source;
|
|
36824
|
-
this.upstreamDir =
|
|
36887
|
+
this.upstreamDir = path15.join(this.defaultProvidersDir, ".upstream");
|
|
36825
36888
|
this.disableUpstream = false;
|
|
36826
36889
|
this.applySourceConfig({
|
|
36827
36890
|
userDir: options?.userDir,
|
|
@@ -36880,7 +36943,7 @@ var init_provider_loader = __esm({
|
|
|
36880
36943
|
this.userDir = detected.path;
|
|
36881
36944
|
this.userDirSource = detected.source;
|
|
36882
36945
|
}
|
|
36883
|
-
this.upstreamDir =
|
|
36946
|
+
this.upstreamDir = path15.join(this.defaultProvidersDir, ".upstream");
|
|
36884
36947
|
this.disableUpstream = this.sourceMode === "no-upstream";
|
|
36885
36948
|
if (this.explicitProviderDir) {
|
|
36886
36949
|
this.log(`Config 'providerDir' applied: ${this.userDir}`);
|
|
@@ -36894,7 +36957,7 @@ var init_provider_loader = __esm({
|
|
|
36894
36957
|
* Canonical provider directory shape for a given root.
|
|
36895
36958
|
*/
|
|
36896
36959
|
getProviderDir(root, category, type) {
|
|
36897
|
-
return
|
|
36960
|
+
return path15.join(root, category, type);
|
|
36898
36961
|
}
|
|
36899
36962
|
/**
|
|
36900
36963
|
* Canonical user override directory for a provider.
|
|
@@ -36921,7 +36984,7 @@ var init_provider_loader = __esm({
|
|
|
36921
36984
|
resolveProviderFile(type, ...segments) {
|
|
36922
36985
|
const dir = this.findProviderDirInternal(type);
|
|
36923
36986
|
if (!dir) return null;
|
|
36924
|
-
return
|
|
36987
|
+
return path15.join(dir, ...segments);
|
|
36925
36988
|
}
|
|
36926
36989
|
/**
|
|
36927
36990
|
* Load all providers (3-tier priority)
|
|
@@ -36934,7 +36997,7 @@ var init_provider_loader = __esm({
|
|
|
36934
36997
|
this.providers.clear();
|
|
36935
36998
|
this.providerAvailability.clear();
|
|
36936
36999
|
let upstreamCount = 0;
|
|
36937
|
-
if (!this.disableUpstream &&
|
|
37000
|
+
if (!this.disableUpstream && fs7.existsSync(this.upstreamDir)) {
|
|
36938
37001
|
upstreamCount = this.loadDir(this.upstreamDir);
|
|
36939
37002
|
if (upstreamCount > 0) {
|
|
36940
37003
|
this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
|
|
@@ -36942,7 +37005,7 @@ var init_provider_loader = __esm({
|
|
|
36942
37005
|
} else if (this.disableUpstream) {
|
|
36943
37006
|
this.log("Upstream loading disabled (sourceMode=no-upstream)");
|
|
36944
37007
|
}
|
|
36945
|
-
if (
|
|
37008
|
+
if (fs7.existsSync(this.userDir)) {
|
|
36946
37009
|
const userCount = this.loadDir(this.userDir, [".upstream"]);
|
|
36947
37010
|
if (userCount > 0) {
|
|
36948
37011
|
this.log(`Loaded ${userCount} user custom providers (never auto-updated)`);
|
|
@@ -36957,10 +37020,10 @@ var init_provider_loader = __esm({
|
|
|
36957
37020
|
* Check if upstream directory exists and has providers.
|
|
36958
37021
|
*/
|
|
36959
37022
|
hasUpstream() {
|
|
36960
|
-
if (!
|
|
37023
|
+
if (!fs7.existsSync(this.upstreamDir)) return false;
|
|
36961
37024
|
try {
|
|
36962
|
-
return
|
|
36963
|
-
(d) =>
|
|
37025
|
+
return fs7.readdirSync(this.upstreamDir).some(
|
|
37026
|
+
(d) => fs7.statSync(path15.join(this.upstreamDir, d)).isDirectory()
|
|
36964
37027
|
);
|
|
36965
37028
|
} catch {
|
|
36966
37029
|
return false;
|
|
@@ -37457,8 +37520,8 @@ var init_provider_loader = __esm({
|
|
|
37457
37520
|
resolved._resolvedScriptDir = entry.scriptDir;
|
|
37458
37521
|
resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
|
|
37459
37522
|
if (providerDir) {
|
|
37460
|
-
const fullDir =
|
|
37461
|
-
resolved._resolvedScriptsPath =
|
|
37523
|
+
const fullDir = path15.join(providerDir, entry.scriptDir);
|
|
37524
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path15.join(fullDir, "scripts.js")) ? path15.join(fullDir, "scripts.js") : fullDir;
|
|
37462
37525
|
}
|
|
37463
37526
|
matched = true;
|
|
37464
37527
|
}
|
|
@@ -37473,8 +37536,8 @@ var init_provider_loader = __esm({
|
|
|
37473
37536
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
37474
37537
|
resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
|
|
37475
37538
|
if (providerDir) {
|
|
37476
|
-
const fullDir =
|
|
37477
|
-
resolved._resolvedScriptsPath =
|
|
37539
|
+
const fullDir = path15.join(providerDir, base.defaultScriptDir);
|
|
37540
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path15.join(fullDir, "scripts.js")) ? path15.join(fullDir, "scripts.js") : fullDir;
|
|
37478
37541
|
}
|
|
37479
37542
|
}
|
|
37480
37543
|
resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
|
|
@@ -37491,8 +37554,8 @@ var init_provider_loader = __esm({
|
|
|
37491
37554
|
resolved._resolvedScriptDir = dirOverride;
|
|
37492
37555
|
resolved._resolvedScriptsSource = `versions:${range}`;
|
|
37493
37556
|
if (providerDir) {
|
|
37494
|
-
const fullDir =
|
|
37495
|
-
resolved._resolvedScriptsPath =
|
|
37557
|
+
const fullDir = path15.join(providerDir, dirOverride);
|
|
37558
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path15.join(fullDir, "scripts.js")) ? path15.join(fullDir, "scripts.js") : fullDir;
|
|
37496
37559
|
}
|
|
37497
37560
|
}
|
|
37498
37561
|
} else if (override.scripts) {
|
|
@@ -37508,8 +37571,8 @@ var init_provider_loader = __esm({
|
|
|
37508
37571
|
resolved._resolvedScriptDir = base.defaultScriptDir;
|
|
37509
37572
|
resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
|
|
37510
37573
|
if (providerDir) {
|
|
37511
|
-
const fullDir =
|
|
37512
|
-
resolved._resolvedScriptsPath =
|
|
37574
|
+
const fullDir = path15.join(providerDir, base.defaultScriptDir);
|
|
37575
|
+
resolved._resolvedScriptsPath = fs7.existsSync(path15.join(fullDir, "scripts.js")) ? path15.join(fullDir, "scripts.js") : fullDir;
|
|
37513
37576
|
}
|
|
37514
37577
|
}
|
|
37515
37578
|
}
|
|
@@ -37541,15 +37604,15 @@ var init_provider_loader = __esm({
|
|
|
37541
37604
|
this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
|
|
37542
37605
|
return null;
|
|
37543
37606
|
}
|
|
37544
|
-
const dir =
|
|
37545
|
-
if (!
|
|
37607
|
+
const dir = path15.join(providerDir, scriptDir);
|
|
37608
|
+
if (!fs7.existsSync(dir)) {
|
|
37546
37609
|
this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
|
|
37547
37610
|
return null;
|
|
37548
37611
|
}
|
|
37549
37612
|
const cached2 = this.scriptsCache.get(dir);
|
|
37550
37613
|
if (cached2) return cached2;
|
|
37551
|
-
const scriptsJs =
|
|
37552
|
-
if (
|
|
37614
|
+
const scriptsJs = path15.join(dir, "scripts.js");
|
|
37615
|
+
if (fs7.existsSync(scriptsJs)) {
|
|
37553
37616
|
try {
|
|
37554
37617
|
delete require.cache[require.resolve(scriptsJs)];
|
|
37555
37618
|
const loaded = require(scriptsJs);
|
|
@@ -37570,9 +37633,9 @@ var init_provider_loader = __esm({
|
|
|
37570
37633
|
watch() {
|
|
37571
37634
|
this.stopWatch();
|
|
37572
37635
|
const watchDir = (dir) => {
|
|
37573
|
-
if (!
|
|
37636
|
+
if (!fs7.existsSync(dir)) {
|
|
37574
37637
|
try {
|
|
37575
|
-
|
|
37638
|
+
fs7.mkdirSync(dir, { recursive: true });
|
|
37576
37639
|
} catch {
|
|
37577
37640
|
return;
|
|
37578
37641
|
}
|
|
@@ -37590,7 +37653,7 @@ var init_provider_loader = __esm({
|
|
|
37590
37653
|
return;
|
|
37591
37654
|
}
|
|
37592
37655
|
if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
|
|
37593
|
-
this.log(`File changed: ${
|
|
37656
|
+
this.log(`File changed: ${path15.basename(filePath)}, reloading...`);
|
|
37594
37657
|
this.reload();
|
|
37595
37658
|
}
|
|
37596
37659
|
};
|
|
@@ -37645,12 +37708,12 @@ var init_provider_loader = __esm({
|
|
|
37645
37708
|
}
|
|
37646
37709
|
const https = require("https");
|
|
37647
37710
|
const { execSync: execSync8 } = require("child_process");
|
|
37648
|
-
const metaPath =
|
|
37711
|
+
const metaPath = path15.join(this.upstreamDir, _ProviderLoader.META_FILE);
|
|
37649
37712
|
let prevEtag = "";
|
|
37650
37713
|
let prevTimestamp = 0;
|
|
37651
37714
|
try {
|
|
37652
|
-
if (
|
|
37653
|
-
const meta3 = JSON.parse(
|
|
37715
|
+
if (fs7.existsSync(metaPath)) {
|
|
37716
|
+
const meta3 = JSON.parse(fs7.readFileSync(metaPath, "utf-8"));
|
|
37654
37717
|
prevEtag = meta3.etag || "";
|
|
37655
37718
|
prevTimestamp = meta3.timestamp || 0;
|
|
37656
37719
|
}
|
|
@@ -37705,39 +37768,39 @@ var init_provider_loader = __esm({
|
|
|
37705
37768
|
return { updated: false };
|
|
37706
37769
|
}
|
|
37707
37770
|
this.log("Downloading latest providers from GitHub...");
|
|
37708
|
-
const tmpTar =
|
|
37709
|
-
const tmpExtract =
|
|
37771
|
+
const tmpTar = path15.join(os17.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
|
|
37772
|
+
const tmpExtract = path15.join(os17.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
|
|
37710
37773
|
await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
|
|
37711
|
-
|
|
37774
|
+
fs7.mkdirSync(tmpExtract, { recursive: true });
|
|
37712
37775
|
execSync8(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
|
|
37713
|
-
const extracted =
|
|
37776
|
+
const extracted = fs7.readdirSync(tmpExtract);
|
|
37714
37777
|
const rootDir = extracted.find(
|
|
37715
|
-
(d) =>
|
|
37778
|
+
(d) => fs7.statSync(path15.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
|
|
37716
37779
|
);
|
|
37717
37780
|
if (!rootDir) throw new Error("Unexpected tarball structure");
|
|
37718
|
-
const sourceDir =
|
|
37781
|
+
const sourceDir = path15.join(tmpExtract, rootDir);
|
|
37719
37782
|
const backupDir = this.upstreamDir + ".bak";
|
|
37720
|
-
if (
|
|
37721
|
-
if (
|
|
37722
|
-
|
|
37783
|
+
if (fs7.existsSync(this.upstreamDir)) {
|
|
37784
|
+
if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
|
|
37785
|
+
fs7.renameSync(this.upstreamDir, backupDir);
|
|
37723
37786
|
}
|
|
37724
37787
|
try {
|
|
37725
37788
|
this.copyDirRecursive(sourceDir, this.upstreamDir);
|
|
37726
37789
|
this.writeMeta(metaPath, etag || `ts-${Date.now()}`, Date.now());
|
|
37727
|
-
if (
|
|
37790
|
+
if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
|
|
37728
37791
|
} catch (e) {
|
|
37729
|
-
if (
|
|
37730
|
-
if (
|
|
37731
|
-
|
|
37792
|
+
if (fs7.existsSync(backupDir)) {
|
|
37793
|
+
if (fs7.existsSync(this.upstreamDir)) fs7.rmSync(this.upstreamDir, { recursive: true, force: true });
|
|
37794
|
+
fs7.renameSync(backupDir, this.upstreamDir);
|
|
37732
37795
|
}
|
|
37733
37796
|
throw e;
|
|
37734
37797
|
}
|
|
37735
37798
|
try {
|
|
37736
|
-
|
|
37799
|
+
fs7.rmSync(tmpTar, { force: true });
|
|
37737
37800
|
} catch {
|
|
37738
37801
|
}
|
|
37739
37802
|
try {
|
|
37740
|
-
|
|
37803
|
+
fs7.rmSync(tmpExtract, { recursive: true, force: true });
|
|
37741
37804
|
} catch {
|
|
37742
37805
|
}
|
|
37743
37806
|
const upstreamCount = this.countProviders(this.upstreamDir);
|
|
@@ -37769,7 +37832,7 @@ var init_provider_loader = __esm({
|
|
|
37769
37832
|
reject(new Error(`HTTP ${res.statusCode}`));
|
|
37770
37833
|
return;
|
|
37771
37834
|
}
|
|
37772
|
-
const ws =
|
|
37835
|
+
const ws = fs7.createWriteStream(destPath);
|
|
37773
37836
|
res.pipe(ws);
|
|
37774
37837
|
ws.on("finish", () => {
|
|
37775
37838
|
ws.close();
|
|
@@ -37788,22 +37851,22 @@ var init_provider_loader = __esm({
|
|
|
37788
37851
|
}
|
|
37789
37852
|
/** Recursive directory copy */
|
|
37790
37853
|
copyDirRecursive(src, dest) {
|
|
37791
|
-
|
|
37792
|
-
for (const entry of
|
|
37793
|
-
const srcPath =
|
|
37794
|
-
const destPath =
|
|
37854
|
+
fs7.mkdirSync(dest, { recursive: true });
|
|
37855
|
+
for (const entry of fs7.readdirSync(src, { withFileTypes: true })) {
|
|
37856
|
+
const srcPath = path15.join(src, entry.name);
|
|
37857
|
+
const destPath = path15.join(dest, entry.name);
|
|
37795
37858
|
if (entry.isDirectory()) {
|
|
37796
37859
|
this.copyDirRecursive(srcPath, destPath);
|
|
37797
37860
|
} else {
|
|
37798
|
-
|
|
37861
|
+
fs7.copyFileSync(srcPath, destPath);
|
|
37799
37862
|
}
|
|
37800
37863
|
}
|
|
37801
37864
|
}
|
|
37802
37865
|
/** .meta.json save */
|
|
37803
37866
|
writeMeta(metaPath, etag, timestamp) {
|
|
37804
37867
|
try {
|
|
37805
|
-
|
|
37806
|
-
|
|
37868
|
+
fs7.mkdirSync(path15.dirname(metaPath), { recursive: true });
|
|
37869
|
+
fs7.writeFileSync(metaPath, JSON.stringify({
|
|
37807
37870
|
etag,
|
|
37808
37871
|
timestamp,
|
|
37809
37872
|
lastCheck: new Date(timestamp).toISOString(),
|
|
@@ -37814,12 +37877,12 @@ var init_provider_loader = __esm({
|
|
|
37814
37877
|
}
|
|
37815
37878
|
/** Count provider files (provider.js or provider.json) */
|
|
37816
37879
|
countProviders(dir) {
|
|
37817
|
-
if (!
|
|
37880
|
+
if (!fs7.existsSync(dir)) return 0;
|
|
37818
37881
|
let count = 0;
|
|
37819
37882
|
const scan = (d) => {
|
|
37820
37883
|
try {
|
|
37821
|
-
for (const entry of
|
|
37822
|
-
if (entry.isDirectory()) scan(
|
|
37884
|
+
for (const entry of fs7.readdirSync(d, { withFileTypes: true })) {
|
|
37885
|
+
if (entry.isDirectory()) scan(path15.join(d, entry.name));
|
|
37823
37886
|
else if (entry.name === "provider.json") count++;
|
|
37824
37887
|
}
|
|
37825
37888
|
} catch {
|
|
@@ -38045,19 +38108,19 @@ var init_provider_loader = __esm({
|
|
|
38045
38108
|
const cat = provider.category;
|
|
38046
38109
|
const searchRoots = this.getProviderRoots();
|
|
38047
38110
|
for (const root of searchRoots) {
|
|
38048
|
-
if (!
|
|
38111
|
+
if (!fs7.existsSync(root)) continue;
|
|
38049
38112
|
const candidate = this.getProviderDir(root, cat, type);
|
|
38050
|
-
if (
|
|
38051
|
-
const catDir =
|
|
38052
|
-
if (
|
|
38113
|
+
if (fs7.existsSync(path15.join(candidate, "provider.json"))) return candidate;
|
|
38114
|
+
const catDir = path15.join(root, cat);
|
|
38115
|
+
if (fs7.existsSync(catDir)) {
|
|
38053
38116
|
try {
|
|
38054
|
-
for (const entry of
|
|
38117
|
+
for (const entry of fs7.readdirSync(catDir, { withFileTypes: true })) {
|
|
38055
38118
|
if (!entry.isDirectory()) continue;
|
|
38056
|
-
const jsonPath =
|
|
38057
|
-
if (
|
|
38119
|
+
const jsonPath = path15.join(catDir, entry.name, "provider.json");
|
|
38120
|
+
if (fs7.existsSync(jsonPath)) {
|
|
38058
38121
|
try {
|
|
38059
|
-
const data = JSON.parse(
|
|
38060
|
-
if (data.type === type) return
|
|
38122
|
+
const data = JSON.parse(fs7.readFileSync(jsonPath, "utf-8"));
|
|
38123
|
+
if (data.type === type) return path15.join(catDir, entry.name);
|
|
38061
38124
|
} catch {
|
|
38062
38125
|
}
|
|
38063
38126
|
}
|
|
@@ -38074,8 +38137,8 @@ var init_provider_loader = __esm({
|
|
|
38074
38137
|
* (template substitution is NOT applied here — scripts.js handles that)
|
|
38075
38138
|
*/
|
|
38076
38139
|
buildScriptWrappersFromDir(dir) {
|
|
38077
|
-
const scriptsJs =
|
|
38078
|
-
if (
|
|
38140
|
+
const scriptsJs = path15.join(dir, "scripts.js");
|
|
38141
|
+
if (fs7.existsSync(scriptsJs)) {
|
|
38079
38142
|
try {
|
|
38080
38143
|
delete require.cache[require.resolve(scriptsJs)];
|
|
38081
38144
|
return require(scriptsJs);
|
|
@@ -38085,13 +38148,13 @@ var init_provider_loader = __esm({
|
|
|
38085
38148
|
const toCamel = (name) => name.replace(/_([a-z])/g, (_2, c) => c.toUpperCase());
|
|
38086
38149
|
const result = {};
|
|
38087
38150
|
try {
|
|
38088
|
-
for (const file2 of
|
|
38151
|
+
for (const file2 of fs7.readdirSync(dir)) {
|
|
38089
38152
|
if (!file2.endsWith(".js")) continue;
|
|
38090
38153
|
const scriptName = toCamel(file2.replace(".js", ""));
|
|
38091
|
-
const filePath =
|
|
38154
|
+
const filePath = path15.join(dir, file2);
|
|
38092
38155
|
result[scriptName] = (...args) => {
|
|
38093
38156
|
try {
|
|
38094
|
-
let content =
|
|
38157
|
+
let content = fs7.readFileSync(filePath, "utf-8");
|
|
38095
38158
|
if (args[0] && typeof args[0] === "object") {
|
|
38096
38159
|
for (const [key, val] of Object.entries(args[0])) {
|
|
38097
38160
|
let v = val;
|
|
@@ -38137,20 +38200,20 @@ var init_provider_loader = __esm({
|
|
|
38137
38200
|
* Structure: dir/category/agent-name/provider.{json,js}
|
|
38138
38201
|
*/
|
|
38139
38202
|
loadDir(dir, excludeDirs) {
|
|
38140
|
-
if (!
|
|
38203
|
+
if (!fs7.existsSync(dir)) return 0;
|
|
38141
38204
|
let count = 0;
|
|
38142
38205
|
const scan = (d) => {
|
|
38143
38206
|
let entries;
|
|
38144
38207
|
try {
|
|
38145
|
-
entries =
|
|
38208
|
+
entries = fs7.readdirSync(d, { withFileTypes: true });
|
|
38146
38209
|
} catch {
|
|
38147
38210
|
return;
|
|
38148
38211
|
}
|
|
38149
38212
|
const hasJson = entries.some((e) => e.name === "provider.json");
|
|
38150
38213
|
if (hasJson) {
|
|
38151
|
-
const jsonPath =
|
|
38214
|
+
const jsonPath = path15.join(d, "provider.json");
|
|
38152
38215
|
try {
|
|
38153
|
-
const raw =
|
|
38216
|
+
const raw = fs7.readFileSync(jsonPath, "utf-8");
|
|
38154
38217
|
const mod = JSON.parse(raw);
|
|
38155
38218
|
if (typeof mod.extensionIdPattern === "string") {
|
|
38156
38219
|
const flags = mod.extensionIdPattern_flags || "";
|
|
@@ -38169,8 +38232,8 @@ var init_provider_loader = __esm({
|
|
|
38169
38232
|
this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
|
|
38170
38233
|
} else {
|
|
38171
38234
|
const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
|
|
38172
|
-
const scriptsPath =
|
|
38173
|
-
if (!hasCompatibility &&
|
|
38235
|
+
const scriptsPath = path15.join(d, "scripts.js");
|
|
38236
|
+
if (!hasCompatibility && fs7.existsSync(scriptsPath)) {
|
|
38174
38237
|
try {
|
|
38175
38238
|
delete require.cache[require.resolve(scriptsPath)];
|
|
38176
38239
|
const scripts = require(scriptsPath);
|
|
@@ -38195,7 +38258,7 @@ var init_provider_loader = __esm({
|
|
|
38195
38258
|
if (!entry.isDirectory()) continue;
|
|
38196
38259
|
if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
|
|
38197
38260
|
if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
|
|
38198
|
-
scan(
|
|
38261
|
+
scan(path15.join(d, entry.name));
|
|
38199
38262
|
}
|
|
38200
38263
|
}
|
|
38201
38264
|
};
|
|
@@ -38391,7 +38454,7 @@ async function isCdpActive(port) {
|
|
|
38391
38454
|
});
|
|
38392
38455
|
}
|
|
38393
38456
|
async function killIdeProcess(ideId) {
|
|
38394
|
-
const plat =
|
|
38457
|
+
const plat = os18.platform();
|
|
38395
38458
|
const appName = getMacAppIdentifiers()[ideId];
|
|
38396
38459
|
const winProcesses = getWinProcessNames()[ideId];
|
|
38397
38460
|
try {
|
|
@@ -38452,7 +38515,7 @@ async function killIdeProcess(ideId) {
|
|
|
38452
38515
|
}
|
|
38453
38516
|
}
|
|
38454
38517
|
function isIdeRunning(ideId) {
|
|
38455
|
-
const plat =
|
|
38518
|
+
const plat = os18.platform();
|
|
38456
38519
|
try {
|
|
38457
38520
|
if (plat === "darwin") {
|
|
38458
38521
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -38507,7 +38570,7 @@ function isIdeRunning(ideId) {
|
|
|
38507
38570
|
}
|
|
38508
38571
|
}
|
|
38509
38572
|
function detectCurrentWorkspace(ideId) {
|
|
38510
|
-
const plat =
|
|
38573
|
+
const plat = os18.platform();
|
|
38511
38574
|
if (plat === "darwin") {
|
|
38512
38575
|
try {
|
|
38513
38576
|
const appName = getMacAppIdentifiers()[ideId];
|
|
@@ -38522,17 +38585,17 @@ function detectCurrentWorkspace(ideId) {
|
|
|
38522
38585
|
}
|
|
38523
38586
|
} else if (plat === "win32") {
|
|
38524
38587
|
try {
|
|
38525
|
-
const
|
|
38588
|
+
const fs23 = require("fs");
|
|
38526
38589
|
const appNameMap = getMacAppIdentifiers();
|
|
38527
38590
|
const appName = appNameMap[ideId];
|
|
38528
38591
|
if (appName) {
|
|
38529
|
-
const storagePath =
|
|
38530
|
-
process.env.APPDATA ||
|
|
38592
|
+
const storagePath = path16.join(
|
|
38593
|
+
process.env.APPDATA || path16.join(os18.homedir(), "AppData", "Roaming"),
|
|
38531
38594
|
appName,
|
|
38532
38595
|
"storage.json"
|
|
38533
38596
|
);
|
|
38534
|
-
if (
|
|
38535
|
-
const data = JSON.parse(
|
|
38597
|
+
if (fs23.existsSync(storagePath)) {
|
|
38598
|
+
const data = JSON.parse(fs23.readFileSync(storagePath, "utf-8"));
|
|
38536
38599
|
const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
|
|
38537
38600
|
if (workspaces.length > 0) {
|
|
38538
38601
|
const recent = workspaces[0];
|
|
@@ -38549,7 +38612,7 @@ function detectCurrentWorkspace(ideId) {
|
|
|
38549
38612
|
return void 0;
|
|
38550
38613
|
}
|
|
38551
38614
|
async function launchWithCdp(options = {}) {
|
|
38552
|
-
const platform12 =
|
|
38615
|
+
const platform12 = os18.platform();
|
|
38553
38616
|
let targetIde;
|
|
38554
38617
|
const ides = await detectIDEs(getProviderLoader());
|
|
38555
38618
|
if (options.ideId) {
|
|
@@ -38698,14 +38761,14 @@ async function launchLinux(ide, port, workspace, newWindow) {
|
|
|
38698
38761
|
function getAvailableIdeIds() {
|
|
38699
38762
|
return getProviderLoader().getAvailableIdeTypes();
|
|
38700
38763
|
}
|
|
38701
|
-
var import_child_process7, net2,
|
|
38764
|
+
var import_child_process7, net2, os18, path16, _providerLoader;
|
|
38702
38765
|
var init_launch = __esm({
|
|
38703
38766
|
"../../oss/packages/daemon-core/src/launch.ts"() {
|
|
38704
38767
|
"use strict";
|
|
38705
38768
|
import_child_process7 = require("child_process");
|
|
38706
38769
|
net2 = __toESM(require("net"));
|
|
38707
|
-
|
|
38708
|
-
|
|
38770
|
+
os18 = __toESM(require("os"));
|
|
38771
|
+
path16 = __toESM(require("path"));
|
|
38709
38772
|
init_ide_detector();
|
|
38710
38773
|
init_provider_loader();
|
|
38711
38774
|
init_macos_app_process();
|
|
@@ -38737,13 +38800,13 @@ function checkRotation() {
|
|
|
38737
38800
|
const today = getDateStr2();
|
|
38738
38801
|
if (today !== currentDate2) {
|
|
38739
38802
|
currentDate2 = today;
|
|
38740
|
-
currentFile =
|
|
38803
|
+
currentFile = path17.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
38741
38804
|
cleanOldFiles();
|
|
38742
38805
|
}
|
|
38743
38806
|
}
|
|
38744
38807
|
function cleanOldFiles() {
|
|
38745
38808
|
try {
|
|
38746
|
-
const files =
|
|
38809
|
+
const files = fs8.readdirSync(LOG_DIR2).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
|
|
38747
38810
|
const cutoff = /* @__PURE__ */ new Date();
|
|
38748
38811
|
cutoff.setDate(cutoff.getDate() - MAX_DAYS);
|
|
38749
38812
|
const cutoffStr = cutoff.toISOString().slice(0, 10);
|
|
@@ -38751,7 +38814,7 @@ function cleanOldFiles() {
|
|
|
38751
38814
|
const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
|
|
38752
38815
|
if (dateMatch && dateMatch[1] < cutoffStr) {
|
|
38753
38816
|
try {
|
|
38754
|
-
|
|
38817
|
+
fs8.unlinkSync(path17.join(LOG_DIR2, file2));
|
|
38755
38818
|
} catch {
|
|
38756
38819
|
}
|
|
38757
38820
|
}
|
|
@@ -38761,14 +38824,14 @@ function cleanOldFiles() {
|
|
|
38761
38824
|
}
|
|
38762
38825
|
function checkSize() {
|
|
38763
38826
|
try {
|
|
38764
|
-
const stat4 =
|
|
38827
|
+
const stat4 = fs8.statSync(currentFile);
|
|
38765
38828
|
if (stat4.size > MAX_FILE_SIZE) {
|
|
38766
38829
|
const backup = currentFile.replace(".jsonl", ".1.jsonl");
|
|
38767
38830
|
try {
|
|
38768
|
-
|
|
38831
|
+
fs8.unlinkSync(backup);
|
|
38769
38832
|
} catch {
|
|
38770
38833
|
}
|
|
38771
|
-
|
|
38834
|
+
fs8.renameSync(currentFile, backup);
|
|
38772
38835
|
}
|
|
38773
38836
|
} catch {
|
|
38774
38837
|
}
|
|
@@ -38793,14 +38856,14 @@ function logCommand(entry) {
|
|
|
38793
38856
|
...entry.error ? { err: entry.error } : {},
|
|
38794
38857
|
...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
|
|
38795
38858
|
});
|
|
38796
|
-
|
|
38859
|
+
fs8.appendFileSync(currentFile, line + "\n");
|
|
38797
38860
|
} catch {
|
|
38798
38861
|
}
|
|
38799
38862
|
}
|
|
38800
38863
|
function getRecentCommands(count = 50) {
|
|
38801
38864
|
try {
|
|
38802
|
-
if (!
|
|
38803
|
-
const content =
|
|
38865
|
+
if (!fs8.existsSync(currentFile)) return [];
|
|
38866
|
+
const content = fs8.readFileSync(currentFile, "utf-8");
|
|
38804
38867
|
const lines = content.trim().split("\n").filter(Boolean);
|
|
38805
38868
|
return lines.slice(-count).map((line) => {
|
|
38806
38869
|
try {
|
|
@@ -38823,18 +38886,18 @@ function getRecentCommands(count = 50) {
|
|
|
38823
38886
|
return [];
|
|
38824
38887
|
}
|
|
38825
38888
|
}
|
|
38826
|
-
var
|
|
38889
|
+
var fs8, path17, os19, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
|
|
38827
38890
|
var init_command_log = __esm({
|
|
38828
38891
|
"../../oss/packages/daemon-core/src/logging/command-log.ts"() {
|
|
38829
38892
|
"use strict";
|
|
38830
|
-
|
|
38831
|
-
|
|
38832
|
-
|
|
38833
|
-
LOG_DIR2 = process.platform === "win32" ?
|
|
38893
|
+
fs8 = __toESM(require("fs"));
|
|
38894
|
+
path17 = __toESM(require("path"));
|
|
38895
|
+
os19 = __toESM(require("os"));
|
|
38896
|
+
LOG_DIR2 = process.platform === "win32" ? path17.join(process.env.LOCALAPPDATA || process.env.APPDATA || path17.join(os19.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path17.join(os19.homedir(), "Library", "Logs", "adhdev") : path17.join(os19.homedir(), ".local", "share", "adhdev", "logs");
|
|
38834
38897
|
MAX_FILE_SIZE = 5 * 1024 * 1024;
|
|
38835
38898
|
MAX_DAYS = 7;
|
|
38836
38899
|
try {
|
|
38837
|
-
|
|
38900
|
+
fs8.mkdirSync(LOG_DIR2, { recursive: true });
|
|
38838
38901
|
} catch {
|
|
38839
38902
|
}
|
|
38840
38903
|
SENSITIVE_KEYS = /* @__PURE__ */ new Set([
|
|
@@ -38849,7 +38912,7 @@ var init_command_log = __esm({
|
|
|
38849
38912
|
"text"
|
|
38850
38913
|
]);
|
|
38851
38914
|
currentDate2 = getDateStr2();
|
|
38852
|
-
currentFile =
|
|
38915
|
+
currentFile = path17.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
|
|
38853
38916
|
writeCount2 = 0;
|
|
38854
38917
|
SKIP_COMMANDS = /* @__PURE__ */ new Set([
|
|
38855
38918
|
"heartbeat",
|
|
@@ -38913,8 +38976,8 @@ function buildAvailableProviders(providerLoader) {
|
|
|
38913
38976
|
}
|
|
38914
38977
|
function buildMachineInfo(profile = "full") {
|
|
38915
38978
|
const base = {
|
|
38916
|
-
hostname:
|
|
38917
|
-
platform:
|
|
38979
|
+
hostname: os20.hostname(),
|
|
38980
|
+
platform: os20.platform()
|
|
38918
38981
|
};
|
|
38919
38982
|
if (profile === "live") {
|
|
38920
38983
|
return base;
|
|
@@ -38923,23 +38986,23 @@ function buildMachineInfo(profile = "full") {
|
|
|
38923
38986
|
const memSnap2 = getHostMemorySnapshot();
|
|
38924
38987
|
return {
|
|
38925
38988
|
...base,
|
|
38926
|
-
arch:
|
|
38927
|
-
cpus:
|
|
38989
|
+
arch: os20.arch(),
|
|
38990
|
+
cpus: os20.cpus().length,
|
|
38928
38991
|
totalMem: memSnap2.totalMem,
|
|
38929
|
-
release:
|
|
38992
|
+
release: os20.release()
|
|
38930
38993
|
};
|
|
38931
38994
|
}
|
|
38932
38995
|
const memSnap = getHostMemorySnapshot();
|
|
38933
38996
|
return {
|
|
38934
38997
|
...base,
|
|
38935
|
-
arch:
|
|
38936
|
-
cpus:
|
|
38998
|
+
arch: os20.arch(),
|
|
38999
|
+
cpus: os20.cpus().length,
|
|
38937
39000
|
totalMem: memSnap.totalMem,
|
|
38938
39001
|
freeMem: memSnap.freeMem,
|
|
38939
39002
|
availableMem: memSnap.availableMem,
|
|
38940
|
-
loadavg:
|
|
38941
|
-
uptime:
|
|
38942
|
-
release:
|
|
39003
|
+
loadavg: os20.loadavg(),
|
|
39004
|
+
uptime: os20.uptime(),
|
|
39005
|
+
release: os20.release()
|
|
38943
39006
|
};
|
|
38944
39007
|
}
|
|
38945
39008
|
function parseMessageTime(value) {
|
|
@@ -39162,11 +39225,11 @@ function buildStatusSnapshot(options) {
|
|
|
39162
39225
|
}
|
|
39163
39226
|
};
|
|
39164
39227
|
}
|
|
39165
|
-
var
|
|
39228
|
+
var os20, READ_DEBUG_ENABLED, recentReadDebugSignatureBySession;
|
|
39166
39229
|
var init_snapshot = __esm({
|
|
39167
39230
|
"../../oss/packages/daemon-core/src/status/snapshot.ts"() {
|
|
39168
39231
|
"use strict";
|
|
39169
|
-
|
|
39232
|
+
os20 = __toESM(require("os"));
|
|
39170
39233
|
init_config();
|
|
39171
39234
|
init_state_store();
|
|
39172
39235
|
init_recent_activity();
|
|
@@ -39184,37 +39247,37 @@ var init_snapshot = __esm({
|
|
|
39184
39247
|
|
|
39185
39248
|
// ../../oss/packages/daemon-core/src/commands/upgrade-helper.ts
|
|
39186
39249
|
function getUpgradeLogPath() {
|
|
39187
|
-
const home =
|
|
39188
|
-
const dir =
|
|
39189
|
-
|
|
39190
|
-
return
|
|
39250
|
+
const home = os21.homedir();
|
|
39251
|
+
const dir = path18.join(home, ".adhdev");
|
|
39252
|
+
fs9.mkdirSync(dir, { recursive: true });
|
|
39253
|
+
return path18.join(dir, "daemon-upgrade.log");
|
|
39191
39254
|
}
|
|
39192
39255
|
function appendUpgradeLog(message) {
|
|
39193
39256
|
const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
|
|
39194
39257
|
`;
|
|
39195
39258
|
try {
|
|
39196
|
-
|
|
39259
|
+
fs9.appendFileSync(getUpgradeLogPath(), line, "utf8");
|
|
39197
39260
|
} catch {
|
|
39198
39261
|
}
|
|
39199
39262
|
}
|
|
39200
39263
|
function resolveSiblingNpmInvocation(nodeExecutable, platform12 = process.platform) {
|
|
39201
|
-
const binDir =
|
|
39264
|
+
const binDir = path18.dirname(nodeExecutable);
|
|
39202
39265
|
if (platform12 === "win32") {
|
|
39203
|
-
const npmCliPath =
|
|
39204
|
-
if (
|
|
39266
|
+
const npmCliPath = path18.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
|
|
39267
|
+
if (fs9.existsSync(npmCliPath)) {
|
|
39205
39268
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
|
|
39206
39269
|
}
|
|
39207
39270
|
for (const candidate of ["npm.exe", "npm"]) {
|
|
39208
|
-
const candidatePath =
|
|
39209
|
-
if (
|
|
39271
|
+
const candidatePath = path18.join(binDir, candidate);
|
|
39272
|
+
if (fs9.existsSync(candidatePath)) {
|
|
39210
39273
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
|
|
39211
39274
|
}
|
|
39212
39275
|
}
|
|
39213
39276
|
return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
|
|
39214
39277
|
}
|
|
39215
39278
|
for (const candidate of ["npm"]) {
|
|
39216
|
-
const candidatePath =
|
|
39217
|
-
if (
|
|
39279
|
+
const candidatePath = path18.join(binDir, candidate);
|
|
39280
|
+
if (fs9.existsSync(candidatePath)) {
|
|
39218
39281
|
return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
|
|
39219
39282
|
}
|
|
39220
39283
|
}
|
|
@@ -39224,22 +39287,22 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
|
|
|
39224
39287
|
if (!currentCliPath) return null;
|
|
39225
39288
|
let resolvedPath = currentCliPath;
|
|
39226
39289
|
try {
|
|
39227
|
-
resolvedPath =
|
|
39290
|
+
resolvedPath = fs9.realpathSync.native(currentCliPath);
|
|
39228
39291
|
} catch {
|
|
39229
39292
|
}
|
|
39230
39293
|
let currentDir = resolvedPath;
|
|
39231
39294
|
try {
|
|
39232
|
-
if (
|
|
39233
|
-
currentDir =
|
|
39295
|
+
if (fs9.statSync(resolvedPath).isFile()) {
|
|
39296
|
+
currentDir = path18.dirname(resolvedPath);
|
|
39234
39297
|
}
|
|
39235
39298
|
} catch {
|
|
39236
|
-
currentDir =
|
|
39299
|
+
currentDir = path18.dirname(resolvedPath);
|
|
39237
39300
|
}
|
|
39238
39301
|
while (true) {
|
|
39239
|
-
const packageJsonPath =
|
|
39302
|
+
const packageJsonPath = path18.join(currentDir, "package.json");
|
|
39240
39303
|
try {
|
|
39241
|
-
if (
|
|
39242
|
-
const parsed = JSON.parse(
|
|
39304
|
+
if (fs9.existsSync(packageJsonPath)) {
|
|
39305
|
+
const parsed = JSON.parse(fs9.readFileSync(packageJsonPath, "utf8"));
|
|
39243
39306
|
if (parsed?.name === packageName) {
|
|
39244
39307
|
const normalized = currentDir.replace(/\\/g, "/");
|
|
39245
39308
|
return normalized.includes("/node_modules/") ? currentDir : null;
|
|
@@ -39247,7 +39310,7 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
|
|
|
39247
39310
|
}
|
|
39248
39311
|
} catch {
|
|
39249
39312
|
}
|
|
39250
|
-
const parentDir =
|
|
39313
|
+
const parentDir = path18.dirname(currentDir);
|
|
39251
39314
|
if (parentDir === currentDir) {
|
|
39252
39315
|
return null;
|
|
39253
39316
|
}
|
|
@@ -39255,13 +39318,13 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
|
|
|
39255
39318
|
}
|
|
39256
39319
|
}
|
|
39257
39320
|
function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
|
|
39258
|
-
const nodeModulesDir = packageName.startsWith("@") ?
|
|
39259
|
-
if (
|
|
39321
|
+
const nodeModulesDir = packageName.startsWith("@") ? path18.dirname(path18.dirname(packageRoot)) : path18.dirname(packageRoot);
|
|
39322
|
+
if (path18.basename(nodeModulesDir) !== "node_modules") {
|
|
39260
39323
|
return null;
|
|
39261
39324
|
}
|
|
39262
|
-
const maybeLibDir =
|
|
39263
|
-
if (
|
|
39264
|
-
return
|
|
39325
|
+
const maybeLibDir = path18.dirname(nodeModulesDir);
|
|
39326
|
+
if (path18.basename(maybeLibDir) === "lib") {
|
|
39327
|
+
return path18.dirname(maybeLibDir);
|
|
39265
39328
|
}
|
|
39266
39329
|
return maybeLibDir;
|
|
39267
39330
|
}
|
|
@@ -39376,10 +39439,10 @@ async function waitForPidExit(pid, timeoutMs) {
|
|
|
39376
39439
|
}
|
|
39377
39440
|
}
|
|
39378
39441
|
function stopSessionHostProcesses(appName) {
|
|
39379
|
-
const pidFile =
|
|
39442
|
+
const pidFile = path18.join(os21.homedir(), ".adhdev", `${appName}-session-host.pid`);
|
|
39380
39443
|
try {
|
|
39381
|
-
if (
|
|
39382
|
-
const pid = Number.parseInt(
|
|
39444
|
+
if (fs9.existsSync(pidFile)) {
|
|
39445
|
+
const pid = Number.parseInt(fs9.readFileSync(pidFile, "utf8").trim(), 10);
|
|
39383
39446
|
if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid(pid)) {
|
|
39384
39447
|
killPid(pid);
|
|
39385
39448
|
}
|
|
@@ -39387,15 +39450,15 @@ function stopSessionHostProcesses(appName) {
|
|
|
39387
39450
|
} catch {
|
|
39388
39451
|
} finally {
|
|
39389
39452
|
try {
|
|
39390
|
-
|
|
39453
|
+
fs9.unlinkSync(pidFile);
|
|
39391
39454
|
} catch {
|
|
39392
39455
|
}
|
|
39393
39456
|
}
|
|
39394
39457
|
}
|
|
39395
39458
|
function removeDaemonPidFile() {
|
|
39396
|
-
const pidFile =
|
|
39459
|
+
const pidFile = path18.join(os21.homedir(), ".adhdev", "daemon.pid");
|
|
39397
39460
|
try {
|
|
39398
|
-
|
|
39461
|
+
fs9.unlinkSync(pidFile);
|
|
39399
39462
|
} catch {
|
|
39400
39463
|
}
|
|
39401
39464
|
}
|
|
@@ -39404,7 +39467,7 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
|
|
|
39404
39467
|
const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
39405
39468
|
if (!npmRoot) return;
|
|
39406
39469
|
const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
|
|
39407
|
-
const binDir = process.platform === "win32" ? npmPrefix :
|
|
39470
|
+
const binDir = process.platform === "win32" ? npmPrefix : path18.join(npmPrefix, "bin");
|
|
39408
39471
|
const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
|
|
39409
39472
|
const binNames = /* @__PURE__ */ new Set([packageBaseName]);
|
|
39410
39473
|
if (pkgName === "@adhdev/daemon-standalone") {
|
|
@@ -39412,25 +39475,25 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
|
|
|
39412
39475
|
}
|
|
39413
39476
|
if (pkgName.startsWith("@")) {
|
|
39414
39477
|
const [scope, name] = pkgName.split("/");
|
|
39415
|
-
const scopeDir =
|
|
39416
|
-
if (!
|
|
39417
|
-
for (const entry of
|
|
39478
|
+
const scopeDir = path18.join(npmRoot, scope);
|
|
39479
|
+
if (!fs9.existsSync(scopeDir)) return;
|
|
39480
|
+
for (const entry of fs9.readdirSync(scopeDir)) {
|
|
39418
39481
|
if (!entry.startsWith(`.${name}-`)) continue;
|
|
39419
|
-
|
|
39420
|
-
appendUpgradeLog(`Removed stale scoped staging dir: ${
|
|
39482
|
+
fs9.rmSync(path18.join(scopeDir, entry), { recursive: true, force: true });
|
|
39483
|
+
appendUpgradeLog(`Removed stale scoped staging dir: ${path18.join(scopeDir, entry)}`);
|
|
39421
39484
|
}
|
|
39422
39485
|
} else {
|
|
39423
|
-
for (const entry of
|
|
39486
|
+
for (const entry of fs9.readdirSync(npmRoot)) {
|
|
39424
39487
|
if (!entry.startsWith(`.${pkgName}-`)) continue;
|
|
39425
|
-
|
|
39426
|
-
appendUpgradeLog(`Removed stale staging dir: ${
|
|
39488
|
+
fs9.rmSync(path18.join(npmRoot, entry), { recursive: true, force: true });
|
|
39489
|
+
appendUpgradeLog(`Removed stale staging dir: ${path18.join(npmRoot, entry)}`);
|
|
39427
39490
|
}
|
|
39428
39491
|
}
|
|
39429
|
-
if (
|
|
39430
|
-
for (const entry of
|
|
39492
|
+
if (fs9.existsSync(binDir)) {
|
|
39493
|
+
for (const entry of fs9.readdirSync(binDir)) {
|
|
39431
39494
|
if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
|
|
39432
|
-
|
|
39433
|
-
appendUpgradeLog(`Removed stale bin staging entry: ${
|
|
39495
|
+
fs9.rmSync(path18.join(binDir, entry), { recursive: true, force: true });
|
|
39496
|
+
appendUpgradeLog(`Removed stale bin staging entry: ${path18.join(binDir, entry)}`);
|
|
39434
39497
|
}
|
|
39435
39498
|
}
|
|
39436
39499
|
}
|
|
@@ -39513,15 +39576,15 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
|
|
|
39513
39576
|
process.exit(1);
|
|
39514
39577
|
}
|
|
39515
39578
|
}
|
|
39516
|
-
var import_child_process8, import_child_process9,
|
|
39579
|
+
var import_child_process8, import_child_process9, fs9, os21, path18, UPGRADE_HELPER_ENV;
|
|
39517
39580
|
var init_upgrade_helper = __esm({
|
|
39518
39581
|
"../../oss/packages/daemon-core/src/commands/upgrade-helper.ts"() {
|
|
39519
39582
|
"use strict";
|
|
39520
39583
|
import_child_process8 = require("child_process");
|
|
39521
39584
|
import_child_process9 = require("child_process");
|
|
39522
|
-
|
|
39523
|
-
|
|
39524
|
-
|
|
39585
|
+
fs9 = __toESM(require("fs"));
|
|
39586
|
+
os21 = __toESM(require("os"));
|
|
39587
|
+
path18 = __toESM(require("path"));
|
|
39525
39588
|
UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
|
|
39526
39589
|
}
|
|
39527
39590
|
});
|
|
@@ -39608,7 +39671,7 @@ function summarizeSessionHostPruneResult(result) {
|
|
|
39608
39671
|
keptCount: Array.isArray(value.keptSessionIds) ? value.keptSessionIds.length : void 0
|
|
39609
39672
|
};
|
|
39610
39673
|
}
|
|
39611
|
-
var
|
|
39674
|
+
var fs10, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
|
|
39612
39675
|
var init_router = __esm({
|
|
39613
39676
|
"../../oss/packages/daemon-core/src/commands/router.ts"() {
|
|
39614
39677
|
"use strict";
|
|
@@ -39633,7 +39696,7 @@ var init_router = __esm({
|
|
|
39633
39696
|
init_snapshot();
|
|
39634
39697
|
init_snapshot();
|
|
39635
39698
|
init_upgrade_helper();
|
|
39636
|
-
|
|
39699
|
+
fs10 = __toESM(require("fs"));
|
|
39637
39700
|
CHAT_COMMANDS = [
|
|
39638
39701
|
"send_chat",
|
|
39639
39702
|
"new_chat",
|
|
@@ -39788,8 +39851,8 @@ var init_router = __esm({
|
|
|
39788
39851
|
if (sinceTs > 0) {
|
|
39789
39852
|
return { success: true, logs: [], totalBuffered: 0 };
|
|
39790
39853
|
}
|
|
39791
|
-
if (
|
|
39792
|
-
const content =
|
|
39854
|
+
if (fs10.existsSync(LOG_PATH)) {
|
|
39855
|
+
const content = fs10.readFileSync(LOG_PATH, "utf-8");
|
|
39793
39856
|
const allLines = content.split("\n");
|
|
39794
39857
|
const recent = allLines.slice(-count).join("\n");
|
|
39795
39858
|
return { success: true, logs: recent, totalLines: allLines.length };
|
|
@@ -42067,19 +42130,19 @@ function getVersion(binary, versionCommand) {
|
|
|
42067
42130
|
function checkPathExists2(paths) {
|
|
42068
42131
|
for (const p of paths) {
|
|
42069
42132
|
if (p.includes("*")) {
|
|
42070
|
-
const home =
|
|
42071
|
-
const resolved = p.replace(/\*/g, home.split(
|
|
42072
|
-
if (
|
|
42133
|
+
const home = os23.homedir();
|
|
42134
|
+
const resolved = p.replace(/\*/g, home.split(path19.sep).pop() || "");
|
|
42135
|
+
if (fs11.existsSync(resolved)) return resolved;
|
|
42073
42136
|
} else {
|
|
42074
|
-
if (
|
|
42137
|
+
if (fs11.existsSync(p)) return p;
|
|
42075
42138
|
}
|
|
42076
42139
|
}
|
|
42077
42140
|
return null;
|
|
42078
42141
|
}
|
|
42079
42142
|
function getMacAppVersion(appPath) {
|
|
42080
42143
|
if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
|
|
42081
|
-
const plistPath =
|
|
42082
|
-
if (!
|
|
42144
|
+
const plistPath = path19.join(appPath, "Contents", "Info.plist");
|
|
42145
|
+
if (!fs11.existsSync(plistPath)) return null;
|
|
42083
42146
|
const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
|
|
42084
42147
|
return raw || null;
|
|
42085
42148
|
}
|
|
@@ -42104,8 +42167,8 @@ async function detectAllVersions(loader, archive) {
|
|
|
42104
42167
|
const cliBin = provider.cli ? findBinary2(provider.cli) : null;
|
|
42105
42168
|
let resolvedBin = cliBin;
|
|
42106
42169
|
if (!resolvedBin && appPath && currentOs === "darwin") {
|
|
42107
|
-
const bundled =
|
|
42108
|
-
if (provider.cli &&
|
|
42170
|
+
const bundled = path19.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
|
|
42171
|
+
if (provider.cli && fs11.existsSync(bundled)) resolvedBin = bundled;
|
|
42109
42172
|
}
|
|
42110
42173
|
info.installed = !!(appPath || resolvedBin);
|
|
42111
42174
|
info.path = appPath || null;
|
|
@@ -42141,16 +42204,16 @@ async function detectAllVersions(loader, archive) {
|
|
|
42141
42204
|
}
|
|
42142
42205
|
return results;
|
|
42143
42206
|
}
|
|
42144
|
-
var
|
|
42207
|
+
var fs11, path19, os23, import_child_process10, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
|
|
42145
42208
|
var init_version_archive = __esm({
|
|
42146
42209
|
"../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
|
|
42147
42210
|
"use strict";
|
|
42148
|
-
|
|
42149
|
-
|
|
42150
|
-
|
|
42211
|
+
fs11 = __toESM(require("fs"));
|
|
42212
|
+
path19 = __toESM(require("path"));
|
|
42213
|
+
os23 = __toESM(require("os"));
|
|
42151
42214
|
import_child_process10 = require("child_process");
|
|
42152
42215
|
import_os3 = require("os");
|
|
42153
|
-
ARCHIVE_PATH =
|
|
42216
|
+
ARCHIVE_PATH = path19.join(os23.homedir(), ".adhdev", "version-history.json");
|
|
42154
42217
|
MAX_ENTRIES_PER_PROVIDER = 20;
|
|
42155
42218
|
VersionArchive = class {
|
|
42156
42219
|
history = {};
|
|
@@ -42159,8 +42222,8 @@ var init_version_archive = __esm({
|
|
|
42159
42222
|
}
|
|
42160
42223
|
load() {
|
|
42161
42224
|
try {
|
|
42162
|
-
if (
|
|
42163
|
-
this.history = JSON.parse(
|
|
42225
|
+
if (fs11.existsSync(ARCHIVE_PATH)) {
|
|
42226
|
+
this.history = JSON.parse(fs11.readFileSync(ARCHIVE_PATH, "utf-8"));
|
|
42164
42227
|
}
|
|
42165
42228
|
} catch {
|
|
42166
42229
|
this.history = {};
|
|
@@ -42197,8 +42260,8 @@ var init_version_archive = __esm({
|
|
|
42197
42260
|
}
|
|
42198
42261
|
save() {
|
|
42199
42262
|
try {
|
|
42200
|
-
|
|
42201
|
-
|
|
42263
|
+
fs11.mkdirSync(path19.dirname(ARCHIVE_PATH), { recursive: true });
|
|
42264
|
+
fs11.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
|
|
42202
42265
|
} catch {
|
|
42203
42266
|
}
|
|
42204
42267
|
}
|
|
@@ -42732,18 +42795,18 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
42732
42795
|
return;
|
|
42733
42796
|
}
|
|
42734
42797
|
let scriptsPath = "";
|
|
42735
|
-
const directScripts =
|
|
42736
|
-
if (
|
|
42798
|
+
const directScripts = path20.join(dir, "scripts.js");
|
|
42799
|
+
if (fs12.existsSync(directScripts)) {
|
|
42737
42800
|
scriptsPath = directScripts;
|
|
42738
42801
|
} else {
|
|
42739
|
-
const scriptsDir =
|
|
42740
|
-
if (
|
|
42741
|
-
const versions =
|
|
42742
|
-
return
|
|
42802
|
+
const scriptsDir = path20.join(dir, "scripts");
|
|
42803
|
+
if (fs12.existsSync(scriptsDir)) {
|
|
42804
|
+
const versions = fs12.readdirSync(scriptsDir).filter((d) => {
|
|
42805
|
+
return fs12.statSync(path20.join(scriptsDir, d)).isDirectory();
|
|
42743
42806
|
}).sort().reverse();
|
|
42744
42807
|
for (const ver of versions) {
|
|
42745
|
-
const p =
|
|
42746
|
-
if (
|
|
42808
|
+
const p = path20.join(scriptsDir, ver, "scripts.js");
|
|
42809
|
+
if (fs12.existsSync(p)) {
|
|
42747
42810
|
scriptsPath = p;
|
|
42748
42811
|
break;
|
|
42749
42812
|
}
|
|
@@ -42755,7 +42818,7 @@ async function handleScriptHints(ctx, type, _req, res) {
|
|
|
42755
42818
|
return;
|
|
42756
42819
|
}
|
|
42757
42820
|
try {
|
|
42758
|
-
const source =
|
|
42821
|
+
const source = fs12.readFileSync(scriptsPath, "utf-8");
|
|
42759
42822
|
const hints = {};
|
|
42760
42823
|
const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
|
|
42761
42824
|
let match;
|
|
@@ -43568,12 +43631,12 @@ async function handleDomContext(ctx, type, req, res) {
|
|
|
43568
43631
|
ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
|
|
43569
43632
|
}
|
|
43570
43633
|
}
|
|
43571
|
-
var
|
|
43634
|
+
var fs12, path20;
|
|
43572
43635
|
var init_dev_cdp_handlers = __esm({
|
|
43573
43636
|
"../../oss/packages/daemon-core/src/daemon/dev-cdp-handlers.ts"() {
|
|
43574
43637
|
"use strict";
|
|
43575
|
-
|
|
43576
|
-
|
|
43638
|
+
fs12 = __toESM(require("fs"));
|
|
43639
|
+
path20 = __toESM(require("path"));
|
|
43577
43640
|
init_logger();
|
|
43578
43641
|
}
|
|
43579
43642
|
});
|
|
@@ -43588,15 +43651,15 @@ function getCliFixtureDir(ctx, type) {
|
|
|
43588
43651
|
if (!providerDir) {
|
|
43589
43652
|
throw new Error(`Provider directory not found for '${type}'`);
|
|
43590
43653
|
}
|
|
43591
|
-
return
|
|
43654
|
+
return path21.join(providerDir, "fixtures");
|
|
43592
43655
|
}
|
|
43593
43656
|
function readCliFixture(ctx, type, name) {
|
|
43594
43657
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
43595
|
-
const filePath =
|
|
43596
|
-
if (!
|
|
43658
|
+
const filePath = path21.join(fixtureDir, `${name}.json`);
|
|
43659
|
+
if (!fs13.existsSync(filePath)) {
|
|
43597
43660
|
throw new Error(`Fixture not found: ${filePath}`);
|
|
43598
43661
|
}
|
|
43599
|
-
return JSON.parse(
|
|
43662
|
+
return JSON.parse(fs13.readFileSync(filePath, "utf-8"));
|
|
43600
43663
|
}
|
|
43601
43664
|
function getExerciseTranscriptText(result) {
|
|
43602
43665
|
const parts = [];
|
|
@@ -44332,7 +44395,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
44332
44395
|
return;
|
|
44333
44396
|
}
|
|
44334
44397
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
44335
|
-
|
|
44398
|
+
fs13.mkdirSync(fixtureDir, { recursive: true });
|
|
44336
44399
|
const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
|
|
44337
44400
|
const result = await runCliExerciseInternal(ctx, { ...request, type });
|
|
44338
44401
|
const fixture = {
|
|
@@ -44359,8 +44422,8 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
44359
44422
|
},
|
|
44360
44423
|
notes: typeof body?.notes === "string" ? body.notes : void 0
|
|
44361
44424
|
};
|
|
44362
|
-
const filePath =
|
|
44363
|
-
|
|
44425
|
+
const filePath = path21.join(fixtureDir, `${name}.json`);
|
|
44426
|
+
fs13.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
|
|
44364
44427
|
ctx.json(res, 200, {
|
|
44365
44428
|
saved: true,
|
|
44366
44429
|
name,
|
|
@@ -44378,14 +44441,14 @@ async function handleCliFixtureCapture(ctx, req, res) {
|
|
|
44378
44441
|
async function handleCliFixtureList(ctx, type, _req, res) {
|
|
44379
44442
|
try {
|
|
44380
44443
|
const fixtureDir = getCliFixtureDir(ctx, type);
|
|
44381
|
-
if (!
|
|
44444
|
+
if (!fs13.existsSync(fixtureDir)) {
|
|
44382
44445
|
ctx.json(res, 200, { fixtures: [], count: 0 });
|
|
44383
44446
|
return;
|
|
44384
44447
|
}
|
|
44385
|
-
const fixtures =
|
|
44386
|
-
const fullPath =
|
|
44448
|
+
const fixtures = fs13.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
|
|
44449
|
+
const fullPath = path21.join(fixtureDir, file2);
|
|
44387
44450
|
try {
|
|
44388
|
-
const raw = JSON.parse(
|
|
44451
|
+
const raw = JSON.parse(fs13.readFileSync(fullPath, "utf-8"));
|
|
44389
44452
|
return {
|
|
44390
44453
|
name: raw.name || file2.replace(/\.json$/i, ""),
|
|
44391
44454
|
path: fullPath,
|
|
@@ -44516,12 +44579,12 @@ async function handleCliRaw(ctx, req, res) {
|
|
|
44516
44579
|
ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
|
|
44517
44580
|
}
|
|
44518
44581
|
}
|
|
44519
|
-
var
|
|
44582
|
+
var fs13, path21;
|
|
44520
44583
|
var init_dev_cli_debug = __esm({
|
|
44521
44584
|
"../../oss/packages/daemon-core/src/daemon/dev-cli-debug.ts"() {
|
|
44522
44585
|
"use strict";
|
|
44523
|
-
|
|
44524
|
-
|
|
44586
|
+
fs13 = __toESM(require("fs"));
|
|
44587
|
+
path21 = __toESM(require("path"));
|
|
44525
44588
|
}
|
|
44526
44589
|
});
|
|
44527
44590
|
|
|
@@ -44571,38 +44634,38 @@ function resolveAutoImplReference(ctx, category, requestedReference, targetType)
|
|
|
44571
44634
|
return fallback2?.type || null;
|
|
44572
44635
|
}
|
|
44573
44636
|
function getLatestScriptVersionDir(scriptsDir) {
|
|
44574
|
-
if (!
|
|
44575
|
-
const versions =
|
|
44637
|
+
if (!fs14.existsSync(scriptsDir)) return null;
|
|
44638
|
+
const versions = fs14.readdirSync(scriptsDir).filter((d) => {
|
|
44576
44639
|
try {
|
|
44577
|
-
return
|
|
44640
|
+
return fs14.statSync(path23.join(scriptsDir, d)).isDirectory();
|
|
44578
44641
|
} catch {
|
|
44579
44642
|
return false;
|
|
44580
44643
|
}
|
|
44581
44644
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
44582
44645
|
if (versions.length === 0) return null;
|
|
44583
|
-
return
|
|
44646
|
+
return path23.join(scriptsDir, versions[0]);
|
|
44584
44647
|
}
|
|
44585
44648
|
function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
44586
|
-
const canonicalUserDir =
|
|
44587
|
-
const desiredDir = requestedDir ?
|
|
44588
|
-
const upstreamRoot =
|
|
44589
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
44649
|
+
const canonicalUserDir = path23.resolve(ctx.providerLoader.getUserProviderDir(category, type));
|
|
44650
|
+
const desiredDir = requestedDir ? path23.resolve(requestedDir) : canonicalUserDir;
|
|
44651
|
+
const upstreamRoot = path23.resolve(ctx.providerLoader.getUpstreamDir());
|
|
44652
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path23.sep}`)) {
|
|
44590
44653
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
44591
44654
|
}
|
|
44592
|
-
if (
|
|
44655
|
+
if (path23.basename(desiredDir) !== type) {
|
|
44593
44656
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
44594
44657
|
}
|
|
44595
44658
|
const sourceDir = ctx.findProviderDir(type);
|
|
44596
44659
|
if (!sourceDir) {
|
|
44597
44660
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
44598
44661
|
}
|
|
44599
|
-
if (!
|
|
44600
|
-
|
|
44601
|
-
|
|
44662
|
+
if (!fs14.existsSync(desiredDir)) {
|
|
44663
|
+
fs14.mkdirSync(path23.dirname(desiredDir), { recursive: true });
|
|
44664
|
+
fs14.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
44602
44665
|
ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
44603
44666
|
}
|
|
44604
|
-
const providerJson =
|
|
44605
|
-
if (!
|
|
44667
|
+
const providerJson = path23.join(desiredDir, "provider.json");
|
|
44668
|
+
if (!fs14.existsSync(providerJson)) {
|
|
44606
44669
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
44607
44670
|
}
|
|
44608
44671
|
return { dir: desiredDir };
|
|
@@ -44610,15 +44673,15 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
|
|
|
44610
44673
|
function loadAutoImplReferenceScripts(ctx, referenceType) {
|
|
44611
44674
|
if (!referenceType) return {};
|
|
44612
44675
|
const refDir = ctx.findProviderDir(referenceType);
|
|
44613
|
-
if (!refDir || !
|
|
44676
|
+
if (!refDir || !fs14.existsSync(refDir)) return {};
|
|
44614
44677
|
const referenceScripts = {};
|
|
44615
|
-
const scriptsDir =
|
|
44678
|
+
const scriptsDir = path23.join(refDir, "scripts");
|
|
44616
44679
|
const latestDir = getLatestScriptVersionDir(scriptsDir);
|
|
44617
44680
|
if (!latestDir) return referenceScripts;
|
|
44618
|
-
for (const file2 of
|
|
44681
|
+
for (const file2 of fs14.readdirSync(latestDir)) {
|
|
44619
44682
|
if (!file2.endsWith(".js")) continue;
|
|
44620
44683
|
try {
|
|
44621
|
-
referenceScripts[file2] =
|
|
44684
|
+
referenceScripts[file2] = fs14.readFileSync(path23.join(latestDir, file2), "utf-8");
|
|
44622
44685
|
} catch {
|
|
44623
44686
|
}
|
|
44624
44687
|
}
|
|
@@ -44726,16 +44789,16 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
44726
44789
|
});
|
|
44727
44790
|
const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
|
|
44728
44791
|
const prompt2 = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
|
|
44729
|
-
const tmpDir =
|
|
44730
|
-
if (!
|
|
44731
|
-
const promptFile =
|
|
44732
|
-
|
|
44792
|
+
const tmpDir = path23.join(os24.tmpdir(), "adhdev-autoimpl");
|
|
44793
|
+
if (!fs14.existsSync(tmpDir)) fs14.mkdirSync(tmpDir, { recursive: true });
|
|
44794
|
+
const promptFile = path23.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
|
|
44795
|
+
fs14.writeFileSync(promptFile, prompt2, "utf-8");
|
|
44733
44796
|
ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt2.length} chars)`);
|
|
44734
44797
|
const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
|
|
44735
44798
|
const spawn6 = agentProvider?.spawn;
|
|
44736
44799
|
if (!spawn6?.command) {
|
|
44737
44800
|
try {
|
|
44738
|
-
|
|
44801
|
+
fs14.unlinkSync(promptFile);
|
|
44739
44802
|
} catch {
|
|
44740
44803
|
}
|
|
44741
44804
|
ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
|
|
@@ -44837,7 +44900,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
44837
44900
|
} catch {
|
|
44838
44901
|
}
|
|
44839
44902
|
try {
|
|
44840
|
-
|
|
44903
|
+
fs14.unlinkSync(promptFile);
|
|
44841
44904
|
} catch {
|
|
44842
44905
|
}
|
|
44843
44906
|
ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
|
|
@@ -44881,7 +44944,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
44881
44944
|
const interactiveFlags = ["--yolo", "--interactive", "-i"];
|
|
44882
44945
|
const baseArgs = [...spawn6.args || []].filter((a) => !interactiveFlags.includes(a));
|
|
44883
44946
|
let shellCmd;
|
|
44884
|
-
const isWin =
|
|
44947
|
+
const isWin = os24.platform() === "win32";
|
|
44885
44948
|
const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
|
|
44886
44949
|
const promptMode = autoImpl?.promptMode ?? "stdin";
|
|
44887
44950
|
const extraArgs = autoImpl?.extraArgs ?? [];
|
|
@@ -44920,7 +44983,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
44920
44983
|
try {
|
|
44921
44984
|
const pty = require("node-pty");
|
|
44922
44985
|
ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
|
|
44923
|
-
const isWin2 =
|
|
44986
|
+
const isWin2 = os24.platform() === "win32";
|
|
44924
44987
|
child = pty.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
|
|
44925
44988
|
name: "xterm-256color",
|
|
44926
44989
|
cols: 120,
|
|
@@ -45063,7 +45126,7 @@ async function handleAutoImplement(ctx, type, req, res) {
|
|
|
45063
45126
|
}
|
|
45064
45127
|
});
|
|
45065
45128
|
try {
|
|
45066
|
-
|
|
45129
|
+
fs14.unlinkSync(promptFile);
|
|
45067
45130
|
} catch {
|
|
45068
45131
|
}
|
|
45069
45132
|
ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
|
|
@@ -45160,7 +45223,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
45160
45223
|
setMode: "set_mode.js"
|
|
45161
45224
|
};
|
|
45162
45225
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
45163
|
-
const scriptsDir =
|
|
45226
|
+
const scriptsDir = path23.join(providerDir, "scripts");
|
|
45164
45227
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
45165
45228
|
if (latestScriptsDir) {
|
|
45166
45229
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -45168,10 +45231,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
45168
45231
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
45169
45232
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
45170
45233
|
lines.push("");
|
|
45171
|
-
for (const file2 of
|
|
45234
|
+
for (const file2 of fs14.readdirSync(latestScriptsDir)) {
|
|
45172
45235
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
45173
45236
|
try {
|
|
45174
|
-
const content =
|
|
45237
|
+
const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
45175
45238
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
45176
45239
|
lines.push("```javascript");
|
|
45177
45240
|
lines.push(content);
|
|
@@ -45181,14 +45244,14 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
45181
45244
|
}
|
|
45182
45245
|
}
|
|
45183
45246
|
}
|
|
45184
|
-
const refFiles =
|
|
45247
|
+
const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
45185
45248
|
if (refFiles.length > 0) {
|
|
45186
45249
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
45187
45250
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
45188
45251
|
lines.push("");
|
|
45189
45252
|
for (const file2 of refFiles) {
|
|
45190
45253
|
try {
|
|
45191
|
-
const content =
|
|
45254
|
+
const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
45192
45255
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
45193
45256
|
lines.push("```javascript");
|
|
45194
45257
|
lines.push(content);
|
|
@@ -45229,11 +45292,11 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
|
|
|
45229
45292
|
lines.push("");
|
|
45230
45293
|
}
|
|
45231
45294
|
}
|
|
45232
|
-
const docsDir =
|
|
45295
|
+
const docsDir = path23.join(providerDir, "../../docs");
|
|
45233
45296
|
const loadGuide = (name) => {
|
|
45234
45297
|
try {
|
|
45235
|
-
const p =
|
|
45236
|
-
if (
|
|
45298
|
+
const p = path23.join(docsDir, name);
|
|
45299
|
+
if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
|
|
45237
45300
|
} catch {
|
|
45238
45301
|
}
|
|
45239
45302
|
return null;
|
|
@@ -45469,7 +45532,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
45469
45532
|
parseApproval: "parse_approval.js"
|
|
45470
45533
|
};
|
|
45471
45534
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
45472
|
-
const scriptsDir =
|
|
45535
|
+
const scriptsDir = path23.join(providerDir, "scripts");
|
|
45473
45536
|
const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
|
|
45474
45537
|
if (latestScriptsDir) {
|
|
45475
45538
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -45477,11 +45540,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
45477
45540
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
45478
45541
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
45479
45542
|
lines.push("");
|
|
45480
|
-
for (const file2 of
|
|
45543
|
+
for (const file2 of fs14.readdirSync(latestScriptsDir)) {
|
|
45481
45544
|
if (!file2.endsWith(".js")) continue;
|
|
45482
45545
|
if (!targetFileNames.has(file2)) continue;
|
|
45483
45546
|
try {
|
|
45484
|
-
const content =
|
|
45547
|
+
const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
45485
45548
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
45486
45549
|
lines.push("```javascript");
|
|
45487
45550
|
lines.push(content);
|
|
@@ -45490,14 +45553,14 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
45490
45553
|
} catch {
|
|
45491
45554
|
}
|
|
45492
45555
|
}
|
|
45493
|
-
const refFiles =
|
|
45556
|
+
const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
45494
45557
|
if (refFiles.length > 0) {
|
|
45495
45558
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
45496
45559
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
45497
45560
|
lines.push("");
|
|
45498
45561
|
for (const file2 of refFiles) {
|
|
45499
45562
|
try {
|
|
45500
|
-
const content =
|
|
45563
|
+
const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
|
|
45501
45564
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
45502
45565
|
lines.push("```javascript");
|
|
45503
45566
|
lines.push(content);
|
|
@@ -45530,11 +45593,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
|
|
|
45530
45593
|
lines.push("");
|
|
45531
45594
|
}
|
|
45532
45595
|
}
|
|
45533
|
-
const docsDir =
|
|
45596
|
+
const docsDir = path23.join(providerDir, "../../docs");
|
|
45534
45597
|
const loadGuide = (name) => {
|
|
45535
45598
|
try {
|
|
45536
|
-
const p =
|
|
45537
|
-
if (
|
|
45599
|
+
const p = path23.join(docsDir, name);
|
|
45600
|
+
if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
|
|
45538
45601
|
} catch {
|
|
45539
45602
|
}
|
|
45540
45603
|
return null;
|
|
@@ -45845,13 +45908,13 @@ data: ${JSON.stringify(msg.data)}
|
|
|
45845
45908
|
}
|
|
45846
45909
|
}
|
|
45847
45910
|
}
|
|
45848
|
-
var
|
|
45911
|
+
var fs14, path23, os24;
|
|
45849
45912
|
var init_dev_auto_implement = __esm({
|
|
45850
45913
|
"../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
|
|
45851
45914
|
"use strict";
|
|
45852
|
-
|
|
45853
|
-
|
|
45854
|
-
|
|
45915
|
+
fs14 = __toESM(require("fs"));
|
|
45916
|
+
path23 = __toESM(require("path"));
|
|
45917
|
+
os24 = __toESM(require("os"));
|
|
45855
45918
|
init_dev_server();
|
|
45856
45919
|
init_dev_cli_debug();
|
|
45857
45920
|
}
|
|
@@ -45890,13 +45953,13 @@ function toProviderListEntry(provider) {
|
|
|
45890
45953
|
}
|
|
45891
45954
|
return base;
|
|
45892
45955
|
}
|
|
45893
|
-
var http2,
|
|
45956
|
+
var http2, fs15, path24, DEV_SERVER_PORT, DevServer;
|
|
45894
45957
|
var init_dev_server = __esm({
|
|
45895
45958
|
"../../oss/packages/daemon-core/src/daemon/dev-server.ts"() {
|
|
45896
45959
|
"use strict";
|
|
45897
45960
|
http2 = __toESM(require("http"));
|
|
45898
|
-
|
|
45899
|
-
|
|
45961
|
+
fs15 = __toESM(require("fs"));
|
|
45962
|
+
path24 = __toESM(require("path"));
|
|
45900
45963
|
init_provider_schema();
|
|
45901
45964
|
init_config();
|
|
45902
45965
|
init_provider_source_config();
|
|
@@ -46009,8 +46072,8 @@ var init_dev_server = __esm({
|
|
|
46009
46072
|
}
|
|
46010
46073
|
getEndpointList() {
|
|
46011
46074
|
return this.routes.map((r) => {
|
|
46012
|
-
const
|
|
46013
|
-
return `${r.method.padEnd(5)} ${
|
|
46075
|
+
const path36 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
|
|
46076
|
+
return `${r.method.padEnd(5)} ${path36}`;
|
|
46014
46077
|
});
|
|
46015
46078
|
}
|
|
46016
46079
|
async start(port = DEV_SERVER_PORT) {
|
|
@@ -46298,12 +46361,12 @@ var init_dev_server = __esm({
|
|
|
46298
46361
|
// ─── DevConsole SPA ───
|
|
46299
46362
|
getConsoleDistDir() {
|
|
46300
46363
|
const candidates = [
|
|
46301
|
-
|
|
46302
|
-
|
|
46303
|
-
|
|
46364
|
+
path24.resolve(__dirname, "../../web-devconsole/dist"),
|
|
46365
|
+
path24.resolve(__dirname, "../../../web-devconsole/dist"),
|
|
46366
|
+
path24.join(process.cwd(), "packages/web-devconsole/dist")
|
|
46304
46367
|
];
|
|
46305
46368
|
for (const dir of candidates) {
|
|
46306
|
-
if (
|
|
46369
|
+
if (fs15.existsSync(path24.join(dir, "index.html"))) return dir;
|
|
46307
46370
|
}
|
|
46308
46371
|
return null;
|
|
46309
46372
|
}
|
|
@@ -46313,9 +46376,9 @@ var init_dev_server = __esm({
|
|
|
46313
46376
|
this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
|
|
46314
46377
|
return;
|
|
46315
46378
|
}
|
|
46316
|
-
const htmlPath =
|
|
46379
|
+
const htmlPath = path24.join(distDir, "index.html");
|
|
46317
46380
|
try {
|
|
46318
|
-
const html =
|
|
46381
|
+
const html = fs15.readFileSync(htmlPath, "utf-8");
|
|
46319
46382
|
res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
|
|
46320
46383
|
res.end(html);
|
|
46321
46384
|
} catch (e) {
|
|
@@ -46338,15 +46401,15 @@ var init_dev_server = __esm({
|
|
|
46338
46401
|
this.json(res, 404, { error: "Not found" });
|
|
46339
46402
|
return;
|
|
46340
46403
|
}
|
|
46341
|
-
const safePath =
|
|
46342
|
-
const filePath =
|
|
46404
|
+
const safePath = path24.normalize(pathname).replace(/^\.\.\//, "");
|
|
46405
|
+
const filePath = path24.join(distDir, safePath);
|
|
46343
46406
|
if (!filePath.startsWith(distDir)) {
|
|
46344
46407
|
this.json(res, 403, { error: "Forbidden" });
|
|
46345
46408
|
return;
|
|
46346
46409
|
}
|
|
46347
46410
|
try {
|
|
46348
|
-
const content =
|
|
46349
|
-
const ext =
|
|
46411
|
+
const content = fs15.readFileSync(filePath);
|
|
46412
|
+
const ext = path24.extname(filePath);
|
|
46350
46413
|
const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
|
|
46351
46414
|
res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
|
|
46352
46415
|
res.end(content);
|
|
@@ -46454,14 +46517,14 @@ var init_dev_server = __esm({
|
|
|
46454
46517
|
const files = [];
|
|
46455
46518
|
const scan = (d, prefix) => {
|
|
46456
46519
|
try {
|
|
46457
|
-
for (const entry of
|
|
46520
|
+
for (const entry of fs15.readdirSync(d, { withFileTypes: true })) {
|
|
46458
46521
|
if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
|
|
46459
46522
|
const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
46460
46523
|
if (entry.isDirectory()) {
|
|
46461
46524
|
files.push({ path: rel, size: 0, type: "dir" });
|
|
46462
|
-
scan(
|
|
46525
|
+
scan(path24.join(d, entry.name), rel);
|
|
46463
46526
|
} else {
|
|
46464
|
-
const stat4 =
|
|
46527
|
+
const stat4 = fs15.statSync(path24.join(d, entry.name));
|
|
46465
46528
|
files.push({ path: rel, size: stat4.size, type: "file" });
|
|
46466
46529
|
}
|
|
46467
46530
|
}
|
|
@@ -46484,16 +46547,16 @@ var init_dev_server = __esm({
|
|
|
46484
46547
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
46485
46548
|
return;
|
|
46486
46549
|
}
|
|
46487
|
-
const fullPath =
|
|
46550
|
+
const fullPath = path24.resolve(dir, path24.normalize(filePath));
|
|
46488
46551
|
if (!fullPath.startsWith(dir)) {
|
|
46489
46552
|
this.json(res, 403, { error: "Forbidden" });
|
|
46490
46553
|
return;
|
|
46491
46554
|
}
|
|
46492
|
-
if (!
|
|
46555
|
+
if (!fs15.existsSync(fullPath) || fs15.statSync(fullPath).isDirectory()) {
|
|
46493
46556
|
this.json(res, 404, { error: `File not found: ${filePath}` });
|
|
46494
46557
|
return;
|
|
46495
46558
|
}
|
|
46496
|
-
const content =
|
|
46559
|
+
const content = fs15.readFileSync(fullPath, "utf-8");
|
|
46497
46560
|
this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
|
|
46498
46561
|
}
|
|
46499
46562
|
/** POST /api/providers/:type/file — write a file { path, content } */
|
|
@@ -46509,15 +46572,15 @@ var init_dev_server = __esm({
|
|
|
46509
46572
|
this.json(res, 404, { error: `Provider directory not found: ${type}` });
|
|
46510
46573
|
return;
|
|
46511
46574
|
}
|
|
46512
|
-
const fullPath =
|
|
46575
|
+
const fullPath = path24.resolve(dir, path24.normalize(filePath));
|
|
46513
46576
|
if (!fullPath.startsWith(dir)) {
|
|
46514
46577
|
this.json(res, 403, { error: "Forbidden" });
|
|
46515
46578
|
return;
|
|
46516
46579
|
}
|
|
46517
46580
|
try {
|
|
46518
|
-
if (
|
|
46519
|
-
|
|
46520
|
-
|
|
46581
|
+
if (fs15.existsSync(fullPath)) fs15.copyFileSync(fullPath, fullPath + ".bak");
|
|
46582
|
+
fs15.mkdirSync(path24.dirname(fullPath), { recursive: true });
|
|
46583
|
+
fs15.writeFileSync(fullPath, content, "utf-8");
|
|
46521
46584
|
this.log(`File saved: ${fullPath} (${content.length} chars)`);
|
|
46522
46585
|
this.providerLoader.reload();
|
|
46523
46586
|
this.json(res, 200, { saved: true, path: filePath, chars: content.length });
|
|
@@ -46533,9 +46596,9 @@ var init_dev_server = __esm({
|
|
|
46533
46596
|
return;
|
|
46534
46597
|
}
|
|
46535
46598
|
for (const name of ["scripts.js", "provider.json"]) {
|
|
46536
|
-
const p =
|
|
46537
|
-
if (
|
|
46538
|
-
const source =
|
|
46599
|
+
const p = path24.join(dir, name);
|
|
46600
|
+
if (fs15.existsSync(p)) {
|
|
46601
|
+
const source = fs15.readFileSync(p, "utf-8");
|
|
46539
46602
|
this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
|
|
46540
46603
|
return;
|
|
46541
46604
|
}
|
|
@@ -46554,11 +46617,11 @@ var init_dev_server = __esm({
|
|
|
46554
46617
|
this.json(res, 404, { error: `Provider not found: ${type}` });
|
|
46555
46618
|
return;
|
|
46556
46619
|
}
|
|
46557
|
-
const target =
|
|
46558
|
-
const targetPath =
|
|
46620
|
+
const target = fs15.existsSync(path24.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
|
|
46621
|
+
const targetPath = path24.join(dir, target);
|
|
46559
46622
|
try {
|
|
46560
|
-
if (
|
|
46561
|
-
|
|
46623
|
+
if (fs15.existsSync(targetPath)) fs15.copyFileSync(targetPath, targetPath + ".bak");
|
|
46624
|
+
fs15.writeFileSync(targetPath, source, "utf-8");
|
|
46562
46625
|
this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
|
|
46563
46626
|
this.providerLoader.reload();
|
|
46564
46627
|
this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
|
|
@@ -46702,21 +46765,21 @@ var init_dev_server = __esm({
|
|
|
46702
46765
|
}
|
|
46703
46766
|
let targetDir;
|
|
46704
46767
|
targetDir = this.providerLoader.getUserProviderDir(category, type);
|
|
46705
|
-
const jsonPath =
|
|
46706
|
-
if (
|
|
46768
|
+
const jsonPath = path24.join(targetDir, "provider.json");
|
|
46769
|
+
if (fs15.existsSync(jsonPath)) {
|
|
46707
46770
|
this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
|
|
46708
46771
|
return;
|
|
46709
46772
|
}
|
|
46710
46773
|
try {
|
|
46711
46774
|
const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2, osPaths, processNames });
|
|
46712
|
-
|
|
46713
|
-
|
|
46775
|
+
fs15.mkdirSync(targetDir, { recursive: true });
|
|
46776
|
+
fs15.writeFileSync(jsonPath, result["provider.json"], "utf-8");
|
|
46714
46777
|
const createdFiles = ["provider.json"];
|
|
46715
46778
|
if (result.files) {
|
|
46716
46779
|
for (const [relPath, content] of Object.entries(result.files)) {
|
|
46717
|
-
const fullPath =
|
|
46718
|
-
|
|
46719
|
-
|
|
46780
|
+
const fullPath = path24.join(targetDir, relPath);
|
|
46781
|
+
fs15.mkdirSync(path24.dirname(fullPath), { recursive: true });
|
|
46782
|
+
fs15.writeFileSync(fullPath, content, "utf-8");
|
|
46720
46783
|
createdFiles.push(relPath);
|
|
46721
46784
|
}
|
|
46722
46785
|
}
|
|
@@ -46765,38 +46828,38 @@ var init_dev_server = __esm({
|
|
|
46765
46828
|
}
|
|
46766
46829
|
// ─── Phase 2: Auto-Implement Backend ───
|
|
46767
46830
|
getLatestScriptVersionDir(scriptsDir) {
|
|
46768
|
-
if (!
|
|
46769
|
-
const versions =
|
|
46831
|
+
if (!fs15.existsSync(scriptsDir)) return null;
|
|
46832
|
+
const versions = fs15.readdirSync(scriptsDir).filter((d) => {
|
|
46770
46833
|
try {
|
|
46771
|
-
return
|
|
46834
|
+
return fs15.statSync(path24.join(scriptsDir, d)).isDirectory();
|
|
46772
46835
|
} catch {
|
|
46773
46836
|
return false;
|
|
46774
46837
|
}
|
|
46775
46838
|
}).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
|
|
46776
46839
|
if (versions.length === 0) return null;
|
|
46777
|
-
return
|
|
46840
|
+
return path24.join(scriptsDir, versions[0]);
|
|
46778
46841
|
}
|
|
46779
46842
|
resolveAutoImplWritableProviderDir(category, type, requestedDir) {
|
|
46780
|
-
const canonicalUserDir =
|
|
46781
|
-
const desiredDir = requestedDir ?
|
|
46782
|
-
const upstreamRoot =
|
|
46783
|
-
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${
|
|
46843
|
+
const canonicalUserDir = path24.resolve(this.providerLoader.getUserProviderDir(category, type));
|
|
46844
|
+
const desiredDir = requestedDir ? path24.resolve(requestedDir) : canonicalUserDir;
|
|
46845
|
+
const upstreamRoot = path24.resolve(this.providerLoader.getUpstreamDir());
|
|
46846
|
+
if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path24.sep}`)) {
|
|
46784
46847
|
return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
|
|
46785
46848
|
}
|
|
46786
|
-
if (
|
|
46849
|
+
if (path24.basename(desiredDir) !== type) {
|
|
46787
46850
|
return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
|
|
46788
46851
|
}
|
|
46789
46852
|
const sourceDir = this.findProviderDir(type);
|
|
46790
46853
|
if (!sourceDir) {
|
|
46791
46854
|
return { dir: null, reason: `Provider source directory not found for '${type}'` };
|
|
46792
46855
|
}
|
|
46793
|
-
if (!
|
|
46794
|
-
|
|
46795
|
-
|
|
46856
|
+
if (!fs15.existsSync(desiredDir)) {
|
|
46857
|
+
fs15.mkdirSync(path24.dirname(desiredDir), { recursive: true });
|
|
46858
|
+
fs15.cpSync(sourceDir, desiredDir, { recursive: true });
|
|
46796
46859
|
this.log(`Auto-implement writable copy created: ${desiredDir}`);
|
|
46797
46860
|
}
|
|
46798
|
-
const providerJson =
|
|
46799
|
-
if (!
|
|
46861
|
+
const providerJson = path24.join(desiredDir, "provider.json");
|
|
46862
|
+
if (!fs15.existsSync(providerJson)) {
|
|
46800
46863
|
return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
|
|
46801
46864
|
}
|
|
46802
46865
|
return { dir: desiredDir };
|
|
@@ -46831,7 +46894,7 @@ var init_dev_server = __esm({
|
|
|
46831
46894
|
setMode: "set_mode.js"
|
|
46832
46895
|
};
|
|
46833
46896
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
46834
|
-
const scriptsDir =
|
|
46897
|
+
const scriptsDir = path24.join(providerDir, "scripts");
|
|
46835
46898
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
46836
46899
|
if (latestScriptsDir) {
|
|
46837
46900
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -46839,10 +46902,10 @@ var init_dev_server = __esm({
|
|
|
46839
46902
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
46840
46903
|
lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
|
|
46841
46904
|
lines.push("");
|
|
46842
|
-
for (const file2 of
|
|
46905
|
+
for (const file2 of fs15.readdirSync(latestScriptsDir)) {
|
|
46843
46906
|
if (file2.endsWith(".js") && targetFileNames.has(file2)) {
|
|
46844
46907
|
try {
|
|
46845
|
-
const content =
|
|
46908
|
+
const content = fs15.readFileSync(path24.join(latestScriptsDir, file2), "utf-8");
|
|
46846
46909
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
46847
46910
|
lines.push("```javascript");
|
|
46848
46911
|
lines.push(content);
|
|
@@ -46852,14 +46915,14 @@ var init_dev_server = __esm({
|
|
|
46852
46915
|
}
|
|
46853
46916
|
}
|
|
46854
46917
|
}
|
|
46855
|
-
const refFiles =
|
|
46918
|
+
const refFiles = fs15.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
46856
46919
|
if (refFiles.length > 0) {
|
|
46857
46920
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
46858
46921
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
46859
46922
|
lines.push("");
|
|
46860
46923
|
for (const file2 of refFiles) {
|
|
46861
46924
|
try {
|
|
46862
|
-
const content =
|
|
46925
|
+
const content = fs15.readFileSync(path24.join(latestScriptsDir, file2), "utf-8");
|
|
46863
46926
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
46864
46927
|
lines.push("```javascript");
|
|
46865
46928
|
lines.push(content);
|
|
@@ -46900,11 +46963,11 @@ var init_dev_server = __esm({
|
|
|
46900
46963
|
lines.push("");
|
|
46901
46964
|
}
|
|
46902
46965
|
}
|
|
46903
|
-
const docsDir =
|
|
46966
|
+
const docsDir = path24.join(providerDir, "../../docs");
|
|
46904
46967
|
const loadGuide = (name) => {
|
|
46905
46968
|
try {
|
|
46906
|
-
const p =
|
|
46907
|
-
if (
|
|
46969
|
+
const p = path24.join(docsDir, name);
|
|
46970
|
+
if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
|
|
46908
46971
|
} catch {
|
|
46909
46972
|
}
|
|
46910
46973
|
return null;
|
|
@@ -47077,7 +47140,7 @@ var init_dev_server = __esm({
|
|
|
47077
47140
|
parseApproval: "parse_approval.js"
|
|
47078
47141
|
};
|
|
47079
47142
|
const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
|
|
47080
|
-
const scriptsDir =
|
|
47143
|
+
const scriptsDir = path24.join(providerDir, "scripts");
|
|
47081
47144
|
const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
|
|
47082
47145
|
if (latestScriptsDir) {
|
|
47083
47146
|
lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
|
|
@@ -47085,11 +47148,11 @@ var init_dev_server = __esm({
|
|
|
47085
47148
|
lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
|
|
47086
47149
|
lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
|
|
47087
47150
|
lines.push("");
|
|
47088
|
-
for (const file2 of
|
|
47151
|
+
for (const file2 of fs15.readdirSync(latestScriptsDir)) {
|
|
47089
47152
|
if (!file2.endsWith(".js")) continue;
|
|
47090
47153
|
if (!targetFileNames.has(file2)) continue;
|
|
47091
47154
|
try {
|
|
47092
|
-
const content =
|
|
47155
|
+
const content = fs15.readFileSync(path24.join(latestScriptsDir, file2), "utf-8");
|
|
47093
47156
|
lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
|
|
47094
47157
|
lines.push("```javascript");
|
|
47095
47158
|
lines.push(content);
|
|
@@ -47098,14 +47161,14 @@ var init_dev_server = __esm({
|
|
|
47098
47161
|
} catch {
|
|
47099
47162
|
}
|
|
47100
47163
|
}
|
|
47101
|
-
const refFiles =
|
|
47164
|
+
const refFiles = fs15.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
|
|
47102
47165
|
if (refFiles.length > 0) {
|
|
47103
47166
|
lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
|
|
47104
47167
|
lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
|
|
47105
47168
|
lines.push("");
|
|
47106
47169
|
for (const file2 of refFiles) {
|
|
47107
47170
|
try {
|
|
47108
|
-
const content =
|
|
47171
|
+
const content = fs15.readFileSync(path24.join(latestScriptsDir, file2), "utf-8");
|
|
47109
47172
|
lines.push(`### \`${file2}\` \u{1F512}`);
|
|
47110
47173
|
lines.push("```javascript");
|
|
47111
47174
|
lines.push(content);
|
|
@@ -47138,11 +47201,11 @@ var init_dev_server = __esm({
|
|
|
47138
47201
|
lines.push("");
|
|
47139
47202
|
}
|
|
47140
47203
|
}
|
|
47141
|
-
const docsDir =
|
|
47204
|
+
const docsDir = path24.join(providerDir, "../../docs");
|
|
47142
47205
|
const loadGuide = (name) => {
|
|
47143
47206
|
try {
|
|
47144
|
-
const p =
|
|
47145
|
-
if (
|
|
47207
|
+
const p = path24.join(docsDir, name);
|
|
47208
|
+
if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
|
|
47146
47209
|
} catch {
|
|
47147
47210
|
}
|
|
47148
47211
|
return null;
|
|
@@ -47952,8 +48015,8 @@ async function installExtension(ide, extension) {
|
|
|
47952
48015
|
const res = await fetch(extension.vsixUrl);
|
|
47953
48016
|
if (res.ok) {
|
|
47954
48017
|
const buffer = Buffer.from(await res.arrayBuffer());
|
|
47955
|
-
const
|
|
47956
|
-
|
|
48018
|
+
const fs23 = await import("fs");
|
|
48019
|
+
fs23.writeFileSync(vsixPath, buffer);
|
|
47957
48020
|
return new Promise((resolve18) => {
|
|
47958
48021
|
const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
|
|
47959
48022
|
(0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
|
|
@@ -60117,15 +60180,15 @@ var require_route = __commonJS({
|
|
|
60117
60180
|
};
|
|
60118
60181
|
}
|
|
60119
60182
|
function wrapConversion(toModel, graph) {
|
|
60120
|
-
const
|
|
60183
|
+
const path36 = [graph[toModel].parent, toModel];
|
|
60121
60184
|
let fn = conversions[graph[toModel].parent][toModel];
|
|
60122
60185
|
let cur = graph[toModel].parent;
|
|
60123
60186
|
while (graph[cur].parent) {
|
|
60124
|
-
|
|
60187
|
+
path36.unshift(graph[cur].parent);
|
|
60125
60188
|
fn = link(conversions[graph[cur].parent][cur], fn);
|
|
60126
60189
|
cur = graph[cur].parent;
|
|
60127
60190
|
}
|
|
60128
|
-
fn.conversion =
|
|
60191
|
+
fn.conversion = path36;
|
|
60129
60192
|
return fn;
|
|
60130
60193
|
}
|
|
60131
60194
|
module2.exports = function(fromModel) {
|
|
@@ -60522,7 +60585,7 @@ var require_has_flag = __commonJS({
|
|
|
60522
60585
|
var require_supports_color = __commonJS({
|
|
60523
60586
|
"../../node_modules/supports-color/index.js"(exports2, module2) {
|
|
60524
60587
|
"use strict";
|
|
60525
|
-
var
|
|
60588
|
+
var os31 = require("os");
|
|
60526
60589
|
var tty3 = require("tty");
|
|
60527
60590
|
var hasFlag3 = require_has_flag();
|
|
60528
60591
|
var { env: env3 } = process;
|
|
@@ -60570,7 +60633,7 @@ var require_supports_color = __commonJS({
|
|
|
60570
60633
|
return min;
|
|
60571
60634
|
}
|
|
60572
60635
|
if (process.platform === "win32") {
|
|
60573
|
-
const osRelease =
|
|
60636
|
+
const osRelease = os31.release().split(".");
|
|
60574
60637
|
if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
|
|
60575
60638
|
return Number(osRelease[2]) >= 14931 ? 3 : 2;
|
|
60576
60639
|
}
|
|
@@ -63423,7 +63486,7 @@ var require_buffer_list = __commonJS({
|
|
|
63423
63486
|
}
|
|
63424
63487
|
}, {
|
|
63425
63488
|
key: "join",
|
|
63426
|
-
value: function
|
|
63489
|
+
value: function join34(s) {
|
|
63427
63490
|
if (this.length === 0) return "";
|
|
63428
63491
|
var p = this.head;
|
|
63429
63492
|
var ret = "" + p.data;
|
|
@@ -73546,10 +73609,10 @@ var require_lib = __commonJS({
|
|
|
73546
73609
|
exports2.analyse = analyse;
|
|
73547
73610
|
var detectFile = (filepath, opts = {}) => new Promise((resolve18, reject) => {
|
|
73548
73611
|
let fd;
|
|
73549
|
-
const
|
|
73612
|
+
const fs23 = (0, node_1.default)();
|
|
73550
73613
|
const handler = (err, buffer) => {
|
|
73551
73614
|
if (fd) {
|
|
73552
|
-
|
|
73615
|
+
fs23.closeSync(fd);
|
|
73553
73616
|
}
|
|
73554
73617
|
if (err) {
|
|
73555
73618
|
reject(err);
|
|
@@ -73561,9 +73624,9 @@ var require_lib = __commonJS({
|
|
|
73561
73624
|
};
|
|
73562
73625
|
const sampleSize = (opts === null || opts === void 0 ? void 0 : opts.sampleSize) || 0;
|
|
73563
73626
|
if (sampleSize > 0) {
|
|
73564
|
-
fd =
|
|
73627
|
+
fd = fs23.openSync(filepath, "r");
|
|
73565
73628
|
let sample = Buffer.allocUnsafe(sampleSize);
|
|
73566
|
-
|
|
73629
|
+
fs23.read(fd, sample, 0, sampleSize, opts.offset, (err, bytesRead) => {
|
|
73567
73630
|
if (err) {
|
|
73568
73631
|
handler(err, null);
|
|
73569
73632
|
} else {
|
|
@@ -73575,22 +73638,22 @@ var require_lib = __commonJS({
|
|
|
73575
73638
|
});
|
|
73576
73639
|
return;
|
|
73577
73640
|
}
|
|
73578
|
-
|
|
73641
|
+
fs23.readFile(filepath, handler);
|
|
73579
73642
|
});
|
|
73580
73643
|
exports2.detectFile = detectFile;
|
|
73581
73644
|
var detectFileSync = (filepath, opts = {}) => {
|
|
73582
|
-
const
|
|
73645
|
+
const fs23 = (0, node_1.default)();
|
|
73583
73646
|
if (opts && opts.sampleSize) {
|
|
73584
|
-
const fd =
|
|
73647
|
+
const fd = fs23.openSync(filepath, "r");
|
|
73585
73648
|
let sample = Buffer.allocUnsafe(opts.sampleSize);
|
|
73586
|
-
const bytesRead =
|
|
73649
|
+
const bytesRead = fs23.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
|
|
73587
73650
|
if (bytesRead < opts.sampleSize) {
|
|
73588
73651
|
sample = sample.subarray(0, bytesRead);
|
|
73589
73652
|
}
|
|
73590
|
-
|
|
73653
|
+
fs23.closeSync(fd);
|
|
73591
73654
|
return (0, exports2.detect)(sample);
|
|
73592
73655
|
}
|
|
73593
|
-
return (0, exports2.detect)(
|
|
73656
|
+
return (0, exports2.detect)(fs23.readFileSync(filepath));
|
|
73594
73657
|
};
|
|
73595
73658
|
exports2.detectFileSync = detectFileSync;
|
|
73596
73659
|
exports2.default = {
|
|
@@ -77482,7 +77545,7 @@ function splitStringBySpace(str) {
|
|
|
77482
77545
|
}
|
|
77483
77546
|
return pieces;
|
|
77484
77547
|
}
|
|
77485
|
-
var import_chardet, import_child_process12, import_fs6, import_node_path2, import_node_os4,
|
|
77548
|
+
var import_chardet, import_child_process12, import_fs6, import_node_path2, import_node_os4, import_node_crypto2, import_iconv_lite, ExternalEditor;
|
|
77486
77549
|
var init_esm2 = __esm({
|
|
77487
77550
|
"../../node_modules/@inquirer/external-editor/dist/esm/index.js"() {
|
|
77488
77551
|
"use strict";
|
|
@@ -77491,7 +77554,7 @@ var init_esm2 = __esm({
|
|
|
77491
77554
|
import_fs6 = require("fs");
|
|
77492
77555
|
import_node_path2 = __toESM(require("path"), 1);
|
|
77493
77556
|
import_node_os4 = __toESM(require("os"), 1);
|
|
77494
|
-
|
|
77557
|
+
import_node_crypto2 = require("crypto");
|
|
77495
77558
|
import_iconv_lite = __toESM(require_lib2(), 1);
|
|
77496
77559
|
init_CreateFileError();
|
|
77497
77560
|
init_LaunchEditorError();
|
|
@@ -77550,7 +77613,7 @@ var init_esm2 = __esm({
|
|
|
77550
77613
|
createTemporaryFile() {
|
|
77551
77614
|
try {
|
|
77552
77615
|
const baseDir = this.fileOptions.dir ?? import_node_os4.default.tmpdir();
|
|
77553
|
-
const id = (0,
|
|
77616
|
+
const id = (0, import_node_crypto2.randomUUID)();
|
|
77554
77617
|
const prefix = sanitizeAffix(this.fileOptions.prefix);
|
|
77555
77618
|
const postfix = sanitizeAffix(this.fileOptions.postfix);
|
|
77556
77619
|
const filename = `${prefix}${id}${postfix}`;
|
|
@@ -77995,9 +78058,9 @@ var init_prompt = __esm({
|
|
|
77995
78058
|
init_utils();
|
|
77996
78059
|
init_baseUI();
|
|
77997
78060
|
_ = {
|
|
77998
|
-
set: (obj,
|
|
78061
|
+
set: (obj, path36 = "", value) => {
|
|
77999
78062
|
let pointer = obj;
|
|
78000
|
-
|
|
78063
|
+
path36.split(".").forEach((key, index, arr) => {
|
|
78001
78064
|
if (key === "__proto__" || key === "constructor") return;
|
|
78002
78065
|
if (index === arr.length - 1) {
|
|
78003
78066
|
pointer[key] = value;
|
|
@@ -78007,8 +78070,8 @@ var init_prompt = __esm({
|
|
|
78007
78070
|
pointer = pointer[key];
|
|
78008
78071
|
});
|
|
78009
78072
|
},
|
|
78010
|
-
get: (obj,
|
|
78011
|
-
const travel = (regexp) => String.prototype.split.call(
|
|
78073
|
+
get: (obj, path36 = "", defaultValue) => {
|
|
78074
|
+
const travel = (regexp) => String.prototype.split.call(path36, regexp).filter(Boolean).reduce(
|
|
78012
78075
|
// @ts-expect-error implicit any on res[key]
|
|
78013
78076
|
(res, key) => res !== null && res !== void 0 ? res[key] : res,
|
|
78014
78077
|
obj
|
|
@@ -80053,12 +80116,14 @@ var init_data_channel_router = __esm({
|
|
|
80053
80116
|
});
|
|
80054
80117
|
|
|
80055
80118
|
// src/daemon-p2p/screenshot-sender.ts
|
|
80056
|
-
var CHUNK_SIZE, ScreenshotSender;
|
|
80119
|
+
var CHUNK_SIZE, MAX_INLINE_JSON_MESSAGE_BYTES, JSON_CHUNK_PAYLOAD_CHARS2, ScreenshotSender;
|
|
80057
80120
|
var init_screenshot_sender = __esm({
|
|
80058
80121
|
"src/daemon-p2p/screenshot-sender.ts"() {
|
|
80059
80122
|
"use strict";
|
|
80060
80123
|
init_log();
|
|
80061
80124
|
CHUNK_SIZE = 6e4;
|
|
80125
|
+
MAX_INLINE_JSON_MESSAGE_BYTES = 6e4;
|
|
80126
|
+
JSON_CHUNK_PAYLOAD_CHARS2 = 16e3;
|
|
80062
80127
|
ScreenshotSender = class {
|
|
80063
80128
|
_ssDebugDone = false;
|
|
80064
80129
|
sendStatus(peers, status) {
|
|
@@ -80097,16 +80162,43 @@ var init_screenshot_sender = __esm({
|
|
|
80097
80162
|
}
|
|
80098
80163
|
sendTopicUpdateToPeer(peer, update) {
|
|
80099
80164
|
if (!peer?.dataChannel || peer.state !== "connected" || !peer.dataChannel.isOpen()) return false;
|
|
80165
|
+
const json2 = JSON.stringify({
|
|
80166
|
+
type: "topic_update",
|
|
80167
|
+
update
|
|
80168
|
+
});
|
|
80169
|
+
if (Buffer.byteLength(json2, "utf8") > MAX_INLINE_JSON_MESSAGE_BYTES) {
|
|
80170
|
+
return this.sendChunkedTopicUpdate(peer, update, json2);
|
|
80171
|
+
}
|
|
80100
80172
|
try {
|
|
80101
|
-
peer.dataChannel.sendMessage(
|
|
80102
|
-
type: "topic_update",
|
|
80103
|
-
update
|
|
80104
|
-
}));
|
|
80173
|
+
peer.dataChannel.sendMessage(json2);
|
|
80105
80174
|
return true;
|
|
80106
80175
|
} catch {
|
|
80107
80176
|
return false;
|
|
80108
80177
|
}
|
|
80109
80178
|
}
|
|
80179
|
+
sendChunkedTopicUpdate(peer, update, json2) {
|
|
80180
|
+
const topic = typeof update?.topic === "string" ? update.topic : "topic_update";
|
|
80181
|
+
const key = typeof update?.key === "string" ? update.key : "";
|
|
80182
|
+
const seq = typeof update?.seq === "number" ? update.seq : Date.now();
|
|
80183
|
+
const chunkId = `${topic}:${key}:${seq}:${Math.random().toString(36).slice(2, 8)}`;
|
|
80184
|
+
const total = Math.ceil(json2.length / JSON_CHUNK_PAYLOAD_CHARS2);
|
|
80185
|
+
logDebug(`topic_update chunked: peer=${peer.peerId || "unknown"} topic=${topic} key=${key || "-"} chars=${json2.length} chunks=${total}`);
|
|
80186
|
+
for (let index = 0; index < total; index += 1) {
|
|
80187
|
+
const chunk = json2.slice(index * JSON_CHUNK_PAYLOAD_CHARS2, (index + 1) * JSON_CHUNK_PAYLOAD_CHARS2);
|
|
80188
|
+
try {
|
|
80189
|
+
peer.dataChannel?.sendMessage(JSON.stringify({
|
|
80190
|
+
type: "topic_update_chunk",
|
|
80191
|
+
chunkId,
|
|
80192
|
+
index,
|
|
80193
|
+
total,
|
|
80194
|
+
data: chunk
|
|
80195
|
+
}));
|
|
80196
|
+
} catch {
|
|
80197
|
+
return false;
|
|
80198
|
+
}
|
|
80199
|
+
}
|
|
80200
|
+
return true;
|
|
80201
|
+
}
|
|
80110
80202
|
/** Broadcast runtime session output to all connected peers */
|
|
80111
80203
|
broadcastSessionOutput(peers, sessionId, data) {
|
|
80112
80204
|
const msg = JSON.stringify({ type: "session_output", sessionId, data });
|
|
@@ -80537,12 +80629,12 @@ var init_peer_connection_manager = __esm({
|
|
|
80537
80629
|
});
|
|
80538
80630
|
|
|
80539
80631
|
// src/daemon-p2p/index.ts
|
|
80540
|
-
var
|
|
80632
|
+
var fs16, path26, import_node_module2, esmRequire, DaemonP2PSender;
|
|
80541
80633
|
var init_daemon_p2p = __esm({
|
|
80542
80634
|
"src/daemon-p2p/index.ts"() {
|
|
80543
80635
|
"use strict";
|
|
80544
|
-
|
|
80545
|
-
|
|
80636
|
+
fs16 = __toESM(require("fs"));
|
|
80637
|
+
path26 = __toESM(require("path"));
|
|
80546
80638
|
import_node_module2 = require("module");
|
|
80547
80639
|
init_src();
|
|
80548
80640
|
init_data_channel_router();
|
|
@@ -80621,17 +80713,17 @@ ${e?.stack || ""}`);
|
|
|
80621
80713
|
const prebuildKey = `${platform12}-${arch3}`;
|
|
80622
80714
|
try {
|
|
80623
80715
|
const candidates = [
|
|
80624
|
-
|
|
80625
|
-
|
|
80626
|
-
|
|
80716
|
+
path26.join(__dirname, "node_modules", "node-datachannel"),
|
|
80717
|
+
path26.join(__dirname, "..", "node_modules", "node-datachannel"),
|
|
80718
|
+
path26.join(__dirname, "..", "..", "node_modules", "node-datachannel")
|
|
80627
80719
|
];
|
|
80628
80720
|
for (const candidate of candidates) {
|
|
80629
|
-
const prebuildPath =
|
|
80630
|
-
if (
|
|
80631
|
-
const targetDir =
|
|
80632
|
-
const targetPath =
|
|
80633
|
-
|
|
80634
|
-
|
|
80721
|
+
const prebuildPath = path26.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
|
|
80722
|
+
if (fs16.existsSync(prebuildPath)) {
|
|
80723
|
+
const targetDir = path26.join(candidate, "build", "Release");
|
|
80724
|
+
const targetPath = path26.join(targetDir, "node_datachannel.node");
|
|
80725
|
+
fs16.mkdirSync(targetDir, { recursive: true });
|
|
80726
|
+
fs16.copyFileSync(prebuildPath, targetPath);
|
|
80635
80727
|
try {
|
|
80636
80728
|
delete esmRequire.cache[esmRequire.resolve("node-datachannel")];
|
|
80637
80729
|
} catch {
|
|
@@ -80998,27 +81090,27 @@ var require_process = __commonJS({
|
|
|
80998
81090
|
var require_filesystem = __commonJS({
|
|
80999
81091
|
"../../node_modules/detect-libc/lib/filesystem.js"(exports2, module2) {
|
|
81000
81092
|
"use strict";
|
|
81001
|
-
var
|
|
81093
|
+
var fs23 = require("fs");
|
|
81002
81094
|
var LDD_PATH = "/usr/bin/ldd";
|
|
81003
81095
|
var SELF_PATH = "/proc/self/exe";
|
|
81004
81096
|
var MAX_LENGTH = 2048;
|
|
81005
|
-
var readFileSync20 = (
|
|
81006
|
-
const fd =
|
|
81097
|
+
var readFileSync20 = (path36) => {
|
|
81098
|
+
const fd = fs23.openSync(path36, "r");
|
|
81007
81099
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
81008
|
-
const bytesRead =
|
|
81009
|
-
|
|
81100
|
+
const bytesRead = fs23.readSync(fd, buffer, 0, MAX_LENGTH, 0);
|
|
81101
|
+
fs23.close(fd, () => {
|
|
81010
81102
|
});
|
|
81011
81103
|
return buffer.subarray(0, bytesRead);
|
|
81012
81104
|
};
|
|
81013
|
-
var readFile = (
|
|
81014
|
-
|
|
81105
|
+
var readFile = (path36) => new Promise((resolve18, reject) => {
|
|
81106
|
+
fs23.open(path36, "r", (err, fd) => {
|
|
81015
81107
|
if (err) {
|
|
81016
81108
|
reject(err);
|
|
81017
81109
|
} else {
|
|
81018
81110
|
const buffer = Buffer.alloc(MAX_LENGTH);
|
|
81019
|
-
|
|
81111
|
+
fs23.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
|
|
81020
81112
|
resolve18(buffer.subarray(0, bytesRead));
|
|
81021
|
-
|
|
81113
|
+
fs23.close(fd, () => {
|
|
81022
81114
|
});
|
|
81023
81115
|
});
|
|
81024
81116
|
}
|
|
@@ -81130,11 +81222,11 @@ var require_detect_libc = __commonJS({
|
|
|
81130
81222
|
}
|
|
81131
81223
|
return null;
|
|
81132
81224
|
};
|
|
81133
|
-
var familyFromInterpreterPath = (
|
|
81134
|
-
if (
|
|
81135
|
-
if (
|
|
81225
|
+
var familyFromInterpreterPath = (path36) => {
|
|
81226
|
+
if (path36) {
|
|
81227
|
+
if (path36.includes("/ld-musl-")) {
|
|
81136
81228
|
return MUSL;
|
|
81137
|
-
} else if (
|
|
81229
|
+
} else if (path36.includes("/ld-linux-")) {
|
|
81138
81230
|
return GLIBC;
|
|
81139
81231
|
}
|
|
81140
81232
|
}
|
|
@@ -81181,8 +81273,8 @@ var require_detect_libc = __commonJS({
|
|
|
81181
81273
|
cachedFamilyInterpreter = null;
|
|
81182
81274
|
try {
|
|
81183
81275
|
const selfContent = await readFile(SELF_PATH);
|
|
81184
|
-
const
|
|
81185
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
81276
|
+
const path36 = interpreterPath(selfContent);
|
|
81277
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path36);
|
|
81186
81278
|
} catch (e) {
|
|
81187
81279
|
}
|
|
81188
81280
|
return cachedFamilyInterpreter;
|
|
@@ -81194,8 +81286,8 @@ var require_detect_libc = __commonJS({
|
|
|
81194
81286
|
cachedFamilyInterpreter = null;
|
|
81195
81287
|
try {
|
|
81196
81288
|
const selfContent = readFileSync20(SELF_PATH);
|
|
81197
|
-
const
|
|
81198
|
-
cachedFamilyInterpreter = familyFromInterpreterPath(
|
|
81289
|
+
const path36 = interpreterPath(selfContent);
|
|
81290
|
+
cachedFamilyInterpreter = familyFromInterpreterPath(path36);
|
|
81199
81291
|
} catch (e) {
|
|
81200
81292
|
}
|
|
81201
81293
|
return cachedFamilyInterpreter;
|
|
@@ -82914,18 +83006,18 @@ var require_sharp = __commonJS({
|
|
|
82914
83006
|
`@img/sharp-${runtimePlatform}/sharp.node`,
|
|
82915
83007
|
"@img/sharp-wasm32/sharp.node"
|
|
82916
83008
|
];
|
|
82917
|
-
var
|
|
83009
|
+
var path36;
|
|
82918
83010
|
var sharp;
|
|
82919
83011
|
var errors = [];
|
|
82920
|
-
for (
|
|
83012
|
+
for (path36 of paths) {
|
|
82921
83013
|
try {
|
|
82922
|
-
sharp = require(
|
|
83014
|
+
sharp = require(path36);
|
|
82923
83015
|
break;
|
|
82924
83016
|
} catch (err) {
|
|
82925
83017
|
errors.push(err);
|
|
82926
83018
|
}
|
|
82927
83019
|
}
|
|
82928
|
-
if (sharp &&
|
|
83020
|
+
if (sharp && path36.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
|
|
82929
83021
|
const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
|
|
82930
83022
|
err.code = "Unsupported CPU";
|
|
82931
83023
|
errors.push(err);
|
|
@@ -82934,7 +83026,7 @@ var require_sharp = __commonJS({
|
|
|
82934
83026
|
if (sharp) {
|
|
82935
83027
|
module2.exports = sharp;
|
|
82936
83028
|
} else {
|
|
82937
|
-
const [isLinux2, isMacOs, isWindows2] = ["linux", "darwin", "win32"].map((
|
|
83029
|
+
const [isLinux2, isMacOs, isWindows2] = ["linux", "darwin", "win32"].map((os31) => runtimePlatform.startsWith(os31));
|
|
82938
83030
|
const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
|
|
82939
83031
|
errors.forEach((err) => {
|
|
82940
83032
|
if (err.code !== "MODULE_NOT_FOUND") {
|
|
@@ -82951,15 +83043,15 @@ var require_sharp = __commonJS({
|
|
|
82951
83043
|
` Requires ${expected}`
|
|
82952
83044
|
);
|
|
82953
83045
|
} else if (prebuiltPlatforms.includes(runtimePlatform)) {
|
|
82954
|
-
const [
|
|
82955
|
-
const libc =
|
|
83046
|
+
const [os31, cpu] = runtimePlatform.split("-");
|
|
83047
|
+
const libc = os31.endsWith("musl") ? " --libc=musl" : "";
|
|
82956
83048
|
help.push(
|
|
82957
83049
|
"- Ensure optional dependencies can be installed:",
|
|
82958
83050
|
" npm install --include=optional sharp",
|
|
82959
83051
|
"- Ensure your package manager supports multi-platform installation:",
|
|
82960
83052
|
" See https://sharp.pixelplumbing.com/install#cross-platform",
|
|
82961
83053
|
"- Add platform-specific dependencies:",
|
|
82962
|
-
` npm install --os=${
|
|
83054
|
+
` npm install --os=${os31.replace("musl", "")}${libc} --cpu=${cpu} sharp`
|
|
82963
83055
|
);
|
|
82964
83056
|
} else {
|
|
82965
83057
|
help.push(
|
|
@@ -85834,15 +85926,15 @@ var require_color = __commonJS({
|
|
|
85834
85926
|
};
|
|
85835
85927
|
}
|
|
85836
85928
|
function wrapConversion(toModel, graph) {
|
|
85837
|
-
const
|
|
85929
|
+
const path36 = [graph[toModel].parent, toModel];
|
|
85838
85930
|
let fn = conversions_default[graph[toModel].parent][toModel];
|
|
85839
85931
|
let cur = graph[toModel].parent;
|
|
85840
85932
|
while (graph[cur].parent) {
|
|
85841
|
-
|
|
85933
|
+
path36.unshift(graph[cur].parent);
|
|
85842
85934
|
fn = link(conversions_default[graph[cur].parent][cur], fn);
|
|
85843
85935
|
cur = graph[cur].parent;
|
|
85844
85936
|
}
|
|
85845
|
-
fn.conversion =
|
|
85937
|
+
fn.conversion = path36;
|
|
85846
85938
|
return fn;
|
|
85847
85939
|
}
|
|
85848
85940
|
function route(fromModel) {
|
|
@@ -86459,7 +86551,7 @@ var require_channel = __commonJS({
|
|
|
86459
86551
|
var require_output = __commonJS({
|
|
86460
86552
|
"../../node_modules/sharp/lib/output.js"(exports2, module2) {
|
|
86461
86553
|
"use strict";
|
|
86462
|
-
var
|
|
86554
|
+
var path36 = require("path");
|
|
86463
86555
|
var is = require_is();
|
|
86464
86556
|
var sharp = require_sharp();
|
|
86465
86557
|
var formats = /* @__PURE__ */ new Map([
|
|
@@ -86490,9 +86582,9 @@ var require_output = __commonJS({
|
|
|
86490
86582
|
let err;
|
|
86491
86583
|
if (!is.string(fileOut)) {
|
|
86492
86584
|
err = new Error("Missing output file path");
|
|
86493
|
-
} else if (is.string(this.options.input.file) &&
|
|
86585
|
+
} else if (is.string(this.options.input.file) && path36.resolve(this.options.input.file) === path36.resolve(fileOut)) {
|
|
86494
86586
|
err = new Error("Cannot use same file for input and output");
|
|
86495
|
-
} else if (jp2Regex.test(
|
|
86587
|
+
} else if (jp2Regex.test(path36.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
|
|
86496
86588
|
err = errJp2Save();
|
|
86497
86589
|
}
|
|
86498
86590
|
if (err) {
|
|
@@ -87766,21 +87858,21 @@ function quarantineLegacyStandaloneSessions(options) {
|
|
|
87766
87858
|
if (shouldSkipForExplicitOverride(env3)) {
|
|
87767
87859
|
return { movedCount: 0, skippedActiveCount: 0, backupDir: null };
|
|
87768
87860
|
}
|
|
87769
|
-
const homeDir = options.homeDir ||
|
|
87861
|
+
const homeDir = options.homeDir || os26.homedir();
|
|
87770
87862
|
const now = options.now || (() => /* @__PURE__ */ new Date());
|
|
87771
87863
|
const isPidRunning = options.isPidRunning || defaultPidRunning;
|
|
87772
|
-
const runtimesDir =
|
|
87773
|
-
if (!
|
|
87864
|
+
const runtimesDir = path27.join(homeDir, ".adhdev", "session-host", options.appName, "runtimes");
|
|
87865
|
+
if (!fs17.existsSync(runtimesDir)) {
|
|
87774
87866
|
return { movedCount: 0, skippedActiveCount: 0, backupDir: null };
|
|
87775
87867
|
}
|
|
87776
|
-
const candidates =
|
|
87868
|
+
const candidates = fs17.readdirSync(runtimesDir).filter((name) => name.endsWith(".json")).map((name) => path27.join(runtimesDir, name));
|
|
87777
87869
|
let movedCount = 0;
|
|
87778
87870
|
let skippedActiveCount = 0;
|
|
87779
87871
|
let backupDir = null;
|
|
87780
87872
|
for (const sourcePath of candidates) {
|
|
87781
87873
|
let parsed;
|
|
87782
87874
|
try {
|
|
87783
|
-
parsed = JSON.parse(
|
|
87875
|
+
parsed = JSON.parse(fs17.readFileSync(sourcePath, "utf8"));
|
|
87784
87876
|
} catch {
|
|
87785
87877
|
continue;
|
|
87786
87878
|
}
|
|
@@ -87791,26 +87883,26 @@ function quarantineLegacyStandaloneSessions(options) {
|
|
|
87791
87883
|
continue;
|
|
87792
87884
|
}
|
|
87793
87885
|
if (!backupDir) {
|
|
87794
|
-
backupDir =
|
|
87886
|
+
backupDir = path27.join(
|
|
87795
87887
|
homeDir,
|
|
87796
87888
|
".adhdev",
|
|
87797
87889
|
"session-host-backups",
|
|
87798
87890
|
`legacy-standalone-${options.appName}-${formatTimestamp(now())}`
|
|
87799
87891
|
);
|
|
87800
|
-
|
|
87892
|
+
fs17.mkdirSync(path27.join(backupDir, "runtimes"), { recursive: true });
|
|
87801
87893
|
}
|
|
87802
|
-
|
|
87894
|
+
fs17.renameSync(sourcePath, path27.join(backupDir, "runtimes", path27.basename(sourcePath)));
|
|
87803
87895
|
movedCount += 1;
|
|
87804
87896
|
}
|
|
87805
87897
|
return { movedCount, skippedActiveCount, backupDir };
|
|
87806
87898
|
}
|
|
87807
|
-
var
|
|
87899
|
+
var fs17, os26, path27, LEGACY_STANDALONE_MANAGER_TAG;
|
|
87808
87900
|
var init_session_host_hygiene = __esm({
|
|
87809
87901
|
"src/session-host-hygiene.ts"() {
|
|
87810
87902
|
"use strict";
|
|
87811
|
-
|
|
87812
|
-
|
|
87813
|
-
|
|
87903
|
+
fs17 = __toESM(require("fs"));
|
|
87904
|
+
os26 = __toESM(require("os"));
|
|
87905
|
+
path27 = __toESM(require("path"));
|
|
87814
87906
|
init_src();
|
|
87815
87907
|
LEGACY_STANDALONE_MANAGER_TAG = "adhdev-standalone";
|
|
87816
87908
|
}
|
|
@@ -87834,18 +87926,18 @@ function buildSessionHostEnv(baseEnv) {
|
|
|
87834
87926
|
}
|
|
87835
87927
|
function resolveSessionHostEntry() {
|
|
87836
87928
|
const packagedCandidates = [
|
|
87837
|
-
|
|
87838
|
-
|
|
87929
|
+
path28.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
|
|
87930
|
+
path28.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
|
|
87839
87931
|
];
|
|
87840
87932
|
for (const candidate of packagedCandidates) {
|
|
87841
|
-
if (
|
|
87933
|
+
if (fs18.existsSync(candidate)) {
|
|
87842
87934
|
return candidate;
|
|
87843
87935
|
}
|
|
87844
87936
|
}
|
|
87845
87937
|
return require.resolve("@adhdev/session-host-daemon");
|
|
87846
87938
|
}
|
|
87847
87939
|
function getSessionHostPidFile() {
|
|
87848
|
-
return
|
|
87940
|
+
return path28.join(os27.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
|
|
87849
87941
|
}
|
|
87850
87942
|
function getSessionHostStatusPaths() {
|
|
87851
87943
|
return {
|
|
@@ -87856,8 +87948,8 @@ function getSessionHostStatusPaths() {
|
|
|
87856
87948
|
function getSessionHostPid() {
|
|
87857
87949
|
try {
|
|
87858
87950
|
const pidFile = getSessionHostPidFile();
|
|
87859
|
-
if (!
|
|
87860
|
-
const pid = Number.parseInt(
|
|
87951
|
+
if (!fs18.existsSync(pidFile)) return null;
|
|
87952
|
+
const pid = Number.parseInt(fs18.readFileSync(pidFile, "utf8").trim(), 10);
|
|
87861
87953
|
return Number.isFinite(pid) ? pid : null;
|
|
87862
87954
|
} catch {
|
|
87863
87955
|
return null;
|
|
@@ -87927,8 +88019,8 @@ function stopManagedSessionHostProcess() {
|
|
|
87927
88019
|
let stopped = false;
|
|
87928
88020
|
const pidFile = getSessionHostPidFile();
|
|
87929
88021
|
try {
|
|
87930
|
-
if (
|
|
87931
|
-
const pid = Number.parseInt(
|
|
88022
|
+
if (fs18.existsSync(pidFile)) {
|
|
88023
|
+
const pid = Number.parseInt(fs18.readFileSync(pidFile, "utf8").trim(), 10);
|
|
87932
88024
|
if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid2(pid)) {
|
|
87933
88025
|
stopped = killPid2(pid) || stopped;
|
|
87934
88026
|
}
|
|
@@ -87936,7 +88028,7 @@ function stopManagedSessionHostProcess() {
|
|
|
87936
88028
|
} catch {
|
|
87937
88029
|
} finally {
|
|
87938
88030
|
try {
|
|
87939
|
-
|
|
88031
|
+
fs18.unlinkSync(pidFile);
|
|
87940
88032
|
} catch {
|
|
87941
88033
|
}
|
|
87942
88034
|
}
|
|
@@ -87964,9 +88056,9 @@ async function ensureSessionHostReady2() {
|
|
|
87964
88056
|
}
|
|
87965
88057
|
const spawnHost = () => {
|
|
87966
88058
|
const entry = resolveSessionHostEntry();
|
|
87967
|
-
const logDir =
|
|
87968
|
-
|
|
87969
|
-
const logFd =
|
|
88059
|
+
const logDir = path28.join(os27.homedir(), ".adhdev", "logs");
|
|
88060
|
+
fs18.mkdirSync(logDir, { recursive: true });
|
|
88061
|
+
const logFd = fs18.openSync(path28.join(logDir, "session-host.log"), "a");
|
|
87970
88062
|
const child = (0, import_child_process13.spawn)(process.execPath, [entry], {
|
|
87971
88063
|
detached: true,
|
|
87972
88064
|
stdio: ["ignore", logFd, logFd],
|
|
@@ -87975,7 +88067,7 @@ async function ensureSessionHostReady2() {
|
|
|
87975
88067
|
});
|
|
87976
88068
|
child.unref();
|
|
87977
88069
|
try {
|
|
87978
|
-
|
|
88070
|
+
fs18.closeSync(logFd);
|
|
87979
88071
|
} catch {
|
|
87980
88072
|
}
|
|
87981
88073
|
};
|
|
@@ -88028,14 +88120,14 @@ async function probeSessionHostStatus() {
|
|
|
88028
88120
|
};
|
|
88029
88121
|
}
|
|
88030
88122
|
}
|
|
88031
|
-
var import_child_process13,
|
|
88123
|
+
var import_child_process13, fs18, os27, path28, SESSION_HOST_APP_NAME, SESSION_HOST_START_TIMEOUT_MS;
|
|
88032
88124
|
var init_session_host = __esm({
|
|
88033
88125
|
"src/session-host.ts"() {
|
|
88034
88126
|
"use strict";
|
|
88035
88127
|
import_child_process13 = require("child_process");
|
|
88036
|
-
|
|
88037
|
-
|
|
88038
|
-
|
|
88128
|
+
fs18 = __toESM(require("fs"));
|
|
88129
|
+
os27 = __toESM(require("os"));
|
|
88130
|
+
path28 = __toESM(require("path"));
|
|
88039
88131
|
init_src();
|
|
88040
88132
|
init_dist();
|
|
88041
88133
|
init_session_host_hygiene();
|
|
@@ -88266,22 +88358,22 @@ function resolveDaemonPort(ref = {}) {
|
|
|
88266
88358
|
return Number.isFinite(ref.port) && Number(ref.port) > 0 ? Number(ref.port) : DEFAULT_DAEMON_PORT;
|
|
88267
88359
|
}
|
|
88268
88360
|
function getDaemonPidFile(ref = {}) {
|
|
88269
|
-
const dir =
|
|
88270
|
-
if (!
|
|
88361
|
+
const dir = path29.join(ref.homeDir || os28.homedir(), ".adhdev");
|
|
88362
|
+
if (!fs19.existsSync(dir)) fs19.mkdirSync(dir, { recursive: true });
|
|
88271
88363
|
const port = resolveDaemonPort(ref);
|
|
88272
|
-
return
|
|
88364
|
+
return path29.join(dir, port === DEFAULT_DAEMON_PORT ? "daemon.pid" : `daemon-${port}.pid`);
|
|
88273
88365
|
}
|
|
88274
88366
|
function writeDaemonPid(pid, ref = {}) {
|
|
88275
88367
|
const pidFile = getDaemonPidFile(ref);
|
|
88276
88368
|
try {
|
|
88277
|
-
|
|
88369
|
+
fs19.writeFileSync(pidFile, String(pid), { encoding: "utf-8", flag: "wx" });
|
|
88278
88370
|
} catch {
|
|
88279
|
-
|
|
88371
|
+
fs19.writeFileSync(pidFile, String(pid), "utf-8");
|
|
88280
88372
|
}
|
|
88281
88373
|
}
|
|
88282
88374
|
function removeDaemonPid(ref = {}) {
|
|
88283
88375
|
try {
|
|
88284
|
-
|
|
88376
|
+
fs19.unlinkSync(getDaemonPidFile(ref));
|
|
88285
88377
|
} catch (e) {
|
|
88286
88378
|
}
|
|
88287
88379
|
}
|
|
@@ -88308,8 +88400,8 @@ function isDaemonRunning(ref = {}) {
|
|
|
88308
88400
|
}
|
|
88309
88401
|
const pidFile = getDaemonPidFile(ref);
|
|
88310
88402
|
try {
|
|
88311
|
-
if (!
|
|
88312
|
-
const pid = parseInt(
|
|
88403
|
+
if (!fs19.existsSync(pidFile)) return false;
|
|
88404
|
+
const pid = parseInt(fs19.readFileSync(pidFile, "utf-8").trim());
|
|
88313
88405
|
process.kill(pid, 0);
|
|
88314
88406
|
if (!isAdhdevProcess(pid)) {
|
|
88315
88407
|
removeDaemonPid(ref);
|
|
@@ -88386,8 +88478,8 @@ function getDaemonHealthPid(ref = {}) {
|
|
|
88386
88478
|
function getDaemonPid(ref = {}) {
|
|
88387
88479
|
const pidFile = getDaemonPidFile(ref);
|
|
88388
88480
|
try {
|
|
88389
|
-
if (
|
|
88390
|
-
const pid = parseInt(
|
|
88481
|
+
if (fs19.existsSync(pidFile)) {
|
|
88482
|
+
const pid = parseInt(fs19.readFileSync(pidFile, "utf-8").trim(), 10);
|
|
88391
88483
|
if (Number.isFinite(pid)) return pid;
|
|
88392
88484
|
}
|
|
88393
88485
|
} catch {
|
|
@@ -88398,8 +88490,8 @@ function stopDaemon(ref = {}) {
|
|
|
88398
88490
|
const pidFile = getDaemonPidFile(ref);
|
|
88399
88491
|
let pid = null;
|
|
88400
88492
|
try {
|
|
88401
|
-
if (
|
|
88402
|
-
const pidFromFile = parseInt(
|
|
88493
|
+
if (fs19.existsSync(pidFile)) {
|
|
88494
|
+
const pidFromFile = parseInt(fs19.readFileSync(pidFile, "utf-8").trim(), 10);
|
|
88403
88495
|
if (Number.isFinite(pidFromFile)) pid = pidFromFile;
|
|
88404
88496
|
}
|
|
88405
88497
|
} catch {
|
|
@@ -88418,7 +88510,7 @@ function stopDaemon(ref = {}) {
|
|
|
88418
88510
|
return false;
|
|
88419
88511
|
}
|
|
88420
88512
|
}
|
|
88421
|
-
var
|
|
88513
|
+
var os28, fs19, path29, import_http, import_child_process14, import_ws3, pkgVersion, AdhdevDaemon;
|
|
88422
88514
|
var init_adhdev_daemon = __esm({
|
|
88423
88515
|
"src/adhdev-daemon.ts"() {
|
|
88424
88516
|
"use strict";
|
|
@@ -88430,9 +88522,9 @@ var init_adhdev_daemon = __esm({
|
|
|
88430
88522
|
init_startup_restore_policy();
|
|
88431
88523
|
init_dist();
|
|
88432
88524
|
init_session_host_controller();
|
|
88433
|
-
|
|
88434
|
-
|
|
88435
|
-
|
|
88525
|
+
os28 = __toESM(require("os"));
|
|
88526
|
+
fs19 = __toESM(require("fs"));
|
|
88527
|
+
path29 = __toESM(require("path"));
|
|
88436
88528
|
import_http = require("http");
|
|
88437
88529
|
import_child_process14 = require("child_process");
|
|
88438
88530
|
import_ws3 = require("ws");
|
|
@@ -88440,7 +88532,7 @@ var init_adhdev_daemon = __esm({
|
|
|
88440
88532
|
init_version();
|
|
88441
88533
|
init_src();
|
|
88442
88534
|
init_runtime_defaults();
|
|
88443
|
-
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.
|
|
88535
|
+
pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.52" });
|
|
88444
88536
|
AdhdevDaemon = class _AdhdevDaemon {
|
|
88445
88537
|
localHttpServer = null;
|
|
88446
88538
|
localWss = null;
|
|
@@ -88964,8 +89056,8 @@ ${err?.stack || ""}`);
|
|
|
88964
89056
|
cliInfo: {
|
|
88965
89057
|
type: "adhdev-daemon",
|
|
88966
89058
|
version: pkgVersion,
|
|
88967
|
-
platform:
|
|
88968
|
-
hostname:
|
|
89059
|
+
platform: os28.platform(),
|
|
89060
|
+
hostname: os28.hostname(),
|
|
88969
89061
|
machineId: config2.machineId,
|
|
88970
89062
|
instanceId
|
|
88971
89063
|
}
|
|
@@ -89723,15 +89815,15 @@ async function loginFlow() {
|
|
|
89723
89815
|
let verificationUrl;
|
|
89724
89816
|
try {
|
|
89725
89817
|
const config2 = loadConfig();
|
|
89726
|
-
const
|
|
89818
|
+
const os31 = await import("os");
|
|
89727
89819
|
const res = await fetch(`${SERVER_URL}/auth/cli/init`, {
|
|
89728
89820
|
method: "POST",
|
|
89729
89821
|
headers: { "Content-Type": "application/json" },
|
|
89730
89822
|
body: JSON.stringify({
|
|
89731
89823
|
clientMachineId: config2.machineId,
|
|
89732
|
-
hostname:
|
|
89733
|
-
platform:
|
|
89734
|
-
arch:
|
|
89824
|
+
hostname: os31.hostname(),
|
|
89825
|
+
platform: os31.platform(),
|
|
89826
|
+
arch: os31.arch()
|
|
89735
89827
|
})
|
|
89736
89828
|
});
|
|
89737
89829
|
if (!res.ok) {
|
|
@@ -89836,8 +89928,8 @@ async function startDaemonFlow() {
|
|
|
89836
89928
|
const { execSync: execSync8 } = await import("child_process");
|
|
89837
89929
|
const { getCurrentDaemonLogPath: getCurrentDaemonLogPath2 } = await Promise.resolve().then(() => (init_src(), src_exports));
|
|
89838
89930
|
const logPath = getCurrentDaemonLogPath2();
|
|
89839
|
-
const
|
|
89840
|
-
const platform12 =
|
|
89931
|
+
const os31 = await import("os");
|
|
89932
|
+
const platform12 = os31.platform();
|
|
89841
89933
|
try {
|
|
89842
89934
|
if (platform12 === "win32") {
|
|
89843
89935
|
execSync8("start /B adhdev daemon >NUL 2>&1", {
|
|
@@ -91730,9 +91822,9 @@ function registerSetupCommands(program2, getProviderLoader2) {
|
|
|
91730
91822
|
});
|
|
91731
91823
|
program2.command("uninstall").description("Completely wipe all setting, configuration, stop daemon and uninstall service").option("-f, --force", "Skip confirmation prompt").action(async (options) => {
|
|
91732
91824
|
const inquirer2 = await Promise.resolve().then(() => (init_lib(), lib_exports));
|
|
91733
|
-
const
|
|
91734
|
-
const
|
|
91735
|
-
const
|
|
91825
|
+
const fs23 = await import("fs");
|
|
91826
|
+
const path36 = await import("path");
|
|
91827
|
+
const os31 = await import("os");
|
|
91736
91828
|
const { spawnSync: spawnSync3 } = await import("child_process");
|
|
91737
91829
|
if (!options.force) {
|
|
91738
91830
|
const { confirm } = await inquirer2.default.prompt([
|
|
@@ -91757,11 +91849,11 @@ function registerSetupCommands(program2, getProviderLoader2) {
|
|
|
91757
91849
|
}
|
|
91758
91850
|
console.log(source_default.gray(" Removing OS background service..."));
|
|
91759
91851
|
spawnSync3(process.execPath, [process.argv[1], "service", "uninstall"], { stdio: "inherit" });
|
|
91760
|
-
const adhdevDir =
|
|
91761
|
-
if (
|
|
91852
|
+
const adhdevDir = path36.join(os31.homedir(), ".adhdev");
|
|
91853
|
+
if (fs23.existsSync(adhdevDir)) {
|
|
91762
91854
|
console.log(source_default.gray(` Deleting ${adhdevDir}...`));
|
|
91763
91855
|
try {
|
|
91764
|
-
|
|
91856
|
+
fs23.rmSync(adhdevDir, { recursive: true, force: true });
|
|
91765
91857
|
console.log(source_default.green(" \u2713 Data wiped."));
|
|
91766
91858
|
} catch (e) {
|
|
91767
91859
|
console.log(source_default.red(` \u2717 Failed to delete ~/.adhdev: ${e.message}`));
|
|
@@ -91780,11 +91872,11 @@ init_source();
|
|
|
91780
91872
|
init_src();
|
|
91781
91873
|
|
|
91782
91874
|
// src/cli/runtime-tools.ts
|
|
91783
|
-
var
|
|
91784
|
-
var
|
|
91875
|
+
var fs20 = __toESM(require("fs"));
|
|
91876
|
+
var path31 = __toESM(require("path"));
|
|
91785
91877
|
function defaultPackageRoot() {
|
|
91786
|
-
const currentCliPath = process.argv[1] ?
|
|
91787
|
-
return
|
|
91878
|
+
const currentCliPath = process.argv[1] ? fs20.realpathSync.native(process.argv[1]) : process.cwd();
|
|
91879
|
+
return path31.resolve(path31.dirname(currentCliPath), "../..");
|
|
91788
91880
|
}
|
|
91789
91881
|
function normalizePath2(value) {
|
|
91790
91882
|
return value.replace(/\\/g, "/").toLowerCase();
|
|
@@ -91793,19 +91885,19 @@ function shouldPreferSource(currentCliPath, packageRoot) {
|
|
|
91793
91885
|
const normalizedCliPath = normalizePath2(currentCliPath || "");
|
|
91794
91886
|
if (normalizedCliPath.includes("/src/cli/")) return true;
|
|
91795
91887
|
if (normalizedCliPath.includes("/dist/cli/")) return false;
|
|
91796
|
-
return
|
|
91888
|
+
return fs20.existsSync(path31.join(packageRoot, "src", "cli", "index.ts"));
|
|
91797
91889
|
}
|
|
91798
91890
|
function getVendoredToolEntry(packageRoot, tool) {
|
|
91799
91891
|
if (tool === "session-host-daemon") {
|
|
91800
|
-
return
|
|
91892
|
+
return path31.join(packageRoot, "vendor", "session-host-daemon", "index.js");
|
|
91801
91893
|
}
|
|
91802
|
-
return
|
|
91894
|
+
return path31.join(packageRoot, "vendor", "terminal-mux-cli", "index.js");
|
|
91803
91895
|
}
|
|
91804
91896
|
function getSourceToolEntry(packageRoot, tool) {
|
|
91805
91897
|
if (tool === "session-host-daemon") {
|
|
91806
|
-
return
|
|
91898
|
+
return path31.resolve(packageRoot, "../../oss/packages/session-host-daemon/src/index.ts");
|
|
91807
91899
|
}
|
|
91808
|
-
return
|
|
91900
|
+
return path31.resolve(packageRoot, "../../oss/packages/terminal-mux-cli/src/index.ts");
|
|
91809
91901
|
}
|
|
91810
91902
|
function getGlobalToolCommand(tool) {
|
|
91811
91903
|
return tool === "session-host-daemon" ? "adhdev-sessiond" : "adhmux";
|
|
@@ -91818,7 +91910,7 @@ function resolveRuntimeToolLaunch(tool, context = {}) {
|
|
|
91818
91910
|
const vendoredEntry = getVendoredToolEntry(packageRoot, tool);
|
|
91819
91911
|
const resolutionOrder = preferSource ? ["source", "vendored", "global"] : ["vendored", "source", "global"];
|
|
91820
91912
|
for (const resolution of resolutionOrder) {
|
|
91821
|
-
if (resolution === "source" &&
|
|
91913
|
+
if (resolution === "source" && fs20.existsSync(sourceEntry)) {
|
|
91822
91914
|
return {
|
|
91823
91915
|
tool,
|
|
91824
91916
|
resolvedVia: "source",
|
|
@@ -91827,7 +91919,7 @@ function resolveRuntimeToolLaunch(tool, context = {}) {
|
|
|
91827
91919
|
env: env3
|
|
91828
91920
|
};
|
|
91829
91921
|
}
|
|
91830
|
-
if (resolution === "vendored" &&
|
|
91922
|
+
if (resolution === "vendored" && fs20.existsSync(vendoredEntry)) {
|
|
91831
91923
|
return {
|
|
91832
91924
|
tool,
|
|
91833
91925
|
resolvedVia: "vendored",
|
|
@@ -92960,9 +93052,9 @@ function registerDaemonCommands(program2, pkgVersion3) {
|
|
|
92960
93052
|
// src/cli/doctor-commands.ts
|
|
92961
93053
|
init_source();
|
|
92962
93054
|
var import_child_process15 = require("child_process");
|
|
92963
|
-
var
|
|
92964
|
-
var
|
|
92965
|
-
var
|
|
93055
|
+
var fs22 = __toESM(require("fs"));
|
|
93056
|
+
var os30 = __toESM(require("os"));
|
|
93057
|
+
var path34 = __toESM(require("path"));
|
|
92966
93058
|
init_src();
|
|
92967
93059
|
init_session_host();
|
|
92968
93060
|
|
|
@@ -93445,11 +93537,11 @@ function formatBytes(bytes) {
|
|
|
93445
93537
|
|
|
93446
93538
|
// src/cli/doctor-commands.ts
|
|
93447
93539
|
function resolvePackageRoot() {
|
|
93448
|
-
return
|
|
93540
|
+
return path34.resolve(__dirname, "..", "..");
|
|
93449
93541
|
}
|
|
93450
93542
|
function isLinkedInstall(packageRoot) {
|
|
93451
|
-
const normalized =
|
|
93452
|
-
return !normalized.includes(`${
|
|
93543
|
+
const normalized = path34.normalize(packageRoot);
|
|
93544
|
+
return !normalized.includes(`${path34.sep}node_modules${path34.sep}adhdev`);
|
|
93453
93545
|
}
|
|
93454
93546
|
function formatCheck(check2) {
|
|
93455
93547
|
const icon = check2.ok ? source_default.green("\u2713") : source_default.red("\u2717");
|
|
@@ -93533,11 +93625,11 @@ function probeSharpRuntime(packageRoot, nativeSharpPackage) {
|
|
|
93533
93625
|
}
|
|
93534
93626
|
}
|
|
93535
93627
|
function probeConfigAccess() {
|
|
93536
|
-
const configDir =
|
|
93537
|
-
const configPath =
|
|
93628
|
+
const configDir = path34.join(os30.homedir(), ".adhdev");
|
|
93629
|
+
const configPath = path34.join(configDir, "config.json");
|
|
93538
93630
|
const checks = [];
|
|
93539
93631
|
try {
|
|
93540
|
-
|
|
93632
|
+
fs22.mkdirSync(configDir, { recursive: true });
|
|
93541
93633
|
checks.push({
|
|
93542
93634
|
label: "Config directory",
|
|
93543
93635
|
ok: true,
|
|
@@ -93552,8 +93644,8 @@ function probeConfigAccess() {
|
|
|
93552
93644
|
}];
|
|
93553
93645
|
}
|
|
93554
93646
|
try {
|
|
93555
|
-
if (
|
|
93556
|
-
|
|
93647
|
+
if (fs22.existsSync(configPath)) {
|
|
93648
|
+
fs22.readFileSync(configPath, "utf-8");
|
|
93557
93649
|
checks.push({
|
|
93558
93650
|
label: "Config file",
|
|
93559
93651
|
ok: true,
|
|
@@ -93574,10 +93666,10 @@ function probeConfigAccess() {
|
|
|
93574
93666
|
fatal: true
|
|
93575
93667
|
});
|
|
93576
93668
|
}
|
|
93577
|
-
const probePath =
|
|
93669
|
+
const probePath = path34.join(configDir, `.doctor-write-${process.pid}-${Date.now()}.tmp`);
|
|
93578
93670
|
try {
|
|
93579
|
-
|
|
93580
|
-
|
|
93671
|
+
fs22.writeFileSync(probePath, "ok", "utf-8");
|
|
93672
|
+
fs22.rmSync(probePath, { force: true });
|
|
93581
93673
|
checks.push({
|
|
93582
93674
|
label: "Config write",
|
|
93583
93675
|
ok: true,
|
|
@@ -93585,7 +93677,7 @@ function probeConfigAccess() {
|
|
|
93585
93677
|
});
|
|
93586
93678
|
} catch (error48) {
|
|
93587
93679
|
try {
|
|
93588
|
-
|
|
93680
|
+
fs22.rmSync(probePath, { force: true });
|
|
93589
93681
|
} catch {
|
|
93590
93682
|
}
|
|
93591
93683
|
checks.push({
|
|
@@ -93641,9 +93733,9 @@ function probeCliBinary(commandPath, currentVersion) {
|
|
|
93641
93733
|
return probe;
|
|
93642
93734
|
}
|
|
93643
93735
|
function readLogHints(logPath) {
|
|
93644
|
-
if (!
|
|
93736
|
+
if (!fs22.existsSync(logPath)) return [];
|
|
93645
93737
|
try {
|
|
93646
|
-
const content =
|
|
93738
|
+
const content = fs22.readFileSync(logPath, "utf-8");
|
|
93647
93739
|
const lines = content.split(/\r?\n/);
|
|
93648
93740
|
const recent = lines.slice(-400);
|
|
93649
93741
|
const hits = recent.filter(
|
|
@@ -93657,11 +93749,11 @@ function readLogHints(logPath) {
|
|
|
93657
93749
|
function buildBrowseProbeChecks() {
|
|
93658
93750
|
const probes = process.platform === "win32" ? [
|
|
93659
93751
|
process.env.SystemDrive ? `${process.env.SystemDrive.replace(/[\\/]+$/, "")}\\` : "C:\\",
|
|
93660
|
-
|
|
93661
|
-
] : ["/",
|
|
93752
|
+
os30.homedir()
|
|
93753
|
+
] : ["/", os30.homedir()];
|
|
93662
93754
|
return probes.map((probePath, index) => {
|
|
93663
93755
|
try {
|
|
93664
|
-
const entries =
|
|
93756
|
+
const entries = fs22.readdirSync(probePath, { withFileTypes: true });
|
|
93665
93757
|
const directoryCount = entries.filter((entry) => entry.isDirectory()).length;
|
|
93666
93758
|
return {
|
|
93667
93759
|
label: index === 0 ? "Folder browse root" : "Folder browse home",
|
|
@@ -93681,7 +93773,7 @@ function buildBrowseProbeChecks() {
|
|
|
93681
93773
|
function registerDoctorCommands(program2, pkgVersion3) {
|
|
93682
93774
|
program2.command("doctor").description("Diagnose install, native dependencies, CLI resolution, and folder browse access").action(async () => {
|
|
93683
93775
|
const packageRoot = resolvePackageRoot();
|
|
93684
|
-
const cliPath =
|
|
93776
|
+
const cliPath = fs22.realpathSync(process.argv[1]);
|
|
93685
93777
|
const linked = isLinkedInstall(packageRoot);
|
|
93686
93778
|
const logPath = getCurrentDaemonLogPath();
|
|
93687
93779
|
const claudePaths = findCommandPaths("claude");
|
|
@@ -93763,12 +93855,12 @@ function registerDoctorCommands(program2, pkgVersion3) {
|
|
|
93763
93855
|
});
|
|
93764
93856
|
}
|
|
93765
93857
|
if (process.platform === "darwin") {
|
|
93766
|
-
serviceDefinitionPath =
|
|
93767
|
-
if (
|
|
93858
|
+
serviceDefinitionPath = path34.join(os30.homedir(), "Library", "LaunchAgents", "dev.adhf.daemon.plist");
|
|
93859
|
+
if (fs22.existsSync(serviceDefinitionPath)) {
|
|
93768
93860
|
serviceDefinitionCheck = evaluateServiceDefinitionDrift({
|
|
93769
93861
|
serviceKind: "launchd",
|
|
93770
93862
|
servicePath: serviceDefinitionPath,
|
|
93771
|
-
installedDefinition:
|
|
93863
|
+
installedDefinition: fs22.readFileSync(serviceDefinitionPath, "utf8"),
|
|
93772
93864
|
expectedDefinition: buildPlist(process.execPath, cliPath)
|
|
93773
93865
|
});
|
|
93774
93866
|
checks.push({
|
|
@@ -93836,12 +93928,12 @@ function registerDoctorCommands(program2, pkgVersion3) {
|
|
|
93836
93928
|
serviceCheck: serviceDefinitionCheck || void 0,
|
|
93837
93929
|
sourceCliExample: "node --import tsx packages/daemon-cloud/src/cli/index.ts doctor"
|
|
93838
93930
|
});
|
|
93839
|
-
const sessionHostLogPath =
|
|
93931
|
+
const sessionHostLogPath = path34.join(os30.homedir(), ".adhdev", "logs", "session-host.log");
|
|
93840
93932
|
console.log(source_default.bold("\n\u{1FA7A} ADHDev Doctor\n"));
|
|
93841
93933
|
console.log(source_default.gray(` Version: ${pkgVersion3}`));
|
|
93842
93934
|
console.log(source_default.gray(` Platform: ${process.platform} ${process.arch}`));
|
|
93843
93935
|
console.log(source_default.gray(` Node: ${process.version}`));
|
|
93844
|
-
console.log(source_default.gray(` Home: ${
|
|
93936
|
+
console.log(source_default.gray(` Home: ${os30.homedir()}`));
|
|
93845
93937
|
console.log(source_default.gray(` Log file: ${logPath}`));
|
|
93846
93938
|
console.log(source_default.gray(` SH log: ${sessionHostLogPath}`));
|
|
93847
93939
|
console.log();
|
|
@@ -93878,7 +93970,7 @@ function registerDoctorCommands(program2, pkgVersion3) {
|
|
|
93878
93970
|
|
|
93879
93971
|
// src/cli/provider-commands.ts
|
|
93880
93972
|
init_source();
|
|
93881
|
-
var
|
|
93973
|
+
var path35 = __toESM(require("path"));
|
|
93882
93974
|
init_cdp_utils();
|
|
93883
93975
|
var DEV_SERVER_PORT3 = 19280;
|
|
93884
93976
|
var IDE_AUTO_FIX_FUNCTIONS = [
|
|
@@ -93961,7 +94053,7 @@ function getProviderSourceCandidatePaths(options) {
|
|
|
93961
94053
|
const results = [];
|
|
93962
94054
|
for (const root of roots) {
|
|
93963
94055
|
for (const name of relativeNames) {
|
|
93964
|
-
results.push(
|
|
94056
|
+
results.push(path35.join(root, options.category, options.type, name));
|
|
93965
94057
|
}
|
|
93966
94058
|
}
|
|
93967
94059
|
return results;
|
|
@@ -94096,35 +94188,35 @@ function registerProviderCommands(program2) {
|
|
|
94096
94188
|
let osPaths = {};
|
|
94097
94189
|
let processNames = {};
|
|
94098
94190
|
if (category === "ide") {
|
|
94099
|
-
const
|
|
94100
|
-
const
|
|
94101
|
-
const
|
|
94102
|
-
if (
|
|
94191
|
+
const fs23 = await import("fs");
|
|
94192
|
+
const path36 = await import("path");
|
|
94193
|
+
const os31 = await import("os");
|
|
94194
|
+
if (os31.platform() === "darwin") {
|
|
94103
94195
|
while (true) {
|
|
94104
94196
|
const p = (await rl.question(`macOS Application Path (e.g. /Applications/${defaultName}.app): `)).trim() || `/Applications/${defaultName}.app`;
|
|
94105
94197
|
if (p === "skip") break;
|
|
94106
|
-
if (!
|
|
94198
|
+
if (!fs23.existsSync(p)) {
|
|
94107
94199
|
console.log(source_default.red(` \u2717 Path not found: ${p}`));
|
|
94108
94200
|
console.log(source_default.gray(` (Please provide the exact absolute path to the .app or binary, or type 'skip')`));
|
|
94109
94201
|
continue;
|
|
94110
94202
|
}
|
|
94111
94203
|
console.log(source_default.green(` \u2713 Path verified: ${p}`));
|
|
94112
94204
|
osPaths["darwin"] = [p];
|
|
94113
|
-
processNames["darwin"] =
|
|
94205
|
+
processNames["darwin"] = path36.basename(p, ".app");
|
|
94114
94206
|
break;
|
|
94115
94207
|
}
|
|
94116
|
-
} else if (
|
|
94208
|
+
} else if (os31.platform() === "win32") {
|
|
94117
94209
|
while (true) {
|
|
94118
94210
|
const p = (await rl.question(`Windows Executable Path (e.g. C:\\Program Files\\${defaultName}\\${defaultName}.exe): `)).trim();
|
|
94119
94211
|
if (!p || p === "skip") break;
|
|
94120
|
-
if (!
|
|
94212
|
+
if (!fs23.existsSync(p)) {
|
|
94121
94213
|
console.log(source_default.red(` \u2717 Path not found: ${p}`));
|
|
94122
94214
|
console.log(source_default.gray(` (Please provide the exact absolute path, or type 'skip')`));
|
|
94123
94215
|
continue;
|
|
94124
94216
|
}
|
|
94125
94217
|
console.log(source_default.green(` \u2713 Path verified: ${p}`));
|
|
94126
94218
|
osPaths["win32"] = [p];
|
|
94127
|
-
processNames["win32"] =
|
|
94219
|
+
processNames["win32"] = path36.basename(p, ".exe");
|
|
94128
94220
|
break;
|
|
94129
94221
|
}
|
|
94130
94222
|
}
|
|
@@ -94811,8 +94903,8 @@ function registerCdpCommands(program2) {
|
|
|
94811
94903
|
}
|
|
94812
94904
|
const output = typeof result === "string" ? result : JSON.stringify(result, null, 2);
|
|
94813
94905
|
if (options.output) {
|
|
94814
|
-
const
|
|
94815
|
-
|
|
94906
|
+
const fs23 = await import("fs");
|
|
94907
|
+
fs23.writeFileSync(options.output, output, "utf-8");
|
|
94816
94908
|
console.log(source_default.green(`
|
|
94817
94909
|
\u2713 Saved to ${options.output} (${output.length} chars)
|
|
94818
94910
|
`));
|
|
@@ -94915,8 +95007,8 @@ function registerCdpCommands(program2) {
|
|
|
94915
95007
|
ws.on("message", async (data) => {
|
|
94916
95008
|
const msg = JSON.parse(data.toString());
|
|
94917
95009
|
if (msg.id === 1 && msg.result?.data) {
|
|
94918
|
-
const
|
|
94919
|
-
|
|
95010
|
+
const fs23 = await import("fs");
|
|
95011
|
+
fs23.writeFileSync(options.output, Buffer.from(msg.result.data, "base64"));
|
|
94920
95012
|
console.log(source_default.green(`
|
|
94921
95013
|
\u2713 Screenshot saved to ${options.output}
|
|
94922
95014
|
`));
|