adhdev 0.9.50 → 0.9.52

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -890,17 +890,17 @@ function checkPathExists(paths) {
890
890
  return null;
891
891
  }
892
892
  async function detectIDEs(providerLoader) {
893
- const os28 = (0, import_os2.platform)();
893
+ const os29 = (0, import_os2.platform)();
894
894
  const results = [];
895
895
  for (const def of getMergedDefinitions()) {
896
896
  const cliPath = findCliCommand(providerLoader?.getIdeCliCommand(def.id, def.cli) || def.cli);
897
- const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os28] || []) || []);
897
+ const appPath = checkPathExists(providerLoader?.getIdePathCandidates(def.id, def.paths[os29] || []) || []);
898
898
  let resolvedCli = cliPath;
899
- if (!resolvedCli && appPath && os28 === "darwin") {
899
+ if (!resolvedCli && appPath && os29 === "darwin") {
900
900
  const bundledCli = `${appPath}/Contents/Resources/app/bin/${def.cli}`;
901
901
  if ((0, import_fs3.existsSync)(bundledCli)) resolvedCli = bundledCli;
902
902
  }
903
- if (!resolvedCli && appPath && os28 === "win32") {
903
+ if (!resolvedCli && appPath && os29 === "win32") {
904
904
  const { dirname: dirname10 } = await import("path");
905
905
  const appDir = dirname10(appPath);
906
906
  const candidates = [
@@ -917,7 +917,7 @@ async function detectIDEs(providerLoader) {
917
917
  }
918
918
  }
919
919
  }
920
- const installed = os28 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
920
+ const installed = os29 === "darwin" ? !!(resolvedCli || appPath) : !!resolvedCli;
921
921
  const version2 = resolvedCli ? getIdeVersion(resolvedCli) : null;
922
922
  results.push({
923
923
  id: def.id,
@@ -7708,6 +7708,50 @@ function buildDebugBundleText(bundle) {
7708
7708
  "```"
7709
7709
  ].join("\n");
7710
7710
  }
7711
+ function getChatDebugBundleDir() {
7712
+ const override = typeof process.env.ADHDEV_DEBUG_BUNDLE_DIR === "string" ? process.env.ADHDEV_DEBUG_BUNDLE_DIR.trim() : "";
7713
+ return override || path8.join(os6.homedir(), ".adhdev", "debug-bundles", "chat");
7714
+ }
7715
+ function safeBundleIdSegment(value, fallback2) {
7716
+ const normalized = String(value || fallback2).trim().replace(/[^A-Za-z0-9_.-]+/g, "-").replace(/^-+|-+$/g, "").slice(0, 80);
7717
+ return normalized || fallback2;
7718
+ }
7719
+ function createChatDebugBundleId(targetSessionId) {
7720
+ const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[-:.]/g, "").replace("T", "T").replace("Z", "Z");
7721
+ const sessionSegment = safeBundleIdSegment(targetSessionId, "unknown-session");
7722
+ return `chat-debug-${timestamp}-${sessionSegment}-${(0, import_node_crypto.randomUUID)().slice(0, 8)}`;
7723
+ }
7724
+ function buildChatDebugBundleSummary(bundle) {
7725
+ const target = bundle.target && typeof bundle.target === "object" ? bundle.target : {};
7726
+ const readChat = bundle.readChat && typeof bundle.readChat === "object" ? bundle.readChat : {};
7727
+ const cli = bundle.cli && typeof bundle.cli === "object" ? bundle.cli : null;
7728
+ const frontend = bundle.frontend && typeof bundle.frontend === "object" ? bundle.frontend : null;
7729
+ return {
7730
+ createdAt: bundle.createdAt,
7731
+ targetSessionId: target.targetSessionId,
7732
+ providerType: target.providerType,
7733
+ transport: target.transport,
7734
+ readChatSuccess: readChat.success,
7735
+ readChatStatus: readChat.status,
7736
+ readChatTotalMessages: readChat.totalMessages,
7737
+ cliStatus: cli?.status,
7738
+ cliMessageCount: cli?.messageCount,
7739
+ hasFrontendSnapshot: !!frontend
7740
+ };
7741
+ }
7742
+ function storeChatDebugBundleOnDaemon(bundle, targetSessionId) {
7743
+ const bundleId = createChatDebugBundleId(targetSessionId);
7744
+ const dir = getChatDebugBundleDir();
7745
+ fs4.mkdirSync(dir, { recursive: true });
7746
+ const savedPath = path8.join(dir, `${bundleId}.json`);
7747
+ const json2 = `${JSON.stringify(bundle, null, 2)}
7748
+ `;
7749
+ fs4.writeFileSync(savedPath, json2, { encoding: "utf8", mode: 384 });
7750
+ return { bundleId, savedPath, sizeBytes: Buffer.byteLength(json2, "utf8") };
7751
+ }
7752
+ function isDaemonFileDebugDelivery(args) {
7753
+ return args?.delivery === "daemon_file" || args?.delivery === "file";
7754
+ }
7711
7755
  async function handleGetChatDebugBundle(h, args) {
7712
7756
  const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
7713
7757
  if (!targetSessionId && !h.currentSession) {
@@ -7819,6 +7863,20 @@ async function handleGetChatDebugBundle(h, args) {
7819
7863
  recentDebugTrace: getRecentDebugTrace({ limit: 120 })
7820
7864
  };
7821
7865
  const bundle = sanitizeDebugBundleValue(rawBundle);
7866
+ if (isDaemonFileDebugDelivery(args)) {
7867
+ const summary = buildChatDebugBundleSummary(bundle);
7868
+ const stored = storeChatDebugBundleOnDaemon(bundle, targetSessionId || String(summary.targetSessionId || "unknown-session"));
7869
+ 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 || ""}`);
7870
+ return {
7871
+ success: true,
7872
+ delivery: "daemon_file",
7873
+ bundleId: stored.bundleId,
7874
+ savedPath: stored.savedPath,
7875
+ sizeBytes: stored.sizeBytes,
7876
+ createdAt: bundle.createdAt,
7877
+ summary
7878
+ };
7879
+ }
7822
7880
  return {
7823
7881
  success: true,
7824
7882
  bundle,
@@ -8798,10 +8856,14 @@ async function handleResolveAction(h, args) {
8798
8856
  }
8799
8857
  return { success: false, error: "resolveAction script not available for this provider" };
8800
8858
  }
8801
- var RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget, DEFAULT_DEBUG_SANITIZE_OPTIONS, SECRET_KEY_PATTERN;
8859
+ var fs4, os6, path8, import_node_crypto, RECENT_SEND_WINDOW_MS, READ_CHAT_PROVIDER_EVAL_TIMEOUT_MS, recentSendByTarget, DEFAULT_DEBUG_SANITIZE_OPTIONS, SECRET_KEY_PATTERN;
8802
8860
  var init_chat_commands = __esm({
8803
8861
  "../../oss/packages/daemon-core/src/commands/chat-commands.ts"() {
8804
8862
  "use strict";
8863
+ fs4 = __toESM(require("fs"));
8864
+ os6 = __toESM(require("os"));
8865
+ path8 = __toESM(require("path"));
8866
+ import_node_crypto = require("crypto");
8805
8867
  init_contracts();
8806
8868
  init_provider_input_support();
8807
8869
  init_read_chat_contract();
@@ -9042,27 +9104,27 @@ function normalizeWindowsRequestedPath(requestedPath) {
9042
9104
  function resolveSafePath(requestedPath) {
9043
9105
  const rawPath = typeof requestedPath === "string" ? requestedPath.trim() : "";
9044
9106
  const inputPath = rawPath || ".";
9045
- const home = os6.homedir();
9107
+ const home = os7.homedir();
9046
9108
  if (inputPath.startsWith("~")) {
9047
- return path8.resolve(path8.join(home, inputPath.slice(1)));
9109
+ return path9.resolve(path9.join(home, inputPath.slice(1)));
9048
9110
  }
9049
9111
  if (process.platform === "win32") {
9050
9112
  const normalized = normalizeWindowsRequestedPath(inputPath);
9051
- if (path8.win32.isAbsolute(normalized)) {
9052
- return path8.win32.normalize(normalized);
9113
+ if (path9.win32.isAbsolute(normalized)) {
9114
+ return path9.win32.normalize(normalized);
9053
9115
  }
9054
- return path8.win32.resolve(normalized);
9116
+ return path9.win32.resolve(normalized);
9055
9117
  }
9056
- if (path8.isAbsolute(inputPath)) {
9057
- return path8.normalize(inputPath);
9118
+ if (path9.isAbsolute(inputPath)) {
9119
+ return path9.normalize(inputPath);
9058
9120
  }
9059
- return path8.resolve(inputPath);
9121
+ return path9.resolve(inputPath);
9060
9122
  }
9061
9123
  function listDirectoryEntriesSafe(dirPath) {
9062
- const entries = fs4.readdirSync(dirPath, { withFileTypes: true });
9124
+ const entries = fs5.readdirSync(dirPath, { withFileTypes: true });
9063
9125
  const files = [];
9064
9126
  for (const entry of entries) {
9065
- const entryPath = path8.join(dirPath, entry.name);
9127
+ const entryPath = path9.join(dirPath, entry.name);
9066
9128
  try {
9067
9129
  if (entry.isDirectory()) {
9068
9130
  files.push({ name: entry.name, type: "directory" });
@@ -9071,14 +9133,14 @@ function listDirectoryEntriesSafe(dirPath) {
9071
9133
  if (entry.isFile()) {
9072
9134
  let size;
9073
9135
  try {
9074
- size = fs4.statSync(entryPath).size;
9136
+ size = fs5.statSync(entryPath).size;
9075
9137
  } catch {
9076
9138
  size = void 0;
9077
9139
  }
9078
9140
  files.push({ name: entry.name, type: "file", size });
9079
9141
  continue;
9080
9142
  }
9081
- const stat4 = fs4.statSync(entryPath);
9143
+ const stat4 = fs5.statSync(entryPath);
9082
9144
  files.push({
9083
9145
  name: entry.name,
9084
9146
  type: stat4.isDirectory() ? "directory" : "file",
@@ -9096,7 +9158,7 @@ function listWindowsDriveEntries(excludePath) {
9096
9158
  const letter = String.fromCharCode(code);
9097
9159
  const root = `${letter}:\\`;
9098
9160
  try {
9099
- if (!fs4.existsSync(root)) continue;
9161
+ if (!fs5.existsSync(root)) continue;
9100
9162
  if (excluded && root.toLowerCase() === excluded) continue;
9101
9163
  drives.push({ name: `${letter}:`, type: "directory", path: root });
9102
9164
  } catch {
@@ -9107,7 +9169,7 @@ function listWindowsDriveEntries(excludePath) {
9107
9169
  async function handleFileRead(h, args) {
9108
9170
  try {
9109
9171
  const filePath = resolveSafePath(args?.path);
9110
- const content = fs4.readFileSync(filePath, "utf-8");
9172
+ const content = fs5.readFileSync(filePath, "utf-8");
9111
9173
  return { success: true, content, path: filePath };
9112
9174
  } catch (e) {
9113
9175
  return { success: false, error: e.message };
@@ -9116,8 +9178,8 @@ async function handleFileRead(h, args) {
9116
9178
  async function handleFileWrite(h, args) {
9117
9179
  try {
9118
9180
  const filePath = resolveSafePath(args?.path);
9119
- fs4.mkdirSync(path8.dirname(filePath), { recursive: true });
9120
- fs4.writeFileSync(filePath, args?.content || "", "utf-8");
9181
+ fs5.mkdirSync(path9.dirname(filePath), { recursive: true });
9182
+ fs5.writeFileSync(filePath, args?.content || "", "utf-8");
9121
9183
  return { success: true, path: filePath };
9122
9184
  } catch (e) {
9123
9185
  return { success: false, error: e.message };
@@ -9149,13 +9211,13 @@ async function handleFileListBrowse(h, args) {
9149
9211
  return { success: false, error: e.message };
9150
9212
  }
9151
9213
  }
9152
- var fs4, path8, os6, KEY_TO_VK;
9214
+ var fs5, path9, os7, KEY_TO_VK;
9153
9215
  var init_cdp_commands = __esm({
9154
9216
  "../../oss/packages/daemon-core/src/commands/cdp-commands.ts"() {
9155
9217
  "use strict";
9156
- fs4 = __toESM(require("fs"));
9157
- path8 = __toESM(require("path"));
9158
- os6 = __toESM(require("os"));
9218
+ fs5 = __toESM(require("fs"));
9219
+ path9 = __toESM(require("path"));
9220
+ os7 = __toESM(require("os"));
9159
9221
  KEY_TO_VK = {
9160
9222
  Backspace: 8,
9161
9223
  Tab: 9,
@@ -9400,12 +9462,13 @@ async function handleSetProviderSourceConfig(h, args) {
9400
9462
  });
9401
9463
  loader.reload();
9402
9464
  loader.registerToDetector();
9465
+ const refreshedInstances = h.ctx.instanceManager ? h.ctx.instanceManager.refreshProviderDefinitions((providerType) => loader.resolve(providerType)) : 0;
9403
9466
  await h.ctx.onProviderSourceConfigChanged?.();
9404
9467
  LOG.info(
9405
9468
  "Command",
9406
9469
  `[set_provider_source_config] mode=${sourceConfig.sourceMode} explicitProviderDir=${sourceConfig.explicitProviderDir || "-"} userDir=${sourceConfig.userDir}`
9407
9470
  );
9408
- return { success: true, reloaded: true, ...sourceConfig };
9471
+ return { success: true, reloaded: true, refreshedInstances, ...sourceConfig };
9409
9472
  }
9410
9473
  function normalizeProviderScriptArgs(args, scriptName) {
9411
9474
  const normalizedArgs = { ...args || {} };
@@ -11096,7 +11159,7 @@ function getDefaultSessionHostEndpoint(appName = "adhdev") {
11096
11159
  }
11097
11160
  return {
11098
11161
  kind: "unix",
11099
- path: path22.join(os8.tmpdir(), `${appName}-session-host.sock`)
11162
+ path: path22.join(os9.tmpdir(), `${appName}-session-host.sock`)
11100
11163
  };
11101
11164
  }
11102
11165
  function serializeEnvelope(envelope) {
@@ -11149,25 +11212,25 @@ function applyTerminalColorEnv(env3) {
11149
11212
  function ensureNodePtySpawnHelperPermissions(logFn) {
11150
11213
  if (os22.platform() === "win32") return;
11151
11214
  try {
11152
- const fs19 = __require("fs");
11215
+ const fs20 = __require("fs");
11153
11216
  const ptyDir = path32.resolve(path32.dirname(__require.resolve("node-pty")), "..");
11154
11217
  const platformArch = `${os22.platform()}-${os22.arch()}`;
11155
11218
  const helper = path32.join(ptyDir, "prebuilds", platformArch, "spawn-helper");
11156
- if (fs19.existsSync(helper)) {
11157
- const stat4 = fs19.statSync(helper);
11219
+ if (fs20.existsSync(helper)) {
11220
+ const stat4 = fs20.statSync(helper);
11158
11221
  if (!(stat4.mode & 73)) {
11159
- fs19.chmodSync(helper, stat4.mode | 493);
11222
+ fs20.chmodSync(helper, stat4.mode | 493);
11160
11223
  logFn?.(`Fixed spawn-helper permissions: ${helper}`);
11161
11224
  }
11162
11225
  }
11163
11226
  } catch {
11164
11227
  }
11165
11228
  }
11166
- var os8, path22, net, import_crypto3, os22, path32, __require, DEFAULT_SESSION_RING_BUFFER_MAX_BYTES, DEFAULT_SESSION_HOST_COLS, DEFAULT_SESSION_HOST_ROWS, SessionHostClient;
11229
+ var os9, path22, net, import_crypto3, os22, path32, __require, DEFAULT_SESSION_RING_BUFFER_MAX_BYTES, DEFAULT_SESSION_HOST_COLS, DEFAULT_SESSION_HOST_ROWS, SessionHostClient;
11167
11230
  var init_dist = __esm({
11168
11231
  "../../oss/packages/session-host-core/dist/index.mjs"() {
11169
11232
  "use strict";
11170
- os8 = __toESM(require("os"), 1);
11233
+ os9 = __toESM(require("os"), 1);
11171
11234
  path22 = __toESM(require("path"), 1);
11172
11235
  net = __toESM(require("net"), 1);
11173
11236
  import_crypto3 = require("crypto");
@@ -11310,11 +11373,11 @@ function loadNodePty() {
11310
11373
  }
11311
11374
  return cachedPty;
11312
11375
  }
11313
- var os9, cachedPty, NodePtyRuntimeTransport, NodePtyTransportFactory;
11376
+ var os10, cachedPty, NodePtyRuntimeTransport, NodePtyTransportFactory;
11314
11377
  var init_pty_transport = __esm({
11315
11378
  "../../oss/packages/daemon-core/src/cli-adapters/pty-transport.ts"() {
11316
11379
  "use strict";
11317
- os9 = __toESM(require("os"));
11380
+ os10 = __toESM(require("os"));
11318
11381
  init_spawn_env();
11319
11382
  NodePtyRuntimeTransport = class {
11320
11383
  constructor(handle) {
@@ -11351,11 +11414,11 @@ var init_pty_transport = __esm({
11351
11414
  let cwd = options.cwd;
11352
11415
  if (cwd) {
11353
11416
  try {
11354
- const fs19 = require("fs");
11355
- const stat4 = fs19.statSync(cwd);
11356
- if (!stat4.isDirectory()) cwd = os9.homedir();
11417
+ const fs20 = require("fs");
11418
+ const stat4 = fs20.statSync(cwd);
11419
+ if (!stat4.isDirectory()) cwd = os10.homedir();
11357
11420
  } catch {
11358
- cwd = os9.homedir();
11421
+ cwd = os10.homedir();
11359
11422
  }
11360
11423
  }
11361
11424
  const handle = pty.spawn(command, args, {
@@ -11435,11 +11498,11 @@ function buildCliScreenSnapshot(text) {
11435
11498
  function findBinary(name) {
11436
11499
  const trimmed = String(name || "").trim();
11437
11500
  if (!trimmed) return trimmed;
11438
- const expanded = trimmed.startsWith("~") ? path9.join(os10.homedir(), trimmed.slice(1)) : trimmed;
11439
- if (path9.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
11440
- return path9.isAbsolute(expanded) ? expanded : path9.resolve(expanded);
11501
+ const expanded = trimmed.startsWith("~") ? path10.join(os11.homedir(), trimmed.slice(1)) : trimmed;
11502
+ if (path10.isAbsolute(expanded) || expanded.includes("/") || expanded.includes("\\")) {
11503
+ return path10.isAbsolute(expanded) ? expanded : path10.resolve(expanded);
11441
11504
  }
11442
- const isWin = os10.platform() === "win32";
11505
+ const isWin = os11.platform() === "win32";
11443
11506
  try {
11444
11507
  const cmd = isWin ? `where ${trimmed}` : `which ${trimmed}`;
11445
11508
  return (0, import_child_process4.execSync)(cmd, {
@@ -11453,14 +11516,14 @@ function findBinary(name) {
11453
11516
  }
11454
11517
  }
11455
11518
  function isScriptBinary(binaryPath) {
11456
- if (!path9.isAbsolute(binaryPath)) return false;
11519
+ if (!path10.isAbsolute(binaryPath)) return false;
11457
11520
  try {
11458
- const fs19 = require("fs");
11459
- const resolved = fs19.realpathSync(binaryPath);
11521
+ const fs20 = require("fs");
11522
+ const resolved = fs20.realpathSync(binaryPath);
11460
11523
  const head = Buffer.alloc(8);
11461
- const fd = fs19.openSync(resolved, "r");
11462
- fs19.readSync(fd, head, 0, 8, 0);
11463
- fs19.closeSync(fd);
11524
+ const fd = fs20.openSync(resolved, "r");
11525
+ fs20.readSync(fd, head, 0, 8, 0);
11526
+ fs20.closeSync(fd);
11464
11527
  let i = 0;
11465
11528
  if (head[0] === 239 && head[1] === 187 && head[2] === 191) i = 3;
11466
11529
  return head[i] === 35 && head[i + 1] === 33;
@@ -11469,14 +11532,14 @@ function isScriptBinary(binaryPath) {
11469
11532
  }
11470
11533
  }
11471
11534
  function looksLikeMachOOrElf(filePath) {
11472
- if (!path9.isAbsolute(filePath)) return false;
11535
+ if (!path10.isAbsolute(filePath)) return false;
11473
11536
  try {
11474
- const fs19 = require("fs");
11475
- const resolved = fs19.realpathSync(filePath);
11537
+ const fs20 = require("fs");
11538
+ const resolved = fs20.realpathSync(filePath);
11476
11539
  const buf = Buffer.alloc(8);
11477
- const fd = fs19.openSync(resolved, "r");
11478
- fs19.readSync(fd, buf, 0, 8, 0);
11479
- fs19.closeSync(fd);
11540
+ const fd = fs20.openSync(resolved, "r");
11541
+ fs20.readSync(fd, buf, 0, 8, 0);
11542
+ fs20.closeSync(fd);
11480
11543
  let i = 0;
11481
11544
  if (buf[0] === 239 && buf[1] === 187 && buf[2] === 191) i = 3;
11482
11545
  const b = buf.subarray(i);
@@ -11492,7 +11555,7 @@ function looksLikeMachOOrElf(filePath) {
11492
11555
  }
11493
11556
  function shSingleQuote(arg) {
11494
11557
  if (/^[a-zA-Z0-9@%_+=:,./-]+$/.test(arg)) return arg;
11495
- if (os10.platform() === "win32") {
11558
+ if (os11.platform() === "win32") {
11496
11559
  return `"${arg.replace(/"/g, '""')}"`;
11497
11560
  }
11498
11561
  return `'${arg.replace(/'/g, `'\\''`)}'`;
@@ -11619,12 +11682,12 @@ function normalizeCliProviderForRuntime(raw) {
11619
11682
  }
11620
11683
  };
11621
11684
  }
11622
- var os10, path9, import_child_process4, buildCliSpawnEnv, COMMON_COMPARABLE_WRAP_WORDS;
11685
+ var os11, path10, import_child_process4, buildCliSpawnEnv, COMMON_COMPARABLE_WRAP_WORDS;
11623
11686
  var init_provider_cli_shared = __esm({
11624
11687
  "../../oss/packages/daemon-core/src/cli-adapters/provider-cli-shared.ts"() {
11625
11688
  "use strict";
11626
- os10 = __toESM(require("os"));
11627
- path9 = __toESM(require("path"));
11689
+ os11 = __toESM(require("os"));
11690
+ path10 = __toESM(require("path"));
11628
11691
  import_child_process4 = require("child_process");
11629
11692
  init_spawn_env();
11630
11693
  buildCliSpawnEnv = sanitizeSpawnEnv;
@@ -11937,13 +12000,13 @@ function resolveCliSpawnPlan(options) {
11937
12000
  const { spawn: spawnConfig } = provider;
11938
12001
  const configuredCommand = typeof runtimeSettings.executablePath === "string" && runtimeSettings.executablePath.trim() ? runtimeSettings.executablePath.trim() : spawnConfig.command;
11939
12002
  const binaryPath = findBinary(configuredCommand);
11940
- const isWin = os11.platform() === "win32";
12003
+ const isWin = os12.platform() === "win32";
11941
12004
  const allArgs = [...spawnConfig.args, ...extraArgs];
11942
12005
  let shellCmd;
11943
12006
  let shellArgs;
11944
- const useShellUnix = !isWin && (!!spawnConfig.shell || !path10.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
12007
+ const useShellUnix = !isWin && (!!spawnConfig.shell || !path11.isAbsolute(binaryPath) || isScriptBinary(binaryPath) || !looksLikeMachOOrElf(binaryPath));
11945
12008
  const isCmdShim = isWin && /\.(cmd|bat)$/i.test(binaryPath);
11946
- const useShellWin = !!spawnConfig.shell || isCmdShim || !path10.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
12009
+ const useShellWin = !!spawnConfig.shell || isCmdShim || !path11.isAbsolute(binaryPath) || isScriptBinary(binaryPath);
11947
12010
  const useShell = isWin ? useShellWin : useShellUnix;
11948
12011
  if (useShell) {
11949
12012
  shellCmd = isWin ? "cmd.exe" : process.env.SHELL || "/bin/zsh";
@@ -12019,12 +12082,12 @@ function respondToCliTerminalQueries(options) {
12019
12082
  }
12020
12083
  return "";
12021
12084
  }
12022
- var os11, path10;
12085
+ var os12, path11;
12023
12086
  var init_provider_cli_runtime = __esm({
12024
12087
  "../../oss/packages/daemon-core/src/cli-adapters/provider-cli-runtime.ts"() {
12025
12088
  "use strict";
12026
- os11 = __toESM(require("os"));
12027
- path10 = __toESM(require("path"));
12089
+ os12 = __toESM(require("os"));
12090
+ path11 = __toESM(require("path"));
12028
12091
  init_dist();
12029
12092
  init_provider_cli_shared();
12030
12093
  }
@@ -12146,11 +12209,11 @@ function trimLastAssistantEchoForCliMessages(messages, prompt2) {
12146
12209
  return;
12147
12210
  }
12148
12211
  }
12149
- var os12, COMMITTED_ACTIVITY_PREFIX_BLOCK_RE, ProviderCliAdapter;
12212
+ var os13, COMMITTED_ACTIVITY_PREFIX_BLOCK_RE, ProviderCliAdapter;
12150
12213
  var init_provider_cli_adapter = __esm({
12151
12214
  "../../oss/packages/daemon-core/src/cli-adapters/provider-cli-adapter.ts"() {
12152
12215
  "use strict";
12153
- os12 = __toESM(require("os"));
12216
+ os13 = __toESM(require("os"));
12154
12217
  init_logger();
12155
12218
  init_debug_config();
12156
12219
  init_terminal_screen();
@@ -12170,7 +12233,7 @@ var init_provider_cli_adapter = __esm({
12170
12233
  this.transportFactory = transportFactory;
12171
12234
  this.cliType = provider.type;
12172
12235
  this.cliName = provider.name;
12173
- this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os12.homedir()) : workingDir;
12236
+ this.workingDir = workingDir.startsWith("~") ? workingDir.replace(/^~/, os13.homedir()) : workingDir;
12174
12237
  const resolvedConfig = resolveCliAdapterConfig(provider);
12175
12238
  this.timeouts = resolvedConfig.timeouts;
12176
12239
  this.approvalKeys = resolvedConfig.approvalKeys;
@@ -14553,7 +14616,7 @@ function buildIncrementalHistoryAppendMessages(previousMessages, currentMessages
14553
14616
  }
14554
14617
  function getDatabaseSync() {
14555
14618
  if (CachedDatabaseSync) return CachedDatabaseSync;
14556
- const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(path11.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
14619
+ const requireFn = typeof require === "function" ? require : (0, import_node_module.createRequire)(path12.join(process.cwd(), "__adhdev_sqlite_loader__.js"));
14557
14620
  const sqliteModule = requireFn(`node:${"sqlite"}`);
14558
14621
  CachedDatabaseSync = sqliteModule.DatabaseSync;
14559
14622
  if (!CachedDatabaseSync) {
@@ -14595,14 +14658,14 @@ async function waitForCliAdapterReady(adapter, options) {
14595
14658
  }
14596
14659
  throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
14597
14660
  }
14598
- var os13, path11, crypto3, fs5, import_node_module, CachedDatabaseSync, CliProviderInstance;
14661
+ var os14, path12, crypto3, fs6, import_node_module, CachedDatabaseSync, CliProviderInstance;
14599
14662
  var init_cli_provider_instance = __esm({
14600
14663
  "../../oss/packages/daemon-core/src/providers/cli-provider-instance.ts"() {
14601
14664
  "use strict";
14602
- os13 = __toESM(require("os"));
14603
- path11 = __toESM(require("path"));
14665
+ os14 = __toESM(require("os"));
14666
+ path12 = __toESM(require("path"));
14604
14667
  crypto3 = __toESM(require("crypto"));
14605
- fs5 = __toESM(require("fs"));
14668
+ fs6 = __toESM(require("fs"));
14606
14669
  import_node_module = require("module");
14607
14670
  init_contracts();
14608
14671
  init_provider_input_support();
@@ -14725,10 +14788,10 @@ var init_cli_provider_instance = __esm({
14725
14788
  * Replaces the previously duplicated probeOpenCode/Codex/Goose functions.
14726
14789
  */
14727
14790
  probeSessionIdFromConfig(probe) {
14728
- const resolvedDbPath = probe.dbPath.replace(/^~/, os13.homedir());
14791
+ const resolvedDbPath = probe.dbPath.replace(/^~/, os14.homedir());
14729
14792
  const now = Date.now();
14730
14793
  if (this.cachedSqliteDbMissingUntil > now) return null;
14731
- if (!fs5.existsSync(resolvedDbPath)) {
14794
+ if (!fs6.existsSync(resolvedDbPath)) {
14732
14795
  this.cachedSqliteDbMissingUntil = now + 1e4;
14733
14796
  return null;
14734
14797
  }
@@ -15460,7 +15523,7 @@ ${effect.notification.body || ""}`.trim();
15460
15523
  };
15461
15524
  addDir(this.workingDir);
15462
15525
  try {
15463
- addDir(fs5.realpathSync.native(this.workingDir));
15526
+ addDir(fs6.realpathSync.native(this.workingDir));
15464
15527
  } catch {
15465
15528
  }
15466
15529
  return Array.from(dirs);
@@ -15751,10 +15814,10 @@ function mergeDefs(...defs) {
15751
15814
  function cloneDef(schema) {
15752
15815
  return mergeDefs(schema._zod.def);
15753
15816
  }
15754
- function getElementAtPath(obj, path28) {
15755
- if (!path28)
15817
+ function getElementAtPath(obj, path29) {
15818
+ if (!path29)
15756
15819
  return obj;
15757
- return path28.reduce((acc, key) => acc?.[key], obj);
15820
+ return path29.reduce((acc, key) => acc?.[key], obj);
15758
15821
  }
15759
15822
  function promiseAllObject(promisesObj) {
15760
15823
  const keys = Object.keys(promisesObj);
@@ -16066,11 +16129,11 @@ function aborted(x, startIndex = 0) {
16066
16129
  }
16067
16130
  return false;
16068
16131
  }
16069
- function prefixIssues(path28, issues) {
16132
+ function prefixIssues(path29, issues) {
16070
16133
  return issues.map((iss) => {
16071
16134
  var _a2;
16072
16135
  (_a2 = iss).path ?? (_a2.path = []);
16073
- iss.path.unshift(path28);
16136
+ iss.path.unshift(path29);
16074
16137
  return iss;
16075
16138
  });
16076
16139
  }
@@ -16313,7 +16376,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
16313
16376
  }
16314
16377
  function treeifyError(error48, mapper = (issue2) => issue2.message) {
16315
16378
  const result = { errors: [] };
16316
- const processError = (error49, path28 = []) => {
16379
+ const processError = (error49, path29 = []) => {
16317
16380
  var _a2, _b;
16318
16381
  for (const issue2 of error49.issues) {
16319
16382
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -16323,7 +16386,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
16323
16386
  } else if (issue2.code === "invalid_element") {
16324
16387
  processError({ issues: issue2.issues }, issue2.path);
16325
16388
  } else {
16326
- const fullpath = [...path28, ...issue2.path];
16389
+ const fullpath = [...path29, ...issue2.path];
16327
16390
  if (fullpath.length === 0) {
16328
16391
  result.errors.push(mapper(issue2));
16329
16392
  continue;
@@ -16355,8 +16418,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
16355
16418
  }
16356
16419
  function toDotPath(_path) {
16357
16420
  const segs = [];
16358
- const path28 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
16359
- for (const seg of path28) {
16421
+ const path29 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
16422
+ for (const seg of path29) {
16360
16423
  if (typeof seg === "number")
16361
16424
  segs.push(`[${seg}]`);
16362
16425
  else if (typeof seg === "symbol")
@@ -29120,13 +29183,13 @@ function resolveRef(ref, ctx) {
29120
29183
  if (!ref.startsWith("#")) {
29121
29184
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
29122
29185
  }
29123
- const path28 = ref.slice(1).split("/").filter(Boolean);
29124
- if (path28.length === 0) {
29186
+ const path29 = ref.slice(1).split("/").filter(Boolean);
29187
+ if (path29.length === 0) {
29125
29188
  return ctx.rootSchema;
29126
29189
  }
29127
29190
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
29128
- if (path28[0] === defsKey) {
29129
- const key = path28[1];
29191
+ if (path29[0] === defsKey) {
29192
+ const key = path29[1];
29130
29193
  if (!key || !ctx.defs[key]) {
29131
29194
  throw new Error(`Reference not found: ${ref}`);
29132
29195
  }
@@ -32972,11 +33035,11 @@ var init_hosted_runtime_restore = __esm({
32972
33035
  // ../../oss/packages/daemon-core/src/commands/cli-manager.ts
32973
33036
  function isExplicitCommand(command) {
32974
33037
  const trimmed = command.trim();
32975
- return path12.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
33038
+ return path13.isAbsolute(trimmed) || trimmed.includes("/") || trimmed.includes("\\") || trimmed.startsWith("~");
32976
33039
  }
32977
33040
  function expandExecutable(command) {
32978
33041
  const trimmed = command.trim();
32979
- return trimmed.startsWith("~") ? path12.join(os14.homedir(), trimmed.slice(1)) : trimmed;
33042
+ return trimmed.startsWith("~") ? path13.join(os15.homedir(), trimmed.slice(1)) : trimmed;
32980
33043
  }
32981
33044
  function commandExists(command) {
32982
33045
  const trimmed = command.trim();
@@ -33113,12 +33176,12 @@ function resolveCliSessionBinding(provider, normalizedType, cliArgs, requestedRe
33113
33176
  launchMode: "new"
33114
33177
  };
33115
33178
  }
33116
- var os14, path12, crypto4, import_fs5, import_child_process6, chalkModule, chalkApi, DaemonCliManager;
33179
+ var os15, path13, crypto4, import_fs5, import_child_process6, chalkModule, chalkApi, DaemonCliManager;
33117
33180
  var init_cli_manager = __esm({
33118
33181
  "../../oss/packages/daemon-core/src/commands/cli-manager.ts"() {
33119
33182
  "use strict";
33120
- os14 = __toESM(require("os"));
33121
- path12 = __toESM(require("path"));
33183
+ os15 = __toESM(require("os"));
33184
+ path13 = __toESM(require("path"));
33122
33185
  crypto4 = __toESM(require("crypto"));
33123
33186
  import_fs5 = require("fs");
33124
33187
  import_child_process6 = require("child_process");
@@ -33281,7 +33344,7 @@ var init_cli_manager = __esm({
33281
33344
  async startSession(cliType, workingDir, cliArgs, initialModel, options) {
33282
33345
  const trimmed = (workingDir || "").trim();
33283
33346
  if (!trimmed) throw new Error("working directory required");
33284
- const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os14.homedir()) : path12.resolve(trimmed);
33347
+ const resolvedDir = trimmed.startsWith("~") ? trimmed.replace(/^~/, os15.homedir()) : path13.resolve(trimmed);
33285
33348
  const normalizedType = this.providerLoader.resolveAlias(cliType);
33286
33349
  const rawProvider = this.providerLoader.getByAlias(cliType);
33287
33350
  const provider = rawProvider ? this.providerLoader.resolve(normalizedType) || rawProvider : void 0;
@@ -33884,7 +33947,7 @@ var init_readdirp = __esm({
33884
33947
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
33885
33948
  const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
33886
33949
  if (wantBigintFsStats) {
33887
- this._stat = (path28) => statMethod(path28, { bigint: true });
33950
+ this._stat = (path29) => statMethod(path29, { bigint: true });
33888
33951
  } else {
33889
33952
  this._stat = statMethod;
33890
33953
  }
@@ -33909,8 +33972,8 @@ var init_readdirp = __esm({
33909
33972
  const par = this.parent;
33910
33973
  const fil = par && par.files;
33911
33974
  if (fil && fil.length > 0) {
33912
- const { path: path28, depth } = par;
33913
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path28));
33975
+ const { path: path29, depth } = par;
33976
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path29));
33914
33977
  const awaited = await Promise.all(slice);
33915
33978
  for (const entry of awaited) {
33916
33979
  if (!entry)
@@ -33950,20 +34013,20 @@ var init_readdirp = __esm({
33950
34013
  this.reading = false;
33951
34014
  }
33952
34015
  }
33953
- async _exploreDir(path28, depth) {
34016
+ async _exploreDir(path29, depth) {
33954
34017
  let files;
33955
34018
  try {
33956
- files = await (0, import_promises.readdir)(path28, this._rdOptions);
34019
+ files = await (0, import_promises.readdir)(path29, this._rdOptions);
33957
34020
  } catch (error48) {
33958
34021
  this._onError(error48);
33959
34022
  }
33960
- return { files, depth, path: path28 };
34023
+ return { files, depth, path: path29 };
33961
34024
  }
33962
- async _formatEntry(dirent, path28) {
34025
+ async _formatEntry(dirent, path29) {
33963
34026
  let entry;
33964
34027
  const basename9 = this._isDirent ? dirent.name : dirent;
33965
34028
  try {
33966
- const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path28, basename9));
34029
+ const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path29, basename9));
33967
34030
  entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename9 };
33968
34031
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
33969
34032
  } catch (err) {
@@ -34020,16 +34083,16 @@ var init_readdirp = __esm({
34020
34083
  });
34021
34084
 
34022
34085
  // ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
34023
- function createFsWatchInstance(path28, options, listener, errHandler, emitRaw) {
34086
+ function createFsWatchInstance(path29, options, listener, errHandler, emitRaw) {
34024
34087
  const handleEvent = (rawEvent, evPath) => {
34025
- listener(path28);
34026
- emitRaw(rawEvent, evPath, { watchedPath: path28 });
34027
- if (evPath && path28 !== evPath) {
34028
- fsWatchBroadcast(sp.resolve(path28, evPath), KEY_LISTENERS, sp.join(path28, evPath));
34088
+ listener(path29);
34089
+ emitRaw(rawEvent, evPath, { watchedPath: path29 });
34090
+ if (evPath && path29 !== evPath) {
34091
+ fsWatchBroadcast(sp.resolve(path29, evPath), KEY_LISTENERS, sp.join(path29, evPath));
34029
34092
  }
34030
34093
  };
34031
34094
  try {
34032
- return (0, import_node_fs.watch)(path28, {
34095
+ return (0, import_node_fs.watch)(path29, {
34033
34096
  persistent: options.persistent
34034
34097
  }, handleEvent);
34035
34098
  } catch (error48) {
@@ -34378,12 +34441,12 @@ var init_handler2 = __esm({
34378
34441
  listener(val1, val2, val3);
34379
34442
  });
34380
34443
  };
34381
- setFsWatchListener = (path28, fullPath, options, handlers) => {
34444
+ setFsWatchListener = (path29, fullPath, options, handlers) => {
34382
34445
  const { listener, errHandler, rawEmitter } = handlers;
34383
34446
  let cont = FsWatchInstances.get(fullPath);
34384
34447
  let watcher;
34385
34448
  if (!options.persistent) {
34386
- watcher = createFsWatchInstance(path28, options, listener, errHandler, rawEmitter);
34449
+ watcher = createFsWatchInstance(path29, options, listener, errHandler, rawEmitter);
34387
34450
  if (!watcher)
34388
34451
  return;
34389
34452
  return watcher.close.bind(watcher);
@@ -34394,7 +34457,7 @@ var init_handler2 = __esm({
34394
34457
  addAndConvert(cont, KEY_RAW, rawEmitter);
34395
34458
  } else {
34396
34459
  watcher = createFsWatchInstance(
34397
- path28,
34460
+ path29,
34398
34461
  options,
34399
34462
  fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
34400
34463
  errHandler,
@@ -34409,7 +34472,7 @@ var init_handler2 = __esm({
34409
34472
  cont.watcherUnusable = true;
34410
34473
  if (isWindows && error48.code === "EPERM") {
34411
34474
  try {
34412
- const fd = await (0, import_promises2.open)(path28, "r");
34475
+ const fd = await (0, import_promises2.open)(path29, "r");
34413
34476
  await fd.close();
34414
34477
  broadcastErr(error48);
34415
34478
  } catch (err) {
@@ -34440,7 +34503,7 @@ var init_handler2 = __esm({
34440
34503
  };
34441
34504
  };
34442
34505
  FsWatchFileInstances = /* @__PURE__ */ new Map();
34443
- setFsWatchFileListener = (path28, fullPath, options, handlers) => {
34506
+ setFsWatchFileListener = (path29, fullPath, options, handlers) => {
34444
34507
  const { listener, rawEmitter } = handlers;
34445
34508
  let cont = FsWatchFileInstances.get(fullPath);
34446
34509
  const copts = cont && cont.options;
@@ -34462,7 +34525,7 @@ var init_handler2 = __esm({
34462
34525
  });
34463
34526
  const currmtime = curr.mtimeMs;
34464
34527
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
34465
- foreach(cont.listeners, (listener2) => listener2(path28, curr));
34528
+ foreach(cont.listeners, (listener2) => listener2(path29, curr));
34466
34529
  }
34467
34530
  })
34468
34531
  };
@@ -34492,13 +34555,13 @@ var init_handler2 = __esm({
34492
34555
  * @param listener on fs change
34493
34556
  * @returns closer for the watcher instance
34494
34557
  */
34495
- _watchWithNodeFs(path28, listener) {
34558
+ _watchWithNodeFs(path29, listener) {
34496
34559
  const opts = this.fsw.options;
34497
- const directory = sp.dirname(path28);
34498
- const basename9 = sp.basename(path28);
34560
+ const directory = sp.dirname(path29);
34561
+ const basename9 = sp.basename(path29);
34499
34562
  const parent = this.fsw._getWatchedDir(directory);
34500
34563
  parent.add(basename9);
34501
- const absolutePath = sp.resolve(path28);
34564
+ const absolutePath = sp.resolve(path29);
34502
34565
  const options = {
34503
34566
  persistent: opts.persistent
34504
34567
  };
@@ -34508,12 +34571,12 @@ var init_handler2 = __esm({
34508
34571
  if (opts.usePolling) {
34509
34572
  const enableBin = opts.interval !== opts.binaryInterval;
34510
34573
  options.interval = enableBin && isBinaryPath(basename9) ? opts.binaryInterval : opts.interval;
34511
- closer = setFsWatchFileListener(path28, absolutePath, options, {
34574
+ closer = setFsWatchFileListener(path29, absolutePath, options, {
34512
34575
  listener,
34513
34576
  rawEmitter: this.fsw._emitRaw
34514
34577
  });
34515
34578
  } else {
34516
- closer = setFsWatchListener(path28, absolutePath, options, {
34579
+ closer = setFsWatchListener(path29, absolutePath, options, {
34517
34580
  listener,
34518
34581
  errHandler: this._boundHandleError,
34519
34582
  rawEmitter: this.fsw._emitRaw
@@ -34535,7 +34598,7 @@ var init_handler2 = __esm({
34535
34598
  let prevStats = stats;
34536
34599
  if (parent.has(basename9))
34537
34600
  return;
34538
- const listener = async (path28, newStats) => {
34601
+ const listener = async (path29, newStats) => {
34539
34602
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
34540
34603
  return;
34541
34604
  if (!newStats || newStats.mtimeMs === 0) {
@@ -34549,11 +34612,11 @@ var init_handler2 = __esm({
34549
34612
  this.fsw._emit(EV.CHANGE, file2, newStats2);
34550
34613
  }
34551
34614
  if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
34552
- this.fsw._closeFile(path28);
34615
+ this.fsw._closeFile(path29);
34553
34616
  prevStats = newStats2;
34554
34617
  const closer2 = this._watchWithNodeFs(file2, listener);
34555
34618
  if (closer2)
34556
- this.fsw._addPathCloser(path28, closer2);
34619
+ this.fsw._addPathCloser(path29, closer2);
34557
34620
  } else {
34558
34621
  prevStats = newStats2;
34559
34622
  }
@@ -34585,7 +34648,7 @@ var init_handler2 = __esm({
34585
34648
  * @param item basename of this item
34586
34649
  * @returns true if no more processing is needed for this entry.
34587
34650
  */
34588
- async _handleSymlink(entry, directory, path28, item) {
34651
+ async _handleSymlink(entry, directory, path29, item) {
34589
34652
  if (this.fsw.closed) {
34590
34653
  return;
34591
34654
  }
@@ -34595,7 +34658,7 @@ var init_handler2 = __esm({
34595
34658
  this.fsw._incrReadyCount();
34596
34659
  let linkPath;
34597
34660
  try {
34598
- linkPath = await (0, import_promises2.realpath)(path28);
34661
+ linkPath = await (0, import_promises2.realpath)(path29);
34599
34662
  } catch (e) {
34600
34663
  this.fsw._emitReady();
34601
34664
  return true;
@@ -34605,12 +34668,12 @@ var init_handler2 = __esm({
34605
34668
  if (dir.has(item)) {
34606
34669
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
34607
34670
  this.fsw._symlinkPaths.set(full, linkPath);
34608
- this.fsw._emit(EV.CHANGE, path28, entry.stats);
34671
+ this.fsw._emit(EV.CHANGE, path29, entry.stats);
34609
34672
  }
34610
34673
  } else {
34611
34674
  dir.add(item);
34612
34675
  this.fsw._symlinkPaths.set(full, linkPath);
34613
- this.fsw._emit(EV.ADD, path28, entry.stats);
34676
+ this.fsw._emit(EV.ADD, path29, entry.stats);
34614
34677
  }
34615
34678
  this.fsw._emitReady();
34616
34679
  return true;
@@ -34640,9 +34703,9 @@ var init_handler2 = __esm({
34640
34703
  return;
34641
34704
  }
34642
34705
  const item = entry.path;
34643
- let path28 = sp.join(directory, item);
34706
+ let path29 = sp.join(directory, item);
34644
34707
  current.add(item);
34645
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path28, item)) {
34708
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path29, item)) {
34646
34709
  return;
34647
34710
  }
34648
34711
  if (this.fsw.closed) {
@@ -34651,8 +34714,8 @@ var init_handler2 = __esm({
34651
34714
  }
34652
34715
  if (item === target || !target && !previous.has(item)) {
34653
34716
  this.fsw._incrReadyCount();
34654
- path28 = sp.join(dir, sp.relative(dir, path28));
34655
- this._addToNodeFs(path28, initialAdd, wh, depth + 1);
34717
+ path29 = sp.join(dir, sp.relative(dir, path29));
34718
+ this._addToNodeFs(path29, initialAdd, wh, depth + 1);
34656
34719
  }
34657
34720
  }).on(EV.ERROR, this._boundHandleError);
34658
34721
  return new Promise((resolve16, reject) => {
@@ -34721,13 +34784,13 @@ var init_handler2 = __esm({
34721
34784
  * @param depth Child path actually targeted for watch
34722
34785
  * @param target Child path actually targeted for watch
34723
34786
  */
34724
- async _addToNodeFs(path28, initialAdd, priorWh, depth, target) {
34787
+ async _addToNodeFs(path29, initialAdd, priorWh, depth, target) {
34725
34788
  const ready = this.fsw._emitReady;
34726
- if (this.fsw._isIgnored(path28) || this.fsw.closed) {
34789
+ if (this.fsw._isIgnored(path29) || this.fsw.closed) {
34727
34790
  ready();
34728
34791
  return false;
34729
34792
  }
34730
- const wh = this.fsw._getWatchHelpers(path28);
34793
+ const wh = this.fsw._getWatchHelpers(path29);
34731
34794
  if (priorWh) {
34732
34795
  wh.filterPath = (entry) => priorWh.filterPath(entry);
34733
34796
  wh.filterDir = (entry) => priorWh.filterDir(entry);
@@ -34743,8 +34806,8 @@ var init_handler2 = __esm({
34743
34806
  const follow = this.fsw.options.followSymlinks;
34744
34807
  let closer;
34745
34808
  if (stats.isDirectory()) {
34746
- const absPath = sp.resolve(path28);
34747
- const targetPath = follow ? await (0, import_promises2.realpath)(path28) : path28;
34809
+ const absPath = sp.resolve(path29);
34810
+ const targetPath = follow ? await (0, import_promises2.realpath)(path29) : path29;
34748
34811
  if (this.fsw.closed)
34749
34812
  return;
34750
34813
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -34754,29 +34817,29 @@ var init_handler2 = __esm({
34754
34817
  this.fsw._symlinkPaths.set(absPath, targetPath);
34755
34818
  }
34756
34819
  } else if (stats.isSymbolicLink()) {
34757
- const targetPath = follow ? await (0, import_promises2.realpath)(path28) : path28;
34820
+ const targetPath = follow ? await (0, import_promises2.realpath)(path29) : path29;
34758
34821
  if (this.fsw.closed)
34759
34822
  return;
34760
34823
  const parent = sp.dirname(wh.watchPath);
34761
34824
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
34762
34825
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
34763
- closer = await this._handleDir(parent, stats, initialAdd, depth, path28, wh, targetPath);
34826
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path29, wh, targetPath);
34764
34827
  if (this.fsw.closed)
34765
34828
  return;
34766
34829
  if (targetPath !== void 0) {
34767
- this.fsw._symlinkPaths.set(sp.resolve(path28), targetPath);
34830
+ this.fsw._symlinkPaths.set(sp.resolve(path29), targetPath);
34768
34831
  }
34769
34832
  } else {
34770
34833
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
34771
34834
  }
34772
34835
  ready();
34773
34836
  if (closer)
34774
- this.fsw._addPathCloser(path28, closer);
34837
+ this.fsw._addPathCloser(path29, closer);
34775
34838
  return false;
34776
34839
  } catch (error48) {
34777
34840
  if (this.fsw._handleError(error48)) {
34778
34841
  ready();
34779
- return path28;
34842
+ return path29;
34780
34843
  }
34781
34844
  }
34782
34845
  }
@@ -34811,24 +34874,24 @@ function createPattern(matcher) {
34811
34874
  }
34812
34875
  return () => false;
34813
34876
  }
34814
- function normalizePath(path28) {
34815
- if (typeof path28 !== "string")
34877
+ function normalizePath(path29) {
34878
+ if (typeof path29 !== "string")
34816
34879
  throw new Error("string expected");
34817
- path28 = sp2.normalize(path28);
34818
- path28 = path28.replace(/\\/g, "/");
34880
+ path29 = sp2.normalize(path29);
34881
+ path29 = path29.replace(/\\/g, "/");
34819
34882
  let prepend = false;
34820
- if (path28.startsWith("//"))
34883
+ if (path29.startsWith("//"))
34821
34884
  prepend = true;
34822
- path28 = path28.replace(DOUBLE_SLASH_RE, "/");
34885
+ path29 = path29.replace(DOUBLE_SLASH_RE, "/");
34823
34886
  if (prepend)
34824
- path28 = "/" + path28;
34825
- return path28;
34887
+ path29 = "/" + path29;
34888
+ return path29;
34826
34889
  }
34827
34890
  function matchPatterns(patterns, testString, stats) {
34828
- const path28 = normalizePath(testString);
34891
+ const path29 = normalizePath(testString);
34829
34892
  for (let index = 0; index < patterns.length; index++) {
34830
34893
  const pattern = patterns[index];
34831
- if (pattern(path28, stats)) {
34894
+ if (pattern(path29, stats)) {
34832
34895
  return true;
34833
34896
  }
34834
34897
  }
@@ -34891,19 +34954,19 @@ var init_chokidar = __esm({
34891
34954
  }
34892
34955
  return str;
34893
34956
  };
34894
- normalizePathToUnix = (path28) => toUnix(sp2.normalize(toUnix(path28)));
34895
- normalizeIgnored = (cwd = "") => (path28) => {
34896
- if (typeof path28 === "string") {
34897
- return normalizePathToUnix(sp2.isAbsolute(path28) ? path28 : sp2.join(cwd, path28));
34957
+ normalizePathToUnix = (path29) => toUnix(sp2.normalize(toUnix(path29)));
34958
+ normalizeIgnored = (cwd = "") => (path29) => {
34959
+ if (typeof path29 === "string") {
34960
+ return normalizePathToUnix(sp2.isAbsolute(path29) ? path29 : sp2.join(cwd, path29));
34898
34961
  } else {
34899
- return path28;
34962
+ return path29;
34900
34963
  }
34901
34964
  };
34902
- getAbsolutePath = (path28, cwd) => {
34903
- if (sp2.isAbsolute(path28)) {
34904
- return path28;
34965
+ getAbsolutePath = (path29, cwd) => {
34966
+ if (sp2.isAbsolute(path29)) {
34967
+ return path29;
34905
34968
  }
34906
- return sp2.join(cwd, path28);
34969
+ return sp2.join(cwd, path29);
34907
34970
  };
34908
34971
  EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
34909
34972
  DirEntry = class {
@@ -34968,10 +35031,10 @@ var init_chokidar = __esm({
34968
35031
  dirParts;
34969
35032
  followSymlinks;
34970
35033
  statMethod;
34971
- constructor(path28, follow, fsw) {
35034
+ constructor(path29, follow, fsw) {
34972
35035
  this.fsw = fsw;
34973
- const watchPath = path28;
34974
- this.path = path28 = path28.replace(REPLACER_RE, "");
35036
+ const watchPath = path29;
35037
+ this.path = path29 = path29.replace(REPLACER_RE, "");
34975
35038
  this.watchPath = watchPath;
34976
35039
  this.fullWatchPath = sp2.resolve(watchPath);
34977
35040
  this.dirParts = [];
@@ -35111,20 +35174,20 @@ var init_chokidar = __esm({
35111
35174
  this._closePromise = void 0;
35112
35175
  let paths = unifyPaths(paths_);
35113
35176
  if (cwd) {
35114
- paths = paths.map((path28) => {
35115
- const absPath = getAbsolutePath(path28, cwd);
35177
+ paths = paths.map((path29) => {
35178
+ const absPath = getAbsolutePath(path29, cwd);
35116
35179
  return absPath;
35117
35180
  });
35118
35181
  }
35119
- paths.forEach((path28) => {
35120
- this._removeIgnoredPath(path28);
35182
+ paths.forEach((path29) => {
35183
+ this._removeIgnoredPath(path29);
35121
35184
  });
35122
35185
  this._userIgnored = void 0;
35123
35186
  if (!this._readyCount)
35124
35187
  this._readyCount = 0;
35125
35188
  this._readyCount += paths.length;
35126
- Promise.all(paths.map(async (path28) => {
35127
- const res = await this._nodeFsHandler._addToNodeFs(path28, !_internal, void 0, 0, _origAdd);
35189
+ Promise.all(paths.map(async (path29) => {
35190
+ const res = await this._nodeFsHandler._addToNodeFs(path29, !_internal, void 0, 0, _origAdd);
35128
35191
  if (res)
35129
35192
  this._emitReady();
35130
35193
  return res;
@@ -35146,17 +35209,17 @@ var init_chokidar = __esm({
35146
35209
  return this;
35147
35210
  const paths = unifyPaths(paths_);
35148
35211
  const { cwd } = this.options;
35149
- paths.forEach((path28) => {
35150
- if (!sp2.isAbsolute(path28) && !this._closers.has(path28)) {
35212
+ paths.forEach((path29) => {
35213
+ if (!sp2.isAbsolute(path29) && !this._closers.has(path29)) {
35151
35214
  if (cwd)
35152
- path28 = sp2.join(cwd, path28);
35153
- path28 = sp2.resolve(path28);
35215
+ path29 = sp2.join(cwd, path29);
35216
+ path29 = sp2.resolve(path29);
35154
35217
  }
35155
- this._closePath(path28);
35156
- this._addIgnoredPath(path28);
35157
- if (this._watched.has(path28)) {
35218
+ this._closePath(path29);
35219
+ this._addIgnoredPath(path29);
35220
+ if (this._watched.has(path29)) {
35158
35221
  this._addIgnoredPath({
35159
- path: path28,
35222
+ path: path29,
35160
35223
  recursive: true
35161
35224
  });
35162
35225
  }
@@ -35220,38 +35283,38 @@ var init_chokidar = __esm({
35220
35283
  * @param stats arguments to be passed with event
35221
35284
  * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
35222
35285
  */
35223
- async _emit(event, path28, stats) {
35286
+ async _emit(event, path29, stats) {
35224
35287
  if (this.closed)
35225
35288
  return;
35226
35289
  const opts = this.options;
35227
35290
  if (isWindows)
35228
- path28 = sp2.normalize(path28);
35291
+ path29 = sp2.normalize(path29);
35229
35292
  if (opts.cwd)
35230
- path28 = sp2.relative(opts.cwd, path28);
35231
- const args = [path28];
35293
+ path29 = sp2.relative(opts.cwd, path29);
35294
+ const args = [path29];
35232
35295
  if (stats != null)
35233
35296
  args.push(stats);
35234
35297
  const awf = opts.awaitWriteFinish;
35235
35298
  let pw;
35236
- if (awf && (pw = this._pendingWrites.get(path28))) {
35299
+ if (awf && (pw = this._pendingWrites.get(path29))) {
35237
35300
  pw.lastChange = /* @__PURE__ */ new Date();
35238
35301
  return this;
35239
35302
  }
35240
35303
  if (opts.atomic) {
35241
35304
  if (event === EVENTS.UNLINK) {
35242
- this._pendingUnlinks.set(path28, [event, ...args]);
35305
+ this._pendingUnlinks.set(path29, [event, ...args]);
35243
35306
  setTimeout(() => {
35244
- this._pendingUnlinks.forEach((entry, path29) => {
35307
+ this._pendingUnlinks.forEach((entry, path30) => {
35245
35308
  this.emit(...entry);
35246
35309
  this.emit(EVENTS.ALL, ...entry);
35247
- this._pendingUnlinks.delete(path29);
35310
+ this._pendingUnlinks.delete(path30);
35248
35311
  });
35249
35312
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
35250
35313
  return this;
35251
35314
  }
35252
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path28)) {
35315
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path29)) {
35253
35316
  event = EVENTS.CHANGE;
35254
- this._pendingUnlinks.delete(path28);
35317
+ this._pendingUnlinks.delete(path29);
35255
35318
  }
35256
35319
  }
35257
35320
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -35269,16 +35332,16 @@ var init_chokidar = __esm({
35269
35332
  this.emitWithAll(event, args);
35270
35333
  }
35271
35334
  };
35272
- this._awaitWriteFinish(path28, awf.stabilityThreshold, event, awfEmit);
35335
+ this._awaitWriteFinish(path29, awf.stabilityThreshold, event, awfEmit);
35273
35336
  return this;
35274
35337
  }
35275
35338
  if (event === EVENTS.CHANGE) {
35276
- const isThrottled = !this._throttle(EVENTS.CHANGE, path28, 50);
35339
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path29, 50);
35277
35340
  if (isThrottled)
35278
35341
  return this;
35279
35342
  }
35280
35343
  if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
35281
- const fullPath = opts.cwd ? sp2.join(opts.cwd, path28) : path28;
35344
+ const fullPath = opts.cwd ? sp2.join(opts.cwd, path29) : path29;
35282
35345
  let stats2;
35283
35346
  try {
35284
35347
  stats2 = await (0, import_promises3.stat)(fullPath);
@@ -35309,23 +35372,23 @@ var init_chokidar = __esm({
35309
35372
  * @param timeout duration of time to suppress duplicate actions
35310
35373
  * @returns tracking object or false if action should be suppressed
35311
35374
  */
35312
- _throttle(actionType, path28, timeout) {
35375
+ _throttle(actionType, path29, timeout) {
35313
35376
  if (!this._throttled.has(actionType)) {
35314
35377
  this._throttled.set(actionType, /* @__PURE__ */ new Map());
35315
35378
  }
35316
35379
  const action = this._throttled.get(actionType);
35317
35380
  if (!action)
35318
35381
  throw new Error("invalid throttle");
35319
- const actionPath = action.get(path28);
35382
+ const actionPath = action.get(path29);
35320
35383
  if (actionPath) {
35321
35384
  actionPath.count++;
35322
35385
  return false;
35323
35386
  }
35324
35387
  let timeoutObject;
35325
35388
  const clear = () => {
35326
- const item = action.get(path28);
35389
+ const item = action.get(path29);
35327
35390
  const count = item ? item.count : 0;
35328
- action.delete(path28);
35391
+ action.delete(path29);
35329
35392
  clearTimeout(timeoutObject);
35330
35393
  if (item)
35331
35394
  clearTimeout(item.timeoutObject);
@@ -35333,7 +35396,7 @@ var init_chokidar = __esm({
35333
35396
  };
35334
35397
  timeoutObject = setTimeout(clear, timeout);
35335
35398
  const thr = { timeoutObject, clear, count: 0 };
35336
- action.set(path28, thr);
35399
+ action.set(path29, thr);
35337
35400
  return thr;
35338
35401
  }
35339
35402
  _incrReadyCount() {
@@ -35347,44 +35410,44 @@ var init_chokidar = __esm({
35347
35410
  * @param event
35348
35411
  * @param awfEmit Callback to be called when ready for event to be emitted.
35349
35412
  */
35350
- _awaitWriteFinish(path28, threshold, event, awfEmit) {
35413
+ _awaitWriteFinish(path29, threshold, event, awfEmit) {
35351
35414
  const awf = this.options.awaitWriteFinish;
35352
35415
  if (typeof awf !== "object")
35353
35416
  return;
35354
35417
  const pollInterval = awf.pollInterval;
35355
35418
  let timeoutHandler;
35356
- let fullPath = path28;
35357
- if (this.options.cwd && !sp2.isAbsolute(path28)) {
35358
- fullPath = sp2.join(this.options.cwd, path28);
35419
+ let fullPath = path29;
35420
+ if (this.options.cwd && !sp2.isAbsolute(path29)) {
35421
+ fullPath = sp2.join(this.options.cwd, path29);
35359
35422
  }
35360
35423
  const now = /* @__PURE__ */ new Date();
35361
35424
  const writes = this._pendingWrites;
35362
35425
  function awaitWriteFinishFn(prevStat) {
35363
35426
  (0, import_node_fs2.stat)(fullPath, (err, curStat) => {
35364
- if (err || !writes.has(path28)) {
35427
+ if (err || !writes.has(path29)) {
35365
35428
  if (err && err.code !== "ENOENT")
35366
35429
  awfEmit(err);
35367
35430
  return;
35368
35431
  }
35369
35432
  const now2 = Number(/* @__PURE__ */ new Date());
35370
35433
  if (prevStat && curStat.size !== prevStat.size) {
35371
- writes.get(path28).lastChange = now2;
35434
+ writes.get(path29).lastChange = now2;
35372
35435
  }
35373
- const pw = writes.get(path28);
35436
+ const pw = writes.get(path29);
35374
35437
  const df = now2 - pw.lastChange;
35375
35438
  if (df >= threshold) {
35376
- writes.delete(path28);
35439
+ writes.delete(path29);
35377
35440
  awfEmit(void 0, curStat);
35378
35441
  } else {
35379
35442
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
35380
35443
  }
35381
35444
  });
35382
35445
  }
35383
- if (!writes.has(path28)) {
35384
- writes.set(path28, {
35446
+ if (!writes.has(path29)) {
35447
+ writes.set(path29, {
35385
35448
  lastChange: now,
35386
35449
  cancelWait: () => {
35387
- writes.delete(path28);
35450
+ writes.delete(path29);
35388
35451
  clearTimeout(timeoutHandler);
35389
35452
  return event;
35390
35453
  }
@@ -35395,8 +35458,8 @@ var init_chokidar = __esm({
35395
35458
  /**
35396
35459
  * Determines whether user has asked to ignore this path.
35397
35460
  */
35398
- _isIgnored(path28, stats) {
35399
- if (this.options.atomic && DOT_RE.test(path28))
35461
+ _isIgnored(path29, stats) {
35462
+ if (this.options.atomic && DOT_RE.test(path29))
35400
35463
  return true;
35401
35464
  if (!this._userIgnored) {
35402
35465
  const { cwd } = this.options;
@@ -35406,17 +35469,17 @@ var init_chokidar = __esm({
35406
35469
  const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
35407
35470
  this._userIgnored = anymatch(list, void 0);
35408
35471
  }
35409
- return this._userIgnored(path28, stats);
35472
+ return this._userIgnored(path29, stats);
35410
35473
  }
35411
- _isntIgnored(path28, stat4) {
35412
- return !this._isIgnored(path28, stat4);
35474
+ _isntIgnored(path29, stat4) {
35475
+ return !this._isIgnored(path29, stat4);
35413
35476
  }
35414
35477
  /**
35415
35478
  * Provides a set of common helpers and properties relating to symlink handling.
35416
35479
  * @param path file or directory pattern being watched
35417
35480
  */
35418
- _getWatchHelpers(path28) {
35419
- return new WatchHelper(path28, this.options.followSymlinks, this);
35481
+ _getWatchHelpers(path29) {
35482
+ return new WatchHelper(path29, this.options.followSymlinks, this);
35420
35483
  }
35421
35484
  // Directory helpers
35422
35485
  // -----------------
@@ -35448,63 +35511,63 @@ var init_chokidar = __esm({
35448
35511
  * @param item base path of item/directory
35449
35512
  */
35450
35513
  _remove(directory, item, isDirectory) {
35451
- const path28 = sp2.join(directory, item);
35452
- const fullPath = sp2.resolve(path28);
35453
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path28) || this._watched.has(fullPath);
35454
- if (!this._throttle("remove", path28, 100))
35514
+ const path29 = sp2.join(directory, item);
35515
+ const fullPath = sp2.resolve(path29);
35516
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path29) || this._watched.has(fullPath);
35517
+ if (!this._throttle("remove", path29, 100))
35455
35518
  return;
35456
35519
  if (!isDirectory && this._watched.size === 1) {
35457
35520
  this.add(directory, item, true);
35458
35521
  }
35459
- const wp = this._getWatchedDir(path28);
35522
+ const wp = this._getWatchedDir(path29);
35460
35523
  const nestedDirectoryChildren = wp.getChildren();
35461
- nestedDirectoryChildren.forEach((nested) => this._remove(path28, nested));
35524
+ nestedDirectoryChildren.forEach((nested) => this._remove(path29, nested));
35462
35525
  const parent = this._getWatchedDir(directory);
35463
35526
  const wasTracked = parent.has(item);
35464
35527
  parent.remove(item);
35465
35528
  if (this._symlinkPaths.has(fullPath)) {
35466
35529
  this._symlinkPaths.delete(fullPath);
35467
35530
  }
35468
- let relPath = path28;
35531
+ let relPath = path29;
35469
35532
  if (this.options.cwd)
35470
- relPath = sp2.relative(this.options.cwd, path28);
35533
+ relPath = sp2.relative(this.options.cwd, path29);
35471
35534
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
35472
35535
  const event = this._pendingWrites.get(relPath).cancelWait();
35473
35536
  if (event === EVENTS.ADD)
35474
35537
  return;
35475
35538
  }
35476
- this._watched.delete(path28);
35539
+ this._watched.delete(path29);
35477
35540
  this._watched.delete(fullPath);
35478
35541
  const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
35479
- if (wasTracked && !this._isIgnored(path28))
35480
- this._emit(eventName, path28);
35481
- this._closePath(path28);
35542
+ if (wasTracked && !this._isIgnored(path29))
35543
+ this._emit(eventName, path29);
35544
+ this._closePath(path29);
35482
35545
  }
35483
35546
  /**
35484
35547
  * Closes all watchers for a path
35485
35548
  */
35486
- _closePath(path28) {
35487
- this._closeFile(path28);
35488
- const dir = sp2.dirname(path28);
35489
- this._getWatchedDir(dir).remove(sp2.basename(path28));
35549
+ _closePath(path29) {
35550
+ this._closeFile(path29);
35551
+ const dir = sp2.dirname(path29);
35552
+ this._getWatchedDir(dir).remove(sp2.basename(path29));
35490
35553
  }
35491
35554
  /**
35492
35555
  * Closes only file-specific watchers
35493
35556
  */
35494
- _closeFile(path28) {
35495
- const closers = this._closers.get(path28);
35557
+ _closeFile(path29) {
35558
+ const closers = this._closers.get(path29);
35496
35559
  if (!closers)
35497
35560
  return;
35498
35561
  closers.forEach((closer) => closer());
35499
- this._closers.delete(path28);
35562
+ this._closers.delete(path29);
35500
35563
  }
35501
- _addPathCloser(path28, closer) {
35564
+ _addPathCloser(path29, closer) {
35502
35565
  if (!closer)
35503
35566
  return;
35504
- let list = this._closers.get(path28);
35567
+ let list = this._closers.get(path29);
35505
35568
  if (!list) {
35506
35569
  list = [];
35507
- this._closers.set(path28, list);
35570
+ this._closers.set(path29, list);
35508
35571
  }
35509
35572
  list.push(closer);
35510
35573
  }
@@ -35765,13 +35828,13 @@ var init_provider_schema = __esm({
35765
35828
  });
35766
35829
 
35767
35830
  // ../../oss/packages/daemon-core/src/providers/provider-loader.ts
35768
- var fs6, path13, os15, ProviderLoader;
35831
+ var fs7, path14, os16, ProviderLoader;
35769
35832
  var init_provider_loader = __esm({
35770
35833
  "../../oss/packages/daemon-core/src/providers/provider-loader.ts"() {
35771
35834
  "use strict";
35772
- fs6 = __toESM(require("fs"));
35773
- path13 = __toESM(require("path"));
35774
- os15 = __toESM(require("os"));
35835
+ fs7 = __toESM(require("fs"));
35836
+ path14 = __toESM(require("path"));
35837
+ os16 = __toESM(require("os"));
35775
35838
  init_chokidar();
35776
35839
  init_ide_detector();
35777
35840
  init_logger();
@@ -35805,9 +35868,9 @@ var init_provider_loader = __esm({
35805
35868
  static siblingStderrLogged = /* @__PURE__ */ new Set();
35806
35869
  static looksLikeProviderRoot(candidate) {
35807
35870
  try {
35808
- if (!fs6.existsSync(candidate) || !fs6.statSync(candidate).isDirectory()) return false;
35871
+ if (!fs7.existsSync(candidate) || !fs7.statSync(candidate).isDirectory()) return false;
35809
35872
  return ["ide", "extension", "cli", "acp"].some(
35810
- (category) => fs6.existsSync(path13.join(candidate, category))
35873
+ (category) => fs7.existsSync(path14.join(candidate, category))
35811
35874
  );
35812
35875
  } catch {
35813
35876
  return false;
@@ -35815,20 +35878,20 @@ var init_provider_loader = __esm({
35815
35878
  }
35816
35879
  static hasProviderRootMarker(candidate) {
35817
35880
  try {
35818
- return fs6.existsSync(path13.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
35881
+ return fs7.existsSync(path14.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
35819
35882
  } catch {
35820
35883
  return false;
35821
35884
  }
35822
35885
  }
35823
35886
  detectDefaultUserDir() {
35824
- const fallback2 = path13.join(os15.homedir(), ".adhdev", "providers");
35887
+ const fallback2 = path14.join(os16.homedir(), ".adhdev", "providers");
35825
35888
  const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
35826
35889
  const visited = /* @__PURE__ */ new Set();
35827
35890
  for (const start of this.probeStarts) {
35828
- let current = path13.resolve(start);
35891
+ let current = path14.resolve(start);
35829
35892
  while (!visited.has(current)) {
35830
35893
  visited.add(current);
35831
- const siblingCandidate = path13.join(path13.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
35894
+ const siblingCandidate = path14.join(path14.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
35832
35895
  if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
35833
35896
  const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
35834
35897
  if (envOptIn || hasMarker) {
@@ -35850,7 +35913,7 @@ var init_provider_loader = __esm({
35850
35913
  return { path: siblingCandidate, source };
35851
35914
  }
35852
35915
  }
35853
- const parent = path13.dirname(current);
35916
+ const parent = path14.dirname(current);
35854
35917
  if (parent === current) break;
35855
35918
  current = parent;
35856
35919
  }
@@ -35860,11 +35923,11 @@ var init_provider_loader = __esm({
35860
35923
  constructor(options) {
35861
35924
  this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
35862
35925
  this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
35863
- this.defaultProvidersDir = path13.join(os15.homedir(), ".adhdev", "providers");
35926
+ this.defaultProvidersDir = path14.join(os16.homedir(), ".adhdev", "providers");
35864
35927
  const detected = this.detectDefaultUserDir();
35865
35928
  this.userDir = detected.path;
35866
35929
  this.userDirSource = detected.source;
35867
- this.upstreamDir = path13.join(this.defaultProvidersDir, ".upstream");
35930
+ this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
35868
35931
  this.disableUpstream = false;
35869
35932
  this.applySourceConfig({
35870
35933
  userDir: options?.userDir,
@@ -35923,7 +35986,7 @@ var init_provider_loader = __esm({
35923
35986
  this.userDir = detected.path;
35924
35987
  this.userDirSource = detected.source;
35925
35988
  }
35926
- this.upstreamDir = path13.join(this.defaultProvidersDir, ".upstream");
35989
+ this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
35927
35990
  this.disableUpstream = this.sourceMode === "no-upstream";
35928
35991
  if (this.explicitProviderDir) {
35929
35992
  this.log(`Config 'providerDir' applied: ${this.userDir}`);
@@ -35937,7 +36000,7 @@ var init_provider_loader = __esm({
35937
36000
  * Canonical provider directory shape for a given root.
35938
36001
  */
35939
36002
  getProviderDir(root, category, type) {
35940
- return path13.join(root, category, type);
36003
+ return path14.join(root, category, type);
35941
36004
  }
35942
36005
  /**
35943
36006
  * Canonical user override directory for a provider.
@@ -35964,7 +36027,7 @@ var init_provider_loader = __esm({
35964
36027
  resolveProviderFile(type, ...segments) {
35965
36028
  const dir = this.findProviderDirInternal(type);
35966
36029
  if (!dir) return null;
35967
- return path13.join(dir, ...segments);
36030
+ return path14.join(dir, ...segments);
35968
36031
  }
35969
36032
  /**
35970
36033
  * Load all providers (3-tier priority)
@@ -35977,7 +36040,7 @@ var init_provider_loader = __esm({
35977
36040
  this.providers.clear();
35978
36041
  this.providerAvailability.clear();
35979
36042
  let upstreamCount = 0;
35980
- if (!this.disableUpstream && fs6.existsSync(this.upstreamDir)) {
36043
+ if (!this.disableUpstream && fs7.existsSync(this.upstreamDir)) {
35981
36044
  upstreamCount = this.loadDir(this.upstreamDir);
35982
36045
  if (upstreamCount > 0) {
35983
36046
  this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
@@ -35985,7 +36048,7 @@ var init_provider_loader = __esm({
35985
36048
  } else if (this.disableUpstream) {
35986
36049
  this.log("Upstream loading disabled (sourceMode=no-upstream)");
35987
36050
  }
35988
- if (fs6.existsSync(this.userDir)) {
36051
+ if (fs7.existsSync(this.userDir)) {
35989
36052
  const userCount = this.loadDir(this.userDir, [".upstream"]);
35990
36053
  if (userCount > 0) {
35991
36054
  this.log(`Loaded ${userCount} user custom providers (never auto-updated)`);
@@ -36000,10 +36063,10 @@ var init_provider_loader = __esm({
36000
36063
  * Check if upstream directory exists and has providers.
36001
36064
  */
36002
36065
  hasUpstream() {
36003
- if (!fs6.existsSync(this.upstreamDir)) return false;
36066
+ if (!fs7.existsSync(this.upstreamDir)) return false;
36004
36067
  try {
36005
- return fs6.readdirSync(this.upstreamDir).some(
36006
- (d) => fs6.statSync(path13.join(this.upstreamDir, d)).isDirectory()
36068
+ return fs7.readdirSync(this.upstreamDir).some(
36069
+ (d) => fs7.statSync(path14.join(this.upstreamDir, d)).isDirectory()
36007
36070
  );
36008
36071
  } catch {
36009
36072
  return false;
@@ -36500,8 +36563,8 @@ var init_provider_loader = __esm({
36500
36563
  resolved._resolvedScriptDir = entry.scriptDir;
36501
36564
  resolved._resolvedScriptsSource = `compatibility:${entry.ideVersion}`;
36502
36565
  if (providerDir) {
36503
- const fullDir = path13.join(providerDir, entry.scriptDir);
36504
- resolved._resolvedScriptsPath = fs6.existsSync(path13.join(fullDir, "scripts.js")) ? path13.join(fullDir, "scripts.js") : fullDir;
36566
+ const fullDir = path14.join(providerDir, entry.scriptDir);
36567
+ resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
36505
36568
  }
36506
36569
  matched = true;
36507
36570
  }
@@ -36516,8 +36579,8 @@ var init_provider_loader = __esm({
36516
36579
  resolved._resolvedScriptDir = base.defaultScriptDir;
36517
36580
  resolved._resolvedScriptsSource = "defaultScriptDir:version_miss";
36518
36581
  if (providerDir) {
36519
- const fullDir = path13.join(providerDir, base.defaultScriptDir);
36520
- resolved._resolvedScriptsPath = fs6.existsSync(path13.join(fullDir, "scripts.js")) ? path13.join(fullDir, "scripts.js") : fullDir;
36582
+ const fullDir = path14.join(providerDir, base.defaultScriptDir);
36583
+ resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
36521
36584
  }
36522
36585
  }
36523
36586
  resolved._versionWarning = `Version ${currentVersion} not in compatibility matrix. Using default scripts.`;
@@ -36534,8 +36597,8 @@ var init_provider_loader = __esm({
36534
36597
  resolved._resolvedScriptDir = dirOverride;
36535
36598
  resolved._resolvedScriptsSource = `versions:${range}`;
36536
36599
  if (providerDir) {
36537
- const fullDir = path13.join(providerDir, dirOverride);
36538
- resolved._resolvedScriptsPath = fs6.existsSync(path13.join(fullDir, "scripts.js")) ? path13.join(fullDir, "scripts.js") : fullDir;
36600
+ const fullDir = path14.join(providerDir, dirOverride);
36601
+ resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
36539
36602
  }
36540
36603
  }
36541
36604
  } else if (override.scripts) {
@@ -36551,8 +36614,8 @@ var init_provider_loader = __esm({
36551
36614
  resolved._resolvedScriptDir = base.defaultScriptDir;
36552
36615
  resolved._resolvedScriptsSource = "defaultScriptDir:no_version";
36553
36616
  if (providerDir) {
36554
- const fullDir = path13.join(providerDir, base.defaultScriptDir);
36555
- resolved._resolvedScriptsPath = fs6.existsSync(path13.join(fullDir, "scripts.js")) ? path13.join(fullDir, "scripts.js") : fullDir;
36617
+ const fullDir = path14.join(providerDir, base.defaultScriptDir);
36618
+ resolved._resolvedScriptsPath = fs7.existsSync(path14.join(fullDir, "scripts.js")) ? path14.join(fullDir, "scripts.js") : fullDir;
36556
36619
  }
36557
36620
  }
36558
36621
  }
@@ -36584,15 +36647,15 @@ var init_provider_loader = __esm({
36584
36647
  this.log(` [loadScriptsFromDir] ${type}: providerDir not found`);
36585
36648
  return null;
36586
36649
  }
36587
- const dir = path13.join(providerDir, scriptDir);
36588
- if (!fs6.existsSync(dir)) {
36650
+ const dir = path14.join(providerDir, scriptDir);
36651
+ if (!fs7.existsSync(dir)) {
36589
36652
  this.log(` [loadScriptsFromDir] ${type}: dir not found: ${dir}`);
36590
36653
  return null;
36591
36654
  }
36592
36655
  const cached2 = this.scriptsCache.get(dir);
36593
36656
  if (cached2) return cached2;
36594
- const scriptsJs = path13.join(dir, "scripts.js");
36595
- if (fs6.existsSync(scriptsJs)) {
36657
+ const scriptsJs = path14.join(dir, "scripts.js");
36658
+ if (fs7.existsSync(scriptsJs)) {
36596
36659
  try {
36597
36660
  delete require.cache[require.resolve(scriptsJs)];
36598
36661
  const loaded = require(scriptsJs);
@@ -36613,9 +36676,9 @@ var init_provider_loader = __esm({
36613
36676
  watch() {
36614
36677
  this.stopWatch();
36615
36678
  const watchDir = (dir) => {
36616
- if (!fs6.existsSync(dir)) {
36679
+ if (!fs7.existsSync(dir)) {
36617
36680
  try {
36618
- fs6.mkdirSync(dir, { recursive: true });
36681
+ fs7.mkdirSync(dir, { recursive: true });
36619
36682
  } catch {
36620
36683
  return;
36621
36684
  }
@@ -36633,7 +36696,7 @@ var init_provider_loader = __esm({
36633
36696
  return;
36634
36697
  }
36635
36698
  if (filePath.endsWith(".js") || filePath.endsWith(".json")) {
36636
- this.log(`File changed: ${path13.basename(filePath)}, reloading...`);
36699
+ this.log(`File changed: ${path14.basename(filePath)}, reloading...`);
36637
36700
  this.reload();
36638
36701
  }
36639
36702
  };
@@ -36688,12 +36751,12 @@ var init_provider_loader = __esm({
36688
36751
  }
36689
36752
  const https = require("https");
36690
36753
  const { execSync: execSync7 } = require("child_process");
36691
- const metaPath = path13.join(this.upstreamDir, _ProviderLoader.META_FILE);
36754
+ const metaPath = path14.join(this.upstreamDir, _ProviderLoader.META_FILE);
36692
36755
  let prevEtag = "";
36693
36756
  let prevTimestamp = 0;
36694
36757
  try {
36695
- if (fs6.existsSync(metaPath)) {
36696
- const meta3 = JSON.parse(fs6.readFileSync(metaPath, "utf-8"));
36758
+ if (fs7.existsSync(metaPath)) {
36759
+ const meta3 = JSON.parse(fs7.readFileSync(metaPath, "utf-8"));
36697
36760
  prevEtag = meta3.etag || "";
36698
36761
  prevTimestamp = meta3.timestamp || 0;
36699
36762
  }
@@ -36748,39 +36811,39 @@ var init_provider_loader = __esm({
36748
36811
  return { updated: false };
36749
36812
  }
36750
36813
  this.log("Downloading latest providers from GitHub...");
36751
- const tmpTar = path13.join(os15.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
36752
- const tmpExtract = path13.join(os15.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
36814
+ const tmpTar = path14.join(os16.tmpdir(), `adhdev-providers-${Date.now()}.tar.gz`);
36815
+ const tmpExtract = path14.join(os16.tmpdir(), `adhdev-providers-extract-${Date.now()}`);
36753
36816
  await this.downloadFile(_ProviderLoader.GITHUB_TARBALL_URL, tmpTar);
36754
- fs6.mkdirSync(tmpExtract, { recursive: true });
36817
+ fs7.mkdirSync(tmpExtract, { recursive: true });
36755
36818
  execSync7(`tar -xzf "${tmpTar}" -C "${tmpExtract}"`, { timeout: 3e4 });
36756
- const extracted = fs6.readdirSync(tmpExtract);
36819
+ const extracted = fs7.readdirSync(tmpExtract);
36757
36820
  const rootDir = extracted.find(
36758
- (d) => fs6.statSync(path13.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
36821
+ (d) => fs7.statSync(path14.join(tmpExtract, d)).isDirectory() && d.startsWith("adhdev-providers")
36759
36822
  );
36760
36823
  if (!rootDir) throw new Error("Unexpected tarball structure");
36761
- const sourceDir = path13.join(tmpExtract, rootDir);
36824
+ const sourceDir = path14.join(tmpExtract, rootDir);
36762
36825
  const backupDir = this.upstreamDir + ".bak";
36763
- if (fs6.existsSync(this.upstreamDir)) {
36764
- if (fs6.existsSync(backupDir)) fs6.rmSync(backupDir, { recursive: true, force: true });
36765
- fs6.renameSync(this.upstreamDir, backupDir);
36826
+ if (fs7.existsSync(this.upstreamDir)) {
36827
+ if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
36828
+ fs7.renameSync(this.upstreamDir, backupDir);
36766
36829
  }
36767
36830
  try {
36768
36831
  this.copyDirRecursive(sourceDir, this.upstreamDir);
36769
36832
  this.writeMeta(metaPath, etag || `ts-${Date.now()}`, Date.now());
36770
- if (fs6.existsSync(backupDir)) fs6.rmSync(backupDir, { recursive: true, force: true });
36833
+ if (fs7.existsSync(backupDir)) fs7.rmSync(backupDir, { recursive: true, force: true });
36771
36834
  } catch (e) {
36772
- if (fs6.existsSync(backupDir)) {
36773
- if (fs6.existsSync(this.upstreamDir)) fs6.rmSync(this.upstreamDir, { recursive: true, force: true });
36774
- fs6.renameSync(backupDir, this.upstreamDir);
36835
+ if (fs7.existsSync(backupDir)) {
36836
+ if (fs7.existsSync(this.upstreamDir)) fs7.rmSync(this.upstreamDir, { recursive: true, force: true });
36837
+ fs7.renameSync(backupDir, this.upstreamDir);
36775
36838
  }
36776
36839
  throw e;
36777
36840
  }
36778
36841
  try {
36779
- fs6.rmSync(tmpTar, { force: true });
36842
+ fs7.rmSync(tmpTar, { force: true });
36780
36843
  } catch {
36781
36844
  }
36782
36845
  try {
36783
- fs6.rmSync(tmpExtract, { recursive: true, force: true });
36846
+ fs7.rmSync(tmpExtract, { recursive: true, force: true });
36784
36847
  } catch {
36785
36848
  }
36786
36849
  const upstreamCount = this.countProviders(this.upstreamDir);
@@ -36812,7 +36875,7 @@ var init_provider_loader = __esm({
36812
36875
  reject(new Error(`HTTP ${res.statusCode}`));
36813
36876
  return;
36814
36877
  }
36815
- const ws = fs6.createWriteStream(destPath);
36878
+ const ws = fs7.createWriteStream(destPath);
36816
36879
  res.pipe(ws);
36817
36880
  ws.on("finish", () => {
36818
36881
  ws.close();
@@ -36831,22 +36894,22 @@ var init_provider_loader = __esm({
36831
36894
  }
36832
36895
  /** Recursive directory copy */
36833
36896
  copyDirRecursive(src, dest) {
36834
- fs6.mkdirSync(dest, { recursive: true });
36835
- for (const entry of fs6.readdirSync(src, { withFileTypes: true })) {
36836
- const srcPath = path13.join(src, entry.name);
36837
- const destPath = path13.join(dest, entry.name);
36897
+ fs7.mkdirSync(dest, { recursive: true });
36898
+ for (const entry of fs7.readdirSync(src, { withFileTypes: true })) {
36899
+ const srcPath = path14.join(src, entry.name);
36900
+ const destPath = path14.join(dest, entry.name);
36838
36901
  if (entry.isDirectory()) {
36839
36902
  this.copyDirRecursive(srcPath, destPath);
36840
36903
  } else {
36841
- fs6.copyFileSync(srcPath, destPath);
36904
+ fs7.copyFileSync(srcPath, destPath);
36842
36905
  }
36843
36906
  }
36844
36907
  }
36845
36908
  /** .meta.json save */
36846
36909
  writeMeta(metaPath, etag, timestamp) {
36847
36910
  try {
36848
- fs6.mkdirSync(path13.dirname(metaPath), { recursive: true });
36849
- fs6.writeFileSync(metaPath, JSON.stringify({
36911
+ fs7.mkdirSync(path14.dirname(metaPath), { recursive: true });
36912
+ fs7.writeFileSync(metaPath, JSON.stringify({
36850
36913
  etag,
36851
36914
  timestamp,
36852
36915
  lastCheck: new Date(timestamp).toISOString(),
@@ -36857,12 +36920,12 @@ var init_provider_loader = __esm({
36857
36920
  }
36858
36921
  /** Count provider files (provider.js or provider.json) */
36859
36922
  countProviders(dir) {
36860
- if (!fs6.existsSync(dir)) return 0;
36923
+ if (!fs7.existsSync(dir)) return 0;
36861
36924
  let count = 0;
36862
36925
  const scan = (d) => {
36863
36926
  try {
36864
- for (const entry of fs6.readdirSync(d, { withFileTypes: true })) {
36865
- if (entry.isDirectory()) scan(path13.join(d, entry.name));
36927
+ for (const entry of fs7.readdirSync(d, { withFileTypes: true })) {
36928
+ if (entry.isDirectory()) scan(path14.join(d, entry.name));
36866
36929
  else if (entry.name === "provider.json") count++;
36867
36930
  }
36868
36931
  } catch {
@@ -37088,19 +37151,19 @@ var init_provider_loader = __esm({
37088
37151
  const cat = provider.category;
37089
37152
  const searchRoots = this.getProviderRoots();
37090
37153
  for (const root of searchRoots) {
37091
- if (!fs6.existsSync(root)) continue;
37154
+ if (!fs7.existsSync(root)) continue;
37092
37155
  const candidate = this.getProviderDir(root, cat, type);
37093
- if (fs6.existsSync(path13.join(candidate, "provider.json"))) return candidate;
37094
- const catDir = path13.join(root, cat);
37095
- if (fs6.existsSync(catDir)) {
37156
+ if (fs7.existsSync(path14.join(candidate, "provider.json"))) return candidate;
37157
+ const catDir = path14.join(root, cat);
37158
+ if (fs7.existsSync(catDir)) {
37096
37159
  try {
37097
- for (const entry of fs6.readdirSync(catDir, { withFileTypes: true })) {
37160
+ for (const entry of fs7.readdirSync(catDir, { withFileTypes: true })) {
37098
37161
  if (!entry.isDirectory()) continue;
37099
- const jsonPath = path13.join(catDir, entry.name, "provider.json");
37100
- if (fs6.existsSync(jsonPath)) {
37162
+ const jsonPath = path14.join(catDir, entry.name, "provider.json");
37163
+ if (fs7.existsSync(jsonPath)) {
37101
37164
  try {
37102
- const data = JSON.parse(fs6.readFileSync(jsonPath, "utf-8"));
37103
- if (data.type === type) return path13.join(catDir, entry.name);
37165
+ const data = JSON.parse(fs7.readFileSync(jsonPath, "utf-8"));
37166
+ if (data.type === type) return path14.join(catDir, entry.name);
37104
37167
  } catch {
37105
37168
  }
37106
37169
  }
@@ -37117,8 +37180,8 @@ var init_provider_loader = __esm({
37117
37180
  * (template substitution is NOT applied here — scripts.js handles that)
37118
37181
  */
37119
37182
  buildScriptWrappersFromDir(dir) {
37120
- const scriptsJs = path13.join(dir, "scripts.js");
37121
- if (fs6.existsSync(scriptsJs)) {
37183
+ const scriptsJs = path14.join(dir, "scripts.js");
37184
+ if (fs7.existsSync(scriptsJs)) {
37122
37185
  try {
37123
37186
  delete require.cache[require.resolve(scriptsJs)];
37124
37187
  return require(scriptsJs);
@@ -37128,13 +37191,13 @@ var init_provider_loader = __esm({
37128
37191
  const toCamel = (name) => name.replace(/_([a-z])/g, (_2, c) => c.toUpperCase());
37129
37192
  const result = {};
37130
37193
  try {
37131
- for (const file2 of fs6.readdirSync(dir)) {
37194
+ for (const file2 of fs7.readdirSync(dir)) {
37132
37195
  if (!file2.endsWith(".js")) continue;
37133
37196
  const scriptName = toCamel(file2.replace(".js", ""));
37134
- const filePath = path13.join(dir, file2);
37197
+ const filePath = path14.join(dir, file2);
37135
37198
  result[scriptName] = (...args) => {
37136
37199
  try {
37137
- let content = fs6.readFileSync(filePath, "utf-8");
37200
+ let content = fs7.readFileSync(filePath, "utf-8");
37138
37201
  if (args[0] && typeof args[0] === "object") {
37139
37202
  for (const [key, val] of Object.entries(args[0])) {
37140
37203
  let v = val;
@@ -37180,20 +37243,20 @@ var init_provider_loader = __esm({
37180
37243
  * Structure: dir/category/agent-name/provider.{json,js}
37181
37244
  */
37182
37245
  loadDir(dir, excludeDirs) {
37183
- if (!fs6.existsSync(dir)) return 0;
37246
+ if (!fs7.existsSync(dir)) return 0;
37184
37247
  let count = 0;
37185
37248
  const scan = (d) => {
37186
37249
  let entries;
37187
37250
  try {
37188
- entries = fs6.readdirSync(d, { withFileTypes: true });
37251
+ entries = fs7.readdirSync(d, { withFileTypes: true });
37189
37252
  } catch {
37190
37253
  return;
37191
37254
  }
37192
37255
  const hasJson = entries.some((e) => e.name === "provider.json");
37193
37256
  if (hasJson) {
37194
- const jsonPath = path13.join(d, "provider.json");
37257
+ const jsonPath = path14.join(d, "provider.json");
37195
37258
  try {
37196
- const raw = fs6.readFileSync(jsonPath, "utf-8");
37259
+ const raw = fs7.readFileSync(jsonPath, "utf-8");
37197
37260
  const mod = JSON.parse(raw);
37198
37261
  if (typeof mod.extensionIdPattern === "string") {
37199
37262
  const flags = mod.extensionIdPattern_flags || "";
@@ -37212,8 +37275,8 @@ var init_provider_loader = __esm({
37212
37275
  this.log(`\u26A0 Invalid provider at ${jsonPath}: ${validation.errors.join("; ")}`);
37213
37276
  } else {
37214
37277
  const hasCompatibility = Array.isArray(normalizedProvider.compatibility);
37215
- const scriptsPath = path13.join(d, "scripts.js");
37216
- if (!hasCompatibility && fs6.existsSync(scriptsPath)) {
37278
+ const scriptsPath = path14.join(d, "scripts.js");
37279
+ if (!hasCompatibility && fs7.existsSync(scriptsPath)) {
37217
37280
  try {
37218
37281
  delete require.cache[require.resolve(scriptsPath)];
37219
37282
  const scripts = require(scriptsPath);
@@ -37238,7 +37301,7 @@ var init_provider_loader = __esm({
37238
37301
  if (!entry.isDirectory()) continue;
37239
37302
  if (entry.name.startsWith("_") || entry.name.startsWith(".")) continue;
37240
37303
  if (excludeDirs && d === dir && excludeDirs.includes(entry.name)) continue;
37241
- scan(path13.join(d, entry.name));
37304
+ scan(path14.join(d, entry.name));
37242
37305
  }
37243
37306
  }
37244
37307
  };
@@ -37434,7 +37497,7 @@ async function isCdpActive(port) {
37434
37497
  });
37435
37498
  }
37436
37499
  async function killIdeProcess(ideId) {
37437
- const plat = os16.platform();
37500
+ const plat = os17.platform();
37438
37501
  const appName = getMacAppIdentifiers()[ideId];
37439
37502
  const winProcesses = getWinProcessNames()[ideId];
37440
37503
  try {
@@ -37495,7 +37558,7 @@ async function killIdeProcess(ideId) {
37495
37558
  }
37496
37559
  }
37497
37560
  function isIdeRunning(ideId) {
37498
- const plat = os16.platform();
37561
+ const plat = os17.platform();
37499
37562
  try {
37500
37563
  if (plat === "darwin") {
37501
37564
  const appName = getMacAppIdentifiers()[ideId];
@@ -37550,7 +37613,7 @@ function isIdeRunning(ideId) {
37550
37613
  }
37551
37614
  }
37552
37615
  function detectCurrentWorkspace(ideId) {
37553
- const plat = os16.platform();
37616
+ const plat = os17.platform();
37554
37617
  if (plat === "darwin") {
37555
37618
  try {
37556
37619
  const appName = getMacAppIdentifiers()[ideId];
@@ -37565,17 +37628,17 @@ function detectCurrentWorkspace(ideId) {
37565
37628
  }
37566
37629
  } else if (plat === "win32") {
37567
37630
  try {
37568
- const fs19 = require("fs");
37631
+ const fs20 = require("fs");
37569
37632
  const appNameMap = getMacAppIdentifiers();
37570
37633
  const appName = appNameMap[ideId];
37571
37634
  if (appName) {
37572
- const storagePath = path14.join(
37573
- process.env.APPDATA || path14.join(os16.homedir(), "AppData", "Roaming"),
37635
+ const storagePath = path15.join(
37636
+ process.env.APPDATA || path15.join(os17.homedir(), "AppData", "Roaming"),
37574
37637
  appName,
37575
37638
  "storage.json"
37576
37639
  );
37577
- if (fs19.existsSync(storagePath)) {
37578
- const data = JSON.parse(fs19.readFileSync(storagePath, "utf-8"));
37640
+ if (fs20.existsSync(storagePath)) {
37641
+ const data = JSON.parse(fs20.readFileSync(storagePath, "utf-8"));
37579
37642
  const workspaces = data?.openedPathsList?.workspaces3 || data?.openedPathsList?.entries || [];
37580
37643
  if (workspaces.length > 0) {
37581
37644
  const recent = workspaces[0];
@@ -37592,7 +37655,7 @@ function detectCurrentWorkspace(ideId) {
37592
37655
  return void 0;
37593
37656
  }
37594
37657
  async function launchWithCdp(options = {}) {
37595
- const platform12 = os16.platform();
37658
+ const platform12 = os17.platform();
37596
37659
  let targetIde;
37597
37660
  const ides = await detectIDEs(getProviderLoader());
37598
37661
  if (options.ideId) {
@@ -37741,14 +37804,14 @@ async function launchLinux(ide, port, workspace, newWindow) {
37741
37804
  function getAvailableIdeIds() {
37742
37805
  return getProviderLoader().getAvailableIdeTypes();
37743
37806
  }
37744
- var import_child_process7, net2, os16, path14, _providerLoader;
37807
+ var import_child_process7, net2, os17, path15, _providerLoader;
37745
37808
  var init_launch = __esm({
37746
37809
  "../../oss/packages/daemon-core/src/launch.ts"() {
37747
37810
  "use strict";
37748
37811
  import_child_process7 = require("child_process");
37749
37812
  net2 = __toESM(require("net"));
37750
- os16 = __toESM(require("os"));
37751
- path14 = __toESM(require("path"));
37813
+ os17 = __toESM(require("os"));
37814
+ path15 = __toESM(require("path"));
37752
37815
  init_ide_detector();
37753
37816
  init_provider_loader();
37754
37817
  init_macos_app_process();
@@ -37780,13 +37843,13 @@ function checkRotation() {
37780
37843
  const today = getDateStr2();
37781
37844
  if (today !== currentDate2) {
37782
37845
  currentDate2 = today;
37783
- currentFile = path15.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
37846
+ currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
37784
37847
  cleanOldFiles();
37785
37848
  }
37786
37849
  }
37787
37850
  function cleanOldFiles() {
37788
37851
  try {
37789
- const files = fs7.readdirSync(LOG_DIR2).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
37852
+ const files = fs8.readdirSync(LOG_DIR2).filter((f) => f.startsWith("commands-") && f.endsWith(".jsonl"));
37790
37853
  const cutoff = /* @__PURE__ */ new Date();
37791
37854
  cutoff.setDate(cutoff.getDate() - MAX_DAYS);
37792
37855
  const cutoffStr = cutoff.toISOString().slice(0, 10);
@@ -37794,7 +37857,7 @@ function cleanOldFiles() {
37794
37857
  const dateMatch = file2.match(/commands-(\d{4}-\d{2}-\d{2})/);
37795
37858
  if (dateMatch && dateMatch[1] < cutoffStr) {
37796
37859
  try {
37797
- fs7.unlinkSync(path15.join(LOG_DIR2, file2));
37860
+ fs8.unlinkSync(path16.join(LOG_DIR2, file2));
37798
37861
  } catch {
37799
37862
  }
37800
37863
  }
@@ -37804,14 +37867,14 @@ function cleanOldFiles() {
37804
37867
  }
37805
37868
  function checkSize() {
37806
37869
  try {
37807
- const stat4 = fs7.statSync(currentFile);
37870
+ const stat4 = fs8.statSync(currentFile);
37808
37871
  if (stat4.size > MAX_FILE_SIZE) {
37809
37872
  const backup = currentFile.replace(".jsonl", ".1.jsonl");
37810
37873
  try {
37811
- fs7.unlinkSync(backup);
37874
+ fs8.unlinkSync(backup);
37812
37875
  } catch {
37813
37876
  }
37814
- fs7.renameSync(currentFile, backup);
37877
+ fs8.renameSync(currentFile, backup);
37815
37878
  }
37816
37879
  } catch {
37817
37880
  }
@@ -37836,14 +37899,14 @@ function logCommand(entry) {
37836
37899
  ...entry.error ? { err: entry.error } : {},
37837
37900
  ...entry.durationMs !== void 0 ? { ms: entry.durationMs } : {}
37838
37901
  });
37839
- fs7.appendFileSync(currentFile, line + "\n");
37902
+ fs8.appendFileSync(currentFile, line + "\n");
37840
37903
  } catch {
37841
37904
  }
37842
37905
  }
37843
37906
  function getRecentCommands(count = 50) {
37844
37907
  try {
37845
- if (!fs7.existsSync(currentFile)) return [];
37846
- const content = fs7.readFileSync(currentFile, "utf-8");
37908
+ if (!fs8.existsSync(currentFile)) return [];
37909
+ const content = fs8.readFileSync(currentFile, "utf-8");
37847
37910
  const lines = content.trim().split("\n").filter(Boolean);
37848
37911
  return lines.slice(-count).map((line) => {
37849
37912
  try {
@@ -37866,18 +37929,18 @@ function getRecentCommands(count = 50) {
37866
37929
  return [];
37867
37930
  }
37868
37931
  }
37869
- var fs7, path15, os17, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
37932
+ var fs8, path16, os18, LOG_DIR2, MAX_FILE_SIZE, MAX_DAYS, SENSITIVE_KEYS, currentDate2, currentFile, writeCount2, SKIP_COMMANDS;
37870
37933
  var init_command_log = __esm({
37871
37934
  "../../oss/packages/daemon-core/src/logging/command-log.ts"() {
37872
37935
  "use strict";
37873
- fs7 = __toESM(require("fs"));
37874
- path15 = __toESM(require("path"));
37875
- os17 = __toESM(require("os"));
37876
- LOG_DIR2 = process.platform === "win32" ? path15.join(process.env.LOCALAPPDATA || process.env.APPDATA || path15.join(os17.homedir(), "AppData", "Local"), "adhdev", "logs") : process.platform === "darwin" ? path15.join(os17.homedir(), "Library", "Logs", "adhdev") : path15.join(os17.homedir(), ".local", "share", "adhdev", "logs");
37936
+ fs8 = __toESM(require("fs"));
37937
+ path16 = __toESM(require("path"));
37938
+ os18 = __toESM(require("os"));
37939
+ 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");
37877
37940
  MAX_FILE_SIZE = 5 * 1024 * 1024;
37878
37941
  MAX_DAYS = 7;
37879
37942
  try {
37880
- fs7.mkdirSync(LOG_DIR2, { recursive: true });
37943
+ fs8.mkdirSync(LOG_DIR2, { recursive: true });
37881
37944
  } catch {
37882
37945
  }
37883
37946
  SENSITIVE_KEYS = /* @__PURE__ */ new Set([
@@ -37892,7 +37955,7 @@ var init_command_log = __esm({
37892
37955
  "text"
37893
37956
  ]);
37894
37957
  currentDate2 = getDateStr2();
37895
- currentFile = path15.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
37958
+ currentFile = path16.join(LOG_DIR2, `commands-${currentDate2}.jsonl`);
37896
37959
  writeCount2 = 0;
37897
37960
  SKIP_COMMANDS = /* @__PURE__ */ new Set([
37898
37961
  "heartbeat",
@@ -37956,8 +38019,8 @@ function buildAvailableProviders(providerLoader) {
37956
38019
  }
37957
38020
  function buildMachineInfo(profile = "full") {
37958
38021
  const base = {
37959
- hostname: os18.hostname(),
37960
- platform: os18.platform()
38022
+ hostname: os19.hostname(),
38023
+ platform: os19.platform()
37961
38024
  };
37962
38025
  if (profile === "live") {
37963
38026
  return base;
@@ -37966,23 +38029,23 @@ function buildMachineInfo(profile = "full") {
37966
38029
  const memSnap2 = getHostMemorySnapshot();
37967
38030
  return {
37968
38031
  ...base,
37969
- arch: os18.arch(),
37970
- cpus: os18.cpus().length,
38032
+ arch: os19.arch(),
38033
+ cpus: os19.cpus().length,
37971
38034
  totalMem: memSnap2.totalMem,
37972
- release: os18.release()
38035
+ release: os19.release()
37973
38036
  };
37974
38037
  }
37975
38038
  const memSnap = getHostMemorySnapshot();
37976
38039
  return {
37977
38040
  ...base,
37978
- arch: os18.arch(),
37979
- cpus: os18.cpus().length,
38041
+ arch: os19.arch(),
38042
+ cpus: os19.cpus().length,
37980
38043
  totalMem: memSnap.totalMem,
37981
38044
  freeMem: memSnap.freeMem,
37982
38045
  availableMem: memSnap.availableMem,
37983
- loadavg: os18.loadavg(),
37984
- uptime: os18.uptime(),
37985
- release: os18.release()
38046
+ loadavg: os19.loadavg(),
38047
+ uptime: os19.uptime(),
38048
+ release: os19.release()
37986
38049
  };
37987
38050
  }
37988
38051
  function parseMessageTime(value) {
@@ -38205,11 +38268,11 @@ function buildStatusSnapshot(options) {
38205
38268
  }
38206
38269
  };
38207
38270
  }
38208
- var os18, READ_DEBUG_ENABLED, recentReadDebugSignatureBySession;
38271
+ var os19, READ_DEBUG_ENABLED, recentReadDebugSignatureBySession;
38209
38272
  var init_snapshot = __esm({
38210
38273
  "../../oss/packages/daemon-core/src/status/snapshot.ts"() {
38211
38274
  "use strict";
38212
- os18 = __toESM(require("os"));
38275
+ os19 = __toESM(require("os"));
38213
38276
  init_config();
38214
38277
  init_state_store();
38215
38278
  init_recent_activity();
@@ -38227,37 +38290,37 @@ var init_snapshot = __esm({
38227
38290
 
38228
38291
  // ../../oss/packages/daemon-core/src/commands/upgrade-helper.ts
38229
38292
  function getUpgradeLogPath() {
38230
- const home = os19.homedir();
38231
- const dir = path16.join(home, ".adhdev");
38232
- fs8.mkdirSync(dir, { recursive: true });
38233
- return path16.join(dir, "daemon-upgrade.log");
38293
+ const home = os20.homedir();
38294
+ const dir = path17.join(home, ".adhdev");
38295
+ fs9.mkdirSync(dir, { recursive: true });
38296
+ return path17.join(dir, "daemon-upgrade.log");
38234
38297
  }
38235
38298
  function appendUpgradeLog(message) {
38236
38299
  const line = `[${(/* @__PURE__ */ new Date()).toISOString()}] ${message}
38237
38300
  `;
38238
38301
  try {
38239
- fs8.appendFileSync(getUpgradeLogPath(), line, "utf8");
38302
+ fs9.appendFileSync(getUpgradeLogPath(), line, "utf8");
38240
38303
  } catch {
38241
38304
  }
38242
38305
  }
38243
38306
  function resolveSiblingNpmInvocation(nodeExecutable, platform12 = process.platform) {
38244
- const binDir = path16.dirname(nodeExecutable);
38307
+ const binDir = path17.dirname(nodeExecutable);
38245
38308
  if (platform12 === "win32") {
38246
- const npmCliPath = path16.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
38247
- if (fs8.existsSync(npmCliPath)) {
38309
+ const npmCliPath = path17.join(binDir, "node_modules", "npm", "bin", "npm-cli.js");
38310
+ if (fs9.existsSync(npmCliPath)) {
38248
38311
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
38249
38312
  }
38250
38313
  for (const candidate of ["npm.exe", "npm"]) {
38251
- const candidatePath = path16.join(binDir, candidate);
38252
- if (fs8.existsSync(candidatePath)) {
38314
+ const candidatePath = path17.join(binDir, candidate);
38315
+ if (fs9.existsSync(candidatePath)) {
38253
38316
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
38254
38317
  }
38255
38318
  }
38256
38319
  return { executable: nodeExecutable, argsPrefix: [npmCliPath], execOptions: getNpmExecOptions(platform12) };
38257
38320
  }
38258
38321
  for (const candidate of ["npm"]) {
38259
- const candidatePath = path16.join(binDir, candidate);
38260
- if (fs8.existsSync(candidatePath)) {
38322
+ const candidatePath = path17.join(binDir, candidate);
38323
+ if (fs9.existsSync(candidatePath)) {
38261
38324
  return { executable: candidatePath, argsPrefix: [], execOptions: getNpmExecOptions(platform12) };
38262
38325
  }
38263
38326
  }
@@ -38267,22 +38330,22 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
38267
38330
  if (!currentCliPath) return null;
38268
38331
  let resolvedPath = currentCliPath;
38269
38332
  try {
38270
- resolvedPath = fs8.realpathSync.native(currentCliPath);
38333
+ resolvedPath = fs9.realpathSync.native(currentCliPath);
38271
38334
  } catch {
38272
38335
  }
38273
38336
  let currentDir = resolvedPath;
38274
38337
  try {
38275
- if (fs8.statSync(resolvedPath).isFile()) {
38276
- currentDir = path16.dirname(resolvedPath);
38338
+ if (fs9.statSync(resolvedPath).isFile()) {
38339
+ currentDir = path17.dirname(resolvedPath);
38277
38340
  }
38278
38341
  } catch {
38279
- currentDir = path16.dirname(resolvedPath);
38342
+ currentDir = path17.dirname(resolvedPath);
38280
38343
  }
38281
38344
  while (true) {
38282
- const packageJsonPath = path16.join(currentDir, "package.json");
38345
+ const packageJsonPath = path17.join(currentDir, "package.json");
38283
38346
  try {
38284
- if (fs8.existsSync(packageJsonPath)) {
38285
- const parsed = JSON.parse(fs8.readFileSync(packageJsonPath, "utf8"));
38347
+ if (fs9.existsSync(packageJsonPath)) {
38348
+ const parsed = JSON.parse(fs9.readFileSync(packageJsonPath, "utf8"));
38286
38349
  if (parsed?.name === packageName) {
38287
38350
  const normalized = currentDir.replace(/\\/g, "/");
38288
38351
  return normalized.includes("/node_modules/") ? currentDir : null;
@@ -38290,7 +38353,7 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
38290
38353
  }
38291
38354
  } catch {
38292
38355
  }
38293
- const parentDir = path16.dirname(currentDir);
38356
+ const parentDir = path17.dirname(currentDir);
38294
38357
  if (parentDir === currentDir) {
38295
38358
  return null;
38296
38359
  }
@@ -38298,13 +38361,13 @@ function findCurrentPackageRoot(currentCliPath, packageName) {
38298
38361
  }
38299
38362
  }
38300
38363
  function resolveInstallPrefixFromPackageRoot(packageRoot, packageName) {
38301
- const nodeModulesDir = packageName.startsWith("@") ? path16.dirname(path16.dirname(packageRoot)) : path16.dirname(packageRoot);
38302
- if (path16.basename(nodeModulesDir) !== "node_modules") {
38364
+ const nodeModulesDir = packageName.startsWith("@") ? path17.dirname(path17.dirname(packageRoot)) : path17.dirname(packageRoot);
38365
+ if (path17.basename(nodeModulesDir) !== "node_modules") {
38303
38366
  return null;
38304
38367
  }
38305
- const maybeLibDir = path16.dirname(nodeModulesDir);
38306
- if (path16.basename(maybeLibDir) === "lib") {
38307
- return path16.dirname(maybeLibDir);
38368
+ const maybeLibDir = path17.dirname(nodeModulesDir);
38369
+ if (path17.basename(maybeLibDir) === "lib") {
38370
+ return path17.dirname(maybeLibDir);
38308
38371
  }
38309
38372
  return maybeLibDir;
38310
38373
  }
@@ -38419,10 +38482,10 @@ async function waitForPidExit(pid, timeoutMs) {
38419
38482
  }
38420
38483
  }
38421
38484
  function stopSessionHostProcesses(appName) {
38422
- const pidFile = path16.join(os19.homedir(), ".adhdev", `${appName}-session-host.pid`);
38485
+ const pidFile = path17.join(os20.homedir(), ".adhdev", `${appName}-session-host.pid`);
38423
38486
  try {
38424
- if (fs8.existsSync(pidFile)) {
38425
- const pid = Number.parseInt(fs8.readFileSync(pidFile, "utf8").trim(), 10);
38487
+ if (fs9.existsSync(pidFile)) {
38488
+ const pid = Number.parseInt(fs9.readFileSync(pidFile, "utf8").trim(), 10);
38426
38489
  if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid(pid)) {
38427
38490
  killPid(pid);
38428
38491
  }
@@ -38430,15 +38493,15 @@ function stopSessionHostProcesses(appName) {
38430
38493
  } catch {
38431
38494
  } finally {
38432
38495
  try {
38433
- fs8.unlinkSync(pidFile);
38496
+ fs9.unlinkSync(pidFile);
38434
38497
  } catch {
38435
38498
  }
38436
38499
  }
38437
38500
  }
38438
38501
  function removeDaemonPidFile() {
38439
- const pidFile = path16.join(os19.homedir(), ".adhdev", "daemon.pid");
38502
+ const pidFile = path17.join(os20.homedir(), ".adhdev", "daemon.pid");
38440
38503
  try {
38441
- fs8.unlinkSync(pidFile);
38504
+ fs9.unlinkSync(pidFile);
38442
38505
  } catch {
38443
38506
  }
38444
38507
  }
@@ -38447,7 +38510,7 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
38447
38510
  const npmRoot = String(execNpmCommandSync(["root", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
38448
38511
  if (!npmRoot) return;
38449
38512
  const npmPrefix = surface.installPrefix || String(execNpmCommandSync(["prefix", "-g", ...prefixArgs], { encoding: "utf8" }, surface)).trim();
38450
- const binDir = process.platform === "win32" ? npmPrefix : path16.join(npmPrefix, "bin");
38513
+ const binDir = process.platform === "win32" ? npmPrefix : path17.join(npmPrefix, "bin");
38451
38514
  const packageBaseName = pkgName.startsWith("@") ? pkgName.split("/")[1] : pkgName;
38452
38515
  const binNames = /* @__PURE__ */ new Set([packageBaseName]);
38453
38516
  if (pkgName === "@adhdev/daemon-standalone") {
@@ -38455,25 +38518,25 @@ function cleanupStaleGlobalInstallDirs(pkgName, surface) {
38455
38518
  }
38456
38519
  if (pkgName.startsWith("@")) {
38457
38520
  const [scope, name] = pkgName.split("/");
38458
- const scopeDir = path16.join(npmRoot, scope);
38459
- if (!fs8.existsSync(scopeDir)) return;
38460
- for (const entry of fs8.readdirSync(scopeDir)) {
38521
+ const scopeDir = path17.join(npmRoot, scope);
38522
+ if (!fs9.existsSync(scopeDir)) return;
38523
+ for (const entry of fs9.readdirSync(scopeDir)) {
38461
38524
  if (!entry.startsWith(`.${name}-`)) continue;
38462
- fs8.rmSync(path16.join(scopeDir, entry), { recursive: true, force: true });
38463
- appendUpgradeLog(`Removed stale scoped staging dir: ${path16.join(scopeDir, entry)}`);
38525
+ fs9.rmSync(path17.join(scopeDir, entry), { recursive: true, force: true });
38526
+ appendUpgradeLog(`Removed stale scoped staging dir: ${path17.join(scopeDir, entry)}`);
38464
38527
  }
38465
38528
  } else {
38466
- for (const entry of fs8.readdirSync(npmRoot)) {
38529
+ for (const entry of fs9.readdirSync(npmRoot)) {
38467
38530
  if (!entry.startsWith(`.${pkgName}-`)) continue;
38468
- fs8.rmSync(path16.join(npmRoot, entry), { recursive: true, force: true });
38469
- appendUpgradeLog(`Removed stale staging dir: ${path16.join(npmRoot, entry)}`);
38531
+ fs9.rmSync(path17.join(npmRoot, entry), { recursive: true, force: true });
38532
+ appendUpgradeLog(`Removed stale staging dir: ${path17.join(npmRoot, entry)}`);
38470
38533
  }
38471
38534
  }
38472
- if (fs8.existsSync(binDir)) {
38473
- for (const entry of fs8.readdirSync(binDir)) {
38535
+ if (fs9.existsSync(binDir)) {
38536
+ for (const entry of fs9.readdirSync(binDir)) {
38474
38537
  if (!Array.from(binNames).some((name) => entry.startsWith(`.${name}-`))) continue;
38475
- fs8.rmSync(path16.join(binDir, entry), { recursive: true, force: true });
38476
- appendUpgradeLog(`Removed stale bin staging entry: ${path16.join(binDir, entry)}`);
38538
+ fs9.rmSync(path17.join(binDir, entry), { recursive: true, force: true });
38539
+ appendUpgradeLog(`Removed stale bin staging entry: ${path17.join(binDir, entry)}`);
38477
38540
  }
38478
38541
  }
38479
38542
  }
@@ -38556,15 +38619,15 @@ async function maybeRunDaemonUpgradeHelperFromEnv() {
38556
38619
  process.exit(1);
38557
38620
  }
38558
38621
  }
38559
- var import_child_process8, import_child_process9, fs8, os19, path16, UPGRADE_HELPER_ENV;
38622
+ var import_child_process8, import_child_process9, fs9, os20, path17, UPGRADE_HELPER_ENV;
38560
38623
  var init_upgrade_helper = __esm({
38561
38624
  "../../oss/packages/daemon-core/src/commands/upgrade-helper.ts"() {
38562
38625
  "use strict";
38563
38626
  import_child_process8 = require("child_process");
38564
38627
  import_child_process9 = require("child_process");
38565
- fs8 = __toESM(require("fs"));
38566
- os19 = __toESM(require("os"));
38567
- path16 = __toESM(require("path"));
38628
+ fs9 = __toESM(require("fs"));
38629
+ os20 = __toESM(require("os"));
38630
+ path17 = __toESM(require("path"));
38568
38631
  UPGRADE_HELPER_ENV = "ADHDEV_DAEMON_UPGRADE_HELPER";
38569
38632
  }
38570
38633
  });
@@ -38651,7 +38714,7 @@ function summarizeSessionHostPruneResult(result) {
38651
38714
  keptCount: Array.isArray(value.keptSessionIds) ? value.keptSessionIds.length : void 0
38652
38715
  };
38653
38716
  }
38654
- var fs9, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
38717
+ var fs10, CHAT_COMMANDS, READ_DEBUG_ENABLED2, DaemonCommandRouter;
38655
38718
  var init_router = __esm({
38656
38719
  "../../oss/packages/daemon-core/src/commands/router.ts"() {
38657
38720
  "use strict";
@@ -38676,7 +38739,7 @@ var init_router = __esm({
38676
38739
  init_snapshot();
38677
38740
  init_snapshot();
38678
38741
  init_upgrade_helper();
38679
- fs9 = __toESM(require("fs"));
38742
+ fs10 = __toESM(require("fs"));
38680
38743
  CHAT_COMMANDS = [
38681
38744
  "send_chat",
38682
38745
  "new_chat",
@@ -38831,8 +38894,8 @@ var init_router = __esm({
38831
38894
  if (sinceTs > 0) {
38832
38895
  return { success: true, logs: [], totalBuffered: 0 };
38833
38896
  }
38834
- if (fs9.existsSync(LOG_PATH)) {
38835
- const content = fs9.readFileSync(LOG_PATH, "utf-8");
38897
+ if (fs10.existsSync(LOG_PATH)) {
38898
+ const content = fs10.readFileSync(LOG_PATH, "utf-8");
38836
38899
  const allLines = content.split("\n");
38837
38900
  const recent = allLines.slice(-count).join("\n");
38838
38901
  return { success: true, logs: recent, totalLines: allLines.length };
@@ -41110,19 +41173,19 @@ function getVersion(binary, versionCommand) {
41110
41173
  function checkPathExists2(paths) {
41111
41174
  for (const p of paths) {
41112
41175
  if (p.includes("*")) {
41113
- const home = os20.homedir();
41114
- const resolved = p.replace(/\*/g, home.split(path17.sep).pop() || "");
41115
- if (fs10.existsSync(resolved)) return resolved;
41176
+ const home = os21.homedir();
41177
+ const resolved = p.replace(/\*/g, home.split(path18.sep).pop() || "");
41178
+ if (fs11.existsSync(resolved)) return resolved;
41116
41179
  } else {
41117
- if (fs10.existsSync(p)) return p;
41180
+ if (fs11.existsSync(p)) return p;
41118
41181
  }
41119
41182
  }
41120
41183
  return null;
41121
41184
  }
41122
41185
  function getMacAppVersion(appPath) {
41123
41186
  if ((0, import_os3.platform)() !== "darwin" || !appPath.endsWith(".app")) return null;
41124
- const plistPath = path17.join(appPath, "Contents", "Info.plist");
41125
- if (!fs10.existsSync(plistPath)) return null;
41187
+ const plistPath = path18.join(appPath, "Contents", "Info.plist");
41188
+ if (!fs11.existsSync(plistPath)) return null;
41126
41189
  const raw = runCommand(`/usr/libexec/PlistBuddy -c "Print CFBundleShortVersionString" "${plistPath}"`);
41127
41190
  return raw || null;
41128
41191
  }
@@ -41147,8 +41210,8 @@ async function detectAllVersions(loader, archive) {
41147
41210
  const cliBin = provider.cli ? findBinary2(provider.cli) : null;
41148
41211
  let resolvedBin = cliBin;
41149
41212
  if (!resolvedBin && appPath && currentOs === "darwin") {
41150
- const bundled = path17.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
41151
- if (provider.cli && fs10.existsSync(bundled)) resolvedBin = bundled;
41213
+ const bundled = path18.join(appPath, "Contents", "Resources", "app", "bin", provider.cli || "");
41214
+ if (provider.cli && fs11.existsSync(bundled)) resolvedBin = bundled;
41152
41215
  }
41153
41216
  info.installed = !!(appPath || resolvedBin);
41154
41217
  info.path = appPath || null;
@@ -41184,16 +41247,16 @@ async function detectAllVersions(loader, archive) {
41184
41247
  }
41185
41248
  return results;
41186
41249
  }
41187
- var fs10, path17, os20, import_child_process10, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
41250
+ var fs11, path18, os21, import_child_process10, import_os3, ARCHIVE_PATH, MAX_ENTRIES_PER_PROVIDER, VersionArchive;
41188
41251
  var init_version_archive = __esm({
41189
41252
  "../../oss/packages/daemon-core/src/providers/version-archive.ts"() {
41190
41253
  "use strict";
41191
- fs10 = __toESM(require("fs"));
41192
- path17 = __toESM(require("path"));
41193
- os20 = __toESM(require("os"));
41254
+ fs11 = __toESM(require("fs"));
41255
+ path18 = __toESM(require("path"));
41256
+ os21 = __toESM(require("os"));
41194
41257
  import_child_process10 = require("child_process");
41195
41258
  import_os3 = require("os");
41196
- ARCHIVE_PATH = path17.join(os20.homedir(), ".adhdev", "version-history.json");
41259
+ ARCHIVE_PATH = path18.join(os21.homedir(), ".adhdev", "version-history.json");
41197
41260
  MAX_ENTRIES_PER_PROVIDER = 20;
41198
41261
  VersionArchive = class {
41199
41262
  history = {};
@@ -41202,8 +41265,8 @@ var init_version_archive = __esm({
41202
41265
  }
41203
41266
  load() {
41204
41267
  try {
41205
- if (fs10.existsSync(ARCHIVE_PATH)) {
41206
- this.history = JSON.parse(fs10.readFileSync(ARCHIVE_PATH, "utf-8"));
41268
+ if (fs11.existsSync(ARCHIVE_PATH)) {
41269
+ this.history = JSON.parse(fs11.readFileSync(ARCHIVE_PATH, "utf-8"));
41207
41270
  }
41208
41271
  } catch {
41209
41272
  this.history = {};
@@ -41240,8 +41303,8 @@ var init_version_archive = __esm({
41240
41303
  }
41241
41304
  save() {
41242
41305
  try {
41243
- fs10.mkdirSync(path17.dirname(ARCHIVE_PATH), { recursive: true });
41244
- fs10.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
41306
+ fs11.mkdirSync(path18.dirname(ARCHIVE_PATH), { recursive: true });
41307
+ fs11.writeFileSync(ARCHIVE_PATH, JSON.stringify(this.history, null, 2));
41245
41308
  } catch {
41246
41309
  }
41247
41310
  }
@@ -41775,18 +41838,18 @@ async function handleScriptHints(ctx, type, _req, res) {
41775
41838
  return;
41776
41839
  }
41777
41840
  let scriptsPath = "";
41778
- const directScripts = path18.join(dir, "scripts.js");
41779
- if (fs11.existsSync(directScripts)) {
41841
+ const directScripts = path19.join(dir, "scripts.js");
41842
+ if (fs12.existsSync(directScripts)) {
41780
41843
  scriptsPath = directScripts;
41781
41844
  } else {
41782
- const scriptsDir = path18.join(dir, "scripts");
41783
- if (fs11.existsSync(scriptsDir)) {
41784
- const versions = fs11.readdirSync(scriptsDir).filter((d) => {
41785
- return fs11.statSync(path18.join(scriptsDir, d)).isDirectory();
41845
+ const scriptsDir = path19.join(dir, "scripts");
41846
+ if (fs12.existsSync(scriptsDir)) {
41847
+ const versions = fs12.readdirSync(scriptsDir).filter((d) => {
41848
+ return fs12.statSync(path19.join(scriptsDir, d)).isDirectory();
41786
41849
  }).sort().reverse();
41787
41850
  for (const ver of versions) {
41788
- const p = path18.join(scriptsDir, ver, "scripts.js");
41789
- if (fs11.existsSync(p)) {
41851
+ const p = path19.join(scriptsDir, ver, "scripts.js");
41852
+ if (fs12.existsSync(p)) {
41790
41853
  scriptsPath = p;
41791
41854
  break;
41792
41855
  }
@@ -41798,7 +41861,7 @@ async function handleScriptHints(ctx, type, _req, res) {
41798
41861
  return;
41799
41862
  }
41800
41863
  try {
41801
- const source = fs11.readFileSync(scriptsPath, "utf-8");
41864
+ const source = fs12.readFileSync(scriptsPath, "utf-8");
41802
41865
  const hints = {};
41803
41866
  const funcRegex = /module\.exports\.(\w+)\s*=\s*function\s+\w+\s*\(params\)/g;
41804
41867
  let match;
@@ -42611,12 +42674,12 @@ async function handleDomContext(ctx, type, req, res) {
42611
42674
  ctx.json(res, 500, { error: `DOM context collection failed: ${e.message}` });
42612
42675
  }
42613
42676
  }
42614
- var fs11, path18;
42677
+ var fs12, path19;
42615
42678
  var init_dev_cdp_handlers = __esm({
42616
42679
  "../../oss/packages/daemon-core/src/daemon/dev-cdp-handlers.ts"() {
42617
42680
  "use strict";
42618
- fs11 = __toESM(require("fs"));
42619
- path18 = __toESM(require("path"));
42681
+ fs12 = __toESM(require("fs"));
42682
+ path19 = __toESM(require("path"));
42620
42683
  init_logger();
42621
42684
  }
42622
42685
  });
@@ -42631,15 +42694,15 @@ function getCliFixtureDir(ctx, type) {
42631
42694
  if (!providerDir) {
42632
42695
  throw new Error(`Provider directory not found for '${type}'`);
42633
42696
  }
42634
- return path19.join(providerDir, "fixtures");
42697
+ return path20.join(providerDir, "fixtures");
42635
42698
  }
42636
42699
  function readCliFixture(ctx, type, name) {
42637
42700
  const fixtureDir = getCliFixtureDir(ctx, type);
42638
- const filePath = path19.join(fixtureDir, `${name}.json`);
42639
- if (!fs12.existsSync(filePath)) {
42701
+ const filePath = path20.join(fixtureDir, `${name}.json`);
42702
+ if (!fs13.existsSync(filePath)) {
42640
42703
  throw new Error(`Fixture not found: ${filePath}`);
42641
42704
  }
42642
- return JSON.parse(fs12.readFileSync(filePath, "utf-8"));
42705
+ return JSON.parse(fs13.readFileSync(filePath, "utf-8"));
42643
42706
  }
42644
42707
  function getExerciseTranscriptText(result) {
42645
42708
  const parts = [];
@@ -43375,7 +43438,7 @@ async function handleCliFixtureCapture(ctx, req, res) {
43375
43438
  return;
43376
43439
  }
43377
43440
  const fixtureDir = getCliFixtureDir(ctx, type);
43378
- fs12.mkdirSync(fixtureDir, { recursive: true });
43441
+ fs13.mkdirSync(fixtureDir, { recursive: true });
43379
43442
  const name = slugifyFixtureName(String(body?.name || `${type}-${Date.now()}`));
43380
43443
  const result = await runCliExerciseInternal(ctx, { ...request, type });
43381
43444
  const fixture = {
@@ -43402,8 +43465,8 @@ async function handleCliFixtureCapture(ctx, req, res) {
43402
43465
  },
43403
43466
  notes: typeof body?.notes === "string" ? body.notes : void 0
43404
43467
  };
43405
- const filePath = path19.join(fixtureDir, `${name}.json`);
43406
- fs12.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
43468
+ const filePath = path20.join(fixtureDir, `${name}.json`);
43469
+ fs13.writeFileSync(filePath, JSON.stringify(fixture, null, 2));
43407
43470
  ctx.json(res, 200, {
43408
43471
  saved: true,
43409
43472
  name,
@@ -43421,14 +43484,14 @@ async function handleCliFixtureCapture(ctx, req, res) {
43421
43484
  async function handleCliFixtureList(ctx, type, _req, res) {
43422
43485
  try {
43423
43486
  const fixtureDir = getCliFixtureDir(ctx, type);
43424
- if (!fs12.existsSync(fixtureDir)) {
43487
+ if (!fs13.existsSync(fixtureDir)) {
43425
43488
  ctx.json(res, 200, { fixtures: [], count: 0 });
43426
43489
  return;
43427
43490
  }
43428
- const fixtures = fs12.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
43429
- const fullPath = path19.join(fixtureDir, file2);
43491
+ const fixtures = fs13.readdirSync(fixtureDir).filter((file2) => file2.endsWith(".json")).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" })).map((file2) => {
43492
+ const fullPath = path20.join(fixtureDir, file2);
43430
43493
  try {
43431
- const raw = JSON.parse(fs12.readFileSync(fullPath, "utf-8"));
43494
+ const raw = JSON.parse(fs13.readFileSync(fullPath, "utf-8"));
43432
43495
  return {
43433
43496
  name: raw.name || file2.replace(/\.json$/i, ""),
43434
43497
  path: fullPath,
@@ -43559,12 +43622,12 @@ async function handleCliRaw(ctx, req, res) {
43559
43622
  ctx.json(res, 500, { error: `Raw send failed: ${e.message}` });
43560
43623
  }
43561
43624
  }
43562
- var fs12, path19;
43625
+ var fs13, path20;
43563
43626
  var init_dev_cli_debug = __esm({
43564
43627
  "../../oss/packages/daemon-core/src/daemon/dev-cli-debug.ts"() {
43565
43628
  "use strict";
43566
- fs12 = __toESM(require("fs"));
43567
- path19 = __toESM(require("path"));
43629
+ fs13 = __toESM(require("fs"));
43630
+ path20 = __toESM(require("path"));
43568
43631
  }
43569
43632
  });
43570
43633
 
@@ -43614,38 +43677,38 @@ function resolveAutoImplReference(ctx, category, requestedReference, targetType)
43614
43677
  return fallback2?.type || null;
43615
43678
  }
43616
43679
  function getLatestScriptVersionDir(scriptsDir) {
43617
- if (!fs13.existsSync(scriptsDir)) return null;
43618
- const versions = fs13.readdirSync(scriptsDir).filter((d) => {
43680
+ if (!fs14.existsSync(scriptsDir)) return null;
43681
+ const versions = fs14.readdirSync(scriptsDir).filter((d) => {
43619
43682
  try {
43620
- return fs13.statSync(path20.join(scriptsDir, d)).isDirectory();
43683
+ return fs14.statSync(path21.join(scriptsDir, d)).isDirectory();
43621
43684
  } catch {
43622
43685
  return false;
43623
43686
  }
43624
43687
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
43625
43688
  if (versions.length === 0) return null;
43626
- return path20.join(scriptsDir, versions[0]);
43689
+ return path21.join(scriptsDir, versions[0]);
43627
43690
  }
43628
43691
  function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
43629
- const canonicalUserDir = path20.resolve(ctx.providerLoader.getUserProviderDir(category, type));
43630
- const desiredDir = requestedDir ? path20.resolve(requestedDir) : canonicalUserDir;
43631
- const upstreamRoot = path20.resolve(ctx.providerLoader.getUpstreamDir());
43632
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path20.sep}`)) {
43692
+ const canonicalUserDir = path21.resolve(ctx.providerLoader.getUserProviderDir(category, type));
43693
+ const desiredDir = requestedDir ? path21.resolve(requestedDir) : canonicalUserDir;
43694
+ const upstreamRoot = path21.resolve(ctx.providerLoader.getUpstreamDir());
43695
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path21.sep}`)) {
43633
43696
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
43634
43697
  }
43635
- if (path20.basename(desiredDir) !== type) {
43698
+ if (path21.basename(desiredDir) !== type) {
43636
43699
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
43637
43700
  }
43638
43701
  const sourceDir = ctx.findProviderDir(type);
43639
43702
  if (!sourceDir) {
43640
43703
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
43641
43704
  }
43642
- if (!fs13.existsSync(desiredDir)) {
43643
- fs13.mkdirSync(path20.dirname(desiredDir), { recursive: true });
43644
- fs13.cpSync(sourceDir, desiredDir, { recursive: true });
43705
+ if (!fs14.existsSync(desiredDir)) {
43706
+ fs14.mkdirSync(path21.dirname(desiredDir), { recursive: true });
43707
+ fs14.cpSync(sourceDir, desiredDir, { recursive: true });
43645
43708
  ctx.log(`Auto-implement writable copy created: ${desiredDir}`);
43646
43709
  }
43647
- const providerJson = path20.join(desiredDir, "provider.json");
43648
- if (!fs13.existsSync(providerJson)) {
43710
+ const providerJson = path21.join(desiredDir, "provider.json");
43711
+ if (!fs14.existsSync(providerJson)) {
43649
43712
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
43650
43713
  }
43651
43714
  return { dir: desiredDir };
@@ -43653,15 +43716,15 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
43653
43716
  function loadAutoImplReferenceScripts(ctx, referenceType) {
43654
43717
  if (!referenceType) return {};
43655
43718
  const refDir = ctx.findProviderDir(referenceType);
43656
- if (!refDir || !fs13.existsSync(refDir)) return {};
43719
+ if (!refDir || !fs14.existsSync(refDir)) return {};
43657
43720
  const referenceScripts = {};
43658
- const scriptsDir = path20.join(refDir, "scripts");
43721
+ const scriptsDir = path21.join(refDir, "scripts");
43659
43722
  const latestDir = getLatestScriptVersionDir(scriptsDir);
43660
43723
  if (!latestDir) return referenceScripts;
43661
- for (const file2 of fs13.readdirSync(latestDir)) {
43724
+ for (const file2 of fs14.readdirSync(latestDir)) {
43662
43725
  if (!file2.endsWith(".js")) continue;
43663
43726
  try {
43664
- referenceScripts[file2] = fs13.readFileSync(path20.join(latestDir, file2), "utf-8");
43727
+ referenceScripts[file2] = fs14.readFileSync(path21.join(latestDir, file2), "utf-8");
43665
43728
  } catch {
43666
43729
  }
43667
43730
  }
@@ -43769,16 +43832,16 @@ async function handleAutoImplement(ctx, type, req, res) {
43769
43832
  });
43770
43833
  const referenceScripts = loadAutoImplReferenceScripts(ctx, resolvedReference);
43771
43834
  const prompt2 = buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domContext, referenceScripts, comment, resolvedReference, verification);
43772
- const tmpDir = path20.join(os21.tmpdir(), "adhdev-autoimpl");
43773
- if (!fs13.existsSync(tmpDir)) fs13.mkdirSync(tmpDir, { recursive: true });
43774
- const promptFile = path20.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
43775
- fs13.writeFileSync(promptFile, prompt2, "utf-8");
43835
+ const tmpDir = path21.join(os23.tmpdir(), "adhdev-autoimpl");
43836
+ if (!fs14.existsSync(tmpDir)) fs14.mkdirSync(tmpDir, { recursive: true });
43837
+ const promptFile = path21.join(tmpDir, `prompt-${type}-${Date.now()}.md`);
43838
+ fs14.writeFileSync(promptFile, prompt2, "utf-8");
43776
43839
  ctx.log(`Auto-implement prompt written to ${promptFile} (${prompt2.length} chars)`);
43777
43840
  const agentProvider = ctx.providerLoader.resolve(agent) || ctx.providerLoader.getMeta(agent);
43778
43841
  const spawn6 = agentProvider?.spawn;
43779
43842
  if (!spawn6?.command) {
43780
43843
  try {
43781
- fs13.unlinkSync(promptFile);
43844
+ fs14.unlinkSync(promptFile);
43782
43845
  } catch {
43783
43846
  }
43784
43847
  ctx.json(res, 400, { error: `Agent '${agent}' has no spawn config. Select a CLI provider with a spawn configuration.` });
@@ -43880,7 +43943,7 @@ async function handleAutoImplement(ctx, type, req, res) {
43880
43943
  } catch {
43881
43944
  }
43882
43945
  try {
43883
- fs13.unlinkSync(promptFile);
43946
+ fs14.unlinkSync(promptFile);
43884
43947
  } catch {
43885
43948
  }
43886
43949
  ctx.log(`Auto-implement (ACP) ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})`);
@@ -43924,7 +43987,7 @@ async function handleAutoImplement(ctx, type, req, res) {
43924
43987
  const interactiveFlags = ["--yolo", "--interactive", "-i"];
43925
43988
  const baseArgs = [...spawn6.args || []].filter((a) => !interactiveFlags.includes(a));
43926
43989
  let shellCmd;
43927
- const isWin = os21.platform() === "win32";
43990
+ const isWin = os23.platform() === "win32";
43928
43991
  const escapeArg = (a) => isWin ? `"${a.replace(/"/g, '""')}"` : `'${a.replace(/'/g, "'\\''")}'`;
43929
43992
  const promptMode = autoImpl?.promptMode ?? "stdin";
43930
43993
  const extraArgs = autoImpl?.extraArgs ?? [];
@@ -43963,7 +44026,7 @@ async function handleAutoImplement(ctx, type, req, res) {
43963
44026
  try {
43964
44027
  const pty = require("node-pty");
43965
44028
  ctx.log(`Auto-implement spawn (PTY): ${shellCmd}`);
43966
- const isWin2 = os21.platform() === "win32";
44029
+ const isWin2 = os23.platform() === "win32";
43967
44030
  child = pty.spawn(isWin2 ? "cmd.exe" : process.env.SHELL || "/bin/zsh", [isWin2 ? "/c" : "-c", shellCmd], {
43968
44031
  name: "xterm-256color",
43969
44032
  cols: 120,
@@ -44106,7 +44169,7 @@ async function handleAutoImplement(ctx, type, req, res) {
44106
44169
  }
44107
44170
  });
44108
44171
  try {
44109
- fs13.unlinkSync(promptFile);
44172
+ fs14.unlinkSync(promptFile);
44110
44173
  } catch {
44111
44174
  }
44112
44175
  ctx.log(`Auto-implement ${success2 ? "completed" : "failed"}: ${type} (exit: ${code})${verificationSummary ? ` verify=${verificationSummary.pass ? "pass" : "fail"}` : ""}`);
@@ -44203,7 +44266,7 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
44203
44266
  setMode: "set_mode.js"
44204
44267
  };
44205
44268
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
44206
- const scriptsDir = path20.join(providerDir, "scripts");
44269
+ const scriptsDir = path21.join(providerDir, "scripts");
44207
44270
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
44208
44271
  if (latestScriptsDir) {
44209
44272
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -44211,10 +44274,10 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
44211
44274
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
44212
44275
  lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
44213
44276
  lines.push("");
44214
- for (const file2 of fs13.readdirSync(latestScriptsDir)) {
44277
+ for (const file2 of fs14.readdirSync(latestScriptsDir)) {
44215
44278
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
44216
44279
  try {
44217
- const content = fs13.readFileSync(path20.join(latestScriptsDir, file2), "utf-8");
44280
+ const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
44218
44281
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
44219
44282
  lines.push("```javascript");
44220
44283
  lines.push(content);
@@ -44224,14 +44287,14 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
44224
44287
  }
44225
44288
  }
44226
44289
  }
44227
- const refFiles = fs13.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
44290
+ const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
44228
44291
  if (refFiles.length > 0) {
44229
44292
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
44230
44293
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
44231
44294
  lines.push("");
44232
44295
  for (const file2 of refFiles) {
44233
44296
  try {
44234
- const content = fs13.readFileSync(path20.join(latestScriptsDir, file2), "utf-8");
44297
+ const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
44235
44298
  lines.push(`### \`${file2}\` \u{1F512}`);
44236
44299
  lines.push("```javascript");
44237
44300
  lines.push(content);
@@ -44272,11 +44335,11 @@ function buildAutoImplPrompt(ctx, type, provider, providerDir, functions, domCon
44272
44335
  lines.push("");
44273
44336
  }
44274
44337
  }
44275
- const docsDir = path20.join(providerDir, "../../docs");
44338
+ const docsDir = path21.join(providerDir, "../../docs");
44276
44339
  const loadGuide = (name) => {
44277
44340
  try {
44278
- const p = path20.join(docsDir, name);
44279
- if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
44341
+ const p = path21.join(docsDir, name);
44342
+ if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
44280
44343
  } catch {
44281
44344
  }
44282
44345
  return null;
@@ -44512,7 +44575,7 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
44512
44575
  parseApproval: "parse_approval.js"
44513
44576
  };
44514
44577
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
44515
- const scriptsDir = path20.join(providerDir, "scripts");
44578
+ const scriptsDir = path21.join(providerDir, "scripts");
44516
44579
  const latestScriptsDir = getLatestScriptVersionDir(scriptsDir);
44517
44580
  if (latestScriptsDir) {
44518
44581
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -44520,11 +44583,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
44520
44583
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
44521
44584
  lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
44522
44585
  lines.push("");
44523
- for (const file2 of fs13.readdirSync(latestScriptsDir)) {
44586
+ for (const file2 of fs14.readdirSync(latestScriptsDir)) {
44524
44587
  if (!file2.endsWith(".js")) continue;
44525
44588
  if (!targetFileNames.has(file2)) continue;
44526
44589
  try {
44527
- const content = fs13.readFileSync(path20.join(latestScriptsDir, file2), "utf-8");
44590
+ const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
44528
44591
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
44529
44592
  lines.push("```javascript");
44530
44593
  lines.push(content);
@@ -44533,14 +44596,14 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
44533
44596
  } catch {
44534
44597
  }
44535
44598
  }
44536
- const refFiles = fs13.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
44599
+ const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
44537
44600
  if (refFiles.length > 0) {
44538
44601
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
44539
44602
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
44540
44603
  lines.push("");
44541
44604
  for (const file2 of refFiles) {
44542
44605
  try {
44543
- const content = fs13.readFileSync(path20.join(latestScriptsDir, file2), "utf-8");
44606
+ const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
44544
44607
  lines.push(`### \`${file2}\` \u{1F512}`);
44545
44608
  lines.push("```javascript");
44546
44609
  lines.push(content);
@@ -44573,11 +44636,11 @@ function buildCliAutoImplPrompt(ctx, type, provider, providerDir, functions, ref
44573
44636
  lines.push("");
44574
44637
  }
44575
44638
  }
44576
- const docsDir = path20.join(providerDir, "../../docs");
44639
+ const docsDir = path21.join(providerDir, "../../docs");
44577
44640
  const loadGuide = (name) => {
44578
44641
  try {
44579
- const p = path20.join(docsDir, name);
44580
- if (fs13.existsSync(p)) return fs13.readFileSync(p, "utf-8");
44642
+ const p = path21.join(docsDir, name);
44643
+ if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
44581
44644
  } catch {
44582
44645
  }
44583
44646
  return null;
@@ -44888,13 +44951,13 @@ data: ${JSON.stringify(msg.data)}
44888
44951
  }
44889
44952
  }
44890
44953
  }
44891
- var fs13, path20, os21;
44954
+ var fs14, path21, os23;
44892
44955
  var init_dev_auto_implement = __esm({
44893
44956
  "../../oss/packages/daemon-core/src/daemon/dev-auto-implement.ts"() {
44894
44957
  "use strict";
44895
- fs13 = __toESM(require("fs"));
44896
- path20 = __toESM(require("path"));
44897
- os21 = __toESM(require("os"));
44958
+ fs14 = __toESM(require("fs"));
44959
+ path21 = __toESM(require("path"));
44960
+ os23 = __toESM(require("os"));
44898
44961
  init_dev_server();
44899
44962
  init_dev_cli_debug();
44900
44963
  }
@@ -44933,13 +44996,13 @@ function toProviderListEntry(provider) {
44933
44996
  }
44934
44997
  return base;
44935
44998
  }
44936
- var http2, fs14, path21, DEV_SERVER_PORT, DevServer;
44999
+ var http2, fs15, path23, DEV_SERVER_PORT, DevServer;
44937
45000
  var init_dev_server = __esm({
44938
45001
  "../../oss/packages/daemon-core/src/daemon/dev-server.ts"() {
44939
45002
  "use strict";
44940
45003
  http2 = __toESM(require("http"));
44941
- fs14 = __toESM(require("fs"));
44942
- path21 = __toESM(require("path"));
45004
+ fs15 = __toESM(require("fs"));
45005
+ path23 = __toESM(require("path"));
44943
45006
  init_provider_schema();
44944
45007
  init_config();
44945
45008
  init_provider_source_config();
@@ -45052,8 +45115,8 @@ var init_dev_server = __esm({
45052
45115
  }
45053
45116
  getEndpointList() {
45054
45117
  return this.routes.map((r) => {
45055
- const path28 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
45056
- return `${r.method.padEnd(5)} ${path28}`;
45118
+ const path29 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
45119
+ return `${r.method.padEnd(5)} ${path29}`;
45057
45120
  });
45058
45121
  }
45059
45122
  async start(port = DEV_SERVER_PORT) {
@@ -45341,12 +45404,12 @@ var init_dev_server = __esm({
45341
45404
  // ─── DevConsole SPA ───
45342
45405
  getConsoleDistDir() {
45343
45406
  const candidates = [
45344
- path21.resolve(__dirname, "../../web-devconsole/dist"),
45345
- path21.resolve(__dirname, "../../../web-devconsole/dist"),
45346
- path21.join(process.cwd(), "packages/web-devconsole/dist")
45407
+ path23.resolve(__dirname, "../../web-devconsole/dist"),
45408
+ path23.resolve(__dirname, "../../../web-devconsole/dist"),
45409
+ path23.join(process.cwd(), "packages/web-devconsole/dist")
45347
45410
  ];
45348
45411
  for (const dir of candidates) {
45349
- if (fs14.existsSync(path21.join(dir, "index.html"))) return dir;
45412
+ if (fs15.existsSync(path23.join(dir, "index.html"))) return dir;
45350
45413
  }
45351
45414
  return null;
45352
45415
  }
@@ -45356,9 +45419,9 @@ var init_dev_server = __esm({
45356
45419
  this.json(res, 500, { error: "DevConsole not found. Run: npm run build -w packages/web-devconsole" });
45357
45420
  return;
45358
45421
  }
45359
- const htmlPath = path21.join(distDir, "index.html");
45422
+ const htmlPath = path23.join(distDir, "index.html");
45360
45423
  try {
45361
- const html = fs14.readFileSync(htmlPath, "utf-8");
45424
+ const html = fs15.readFileSync(htmlPath, "utf-8");
45362
45425
  res.writeHead(200, { "Content-Type": "text/html; charset=utf-8" });
45363
45426
  res.end(html);
45364
45427
  } catch (e) {
@@ -45381,15 +45444,15 @@ var init_dev_server = __esm({
45381
45444
  this.json(res, 404, { error: "Not found" });
45382
45445
  return;
45383
45446
  }
45384
- const safePath = path21.normalize(pathname).replace(/^\.\.\//, "");
45385
- const filePath = path21.join(distDir, safePath);
45447
+ const safePath = path23.normalize(pathname).replace(/^\.\.\//, "");
45448
+ const filePath = path23.join(distDir, safePath);
45386
45449
  if (!filePath.startsWith(distDir)) {
45387
45450
  this.json(res, 403, { error: "Forbidden" });
45388
45451
  return;
45389
45452
  }
45390
45453
  try {
45391
- const content = fs14.readFileSync(filePath);
45392
- const ext = path21.extname(filePath);
45454
+ const content = fs15.readFileSync(filePath);
45455
+ const ext = path23.extname(filePath);
45393
45456
  const contentType = _DevServer.MIME_MAP[ext] || "application/octet-stream";
45394
45457
  res.writeHead(200, { "Content-Type": contentType, "Cache-Control": "public, max-age=31536000, immutable" });
45395
45458
  res.end(content);
@@ -45497,14 +45560,14 @@ var init_dev_server = __esm({
45497
45560
  const files = [];
45498
45561
  const scan = (d, prefix) => {
45499
45562
  try {
45500
- for (const entry of fs14.readdirSync(d, { withFileTypes: true })) {
45563
+ for (const entry of fs15.readdirSync(d, { withFileTypes: true })) {
45501
45564
  if (entry.name.startsWith(".") || entry.name.endsWith(".bak")) continue;
45502
45565
  const rel = prefix ? `${prefix}/${entry.name}` : entry.name;
45503
45566
  if (entry.isDirectory()) {
45504
45567
  files.push({ path: rel, size: 0, type: "dir" });
45505
- scan(path21.join(d, entry.name), rel);
45568
+ scan(path23.join(d, entry.name), rel);
45506
45569
  } else {
45507
- const stat4 = fs14.statSync(path21.join(d, entry.name));
45570
+ const stat4 = fs15.statSync(path23.join(d, entry.name));
45508
45571
  files.push({ path: rel, size: stat4.size, type: "file" });
45509
45572
  }
45510
45573
  }
@@ -45527,16 +45590,16 @@ var init_dev_server = __esm({
45527
45590
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
45528
45591
  return;
45529
45592
  }
45530
- const fullPath = path21.resolve(dir, path21.normalize(filePath));
45593
+ const fullPath = path23.resolve(dir, path23.normalize(filePath));
45531
45594
  if (!fullPath.startsWith(dir)) {
45532
45595
  this.json(res, 403, { error: "Forbidden" });
45533
45596
  return;
45534
45597
  }
45535
- if (!fs14.existsSync(fullPath) || fs14.statSync(fullPath).isDirectory()) {
45598
+ if (!fs15.existsSync(fullPath) || fs15.statSync(fullPath).isDirectory()) {
45536
45599
  this.json(res, 404, { error: `File not found: ${filePath}` });
45537
45600
  return;
45538
45601
  }
45539
- const content = fs14.readFileSync(fullPath, "utf-8");
45602
+ const content = fs15.readFileSync(fullPath, "utf-8");
45540
45603
  this.json(res, 200, { type, path: filePath, content, lines: content.split("\n").length });
45541
45604
  }
45542
45605
  /** POST /api/providers/:type/file — write a file { path, content } */
@@ -45552,15 +45615,15 @@ var init_dev_server = __esm({
45552
45615
  this.json(res, 404, { error: `Provider directory not found: ${type}` });
45553
45616
  return;
45554
45617
  }
45555
- const fullPath = path21.resolve(dir, path21.normalize(filePath));
45618
+ const fullPath = path23.resolve(dir, path23.normalize(filePath));
45556
45619
  if (!fullPath.startsWith(dir)) {
45557
45620
  this.json(res, 403, { error: "Forbidden" });
45558
45621
  return;
45559
45622
  }
45560
45623
  try {
45561
- if (fs14.existsSync(fullPath)) fs14.copyFileSync(fullPath, fullPath + ".bak");
45562
- fs14.mkdirSync(path21.dirname(fullPath), { recursive: true });
45563
- fs14.writeFileSync(fullPath, content, "utf-8");
45624
+ if (fs15.existsSync(fullPath)) fs15.copyFileSync(fullPath, fullPath + ".bak");
45625
+ fs15.mkdirSync(path23.dirname(fullPath), { recursive: true });
45626
+ fs15.writeFileSync(fullPath, content, "utf-8");
45564
45627
  this.log(`File saved: ${fullPath} (${content.length} chars)`);
45565
45628
  this.providerLoader.reload();
45566
45629
  this.json(res, 200, { saved: true, path: filePath, chars: content.length });
@@ -45576,9 +45639,9 @@ var init_dev_server = __esm({
45576
45639
  return;
45577
45640
  }
45578
45641
  for (const name of ["scripts.js", "provider.json"]) {
45579
- const p = path21.join(dir, name);
45580
- if (fs14.existsSync(p)) {
45581
- const source = fs14.readFileSync(p, "utf-8");
45642
+ const p = path23.join(dir, name);
45643
+ if (fs15.existsSync(p)) {
45644
+ const source = fs15.readFileSync(p, "utf-8");
45582
45645
  this.json(res, 200, { type, path: p, source, lines: source.split("\n").length });
45583
45646
  return;
45584
45647
  }
@@ -45597,11 +45660,11 @@ var init_dev_server = __esm({
45597
45660
  this.json(res, 404, { error: `Provider not found: ${type}` });
45598
45661
  return;
45599
45662
  }
45600
- const target = fs14.existsSync(path21.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
45601
- const targetPath = path21.join(dir, target);
45663
+ const target = fs15.existsSync(path23.join(dir, "scripts.js")) ? "scripts.js" : "provider.json";
45664
+ const targetPath = path23.join(dir, target);
45602
45665
  try {
45603
- if (fs14.existsSync(targetPath)) fs14.copyFileSync(targetPath, targetPath + ".bak");
45604
- fs14.writeFileSync(targetPath, source, "utf-8");
45666
+ if (fs15.existsSync(targetPath)) fs15.copyFileSync(targetPath, targetPath + ".bak");
45667
+ fs15.writeFileSync(targetPath, source, "utf-8");
45605
45668
  this.log(`Saved provider: ${targetPath} (${source.length} chars)`);
45606
45669
  this.providerLoader.reload();
45607
45670
  this.json(res, 200, { saved: true, path: targetPath, chars: source.length });
@@ -45745,21 +45808,21 @@ var init_dev_server = __esm({
45745
45808
  }
45746
45809
  let targetDir;
45747
45810
  targetDir = this.providerLoader.getUserProviderDir(category, type);
45748
- const jsonPath = path21.join(targetDir, "provider.json");
45749
- if (fs14.existsSync(jsonPath)) {
45811
+ const jsonPath = path23.join(targetDir, "provider.json");
45812
+ if (fs15.existsSync(jsonPath)) {
45750
45813
  this.json(res, 409, { error: `Provider already exists at ${targetDir}`, path: targetDir });
45751
45814
  return;
45752
45815
  }
45753
45816
  try {
45754
45817
  const result = generateFiles(type, name, category, { cdpPorts, cli, processName, installPath, binary, extensionId, version: version2, osPaths, processNames });
45755
- fs14.mkdirSync(targetDir, { recursive: true });
45756
- fs14.writeFileSync(jsonPath, result["provider.json"], "utf-8");
45818
+ fs15.mkdirSync(targetDir, { recursive: true });
45819
+ fs15.writeFileSync(jsonPath, result["provider.json"], "utf-8");
45757
45820
  const createdFiles = ["provider.json"];
45758
45821
  if (result.files) {
45759
45822
  for (const [relPath, content] of Object.entries(result.files)) {
45760
- const fullPath = path21.join(targetDir, relPath);
45761
- fs14.mkdirSync(path21.dirname(fullPath), { recursive: true });
45762
- fs14.writeFileSync(fullPath, content, "utf-8");
45823
+ const fullPath = path23.join(targetDir, relPath);
45824
+ fs15.mkdirSync(path23.dirname(fullPath), { recursive: true });
45825
+ fs15.writeFileSync(fullPath, content, "utf-8");
45763
45826
  createdFiles.push(relPath);
45764
45827
  }
45765
45828
  }
@@ -45808,38 +45871,38 @@ var init_dev_server = __esm({
45808
45871
  }
45809
45872
  // ─── Phase 2: Auto-Implement Backend ───
45810
45873
  getLatestScriptVersionDir(scriptsDir) {
45811
- if (!fs14.existsSync(scriptsDir)) return null;
45812
- const versions = fs14.readdirSync(scriptsDir).filter((d) => {
45874
+ if (!fs15.existsSync(scriptsDir)) return null;
45875
+ const versions = fs15.readdirSync(scriptsDir).filter((d) => {
45813
45876
  try {
45814
- return fs14.statSync(path21.join(scriptsDir, d)).isDirectory();
45877
+ return fs15.statSync(path23.join(scriptsDir, d)).isDirectory();
45815
45878
  } catch {
45816
45879
  return false;
45817
45880
  }
45818
45881
  }).sort((a, b) => b.localeCompare(a, void 0, { numeric: true, sensitivity: "base" }));
45819
45882
  if (versions.length === 0) return null;
45820
- return path21.join(scriptsDir, versions[0]);
45883
+ return path23.join(scriptsDir, versions[0]);
45821
45884
  }
45822
45885
  resolveAutoImplWritableProviderDir(category, type, requestedDir) {
45823
- const canonicalUserDir = path21.resolve(this.providerLoader.getUserProviderDir(category, type));
45824
- const desiredDir = requestedDir ? path21.resolve(requestedDir) : canonicalUserDir;
45825
- const upstreamRoot = path21.resolve(this.providerLoader.getUpstreamDir());
45826
- if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path21.sep}`)) {
45886
+ const canonicalUserDir = path23.resolve(this.providerLoader.getUserProviderDir(category, type));
45887
+ const desiredDir = requestedDir ? path23.resolve(requestedDir) : canonicalUserDir;
45888
+ const upstreamRoot = path23.resolve(this.providerLoader.getUpstreamDir());
45889
+ if (desiredDir === upstreamRoot || desiredDir.startsWith(`${upstreamRoot}${path23.sep}`)) {
45827
45890
  return { dir: null, reason: `Refusing to write into upstream provider directory: ${desiredDir}` };
45828
45891
  }
45829
- if (path21.basename(desiredDir) !== type) {
45892
+ if (path23.basename(desiredDir) !== type) {
45830
45893
  return { dir: null, reason: `Requested writable provider directory must end with '${type}': ${desiredDir}` };
45831
45894
  }
45832
45895
  const sourceDir = this.findProviderDir(type);
45833
45896
  if (!sourceDir) {
45834
45897
  return { dir: null, reason: `Provider source directory not found for '${type}'` };
45835
45898
  }
45836
- if (!fs14.existsSync(desiredDir)) {
45837
- fs14.mkdirSync(path21.dirname(desiredDir), { recursive: true });
45838
- fs14.cpSync(sourceDir, desiredDir, { recursive: true });
45899
+ if (!fs15.existsSync(desiredDir)) {
45900
+ fs15.mkdirSync(path23.dirname(desiredDir), { recursive: true });
45901
+ fs15.cpSync(sourceDir, desiredDir, { recursive: true });
45839
45902
  this.log(`Auto-implement writable copy created: ${desiredDir}`);
45840
45903
  }
45841
- const providerJson = path21.join(desiredDir, "provider.json");
45842
- if (!fs14.existsSync(providerJson)) {
45904
+ const providerJson = path23.join(desiredDir, "provider.json");
45905
+ if (!fs15.existsSync(providerJson)) {
45843
45906
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
45844
45907
  }
45845
45908
  return { dir: desiredDir };
@@ -45874,7 +45937,7 @@ var init_dev_server = __esm({
45874
45937
  setMode: "set_mode.js"
45875
45938
  };
45876
45939
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
45877
- const scriptsDir = path21.join(providerDir, "scripts");
45940
+ const scriptsDir = path23.join(providerDir, "scripts");
45878
45941
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
45879
45942
  if (latestScriptsDir) {
45880
45943
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -45882,10 +45945,10 @@ var init_dev_server = __esm({
45882
45945
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
45883
45946
  lines.push("These are the ONLY files you are allowed to modify. Replace the TODO stubs with working implementations.");
45884
45947
  lines.push("");
45885
- for (const file2 of fs14.readdirSync(latestScriptsDir)) {
45948
+ for (const file2 of fs15.readdirSync(latestScriptsDir)) {
45886
45949
  if (file2.endsWith(".js") && targetFileNames.has(file2)) {
45887
45950
  try {
45888
- const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
45951
+ const content = fs15.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
45889
45952
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
45890
45953
  lines.push("```javascript");
45891
45954
  lines.push(content);
@@ -45895,14 +45958,14 @@ var init_dev_server = __esm({
45895
45958
  }
45896
45959
  }
45897
45960
  }
45898
- const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
45961
+ const refFiles = fs15.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
45899
45962
  if (refFiles.length > 0) {
45900
45963
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
45901
45964
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
45902
45965
  lines.push("");
45903
45966
  for (const file2 of refFiles) {
45904
45967
  try {
45905
- const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
45968
+ const content = fs15.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
45906
45969
  lines.push(`### \`${file2}\` \u{1F512}`);
45907
45970
  lines.push("```javascript");
45908
45971
  lines.push(content);
@@ -45943,11 +46006,11 @@ var init_dev_server = __esm({
45943
46006
  lines.push("");
45944
46007
  }
45945
46008
  }
45946
- const docsDir = path21.join(providerDir, "../../docs");
46009
+ const docsDir = path23.join(providerDir, "../../docs");
45947
46010
  const loadGuide = (name) => {
45948
46011
  try {
45949
- const p = path21.join(docsDir, name);
45950
- if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
46012
+ const p = path23.join(docsDir, name);
46013
+ if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
45951
46014
  } catch {
45952
46015
  }
45953
46016
  return null;
@@ -46120,7 +46183,7 @@ var init_dev_server = __esm({
46120
46183
  parseApproval: "parse_approval.js"
46121
46184
  };
46122
46185
  const targetFileNames = new Set(functions.map((fn) => funcToFile[fn]).filter(Boolean));
46123
- const scriptsDir = path21.join(providerDir, "scripts");
46186
+ const scriptsDir = path23.join(providerDir, "scripts");
46124
46187
  const latestScriptsDir = this.getLatestScriptVersionDir(scriptsDir);
46125
46188
  if (latestScriptsDir) {
46126
46189
  lines.push(`Scripts version directory: \`${latestScriptsDir}\``);
@@ -46128,11 +46191,11 @@ var init_dev_server = __esm({
46128
46191
  lines.push("## \u270F\uFE0F Target Files (EDIT THESE)");
46129
46192
  lines.push("These are the ONLY files you are allowed to modify. Replace TODO or heuristic-only logic with working PTY-aware implementations.");
46130
46193
  lines.push("");
46131
- for (const file2 of fs14.readdirSync(latestScriptsDir)) {
46194
+ for (const file2 of fs15.readdirSync(latestScriptsDir)) {
46132
46195
  if (!file2.endsWith(".js")) continue;
46133
46196
  if (!targetFileNames.has(file2)) continue;
46134
46197
  try {
46135
- const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
46198
+ const content = fs15.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
46136
46199
  lines.push(`### \`${file2}\` \u270F\uFE0F EDIT`);
46137
46200
  lines.push("```javascript");
46138
46201
  lines.push(content);
@@ -46141,14 +46204,14 @@ var init_dev_server = __esm({
46141
46204
  } catch {
46142
46205
  }
46143
46206
  }
46144
- const refFiles = fs14.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
46207
+ const refFiles = fs15.readdirSync(latestScriptsDir).filter((f) => f.endsWith(".js") && !targetFileNames.has(f));
46145
46208
  if (refFiles.length > 0) {
46146
46209
  lines.push("## \u{1F512} Other Scripts (REFERENCE ONLY \u2014 DO NOT EDIT)");
46147
46210
  lines.push("These files are shown for context only. Do NOT modify them under any circumstances.");
46148
46211
  lines.push("");
46149
46212
  for (const file2 of refFiles) {
46150
46213
  try {
46151
- const content = fs14.readFileSync(path21.join(latestScriptsDir, file2), "utf-8");
46214
+ const content = fs15.readFileSync(path23.join(latestScriptsDir, file2), "utf-8");
46152
46215
  lines.push(`### \`${file2}\` \u{1F512}`);
46153
46216
  lines.push("```javascript");
46154
46217
  lines.push(content);
@@ -46181,11 +46244,11 @@ var init_dev_server = __esm({
46181
46244
  lines.push("");
46182
46245
  }
46183
46246
  }
46184
- const docsDir = path21.join(providerDir, "../../docs");
46247
+ const docsDir = path23.join(providerDir, "../../docs");
46185
46248
  const loadGuide = (name) => {
46186
46249
  try {
46187
- const p = path21.join(docsDir, name);
46188
- if (fs14.existsSync(p)) return fs14.readFileSync(p, "utf-8");
46250
+ const p = path23.join(docsDir, name);
46251
+ if (fs15.existsSync(p)) return fs15.readFileSync(p, "utf-8");
46189
46252
  } catch {
46190
46253
  }
46191
46254
  return null;
@@ -46995,8 +47058,8 @@ async function installExtension(ide, extension) {
46995
47058
  const res = await fetch(extension.vsixUrl);
46996
47059
  if (res.ok) {
46997
47060
  const buffer = Buffer.from(await res.arrayBuffer());
46998
- const fs19 = await import("fs");
46999
- fs19.writeFileSync(vsixPath, buffer);
47061
+ const fs20 = await import("fs");
47062
+ fs20.writeFileSync(vsixPath, buffer);
47000
47063
  return new Promise((resolve16) => {
47001
47064
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
47002
47065
  (0, import_child_process11.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
@@ -48417,12 +48480,14 @@ var init_data_channel_router = __esm({
48417
48480
  });
48418
48481
 
48419
48482
  // src/daemon-p2p/screenshot-sender.ts
48420
- var CHUNK_SIZE, ScreenshotSender;
48483
+ var CHUNK_SIZE, MAX_INLINE_JSON_MESSAGE_BYTES, JSON_CHUNK_PAYLOAD_CHARS2, ScreenshotSender;
48421
48484
  var init_screenshot_sender = __esm({
48422
48485
  "src/daemon-p2p/screenshot-sender.ts"() {
48423
48486
  "use strict";
48424
48487
  init_log();
48425
48488
  CHUNK_SIZE = 6e4;
48489
+ MAX_INLINE_JSON_MESSAGE_BYTES = 6e4;
48490
+ JSON_CHUNK_PAYLOAD_CHARS2 = 16e3;
48426
48491
  ScreenshotSender = class {
48427
48492
  _ssDebugDone = false;
48428
48493
  sendStatus(peers, status) {
@@ -48461,16 +48526,43 @@ var init_screenshot_sender = __esm({
48461
48526
  }
48462
48527
  sendTopicUpdateToPeer(peer, update) {
48463
48528
  if (!peer?.dataChannel || peer.state !== "connected" || !peer.dataChannel.isOpen()) return false;
48529
+ const json2 = JSON.stringify({
48530
+ type: "topic_update",
48531
+ update
48532
+ });
48533
+ if (Buffer.byteLength(json2, "utf8") > MAX_INLINE_JSON_MESSAGE_BYTES) {
48534
+ return this.sendChunkedTopicUpdate(peer, update, json2);
48535
+ }
48464
48536
  try {
48465
- peer.dataChannel.sendMessage(JSON.stringify({
48466
- type: "topic_update",
48467
- update
48468
- }));
48537
+ peer.dataChannel.sendMessage(json2);
48469
48538
  return true;
48470
48539
  } catch {
48471
48540
  return false;
48472
48541
  }
48473
48542
  }
48543
+ sendChunkedTopicUpdate(peer, update, json2) {
48544
+ const topic = typeof update?.topic === "string" ? update.topic : "topic_update";
48545
+ const key = typeof update?.key === "string" ? update.key : "";
48546
+ const seq = typeof update?.seq === "number" ? update.seq : Date.now();
48547
+ const chunkId = `${topic}:${key}:${seq}:${Math.random().toString(36).slice(2, 8)}`;
48548
+ const total = Math.ceil(json2.length / JSON_CHUNK_PAYLOAD_CHARS2);
48549
+ logDebug(`topic_update chunked: peer=${peer.peerId || "unknown"} topic=${topic} key=${key || "-"} chars=${json2.length} chunks=${total}`);
48550
+ for (let index = 0; index < total; index += 1) {
48551
+ const chunk = json2.slice(index * JSON_CHUNK_PAYLOAD_CHARS2, (index + 1) * JSON_CHUNK_PAYLOAD_CHARS2);
48552
+ try {
48553
+ peer.dataChannel?.sendMessage(JSON.stringify({
48554
+ type: "topic_update_chunk",
48555
+ chunkId,
48556
+ index,
48557
+ total,
48558
+ data: chunk
48559
+ }));
48560
+ } catch {
48561
+ return false;
48562
+ }
48563
+ }
48564
+ return true;
48565
+ }
48474
48566
  /** Broadcast runtime session output to all connected peers */
48475
48567
  broadcastSessionOutput(peers, sessionId, data) {
48476
48568
  const msg = JSON.stringify({ type: "session_output", sessionId, data });
@@ -48901,12 +48993,12 @@ var init_peer_connection_manager = __esm({
48901
48993
  });
48902
48994
 
48903
48995
  // src/daemon-p2p/index.ts
48904
- var fs15, path23, import_node_module2, esmRequire, DaemonP2PSender;
48996
+ var fs16, path24, import_node_module2, esmRequire, DaemonP2PSender;
48905
48997
  var init_daemon_p2p = __esm({
48906
48998
  "src/daemon-p2p/index.ts"() {
48907
48999
  "use strict";
48908
- fs15 = __toESM(require("fs"));
48909
- path23 = __toESM(require("path"));
49000
+ fs16 = __toESM(require("fs"));
49001
+ path24 = __toESM(require("path"));
48910
49002
  import_node_module2 = require("module");
48911
49003
  init_src();
48912
49004
  init_data_channel_router();
@@ -48985,17 +49077,17 @@ ${e?.stack || ""}`);
48985
49077
  const prebuildKey = `${platform12}-${arch3}`;
48986
49078
  try {
48987
49079
  const candidates = [
48988
- path23.join(__dirname, "node_modules", "node-datachannel"),
48989
- path23.join(__dirname, "..", "node_modules", "node-datachannel"),
48990
- path23.join(__dirname, "..", "..", "node_modules", "node-datachannel")
49080
+ path24.join(__dirname, "node_modules", "node-datachannel"),
49081
+ path24.join(__dirname, "..", "node_modules", "node-datachannel"),
49082
+ path24.join(__dirname, "..", "..", "node_modules", "node-datachannel")
48991
49083
  ];
48992
49084
  for (const candidate of candidates) {
48993
- const prebuildPath = path23.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
48994
- if (fs15.existsSync(prebuildPath)) {
48995
- const targetDir = path23.join(candidate, "build", "Release");
48996
- const targetPath = path23.join(targetDir, "node_datachannel.node");
48997
- fs15.mkdirSync(targetDir, { recursive: true });
48998
- fs15.copyFileSync(prebuildPath, targetPath);
49085
+ const prebuildPath = path24.join(candidate, "prebuilds", prebuildKey, "node_datachannel.node");
49086
+ if (fs16.existsSync(prebuildPath)) {
49087
+ const targetDir = path24.join(candidate, "build", "Release");
49088
+ const targetPath = path24.join(targetDir, "node_datachannel.node");
49089
+ fs16.mkdirSync(targetDir, { recursive: true });
49090
+ fs16.copyFileSync(prebuildPath, targetPath);
48999
49091
  try {
49000
49092
  delete esmRequire.cache[esmRequire.resolve("node-datachannel")];
49001
49093
  } catch {
@@ -49362,27 +49454,27 @@ var require_process = __commonJS({
49362
49454
  var require_filesystem = __commonJS({
49363
49455
  "../../node_modules/detect-libc/lib/filesystem.js"(exports2, module2) {
49364
49456
  "use strict";
49365
- var fs19 = require("fs");
49457
+ var fs20 = require("fs");
49366
49458
  var LDD_PATH = "/usr/bin/ldd";
49367
49459
  var SELF_PATH = "/proc/self/exe";
49368
49460
  var MAX_LENGTH = 2048;
49369
- var readFileSync19 = (path28) => {
49370
- const fd = fs19.openSync(path28, "r");
49461
+ var readFileSync19 = (path29) => {
49462
+ const fd = fs20.openSync(path29, "r");
49371
49463
  const buffer = Buffer.alloc(MAX_LENGTH);
49372
- const bytesRead = fs19.readSync(fd, buffer, 0, MAX_LENGTH, 0);
49373
- fs19.close(fd, () => {
49464
+ const bytesRead = fs20.readSync(fd, buffer, 0, MAX_LENGTH, 0);
49465
+ fs20.close(fd, () => {
49374
49466
  });
49375
49467
  return buffer.subarray(0, bytesRead);
49376
49468
  };
49377
- var readFile = (path28) => new Promise((resolve16, reject) => {
49378
- fs19.open(path28, "r", (err, fd) => {
49469
+ var readFile = (path29) => new Promise((resolve16, reject) => {
49470
+ fs20.open(path29, "r", (err, fd) => {
49379
49471
  if (err) {
49380
49472
  reject(err);
49381
49473
  } else {
49382
49474
  const buffer = Buffer.alloc(MAX_LENGTH);
49383
- fs19.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
49475
+ fs20.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
49384
49476
  resolve16(buffer.subarray(0, bytesRead));
49385
- fs19.close(fd, () => {
49477
+ fs20.close(fd, () => {
49386
49478
  });
49387
49479
  });
49388
49480
  }
@@ -49494,11 +49586,11 @@ var require_detect_libc = __commonJS({
49494
49586
  }
49495
49587
  return null;
49496
49588
  };
49497
- var familyFromInterpreterPath = (path28) => {
49498
- if (path28) {
49499
- if (path28.includes("/ld-musl-")) {
49589
+ var familyFromInterpreterPath = (path29) => {
49590
+ if (path29) {
49591
+ if (path29.includes("/ld-musl-")) {
49500
49592
  return MUSL;
49501
- } else if (path28.includes("/ld-linux-")) {
49593
+ } else if (path29.includes("/ld-linux-")) {
49502
49594
  return GLIBC;
49503
49595
  }
49504
49596
  }
@@ -49545,8 +49637,8 @@ var require_detect_libc = __commonJS({
49545
49637
  cachedFamilyInterpreter = null;
49546
49638
  try {
49547
49639
  const selfContent = await readFile(SELF_PATH);
49548
- const path28 = interpreterPath(selfContent);
49549
- cachedFamilyInterpreter = familyFromInterpreterPath(path28);
49640
+ const path29 = interpreterPath(selfContent);
49641
+ cachedFamilyInterpreter = familyFromInterpreterPath(path29);
49550
49642
  } catch (e) {
49551
49643
  }
49552
49644
  return cachedFamilyInterpreter;
@@ -49558,8 +49650,8 @@ var require_detect_libc = __commonJS({
49558
49650
  cachedFamilyInterpreter = null;
49559
49651
  try {
49560
49652
  const selfContent = readFileSync19(SELF_PATH);
49561
- const path28 = interpreterPath(selfContent);
49562
- cachedFamilyInterpreter = familyFromInterpreterPath(path28);
49653
+ const path29 = interpreterPath(selfContent);
49654
+ cachedFamilyInterpreter = familyFromInterpreterPath(path29);
49563
49655
  } catch (e) {
49564
49656
  }
49565
49657
  return cachedFamilyInterpreter;
@@ -51278,18 +51370,18 @@ var require_sharp = __commonJS({
51278
51370
  `@img/sharp-${runtimePlatform}/sharp.node`,
51279
51371
  "@img/sharp-wasm32/sharp.node"
51280
51372
  ];
51281
- var path28;
51373
+ var path29;
51282
51374
  var sharp;
51283
51375
  var errors = [];
51284
- for (path28 of paths) {
51376
+ for (path29 of paths) {
51285
51377
  try {
51286
- sharp = require(path28);
51378
+ sharp = require(path29);
51287
51379
  break;
51288
51380
  } catch (err) {
51289
51381
  errors.push(err);
51290
51382
  }
51291
51383
  }
51292
- if (sharp && path28.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
51384
+ if (sharp && path29.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
51293
51385
  const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
51294
51386
  err.code = "Unsupported CPU";
51295
51387
  errors.push(err);
@@ -51298,7 +51390,7 @@ var require_sharp = __commonJS({
51298
51390
  if (sharp) {
51299
51391
  module2.exports = sharp;
51300
51392
  } else {
51301
- const [isLinux2, isMacOs, isWindows2] = ["linux", "darwin", "win32"].map((os28) => runtimePlatform.startsWith(os28));
51393
+ const [isLinux2, isMacOs, isWindows2] = ["linux", "darwin", "win32"].map((os29) => runtimePlatform.startsWith(os29));
51302
51394
  const help = [`Could not load the "sharp" module using the ${runtimePlatform} runtime`];
51303
51395
  errors.forEach((err) => {
51304
51396
  if (err.code !== "MODULE_NOT_FOUND") {
@@ -51315,15 +51407,15 @@ var require_sharp = __commonJS({
51315
51407
  ` Requires ${expected}`
51316
51408
  );
51317
51409
  } else if (prebuiltPlatforms.includes(runtimePlatform)) {
51318
- const [os28, cpu] = runtimePlatform.split("-");
51319
- const libc = os28.endsWith("musl") ? " --libc=musl" : "";
51410
+ const [os29, cpu] = runtimePlatform.split("-");
51411
+ const libc = os29.endsWith("musl") ? " --libc=musl" : "";
51320
51412
  help.push(
51321
51413
  "- Ensure optional dependencies can be installed:",
51322
51414
  " npm install --include=optional sharp",
51323
51415
  "- Ensure your package manager supports multi-platform installation:",
51324
51416
  " See https://sharp.pixelplumbing.com/install#cross-platform",
51325
51417
  "- Add platform-specific dependencies:",
51326
- ` npm install --os=${os28.replace("musl", "")}${libc} --cpu=${cpu} sharp`
51418
+ ` npm install --os=${os29.replace("musl", "")}${libc} --cpu=${cpu} sharp`
51327
51419
  );
51328
51420
  } else {
51329
51421
  help.push(
@@ -54198,15 +54290,15 @@ var require_color = __commonJS({
54198
54290
  };
54199
54291
  }
54200
54292
  function wrapConversion(toModel, graph) {
54201
- const path28 = [graph[toModel].parent, toModel];
54293
+ const path29 = [graph[toModel].parent, toModel];
54202
54294
  let fn = conversions_default[graph[toModel].parent][toModel];
54203
54295
  let cur = graph[toModel].parent;
54204
54296
  while (graph[cur].parent) {
54205
- path28.unshift(graph[cur].parent);
54297
+ path29.unshift(graph[cur].parent);
54206
54298
  fn = link(conversions_default[graph[cur].parent][cur], fn);
54207
54299
  cur = graph[cur].parent;
54208
54300
  }
54209
- fn.conversion = path28;
54301
+ fn.conversion = path29;
54210
54302
  return fn;
54211
54303
  }
54212
54304
  function route(fromModel) {
@@ -54823,7 +54915,7 @@ var require_channel = __commonJS({
54823
54915
  var require_output = __commonJS({
54824
54916
  "../../node_modules/sharp/lib/output.js"(exports2, module2) {
54825
54917
  "use strict";
54826
- var path28 = require("path");
54918
+ var path29 = require("path");
54827
54919
  var is = require_is();
54828
54920
  var sharp = require_sharp();
54829
54921
  var formats = /* @__PURE__ */ new Map([
@@ -54854,9 +54946,9 @@ var require_output = __commonJS({
54854
54946
  let err;
54855
54947
  if (!is.string(fileOut)) {
54856
54948
  err = new Error("Missing output file path");
54857
- } else if (is.string(this.options.input.file) && path28.resolve(this.options.input.file) === path28.resolve(fileOut)) {
54949
+ } else if (is.string(this.options.input.file) && path29.resolve(this.options.input.file) === path29.resolve(fileOut)) {
54858
54950
  err = new Error("Cannot use same file for input and output");
54859
- } else if (jp2Regex.test(path28.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
54951
+ } else if (jp2Regex.test(path29.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
54860
54952
  err = errJp2Save();
54861
54953
  }
54862
54954
  if (err) {
@@ -56130,21 +56222,21 @@ function quarantineLegacyStandaloneSessions(options) {
56130
56222
  if (shouldSkipForExplicitOverride(env3)) {
56131
56223
  return { movedCount: 0, skippedActiveCount: 0, backupDir: null };
56132
56224
  }
56133
- const homeDir = options.homeDir || os23.homedir();
56225
+ const homeDir = options.homeDir || os24.homedir();
56134
56226
  const now = options.now || (() => /* @__PURE__ */ new Date());
56135
56227
  const isPidRunning = options.isPidRunning || defaultPidRunning;
56136
- const runtimesDir = path24.join(homeDir, ".adhdev", "session-host", options.appName, "runtimes");
56137
- if (!fs16.existsSync(runtimesDir)) {
56228
+ const runtimesDir = path25.join(homeDir, ".adhdev", "session-host", options.appName, "runtimes");
56229
+ if (!fs17.existsSync(runtimesDir)) {
56138
56230
  return { movedCount: 0, skippedActiveCount: 0, backupDir: null };
56139
56231
  }
56140
- const candidates = fs16.readdirSync(runtimesDir).filter((name) => name.endsWith(".json")).map((name) => path24.join(runtimesDir, name));
56232
+ const candidates = fs17.readdirSync(runtimesDir).filter((name) => name.endsWith(".json")).map((name) => path25.join(runtimesDir, name));
56141
56233
  let movedCount = 0;
56142
56234
  let skippedActiveCount = 0;
56143
56235
  let backupDir = null;
56144
56236
  for (const sourcePath of candidates) {
56145
56237
  let parsed;
56146
56238
  try {
56147
- parsed = JSON.parse(fs16.readFileSync(sourcePath, "utf8"));
56239
+ parsed = JSON.parse(fs17.readFileSync(sourcePath, "utf8"));
56148
56240
  } catch {
56149
56241
  continue;
56150
56242
  }
@@ -56155,26 +56247,26 @@ function quarantineLegacyStandaloneSessions(options) {
56155
56247
  continue;
56156
56248
  }
56157
56249
  if (!backupDir) {
56158
- backupDir = path24.join(
56250
+ backupDir = path25.join(
56159
56251
  homeDir,
56160
56252
  ".adhdev",
56161
56253
  "session-host-backups",
56162
56254
  `legacy-standalone-${options.appName}-${formatTimestamp(now())}`
56163
56255
  );
56164
- fs16.mkdirSync(path24.join(backupDir, "runtimes"), { recursive: true });
56256
+ fs17.mkdirSync(path25.join(backupDir, "runtimes"), { recursive: true });
56165
56257
  }
56166
- fs16.renameSync(sourcePath, path24.join(backupDir, "runtimes", path24.basename(sourcePath)));
56258
+ fs17.renameSync(sourcePath, path25.join(backupDir, "runtimes", path25.basename(sourcePath)));
56167
56259
  movedCount += 1;
56168
56260
  }
56169
56261
  return { movedCount, skippedActiveCount, backupDir };
56170
56262
  }
56171
- var fs16, os23, path24, LEGACY_STANDALONE_MANAGER_TAG;
56263
+ var fs17, os24, path25, LEGACY_STANDALONE_MANAGER_TAG;
56172
56264
  var init_session_host_hygiene = __esm({
56173
56265
  "src/session-host-hygiene.ts"() {
56174
56266
  "use strict";
56175
- fs16 = __toESM(require("fs"));
56176
- os23 = __toESM(require("os"));
56177
- path24 = __toESM(require("path"));
56267
+ fs17 = __toESM(require("fs"));
56268
+ os24 = __toESM(require("os"));
56269
+ path25 = __toESM(require("path"));
56178
56270
  init_src();
56179
56271
  LEGACY_STANDALONE_MANAGER_TAG = "adhdev-standalone";
56180
56272
  }
@@ -56188,18 +56280,18 @@ function buildSessionHostEnv(baseEnv) {
56188
56280
  }
56189
56281
  function resolveSessionHostEntry() {
56190
56282
  const packagedCandidates = [
56191
- path25.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
56192
- path25.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
56283
+ path26.resolve(__dirname, "../vendor/session-host-daemon/index.js"),
56284
+ path26.resolve(__dirname, "../../vendor/session-host-daemon/index.js")
56193
56285
  ];
56194
56286
  for (const candidate of packagedCandidates) {
56195
- if (fs17.existsSync(candidate)) {
56287
+ if (fs18.existsSync(candidate)) {
56196
56288
  return candidate;
56197
56289
  }
56198
56290
  }
56199
56291
  return require.resolve("@adhdev/session-host-daemon");
56200
56292
  }
56201
56293
  function getSessionHostPidFile() {
56202
- return path25.join(os24.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
56294
+ return path26.join(os25.homedir(), ".adhdev", `${SESSION_HOST_APP_NAME}-session-host.pid`);
56203
56295
  }
56204
56296
  function killPid2(pid) {
56205
56297
  try {
@@ -56265,8 +56357,8 @@ function stopManagedSessionHostProcess() {
56265
56357
  let stopped = false;
56266
56358
  const pidFile = getSessionHostPidFile();
56267
56359
  try {
56268
- if (fs17.existsSync(pidFile)) {
56269
- const pid = Number.parseInt(fs17.readFileSync(pidFile, "utf8").trim(), 10);
56360
+ if (fs18.existsSync(pidFile)) {
56361
+ const pid = Number.parseInt(fs18.readFileSync(pidFile, "utf8").trim(), 10);
56270
56362
  if (Number.isFinite(pid) && pid !== process.pid && isManagedSessionHostPid2(pid)) {
56271
56363
  stopped = killPid2(pid) || stopped;
56272
56364
  }
@@ -56274,7 +56366,7 @@ function stopManagedSessionHostProcess() {
56274
56366
  } catch {
56275
56367
  } finally {
56276
56368
  try {
56277
- fs17.unlinkSync(pidFile);
56369
+ fs18.unlinkSync(pidFile);
56278
56370
  } catch {
56279
56371
  }
56280
56372
  }
@@ -56302,9 +56394,9 @@ async function ensureSessionHostReady2() {
56302
56394
  }
56303
56395
  const spawnHost = () => {
56304
56396
  const entry = resolveSessionHostEntry();
56305
- const logDir = path25.join(os24.homedir(), ".adhdev", "logs");
56306
- fs17.mkdirSync(logDir, { recursive: true });
56307
- const logFd = fs17.openSync(path25.join(logDir, "session-host.log"), "a");
56397
+ const logDir = path26.join(os25.homedir(), ".adhdev", "logs");
56398
+ fs18.mkdirSync(logDir, { recursive: true });
56399
+ const logFd = fs18.openSync(path26.join(logDir, "session-host.log"), "a");
56308
56400
  const child = (0, import_child_process12.spawn)(process.execPath, [entry], {
56309
56401
  detached: true,
56310
56402
  stdio: ["ignore", logFd, logFd],
@@ -56313,7 +56405,7 @@ async function ensureSessionHostReady2() {
56313
56405
  });
56314
56406
  child.unref();
56315
56407
  try {
56316
- fs17.closeSync(logFd);
56408
+ fs18.closeSync(logFd);
56317
56409
  } catch {
56318
56410
  }
56319
56411
  };
@@ -56339,14 +56431,14 @@ async function ensureSessionHostReady2() {
56339
56431
  async function listHostedCliRuntimes2(endpoint) {
56340
56432
  return listHostedCliRuntimes(endpoint);
56341
56433
  }
56342
- var import_child_process12, fs17, os24, path25, SESSION_HOST_APP_NAME, SESSION_HOST_START_TIMEOUT_MS;
56434
+ var import_child_process12, fs18, os25, path26, SESSION_HOST_APP_NAME, SESSION_HOST_START_TIMEOUT_MS;
56343
56435
  var init_session_host = __esm({
56344
56436
  "src/session-host.ts"() {
56345
56437
  "use strict";
56346
56438
  import_child_process12 = require("child_process");
56347
- fs17 = __toESM(require("fs"));
56348
- os24 = __toESM(require("os"));
56349
- path25 = __toESM(require("path"));
56439
+ fs18 = __toESM(require("fs"));
56440
+ os25 = __toESM(require("os"));
56441
+ path26 = __toESM(require("path"));
56350
56442
  init_src();
56351
56443
  init_dist();
56352
56444
  init_session_host_hygiene();
@@ -57124,22 +57216,22 @@ function resolveDaemonPort(ref = {}) {
57124
57216
  return Number.isFinite(ref.port) && Number(ref.port) > 0 ? Number(ref.port) : DEFAULT_DAEMON_PORT;
57125
57217
  }
57126
57218
  function getDaemonPidFile(ref = {}) {
57127
- const dir = path26.join(ref.homeDir || os26.homedir(), ".adhdev");
57128
- if (!fs18.existsSync(dir)) fs18.mkdirSync(dir, { recursive: true });
57219
+ const dir = path27.join(ref.homeDir || os27.homedir(), ".adhdev");
57220
+ if (!fs19.existsSync(dir)) fs19.mkdirSync(dir, { recursive: true });
57129
57221
  const port = resolveDaemonPort(ref);
57130
- return path26.join(dir, port === DEFAULT_DAEMON_PORT ? "daemon.pid" : `daemon-${port}.pid`);
57222
+ return path27.join(dir, port === DEFAULT_DAEMON_PORT ? "daemon.pid" : `daemon-${port}.pid`);
57131
57223
  }
57132
57224
  function writeDaemonPid(pid, ref = {}) {
57133
57225
  const pidFile = getDaemonPidFile(ref);
57134
57226
  try {
57135
- fs18.writeFileSync(pidFile, String(pid), { encoding: "utf-8", flag: "wx" });
57227
+ fs19.writeFileSync(pidFile, String(pid), { encoding: "utf-8", flag: "wx" });
57136
57228
  } catch {
57137
- fs18.writeFileSync(pidFile, String(pid), "utf-8");
57229
+ fs19.writeFileSync(pidFile, String(pid), "utf-8");
57138
57230
  }
57139
57231
  }
57140
57232
  function removeDaemonPid(ref = {}) {
57141
57233
  try {
57142
- fs18.unlinkSync(getDaemonPidFile(ref));
57234
+ fs19.unlinkSync(getDaemonPidFile(ref));
57143
57235
  } catch (e) {
57144
57236
  }
57145
57237
  }
@@ -57166,8 +57258,8 @@ function isDaemonRunning(ref = {}) {
57166
57258
  }
57167
57259
  const pidFile = getDaemonPidFile(ref);
57168
57260
  try {
57169
- if (!fs18.existsSync(pidFile)) return false;
57170
- const pid = parseInt(fs18.readFileSync(pidFile, "utf-8").trim());
57261
+ if (!fs19.existsSync(pidFile)) return false;
57262
+ const pid = parseInt(fs19.readFileSync(pidFile, "utf-8").trim());
57171
57263
  process.kill(pid, 0);
57172
57264
  if (!isAdhdevProcess(pid)) {
57173
57265
  removeDaemonPid(ref);
@@ -57244,8 +57336,8 @@ function getDaemonHealthPid(ref = {}) {
57244
57336
  function getDaemonPid(ref = {}) {
57245
57337
  const pidFile = getDaemonPidFile(ref);
57246
57338
  try {
57247
- if (fs18.existsSync(pidFile)) {
57248
- const pid = parseInt(fs18.readFileSync(pidFile, "utf-8").trim(), 10);
57339
+ if (fs19.existsSync(pidFile)) {
57340
+ const pid = parseInt(fs19.readFileSync(pidFile, "utf-8").trim(), 10);
57249
57341
  if (Number.isFinite(pid)) return pid;
57250
57342
  }
57251
57343
  } catch {
@@ -57256,8 +57348,8 @@ function stopDaemon(ref = {}) {
57256
57348
  const pidFile = getDaemonPidFile(ref);
57257
57349
  let pid = null;
57258
57350
  try {
57259
- if (fs18.existsSync(pidFile)) {
57260
- const pidFromFile = parseInt(fs18.readFileSync(pidFile, "utf-8").trim(), 10);
57351
+ if (fs19.existsSync(pidFile)) {
57352
+ const pidFromFile = parseInt(fs19.readFileSync(pidFile, "utf-8").trim(), 10);
57261
57353
  if (Number.isFinite(pidFromFile)) pid = pidFromFile;
57262
57354
  }
57263
57355
  } catch {
@@ -57276,7 +57368,7 @@ function stopDaemon(ref = {}) {
57276
57368
  return false;
57277
57369
  }
57278
57370
  }
57279
- var os26, fs18, path26, import_http, import_child_process13, import_ws3, pkgVersion, AdhdevDaemon;
57371
+ var os27, fs19, path27, import_http, import_child_process13, import_ws3, pkgVersion, AdhdevDaemon;
57280
57372
  var init_adhdev_daemon = __esm({
57281
57373
  "src/adhdev-daemon.ts"() {
57282
57374
  "use strict";
@@ -57288,9 +57380,9 @@ var init_adhdev_daemon = __esm({
57288
57380
  init_startup_restore_policy();
57289
57381
  init_dist();
57290
57382
  init_session_host_controller();
57291
- os26 = __toESM(require("os"));
57292
- fs18 = __toESM(require("fs"));
57293
- path26 = __toESM(require("path"));
57383
+ os27 = __toESM(require("os"));
57384
+ fs19 = __toESM(require("fs"));
57385
+ path27 = __toESM(require("path"));
57294
57386
  import_http = require("http");
57295
57387
  import_child_process13 = require("child_process");
57296
57388
  import_ws3 = require("ws");
@@ -57298,7 +57390,7 @@ var init_adhdev_daemon = __esm({
57298
57390
  init_version();
57299
57391
  init_src();
57300
57392
  init_runtime_defaults();
57301
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.50" });
57393
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.9.52" });
57302
57394
  AdhdevDaemon = class _AdhdevDaemon {
57303
57395
  localHttpServer = null;
57304
57396
  localWss = null;
@@ -57822,8 +57914,8 @@ ${err?.stack || ""}`);
57822
57914
  cliInfo: {
57823
57915
  type: "adhdev-daemon",
57824
57916
  version: pkgVersion,
57825
- platform: os26.platform(),
57826
- hostname: os26.hostname(),
57917
+ platform: os27.platform(),
57918
+ hostname: os27.hostname(),
57827
57919
  machineId: config2.machineId,
57828
57920
  instanceId
57829
57921
  }
@@ -69761,15 +69853,15 @@ var require_route = __commonJS({
69761
69853
  };
69762
69854
  }
69763
69855
  function wrapConversion(toModel, graph) {
69764
- const path28 = [graph[toModel].parent, toModel];
69856
+ const path29 = [graph[toModel].parent, toModel];
69765
69857
  let fn = conversions[graph[toModel].parent][toModel];
69766
69858
  let cur = graph[toModel].parent;
69767
69859
  while (graph[cur].parent) {
69768
- path28.unshift(graph[cur].parent);
69860
+ path29.unshift(graph[cur].parent);
69769
69861
  fn = link(conversions[graph[cur].parent][cur], fn);
69770
69862
  cur = graph[cur].parent;
69771
69863
  }
69772
- fn.conversion = path28;
69864
+ fn.conversion = path29;
69773
69865
  return fn;
69774
69866
  }
69775
69867
  module2.exports = function(fromModel) {
@@ -70166,7 +70258,7 @@ var require_has_flag = __commonJS({
70166
70258
  var require_supports_color = __commonJS({
70167
70259
  "../../node_modules/supports-color/index.js"(exports2, module2) {
70168
70260
  "use strict";
70169
- var os28 = require("os");
70261
+ var os29 = require("os");
70170
70262
  var tty3 = require("tty");
70171
70263
  var hasFlag3 = require_has_flag();
70172
70264
  var { env: env3 } = process;
@@ -70214,7 +70306,7 @@ var require_supports_color = __commonJS({
70214
70306
  return min;
70215
70307
  }
70216
70308
  if (process.platform === "win32") {
70217
- const osRelease = os28.release().split(".");
70309
+ const osRelease = os29.release().split(".");
70218
70310
  if (Number(osRelease[0]) >= 10 && Number(osRelease[2]) >= 10586) {
70219
70311
  return Number(osRelease[2]) >= 14931 ? 3 : 2;
70220
70312
  }
@@ -73067,7 +73159,7 @@ var require_buffer_list = __commonJS({
73067
73159
  }
73068
73160
  }, {
73069
73161
  key: "join",
73070
- value: function join30(s) {
73162
+ value: function join31(s) {
73071
73163
  if (this.length === 0) return "";
73072
73164
  var p = this.head;
73073
73165
  var ret = "" + p.data;
@@ -83190,10 +83282,10 @@ var require_lib2 = __commonJS({
83190
83282
  exports2.analyse = analyse;
83191
83283
  var detectFile = (filepath, opts = {}) => new Promise((resolve16, reject) => {
83192
83284
  let fd;
83193
- const fs19 = (0, node_1.default)();
83285
+ const fs20 = (0, node_1.default)();
83194
83286
  const handler = (err, buffer) => {
83195
83287
  if (fd) {
83196
- fs19.closeSync(fd);
83288
+ fs20.closeSync(fd);
83197
83289
  }
83198
83290
  if (err) {
83199
83291
  reject(err);
@@ -83205,9 +83297,9 @@ var require_lib2 = __commonJS({
83205
83297
  };
83206
83298
  const sampleSize = (opts === null || opts === void 0 ? void 0 : opts.sampleSize) || 0;
83207
83299
  if (sampleSize > 0) {
83208
- fd = fs19.openSync(filepath, "r");
83300
+ fd = fs20.openSync(filepath, "r");
83209
83301
  let sample = Buffer.allocUnsafe(sampleSize);
83210
- fs19.read(fd, sample, 0, sampleSize, opts.offset, (err, bytesRead) => {
83302
+ fs20.read(fd, sample, 0, sampleSize, opts.offset, (err, bytesRead) => {
83211
83303
  if (err) {
83212
83304
  handler(err, null);
83213
83305
  } else {
@@ -83219,22 +83311,22 @@ var require_lib2 = __commonJS({
83219
83311
  });
83220
83312
  return;
83221
83313
  }
83222
- fs19.readFile(filepath, handler);
83314
+ fs20.readFile(filepath, handler);
83223
83315
  });
83224
83316
  exports2.detectFile = detectFile;
83225
83317
  var detectFileSync = (filepath, opts = {}) => {
83226
- const fs19 = (0, node_1.default)();
83318
+ const fs20 = (0, node_1.default)();
83227
83319
  if (opts && opts.sampleSize) {
83228
- const fd = fs19.openSync(filepath, "r");
83320
+ const fd = fs20.openSync(filepath, "r");
83229
83321
  let sample = Buffer.allocUnsafe(opts.sampleSize);
83230
- const bytesRead = fs19.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
83322
+ const bytesRead = fs20.readSync(fd, sample, 0, opts.sampleSize, opts.offset);
83231
83323
  if (bytesRead < opts.sampleSize) {
83232
83324
  sample = sample.subarray(0, bytesRead);
83233
83325
  }
83234
- fs19.closeSync(fd);
83326
+ fs20.closeSync(fd);
83235
83327
  return (0, exports2.detect)(sample);
83236
83328
  }
83237
- return (0, exports2.detect)(fs19.readFileSync(filepath));
83329
+ return (0, exports2.detect)(fs20.readFileSync(filepath));
83238
83330
  };
83239
83331
  exports2.detectFileSync = detectFileSync;
83240
83332
  exports2.default = {
@@ -87126,7 +87218,7 @@ function splitStringBySpace(str) {
87126
87218
  }
87127
87219
  return pieces;
87128
87220
  }
87129
- var import_chardet, import_child_process14, import_fs7, import_node_path2, import_node_os4, import_node_crypto, import_iconv_lite, ExternalEditor;
87221
+ var import_chardet, import_child_process14, import_fs7, import_node_path2, import_node_os4, import_node_crypto2, import_iconv_lite, ExternalEditor;
87130
87222
  var init_esm2 = __esm({
87131
87223
  "../../node_modules/@inquirer/external-editor/dist/esm/index.js"() {
87132
87224
  "use strict";
@@ -87135,7 +87227,7 @@ var init_esm2 = __esm({
87135
87227
  import_fs7 = require("fs");
87136
87228
  import_node_path2 = __toESM(require("path"), 1);
87137
87229
  import_node_os4 = __toESM(require("os"), 1);
87138
- import_node_crypto = require("crypto");
87230
+ import_node_crypto2 = require("crypto");
87139
87231
  import_iconv_lite = __toESM(require_lib3(), 1);
87140
87232
  init_CreateFileError();
87141
87233
  init_LaunchEditorError();
@@ -87194,7 +87286,7 @@ var init_esm2 = __esm({
87194
87286
  createTemporaryFile() {
87195
87287
  try {
87196
87288
  const baseDir = this.fileOptions.dir ?? import_node_os4.default.tmpdir();
87197
- const id = (0, import_node_crypto.randomUUID)();
87289
+ const id = (0, import_node_crypto2.randomUUID)();
87198
87290
  const prefix = sanitizeAffix(this.fileOptions.prefix);
87199
87291
  const postfix = sanitizeAffix(this.fileOptions.postfix);
87200
87292
  const filename = `${prefix}${id}${postfix}`;
@@ -87639,9 +87731,9 @@ var init_prompt = __esm({
87639
87731
  init_utils();
87640
87732
  init_baseUI();
87641
87733
  _ = {
87642
- set: (obj, path28 = "", value) => {
87734
+ set: (obj, path29 = "", value) => {
87643
87735
  let pointer = obj;
87644
- path28.split(".").forEach((key, index, arr) => {
87736
+ path29.split(".").forEach((key, index, arr) => {
87645
87737
  if (key === "__proto__" || key === "constructor") return;
87646
87738
  if (index === arr.length - 1) {
87647
87739
  pointer[key] = value;
@@ -87651,8 +87743,8 @@ var init_prompt = __esm({
87651
87743
  pointer = pointer[key];
87652
87744
  });
87653
87745
  },
87654
- get: (obj, path28 = "", defaultValue) => {
87655
- const travel = (regexp) => String.prototype.split.call(path28, regexp).filter(Boolean).reduce(
87746
+ get: (obj, path29 = "", defaultValue) => {
87747
+ const travel = (regexp) => String.prototype.split.call(path29, regexp).filter(Boolean).reduce(
87656
87748
  // @ts-expect-error implicit any on res[key]
87657
87749
  (res, key) => res !== null && res !== void 0 ? res[key] : res,
87658
87750
  obj
@@ -89117,15 +89209,15 @@ async function loginFlow() {
89117
89209
  let verificationUrl;
89118
89210
  try {
89119
89211
  const config2 = loadConfig();
89120
- const os28 = await import("os");
89212
+ const os29 = await import("os");
89121
89213
  const res = await fetch(`${SERVER_URL}/auth/cli/init`, {
89122
89214
  method: "POST",
89123
89215
  headers: { "Content-Type": "application/json" },
89124
89216
  body: JSON.stringify({
89125
89217
  clientMachineId: config2.machineId,
89126
- hostname: os28.hostname(),
89127
- platform: os28.platform(),
89128
- arch: os28.arch()
89218
+ hostname: os29.hostname(),
89219
+ platform: os29.platform(),
89220
+ arch: os29.arch()
89129
89221
  })
89130
89222
  });
89131
89223
  if (!res.ok) {
@@ -89230,8 +89322,8 @@ async function startDaemonFlow() {
89230
89322
  const { execSync: execSync7 } = await import("child_process");
89231
89323
  const { getCurrentDaemonLogPath: getCurrentDaemonLogPath2 } = await Promise.resolve().then(() => (init_src(), src_exports));
89232
89324
  const logPath = getCurrentDaemonLogPath2();
89233
- const os28 = await import("os");
89234
- const platform12 = os28.platform();
89325
+ const os29 = await import("os");
89326
+ const platform12 = os29.platform();
89235
89327
  try {
89236
89328
  if (platform12 === "win32") {
89237
89329
  execSync7("start /B adhdev daemon >NUL 2>&1", {