spectrum-ts 1.9.2 → 1.12.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/{chunk-TN54TDTQ.js → chunk-4TXLNBGE.js} +1 -1
- package/dist/{chunk-N3ZKMTSG.js → chunk-7Z3QGRGI.js} +8 -6
- package/dist/chunk-E7AXYNOZ.js +524 -0
- package/dist/{chunk-7O5BCLGQ.js → chunk-FPYXHZZA.js} +191 -97
- package/dist/chunk-KO67KDBD.js +61 -0
- package/dist/chunk-L3VXHUVY.js +457 -0
- package/dist/{chunk-5NHNMN4H.js → chunk-UFJZIZDO.js} +1 -1
- package/dist/{chunk-OR3VGVML.js → chunk-VQOW7X7U.js} +8 -4
- package/dist/{chunk-XZSBR26X.js → chunk-YDHES53X.js} +189 -500
- package/dist/{chunk-HWADNTQF.js → chunk-YKWKZ2PZ.js} +4 -59
- package/dist/index.d.ts +210 -85
- package/dist/index.js +17 -9
- package/dist/photo-content-BQF42prd.d.ts +13 -0
- package/dist/providers/imessage/index.d.ts +32 -5
- package/dist/providers/imessage/index.js +10 -6
- package/dist/providers/index.d.ts +4 -1
- package/dist/providers/index.js +13 -7
- package/dist/providers/slack/index.d.ts +47 -0
- package/dist/providers/slack/index.js +8 -0
- package/dist/providers/terminal/index.d.ts +46 -10
- package/dist/providers/terminal/index.js +4 -3
- package/dist/providers/whatsapp-business/index.d.ts +2 -2
- package/dist/providers/whatsapp-business/index.js +5 -3
- package/dist/{types-lUyzRurY.d.ts → types-BzW4gInA.d.ts} +231 -104
- package/package.json +12 -1
|
@@ -91,10 +91,10 @@ declare const contentSchema: z__default.ZodDiscriminatedUnion<[z__default.ZodObj
|
|
|
91
91
|
}, z__default.core.$strip>, z__default.ZodObject<{
|
|
92
92
|
type: z__default.ZodLiteral<"reaction">;
|
|
93
93
|
emoji: z__default.ZodString;
|
|
94
|
-
target: z__default.ZodCustom<Message, Message
|
|
94
|
+
target: z__default.ZodCustom<Message<string, User, Space<unknown>>, Message<string, User, Space<unknown>>>;
|
|
95
95
|
}, z__default.core.$strip>, z__default.ZodObject<{
|
|
96
96
|
type: z__default.ZodLiteral<"group">;
|
|
97
|
-
items: z__default.ZodArray<z__default.ZodCustom<Message, Message
|
|
97
|
+
items: z__default.ZodArray<z__default.ZodCustom<Message<string, User, Space<unknown>>, Message<string, User, Space<unknown>>>>;
|
|
98
98
|
}, z__default.core.$strip>, z__default.ZodObject<{
|
|
99
99
|
type: z__default.ZodLiteral<"poll">;
|
|
100
100
|
title: z__default.ZodString;
|
|
@@ -135,9 +135,43 @@ declare const contentSchema: z__default.ZodDiscriminatedUnion<[z__default.ZodObj
|
|
|
135
135
|
start: "start";
|
|
136
136
|
stop: "stop";
|
|
137
137
|
}>;
|
|
138
|
+
}, z__default.core.$strip>, z__default.ZodObject<{
|
|
139
|
+
type: z__default.ZodLiteral<"rename">;
|
|
140
|
+
displayName: z__default.ZodString;
|
|
141
|
+
}, z__default.core.$strip>, z__default.ZodObject<{
|
|
142
|
+
type: z__default.ZodLiteral<"avatar">;
|
|
143
|
+
action: z__default.ZodDiscriminatedUnion<[z__default.ZodObject<{
|
|
144
|
+
kind: z__default.ZodLiteral<"set">;
|
|
145
|
+
read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
|
|
146
|
+
mimeType: z__default.ZodString;
|
|
147
|
+
}, z__default.core.$strip>, z__default.ZodObject<{
|
|
148
|
+
kind: z__default.ZodLiteral<"clear">;
|
|
149
|
+
}, z__default.core.$strip>], "kind">;
|
|
138
150
|
}, z__default.core.$strip>, z__default.ZodObject<{
|
|
139
151
|
type: z__default.ZodLiteral<"reply">;
|
|
140
152
|
content: z__default.ZodCustom<{
|
|
153
|
+
type: "avatar";
|
|
154
|
+
action: {
|
|
155
|
+
kind: "set";
|
|
156
|
+
read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
|
|
157
|
+
mimeType: string;
|
|
158
|
+
} | {
|
|
159
|
+
kind: "clear";
|
|
160
|
+
};
|
|
161
|
+
} | {
|
|
162
|
+
type: "text";
|
|
163
|
+
text: string;
|
|
164
|
+
} | {
|
|
165
|
+
type: "attachment";
|
|
166
|
+
name: string;
|
|
167
|
+
mimeType: string;
|
|
168
|
+
read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
|
|
169
|
+
stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
|
|
170
|
+
size?: number | undefined;
|
|
171
|
+
} | {
|
|
172
|
+
type: "custom";
|
|
173
|
+
raw: unknown;
|
|
174
|
+
} | {
|
|
141
175
|
type: "contact";
|
|
142
176
|
user?: {
|
|
143
177
|
__platform: string;
|
|
@@ -180,19 +214,6 @@ declare const contentSchema: z__default.ZodDiscriminatedUnion<[z__default.ZodObj
|
|
|
180
214
|
read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
|
|
181
215
|
} | undefined;
|
|
182
216
|
raw?: unknown;
|
|
183
|
-
} | {
|
|
184
|
-
type: "text";
|
|
185
|
-
text: string;
|
|
186
|
-
} | {
|
|
187
|
-
type: "attachment";
|
|
188
|
-
name: string;
|
|
189
|
-
mimeType: string;
|
|
190
|
-
read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
|
|
191
|
-
stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
|
|
192
|
-
size?: number | undefined;
|
|
193
|
-
} | {
|
|
194
|
-
type: "custom";
|
|
195
|
-
raw: unknown;
|
|
196
217
|
} | {
|
|
197
218
|
type: "voice";
|
|
198
219
|
mimeType: string;
|
|
@@ -214,10 +235,10 @@ declare const contentSchema: z__default.ZodDiscriminatedUnion<[z__default.ZodObj
|
|
|
214
235
|
} | {
|
|
215
236
|
type: "reaction";
|
|
216
237
|
emoji: string;
|
|
217
|
-
target: Message
|
|
238
|
+
target: Message<string, User, Space<unknown>>;
|
|
218
239
|
} | {
|
|
219
240
|
type: "group";
|
|
220
|
-
items: Message[];
|
|
241
|
+
items: Message<string, User, Space<unknown>>[];
|
|
221
242
|
} | {
|
|
222
243
|
type: "poll";
|
|
223
244
|
title: string;
|
|
@@ -255,7 +276,32 @@ declare const contentSchema: z__default.ZodDiscriminatedUnion<[z__default.ZodObj
|
|
|
255
276
|
} | {
|
|
256
277
|
type: "typing";
|
|
257
278
|
state: "start" | "stop";
|
|
279
|
+
} | {
|
|
280
|
+
type: "rename";
|
|
281
|
+
displayName: string;
|
|
258
282
|
}, {
|
|
283
|
+
type: "avatar";
|
|
284
|
+
action: {
|
|
285
|
+
kind: "set";
|
|
286
|
+
read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
|
|
287
|
+
mimeType: string;
|
|
288
|
+
} | {
|
|
289
|
+
kind: "clear";
|
|
290
|
+
};
|
|
291
|
+
} | {
|
|
292
|
+
type: "text";
|
|
293
|
+
text: string;
|
|
294
|
+
} | {
|
|
295
|
+
type: "attachment";
|
|
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
|
+
type: "custom";
|
|
303
|
+
raw: unknown;
|
|
304
|
+
} | {
|
|
259
305
|
type: "contact";
|
|
260
306
|
user?: {
|
|
261
307
|
__platform: string;
|
|
@@ -298,19 +344,6 @@ declare const contentSchema: z__default.ZodDiscriminatedUnion<[z__default.ZodObj
|
|
|
298
344
|
read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
|
|
299
345
|
} | undefined;
|
|
300
346
|
raw?: unknown;
|
|
301
|
-
} | {
|
|
302
|
-
type: "text";
|
|
303
|
-
text: string;
|
|
304
|
-
} | {
|
|
305
|
-
type: "attachment";
|
|
306
|
-
name: string;
|
|
307
|
-
mimeType: string;
|
|
308
|
-
read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
|
|
309
|
-
stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
|
|
310
|
-
size?: number | undefined;
|
|
311
|
-
} | {
|
|
312
|
-
type: "custom";
|
|
313
|
-
raw: unknown;
|
|
314
347
|
} | {
|
|
315
348
|
type: "voice";
|
|
316
349
|
mimeType: string;
|
|
@@ -332,10 +365,10 @@ declare const contentSchema: z__default.ZodDiscriminatedUnion<[z__default.ZodObj
|
|
|
332
365
|
} | {
|
|
333
366
|
type: "reaction";
|
|
334
367
|
emoji: string;
|
|
335
|
-
target: Message
|
|
368
|
+
target: Message<string, User, Space<unknown>>;
|
|
336
369
|
} | {
|
|
337
370
|
type: "group";
|
|
338
|
-
items: Message[];
|
|
371
|
+
items: Message<string, User, Space<unknown>>[];
|
|
339
372
|
} | {
|
|
340
373
|
type: "poll";
|
|
341
374
|
title: string;
|
|
@@ -373,11 +406,36 @@ declare const contentSchema: z__default.ZodDiscriminatedUnion<[z__default.ZodObj
|
|
|
373
406
|
} | {
|
|
374
407
|
type: "typing";
|
|
375
408
|
state: "start" | "stop";
|
|
409
|
+
} | {
|
|
410
|
+
type: "rename";
|
|
411
|
+
displayName: string;
|
|
376
412
|
}>;
|
|
377
|
-
target: z__default.ZodCustom<Message, Message
|
|
413
|
+
target: z__default.ZodCustom<Message<string, User, Space<unknown>>, Message<string, User, Space<unknown>>>;
|
|
378
414
|
}, z__default.core.$strip>, z__default.ZodObject<{
|
|
379
415
|
type: z__default.ZodLiteral<"edit">;
|
|
380
416
|
content: z__default.ZodCustom<{
|
|
417
|
+
type: "avatar";
|
|
418
|
+
action: {
|
|
419
|
+
kind: "set";
|
|
420
|
+
read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
|
|
421
|
+
mimeType: string;
|
|
422
|
+
} | {
|
|
423
|
+
kind: "clear";
|
|
424
|
+
};
|
|
425
|
+
} | {
|
|
426
|
+
type: "text";
|
|
427
|
+
text: string;
|
|
428
|
+
} | {
|
|
429
|
+
type: "attachment";
|
|
430
|
+
name: string;
|
|
431
|
+
mimeType: string;
|
|
432
|
+
read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
|
|
433
|
+
stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
|
|
434
|
+
size?: number | undefined;
|
|
435
|
+
} | {
|
|
436
|
+
type: "custom";
|
|
437
|
+
raw: unknown;
|
|
438
|
+
} | {
|
|
381
439
|
type: "contact";
|
|
382
440
|
user?: {
|
|
383
441
|
__platform: string;
|
|
@@ -420,19 +478,6 @@ declare const contentSchema: z__default.ZodDiscriminatedUnion<[z__default.ZodObj
|
|
|
420
478
|
read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
|
|
421
479
|
} | undefined;
|
|
422
480
|
raw?: unknown;
|
|
423
|
-
} | {
|
|
424
|
-
type: "text";
|
|
425
|
-
text: string;
|
|
426
|
-
} | {
|
|
427
|
-
type: "attachment";
|
|
428
|
-
name: string;
|
|
429
|
-
mimeType: string;
|
|
430
|
-
read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
|
|
431
|
-
stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
|
|
432
|
-
size?: number | undefined;
|
|
433
|
-
} | {
|
|
434
|
-
type: "custom";
|
|
435
|
-
raw: unknown;
|
|
436
481
|
} | {
|
|
437
482
|
type: "voice";
|
|
438
483
|
mimeType: string;
|
|
@@ -454,10 +499,10 @@ declare const contentSchema: z__default.ZodDiscriminatedUnion<[z__default.ZodObj
|
|
|
454
499
|
} | {
|
|
455
500
|
type: "reaction";
|
|
456
501
|
emoji: string;
|
|
457
|
-
target: Message
|
|
502
|
+
target: Message<string, User, Space<unknown>>;
|
|
458
503
|
} | {
|
|
459
504
|
type: "group";
|
|
460
|
-
items: Message[];
|
|
505
|
+
items: Message<string, User, Space<unknown>>[];
|
|
461
506
|
} | {
|
|
462
507
|
type: "poll";
|
|
463
508
|
title: string;
|
|
@@ -495,7 +540,32 @@ declare const contentSchema: z__default.ZodDiscriminatedUnion<[z__default.ZodObj
|
|
|
495
540
|
} | {
|
|
496
541
|
type: "typing";
|
|
497
542
|
state: "start" | "stop";
|
|
543
|
+
} | {
|
|
544
|
+
type: "rename";
|
|
545
|
+
displayName: string;
|
|
498
546
|
}, {
|
|
547
|
+
type: "avatar";
|
|
548
|
+
action: {
|
|
549
|
+
kind: "set";
|
|
550
|
+
read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
|
|
551
|
+
mimeType: string;
|
|
552
|
+
} | {
|
|
553
|
+
kind: "clear";
|
|
554
|
+
};
|
|
555
|
+
} | {
|
|
556
|
+
type: "text";
|
|
557
|
+
text: string;
|
|
558
|
+
} | {
|
|
559
|
+
type: "attachment";
|
|
560
|
+
name: string;
|
|
561
|
+
mimeType: string;
|
|
562
|
+
read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
|
|
563
|
+
stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
|
|
564
|
+
size?: number | undefined;
|
|
565
|
+
} | {
|
|
566
|
+
type: "custom";
|
|
567
|
+
raw: unknown;
|
|
568
|
+
} | {
|
|
499
569
|
type: "contact";
|
|
500
570
|
user?: {
|
|
501
571
|
__platform: string;
|
|
@@ -538,19 +608,6 @@ declare const contentSchema: z__default.ZodDiscriminatedUnion<[z__default.ZodObj
|
|
|
538
608
|
read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
|
|
539
609
|
} | undefined;
|
|
540
610
|
raw?: unknown;
|
|
541
|
-
} | {
|
|
542
|
-
type: "text";
|
|
543
|
-
text: string;
|
|
544
|
-
} | {
|
|
545
|
-
type: "attachment";
|
|
546
|
-
name: string;
|
|
547
|
-
mimeType: string;
|
|
548
|
-
read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
|
|
549
|
-
stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
|
|
550
|
-
size?: number | undefined;
|
|
551
|
-
} | {
|
|
552
|
-
type: "custom";
|
|
553
|
-
raw: unknown;
|
|
554
611
|
} | {
|
|
555
612
|
type: "voice";
|
|
556
613
|
mimeType: string;
|
|
@@ -572,10 +629,10 @@ declare const contentSchema: z__default.ZodDiscriminatedUnion<[z__default.ZodObj
|
|
|
572
629
|
} | {
|
|
573
630
|
type: "reaction";
|
|
574
631
|
emoji: string;
|
|
575
|
-
target: Message
|
|
632
|
+
target: Message<string, User, Space<unknown>>;
|
|
576
633
|
} | {
|
|
577
634
|
type: "group";
|
|
578
|
-
items: Message[];
|
|
635
|
+
items: Message<string, User, Space<unknown>>[];
|
|
579
636
|
} | {
|
|
580
637
|
type: "poll";
|
|
581
638
|
title: string;
|
|
@@ -613,8 +670,11 @@ declare const contentSchema: z__default.ZodDiscriminatedUnion<[z__default.ZodObj
|
|
|
613
670
|
} | {
|
|
614
671
|
type: "typing";
|
|
615
672
|
state: "start" | "stop";
|
|
673
|
+
} | {
|
|
674
|
+
type: "rename";
|
|
675
|
+
displayName: string;
|
|
616
676
|
}>;
|
|
617
|
-
target: z__default.ZodCustom<Message, Message
|
|
677
|
+
target: z__default.ZodCustom<Message<string, User, Space<unknown>>, Message<string, User, Space<unknown>>>;
|
|
618
678
|
}, z__default.core.$strip>], "type">;
|
|
619
679
|
type Content = z__default.infer<typeof contentSchema>;
|
|
620
680
|
interface ContentBuilder {
|
|
@@ -625,11 +685,34 @@ type ContentInput = string | ContentBuilder;
|
|
|
625
685
|
interface User {
|
|
626
686
|
readonly __platform: string;
|
|
627
687
|
readonly id: string;
|
|
688
|
+
readonly kind?: "agent";
|
|
689
|
+
}
|
|
690
|
+
interface AgentSender extends User {
|
|
691
|
+
readonly kind: "agent";
|
|
628
692
|
}
|
|
629
693
|
|
|
630
694
|
interface Space<_Def = unknown> {
|
|
631
695
|
readonly __platform: string;
|
|
632
|
-
|
|
696
|
+
/**
|
|
697
|
+
* Set or clear the current chat's avatar (group icon). Sugar for
|
|
698
|
+
* `send(avatar(input, options?))`.
|
|
699
|
+
*
|
|
700
|
+
* - `space.avatar("clear")` — remove the current avatar.
|
|
701
|
+
* - `space.avatar("./icon.png")` — set from a filesystem path; MIME type
|
|
702
|
+
* is inferred from the extension.
|
|
703
|
+
* - `space.avatar(buffer, { mimeType })` — set from in-memory bytes;
|
|
704
|
+
* `mimeType` is required (enforced at the type level).
|
|
705
|
+
*
|
|
706
|
+
* Universal API; per-platform constraints (e.g. iMessage: remote + group
|
|
707
|
+
* only) surface as `UnsupportedError` from the provider's send action.
|
|
708
|
+
*/
|
|
709
|
+
avatar(input: string, options?: {
|
|
710
|
+
mimeType?: string;
|
|
711
|
+
}): Promise<void>;
|
|
712
|
+
avatar(input: Buffer, options: {
|
|
713
|
+
mimeType: string;
|
|
714
|
+
}): Promise<void>;
|
|
715
|
+
edit(message: Message, newContent: ContentInput): Promise<void>;
|
|
633
716
|
/**
|
|
634
717
|
* Look up a message in this space by its id. Returns `undefined` if the
|
|
635
718
|
* platform has no way to resolve the id (e.g. cache miss with no by-id
|
|
@@ -638,33 +721,33 @@ interface Space<_Def = unknown> {
|
|
|
638
721
|
*/
|
|
639
722
|
getMessage(id: string): Promise<Message | undefined>;
|
|
640
723
|
readonly id: string;
|
|
724
|
+
/**
|
|
725
|
+
* Rename the current chat. Sugar for `send(rename(displayName))`.
|
|
726
|
+
*
|
|
727
|
+
* Universal API; per-platform constraints (e.g. iMessage: remote + group
|
|
728
|
+
* only) surface as `UnsupportedError` from the provider's send action.
|
|
729
|
+
*/
|
|
730
|
+
rename(displayName: string): Promise<void>;
|
|
641
731
|
responding<T>(fn: () => T | Promise<T>): Promise<T>;
|
|
642
|
-
send(content: ContentInput): Promise<
|
|
643
|
-
send(...content: [ContentInput, ContentInput, ...ContentInput[]]): Promise<
|
|
732
|
+
send(content: ContentInput): Promise<Message<string, AgentSender> | undefined>;
|
|
733
|
+
send(...content: [ContentInput, ContentInput, ...ContentInput[]]): Promise<Message<string, AgentSender>[]>;
|
|
644
734
|
startTyping(): Promise<void>;
|
|
645
735
|
stopTyping(): Promise<void>;
|
|
646
736
|
}
|
|
647
737
|
|
|
648
|
-
interface
|
|
738
|
+
interface Message<TPlatform extends string = string, TSender extends User = User, TSpace extends Space = Space> {
|
|
649
739
|
content: Content;
|
|
740
|
+
direction: "inbound" | "outbound";
|
|
741
|
+
edit(newContent: ContentInput): Promise<void>;
|
|
650
742
|
readonly id: string;
|
|
651
743
|
platform: TPlatform;
|
|
652
744
|
react(reaction: string): Promise<void>;
|
|
653
|
-
reply(content: ContentInput): Promise<
|
|
654
|
-
reply(...content: [ContentInput, ContentInput, ...ContentInput[]]): Promise<
|
|
745
|
+
reply(content: ContentInput): Promise<Message<TPlatform, AgentSender, TSpace> | undefined>;
|
|
746
|
+
reply(...content: [ContentInput, ContentInput, ...ContentInput[]]): Promise<Message<TPlatform, AgentSender, TSpace>[]>;
|
|
747
|
+
sender: TSender | undefined;
|
|
655
748
|
space: TSpace;
|
|
656
749
|
timestamp: Date;
|
|
657
750
|
}
|
|
658
|
-
interface InboundMessage<TPlatform extends string = string, TSender extends User = User, TSpace extends Space = Space> extends BaseMessage<TPlatform, TSender, TSpace> {
|
|
659
|
-
direction: "inbound";
|
|
660
|
-
sender: TSender;
|
|
661
|
-
}
|
|
662
|
-
interface OutboundMessage<TPlatform extends string = string, TSender extends User = User, TSpace extends Space = Space> extends BaseMessage<TPlatform, TSender, TSpace> {
|
|
663
|
-
direction: "outbound";
|
|
664
|
-
edit(newContent: ContentInput): Promise<void>;
|
|
665
|
-
sender: TSender | undefined;
|
|
666
|
-
}
|
|
667
|
-
type Message<TPlatform extends string = string, TSender extends User = User, TSpace extends Space = Space> = InboundMessage<TPlatform, TSender, TSpace> | OutboundMessage<TPlatform, TSender, TSpace>;
|
|
668
751
|
|
|
669
752
|
/**
|
|
670
753
|
* A small per-platform key-value bag, modeled after Swift's `UserDefaults`.
|
|
@@ -702,16 +785,31 @@ interface Broadcaster<T> {
|
|
|
702
785
|
declare function broadcast<T>(source: ManagedStream<T>): Broadcaster<T>;
|
|
703
786
|
|
|
704
787
|
/**
|
|
705
|
-
* A platform-defined
|
|
706
|
-
*
|
|
707
|
-
* `
|
|
788
|
+
* A platform-defined method on `Space`. The first parameter is bound to the
|
|
789
|
+
* built `Space` at construction time, so callers only pass the trailing args.
|
|
790
|
+
* Actions are plain functions returning `Promise<void>` — they can delegate
|
|
791
|
+
* through `space.send(...)`, call the underlying SDK, or perform any other
|
|
792
|
+
* side effect.
|
|
708
793
|
*
|
|
709
794
|
* Names that collide with reserved `Space` keys (`send`, `edit`,
|
|
710
795
|
* `getMessage`, `startTyping`, `stopTyping`, `responding`, `id`,
|
|
711
796
|
* `__platform`) are skipped at runtime with a warning and excluded at the
|
|
712
797
|
* type level via `Exclude<…, keyof Space>`.
|
|
713
798
|
*/
|
|
714
|
-
type
|
|
799
|
+
type SpaceActionFn = (space: Space, ...args: never[]) => Promise<void>;
|
|
800
|
+
/**
|
|
801
|
+
* A platform-defined method on `Message`. The first parameter is bound to
|
|
802
|
+
* the message itself (`self`) at build time, so callers only pass the
|
|
803
|
+
* trailing args. Actions are plain functions returning `Promise<void>` —
|
|
804
|
+
* they can delegate through `message.space.send(...)`, call the underlying
|
|
805
|
+
* SDK, or perform any other side effect.
|
|
806
|
+
*
|
|
807
|
+
* Names that collide with reserved `Message` keys (`react`, `reply`, `edit`,
|
|
808
|
+
* `id`, `space`, `sender`, `content`, `platform`, `direction`, `timestamp`)
|
|
809
|
+
* are skipped at runtime with a warning and excluded at the type level via
|
|
810
|
+
* `Exclude<…, keyof Message>`.
|
|
811
|
+
*/
|
|
812
|
+
type MessageActionFn = (message: Message, ...args: never[]) => Promise<void>;
|
|
715
813
|
type ResolvedSpace = Pick<Space, "id">;
|
|
716
814
|
type SpaceRef = Pick<Space, "id" | "__platform">;
|
|
717
815
|
type ResolvedUser = Pick<User, "id">;
|
|
@@ -785,7 +883,7 @@ interface CreateClientContext<_ConfigSchema extends z__default.ZodType<object>>
|
|
|
785
883
|
*/
|
|
786
884
|
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>>> & {
|
|
787
885
|
messages?: never;
|
|
788
|
-
}) | undefined = undefined> {
|
|
886
|
+
}) | undefined = undefined, _SpaceActions extends Record<string, SpaceActionFn> = Record<never, never>, _MessageActions extends Record<string, MessageActionFn> = Record<never, never>> {
|
|
789
887
|
/**
|
|
790
888
|
* Optional escape hatch: platform actions beyond `send`. Currently the
|
|
791
889
|
* framework recognizes one slot:
|
|
@@ -829,6 +927,26 @@ interface PlatformDef<_Name extends string = string, _ConfigSchema extends z__de
|
|
|
829
927
|
};
|
|
830
928
|
message?: {
|
|
831
929
|
schema?: _MessageSchema;
|
|
930
|
+
/**
|
|
931
|
+
* Optional platform-specific sugar methods bound to `PlatformMessage<Def>`.
|
|
932
|
+
*
|
|
933
|
+
* Each entry is a `ContentBuilder` factory whose **first parameter** is
|
|
934
|
+
* the message itself (`self`); `buildMessage` injects a thin wrapper
|
|
935
|
+
* that supplies `self` and calls `space.send(factory(self, ...args))`.
|
|
936
|
+
* The wrapper is typed as `(...args) => Promise<void>` on
|
|
937
|
+
* `PlatformMessage<Def>` via `MessageActionMethods<Def>`.
|
|
938
|
+
*
|
|
939
|
+
* Mirrors `space.actions` — `space.actions` lives on the space slot for
|
|
940
|
+
* chat-level sugar (e.g. `space.background(...)`); `message.actions`
|
|
941
|
+
* lives here for per-message sugar that needs `self` (e.g.
|
|
942
|
+
* `message.read()`).
|
|
943
|
+
*
|
|
944
|
+
* Names that collide with reserved `Message` keys (`react`, `reply`,
|
|
945
|
+
* `edit`, `id`, `space`, `sender`, `content`, `platform`, `direction`,
|
|
946
|
+
* `timestamp`) are skipped at runtime with a warning and excluded at
|
|
947
|
+
* the type level.
|
|
948
|
+
*/
|
|
949
|
+
actions?: _MessageActions;
|
|
832
950
|
};
|
|
833
951
|
/**
|
|
834
952
|
* Inbound message stream. Returns an `AsyncIterable<ProviderMessageRecord>`
|
|
@@ -874,23 +992,25 @@ interface PlatformDef<_Name extends string = string, _ConfigSchema extends z__de
|
|
|
874
992
|
store: Store;
|
|
875
993
|
}) => Promise<_ResolvedSpace>;
|
|
876
994
|
/**
|
|
877
|
-
* Optional platform-specific
|
|
995
|
+
* Optional platform-specific methods bound to `PlatformSpace<Def>`.
|
|
878
996
|
*
|
|
879
|
-
* Each entry is a
|
|
880
|
-
*
|
|
881
|
-
*
|
|
882
|
-
* `
|
|
997
|
+
* Each entry is a plain async function `(space, ...args) => Promise<void>`;
|
|
998
|
+
* `buildSpace` injects the built `PlatformSpace<Def>` as the first
|
|
999
|
+
* argument and exposes the trailing args as the public surface. Action
|
|
1000
|
+
* implementations choose how to dispatch — `space.send(...)`, a direct
|
|
1001
|
+
* SDK call, or any other side effect — and always return `Promise<void>`
|
|
1002
|
+
* to callers.
|
|
883
1003
|
*
|
|
884
1004
|
* Mirrors the top-level `PlatformDef.actions` slot — `actions` lives at
|
|
885
1005
|
* the platform level for capabilities (e.g. `getMessage`); `space.actions`
|
|
886
|
-
* lives here for
|
|
1006
|
+
* lives here for platform-specific surface area.
|
|
887
1007
|
*
|
|
888
1008
|
* Names that collide with reserved `Space` keys (`send`, `edit`,
|
|
889
1009
|
* `getMessage`, `startTyping`, `stopTyping`, `responding`, `id`,
|
|
890
1010
|
* `__platform`) are skipped at runtime with a warning and excluded at
|
|
891
1011
|
* the type level.
|
|
892
1012
|
*/
|
|
893
|
-
actions?:
|
|
1013
|
+
actions?: _SpaceActions;
|
|
894
1014
|
};
|
|
895
1015
|
user: {
|
|
896
1016
|
schema?: _UserSchema;
|
|
@@ -918,6 +1038,7 @@ interface AnyPlatformDef {
|
|
|
918
1038
|
};
|
|
919
1039
|
message?: {
|
|
920
1040
|
schema?: z__default.ZodType<object>;
|
|
1041
|
+
actions?: Record<string, MessageActionFn>;
|
|
921
1042
|
};
|
|
922
1043
|
messages: (ctx: any) => AsyncIterable<any>;
|
|
923
1044
|
name: string;
|
|
@@ -926,7 +1047,7 @@ interface AnyPlatformDef {
|
|
|
926
1047
|
schema?: z__default.ZodType<object>;
|
|
927
1048
|
params?: z__default.ZodType<object>;
|
|
928
1049
|
resolve: (_: any) => Promise<any>;
|
|
929
|
-
actions?: Record<string,
|
|
1050
|
+
actions?: Record<string, SpaceActionFn>;
|
|
930
1051
|
};
|
|
931
1052
|
user: {
|
|
932
1053
|
schema?: z__default.ZodType<object>;
|
|
@@ -982,21 +1103,27 @@ type SpaceVarargArgs<Def extends AnyPlatformDef> = [
|
|
|
982
1103
|
SpaceParamsInputOf<Def>
|
|
983
1104
|
] extends [never] ? SpaceUserLike<Def>[] : SpaceUserLike<Def>[] | [...SpaceUserLike<Def>[], SpaceParamsInputOf<Def>];
|
|
984
1105
|
type SpaceArgs<Def extends AnyPlatformDef> = SpaceArrayArgs<Def> | SpaceVarargArgs<Def>;
|
|
985
|
-
type
|
|
1106
|
+
type SpaceActionFns<Def extends AnyPlatformDef> = Def["space"] extends {
|
|
986
1107
|
actions?: infer A;
|
|
987
|
-
} ? A extends Record<string,
|
|
1108
|
+
} ? A extends Record<string, SpaceActionFn> ? A : Record<string, never> : Record<string, never>;
|
|
1109
|
+
type TailArgs<T extends readonly unknown[]> = T extends readonly [
|
|
1110
|
+
unknown,
|
|
1111
|
+
...infer Rest
|
|
1112
|
+
] ? Rest : [];
|
|
988
1113
|
type SpaceActionMethods<Def extends AnyPlatformDef> = {
|
|
989
|
-
[K in Exclude<keyof
|
|
1114
|
+
[K in Exclude<keyof SpaceActionFns<Def>, keyof Space>]: (...args: TailArgs<Parameters<SpaceActionFns<Def>[K]>>) => Promise<void>;
|
|
1115
|
+
};
|
|
1116
|
+
type MessageActionFns<Def extends AnyPlatformDef> = NonNullable<Def["message"]> extends {
|
|
1117
|
+
actions?: infer A;
|
|
1118
|
+
} ? A extends Record<string, MessageActionFn> ? A : Record<string, never> : Record<string, never>;
|
|
1119
|
+
type MessageActionMethods<Def extends AnyPlatformDef> = {
|
|
1120
|
+
[K in Exclude<keyof MessageActionFns<Def>, keyof Message>]: (...args: TailArgs<Parameters<MessageActionFns<Def>[K]>>) => Promise<void>;
|
|
990
1121
|
};
|
|
991
1122
|
type PlatformSpace<Def extends AnyPlatformDef> = Omit<SpaceShapeOf<Def>, keyof Space | keyof SpaceActionMethods<Def>> & Space & SpaceActionMethods<Def>;
|
|
992
|
-
type PlatformMessage<Def extends AnyPlatformDef> = Omit<SchemaInfer<Def["message"]>, keyof Message
|
|
993
|
-
type InboundPlatformMessage<Def extends AnyPlatformDef> = Omit<SchemaInfer<Def["message"]>, keyof InboundMessage> & InboundMessage<Def["name"], PlatformUser<Def>, PlatformSpace<Def>>;
|
|
1123
|
+
type PlatformMessage<Def extends AnyPlatformDef> = Omit<SchemaInfer<Def["message"]>, keyof Message | keyof MessageActionMethods<Def>> & Message<Def["name"], PlatformUser<Def>, PlatformSpace<Def>> & MessageActionMethods<Def>;
|
|
994
1124
|
type PlatformUser<Def extends AnyPlatformDef> = Omit<ResolvedUserOf<Def>, keyof User> & User;
|
|
995
1125
|
type PlatformInstance<Def extends AnyPlatformDef> = {
|
|
996
|
-
readonly messages: AsyncIterable<[
|
|
997
|
-
PlatformSpace<Def>,
|
|
998
|
-
InboundPlatformMessage<Def>
|
|
999
|
-
]>;
|
|
1126
|
+
readonly messages: AsyncIterable<[PlatformSpace<Def>, PlatformMessage<Def>]>;
|
|
1000
1127
|
space(...args: SpaceArgs<Def>): Promise<PlatformSpace<Def>>;
|
|
1001
1128
|
user(userID: string): Promise<PlatformUser<Def>>;
|
|
1002
1129
|
} & CustomEventInstanceProperties<Def>;
|
|
@@ -1008,7 +1135,7 @@ interface PlatformRuntime {
|
|
|
1008
1135
|
config: unknown;
|
|
1009
1136
|
definition: AnyPlatformDef;
|
|
1010
1137
|
store: Store;
|
|
1011
|
-
subscribeMessages: () => ManagedStream<[Space,
|
|
1138
|
+
subscribeMessages: () => ManagedStream<[Space, Message]>;
|
|
1012
1139
|
}
|
|
1013
1140
|
interface SpectrumLike<Providers extends PlatformProviderConfig[] = PlatformProviderConfig[]> {
|
|
1014
1141
|
readonly __internal: {
|
|
@@ -1026,4 +1153,4 @@ interface Platform<Def extends AnyPlatformDef> {
|
|
|
1026
1153
|
(message: Message): PlatformMessage<Def>;
|
|
1027
1154
|
}
|
|
1028
1155
|
|
|
1029
|
-
export { type
|
|
1156
|
+
export { type AgentSender as A, type Broadcaster as B, type ContentBuilder as C, type EventProducer as E, type Message as M, type Platform as P, type SchemaMessage as S, type User as U, type PlatformDef as a, type Space as b, type ContentInput as c, type Content as d, type ProviderMessage as e, type SpaceActionFn as f, type MessageActionFn as g, type CreateClientContext as h, type Store as i, type PlatformProviderConfig as j, type SpectrumLike as k, type CustomEventStreams as l, type AnyPlatformDef as m, type ManagedStream as n, type PlatformInstance as o, type PlatformMessage as p, type PlatformRuntime as q, type PlatformSpace as r, type PlatformUser as s, broadcast as t, mergeStreams as u, stream as v };
|
package/package.json
CHANGED
|
@@ -1,6 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "spectrum-ts",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.0",
|
|
4
|
+
"description": "Bring agents to any interface — unified messaging SDK for TypeScript.",
|
|
5
|
+
"repository": {
|
|
6
|
+
"type": "git",
|
|
7
|
+
"url": "git+https://github.com/photon-hq/spectrum-ts.git",
|
|
8
|
+
"directory": "packages/spectrum-ts"
|
|
9
|
+
},
|
|
10
|
+
"homepage": "https://photon.codes/spectrum",
|
|
11
|
+
"bugs": {
|
|
12
|
+
"url": "https://github.com/photon-hq/spectrum-ts/issues"
|
|
13
|
+
},
|
|
4
14
|
"type": "module",
|
|
5
15
|
"main": "./dist/index.js",
|
|
6
16
|
"module": "./dist/index.js",
|
|
@@ -26,6 +36,7 @@
|
|
|
26
36
|
"@photon-ai/advanced-imessage": "^0.8.0",
|
|
27
37
|
"@photon-ai/imessage-kit": "^3.0.0",
|
|
28
38
|
"@photon-ai/otel": "^0.1.1",
|
|
39
|
+
"@photon-ai/slack": "^0.2.0",
|
|
29
40
|
"@photon-ai/whatsapp-business": "^0.1.1",
|
|
30
41
|
"@repeaterjs/repeater": "^3.0.6",
|
|
31
42
|
"better-grpc": "^0.3.2",
|