pty-manager 1.10.2 → 1.11.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 +39 -0
- package/dist/index.d.ts +39 -0
- package/dist/index.js +62 -0
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +62 -0
- package/dist/index.mjs.map +1 -1
- package/dist/pty-worker.js +48 -0
- package/package.json +1 -1
package/dist/index.d.mts
CHANGED
|
@@ -312,6 +312,21 @@ declare class BunCompatiblePTYManager extends EventEmitter {
|
|
|
312
312
|
* Check if a session exists
|
|
313
313
|
*/
|
|
314
314
|
has(id: string): boolean;
|
|
315
|
+
/**
|
|
316
|
+
* Whether the adapter currently classifies the session as actively
|
|
317
|
+
* processing work.
|
|
318
|
+
*
|
|
319
|
+
* This round-trips to the worker since the adapter lives in the
|
|
320
|
+
* worker process. Orchestrators (like milady's swarm idle watchdog)
|
|
321
|
+
* should consult this before assuming a session is idle based on
|
|
322
|
+
* output byte diffs — TUIs that redraw their status row in place
|
|
323
|
+
* (Codex's "Working… esc to interrupt") can fool a raw text diff
|
|
324
|
+
* even while the model is actively reasoning.
|
|
325
|
+
*
|
|
326
|
+
* Returns `false` for unknown sessions, adapters that don't
|
|
327
|
+
* implement `detectLoading`, or on IPC errors.
|
|
328
|
+
*/
|
|
329
|
+
isSessionLoading(id: string): Promise<boolean>;
|
|
315
330
|
/**
|
|
316
331
|
* Subscribe to output from a specific session
|
|
317
332
|
*/
|
|
@@ -536,6 +551,18 @@ declare class PTYSession extends EventEmitter {
|
|
|
536
551
|
* signal before transitioning, so stale triggers are safe.
|
|
537
552
|
*/
|
|
538
553
|
private scheduleTaskComplete;
|
|
554
|
+
/**
|
|
555
|
+
* Whether the adapter's `detectLoading()` currently classifies the
|
|
556
|
+
* session as actively processing work.
|
|
557
|
+
*
|
|
558
|
+
* This wraps `adapter.detectLoading(outputBuffer)` for consumers outside
|
|
559
|
+
* the PTY layer (e.g. milady's swarm idle watchdog) that need a
|
|
560
|
+
* reliable "is the agent busy right now?" signal without reimplementing
|
|
561
|
+
* heuristics over raw terminal output.
|
|
562
|
+
*
|
|
563
|
+
* Returns `false` if the adapter does not implement `detectLoading`.
|
|
564
|
+
*/
|
|
565
|
+
isLoading(): boolean;
|
|
539
566
|
/**
|
|
540
567
|
* Adapter-level task completion check with compatibility fallback.
|
|
541
568
|
* Prefer detectTaskComplete() because detectReady() may be broad for TUIs.
|
|
@@ -780,6 +807,18 @@ declare class PTYManager extends EventEmitter {
|
|
|
780
807
|
* Get the underlying PTYSession (for advanced use)
|
|
781
808
|
*/
|
|
782
809
|
getSession(sessionId: string): PTYSession | undefined;
|
|
810
|
+
/**
|
|
811
|
+
* Whether the adapter currently classifies the session as actively
|
|
812
|
+
* processing work (e.g. Codex's "esc to interrupt" status row).
|
|
813
|
+
*
|
|
814
|
+
* Orchestrators (like milady's swarm idle watchdog) should consult
|
|
815
|
+
* this before assuming a session is idle based on output byte diffs,
|
|
816
|
+
* which are fooled by TUIs that redraw the same status row in place.
|
|
817
|
+
*
|
|
818
|
+
* Returns `false` for unknown sessions or adapters that don't
|
|
819
|
+
* implement `detectLoading`.
|
|
820
|
+
*/
|
|
821
|
+
isSessionLoading(sessionId: string): boolean;
|
|
783
822
|
/**
|
|
784
823
|
* Configure stall detection at runtime.
|
|
785
824
|
* Affects newly spawned sessions only — existing sessions keep their config.
|
package/dist/index.d.ts
CHANGED
|
@@ -312,6 +312,21 @@ declare class BunCompatiblePTYManager extends EventEmitter {
|
|
|
312
312
|
* Check if a session exists
|
|
313
313
|
*/
|
|
314
314
|
has(id: string): boolean;
|
|
315
|
+
/**
|
|
316
|
+
* Whether the adapter currently classifies the session as actively
|
|
317
|
+
* processing work.
|
|
318
|
+
*
|
|
319
|
+
* This round-trips to the worker since the adapter lives in the
|
|
320
|
+
* worker process. Orchestrators (like milady's swarm idle watchdog)
|
|
321
|
+
* should consult this before assuming a session is idle based on
|
|
322
|
+
* output byte diffs — TUIs that redraw their status row in place
|
|
323
|
+
* (Codex's "Working… esc to interrupt") can fool a raw text diff
|
|
324
|
+
* even while the model is actively reasoning.
|
|
325
|
+
*
|
|
326
|
+
* Returns `false` for unknown sessions, adapters that don't
|
|
327
|
+
* implement `detectLoading`, or on IPC errors.
|
|
328
|
+
*/
|
|
329
|
+
isSessionLoading(id: string): Promise<boolean>;
|
|
315
330
|
/**
|
|
316
331
|
* Subscribe to output from a specific session
|
|
317
332
|
*/
|
|
@@ -536,6 +551,18 @@ declare class PTYSession extends EventEmitter {
|
|
|
536
551
|
* signal before transitioning, so stale triggers are safe.
|
|
537
552
|
*/
|
|
538
553
|
private scheduleTaskComplete;
|
|
554
|
+
/**
|
|
555
|
+
* Whether the adapter's `detectLoading()` currently classifies the
|
|
556
|
+
* session as actively processing work.
|
|
557
|
+
*
|
|
558
|
+
* This wraps `adapter.detectLoading(outputBuffer)` for consumers outside
|
|
559
|
+
* the PTY layer (e.g. milady's swarm idle watchdog) that need a
|
|
560
|
+
* reliable "is the agent busy right now?" signal without reimplementing
|
|
561
|
+
* heuristics over raw terminal output.
|
|
562
|
+
*
|
|
563
|
+
* Returns `false` if the adapter does not implement `detectLoading`.
|
|
564
|
+
*/
|
|
565
|
+
isLoading(): boolean;
|
|
539
566
|
/**
|
|
540
567
|
* Adapter-level task completion check with compatibility fallback.
|
|
541
568
|
* Prefer detectTaskComplete() because detectReady() may be broad for TUIs.
|
|
@@ -780,6 +807,18 @@ declare class PTYManager extends EventEmitter {
|
|
|
780
807
|
* Get the underlying PTYSession (for advanced use)
|
|
781
808
|
*/
|
|
782
809
|
getSession(sessionId: string): PTYSession | undefined;
|
|
810
|
+
/**
|
|
811
|
+
* Whether the adapter currently classifies the session as actively
|
|
812
|
+
* processing work (e.g. Codex's "esc to interrupt" status row).
|
|
813
|
+
*
|
|
814
|
+
* Orchestrators (like milady's swarm idle watchdog) should consult
|
|
815
|
+
* this before assuming a session is idle based on output byte diffs,
|
|
816
|
+
* which are fooled by TUIs that redraw the same status row in place.
|
|
817
|
+
*
|
|
818
|
+
* Returns `false` for unknown sessions or adapters that don't
|
|
819
|
+
* implement `detectLoading`.
|
|
820
|
+
*/
|
|
821
|
+
isSessionLoading(sessionId: string): boolean;
|
|
783
822
|
/**
|
|
784
823
|
* Configure stall detection at runtime.
|
|
785
824
|
* Affects newly spawned sessions only — existing sessions keep their config.
|
package/dist/index.js
CHANGED
|
@@ -405,6 +405,13 @@ var BunCompatiblePTYManager = class extends import_node_events.EventEmitter {
|
|
|
405
405
|
this.resolvePending("list", sessions);
|
|
406
406
|
break;
|
|
407
407
|
}
|
|
408
|
+
case "isSessionLoading": {
|
|
409
|
+
this.resolvePending(
|
|
410
|
+
`isSessionLoading:${id}`,
|
|
411
|
+
Boolean(event.loading)
|
|
412
|
+
);
|
|
413
|
+
break;
|
|
414
|
+
}
|
|
408
415
|
case "rules": {
|
|
409
416
|
const serializedRules = event.rules;
|
|
410
417
|
const rules = serializedRules.map((r) => ({
|
|
@@ -566,6 +573,33 @@ var BunCompatiblePTYManager = class extends import_node_events.EventEmitter {
|
|
|
566
573
|
has(id) {
|
|
567
574
|
return this.sessions.has(id);
|
|
568
575
|
}
|
|
576
|
+
/**
|
|
577
|
+
* Whether the adapter currently classifies the session as actively
|
|
578
|
+
* processing work.
|
|
579
|
+
*
|
|
580
|
+
* This round-trips to the worker since the adapter lives in the
|
|
581
|
+
* worker process. Orchestrators (like milady's swarm idle watchdog)
|
|
582
|
+
* should consult this before assuming a session is idle based on
|
|
583
|
+
* output byte diffs — TUIs that redraw their status row in place
|
|
584
|
+
* (Codex's "Working… esc to interrupt") can fool a raw text diff
|
|
585
|
+
* even while the model is actively reasoning.
|
|
586
|
+
*
|
|
587
|
+
* Returns `false` for unknown sessions, adapters that don't
|
|
588
|
+
* implement `detectLoading`, or on IPC errors.
|
|
589
|
+
*/
|
|
590
|
+
async isSessionLoading(id) {
|
|
591
|
+
if (!this.sessions.has(id)) return false;
|
|
592
|
+
await this.waitForReady();
|
|
593
|
+
this.sendCommand({ cmd: "isSessionLoading", id });
|
|
594
|
+
try {
|
|
595
|
+
const result = await this.createPending(
|
|
596
|
+
`isSessionLoading:${id}`
|
|
597
|
+
);
|
|
598
|
+
return Boolean(result);
|
|
599
|
+
} catch {
|
|
600
|
+
return false;
|
|
601
|
+
}
|
|
602
|
+
}
|
|
569
603
|
/**
|
|
570
604
|
* Subscribe to output from a specific session
|
|
571
605
|
*/
|
|
@@ -1540,6 +1574,20 @@ var PTYSession = class _PTYSession extends import_node_events2.EventEmitter {
|
|
|
1540
1574
|
);
|
|
1541
1575
|
}, _PTYSession.TASK_COMPLETE_DEBOUNCE_MS);
|
|
1542
1576
|
}
|
|
1577
|
+
/**
|
|
1578
|
+
* Whether the adapter's `detectLoading()` currently classifies the
|
|
1579
|
+
* session as actively processing work.
|
|
1580
|
+
*
|
|
1581
|
+
* This wraps `adapter.detectLoading(outputBuffer)` for consumers outside
|
|
1582
|
+
* the PTY layer (e.g. milady's swarm idle watchdog) that need a
|
|
1583
|
+
* reliable "is the agent busy right now?" signal without reimplementing
|
|
1584
|
+
* heuristics over raw terminal output.
|
|
1585
|
+
*
|
|
1586
|
+
* Returns `false` if the adapter does not implement `detectLoading`.
|
|
1587
|
+
*/
|
|
1588
|
+
isLoading() {
|
|
1589
|
+
return this.adapter.detectLoading?.(this.outputBuffer) ?? false;
|
|
1590
|
+
}
|
|
1543
1591
|
/**
|
|
1544
1592
|
* Adapter-level task completion check with compatibility fallback.
|
|
1545
1593
|
* Prefer detectTaskComplete() because detectReady() may be broad for TUIs.
|
|
@@ -2556,6 +2604,20 @@ var PTYManager = class extends import_node_events3.EventEmitter {
|
|
|
2556
2604
|
getSession(sessionId) {
|
|
2557
2605
|
return this.sessions.get(sessionId);
|
|
2558
2606
|
}
|
|
2607
|
+
/**
|
|
2608
|
+
* Whether the adapter currently classifies the session as actively
|
|
2609
|
+
* processing work (e.g. Codex's "esc to interrupt" status row).
|
|
2610
|
+
*
|
|
2611
|
+
* Orchestrators (like milady's swarm idle watchdog) should consult
|
|
2612
|
+
* this before assuming a session is idle based on output byte diffs,
|
|
2613
|
+
* which are fooled by TUIs that redraw the same status row in place.
|
|
2614
|
+
*
|
|
2615
|
+
* Returns `false` for unknown sessions or adapters that don't
|
|
2616
|
+
* implement `detectLoading`.
|
|
2617
|
+
*/
|
|
2618
|
+
isSessionLoading(sessionId) {
|
|
2619
|
+
return this.sessions.get(sessionId)?.isLoading() ?? false;
|
|
2620
|
+
}
|
|
2559
2621
|
// ─────────────────────────────────────────────────────────────────────────────
|
|
2560
2622
|
// Stall Detection Configuration
|
|
2561
2623
|
// ─────────────────────────────────────────────────────────────────────────────
|