adhdev 0.8.57 → 0.8.58

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli/index.js CHANGED
@@ -564,9 +564,16 @@ __export(config_exports, {
564
564
  loadConfig: () => loadConfig,
565
565
  markSetupComplete: () => markSetupComplete,
566
566
  resetConfig: () => resetConfig,
567
+ resolveProviderSourceMode: () => resolveProviderSourceMode,
567
568
  saveConfig: () => saveConfig,
568
569
  updateConfig: () => updateConfig
569
570
  });
571
+ function resolveProviderSourceMode(providerSourceMode, legacyDisableUpstream) {
572
+ if (providerSourceMode === "normal" || providerSourceMode === "no-upstream") {
573
+ return providerSourceMode;
574
+ }
575
+ return legacyDisableUpstream === true ? "no-upstream" : "normal";
576
+ }
570
577
  function isPlainObject(value) {
571
578
  return !!value && typeof value === "object" && !Array.isArray(value);
572
579
  }
@@ -604,7 +611,7 @@ function normalizeConfig(raw) {
604
611
  registeredMachineId: asOptionalString(parsed.registeredMachineId),
605
612
  providerSettings: isPlainObject(parsed.providerSettings) ? parsed.providerSettings : {},
606
613
  ideSettings: isPlainObject(parsed.ideSettings) ? parsed.ideSettings : {},
607
- disableUpstream: asBoolean(parsed.disableUpstream, DEFAULT_CONFIG.disableUpstream ?? false),
614
+ providerSourceMode: resolveProviderSourceMode(parsed.providerSourceMode, parsed.disableUpstream),
608
615
  providerDir: asOptionalString(parsed.providerDir),
609
616
  terminalSizingMode: parsed.terminalSizingMode === "fit" ? "fit" : "measured"
610
617
  };
@@ -753,7 +760,7 @@ var init_config = __esm({
753
760
  registeredMachineId: void 0,
754
761
  providerSettings: {},
755
762
  ideSettings: {},
756
- disableUpstream: false,
763
+ providerSourceMode: "normal",
757
764
  terminalSizingMode: "measured"
758
765
  };
759
766
  MACHINE_ID_PREFIX = "mach_";
@@ -1253,15 +1260,15 @@ function resolveCommandPath(command) {
1253
1260
  return null;
1254
1261
  }
1255
1262
  function execAsync(cmd, timeoutMs = 5e3) {
1256
- return new Promise((resolve18) => {
1263
+ return new Promise((resolve17) => {
1257
1264
  const child = (0, import_child_process2.exec)(cmd, { encoding: "utf-8", timeout: timeoutMs }, (err, stdout) => {
1258
1265
  if (err || !stdout?.trim()) {
1259
- resolve18(null);
1266
+ resolve17(null);
1260
1267
  } else {
1261
- resolve18(stdout.trim());
1268
+ resolve17(stdout.trim());
1262
1269
  }
1263
1270
  });
1264
- child.on("error", () => resolve18(null));
1271
+ child.on("error", () => resolve17(null));
1265
1272
  });
1266
1273
  }
1267
1274
  async function detectCLIs(providerLoader, options) {
@@ -1707,7 +1714,7 @@ var init_manager = __esm({
1707
1714
  * Returns multiple entries if multiple IDE windows are open on same port
1708
1715
  */
1709
1716
  static listAllTargets(port) {
1710
- return new Promise((resolve18) => {
1717
+ return new Promise((resolve17) => {
1711
1718
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
1712
1719
  let data = "";
1713
1720
  res.on("data", (chunk) => data += chunk.toString());
@@ -1723,16 +1730,16 @@ var init_manager = __esm({
1723
1730
  (t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
1724
1731
  );
1725
1732
  const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
1726
- resolve18(mainPages.length > 0 ? mainPages : fallbackPages);
1733
+ resolve17(mainPages.length > 0 ? mainPages : fallbackPages);
1727
1734
  } catch {
1728
- resolve18([]);
1735
+ resolve17([]);
1729
1736
  }
1730
1737
  });
1731
1738
  });
1732
- req.on("error", () => resolve18([]));
1739
+ req.on("error", () => resolve17([]));
1733
1740
  req.setTimeout(2e3, () => {
1734
1741
  req.destroy();
1735
- resolve18([]);
1742
+ resolve17([]);
1736
1743
  });
1737
1744
  });
1738
1745
  }
@@ -1772,7 +1779,7 @@ var init_manager = __esm({
1772
1779
  }
1773
1780
  }
1774
1781
  findTargetOnPort(port) {
1775
- return new Promise((resolve18) => {
1782
+ return new Promise((resolve17) => {
1776
1783
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
1777
1784
  let data = "";
1778
1785
  res.on("data", (chunk) => data += chunk.toString());
@@ -1783,7 +1790,7 @@ var init_manager = __esm({
1783
1790
  (t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
1784
1791
  );
1785
1792
  if (pages.length === 0) {
1786
- resolve18(targets.find((t) => t.webSocketDebuggerUrl) || null);
1793
+ resolve17(targets.find((t) => t.webSocketDebuggerUrl) || null);
1787
1794
  return;
1788
1795
  }
1789
1796
  const mainPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
@@ -1793,24 +1800,24 @@ var init_manager = __esm({
1793
1800
  const specific = list.find((t) => t.id === this._targetId);
1794
1801
  if (specific) {
1795
1802
  this._pageTitle = specific.title || "";
1796
- resolve18(specific);
1803
+ resolve17(specific);
1797
1804
  } else {
1798
1805
  this.log(`[CDP] Target ${this._targetId} not found in page list`);
1799
- resolve18(null);
1806
+ resolve17(null);
1800
1807
  }
1801
1808
  return;
1802
1809
  }
1803
1810
  this._pageTitle = list[0]?.title || "";
1804
- resolve18(list[0]);
1811
+ resolve17(list[0]);
1805
1812
  } catch {
1806
- resolve18(null);
1813
+ resolve17(null);
1807
1814
  }
1808
1815
  });
1809
1816
  });
1810
- req.on("error", () => resolve18(null));
1817
+ req.on("error", () => resolve17(null));
1811
1818
  req.setTimeout(2e3, () => {
1812
1819
  req.destroy();
1813
- resolve18(null);
1820
+ resolve17(null);
1814
1821
  });
1815
1822
  });
1816
1823
  }
@@ -1821,7 +1828,7 @@ var init_manager = __esm({
1821
1828
  this.extensionProviders = providers;
1822
1829
  }
1823
1830
  connectToTarget(wsUrl) {
1824
- return new Promise((resolve18) => {
1831
+ return new Promise((resolve17) => {
1825
1832
  this.ws = new import_ws.default(wsUrl);
1826
1833
  this.ws.on("open", async () => {
1827
1834
  this._connected = true;
@@ -1831,17 +1838,17 @@ var init_manager = __esm({
1831
1838
  }
1832
1839
  this.connectBrowserWs().catch(() => {
1833
1840
  });
1834
- resolve18(true);
1841
+ resolve17(true);
1835
1842
  });
1836
1843
  this.ws.on("message", (data) => {
1837
1844
  try {
1838
1845
  const msg = JSON.parse(data.toString());
1839
1846
  if (msg.id && this.pending.has(msg.id)) {
1840
- const { resolve: resolve19, reject } = this.pending.get(msg.id);
1847
+ const { resolve: resolve18, reject } = this.pending.get(msg.id);
1841
1848
  this.pending.delete(msg.id);
1842
1849
  this.failureCount = 0;
1843
1850
  if (msg.error) reject(new Error(msg.error.message));
1844
- else resolve19(msg.result);
1851
+ else resolve18(msg.result);
1845
1852
  } else if (msg.method === "Runtime.executionContextCreated") {
1846
1853
  this.contexts.add(msg.params.context.id);
1847
1854
  } else if (msg.method === "Runtime.executionContextDestroyed") {
@@ -1864,7 +1871,7 @@ var init_manager = __esm({
1864
1871
  this.ws.on("error", (err) => {
1865
1872
  this.log(`[CDP] WebSocket error: ${err.message}`);
1866
1873
  this._connected = false;
1867
- resolve18(false);
1874
+ resolve17(false);
1868
1875
  });
1869
1876
  });
1870
1877
  }
@@ -1878,7 +1885,7 @@ var init_manager = __esm({
1878
1885
  return;
1879
1886
  }
1880
1887
  this.log(`[CDP] Connecting browser WS for target discovery...`);
1881
- await new Promise((resolve18, reject) => {
1888
+ await new Promise((resolve17, reject) => {
1882
1889
  this.browserWs = new import_ws.default(browserWsUrl);
1883
1890
  this.browserWs.on("open", async () => {
1884
1891
  this._browserConnected = true;
@@ -1888,16 +1895,16 @@ var init_manager = __esm({
1888
1895
  } catch (e) {
1889
1896
  this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
1890
1897
  }
1891
- resolve18();
1898
+ resolve17();
1892
1899
  });
1893
1900
  this.browserWs.on("message", (data) => {
1894
1901
  try {
1895
1902
  const msg = JSON.parse(data.toString());
1896
1903
  if (msg.id && this.browserPending.has(msg.id)) {
1897
- const { resolve: resolve19, reject: reject2 } = this.browserPending.get(msg.id);
1904
+ const { resolve: resolve18, reject: reject2 } = this.browserPending.get(msg.id);
1898
1905
  this.browserPending.delete(msg.id);
1899
1906
  if (msg.error) reject2(new Error(msg.error.message));
1900
- else resolve19(msg.result);
1907
+ else resolve18(msg.result);
1901
1908
  }
1902
1909
  } catch {
1903
1910
  }
@@ -1917,31 +1924,31 @@ var init_manager = __esm({
1917
1924
  }
1918
1925
  }
1919
1926
  getBrowserWsUrl() {
1920
- return new Promise((resolve18) => {
1927
+ return new Promise((resolve17) => {
1921
1928
  const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
1922
1929
  let data = "";
1923
1930
  res.on("data", (chunk) => data += chunk.toString());
1924
1931
  res.on("end", () => {
1925
1932
  try {
1926
1933
  const info = JSON.parse(data);
1927
- resolve18(info.webSocketDebuggerUrl || null);
1934
+ resolve17(info.webSocketDebuggerUrl || null);
1928
1935
  } catch {
1929
- resolve18(null);
1936
+ resolve17(null);
1930
1937
  }
1931
1938
  });
1932
1939
  });
1933
- req.on("error", () => resolve18(null));
1940
+ req.on("error", () => resolve17(null));
1934
1941
  req.setTimeout(3e3, () => {
1935
1942
  req.destroy();
1936
- resolve18(null);
1943
+ resolve17(null);
1937
1944
  });
1938
1945
  });
1939
1946
  }
1940
1947
  sendBrowser(method, params = {}, timeoutMs = 15e3) {
1941
- return new Promise((resolve18, reject) => {
1948
+ return new Promise((resolve17, reject) => {
1942
1949
  if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
1943
1950
  const id = this.browserMsgId++;
1944
- this.browserPending.set(id, { resolve: resolve18, reject });
1951
+ this.browserPending.set(id, { resolve: resolve17, reject });
1945
1952
  this.browserWs.send(JSON.stringify({ id, method, params }));
1946
1953
  setTimeout(() => {
1947
1954
  if (this.browserPending.has(id)) {
@@ -1981,11 +1988,11 @@ var init_manager = __esm({
1981
1988
  }
1982
1989
  // ─── CDP Protocol ────────────────────────────────────────
1983
1990
  sendInternal(method, params = {}, timeoutMs = 15e3) {
1984
- return new Promise((resolve18, reject) => {
1991
+ return new Promise((resolve17, reject) => {
1985
1992
  if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
1986
1993
  if (this.ws.readyState !== import_ws.default.OPEN) return reject(new Error("WebSocket not open"));
1987
1994
  const id = this.msgId++;
1988
- this.pending.set(id, { resolve: resolve18, reject });
1995
+ this.pending.set(id, { resolve: resolve17, reject });
1989
1996
  this.ws.send(JSON.stringify({ id, method, params }));
1990
1997
  setTimeout(() => {
1991
1998
  if (this.pending.has(id)) {
@@ -2234,7 +2241,7 @@ var init_manager = __esm({
2234
2241
  const browserWs = this.browserWs;
2235
2242
  let msgId = this.browserMsgId;
2236
2243
  const sendWs = (method, params = {}, sessionId) => {
2237
- return new Promise((resolve18, reject) => {
2244
+ return new Promise((resolve17, reject) => {
2238
2245
  const mid = msgId++;
2239
2246
  this.browserMsgId = msgId;
2240
2247
  const handler = (raw) => {
@@ -2243,7 +2250,7 @@ var init_manager = __esm({
2243
2250
  if (msg.id === mid) {
2244
2251
  browserWs.removeListener("message", handler);
2245
2252
  if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
2246
- else resolve18(msg.result);
2253
+ else resolve17(msg.result);
2247
2254
  }
2248
2255
  } catch {
2249
2256
  }
@@ -2444,14 +2451,14 @@ var init_manager = __esm({
2444
2451
  if (!ws || ws.readyState !== import_ws.default.OPEN) {
2445
2452
  throw new Error("CDP not connected");
2446
2453
  }
2447
- return new Promise((resolve18, reject) => {
2454
+ return new Promise((resolve17, reject) => {
2448
2455
  const id = getNextId();
2449
2456
  pendingMap.set(id, {
2450
2457
  resolve: (result) => {
2451
2458
  if (result?.result?.subtype === "error") {
2452
2459
  reject(new Error(result.result.description));
2453
2460
  } else {
2454
- resolve18(result?.result?.value);
2461
+ resolve17(result?.result?.value);
2455
2462
  }
2456
2463
  },
2457
2464
  reject
@@ -2483,10 +2490,10 @@ var init_manager = __esm({
2483
2490
  throw new Error("CDP not connected");
2484
2491
  }
2485
2492
  const sendViaSession = (method, params = {}) => {
2486
- return new Promise((resolve18, reject) => {
2493
+ return new Promise((resolve17, reject) => {
2487
2494
  const pendingMap = this._browserConnected ? this.browserPending : this.pending;
2488
2495
  const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
2489
- pendingMap.set(id, { resolve: resolve18, reject });
2496
+ pendingMap.set(id, { resolve: resolve17, reject });
2490
2497
  ws.send(JSON.stringify({ id, sessionId, method, params }));
2491
2498
  setTimeout(() => {
2492
2499
  if (pendingMap.has(id)) {
@@ -3321,6 +3328,7 @@ function listSavedHistorySessions(agentType, options = {}) {
3321
3328
  let lastMessageAt = 0;
3322
3329
  let sessionTitle = "";
3323
3330
  let preview = "";
3331
+ let workspace = "";
3324
3332
  for (const file2 of files.sort()) {
3325
3333
  const filePath = path7.join(dir, file2);
3326
3334
  const content = fs3.readFileSync(filePath, "utf-8");
@@ -3333,6 +3341,10 @@ function listSavedHistorySessions(agentType, options = {}) {
3333
3341
  parsed = null;
3334
3342
  }
3335
3343
  if (!parsed || parsed.historySessionId !== historySessionId) continue;
3344
+ if (parsed.kind === "session_start") {
3345
+ if (!workspace && parsed.workspace) workspace = parsed.workspace;
3346
+ continue;
3347
+ }
3336
3348
  messageCount += 1;
3337
3349
  if (!firstMessageAt || parsed.receivedAt < firstMessageAt) firstMessageAt = parsed.receivedAt;
3338
3350
  if (!lastMessageAt || parsed.receivedAt > lastMessageAt) lastMessageAt = parsed.receivedAt;
@@ -3347,7 +3359,8 @@ function listSavedHistorySessions(agentType, options = {}) {
3347
3359
  messageCount,
3348
3360
  firstMessageAt,
3349
3361
  lastMessageAt,
3350
- preview: preview || void 0
3362
+ preview: preview || void 0,
3363
+ workspace: workspace || void 0
3351
3364
  });
3352
3365
  }
3353
3366
  summaries.sort((a, b) => b.lastMessageAt - a.lastMessageAt);
@@ -3530,6 +3543,30 @@ var init_chat_history = __esm({
3530
3543
  options.historySessionId
3531
3544
  );
3532
3545
  }
3546
+ writeSessionStart(agentType, historySessionId, workspace, instanceId) {
3547
+ const id = String(historySessionId || "").trim();
3548
+ const ws = String(workspace || "").trim();
3549
+ if (!id || !ws) return;
3550
+ try {
3551
+ const dir = path7.join(HISTORY_DIR, this.sanitize(agentType));
3552
+ fs3.mkdirSync(dir, { recursive: true });
3553
+ const date5 = (/* @__PURE__ */ new Date()).toISOString().slice(0, 10);
3554
+ const filePath = path7.join(dir, `${this.sanitize(id)}_${date5}.jsonl`);
3555
+ const record2 = {
3556
+ ts: (/* @__PURE__ */ new Date()).toISOString(),
3557
+ receivedAt: Date.now(),
3558
+ role: "system",
3559
+ kind: "session_start",
3560
+ content: ws,
3561
+ agent: agentType,
3562
+ instanceId,
3563
+ historySessionId: id,
3564
+ workspace: ws
3565
+ };
3566
+ fs3.appendFileSync(filePath, JSON.stringify(record2) + "\n", "utf-8");
3567
+ } catch {
3568
+ }
3569
+ }
3533
3570
  promoteHistorySession(agentType, previousHistorySessionId, nextHistorySessionId) {
3534
3571
  const fromId = String(previousHistorySessionId || "").trim();
3535
3572
  const toId = String(nextHistorySessionId || "").trim();
@@ -6122,7 +6159,7 @@ function getStateLastSignature(state) {
6122
6159
  async function getStableExtensionBaseline(h) {
6123
6160
  const first = await readExtensionChatState(h);
6124
6161
  if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
6125
- await new Promise((resolve18) => setTimeout(resolve18, 150));
6162
+ await new Promise((resolve17) => setTimeout(resolve17, 150));
6126
6163
  const second = await readExtensionChatState(h);
6127
6164
  return getStateMessageCount(second) >= getStateMessageCount(first) ? second : first;
6128
6165
  }
@@ -6130,7 +6167,7 @@ async function verifyExtensionSendObserved(h, before) {
6130
6167
  const beforeCount = getStateMessageCount(before);
6131
6168
  const beforeSignature = getStateLastSignature(before);
6132
6169
  for (let attempt = 0; attempt < 12; attempt += 1) {
6133
- await new Promise((resolve18) => setTimeout(resolve18, 250));
6170
+ await new Promise((resolve17) => setTimeout(resolve17, 250));
6134
6171
  const state = await readExtensionChatState(h);
6135
6172
  if (state?.status === "waiting_approval") return true;
6136
6173
  const afterCount = getStateMessageCount(state);
@@ -7340,6 +7377,32 @@ var init_cdp_commands = __esm({
7340
7377
  }
7341
7378
  });
7342
7379
 
7380
+ // ../../oss/packages/daemon-core/src/config/provider-source-config.ts
7381
+ function normalizeProviderDir(value) {
7382
+ if (typeof value !== "string") return void 0;
7383
+ const trimmed = value.trim();
7384
+ return trimmed ? trimmed : void 0;
7385
+ }
7386
+ function parseProviderSourceConfigUpdate(input) {
7387
+ const updates = {};
7388
+ if (Object.prototype.hasOwnProperty.call(input, "providerSourceMode")) {
7389
+ const { providerSourceMode } = input;
7390
+ if (providerSourceMode !== "normal" && providerSourceMode !== "no-upstream") {
7391
+ return { ok: false, error: "providerSourceMode must be 'normal' or 'no-upstream'" };
7392
+ }
7393
+ updates.providerSourceMode = providerSourceMode;
7394
+ }
7395
+ if (Object.prototype.hasOwnProperty.call(input, "providerDir")) {
7396
+ updates.providerDir = normalizeProviderDir(input.providerDir);
7397
+ }
7398
+ return { ok: true, updates };
7399
+ }
7400
+ var init_provider_source_config = __esm({
7401
+ "../../oss/packages/daemon-core/src/config/provider-source-config.ts"() {
7402
+ "use strict";
7403
+ }
7404
+ });
7405
+
7343
7406
  // ../../oss/packages/daemon-core/src/providers/cli-script-results.ts
7344
7407
  function parseCliScriptResult(result) {
7345
7408
  if (typeof result === "string") {
@@ -7456,6 +7519,38 @@ async function handleSetProviderSetting(h, args) {
7456
7519
  }
7457
7520
  return { success: false, error: `Failed to set ${providerType}.${key} \u2014 invalid key, value, or not a public setting` };
7458
7521
  }
7522
+ function handleGetProviderSourceConfig(h, _args) {
7523
+ const loader = h.ctx.providerLoader;
7524
+ if (!loader) return { success: false, error: "providerLoader not available" };
7525
+ return { success: true, ...loader.getSourceConfig() };
7526
+ }
7527
+ async function handleSetProviderSourceConfig(h, args) {
7528
+ const loader = h.ctx.providerLoader;
7529
+ if (!loader) return { success: false, error: "providerLoader not available" };
7530
+ const parsed = parseProviderSourceConfigUpdate(args || {});
7531
+ if ("error" in parsed) {
7532
+ return { success: false, error: parsed.error };
7533
+ }
7534
+ const currentConfig2 = loadConfig();
7535
+ const nextConfig = {
7536
+ ...currentConfig2,
7537
+ ...parsed.updates.providerSourceMode ? { providerSourceMode: parsed.updates.providerSourceMode } : {},
7538
+ ...Object.prototype.hasOwnProperty.call(parsed.updates, "providerDir") ? { providerDir: parsed.updates.providerDir } : {}
7539
+ };
7540
+ saveConfig(nextConfig);
7541
+ const sourceConfig = loader.applySourceConfig({
7542
+ sourceMode: nextConfig.providerSourceMode,
7543
+ userDir: Object.prototype.hasOwnProperty.call(parsed.updates, "providerDir") ? parsed.updates.providerDir : loader.getSourceConfig().explicitProviderDir || void 0
7544
+ });
7545
+ loader.reload();
7546
+ loader.registerToDetector();
7547
+ await h.ctx.onProviderSourceConfigChanged?.();
7548
+ LOG.info(
7549
+ "Command",
7550
+ `[set_provider_source_config] mode=${sourceConfig.sourceMode} explicitProviderDir=${sourceConfig.explicitProviderDir || "-"} userDir=${sourceConfig.userDir}`
7551
+ );
7552
+ return { success: true, reloaded: true, ...sourceConfig };
7553
+ }
7459
7554
  function normalizeProviderScriptArgs(args) {
7460
7555
  const normalizedArgs = { ...args || {} };
7461
7556
  for (const key of ["mode", "model", "message", "action", "button", "text", "sessionId", "value"]) {
@@ -7649,6 +7744,8 @@ function handleSetIdeExtension(h, args) {
7649
7744
  var init_stream_commands = __esm({
7650
7745
  "../../oss/packages/daemon-core/src/commands/stream-commands.ts"() {
7651
7746
  "use strict";
7747
+ init_config();
7748
+ init_provider_source_config();
7652
7749
  init_cli_script_results();
7653
7750
  init_control_effects();
7654
7751
  init_logger();
@@ -8176,6 +8273,10 @@ var init_handler = __esm({
8176
8273
  return handleGetProviderSettings(this, args);
8177
8274
  case "set_provider_setting":
8178
8275
  return handleSetProviderSetting(this, args);
8276
+ case "get_provider_source_config":
8277
+ return handleGetProviderSourceConfig(this, args);
8278
+ case "set_provider_source_config":
8279
+ return handleSetProviderSourceConfig(this, args);
8179
8280
  // ─── IDE Extension Settings (stream-commands.ts) ──────────
8180
8281
  case "get_ide_extensions":
8181
8282
  return handleGetIdeExtensions(this, args);
@@ -8215,7 +8316,7 @@ var init_handler = __esm({
8215
8316
  try {
8216
8317
  const http3 = await import("http");
8217
8318
  const postData = JSON.stringify(body);
8218
- const result = await new Promise((resolve18, reject) => {
8319
+ const result = await new Promise((resolve17, reject) => {
8219
8320
  const req = http3.request({
8220
8321
  hostname: "127.0.0.1",
8221
8322
  port: 19280,
@@ -8227,9 +8328,9 @@ var init_handler = __esm({
8227
8328
  res.on("data", (chunk) => data += chunk);
8228
8329
  res.on("end", () => {
8229
8330
  try {
8230
- resolve18(JSON.parse(data));
8331
+ resolve17(JSON.parse(data));
8231
8332
  } catch {
8232
- resolve18({ raw: data });
8333
+ resolve17({ raw: data });
8233
8334
  }
8234
8335
  });
8235
8336
  });
@@ -8247,15 +8348,15 @@ var init_handler = __esm({
8247
8348
  if (!providerType) return { success: false, error: "providerType required" };
8248
8349
  try {
8249
8350
  const http3 = await import("http");
8250
- const result = await new Promise((resolve18, reject) => {
8351
+ const result = await new Promise((resolve17, reject) => {
8251
8352
  http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
8252
8353
  let data = "";
8253
8354
  res.on("data", (chunk) => data += chunk);
8254
8355
  res.on("end", () => {
8255
8356
  try {
8256
- resolve18(JSON.parse(data));
8357
+ resolve17(JSON.parse(data));
8257
8358
  } catch {
8258
- resolve18({ raw: data });
8359
+ resolve17({ raw: data });
8259
8360
  }
8260
8361
  });
8261
8362
  }).on("error", reject);
@@ -8269,7 +8370,7 @@ var init_handler = __esm({
8269
8370
  try {
8270
8371
  const http3 = await import("http");
8271
8372
  const postData = JSON.stringify(args || {});
8272
- const result = await new Promise((resolve18, reject) => {
8373
+ const result = await new Promise((resolve17, reject) => {
8273
8374
  const req = http3.request({
8274
8375
  hostname: "127.0.0.1",
8275
8376
  port: 19280,
@@ -8281,9 +8382,9 @@ var init_handler = __esm({
8281
8382
  res.on("data", (chunk) => data += chunk);
8282
8383
  res.on("end", () => {
8283
8384
  try {
8284
- resolve18(JSON.parse(data));
8385
+ resolve17(JSON.parse(data));
8285
8386
  } catch {
8286
- resolve18({ raw: data });
8387
+ resolve17({ raw: data });
8287
8388
  }
8288
8389
  });
8289
8390
  });
@@ -10888,7 +10989,7 @@ var init_provider_cli_adapter = __esm({
10888
10989
  `[${this.cliType}] Waiting for interactive prompt: hasPrompt=${hasPrompt} stableMs=${stableMs} recentOutputMs=${recentlyOutput} status=${status} startup=${startupLikelyActive} screen=${JSON.stringify(summarizeCliTraceText(screenText, 220)).slice(0, 260)}`
10889
10990
  );
10890
10991
  }
10891
- await new Promise((resolve18) => setTimeout(resolve18, 50));
10992
+ await new Promise((resolve17) => setTimeout(resolve17, 50));
10892
10993
  }
10893
10994
  const finalScreenText = this.terminalScreen.getText() || "";
10894
10995
  LOG.warn(
@@ -11461,7 +11562,7 @@ ${data.message || ""}`.trim();
11461
11562
  const deadline = Date.now() + 1e4;
11462
11563
  while (this.startupParseGate && Date.now() < deadline) {
11463
11564
  this.resolveStartupState("send_wait");
11464
- await new Promise((resolve18) => setTimeout(resolve18, 50));
11565
+ await new Promise((resolve17) => setTimeout(resolve17, 50));
11465
11566
  }
11466
11567
  }
11467
11568
  await this.waitForInteractivePrompt();
@@ -11531,12 +11632,12 @@ ${data.message || ""}`.trim();
11531
11632
  if (this.isWaitingForResponse) this.finishResponse();
11532
11633
  }, this.timeouts.maxResponse);
11533
11634
  };
11534
- await new Promise((resolve18) => {
11635
+ await new Promise((resolve17) => {
11535
11636
  let resolved = false;
11536
11637
  const resolveOnce = () => {
11537
11638
  if (resolved) return;
11538
11639
  resolved = true;
11539
- resolve18();
11640
+ resolve17();
11540
11641
  };
11541
11642
  const submit = () => {
11542
11643
  if (!this.ptyProcess) {
@@ -11710,17 +11811,17 @@ ${data.message || ""}`.trim();
11710
11811
  }
11711
11812
  }
11712
11813
  waitForStopped(timeoutMs) {
11713
- return new Promise((resolve18) => {
11814
+ return new Promise((resolve17) => {
11714
11815
  const startedAt = Date.now();
11715
11816
  const timer = setInterval(() => {
11716
11817
  if (!this.ptyProcess || this.currentStatus === "stopped") {
11717
11818
  clearInterval(timer);
11718
- resolve18(true);
11819
+ resolve17(true);
11719
11820
  return;
11720
11821
  }
11721
11822
  if (Date.now() - startedAt >= timeoutMs) {
11722
11823
  clearInterval(timer);
11723
- resolve18(false);
11824
+ resolve17(false);
11724
11825
  }
11725
11826
  }, 100);
11726
11827
  });
@@ -12010,6 +12111,9 @@ function getForcedNewSessionScriptName(provider, launchMode) {
12010
12111
  const controls = Array.isArray(provider.controls) ? provider.controls : [];
12011
12112
  for (const control of controls) {
12012
12113
  if (control?.type !== "action") continue;
12114
+ if (typeof control?.confirmTitle === "string" && control.confirmTitle.trim()) continue;
12115
+ if (typeof control?.confirmMessage === "string" && control.confirmMessage.trim()) continue;
12116
+ if (typeof control?.confirmLabel === "string" && control.confirmLabel.trim()) continue;
12013
12117
  const invokeScript = typeof control?.invokeScript === "string" ? control.invokeScript.trim() : "";
12014
12118
  if (!invokeScript) continue;
12015
12119
  const controlId = typeof control?.id === "string" ? control.id.trim() : "";
@@ -12019,6 +12123,20 @@ function getForcedNewSessionScriptName(provider, launchMode) {
12019
12123
  }
12020
12124
  return null;
12021
12125
  }
12126
+ async function waitForCliAdapterReady(adapter, options) {
12127
+ const timeoutMs = Math.max(100, options?.timeoutMs ?? 15e3);
12128
+ const pollMs = Math.max(10, options?.pollMs ?? 50);
12129
+ const deadline = Date.now() + timeoutMs;
12130
+ while (Date.now() < deadline) {
12131
+ if (adapter?.isReady?.()) return;
12132
+ const status = adapter?.getStatus?.()?.status;
12133
+ if (status === "stopped") {
12134
+ throw new Error("CLI runtime stopped before it became ready");
12135
+ }
12136
+ await new Promise((resolve17) => setTimeout(resolve17, pollMs));
12137
+ }
12138
+ throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
12139
+ }
12022
12140
  var os14, path12, crypto3, fs5, import_node_module, CachedDatabaseSync, CliProviderInstance;
12023
12141
  var init_cli_provider_instance = __esm({
12024
12142
  "../../oss/packages/daemon-core/src/providers/cli-provider-instance.ts"() {
@@ -12315,6 +12433,7 @@ var init_cli_provider_instance = __esm({
12315
12433
  const scriptName = getForcedNewSessionScriptName(this.provider, this.launchMode);
12316
12434
  if (!scriptName) return;
12317
12435
  LOG.info("CLI", `[${this.type}] forcing fresh session launch via script: ${scriptName}`);
12436
+ await waitForCliAdapterReady(this.adapter);
12318
12437
  const raw = await this.adapter.invokeScript(scriptName, {});
12319
12438
  const parsed = parseCliScriptResult(raw);
12320
12439
  if (!parsed.success) {
@@ -12664,6 +12783,7 @@ ${effect.notification.body || ""}`.trim();
12664
12783
  const previousProviderSessionId = this.providerSessionId;
12665
12784
  this.providerSessionId = nextSessionId;
12666
12785
  this.historyWriter.promoteHistorySession(this.type, previousHistorySessionId, nextSessionId);
12786
+ this.historyWriter.writeSessionStart(this.type, nextSessionId, this.workingDir, this.instanceId);
12667
12787
  this.adapter.updateRuntimeMeta({ providerSessionId: nextSessionId });
12668
12788
  this.onProviderSessionResolved?.({
12669
12789
  instanceId: this.instanceId,
@@ -12965,10 +13085,10 @@ function mergeDefs(...defs) {
12965
13085
  function cloneDef(schema) {
12966
13086
  return mergeDefs(schema._zod.def);
12967
13087
  }
12968
- function getElementAtPath(obj, path35) {
12969
- if (!path35)
13088
+ function getElementAtPath(obj, path36) {
13089
+ if (!path36)
12970
13090
  return obj;
12971
- return path35.reduce((acc, key) => acc?.[key], obj);
13091
+ return path36.reduce((acc, key) => acc?.[key], obj);
12972
13092
  }
12973
13093
  function promiseAllObject(promisesObj) {
12974
13094
  const keys = Object.keys(promisesObj);
@@ -13280,11 +13400,11 @@ function aborted(x, startIndex = 0) {
13280
13400
  }
13281
13401
  return false;
13282
13402
  }
13283
- function prefixIssues(path35, issues) {
13403
+ function prefixIssues(path36, issues) {
13284
13404
  return issues.map((iss) => {
13285
13405
  var _a2;
13286
13406
  (_a2 = iss).path ?? (_a2.path = []);
13287
- iss.path.unshift(path35);
13407
+ iss.path.unshift(path36);
13288
13408
  return iss;
13289
13409
  });
13290
13410
  }
@@ -13527,7 +13647,7 @@ function formatError(error48, mapper = (issue2) => issue2.message) {
13527
13647
  }
13528
13648
  function treeifyError(error48, mapper = (issue2) => issue2.message) {
13529
13649
  const result = { errors: [] };
13530
- const processError = (error49, path35 = []) => {
13650
+ const processError = (error49, path36 = []) => {
13531
13651
  var _a2, _b;
13532
13652
  for (const issue2 of error49.issues) {
13533
13653
  if (issue2.code === "invalid_union" && issue2.errors.length) {
@@ -13537,7 +13657,7 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
13537
13657
  } else if (issue2.code === "invalid_element") {
13538
13658
  processError({ issues: issue2.issues }, issue2.path);
13539
13659
  } else {
13540
- const fullpath = [...path35, ...issue2.path];
13660
+ const fullpath = [...path36, ...issue2.path];
13541
13661
  if (fullpath.length === 0) {
13542
13662
  result.errors.push(mapper(issue2));
13543
13663
  continue;
@@ -13569,8 +13689,8 @@ function treeifyError(error48, mapper = (issue2) => issue2.message) {
13569
13689
  }
13570
13690
  function toDotPath(_path) {
13571
13691
  const segs = [];
13572
- const path35 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
13573
- for (const seg of path35) {
13692
+ const path36 = _path.map((seg) => typeof seg === "object" ? seg.key : seg);
13693
+ for (const seg of path36) {
13574
13694
  if (typeof seg === "number")
13575
13695
  segs.push(`[${seg}]`);
13576
13696
  else if (typeof seg === "symbol")
@@ -26334,13 +26454,13 @@ function resolveRef(ref, ctx) {
26334
26454
  if (!ref.startsWith("#")) {
26335
26455
  throw new Error("External $ref is not supported, only local refs (#/...) are allowed");
26336
26456
  }
26337
- const path35 = ref.slice(1).split("/").filter(Boolean);
26338
- if (path35.length === 0) {
26457
+ const path36 = ref.slice(1).split("/").filter(Boolean);
26458
+ if (path36.length === 0) {
26339
26459
  return ctx.rootSchema;
26340
26460
  }
26341
26461
  const defsKey = ctx.version === "draft-2020-12" ? "$defs" : "definitions";
26342
- if (path35[0] === defsKey) {
26343
- const key = path35[1];
26462
+ if (path36[0] === defsKey) {
26463
+ const key = path36[1];
26344
26464
  if (!key || !ctx.defs[key]) {
26345
26465
  throw new Error(`Reference not found: ${ref}`);
26346
26466
  }
@@ -28767,8 +28887,8 @@ var init_acp = __esm({
28767
28887
  this.#requestHandler = requestHandler;
28768
28888
  this.#notificationHandler = notificationHandler;
28769
28889
  this.#stream = stream;
28770
- this.#closedPromise = new Promise((resolve18) => {
28771
- this.#abortController.signal.addEventListener("abort", () => resolve18());
28890
+ this.#closedPromise = new Promise((resolve17) => {
28891
+ this.#abortController.signal.addEventListener("abort", () => resolve17());
28772
28892
  });
28773
28893
  this.#receive();
28774
28894
  }
@@ -28917,8 +29037,8 @@ var init_acp = __esm({
28917
29037
  }
28918
29038
  async sendRequest(method, params) {
28919
29039
  const id = this.#nextRequestId++;
28920
- const responsePromise = new Promise((resolve18, reject) => {
28921
- this.#pendingResponses.set(id, { resolve: resolve18, reject });
29040
+ const responsePromise = new Promise((resolve17, reject) => {
29041
+ this.#pendingResponses.set(id, { resolve: resolve17, reject });
28922
29042
  });
28923
29043
  await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
28924
29044
  return responsePromise;
@@ -29554,13 +29674,13 @@ var init_acp_provider_instance = __esm({
29554
29674
  }
29555
29675
  this.currentStatus = "waiting_approval";
29556
29676
  this.detectStatusTransition();
29557
- const approved = await new Promise((resolve18) => {
29558
- this.permissionResolvers.push(resolve18);
29677
+ const approved = await new Promise((resolve17) => {
29678
+ this.permissionResolvers.push(resolve17);
29559
29679
  setTimeout(() => {
29560
- const idx = this.permissionResolvers.indexOf(resolve18);
29680
+ const idx = this.permissionResolvers.indexOf(resolve17);
29561
29681
  if (idx >= 0) {
29562
29682
  this.permissionResolvers.splice(idx, 1);
29563
- resolve18(false);
29683
+ resolve17(false);
29564
29684
  }
29565
29685
  }, 3e5);
29566
29686
  });
@@ -30920,7 +31040,7 @@ var init_readdirp = __esm({
30920
31040
  this._directoryFilter = normalizeFilter(opts.directoryFilter);
30921
31041
  const statMethod = opts.lstat ? import_promises.lstat : import_promises.stat;
30922
31042
  if (wantBigintFsStats) {
30923
- this._stat = (path35) => statMethod(path35, { bigint: true });
31043
+ this._stat = (path36) => statMethod(path36, { bigint: true });
30924
31044
  } else {
30925
31045
  this._stat = statMethod;
30926
31046
  }
@@ -30945,8 +31065,8 @@ var init_readdirp = __esm({
30945
31065
  const par = this.parent;
30946
31066
  const fil = par && par.files;
30947
31067
  if (fil && fil.length > 0) {
30948
- const { path: path35, depth } = par;
30949
- const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path35));
31068
+ const { path: path36, depth } = par;
31069
+ const slice = fil.splice(0, batch).map((dirent) => this._formatEntry(dirent, path36));
30950
31070
  const awaited = await Promise.all(slice);
30951
31071
  for (const entry of awaited) {
30952
31072
  if (!entry)
@@ -30986,20 +31106,20 @@ var init_readdirp = __esm({
30986
31106
  this.reading = false;
30987
31107
  }
30988
31108
  }
30989
- async _exploreDir(path35, depth) {
31109
+ async _exploreDir(path36, depth) {
30990
31110
  let files;
30991
31111
  try {
30992
- files = await (0, import_promises.readdir)(path35, this._rdOptions);
31112
+ files = await (0, import_promises.readdir)(path36, this._rdOptions);
30993
31113
  } catch (error48) {
30994
31114
  this._onError(error48);
30995
31115
  }
30996
- return { files, depth, path: path35 };
31116
+ return { files, depth, path: path36 };
30997
31117
  }
30998
- async _formatEntry(dirent, path35) {
31118
+ async _formatEntry(dirent, path36) {
30999
31119
  let entry;
31000
31120
  const basename10 = this._isDirent ? dirent.name : dirent;
31001
31121
  try {
31002
- const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path35, basename10));
31122
+ const fullPath = (0, import_node_path.resolve)((0, import_node_path.join)(path36, basename10));
31003
31123
  entry = { path: (0, import_node_path.relative)(this._root, fullPath), fullPath, basename: basename10 };
31004
31124
  entry[this._statsProp] = this._isDirent ? dirent : await this._stat(fullPath);
31005
31125
  } catch (err) {
@@ -31056,16 +31176,16 @@ var init_readdirp = __esm({
31056
31176
  });
31057
31177
 
31058
31178
  // ../../oss/packages/daemon-core/node_modules/chokidar/handler.js
31059
- function createFsWatchInstance(path35, options, listener, errHandler, emitRaw) {
31179
+ function createFsWatchInstance(path36, options, listener, errHandler, emitRaw) {
31060
31180
  const handleEvent = (rawEvent, evPath) => {
31061
- listener(path35);
31062
- emitRaw(rawEvent, evPath, { watchedPath: path35 });
31063
- if (evPath && path35 !== evPath) {
31064
- fsWatchBroadcast(sp.resolve(path35, evPath), KEY_LISTENERS, sp.join(path35, evPath));
31181
+ listener(path36);
31182
+ emitRaw(rawEvent, evPath, { watchedPath: path36 });
31183
+ if (evPath && path36 !== evPath) {
31184
+ fsWatchBroadcast(sp.resolve(path36, evPath), KEY_LISTENERS, sp.join(path36, evPath));
31065
31185
  }
31066
31186
  };
31067
31187
  try {
31068
- return (0, import_node_fs.watch)(path35, {
31188
+ return (0, import_node_fs.watch)(path36, {
31069
31189
  persistent: options.persistent
31070
31190
  }, handleEvent);
31071
31191
  } catch (error48) {
@@ -31414,12 +31534,12 @@ var init_handler2 = __esm({
31414
31534
  listener(val1, val2, val3);
31415
31535
  });
31416
31536
  };
31417
- setFsWatchListener = (path35, fullPath, options, handlers) => {
31537
+ setFsWatchListener = (path36, fullPath, options, handlers) => {
31418
31538
  const { listener, errHandler, rawEmitter } = handlers;
31419
31539
  let cont = FsWatchInstances.get(fullPath);
31420
31540
  let watcher;
31421
31541
  if (!options.persistent) {
31422
- watcher = createFsWatchInstance(path35, options, listener, errHandler, rawEmitter);
31542
+ watcher = createFsWatchInstance(path36, options, listener, errHandler, rawEmitter);
31423
31543
  if (!watcher)
31424
31544
  return;
31425
31545
  return watcher.close.bind(watcher);
@@ -31430,7 +31550,7 @@ var init_handler2 = __esm({
31430
31550
  addAndConvert(cont, KEY_RAW, rawEmitter);
31431
31551
  } else {
31432
31552
  watcher = createFsWatchInstance(
31433
- path35,
31553
+ path36,
31434
31554
  options,
31435
31555
  fsWatchBroadcast.bind(null, fullPath, KEY_LISTENERS),
31436
31556
  errHandler,
@@ -31445,7 +31565,7 @@ var init_handler2 = __esm({
31445
31565
  cont.watcherUnusable = true;
31446
31566
  if (isWindows && error48.code === "EPERM") {
31447
31567
  try {
31448
- const fd = await (0, import_promises2.open)(path35, "r");
31568
+ const fd = await (0, import_promises2.open)(path36, "r");
31449
31569
  await fd.close();
31450
31570
  broadcastErr(error48);
31451
31571
  } catch (err) {
@@ -31476,7 +31596,7 @@ var init_handler2 = __esm({
31476
31596
  };
31477
31597
  };
31478
31598
  FsWatchFileInstances = /* @__PURE__ */ new Map();
31479
- setFsWatchFileListener = (path35, fullPath, options, handlers) => {
31599
+ setFsWatchFileListener = (path36, fullPath, options, handlers) => {
31480
31600
  const { listener, rawEmitter } = handlers;
31481
31601
  let cont = FsWatchFileInstances.get(fullPath);
31482
31602
  const copts = cont && cont.options;
@@ -31498,7 +31618,7 @@ var init_handler2 = __esm({
31498
31618
  });
31499
31619
  const currmtime = curr.mtimeMs;
31500
31620
  if (curr.size !== prev.size || currmtime > prev.mtimeMs || currmtime === 0) {
31501
- foreach(cont.listeners, (listener2) => listener2(path35, curr));
31621
+ foreach(cont.listeners, (listener2) => listener2(path36, curr));
31502
31622
  }
31503
31623
  })
31504
31624
  };
@@ -31528,13 +31648,13 @@ var init_handler2 = __esm({
31528
31648
  * @param listener on fs change
31529
31649
  * @returns closer for the watcher instance
31530
31650
  */
31531
- _watchWithNodeFs(path35, listener) {
31651
+ _watchWithNodeFs(path36, listener) {
31532
31652
  const opts = this.fsw.options;
31533
- const directory = sp.dirname(path35);
31534
- const basename10 = sp.basename(path35);
31653
+ const directory = sp.dirname(path36);
31654
+ const basename10 = sp.basename(path36);
31535
31655
  const parent = this.fsw._getWatchedDir(directory);
31536
31656
  parent.add(basename10);
31537
- const absolutePath = sp.resolve(path35);
31657
+ const absolutePath = sp.resolve(path36);
31538
31658
  const options = {
31539
31659
  persistent: opts.persistent
31540
31660
  };
@@ -31544,12 +31664,12 @@ var init_handler2 = __esm({
31544
31664
  if (opts.usePolling) {
31545
31665
  const enableBin = opts.interval !== opts.binaryInterval;
31546
31666
  options.interval = enableBin && isBinaryPath(basename10) ? opts.binaryInterval : opts.interval;
31547
- closer = setFsWatchFileListener(path35, absolutePath, options, {
31667
+ closer = setFsWatchFileListener(path36, absolutePath, options, {
31548
31668
  listener,
31549
31669
  rawEmitter: this.fsw._emitRaw
31550
31670
  });
31551
31671
  } else {
31552
- closer = setFsWatchListener(path35, absolutePath, options, {
31672
+ closer = setFsWatchListener(path36, absolutePath, options, {
31553
31673
  listener,
31554
31674
  errHandler: this._boundHandleError,
31555
31675
  rawEmitter: this.fsw._emitRaw
@@ -31571,7 +31691,7 @@ var init_handler2 = __esm({
31571
31691
  let prevStats = stats;
31572
31692
  if (parent.has(basename10))
31573
31693
  return;
31574
- const listener = async (path35, newStats) => {
31694
+ const listener = async (path36, newStats) => {
31575
31695
  if (!this.fsw._throttle(THROTTLE_MODE_WATCH, file2, 5))
31576
31696
  return;
31577
31697
  if (!newStats || newStats.mtimeMs === 0) {
@@ -31585,11 +31705,11 @@ var init_handler2 = __esm({
31585
31705
  this.fsw._emit(EV.CHANGE, file2, newStats2);
31586
31706
  }
31587
31707
  if ((isMacos || isLinux || isFreeBSD) && prevStats.ino !== newStats2.ino) {
31588
- this.fsw._closeFile(path35);
31708
+ this.fsw._closeFile(path36);
31589
31709
  prevStats = newStats2;
31590
31710
  const closer2 = this._watchWithNodeFs(file2, listener);
31591
31711
  if (closer2)
31592
- this.fsw._addPathCloser(path35, closer2);
31712
+ this.fsw._addPathCloser(path36, closer2);
31593
31713
  } else {
31594
31714
  prevStats = newStats2;
31595
31715
  }
@@ -31621,7 +31741,7 @@ var init_handler2 = __esm({
31621
31741
  * @param item basename of this item
31622
31742
  * @returns true if no more processing is needed for this entry.
31623
31743
  */
31624
- async _handleSymlink(entry, directory, path35, item) {
31744
+ async _handleSymlink(entry, directory, path36, item) {
31625
31745
  if (this.fsw.closed) {
31626
31746
  return;
31627
31747
  }
@@ -31631,7 +31751,7 @@ var init_handler2 = __esm({
31631
31751
  this.fsw._incrReadyCount();
31632
31752
  let linkPath;
31633
31753
  try {
31634
- linkPath = await (0, import_promises2.realpath)(path35);
31754
+ linkPath = await (0, import_promises2.realpath)(path36);
31635
31755
  } catch (e) {
31636
31756
  this.fsw._emitReady();
31637
31757
  return true;
@@ -31641,12 +31761,12 @@ var init_handler2 = __esm({
31641
31761
  if (dir.has(item)) {
31642
31762
  if (this.fsw._symlinkPaths.get(full) !== linkPath) {
31643
31763
  this.fsw._symlinkPaths.set(full, linkPath);
31644
- this.fsw._emit(EV.CHANGE, path35, entry.stats);
31764
+ this.fsw._emit(EV.CHANGE, path36, entry.stats);
31645
31765
  }
31646
31766
  } else {
31647
31767
  dir.add(item);
31648
31768
  this.fsw._symlinkPaths.set(full, linkPath);
31649
- this.fsw._emit(EV.ADD, path35, entry.stats);
31769
+ this.fsw._emit(EV.ADD, path36, entry.stats);
31650
31770
  }
31651
31771
  this.fsw._emitReady();
31652
31772
  return true;
@@ -31676,9 +31796,9 @@ var init_handler2 = __esm({
31676
31796
  return;
31677
31797
  }
31678
31798
  const item = entry.path;
31679
- let path35 = sp.join(directory, item);
31799
+ let path36 = sp.join(directory, item);
31680
31800
  current.add(item);
31681
- if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path35, item)) {
31801
+ if (entry.stats.isSymbolicLink() && await this._handleSymlink(entry, directory, path36, item)) {
31682
31802
  return;
31683
31803
  }
31684
31804
  if (this.fsw.closed) {
@@ -31687,11 +31807,11 @@ var init_handler2 = __esm({
31687
31807
  }
31688
31808
  if (item === target || !target && !previous.has(item)) {
31689
31809
  this.fsw._incrReadyCount();
31690
- path35 = sp.join(dir, sp.relative(dir, path35));
31691
- this._addToNodeFs(path35, initialAdd, wh, depth + 1);
31810
+ path36 = sp.join(dir, sp.relative(dir, path36));
31811
+ this._addToNodeFs(path36, initialAdd, wh, depth + 1);
31692
31812
  }
31693
31813
  }).on(EV.ERROR, this._boundHandleError);
31694
- return new Promise((resolve18, reject) => {
31814
+ return new Promise((resolve17, reject) => {
31695
31815
  if (!stream)
31696
31816
  return reject();
31697
31817
  stream.once(STR_END, () => {
@@ -31700,7 +31820,7 @@ var init_handler2 = __esm({
31700
31820
  return;
31701
31821
  }
31702
31822
  const wasThrottled = throttler ? throttler.clear() : false;
31703
- resolve18(void 0);
31823
+ resolve17(void 0);
31704
31824
  previous.getChildren().filter((item) => {
31705
31825
  return item !== directory && !current.has(item);
31706
31826
  }).forEach((item) => {
@@ -31757,13 +31877,13 @@ var init_handler2 = __esm({
31757
31877
  * @param depth Child path actually targeted for watch
31758
31878
  * @param target Child path actually targeted for watch
31759
31879
  */
31760
- async _addToNodeFs(path35, initialAdd, priorWh, depth, target) {
31880
+ async _addToNodeFs(path36, initialAdd, priorWh, depth, target) {
31761
31881
  const ready = this.fsw._emitReady;
31762
- if (this.fsw._isIgnored(path35) || this.fsw.closed) {
31882
+ if (this.fsw._isIgnored(path36) || this.fsw.closed) {
31763
31883
  ready();
31764
31884
  return false;
31765
31885
  }
31766
- const wh = this.fsw._getWatchHelpers(path35);
31886
+ const wh = this.fsw._getWatchHelpers(path36);
31767
31887
  if (priorWh) {
31768
31888
  wh.filterPath = (entry) => priorWh.filterPath(entry);
31769
31889
  wh.filterDir = (entry) => priorWh.filterDir(entry);
@@ -31779,8 +31899,8 @@ var init_handler2 = __esm({
31779
31899
  const follow = this.fsw.options.followSymlinks;
31780
31900
  let closer;
31781
31901
  if (stats.isDirectory()) {
31782
- const absPath = sp.resolve(path35);
31783
- const targetPath = follow ? await (0, import_promises2.realpath)(path35) : path35;
31902
+ const absPath = sp.resolve(path36);
31903
+ const targetPath = follow ? await (0, import_promises2.realpath)(path36) : path36;
31784
31904
  if (this.fsw.closed)
31785
31905
  return;
31786
31906
  closer = await this._handleDir(wh.watchPath, stats, initialAdd, depth, target, wh, targetPath);
@@ -31790,29 +31910,29 @@ var init_handler2 = __esm({
31790
31910
  this.fsw._symlinkPaths.set(absPath, targetPath);
31791
31911
  }
31792
31912
  } else if (stats.isSymbolicLink()) {
31793
- const targetPath = follow ? await (0, import_promises2.realpath)(path35) : path35;
31913
+ const targetPath = follow ? await (0, import_promises2.realpath)(path36) : path36;
31794
31914
  if (this.fsw.closed)
31795
31915
  return;
31796
31916
  const parent = sp.dirname(wh.watchPath);
31797
31917
  this.fsw._getWatchedDir(parent).add(wh.watchPath);
31798
31918
  this.fsw._emit(EV.ADD, wh.watchPath, stats);
31799
- closer = await this._handleDir(parent, stats, initialAdd, depth, path35, wh, targetPath);
31919
+ closer = await this._handleDir(parent, stats, initialAdd, depth, path36, wh, targetPath);
31800
31920
  if (this.fsw.closed)
31801
31921
  return;
31802
31922
  if (targetPath !== void 0) {
31803
- this.fsw._symlinkPaths.set(sp.resolve(path35), targetPath);
31923
+ this.fsw._symlinkPaths.set(sp.resolve(path36), targetPath);
31804
31924
  }
31805
31925
  } else {
31806
31926
  closer = this._handleFile(wh.watchPath, stats, initialAdd);
31807
31927
  }
31808
31928
  ready();
31809
31929
  if (closer)
31810
- this.fsw._addPathCloser(path35, closer);
31930
+ this.fsw._addPathCloser(path36, closer);
31811
31931
  return false;
31812
31932
  } catch (error48) {
31813
31933
  if (this.fsw._handleError(error48)) {
31814
31934
  ready();
31815
- return path35;
31935
+ return path36;
31816
31936
  }
31817
31937
  }
31818
31938
  }
@@ -31847,24 +31967,24 @@ function createPattern(matcher) {
31847
31967
  }
31848
31968
  return () => false;
31849
31969
  }
31850
- function normalizePath(path35) {
31851
- if (typeof path35 !== "string")
31970
+ function normalizePath(path36) {
31971
+ if (typeof path36 !== "string")
31852
31972
  throw new Error("string expected");
31853
- path35 = sp2.normalize(path35);
31854
- path35 = path35.replace(/\\/g, "/");
31973
+ path36 = sp2.normalize(path36);
31974
+ path36 = path36.replace(/\\/g, "/");
31855
31975
  let prepend = false;
31856
- if (path35.startsWith("//"))
31976
+ if (path36.startsWith("//"))
31857
31977
  prepend = true;
31858
- path35 = path35.replace(DOUBLE_SLASH_RE, "/");
31978
+ path36 = path36.replace(DOUBLE_SLASH_RE, "/");
31859
31979
  if (prepend)
31860
- path35 = "/" + path35;
31861
- return path35;
31980
+ path36 = "/" + path36;
31981
+ return path36;
31862
31982
  }
31863
31983
  function matchPatterns(patterns, testString, stats) {
31864
- const path35 = normalizePath(testString);
31984
+ const path36 = normalizePath(testString);
31865
31985
  for (let index = 0; index < patterns.length; index++) {
31866
31986
  const pattern = patterns[index];
31867
- if (pattern(path35, stats)) {
31987
+ if (pattern(path36, stats)) {
31868
31988
  return true;
31869
31989
  }
31870
31990
  }
@@ -31927,19 +32047,19 @@ var init_chokidar = __esm({
31927
32047
  }
31928
32048
  return str;
31929
32049
  };
31930
- normalizePathToUnix = (path35) => toUnix(sp2.normalize(toUnix(path35)));
31931
- normalizeIgnored = (cwd = "") => (path35) => {
31932
- if (typeof path35 === "string") {
31933
- return normalizePathToUnix(sp2.isAbsolute(path35) ? path35 : sp2.join(cwd, path35));
32050
+ normalizePathToUnix = (path36) => toUnix(sp2.normalize(toUnix(path36)));
32051
+ normalizeIgnored = (cwd = "") => (path36) => {
32052
+ if (typeof path36 === "string") {
32053
+ return normalizePathToUnix(sp2.isAbsolute(path36) ? path36 : sp2.join(cwd, path36));
31934
32054
  } else {
31935
- return path35;
32055
+ return path36;
31936
32056
  }
31937
32057
  };
31938
- getAbsolutePath = (path35, cwd) => {
31939
- if (sp2.isAbsolute(path35)) {
31940
- return path35;
32058
+ getAbsolutePath = (path36, cwd) => {
32059
+ if (sp2.isAbsolute(path36)) {
32060
+ return path36;
31941
32061
  }
31942
- return sp2.join(cwd, path35);
32062
+ return sp2.join(cwd, path36);
31943
32063
  };
31944
32064
  EMPTY_SET = Object.freeze(/* @__PURE__ */ new Set());
31945
32065
  DirEntry = class {
@@ -32004,10 +32124,10 @@ var init_chokidar = __esm({
32004
32124
  dirParts;
32005
32125
  followSymlinks;
32006
32126
  statMethod;
32007
- constructor(path35, follow, fsw) {
32127
+ constructor(path36, follow, fsw) {
32008
32128
  this.fsw = fsw;
32009
- const watchPath = path35;
32010
- this.path = path35 = path35.replace(REPLACER_RE, "");
32129
+ const watchPath = path36;
32130
+ this.path = path36 = path36.replace(REPLACER_RE, "");
32011
32131
  this.watchPath = watchPath;
32012
32132
  this.fullWatchPath = sp2.resolve(watchPath);
32013
32133
  this.dirParts = [];
@@ -32147,20 +32267,20 @@ var init_chokidar = __esm({
32147
32267
  this._closePromise = void 0;
32148
32268
  let paths = unifyPaths(paths_);
32149
32269
  if (cwd) {
32150
- paths = paths.map((path35) => {
32151
- const absPath = getAbsolutePath(path35, cwd);
32270
+ paths = paths.map((path36) => {
32271
+ const absPath = getAbsolutePath(path36, cwd);
32152
32272
  return absPath;
32153
32273
  });
32154
32274
  }
32155
- paths.forEach((path35) => {
32156
- this._removeIgnoredPath(path35);
32275
+ paths.forEach((path36) => {
32276
+ this._removeIgnoredPath(path36);
32157
32277
  });
32158
32278
  this._userIgnored = void 0;
32159
32279
  if (!this._readyCount)
32160
32280
  this._readyCount = 0;
32161
32281
  this._readyCount += paths.length;
32162
- Promise.all(paths.map(async (path35) => {
32163
- const res = await this._nodeFsHandler._addToNodeFs(path35, !_internal, void 0, 0, _origAdd);
32282
+ Promise.all(paths.map(async (path36) => {
32283
+ const res = await this._nodeFsHandler._addToNodeFs(path36, !_internal, void 0, 0, _origAdd);
32164
32284
  if (res)
32165
32285
  this._emitReady();
32166
32286
  return res;
@@ -32182,17 +32302,17 @@ var init_chokidar = __esm({
32182
32302
  return this;
32183
32303
  const paths = unifyPaths(paths_);
32184
32304
  const { cwd } = this.options;
32185
- paths.forEach((path35) => {
32186
- if (!sp2.isAbsolute(path35) && !this._closers.has(path35)) {
32305
+ paths.forEach((path36) => {
32306
+ if (!sp2.isAbsolute(path36) && !this._closers.has(path36)) {
32187
32307
  if (cwd)
32188
- path35 = sp2.join(cwd, path35);
32189
- path35 = sp2.resolve(path35);
32308
+ path36 = sp2.join(cwd, path36);
32309
+ path36 = sp2.resolve(path36);
32190
32310
  }
32191
- this._closePath(path35);
32192
- this._addIgnoredPath(path35);
32193
- if (this._watched.has(path35)) {
32311
+ this._closePath(path36);
32312
+ this._addIgnoredPath(path36);
32313
+ if (this._watched.has(path36)) {
32194
32314
  this._addIgnoredPath({
32195
- path: path35,
32315
+ path: path36,
32196
32316
  recursive: true
32197
32317
  });
32198
32318
  }
@@ -32256,38 +32376,38 @@ var init_chokidar = __esm({
32256
32376
  * @param stats arguments to be passed with event
32257
32377
  * @returns the error if defined, otherwise the value of the FSWatcher instance's `closed` flag
32258
32378
  */
32259
- async _emit(event, path35, stats) {
32379
+ async _emit(event, path36, stats) {
32260
32380
  if (this.closed)
32261
32381
  return;
32262
32382
  const opts = this.options;
32263
32383
  if (isWindows)
32264
- path35 = sp2.normalize(path35);
32384
+ path36 = sp2.normalize(path36);
32265
32385
  if (opts.cwd)
32266
- path35 = sp2.relative(opts.cwd, path35);
32267
- const args = [path35];
32386
+ path36 = sp2.relative(opts.cwd, path36);
32387
+ const args = [path36];
32268
32388
  if (stats != null)
32269
32389
  args.push(stats);
32270
32390
  const awf = opts.awaitWriteFinish;
32271
32391
  let pw;
32272
- if (awf && (pw = this._pendingWrites.get(path35))) {
32392
+ if (awf && (pw = this._pendingWrites.get(path36))) {
32273
32393
  pw.lastChange = /* @__PURE__ */ new Date();
32274
32394
  return this;
32275
32395
  }
32276
32396
  if (opts.atomic) {
32277
32397
  if (event === EVENTS.UNLINK) {
32278
- this._pendingUnlinks.set(path35, [event, ...args]);
32398
+ this._pendingUnlinks.set(path36, [event, ...args]);
32279
32399
  setTimeout(() => {
32280
- this._pendingUnlinks.forEach((entry, path36) => {
32400
+ this._pendingUnlinks.forEach((entry, path37) => {
32281
32401
  this.emit(...entry);
32282
32402
  this.emit(EVENTS.ALL, ...entry);
32283
- this._pendingUnlinks.delete(path36);
32403
+ this._pendingUnlinks.delete(path37);
32284
32404
  });
32285
32405
  }, typeof opts.atomic === "number" ? opts.atomic : 100);
32286
32406
  return this;
32287
32407
  }
32288
- if (event === EVENTS.ADD && this._pendingUnlinks.has(path35)) {
32408
+ if (event === EVENTS.ADD && this._pendingUnlinks.has(path36)) {
32289
32409
  event = EVENTS.CHANGE;
32290
- this._pendingUnlinks.delete(path35);
32410
+ this._pendingUnlinks.delete(path36);
32291
32411
  }
32292
32412
  }
32293
32413
  if (awf && (event === EVENTS.ADD || event === EVENTS.CHANGE) && this._readyEmitted) {
@@ -32305,16 +32425,16 @@ var init_chokidar = __esm({
32305
32425
  this.emitWithAll(event, args);
32306
32426
  }
32307
32427
  };
32308
- this._awaitWriteFinish(path35, awf.stabilityThreshold, event, awfEmit);
32428
+ this._awaitWriteFinish(path36, awf.stabilityThreshold, event, awfEmit);
32309
32429
  return this;
32310
32430
  }
32311
32431
  if (event === EVENTS.CHANGE) {
32312
- const isThrottled = !this._throttle(EVENTS.CHANGE, path35, 50);
32432
+ const isThrottled = !this._throttle(EVENTS.CHANGE, path36, 50);
32313
32433
  if (isThrottled)
32314
32434
  return this;
32315
32435
  }
32316
32436
  if (opts.alwaysStat && stats === void 0 && (event === EVENTS.ADD || event === EVENTS.ADD_DIR || event === EVENTS.CHANGE)) {
32317
- const fullPath = opts.cwd ? sp2.join(opts.cwd, path35) : path35;
32437
+ const fullPath = opts.cwd ? sp2.join(opts.cwd, path36) : path36;
32318
32438
  let stats2;
32319
32439
  try {
32320
32440
  stats2 = await (0, import_promises3.stat)(fullPath);
@@ -32345,23 +32465,23 @@ var init_chokidar = __esm({
32345
32465
  * @param timeout duration of time to suppress duplicate actions
32346
32466
  * @returns tracking object or false if action should be suppressed
32347
32467
  */
32348
- _throttle(actionType, path35, timeout) {
32468
+ _throttle(actionType, path36, timeout) {
32349
32469
  if (!this._throttled.has(actionType)) {
32350
32470
  this._throttled.set(actionType, /* @__PURE__ */ new Map());
32351
32471
  }
32352
32472
  const action = this._throttled.get(actionType);
32353
32473
  if (!action)
32354
32474
  throw new Error("invalid throttle");
32355
- const actionPath = action.get(path35);
32475
+ const actionPath = action.get(path36);
32356
32476
  if (actionPath) {
32357
32477
  actionPath.count++;
32358
32478
  return false;
32359
32479
  }
32360
32480
  let timeoutObject;
32361
32481
  const clear = () => {
32362
- const item = action.get(path35);
32482
+ const item = action.get(path36);
32363
32483
  const count = item ? item.count : 0;
32364
- action.delete(path35);
32484
+ action.delete(path36);
32365
32485
  clearTimeout(timeoutObject);
32366
32486
  if (item)
32367
32487
  clearTimeout(item.timeoutObject);
@@ -32369,7 +32489,7 @@ var init_chokidar = __esm({
32369
32489
  };
32370
32490
  timeoutObject = setTimeout(clear, timeout);
32371
32491
  const thr = { timeoutObject, clear, count: 0 };
32372
- action.set(path35, thr);
32492
+ action.set(path36, thr);
32373
32493
  return thr;
32374
32494
  }
32375
32495
  _incrReadyCount() {
@@ -32383,44 +32503,44 @@ var init_chokidar = __esm({
32383
32503
  * @param event
32384
32504
  * @param awfEmit Callback to be called when ready for event to be emitted.
32385
32505
  */
32386
- _awaitWriteFinish(path35, threshold, event, awfEmit) {
32506
+ _awaitWriteFinish(path36, threshold, event, awfEmit) {
32387
32507
  const awf = this.options.awaitWriteFinish;
32388
32508
  if (typeof awf !== "object")
32389
32509
  return;
32390
32510
  const pollInterval = awf.pollInterval;
32391
32511
  let timeoutHandler;
32392
- let fullPath = path35;
32393
- if (this.options.cwd && !sp2.isAbsolute(path35)) {
32394
- fullPath = sp2.join(this.options.cwd, path35);
32512
+ let fullPath = path36;
32513
+ if (this.options.cwd && !sp2.isAbsolute(path36)) {
32514
+ fullPath = sp2.join(this.options.cwd, path36);
32395
32515
  }
32396
32516
  const now = /* @__PURE__ */ new Date();
32397
32517
  const writes = this._pendingWrites;
32398
32518
  function awaitWriteFinishFn(prevStat) {
32399
32519
  (0, import_node_fs2.stat)(fullPath, (err, curStat) => {
32400
- if (err || !writes.has(path35)) {
32520
+ if (err || !writes.has(path36)) {
32401
32521
  if (err && err.code !== "ENOENT")
32402
32522
  awfEmit(err);
32403
32523
  return;
32404
32524
  }
32405
32525
  const now2 = Number(/* @__PURE__ */ new Date());
32406
32526
  if (prevStat && curStat.size !== prevStat.size) {
32407
- writes.get(path35).lastChange = now2;
32527
+ writes.get(path36).lastChange = now2;
32408
32528
  }
32409
- const pw = writes.get(path35);
32529
+ const pw = writes.get(path36);
32410
32530
  const df = now2 - pw.lastChange;
32411
32531
  if (df >= threshold) {
32412
- writes.delete(path35);
32532
+ writes.delete(path36);
32413
32533
  awfEmit(void 0, curStat);
32414
32534
  } else {
32415
32535
  timeoutHandler = setTimeout(awaitWriteFinishFn, pollInterval, curStat);
32416
32536
  }
32417
32537
  });
32418
32538
  }
32419
- if (!writes.has(path35)) {
32420
- writes.set(path35, {
32539
+ if (!writes.has(path36)) {
32540
+ writes.set(path36, {
32421
32541
  lastChange: now,
32422
32542
  cancelWait: () => {
32423
- writes.delete(path35);
32543
+ writes.delete(path36);
32424
32544
  clearTimeout(timeoutHandler);
32425
32545
  return event;
32426
32546
  }
@@ -32431,8 +32551,8 @@ var init_chokidar = __esm({
32431
32551
  /**
32432
32552
  * Determines whether user has asked to ignore this path.
32433
32553
  */
32434
- _isIgnored(path35, stats) {
32435
- if (this.options.atomic && DOT_RE.test(path35))
32554
+ _isIgnored(path36, stats) {
32555
+ if (this.options.atomic && DOT_RE.test(path36))
32436
32556
  return true;
32437
32557
  if (!this._userIgnored) {
32438
32558
  const { cwd } = this.options;
@@ -32442,17 +32562,17 @@ var init_chokidar = __esm({
32442
32562
  const list = [...ignoredPaths.map(normalizeIgnored(cwd)), ...ignored];
32443
32563
  this._userIgnored = anymatch(list, void 0);
32444
32564
  }
32445
- return this._userIgnored(path35, stats);
32565
+ return this._userIgnored(path36, stats);
32446
32566
  }
32447
- _isntIgnored(path35, stat4) {
32448
- return !this._isIgnored(path35, stat4);
32567
+ _isntIgnored(path36, stat4) {
32568
+ return !this._isIgnored(path36, stat4);
32449
32569
  }
32450
32570
  /**
32451
32571
  * Provides a set of common helpers and properties relating to symlink handling.
32452
32572
  * @param path file or directory pattern being watched
32453
32573
  */
32454
- _getWatchHelpers(path35) {
32455
- return new WatchHelper(path35, this.options.followSymlinks, this);
32574
+ _getWatchHelpers(path36) {
32575
+ return new WatchHelper(path36, this.options.followSymlinks, this);
32456
32576
  }
32457
32577
  // Directory helpers
32458
32578
  // -----------------
@@ -32484,63 +32604,63 @@ var init_chokidar = __esm({
32484
32604
  * @param item base path of item/directory
32485
32605
  */
32486
32606
  _remove(directory, item, isDirectory) {
32487
- const path35 = sp2.join(directory, item);
32488
- const fullPath = sp2.resolve(path35);
32489
- isDirectory = isDirectory != null ? isDirectory : this._watched.has(path35) || this._watched.has(fullPath);
32490
- if (!this._throttle("remove", path35, 100))
32607
+ const path36 = sp2.join(directory, item);
32608
+ const fullPath = sp2.resolve(path36);
32609
+ isDirectory = isDirectory != null ? isDirectory : this._watched.has(path36) || this._watched.has(fullPath);
32610
+ if (!this._throttle("remove", path36, 100))
32491
32611
  return;
32492
32612
  if (!isDirectory && this._watched.size === 1) {
32493
32613
  this.add(directory, item, true);
32494
32614
  }
32495
- const wp = this._getWatchedDir(path35);
32615
+ const wp = this._getWatchedDir(path36);
32496
32616
  const nestedDirectoryChildren = wp.getChildren();
32497
- nestedDirectoryChildren.forEach((nested) => this._remove(path35, nested));
32617
+ nestedDirectoryChildren.forEach((nested) => this._remove(path36, nested));
32498
32618
  const parent = this._getWatchedDir(directory);
32499
32619
  const wasTracked = parent.has(item);
32500
32620
  parent.remove(item);
32501
32621
  if (this._symlinkPaths.has(fullPath)) {
32502
32622
  this._symlinkPaths.delete(fullPath);
32503
32623
  }
32504
- let relPath = path35;
32624
+ let relPath = path36;
32505
32625
  if (this.options.cwd)
32506
- relPath = sp2.relative(this.options.cwd, path35);
32626
+ relPath = sp2.relative(this.options.cwd, path36);
32507
32627
  if (this.options.awaitWriteFinish && this._pendingWrites.has(relPath)) {
32508
32628
  const event = this._pendingWrites.get(relPath).cancelWait();
32509
32629
  if (event === EVENTS.ADD)
32510
32630
  return;
32511
32631
  }
32512
- this._watched.delete(path35);
32632
+ this._watched.delete(path36);
32513
32633
  this._watched.delete(fullPath);
32514
32634
  const eventName = isDirectory ? EVENTS.UNLINK_DIR : EVENTS.UNLINK;
32515
- if (wasTracked && !this._isIgnored(path35))
32516
- this._emit(eventName, path35);
32517
- this._closePath(path35);
32635
+ if (wasTracked && !this._isIgnored(path36))
32636
+ this._emit(eventName, path36);
32637
+ this._closePath(path36);
32518
32638
  }
32519
32639
  /**
32520
32640
  * Closes all watchers for a path
32521
32641
  */
32522
- _closePath(path35) {
32523
- this._closeFile(path35);
32524
- const dir = sp2.dirname(path35);
32525
- this._getWatchedDir(dir).remove(sp2.basename(path35));
32642
+ _closePath(path36) {
32643
+ this._closeFile(path36);
32644
+ const dir = sp2.dirname(path36);
32645
+ this._getWatchedDir(dir).remove(sp2.basename(path36));
32526
32646
  }
32527
32647
  /**
32528
32648
  * Closes only file-specific watchers
32529
32649
  */
32530
- _closeFile(path35) {
32531
- const closers = this._closers.get(path35);
32650
+ _closeFile(path36) {
32651
+ const closers = this._closers.get(path36);
32532
32652
  if (!closers)
32533
32653
  return;
32534
32654
  closers.forEach((closer) => closer());
32535
- this._closers.delete(path35);
32655
+ this._closers.delete(path36);
32536
32656
  }
32537
- _addPathCloser(path35, closer) {
32657
+ _addPathCloser(path36, closer) {
32538
32658
  if (!closer)
32539
32659
  return;
32540
- let list = this._closers.get(path35);
32660
+ let list = this._closers.get(path36);
32541
32661
  if (!list) {
32542
32662
  list = [];
32543
- this._closers.set(path35, list);
32663
+ this._closers.set(path36, list);
32544
32664
  }
32545
32665
  list.push(closer);
32546
32666
  }
@@ -32585,6 +32705,9 @@ function validateProviderDefinition(raw) {
32585
32705
  warnings.push(`Unknown provider field: ${key}`);
32586
32706
  }
32587
32707
  }
32708
+ if (provider.disableUpstream !== void 0) {
32709
+ warnings.push("disableUpstream is deprecated in provider definitions; use machine-level provider source policy instead");
32710
+ }
32588
32711
  const category = provider.category;
32589
32712
  if (category === "cli" || category === "acp") {
32590
32713
  const spawn6 = provider.spawn;
@@ -32714,8 +32837,11 @@ var init_provider_loader = __esm({
32714
32837
  ProviderLoader = class _ProviderLoader {
32715
32838
  providers = /* @__PURE__ */ new Map();
32716
32839
  providerAvailability = /* @__PURE__ */ new Map();
32840
+ defaultProvidersDir;
32841
+ explicitProviderDir = null;
32717
32842
  userDir;
32718
32843
  upstreamDir;
32844
+ sourceMode = "normal";
32719
32845
  disableUpstream;
32720
32846
  watchers = [];
32721
32847
  logFn;
@@ -32729,22 +32855,15 @@ var init_provider_loader = __esm({
32729
32855
  static META_FILE = ".meta.json";
32730
32856
  constructor(options) {
32731
32857
  this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
32732
- const defaultProvidersDir = path15.join(os16.homedir(), ".adhdev", "providers");
32733
- if (options?.userDir) {
32734
- this.userDir = options.userDir;
32735
- this.log(`Config 'providerDir' applied: ${this.userDir}`);
32736
- } else {
32737
- const localRepoPath = path15.resolve(__dirname, "../../../../../adhdev-providers");
32738
- if (fs6.existsSync(localRepoPath)) {
32739
- this.userDir = localRepoPath;
32740
- this.log(`Auto-detected local public repository: ${this.userDir} (Dev workspace speedup)`);
32741
- } else {
32742
- this.userDir = defaultProvidersDir;
32743
- this.log(`Using default user providers directory: ${this.userDir}`);
32744
- }
32745
- }
32746
- this.upstreamDir = path15.join(defaultProvidersDir, ".upstream");
32747
- this.disableUpstream = options?.disableUpstream ?? false;
32858
+ this.defaultProvidersDir = path15.join(os16.homedir(), ".adhdev", "providers");
32859
+ this.userDir = this.defaultProvidersDir;
32860
+ this.upstreamDir = path15.join(this.defaultProvidersDir, ".upstream");
32861
+ this.disableUpstream = false;
32862
+ this.applySourceConfig({
32863
+ userDir: options?.userDir,
32864
+ sourceMode: options?.sourceMode,
32865
+ disableUpstream: options?.disableUpstream
32866
+ });
32748
32867
  }
32749
32868
  log(msg) {
32750
32869
  this.logFn(`[ProviderLoader] ${msg}`);
@@ -32769,6 +32888,33 @@ var init_provider_loader = __esm({
32769
32888
  getProviderRoots() {
32770
32889
  return [this.userDir, this.upstreamDir];
32771
32890
  }
32891
+ getSourceConfig() {
32892
+ return {
32893
+ sourceMode: this.sourceMode,
32894
+ disableUpstream: this.disableUpstream,
32895
+ explicitProviderDir: this.explicitProviderDir,
32896
+ userDir: this.userDir,
32897
+ upstreamDir: this.upstreamDir,
32898
+ providerRoots: this.getProviderRoots()
32899
+ };
32900
+ }
32901
+ applySourceConfig(options) {
32902
+ const nextSourceMode = options?.sourceMode === "no-upstream" ? "no-upstream" : options?.sourceMode === "normal" ? "normal" : options?.disableUpstream ? "no-upstream" : this.sourceMode || "normal";
32903
+ if (options && Object.prototype.hasOwnProperty.call(options, "userDir")) {
32904
+ this.explicitProviderDir = options.userDir?.trim() ? options.userDir : null;
32905
+ }
32906
+ this.sourceMode = nextSourceMode;
32907
+ this.userDir = this.explicitProviderDir || this.defaultProvidersDir;
32908
+ this.upstreamDir = path15.join(this.defaultProvidersDir, ".upstream");
32909
+ this.disableUpstream = this.sourceMode === "no-upstream";
32910
+ if (this.explicitProviderDir) {
32911
+ this.log(`Config 'providerDir' applied: ${this.userDir}`);
32912
+ } else {
32913
+ this.log(`Using default user providers directory: ${this.userDir}`);
32914
+ }
32915
+ this.log(`Provider source config: mode=${this.sourceMode} explicitProviderDir=${this.explicitProviderDir || "-"} userDir=${this.userDir} upstreamDir=${this.upstreamDir}`);
32916
+ return this.getSourceConfig();
32917
+ }
32772
32918
  /**
32773
32919
  * Canonical provider directory shape for a given root.
32774
32920
  */
@@ -32819,7 +32965,7 @@ var init_provider_loader = __esm({
32819
32965
  this.log(`Loaded ${upstreamCount} upstream providers (auto-updated)`);
32820
32966
  }
32821
32967
  } else if (this.disableUpstream) {
32822
- this.log("Upstream loading disabled (disableUpstream=true)");
32968
+ this.log("Upstream loading disabled (sourceMode=no-upstream)");
32823
32969
  }
32824
32970
  if (fs6.existsSync(this.userDir)) {
32825
32971
  const userCount = this.loadDir(this.userDir, [".upstream"]);
@@ -33330,7 +33476,7 @@ var init_provider_loader = __esm({
33330
33476
  */
33331
33477
  async fetchLatest() {
33332
33478
  if (this.disableUpstream) {
33333
- this.log("Upstream fetch skipped (disableUpstream=true)");
33479
+ this.log("Upstream fetch skipped (sourceMode=no-upstream)");
33334
33480
  return { updated: false };
33335
33481
  }
33336
33482
  const https = require("https");
@@ -33352,7 +33498,7 @@ var init_provider_loader = __esm({
33352
33498
  return { updated: false };
33353
33499
  }
33354
33500
  try {
33355
- const etag = await new Promise((resolve18, reject) => {
33501
+ const etag = await new Promise((resolve17, reject) => {
33356
33502
  const options = {
33357
33503
  method: "HEAD",
33358
33504
  hostname: "github.com",
@@ -33370,7 +33516,7 @@ var init_provider_loader = __esm({
33370
33516
  headers: { "User-Agent": "adhdev-launcher" },
33371
33517
  timeout: 1e4
33372
33518
  }, (res2) => {
33373
- resolve18(res2.headers.etag || res2.headers["last-modified"] || "");
33519
+ resolve17(res2.headers.etag || res2.headers["last-modified"] || "");
33374
33520
  });
33375
33521
  req2.on("error", reject);
33376
33522
  req2.on("timeout", () => {
@@ -33379,7 +33525,7 @@ var init_provider_loader = __esm({
33379
33525
  });
33380
33526
  req2.end();
33381
33527
  } else {
33382
- resolve18(res.headers.etag || res.headers["last-modified"] || "");
33528
+ resolve17(res.headers.etag || res.headers["last-modified"] || "");
33383
33529
  }
33384
33530
  });
33385
33531
  req.on("error", reject);
@@ -33443,7 +33589,7 @@ var init_provider_loader = __esm({
33443
33589
  downloadFile(url2, destPath) {
33444
33590
  const https = require("https");
33445
33591
  const http3 = require("http");
33446
- return new Promise((resolve18, reject) => {
33592
+ return new Promise((resolve17, reject) => {
33447
33593
  const doRequest = (reqUrl, redirectCount = 0) => {
33448
33594
  if (redirectCount > 5) {
33449
33595
  reject(new Error("Too many redirects"));
@@ -33463,7 +33609,7 @@ var init_provider_loader = __esm({
33463
33609
  res.pipe(ws);
33464
33610
  ws.on("finish", () => {
33465
33611
  ws.close();
33466
- resolve18();
33612
+ resolve17();
33467
33613
  });
33468
33614
  ws.on("error", reject);
33469
33615
  });
@@ -33939,17 +34085,17 @@ async function findFreePort(ports) {
33939
34085
  throw new Error("No free port found");
33940
34086
  }
33941
34087
  function checkPortFree(port) {
33942
- return new Promise((resolve18) => {
34088
+ return new Promise((resolve17) => {
33943
34089
  const server = net2.createServer();
33944
34090
  server.unref();
33945
- server.on("error", () => resolve18(false));
34091
+ server.on("error", () => resolve17(false));
33946
34092
  server.listen(port, "127.0.0.1", () => {
33947
- server.close(() => resolve18(true));
34093
+ server.close(() => resolve17(true));
33948
34094
  });
33949
34095
  });
33950
34096
  }
33951
34097
  async function isCdpActive(port) {
33952
- return new Promise((resolve18) => {
34098
+ return new Promise((resolve17) => {
33953
34099
  const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
33954
34100
  timeout: 2e3
33955
34101
  }, (res) => {
@@ -33958,16 +34104,16 @@ async function isCdpActive(port) {
33958
34104
  res.on("end", () => {
33959
34105
  try {
33960
34106
  const info = JSON.parse(data);
33961
- resolve18(!!info["WebKit-Version"] || !!info["Browser"]);
34107
+ resolve17(!!info["WebKit-Version"] || !!info["Browser"]);
33962
34108
  } catch {
33963
- resolve18(false);
34109
+ resolve17(false);
33964
34110
  }
33965
34111
  });
33966
34112
  });
33967
- req.on("error", () => resolve18(false));
34113
+ req.on("error", () => resolve17(false));
33968
34114
  req.on("timeout", () => {
33969
34115
  req.destroy();
33970
- resolve18(false);
34116
+ resolve17(false);
33971
34117
  });
33972
34118
  });
33973
34119
  }
@@ -34713,7 +34859,7 @@ async function waitForPidExit(pid, timeoutMs) {
34713
34859
  while (Date.now() - start < timeoutMs) {
34714
34860
  try {
34715
34861
  process.kill(pid, 0);
34716
- await new Promise((resolve18) => setTimeout(resolve18, 250));
34862
+ await new Promise((resolve17) => setTimeout(resolve17, 250));
34717
34863
  } catch {
34718
34864
  return;
34719
34865
  }
@@ -34828,7 +34974,7 @@ async function runDaemonUpgradeHelper(payload) {
34828
34974
  appendUpgradeLog(installOutput.trim());
34829
34975
  }
34830
34976
  if (process.platform === "win32") {
34831
- await new Promise((resolve18) => setTimeout(resolve18, 500));
34977
+ await new Promise((resolve17) => setTimeout(resolve17, 500));
34832
34978
  cleanupStaleGlobalInstallDirs(payload.packageName);
34833
34979
  appendUpgradeLog("Post-install staging cleanup complete");
34834
34980
  }
@@ -35156,8 +35302,9 @@ var init_router = __esm({
35156
35302
  if (!providerType) {
35157
35303
  return { success: false, error: "providerType required" };
35158
35304
  }
35159
- const offset = Math.max(0, Number(args?.offset) || 0);
35160
- const limit = Math.max(1, Math.min(100, Number(args?.limit) || 30));
35305
+ const wantsAll = args?.all === true;
35306
+ const offset = wantsAll ? 0 : Math.max(0, Number(args?.offset) || 0);
35307
+ const limit = wantsAll ? Number.MAX_SAFE_INTEGER : Math.max(1, Math.min(100, Number(args?.limit) || 30));
35161
35308
  const { sessions: historySessions, hasMore } = listSavedHistorySessions(providerType, { offset, limit });
35162
35309
  const state = loadState();
35163
35310
  const savedSessions = getSavedProviderSessions(state, { providerType, kind });
@@ -35178,13 +35325,13 @@ var init_router = __esm({
35178
35325
  providerName: saved?.providerName || recent?.providerName || providerType,
35179
35326
  kind: saved?.kind || recent?.kind || kind,
35180
35327
  title: saved?.title || recent?.title || session.sessionTitle || session.preview || providerType,
35181
- workspace: saved?.workspace || recent?.workspace,
35328
+ workspace: saved?.workspace || recent?.workspace || session.workspace,
35182
35329
  currentModel: saved?.currentModel || recent?.currentModel,
35183
35330
  preview: session.preview,
35184
35331
  messageCount: session.messageCount,
35185
35332
  firstMessageAt: session.firstMessageAt,
35186
35333
  lastMessageAt: session.lastMessageAt,
35187
- canResume: !!(saved?.workspace || recent?.workspace) && canResumeById
35334
+ canResume: !!(saved?.workspace || recent?.workspace || session.workspace) && canResumeById
35188
35335
  };
35189
35336
  }),
35190
35337
  hasMore
@@ -35819,7 +35966,7 @@ var init_provider_adapter = __esm({
35819
35966
  const beforeCount = this.messageCount(before);
35820
35967
  const beforeSignature = this.lastMessageSignature(before);
35821
35968
  for (let attempt = 0; attempt < 12; attempt += 1) {
35822
- await new Promise((resolve18) => setTimeout(resolve18, 250));
35969
+ await new Promise((resolve17) => setTimeout(resolve17, 250));
35823
35970
  let state;
35824
35971
  try {
35825
35972
  state = await this.readChat(evaluate);
@@ -35841,7 +35988,7 @@ var init_provider_adapter = __esm({
35841
35988
  if (this.messageCount(first) > 0 || this.lastMessageSignature(first)) {
35842
35989
  return first;
35843
35990
  }
35844
- await new Promise((resolve18) => setTimeout(resolve18, 150));
35991
+ await new Promise((resolve17) => setTimeout(resolve17, 150));
35845
35992
  const second = await this.readChat(evaluate);
35846
35993
  return this.messageCount(second) >= this.messageCount(first) ? second : first;
35847
35994
  }
@@ -35981,7 +36128,7 @@ var init_provider_adapter = __esm({
35981
36128
  if (typeof data.error === "string" && data.error.trim()) return false;
35982
36129
  }
35983
36130
  for (let attempt = 0; attempt < 6; attempt += 1) {
35984
- await new Promise((resolve18) => setTimeout(resolve18, 250));
36131
+ await new Promise((resolve17) => setTimeout(resolve17, 250));
35985
36132
  const state = await this.readChat(evaluate);
35986
36133
  const title = this.getStateTitle(state);
35987
36134
  if (this.titlesMatch(title, sessionId)) return true;
@@ -38493,7 +38640,7 @@ function getCliTargetBundle(ctx, type, instanceId) {
38493
38640
  return { target, instance, adapter };
38494
38641
  }
38495
38642
  function sleep(ms) {
38496
- return new Promise((resolve18) => setTimeout(resolve18, ms));
38643
+ return new Promise((resolve17) => setTimeout(resolve17, ms));
38497
38644
  }
38498
38645
  async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
38499
38646
  const startedAt = Date.now();
@@ -39345,18 +39492,6 @@ function resolveAutoImplWritableProviderDir(ctx, category, type, requestedDir) {
39345
39492
  if (!fs13.existsSync(providerJson)) {
39346
39493
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
39347
39494
  }
39348
- try {
39349
- const providerData = JSON.parse(fs13.readFileSync(providerJson, "utf-8"));
39350
- if (providerData.disableUpstream !== true) {
39351
- providerData.disableUpstream = true;
39352
- fs13.writeFileSync(providerJson, JSON.stringify(providerData, null, 2));
39353
- }
39354
- } catch (error48) {
39355
- return {
39356
- dir: null,
39357
- reason: `Failed to update provider.json in writable provider directory: ${error48.message}`
39358
- };
39359
- }
39360
39495
  return { dir: desiredDir };
39361
39496
  }
39362
39497
  function loadAutoImplReferenceScripts(ctx, referenceType) {
@@ -40655,6 +40790,8 @@ var init_dev_server = __esm({
40655
40790
  fs14 = __toESM(require("fs"));
40656
40791
  path24 = __toESM(require("path"));
40657
40792
  init_provider_schema();
40793
+ init_config();
40794
+ init_provider_source_config();
40658
40795
  init_scaffold_template();
40659
40796
  init_version_archive();
40660
40797
  init_logger();
@@ -40669,6 +40806,7 @@ var init_dev_server = __esm({
40669
40806
  cdpManagers;
40670
40807
  instanceManager;
40671
40808
  cliManager;
40809
+ onProviderSourceConfigChanged;
40672
40810
  logFn;
40673
40811
  sseClients = [];
40674
40812
  watchScriptPath = null;
@@ -40685,6 +40823,7 @@ var init_dev_server = __esm({
40685
40823
  this.cdpManagers = options.cdpManagers;
40686
40824
  this.instanceManager = options.instanceManager || null;
40687
40825
  this.cliManager = options.cliManager || null;
40826
+ this.onProviderSourceConfigChanged = options.onProviderSourceConfigChanged || null;
40688
40827
  this.logFn = options.logFn || LOG.forComponent("DevServer").asLogFn();
40689
40828
  }
40690
40829
  log(msg) {
@@ -40694,6 +40833,8 @@ var init_dev_server = __esm({
40694
40833
  routes = [
40695
40834
  // Static routes
40696
40835
  { method: "GET", pattern: "/api/providers", handler: (q, s) => this.handleListProviders(q, s) },
40836
+ { method: "GET", pattern: "/api/providers/source-config", handler: (q, s) => this.handleGetProviderSourceConfig(q, s) },
40837
+ { method: "POST", pattern: "/api/providers/source-config", handler: (q, s) => this.handleSetProviderSourceConfig(q, s) },
40697
40838
  { method: "GET", pattern: "/api/providers/versions", handler: (q, s) => this.handleDetectVersions(q, s) },
40698
40839
  { method: "POST", pattern: "/api/providers/reload", handler: (q, s) => this.handleReload(q, s) },
40699
40840
  { method: "POST", pattern: "/api/cdp/evaluate", handler: (q, s) => this.handleCdpEvaluate(q, s) },
@@ -40759,8 +40900,8 @@ var init_dev_server = __esm({
40759
40900
  }
40760
40901
  getEndpointList() {
40761
40902
  return this.routes.map((r) => {
40762
- const path35 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
40763
- return `${r.method.padEnd(5)} ${path35}`;
40903
+ const path36 = typeof r.pattern === "string" ? r.pattern : r.pattern.source.replace(/\\\//g, "/").replace(/\(\[.*?\]\+\)/g, ":type").replace(/[\^$]/g, "");
40904
+ return `${r.method.padEnd(5)} ${path36}`;
40764
40905
  });
40765
40906
  }
40766
40907
  async start(port = DEV_SERVER_PORT) {
@@ -40791,15 +40932,15 @@ var init_dev_server = __esm({
40791
40932
  this.json(res, 500, { error: e.message });
40792
40933
  }
40793
40934
  });
40794
- return new Promise((resolve18, reject) => {
40935
+ return new Promise((resolve17, reject) => {
40795
40936
  this.server.listen(port, "127.0.0.1", () => {
40796
40937
  this.log(`Dev server listening on http://127.0.0.1:${port}`);
40797
- resolve18();
40938
+ resolve17();
40798
40939
  });
40799
40940
  this.server.on("error", (e) => {
40800
40941
  if (e.code === "EADDRINUSE") {
40801
40942
  this.log(`Port ${port} in use, skipping dev server`);
40802
- resolve18();
40943
+ resolve17();
40803
40944
  } else {
40804
40945
  reject(e);
40805
40946
  }
@@ -40813,7 +40954,33 @@ var init_dev_server = __esm({
40813
40954
  // ─── Handlers ───
40814
40955
  async handleListProviders(_req, res) {
40815
40956
  const providers = this.providerLoader.getAll().map(toProviderListEntry);
40816
- this.json(res, 200, { providers, count: providers.length });
40957
+ this.json(res, 200, { providers, count: providers.length, sourceConfig: this.providerLoader.getSourceConfig() });
40958
+ }
40959
+ async handleGetProviderSourceConfig(_req, res) {
40960
+ this.json(res, 200, { success: true, sourceConfig: this.providerLoader.getSourceConfig() });
40961
+ }
40962
+ async handleSetProviderSourceConfig(req, res) {
40963
+ const body = await this.readBody(req);
40964
+ const parsed = parseProviderSourceConfigUpdate(body || {});
40965
+ if (!parsed.ok) {
40966
+ this.json(res, 400, { success: false, error: parsed.error });
40967
+ return;
40968
+ }
40969
+ const currentConfig2 = loadConfig();
40970
+ const nextConfig = {
40971
+ ...currentConfig2,
40972
+ ...parsed.updates.providerSourceMode ? { providerSourceMode: parsed.updates.providerSourceMode } : {},
40973
+ ...Object.prototype.hasOwnProperty.call(parsed.updates, "providerDir") ? { providerDir: parsed.updates.providerDir } : {}
40974
+ };
40975
+ saveConfig(nextConfig);
40976
+ const sourceConfig = this.providerLoader.applySourceConfig({
40977
+ sourceMode: nextConfig.providerSourceMode,
40978
+ userDir: Object.prototype.hasOwnProperty.call(parsed.updates, "providerDir") ? parsed.updates.providerDir : this.providerLoader.getSourceConfig().explicitProviderDir || void 0
40979
+ });
40980
+ this.providerLoader.reload();
40981
+ this.providerLoader.registerToDetector();
40982
+ await this.onProviderSourceConfigChanged?.();
40983
+ this.json(res, 200, { success: true, reloaded: true, sourceConfig });
40817
40984
  }
40818
40985
  async handleProviderConfig(type, _req, res) {
40819
40986
  const provider = this.providerLoader.resolve(type);
@@ -40855,20 +41022,20 @@ var init_dev_server = __esm({
40855
41022
  child.stderr?.on("data", (d) => {
40856
41023
  stderr += d.toString().slice(0, 2e3);
40857
41024
  });
40858
- await new Promise((resolve18) => {
41025
+ await new Promise((resolve17) => {
40859
41026
  const timer = setTimeout(() => {
40860
41027
  child.kill();
40861
- resolve18();
41028
+ resolve17();
40862
41029
  }, 3e3);
40863
41030
  child.on("exit", () => {
40864
41031
  clearTimeout(timer);
40865
- resolve18();
41032
+ resolve17();
40866
41033
  });
40867
41034
  child.stdout?.once("data", () => {
40868
41035
  setTimeout(() => {
40869
41036
  child.kill();
40870
41037
  clearTimeout(timer);
40871
- resolve18();
41038
+ resolve17();
40872
41039
  }, 500);
40873
41040
  });
40874
41041
  });
@@ -41364,14 +41531,14 @@ var init_dev_server = __esm({
41364
41531
  child.stderr?.on("data", (d) => {
41365
41532
  stderr += d.toString();
41366
41533
  });
41367
- await new Promise((resolve18) => {
41534
+ await new Promise((resolve17) => {
41368
41535
  const timer = setTimeout(() => {
41369
41536
  child.kill();
41370
- resolve18();
41537
+ resolve17();
41371
41538
  }, timeout);
41372
41539
  child.on("exit", () => {
41373
41540
  clearTimeout(timer);
41374
- resolve18();
41541
+ resolve17();
41375
41542
  });
41376
41543
  });
41377
41544
  const elapsed = Date.now() - start;
@@ -41516,18 +41683,6 @@ var init_dev_server = __esm({
41516
41683
  if (!fs14.existsSync(providerJson)) {
41517
41684
  return { dir: null, reason: `provider.json not found in writable provider directory: ${desiredDir}` };
41518
41685
  }
41519
- try {
41520
- const providerData = JSON.parse(fs14.readFileSync(providerJson, "utf-8"));
41521
- if (providerData.disableUpstream !== true) {
41522
- providerData.disableUpstream = true;
41523
- fs14.writeFileSync(providerJson, JSON.stringify(providerData, null, 2));
41524
- }
41525
- } catch (error48) {
41526
- return {
41527
- dir: null,
41528
- reason: `Failed to update provider.json in writable provider directory: ${error48.message}`
41529
- };
41530
- }
41531
41686
  return { dir: desiredDir };
41532
41687
  }
41533
41688
  async handleAutoImplement(type, req, res) {
@@ -42053,14 +42208,14 @@ data: ${JSON.stringify(msg.data)}
42053
42208
  res.end(JSON.stringify(data, null, 2));
42054
42209
  }
42055
42210
  async readBody(req) {
42056
- return new Promise((resolve18) => {
42211
+ return new Promise((resolve17) => {
42057
42212
  let body = "";
42058
42213
  req.on("data", (chunk) => body += chunk);
42059
42214
  req.on("end", () => {
42060
42215
  try {
42061
- resolve18(JSON.parse(body));
42216
+ resolve17(JSON.parse(body));
42062
42217
  } catch {
42063
- resolve18({});
42218
+ resolve17({});
42064
42219
  }
42065
42220
  });
42066
42221
  });
@@ -42545,7 +42700,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
42545
42700
  const deadline = Date.now() + timeoutMs;
42546
42701
  while (Date.now() < deadline) {
42547
42702
  if (await canConnect(endpoint)) return;
42548
- await new Promise((resolve18) => setTimeout(resolve18, STARTUP_POLL_MS));
42703
+ await new Promise((resolve17) => setTimeout(resolve17, STARTUP_POLL_MS));
42549
42704
  }
42550
42705
  throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
42551
42706
  }
@@ -42709,10 +42864,10 @@ async function installExtension(ide, extension) {
42709
42864
  const buffer = Buffer.from(await res.arrayBuffer());
42710
42865
  const fs27 = await import("fs");
42711
42866
  fs27.writeFileSync(vsixPath, buffer);
42712
- return new Promise((resolve18) => {
42867
+ return new Promise((resolve17) => {
42713
42868
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
42714
42869
  (0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
42715
- resolve18({
42870
+ resolve17({
42716
42871
  extensionId: extension.id,
42717
42872
  marketplaceId: extension.marketplaceId,
42718
42873
  success: !error48,
@@ -42725,11 +42880,11 @@ async function installExtension(ide, extension) {
42725
42880
  } catch (e) {
42726
42881
  }
42727
42882
  }
42728
- return new Promise((resolve18) => {
42883
+ return new Promise((resolve17) => {
42729
42884
  const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
42730
42885
  (0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
42731
42886
  if (error48) {
42732
- resolve18({
42887
+ resolve17({
42733
42888
  extensionId: extension.id,
42734
42889
  marketplaceId: extension.marketplaceId,
42735
42890
  success: false,
@@ -42737,7 +42892,7 @@ async function installExtension(ide, extension) {
42737
42892
  error: stderr || error48.message
42738
42893
  });
42739
42894
  } else {
42740
- resolve18({
42895
+ resolve17({
42741
42896
  extensionId: extension.id,
42742
42897
  marketplaceId: extension.marketplaceId,
42743
42898
  success: true,
@@ -42931,10 +43086,11 @@ var init_registry = __esm({
42931
43086
  async function initDaemonComponents(config2) {
42932
43087
  installGlobalInterceptor();
42933
43088
  const appConfig = loadConfig();
42934
- const disableUpstream = appConfig.disableUpstream ?? false;
43089
+ const providerSourceMode = appConfig.providerSourceMode || "normal";
43090
+ const disableUpstream = providerSourceMode === "no-upstream";
42935
43091
  const providerLoader = new ProviderLoader({
42936
43092
  logFn: config2.providerLogFn,
42937
- disableUpstream,
43093
+ sourceMode: providerSourceMode,
42938
43094
  userDir: appConfig.providerDir
42939
43095
  });
42940
43096
  if (!disableUpstream && !providerLoader.hasUpstream()) {
@@ -43039,6 +43195,10 @@ async function initDaemonComponents(config2) {
43039
43195
  onProviderSettingChanged: async (providerType) => {
43040
43196
  await refreshProviderAvailability(providerType);
43041
43197
  config2.onStatusChange?.();
43198
+ },
43199
+ onProviderSourceConfigChanged: async () => {
43200
+ await refreshProviderAvailability();
43201
+ config2.onStatusChange?.();
43042
43202
  }
43043
43203
  });
43044
43204
  agentStreamManager = new DaemonAgentStreamManager(
@@ -43088,7 +43248,8 @@ async function initDaemonComponents(config2) {
43088
43248
  cdpInitializer,
43089
43249
  cdpManagers,
43090
43250
  sessionRegistry,
43091
- detectedIdes: detectedIdesRef
43251
+ detectedIdes: detectedIdesRef,
43252
+ refreshProviderAvailability
43092
43253
  };
43093
43254
  }
43094
43255
  async function startDaemonDevSupport(options) {
@@ -43097,7 +43258,10 @@ async function startDaemonDevSupport(options) {
43097
43258
  cdpManagers: options.components.cdpManagers,
43098
43259
  instanceManager: options.components.instanceManager,
43099
43260
  cliManager: options.components.cliManager,
43100
- logFn: options.logFn
43261
+ logFn: options.logFn,
43262
+ onProviderSourceConfigChanged: async () => {
43263
+ await options.components.refreshProviderAvailability();
43264
+ }
43101
43265
  });
43102
43266
  await devServer.start();
43103
43267
  options.components.providerLoader.watch();
@@ -43247,6 +43411,7 @@ __export(src_exports, {
43247
43411
  normalizeInputEnvelope: () => normalizeInputEnvelope,
43248
43412
  normalizeManagedStatus: () => normalizeManagedStatus,
43249
43413
  normalizeMessageParts: () => normalizeMessageParts,
43414
+ parseProviderSourceConfigUpdate: () => parseProviderSourceConfigUpdate,
43250
43415
  partitionSessionHostDiagnosticsSessions: () => partitionSessionHostDiagnosticsSessions,
43251
43416
  partitionSessionHostRecords: () => partitionSessionHostRecords,
43252
43417
  probeCdpPort: () => probeCdpPort,
@@ -43310,6 +43475,7 @@ var init_src = __esm({
43310
43475
  init_ide_provider_instance();
43311
43476
  init_cli_provider_instance();
43312
43477
  init_acp_provider_instance();
43478
+ init_provider_source_config();
43313
43479
  init_io_contracts();
43314
43480
  init_version_archive();
43315
43481
  init_dev_server();
@@ -43344,7 +43510,7 @@ async function sendDaemonCommand(cmd, args = {}, port) {
43344
43510
  const resolvedPort = resolveDaemonCommandPort(port);
43345
43511
  const WebSocket4 = (await import("ws")).default;
43346
43512
  const { DAEMON_WS_PATH: DAEMON_WS_PATH2 } = await Promise.resolve().then(() => (init_src(), src_exports));
43347
- return new Promise((resolve18, reject) => {
43513
+ return new Promise((resolve17, reject) => {
43348
43514
  const wsUrl = `ws://127.0.0.1:${resolvedPort}${DAEMON_WS_PATH2 || "/daemon"}`;
43349
43515
  const ws = new WebSocket4(wsUrl);
43350
43516
  const requestId = `cli-${Date.now()}`;
@@ -43385,7 +43551,7 @@ async function sendDaemonCommand(cmd, args = {}, port) {
43385
43551
  if (msg.type === "ext:command_result" && msg.payload?.requestId === requestId || msg.type === "daemon:command_result" || msg.type === "command_result") {
43386
43552
  clearTimeout(timeout);
43387
43553
  ws.close();
43388
- resolve18(msg.payload?.result || msg.payload || msg);
43554
+ resolve17(msg.payload?.result || msg.payload || msg);
43389
43555
  }
43390
43556
  } catch {
43391
43557
  }
@@ -43404,13 +43570,13 @@ This command needs a running local daemon with IPC enabled. Start with: adhdev d
43404
43570
  }
43405
43571
  async function directCdpEval(expression, port = 9222) {
43406
43572
  const http3 = await import("http");
43407
- const targets = await new Promise((resolve18, reject) => {
43573
+ const targets = await new Promise((resolve17, reject) => {
43408
43574
  http3.get(`http://127.0.0.1:${port}/json`, (res) => {
43409
43575
  let data = "";
43410
43576
  res.on("data", (c) => data += c);
43411
43577
  res.on("end", () => {
43412
43578
  try {
43413
- resolve18(JSON.parse(data));
43579
+ resolve17(JSON.parse(data));
43414
43580
  } catch {
43415
43581
  reject(new Error("Invalid JSON"));
43416
43582
  }
@@ -43423,7 +43589,7 @@ async function directCdpEval(expression, port = 9222) {
43423
43589
  const target = (mainPages.length > 0 ? mainPages[0] : pages[0]) || targets[0];
43424
43590
  if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target found");
43425
43591
  const WebSocket4 = (await import("ws")).default;
43426
- return new Promise((resolve18, reject) => {
43592
+ return new Promise((resolve17, reject) => {
43427
43593
  const ws = new WebSocket4(target.webSocketDebuggerUrl);
43428
43594
  const timeout = setTimeout(() => {
43429
43595
  ws.close();
@@ -43445,11 +43611,11 @@ async function directCdpEval(expression, port = 9222) {
43445
43611
  clearTimeout(timeout);
43446
43612
  ws.close();
43447
43613
  if (msg.result?.result?.value !== void 0) {
43448
- resolve18(msg.result.result.value);
43614
+ resolve17(msg.result.result.value);
43449
43615
  } else if (msg.result?.exceptionDetails) {
43450
43616
  reject(new Error(msg.result.exceptionDetails.text));
43451
43617
  } else {
43452
- resolve18(msg.result);
43618
+ resolve17(msg.result);
43453
43619
  }
43454
43620
  }
43455
43621
  });
@@ -43984,14 +44150,14 @@ var require_run_async = __commonJS({
43984
44150
  return function() {
43985
44151
  var args = arguments;
43986
44152
  var originalThis = this;
43987
- var promise2 = new Promise(function(resolve18, reject) {
44153
+ var promise2 = new Promise(function(resolve17, reject) {
43988
44154
  var resolved = false;
43989
44155
  const wrappedResolve = function(value) {
43990
44156
  if (resolved) {
43991
44157
  console.warn("Run-async promise already resolved.");
43992
44158
  }
43993
44159
  resolved = true;
43994
- resolve18(value);
44160
+ resolve17(value);
43995
44161
  };
43996
44162
  var rejected = false;
43997
44163
  const wrappedReject = function(value) {
@@ -44782,7 +44948,7 @@ var require_Observable = __commonJS({
44782
44948
  Observable2.prototype.forEach = function(next, promiseCtor) {
44783
44949
  var _this = this;
44784
44950
  promiseCtor = getPromiseCtor(promiseCtor);
44785
- return new promiseCtor(function(resolve18, reject) {
44951
+ return new promiseCtor(function(resolve17, reject) {
44786
44952
  var subscriber = new Subscriber_1.SafeSubscriber({
44787
44953
  next: function(value) {
44788
44954
  try {
@@ -44793,7 +44959,7 @@ var require_Observable = __commonJS({
44793
44959
  }
44794
44960
  },
44795
44961
  error: reject,
44796
- complete: resolve18
44962
+ complete: resolve17
44797
44963
  });
44798
44964
  _this.subscribe(subscriber);
44799
44965
  });
@@ -44815,14 +44981,14 @@ var require_Observable = __commonJS({
44815
44981
  Observable2.prototype.toPromise = function(promiseCtor) {
44816
44982
  var _this = this;
44817
44983
  promiseCtor = getPromiseCtor(promiseCtor);
44818
- return new promiseCtor(function(resolve18, reject) {
44984
+ return new promiseCtor(function(resolve17, reject) {
44819
44985
  var value;
44820
44986
  _this.subscribe(function(x) {
44821
44987
  return value = x;
44822
44988
  }, function(err) {
44823
44989
  return reject(err);
44824
44990
  }, function() {
44825
- return resolve18(value);
44991
+ return resolve17(value);
44826
44992
  });
44827
44993
  });
44828
44994
  };
@@ -46918,11 +47084,11 @@ var require_innerFrom = __commonJS({
46918
47084
  "use strict";
46919
47085
  var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
46920
47086
  function adopt(value) {
46921
- return value instanceof P ? value : new P(function(resolve18) {
46922
- resolve18(value);
47087
+ return value instanceof P ? value : new P(function(resolve17) {
47088
+ resolve17(value);
46923
47089
  });
46924
47090
  }
46925
- return new (P || (P = Promise))(function(resolve18, reject) {
47091
+ return new (P || (P = Promise))(function(resolve17, reject) {
46926
47092
  function fulfilled(value) {
46927
47093
  try {
46928
47094
  step(generator.next(value));
@@ -46938,7 +47104,7 @@ var require_innerFrom = __commonJS({
46938
47104
  }
46939
47105
  }
46940
47106
  function step(result) {
46941
- result.done ? resolve18(result.value) : adopt(result.value).then(fulfilled, rejected);
47107
+ result.done ? resolve17(result.value) : adopt(result.value).then(fulfilled, rejected);
46942
47108
  }
46943
47109
  step((generator = generator.apply(thisArg, _arguments || [])).next());
46944
47110
  });
@@ -47020,14 +47186,14 @@ var require_innerFrom = __commonJS({
47020
47186
  }, i);
47021
47187
  function verb(n) {
47022
47188
  i[n] = o[n] && function(v) {
47023
- return new Promise(function(resolve18, reject) {
47024
- v = o[n](v), settle(resolve18, reject, v.done, v.value);
47189
+ return new Promise(function(resolve17, reject) {
47190
+ v = o[n](v), settle(resolve17, reject, v.done, v.value);
47025
47191
  });
47026
47192
  };
47027
47193
  }
47028
- function settle(resolve18, reject, d, v) {
47194
+ function settle(resolve17, reject, d, v) {
47029
47195
  Promise.resolve(v).then(function(v2) {
47030
- resolve18({ value: v2, done: d });
47196
+ resolve17({ value: v2, done: d });
47031
47197
  }, reject);
47032
47198
  }
47033
47199
  };
@@ -47646,7 +47812,7 @@ var require_lastValueFrom = __commonJS({
47646
47812
  var EmptyError_1 = require_EmptyError();
47647
47813
  function lastValueFrom(source, config2) {
47648
47814
  var hasConfig = typeof config2 === "object";
47649
- return new Promise(function(resolve18, reject) {
47815
+ return new Promise(function(resolve17, reject) {
47650
47816
  var _hasValue = false;
47651
47817
  var _value;
47652
47818
  source.subscribe({
@@ -47657,9 +47823,9 @@ var require_lastValueFrom = __commonJS({
47657
47823
  error: reject,
47658
47824
  complete: function() {
47659
47825
  if (_hasValue) {
47660
- resolve18(_value);
47826
+ resolve17(_value);
47661
47827
  } else if (hasConfig) {
47662
- resolve18(config2.defaultValue);
47828
+ resolve17(config2.defaultValue);
47663
47829
  } else {
47664
47830
  reject(new EmptyError_1.EmptyError());
47665
47831
  }
@@ -47681,16 +47847,16 @@ var require_firstValueFrom = __commonJS({
47681
47847
  var Subscriber_1 = require_Subscriber();
47682
47848
  function firstValueFrom(source, config2) {
47683
47849
  var hasConfig = typeof config2 === "object";
47684
- return new Promise(function(resolve18, reject) {
47850
+ return new Promise(function(resolve17, reject) {
47685
47851
  var subscriber = new Subscriber_1.SafeSubscriber({
47686
47852
  next: function(value) {
47687
- resolve18(value);
47853
+ resolve17(value);
47688
47854
  subscriber.unsubscribe();
47689
47855
  },
47690
47856
  error: reject,
47691
47857
  complete: function() {
47692
47858
  if (hasConfig) {
47693
- resolve18(config2.defaultValue);
47859
+ resolve17(config2.defaultValue);
47694
47860
  } else {
47695
47861
  reject(new EmptyError_1.EmptyError());
47696
47862
  }
@@ -54809,15 +54975,15 @@ var require_route = __commonJS({
54809
54975
  };
54810
54976
  }
54811
54977
  function wrapConversion(toModel, graph) {
54812
- const path35 = [graph[toModel].parent, toModel];
54978
+ const path36 = [graph[toModel].parent, toModel];
54813
54979
  let fn = conversions[graph[toModel].parent][toModel];
54814
54980
  let cur = graph[toModel].parent;
54815
54981
  while (graph[cur].parent) {
54816
- path35.unshift(graph[cur].parent);
54982
+ path36.unshift(graph[cur].parent);
54817
54983
  fn = link(conversions[graph[cur].parent][cur], fn);
54818
54984
  cur = graph[cur].parent;
54819
54985
  }
54820
- fn.conversion = path35;
54986
+ fn.conversion = path36;
54821
54987
  return fn;
54822
54988
  }
54823
54989
  module2.exports = function(fromModel) {
@@ -58115,7 +58281,7 @@ var require_buffer_list = __commonJS({
58115
58281
  }
58116
58282
  }, {
58117
58283
  key: "join",
58118
- value: function join31(s) {
58284
+ value: function join32(s) {
58119
58285
  if (this.length === 0) return "";
58120
58286
  var p = this.head;
58121
58287
  var ret = "" + p.data;
@@ -59496,14 +59662,14 @@ var require_async_iterator = __commonJS({
59496
59662
  };
59497
59663
  }
59498
59664
  function readAndResolve(iter) {
59499
- var resolve18 = iter[kLastResolve];
59500
- if (resolve18 !== null) {
59665
+ var resolve17 = iter[kLastResolve];
59666
+ if (resolve17 !== null) {
59501
59667
  var data = iter[kStream].read();
59502
59668
  if (data !== null) {
59503
59669
  iter[kLastPromise] = null;
59504
59670
  iter[kLastResolve] = null;
59505
59671
  iter[kLastReject] = null;
59506
- resolve18(createIterResult(data, false));
59672
+ resolve17(createIterResult(data, false));
59507
59673
  }
59508
59674
  }
59509
59675
  }
@@ -59511,13 +59677,13 @@ var require_async_iterator = __commonJS({
59511
59677
  process.nextTick(readAndResolve, iter);
59512
59678
  }
59513
59679
  function wrapForNext(lastPromise, iter) {
59514
- return function(resolve18, reject) {
59680
+ return function(resolve17, reject) {
59515
59681
  lastPromise.then(function() {
59516
59682
  if (iter[kEnded]) {
59517
- resolve18(createIterResult(void 0, true));
59683
+ resolve17(createIterResult(void 0, true));
59518
59684
  return;
59519
59685
  }
59520
- iter[kHandlePromise](resolve18, reject);
59686
+ iter[kHandlePromise](resolve17, reject);
59521
59687
  }, reject);
59522
59688
  };
59523
59689
  }
@@ -59537,12 +59703,12 @@ var require_async_iterator = __commonJS({
59537
59703
  return Promise.resolve(createIterResult(void 0, true));
59538
59704
  }
59539
59705
  if (this[kStream].destroyed) {
59540
- return new Promise(function(resolve18, reject) {
59706
+ return new Promise(function(resolve17, reject) {
59541
59707
  process.nextTick(function() {
59542
59708
  if (_this[kError]) {
59543
59709
  reject(_this[kError]);
59544
59710
  } else {
59545
- resolve18(createIterResult(void 0, true));
59711
+ resolve17(createIterResult(void 0, true));
59546
59712
  }
59547
59713
  });
59548
59714
  });
@@ -59565,13 +59731,13 @@ var require_async_iterator = __commonJS({
59565
59731
  return this;
59566
59732
  }), _defineProperty(_Object$setPrototypeO, "return", function _return() {
59567
59733
  var _this2 = this;
59568
- return new Promise(function(resolve18, reject) {
59734
+ return new Promise(function(resolve17, reject) {
59569
59735
  _this2[kStream].destroy(null, function(err) {
59570
59736
  if (err) {
59571
59737
  reject(err);
59572
59738
  return;
59573
59739
  }
59574
- resolve18(createIterResult(void 0, true));
59740
+ resolve17(createIterResult(void 0, true));
59575
59741
  });
59576
59742
  });
59577
59743
  }), _Object$setPrototypeO), AsyncIteratorPrototype);
@@ -59593,15 +59759,15 @@ var require_async_iterator = __commonJS({
59593
59759
  value: stream._readableState.endEmitted,
59594
59760
  writable: true
59595
59761
  }), _defineProperty(_Object$create, kHandlePromise, {
59596
- value: function value(resolve18, reject) {
59762
+ value: function value(resolve17, reject) {
59597
59763
  var data = iterator[kStream].read();
59598
59764
  if (data) {
59599
59765
  iterator[kLastPromise] = null;
59600
59766
  iterator[kLastResolve] = null;
59601
59767
  iterator[kLastReject] = null;
59602
- resolve18(createIterResult(data, false));
59768
+ resolve17(createIterResult(data, false));
59603
59769
  } else {
59604
- iterator[kLastResolve] = resolve18;
59770
+ iterator[kLastResolve] = resolve17;
59605
59771
  iterator[kLastReject] = reject;
59606
59772
  }
59607
59773
  },
@@ -59620,12 +59786,12 @@ var require_async_iterator = __commonJS({
59620
59786
  iterator[kError] = err;
59621
59787
  return;
59622
59788
  }
59623
- var resolve18 = iterator[kLastResolve];
59624
- if (resolve18 !== null) {
59789
+ var resolve17 = iterator[kLastResolve];
59790
+ if (resolve17 !== null) {
59625
59791
  iterator[kLastPromise] = null;
59626
59792
  iterator[kLastResolve] = null;
59627
59793
  iterator[kLastReject] = null;
59628
- resolve18(createIterResult(void 0, true));
59794
+ resolve17(createIterResult(void 0, true));
59629
59795
  }
59630
59796
  iterator[kEnded] = true;
59631
59797
  });
@@ -59640,7 +59806,7 @@ var require_async_iterator = __commonJS({
59640
59806
  var require_from2 = __commonJS({
59641
59807
  "../../node_modules/readable-stream/lib/internal/streams/from.js"(exports2, module2) {
59642
59808
  "use strict";
59643
- function asyncGeneratorStep(gen, resolve18, reject, _next, _throw, key, arg) {
59809
+ function asyncGeneratorStep(gen, resolve17, reject, _next, _throw, key, arg) {
59644
59810
  try {
59645
59811
  var info = gen[key](arg);
59646
59812
  var value = info.value;
@@ -59649,7 +59815,7 @@ var require_from2 = __commonJS({
59649
59815
  return;
59650
59816
  }
59651
59817
  if (info.done) {
59652
- resolve18(value);
59818
+ resolve17(value);
59653
59819
  } else {
59654
59820
  Promise.resolve(value).then(_next, _throw);
59655
59821
  }
@@ -59657,13 +59823,13 @@ var require_from2 = __commonJS({
59657
59823
  function _asyncToGenerator(fn) {
59658
59824
  return function() {
59659
59825
  var self2 = this, args = arguments;
59660
- return new Promise(function(resolve18, reject) {
59826
+ return new Promise(function(resolve17, reject) {
59661
59827
  var gen = fn.apply(self2, args);
59662
59828
  function _next(value) {
59663
- asyncGeneratorStep(gen, resolve18, reject, _next, _throw, "next", value);
59829
+ asyncGeneratorStep(gen, resolve17, reject, _next, _throw, "next", value);
59664
59830
  }
59665
59831
  function _throw(err) {
59666
- asyncGeneratorStep(gen, resolve18, reject, _next, _throw, "throw", err);
59832
+ asyncGeneratorStep(gen, resolve17, reject, _next, _throw, "throw", err);
59667
59833
  }
59668
59834
  _next(void 0);
59669
59835
  });
@@ -61602,9 +61768,9 @@ var init_base = __esm({
61602
61768
  * @return {Promise}
61603
61769
  */
61604
61770
  run() {
61605
- return new Promise((resolve18, reject) => {
61771
+ return new Promise((resolve17, reject) => {
61606
61772
  this._run(
61607
- (value) => resolve18(value),
61773
+ (value) => resolve17(value),
61608
61774
  (error48) => reject(error48)
61609
61775
  );
61610
61776
  });
@@ -68236,7 +68402,7 @@ var require_lib = __commonJS({
68236
68402
  return matches;
68237
68403
  };
68238
68404
  exports2.analyse = analyse;
68239
- var detectFile = (filepath, opts = {}) => new Promise((resolve18, reject) => {
68405
+ var detectFile = (filepath, opts = {}) => new Promise((resolve17, reject) => {
68240
68406
  let fd;
68241
68407
  const fs27 = (0, node_1.default)();
68242
68408
  const handler = (err, buffer) => {
@@ -68246,7 +68412,7 @@ var require_lib = __commonJS({
68246
68412
  if (err) {
68247
68413
  reject(err);
68248
68414
  } else if (buffer) {
68249
- resolve18((0, exports2.detect)(buffer));
68415
+ resolve17((0, exports2.detect)(buffer));
68250
68416
  } else {
68251
68417
  reject(new Error("No error and no buffer received"));
68252
68418
  }
@@ -72687,9 +72853,9 @@ var init_prompt = __esm({
72687
72853
  init_utils();
72688
72854
  init_baseUI();
72689
72855
  _ = {
72690
- set: (obj, path35 = "", value) => {
72856
+ set: (obj, path36 = "", value) => {
72691
72857
  let pointer = obj;
72692
- path35.split(".").forEach((key, index, arr) => {
72858
+ path36.split(".").forEach((key, index, arr) => {
72693
72859
  if (key === "__proto__" || key === "constructor") return;
72694
72860
  if (index === arr.length - 1) {
72695
72861
  pointer[key] = value;
@@ -72699,8 +72865,8 @@ var init_prompt = __esm({
72699
72865
  pointer = pointer[key];
72700
72866
  });
72701
72867
  },
72702
- get: (obj, path35 = "", defaultValue) => {
72703
- const travel = (regexp) => String.prototype.split.call(path35, regexp).filter(Boolean).reduce(
72868
+ get: (obj, path36 = "", defaultValue) => {
72869
+ const travel = (regexp) => String.prototype.split.call(path36, regexp).filter(Boolean).reduce(
72704
72870
  // @ts-expect-error implicit any on res[key]
72705
72871
  (res, key) => res !== null && res !== void 0 ? res[key] : res,
72706
72872
  obj
@@ -74491,14 +74657,14 @@ var init_open = __esm({
74491
74657
  }
74492
74658
  const subprocess = import_node_child_process5.default.spawn(command, cliArguments, childProcessOptions);
74493
74659
  if (options.wait) {
74494
- return new Promise((resolve18, reject) => {
74660
+ return new Promise((resolve17, reject) => {
74495
74661
  subprocess.once("error", reject);
74496
74662
  subprocess.once("close", (exitCode) => {
74497
74663
  if (!options.allowNonzeroExitCode && exitCode > 0) {
74498
74664
  reject(new Error(`Exited with code ${exitCode}`));
74499
74665
  return;
74500
74666
  }
74501
- resolve18(subprocess);
74667
+ resolve17(subprocess);
74502
74668
  });
74503
74669
  });
74504
74670
  }
@@ -74979,7 +75145,7 @@ function routeDataChannelMessage(peerId, msg, peers, handlers) {
74979
75145
  log(`pty_input: REJECTED \u2014 permission=${permission} peer=${peerId}`);
74980
75146
  return;
74981
75147
  }
74982
- const sessionId = parsed.sessionId || parsed.cliId || parsed.cliType || "";
75148
+ const sessionId = parsed.sessionId || parsed.targetSessionId || parsed.cliId || parsed.cliType || "";
74983
75149
  if (handlers.ptyInputHandler && parsed.data && sessionId) {
74984
75150
  handlers.ptyInputHandler(sessionId, parsed.data);
74985
75151
  }
@@ -74991,7 +75157,7 @@ function routeDataChannelMessage(peerId, msg, peers, handlers) {
74991
75157
  log(`pty_resize: REJECTED \u2014 permission=${permission} peer=${peerId}`);
74992
75158
  return;
74993
75159
  }
74994
- const sessionId = parsed.sessionId || parsed.cliId || parsed.cliType || "";
75160
+ const sessionId = parsed.sessionId || parsed.targetSessionId || parsed.cliId || parsed.cliType || "";
74995
75161
  if (handlers.ptyResizeHandler && parsed.cols && parsed.rows && sessionId) {
74996
75162
  handlers.ptyResizeHandler(sessionId, parsed.cols, parsed.rows);
74997
75163
  }
@@ -76001,22 +76167,22 @@ var require_filesystem = __commonJS({
76001
76167
  var LDD_PATH = "/usr/bin/ldd";
76002
76168
  var SELF_PATH = "/proc/self/exe";
76003
76169
  var MAX_LENGTH = 2048;
76004
- var readFileSync20 = (path35) => {
76005
- const fd = fs27.openSync(path35, "r");
76170
+ var readFileSync20 = (path36) => {
76171
+ const fd = fs27.openSync(path36, "r");
76006
76172
  const buffer = Buffer.alloc(MAX_LENGTH);
76007
76173
  const bytesRead = fs27.readSync(fd, buffer, 0, MAX_LENGTH, 0);
76008
76174
  fs27.close(fd, () => {
76009
76175
  });
76010
76176
  return buffer.subarray(0, bytesRead);
76011
76177
  };
76012
- var readFile = (path35) => new Promise((resolve18, reject) => {
76013
- fs27.open(path35, "r", (err, fd) => {
76178
+ var readFile = (path36) => new Promise((resolve17, reject) => {
76179
+ fs27.open(path36, "r", (err, fd) => {
76014
76180
  if (err) {
76015
76181
  reject(err);
76016
76182
  } else {
76017
76183
  const buffer = Buffer.alloc(MAX_LENGTH);
76018
76184
  fs27.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
76019
- resolve18(buffer.subarray(0, bytesRead));
76185
+ resolve17(buffer.subarray(0, bytesRead));
76020
76186
  fs27.close(fd, () => {
76021
76187
  });
76022
76188
  });
@@ -76084,10 +76250,10 @@ var require_detect_libc = __commonJS({
76084
76250
  var commandOut = "";
76085
76251
  var safeCommand = () => {
76086
76252
  if (!commandOut) {
76087
- return new Promise((resolve18) => {
76253
+ return new Promise((resolve17) => {
76088
76254
  childProcess2.exec(command, (err, out) => {
76089
76255
  commandOut = err ? " " : out;
76090
- resolve18(commandOut);
76256
+ resolve17(commandOut);
76091
76257
  });
76092
76258
  });
76093
76259
  }
@@ -76129,11 +76295,11 @@ var require_detect_libc = __commonJS({
76129
76295
  }
76130
76296
  return null;
76131
76297
  };
76132
- var familyFromInterpreterPath = (path35) => {
76133
- if (path35) {
76134
- if (path35.includes("/ld-musl-")) {
76298
+ var familyFromInterpreterPath = (path36) => {
76299
+ if (path36) {
76300
+ if (path36.includes("/ld-musl-")) {
76135
76301
  return MUSL;
76136
- } else if (path35.includes("/ld-linux-")) {
76302
+ } else if (path36.includes("/ld-linux-")) {
76137
76303
  return GLIBC;
76138
76304
  }
76139
76305
  }
@@ -76180,8 +76346,8 @@ var require_detect_libc = __commonJS({
76180
76346
  cachedFamilyInterpreter = null;
76181
76347
  try {
76182
76348
  const selfContent = await readFile(SELF_PATH);
76183
- const path35 = interpreterPath(selfContent);
76184
- cachedFamilyInterpreter = familyFromInterpreterPath(path35);
76349
+ const path36 = interpreterPath(selfContent);
76350
+ cachedFamilyInterpreter = familyFromInterpreterPath(path36);
76185
76351
  } catch (e) {
76186
76352
  }
76187
76353
  return cachedFamilyInterpreter;
@@ -76193,8 +76359,8 @@ var require_detect_libc = __commonJS({
76193
76359
  cachedFamilyInterpreter = null;
76194
76360
  try {
76195
76361
  const selfContent = readFileSync20(SELF_PATH);
76196
- const path35 = interpreterPath(selfContent);
76197
- cachedFamilyInterpreter = familyFromInterpreterPath(path35);
76362
+ const path36 = interpreterPath(selfContent);
76363
+ cachedFamilyInterpreter = familyFromInterpreterPath(path36);
76198
76364
  } catch (e) {
76199
76365
  }
76200
76366
  return cachedFamilyInterpreter;
@@ -77913,18 +78079,18 @@ var require_sharp = __commonJS({
77913
78079
  `@img/sharp-${runtimePlatform}/sharp.node`,
77914
78080
  "@img/sharp-wasm32/sharp.node"
77915
78081
  ];
77916
- var path35;
78082
+ var path36;
77917
78083
  var sharp;
77918
78084
  var errors = [];
77919
- for (path35 of paths) {
78085
+ for (path36 of paths) {
77920
78086
  try {
77921
- sharp = require(path35);
78087
+ sharp = require(path36);
77922
78088
  break;
77923
78089
  } catch (err) {
77924
78090
  errors.push(err);
77925
78091
  }
77926
78092
  }
77927
- if (sharp && path35.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
78093
+ if (sharp && path36.startsWith("@img/sharp-linux-x64") && !sharp._isUsingX64V2()) {
77928
78094
  const err = new Error("Prebuilt binaries for linux-x64 require v2 microarchitecture");
77929
78095
  err.code = "Unsupported CPU";
77930
78096
  errors.push(err);
@@ -78767,14 +78933,14 @@ var require_input = __commonJS({
78767
78933
  return this;
78768
78934
  } else {
78769
78935
  if (this._isStreamInput()) {
78770
- return new Promise((resolve18, reject) => {
78936
+ return new Promise((resolve17, reject) => {
78771
78937
  const finished = () => {
78772
78938
  this._flattenBufferIn();
78773
78939
  sharp.metadata(this.options, (err, metadata2) => {
78774
78940
  if (err) {
78775
78941
  reject(is.nativeError(err, stack));
78776
78942
  } else {
78777
- resolve18(metadata2);
78943
+ resolve17(metadata2);
78778
78944
  }
78779
78945
  });
78780
78946
  };
@@ -78785,12 +78951,12 @@ var require_input = __commonJS({
78785
78951
  }
78786
78952
  });
78787
78953
  } else {
78788
- return new Promise((resolve18, reject) => {
78954
+ return new Promise((resolve17, reject) => {
78789
78955
  sharp.metadata(this.options, (err, metadata2) => {
78790
78956
  if (err) {
78791
78957
  reject(is.nativeError(err, stack));
78792
78958
  } else {
78793
- resolve18(metadata2);
78959
+ resolve17(metadata2);
78794
78960
  }
78795
78961
  });
78796
78962
  });
@@ -78823,25 +78989,25 @@ var require_input = __commonJS({
78823
78989
  return this;
78824
78990
  } else {
78825
78991
  if (this._isStreamInput()) {
78826
- return new Promise((resolve18, reject) => {
78992
+ return new Promise((resolve17, reject) => {
78827
78993
  this.on("finish", function() {
78828
78994
  this._flattenBufferIn();
78829
78995
  sharp.stats(this.options, (err, stats2) => {
78830
78996
  if (err) {
78831
78997
  reject(is.nativeError(err, stack));
78832
78998
  } else {
78833
- resolve18(stats2);
78999
+ resolve17(stats2);
78834
79000
  }
78835
79001
  });
78836
79002
  });
78837
79003
  });
78838
79004
  } else {
78839
- return new Promise((resolve18, reject) => {
79005
+ return new Promise((resolve17, reject) => {
78840
79006
  sharp.stats(this.options, (err, stats2) => {
78841
79007
  if (err) {
78842
79008
  reject(is.nativeError(err, stack));
78843
79009
  } else {
78844
- resolve18(stats2);
79010
+ resolve17(stats2);
78845
79011
  }
78846
79012
  });
78847
79013
  });
@@ -80833,15 +80999,15 @@ var require_color = __commonJS({
80833
80999
  };
80834
81000
  }
80835
81001
  function wrapConversion(toModel, graph) {
80836
- const path35 = [graph[toModel].parent, toModel];
81002
+ const path36 = [graph[toModel].parent, toModel];
80837
81003
  let fn = conversions_default[graph[toModel].parent][toModel];
80838
81004
  let cur = graph[toModel].parent;
80839
81005
  while (graph[cur].parent) {
80840
- path35.unshift(graph[cur].parent);
81006
+ path36.unshift(graph[cur].parent);
80841
81007
  fn = link(conversions_default[graph[cur].parent][cur], fn);
80842
81008
  cur = graph[cur].parent;
80843
81009
  }
80844
- fn.conversion = path35;
81010
+ fn.conversion = path36;
80845
81011
  return fn;
80846
81012
  }
80847
81013
  function route(fromModel) {
@@ -81458,7 +81624,7 @@ var require_channel = __commonJS({
81458
81624
  var require_output = __commonJS({
81459
81625
  "../../node_modules/sharp/lib/output.js"(exports2, module2) {
81460
81626
  "use strict";
81461
- var path35 = require("path");
81627
+ var path36 = require("path");
81462
81628
  var is = require_is();
81463
81629
  var sharp = require_sharp();
81464
81630
  var formats = /* @__PURE__ */ new Map([
@@ -81489,9 +81655,9 @@ var require_output = __commonJS({
81489
81655
  let err;
81490
81656
  if (!is.string(fileOut)) {
81491
81657
  err = new Error("Missing output file path");
81492
- } else if (is.string(this.options.input.file) && path35.resolve(this.options.input.file) === path35.resolve(fileOut)) {
81658
+ } else if (is.string(this.options.input.file) && path36.resolve(this.options.input.file) === path36.resolve(fileOut)) {
81493
81659
  err = new Error("Cannot use same file for input and output");
81494
- } else if (jp2Regex.test(path35.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
81660
+ } else if (jp2Regex.test(path36.extname(fileOut)) && !this.constructor.format.jp2k.output.file) {
81495
81661
  err = errJp2Save();
81496
81662
  }
81497
81663
  if (err) {
@@ -82263,7 +82429,7 @@ var require_output = __commonJS({
82263
82429
  return this;
82264
82430
  } else {
82265
82431
  if (this._isStreamInput()) {
82266
- return new Promise((resolve18, reject) => {
82432
+ return new Promise((resolve17, reject) => {
82267
82433
  this.once("finish", () => {
82268
82434
  this._flattenBufferIn();
82269
82435
  sharp.pipeline(this.options, (err, data, info) => {
@@ -82271,24 +82437,24 @@ var require_output = __commonJS({
82271
82437
  reject(is.nativeError(err, stack));
82272
82438
  } else {
82273
82439
  if (this.options.resolveWithObject) {
82274
- resolve18({ data, info });
82440
+ resolve17({ data, info });
82275
82441
  } else {
82276
- resolve18(data);
82442
+ resolve17(data);
82277
82443
  }
82278
82444
  }
82279
82445
  });
82280
82446
  });
82281
82447
  });
82282
82448
  } else {
82283
- return new Promise((resolve18, reject) => {
82449
+ return new Promise((resolve17, reject) => {
82284
82450
  sharp.pipeline(this.options, (err, data, info) => {
82285
82451
  if (err) {
82286
82452
  reject(is.nativeError(err, stack));
82287
82453
  } else {
82288
82454
  if (this.options.resolveWithObject) {
82289
- resolve18({ data, info });
82455
+ resolve17({ data, info });
82290
82456
  } else {
82291
- resolve18(data);
82457
+ resolve17(data);
82292
82458
  }
82293
82459
  }
82294
82460
  });
@@ -83381,7 +83547,7 @@ var init_adhdev_daemon = __esm({
83381
83547
  import_ws3 = require("ws");
83382
83548
  init_source();
83383
83549
  init_version();
83384
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.57" });
83550
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.58" });
83385
83551
  ACTIVE_CHAT_POLL_STATUSES = /* @__PURE__ */ new Set([
83386
83552
  "generating",
83387
83553
  "waiting_approval",
@@ -83889,6 +84055,8 @@ ${err?.stack || ""}`);
83889
84055
  forwardAgentStreamsToIdeInstance(this.components.instanceManager, ideType, streams);
83890
84056
  }
83891
84057
  });
84058
+ const providerSourceConfig = this.components.providerLoader.getSourceConfig();
84059
+ LOG.info("Provider", `Source config: mode=${providerSourceConfig.sourceMode} explicitProviderDir=${providerSourceConfig.explicitProviderDir || "-"} userDir=${providerSourceConfig.userDir} upstreamDir=${providerSourceConfig.upstreamDir}`);
83892
84060
  if (shouldAutoRestoreHostedSessionsOnStartup(process.env)) {
83893
84061
  await this.components.cliManager.restoreHostedSessions();
83894
84062
  }
@@ -84050,7 +84218,11 @@ ${err?.stack || ""}`);
84050
84218
  providerLoader: this.components.providerLoader,
84051
84219
  cdpManagers: this.components.cdpManagers,
84052
84220
  instanceManager: this.components.instanceManager,
84053
- cliManager: this.components.cliManager
84221
+ cliManager: this.components.cliManager,
84222
+ onProviderSourceConfigChanged: async () => {
84223
+ await this.components.refreshProviderAvailability();
84224
+ this.statusReporter?.onStatusChange();
84225
+ }
84054
84226
  });
84055
84227
  await devServer.start();
84056
84228
  }
@@ -84247,7 +84419,7 @@ ${err?.stack || ""}`);
84247
84419
  this.localWss.emit("connection", ws, req);
84248
84420
  });
84249
84421
  });
84250
- await new Promise((resolve18, reject) => {
84422
+ await new Promise((resolve17, reject) => {
84251
84423
  const cleanup = () => {
84252
84424
  this.localHttpServer?.off("error", onError);
84253
84425
  this.localHttpServer?.off("listening", onListening);
@@ -84258,7 +84430,7 @@ ${err?.stack || ""}`);
84258
84430
  };
84259
84431
  const onListening = () => {
84260
84432
  cleanup();
84261
- resolve18();
84433
+ resolve17();
84262
84434
  };
84263
84435
  this.localHttpServer.once("error", onError);
84264
84436
  this.localHttpServer.once("listening", onListening);
@@ -84418,12 +84590,12 @@ ${err?.stack || ""}`);
84418
84590
  this.localClients.clear();
84419
84591
  this.localWss?.close();
84420
84592
  this.localWss = null;
84421
- await new Promise((resolve18) => {
84593
+ await new Promise((resolve17) => {
84422
84594
  if (!this.localHttpServer) {
84423
- resolve18();
84595
+ resolve17();
84424
84596
  return;
84425
84597
  }
84426
- this.localHttpServer.close(() => resolve18());
84598
+ this.localHttpServer.close(() => resolve17());
84427
84599
  this.localHttpServer = null;
84428
84600
  });
84429
84601
  } catch {
@@ -85836,7 +86008,219 @@ init_src();
85836
86008
 
85837
86009
  // src/cli/setup-commands.ts
85838
86010
  init_source();
86011
+
86012
+ // src/cli/provider-source-status.ts
86013
+ function buildProviderSourceStatusLines(config2) {
86014
+ return [
86015
+ `Provider source mode: ${config2.disableUpstream ? `${config2.sourceMode} (upstream fetch/load disabled)` : config2.sourceMode}`,
86016
+ `Explicit providerDir: ${config2.explicitProviderDir || "default (~/.adhdev/providers)"}`,
86017
+ `Effective user root: ${config2.userDir}`,
86018
+ `Upstream root: ${config2.upstreamDir}`,
86019
+ `Provider roots: ${config2.providerRoots.join(" -> ")}`
86020
+ ];
86021
+ }
86022
+
86023
+ // src/cli/setup-commands.ts
85839
86024
  init_cdp_utils();
86025
+ function resolveLaunchableProviderTarget(providerLoader, targetArg) {
86026
+ if (!targetArg) return null;
86027
+ const resolvedType = providerLoader.resolveAlias(targetArg.toLowerCase());
86028
+ const resolvedProvider = resolvedType ? providerLoader.getMeta(resolvedType) : null;
86029
+ if (!resolvedProvider || resolvedProvider.category !== "cli" && resolvedProvider.category !== "acp") {
86030
+ return null;
86031
+ }
86032
+ return {
86033
+ resolvedType,
86034
+ category: resolvedProvider.category
86035
+ };
86036
+ }
86037
+ function formatSavedHistoryTimestamp(timestamp) {
86038
+ if (!timestamp) return "-";
86039
+ try {
86040
+ return new Date(timestamp).toLocaleString();
86041
+ } catch {
86042
+ return String(timestamp);
86043
+ }
86044
+ }
86045
+ function getSavedHistoryStatusLabel(session) {
86046
+ return session.canResume ? "resume-ready" : "needs --dir";
86047
+ }
86048
+ function buildSavedHistorySessionLines(session) {
86049
+ const title = session.title || session.providerSessionId;
86050
+ const locationParts = [session.providerSessionId];
86051
+ if (session.workspace) locationParts.push(session.workspace);
86052
+ const summaryParts = [`${session.messageCount || 0} msgs`];
86053
+ if (session.currentModel) summaryParts.push(session.currentModel);
86054
+ const updated = formatSavedHistoryTimestamp(session.lastMessageAt);
86055
+ if (updated !== "-") summaryParts.push(`updated ${updated}`);
86056
+ summaryParts.push(getSavedHistoryStatusLabel(session));
86057
+ const lines = [
86058
+ source_default.bold(` \u2022 ${title}`),
86059
+ source_default.gray(` ${locationParts.join(" \xB7 ")}`),
86060
+ source_default.gray(` ${summaryParts.join(" \xB7 ")}`)
86061
+ ];
86062
+ if (session.preview) {
86063
+ lines.push(source_default.gray(` ${session.preview}`));
86064
+ }
86065
+ lines.push("");
86066
+ return lines;
86067
+ }
86068
+ function filterSavedHistorySessions(sessions, options = {}) {
86069
+ const textQuery = String(options.textQuery || "").trim().toLowerCase();
86070
+ const workspaceQuery = String(options.workspaceQuery || "").trim().toLowerCase();
86071
+ const modelQuery = String(options.modelQuery || "").trim().toLowerCase();
86072
+ return sessions.filter((session) => {
86073
+ if (options.resumableOnly && !session.canResume) return false;
86074
+ if (textQuery) {
86075
+ const haystack = [session.title, session.preview].map((value) => String(value || "").toLowerCase()).join("\n");
86076
+ if (!haystack.includes(textQuery)) return false;
86077
+ }
86078
+ if (workspaceQuery) {
86079
+ const workspace = String(session.workspace || "").toLowerCase();
86080
+ if (!workspace.includes(workspaceQuery)) return false;
86081
+ }
86082
+ if (modelQuery) {
86083
+ const model = String(session.currentModel || "").toLowerCase();
86084
+ if (!model.includes(modelQuery)) return false;
86085
+ }
86086
+ return true;
86087
+ });
86088
+ }
86089
+ function sortSavedHistorySessions(sessions, sortMode = "recent") {
86090
+ const sorted = sessions.slice();
86091
+ sorted.sort((left2, right2) => {
86092
+ if (sortMode === "oldest") {
86093
+ return (left2.lastMessageAt || 0) - (right2.lastMessageAt || 0);
86094
+ }
86095
+ if (sortMode === "messages") {
86096
+ const diff = (right2.messageCount || 0) - (left2.messageCount || 0);
86097
+ if (diff !== 0) return diff;
86098
+ }
86099
+ return (right2.lastMessageAt || 0) - (left2.lastMessageAt || 0);
86100
+ });
86101
+ return sorted;
86102
+ }
86103
+ function prepareSavedHistoryListView(sessions, options = {}) {
86104
+ const filtered = filterSavedHistorySessions(sessions, {
86105
+ resumableOnly: options.resumableOnly,
86106
+ textQuery: options.textQuery,
86107
+ workspaceQuery: options.workspaceQuery,
86108
+ modelQuery: options.modelQuery
86109
+ });
86110
+ const sorted = sortSavedHistorySessions(filtered, options.sortMode || "recent");
86111
+ const offset = Math.max(0, options.offset || 0);
86112
+ const limit = Math.max(1, options.limit || 30);
86113
+ return {
86114
+ sessions: sorted.slice(offset, offset + limit),
86115
+ hasMore: sorted.length > offset + limit
86116
+ };
86117
+ }
86118
+ function prepareSavedHistoryResumePickerSessions(sessions, options = {}) {
86119
+ return prepareSavedHistoryListView(sessions, {
86120
+ resumableOnly: options.resumableOnly,
86121
+ textQuery: options.textQuery,
86122
+ workspaceQuery: options.workspaceQuery,
86123
+ modelQuery: options.modelQuery,
86124
+ sortMode: options.sortMode,
86125
+ offset: 0,
86126
+ limit: Math.max(1, sessions.length || 1)
86127
+ }).sessions;
86128
+ }
86129
+ function parsePositiveInteger(value, fallback2) {
86130
+ const parsed = Number.parseInt(String(value || ""), 10);
86131
+ return Number.isFinite(parsed) && parsed >= 0 ? parsed : fallback2;
86132
+ }
86133
+ function buildHistoryResumeLaunchPayload(cliType, session, overrideDir) {
86134
+ const path36 = require("path");
86135
+ const dir = typeof overrideDir === "string" && overrideDir.trim() ? path36.resolve(overrideDir.trim()) : typeof session.workspace === "string" && session.workspace.trim() ? path36.resolve(session.workspace.trim()) : "";
86136
+ if (!dir) {
86137
+ throw new Error(`Saved history ${session.providerSessionId} is missing workspace metadata. Pass --dir to resume it explicitly.`);
86138
+ }
86139
+ const payload = {
86140
+ cliType,
86141
+ dir,
86142
+ resumeSessionId: session.providerSessionId
86143
+ };
86144
+ if (typeof session.currentModel === "string" && session.currentModel.trim()) {
86145
+ payload.initialModel = session.currentModel.trim();
86146
+ }
86147
+ return payload;
86148
+ }
86149
+ function printSavedHistorySessions(providerArg, resolvedType, sessions, hasMore) {
86150
+ console.log();
86151
+ console.log(source_default.bold(` \u{1F4DA} Saved History \u2014 ${providerArg} (${resolvedType})
86152
+ `));
86153
+ if (sessions.length === 0) {
86154
+ console.log(source_default.gray(" No saved history found yet."));
86155
+ console.log();
86156
+ return;
86157
+ }
86158
+ for (const session of sessions) {
86159
+ for (const line of buildSavedHistorySessionLines(session)) {
86160
+ console.log(line);
86161
+ }
86162
+ }
86163
+ if (hasMore) {
86164
+ console.log(source_default.gray(" More saved history is available. Re-run with --offset to page further."));
86165
+ console.log();
86166
+ }
86167
+ }
86168
+ function resolveSavedHistoryResumeSession(sessions, historySessionId) {
86169
+ const requestedId = String(historySessionId || "").trim();
86170
+ if (requestedId) {
86171
+ const exact = sessions.find((session) => session.providerSessionId === requestedId || session.id === requestedId);
86172
+ if (!exact) {
86173
+ throw new Error(`Saved history not found: ${requestedId}`);
86174
+ }
86175
+ return exact;
86176
+ }
86177
+ const resumableSessions = sessions.filter((session) => session.canResume);
86178
+ if (resumableSessions.length === 1) {
86179
+ return resumableSessions[0] || null;
86180
+ }
86181
+ return null;
86182
+ }
86183
+ function buildSavedHistoryResumeChoices(sessions) {
86184
+ return sessions.map((session) => {
86185
+ const title = session.title || session.providerSessionId;
86186
+ const workspace = session.workspace || "Workspace unknown";
86187
+ const updated = formatSavedHistoryTimestamp(session.lastMessageAt);
86188
+ const parts = [title, workspace];
86189
+ if ((session.messageCount || 0) > 0) parts.push(`${session.messageCount} msgs`);
86190
+ if (updated && updated !== "-") parts.push(updated);
86191
+ return {
86192
+ value: session.providerSessionId,
86193
+ name: parts.join(" \xB7 "),
86194
+ ...session.canResume ? {} : { disabled: "workspace metadata missing" }
86195
+ };
86196
+ });
86197
+ }
86198
+ async function promptForSavedHistoryResumeSession(providerArg, sessions, options = {}) {
86199
+ if (!process.stdin.isTTY || !process.stdout.isTTY) {
86200
+ throw new Error(`Multiple saved history entries are available for ${providerArg}. Re-run with a specific historySessionId or use an interactive terminal to choose one.`);
86201
+ }
86202
+ const preparedSessions = prepareSavedHistoryResumePickerSessions(sessions, options);
86203
+ const choices = buildSavedHistoryResumeChoices(preparedSessions);
86204
+ const resumableCount = preparedSessions.filter((session) => session.canResume).length;
86205
+ if (resumableCount === 0) {
86206
+ throw new Error(`No resumable saved history entries are available for ${providerArg}. Use 'adhdev history list ${providerArg}' to inspect the available records.`);
86207
+ }
86208
+ const inquirer2 = await Promise.resolve().then(() => (init_lib(), lib_exports));
86209
+ const { historySessionId } = await inquirer2.default.prompt([
86210
+ {
86211
+ type: "list",
86212
+ name: "historySessionId",
86213
+ message: `Resume which saved history for ${providerArg}?`,
86214
+ choices,
86215
+ pageSize: 12
86216
+ }
86217
+ ]);
86218
+ const selected = preparedSessions.find((session) => session.providerSessionId === historySessionId || session.id === historySessionId);
86219
+ if (!selected) {
86220
+ throw new Error(`Saved history not found: ${historySessionId}`);
86221
+ }
86222
+ return selected;
86223
+ }
85840
86224
  function registerSetupCommands(program2, providerLoader) {
85841
86225
  program2.command("setup").description("Run the interactive setup wizard (detect IDEs, login)").option("-f, --force", "Force re-run setup even if already configured").action(async (options) => {
85842
86226
  const { runWizard: runWizard2 } = await Promise.resolve().then(() => (init_wizard(), wizard_exports));
@@ -85980,6 +86364,172 @@ function registerSetupCommands(program2, providerLoader) {
85980
86364
  spinner.stop();
85981
86365
  console.log(source_default.red(`
85982
86366
  \u2717 Launch failed: ${e?.message || e}
86367
+ `));
86368
+ process.exit(1);
86369
+ }
86370
+ });
86371
+ const history = program2.command("history").description("Browse and resume provider saved history");
86372
+ history.command("list <provider>").description("List saved history for a CLI or ACP provider").option("--json", "Print raw JSON output").option("--limit <count>", "Maximum number of saved history entries to show", "30").option("--offset <count>", "Skip the first N saved history entries", "0").option("--resumable", "Show only saved history entries that can resume immediately").option("--text <text>", "Filter saved history by title or preview substring").option("--workspace <text>", "Filter saved history by workspace path substring").option("--model <text>", "Filter saved history by model substring").option("--sort <mode>", "Sort by recent, oldest, or messages", "recent").action(async (providerArg, options) => {
86373
+ const providerTarget = resolveLaunchableProviderTarget(providerLoader, providerArg);
86374
+ if (!providerTarget) {
86375
+ console.log(source_default.red(`
86376
+ \u2717 Unknown CLI/ACP provider: ${providerArg}
86377
+ `));
86378
+ process.exit(1);
86379
+ }
86380
+ const { isDaemonRunning: isDaemonRunning2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
86381
+ const daemonPort = resolveDaemonCommandPort();
86382
+ if (!isDaemonRunning2({ port: daemonPort })) {
86383
+ console.log(source_default.yellow(`
86384
+ \u26A0 Daemon not running on port ${daemonPort}. Start with 'adhdev daemon${daemonPort === 19222 ? "" : ` -p ${daemonPort}`}' first.
86385
+ `));
86386
+ console.log(source_default.gray(` Then run: adhdev history list ${providerArg}`));
86387
+ process.exit(1);
86388
+ }
86389
+ const sortMode = String(options.sort || "recent").trim().toLowerCase();
86390
+ if (!["recent", "oldest", "messages"].includes(sortMode)) {
86391
+ console.log(source_default.red(`
86392
+ \u2717 Unknown history sort mode: ${options.sort}
86393
+ `));
86394
+ console.log(source_default.gray(" Valid values: recent, oldest, messages\n"));
86395
+ process.exit(1);
86396
+ }
86397
+ const textQuery = String(options.text || "").trim();
86398
+ const workspaceQuery = String(options.workspace || "").trim();
86399
+ const modelQuery = String(options.model || "").trim();
86400
+ const requestedLimit = Math.max(1, Math.min(100, parsePositiveInteger(options.limit, 30) || 30));
86401
+ const requestedOffset = Math.max(0, parsePositiveInteger(options.offset, 0) || 0);
86402
+ const needsFullHistory = options.resumable === true || sortMode !== "recent" || !!textQuery || !!workspaceQuery || !!modelQuery;
86403
+ const result = await sendDaemonCommand("list_saved_sessions", {
86404
+ providerType: providerTarget.resolvedType,
86405
+ kind: providerTarget.category,
86406
+ limit: needsFullHistory ? 100 : requestedLimit,
86407
+ offset: needsFullHistory ? 0 : requestedOffset,
86408
+ all: needsFullHistory
86409
+ }, daemonPort);
86410
+ if (!result?.success) {
86411
+ console.log(source_default.red(`
86412
+ \u2717 ${result?.error || "Could not list saved history"}
86413
+ `));
86414
+ process.exit(1);
86415
+ }
86416
+ const rawSessions = Array.isArray(result.sessions) ? result.sessions : [];
86417
+ const view = prepareSavedHistoryListView(rawSessions, {
86418
+ resumableOnly: options.resumable === true,
86419
+ textQuery,
86420
+ workspaceQuery,
86421
+ modelQuery,
86422
+ sortMode,
86423
+ offset: needsFullHistory ? requestedOffset : 0,
86424
+ limit: needsFullHistory ? requestedLimit : rawSessions.length || requestedLimit
86425
+ });
86426
+ const sessions = needsFullHistory ? view.sessions : rawSessions;
86427
+ const hasMore = needsFullHistory ? view.hasMore : result.hasMore === true;
86428
+ if (options.json) {
86429
+ console.log(JSON.stringify({
86430
+ providerType: providerTarget.resolvedType,
86431
+ kind: providerTarget.category,
86432
+ sort: sortMode,
86433
+ resumableOnly: options.resumable === true,
86434
+ textQuery: textQuery || null,
86435
+ workspaceQuery: workspaceQuery || null,
86436
+ modelQuery: modelQuery || null,
86437
+ sessions,
86438
+ hasMore
86439
+ }, null, 2));
86440
+ return;
86441
+ }
86442
+ printSavedHistorySessions(providerArg, providerTarget.resolvedType, sessions, hasMore);
86443
+ });
86444
+ history.command("resume <provider> [historySessionId]").description("Resume saved history for a CLI or ACP provider").option("-d, --dir <path>", "Override the saved workspace when resuming").option("--resumable", "When choosing interactively, hide entries that still need --dir").option("--text <text>", "When choosing interactively, filter by title or preview substring").option("--workspace <text>", "When choosing interactively, filter by workspace path substring").option("--model <text>", "When choosing interactively, filter by model substring").option("--sort <mode>", "When choosing interactively, sort by recent, oldest, or messages", "recent").action(async (providerArg, historySessionId, options) => {
86445
+ const providerTarget = resolveLaunchableProviderTarget(providerLoader, providerArg);
86446
+ if (!providerTarget) {
86447
+ console.log(source_default.red(`
86448
+ \u2717 Unknown CLI/ACP provider: ${providerArg}
86449
+ `));
86450
+ process.exit(1);
86451
+ }
86452
+ const { isDaemonRunning: isDaemonRunning2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
86453
+ const daemonPort = resolveDaemonCommandPort();
86454
+ if (!isDaemonRunning2({ port: daemonPort })) {
86455
+ console.log(source_default.yellow(`
86456
+ \u26A0 Daemon not running on port ${daemonPort}. Start with 'adhdev daemon${daemonPort === 19222 ? "" : ` -p ${daemonPort}`}' first.
86457
+ `));
86458
+ console.log(source_default.gray(` Then run: adhdev history resume ${providerArg} ${historySessionId}`));
86459
+ process.exit(1);
86460
+ }
86461
+ const sortMode = String(options.sort || "recent").trim().toLowerCase();
86462
+ if (!["recent", "oldest", "messages"].includes(sortMode)) {
86463
+ console.log(source_default.red(`
86464
+ \u2717 Unknown history sort mode: ${options.sort}
86465
+ `));
86466
+ console.log(source_default.gray(" Valid values: recent, oldest, messages\n"));
86467
+ process.exit(1);
86468
+ }
86469
+ const workspaceQuery = String(options.workspace || "").trim();
86470
+ const modelQuery = String(options.model || "").trim();
86471
+ const textQuery = String(options.text || "").trim();
86472
+ const result = await sendDaemonCommand("list_saved_sessions", {
86473
+ providerType: providerTarget.resolvedType,
86474
+ kind: providerTarget.category,
86475
+ all: true
86476
+ }, daemonPort);
86477
+ if (!result?.success) {
86478
+ console.log(source_default.red(`
86479
+ \u2717 ${result?.error || "Could not load saved history"}
86480
+ `));
86481
+ process.exit(1);
86482
+ }
86483
+ const sessions = Array.isArray(result.sessions) ? result.sessions : [];
86484
+ let targetSession = null;
86485
+ try {
86486
+ targetSession = resolveSavedHistoryResumeSession(sessions, historySessionId);
86487
+ } catch (error48) {
86488
+ console.log(source_default.red(`
86489
+ \u2717 ${error48?.message || error48}
86490
+ `));
86491
+ process.exit(1);
86492
+ }
86493
+ if (!targetSession) {
86494
+ try {
86495
+ targetSession = await promptForSavedHistoryResumeSession(providerArg, sessions, {
86496
+ resumableOnly: options.resumable === true,
86497
+ textQuery,
86498
+ workspaceQuery,
86499
+ modelQuery,
86500
+ sortMode
86501
+ });
86502
+ } catch (error48) {
86503
+ console.log(source_default.red(`
86504
+ \u2717 ${error48?.message || error48}
86505
+ `));
86506
+ process.exit(1);
86507
+ }
86508
+ }
86509
+ try {
86510
+ const payload = buildHistoryResumeLaunchPayload(providerTarget.resolvedType, targetSession, options.dir);
86511
+ const launchResult = await sendDaemonCommand("launch_cli", payload, daemonPort);
86512
+ if (!launchResult?.success) {
86513
+ console.log(source_default.red(`
86514
+ \u2717 ${launchResult?.error || "Could not resume saved history"}
86515
+ `));
86516
+ process.exit(1);
86517
+ }
86518
+ console.log();
86519
+ console.log(source_default.bold(` \u{1F680} Saved History Resumed
86520
+ `));
86521
+ console.log(` ${source_default.bold("Provider:")} ${providerArg} (${providerTarget.resolvedType})`);
86522
+ console.log(` ${source_default.bold("History:")} ${targetSession.providerSessionId}`);
86523
+ console.log(` ${source_default.bold("Dir:")} ${launchResult?.dir || payload.dir}`);
86524
+ if (launchResult?.sessionId) {
86525
+ console.log(` ${source_default.bold("Session:")} ${launchResult.sessionId}`);
86526
+ }
86527
+ console.log();
86528
+ console.log(source_default.gray(" Open dashboard: https://adhf.dev/dashboard"));
86529
+ console.log();
86530
+ } catch (error48) {
86531
+ console.log(source_default.red(`
86532
+ \u2717 ${error48?.message || error48}
85983
86533
  `));
85984
86534
  process.exit(1);
85985
86535
  }
@@ -86061,6 +86611,9 @@ function registerSetupCommands(program2, providerLoader) {
86061
86611
  }
86062
86612
  console.log(` ${source_default.bold("User:")} ${config2.userEmail || source_default.gray("not logged in")}`);
86063
86613
  console.log(` ${source_default.bold("Server:")} ${config2.serverUrl}`);
86614
+ for (const line of buildProviderSourceStatusLines(providerLoader.getSourceConfig())) {
86615
+ console.log(source_default.gray(` ${line}`));
86616
+ }
86064
86617
  console.log(` ${source_default.bold("Setup date:")} ${config2.setupDate || "unknown"}`);
86065
86618
  console.log();
86066
86619
  });
@@ -86166,7 +86719,7 @@ function registerSetupCommands(program2, providerLoader) {
86166
86719
  program2.command("uninstall").description("Completely wipe all setting, configuration, stop daemon and uninstall service").option("-f, --force", "Skip confirmation prompt").action(async (options) => {
86167
86720
  const inquirer2 = await Promise.resolve().then(() => (init_lib(), lib_exports));
86168
86721
  const fs27 = await import("fs");
86169
- const path35 = await import("path");
86722
+ const path36 = await import("path");
86170
86723
  const os31 = await import("os");
86171
86724
  const { spawnSync: spawnSync3 } = await import("child_process");
86172
86725
  if (!options.force) {
@@ -86192,7 +86745,7 @@ function registerSetupCommands(program2, providerLoader) {
86192
86745
  }
86193
86746
  console.log(source_default.gray(" Removing OS background service..."));
86194
86747
  spawnSync3(process.execPath, [process.argv[1], "service", "uninstall"], { stdio: "inherit" });
86195
- const adhdevDir = path35.join(os31.homedir(), ".adhdev");
86748
+ const adhdevDir = path36.join(os31.homedir(), ".adhdev");
86196
86749
  if (fs27.existsSync(adhdevDir)) {
86197
86750
  console.log(source_default.gray(` Deleting ${adhdevDir}...`));
86198
86751
  try {
@@ -86346,14 +86899,14 @@ async function requestSessionHostDirect(request) {
86346
86899
  }
86347
86900
  async function runRuntimeLaunchSpec(spec) {
86348
86901
  const { spawn: spawn6 } = await import("child_process");
86349
- return await new Promise((resolve18, reject) => {
86902
+ return await new Promise((resolve17, reject) => {
86350
86903
  const child = spawn6(spec.command, spec.args, {
86351
86904
  stdio: "inherit",
86352
86905
  env: spec.env,
86353
86906
  shell: process.platform === "win32" && spec.command !== process.execPath
86354
86907
  });
86355
86908
  child.on("error", reject);
86356
- child.on("exit", (code) => resolve18(code ?? 0));
86909
+ child.on("exit", (code) => resolve17(code ?? 0));
86357
86910
  });
86358
86911
  }
86359
86912
  async function resolveRuntimeSessionId(target, options) {
@@ -86587,8 +87140,14 @@ function registerDaemonCommands(program2, pkgVersion3) {
86587
87140
  const { getCurrentDaemonLogPath: getCurrentDaemonLogPath2 } = await Promise.resolve().then(() => (init_src(), src_exports));
86588
87141
  const { probeSessionHostStatus: probeSessionHostStatus2 } = await Promise.resolve().then(() => (init_session_host(), session_host_exports));
86589
87142
  const port = parseInt(options.port, 10) || 19222;
86590
- const { loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_src(), src_exports));
87143
+ const { loadConfig: loadConfig2, ProviderLoader: ProviderLoader2 } = await Promise.resolve().then(() => (init_src(), src_exports));
86591
87144
  const config2 = loadConfig2();
87145
+ const providerLoader = new ProviderLoader2({
87146
+ logFn: () => {
87147
+ },
87148
+ userDir: config2.providerDir,
87149
+ sourceMode: config2.providerSourceMode
87150
+ });
86592
87151
  if (isDaemonRunning2({ port })) {
86593
87152
  console.log(source_default.green(`
86594
87153
  \u2713 ADHDev Daemon is running.
@@ -86667,6 +87226,9 @@ function registerDaemonCommands(program2, pkgVersion3) {
86667
87226
  } catch {
86668
87227
  console.log(source_default.gray(" DevServer: not reachable (run `adhdev daemon --dev` for local debug APIs)"));
86669
87228
  }
87229
+ for (const line of buildProviderSourceStatusLines(providerLoader.getSourceConfig())) {
87230
+ console.log(source_default.gray(` ${line}`));
87231
+ }
86670
87232
  console.log();
86671
87233
  } else {
86672
87234
  console.log(source_default.gray(`
@@ -86817,7 +87379,7 @@ function registerDaemonCommands(program2, pkgVersion3) {
86817
87379
  process.exit(1);
86818
87380
  }
86819
87381
  }));
86820
- const runtime = program2.command("runtime").description("Primary user-facing hosted runtime surface for inspection, attach, recovery, and expert mux open flows");
87382
+ const runtime = program2.command("runtime").description("Hosted runtime recovery and diagnostics surface for attach, recover, and expert mux flows");
86821
87383
  runtime.command("list").description("List hosted runtimes grouped as live runtimes, recovery snapshots, and optional inactive records").option("--json", "Print grouped JSON output").option("--all", "Include inactive records in plain-text output and JSON payload").option("--limit <count>", "Number of diagnostics entries to include", "20").action(async (options) => {
86822
87384
  try {
86823
87385
  const limit = Math.max(1, Math.min(200, parseInt(options.limit, 10) || 20));
@@ -87666,6 +88228,7 @@ function registerDoctorCommands(program2, pkgVersion3) {
87666
88228
 
87667
88229
  // src/cli/provider-commands.ts
87668
88230
  init_source();
88231
+ var path34 = __toESM(require("path"));
87669
88232
  init_cdp_utils();
87670
88233
  var IDE_AUTO_FIX_FUNCTIONS = [
87671
88234
  "openPanel",
@@ -87824,11 +88387,22 @@ async function createConfiguredProviderLoader() {
87824
88387
  const config2 = loadConfig2();
87825
88388
  const loader = new ProviderLoader2({
87826
88389
  userDir: config2.providerDir,
87827
- disableUpstream: config2.disableUpstream
88390
+ sourceMode: config2.providerSourceMode
87828
88391
  });
87829
88392
  loader.loadAll();
87830
88393
  return loader;
87831
88394
  }
88395
+ function getProviderSourceCandidatePaths(options) {
88396
+ const relativeNames = ["provider.json", "scripts.js", "provider.js"];
88397
+ const roots = [options.userDir, options.upstreamDir];
88398
+ const results = [];
88399
+ for (const root of roots) {
88400
+ for (const name of relativeNames) {
88401
+ results.push(path34.join(root, options.category, options.type, name));
88402
+ }
88403
+ }
88404
+ return results;
88405
+ }
87832
88406
  function registerProviderCommands(program2) {
87833
88407
  const provider = hideCommand2(program2.command("provider").description("\u{1F50C} Provider management \u2014 list, test, reload providers"));
87834
88408
  provider.command("list").description("List all loaded providers").option("-j, --json", "Output raw JSON").action(async (options) => {
@@ -87885,7 +88459,7 @@ function registerProviderCommands(program2) {
87885
88459
  } catch {
87886
88460
  try {
87887
88461
  const http3 = await import("http");
87888
- const result = await new Promise((resolve18, reject) => {
88462
+ const result = await new Promise((resolve17, reject) => {
87889
88463
  const req = http3.request({
87890
88464
  hostname: "127.0.0.1",
87891
88465
  port: 19280,
@@ -87897,9 +88471,9 @@ function registerProviderCommands(program2) {
87897
88471
  res.on("data", (c) => data += c);
87898
88472
  res.on("end", () => {
87899
88473
  try {
87900
- resolve18(JSON.parse(data));
88474
+ resolve17(JSON.parse(data));
87901
88475
  } catch {
87902
- resolve18({ raw: data });
88476
+ resolve17({ raw: data });
87903
88477
  }
87904
88478
  });
87905
88479
  });
@@ -87960,7 +88534,7 @@ function registerProviderCommands(program2) {
87960
88534
  let processNames = {};
87961
88535
  if (category === "ide") {
87962
88536
  const fs27 = await import("fs");
87963
- const path35 = await import("path");
88537
+ const path36 = await import("path");
87964
88538
  const os31 = await import("os");
87965
88539
  if (os31.platform() === "darwin") {
87966
88540
  while (true) {
@@ -87973,7 +88547,7 @@ function registerProviderCommands(program2) {
87973
88547
  }
87974
88548
  console.log(source_default.green(` \u2713 Path verified: ${p}`));
87975
88549
  osPaths["darwin"] = [p];
87976
- processNames["darwin"] = path35.basename(p, ".app");
88550
+ processNames["darwin"] = path36.basename(p, ".app");
87977
88551
  break;
87978
88552
  }
87979
88553
  } else if (os31.platform() === "win32") {
@@ -87987,7 +88561,7 @@ function registerProviderCommands(program2) {
87987
88561
  }
87988
88562
  console.log(source_default.green(` \u2713 Path verified: ${p}`));
87989
88563
  osPaths["win32"] = [p];
87990
- processNames["win32"] = path35.basename(p, ".exe");
88564
+ processNames["win32"] = path36.basename(p, ".exe");
87991
88565
  break;
87992
88566
  }
87993
88567
  }
@@ -88001,12 +88575,12 @@ function registerProviderCommands(program2) {
88001
88575
  console.log(source_default.yellow("Invalid port number."));
88002
88576
  continue;
88003
88577
  }
88004
- const isFree = await new Promise((resolve18) => {
88578
+ const isFree = await new Promise((resolve17) => {
88005
88579
  const server = net3.createServer();
88006
88580
  server.unref();
88007
- server.on("error", () => resolve18(false));
88581
+ server.on("error", () => resolve17(false));
88008
88582
  server.listen(port, "127.0.0.1", () => {
88009
- server.close(() => resolve18(true));
88583
+ server.close(() => resolve17(true));
88010
88584
  });
88011
88585
  });
88012
88586
  if (!isFree) {
@@ -88021,7 +88595,7 @@ function registerProviderCommands(program2) {
88021
88595
  rl.close();
88022
88596
  const location = options.builtin ? "builtin" : "user";
88023
88597
  const http3 = await import("http");
88024
- const result = await new Promise((resolve18, reject) => {
88598
+ const result = await new Promise((resolve17, reject) => {
88025
88599
  const postData = JSON.stringify({ type, name, category, location, cdpPorts, osPaths, processNames });
88026
88600
  const req = http3.request({
88027
88601
  hostname: "127.0.0.1",
@@ -88034,9 +88608,9 @@ function registerProviderCommands(program2) {
88034
88608
  res.on("data", (c) => data += c);
88035
88609
  res.on("end", () => {
88036
88610
  try {
88037
- resolve18(JSON.parse(data));
88611
+ resolve17(JSON.parse(data));
88038
88612
  } catch {
88039
- resolve18({ raw: data });
88613
+ resolve17({ raw: data });
88040
88614
  }
88041
88615
  });
88042
88616
  });
@@ -88144,7 +88718,7 @@ function registerProviderCommands(program2) {
88144
88718
  if (providerToFix && !isUserProvider(providerToFix)) {
88145
88719
  console.log(source_default.yellow(`
88146
88720
  \u26A0\uFE0F [${type}] is an upstream provider.`));
88147
- console.log(source_default.gray(` Preparing a writable local copy in the user providers directory and disabling upstream updates for this provider.`));
88721
+ console.log(source_default.gray(` Preparing a writable local override in the user providers directory. The local copy will shadow upstream by root precedence; no provider-level upstream flag is required.`));
88148
88722
  const pathMod = await import("path");
88149
88723
  const fsMod2 = await import("fs");
88150
88724
  const downloadedSrc = loader.getUpstreamProviderDir(providerToFix.category, type);
@@ -88153,12 +88727,6 @@ function registerProviderCommands(program2) {
88153
88727
  if (!fsMod2.existsSync(targetDir2)) {
88154
88728
  fsMod2.cpSync(sourceDir, targetDir2, { recursive: true });
88155
88729
  }
88156
- const pJsonPath = pathMod.join(targetDir2, "provider.json");
88157
- if (fsMod2.existsSync(pJsonPath)) {
88158
- const pJson = JSON.parse(fsMod2.readFileSync(pJsonPath, "utf8"));
88159
- pJson.disableUpstream = true;
88160
- fsMod2.writeFileSync(pJsonPath, JSON.stringify(pJson, null, 2));
88161
- }
88162
88730
  console.log(source_default.green(`
88163
88731
  \u2713 Writable local copy ready at [${targetDir2}]`));
88164
88732
  }
@@ -88236,7 +88804,7 @@ function registerProviderCommands(program2) {
88236
88804
  reference,
88237
88805
  ...verification ? { verification } : {}
88238
88806
  });
88239
- const startResult = await new Promise((resolve18, reject) => {
88807
+ const startResult = await new Promise((resolve17, reject) => {
88240
88808
  const req = http3.request({
88241
88809
  hostname: "127.0.0.1",
88242
88810
  port: 19280,
@@ -88248,9 +88816,9 @@ function registerProviderCommands(program2) {
88248
88816
  res.on("data", (c) => data += c);
88249
88817
  res.on("end", () => {
88250
88818
  try {
88251
- resolve18(JSON.parse(data));
88819
+ resolve17(JSON.parse(data));
88252
88820
  } catch {
88253
- resolve18({ raw: data });
88821
+ resolve17({ raw: data });
88254
88822
  }
88255
88823
  });
88256
88824
  });
@@ -88284,7 +88852,7 @@ function registerProviderCommands(program2) {
88284
88852
  fsMock.writeFileSync(logFile, `=== Auto-Impl Started ===
88285
88853
  `);
88286
88854
  console.log(source_default.gray(` Agent logs: ${logFile}`));
88287
- await new Promise((resolve18, reject) => {
88855
+ await new Promise((resolve17, reject) => {
88288
88856
  http3.get(`http://127.0.0.1:19280${startResult.sseUrl}`, (res) => {
88289
88857
  let buffer = "";
88290
88858
  res.on("data", (chunk) => {
@@ -88321,7 +88889,7 @@ function registerProviderCommands(program2) {
88321
88889
  if (currentData.success === false) {
88322
88890
  reject(new Error(`Agent failed to implement scripts properly (exit: ${currentData.exitCode})`));
88323
88891
  } else {
88324
- resolve18();
88892
+ resolve17();
88325
88893
  }
88326
88894
  } else if (currentEvent === "error") {
88327
88895
  fsMock.appendFileSync(logFile, `
@@ -88332,7 +88900,7 @@ function registerProviderCommands(program2) {
88332
88900
  }
88333
88901
  }
88334
88902
  });
88335
- res.on("end", resolve18);
88903
+ res.on("end", resolve17);
88336
88904
  }).on("error", reject);
88337
88905
  });
88338
88906
  console.log(source_default.green(`
@@ -88391,7 +88959,7 @@ function registerProviderCommands(program2) {
88391
88959
  ideType: type,
88392
88960
  params: options.param ? { text: options.param, sessionId: options.param, buttonText: options.param } : {}
88393
88961
  });
88394
- const result = await new Promise((resolve18, reject) => {
88962
+ const result = await new Promise((resolve17, reject) => {
88395
88963
  const req = http3.request({
88396
88964
  hostname: "127.0.0.1",
88397
88965
  port: 19280,
@@ -88403,9 +88971,9 @@ function registerProviderCommands(program2) {
88403
88971
  res.on("data", (c) => data += c);
88404
88972
  res.on("end", () => {
88405
88973
  try {
88406
- resolve18(JSON.parse(data));
88974
+ resolve17(JSON.parse(data));
88407
88975
  } catch {
88408
- resolve18({ raw: data });
88976
+ resolve17({ raw: data });
88409
88977
  }
88410
88978
  });
88411
88979
  });
@@ -88441,15 +89009,15 @@ function registerProviderCommands(program2) {
88441
89009
  provider.command("source <type>").description("View source code of a provider").action(async (type) => {
88442
89010
  try {
88443
89011
  const http3 = await import("http");
88444
- const result = await new Promise((resolve18, reject) => {
89012
+ const result = await new Promise((resolve17, reject) => {
88445
89013
  http3.get(`http://127.0.0.1:19280/api/providers/${type}/source`, (res) => {
88446
89014
  let data = "";
88447
89015
  res.on("data", (c) => data += c);
88448
89016
  res.on("end", () => {
88449
89017
  try {
88450
- resolve18(JSON.parse(data));
89018
+ resolve17(JSON.parse(data));
88451
89019
  } catch {
88452
- resolve18({ raw: data });
89020
+ resolve17({ raw: data });
88453
89021
  }
88454
89022
  });
88455
89023
  }).on("error", () => {
@@ -88463,10 +89031,12 @@ function registerProviderCommands(program2) {
88463
89031
  if (!providerMeta) {
88464
89032
  return { error: `Provider '${type}' not found` };
88465
89033
  }
88466
- const possiblePaths = [
88467
- pathMod.join(loader.getUserProviderDir(providerMeta.category, type), "provider.js"),
88468
- pathMod.join(loader.getUpstreamProviderDir(providerMeta.category, type), "provider.js")
88469
- ];
89034
+ const possiblePaths = getProviderSourceCandidatePaths({
89035
+ category: providerMeta.category,
89036
+ type,
89037
+ userDir: loader.getUserDir(),
89038
+ upstreamDir: loader.getUpstreamDir()
89039
+ });
88470
89040
  for (const p of possiblePaths) {
88471
89041
  if (fsMod.existsSync(p)) {
88472
89042
  return { type, path: p, source: fsMod.readFileSync(p, "utf-8") };
@@ -88495,7 +89065,7 @@ function registerProviderCommands(program2) {
88495
89065
  try {
88496
89066
  const http3 = await import("http");
88497
89067
  const postData = JSON.stringify({ script: "readChat", params: {} });
88498
- const result = await new Promise((resolve18, reject) => {
89068
+ const result = await new Promise((resolve17, reject) => {
88499
89069
  const req = http3.request({
88500
89070
  hostname: "127.0.0.1",
88501
89071
  port: 19280,
@@ -88507,9 +89077,9 @@ function registerProviderCommands(program2) {
88507
89077
  res2.on("data", (c) => data += c);
88508
89078
  res2.on("end", () => {
88509
89079
  try {
88510
- resolve18(JSON.parse(data));
89080
+ resolve17(JSON.parse(data));
88511
89081
  } catch {
88512
- resolve18({ raw: data });
89082
+ resolve17({ raw: data });
88513
89083
  }
88514
89084
  });
88515
89085
  });
@@ -88750,13 +89320,13 @@ function registerCdpCommands(program2) {
88750
89320
  cdp.command("screenshot").description("Capture IDE screenshot").option("-p, --port <port>", "CDP port", "9222").option("-o, --output <file>", "Output file path", "/tmp/cdp_screenshot.jpg").action(async (options) => {
88751
89321
  try {
88752
89322
  const http3 = await import("http");
88753
- const targets = await new Promise((resolve18, reject) => {
89323
+ const targets = await new Promise((resolve17, reject) => {
88754
89324
  http3.get(`http://127.0.0.1:${options.port}/json`, (res) => {
88755
89325
  let data = "";
88756
89326
  res.on("data", (c) => data += c);
88757
89327
  res.on("end", () => {
88758
89328
  try {
88759
- resolve18(JSON.parse(data));
89329
+ resolve17(JSON.parse(data));
88760
89330
  } catch {
88761
89331
  reject(new Error("Invalid JSON"));
88762
89332
  }
@@ -88770,7 +89340,7 @@ function registerCdpCommands(program2) {
88770
89340
  if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target");
88771
89341
  const WebSocket4 = (await import("ws")).default;
88772
89342
  const ws = new WebSocket4(target.webSocketDebuggerUrl);
88773
- await new Promise((resolve18, reject) => {
89343
+ await new Promise((resolve17, reject) => {
88774
89344
  ws.on("open", () => {
88775
89345
  ws.send(JSON.stringify({ id: 1, method: "Page.captureScreenshot", params: { format: "jpeg", quality: 50 } }));
88776
89346
  });
@@ -88783,7 +89353,7 @@ function registerCdpCommands(program2) {
88783
89353
  \u2713 Screenshot saved to ${options.output}
88784
89354
  `));
88785
89355
  ws.close();
88786
- resolve18();
89356
+ resolve17();
88787
89357
  }
88788
89358
  });
88789
89359
  ws.on("error", (e) => reject(e));
@@ -89173,8 +89743,13 @@ if (process.platform === "win32") {
89173
89743
  process.exit(1);
89174
89744
  }
89175
89745
  }
89176
- var _cliProviderLoader = new ProviderLoader({ logFn: () => {
89177
- } });
89746
+ var cliConfig = loadConfig();
89747
+ var _cliProviderLoader = new ProviderLoader({
89748
+ logFn: () => {
89749
+ },
89750
+ userDir: cliConfig.providerDir,
89751
+ sourceMode: cliConfig.providerSourceMode
89752
+ });
89178
89753
  _cliProviderLoader.loadAll();
89179
89754
  _cliProviderLoader.registerToDetector();
89180
89755
  var program = new import_commander.Command();
@@ -89199,9 +89774,11 @@ void (async () => {
89199
89774
  console.log(source_default.gray(" adhdev standalone \u2014 Start standalone local dashboard & daemon"));
89200
89775
  console.log(source_default.gray(" adhdev launch cursor \u2014 Launch IDE with CDP (e.g. cursor, windsurf)"));
89201
89776
  console.log(source_default.gray(" adhdev launch claude \u2014 Launch CLI agent via the running daemon"));
89202
- console.log(source_default.gray(" adhdev runtime list \u2014 Primary hosted runtime view: live, recovery, inactive"));
89777
+ console.log(source_default.gray(" adhdev history list claude \u2014 Browse saved CLI history"));
89778
+ console.log(source_default.gray(" adhdev history resume claude <session> \u2014 Resume saved history explicitly"));
89779
+ console.log(source_default.gray(" adhdev runtime list \u2014 Hosted runtime recovery & diagnostics"));
89203
89780
  console.log(source_default.gray(" adhdev attach \u2014 Attach this terminal to a live hosted runtime"));
89204
- console.log(source_default.gray(" adhdev recover \u2014 Recover or resume a hosted runtime explicitly"));
89781
+ console.log(source_default.gray(" adhdev recover \u2014 Recover a hosted runtime after interruption"));
89205
89782
  console.log(source_default.gray(" adhdev status \u2014 Check current setup"));
89206
89783
  console.log(source_default.gray(" adhdev doctor \u2014 Diagnose install & native dependencies"));
89207
89784
  console.log(source_default.gray(" adhdev update \u2014 Upgrade to latest version"));