adhdev 0.5.58 → 0.5.61

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/index.js CHANGED
@@ -19054,11 +19054,35 @@ var require_dist = __commonJS({
19054
19054
  }
19055
19055
  this.autoApproveBusy = true;
19056
19056
  try {
19057
- const script = scriptFn({ action: "approve", button: "", buttonText: "" });
19057
+ let targetButton = _chatData?.activeModal?.buttons?.[0] || "Run";
19058
+ const buttons = _chatData?.activeModal?.buttons || [];
19059
+ for (const b of buttons) {
19060
+ const lower = String(b).toLowerCase().replace(/[^\w]/g, "");
19061
+ if (/^(run|approve|accept|yes|allow|always|proceed|save)/.test(lower)) {
19062
+ targetButton = b;
19063
+ break;
19064
+ }
19065
+ }
19066
+ const script = scriptFn({ action: "approve", button: targetButton, buttonText: targetButton });
19058
19067
  if (!script) return;
19059
- LOG5.info("IdeInstance", `[IdeInstance:${this.type}] autoApprove: executing resolveAction`);
19060
- const result = await cdp.evaluate(script, 1e4);
19068
+ LOG5.info("IdeInstance", `[IdeInstance:${this.type}] autoApprove: executing resolveAction for "${targetButton}"`);
19069
+ let rawResult = await cdp.evaluate(script, 1e4);
19070
+ if (typeof rawResult === "string") {
19071
+ try {
19072
+ rawResult = JSON.parse(rawResult);
19073
+ } catch {
19074
+ }
19075
+ }
19076
+ const result = rawResult;
19061
19077
  LOG5.info("IdeInstance", `[IdeInstance:${this.type}] autoApprove result: ${JSON.stringify(result)?.slice(0, 200)}`);
19078
+ if (result?.found && result.x != null && result.y != null) {
19079
+ const x = result.x;
19080
+ const y = result.y;
19081
+ const anyCdp = cdp;
19082
+ await anyCdp.send("Input.dispatchMouseEvent", { type: "mousePressed", x, y, button: "left", clickCount: 1 });
19083
+ await anyCdp.send("Input.dispatchMouseEvent", { type: "mouseReleased", x, y, button: "left", clickCount: 1 });
19084
+ LOG5.info("IdeInstance", `[IdeInstance:${this.type}] autoApprove: dispatched mouse event at ${x},${y}`);
19085
+ }
19062
19086
  this.pushEvent({
19063
19087
  event: "agent:auto_approved",
19064
19088
  chatTitle: _chatData?.title || this.provider.name,
@@ -19070,7 +19094,7 @@ var require_dist = __commonJS({
19070
19094
  } finally {
19071
19095
  setTimeout(() => {
19072
19096
  this.autoApproveBusy = false;
19073
- }, 500);
19097
+ }, 1e3);
19074
19098
  }
19075
19099
  }
19076
19100
  };
@@ -19650,13 +19674,23 @@ var require_dist = __commonJS({
19650
19674
  if (!text) return { success: false, error: "text required" };
19651
19675
  const _log = (msg) => LOG5.debug("Command", `[send_chat] ${msg}`);
19652
19676
  const provider = h.getProvider();
19677
+ const _logSendSuccess = (method, targetAgent) => {
19678
+ h.historyWriter.appendNewMessages(
19679
+ targetAgent || provider?.type || h.currentIdeType || "unknown_agent",
19680
+ [{ role: "user", content: text, receivedAt: Date.now() }],
19681
+ void 0,
19682
+ // title
19683
+ args?.instanceId
19684
+ );
19685
+ return { success: true, sent: true, method, targetAgent };
19686
+ };
19653
19687
  if (provider?.category === "cli" || provider?.category === "acp") {
19654
19688
  const adapter = h.getCliAdapter(provider.type);
19655
19689
  if (adapter) {
19656
19690
  _log(`${provider.category} adapter: ${adapter.cliType}`);
19657
19691
  try {
19658
19692
  await adapter.sendMessage(text);
19659
- return { success: true, sent: true, method: `${provider.category}-adapter`, targetAgent: adapter.cliType };
19693
+ return _logSendSuccess(`${provider.category}-adapter`, adapter.cliType);
19660
19694
  } catch (e) {
19661
19695
  return { success: false, error: `${provider.category} send failed: ${e.message}` };
19662
19696
  }
@@ -19676,7 +19710,7 @@ var require_dist = __commonJS({
19676
19710
  }
19677
19711
  if (parsed?.sent) {
19678
19712
  _log(`Extension script sent OK`);
19679
- return { success: true, sent: true, method: "extension-script" };
19713
+ return _logSendSuccess("extension-script");
19680
19714
  }
19681
19715
  if (parsed?.needsTypeAndSend) {
19682
19716
  _log(`Extension needsTypeAndSend \u2192 AgentStreamManager`);
@@ -19689,7 +19723,7 @@ var require_dist = __commonJS({
19689
19723
  const ok = await h.agentStream.sendToAgent(h.getCdp(), provider.type, text, h.currentIdeType);
19690
19724
  if (ok) {
19691
19725
  _log(`AgentStreamManager sent OK`);
19692
- return { success: true, sent: true, method: "agent-stream" };
19726
+ return _logSendSuccess("agent-stream");
19693
19727
  }
19694
19728
  }
19695
19729
  return { success: false, error: `Extension '${provider.type}' send failed` };
@@ -19716,7 +19750,7 @@ var require_dist = __commonJS({
19716
19750
  }
19717
19751
  if (wvParsed?.sent) {
19718
19752
  _log(`webviewSendMessage (priority) OK`);
19719
- return { success: true, sent: true, method: "webview-script-priority" };
19753
+ return _logSendSuccess("webview-script-priority");
19720
19754
  }
19721
19755
  _log(`webviewSendMessage (priority) did not confirm sent, falling through`);
19722
19756
  }
@@ -19729,7 +19763,7 @@ var require_dist = __commonJS({
19729
19763
  const sent = await targetCdp.typeAndSend(provider.inputSelector, text);
19730
19764
  if (sent) {
19731
19765
  _log(`typeAndSend(provider.inputSelector=${provider.inputSelector}) success`);
19732
- return { success: true, sent: true, method: "typeAndSend-provider" };
19766
+ return _logSendSuccess("typeAndSend-provider");
19733
19767
  }
19734
19768
  } catch (e) {
19735
19769
  _log(`typeAndSend(provider) failed: ${e.message}`);
@@ -19748,14 +19782,14 @@ var require_dist = __commonJS({
19748
19782
  }
19749
19783
  if (parsed?.sent) {
19750
19784
  _log(`sendMessage script OK`);
19751
- return { success: true, sent: true, method: "script" };
19785
+ return _logSendSuccess("script");
19752
19786
  }
19753
19787
  if (parsed?.needsTypeAndSend && parsed?.selector) {
19754
19788
  try {
19755
19789
  const sent = await targetCdp.typeAndSend(parsed.selector, text);
19756
19790
  if (sent) {
19757
19791
  _log(`typeAndSend(script.selector=${parsed.selector}) success`);
19758
- return { success: true, sent: true, method: "typeAndSend-script" };
19792
+ return _logSendSuccess("typeAndSend-script");
19759
19793
  }
19760
19794
  } catch (e) {
19761
19795
  _log(`typeAndSend(script.selector) failed: ${e.message}`);
@@ -19777,7 +19811,7 @@ var require_dist = __commonJS({
19777
19811
  }
19778
19812
  if (wvParsed?.sent) {
19779
19813
  _log(`webviewSendMessage OK`);
19780
- return { success: true, sent: true, method: "webview-script" };
19814
+ return _logSendSuccess("webview-script");
19781
19815
  }
19782
19816
  }
19783
19817
  } catch (e) {
@@ -19790,7 +19824,7 @@ var require_dist = __commonJS({
19790
19824
  const sent = await targetCdp.typeAndSendAt(x, y, text);
19791
19825
  if (sent) {
19792
19826
  _log(`typeAndSendAt(${x},${y}) success`);
19793
- return { success: true, sent: true, method: "typeAndSendAt-script" };
19827
+ return _logSendSuccess("typeAndSendAt-script");
19794
19828
  }
19795
19829
  } catch (e) {
19796
19830
  _log(`typeAndSendAt failed: ${e.message}`);
@@ -21216,6 +21250,8 @@ var require_dist = __commonJS({
21216
21250
  }
21217
21251
  async handleRefreshScripts(_args) {
21218
21252
  if (this._ctx.providerLoader) {
21253
+ await this._ctx.providerLoader.fetchLatest().catch(() => {
21254
+ });
21219
21255
  this._ctx.providerLoader.reload();
21220
21256
  return { success: true };
21221
21257
  }
@@ -23242,13 +23278,12 @@ var require_dist = __commonJS({
23242
23278
  /Always\s*allow/i,
23243
23279
  /\(y\/n\)/i,
23244
23280
  /\[Y\/n\]/i,
23245
- /Run\s*this\s*command/i,
23246
- /Allow\s*tool/i,
23247
- // Claude Code v2 approval
23281
+ /Run\s+\w+\s+command/i,
23282
+ // "Run bash command" etc — requires surrounding words to avoid false matches
23248
23283
  /Yes,?\s*don'?t\s*ask/i,
23249
23284
  // "Yes, don't ask again" (Claude Code)
23250
- /Deny/i
23251
- // Deny button presence = approval dialog
23285
+ /\bDeny\b/i
23286
+ // Word-boundary match avoids "allow & deny" in /permissions menu text
23252
23287
  ];
23253
23288
  function defaultCleanOutput(raw, _lastUserInput) {
23254
23289
  return stripAnsi(raw).trim();
@@ -23277,7 +23312,7 @@ var require_dist = __commonJS({
23277
23312
  this.timeouts = {
23278
23313
  ptyFlush: t.ptyFlush ?? 50,
23279
23314
  dialogAccept: t.dialogAccept ?? 300,
23280
- approvalCooldown: t.approvalCooldown ?? 500,
23315
+ approvalCooldown: t.approvalCooldown ?? 3e3,
23281
23316
  generatingIdle: t.generatingIdle ?? 6e3,
23282
23317
  idleFinish: t.idleFinish ?? 5e3,
23283
23318
  maxResponse: t.maxResponse ?? 3e5,
@@ -30462,7 +30497,7 @@ var init_adhdev_daemon = __esm({
30462
30497
  fs2 = __toESM(require("fs"));
30463
30498
  path2 = __toESM(require("path"));
30464
30499
  import_chalk = __toESM(require("chalk"));
30465
- pkgVersion = "0.5.58";
30500
+ pkgVersion = "0.5.61";
30466
30501
  if (pkgVersion === "unknown") {
30467
30502
  try {
30468
30503
  const possiblePaths = [