pty-manager 1.6.4 → 1.6.6

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/README.md CHANGED
@@ -217,7 +217,7 @@ interface SpawnConfig {
217
217
  timeout?: number; // Session timeout in ms
218
218
  readySettleMs?: number; // Override adapter's ready settle delay
219
219
  stallTimeoutMs?: number; // Override manager stall timeout for this session
220
- traceTaskCompletion?: boolean; // Verbose completion trace logs (auto-enabled for Claude)
220
+ traceTaskCompletion?: boolean; // Verbose completion trace logs (off by default)
221
221
  }
222
222
  ```
223
223
 
@@ -498,14 +498,13 @@ If the fast-path timer doesn't fire (e.g. the prompt indicator disappears from t
498
498
  - `debounce_reject_signal`
499
499
  - `transition_ready`
500
500
 
501
- By default, tracing is enabled for adapter type `claude`. You can override per session:
501
+ Tracing is off by default. Enable per session:
502
502
 
503
503
  ```typescript
504
504
  const handle = await manager.spawn({
505
505
  name: 'agent',
506
506
  type: 'claude',
507
- traceTaskCompletion: true, // force on
508
- // traceTaskCompletion: false, // force off
507
+ traceTaskCompletion: true,
509
508
  });
510
509
  ```
511
510
 
package/dist/index.d.mts CHANGED
@@ -41,7 +41,7 @@ interface SpawnConfig {
41
41
  * Ms of output silence after detectReady match before emitting session_ready. */
42
42
  readySettleMs?: number;
43
43
  /** Enable verbose task-completion trace logs.
44
- * If unset, PTYSession enables this automatically for adapter type "claude". */
44
+ * Disabled by default; set true to enable. */
45
45
  traceTaskCompletion?: boolean;
46
46
  /** Override or disable specific adapter auto-response rules for this session.
47
47
  * Keys are regex source strings (from rule.pattern.source).
@@ -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.
@@ -557,7 +563,7 @@ declare class PTYSession extends EventEmitter {
557
563
  private isTaskCompleteSignal;
558
564
  /**
559
565
  * Claude-oriented task completion traces for PTY debugging.
560
- * Enabled by config.traceTaskCompletion, otherwise defaults to enabled for Claude.
566
+ * Disabled by default; enable via config.traceTaskCompletion.
561
567
  */
562
568
  private traceTaskCompletion;
563
569
  private shouldTraceTaskCompletion;
package/dist/index.d.ts CHANGED
@@ -41,7 +41,7 @@ interface SpawnConfig {
41
41
  * Ms of output silence after detectReady match before emitting session_ready. */
42
42
  readySettleMs?: number;
43
43
  /** Enable verbose task-completion trace logs.
44
- * If unset, PTYSession enables this automatically for adapter type "claude". */
44
+ * Disabled by default; set true to enable. */
45
45
  traceTaskCompletion?: boolean;
46
46
  /** Override or disable specific adapter auto-response rules for this session.
47
47
  * Keys are regex source strings (from rule.pattern.source).
@@ -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.
@@ -557,7 +563,7 @@ declare class PTYSession extends EventEmitter {
557
563
  private isTaskCompleteSignal;
558
564
  /**
559
565
  * Claude-oriented task completion traces for PTY debugging.
560
- * Enabled by config.traceTaskCompletion, otherwise defaults to enabled for Claude.
566
+ * Disabled by default; enable via config.traceTaskCompletion.
561
567
  */
562
568
  private traceTaskCompletion;
563
569
  private shouldTraceTaskCompletion;
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.
@@ -710,7 +735,7 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
710
735
  }
711
736
  /**
712
737
  * Claude-oriented task completion traces for PTY debugging.
713
- * Enabled by config.traceTaskCompletion, otherwise defaults to enabled for Claude.
738
+ * Disabled by default; enable via config.traceTaskCompletion.
714
739
  */
715
740
  traceTaskCompletion(event, ctx = {}) {
716
741
  if (!this.shouldTraceTaskCompletion()) return;
@@ -739,10 +764,7 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
739
764
  );
740
765
  }
741
766
  shouldTraceTaskCompletion() {
742
- if (typeof this.config.traceTaskCompletion === "boolean") {
743
- return this.config.traceTaskCompletion;
744
- }
745
- return this.adapter.adapterType === "claude";
767
+ return this.config.traceTaskCompletion === true;
746
768
  }
747
769
  /**
748
770
  * Cancel a pending task_complete timer (new output arrived that
@@ -925,7 +947,7 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
925
947
  this.clearStallTimer();
926
948
  this.emit("exit", exitDetection.code || 0);
927
949
  }
928
- if (this._status !== "starting" && this._status !== "authenticating") {
950
+ if (this._status === "ready") {
929
951
  this.tryParseOutput();
930
952
  }
931
953
  }