pty-manager 1.6.6 → 1.6.8

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
@@ -37,6 +37,12 @@ sudo apt-get install build-essential
37
37
  npm install --global windows-build-tools
38
38
  ```
39
39
 
40
+ On some platforms, `node-pty`'s prebuilt `spawn-helper` binary may lack execute permissions after install. If you see `EACCES` errors when spawning sessions, fix with:
41
+
42
+ ```bash
43
+ chmod +x node_modules/node-pty/build/Release/spawn-helper
44
+ ```
45
+
40
46
  ## Quick Start
41
47
 
42
48
  ```typescript
package/dist/index.js CHANGED
@@ -97,6 +97,7 @@ var AdapterRegistry = class {
97
97
 
98
98
  // src/pty-session.ts
99
99
  var import_events = require("events");
100
+ var import_crypto = require("crypto");
100
101
  var ptyCache = null;
101
102
  function loadPty() {
102
103
  if (!ptyCache) {
@@ -141,7 +142,7 @@ var consoleLogger = {
141
142
  }
142
143
  };
143
144
  function generateId() {
144
- return `pty-${Date.now()}-${Math.random().toString(36).slice(2, 11)}`;
145
+ return `pty-${Date.now()}-${(0, import_crypto.randomUUID)().slice(0, 8)}`;
145
146
  }
146
147
  var SPECIAL_KEYS = {
147
148
  // Control keys (Ctrl+letter = ASCII control code)
@@ -999,6 +1000,7 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
999
1000
  }
1000
1001
  if (detection.type === "login") {
1001
1002
  this._status = "authenticating";
1003
+ this.emit("login_required", detection.instructions, detection.url);
1002
1004
  }
1003
1005
  this.logger.warn(
1004
1006
  {
@@ -1417,7 +1419,8 @@ var PTYManager = class extends import_events2.EventEmitter {
1417
1419
  const handle = session.toHandle();
1418
1420
  this.emit("stall_detected", handle, recentOutput, stallDurationMs);
1419
1421
  if (this._onStallClassify) {
1420
- this._onStallClassify(session.id, recentOutput, stallDurationMs).then((classification) => {
1422
+ const sanitized = recentOutput.slice(-1500).replace(/\b(ignore|disregard|forget)\s+(all\s+)?(previous|above|prior)\s+(instructions?|prompts?|rules?)\b/gi, "[REDACTED]").replace(/\b(you\s+are|act\s+as|pretend\s+to\s+be|you\s+must|system\s*:)\b/gi, "[REDACTED]");
1423
+ this._onStallClassify(session.id, sanitized, stallDurationMs).then((classification) => {
1421
1424
  session.handleStallClassification(classification);
1422
1425
  }).catch((err) => {
1423
1426
  this.logger.error(
@@ -1446,6 +1449,7 @@ var PTYManager = class extends import_events2.EventEmitter {
1446
1449
  }, timeout);
1447
1450
  session.once("exit", () => {
1448
1451
  clearTimeout(timer);
1452
+ session.removeAllListeners();
1449
1453
  this.sessions.delete(sessionId);
1450
1454
  this.outputLogs.delete(sessionId);
1451
1455
  resolve();