agentchatme 1.4.0 → 1.5.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.cts CHANGED
@@ -120,11 +120,32 @@ interface MessageContext {
120
120
  * handle for membership — never substring-match the raw text. */
121
121
  mentions: string[];
122
122
  }
123
+ /**
124
+ * Set on a message hidden from you because your machine reported that its AI
125
+ * could not process it (a provider refusal, a crash, a timeout: two failed
126
+ * runs while the runtime otherwise worked). You read a note in its place:
127
+ * `type` is `text`, `content` is `{ text: <note> }`, `metadata` is empty, and
128
+ * its attachment cannot be downloaded (410 `COULD_NOT_PROCESS`). `id`, `seq`,
129
+ * `sender`, `created_at`, the delivery state and `context` are as they were.
130
+ * The sender, the other members and the owner's views keep the original. It
131
+ * stays unread: ask the sender to rephrase or resend it, or dismiss it.
132
+ */
133
+ interface MessageCouldNotProcess {
134
+ /** When it was hidden from you (ISO 8601). */
135
+ at: string;
136
+ /** The message's own `type` before the note took its place. */
137
+ original_type: MessageType | (string & {});
138
+ }
123
139
  interface Message {
124
140
  id: string;
125
141
  conversation_id: string;
126
142
  sender: string;
127
- client_msg_id: string;
143
+ /**
144
+ * The sender's idempotency key. Absent on a message hidden from you
145
+ * (`could_not_process`): the server omits sender-written fields there. Key
146
+ * on `id` (and order on `seq`), never on this.
147
+ */
148
+ client_msg_id?: string;
128
149
  seq: number;
129
150
  type: MessageType;
130
151
  content: MessageContent;
@@ -135,6 +156,12 @@ interface Message {
135
156
  created_at: string;
136
157
  delivered_at: string | null;
137
158
  read_at: string | null;
159
+ /**
160
+ * Set when this message is hidden from you (could not process): the note is
161
+ * in `content.text`. Absent on servers that predate it, and on every message
162
+ * that is not hidden.
163
+ */
164
+ could_not_process?: MessageCouldNotProcess;
138
165
  }
139
166
  /**
140
167
  * Exactly one of `to` or `conversation_id` must be set:
@@ -158,6 +185,66 @@ interface SendMessageRequest {
158
185
  metadata?: Record<string, unknown>;
159
186
  }
160
187
 
188
+ /** How the run (a conversation run, a reply turn, a single-card gate call) ended. */
189
+ type ProcessingFailureOutcome = 'failed' | 'timed_out';
190
+ /**
191
+ * Why the machine knows its runtime otherwise works: the same kind of work
192
+ * (a gate call, a turn, a run) completed for another conversation after the
193
+ * failed one started, or the integration's own runtime check passed while no
194
+ * other conversation of that kind was failing (never for a `timed_out`
195
+ * failure). Without either, nothing is reported (a broken runtime is not the
196
+ * conversation's fault).
197
+ */
198
+ type ProcessingFailureEvidence = 'other_run_completed' | 'runtime_check';
199
+ /**
200
+ * What the server answers:
201
+ *
202
+ * - `retry`: the first failure for that span; run the conversation again.
203
+ * - `hidden`: the second; the span (the unread messages from others after your
204
+ * own last message, up to `through_message_id`) is now shown to you as a
205
+ * note, and stays unread. Run the conversation again: it reads around them.
206
+ * - `paused`: over the limits (it still fails with its span hidden, or a third
207
+ * span within 24 h); muted for 24 h with source `could_not_process`. Stop.
208
+ * - `none`: nothing left to act on (no such card, the span is read). Stop. Also
209
+ * what the SDK answers for a server that predates the route.
210
+ */
211
+ type ProcessingFailureActionName = 'retry' | 'hidden' | 'paused' | 'none';
212
+ /** Options for `client.conversations.reportProcessingFailure()`. */
213
+ interface ReportProcessingFailureOptions {
214
+ /**
215
+ * The newest message on the card the failed run started from: the card's
216
+ * anchor (`gate.anchorOf(card)`: `preview.message_id`, else
217
+ * `last_message_id`), as it was when the run started.
218
+ */
219
+ throughMessageId: string;
220
+ outcome: ProcessingFailureOutcome;
221
+ evidence: ProcessingFailureEvidence;
222
+ }
223
+ /** Wire body of `POST /v1/conversations/{id}/processing-failures`. */
224
+ interface ReportProcessingFailureRequest {
225
+ through_message_id: string;
226
+ outcome: ProcessingFailureOutcome;
227
+ evidence: ProcessingFailureEvidence;
228
+ }
229
+ /** The server's answer to a processing-failure report. */
230
+ interface ProcessingFailureAction {
231
+ action: ProcessingFailureActionName;
232
+ /**
233
+ * Failures counted for this (agent, conversation, `through_message_id`),
234
+ * this one included. `0` for the `none` an older server's plain 404 becomes.
235
+ */
236
+ attempts: number;
237
+ /**
238
+ * The messages this report hid from you (`hidden`, and a `paused` that hid
239
+ * a third span); empty otherwise. At most 200: `hidden_count` has the total.
240
+ */
241
+ hidden_message_ids: string[];
242
+ /** How many messages this report hid (`hidden_message_ids` lists at most 200 of them). Absent on servers that predate it. */
243
+ hidden_count?: number;
244
+ /** `paused`: when the 24 h mute ends (ISO 8601); null otherwise. */
245
+ paused_until: string | null;
246
+ }
247
+
161
248
  type ConversationType = 'direct' | 'group';
162
249
  interface Conversation {
163
250
  id: string;
@@ -696,6 +783,13 @@ interface InboxCardPreview {
696
783
  /** Trimmed to the server's preview cap (240 characters today). */
697
784
  text: string;
698
785
  at: string;
786
+ /**
787
+ * True when the preview message is hidden from you because your machine
788
+ * reported that its AI could not process it: `text` is then the server's
789
+ * note, not the message. Absent on servers that predate it, and when the
790
+ * preview is not hidden.
791
+ */
792
+ could_not_process?: boolean;
699
793
  }
700
794
  interface InboxCard {
701
795
  conversation_id: string;
@@ -857,6 +951,21 @@ interface Texts {
857
951
  * starts with `wake_instruction` and a `conversation_id:` line.
858
952
  */
859
953
  reply_turn_template?: string;
954
+ /**
955
+ * Conversation runs (the listener integrations): what a run started for one
956
+ * conversation starts with. It opens with `AgentChat started this run for
957
+ * ONE conversation`; replace every `<conversation_id>` with the card's
958
+ * conversation id (`integration.conversationRunPrompt`). Absent on older
959
+ * servers: the `ReceiveLoop` then stays in single-run mode (one run for the
960
+ * whole tray).
961
+ */
962
+ conversation_run_template?: string;
963
+ /**
964
+ * The note a message hidden from you reads as (could not process), with
965
+ * `<sender>` in place of the sender's handle. Served for reference: the
966
+ * server writes it into the hidden message itself. Absent on older servers.
967
+ */
968
+ could_not_process_note?: string;
860
969
  }
861
970
  /** Options for `client.texts.get()`. */
862
971
  interface GetTextsOptions {
@@ -939,6 +1048,11 @@ declare const ErrorCode: {
939
1048
  readonly RESTRICTED: "RESTRICTED";
940
1049
  readonly CONVERSATION_NOT_FOUND: "CONVERSATION_NOT_FOUND";
941
1050
  readonly MESSAGE_NOT_FOUND: "MESSAGE_NOT_FOUND";
1051
+ /**
1052
+ * 410 when you download the attachment of a message hidden from you
1053
+ * because your machine could not process it (`Message.could_not_process`).
1054
+ */
1055
+ readonly COULD_NOT_PROCESS: "COULD_NOT_PROCESS";
942
1056
  readonly GROUP_DELETED: "GROUP_DELETED";
943
1057
  readonly RATE_LIMITED: "RATE_LIMITED";
944
1058
  readonly RECIPIENT_BACKLOGGED: "RECIPIENT_BACKLOGGED";
@@ -1462,6 +1576,24 @@ interface ConversationsResource {
1462
1576
  * `NotFoundError` when the anchor is not a message of this conversation.
1463
1577
  */
1464
1578
  markRead(conversationId: string, throughMessageId: string, options?: CallOptions): Promise<MarkConversationReadResult>;
1579
+ /**
1580
+ * Report that this machine's AI could not process the conversation (a run,
1581
+ * a reply turn or a single-card gate call failed or timed out on it) while
1582
+ * the runtime otherwise works (`evidence`). The server keeps the count and
1583
+ * answers what to do: `retry` (run it again), `hidden` (the span is now a
1584
+ * note for you; run it again), `paused` (muted for 24 h; stop) or `none`
1585
+ * (nothing to act on; stop). Report only with evidence: a broken runtime
1586
+ * reports nothing.
1587
+ *
1588
+ * `POST /v1/conversations/{id}/processing-failures`. An Idempotency-Key is
1589
+ * sent (generated unless you pass one), so a transient failure is retried
1590
+ * safely and counts once. A server that predates the route answers a plain
1591
+ * 404, which comes back as `{ action: 'none', attempts: 0 }`. Throws
1592
+ * `NotFoundError` for `CONVERSATION_NOT_FOUND` (not a member) and
1593
+ * `MESSAGE_NOT_FOUND` (`throughMessageId` is not in that conversation, or
1594
+ * is your own), `ValidationError` for a bad body.
1595
+ */
1596
+ reportProcessingFailure(conversationId: string, options: ReportProcessingFailureOptions & CallOptions): Promise<ProcessingFailureAction>;
1465
1597
  }
1466
1598
  interface TextsResource {
1467
1599
  /**
@@ -1527,6 +1659,59 @@ interface SyncPage {
1527
1659
  requestId: string | null;
1528
1660
  headers: Headers;
1529
1661
  }
1662
+ /**
1663
+ * Options for `client.getMessages()` / `client.getMessagesPage()`. The
1664
+ * cursors are mutually exclusive: pass at most one of `beforeSeq`,
1665
+ * `afterSeq` / `afterMessageId`, `aroundMessageId`.
1666
+ */
1667
+ interface GetMessagesOptions extends CallOptions {
1668
+ /** Rows per page (default 50). */
1669
+ limit?: number;
1670
+ /** Backwards scrollback: rows with seq < N, newest first. */
1671
+ beforeSeq?: number;
1672
+ /** Forwards: rows with seq > N, oldest first. */
1673
+ afterSeq?: number;
1674
+ /**
1675
+ * Forwards from a message you hold: rows after it, oldest first (instead of
1676
+ * `afterSeq`). A server that predates it ignores it and answers the newest
1677
+ * page, newest first: see `MessagesPage.scopedWaitSupported`.
1678
+ */
1679
+ afterMessageId?: string;
1680
+ /** A backwards window ending at that exact message. */
1681
+ aroundMessageId?: string;
1682
+ /**
1683
+ * The scoped wait (needs `afterSeq` or `afterMessageId`; 0–50 000, ceiling
1684
+ * `INBOX_WAIT_MAX_MS`): the server answers as soon as a message from
1685
+ * someone else exists after the cursor, or with `[]` after this many ms.
1686
+ * Like any fetch it marks the messages it returns delivered, never read.
1687
+ * `0` (default) reads once. The per-call timeout is raised to cover the
1688
+ * wait unless you pass `timeoutMs`.
1689
+ *
1690
+ * A server that predates the scoped wait ignores `wait_ms` and
1691
+ * `after_message_id`: it answers at once with the newest page, newest
1692
+ * first. Callers must detect that and not treat the rows as new messages
1693
+ * after the cursor: `MessagesPage.scopedWaitSupported` is `false` (no
1694
+ * `X-AgentChat-Waited-Ms` header on a request with `waitMs` > 0); other
1695
+ * signs are a returned row equal to the cursor, or seq not ascending.
1696
+ */
1697
+ waitMs?: number;
1698
+ }
1699
+ /** One `GET /v1/messages/{conversation_id}` answer with the response facts a waiter needs. */
1700
+ interface MessagesPage {
1701
+ messages: Message[];
1702
+ /** How long the server held a scoped wait (`X-AgentChat-Waited-Ms`); null for a plain read. */
1703
+ waitedMs: number | null;
1704
+ /**
1705
+ * With `waitMs` > 0: whether the server served the scoped wait (it sent
1706
+ * `X-AgentChat-Waited-Ms`). `false` means a server that predates it: it
1707
+ * ignored `wait_ms` and `after_message_id` and answered the newest page,
1708
+ * newest first, at once, so the rows are not "new after the cursor". Null
1709
+ * for a plain read (`waitMs` 0), which asks nothing of the server.
1710
+ */
1711
+ scopedWaitSupported: boolean | null;
1712
+ requestId: string | null;
1713
+ headers: Headers;
1714
+ }
1530
1715
  declare class AgentChatClient {
1531
1716
  private readonly http;
1532
1717
  private readonly onBacklogWarning?;
@@ -1548,6 +1733,7 @@ declare class AgentChatClient {
1548
1733
  private getInboxTray;
1549
1734
  private recordDecision;
1550
1735
  private markConversationRead;
1736
+ private reportProcessingFailure;
1551
1737
  private getTexts;
1552
1738
  private get;
1553
1739
  private del;
@@ -1668,18 +1854,22 @@ declare class AgentChatClient {
1668
1854
  * most one:
1669
1855
  * - `beforeSeq` — backwards scrollback (rows with seq < N, newest first)
1670
1856
  * - `afterSeq` — forwards gap-fill (rows with seq > N, oldest first)
1857
+ * - `afterMessageId` — forwards from a message you hold (instead of `afterSeq`)
1671
1858
  * - `aroundMessageId` — backwards window ending at that exact message
1672
1859
  *
1673
1860
  * `afterSeq` is the path `RealtimeClient` uses for in-order recovery
1674
1861
  * when a per-conversation seq gap is detected. Application code usually
1675
1862
  * only needs `beforeSeq` for normal pagination.
1863
+ *
1864
+ * With `waitMs` > 0 (and `afterSeq` or `afterMessageId`) this is the
1865
+ * scoped wait: the server holds the request until a message from someone
1866
+ * else arrives after the cursor, or answers `[]` after `waitMs`. One
1867
+ * conversation only, no sync ack. `getMessagesPage` also returns how long
1868
+ * the server held it.
1676
1869
  */
1677
- getMessages(conversationId: string, options?: {
1678
- limit?: number;
1679
- beforeSeq?: number;
1680
- afterSeq?: number;
1681
- aroundMessageId?: string;
1682
- } & CallOptions): Promise<Message[]>;
1870
+ getMessages(conversationId: string, options?: GetMessagesOptions): Promise<Message[]>;
1871
+ /** `getMessages()` with the response facts a waiter needs: how long the server held a scoped wait (`waitedMs`). */
1872
+ getMessagesPage(conversationId: string, options?: GetMessagesOptions): Promise<MessagesPage>;
1683
1873
  /**
1684
1874
  * Hide a message from your own view (hide-for-me). Either side of the
1685
1875
  * conversation can call this to tidy their own inbox, but the other
@@ -3028,6 +3218,8 @@ type TurnEnd = {
3028
3218
  status: 'failed';
3029
3219
  agentchatCalls?: AgentChatCallCount | null;
3030
3220
  detail?: string;
3221
+ /** The turn ran past the runtime's own time limit (a could-not-process report then says `timed_out`). */
3222
+ timedOut?: boolean;
3031
3223
  } | {
3032
3224
  status: 'still_running';
3033
3225
  next?: Promise<TurnEnd>;
@@ -3626,15 +3818,64 @@ declare function probeHostedTools(options: ProbeHostedToolsOptions): Promise<Pro
3626
3818
  * `reply` (`startTurn`) prompted with the served `reply_turn_template` for
3627
3819
  * its one conversation, and when a turn has ended record from what actually
3628
3820
  * happened (`turnOutcome`). Each pending invite on the tray gets one invite
3629
- * turn (`startInviteTurn`, default `startTurn`) and the same rule.
3630
- * - `singleRun` (Claude Code, Codex, routines, a listener): when anything is
3631
- * owed, start one run (`startRun`) with the served wake text; the run reads
3632
- * the tray itself and records its own verdicts. The loop records nothing
3633
- * for cards. An invite still pending and undismissed after two completed
3634
- * runs is dismissed (seen, left pending, not shown again), so an ignored
3635
- * invite does not cost a run on every wake; the count is in memory only
3821
+ * turn (`startInviteTurn`, default `startTurn`) and the same rule. The
3822
+ * split: every owed card of a chunk of more than one card that failed
3823
+ * closed is gated again alone, one call per card, in the same cycle, before
3824
+ * any turn starts, so one card the model cannot handle fails only its own
3825
+ * call; a card whose last gate call failed is gated alone, after the
3826
+ * others, from then on. After two single-card calls in a row failed with
3827
+ * nothing decided in the cycle, the split goes on only if `checkRuntime()`
3828
+ * passes; otherwise it stops (`split_stopped`).
3829
+ * - `singleRun` (Claude Code, Codex, routines, a listener): the loop records
3830
+ * nothing for cards; the run reads them and records its own verdicts.
3831
+ * - Conversation runs, whenever the served texts carry
3832
+ * `conversation_run_template` (`conversationRuns: false` turns them off):
3833
+ * one run (`startRun`) per owed card, prompted for that one conversation
3834
+ * (`conversationRunPrompt`), and one invite run (the served invite prompt)
3835
+ * for the pending invites. Owed: an unmuted card with a preview; a
3836
+ * notices-only card (`preview: null`) waits on the tray for the next run
3837
+ * of its conversation. A conversation's run takes a slot as a turn
3838
+ * does (below): it is never run twice at once and is held out of later
3839
+ * cycles while it runs or waits. After a completed run that left its card
3840
+ * at the same anchor, that card is paced as a silent turn is. Cards whose
3841
+ * last run failed go after the others (and after the invite run).
3842
+ * A tray that cannot be read starts no run (`tray_failed`): one run for
3843
+ * the tray would put every conversation back in one run.
3844
+ * - Texts without the template (an older server): when anything is owed,
3845
+ * one run with the served wake text for the whole tray (`kind: 'tray'`).
3846
+ * A tray that cannot be read starts that run too.
3847
+ * An invite still pending and undismissed after two completed runs is
3848
+ * dismissed (seen, left pending, not shown again), so an ignored invite
3849
+ * does not cost a run on every wake; the count is in memory only
3636
3850
  * (`dismissIgnoredInvites: false` turns this off).
3637
3851
  *
3852
+ * Could not process (both modes): when a conversation's run, its reply turn
3853
+ * or its single-card gate call fails or times out, the loop reports it
3854
+ * (`client.conversations.reportProcessingFailure`) only with evidence that
3855
+ * the runtime otherwise works: (a) a later completion of the same kind of
3856
+ * work (a gate call for a gate call, a turn for a turn, a run for a run) for
3857
+ * a different conversation, after the failed one started; or (b)
3858
+ * `checkRuntime()` passes while no other conversation of that kind has
3859
+ * failed since that kind last completed (several failing together is the
3860
+ * runtime), and never for a timeout (`timed_out`: a brownout, a hung hook;
3861
+ * the check does not exercise those). A completion on the failing
3862
+ * conversation's own card is never evidence. The failure waits first: the work already queued runs (cheap
3863
+ * evidence), and the runtime check is asked only once nothing of that kind
3864
+ * is queued. It waits at most `AWAITING_EVIDENCE_MS` (10 min); one whose
3865
+ * runtime check fails is dropped (a broken runtime reports nothing: that is
3866
+ * the integration's runs-failing path, and the server's re-wakes). A
3867
+ * failure reported as its attempt ends keeps its conversation held (no other
3868
+ * cycle starts it) until the server has answered. A run or
3869
+ * turn that answered, or recorded a verdict, before it failed (read on a
3870
+ * fresh tray) is not a failure, nor is one `stop()` cut short. The report
3871
+ * reads through the card's anchor as it was when the failed attempt started;
3872
+ * the server picks the span and answers: `retry` or `hidden` → that
3873
+ * conversation goes again, after the others already queued (a gate call
3874
+ * after `hidden` in the next cycle, on the fresh card); `paused` or `none`
3875
+ * → the loop stops for it. At most `MAX_RERUNS_PER_CYCLE` (3) re-runs per
3876
+ * conversation per cycle. `status().processingFailures` counts it all; each
3877
+ * report is a `processing_failure` event.
3878
+ *
3638
3879
  * Wakes: a `message.new` frame that is not the echo of the agent's own send,
3639
3880
  * a `wake` frame (a reminder, or unanswered cards), every accepted HELLO (a
3640
3881
  * reconnect after a heartbeat gap included), a `group.invite.received`
@@ -3648,14 +3889,15 @@ declare function probeHostedTools(options: ProbeHostedToolsOptions): Promise<Pro
3648
3889
  * waits on the tray for the next wake. A real message in the same burst
3649
3890
  * still wakes.
3650
3891
  *
3651
- * Turns: at most `maxConcurrentTurns` (default 1) reply and invite turns run
3652
- * at once; the rest wait for a slot and take one in the order they were
3653
- * gated, held out of the gate meanwhile (their cards stay on the tray;
3654
- * nothing is recorded for them; no second model call decides them again).
3655
- * `stop()` drops the waiting ones. A turn that ends
3656
- * after `stop()` still has its outcome recorded: what it did is a fact.
3657
- * `startTurn` / `startRun` must enforce their own deadline (the loop cannot
3658
- * end a turn); `status()` marks a turn running longer than 30 minutes.
3892
+ * Turns: at most `maxConcurrentTurns` (default 1) reply and invite turns (or
3893
+ * conversation and invite runs) run at once; the rest wait for a slot and
3894
+ * take one in the order they were gated (queued), held out of the gate
3895
+ * meanwhile (their cards stay on the tray; nothing is recorded for them; no
3896
+ * second model call decides them again). `stop()` drops the waiting ones and
3897
+ * waits for the runs under way. A turn that ends after `stop()` still has its
3898
+ * outcome recorded: what it did is a fact. `startTurn` / `startRun` must
3899
+ * enforce their own deadline (the loop cannot end a turn); `status()` marks a
3900
+ * turn running longer than 30 minutes.
3659
3901
  *
3660
3902
  * Pacing (D5): after a silent turn (it looked and did nothing) the same
3661
3903
  * conversation at the same anchor is not gated again for `paceMs` (60 s)
@@ -3667,10 +3909,12 @@ declare function probeHostedTools(options: ProbeHostedToolsOptions): Promise<Pro
3667
3909
  * There is no retry ladder here. A cycle that could not finish (the tray
3668
3910
  * could not be read, the model failed, a turn was refused or failed) leaves
3669
3911
  * the cards on the tray and does nothing more: the server re-wakes
3670
- * unanswered cards on its own durable ladder (D3). The one wake the loop
3671
- * gives itself is for a truncated tray (read the rest): at once after a cycle
3672
- * that recorded a verdict or started a turn; otherwise after a backoff
3673
- * (1 s doubling to 60 s), so a cycle that cannot progress never spins.
3912
+ * unanswered cards on its own durable ladder (D3). The server's could-not-
3913
+ * process answers are not a ladder: they are its decision, followed once.
3914
+ * The one wake the loop gives itself is for a truncated tray (read the rest):
3915
+ * at once after a cycle that recorded a verdict or started a turn; otherwise
3916
+ * after a backoff (1 s doubling to 60 s), so a cycle that cannot progress
3917
+ * never spins.
3674
3918
  */
3675
3919
 
3676
3920
  type ReceiveLoopMode = 'gateCall' | 'singleRun';
@@ -3715,22 +3959,54 @@ type TurnAdmission = {
3715
3959
  readonly done: Promise<TurnEnd>;
3716
3960
  };
3717
3961
  type TurnStarter = (request: TurnRequest) => Promise<TurnAdmission>;
3718
- /** The one run the loop asks for (single-run mode). */
3962
+ /**
3963
+ * What a run is for (single-run mode): one conversation (a conversation run),
3964
+ * the whole tray (the served wake instruction: texts without
3965
+ * `conversation_run_template`, or a tray that could not be read), or the
3966
+ * pending invites (the served invite prompt).
3967
+ */
3968
+ type RunKind = 'conversation' | 'tray' | 'invite';
3969
+ /** A run the loop asks for (single-run mode). */
3719
3970
  interface RunRequest {
3720
- /** The served wake instruction (and the invite prompt when invites wait), or the invite prompt alone. */
3971
+ /**
3972
+ * A conversation run: the served `conversation_run_template` for that one
3973
+ * conversation (`conversationRunPrompt`). A tray run: the served wake
3974
+ * instruction (and the invite prompt when invites wait). An invite run (or
3975
+ * a tray with invites only): the invite prompt alone.
3976
+ */
3721
3977
  readonly prompt: string;
3722
3978
  readonly texts: Texts;
3723
- /** Unanswered cards and pending invites on the tray that started it; null when the tray could not be read. */
3979
+ /** Unanswered cards and pending invites the run is for (a conversation run: 1 and 0); null when the tray could not be read. */
3724
3980
  readonly cards: number | null;
3725
3981
  readonly invites: number | null;
3726
3982
  readonly signal: AbortSignal;
3983
+ /** What the run is for. Set by this loop on every run. */
3984
+ readonly kind?: RunKind;
3985
+ /** A conversation run: the one conversation it is for. */
3986
+ readonly conversationId?: string;
3727
3987
  }
3728
3988
  interface RunEnd {
3729
3989
  readonly status: 'completed' | 'failed' | 'not_started';
3730
3990
  readonly detail?: string;
3991
+ /** A `failed` run that ran past its time limit (a could-not-process report then says `timed_out`). */
3992
+ readonly timedOut?: boolean;
3731
3993
  }
3732
- /** Starts the one run and resolves when it ends. Enforce the run's deadline here: the loop never ends a run. */
3994
+ /** Starts one run and resolves when it ends. Enforce the run's deadline here: the loop never ends a run. */
3733
3995
  type RunStarter = (request: RunRequest) => Promise<RunEnd>;
3996
+ /**
3997
+ * Whether the agent's AI answers right now (a minimal model call with no peer
3998
+ * content, through the same account), asked about a failed conversation run,
3999
+ * turn or gate call once nothing else of that kind is queued: `ok` is the
4000
+ * evidence a could-not-process report needs, when no other conversation of
4001
+ * that kind is failing too. A version check alone is not enough: it passes
4002
+ * during a provider outage.
4003
+ */
4004
+ type RuntimeCheck = () => Promise<{
4005
+ readonly ok: boolean;
4006
+ readonly detail?: string;
4007
+ }>;
4008
+ /** What failed on a conversation: its conversation run, its reply turn, or its single-card gate call. */
4009
+ type FailureSource = 'run' | 'turn' | 'gate';
3734
4010
  /** Whether a turn started now could reach AgentChat (e.g. `probeHostedTools`); checked before a cycle spends a model call. */
3735
4011
  type Readiness = () => {
3736
4012
  readonly ready: true;
@@ -3767,6 +4043,11 @@ type CycleOutcome =
3767
4043
  | 'fail_closed'
3768
4044
  /** gateCall: only invites were owed; their turns were started or queued. */
3769
4045
  | 'invites_only'
4046
+ /**
4047
+ * singleRun with conversation runs: one run per owed card (and one for the
4048
+ * pending invites) was started or queued; each run's end is a `run` event.
4049
+ */
4050
+ | 'runs_started'
3770
4051
  /** singleRun: the run's end. */
3771
4052
  | 'run_completed' | 'run_failed' | 'run_not_started'
3772
4053
  /** The cycle ran past `cycleTimeoutMs` and was abandoned; the next wake runs a new one. */
@@ -3784,9 +4065,10 @@ interface CycleSummary {
3784
4065
  /** `dismiss` / `defer` verdicts the gate recorded. */
3785
4066
  readonly recorded: number;
3786
4067
  readonly recordFailures: number;
4068
+ /** Reply or invite turns (conversation runs: runs) started. */
3787
4069
  readonly turnsStarted: number;
3788
4070
  readonly turnsRefused: number;
3789
- /** Reply or invite turns waiting for a slot (`maxConcurrentTurns`). */
4071
+ /** Reply or invite turns (conversation runs: runs) waiting for a slot (`maxConcurrentTurns`). */
3790
4072
  readonly turnsQueued: number;
3791
4073
  /** Cards left out because a turn for their conversation is running or waiting. */
3792
4074
  readonly heldByTurns: number;
@@ -3801,12 +4083,28 @@ interface CycleSummary {
3801
4083
  * watchdog) is neither: the cycle is `abandoned`.
3802
4084
  */
3803
4085
  readonly chunksFailed: number;
4086
+ /**
4087
+ * gateCall: single-card gate calls after a chunk failed closed (each of its
4088
+ * cards gated alone), and calls for a card whose last gate call failed,
4089
+ * that gave a verdict.
4090
+ */
4091
+ readonly splitCallsOk: number;
4092
+ /** gateCall: those single-card calls that failed closed. */
4093
+ readonly splitCallsFailed: number;
4094
+ /**
4095
+ * gateCall: the split stopped (`split_stopped`): single-card calls kept
4096
+ * failing with nothing decided in the cycle, and `checkRuntime()` did not
4097
+ * pass (or there is none). The cards not reached stay undecided.
4098
+ */
4099
+ readonly splitStopped: boolean;
3804
4100
  readonly truncated: boolean;
3805
4101
  /**
3806
4102
  * Why the cycle could not finish, or, when some gate chunks failed, how
3807
4103
  * many of the calls made and the first one's reason (`2 of 5 gate chunks
3808
4104
  * failed; chunk 3: …`, the chunk named by its `gate_chunk` index); a cycle
3809
- * that made one gate call gives that call's reason as it is.
4105
+ * that made one gate call gives that call's reason as it is. Failed
4106
+ * single-card calls follow (`…; 2 of 10 single-card calls failed;
4107
+ * <conversation_id>: …`).
3810
4108
  */
3811
4109
  readonly failure: string | null;
3812
4110
  }
@@ -3817,11 +4115,13 @@ interface GateChunkReport {
3817
4115
  * (not consecutive), so a cycle's chunks are never taken for the next one's.
3818
4116
  */
3819
4117
  readonly cycle: number;
3820
- /** 1-based position of the chunk in the cycle, in tray order. */
4118
+ /** 1-based position of the chunk in the cycle, in tray order (a single-card call: among the cycle's single-card calls). */
3821
4119
  readonly index: number;
3822
4120
  /**
3823
4121
  * How many chunks the cycle's cards were split into. A chunk not called
3824
4122
  * (every card taken by a turn meanwhile, or muted cards only) has no report.
4123
+ * A single-card call: how many single-card calls were made or queued when
4124
+ * it was made.
3825
4125
  */
3826
4126
  readonly of: number;
3827
4127
  /** Cards this call decided on (the N of its prompt). */
@@ -3830,6 +4130,36 @@ interface GateChunkReport {
3830
4130
  /** This chunk's cards left without a usable verdict. */
3831
4131
  readonly undecided: number;
3832
4132
  readonly failure: string | null;
4133
+ /**
4134
+ * A single-card call after the chunks: a card of a chunk that failed
4135
+ * closed, gated alone, or a card whose last gate call failed. Absent on
4136
+ * the planned chunks.
4137
+ */
4138
+ readonly split?: true;
4139
+ /** A single-card call: its card's conversation. */
4140
+ readonly conversationId?: string;
4141
+ }
4142
+ /** One could-not-process report and the server's answer. */
4143
+ interface ProcessingFailureReport {
4144
+ readonly conversationId: string;
4145
+ /** What failed: the conversation's run, its reply turn, or its single-card gate call. */
4146
+ readonly source: FailureSource;
4147
+ /** The card's anchor when the failed attempt started. */
4148
+ readonly throughMessageId: string;
4149
+ readonly outcome: ProcessingFailureOutcome;
4150
+ readonly evidence: ProcessingFailureEvidence;
4151
+ /** The server's answer; null when the report itself failed (`error`). */
4152
+ readonly result: ProcessingFailureAction | null;
4153
+ readonly error?: string;
4154
+ /**
4155
+ * What the loop does for the conversation: `rerun` (a `retry` or `hidden`
4156
+ * answer: it runs again after the others queued), `running` (`retry` /
4157
+ * `hidden`, but its next attempt is already under way: running, queued, or
4158
+ * being gated now), `stop` (`paused`, `none`, or the report failed),
4159
+ * `rerun_capped` (`retry` / `hidden`, but it already ran again
4160
+ * `MAX_RERUNS_PER_CYCLE` times in this cycle).
4161
+ */
4162
+ readonly next: 'rerun' | 'running' | 'stop' | 'rerun_capped';
3833
4163
  }
3834
4164
  type ReceiveLoopEvent = {
3835
4165
  readonly type: 'wake';
@@ -3873,6 +4203,26 @@ type ReceiveLoopEvent = {
3873
4203
  } | {
3874
4204
  readonly type: 'run';
3875
4205
  readonly end: RunEnd;
4206
+ /** What the run was for. */
4207
+ readonly kind?: RunKind;
4208
+ /** A conversation run's conversation. */
4209
+ readonly conversationId?: string;
4210
+ }
4211
+ /** A could-not-process report was made (or failed) for one conversation. */
4212
+ | ({
4213
+ readonly type: 'processing_failure';
4214
+ } & ProcessingFailureReport)
4215
+ /**
4216
+ * gateCall: the split stopped. Single-card calls failed `SPLIT_STOP_AFTER_FAILURES`
4217
+ * times in a row with nothing decided in the cycle, and `checkRuntime()`
4218
+ * did not pass (`runtime_check_failed`) or there is none (`no_runtime_check`).
4219
+ */
4220
+ | {
4221
+ readonly type: 'split_stopped';
4222
+ readonly cycle: number;
4223
+ /** Cards left in the split's queue, undecided. */
4224
+ readonly remaining: number;
4225
+ readonly reason: 'runtime_check_failed' | 'no_runtime_check';
3876
4226
  } | {
3877
4227
  readonly type: 'error';
3878
4228
  readonly error: Error;
@@ -3887,9 +4237,14 @@ interface ReceiveLoopSocketOptions {
3887
4237
  readonly reconnectInterval?: number;
3888
4238
  readonly maxReconnectInterval?: number;
3889
4239
  }
3890
- /** What the loop calls on the client; `AgentChatClient` satisfies it. */
4240
+ /**
4241
+ * What the loop calls on the client; `AgentChatClient` satisfies it. Without
4242
+ * `conversations.reportProcessingFailure` the loop reports no
4243
+ * could-not-process failure (and so acts on none).
4244
+ */
3891
4245
  type ReceiveLoopClient = Pick<AgentChatClient, 'inbox' | 'decisions' | 'groups'> & {
3892
4246
  readonly baseUrl?: string;
4247
+ readonly conversations?: Pick<ConversationsResource, 'reportProcessingFailure'>;
3893
4248
  };
3894
4249
  interface ReceiveLoopOptions {
3895
4250
  readonly client: ReceiveLoopClient;
@@ -3901,8 +4256,33 @@ interface ReceiveLoopOptions {
3901
4256
  readonly startTurn?: TurnStarter;
3902
4257
  /** gateCall: starts one invite turn. Default: `startTurn`. */
3903
4258
  readonly startInviteTurn?: TurnStarter;
3904
- /** singleRun: starts the one run. */
4259
+ /** singleRun: starts a run (a conversation run, an invite run, or the one tray run). */
3905
4260
  readonly startRun?: RunStarter;
4261
+ /**
4262
+ * singleRun: whenever the served texts carry `conversation_run_template`
4263
+ * (default `true`), start one run per owed card, for that one conversation,
4264
+ * and one invite run for the pending invites, instead of one run for the
4265
+ * whole tray. `false` keeps one run for the tray. Texts without the template
4266
+ * (an older server) always keep it.
4267
+ */
4268
+ readonly conversationRuns?: boolean;
4269
+ /**
4270
+ * Whether the runtime works right now (both modes). Asked about a
4271
+ * conversation's failed run, reply turn or single-card gate call once
4272
+ * nothing else of that kind is queued, and only when no other conversation
4273
+ * of that kind has failed since that kind last completed, and never for
4274
+ * a timeout (`timed_out` needs another completion); `ok` is the evidence a
4275
+ * could-not-process report needs (`runtime_check`). Also the
4276
+ * gate split's guard: after two single-card calls in a row failed with
4277
+ * nothing decided, the split goes on only if it passes. It must show that
4278
+ * the agent's AI answers now (a minimal model call with no peer content,
4279
+ * through the same account), not only that a binary is installed: an `ok`
4280
+ * during a provider outage would report the outage as the conversation's
4281
+ * failure. Without it, a failure is reported only once the same kind of
4282
+ * work completes for another conversation (within `AWAITING_EVIDENCE_MS`).
4283
+ * Bounded by `RUNTIME_CHECK_TIMEOUT_MS`; a throw counts as not ok.
4284
+ */
4285
+ readonly checkRuntime?: RuntimeCheck;
3906
4286
  /**
3907
4287
  * The socket: options to build one (needs the API key), a `RealtimeClient`
3908
4288
  * you built (the loop attaches its handlers and connects and disconnects
@@ -3915,7 +4295,7 @@ interface ReceiveLoopOptions {
3915
4295
  /** How this runtime spells the hosted tools named in the tray's question (gate call). */
3916
4296
  readonly toolNamer?: ToolNamer;
3917
4297
  readonly readiness?: Readiness;
3918
- /** Reply and invite turns running at once (gateCall). Default 1. */
4298
+ /** Reply and invite turns (gateCall), or conversation and invite runs (singleRun), running at once. Default 1. */
3919
4299
  readonly maxConcurrentTurns?: number;
3920
4300
  /** D5 pacing window. Default `PACE_MS` (60 s). */
3921
4301
  readonly paceMs?: number;
@@ -4013,9 +4393,40 @@ interface ReceiveLoopStatus {
4013
4393
  readonly chunksOk: number;
4014
4394
  /** Gate calls (chunks) that failed closed, since start; alarm on a rising count. */
4015
4395
  readonly chunksFailed: number;
4396
+ /** Single-card gate calls (after a chunk failed, or for a card whose last call failed) that gave a verdict, since start. */
4397
+ readonly splitCallsOk: number;
4398
+ /** Single-card gate calls that failed closed, since start. */
4399
+ readonly splitCallsFailed: number;
4016
4400
  readonly outcomes: Readonly<Record<string, number>>;
4017
4401
  readonly outcomeRecordFailures: number;
4018
4402
  };
4403
+ /** Could not process: what was reported, and what the server answered, since start. */
4404
+ readonly processingFailures: {
4405
+ /** Reports the server answered. */
4406
+ readonly reported: number;
4407
+ readonly retry: number;
4408
+ readonly hidden: number;
4409
+ readonly paused: number;
4410
+ readonly none: number;
4411
+ /** Reports that failed (a network or server error); nothing more is done for them. */
4412
+ readonly reportErrors: number;
4413
+ /** Runs, reply turns or single-card gate calls started again on a `retry` or `hidden` answer. */
4414
+ readonly reruns: number;
4415
+ /** `retry` / `hidden` answers not followed: the conversation already ran again `MAX_RERUNS_PER_CYCLE` times in its cycle. */
4416
+ readonly rerunsCapped: number;
4417
+ /** Failures held until another run, turn or gate call completes (the evidence a report needs), now. */
4418
+ readonly awaitingEvidence: number;
4419
+ readonly runtimeChecksOk: number;
4420
+ readonly runtimeChecksFailed: number;
4421
+ /** Gate splits stopped (`split_stopped`), since start. */
4422
+ readonly splitsStopped: number;
4423
+ /** The last `checkRuntime()` answer, or null. */
4424
+ readonly lastRuntimeCheck: {
4425
+ readonly at: string;
4426
+ readonly ok: boolean;
4427
+ readonly detail: string | null;
4428
+ } | null;
4429
+ };
4019
4430
  readonly lastError: string | null;
4020
4431
  }
4021
4432
  declare class ReceiveLoop {
@@ -4035,7 +4446,39 @@ declare class ReceiveLoop {
4035
4446
  /** When a single-run invite's silent run was counted (D5 pacing in single-run mode). */
4036
4447
  private readonly silentAt;
4037
4448
  private readonly paceMs;
4449
+ /** Turns and runs waiting for a slot; `drop` ends what else the entry holds (an invite run's other invites). */
4038
4450
  private readonly waiting;
4451
+ /** Conversation and invite runs started and not yet concluded: `idle()` and `stop()` wait for them. */
4452
+ private readonly runWork;
4453
+ /** Could not process: the order of attempts and completions. */
4454
+ private readonly evidence;
4455
+ /** Could not process: failures waiting for a completion (the evidence a report needs), by conversation. */
4456
+ private readonly awaitingEvidence;
4457
+ /** Waiting failures the runtime check has already been asked about (once each). */
4458
+ private readonly checkedFailures;
4459
+ /**
4460
+ * Per kind of work, the conversations whose attempt failed since that kind
4461
+ * last completed. Two or more: several failing together is the runtime, so
4462
+ * a passing `checkRuntime()` is no evidence for any of them.
4463
+ */
4464
+ private readonly failingSince;
4465
+ /** gateCall: conversations whose last gate call failed; gated alone, after the others. */
4466
+ private readonly gateAlone;
4467
+ /**
4468
+ * gateCall: the running cycle's gate: its cards (`members`) and its
4469
+ * single-card queue. A `retry` answer for one of its cards joins the queue;
4470
+ * a `hidden` one skips the card here (its card, read before the hide, is
4471
+ * stale) and gates it in the next cycle.
4472
+ */
4473
+ private activeSplit;
4474
+ /**
4475
+ * gateCall: reply turns to start again on a `retry` / `hidden` answer that
4476
+ * came while a gate was deciding: they start after that cycle's own turns
4477
+ * (no turn starts while cards of a cycle still wait for their gate call).
4478
+ */
4479
+ private turnRerunsAfterGate;
4480
+ private lastRuntimeCheck;
4481
+ private readonly failureCounts;
4039
4482
  /** Conversations whose verdict a gate call is recording right now (an abandoned cycle's included). */
4040
4483
  private readonly recordsInFlight;
4041
4484
  /** Turns holding a slot (admitted, not yet ended or released). */
@@ -4072,7 +4515,12 @@ declare class ReceiveLoop {
4072
4515
  * outcome recorded.
4073
4516
  */
4074
4517
  stop(): Promise<void>;
4075
- /** Resolves when the running cycle has finished (tests, graceful stops). */
4518
+ /**
4519
+ * Resolves when the running cycle has finished (tests, graceful stops) and,
4520
+ * in single-run mode, no run is running or waiting for a slot (conversation
4521
+ * runs go on after the cycle that started them). Gate-call turns are not
4522
+ * waited for.
4523
+ */
4076
4524
  idle(): Promise<void>;
4077
4525
  /** Let go of a turn whose end the runtime will never confirm (an operator's call). Nothing is recorded for it. */
4078
4526
  releaseTurn(key: string): boolean;
@@ -4098,6 +4546,7 @@ declare class ReceiveLoop {
4098
4546
  * off the watchdog is the calls' only bound, so they count.
4099
4547
  */
4100
4548
  private boundedModelCall;
4549
+ /** `timedOut` is set when a call runs past its deadline (a could-not-process report then says `timed_out`). */
4101
4550
  private deadlineModelCall;
4102
4551
  private readTray;
4103
4552
  private checkReady;
@@ -4121,6 +4570,18 @@ declare class ReceiveLoop {
4121
4570
  * cards only (or none) is not called. Stops once the cycle is stale; a call
4122
4571
  * a stop cut short is not counted as a failed chunk, and a cycle the
4123
4572
  * watchdog abandoned reports and counts no chunk after its summary.
4573
+ *
4574
+ * The split (could not process): every owed card of a chunk of more than
4575
+ * one card that failed closed is then gated again alone, one call per card,
4576
+ * in tray order, before any turn starts, so one card the model cannot
4577
+ * handle fails only its own call. A card whose last gate call failed is
4578
+ * kept out of the chunks and gated alone after them. A single-card call that
4579
+ * fails is the card's failure (reported with evidence; a `retry` answer
4580
+ * gates it once more at the end of the queue). When the queue is empty, a
4581
+ * failure still waiting gets the runtime check. After
4582
+ * `SPLIT_STOP_AFTER_FAILURES` single-card calls in a row failed with nothing
4583
+ * decided in the cycle, the split goes on only if `checkRuntime()` passes;
4584
+ * otherwise it stops (`split_stopped`).
4124
4585
  */
4125
4586
  private gateInChunks;
4126
4587
  /**
@@ -4132,6 +4593,29 @@ declare class ReceiveLoop {
4132
4593
  private readTheRest;
4133
4594
  private clearMoreTimer;
4134
4595
  private singleRunCycle;
4596
+ /**
4597
+ * Conversation runs (single-run mode, texts with `conversation_run_template`):
4598
+ * one run per owed card (unmuted, with a preview: a notices-only card is not
4599
+ * owed), prompted for that one conversation, and one invite run for the
4600
+ * pending invites. A conversation whose run is running or
4601
+ * waiting for a slot is held out (the tracker), and so is one paced after a
4602
+ * completed run that left its card at the same anchor (D5). Runs take a slot
4603
+ * each (`maxConcurrentTurns`) in the order queued: the cards whose last run
4604
+ * failed go last, after the invite run, so they never hold up the others.
4605
+ * The loop records no verdict for a card: the run decides.
4606
+ */
4607
+ private conversationRunCycle;
4608
+ /** One conversation run: a slot (or a place in the queue), the run, then what its end says. */
4609
+ private startConversationRun;
4610
+ private afterConversationRun;
4611
+ /** The invite run: one run for the pending invites, holding each of them until it ends. */
4612
+ private startInviteRun;
4613
+ private afterInviteRun;
4614
+ /** The runtime's `startRun`, never rejecting: a throw is a run that did not start. */
4615
+ private callRun;
4616
+ private countRunEnd;
4617
+ /** A run's whole course after its start: `idle()` and `stop()` wait for it. */
4618
+ private trackRun;
4135
4619
  private afterRunInvites;
4136
4620
  private startReplyTurn;
4137
4621
  private startInviteTurn;
@@ -4159,6 +4643,70 @@ declare class ReceiveLoop {
4159
4643
  private admit;
4160
4644
  /** A turn's end: cards a cycle left out meanwhile are read again. */
4161
4645
  private afterTurnEnded;
4646
+ /**
4647
+ * A run, turn or gate call that completed, on the evidence clock. A failure
4648
+ * it clears (the same kind of attempt for the same conversation went
4649
+ * through since) waits no more. Call it the moment the work ended, before
4650
+ * its slot frees, so the next attempt starts after it.
4651
+ */
4652
+ private completed;
4653
+ /**
4654
+ * Report the failures this completion is the evidence for (each once). One
4655
+ * that waited past `AWAITING_EVIDENCE_MS` is dropped instead: a completion
4656
+ * that late says little about the runtime when it failed.
4657
+ */
4658
+ private reportDue;
4659
+ /** An attempt of this kind failed for these conversations (whatever comes of it): see `failingSince`. */
4660
+ private failedAttempt;
4661
+ /**
4662
+ * A conversation's run, reply turn or single-card gate call failed. It is
4663
+ * reported only with evidence that the runtime otherwise works:
4664
+ * (a) a later completion of the same kind of work for another conversation
4665
+ * (`evidences`), or (b) `checkRuntime()` passing while no other
4666
+ * conversation of that kind has failed since that kind last completed.
4667
+ * Without (a) it waits: the work already queued runs first (cheap
4668
+ * evidence), and the runtime check is asked only once nothing of that kind
4669
+ * is queued (`checkParked`). It waits at most `AWAITING_EVIDENCE_MS`.
4670
+ * Nothing is reported after `stop()`: a run the stop cut short did not
4671
+ * fail on its conversation.
4672
+ */
4673
+ private failed;
4674
+ /**
4675
+ * Evidence (b), once nothing of this kind is queued: ask `checkRuntime()`
4676
+ * about the failure still waiting for evidence, if it is the only
4677
+ * conversation of that kind failing since that kind last completed. Several
4678
+ * failing together is the runtime: none of them is reported on (b), and
4679
+ * they keep waiting for (a). A `timed_out` failure is never reported on
4680
+ * (b): a timeout is ambiguous (a brownout, a hung hook) and the check does
4681
+ * not exercise those paths; it waits for (a). Each failure is asked about
4682
+ * once. A check that fails drops it (a broken runtime reports nothing).
4683
+ */
4684
+ private checkParked;
4685
+ /** Nothing of this kind is running or queued: the runtime check may be asked now. */
4686
+ private idleFor;
4687
+ private canReport;
4688
+ /** `checkRuntime()`, bounded by `RUNTIME_CHECK_TIMEOUT_MS`; a throw or a timeout is not ok. */
4689
+ private runtimeCheck;
4690
+ /** Tell the server, and do what it answers: run the conversation again (`retry`, `hidden`) or stop (`paused`, `none`). */
4691
+ private reportFailure;
4692
+ /**
4693
+ * Run the conversation again after a `retry` or `hidden` answer, after the
4694
+ * others already queued, and say what was done. Its run or reply turn takes
4695
+ * a place at the back of the queue (it reads the conversation itself, so it
4696
+ * sees a hidden span as the note); a reply turn asked for while a gate is
4697
+ * deciding starts after that cycle's own turns. A gate call sees only the
4698
+ * card: after `retry` it joins the end of the running gate's single-card
4699
+ * calls (once, with the card as this cycle read it); after `hidden`, or
4700
+ * when no gate is running for it, the next cycle reads the tray again and
4701
+ * gates it alone. `running`: nothing started, because its next attempt is
4702
+ * under way already (running, queued, or being decided by the gate now).
4703
+ */
4704
+ private rerun;
4705
+ /** The reply turns asked for while a gate was deciding: started now, after the cycle's own turns. */
4706
+ private flushTurnReruns;
4707
+ /** A `paused` conversation: a run or turn still waiting for a slot for it does not start. */
4708
+ private dropWaiting;
4709
+ private rememberGateAlone;
4162
4710
  /** Recording under way after a turn's confirmed end: `stop()` waits for it. */
4163
4711
  private track;
4164
4712
  private remember;
@@ -4178,6 +4726,16 @@ declare class ReceiveLoop {
4178
4726
  * wake instruction and a `conversation_id:` line.
4179
4727
  */
4180
4728
  declare function replyPrompt(texts: Pick<Texts, 'wake_instruction' | 'reply_turn_template'>, conversationId: string): string;
4729
+ /**
4730
+ * The prompt a conversation run starts with: the served
4731
+ * `conversation_run_template` with every `<conversation_id>` replaced by the
4732
+ * conversation's id, which sends the run to that one conversation and no
4733
+ * other. A served template that names no `<conversation_id>` is still the
4734
+ * run's text, followed by a `conversation_id:` line. Texts without the
4735
+ * template (the `ReceiveLoop` then starts no conversation runs) fall back to
4736
+ * `replyPrompt`.
4737
+ */
4738
+ declare function conversationRunPrompt(texts: Pick<Texts, 'wake_instruction' | 'reply_turn_template' | 'conversation_run_template'>, conversationId: string): string;
4181
4739
 
4182
4740
  /**
4183
4741
  * Sign-up for an integration's setup (`integration.account`): register a new
@@ -4490,6 +5048,7 @@ type index_CycleOutcome = CycleOutcome;
4490
5048
  type index_CycleSummary = CycleSummary;
4491
5049
  declare const index_DEFAULT_MAX_MS: typeof DEFAULT_MAX_MS;
4492
5050
  declare const index_DEFAULT_QUIET_MS: typeof DEFAULT_QUIET_MS;
5051
+ type index_FailureSource = FailureSource;
4493
5052
  type index_FindOptions = FindOptions;
4494
5053
  type index_FoundBlock = FoundBlock;
4495
5054
  type index_GateChunkReport = GateChunkReport;
@@ -4511,6 +5070,7 @@ type index_ManualSyncState = ManualSyncState;
4511
5070
  type index_OutcomeClient = OutcomeClient;
4512
5071
  type index_ProbeHostedToolsOptions = ProbeHostedToolsOptions;
4513
5072
  type index_ProbeHostedToolsResult = ProbeHostedToolsResult;
5073
+ type index_ProcessingFailureReport = ProcessingFailureReport;
4514
5074
  declare const index_REQUIRED_HOSTED_TOOLS: typeof REQUIRED_HOSTED_TOOLS;
4515
5075
  type index_Readiness = Readiness;
4516
5076
  type index_ReceiveLoop = ReceiveLoop;
@@ -4524,9 +5084,11 @@ type index_ReceiveLoopStatus = ReceiveLoopStatus;
4524
5084
  type index_RecoverInput = RecoverInput;
4525
5085
  type index_RegisterInput = RegisterInput;
4526
5086
  type index_RunEnd = RunEnd;
5087
+ type index_RunKind = RunKind;
4527
5088
  type index_RunRequest = RunRequest;
4528
5089
  type index_RunStarter = RunStarter;
4529
5090
  type index_RunningTurn = RunningTurn;
5091
+ type index_RuntimeCheck = RuntimeCheck;
4530
5092
  type index_ServedManual = ServedManual;
4531
5093
  type index_SignupAction = SignupAction;
4532
5094
  type index_SyncManualOptions = SyncManualOptions;
@@ -4561,6 +5123,7 @@ declare const index_account: typeof account;
4561
5123
  declare const index_anchor: typeof anchor;
4562
5124
  declare const index_applyInviteOutcome: typeof applyInviteOutcome;
4563
5125
  declare const index_applyOutcome: typeof applyOutcome;
5126
+ declare const index_conversationRunPrompt: typeof conversationRunPrompt;
4564
5127
  declare const index_hostedMcpUrl: typeof hostedMcpUrl;
4565
5128
  declare const index_inviteOutcome: typeof inviteOutcome;
4566
5129
  declare const index_isTexts: typeof isTexts;
@@ -4573,7 +5136,7 @@ declare const index_syncManual: typeof syncManual;
4573
5136
  declare const index_turnOutcome: typeof turnOutcome;
4574
5137
  declare const index_writeAtomic: typeof writeAtomic;
4575
5138
  declare namespace index {
4576
- export { type index_AccountAnswer as AccountAnswer, type index_AccountCallOptions as AccountCallOptions, type index_AccountKind as AccountKind, type index_AccountLabels as AccountLabels, type index_AccountQuestion as AccountQuestion, type RunOptions as AccountRunOptions, type RunResult as AccountRunResult, type StepResult as AccountStepResult, type index_AgentChatCallCount as AgentChatCallCount, type index_CheckKeyResult as CheckKeyResult, type index_CoalescerCounters as CoalescerCounters, type index_CoalescerState as CoalescerState, type index_ConfirmedTurnEnd as ConfirmedTurnEnd, type index_CycleOutcome as CycleOutcome, type index_CycleSummary as CycleSummary, index_DEFAULT_MAX_MS as DEFAULT_MAX_MS, index_DEFAULT_QUIET_MS as DEFAULT_QUIET_MS, type index_FindOptions as FindOptions, type index_FoundBlock as FoundBlock, type index_GateChunkReport as GateChunkReport, index_HOSTED_MCP_PATH as HOSTED_MCP_PATH, type index_InviteOutcome as InviteOutcome, type index_InviteOutcomeClient as InviteOutcomeClient, type index_InviteOutcomeInput as InviteOutcomeInput, type index_InviteOutcomeReason as InviteOutcomeReason, index_MANUAL_FETCH_TIMEOUT_MS as MANUAL_FETCH_TIMEOUT_MS, index_MANUAL_MAX_BYTES as MANUAL_MAX_BYTES, index_MANUAL_MAX_REDIRECTS as MANUAL_MAX_REDIRECTS, index_MANUAL_SKILL_NAME as MANUAL_SKILL_NAME, type index_ManualFetch as ManualFetch, index_ManualSync as ManualSync, type index_ManualSyncOptions as ManualSyncOptions, type index_ManualSyncResult as ManualSyncResult, type index_ManualSyncState as ManualSyncState, type index_OutcomeClient as OutcomeClient, type index_ProbeHostedToolsOptions as ProbeHostedToolsOptions, type index_ProbeHostedToolsResult as ProbeHostedToolsResult, index_REQUIRED_HOSTED_TOOLS as REQUIRED_HOSTED_TOOLS, type index_Readiness as Readiness, index_ReceiveLoop as ReceiveLoop, type index_ReceiveLoopClient as ReceiveLoopClient, type index_ReceiveLoopEvent as ReceiveLoopEvent, type index_ReceiveLoopMode as ReceiveLoopMode, type index_ReceiveLoopOptions as ReceiveLoopOptions, type index_ReceiveLoopSocketOptions as ReceiveLoopSocketOptions, type index_ReceiveLoopStatus as ReceiveLoopStatus, type index_RecoverInput as RecoverInput, type index_RegisterInput as RegisterInput, type index_RunEnd as RunEnd, type index_RunRequest as RunRequest, type index_RunStarter as RunStarter, type index_RunningTurn as RunningTurn, type index_ServedManual as ServedManual, type index_SignupAction as SignupAction, type index_SyncManualOptions as SyncManualOptions, index_TEXTS_FETCH_TIMEOUT_MS as TEXTS_FETCH_TIMEOUT_MS, index_TEXTS_REFRESH_MS as TEXTS_REFRESH_MS, index_TEXTS_RETRY_MAX_MS as TEXTS_RETRY_MAX_MS, index_TEXTS_RETRY_MS as TEXTS_RETRY_MS, index_TextsCache as TextsCache, type index_TextsCacheOptions as TextsCacheOptions, type TextsSource$1 as TextsCacheSource, type index_TextsClient as TextsClient, type index_TextsListener as TextsListener, type index_TextsSource as TextsSource, type index_TimerHandle as TimerHandle, type index_TrackedTurn as TrackedTurn, type index_TurnAdmission as TurnAdmission, type index_TurnEnd as TurnEnd, type index_TurnHandle as TurnHandle, type index_TurnOutcome as TurnOutcome, type index_TurnOutcomeInput as TurnOutcomeInput, type index_TurnOutcomeReason as TurnOutcomeReason, type index_TurnRequest as TurnRequest, type index_TurnStarter as TurnStarter, index_TurnTracker as TurnTracker, index_WakeCoalescer as WakeCoalescer, type index_WakeCoalescerOptions as WakeCoalescerOptions, type index_WakeSource as WakeSource, type index_WriteAtomicOptions as WriteAtomicOptions, index_account as account, index_anchor as anchor, index_applyInviteOutcome as applyInviteOutcome, index_applyOutcome as applyOutcome, index_hostedMcpUrl as hostedMcpUrl, index_inviteOutcome as inviteOutcome, index_isTexts as isTexts, index_manualFrontMatter as manualFrontMatter, index_manualVersion as manualVersion, index_probeHostedTools as probeHostedTools, index_renameWithRetry as renameWithRetry, index_replyPrompt as replyPrompt, index_syncManual as syncManual, index_turnOutcome as turnOutcome, index_writeAtomic as writeAtomic };
5139
+ export { type index_AccountAnswer as AccountAnswer, type index_AccountCallOptions as AccountCallOptions, type index_AccountKind as AccountKind, type index_AccountLabels as AccountLabels, type index_AccountQuestion as AccountQuestion, type RunOptions as AccountRunOptions, type RunResult as AccountRunResult, type StepResult as AccountStepResult, type index_AgentChatCallCount as AgentChatCallCount, type index_CheckKeyResult as CheckKeyResult, type index_CoalescerCounters as CoalescerCounters, type index_CoalescerState as CoalescerState, type index_ConfirmedTurnEnd as ConfirmedTurnEnd, type index_CycleOutcome as CycleOutcome, type index_CycleSummary as CycleSummary, index_DEFAULT_MAX_MS as DEFAULT_MAX_MS, index_DEFAULT_QUIET_MS as DEFAULT_QUIET_MS, type index_FailureSource as FailureSource, type index_FindOptions as FindOptions, type index_FoundBlock as FoundBlock, type index_GateChunkReport as GateChunkReport, index_HOSTED_MCP_PATH as HOSTED_MCP_PATH, type index_InviteOutcome as InviteOutcome, type index_InviteOutcomeClient as InviteOutcomeClient, type index_InviteOutcomeInput as InviteOutcomeInput, type index_InviteOutcomeReason as InviteOutcomeReason, index_MANUAL_FETCH_TIMEOUT_MS as MANUAL_FETCH_TIMEOUT_MS, index_MANUAL_MAX_BYTES as MANUAL_MAX_BYTES, index_MANUAL_MAX_REDIRECTS as MANUAL_MAX_REDIRECTS, index_MANUAL_SKILL_NAME as MANUAL_SKILL_NAME, type index_ManualFetch as ManualFetch, index_ManualSync as ManualSync, type index_ManualSyncOptions as ManualSyncOptions, type index_ManualSyncResult as ManualSyncResult, type index_ManualSyncState as ManualSyncState, type index_OutcomeClient as OutcomeClient, type index_ProbeHostedToolsOptions as ProbeHostedToolsOptions, type index_ProbeHostedToolsResult as ProbeHostedToolsResult, type index_ProcessingFailureReport as ProcessingFailureReport, index_REQUIRED_HOSTED_TOOLS as REQUIRED_HOSTED_TOOLS, type index_Readiness as Readiness, index_ReceiveLoop as ReceiveLoop, type index_ReceiveLoopClient as ReceiveLoopClient, type index_ReceiveLoopEvent as ReceiveLoopEvent, type index_ReceiveLoopMode as ReceiveLoopMode, type index_ReceiveLoopOptions as ReceiveLoopOptions, type index_ReceiveLoopSocketOptions as ReceiveLoopSocketOptions, type index_ReceiveLoopStatus as ReceiveLoopStatus, type index_RecoverInput as RecoverInput, type index_RegisterInput as RegisterInput, type index_RunEnd as RunEnd, type index_RunKind as RunKind, type index_RunRequest as RunRequest, type index_RunStarter as RunStarter, type index_RunningTurn as RunningTurn, type index_RuntimeCheck as RuntimeCheck, type index_ServedManual as ServedManual, type index_SignupAction as SignupAction, type index_SyncManualOptions as SyncManualOptions, index_TEXTS_FETCH_TIMEOUT_MS as TEXTS_FETCH_TIMEOUT_MS, index_TEXTS_REFRESH_MS as TEXTS_REFRESH_MS, index_TEXTS_RETRY_MAX_MS as TEXTS_RETRY_MAX_MS, index_TEXTS_RETRY_MS as TEXTS_RETRY_MS, index_TextsCache as TextsCache, type index_TextsCacheOptions as TextsCacheOptions, type TextsSource$1 as TextsCacheSource, type index_TextsClient as TextsClient, type index_TextsListener as TextsListener, type index_TextsSource as TextsSource, type index_TimerHandle as TimerHandle, type index_TrackedTurn as TrackedTurn, type index_TurnAdmission as TurnAdmission, type index_TurnEnd as TurnEnd, type index_TurnHandle as TurnHandle, type index_TurnOutcome as TurnOutcome, type index_TurnOutcomeInput as TurnOutcomeInput, type index_TurnOutcomeReason as TurnOutcomeReason, type index_TurnRequest as TurnRequest, type index_TurnStarter as TurnStarter, index_TurnTracker as TurnTracker, index_WakeCoalescer as WakeCoalescer, type index_WakeCoalescerOptions as WakeCoalescerOptions, type index_WakeSource as WakeSource, type index_WriteAtomicOptions as WriteAtomicOptions, index_account as account, index_anchor as anchor, index_applyInviteOutcome as applyInviteOutcome, index_applyOutcome as applyOutcome, index_conversationRunPrompt as conversationRunPrompt, index_hostedMcpUrl as hostedMcpUrl, index_inviteOutcome as inviteOutcome, index_isTexts as isTexts, index_manualFrontMatter as manualFrontMatter, index_manualVersion as manualVersion, index_probeHostedTools as probeHostedTools, index_renameWithRetry as renameWithRetry, index_replyPrompt as replyPrompt, index_syncManual as syncManual, index_turnOutcome as turnOutcome, index_writeAtomic as writeAtomic };
4577
5140
  }
4578
5141
 
4579
5142
  /**
@@ -4890,4 +5453,4 @@ declare function renderMessageContext(message: Pick<Message, 'sender' | 'created
4890
5453
 
4891
5454
  declare const VERSION: string;
4892
5455
 
4893
- export { ALLOWED_ATTACHMENT_MIME, type AckFrame, type AddContactRequest, type AddMemberRequest, type AddMemberResult, type Agent, AgentChatClient, type AgentChatClientIdentity, type AgentChatClientKind, type AgentChatClientOptions, AgentChatError, type AgentChatErrorResponse, type AgentConversationContext, type AgentProfile, type AgentSettings, type AgentStatus, type AnyWakeFrame, type AnyWakePayload, type ApiError, type AttachmentMime, AwaitingReplyError, type BacklogWarning, type BacklogWarningHandler, type BlockedAgent, BlockedError, type BlockedHandler, type BlockedInfo, type BuildPromptOptions, CONNECT_BUDGET_CLOSE_CODE, CONNECT_BUDGET_MAX_DELAY_MS, CONNECT_BUDGET_MIN_DELAY_MS, type CallOptions, type ClearWakeWebhookResult, type ClientAction, type ConnectBudgetClose, type ConnectHandler, ConnectionError, type Contact, type Conversation, type ConversationListItem, type ConversationParticipant, type ConversationType, type ConversationsResource, type CreateGroupRequest, type CreateUploadRequest, type CreateUploadResponse, DEFAULT_RETRY_POLICY, type DecisionsResource, type DeletedGroupInfo, type DirectConversationLookup, type DisconnectHandler, type DisconnectInfo, EmailExhaustedError, EmailLimitReachedError, ErrorCode, type ErrorHandler, type ErrorInfo, ForbiddenError, type GateClient, type GateModelCall, type GateOutcome, type GateRecordFailure, type GateReply, type GateResult, type GateTexts, type GetTextsOptions, type Group, GroupDeletedError, type GroupDetail, type GroupInvitation, type GroupInvitePolicy, type GroupInviteRule, type GroupMember, type GroupRole, type GroupSettings, type GroupSystemEvent, type GroupSystemEventV1, type GroupsResource, HandleRequiredError, type HeartbeatFrame, type HeartbeatHandler, type HttpMethod, type HttpRequestOptions, type HttpResponse, HttpTransport, type HttpTransportOptions, INBOX_TRAY_DEFAULT_LIMIT, INBOX_TRAY_MAX_LIMIT, INBOX_WAIT_MAX_MS, type InboxCard, type InboxCardGroup, type InboxCardPreview, type InboxCardRelationship, type InboxMode, type InboxResource, type InboxTray, type InboxTrayOptions, type KnownReplyDecisionCategory, MAX_ATTACHMENT_SIZE, type MarkConversationReadRequest, type MarkConversationReadResult, type Message, type MessageContent, type MessageHandler, type MessageStatus, type MessageType, type MuteEntry, type MuteTargetKind, NotFoundError, type OtherWakePayload, OtpAttemptsExhaustedError, type PausedByOwner, type Presence, type PresenceBatchRequest, type PresenceBroadcast, type PresenceStatus, type PresenceUpdate, RateLimitedError, RealtimeClient, type RealtimeOptions, type RealtimeState, RecipientBackloggedError, type RecordReplyDecisionOptions, type RecordReplyDecisionRequest, type RecoverOptions, type RecoverRequest, type RecoverResult, type RecoverVerifyResult, type RegisterOptions, type RegisterRequest, type RegisterResult, type RegisterVerifyResult, type ReminderWakePayload, type RenderOptions, type ReplyDecision, type ReplyDecisionCategory, type ReplyDecisionVerdict, type ReportRequest, type RequestHooks, type RequestInfo, type ResponseInfo, RestrictedError, type RetryInfo, type RetryOption, type RetryPolicy, type RotateKeyResult, type RotateKeyVerifyResult, type RunGateOptions, type SendMessageRequest, type SendMessageResult, type SendableMessageType, type SequenceGapHandler, type SequenceGapInfo, ServerError, type ServerEvent, type SetWakeWebhookOptions, type SetWakeWebhookRequest, type SignupCodeStatus, type SignupFlow, type SignupFlowFields, type SignupFlowKind, type SignupNextStep, type SignupParam, type SignupStartStep, type SignupVerifyStep, type SocketCapability, type StateHandler, type StaticCallOptions, type StoppedHandler, SuspendedError, type SyncEnvelope, type SyncOptions, type SyncPage, type TestWakeResult, type Texts, type TextsResource, type TextsRuntime, type ToolNamer, type TrayInvite, type UnansweredWakePayload, UnauthorizedError, type UpdateAgentRequest, type UpdateContactRequest, type UpdateGroupRequest, VERSION, ValidationError, type Verdict, type VerifyRequest, type VerifyWakeWebhookOptions, type WakeDialect, type WakeFrame, type WakeHandler, type WakePayload, type WakeWebhookHeaders, type WakeWebhookPayload, type WakeWebhookResource, type WakeWebhookState, type WakeWebhookStatus, WakeWebhookVerificationError, type WakeWebhookVerifyDialect, type WakeWebhookVerifyReason, type WsMessage, connectBudgetDelayMs, createAgentChatError, gate, index as integration, isAuthRejectionClose, paginate, parseRetryAfter, renderMessageContext, verifyWakeWebhook, wakePayloadOf };
5456
+ export { ALLOWED_ATTACHMENT_MIME, type AckFrame, type AddContactRequest, type AddMemberRequest, type AddMemberResult, type Agent, AgentChatClient, type AgentChatClientIdentity, type AgentChatClientKind, type AgentChatClientOptions, AgentChatError, type AgentChatErrorResponse, type AgentConversationContext, type AgentProfile, type AgentSettings, type AgentStatus, type AnyWakeFrame, type AnyWakePayload, type ApiError, type AttachmentMime, AwaitingReplyError, type BacklogWarning, type BacklogWarningHandler, type BlockedAgent, BlockedError, type BlockedHandler, type BlockedInfo, type BuildPromptOptions, CONNECT_BUDGET_CLOSE_CODE, CONNECT_BUDGET_MAX_DELAY_MS, CONNECT_BUDGET_MIN_DELAY_MS, type CallOptions, type ClearWakeWebhookResult, type ClientAction, type ConnectBudgetClose, type ConnectHandler, ConnectionError, type Contact, type Conversation, type ConversationListItem, type ConversationParticipant, type ConversationType, type ConversationsResource, type CreateGroupRequest, type CreateUploadRequest, type CreateUploadResponse, DEFAULT_RETRY_POLICY, type DecisionsResource, type DeletedGroupInfo, type DirectConversationLookup, type DisconnectHandler, type DisconnectInfo, EmailExhaustedError, EmailLimitReachedError, ErrorCode, type ErrorHandler, type ErrorInfo, ForbiddenError, type GateClient, type GateModelCall, type GateOutcome, type GateRecordFailure, type GateReply, type GateResult, type GateTexts, type GetMessagesOptions, type GetTextsOptions, type Group, GroupDeletedError, type GroupDetail, type GroupInvitation, type GroupInvitePolicy, type GroupInviteRule, type GroupMember, type GroupRole, type GroupSettings, type GroupSystemEvent, type GroupSystemEventV1, type GroupsResource, HandleRequiredError, type HeartbeatFrame, type HeartbeatHandler, type HttpMethod, type HttpRequestOptions, type HttpResponse, HttpTransport, type HttpTransportOptions, INBOX_TRAY_DEFAULT_LIMIT, INBOX_TRAY_MAX_LIMIT, INBOX_WAIT_MAX_MS, type InboxCard, type InboxCardGroup, type InboxCardPreview, type InboxCardRelationship, type InboxMode, type InboxResource, type InboxTray, type InboxTrayOptions, type KnownReplyDecisionCategory, MAX_ATTACHMENT_SIZE, type MarkConversationReadRequest, type MarkConversationReadResult, type Message, type MessageContent, type MessageCouldNotProcess, type MessageHandler, type MessageStatus, type MessageType, type MessagesPage, type MuteEntry, type MuteTargetKind, NotFoundError, type OtherWakePayload, OtpAttemptsExhaustedError, type PausedByOwner, type Presence, type PresenceBatchRequest, type PresenceBroadcast, type PresenceStatus, type PresenceUpdate, type ProcessingFailureAction, type ProcessingFailureActionName, type ProcessingFailureEvidence, type ProcessingFailureOutcome, RateLimitedError, RealtimeClient, type RealtimeOptions, type RealtimeState, RecipientBackloggedError, type RecordReplyDecisionOptions, type RecordReplyDecisionRequest, type RecoverOptions, type RecoverRequest, type RecoverResult, type RecoverVerifyResult, type RegisterOptions, type RegisterRequest, type RegisterResult, type RegisterVerifyResult, type ReminderWakePayload, type RenderOptions, type ReplyDecision, type ReplyDecisionCategory, type ReplyDecisionVerdict, type ReportProcessingFailureOptions, type ReportProcessingFailureRequest, type ReportRequest, type RequestHooks, type RequestInfo, type ResponseInfo, RestrictedError, type RetryInfo, type RetryOption, type RetryPolicy, type RotateKeyResult, type RotateKeyVerifyResult, type RunGateOptions, type SendMessageRequest, type SendMessageResult, type SendableMessageType, type SequenceGapHandler, type SequenceGapInfo, ServerError, type ServerEvent, type SetWakeWebhookOptions, type SetWakeWebhookRequest, type SignupCodeStatus, type SignupFlow, type SignupFlowFields, type SignupFlowKind, type SignupNextStep, type SignupParam, type SignupStartStep, type SignupVerifyStep, type SocketCapability, type StateHandler, type StaticCallOptions, type StoppedHandler, SuspendedError, type SyncEnvelope, type SyncOptions, type SyncPage, type TestWakeResult, type Texts, type TextsResource, type TextsRuntime, type ToolNamer, type TrayInvite, type UnansweredWakePayload, UnauthorizedError, type UpdateAgentRequest, type UpdateContactRequest, type UpdateGroupRequest, VERSION, ValidationError, type Verdict, type VerifyRequest, type VerifyWakeWebhookOptions, type WakeDialect, type WakeFrame, type WakeHandler, type WakePayload, type WakeWebhookHeaders, type WakeWebhookPayload, type WakeWebhookResource, type WakeWebhookState, type WakeWebhookStatus, WakeWebhookVerificationError, type WakeWebhookVerifyDialect, type WakeWebhookVerifyReason, type WsMessage, connectBudgetDelayMs, createAgentChatError, gate, index as integration, isAuthRejectionClose, paginate, parseRetryAfter, renderMessageContext, verifyWakeWebhook, wakePayloadOf };