pty-manager 1.9.4 → 1.9.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/dist/index.d.mts +10 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.js +41 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -1
- package/dist/index.mjs.map +1 -1
- package/dist/pty-worker.js +57 -4
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -744,6 +744,12 @@ declare class PTYSession extends EventEmitter {
|
|
|
744
744
|
/**
|
|
745
745
|
* Kill the PTY process
|
|
746
746
|
*/
|
|
747
|
+
/**
|
|
748
|
+
* Notify the session of an external hook event (e.g. from Claude Code HTTP hooks).
|
|
749
|
+
* Resets the stall timer so hook-managed sessions don't get false stall escalations.
|
|
750
|
+
* For "task_complete" events, transitions the session to ready.
|
|
751
|
+
*/
|
|
752
|
+
notifyHookEvent(event: string): void;
|
|
747
753
|
kill(signal?: string): void;
|
|
748
754
|
/**
|
|
749
755
|
* Get current output buffer
|
|
@@ -1164,6 +1170,10 @@ declare class BunCompatiblePTYManager extends EventEmitter {
|
|
|
1164
1170
|
* Send special keys to a session
|
|
1165
1171
|
*/
|
|
1166
1172
|
sendKeys(id: string, keys: string | string[]): Promise<void>;
|
|
1173
|
+
/**
|
|
1174
|
+
* Notify a session of an external hook event (resets stall timer, updates status).
|
|
1175
|
+
*/
|
|
1176
|
+
notifyHookEvent(id: string, hookEvent: string): Promise<void>;
|
|
1167
1177
|
/**
|
|
1168
1178
|
* Write raw data to a session (bypasses adapter formatting)
|
|
1169
1179
|
*/
|
package/dist/index.d.ts
CHANGED
|
@@ -744,6 +744,12 @@ declare class PTYSession extends EventEmitter {
|
|
|
744
744
|
/**
|
|
745
745
|
* Kill the PTY process
|
|
746
746
|
*/
|
|
747
|
+
/**
|
|
748
|
+
* Notify the session of an external hook event (e.g. from Claude Code HTTP hooks).
|
|
749
|
+
* Resets the stall timer so hook-managed sessions don't get false stall escalations.
|
|
750
|
+
* For "task_complete" events, transitions the session to ready.
|
|
751
|
+
*/
|
|
752
|
+
notifyHookEvent(event: string): void;
|
|
747
753
|
kill(signal?: string): void;
|
|
748
754
|
/**
|
|
749
755
|
* Get current output buffer
|
|
@@ -1164,6 +1170,10 @@ declare class BunCompatiblePTYManager extends EventEmitter {
|
|
|
1164
1170
|
* Send special keys to a session
|
|
1165
1171
|
*/
|
|
1166
1172
|
sendKeys(id: string, keys: string | string[]): Promise<void>;
|
|
1173
|
+
/**
|
|
1174
|
+
* Notify a session of an external hook event (resets stall timer, updates status).
|
|
1175
|
+
*/
|
|
1176
|
+
notifyHookEvent(id: string, hookEvent: string): Promise<void>;
|
|
1167
1177
|
/**
|
|
1168
1178
|
* Write raw data to a session (bypasses adapter formatting)
|
|
1169
1179
|
*/
|
package/dist/index.js
CHANGED
|
@@ -1044,7 +1044,8 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
|
|
|
1044
1044
|
if (this.adapter.detectBlockingPrompt) {
|
|
1045
1045
|
const detection = this.adapter.detectBlockingPrompt(this.outputBuffer);
|
|
1046
1046
|
if (detection.detected) {
|
|
1047
|
-
const
|
|
1047
|
+
const normalizedPrompt = (detection.prompt || "").replace(/\s+/g, " ").replace(/\d+/g, "#").trim().slice(0, 100);
|
|
1048
|
+
const promptHash = `${detection.type}:${normalizedPrompt}`;
|
|
1048
1049
|
if (promptHash === this._lastBlockingPromptHash) {
|
|
1049
1050
|
return true;
|
|
1050
1051
|
}
|
|
@@ -1403,6 +1404,37 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
|
|
|
1403
1404
|
/**
|
|
1404
1405
|
* Kill the PTY process
|
|
1405
1406
|
*/
|
|
1407
|
+
/**
|
|
1408
|
+
* Notify the session of an external hook event (e.g. from Claude Code HTTP hooks).
|
|
1409
|
+
* Resets the stall timer so hook-managed sessions don't get false stall escalations.
|
|
1410
|
+
* For "task_complete" events, transitions the session to ready.
|
|
1411
|
+
*/
|
|
1412
|
+
notifyHookEvent(event) {
|
|
1413
|
+
switch (event) {
|
|
1414
|
+
case "tool_running":
|
|
1415
|
+
this._lastActivityAt = /* @__PURE__ */ new Date();
|
|
1416
|
+
this.resetStallTimer();
|
|
1417
|
+
break;
|
|
1418
|
+
case "task_complete":
|
|
1419
|
+
this._status = "ready";
|
|
1420
|
+
this._lastBlockingPromptHash = null;
|
|
1421
|
+
this.outputBuffer = "";
|
|
1422
|
+
this.clearStallTimer();
|
|
1423
|
+
this.emit("status_changed", "ready");
|
|
1424
|
+
this.emit("task_complete");
|
|
1425
|
+
this.logger.info({ sessionId: this.id, event }, "Hook event: task_complete \u2192 ready");
|
|
1426
|
+
break;
|
|
1427
|
+
case "permission_approved":
|
|
1428
|
+
this._lastActivityAt = /* @__PURE__ */ new Date();
|
|
1429
|
+
this._lastBlockingPromptHash = null;
|
|
1430
|
+
this.resetStallTimer();
|
|
1431
|
+
break;
|
|
1432
|
+
default:
|
|
1433
|
+
this._lastActivityAt = /* @__PURE__ */ new Date();
|
|
1434
|
+
this.resetStallTimer();
|
|
1435
|
+
break;
|
|
1436
|
+
}
|
|
1437
|
+
}
|
|
1406
1438
|
kill(signal) {
|
|
1407
1439
|
if (this.ptyProcess) {
|
|
1408
1440
|
this._status = "stopping";
|
|
@@ -2756,6 +2788,14 @@ var BunCompatiblePTYManager = class extends import_events3.EventEmitter {
|
|
|
2756
2788
|
this.sendCommand({ cmd: "sendKeys", id, keys });
|
|
2757
2789
|
await this.createPending(`sendKeys:${id}`);
|
|
2758
2790
|
}
|
|
2791
|
+
/**
|
|
2792
|
+
* Notify a session of an external hook event (resets stall timer, updates status).
|
|
2793
|
+
*/
|
|
2794
|
+
async notifyHookEvent(id, hookEvent) {
|
|
2795
|
+
await this.waitForReady();
|
|
2796
|
+
this.sendCommand({ cmd: "notifyHookEvent", id, hookEvent });
|
|
2797
|
+
await this.createPending(`notifyHookEvent:${id}`);
|
|
2798
|
+
}
|
|
2759
2799
|
/**
|
|
2760
2800
|
* Write raw data to a session (bypasses adapter formatting)
|
|
2761
2801
|
*/
|