adhdev 0.9.49 → 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,10 +8228,57 @@ 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) {
8276
+ const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
8277
+ if (!targetSessionId && !h.currentSession) {
8278
+ return { success: false, error: "No targetSessionId specified \u2014 cannot route command" };
8279
+ }
8232
8280
  const provider = h.getProvider(args?.agentType);
8233
8281
  const transport = getTargetTransport(h, provider);
8234
- const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
8235
8282
  const providerType = provider?.type || getCurrentProviderType(h, args?.agentType || "");
8236
8283
  const adapter = isCliLikeTransport(transport) ? getTargetedCliAdapter(h, args, provider?.type) : null;
8237
8284
  const targetInstance = getTargetInstance(h, args);
@@ -8336,6 +8383,20 @@ async function handleGetChatDebugBundle(h, args) {
8336
8383
  recentDebugTrace: getRecentDebugTrace({ limit: 120 })
8337
8384
  };
8338
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
+ }
8339
8400
  return {
8340
8401
  success: true,
8341
8402
  bundle,
@@ -9315,10 +9376,14 @@ async function handleResolveAction(h, args) {
9315
9376
  }
9316
9377
  return { success: false, error: "resolveAction script not available for this provider" };
9317
9378
  }
9318
- 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;
9319
9380
  var init_chat_commands = __esm({
9320
9381
  "../../oss/packages/daemon-core/src/commands/chat-commands.ts"() {
9321
9382
  "use strict";
9383
+ fs4 = __toESM(require("fs"));
9384
+ os7 = __toESM(require("os"));
9385
+ path8 = __toESM(require("path"));
9386
+ import_node_crypto = require("crypto");
9322
9387
  init_contracts();
9323
9388
  init_provider_input_support();
9324
9389
  init_read_chat_contract();
@@ -9559,27 +9624,27 @@ function normalizeWindowsRequestedPath(requestedPath) {
9559
9624
  function resolveSafePath(requestedPath) {
9560
9625
  const rawPath = typeof requestedPath === "string" ? requestedPath.trim() : "";
9561
9626
  const inputPath = rawPath || ".";
9562
- const home = os7.homedir();
9627
+ const home = os8.homedir();
9563
9628
  if (inputPath.startsWith("~")) {
9564
- return path8.resolve(path8.join(home, inputPath.slice(1)));
9629
+ return path9.resolve(path9.join(home, inputPath.slice(1)));
9565
9630
  }
9566
9631
  if (process.platform === "win32") {
9567
9632
  const normalized = normalizeWindowsRequestedPath(inputPath);
9568
- if (path8.win32.isAbsolute(normalized)) {
9569
- return path8.win32.normalize(normalized);
9633
+ if (path9.win32.isAbsolute(normalized)) {
9634
+ return path9.win32.normalize(normalized);
9570
9635
  }
9571
- return path8.win32.resolve(normalized);
9636
+ return path9.win32.resolve(normalized);
9572
9637
  }
9573
- if (path8.isAbsolute(inputPath)) {
9574
- return path8.normalize(inputPath);
9638
+ if (path9.isAbsolute(inputPath)) {
9639
+ return path9.normalize(inputPath);
9575
9640
  }
9576
- return path8.resolve(inputPath);
9641
+ return path9.resolve(inputPath);
9577
9642
  }
9578
9643
  function listDirectoryEntriesSafe(dirPath) {
9579
- const entries = fs4.readdirSync(dirPath, { withFileTypes: true });
9644
+ const entries = fs5.readdirSync(dirPath, { withFileTypes: true });
9580
9645
  const files = [];
9581
9646
  for (const entry of entries) {
9582
- const entryPath = path8.join(dirPath, entry.name);
9647
+ const entryPath = path9.join(dirPath, entry.name);
9583
9648
  try {
9584
9649
  if (entry.isDirectory()) {
9585
9650
  files.push({ name: entry.name, type: "directory" });
@@ -9588,14 +9653,14 @@ function listDirectoryEntriesSafe(dirPath) {
9588
9653
  if (entry.isFile()) {
9589
9654
  let size;
9590
9655
  try {
9591
- size = fs4.statSync(entryPath).size;
9656
+ size = fs5.statSync(entryPath).size;
9592
9657
  } catch {
9593
9658
  size = void 0;
9594
9659
  }
9595
9660
  files.push({ name: entry.name, type: "file", size });
9596
9661
  continue;
9597
9662
  }
9598
- const stat4 = fs4.statSync(entryPath);
9663
+ const stat4 = fs5.statSync(entryPath);
9599
9664
  files.push({
9600
9665
  name: entry.name,
9601
9666
  type: stat4.isDirectory() ? "directory" : "file",
@@ -9613,7 +9678,7 @@ function listWindowsDriveEntries(excludePath) {
9613
9678
  const letter = String.fromCharCode(code);
9614
9679
  const root = `${letter}:\\`;
9615
9680
  try {
9616
- if (!fs4.existsSync(root)) continue;
9681
+ if (!fs5.existsSync(root)) continue;
9617
9682
  if (excluded && root.toLowerCase() === excluded) continue;
9618
9683
  drives.push({ name: `${letter}:`, type: "directory", path: root });
9619
9684
  } catch {
@@ -9624,7 +9689,7 @@ function listWindowsDriveEntries(excludePath) {
9624
9689
  async function handleFileRead(h, args) {
9625
9690
  try {
9626
9691
  const filePath = resolveSafePath(args?.path);
9627
- const content = fs4.readFileSync(filePath, "utf-8");
9692
+ const content = fs5.readFileSync(filePath, "utf-8");
9628
9693
  return { success: true, content, path: filePath };
9629
9694
  } catch (e) {
9630
9695
  return { success: false, error: e.message };
@@ -9633,8 +9698,8 @@ async function handleFileRead(h, args) {
9633
9698
  async function handleFileWrite(h, args) {
9634
9699
  try {
9635
9700
  const filePath = resolveSafePath(args?.path);
9636
- fs4.mkdirSync(path8.dirname(filePath), { recursive: true });
9637
- fs4.writeFileSync(filePath, args?.content || "", "utf-8");
9701
+ fs5.mkdirSync(path9.dirname(filePath), { recursive: true });
9702
+ fs5.writeFileSync(filePath, args?.content || "", "utf-8");
9638
9703
  return { success: true, path: filePath };
9639
9704
  } catch (e) {
9640
9705
  return { success: false, error: e.message };
@@ -9666,13 +9731,13 @@ async function handleFileListBrowse(h, args) {
9666
9731
  return { success: false, error: e.message };
9667
9732
  }
9668
9733
  }
9669
- var fs4, path8, os7, KEY_TO_VK;
9734
+ var fs5, path9, os8, KEY_TO_VK;
9670
9735
  var init_cdp_commands = __esm({
9671
9736
  "../../oss/packages/daemon-core/src/commands/cdp-commands.ts"() {
9672
9737
  "use strict";
9673
- fs4 = __toESM(require("fs"));
9674
- path8 = __toESM(require("path"));
9675
- os7 = __toESM(require("os"));
9738
+ fs5 = __toESM(require("fs"));
9739
+ path9 = __toESM(require("path"));
9740
+ os8 = __toESM(require("os"));
9676
9741
  KEY_TO_VK = {
9677
9742
  Backspace: 8,
9678
9743
  Tab: 9,
@@ -10557,6 +10622,7 @@ var init_handler = __esm({
10557
10622
  this.logCommandStart(cmd, args);
10558
10623
  const sessionScopedCommands = /* @__PURE__ */ new Set([
10559
10624
  "read_chat",
10625
+ "get_chat_debug_bundle",
10560
10626
  "send_chat",
10561
10627
  "list_chats",
10562
10628
  "new_chat",
@@ -11652,7 +11718,7 @@ function getWorkspaceLabel(workspace) {
11652
11718
  const trimmed = workspace.trim();
11653
11719
  if (!trimmed) return "workspace";
11654
11720
  const normalized = trimmed.replace(/[\\/]+$/, "");
11655
- const base = path9.basename(normalized);
11721
+ const base = path10.basename(normalized);
11656
11722
  return base || normalized;
11657
11723
  }
11658
11724
  function buildRuntimeDisplayName(payload) {
@@ -11761,7 +11827,7 @@ function getDefaultSessionHostEndpoint(appName = "adhdev") {
11761
11827
  }
11762
11828
  return {
11763
11829
  kind: "unix",
11764
- path: path22.join(os9.tmpdir(), `${appName}-session-host.sock`)
11830
+ path: path22.join(os10.tmpdir(), `${appName}-session-host.sock`)
11765
11831
  };
11766
11832
  }
11767
11833
  function serializeEnvelope(envelope) {
@@ -11824,27 +11890,27 @@ function applyTerminalColorEnv(env3) {
11824
11890
  function ensureNodePtySpawnHelperPermissions(logFn) {
11825
11891
  if (os22.platform() === "win32") return;
11826
11892
  try {
11827
- const fs22 = __require("fs");
11893
+ const fs23 = __require("fs");
11828
11894
  const ptyDir = path32.resolve(path32.dirname(__require.resolve("node-pty")), "..");
11829
11895
  const platformArch = `${os22.platform()}-${os22.arch()}`;
11830
11896
  const helper = path32.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
11831
- if (fs22.existsSync(helper)) {
11832
- const stat4 = fs22.statSync(helper);
11897
+ if (fs23.existsSync(helper)) {
11898
+ const stat4 = fs23.statSync(helper);
11833
11899
  if (!(stat4.mode & 73)) {
11834
- fs22.chmodSync(helper, stat4.mode | 493);
11900
+ fs23.chmodSync(helper, stat4.mode | 493);
11835
11901
  logFn?.(`Fixed spawn-helper permissions: ${helper}`);
11836
11902
  }
11837
11903
  }
11838
11904
  } catch {
11839
11905
  }
11840
11906
  }
11841
- 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;
11842
11908
  var init_dist = __esm({
11843
11909
  "../../oss/packages/session-host-core/dist/index.mjs"() {
11844
11910
  "use strict";
11845
11911
  import_crypto3 = require("crypto");
11846
- path9 = __toESM(require("path"), 1);
11847
- os9 = __toESM(require("os"), 1);
11912
+ path10 = __toESM(require("path"), 1);
11913
+ os10 = __toESM(require("os"), 1);
11848
11914
  path22 = __toESM(require("path"), 1);
11849
11915
  net = __toESM(require("net"), 1);
11850
11916
  import_crypto4 = require("crypto");
@@ -12263,11 +12329,11 @@ function loadNodePty() {
12263
12329
  }
12264
12330
  return cachedPty;
12265
12331
  }
12266
- var os10, cachedPty, NodePtyRuntimeTransport, NodePtyTransportFactory;
12332
+ var os11, cachedPty, NodePtyRuntimeTransport, NodePtyTransportFactory;
12267
12333
  var init_pty_transport = __esm({
12268
12334
  "../../oss/packages/daemon-core/src/cli-adapters/pty-transport.ts"() {
12269
12335
  "use strict";
12270
- os10 = __toESM(require("os"));
12336
+ os11 = __toESM(require("os"));
12271
12337
  init_spawn_env();
12272
12338
  NodePtyRuntimeTransport = class {
12273
12339
  constructor(handle) {
@@ -12304,11 +12370,11 @@ var init_pty_transport = __esm({
12304
12370
  let cwd = options.cwd;
12305
12371
  if (cwd) {
12306
12372
  try {
12307
- const fs22 = require("fs");
12308
- const stat4 = fs22.statSync(cwd);
12309
- if (!stat4.isDirectory()) cwd = os10.homedir();
12373
+ const fs23 = require("fs");
12374
+ const stat4 = fs23.statSync(cwd);
12375
+ if (!stat4.isDirectory()) cwd = os11.homedir();
12310
12376
  } catch {
12311
- cwd = os10.homedir();
12377
+ cwd = os11.homedir();
12312
12378
  }
12313
12379
  }
12314
12380
  const handle = pty.spawn(command, args, {
@@ -12388,11 +12454,11 @@ function buildCliScreenSnapshot(text) {
12388
12454
  function findBinary(name) {
12389
12455
  const trimmed = String(name || "").trim();
12390
12456
  if (!trimmed) return trimmed;
12391
- const expanded = trimmed.startsWith("~") ? path10.join(os11.homedir(), trimmed.slice(1)) : trimmed;
12392
- if (path10.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
12393
- 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);
12394
12460
  }
12395
- const isWin = os11.platform() === "win32";
12461
+ const isWin = os12.platform() === "win32";
12396
12462
  try {
12397
12463
  const cmd = isWin ? `where ${trimmed}` : `which ${trimmed}`;
12398
12464
  return (0, import_child_process4.execSync)(cmd, {
@@ -12406,14 +12472,14 @@ function findBinary(name) {
12406
12472
  }
12407
12473
  }
12408
12474
  function isScriptBinary(binaryPath) {
12409
- if (!path10.isAbsolute(binaryPath)) return false;
12475
+ if (!path11.isAbsolute(binaryPath)) return false;
12410
12476
  try {
12411
- const fs22 = require("fs");
12412
- const resolved = fs22.realpathSync(binaryPath);
12477
+ const fs23 = require("fs");
12478
+ const resolved = fs23.realpathSync(binaryPath);
12413
12479
  const head = Buffer.alloc(8);
12414
- const fd = fs22.openSync(resolved, "r");
12415
- fs22.readSync(fd, head, 0, 8, 0);
12416
- fs22.closeSync(fd);
12480
+ const fd = fs23.openSync(resolved, "r");
12481
+ fs23.readSync(fd, head, 0, 8, 0);
12482
+ fs23.closeSync(fd);
12417
12483
  let i = 0;
12418
12484
  if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
12419
12485
  return head[i] === 35 && head[i + 1] === 33;
@@ -12422,14 +12488,14 @@ function isScriptBinary(binaryPath) {
12422
12488
  }
12423
12489
  }
12424
12490
  function looksLikeMachOOrElf(filePath) {
12425
- if (!path10.isAbsolute(filePath)) return false;
12491
+ if (!path11.isAbsolute(filePath)) return false;
12426
12492
  try {
12427
- const fs22 = require("fs");
12428
- const resolved = fs22.realpathSync(filePath);
12493
+ const fs23 = require("fs");
12494
+ const resolved = fs23.realpathSync(filePath);
12429
12495
  const buf = Buffer.alloc(8);
12430
- const fd = fs22.openSync(resolved, "r");
12431
- fs22.readSync(fd, buf, 0, 8, 0);
12432
- fs22.closeSync(fd);
12496
+ const fd = fs23.openSync(resolved, "r");
12497
+ fs23.readSync(fd, buf, 0, 8, 0);
12498
+ fs23.closeSync(fd);
12433
12499
  let i = 0;
12434
12500
  if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
12435
12501
  const b = buf.subarray(i);
@@ -12445,7 +12511,7 @@ function looksLikeMachOOrElf(filePath) {
12445
12511
  }
12446
12512
  function shSingleQuote(arg) {
12447
12513
  if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
12448
- if (os11.platform() === "win32") {
12514
+ if (os12.platform() === "win32") {
12449
12515
  return `"${arg.replace(/"/g, '""')}"`;
12450
12516
  }
12451
12517
  return `'${arg.replace(/'/g, `'\\''`)}'`;
@@ -12572,12 +12638,12 @@ function normalizeCliProviderForRuntime(raw) {
12572
12638
  }
12573
12639
  };
12574
12640
  }
12575
- var os11, path10, import_child_process4, buildCliSpawnEnv, COMMON_COMPARABLE_WRAP_WORDS;
12641
+ var os12, path11, import_child_process4, buildCliSpawnEnv, COMMON_COMPARABLE_WRAP_WORDS;
12576
12642
  var init_provider_cli_shared = __esm({
12577
12643
  "../../oss/packages/daemon-core/src/cli-adapters/provider-cli-shared.ts"() {
12578
12644
  "use strict";
12579
- os11 = __toESM(require("os"));
12580
- path10 = __toESM(require("path"));
12645
+ os12 = __toESM(require("os"));
12646
+ path11 = __toESM(require("path"));
12581
12647
  import_child_process4 = require("child_process");
12582
12648
  init_spawn_env();
12583
12649
  buildCliSpawnEnv = sanitizeSpawnEnv;
@@ -12890,13 +12956,13 @@ function resolveCliSpawnPlan(options) {
12890
12956
  const { spawn: spawnConfig } = provider;
12891
12957
  const configuredCommand = typeof runtimeSettings.executablePath === "string" && runtimeSettings.executablePath.trim() ? runtimeSettings.executablePath.trim() : spawnConfig.command;
12892
12958
  const binaryPath = findBinary(configuredCommand);
12893
- const isWin = os12.platform() === "win32";
12959
+ const isWin = os13.platform() === "win32";
12894
12960
  const allArgs = [...spawnConfig.args, ...extraArgs];
12895
12961
  let shellCmd;
12896
12962
  let shellArgs;
12897
- 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));
12898
12964
  const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
12899
- const useShellWin = !!spawnConfig.shell || isCmdShim || !path11.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
12965
+ const useShellWin = !!spawnConfig.shell || isCmdShim || !path12.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
12900
12966
  const useShell = isWin ? useShellWin : useShellUnix;
12901
12967
  if (useShell) {
12902
12968
  shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
@@ -12972,12 +13038,12 @@ function respondToCliTerminalQueries(options) {
12972
13038
  }
12973
13039
  return "";
12974
13040
  }
12975
- var os12, path11;
13041
+ var os13, path12;
12976
13042
  var init_provider_cli_runtime = __esm({
12977
13043
  "../../oss/packages/daemon-core/src/cli-adapters/provider-cli-runtime.ts"() {
12978
13044
  "use strict";
12979
- os12 = __toESM(require("os"));
12980
- path11 = __toESM(require("path"));
13045
+ os13 = __toESM(require("os"));
13046
+ path12 = __toESM(require("path"));
12981
13047
  init_dist();
12982
13048
  init_provider_cli_shared();
12983
13049
  }
@@ -13099,11 +13165,11 @@ function trimLastAssistantEchoForCliMessages(messages, prompt2) {
13099
13165
  return;
13100
13166
  }
13101
13167
  }
13102
- var os13, COMMITTED_ACTIVITY_PREFIX_BLOCK_RE, ProviderCliAdapter;
13168
+ var os14, COMMITTED_ACTIVITY_PREFIX_BLOCK_RE, ProviderCliAdapter;
13103
13169
  var init_provider_cli_adapter = __esm({
13104
13170
  "../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts"() {
13105
13171
  "use strict";
13106
- os13 = __toESM(require("os"));
13172
+ os14 = __toESM(require("os"));
13107
13173
  init_logger();
13108
13174
  init_debug_config();
13109
13175
  init_terminal_screen();
@@ -13123,7 +13189,7 @@ var init_provider_cli_adapter = __esm({
13123
13189
  this.transportFactory = transportFactory;
13124
13190
  this.cliType = provider.type;
13125
13191
  this.cliName = provider.name;
13126
- this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os13.homedir()) : workingDir;
13192
+ this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os14.homedir()) : workingDir;
13127
13193
  const resolvedConfig = resolveCliAdapterConfig(provider);
13128
13194
  this.timeouts = resolvedConfig.timeouts;
13129
13195
  this.approvalKeys = resolvedConfig.approvalKeys;
@@ -15506,7 +15572,7 @@ function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages
15506
15572
  }
15507
15573
  function getDatabaseSync() {
15508
15574
  if (CachedDatabaseSync) return CachedDatabaseSync;
15509
- 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"));
15510
15576
  const sqliteModule = requireFn(`node:${"sqlite"}`);
15511
15577
  CachedDatabaseSync = sqliteModule.DatabaseSync;
15512
15578
  if (!CachedDatabaseSync) {
@@ -15548,14 +15614,14 @@ async function waitForCliAdapterReady(adapter, options) {
15548
15614
  }
15549
15615
  throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
15550
15616
  }
15551
- var os14, path12, crypto3, fs5, import_node_module, CachedDatabaseSync, CliProviderInstance;
15617
+ var os15, path13, crypto3, fs6, import_node_module, CachedDatabaseSync, CliProviderInstance;
15552
15618
  var init_cli_provider_instance = __esm({
15553
15619
  "../../oss/packages/daemon-core/src/providers/cli-provider-instance.ts"() {
15554
15620
  "use strict";
15555
- os14 = __toESM(require("os"));
15556
- path12 = __toESM(require("path"));
15621
+ os15 = __toESM(require("os"));
15622
+ path13 = __toESM(require("path"));
15557
15623
  crypto3 = __toESM(require("crypto"));
15558
- fs5 = __toESM(require("fs"));
15624
+ fs6 = __toESM(require("fs"));
15559
15625
  import_node_module = require("module");
15560
15626
  init_contracts();
15561
15627
  init_provider_input_support();
@@ -15678,10 +15744,10 @@ var init_cli_provider_instance = __esm({
15678
15744
  * Replaces the previously duplicated probeOpenCode/Codex/Goose functions.
15679
15745
  */
15680
15746
  probeSessionIdFromConfig(probe) {
15681
- const resolvedDbPath = probe.dbPath.replace(/^~/, os14.homedir());
15747
+ const resolvedDbPath = probe.dbPath.replace(/^~/, os15.homedir());
15682
15748
  const now = Date.now();
15683
15749
  if (this.cachedSqliteDbMissingUntil > now) return null;
15684
- if (!fs5.existsSync(resolvedDbPath)) {
15750
+ if (!fs6.existsSync(resolvedDbPath)) {
15685
15751
  this.cachedSqliteDbMissingUntil = now + 1e4;
15686
15752
  return null;
15687
15753
  }
@@ -16413,7 +16479,7 @@ ${effect.notification.body || ""}`.trim();
16413
16479
  };
16414
16480
  addDir(this.workingDir);
16415
16481
  try {
16416
- addDir(fs5.realpathSync.native(this.workingDir));
16482
+ addDir(fs6.realpathSync.native(this.workingDir));
16417
16483
  } catch {
16418
16484
  }
16419
16485
  return Array.from(dirs);
@@ -16704,10 +16770,10 @@ function mergeDefs(...defs) {
16704
16770
  function cloneDef(schema) {
16705
16771
  return mergeDefs(schema._zod.def);
16706
16772
  }
16707
- function getElementAtPath(obj, path35) {
16708
- if (!path35)
16773
+ function getElementAtPath(obj, path36) {
16774
+ if (!path36)
16709
16775
  return obj;
16710
- return path35.reduce((acc, key) => acc?.[key], obj);
16776
+ return path36.reduce((acc, key) => acc?.[key], obj);
16711
16777
  }
16712
16778
  function promiseAllObject(promisesObj) {
16713
16779
  const keys = Object.keys(promisesObj);
@@ -17019,11 +17085,11 @@ function aborted(x, startIndex = 0) {
17019
17085
  }
17020
17086
  return false;
17021
17087
  }
17022
- function prefixIssues(path35, issues) {
17088
+ function prefixIssues(path36, issues) {
17023
17089
  return issues.map((iss) => {
17024
17090
  var _a2;
17025
17091
  (_a2 = iss).path ?? (_a2.path = []);
17026
- iss.path.unshift(path35);
17092
+ iss.path.unshift(path36);
17027
17093
  return iss;
17028
17094
  });
17029
17095
  }
@@ -17266,7 +17332,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
17266
17332
  }
17267
17333
  function treeifyError(error48, mapper = (issue2) => issue2.message) {
17268
17334
  const result = { errors: [] };
17269
- const processError = (error49, path35 = []) => {
17335
+ const processError = (error49, path36 = []) => {
17270
17336
  var _a2, _b;
17271
17337
  for (const issue2 of error49.issues) {
17272
17338
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -17276,7 +17342,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
17276
17342
  } else if (issue2.code === "invalid_element") {
17277
17343
  processError({ issues: issue2.issues }, issue2.path);
17278
17344
  } else {
17279
- const fullpath = [...path35, ...issue2.path];
17345
+ const fullpath = [...path36, ...issue2.path];
17280
17346
  if (fullpath.length === 0) {
17281
17347
  result.errors.push(mapper(issue2));
17282
17348
  continue;
@@ -17308,8 +17374,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
17308
17374
  }
17309
17375
  function toDotPath(_path) {
17310
17376
  const segs = [];
17311
- const path35 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
17312
- for (const seg of path35) {
17377
+ const path36 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
17378
+ for (const seg of path36) {
17313
17379
  if (typeof seg === "number")
17314
17380
  segs.push(`[${seg}]`);
17315
17381
  else if (typeof seg === "symbol")
@@ -30073,13 +30139,13 @@ function resolveRef(ref, ctx) {
30073
30139
  if (!ref.startsWith("#")) {
30074
30140
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
30075
30141
  }
30076
- const path35 = ref.slice(1).split("/").filter(Boolean);
30077
- if (path35.length === 0) {
30142
+ const path36 = ref.slice(1).split("/").filter(Boolean);
30143
+ if (path36.length === 0) {
30078
30144
  return ctx.rootSchema;
30079
30145
  }
30080
30146
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
30081
- if (path35[0] === defsKey) {
30082
- const key = path35[1];
30147
+ if (path36[0] === defsKey) {
30148
+ const key = path36[1];
30083
30149
  if (!key || !ctx.defs[key]) {
30084
30150
  throw new Error(`Reference not found: ${ref}`);
30085
30151
  }
@@ -33925,11 +33991,11 @@ var init_hosted_runtime_restore = __esm({
33925
33991
  // ../../oss/packages/daemon-core/src/commands/cli-manager.ts
33926
33992
  function isExplicitCommand(command) {
33927
33993
  const trimmed = command.trim();
33928
- return path13.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
33994
+ return path14.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
33929
33995
  }
33930
33996
  function expandExecutable(command) {
33931
33997
  const trimmed = command.trim();
33932
- return trimmed.startsWith("~") ? path13.join(os15.homedir(), trimmed.slice(1)) : trimmed;
33998
+ return trimmed.startsWith("~") ? path14.join(os16.homedir(), trimmed.slice(1)) : trimmed;
33933
33999
  }
33934
34000
  function commandExists(command) {
33935
34001
  const trimmed = command.trim();
@@ -34066,12 +34132,12 @@ function resolveCliSessionBinding(provider, normalizedType, cliArgs, requestedRe
34066
34132
  launchMode: "new"
34067
34133
  };
34068
34134
  }
34069
- 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;
34070
34136
  var init_cli_manager = __esm({
34071
34137
  "../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
34072
34138
  "use strict";
34073
- os15 = __toESM(require("os"));
34074
- path13 = __toESM(require("path"));
34139
+ os16 = __toESM(require("os"));
34140
+ path14 = __toESM(require("path"));
34075
34141
  crypto4 = __toESM(require("crypto"));
34076
34142
  import_fs5 = require("fs");
34077
34143
  import_child_process6 = require("child_process");
@@ -34234,7 +34300,7 @@ var init_cli_manager = __esm({
34234
34300
  async startSession(cliType, workingDir, cliArgs, initialModel, options) {
34235
34301
  const trimmed = (workingDir || "").trim();
34236
34302
  if (!trimmed) throw new Error("working directory required");
34237
- const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os15.homedir()) : path13.resolve(trimmed);
34303
+ const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os16.homedir()) : path14.resolve(trimmed);
34238
34304
  const normalizedType = this.providerLoader.resolveAlias(cliType);
34239
34305
  const rawProvider = this.providerLoader.getByAlias(cliType);
34240
34306
  const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
@@ -34837,7 +34903,7 @@ var init_readdirp = __esm({
34837
34903
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
34838
34904
  const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
34839
34905
  if (wantBigintFsStats) {
34840
- this._stat = (path35) => statMethod(path35, { bigint: true });
34906
+ this._stat = (path36) => statMethod(path36, { bigint: true });
34841
34907
  } else {
34842
34908
  this._stat = statMethod;
34843
34909
  }
@@ -34862,8 +34928,8 @@ var init_readdirp = __esm({
34862
34928
  const par = this.parent;
34863
34929
  const fil = par && par.files;
34864
34930
  if (fil && fil.length > 0) {
34865
- const { path: path35, depth } = par;
34866
- 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));
34867
34933
  const awaited = await Promise.all(slice);
34868
34934
  for (const entry of awaited) {
34869
34935
  if (!entry)
@@ -34903,20 +34969,20 @@ var init_readdirp = __esm({
34903
34969
  this.reading = false;
34904
34970
  }
34905
34971
  }
34906
- async _exploreDir(path35, depth) {
34972
+ async _exploreDir(path36, depth) {
34907
34973
  let files;
34908
34974
  try {
34909
- files = await (0, import_promises.readdir)(path35, this._rdOptions);
34975
+ files = await (0, import_promises.readdir)(path36, this._rdOptions);
34910
34976
  } catch (error48) {
34911
34977
  this._onError(error48);
34912
34978
  }
34913
- return { files, depth, path: path35 };
34979
+ return { files, depth, path: path36 };
34914
34980
  }
34915
- async _formatEntry(dirent, path35) {
34981
+ async _formatEntry(dirent, path36) {
34916
34982
  let entry;
34917
34983
  const basename10 = this._isDirent ? dirent.name : dirent;
34918
34984
  try {
34919
- 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));
34920
34986
  entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename10 };
34921
34987
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
34922
34988
  } catch (err) {
@@ -34973,16 +35039,16 @@ var init_readdirp = __esm({
34973
35039
  });
34974
35040
 
34975
35041
  // ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
34976
- function createFsWatchInstance(path35, options, listener, errHandler, emitRaw) {
35042
+ function createFsWatchInstance(path36, options, listener, errHandler, emitRaw) {
34977
35043
  const handleEvent = (rawEvent, evPath) => {
34978
- listener(path35);
34979
- emitRaw(rawEvent, evPath, { watchedPath: path35 });
34980
- if (evPath && path35 !== evPath) {
34981
- 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));
34982
35048
  }
34983
35049
  };
34984
35050
  try {
34985
- return (0, import_node_fs.watch)(path35, {
35051
+ return (0, import_node_fs.watch)(path36, {
34986
35052
  persistent: options.persistent
34987
35053
  }, handleEvent);
34988
35054
  } catch (error48) {
@@ -35331,12 +35397,12 @@ var init_handler2 = __esm({
35331
35397
  listener(val1, val2, val3);
35332
35398
  });
35333
35399
  };
35334
- setFsWatchListener = (path35, fullPath, options, handlers) => {
35400
+ setFsWatchListener = (path36, fullPath, options, handlers) => {
35335
35401
  const { listener, errHandler, rawEmitter } = handlers;
35336
35402
  let cont = FsWatchInstances.get(fullPath);
35337
35403
  let watcher;
35338
35404
  if (!options.persistent) {
35339
- watcher = createFsWatchInstance(path35, options, listener, errHandler, rawEmitter);
35405
+ watcher = createFsWatchInstance(path36, options, listener, errHandler, rawEmitter);
35340
35406
  if (!watcher)
35341
35407
  return;
35342
35408
  return watcher.close.bind(watcher);
@@ -35347,7 +35413,7 @@ var init_handler2 = __esm({
35347
35413
  addAndConvert(cont, KEY_RAW, rawEmitter);
35348
35414
  } else {
35349
35415
  watcher = createFsWatchInstance(
35350
- path35,
35416
+ path36,
35351
35417
  options,
35352
35418
  fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
35353
35419
  errHandler,
@@ -35362,7 +35428,7 @@ var init_handler2 = __esm({
35362
35428
  cont.watcherUnusable = true;
35363
35429
  if (isWindows && error48.code === "EPERM") {
35364
35430
  try {
35365
- const fd = await (0, import_promises2.open)(path35, "r");
35431
+ const fd = await (0, import_promises2.open)(path36, "r");
35366
35432
  await fd.close();
35367
35433
  broadcastErr(error48);
35368
35434
  } catch (err) {
@@ -35393,7 +35459,7 @@ var init_handler2 = __esm({
35393
35459
  };
35394
35460
  };
35395
35461
  FsWatchFileInstances = /* @__PURE__ */ new Map();
35396
- setFsWatchFileListener = (path35, fullPath, options, handlers) => {
35462
+ setFsWatchFileListener = (path36, fullPath, options, handlers) => {
35397
35463
  const { listener, rawEmitter } = handlers;
35398
35464
  let cont = FsWatchFileInstances.get(fullPath);
35399
35465
  const copts = cont && cont.options;
@@ -35415,7 +35481,7 @@ var init_handler2 = __esm({
35415
35481
  });
35416
35482
  const currmtime = curr.mtimeMs;
35417
35483
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
35418
- foreach(cont.listeners, (listener2) => listener2(path35, curr));
35484
+ foreach(cont.listeners, (listener2) => listener2(path36, curr));
35419
35485
  }
35420
35486
  })
35421
35487
  };
@@ -35445,13 +35511,13 @@ var init_handler2 = __esm({
35445
35511
  * @param listener on fs change
35446
35512
  * @returns closer for the watcher instance
35447
35513
  */
35448
- _watchWithNodeFs(path35, listener) {
35514
+ _watchWithNodeFs(path36, listener) {
35449
35515
  const opts = this.fsw.options;
35450
- const directory = sp.dirname(path35);
35451
- const basename10 = sp.basename(path35);
35516
+ const directory = sp.dirname(path36);
35517
+ const basename10 = sp.basename(path36);
35452
35518
  const parent = this.fsw._getWatchedDir(directory);
35453
35519
  parent.add(basename10);
35454
- const absolutePath = sp.resolve(path35);
35520
+ const absolutePath = sp.resolve(path36);
35455
35521
  const options = {
35456
35522
  persistent: opts.persistent
35457
35523
  };
@@ -35461,12 +35527,12 @@ var init_handler2 = __esm({
35461
35527
  if (opts.usePolling) {
35462
35528
  const enableBin = opts.interval !== opts.binaryInterval;
35463
35529
  options.interval = enableBin && isBinaryPath(basename10) ? opts.binaryInterval : opts.interval;
35464
- closer = setFsWatchFileListener(path35, absolutePath, options, {
35530
+ closer = setFsWatchFileListener(path36, absolutePath, options, {
35465
35531
  listener,
35466
35532
  rawEmitter: this.fsw._emitRaw
35467
35533
  });
35468
35534
  } else {
35469
- closer = setFsWatchListener(path35, absolutePath, options, {
35535
+ closer = setFsWatchListener(path36, absolutePath, options, {
35470
35536
  listener,
35471
35537
  errHandler: this._boundHandleError,
35472
35538
  rawEmitter: this.fsw._emitRaw
@@ -35488,7 +35554,7 @@ var init_handler2 = __esm({
35488
35554
  let prevStats = stats;
35489
35555
  if (parent.has(basename10))
35490
35556
  return;
35491
- const listener = async (path35, newStats) => {
35557
+ const listener = async (path36, newStats) => {
35492
35558
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
35493
35559
  return;
35494
35560
  if (!newStats || newStats.mtimeMs === 0) {
@@ -35502,11 +35568,11 @@ var init_handler2 = __esm({
35502
35568
  this.fsw._emit(EV.CHANGE, file2, newStats2);
35503
35569
  }
35504
35570
  if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
35505
- this.fsw._closeFile(path35);
35571
+ this.fsw._closeFile(path36);
35506
35572
  prevStats = newStats2;
35507
35573
  const closer2 = this._watchWithNodeFs(file2, listener);
35508
35574
  if (closer2)
35509
- this.fsw._addPathCloser(path35, closer2);
35575
+ this.fsw._addPathCloser(path36, closer2);
35510
35576
  } else {
35511
35577
  prevStats = newStats2;
35512
35578
  }
@@ -35538,7 +35604,7 @@ var init_handler2 = __esm({
35538
35604
  * @param item basename of this item
35539
35605
  * @returns true if no more processing is needed for this entry.
35540
35606
  */
35541
- async _handleSymlink(entry, directory, path35, item) {
35607
+ async _handleSymlink(entry, directory, path36, item) {
35542
35608
  if (this.fsw.closed) {
35543
35609
  return;
35544
35610
  }
@@ -35548,7 +35614,7 @@ var init_handler2 = __esm({
35548
35614
  this.fsw._incrReadyCount();
35549
35615
  let linkPath;
35550
35616
  try {
35551
- linkPath = await (0, import_promises2.realpath)(path35);
35617
+ linkPath = await (0, import_promises2.realpath)(path36);
35552
35618
  } catch (e) {
35553
35619
  this.fsw._emitReady();
35554
35620
  return true;
@@ -35558,12 +35624,12 @@ var init_handler2 = __esm({
35558
35624
  if (dir.has(item)) {
35559
35625
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
35560
35626
  this.fsw._symlinkPaths.set(full, linkPath);
35561
- this.fsw._emit(EV.CHANGE, path35, entry.stats);
35627
+ this.fsw._emit(EV.CHANGE, path36, entry.stats);
35562
35628
  }
35563
35629
  } else {
35564
35630
  dir.add(item);
35565
35631
  this.fsw._symlinkPaths.set(full, linkPath);
35566
- this.fsw._emit(EV.ADD, path35, entry.stats);
35632
+ this.fsw._emit(EV.ADD, path36, entry.stats);
35567
35633
  }
35568
35634
  this.fsw._emitReady();
35569
35635
  return true;
@@ -35593,9 +35659,9 @@ var init_handler2 = __esm({
35593
35659
  return;
35594
35660
  }
35595
35661
  const item = entry.path;
35596
- let path35 = sp.join(directory, item);
35662
+ let path36 = sp.join(directory, item);
35597
35663
  current.add(item);
35598
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path35, item)) {
35664
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path36, item)) {
35599
35665
  return;
35600
35666
  }
35601
35667
  if (this.fsw.closed) {
@@ -35604,8 +35670,8 @@ var init_handler2 = __esm({
35604
35670
  }
35605
35671
  if (item === target || !target && !previous.has(item)) {
35606
35672
  this.fsw._incrReadyCount();
35607
- path35 = sp.join(dir, sp.relative(dir, path35));
35608
- this._addToNodeFs(path35, initialAdd, wh, depth + 1);
35673
+ path36 = sp.join(dir, sp.relative(dir, path36));
35674
+ this._addToNodeFs(path36, initialAdd, wh, depth + 1);
35609
35675
  }
35610
35676
  }).on(EV.ERROR, this._boundHandleError);
35611
35677
  return new Promise((resolve18, reject) => {
@@ -35674,13 +35740,13 @@ var init_handler2 = __esm({
35674
35740
  * @param depth Child path actually targeted for watch
35675
35741
  * @param target Child path actually targeted for watch
35676
35742
  */
35677
- async _addToNodeFs(path35, initialAdd, priorWh, depth, target) {
35743
+ async _addToNodeFs(path36, initialAdd, priorWh, depth, target) {
35678
35744
  const ready = this.fsw._emitReady;
35679
- if (this.fsw._isIgnored(path35) || this.fsw.closed) {
35745
+ if (this.fsw._isIgnored(path36) || this.fsw.closed) {
35680
35746
  ready();
35681
35747
  return false;
35682
35748
  }
35683
- const wh = this.fsw._getWatchHelpers(path35);
35749
+ const wh = this.fsw._getWatchHelpers(path36);
35684
35750
  if (priorWh) {
35685
35751
  wh.filterPath = (entry) => priorWh.filterPath(entry);
35686
35752
  wh.filterDir = (entry) => priorWh.filterDir(entry);
@@ -35696,8 +35762,8 @@ var init_handler2 = __esm({
35696
35762
  const follow = this.fsw.options.followSymlinks;
35697
35763
  let closer;
35698
35764
  if (stats.isDirectory()) {
35699
- const absPath = sp.resolve(path35);
35700
- 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;
35701
35767
  if (this.fsw.closed)
35702
35768
  return;
35703
35769
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -35707,29 +35773,29 @@ var init_handler2 = __esm({
35707
35773
  this.fsw._symlinkPaths.set(absPath, targetPath);
35708
35774
  }
35709
35775
  } else if (stats.isSymbolicLink()) {
35710
- const targetPath = follow ? await (0, import_promises2.realpath)(path35) : path35;
35776
+ const targetPath = follow ? await (0, import_promises2.realpath)(path36) : path36;
35711
35777
  if (this.fsw.closed)
35712
35778
  return;
35713
35779
  const parent = sp.dirname(wh.watchPath);
35714
35780
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
35715
35781
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
35716
- closer = await this._handleDir(parent, stats, initialAdd, depth, path35, wh, targetPath);
35782
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path36, wh, targetPath);
35717
35783
  if (this.fsw.closed)
35718
35784
  return;
35719
35785
  if (targetPath !== void 0) {
35720
- this.fsw._symlinkPaths.set(sp.resolve(path35), targetPath);
35786
+ this.fsw._symlinkPaths.set(sp.resolve(path36), targetPath);
35721
35787
  }
35722
35788
  } else {
35723
35789
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
35724
35790
  }
35725
35791
  ready();
35726
35792
  if (closer)
35727
- this.fsw._addPathCloser(path35, closer);
35793
+ this.fsw._addPathCloser(path36, closer);
35728
35794
  return false;
35729
35795
  } catch (error48) {
35730
35796
  if (this.fsw._handleError(error48)) {
35731
35797
  ready();
35732
- return path35;
35798
+ return path36;
35733
35799
  }
35734
35800
  }
35735
35801
  }
@@ -35764,24 +35830,24 @@ function createPattern(matcher) {
35764
35830
  }
35765
35831
  return () => false;
35766
35832
  }
35767
- function normalizePath(path35) {
35768
- if (typeof path35 !== "string")
35833
+ function normalizePath(path36) {
35834
+ if (typeof path36 !== "string")
35769
35835
  throw new Error("string expected");
35770
- path35 = sp2.normalize(path35);
35771
- path35 = path35.replace(/\\/g, "/");
35836
+ path36 = sp2.normalize(path36);
35837
+ path36 = path36.replace(/\\/g, "/");
35772
35838
  let prepend = false;
35773
- if (path35.startsWith("//"))
35839
+ if (path36.startsWith("//"))
35774
35840
  prepend = true;
35775
- path35 = path35.replace(DOUBLE_SLASH_RE, "/");
35841
+ path36 = path36.replace(DOUBLE_SLASH_RE, "/");
35776
35842
  if (prepend)
35777
- path35 = "/" + path35;
35778
- return path35;
35843
+ path36 = "/" + path36;
35844
+ return path36;
35779
35845
  }
35780
35846
  function matchPatterns(patterns, testString, stats) {
35781
- const path35 = normalizePath(testString);
35847
+ const path36 = normalizePath(testString);
35782
35848
  for (let index = 0; index < patterns.length; index++) {
35783
35849
  const pattern = patterns[index];
35784
- if (pattern(path35, stats)) {
35850
+ if (pattern(path36, stats)) {
35785
35851
  return true;
35786
35852
  }
35787
35853
  }
@@ -35844,19 +35910,19 @@ var init_chokidar = __esm({
35844
35910
  }
35845
35911
  return str;
35846
35912
  };
35847
- normalizePathToUnix = (path35) => toUnix(sp2.normalize(toUnix(path35)));
35848
- normalizeIgnored = (cwd = "") => (path35) => {
35849
- if (typeof path35 === "string") {
35850
- 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));
35851
35917
  } else {
35852
- return path35;
35918
+ return path36;
35853
35919
  }
35854
35920
  };
35855
- getAbsolutePath = (path35, cwd) => {
35856
- if (sp2.isAbsolute(path35)) {
35857
- return path35;
35921
+ getAbsolutePath = (path36, cwd) => {
35922
+ if (sp2.isAbsolute(path36)) {
35923
+ return path36;
35858
35924
  }
35859
- return sp2.join(cwd, path35);
35925
+ return sp2.join(cwd, path36);
35860
35926
  };
35861
35927
  EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
35862
35928
  DirEntry = class {
@@ -35921,10 +35987,10 @@ var init_chokidar = __esm({
35921
35987
  dirParts;
35922
35988
  followSymlinks;
35923
35989
  statMethod;
35924
- constructor(path35, follow, fsw) {
35990
+ constructor(path36, follow, fsw) {
35925
35991
  this.fsw = fsw;
35926
- const watchPath = path35;
35927
- this.path = path35 = path35.replace(REPLACER_RE, "");
35992
+ const watchPath = path36;
35993
+ this.path = path36 = path36.replace(REPLACER_RE, "");
35928
35994
  this.watchPath = watchPath;
35929
35995
  this.fullWatchPath = sp2.resolve(watchPath);
35930
35996
  this.dirParts = [];
@@ -36064,20 +36130,20 @@ var init_chokidar = __esm({
36064
36130
  this._closePromise = void 0;
36065
36131
  let paths = unifyPaths(paths_);
36066
36132
  if (cwd) {
36067
- paths = paths.map((path35) => {
36068
- const absPath = getAbsolutePath(path35, cwd);
36133
+ paths = paths.map((path36) => {
36134
+ const absPath = getAbsolutePath(path36, cwd);
36069
36135
  return absPath;
36070
36136
  });
36071
36137
  }
36072
- paths.forEach((path35) => {
36073
- this._removeIgnoredPath(path35);
36138
+ paths.forEach((path36) => {
36139
+ this._removeIgnoredPath(path36);
36074
36140
  });
36075
36141
  this._userIgnored = void 0;
36076
36142
  if (!this._readyCount)
36077
36143
  this._readyCount = 0;
36078
36144
  this._readyCount += paths.length;
36079
- Promise.all(paths.map(async (path35) => {
36080
- 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);
36081
36147
  if (res)
36082
36148
  this._emitReady();
36083
36149
  return res;
@@ -36099,17 +36165,17 @@ var init_chokidar = __esm({
36099
36165
  return this;
36100
36166
  const paths = unifyPaths(paths_);
36101
36167
  const { cwd } = this.options;
36102
- paths.forEach((path35) => {
36103
- if (!sp2.isAbsolute(path35) && !this._closers.has(path35)) {
36168
+ paths.forEach((path36) => {
36169
+ if (!sp2.isAbsolute(path36) && !this._closers.has(path36)) {
36104
36170
  if (cwd)
36105
- path35 = sp2.join(cwd, path35);
36106
- path35 = sp2.resolve(path35);
36171
+ path36 = sp2.join(cwd, path36);
36172
+ path36 = sp2.resolve(path36);
36107
36173
  }
36108
- this._closePath(path35);
36109
- this._addIgnoredPath(path35);
36110
- if (this._watched.has(path35)) {
36174
+ this._closePath(path36);
36175
+ this._addIgnoredPath(path36);
36176
+ if (this._watched.has(path36)) {
36111
36177
  this._addIgnoredPath({
36112
- path: path35,
36178
+ path: path36,
36113
36179
  recursive: true
36114
36180
  });
36115
36181
  }
@@ -36173,38 +36239,38 @@ var init_chokidar = __esm({
36173
36239
  * @param stats arguments to be passed with event
36174
36240
  * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
36175
36241
  */
36176
- async _emit(event, path35, stats) {
36242
+ async _emit(event, path36, stats) {
36177
36243
  if (this.closed)
36178
36244
  return;
36179
36245
  const opts = this.options;
36180
36246
  if (isWindows)
36181
- path35 = sp2.normalize(path35);
36247
+ path36 = sp2.normalize(path36);
36182
36248
  if (opts.cwd)
36183
- path35 = sp2.relative(opts.cwd, path35);
36184
- const args = [path35];
36249
+ path36 = sp2.relative(opts.cwd, path36);
36250
+ const args = [path36];
36185
36251
  if (stats != null)
36186
36252
  args.push(stats);
36187
36253
  const awf = opts.awaitWriteFinish;
36188
36254
  let pw;
36189
- if (awf && (pw = this._pendingWrites.get(path35))) {
36255
+ if (awf && (pw = this._pendingWrites.get(path36))) {
36190
36256
  pw.lastChange = /* @__PURE__ */ new Date();
36191
36257
  return this;
36192
36258
  }
36193
36259
  if (opts.atomic) {
36194
36260
  if (event === EVENTS.UNLINK) {
36195
- this._pendingUnlinks.set(path35, [event, ...args]);
36261
+ this._pendingUnlinks.set(path36, [event, ...args]);
36196
36262
  setTimeout(() => {
36197
- this._pendingUnlinks.forEach((entry, path36) => {
36263
+ this._pendingUnlinks.forEach((entry, path37) => {
36198
36264
  this.emit(...entry);
36199
36265
  this.emit(EVENTS.ALL, ...entry);
36200
- this._pendingUnlinks.delete(path36);
36266
+ this._pendingUnlinks.delete(path37);
36201
36267
  });
36202
36268
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
36203
36269
  return this;
36204
36270
  }
36205
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path35)) {
36271
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path36)) {
36206
36272
  event = EVENTS.CHANGE;
36207
- this._pendingUnlinks.delete(path35);
36273
+ this._pendingUnlinks.delete(path36);
36208
36274
  }
36209
36275
  }
36210
36276
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -36222,16 +36288,16 @@ var init_chokidar = __esm({
36222
36288
  this.emitWithAll(event, args);
36223
36289
  }
36224
36290
  };
36225
- this._awaitWriteFinish(path35, awf.stabilityThreshold, event, awfEmit);
36291
+ this._awaitWriteFinish(path36, awf.stabilityThreshold, event, awfEmit);
36226
36292
  return this;
36227
36293
  }
36228
36294
  if (event === EVENTS.CHANGE) {
36229
- const isThrottled = !this._throttle(EVENTS.CHANGE, path35, 50);
36295
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path36, 50);
36230
36296
  if (isThrottled)
36231
36297
  return this;
36232
36298
  }
36233
36299
  if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
36234
- const fullPath = opts.cwd ? sp2.join(opts.cwd, path35) : path35;
36300
+ const fullPath = opts.cwd ? sp2.join(opts.cwd, path36) : path36;
36235
36301
  let stats2;
36236
36302
  try {
36237
36303
  stats2 = await (0, import_promises3.stat)(fullPath);
@@ -36262,23 +36328,23 @@ var init_chokidar = __esm({
36262
36328
  * @param timeout duration of time to suppress duplicate actions
36263
36329
  * @returns tracking object or false if action should be suppressed
36264
36330
  */
36265
- _throttle(actionType, path35, timeout) {
36331
+ _throttle(actionType, path36, timeout) {
36266
36332
  if (!this._throttled.has(actionType)) {
36267
36333
  this._throttled.set(actionType, /* @__PURE__ */ new Map());
36268
36334
  }
36269
36335
  const action = this._throttled.get(actionType);
36270
36336
  if (!action)
36271
36337
  throw new Error("invalid throttle");
36272
- const actionPath = action.get(path35);
36338
+ const actionPath = action.get(path36);
36273
36339
  if (actionPath) {
36274
36340
  actionPath.count++;
36275
36341
  return false;
36276
36342
  }
36277
36343
  let timeoutObject;
36278
36344
  const clear = () => {
36279
- const item = action.get(path35);
36345
+ const item = action.get(path36);
36280
36346
  const count = item ? item.count : 0;
36281
- action.delete(path35);
36347
+ action.delete(path36);
36282
36348
  clearTimeout(timeoutObject);
36283
36349
  if (item)
36284
36350
  clearTimeout(item.timeoutObject);
@@ -36286,7 +36352,7 @@ var init_chokidar = __esm({
36286
36352
  };
36287
36353
  timeoutObject = setTimeout(clear, timeout);
36288
36354
  const thr = { timeoutObject, clear, count: 0 };
36289
- action.set(path35, thr);
36355
+ action.set(path36, thr);
36290
36356
  return thr;
36291
36357
  }
36292
36358
  _incrReadyCount() {
@@ -36300,44 +36366,44 @@ var init_chokidar = __esm({
36300
36366
  * @param event
36301
36367
  * @param awfEmit Callback to be called when ready for event to be emitted.
36302
36368
  */
36303
- _awaitWriteFinish(path35, threshold, event, awfEmit) {
36369
+ _awaitWriteFinish(path36, threshold, event, awfEmit) {
36304
36370
  const awf = this.options.awaitWriteFinish;
36305
36371
  if (typeof awf !== "object")
36306
36372
  return;
36307
36373
  const pollInterval = awf.pollInterval;
36308
36374
  let timeoutHandler;
36309
- let fullPath = path35;
36310
- if (this.options.cwd && !sp2.isAbsolute(path35)) {
36311
- 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);
36312
36378
  }
36313
36379
  const now = /* @__PURE__ */ new Date();
36314
36380
  const writes = this._pendingWrites;
36315
36381
  function awaitWriteFinishFn(prevStat) {
36316
36382
  (0, import_node_fs2.stat)(fullPath, (err, curStat) => {
36317
- if (err || !writes.has(path35)) {
36383
+ if (err || !writes.has(path36)) {
36318
36384
  if (err && err.code !== "ENOENT")
36319
36385
  awfEmit(err);
36320
36386
  return;
36321
36387
  }
36322
36388
  const now2 = Number(/* @__PURE__ */ new Date());
36323
36389
  if (prevStat && curStat.size !== prevStat.size) {
36324
- writes.get(path35).lastChange = now2;
36390
+ writes.get(path36).lastChange = now2;
36325
36391
  }
36326
- const pw = writes.get(path35);
36392
+ const pw = writes.get(path36);
36327
36393
  const df = now2 - pw.lastChange;
36328
36394
  if (df >= threshold) {
36329
- writes.delete(path35);
36395
+ writes.delete(path36);
36330
36396
  awfEmit(void 0, curStat);
36331
36397
  } else {
36332
36398
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
36333
36399
  }
36334
36400
  });
36335
36401
  }
36336
- if (!writes.has(path35)) {
36337
- writes.set(path35, {
36402
+ if (!writes.has(path36)) {
36403
+ writes.set(path36, {
36338
36404
  lastChange: now,
36339
36405
  cancelWait: () => {
36340
- writes.delete(path35);
36406
+ writes.delete(path36);
36341
36407
  clearTimeout(timeoutHandler);
36342
36408
  return event;
36343
36409
  }
@@ -36348,8 +36414,8 @@ var init_chokidar = __esm({
36348
36414
  /**
36349
36415
  * Determines whether user has asked to ignore this path.
36350
36416
  */
36351
- _isIgnored(path35, stats) {
36352
- if (this.options.atomic && DOT_RE.test(path35))
36417
+ _isIgnored(path36, stats) {
36418
+ if (this.options.atomic && DOT_RE.test(path36))
36353
36419
  return true;
36354
36420
  if (!this._userIgnored) {
36355
36421
  const { cwd } = this.options;
@@ -36359,17 +36425,17 @@ var init_chokidar = __esm({
36359
36425
  const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
36360
36426
  this._userIgnored = anymatch(list, void 0);
36361
36427
  }
36362
- return this._userIgnored(path35, stats);
36428
+ return this._userIgnored(path36, stats);
36363
36429
  }
36364
- _isntIgnored(path35, stat4) {
36365
- return !this._isIgnored(path35, stat4);
36430
+ _isntIgnored(path36, stat4) {
36431
+ return !this._isIgnored(path36, stat4);
36366
36432
  }
36367
36433
  /**
36368
36434
  * Provides a set of common helpers and properties relating to symlink handling.
36369
36435
  * @param path file or directory pattern being watched
36370
36436
  */
36371
- _getWatchHelpers(path35) {
36372
- return new WatchHelper(path35, this.options.followSymlinks, this);
36437
+ _getWatchHelpers(path36) {
36438
+ return new WatchHelper(path36, this.options.followSymlinks, this);
36373
36439
  }
36374
36440
  // Directory helpers
36375
36441
  // -----------------
@@ -36401,63 +36467,63 @@ var init_chokidar = __esm({
36401
36467
  * @param item base path of item/directory
36402
36468
  */
36403
36469
  _remove(directory, item, isDirectory) {
36404
- const path35 = sp2.join(directory, item);
36405
- const fullPath = sp2.resolve(path35);
36406
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path35) || this._watched.has(fullPath);
36407
- 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))
36408
36474
  return;
36409
36475
  if (!isDirectory && this._watched.size === 1) {
36410
36476
  this.add(directory, item, true);
36411
36477
  }
36412
- const wp = this._getWatchedDir(path35);
36478
+ const wp = this._getWatchedDir(path36);
36413
36479
  const nestedDirectoryChildren = wp.getChildren();
36414
- nestedDirectoryChildren.forEach((nested) => this._remove(path35, nested));
36480
+ nestedDirectoryChildren.forEach((nested) => this._remove(path36, nested));
36415
36481
  const parent = this._getWatchedDir(directory);
36416
36482
  const wasTracked = parent.has(item);
36417
36483
  parent.remove(item);
36418
36484
  if (this._symlinkPaths.has(fullPath)) {
36419
36485
  this._symlinkPaths.delete(fullPath);
36420
36486
  }
36421
- let relPath = path35;
36487
+ let relPath = path36;
36422
36488
  if (this.options.cwd)
36423
- relPath = sp2.relative(this.options.cwd, path35);
36489
+ relPath = sp2.relative(this.options.cwd, path36);
36424
36490
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
36425
36491
  const event = this._pendingWrites.get(relPath).cancelWait();
36426
36492
  if (event === EVENTS.ADD)
36427
36493
  return;
36428
36494
  }
36429
- this._watched.delete(path35);
36495
+ this._watched.delete(path36);
36430
36496
  this._watched.delete(fullPath);
36431
36497
  const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
36432
- if (wasTracked && !this._isIgnored(path35))
36433
- this._emit(eventName, path35);
36434
- this._closePath(path35);
36498
+ if (wasTracked && !this._isIgnored(path36))
36499
+ this._emit(eventName, path36);
36500
+ this._closePath(path36);
36435
36501
  }
36436
36502
  /**
36437
36503
  * Closes all watchers for a path
36438
36504
  */
36439
- _closePath(path35) {
36440
- this._closeFile(path35);
36441
- const dir = sp2.dirname(path35);
36442
- 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));
36443
36509
  }
36444
36510
  /**
36445
36511
  * Closes only file-specific watchers
36446
36512
  */
36447
- _closeFile(path35) {
36448
- const closers = this._closers.get(path35);
36513
+ _closeFile(path36) {
36514
+ const closers = this._closers.get(path36);
36449
36515
  if (!closers)
36450
36516
  return;
36451
36517
  closers.forEach((closer) => closer());
36452
- this._closers.delete(path35);
36518
+ this._closers.delete(path36);
36453
36519
  }
36454
- _addPathCloser(path35, closer) {
36520
+ _addPathCloser(path36, closer) {
36455
36521
  if (!closer)
36456
36522
  return;
36457
- let list = this._closers.get(path35);
36523
+ let list = this._closers.get(path36);
36458
36524
  if (!list) {
36459
36525
  list = [];
36460
- this._closers.set(path35, list);
36526
+ this._closers.set(path36, list);
36461
36527
  }
36462
36528
  list.push(closer);
36463
36529
  }
@@ -36718,13 +36784,13 @@ var init_provider_schema = __esm({
36718
36784
  });
36719
36785
 
36720
36786
  // ../../oss/packages/daemon-core/src/providers/provider-loader.ts
36721
- var fs6, path14, os16, ProviderLoader;
36787
+ var fs7, path15, os17, ProviderLoader;
36722
36788
  var init_provider_loader = __esm({
36723
36789
  "../../oss/packages/daemon-core/src/providers/provider-loader.ts"() {
36724
36790
  "use strict";
36725
- fs6 = __toESM(require("fs"));
36726
- path14 = __toESM(require("path"));
36727
- os16 = __toESM(require("os"));
36791
+ fs7 = __toESM(require("fs"));
36792
+ path15 = __toESM(require("path"));
36793
+ os17 = __toESM(require("os"));
36728
36794
  init_chokidar();
36729
36795
  init_ide_detector();
36730
36796
  init_logger();
@@ -36758,9 +36824,9 @@ var init_provider_loader = __esm({
36758
36824
  static siblingStderrLogged = /* @__PURE__ */ new Set();
36759
36825
  static looksLikeProviderRoot(candidate) {
36760
36826
  try {
36761
- if (!fs6.existsSync(candidate) || !fs6.statSync(candidate).isDirectory()) return false;
36827
+ if (!fs7.existsSync(candidate) || !fs7.statSync(candidate).isDirectory()) return false;
36762
36828
  return ["ide", "extension", "cli", "acp"].some(
36763
- (category) => fs6.existsSync(path14.join(candidate, category))
36829
+ (category) => fs7.existsSync(path15.join(candidate, category))
36764
36830
  );
36765
36831
  } catch {
36766
36832
  return false;
@@ -36768,20 +36834,20 @@ var init_provider_loader = __esm({
36768
36834
  }
36769
36835
  static hasProviderRootMarker(candidate) {
36770
36836
  try {
36771
- return fs6.existsSync(path14.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
36837
+ return fs7.existsSync(path15.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
36772
36838
  } catch {
36773
36839
  return false;
36774
36840
  }
36775
36841
  }
36776
36842
  detectDefaultUserDir() {
36777
- const fallback2 = path14.join(os16.homedir(), ".adhdev", "providers");
36843
+ const fallback2 = path15.join(os17.homedir(), ".adhdev", "providers");
36778
36844
  const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
36779
36845
  const visited = /* @__PURE__ */ new Set();
36780
36846
  for (const start of this.probeStarts) {
36781
- let current = path14.resolve(start);
36847
+ let current = path15.resolve(start);
36782
36848
  while (!visited.has(current)) {
36783
36849
  visited.add(current);
36784
- const siblingCandidate = path14.join(path14.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
36850
+ const siblingCandidate = path15.join(path15.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
36785
36851
  if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
36786
36852
  const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
36787
36853
  if (envOptIn || hasMarker) {
@@ -36803,7 +36869,7 @@ var init_provider_loader = __esm({
36803
36869
  return { path: siblingCandidate, source };
36804
36870
  }
36805
36871
  }
36806
- const parent = path14.dirname(current);
36872
+ const parent = path15.dirname(current);
36807
36873
  if (parent === current) break;
36808
36874
  current = parent;
36809
36875
  }
@@ -36813,11 +36879,11 @@ var init_provider_loader = __esm({
36813
36879
  constructor(options) {
36814
36880
  this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
36815
36881
  this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
36816
- this.defaultProvidersDir = path14.join(os16.homedir(), ".adhdev", "providers");
36882
+ this.defaultProvidersDir = path15.join(os17.homedir(), ".adhdev", "providers");
36817
36883
  const detected = this.detectDefaultUserDir();
36818
36884
  this.userDir = detected.path;
36819
36885
  this.userDirSource = detected.source;
36820
- this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
36886
+ this.upstreamDir = path15.join(this.defaultProvidersDir, ".upstream");
36821
36887
  this.disableUpstream = false;
36822
36888
  this.applySourceConfig({
36823
36889
  userDir: options?.userDir,
@@ -36876,7 +36942,7 @@ var init_provider_loader = __esm({
36876
36942
  this.userDir = detected.path;
36877
36943
  this.userDirSource = detected.source;
36878
36944
  }
36879
- this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
36945
+ this.upstreamDir = path15.join(this.defaultProvidersDir, ".upstream");
36880
36946
  this.disableUpstream = this.sourceMode === "no-upstream";
36881
36947
  if (this.explicitProviderDir) {
36882
36948
  this.log(`Config 'providerDir' applied: ${this.userDir}`);
@@ -36890,7 +36956,7 @@ var init_provider_loader = __esm({
36890
36956
  * Canonical provider directory shape for a given root.
36891
36957
  */
36892
36958
  getProviderDir(root, category, type) {
36893
- return path14.join(root, category, type);
36959
+ return path15.join(root, category, type);
36894
36960
  }
36895
36961
  /**
36896
36962
  * Canonical user override directory for a provider.
@@ -36917,7 +36983,7 @@ var init_provider_loader = __esm({
36917
36983
  resolveProviderFile(type, ...segments) {
36918
36984
  const dir = this.findProviderDirInternal(type);
36919
36985
  if (!dir) return null;
36920
- return path14.join(dir, ...segments);
36986
+ return path15.join(dir, ...segments);
36921
36987
  }
36922
36988
  /**
36923
36989
  * Load all providers (3-tier priority)
@@ -36930,7 +36996,7 @@ var init_provider_loader = __esm({
36930
36996
  this.providers.clear();
36931
36997
  this.providerAvailability.clear();
36932
36998
  let upstreamCount = 0;
36933
- if (!this.disableUpstream && fs6.existsSync(this.upstreamDir)) {
36999
+ if (!this.disableUpstream && fs7.existsSync(this.upstreamDir)) {
36934
37000
  upstreamCount = this.loadDir(this.upstreamDir);
36935
37001
  if (upstreamCount > 0) {
36936
37002
  this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
@@ -36938,7 +37004,7 @@ var init_provider_loader = __esm({
36938
37004
  } else if (this.disableUpstream) {
36939
37005
  this.log("Upstream loading disabled (sourceMode=no-upstream)");
36940
37006
  }
36941
- if (fs6.existsSync(this.userDir)) {
37007
+ if (fs7.existsSync(this.userDir)) {
36942
37008
  const userCount = this.loadDir(this.userDir, [".upstream"]);
36943
37009
  if (userCount > 0) {
36944
37010
  this.log(`Loaded ${userCount} user custom providers (never auto-updated)`);
@@ -36953,10 +37019,10 @@ var init_provider_loader = __esm({
36953
37019
  * Check if upstream directory exists and has providers.
36954
37020
  */
36955
37021
  hasUpstream() {
36956
- if (!fs6.existsSync(this.upstreamDir)) return false;
37022
+ if (!fs7.existsSync(this.upstreamDir)) return false;
36957
37023
  try {
36958
- return fs6.readdirSync(this.upstreamDir).some(
36959
- (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()
36960
37026
  );
36961
37027
  } catch {
36962
37028
  return false;
@@ -37453,8 +37519,8 @@ var init_provider_loader = __esm({
37453
37519
  resolved._resolvedScriptDir = entry.scriptDir;
37454
37520
  resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
37455
37521
  if (providerDir) {
37456
- const fullDir = path14.join(providerDir, entry.scriptDir);
37457
- 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;
37458
37524
  }
37459
37525
  matched = true;
37460
37526
  }
@@ -37469,8 +37535,8 @@ var init_provider_loader = __esm({
37469
37535
  resolved._resolvedScriptDir = base.defaultScriptDir;
37470
37536
  resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
37471
37537
  if (providerDir) {
37472
- const fullDir = path14.join(providerDir, base.defaultScriptDir);
37473
- 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;
37474
37540
  }
37475
37541
  }
37476
37542
  resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
@@ -37487,8 +37553,8 @@ var init_provider_loader = __esm({
37487
37553
  resolved._resolvedScriptDir = dirOverride;
37488
37554
  resolved._resolvedScriptsSource = `versions:${range}`;
37489
37555
  if (providerDir) {
37490
- const fullDir = path14.join(providerDir, dirOverride);
37491
- 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;
37492
37558
  }
37493
37559
  }
37494
37560
  } else if (override.scripts) {
@@ -37504,8 +37570,8 @@ var init_provider_loader = __esm({
37504
37570
  resolved._resolvedScriptDir = base.defaultScriptDir;
37505
37571
  resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
37506
37572
  if (providerDir) {
37507
- const fullDir = path14.join(providerDir, base.defaultScriptDir);
37508
- 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;
37509
37575
  }
37510
37576
  }
37511
37577
  }
@@ -37537,15 +37603,15 @@ var init_provider_loader = __esm({
37537
37603
  this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
37538
37604
  return null;
37539
37605
  }
37540
- const dir = path14.join(providerDir, scriptDir);
37541
- if (!fs6.existsSync(dir)) {
37606
+ const dir = path15.join(providerDir, scriptDir);
37607
+ if (!fs7.existsSync(dir)) {
37542
37608
  this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
37543
37609
  return null;
37544
37610
  }
37545
37611
  const cached2 = this.scriptsCache.get(dir);
37546
37612
  if (cached2) return cached2;
37547
- const scriptsJs = path14.join(dir, "scripts.js");
37548
- if (fs6.existsSync(scriptsJs)) {
37613
+ const scriptsJs = path15.join(dir, "scripts.js");
37614
+ if (fs7.existsSync(scriptsJs)) {
37549
37615
  try {
37550
37616
  delete require.cache[require.resolve(scriptsJs)];
37551
37617
  const loaded = require(scriptsJs);
@@ -37566,9 +37632,9 @@ var init_provider_loader = __esm({
37566
37632
  watch() {
37567
37633
  this.stopWatch();
37568
37634
  const watchDir = (dir) => {
37569
- if (!fs6.existsSync(dir)) {
37635
+ if (!fs7.existsSync(dir)) {
37570
37636
  try {
37571
- fs6.mkdirSync(dir, { recursive: true });
37637
+ fs7.mkdirSync(dir, { recursive: true });
37572
37638
  } catch {
37573
37639
  return;
37574
37640
  }
@@ -37586,7 +37652,7 @@ var init_provider_loader = __esm({
37586
37652
  return;
37587
37653
  }
37588
37654
  if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
37589
- this.log(`File changed: ${path14.basename(filePath)}, reloading...`);
37655
+ this.log(`File changed: ${path15.basename(filePath)}, reloading...`);
37590
37656
  this.reload();
37591
37657
  }
37592
37658
  };
@@ -37641,12 +37707,12 @@ var init_provider_loader = __esm({
37641
37707
  }
37642
37708
  const https = require("https");
37643
37709
  const { execSync: execSync8 } = require("child_process");
37644
- const metaPath = path14.join(this.upstreamDir, _ProviderLoader.META_FILE);
37710
+ const metaPath = path15.join(this.upstreamDir, _ProviderLoader.META_FILE);
37645
37711
  let prevEtag = "";
37646
37712
  let prevTimestamp = 0;
37647
37713
  try {
37648
- if (fs6.existsSync(metaPath)) {
37649
- const meta3 = JSON.parse(fs6.readFileSync(metaPath, "utf-8"));
37714
+ if (fs7.existsSync(metaPath)) {
37715
+ const meta3 = JSON.parse(fs7.readFileSync(metaPath, "utf-8"));
37650
37716
  prevEtag = meta3.etag || "";
37651
37717
  prevTimestamp = meta3.timestamp || 0;
37652
37718
  }
@@ -37701,39 +37767,39 @@ var init_provider_loader = __esm({
37701
37767
  return { updated: false };
37702
37768
  }
37703
37769
  this.log("Downloading latest providers from GitHub...");
37704
- const tmpTar = path14.join(os16.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
37705
- 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()}`);
37706
37772
  await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
37707
- fs6.mkdirSync(tmpExtract, { recursive: true });
37773
+ fs7.mkdirSync(tmpExtract, { recursive: true });
37708
37774
  execSync8(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
37709
- const extracted = fs6.readdirSync(tmpExtract);
37775
+ const extracted = fs7.readdirSync(tmpExtract);
37710
37776
  const rootDir = extracted.find(
37711
- (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")
37712
37778
  );
37713
37779
  if (!rootDir) throw new Error("Unexpected tarball structure");
37714
- const sourceDir = path14.join(tmpExtract, rootDir);
37780
+ const sourceDir = path15.join(tmpExtract, rootDir);
37715
37781
  const backupDir = this.upstreamDir + ".bak";
37716
- if (fs6.existsSync(this.upstreamDir)) {
37717
- if (fs6.existsSync(backupDir)) fs6.rmSync(backupDir, { recursive: true, force: true });
37718
- 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);
37719
37785
  }
37720
37786
  try {
37721
37787
  this.copyDirRecursive(sourceDir, this.upstreamDir);
37722
37788
  this.writeMeta(metaPath, etag || `ts-${Date.now()}`, Date.now());
37723
- if (fs6.existsSync(backupDir)) fs6.rmSync(backupDir, { recursive: true, force: true });
37789
+ if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
37724
37790
  } catch (e) {
37725
- if (fs6.existsSync(backupDir)) {
37726
- if (fs6.existsSync(this.upstreamDir)) fs6.rmSync(this.upstreamDir, { recursive: true, force: true });
37727
- 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);
37728
37794
  }
37729
37795
  throw e;
37730
37796
  }
37731
37797
  try {
37732
- fs6.rmSync(tmpTar, { force: true });
37798
+ fs7.rmSync(tmpTar, { force: true });
37733
37799
  } catch {
37734
37800
  }
37735
37801
  try {
37736
- fs6.rmSync(tmpExtract, { recursive: true, force: true });
37802
+ fs7.rmSync(tmpExtract, { recursive: true, force: true });
37737
37803
  } catch {
37738
37804
  }
37739
37805
  const upstreamCount = this.countProviders(this.upstreamDir);
@@ -37765,7 +37831,7 @@ var init_provider_loader = __esm({
37765
37831
  reject(new Error(`HTTP ${res.statusCode}`));
37766
37832
  return;
37767
37833
  }
37768
- const ws = fs6.createWriteStream(destPath);
37834
+ const ws = fs7.createWriteStream(destPath);
37769
37835
  res.pipe(ws);
37770
37836
  ws.on("finish", () => {
37771
37837
  ws.close();
@@ -37784,22 +37850,22 @@ var init_provider_loader = __esm({
37784
37850
  }
37785
37851
  /** Recursive directory copy */
37786
37852
  copyDirRecursive(src, dest) {
37787
- fs6.mkdirSync(dest, { recursive: true });
37788
- for (const entry of fs6.readdirSync(src, { withFileTypes: true })) {
37789
- const srcPath = path14.join(src, entry.name);
37790
- 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);
37791
37857
  if (entry.isDirectory()) {
37792
37858
  this.copyDirRecursive(srcPath, destPath);
37793
37859
  } else {
37794
- fs6.copyFileSync(srcPath, destPath);
37860
+ fs7.copyFileSync(srcPath, destPath);
37795
37861
  }
37796
37862
  }
37797
37863
  }
37798
37864
  /** .meta.json save */
37799
37865
  writeMeta(metaPath, etag, timestamp) {
37800
37866
  try {
37801
- fs6.mkdirSync(path14.dirname(metaPath), { recursive: true });
37802
- fs6.writeFileSync(metaPath, JSON.stringify({
37867
+ fs7.mkdirSync(path15.dirname(metaPath), { recursive: true });
37868
+ fs7.writeFileSync(metaPath, JSON.stringify({
37803
37869
  etag,
37804
37870
  timestamp,
37805
37871
  lastCheck: new Date(timestamp).toISOString(),
@@ -37810,12 +37876,12 @@ var init_provider_loader = __esm({
37810
37876
  }
37811
37877
  /** Count provider files (provider.js or provider.json) */
37812
37878
  countProviders(dir) {
37813
- if (!fs6.existsSync(dir)) return 0;
37879
+ if (!fs7.existsSync(dir)) return 0;
37814
37880
  let count = 0;
37815
37881
  const scan = (d) => {
37816
37882
  try {
37817
- for (const entry of fs6.readdirSync(d, { withFileTypes: true })) {
37818
- 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));
37819
37885
  else if (entry.name === "provider.json") count++;
37820
37886
  }
37821
37887
  } catch {
@@ -38041,19 +38107,19 @@ var init_provider_loader = __esm({
38041
38107
  const cat = provider.category;
38042
38108
  const searchRoots = this.getProviderRoots();
38043
38109
  for (const root of searchRoots) {
38044
- if (!fs6.existsSync(root)) continue;
38110
+ if (!fs7.existsSync(root)) continue;
38045
38111
  const candidate = this.getProviderDir(root, cat, type);
38046
- if (fs6.existsSync(path14.join(candidate, "provider.json"))) return candidate;
38047
- const catDir = path14.join(root, cat);
38048
- 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)) {
38049
38115
  try {
38050
- for (const entry of fs6.readdirSync(catDir, { withFileTypes: true })) {
38116
+ for (const entry of fs7.readdirSync(catDir, { withFileTypes: true })) {
38051
38117
  if (!entry.isDirectory()) continue;
38052
- const jsonPath = path14.join(catDir, entry.name, "provider.json");
38053
- if (fs6.existsSync(jsonPath)) {
38118
+ const jsonPath = path15.join(catDir, entry.name, "provider.json");
38119
+ if (fs7.existsSync(jsonPath)) {
38054
38120
  try {
38055
- const data = JSON.parse(fs6.readFileSync(jsonPath, "utf-8"));
38056
- 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);
38057
38123
  } catch {
38058
38124
  }
38059
38125
  }
@@ -38070,8 +38136,8 @@ var init_provider_loader = __esm({
38070
38136
  * (template substitution is NOT applied here — scripts.js handles that)
38071
38137
  */
38072
38138
  buildScriptWrappersFromDir(dir) {
38073
- const scriptsJs = path14.join(dir, "scripts.js");
38074
- if (fs6.existsSync(scriptsJs)) {
38139
+ const scriptsJs = path15.join(dir, "scripts.js");
38140
+ if (fs7.existsSync(scriptsJs)) {
38075
38141
  try {
38076
38142
  delete require.cache[require.resolve(scriptsJs)];
38077
38143
  return require(scriptsJs);
@@ -38081,13 +38147,13 @@ var init_provider_loader = __esm({
38081
38147
  const toCamel = (name) => name.replace(/_([a-z])/g, (_2, c) => c.toUpperCase());
38082
38148
  const result = {};
38083
38149
  try {
38084
- for (const file2 of fs6.readdirSync(dir)) {
38150
+ for (const file2 of fs7.readdirSync(dir)) {
38085
38151
  if (!file2.endsWith(".js")) continue;
38086
38152
  const scriptName = toCamel(file2.replace(".js", ""));
38087
- const filePath = path14.join(dir, file2);
38153
+ const filePath = path15.join(dir, file2);
38088
38154
  result[scriptName] = (...args) => {
38089
38155
  try {
38090
- let content = fs6.readFileSync(filePath, "utf-8");
38156
+ let content = fs7.readFileSync(filePath, "utf-8");
38091
38157
  if (args[0] && typeof args[0] === "object") {
38092
38158
  for (const [key, val] of Object.entries(args[0])) {
38093
38159
  let v = val;
@@ -38133,20 +38199,20 @@ var init_provider_loader = __esm({
38133
38199
  * Structure: dir/category/agent-name/provider.{json,js}
38134
38200
  */
38135
38201
  loadDir(dir, excludeDirs) {
38136
- if (!fs6.existsSync(dir)) return 0;
38202
+ if (!fs7.existsSync(dir)) return 0;
38137
38203
  let count = 0;
38138
38204
  const scan = (d) => {
38139
38205
  let entries;
38140
38206
  try {
38141
- entries = fs6.readdirSync(d, { withFileTypes: true });
38207
+ entries = fs7.readdirSync(d, { withFileTypes: true });
38142
38208
  } catch {
38143
38209
  return;
38144
38210
  }
38145
38211
  const hasJson = entries.some((e) => e.name === "provider.json");
38146
38212
  if (hasJson) {
38147
- const jsonPath = path14.join(d, "provider.json");
38213
+ const jsonPath = path15.join(d, "provider.json");
38148
38214
  try {
38149
- const raw = fs6.readFileSync(jsonPath, "utf-8");
38215
+ const raw = fs7.readFileSync(jsonPath, "utf-8");
38150
38216
  const mod = JSON.parse(raw);
38151
38217
  if (typeof mod.extensionIdPattern === "string") {
38152
38218
  const flags = mod.extensionIdPattern_flags || "";
@@ -38165,8 +38231,8 @@ var init_provider_loader = __esm({
38165
38231
  this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
38166
38232
  } else {
38167
38233
  const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
38168
- const scriptsPath = path14.join(d, "scripts.js");
38169
- if (!hasCompatibility && fs6.existsSync(scriptsPath)) {
38234
+ const scriptsPath = path15.join(d, "scripts.js");
38235
+ if (!hasCompatibility && fs7.existsSync(scriptsPath)) {
38170
38236
  try {
38171
38237
  delete require.cache[require.resolve(scriptsPath)];
38172
38238
  const scripts = require(scriptsPath);
@@ -38191,7 +38257,7 @@ var init_provider_loader = __esm({
38191
38257
  if (!entry.isDirectory()) continue;
38192
38258
  if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
38193
38259
  if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
38194
- scan(path14.join(d, entry.name));
38260
+ scan(path15.join(d, entry.name));
38195
38261
  }
38196
38262
  }
38197
38263
  };
@@ -38387,7 +38453,7 @@ async function isCdpActive(port) {
38387
38453
  });
38388
38454
  }
38389
38455
  async function killIdeProcess(ideId) {
38390
- const plat = os17.platform();
38456
+ const plat = os18.platform();
38391
38457
  const appName = getMacAppIdentifiers()[ideId];
38392
38458
  const winProcesses = getWinProcessNames()[ideId];
38393
38459
  try {
@@ -38448,7 +38514,7 @@ async function killIdeProcess(ideId) {
38448
38514
  }
38449
38515
  }
38450
38516
  function isIdeRunning(ideId) {
38451
- const plat = os17.platform();
38517
+ const plat = os18.platform();
38452
38518
  try {
38453
38519
  if (plat === "darwin") {
38454
38520
  const appName = getMacAppIdentifiers()[ideId];
@@ -38503,7 +38569,7 @@ function isIdeRunning(ideId) {
38503
38569
  }
38504
38570
  }
38505
38571
  function detectCurrentWorkspace(ideId) {
38506
- const plat = os17.platform();
38572
+ const plat = os18.platform();
38507
38573
  if (plat === "darwin") {
38508
38574
  try {
38509
38575
  const appName = getMacAppIdentifiers()[ideId];
@@ -38518,17 +38584,17 @@ function detectCurrentWorkspace(ideId) {
38518
38584
  }
38519
38585
  } else if (plat === "win32") {
38520
38586
  try {
38521
- const fs22 = require("fs");
38587
+ const fs23 = require("fs");
38522
38588
  const appNameMap = getMacAppIdentifiers();
38523
38589
  const appName = appNameMap[ideId];
38524
38590
  if (appName) {
38525
- const storagePath = path15.join(
38526
- process.env.APPDATA || path15.join(os17.homedir(), "AppData", "Roaming"),
38591
+ const storagePath = path16.join(
38592
+ process.env.APPDATA || path16.join(os18.homedir(), "AppData", "Roaming"),
38527
38593
  appName,
38528
38594
  "storage.json"
38529
38595
  );
38530
- if (fs22.existsSync(storagePath)) {
38531
- const data = JSON.parse(fs22.readFileSync(storagePath, "utf-8"));
38596
+ if (fs23.existsSync(storagePath)) {
38597
+ const data = JSON.parse(fs23.readFileSync(storagePath, "utf-8"));
38532
38598
  const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
38533
38599
  if (workspaces.length > 0) {
38534
38600
  const recent = workspaces[0];
@@ -38545,7 +38611,7 @@ function detectCurrentWorkspace(ideId) {
38545
38611
  return void 0;
38546
38612
  }
38547
38613
  async function launchWithCdp(options = {}) {
38548
- const platform12 = os17.platform();
38614
+ const platform12 = os18.platform();
38549
38615
  let targetIde;
38550
38616
  const ides = await detectIDEs(getProviderLoader());
38551
38617
  if (options.ideId) {
@@ -38694,14 +38760,14 @@ async function launchLinux(ide, port, workspace, newWindow) {
38694
38760
  function getAvailableIdeIds() {
38695
38761
  return getProviderLoader().getAvailableIdeTypes();
38696
38762
  }
38697
- var import_child_process7, net2, os17, path15, _providerLoader;
38763
+ var import_child_process7, net2, os18, path16, _providerLoader;
38698
38764
  var init_launch = __esm({
38699
38765
  "../../oss/packages/daemon-core/src/launch.ts"() {
38700
38766
  "use strict";
38701
38767
  import_child_process7 = require("child_process");
38702
38768
  net2 = __toESM(require("net"));
38703
- os17 = __toESM(require("os"));
38704
- path15 = __toESM(require("path"));
38769
+ os18 = __toESM(require("os"));
38770
+ path16 = __toESM(require("path"));
38705
38771
  init_ide_detector();
38706
38772
  init_provider_loader();
38707
38773
  init_macos_app_process();
@@ -38733,13 +38799,13 @@ function checkRotation() {
38733
38799
  const today = getDateStr2();
38734
38800
  if (today !== currentDate2) {
38735
38801
  currentDate2 = today;
38736
- currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
38802
+ currentFile = path17.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
38737
38803
  cleanOldFiles();
38738
38804
  }
38739
38805
  }
38740
38806
  function cleanOldFiles() {
38741
38807
  try {
38742
- 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"));
38743
38809
  const cutoff = /* @__PURE__ */ new Date();
38744
38810
  cutoff.setDate(cutoff.getDate() - MAX_DAYS);
38745
38811
  const cutoffStr = cutoff.toISOString().slice(0, 10);
@@ -38747,7 +38813,7 @@ function cleanOldFiles() {
38747
38813
  const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
38748
38814
  if (dateMatch && dateMatch[1] < cutoffStr) {
38749
38815
  try {
38750
- fs7.unlinkSync(path16.join(LOG_DIR2, file2));
38816
+ fs8.unlinkSync(path17.join(LOG_DIR2, file2));
38751
38817
  } catch {
38752
38818
  }
38753
38819
  }
@@ -38757,14 +38823,14 @@ function cleanOldFiles() {
38757
38823
  }
38758
38824
  function checkSize() {
38759
38825
  try {
38760
- const stat4 = fs7.statSync(currentFile);
38826
+ const stat4 = fs8.statSync(currentFile);
38761
38827
  if (stat4.size > MAX_FILE_SIZE) {
38762
38828
  const backup = currentFile.replace(".jsonl", ".1.jsonl");
38763
38829
  try {
38764
- fs7.unlinkSync(backup);
38830
+ fs8.unlinkSync(backup);
38765
38831
  } catch {
38766
38832
  }
38767
- fs7.renameSync(currentFile, backup);
38833
+ fs8.renameSync(currentFile, backup);
38768
38834
  }
38769
38835
  } catch {
38770
38836
  }
@@ -38789,14 +38855,14 @@ function logCommand(entry) {
38789
38855
  ...entry.error ? { err: entry.error } : {},
38790
38856
  ...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
38791
38857
  });
38792
- fs7.appendFileSync(currentFile, line + "\n");
38858
+ fs8.appendFileSync(currentFile, line + "\n");
38793
38859
  } catch {
38794
38860
  }
38795
38861
  }
38796
38862
  function getRecentCommands(count = 50) {
38797
38863
  try {
38798
- if (!fs7.existsSync(currentFile)) return [];
38799
- const content = fs7.readFileSync(currentFile, "utf-8");
38864
+ if (!fs8.existsSync(currentFile)) return [];
38865
+ const content = fs8.readFileSync(currentFile, "utf-8");
38800
38866
  const lines = content.trim().split("\n").filter(Boolean);
38801
38867
  return lines.slice(-count).map((line) => {
38802
38868
  try {
@@ -38819,18 +38885,18 @@ function getRecentCommands(count = 50) {
38819
38885
  return [];
38820
38886
  }
38821
38887
  }
38822
- 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;
38823
38889
  var init_command_log = __esm({
38824
38890
  "../../oss/packages/daemon-core/src/logging/command-log.ts"() {
38825
38891
  "use strict";
38826
- fs7 = __toESM(require("fs"));
38827
- path16 = __toESM(require("path"));
38828
- os18 = __toESM(require("os"));
38829
- 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");
38830
38896
  MAX_FILE_SIZE = 5 * 1024 * 1024;
38831
38897
  MAX_DAYS = 7;
38832
38898
  try {
38833
- fs7.mkdirSync(LOG_DIR2, { recursive: true });
38899
+ fs8.mkdirSync(LOG_DIR2, { recursive: true });
38834
38900
  } catch {
38835
38901
  }
38836
38902
  SENSITIVE_KEYS = /* @__PURE__ */ new Set([
@@ -38845,7 +38911,7 @@ var init_command_log = __esm({
38845
38911
  "text"
38846
38912
  ]);
38847
38913
  currentDate2 = getDateStr2();
38848
- currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
38914
+ currentFile = path17.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
38849
38915
  writeCount2 = 0;
38850
38916
  SKIP_COMMANDS = /* @__PURE__ */ new Set([
38851
38917
  "heartbeat",
@@ -38909,8 +38975,8 @@ function buildAvailableProviders(providerLoader) {
38909
38975
  }
38910
38976
  function buildMachineInfo(profile = "full") {
38911
38977
  const base = {
38912
- hostname: os19.hostname(),
38913
- platform: os19.platform()
38978
+ hostname: os20.hostname(),
38979
+ platform: os20.platform()
38914
38980
  };
38915
38981
  if (profile === "live") {
38916
38982
  return base;
@@ -38919,23 +38985,23 @@ function buildMachineInfo(profile = "full") {
38919
38985
  const memSnap2 = getHostMemorySnapshot();
38920
38986
  return {
38921
38987
  ...base,
38922
- arch: os19.arch(),
38923
- cpus: os19.cpus().length,
38988
+ arch: os20.arch(),
38989
+ cpus: os20.cpus().length,
38924
38990
  totalMem: memSnap2.totalMem,
38925
- release: os19.release()
38991
+ release: os20.release()
38926
38992
  };
38927
38993
  }
38928
38994
  const memSnap = getHostMemorySnapshot();
38929
38995
  return {
38930
38996
  ...base,
38931
- arch: os19.arch(),
38932
- cpus: os19.cpus().length,
38997
+ arch: os20.arch(),
38998
+ cpus: os20.cpus().length,
38933
38999
  totalMem: memSnap.totalMem,
38934
39000
  freeMem: memSnap.freeMem,
38935
39001
  availableMem: memSnap.availableMem,
38936
- loadavg: os19.loadavg(),
38937
- uptime: os19.uptime(),
38938
- release: os19.release()
39002
+ loadavg: os20.loadavg(),
39003
+ uptime: os20.uptime(),
39004
+ release: os20.release()
38939
39005
  };
38940
39006
  }
38941
39007
  function parseMessageTime(value) {
@@ -39158,11 +39224,11 @@ function buildStatusSnapshot(options) {
39158
39224
  }
39159
39225
  };
39160
39226
  }
39161
- var os19, READ_DEBUG_ENABLED, recentReadDebugSignatureBySession;
39227
+ var os20, READ_DEBUG_ENABLED, recentReadDebugSignatureBySession;
39162
39228
  var init_snapshot = __esm({
39163
39229
  "../../oss/packages/daemon-core/src/status/snapshot.ts"() {
39164
39230
  "use strict";
39165
- os19 = __toESM(require("os"));
39231
+ os20 = __toESM(require("os"));
39166
39232
  init_config();
39167
39233
  init_state_store();
39168
39234
  init_recent_activity();
@@ -39180,37 +39246,37 @@ var init_snapshot = __esm({
39180
39246
 
39181
39247
  // ../../oss/packages/daemon-core/src/commands/upgrade-helper.ts
39182
39248
  function getUpgradeLogPath() {
39183
- const home = os20.homedir();
39184
- const dir = path17.join(home, ".adhdev");
39185
- fs8.mkdirSync(dir, { recursive: true });
39186
- 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");
39187
39253
  }
39188
39254
  function appendUpgradeLog(message) {
39189
39255
  const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
39190
39256
  `;
39191
39257
  try {
39192
- fs8.appendFileSync(getUpgradeLogPath(), line, "utf8");
39258
+ fs9.appendFileSync(getUpgradeLogPath(), line, "utf8");
39193
39259
  } catch {
39194
39260
  }
39195
39261
  }
39196
39262
  function resolveSiblingNpmInvocation(nodeExecutable, platform12 = process.platform) {
39197
- const binDir = path17.dirname(nodeExecutable);
39263
+ const binDir = path18.dirname(nodeExecutable);
39198
39264
  if (platform12 === "win32") {
39199
- const npmCliPath = path17.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
39200
- if (fs8.existsSync(npmCliPath)) {
39265
+ const npmCliPath = path18.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
39266
+ if (fs9.existsSync(npmCliPath)) {
39201
39267
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
39202
39268
  }
39203
39269
  for (const candidate of ["npm.exe", "npm"]) {
39204
- const candidatePath = path17.join(binDir, candidate);
39205
- if (fs8.existsSync(candidatePath)) {
39270
+ const candidatePath = path18.join(binDir, candidate);
39271
+ if (fs9.existsSync(candidatePath)) {
39206
39272
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
39207
39273
  }
39208
39274
  }
39209
39275
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
39210
39276
  }
39211
39277
  for (const candidate of ["npm"]) {
39212
- const candidatePath = path17.join(binDir, candidate);
39213
- if (fs8.existsSync(candidatePath)) {
39278
+ const candidatePath = path18.join(binDir, candidate);
39279
+ if (fs9.existsSync(candidatePath)) {
39214
39280
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
39215
39281
  }
39216
39282
  }
@@ -39220,22 +39286,22 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
39220
39286
  if (!currentCliPath) return null;
39221
39287
  let resolvedPath = currentCliPath;
39222
39288
  try {
39223
- resolvedPath = fs8.realpathSync.native(currentCliPath);
39289
+ resolvedPath = fs9.realpathSync.native(currentCliPath);
39224
39290
  } catch {
39225
39291
  }
39226
39292
  let currentDir = resolvedPath;
39227
39293
  try {
39228
- if (fs8.statSync(resolvedPath).isFile()) {
39229
- currentDir = path17.dirname(resolvedPath);
39294
+ if (fs9.statSync(resolvedPath).isFile()) {
39295
+ currentDir = path18.dirname(resolvedPath);
39230
39296
  }
39231
39297
  } catch {
39232
- currentDir = path17.dirname(resolvedPath);
39298
+ currentDir = path18.dirname(resolvedPath);
39233
39299
  }
39234
39300
  while (true) {
39235
- const packageJsonPath = path17.join(currentDir, "package.json");
39301
+ const packageJsonPath = path18.join(currentDir, "package.json");
39236
39302
  try {
39237
- if (fs8.existsSync(packageJsonPath)) {
39238
- const parsed = JSON.parse(fs8.readFileSync(packageJsonPath, "utf8"));
39303
+ if (fs9.existsSync(packageJsonPath)) {
39304
+ const parsed = JSON.parse(fs9.readFileSync(packageJsonPath, "utf8"));
39239
39305
  if (parsed?.name === packageName) {
39240
39306
  const normalized = currentDir.replace(/\\/g, "/");
39241
39307
  return normalized.includes("/node_modules/") ? currentDir : null;
@@ -39243,7 +39309,7 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
39243
39309
  }
39244
39310
  } catch {
39245
39311
  }
39246
- const parentDir = path17.dirname(currentDir);
39312
+ const parentDir = path18.dirname(currentDir);
39247
39313
  if (parentDir === currentDir) {
39248
39314
  return null;
39249
39315
  }
@@ -39251,13 +39317,13 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
39251
39317
  }
39252
39318
  }
39253
39319
  function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
39254
- const nodeModulesDir = packageName.startsWith("@") ? path17.dirname(path17.dirname(packageRoot)) : path17.dirname(packageRoot);
39255
- 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") {
39256
39322
  return null;
39257
39323
  }
39258
- const maybeLibDir = path17.dirname(nodeModulesDir);
39259
- if (path17.basename(maybeLibDir) === "lib") {
39260
- return path17.dirname(maybeLibDir);
39324
+ const maybeLibDir = path18.dirname(nodeModulesDir);
39325
+ if (path18.basename(maybeLibDir) === "lib") {
39326
+ return path18.dirname(maybeLibDir);
39261
39327
  }
39262
39328
  return maybeLibDir;
39263
39329
  }
@@ -39372,10 +39438,10 @@ async function waitForPidExit(pid, timeoutMs) {
39372
39438
  }
39373
39439
  }
39374
39440
  function stopSessionHostProcesses(appName) {
39375
- const pidFile = path17.join(os20.homedir(), ".adhdev", `${appName}-session-host.pid`);
39441
+ const pidFile = path18.join(os21.homedir(), ".adhdev", `${appName}-session-host.pid`);
39376
39442
  try {
39377
- if (fs8.existsSync(pidFile)) {
39378
- 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);
39379
39445
  if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid(pid)) {
39380
39446
  killPid(pid);
39381
39447
  }
@@ -39383,15 +39449,15 @@ function stopSessionHostProcesses(appName) {
39383
39449
  } catch {
39384
39450
  } finally {
39385
39451
  try {
39386
- fs8.unlinkSync(pidFile);
39452
+ fs9.unlinkSync(pidFile);
39387
39453
  } catch {
39388
39454
  }
39389
39455
  }
39390
39456
  }
39391
39457
  function removeDaemonPidFile() {
39392
- const pidFile = path17.join(os20.homedir(), ".adhdev", "daemon.pid");
39458
+ const pidFile = path18.join(os21.homedir(), ".adhdev", "daemon.pid");
39393
39459
  try {
39394
- fs8.unlinkSync(pidFile);
39460
+ fs9.unlinkSync(pidFile);
39395
39461
  } catch {
39396
39462
  }
39397
39463
  }
@@ -39400,7 +39466,7 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
39400
39466
  const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
39401
39467
  if (!npmRoot) return;
39402
39468
  const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
39403
- const binDir = process.platform === "win32" ? npmPrefix : path17.join(npmPrefix, "bin");
39469
+ const binDir = process.platform === "win32" ? npmPrefix : path18.join(npmPrefix, "bin");
39404
39470
  const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
39405
39471
  const binNames = /* @__PURE__ */ new Set([packageBaseName]);
39406
39472
  if (pkgName === "@adhdev/daemon-standalone") {
@@ -39408,25 +39474,25 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
39408
39474
  }
39409
39475
  if (pkgName.startsWith("@")) {
39410
39476
  const [scope, name] = pkgName.split("/");
39411
- const scopeDir = path17.join(npmRoot, scope);
39412
- if (!fs8.existsSync(scopeDir)) return;
39413
- 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)) {
39414
39480
  if (!entry.startsWith(`.${name}-`)) continue;
39415
- fs8.rmSync(path17.join(scopeDir, entry), { recursive: true, force: true });
39416
- 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)}`);
39417
39483
  }
39418
39484
  } else {
39419
- for (const entry of fs8.readdirSync(npmRoot)) {
39485
+ for (const entry of fs9.readdirSync(npmRoot)) {
39420
39486
  if (!entry.startsWith(`.${pkgName}-`)) continue;
39421
- fs8.rmSync(path17.join(npmRoot, entry), { recursive: true, force: true });
39422
- 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)}`);
39423
39489
  }
39424
39490
  }
39425
- if (fs8.existsSync(binDir)) {
39426
- for (const entry of fs8.readdirSync(binDir)) {
39491
+ if (fs9.existsSync(binDir)) {
39492
+ for (const entry of fs9.readdirSync(binDir)) {
39427
39493
  if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
39428
- fs8.rmSync(path17.join(binDir, entry), { recursive: true, force: true });
39429
- 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)}`);
39430
39496
  }
39431
39497
  }
39432
39498
  }
@@ -39509,15 +39575,15 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
39509
39575
  process.exit(1);
39510
39576
  }
39511
39577
  }
39512
- 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;
39513
39579
  var init_upgrade_helper = __esm({
39514
39580
  "../../oss/packages/daemon-core/src/commands/upgrade-helper.ts"() {
39515
39581
  "use strict";
39516
39582
  import_child_process8 = require("child_process");
39517
39583
  import_child_process9 = require("child_process");
39518
- fs8 = __toESM(require("fs"));
39519
- os20 = __toESM(require("os"));
39520
- path17 = __toESM(require("path"));
39584
+ fs9 = __toESM(require("fs"));
39585
+ os21 = __toESM(require("os"));
39586
+ path18 = __toESM(require("path"));
39521
39587
  UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
39522
39588
  }
39523
39589
  });
@@ -39604,7 +39670,7 @@ function summarizeSessionHostPruneResult(result) {
39604
39670
  keptCount: Array.isArray(value.keptSessionIds) ? value.keptSessionIds.length : void 0
39605
39671
  };
39606
39672
  }
39607
- var fs9, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
39673
+ var fs10, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
39608
39674
  var init_router = __esm({
39609
39675
  "../../oss/packages/daemon-core/src/commands/router.ts"() {
39610
39676
  "use strict";
@@ -39629,7 +39695,7 @@ var init_router = __esm({
39629
39695
  init_snapshot();
39630
39696
  init_snapshot();
39631
39697
  init_upgrade_helper();
39632
- fs9 = __toESM(require("fs"));
39698
+ fs10 = __toESM(require("fs"));
39633
39699
  CHAT_COMMANDS = [
39634
39700
  "send_chat",
39635
39701
  "new_chat",
@@ -39784,8 +39850,8 @@ var init_router = __esm({
39784
39850
  if (sinceTs > 0) {
39785
39851
  return { success: true, logs: [], totalBuffered: 0 };
39786
39852
  }
39787
- if (fs9.existsSync(LOG_PATH)) {
39788
- const content = fs9.readFileSync(LOG_PATH, "utf-8");
39853
+ if (fs10.existsSync(LOG_PATH)) {
39854
+ const content = fs10.readFileSync(LOG_PATH, "utf-8");
39789
39855
  const allLines = content.split("\n");
39790
39856
  const recent = allLines.slice(-count).join("\n");
39791
39857
  return { success: true, logs: recent, totalLines: allLines.length };
@@ -39927,6 +39993,8 @@ var init_router = __esm({
39927
39993
  const wantsAll = args?.all === true;
39928
39994
  const offset = wantsAll ? 0 : Math.max(0, Number(args?.offset) || 0);
39929
39995
  const limit = wantsAll ? Number.MAX_SAFE_INTEGER : Math.max(1, Math.min(100, Number(args?.limit) || 30));
39996
+ const requestedWorkspace = typeof args?.workspace === "string" ? args.workspace.trim() : "";
39997
+ const requestedProviderSessionId = typeof args?.providerSessionId === "string" ? args.providerSessionId.trim() : typeof args?.activeProviderSessionId === "string" ? args.activeProviderSessionId.trim() : "";
39930
39998
  const providerMeta = this.deps.providerLoader.resolve?.(providerType) || this.deps.providerLoader.getMeta(providerType);
39931
39999
  const { sessions: historySessions, hasMore, source } = listProviderHistorySessions(providerType, {
39932
40000
  canonicalHistory: providerMeta?.canonicalHistory,
@@ -39946,6 +40014,7 @@ var init_router = __esm({
39946
40014
  sessions: historySessions.map((session) => {
39947
40015
  const saved = savedSessionById.get(session.historySessionId);
39948
40016
  const recent = recentSessionById.get(session.historySessionId);
40017
+ const workspace = saved?.workspace || recent?.workspace || session.workspace || (requestedWorkspace && requestedProviderSessionId === session.historySessionId ? requestedWorkspace : void 0);
39949
40018
  return {
39950
40019
  id: session.historySessionId,
39951
40020
  providerSessionId: session.historySessionId,
@@ -39953,13 +40022,13 @@ var init_router = __esm({
39953
40022
  providerName: saved?.providerName || recent?.providerName || providerType,
39954
40023
  kind: saved?.kind || recent?.kind || kind,
39955
40024
  title: saved?.title || recent?.title || session.sessionTitle || session.preview || providerType,
39956
- workspace: saved?.workspace || recent?.workspace || session.workspace,
40025
+ workspace,
39957
40026
  summaryMetadata: saved?.summaryMetadata || recent?.summaryMetadata,
39958
40027
  preview: session.preview,
39959
40028
  messageCount: session.messageCount,
39960
40029
  firstMessageAt: session.firstMessageAt,
39961
40030
  lastMessageAt: session.lastMessageAt,
39962
- canResume: !!(saved?.workspace || recent?.workspace || session.workspace) && canResumeById,
40031
+ canResume: !!workspace && canResumeById,
39963
40032
  historySource: session.source,
39964
40033
  sourcePath: session.sourcePath,
39965
40034
  sourceMtimeMs: session.sourceMtimeMs
@@ -42060,19 +42129,19 @@ function getVersion(binary, versionCommand) {
42060
42129
  function checkPathExists2(paths) {
42061
42130
  for (const p of paths) {
42062
42131
  if (p.includes("*")) {
42063
- const home = os21.homedir();
42064
- const resolved = p.replace(/\*/g, home.split(path18.sep).pop() || "");
42065
- 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;
42066
42135
  } else {
42067
- if (fs10.existsSync(p)) return p;
42136
+ if (fs11.existsSync(p)) return p;
42068
42137
  }
42069
42138
  }
42070
42139
  return null;
42071
42140
  }
42072
42141
  function getMacAppVersion(appPath) {
42073
42142
  if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
42074
- const plistPath = path18.join(appPath, "Contents", "Info.plist");
42075
- if (!fs10.existsSync(plistPath)) return null;
42143
+ const plistPath = path19.join(appPath, "Contents", "Info.plist");
42144
+ if (!fs11.existsSync(plistPath)) return null;
42076
42145
  const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
42077
42146
  return raw || null;
42078
42147
  }
@@ -42097,8 +42166,8 @@ async function detectAllVersions(loader, archive) {
42097
42166
  const cliBin = provider.cli ? findBinary2(provider.cli) : null;
42098
42167
  let resolvedBin = cliBin;
42099
42168
  if (!resolvedBin && appPath && currentOs === "darwin") {
42100
- const bundled = path18.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
42101
- 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;
42102
42171
  }
42103
42172
  info.installed = !!(appPath || resolvedBin);
42104
42173
  info.path = appPath || null;
@@ -42134,16 +42203,16 @@ async function detectAllVersions(loader, archive) {
42134
42203
  }
42135
42204
  return results;
42136
42205
  }
42137
- 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;
42138
42207
  var init_version_archive = __esm({
42139
42208
  "../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
42140
42209
  "use strict";
42141
- fs10 = __toESM(require("fs"));
42142
- path18 = __toESM(require("path"));
42143
- os21 = __toESM(require("os"));
42210
+ fs11 = __toESM(require("fs"));
42211
+ path19 = __toESM(require("path"));
42212
+ os23 = __toESM(require("os"));
42144
42213
  import_child_process10 = require("child_process");
42145
42214
  import_os3 = require("os");
42146
- ARCHIVE_PATH = path18.join(os21.homedir(), ".adhdev", "version-history.json");
42215
+ ARCHIVE_PATH = path19.join(os23.homedir(), ".adhdev", "version-history.json");
42147
42216
  MAX_ENTRIES_PER_PROVIDER = 20;
42148
42217
  VersionArchive = class {
42149
42218
  history = {};
@@ -42152,8 +42221,8 @@ var init_version_archive = __esm({
42152
42221
  }
42153
42222
  load() {
42154
42223
  try {
42155
- if (fs10.existsSync(ARCHIVE_PATH)) {
42156
- 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"));
42157
42226
  }
42158
42227
  } catch {
42159
42228
  this.history = {};
@@ -42190,8 +42259,8 @@ var init_version_archive = __esm({
42190
42259
  }
42191
42260
  save() {
42192
42261
  try {
42193
- fs10.mkdirSync(path18.dirname(ARCHIVE_PATH), { recursive: true });
42194
- 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));
42195
42264
  } catch {
42196
42265
  }
42197
42266
  }
@@ -42725,18 +42794,18 @@ async function handleScriptHints(ctx, type, _req, res) {
42725
42794
  return;
42726
42795
  }
42727
42796
  let scriptsPath = "";
42728
- const directScripts = path19.join(dir, "scripts.js");
42729
- if (fs11.existsSync(directScripts)) {
42797
+ const directScripts = path20.join(dir, "scripts.js");
42798
+ if (fs12.existsSync(directScripts)) {
42730
42799
  scriptsPath = directScripts;
42731
42800
  } else {
42732
- const scriptsDir = path19.join(dir, "scripts");
42733
- if (fs11.existsSync(scriptsDir)) {
42734
- const versions = fs11.readdirSync(scriptsDir).filter((d) => {
42735
- 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();
42736
42805
  }).sort().reverse();
42737
42806
  for (const ver of versions) {
42738
- const p = path19.join(scriptsDir, ver, "scripts.js");
42739
- if (fs11.existsSync(p)) {
42807
+ const p = path20.join(scriptsDir, ver, "scripts.js");
42808
+ if (fs12.existsSync(p)) {
42740
42809
  scriptsPath = p;
42741
42810
  break;
42742
42811
  }
@@ -42748,7 +42817,7 @@ async function handleScriptHints(ctx, type, _req, res) {
42748
42817
  return;
42749
42818
  }
42750
42819
  try {
42751
- const source = fs11.readFileSync(scriptsPath, "utf-8");
42820
+ const source = fs12.readFileSync(scriptsPath, "utf-8");
42752
42821
  const hints = {};
42753
42822
  const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
42754
42823
  let match;
@@ -43561,12 +43630,12 @@ async function handleDomContext(ctx, type, req, res) {
43561
43630
  ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
43562
43631
  }
43563
43632
  }
43564
- var fs11, path19;
43633
+ var fs12, path20;
43565
43634
  var init_dev_cdp_handlers = __esm({
43566
43635
  "../../oss/packages/daemon-core/src/daemon/dev-cdp-handlers.ts"() {
43567
43636
  "use strict";
43568
- fs11 = __toESM(require("fs"));
43569
- path19 = __toESM(require("path"));
43637
+ fs12 = __toESM(require("fs"));
43638
+ path20 = __toESM(require("path"));
43570
43639
  init_logger();
43571
43640
  }
43572
43641
  });
@@ -43581,15 +43650,15 @@ function getCliFixtureDir(ctx, type) {
43581
43650
  if (!providerDir) {
43582
43651
  throw new Error(`Provider directory not found for '${type}'`);
43583
43652
  }
43584
- return path20.join(providerDir, "fixtures");
43653
+ return path21.join(providerDir, "fixtures");
43585
43654
  }
43586
43655
  function readCliFixture(ctx, type, name) {
43587
43656
  const fixtureDir = getCliFixtureDir(ctx, type);
43588
- const filePath = path20.join(fixtureDir, `${name}.json`);
43589
- if (!fs12.existsSync(filePath)) {
43657
+ const filePath = path21.join(fixtureDir, `${name}.json`);
43658
+ if (!fs13.existsSync(filePath)) {
43590
43659
  throw new Error(`Fixture not found: ${filePath}`);
43591
43660
  }
43592
- return JSON.parse(fs12.readFileSync(filePath, "utf-8"));
43661
+ return JSON.parse(fs13.readFileSync(filePath, "utf-8"));
43593
43662
  }
43594
43663
  function getExerciseTranscriptText(result) {
43595
43664
  const parts = [];
@@ -44325,7 +44394,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
44325
44394
  return;
44326
44395
  }
44327
44396
  const fixtureDir = getCliFixtureDir(ctx, type);
44328
- fs12.mkdirSync(fixtureDir, { recursive: true });
44397
+ fs13.mkdirSync(fixtureDir, { recursive: true });
44329
44398
  const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
44330
44399
  const result = await runCliExerciseInternal(ctx, { ...request, type });
44331
44400
  const fixture = {
@@ -44352,8 +44421,8 @@ async function handleCliFixtureCapture(ctx, req, res) {
44352
44421
  },
44353
44422
  notes: typeof body?.notes === "string" ? body.notes : void 0
44354
44423
  };
44355
- const filePath = path20.join(fixtureDir, `${name}.json`);
44356
- 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));
44357
44426
  ctx.json(res, 200, {
44358
44427
  saved: true,
44359
44428
  name,
@@ -44371,14 +44440,14 @@ async function handleCliFixtureCapture(ctx, req, res) {
44371
44440
  async function handleCliFixtureList(ctx, type, _req, res) {
44372
44441
  try {
44373
44442
  const fixtureDir = getCliFixtureDir(ctx, type);
44374
- if (!fs12.existsSync(fixtureDir)) {
44443
+ if (!fs13.existsSync(fixtureDir)) {
44375
44444
  ctx.json(res, 200, { fixtures: [], count: 0 });
44376
44445
  return;
44377
44446
  }
44378
- const fixtures = fs12.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
44379
- 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);
44380
44449
  try {
44381
- const raw = JSON.parse(fs12.readFileSync(fullPath, "utf-8"));
44450
+ const raw = JSON.parse(fs13.readFileSync(fullPath, "utf-8"));
44382
44451
  return {
44383
44452
  name: raw.name || file2.replace(/\.json$/i, ""),
44384
44453
  path: fullPath,
@@ -44509,12 +44578,12 @@ async function handleCliRaw(ctx, req, res) {
44509
44578
  ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
44510
44579
  }
44511
44580
  }
44512
- var fs12, path20;
44581
+ var fs13, path21;
44513
44582
  var init_dev_cli_debug = __esm({
44514
44583
  "../../oss/packages/daemon-core/src/daemon/dev-cli-debug.ts"() {
44515
44584
  "use strict";
44516
- fs12 = __toESM(require("fs"));
44517
- path20 = __toESM(require("path"));
44585
+ fs13 = __toESM(require("fs"));
44586
+ path21 = __toESM(require("path"));
44518
44587
  }
44519
44588
  });
44520
44589
 
@@ -44564,38 +44633,38 @@ function resolveAutoImplReference(ctx, category, requestedReference, targetType)
44564
44633
  return fallback2?.type || null;
44565
44634
  }
44566
44635
  function getLatestScriptVersionDir(scriptsDir) {
44567
- if (!fs13.existsSync(scriptsDir)) return null;
44568
- const versions = fs13.readdirSync(scriptsDir).filter((d) => {
44636
+ if (!fs14.existsSync(scriptsDir)) return null;
44637
+ const versions = fs14.readdirSync(scriptsDir).filter((d) => {
44569
44638
  try {
44570
- return fs13.statSync(path21.join(scriptsDir, d)).isDirectory();
44639
+ return fs14.statSync(path23.join(scriptsDir, d)).isDirectory();
44571
44640
  } catch {
44572
44641
  return false;
44573
44642
  }
44574
44643
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
44575
44644
  if (versions.length === 0) return null;
44576
- return path21.join(scriptsDir, versions[0]);
44645
+ return path23.join(scriptsDir, versions[0]);
44577
44646
  }
44578
44647
  function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
44579
- const canonicalUserDir = path21.resolve(ctx.providerLoader.getUserProviderDir(category, type));
44580
- const desiredDir = requestedDir ? path21.resolve(requestedDir) : canonicalUserDir;
44581
- const upstreamRoot = path21.resolve(ctx.providerLoader.getUpstreamDir());
44582
- 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}`)) {
44583
44652
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
44584
44653
  }
44585
- if (path21.basename(desiredDir) !== type) {
44654
+ if (path23.basename(desiredDir) !== type) {
44586
44655
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
44587
44656
  }
44588
44657
  const sourceDir = ctx.findProviderDir(type);
44589
44658
  if (!sourceDir) {
44590
44659
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
44591
44660
  }
44592
- if (!fs13.existsSync(desiredDir)) {
44593
- fs13.mkdirSync(path21.dirname(desiredDir), { recursive: true });
44594
- 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 });
44595
44664
  ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
44596
44665
  }
44597
- const providerJson = path21.join(desiredDir, "provider.json");
44598
- if (!fs13.existsSync(providerJson)) {
44666
+ const providerJson = path23.join(desiredDir, "provider.json");
44667
+ if (!fs14.existsSync(providerJson)) {
44599
44668
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
44600
44669
  }
44601
44670
  return { dir: desiredDir };
@@ -44603,15 +44672,15 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
44603
44672
  function loadAutoImplReferenceScripts(ctx, referenceType) {
44604
44673
  if (!referenceType) return {};
44605
44674
  const refDir = ctx.findProviderDir(referenceType);
44606
- if (!refDir || !fs13.existsSync(refDir)) return {};
44675
+ if (!refDir || !fs14.existsSync(refDir)) return {};
44607
44676
  const referenceScripts = {};
44608
- const scriptsDir = path21.join(refDir, "scripts");
44677
+ const scriptsDir = path23.join(refDir, "scripts");
44609
44678
  const latestDir = getLatestScriptVersionDir(scriptsDir);
44610
44679
  if (!latestDir) return referenceScripts;
44611
- for (const file2 of fs13.readdirSync(latestDir)) {
44680
+ for (const file2 of fs14.readdirSync(latestDir)) {
44612
44681
  if (!file2.endsWith(".js")) continue;
44613
44682
  try {
44614
- referenceScripts[file2] = fs13.readFileSync(path21.join(latestDir, file2), "utf-8");
44683
+ referenceScripts[file2] = fs14.readFileSync(path23.join(latestDir, file2), "utf-8");
44615
44684
  } catch {
44616
44685
  }
44617
44686
  }
@@ -44719,16 +44788,16 @@ async function handleAutoImplement(ctx, type, req, res) {
44719
44788
  });
44720
44789
  const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
44721
44790
  const prompt2 = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
44722
- const tmpDir = path21.join(os23.tmpdir(), "adhdev-autoimpl");
44723
- if (!fs13.existsSync(tmpDir)) fs13.mkdirSync(tmpDir, { recursive: true });
44724
- const promptFile = path21.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
44725
- 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");
44726
44795
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt2.length} chars)`);
44727
44796
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
44728
44797
  const spawn6 = agentProvider?.spawn;
44729
44798
  if (!spawn6?.command) {
44730
44799
  try {
44731
- fs13.unlinkSync(promptFile);
44800
+ fs14.unlinkSync(promptFile);
44732
44801
  } catch {
44733
44802
  }
44734
44803
  ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
@@ -44830,7 +44899,7 @@ async function handleAutoImplement(ctx, type, req, res) {
44830
44899
  } catch {
44831
44900
  }
44832
44901
  try {
44833
- fs13.unlinkSync(promptFile);
44902
+ fs14.unlinkSync(promptFile);
44834
44903
  } catch {
44835
44904
  }
44836
44905
  ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
@@ -44874,7 +44943,7 @@ async function handleAutoImplement(ctx, type, req, res) {
44874
44943
  const interactiveFlags = ["--yolo", "--interactive", "-i"];
44875
44944
  const baseArgs = [...spawn6.args || []].filter((a) => !interactiveFlags.includes(a));
44876
44945
  let shellCmd;
44877
- const isWin = os23.platform() === "win32";
44946
+ const isWin = os24.platform() === "win32";
44878
44947
  const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
44879
44948
  const promptMode = autoImpl?.promptMode ?? "stdin";
44880
44949
  const extraArgs = autoImpl?.extraArgs ?? [];
@@ -44913,7 +44982,7 @@ async function handleAutoImplement(ctx, type, req, res) {
44913
44982
  try {
44914
44983
  const pty = require("node-pty");
44915
44984
  ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
44916
- const isWin2 = os23.platform() === "win32";
44985
+ const isWin2 = os24.platform() === "win32";
44917
44986
  child = pty.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
44918
44987
  name: "xterm-256color",
44919
44988
  cols: 120,
@@ -45056,7 +45125,7 @@ async function handleAutoImplement(ctx, type, req, res) {
45056
45125
  }
45057
45126
  });
45058
45127
  try {
45059
- fs13.unlinkSync(promptFile);
45128
+ fs14.unlinkSync(promptFile);
45060
45129
  } catch {
45061
45130
  }
45062
45131
  ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
@@ -45153,7 +45222,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
45153
45222
  setMode: "set_mode.js"
45154
45223
  };
45155
45224
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
45156
- const scriptsDir = path21.join(providerDir, "scripts");
45225
+ const scriptsDir = path23.join(providerDir, "scripts");
45157
45226
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
45158
45227
  if (latestScriptsDir) {
45159
45228
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -45161,10 +45230,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
45161
45230
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
45162
45231
  lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
45163
45232
  lines.push("");
45164
- for (const file2 of fs13.readdirSync(latestScriptsDir)) {
45233
+ for (const file2 of fs14.readdirSync(latestScriptsDir)) {
45165
45234
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
45166
45235
  try {
45167
- const content = fs13.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
45236
+ const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
45168
45237
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
45169
45238
  lines.push("```javascript");
45170
45239
  lines.push(content);
@@ -45174,14 +45243,14 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
45174
45243
  }
45175
45244
  }
45176
45245
  }
45177
- 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));
45178
45247
  if (refFiles.length > 0) {
45179
45248
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
45180
45249
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
45181
45250
  lines.push("");
45182
45251
  for (const file2 of refFiles) {
45183
45252
  try {
45184
- const content = fs13.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
45253
+ const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
45185
45254
  lines.push(`### \`${file2}\` \u{1F512}`);
45186
45255
  lines.push("```javascript");
45187
45256
  lines.push(content);
@@ -45222,11 +45291,11 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
45222
45291
  lines.push("");
45223
45292
  }
45224
45293
  }
45225
- const docsDir = path21.join(providerDir, "../../docs");
45294
+ const docsDir = path23.join(providerDir, "../../docs");
45226
45295
  const loadGuide = (name) => {
45227
45296
  try {
45228
- const p = path21.join(docsDir, name);
45229
- 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");
45230
45299
  } catch {
45231
45300
  }
45232
45301
  return null;
@@ -45462,7 +45531,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
45462
45531
  parseApproval: "parse_approval.js"
45463
45532
  };
45464
45533
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
45465
- const scriptsDir = path21.join(providerDir, "scripts");
45534
+ const scriptsDir = path23.join(providerDir, "scripts");
45466
45535
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
45467
45536
  if (latestScriptsDir) {
45468
45537
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -45470,11 +45539,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
45470
45539
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
45471
45540
  lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
45472
45541
  lines.push("");
45473
- for (const file2 of fs13.readdirSync(latestScriptsDir)) {
45542
+ for (const file2 of fs14.readdirSync(latestScriptsDir)) {
45474
45543
  if (!file2.endsWith(".js")) continue;
45475
45544
  if (!targetFileNames.has(file2)) continue;
45476
45545
  try {
45477
- const content = fs13.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
45546
+ const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
45478
45547
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
45479
45548
  lines.push("```javascript");
45480
45549
  lines.push(content);
@@ -45483,14 +45552,14 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
45483
45552
  } catch {
45484
45553
  }
45485
45554
  }
45486
- 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));
45487
45556
  if (refFiles.length > 0) {
45488
45557
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
45489
45558
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
45490
45559
  lines.push("");
45491
45560
  for (const file2 of refFiles) {
45492
45561
  try {
45493
- const content = fs13.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
45562
+ const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
45494
45563
  lines.push(`### \`${file2}\` \u{1F512}`);
45495
45564
  lines.push("```javascript");
45496
45565
  lines.push(content);
@@ -45523,11 +45592,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
45523
45592
  lines.push("");
45524
45593
  }
45525
45594
  }
45526
- const docsDir = path21.join(providerDir, "../../docs");
45595
+ const docsDir = path23.join(providerDir, "../../docs");
45527
45596
  const loadGuide = (name) => {
45528
45597
  try {
45529
- const p = path21.join(docsDir, name);
45530
- 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");
45531
45600
  } catch {
45532
45601
  }
45533
45602
  return null;
@@ -45838,13 +45907,13 @@ data: ${JSON.stringify(msg.data)}
45838
45907
  }
45839
45908
  }
45840
45909
  }
45841
- var fs13, path21, os23;
45910
+ var fs14, path23, os24;
45842
45911
  var init_dev_auto_implement = __esm({
45843
45912
  "../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
45844
45913
  "use strict";
45845
- fs13 = __toESM(require("fs"));
45846
- path21 = __toESM(require("path"));
45847
- os23 = __toESM(require("os"));
45914
+ fs14 = __toESM(require("fs"));
45915
+ path23 = __toESM(require("path"));
45916
+ os24 = __toESM(require("os"));
45848
45917
  init_dev_server();
45849
45918
  init_dev_cli_debug();
45850
45919
  }
@@ -45883,13 +45952,13 @@ function toProviderListEntry(provider) {
45883
45952
  }
45884
45953
  return base;
45885
45954
  }
45886
- var http2, fs14, path23, DEV_SERVER_PORT, DevServer;
45955
+ var http2, fs15, path24, DEV_SERVER_PORT, DevServer;
45887
45956
  var init_dev_server = __esm({
45888
45957
  "../../oss/packages/daemon-core/src/daemon/dev-server.ts"() {
45889
45958
  "use strict";
45890
45959
  http2 = __toESM(require("http"));
45891
- fs14 = __toESM(require("fs"));
45892
- path23 = __toESM(require("path"));
45960
+ fs15 = __toESM(require("fs"));
45961
+ path24 = __toESM(require("path"));
45893
45962
  init_provider_schema();
45894
45963
  init_config();
45895
45964
  init_provider_source_config();
@@ -46002,8 +46071,8 @@ var init_dev_server = __esm({
46002
46071
  }
46003
46072
  getEndpointList() {
46004
46073
  return this.routes.map((r) => {
46005
- const path35 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
46006
- 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}`;
46007
46076
  });
46008
46077
  }
46009
46078
  async start(port = DEV_SERVER_PORT) {
@@ -46291,12 +46360,12 @@ var init_dev_server = __esm({
46291
46360
  // ─── DevConsole SPA ───
46292
46361
  getConsoleDistDir() {
46293
46362
  const candidates = [
46294
- path23.resolve(__dirname, "../../web-devconsole/dist"),
46295
- path23.resolve(__dirname, "../../../web-devconsole/dist"),
46296
- 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")
46297
46366
  ];
46298
46367
  for (const dir of candidates) {
46299
- if (fs14.existsSync(path23.join(dir, "index.html"))) return dir;
46368
+ if (fs15.existsSync(path24.join(dir, "index.html"))) return dir;
46300
46369
  }
46301
46370
  return null;
46302
46371
  }
@@ -46306,9 +46375,9 @@ var init_dev_server = __esm({
46306
46375
  this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
46307
46376
  return;
46308
46377
  }
46309
- const htmlPath = path23.join(distDir, "index.html");
46378
+ const htmlPath = path24.join(distDir, "index.html");
46310
46379
  try {
46311
- const html = fs14.readFileSync(htmlPath, "utf-8");
46380
+ const html = fs15.readFileSync(htmlPath, "utf-8");
46312
46381
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
46313
46382
  res.end(html);
46314
46383
  } catch (e) {
@@ -46331,15 +46400,15 @@ var init_dev_server = __esm({
46331
46400
  this.json(res, 404, { error: "Not found" });
46332
46401
  return;
46333
46402
  }
46334
- const safePath = path23.normalize(pathname).replace(/^\.\.\//, "");
46335
- const filePath = path23.join(distDir, safePath);
46403
+ const safePath = path24.normalize(pathname).replace(/^\.\.\//, "");
46404
+ const filePath = path24.join(distDir, safePath);
46336
46405
  if (!filePath.startsWith(distDir)) {
46337
46406
  this.json(res, 403, { error: "Forbidden" });
46338
46407
  return;
46339
46408
  }
46340
46409
  try {
46341
- const content = fs14.readFileSync(filePath);
46342
- const ext = path23.extname(filePath);
46410
+ const content = fs15.readFileSync(filePath);
46411
+ const ext = path24.extname(filePath);
46343
46412
  const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
46344
46413
  res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
46345
46414
  res.end(content);
@@ -46447,14 +46516,14 @@ var init_dev_server = __esm({
46447
46516
  const files = [];
46448
46517
  const scan = (d, prefix) => {
46449
46518
  try {
46450
- for (const entry of fs14.readdirSync(d, { withFileTypes: true })) {
46519
+ for (const entry of fs15.readdirSync(d, { withFileTypes: true })) {
46451
46520
  if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
46452
46521
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
46453
46522
  if (entry.isDirectory()) {
46454
46523
  files.push({ path: rel, size: 0, type: "dir" });
46455
- scan(path23.join(d, entry.name), rel);
46524
+ scan(path24.join(d, entry.name), rel);
46456
46525
  } else {
46457
- const stat4 = fs14.statSync(path23.join(d, entry.name));
46526
+ const stat4 = fs15.statSync(path24.join(d, entry.name));
46458
46527
  files.push({ path: rel, size: stat4.size, type: "file" });
46459
46528
  }
46460
46529
  }
@@ -46477,16 +46546,16 @@ var init_dev_server = __esm({
46477
46546
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
46478
46547
  return;
46479
46548
  }
46480
- const fullPath = path23.resolve(dir, path23.normalize(filePath));
46549
+ const fullPath = path24.resolve(dir, path24.normalize(filePath));
46481
46550
  if (!fullPath.startsWith(dir)) {
46482
46551
  this.json(res, 403, { error: "Forbidden" });
46483
46552
  return;
46484
46553
  }
46485
- if (!fs14.existsSync(fullPath) || fs14.statSync(fullPath).isDirectory()) {
46554
+ if (!fs15.existsSync(fullPath) || fs15.statSync(fullPath).isDirectory()) {
46486
46555
  this.json(res, 404, { error: `File not found: ${filePath}` });
46487
46556
  return;
46488
46557
  }
46489
- const content = fs14.readFileSync(fullPath, "utf-8");
46558
+ const content = fs15.readFileSync(fullPath, "utf-8");
46490
46559
  this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
46491
46560
  }
46492
46561
  /** POST /api/providers/:type/file — write a file { path, content } */
@@ -46502,15 +46571,15 @@ var init_dev_server = __esm({
46502
46571
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
46503
46572
  return;
46504
46573
  }
46505
- const fullPath = path23.resolve(dir, path23.normalize(filePath));
46574
+ const fullPath = path24.resolve(dir, path24.normalize(filePath));
46506
46575
  if (!fullPath.startsWith(dir)) {
46507
46576
  this.json(res, 403, { error: "Forbidden" });
46508
46577
  return;
46509
46578
  }
46510
46579
  try {
46511
- if (fs14.existsSync(fullPath)) fs14.copyFileSync(fullPath, fullPath + ".bak");
46512
- fs14.mkdirSync(path23.dirname(fullPath), { recursive: true });
46513
- 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");
46514
46583
  this.log(`File saved: ${fullPath} (${content.length} chars)`);
46515
46584
  this.providerLoader.reload();
46516
46585
  this.json(res, 200, { saved: true, path: filePath, chars: content.length });
@@ -46526,9 +46595,9 @@ var init_dev_server = __esm({
46526
46595
  return;
46527
46596
  }
46528
46597
  for (const name of ["scripts.js", "provider.json"]) {
46529
- const p = path23.join(dir, name);
46530
- if (fs14.existsSync(p)) {
46531
- 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");
46532
46601
  this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
46533
46602
  return;
46534
46603
  }
@@ -46547,11 +46616,11 @@ var init_dev_server = __esm({
46547
46616
  this.json(res, 404, { error: `Provider not found: ${type}` });
46548
46617
  return;
46549
46618
  }
46550
- const target = fs14.existsSync(path23.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
46551
- 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);
46552
46621
  try {
46553
- if (fs14.existsSync(targetPath)) fs14.copyFileSync(targetPath, targetPath + ".bak");
46554
- fs14.writeFileSync(targetPath, source, "utf-8");
46622
+ if (fs15.existsSync(targetPath)) fs15.copyFileSync(targetPath, targetPath + ".bak");
46623
+ fs15.writeFileSync(targetPath, source, "utf-8");
46555
46624
  this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
46556
46625
  this.providerLoader.reload();
46557
46626
  this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
@@ -46695,21 +46764,21 @@ var init_dev_server = __esm({
46695
46764
  }
46696
46765
  let targetDir;
46697
46766
  targetDir = this.providerLoader.getUserProviderDir(category, type);
46698
- const jsonPath = path23.join(targetDir, "provider.json");
46699
- if (fs14.existsSync(jsonPath)) {
46767
+ const jsonPath = path24.join(targetDir, "provider.json");
46768
+ if (fs15.existsSync(jsonPath)) {
46700
46769
  this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
46701
46770
  return;
46702
46771
  }
46703
46772
  try {
46704
46773
  const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2, osPaths, processNames });
46705
- fs14.mkdirSync(targetDir, { recursive: true });
46706
- fs14.writeFileSync(jsonPath, result["provider.json"], "utf-8");
46774
+ fs15.mkdirSync(targetDir, { recursive: true });
46775
+ fs15.writeFileSync(jsonPath, result["provider.json"], "utf-8");
46707
46776
  const createdFiles = ["provider.json"];
46708
46777
  if (result.files) {
46709
46778
  for (const [relPath, content] of Object.entries(result.files)) {
46710
- const fullPath = path23.join(targetDir, relPath);
46711
- fs14.mkdirSync(path23.dirname(fullPath), { recursive: true });
46712
- 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");
46713
46782
  createdFiles.push(relPath);
46714
46783
  }
46715
46784
  }
@@ -46758,38 +46827,38 @@ var init_dev_server = __esm({
46758
46827
  }
46759
46828
  // ─── Phase 2: Auto-Implement Backend ───
46760
46829
  getLatestScriptVersionDir(scriptsDir) {
46761
- if (!fs14.existsSync(scriptsDir)) return null;
46762
- const versions = fs14.readdirSync(scriptsDir).filter((d) => {
46830
+ if (!fs15.existsSync(scriptsDir)) return null;
46831
+ const versions = fs15.readdirSync(scriptsDir).filter((d) => {
46763
46832
  try {
46764
- return fs14.statSync(path23.join(scriptsDir, d)).isDirectory();
46833
+ return fs15.statSync(path24.join(scriptsDir, d)).isDirectory();
46765
46834
  } catch {
46766
46835
  return false;
46767
46836
  }
46768
46837
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
46769
46838
  if (versions.length === 0) return null;
46770
- return path23.join(scriptsDir, versions[0]);
46839
+ return path24.join(scriptsDir, versions[0]);
46771
46840
  }
46772
46841
  resolveAutoImplWritableProviderDir(category, type, requestedDir) {
46773
- const canonicalUserDir = path23.resolve(this.providerLoader.getUserProviderDir(category, type));
46774
- const desiredDir = requestedDir ? path23.resolve(requestedDir) : canonicalUserDir;
46775
- const upstreamRoot = path23.resolve(this.providerLoader.getUpstreamDir());
46776
- 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}`)) {
46777
46846
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
46778
46847
  }
46779
- if (path23.basename(desiredDir) !== type) {
46848
+ if (path24.basename(desiredDir) !== type) {
46780
46849
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
46781
46850
  }
46782
46851
  const sourceDir = this.findProviderDir(type);
46783
46852
  if (!sourceDir) {
46784
46853
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
46785
46854
  }
46786
- if (!fs14.existsSync(desiredDir)) {
46787
- fs14.mkdirSync(path23.dirname(desiredDir), { recursive: true });
46788
- 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 });
46789
46858
  this.log(`Auto-implement writable copy created: ${desiredDir}`);
46790
46859
  }
46791
- const providerJson = path23.join(desiredDir, "provider.json");
46792
- if (!fs14.existsSync(providerJson)) {
46860
+ const providerJson = path24.join(desiredDir, "provider.json");
46861
+ if (!fs15.existsSync(providerJson)) {
46793
46862
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
46794
46863
  }
46795
46864
  return { dir: desiredDir };
@@ -46824,7 +46893,7 @@ var init_dev_server = __esm({
46824
46893
  setMode: "set_mode.js"
46825
46894
  };
46826
46895
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
46827
- const scriptsDir = path23.join(providerDir, "scripts");
46896
+ const scriptsDir = path24.join(providerDir, "scripts");
46828
46897
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
46829
46898
  if (latestScriptsDir) {
46830
46899
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -46832,10 +46901,10 @@ var init_dev_server = __esm({
46832
46901
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
46833
46902
  lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
46834
46903
  lines.push("");
46835
- for (const file2 of fs14.readdirSync(latestScriptsDir)) {
46904
+ for (const file2 of fs15.readdirSync(latestScriptsDir)) {
46836
46905
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
46837
46906
  try {
46838
- const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
46907
+ const content = fs15.readFileSync(path24.join(latestScriptsDir, file2), "utf-8");
46839
46908
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
46840
46909
  lines.push("```javascript");
46841
46910
  lines.push(content);
@@ -46845,14 +46914,14 @@ var init_dev_server = __esm({
46845
46914
  }
46846
46915
  }
46847
46916
  }
46848
- 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));
46849
46918
  if (refFiles.length > 0) {
46850
46919
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
46851
46920
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
46852
46921
  lines.push("");
46853
46922
  for (const file2 of refFiles) {
46854
46923
  try {
46855
- const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
46924
+ const content = fs15.readFileSync(path24.join(latestScriptsDir, file2), "utf-8");
46856
46925
  lines.push(`### \`${file2}\` \u{1F512}`);
46857
46926
  lines.push("```javascript");
46858
46927
  lines.push(content);
@@ -46893,11 +46962,11 @@ var init_dev_server = __esm({
46893
46962
  lines.push("");
46894
46963
  }
46895
46964
  }
46896
- const docsDir = path23.join(providerDir, "../../docs");
46965
+ const docsDir = path24.join(providerDir, "../../docs");
46897
46966
  const loadGuide = (name) => {
46898
46967
  try {
46899
- const p = path23.join(docsDir, name);
46900
- 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");
46901
46970
  } catch {
46902
46971
  }
46903
46972
  return null;
@@ -47070,7 +47139,7 @@ var init_dev_server = __esm({
47070
47139
  parseApproval: "parse_approval.js"
47071
47140
  };
47072
47141
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
47073
- const scriptsDir = path23.join(providerDir, "scripts");
47142
+ const scriptsDir = path24.join(providerDir, "scripts");
47074
47143
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
47075
47144
  if (latestScriptsDir) {
47076
47145
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -47078,11 +47147,11 @@ var init_dev_server = __esm({
47078
47147
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
47079
47148
  lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
47080
47149
  lines.push("");
47081
- for (const file2 of fs14.readdirSync(latestScriptsDir)) {
47150
+ for (const file2 of fs15.readdirSync(latestScriptsDir)) {
47082
47151
  if (!file2.endsWith(".js")) continue;
47083
47152
  if (!targetFileNames.has(file2)) continue;
47084
47153
  try {
47085
- const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
47154
+ const content = fs15.readFileSync(path24.join(latestScriptsDir, file2), "utf-8");
47086
47155
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
47087
47156
  lines.push("```javascript");
47088
47157
  lines.push(content);
@@ -47091,14 +47160,14 @@ var init_dev_server = __esm({
47091
47160
  } catch {
47092
47161
  }
47093
47162
  }
47094
- 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));
47095
47164
  if (refFiles.length > 0) {
47096
47165
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
47097
47166
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
47098
47167
  lines.push("");
47099
47168
  for (const file2 of refFiles) {
47100
47169
  try {
47101
- const content = fs14.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
47170
+ const content = fs15.readFileSync(path24.join(latestScriptsDir, file2), "utf-8");
47102
47171
  lines.push(`### \`${file2}\` \u{1F512}`);
47103
47172
  lines.push("```javascript");
47104
47173
  lines.push(content);
@@ -47131,11 +47200,11 @@ var init_dev_server = __esm({
47131
47200
  lines.push("");
47132
47201
  }
47133
47202
  }
47134
- const docsDir = path23.join(providerDir, "../../docs");
47203
+ const docsDir = path24.join(providerDir, "../../docs");
47135
47204
  const loadGuide = (name) => {
47136
47205
  try {
47137
- const p = path23.join(docsDir, name);
47138
- 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");
47139
47208
  } catch {
47140
47209
  }
47141
47210
  return null;
@@ -47945,8 +48014,8 @@ async function installExtension(ide, extension) {
47945
48014
  const res = await fetch(extension.vsixUrl);
47946
48015
  if (res.ok) {
47947
48016
  const buffer = Buffer.from(await res.arrayBuffer());
47948
- const fs22 = await import("fs");
47949
- fs22.writeFileSync(vsixPath, buffer);
48017
+ const fs23 = await import("fs");
48018
+ fs23.writeFileSync(vsixPath, buffer);
47950
48019
  return new Promise((resolve18) => {
47951
48020
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
47952
48021
  (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
@@ -60110,15 +60179,15 @@ var require_route = __commonJS({
60110
60179
  };
60111
60180
  }
60112
60181
  function wrapConversion(toModel, graph) {
60113
- const path35 = [graph[toModel].parent, toModel];
60182
+ const path36 = [graph[toModel].parent, toModel];
60114
60183
  let fn = conversions[graph[toModel].parent][toModel];
60115
60184
  let cur = graph[toModel].parent;
60116
60185
  while (graph[cur].parent) {
60117
- path35.unshift(graph[cur].parent);
60186
+ path36.unshift(graph[cur].parent);
60118
60187
  fn = link(conversions[graph[cur].parent][cur], fn);
60119
60188
  cur = graph[cur].parent;
60120
60189
  }
60121
- fn.conversion = path35;
60190
+ fn.conversion = path36;
60122
60191
  return fn;
60123
60192
  }
60124
60193
  module2.exports = function(fromModel) {
@@ -60515,7 +60584,7 @@ var require_has_flag = __commonJS({
60515
60584
  var require_supports_color = __commonJS({
60516
60585
  "../../node_modules/supports-color/index.js"(exports2, module2) {
60517
60586
  "use strict";
60518
- var os30 = require("os");
60587
+ var os31 = require("os");
60519
60588
  var tty3 = require("tty");
60520
60589
  var hasFlag3 = require_has_flag();
60521
60590
  var { env: env3 } = process;
@@ -60563,7 +60632,7 @@ var require_supports_color = __commonJS({
60563
60632
  return min;
60564
60633
  }
60565
60634
  if (process.platform === "win32") {
60566
- const osRelease = os30.release().split(".");
60635
+ const osRelease = os31.release().split(".");
60567
60636
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
60568
60637
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
60569
60638
  }
@@ -63416,7 +63485,7 @@ var require_buffer_list = __commonJS({
63416
63485
  }
63417
63486
  }, {
63418
63487
  key: "join",
63419
- value: function join33(s) {
63488
+ value: function join34(s) {
63420
63489
  if (this.length === 0) return "";
63421
63490
  var p = this.head;
63422
63491
  var ret = "" + p.data;
@@ -73539,10 +73608,10 @@ var require_lib = __commonJS({
73539
73608
  exports2.analyse = analyse;
73540
73609
  var detectFile = (filepath, opts = {}) => new Promise((resolve18, reject) => {
73541
73610
  let fd;
73542
- const fs22 = (0, node_1.default)();
73611
+ const fs23 = (0, node_1.default)();
73543
73612
  const handler = (err, buffer) => {
73544
73613
  if (fd) {
73545
- fs22.closeSync(fd);
73614
+ fs23.closeSync(fd);
73546
73615
  }
73547
73616
  if (err) {
73548
73617
  reject(err);
@@ -73554,9 +73623,9 @@ var require_lib = __commonJS({
73554
73623
  };
73555
73624
  const sampleSize = (opts === null || opts === void 0 ? void 0 : opts.sampleSize) || 0;
73556
73625
  if (sampleSize > 0) {
73557
- fd = fs22.openSync(filepath, "r");
73626
+ fd = fs23.openSync(filepath, "r");
73558
73627
  let sample = Buffer.allocUnsafe(sampleSize);
73559
- fs22.read(fd, sample, 0, sampleSize, opts.offset, (err, bytesRead) => {
73628
+ fs23.read(fd, sample, 0, sampleSize, opts.offset, (err, bytesRead) => {
73560
73629
  if (err) {
73561
73630
  handler(err, null);
73562
73631
  } else {
@@ -73568,22 +73637,22 @@ var require_lib = __commonJS({
73568
73637
  });
73569
73638
  return;
73570
73639
  }
73571
- fs22.readFile(filepath, handler);
73640
+ fs23.readFile(filepath, handler);
73572
73641
  });
73573
73642
  exports2.detectFile = detectFile;
73574
73643
  var detectFileSync = (filepath, opts = {}) => {
73575
- const fs22 = (0, node_1.default)();
73644
+ const fs23 = (0, node_1.default)();
73576
73645
  if (opts && opts.sampleSize) {
73577
- const fd = fs22.openSync(filepath, "r");
73646
+ const fd = fs23.openSync(filepath, "r");
73578
73647
  let sample = Buffer.allocUnsafe(opts.sampleSize);
73579
- const bytesRead = fs22.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
73648
+ const bytesRead = fs23.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
73580
73649
  if (bytesRead < opts.sampleSize) {
73581
73650
  sample = sample.subarray(0, bytesRead);
73582
73651
  }
73583
- fs22.closeSync(fd);
73652
+ fs23.closeSync(fd);
73584
73653
  return (0, exports2.detect)(sample);
73585
73654
  }
73586
- return (0, exports2.detect)(fs22.readFileSync(filepath));
73655
+ return (0, exports2.detect)(fs23.readFileSync(filepath));
73587
73656
  };
73588
73657
  exports2.detectFileSync = detectFileSync;
73589
73658
  exports2.default = {
@@ -77475,7 +77544,7 @@ function splitStringBySpace(str) {
77475
77544
  }
77476
77545
  return pieces;
77477
77546
  }
77478
- 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;
77479
77548
  var init_esm2 = __esm({
77480
77549
  "../../node_modules/@inquirer/external-editor/dist/esm/index.js"() {
77481
77550
  "use strict";
@@ -77484,7 +77553,7 @@ var init_esm2 = __esm({
77484
77553
  import_fs6 = require("fs");
77485
77554
  import_node_path2 = __toESM(require("path"), 1);
77486
77555
  import_node_os4 = __toESM(require("os"), 1);
77487
- import_node_crypto = require("crypto");
77556
+ import_node_crypto2 = require("crypto");
77488
77557
  import_iconv_lite = __toESM(require_lib2(), 1);
77489
77558
  init_CreateFileError();
77490
77559
  init_LaunchEditorError();
@@ -77543,7 +77612,7 @@ var init_esm2 = __esm({
77543
77612
  createTemporaryFile() {
77544
77613
  try {
77545
77614
  const baseDir = this.fileOptions.dir ?? import_node_os4.default.tmpdir();
77546
- const id = (0, import_node_crypto.randomUUID)();
77615
+ const id = (0, import_node_crypto2.randomUUID)();
77547
77616
  const prefix = sanitizeAffix(this.fileOptions.prefix);
77548
77617
  const postfix = sanitizeAffix(this.fileOptions.postfix);
77549
77618
  const filename = `${prefix}${id}${postfix}`;
@@ -77988,9 +78057,9 @@ var init_prompt = __esm({
77988
78057
  init_utils();
77989
78058
  init_baseUI();
77990
78059
  _ = {
77991
- set: (obj, path35 = "", value) => {
78060
+ set: (obj, path36 = "", value) => {
77992
78061
  let pointer = obj;
77993
- path35.split(".").forEach((key, index, arr) => {
78062
+ path36.split(".").forEach((key, index, arr) => {
77994
78063
  if (key === "__proto__" || key === "constructor") return;
77995
78064
  if (index === arr.length - 1) {
77996
78065
  pointer[key] = value;
@@ -78000,8 +78069,8 @@ var init_prompt = __esm({
78000
78069
  pointer = pointer[key];
78001
78070
  });
78002
78071
  },
78003
- get: (obj, path35 = "", defaultValue) => {
78004
- 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(
78005
78074
  // @ts-expect-error implicit any on res[key]
78006
78075
  (res, key) => res !== null && res !== void 0 ? res[key] : res,
78007
78076
  obj
@@ -80046,12 +80115,14 @@ var init_data_channel_router = __esm({
80046
80115
  });
80047
80116
 
80048
80117
  // src/daemon-p2p/screenshot-sender.ts
80049
- var CHUNK_SIZE, ScreenshotSender;
80118
+ var CHUNK_SIZE, MAX_INLINE_JSON_MESSAGE_BYTES, JSON_CHUNK_PAYLOAD_CHARS2, ScreenshotSender;
80050
80119
  var init_screenshot_sender = __esm({
80051
80120
  "src/daemon-p2p/screenshot-sender.ts"() {
80052
80121
  "use strict";
80053
80122
  init_log();
80054
80123
  CHUNK_SIZE = 6e4;
80124
+ MAX_INLINE_JSON_MESSAGE_BYTES = 6e4;
80125
+ JSON_CHUNK_PAYLOAD_CHARS2 = 16e3;
80055
80126
  ScreenshotSender = class {
80056
80127
  _ssDebugDone = false;
80057
80128
  sendStatus(peers, status) {
@@ -80090,16 +80161,43 @@ var init_screenshot_sender = __esm({
80090
80161
  }
80091
80162
  sendTopicUpdateToPeer(peer, update) {
80092
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
+ }
80093
80171
  try {
80094
- peer.dataChannel.sendMessage(JSON.stringify({
80095
- type: "topic_update",
80096
- update
80097
- }));
80172
+ peer.dataChannel.sendMessage(json2);
80098
80173
  return true;
80099
80174
  } catch {
80100
80175
  return false;
80101
80176
  }
80102
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
+ }
80103
80201
  /** Broadcast runtime session output to all connected peers */
80104
80202
  broadcastSessionOutput(peers, sessionId, data) {
80105
80203
  const msg = JSON.stringify({ type: "session_output", sessionId, data });
@@ -80530,12 +80628,12 @@ var init_peer_connection_manager = __esm({
80530
80628
  });
80531
80629
 
80532
80630
  // src/daemon-p2p/index.ts
80533
- var fs15, path25, import_node_module2, esmRequire, DaemonP2PSender;
80631
+ var fs16, path26, import_node_module2, esmRequire, DaemonP2PSender;
80534
80632
  var init_daemon_p2p = __esm({
80535
80633
  "src/daemon-p2p/index.ts"() {
80536
80634
  "use strict";
80537
- fs15 = __toESM(require("fs"));
80538
- path25 = __toESM(require("path"));
80635
+ fs16 = __toESM(require("fs"));
80636
+ path26 = __toESM(require("path"));
80539
80637
  import_node_module2 = require("module");
80540
80638
  init_src();
80541
80639
  init_data_channel_router();
@@ -80614,17 +80712,17 @@ ${e?.stack || ""}`);
80614
80712
  const prebuildKey = `${platform12}-${arch3}`;
80615
80713
  try {
80616
80714
  const candidates = [
80617
- path25.join(__dirname, "node_modules", "node-datachannel"),
80618
- path25.join(__dirname, "..", "node_modules", "node-datachannel"),
80619
- 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")
80620
80718
  ];
80621
80719
  for (const candidate of candidates) {
80622
- const prebuildPath = path25.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
80623
- if (fs15.existsSync(prebuildPath)) {
80624
- const targetDir = path25.join(candidate, "build", "Release");
80625
- const targetPath = path25.join(targetDir, "node_datachannel.node");
80626
- fs15.mkdirSync(targetDir, { recursive: true });
80627
- 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);
80628
80726
  try {
80629
80727
  delete esmRequire.cache[esmRequire.resolve("node-datachannel")];
80630
80728
  } catch {
@@ -80991,27 +81089,27 @@ var require_process = __commonJS({
80991
81089
  var require_filesystem = __commonJS({
80992
81090
  "../../node_modules/detect-libc/lib/filesystem.js"(exports2, module2) {
80993
81091
  "use strict";
80994
- var fs22 = require("fs");
81092
+ var fs23 = require("fs");
80995
81093
  var LDD_PATH = "/usr/bin/ldd";
80996
81094
  var SELF_PATH = "/proc/self/exe";
80997
81095
  var MAX_LENGTH = 2048;
80998
- var readFileSync20 = (path35) => {
80999
- const fd = fs22.openSync(path35, "r");
81096
+ var readFileSync20 = (path36) => {
81097
+ const fd = fs23.openSync(path36, "r");
81000
81098
  const buffer = Buffer.alloc(MAX_LENGTH);
81001
- const bytesRead = fs22.readSync(fd, buffer, 0, MAX_LENGTH, 0);
81002
- fs22.close(fd, () => {
81099
+ const bytesRead = fs23.readSync(fd, buffer, 0, MAX_LENGTH, 0);
81100
+ fs23.close(fd, () => {
81003
81101
  });
81004
81102
  return buffer.subarray(0, bytesRead);
81005
81103
  };
81006
- var readFile = (path35) => new Promise((resolve18, reject) => {
81007
- fs22.open(path35, "r", (err, fd) => {
81104
+ var readFile = (path36) => new Promise((resolve18, reject) => {
81105
+ fs23.open(path36, "r", (err, fd) => {
81008
81106
  if (err) {
81009
81107
  reject(err);
81010
81108
  } else {
81011
81109
  const buffer = Buffer.alloc(MAX_LENGTH);
81012
- fs22.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
81110
+ fs23.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
81013
81111
  resolve18(buffer.subarray(0, bytesRead));
81014
- fs22.close(fd, () => {
81112
+ fs23.close(fd, () => {
81015
81113
  });
81016
81114
  });
81017
81115
  }
@@ -81123,11 +81221,11 @@ var require_detect_libc = __commonJS({
81123
81221
  }
81124
81222
  return null;
81125
81223
  };
81126
- var familyFromInterpreterPath = (path35) => {
81127
- if (path35) {
81128
- if (path35.includes("/ld-musl-")) {
81224
+ var familyFromInterpreterPath = (path36) => {
81225
+ if (path36) {
81226
+ if (path36.includes("/ld-musl-")) {
81129
81227
  return MUSL;
81130
- } else if (path35.includes("/ld-linux-")) {
81228
+ } else if (path36.includes("/ld-linux-")) {
81131
81229
  return GLIBC;
81132
81230
  }
81133
81231
  }
@@ -81174,8 +81272,8 @@ var require_detect_libc = __commonJS({
81174
81272
  cachedFamilyInterpreter = null;
81175
81273
  try {
81176
81274
  const selfContent = await readFile(SELF_PATH);
81177
- const path35 = interpreterPath(selfContent);
81178
- cachedFamilyInterpreter = familyFromInterpreterPath(path35);
81275
+ const path36 = interpreterPath(selfContent);
81276
+ cachedFamilyInterpreter = familyFromInterpreterPath(path36);
81179
81277
  } catch (e) {
81180
81278
  }
81181
81279
  return cachedFamilyInterpreter;
@@ -81187,8 +81285,8 @@ var require_detect_libc = __commonJS({
81187
81285
  cachedFamilyInterpreter = null;
81188
81286
  try {
81189
81287
  const selfContent = readFileSync20(SELF_PATH);
81190
- const path35 = interpreterPath(selfContent);
81191
- cachedFamilyInterpreter = familyFromInterpreterPath(path35);
81288
+ const path36 = interpreterPath(selfContent);
81289
+ cachedFamilyInterpreter = familyFromInterpreterPath(path36);
81192
81290
  } catch (e) {
81193
81291
  }
81194
81292
  return cachedFamilyInterpreter;
@@ -82907,18 +83005,18 @@ var require_sharp = __commonJS({
82907
83005
  `@img/sharp-${runtimePlatform}/sharp.node`,
82908
83006
  "@img/sharp-wasm32/sharp.node"
82909
83007
  ];
82910
- var path35;
83008
+ var path36;
82911
83009
  var sharp;
82912
83010
  var errors = [];
82913
- for (path35 of paths) {
83011
+ for (path36 of paths) {
82914
83012
  try {
82915
- sharp = require(path35);
83013
+ sharp = require(path36);
82916
83014
  break;
82917
83015
  } catch (err) {
82918
83016
  errors.push(err);
82919
83017
  }
82920
83018
  }
82921
- if (sharp && path35.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
83019
+ if (sharp && path36.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
82922
83020
  const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
82923
83021
  err.code = "Unsupported CPU";
82924
83022
  errors.push(err);
@@ -82927,7 +83025,7 @@ var require_sharp = __commonJS({
82927
83025
  if (sharp) {
82928
83026
  module2.exports = sharp;
82929
83027
  } else {
82930
- 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));
82931
83029
  const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
82932
83030
  errors.forEach((err) => {
82933
83031
  if (err.code !== "MODULE_NOT_FOUND") {
@@ -82944,15 +83042,15 @@ var require_sharp = __commonJS({
82944
83042
  ` Requires ${expected}`
82945
83043
  );
82946
83044
  } else if (prebuiltPlatforms.includes(runtimePlatform)) {
82947
- const [os30, cpu] = runtimePlatform.split("-");
82948
- const libc = os30.endsWith("musl") ? " --libc=musl" : "";
83045
+ const [os31, cpu] = runtimePlatform.split("-");
83046
+ const libc = os31.endsWith("musl") ? " --libc=musl" : "";
82949
83047
  help.push(
82950
83048
  "- Ensure optional dependencies can be installed:",
82951
83049
  " npm install --include=optional sharp",
82952
83050
  "- Ensure your package manager supports multi-platform installation:",
82953
83051
  " See https://sharp.pixelplumbing.com/install#cross-platform",
82954
83052
  "- Add platform-specific dependencies:",
82955
- ` npm install --os=${os30.replace("musl", "")}${libc} --cpu=${cpu} sharp`
83053
+ ` npm install --os=${os31.replace("musl", "")}${libc} --cpu=${cpu} sharp`
82956
83054
  );
82957
83055
  } else {
82958
83056
  help.push(
@@ -85827,15 +85925,15 @@ var require_color = __commonJS({
85827
85925
  };
85828
85926
  }
85829
85927
  function wrapConversion(toModel, graph) {
85830
- const path35 = [graph[toModel].parent, toModel];
85928
+ const path36 = [graph[toModel].parent, toModel];
85831
85929
  let fn = conversions_default[graph[toModel].parent][toModel];
85832
85930
  let cur = graph[toModel].parent;
85833
85931
  while (graph[cur].parent) {
85834
- path35.unshift(graph[cur].parent);
85932
+ path36.unshift(graph[cur].parent);
85835
85933
  fn = link(conversions_default[graph[cur].parent][cur], fn);
85836
85934
  cur = graph[cur].parent;
85837
85935
  }
85838
- fn.conversion = path35;
85936
+ fn.conversion = path36;
85839
85937
  return fn;
85840
85938
  }
85841
85939
  function route(fromModel) {
@@ -86452,7 +86550,7 @@ var require_channel = __commonJS({
86452
86550
  var require_output = __commonJS({
86453
86551
  "../../node_modules/sharp/lib/output.js"(exports2, module2) {
86454
86552
  "use strict";
86455
- var path35 = require("path");
86553
+ var path36 = require("path");
86456
86554
  var is = require_is();
86457
86555
  var sharp = require_sharp();
86458
86556
  var formats = /* @__PURE__ */ new Map([
@@ -86483,9 +86581,9 @@ var require_output = __commonJS({
86483
86581
  let err;
86484
86582
  if (!is.string(fileOut)) {
86485
86583
  err = new Error("Missing output file path");
86486
- } 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)) {
86487
86585
  err = new Error("Cannot use same file for input and output");
86488
- } 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) {
86489
86587
  err = errJp2Save();
86490
86588
  }
86491
86589
  if (err) {
@@ -87759,21 +87857,21 @@ function quarantineLegacyStandaloneSessions(options) {
87759
87857
  if (shouldSkipForExplicitOverride(env3)) {
87760
87858
  return { movedCount: 0, skippedActiveCount: 0, backupDir: null };
87761
87859
  }
87762
- const homeDir = options.homeDir || os25.homedir();
87860
+ const homeDir = options.homeDir || os26.homedir();
87763
87861
  const now = options.now || (() => /* @__PURE__ */ new Date());
87764
87862
  const isPidRunning = options.isPidRunning || defaultPidRunning;
87765
- const runtimesDir = path26.join(homeDir, ".adhdev", "session-host", options.appName, "runtimes");
87766
- if (!fs16.existsSync(runtimesDir)) {
87863
+ const runtimesDir = path27.join(homeDir, ".adhdev", "session-host", options.appName, "runtimes");
87864
+ if (!fs17.existsSync(runtimesDir)) {
87767
87865
  return { movedCount: 0, skippedActiveCount: 0, backupDir: null };
87768
87866
  }
87769
- 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));
87770
87868
  let movedCount = 0;
87771
87869
  let skippedActiveCount = 0;
87772
87870
  let backupDir = null;
87773
87871
  for (const sourcePath of candidates) {
87774
87872
  let parsed;
87775
87873
  try {
87776
- parsed = JSON.parse(fs16.readFileSync(sourcePath, "utf8"));
87874
+ parsed = JSON.parse(fs17.readFileSync(sourcePath, "utf8"));
87777
87875
  } catch {
87778
87876
  continue;
87779
87877
  }
@@ -87784,26 +87882,26 @@ function quarantineLegacyStandaloneSessions(options) {
87784
87882
  continue;
87785
87883
  }
87786
87884
  if (!backupDir) {
87787
- backupDir = path26.join(
87885
+ backupDir = path27.join(
87788
87886
  homeDir,
87789
87887
  ".adhdev",
87790
87888
  "session-host-backups",
87791
87889
  `legacy-standalone-${options.appName}-${formatTimestamp(now())}`
87792
87890
  );
87793
- fs16.mkdirSync(path26.join(backupDir, "runtimes"), { recursive: true });
87891
+ fs17.mkdirSync(path27.join(backupDir, "runtimes"), { recursive: true });
87794
87892
  }
87795
- fs16.renameSync(sourcePath, path26.join(backupDir, "runtimes", path26.basename(sourcePath)));
87893
+ fs17.renameSync(sourcePath, path27.join(backupDir, "runtimes", path27.basename(sourcePath)));
87796
87894
  movedCount += 1;
87797
87895
  }
87798
87896
  return { movedCount, skippedActiveCount, backupDir };
87799
87897
  }
87800
- var fs16, os25, path26, LEGACY_STANDALONE_MANAGER_TAG;
87898
+ var fs17, os26, path27, LEGACY_STANDALONE_MANAGER_TAG;
87801
87899
  var init_session_host_hygiene = __esm({
87802
87900
  "src/session-host-hygiene.ts"() {
87803
87901
  "use strict";
87804
- fs16 = __toESM(require("fs"));
87805
- os25 = __toESM(require("os"));
87806
- path26 = __toESM(require("path"));
87902
+ fs17 = __toESM(require("fs"));
87903
+ os26 = __toESM(require("os"));
87904
+ path27 = __toESM(require("path"));
87807
87905
  init_src();
87808
87906
  LEGACY_STANDALONE_MANAGER_TAG = "adhdev-standalone";
87809
87907
  }
@@ -87827,18 +87925,18 @@ function buildSessionHostEnv(baseEnv) {
87827
87925
  }
87828
87926
  function resolveSessionHostEntry() {
87829
87927
  const packagedCandidates = [
87830
- path27.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
87831
- 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")
87832
87930
  ];
87833
87931
  for (const candidate of packagedCandidates) {
87834
- if (fs17.existsSync(candidate)) {
87932
+ if (fs18.existsSync(candidate)) {
87835
87933
  return candidate;
87836
87934
  }
87837
87935
  }
87838
87936
  return require.resolve("@adhdev/session-host-daemon");
87839
87937
  }
87840
87938
  function getSessionHostPidFile() {
87841
- 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`);
87842
87940
  }
87843
87941
  function getSessionHostStatusPaths() {
87844
87942
  return {
@@ -87849,8 +87947,8 @@ function getSessionHostStatusPaths() {
87849
87947
  function getSessionHostPid() {
87850
87948
  try {
87851
87949
  const pidFile = getSessionHostPidFile();
87852
- if (!fs17.existsSync(pidFile)) return null;
87853
- 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);
87854
87952
  return Number.isFinite(pid) ? pid : null;
87855
87953
  } catch {
87856
87954
  return null;
@@ -87920,8 +88018,8 @@ function stopManagedSessionHostProcess() {
87920
88018
  let stopped = false;
87921
88019
  const pidFile = getSessionHostPidFile();
87922
88020
  try {
87923
- if (fs17.existsSync(pidFile)) {
87924
- 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);
87925
88023
  if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid2(pid)) {
87926
88024
  stopped = killPid2(pid) || stopped;
87927
88025
  }
@@ -87929,7 +88027,7 @@ function stopManagedSessionHostProcess() {
87929
88027
  } catch {
87930
88028
  } finally {
87931
88029
  try {
87932
- fs17.unlinkSync(pidFile);
88030
+ fs18.unlinkSync(pidFile);
87933
88031
  } catch {
87934
88032
  }
87935
88033
  }
@@ -87957,9 +88055,9 @@ async function ensureSessionHostReady2() {
87957
88055
  }
87958
88056
  const spawnHost = () => {
87959
88057
  const entry = resolveSessionHostEntry();
87960
- const logDir = path27.join(os26.homedir(), ".adhdev", "logs");
87961
- fs17.mkdirSync(logDir, { recursive: true });
87962
- 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");
87963
88061
  const child = (0, import_child_process13.spawn)(process.execPath, [entry], {
87964
88062
  detached: true,
87965
88063
  stdio: ["ignore", logFd, logFd],
@@ -87968,7 +88066,7 @@ async function ensureSessionHostReady2() {
87968
88066
  });
87969
88067
  child.unref();
87970
88068
  try {
87971
- fs17.closeSync(logFd);
88069
+ fs18.closeSync(logFd);
87972
88070
  } catch {
87973
88071
  }
87974
88072
  };
@@ -88021,14 +88119,14 @@ async function probeSessionHostStatus() {
88021
88119
  };
88022
88120
  }
88023
88121
  }
88024
- 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;
88025
88123
  var init_session_host = __esm({
88026
88124
  "src/session-host.ts"() {
88027
88125
  "use strict";
88028
88126
  import_child_process13 = require("child_process");
88029
- fs17 = __toESM(require("fs"));
88030
- os26 = __toESM(require("os"));
88031
- path27 = __toESM(require("path"));
88127
+ fs18 = __toESM(require("fs"));
88128
+ os27 = __toESM(require("os"));
88129
+ path28 = __toESM(require("path"));
88032
88130
  init_src();
88033
88131
  init_dist();
88034
88132
  init_session_host_hygiene();
@@ -88259,22 +88357,22 @@ function resolveDaemonPort(ref = {}) {
88259
88357
  return Number.isFinite(ref.port) && Number(ref.port) > 0 ? Number(ref.port) : DEFAULT_DAEMON_PORT;
88260
88358
  }
88261
88359
  function getDaemonPidFile(ref = {}) {
88262
- const dir = path28.join(ref.homeDir || os27.homedir(), ".adhdev");
88263
- 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 });
88264
88362
  const port = resolveDaemonPort(ref);
88265
- 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`);
88266
88364
  }
88267
88365
  function writeDaemonPid(pid, ref = {}) {
88268
88366
  const pidFile = getDaemonPidFile(ref);
88269
88367
  try {
88270
- fs18.writeFileSync(pidFile, String(pid), { encoding: "utf-8", flag: "wx" });
88368
+ fs19.writeFileSync(pidFile, String(pid), { encoding: "utf-8", flag: "wx" });
88271
88369
  } catch {
88272
- fs18.writeFileSync(pidFile, String(pid), "utf-8");
88370
+ fs19.writeFileSync(pidFile, String(pid), "utf-8");
88273
88371
  }
88274
88372
  }
88275
88373
  function removeDaemonPid(ref = {}) {
88276
88374
  try {
88277
- fs18.unlinkSync(getDaemonPidFile(ref));
88375
+ fs19.unlinkSync(getDaemonPidFile(ref));
88278
88376
  } catch (e) {
88279
88377
  }
88280
88378
  }
@@ -88301,8 +88399,8 @@ function isDaemonRunning(ref = {}) {
88301
88399
  }
88302
88400
  const pidFile = getDaemonPidFile(ref);
88303
88401
  try {
88304
- if (!fs18.existsSync(pidFile)) return false;
88305
- 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());
88306
88404
  process.kill(pid, 0);
88307
88405
  if (!isAdhdevProcess(pid)) {
88308
88406
  removeDaemonPid(ref);
@@ -88379,8 +88477,8 @@ function getDaemonHealthPid(ref = {}) {
88379
88477
  function getDaemonPid(ref = {}) {
88380
88478
  const pidFile = getDaemonPidFile(ref);
88381
88479
  try {
88382
- if (fs18.existsSync(pidFile)) {
88383
- 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);
88384
88482
  if (Number.isFinite(pid)) return pid;
88385
88483
  }
88386
88484
  } catch {
@@ -88391,8 +88489,8 @@ function stopDaemon(ref = {}) {
88391
88489
  const pidFile = getDaemonPidFile(ref);
88392
88490
  let pid = null;
88393
88491
  try {
88394
- if (fs18.existsSync(pidFile)) {
88395
- 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);
88396
88494
  if (Number.isFinite(pidFromFile)) pid = pidFromFile;
88397
88495
  }
88398
88496
  } catch {
@@ -88411,7 +88509,7 @@ function stopDaemon(ref = {}) {
88411
88509
  return false;
88412
88510
  }
88413
88511
  }
88414
- 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;
88415
88513
  var init_adhdev_daemon = __esm({
88416
88514
  "src/adhdev-daemon.ts"() {
88417
88515
  "use strict";
@@ -88423,9 +88521,9 @@ var init_adhdev_daemon = __esm({
88423
88521
  init_startup_restore_policy();
88424
88522
  init_dist();
88425
88523
  init_session_host_controller();
88426
- os27 = __toESM(require("os"));
88427
- fs18 = __toESM(require("fs"));
88428
- path28 = __toESM(require("path"));
88524
+ os28 = __toESM(require("os"));
88525
+ fs19 = __toESM(require("fs"));
88526
+ path29 = __toESM(require("path"));
88429
88527
  import_http = require("http");
88430
88528
  import_child_process14 = require("child_process");
88431
88529
  import_ws3 = require("ws");
@@ -88433,7 +88531,7 @@ var init_adhdev_daemon = __esm({
88433
88531
  init_version();
88434
88532
  init_src();
88435
88533
  init_runtime_defaults();
88436
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.49" });
88534
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.51" });
88437
88535
  AdhdevDaemon = class _AdhdevDaemon {
88438
88536
  localHttpServer = null;
88439
88537
  localWss = null;
@@ -88957,8 +89055,8 @@ ${err?.stack || ""}`);
88957
89055
  cliInfo: {
88958
89056
  type: "adhdev-daemon",
88959
89057
  version: pkgVersion,
88960
- platform: os27.platform(),
88961
- hostname: os27.hostname(),
89058
+ platform: os28.platform(),
89059
+ hostname: os28.hostname(),
88962
89060
  machineId: config2.machineId,
88963
89061
  instanceId
88964
89062
  }
@@ -89716,15 +89814,15 @@ async function loginFlow() {
89716
89814
  let verificationUrl;
89717
89815
  try {
89718
89816
  const config2 = loadConfig();
89719
- const os30 = await import("os");
89817
+ const os31 = await import("os");
89720
89818
  const res = await fetch(`${SERVER_URL}/auth/cli/init`, {
89721
89819
  method: "POST",
89722
89820
  headers: { "Content-Type": "application/json" },
89723
89821
  body: JSON.stringify({
89724
89822
  clientMachineId: config2.machineId,
89725
- hostname: os30.hostname(),
89726
- platform: os30.platform(),
89727
- arch: os30.arch()
89823
+ hostname: os31.hostname(),
89824
+ platform: os31.platform(),
89825
+ arch: os31.arch()
89728
89826
  })
89729
89827
  });
89730
89828
  if (!res.ok) {
@@ -89829,8 +89927,8 @@ async function startDaemonFlow() {
89829
89927
  const { execSync: execSync8 } = await import("child_process");
89830
89928
  const { getCurrentDaemonLogPath: getCurrentDaemonLogPath2 } = await Promise.resolve().then(() => (init_src(), src_exports));
89831
89929
  const logPath = getCurrentDaemonLogPath2();
89832
- const os30 = await import("os");
89833
- const platform12 = os30.platform();
89930
+ const os31 = await import("os");
89931
+ const platform12 = os31.platform();
89834
89932
  try {
89835
89933
  if (platform12 === "win32") {
89836
89934
  execSync8("start /B adhdev daemon >NUL 2>&1", {
@@ -91723,9 +91821,9 @@ function registerSetupCommands(program2, getProviderLoader2) {
91723
91821
  });
91724
91822
  program2.command("uninstall").description("Completely wipe all setting, configuration, stop daemon and uninstall service").option("-f, --force", "Skip confirmation prompt").action(async (options) => {
91725
91823
  const inquirer2 = await Promise.resolve().then(() => (init_lib(), lib_exports));
91726
- const fs22 = await import("fs");
91727
- const path35 = await import("path");
91728
- const os30 = await import("os");
91824
+ const fs23 = await import("fs");
91825
+ const path36 = await import("path");
91826
+ const os31 = await import("os");
91729
91827
  const { spawnSync: spawnSync3 } = await import("child_process");
91730
91828
  if (!options.force) {
91731
91829
  const { confirm } = await inquirer2.default.prompt([
@@ -91750,11 +91848,11 @@ function registerSetupCommands(program2, getProviderLoader2) {
91750
91848
  }
91751
91849
  console.log(source_default.gray(" Removing OS background service..."));
91752
91850
  spawnSync3(process.execPath, [process.argv[1], "service", "uninstall"], { stdio: "inherit" });
91753
- const adhdevDir = path35.join(os30.homedir(), ".adhdev");
91754
- if (fs22.existsSync(adhdevDir)) {
91851
+ const adhdevDir = path36.join(os31.homedir(), ".adhdev");
91852
+ if (fs23.existsSync(adhdevDir)) {
91755
91853
  console.log(source_default.gray(` Deleting ${adhdevDir}...`));
91756
91854
  try {
91757
- fs22.rmSync(adhdevDir, { recursive: true, force: true });
91855
+ fs23.rmSync(adhdevDir, { recursive: true, force: true });
91758
91856
  console.log(source_default.green(" \u2713 Data wiped."));
91759
91857
  } catch (e) {
91760
91858
  console.log(source_default.red(` \u2717 Failed to delete ~/.adhdev: ${e.message}`));
@@ -91773,11 +91871,11 @@ init_source();
91773
91871
  init_src();
91774
91872
 
91775
91873
  // src/cli/runtime-tools.ts
91776
- var fs19 = __toESM(require("fs"));
91777
- var path30 = __toESM(require("path"));
91874
+ var fs20 = __toESM(require("fs"));
91875
+ var path31 = __toESM(require("path"));
91778
91876
  function defaultPackageRoot() {
91779
- const currentCliPath = process.argv[1] ? fs19.realpathSync.native(process.argv[1]) : process.cwd();
91780
- 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), "../..");
91781
91879
  }
91782
91880
  function normalizePath2(value) {
91783
91881
  return value.replace(/\\/g, "/").toLowerCase();
@@ -91786,19 +91884,19 @@ function shouldPreferSource(currentCliPath, packageRoot) {
91786
91884
  const normalizedCliPath = normalizePath2(currentCliPath || "");
91787
91885
  if (normalizedCliPath.includes("/src/cli/")) return true;
91788
91886
  if (normalizedCliPath.includes("/dist/cli/")) return false;
91789
- return fs19.existsSync(path30.join(packageRoot, "src", "cli", "index.ts"));
91887
+ return fs20.existsSync(path31.join(packageRoot, "src", "cli", "index.ts"));
91790
91888
  }
91791
91889
  function getVendoredToolEntry(packageRoot, tool) {
91792
91890
  if (tool === "session-host-daemon") {
91793
- return path30.join(packageRoot, "vendor", "session-host-daemon", "index.js");
91891
+ return path31.join(packageRoot, "vendor", "session-host-daemon", "index.js");
91794
91892
  }
91795
- return path30.join(packageRoot, "vendor", "terminal-mux-cli", "index.js");
91893
+ return path31.join(packageRoot, "vendor", "terminal-mux-cli", "index.js");
91796
91894
  }
91797
91895
  function getSourceToolEntry(packageRoot, tool) {
91798
91896
  if (tool === "session-host-daemon") {
91799
- 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");
91800
91898
  }
91801
- 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");
91802
91900
  }
91803
91901
  function getGlobalToolCommand(tool) {
91804
91902
  return tool === "session-host-daemon" ? "adhdev-sessiond" : "adhmux";
@@ -91811,7 +91909,7 @@ function resolveRuntimeToolLaunch(tool, context = {}) {
91811
91909
  const vendoredEntry = getVendoredToolEntry(packageRoot, tool);
91812
91910
  const resolutionOrder = preferSource ? ["source", "vendored", "global"] : ["vendored", "source", "global"];
91813
91911
  for (const resolution of resolutionOrder) {
91814
- if (resolution === "source" && fs19.existsSync(sourceEntry)) {
91912
+ if (resolution === "source" && fs20.existsSync(sourceEntry)) {
91815
91913
  return {
91816
91914
  tool,
91817
91915
  resolvedVia: "source",
@@ -91820,7 +91918,7 @@ function resolveRuntimeToolLaunch(tool, context = {}) {
91820
91918
  env: env3
91821
91919
  };
91822
91920
  }
91823
- if (resolution === "vendored" && fs19.existsSync(vendoredEntry)) {
91921
+ if (resolution === "vendored" && fs20.existsSync(vendoredEntry)) {
91824
91922
  return {
91825
91923
  tool,
91826
91924
  resolvedVia: "vendored",
@@ -92953,9 +93051,9 @@ function registerDaemonCommands(program2, pkgVersion3) {
92953
93051
  // src/cli/doctor-commands.ts
92954
93052
  init_source();
92955
93053
  var import_child_process15 = require("child_process");
92956
- var fs21 = __toESM(require("fs"));
92957
- var os29 = __toESM(require("os"));
92958
- var path33 = __toESM(require("path"));
93054
+ var fs22 = __toESM(require("fs"));
93055
+ var os30 = __toESM(require("os"));
93056
+ var path34 = __toESM(require("path"));
92959
93057
  init_src();
92960
93058
  init_session_host();
92961
93059
 
@@ -93438,11 +93536,11 @@ function formatBytes(bytes) {
93438
93536
 
93439
93537
  // src/cli/doctor-commands.ts
93440
93538
  function resolvePackageRoot() {
93441
- return path33.resolve(__dirname, "..", "..");
93539
+ return path34.resolve(__dirname, "..", "..");
93442
93540
  }
93443
93541
  function isLinkedInstall(packageRoot) {
93444
- const normalized = path33.normalize(packageRoot);
93445
- 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`);
93446
93544
  }
93447
93545
  function formatCheck(check2) {
93448
93546
  const icon = check2.ok ? source_default.green("\u2713") : source_default.red("\u2717");
@@ -93526,11 +93624,11 @@ function probeSharpRuntime(packageRoot, nativeSharpPackage) {
93526
93624
  }
93527
93625
  }
93528
93626
  function probeConfigAccess() {
93529
- const configDir = path33.join(os29.homedir(), ".adhdev");
93530
- const configPath = path33.join(configDir, "config.json");
93627
+ const configDir = path34.join(os30.homedir(), ".adhdev");
93628
+ const configPath = path34.join(configDir, "config.json");
93531
93629
  const checks = [];
93532
93630
  try {
93533
- fs21.mkdirSync(configDir, { recursive: true });
93631
+ fs22.mkdirSync(configDir, { recursive: true });
93534
93632
  checks.push({
93535
93633
  label: "Config directory",
93536
93634
  ok: true,
@@ -93545,8 +93643,8 @@ function probeConfigAccess() {
93545
93643
  }];
93546
93644
  }
93547
93645
  try {
93548
- if (fs21.existsSync(configPath)) {
93549
- fs21.readFileSync(configPath, "utf-8");
93646
+ if (fs22.existsSync(configPath)) {
93647
+ fs22.readFileSync(configPath, "utf-8");
93550
93648
  checks.push({
93551
93649
  label: "Config file",
93552
93650
  ok: true,
@@ -93567,10 +93665,10 @@ function probeConfigAccess() {
93567
93665
  fatal: true
93568
93666
  });
93569
93667
  }
93570
- 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`);
93571
93669
  try {
93572
- fs21.writeFileSync(probePath, "ok", "utf-8");
93573
- fs21.rmSync(probePath, { force: true });
93670
+ fs22.writeFileSync(probePath, "ok", "utf-8");
93671
+ fs22.rmSync(probePath, { force: true });
93574
93672
  checks.push({
93575
93673
  label: "Config write",
93576
93674
  ok: true,
@@ -93578,7 +93676,7 @@ function probeConfigAccess() {
93578
93676
  });
93579
93677
  } catch (error48) {
93580
93678
  try {
93581
- fs21.rmSync(probePath, { force: true });
93679
+ fs22.rmSync(probePath, { force: true });
93582
93680
  } catch {
93583
93681
  }
93584
93682
  checks.push({
@@ -93634,9 +93732,9 @@ function probeCliBinary(commandPath, currentVersion) {
93634
93732
  return probe;
93635
93733
  }
93636
93734
  function readLogHints(logPath) {
93637
- if (!fs21.existsSync(logPath)) return [];
93735
+ if (!fs22.existsSync(logPath)) return [];
93638
93736
  try {
93639
- const content = fs21.readFileSync(logPath, "utf-8");
93737
+ const content = fs22.readFileSync(logPath, "utf-8");
93640
93738
  const lines = content.split(/\r?\n/);
93641
93739
  const recent = lines.slice(-400);
93642
93740
  const hits = recent.filter(
@@ -93650,11 +93748,11 @@ function readLogHints(logPath) {
93650
93748
  function buildBrowseProbeChecks() {
93651
93749
  const probes = process.platform === "win32" ? [
93652
93750
  process.env.SystemDrive ? `${process.env.SystemDrive.replace(/[\\/]+$/, "")}\\` : "C:\\",
93653
- os29.homedir()
93654
- ] : ["/", os29.homedir()];
93751
+ os30.homedir()
93752
+ ] : ["/", os30.homedir()];
93655
93753
  return probes.map((probePath, index) => {
93656
93754
  try {
93657
- const entries = fs21.readdirSync(probePath, { withFileTypes: true });
93755
+ const entries = fs22.readdirSync(probePath, { withFileTypes: true });
93658
93756
  const directoryCount = entries.filter((entry) => entry.isDirectory()).length;
93659
93757
  return {
93660
93758
  label: index === 0 ? "Folder browse root" : "Folder browse home",
@@ -93674,7 +93772,7 @@ function buildBrowseProbeChecks() {
93674
93772
  function registerDoctorCommands(program2, pkgVersion3) {
93675
93773
  program2.command("doctor").description("Diagnose install, native dependencies, CLI resolution, and folder browse access").action(async () => {
93676
93774
  const packageRoot = resolvePackageRoot();
93677
- const cliPath = fs21.realpathSync(process.argv[1]);
93775
+ const cliPath = fs22.realpathSync(process.argv[1]);
93678
93776
  const linked = isLinkedInstall(packageRoot);
93679
93777
  const logPath = getCurrentDaemonLogPath();
93680
93778
  const claudePaths = findCommandPaths("claude");
@@ -93756,12 +93854,12 @@ function registerDoctorCommands(program2, pkgVersion3) {
93756
93854
  });
93757
93855
  }
93758
93856
  if (process.platform === "darwin") {
93759
- serviceDefinitionPath = path33.join(os29.homedir(), "Library", "LaunchAgents", "dev.adhf.daemon.plist");
93760
- if (fs21.existsSync(serviceDefinitionPath)) {
93857
+ serviceDefinitionPath = path34.join(os30.homedir(), "Library", "LaunchAgents", "dev.adhf.daemon.plist");
93858
+ if (fs22.existsSync(serviceDefinitionPath)) {
93761
93859
  serviceDefinitionCheck = evaluateServiceDefinitionDrift({
93762
93860
  serviceKind: "launchd",
93763
93861
  servicePath: serviceDefinitionPath,
93764
- installedDefinition: fs21.readFileSync(serviceDefinitionPath, "utf8"),
93862
+ installedDefinition: fs22.readFileSync(serviceDefinitionPath, "utf8"),
93765
93863
  expectedDefinition: buildPlist(process.execPath, cliPath)
93766
93864
  });
93767
93865
  checks.push({
@@ -93829,12 +93927,12 @@ function registerDoctorCommands(program2, pkgVersion3) {
93829
93927
  serviceCheck: serviceDefinitionCheck || void 0,
93830
93928
  sourceCliExample: "node --import tsx packages/daemon-cloud/src/cli/index.ts doctor"
93831
93929
  });
93832
- const sessionHostLogPath = path33.join(os29.homedir(), ".adhdev", "logs", "session-host.log");
93930
+ const sessionHostLogPath = path34.join(os30.homedir(), ".adhdev", "logs", "session-host.log");
93833
93931
  console.log(source_default.bold("\n\u{1FA7A} ADHDev Doctor\n"));
93834
93932
  console.log(source_default.gray(` Version: ${pkgVersion3}`));
93835
93933
  console.log(source_default.gray(` Platform: ${process.platform} ${process.arch}`));
93836
93934
  console.log(source_default.gray(` Node: ${process.version}`));
93837
- console.log(source_default.gray(` Home: ${os29.homedir()}`));
93935
+ console.log(source_default.gray(` Home: ${os30.homedir()}`));
93838
93936
  console.log(source_default.gray(` Log file: ${logPath}`));
93839
93937
  console.log(source_default.gray(` SH log: ${sessionHostLogPath}`));
93840
93938
  console.log();
@@ -93871,7 +93969,7 @@ function registerDoctorCommands(program2, pkgVersion3) {
93871
93969
 
93872
93970
  // src/cli/provider-commands.ts
93873
93971
  init_source();
93874
- var path34 = __toESM(require("path"));
93972
+ var path35 = __toESM(require("path"));
93875
93973
  init_cdp_utils();
93876
93974
  var DEV_SERVER_PORT3 = 19280;
93877
93975
  var IDE_AUTO_FIX_FUNCTIONS = [
@@ -93954,7 +94052,7 @@ function getProviderSourceCandidatePaths(options) {
93954
94052
  const results = [];
93955
94053
  for (const root of roots) {
93956
94054
  for (const name of relativeNames) {
93957
- results.push(path34.join(root, options.category, options.type, name));
94055
+ results.push(path35.join(root, options.category, options.type, name));
93958
94056
  }
93959
94057
  }
93960
94058
  return results;
@@ -94089,35 +94187,35 @@ function registerProviderCommands(program2) {
94089
94187
  let osPaths = {};
94090
94188
  let processNames = {};
94091
94189
  if (category === "ide") {
94092
- const fs22 = await import("fs");
94093
- const path35 = await import("path");
94094
- const os30 = await import("os");
94095
- 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") {
94096
94194
  while (true) {
94097
94195
  const p = (await rl.question(`macOS Application Path (e.g. /Applications/${defaultName}.app): `)).trim() || `/Applications/${defaultName}.app`;
94098
94196
  if (p === "skip") break;
94099
- if (!fs22.existsSync(p)) {
94197
+ if (!fs23.existsSync(p)) {
94100
94198
  console.log(source_default.red(` \u2717 Path not found: ${p}`));
94101
94199
  console.log(source_default.gray(` (Please provide the exact absolute path to the .app or binary, or type 'skip')`));
94102
94200
  continue;
94103
94201
  }
94104
94202
  console.log(source_default.green(` \u2713 Path verified: ${p}`));
94105
94203
  osPaths["darwin"] = [p];
94106
- processNames["darwin"] = path35.basename(p, ".app");
94204
+ processNames["darwin"] = path36.basename(p, ".app");
94107
94205
  break;
94108
94206
  }
94109
- } else if (os30.platform() === "win32") {
94207
+ } else if (os31.platform() === "win32") {
94110
94208
  while (true) {
94111
94209
  const p = (await rl.question(`Windows Executable Path (e.g. C:\\Program Files\\${defaultName}\\${defaultName}.exe): `)).trim();
94112
94210
  if (!p || p === "skip") break;
94113
- if (!fs22.existsSync(p)) {
94211
+ if (!fs23.existsSync(p)) {
94114
94212
  console.log(source_default.red(` \u2717 Path not found: ${p}`));
94115
94213
  console.log(source_default.gray(` (Please provide the exact absolute path, or type 'skip')`));
94116
94214
  continue;
94117
94215
  }
94118
94216
  console.log(source_default.green(` \u2713 Path verified: ${p}`));
94119
94217
  osPaths["win32"] = [p];
94120
- processNames["win32"] = path35.basename(p, ".exe");
94218
+ processNames["win32"] = path36.basename(p, ".exe");
94121
94219
  break;
94122
94220
  }
94123
94221
  }
@@ -94804,8 +94902,8 @@ function registerCdpCommands(program2) {
94804
94902
  }
94805
94903
  const output = typeof result === "string" ? result : JSON.stringify(result, null, 2);
94806
94904
  if (options.output) {
94807
- const fs22 = await import("fs");
94808
- fs22.writeFileSync(options.output, output, "utf-8");
94905
+ const fs23 = await import("fs");
94906
+ fs23.writeFileSync(options.output, output, "utf-8");
94809
94907
  console.log(source_default.green(`
94810
94908
  \u2713 Saved to ${options.output} (${output.length} chars)
94811
94909
  `));
@@ -94908,8 +95006,8 @@ function registerCdpCommands(program2) {
94908
95006
  ws.on("message", async (data) => {
94909
95007
  const msg = JSON.parse(data.toString());
94910
95008
  if (msg.id === 1 && msg.result?.data) {
94911
- const fs22 = await import("fs");
94912
- 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"));
94913
95011
  console.log(source_default.green(`
94914
95012
  \u2713 Screenshot saved to ${options.output}
94915
95013
  `));