spectrum-ts 4.1.0 → 5.0.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.
Files changed (46) hide show
  1. package/README.md +29 -67
  2. package/dist/authoring.d.ts +1 -6
  3. package/dist/authoring.js +2 -36
  4. package/dist/elysia.d.ts +1 -0
  5. package/dist/elysia.js +2 -0
  6. package/dist/express.d.ts +1 -0
  7. package/dist/express.js +2 -0
  8. package/dist/hono.d.ts +1 -0
  9. package/dist/hono.js +2 -0
  10. package/dist/index.d.ts +1 -2837
  11. package/dist/index.js +2 -3373
  12. package/dist/manifest.json +5 -5
  13. package/dist/providers/imessage/index.d.ts +1 -222
  14. package/dist/providers/imessage/index.js +2 -25
  15. package/dist/providers/index.d.ts +6 -19
  16. package/dist/providers/index.js +6 -34
  17. package/dist/providers/slack/index.d.ts +1 -46
  18. package/dist/providers/slack/index.js +2 -11
  19. package/dist/providers/telegram/index.d.ts +1 -45
  20. package/dist/providers/telegram/index.js +2 -13
  21. package/dist/providers/terminal/index.d.ts +1 -119
  22. package/dist/providers/terminal/index.js +2 -13
  23. package/dist/providers/whatsapp-business/index.d.ts +1 -27
  24. package/dist/providers/whatsapp-business/index.js +2 -14
  25. package/package.json +23 -26
  26. package/dist/attachment-CnivEhr6.d.ts +0 -29
  27. package/dist/authoring-b9AhXgPI.d.ts +0 -304
  28. package/dist/chunk-2D27WW5B.js +0 -63
  29. package/dist/chunk-34FQGGD7.js +0 -34
  30. package/dist/chunk-3GEJYGZK.js +0 -84
  31. package/dist/chunk-3KWFP4L2.js +0 -864
  32. package/dist/chunk-5XEFJBN2.js +0 -197
  33. package/dist/chunk-6UZFVXQF.js +0 -374
  34. package/dist/chunk-A37PM5N2.js +0 -91
  35. package/dist/chunk-B52VPQO3.js +0 -1379
  36. package/dist/chunk-DMT6BFJV.js +0 -2980
  37. package/dist/chunk-FAIFTUV2.js +0 -139
  38. package/dist/chunk-IM5ADDZS.js +0 -887
  39. package/dist/chunk-LZXPLXZF.js +0 -35
  40. package/dist/chunk-U3QQ56YZ.js +0 -929
  41. package/dist/chunk-UXAKIXVM.js +0 -409
  42. package/dist/chunk-WXLQNANA.js +0 -539
  43. package/dist/chunk-ZR3TKZMT.js +0 -129
  44. package/dist/read-C4uvozGX.d.ts +0 -53
  45. package/dist/types-BIta6Kxi.d.ts +0 -82
  46. package/dist/types-CyfLJXgu.d.ts +0 -1530
@@ -1,1530 +0,0 @@
1
- import { Pipe, Tuples, Fn } from 'hotscript';
2
- import z__default from 'zod';
3
-
4
- declare const contentSchema: z__default.ZodDiscriminatedUnion<[z__default.ZodObject<{
5
- type: z__default.ZodLiteral<"text">;
6
- text: z__default.ZodString;
7
- }, z__default.core.$strip>, z__default.ZodObject<{
8
- type: z__default.ZodLiteral<"markdown">;
9
- markdown: z__default.ZodString;
10
- }, z__default.core.$strip>, z__default.ZodObject<{
11
- type: z__default.ZodLiteral<"streamText">;
12
- stream: z__default.ZodCustom<() => AsyncIterable<string>, () => AsyncIterable<string>>;
13
- format: z__default.ZodOptional<z__default.ZodEnum<{
14
- markdown: "markdown";
15
- plain: "plain";
16
- }>>;
17
- }, z__default.core.$strip>, z__default.ZodObject<{
18
- type: z__default.ZodLiteral<"custom">;
19
- raw: z__default.ZodUnknown;
20
- }, z__default.core.$strip>, z__default.ZodObject<{
21
- type: z__default.ZodLiteral<"attachment">;
22
- id: z__default.ZodString;
23
- name: z__default.ZodString;
24
- mimeType: z__default.ZodString;
25
- size: z__default.ZodOptional<z__default.ZodNumber>;
26
- read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
27
- stream: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
28
- }, z__default.core.$strip>, z__default.ZodObject<{
29
- type: z__default.ZodLiteral<"contact">;
30
- user: z__default.ZodOptional<z__default.ZodObject<{
31
- __platform: z__default.ZodString;
32
- id: z__default.ZodString;
33
- }, z__default.core.$strip>>;
34
- name: z__default.ZodOptional<z__default.ZodObject<{
35
- formatted: z__default.ZodOptional<z__default.ZodString>;
36
- first: z__default.ZodOptional<z__default.ZodString>;
37
- last: z__default.ZodOptional<z__default.ZodString>;
38
- middle: z__default.ZodOptional<z__default.ZodString>;
39
- prefix: z__default.ZodOptional<z__default.ZodString>;
40
- suffix: z__default.ZodOptional<z__default.ZodString>;
41
- }, z__default.core.$strip>>;
42
- phones: z__default.ZodOptional<z__default.ZodArray<z__default.ZodObject<{
43
- value: z__default.ZodString;
44
- type: z__default.ZodOptional<z__default.ZodEnum<{
45
- mobile: "mobile";
46
- home: "home";
47
- work: "work";
48
- other: "other";
49
- }>>;
50
- }, z__default.core.$strip>>>;
51
- emails: z__default.ZodOptional<z__default.ZodArray<z__default.ZodObject<{
52
- value: z__default.ZodString;
53
- type: z__default.ZodOptional<z__default.ZodEnum<{
54
- home: "home";
55
- work: "work";
56
- other: "other";
57
- }>>;
58
- }, z__default.core.$strip>>>;
59
- addresses: z__default.ZodOptional<z__default.ZodArray<z__default.ZodObject<{
60
- street: z__default.ZodOptional<z__default.ZodString>;
61
- city: z__default.ZodOptional<z__default.ZodString>;
62
- region: z__default.ZodOptional<z__default.ZodString>;
63
- postalCode: z__default.ZodOptional<z__default.ZodString>;
64
- country: z__default.ZodOptional<z__default.ZodString>;
65
- type: z__default.ZodOptional<z__default.ZodEnum<{
66
- home: "home";
67
- work: "work";
68
- other: "other";
69
- }>>;
70
- }, z__default.core.$strip>>>;
71
- org: z__default.ZodOptional<z__default.ZodObject<{
72
- name: z__default.ZodOptional<z__default.ZodString>;
73
- title: z__default.ZodOptional<z__default.ZodString>;
74
- department: z__default.ZodOptional<z__default.ZodString>;
75
- }, z__default.core.$strip>>;
76
- urls: z__default.ZodOptional<z__default.ZodArray<z__default.ZodString>>;
77
- birthday: z__default.ZodOptional<z__default.ZodString>;
78
- note: z__default.ZodOptional<z__default.ZodString>;
79
- photo: z__default.ZodOptional<z__default.ZodObject<{
80
- mimeType: z__default.ZodString;
81
- read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
82
- }, z__default.core.$strip>>;
83
- raw: z__default.ZodOptional<z__default.ZodUnknown>;
84
- }, z__default.core.$strip>, z__default.ZodObject<{
85
- type: z__default.ZodLiteral<"voice">;
86
- name: z__default.ZodOptional<z__default.ZodString>;
87
- mimeType: z__default.ZodString;
88
- duration: z__default.ZodOptional<z__default.ZodNumber>;
89
- size: z__default.ZodOptional<z__default.ZodNumber>;
90
- read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
91
- stream: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
92
- }, z__default.core.$strip>, z__default.ZodObject<{
93
- type: z__default.ZodLiteral<"richlink">;
94
- url: z__default.ZodURL;
95
- title: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
96
- summary: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
97
- cover: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodObject<{
98
- mimeType: z__default.ZodOptional<z__default.ZodString>;
99
- read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
100
- stream: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
101
- }, z__default.core.$strip>>>>;
102
- }, z__default.core.$strip>, z__default.ZodObject<{
103
- type: z__default.ZodLiteral<"reaction">;
104
- emoji: z__default.ZodString;
105
- target: z__default.ZodCustom<Message<string, User, Space<unknown>>, Message<string, User, Space<unknown>>>;
106
- }, z__default.core.$strip>, z__default.ZodObject<{
107
- type: z__default.ZodLiteral<"group">;
108
- items: z__default.ZodArray<z__default.ZodCustom<Message<string, User, Space<unknown>>, Message<string, User, Space<unknown>>>>;
109
- }, z__default.core.$strip>, z__default.ZodObject<{
110
- type: z__default.ZodLiteral<"poll">;
111
- title: z__default.ZodString;
112
- options: z__default.ZodArray<z__default.ZodObject<{
113
- title: z__default.ZodString;
114
- }, z__default.core.$strip>>;
115
- }, z__default.core.$strip>, z__default.ZodObject<{
116
- type: z__default.ZodLiteral<"poll_option">;
117
- option: z__default.ZodObject<{
118
- title: z__default.ZodString;
119
- }, z__default.core.$strip>;
120
- poll: z__default.ZodObject<{
121
- type: z__default.ZodLiteral<"poll">;
122
- title: z__default.ZodString;
123
- options: z__default.ZodArray<z__default.ZodObject<{
124
- title: z__default.ZodString;
125
- }, z__default.core.$strip>>;
126
- }, z__default.core.$strip>;
127
- selected: z__default.ZodBoolean;
128
- title: z__default.ZodString;
129
- }, z__default.core.$strip>, z__default.ZodObject<{
130
- type: z__default.ZodLiteral<"effect">;
131
- content: z__default.ZodDiscriminatedUnion<[z__default.ZodObject<{
132
- type: z__default.ZodLiteral<"text">;
133
- text: z__default.ZodString;
134
- }, z__default.core.$strip>, z__default.ZodObject<{
135
- type: z__default.ZodLiteral<"markdown">;
136
- markdown: z__default.ZodString;
137
- }, z__default.core.$strip>, z__default.ZodObject<{
138
- type: z__default.ZodLiteral<"attachment">;
139
- id: z__default.ZodString;
140
- name: z__default.ZodString;
141
- mimeType: z__default.ZodString;
142
- size: z__default.ZodOptional<z__default.ZodNumber>;
143
- read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
144
- stream: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
145
- }, z__default.core.$strip>], "type">;
146
- effect: z__default.ZodString;
147
- }, z__default.core.$strip>, z__default.ZodObject<{
148
- type: z__default.ZodLiteral<"typing">;
149
- state: z__default.ZodEnum<{
150
- start: "start";
151
- stop: "stop";
152
- }>;
153
- }, z__default.core.$strip>, z__default.ZodObject<{
154
- type: z__default.ZodLiteral<"rename">;
155
- displayName: z__default.ZodString;
156
- }, z__default.core.$strip>, z__default.ZodObject<{
157
- type: z__default.ZodLiteral<"avatar">;
158
- action: z__default.ZodDiscriminatedUnion<[z__default.ZodObject<{
159
- kind: z__default.ZodLiteral<"set">;
160
- read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
161
- mimeType: z__default.ZodString;
162
- }, z__default.core.$strip>, z__default.ZodObject<{
163
- kind: z__default.ZodLiteral<"clear">;
164
- }, z__default.core.$strip>], "kind">;
165
- }, z__default.core.$strip>, z__default.ZodObject<{
166
- type: z__default.ZodLiteral<"reply">;
167
- content: z__default.ZodCustom<{
168
- type: "avatar";
169
- action: {
170
- kind: "set";
171
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
172
- mimeType: string;
173
- } | {
174
- kind: "clear";
175
- };
176
- } | {
177
- type: "text";
178
- text: string;
179
- } | {
180
- type: "markdown";
181
- markdown: string;
182
- } | {
183
- type: "attachment";
184
- id: string;
185
- name: string;
186
- mimeType: string;
187
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
188
- stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
189
- size?: number | undefined;
190
- } | {
191
- type: "streamText";
192
- stream: () => AsyncIterable<string>;
193
- format?: "markdown" | "plain" | undefined;
194
- } | {
195
- type: "custom";
196
- raw: unknown;
197
- } | {
198
- type: "contact";
199
- user?: {
200
- __platform: string;
201
- id: string;
202
- } | undefined;
203
- name?: {
204
- formatted?: string | undefined;
205
- first?: string | undefined;
206
- last?: string | undefined;
207
- middle?: string | undefined;
208
- prefix?: string | undefined;
209
- suffix?: string | undefined;
210
- } | undefined;
211
- phones?: {
212
- value: string;
213
- type?: "mobile" | "home" | "work" | "other" | undefined;
214
- }[] | undefined;
215
- emails?: {
216
- value: string;
217
- type?: "home" | "work" | "other" | undefined;
218
- }[] | undefined;
219
- addresses?: {
220
- street?: string | undefined;
221
- city?: string | undefined;
222
- region?: string | undefined;
223
- postalCode?: string | undefined;
224
- country?: string | undefined;
225
- type?: "home" | "work" | "other" | undefined;
226
- }[] | undefined;
227
- org?: {
228
- name?: string | undefined;
229
- title?: string | undefined;
230
- department?: string | undefined;
231
- } | undefined;
232
- urls?: string[] | undefined;
233
- birthday?: string | undefined;
234
- note?: string | undefined;
235
- photo?: {
236
- mimeType: string;
237
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
238
- } | undefined;
239
- raw?: unknown;
240
- } | {
241
- type: "voice";
242
- mimeType: string;
243
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
244
- stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
245
- name?: string | undefined;
246
- duration?: number | undefined;
247
- size?: number | undefined;
248
- } | {
249
- type: "richlink";
250
- url: string;
251
- title: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
252
- summary: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
253
- cover: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodObject<{
254
- mimeType: z__default.ZodOptional<z__default.ZodString>;
255
- read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
256
- stream: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
257
- }, z__default.core.$strip>>>>;
258
- } | {
259
- type: "reaction";
260
- emoji: string;
261
- target: Message<string, User, Space<unknown>>;
262
- } | {
263
- type: "group";
264
- items: Message<string, User, Space<unknown>>[];
265
- } | {
266
- type: "poll";
267
- title: string;
268
- options: {
269
- title: string;
270
- }[];
271
- } | {
272
- type: "poll_option";
273
- option: {
274
- title: string;
275
- };
276
- poll: {
277
- type: "poll";
278
- title: string;
279
- options: {
280
- title: string;
281
- }[];
282
- };
283
- selected: boolean;
284
- title: string;
285
- } | {
286
- type: "effect";
287
- content: {
288
- type: "text";
289
- text: string;
290
- } | {
291
- type: "markdown";
292
- markdown: string;
293
- } | {
294
- type: "attachment";
295
- id: string;
296
- name: string;
297
- mimeType: string;
298
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
299
- stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
300
- size?: number | undefined;
301
- };
302
- effect: string;
303
- } | {
304
- type: "typing";
305
- state: "start" | "stop";
306
- } | {
307
- type: "rename";
308
- displayName: string;
309
- }, {
310
- type: "avatar";
311
- action: {
312
- kind: "set";
313
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
314
- mimeType: string;
315
- } | {
316
- kind: "clear";
317
- };
318
- } | {
319
- type: "text";
320
- text: string;
321
- } | {
322
- type: "markdown";
323
- markdown: string;
324
- } | {
325
- type: "attachment";
326
- id: string;
327
- name: string;
328
- mimeType: string;
329
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
330
- stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
331
- size?: number | undefined;
332
- } | {
333
- type: "streamText";
334
- stream: () => AsyncIterable<string>;
335
- format?: "markdown" | "plain" | undefined;
336
- } | {
337
- type: "custom";
338
- raw: unknown;
339
- } | {
340
- type: "contact";
341
- user?: {
342
- __platform: string;
343
- id: string;
344
- } | undefined;
345
- name?: {
346
- formatted?: string | undefined;
347
- first?: string | undefined;
348
- last?: string | undefined;
349
- middle?: string | undefined;
350
- prefix?: string | undefined;
351
- suffix?: string | undefined;
352
- } | undefined;
353
- phones?: {
354
- value: string;
355
- type?: "mobile" | "home" | "work" | "other" | undefined;
356
- }[] | undefined;
357
- emails?: {
358
- value: string;
359
- type?: "home" | "work" | "other" | undefined;
360
- }[] | undefined;
361
- addresses?: {
362
- street?: string | undefined;
363
- city?: string | undefined;
364
- region?: string | undefined;
365
- postalCode?: string | undefined;
366
- country?: string | undefined;
367
- type?: "home" | "work" | "other" | undefined;
368
- }[] | undefined;
369
- org?: {
370
- name?: string | undefined;
371
- title?: string | undefined;
372
- department?: string | undefined;
373
- } | undefined;
374
- urls?: string[] | undefined;
375
- birthday?: string | undefined;
376
- note?: string | undefined;
377
- photo?: {
378
- mimeType: string;
379
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
380
- } | undefined;
381
- raw?: unknown;
382
- } | {
383
- type: "voice";
384
- mimeType: string;
385
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
386
- stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
387
- name?: string | undefined;
388
- duration?: number | undefined;
389
- size?: number | undefined;
390
- } | {
391
- type: "richlink";
392
- url: string;
393
- title: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
394
- summary: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
395
- cover: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodObject<{
396
- mimeType: z__default.ZodOptional<z__default.ZodString>;
397
- read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
398
- stream: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
399
- }, z__default.core.$strip>>>>;
400
- } | {
401
- type: "reaction";
402
- emoji: string;
403
- target: Message<string, User, Space<unknown>>;
404
- } | {
405
- type: "group";
406
- items: Message<string, User, Space<unknown>>[];
407
- } | {
408
- type: "poll";
409
- title: string;
410
- options: {
411
- title: string;
412
- }[];
413
- } | {
414
- type: "poll_option";
415
- option: {
416
- title: string;
417
- };
418
- poll: {
419
- type: "poll";
420
- title: string;
421
- options: {
422
- title: string;
423
- }[];
424
- };
425
- selected: boolean;
426
- title: string;
427
- } | {
428
- type: "effect";
429
- content: {
430
- type: "text";
431
- text: string;
432
- } | {
433
- type: "markdown";
434
- markdown: string;
435
- } | {
436
- type: "attachment";
437
- id: string;
438
- name: string;
439
- mimeType: string;
440
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
441
- stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
442
- size?: number | undefined;
443
- };
444
- effect: string;
445
- } | {
446
- type: "typing";
447
- state: "start" | "stop";
448
- } | {
449
- type: "rename";
450
- displayName: string;
451
- }>;
452
- target: z__default.ZodCustom<Message<string, User, Space<unknown>>, Message<string, User, Space<unknown>>>;
453
- }, z__default.core.$strip>, z__default.ZodObject<{
454
- type: z__default.ZodLiteral<"edit">;
455
- content: z__default.ZodCustom<{
456
- type: "avatar";
457
- action: {
458
- kind: "set";
459
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
460
- mimeType: string;
461
- } | {
462
- kind: "clear";
463
- };
464
- } | {
465
- type: "text";
466
- text: string;
467
- } | {
468
- type: "markdown";
469
- markdown: string;
470
- } | {
471
- type: "attachment";
472
- id: string;
473
- name: string;
474
- mimeType: string;
475
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
476
- stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
477
- size?: number | undefined;
478
- } | {
479
- type: "streamText";
480
- stream: () => AsyncIterable<string>;
481
- format?: "markdown" | "plain" | undefined;
482
- } | {
483
- type: "custom";
484
- raw: unknown;
485
- } | {
486
- type: "contact";
487
- user?: {
488
- __platform: string;
489
- id: string;
490
- } | undefined;
491
- name?: {
492
- formatted?: string | undefined;
493
- first?: string | undefined;
494
- last?: string | undefined;
495
- middle?: string | undefined;
496
- prefix?: string | undefined;
497
- suffix?: string | undefined;
498
- } | undefined;
499
- phones?: {
500
- value: string;
501
- type?: "mobile" | "home" | "work" | "other" | undefined;
502
- }[] | undefined;
503
- emails?: {
504
- value: string;
505
- type?: "home" | "work" | "other" | undefined;
506
- }[] | undefined;
507
- addresses?: {
508
- street?: string | undefined;
509
- city?: string | undefined;
510
- region?: string | undefined;
511
- postalCode?: string | undefined;
512
- country?: string | undefined;
513
- type?: "home" | "work" | "other" | undefined;
514
- }[] | undefined;
515
- org?: {
516
- name?: string | undefined;
517
- title?: string | undefined;
518
- department?: string | undefined;
519
- } | undefined;
520
- urls?: string[] | undefined;
521
- birthday?: string | undefined;
522
- note?: string | undefined;
523
- photo?: {
524
- mimeType: string;
525
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
526
- } | undefined;
527
- raw?: unknown;
528
- } | {
529
- type: "voice";
530
- mimeType: string;
531
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
532
- stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
533
- name?: string | undefined;
534
- duration?: number | undefined;
535
- size?: number | undefined;
536
- } | {
537
- type: "richlink";
538
- url: string;
539
- title: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
540
- summary: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
541
- cover: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodObject<{
542
- mimeType: z__default.ZodOptional<z__default.ZodString>;
543
- read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
544
- stream: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
545
- }, z__default.core.$strip>>>>;
546
- } | {
547
- type: "reaction";
548
- emoji: string;
549
- target: Message<string, User, Space<unknown>>;
550
- } | {
551
- type: "group";
552
- items: Message<string, User, Space<unknown>>[];
553
- } | {
554
- type: "poll";
555
- title: string;
556
- options: {
557
- title: string;
558
- }[];
559
- } | {
560
- type: "poll_option";
561
- option: {
562
- title: string;
563
- };
564
- poll: {
565
- type: "poll";
566
- title: string;
567
- options: {
568
- title: string;
569
- }[];
570
- };
571
- selected: boolean;
572
- title: string;
573
- } | {
574
- type: "effect";
575
- content: {
576
- type: "text";
577
- text: string;
578
- } | {
579
- type: "markdown";
580
- markdown: string;
581
- } | {
582
- type: "attachment";
583
- id: string;
584
- name: string;
585
- mimeType: string;
586
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
587
- stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
588
- size?: number | undefined;
589
- };
590
- effect: string;
591
- } | {
592
- type: "typing";
593
- state: "start" | "stop";
594
- } | {
595
- type: "rename";
596
- displayName: string;
597
- }, {
598
- type: "avatar";
599
- action: {
600
- kind: "set";
601
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
602
- mimeType: string;
603
- } | {
604
- kind: "clear";
605
- };
606
- } | {
607
- type: "text";
608
- text: string;
609
- } | {
610
- type: "markdown";
611
- markdown: string;
612
- } | {
613
- type: "attachment";
614
- id: string;
615
- name: string;
616
- mimeType: string;
617
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
618
- stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
619
- size?: number | undefined;
620
- } | {
621
- type: "streamText";
622
- stream: () => AsyncIterable<string>;
623
- format?: "markdown" | "plain" | undefined;
624
- } | {
625
- type: "custom";
626
- raw: unknown;
627
- } | {
628
- type: "contact";
629
- user?: {
630
- __platform: string;
631
- id: string;
632
- } | undefined;
633
- name?: {
634
- formatted?: string | undefined;
635
- first?: string | undefined;
636
- last?: string | undefined;
637
- middle?: string | undefined;
638
- prefix?: string | undefined;
639
- suffix?: string | undefined;
640
- } | undefined;
641
- phones?: {
642
- value: string;
643
- type?: "mobile" | "home" | "work" | "other" | undefined;
644
- }[] | undefined;
645
- emails?: {
646
- value: string;
647
- type?: "home" | "work" | "other" | undefined;
648
- }[] | undefined;
649
- addresses?: {
650
- street?: string | undefined;
651
- city?: string | undefined;
652
- region?: string | undefined;
653
- postalCode?: string | undefined;
654
- country?: string | undefined;
655
- type?: "home" | "work" | "other" | undefined;
656
- }[] | undefined;
657
- org?: {
658
- name?: string | undefined;
659
- title?: string | undefined;
660
- department?: string | undefined;
661
- } | undefined;
662
- urls?: string[] | undefined;
663
- birthday?: string | undefined;
664
- note?: string | undefined;
665
- photo?: {
666
- mimeType: string;
667
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
668
- } | undefined;
669
- raw?: unknown;
670
- } | {
671
- type: "voice";
672
- mimeType: string;
673
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
674
- stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
675
- name?: string | undefined;
676
- duration?: number | undefined;
677
- size?: number | undefined;
678
- } | {
679
- type: "richlink";
680
- url: string;
681
- title: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
682
- summary: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodString>>>;
683
- cover: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodOptional<z__default.ZodObject<{
684
- mimeType: z__default.ZodOptional<z__default.ZodString>;
685
- read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
686
- stream: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
687
- }, z__default.core.$strip>>>>;
688
- } | {
689
- type: "reaction";
690
- emoji: string;
691
- target: Message<string, User, Space<unknown>>;
692
- } | {
693
- type: "group";
694
- items: Message<string, User, Space<unknown>>[];
695
- } | {
696
- type: "poll";
697
- title: string;
698
- options: {
699
- title: string;
700
- }[];
701
- } | {
702
- type: "poll_option";
703
- option: {
704
- title: string;
705
- };
706
- poll: {
707
- type: "poll";
708
- title: string;
709
- options: {
710
- title: string;
711
- }[];
712
- };
713
- selected: boolean;
714
- title: string;
715
- } | {
716
- type: "effect";
717
- content: {
718
- type: "text";
719
- text: string;
720
- } | {
721
- type: "markdown";
722
- markdown: string;
723
- } | {
724
- type: "attachment";
725
- id: string;
726
- name: string;
727
- mimeType: string;
728
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
729
- stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
730
- size?: number | undefined;
731
- };
732
- effect: string;
733
- } | {
734
- type: "typing";
735
- state: "start" | "stop";
736
- } | {
737
- type: "rename";
738
- displayName: string;
739
- }>;
740
- target: z__default.ZodCustom<Message<string, User, Space<unknown>>, Message<string, User, Space<unknown>>>;
741
- }, z__default.core.$strip>, z__default.ZodObject<{
742
- type: z__default.ZodLiteral<"unsend">;
743
- target: z__default.ZodCustom<Message<string, User, Space<unknown>>, Message<string, User, Space<unknown>>>;
744
- }, z__default.core.$strip>, z__default.ZodObject<{
745
- type: z__default.ZodLiteral<"read">;
746
- target: z__default.ZodCustom<Message<string, User, Space<unknown>>, Message<string, User, Space<unknown>>>;
747
- }, z__default.core.$strip>], "type">;
748
- type Content = z__default.infer<typeof contentSchema>;
749
- interface ContentBuilder {
750
- build(): Promise<Content>;
751
- }
752
- type ContentInput = string | ContentBuilder;
753
-
754
- interface User {
755
- readonly __platform: string;
756
- readonly id: string;
757
- readonly kind?: "agent";
758
- }
759
- interface AgentSender extends User {
760
- readonly kind: "agent";
761
- }
762
-
763
- /**
764
- * A `ContentBuilder` whose build is statically known to produce `Reaction`
765
- * content. `space.send` overloads on this so `space.send(reaction(...))`
766
- * returns a Message with `content` narrowed to `Reaction`, matching
767
- * `message.react()`.
768
- */
769
- interface ReactionBuilder extends ContentBuilder {
770
- build(): Promise<Reaction>;
771
- }
772
- declare const reactionSchema: z__default.ZodObject<{
773
- type: z__default.ZodLiteral<"reaction">;
774
- emoji: z__default.ZodString;
775
- target: z__default.ZodCustom<Message<string, User, Space<unknown>>, Message<string, User, Space<unknown>>>;
776
- }, z__default.core.$strip>;
777
- type Reaction = z__default.infer<typeof reactionSchema>;
778
- declare const asReaction: (input: {
779
- emoji: string;
780
- target: Message;
781
- }) => Reaction;
782
- /**
783
- * Construct a `reaction` content value targeting the given message.
784
- *
785
- * `space.send(reaction(emoji, message))` is the canonical form of
786
- * `message.react(emoji)`. It resolves to the reaction `Message`
787
- * (`content.type === "reaction"`) — keep it as the handle to `unsend()`
788
- * later. Resolves `undefined` only when the platform does not support
789
- * reactions (warned and skipped).
790
- *
791
- * Accepts `Message | undefined` so `space.send` results chain without
792
- * narrowing (`send` resolves `undefined` when a platform skips unsupported
793
- * content); an undefined target throws at build time.
794
- *
795
- * To react to a message known only by id, resolve it first via
796
- * `space.getMessage(id)`.
797
- */
798
- declare function reaction(emoji: string, target: Message | undefined): ReactionBuilder;
799
-
800
- interface Space<_Def = unknown> {
801
- readonly __platform: string;
802
- /**
803
- * Set or clear the current chat's avatar (group icon). Sugar for
804
- * `send(avatar(input, options?))`.
805
- *
806
- * - `space.avatar("clear")` — remove the current avatar.
807
- * - `space.avatar("./icon.png")` — set from a filesystem path; MIME type
808
- * is inferred from the extension.
809
- * - `space.avatar(new URL("https://…/icon.png"))` — fetch the avatar
810
- * lazily over the network. Bytes stay in memory (safe in read-only
811
- * environments); MIME type is inferred from the URL pathname extension.
812
- * - `space.avatar(buffer, { mimeType })` — set from in-memory bytes;
813
- * `mimeType` is required (enforced at the type level).
814
- *
815
- * Universal API; per-platform constraints (e.g. iMessage: remote + group
816
- * only) surface as `UnsupportedError` from the provider's send action.
817
- */
818
- avatar(input: string | URL, options?: {
819
- mimeType?: string;
820
- }): Promise<void>;
821
- avatar(input: Buffer, options: {
822
- mimeType: string;
823
- }): Promise<void>;
824
- /**
825
- * Rewrite a previously-sent outbound message. Sugar for
826
- * `send(edit(newContent, message))`. Accepts `Message | undefined` so
827
- * `send` results chain without narrowing; an undefined target throws.
828
- */
829
- edit(message: Message | undefined, newContent: ContentInput): Promise<void>;
830
- /**
831
- * Look up a message in this space by its id. Returns `undefined` if the
832
- * platform has no way to resolve the id (e.g. cache miss with no by-id
833
- * SDK fallback). Used to materialize a `Message` for APIs that require one,
834
- * such as `reaction()`.
835
- */
836
- getMessage(id: string): Promise<Message | undefined>;
837
- readonly id: string;
838
- /**
839
- * Mark the conversation as read up to `message`, surfacing a read receipt
840
- * to the sender where the platform supports one. Sugar for
841
- * `send(read(message))`. Fire-and-forget; only inbound messages can be
842
- * marked read.
843
- *
844
- * Granularity is per-platform: WhatsApp Business issues a receipt for
845
- * `message` and everything before it; iMessage (remote) marks the whole
846
- * chat read. Platforms with no read-receipt concept for bot conversations
847
- * (Telegram, Slack) silently no-op, so the signal is best-effort
848
- * everywhere — same contract as `startTyping()`.
849
- */
850
- read(message: Message): Promise<void>;
851
- /**
852
- * Rename the current chat. Sugar for `send(rename(displayName))`.
853
- *
854
- * Universal API; per-platform constraints (e.g. iMessage: remote + group
855
- * only) surface as `UnsupportedError` from the provider's send action.
856
- */
857
- rename(displayName: string): Promise<void>;
858
- responding<T>(fn: () => T | Promise<T>): Promise<T>;
859
- /**
860
- * A reaction send resolves to the reaction Message (`content` narrowed to
861
- * `Reaction`) — the handle to `unsend()` later. Listed before the general
862
- * overload so `send(reaction(...))` picks it; every other `ContentBuilder`
863
- * fails the `ReactionBuilder` shape and falls through.
864
- */
865
- send(content: ReactionBuilder): Promise<(Message<string, AgentSender> & {
866
- content: Reaction;
867
- }) | undefined>;
868
- send(content: ContentInput): Promise<Message<string, AgentSender> | undefined>;
869
- send(...content: [ContentInput, ContentInput, ...ContentInput[]]): Promise<Message<string, AgentSender>[]>;
870
- startTyping(): Promise<void>;
871
- stopTyping(): Promise<void>;
872
- /**
873
- * Retract a previously-sent outbound message. Sugar for
874
- * `send(unsend(message))`. Accepts `Message | undefined` so `send`
875
- * results chain without narrowing; an undefined target throws.
876
- */
877
- unsend(message: Message | undefined): Promise<void>;
878
- }
879
-
880
- interface Message<TPlatform extends string = string, TSender extends User = User, TSpace extends Space = Space> {
881
- content: Content;
882
- direction: "inbound" | "outbound";
883
- edit(newContent: ContentInput): Promise<void>;
884
- readonly id: string;
885
- platform: TPlatform;
886
- /**
887
- * React to this message. Resolves to the reaction `Message` (content
888
- * narrowed to `Reaction`) — keep it as the handle to `unsend()` later.
889
- * Resolves `undefined` when the platform does not support reactions
890
- * (warned and skipped).
891
- *
892
- * The return type is an inline intersection rather than a `TContent`
893
- * generic on `Message`: a content type parameter would need `Content` as
894
- * its default, and `Content`'s schemas (`reaction`, `reply`, `edit`,
895
- * `group`) reference `Message` — TS rejects the resulting circular
896
- * default (TS2716).
897
- */
898
- react(reaction: string): Promise<(Message<TPlatform, AgentSender, TSpace> & {
899
- content: Reaction;
900
- }) | undefined>;
901
- /**
902
- * Mark this message (and everything before it in the conversation) as
903
- * read. Sugar for `space.send(read(this))`. Reads are fire-and-forget;
904
- * per-platform granularity and support (e.g. iMessage marks the whole
905
- * chat; Telegram/Slack silently no-op) surface from the provider's send
906
- * action. Only inbound messages can be marked read; calling this on an
907
- * outbound message throws.
908
- */
909
- read(): Promise<void>;
910
- reply(content: ContentInput): Promise<Message<TPlatform, AgentSender, TSpace> | undefined>;
911
- reply(...content: [ContentInput, ContentInput, ...ContentInput[]]): Promise<Message<TPlatform, AgentSender, TSpace>[]>;
912
- sender: TSender | undefined;
913
- space: TSpace;
914
- timestamp: Date;
915
- /**
916
- * Retract this message. Sugar for `space.send(unsend(this))`. Unsends are
917
- * fire-and-forget; per-platform support and constraints (e.g. iMessage's
918
- * ~2-minute unsend window for regular messages) surface from the
919
- * provider's send action. Only outbound messages can be unsent; calling
920
- * this on an inbound message throws.
921
- */
922
- unsend(): Promise<void>;
923
- }
924
-
925
- type SubscriptionStatus = "active" | "canceled" | "past_due";
926
- interface SubscriptionData {
927
- status: SubscriptionStatus | null;
928
- tier: string;
929
- }
930
- interface SharedTokenData {
931
- expiresIn: number;
932
- token: string;
933
- type: "shared";
934
- }
935
- interface DedicatedTokenData {
936
- auth: Record<string, string>;
937
- expiresIn: number;
938
- numbers: Record<string, string | null>;
939
- type: "dedicated";
940
- }
941
- type TokenData = SharedTokenData | DedicatedTokenData;
942
- type CloudPlatform = "imessage" | "whatsapp_business" | "slack";
943
- interface PlatformStatus {
944
- enabled: boolean;
945
- }
946
- type PlatformsData = Record<CloudPlatform, PlatformStatus>;
947
- interface ImessageInfoData {
948
- type: "shared" | "dedicated";
949
- }
950
- interface WhatsappBusinessTokenData {
951
- auth: Record<string, string>;
952
- expiresIn: number;
953
- numbers: Record<string, string | null>;
954
- }
955
- interface SlackTeamMeta {
956
- appId: string;
957
- botUserId: string;
958
- grantedScopes: string[];
959
- teamName: string;
960
- }
961
- interface SlackTokenData {
962
- auth: Record<string, string>;
963
- expiresIn: number;
964
- teams: Record<string, SlackTeamMeta>;
965
- }
966
- interface FusorTokenData {
967
- expiresIn: number;
968
- token: string;
969
- }
970
- /**
971
- * Per-project profile bag — a flexible record of project-level settings
972
- * defined in Spectrum Cloud. Concrete fields depend on the project; consumers
973
- * read them as `app.config.profile.<key>`.
974
- */
975
- interface ProjectProfile {
976
- [key: string]: unknown;
977
- }
978
- /**
979
- * The project record returned by `GET /projects/{projectId}/`. Populated on
980
- * `app.config` when `Spectrum()` is called with `projectId` + `projectSecret`.
981
- */
982
- interface ProjectData {
983
- id: string;
984
- name: string;
985
- profile: ProjectProfile;
986
- /**
987
- * URL-safe project identifier (e.g. `what-c62a6`). Used as the subdomain of
988
- * the Fusor "super webhook" edge a platform registers its provider webhook
989
- * against — see Telegram's `webhookUrl`.
990
- */
991
- slug: string;
992
- }
993
- declare class SpectrumCloudError extends Error {
994
- readonly status: number;
995
- readonly code: string;
996
- constructor(status: number, code: string, message: string);
997
- }
998
- declare const cloud: {
999
- getProject: (projectId: string, projectSecret: string) => Promise<ProjectData>;
1000
- getSubscription: (projectId: string) => Promise<SubscriptionData>;
1001
- issueImessageTokens: (projectId: string, projectSecret: string) => Promise<TokenData>;
1002
- getImessageInfo: (projectId: string) => Promise<ImessageInfoData>;
1003
- issueWhatsappBusinessTokens: (projectId: string, projectSecret: string) => Promise<WhatsappBusinessTokenData>;
1004
- issueSlackTokens: (projectId: string, projectSecret: string) => Promise<SlackTokenData>;
1005
- issueFusorToken: (projectId: string, projectSecret: string) => Promise<FusorTokenData>;
1006
- getPlatforms: (projectId: string) => Promise<PlatformsData>;
1007
- togglePlatform: (projectId: string, projectSecret: string, platform: CloudPlatform, enabled: boolean) => Promise<PlatformsData>;
1008
- };
1009
-
1010
- /**
1011
- * A small per-platform key-value bag, modeled after Swift's `UserDefaults`.
1012
- * Untyped writes; typed reads return `undefined` on missing key OR type
1013
- * mismatch (no throws). In-memory only.
1014
- *
1015
- * SDK-internal: reachable from inside `definePlatform` callbacks via the
1016
- * `store` field on lifecycle/action/event ctx. Not exposed on the public
1017
- * SpectrumInstance or platform narrower.
1018
- */
1019
- interface Store {
1020
- array<T = unknown>(key: string): T[] | undefined;
1021
- bool(key: string): boolean | undefined;
1022
- clear(): void;
1023
- delete(key: string): boolean;
1024
- get(key: string): unknown;
1025
- has(key: string): boolean;
1026
- keys(): string[];
1027
- number(key: string): number | undefined;
1028
- object<T = Record<string, unknown>>(key: string): T | undefined;
1029
- set(key: string, value: unknown): void;
1030
- string(key: string): string | undefined;
1031
- }
1032
-
1033
- interface ManagedStream<T> extends AsyncIterable<T> {
1034
- close(): Promise<void>;
1035
- }
1036
- type StreamCleanup = void | (() => void | Promise<void>);
1037
- declare function stream<T>(setup: (emit: (value: T) => Promise<void>, end: (error?: unknown) => void) => StreamCleanup | Promise<StreamCleanup>): ManagedStream<T>;
1038
- declare function mergeStreams<T>(streams: readonly ManagedStream<T>[]): ManagedStream<T>;
1039
- interface Broadcaster<T> {
1040
- close(): Promise<void>;
1041
- subscribe(): ManagedStream<T>;
1042
- }
1043
- declare function broadcast<T>(source: ManagedStream<T>): Broadcaster<T>;
1044
-
1045
- /**
1046
- * A platform-defined method on `Space`. The first parameter is bound to the
1047
- * built `Space` at construction time, so callers only pass the trailing args.
1048
- * Actions are plain functions returning `Promise<void>` — they can delegate
1049
- * through `space.send(...)`, call the underlying SDK, or perform any other
1050
- * side effect.
1051
- *
1052
- * Names that collide with reserved `Space` keys (`send`, `edit`, `unsend`,
1053
- * `getMessage`, `startTyping`, `stopTyping`, `responding`, `id`,
1054
- * `__platform`) are skipped at runtime with a warning and excluded at the
1055
- * type level via `Exclude<…, keyof Space>`.
1056
- */
1057
- type SpaceActionFn = (space: Space, ...args: never[]) => Promise<void>;
1058
- /**
1059
- * A platform-defined method on `Message`. The first parameter is bound to
1060
- * the message itself (`self`) at build time, so callers only pass the
1061
- * trailing args. Actions are plain functions returning `Promise<void>` —
1062
- * they can delegate through `message.space.send(...)`, call the underlying
1063
- * SDK, or perform any other side effect.
1064
- *
1065
- * Names that collide with reserved `Message` keys (`react`, `reply`, `edit`,
1066
- * `unsend`, `id`, `space`, `sender`, `content`, `platform`, `direction`,
1067
- * `timestamp`) are skipped at runtime with a warning and excluded at the
1068
- * type level via `Exclude<…, keyof Message>`.
1069
- */
1070
- type MessageActionFn = (message: Message, ...args: never[]) => Promise<void>;
1071
- /**
1072
- * A platform-defined method projected onto the value returned by
1073
- * `provider(spectrum)` (e.g. `imessage(spectrum).getAttachment(guid)`). The
1074
- * first parameter is an injected runtime context (`{ client, config, store }`);
1075
- * `createPlatformInstance` supplies it so callers only pass the trailing args.
1076
- *
1077
- * Unlike `SpaceActionFn` / `MessageActionFn` (which always return
1078
- * `Promise<void>` because they dispatch through `send`), instance actions
1079
- * return arbitrary data — the public signature preserves the declared return
1080
- * type via `InstanceActionMethods<Def>`.
1081
- *
1082
- * Two tiers live in the same `actions?` slot:
1083
- *
1084
- * - **Platform-wise actions** — fixed framework-known names (currently just
1085
- * `getMessage`) whose signatures are defined by `PlatformWiseActions`. They
1086
- * power universal sugar (`space.getMessage(id)`) AND surface on the
1087
- * platform instance. If a provider omits one, the framework wires a
1088
- * default that throws `UnsupportedError`.
1089
- * - **Platform-specific actions** — free-form keys each platform declares
1090
- * for its own ergonomics (e.g. iMessage's `getAttachment`). Surface on
1091
- * the platform instance only.
1092
- *
1093
- * Names that collide with reserved instance keys (`user`, `space`, `messages`,
1094
- * plus any declared `events` key) are skipped at runtime with a warning and
1095
- * excluded at the type level.
1096
- */
1097
- type InstanceActionFn = (ctx: any, ...args: any[]) => Promise<unknown>;
1098
- /**
1099
- * Framework-known action names that every platform implicitly has.
1100
- *
1101
- * Each entry's signature lives here; the framework wires the corresponding
1102
- * method onto the `PlatformInstance` for every platform — providers override
1103
- * by declaring the key inside their `actions` slot, and platforms that omit
1104
- * the key get a default that throws `UnsupportedError`.
1105
- *
1106
- * Add a new platform-wise capability by extending this record (and the
1107
- * runtime list in `define.ts`); the corresponding instance method will be
1108
- * surfaced on every `PlatformInstance` automatically.
1109
- */
1110
- interface PlatformWiseActions<_ResolvedSpace extends {
1111
- id: string;
1112
- }, _MessageType, _Client, _Config> {
1113
- getMessage: (ctx: {
1114
- client: _Client;
1115
- config: _Config;
1116
- store: Store;
1117
- }, space: _ResolvedSpace & {
1118
- id: string;
1119
- __platform: string;
1120
- }, messageId: string) => Promise<_MessageType | undefined>;
1121
- }
1122
- type PlatformWiseActionKey = keyof PlatformWiseActions<{
1123
- id: string;
1124
- }, unknown, unknown, unknown>;
1125
- type ResolvedSpace = Pick<Space, "id">;
1126
- type SpaceRef = Pick<Space, "id" | "__platform">;
1127
- type ResolvedUser = Pick<User, "id">;
1128
- type AwaitedReturn<T> = T extends (...args: never[]) => infer R ? Awaited<R> : never;
1129
- type NoInferClient<T> = [T][T extends unknown ? 0 : never];
1130
- type SchemaInfer<T> = T extends {
1131
- schema?: infer S extends z__default.ZodType<object>;
1132
- } ? z__default.infer<S> : Record<never, never>;
1133
- type InferSchema<TSchema> = TSchema extends z__default.ZodType<object> ? z__default.infer<TSchema> : Record<never, never>;
1134
- type InferOptionalSchema<TSchema> = TSchema extends z__default.ZodType<object> ? z__default.infer<TSchema> : never;
1135
- type InputSchema<TSchema> = TSchema extends z__default.ZodType<object> ? z__default.input<TSchema> : never;
1136
- type EventProducer<TPayload = unknown, TClient = unknown, TConfig = unknown> = (ctx: {
1137
- client: NoInferClient<TClient>;
1138
- config: TConfig;
1139
- /**
1140
- * Spectrum Cloud project metadata, fetched once at `Spectrum()` init.
1141
- * `undefined` when the instance was created without `projectId`/`projectSecret`
1142
- * (local-only setups). Providers read project-level toggles from
1143
- * `projectConfig.profile.<key>` — e.g. iMessage's `imessageSynced` flag.
1144
- */
1145
- projectConfig: ProjectData | undefined;
1146
- store: Store;
1147
- }) => AsyncIterable<TPayload>;
1148
- type ProviderMessage<TSender extends ResolvedUser = ResolvedUser, TSpace extends ResolvedSpace = ResolvedSpace, TExtra extends object = Record<never, never>> = {
1149
- id: string;
1150
- content: Content;
1151
- sender: TSender;
1152
- space: TSpace;
1153
- timestamp?: Date;
1154
- } & TExtra;
1155
- /**
1156
- * A message a provider produced — used for both inbound (`messages`,
1157
- * `actions.getMessage`) and outbound (`send`) flows. Providers return their native
1158
- * record shape (including platform extras like `partIndex`/`parentId` for
1159
- * iMessage) and the platform `wrapProviderMessage` pipeline turns it into a
1160
- * fully-built Message.
1161
- *
1162
- * `sender` is optional because outbound sends often can't synthesize one
1163
- * (the SDK doesn't surface the bot's own handle); inbound providers are
1164
- * expected to populate it.
1165
- */
1166
- type ProviderMessageRecord = {
1167
- id: string;
1168
- content: Content;
1169
- direction?: "inbound" | "outbound";
1170
- sender?: {
1171
- id: string;
1172
- } & Record<string, unknown>;
1173
- space: {
1174
- id: string;
1175
- } & Record<string, unknown>;
1176
- timestamp?: Date;
1177
- } & Record<string, unknown>;
1178
- type MergeSchema<TSchema extends z__default.ZodType | undefined, TBase extends object> = TSchema extends z__default.ZodType ? string extends keyof z__default.infer<TSchema> ? TBase : Omit<z__default.infer<TSchema>, keyof TBase> & TBase : TBase;
1179
- type SchemaMessage<TUserSchema extends z__default.ZodType | undefined = undefined, TSpaceSchema extends z__default.ZodType | undefined = undefined> = ProviderMessage<MergeSchema<TUserSchema, ResolvedUser>, MergeSchema<TSpaceSchema, ResolvedSpace>>;
1180
- type InferEventPayload<T> = T extends z__default.ZodType ? z__default.infer<T> : T extends (ctx: never) => AsyncIterable<infer P> ? P : never;
1181
- type ReservedNames = "stop" | "send" | "config" | "__internal" | "__providers";
1182
- interface CreateClientContext<_ConfigSchema extends z__default.ZodType<object>> {
1183
- config: z__default.infer<_ConfigSchema>;
1184
- /**
1185
- * The resolved cloud project record (slug, profile, …) when `Spectrum()` runs
1186
- * with `projectId` + `projectSecret`; `undefined` in local/direct mode. Lets
1187
- * `createClient` self-register provider webhooks against the Fusor edge keyed
1188
- * by `projectConfig.slug` — see Telegram.
1189
- */
1190
- projectConfig: ProjectData | undefined;
1191
- projectId: string | undefined;
1192
- projectSecret: string | undefined;
1193
- store: Store;
1194
- }
1195
- /**
1196
- * The full definition of a platform adapter.
1197
- *
1198
- * Spectrum's platform API is shaped around the universal messaging contract:
1199
- * **`messages` (inbound stream) + `send` (outbound dispatcher)**. Together
1200
- * they handle 99% of what any platform integration needs to do — every
1201
- * higher-level affordance (`message.reply`, `message.react`, `space.edit`,
1202
- * `space.startTyping`, etc.) is sugar that routes through `send`.
1203
- *
1204
- * Everything beyond those two is optional: `getMessage` is a known capability
1205
- * that lives inside `actions?`; platform-specific event streams live inside
1206
- * `events?` and surface as flat properties on the platform instance.
1207
- *
1208
- * Minimum viable platform integration:
1209
- * `name`, `config`, `lifecycle`, `user`, `space`, `messages`, `send`.
1210
- */
1211
- interface PlatformDef<_Name extends string = string, _ConfigSchema extends z__default.ZodType<object> = z__default.ZodType<object>, _UserSchema extends z__default.ZodType<object> | undefined = undefined, _SpaceSchema extends z__default.ZodType<object> | undefined = undefined, _SpaceParamsSchema extends z__default.ZodType<object> | undefined = undefined, _Client = unknown, _ResolvedUser extends ResolvedUser = ResolvedUser, _ResolvedSpace extends ResolvedSpace = ResolvedSpace, _MessageSchema extends z__default.ZodType<object> | undefined = undefined, _MessageType extends ProviderMessage<_ResolvedUser, _ResolvedSpace, InferSchema<_MessageSchema>> = ProviderMessage<_ResolvedUser, _ResolvedSpace, InferSchema<_MessageSchema>>, _Events extends (Record<string, EventProducer<unknown, _Client, z__default.infer<_ConfigSchema>> | z__default.ZodType<object>> & {
1212
- messages?: never;
1213
- }) | undefined = undefined, _SpaceActions extends Record<string, SpaceActionFn> = Record<never, never>, _MessageActions extends Record<string, MessageActionFn> = Record<never, never>, _Actions extends Record<string, InstanceActionFn> = Record<never, never>> {
1214
- /**
1215
- * Provider-defined methods exposed on the platform instance.
1216
- *
1217
- * Two tiers share this slot:
1218
- *
1219
- * 1. **Platform-wise actions** (`getMessage`) — framework-recognized names
1220
- * declared in `PlatformWiseActions`. Override by declaring the key here
1221
- * with the matching signature. The framework injects `ctx = { client,
1222
- * config, store }` as the first arg and surfaces the method on the
1223
- * platform instance (`im.getMessage(space, id)`). If omitted, the
1224
- * framework wires a default that throws `UnsupportedError`. Powers
1225
- * universal sugar like `space.getMessage(id)`.
1226
- *
1227
- * 2. **Platform-specific actions** — free-form keys like `getAttachment`.
1228
- * Each gets `ctx = { client, config, store }` as the first arg; the
1229
- * public signature on `PlatformInstance<Def>` drops `ctx` and preserves
1230
- * the declared return type.
1231
- *
1232
- * Names that collide with reserved instance keys (`user`, `space`,
1233
- * `messages`, plus any declared `events` key) are skipped at runtime with
1234
- * a warning and excluded at the type level.
1235
- */
1236
- actions?: Partial<PlatformWiseActions<_ResolvedSpace, _MessageType, NoInferClient<_Client>, z__default.infer<_ConfigSchema>>> & _Actions;
1237
- config: _ConfigSchema;
1238
- /**
1239
- * Optional escape hatch: platform-specific event streams beyond the core
1240
- * `messages` stream (e.g. presence updates, read receipts). Each producer
1241
- * is surfaced as a flat property on both `spectrum` and the platform
1242
- * instance (e.g. `spectrum.presence`, `slack.readReceipt`).
1243
- *
1244
- * The key `messages` is reserved — the core inbound stream lives at the
1245
- * top level, not inside `events?`.
1246
- *
1247
- * 99% of integrations don't need this — `messages` + `send` is the
1248
- * universal contract.
1249
- */
1250
- events?: _Events;
1251
- lifecycle: {
1252
- createClient: (ctx: CreateClientContext<_ConfigSchema>) => Promise<_Client>;
1253
- destroyClient?: (ctx: {
1254
- client: NoInferClient<_Client>;
1255
- store: Store;
1256
- }) => Promise<void>;
1257
- };
1258
- message?: {
1259
- schema?: _MessageSchema;
1260
- /**
1261
- * Optional platform-specific sugar methods bound to `PlatformMessage<Def>`.
1262
- *
1263
- * Each entry is a `ContentBuilder` factory whose **first parameter** is
1264
- * the message itself (`self`); `buildMessage` injects a thin wrapper
1265
- * that supplies `self` and calls `space.send(factory(self, ...args))`.
1266
- * The wrapper is typed as `(...args) => Promise<void>` on
1267
- * `PlatformMessage<Def>` via `MessageActionMethods<Def>`.
1268
- *
1269
- * Mirrors `space.actions` — `space.actions` lives on the space slot for
1270
- * chat-level sugar (e.g. `space.background(...)`); `message.actions`
1271
- * lives here for per-message sugar that needs `self` (e.g.
1272
- * `message.read()`).
1273
- *
1274
- * Names that collide with reserved `Message` keys (`react`, `reply`,
1275
- * `edit`, `id`, `space`, `sender`, `content`, `platform`, `direction`,
1276
- * `timestamp`) are skipped at runtime with a warning and excluded at
1277
- * the type level.
1278
- */
1279
- actions?: _MessageActions;
1280
- };
1281
- /**
1282
- * Inbound message stream.
1283
- *
1284
- * - **Default mode**: returns an `AsyncIterable<ProviderMessageRecord>` —
1285
- * Spectrum wraps each emitted record into a fully-built `Message` and
1286
- * fans it out via `spectrum.messages`.
1287
- * - **Fusor mode**: when `lifecycle.createClient` returns a `FusorClient`
1288
- * (constructed via `fusor(platform, verify)`), the signature switches to a
1289
- * per-payload callback `(ctx: { payload, respond }) => …` whose return
1290
- * value is the message(s) to emit and whose optional `respond` call
1291
- * customises the HTTP reply sent back to fusor.
1292
- *
1293
- * One of the two universal platform contracts (along with `send`). 99% of
1294
- * integrations only need to implement `messages` + `send`.
1295
- */
1296
- messages: EventProducer<_MessageType, _Client, z__default.infer<_ConfigSchema>>;
1297
- name: _Name;
1298
- /**
1299
- * Send a piece of `Content` to a space. The provider inspects
1300
- * `content.type` and dispatches accordingly — text, attachments, reactions,
1301
- * replies, edits, typing indicators, and any other content type all flow
1302
- * through this single action.
1303
- *
1304
- * Returns a `ProviderMessageRecord` (id + timestamp) for content that
1305
- * produces a message — including reactions, whose record is the unsend
1306
- * handle (synthesize a deterministic id when the platform assigns none);
1307
- * returns `undefined` only for fire-and-forget control signals (typing,
1308
- * edits, renames, avatars, unsends) on platforms that don't return ids.
1309
- *
1310
- * One of the two universal platform contracts (along with `messages`).
1311
- */
1312
- send: (_: {
1313
- space: _ResolvedSpace & SpaceRef;
1314
- content: Content;
1315
- client: NoInferClient<_Client>;
1316
- config: z__default.infer<_ConfigSchema>;
1317
- store: Store;
1318
- }) => Promise<ProviderMessageRecord | undefined>;
1319
- space: {
1320
- schema?: _SpaceSchema;
1321
- params?: _SpaceParamsSchema;
1322
- create: (_: {
1323
- input: {
1324
- users: (_ResolvedUser & {
1325
- __platform: _Name;
1326
- })[];
1327
- params?: _SpaceParamsSchema extends z__default.ZodType<object> ? z__default.infer<_SpaceParamsSchema> : undefined;
1328
- };
1329
- client: NoInferClient<_Client>;
1330
- config: z__default.infer<_ConfigSchema>;
1331
- store: Store;
1332
- }) => Promise<_ResolvedSpace>;
1333
- /**
1334
- * Optional: hydrate a space from a known platform space id. When absent,
1335
- * the framework builds the candidate `{ id }` and validates it against
1336
- * `space.schema` — providers whose schema requires more fields must
1337
- * implement this.
1338
- */
1339
- get?: (_: {
1340
- input: {
1341
- id: string;
1342
- params?: _SpaceParamsSchema extends z__default.ZodType<object> ? z__default.infer<_SpaceParamsSchema> : undefined;
1343
- };
1344
- client: NoInferClient<_Client>;
1345
- config: z__default.infer<_ConfigSchema>;
1346
- store: Store;
1347
- }) => Promise<_ResolvedSpace>;
1348
- /**
1349
- * Optional platform-specific methods bound to `PlatformSpace<Def>`.
1350
- *
1351
- * Each entry is a plain async function `(space, ...args) => Promise<void>`;
1352
- * `buildSpace` injects the built `PlatformSpace<Def>` as the first
1353
- * argument and exposes the trailing args as the public surface. Action
1354
- * implementations choose how to dispatch — `space.send(...)`, a direct
1355
- * SDK call, or any other side effect — and always return `Promise<void>`
1356
- * to callers.
1357
- *
1358
- * Mirrors the top-level `PlatformDef.actions` slot — `actions` lives at
1359
- * the platform level for capabilities (e.g. `getMessage`); `space.actions`
1360
- * lives here for platform-specific surface area.
1361
- *
1362
- * Names that collide with reserved `Space` keys (`send`, `edit`,
1363
- * `unsend`, `getMessage`, `startTyping`, `stopTyping`, `responding`,
1364
- * `id`, `__platform`) are skipped at runtime with a warning and excluded
1365
- * at the type level.
1366
- */
1367
- actions?: _SpaceActions;
1368
- };
1369
- user: {
1370
- schema?: _UserSchema;
1371
- resolve: (_: {
1372
- input: {
1373
- userID: string;
1374
- };
1375
- client: NoInferClient<_Client>;
1376
- config: z__default.infer<_ConfigSchema>;
1377
- store: Store;
1378
- }) => Promise<_ResolvedUser>;
1379
- };
1380
- }
1381
- interface AnyPlatformDef {
1382
- actions?: Record<string, InstanceActionFn>;
1383
- config: z__default.ZodType<object>;
1384
- events?: {
1385
- [key: string]: ((ctx: any) => AsyncIterable<any>) | z__default.ZodType<object>;
1386
- };
1387
- lifecycle: {
1388
- createClient: (ctx: any) => Promise<any>;
1389
- destroyClient?: (ctx: any) => Promise<void>;
1390
- };
1391
- message?: {
1392
- schema?: z__default.ZodType<object>;
1393
- actions?: Record<string, MessageActionFn>;
1394
- };
1395
- messages: (ctx: any) => AsyncIterable<any>;
1396
- name: string;
1397
- send: (_: any) => Promise<ProviderMessageRecord | undefined>;
1398
- space: {
1399
- schema?: z__default.ZodType<object>;
1400
- params?: z__default.ZodType<object>;
1401
- create: (_: any) => Promise<any>;
1402
- get?: (_: any) => Promise<any>;
1403
- actions?: Record<string, SpaceActionFn>;
1404
- };
1405
- user: {
1406
- schema?: z__default.ZodType<object>;
1407
- resolve: (_: any) => Promise<any>;
1408
- };
1409
- }
1410
- interface PlatformProviderConfig<Def extends AnyPlatformDef = AnyPlatformDef> {
1411
- readonly __def: Def;
1412
- readonly __definition: AnyPlatformDef;
1413
- readonly __name: Def["name"];
1414
- readonly __tag: "PlatformProviderConfig";
1415
- readonly config: unknown;
1416
- }
1417
- interface MatchesPlatformName<Name extends string> extends Fn {
1418
- return: this["arg0"] extends PlatformProviderConfig<infer Def> ? Def["name"] extends Name ? true : false : false;
1419
- }
1420
- interface ExtractDef extends Fn {
1421
- return: this["arg0"] extends PlatformProviderConfig<infer Def> ? Def : never;
1422
- }
1423
- interface ExtractCustomEventNames extends Fn {
1424
- return: this["arg0"] extends AnyPlatformDef ? this["arg0"]["events"] extends Record<string, unknown> ? Exclude<keyof this["arg0"]["events"], symbol | number> : never : never;
1425
- }
1426
- interface ToCustomEventVariant<EventName extends string> extends Fn {
1427
- return: this["arg0"] extends PlatformProviderConfig<infer Def> ? Def["events"] extends Record<string, unknown> ? EventName extends keyof Def["events"] ? InferEventPayload<Def["events"][EventName]> & {
1428
- platform: Def["name"];
1429
- } : never : never : never;
1430
- }
1431
- type HasProvider<Providers extends PlatformProviderConfig[], Name extends string> = Pipe<Providers, [Tuples.Some<MatchesPlatformName<Name>>]>;
1432
- type AllCustomEventNames<Providers extends PlatformProviderConfig[]> = Pipe<Providers, [
1433
- Tuples.Map<ExtractDef>,
1434
- Tuples.Map<ExtractCustomEventNames>,
1435
- Tuples.ToUnion
1436
- ]>;
1437
- type UnifiedCustomEvent<Providers extends PlatformProviderConfig[], EventName extends string> = Pipe<Providers, [
1438
- Tuples.Map<ToCustomEventVariant<EventName>>,
1439
- Tuples.ToUnion
1440
- ]>;
1441
- type CustomEventStreams<Providers extends PlatformProviderConfig[]> = {
1442
- [K in Exclude<AllCustomEventNames<Providers>, ReservedNames> & string]: AsyncIterable<UnifiedCustomEvent<Providers, K>>;
1443
- };
1444
- type ResolvedSpaceOf<Def extends AnyPlatformDef> = AwaitedReturn<Def["space"]["create"]>;
1445
- type SchemaSpaceOf<Def extends AnyPlatformDef> = InferOptionalSchema<Def["space"]["schema"]>;
1446
- type ResolvedUserOf<Def extends AnyPlatformDef> = AwaitedReturn<Def["user"]["resolve"]>;
1447
- type SpaceShapeOf<Def extends AnyPlatformDef> = [SchemaSpaceOf<Def>] extends [
1448
- never
1449
- ] ? ResolvedSpaceOf<Def> : SchemaSpaceOf<Def>;
1450
- type SpaceParamsInputOf<Def extends AnyPlatformDef> = z__default.ZodType<object> extends Def["space"]["params"] ? never : InputSchema<Def["space"]["params"]>;
1451
- type SpaceUserLike<Def extends AnyPlatformDef> = PlatformUser<Def> | string;
1452
- type SpaceParamsArgs<Def extends AnyPlatformDef> = [
1453
- SpaceParamsInputOf<Def>
1454
- ] extends [never] ? [] : Record<string, never> extends SpaceParamsInputOf<Def> ? [params?: SpaceParamsInputOf<Def>] : [params: SpaceParamsInputOf<Def>];
1455
- interface SpaceNamespace<Def extends AnyPlatformDef> {
1456
- /**
1457
- * Resolve or create a space from its participants — a single user (1:1
1458
- * conversation) or several (group, where the platform supports it). Users
1459
- * may be raw id strings or previously resolved `PlatformUser`s.
1460
- */
1461
- create(users: SpaceUserLike<Def> | SpaceUserLike<Def>[], ...params: SpaceParamsArgs<Def>): Promise<PlatformSpace<Def>>;
1462
- /**
1463
- * Construct a space from a known platform space id — e.g. one persisted
1464
- * from an earlier event. Providers may hydrate platform-specific fields
1465
- * (or verify existence) via their `space.get` hook.
1466
- */
1467
- get(id: string, ...params: SpaceParamsArgs<Def>): Promise<PlatformSpace<Def>>;
1468
- }
1469
- type SpaceActionFns<Def extends AnyPlatformDef> = Def["space"] extends {
1470
- actions?: infer A;
1471
- } ? A extends Record<string, SpaceActionFn> ? A : Record<string, never> : Record<string, never>;
1472
- type TailArgs<T extends readonly unknown[]> = T extends readonly [
1473
- unknown,
1474
- ...infer Rest
1475
- ] ? Rest : [];
1476
- type SpaceActionMethods<Def extends AnyPlatformDef> = {
1477
- [K in Exclude<keyof SpaceActionFns<Def>, keyof Space>]: (...args: TailArgs<Parameters<SpaceActionFns<Def>[K]>>) => Promise<void>;
1478
- };
1479
- type MessageActionFns<Def extends AnyPlatformDef> = NonNullable<Def["message"]> extends {
1480
- actions?: infer A;
1481
- } ? A extends Record<string, MessageActionFn> ? A : Record<string, never> : Record<string, never>;
1482
- type MessageActionMethods<Def extends AnyPlatformDef> = {
1483
- [K in Exclude<keyof MessageActionFns<Def>, keyof Message>]: (...args: TailArgs<Parameters<MessageActionFns<Def>[K]>>) => Promise<void>;
1484
- };
1485
- type AnyInstanceActionFn = (...args: any[]) => Promise<unknown>;
1486
- type InstanceActionFns<Def extends AnyPlatformDef> = Def["actions"] extends infer A | undefined ? A extends Record<string, AnyInstanceActionFn> ? A : Record<string, never> : Record<string, never>;
1487
- type ReservedInstanceKeys<Def extends AnyPlatformDef> = "user" | "space" | "messages" | PlatformWiseActionKey | Extract<keyof CustomEventInstanceProperties<Def>, string>;
1488
- type InstanceActionMethods<Def extends AnyPlatformDef> = {
1489
- [K in Exclude<keyof InstanceActionFns<Def>, ReservedInstanceKeys<Def> | symbol | number>]: (...args: TailArgs<Parameters<InstanceActionFns<Def>[K]>>) => ReturnType<InstanceActionFns<Def>[K]>;
1490
- };
1491
- interface PlatformWiseInstanceMethods<Def extends AnyPlatformDef> {
1492
- getMessage: (space: PlatformSpace<Def>, messageId: string) => Promise<PlatformMessage<Def> | undefined>;
1493
- }
1494
- type PlatformSpace<Def extends AnyPlatformDef> = Omit<SpaceShapeOf<Def>, keyof Space | keyof SpaceActionMethods<Def>> & Space & SpaceActionMethods<Def>;
1495
- type PlatformMessage<Def extends AnyPlatformDef> = Omit<SchemaInfer<Def["message"]>, keyof Message | keyof MessageActionMethods<Def>> & Message<Def["name"], PlatformUser<Def>, PlatformSpace<Def>> & MessageActionMethods<Def>;
1496
- type PlatformUser<Def extends AnyPlatformDef> = Omit<ResolvedUserOf<Def>, keyof User> & User;
1497
- type PlatformInstance<Def extends AnyPlatformDef> = {
1498
- readonly messages: AsyncIterable<[PlatformSpace<Def>, PlatformMessage<Def>]>;
1499
- readonly space: SpaceNamespace<Def>;
1500
- user(userID: string): Promise<PlatformUser<Def>>;
1501
- } & CustomEventInstanceProperties<Def> & PlatformWiseInstanceMethods<Def> & InstanceActionMethods<Def>;
1502
- type CustomEventInstanceProperties<Def extends AnyPlatformDef> = Def["events"] extends Record<string, unknown> ? {
1503
- [K in Exclude<keyof Def["events"], symbol | number> as K extends ReservedNames ? never : K]: AsyncIterable<InferEventPayload<NonNullable<Def["events"]>[K]>>;
1504
- } : Record<never, never>;
1505
- interface PlatformRuntime {
1506
- client: unknown;
1507
- config: unknown;
1508
- definition: AnyPlatformDef;
1509
- projectConfig: ProjectData | undefined;
1510
- store: Store;
1511
- subscribeEvent?: (channel: string) => AsyncIterable<unknown> | undefined;
1512
- subscribeMessages: () => ManagedStream<[Space, Message]>;
1513
- }
1514
- interface SpectrumLike<Providers extends PlatformProviderConfig[] = PlatformProviderConfig[]> {
1515
- readonly __internal: {
1516
- platforms: Map<string, PlatformRuntime>;
1517
- };
1518
- readonly __providers: Providers;
1519
- }
1520
- interface Platform<Def extends AnyPlatformDef> {
1521
- config(...args: Record<string, never> extends z__default.input<Def["config"]> ? [config?: z__default.input<Def["config"]>] : [config: z__default.input<Def["config"]>]): PlatformProviderConfig<Def>;
1522
- is(input: Message): input is PlatformMessage<Def>;
1523
- is(input: Space): input is PlatformSpace<Def>;
1524
- is(input: unknown): input is PlatformMessage<Def> | PlatformSpace<Def>;
1525
- <Providers extends PlatformProviderConfig[]>(spectrum: SpectrumLike<Providers>): HasProvider<Providers, Def["name"]> extends true ? PlatformInstance<Def> : never;
1526
- (space: Space): PlatformSpace<Def>;
1527
- (message: Message): PlatformMessage<Def>;
1528
- }
1529
-
1530
- export { asReaction as $, type AgentSender as A, type Broadcaster as B, type ContentBuilder as C, type DedicatedTokenData as D, type EventProducer as E, type FusorTokenData as F, type ProjectProfile as G, type ReactionBuilder as H, type InstanceActionFn as I, type SharedTokenData as J, type SlackTeamMeta as K, type SlackTokenData as L, type Message as M, type SpaceNamespace as N, SpectrumCloudError as O, type Platform as P, type SubscriptionData as Q, type Reaction as R, type Space as S, type SubscriptionStatus as T, type User as U, type TokenData as V, broadcast as W, cloud as X, mergeStreams as Y, reaction as Z, stream as _, type SchemaMessage as a, type PlatformDef as b, type ProjectData as c, type Store as d, type ProviderMessageRecord as e, contentSchema as f, type ProviderMessage as g, type ContentInput as h, type Content as i, type SpaceActionFn as j, type MessageActionFn as k, type CreateClientContext as l, type PlatformProviderConfig as m, type SpectrumLike as n, type CustomEventStreams as o, type AnyPlatformDef as p, type CloudPlatform as q, type ImessageInfoData as r, type ManagedStream as s, type PlatformInstance as t, type PlatformMessage as u, type PlatformRuntime as v, type PlatformSpace as w, type PlatformStatus as x, type PlatformUser as y, type PlatformsData as z };