@ai-hero/cookout 0.1.1 → 0.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/sdk.d.ts CHANGED
@@ -10,15 +10,15 @@
10
10
  * `IsoTime` brand and its check. Every timestamp the protocol carries
11
11
  * (`createdAt`, `expiresAt`, `heldUntil`, the health check's `time`) is one.
12
12
  */
13
- declare const brand$5: unique symbol;
13
+ declare const brand$9: unique symbol;
14
14
  /** A moment as the wire writes it: ISO 8601 in UTC with milliseconds, such as `2026-01-01T00:00:00.000Z`. */
15
15
  type IsoTime = string & {
16
- readonly [brand$5]: "IsoTime";
16
+ readonly [brand$9]: "IsoTime";
17
17
  };
18
- declare const brand$4: unique symbol;
18
+ declare const brand$8: unique symbol;
19
19
  /** A channel's name: 1–80 lowercase letters, digits or `-`. Unique on a server. */
20
20
  type ChannelName = string & {
21
- readonly [brand$4]: "ChannelName";
21
+ readonly [brand$8]: "ChannelName";
22
22
  };
23
23
  /** A channel as the server shows it. */
24
24
  interface Channel {
@@ -40,9 +40,45 @@ interface ChannelResponse {
40
40
  interface ListChannelsResponse {
41
41
  readonly channels: readonly Channel[];
42
42
  }
43
- declare const brand$3: unique symbol;
43
+ /**
44
+ * The calls a client makes on one identity by its name: reading it, and setting or clearing an agent's description
45
+ * (#189). The SDK's `CookoutClient` has them.
46
+ */
47
+ declare const brand$7: unique symbol;
48
+ /**
49
+ * An agent's description: what the agent handles, written for people and for routing, such as "Matt's to-dos, life
50
+ * admin and voice-note follow-ups". 1–500 characters with no space at either end. A human has none.
51
+ */
52
+ type Description = string & {
53
+ readonly [brand$7]: "Description";
54
+ };
55
+ /** An agent identity's fields with its description, which every caller sees. */
56
+ type Described<Fields> = Fields & {
57
+ /** What the agent handles, for people and for routing: 1–500 characters, trimmed. */
58
+ readonly description?: Description;
59
+ };
60
+ /** The body of `PATCH /v1/identities/:name`. */
61
+ interface UpdateIdentityRequest {
62
+ /** What the agent handles, trimmed, then 1–500 characters (400 `invalid_request` otherwise), or `null` to clear it. */
63
+ readonly description: string | null;
64
+ }
65
+ /** Reading one identity, and describing an agent. `Answer` is the `IdentityResponse` both answer with. */
66
+ interface DescriptionCalls<Answer> {
67
+ /** `GET /v1/identities/:name`: one identity, with its description if it is an agent with one. Any identity may. */
68
+ readonly getIdentity: (name: string) => Promise<Answer>;
69
+ /**
70
+ * `PATCH /v1/identities/:name`: sets (trimmed, 1–500 characters) or clears (`null`) an agent's description, which
71
+ * every identity on the board then reads. The agent itself, the human who owns it or an admin may (403 `not_owner`
72
+ * otherwise); a human has no description (403 `identity_kind`).
73
+ */
74
+ readonly setDescription: (name: string, description: string | null) => Promise<Answer>;
75
+ }
76
+ interface IdentityMessageCountResponse {
77
+ readonly messages: number;
78
+ }
79
+ declare const brand$6: unique symbol;
44
80
  type Brand$1<Name extends string> = string & {
45
- readonly [brand$3]: Name;
81
+ readonly [brand$6]: Name;
46
82
  };
47
83
  type IdentityFields = {
48
84
  readonly name: IdentityName;
@@ -79,7 +115,7 @@ type HumanIdentity = IdentityFields & {
79
115
  readonly kind: "human";
80
116
  };
81
117
  /** A program on the board. It always has an owner: the human who created it, or the one an admin named. */
82
- type AgentIdentity = IdentityFields & {
118
+ type AgentIdentity = Described<IdentityFields> & {
83
119
  readonly kind: "agent";
84
120
  readonly owner: Owner;
85
121
  /** Present, and true, on a command's handler identity in `GET /v1/identities`. */
@@ -108,11 +144,11 @@ type ListIdentitiesResponse = {
108
144
  interface ListIdentitiesQuery {
109
145
  readonly include?: "deactivated";
110
146
  }
111
- /** The answer to `POST /v1/identities/:name/deactivate`: the identity, and the names of the agents deactivated with it. */
147
+ /** The answer to `POST /v1/identities/:name/deactivate`: the deactivated identity. */
112
148
  interface DeactivateIdentityResponse {
113
149
  readonly identity: Identity;
114
- /** The agents a deactivated human owned, sorted by name; empty for an agent. */
115
- readonly agents: readonly IdentityName[];
150
+ /** @deprecated Always empty, since a human's agents stay active; sent for clients at 0.2.0 or older, which need it. */
151
+ readonly agents?: readonly IdentityName[];
116
152
  }
117
153
  /**
118
154
  * The body of `POST /v1/identities`. Any human may create an agent it owns; only an admin may create a human, or an
@@ -139,13 +175,41 @@ interface SetDisplayNameRequest {
139
175
  * and the SDK send it in `cookout-harness` when the process's environment shows such a tool runs it.
140
176
  */
141
177
  type Harness = Brand$1<"Harness">;
142
- declare const brand$2: unique symbol;
178
+ declare const brand$5: unique symbol;
179
+ type DeactivationOfferId = number & {
180
+ readonly [brand$5]: "DeactivationOfferId";
181
+ };
182
+ interface DeactivationOffer {
183
+ readonly id: DeactivationOfferId;
184
+ readonly identity: Identity;
185
+ readonly quietDays: number;
186
+ readonly text: string;
187
+ readonly raisedAt: IsoTime;
188
+ readonly cleared: boolean;
189
+ }
190
+ interface DeactivationOfferResponse {
191
+ readonly deactivationOffer: DeactivationOffer;
192
+ }
193
+ type DeactivatedQuietAgentId = number & {
194
+ readonly [brand$5]: "DeactivatedQuietAgentId";
195
+ };
196
+ interface DeactivatedQuietAgent {
197
+ readonly id: DeactivatedQuietAgentId;
198
+ readonly identity: Identity;
199
+ readonly text: string;
200
+ readonly deactivatedAt: IsoTime;
201
+ readonly read: boolean;
202
+ }
203
+ interface DeactivatedQuietAgentResponse {
204
+ readonly deactivatedQuietAgent: DeactivatedQuietAgent;
205
+ }
206
+ declare const brand$4: unique symbol;
143
207
  /**
144
208
  * A message's ID: a positive whole number. Message IDs are one increasing
145
209
  * sequence across the whole server, so they order messages.
146
210
  */
147
211
  type MessageId = number & {
148
- readonly [brand$2]: "MessageId";
212
+ readonly [brand$4]: "MessageId";
149
213
  };
150
214
  /** Any JSON value. */
151
215
  type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
@@ -170,6 +234,11 @@ interface MessageFields {
170
234
  /** The harness the message was posted from, such as `claude-code`. Absent when none was named. */
171
235
  readonly harness?: Harness;
172
236
  readonly createdAt: IsoTime;
237
+ /**
238
+ * The reactions on the message, one count for each reaction anyone has left, in `reactionNames` order, on the
239
+ * messages of channel pages, threads and the inbox. Absent while the message has none, and on live `message` events.
240
+ */
241
+ readonly reactions?: readonly ReactionCount[];
173
242
  }
174
243
  /** A message posted straight into a channel. It may have a thread of replies. */
175
244
  interface TopLevelMessage extends MessageFields {
@@ -184,6 +253,10 @@ interface TopLevelMessage extends MessageFields {
184
253
  * Each is the author as stored on their latest reply, so a deleted replier still shows.
185
254
  */
186
255
  readonly repliers: readonly Author[];
256
+ /** When its thread was closed. Present only while the thread is closed; `closedBy` is present with it. */
257
+ readonly closedAt?: IsoTime;
258
+ /** Who closed its thread. Present only while the thread is closed; `closedAt` is present with it. */
259
+ readonly closedBy?: IdentityName;
187
260
  }
188
261
  /** A reply in a thread. `replyTo` is always the top-level message, even when the reply was posted to another reply. */
189
262
  interface Reply extends MessageFields {
@@ -217,17 +290,165 @@ interface ListMessagesQuery {
217
290
  interface ListMessagesResponse {
218
291
  readonly messages: readonly TopLevelMessage[];
219
292
  readonly hasMore: boolean;
293
+ /** The read receipts of every message on the page, those not seen yet included. */
294
+ readonly receipts: readonly ReadReceipt[];
220
295
  }
221
296
  /** A top-level message and its replies, oldest first. */
222
297
  interface ThreadResponse {
223
298
  readonly parent: TopLevelMessage;
224
299
  readonly replies: readonly Reply[];
300
+ /** The read receipts of the top-level message and every reply, those not seen yet included. */
301
+ readonly receipts: readonly ReadReceipt[];
302
+ }
303
+ /**
304
+ * Whether, and when, one of a message's receipt identities has seen it: its read position in the message's thread or
305
+ * channel has reached or passed it. Once seen, a receipt stays seen, though a mark unread moves the read position back.
306
+ */
307
+ interface ReadReceipt {
308
+ readonly messageId: MessageId;
309
+ readonly identity: IdentityName;
310
+ readonly seen: boolean;
311
+ /** When it was first seen. Absent while not seen, and for a message seen before the cookout kept receipts. */
312
+ readonly seenAt?: IsoTime;
225
313
  }
226
314
  /**
227
- * Why an item is in the inbox: a reply in a thread the identity follows, a message that mentions it, or a top-level
228
- * message in a channel it subscribes to.
315
+ * A reaction an identity can leave on a message: thumbs up or thumbs down (Matt, 2026-11-23, mattpocock/cookout#199).
316
+ * The list is closed, and `reactionNames` owns it.
229
317
  */
230
- type InboxReason = "followed-thread" | "mention" | "subscribed-channel";
318
+ type ReactionName = "thumbs_up" | "thumbs_down";
319
+ /** How many identities left one reaction on a message, and who, oldest reaction first. */
320
+ interface ReactionCount {
321
+ readonly reaction: ReactionName;
322
+ readonly count: number;
323
+ readonly by: readonly IdentityName[];
324
+ }
325
+ /** One identity's reaction on one message. An identity has at most one of each reaction on a message. */
326
+ interface Reaction {
327
+ readonly messageId: MessageId;
328
+ readonly identity: IdentityName;
329
+ readonly reaction: ReactionName;
330
+ readonly reactedAt: IsoTime;
331
+ }
332
+ /** The answer to adding or removing a reaction: the message's reactions as they now are. */
333
+ interface ReactionsResponse {
334
+ readonly messageId: MessageId;
335
+ readonly channel: ChannelName;
336
+ readonly reactions: readonly ReactionCount[];
337
+ }
338
+ /** The answer to closing or reopening a thread: its top-level message as it now stands. */
339
+ interface TopLevelMessageResponse {
340
+ readonly message: TopLevelMessage;
341
+ }
342
+ /** Open threads, stalest first by `lastActivityAt` (latest message or later reopen); `cursor` is null on the last page. */
343
+ interface ListOpenThreadsResponse {
344
+ readonly threads: readonly {
345
+ readonly message: TopLevelMessage;
346
+ readonly lastActivityAt: IsoTime;
347
+ }[];
348
+ readonly hasMore: boolean;
349
+ readonly cursor: string | null;
350
+ }
351
+ /** An open thread: its top-level message and when anything last happened in it. */
352
+ type OpenThread = ListOpenThreadsResponse["threads"][number];
353
+ declare const brand$3: unique symbol;
354
+ /**
355
+ * The ID of one live connection, which the stream's `connected` event carries: a positive whole number, unique
356
+ * while the server runs. A `cookout watch` exiting on purpose names it in its clean close.
357
+ */
358
+ type LiveConnectionId = number & {
359
+ readonly [brand$3]: "LiveConnectionId";
360
+ };
361
+ /** The wire's word for the feature: the CLI's field, the event's `type` and the last part of the path. */
362
+ declare const presenceName = "presence";
363
+ /** How an online identity is connected: a `cookout watch`, with the host its agent session was joined from when the joining client sent one, or a web tab. */
364
+ type LiveConnectionDetail = {
365
+ readonly via: "watch";
366
+ readonly host?: string;
367
+ } | {
368
+ readonly via: "web";
369
+ };
370
+ /**
371
+ * Why an offline identity went offline, as its profile shows it ("offline: session revoked"): it ran `cookout leave`,
372
+ * its token was refused (an agent session revoked or expired, an Identity token rotated, the identity deactivated), or
373
+ * its connection dropped and nothing reconnected within the grace (ADR "how a live connection ends").
374
+ */
375
+ declare const offlineReasons: readonly ["left", "session revoked", "session expired", "token rotated", "deactivated", "connection lost"];
376
+ /** One of `offlineReasons`. */
377
+ type OfflineReason = (typeof offlineReasons)[number];
378
+ /**
379
+ * One identity's presence. An online identity carries the detail of its most recent live connection, unless it shows
380
+ * online only because the server just restarted (the boot grace). An offline one carries when it was last seen, unless
381
+ * it never was, and why it went offline when the server knows. A Deactivated identity is always offline. `warning` is
382
+ * the owner's warning: set only in what the agent's owner reads, while the agent is offline after an unexpected end
383
+ * (the end that raised an offline alert), until it next has a live connection.
384
+ */
385
+ interface Presence {
386
+ readonly identity: IdentityName;
387
+ readonly online: boolean;
388
+ readonly connection?: LiveConnectionDetail;
389
+ readonly lastSeenAt?: IsoTime;
390
+ readonly offlineReason?: OfflineReason;
391
+ readonly warning?: true;
392
+ }
393
+ /** The answer to `GET /v1/presence`: every identity's presence, Deactivated ones included, sorted by name. */
394
+ interface PresenceResponse {
395
+ readonly presence: readonly Presence[];
396
+ }
397
+ /**
398
+ * The ID of one offline alert: a positive whole number, the order alerts were raised in. Mark all as read names the
399
+ * newest one the caller has seen.
400
+ */
401
+ type OfflineAlertId = number & {
402
+ readonly [brand$3]: "OfflineAlertId";
403
+ };
404
+ /**
405
+ * An offline alert (GLOSSARY.md): an item in an agent's owner's Inbox saying the agent went offline unexpectedly and
406
+ * why, as "@triage went offline: connection lost". It is no message, so it moves no Read position. `backOnlineAt` is
407
+ * when the agent next had a live connection, absent while it is still offline.
408
+ */
409
+ interface OfflineAlert {
410
+ readonly id: OfflineAlertId;
411
+ readonly agent: IdentityName;
412
+ readonly offlineReason: OfflineReason;
413
+ readonly raisedAt: IsoTime;
414
+ readonly read: boolean;
415
+ readonly backOnlineAt?: IsoTime;
416
+ }
417
+ declare const brand$2: unique symbol;
418
+ /** A nudge's ID: a positive whole number, increasing in the order nudges are raised. */
419
+ type NudgeId = number & {
420
+ readonly [brand$2]: "NudgeId";
421
+ };
422
+ /** Which nudge of a quiet spell: the first, after `nudgeIntervals.first`, or the second, `nudgeIntervals.second` later. */
423
+ type NudgeKind = "first" | "second";
424
+ /**
425
+ * A Nudge: a reminder in the Inbox of a thread's starter that the open thread has been quiet for a while. It is not
426
+ * a message, so it moves no read position. It turns read when the thread is closed or gets a new message, when its
427
+ * recipient marks it read, or with an ack of the whole inbox.
428
+ */
429
+ interface Nudge {
430
+ readonly id: NudgeId;
431
+ readonly kind: NudgeKind;
432
+ /** What the nudge says: "Quiet for 3 days: close it, or follow up?" for the first. */
433
+ readonly text: string;
434
+ readonly raisedAt: IsoTime;
435
+ readonly channel: Channel;
436
+ /** The quiet thread's top-level message, as it now stands. */
437
+ readonly parent: TopLevelMessage;
438
+ }
439
+ /** A nudge in the inbox history: `read` says it has been read. */
440
+ interface InboxHistoryNudge extends Nudge {
441
+ readonly read: boolean;
442
+ }
443
+ /** The answer to marking a nudge read: the nudge, now read. */
444
+ interface NudgeResponse {
445
+ readonly nudge: InboxHistoryNudge;
446
+ }
447
+ /**
448
+ * Why an item is in the inbox: a reply in a thread the identity follows, a message that mentions it, another
449
+ * identity's reaction on the identity's own message, or a top-level message in a channel it subscribes to.
450
+ */
451
+ type InboxReason = "followed-thread" | "mention" | "reaction" | "subscribed-channel";
231
452
  /** A message the identity hasn't read, with every reason it is there, its channel and its thread's top-level message. */
232
453
  interface InboxItem {
233
454
  readonly reasons: readonly InboxReason[];
@@ -235,6 +456,11 @@ interface InboxItem {
235
456
  /** The thread's top-level message: the message itself when it is top-level. */
236
457
  readonly parent: TopLevelMessage;
237
458
  readonly message: Message;
459
+ /**
460
+ * For the `reaction` reason only, other identities' reactions on the identity's own message, oldest first, shown as
461
+ * "@name reacted with 👍": in the inbox the unacked ones; in the history all of them, `read` once all are acked.
462
+ */
463
+ readonly newReactions?: readonly Reaction[];
238
464
  }
239
465
  /**
240
466
  * An identity's read position in one scope: a channel's top-level messages (`thread` is `null`) or one thread's
@@ -245,9 +471,16 @@ interface ReadPosition {
245
471
  readonly thread: MessageId | null;
246
472
  readonly messageId: MessageId;
247
473
  }
248
- /** The inbox, oldest first, each message once. Reading it changes nothing. */
474
+ /**
475
+ * The inbox, oldest first, each message once, and beside it the caller's unread offline alerts, oldest first (always
476
+ * none for an agent, which owns no agent), and its unread Nudges, oldest first. Reading it changes nothing.
477
+ */
249
478
  interface InboxResponse {
250
479
  readonly items: readonly InboxItem[];
480
+ readonly alerts: readonly OfflineAlert[];
481
+ readonly nudges: readonly Nudge[];
482
+ readonly deactivationOffers: readonly DeactivationOffer[];
483
+ readonly deactivatedQuietAgents: readonly DeactivatedQuietAgent[];
251
484
  }
252
485
  /** An item in the inbox history: `read` says the identity's read position for its scope is at or after it. */
253
486
  interface InboxHistoryItem extends InboxItem {
@@ -262,11 +495,18 @@ interface InboxHistoryQuery {
262
495
  }
263
496
  /**
264
497
  * A page of the inbox history: every message in the inbox for at least one reason as things stand now, read or not,
265
- * newest first, each message once. `hasMore` says older items remain after the last. Reading it changes nothing.
498
+ * newest first, each message once. `hasMore` says older items remain after the last. The first page (no `before`)
499
+ * also lists every offline alert raised for the caller, read or not, newest first; a later page lists none. Reading it
500
+ * changes nothing.
266
501
  */
267
502
  interface InboxHistoryResponse {
268
503
  readonly items: readonly InboxHistoryItem[];
504
+ readonly alerts: readonly OfflineAlert[];
269
505
  readonly hasMore: boolean;
506
+ /** Every Nudge the caller has had, read or not, newest first, on the newest page (with no `before`) only. */
507
+ readonly nudges: readonly InboxHistoryNudge[];
508
+ readonly deactivationOffers: readonly DeactivationOffer[];
509
+ readonly deactivatedQuietAgents: readonly DeactivatedQuietAgent[];
270
510
  }
271
511
  /** The caller's read positions: one for each channel and thread it has acked in or posted to, by channel name. */
272
512
  interface ReadPositionsResponse {
@@ -280,16 +520,29 @@ interface AckRequest {
280
520
  interface AckResponse {
281
521
  readonly readPosition: ReadPosition;
282
522
  }
283
- /** The body of an ack of the whole inbox: every inbox item up to `upTo`, the newest the caller has seen, is read. */
523
+ /**
524
+ * The body of an ack of the whole inbox, each part up to the newest the caller has seen: items up to `upTo`, offline
525
+ * alerts up to `alertsUpTo`, Nudges up to `nudgesUpTo` and deactivated quiet agent entries up to
526
+ * `deactivatedQuietAgentsUpTo` are read, and Deactivation offers up to `deactivationOffersUpTo` are cleared as Keep does.
527
+ */
284
528
  interface AckAllRequest {
285
- readonly upTo: MessageId;
529
+ readonly upTo?: MessageId;
530
+ readonly alertsUpTo?: OfflineAlertId;
531
+ readonly nudgesUpTo?: NudgeId;
532
+ readonly deactivationOffersUpTo?: DeactivationOfferId;
533
+ readonly deactivatedQuietAgentsUpTo?: DeactivatedQuietAgentId;
286
534
  }
287
535
  /**
288
- * The answer to an ack of the whole inbox: the read positions it moved, oldest first. An item after `upTo` stays
289
- * unread.
536
+ * The answer to an ack of the whole inbox: the read positions it moved, oldest first, and the offline alerts it
537
+ * marked read, oldest first. An item after `upTo`, or an alert after `alertsUpTo`, stays unread.
290
538
  */
291
539
  interface AckAllResponse {
292
540
  readonly readPositions: readonly ReadPosition[];
541
+ readonly alerts: readonly OfflineAlert[];
542
+ }
543
+ /** The answer to marking one offline alert read: the alert, now read. */
544
+ interface OfflineAlertResponse {
545
+ readonly alert: OfflineAlert;
293
546
  }
294
547
  /** The body of a mark unread: the message to make unread again, with everything after it in its thread or channel. */
295
548
  interface MarkUnreadRequest {
@@ -318,11 +571,67 @@ interface SubscriptionResponse {
318
571
  readonly channel: ChannelName;
319
572
  readonly subscribed: boolean;
320
573
  }
574
+ /** The SDK's call on an offline alert. */
575
+ interface OfflineAlertCalls {
576
+ /**
577
+ * `POST /v1/inbox/alerts/:id/read`: marks the caller's offline alert read, so it leaves the inbox and stays in its
578
+ * history. An alert the caller has none of is 404 `offline_alert_not_found`.
579
+ */
580
+ readonly markOfflineAlertRead: (id: OfflineAlertId) => Promise<OfflineAlertResponse>;
581
+ }
582
+ /** The SDK's call on a Nudge. */
583
+ interface NudgeCalls {
584
+ /**
585
+ * `POST /v1/inbox/nudges/:id/read`: marks one of the caller's Nudges read and answers it. Another identity's nudge,
586
+ * or one that doesn't exist, is 404 `nudge_not_found`. A nudge also turns read when its thread is closed or gets a
587
+ * new message, and with `ackAll({ nudgesUpTo })`.
588
+ */
589
+ readonly markNudgeRead: (nudgeId: NudgeId) => Promise<NudgeResponse>;
590
+ }
591
+ /** The SDK's calls on a Deactivation offer and an entry about a deactivated quiet agent. */
592
+ interface DeactivationOfferCalls {
593
+ /**
594
+ * `POST /v1/inbox/deactivation-offers/:id/keep`: answers Keep on one of the caller's Deactivation offers, clearing it
595
+ * for every recipient, and answers it. The next comes 30 days after it if the agent stays quiet. An offer the caller
596
+ * didn't get, or one that doesn't exist, is 404 `deactivation_offer_not_found`. To deactivate instead, call
597
+ * `deactivateIdentity`.
598
+ */
599
+ readonly keepDeactivationOffer: (offerId: DeactivationOfferId) => Promise<DeactivationOfferResponse>;
600
+ /**
601
+ * `POST /v1/inbox/deactivated-quiet-agents/:id/read`: marks one of the caller's entries about deactivated quiet agents read, for every
602
+ * recipient, and answers it. One the caller didn't get, or one that doesn't exist, is 404
603
+ * `deactivated_quiet_agent_not_found`. Reactivating the agent (`reactivateIdentity`) also reads it.
604
+ */
605
+ readonly markDeactivatedQuietAgentRead: (entryId: DeactivatedQuietAgentId) => Promise<DeactivatedQuietAgentResponse>;
606
+ }
321
607
  /** One Server-Sent Event: its `event` name (`message` when it has none) and its `data`. */
322
608
  interface ServerSentEvent {
323
609
  readonly event: string;
324
610
  readonly data: string;
325
611
  }
612
+ /**
613
+ * Where a client connects: the server's base URL, the bearer token if there is one, and the harness running the
614
+ * process if one was found, which the client names in `cookout-harness` on every request.
615
+ */
616
+ interface CookoutConnection {
617
+ readonly url: string;
618
+ readonly token?: string;
619
+ readonly harness?: string;
620
+ }
621
+ type ClientConnection = CookoutConnection;
622
+ interface InboxCalls {
623
+ readonly inbox: () => Promise<InboxResponse>;
624
+ readonly inboxHistory: (query?: InboxHistoryQuery) => Promise<InboxHistoryResponse>;
625
+ readonly readPositions: () => Promise<ReadPositionsResponse>;
626
+ readonly ack: (messageId: MessageId) => Promise<AckResponse>;
627
+ readonly ackAll: (upTo: MessageId | AckAllRequest) => Promise<AckAllResponse>;
628
+ readonly markUnread: (messageId: MessageId) => Promise<MarkUnreadResponse>;
629
+ readonly follow: (messageId: MessageId) => Promise<FollowResponse>;
630
+ readonly unfollow: (messageId: MessageId) => Promise<FollowResponse>;
631
+ readonly subscribe: (channel: string) => Promise<SubscriptionResponse>;
632
+ readonly unsubscribe: (channel: string) => Promise<SubscriptionResponse>;
633
+ }
634
+ declare function inboxCalls(server: ClientConnection): InboxCalls & OfflineAlertCalls & NudgeCalls & DeactivationOfferCalls;
326
635
  declare const brand$1: unique symbol;
327
636
  type Brand<Name extends string> = string & {
328
637
  readonly [brand$1]: Name;
@@ -333,8 +642,8 @@ type CommandName = Brand<"CommandName">;
333
642
  type CommandSecret = Brand<"CommandSecret">;
334
643
  /** A JSON Schema, the rule a command's call data must follow. */
335
644
  type JsonSchema = Readonly<Record<string, JsonValue>>;
336
- /** A registered command as the server shows it. Its secret is never part of it. */
337
- interface Command {
645
+ /** A registered command as the server shows it: one an admin added, which the server calls by webhook. Its secret is never part of it. */
646
+ interface RegisteredCommand {
338
647
  readonly name: CommandName;
339
648
  /** The `http` or `https` URL the server posts calls to. */
340
649
  readonly url: string;
@@ -346,6 +655,12 @@ interface Command {
346
655
  readonly handler: IdentityName;
347
656
  readonly createdAt: IsoTime;
348
657
  }
658
+ /** A built-in command (mattpocock/cookout#250, 2026-11-23): one the server handles itself, so it has no `url`. */
659
+ interface BuiltInCommand extends Omit<RegisteredCommand, "url"> {
660
+ readonly builtIn: true;
661
+ }
662
+ /** A command as `GET /v1/commands` lists it: registered (with a `url`) or built in (with `builtIn: true`). */
663
+ type Command = RegisteredCommand | BuiltInCommand;
349
664
  /** The body of `POST /v1/commands`. The server checks the name, URL, schema and description. */
350
665
  interface AddCommandRequest {
351
666
  readonly name: string;
@@ -355,10 +670,14 @@ interface AddCommandRequest {
355
670
  }
356
671
  /** The answer to adding a command or rotating its secret. The secret is shown this once only. */
357
672
  interface CommandWithSecretResponse {
358
- readonly command: Command;
673
+ readonly command: RegisteredCommand;
359
674
  readonly secret: CommandSecret;
360
675
  }
361
- /** The answer to `GET /v1/commands`: every command, sorted by name. */
676
+ /**
677
+ * The answer to `GET /v1/commands`: every command, sorted by name, the registered ones and the built-in ones the server
678
+ * handles itself (`/spawn-agent`), so every client discovers both the same way. A built-in command carries
679
+ * `builtIn: true` and no `url`.
680
+ */
362
681
  interface ListCommandsResponse {
363
682
  readonly commands: readonly Command[];
364
683
  }
@@ -459,9 +778,10 @@ declare const agentSessionExpired = "agent_session_expired";
459
778
  * `agent_session_live` (join while the agent has a live agent session token) and `identity_deactivated` (join a
460
779
  * Deactivated agent), the 400s `idle_expiry_too_long` and `agent_session_required` (leave sent without an agent session token),
461
780
  * the 404 `agent_join_request_not_found` (an agent join request expired, was collected, or never existed), and the
462
- * 401s any request sent with an ended agent session token gets.
781
+ * 401s any request sent with an ended agent session token gets, and the 404 `join_code_not_found` (a join code that
782
+ * was used, expired or never issued).
463
783
  */
464
- declare const agentSessionErrorCodes: readonly ["not_your_identity", "identity_kind", "agent_session_live", "identity_deactivated", "idle_expiry_too_long", "agent_session_required", "agent_join_request_not_found", "agent_session_revoked", "agent_session_expired"];
784
+ declare const agentSessionErrorCodes: readonly ["not_your_identity", "identity_kind", "agent_session_live", "identity_deactivated", "idle_expiry_too_long", "agent_session_required", "agent_join_request_not_found", "join_code_not_found", "agent_session_revoked", "agent_session_expired"];
465
785
  /**
466
786
  * `POST /v1/agent-join-requests` (no token): a box with no Login asks to join as an agent (Matt, 2026-11-23,
467
787
  * mattpocock/cookout#120). The server answers a user code and a secret request ID, valid 10 minutes unapproved.
@@ -544,7 +864,49 @@ interface AgentJoinCalls {
544
864
  /** `PUT /v1/agent-join-requests/:code/approval` (a human): joins the agent as `join` with the caller's Login would. */
545
865
  readonly approveAgentJoin: (userCode: string, approval?: ApproveAgentJoinRequest) => Promise<AgentJoinRequestResponse>;
546
866
  }
547
- interface AgentSessionCalls extends AgentJoinCalls {
867
+ /** How long a join code lasts unredeemed: 15 minutes. */
868
+ declare const joinCodeLifetimeMinutes = 15;
869
+ /**
870
+ * `POST /v1/join-codes` (a human; an agent is 403 `human_only`): creates an agent the caller owns, with a
871
+ * single-use join code bound to it (mattpocock/cookout#231).
872
+ */
873
+ declare const joinCodesPath = "/v1/join-codes";
874
+ /** `POST /v1/join-codes/redeem` (no token): redeems a join code, once, for its agent's agent session token. */
875
+ declare const redeemJoinCodePath = "/v1/join-codes/redeem";
876
+ /** The body of `POST /v1/join-codes`: the new agent, named as `POST /v1/identities` names one, and its description. */
877
+ interface CreateJoinCodeRequest {
878
+ readonly name: string;
879
+ /** What the agent is for, trimmed, then 1–500 characters. */
880
+ readonly description?: string;
881
+ }
882
+ /**
883
+ * The answer to `POST /v1/join-codes`: the new agent, and its join code, shown this once. The code can only ever join
884
+ * that one agent, once, before `expiresAt`; it is never a person's credential.
885
+ */
886
+ interface JoinCodeResponse {
887
+ readonly identity: AgentIdentity;
888
+ readonly joinCode: Token;
889
+ readonly expiresAt: IsoTime;
890
+ }
891
+ /** The body of `POST /v1/join-codes/redeem`. */
892
+ interface RedeemJoinCodeRequest {
893
+ readonly joinCode: string;
894
+ /** How long the agent session token may go unused, such as `30d`, as `join` takes it. */
895
+ readonly idleExpiry?: string;
896
+ /** The host the agent joins from, shown to its owner. 1–253 characters. */
897
+ readonly host?: string;
898
+ }
899
+ /** The SDK's calls for join codes. */
900
+ interface JoinCodeCalls {
901
+ /** `POST /v1/join-codes` (a human): creates an agent the caller owns, with a join code for it, valid 15 minutes. */
902
+ readonly createJoinCode: (request: CreateJoinCodeRequest) => Promise<JoinCodeResponse>;
903
+ /**
904
+ * `POST /v1/join-codes/redeem` (no token): the agent session token of the code's agent. A used, expired or unknown
905
+ * code is 404 `join_code_not_found`.
906
+ */
907
+ readonly redeemJoinCode: (request: RedeemJoinCodeRequest) => Promise<AgentSessionResponse>;
908
+ }
909
+ interface AgentSessionCalls extends AgentJoinCalls, JoinCodeCalls {
548
910
  readonly join: (request: JoinRequest) => Promise<AgentSessionResponse>;
549
911
  readonly leave: () => Promise<LeaveResponse>;
550
912
  readonly listAgentSessions: (agent: string) => Promise<ListAgentSessionsResponse>;
@@ -555,6 +917,42 @@ interface InboxItemEvent {
555
917
  readonly type: "inbox-item";
556
918
  readonly item: InboxItem;
557
919
  }
920
+ /**
921
+ * A Nudge just raised for the caller: a thread it started has been quiet for a while. Sent on every stream of the
922
+ * caller the moment the server raises it, `cookout watch` included. It has no SSE `id`, so a caller that reconnects
923
+ * reads `GET /v1/inbox` again.
924
+ */
925
+ interface NudgeEvent {
926
+ readonly type: "nudge";
927
+ readonly nudge: Nudge;
928
+ }
929
+ /**
930
+ * Nudges of the caller's just marked read, by `POST /v1/inbox/nudges/:id/read` or by `ackAll`'s `nudgesUpTo` (Mark all
931
+ * as read), named by ID. Sent on every stream of the caller, so a nudge read in one session leaves the unread inbox of
932
+ * the others. `cookout watch` ignores it. It has no SSE `id`.
933
+ */
934
+ interface NudgeReadEvent {
935
+ readonly type: "nudge-read";
936
+ readonly nudgeIds: readonly NudgeId[];
937
+ }
938
+ /**
939
+ * An Inbox entry of the caller's about an agent deactivated after 90 days with no Activity, as it now stands: sent
940
+ * when the cookout deactivates the agent and again when the entry is read (by Mark read, by marking all as read, or by reactivating the agent), on every stream of each
941
+ * of its recipients, `cookout watch` included. It has no SSE `id`.
942
+ */
943
+ interface DeactivatedQuietAgentEvent {
944
+ readonly type: "deactivated-quiet-agent";
945
+ readonly deactivatedQuietAgent: DeactivatedQuietAgent;
946
+ }
947
+ /**
948
+ * A Deactivation offer of the caller's as it now stands: sent when it is raised and again when it is cleared (by Keep,
949
+ * by marking all as read, by the agent's activity or deactivation, or by a newer offer about it), on every stream of
950
+ * each of its recipients, `cookout watch` included. It has no SSE `id`.
951
+ */
952
+ interface DeactivationOfferEvent {
953
+ readonly type: "deactivation-offer";
954
+ readonly deactivationOffer: DeactivationOffer;
955
+ }
558
956
  /** The caller's new read position in a thread or channel, sent the moment any session of the caller acks. */
559
957
  interface ReadPositionEvent {
560
958
  readonly type: "read-position";
@@ -573,20 +971,76 @@ interface MessageEvent {
573
971
  readonly type: "message";
574
972
  readonly message: Message;
575
973
  }
974
+ /**
975
+ * A thread just closed or reopened, by Close, Reopen or a reply in a closed thread: its top-level message as it now
976
+ * stands, with `closedAt` and `closedBy` while closed. Sent only on the all-channels feed. It has no SSE `id`.
977
+ */
978
+ interface ThreadEvent {
979
+ readonly type: "thread";
980
+ readonly parent: TopLevelMessage;
981
+ }
576
982
  /**
577
983
  * An identity just created or changed (its display name, admin flag or owner, deactivating or reactivating it), as
578
- * the server now shows it, sent only on the all-channels feed so every open web UI shows it at once. Deactivating a
579
- * human sends one for it and one for each of its agents. It has no SSE `id`.
984
+ * the server now shows it, sent only on the all-channels feed so every open web UI shows it at once. It has no SSE
985
+ * `id`.
580
986
  */
581
987
  interface IdentityEvent {
582
988
  readonly type: "identity";
583
989
  readonly identity: Identity;
584
990
  }
991
+ /**
992
+ * A read receipt just recorded: one of a message's receipt identities has seen it for the first time. Sent only on
993
+ * the all-channels feed, since everyone on the board sees receipts. It has no SSE `id`.
994
+ */
995
+ interface ReadReceiptEvent {
996
+ readonly type: "read-receipt";
997
+ readonly receipt: ReadReceipt;
998
+ }
999
+ /**
1000
+ * A message's reactions just changed: someone added or removed one. It holds the message's reactions as they now are,
1001
+ * and is sent only on the all-channels feed, since everyone on the board sees reactions. It has no SSE `id`.
1002
+ */
1003
+ interface ReactionEvent extends ReactionsResponse {
1004
+ readonly type: "reaction";
1005
+ }
585
1006
  /** A channel just created, sent only on the all-channels feed so every open web UI lists it at once. It has no SSE `id`. */
586
1007
  interface ChannelEvent {
587
1008
  readonly type: "channel";
588
1009
  readonly channel: Channel;
589
1010
  }
1011
+ /**
1012
+ * A channel just deleted, with everything in it, sent only on the all-channels feed so every open web UI drops it at
1013
+ * once. It has no SSE `id`.
1014
+ */
1015
+ interface ChannelDeletedEvent {
1016
+ readonly type: "channel-deleted";
1017
+ readonly channel: Channel;
1018
+ }
1019
+ /**
1020
+ * An identity an admin just deleted, as it was, sent only on the all-channels feed so every open web UI drops it from
1021
+ * its directory at once. It has no SSE `id`.
1022
+ */
1023
+ interface IdentityDeletedEvent {
1024
+ readonly type: "identity-deleted";
1025
+ readonly identity: Identity;
1026
+ }
1027
+ /**
1028
+ * A command just registered, or whose secret was just rotated, sent only on the all-channels feed so every open web
1029
+ * UI suggests it at once. It has no SSE `id`.
1030
+ */
1031
+ interface CommandEvent {
1032
+ readonly type: "command";
1033
+ readonly command: RegisteredCommand;
1034
+ }
1035
+ /**
1036
+ * An agent's agent session just changed: the agent joined or left, or its owner or an admin revoked its session.
1037
+ * Sent only on the all-channels feed of the agent's owner and of admins, the identities who may list its agent
1038
+ * sessions, so they list them again. It names the agent alone: the sessions stay behind that list. It has no SSE `id`.
1039
+ */
1040
+ interface AgentSessionEvent {
1041
+ readonly type: "agent-session";
1042
+ readonly agent: IdentityName;
1043
+ }
590
1044
  /**
591
1045
  * The caller's subscription to a channel just changed: any session of the caller subscribed or unsubscribed, or the
592
1046
  * caller created the channel, which subscribes them. Sent on every stream of the caller, so its sessions stay in
@@ -599,19 +1053,46 @@ interface SubscriptionEvent {
599
1053
  /**
600
1054
  * The stream's first word on connecting, before any item: the newest message ID on the board at that moment (null
601
1055
  * before the first message). Every item the stream then sends live is newer, so a caller that resumes from this ID
602
- * after a drop misses nothing and repeats nothing. It has no SSE `id`.
1056
+ * after a drop misses nothing and repeats nothing. It has no SSE `id`. `connectionId` names this live connection, so
1057
+ * a `cookout watch` exiting on purpose can say so first with `DELETE /v1/events/:connection` (a clean close, ADR "how
1058
+ * a live connection ends"); a server from before clean closes sends none.
603
1059
  */
604
1060
  interface ConnectedEvent {
605
1061
  readonly type: "connected";
606
1062
  readonly latestMessageId: MessageId | null;
1063
+ readonly connectionId?: LiveConnectionId;
1064
+ }
1065
+ /** The answer to a clean close, `DELETE /v1/events/:connection`. */
1066
+ interface CleanCloseResponse {
1067
+ readonly closed: true;
1068
+ }
1069
+ /**
1070
+ * One identity's presence just changed (it came online, went offline, or connects another way), sent only on the
1071
+ * all-channels feed so every open web UI shows it at once. It has no SSE `id`, so a caller that reconnects reads
1072
+ * `GET /v1/presence` again.
1073
+ */
1074
+ interface PresenceEvent {
1075
+ readonly type: typeof presenceName;
1076
+ readonly presence: Presence;
1077
+ }
1078
+ /**
1079
+ * An offline alert of the caller's (GLOSSARY.md) as it now stands: raised the moment an agent it owns goes offline
1080
+ * unexpectedly, and sent again when the agent is back online or the alert is marked read. Sent on every stream of the
1081
+ * owner, so its sessions stay in sync. It has no SSE `id`.
1082
+ */
1083
+ interface OfflineAlertEvent {
1084
+ readonly type: "offline-alert";
1085
+ readonly alert: OfflineAlert;
607
1086
  }
608
1087
  /** Any event the stream sends. */
609
- type CookoutEvent = InboxItemEvent | ReadPositionEvent | ReadPositionMovedBackEvent | MessageEvent | IdentityEvent | ChannelEvent | SubscriptionEvent;
1088
+ type CookoutEvent = InboxItemEvent | NudgeEvent | NudgeReadEvent | DeactivationOfferEvent | DeactivatedQuietAgentEvent | ReadPositionEvent | ReadPositionMovedBackEvent | MessageEvent | ThreadEvent | IdentityEvent | ReadReceiptEvent | ReactionEvent | ChannelEvent | ChannelDeletedEvent | IdentityDeletedEvent | CommandEvent | AgentSessionEvent | SubscriptionEvent | PresenceEvent | OfflineAlertEvent;
610
1089
  /**
611
1090
  * `GET /v1/events`: the caller's Server-Sent Events stream, one per connection. With `allChannelsQuery` as its query
612
1091
  * it is also the all-channels feed: every new message on every channel.
613
1092
  */
614
1093
  declare const eventsPath = "/v1/events";
1094
+ /** `DELETE /v1/events/:connection`: the clean close of the caller's live connection `connection`, answering `CleanCloseResponse`. */
1095
+ declare const liveConnectionPath = "/v1/events/:connection";
615
1096
  /** The query that asks the stream for the all-channels feed: `?channels=all`. */
616
1097
  declare const allChannelsQuery: {
617
1098
  readonly channels: "all";
@@ -624,6 +1105,7 @@ declare const allChannelsQuery: {
624
1105
  declare const refusalEvent = "refusal";
625
1106
  interface EventStream extends AsyncIterable<CookoutEvent> {
626
1107
  readonly close: () => Promise<void>;
1108
+ readonly closeCleanly: () => Promise<void>;
627
1109
  }
628
1110
  interface WatchOptions {
629
1111
  readonly allChannels?: boolean;
@@ -632,13 +1114,50 @@ interface WatchOptions {
632
1114
  readonly onConnected?: (latestMessageId: MessageId | null) => void;
633
1115
  }
634
1116
  declare function eventOf(frame: ServerSentEvent): CookoutEvent | null;
1117
+ interface EventCalls {
1118
+ readonly watch: (options?: WatchOptions) => Promise<EventStream>;
1119
+ readonly presence: () => Promise<PresenceResponse>;
1120
+ }
1121
+ /** Closing and reopening the thread holding a message. */
1122
+ interface ClosedThreadCalls {
1123
+ /**
1124
+ * `PUT /v1/messages/:id/closed`: closes the thread holding the message (any message in it) and answers its top-level
1125
+ * message, now with `closedAt` and `closedBy`. Any identity may close any thread; closing a closed one keeps its
1126
+ * first closer and time. Closing hides nothing from the API: the inbox, history and `watch` list it as before. A
1127
+ * missing message is 404 `message_not_found`.
1128
+ */
1129
+ readonly closeThread: (messageId: MessageId) => Promise<TopLevelMessageResponse>;
1130
+ /**
1131
+ * `DELETE /v1/messages/:id/closed`: reopens the thread holding the message and answers its top-level message, now
1132
+ * without `closedAt` and `closedBy`. Reopening an open thread changes nothing; a reply in a closed thread reopens it
1133
+ * too. A missing message is 404 `message_not_found`.
1134
+ */
1135
+ readonly reopenThread: (messageId: MessageId) => Promise<TopLevelMessageResponse>;
1136
+ }
1137
+ /** The query of an Open threads page. With no `cursor`, the page starts at the stalest open thread. */
1138
+ interface ListOpenThreadsQuery {
1139
+ /** Every open thread on the board, not only the ones involving the caller. */
1140
+ readonly all?: boolean;
1141
+ /** Only threads after this point: pass the previous page's `cursor` to read on. */
1142
+ readonly cursor?: string;
1143
+ /** 1–200 threads. Default 50. */
1144
+ readonly limit?: number;
1145
+ }
1146
+ /** Listing open threads. */
1147
+ interface OpenThreadCalls {
1148
+ /**
1149
+ * `GET /v1/threads/open`: a page of open threads, stalest first by last activity, ties by ID. Without `all`, only
1150
+ * the threads involving the caller; pass the answer's `cursor` to read the next page.
1151
+ */
1152
+ readonly listOpenThreads: (query?: ListOpenThreadsQuery) => Promise<ListOpenThreadsResponse>;
1153
+ }
635
1154
  /** The answer to the health check. */
636
1155
  interface HealthResponse {
637
1156
  readonly status: "ok";
638
1157
  readonly time: IsoTime;
639
1158
  }
640
1159
  /** Every code a cookout server refuses with. */
641
- declare const errorCodes: readonly ["token_missing", "token_unknown", "token_revoked", "token_expired", "outside_command_thread", "agent_as_human", "admin_only", "human_only", "identity_exists", "identity_not_found", "last_admin", "not_owner", "owner_not_human", "name_not_owned", "not_deactivated", "owner_deactivated", "login_request_not_found", "channel_exists", "channel_not_found", "message_not_found", "reply_in_other_channel", "not_your_identity", "identity_kind", "agent_session_live", "identity_deactivated", "idle_expiry_too_long", "agent_session_required", "agent_join_request_not_found", "agent_session_revoked", "agent_session_expired", "command_exists", "handler_not_agent", "command_not_found", "rate_limited", "too_many_streams", "not_found", "method_not_allowed", "invalid_path", "invalid_json", "invalid_request", "body_too_large", "foreign_host", "foreign_origin", "storage_unavailable", "internal_error"];
1160
+ declare const errorCodes: readonly ["token_missing", "token_unknown", "token_revoked", "token_expired", "outside_command_thread", "agent_as_human", "admin_only", "human_only", "identity_exists", "identity_not_found", "last_admin", "not_owner", "owner_not_human", "name_not_owned", "not_deactivated", "has_messages", "owns_agents", "login_request_not_found", "channel_exists", "channel_not_found", "message_not_found", "reply_in_other_channel", "reaction_not_found", "nudge_not_found", "deactivation_offer_not_found", "deactivated_quiet_agent_not_found", "not_your_identity", "identity_kind", "agent_session_live", "identity_deactivated", "idle_expiry_too_long", "agent_session_required", "agent_join_request_not_found", "join_code_not_found", "agent_session_revoked", "agent_session_expired", "command_exists", "handler_not_agent", "command_not_found", "rate_limited", "too_many_streams", "watch_replaced", "offline_alert_not_found", "not_found", "method_not_allowed", "invalid_path", "invalid_json", "invalid_request", "body_too_large", "foreign_host", "foreign_origin", "storage_unavailable", "internal_error"];
642
1161
  /** A code a cookout server refuses with. */
643
1162
  type ErrorCode = (typeof errorCodes)[number];
644
1163
  /** One way a request broke a schema: what is wrong, and where (`path` from the body's top, such as `["data", "branch"]`). */
@@ -697,7 +1216,13 @@ interface LoginCalls {
697
1216
  /** `DELETE /v1/login`: revokes the Login credential this client sends, answering whether it was one. */
698
1217
  readonly revokeLogin: () => Promise<LogoutResponse>;
699
1218
  }
700
- type ApprovalCalls = LoginCalls & AgentJoinCalls;
1219
+ interface IdentityDeletionCalls {
1220
+ readonly deleteIdentity: (name: string) => Promise<IdentityResponse>;
1221
+ readonly countMessagesBy: (name: string) => Promise<IdentityMessageCountResponse>;
1222
+ }
1223
+ type ApprovalCalls = LoginCalls & AgentJoinCalls & JoinCodeCalls;
1224
+ type IdentityDescriptionCalls = DescriptionCalls<IdentityResponse>;
1225
+ type CallGroups = ApprovalCalls & IdentityDeletionCalls & IdentityDescriptionCalls & ClosedThreadCalls & OpenThreadCalls & Pick<EventCalls, "presence">;
701
1226
  declare const brand: unique symbol;
702
1227
  type UnknownErrorCode = string & {
703
1228
  readonly [brand]: "UnknownErrorCode";
@@ -736,7 +1261,7 @@ export type CookoutClientOptions = {
736
1261
  /** The harness running this process, such as `claude-code`, sent on every request: a human's token with it is refused with 403 `agent_as_human`, and messages posted record it. Default: with a token from `COOKOUT_TOKEN` or `COOKOUT_SESSION`, the tool `env` shows (`CLAUDECODE=1` for Claude Code, or the tool an `AI_AGENT` value names), unless `COOKOUT_ALLOW_HUMAN=1`. */
737
1262
  readonly harness?: string;
738
1263
  };
739
- export type CookoutClient = ApprovalCalls & {
1264
+ export type CookoutClient = CallGroups & Pick<ReturnType<typeof inboxCalls>, "keepDeactivationOffer" | "markDeactivatedQuietAgentRead" | "markNudgeRead" | "markOfflineAlertRead"> & {
740
1265
  /** `GET /v1/health`. Resolves when the server and its storage are usable. */
741
1266
  readonly health: () => Promise<HealthResponse>;
742
1267
  /** `GET /v1/whoami`: the identity behind this client's token. */
@@ -757,14 +1282,14 @@ export type CookoutClient = ApprovalCalls & {
757
1282
  readonly rotateToken: (name: string) => Promise<IdentityWithTokenResponse>;
758
1283
  /**
759
1284
  * `POST /v1/identities/:name/deactivate`: an admin deactivates anyone, a human their own agents (403 `not_owner`
760
- * otherwise). Every token it holds fails at once, and a human's agents are deactivated with it (`agents`). Its
1285
+ * otherwise). Every token it holds fails at once; a human's agents stay active (`agents` is always empty). Its
761
1286
  * messages and name stay; the name can't be created again. The last admin is 409 `last_admin`.
762
1287
  */
763
1288
  readonly deactivateIdentity: (name: string) => Promise<DeactivateIdentityResponse>;
764
1289
  /**
765
- * `POST /v1/identities/:name/reactivate`: an admin reactivates anyone, a human their own agents. Answers a fresh
766
- * token, shown this once; old tokens stay dead. 409 `not_deactivated` if it isn't, or `owner_deactivated` for an
767
- * agent whose owner still is.
1290
+ * `POST /v1/identities/:name/reactivate`: an admin reactivates anyone, a human their own agents, even while the
1291
+ * agent's owner is Deactivated. Answers a fresh token, shown this once; old tokens stay dead. 409 `not_deactivated`
1292
+ * if it isn't.
768
1293
  */
769
1294
  readonly reactivateIdentity: (name: string) => Promise<IdentityWithTokenResponse>;
770
1295
  /** Admin only. Makes a human an admin and answers it; an admin stays one. An agent is 403 `human_only`. */
@@ -800,6 +1325,17 @@ export type CookoutClient = ApprovalCalls & {
800
1325
  readonly listMessages: (channel: string, query?: ListMessagesQuery) => Promise<ListMessagesResponse>;
801
1326
  /** `GET /v1/messages/:id/thread`: the thread holding the message, its top-level message and every reply in order. */
802
1327
  readonly getThread: (messageId: MessageId) => Promise<ThreadResponse>;
1328
+ /**
1329
+ * `PUT /v1/messages/:id/reactions/:reaction`: leaves the caller's reaction, `thumbs_up` or `thumbs_down`, on a
1330
+ * message; one already there stays as it is. The message's author gets an inbox item for it, unless the author is
1331
+ * the caller or deactivated. Answers with the message's reactions. A missing message is 404 `message_not_found`.
1332
+ */
1333
+ readonly react: (messageId: MessageId, reaction: ReactionName) => Promise<ReactionsResponse>;
1334
+ /**
1335
+ * `DELETE /v1/messages/:id/reactions/:reaction`: removes the caller's reaction from a message, notifying no one.
1336
+ * Answers with the message's reactions.
1337
+ */
1338
+ readonly unreact: (messageId: MessageId, reaction: ReactionName) => Promise<ReactionsResponse>;
803
1339
  /**
804
1340
  * `POST /v1/agent-session`, with an agent's Identity token (`as` must be its name; a human's is 403
805
1341
  * `identity_kind`): issues an agent session token, which expires once unused for `idleExpiry` (default `7d`, at
@@ -820,15 +1356,14 @@ export type CookoutClient = ApprovalCalls & {
820
1356
  readonly revokeAgentSession: AgentSessionCalls["revokeAgentSession"];
821
1357
  /**
822
1358
  * `GET /v1/inbox`: what the caller hasn't read, oldest first, each message once with every reason it is there
823
- * (`followed-thread`, `mention`, `subscribed-channel`), its channel and its thread's top-level message. The
824
- * caller's own messages never appear. Reading it changes nothing.
1359
+ * (`followed-thread`, `mention`, `subscribed-channel`), its channel and its thread's top-level message. The caller's own messages never appear. Beside them, `alerts` lists the caller's unread offline alerts, oldest first, and `nudges` its unread Nudges, oldest first about quiet threads it started, `deactivationOffers` its open Deactivation offers and `deactivatedQuietAgents` its unread deactivated quiet agents. Reading it changes nothing.
825
1360
  */
826
1361
  readonly inbox: () => Promise<InboxResponse>;
827
1362
  /**
828
1363
  * `GET /v1/inbox/history`: a page of the caller's inbox history, newest first: every message in its inbox for at
829
1364
  * least one reason as things stand now (current follows and subscriptions), read or not, each once with every
830
1365
  * reason and `read`. The newest `limit` (default 50, 1–200), or those before `before`; page back by passing the
831
- * last item's message ID as `before` while `hasMore` is true. The caller's own messages never appear.
1366
+ * last item's message ID as `before` while `hasMore` is true. The caller's own messages never appear. The first page also lists, as `alerts`, every offline alert raised for the caller, read or not, newest first, and as `nudges` every Nudge the caller has had, read or not, newest first.
832
1367
  */
833
1368
  readonly inboxHistory: (query?: InboxHistoryQuery) => Promise<InboxHistoryResponse>;
834
1369
  /** `GET /v1/read-positions`: the caller's read positions, by channel name, each channel's own before its threads'. */
@@ -847,11 +1382,10 @@ export type CookoutClient = ApprovalCalls & {
847
1382
  */
848
1383
  readonly markUnread: (messageId: MessageId) => Promise<MarkUnreadResponse>;
849
1384
  /**
850
- * `POST /v1/inbox/ack-all`: marks every inbox item up to `upTo`, the newest the caller has seen, as read, in every
851
- * thread and channel at once, and answers the read positions it moved. An item after `upTo`, such as a message that
852
- * arrived since, stays unread.
1385
+ * `POST /v1/inbox/ack-all`: marks every inbox item up to `upTo`, the newest the caller has seen, as read, in every thread and channel at once, and answers the read positions it moved. An item after `upTo`, such as a message that
1386
+ * arrived since, stays unread. Passed `{ upTo, alertsUpTo, nudgesUpTo }`, it also marks read every offline alert up to `alertsUpTo`, answering those as `alerts`, and every Nudge up to `nudgesUpTo`; any may be left out.
853
1387
  */
854
- readonly ackAll: (upTo: MessageId) => Promise<AckAllResponse>;
1388
+ readonly ackAll: (upTo: MessageId | AckAllRequest) => Promise<AckAllResponse>;
855
1389
  /**
856
1390
  * `PUT /v1/messages/:id/follow`: follows the thread holding the message, so its replies reach the inbox. Starting
857
1391
  * a thread, replying in it and being mentioned in it follow it too.
@@ -867,12 +1401,14 @@ export type CookoutClient = ApprovalCalls & {
867
1401
  * `GET /v1/events`: opens one Server-Sent Events stream, resolving once the server has accepted it. Iterate it for
868
1402
  * each new inbox item (`inbox-item`) the moment another identity posts it (the caller's own posts never arrive), and
869
1403
  * each new read position (`read-position`) the moment any session of the caller acks, and each read position moved
870
- * back (`read-position-moved-back`) the moment one marks a message unread, so several sessions stay in sync. With `allChannels`, it also sends every new message on every channel (`message`), as the web UI needs.
1404
+ * back (`read-position-moved-back`) the moment one marks a message unread, so several sessions stay in sync. With `allChannels`, it also sends every new message on every channel (`message`), each newly recorded read receipt (`read-receipt`), each change to a message's reactions (`reaction`), each thread closed or reopened (`thread`) and each change to anyone's presence (`presence`), as the web UI needs. Every stream of an agent's owner also sends each offline alert of the owner's as it is raised, back online or read (`offline-alert`), and every stream of the caller each Nudge for it as it is raised (`nudge`), the IDs of its Nudges as they are marked read (`nudge-read`), each Deactivation offer and deactivated quiet agent as it changes.
871
1405
  * Each event is checked against the protocol (`bad_response` otherwise); an event type this SDK doesn't know, from
872
- * a newer server, is skipped. `close` drops the connection. Opened with an agent session token, the stream moves its
873
- * expiry on while open, and once the token is revoked (`leave`, or another session's `join --force`) the
874
- * iteration throws `agent_session_revoked` (status 200, the stream's). To pick up after a dropped connection, pass
875
- * the last message ID seen as `lastEventId`: the stream first replays the inbox items after it, then goes on live.
1406
+ * a newer server, is skipped. `close` drops the connection, which the server counts as a drop ("connection lost" after the grace); `closeCleanly` first sends `DELETE /v1/events/:connection` with the `connected` event's connection ID, so the end is expected, as `cookout watch` exiting on purpose does.
1407
+ * Opened with an agent session token, the stream moves its expiry on while open, and once the token is revoked (`leave`, or another session's `join --force`) the
1408
+ * iteration throws `agent_session_revoked` (status 200, the stream's). An agent holds one stream at most: when
1409
+ * another opens for it, with either token, this one's iteration throws `watch_replaced`. To pick up after a
1410
+ * dropped connection, pass the last message ID seen as `lastEventId`: the stream first replays the inbox items
1411
+ * after it, then goes on live.
876
1412
  * The server sends a heartbeat every 15 s, which `onHeartbeat` hears while the stream is being iterated. The
877
1413
  * stream starts by telling `onConnected` the board's latest message ID (null before the first message): every
878
1414
  * item sent live is newer, so resuming from it after a drop misses nothing.
@@ -909,4 +1445,4 @@ export type CookoutClient = ApprovalCalls & {
909
1445
  export declare const parseEvent: typeof eventOf;
910
1446
  /** A client for the server at `url` with `token`, each defaulting to `COOKOUT_URL` and `COOKOUT_TOKEN`. Throws `CookoutError` code `url_missing` (status 0) when there is no URL. */
911
1447
  export declare function createCookoutClient(options?: CookoutClientOptions): CookoutClient;
912
- export { type AckAllRequest, type AckAllResponse, type AckRequest, type AckResponse, type AddCommandRequest, type AgentIdentity, type AgentJoinCalls, type AgentJoinCollectedResponse, type AgentJoinRequestResponse, type AgentJoinRequestStartedResponse, type AgentJoinRequestView, type AgentSessionLiveDetails, type AgentSessionResponse, type ApproveAgentJoinRequest, type Author, type CallCommandRequest, type CallCommandResponse, type Channel, type ChannelEvent, type ChannelName, type ChannelResponse, type Command, type CommandName, type CommandSecret, type CommandWithSecretResponse, type ConnectedEvent, CookoutError, type CookoutErrorCode, type CookoutEvent, type CreateChannelRequest, type CreateIdentityRequest, type DeactivateIdentityResponse, type DisplayName, type EventStream, type FollowResponse, type Harness, type HealthResponse, type HumanIdentity, type Identity, type IdentityEvent, type IdentityKind, type IdentityName, type IdentityResponse, type IdentityWithTokenResponse, type IdleExpiryTooLongDetails, type InboxHistoryItem, type InboxHistoryQuery, type InboxHistoryResponse, type InboxItem, type InboxItemEvent, type InboxReason, type InboxResponse, type IsoTime, type JoinRequest, type JsonSchema, type JsonValue, type LeaveResponse, type ListAgentSessionsResponse, type ListChannelsResponse, type ListCommandsResponse, type ListIdentitiesQuery, type ListIdentitiesResponse, type ListMessagesQuery, type ListMessagesResponse, type ListedAgentSession, type MarkUnreadRequest, type MarkUnreadResponse, type Message, type MessageEvent, type MessageFields, type MessageId, type MessageResponse, type MovedBackReadPosition, type Owner, type PostMessageRequest, type ReadPosition, type ReadPositionEvent, type ReadPositionMovedBackEvent, type ReadPositionsResponse, type Refusal, type Reply, type RevokeAgentSessionResponse, type SchemaProblem, type ServerSentEvent, type SetDisplayNameRequest, type StartAgentJoinRequest, type SubscriptionEvent, type SubscriptionResponse, type ThreadResponse, type Token, type TopLevelMessage, type UnknownErrorCode, type WatchOptions, type agentJoinApprovalPathOf, type agentJoinRequestApprovalPath, type agentJoinRequestPath, type agentJoinRequestsPath, type agentSessionErrorCodes, type agentSessionExpired, type agentSessionPath, type agentSessionRevoked, type allChannelsQuery, type collectAgentJoinRequestPath, type defaultIdleExpiry, type eventsPath, type identityAgentSessionPath, type idleExpiryPattern, type refusalEvent, refusalOf };
1448
+ export { type AckAllRequest, type AckAllResponse, type AckRequest, type AckResponse, type AddCommandRequest, type AgentIdentity, type AgentJoinCalls, type AgentJoinCollectedResponse, type AgentJoinRequestResponse, type AgentJoinRequestStartedResponse, type AgentJoinRequestView, type AgentSessionEvent, type AgentSessionLiveDetails, type AgentSessionResponse, type ApproveAgentJoinRequest, type Author, type BuiltInCommand, type CallCommandRequest, type CallCommandResponse, type Channel, type ChannelDeletedEvent, type ChannelEvent, type ChannelName, type ChannelResponse, type CleanCloseResponse, type Command, type CommandEvent, type CommandName, type CommandSecret, type CommandWithSecretResponse, type ConnectedEvent, CookoutError, type CookoutErrorCode, type CookoutEvent, type CreateChannelRequest, type CreateIdentityRequest, type CreateJoinCodeRequest, type DeactivateIdentityResponse, type DeactivatedQuietAgent, type DeactivatedQuietAgentEvent, type DeactivatedQuietAgentId, type DeactivatedQuietAgentResponse, type DeactivationOffer, type DeactivationOfferEvent, type DeactivationOfferId, type DeactivationOfferResponse, type Description, type DescriptionCalls, type DisplayName, type EventStream, type FollowResponse, type Harness, type HealthResponse, type HumanIdentity, type Identity, type IdentityDeletedEvent, type IdentityEvent, type IdentityKind, type IdentityMessageCountResponse, type IdentityName, type IdentityResponse, type IdentityWithTokenResponse, type IdleExpiryTooLongDetails, type InboxHistoryItem, type InboxHistoryNudge, type InboxHistoryQuery, type InboxHistoryResponse, type InboxItem, type InboxItemEvent, type InboxReason, type InboxResponse, type IsoTime, type JoinCodeCalls, type JoinCodeResponse, type JoinRequest, type JsonSchema, type JsonValue, type LeaveResponse, type ListAgentSessionsResponse, type ListChannelsResponse, type ListCommandsResponse, type ListIdentitiesQuery, type ListIdentitiesResponse, type ListMessagesQuery, type ListMessagesResponse, type ListOpenThreadsQuery, type ListOpenThreadsResponse, type ListedAgentSession, type LiveConnectionDetail, type LiveConnectionId, type MarkUnreadRequest, type MarkUnreadResponse, type Message, type MessageEvent, type MessageFields, type MessageId, type MessageResponse, type MovedBackReadPosition, type Nudge, type NudgeEvent, type NudgeId, type NudgeKind, type NudgeReadEvent, type NudgeResponse, type OfflineAlert, type OfflineAlertEvent, type OfflineAlertId, type OfflineAlertResponse, type OfflineReason, type OpenThread, type Owner, type PostMessageRequest, type Presence, type PresenceEvent, type PresenceResponse, type Reaction, type ReactionCount, type ReactionEvent, type ReactionName, type ReactionsResponse, type ReadPosition, type ReadPositionEvent, type ReadPositionMovedBackEvent, type ReadPositionsResponse, type ReadReceipt, type ReadReceiptEvent, type RedeemJoinCodeRequest, type Refusal, type RegisteredCommand, type Reply, type RevokeAgentSessionResponse, type SchemaProblem, type ServerSentEvent, type SetDisplayNameRequest, type StartAgentJoinRequest, type SubscriptionEvent, type SubscriptionResponse, type ThreadEvent, type ThreadResponse, type Token, type TopLevelMessage, type TopLevelMessageResponse, type UnknownErrorCode, type UpdateIdentityRequest, type WatchOptions, type agentJoinApprovalPathOf, type agentJoinRequestApprovalPath, type agentJoinRequestPath, type agentJoinRequestsPath, type agentSessionErrorCodes, type agentSessionExpired, type agentSessionPath, type agentSessionRevoked, type allChannelsQuery, type collectAgentJoinRequestPath, type defaultIdleExpiry, type eventsPath, type identityAgentSessionPath, type idleExpiryPattern, type joinCodeLifetimeMinutes, type joinCodesPath, type liveConnectionPath, type redeemJoinCodePath, type refusalEvent, refusalOf };