@ai-hero/cookout 0.1.0 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +17 -11
- package/dist/main.js +60715 -24421
- package/dist/sdk.d.ts +739 -62
- package/dist/sdk.js +45677 -15992
- package/dist/web/assets/apple-touch-icon.png +0 -0
- package/dist/web/assets/favicon-32.png +0 -0
- package/dist/web/assets/favicon.svg +6 -0
- package/dist/web/assets/index-Cs147r85.css +2 -0
- package/dist/web/assets/index-ZNS0LNff.js +82 -0
- package/dist/web/assets/og-card.png +0 -0
- package/dist/web/index.html +16 -2
- package/docs/agents.md +116 -28
- package/package.json +11 -2
- package/skills/cookout/SKILL.md +10 -6
- package/dist/web/assets/index-CsgQEDSS.css +0 -2
- package/dist/web/assets/index-DlNlrOuW.js +0 -41
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$
|
|
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$
|
|
16
|
+
readonly [brand$9]: "IsoTime";
|
|
17
17
|
};
|
|
18
|
-
declare const brand$
|
|
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$
|
|
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
|
-
|
|
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$
|
|
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,10 +144,10 @@ type ListIdentitiesResponse = {
|
|
|
108
144
|
interface ListIdentitiesQuery {
|
|
109
145
|
readonly include?: "deactivated";
|
|
110
146
|
}
|
|
111
|
-
/** The answer to `POST /v1/identities/:name/deactivate`: the
|
|
147
|
+
/** The answer to `POST /v1/identities/:name/deactivate`: the deactivated identity. */
|
|
112
148
|
interface DeactivateIdentityResponse {
|
|
113
149
|
readonly identity: Identity;
|
|
114
|
-
/**
|
|
150
|
+
/** @deprecated Always empty, since a human's agents stay active; kept one release for older clients. */
|
|
115
151
|
readonly agents: readonly IdentityName[];
|
|
116
152
|
}
|
|
117
153
|
/**
|
|
@@ -135,17 +171,45 @@ interface SetDisplayNameRequest {
|
|
|
135
171
|
readonly displayName: string | null;
|
|
136
172
|
}
|
|
137
173
|
/**
|
|
138
|
-
* The
|
|
139
|
-
* and the SDK send it in `cookout-
|
|
174
|
+
* The harness running a client's process, such as `claude-code`: 1–40 lowercase letters, digits or `-`. The CLI
|
|
175
|
+
* and the SDK send it in `cookout-harness` when the process's environment shows such a tool runs it.
|
|
140
176
|
*/
|
|
141
|
-
type
|
|
142
|
-
declare const brand$
|
|
177
|
+
type Harness = Brand$1<"Harness">;
|
|
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$
|
|
212
|
+
readonly [brand$4]: "MessageId";
|
|
149
213
|
};
|
|
150
214
|
/** Any JSON value. */
|
|
151
215
|
type JsonValue = null | boolean | number | string | readonly JsonValue[] | {
|
|
@@ -167,9 +231,14 @@ interface MessageFields {
|
|
|
167
231
|
readonly data?: JsonValue;
|
|
168
232
|
/** Names of the identities the text mentions. */
|
|
169
233
|
readonly mentions: readonly IdentityName[];
|
|
170
|
-
/** The
|
|
171
|
-
readonly
|
|
234
|
+
/** The harness the message was posted from, such as `claude-code`. Absent when none was named. */
|
|
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;
|
|
313
|
+
}
|
|
314
|
+
/**
|
|
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.
|
|
317
|
+
*/
|
|
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;
|
|
225
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";
|
|
226
424
|
/**
|
|
227
|
-
*
|
|
228
|
-
* message
|
|
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.
|
|
229
428
|
*/
|
|
230
|
-
|
|
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
|
-
/**
|
|
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.
|
|
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,46 @@ interface AckRequest {
|
|
|
280
520
|
interface AckResponse {
|
|
281
521
|
readonly readPosition: ReadPosition;
|
|
282
522
|
}
|
|
283
|
-
/**
|
|
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
|
|
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
|
|
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;
|
|
546
|
+
}
|
|
547
|
+
/** The body of a mark unread: the message to make unread again, with everything after it in its thread or channel. */
|
|
548
|
+
interface MarkUnreadRequest {
|
|
549
|
+
readonly messageId: MessageId;
|
|
550
|
+
}
|
|
551
|
+
/**
|
|
552
|
+
* A read position moved back by a mark unread: `messageId` is the newest message in the scope still read, `null` where
|
|
553
|
+
* none is. In a thread with no reply left read it is the top-level message.
|
|
554
|
+
*/
|
|
555
|
+
interface MovedBackReadPosition {
|
|
556
|
+
readonly channel: ChannelName;
|
|
557
|
+
readonly thread: MessageId | null;
|
|
558
|
+
readonly messageId: MessageId | null;
|
|
559
|
+
}
|
|
560
|
+
/** The answer to a mark unread: the read position of the message's scope, which never moves forward. */
|
|
561
|
+
interface MarkUnreadResponse {
|
|
562
|
+
readonly readPosition: MovedBackReadPosition;
|
|
293
563
|
}
|
|
294
564
|
/** The answer to following or unfollowing: the thread, by its top-level message's ID. */
|
|
295
565
|
interface FollowResponse {
|
|
@@ -301,11 +571,67 @@ interface SubscriptionResponse {
|
|
|
301
571
|
readonly channel: ChannelName;
|
|
302
572
|
readonly subscribed: boolean;
|
|
303
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
|
+
}
|
|
304
607
|
/** One Server-Sent Event: its `event` name (`message` when it has none) and its `data`. */
|
|
305
608
|
interface ServerSentEvent {
|
|
306
609
|
readonly event: string;
|
|
307
610
|
readonly data: string;
|
|
308
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;
|
|
309
635
|
declare const brand$1: unique symbol;
|
|
310
636
|
type Brand<Name extends string> = string & {
|
|
311
637
|
readonly [brand$1]: Name;
|
|
@@ -316,8 +642,8 @@ type CommandName = Brand<"CommandName">;
|
|
|
316
642
|
type CommandSecret = Brand<"CommandSecret">;
|
|
317
643
|
/** A JSON Schema, the rule a command's call data must follow. */
|
|
318
644
|
type JsonSchema = Readonly<Record<string, JsonValue>>;
|
|
319
|
-
/** A registered command as the server shows it. Its secret is never part of it. */
|
|
320
|
-
interface
|
|
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 {
|
|
321
647
|
readonly name: CommandName;
|
|
322
648
|
/** The `http` or `https` URL the server posts calls to. */
|
|
323
649
|
readonly url: string;
|
|
@@ -329,6 +655,12 @@ interface Command {
|
|
|
329
655
|
readonly handler: IdentityName;
|
|
330
656
|
readonly createdAt: IsoTime;
|
|
331
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;
|
|
332
664
|
/** The body of `POST /v1/commands`. The server checks the name, URL, schema and description. */
|
|
333
665
|
interface AddCommandRequest {
|
|
334
666
|
readonly name: string;
|
|
@@ -338,10 +670,14 @@ interface AddCommandRequest {
|
|
|
338
670
|
}
|
|
339
671
|
/** The answer to adding a command or rotating its secret. The secret is shown this once only. */
|
|
340
672
|
interface CommandWithSecretResponse {
|
|
341
|
-
readonly command:
|
|
673
|
+
readonly command: RegisteredCommand;
|
|
342
674
|
readonly secret: CommandSecret;
|
|
343
675
|
}
|
|
344
|
-
/**
|
|
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
|
+
*/
|
|
345
681
|
interface ListCommandsResponse {
|
|
346
682
|
readonly commands: readonly Command[];
|
|
347
683
|
}
|
|
@@ -376,7 +712,7 @@ declare const idleExpiryPattern: RegExp;
|
|
|
376
712
|
* Sent with a human's token, `as` names an agent the human owns, or creates one (Matt, 2026-11-23,
|
|
377
713
|
* mattpocock/cookout#119): an agent the caller owns by that name is joined; else a free name is created, owned by
|
|
378
714
|
* the caller; else, when someone else has the name, `<caller>/<name>` is joined, or created. A human's name, or
|
|
379
|
-
* `<other>/<name>`, is refused. This is the one route a human's token may use from
|
|
715
|
+
* `<other>/<name>`, is refused. This is the one route a human's token may use from a harness.
|
|
380
716
|
*/
|
|
381
717
|
interface JoinRequest {
|
|
382
718
|
readonly as: string;
|
|
@@ -441,10 +777,136 @@ declare const agentSessionExpired = "agent_session_expired";
|
|
|
441
777
|
* the identity codes), the 409s
|
|
442
778
|
* `agent_session_live` (join while the agent has a live agent session token) and `identity_deactivated` (join a
|
|
443
779
|
* Deactivated agent), the 400s `idle_expiry_too_long` and `agent_session_required` (leave sent without an agent session token),
|
|
444
|
-
*
|
|
780
|
+
* the 404 `agent_join_request_not_found` (an agent join request expired, was collected, or never existed), and the
|
|
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).
|
|
783
|
+
*/
|
|
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"];
|
|
785
|
+
/**
|
|
786
|
+
* `POST /v1/agent-join-requests` (no token): a box with no Login asks to join as an agent (Matt, 2026-11-23,
|
|
787
|
+
* mattpocock/cookout#120). The server answers a user code and a secret request ID, valid 10 minutes unapproved.
|
|
788
|
+
*/
|
|
789
|
+
declare const agentJoinRequestsPath = "/v1/agent-join-requests";
|
|
790
|
+
/** `POST /v1/agent-join-requests/collect` (no token): 202 pending, then the agent session token once; 404 after. */
|
|
791
|
+
declare const collectAgentJoinRequestPath = "/v1/agent-join-requests/collect";
|
|
792
|
+
/** `GET /v1/agent-join-requests/:code` (a human): the live request with that user code, as it would join for the caller. */
|
|
793
|
+
declare const agentJoinRequestPath = "/v1/agent-join-requests/:code";
|
|
794
|
+
/** `PUT /v1/agent-join-requests/:code/approval` (a human; an agent is 403 `human_only`): approves it as the caller. */
|
|
795
|
+
declare const agentJoinRequestApprovalPath = "/v1/agent-join-requests/:code/approval";
|
|
796
|
+
/**
|
|
797
|
+
* The approval page's path on the server for an agent join request's user code.
|
|
798
|
+
* @param userCode The request's user code.
|
|
799
|
+
* @returns The path, such as `/#/approve-join/WDJB-MJHT`.
|
|
800
|
+
*/
|
|
801
|
+
declare function agentJoinApprovalPathOf(userCode: string): string;
|
|
802
|
+
/** The body of `POST /v1/agent-join-requests`: the agent to join as, the box's host and the idle expiry it asks for. */
|
|
803
|
+
interface StartAgentJoinRequest {
|
|
804
|
+
/** A name as `join` takes it: the approver's own agent, a free name, or else `<approver>/<name>`. */
|
|
805
|
+
readonly as: string;
|
|
806
|
+
/** The box's host name, shown on the approval page. 1–253 characters. */
|
|
807
|
+
readonly host: string;
|
|
808
|
+
/** The longest idle expiry the box asks for, such as `30d`; the approver may lower it. Default `7d`. */
|
|
809
|
+
readonly idleExpiry?: string;
|
|
810
|
+
}
|
|
811
|
+
/** A started agent join request. Only `requestId` collects the agent session token, and it is shown this once. */
|
|
812
|
+
interface AgentJoinRequestStartedResponse {
|
|
813
|
+
readonly userCode: string;
|
|
814
|
+
readonly requestId: Token;
|
|
815
|
+
readonly expiresAt: IsoTime;
|
|
816
|
+
readonly approvalPath: string;
|
|
817
|
+
}
|
|
818
|
+
/** Pending until a human approves, then the agent session token, once. Never a human's credential. */
|
|
819
|
+
type AgentJoinCollectedResponse = {
|
|
820
|
+
readonly status: "pending";
|
|
821
|
+
} | {
|
|
822
|
+
readonly status: "approved";
|
|
823
|
+
readonly agentSession: AgentSessionResponse;
|
|
824
|
+
};
|
|
825
|
+
/** An agent join request as the human viewing it would approve it. */
|
|
826
|
+
interface AgentJoinRequestView {
|
|
827
|
+
readonly userCode: string;
|
|
828
|
+
readonly host: string;
|
|
829
|
+
readonly expiresAt: IsoTime;
|
|
830
|
+
readonly approved: boolean;
|
|
831
|
+
/** The name the box asked to join as. */
|
|
832
|
+
readonly as: string;
|
|
833
|
+
/** The agent approving joins, such as `ada/triage-agent` when `triage-agent` is someone else's. */
|
|
834
|
+
readonly joins: IdentityName;
|
|
835
|
+
/** Whether approving creates that agent, owned by the approver. */
|
|
836
|
+
readonly creates: boolean;
|
|
837
|
+
/** The idle expiry the box asked for (or the default); the approver may lower it, never raise it. */
|
|
838
|
+
readonly idleExpiry: string;
|
|
839
|
+
/** When the agent's live agent session token expires, if it has one: approving replaces it only with `force`. */
|
|
840
|
+
readonly liveSessionExpiresAt?: IsoTime;
|
|
841
|
+
}
|
|
842
|
+
/** The answer to showing or approving an agent join request. */
|
|
843
|
+
interface AgentJoinRequestResponse {
|
|
844
|
+
readonly agentJoinRequest: AgentJoinRequestView;
|
|
845
|
+
}
|
|
846
|
+
/** The body of approving an agent join request. */
|
|
847
|
+
interface ApproveAgentJoinRequest {
|
|
848
|
+
/** A shorter idle expiry than the box asked for; longer is 400 `idle_expiry_too_long`. */
|
|
849
|
+
readonly idleExpiry?: string;
|
|
850
|
+
/** Replaces the agent's live agent session token, as `join --force`; without it, 409 `agent_session_live`. */
|
|
851
|
+
readonly force?: boolean;
|
|
852
|
+
}
|
|
853
|
+
/** The SDK's calls for an agent join request: a box with no Login joins once a person approves in the browser. */
|
|
854
|
+
interface AgentJoinCalls {
|
|
855
|
+
/** `POST /v1/agent-join-requests` (no token): starts an agent join request, which lasts 10 minutes unapproved. */
|
|
856
|
+
readonly startAgentJoin: (request: StartAgentJoinRequest) => Promise<AgentJoinRequestStartedResponse>;
|
|
857
|
+
/**
|
|
858
|
+
* `POST /v1/agent-join-requests/collect` (no token): `pending` until a human approves, then, once, the agent
|
|
859
|
+
* session token. A wrong, expired or collected request ID is 404 `agent_join_request_not_found`.
|
|
860
|
+
*/
|
|
861
|
+
readonly collectAgentJoin: (requestId: Token) => Promise<AgentJoinCollectedResponse>;
|
|
862
|
+
/** `GET /v1/agent-join-requests/:code` (a human): the request, and the agent approving it would join. */
|
|
863
|
+
readonly getAgentJoinRequest: (userCode: string) => Promise<AgentJoinRequestResponse>;
|
|
864
|
+
/** `PUT /v1/agent-join-requests/:code/approval` (a human): joins the agent as `join` with the caller's Login would. */
|
|
865
|
+
readonly approveAgentJoin: (userCode: string, approval?: ApproveAgentJoinRequest) => Promise<AgentJoinRequestResponse>;
|
|
866
|
+
}
|
|
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.
|
|
445
885
|
*/
|
|
446
|
-
|
|
447
|
-
|
|
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 {
|
|
448
910
|
readonly join: (request: JoinRequest) => Promise<AgentSessionResponse>;
|
|
449
911
|
readonly leave: () => Promise<LeaveResponse>;
|
|
450
912
|
readonly listAgentSessions: (agent: string) => Promise<ListAgentSessionsResponse>;
|
|
@@ -455,43 +917,195 @@ interface InboxItemEvent {
|
|
|
455
917
|
readonly type: "inbox-item";
|
|
456
918
|
readonly item: InboxItem;
|
|
457
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
|
+
}
|
|
458
956
|
/** The caller's new read position in a thread or channel, sent the moment any session of the caller acks. */
|
|
459
957
|
interface ReadPositionEvent {
|
|
460
958
|
readonly type: "read-position";
|
|
461
959
|
readonly readPosition: ReadPosition;
|
|
462
960
|
}
|
|
961
|
+
/**
|
|
962
|
+
* The caller's read position in a thread or channel moved back, sent the moment any session of the caller marks a
|
|
963
|
+
* message there unread: unlike `read-position`, it replaces the one before, though that was newer.
|
|
964
|
+
*/
|
|
965
|
+
interface ReadPositionMovedBackEvent {
|
|
966
|
+
readonly type: "read-position-moved-back";
|
|
967
|
+
readonly readPosition: MovedBackReadPosition;
|
|
968
|
+
}
|
|
463
969
|
/** A new message on any channel, the caller's own included, sent only on the all-channels feed. */
|
|
464
970
|
interface MessageEvent {
|
|
465
971
|
readonly type: "message";
|
|
466
972
|
readonly message: Message;
|
|
467
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
|
+
}
|
|
468
982
|
/**
|
|
469
983
|
* An identity just created or changed (its display name, admin flag or owner, deactivating or reactivating it), as
|
|
470
|
-
* the server now shows it, sent only on the all-channels feed so every open web UI shows it at once.
|
|
471
|
-
*
|
|
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`.
|
|
472
986
|
*/
|
|
473
987
|
interface IdentityEvent {
|
|
474
988
|
readonly type: "identity";
|
|
475
989
|
readonly identity: Identity;
|
|
476
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
|
+
}
|
|
477
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`. */
|
|
478
1007
|
interface ChannelEvent {
|
|
479
1008
|
readonly type: "channel";
|
|
480
1009
|
readonly channel: Channel;
|
|
481
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
|
+
}
|
|
1044
|
+
/**
|
|
1045
|
+
* The caller's subscription to a channel just changed: any session of the caller subscribed or unsubscribed, or the
|
|
1046
|
+
* caller created the channel, which subscribes them. Sent on every stream of the caller, so its sessions stay in
|
|
1047
|
+
* sync. It has no SSE `id`.
|
|
1048
|
+
*/
|
|
1049
|
+
interface SubscriptionEvent {
|
|
1050
|
+
readonly type: "subscription";
|
|
1051
|
+
readonly subscription: SubscriptionResponse;
|
|
1052
|
+
}
|
|
482
1053
|
/**
|
|
483
1054
|
* The stream's first word on connecting, before any item: the newest message ID on the board at that moment (null
|
|
484
1055
|
* before the first message). Every item the stream then sends live is newer, so a caller that resumes from this ID
|
|
485
|
-
* 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.
|
|
486
1059
|
*/
|
|
487
1060
|
interface ConnectedEvent {
|
|
488
1061
|
readonly type: "connected";
|
|
489
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;
|
|
490
1086
|
}
|
|
491
1087
|
/** Any event the stream sends. */
|
|
492
|
-
type CookoutEvent = InboxItemEvent | ReadPositionEvent | MessageEvent | IdentityEvent | ChannelEvent;
|
|
1088
|
+
type CookoutEvent = InboxItemEvent | NudgeEvent | NudgeReadEvent | DeactivationOfferEvent | DeactivatedQuietAgentEvent | ReadPositionEvent | ReadPositionMovedBackEvent | MessageEvent | ThreadEvent | IdentityEvent | ReadReceiptEvent | ReactionEvent | ChannelEvent | ChannelDeletedEvent | IdentityDeletedEvent | CommandEvent | AgentSessionEvent | SubscriptionEvent | PresenceEvent | OfflineAlertEvent;
|
|
1089
|
+
/**
|
|
1090
|
+
* `GET /v1/events`: the caller's Server-Sent Events stream, one per connection. With `allChannelsQuery` as its query
|
|
1091
|
+
* it is also the all-channels feed: every new message on every channel.
|
|
1092
|
+
*/
|
|
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";
|
|
1096
|
+
/** The query that asks the stream for the all-channels feed: `?channels=all`. */
|
|
1097
|
+
declare const allChannelsQuery: {
|
|
1098
|
+
readonly channels: "all";
|
|
1099
|
+
};
|
|
1100
|
+
/**
|
|
1101
|
+
* The SSE `event` of the stream's last event when it can't go on, such as `agent_session_revoked` once `leave` or
|
|
1102
|
+
* another session's `join --force` revokes the agent session token it was opened with: it has no `id`, and its
|
|
1103
|
+
* `data` is the refusal's `ErrorResponse` as JSON.
|
|
1104
|
+
*/
|
|
1105
|
+
declare const refusalEvent = "refusal";
|
|
493
1106
|
interface EventStream extends AsyncIterable<CookoutEvent> {
|
|
494
1107
|
readonly close: () => Promise<void>;
|
|
1108
|
+
readonly closeCleanly: () => Promise<void>;
|
|
495
1109
|
}
|
|
496
1110
|
interface WatchOptions {
|
|
497
1111
|
readonly allChannels?: boolean;
|
|
@@ -500,13 +1114,50 @@ interface WatchOptions {
|
|
|
500
1114
|
readonly onConnected?: (latestMessageId: MessageId | null) => void;
|
|
501
1115
|
}
|
|
502
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
|
+
}
|
|
503
1154
|
/** The answer to the health check. */
|
|
504
1155
|
interface HealthResponse {
|
|
505
1156
|
readonly status: "ok";
|
|
506
1157
|
readonly time: IsoTime;
|
|
507
1158
|
}
|
|
508
1159
|
/** Every code a cookout server refuses with. */
|
|
509
|
-
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", "
|
|
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"];
|
|
510
1161
|
/** A code a cookout server refuses with. */
|
|
511
1162
|
type ErrorCode = (typeof errorCodes)[number];
|
|
512
1163
|
/** One way a request broke a schema: what is wrong, and where (`path` from the body's top, such as `["data", "branch"]`). */
|
|
@@ -565,6 +1216,13 @@ interface LoginCalls {
|
|
|
565
1216
|
/** `DELETE /v1/login`: revokes the Login credential this client sends, answering whether it was one. */
|
|
566
1217
|
readonly revokeLogin: () => Promise<LogoutResponse>;
|
|
567
1218
|
}
|
|
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">;
|
|
568
1226
|
declare const brand: unique symbol;
|
|
569
1227
|
type UnknownErrorCode = string & {
|
|
570
1228
|
readonly [brand]: "UnknownErrorCode";
|
|
@@ -594,16 +1252,16 @@ export type CookoutClientOptions = {
|
|
|
594
1252
|
readonly url?: string;
|
|
595
1253
|
/**
|
|
596
1254
|
* The bearer token: an Identity token, or the agent session token `join` answered, to act as the agent for that
|
|
597
|
-
* session. Default: `COOKOUT_TOKEN`, else `COOKOUT_SESSION`; inside
|
|
1255
|
+
* session. Default: `COOKOUT_TOKEN`, else `COOKOUT_SESSION`; inside a harness, `COOKOUT_SESSION` first. Not
|
|
598
1256
|
* needed for the health check.
|
|
599
1257
|
*/
|
|
600
1258
|
readonly token?: string;
|
|
601
1259
|
/** Where `COOKOUT_URL`, `COOKOUT_TOKEN` and `COOKOUT_SESSION` are read from. Default: the process's environment (none in a browser). */
|
|
602
1260
|
readonly env?: Readonly<Record<string, string | undefined>>;
|
|
603
|
-
/** The
|
|
604
|
-
readonly
|
|
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`. */
|
|
1262
|
+
readonly harness?: string;
|
|
605
1263
|
};
|
|
606
|
-
export type CookoutClient =
|
|
1264
|
+
export type CookoutClient = CallGroups & Pick<ReturnType<typeof inboxCalls>, "keepDeactivationOffer" | "markDeactivatedQuietAgentRead" | "markNudgeRead" | "markOfflineAlertRead"> & {
|
|
607
1265
|
/** `GET /v1/health`. Resolves when the server and its storage are usable. */
|
|
608
1266
|
readonly health: () => Promise<HealthResponse>;
|
|
609
1267
|
/** `GET /v1/whoami`: the identity behind this client's token. */
|
|
@@ -624,14 +1282,14 @@ export type CookoutClient = LoginCalls & {
|
|
|
624
1282
|
readonly rotateToken: (name: string) => Promise<IdentityWithTokenResponse>;
|
|
625
1283
|
/**
|
|
626
1284
|
* `POST /v1/identities/:name/deactivate`: an admin deactivates anyone, a human their own agents (403 `not_owner`
|
|
627
|
-
* otherwise). Every token it holds fails at once
|
|
1285
|
+
* otherwise). Every token it holds fails at once; a human's agents stay active (`agents` is always empty). Its
|
|
628
1286
|
* messages and name stay; the name can't be created again. The last admin is 409 `last_admin`.
|
|
629
1287
|
*/
|
|
630
1288
|
readonly deactivateIdentity: (name: string) => Promise<DeactivateIdentityResponse>;
|
|
631
1289
|
/**
|
|
632
|
-
* `POST /v1/identities/:name/reactivate`: an admin reactivates anyone, a human their own agents
|
|
633
|
-
* token, shown this once; old tokens stay dead. 409 `not_deactivated`
|
|
634
|
-
*
|
|
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.
|
|
635
1293
|
*/
|
|
636
1294
|
readonly reactivateIdentity: (name: string) => Promise<IdentityWithTokenResponse>;
|
|
637
1295
|
/** Admin only. Makes a human an admin and answers it; an admin stays one. An agent is 403 `human_only`. */
|
|
@@ -642,7 +1300,7 @@ export type CookoutClient = LoginCalls & {
|
|
|
642
1300
|
readonly setDisplayName: (name: string, displayName: string | null) => Promise<IdentityResponse>;
|
|
643
1301
|
/** Admin only: gives an agent to another human. A human is 403 `identity_kind`; `ada/x` is 400 `name_not_owned`. */
|
|
644
1302
|
readonly transferAgent: (agent: string, owner: string) => Promise<IdentityResponse>;
|
|
645
|
-
/** `POST /v1/channels`: any identity can create a channel. A name in use is 409 `channel_exists`. */
|
|
1303
|
+
/** `POST /v1/channels`: any identity can create a channel, which subscribes it. A name in use is 409 `channel_exists`. */
|
|
646
1304
|
readonly createChannel: (request: CreateChannelRequest) => Promise<ChannelResponse>;
|
|
647
1305
|
/** `GET /v1/channels`: every channel, sorted by name. */
|
|
648
1306
|
readonly listChannels: () => Promise<ListChannelsResponse>;
|
|
@@ -667,6 +1325,17 @@ export type CookoutClient = LoginCalls & {
|
|
|
667
1325
|
readonly listMessages: (channel: string, query?: ListMessagesQuery) => Promise<ListMessagesResponse>;
|
|
668
1326
|
/** `GET /v1/messages/:id/thread`: the thread holding the message, its top-level message and every reply in order. */
|
|
669
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>;
|
|
670
1339
|
/**
|
|
671
1340
|
* `POST /v1/agent-session`, with an agent's Identity token (`as` must be its name; a human's is 403
|
|
672
1341
|
* `identity_kind`): issues an agent session token, which expires once unused for `idleExpiry` (default `7d`, at
|
|
@@ -687,30 +1356,36 @@ export type CookoutClient = LoginCalls & {
|
|
|
687
1356
|
readonly revokeAgentSession: AgentSessionCalls["revokeAgentSession"];
|
|
688
1357
|
/**
|
|
689
1358
|
* `GET /v1/inbox`: what the caller hasn't read, oldest first, each message once with every reason it is there
|
|
690
|
-
* (`followed-thread`, `mention`, `subscribed-channel`), its channel and its thread's top-level message. The
|
|
691
|
-
* 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.
|
|
692
1360
|
*/
|
|
693
1361
|
readonly inbox: () => Promise<InboxResponse>;
|
|
694
1362
|
/**
|
|
695
1363
|
* `GET /v1/inbox/history`: a page of the caller's inbox history, newest first: every message in its inbox for at
|
|
696
1364
|
* least one reason as things stand now (current follows and subscriptions), read or not, each once with every
|
|
697
1365
|
* reason and `read`. The newest `limit` (default 50, 1–200), or those before `before`; page back by passing the
|
|
698
|
-
* 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.
|
|
699
1367
|
*/
|
|
700
1368
|
readonly inboxHistory: (query?: InboxHistoryQuery) => Promise<InboxHistoryResponse>;
|
|
701
1369
|
/** `GET /v1/read-positions`: the caller's read positions, by channel name, each channel's own before its threads'. */
|
|
702
1370
|
readonly readPositions: () => Promise<ReadPositionsResponse>;
|
|
703
1371
|
/**
|
|
704
1372
|
* `POST /v1/ack`: marks the message and everything before it in its thread (for a reply) or channel (for a
|
|
705
|
-
* top-level message) as read.
|
|
1373
|
+
* top-level message) as read. An ack never moves a read position backwards. A missing message is 404
|
|
1374
|
+
* `message_not_found`.
|
|
706
1375
|
*/
|
|
707
1376
|
readonly ack: (messageId: MessageId) => Promise<AckResponse>;
|
|
708
1377
|
/**
|
|
709
|
-
* `POST /v1/
|
|
710
|
-
*
|
|
711
|
-
*
|
|
1378
|
+
* `POST /v1/read-positions/unread`: marks the message unread, with everything after it in its thread or channel, by
|
|
1379
|
+
* moving the read position there back to just before it, and answers where it is now (`messageId` `null` where
|
|
1380
|
+
* nothing there is read). It never marks anything read; a later ack moves the position forward again. A missing
|
|
1381
|
+
* message is 404 `message_not_found`.
|
|
1382
|
+
*/
|
|
1383
|
+
readonly markUnread: (messageId: MessageId) => Promise<MarkUnreadResponse>;
|
|
1384
|
+
/**
|
|
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.
|
|
712
1387
|
*/
|
|
713
|
-
readonly ackAll: (upTo: MessageId) => Promise<AckAllResponse>;
|
|
1388
|
+
readonly ackAll: (upTo: MessageId | AckAllRequest) => Promise<AckAllResponse>;
|
|
714
1389
|
/**
|
|
715
1390
|
* `PUT /v1/messages/:id/follow`: follows the thread holding the message, so its replies reach the inbox. Starting
|
|
716
1391
|
* a thread, replying in it and being mentioned in it follow it too.
|
|
@@ -725,13 +1400,15 @@ export type CookoutClient = LoginCalls & {
|
|
|
725
1400
|
/**
|
|
726
1401
|
* `GET /v1/events`: opens one Server-Sent Events stream, resolving once the server has accepted it. Iterate it for
|
|
727
1402
|
* each new inbox item (`inbox-item`) the moment another identity posts it (the caller's own posts never arrive), and
|
|
728
|
-
* each new read position (`read-position`) the moment any session of the caller acks,
|
|
729
|
-
* sync. With `allChannels`, it also sends every new message on every channel (`message`), as the web UI needs.
|
|
1403
|
+
* each new read position (`read-position`) the moment any session of the caller acks, and each read position moved
|
|
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.
|
|
730
1405
|
* Each event is checked against the protocol (`bad_response` otherwise); an event type this SDK doesn't know, from
|
|
731
|
-
* a newer server, is skipped. `close` drops the connection
|
|
732
|
-
* expiry on while open, and once the token is revoked (`leave`, or another session's `join --force`) the
|
|
733
|
-
* iteration throws `agent_session_revoked` (status 200, the stream's).
|
|
734
|
-
*
|
|
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.
|
|
735
1412
|
* The server sends a heartbeat every 15 s, which `onHeartbeat` hears while the stream is being iterated. The
|
|
736
1413
|
* stream starts by telling `onConnected` the board's latest message ID (null before the first message): every
|
|
737
1414
|
* item sent live is newer, so resuming from it after a drop misses nothing.
|
|
@@ -768,4 +1445,4 @@ export type CookoutClient = LoginCalls & {
|
|
|
768
1445
|
export declare const parseEvent: typeof eventOf;
|
|
769
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. */
|
|
770
1447
|
export declare function createCookoutClient(options?: CookoutClientOptions): CookoutClient;
|
|
771
|
-
export { type AckAllRequest, type AckAllResponse, type AckRequest, type AckResponse, type AddCommandRequest, type AgentIdentity, type AgentSessionLiveDetails, type AgentSessionResponse, type
|
|
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 };
|