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.
@@ -1,58 +1,3 @@
1
- // src/content/poll.ts
2
- import z from "zod";
3
- var pollChoiceSchema = z.object({
4
- title: z.string().nonempty()
5
- });
6
- var pollSchema = z.object({
7
- type: z.literal("poll"),
8
- title: z.string().nonempty().max(300),
9
- options: z.array(pollChoiceSchema).min(2).max(10)
10
- });
11
- var pollOptionSchema = z.object({
12
- type: z.literal("poll_option"),
13
- option: pollChoiceSchema,
14
- poll: pollSchema,
15
- selected: z.boolean(),
16
- title: z.string().nonempty()
17
- }).superRefine((value, ctx) => {
18
- if (value.title !== value.option.title) {
19
- ctx.addIssue({
20
- code: "custom",
21
- message: "poll_option title must match option.title",
22
- path: ["title"]
23
- });
24
- }
25
- if (!value.poll.options.some(
26
- (pollOption) => pollOption.title === value.option.title
27
- )) {
28
- ctx.addIssue({
29
- code: "custom",
30
- message: "poll_option option must exist in poll.options",
31
- path: ["option"]
32
- });
33
- }
34
- });
35
- var asPoll = (input) => pollSchema.parse({ type: "poll", ...input });
36
- var asPollOption = (input) => pollOptionSchema.parse({
37
- type: "poll_option",
38
- ...input,
39
- title: input.option.title
40
- });
41
- var option = (title) => ({ title });
42
- var normalize = (raw) => typeof raw === "string" ? { title: raw } : { title: raw.title };
43
- var collectOptions = (args) => {
44
- const [first] = args;
45
- if (args.length === 1 && Array.isArray(first)) {
46
- return first;
47
- }
48
- return args;
49
- };
50
- function poll(title, ...rest) {
51
- return {
52
- build: async () => asPoll({ title, options: collectOptions(rest).map(normalize) })
53
- };
54
- }
55
-
56
1
  // src/utils/stream.ts
57
2
  import { Repeater } from "@repeaterjs/repeater";
58
3
  var ignoreCleanupError = () => void 0;
@@ -247,6 +192,10 @@ var cloud = {
247
192
  method: "POST",
248
193
  headers: { Authorization: basicAuth(projectId, projectSecret) }
249
194
  }),
195
+ issueSlackTokens: (projectId, projectSecret) => request(`/projects/${projectId}/slack/tokens`, {
196
+ method: "POST",
197
+ headers: { Authorization: basicAuth(projectId, projectSecret) }
198
+ }),
250
199
  getPlatforms: (projectId) => request(`/projects/${projectId}/platforms/`),
251
200
  togglePlatform: (projectId, projectSecret, platform, enabled) => request(`/projects/${projectId}/platforms/`, {
252
201
  method: "PATCH",
@@ -259,10 +208,6 @@ var cloud = {
259
208
  };
260
209
 
261
210
  export {
262
- asPoll,
263
- asPollOption,
264
- option,
265
- poll,
266
211
  stream,
267
212
  mergeStreams,
268
213
  broadcast,
package/dist/index.d.ts CHANGED
@@ -1,7 +1,8 @@
1
- import { C as ContentBuilder, U as User, M as Message, b as ContentInput, O as OutboundMessage, c as Content, d as ProviderMessage, E as EventProducer, e as CreateClientContext, f as Store, a as PlatformDef, P as Platform, g as PlatformProviderConfig, h as SpectrumLike, i as CustomEventStreams, j as Space, I as InboundMessage } from './types-lUyzRurY.js';
2
- export { A as AnyPlatformDef, B as Broadcaster, k as InboundPlatformMessage, l as ManagedStream, m as PlatformInstance, n as PlatformMessage, o as PlatformRuntime, p as PlatformSpace, q as PlatformUser, S as SchemaMessage, r as broadcast, s as mergeStreams, t as stream } from './types-lUyzRurY.js';
3
- import vCard from 'vcf';
1
+ import { C as ContentBuilder, U as User, M as Message, b as Space, c as ContentInput, d as Content, e as ProviderMessage, E as EventProducer, f as SpaceActionFn, g as MessageActionFn, h as CreateClientContext, i as Store, a as PlatformDef, P as Platform, j as PlatformProviderConfig, k as SpectrumLike, l as CustomEventStreams, A as AgentSender } from './types-BzW4gInA.js';
2
+ export { m as AnyPlatformDef, B as Broadcaster, n as ManagedStream, o as PlatformInstance, p as PlatformMessage, q as PlatformRuntime, r as PlatformSpace, s as PlatformUser, S as SchemaMessage, t as broadcast, u as mergeStreams, v as stream } from './types-BzW4gInA.js';
4
3
  import z__default from 'zod';
4
+ import { P as PhotoInput } from './photo-content-BQF42prd.js';
5
+ import vCard from 'vcf';
5
6
  import 'hotscript';
6
7
 
7
8
  declare function attachment(input: string | Buffer, options?: {
@@ -9,6 +10,49 @@ declare function attachment(input: string | Buffer, options?: {
9
10
  name?: string;
10
11
  }): ContentBuilder;
11
12
 
13
+ /**
14
+ * Set or clear the chat avatar (group icon). Universal content — providers
15
+ * dispatch by `content.type === "avatar"` in their `send` action and decide
16
+ * their own support story (e.g. iMessage only supports it for remote group
17
+ * chats).
18
+ *
19
+ * `space.send(avatar(...))` is the canonical form; `space.avatar(...)` is
20
+ * universal sugar that delegates here. Per-platform constraints (e.g.
21
+ * group-only, remote-only) surface as `UnsupportedError` from the provider's
22
+ * `send` action so the canonical and sugar forms share one error path.
23
+ */
24
+ declare const avatarSchema: z__default.ZodObject<{
25
+ type: z__default.ZodLiteral<"avatar">;
26
+ action: z__default.ZodDiscriminatedUnion<[z__default.ZodObject<{
27
+ kind: z__default.ZodLiteral<"set">;
28
+ read: z__default.ZodFunction<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
29
+ mimeType: z__default.ZodString;
30
+ }, z__default.core.$strip>, z__default.ZodObject<{
31
+ kind: z__default.ZodLiteral<"clear">;
32
+ }, z__default.core.$strip>], "kind">;
33
+ }, z__default.core.$strip>;
34
+ type Avatar = z__default.infer<typeof avatarSchema>;
35
+ type AvatarInput = PhotoInput;
36
+ /**
37
+ * Build an `Avatar` content value.
38
+ *
39
+ * - `avatar("clear")` — remove the current chat avatar.
40
+ * - `avatar("./icon.png")` — set avatar from a filesystem path. MIME type is
41
+ * inferred from the extension; override with `options.mimeType`.
42
+ * - `avatar(buffer, { mimeType })` — set avatar from in-memory bytes.
43
+ * `options.mimeType` is required (enforced at the type level).
44
+ *
45
+ * `"clear"` is a reserved string-literal sentinel. If you have a file
46
+ * literally named `clear` with no extension, pass `"./clear"` or load it as a
47
+ * Buffer.
48
+ */
49
+ declare function avatar(input: string, options?: {
50
+ mimeType?: string;
51
+ }): ContentBuilder;
52
+ declare function avatar(input: Buffer, options: {
53
+ mimeType: string;
54
+ }): ContentBuilder;
55
+
12
56
  declare const nameSchema: z__default.ZodObject<{
13
57
  formatted: z__default.ZodOptional<z__default.ZodString>;
14
58
  first: z__default.ZodOptional<z__default.ZodString>;
@@ -130,11 +174,34 @@ declare function custom(raw: unknown): ContentBuilder;
130
174
  * them inside their `send` action and the resolved value is `undefined`
131
175
  * (no new message id is produced; the existing message mutates in place).
132
176
  *
133
- * Edit cannot wrap `edit`, `reply`, `reaction`, `group`, or `typing`.
177
+ * Edit cannot wrap `edit`, `reply`, `reaction`, `group`, `typing`, `rename`,
178
+ * or `avatar` content.
134
179
  */
135
180
  declare const editSchema: z__default.ZodObject<{
136
181
  type: z__default.ZodLiteral<"edit">;
137
182
  content: z__default.ZodCustom<{
183
+ type: "avatar";
184
+ action: {
185
+ kind: "set";
186
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
187
+ mimeType: string;
188
+ } | {
189
+ kind: "clear";
190
+ };
191
+ } | {
192
+ type: "text";
193
+ text: string;
194
+ } | {
195
+ type: "attachment";
196
+ name: string;
197
+ mimeType: string;
198
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
199
+ stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
200
+ size?: number | undefined;
201
+ } | {
202
+ type: "custom";
203
+ raw: unknown;
204
+ } | {
138
205
  type: "contact";
139
206
  user?: {
140
207
  __platform: string;
@@ -177,19 +244,6 @@ declare const editSchema: z__default.ZodObject<{
177
244
  read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
178
245
  } | undefined;
179
246
  raw?: unknown;
180
- } | {
181
- type: "text";
182
- text: string;
183
- } | {
184
- type: "attachment";
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: "custom";
192
- raw: unknown;
193
247
  } | {
194
248
  type: "voice";
195
249
  mimeType: string;
@@ -211,10 +265,10 @@ declare const editSchema: z__default.ZodObject<{
211
265
  } | {
212
266
  type: "reaction";
213
267
  emoji: string;
214
- target: Message;
268
+ target: Message<string, User, Space<unknown>>;
215
269
  } | {
216
270
  type: "group";
217
- items: Message[];
271
+ items: Message<string, User, Space<unknown>>[];
218
272
  } | {
219
273
  type: "poll";
220
274
  title: string;
@@ -252,7 +306,32 @@ declare const editSchema: z__default.ZodObject<{
252
306
  } | {
253
307
  type: "typing";
254
308
  state: "start" | "stop";
309
+ } | {
310
+ type: "rename";
311
+ displayName: string;
255
312
  }, {
313
+ type: "avatar";
314
+ action: {
315
+ kind: "set";
316
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
317
+ mimeType: string;
318
+ } | {
319
+ kind: "clear";
320
+ };
321
+ } | {
322
+ type: "text";
323
+ text: string;
324
+ } | {
325
+ type: "attachment";
326
+ name: string;
327
+ mimeType: string;
328
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
329
+ stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
330
+ size?: number | undefined;
331
+ } | {
332
+ type: "custom";
333
+ raw: unknown;
334
+ } | {
256
335
  type: "contact";
257
336
  user?: {
258
337
  __platform: string;
@@ -295,19 +374,6 @@ declare const editSchema: z__default.ZodObject<{
295
374
  read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
296
375
  } | undefined;
297
376
  raw?: unknown;
298
- } | {
299
- type: "text";
300
- text: string;
301
- } | {
302
- type: "attachment";
303
- name: string;
304
- mimeType: string;
305
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
306
- stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
307
- size?: number | undefined;
308
- } | {
309
- type: "custom";
310
- raw: unknown;
311
377
  } | {
312
378
  type: "voice";
313
379
  mimeType: string;
@@ -329,10 +395,10 @@ declare const editSchema: z__default.ZodObject<{
329
395
  } | {
330
396
  type: "reaction";
331
397
  emoji: string;
332
- target: Message;
398
+ target: Message<string, User, Space<unknown>>;
333
399
  } | {
334
400
  type: "group";
335
- items: Message[];
401
+ items: Message<string, User, Space<unknown>>[];
336
402
  } | {
337
403
  type: "poll";
338
404
  title: string;
@@ -370,19 +436,21 @@ declare const editSchema: z__default.ZodObject<{
370
436
  } | {
371
437
  type: "typing";
372
438
  state: "start" | "stop";
439
+ } | {
440
+ type: "rename";
441
+ displayName: string;
373
442
  }>;
374
- target: z__default.ZodCustom<Message, Message>;
443
+ target: z__default.ZodCustom<Message<string, User, Space<unknown>>, Message<string, User, Space<unknown>>>;
375
444
  }, z__default.core.$strip>;
376
445
  type Edit = z__default.infer<typeof editSchema>;
377
446
  /**
378
447
  * Construct an `edit` content value rewriting `target`'s content.
379
448
  *
380
- * `target` is typed as `OutboundMessage` because only messages you sent can
381
- * be edited; the schema field stays loose at `Message` (matching
382
- * reply/reaction) so providers receive the same shape regardless of
383
- * direction.
449
+ * Only outbound messages (those sent by the agent) can be edited; calling
450
+ * this with an inbound target throws at build time so the misuse surfaces
451
+ * before the send pipeline runs.
384
452
  */
385
- declare function edit(content: ContentInput, target: OutboundMessage): ContentBuilder;
453
+ declare function edit(content: ContentInput, target: Message): ContentBuilder;
386
454
 
387
455
  /**
388
456
  * A `group` bundles multiple messages into one logical unit (e.g. an album
@@ -395,7 +463,7 @@ declare function edit(content: ContentInput, target: OutboundMessage): ContentBu
395
463
  */
396
464
  declare const groupSchema: z__default.ZodObject<{
397
465
  type: z__default.ZodLiteral<"group">;
398
- items: z__default.ZodArray<z__default.ZodCustom<Message, Message>>;
466
+ items: z__default.ZodArray<z__default.ZodCustom<Message<string, User, Space<unknown>>, Message<string, User, Space<unknown>>>>;
399
467
  }, z__default.core.$strip>;
400
468
  type Group = z__default.infer<typeof groupSchema>;
401
469
  declare function group(...items: [ContentInput, ContentInput, ...ContentInput[]]): ContentBuilder;
@@ -438,21 +506,41 @@ declare function poll(title: string, ...options: PollChoiceInput[]): ContentBuil
438
506
  declare const reactionSchema: z__default.ZodObject<{
439
507
  type: z__default.ZodLiteral<"reaction">;
440
508
  emoji: z__default.ZodString;
441
- target: z__default.ZodCustom<Message, Message>;
509
+ target: z__default.ZodCustom<Message<string, User, Space<unknown>>, Message<string, User, Space<unknown>>>;
442
510
  }, z__default.core.$strip>;
443
511
  type Reaction = z__default.infer<typeof reactionSchema>;
444
512
  /**
445
513
  * Construct a `reaction` content value targeting the given message.
446
514
  *
447
515
  * `space.send(reaction(emoji, message))` is sugar for `message.react(emoji)`.
448
- * Reactions are fire-and-forget — the returned `OutboundMessage` will be
449
- * `undefined` because platforms do not surface a message id for reactions.
516
+ * Reactions are fire-and-forget — the returned `Message` will be `undefined`
517
+ * because platforms do not surface a message id for reactions.
450
518
  *
451
519
  * To react to a message known only by id, resolve it first via
452
520
  * `space.getMessage(id)`.
453
521
  */
454
522
  declare function reaction(emoji: string, target: Message): ContentBuilder;
455
523
 
524
+ /**
525
+ * Rename the current chat. Universal content — providers dispatch by
526
+ * `content.type === "rename"` in their `send` action and decide their own
527
+ * support story (e.g. iMessage only supports it for remote group chats).
528
+ *
529
+ * `space.send(rename("New Name"))` is the canonical form; `space.rename(...)`
530
+ * is universal sugar that delegates here.
531
+ *
532
+ * Throws at build time if `displayName` is empty. Per-platform constraints
533
+ * (e.g. group-only, remote-only) surface as `UnsupportedError` from the
534
+ * provider's `send` action so the canonical and sugar forms share one
535
+ * error path.
536
+ */
537
+ declare const renameSchema: z__default.ZodObject<{
538
+ type: z__default.ZodLiteral<"rename">;
539
+ displayName: z__default.ZodString;
540
+ }, z__default.core.$strip>;
541
+ type Rename = z__default.infer<typeof renameSchema>;
542
+ declare function rename(displayName: string): ContentBuilder;
543
+
456
544
  /**
457
545
  * A `reply` wraps inner content with the message it replies to.
458
546
  *
@@ -460,11 +548,34 @@ declare function reaction(emoji: string, target: Message): ContentBuilder;
460
548
  * `message.reply(content)` is sugar that delegates here. Providers see
461
549
  * `reply` like any other content type and route to a threaded send.
462
550
  *
463
- * Reply cannot wrap `reply`, `reaction`, or `group` content.
551
+ * Reply cannot wrap `reply`, `edit`, `reaction`, `group`, `typing`, `rename`,
552
+ * or `avatar` content.
464
553
  */
465
554
  declare const replySchema: z__default.ZodObject<{
466
555
  type: z__default.ZodLiteral<"reply">;
467
556
  content: z__default.ZodCustom<{
557
+ type: "avatar";
558
+ action: {
559
+ kind: "set";
560
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
561
+ mimeType: string;
562
+ } | {
563
+ kind: "clear";
564
+ };
565
+ } | {
566
+ type: "text";
567
+ text: string;
568
+ } | {
569
+ type: "attachment";
570
+ name: string;
571
+ mimeType: string;
572
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
573
+ stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
574
+ size?: number | undefined;
575
+ } | {
576
+ type: "custom";
577
+ raw: unknown;
578
+ } | {
468
579
  type: "contact";
469
580
  user?: {
470
581
  __platform: string;
@@ -507,19 +618,6 @@ declare const replySchema: z__default.ZodObject<{
507
618
  read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
508
619
  } | undefined;
509
620
  raw?: unknown;
510
- } | {
511
- type: "text";
512
- text: string;
513
- } | {
514
- type: "attachment";
515
- name: string;
516
- mimeType: string;
517
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
518
- stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
519
- size?: number | undefined;
520
- } | {
521
- type: "custom";
522
- raw: unknown;
523
621
  } | {
524
622
  type: "voice";
525
623
  mimeType: string;
@@ -541,10 +639,10 @@ declare const replySchema: z__default.ZodObject<{
541
639
  } | {
542
640
  type: "reaction";
543
641
  emoji: string;
544
- target: Message;
642
+ target: Message<string, User, Space<unknown>>;
545
643
  } | {
546
644
  type: "group";
547
- items: Message[];
645
+ items: Message<string, User, Space<unknown>>[];
548
646
  } | {
549
647
  type: "poll";
550
648
  title: string;
@@ -582,7 +680,32 @@ declare const replySchema: z__default.ZodObject<{
582
680
  } | {
583
681
  type: "typing";
584
682
  state: "start" | "stop";
683
+ } | {
684
+ type: "rename";
685
+ displayName: string;
585
686
  }, {
687
+ type: "avatar";
688
+ action: {
689
+ kind: "set";
690
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
691
+ mimeType: string;
692
+ } | {
693
+ kind: "clear";
694
+ };
695
+ } | {
696
+ type: "text";
697
+ text: string;
698
+ } | {
699
+ type: "attachment";
700
+ name: string;
701
+ mimeType: string;
702
+ read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
703
+ stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
704
+ size?: number | undefined;
705
+ } | {
706
+ type: "custom";
707
+ raw: unknown;
708
+ } | {
586
709
  type: "contact";
587
710
  user?: {
588
711
  __platform: string;
@@ -625,19 +748,6 @@ declare const replySchema: z__default.ZodObject<{
625
748
  read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
626
749
  } | undefined;
627
750
  raw?: unknown;
628
- } | {
629
- type: "text";
630
- text: string;
631
- } | {
632
- type: "attachment";
633
- name: string;
634
- mimeType: string;
635
- read: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
636
- stream: z__default.core.$InferOuterFunctionType<z__default.ZodTuple<readonly [], null>, z__default.ZodPromise<z__default.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
637
- size?: number | undefined;
638
- } | {
639
- type: "custom";
640
- raw: unknown;
641
751
  } | {
642
752
  type: "voice";
643
753
  mimeType: string;
@@ -659,10 +769,10 @@ declare const replySchema: z__default.ZodObject<{
659
769
  } | {
660
770
  type: "reaction";
661
771
  emoji: string;
662
- target: Message;
772
+ target: Message<string, User, Space<unknown>>;
663
773
  } | {
664
774
  type: "group";
665
- items: Message[];
775
+ items: Message<string, User, Space<unknown>>[];
666
776
  } | {
667
777
  type: "poll";
668
778
  title: string;
@@ -700,8 +810,11 @@ declare const replySchema: z__default.ZodObject<{
700
810
  } | {
701
811
  type: "typing";
702
812
  state: "start" | "stop";
813
+ } | {
814
+ type: "rename";
815
+ displayName: string;
703
816
  }>;
704
- target: z__default.ZodCustom<Message, Message>;
817
+ target: z__default.ZodCustom<Message<string, User, Space<unknown>>, Message<string, User, Space<unknown>>>;
705
818
  }, z__default.core.$strip>;
706
819
  type Reply = z__default.infer<typeof replySchema>;
707
820
  declare function reply(content: ContentInput, target: Message): ContentBuilder;
@@ -2698,7 +2811,7 @@ declare function definePlatform<_Name extends string, _ConfigSchema extends z__d
2698
2811
  id: string;
2699
2812
  }, _MessageSchema extends z__default.ZodType<object> | undefined = undefined, _MessageType extends ProviderMessage<_ResolvedUser, _ResolvedSpace, _MessageSchema extends z__default.ZodType<object> ? z__default.infer<_MessageSchema> : Record<never, never>> = ProviderMessage<_ResolvedUser, _ResolvedSpace, _MessageSchema extends z__default.ZodType<object> ? z__default.infer<_MessageSchema> : Record<never, never>>, _Events extends (Record<string, EventProducer<unknown, _Client, z__default.infer<_ConfigSchema>>> & {
2700
2813
  messages?: never;
2701
- }) | undefined = undefined, _Static extends Record<string, unknown> = Record<never, never>>(name: _Name, def: {
2814
+ }) | undefined = undefined, _Static extends Record<string, unknown> = Record<never, never>, _SpaceActions extends Record<string, SpaceActionFn> = Record<never, never>, _MessageActions extends Record<string, MessageActionFn> = Record<never, never>>(name: _Name, def: {
2702
2815
  lifecycle: {
2703
2816
  createClient: (ctx: CreateClientContext<_ConfigSchema>) => Promise<_Client>;
2704
2817
  destroyClient?: (ctx: {
@@ -2706,16 +2819,16 @@ declare function definePlatform<_Name extends string, _ConfigSchema extends z__d
2706
2819
  store: Store;
2707
2820
  }) => Promise<void>;
2708
2821
  };
2709
- } & Omit<PlatformDef<_Name, _ConfigSchema, _UserSchema, _SpaceSchema, _SpaceParamsSchema, _Client, _ResolvedUser, _ResolvedSpace, _MessageSchema, _MessageType, _Events>, "lifecycle" | "name"> & {
2822
+ } & Omit<PlatformDef<_Name, _ConfigSchema, _UserSchema, _SpaceSchema, _SpaceParamsSchema, _Client, _ResolvedUser, _ResolvedSpace, _MessageSchema, _MessageType, _Events, _SpaceActions, _MessageActions>, "lifecycle" | "name"> & {
2710
2823
  static?: _Static;
2711
- }): Platform<PlatformDef<_Name, _ConfigSchema, _UserSchema, _SpaceSchema, _SpaceParamsSchema, _Client, _ResolvedUser, _ResolvedSpace, _MessageSchema, _MessageType, _Events>> & Readonly<_Static>;
2824
+ }): Platform<PlatformDef<_Name, _ConfigSchema, _UserSchema, _SpaceSchema, _SpaceParamsSchema, _Client, _ResolvedUser, _ResolvedSpace, _MessageSchema, _MessageType, _Events, _SpaceActions, _MessageActions>> & Readonly<_Static>;
2712
2825
 
2713
2826
  type SpectrumInstance<Providers extends PlatformProviderConfig[] = PlatformProviderConfig[]> = SpectrumLike<Providers> & CustomEventStreams<Providers> & {
2714
- readonly messages: AsyncIterable<[Space, InboundMessage]>;
2827
+ readonly messages: AsyncIterable<[Space, Message]>;
2715
2828
  stop(): Promise<void>;
2716
- send(space: Space, content: ContentInput): Promise<OutboundMessage | undefined>;
2717
- send(space: Space, ...content: [ContentInput, ContentInput, ...ContentInput[]]): Promise<OutboundMessage[]>;
2718
- edit(message: OutboundMessage, newContent: ContentInput): Promise<void>;
2829
+ send(space: Space, content: ContentInput): Promise<Message<string, AgentSender> | undefined>;
2830
+ send(space: Space, ...content: [ContentInput, ContentInput, ...ContentInput[]]): Promise<Message<string, AgentSender>[]>;
2831
+ edit(message: Message, newContent: ContentInput): Promise<void>;
2719
2832
  responding<T>(space: Space, fn: () => T | Promise<T>): Promise<T>;
2720
2833
  };
2721
2834
  /**
@@ -2765,7 +2878,7 @@ interface DedicatedTokenData {
2765
2878
  type: "dedicated";
2766
2879
  }
2767
2880
  type TokenData = SharedTokenData | DedicatedTokenData;
2768
- type CloudPlatform = "imessage" | "whatsapp_business";
2881
+ type CloudPlatform = "imessage" | "whatsapp_business" | "slack";
2769
2882
  interface PlatformStatus {
2770
2883
  enabled: boolean;
2771
2884
  }
@@ -2778,6 +2891,17 @@ interface WhatsappBusinessTokenData {
2778
2891
  expiresIn: number;
2779
2892
  numbers: Record<string, string | null>;
2780
2893
  }
2894
+ interface SlackTeamMeta {
2895
+ appId: string;
2896
+ botUserId: string;
2897
+ grantedScopes: string[];
2898
+ teamName: string;
2899
+ }
2900
+ interface SlackTokenData {
2901
+ auth: Record<string, string>;
2902
+ expiresIn: number;
2903
+ teams: Record<string, SlackTeamMeta>;
2904
+ }
2781
2905
  declare class SpectrumCloudError extends Error {
2782
2906
  readonly status: number;
2783
2907
  readonly code: string;
@@ -2788,6 +2912,7 @@ declare const cloud: {
2788
2912
  issueImessageTokens: (projectId: string, projectSecret: string) => Promise<TokenData>;
2789
2913
  getImessageInfo: (projectId: string) => Promise<ImessageInfoData>;
2790
2914
  issueWhatsappBusinessTokens: (projectId: string, projectSecret: string) => Promise<WhatsappBusinessTokenData>;
2915
+ issueSlackTokens: (projectId: string, projectSecret: string) => Promise<SlackTokenData>;
2791
2916
  getPlatforms: (projectId: string) => Promise<PlatformsData>;
2792
2917
  togglePlatform: (projectId: string, projectSecret: string, platform: CloudPlatform, enabled: boolean) => Promise<PlatformsData>;
2793
2918
  };
@@ -2815,4 +2940,4 @@ declare class UnsupportedError extends Error {
2815
2940
  declare const fromVCard: (vcf: string) => ContactInput;
2816
2941
  declare const toVCard: (contact: Contact) => Promise<string>;
2817
2942
 
2818
- export { type CloudPlatform, type Contact, type ContactAddress, type ContactDetails, type ContactEmail, type ContactInput, type ContactName, type ContactOrg, type ContactPhone, Content, ContentBuilder, ContentInput, type DedicatedTokenData, type Edit, Emoji, type EmojiKey, EventProducer, type Group, type ImessageInfoData, Message, Platform, PlatformDef, PlatformProviderConfig, type PlatformStatus, type PlatformsData, type Poll, type PollChoice, type PollChoiceInput, type PollOption, type Reaction, type Reply, type Richlink, type SharedTokenData, Space, Spectrum, SpectrumCloudError, type SpectrumInstance, type SubscriptionData, type SubscriptionStatus, type TokenData, type Typing, UnsupportedError, type UnsupportedKind, User, type Voice, attachment, cloud, contact, custom, definePlatform, edit, fromVCard, group, option, poll, reaction, reply, resolveContents, richlink, text, toVCard, typing, voice };
2943
+ export { AgentSender, type Avatar, type AvatarInput, type CloudPlatform, type Contact, type ContactAddress, type ContactDetails, type ContactEmail, type ContactInput, type ContactName, type ContactOrg, type ContactPhone, Content, ContentBuilder, ContentInput, type DedicatedTokenData, type Edit, Emoji, type EmojiKey, EventProducer, type Group, type ImessageInfoData, Message, Platform, PlatformDef, PlatformProviderConfig, type PlatformStatus, type PlatformsData, type Poll, type PollChoice, type PollChoiceInput, type PollOption, type Reaction, type Rename, type Reply, type Richlink, type SharedTokenData, type SlackTeamMeta, type SlackTokenData, Space, Spectrum, SpectrumCloudError, type SpectrumInstance, type SubscriptionData, type SubscriptionStatus, type TokenData, type Typing, UnsupportedError, type UnsupportedKind, User, type Voice, attachment, avatar, cloud, contact, custom, definePlatform, edit, fromVCard, group, option, poll, reaction, rename, reply, resolveContents, richlink, text, toVCard, typing, voice };
package/dist/index.js CHANGED
@@ -1,38 +1,44 @@
1
1
  import {
2
2
  group,
3
3
  richlink
4
- } from "./chunk-5NHNMN4H.js";
4
+ } from "./chunk-UFJZIZDO.js";
5
5
  import {
6
6
  voice
7
- } from "./chunk-TN54TDTQ.js";
7
+ } from "./chunk-4TXLNBGE.js";
8
+ import {
9
+ option,
10
+ poll
11
+ } from "./chunk-KO67KDBD.js";
8
12
  import {
9
13
  SpectrumCloudError,
10
14
  broadcast,
11
15
  cloud,
12
16
  mergeStreams,
13
- option,
14
- poll,
15
17
  stream
16
- } from "./chunk-HWADNTQF.js";
18
+ } from "./chunk-YKWKZ2PZ.js";
19
+ import {
20
+ contact,
21
+ fromVCard,
22
+ toVCard
23
+ } from "./chunk-L3VXHUVY.js";
17
24
  import {
18
25
  UnsupportedError,
19
26
  attachment,
27
+ avatar,
20
28
  buildSpace,
21
- contact,
22
29
  contentAttrs,
23
30
  custom,
24
31
  definePlatform,
25
32
  edit,
26
- fromVCard,
27
33
  reaction,
34
+ rename,
28
35
  reply,
29
36
  resolveContents,
30
37
  senderAttrs,
31
38
  text,
32
- toVCard,
33
39
  typing,
34
40
  wrapProviderMessage
35
- } from "./chunk-XZSBR26X.js";
41
+ } from "./chunk-YDHES53X.js";
36
42
 
37
43
  // src/emoji/generated.ts
38
44
  var GeneratedEmoji = {
@@ -2385,6 +2391,7 @@ export {
2385
2391
  SpectrumCloudError,
2386
2392
  UnsupportedError,
2387
2393
  attachment,
2394
+ avatar,
2388
2395
  broadcast,
2389
2396
  cloud,
2390
2397
  contact,
@@ -2397,6 +2404,7 @@ export {
2397
2404
  option,
2398
2405
  poll,
2399
2406
  reaction,
2407
+ rename,
2400
2408
  reply,
2401
2409
  resolveContents,
2402
2410
  richlink,
@@ -0,0 +1,13 @@
1
+ /**
2
+ * Shared building blocks for photo-style content (chat background, group
3
+ * avatar/icon, …) whose builders all share the same `set | clear` shape and
4
+ * the same `"clear"` reserved-string sentinel.
5
+ *
6
+ * Keeping the action schema and `buildPhotoAction` factory here means both
7
+ * `background()` and `avatar()` parse against the same structural definition
8
+ * and any DX fix (mime inference, read caching, sentinel docs) lands once.
9
+ */
10
+ declare const CLEAR_SENTINEL: "clear";
11
+ type PhotoInput = typeof CLEAR_SENTINEL | string | Buffer;
12
+
13
+ export type { PhotoInput as P };