adhdev 0.9.50 → 0.9.51

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