adhdev 0.9.50 → 0.9.51

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