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.
- package/dist/index.d.mts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +18 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +18 -1
- package/dist/index.mjs.map +1 -1
- package/dist/pty-worker.js +15 -0
- package/package.json +1 -1
package/dist/index.mjs
CHANGED
|
@@ -310,6 +310,8 @@ var PTYSession = class _PTYSession extends EventEmitter {
|
|
|
310
310
|
_stallBackoffMs = 0;
|
|
311
311
|
// Initialized in constructor from _stallTimeoutMs
|
|
312
312
|
static MAX_STALL_BACKOFF_MS = 3e4;
|
|
313
|
+
_stallEmissionCount = 0;
|
|
314
|
+
static MAX_STALL_EMISSIONS = 5;
|
|
313
315
|
// Task completion detection (idle detection when busy)
|
|
314
316
|
_taskCompleteTimer = null;
|
|
315
317
|
_taskCompletePending = false;
|
|
@@ -427,6 +429,7 @@ var PTYSession = class _PTYSession extends EventEmitter {
|
|
|
427
429
|
return;
|
|
428
430
|
}
|
|
429
431
|
this._lastContentHash = hash;
|
|
432
|
+
this._stallEmissionCount = 0;
|
|
430
433
|
if (this._stallTimer) {
|
|
431
434
|
clearTimeout(this._stallTimer);
|
|
432
435
|
this._stallTimer = null;
|
|
@@ -449,6 +452,7 @@ var PTYSession = class _PTYSession extends EventEmitter {
|
|
|
449
452
|
this._stallStartedAt = null;
|
|
450
453
|
this._lastContentHash = null;
|
|
451
454
|
this._stallBackoffMs = this._stallTimeoutMs;
|
|
455
|
+
this._stallEmissionCount = 0;
|
|
452
456
|
}
|
|
453
457
|
/**
|
|
454
458
|
* Called when the stall timer fires (no output for stallTimeoutMs).
|
|
@@ -485,6 +489,15 @@ var PTYSession = class _PTYSession extends EventEmitter {
|
|
|
485
489
|
);
|
|
486
490
|
return;
|
|
487
491
|
}
|
|
492
|
+
this._stallEmissionCount++;
|
|
493
|
+
if (this._stallEmissionCount > _PTYSession.MAX_STALL_EMISSIONS) {
|
|
494
|
+
this.logger.warn(
|
|
495
|
+
{ sessionId: this.id, count: this._stallEmissionCount },
|
|
496
|
+
"Max stall emissions reached \u2014 suspending stall detection for this task"
|
|
497
|
+
);
|
|
498
|
+
this.clearStallTimer();
|
|
499
|
+
return;
|
|
500
|
+
}
|
|
488
501
|
const recentRaw = this.outputBuffer.slice(-2e3);
|
|
489
502
|
const recentOutput = this.stripAnsiForStall(recentRaw);
|
|
490
503
|
const stallDurationMs = this._stallStartedAt ? Date.now() - this._stallStartedAt : this._stallTimeoutMs;
|
|
@@ -524,6 +537,8 @@ var PTYSession = class _PTYSession extends EventEmitter {
|
|
|
524
537
|
let result = str.replace(/\x1b\[\d*[CDABGdEF]/g, " ");
|
|
525
538
|
result = result.replace(/\x1b\[\d*(?:;\d+)?[Hf]/g, " ");
|
|
526
539
|
result = result.replace(/\x1b\[\d*[JK]/g, " ");
|
|
540
|
+
result = result.replace(/\x1b\](?:[^\x07\x1b]|\x1b[^\\])*(?:\x07|\x1b\\)/g, "");
|
|
541
|
+
result = result.replace(/\x1bP(?:[^\x1b]|\x1b[^\\])*\x1b\\/g, "");
|
|
527
542
|
result = result.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
|
|
528
543
|
result = result.replace(/[\x00-\x08\x0b-\x1f\x7f]/g, "");
|
|
529
544
|
result = result.replace(/\xa0/g, " ");
|
|
@@ -1761,7 +1776,9 @@ var BaseCLIAdapter = class {
|
|
|
1761
1776
|
*/
|
|
1762
1777
|
stripAnsi(str) {
|
|
1763
1778
|
const withSpaces = str.replace(/\x1b\[\d*C/g, " ");
|
|
1764
|
-
|
|
1779
|
+
const withoutOsc = withSpaces.replace(/\x1b\](?:[^\x07\x1b]|\x1b[^\\])*(?:\x07|\x1b\\)/g, "");
|
|
1780
|
+
const withoutDcs = withoutOsc.replace(/\x1bP(?:[^\x1b]|\x1b[^\\])*\x1b\\/g, "");
|
|
1781
|
+
return withoutDcs.replace(/\x1B(?:[@-Z\\-_]|\[[0-?]*[ -/]*[@-~])/g, "");
|
|
1765
1782
|
}
|
|
1766
1783
|
};
|
|
1767
1784
|
|