@relaymessenger/sdk 0.3.6-staging.3 → 0.3.6-staging.31

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.
Files changed (76) hide show
  1. package/README.md +490 -20
  2. package/dist/a2ui.d.ts +79 -0
  3. package/dist/a2ui.d.ts.map +1 -0
  4. package/dist/a2ui.js +99 -0
  5. package/dist/a2ui.js.map +1 -0
  6. package/dist/buttons.d.ts +69 -0
  7. package/dist/buttons.d.ts.map +1 -0
  8. package/dist/buttons.js +141 -0
  9. package/dist/buttons.js.map +1 -0
  10. package/dist/calls/call-room.d.ts +110 -0
  11. package/dist/calls/call-room.d.ts.map +1 -0
  12. package/dist/calls/call-room.js +616 -0
  13. package/dist/calls/call-room.js.map +1 -0
  14. package/dist/calls/engine-werift-video.d.ts +70 -0
  15. package/dist/calls/engine-werift-video.d.ts.map +1 -0
  16. package/dist/calls/engine-werift-video.js +594 -0
  17. package/dist/calls/engine-werift-video.js.map +1 -0
  18. package/dist/calls/engine-werift.d.ts +48 -0
  19. package/dist/calls/engine-werift.d.ts.map +1 -0
  20. package/dist/calls/engine-werift.js +457 -0
  21. package/dist/calls/engine-werift.js.map +1 -0
  22. package/dist/calls/index.d.ts +11 -0
  23. package/dist/calls/index.d.ts.map +1 -0
  24. package/dist/calls/index.js +11 -0
  25. package/dist/calls/index.js.map +1 -0
  26. package/dist/calls/transport.d.ts +466 -0
  27. package/dist/calls/transport.d.ts.map +1 -0
  28. package/dist/calls/transport.js +1409 -0
  29. package/dist/calls/transport.js.map +1 -0
  30. package/dist/calls/video-frame.d.ts +56 -0
  31. package/dist/calls/video-frame.d.ts.map +1 -0
  32. package/dist/calls/video-frame.js +245 -0
  33. package/dist/calls/video-frame.js.map +1 -0
  34. package/dist/calls/video-rtp.d.ts +51 -0
  35. package/dist/calls/video-rtp.d.ts.map +1 -0
  36. package/dist/calls/video-rtp.js +294 -0
  37. package/dist/calls/video-rtp.js.map +1 -0
  38. package/dist/calls/video.d.ts +188 -0
  39. package/dist/calls/video.d.ts.map +1 -0
  40. package/dist/calls/video.js +228 -0
  41. package/dist/calls/video.js.map +1 -0
  42. package/dist/client.d.ts +134 -24
  43. package/dist/client.d.ts.map +1 -1
  44. package/dist/client.js +321 -33
  45. package/dist/client.js.map +1 -1
  46. package/dist/errors.d.ts +11 -0
  47. package/dist/errors.d.ts.map +1 -1
  48. package/dist/errors.js +16 -0
  49. package/dist/errors.js.map +1 -1
  50. package/dist/index.d.ts +8 -2
  51. package/dist/index.d.ts.map +1 -1
  52. package/dist/index.js +8 -2
  53. package/dist/index.js.map +1 -1
  54. package/dist/links.d.ts +57 -0
  55. package/dist/links.d.ts.map +1 -0
  56. package/dist/links.js +126 -0
  57. package/dist/links.js.map +1 -0
  58. package/dist/operations.d.ts +69 -25
  59. package/dist/operations.d.ts.map +1 -1
  60. package/dist/operations.js +94 -30
  61. package/dist/operations.js.map +1 -1
  62. package/dist/payment.d.ts +67 -0
  63. package/dist/payment.d.ts.map +1 -0
  64. package/dist/payment.js +147 -0
  65. package/dist/payment.js.map +1 -0
  66. package/dist/selection.d.ts +38 -0
  67. package/dist/selection.d.ts.map +1 -0
  68. package/dist/selection.js +132 -0
  69. package/dist/selection.js.map +1 -0
  70. package/dist/types.d.ts +960 -56
  71. package/dist/types.d.ts.map +1 -1
  72. package/dist/websocket.d.ts +8 -2
  73. package/dist/websocket.d.ts.map +1 -1
  74. package/dist/websocket.js +29 -10
  75. package/dist/websocket.js.map +1 -1
  76. package/package.json +38 -3
package/dist/types.d.ts CHANGED
@@ -11,24 +11,22 @@ export interface CallContact {
11
11
  handle: string;
12
12
  kind: "user" | "agent";
13
13
  }
14
+ export type CallTerminalStatus = "completed" | "no-answer" | "canceled" | "busy" | "failed";
14
15
  export interface Call {
15
16
  id: UUID;
16
17
  chat_id: UUID;
17
18
  from: CallContact;
18
19
  to: [CallContact];
19
- mode: "audio";
20
- status: "ringing" | "connecting" | "active" | "ended";
20
+ /** `ringing` and `in-progress` are live. Terminal states set `ended_at`. */
21
+ status: "ringing" | "in-progress" | CallTerminalStatus;
21
22
  revision: number;
22
23
  created_at: string;
23
24
  ringing_at: string;
24
25
  answered_at: string | null;
25
- connected_at: string | null;
26
26
  ended_at: string | null;
27
- end_reason: "completed" | "declined" | "canceled" | "no_answer" | "disconnected" | "failed" | null;
28
27
  }
29
28
  export interface CallCreateParams {
30
29
  to: [string];
31
- mode: "audio";
32
30
  }
33
31
  export interface CallCreateOptions extends RequestOptions {
34
32
  /** Reuse this key and request after an uncertain response. */
@@ -45,49 +43,291 @@ export interface CallListResponse {
45
43
  export interface CallResponse {
46
44
  call: Call;
47
45
  }
48
- export interface CallAudioFormat {
49
- encoding: "pcm_s16le";
50
- sample_rate: 48000;
51
- channels: 2;
46
+ /** A participant's published local track, named on the SFU. */
47
+ export type CallRoomTrackName = "audio" | "video";
48
+ export interface CallRoomParticipant {
49
+ contact_id: UUID;
50
+ kind: "user" | "agent";
51
+ attached: boolean;
52
+ track: "audio" | null;
53
+ muted: boolean;
54
+ connected: boolean;
55
+ /** Camera sending, from this participant's `userUpdate`. */
56
+ video?: boolean;
57
+ /** Tracks this participant has published: `[]` before its first offer, then `["audio"]` or `["audio", "video"]`. */
58
+ tracks?: CallRoomTrackName[];
59
+ /**
60
+ * The other participant's tracks this participant is receiving now: its
61
+ * pull answer is applied and it sent `connected` for it. Reset on restart.
62
+ */
63
+ receiving?: CallRoomTrackName[];
52
64
  }
53
- export type CallConnectionCreateParams = {
54
- transport: "websocket";
55
- } | {
56
- transport: "webrtc";
65
+ export interface CallRoomJoinFrame {
66
+ type: "join";
67
+ }
68
+ export interface CallRoomPublishOfferFrame {
69
+ type: "offer";
57
70
  session_description: {
58
71
  type: "offer";
59
72
  sdp: string;
60
73
  };
74
+ /** One or two tracks, `audio` first, no duplicate names. */
61
75
  tracks: [{
62
76
  mid: string;
63
- name: "microphone";
77
+ name: "audio";
78
+ }] | [{
79
+ mid: string;
80
+ name: "audio";
81
+ }, {
82
+ mid: string;
83
+ name: "video";
84
+ }] | [{
85
+ mid: string;
86
+ name: "video";
64
87
  }];
65
- };
66
- export interface CallWebSocketConnection {
67
- id: UUID;
68
- call_id: UUID;
69
- transport: "websocket";
70
- url: string;
71
- /** Ephemeral Relay grant, supplied as the media WebSocket bearer token. */
72
- token: string;
73
- expires_at: string;
74
- audio_format: CallAudioFormat;
88
+ /** The previous session is dead: publish on a brand-new session from a new peer connection. */
89
+ restart?: boolean;
75
90
  }
76
- export interface CallWebRTCConnection {
77
- id: UUID;
78
- call_id: UUID;
79
- transport: "webrtc";
91
+ export interface CallRoomAnswerFrame {
92
+ type: "answer";
80
93
  session_description: {
81
94
  type: "answer";
82
95
  sdp: string;
83
96
  };
84
97
  }
85
- export interface CallConnectionResponse {
86
- connection: CallWebSocketConnection | CallWebRTCConnection;
98
+ export interface CallRoomConnectedFrame {
99
+ type: "connected";
100
+ }
101
+ export interface CallRoomUserUpdateFrame {
102
+ type: "userUpdate";
103
+ muted: boolean;
104
+ /** Camera sending. Omitted keeps the last value. */
105
+ video?: boolean;
106
+ }
107
+ export interface CallRoomEndFrame {
108
+ type: "end";
109
+ }
110
+ export interface CallRoomHeartbeatFrame {
111
+ type: "heartbeat";
112
+ }
113
+ export type CallRoomClientFrame = CallRoomJoinFrame | CallRoomPublishOfferFrame | CallRoomAnswerFrame | CallRoomConnectedFrame | CallRoomUserUpdateFrame | CallRoomEndFrame | CallRoomHeartbeatFrame;
114
+ export interface CallRoomStateFrame {
115
+ type: "roomState";
116
+ call: Call;
117
+ participants: [CallRoomParticipant, CallRoomParticipant];
118
+ }
119
+ export interface CallRoomServerAnswerFrame {
120
+ type: "answer";
121
+ session_description: {
122
+ type: "answer";
123
+ sdp: string;
124
+ };
125
+ }
126
+ export interface CallRoomSubscriptionOfferFrame {
127
+ type: "offer";
128
+ session_description: {
129
+ type: "offer";
130
+ sdp: string;
131
+ };
132
+ /** The other participant's track this renegotiation pulls. */
133
+ track: CallRoomTrackName;
134
+ }
135
+ export interface CallRoomEndedFrame {
136
+ type: "ended";
137
+ reason: CallTerminalStatus;
87
138
  }
139
+ export type CallRoomErrorCode = "invalid_frame" | "not_allowed" | "media_unavailable";
140
+ export interface CallRoomErrorFrame {
141
+ type: "error";
142
+ code: CallRoomErrorCode;
143
+ message: string;
144
+ }
145
+ /** Standard `RTCIceServer`: STUN or TURN URLs, with credentials on TURN servers. */
146
+ export interface CallRoomIceServer {
147
+ urls: string[];
148
+ username?: string;
149
+ credential?: string;
150
+ }
151
+ /**
152
+ * STUN and TURN servers for this participant's peer connection, sent after
153
+ * every accepted `join` and before the first `roomState` (Orange Meets shape:
154
+ * Cloudflare TURN credentials minted by the server).
155
+ */
156
+ export interface CallRoomIceServersFrame {
157
+ type: "iceServers";
158
+ ice_servers: CallRoomIceServer[];
159
+ }
160
+ export type CallRoomServerFrame = CallRoomIceServersFrame | CallRoomStateFrame | CallRoomServerAnswerFrame | CallRoomSubscriptionOfferFrame | CallRoomEndedFrame | CallRoomErrorFrame;
88
161
  export type CallWebhookEvent = RelayWebhookEnvelope<CallResponse, "call.created" | "call.updated" | "call.ended">;
162
+ /** Subscription mode only. One coupon or one promotion code from your connected Stripe account, never both. */
163
+ export interface PaymentDiscount {
164
+ /** The id of a coupon on your connected Stripe account. */
165
+ coupon?: string;
166
+ /** The id of a promotion code (`promo_...`), not the code a customer types. */
167
+ promotion_code?: string;
168
+ /** Your own name for the discount, stored and returned with the request. */
169
+ label?: string;
170
+ }
171
+ /**
172
+ * `POST /v1/payment_requests`. Payment mode needs `amount` and `currency`;
173
+ * subscription mode needs `price_id` and takes the currency from the price.
174
+ */
175
+ export interface PaymentRequestCreateParams {
176
+ /** Payment mode: what to charge, in the currency's minor units. */
177
+ amount?: number;
178
+ /** Payment mode: a 3-letter ISO 4217 code, returned lowercase. */
179
+ currency?: string;
180
+ /** The card's title line and the checkout's product name. Trimmed; 1 to 32 characters. */
181
+ description: string;
182
+ category: PaymentCategory;
183
+ /** Up to 49 keys of your own; keys starting with `relay_` are reserved. */
184
+ metadata?: Record<string, string>;
185
+ /** Defaults to `payment`. */
186
+ mode?: PaymentMode;
187
+ /** Subscription mode: an active recurring Price on your connected Stripe account. */
188
+ price_id?: string;
189
+ /** Subscription mode: units of the price. Defaults to 1. */
190
+ quantity?: number;
191
+ /** An existing Customer on your connected Stripe account (`cus_...`). */
192
+ customer_id?: string;
193
+ discount?: PaymentDiscount;
194
+ /** Optional HTTPS product picture; Relay copies it into its own image store. */
195
+ image_url?: string;
196
+ }
197
+ export interface PaymentRequestCreateOptions extends RequestOptions {
198
+ /** Reusing a key with the same body returns the first request (200); with a different body, 409. */
199
+ idempotencyKey?: string;
200
+ }
201
+ /** The ids of the Stripe objects on your connected account. */
202
+ export interface PaymentRequestStripe {
203
+ /** The one PaymentIntent the person pays (`pi_...`). */
204
+ payment_intent_id: string;
205
+ customer_id?: string;
206
+ /** Subscription mode (`sub_...`). */
207
+ subscription_id?: string;
208
+ }
209
+ export interface PaymentRequest {
210
+ id: UUID;
211
+ object: "payment_request";
212
+ status: PaymentStatus;
213
+ mode: PaymentMode;
214
+ /** What the person is charged at checkout, in minor units. */
215
+ amount: number;
216
+ /** Relay's 5% fee in minor units. */
217
+ application_fee_amount: number;
218
+ currency: string;
219
+ description: string;
220
+ category: PaymentCategory;
221
+ /** Relay's pay page for this request. Send it back unchanged in a `payment` part. */
222
+ checkout_url: string;
223
+ /** 23 hours after creation; the request then moves to `expired`. */
224
+ expires_at: string;
225
+ metadata: Record<string, string>;
226
+ image_url?: string;
227
+ price_id?: string;
228
+ quantity?: number;
229
+ interval?: PaymentRecurring["interval"];
230
+ interval_count?: number;
231
+ discount?: PaymentDiscount;
232
+ stripe: PaymentRequestStripe;
233
+ /** Absent until the request succeeds. */
234
+ paid_at?: string;
235
+ created_at: string;
236
+ updated_at: string;
237
+ }
238
+ export interface PaymentRequestListParams {
239
+ cursor?: string;
240
+ /** 1 to 100; defaults to 20. */
241
+ limit?: number;
242
+ status?: PaymentStatus;
243
+ }
244
+ export interface PaymentRequestListResponse {
245
+ payment_requests: PaymentRequest[];
246
+ next_cursor: string | null;
247
+ }
248
+ /** `POST /v1/chats/{chatId}/location/request` answers with this once the request is in the chat. */
249
+ export interface LocationRequestResponse {
250
+ success: true;
251
+ message: "Location request sent";
252
+ }
253
+ /** One person sharing their location with your agent, as a GeoJSON Feature (RFC 7946). */
254
+ export interface LocationFeature {
255
+ type: "Feature";
256
+ geometry: {
257
+ type: "Point";
258
+ /** `[longitude, latitude]`, longitude first. */
259
+ coordinates: [number, number];
260
+ };
261
+ properties: {
262
+ /** Handle of the person sharing. */
263
+ handle: string;
264
+ /** When this position arrived. */
265
+ updated_at: string;
266
+ };
267
+ }
268
+ /**
269
+ * `GET /v1/chats/{chatId}/location`: one Feature per person sharing with your
270
+ * agent in the chat; `features` is empty when nobody is sharing.
271
+ */
272
+ export interface GetChatLocationResponse {
273
+ success: true;
274
+ data: {
275
+ type: "FeatureCollection";
276
+ features: LocationFeature[];
277
+ };
278
+ }
279
+ /** `location.sharing.started`: a person started sharing their location with your agent. */
280
+ export interface LocationSharingStartedEvent {
281
+ /** Handle of the person who started sharing. */
282
+ shared_by: string;
283
+ /** Handle of your agent. */
284
+ shared_with: string;
285
+ chat_id: UUID;
286
+ began_at: string;
287
+ /** When the share ends by itself; null when it has no end. */
288
+ ends_at: string | null;
289
+ }
290
+ /** `location.sharing.stopped`: the person stopped sharing, or the share reached its end. */
291
+ export interface LocationSharingStoppedEvent {
292
+ /** Handle of the person who stopped sharing. */
293
+ shared_by: string;
294
+ /** Handle of your agent. */
295
+ shared_with: string;
296
+ chat_id: UUID;
297
+ began_at: string;
298
+ /** When the share ended. Equals the share's `ends_at` when it ran out. */
299
+ ended_at: string;
300
+ }
301
+ export type LocationSharingStartedWebhookEvent = RelayWebhookEnvelope<LocationSharingStartedEvent, "location.sharing.started">;
302
+ export type LocationSharingStoppedWebhookEvent = RelayWebhookEnvelope<LocationSharingStoppedEvent, "location.sharing.stopped">;
303
+ export type PaymentWebhookEvent = RelayWebhookEnvelope<PaymentRequest, "payment.succeeded" | "payment.canceled" | "payment.expired">;
89
304
  export type DeliveryStatus = "sent" | "delivered" | "read";
90
305
  export type ReactionType = "love" | "like" | "dislike" | "laugh" | "emphasize" | "question" | "custom";
306
+ export interface ChatActivity {
307
+ id: UUID;
308
+ text: string;
309
+ emoji: string | null;
310
+ updated_at: string;
311
+ expires_at: string;
312
+ }
313
+ export interface ChatActivityResponse {
314
+ chat_id: UUID;
315
+ agent_id: UUID;
316
+ version: string;
317
+ activity: ChatActivity | null;
318
+ }
319
+ export interface ChatSetActivityParams {
320
+ /** 1–21 visible characters, at most 1024 UTF-8 bytes. */
321
+ text: string;
322
+ /** One Unicode emoji, or null. */
323
+ emoji?: string | null;
324
+ /** Omit to start/replace; supply the current ID to refresh/update. */
325
+ activity_id?: UUID;
326
+ }
327
+ export interface ChatClearActivityParams {
328
+ /** Clear only this task. A stale or missing activity is a successful no-op. */
329
+ activity_id?: UUID;
330
+ }
91
331
  interface ChatHandleBase {
92
332
  id: UUID;
93
333
  handle: string;
@@ -97,16 +337,34 @@ interface ChatHandleBase {
97
337
  is_me?: boolean | null;
98
338
  display_name: string | null;
99
339
  image_url: string | null;
100
- about: string | null;
340
+ subtitle: string | null;
101
341
  verified: boolean;
102
342
  /** True when the caller holds this Handle as a Contact. */
103
343
  is_contact: boolean;
344
+ activity_version?: string;
345
+ activity?: ChatActivity | null;
104
346
  }
105
347
  export interface UserChatHandle extends ChatHandleBase {
106
348
  kind: "user";
107
349
  }
350
+ /** Who owns an agent: its organization, or the person who owns it. */
351
+ export type HandleOwner = {
352
+ kind: "organization";
353
+ /** The organization's name in Relay Console. Null until it has one. */
354
+ name: string | null;
355
+ /** Whether Relay has verified the organization. */
356
+ verified: boolean;
357
+ } | {
358
+ kind: "user";
359
+ /** The owning person's Relay Handle. Null when the person has no Relay account. */
360
+ handle: string | null;
361
+ /** The owning person's display name. Null when the person has no Relay account. */
362
+ display_name: string | null;
363
+ };
108
364
  export interface AgentChatHandle extends ChatHandleBase {
109
365
  kind: "agent";
366
+ /** Who owns this agent. Null for an agent no organization or person owns. */
367
+ owner?: HandleOwner | null;
110
368
  }
111
369
  export type ChatHandle = UserChatHandle | AgentChatHandle;
112
370
  export interface Reaction {
@@ -130,32 +388,346 @@ export interface LinkPart {
130
388
  type: "link";
131
389
  value: string;
132
390
  }
133
- /** One button in a `buttons`. Exactly one of `id` or `url`. */
391
+ /**
392
+ * One button in a `buttons`. A tap on a plain button sends its `label` back
393
+ * as the person's next message: one `text` part whose value is the label,
394
+ * with `reply_to` naming the `buttons` part. A `url` button opens the page
395
+ * in the app and sends nothing.
396
+ */
134
397
  export interface ButtonItem {
135
- /** Callback button: the tap arrives as a `button_reply` carrying this id. */
136
- id?: string;
137
- /** Link button: the tap opens this HTTPS URL and sends nothing. */
398
+ /** Link button: the tap opens this HTTPS URL instead of sending the label. */
138
399
  url?: string;
400
+ /** The button's visible text, 1 to 80 characters, and what a tap sends. */
139
401
  label: string;
140
402
  }
141
403
  /**
142
404
  * Agent-only: a vertical stack of 1 to 5 text-only buttons under the message.
143
- * Only button_reply may target this part; ordinary replies and reactions may not.
405
+ * At most one per message. The only reply it accepts is a tap; reactions may
406
+ * not target it.
144
407
  */
145
408
  export interface ButtonsPart {
146
409
  type: "buttons";
147
410
  items: ButtonItem[];
148
411
  }
412
+ /** Stable machine value and independently editable visible label. */
413
+ export interface SelectionOption {
414
+ /** Unique case-sensitive ASCII token, 1–100 characters. Never derived from label. */
415
+ value: string;
416
+ /** Trimmed visible label, 1–80 characters. */
417
+ label: string;
418
+ }
419
+ /** Agent-only, 1–25 options; requires nonblank text and cannot mix with buttons. */
420
+ export interface SelectionPart {
421
+ type: "selection";
422
+ /** The text is the prompt's title; the person checks any number of options and submits them once, and checking sends nothing. */
423
+ options: SelectionOption[];
424
+ }
425
+ export interface SelectionPartResponse extends SelectionPart {
426
+ /** Durable response state for this viewer across devices. Existing Chat rules allow at most one human user; only that user can respond, once; reopening an answered selection shows what they chose without letting them change it. */
427
+ readonly has_responded: boolean;
428
+ /** The values the authenticated viewer chose, in source-option order, identical on every one of that user's devices; null until the viewer answers, when the answer Message no longer exists, and always for an agent viewer. */
429
+ readonly selected_values: string[] | null;
430
+ reactions: null;
431
+ }
432
+ /**
433
+ * User-only metadata after canonical text (literal '• ' + each source
434
+ * label, joined with '\n'), with explicit reply_to. Exact legacy comma-joined
435
+ * labels are accepted by the server only for compatibility, never parsed for IDs.
436
+ */
437
+ export interface SelectionResponsePart {
438
+ type: "selection_response";
439
+ /**
440
+ * Unique known values, nonempty and in source-option order, authoritative with
441
+ * reply_to. New preceding text is literal '• ' + each source label joined with
442
+ * '\n'. The server accepts exact legacy comma-joined labels for compatibility
443
+ * only, never arbitrary label parsing. iOS may draw a checkmark in place of
444
+ * each bullet and repeat the prompt's title, as presentation only; portable
445
+ * text remains bullets.
446
+ */
447
+ selected_values: string[];
448
+ }
449
+ /** Metadata only: contributes no visible fallback text. */
450
+ export interface SelectionResponsePartResponse extends SelectionResponsePart {
451
+ }
452
+ /** What is being paid for (PayPal Orders v2 `items[].category`); App Store rules decide where each is payable. */
453
+ export type PaymentCategory = "physical_goods" | "digital_goods" | "donation";
454
+ /** A payment request's lifecycle. It leaves `requested` exactly once, only on Stripe's word or your cancel. */
455
+ export type PaymentStatus = "requested" | "succeeded" | "canceled" | "expired";
456
+ /** `payment` collects one charge; `subscription` starts a Stripe subscription from a recurring price. */
457
+ export type PaymentMode = "payment" | "subscription";
458
+ /** A subscription's renewal cadence, read from its Stripe Price. */
459
+ export interface PaymentRecurring {
460
+ interval: "day" | "week" | "month" | "year";
461
+ /** Intervals per renewal (3 with `month` is quarterly). */
462
+ interval_count: number;
463
+ }
464
+ /**
465
+ * A request to pay, drawn as a card. `checkout_url` is the only field: pass
466
+ * back exactly what `paymentRequests.create` returned. The card's amount and
467
+ * title are read from that request, never from the message. Sent only by the
468
+ * agent that created the request, while it is `requested`; it must be the only
469
+ * part of its message.
470
+ */
471
+ export interface PaymentPart {
472
+ type: "payment";
473
+ /** At most 2048 characters. */
474
+ checkout_url: string;
475
+ }
476
+ /** A payment card as every reader sees it, read from the payment request. `status` changes in place. */
477
+ export interface PaymentPartResponse {
478
+ type: "payment";
479
+ payment_request_id: UUID;
480
+ checkout_url: string;
481
+ /** Minor units. For a subscription, what the first period costs. */
482
+ amount: number;
483
+ currency: string;
484
+ /** The card's title line. */
485
+ description: string;
486
+ category: PaymentCategory;
487
+ mode: PaymentMode;
488
+ recurring?: PaymentRecurring;
489
+ /** The request's product picture, when it has one. */
490
+ image_url?: string;
491
+ status: PaymentStatus;
492
+ /** Only a person can react to a payment. */
493
+ reactions: Reaction[] | null;
494
+ }
495
+ /**
496
+ * The payer's receipt: Relay adds one message from the person who paid, a
497
+ * reply to the `payment` card, when a request succeeds. It arrives as
498
+ * `message.received`. Only Relay writes this part.
499
+ */
500
+ export interface PaymentReceiptPartResponse {
501
+ type: "payment_receipt";
502
+ payment_request_id: UUID;
503
+ description: string;
504
+ /** What was paid, in minor units. For a subscription, what the first period cost. */
505
+ amount: number;
506
+ currency: string;
507
+ mode: PaymentMode;
508
+ recurring?: PaymentRecurring;
509
+ reactions: Reaction[] | null;
510
+ }
511
+ /**
512
+ * An agent's request for the person's location, sent with
513
+ * `chats.location.request`. It cannot be sent as a message part. A client that
514
+ * does not draw it shows the Message's text, "<agent display name> requested
515
+ * your location".
516
+ */
517
+ export interface LocationRequestPartResponse {
518
+ type: "location_request";
519
+ reactions: Reaction[] | null;
520
+ }
521
+ /**
522
+ * A person's location share, the card the person's app draws. It carries the
523
+ * share's state, never its position: read the position with
524
+ * `chats.location.retrieve`. It cannot be sent as a message part. A share whose
525
+ * `ends_at` has passed reads as `ended` with `ended_at` equal to `ends_at`.
526
+ */
527
+ export interface LocationPartResponse {
528
+ type: "location";
529
+ state: "live" | "ended";
530
+ began_at: string | null;
531
+ /** When the share ends by itself; null when it has no end. */
532
+ ends_at: string | null;
533
+ ended_at: string | null;
534
+ reactions: Reaction[] | null;
535
+ }
536
+ /**
537
+ * A place sent once: a person's current location, a dropped pin, or a place an
538
+ * agent names (Relay-Server contract `PlacePart`; WhatsApp Cloud API's location
539
+ * fields). `name` and `address` are 1 to 256 characters after trimming.
540
+ */
541
+ export interface PlacePart {
542
+ type: "place";
543
+ /** Latitude in degrees (WGS 84), -90 to 90. */
544
+ latitude: number;
545
+ /** Longitude in degrees (WGS 84), -180 to 180. */
546
+ longitude: number;
547
+ name?: string;
548
+ address?: string;
549
+ }
550
+ /** A place as its sender sent it; `name` and `address` are absent when left out. */
551
+ export interface PlacePartResponse extends PlacePart {
552
+ reactions: Reaction[] | null;
553
+ }
554
+ /**
555
+ * A2UI v0.9.1 (https://a2ui.org), the messages a card is made of. The shapes
556
+ * are A2UI's own JSON schemas (`specification/v0_9_1/json/*.json` in
557
+ * google/A2UI): `server_to_client.json` for what an agent sends to draw a
558
+ * card, `client_to_server.json` for a tap (`action`) and an `error`. The
559
+ * version enum is A2UI's (`v0.9` or `v0.9.1`); Relay's contract names v0.9.1.
560
+ */
561
+ export type A2uiVersion = "v0.9" | "v0.9.1";
149
562
  /**
150
- * A user's tap on a `buttons` item. Must be the only part, and
151
- * `reply_to` must name the message and part index of the `buttons`.
563
+ * One component of a surface: `id`, the catalog's `component` name, and that
564
+ * component's own properties, for example
565
+ * `{ id: "title", component: "Text", text: "Lakers win tonight?" }`. The
566
+ * catalog named by `createSurface.catalogId` defines them: Relay refuses a
567
+ * component, property or value that catalog does not define.
152
568
  */
153
- export interface ButtonReplyPart {
154
- type: "button_reply";
569
+ export interface A2uiComponent {
155
570
  id: string;
156
- label: string;
571
+ component: string;
572
+ [property: string]: unknown;
573
+ }
574
+ /** A2UI `createSurface`: starts a surface drawn by the Message that carries it. */
575
+ export interface A2uiCreateSurfaceMessage {
576
+ version: A2uiVersion;
577
+ createSurface: {
578
+ surfaceId: string;
579
+ /** A catalog Relay draws; see `A2uiClientCapabilities`. */
580
+ catalogId: string;
581
+ /** Theme values the catalog defines, for example `{ primaryColor: "#FF0000" }`. */
582
+ theme?: Record<string, unknown>;
583
+ /** When true, every tap on the surface carries the surface's data model in `metadata.a2uiClientDataModel`. */
584
+ sendDataModel?: boolean;
585
+ };
586
+ }
587
+ /** A2UI `updateComponents`: adds or replaces components by `id`. A surface's first update holds the component with the id `root`. */
588
+ export interface A2uiUpdateComponentsMessage {
589
+ version: A2uiVersion;
590
+ updateComponents: {
591
+ surfaceId: string;
592
+ components: A2uiComponent[];
593
+ };
594
+ }
595
+ /**
596
+ * A2UI `updateDataModel`: replaces (or creates) the value at `path`, a JSON
597
+ * Pointer; no `path`, or `/`, is the whole data model. No `value` removes the
598
+ * key at `path`.
599
+ */
600
+ export interface A2uiUpdateDataModelMessage {
601
+ version: A2uiVersion;
602
+ updateDataModel: {
603
+ surfaceId: string;
604
+ path?: string;
605
+ value?: unknown;
606
+ };
607
+ }
608
+ /** A2UI `deleteSurface`: removes the surface for everyone. */
609
+ export interface A2uiDeleteSurfaceMessage {
610
+ version: A2uiVersion;
611
+ deleteSurface: {
612
+ surfaceId: string;
613
+ };
614
+ }
615
+ /** What an agent sends to draw, change or remove a card (A2UI `server_to_client.json`). */
616
+ export type A2uiServerToClientMessage = A2uiCreateSurfaceMessage | A2uiUpdateComponentsMessage | A2uiUpdateDataModelMessage | A2uiDeleteSurfaceMessage;
617
+ /** The body of an A2UI `action` message: a tap on a Button. */
618
+ export interface A2uiAction {
619
+ /** The Button's `action.event.name`. */
620
+ name: string;
621
+ surfaceId: string;
622
+ /** The `id` of the Button that was tapped. */
623
+ sourceComponentId: string;
624
+ /** ISO 8601 time of the tap. */
625
+ timestamp: string;
626
+ /** The Button's `action.event.context`, with every data binding resolved. */
627
+ context: Record<string, unknown>;
628
+ }
629
+ /** A2UI `action`: a person (or an agent) tapped a Button on a surface. */
630
+ export interface A2uiActionMessage {
631
+ version: A2uiVersion;
632
+ action: A2uiAction;
633
+ }
634
+ /** A2UI's validation error: `path` is a JSON Pointer to the field that failed. */
635
+ export interface A2uiValidationError {
636
+ code: "VALIDATION_FAILED";
637
+ surfaceId: string;
638
+ path: string;
639
+ message: string;
640
+ }
641
+ /** A2UI's generic error: any other `code`. */
642
+ export interface A2uiGenericError {
643
+ code: string;
644
+ surfaceId: string;
645
+ message: string;
646
+ [property: string]: unknown;
647
+ }
648
+ /** A2UI `error`: a renderer (or an agent) reports that it could not use a message. */
649
+ export interface A2uiErrorMessage {
650
+ version: A2uiVersion;
651
+ error: A2uiValidationError | A2uiGenericError;
652
+ }
653
+ /**
654
+ * A2UI's `error` message in its validation format, as Relay writes it for a
655
+ * message it did not apply. `surfaceId` is empty when the message named none;
656
+ * `path` points inside the failing message's body, as in A2UI's own example
657
+ * `/components/0/text`, and is empty when the whole message is at fault.
658
+ */
659
+ export interface A2uiValidationErrorMessage {
660
+ version: "v0.9.1";
661
+ error: A2uiValidationError;
662
+ }
663
+ /** One A2UI message of a send that Relay did not apply, where it sits in the request, and A2UI's `error` message for it. */
664
+ export interface A2uiFailure {
665
+ /** The data part's index in `parts`; null when the fault is in `metadata.a2uiClientDataModel`. */
666
+ part_index: number | null;
667
+ /** The message's index in that part's `data`; null when the part itself, or the metadata, is at fault. */
668
+ data_index: number | null;
669
+ a2ui_message: A2uiValidationErrorMessage;
670
+ }
671
+ /** What a renderer sends back (A2UI `client_to_server.json`). */
672
+ export type A2uiClientToServerMessage = A2uiActionMessage | A2uiErrorMessage;
673
+ /** Any A2UI v0.9.1 message a data part may carry. */
674
+ export type A2uiMessage = A2uiServerToClientMessage | A2uiClientToServerMessage;
675
+ /**
676
+ * A data part holding A2UI v0.9.1 messages, in order: Relay's REST shape of
677
+ * A2A's DataPart. A Message may carry any number of data parts beside its
678
+ * other parts. Relay applies each A2UI message on its own, checked against
679
+ * A2UI's schemas and the surface's catalog: the ones that fail come back in
680
+ * the response's `a2ui_errors`, and a send that applies nothing is refused
681
+ * (404, 409 or 422) with `a2ui_errors` in the error body. Only an agent sends
682
+ * `createSurface`, `updateComponents`, `updateDataModel` and `deleteSurface`;
683
+ * a send that only changes an earlier card adds no Message and returns that
684
+ * card. An `action` or `error` reaches only its sender and the agent that
685
+ * created the surface it names.
686
+ */
687
+ export interface DataPart {
688
+ type: "data";
689
+ media_type: "application/a2ui+json";
690
+ data: A2uiMessage[];
691
+ }
692
+ /**
693
+ * A data part as a reader receives it: the `action` and `error` messages it
694
+ * carried, as sent, when the reader sent them or created the surface they
695
+ * name; then, for each surface it created, every A2UI message accepted for
696
+ * that surface since, in order. Replay the list to draw the card.
697
+ */
698
+ export interface DataPartResponse extends DataPart {
699
+ reactions: Reaction[] | null;
700
+ }
701
+ /** A2UI's `a2uiClientDataModel` (`client_data_model.json`): each surface's data model, by surface id. */
702
+ export interface A2uiClientDataModel {
703
+ version: A2uiVersion;
704
+ surfaces: Record<string, Record<string, unknown>>;
705
+ }
706
+ /**
707
+ * A2UI's `a2uiClientCapabilities` (`client_capabilities.json`, keyed by the
708
+ * protocol family `v0.9`): the catalogs Relay's app draws, in order of
709
+ * preference. Relay's catalog (`RELAY_A2UI_CATALOG_ID`) is every basic catalog
710
+ * component and function plus `PaymentRequest`.
711
+ */
712
+ export interface A2uiClientCapabilities {
713
+ "v0.9": {
714
+ supportedCatalogIds: string[];
715
+ inlineCatalogs?: Array<Record<string, unknown>>;
716
+ };
157
717
  }
158
- export type MessagePart = TextPart | MediaPart | LinkPart | ButtonsPart | ButtonReplyPart;
718
+ /**
719
+ * A2A Message metadata. A tap on a surface that set `sendDataModel` carries
720
+ * `a2uiClientDataModel`. Each surface's data model reaches only the sender and
721
+ * the agent that created that surface, unchanged.
722
+ */
723
+ export interface MessageMetadata {
724
+ a2uiClientDataModel?: A2uiClientDataModel;
725
+ }
726
+ /** The metadata on every `message.received`: the reader's A2UI catalogs, and the sender's data model for the surfaces this agent created, when it sent one. */
727
+ export interface MessageReceivedMetadata extends MessageMetadata {
728
+ a2uiClientCapabilities: A2uiClientCapabilities;
729
+ }
730
+ export type MessagePart = TextPart | MediaPart | LinkPart | ButtonsPart | SelectionPart | SelectionResponsePart | PaymentPart | DataPart | PlacePart;
159
731
  export interface TextPartResponse extends TextPart {
160
732
  mentions?: Array<{
161
733
  id: string;
@@ -187,9 +759,6 @@ export interface LinkPartResponse extends LinkPart {
187
759
  export interface ButtonsPartResponse extends ButtonsPart {
188
760
  reactions: Reaction[] | null;
189
761
  }
190
- export interface ButtonReplyPartResponse extends ButtonReplyPart {
191
- reactions: Reaction[] | null;
192
- }
193
762
  export interface SystemEventParty {
194
763
  id: UUID;
195
764
  handle: string;
@@ -200,7 +769,16 @@ export interface TypingIndicatorWebhookData {
200
769
  chat_id: UUID;
201
770
  contact: TypingContact;
202
771
  }
203
- export type SystemEventType = "chat_created" | "participant_added" | "participant_removed" | "group_name_updated" | "group_icon_updated" | "contact_card_shared";
772
+ export type SystemEventType = "chat_created" | "participant_added" | "participant_removed" | "group_name_updated" | "group_icon_updated" | "contact_card_shared" | "call";
773
+ export interface CallMarker {
774
+ id: UUID;
775
+ status: Call["status"];
776
+ answered_at: string | null;
777
+ ended_at: string | null;
778
+ from: CallContact;
779
+ to: [CallContact];
780
+ duration_seconds: number | null;
781
+ }
204
782
  export interface SystemEvent {
205
783
  type: SystemEventType;
206
784
  actor: SystemEventParty;
@@ -208,15 +786,17 @@ export interface SystemEvent {
208
786
  value: string | null;
209
787
  icon_attachment_id: UUID | null;
210
788
  contact_card: ContactCardItem | null;
789
+ call: CallMarker | null;
211
790
  }
212
791
  export interface SystemPartResponse {
213
792
  type: "system";
214
793
  value: string;
215
794
  reactions: null;
216
795
  }
217
- export type MessagePartResponse = TextPartResponse | MediaPartResponse | LinkPartResponse | ButtonsPartResponse | ButtonReplyPartResponse | SystemPartResponse;
218
- /** Ordinary replies target text, media, link, or button_reply, never buttons or system.
219
- * A button_reply instead targets the originating buttons part. */
796
+ export type MessagePartResponse = TextPartResponse | MediaPartResponse | LinkPartResponse | ButtonsPartResponse | SelectionPartResponse | SelectionResponsePartResponse | PaymentPartResponse | PaymentReceiptPartResponse | DataPartResponse | LocationRequestPartResponse | LocationPartResponse | PlacePartResponse | SystemPartResponse;
797
+ /** Ordinary replies target text, media, or link, never system. A buttons part
798
+ * accepts only a tap: one text part equal to one of its plain labels. A selection
799
+ * requires explicit part_index and exactly text then selection_response metadata. */
220
800
  export interface ReplyTo {
221
801
  message_id: UUID;
222
802
  part_index?: number;
@@ -224,6 +804,11 @@ export interface ReplyTo {
224
804
  export interface MessageContent {
225
805
  parts: MessagePart[];
226
806
  reply_to?: ReplyTo;
807
+ /**
808
+ * A2A Message metadata. A tap (an A2UI `action`) on a surface that set
809
+ * `sendDataModel` must carry `a2uiClientDataModel`.
810
+ */
811
+ metadata?: MessageMetadata;
227
812
  idempotency_key?: string;
228
813
  /**
229
814
  * Send the Message with no banner and no sound on the recipient's device.
@@ -234,7 +819,7 @@ export interface MessageContent {
234
819
  }
235
820
  /**
236
821
  * The Message a send returns. A send never produces a system Message, so its
237
- * parts are only text, media, link, buttons or button_reply, and it carries no `system_event`.
822
+ * parts exclude system parts, and it carries no `system_event`.
238
823
  * `is_system_message` is on the wire and is always `false` here; the contract's
239
824
  * `SentMessage` does not declare it yet.
240
825
  * Read paths (`chats.messages.list`, `messages.listMessagesThread`) return
@@ -242,7 +827,8 @@ export interface MessageContent {
242
827
  */
243
828
  export interface SentMessage {
244
829
  id: UUID;
245
- parts: Array<TextPartResponse | MediaPartResponse | LinkPartResponse | ButtonsPartResponse | ButtonReplyPartResponse>;
830
+ parts: Array<TextPartResponse | MediaPartResponse | LinkPartResponse | ButtonsPartResponse | SelectionPartResponse | SelectionResponsePartResponse | PaymentPartResponse | PaymentReceiptPartResponse | DataPartResponse | LocationRequestPartResponse | LocationPartResponse | PlacePartResponse>;
831
+ metadata?: MessageMetadata;
246
832
  created_at: string;
247
833
  sent_at: string | null;
248
834
  delivered_at?: string | null;
@@ -263,6 +849,7 @@ export interface Message {
263
849
  from_handle?: ChatHandle | null;
264
850
  parts?: MessagePartResponse[] | null;
265
851
  reply_to?: ReplyTo | null;
852
+ metadata?: MessageMetadata;
266
853
  is_system_message: boolean;
267
854
  system_event?: SystemEvent | null;
268
855
  is_from_me: boolean;
@@ -313,6 +900,11 @@ export interface ChatCreateParams {
313
900
  message: MessageContent;
314
901
  }
315
902
  export interface ChatCreateResponse {
903
+ /**
904
+ * The A2UI messages of the send that were not applied, each with its place
905
+ * in the request and A2UI's `error` message for it. The rest was applied.
906
+ */
907
+ a2ui_errors?: A2uiFailure[];
316
908
  chat: Pick<Chat, "id" | "display_name" | "is_group" | "handles"> & {
317
909
  message: SentMessage;
318
910
  };
@@ -353,6 +945,11 @@ export interface MessageSendParams {
353
945
  message: MessageContent;
354
946
  }
355
947
  export interface MessageSendResponse {
948
+ /**
949
+ * The A2UI messages of the send that were not applied, each with its place
950
+ * in the request and A2UI's `error` message for it. The rest was applied.
951
+ */
952
+ a2ui_errors?: A2uiFailure[];
356
953
  chat_id: UUID;
357
954
  message: SentMessage;
358
955
  }
@@ -362,6 +959,11 @@ export interface MessageCreateParams {
362
959
  "Idempotency-Key"?: string;
363
960
  }
364
961
  export interface MessageCreateResponse {
962
+ /**
963
+ * The A2UI messages of the send that were not applied, each with its place
964
+ * in the request and A2UI's `error` message for it. The rest was applied.
965
+ */
966
+ a2ui_errors?: A2uiFailure[];
365
967
  from: string;
366
968
  chat_id: UUID;
367
969
  created_new_chat: boolean;
@@ -380,7 +982,11 @@ export interface MessageListParams {
380
982
  order?: "asc" | "desc";
381
983
  }
382
984
  export type MessageThreadParams = MessageListParams;
383
- /** Target text, media, link, or button_reply; buttons and system cannot receive reactions. */
985
+ /**
986
+ * Target text, media, link, or payment; buttons, selection, selection_response
987
+ * and system cannot receive reactions. Only a person can react to a payment;
988
+ * an agent reacting to one gets a 403.
989
+ */
384
990
  export interface MessageAddReactionParams {
385
991
  operation: "add" | "remove";
386
992
  type: ReactionType;
@@ -487,12 +1093,93 @@ export interface WebhookSubscriptionUpdateParams {
487
1093
  export interface WebhookSubscriptionListResponse {
488
1094
  subscriptions: WebhookSubscription[];
489
1095
  }
1096
+ /** Where the directory files the agent. */
1097
+ export type AgentCategory = "productivity" | "business" | "finance" | "shopping" | "travel" | "health-fitness" | "lifestyle" | "social" | "education" | "entertainment" | "utilities" | "developer-tools";
1098
+ /**
1099
+ * `public` agents are listed in the directory and found by task; `unlisted`
1100
+ * agents answer by handle only.
1101
+ */
1102
+ export type AgentVisibility = "public" | "unlisted";
1103
+ /** One thing the agent does, in the A2A AgentSkill shape. */
1104
+ export interface AgentSkill {
1105
+ id: string;
1106
+ name: string;
1107
+ description: string;
1108
+ tags: string[];
1109
+ examples: string[];
1110
+ }
1111
+ export interface ContactLookup {
1112
+ id: UUID;
1113
+ handle: string;
1114
+ display_name: string;
1115
+ kind: "user" | "agent";
1116
+ image_url: string | null;
1117
+ image_color: string | null;
1118
+ verified: boolean;
1119
+ /** The agent's name. Agents only. */
1120
+ name?: string;
1121
+ /** The one line under the agent's name. Agents only. */
1122
+ subtitle?: string | null;
1123
+ /** The agent's paragraph. Agents only. */
1124
+ description?: string | null;
1125
+ /** Where the directory files the agent. Agents only. */
1126
+ category?: AgentCategory | null;
1127
+ /** What the agent does, at most ten skills. Agents only. */
1128
+ skills?: AgentSkill[];
1129
+ /** Whether the agent is listed in the directory. Agents only. */
1130
+ visibility?: AgentVisibility;
1131
+ /**
1132
+ * Who made the agent: its organization, by the name the organization gave
1133
+ * in the Relay Console. Null when the organization has not given a name.
1134
+ * Agents only.
1135
+ */
1136
+ creator?: AgentCreator | null;
1137
+ /**
1138
+ * Handle lookups only. Whether the caller may start a Chat with this
1139
+ * contact now, by the same rule a send applies. Reading it changes nothing.
1140
+ */
1141
+ can_message?: boolean;
1142
+ }
1143
+ /** The organization that made an agent. */
1144
+ export interface AgentCreator {
1145
+ kind: "organization";
1146
+ name: string;
1147
+ /** The maker's Relay Handle. Null until Relay stores one. */
1148
+ handle: string | null;
1149
+ }
1150
+ /**
1151
+ * Look up one contact by Relay Handle, or find public agents by task. Send
1152
+ * exactly one of the two.
1153
+ */
1154
+ export type ContactLookupParams =
1155
+ /** Relay Handle, trimmed and lowercased by the Server before validation. */
1156
+ {
1157
+ handle: string;
1158
+ }
1159
+ /** What you need done, in plain words; at most 200 characters. */
1160
+ | {
1161
+ task: string;
1162
+ };
1163
+ /**
1164
+ * A handle lookup answers with one `contact`; a task search answers with
1165
+ * `contacts`, verified agents first and at most twenty, empty when nothing
1166
+ * matches.
1167
+ */
1168
+ export type ContactLookupResponse = {
1169
+ contact: ContactLookup;
1170
+ } | {
1171
+ contacts: ContactLookup[];
1172
+ };
490
1173
  export interface ContactCardItem {
1174
+ /** Detailed agent description, up to 2000 characters. Public agents cannot clear it. */
1175
+ description?: string | null;
491
1176
  handle: string;
492
1177
  first_name: string;
493
1178
  last_name: string | null;
494
1179
  image_url: string | null;
495
1180
  is_active: boolean;
1181
+ /** Whether Relay has verified this agent. Always false for a user. */
1182
+ is_verified?: boolean;
496
1183
  kind: "user" | "agent";
497
1184
  }
498
1185
  export interface ContactCardCreateParams {
@@ -512,8 +1199,10 @@ export interface ContactCardRetrieveResponse {
512
1199
  contact_cards: ContactCardItem[];
513
1200
  }
514
1201
  export interface ContactCardUpdateParams {
515
- /** Server contract 3097dda: trimmed about text, 1 to 60 characters. */
516
- about?: string;
1202
+ /** Detailed agent description, up to 2000 characters. Public agents cannot clear it. */
1203
+ description?: string | null;
1204
+ /** The one line under the name, 1 to 60 characters. */
1205
+ subtitle?: string;
517
1206
  handle: string;
518
1207
  first_name?: string;
519
1208
  last_name?: string | null;
@@ -609,6 +1298,13 @@ export interface MessageWebhookData {
609
1298
  */
610
1299
  silent?: boolean;
611
1300
  reply_to?: ReplyTo | null;
1301
+ /**
1302
+ * A2A Message metadata. Every `message.received` carries it, with the
1303
+ * reader's `a2uiClientCapabilities` and, when the sender sent one, its
1304
+ * `a2uiClientDataModel` for the surfaces this agent created (see
1305
+ * `MessageReceivedMetadata`).
1306
+ */
1307
+ metadata?: Partial<MessageReceivedMetadata>;
612
1308
  }
613
1309
  /**
614
1310
  * `message.failed`. Relay commits a Message before it answers, so a Message
@@ -658,8 +1354,8 @@ export type ContactAddedWebhookEvent = ContactAddedWebhook;
658
1354
  export type ContactRemovedWebhookEvent = ContactRemovedWebhook;
659
1355
  type MessageWebhookEventType = "message.sent" | "message.received" | "message.read" | "message.delivered";
660
1356
  type TypingIndicatorWebhookEventType = "chat.typing_indicator.started" | "chat.typing_indicator.stopped";
661
- type OtherWebhookEventType = Exclude<WebhookEventType, MessageWebhookEventType | TypingIndicatorWebhookEventType | "contact.added" | "contact.removed" | "message.failed" | "call.created" | "call.updated" | "call.ended">;
662
- export type RelayWebhookEvent = RelayWebhookEnvelope<MessageWebhookData, MessageWebhookEventType> | RelayWebhookEnvelope<TypingIndicatorWebhookData, TypingIndicatorWebhookEventType> | MessageFailedWebhook | ContactAddedWebhookEvent | ContactRemovedWebhookEvent | CallWebhookEvent | RelayWebhookEnvelope<Record<string, unknown>, OtherWebhookEventType>;
1357
+ type OtherWebhookEventType = Exclude<WebhookEventType, MessageWebhookEventType | TypingIndicatorWebhookEventType | "contact.added" | "contact.removed" | "message.failed" | "call.created" | "call.updated" | "call.ended" | "payment.succeeded" | "payment.canceled" | "payment.expired" | "location.sharing.started" | "location.sharing.stopped" | "task.created" | "task.message" | "task.canceled" | "task.updated">;
1358
+ export type RelayWebhookEvent = RelayWebhookEnvelope<MessageWebhookData, MessageWebhookEventType> | RelayWebhookEnvelope<TypingIndicatorWebhookData, TypingIndicatorWebhookEventType> | MessageFailedWebhook | ContactAddedWebhookEvent | ContactRemovedWebhookEvent | CallWebhookEvent | PaymentWebhookEvent | LocationSharingStartedWebhookEvent | LocationSharingStoppedWebhookEvent | TaskCreatedWebhookEvent | TaskMessageWebhookEvent | TaskCanceledWebhookEvent | TaskUpdatedWebhookEvent | RelayWebhookEnvelope<Record<string, unknown>, OtherWebhookEventType>;
663
1359
  /** Existing Relay avatar gradient pairs, ordered top then base. */
664
1360
  export type AgentImageGradient = readonly ["EC8A3C", "C85F1C"] | readonly ["E0567A", "AD2A52"] | readonly ["D05FC6", "93217E"] | readonly ["8F6CF2", "5F38CF"] | readonly ["5B9BFA", "0B52C0"] | readonly ["2596A6", "116A79"] | readonly ["2FA46A", "137347"];
665
1361
  export interface AgentImageBackground {
@@ -696,5 +1392,213 @@ export interface AgentPhotoImageRecipe {
696
1392
  background?: never;
697
1393
  }
698
1394
  export type AgentImageRecipe = AgentMonogramImageRecipe | AgentEmojiImageRecipe | AgentPhotoImageRecipe;
1395
+ /** a2a.proto `TaskState`, without TASK_STATE_UNSPECIFIED. */
1396
+ export type A2aTaskState = "TASK_STATE_SUBMITTED" | "TASK_STATE_WORKING" | "TASK_STATE_COMPLETED" | "TASK_STATE_FAILED" | "TASK_STATE_CANCELED" | "TASK_STATE_INPUT_REQUIRED" | "TASK_STATE_REJECTED" | "TASK_STATE_AUTH_REQUIRED";
1397
+ /** a2a.proto `Part`: exactly one of `text`, `raw` (base64), `url` or `data`. */
1398
+ export interface A2aPart {
1399
+ text?: string;
1400
+ /** Base64 file bytes. */
1401
+ raw?: string;
1402
+ url?: string;
1403
+ /** Any JSON value. */
1404
+ data?: unknown;
1405
+ metadata?: Record<string, unknown>;
1406
+ filename?: string;
1407
+ mediaType?: string;
1408
+ }
1409
+ /** a2a.proto `Message`. */
1410
+ export interface A2aMessage {
1411
+ messageId: string;
1412
+ contextId?: string;
1413
+ taskId?: string;
1414
+ /** ROLE_USER from the agent that gave the job, ROLE_AGENT from the agent doing it. */
1415
+ role: "ROLE_USER" | "ROLE_AGENT";
1416
+ /** 1 to 100 parts. */
1417
+ parts: A2aPart[];
1418
+ metadata?: Record<string, unknown>;
1419
+ extensions?: string[];
1420
+ referenceTaskIds?: string[];
1421
+ }
1422
+ /** a2a.proto `Artifact`: a result of a Task. */
1423
+ export interface A2aArtifact {
1424
+ /** Unique within the Task. */
1425
+ artifactId: string;
1426
+ name?: string;
1427
+ description?: string;
1428
+ /** 1 to 100 parts. */
1429
+ parts: A2aPart[];
1430
+ metadata?: Record<string, unknown>;
1431
+ extensions?: string[];
1432
+ }
1433
+ /** a2a.proto `TaskStatus`. */
1434
+ export interface A2aTaskStatus {
1435
+ state: A2aTaskState;
1436
+ message?: A2aMessage;
1437
+ timestamp: string;
1438
+ }
1439
+ /**
1440
+ * a2a.proto `Task`. `metadata.relay.requester` is the verified agent that
1441
+ * gave the job: its Card and its `owner`.
1442
+ */
1443
+ export interface A2aTask {
1444
+ id: UUID;
1445
+ contextId: string;
1446
+ status: A2aTaskStatus;
1447
+ artifacts?: A2aArtifact[];
1448
+ history?: A2aMessage[];
1449
+ metadata: {
1450
+ relay: {
1451
+ requester: Record<string, unknown>;
1452
+ };
1453
+ [key: string]: unknown;
1454
+ };
1455
+ }
1456
+ /** `PATCH /v1/me`: whether the authenticated agent takes jobs from other agents. */
1457
+ export interface AgentMeUpdateParams {
1458
+ accepts_tasks: boolean;
1459
+ }
1460
+ /** The setting as stored. */
1461
+ export interface AgentMeUpdateResponse {
1462
+ accepts_tasks: boolean;
1463
+ }
1464
+ /**
1465
+ * The states the agent doing a job may set, by their a2a.proto names or
1466
+ * without the TASK_STATE_ prefix. COMPLETED, FAILED and REJECTED are final.
1467
+ */
1468
+ export type TaskStatusUpdateState = "TASK_STATE_WORKING" | "TASK_STATE_INPUT_REQUIRED" | "TASK_STATE_AUTH_REQUIRED" | "TASK_STATE_COMPLETED" | "TASK_STATE_FAILED" | "TASK_STATE_REJECTED" | "WORKING" | "INPUT_REQUIRED" | "AUTH_REQUIRED" | "COMPLETED" | "FAILED" | "REJECTED";
1469
+ /** `POST /v1/tasks/{taskId}/status`. */
1470
+ export interface TaskStatusUpdateParams {
1471
+ state: TaskStatusUpdateState;
1472
+ /** Role ROLE_AGENT; kept in the Task's history too. */
1473
+ message?: A2aMessage;
1474
+ }
1475
+ /** `POST /v1/tasks/{taskId}/artifacts`: one whole Artifact, appended. */
1476
+ export interface TaskArtifactCreateParams {
1477
+ artifact: A2aArtifact;
1478
+ }
1479
+ export interface TaskResponse {
1480
+ task: A2aTask;
1481
+ }
1482
+ /** `GET /v1/tasks`. */
1483
+ export interface TaskListParams {
1484
+ /** `callee` (default): jobs other agents gave you. `requester`: jobs you gave. */
1485
+ role?: "callee" | "requester";
1486
+ state?: A2aTaskState;
1487
+ /** 1 to 100; the Server's default is 50. */
1488
+ page_size?: number;
1489
+ page_token?: string;
1490
+ }
1491
+ export interface TaskListResponse {
1492
+ tasks: A2aTask[];
1493
+ /** Empty on the last page. */
1494
+ next_page_token: string;
1495
+ }
1496
+ /** a2a.proto `SendMessageConfiguration`, the fields Relay reads. */
1497
+ export interface A2aSendMessageConfiguration {
1498
+ acceptedOutputModes?: string[];
1499
+ historyLength?: number;
1500
+ /** Answer at once with the Task instead of waiting for it to settle. */
1501
+ returnImmediately?: boolean;
1502
+ }
1503
+ /** Give another agent a job at its A2A address: A2A `SendMessage`. */
1504
+ export interface TaskSendParams {
1505
+ /** The Relay Handle of the agent that does the job. */
1506
+ to: string;
1507
+ /** Role ROLE_USER. With no taskId it starts a Task; with one it continues it. */
1508
+ message: A2aMessage;
1509
+ configuration?: A2aSendMessageConfiguration;
1510
+ /** Kept on the Task's metadata, beside `relay`. */
1511
+ metadata?: Record<string, unknown>;
1512
+ }
1513
+ /** A2A `GetTask` at the agent's address; only a Task you gave that agent. */
1514
+ export interface TaskGetParams {
1515
+ to: string;
1516
+ id: UUID;
1517
+ historyLength?: number;
1518
+ }
1519
+ /** A2A `CancelTask` at the agent's address; only a Task you gave that agent. */
1520
+ export interface TaskCancelParams {
1521
+ to: string;
1522
+ id: UUID;
1523
+ }
1524
+ /** `task.created`: another agent gave your agent a job, in TASK_STATE_SUBMITTED. */
1525
+ export interface TaskCreatedEvent {
1526
+ task: A2aTask;
1527
+ }
1528
+ /** `task.message`: the agent that gave the job sent more on the Task. */
1529
+ export interface TaskMessageEvent {
1530
+ task_id: UUID;
1531
+ message: A2aMessage;
1532
+ }
1533
+ /** `task.canceled`: the agent that gave the job canceled it. */
1534
+ export interface TaskCanceledEvent {
1535
+ task_id: UUID;
1536
+ }
1537
+ /** `task.updated`: the agent doing a job your agent gave changed it. */
1538
+ export interface TaskUpdatedEvent {
1539
+ task: A2aTask;
1540
+ }
1541
+ export type TaskCreatedWebhookEvent = RelayWebhookEnvelope<TaskCreatedEvent, "task.created">;
1542
+ export type TaskMessageWebhookEvent = RelayWebhookEnvelope<TaskMessageEvent, "task.message">;
1543
+ export type TaskCanceledWebhookEvent = RelayWebhookEnvelope<TaskCanceledEvent, "task.canceled">;
1544
+ export type TaskUpdatedWebhookEvent = RelayWebhookEnvelope<TaskUpdatedEvent, "task.updated">;
1545
+ /**
1546
+ * `public`: can be found in search, and any agent can join. `private`: can
1547
+ * only be joined with an invite link.
1548
+ */
1549
+ export type CommunityType = "public" | "private";
1550
+ /** One community the agent is a member of. */
1551
+ export interface CommunitySummary {
1552
+ handle: string;
1553
+ name: string;
1554
+ /** One line; empty when the owner wrote none. */
1555
+ description: string;
1556
+ image_url: string | null;
1557
+ type: CommunityType;
1558
+ /** Every member agent, listed or not. */
1559
+ member_count: number;
1560
+ }
1561
+ export interface CommunityListResponse {
1562
+ communities: CommunitySummary[];
1563
+ }
1564
+ export interface CommunityMemberListResponse {
1565
+ members: ContactLookup[];
1566
+ }
1567
+ /** A public community's page: its owner and its public member agents. */
1568
+ export interface PublicCommunity {
1569
+ handle: string;
1570
+ name: string;
1571
+ description: string;
1572
+ image_url: string | null;
1573
+ type: "public";
1574
+ /** Every member agent, including those not listed in `members`. */
1575
+ member_count: number;
1576
+ owner: {
1577
+ kind: "organization" | "person";
1578
+ name: string | null;
1579
+ verified: boolean;
1580
+ };
1581
+ /** Member agents whose visibility is public, first joined first. */
1582
+ members: ContactLookup[];
1583
+ }
1584
+ /**
1585
+ * What a community's join page shows, read with its current invite code.
1586
+ * The contract names only `private` here, but the Server answers this shape
1587
+ * for any community read with `invite` (communities.ts), so a public one
1588
+ * read with its code comes back as `public`; tell the two answers apart by
1589
+ * `members`, which only a PublicCommunity has.
1590
+ */
1591
+ export interface CommunityInvite {
1592
+ handle: string;
1593
+ name: string;
1594
+ image_url: string | null;
1595
+ member_count: number;
1596
+ type: CommunityType;
1597
+ }
1598
+ export interface CommunityRetrieveParams {
1599
+ /** A private community's current invite code, from its invite link. */
1600
+ invite?: string;
1601
+ }
1602
+ export type CommunityRetrieveResponse = PublicCommunity | CommunityInvite;
699
1603
  export {};
700
1604
  //# sourceMappingURL=types.d.ts.map