pty-manager 1.9.5 → 1.9.7
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 -2
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +41 -2
- package/dist/index.mjs.map +1 -1
- package/dist/pty-worker.js +53 -2
- 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
|
}
|
|
@@ -1073,7 +1074,6 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
|
|
|
1073
1074
|
} else {
|
|
1074
1075
|
this.writeRaw(resp + "\r");
|
|
1075
1076
|
}
|
|
1076
|
-
this._lastBlockingPromptHash = null;
|
|
1077
1077
|
this.outputBuffer = "";
|
|
1078
1078
|
this.emit("blocking_prompt", promptInfo, true);
|
|
1079
1079
|
return true;
|
|
@@ -1403,6 +1403,37 @@ var PTYSession = class _PTYSession extends import_events.EventEmitter {
|
|
|
1403
1403
|
/**
|
|
1404
1404
|
* Kill the PTY process
|
|
1405
1405
|
*/
|
|
1406
|
+
/**
|
|
1407
|
+
* Notify the session of an external hook event (e.g. from Claude Code HTTP hooks).
|
|
1408
|
+
* Resets the stall timer so hook-managed sessions don't get false stall escalations.
|
|
1409
|
+
* For "task_complete" events, transitions the session to ready.
|
|
1410
|
+
*/
|
|
1411
|
+
notifyHookEvent(event) {
|
|
1412
|
+
switch (event) {
|
|
1413
|
+
case "tool_running":
|
|
1414
|
+
this._lastActivityAt = /* @__PURE__ */ new Date();
|
|
1415
|
+
this.resetStallTimer();
|
|
1416
|
+
break;
|
|
1417
|
+
case "task_complete":
|
|
1418
|
+
this._status = "ready";
|
|
1419
|
+
this._lastBlockingPromptHash = null;
|
|
1420
|
+
this.outputBuffer = "";
|
|
1421
|
+
this.clearStallTimer();
|
|
1422
|
+
this.emit("status_changed", "ready");
|
|
1423
|
+
this.emit("task_complete");
|
|
1424
|
+
this.logger.info({ sessionId: this.id, event }, "Hook event: task_complete \u2192 ready");
|
|
1425
|
+
break;
|
|
1426
|
+
case "permission_approved":
|
|
1427
|
+
this._lastActivityAt = /* @__PURE__ */ new Date();
|
|
1428
|
+
this.outputBuffer = "";
|
|
1429
|
+
this.resetStallTimer();
|
|
1430
|
+
break;
|
|
1431
|
+
default:
|
|
1432
|
+
this._lastActivityAt = /* @__PURE__ */ new Date();
|
|
1433
|
+
this.resetStallTimer();
|
|
1434
|
+
break;
|
|
1435
|
+
}
|
|
1436
|
+
}
|
|
1406
1437
|
kill(signal) {
|
|
1407
1438
|
if (this.ptyProcess) {
|
|
1408
1439
|
this._status = "stopping";
|
|
@@ -2756,6 +2787,14 @@ var BunCompatiblePTYManager = class extends import_events3.EventEmitter {
|
|
|
2756
2787
|
this.sendCommand({ cmd: "sendKeys", id, keys });
|
|
2757
2788
|
await this.createPending(`sendKeys:${id}`);
|
|
2758
2789
|
}
|
|
2790
|
+
/**
|
|
2791
|
+
* Notify a session of an external hook event (resets stall timer, updates status).
|
|
2792
|
+
*/
|
|
2793
|
+
async notifyHookEvent(id, hookEvent) {
|
|
2794
|
+
await this.waitForReady();
|
|
2795
|
+
this.sendCommand({ cmd: "notifyHookEvent", id, hookEvent });
|
|
2796
|
+
await this.createPending(`notifyHookEvent:${id}`);
|
|
2797
|
+
}
|
|
2759
2798
|
/**
|
|
2760
2799
|
* Write raw data to a session (bypasses adapter formatting)
|
|
2761
2800
|
*/
|