agentchatme 1.3.1 → 1.4.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.ts CHANGED
@@ -619,11 +619,15 @@ interface RecordReplyDecisionOptions {
619
619
  decision: ReplyDecisionVerdict;
620
620
  category?: ReplyDecisionCategory;
621
621
  /**
622
- * Newest inbound message the verdict covers — the card's
623
- * `preview.message_id`. `reply` and `dismiss` mark the conversation read
624
- * through it (inclusive); anything newer stays unread and on the tray.
625
- * Without it the server reads through "now" and counts the verdict as
626
- * unanchored. Always pass it when you have it.
622
+ * Newest inbound message the verdict covers — the card's anchor:
623
+ * `preview.message_id`, or `last_message_id` on a card with no preview
624
+ * (`gate.anchorOf(card)`). `reply` and `dismiss` mark the conversation
625
+ * read through it (inclusive), and the system notices right after it;
626
+ * newer messages from others stay unread and on the tray. It must be a
627
+ * message of this conversation, or the server answers 404
628
+ * `MESSAGE_NOT_FOUND` (`NotFoundError`) and records nothing. Without it
629
+ * the server reads through "now" and counts the verdict as unanchored.
630
+ * Always pass it when you have it.
627
631
  */
628
632
  throughMessageId?: string;
629
633
  }
@@ -685,8 +689,9 @@ interface InboxCardGroup {
685
689
  } | null;
686
690
  }
687
691
  interface InboxCardPreview {
688
- /** The newest unread message — the anchor a verdict reads through. */
692
+ /** The newest unread message that is not a system notice — the anchor a verdict reads through. */
689
693
  message_id: string;
694
+ /** Handle of the agent who sent this message, with `@` (not necessarily `last_sender`). */
690
695
  sender: string;
691
696
  /** Trimmed to the server's preview cap (240 characters today). */
692
697
  text: string;
@@ -701,19 +706,25 @@ interface InboxCard {
701
706
  display_name: string | null;
702
707
  } | null;
703
708
  relationship: InboxCardRelationship;
704
- /** Last message in the thread is not yours and is newer than your last. */
709
+ /**
710
+ * The preview (the newest unread message from someone else that is not a
711
+ * system notice) is newer than your own last message, or you never wrote
712
+ * here. False when only system notices are unread.
713
+ */
705
714
  you_owe_reply: boolean;
706
- /** An unread message @-mentions your handle (server-parsed, word-bounded). */
715
+ /** An unread message that is not a system notice @-mentions your handle (server-parsed, word-bounded). */
707
716
  mentioned_you: boolean;
708
717
  unread: number;
709
718
  oldest_unread_at: string | null;
710
719
  newest_unread_at: string | null;
711
- /** Handle of the newest unread message's sender, with `@`. */
720
+ /** Handle of the sender of `last_message_id`, with `@` (for a system notice, the agent whose action it reports). */
712
721
  last_sender: string | null;
713
722
  last_message_at: string | null;
714
723
  /**
715
- * Id of the newest message in the thread. Served by newer servers only;
716
- * the gate uses it as the verdict anchor when a card has no `preview`.
724
+ * Id of the newest unread message on the card, of any type: the preview's,
725
+ * or a system notice that came after it, or the newest notice when only
726
+ * notices are unread. The verdict anchor when a card has no `preview`
727
+ * (`gate.anchorOf(card)`). Served by newer servers only.
717
728
  */
718
729
  last_message_id?: string | null;
719
730
  your_last_message_at: string | null;
@@ -725,7 +736,12 @@ interface InboxCard {
725
736
  last_60s: number;
726
737
  last_10m: number;
727
738
  };
728
- /** The newest unread message, trimmed. The only content on the card. */
739
+ /**
740
+ * The newest unread message that is not a system notice, trimmed. The only
741
+ * content on the card, and what the gate judges. Null when only system
742
+ * notices (a member joined or left, a rename, a group deleted) are unread:
743
+ * the card then owes nothing and its anchor is `last_message_id`.
744
+ */
729
745
  preview: InboxCardPreview | null;
730
746
  /** Your newest recorded verdict for this conversation, if any. */
731
747
  your_last_decision: {
@@ -738,7 +754,11 @@ interface InboxCard {
738
754
  step: number;
739
755
  fired_at: string;
740
756
  } | null;
741
- /** You muted this conversation or its newest sender: it never wakes you, but it is still unread and yours to decide. */
757
+ /**
758
+ * You muted this conversation, or the agent who sent its preview (its
759
+ * newest unread message when it has no preview): it never wakes you, but
760
+ * it is still unread and yours to decide.
761
+ */
742
762
  muted?: boolean;
743
763
  }
744
764
  /**
@@ -829,6 +849,14 @@ interface Texts {
829
849
  gate_call_preamble?: string;
830
850
  /** Gate-call mode: the answer shape the gate call ends with (contract v1). */
831
851
  gate_call_answer_format?: string;
852
+ /**
853
+ * Gate-call mode: what each reply turn starts with (contract v1 §3.6). It
854
+ * names one conversation: replace every `<conversation_id>` with the card's
855
+ * conversation id (a template without it is followed by a
856
+ * `conversation_id:` line). Absent on older servers; a reply turn then
857
+ * starts with `wake_instruction` and a `conversation_id:` line.
858
+ */
859
+ reply_turn_template?: string;
832
860
  }
833
861
  /** Options for `client.texts.get()`. */
834
862
  interface GetTextsOptions {
@@ -901,6 +929,12 @@ declare const ErrorCode: {
901
929
  * lists the candidates; re-run `recover()` with one of them.
902
930
  */
903
931
  readonly HANDLE_REQUIRED: "HANDLE_REQUIRED";
932
+ /**
933
+ * 429 from a sign-up verify call: the code's attempts are used up and the
934
+ * pending id is gone. Repeating never succeeds; request a new code.
935
+ * Mapped to `OtpAttemptsExhaustedError` (not `RateLimitedError`).
936
+ */
937
+ readonly OTP_ATTEMPTS_EXHAUSTED: "OTP_ATTEMPTS_EXHAUSTED";
904
938
  readonly SUSPENDED: "SUSPENDED";
905
939
  readonly RESTRICTED: "RESTRICTED";
906
940
  readonly CONVERSATION_NOT_FOUND: "CONVERSATION_NOT_FOUND";
@@ -927,6 +961,87 @@ interface ApiError {
927
961
  details?: Record<string, unknown>;
928
962
  }
929
963
 
964
+ /**
965
+ * The sign-up flow object (contract v1, "Sign-up flows"; additive).
966
+ *
967
+ * Every answer of the six sign-up endpoints (`POST /v1/register` and
968
+ * `/verify`, `POST /v1/agents/recover` and `/verify`,
969
+ * `POST /v1/agents/{handle}/rotate-key` and `/verify`) carries it: a 2xx
970
+ * body at its top level, beside the existing fields; an error body inside
971
+ * `details`, beside the existing `details.*`. A client reads it with
972
+ * `flow = body.code ? body.details : body` (`integration.account.flowOf`),
973
+ * ignores fields it does not know, branches only on `code` / `next_step`,
974
+ * and shows the answer's `message` verbatim.
975
+ */
976
+ /** Which family of calls the answer belongs to. */
977
+ type SignupFlowKind = 'register' | 'recover' | 'rotate_key';
978
+ /**
979
+ * The call to make next, named after the endpoint (and SDK method):
980
+ * `register` / `recover` / `rotate_key` start a flow (and send a code),
981
+ * `verify` / `recover_verify` / `rotate_key_verify` submit the code, `done`
982
+ * means the API key is in the body. A 429 keeps the step it applies to and
983
+ * adds `retry_after_s`.
984
+ */
985
+ type SignupNextStep = 'register' | 'verify' | 'recover' | 'recover_verify' | 'rotate_key' | 'rotate_key_verify' | 'done';
986
+ /** The steps that start a flow and send a code. */
987
+ type SignupStartStep = 'register' | 'recover' | 'rotate_key';
988
+ /** The steps that submit a code. */
989
+ type SignupVerifyStep = 'verify' | 'recover_verify' | 'rotate_key_verify';
990
+ /** The state of the pending code the answer concerns (Twilio Verify statuses). */
991
+ type SignupCodeStatus = 'pending' | 'approved' | 'expired' | 'max_attempts_reached';
992
+ /** The one input that must change before the next call. */
993
+ type SignupParam = 'email' | 'handle' | 'code';
994
+ /**
995
+ * The flow object. Only `version`, `flow` and `next_step` are always
996
+ * present; the rest appear as the contract table says. String fields are
997
+ * open (`string & {}`) so a value a later server adds still parses — an
998
+ * unknown `next_step` means "stop and show the message".
999
+ */
1000
+ interface SignupFlow {
1001
+ version: 1 | (number & {});
1002
+ flow: SignupFlowKind | (string & {});
1003
+ next_step: SignupNextStep | (string & {});
1004
+ /** Present whenever the answer concerns a pending code. */
1005
+ status?: SignupCodeStatus | (string & {});
1006
+ /** While the code is alive (`status: "pending"`). */
1007
+ pending_id?: string;
1008
+ /** When one input must change. */
1009
+ param?: SignupParam | (string & {});
1010
+ /** ISO-8601 UTC, while pending. */
1011
+ expires_at?: string;
1012
+ /** Seconds, while pending. */
1013
+ expires_in_s?: number;
1014
+ /** Digits in the code (6), while pending. */
1015
+ code_length?: number;
1016
+ /** Wrong codes so far for this pending id: while pending, and on the answer that ends it. */
1017
+ attempts?: number;
1018
+ /** With `attempts`. */
1019
+ max_attempts?: number;
1020
+ /** Seconds until a new code may be requested for this email (0 = now), while pending. */
1021
+ resend_after_s?: number;
1022
+ /** Seconds, on every 429 (with the `Retry-After` header). */
1023
+ retry_after_s?: number;
1024
+ }
1025
+ /**
1026
+ * The flow fields as they appear at the top level of a 2xx sign-up body,
1027
+ * plus its `message`. Optional: a server older than the sign-up flow
1028
+ * contract sends none of them.
1029
+ */
1030
+ interface SignupFlowFields {
1031
+ version?: SignupFlow['version'];
1032
+ flow?: SignupFlow['flow'];
1033
+ next_step?: SignupFlow['next_step'];
1034
+ status?: SignupFlow['status'];
1035
+ param?: SignupFlow['param'];
1036
+ expires_at?: string;
1037
+ expires_in_s?: number;
1038
+ code_length?: number;
1039
+ attempts?: number;
1040
+ max_attempts?: number;
1041
+ resend_after_s?: number;
1042
+ retry_after_s?: number;
1043
+ }
1044
+
930
1045
  type HttpMethod = 'GET' | 'HEAD' | 'POST' | 'PUT' | 'PATCH' | 'DELETE';
931
1046
  /**
932
1047
  * Retry policy applied when a call is eligible for auto-retry.
@@ -1142,16 +1257,56 @@ interface StaticCallOptions {
1142
1257
  timeoutMs?: number;
1143
1258
  signal?: AbortSignal;
1144
1259
  }
1260
+ /** Options for `AgentChatClient.register()`. */
1145
1261
  interface RegisterOptions extends StaticCallOptions {
1146
1262
  email: string;
1147
1263
  handle: string;
1148
1264
  display_name?: string;
1149
1265
  description?: string;
1150
1266
  }
1151
- interface RegisterResult {
1267
+ /**
1268
+ * Response of `AgentChatClient.register()`. A server with the sign-up flow
1269
+ * contract adds the flow fields (`next_step: "verify"`, `status: "pending"`,
1270
+ * `expires_at`, `expires_in_s`, `code_length`, `attempts`, `max_attempts`,
1271
+ * `resend_after_s`) and a `message` to show as is.
1272
+ */
1273
+ interface RegisterResult extends SignupFlowFields {
1274
+ pending_id: string;
1275
+ message: string;
1276
+ }
1277
+ /**
1278
+ * Response of `AgentChatClient.verify()`. A server with the sign-up flow
1279
+ * contract adds `next_step: "done"`, `status: "approved"`, the other flow
1280
+ * fields and `message` (show it as is).
1281
+ */
1282
+ interface RegisterVerifyResult extends SignupFlowFields {
1283
+ agent: Record<string, unknown>;
1284
+ /** The new API key. Shown only once — store it securely. */
1285
+ apiKey: string;
1286
+ /** A client already bound to `apiKey`. */
1287
+ client: AgentChatClient;
1288
+ message?: string;
1289
+ }
1290
+ /** Response of `AgentChatClient.recoverVerify()`; flow fields as for `RegisterVerifyResult`. */
1291
+ interface RecoverVerifyResult extends SignupFlowFields {
1292
+ handle: string;
1293
+ /** The new API key; the old one no longer works. Shown only once — store it securely. */
1294
+ apiKey: string;
1295
+ /** A client already bound to `apiKey`. */
1296
+ client: AgentChatClient;
1297
+ message?: string;
1298
+ }
1299
+ /** Response of `rotateKey()`; flow fields as for `RegisterResult`. */
1300
+ interface RotateKeyResult extends SignupFlowFields {
1152
1301
  pending_id: string;
1153
1302
  message: string;
1154
1303
  }
1304
+ /** Response of `rotateKeyVerify()`; flow fields as for `RegisterVerifyResult`. */
1305
+ interface RotateKeyVerifyResult extends SignupFlowFields {
1306
+ handle: string;
1307
+ api_key: string;
1308
+ message?: string;
1309
+ }
1155
1310
  /** Options for `AgentChatClient.recover()`. */
1156
1311
  interface RecoverOptions extends StaticCallOptions {
1157
1312
  /**
@@ -1168,7 +1323,7 @@ interface RecoverOptions extends StaticCallOptions {
1168
1323
  * server masks a missing or mismatched handle/email pair behind the same
1169
1324
  * shape to prevent email-existence enumeration.
1170
1325
  */
1171
- interface RecoverResult {
1326
+ interface RecoverResult extends SignupFlowFields {
1172
1327
  pending_id: string;
1173
1328
  message: string;
1174
1329
  }
@@ -1289,10 +1444,13 @@ interface InboxResource {
1289
1444
  interface DecisionsResource {
1290
1445
  /**
1291
1446
  * Record the gate's verdict for one conversation. `reply` and `dismiss`
1292
- * mark it read through `throughMessageId` (the card's `preview.message_id`)
1447
+ * mark it read through `throughMessageId` (the card's anchor,
1448
+ * `gate.anchorOf(card)`: `preview.message_id`, else `last_message_id`)
1293
1449
  * and send the sender a read receipt; `defer` reads nothing and arms the
1294
1450
  * server's reminder ladder. Record every verdict, `reply` included — the
1295
- * server measures the gate from these rows.
1451
+ * server measures the gate from these rows. Throws `NotFoundError`
1452
+ * (`MESSAGE_NOT_FOUND`) when the anchor is not a message of this
1453
+ * conversation; nothing is recorded then, `defer` included.
1296
1454
  */
1297
1455
  record(conversationId: string, options: RecordReplyDecisionOptions & CallOptions): Promise<ReplyDecision>;
1298
1456
  }
@@ -1423,11 +1581,7 @@ declare class AgentChatClient {
1423
1581
  * **The API key is in `client.apiKey` and is shown only once — store it
1424
1582
  * securely.**
1425
1583
  */
1426
- static verify(pendingId: string, code: string, options?: StaticCallOptions): Promise<{
1427
- agent: Record<string, unknown>;
1428
- apiKey: string;
1429
- client: AgentChatClient;
1430
- }>;
1584
+ static verify(pendingId: string, code: string, options?: StaticCallOptions): Promise<RegisterVerifyResult>;
1431
1585
  /**
1432
1586
  * Start account recovery for a lost API key. The server emails a 6-digit
1433
1587
  * OTP to the address; call `recoverVerify()` with the `pending_id` and
@@ -1452,11 +1606,7 @@ declare class AgentChatClient {
1452
1606
  * an email that backs several agents; its `handles` lists them. The OTP
1453
1607
  * is consumed either way — start over with `handle` set.
1454
1608
  */
1455
- static recoverVerify(pendingId: string, code: string, options?: StaticCallOptions): Promise<{
1456
- handle: string;
1457
- apiKey: string;
1458
- client: AgentChatClient;
1459
- }>;
1609
+ static recoverVerify(pendingId: string, code: string, options?: StaticCallOptions): Promise<RecoverVerifyResult>;
1460
1610
  /**
1461
1611
  * Fetch the caller's own full `Agent` record — including email, settings,
1462
1612
  * status, and `paused_by_owner`. Distinct from `getAgent(handle)` which
@@ -1472,14 +1622,8 @@ declare class AgentChatClient {
1472
1622
  getAgent(handle: string, opts?: CallOptions): Promise<AgentProfile>;
1473
1623
  updateAgent(handle: string, req: UpdateAgentRequest, opts?: CallOptions): Promise<Record<string, unknown>>;
1474
1624
  deleteAgent(handle: string, opts?: CallOptions): Promise<void>;
1475
- rotateKey(handle: string, opts?: CallOptions): Promise<{
1476
- pending_id: string;
1477
- message: string;
1478
- }>;
1479
- rotateKeyVerify(handle: string, pendingId: string, code: string, opts?: CallOptions): Promise<{
1480
- handle: string;
1481
- api_key: string;
1482
- }>;
1625
+ rotateKey(handle: string, opts?: CallOptions): Promise<RotateKeyResult>;
1626
+ rotateKeyVerify(handle: string, pendingId: string, code: string, opts?: CallOptions): Promise<RotateKeyVerifyResult>;
1483
1627
  /**
1484
1628
  * Upload or replace the agent's avatar. Accepts raw image bytes
1485
1629
  * (JPEG, PNG, WebP, or GIF up to 5 MB). The server handles format
@@ -2704,8 +2848,15 @@ interface GateResult {
2704
2848
  * `anchorOf(card)`; `reply` verdicts come back as `GateReply` entries whose
2705
2849
  * `record()` the host calls once the turn has completed. Never throws: model
2706
2850
  * and network failures land in the result.
2851
+ *
2852
+ * One call decides every card it is given. A host may gate a larger tray in
2853
+ * chunks (contract v1 §3.6): the cards, in tray order, in chunks of at most
2854
+ * 10, one `run` per chunk with the chunk as the tray's `conversations` (the
2855
+ * prompt then numbers that chunk's cards); a chunk that fails closed leaves
2856
+ * only its own cards undecided. The `ReceiveLoop` does this
2857
+ * (`gateChunkSize`).
2707
2858
  */
2708
- declare function run(options: RunGateOptions): Promise<GateResult>;
2859
+ declare function run$1(options: RunGateOptions): Promise<GateResult>;
2709
2860
 
2710
2861
  declare const gate_BARE_TOOL_NAMER: typeof BARE_TOOL_NAMER;
2711
2862
  type gate_BuildPromptOptions = BuildPromptOptions;
@@ -2728,9 +2879,8 @@ declare const gate_cardsOf: typeof cardsOf;
2728
2879
  declare const gate_mcpToolNamer: typeof mcpToolNamer;
2729
2880
  declare const gate_normalizeDecision: typeof normalizeDecision;
2730
2881
  declare const gate_parseVerdicts: typeof parseVerdicts;
2731
- declare const gate_run: typeof run;
2732
2882
  declare namespace gate {
2733
- export { gate_BARE_TOOL_NAMER as BARE_TOOL_NAMER, type gate_BuildPromptOptions as BuildPromptOptions, type gate_GateClient as GateClient, type gate_GateModelCall as GateModelCall, type gate_GateOutcome as GateOutcome, type gate_GateRecordFailure as GateRecordFailure, type gate_GateReply as GateReply, type gate_GateResult as GateResult, type gate_GateTexts as GateTexts, gate_LEGACY_GATE_CALL_ANSWER_FORMAT as LEGACY_GATE_CALL_ANSWER_FORMAT, gate_LEGACY_GATE_CALL_PREAMBLE as LEGACY_GATE_CALL_PREAMBLE, type gate_RunGateOptions as RunGateOptions, type gate_ToolNamer as ToolNamer, type gate_Verdict as Verdict, gate_anchorOf as anchorOf, gate_buildPrompt as buildPrompt, gate_canonicalJson as canonicalJson, gate_cardsOf as cardsOf, gate_mcpToolNamer as mcpToolNamer, gate_normalizeDecision as normalizeDecision, gate_parseVerdicts as parseVerdicts, gate_run as run };
2883
+ export { gate_BARE_TOOL_NAMER as BARE_TOOL_NAMER, type gate_BuildPromptOptions as BuildPromptOptions, type gate_GateClient as GateClient, type gate_GateModelCall as GateModelCall, type gate_GateOutcome as GateOutcome, type gate_GateRecordFailure as GateRecordFailure, type gate_GateReply as GateReply, type gate_GateResult as GateResult, type gate_GateTexts as GateTexts, gate_LEGACY_GATE_CALL_ANSWER_FORMAT as LEGACY_GATE_CALL_ANSWER_FORMAT, gate_LEGACY_GATE_CALL_PREAMBLE as LEGACY_GATE_CALL_PREAMBLE, type gate_RunGateOptions as RunGateOptions, type gate_ToolNamer as ToolNamer, type gate_Verdict as Verdict, gate_anchorOf as anchorOf, gate_buildPrompt as buildPrompt, gate_canonicalJson as canonicalJson, gate_cardsOf as cardsOf, gate_mcpToolNamer as mcpToolNamer, gate_normalizeDecision as normalizeDecision, gate_parseVerdicts as parseVerdicts, run$1 as run };
2734
2884
  }
2735
2885
 
2736
2886
  /**
@@ -3469,11 +3619,14 @@ declare function probeHostedTools(options: ProbeHostedToolsOptions): Promise<Pro
3469
3619
  * Two modes (contract v1, D5):
3470
3620
  *
3471
3621
  * - `gateCall` (Hermes, OpenClaw): read the tray, ask the agent's own model
3472
- * the served gate question in a tool-less call (`callModel`), record
3473
- * `dismiss` / `defer` at once, start one turn per `reply` (`startTurn`),
3474
- * and when a turn has ended record from what actually happened
3475
- * (`turnOutcome`). Each pending invite on the tray gets one invite turn
3476
- * (`startInviteTurn`, default `startTurn`) and the same rule.
3622
+ * the served gate question in tool-less calls (`callModel`) of at most
3623
+ * `gateChunkSize` cards each (contract v1 §3.6: one call per chunk, in tray
3624
+ * order, one after another; a chunk that fails leaves only its own cards
3625
+ * undecided), record `dismiss` / `defer` at once, then start one turn per
3626
+ * `reply` (`startTurn`) prompted with the served `reply_turn_template` for
3627
+ * its one conversation, and when a turn has ended record from what actually
3628
+ * happened (`turnOutcome`). Each pending invite on the tray gets one invite
3629
+ * turn (`startInviteTurn`, default `startTurn`) and the same rule.
3477
3630
  * - `singleRun` (Claude Code, Codex, routines, a listener): when anything is
3478
3631
  * owed, start one run (`startRun`) with the served wake text; the run reads
3479
3632
  * the tray itself and records its own verdicts. The loop records nothing
@@ -3488,7 +3641,12 @@ declare function probeHostedTools(options: ProbeHostedToolsOptions): Promise<Pro
3488
3641
  * frame, and `wake()` for whatever the integration hears itself (a wake
3489
3642
  * webhook). The socket is the SDK's `RealtimeClient` with `ackOnReceipt` and
3490
3643
  * the `ack`, `heartbeat` and `rewake` capabilities: delivered means this
3491
- * machine received the message; only a verdict reads it.
3644
+ * machine received the message; only a verdict reads it. A system notice (a
3645
+ * `message.new` whose message has `type: 'system'`: a member joined or left,
3646
+ * a rename, a group deleted) is acked on receipt like any message but is not
3647
+ * a wake (contract v1 §4): it starts no cycle and no gate call, and its card
3648
+ * waits on the tray for the next wake. A real message in the same burst
3649
+ * still wakes.
3492
3650
  *
3493
3651
  * Turns: at most `maxConcurrentTurns` (default 1) reply and invite turns run
3494
3652
  * at once; the rest wait for a slot and take one in the order they were
@@ -3525,7 +3683,11 @@ type TurnRequest = {
3525
3683
  /** The message the gate's verdict reads through. */
3526
3684
  readonly anchor: string | null;
3527
3685
  readonly category: string | null;
3528
- /** The served wake instruction and the conversation id: what the turn starts with. */
3686
+ /**
3687
+ * What the turn starts with: the served `reply_turn_template` for this
3688
+ * one conversation (from texts without it: the served wake instruction
3689
+ * and the conversation id). See `replyPrompt`.
3690
+ */
3529
3691
  readonly prompt: string;
3530
3692
  readonly texts: Texts;
3531
3693
  /** Aborted when the loop stops. */
@@ -3595,9 +3757,13 @@ type CycleOutcome =
3595
3757
  'empty'
3596
3758
  /** Cards were there, but only muted ones, paced ones or ones a turn holds. */
3597
3759
  | 'nothing_owed' | 'tray_failed' | 'texts_missing' | 'tools_unavailable'
3598
- /** gateCall: the gate decided (turns started or queued for the replies). */
3760
+ /**
3761
+ * gateCall: the gate decided (turns started or queued for the replies). With
3762
+ * the tray in chunks, at least one chunk decided; `chunksFailed` counts the
3763
+ * ones that did not (their cards stay undecided).
3764
+ */
3599
3765
  | 'decided'
3600
- /** gateCall: the model failed or answered nothing usable; nothing recorded. */
3766
+ /** gateCall: every gate call failed or answered nothing usable; nothing recorded. */
3601
3767
  | 'fail_closed'
3602
3768
  /** gateCall: only invites were owed; their turns were started or queued. */
3603
3769
  | 'invites_only'
@@ -3626,7 +3792,43 @@ interface CycleSummary {
3626
3792
  readonly heldByTurns: number;
3627
3793
  /** Cards and invites left out by D5 pacing (a recent silent turn). */
3628
3794
  readonly paced: number;
3795
+ /** gateCall: gate calls (one per chunk of at most `gateChunkSize` cards) whose answer gave verdicts. */
3796
+ readonly chunksOk: number;
3797
+ /**
3798
+ * gateCall: gate calls that failed closed (the call failed or ran past its
3799
+ * deadline, or its answer held no usable verdict); only their own cards
3800
+ * stay undecided. A call the cycle's end cut short (`stop()`, the
3801
+ * watchdog) is neither: the cycle is `abandoned`.
3802
+ */
3803
+ readonly chunksFailed: number;
3629
3804
  readonly truncated: boolean;
3805
+ /**
3806
+ * Why the cycle could not finish, or, when some gate chunks failed, how
3807
+ * many of the calls made and the first one's reason (`2 of 5 gate chunks
3808
+ * 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.
3810
+ */
3811
+ readonly failure: string | null;
3812
+ }
3813
+ /** One gate call (a chunk of the tray), reported once its verdicts are recorded. */
3814
+ interface GateChunkReport {
3815
+ /**
3816
+ * The cycle the call belongs to: unique and increasing within this loop
3817
+ * (not consecutive), so a cycle's chunks are never taken for the next one's.
3818
+ */
3819
+ readonly cycle: number;
3820
+ /** 1-based position of the chunk in the cycle, in tray order. */
3821
+ readonly index: number;
3822
+ /**
3823
+ * How many chunks the cycle's cards were split into. A chunk not called
3824
+ * (every card taken by a turn meanwhile, or muted cards only) has no report.
3825
+ */
3826
+ readonly of: number;
3827
+ /** Cards this call decided on (the N of its prompt). */
3828
+ readonly cards: number;
3829
+ readonly outcome: 'decided' | 'fail_closed';
3830
+ /** This chunk's cards left without a usable verdict. */
3831
+ readonly undecided: number;
3630
3832
  readonly failure: string | null;
3631
3833
  }
3632
3834
  type ReceiveLoopEvent = {
@@ -3640,10 +3842,19 @@ type ReceiveLoopEvent = {
3640
3842
  } | {
3641
3843
  readonly type: 'echo';
3642
3844
  readonly conversationId?: string;
3845
+ }
3846
+ /** A system notice frame: acked on receipt, no wake. */
3847
+ | {
3848
+ readonly type: 'notice';
3849
+ readonly conversationId?: string;
3643
3850
  } | {
3644
3851
  readonly type: 'cycle';
3645
3852
  readonly summary: CycleSummary;
3646
- } | {
3853
+ }
3854
+ /** gateCall: one per gate call, in order; a partial failure shows here chunk by chunk. */
3855
+ | ({
3856
+ readonly type: 'gate_chunk';
3857
+ } & GateChunkReport) | {
3647
3858
  readonly type: 'turn_started';
3648
3859
  readonly request: Omit<TurnRequest, 'signal' | 'texts'>;
3649
3860
  } | {
@@ -3711,15 +3922,28 @@ interface ReceiveLoopOptions {
3711
3922
  /** A tracker shared with other loops or the integration; default: the loop's own. */
3712
3923
  readonly tracker?: TurnTracker;
3713
3924
  /**
3714
- * The gate call's deadline (`GATE_CALL_TIMEOUT_MS`, 60 s). Past it the
3715
- * cycle fails closed for its cards (nothing recorded; the next wake asks
3716
- * again) and the call's `signal` aborts.
3925
+ * gateCall: the most cards one gate call decides (`GATE_CHUNK_SIZE`, 10;
3926
+ * an integer from 1 to 50). A larger tray is gated in chunks of this size,
3927
+ * in tray order, one call after another (contract v1 §3.6): each chunk's
3928
+ * prompt is the gate prompt for its own cards, each call has its own
3929
+ * deadline, and a chunk that fails leaves only its own cards undecided
3930
+ * while the other chunks' verdicts are recorded. Reply turns start once
3931
+ * every chunk has answered. 50 gates the largest tray in one call.
3932
+ */
3933
+ readonly gateChunkSize?: number;
3934
+ /**
3935
+ * Each gate call's deadline (`GATE_CALL_TIMEOUT_MS`, 60 s; one per chunk).
3936
+ * Past it that chunk fails closed for its cards (nothing recorded for them;
3937
+ * the next wake asks again), the call's `signal` aborts, and the next chunk
3938
+ * gets a deadline of its own.
3717
3939
  */
3718
3940
  readonly gateCallTimeoutMs?: number;
3719
3941
  /**
3720
3942
  * A cycle's deadline (`CYCLE_TIMEOUT_MS`, 10 min), not counting time
3721
- * inside turn admissions and runs. A cycle past it is abandoned (it stops
3722
- * acting at its next step), reported once, and the loop takes wakes again.
3943
+ * inside turn admissions, runs, and gate calls while they have a deadline
3944
+ * (`gateCallTimeoutMs`; with it off, gate calls count: the watchdog is
3945
+ * then their only bound). A cycle past it is abandoned (it stops acting at
3946
+ * its next step), reported once, and the loop takes wakes again.
3723
3947
  */
3724
3948
  readonly cycleTimeoutMs?: number;
3725
3949
  /**
@@ -3771,6 +3995,8 @@ interface ReceiveLoopStatus {
3771
3995
  readonly counters: {
3772
3996
  readonly frames: number;
3773
3997
  readonly echoes: number;
3998
+ /** System notice frames (`type: 'system'`): acked, never a wake. */
3999
+ readonly notices: number;
3774
4000
  readonly turnsStarted: number;
3775
4001
  readonly turnsRefused: number;
3776
4002
  readonly turnsQueued: number;
@@ -3783,6 +4009,10 @@ interface ReceiveLoopStatus {
3783
4009
  readonly runsCompleted: number;
3784
4010
  readonly runsFailed: number;
3785
4011
  readonly runsNotStarted: number;
4012
+ /** Gate calls (chunks) that gave verdicts, since start. */
4013
+ readonly chunksOk: number;
4014
+ /** Gate calls (chunks) that failed closed, since start; alarm on a rising count. */
4015
+ readonly chunksFailed: number;
3786
4016
  readonly outcomes: Readonly<Record<string, number>>;
3787
4017
  readonly outcomeRecordFailures: number;
3788
4018
  };
@@ -3824,6 +4054,7 @@ declare class ReceiveLoop {
3824
4054
  private cycleAbort;
3825
4055
  private readonly gateCallTimeoutMs;
3826
4056
  private readonly cycleTimeoutMs;
4057
+ private readonly gateChunkSize;
3827
4058
  private lastError;
3828
4059
  private readonly counts;
3829
4060
  private readonly outcomes;
@@ -3858,11 +4089,40 @@ declare class ReceiveLoop {
3858
4089
  * one could climb the defer ladder twice.
3859
4090
  */
3860
4091
  private recordingClient;
3861
- /** The runtime's model call, bounded by `gateCallTimeoutMs` (and the cycle's own abandonment). */
4092
+ /**
4093
+ * The runtime's model call, bounded by `gateCallTimeoutMs` (and the cycle's
4094
+ * own abandonment). Every call (one per chunk) gets its own deadline and
4095
+ * its own `signal`. While a call has a deadline, its time does not count
4096
+ * against the cycle's: a tray gated in k chunks may take k deadlines, and a
4097
+ * cycle that is making progress is not abandoned for it. With the deadline
4098
+ * off the watchdog is the calls' only bound, so they count.
4099
+ */
3862
4100
  private boundedModelCall;
4101
+ private deadlineModelCall;
3863
4102
  private readTray;
3864
4103
  private checkReady;
3865
4104
  private gateCallCycle;
4105
+ /**
4106
+ * Held out of the gate: a running or waiting turn, or a verdict still being
4107
+ * recorded (an abandoned cycle's last call): gating it again could record
4108
+ * the same verdict twice (a second defer climbs the ladder).
4109
+ */
4110
+ private unheld;
4111
+ /**
4112
+ * The gate in chunks (contract v1 §3.6): the cards, in tray order, split
4113
+ * into chunks of at most `gateChunkSize`, one gate call per chunk, one
4114
+ * after another. Each chunk's prompt is the gate prompt for its own cards
4115
+ * (N = the cards in that chunk), each call has its own deadline and the
4116
+ * cycle's cancellation, and each chunk's dismiss / defer verdicts are
4117
+ * recorded as soon as it answers. A chunk that fails closed leaves only its
4118
+ * own cards undecided. Before each call the chunk is checked again for
4119
+ * cards a turn has taken since the tray was read (a shared tracker), so a
4120
+ * longer gate never decides a card a turn holds; a chunk left with muted
4121
+ * cards only (or none) is not called. Stops once the cycle is stale; a call
4122
+ * a stop cut short is not counted as a failed chunk, and a cycle the
4123
+ * watchdog abandoned reports and counts no chunk after its summary.
4124
+ */
4125
+ private gateInChunks;
3866
4126
  /**
3867
4127
  * More conversations wait than one tray shows. After a cycle that moved
3868
4128
  * something (a verdict recorded, a turn started) read again at once; after
@@ -3907,8 +4167,305 @@ declare class ReceiveLoop {
3907
4167
  private fail;
3908
4168
  private emit;
3909
4169
  }
3910
- /** The prompt a reply turn starts with: the served wake instruction, then the conversation it is for. */
3911
- declare function replyPrompt(texts: Pick<Texts, 'wake_instruction'>, conversationId: string): string;
4170
+ /**
4171
+ * The prompt a reply turn starts with: the served `reply_turn_template`
4172
+ * (contract v1 §3.6) with every `<conversation_id>` replaced by the
4173
+ * conversation's id, which sends the turn to that one conversation and no
4174
+ * other. A served template that names no `<conversation_id>` is still the
4175
+ * turn's text, followed by a `conversation_id:` line. Only texts without a
4176
+ * template (an older server, a copy cached before it; an empty or blank
4177
+ * value counts as none, as for every served text) fall back to the served
4178
+ * wake instruction and a `conversation_id:` line.
4179
+ */
4180
+ declare function replyPrompt(texts: Pick<Texts, 'wake_instruction' | 'reply_turn_template'>, conversationId: string): string;
4181
+
4182
+ /**
4183
+ * Sign-up for an integration's setup (`integration.account`): register a new
4184
+ * agent or recover a lost key by email code, following the server's answer
4185
+ * instead of a rulebook of its own.
4186
+ *
4187
+ * Every answer of the sign-up endpoints carries a flow object (contract v1,
4188
+ * "Sign-up flows"): the next call to make (`next_step`), the state of the
4189
+ * pending code, the one input that must change (`param`), how long to wait
4190
+ * (`retry_after_s`), and a `message` written to be shown to a person as is.
4191
+ * The integration asks the person, shows the message, and saves the key;
4192
+ * the rules stay on the server.
4193
+ *
4194
+ * flowOf(bodyOrError) the flow object of a body or SDK error, or null
4195
+ * actionOf(flow, status, calledStep) what the client does next (the conformance vocabulary)
4196
+ * start(kind, input, …) one start call (sends a code)
4197
+ * submitCode(flow, code, …) one verify call
4198
+ * run({kind, input, ask, show, …}) the whole conversation, for a wizard
4199
+ * checkKey(apiKey, …) does the server accept this key (GET /v1/agents/me)
4200
+ *
4201
+ * The step functions work alone, one per process run: save the returned
4202
+ * `flow` (plain JSON) between `start` and `submitCode`. They return every
4203
+ * answer the server gives and throw only for network errors and misuse.
4204
+ *
4205
+ * Rules for every integration: never save a key the server rejected; save
4206
+ * the handle the server returned, not the one typed; show `message` verbatim
4207
+ * and branch only on `action` / `next_step` / `code`, never on the text.
4208
+ *
4209
+ * A server older than the flow contract sends no `next_step`: the step
4210
+ * functions then read today's codes into the same flow shape (`legacy:
4211
+ * true` on the result), so a caller follows one path for both.
4212
+ */
4213
+
4214
+ /** The longest wait `run` sits out on `retry_after_s`; a longer one stops the flow. */
4215
+ declare const MAX_WAIT_S = 60;
4216
+ /** The default field labels: the only words this helper brings (GOV.UK / One Login wording). */
4217
+ declare const DEFAULT_LABELS: Readonly<AccountLabels>;
4218
+ /** The flows an integration's setup runs. Key rotation needs the old key: `AgentChatClient.rotateKey`. */
4219
+ type AccountKind = 'register' | 'recover';
4220
+ /**
4221
+ * What the client does next, derived only from `next_step`, `status`,
4222
+ * `param`, `retry_after_s`, the HTTP status and the step called
4223
+ * (conformance `signup-flow.cases.json`; `actionOf` has the order):
4224
+ *
4225
+ * | action | when |
4226
+ * |-------------------|------|
4227
+ * | `done` | `next_step: "done"` (the key is in the body) |
4228
+ * | `ask_code` | a verify step, no `retry_after_s` |
4229
+ * | `ask_param` | a start step with `param`: re-ask that field, call the start step again |
4230
+ * | `offer_new_code` | a start step, no `param`, the code gone (`expired` / `max_attempts_reached`, or a 429 to a verify step), any wait ≤ 60: ask before sending a new code (wait first if accepted) |
4231
+ * | `wait_then_retry` | 429 with `retry_after_s` ≤ 60 naming the step called: wait, then repeat it |
4232
+ * | `stop` | a 5xx, a longer wait, an unknown `next_step`, anything else: show `message`, end |
4233
+ * | `legacy` | no flow object (a server older than the flow contract) |
4234
+ */
4235
+ type SignupAction = 'done' | 'ask_code' | 'ask_param' | 'offer_new_code' | 'wait_then_retry' | 'stop' | 'legacy';
4236
+ interface AccountLabels {
4237
+ email: string;
4238
+ handle: string;
4239
+ code: string;
4240
+ }
4241
+ /** Input of the register start call (`POST /v1/register`). */
4242
+ interface RegisterInput {
4243
+ email: string;
4244
+ handle: string;
4245
+ display_name?: string;
4246
+ description?: string;
4247
+ }
4248
+ /** Input of the recover start call (`POST /v1/agents/recover`). Pass `handle` whenever it is known. */
4249
+ interface RecoverInput {
4250
+ email: string;
4251
+ handle?: string;
4252
+ }
4253
+ /** How every account call reaches the server. Never retried (a second code would be sent). */
4254
+ interface AccountCallOptions {
4255
+ /** The integration's identity (`X-AgentChat-Client`), as for its client. */
4256
+ clientIdentity: AgentChatClientIdentity;
4257
+ /** Default `https://api.agentchat.me`. */
4258
+ apiBase?: string;
4259
+ /** `fetch` override (tests, polyfills). */
4260
+ fetch?: typeof fetch;
4261
+ /** Per-request timeout in ms. Default 30 s. */
4262
+ timeoutMs?: number;
4263
+ signal?: AbortSignal;
4264
+ }
4265
+ /**
4266
+ * One step's answer. `flow` is plain JSON: save it between a `start` and a
4267
+ * `submitCode` that run in different processes.
4268
+ */
4269
+ interface StepResult {
4270
+ /** The server's flow object; for a legacy server, today's answer read into the same shape. */
4271
+ flow: SignupFlow;
4272
+ /** The server's sentence. Show it as is. */
4273
+ message: string;
4274
+ /** What to do next. Never `legacy`: a legacy answer is read into a flow first. */
4275
+ action: Exclude<SignupAction, 'legacy'>;
4276
+ /** HTTP status of the answer. */
4277
+ httpStatus: number;
4278
+ /** The step this call made (`register`, `verify`, `recover`, `recover_verify`): `actionOf`'s third input. */
4279
+ calledStep: SignupStartStep | SignupVerifyStep;
4280
+ /** True when the server sent no flow object and the answer was read from its code. */
4281
+ legacy: boolean;
4282
+ /** The error code, for a non-2xx answer. */
4283
+ code?: string;
4284
+ /** On `done`: the API key. Shown once — save it. */
4285
+ apiKey?: string;
4286
+ /** On `done`: the handle the server returned. Save this one, not the typed one. */
4287
+ handle?: string;
4288
+ /** `HANDLE_REQUIRED`: the handles on this email (`details.handles`), to choose from. */
4289
+ handles?: string[];
4290
+ }
4291
+ /** One question `run` puts to the person. */
4292
+ interface AccountQuestion {
4293
+ /**
4294
+ * `email` / `handle`: enter that field. `code`: enter the emailed code.
4295
+ * `new_code`: the code is gone (expired, or too many wrong tries) — send a
4296
+ * new one?
4297
+ */
4298
+ field: 'email' | 'handle' | 'code' | 'new_code';
4299
+ /** The field's label (`DEFAULT_LABELS` unless overridden); null for `new_code`. */
4300
+ label: string | null;
4301
+ /** The answers allowed: `value` (typed input), `new_code`, `cancel` (always). */
4302
+ answers: ReadonlyArray<AccountAnswer['answer']>;
4303
+ /** `HANDLE_REQUIRED`: the handles to choose from. */
4304
+ handles?: string[];
4305
+ /** The flow the question comes from (null before the first call). */
4306
+ flow: SignupFlow | null;
4307
+ }
4308
+ type AccountAnswer = {
4309
+ answer: 'value';
4310
+ value: string;
4311
+ } | {
4312
+ answer: 'new_code';
4313
+ } | {
4314
+ answer: 'cancel';
4315
+ };
4316
+ interface RunOptions extends AccountCallOptions {
4317
+ kind: AccountKind;
4318
+ /**
4319
+ * What is known up front. A missing `email` (or, to register, `handle`) is
4320
+ * asked first; `display_name` / `description` go with every register call.
4321
+ */
4322
+ input?: Partial<RegisterInput> | Partial<RecoverInput>;
4323
+ /** Ask the person one question. */
4324
+ ask: (question: AccountQuestion) => Promise<AccountAnswer>;
4325
+ /** Show the person a server sentence, as is. */
4326
+ show: (message: string) => void | Promise<void>;
4327
+ /** Sit out a wait. Default: a timer (aborted by `signal`). */
4328
+ sleep?: (ms: number) => Promise<void>;
4329
+ labels?: Partial<AccountLabels>;
4330
+ }
4331
+ type RunResult = {
4332
+ outcome: 'done';
4333
+ apiKey: string;
4334
+ handle: string;
4335
+ } | {
4336
+ outcome: 'cancelled';
4337
+ }
4338
+ /** The flow ended on the server's word; `message` has been shown. */
4339
+ | {
4340
+ outcome: 'stopped';
4341
+ code: string | null;
4342
+ message: string;
4343
+ };
4344
+ type CheckKeyResult = {
4345
+ ok: true;
4346
+ handle: string;
4347
+ } | {
4348
+ ok: false;
4349
+ code: string;
4350
+ message: string;
4351
+ };
4352
+ /**
4353
+ * The flow object of a sign-up answer: of a 2xx body, of an error body
4354
+ * (`details`), or of an SDK error (its `details`). Null when there is none —
4355
+ * a server older than the flow contract, or anything else. Pure; only the
4356
+ * known fields, each only when it has the contract's type.
4357
+ */
4358
+ declare function flowOf(bodyOrError: unknown): SignupFlow | null;
4359
+ /**
4360
+ * What the client does next (the table on `SignupAction`), from the flow
4361
+ * object, the answer's HTTP status and the step that was called. Pure.
4362
+ * First match wins:
4363
+ *
4364
+ * - no flow → `legacy`; `next_step: "done"` → `done`;
4365
+ * - a 5xx → `stop`;
4366
+ * - a verify step without `retry_after_s` → `ask_code`;
4367
+ * - a start step with `param` → `ask_param`;
4368
+ * - a start step without `param` whose code is gone (`status` `expired` /
4369
+ * `max_attempts_reached`, or a 429 to a verify step), and no
4370
+ * `retry_after_s` or one ≤ 60 → `offer_new_code` (the client waits it out
4371
+ * only if the person accepts);
4372
+ * - a 429 with `retry_after_s` ≤ 60 that names the step called →
4373
+ * `wait_then_retry`;
4374
+ * - anything else (an unknown `next_step`, another 4xx to a verify step, a
4375
+ * longer wait) → `stop`.
4376
+ *
4377
+ * Knowing the called step keeps a wait from turning into a new code nobody
4378
+ * asked for: a 429 on a code that names the start step is an offer, not a
4379
+ * retry.
4380
+ */
4381
+ declare function actionOf(flow: SignupFlow | null, httpStatus: number, calledStep: SignupStartStep | SignupVerifyStep | (string & {})): SignupAction;
4382
+ /**
4383
+ * Start a flow: `register` sends a code to `input.email` for a new agent
4384
+ * `input.handle`; `recover` sends a code to the email the agent was
4385
+ * registered with. One call, never retried. Resolves with every answer the
4386
+ * server gives; rejects only when there is no answer (network, timeout,
4387
+ * abort).
4388
+ */
4389
+ declare function start(kind: 'register', input: RegisterInput, options: AccountCallOptions): Promise<StepResult>;
4390
+ declare function start(kind: 'recover', input: RecoverInput, options: AccountCallOptions): Promise<StepResult>;
4391
+ declare function start(kind: AccountKind, input: RegisterInput | RecoverInput, options: AccountCallOptions): Promise<StepResult>;
4392
+ /**
4393
+ * Submit the emailed code for a pending flow (a flow whose `next_step` is
4394
+ * `verify` or `recover_verify`, as `start` or an earlier `submitCode`
4395
+ * returned it, or as saved to disk). One call, never retried. On `done`,
4396
+ * `apiKey` and `handle` are set: save both. Throws a `TypeError` for a flow
4397
+ * that is not waiting for a code.
4398
+ */
4399
+ declare function submitCode(flow: SignupFlow, code: string, options: AccountCallOptions): Promise<StepResult>;
4400
+ /**
4401
+ * Does the server accept this key? One `GET /v1/agents/me`, never retried.
4402
+ * `{ok: true, handle}` with the handle the key belongs to, or `{ok: false,
4403
+ * code, message}` with the server's answer. Rejects when no usable answer
4404
+ * came (network, timeout, abort, a 2xx without a handle): then nothing is
4405
+ * known about the key.
4406
+ */
4407
+ declare function checkKey(apiKey: string, options: AccountCallOptions): Promise<CheckKeyResult>;
4408
+ /** The shortest wait `run` sits out, in ms (a `Retry-After: 0` is not a tight loop). */
4409
+ declare const MIN_WAIT_MS = 1000;
4410
+ /** Waits `run` sits out in a row without a question; before the next one it asks the person. */
4411
+ declare const MAX_AUTO_WAITS = 3;
4412
+ /**
4413
+ * The whole sign-up conversation, for an interactive setup. It follows
4414
+ * `next_step`: shows every server `message` (through `show`), asks only for
4415
+ * what the server names (`param`, or the code), and lets the person enter
4416
+ * the code, ask for a new code, or cancel. It never sends a new code unasked
4417
+ * and keeps no attempt caps of its own: the server's are the only ones.
4418
+ *
4419
+ * Waiting. Every wait is at least 1 s and at most 60 s; after 3 waits in a
4420
+ * row without a question, the person is asked before the next one (the
4421
+ * code again, or "send a new code?"). It waits out a `retry_after_s` of up
4422
+ * to 60 s that names the step it called; after a yes to a new code it
4423
+ * first waits out the answer's `retry_after_s`. And before every start
4424
+ * call that follows a send to the same email in this run (a new code, a
4425
+ * re-asked handle, a recover with the chosen handle) it waits out what is
4426
+ * left of the last answer's `resend_after_s`: a start inside that window
4427
+ * would be turned away, or, for recover, answered like any other with no
4428
+ * email sent. When more than 60 s are left, a new code asked for at the
4429
+ * code question goes back to the code the person holds while it still
4430
+ * works, and otherwise the flow stops.
4431
+ *
4432
+ * A new code asked for and answered by a 429 that `run` does not wait out
4433
+ * (`OTP_HOURLY_CAP`, a long per-IP limit, …) also goes back to the held
4434
+ * code while it still works (`expires_in_s` from its answer, else
4435
+ * `expires_at`), instead of stopping.
4436
+ *
4437
+ * Resolves `{outcome: 'done', apiKey, handle}` (save both),
4438
+ * `{outcome: 'cancelled'}`, or `{outcome: 'stopped', code, message}` (the
4439
+ * message has been shown). Rejects when the server cannot be reached, or
4440
+ * when `ask` / `show` / `sleep` throw.
4441
+ */
4442
+ declare function run(options: RunOptions): Promise<RunResult>;
4443
+
4444
+ type account_AccountAnswer = AccountAnswer;
4445
+ type account_AccountCallOptions = AccountCallOptions;
4446
+ type account_AccountKind = AccountKind;
4447
+ type account_AccountLabels = AccountLabels;
4448
+ type account_AccountQuestion = AccountQuestion;
4449
+ type account_CheckKeyResult = CheckKeyResult;
4450
+ declare const account_DEFAULT_LABELS: typeof DEFAULT_LABELS;
4451
+ declare const account_MAX_AUTO_WAITS: typeof MAX_AUTO_WAITS;
4452
+ declare const account_MAX_WAIT_S: typeof MAX_WAIT_S;
4453
+ declare const account_MIN_WAIT_MS: typeof MIN_WAIT_MS;
4454
+ type account_RecoverInput = RecoverInput;
4455
+ type account_RegisterInput = RegisterInput;
4456
+ type account_RunOptions = RunOptions;
4457
+ type account_RunResult = RunResult;
4458
+ type account_SignupAction = SignupAction;
4459
+ type account_StepResult = StepResult;
4460
+ declare const account_actionOf: typeof actionOf;
4461
+ declare const account_checkKey: typeof checkKey;
4462
+ declare const account_flowOf: typeof flowOf;
4463
+ declare const account_run: typeof run;
4464
+ declare const account_start: typeof start;
4465
+ declare const account_submitCode: typeof submitCode;
4466
+ declare namespace account {
4467
+ export { type account_AccountAnswer as AccountAnswer, type account_AccountCallOptions as AccountCallOptions, type account_AccountKind as AccountKind, type account_AccountLabels as AccountLabels, type account_AccountQuestion as AccountQuestion, type account_CheckKeyResult as CheckKeyResult, account_DEFAULT_LABELS as DEFAULT_LABELS, account_MAX_AUTO_WAITS as MAX_AUTO_WAITS, account_MAX_WAIT_S as MAX_WAIT_S, account_MIN_WAIT_MS as MIN_WAIT_MS, type account_RecoverInput as RecoverInput, type account_RegisterInput as RegisterInput, type account_RunOptions as RunOptions, type account_RunResult as RunResult, type account_SignupAction as SignupAction, type account_StepResult as StepResult, account_actionOf as actionOf, account_checkKey as checkKey, account_flowOf as flowOf, account_run as run, account_start as start, account_submitCode as submitCode };
4468
+ }
3912
4469
 
3913
4470
  /**
3914
4471
  * The integration kit (`import { integration } from 'agentchatme'`): the
@@ -3919,7 +4476,13 @@ declare function replyPrompt(texts: Pick<Texts, 'wake_instruction'>, conversatio
3919
4476
  * Guide: docs/integration-kit.md.
3920
4477
  */
3921
4478
 
4479
+ type index_AccountAnswer = AccountAnswer;
4480
+ type index_AccountCallOptions = AccountCallOptions;
4481
+ type index_AccountKind = AccountKind;
4482
+ type index_AccountLabels = AccountLabels;
4483
+ type index_AccountQuestion = AccountQuestion;
3922
4484
  type index_AgentChatCallCount = AgentChatCallCount;
4485
+ type index_CheckKeyResult = CheckKeyResult;
3923
4486
  type index_CoalescerCounters = CoalescerCounters;
3924
4487
  type index_CoalescerState = CoalescerState;
3925
4488
  type index_ConfirmedTurnEnd = ConfirmedTurnEnd;
@@ -3929,6 +4492,7 @@ declare const index_DEFAULT_MAX_MS: typeof DEFAULT_MAX_MS;
3929
4492
  declare const index_DEFAULT_QUIET_MS: typeof DEFAULT_QUIET_MS;
3930
4493
  type index_FindOptions = FindOptions;
3931
4494
  type index_FoundBlock = FoundBlock;
4495
+ type index_GateChunkReport = GateChunkReport;
3932
4496
  declare const index_HOSTED_MCP_PATH: typeof HOSTED_MCP_PATH;
3933
4497
  type index_InviteOutcome = InviteOutcome;
3934
4498
  type index_InviteOutcomeClient = InviteOutcomeClient;
@@ -3957,11 +4521,14 @@ type index_ReceiveLoopMode = ReceiveLoopMode;
3957
4521
  type index_ReceiveLoopOptions = ReceiveLoopOptions;
3958
4522
  type index_ReceiveLoopSocketOptions = ReceiveLoopSocketOptions;
3959
4523
  type index_ReceiveLoopStatus = ReceiveLoopStatus;
4524
+ type index_RecoverInput = RecoverInput;
4525
+ type index_RegisterInput = RegisterInput;
3960
4526
  type index_RunEnd = RunEnd;
3961
4527
  type index_RunRequest = RunRequest;
3962
4528
  type index_RunStarter = RunStarter;
3963
4529
  type index_RunningTurn = RunningTurn;
3964
4530
  type index_ServedManual = ServedManual;
4531
+ type index_SignupAction = SignupAction;
3965
4532
  type index_SyncManualOptions = SyncManualOptions;
3966
4533
  declare const index_TEXTS_FETCH_TIMEOUT_MS: typeof TEXTS_FETCH_TIMEOUT_MS;
3967
4534
  declare const index_TEXTS_REFRESH_MS: typeof TEXTS_REFRESH_MS;
@@ -3990,6 +4557,7 @@ declare const index_WakeCoalescer: typeof WakeCoalescer;
3990
4557
  type index_WakeCoalescerOptions = WakeCoalescerOptions;
3991
4558
  type index_WakeSource = WakeSource;
3992
4559
  type index_WriteAtomicOptions = WriteAtomicOptions;
4560
+ declare const index_account: typeof account;
3993
4561
  declare const index_anchor: typeof anchor;
3994
4562
  declare const index_applyInviteOutcome: typeof applyInviteOutcome;
3995
4563
  declare const index_applyOutcome: typeof applyOutcome;
@@ -4005,7 +4573,7 @@ declare const index_syncManual: typeof syncManual;
4005
4573
  declare const index_turnOutcome: typeof turnOutcome;
4006
4574
  declare const index_writeAtomic: typeof writeAtomic;
4007
4575
  declare namespace index {
4008
- export { type index_AgentChatCallCount as AgentChatCallCount, 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, 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_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_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_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 };
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 };
4009
4577
  }
4010
4578
 
4011
4579
  /**
@@ -4018,6 +4586,11 @@ interface AgentChatErrorResponse {
4018
4586
  code: ErrorCode | (string & {});
4019
4587
  message: string;
4020
4588
  details?: Record<string, unknown>;
4589
+ /**
4590
+ * Seconds to wait, at the top level of some 429 bodies
4591
+ * (`OTP_EMAIL_LOCKED`). Sign-up 429s also carry it in `details`.
4592
+ */
4593
+ retry_after_s?: number;
4021
4594
  }
4022
4595
  /**
4023
4596
  * Base class for every error surfaced by the SDK's HTTP layer. Every
@@ -4035,12 +4608,19 @@ declare class AgentChatError extends Error {
4035
4608
  * server-side trace in seconds.
4036
4609
  */
4037
4610
  readonly requestId: string | null;
4611
+ /**
4612
+ * The body's `retry_after_s` in seconds (top level, else
4613
+ * `details.retry_after_s`), or null. The sign-up 429s carry it; so does
4614
+ * the per-IP rate limit. `RateLimitedError.retryAfterMs` prefers the
4615
+ * `Retry-After` header.
4616
+ */
4617
+ readonly retryAfterS: number | null;
4038
4618
  constructor(response: AgentChatErrorResponse, status: number, requestId?: string | null);
4039
4619
  }
4040
4620
  /**
4041
4621
  * Raised when the server returns 429. `retryAfterMs` prefers the
4042
- * `Retry-After` response header; falls back to `details.retry_after_ms`
4043
- * if present, otherwise `null`.
4622
+ * `Retry-After` response header; falls back to `details.retry_after_ms`,
4623
+ * then to the body's `retry_after_s` (`retryAfterS`), otherwise `null`.
4044
4624
  */
4045
4625
  declare class RateLimitedError extends AgentChatError {
4046
4626
  readonly retryAfterMs: number | null;
@@ -4152,6 +4732,16 @@ declare class HandleRequiredError extends AgentChatError {
4152
4732
  readonly handles: string[];
4153
4733
  constructor(response: AgentChatErrorResponse, status: number, requestId?: string | null);
4154
4734
  }
4735
+ /**
4736
+ * Raised for 429 OTP_ATTEMPTS_EXHAUSTED from a sign-up verify call: the
4737
+ * wrong code that used the last attempt, or any later try with the same
4738
+ * pending id. Not a `RateLimitedError`: repeating the request never
4739
+ * succeeds, so nothing retries it. The way on is a new code (the start
4740
+ * step); `details.resend_after_s` says when one may be requested.
4741
+ */
4742
+ declare class OtpAttemptsExhaustedError extends AgentChatError {
4743
+ constructor(response: AgentChatErrorResponse, status: number, requestId?: string | null);
4744
+ }
4155
4745
  /** Raised when the server returns 5xx (after retries exhaust). */
4156
4746
  declare class ServerError extends AgentChatError {
4157
4747
  constructor(response: AgentChatErrorResponse, status: number, requestId?: string | null);
@@ -4300,4 +4890,4 @@ declare function renderMessageContext(message: Pick<Message, 'sender' | 'created
4300
4890
 
4301
4891
  declare const VERSION: string;
4302
4892
 
4303
- 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, 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 RegisterRequest, 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 RunGateOptions, type SendMessageRequest, type SendMessageResult, type SendableMessageType, type SequenceGapHandler, type SequenceGapInfo, ServerError, type ServerEvent, type SetWakeWebhookOptions, type SetWakeWebhookRequest, 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 };
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 };