pty-manager 1.2.22 → 1.3.0

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.mjs CHANGED
@@ -448,6 +448,19 @@ var PTYSession = class _PTYSession extends EventEmitter {
448
448
  return;
449
449
  }
450
450
  this._lastStallHash = hash;
451
+ if (this._status === "busy" && this.adapter.detectTaskComplete?.(this.outputBuffer)) {
452
+ this._status = "ready";
453
+ this._lastBlockingPromptHash = null;
454
+ this.outputBuffer = "";
455
+ this.clearStallTimer();
456
+ this.emit("status_changed", "ready");
457
+ this.emit("task_complete");
458
+ this.logger.info(
459
+ { sessionId: this.id },
460
+ "Task complete (adapter fast-path) \u2014 agent returned to idle prompt"
461
+ );
462
+ return;
463
+ }
451
464
  const recentRaw = this.outputBuffer.slice(-2e3);
452
465
  const recentOutput = this.stripAnsiForStall(recentRaw);
453
466
  const stallDurationMs = this._stallStartedAt ? Date.now() - this._stallStartedAt : this._stallTimeoutMs;
@@ -1556,6 +1569,14 @@ var BaseCLIAdapter = class {
1556
1569
  }
1557
1570
  return { detected: false };
1558
1571
  }
1572
+ /**
1573
+ * Default task completion detection — delegates to detectReady().
1574
+ * Subclasses should override to match high-confidence completion patterns
1575
+ * (e.g. duration summaries) that short-circuit the LLM stall classifier.
1576
+ */
1577
+ detectTaskComplete(output) {
1578
+ return this.detectReady(output);
1579
+ }
1559
1580
  /**
1560
1581
  * Default input formatting - just return as-is
1561
1582
  */