adhdev 0.8.92 → 0.8.94

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)) {
@@ -7475,7 +7475,9 @@ function getTargetInstance(h, args) {
7475
7475
  const targetSessionId = typeof args?.targetSessionId === "string" ? args.targetSessionId.trim() : "";
7476
7476
  const sessionId = targetSessionId || h.currentSession?.sessionId || "";
7477
7477
  if (!sessionId) return null;
7478
- return h.ctx.instanceManager?.getInstance(sessionId) || null;
7478
+ const session = h.ctx.sessionRegistry?.get(sessionId);
7479
+ const instanceKey = session?.adapterKey || session?.instanceKey || sessionId;
7480
+ return h.ctx.instanceManager?.getInstance(instanceKey) || null;
7479
7481
  }
7480
7482
  function getTargetTransport(h, provider) {
7481
7483
  if (h.currentSession?.transport) return h.currentSession.transport;
@@ -7772,7 +7774,7 @@ function getStateLastSignature(state) {
7772
7774
  async function getStableExtensionBaseline(h) {
7773
7775
  const first = await readExtensionChatState(h);
7774
7776
  if (getStateMessageCount(first) > 0 || getStateLastSignature(first)) return first;
7775
- await new Promise((resolve17) => setTimeout(resolve17, 150));
7777
+ await new Promise((resolve18) => setTimeout(resolve18, 150));
7776
7778
  const second = await readExtensionChatState(h);
7777
7779
  return getStateMessageCount(second) >= getStateMessageCount(first) ? second : first;
7778
7780
  }
@@ -7780,7 +7782,7 @@ async function verifyExtensionSendObserved(h, before) {
7780
7782
  const beforeCount = getStateMessageCount(before);
7781
7783
  const beforeSignature = getStateLastSignature(before);
7782
7784
  for (let attempt = 0; attempt < 12; attempt += 1) {
7783
- await new Promise((resolve17) => setTimeout(resolve17, 250));
7785
+ await new Promise((resolve18) => setTimeout(resolve18, 250));
7784
7786
  const state = await readExtensionChatState(h);
7785
7787
  if (state?.status === "waiting_approval") return true;
7786
7788
  const afterCount = getStateMessageCount(state);
@@ -8544,10 +8546,17 @@ async function handleResolveAction(h, args) {
8544
8546
  }
8545
8547
  }
8546
8548
  const status = adapter.getStatus();
8547
- if (status?.status !== "waiting_approval") {
8549
+ const targetInstance = getTargetInstance(h, args);
8550
+ const targetState = targetInstance?.getState?.();
8551
+ 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;
8552
+ const statusModal = status?.activeModal && Array.isArray(status.activeModal.buttons) && status.activeModal.buttons.some((candidate) => typeof candidate === "string" && candidate.trim()) ? status.activeModal : null;
8553
+ const effectiveModal = statusModal || surfacedModal;
8554
+ const effectiveStatus = status?.status === "waiting_approval" || targetState?.activeChat?.status === "waiting_approval" ? "waiting_approval" : status?.status;
8555
+ 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"}`);
8556
+ if (effectiveStatus !== "waiting_approval" && !effectiveModal) {
8548
8557
  return { success: false, error: "Not in approval state" };
8549
8558
  }
8550
- const buttons = status.activeModal?.buttons || ["Allow once", "Always allow", "Deny"];
8559
+ const buttons = effectiveModal?.buttons || ["Allow once", "Always allow", "Deny"];
8551
8560
  let buttonIndex = typeof args?.buttonIndex === "number" ? args.buttonIndex : -1;
8552
8561
  if (buttonIndex < 0) {
8553
8562
  const btnLower = button.toLowerCase();
@@ -10058,7 +10067,7 @@ var init_handler = __esm({
10058
10067
  try {
10059
10068
  const http3 = await import("http");
10060
10069
  const postData = JSON.stringify(body);
10061
- const result = await new Promise((resolve17, reject) => {
10070
+ const result = await new Promise((resolve18, reject) => {
10062
10071
  const req = http3.request({
10063
10072
  hostname: "127.0.0.1",
10064
10073
  port: 19280,
@@ -10070,9 +10079,9 @@ var init_handler = __esm({
10070
10079
  res.on("data", (chunk) => data += chunk);
10071
10080
  res.on("end", () => {
10072
10081
  try {
10073
- resolve17(JSON.parse(data));
10082
+ resolve18(JSON.parse(data));
10074
10083
  } catch {
10075
- resolve17({ raw: data });
10084
+ resolve18({ raw: data });
10076
10085
  }
10077
10086
  });
10078
10087
  });
@@ -10090,15 +10099,15 @@ var init_handler = __esm({
10090
10099
  if (!providerType) return { success: false, error: "providerType required" };
10091
10100
  try {
10092
10101
  const http3 = await import("http");
10093
- const result = await new Promise((resolve17, reject) => {
10102
+ const result = await new Promise((resolve18, reject) => {
10094
10103
  http3.get(`http://127.0.0.1:19280/api/providers/${providerType}/${endpoint}`, (res) => {
10095
10104
  let data = "";
10096
10105
  res.on("data", (chunk) => data += chunk);
10097
10106
  res.on("end", () => {
10098
10107
  try {
10099
- resolve17(JSON.parse(data));
10108
+ resolve18(JSON.parse(data));
10100
10109
  } catch {
10101
- resolve17({ raw: data });
10110
+ resolve18({ raw: data });
10102
10111
  }
10103
10112
  });
10104
10113
  }).on("error", reject);
@@ -10112,7 +10121,7 @@ var init_handler = __esm({
10112
10121
  try {
10113
10122
  const http3 = await import("http");
10114
10123
  const postData = JSON.stringify(args || {});
10115
- const result = await new Promise((resolve17, reject) => {
10124
+ const result = await new Promise((resolve18, reject) => {
10116
10125
  const req = http3.request({
10117
10126
  hostname: "127.0.0.1",
10118
10127
  port: 19280,
@@ -10124,9 +10133,9 @@ var init_handler = __esm({
10124
10133
  res.on("data", (chunk) => data += chunk);
10125
10134
  res.on("end", () => {
10126
10135
  try {
10127
- resolve17(JSON.parse(data));
10136
+ resolve18(JSON.parse(data));
10128
10137
  } catch {
10129
- resolve17({ raw: data });
10138
+ resolve18({ raw: data });
10130
10139
  }
10131
10140
  });
10132
10141
  });
@@ -12784,7 +12793,7 @@ var init_provider_cli_adapter = __esm({
12784
12793
  `[${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
12794
  );
12786
12795
  }
12787
- await new Promise((resolve17) => setTimeout(resolve17, 50));
12796
+ await new Promise((resolve18) => setTimeout(resolve18, 50));
12788
12797
  }
12789
12798
  const finalScreenText = this.terminalScreen.getText() || "";
12790
12799
  LOG.warn(
@@ -13372,7 +13381,7 @@ var init_provider_cli_adapter = __esm({
13372
13381
  }
13373
13382
  projectEffectiveStatus(startupModal = null) {
13374
13383
  if (this.parseErrorMessage) return "error";
13375
- if (startupModal) return "waiting_approval";
13384
+ if (startupModal || this.activeModal) return "waiting_approval";
13376
13385
  if (this.isWaitingForResponse && this.currentTurnScope && this.currentStatus === "idle") return "generating";
13377
13386
  return this.currentStatus;
13378
13387
  }
@@ -13380,12 +13389,24 @@ var init_provider_cli_adapter = __esm({
13380
13389
  getStatus() {
13381
13390
  const screenText = this.terminalScreen.getText() || "";
13382
13391
  const startupModal = this.startupParseGate ? this.getStartupConfirmationModal(screenText) : null;
13383
- const effectiveStatus = this.projectEffectiveStatus(startupModal);
13392
+ let effectiveStatus = this.projectEffectiveStatus(startupModal);
13393
+ let effectiveModal = startupModal || this.activeModal;
13394
+ if (!startupModal && !effectiveModal && typeof this.cliScripts?.parseOutput === "function") {
13395
+ try {
13396
+ const parsed = this.getScriptParsedStatus();
13397
+ const parsedModal = parsed?.activeModal && Array.isArray(parsed.activeModal.buttons) && parsed.activeModal.buttons.some((button) => typeof button === "string" && button.trim()) ? parsed.activeModal : null;
13398
+ if (parsed?.status === "waiting_approval" && parsedModal) {
13399
+ effectiveStatus = "waiting_approval";
13400
+ effectiveModal = parsedModal;
13401
+ }
13402
+ } catch {
13403
+ }
13404
+ }
13384
13405
  return {
13385
13406
  status: effectiveStatus,
13386
13407
  messages: [...this.committedMessages],
13387
13408
  workingDir: this.workingDir,
13388
- activeModal: startupModal || this.activeModal,
13409
+ activeModal: effectiveModal,
13389
13410
  errorMessage: this.parseErrorMessage || void 0,
13390
13411
  errorReason: this.parseErrorMessage ? "parse_error" : void 0
13391
13412
  };
@@ -13421,6 +13442,15 @@ var init_provider_cli_adapter = __esm({
13421
13442
  this.currentTurnScope,
13422
13443
  screenText
13423
13444
  );
13445
+ const parsedModal = parsed?.activeModal && Array.isArray(parsed.activeModal.buttons) && parsed.activeModal.buttons.some((button) => typeof button === "string" && button.trim()) ? parsed.activeModal : null;
13446
+ if (parsedModal && parsed?.status === "waiting_approval") {
13447
+ this.activeModal = parsedModal;
13448
+ this.isWaitingForResponse = true;
13449
+ if (this.currentStatus !== "waiting_approval") {
13450
+ this.setStatus("waiting_approval", "parsed_waiting_approval");
13451
+ this.onStatusChange?.();
13452
+ }
13453
+ }
13424
13454
  if (this.maybeCommitVisibleIdleTranscript(parsed)) {
13425
13455
  return this.getScriptParsedStatus();
13426
13456
  }
@@ -13625,7 +13655,7 @@ ${data.message || ""}`.trim();
13625
13655
  const deadline = Date.now() + 1e4;
13626
13656
  while (this.startupParseGate && Date.now() < deadline) {
13627
13657
  this.resolveStartupState("send_wait");
13628
- await new Promise((resolve17) => setTimeout(resolve17, 50));
13658
+ await new Promise((resolve18) => setTimeout(resolve18, 50));
13629
13659
  }
13630
13660
  }
13631
13661
  if (!allowInterventionPrompt) {
@@ -13717,12 +13747,12 @@ ${data.message || ""}`.trim();
13717
13747
  if (this.isWaitingForResponse) this.finishResponse();
13718
13748
  }, this.timeouts.maxResponse);
13719
13749
  };
13720
- await new Promise((resolve17) => {
13750
+ await new Promise((resolve18) => {
13721
13751
  let resolved = false;
13722
13752
  const resolveOnce = () => {
13723
13753
  if (resolved) return;
13724
13754
  resolved = true;
13725
- resolve17();
13755
+ resolve18();
13726
13756
  };
13727
13757
  const submit = () => {
13728
13758
  if (!this.ptyProcess) {
@@ -13896,17 +13926,17 @@ ${data.message || ""}`.trim();
13896
13926
  }
13897
13927
  }
13898
13928
  waitForStopped(timeoutMs) {
13899
- return new Promise((resolve17) => {
13929
+ return new Promise((resolve18) => {
13900
13930
  const startedAt = Date.now();
13901
13931
  const timer = setInterval(() => {
13902
13932
  if (!this.ptyProcess || this.currentStatus === "stopped") {
13903
13933
  clearInterval(timer);
13904
- resolve17(true);
13934
+ resolve18(true);
13905
13935
  return;
13906
13936
  }
13907
13937
  if (Date.now() - startedAt >= timeoutMs) {
13908
13938
  clearInterval(timer);
13909
- resolve17(false);
13939
+ resolve18(false);
13910
13940
  }
13911
13941
  }, 100);
13912
13942
  });
@@ -14071,7 +14101,22 @@ ${data.message || ""}`.trim();
14071
14101
  }
14072
14102
  resolveModal(buttonIndex) {
14073
14103
  const screenText = this.terminalScreen.getText() || "";
14074
- const modal = this.activeModal || this.getStartupConfirmationModal(screenText);
14104
+ let modal = this.activeModal || this.getStartupConfirmationModal(screenText);
14105
+ if (!modal && typeof this.cliScripts?.parseOutput === "function") {
14106
+ try {
14107
+ const parsed = this.getScriptParsedStatus();
14108
+ const parsedModal = parsed?.activeModal && Array.isArray(parsed.activeModal.buttons) && parsed.activeModal.buttons.some((button) => typeof button === "string" && button.trim()) ? parsed.activeModal : null;
14109
+ if (parsed?.status === "waiting_approval" && parsedModal) {
14110
+ modal = parsedModal;
14111
+ this.activeModal = parsedModal;
14112
+ if (this.currentStatus !== "waiting_approval") {
14113
+ this.setStatus("waiting_approval", "resolve_modal_parse");
14114
+ this.onStatusChange?.();
14115
+ }
14116
+ }
14117
+ } catch {
14118
+ }
14119
+ }
14075
14120
  if (!this.ptyProcess || this.currentStatus !== "waiting_approval" && !modal) return;
14076
14121
  this.clearIdleFinishCandidate("resolve_modal");
14077
14122
  this.recordTrace("resolve_modal", {
@@ -14250,7 +14295,7 @@ async function waitForCliAdapterReady(adapter, options) {
14250
14295
  if (status === "stopped") {
14251
14296
  throw new Error("CLI runtime stopped before it became ready");
14252
14297
  }
14253
- await new Promise((resolve17) => setTimeout(resolve17, pollMs));
14298
+ await new Promise((resolve18) => setTimeout(resolve18, pollMs));
14254
14299
  }
14255
14300
  throw new Error(`CLI runtime did not become ready within ${timeoutMs}ms`);
14256
14301
  }
@@ -31064,8 +31109,8 @@ var init_acp = __esm({
31064
31109
  this.#requestHandler = requestHandler;
31065
31110
  this.#notificationHandler = notificationHandler;
31066
31111
  this.#stream = stream;
31067
- this.#closedPromise = new Promise((resolve17) => {
31068
- this.#abortController.signal.addEventListener("abort", () => resolve17());
31112
+ this.#closedPromise = new Promise((resolve18) => {
31113
+ this.#abortController.signal.addEventListener("abort", () => resolve18());
31069
31114
  });
31070
31115
  this.#receive();
31071
31116
  }
@@ -31214,8 +31259,8 @@ var init_acp = __esm({
31214
31259
  }
31215
31260
  async sendRequest(method, params) {
31216
31261
  const id = this.#nextRequestId++;
31217
- const responsePromise = new Promise((resolve17, reject) => {
31218
- this.#pendingResponses.set(id, { resolve: resolve17, reject });
31262
+ const responsePromise = new Promise((resolve18, reject) => {
31263
+ this.#pendingResponses.set(id, { resolve: resolve18, reject });
31219
31264
  });
31220
31265
  await this.#sendMessage({ jsonrpc: "2.0", id, method, params });
31221
31266
  return responsePromise;
@@ -31886,13 +31931,13 @@ var init_acp_provider_instance = __esm({
31886
31931
  }
31887
31932
  this.currentStatus = "waiting_approval";
31888
31933
  this.detectStatusTransition();
31889
- const approved = await new Promise((resolve17) => {
31890
- this.permissionResolvers.push(resolve17);
31934
+ const approved = await new Promise((resolve18) => {
31935
+ this.permissionResolvers.push(resolve18);
31891
31936
  setTimeout(() => {
31892
- const idx = this.permissionResolvers.indexOf(resolve17);
31937
+ const idx = this.permissionResolvers.indexOf(resolve18);
31893
31938
  if (idx >= 0) {
31894
31939
  this.permissionResolvers.splice(idx, 1);
31895
- resolve17(false);
31940
+ resolve18(false);
31896
31941
  }
31897
31942
  }, 3e5);
31898
31943
  });
@@ -34115,7 +34160,7 @@ var init_handler2 = __esm({
34115
34160
  this._addToNodeFs(path35, initialAdd, wh, depth + 1);
34116
34161
  }
34117
34162
  }).on(EV.ERROR, this._boundHandleError);
34118
- return new Promise((resolve17, reject) => {
34163
+ return new Promise((resolve18, reject) => {
34119
34164
  if (!stream)
34120
34165
  return reject();
34121
34166
  stream.once(STR_END, () => {
@@ -34124,7 +34169,7 @@ var init_handler2 = __esm({
34124
34169
  return;
34125
34170
  }
34126
34171
  const wasThrottled = throttler ? throttler.clear() : false;
34127
- resolve17(void 0);
34172
+ resolve18(void 0);
34128
34173
  previous.getChildren().filter((item) => {
34129
34174
  return item !== directory && !current.has(item);
34130
34175
  }).forEach((item) => {
@@ -35215,10 +35260,75 @@ var init_provider_loader = __esm({
35215
35260
  }
35216
35261
  static GITHUB_TARBALL_URL = "https://github.com/vilmire/adhdev-providers/archive/refs/heads/main.tar.gz";
35217
35262
  static META_FILE = ".meta.json";
35263
+ static REPO_PROVIDER_DIRNAME = "adhdev-providers";
35264
+ static SIBLING_MARKER_FILE = ".adhdev-provider-root";
35265
+ static SIBLING_ENV_VAR = "ADHDEV_USE_SIBLING_PROVIDERS";
35266
+ probeStarts = [];
35267
+ siblingLogged = false;
35268
+ userDirSource = "home-default";
35269
+ /** Process-level dedup for stderr sibling-adoption notices (shared across all ProviderLoader instances). */
35270
+ static siblingStderrLogged = /* @__PURE__ */ new Set();
35271
+ static looksLikeProviderRoot(candidate) {
35272
+ try {
35273
+ if (!fs6.existsSync(candidate) || !fs6.statSync(candidate).isDirectory()) return false;
35274
+ return ["ide", "extension", "cli", "acp"].some(
35275
+ (category) => fs6.existsSync(path14.join(candidate, category))
35276
+ );
35277
+ } catch {
35278
+ return false;
35279
+ }
35280
+ }
35281
+ static hasProviderRootMarker(candidate) {
35282
+ try {
35283
+ return fs6.existsSync(path14.join(candidate, _ProviderLoader.SIBLING_MARKER_FILE));
35284
+ } catch {
35285
+ return false;
35286
+ }
35287
+ }
35288
+ detectDefaultUserDir() {
35289
+ const fallback2 = path14.join(os16.homedir(), ".adhdev", "providers");
35290
+ const envOptIn = process.env[_ProviderLoader.SIBLING_ENV_VAR] === "1";
35291
+ const visited = /* @__PURE__ */ new Set();
35292
+ for (const start of this.probeStarts) {
35293
+ let current = path14.resolve(start);
35294
+ while (!visited.has(current)) {
35295
+ visited.add(current);
35296
+ const siblingCandidate = path14.join(path14.dirname(current), _ProviderLoader.REPO_PROVIDER_DIRNAME);
35297
+ if (_ProviderLoader.looksLikeProviderRoot(siblingCandidate)) {
35298
+ const hasMarker = _ProviderLoader.hasProviderRootMarker(siblingCandidate);
35299
+ if (envOptIn || hasMarker) {
35300
+ const source = hasMarker ? "sibling-marker" : "sibling-env";
35301
+ if (!this.siblingLogged) {
35302
+ this.log(`Using sibling provider checkout (${source}): ${siblingCandidate}`);
35303
+ this.siblingLogged = true;
35304
+ }
35305
+ if (!_ProviderLoader.siblingStderrLogged.has(siblingCandidate)) {
35306
+ _ProviderLoader.siblingStderrLogged.add(siblingCandidate);
35307
+ try {
35308
+ process.stderr.write(
35309
+ `[adhdev] Using sibling adhdev-providers checkout (${source}): ${siblingCandidate}
35310
+ `
35311
+ );
35312
+ } catch {
35313
+ }
35314
+ }
35315
+ return { path: siblingCandidate, source };
35316
+ }
35317
+ }
35318
+ const parent = path14.dirname(current);
35319
+ if (parent === current) break;
35320
+ current = parent;
35321
+ }
35322
+ }
35323
+ return { path: fallback2, source: "home-default" };
35324
+ }
35218
35325
  constructor(options) {
35219
35326
  this.logFn = options?.logFn || LOG.forComponent("Provider").asLogFn();
35327
+ this.probeStarts = options?.probeStarts ?? [process.cwd(), __dirname];
35220
35328
  this.defaultProvidersDir = path14.join(os16.homedir(), ".adhdev", "providers");
35221
- this.userDir = this.defaultProvidersDir;
35329
+ const detected = this.detectDefaultUserDir();
35330
+ this.userDir = detected.path;
35331
+ this.userDirSource = detected.source;
35222
35332
  this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
35223
35333
  this.disableUpstream = false;
35224
35334
  this.applySourceConfig({
@@ -35256,6 +35366,7 @@ var init_provider_loader = __esm({
35256
35366
  disableUpstream: this.disableUpstream,
35257
35367
  explicitProviderDir: this.explicitProviderDir,
35258
35368
  userDir: this.userDir,
35369
+ userDirSource: this.userDirSource,
35259
35370
  upstreamDir: this.upstreamDir,
35260
35371
  providerRoots: this.getProviderRoots()
35261
35372
  };
@@ -35266,7 +35377,14 @@ var init_provider_loader = __esm({
35266
35377
  this.explicitProviderDir = options.userDir?.trim() ? options.userDir : null;
35267
35378
  }
35268
35379
  this.sourceMode = nextSourceMode;
35269
- this.userDir = this.explicitProviderDir || this.defaultProvidersDir;
35380
+ if (this.explicitProviderDir) {
35381
+ this.userDir = this.explicitProviderDir;
35382
+ this.userDirSource = "explicit";
35383
+ } else {
35384
+ const detected = this.detectDefaultUserDir();
35385
+ this.userDir = detected.path;
35386
+ this.userDirSource = detected.source;
35387
+ }
35270
35388
  this.upstreamDir = path14.join(this.defaultProvidersDir, ".upstream");
35271
35389
  this.disableUpstream = this.sourceMode === "no-upstream";
35272
35390
  if (this.explicitProviderDir) {
@@ -35860,7 +35978,7 @@ var init_provider_loader = __esm({
35860
35978
  return { updated: false };
35861
35979
  }
35862
35980
  try {
35863
- const etag = await new Promise((resolve17, reject) => {
35981
+ const etag = await new Promise((resolve18, reject) => {
35864
35982
  const options = {
35865
35983
  method: "HEAD",
35866
35984
  hostname: "github.com",
@@ -35878,7 +35996,7 @@ var init_provider_loader = __esm({
35878
35996
  headers: { "User-Agent": "adhdev-launcher" },
35879
35997
  timeout: 1e4
35880
35998
  }, (res2) => {
35881
- resolve17(res2.headers.etag || res2.headers["last-modified"] || "");
35999
+ resolve18(res2.headers.etag || res2.headers["last-modified"] || "");
35882
36000
  });
35883
36001
  req2.on("error", reject);
35884
36002
  req2.on("timeout", () => {
@@ -35887,7 +36005,7 @@ var init_provider_loader = __esm({
35887
36005
  });
35888
36006
  req2.end();
35889
36007
  } else {
35890
- resolve17(res.headers.etag || res.headers["last-modified"] || "");
36008
+ resolve18(res.headers.etag || res.headers["last-modified"] || "");
35891
36009
  }
35892
36010
  });
35893
36011
  req.on("error", reject);
@@ -35951,7 +36069,7 @@ var init_provider_loader = __esm({
35951
36069
  downloadFile(url2, destPath) {
35952
36070
  const https = require("https");
35953
36071
  const http3 = require("http");
35954
- return new Promise((resolve17, reject) => {
36072
+ return new Promise((resolve18, reject) => {
35955
36073
  const doRequest = (reqUrl, redirectCount = 0) => {
35956
36074
  if (redirectCount > 5) {
35957
36075
  reject(new Error("Too many redirects"));
@@ -35971,7 +36089,7 @@ var init_provider_loader = __esm({
35971
36089
  res.pipe(ws);
35972
36090
  ws.on("finish", () => {
35973
36091
  ws.close();
35974
- resolve17();
36092
+ resolve18();
35975
36093
  });
35976
36094
  ws.on("error", reject);
35977
36095
  });
@@ -36447,17 +36565,17 @@ async function findFreePort(ports) {
36447
36565
  throw new Error("No free port found");
36448
36566
  }
36449
36567
  function checkPortFree(port) {
36450
- return new Promise((resolve17) => {
36568
+ return new Promise((resolve18) => {
36451
36569
  const server = net2.createServer();
36452
36570
  server.unref();
36453
- server.on("error", () => resolve17(false));
36571
+ server.on("error", () => resolve18(false));
36454
36572
  server.listen(port, "127.0.0.1", () => {
36455
- server.close(() => resolve17(true));
36573
+ server.close(() => resolve18(true));
36456
36574
  });
36457
36575
  });
36458
36576
  }
36459
36577
  async function isCdpActive(port) {
36460
- return new Promise((resolve17) => {
36578
+ return new Promise((resolve18) => {
36461
36579
  const req = require("http").get(`http://127.0.0.1:${port}/json/version`, {
36462
36580
  timeout: 2e3
36463
36581
  }, (res) => {
@@ -36466,16 +36584,16 @@ async function isCdpActive(port) {
36466
36584
  res.on("end", () => {
36467
36585
  try {
36468
36586
  const info = JSON.parse(data);
36469
- resolve17(!!info["WebKit-Version"] || !!info["Browser"]);
36587
+ resolve18(!!info["WebKit-Version"] || !!info["Browser"]);
36470
36588
  } catch {
36471
- resolve17(false);
36589
+ resolve18(false);
36472
36590
  }
36473
36591
  });
36474
36592
  });
36475
- req.on("error", () => resolve17(false));
36593
+ req.on("error", () => resolve18(false));
36476
36594
  req.on("timeout", () => {
36477
36595
  req.destroy();
36478
- resolve17(false);
36596
+ resolve18(false);
36479
36597
  });
36480
36598
  });
36481
36599
  }
@@ -37285,7 +37403,7 @@ async function waitForPidExit(pid, timeoutMs) {
37285
37403
  while (Date.now() - start < timeoutMs) {
37286
37404
  try {
37287
37405
  process.kill(pid, 0);
37288
- await new Promise((resolve17) => setTimeout(resolve17, 250));
37406
+ await new Promise((resolve18) => setTimeout(resolve18, 250));
37289
37407
  } catch {
37290
37408
  return;
37291
37409
  }
@@ -37400,7 +37518,7 @@ async function runDaemonUpgradeHelper(payload) {
37400
37518
  appendUpgradeLog(installOutput.trim());
37401
37519
  }
37402
37520
  if (process.platform === "win32") {
37403
- await new Promise((resolve17) => setTimeout(resolve17, 500));
37521
+ await new Promise((resolve18) => setTimeout(resolve18, 500));
37404
37522
  cleanupStaleGlobalInstallDirs(payload.packageName);
37405
37523
  appendUpgradeLog("Post-install staging cleanup complete");
37406
37524
  }
@@ -38808,7 +38926,7 @@ var init_provider_adapter = __esm({
38808
38926
  const beforeCount = this.messageCount(before);
38809
38927
  const beforeSignature = this.lastMessageSignature(before);
38810
38928
  for (let attempt = 0; attempt < 12; attempt += 1) {
38811
- await new Promise((resolve17) => setTimeout(resolve17, 250));
38929
+ await new Promise((resolve18) => setTimeout(resolve18, 250));
38812
38930
  let state;
38813
38931
  try {
38814
38932
  state = await this.readChat(evaluate);
@@ -38830,7 +38948,7 @@ var init_provider_adapter = __esm({
38830
38948
  if (this.messageCount(first) > 0 || this.lastMessageSignature(first)) {
38831
38949
  return first;
38832
38950
  }
38833
- await new Promise((resolve17) => setTimeout(resolve17, 150));
38951
+ await new Promise((resolve18) => setTimeout(resolve18, 150));
38834
38952
  const second = await this.readChat(evaluate);
38835
38953
  return this.messageCount(second) >= this.messageCount(first) ? second : first;
38836
38954
  }
@@ -38981,7 +39099,7 @@ var init_provider_adapter = __esm({
38981
39099
  if (typeof data.error === "string" && data.error.trim()) return false;
38982
39100
  }
38983
39101
  for (let attempt = 0; attempt < 6; attempt += 1) {
38984
- await new Promise((resolve17) => setTimeout(resolve17, 250));
39102
+ await new Promise((resolve18) => setTimeout(resolve18, 250));
38985
39103
  const state = await this.readChat(evaluate);
38986
39104
  const title = this.getStateTitle(state);
38987
39105
  if (this.titlesMatch(title, sessionId)) return true;
@@ -41556,7 +41674,7 @@ function getCliTargetBundle(ctx, type, instanceId) {
41556
41674
  return { target, instance, adapter };
41557
41675
  }
41558
41676
  function sleep(ms) {
41559
- return new Promise((resolve17) => setTimeout(resolve17, ms));
41677
+ return new Promise((resolve18) => setTimeout(resolve18, ms));
41560
41678
  }
41561
41679
  async function waitForCliReady(ctx, type, instanceId, timeoutMs) {
41562
41680
  const startedAt = Date.now();
@@ -43848,15 +43966,15 @@ var init_dev_server = __esm({
43848
43966
  this.json(res, 500, { error: e.message });
43849
43967
  }
43850
43968
  });
43851
- return new Promise((resolve17, reject) => {
43969
+ return new Promise((resolve18, reject) => {
43852
43970
  this.server.listen(port, "127.0.0.1", () => {
43853
43971
  this.log(`Dev server listening on http://127.0.0.1:${port}`);
43854
- resolve17();
43972
+ resolve18();
43855
43973
  });
43856
43974
  this.server.on("error", (e) => {
43857
43975
  if (e.code === "EADDRINUSE") {
43858
43976
  this.log(`Port ${port} in use, skipping dev server`);
43859
- resolve17();
43977
+ resolve18();
43860
43978
  } else {
43861
43979
  reject(e);
43862
43980
  }
@@ -43938,20 +44056,20 @@ var init_dev_server = __esm({
43938
44056
  child.stderr?.on("data", (d) => {
43939
44057
  stderr += d.toString().slice(0, 2e3);
43940
44058
  });
43941
- await new Promise((resolve17) => {
44059
+ await new Promise((resolve18) => {
43942
44060
  const timer = setTimeout(() => {
43943
44061
  child.kill();
43944
- resolve17();
44062
+ resolve18();
43945
44063
  }, 3e3);
43946
44064
  child.on("exit", () => {
43947
44065
  clearTimeout(timer);
43948
- resolve17();
44066
+ resolve18();
43949
44067
  });
43950
44068
  child.stdout?.once("data", () => {
43951
44069
  setTimeout(() => {
43952
44070
  child.kill();
43953
44071
  clearTimeout(timer);
43954
- resolve17();
44072
+ resolve18();
43955
44073
  }, 500);
43956
44074
  });
43957
44075
  });
@@ -44467,14 +44585,14 @@ var init_dev_server = __esm({
44467
44585
  child.stderr?.on("data", (d) => {
44468
44586
  stderr += d.toString();
44469
44587
  });
44470
- await new Promise((resolve17) => {
44588
+ await new Promise((resolve18) => {
44471
44589
  const timer = setTimeout(() => {
44472
44590
  child.kill();
44473
- resolve17();
44591
+ resolve18();
44474
44592
  }, timeout);
44475
44593
  child.on("exit", () => {
44476
44594
  clearTimeout(timer);
44477
- resolve17();
44595
+ resolve18();
44478
44596
  });
44479
44597
  });
44480
44598
  const elapsed = Date.now() - start;
@@ -45144,14 +45262,14 @@ data: ${JSON.stringify(msg.data)}
45144
45262
  res.end(JSON.stringify(data, null, 2));
45145
45263
  }
45146
45264
  async readBody(req) {
45147
- return new Promise((resolve17) => {
45265
+ return new Promise((resolve18) => {
45148
45266
  let body = "";
45149
45267
  req.on("data", (chunk) => body += chunk);
45150
45268
  req.on("end", () => {
45151
45269
  try {
45152
- resolve17(JSON.parse(body));
45270
+ resolve18(JSON.parse(body));
45153
45271
  } catch {
45154
- resolve17({});
45272
+ resolve18({});
45155
45273
  }
45156
45274
  });
45157
45275
  });
@@ -45666,7 +45784,7 @@ async function waitForReady(endpoint, timeoutMs = STARTUP_TIMEOUT_MS) {
45666
45784
  const deadline = Date.now() + timeoutMs;
45667
45785
  while (Date.now() < deadline) {
45668
45786
  if (await canConnect(endpoint)) return;
45669
- await new Promise((resolve17) => setTimeout(resolve17, STARTUP_POLL_MS));
45787
+ await new Promise((resolve18) => setTimeout(resolve18, STARTUP_POLL_MS));
45670
45788
  }
45671
45789
  throw new Error(`Session host did not become ready within ${timeoutMs}ms`);
45672
45790
  }
@@ -45772,10 +45890,10 @@ async function installExtension(ide, extension) {
45772
45890
  const buffer = Buffer.from(await res.arrayBuffer());
45773
45891
  const fs27 = await import("fs");
45774
45892
  fs27.writeFileSync(vsixPath, buffer);
45775
- return new Promise((resolve17) => {
45893
+ return new Promise((resolve18) => {
45776
45894
  const cmd = `"${ide.cliCommand}" --install-extension "${vsixPath}" --force`;
45777
45895
  (0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error48, _stdout, stderr) => {
45778
- resolve17({
45896
+ resolve18({
45779
45897
  extensionId: extension.id,
45780
45898
  marketplaceId: extension.marketplaceId,
45781
45899
  success: !error48,
@@ -45788,11 +45906,11 @@ async function installExtension(ide, extension) {
45788
45906
  } catch (e) {
45789
45907
  }
45790
45908
  }
45791
- return new Promise((resolve17) => {
45909
+ return new Promise((resolve18) => {
45792
45910
  const cmd = `"${ide.cliCommand}" --install-extension ${extension.marketplaceId} --force`;
45793
45911
  (0, import_child_process10.exec)(cmd, { timeout: 6e4 }, (error48, stdout, stderr) => {
45794
45912
  if (error48) {
45795
- resolve17({
45913
+ resolve18({
45796
45914
  extensionId: extension.id,
45797
45915
  marketplaceId: extension.marketplaceId,
45798
45916
  success: false,
@@ -45800,7 +45918,7 @@ async function installExtension(ide, extension) {
45800
45918
  error: stderr || error48.message
45801
45919
  });
45802
45920
  } else {
45803
- resolve17({
45921
+ resolve18({
45804
45922
  extensionId: extension.id,
45805
45923
  marketplaceId: extension.marketplaceId,
45806
45924
  success: true,
@@ -46464,7 +46582,7 @@ async function sendDaemonCommand(cmd, args = {}, port) {
46464
46582
  const resolvedPort = resolveDaemonCommandPort(port);
46465
46583
  const WebSocket4 = (await import("ws")).default;
46466
46584
  const { DAEMON_WS_PATH: DAEMON_WS_PATH2 } = await Promise.resolve().then(() => (init_src(), src_exports));
46467
- return new Promise((resolve17, reject) => {
46585
+ return new Promise((resolve18, reject) => {
46468
46586
  const wsUrl = `ws://127.0.0.1:${resolvedPort}${DAEMON_WS_PATH2 || "/daemon"}`;
46469
46587
  const ws = new WebSocket4(wsUrl);
46470
46588
  const requestId = `cli-${Date.now()}`;
@@ -46505,7 +46623,7 @@ async function sendDaemonCommand(cmd, args = {}, port) {
46505
46623
  if (msg.type === "ext:command_result" && msg.payload?.requestId === requestId || msg.type === "daemon:command_result" || msg.type === "command_result") {
46506
46624
  clearTimeout(timeout);
46507
46625
  ws.close();
46508
- resolve17(msg.payload?.result || msg.payload || msg);
46626
+ resolve18(msg.payload?.result || msg.payload || msg);
46509
46627
  }
46510
46628
  } catch {
46511
46629
  }
@@ -46524,13 +46642,13 @@ This command needs a running local daemon with IPC enabled. Start with: adhdev d
46524
46642
  }
46525
46643
  async function directCdpEval(expression, port = 9222) {
46526
46644
  const http3 = await import("http");
46527
- const targets = await new Promise((resolve17, reject) => {
46645
+ const targets = await new Promise((resolve18, reject) => {
46528
46646
  http3.get(`http://127.0.0.1:${port}/json`, (res) => {
46529
46647
  let data = "";
46530
46648
  res.on("data", (c) => data += c);
46531
46649
  res.on("end", () => {
46532
46650
  try {
46533
- resolve17(JSON.parse(data));
46651
+ resolve18(JSON.parse(data));
46534
46652
  } catch {
46535
46653
  reject(new Error("Invalid JSON"));
46536
46654
  }
@@ -46543,7 +46661,7 @@ async function directCdpEval(expression, port = 9222) {
46543
46661
  const target = (mainPages.length > 0 ? mainPages[0] : pages[0]) || targets[0];
46544
46662
  if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target found");
46545
46663
  const WebSocket4 = (await import("ws")).default;
46546
- return new Promise((resolve17, reject) => {
46664
+ return new Promise((resolve18, reject) => {
46547
46665
  const ws = new WebSocket4(target.webSocketDebuggerUrl);
46548
46666
  const timeout = setTimeout(() => {
46549
46667
  ws.close();
@@ -46565,11 +46683,11 @@ async function directCdpEval(expression, port = 9222) {
46565
46683
  clearTimeout(timeout);
46566
46684
  ws.close();
46567
46685
  if (msg.result?.result?.value !== void 0) {
46568
- resolve17(msg.result.result.value);
46686
+ resolve18(msg.result.result.value);
46569
46687
  } else if (msg.result?.exceptionDetails) {
46570
46688
  reject(new Error(msg.result.exceptionDetails.text));
46571
46689
  } else {
46572
- resolve17(msg.result);
46690
+ resolve18(msg.result);
46573
46691
  }
46574
46692
  }
46575
46693
  });
@@ -47105,14 +47223,14 @@ var require_run_async = __commonJS({
47105
47223
  return function() {
47106
47224
  var args = arguments;
47107
47225
  var originalThis = this;
47108
- var promise2 = new Promise(function(resolve17, reject) {
47226
+ var promise2 = new Promise(function(resolve18, reject) {
47109
47227
  var resolved = false;
47110
47228
  const wrappedResolve = function(value) {
47111
47229
  if (resolved) {
47112
47230
  console.warn("Run-async promise already resolved.");
47113
47231
  }
47114
47232
  resolved = true;
47115
- resolve17(value);
47233
+ resolve18(value);
47116
47234
  };
47117
47235
  var rejected = false;
47118
47236
  const wrappedReject = function(value) {
@@ -47903,7 +48021,7 @@ var require_Observable = __commonJS({
47903
48021
  Observable2.prototype.forEach = function(next, promiseCtor) {
47904
48022
  var _this = this;
47905
48023
  promiseCtor = getPromiseCtor(promiseCtor);
47906
- return new promiseCtor(function(resolve17, reject) {
48024
+ return new promiseCtor(function(resolve18, reject) {
47907
48025
  var subscriber = new Subscriber_1.SafeSubscriber({
47908
48026
  next: function(value) {
47909
48027
  try {
@@ -47914,7 +48032,7 @@ var require_Observable = __commonJS({
47914
48032
  }
47915
48033
  },
47916
48034
  error: reject,
47917
- complete: resolve17
48035
+ complete: resolve18
47918
48036
  });
47919
48037
  _this.subscribe(subscriber);
47920
48038
  });
@@ -47936,14 +48054,14 @@ var require_Observable = __commonJS({
47936
48054
  Observable2.prototype.toPromise = function(promiseCtor) {
47937
48055
  var _this = this;
47938
48056
  promiseCtor = getPromiseCtor(promiseCtor);
47939
- return new promiseCtor(function(resolve17, reject) {
48057
+ return new promiseCtor(function(resolve18, reject) {
47940
48058
  var value;
47941
48059
  _this.subscribe(function(x) {
47942
48060
  return value = x;
47943
48061
  }, function(err) {
47944
48062
  return reject(err);
47945
48063
  }, function() {
47946
- return resolve17(value);
48064
+ return resolve18(value);
47947
48065
  });
47948
48066
  });
47949
48067
  };
@@ -50039,11 +50157,11 @@ var require_innerFrom = __commonJS({
50039
50157
  "use strict";
50040
50158
  var __awaiter = exports2 && exports2.__awaiter || function(thisArg, _arguments, P, generator) {
50041
50159
  function adopt(value) {
50042
- return value instanceof P ? value : new P(function(resolve17) {
50043
- resolve17(value);
50160
+ return value instanceof P ? value : new P(function(resolve18) {
50161
+ resolve18(value);
50044
50162
  });
50045
50163
  }
50046
- return new (P || (P = Promise))(function(resolve17, reject) {
50164
+ return new (P || (P = Promise))(function(resolve18, reject) {
50047
50165
  function fulfilled(value) {
50048
50166
  try {
50049
50167
  step(generator.next(value));
@@ -50059,7 +50177,7 @@ var require_innerFrom = __commonJS({
50059
50177
  }
50060
50178
  }
50061
50179
  function step(result) {
50062
- result.done ? resolve17(result.value) : adopt(result.value).then(fulfilled, rejected);
50180
+ result.done ? resolve18(result.value) : adopt(result.value).then(fulfilled, rejected);
50063
50181
  }
50064
50182
  step((generator = generator.apply(thisArg, _arguments || [])).next());
50065
50183
  });
@@ -50141,14 +50259,14 @@ var require_innerFrom = __commonJS({
50141
50259
  }, i);
50142
50260
  function verb(n) {
50143
50261
  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);
50262
+ return new Promise(function(resolve18, reject) {
50263
+ v = o[n](v), settle(resolve18, reject, v.done, v.value);
50146
50264
  });
50147
50265
  };
50148
50266
  }
50149
- function settle(resolve17, reject, d, v) {
50267
+ function settle(resolve18, reject, d, v) {
50150
50268
  Promise.resolve(v).then(function(v2) {
50151
- resolve17({ value: v2, done: d });
50269
+ resolve18({ value: v2, done: d });
50152
50270
  }, reject);
50153
50271
  }
50154
50272
  };
@@ -50767,7 +50885,7 @@ var require_lastValueFrom = __commonJS({
50767
50885
  var EmptyError_1 = require_EmptyError();
50768
50886
  function lastValueFrom(source, config2) {
50769
50887
  var hasConfig = typeof config2 === "object";
50770
- return new Promise(function(resolve17, reject) {
50888
+ return new Promise(function(resolve18, reject) {
50771
50889
  var _hasValue = false;
50772
50890
  var _value;
50773
50891
  source.subscribe({
@@ -50778,9 +50896,9 @@ var require_lastValueFrom = __commonJS({
50778
50896
  error: reject,
50779
50897
  complete: function() {
50780
50898
  if (_hasValue) {
50781
- resolve17(_value);
50899
+ resolve18(_value);
50782
50900
  } else if (hasConfig) {
50783
- resolve17(config2.defaultValue);
50901
+ resolve18(config2.defaultValue);
50784
50902
  } else {
50785
50903
  reject(new EmptyError_1.EmptyError());
50786
50904
  }
@@ -50802,16 +50920,16 @@ var require_firstValueFrom = __commonJS({
50802
50920
  var Subscriber_1 = require_Subscriber();
50803
50921
  function firstValueFrom(source, config2) {
50804
50922
  var hasConfig = typeof config2 === "object";
50805
- return new Promise(function(resolve17, reject) {
50923
+ return new Promise(function(resolve18, reject) {
50806
50924
  var subscriber = new Subscriber_1.SafeSubscriber({
50807
50925
  next: function(value) {
50808
- resolve17(value);
50926
+ resolve18(value);
50809
50927
  subscriber.unsubscribe();
50810
50928
  },
50811
50929
  error: reject,
50812
50930
  complete: function() {
50813
50931
  if (hasConfig) {
50814
- resolve17(config2.defaultValue);
50932
+ resolve18(config2.defaultValue);
50815
50933
  } else {
50816
50934
  reject(new EmptyError_1.EmptyError());
50817
50935
  }
@@ -62617,14 +62735,14 @@ var require_async_iterator = __commonJS({
62617
62735
  };
62618
62736
  }
62619
62737
  function readAndResolve(iter) {
62620
- var resolve17 = iter[kLastResolve];
62621
- if (resolve17 !== null) {
62738
+ var resolve18 = iter[kLastResolve];
62739
+ if (resolve18 !== null) {
62622
62740
  var data = iter[kStream].read();
62623
62741
  if (data !== null) {
62624
62742
  iter[kLastPromise] = null;
62625
62743
  iter[kLastResolve] = null;
62626
62744
  iter[kLastReject] = null;
62627
- resolve17(createIterResult(data, false));
62745
+ resolve18(createIterResult(data, false));
62628
62746
  }
62629
62747
  }
62630
62748
  }
@@ -62632,13 +62750,13 @@ var require_async_iterator = __commonJS({
62632
62750
  process.nextTick(readAndResolve, iter);
62633
62751
  }
62634
62752
  function wrapForNext(lastPromise, iter) {
62635
- return function(resolve17, reject) {
62753
+ return function(resolve18, reject) {
62636
62754
  lastPromise.then(function() {
62637
62755
  if (iter[kEnded]) {
62638
- resolve17(createIterResult(void 0, true));
62756
+ resolve18(createIterResult(void 0, true));
62639
62757
  return;
62640
62758
  }
62641
- iter[kHandlePromise](resolve17, reject);
62759
+ iter[kHandlePromise](resolve18, reject);
62642
62760
  }, reject);
62643
62761
  };
62644
62762
  }
@@ -62658,12 +62776,12 @@ var require_async_iterator = __commonJS({
62658
62776
  return Promise.resolve(createIterResult(void 0, true));
62659
62777
  }
62660
62778
  if (this[kStream].destroyed) {
62661
- return new Promise(function(resolve17, reject) {
62779
+ return new Promise(function(resolve18, reject) {
62662
62780
  process.nextTick(function() {
62663
62781
  if (_this[kError]) {
62664
62782
  reject(_this[kError]);
62665
62783
  } else {
62666
- resolve17(createIterResult(void 0, true));
62784
+ resolve18(createIterResult(void 0, true));
62667
62785
  }
62668
62786
  });
62669
62787
  });
@@ -62686,13 +62804,13 @@ var require_async_iterator = __commonJS({
62686
62804
  return this;
62687
62805
  }), _defineProperty(_Object$setPrototypeO, "return", function _return() {
62688
62806
  var _this2 = this;
62689
- return new Promise(function(resolve17, reject) {
62807
+ return new Promise(function(resolve18, reject) {
62690
62808
  _this2[kStream].destroy(null, function(err) {
62691
62809
  if (err) {
62692
62810
  reject(err);
62693
62811
  return;
62694
62812
  }
62695
- resolve17(createIterResult(void 0, true));
62813
+ resolve18(createIterResult(void 0, true));
62696
62814
  });
62697
62815
  });
62698
62816
  }), _Object$setPrototypeO), AsyncIteratorPrototype);
@@ -62714,15 +62832,15 @@ var require_async_iterator = __commonJS({
62714
62832
  value: stream._readableState.endEmitted,
62715
62833
  writable: true
62716
62834
  }), _defineProperty(_Object$create, kHandlePromise, {
62717
- value: function value(resolve17, reject) {
62835
+ value: function value(resolve18, reject) {
62718
62836
  var data = iterator[kStream].read();
62719
62837
  if (data) {
62720
62838
  iterator[kLastPromise] = null;
62721
62839
  iterator[kLastResolve] = null;
62722
62840
  iterator[kLastReject] = null;
62723
- resolve17(createIterResult(data, false));
62841
+ resolve18(createIterResult(data, false));
62724
62842
  } else {
62725
- iterator[kLastResolve] = resolve17;
62843
+ iterator[kLastResolve] = resolve18;
62726
62844
  iterator[kLastReject] = reject;
62727
62845
  }
62728
62846
  },
@@ -62741,12 +62859,12 @@ var require_async_iterator = __commonJS({
62741
62859
  iterator[kError] = err;
62742
62860
  return;
62743
62861
  }
62744
- var resolve17 = iterator[kLastResolve];
62745
- if (resolve17 !== null) {
62862
+ var resolve18 = iterator[kLastResolve];
62863
+ if (resolve18 !== null) {
62746
62864
  iterator[kLastPromise] = null;
62747
62865
  iterator[kLastResolve] = null;
62748
62866
  iterator[kLastReject] = null;
62749
- resolve17(createIterResult(void 0, true));
62867
+ resolve18(createIterResult(void 0, true));
62750
62868
  }
62751
62869
  iterator[kEnded] = true;
62752
62870
  });
@@ -62761,7 +62879,7 @@ var require_async_iterator = __commonJS({
62761
62879
  var require_from2 = __commonJS({
62762
62880
  "../../node_modules/readable-stream/lib/internal/streams/from.js"(exports2, module2) {
62763
62881
  "use strict";
62764
- function asyncGeneratorStep(gen, resolve17, reject, _next, _throw, key, arg) {
62882
+ function asyncGeneratorStep(gen, resolve18, reject, _next, _throw, key, arg) {
62765
62883
  try {
62766
62884
  var info = gen[key](arg);
62767
62885
  var value = info.value;
@@ -62770,7 +62888,7 @@ var require_from2 = __commonJS({
62770
62888
  return;
62771
62889
  }
62772
62890
  if (info.done) {
62773
- resolve17(value);
62891
+ resolve18(value);
62774
62892
  } else {
62775
62893
  Promise.resolve(value).then(_next, _throw);
62776
62894
  }
@@ -62778,13 +62896,13 @@ var require_from2 = __commonJS({
62778
62896
  function _asyncToGenerator(fn) {
62779
62897
  return function() {
62780
62898
  var self2 = this, args = arguments;
62781
- return new Promise(function(resolve17, reject) {
62899
+ return new Promise(function(resolve18, reject) {
62782
62900
  var gen = fn.apply(self2, args);
62783
62901
  function _next(value) {
62784
- asyncGeneratorStep(gen, resolve17, reject, _next, _throw, "next", value);
62902
+ asyncGeneratorStep(gen, resolve18, reject, _next, _throw, "next", value);
62785
62903
  }
62786
62904
  function _throw(err) {
62787
- asyncGeneratorStep(gen, resolve17, reject, _next, _throw, "throw", err);
62905
+ asyncGeneratorStep(gen, resolve18, reject, _next, _throw, "throw", err);
62788
62906
  }
62789
62907
  _next(void 0);
62790
62908
  });
@@ -64723,9 +64841,9 @@ var init_base = __esm({
64723
64841
  * @return {Promise}
64724
64842
  */
64725
64843
  run() {
64726
- return new Promise((resolve17, reject) => {
64844
+ return new Promise((resolve18, reject) => {
64727
64845
  this._run(
64728
- (value) => resolve17(value),
64846
+ (value) => resolve18(value),
64729
64847
  (error48) => reject(error48)
64730
64848
  );
64731
64849
  });
@@ -71357,7 +71475,7 @@ var require_lib = __commonJS({
71357
71475
  return matches;
71358
71476
  };
71359
71477
  exports2.analyse = analyse;
71360
- var detectFile = (filepath, opts = {}) => new Promise((resolve17, reject) => {
71478
+ var detectFile = (filepath, opts = {}) => new Promise((resolve18, reject) => {
71361
71479
  let fd;
71362
71480
  const fs27 = (0, node_1.default)();
71363
71481
  const handler = (err, buffer) => {
@@ -71367,7 +71485,7 @@ var require_lib = __commonJS({
71367
71485
  if (err) {
71368
71486
  reject(err);
71369
71487
  } else if (buffer) {
71370
- resolve17((0, exports2.detect)(buffer));
71488
+ resolve18((0, exports2.detect)(buffer));
71371
71489
  } else {
71372
71490
  reject(new Error("No error and no buffer received"));
71373
71491
  }
@@ -77612,14 +77730,14 @@ var init_open = __esm({
77612
77730
  }
77613
77731
  const subprocess = import_node_child_process5.default.spawn(command, cliArguments, childProcessOptions);
77614
77732
  if (options.wait) {
77615
- return new Promise((resolve17, reject) => {
77733
+ return new Promise((resolve18, reject) => {
77616
77734
  subprocess.once("error", reject);
77617
77735
  subprocess.once("close", (exitCode) => {
77618
77736
  if (!options.allowNonzeroExitCode && exitCode > 0) {
77619
77737
  reject(new Error(`Exited with code ${exitCode}`));
77620
77738
  return;
77621
77739
  }
77622
- resolve17(subprocess);
77740
+ resolve18(subprocess);
77623
77741
  });
77624
77742
  });
77625
77743
  }
@@ -79199,14 +79317,14 @@ var require_filesystem = __commonJS({
79199
79317
  });
79200
79318
  return buffer.subarray(0, bytesRead);
79201
79319
  };
79202
- var readFile = (path35) => new Promise((resolve17, reject) => {
79320
+ var readFile = (path35) => new Promise((resolve18, reject) => {
79203
79321
  fs27.open(path35, "r", (err, fd) => {
79204
79322
  if (err) {
79205
79323
  reject(err);
79206
79324
  } else {
79207
79325
  const buffer = Buffer.alloc(MAX_LENGTH);
79208
79326
  fs27.read(fd, buffer, 0, MAX_LENGTH, 0, (_2, bytesRead) => {
79209
- resolve17(buffer.subarray(0, bytesRead));
79327
+ resolve18(buffer.subarray(0, bytesRead));
79210
79328
  fs27.close(fd, () => {
79211
79329
  });
79212
79330
  });
@@ -79274,10 +79392,10 @@ var require_detect_libc = __commonJS({
79274
79392
  var commandOut = "";
79275
79393
  var safeCommand = () => {
79276
79394
  if (!commandOut) {
79277
- return new Promise((resolve17) => {
79395
+ return new Promise((resolve18) => {
79278
79396
  childProcess2.exec(command, (err, out) => {
79279
79397
  commandOut = err ? " " : out;
79280
- resolve17(commandOut);
79398
+ resolve18(commandOut);
79281
79399
  });
79282
79400
  });
79283
79401
  }
@@ -81957,14 +82075,14 @@ var require_input = __commonJS({
81957
82075
  return this;
81958
82076
  } else {
81959
82077
  if (this._isStreamInput()) {
81960
- return new Promise((resolve17, reject) => {
82078
+ return new Promise((resolve18, reject) => {
81961
82079
  const finished = () => {
81962
82080
  this._flattenBufferIn();
81963
82081
  sharp.metadata(this.options, (err, metadata2) => {
81964
82082
  if (err) {
81965
82083
  reject(is.nativeError(err, stack));
81966
82084
  } else {
81967
- resolve17(metadata2);
82085
+ resolve18(metadata2);
81968
82086
  }
81969
82087
  });
81970
82088
  };
@@ -81975,12 +82093,12 @@ var require_input = __commonJS({
81975
82093
  }
81976
82094
  });
81977
82095
  } else {
81978
- return new Promise((resolve17, reject) => {
82096
+ return new Promise((resolve18, reject) => {
81979
82097
  sharp.metadata(this.options, (err, metadata2) => {
81980
82098
  if (err) {
81981
82099
  reject(is.nativeError(err, stack));
81982
82100
  } else {
81983
- resolve17(metadata2);
82101
+ resolve18(metadata2);
81984
82102
  }
81985
82103
  });
81986
82104
  });
@@ -82013,25 +82131,25 @@ var require_input = __commonJS({
82013
82131
  return this;
82014
82132
  } else {
82015
82133
  if (this._isStreamInput()) {
82016
- return new Promise((resolve17, reject) => {
82134
+ return new Promise((resolve18, reject) => {
82017
82135
  this.on("finish", function() {
82018
82136
  this._flattenBufferIn();
82019
82137
  sharp.stats(this.options, (err, stats2) => {
82020
82138
  if (err) {
82021
82139
  reject(is.nativeError(err, stack));
82022
82140
  } else {
82023
- resolve17(stats2);
82141
+ resolve18(stats2);
82024
82142
  }
82025
82143
  });
82026
82144
  });
82027
82145
  });
82028
82146
  } else {
82029
- return new Promise((resolve17, reject) => {
82147
+ return new Promise((resolve18, reject) => {
82030
82148
  sharp.stats(this.options, (err, stats2) => {
82031
82149
  if (err) {
82032
82150
  reject(is.nativeError(err, stack));
82033
82151
  } else {
82034
- resolve17(stats2);
82152
+ resolve18(stats2);
82035
82153
  }
82036
82154
  });
82037
82155
  });
@@ -85453,7 +85571,7 @@ var require_output = __commonJS({
85453
85571
  return this;
85454
85572
  } else {
85455
85573
  if (this._isStreamInput()) {
85456
- return new Promise((resolve17, reject) => {
85574
+ return new Promise((resolve18, reject) => {
85457
85575
  this.once("finish", () => {
85458
85576
  this._flattenBufferIn();
85459
85577
  sharp.pipeline(this.options, (err, data, info) => {
@@ -85461,24 +85579,24 @@ var require_output = __commonJS({
85461
85579
  reject(is.nativeError(err, stack));
85462
85580
  } else {
85463
85581
  if (this.options.resolveWithObject) {
85464
- resolve17({ data, info });
85582
+ resolve18({ data, info });
85465
85583
  } else {
85466
- resolve17(data);
85584
+ resolve18(data);
85467
85585
  }
85468
85586
  }
85469
85587
  });
85470
85588
  });
85471
85589
  });
85472
85590
  } else {
85473
- return new Promise((resolve17, reject) => {
85591
+ return new Promise((resolve18, reject) => {
85474
85592
  sharp.pipeline(this.options, (err, data, info) => {
85475
85593
  if (err) {
85476
85594
  reject(is.nativeError(err, stack));
85477
85595
  } else {
85478
85596
  if (this.options.resolveWithObject) {
85479
- resolve17({ data, info });
85597
+ resolve18({ data, info });
85480
85598
  } else {
85481
- resolve17(data);
85599
+ resolve18(data);
85482
85600
  }
85483
85601
  }
85484
85602
  });
@@ -86532,7 +86650,7 @@ var init_adhdev_daemon = __esm({
86532
86650
  init_version();
86533
86651
  init_src();
86534
86652
  init_runtime_defaults();
86535
- pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.92" });
86653
+ pkgVersion = resolvePackageVersion({ injectedVersion: "0.8.94" });
86536
86654
  AdhdevDaemon = class _AdhdevDaemon {
86537
86655
  localHttpServer = null;
86538
86656
  localWss = null;
@@ -87376,7 +87494,7 @@ ${err?.stack || ""}`);
87376
87494
  this.localWss.emit("connection", ws, req);
87377
87495
  });
87378
87496
  });
87379
- await new Promise((resolve17, reject) => {
87497
+ await new Promise((resolve18, reject) => {
87380
87498
  const cleanup = () => {
87381
87499
  this.localHttpServer?.off("error", onError);
87382
87500
  this.localHttpServer?.off("listening", onListening);
@@ -87387,7 +87505,7 @@ ${err?.stack || ""}`);
87387
87505
  };
87388
87506
  const onListening = () => {
87389
87507
  cleanup();
87390
- resolve17();
87508
+ resolve18();
87391
87509
  };
87392
87510
  this.localHttpServer.once("error", onError);
87393
87511
  this.localHttpServer.once("listening", onListening);
@@ -87547,12 +87665,12 @@ ${err?.stack || ""}`);
87547
87665
  this.localClients.clear();
87548
87666
  this.localWss?.close();
87549
87667
  this.localWss = null;
87550
- await new Promise((resolve17) => {
87668
+ await new Promise((resolve18) => {
87551
87669
  if (!this.localHttpServer) {
87552
- resolve17();
87670
+ resolve18();
87553
87671
  return;
87554
87672
  }
87555
- this.localHttpServer.close(() => resolve17());
87673
+ this.localHttpServer.close(() => resolve18());
87556
87674
  this.localHttpServer = null;
87557
87675
  });
87558
87676
  } catch {
@@ -89003,11 +89121,25 @@ init_source();
89003
89121
  init_src();
89004
89122
 
89005
89123
  // src/cli/provider-source-status.ts
89124
+ function describeUserDirSource(source) {
89125
+ switch (source) {
89126
+ case "sibling-env":
89127
+ return " (auto-adopted sibling checkout via ADHDEV_USE_SIBLING_PROVIDERS=1)";
89128
+ case "sibling-marker":
89129
+ return " (auto-adopted sibling checkout via .adhdev-provider-root marker)";
89130
+ case "explicit":
89131
+ return " (from config.providerDir)";
89132
+ case "home-default":
89133
+ case void 0:
89134
+ return "";
89135
+ }
89136
+ }
89006
89137
  function buildProviderSourceStatusLines(config2) {
89138
+ const sourceSuffix = describeUserDirSource(config2.userDirSource);
89007
89139
  return [
89008
89140
  `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}`,
89141
+ `Explicit providerDir: ${config2.explicitProviderDir || `default (${config2.userDir})`}`,
89142
+ `Effective user root: ${config2.userDir}${sourceSuffix}`,
89011
89143
  `Upstream root: ${config2.upstreamDir}`,
89012
89144
  `Provider roots: ${config2.providerRoots.join(" -> ")}`
89013
89145
  ];
@@ -89867,6 +89999,20 @@ function buildRuntimeOpenLaunchSpec(options) {
89867
89999
  return spec;
89868
90000
  }
89869
90001
 
90002
+ // src/cli/provider-loader-factory.ts
90003
+ async function createConfiguredProviderLoader(options = {}) {
90004
+ const { ProviderLoader: ProviderLoader2, loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_src(), src_exports));
90005
+ const config2 = loadConfig2();
90006
+ const loader = new ProviderLoader2({
90007
+ logFn: options.silent === false ? void 0 : () => {
90008
+ },
90009
+ userDir: config2.providerDir,
90010
+ sourceMode: config2.providerSourceMode
90011
+ });
90012
+ if (options.load) loader.loadAll();
90013
+ return loader;
90014
+ }
90015
+
89870
90016
  // src/cli/debug-trace-cli.ts
89871
90017
  function normalizeOptionalFilter(value) {
89872
90018
  if (typeof value !== "string") return void 0;
@@ -89980,14 +90126,14 @@ async function requestSessionHostDirect(request) {
89980
90126
  }
89981
90127
  async function runRuntimeLaunchSpec(spec) {
89982
90128
  const { spawn: spawn6 } = await import("child_process");
89983
- return await new Promise((resolve17, reject) => {
90129
+ return await new Promise((resolve18, reject) => {
89984
90130
  const child = spawn6(spec.command, spec.args, {
89985
90131
  stdio: "inherit",
89986
90132
  env: spec.env,
89987
90133
  shell: process.platform === "win32" && spec.command !== process.execPath
89988
90134
  });
89989
90135
  child.on("error", reject);
89990
- child.on("exit", (code) => resolve17(code ?? 0));
90136
+ child.on("exit", (code) => resolve18(code ?? 0));
89991
90137
  });
89992
90138
  }
89993
90139
  async function resolveRuntimeSessionId(target, options) {
@@ -90221,7 +90367,7 @@ async function handleTraceCommand(options) {
90221
90367
  }
90222
90368
  }
90223
90369
  while (!stopped) {
90224
- await new Promise((resolve17) => setTimeout(resolve17, intervalMs));
90370
+ await new Promise((resolve18) => setTimeout(resolve18, intervalMs));
90225
90371
  if (stopped) break;
90226
90372
  const nextTrace = await fetchTrace(buildDebugTraceFollowPollArgs(baseArgs, cursor));
90227
90373
  const nextBatch = collectFreshDebugTraceEntries(nextTrace, cursor);
@@ -90344,17 +90490,11 @@ function registerDaemonCommands(program2, pkgVersion3) {
90344
90490
  }));
90345
90491
  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
90492
  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));
90493
+ const { getCurrentDaemonLogPath: getCurrentDaemonLogPath2, loadConfig: loadConfig2 } = await Promise.resolve().then(() => (init_src(), src_exports));
90348
90494
  const { probeSessionHostStatus: probeSessionHostStatus2 } = await Promise.resolve().then(() => (init_session_host(), session_host_exports));
90349
90495
  const port = parseInt(options.port, 10) || DEFAULT_DAEMON_PORT;
90350
- const { loadConfig: loadConfig2, ProviderLoader: ProviderLoader2 } = await Promise.resolve().then(() => (init_src(), src_exports));
90351
90496
  const config2 = loadConfig2();
90352
- const providerLoader = new ProviderLoader2({
90353
- logFn: () => {
90354
- },
90355
- userDir: config2.providerDir,
90356
- sourceMode: config2.providerSourceMode
90357
- });
90497
+ const providerLoader = await createConfiguredProviderLoader();
90358
90498
  if (isDaemonRunning2({ port })) {
90359
90499
  console.log(source_default.green(`
90360
90500
  \u2713 ADHDev Daemon is running.
@@ -91370,7 +91510,7 @@ function registerDoctorCommands(program2, pkgVersion3) {
91370
91510
  } catch {
91371
91511
  }
91372
91512
  try {
91373
- const providerLoader = new ProviderLoader();
91513
+ const providerLoader = await createConfiguredProviderLoader({ load: true });
91374
91514
  const cliResults = await detectCLIs(providerLoader);
91375
91515
  for (const cli of cliResults) {
91376
91516
  checks.push({
@@ -91590,15 +91730,8 @@ function hideCommand2(command) {
91590
91730
  command.hideHelp?.();
91591
91731
  return command;
91592
91732
  }
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;
91733
+ async function createConfiguredProviderLoader2() {
91734
+ return createConfiguredProviderLoader({ silent: false, load: true });
91602
91735
  }
91603
91736
  function getProviderSourceCandidatePaths(options) {
91604
91737
  const relativeNames = ["provider.json", "scripts.js", "provider.js"];
@@ -91615,7 +91748,7 @@ function registerProviderCommands(program2) {
91615
91748
  const provider = hideCommand2(program2.command("provider").description("\u{1F50C} Provider management \u2014 list, test, reload providers"));
91616
91749
  provider.command("list").description("List all loaded providers").option("-j, --json", "Output raw JSON").action(async (options) => {
91617
91750
  try {
91618
- const loader = await createConfiguredProviderLoader();
91751
+ const loader = await createConfiguredProviderLoader2();
91619
91752
  const providers = loader.getAll();
91620
91753
  if (options.json) {
91621
91754
  console.log(JSON.stringify(providers.map((p) => ({
@@ -91667,7 +91800,7 @@ function registerProviderCommands(program2) {
91667
91800
  } catch {
91668
91801
  try {
91669
91802
  const http3 = await import("http");
91670
- const result = await new Promise((resolve17, reject) => {
91803
+ const result = await new Promise((resolve18, reject) => {
91671
91804
  const req = http3.request({
91672
91805
  hostname: "127.0.0.1",
91673
91806
  port: DEV_SERVER_PORT3,
@@ -91679,9 +91812,9 @@ function registerProviderCommands(program2) {
91679
91812
  res.on("data", (c) => data += c);
91680
91813
  res.on("end", () => {
91681
91814
  try {
91682
- resolve17(JSON.parse(data));
91815
+ resolve18(JSON.parse(data));
91683
91816
  } catch {
91684
- resolve17({ raw: data });
91817
+ resolve18({ raw: data });
91685
91818
  }
91686
91819
  });
91687
91820
  });
@@ -91783,12 +91916,12 @@ function registerProviderCommands(program2) {
91783
91916
  console.log(source_default.yellow("Invalid port number."));
91784
91917
  continue;
91785
91918
  }
91786
- const isFree = await new Promise((resolve17) => {
91919
+ const isFree = await new Promise((resolve18) => {
91787
91920
  const server = net3.createServer();
91788
91921
  server.unref();
91789
- server.on("error", () => resolve17(false));
91922
+ server.on("error", () => resolve18(false));
91790
91923
  server.listen(port, "127.0.0.1", () => {
91791
- server.close(() => resolve17(true));
91924
+ server.close(() => resolve18(true));
91792
91925
  });
91793
91926
  });
91794
91927
  if (!isFree) {
@@ -91803,7 +91936,7 @@ function registerProviderCommands(program2) {
91803
91936
  rl.close();
91804
91937
  const location = options.builtin ? "builtin" : "user";
91805
91938
  const http3 = await import("http");
91806
- const result = await new Promise((resolve17, reject) => {
91939
+ const result = await new Promise((resolve18, reject) => {
91807
91940
  const postData = JSON.stringify({ type, name, category, location, cdpPorts, osPaths, processNames });
91808
91941
  const req = http3.request({
91809
91942
  hostname: "127.0.0.1",
@@ -91816,9 +91949,9 @@ function registerProviderCommands(program2) {
91816
91949
  res.on("data", (c) => data += c);
91817
91950
  res.on("end", () => {
91818
91951
  try {
91819
- resolve17(JSON.parse(data));
91952
+ resolve18(JSON.parse(data));
91820
91953
  } catch {
91821
- resolve17({ raw: data });
91954
+ resolve18({ raw: data });
91822
91955
  }
91823
91956
  });
91824
91957
  });
@@ -91828,7 +91961,7 @@ function registerProviderCommands(program2) {
91828
91961
  }).catch(async () => {
91829
91962
  const pathMod = await import("path");
91830
91963
  const fsMod = await import("fs");
91831
- const loader = await createConfiguredProviderLoader();
91964
+ const loader = await createConfiguredProviderLoader2();
91832
91965
  let targetDir = location === "builtin" ? loader.getUpstreamProviderDir(category, type) : loader.getUserProviderDir(category, type);
91833
91966
  if (fsMod.existsSync(targetDir)) return { error: `Provider already exists at ${targetDir}` };
91834
91967
  const isExt = category === "extension";
@@ -91881,7 +92014,7 @@ function registerProviderCommands(program2) {
91881
92014
  try {
91882
92015
  const http3 = await import("http");
91883
92016
  const inquirer2 = (await Promise.resolve().then(() => (init_lib(), lib_exports))).default;
91884
- const loader = await createConfiguredProviderLoader();
92017
+ const loader = await createConfiguredProviderLoader2();
91885
92018
  const allProviders = loader.getAll();
91886
92019
  const fsMod = await import("fs");
91887
92020
  const isUserProvider = (p) => {
@@ -92012,7 +92145,7 @@ function registerProviderCommands(program2) {
92012
92145
  reference,
92013
92146
  ...verification ? { verification } : {}
92014
92147
  });
92015
- const startResult = await new Promise((resolve17, reject) => {
92148
+ const startResult = await new Promise((resolve18, reject) => {
92016
92149
  const req = http3.request({
92017
92150
  hostname: "127.0.0.1",
92018
92151
  port: DEV_SERVER_PORT3,
@@ -92024,9 +92157,9 @@ function registerProviderCommands(program2) {
92024
92157
  res.on("data", (c) => data += c);
92025
92158
  res.on("end", () => {
92026
92159
  try {
92027
- resolve17(JSON.parse(data));
92160
+ resolve18(JSON.parse(data));
92028
92161
  } catch {
92029
- resolve17({ raw: data });
92162
+ resolve18({ raw: data });
92030
92163
  }
92031
92164
  });
92032
92165
  });
@@ -92060,7 +92193,7 @@ function registerProviderCommands(program2) {
92060
92193
  fsMock.writeFileSync(logFile, `=== Auto-Impl Started ===
92061
92194
  `);
92062
92195
  console.log(source_default.gray(` Agent logs: ${logFile}`));
92063
- await new Promise((resolve17, reject) => {
92196
+ await new Promise((resolve18, reject) => {
92064
92197
  http3.get(`http://127.0.0.1:${DEV_SERVER_PORT3}${startResult.sseUrl}`, (res) => {
92065
92198
  let buffer = "";
92066
92199
  res.on("data", (chunk) => {
@@ -92097,7 +92230,7 @@ function registerProviderCommands(program2) {
92097
92230
  if (currentData.success === false) {
92098
92231
  reject(new Error(`Agent failed to implement scripts properly (exit: ${currentData.exitCode})`));
92099
92232
  } else {
92100
- resolve17();
92233
+ resolve18();
92101
92234
  }
92102
92235
  } else if (currentEvent === "error") {
92103
92236
  fsMock.appendFileSync(logFile, `
@@ -92108,7 +92241,7 @@ function registerProviderCommands(program2) {
92108
92241
  }
92109
92242
  }
92110
92243
  });
92111
- res.on("end", resolve17);
92244
+ res.on("end", resolve18);
92112
92245
  }).on("error", reject);
92113
92246
  });
92114
92247
  console.log(source_default.green(`
@@ -92167,7 +92300,7 @@ function registerProviderCommands(program2) {
92167
92300
  ideType: type,
92168
92301
  params: options.param ? { text: options.param, sessionId: options.param, buttonText: options.param } : {}
92169
92302
  });
92170
- const result = await new Promise((resolve17, reject) => {
92303
+ const result = await new Promise((resolve18, reject) => {
92171
92304
  const req = http3.request({
92172
92305
  hostname: "127.0.0.1",
92173
92306
  port: DEV_SERVER_PORT3,
@@ -92179,9 +92312,9 @@ function registerProviderCommands(program2) {
92179
92312
  res.on("data", (c) => data += c);
92180
92313
  res.on("end", () => {
92181
92314
  try {
92182
- resolve17(JSON.parse(data));
92315
+ resolve18(JSON.parse(data));
92183
92316
  } catch {
92184
- resolve17({ raw: data });
92317
+ resolve18({ raw: data });
92185
92318
  }
92186
92319
  });
92187
92320
  });
@@ -92217,15 +92350,15 @@ function registerProviderCommands(program2) {
92217
92350
  provider.command("source <type>").description("View source code of a provider").action(async (type) => {
92218
92351
  try {
92219
92352
  const http3 = await import("http");
92220
- const result = await new Promise((resolve17, reject) => {
92353
+ const result = await new Promise((resolve18, reject) => {
92221
92354
  http3.get(`http://127.0.0.1:${DEV_SERVER_PORT3}/api/providers/${type}/source`, (res) => {
92222
92355
  let data = "";
92223
92356
  res.on("data", (c) => data += c);
92224
92357
  res.on("end", () => {
92225
92358
  try {
92226
- resolve17(JSON.parse(data));
92359
+ resolve18(JSON.parse(data));
92227
92360
  } catch {
92228
- resolve17({ raw: data });
92361
+ resolve18({ raw: data });
92229
92362
  }
92230
92363
  });
92231
92364
  }).on("error", () => {
@@ -92234,7 +92367,7 @@ function registerProviderCommands(program2) {
92234
92367
  }).catch(async () => {
92235
92368
  const pathMod = await import("path");
92236
92369
  const fsMod = await import("fs");
92237
- const loader = await createConfiguredProviderLoader();
92370
+ const loader = await createConfiguredProviderLoader2();
92238
92371
  const providerMeta = loader.getMeta(type);
92239
92372
  if (!providerMeta) {
92240
92373
  return { error: `Provider '${type}' not found` };
@@ -92273,7 +92406,7 @@ function registerProviderCommands(program2) {
92273
92406
  try {
92274
92407
  const http3 = await import("http");
92275
92408
  const postData = JSON.stringify({ script: "readChat", params: {} });
92276
- const result = await new Promise((resolve17, reject) => {
92409
+ const result = await new Promise((resolve18, reject) => {
92277
92410
  const req = http3.request({
92278
92411
  hostname: "127.0.0.1",
92279
92412
  port: DEV_SERVER_PORT3,
@@ -92285,9 +92418,9 @@ function registerProviderCommands(program2) {
92285
92418
  res2.on("data", (c) => data += c);
92286
92419
  res2.on("end", () => {
92287
92420
  try {
92288
- resolve17(JSON.parse(data));
92421
+ resolve18(JSON.parse(data));
92289
92422
  } catch {
92290
- resolve17({ raw: data });
92423
+ resolve18({ raw: data });
92291
92424
  }
92292
92425
  });
92293
92426
  });
@@ -92528,13 +92661,13 @@ function registerCdpCommands(program2) {
92528
92661
  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
92662
  try {
92530
92663
  const http3 = await import("http");
92531
- const targets = await new Promise((resolve17, reject) => {
92664
+ const targets = await new Promise((resolve18, reject) => {
92532
92665
  http3.get(`http://127.0.0.1:${options.port}/json`, (res) => {
92533
92666
  let data = "";
92534
92667
  res.on("data", (c) => data += c);
92535
92668
  res.on("end", () => {
92536
92669
  try {
92537
- resolve17(JSON.parse(data));
92670
+ resolve18(JSON.parse(data));
92538
92671
  } catch {
92539
92672
  reject(new Error("Invalid JSON"));
92540
92673
  }
@@ -92548,7 +92681,7 @@ function registerCdpCommands(program2) {
92548
92681
  if (!target?.webSocketDebuggerUrl) throw new Error("No CDP target");
92549
92682
  const WebSocket4 = (await import("ws")).default;
92550
92683
  const ws = new WebSocket4(target.webSocketDebuggerUrl);
92551
- await new Promise((resolve17, reject) => {
92684
+ await new Promise((resolve18, reject) => {
92552
92685
  ws.on("open", () => {
92553
92686
  ws.send(JSON.stringify({ id: 1, method: "Page.captureScreenshot", params: { format: "jpeg", quality: 50 } }));
92554
92687
  });
@@ -92561,7 +92694,7 @@ function registerCdpCommands(program2) {
92561
92694
  \u2713 Screenshot saved to ${options.output}
92562
92695
  `));
92563
92696
  ws.close();
92564
- resolve17();
92697
+ resolve18();
92565
92698
  }
92566
92699
  });
92567
92700
  ws.on("error", (e) => reject(e));