adhdev 0.8.93 → 0.8.95

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
@@ -1502,15 +1502,15 @@ function resolveCommandPath(command) {
1502
1502
  return null;
1503
1503
  }
1504
1504
  function execAsync(cmd, timeoutMs = 5e3) {
1505
- return new Promise((resolve17) => {
1505
+ return new Promise((resolve18) => {
1506
1506
  const child = (0, import_child_process2.exec)(cmd, { encoding: "utf-8", timeout: timeoutMs }, (err, stdout) => {
1507
1507
  if (err || !stdout?.trim()) {
1508
- resolve17(null);
1508
+ resolve18(null);
1509
1509
  } else {
1510
- resolve17(stdout.trim());
1510
+ resolve18(stdout.trim());
1511
1511
  }
1512
1512
  });
1513
- child.on("error", () => resolve17(null));
1513
+ child.on("error", () => resolve18(null));
1514
1514
  });
1515
1515
  }
1516
1516
  async function detectCLIs(providerLoader, options) {
@@ -2118,7 +2118,7 @@ var init_manager = __esm({
2118
2118
  * Returns multiple entries if multiple IDE windows are open on same port
2119
2119
  */
2120
2120
  static listAllTargets(port) {
2121
- return new Promise((resolve17) => {
2121
+ return new Promise((resolve18) => {
2122
2122
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
2123
2123
  let data = "";
2124
2124
  res.on("data", (chunk) => data += chunk.toString());
@@ -2134,16 +2134,16 @@ var init_manager = __esm({
2134
2134
  (t) => !isNonMain(t.title || "") && t.url?.includes("workbench.html") && !t.url?.includes("agent")
2135
2135
  );
2136
2136
  const fallbackPages = pages.filter((t) => !isNonMain(t.title || ""));
2137
- resolve17(mainPages.length > 0 ? mainPages : fallbackPages);
2137
+ resolve18(mainPages.length > 0 ? mainPages : fallbackPages);
2138
2138
  } catch {
2139
- resolve17([]);
2139
+ resolve18([]);
2140
2140
  }
2141
2141
  });
2142
2142
  });
2143
- req.on("error", () => resolve17([]));
2143
+ req.on("error", () => resolve18([]));
2144
2144
  req.setTimeout(2e3, () => {
2145
2145
  req.destroy();
2146
- resolve17([]);
2146
+ resolve18([]);
2147
2147
  });
2148
2148
  });
2149
2149
  }
@@ -2183,7 +2183,7 @@ var init_manager = __esm({
2183
2183
  }
2184
2184
  }
2185
2185
  findTargetOnPort(port) {
2186
- return new Promise((resolve17) => {
2186
+ return new Promise((resolve18) => {
2187
2187
  const req = http.get(`http://127.0.0.1:${port}/json`, (res) => {
2188
2188
  let data = "";
2189
2189
  res.on("data", (chunk) => data += chunk.toString());
@@ -2194,7 +2194,7 @@ var init_manager = __esm({
2194
2194
  (t) => (t.type === "page" || t.type === "browser" || t.type === "Page") && t.webSocketDebuggerUrl
2195
2195
  );
2196
2196
  if (pages.length === 0) {
2197
- resolve17(targets.find((t) => t.webSocketDebuggerUrl) || null);
2197
+ resolve18(targets.find((t) => t.webSocketDebuggerUrl) || null);
2198
2198
  return;
2199
2199
  }
2200
2200
  const titleFilteredPages = pages.filter((t) => !this.isNonMainTitle(t.title || ""));
@@ -2213,25 +2213,25 @@ var init_manager = __esm({
2213
2213
  this._targetId = selected.target.id;
2214
2214
  }
2215
2215
  this._pageTitle = selected.target.title || "";
2216
- resolve17(selected.target);
2216
+ resolve18(selected.target);
2217
2217
  return;
2218
2218
  }
2219
2219
  if (previousTargetId) {
2220
2220
  this.log(`[CDP] Target ${previousTargetId} not found in page list`);
2221
- resolve17(null);
2221
+ resolve18(null);
2222
2222
  return;
2223
2223
  }
2224
2224
  this._pageTitle = list[0]?.title || "";
2225
- resolve17(list[0]);
2225
+ resolve18(list[0]);
2226
2226
  } catch {
2227
- resolve17(null);
2227
+ resolve18(null);
2228
2228
  }
2229
2229
  });
2230
2230
  });
2231
- req.on("error", () => resolve17(null));
2231
+ req.on("error", () => resolve18(null));
2232
2232
  req.setTimeout(2e3, () => {
2233
2233
  req.destroy();
2234
- resolve17(null);
2234
+ resolve18(null);
2235
2235
  });
2236
2236
  });
2237
2237
  }
@@ -2242,7 +2242,7 @@ var init_manager = __esm({
2242
2242
  this.extensionProviders = providers;
2243
2243
  }
2244
2244
  connectToTarget(wsUrl) {
2245
- return new Promise((resolve17) => {
2245
+ return new Promise((resolve18) => {
2246
2246
  this.ws = new import_ws.default(wsUrl);
2247
2247
  this.ws.on("open", async () => {
2248
2248
  this._connected = true;
@@ -2252,17 +2252,17 @@ var init_manager = __esm({
2252
2252
  }
2253
2253
  this.connectBrowserWs().catch(() => {
2254
2254
  });
2255
- resolve17(true);
2255
+ resolve18(true);
2256
2256
  });
2257
2257
  this.ws.on("message", (data) => {
2258
2258
  try {
2259
2259
  const msg = JSON.parse(data.toString());
2260
2260
  if (msg.id && this.pending.has(msg.id)) {
2261
- const { resolve: resolve18, reject } = this.pending.get(msg.id);
2261
+ const { resolve: resolve19, reject } = this.pending.get(msg.id);
2262
2262
  this.pending.delete(msg.id);
2263
2263
  this.failureCount = 0;
2264
2264
  if (msg.error) reject(new Error(msg.error.message));
2265
- else resolve18(msg.result);
2265
+ else resolve19(msg.result);
2266
2266
  } else if (msg.method === "Runtime.executionContextCreated") {
2267
2267
  this.contexts.add(msg.params.context.id);
2268
2268
  } else if (msg.method === "Runtime.executionContextDestroyed") {
@@ -2285,7 +2285,7 @@ var init_manager = __esm({
2285
2285
  this.ws.on("error", (err) => {
2286
2286
  this.log(`[CDP] WebSocket error: ${err.message}`);
2287
2287
  this._connected = false;
2288
- resolve17(false);
2288
+ resolve18(false);
2289
2289
  });
2290
2290
  });
2291
2291
  }
@@ -2299,7 +2299,7 @@ var init_manager = __esm({
2299
2299
  return;
2300
2300
  }
2301
2301
  this.log(`[CDP] Connecting browser WS for target discovery...`);
2302
- await new Promise((resolve17, reject) => {
2302
+ await new Promise((resolve18, reject) => {
2303
2303
  this.browserWs = new import_ws.default(browserWsUrl);
2304
2304
  this.browserWs.on("open", async () => {
2305
2305
  this._browserConnected = true;
@@ -2309,16 +2309,16 @@ var init_manager = __esm({
2309
2309
  } catch (e) {
2310
2310
  this.log(`[CDP] setDiscoverTargets failed: ${e.message}`);
2311
2311
  }
2312
- resolve17();
2312
+ resolve18();
2313
2313
  });
2314
2314
  this.browserWs.on("message", (data) => {
2315
2315
  try {
2316
2316
  const msg = JSON.parse(data.toString());
2317
2317
  if (msg.id && this.browserPending.has(msg.id)) {
2318
- const { resolve: resolve18, reject: reject2 } = this.browserPending.get(msg.id);
2318
+ const { resolve: resolve19, reject: reject2 } = this.browserPending.get(msg.id);
2319
2319
  this.browserPending.delete(msg.id);
2320
2320
  if (msg.error) reject2(new Error(msg.error.message));
2321
- else resolve18(msg.result);
2321
+ else resolve19(msg.result);
2322
2322
  }
2323
2323
  } catch {
2324
2324
  }
@@ -2338,31 +2338,31 @@ var init_manager = __esm({
2338
2338
  }
2339
2339
  }
2340
2340
  getBrowserWsUrl() {
2341
- return new Promise((resolve17) => {
2341
+ return new Promise((resolve18) => {
2342
2342
  const req = http.get(`http://127.0.0.1:${this.port}/json/version`, (res) => {
2343
2343
  let data = "";
2344
2344
  res.on("data", (chunk) => data += chunk.toString());
2345
2345
  res.on("end", () => {
2346
2346
  try {
2347
2347
  const info = JSON.parse(data);
2348
- resolve17(info.webSocketDebuggerUrl || null);
2348
+ resolve18(info.webSocketDebuggerUrl || null);
2349
2349
  } catch {
2350
- resolve17(null);
2350
+ resolve18(null);
2351
2351
  }
2352
2352
  });
2353
2353
  });
2354
- req.on("error", () => resolve17(null));
2354
+ req.on("error", () => resolve18(null));
2355
2355
  req.setTimeout(3e3, () => {
2356
2356
  req.destroy();
2357
- resolve17(null);
2357
+ resolve18(null);
2358
2358
  });
2359
2359
  });
2360
2360
  }
2361
2361
  sendBrowser(method, params = {}, timeoutMs = 15e3) {
2362
- return new Promise((resolve17, reject) => {
2362
+ return new Promise((resolve18, reject) => {
2363
2363
  if (!this.browserWs || !this._browserConnected) return reject(new Error("Browser WS not connected"));
2364
2364
  const id = this.browserMsgId++;
2365
- this.browserPending.set(id, { resolve: resolve17, reject });
2365
+ this.browserPending.set(id, { resolve: resolve18, reject });
2366
2366
  this.browserWs.send(JSON.stringify({ id, method, params }));
2367
2367
  setTimeout(() => {
2368
2368
  if (this.browserPending.has(id)) {
@@ -2402,11 +2402,11 @@ var init_manager = __esm({
2402
2402
  }
2403
2403
  // ─── CDP Protocol ────────────────────────────────────────
2404
2404
  sendInternal(method, params = {}, timeoutMs = 15e3) {
2405
- return new Promise((resolve17, reject) => {
2405
+ return new Promise((resolve18, reject) => {
2406
2406
  if (!this.ws || !this._connected) return reject(new Error("CDP not connected"));
2407
2407
  if (this.ws.readyState !== import_ws.default.OPEN) return reject(new Error("WebSocket not open"));
2408
2408
  const id = this.msgId++;
2409
- this.pending.set(id, { resolve: resolve17, reject });
2409
+ this.pending.set(id, { resolve: resolve18, reject });
2410
2410
  this.ws.send(JSON.stringify({ id, method, params }));
2411
2411
  setTimeout(() => {
2412
2412
  if (this.pending.has(id)) {
@@ -2655,7 +2655,7 @@ var init_manager = __esm({
2655
2655
  const browserWs = this.browserWs;
2656
2656
  let msgId = this.browserMsgId;
2657
2657
  const sendWs = (method, params = {}, sessionId) => {
2658
- return new Promise((resolve17, reject) => {
2658
+ return new Promise((resolve18, reject) => {
2659
2659
  const mid = msgId++;
2660
2660
  this.browserMsgId = msgId;
2661
2661
  const handler = (raw) => {
@@ -2664,7 +2664,7 @@ var init_manager = __esm({
2664
2664
  if (msg.id === mid) {
2665
2665
  browserWs.removeListener("message", handler);
2666
2666
  if (msg.error) reject(new Error(msg.error.message || JSON.stringify(msg.error)));
2667
- else resolve17(msg.result);
2667
+ else resolve18(msg.result);
2668
2668
  }
2669
2669
  } catch {
2670
2670
  }
@@ -2865,14 +2865,14 @@ var init_manager = __esm({
2865
2865
  if (!ws || ws.readyState !== import_ws.default.OPEN) {
2866
2866
  throw new Error("CDP not connected");
2867
2867
  }
2868
- return new Promise((resolve17, reject) => {
2868
+ return new Promise((resolve18, reject) => {
2869
2869
  const id = getNextId();
2870
2870
  pendingMap.set(id, {
2871
2871
  resolve: (result) => {
2872
2872
  if (result?.result?.subtype === "error") {
2873
2873
  reject(new Error(result.result.description));
2874
2874
  } else {
2875
- resolve17(result?.result?.value);
2875
+ resolve18(result?.result?.value);
2876
2876
  }
2877
2877
  },
2878
2878
  reject
@@ -2904,10 +2904,10 @@ var init_manager = __esm({
2904
2904
  throw new Error("CDP not connected");
2905
2905
  }
2906
2906
  const sendViaSession = (method, params = {}) => {
2907
- return new Promise((resolve17, reject) => {
2907
+ return new Promise((resolve18, reject) => {
2908
2908
  const pendingMap = this._browserConnected ? this.browserPending : this.pending;
2909
2909
  const id = this._browserConnected ? this.browserMsgId++ : this.msgId++;
2910
- pendingMap.set(id, { resolve: resolve17, reject });
2910
+ pendingMap.set(id, { resolve: resolve18, reject });
2911
2911
  ws.send(JSON.stringify({ id, sessionId, method, params }));
2912
2912
  setTimeout(() => {
2913
2913
  if (pendingMap.has(id)) {
@@ -4661,6 +4661,125 @@ function listSavedHistorySessions(agentType, options = {}) {
4661
4661
  return { sessions: [], hasMore: false };
4662
4662
  }
4663
4663
  }
4664
+ function normalizeCanonicalHermesMessageContent(content) {
4665
+ if (typeof content === "string") return content.trim();
4666
+ if (content == null) return "";
4667
+ try {
4668
+ return JSON.stringify(content).trim();
4669
+ } catch {
4670
+ return String(content).trim();
4671
+ }
4672
+ }
4673
+ function extractCanonicalHermesMessageTimestamp(message, fallbackTs) {
4674
+ const numericTimestamp = Number(message.receivedAt || message.timestamp || message.ts || 0);
4675
+ if (Number.isFinite(numericTimestamp) && numericTimestamp > 0) return numericTimestamp;
4676
+ const stringTimestamp = typeof message.ts === "string" ? Date.parse(message.ts) : typeof message.timestamp === "string" ? Date.parse(message.timestamp) : NaN;
4677
+ if (Number.isFinite(stringTimestamp) && stringTimestamp > 0) return stringTimestamp;
4678
+ return fallbackTs;
4679
+ }
4680
+ function readExistingHermesSessionStartRecord(historySessionId) {
4681
+ try {
4682
+ const dir = path7.join(HISTORY_DIR, "hermes-cli");
4683
+ if (!fs3.existsSync(dir)) return null;
4684
+ const files = listHistoryFiles(dir, historySessionId).sort();
4685
+ for (const file2 of files) {
4686
+ const lines = fs3.readFileSync(path7.join(dir, file2), "utf-8").split("\n").filter(Boolean);
4687
+ for (const line of lines) {
4688
+ try {
4689
+ const parsed = JSON.parse(line);
4690
+ if (parsed.historySessionId !== historySessionId) continue;
4691
+ if (parsed.kind === "session_start" && parsed.role === "system") {
4692
+ return parsed;
4693
+ }
4694
+ } catch {
4695
+ }
4696
+ }
4697
+ }
4698
+ return null;
4699
+ } catch {
4700
+ return null;
4701
+ }
4702
+ }
4703
+ function rebuildHermesSavedHistoryFromCanonicalSession(historySessionId) {
4704
+ const normalizedSessionId = normalizeSavedHistorySessionId("hermes-cli", historySessionId);
4705
+ if (!normalizedSessionId) return false;
4706
+ try {
4707
+ const sessionFilePath = path7.join(os6.homedir(), ".hermes", "sessions", `session_${normalizedSessionId}.json`);
4708
+ if (!fs3.existsSync(sessionFilePath)) return false;
4709
+ const raw = JSON.parse(fs3.readFileSync(sessionFilePath, "utf-8"));
4710
+ const canonicalMessages = Array.isArray(raw.messages) ? raw.messages : [];
4711
+ const dir = path7.join(HISTORY_DIR, "hermes-cli");
4712
+ fs3.mkdirSync(dir, { recursive: true });
4713
+ const existingSessionStart = readExistingHermesSessionStartRecord(normalizedSessionId);
4714
+ const records = [];
4715
+ if (existingSessionStart) {
4716
+ records.push({
4717
+ ...existingSessionStart,
4718
+ historySessionId: normalizedSessionId
4719
+ });
4720
+ }
4721
+ let fallbackTs = Date.parse(raw.session_start || raw.last_updated || "") || Date.now();
4722
+ for (const message of canonicalMessages) {
4723
+ const role = String(message.role || "").trim();
4724
+ const content = normalizeCanonicalHermesMessageContent(message.content);
4725
+ if (!content) continue;
4726
+ const receivedAt = extractCanonicalHermesMessageTimestamp(message, fallbackTs);
4727
+ fallbackTs = receivedAt + 1;
4728
+ if (role === "user") {
4729
+ records.push({
4730
+ ts: new Date(receivedAt).toISOString(),
4731
+ receivedAt,
4732
+ role: "user",
4733
+ content,
4734
+ kind: "standard",
4735
+ agent: "hermes-cli",
4736
+ historySessionId: normalizedSessionId
4737
+ });
4738
+ continue;
4739
+ }
4740
+ if (role === "assistant") {
4741
+ records.push({
4742
+ ts: new Date(receivedAt).toISOString(),
4743
+ receivedAt,
4744
+ role: "assistant",
4745
+ content,
4746
+ kind: "standard",
4747
+ agent: "hermes-cli",
4748
+ historySessionId: normalizedSessionId
4749
+ });
4750
+ continue;
4751
+ }
4752
+ if (role === "tool") {
4753
+ records.push({
4754
+ ts: new Date(receivedAt).toISOString(),
4755
+ receivedAt,
4756
+ role: "assistant",
4757
+ content,
4758
+ kind: "tool",
4759
+ senderName: "Tool",
4760
+ agent: "hermes-cli",
4761
+ historySessionId: normalizedSessionId
4762
+ });
4763
+ }
4764
+ }
4765
+ if (records.length === 0) return false;
4766
+ const prefix = `${normalizedSessionId.replace(/[^a-zA-Z0-9_-]/g, "_")}_`;
4767
+ for (const file2 of fs3.readdirSync(dir)) {
4768
+ if (file2.startsWith(prefix) && file2.endsWith(".jsonl")) {
4769
+ fs3.unlinkSync(path7.join(dir, file2));
4770
+ }
4771
+ }
4772
+ const targetDate = new Date(records[records.length - 1].receivedAt || Date.now()).toISOString().slice(0, 10);
4773
+ const filePath = path7.join(dir, `${prefix}${targetDate}.jsonl`);
4774
+ fs3.writeFileSync(filePath, `${records.map((record2) => JSON.stringify(record2)).join("\n")}
4775
+ `, "utf-8");
4776
+ invalidatePersistedSavedHistoryIndex("hermes-cli", dir);
4777
+ savedHistorySessionCache.delete("hermes-cli");
4778
+ return true;
4779
+ } catch {
4780
+ return false;
4781
+ }
4782
+ }
4664
4783
  var fs3, path7, os6, HISTORY_DIR, RETAIN_DAYS, SAVED_HISTORY_INDEX_VERSION, SAVED_HISTORY_INDEX_FILE, SAVED_HISTORY_INDEX_LOCK_SUFFIX, SAVED_HISTORY_INDEX_LOCK_WAIT_MS, SAVED_HISTORY_INDEX_LOCK_STALE_MS, SAVED_HISTORY_INDEX_LOCK_POLL_MS, SAVED_HISTORY_ROLLUP_THRESHOLD_BYTES, savedHistorySessionCache, savedHistoryFileSummaryCache, savedHistoryBackgroundRefresh, savedHistoryRollupInFlight, CODEX_STARTER_PROMPT_RE, ChatHistoryWriter;
4665
4784
  var init_chat_history = __esm({
4666
4785
  "../../oss/packages/daemon-core/src/config/chat-history.ts"() {
@@ -7475,7 +7594,9 @@ function getTargetInstance(h, args) {
7475
7594
  const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
7476
7595
  const sessionId = targetSessionId || h.currentSession?.sessionId || "";
7477
7596
  if (!sessionId) return null;
7478
- return h.ctx.instanceManager?.getInstance(sessionId) || null;
7597
+ const session = h.ctx.sessionRegistry?.get(sessionId);
7598
+ const instanceKey = session?.adapterKey || session?.instanceKey || sessionId;
7599
+ return h.ctx.instanceManager?.getInstance(instanceKey) || null;
7479
7600
  }
7480
7601
  function getTargetTransport(h, provider) {
7481
7602
  if (h.currentSession?.transport) return h.currentSession.transport;
@@ -7772,7 +7893,7 @@ function getStateLastSignature(state) {
7772
7893
  async function getStableExtensionBaseline(h) {
7773
7894
  const first = await readExtensionChatState(h);
7774
7895
  if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
7775
- await new Promise((resolve17) => setTimeout(resolve17, 150));
7896
+ await new Promise((resolve18) => setTimeout(resolve18, 150));
7776
7897
  const second = await readExtensionChatState(h);
7777
7898
  return getStateMessageCount(second) >= getStateMessageCount(first) ? second : first;
7778
7899
  }
@@ -7780,7 +7901,7 @@ async function verifyExtensionSendObserved(h, before) {
7780
7901
  const beforeCount = getStateMessageCount(before);
7781
7902
  const beforeSignature = getStateLastSignature(before);
7782
7903
  for (let attempt = 0; attempt < 12; attempt += 1) {
7783
- await new Promise((resolve17) => setTimeout(resolve17, 250));
7904
+ await new Promise((resolve18) => setTimeout(resolve18, 250));
7784
7905
  const state = await readExtensionChatState(h);
7785
7906
  if (state?.status === "waiting_approval") return true;
7786
7907
  const afterCount = getStateMessageCount(state);
@@ -8544,10 +8665,17 @@ async function handleResolveAction(h, args) {
8544
8665
  }
8545
8666
  }
8546
8667
  const status = adapter.getStatus();
8547
- if (status?.status !== "waiting_approval") {
8668
+ const targetInstance = getTargetInstance(h, args);
8669
+ const targetState = targetInstance?.getState?.();
8670
+ const surfacedModal = targetState?.activeChat?.activeModal && Array.isArray(targetState.activeChat.activeModal.buttons) && targetState.activeChat.activeModal.buttons.some((candidate) => typeof candidate === "string" && candidate.trim()) ? targetState.activeChat.activeModal : null;
8671
+ const statusModal = status?.activeModal && Array.isArray(status.activeModal.buttons) && status.activeModal.buttons.some((candidate) => typeof candidate === "string" && candidate.trim()) ? status.activeModal : null;
8672
+ const effectiveModal = statusModal || surfacedModal;
8673
+ const effectiveStatus = status?.status === "waiting_approval" || targetState?.activeChat?.status === "waiting_approval" ? "waiting_approval" : status?.status;
8674
+ LOG.info("Command", `[resolveAction] CLI PTY gate target=${String(args?.targetSessionId || "")} rawStatus=${String(status?.status || "")} effectiveStatus=${String(effectiveStatus || "")} statusModal=${statusModal ? "yes" : "no"} surfacedModal=${surfacedModal ? "yes" : "no"} instance=${targetInstance ? "yes" : "no"}`);
8675
+ if (effectiveStatus !== "waiting_approval" && !effectiveModal) {
8548
8676
  return { success: false, error: "Not in approval state" };
8549
8677
  }
8550
- const buttons = status.activeModal?.buttons || ["Allow once", "Always allow", "Deny"];
8678
+ const buttons = effectiveModal?.buttons || ["Allow once", "Always allow", "Deny"];
8551
8679
  let buttonIndex = typeof args?.buttonIndex === "number" ? args.buttonIndex : -1;
8552
8680
  if (buttonIndex < 0) {
8553
8681
  const btnLower = button.toLowerCase();
@@ -10058,7 +10186,7 @@ var init_handler = __esm({
10058
10186
  try {
10059
10187
  const http3 = await import("http");
10060
10188
  const postData = JSON.stringify(body);
10061
- const result = await new Promise((resolve17, reject) => {
10189
+ const result = await new Promise((resolve18, reject) => {
10062
10190
  const req = http3.request({
10063
10191
  hostname: "127.0.0.1",
10064
10192
  port: 19280,
@@ -10070,9 +10198,9 @@ var init_handler = __esm({
10070
10198
  res.on("data", (chunk) => data += chunk);
10071
10199
  res.on("end", () => {
10072
10200
  try {
10073
- resolve17(JSON.parse(data));
10201
+ resolve18(JSON.parse(data));
10074
10202
  } catch {
10075
- resolve17({ raw: data });
10203
+ resolve18({ raw: data });
10076
10204
  }
10077
10205
  });
10078
10206
  });
@@ -10090,15 +10218,15 @@ var init_handler = __esm({
10090
10218
  if (!providerType) return { success: false, error: "providerType required" };
10091
10219
  try {
10092
10220
  const http3 = await import("http");
10093
- const result = await new Promise((resolve17, reject) => {
10221
+ const result = await new Promise((resolve18, reject) => {
10094
10222
  http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
10095
10223
  let data = "";
10096
10224
  res.on("data", (chunk) => data += chunk);
10097
10225
  res.on("end", () => {
10098
10226
  try {
10099
- resolve17(JSON.parse(data));
10227
+ resolve18(JSON.parse(data));
10100
10228
  } catch {
10101
- resolve17({ raw: data });
10229
+ resolve18({ raw: data });
10102
10230
  }
10103
10231
  });
10104
10232
  }).on("error", reject);
@@ -10112,7 +10240,7 @@ var init_handler = __esm({
10112
10240
  try {
10113
10241
  const http3 = await import("http");
10114
10242
  const postData = JSON.stringify(args || {});
10115
- const result = await new Promise((resolve17, reject) => {
10243
+ const result = await new Promise((resolve18, reject) => {
10116
10244
  const req = http3.request({
10117
10245
  hostname: "127.0.0.1",
10118
10246
  port: 19280,
@@ -10124,9 +10252,9 @@ var init_handler = __esm({
10124
10252
  res.on("data", (chunk) => data += chunk);
10125
10253
  res.on("end", () => {
10126
10254
  try {
10127
- resolve17(JSON.parse(data));
10255
+ resolve18(JSON.parse(data));
10128
10256
  } catch {
10129
- resolve17({ raw: data });
10257
+ resolve18({ raw: data });
10130
10258
  }
10131
10259
  });
10132
10260
  });
@@ -12784,7 +12912,7 @@ var init_provider_cli_adapter = __esm({
12784
12912
  `[${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)}`
12785
12913
  );
12786
12914
  }
12787
- await new Promise((resolve17) => setTimeout(resolve17, 50));
12915
+ await new Promise((resolve18) => setTimeout(resolve18, 50));
12788
12916
  }
12789
12917
  const finalScreenText = this.terminalScreen.getText() || "";
12790
12918
  LOG.warn(
@@ -13372,7 +13500,7 @@ var init_provider_cli_adapter = __esm({
13372
13500
  }
13373
13501
  projectEffectiveStatus(startupModal = null) {
13374
13502
  if (this.parseErrorMessage) return "error";
13375
- if (startupModal) return "waiting_approval";
13503
+ if (startupModal || this.activeModal) return "waiting_approval";
13376
13504
  if (this.isWaitingForResponse && this.currentTurnScope && this.currentStatus === "idle") return "generating";
13377
13505
  return this.currentStatus;
13378
13506
  }
@@ -13380,12 +13508,24 @@ var init_provider_cli_adapter = __esm({
13380
13508
  getStatus() {
13381
13509
  const screenText = this.terminalScreen.getText() || "";
13382
13510
  const startupModal = this.startupParseGate ? this.getStartupConfirmationModal(screenText) : null;
13383
- const effectiveStatus = this.projectEffectiveStatus(startupModal);
13511
+ let effectiveStatus = this.projectEffectiveStatus(startupModal);
13512
+ let effectiveModal = startupModal || this.activeModal;
13513
+ if (!startupModal && !effectiveModal && typeof this.cliScripts?.parseOutput === "function") {
13514
+ try {
13515
+ const parsed = this.getScriptParsedStatus();
13516
+ const parsedModal = parsed?.activeModal && Array.isArray(parsed.activeModal.buttons) && parsed.activeModal.buttons.some((button) => typeof button === "string" && button.trim()) ? parsed.activeModal : null;
13517
+ if (parsed?.status === "waiting_approval" && parsedModal) {
13518
+ effectiveStatus = "waiting_approval";
13519
+ effectiveModal = parsedModal;
13520
+ }
13521
+ } catch {
13522
+ }
13523
+ }
13384
13524
  return {
13385
13525
  status: effectiveStatus,
13386
13526
  messages: [...this.committedMessages],
13387
13527
  workingDir: this.workingDir,
13388
- activeModal: startupModal || this.activeModal,
13528
+ activeModal: effectiveModal,
13389
13529
  errorMessage: this.parseErrorMessage || void 0,
13390
13530
  errorReason: this.parseErrorMessage ? "parse_error" : void 0
13391
13531
  };
@@ -13421,6 +13561,15 @@ var init_provider_cli_adapter = __esm({
13421
13561
  this.currentTurnScope,
13422
13562
  screenText
13423
13563
  );
13564
+ const parsedModal = parsed?.activeModal && Array.isArray(parsed.activeModal.buttons) && parsed.activeModal.buttons.some((button) => typeof button === "string" && button.trim()) ? parsed.activeModal : null;
13565
+ if (parsedModal && parsed?.status === "waiting_approval") {
13566
+ this.activeModal = parsedModal;
13567
+ this.isWaitingForResponse = true;
13568
+ if (this.currentStatus !== "waiting_approval") {
13569
+ this.setStatus("waiting_approval", "parsed_waiting_approval");
13570
+ this.onStatusChange?.();
13571
+ }
13572
+ }
13424
13573
  if (this.maybeCommitVisibleIdleTranscript(parsed)) {
13425
13574
  return this.getScriptParsedStatus();
13426
13575
  }
@@ -13625,7 +13774,7 @@ ${data.message || ""}`.trim();
13625
13774
  const deadline = Date.now() + 1e4;
13626
13775
  while (this.startupParseGate && Date.now() < deadline) {
13627
13776
  this.resolveStartupState("send_wait");
13628
- await new Promise((resolve17) => setTimeout(resolve17, 50));
13777
+ await new Promise((resolve18) => setTimeout(resolve18, 50));
13629
13778
  }
13630
13779
  }
13631
13780
  if (!allowInterventionPrompt) {
@@ -13717,12 +13866,12 @@ ${data.message || ""}`.trim();
13717
13866
  if (this.isWaitingForResponse) this.finishResponse();
13718
13867
  }, this.timeouts.maxResponse);
13719
13868
  };
13720
- await new Promise((resolve17) => {
13869
+ await new Promise((resolve18) => {
13721
13870
  let resolved = false;
13722
13871
  const resolveOnce = () => {
13723
13872
  if (resolved) return;
13724
13873
  resolved = true;
13725
- resolve17();
13874
+ resolve18();
13726
13875
  };
13727
13876
  const submit = () => {
13728
13877
  if (!this.ptyProcess) {
@@ -13896,17 +14045,17 @@ ${data.message || ""}`.trim();
13896
14045
  }
13897
14046
  }
13898
14047
  waitForStopped(timeoutMs) {
13899
- return new Promise((resolve17) => {
14048
+ return new Promise((resolve18) => {
13900
14049
  const startedAt = Date.now();
13901
14050
  const timer = setInterval(() => {
13902
14051
  if (!this.ptyProcess || this.currentStatus === "stopped") {
13903
14052
  clearInterval(timer);
13904
- resolve17(true);
14053
+ resolve18(true);
13905
14054
  return;
13906
14055
  }
13907
14056
  if (Date.now() - startedAt >= timeoutMs) {
13908
14057
  clearInterval(timer);
13909
- resolve17(false);
14058
+ resolve18(false);
13910
14059
  }
13911
14060
  }, 100);
13912
14061
  });
@@ -14071,7 +14220,22 @@ ${data.message || ""}`.trim();
14071
14220
  }
14072
14221
  resolveModal(buttonIndex) {
14073
14222
  const screenText = this.terminalScreen.getText() || "";
14074
- const modal = this.activeModal || this.getStartupConfirmationModal(screenText);
14223
+ let modal = this.activeModal || this.getStartupConfirmationModal(screenText);
14224
+ if (!modal && typeof this.cliScripts?.parseOutput === "function") {
14225
+ try {
14226
+ const parsed = this.getScriptParsedStatus();
14227
+ const parsedModal = parsed?.activeModal && Array.isArray(parsed.activeModal.buttons) && parsed.activeModal.buttons.some((button) => typeof button === "string" && button.trim()) ? parsed.activeModal : null;
14228
+ if (parsed?.status === "waiting_approval" && parsedModal) {
14229
+ modal = parsedModal;
14230
+ this.activeModal = parsedModal;
14231
+ if (this.currentStatus !== "waiting_approval") {
14232
+ this.setStatus("waiting_approval", "resolve_modal_parse");
14233
+ this.onStatusChange?.();
14234
+ }
14235
+ }
14236
+ } catch {
14237
+ }
14238
+ }
14075
14239
  if (!this.ptyProcess || this.currentStatus !== "waiting_approval" && !modal) return;
14076
14240
  this.clearIdleFinishCandidate("resolve_modal");
14077
14241
  this.recordTrace("resolve_modal", {
@@ -14250,7 +14414,7 @@ async function waitForCliAdapterReady(adapter, options) {
14250
14414
  if (status === "stopped") {
14251
14415
  throw new Error("CLI runtime stopped before it became ready");
14252
14416
  }
14253
- await new Promise((resolve17) => setTimeout(resolve17, pollMs));
14417
+ await new Promise((resolve18) => setTimeout(resolve18, pollMs));
14254
14418
  }
14255
14419
  throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
14256
14420
  }
@@ -14309,6 +14473,7 @@ var init_cli_provider_instance = __esm({
14309
14473
  historyWriter;
14310
14474
  runtimeMessages = [];
14311
14475
  lastPersistedHistoryMessages = [];
14476
+ lastCanonicalHermesSyncMtimeMs = 0;
14312
14477
  instanceId;
14313
14478
  suppressIdleHistoryReplay = false;
14314
14479
  errorMessage = void 0;
@@ -14341,34 +14506,7 @@ var init_cli_provider_instance = __esm({
14341
14506
  await this.enforceFreshSessionLaunchIfNeeded();
14342
14507
  this.maybeAppendRuntimeRecoveryMessage(this.adapter.getRuntimeMetadata());
14343
14508
  if (this.providerSessionId) {
14344
- this.historyWriter.compactHistorySession(this.type, this.providerSessionId);
14345
- const restoredHistory = readChatHistory(this.type, 0, 200, this.providerSessionId);
14346
- this.historyWriter.seedSessionHistory(
14347
- this.type,
14348
- restoredHistory.messages,
14349
- this.providerSessionId,
14350
- this.instanceId
14351
- );
14352
- this.lastPersistedHistoryMessages = restoredHistory.messages.map((message) => ({
14353
- role: message.role,
14354
- content: message.content,
14355
- kind: message.kind,
14356
- senderName: message.senderName,
14357
- receivedAt: message.receivedAt
14358
- }));
14359
- this.suppressIdleHistoryReplay = restoredHistory.messages.length > 0;
14360
- if (restoredHistory.messages.length > 0) {
14361
- this.adapter.seedCommittedMessages(
14362
- restoredHistory.messages.map((message) => ({
14363
- role: message.role,
14364
- content: message.content,
14365
- timestamp: message.receivedAt,
14366
- receivedAt: message.receivedAt,
14367
- kind: message.kind,
14368
- senderName: message.senderName
14369
- }))
14370
- );
14371
- }
14509
+ this.restorePersistedHistoryFromCurrentSession();
14372
14510
  }
14373
14511
  if (this.providerSessionId && this.launchMode === "resume") {
14374
14512
  const resumedAt = Date.now();
@@ -14477,6 +14615,7 @@ var init_cli_provider_instance = __esm({
14477
14615
  parsedMessages = historyMessageCount > 0 ? parsedMessages.slice(-historyMessageCount) : [];
14478
14616
  }
14479
14617
  const mergedMessages = this.mergeConversationMessages(parsedMessages);
14618
+ const canonicalHermesBackedHistory = this.syncCanonicalHermesSavedHistoryIfNeeded();
14480
14619
  const dirName = this.workingDir.split("/").filter(Boolean).pop() || "session";
14481
14620
  if (parsedMessages.length > 0) {
14482
14621
  const shouldSkipReplayPersist = this.suppressIdleHistoryReplay && adapterStatus.status === "idle" && parsedStatus?.status === "idle";
@@ -14494,7 +14633,7 @@ var init_cli_provider_instance = __esm({
14494
14633
  senderName: typeof message.senderName === "string" ? message.senderName : void 0,
14495
14634
  receivedAt: typeof message.receivedAt === "number" ? message.receivedAt : message.timestamp
14496
14635
  }));
14497
- if (!shouldSkipReplayPersist && normalizedMessagesToSave.length > 0) {
14636
+ if (!canonicalHermesBackedHistory && !shouldSkipReplayPersist && normalizedMessagesToSave.length > 0) {
14498
14637
  const incrementalMessages = buildIncrementalHistoryAppendMessages(this.lastPersistedHistoryMessages, normalizedMessagesToSave);
14499
14638
  this.historyWriter.appendNewMessages(
14500
14639
  this.type,
@@ -14504,7 +14643,9 @@ var init_cli_provider_instance = __esm({
14504
14643
  this.providerSessionId
14505
14644
  );
14506
14645
  }
14507
- this.lastPersistedHistoryMessages = normalizedMessagesToSave;
14646
+ if (!canonicalHermesBackedHistory) {
14647
+ this.lastPersistedHistoryMessages = normalizedMessagesToSave;
14648
+ }
14508
14649
  }
14509
14650
  this.applyProviderResponse(parsedStatus, { phase: "immediate" });
14510
14651
  const surface = resolveProviderStateSurface({
@@ -14961,6 +15102,7 @@ ${effect.notification.body || ""}`.trim();
14961
15102
  this.providerSessionId = nextSessionId;
14962
15103
  this.historyWriter.promoteHistorySession(this.type, previousHistorySessionId, nextSessionId);
14963
15104
  this.historyWriter.writeSessionStart(this.type, nextSessionId, this.workingDir, this.instanceId);
15105
+ this.restorePersistedHistoryFromCurrentSession();
14964
15106
  this.adapter.updateRuntimeMeta({ providerSessionId: nextSessionId });
14965
15107
  this.onProviderSessionResolved?.({
14966
15108
  instanceId: this.instanceId,
@@ -14972,6 +15114,61 @@ ${effect.notification.body || ""}`.trim();
14972
15114
  });
14973
15115
  LOG.info("CLI", `[${this.type}] discovered provider session id: ${nextSessionId}`);
14974
15116
  }
15117
+ syncCanonicalHermesSavedHistoryIfNeeded() {
15118
+ if (this.type !== "hermes-cli" || !this.providerSessionId) return false;
15119
+ try {
15120
+ const canonicalPath = path12.join(os14.homedir(), ".hermes", "sessions", `session_${this.providerSessionId}.json`);
15121
+ if (!fs5.existsSync(canonicalPath)) return false;
15122
+ const stat4 = fs5.statSync(canonicalPath);
15123
+ if (stat4.mtimeMs <= this.lastCanonicalHermesSyncMtimeMs) return true;
15124
+ const rebuilt = rebuildHermesSavedHistoryFromCanonicalSession(this.providerSessionId);
15125
+ if (!rebuilt) return false;
15126
+ this.lastCanonicalHermesSyncMtimeMs = stat4.mtimeMs;
15127
+ const restoredHistory = readChatHistory(this.type, 0, 200, this.providerSessionId);
15128
+ this.lastPersistedHistoryMessages = restoredHistory.messages.map((message) => ({
15129
+ role: message.role,
15130
+ content: message.content,
15131
+ kind: message.kind,
15132
+ senderName: message.senderName,
15133
+ receivedAt: message.receivedAt
15134
+ }));
15135
+ return true;
15136
+ } catch {
15137
+ return false;
15138
+ }
15139
+ }
15140
+ restorePersistedHistoryFromCurrentSession() {
15141
+ if (!this.providerSessionId) return;
15142
+ this.syncCanonicalHermesSavedHistoryIfNeeded();
15143
+ this.historyWriter.compactHistorySession(this.type, this.providerSessionId);
15144
+ const restoredHistory = readChatHistory(this.type, 0, 200, this.providerSessionId);
15145
+ this.historyWriter.seedSessionHistory(
15146
+ this.type,
15147
+ restoredHistory.messages,
15148
+ this.providerSessionId,
15149
+ this.instanceId
15150
+ );
15151
+ this.lastPersistedHistoryMessages = restoredHistory.messages.map((message) => ({
15152
+ role: message.role,
15153
+ content: message.content,
15154
+ kind: message.kind,
15155
+ senderName: message.senderName,
15156
+ receivedAt: message.receivedAt
15157
+ }));
15158
+ this.suppressIdleHistoryReplay = restoredHistory.messages.length > 0;
15159
+ if (restoredHistory.messages.length > 0) {
15160
+ this.adapter.seedCommittedMessages(
15161
+ restoredHistory.messages.map((message) => ({
15162
+ role: message.role,
15163
+ content: message.content,
15164
+ timestamp: message.receivedAt,
15165
+ receivedAt: message.receivedAt,
15166
+ kind: message.kind,
15167
+ senderName: message.senderName
15168
+ }))
15169
+ );
15170
+ }
15171
+ }
14975
15172
  getProbeDirectories() {
14976
15173
  const dirs = /* @__PURE__ */ new Set();
14977
15174
  const addDir = (value) => {
@@ -31064,8 +31261,8 @@ var init_acp = __esm({
31064
31261
  this.#requestHandler = requestHandler;
31065
31262
  this.#notificationHandler = notificationHandler;
31066
31263
  this.#stream = stream;
31067
- this.#closedPromise = new Promise((resolve17) => {
31068
- this.#abortController.signal.addEventListener("abort", () => resolve17());
31264
+ this.#closedPromise = new Promise((resolve18) => {
31265
+ this.#abortController.signal.addEventListener("abort", () => resolve18());
31069
31266
  });
31070
31267
  this.#receive();
31071
31268
  }
@@ -31214,8 +31411,8 @@ var init_acp = __esm({
31214
31411
  }
31215
31412
  async sendRequest(method, params) {
31216
31413
  const id = this.#nextRequestId++;
31217
- const responsePromise = new Promise((resolve17, reject) => {
31218
- this.#pendingResponses.set(id, { resolve: resolve17, reject });
31414
+ const responsePromise = new Promise((resolve18, reject) => {
31415
+ this.#pendingResponses.set(id, { resolve: resolve18, reject });
31219
31416
  });
31220
31417
  await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
31221
31418
  return responsePromise;
@@ -31886,13 +32083,13 @@ var init_acp_provider_instance = __esm({
31886
32083
  }
31887
32084
  this.currentStatus = "waiting_approval";
31888
32085
  this.detectStatusTransition();
31889
- const approved = await new Promise((resolve17) => {
31890
- this.permissionResolvers.push(resolve17);
32086
+ const approved = await new Promise((resolve18) => {
32087
+ this.permissionResolvers.push(resolve18);
31891
32088
  setTimeout(() => {
31892
- const idx = this.permissionResolvers.indexOf(resolve17);
32089
+ const idx = this.permissionResolvers.indexOf(resolve18);
31893
32090
  if (idx >= 0) {
31894
32091
  this.permissionResolvers.splice(idx, 1);
31895
- resolve17(false);
32092
+ resolve18(false);
31896
32093
  }
31897
32094
  }, 3e5);
31898
32095
  });
@@ -34115,7 +34312,7 @@ var init_handler2 = __esm({
34115
34312
  this._addToNodeFs(path35, initialAdd, wh, depth + 1);
34116
34313
  }
34117
34314
  }).on(EV.ERROR, this._boundHandleError);
34118
- return new Promise((resolve17, reject) => {
34315
+ return new Promise((resolve18, reject) => {
34119
34316
  if (!stream)
34120
34317
  return reject();
34121
34318
  stream.once(STR_END, () => {
@@ -34124,7 +34321,7 @@ var init_handler2 = __esm({
34124
34321
  return;
34125
34322
  }
34126
34323
  const wasThrottled = throttler ? throttler.clear() : false;
34127
- resolve17(void 0);
34324
+ resolve18(void 0);
34128
34325
  previous.getChildren().filter((item) => {
34129
34326
  return item !== directory && !current.has(item);
34130
34327
  }).forEach((item) => {
@@ -35215,10 +35412,75 @@ var init_provider_loader = __esm({
35215
35412
  }
35216
35413
  static GITHUB_TARBALL_URL = "https://github.com/vilmire/adhdev-providers/archive/refs/heads/main.tar.gz";
35217
35414
  static META_FILE = ".meta.json";
35415
+ static REPO_PROVIDER_DIRNAME = "adhdev-providers";
35416
+ static SIBLING_MARKER_FILE = ".adhdev-provider-root";
35417
+ static SIBLING_ENV_VAR = "ADHDEV_USE_SIBLING_PROVIDERS";
35418
+ probeStarts = [];
35419
+ siblingLogged = false;
35420
+ userDirSource = "home-default";
35421
+ /** Process-level dedup for stderr sibling-adoption notices (shared across all ProviderLoader instances). */
35422
+ static siblingStderrLogged = /* @__PURE__ */ new Set();
35423
+ static looksLikeProviderRoot(candidate) {
35424
+ try {
35425
+ if (!fs6.existsSync(candidate) || !fs6.statSync(candidate).isDirectory()) return false;
35426
+ return ["ide", "extension", "cli", "acp"].some(
35427
+ (category) => fs6.existsSync(path14.join(candidate, category))
35428
+ );
35429
+ } catch {
35430
+ return false;
35431
+ }
35432
+ }
35433
+ static hasProviderRootMarker(candidate) {
35434
+ try {
35435
+ return fs6.existsSync(path14.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
35436
+ } catch {
35437
+ return false;
35438
+ }
35439
+ }
35440
+ detectDefaultUserDir() {
35441
+ const fallback2 = path14.join(os16.homedir(), ".adhdev", "providers");
35442
+ const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
35443
+ const visited = /* @__PURE__ */ new Set();
35444
+ for (const start of this.probeStarts) {
35445
+ let current = path14.resolve(start);
35446
+ while (!visited.has(current)) {
35447
+ visited.add(current);
35448
+ const siblingCandidate = path14.join(path14.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
35449
+ if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
35450
+ const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
35451
+ if (envOptIn || hasMarker) {
35452
+ const source = hasMarker ? "sibling-marker" : "sibling-env";
35453
+ if (!this.siblingLogged) {
35454
+ this.log(`Using sibling provider checkout (${source}): ${siblingCandidate}`);
35455
+ this.siblingLogged = true;
35456
+ }
35457
+ if (!_ProviderLoader.siblingStderrLogged.has(siblingCandidate)) {
35458
+ _ProviderLoader.siblingStderrLogged.add(siblingCandidate);
35459
+ try {
35460
+ process.stderr.write(
35461
+ `[adhdev] Using sibling adhdev-providers checkout (${source}): ${siblingCandidate}
35462
+ `
35463
+ );
35464
+ } catch {
35465
+ }
35466
+ }
35467
+ return { path: siblingCandidate, source };
35468
+ }
35469
+ }
35470
+ const parent = path14.dirname(current);
35471
+ if (parent === current) break;
35472
+ current = parent;
35473
+ }
35474
+ }
35475
+ return { path: fallback2, source: "home-default" };
35476
+ }
35218
35477
  constructor(options) {
35219
35478
  this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
35479
+ this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
35220
35480
  this.defaultProvidersDir = path14.join(os16.homedir(), ".adhdev", "providers");
35221
- this.userDir = this.defaultProvidersDir;
35481
+ const detected = this.detectDefaultUserDir();
35482
+ this.userDir = detected.path;
35483
+ this.userDirSource = detected.source;
35222
35484
  this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
35223
35485
  this.disableUpstream = false;
35224
35486
  this.applySourceConfig({
@@ -35256,6 +35518,7 @@ var init_provider_loader = __esm({
35256
35518
  disableUpstream: this.disableUpstream,
35257
35519
  explicitProviderDir: this.explicitProviderDir,
35258
35520
  userDir: this.userDir,
35521
+ userDirSource: this.userDirSource,
35259
35522
  upstreamDir: this.upstreamDir,
35260
35523
  providerRoots: this.getProviderRoots()
35261
35524
  };
@@ -35266,7 +35529,14 @@ var init_provider_loader = __esm({
35266
35529
  this.explicitProviderDir = options.userDir?.trim() ? options.userDir : null;
35267
35530
  }
35268
35531
  this.sourceMode = nextSourceMode;
35269
- this.userDir = this.explicitProviderDir || this.defaultProvidersDir;
35532
+ if (this.explicitProviderDir) {
35533
+ this.userDir = this.explicitProviderDir;
35534
+ this.userDirSource = "explicit";
35535
+ } else {
35536
+ const detected = this.detectDefaultUserDir();
35537
+ this.userDir = detected.path;
35538
+ this.userDirSource = detected.source;
35539
+ }
35270
35540
  this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
35271
35541
  this.disableUpstream = this.sourceMode === "no-upstream";
35272
35542
  if (this.explicitProviderDir) {
@@ -35860,7 +36130,7 @@ var init_provider_loader = __esm({
35860
36130
  return { updated: false };
35861
36131
  }
35862
36132
  try {
35863
- const etag = await new Promise((resolve17, reject) => {
36133
+ const etag = await new Promise((resolve18, reject) => {
35864
36134
  const options = {
35865
36135
  method: "HEAD",
35866
36136
  hostname: "github.com",
@@ -35878,7 +36148,7 @@ var init_provider_loader = __esm({
35878
36148
  headers: { "User-Agent": "adhdev-launcher" },
35879
36149
  timeout: 1e4
35880
36150
  }, (res2) => {
35881
- resolve17(res2.headers.etag || res2.headers["last-modified"] || "");
36151
+ resolve18(res2.headers.etag || res2.headers["last-modified"] || "");
35882
36152
  });
35883
36153
  req2.on("error", reject);
35884
36154
  req2.on("timeout", () => {
@@ -35887,7 +36157,7 @@ var init_provider_loader = __esm({
35887
36157
  });
35888
36158
  req2.end();
35889
36159
  } else {
35890
- resolve17(res.headers.etag || res.headers["last-modified"] || "");
36160
+ resolve18(res.headers.etag || res.headers["last-modified"] || "");
35891
36161
  }
35892
36162
  });
35893
36163
  req.on("error", reject);
@@ -35951,7 +36221,7 @@ var init_provider_loader = __esm({
35951
36221
  downloadFile(url2, destPath) {
35952
36222
  const https = require("https");
35953
36223
  const http3 = require("http");
35954
- return new Promise((resolve17, reject) => {
36224
+ return new Promise((resolve18, reject) => {
35955
36225
  const doRequest = (reqUrl, redirectCount = 0) => {
35956
36226
  if (redirectCount > 5) {
35957
36227
  reject(new Error("Too many redirects"));
@@ -35971,7 +36241,7 @@ var init_provider_loader = __esm({
35971
36241
  res.pipe(ws);
35972
36242
  ws.on("finish", () => {
35973
36243
  ws.close();
35974
- resolve17();
36244
+ resolve18();
35975
36245
  });
35976
36246
  ws.on("error", reject);
35977
36247
  });
@@ -36447,17 +36717,17 @@ async function findFreePort(ports) {
36447
36717
  throw new Error("No free port found");
36448
36718
  }
36449
36719
  function checkPortFree(port) {
36450
- return new Promise((resolve17) => {
36720
+ return new Promise((resolve18) => {
36451
36721
  const server = net2.createServer();
36452
36722
  server.unref();
36453
- server.on("error", () => resolve17(false));
36723
+ server.on("error", () => resolve18(false));
36454
36724
  server.listen(port, "127.0.0.1", () => {
36455
- server.close(() => resolve17(true));
36725
+ server.close(() => resolve18(true));
36456
36726
  });
36457
36727
  });
36458
36728
  }
36459
36729
  async function isCdpActive(port) {
36460
- return new Promise((resolve17) => {
36730
+ return new Promise((resolve18) => {
36461
36731
  const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
36462
36732
  timeout: 2e3
36463
36733
  }, (res) => {
@@ -36466,16 +36736,16 @@ async function isCdpActive(port) {
36466
36736
  res.on("end", () => {
36467
36737
  try {
36468
36738
  const info = JSON.parse(data);
36469
- resolve17(!!info["WebKit-Version"] || !!info["Browser"]);
36739
+ resolve18(!!info["WebKit-Version"] || !!info["Browser"]);
36470
36740
  } catch {
36471
- resolve17(false);
36741
+ resolve18(false);
36472
36742
  }
36473
36743
  });
36474
36744
  });
36475
- req.on("error", () => resolve17(false));
36745
+ req.on("error", () => resolve18(false));
36476
36746
  req.on("timeout", () => {
36477
36747
  req.destroy();
36478
- resolve17(false);
36748
+ resolve18(false);
36479
36749
  });
36480
36750
  });
36481
36751
  }
@@ -37285,7 +37555,7 @@ async function waitForPidExit(pid, timeoutMs) {
37285
37555
  while (Date.now() - start < timeoutMs) {
37286
37556
  try {
37287
37557
  process.kill(pid, 0);
37288
- await new Promise((resolve17) => setTimeout(resolve17, 250));
37558
+ await new Promise((resolve18) => setTimeout(resolve18, 250));
37289
37559
  } catch {
37290
37560
  return;
37291
37561
  }
@@ -37400,7 +37670,7 @@ async function runDaemonUpgradeHelper(payload) {
37400
37670
  appendUpgradeLog(installOutput.trim());
37401
37671
  }
37402
37672
  if (process.platform === "win32") {
37403
- await new Promise((resolve17) => setTimeout(resolve17, 500));
37673
+ await new Promise((resolve18) => setTimeout(resolve18, 500));
37404
37674
  cleanupStaleGlobalInstallDirs(payload.packageName);
37405
37675
  appendUpgradeLog("Post-install staging cleanup complete");
37406
37676
  }
@@ -38808,7 +39078,7 @@ var init_provider_adapter = __esm({
38808
39078
  const beforeCount = this.messageCount(before);
38809
39079
  const beforeSignature = this.lastMessageSignature(before);
38810
39080
  for (let attempt = 0; attempt < 12; attempt += 1) {
38811
- await new Promise((resolve17) => setTimeout(resolve17, 250));
39081
+ await new Promise((resolve18) => setTimeout(resolve18, 250));
38812
39082
  let state;
38813
39083
  try {
38814
39084
  state = await this.readChat(evaluate);
@@ -38830,7 +39100,7 @@ var init_provider_adapter = __esm({
38830
39100
  if (this.messageCount(first) > 0 || this.lastMessageSignature(first)) {
38831
39101
  return first;
38832
39102
  }
38833
- await new Promise((resolve17) => setTimeout(resolve17, 150));
39103
+ await new Promise((resolve18) => setTimeout(resolve18, 150));
38834
39104
  const second = await this.readChat(evaluate);
38835
39105
  return this.messageCount(second) >= this.messageCount(first) ? second : first;
38836
39106
  }
@@ -38981,7 +39251,7 @@ var init_provider_adapter = __esm({
38981
39251
  if (typeof data.error === "string" && data.error.trim()) return false;
38982
39252
  }
38983
39253
  for (let attempt = 0; attempt < 6; attempt += 1) {
38984
- await new Promise((resolve17) => setTimeout(resolve17, 250));
39254
+ await new Promise((resolve18) => setTimeout(resolve18, 250));
38985
39255
  const state = await this.readChat(evaluate);
38986
39256
  const title = this.getStateTitle(state);
38987
39257
  if (this.titlesMatch(title, sessionId)) return true;
@@ -41556,7 +41826,7 @@ function getCliTargetBundle(ctx, type, instanceId) {
41556
41826
  return { target, instance, adapter };
41557
41827
  }
41558
41828
  function sleep(ms) {
41559
- return new Promise((resolve17) => setTimeout(resolve17, ms));
41829
+ return new Promise((resolve18) => setTimeout(resolve18, ms));
41560
41830
  }
41561
41831
  async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
41562
41832
  const startedAt = Date.now();
@@ -43848,15 +44118,15 @@ var init_dev_server = __esm({
43848
44118
  this.json(res, 500, { error: e.message });
43849
44119
  }
43850
44120
  });
43851
- return new Promise((resolve17, reject) => {
44121
+ return new Promise((resolve18, reject) => {
43852
44122
  this.server.listen(port, "127.0.0.1", () => {
43853
44123
  this.log(`Dev server listening on http://127.0.0.1:${port}`);
43854
- resolve17();
44124
+ resolve18();
43855
44125
  });
43856
44126
  this.server.on("error", (e) => {
43857
44127
  if (e.code === "EADDRINUSE") {
43858
44128
  this.log(`Port ${port} in use, skipping dev server`);
43859
- resolve17();
44129
+ resolve18();
43860
44130
  } else {
43861
44131
  reject(e);
43862
44132
  }
@@ -43938,20 +44208,20 @@ var init_dev_server = __esm({
43938
44208
  child.stderr?.on("data", (d) => {
43939
44209
  stderr += d.toString().slice(0, 2e3);
43940
44210
  });
43941
- await new Promise((resolve17) => {
44211
+ await new Promise((resolve18) => {
43942
44212
  const timer = setTimeout(() => {
43943
44213
  child.kill();
43944
- resolve17();
44214
+ resolve18();
43945
44215
  }, 3e3);
43946
44216
  child.on("exit", () => {
43947
44217
  clearTimeout(timer);
43948
- resolve17();
44218
+ resolve18();
43949
44219
  });
43950
44220
  child.stdout?.once("data", () => {
43951
44221
  setTimeout(() => {
43952
44222
  child.kill();
43953
44223
  clearTimeout(timer);
43954
- resolve17();
44224
+ resolve18();
43955
44225
  }, 500);
43956
44226
  });
43957
44227
  });
@@ -44467,14 +44737,14 @@ var init_dev_server = __esm({
44467
44737
  child.stderr?.on("data", (d) => {
44468
44738
  stderr += d.toString();
44469
44739
  });
44470
- await new Promise((resolve17) => {
44740
+ await new Promise((resolve18) => {
44471
44741
  const timer = setTimeout(() => {
44472
44742
  child.kill();
44473
- resolve17();
44743
+ resolve18();
44474
44744
  }, timeout);
44475
44745
  child.on("exit", () => {
44476
44746
  clearTimeout(timer);
44477
- resolve17();
44747
+ resolve18();
44478
44748
  });
44479
44749
  });
44480
44750
  const elapsed = Date.now() - start;
@@ -45144,14 +45414,14 @@ data: ${JSON.stringify(msg.data)}
45144
45414
  res.end(JSON.stringify(data, null, 2));
45145
45415
  }
45146
45416
  async readBody(req) {
45147
- return new Promise((resolve17) => {
45417
+ return new Promise((resolve18) => {
45148
45418
  let body = "";
45149
45419
  req.on("data", (chunk) => body += chunk);
45150
45420
  req.on("end", () => {
45151
45421
  try {
45152
- resolve17(JSON.parse(body));
45422
+ resolve18(JSON.parse(body));
45153
45423
  } catch {
45154
- resolve17({});
45424
+ resolve18({});
45155
45425
  }
45156
45426
  });
45157
45427
  });
@@ -45666,7 +45936,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
45666
45936
  const deadline = Date.now() + timeoutMs;
45667
45937
  while (Date.now() < deadline) {
45668
45938
  if (await canConnect(endpoint)) return;
45669
- await new Promise((resolve17) => setTimeout(resolve17, STARTUP_POLL_MS));
45939
+ await new Promise((resolve18) => setTimeout(resolve18, STARTUP_POLL_MS));
45670
45940
  }
45671
45941
  throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
45672
45942
  }
@@ -45772,10 +46042,10 @@ async function installExtension(ide, extension) {
45772
46042
  const buffer = Buffer.from(await res.arrayBuffer());
45773
46043
  const fs27 = await import("fs");
45774
46044
  fs27.writeFileSync(vsixPath, buffer);
45775
- return new Promise((resolve17) => {
46045
+ return new Promise((resolve18) => {
45776
46046
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
45777
46047
  (0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
45778
- resolve17({
46048
+ resolve18({
45779
46049
  extensionId: extension.id,
45780
46050
  marketplaceId: extension.marketplaceId,
45781
46051
  success: !error48,
@@ -45788,11 +46058,11 @@ async function installExtension(ide, extension) {
45788
46058
  } catch (e) {
45789
46059
  }
45790
46060
  }
45791
- return new Promise((resolve17) => {
46061
+ return new Promise((resolve18) => {
45792
46062
  const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
45793
46063
  (0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
45794
46064
  if (error48) {
45795
- resolve17({
46065
+ resolve18({
45796
46066
  extensionId: extension.id,
45797
46067
  marketplaceId: extension.marketplaceId,
45798
46068
  success: false,
@@ -45800,7 +46070,7 @@ async function installExtension(ide, extension) {
45800
46070
  error: stderr || error48.message
45801
46071
  });
45802
46072
  } else {
45803
- resolve17({
46073
+ resolve18({
45804
46074
  extensionId: extension.id,
45805
46075
  marketplaceId: extension.marketplaceId,
45806
46076
  success: true,
@@ -46464,7 +46734,7 @@ async function sendDaemonCommand(cmd, args = {}, port) {
46464
46734
  const resolvedPort = resolveDaemonCommandPort(port);
46465
46735
  const WebSocket4 = (await import("ws")).default;
46466
46736
  const { DAEMON_WS_PATH: DAEMON_WS_PATH2 } = await Promise.resolve().then(() => (init_src(), src_exports));
46467
- return new Promise((resolve17, reject) => {
46737
+ return new Promise((resolve18, reject) => {
46468
46738
  const wsUrl = `ws://127.0.0.1:${resolvedPort}${DAEMON_WS_PATH2 || "/daemon"}`;
46469
46739
  const ws = new WebSocket4(wsUrl);
46470
46740
  const requestId = `cli-${Date.now()}`;
@@ -46505,7 +46775,7 @@ async function sendDaemonCommand(cmd, args = {}, port) {
46505
46775
  if (msg.type === "ext:command_result" && msg.payload?.requestId === requestId || msg.type === "daemon:command_result" || msg.type === "command_result") {
46506
46776
  clearTimeout(timeout);
46507
46777
  ws.close();
46508
- resolve17(msg.payload?.result || msg.payload || msg);
46778
+ resolve18(msg.payload?.result || msg.payload || msg);
46509
46779
  }
46510
46780
  } catch {
46511
46781
  }
@@ -46524,13 +46794,13 @@ This command needs a running local daemon with IPC enabled. Start with: adhdev d
46524
46794
  }
46525
46795
  async function directCdpEval(expression, port = 9222) {
46526
46796
  const http3 = await import("http");
46527
- const targets = await new Promise((resolve17, reject) => {
46797
+ const targets = await new Promise((resolve18, reject) => {
46528
46798
  http3.get(`http://127.0.0.1:${port}/json`, (res) => {
46529
46799
  let data = "";
46530
46800
  res.on("data", (c) => data += c);
46531
46801
  res.on("end", () => {
46532
46802
  try {
46533
- resolve17(JSON.parse(data));
46803
+ resolve18(JSON.parse(data));
46534
46804
  } catch {
46535
46805
  reject(new Error("Invalid JSON"));
46536
46806
  }
@@ -46543,7 +46813,7 @@ async function directCdpEval(expression, port = 9222) {
46543
46813
  const target = (mainPages.length > 0 ? mainPages[0] : pages[0]) || targets[0];
46544
46814
  if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target found");
46545
46815
  const WebSocket4 = (await import("ws")).default;
46546
- return new Promise((resolve17, reject) => {
46816
+ return new Promise((resolve18, reject) => {
46547
46817
  const ws = new WebSocket4(target.webSocketDebuggerUrl);
46548
46818
  const timeout = setTimeout(() => {
46549
46819
  ws.close();
@@ -46565,11 +46835,11 @@ async function directCdpEval(expression, port = 9222) {
46565
46835
  clearTimeout(timeout);
46566
46836
  ws.close();
46567
46837
  if (msg.result?.result?.value !== void 0) {
46568
- resolve17(msg.result.result.value);
46838
+ resolve18(msg.result.result.value);
46569
46839
  } else if (msg.result?.exceptionDetails) {
46570
46840
  reject(new Error(msg.result.exceptionDetails.text));
46571
46841
  } else {
46572
- resolve17(msg.result);
46842
+ resolve18(msg.result);
46573
46843
  }
46574
46844
  }
46575
46845
  });
@@ -47105,14 +47375,14 @@ var require_run_async = __commonJS({
47105
47375
  return function() {
47106
47376
  var args = arguments;
47107
47377
  var originalThis = this;
47108
- var promise2 = new Promise(function(resolve17, reject) {
47378
+ var promise2 = new Promise(function(resolve18, reject) {
47109
47379
  var resolved = false;
47110
47380
  const wrappedResolve = function(value) {
47111
47381
  if (resolved) {
47112
47382
  console.warn("Run-async promise already resolved.");
47113
47383
  }
47114
47384
  resolved = true;
47115
- resolve17(value);
47385
+ resolve18(value);
47116
47386
  };
47117
47387
  var rejected = false;
47118
47388
  const wrappedReject = function(value) {
@@ -47903,7 +48173,7 @@ var require_Observable = __commonJS({
47903
48173
  Observable2.prototype.forEach = function(next, promiseCtor) {
47904
48174
  var _this = this;
47905
48175
  promiseCtor = getPromiseCtor(promiseCtor);
47906
- return new promiseCtor(function(resolve17, reject) {
48176
+ return new promiseCtor(function(resolve18, reject) {
47907
48177
  var subscriber = new Subscriber_1.SafeSubscriber({
47908
48178
  next: function(value) {
47909
48179
  try {
@@ -47914,7 +48184,7 @@ var require_Observable = __commonJS({
47914
48184
  }
47915
48185
  },
47916
48186
  error: reject,
47917
- complete: resolve17
48187
+ complete: resolve18
47918
48188
  });
47919
48189
  _this.subscribe(subscriber);
47920
48190
  });
@@ -47936,14 +48206,14 @@ var require_Observable = __commonJS({
47936
48206
  Observable2.prototype.toPromise = function(promiseCtor) {
47937
48207
  var _this = this;
47938
48208
  promiseCtor = getPromiseCtor(promiseCtor);
47939
- return new promiseCtor(function(resolve17, reject) {
48209
+ return new promiseCtor(function(resolve18, reject) {
47940
48210
  var value;
47941
48211
  _this.subscribe(function(x) {
47942
48212
  return value = x;
47943
48213
  }, function(err) {
47944
48214
  return reject(err);
47945
48215
  }, function() {
47946
- return resolve17(value);
48216
+ return resolve18(value);
47947
48217
  });
47948
48218
  });
47949
48219
  };
@@ -50039,11 +50309,11 @@ var require_innerFrom = __commonJS({
50039
50309
  "use strict";
50040
50310
  var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
50041
50311
  function adopt(value) {
50042
- return value instanceof P ? value : new P(function(resolve17) {
50043
- resolve17(value);
50312
+ return value instanceof P ? value : new P(function(resolve18) {
50313
+ resolve18(value);
50044
50314
  });
50045
50315
  }
50046
- return new (P || (P = Promise))(function(resolve17, reject) {
50316
+ return new (P || (P = Promise))(function(resolve18, reject) {
50047
50317
  function fulfilled(value) {
50048
50318
  try {
50049
50319
  step(generator.next(value));
@@ -50059,7 +50329,7 @@ var require_innerFrom = __commonJS({
50059
50329
  }
50060
50330
  }
50061
50331
  function step(result) {
50062
- result.done ? resolve17(result.value) : adopt(result.value).then(fulfilled, rejected);
50332
+ result.done ? resolve18(result.value) : adopt(result.value).then(fulfilled, rejected);
50063
50333
  }
50064
50334
  step((generator = generator.apply(thisArg, _arguments || [])).next());
50065
50335
  });
@@ -50141,14 +50411,14 @@ var require_innerFrom = __commonJS({
50141
50411
  }, i);
50142
50412
  function verb(n) {
50143
50413
  i[n] = o[n] && function(v) {
50144
- return new Promise(function(resolve17, reject) {
50145
- v = o[n](v), settle(resolve17, reject, v.done, v.value);
50414
+ return new Promise(function(resolve18, reject) {
50415
+ v = o[n](v), settle(resolve18, reject, v.done, v.value);
50146
50416
  });
50147
50417
  };
50148
50418
  }
50149
- function settle(resolve17, reject, d, v) {
50419
+ function settle(resolve18, reject, d, v) {
50150
50420
  Promise.resolve(v).then(function(v2) {
50151
- resolve17({ value: v2, done: d });
50421
+ resolve18({ value: v2, done: d });
50152
50422
  }, reject);
50153
50423
  }
50154
50424
  };
@@ -50767,7 +51037,7 @@ var require_lastValueFrom = __commonJS({
50767
51037
  var EmptyError_1 = require_EmptyError();
50768
51038
  function lastValueFrom(source, config2) {
50769
51039
  var hasConfig = typeof config2 === "object";
50770
- return new Promise(function(resolve17, reject) {
51040
+ return new Promise(function(resolve18, reject) {
50771
51041
  var _hasValue = false;
50772
51042
  var _value;
50773
51043
  source.subscribe({
@@ -50778,9 +51048,9 @@ var require_lastValueFrom = __commonJS({
50778
51048
  error: reject,
50779
51049
  complete: function() {
50780
51050
  if (_hasValue) {
50781
- resolve17(_value);
51051
+ resolve18(_value);
50782
51052
  } else if (hasConfig) {
50783
- resolve17(config2.defaultValue);
51053
+ resolve18(config2.defaultValue);
50784
51054
  } else {
50785
51055
  reject(new EmptyError_1.EmptyError());
50786
51056
  }
@@ -50802,16 +51072,16 @@ var require_firstValueFrom = __commonJS({
50802
51072
  var Subscriber_1 = require_Subscriber();
50803
51073
  function firstValueFrom(source, config2) {
50804
51074
  var hasConfig = typeof config2 === "object";
50805
- return new Promise(function(resolve17, reject) {
51075
+ return new Promise(function(resolve18, reject) {
50806
51076
  var subscriber = new Subscriber_1.SafeSubscriber({
50807
51077
  next: function(value) {
50808
- resolve17(value);
51078
+ resolve18(value);
50809
51079
  subscriber.unsubscribe();
50810
51080
  },
50811
51081
  error: reject,
50812
51082
  complete: function() {
50813
51083
  if (hasConfig) {
50814
- resolve17(config2.defaultValue);
51084
+ resolve18(config2.defaultValue);
50815
51085
  } else {
50816
51086
  reject(new EmptyError_1.EmptyError());
50817
51087
  }
@@ -62617,14 +62887,14 @@ var require_async_iterator = __commonJS({
62617
62887
  };
62618
62888
  }
62619
62889
  function readAndResolve(iter) {
62620
- var resolve17 = iter[kLastResolve];
62621
- if (resolve17 !== null) {
62890
+ var resolve18 = iter[kLastResolve];
62891
+ if (resolve18 !== null) {
62622
62892
  var data = iter[kStream].read();
62623
62893
  if (data !== null) {
62624
62894
  iter[kLastPromise] = null;
62625
62895
  iter[kLastResolve] = null;
62626
62896
  iter[kLastReject] = null;
62627
- resolve17(createIterResult(data, false));
62897
+ resolve18(createIterResult(data, false));
62628
62898
  }
62629
62899
  }
62630
62900
  }
@@ -62632,13 +62902,13 @@ var require_async_iterator = __commonJS({
62632
62902
  process.nextTick(readAndResolve, iter);
62633
62903
  }
62634
62904
  function wrapForNext(lastPromise, iter) {
62635
- return function(resolve17, reject) {
62905
+ return function(resolve18, reject) {
62636
62906
  lastPromise.then(function() {
62637
62907
  if (iter[kEnded]) {
62638
- resolve17(createIterResult(void 0, true));
62908
+ resolve18(createIterResult(void 0, true));
62639
62909
  return;
62640
62910
  }
62641
- iter[kHandlePromise](resolve17, reject);
62911
+ iter[kHandlePromise](resolve18, reject);
62642
62912
  }, reject);
62643
62913
  };
62644
62914
  }
@@ -62658,12 +62928,12 @@ var require_async_iterator = __commonJS({
62658
62928
  return Promise.resolve(createIterResult(void 0, true));
62659
62929
  }
62660
62930
  if (this[kStream].destroyed) {
62661
- return new Promise(function(resolve17, reject) {
62931
+ return new Promise(function(resolve18, reject) {
62662
62932
  process.nextTick(function() {
62663
62933
  if (_this[kError]) {
62664
62934
  reject(_this[kError]);
62665
62935
  } else {
62666
- resolve17(createIterResult(void 0, true));
62936
+ resolve18(createIterResult(void 0, true));
62667
62937
  }
62668
62938
  });
62669
62939
  });
@@ -62686,13 +62956,13 @@ var require_async_iterator = __commonJS({
62686
62956
  return this;
62687
62957
  }), _defineProperty(_Object$setPrototypeO, "return", function _return() {
62688
62958
  var _this2 = this;
62689
- return new Promise(function(resolve17, reject) {
62959
+ return new Promise(function(resolve18, reject) {
62690
62960
  _this2[kStream].destroy(null, function(err) {
62691
62961
  if (err) {
62692
62962
  reject(err);
62693
62963
  return;
62694
62964
  }
62695
- resolve17(createIterResult(void 0, true));
62965
+ resolve18(createIterResult(void 0, true));
62696
62966
  });
62697
62967
  });
62698
62968
  }), _Object$setPrototypeO), AsyncIteratorPrototype);
@@ -62714,15 +62984,15 @@ var require_async_iterator = __commonJS({
62714
62984
  value: stream._readableState.endEmitted,
62715
62985
  writable: true
62716
62986
  }), _defineProperty(_Object$create, kHandlePromise, {
62717
- value: function value(resolve17, reject) {
62987
+ value: function value(resolve18, reject) {
62718
62988
  var data = iterator[kStream].read();
62719
62989
  if (data) {
62720
62990
  iterator[kLastPromise] = null;
62721
62991
  iterator[kLastResolve] = null;
62722
62992
  iterator[kLastReject] = null;
62723
- resolve17(createIterResult(data, false));
62993
+ resolve18(createIterResult(data, false));
62724
62994
  } else {
62725
- iterator[kLastResolve] = resolve17;
62995
+ iterator[kLastResolve] = resolve18;
62726
62996
  iterator[kLastReject] = reject;
62727
62997
  }
62728
62998
  },
@@ -62741,12 +63011,12 @@ var require_async_iterator = __commonJS({
62741
63011
  iterator[kError] = err;
62742
63012
  return;
62743
63013
  }
62744
- var resolve17 = iterator[kLastResolve];
62745
- if (resolve17 !== null) {
63014
+ var resolve18 = iterator[kLastResolve];
63015
+ if (resolve18 !== null) {
62746
63016
  iterator[kLastPromise] = null;
62747
63017
  iterator[kLastResolve] = null;
62748
63018
  iterator[kLastReject] = null;
62749
- resolve17(createIterResult(void 0, true));
63019
+ resolve18(createIterResult(void 0, true));
62750
63020
  }
62751
63021
  iterator[kEnded] = true;
62752
63022
  });
@@ -62761,7 +63031,7 @@ var require_async_iterator = __commonJS({
62761
63031
  var require_from2 = __commonJS({
62762
63032
  "../../node_modules/readable-stream/lib/internal/streams/from.js"(exports2, module2) {
62763
63033
  "use strict";
62764
- function asyncGeneratorStep(gen, resolve17, reject, _next, _throw, key, arg) {
63034
+ function asyncGeneratorStep(gen, resolve18, reject, _next, _throw, key, arg) {
62765
63035
  try {
62766
63036
  var info = gen[key](arg);
62767
63037
  var value = info.value;
@@ -62770,7 +63040,7 @@ var require_from2 = __commonJS({
62770
63040
  return;
62771
63041
  }
62772
63042
  if (info.done) {
62773
- resolve17(value);
63043
+ resolve18(value);
62774
63044
  } else {
62775
63045
  Promise.resolve(value).then(_next, _throw);
62776
63046
  }
@@ -62778,13 +63048,13 @@ var require_from2 = __commonJS({
62778
63048
  function _asyncToGenerator(fn) {
62779
63049
  return function() {
62780
63050
  var self2 = this, args = arguments;
62781
- return new Promise(function(resolve17, reject) {
63051
+ return new Promise(function(resolve18, reject) {
62782
63052
  var gen = fn.apply(self2, args);
62783
63053
  function _next(value) {
62784
- asyncGeneratorStep(gen, resolve17, reject, _next, _throw, "next", value);
63054
+ asyncGeneratorStep(gen, resolve18, reject, _next, _throw, "next", value);
62785
63055
  }
62786
63056
  function _throw(err) {
62787
- asyncGeneratorStep(gen, resolve17, reject, _next, _throw, "throw", err);
63057
+ asyncGeneratorStep(gen, resolve18, reject, _next, _throw, "throw", err);
62788
63058
  }
62789
63059
  _next(void 0);
62790
63060
  });
@@ -64723,9 +64993,9 @@ var init_base = __esm({
64723
64993
  * @return {Promise}
64724
64994
  */
64725
64995
  run() {
64726
- return new Promise((resolve17, reject) => {
64996
+ return new Promise((resolve18, reject) => {
64727
64997
  this._run(
64728
- (value) => resolve17(value),
64998
+ (value) => resolve18(value),
64729
64999
  (error48) => reject(error48)
64730
65000
  );
64731
65001
  });
@@ -71357,7 +71627,7 @@ var require_lib = __commonJS({
71357
71627
  return matches;
71358
71628
  };
71359
71629
  exports2.analyse = analyse;
71360
- var detectFile = (filepath, opts = {}) => new Promise((resolve17, reject) => {
71630
+ var detectFile = (filepath, opts = {}) => new Promise((resolve18, reject) => {
71361
71631
  let fd;
71362
71632
  const fs27 = (0, node_1.default)();
71363
71633
  const handler = (err, buffer) => {
@@ -71367,7 +71637,7 @@ var require_lib = __commonJS({
71367
71637
  if (err) {
71368
71638
  reject(err);
71369
71639
  } else if (buffer) {
71370
- resolve17((0, exports2.detect)(buffer));
71640
+ resolve18((0, exports2.detect)(buffer));
71371
71641
  } else {
71372
71642
  reject(new Error("No error and no buffer received"));
71373
71643
  }
@@ -77612,14 +77882,14 @@ var init_open = __esm({
77612
77882
  }
77613
77883
  const subprocess = import_node_child_process5.default.spawn(command, cliArguments, childProcessOptions);
77614
77884
  if (options.wait) {
77615
- return new Promise((resolve17, reject) => {
77885
+ return new Promise((resolve18, reject) => {
77616
77886
  subprocess.once("error", reject);
77617
77887
  subprocess.once("close", (exitCode) => {
77618
77888
  if (!options.allowNonzeroExitCode && exitCode > 0) {
77619
77889
  reject(new Error(`Exited with code ${exitCode}`));
77620
77890
  return;
77621
77891
  }
77622
- resolve17(subprocess);
77892
+ resolve18(subprocess);
77623
77893
  });
77624
77894
  });
77625
77895
  }
@@ -79199,14 +79469,14 @@ var require_filesystem = __commonJS({
79199
79469
  });
79200
79470
  return buffer.subarray(0, bytesRead);
79201
79471
  };
79202
- var readFile = (path35) => new Promise((resolve17, reject) => {
79472
+ var readFile = (path35) => new Promise((resolve18, reject) => {
79203
79473
  fs27.open(path35, "r", (err, fd) => {
79204
79474
  if (err) {
79205
79475
  reject(err);
79206
79476
  } else {
79207
79477
  const buffer = Buffer.alloc(MAX_LENGTH);
79208
79478
  fs27.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
79209
- resolve17(buffer.subarray(0, bytesRead));
79479
+ resolve18(buffer.subarray(0, bytesRead));
79210
79480
  fs27.close(fd, () => {
79211
79481
  });
79212
79482
  });
@@ -79274,10 +79544,10 @@ var require_detect_libc = __commonJS({
79274
79544
  var commandOut = "";
79275
79545
  var safeCommand = () => {
79276
79546
  if (!commandOut) {
79277
- return new Promise((resolve17) => {
79547
+ return new Promise((resolve18) => {
79278
79548
  childProcess2.exec(command, (err, out) => {
79279
79549
  commandOut = err ? " " : out;
79280
- resolve17(commandOut);
79550
+ resolve18(commandOut);
79281
79551
  });
79282
79552
  });
79283
79553
  }
@@ -81957,14 +82227,14 @@ var require_input = __commonJS({
81957
82227
  return this;
81958
82228
  } else {
81959
82229
  if (this._isStreamInput()) {
81960
- return new Promise((resolve17, reject) => {
82230
+ return new Promise((resolve18, reject) => {
81961
82231
  const finished = () => {
81962
82232
  this._flattenBufferIn();
81963
82233
  sharp.metadata(this.options, (err, metadata2) => {
81964
82234
  if (err) {
81965
82235
  reject(is.nativeError(err, stack));
81966
82236
  } else {
81967
- resolve17(metadata2);
82237
+ resolve18(metadata2);
81968
82238
  }
81969
82239
  });
81970
82240
  };
@@ -81975,12 +82245,12 @@ var require_input = __commonJS({
81975
82245
  }
81976
82246
  });
81977
82247
  } else {
81978
- return new Promise((resolve17, reject) => {
82248
+ return new Promise((resolve18, reject) => {
81979
82249
  sharp.metadata(this.options, (err, metadata2) => {
81980
82250
  if (err) {
81981
82251
  reject(is.nativeError(err, stack));
81982
82252
  } else {
81983
- resolve17(metadata2);
82253
+ resolve18(metadata2);
81984
82254
  }
81985
82255
  });
81986
82256
  });
@@ -82013,25 +82283,25 @@ var require_input = __commonJS({
82013
82283
  return this;
82014
82284
  } else {
82015
82285
  if (this._isStreamInput()) {
82016
- return new Promise((resolve17, reject) => {
82286
+ return new Promise((resolve18, reject) => {
82017
82287
  this.on("finish", function() {
82018
82288
  this._flattenBufferIn();
82019
82289
  sharp.stats(this.options, (err, stats2) => {
82020
82290
  if (err) {
82021
82291
  reject(is.nativeError(err, stack));
82022
82292
  } else {
82023
- resolve17(stats2);
82293
+ resolve18(stats2);
82024
82294
  }
82025
82295
  });
82026
82296
  });
82027
82297
  });
82028
82298
  } else {
82029
- return new Promise((resolve17, reject) => {
82299
+ return new Promise((resolve18, reject) => {
82030
82300
  sharp.stats(this.options, (err, stats2) => {
82031
82301
  if (err) {
82032
82302
  reject(is.nativeError(err, stack));
82033
82303
  } else {
82034
- resolve17(stats2);
82304
+ resolve18(stats2);
82035
82305
  }
82036
82306
  });
82037
82307
  });
@@ -85453,7 +85723,7 @@ var require_output = __commonJS({
85453
85723
  return this;
85454
85724
  } else {
85455
85725
  if (this._isStreamInput()) {
85456
- return new Promise((resolve17, reject) => {
85726
+ return new Promise((resolve18, reject) => {
85457
85727
  this.once("finish", () => {
85458
85728
  this._flattenBufferIn();
85459
85729
  sharp.pipeline(this.options, (err, data, info) => {
@@ -85461,24 +85731,24 @@ var require_output = __commonJS({
85461
85731
  reject(is.nativeError(err, stack));
85462
85732
  } else {
85463
85733
  if (this.options.resolveWithObject) {
85464
- resolve17({ data, info });
85734
+ resolve18({ data, info });
85465
85735
  } else {
85466
- resolve17(data);
85736
+ resolve18(data);
85467
85737
  }
85468
85738
  }
85469
85739
  });
85470
85740
  });
85471
85741
  });
85472
85742
  } else {
85473
- return new Promise((resolve17, reject) => {
85743
+ return new Promise((resolve18, reject) => {
85474
85744
  sharp.pipeline(this.options, (err, data, info) => {
85475
85745
  if (err) {
85476
85746
  reject(is.nativeError(err, stack));
85477
85747
  } else {
85478
85748
  if (this.options.resolveWithObject) {
85479
- resolve17({ data, info });
85749
+ resolve18({ data, info });
85480
85750
  } else {
85481
- resolve17(data);
85751
+ resolve18(data);
85482
85752
  }
85483
85753
  }
85484
85754
  });
@@ -86532,7 +86802,7 @@ var init_adhdev_daemon = __esm({
86532
86802
  init_version();
86533
86803
  init_src();
86534
86804
  init_runtime_defaults();
86535
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.93" });
86805
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.95" });
86536
86806
  AdhdevDaemon = class _AdhdevDaemon {
86537
86807
  localHttpServer = null;
86538
86808
  localWss = null;
@@ -87376,7 +87646,7 @@ ${err?.stack || ""}`);
87376
87646
  this.localWss.emit("connection", ws, req);
87377
87647
  });
87378
87648
  });
87379
- await new Promise((resolve17, reject) => {
87649
+ await new Promise((resolve18, reject) => {
87380
87650
  const cleanup = () => {
87381
87651
  this.localHttpServer?.off("error", onError);
87382
87652
  this.localHttpServer?.off("listening", onListening);
@@ -87387,7 +87657,7 @@ ${err?.stack || ""}`);
87387
87657
  };
87388
87658
  const onListening = () => {
87389
87659
  cleanup();
87390
- resolve17();
87660
+ resolve18();
87391
87661
  };
87392
87662
  this.localHttpServer.once("error", onError);
87393
87663
  this.localHttpServer.once("listening", onListening);
@@ -87547,12 +87817,12 @@ ${err?.stack || ""}`);
87547
87817
  this.localClients.clear();
87548
87818
  this.localWss?.close();
87549
87819
  this.localWss = null;
87550
- await new Promise((resolve17) => {
87820
+ await new Promise((resolve18) => {
87551
87821
  if (!this.localHttpServer) {
87552
- resolve17();
87822
+ resolve18();
87553
87823
  return;
87554
87824
  }
87555
- this.localHttpServer.close(() => resolve17());
87825
+ this.localHttpServer.close(() => resolve18());
87556
87826
  this.localHttpServer = null;
87557
87827
  });
87558
87828
  } catch {
@@ -89003,11 +89273,25 @@ init_source();
89003
89273
  init_src();
89004
89274
 
89005
89275
  // src/cli/provider-source-status.ts
89276
+ function describeUserDirSource(source) {
89277
+ switch (source) {
89278
+ case "sibling-env":
89279
+ return " (auto-adopted sibling checkout via ADHDEV_USE_SIBLING_PROVIDERS=1)";
89280
+ case "sibling-marker":
89281
+ return " (auto-adopted sibling checkout via .adhdev-provider-root marker)";
89282
+ case "explicit":
89283
+ return " (from config.providerDir)";
89284
+ case "home-default":
89285
+ case void 0:
89286
+ return "";
89287
+ }
89288
+ }
89006
89289
  function buildProviderSourceStatusLines(config2) {
89290
+ const sourceSuffix = describeUserDirSource(config2.userDirSource);
89007
89291
  return [
89008
89292
  `Provider source mode: ${config2.disableUpstream ? `${config2.sourceMode} (upstream fetch/load disabled)` : config2.sourceMode}`,
89009
- `Explicit providerDir: ${config2.explicitProviderDir || "default (~/.adhdev/providers)"}`,
89010
- `Effective user root: ${config2.userDir}`,
89293
+ `Explicit providerDir: ${config2.explicitProviderDir || `default (${config2.userDir})`}`,
89294
+ `Effective user root: ${config2.userDir}${sourceSuffix}`,
89011
89295
  `Upstream root: ${config2.upstreamDir}`,
89012
89296
  `Provider roots: ${config2.providerRoots.join(" -> ")}`
89013
89297
  ];
@@ -89867,6 +90151,20 @@ function buildRuntimeOpenLaunchSpec(options) {
89867
90151
  return spec;
89868
90152
  }
89869
90153
 
90154
+ // src/cli/provider-loader-factory.ts
90155
+ async function createConfiguredProviderLoader(options = {}) {
90156
+ const { ProviderLoader: ProviderLoader2, loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_src(), src_exports));
90157
+ const config2 = loadConfig2();
90158
+ const loader = new ProviderLoader2({
90159
+ logFn: options.silent === false ? void 0 : () => {
90160
+ },
90161
+ userDir: config2.providerDir,
90162
+ sourceMode: config2.providerSourceMode
90163
+ });
90164
+ if (options.load) loader.loadAll();
90165
+ return loader;
90166
+ }
90167
+
89870
90168
  // src/cli/debug-trace-cli.ts
89871
90169
  function normalizeOptionalFilter(value) {
89872
90170
  if (typeof value !== "string") return void 0;
@@ -89980,14 +90278,14 @@ async function requestSessionHostDirect(request) {
89980
90278
  }
89981
90279
  async function runRuntimeLaunchSpec(spec) {
89982
90280
  const { spawn: spawn6 } = await import("child_process");
89983
- return await new Promise((resolve17, reject) => {
90281
+ return await new Promise((resolve18, reject) => {
89984
90282
  const child = spawn6(spec.command, spec.args, {
89985
90283
  stdio: "inherit",
89986
90284
  env: spec.env,
89987
90285
  shell: process.platform === "win32" && spec.command !== process.execPath
89988
90286
  });
89989
90287
  child.on("error", reject);
89990
- child.on("exit", (code) => resolve17(code ?? 0));
90288
+ child.on("exit", (code) => resolve18(code ?? 0));
89991
90289
  });
89992
90290
  }
89993
90291
  async function resolveRuntimeSessionId(target, options) {
@@ -90221,7 +90519,7 @@ async function handleTraceCommand(options) {
90221
90519
  }
90222
90520
  }
90223
90521
  while (!stopped) {
90224
- await new Promise((resolve17) => setTimeout(resolve17, intervalMs));
90522
+ await new Promise((resolve18) => setTimeout(resolve18, intervalMs));
90225
90523
  if (stopped) break;
90226
90524
  const nextTrace = await fetchTrace(buildDebugTraceFollowPollArgs(baseArgs, cursor));
90227
90525
  const nextBatch = collectFreshDebugTraceEntries(nextTrace, cursor);
@@ -90344,17 +90642,11 @@ function registerDaemonCommands(program2, pkgVersion3) {
90344
90642
  }));
90345
90643
  hideCommand(program2.command("daemon:status").description("Check ADHDev Daemon status").option("-p, --port <port>", "Local WS server port", DEFAULT_DAEMON_PORT_TEXT).action(async (options) => {
90346
90644
  const { isDaemonRunning: isDaemonRunning2, getDaemonPid: getDaemonPid2 } = await Promise.resolve().then(() => (init_adhdev_daemon(), adhdev_daemon_exports));
90347
- const { getCurrentDaemonLogPath: getCurrentDaemonLogPath2 } = await Promise.resolve().then(() => (init_src(), src_exports));
90645
+ const { getCurrentDaemonLogPath: getCurrentDaemonLogPath2, loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_src(), src_exports));
90348
90646
  const { probeSessionHostStatus: probeSessionHostStatus2 } = await Promise.resolve().then(() => (init_session_host(), session_host_exports));
90349
90647
  const port = parseInt(options.port, 10) || DEFAULT_DAEMON_PORT;
90350
- const { loadConfig: loadConfig2, ProviderLoader: ProviderLoader2 } = await Promise.resolve().then(() => (init_src(), src_exports));
90351
90648
  const config2 = loadConfig2();
90352
- const providerLoader = new ProviderLoader2({
90353
- logFn: () => {
90354
- },
90355
- userDir: config2.providerDir,
90356
- sourceMode: config2.providerSourceMode
90357
- });
90649
+ const providerLoader = await createConfiguredProviderLoader();
90358
90650
  if (isDaemonRunning2({ port })) {
90359
90651
  console.log(source_default.green(`
90360
90652
  \u2713 ADHDev Daemon is running.
@@ -91370,7 +91662,7 @@ function registerDoctorCommands(program2, pkgVersion3) {
91370
91662
  } catch {
91371
91663
  }
91372
91664
  try {
91373
- const providerLoader = new ProviderLoader();
91665
+ const providerLoader = await createConfiguredProviderLoader({ load: true });
91374
91666
  const cliResults = await detectCLIs(providerLoader);
91375
91667
  for (const cli of cliResults) {
91376
91668
  checks.push({
@@ -91590,15 +91882,8 @@ function hideCommand2(command) {
91590
91882
  command.hideHelp?.();
91591
91883
  return command;
91592
91884
  }
91593
- async function createConfiguredProviderLoader() {
91594
- const { ProviderLoader: ProviderLoader2, loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_src(), src_exports));
91595
- const config2 = loadConfig2();
91596
- const loader = new ProviderLoader2({
91597
- userDir: config2.providerDir,
91598
- sourceMode: config2.providerSourceMode
91599
- });
91600
- loader.loadAll();
91601
- return loader;
91885
+ async function createConfiguredProviderLoader2() {
91886
+ return createConfiguredProviderLoader({ silent: false, load: true });
91602
91887
  }
91603
91888
  function getProviderSourceCandidatePaths(options) {
91604
91889
  const relativeNames = ["provider.json", "scripts.js", "provider.js"];
@@ -91615,7 +91900,7 @@ function registerProviderCommands(program2) {
91615
91900
  const provider = hideCommand2(program2.command("provider").description("\u{1F50C} Provider management \u2014 list, test, reload providers"));
91616
91901
  provider.command("list").description("List all loaded providers").option("-j, --json", "Output raw JSON").action(async (options) => {
91617
91902
  try {
91618
- const loader = await createConfiguredProviderLoader();
91903
+ const loader = await createConfiguredProviderLoader2();
91619
91904
  const providers = loader.getAll();
91620
91905
  if (options.json) {
91621
91906
  console.log(JSON.stringify(providers.map((p) => ({
@@ -91667,7 +91952,7 @@ function registerProviderCommands(program2) {
91667
91952
  } catch {
91668
91953
  try {
91669
91954
  const http3 = await import("http");
91670
- const result = await new Promise((resolve17, reject) => {
91955
+ const result = await new Promise((resolve18, reject) => {
91671
91956
  const req = http3.request({
91672
91957
  hostname: "127.0.0.1",
91673
91958
  port: DEV_SERVER_PORT3,
@@ -91679,9 +91964,9 @@ function registerProviderCommands(program2) {
91679
91964
  res.on("data", (c) => data += c);
91680
91965
  res.on("end", () => {
91681
91966
  try {
91682
- resolve17(JSON.parse(data));
91967
+ resolve18(JSON.parse(data));
91683
91968
  } catch {
91684
- resolve17({ raw: data });
91969
+ resolve18({ raw: data });
91685
91970
  }
91686
91971
  });
91687
91972
  });
@@ -91783,12 +92068,12 @@ function registerProviderCommands(program2) {
91783
92068
  console.log(source_default.yellow("Invalid port number."));
91784
92069
  continue;
91785
92070
  }
91786
- const isFree = await new Promise((resolve17) => {
92071
+ const isFree = await new Promise((resolve18) => {
91787
92072
  const server = net3.createServer();
91788
92073
  server.unref();
91789
- server.on("error", () => resolve17(false));
92074
+ server.on("error", () => resolve18(false));
91790
92075
  server.listen(port, "127.0.0.1", () => {
91791
- server.close(() => resolve17(true));
92076
+ server.close(() => resolve18(true));
91792
92077
  });
91793
92078
  });
91794
92079
  if (!isFree) {
@@ -91803,7 +92088,7 @@ function registerProviderCommands(program2) {
91803
92088
  rl.close();
91804
92089
  const location = options.builtin ? "builtin" : "user";
91805
92090
  const http3 = await import("http");
91806
- const result = await new Promise((resolve17, reject) => {
92091
+ const result = await new Promise((resolve18, reject) => {
91807
92092
  const postData = JSON.stringify({ type, name, category, location, cdpPorts, osPaths, processNames });
91808
92093
  const req = http3.request({
91809
92094
  hostname: "127.0.0.1",
@@ -91816,9 +92101,9 @@ function registerProviderCommands(program2) {
91816
92101
  res.on("data", (c) => data += c);
91817
92102
  res.on("end", () => {
91818
92103
  try {
91819
- resolve17(JSON.parse(data));
92104
+ resolve18(JSON.parse(data));
91820
92105
  } catch {
91821
- resolve17({ raw: data });
92106
+ resolve18({ raw: data });
91822
92107
  }
91823
92108
  });
91824
92109
  });
@@ -91828,7 +92113,7 @@ function registerProviderCommands(program2) {
91828
92113
  }).catch(async () => {
91829
92114
  const pathMod = await import("path");
91830
92115
  const fsMod = await import("fs");
91831
- const loader = await createConfiguredProviderLoader();
92116
+ const loader = await createConfiguredProviderLoader2();
91832
92117
  let targetDir = location === "builtin" ? loader.getUpstreamProviderDir(category, type) : loader.getUserProviderDir(category, type);
91833
92118
  if (fsMod.existsSync(targetDir)) return { error: `Provider already exists at ${targetDir}` };
91834
92119
  const isExt = category === "extension";
@@ -91881,7 +92166,7 @@ function registerProviderCommands(program2) {
91881
92166
  try {
91882
92167
  const http3 = await import("http");
91883
92168
  const inquirer2 = (await Promise.resolve().then(() => (init_lib(), lib_exports))).default;
91884
- const loader = await createConfiguredProviderLoader();
92169
+ const loader = await createConfiguredProviderLoader2();
91885
92170
  const allProviders = loader.getAll();
91886
92171
  const fsMod = await import("fs");
91887
92172
  const isUserProvider = (p) => {
@@ -92012,7 +92297,7 @@ function registerProviderCommands(program2) {
92012
92297
  reference,
92013
92298
  ...verification ? { verification } : {}
92014
92299
  });
92015
- const startResult = await new Promise((resolve17, reject) => {
92300
+ const startResult = await new Promise((resolve18, reject) => {
92016
92301
  const req = http3.request({
92017
92302
  hostname: "127.0.0.1",
92018
92303
  port: DEV_SERVER_PORT3,
@@ -92024,9 +92309,9 @@ function registerProviderCommands(program2) {
92024
92309
  res.on("data", (c) => data += c);
92025
92310
  res.on("end", () => {
92026
92311
  try {
92027
- resolve17(JSON.parse(data));
92312
+ resolve18(JSON.parse(data));
92028
92313
  } catch {
92029
- resolve17({ raw: data });
92314
+ resolve18({ raw: data });
92030
92315
  }
92031
92316
  });
92032
92317
  });
@@ -92060,7 +92345,7 @@ function registerProviderCommands(program2) {
92060
92345
  fsMock.writeFileSync(logFile, `=== Auto-Impl Started ===
92061
92346
  `);
92062
92347
  console.log(source_default.gray(` Agent logs: ${logFile}`));
92063
- await new Promise((resolve17, reject) => {
92348
+ await new Promise((resolve18, reject) => {
92064
92349
  http3.get(`http://127.0.0.1:${DEV_SERVER_PORT3}${startResult.sseUrl}`, (res) => {
92065
92350
  let buffer = "";
92066
92351
  res.on("data", (chunk) => {
@@ -92097,7 +92382,7 @@ function registerProviderCommands(program2) {
92097
92382
  if (currentData.success === false) {
92098
92383
  reject(new Error(`Agent failed to implement scripts properly (exit: ${currentData.exitCode})`));
92099
92384
  } else {
92100
- resolve17();
92385
+ resolve18();
92101
92386
  }
92102
92387
  } else if (currentEvent === "error") {
92103
92388
  fsMock.appendFileSync(logFile, `
@@ -92108,7 +92393,7 @@ function registerProviderCommands(program2) {
92108
92393
  }
92109
92394
  }
92110
92395
  });
92111
- res.on("end", resolve17);
92396
+ res.on("end", resolve18);
92112
92397
  }).on("error", reject);
92113
92398
  });
92114
92399
  console.log(source_default.green(`
@@ -92167,7 +92452,7 @@ function registerProviderCommands(program2) {
92167
92452
  ideType: type,
92168
92453
  params: options.param ? { text: options.param, sessionId: options.param, buttonText: options.param } : {}
92169
92454
  });
92170
- const result = await new Promise((resolve17, reject) => {
92455
+ const result = await new Promise((resolve18, reject) => {
92171
92456
  const req = http3.request({
92172
92457
  hostname: "127.0.0.1",
92173
92458
  port: DEV_SERVER_PORT3,
@@ -92179,9 +92464,9 @@ function registerProviderCommands(program2) {
92179
92464
  res.on("data", (c) => data += c);
92180
92465
  res.on("end", () => {
92181
92466
  try {
92182
- resolve17(JSON.parse(data));
92467
+ resolve18(JSON.parse(data));
92183
92468
  } catch {
92184
- resolve17({ raw: data });
92469
+ resolve18({ raw: data });
92185
92470
  }
92186
92471
  });
92187
92472
  });
@@ -92217,15 +92502,15 @@ function registerProviderCommands(program2) {
92217
92502
  provider.command("source <type>").description("View source code of a provider").action(async (type) => {
92218
92503
  try {
92219
92504
  const http3 = await import("http");
92220
- const result = await new Promise((resolve17, reject) => {
92505
+ const result = await new Promise((resolve18, reject) => {
92221
92506
  http3.get(`http://127.0.0.1:${DEV_SERVER_PORT3}/api/providers/${type}/source`, (res) => {
92222
92507
  let data = "";
92223
92508
  res.on("data", (c) => data += c);
92224
92509
  res.on("end", () => {
92225
92510
  try {
92226
- resolve17(JSON.parse(data));
92511
+ resolve18(JSON.parse(data));
92227
92512
  } catch {
92228
- resolve17({ raw: data });
92513
+ resolve18({ raw: data });
92229
92514
  }
92230
92515
  });
92231
92516
  }).on("error", () => {
@@ -92234,7 +92519,7 @@ function registerProviderCommands(program2) {
92234
92519
  }).catch(async () => {
92235
92520
  const pathMod = await import("path");
92236
92521
  const fsMod = await import("fs");
92237
- const loader = await createConfiguredProviderLoader();
92522
+ const loader = await createConfiguredProviderLoader2();
92238
92523
  const providerMeta = loader.getMeta(type);
92239
92524
  if (!providerMeta) {
92240
92525
  return { error: `Provider '${type}' not found` };
@@ -92273,7 +92558,7 @@ function registerProviderCommands(program2) {
92273
92558
  try {
92274
92559
  const http3 = await import("http");
92275
92560
  const postData = JSON.stringify({ script: "readChat", params: {} });
92276
- const result = await new Promise((resolve17, reject) => {
92561
+ const result = await new Promise((resolve18, reject) => {
92277
92562
  const req = http3.request({
92278
92563
  hostname: "127.0.0.1",
92279
92564
  port: DEV_SERVER_PORT3,
@@ -92285,9 +92570,9 @@ function registerProviderCommands(program2) {
92285
92570
  res2.on("data", (c) => data += c);
92286
92571
  res2.on("end", () => {
92287
92572
  try {
92288
- resolve17(JSON.parse(data));
92573
+ resolve18(JSON.parse(data));
92289
92574
  } catch {
92290
- resolve17({ raw: data });
92575
+ resolve18({ raw: data });
92291
92576
  }
92292
92577
  });
92293
92578
  });
@@ -92528,13 +92813,13 @@ function registerCdpCommands(program2) {
92528
92813
  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) => {
92529
92814
  try {
92530
92815
  const http3 = await import("http");
92531
- const targets = await new Promise((resolve17, reject) => {
92816
+ const targets = await new Promise((resolve18, reject) => {
92532
92817
  http3.get(`http://127.0.0.1:${options.port}/json`, (res) => {
92533
92818
  let data = "";
92534
92819
  res.on("data", (c) => data += c);
92535
92820
  res.on("end", () => {
92536
92821
  try {
92537
- resolve17(JSON.parse(data));
92822
+ resolve18(JSON.parse(data));
92538
92823
  } catch {
92539
92824
  reject(new Error("Invalid JSON"));
92540
92825
  }
@@ -92548,7 +92833,7 @@ function registerCdpCommands(program2) {
92548
92833
  if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target");
92549
92834
  const WebSocket4 = (await import("ws")).default;
92550
92835
  const ws = new WebSocket4(target.webSocketDebuggerUrl);
92551
- await new Promise((resolve17, reject) => {
92836
+ await new Promise((resolve18, reject) => {
92552
92837
  ws.on("open", () => {
92553
92838
  ws.send(JSON.stringify({ id: 1, method: "Page.captureScreenshot", params: { format: "jpeg", quality: 50 } }));
92554
92839
  });
@@ -92561,7 +92846,7 @@ function registerCdpCommands(program2) {
92561
92846
  \u2713 Screenshot saved to ${options.output}
92562
92847
  `));
92563
92848
  ws.close();
92564
- resolve17();
92849
+ resolve18();
92565
92850
  }
92566
92851
  });
92567
92852
  ws.on("error", (e) => reject(e));