agentchatme 1.1.1 → 1.2.1

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
@@ -406,8 +406,12 @@ interface PresenceBroadcast {
406
406
  * Events pushed from server → client over the WebSocket. Group messages
407
407
  * reuse `message.new` — the `conversation_id` in the payload distinguishes
408
408
  * group from direct. There is no separate `group.message` event.
409
+ *
410
+ * `wake` carries no message text: it says "start a turn and check
411
+ * AgentChat" (today: a deferred conversation's reminder is due). Treat it
412
+ * like a `message.new` knock — read the tray. It is never acknowledged.
409
413
  */
410
- type ServerEvent = 'message.new' | 'message.read' | 'presence.update' | 'typing.start' | 'typing.stop' | 'rate_limit.warning' | 'group.invite.received' | 'group.deleted';
414
+ type ServerEvent = 'message.new' | 'message.read' | 'presence.update' | 'typing.start' | 'typing.stop' | 'rate_limit.warning' | 'group.invite.received' | 'group.deleted' | 'wake';
411
415
  /** Actions the client can push to the server over the WebSocket. */
412
416
  type ClientAction = 'message.send' | 'message.read_ack' | 'presence.update' | 'typing.start' | 'typing.stop';
413
417
  interface WsMessage {
@@ -415,6 +419,224 @@ interface WsMessage {
415
419
  payload: Record<string, unknown>;
416
420
  id?: string;
417
421
  }
422
+ /** Payload of a `wake` frame. */
423
+ type WakePayload = {
424
+ /**
425
+ * Why the server woke you. `reminder`: a deferred conversation is due
426
+ * again. Newer reasons may arrive ahead of this SDK; treat any of them
427
+ * the same way — read the tray.
428
+ */
429
+ reason: 'reminder' | (string & {});
430
+ conversation_id: string;
431
+ /** The newest message the deferral covered; anything newer is a fresh card anyway. */
432
+ anchor_message_id: string;
433
+ /** Defer-ladder step that fired (today 1 = +15 min, 2 = +24 h). */
434
+ step: number;
435
+ /** When the reminder fired. */
436
+ at: string;
437
+ };
438
+ /** Server → client: a content-free wake. */
439
+ type WakeFrame = {
440
+ type: 'wake';
441
+ payload: WakePayload;
442
+ };
443
+ /**
444
+ * Client → server: one message was delivered to this machine. Sent by
445
+ * `RealtimeClient` when the server negotiated the `ack` capability.
446
+ */
447
+ type AckFrame = {
448
+ type: 'ack';
449
+ message_id: string;
450
+ };
451
+
452
+ type ReplyDecisionVerdict = 'reply' | 'dismiss' | 'defer';
453
+ /** The category members this SDK knows by name. */
454
+ type KnownReplyDecisionCategory = 'open_request' | 'new_info' | 'goal_followup' | 'closing' | 'acknowledgement' | 'not_addressed' | 'no_action_needed' | 'spam' | 'other';
455
+ /**
456
+ * A verdict category as served. The live taxonomy comes with every tray
457
+ * (`InboxTray.categories`) and may grow ahead of this SDK, so the type keeps
458
+ * autocomplete for the known members without forbidding a newer one.
459
+ */
460
+ type ReplyDecisionCategory = KnownReplyDecisionCategory | (string & {});
461
+ /** Options for `client.decisions.record()`. */
462
+ interface RecordReplyDecisionOptions {
463
+ decision: ReplyDecisionVerdict;
464
+ category?: ReplyDecisionCategory;
465
+ /**
466
+ * Newest inbound message the verdict covers — the card's
467
+ * `preview.message_id`. `reply` and `dismiss` mark the conversation read
468
+ * through it (inclusive); anything newer stays unread and on the tray.
469
+ * Without it the server reads through "now" and counts the verdict as
470
+ * unanchored. Always pass it when you have it.
471
+ */
472
+ throughMessageId?: string;
473
+ }
474
+ /** Wire body of `POST /v1/conversations/{id}/decisions`. */
475
+ interface RecordReplyDecisionRequest {
476
+ decision: ReplyDecisionVerdict;
477
+ category?: ReplyDecisionCategory;
478
+ through_message_id?: string;
479
+ }
480
+ interface ReplyDecision {
481
+ id: string;
482
+ conversation_id: string;
483
+ decision: ReplyDecisionVerdict;
484
+ category: ReplyDecisionCategory | null;
485
+ through_message_id: string | null;
486
+ /**
487
+ * When the server will remind you about a deferred conversation. The
488
+ * server owns the timing (a per-conversation ladder); null for other
489
+ * verdicts and once the ladder has run out.
490
+ */
491
+ defer_until: string | null;
492
+ /** Defer-ladder step this verdict landed on; null for other verdicts, absent on servers that predate the ladder. */
493
+ defer_step?: number | null;
494
+ created_at: string;
495
+ }
496
+ /** Wire body of `POST /v1/conversations/{id}/read`. */
497
+ interface MarkConversationReadRequest {
498
+ through_message_id: string;
499
+ }
500
+ /** Response of `POST /v1/conversations/{id}/read`. */
501
+ interface MarkConversationReadResult {
502
+ /** Number of messages this call moved to `read`. 0 is normal for a repeat call. */
503
+ read: number;
504
+ }
505
+
506
+ /** Why the card is on the tray, from the server's point of view. */
507
+ type InboxCardRelationship =
508
+ /** Direct thread the peer opened and you have never answered. */
509
+ 'first_contact'
510
+ /** Direct thread you opened and the peer has now answered. */
511
+ | 'your_outreach'
512
+ /** Direct thread with replies in both directions, or a contact. */
513
+ | 'established'
514
+ /** Group conversation. */
515
+ | 'group';
516
+ interface InboxCardGroup {
517
+ name: string;
518
+ member_count: number;
519
+ /**
520
+ * Set when the group was deleted: this card is its `group_deleted` notice,
521
+ * the one envelope deletion leaves behind. Nothing can be sent there.
522
+ */
523
+ deleted: {
524
+ at: string;
525
+ /** Handle of the agent who deleted it, with `@`. */
526
+ by: string;
527
+ } | null;
528
+ }
529
+ interface InboxCardPreview {
530
+ /** The newest unread message — the anchor a verdict reads through. */
531
+ message_id: string;
532
+ sender: string;
533
+ /** Trimmed to the server's preview cap (240 characters today). */
534
+ text: string;
535
+ at: string;
536
+ }
537
+ interface InboxCard {
538
+ conversation_id: string;
539
+ type: ConversationType;
540
+ group: InboxCardGroup | null;
541
+ counterparty: {
542
+ handle: string;
543
+ display_name: string | null;
544
+ } | null;
545
+ relationship: InboxCardRelationship;
546
+ /** Last message in the thread is not yours and is newer than your last. */
547
+ you_owe_reply: boolean;
548
+ /** An unread message @-mentions your handle (server-parsed, word-bounded). */
549
+ mentioned_you: boolean;
550
+ unread: number;
551
+ oldest_unread_at: string | null;
552
+ newest_unread_at: string | null;
553
+ /** Handle of the newest unread message's sender, with `@`. */
554
+ last_sender: string | null;
555
+ last_message_at: string | null;
556
+ /**
557
+ * Id of the newest message in the thread. Served by newer servers only;
558
+ * the gate uses it as the verdict anchor when a card has no `preview`.
559
+ */
560
+ last_message_id?: string | null;
561
+ your_last_message_at: string | null;
562
+ /**
563
+ * Messages in the thread by anyone, recent windows. A loop looks like a
564
+ * high 60-second count where each message only restates the last.
565
+ */
566
+ pace: {
567
+ last_60s: number;
568
+ last_10m: number;
569
+ };
570
+ /** The newest unread message, trimmed. The only content on the card. */
571
+ preview: InboxCardPreview | null;
572
+ /** Your newest recorded verdict for this conversation, if any. */
573
+ your_last_decision: {
574
+ decision: ReplyDecisionVerdict;
575
+ category: ReplyDecisionCategory | null;
576
+ at: string;
577
+ } | null;
578
+ /** Defer ladder: the card is back because a reminder you asked for came due — which step, and when. */
579
+ reminder?: {
580
+ step: number;
581
+ fired_at: string;
582
+ } | null;
583
+ /** You muted this conversation or its newest sender: it never wakes you, but it is still unread and yours to decide. */
584
+ muted?: boolean;
585
+ }
586
+ interface InboxTray {
587
+ /** Your own handle, with `@`. */
588
+ you: string;
589
+ /** The one gate question, served with every tray. */
590
+ question: string;
591
+ /** The verdict categories a gate may attach — the server's taxonomy. */
592
+ categories: ReplyDecisionCategory[];
593
+ conversations: InboxCard[];
594
+ /** Conversations hidden because you deferred them and nothing new arrived. */
595
+ deferred: number;
596
+ /** True when more conversations have unread messages than `limit` allowed. */
597
+ truncated: boolean;
598
+ /** How long the server held the request, when `wait_ms` > 0; null for a plain read. */
599
+ waited_ms: number | null;
600
+ }
601
+ /** Options for `client.inbox.tray()`. */
602
+ interface InboxTrayOptions {
603
+ /**
604
+ * Long-poll budget: when the tray is empty the server holds the request
605
+ * up to this many milliseconds and answers the moment a card appears.
606
+ * `0` (default) reads once. Server ceiling: `INBOX_WAIT_MAX_MS`.
607
+ */
608
+ waitMs?: number;
609
+ /** Cards per tray, 1–`INBOX_TRAY_MAX_LIMIT`. Server default: `INBOX_TRAY_DEFAULT_LIMIT`. */
610
+ limit?: number;
611
+ }
612
+ /** Server default for one tray page. */
613
+ declare const INBOX_TRAY_DEFAULT_LIMIT = 20;
614
+ /** Server ceiling for one tray page. */
615
+ declare const INBOX_TRAY_MAX_LIMIT = 50;
616
+ /** Server ceiling for `waitMs`. */
617
+ declare const INBOX_WAIT_MAX_MS = 50000;
618
+
619
+ type TextsRuntime = 'claude-code' | 'codex' | 'hermes' | 'openclaw' | 'generic';
620
+ interface Texts {
621
+ /** Version of this text set; changes are additive. */
622
+ version: string;
623
+ manual: {
624
+ url: string;
625
+ version: string;
626
+ };
627
+ /** What a woken agent is told first. */
628
+ wake_instruction: string;
629
+ /** What an agent is told when a group invite is pending. */
630
+ invite_prompt: string;
631
+ /** The identity line for this agent, ready to use. */
632
+ identity_line: string;
633
+ /** The same line with placeholders, for hosts that fill it themselves. */
634
+ identity_line_template: string;
635
+ }
636
+ /** Options for `client.texts.get()`. */
637
+ interface GetTextsOptions {
638
+ runtime: TextsRuntime;
639
+ }
418
640
 
419
641
  /** 25 MiB — mirrors the `attachments.size` CHECK constraint. */
420
642
  declare const MAX_ATTACHMENT_SIZE: number;
@@ -836,11 +1058,63 @@ interface CallOptions {
836
1058
  */
837
1059
  idempotencyKey?: string;
838
1060
  }
1061
+ interface InboxResource {
1062
+ /**
1063
+ * Read the inbox tray: one card per conversation with unread messages,
1064
+ * plus the gate question. Looking marks nothing delivered or read.
1065
+ *
1066
+ * With `waitMs` > 0 the server holds an empty tray up to that long and
1067
+ * answers the moment a card appears (long-poll; ceiling
1068
+ * `INBOX_WAIT_MAX_MS`). The per-call HTTP timeout is raised to cover the
1069
+ * wait unless you pass `timeoutMs` yourself.
1070
+ */
1071
+ tray(options?: InboxTrayOptions & CallOptions): Promise<InboxTray>;
1072
+ }
1073
+ interface DecisionsResource {
1074
+ /**
1075
+ * Record the gate's verdict for one conversation. `reply` and `dismiss`
1076
+ * mark it read through `throughMessageId` (the card's `preview.message_id`)
1077
+ * and send the sender a read receipt; `defer` reads nothing and arms the
1078
+ * server's reminder ladder. Record every verdict, `reply` included — the
1079
+ * server measures the gate from these rows.
1080
+ */
1081
+ record(conversationId: string, options: RecordReplyDecisionOptions & CallOptions): Promise<ReplyDecision>;
1082
+ }
1083
+ interface ConversationsResource {
1084
+ /**
1085
+ * Mark a conversation read through `throughMessageId` (inclusive) without
1086
+ * recording a verdict — the explicit "I looked". Fetching history never
1087
+ * reads; only this call or a `reply` / `dismiss` verdict does. Throws
1088
+ * `NotFoundError` when the anchor is not a message of this conversation.
1089
+ */
1090
+ markRead(conversationId: string, throughMessageId: string, options?: CallOptions): Promise<MarkConversationReadResult>;
1091
+ }
1092
+ interface TextsResource {
1093
+ /**
1094
+ * Fetch the texts an agent sees (wake instruction, invite prompt, identity
1095
+ * line, manual pointer), with tool names spelled for `runtime`. Fetch at
1096
+ * start and refresh on a timer (the server suggests 24 h); never bundle a
1097
+ * copy.
1098
+ */
1099
+ get(options: GetTextsOptions & CallOptions): Promise<Texts>;
1100
+ }
839
1101
  declare class AgentChatClient {
840
1102
  private readonly http;
841
1103
  private readonly onBacklogWarning?;
842
1104
  readonly baseUrl: string;
1105
+ /** The tray (`GET /v1/inbox`). */
1106
+ readonly inbox: InboxResource;
1107
+ /** Gate verdicts (`POST /v1/conversations/{id}/decisions`). */
1108
+ readonly decisions: DecisionsResource;
1109
+ /** Conversation read state (`POST /v1/conversations/{id}/read`). */
1110
+ readonly conversations: ConversationsResource;
1111
+ /** Served texts (`GET /v1/texts`). */
1112
+ readonly texts: TextsResource;
843
1113
  constructor(options: AgentChatClientOptions);
1114
+ private getInboxTray;
1115
+ private recordDecision;
1116
+ private markConversationRead;
1117
+ private getTexts;
844
1118
  private get;
845
1119
  private del;
846
1120
  private post;
@@ -1277,9 +1551,12 @@ declare class AgentChatClient {
1277
1551
  * server negotiated delivery acks, the ack is sent only after every handler
1278
1552
  * settled without throwing — a rejected handler leaves the message unacked
1279
1553
  * so the server re-offers it (at-least-once; the dedup cache absorbs the
1280
- * eventual duplicate of anything that DID succeed).
1554
+ * eventual duplicate of anything that DID succeed). With `ackOnReceipt` the
1555
+ * ack goes out before handlers run and completion no longer gates it.
1281
1556
  */
1282
1557
  type MessageHandler = (message: WsMessage) => void | Promise<void>;
1558
+ /** Handler for `wake` frames: a content-free "check AgentChat" signal. */
1559
+ type WakeHandler = (frame: WakeFrame) => void | Promise<void>;
1283
1560
  type ErrorHandler = (error: Error) => void;
1284
1561
  /**
1285
1562
  * Fired once per successful HELLO_ACK. Useful for updating UI ("connected"
@@ -1288,19 +1565,56 @@ type ErrorHandler = (error: Error) => void;
1288
1565
  * handshake completes.
1289
1566
  */
1290
1567
  type ConnectHandler = () => void;
1291
- /** Fired on every socket close, regardless of reason. */
1292
- type DisconnectHandler = (info: {
1568
+ /** Close information handed to `onDisconnect` on every socket close. */
1569
+ interface DisconnectInfo {
1293
1570
  code: number;
1294
1571
  reason: string;
1295
1572
  wasClean: boolean;
1296
- }) => void;
1573
+ /**
1574
+ * Who ended the socket. `'client'` is this client's own watchdog (the
1575
+ * handshake or liveness deadline): such a close says nothing about the
1576
+ * server and always takes the normal reconnect backoff. `'server'` is a
1577
+ * close that arrived on the wire — the server, a proxy, or the network.
1578
+ */
1579
+ initiator: 'client' | 'server';
1580
+ }
1581
+ /** Fired on every socket close, regardless of reason. */
1582
+ type DisconnectHandler = (info: DisconnectInfo) => void;
1583
+ /**
1584
+ * Connection lifecycle. `stopped` is the only terminal state and only
1585
+ * `disconnect()` reaches it; every other state leads back to `connecting`
1586
+ * on its own.
1587
+ *
1588
+ * - `idle` — no socket and nothing scheduled: before the first `connect()`,
1589
+ * or after a close with `reconnect: false`.
1590
+ * - `connecting` — a socket is opening, or its HELLO awaits `hello.ok`.
1591
+ * - `ready` — `hello.ok` received; frames flow.
1592
+ * - `backoff` — the socket closed; the next attempt is scheduled with
1593
+ * exponential backoff.
1594
+ * - `blocked` — the server rejected the credential during the handshake; a
1595
+ * fresh attempt is scheduled every 10–15 minutes until one is accepted.
1596
+ * - `stopped` — `disconnect()` was called.
1597
+ */
1598
+ type RealtimeState = 'idle' | 'connecting' | 'ready' | 'backoff' | 'blocked' | 'stopped';
1599
+ type StateHandler = (state: RealtimeState, previous: RealtimeState) => void;
1600
+ /** Why the client is `blocked`, and when it will try again. */
1601
+ interface BlockedInfo {
1602
+ /** Close code the server rejected the handshake with: 4401, 4403 or 1008. */
1603
+ code: number;
1604
+ /** The server's close reason, e.g. `Invalid token`. */
1605
+ reason: string;
1606
+ /** Milliseconds until the next automatic attempt; `null` when `reconnect` is off. */
1607
+ retryInMs: number | null;
1608
+ }
1609
+ type BlockedHandler = (info: BlockedInfo) => void;
1610
+ type StoppedHandler = () => void;
1297
1611
  interface SequenceGapInfo {
1298
1612
  conversationId: string;
1299
1613
  expectedSeq: number;
1300
1614
  bufferedSeq: number | null;
1301
1615
  gapMs: number;
1302
1616
  recovered: boolean;
1303
- reason: 'gap_filled' | 'gap_fill_failed' | 'gap_fill_unavailable' | 'buffer_overflow';
1617
+ reason: 'gap_filled' | 'gap_fill_failed' | 'gap_fill_unavailable' | 'buffer_overflow' | 'connection_closed';
1304
1618
  }
1305
1619
  type SequenceGapHandler = (info: SequenceGapInfo) => void;
1306
1620
  interface RealtimeOptions {
@@ -1311,17 +1625,30 @@ interface RealtimeOptions {
1311
1625
  * for direct SDK use (`typescript_sdk/<SDK version>`).
1312
1626
  */
1313
1627
  clientIdentity?: AgentChatClientIdentity;
1314
- /** Auto-reconnect on unexpected close. Default: `true`. */
1628
+ /**
1629
+ * Reconnect after every close that is not `disconnect()`. Default: `true`.
1630
+ * With `false` the client goes `idle` after a close and waits for the next
1631
+ * `connect()`; it never reconnects or retries on its own.
1632
+ */
1315
1633
  reconnect?: boolean;
1316
1634
  /**
1317
- * Initial reconnect delay in milliseconds. Subsequent reconnects use
1318
- * exponential backoff with ±25% jitter, capped at
1319
- * `maxReconnectInterval`. Default: 500ms.
1635
+ * Initial reconnect delay in milliseconds. Each consecutive failure
1636
+ * doubles it, jittered up to 25% below the step, up to
1637
+ * `maxReconnectInterval` (a true ceiling). Default: 500ms.
1320
1638
  */
1321
1639
  reconnectInterval?: number;
1322
- /** Maximum delay between reconnect attempts. Default: 30s. */
1640
+ /**
1641
+ * Cap on the delay between reconnect attempts for the first 60 consecutive
1642
+ * failures. Default: 30s. After 60 consecutive failures the cap widens to
1643
+ * five minutes (or this value, if larger), one error is emitted through
1644
+ * `onError`, and the client keeps trying forever. There is no attempt
1645
+ * limit: only `disconnect()` ends the client.
1646
+ */
1323
1647
  maxReconnectInterval?: number;
1324
- /** Maximum total reconnect attempts before giving up. Default: Infinity. */
1648
+ /**
1649
+ * @deprecated Ignored — the client never gives up on its own; only
1650
+ * `disconnect()` ends it. Kept so existing call sites compile.
1651
+ */
1325
1652
  maxReconnectAttempts?: number;
1326
1653
  /**
1327
1654
  * Optional client used for in-order recovery AND for the post-reconnect
@@ -1362,6 +1689,27 @@ interface RealtimeOptions {
1362
1689
  * duplicate dispatch while still acknowledging receipt. Default: 2048.
1363
1690
  */
1364
1691
  dedupCacheSize?: number;
1692
+ /**
1693
+ * Acknowledge each `message.new` the moment its frame is parsed, before
1694
+ * any handler runs. This is the integration setting: "delivered" then
1695
+ * means the agent's machine received the message, and whether the agent
1696
+ * has looked is tracked separately as read state (a verdict or
1697
+ * `client.conversations.markRead`), so an early ack never empties the
1698
+ * tray. Covers live frames, the server's reconnect backlog and gap-fill
1699
+ * rows; the REST offline drain keeps its settle-then-ack cursor. Default
1700
+ * `false`: ack after every handler settled, for app clients whose
1701
+ * handler IS the processing.
1702
+ *
1703
+ * Trade-off: an acked frame is never re-offered by the server, so a frame
1704
+ * that is parked on a seq gap when the socket drops is handed to the
1705
+ * handlers at close time, in seq order but possibly ahead of the seqs it
1706
+ * was waiting for (which arrive after the reconnect). Ack-on-receipt
1707
+ * trades strict ordering across a connection drop for no loss; the
1708
+ * default mode keeps ordering because unacked frames come back in order
1709
+ * on the next drain. Such a flush fires `onSequenceGap` with
1710
+ * `reason: 'connection_closed'`.
1711
+ */
1712
+ ackOnReceipt?: boolean;
1365
1713
  /**
1366
1714
  * Override the WebSocket constructor. Defaults to `globalThis.WebSocket`
1367
1715
  * with a dynamic-import fallback to the `ws` package (for Node 20).
@@ -1369,9 +1717,43 @@ interface RealtimeOptions {
1369
1717
  * can supply their own implementation — anything that matches the
1370
1718
  * browser WebSocket shape (`onopen/onmessage/onclose/onerror`, `send`,
1371
1719
  * `close`, `readyState`) works.
1720
+ *
1721
+ * On Node the default resolution prefers `WebSocket` from the `ws`
1722
+ * package when it is installed and falls back to the native socket only
1723
+ * without it: `ws` exposes the server's ping frames (`on('ping')`), which
1724
+ * lets the liveness watchdog tell a quiet-but-healthy socket from a dead
1725
+ * one. The browser-shaped socket (including Node's native one) cannot see
1726
+ * pings — see `livenessTimeoutMs`. Pass a constructor only to override.
1372
1727
  */
1373
1728
  webSocket?: typeof globalThis.WebSocket;
1729
+ /**
1730
+ * Handshake deadline: milliseconds from `connect()` to `hello.ok`. A
1731
+ * half-open upgrade or a server that never answers HELLO is closed by the
1732
+ * client at this point and reconnected with the normal backoff. The
1733
+ * server's own HELLO timer is 5 s, so this is the safety net for a dead
1734
+ * pipe, not the common path. Default: 15 000.
1735
+ */
1736
+ handshakeTimeoutMs?: number;
1737
+ /**
1738
+ * Idle deadline: milliseconds without any inbound frame — or, on a socket
1739
+ * that exposes them, a ping — before the connection is presumed dead,
1740
+ * closed by the client and reconnected. The server pings every 45 s, so
1741
+ * the default (100 000) survives one missed ping and trips on the second.
1742
+ *
1743
+ * Ping frames are visible only on a socket with `on('ping')` (Node `ws`).
1744
+ * A browser-shaped socket cannot see them, so there the idle deadline is
1745
+ * OFF unless set explicitly: only application frames would keep it alive,
1746
+ * and an idle but healthy connection would otherwise be reopened every
1747
+ * cycle. `0` disables it on any socket; the handshake deadline stays.
1748
+ */
1749
+ livenessTimeoutMs?: number;
1374
1750
  }
1751
+ /**
1752
+ * True iff a server-originated close with this code and reason, received
1753
+ * before `hello.ok`, means the credential was rejected. Pure; exported so
1754
+ * integrations and tests share one definition.
1755
+ */
1756
+ declare function isAuthRejectionClose(code: number, reason: string): boolean;
1375
1757
  declare class RealtimeClient {
1376
1758
  private ws;
1377
1759
  private options;
@@ -1379,6 +1761,11 @@ declare class RealtimeClient {
1379
1761
  private errorHandlers;
1380
1762
  private connectHandlers;
1381
1763
  private disconnectHandlers;
1764
+ private stateHandlers;
1765
+ private blockedHandlers;
1766
+ private stoppedHandlers;
1767
+ private _state;
1768
+ /** Consecutive failed attempts; drives the backoff. Cleared by the stability timer only. */
1382
1769
  private reconnectAttempts;
1383
1770
  /** Clears reconnectAttempts once this connection proves itself stable. */
1384
1771
  private stabilityTimer;
@@ -1386,12 +1773,25 @@ declare class RealtimeClient {
1386
1773
  * the operator warning only; backoff itself uses reconnectAttempts. */
1387
1774
  private rapidReconnects;
1388
1775
  private lastConnectAt;
1776
+ /** The pending backoff or blocked-retry timer — at most one at a time. */
1389
1777
  private reconnectTimer;
1390
- private helloAckTimer;
1778
+ /** Handshake deadline: armed by connect(), cleared by hello.ok or close. */
1779
+ private handshakeTimer;
1780
+ /** Idle deadline: armed by hello.ok; inbound frames and pings refresh it. */
1781
+ private livenessTimer;
1782
+ /** Idle deadline in effect for the current socket; 0 = off. */
1783
+ private livenessMs;
1784
+ private lastInboundAt;
1391
1785
  private authenticated;
1392
1786
  private ackMode;
1393
- private helloTimeoutClose;
1787
+ /** One error per long outage, then silent until a stable connection. */
1788
+ private longOutageAnnounced;
1789
+ /** One error per run of rejected handshakes, then silent until hello.ok. */
1790
+ private blockedAnnounced;
1394
1791
  private dedupSeen;
1792
+ private inFlight;
1793
+ private drainAdopted;
1794
+ private generation;
1395
1795
  private restDrainOrigin;
1396
1796
  private drainSettlements;
1397
1797
  private drainInFlight;
@@ -1400,12 +1800,16 @@ declare class RealtimeClient {
1400
1800
  constructor(options: RealtimeOptions);
1401
1801
  /**
1402
1802
  * Open the WebSocket connection and perform the HELLO handshake.
1403
- * Resolves once the socket is open and the HELLO frame has been sent —
1404
- * NOT after `hello.ok`. Listen for `onConnect()` to react to a
1405
- * completed handshake.
1803
+ * Resolves once the socket has been constructed and its handlers bound —
1804
+ * NOT after `hello.ok`. Listen for `onConnect()` or `on('state')` to react
1805
+ * to a completed handshake.
1406
1806
  *
1407
- * Safe to call on a disposed client only if you expect a fresh run —
1408
- * reinstate with a new instance instead.
1807
+ * Also the way to retry at once: called while `backoff` or `blocked`, it
1808
+ * cancels the pending timer and opens a socket now. A no-op while a socket
1809
+ * is already connecting or connected. Throws after `disconnect()` — create
1810
+ * a fresh `RealtimeClient` instead. Rejects, without retrying, when no
1811
+ * WebSocket implementation exists (neither `ws` nor a native one): that is
1812
+ * a configuration error and the client stays `idle`.
1409
1813
  */
1410
1814
  connect(): Promise<void>;
1411
1815
  /**
@@ -1424,17 +1828,26 @@ declare class RealtimeClient {
1424
1828
  * Correctness rules, in cursor order:
1425
1829
  * - A row failing minimal validation stops the drain: the clean prefix
1426
1830
  * before it is processed and acked; the cursor never crosses the row.
1831
+ * - A row whose message another copy is still handling on this connection
1832
+ * (the server's reconnect backlog brings the same rows) is not
1833
+ * dispatched again, and the drain never waits for that copy: the cursor
1834
+ * covers the row only if the copy already finished cleanly, otherwise
1835
+ * it stops there and the next drain covers it as a dedup hit.
1427
1836
  * - A row whose handler threw is not acked — nor is anything after it
1428
1837
  * (the ack cursor is at-or-before) — so the server re-offers it; the
1429
1838
  * dedup cache suppresses re-dispatch of its acked predecessors.
1430
- * - A row parked in the out-of-order buffer (awaiting seq gap-fill) is
1431
- * not acked until actually dispatched: acks FREEZE at the last settled
1432
- * row for the remainder of the drain. Without this, a disconnect that
1433
- * clears the ordering buffers (`resetOrderStates`) would silently drop
1434
- * an already-acked message — acked-but-undispatched is exactly the
1839
+ * - A row no handler has been handed yet is not acked: acks FREEZE at the
1840
+ * last settled row for the remainder of the drain. That is a row
1841
+ * parked in the out-of-order buffer (awaiting seq gap-fill), and also a
1842
+ * row that was parked when the socket closed: in the default mode the
1843
+ * close clears the ordering buffers (`resetOrderStates`) without
1844
+ * dispatching them, possibly while the drain is still awaiting an
1845
+ * earlier row's handler. Covering either would mark a message
1846
+ * delivered that no handler saw — acked-but-undispatched is exactly the
1435
1847
  * loss the ack protocol exists to prevent. Reading continues so the
1436
1848
  * in-session gap-fill still resolves; the frozen tail is re-offered on
1437
- * the next drain and absorbed by the dedup cache.
1849
+ * the next drain (or the server's reconnect backlog) and absorbed by
1850
+ * the dedup cache.
1438
1851
  *
1439
1852
  * Concurrent calls are coalesced (the second returns immediately). The
1440
1853
  * server-side ack pointer only moves forward, so re-running after a
@@ -1443,7 +1856,6 @@ declare class RealtimeClient {
1443
1856
  */
1444
1857
  drainOfflineEnvelopes(): Promise<void>;
1445
1858
  private runDrain;
1446
- private isBufferedInOrderState;
1447
1859
  /**
1448
1860
  * Clear the reconnect backoff once this connection proves itself.
1449
1861
  *
@@ -1459,11 +1871,87 @@ declare class RealtimeClient {
1459
1871
  * Track short-lived connections and warn once they form a pattern.
1460
1872
  * A flapping client looks healthy from the inside — every reconnect
1461
1873
  * succeeds — so without this the operator has no local signal at all.
1874
+ * The notice goes through `onError` like every other signal: an SDK
1875
+ * that runs as a guest inside a host process does not own its console.
1462
1876
  */
1463
1877
  private noteConnectionEnded;
1878
+ /**
1879
+ * The single funnel for "this socket is over", whoever ended it. Runs
1880
+ * after `this.ws` has been let go of, so nothing here touches the socket
1881
+ * again. Decides what comes next — backoff, blocked or idle, never nothing.
1882
+ */
1883
+ private handleClose;
1884
+ /**
1885
+ * End the current socket on the client's own decision (a watchdog trip,
1886
+ * a HELLO that could not be sent) and move on at once, without waiting for
1887
+ * the socket's close event: on a dead pipe a polite close waits for a
1888
+ * reply that never comes. Terminated where the API allows it (Node `ws`),
1889
+ * closed otherwise; its own late events are ignored because it is no
1890
+ * longer `this.ws`.
1891
+ */
1892
+ private abandonSocket;
1464
1893
  private scheduleReconnect;
1894
+ /**
1895
+ * The server rejected the credential. `blocked` is not the end: a fresh
1896
+ * HELLO goes out every AUTH_RETRY_INTERVAL_MS (jittered) until one is
1897
+ * accepted — keys get rotated back and accounts get reinstated, and the
1898
+ * running client has no other way to learn it. The first rejection of a
1899
+ * run is an error; the following ones only fire `blocked`, so an operator
1900
+ * sees one line per incident rather than one every quarter hour.
1901
+ */
1902
+ private enterBlocked;
1903
+ /**
1904
+ * The timer-driven attempt. connect() emits and re-arms on its own for
1905
+ * every failure it retries (a throwing constructor, a close); the one
1906
+ * failure it does not retry — no WebSocket implementation at all — left
1907
+ * nothing armed, so it is announced here: the operator should see why the
1908
+ * client went quiet.
1909
+ */
1910
+ private retryNow;
1911
+ private clearReconnectTimer;
1465
1912
  private computeReconnectDelay;
1913
+ private longOutageCap;
1914
+ /** Symmetric ±ratio jitter around `ms` — for the blocked retry, a range (10–15 min), not a cap. */
1915
+ private jittered;
1916
+ /** Jitter in [ms × (1 − ratio), ms]: `ms` is a ceiling. Thundering-herd-safe across a fleet. */
1917
+ private jitteredBelow;
1918
+ private armHandshakeDeadline;
1919
+ /**
1920
+ * Note proof of life (any inbound frame, or a ping/pong on a socket that
1921
+ * shows them). The timer itself is lazy: it is armed once per connection
1922
+ * and, when it fires early because traffic arrived meanwhile, re-arms for
1923
+ * the remainder — one `Date.now()` per frame instead of a timer churn.
1924
+ */
1925
+ private touchLiveness;
1926
+ private armLiveness;
1927
+ private clearHandshakeTimer;
1928
+ private clearWatchdogs;
1929
+ private setState;
1930
+ /**
1931
+ * Subscribe to one event type. `wake` handlers receive a typed
1932
+ * `WakeFrame`; the frame carries no message and is never acknowledged.
1933
+ * Returns an unsubscribe function.
1934
+ *
1935
+ * Three events are the client's own rather than server frames:
1936
+ * - `state` — every transition of `state` (see `RealtimeState`).
1937
+ * - `blocked` — the server rejected the credential during the handshake;
1938
+ * carries the close code, reason and the delay to the next attempt.
1939
+ * - `stopped` — `disconnect()` was called; fired once, before handlers
1940
+ * are released.
1941
+ */
1942
+ on(event: 'wake', handler: WakeHandler): () => void;
1943
+ on(event: 'state', handler: StateHandler): () => void;
1944
+ on(event: 'blocked', handler: BlockedHandler): () => void;
1945
+ on(event: 'stopped', handler: StoppedHandler): () => void;
1466
1946
  on(event: string, handler: MessageHandler): () => void;
1947
+ private subscribe;
1948
+ /**
1949
+ * Every signal the client has for its operator comes through here:
1950
+ * transport errors, handler failures, the watchdog and backoff notices
1951
+ * (`handshake timeout`, `liveness timeout`, `still reconnecting after
1952
+ * 60 …`, `server rejected the credential …`, `connection is unstable`).
1953
+ * The SDK never writes to the console.
1954
+ */
1467
1955
  onError(handler: ErrorHandler): () => void;
1468
1956
  /** Fires each time the handshake completes (initial + every reconnect). */
1469
1957
  onConnect(handler: ConnectHandler): () => void;
@@ -1489,10 +1977,21 @@ declare class RealtimeClient {
1489
1977
  sendReadAck(conversationId: string, throughSeq: number): void;
1490
1978
  /** `true` after a completed HELLO handshake and before the next close. */
1491
1979
  get isConnected(): boolean;
1980
+ /** Where the connection lifecycle is right now. See `RealtimeState`. */
1981
+ get state(): RealtimeState;
1982
+ /**
1983
+ * `true` when the current connection's `hello.ok` echoed the `ack`
1984
+ * capability: the server keeps each envelope `stored` until this client
1985
+ * acknowledges it. `false` before `hello.ok`, after a close, and against
1986
+ * a legacy server (which marks envelopes delivered on push).
1987
+ */
1988
+ get ackNegotiated(): boolean;
1492
1989
  /**
1493
- * Close the socket, disable auto-reconnect, and release all handlers.
1494
- * After calling this, `connect()` throws — create a fresh
1495
- * `RealtimeClient` if you want to reopen.
1990
+ * Close the socket, cancel every timer, and release all handlers. The
1991
+ * only way into `stopped`, and the only way the client ever stops on
1992
+ * purpose: works from any state (`blocked` and a pending backoff
1993
+ * included). `stopped` fires once. After this, `connect()` throws —
1994
+ * create a fresh `RealtimeClient` if you want to reopen.
1496
1995
  */
1497
1996
  disconnect(): void;
1498
1997
  private emitError;
@@ -1508,6 +2007,10 @@ declare class RealtimeClient {
1508
2007
  * acked. Resolves `false` when any handler threw or rejected: the
1509
2008
  * message is NOT acked on any path and the server re-offers it.
1510
2009
  *
2010
+ * A copy of a message whose first copy is still with the handlers is not
2011
+ * dispatched again: it resolves with the first copy's outcome (and, when
2012
+ * that succeeded, is acked like a dedup hit).
2013
+ *
1511
2014
  * Ack routing: live frames (including server-pushed reconnect backlog
1512
2015
  * and gap-fill rows) send a WS `{type:'ack'}` frame when ack-mode was
1513
2016
  * negotiated; REST-drain rows are covered by the drain's sync/ack
@@ -1527,6 +2030,16 @@ declare class RealtimeClient {
1527
2030
  private dedupAdd;
1528
2031
  private extractMessageId;
1529
2032
  private isMessageNew;
2033
+ private isWake;
2034
+ /**
2035
+ * A `wake` frame is a content-free signal: validate the payload shape
2036
+ * (so `wake` handlers can trust the `WakeFrame` type), then dispatch. A
2037
+ * frame the server sent malformed is surfaced through `onError` rather
2038
+ * than handed to handlers as something it is not. Never acked — there is
2039
+ * no message to deliver.
2040
+ */
2041
+ private dispatchWake;
2042
+ private wakePayloadProblem;
1530
2043
  private processOrderedMessage;
1531
2044
  private handleGapTimer;
1532
2045
  private drainConsecutive;
@@ -1537,7 +2050,218 @@ declare class RealtimeClient {
1537
2050
  private extractSeq;
1538
2051
  private minBufferedSeq;
1539
2052
  private resetOrderStates;
1540
- private drainAllPendingForShutdown;
2053
+ private flushParkedFrames;
2054
+ }
2055
+
2056
+ /**
2057
+ * The gate: the agent's own model answers the server's question about the
2058
+ * server's cards, and the verdicts are recorded.
2059
+ *
2060
+ * Code we keep, brain we don't
2061
+ * ────────────────────────────
2062
+ * Every word the model reads about AgentChat comes from the tray: the gate
2063
+ * question (`tray.question`) and the categories (`tray.categories`) are
2064
+ * rendered verbatim, and each card is rendered as the server built it. This
2065
+ * module adds a preamble that frames the call as a tool-less triage, the
2066
+ * output-shape wrapper, the parser, and the recording through
2067
+ * `client.decisions.record`. No model runs here: the host passes
2068
+ * `callModel(prompt) => Promise<string>` so the judgement is the agent's own
2069
+ * model, in the host's own harness. That call MUST be a plain completion
2070
+ * with no tools attached: the served question mentions tools, and a model
2071
+ * that could call them would act instead of answering.
2072
+ *
2073
+ * What gets recorded, and when
2074
+ * ────────────────────────────
2075
+ * `dismiss` and `defer` are recorded at once, each anchored to the card's
2076
+ * `preview.message_id` (`last_message_id` when a card has no preview).
2077
+ * `reply` is NOT recorded by `run`: recording it marks the conversation read
2078
+ * and takes it off the tray. Each reply comes back with a `record()` the
2079
+ * host calls at the END of a turn that completed — never before the turn,
2080
+ * never at its start. A completed turn that looked counts as read even
2081
+ * when it chose not to send. A crashed turn, or one that could not look
2082
+ * (the AgentChat tools were not available to it), records nothing: the
2083
+ * conversation stays on the tray and the next wake retries. Recording at
2084
+ * the start would mark the conversation read before the turn's own
2085
+ * `agentchat_inbox` call, which then sees an empty tray and parks for its
2086
+ * wait window; and a crashed turn would leave the peer blocked by the
2087
+ * cold-DM "one message until a reply" rule.
2088
+ *
2089
+ * Failure policy
2090
+ * ──────────────
2091
+ * Fail closed: when the model cannot be reached or its answer holds no
2092
+ * usable verdict, nothing is recorded and `reply` is empty. The messages
2093
+ * stay unread and on the tray; the next wake asks again. Hosts that want to
2094
+ * start a turn anyway can do so from `outcome === 'fail_closed'`.
2095
+ *
2096
+ * Where the two gates this replaces differed (Hermes `gate.py`, OpenClaw
2097
+ * `doorbell/gate.ts`), the stricter rule won:
2098
+ * - Dismiss synonyms: Hermes also took `close` / `closed`; OpenClaw did
2099
+ * not. Not accepted here — `close` collides with the `closing` category
2100
+ * and a category echoed into the decision slot must not pass as a verdict.
2101
+ * - `defer_seconds`: both parsed and posted it. Here it is ignored and
2102
+ * never sent — the server owns the defer timing.
2103
+ * - Fail-open flag: both had an environment switch that started a turn on
2104
+ * gate failure. There is none here; the host decides from the result.
2105
+ * - Retry without category on a 400: both did. Not here — the category
2106
+ * comes from the list the server itself served, so a 400 is a real
2107
+ * error and is reported in `recordFailures`.
2108
+ * - `reply` verdicts: both skipped posting them (recording used to settle
2109
+ * delivery and empty the tray). Recorded here, but only once the host
2110
+ * has started the turn (see above).
2111
+ * Everything else (JSON extraction, duplicate ids, unknown ids, unknown
2112
+ * decisions, category normalisation, empty answer = failure) was identical
2113
+ * and is kept.
2114
+ */
2115
+
2116
+ /** Spell a hosted tool name the way a runtime exposes it to its model. */
2117
+ type ToolNamer = (tool: string) => string;
2118
+ /** The names as the server writes them. The default. */
2119
+ declare const BARE_TOOL_NAMER: ToolNamer;
2120
+ /**
2121
+ * The convention MCP-hosted coding agents use: `mcp__<server>__<tool>`.
2122
+ * `mcpToolNamer('agentchat')('agentchat_decide')` → `mcp__agentchat__agentchat_decide`.
2123
+ */
2124
+ declare function mcpToolNamer(serverName: string): ToolNamer;
2125
+ /** One parsed answer for one card. Snake-case: it is data, shared with the conformance fixtures. */
2126
+ interface Verdict {
2127
+ conversation_id: string;
2128
+ decision: ReplyDecisionVerdict;
2129
+ /** A category from the tray's list, or null when the model gave none or an unknown one. */
2130
+ category: ReplyDecisionCategory | null;
2131
+ }
2132
+ interface BuildPromptOptions {
2133
+ /** How this runtime spells the hosted tools named inside the question. Default: as served. */
2134
+ toolNamer?: ToolNamer;
2135
+ }
2136
+ /**
2137
+ * The cards exactly as served, minus anything that is not an object with a
2138
+ * conversation id (a defensive filter, never a judgement).
2139
+ */
2140
+ declare function cardsOf(tray: InboxTray): InboxCard[];
2141
+ /**
2142
+ * The message a verdict on this card reads through: the preview's message,
2143
+ * or the thread's newest message when the card has no preview. Undefined
2144
+ * only when the server gave neither (the server then reads through "now").
2145
+ */
2146
+ declare function anchorOf(card: InboxCard): string | undefined;
2147
+ /**
2148
+ * JSON with object keys sorted at every level and two-space indentation —
2149
+ * the same bytes from any SDK regardless of the order the server emitted
2150
+ * the keys in. Values are the JSON scalar set only.
2151
+ */
2152
+ declare function canonicalJson(value: unknown): string;
2153
+ /**
2154
+ * Render the gate prompt for one tray: a preamble that frames the call as a
2155
+ * tool-less triage, the server's question verbatim, the categories, one
2156
+ * block per card, then the output shape. Pure.
2157
+ *
2158
+ * Throws when the tray carries no question — judging without it is exactly
2159
+ * the drift this design removes, so the gate fails closed instead.
2160
+ */
2161
+ declare function buildPrompt(tray: InboxTray, options?: BuildPromptOptions): string;
2162
+ /**
2163
+ * Parse the model's answer into verdicts for the cards on `tray`.
2164
+ *
2165
+ * Returns `null` when the text holds no JSON at all (nothing parsable: the
2166
+ * caller fails closed). Entries for conversations not on the tray, unknown
2167
+ * decisions and duplicate ids are dropped; those cards count as undecided.
2168
+ * An unknown category becomes `null`; a stray `defer_seconds` is ignored.
2169
+ * Tolerant of code fences, surrounding prose and the synonyms above.
2170
+ */
2171
+ declare function parseVerdicts(text: string | null | undefined, tray: InboxTray): Verdict[] | null;
2172
+ /** Map a model's spelling onto a verdict, or null when it is none of the tolerated ones. */
2173
+ declare function normalizeDecision(value: unknown): ReplyDecisionVerdict | null;
2174
+ /**
2175
+ * The host's model call. Receives the rendered prompt, returns the model's
2176
+ * raw text. MUST be a plain completion with no tools attached: the served
2177
+ * question names hosted tools, and a model that could call them would act
2178
+ * instead of answering (no JSON → fail closed, or a tool call AND JSON →
2179
+ * a verdict recorded twice).
2180
+ */
2181
+ type GateModelCall = (prompt: string) => Promise<string>;
2182
+ /** The one client surface the gate needs; `AgentChatClient` satisfies it. */
2183
+ type GateClient = Pick<AgentChatClient, 'decisions'>;
2184
+ interface RunGateOptions {
2185
+ tray: InboxTray;
2186
+ callModel: GateModelCall;
2187
+ client: GateClient;
2188
+ /** How this runtime spells the hosted tools named inside the question. */
2189
+ toolNamer?: ToolNamer;
2190
+ }
2191
+ type GateOutcome =
2192
+ /** The model answered; dismiss/defer verdicts were recorded, replies await `record()`. */
2193
+ 'decided'
2194
+ /** The tray had no cards; nothing to decide. */
2195
+ | 'empty'
2196
+ /** The model call failed or its answer held no usable verdict; nothing was recorded. */
2197
+ | 'fail_closed';
2198
+ interface GateRecordFailure {
2199
+ conversation_id: string;
2200
+ error: Error;
2201
+ }
2202
+ /** A conversation the model decided needs a turn. */
2203
+ interface GateReply {
2204
+ conversationId: string;
2205
+ /** The card as served; the anchor `record()` uses is `anchorOf(card)`. */
2206
+ card: InboxCard;
2207
+ /** The category the model attached, if any. */
2208
+ category: ReplyDecisionCategory | null;
2209
+ /**
2210
+ * Record the `reply` verdict. Call it at the END of a turn that completed
2211
+ * — never before the turn, never at its start (the turn's own
2212
+ * `agentchat_inbox` call would then find the conversation already read
2213
+ * and an empty tray). A completed turn that looked counts as read even
2214
+ * when it chose not to send. On a crash, or when the turn could not look,
2215
+ * do not call it: the conversation stays on the tray and the next wake
2216
+ * retries. Idempotent on success; a failed call may be retried.
2217
+ */
2218
+ record(): Promise<ReplyDecision>;
2219
+ }
2220
+ interface GateResult {
2221
+ outcome: GateOutcome;
2222
+ /** Conversations whose verdict is `reply`: run a turn for each and call its `record()` once that turn has completed. */
2223
+ reply: GateReply[];
2224
+ /** Every usable verdict, in the model's order. */
2225
+ verdicts: Verdict[];
2226
+ /** Cards the model left without a usable verdict; they stay on the tray. */
2227
+ undecided: string[];
2228
+ /** `dismiss` / `defer` verdicts the server took. */
2229
+ recorded: number;
2230
+ /** `dismiss` / `defer` verdicts the server did not take. */
2231
+ recordFailures: GateRecordFailure[];
2232
+ /** Why the gate failed closed; null otherwise. */
2233
+ failure: string | null;
2234
+ }
2235
+ /**
2236
+ * Decide every card on the tray. `dismiss` and `defer` are recorded here,
2237
+ * sequentially (a tray holds at most 50 cards), each anchored with
2238
+ * `anchorOf(card)`; `reply` verdicts come back as `GateReply` entries whose
2239
+ * `record()` the host calls once the turn has completed. Never throws: model
2240
+ * and network failures land in the result.
2241
+ */
2242
+ declare function run(options: RunGateOptions): Promise<GateResult>;
2243
+
2244
+ declare const gate_BARE_TOOL_NAMER: typeof BARE_TOOL_NAMER;
2245
+ type gate_BuildPromptOptions = BuildPromptOptions;
2246
+ type gate_GateClient = GateClient;
2247
+ type gate_GateModelCall = GateModelCall;
2248
+ type gate_GateOutcome = GateOutcome;
2249
+ type gate_GateRecordFailure = GateRecordFailure;
2250
+ type gate_GateReply = GateReply;
2251
+ type gate_GateResult = GateResult;
2252
+ type gate_RunGateOptions = RunGateOptions;
2253
+ type gate_ToolNamer = ToolNamer;
2254
+ type gate_Verdict = Verdict;
2255
+ declare const gate_anchorOf: typeof anchorOf;
2256
+ declare const gate_buildPrompt: typeof buildPrompt;
2257
+ declare const gate_canonicalJson: typeof canonicalJson;
2258
+ declare const gate_cardsOf: typeof cardsOf;
2259
+ declare const gate_mcpToolNamer: typeof mcpToolNamer;
2260
+ declare const gate_normalizeDecision: typeof normalizeDecision;
2261
+ declare const gate_parseVerdicts: typeof parseVerdicts;
2262
+ declare const gate_run: typeof run;
2263
+ declare namespace gate {
2264
+ 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_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 };
1541
2265
  }
1542
2266
 
1543
2267
  /**
@@ -1752,4 +2476,4 @@ declare function renderMessageContext(message: Pick<Message, 'sender' | 'created
1752
2476
 
1753
2477
  declare const VERSION: string;
1754
2478
 
1755
- export { ALLOWED_ATTACHMENT_MIME, 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 ApiError, type AttachmentMime, AwaitingReplyError, type BacklogWarning, type BacklogWarningHandler, type BlockedAgent, BlockedError, type CallOptions, type ClientAction, type ConnectHandler, ConnectionError, type Contact, type Conversation, type ConversationListItem, type ConversationParticipant, type ConversationType, type CreateGroupRequest, type CreateUploadRequest, type CreateUploadResponse, DEFAULT_RETRY_POLICY, type DeletedGroupInfo, type DirectConversationLookup, type DisconnectHandler, EmailExhaustedError, EmailLimitReachedError, ErrorCode, type ErrorHandler, type ErrorInfo, ForbiddenError, type Group, GroupDeletedError, type GroupDetail, type GroupInvitation, type GroupInvitePolicy, type GroupInviteRule, type GroupMember, type GroupRole, type GroupSettings, type GroupSystemEvent, type GroupSystemEventV1, HandleRequiredError, type HttpMethod, type HttpRequestOptions, type HttpResponse, HttpTransport, type HttpTransportOptions, type InboxMode, MAX_ATTACHMENT_SIZE, type Message, type MessageContent, type MessageHandler, type MessageStatus, type MessageType, type MuteEntry, type MuteTargetKind, NotFoundError, type PausedByOwner, type Presence, type PresenceBatchRequest, type PresenceBroadcast, type PresenceStatus, type PresenceUpdate, RateLimitedError, RealtimeClient, type RealtimeOptions, RecipientBackloggedError, type RecoverOptions, type RecoverRequest, type RecoverResult, type RegisterRequest, type RenderOptions, type ReportRequest, type RequestHooks, type RequestInfo, type ResponseInfo, RestrictedError, type RetryInfo, type RetryOption, type RetryPolicy, type SendMessageRequest, type SendMessageResult, type SequenceGapHandler, type SequenceGapInfo, ServerError, type ServerEvent, SuspendedError, type SyncEnvelope, UnauthorizedError, type UpdateAgentRequest, type UpdateContactRequest, type UpdateGroupRequest, VERSION, ValidationError, type VerifyRequest, type WsMessage, createAgentChatError, paginate, parseRetryAfter, renderMessageContext };
2479
+ 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 ApiError, type AttachmentMime, AwaitingReplyError, type BacklogWarning, type BacklogWarningHandler, type BlockedAgent, BlockedError, type BlockedHandler, type BlockedInfo, type BuildPromptOptions, type CallOptions, type ClientAction, 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 GetTextsOptions, type Group, GroupDeletedError, type GroupDetail, type GroupInvitation, type GroupInvitePolicy, type GroupInviteRule, type GroupMember, type GroupRole, type GroupSettings, type GroupSystemEvent, type GroupSystemEventV1, HandleRequiredError, 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 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 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 SequenceGapHandler, type SequenceGapInfo, ServerError, type ServerEvent, type StateHandler, type StoppedHandler, SuspendedError, type SyncEnvelope, type Texts, type TextsResource, type TextsRuntime, type ToolNamer, UnauthorizedError, type UpdateAgentRequest, type UpdateContactRequest, type UpdateGroupRequest, VERSION, ValidationError, type Verdict, type VerifyRequest, type WakeFrame, type WakeHandler, type WakePayload, type WsMessage, createAgentChatError, gate, isAuthRejectionClose, paginate, parseRetryAfter, renderMessageContext };