pty-manager 1.6.4 → 1.6.5

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.d.mts CHANGED
@@ -535,6 +535,12 @@ declare class PTYSession extends EventEmitter {
535
535
  * word boundaries — e.g. "Do\x1b[5Cyou" becomes "Do you", not "Doyou".
536
536
  */
537
537
  private stripAnsiForStall;
538
+ /**
539
+ * Less-aggressive ANSI stripping for classifier context.
540
+ * Preserves visible TUI symbols (e.g. ❯, ✻) and durations while removing
541
+ * escape/control sequences so the classifier keeps useful evidence.
542
+ */
543
+ private stripAnsiForClassifier;
538
544
  /**
539
545
  * Handle external stall classification result.
540
546
  * Called by the manager after onStallClassify resolves.
package/dist/index.d.ts CHANGED
@@ -535,6 +535,12 @@ declare class PTYSession extends EventEmitter {
535
535
  * word boundaries — e.g. "Do\x1b[5Cyou" becomes "Do you", not "Doyou".
536
536
  */
537
537
  private stripAnsiForStall;
538
+ /**
539
+ * Less-aggressive ANSI stripping for classifier context.
540
+ * Preserves visible TUI symbols (e.g. ❯, ✻) and durations while removing
541
+ * escape/control sequences so the classifier keeps useful evidence.
542
+ */
543
+ private stripAnsiForClassifier;
538
544
  /**
539
545
  * Handle external stall classification result.
540
546
  * Called by the manager after onStallClassify resolves.
package/dist/index.js CHANGED
@@ -463,8 +463,10 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
463
463
  return;
464
464
  }
465
465
  const stripped = this.stripAnsiForStall(this.outputBuffer).trim();
466
+ const visible = this.stripAnsiForClassifier(this.outputBuffer).trim();
466
467
  const tail = stripped.slice(-500);
467
- const hash = this.simpleHash(tail);
468
+ const fallbackTail = visible.slice(-500);
469
+ const hash = this.simpleHash(tail || fallbackTail);
468
470
  if (hash === this._lastContentHash) {
469
471
  return;
470
472
  }
@@ -539,10 +541,16 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
539
541
  return;
540
542
  }
541
543
  const recentRaw = this.outputBuffer.slice(-2e3);
542
- const recentOutput = this.stripAnsiForStall(recentRaw);
544
+ const recentOutput = this.stripAnsiForClassifier(recentRaw).trim();
543
545
  const stallDurationMs = this._stallStartedAt ? Date.now() - this._stallStartedAt : this._stallTimeoutMs;
544
546
  this.logger.debug(
545
- { sessionId: this.id, stallDurationMs, bufferTailLength: tail.length },
547
+ {
548
+ sessionId: this.id,
549
+ stallDurationMs,
550
+ bufferTailLength: tail.length,
551
+ recentOutputLength: recentOutput.length,
552
+ recentOutputHash: this.simpleHash(recentOutput.slice(-500))
553
+ },
546
554
  "Stall detected"
547
555
  );
548
556
  this.emit("stall_detected", recentOutput, stallDurationMs);
@@ -587,6 +595,23 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
587
595
  result = result.replace(/ {2,}/g, " ");
588
596
  return result;
589
597
  }
598
+ /**
599
+ * Less-aggressive ANSI stripping for classifier context.
600
+ * Preserves visible TUI symbols (e.g. ❯, ✻) and durations while removing
601
+ * escape/control sequences so the classifier keeps useful evidence.
602
+ */
603
+ stripAnsiForClassifier(str) {
604
+ let result = str.replace(/\x1b\[\d*[CDABGdEF]/g, " ");
605
+ result = result.replace(/\x1b\[\d*(?:;\d+)?[Hf]/g, " ");
606
+ result = result.replace(/\x1b\[\d*[JK]/g, " ");
607
+ result = result.replace(/\x1b\](?:[^\x07\x1b]|\x1b[^\\])*(?:\x07|\x1b\\)/g, "");
608
+ result = result.replace(/\x1bP(?:[^\x1b]|\x1b[^\\])*\x1b\\/g, "");
609
+ result = result.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
610
+ result = result.replace(/[\x00-\x08\x0b-\x1f\x7f]/g, "");
611
+ result = result.replace(/\xa0/g, " ");
612
+ result = result.replace(/ {2,}/g, " ");
613
+ return result;
614
+ }
590
615
  /**
591
616
  * Handle external stall classification result.
592
617
  * Called by the manager after onStallClassify resolves.
@@ -925,7 +950,7 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
925
950
  this.clearStallTimer();
926
951
  this.emit("exit", exitDetection.code || 0);
927
952
  }
928
- if (this._status !== "starting" && this._status !== "authenticating") {
953
+ if (this._status === "ready") {
929
954
  this.tryParseOutput();
930
955
  }
931
956
  }