11/**
2- * Bounded waits during a live turn, so a stalled agent says so instead of leaving the
3- * panel on a progress line forever. Two independent deadlines:
4- * - "first event": nothing has streamed back since the message was sent.
5- * - "tool pending": a single tool call has stayed pending too long.
6- * Both drive the same live-error affordance the SDK's own errors use (`turn-error.ts`),
7- * and both clear the moment the condition they're watching changes — including late
8- * recovery after they've already fired.
2+ * Bounded waits during a live turn: "first event" (nothing streamed yet) and "tool
3+ * pending" (one tool call stuck). Both clear the moment the watched condition changes.
94 */
105
116export const FIRST_EVENT_DEADLINE_MS = 45_000 ;
@@ -14,9 +9,8 @@ export const TOOL_PENDING_DEADLINE_MS = 120_000;
149export type TurnDeadlineError = { kind : "first-event" } | { kind : "tool-pending" ; tool : string } ;
1510
1611/**
17- * The tool-pending deadline's key: null unless a turn is actually live. A dangling
18- * `input-available` part on an idle chat — a stopped turn, a reload of old history — is
19- * not a pending call, and arming a timer for it would fire with nothing able to clear it.
12+ * Null unless a turn is live. A dangling `input-available` part on an idle chat isn't a
13+ * pending call, and arming a timer for it would fire with nothing able to clear it.
2014 */
2115export function activeToolPendingKey ( status : string , inFlightTool : string | null ) : string | null {
2216 const inFlight = status === "streaming" || status === "submitted" ;
@@ -51,9 +45,8 @@ export type KeyedDeadline<K extends string> = {
5145} ;
5246
5347/**
54- * Watches one condition across successive `sync` calls: the timer starts the moment `sync`
55- * sees a key it wasn't already watching, fires `onTimeout` if that same key is still active
56- * after `deadlineMs`, and clears (`onClear`) whenever the key changes away, fired or not.
48+ * Timer starts when `sync` sees a new key, fires `onTimeout` if it's still active after
49+ * `deadlineMs`, and clears (`onClear`) whenever the key changes away, fired or not.
5750 */
5851export function createKeyedDeadline < K extends string > (
5952 options : KeyedDeadlineOptions < K >
0 commit comments