adhdev 0.5.31 → 0.5.33

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
@@ -23022,7 +23022,7 @@ var require_dist = __commonJS({
23022
23022
  LOG5.error("CLI", "[ProviderCliAdapter] node-pty not found. Terminal features disabled.");
23023
23023
  }
23024
23024
  function stripAnsi(str) {
23025
- return str.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "").replace(/\x1B\][^\x07]*\x07/g, "").replace(/\x1B\][^\x1B]*\x1B\\/g, "");
23025
+ return str.replace(/\x1B\[\d*[A-HJKSTfG]/g, " ").replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "").replace(/\x1B\][^\x07]*\x07/g, "").replace(/\x1B\][^\x1B]*\x1B\\/g, "").replace(/ +/g, " ");
23026
23026
  }
23027
23027
  function findBinary(name) {
23028
23028
  const isWin = os11.platform() === "win32";
@@ -23330,6 +23330,9 @@ var require_dist = __commonJS({
23330
23330
  }
23331
23331
  return;
23332
23332
  }
23333
+ if (cleanData.trim().length > 5) {
23334
+ LOG5.debug("CLI", `[${this.cliType}] output chunk (${cleanData.length}): ${cleanData.slice(0, 300).replace(/\n/g, "\\n")}`);
23335
+ }
23333
23336
  const hasApproval = patterns.approval.some((p) => p.test(this.recentOutputBuffer));
23334
23337
  if (hasApproval && this.currentStatus !== "waiting_approval") {
23335
23338
  const inCooldown = this.lastApprovalResolvedAt && Date.now() - this.lastApprovalResolvedAt < this.timeouts.approvalCooldown;
@@ -23606,6 +23609,7 @@ var require_dist = __commonJS({
23606
23609
  monitor;
23607
23610
  generatingDebounceTimer = null;
23608
23611
  generatingDebouncePending = null;
23612
+ lastApprovalEventAt = 0;
23609
23613
  historyWriter;
23610
23614
  instanceId;
23611
23615
  // ─── Lifecycle ─────────────────────────────────
@@ -23690,7 +23694,8 @@ var require_dist = __commonJS({
23690
23694
  this.adapter.shutdown();
23691
23695
  this.monitor.reset();
23692
23696
  }
23693
- // ─── Status transition detection (moved from daemon-status.ts) ──────
23697
+ completedDebounceTimer = null;
23698
+ completedDebouncePending = null;
23694
23699
  detectStatusTransition() {
23695
23700
  const now = Date.now();
23696
23701
  const adapterStatus = this.adapter.getStatus();
@@ -23700,7 +23705,15 @@ var require_dist = __commonJS({
23700
23705
  if (newStatus !== this.lastStatus) {
23701
23706
  LOG5.info("CLI", `[${this.type}] status: ${this.lastStatus} \u2192 ${newStatus}`);
23702
23707
  if (this.lastStatus === "idle" && newStatus === "generating") {
23703
- this.generatingStartedAt = now;
23708
+ if (this.completedDebouncePending) {
23709
+ LOG5.info("CLI", `[${this.type}] cancelled pending completed (resumed generating)`);
23710
+ if (this.completedDebounceTimer) {
23711
+ clearTimeout(this.completedDebounceTimer);
23712
+ this.completedDebounceTimer = null;
23713
+ }
23714
+ this.completedDebouncePending = null;
23715
+ }
23716
+ if (!this.generatingStartedAt) this.generatingStartedAt = now;
23704
23717
  if (this.generatingDebounceTimer) clearTimeout(this.generatingDebounceTimer);
23705
23718
  this.generatingDebouncePending = { chatTitle, timestamp: now };
23706
23719
  this.generatingDebounceTimer = setTimeout(() => {
@@ -23719,16 +23732,25 @@ var require_dist = __commonJS({
23719
23732
  this.pushEvent({ event: "agent:generating_started", ...this.generatingDebouncePending });
23720
23733
  this.generatingDebouncePending = null;
23721
23734
  }
23735
+ if (this.completedDebounceTimer) {
23736
+ clearTimeout(this.completedDebounceTimer);
23737
+ this.completedDebounceTimer = null;
23738
+ }
23739
+ this.completedDebouncePending = null;
23722
23740
  if (!this.generatingStartedAt) this.generatingStartedAt = now;
23723
23741
  const modal = adapterStatus.activeModal;
23724
23742
  LOG5.info("CLI", `[${this.type}] approval modal: "${modal?.message?.slice(0, 80) ?? "none"}"`);
23725
- this.pushEvent({
23726
- event: "agent:waiting_approval",
23727
- chatTitle,
23728
- timestamp: now,
23729
- modalMessage: modal?.message,
23730
- modalButtons: modal?.buttons
23731
- });
23743
+ const approvalCooldown = 5e3;
23744
+ if (this.lastStatus !== "waiting_approval" && (!this.lastApprovalEventAt || now - this.lastApprovalEventAt > approvalCooldown)) {
23745
+ this.lastApprovalEventAt = now;
23746
+ this.pushEvent({
23747
+ event: "agent:waiting_approval",
23748
+ chatTitle,
23749
+ timestamp: now,
23750
+ modalMessage: modal?.message,
23751
+ modalButtons: modal?.buttons
23752
+ });
23753
+ }
23732
23754
  } else if (newStatus === "idle" && (this.lastStatus === "generating" || this.lastStatus === "waiting_approval")) {
23733
23755
  const duration3 = this.generatingStartedAt ? Math.round((now - this.generatingStartedAt) / 1e3) : 0;
23734
23756
  if (this.generatingDebouncePending) {
@@ -23738,17 +23760,31 @@ var require_dist = __commonJS({
23738
23760
  this.generatingDebounceTimer = null;
23739
23761
  }
23740
23762
  this.generatingDebouncePending = null;
23763
+ this.generatingStartedAt = 0;
23741
23764
  } else {
23742
- LOG5.info("CLI", `[${this.type}] completed in ${duration3}s`);
23743
- this.pushEvent({ event: "agent:generating_completed", chatTitle, duration: duration3, timestamp: now });
23765
+ if (this.completedDebounceTimer) clearTimeout(this.completedDebounceTimer);
23766
+ this.completedDebouncePending = { chatTitle, duration: duration3, timestamp: now };
23767
+ this.completedDebounceTimer = setTimeout(() => {
23768
+ if (this.completedDebouncePending) {
23769
+ LOG5.info("CLI", `[${this.type}] completed in ${this.completedDebouncePending.duration}s`);
23770
+ this.pushEvent({ event: "agent:generating_completed", ...this.completedDebouncePending });
23771
+ this.completedDebouncePending = null;
23772
+ this.generatingStartedAt = 0;
23773
+ }
23774
+ this.completedDebounceTimer = null;
23775
+ }, 2e3);
23744
23776
  }
23745
- this.generatingStartedAt = 0;
23746
23777
  } else if (newStatus === "stopped") {
23747
23778
  if (this.generatingDebounceTimer) {
23748
23779
  clearTimeout(this.generatingDebounceTimer);
23749
23780
  this.generatingDebounceTimer = null;
23750
23781
  }
23751
23782
  this.generatingDebouncePending = null;
23783
+ if (this.completedDebounceTimer) {
23784
+ clearTimeout(this.completedDebounceTimer);
23785
+ this.completedDebounceTimer = null;
23786
+ }
23787
+ this.completedDebouncePending = null;
23752
23788
  this.pushEvent({ event: "agent:stopped", chatTitle, timestamp: now });
23753
23789
  }
23754
23790
  this.lastStatus = newStatus;
@@ -25135,7 +25171,8 @@ ${installInfo}`
25135
25171
  extensionId: this.extensionId,
25136
25172
  status: "error",
25137
25173
  messages: [],
25138
- inputContent: ""
25174
+ inputContent: "",
25175
+ _error: message
25139
25176
  };
25140
25177
  }
25141
25178
  };
@@ -25152,9 +25189,11 @@ ${installInfo}`
25152
25189
  if (providerLoader) {
25153
25190
  const allExtProviders = providerLoader.getByCategory("extension");
25154
25191
  for (const p of allExtProviders) {
25155
- const adapter = new ProviderStreamAdapter(p);
25192
+ const resolved = providerLoader.resolve(p.type);
25193
+ if (!resolved) continue;
25194
+ const adapter = new ProviderStreamAdapter(resolved);
25156
25195
  this.allAdapters.push(adapter);
25157
- this.logFn(`[AgentStream] Adapter created: ${p.type} (${p.name})`);
25196
+ this.logFn(`[AgentStream] Adapter created: ${p.type} (${p.name}) scripts=${Object.keys(resolved.scripts || {}).join(",") || "none"}`);
25158
25197
  }
25159
25198
  }
25160
25199
  }
@@ -25241,6 +25280,7 @@ ${installInfo}`
25241
25280
  try {
25242
25281
  const evaluate = (expr, timeout) => cdp.evaluateInSessionFrame(agent.sessionId, expr, timeout);
25243
25282
  const state = await agent.adapter.readChat(evaluate);
25283
+ this.logFn(`[AgentStream] readChat(${type}) result: status=${state.status} msgs=${state.messages?.length || 0} model=${state.model || ""}${state.status === "error" ? " error=" + JSON.stringify(state.error || state._error || "unknown") : ""}`);
25244
25284
  agent.lastState = state;
25245
25285
  agent.lastError = null;
25246
25286
  if (state.status === "panel_hidden") {
@@ -30282,7 +30322,7 @@ var init_adhdev_daemon = __esm({
30282
30322
  path2 = __toESM(require("path"));
30283
30323
  crypto2 = __toESM(require("crypto"));
30284
30324
  import_chalk = __toESM(require("chalk"));
30285
- pkgVersion = "0.5.31";
30325
+ pkgVersion = "0.5.33";
30286
30326
  if (pkgVersion === "unknown") {
30287
30327
  try {
30288
30328
  const possiblePaths = [