pty-manager 1.2.7 → 1.2.9
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 +3 -1
- package/dist/index.d.ts +3 -1
- package/dist/index.js +32 -17
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +32 -17
- package/dist/index.mjs.map +1 -1
- package/dist/pty-worker.js +32 -17
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -380,6 +380,7 @@ declare class PTYSession extends EventEmitter {
|
|
|
380
380
|
private messageCounter;
|
|
381
381
|
private logger;
|
|
382
382
|
private sessionRules;
|
|
383
|
+
private _lastBlockingPromptHash;
|
|
383
384
|
readonly id: string;
|
|
384
385
|
readonly config: SpawnConfig;
|
|
385
386
|
constructor(adapter: CLIAdapter, config: SpawnConfig, logger?: Logger);
|
|
@@ -418,7 +419,8 @@ declare class PTYSession extends EventEmitter {
|
|
|
418
419
|
*/
|
|
419
420
|
private setupEventHandlers;
|
|
420
421
|
/**
|
|
421
|
-
* Detect blocking prompts and handle them with auto-responses or user notification
|
|
422
|
+
* Detect blocking prompts and handle them with auto-responses or user notification.
|
|
423
|
+
* Deduplicates emissions - won't re-emit the same blocking prompt repeatedly.
|
|
422
424
|
*/
|
|
423
425
|
private detectAndHandleBlockingPrompt;
|
|
424
426
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -380,6 +380,7 @@ declare class PTYSession extends EventEmitter {
|
|
|
380
380
|
private messageCounter;
|
|
381
381
|
private logger;
|
|
382
382
|
private sessionRules;
|
|
383
|
+
private _lastBlockingPromptHash;
|
|
383
384
|
readonly id: string;
|
|
384
385
|
readonly config: SpawnConfig;
|
|
385
386
|
constructor(adapter: CLIAdapter, config: SpawnConfig, logger?: Logger);
|
|
@@ -418,7 +419,8 @@ declare class PTYSession extends EventEmitter {
|
|
|
418
419
|
*/
|
|
419
420
|
private setupEventHandlers;
|
|
420
421
|
/**
|
|
421
|
-
* Detect blocking prompts and handle them with auto-responses or user notification
|
|
422
|
+
* Detect blocking prompts and handle them with auto-responses or user notification.
|
|
423
|
+
* Deduplicates emissions - won't re-emit the same blocking prompt repeatedly.
|
|
422
424
|
*/
|
|
423
425
|
private detectAndHandleBlockingPrompt;
|
|
424
426
|
/**
|
package/dist/index.js
CHANGED
|
@@ -322,6 +322,7 @@ var PTYSession = class extends import_events.EventEmitter {
|
|
|
322
322
|
messageCounter = 0;
|
|
323
323
|
logger;
|
|
324
324
|
sessionRules = [];
|
|
325
|
+
_lastBlockingPromptHash = null;
|
|
325
326
|
id;
|
|
326
327
|
config;
|
|
327
328
|
get status() {
|
|
@@ -461,31 +462,36 @@ var PTYSession = class extends import_events.EventEmitter {
|
|
|
461
462
|
this._lastActivityAt = /* @__PURE__ */ new Date();
|
|
462
463
|
this.outputBuffer += data;
|
|
463
464
|
this.emit("output", data);
|
|
464
|
-
|
|
465
|
-
if (blockingPrompt) {
|
|
466
|
-
return;
|
|
467
|
-
}
|
|
468
|
-
const loginDetection = this.adapter.detectLogin(this.outputBuffer);
|
|
469
|
-
if (loginDetection.required && this._status !== "authenticating") {
|
|
470
|
-
this._status = "authenticating";
|
|
471
|
-
this.emit("login_required", loginDetection.instructions, loginDetection.url);
|
|
472
|
-
this.logger.warn(
|
|
473
|
-
{ sessionId: this.id, loginType: loginDetection.type },
|
|
474
|
-
"Login required"
|
|
475
|
-
);
|
|
476
|
-
return;
|
|
477
|
-
}
|
|
478
|
-
if (this._status === "starting" && this.adapter.detectReady(this.outputBuffer)) {
|
|
465
|
+
if ((this._status === "starting" || this._status === "authenticating") && this.adapter.detectReady(this.outputBuffer)) {
|
|
479
466
|
this._status = "ready";
|
|
467
|
+
this._lastBlockingPromptHash = null;
|
|
480
468
|
this.emit("ready");
|
|
481
469
|
this.logger.info({ sessionId: this.id }, "Session ready");
|
|
482
470
|
}
|
|
471
|
+
if (this._status !== "ready") {
|
|
472
|
+
const blockingPrompt = this.detectAndHandleBlockingPrompt();
|
|
473
|
+
if (blockingPrompt) {
|
|
474
|
+
return;
|
|
475
|
+
}
|
|
476
|
+
const loginDetection = this.adapter.detectLogin(this.outputBuffer);
|
|
477
|
+
if (loginDetection.required && this._status !== "authenticating") {
|
|
478
|
+
this._status = "authenticating";
|
|
479
|
+
this.emit("login_required", loginDetection.instructions, loginDetection.url);
|
|
480
|
+
this.logger.warn(
|
|
481
|
+
{ sessionId: this.id, loginType: loginDetection.type },
|
|
482
|
+
"Login required"
|
|
483
|
+
);
|
|
484
|
+
return;
|
|
485
|
+
}
|
|
486
|
+
}
|
|
483
487
|
const exitDetection = this.adapter.detectExit(this.outputBuffer);
|
|
484
488
|
if (exitDetection.exited) {
|
|
485
489
|
this._status = "stopped";
|
|
486
490
|
this.emit("exit", exitDetection.code || 0);
|
|
487
491
|
}
|
|
488
|
-
this.
|
|
492
|
+
if (this._status !== "starting" && this._status !== "authenticating") {
|
|
493
|
+
this.tryParseOutput();
|
|
494
|
+
}
|
|
489
495
|
});
|
|
490
496
|
this.ptyProcess.onExit(({ exitCode, signal }) => {
|
|
491
497
|
this._status = "stopped";
|
|
@@ -497,7 +503,8 @@ var PTYSession = class extends import_events.EventEmitter {
|
|
|
497
503
|
});
|
|
498
504
|
}
|
|
499
505
|
/**
|
|
500
|
-
* Detect blocking prompts and handle them with auto-responses or user notification
|
|
506
|
+
* Detect blocking prompts and handle them with auto-responses or user notification.
|
|
507
|
+
* Deduplicates emissions - won't re-emit the same blocking prompt repeatedly.
|
|
501
508
|
*/
|
|
502
509
|
detectAndHandleBlockingPrompt() {
|
|
503
510
|
const autoHandled = this.tryAutoResponse();
|
|
@@ -507,6 +514,11 @@ var PTYSession = class extends import_events.EventEmitter {
|
|
|
507
514
|
if (this.adapter.detectBlockingPrompt) {
|
|
508
515
|
const detection = this.adapter.detectBlockingPrompt(this.outputBuffer);
|
|
509
516
|
if (detection.detected) {
|
|
517
|
+
const promptHash = `${detection.type}:${detection.prompt || ""}`;
|
|
518
|
+
if (promptHash === this._lastBlockingPromptHash) {
|
|
519
|
+
return true;
|
|
520
|
+
}
|
|
521
|
+
this._lastBlockingPromptHash = promptHash;
|
|
510
522
|
const promptInfo = {
|
|
511
523
|
type: detection.type || "unknown",
|
|
512
524
|
prompt: detection.prompt,
|
|
@@ -525,6 +537,7 @@ var PTYSession = class extends import_events.EventEmitter {
|
|
|
525
537
|
"Auto-responding to blocking prompt"
|
|
526
538
|
);
|
|
527
539
|
this.writeRaw(detection.suggestedResponse + "\r");
|
|
540
|
+
this._lastBlockingPromptHash = null;
|
|
528
541
|
this.emit("blocking_prompt", promptInfo, true);
|
|
529
542
|
return true;
|
|
530
543
|
}
|
|
@@ -541,6 +554,8 @@ var PTYSession = class extends import_events.EventEmitter {
|
|
|
541
554
|
);
|
|
542
555
|
this.emit("blocking_prompt", promptInfo, false);
|
|
543
556
|
return true;
|
|
557
|
+
} else {
|
|
558
|
+
this._lastBlockingPromptHash = null;
|
|
544
559
|
}
|
|
545
560
|
}
|
|
546
561
|
return false;
|