pty-manager 1.11.0 → 1.12.0

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 CHANGED
@@ -419,7 +419,13 @@ interface PTYSessionEvents {
419
419
  error: (error: Error) => void;
420
420
  stall_detected: (recentOutput: string, stallDurationMs: number) => void;
421
421
  status_changed: (status: SessionStatus) => void;
422
- task_complete: () => void;
422
+ /**
423
+ * Fired when the agent's turn completes. `output` is the session's
424
+ * output buffer captured just before it is cleared for the next turn —
425
+ * consumers must use this payload rather than `getOutputBuffer()`,
426
+ * which is already empty by the time the event fires.
427
+ */
428
+ task_complete: (output: string) => void;
423
429
  tool_running: (info: ToolRunningInfo) => void;
424
430
  }
425
431
  /**
@@ -731,7 +737,12 @@ interface PTYManagerEvents {
731
737
  question: (session: SessionHandle, question: string) => void;
732
738
  stall_detected: (session: SessionHandle, recentOutput: string, stallDurationMs: number) => void;
733
739
  session_status_changed: (session: SessionHandle) => void;
734
- task_complete: (session: SessionHandle) => void;
740
+ /**
741
+ * Fired when a session's turn completes. `output` is the turn's output
742
+ * buffer captured before the session cleared it — use it instead of
743
+ * `getSession(id).getOutputBuffer()`, which is already empty here.
744
+ */
745
+ task_complete: (session: SessionHandle, output: string) => void;
735
746
  tool_running: (session: SessionHandle, info: ToolRunningInfo) => void;
736
747
  }
737
748
  declare class PTYManager extends EventEmitter {
package/dist/index.d.ts CHANGED
@@ -419,7 +419,13 @@ interface PTYSessionEvents {
419
419
  error: (error: Error) => void;
420
420
  stall_detected: (recentOutput: string, stallDurationMs: number) => void;
421
421
  status_changed: (status: SessionStatus) => void;
422
- task_complete: () => void;
422
+ /**
423
+ * Fired when the agent's turn completes. `output` is the session's
424
+ * output buffer captured just before it is cleared for the next turn —
425
+ * consumers must use this payload rather than `getOutputBuffer()`,
426
+ * which is already empty by the time the event fires.
427
+ */
428
+ task_complete: (output: string) => void;
423
429
  tool_running: (info: ToolRunningInfo) => void;
424
430
  }
425
431
  /**
@@ -731,7 +737,12 @@ interface PTYManagerEvents {
731
737
  question: (session: SessionHandle, question: string) => void;
732
738
  stall_detected: (session: SessionHandle, recentOutput: string, stallDurationMs: number) => void;
733
739
  session_status_changed: (session: SessionHandle) => void;
734
- task_complete: (session: SessionHandle) => void;
740
+ /**
741
+ * Fired when a session's turn completes. `output` is the turn's output
742
+ * buffer captured before the session cleared it — use it instead of
743
+ * `getSession(id).getOutputBuffer()`, which is already empty here.
744
+ */
745
+ task_complete: (session: SessionHandle, output: string) => void;
735
746
  tool_running: (session: SessionHandle, info: ToolRunningInfo) => void;
736
747
  }
737
748
  declare class PTYManager extends EventEmitter {
package/dist/index.js CHANGED
@@ -359,7 +359,7 @@ var BunCompatiblePTYManager = class extends import_node_events.EventEmitter {
359
359
  if (session) {
360
360
  session.status = "ready";
361
361
  session.lastActivityAt = /* @__PURE__ */ new Date();
362
- this.emit("task_complete", session);
362
+ this.emit("task_complete", session, event.output ?? "");
363
363
  }
364
364
  break;
365
365
  }
@@ -1074,6 +1074,7 @@ var PTYSession = class _PTYSession extends import_node_events2.EventEmitter {
1074
1074
  }
1075
1075
  }
1076
1076
  }
1077
+ adapter;
1077
1078
  ptyProcess = null;
1078
1079
  outputBuffer = "";
1079
1080
  _status = "pending";
@@ -1254,13 +1255,14 @@ var PTYSession = class _PTYSession extends import_node_events2.EventEmitter {
1254
1255
  return;
1255
1256
  }
1256
1257
  if (this._status === "busy" && this.adapter.detectTaskComplete?.(this.outputBuffer)) {
1258
+ const turnOutput = this.outputBuffer;
1257
1259
  this._status = "ready";
1258
1260
  this._lastBlockingPromptHash = null;
1259
1261
  this._lastBlockingPromptEmitAt = 0;
1260
1262
  this.outputBuffer = "";
1261
1263
  this.clearStallTimer();
1262
1264
  this.emit("status_changed", "ready");
1263
- this.emit("task_complete");
1265
+ this.emit("task_complete", turnOutput);
1264
1266
  this.logger.info(
1265
1267
  { sessionId: this.id },
1266
1268
  "Task complete (adapter fast-path) \u2014 agent returned to idle prompt"
@@ -1560,13 +1562,14 @@ var PTYSession = class _PTYSession extends import_node_events2.EventEmitter {
1560
1562
  this.traceTaskCompletion("debounce_reject_signal", { signal });
1561
1563
  return;
1562
1564
  }
1565
+ const turnOutput = this.outputBuffer;
1563
1566
  this._status = "ready";
1564
1567
  this._lastBlockingPromptHash = null;
1565
1568
  this._lastBlockingPromptEmitAt = 0;
1566
1569
  this.outputBuffer = "";
1567
1570
  this.clearStallTimer();
1568
1571
  this.emit("status_changed", "ready");
1569
- this.emit("task_complete");
1572
+ this.emit("task_complete", turnOutput);
1570
1573
  this.traceTaskCompletion("transition_ready", { signal: true });
1571
1574
  this.logger.info(
1572
1575
  { sessionId: this.id },
@@ -2227,19 +2230,21 @@ var PTYSession = class _PTYSession extends import_node_events2.EventEmitter {
2227
2230
  this._lastActivityAt = /* @__PURE__ */ new Date();
2228
2231
  this.resetStallTimer();
2229
2232
  break;
2230
- case "task_complete":
2233
+ case "task_complete": {
2234
+ const turnOutput = this.outputBuffer;
2231
2235
  this._status = "ready";
2232
2236
  this._lastBlockingPromptHash = null;
2233
2237
  this._lastBlockingPromptEmitAt = 0;
2234
2238
  this.outputBuffer = "";
2235
2239
  this.clearStallTimer();
2236
2240
  this.emit("status_changed", "ready");
2237
- this.emit("task_complete");
2241
+ this.emit("task_complete", turnOutput);
2238
2242
  this.logger.info(
2239
2243
  { sessionId: this.id, event },
2240
2244
  "Hook event: task_complete \u2192 ready"
2241
2245
  );
2242
2246
  break;
2247
+ }
2243
2248
  case "permission_approved":
2244
2249
  this._lastActivityAt = /* @__PURE__ */ new Date();
2245
2250
  this.outputBuffer = "";
@@ -2396,8 +2401,8 @@ var PTYManager = class extends import_node_events3.EventEmitter {
2396
2401
  session.on("status_changed", () => {
2397
2402
  this.emit("session_status_changed", session.toHandle());
2398
2403
  });
2399
- session.on("task_complete", () => {
2400
- this.emit("task_complete", session.toHandle());
2404
+ session.on("task_complete", (output) => {
2405
+ this.emit("task_complete", session.toHandle(), output);
2401
2406
  });
2402
2407
  session.on("tool_running", (info) => {
2403
2408
  this.emit("tool_running", session.toHandle(), info);