pty-manager 1.6.2 → 1.6.3

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.
@@ -331,6 +331,8 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
331
331
  _stallBackoffMs = 0;
332
332
  // Initialized in constructor from _stallTimeoutMs
333
333
  static MAX_STALL_BACKOFF_MS = 3e4;
334
+ _stallEmissionCount = 0;
335
+ static MAX_STALL_EMISSIONS = 5;
334
336
  // Task completion detection (idle detection when busy)
335
337
  _taskCompleteTimer = null;
336
338
  _taskCompletePending = false;
@@ -448,6 +450,7 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
448
450
  return;
449
451
  }
450
452
  this._lastContentHash = hash;
453
+ this._stallEmissionCount = 0;
451
454
  if (this._stallTimer) {
452
455
  clearTimeout(this._stallTimer);
453
456
  this._stallTimer = null;
@@ -470,6 +473,7 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
470
473
  this._stallStartedAt = null;
471
474
  this._lastContentHash = null;
472
475
  this._stallBackoffMs = this._stallTimeoutMs;
476
+ this._stallEmissionCount = 0;
473
477
  }
474
478
  /**
475
479
  * Called when the stall timer fires (no output for stallTimeoutMs).
@@ -506,6 +510,15 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
506
510
  );
507
511
  return;
508
512
  }
513
+ this._stallEmissionCount++;
514
+ if (this._stallEmissionCount > _PTYSession.MAX_STALL_EMISSIONS) {
515
+ this.logger.warn(
516
+ { sessionId: this.id, count: this._stallEmissionCount },
517
+ "Max stall emissions reached \u2014 suspending stall detection for this task"
518
+ );
519
+ this.clearStallTimer();
520
+ return;
521
+ }
509
522
  const recentRaw = this.outputBuffer.slice(-2e3);
510
523
  const recentOutput = this.stripAnsiForStall(recentRaw);
511
524
  const stallDurationMs = this._stallStartedAt ? Date.now() - this._stallStartedAt : this._stallTimeoutMs;
@@ -545,6 +558,8 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
545
558
  let result = str.replace(/\x1b\[\d*[CDABGdEF]/g, " ");
546
559
  result = result.replace(/\x1b\[\d*(?:;\d+)?[Hf]/g, " ");
547
560
  result = result.replace(/\x1b\[\d*[JK]/g, " ");
561
+ result = result.replace(/\x1b\](?:[^\x07\x1b]|\x1b[^\\])*(?:\x07|\x1b\\)/g, "");
562
+ result = result.replace(/\x1bP(?:[^\x1b]|\x1b[^\\])*\x1b\\/g, "");
548
563
  result = result.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
549
564
  result = result.replace(/[\x00-\x08\x0b-\x1f\x7f]/g, "");
550
565
  result = result.replace(/\xa0/g, " ");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "pty-manager",
3
- "version": "1.6.2",
3
+ "version": "1.6.3",
4
4
  "description": "PTY session manager with lifecycle management, pluggable adapters, and blocking prompt detection",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",