adhdev 0.5.41 → 0.5.43

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
@@ -18386,9 +18386,9 @@ var require_dist = __commonJS({
18386
18386
  approvalAlert: true,
18387
18387
  longGeneratingAlert: true,
18388
18388
  longGeneratingThresholdSec: 180,
18389
- // 3minutes
18389
+ // 3 minutes
18390
18390
  alertCooldownSec: 60
18391
- // 1minutes cooldown
18391
+ // 1 minute cooldown
18392
18392
  };
18393
18393
  var StatusMonitor = class {
18394
18394
  config;
@@ -18397,18 +18397,18 @@ var require_dist = __commonJS({
18397
18397
  constructor(config2) {
18398
18398
  this.config = { ...DEFAULT_MONITOR_CONFIG, ...config2 };
18399
18399
  }
18400
- /** Config update (called from Provider Settings) */
18400
+ /** Update config (called from Provider Settings) */
18401
18401
  updateConfig(partial2) {
18402
18402
  Object.assign(this.config, partial2);
18403
18403
  }
18404
- /** current config return */
18404
+ /** Return current config */
18405
18405
  getConfig() {
18406
18406
  return { ...this.config };
18407
18407
  }
18408
18408
  /**
18409
- * Check status transition → return notification event array
18410
- * each onTick()from call.
18411
- */
18409
+ * Check status transition → return notification event array.
18410
+ * Called from each onTick() or detectStatusTransition().
18411
+ */
18412
18412
  check(agentKey, status, now) {
18413
18413
  const events = [];
18414
18414
  if (this.config.approvalAlert && status === "waiting_approval") {
@@ -18706,7 +18706,7 @@ var require_dist = __commonJS({
18706
18706
  if (sanitizedInstance) {
18707
18707
  return f.startsWith(`${sanitizedInstance}_`);
18708
18708
  }
18709
- return !f.includes("_") || f.match(/^\d{4}-\d{2}-\d{2}\.jsonl$/);
18709
+ return true;
18710
18710
  }).sort().reverse();
18711
18711
  const allMessages = [];
18712
18712
  const needed = offset + limit + 1;
@@ -18747,6 +18747,7 @@ var require_dist = __commonJS({
18747
18747
  tickBusy = false;
18748
18748
  monitor;
18749
18749
  historyWriter;
18750
+ autoApproveBusy = false;
18750
18751
  // IDE meta
18751
18752
  ideVersion = "";
18752
18753
  instanceId;
@@ -19021,6 +19022,9 @@ var require_dist = __commonJS({
19021
19022
  }
19022
19023
  this.lastAgentStatuses.set(agentKey, agentStatus);
19023
19024
  }
19025
+ if (agentStatus === "waiting_approval" && this.settings.autoApprove && !this.autoApproveBusy) {
19026
+ this.autoApproveViaScript(chatData);
19027
+ }
19024
19028
  const monitorEvents = this.monitor.check(agentKey, agentStatus, now);
19025
19029
  for (const me of monitorEvents) {
19026
19030
  this.pushEvent({ event: me.type, agentKey: me.agentKey, message: me.message, elapsedSec: me.elapsedSec, timestamp: me.timestamp });
@@ -19039,6 +19043,36 @@ var require_dist = __commonJS({
19039
19043
  updateCdp(cdp) {
19040
19044
  if (this.context) this.context.cdp = cdp;
19041
19045
  }
19046
+ // ─── Auto-approve via CDP script ────────────────────
19047
+ async autoApproveViaScript(_chatData) {
19048
+ const cdp = this.context?.cdp;
19049
+ if (!cdp?.isConnected) return;
19050
+ const scriptFn = this.provider.scripts?.resolveAction;
19051
+ if (typeof scriptFn !== "function") {
19052
+ LOG5.debug("IdeInstance", `[IdeInstance:${this.type}] autoApprove: no resolveAction script available`);
19053
+ return;
19054
+ }
19055
+ this.autoApproveBusy = true;
19056
+ try {
19057
+ const script = scriptFn({ action: "approve", button: "", buttonText: "" });
19058
+ if (!script) return;
19059
+ LOG5.info("IdeInstance", `[IdeInstance:${this.type}] autoApprove: executing resolveAction`);
19060
+ const result = await cdp.evaluate(script, 1e4);
19061
+ LOG5.info("IdeInstance", `[IdeInstance:${this.type}] autoApprove result: ${JSON.stringify(result)?.slice(0, 200)}`);
19062
+ this.pushEvent({
19063
+ event: "agent:auto_approved",
19064
+ chatTitle: _chatData?.title || this.provider.name,
19065
+ timestamp: Date.now(),
19066
+ ideType: this.type
19067
+ });
19068
+ } catch (e) {
19069
+ LOG5.warn("IdeInstance", `[IdeInstance:${this.type}] autoApprove error: ${e?.message}`);
19070
+ } finally {
19071
+ setTimeout(() => {
19072
+ this.autoApproveBusy = false;
19073
+ }, 500);
19074
+ }
19075
+ }
19042
19076
  };
19043
19077
  function registerExtensionProviders(providerLoader, manager, ideType) {
19044
19078
  const enabledExtProviders = providerLoader.getEnabledExtensionProviders(ideType).map((p) => ({
@@ -30428,7 +30462,7 @@ var init_adhdev_daemon = __esm({
30428
30462
  fs2 = __toESM(require("fs"));
30429
30463
  path2 = __toESM(require("path"));
30430
30464
  import_chalk = __toESM(require("chalk"));
30431
- pkgVersion = "0.5.41";
30465
+ pkgVersion = "0.5.43";
30432
30466
  if (pkgVersion === "unknown") {
30433
30467
  try {
30434
30468
  const possiblePaths = [