@spectrum-ts/core 12.0.0 → 12.1.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.
@@ -642,29 +642,18 @@ declare const editSchema: z.ZodObject<{
642
642
  read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
643
643
  stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
644
644
  size?: number | undefined;
645
- } | {
646
- type: "poll";
647
- title: string;
648
- options: {
649
- title: string;
650
- }[];
651
- } | {
652
- type: "poll_option";
653
- option: {
654
- title: string;
655
- };
656
- poll: {
657
- type: "poll";
658
- title: string;
659
- options: {
660
- title: string;
661
- }[];
662
- };
663
- selected: boolean;
664
- title: string;
665
645
  } | {
666
646
  type: "custom";
667
647
  raw: unknown;
648
+ } | {
649
+ type: "voice";
650
+ mimeType: string;
651
+ read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
652
+ stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
653
+ id?: string | undefined;
654
+ name?: string | undefined;
655
+ duration?: number | undefined;
656
+ size?: number | undefined;
668
657
  } | {
669
658
  type: "text";
670
659
  text: string;
@@ -675,15 +664,6 @@ declare const editSchema: z.ZodObject<{
675
664
  type: "streamText";
676
665
  stream: () => AsyncIterable<string>;
677
666
  format?: "markdown" | "plain" | undefined;
678
- } | {
679
- type: "voice";
680
- mimeType: string;
681
- read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
682
- stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
683
- id?: string | undefined;
684
- name?: string | undefined;
685
- duration?: number | undefined;
686
- size?: number | undefined;
687
667
  } | {
688
668
  type: "richlink";
689
669
  url: string;
@@ -708,6 +688,26 @@ declare const editSchema: z.ZodObject<{
708
688
  } | {
709
689
  type: "group";
710
690
  items: Message<string, User, Space<unknown>>[];
691
+ } | {
692
+ type: "poll";
693
+ title: string;
694
+ options: {
695
+ title: string;
696
+ }[];
697
+ } | {
698
+ type: "poll_option";
699
+ option: {
700
+ title: string;
701
+ };
702
+ poll: {
703
+ type: "poll";
704
+ title: string;
705
+ options: {
706
+ title: string;
707
+ }[];
708
+ };
709
+ selected: boolean;
710
+ title: string;
711
711
  } | {
712
712
  type: "effect";
713
713
  content: {
@@ -800,29 +800,18 @@ declare const editSchema: z.ZodObject<{
800
800
  read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
801
801
  stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
802
802
  size?: number | undefined;
803
- } | {
804
- type: "poll";
805
- title: string;
806
- options: {
807
- title: string;
808
- }[];
809
- } | {
810
- type: "poll_option";
811
- option: {
812
- title: string;
813
- };
814
- poll: {
815
- type: "poll";
816
- title: string;
817
- options: {
818
- title: string;
819
- }[];
820
- };
821
- selected: boolean;
822
- title: string;
823
803
  } | {
824
804
  type: "custom";
825
805
  raw: unknown;
806
+ } | {
807
+ type: "voice";
808
+ mimeType: string;
809
+ read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
810
+ stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
811
+ id?: string | undefined;
812
+ name?: string | undefined;
813
+ duration?: number | undefined;
814
+ size?: number | undefined;
826
815
  } | {
827
816
  type: "text";
828
817
  text: string;
@@ -833,15 +822,6 @@ declare const editSchema: z.ZodObject<{
833
822
  type: "streamText";
834
823
  stream: () => AsyncIterable<string>;
835
824
  format?: "markdown" | "plain" | undefined;
836
- } | {
837
- type: "voice";
838
- mimeType: string;
839
- read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
840
- stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
841
- id?: string | undefined;
842
- name?: string | undefined;
843
- duration?: number | undefined;
844
- size?: number | undefined;
845
825
  } | {
846
826
  type: "richlink";
847
827
  url: string;
@@ -866,6 +846,26 @@ declare const editSchema: z.ZodObject<{
866
846
  } | {
867
847
  type: "group";
868
848
  items: Message<string, User, Space<unknown>>[];
849
+ } | {
850
+ type: "poll";
851
+ title: string;
852
+ options: {
853
+ title: string;
854
+ }[];
855
+ } | {
856
+ type: "poll_option";
857
+ option: {
858
+ title: string;
859
+ };
860
+ poll: {
861
+ type: "poll";
862
+ title: string;
863
+ options: {
864
+ title: string;
865
+ }[];
866
+ };
867
+ selected: boolean;
868
+ title: string;
869
869
  } | {
870
870
  type: "effect";
871
871
  content: {
@@ -1188,29 +1188,18 @@ declare const replySchema: z.ZodObject<{
1188
1188
  read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
1189
1189
  stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
1190
1190
  size?: number | undefined;
1191
- } | {
1192
- type: "poll";
1193
- title: string;
1194
- options: {
1195
- title: string;
1196
- }[];
1197
- } | {
1198
- type: "poll_option";
1199
- option: {
1200
- title: string;
1201
- };
1202
- poll: {
1203
- type: "poll";
1204
- title: string;
1205
- options: {
1206
- title: string;
1207
- }[];
1208
- };
1209
- selected: boolean;
1210
- title: string;
1211
1191
  } | {
1212
1192
  type: "custom";
1213
1193
  raw: unknown;
1194
+ } | {
1195
+ type: "voice";
1196
+ mimeType: string;
1197
+ read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
1198
+ stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
1199
+ id?: string | undefined;
1200
+ name?: string | undefined;
1201
+ duration?: number | undefined;
1202
+ size?: number | undefined;
1214
1203
  } | {
1215
1204
  type: "text";
1216
1205
  text: string;
@@ -1221,15 +1210,6 @@ declare const replySchema: z.ZodObject<{
1221
1210
  type: "streamText";
1222
1211
  stream: () => AsyncIterable<string>;
1223
1212
  format?: "markdown" | "plain" | undefined;
1224
- } | {
1225
- type: "voice";
1226
- mimeType: string;
1227
- read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
1228
- stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
1229
- id?: string | undefined;
1230
- name?: string | undefined;
1231
- duration?: number | undefined;
1232
- size?: number | undefined;
1233
1213
  } | {
1234
1214
  type: "richlink";
1235
1215
  url: string;
@@ -1254,6 +1234,26 @@ declare const replySchema: z.ZodObject<{
1254
1234
  } | {
1255
1235
  type: "group";
1256
1236
  items: Message<string, User, Space<unknown>>[];
1237
+ } | {
1238
+ type: "poll";
1239
+ title: string;
1240
+ options: {
1241
+ title: string;
1242
+ }[];
1243
+ } | {
1244
+ type: "poll_option";
1245
+ option: {
1246
+ title: string;
1247
+ };
1248
+ poll: {
1249
+ type: "poll";
1250
+ title: string;
1251
+ options: {
1252
+ title: string;
1253
+ }[];
1254
+ };
1255
+ selected: boolean;
1256
+ title: string;
1257
1257
  } | {
1258
1258
  type: "effect";
1259
1259
  content: {
@@ -1346,29 +1346,18 @@ declare const replySchema: z.ZodObject<{
1346
1346
  read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
1347
1347
  stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
1348
1348
  size?: number | undefined;
1349
- } | {
1350
- type: "poll";
1351
- title: string;
1352
- options: {
1353
- title: string;
1354
- }[];
1355
- } | {
1356
- type: "poll_option";
1357
- option: {
1358
- title: string;
1359
- };
1360
- poll: {
1361
- type: "poll";
1362
- title: string;
1363
- options: {
1364
- title: string;
1365
- }[];
1366
- };
1367
- selected: boolean;
1368
- title: string;
1369
1349
  } | {
1370
1350
  type: "custom";
1371
1351
  raw: unknown;
1352
+ } | {
1353
+ type: "voice";
1354
+ mimeType: string;
1355
+ read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
1356
+ stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
1357
+ id?: string | undefined;
1358
+ name?: string | undefined;
1359
+ duration?: number | undefined;
1360
+ size?: number | undefined;
1372
1361
  } | {
1373
1362
  type: "text";
1374
1363
  text: string;
@@ -1379,15 +1368,6 @@ declare const replySchema: z.ZodObject<{
1379
1368
  type: "streamText";
1380
1369
  stream: () => AsyncIterable<string>;
1381
1370
  format?: "markdown" | "plain" | undefined;
1382
- } | {
1383
- type: "voice";
1384
- mimeType: string;
1385
- read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
1386
- stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
1387
- id?: string | undefined;
1388
- name?: string | undefined;
1389
- duration?: number | undefined;
1390
- size?: number | undefined;
1391
1371
  } | {
1392
1372
  type: "richlink";
1393
1373
  url: string;
@@ -1412,6 +1392,26 @@ declare const replySchema: z.ZodObject<{
1412
1392
  } | {
1413
1393
  type: "group";
1414
1394
  items: Message<string, User, Space<unknown>>[];
1395
+ } | {
1396
+ type: "poll";
1397
+ title: string;
1398
+ options: {
1399
+ title: string;
1400
+ }[];
1401
+ } | {
1402
+ type: "poll_option";
1403
+ option: {
1404
+ title: string;
1405
+ };
1406
+ poll: {
1407
+ type: "poll";
1408
+ title: string;
1409
+ options: {
1410
+ title: string;
1411
+ }[];
1412
+ };
1413
+ selected: boolean;
1414
+ title: string;
1415
1415
  } | {
1416
1416
  type: "effect";
1417
1417
  content: {
@@ -6786,7 +6786,7 @@ declare function definePlatform<_Name extends string, _ConfigSchema extends z.Zo
6786
6786
  id: string;
6787
6787
  }, _MessageSchema extends z.ZodType<object> | undefined = undefined, _MessageType extends ProviderMessage<_ResolvedUser, _ResolvedSpace, _MessageSchema extends z.ZodType<object> ? z.infer<_MessageSchema> : Record<never, never>> = ProviderMessage<_ResolvedUser, _ResolvedSpace, _MessageSchema extends z.ZodType<object> ? z.infer<_MessageSchema> : Record<never, never>>, _Events extends (Record<string, EventProducer<unknown, _Client, z.infer<_ConfigSchema>>> & {
6788
6788
  messages?: never;
6789
- }) | 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>, _Actions extends Record<string, InstanceActionFn> = Record<never, never>>(name: _Name, def: {
6789
+ }) | 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>, _Actions extends Record<string, InstanceActionFn> = Record<never, never>>(platformId: _Name, def: {
6790
6790
  lifecycle: {
6791
6791
  createClient: (ctx: CreateClientContext<_ConfigSchema>) => Promise<_Client>;
6792
6792
  destroyClient?: (ctx: {
@@ -6803,7 +6803,7 @@ declare function definePlatform<_Name extends string, _ConfigSchema extends z.Zo
6803
6803
  id: string;
6804
6804
  }, _MessageSchema extends z.ZodType<object> | undefined = undefined, _FusorEvents extends (Record<string, z.ZodType<object>> & {
6805
6805
  messages?: never;
6806
- }) | 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: Omit<PlatformDef<_Name, _ConfigSchema, _UserSchema, _SpaceSchema, _SpaceParamsSchema, FusorClient<_TPayload>, _ResolvedUser, _ResolvedSpace, _MessageSchema, ProviderMessage<_ResolvedUser, _ResolvedSpace, _MessageSchema extends z.ZodType<object> ? z.infer<_MessageSchema> : Record<never, never>>, _FusorEvents, _SpaceActions, _MessageActions>, "lifecycle" | "name" | "messages"> & {
6806
+ }) | 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>>(platformId: _Name, def: Omit<PlatformDef<_Name, _ConfigSchema, _UserSchema, _SpaceSchema, _SpaceParamsSchema, FusorClient<_TPayload>, _ResolvedUser, _ResolvedSpace, _MessageSchema, ProviderMessage<_ResolvedUser, _ResolvedSpace, _MessageSchema extends z.ZodType<object> ? z.infer<_MessageSchema> : Record<never, never>>, _FusorEvents, _SpaceActions, _MessageActions>, "lifecycle" | "name" | "messages"> & {
6807
6807
  lifecycle: {
6808
6808
  createClient: (ctx: CreateClientContext<_ConfigSchema>) => Promise<FusorClient<_TPayload>>;
6809
6809
  destroyClient?: (ctx: {
@@ -7333,29 +7333,18 @@ declare const contentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
7333
7333
  read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
7334
7334
  stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
7335
7335
  size?: number | undefined;
7336
- } | {
7337
- type: "poll";
7338
- title: string;
7339
- options: {
7340
- title: string;
7341
- }[];
7342
- } | {
7343
- type: "poll_option";
7344
- option: {
7345
- title: string;
7346
- };
7347
- poll: {
7348
- type: "poll";
7349
- title: string;
7350
- options: {
7351
- title: string;
7352
- }[];
7353
- };
7354
- selected: boolean;
7355
- title: string;
7356
7336
  } | {
7357
7337
  type: "custom";
7358
7338
  raw: unknown;
7339
+ } | {
7340
+ type: "voice";
7341
+ mimeType: string;
7342
+ read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
7343
+ stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
7344
+ id?: string | undefined;
7345
+ name?: string | undefined;
7346
+ duration?: number | undefined;
7347
+ size?: number | undefined;
7359
7348
  } | {
7360
7349
  type: "text";
7361
7350
  text: string;
@@ -7366,15 +7355,6 @@ declare const contentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
7366
7355
  type: "streamText";
7367
7356
  stream: () => AsyncIterable<string>;
7368
7357
  format?: "markdown" | "plain" | undefined;
7369
- } | {
7370
- type: "voice";
7371
- mimeType: string;
7372
- read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
7373
- stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
7374
- id?: string | undefined;
7375
- name?: string | undefined;
7376
- duration?: number | undefined;
7377
- size?: number | undefined;
7378
7358
  } | {
7379
7359
  type: "richlink";
7380
7360
  url: string;
@@ -7399,6 +7379,26 @@ declare const contentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
7399
7379
  } | {
7400
7380
  type: "group";
7401
7381
  items: Message<string, User, Space<unknown>>[];
7382
+ } | {
7383
+ type: "poll";
7384
+ title: string;
7385
+ options: {
7386
+ title: string;
7387
+ }[];
7388
+ } | {
7389
+ type: "poll_option";
7390
+ option: {
7391
+ title: string;
7392
+ };
7393
+ poll: {
7394
+ type: "poll";
7395
+ title: string;
7396
+ options: {
7397
+ title: string;
7398
+ }[];
7399
+ };
7400
+ selected: boolean;
7401
+ title: string;
7402
7402
  } | {
7403
7403
  type: "effect";
7404
7404
  content: {
@@ -7491,29 +7491,18 @@ declare const contentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
7491
7491
  read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
7492
7492
  stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
7493
7493
  size?: number | undefined;
7494
- } | {
7495
- type: "poll";
7496
- title: string;
7497
- options: {
7498
- title: string;
7499
- }[];
7500
- } | {
7501
- type: "poll_option";
7502
- option: {
7503
- title: string;
7504
- };
7505
- poll: {
7506
- type: "poll";
7507
- title: string;
7508
- options: {
7509
- title: string;
7510
- }[];
7511
- };
7512
- selected: boolean;
7513
- title: string;
7514
7494
  } | {
7515
7495
  type: "custom";
7516
7496
  raw: unknown;
7497
+ } | {
7498
+ type: "voice";
7499
+ mimeType: string;
7500
+ read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
7501
+ stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
7502
+ id?: string | undefined;
7503
+ name?: string | undefined;
7504
+ duration?: number | undefined;
7505
+ size?: number | undefined;
7517
7506
  } | {
7518
7507
  type: "text";
7519
7508
  text: string;
@@ -7524,15 +7513,6 @@ declare const contentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
7524
7513
  type: "streamText";
7525
7514
  stream: () => AsyncIterable<string>;
7526
7515
  format?: "markdown" | "plain" | undefined;
7527
- } | {
7528
- type: "voice";
7529
- mimeType: string;
7530
- read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
7531
- stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
7532
- id?: string | undefined;
7533
- name?: string | undefined;
7534
- duration?: number | undefined;
7535
- size?: number | undefined;
7536
7516
  } | {
7537
7517
  type: "richlink";
7538
7518
  url: string;
@@ -7557,6 +7537,26 @@ declare const contentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
7557
7537
  } | {
7558
7538
  type: "group";
7559
7539
  items: Message<string, User, Space<unknown>>[];
7540
+ } | {
7541
+ type: "poll";
7542
+ title: string;
7543
+ options: {
7544
+ title: string;
7545
+ }[];
7546
+ } | {
7547
+ type: "poll_option";
7548
+ option: {
7549
+ title: string;
7550
+ };
7551
+ poll: {
7552
+ type: "poll";
7553
+ title: string;
7554
+ options: {
7555
+ title: string;
7556
+ }[];
7557
+ };
7558
+ selected: boolean;
7559
+ title: string;
7560
7560
  } | {
7561
7561
  type: "effect";
7562
7562
  content: {
@@ -7653,29 +7653,18 @@ declare const contentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
7653
7653
  read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
7654
7654
  stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
7655
7655
  size?: number | undefined;
7656
- } | {
7657
- type: "poll";
7658
- title: string;
7659
- options: {
7660
- title: string;
7661
- }[];
7662
- } | {
7663
- type: "poll_option";
7664
- option: {
7665
- title: string;
7666
- };
7667
- poll: {
7668
- type: "poll";
7669
- title: string;
7670
- options: {
7671
- title: string;
7672
- }[];
7673
- };
7674
- selected: boolean;
7675
- title: string;
7676
7656
  } | {
7677
7657
  type: "custom";
7678
7658
  raw: unknown;
7659
+ } | {
7660
+ type: "voice";
7661
+ mimeType: string;
7662
+ read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
7663
+ stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
7664
+ id?: string | undefined;
7665
+ name?: string | undefined;
7666
+ duration?: number | undefined;
7667
+ size?: number | undefined;
7679
7668
  } | {
7680
7669
  type: "text";
7681
7670
  text: string;
@@ -7686,15 +7675,6 @@ declare const contentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
7686
7675
  type: "streamText";
7687
7676
  stream: () => AsyncIterable<string>;
7688
7677
  format?: "markdown" | "plain" | undefined;
7689
- } | {
7690
- type: "voice";
7691
- mimeType: string;
7692
- read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
7693
- stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
7694
- id?: string | undefined;
7695
- name?: string | undefined;
7696
- duration?: number | undefined;
7697
- size?: number | undefined;
7698
7678
  } | {
7699
7679
  type: "richlink";
7700
7680
  url: string;
@@ -7719,6 +7699,26 @@ declare const contentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
7719
7699
  } | {
7720
7700
  type: "group";
7721
7701
  items: Message<string, User, Space<unknown>>[];
7702
+ } | {
7703
+ type: "poll";
7704
+ title: string;
7705
+ options: {
7706
+ title: string;
7707
+ }[];
7708
+ } | {
7709
+ type: "poll_option";
7710
+ option: {
7711
+ title: string;
7712
+ };
7713
+ poll: {
7714
+ type: "poll";
7715
+ title: string;
7716
+ options: {
7717
+ title: string;
7718
+ }[];
7719
+ };
7720
+ selected: boolean;
7721
+ title: string;
7722
7722
  } | {
7723
7723
  type: "effect";
7724
7724
  content: {
@@ -7811,29 +7811,18 @@ declare const contentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
7811
7811
  read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
7812
7812
  stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
7813
7813
  size?: number | undefined;
7814
- } | {
7815
- type: "poll";
7816
- title: string;
7817
- options: {
7818
- title: string;
7819
- }[];
7820
- } | {
7821
- type: "poll_option";
7822
- option: {
7823
- title: string;
7824
- };
7825
- poll: {
7826
- type: "poll";
7827
- title: string;
7828
- options: {
7829
- title: string;
7830
- }[];
7831
- };
7832
- selected: boolean;
7833
- title: string;
7834
7814
  } | {
7835
7815
  type: "custom";
7836
7816
  raw: unknown;
7817
+ } | {
7818
+ type: "voice";
7819
+ mimeType: string;
7820
+ read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
7821
+ stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
7822
+ id?: string | undefined;
7823
+ name?: string | undefined;
7824
+ duration?: number | undefined;
7825
+ size?: number | undefined;
7837
7826
  } | {
7838
7827
  type: "text";
7839
7828
  text: string;
@@ -7844,15 +7833,6 @@ declare const contentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
7844
7833
  type: "streamText";
7845
7834
  stream: () => AsyncIterable<string>;
7846
7835
  format?: "markdown" | "plain" | undefined;
7847
- } | {
7848
- type: "voice";
7849
- mimeType: string;
7850
- read: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<Buffer<ArrayBufferLike>, Buffer<ArrayBufferLike>>>>;
7851
- stream: z.core.$InferOuterFunctionType<z.ZodTuple<readonly [], null>, z.ZodPromise<z.ZodCustom<ReadableStream<unknown>, ReadableStream<unknown>>>>;
7852
- id?: string | undefined;
7853
- name?: string | undefined;
7854
- duration?: number | undefined;
7855
- size?: number | undefined;
7856
7836
  } | {
7857
7837
  type: "richlink";
7858
7838
  url: string;
@@ -7877,6 +7857,26 @@ declare const contentSchema: z.ZodDiscriminatedUnion<[z.ZodObject<{
7877
7857
  } | {
7878
7858
  type: "group";
7879
7859
  items: Message<string, User, Space<unknown>>[];
7860
+ } | {
7861
+ type: "poll";
7862
+ title: string;
7863
+ options: {
7864
+ title: string;
7865
+ }[];
7866
+ } | {
7867
+ type: "poll_option";
7868
+ option: {
7869
+ title: string;
7870
+ };
7871
+ poll: {
7872
+ type: "poll";
7873
+ title: string;
7874
+ options: {
7875
+ title: string;
7876
+ }[];
7877
+ };
7878
+ selected: boolean;
7879
+ title: string;
7880
7880
  } | {
7881
7881
  type: "effect";
7882
7882
  content: {
@@ -1,4 +1,4 @@
1
- import { Cn as reactionSchema, Dt as asRichlink, Gn as photoActionSchema, Gt as asPollOption, H as ProviderMessageRecord, Hn as avatarSchema, It as renameSchema, Nt as replySchema, Pn as asContact, Rt as asRead, U as ProviderUserRecord, Un as PhotoInput, Wn as buildPhotoAction, Wt as asPoll, Yt as asMarkdown, _t as asVoice, bt as asUnsend, gn as leaveSpaceSchema, in as groupSchema, jt as asReply, mn as addMemberSchema, nn as asGroup, q as ManagedStream, r as asAttachment, vn as removeMemberSchema, wn as asCustom, wt as asText, xn as asReaction } from "./attachment-DN82cCAP.js";
1
+ import { Cn as reactionSchema, Dt as asRichlink, Gn as photoActionSchema, Gt as asPollOption, H as ProviderMessageRecord, Hn as avatarSchema, It as renameSchema, Nt as replySchema, Pn as asContact, Rt as asRead, U as ProviderUserRecord, Un as PhotoInput, Wn as buildPhotoAction, Wt as asPoll, Yt as asMarkdown, _t as asVoice, bt as asUnsend, gn as leaveSpaceSchema, in as groupSchema, jt as asReply, mn as addMemberSchema, nn as asGroup, q as ManagedStream, r as asAttachment, vn as removeMemberSchema, wn as asCustom, wt as asText, xn as asReaction } from "./attachment-CbNQEDfL.js";
2
2
  import z from "zod";
3
3
  import { FetchSpanOptions, LogAttrs, LogAttrs as LogAttrs$1, LogLevel, PhotonLogger, SanitizeUrlOptions, createLogger, sanitizeEmail, sanitizeErrorMessage, sanitizePhone, sanitizeUrl, setLogLevel } from "@photon-ai/otel";
4
4
  import { Token } from "marked";
@@ -178,4 +178,18 @@ declare const resumableOrderedStream: <TLive, TMissed, TOutput>(options: Resumab
178
178
  */
179
179
  declare function errorAttrs(error: unknown, prefix?: string): LogAttrs$1;
180
180
  //#endregion
181
- export { type CloseableAsyncIterable, type LogAttrs, type LogLevel, type PhotoInput, type PhotonLogger, type ProviderMessageRecord, type ProviderUserRecord, type ResumableStreamItem, type SanitizeUrlOptions, addMemberSchema, asAttachment, asContact, asCustom, asGroup, asMarkdown, asPoll, asPollOption, asReaction, asRead, asReply, asRichlink, asText, asUnsend, asVoice, avatarSchema, buildPhotoAction, createLogger, ensureM4a, envAwareConfig, envFor, errorAttrs, fromEnv, groupSchema, leaveSpaceSchema, messageEffectSchema, photoActionSchema, reactionSchema, removeMemberSchema, renameSchema, renderInlineTokens, replySchema, resumableOrderedStream, sanitizeEmail, sanitizeErrorMessage, sanitizePhone, sanitizeUrl, setLogLevel, tracedFetch };
181
+ //#region src/utils/token-renewal.d.ts
182
+ interface TokenRenewal {
183
+ dispose(): void;
184
+ forceRefresh(): Promise<void>;
185
+ invalidate(): void;
186
+ refreshIfNeeded(): Promise<void>;
187
+ }
188
+ interface TokenRenewalOptions {
189
+ expiresInSeconds(): number;
190
+ name: string;
191
+ refresh(): Promise<void>;
192
+ }
193
+ declare const createTokenRenewal: (options: TokenRenewalOptions) => TokenRenewal;
194
+ //#endregion
195
+ export { type CloseableAsyncIterable, type LogAttrs, type LogLevel, type PhotoInput, type PhotonLogger, type ProviderMessageRecord, type ProviderUserRecord, type ResumableStreamItem, type SanitizeUrlOptions, type TokenRenewal, type TokenRenewalOptions, addMemberSchema, asAttachment, asContact, asCustom, asGroup, asMarkdown, asPoll, asPollOption, asReaction, asRead, asReply, asRichlink, asText, asUnsend, asVoice, avatarSchema, buildPhotoAction, createLogger, createTokenRenewal, ensureM4a, envAwareConfig, envFor, errorAttrs, fromEnv, groupSchema, leaveSpaceSchema, messageEffectSchema, photoActionSchema, reactionSchema, removeMemberSchema, renameSchema, renderInlineTokens, replySchema, resumableOrderedStream, sanitizeEmail, sanitizeErrorMessage, sanitizePhone, sanitizeUrl, setLogLevel, tracedFetch };
package/dist/authoring.js CHANGED
@@ -1,4 +1,4 @@
1
- import { A as asPoll, B as asMarkdown, D as asReaction, F as addMemberSchema, G as groupSchema, H as markdownSchema, L as leaveSpaceSchema, Q as asCustom, S as replySchema, T as asRead, U as asGroup, Y as textSchema, at as avatarSchema, b as asReply, ct as asAttachment, d as envAwareConfig, et as asContact, f as envFor, ft as tracedFetch, g as asUnsend, i as stream, j as asPollOption, k as reactionSchema, l as renderInlineTokens, m as asVoice, o as errorAttrs, ot as buildPhotoAction, p as fromEnv, q as asText, st as photoActionSchema, ut as attachmentSchema, v as asRichlink, w as renameSchema, z as removeMemberSchema } from "./stream-B6kth7y9.js";
1
+ import { $ as asCustom, A as reactionSchema, B as removeMemberSchema, C as replySchema, E as asRead, I as addMemberSchema, J as asText, K as groupSchema, M as asPollOption, O as asReaction, R as leaveSpaceSchema, T as renameSchema, U as markdownSchema, V as asMarkdown, W as asGroup, X as textSchema, _ as asUnsend, a as createTokenRenewal, ct as photoActionSchema, dt as attachmentSchema, f as envAwareConfig, h as asVoice, i as stream, j as asPoll, lt as asAttachment, m as fromEnv, ot as avatarSchema, p as envFor, pt as tracedFetch, s as errorAttrs, st as buildPhotoAction, tt as asContact, u as renderInlineTokens, x as asReply, y as asRichlink } from "./stream-4VQBWgZQ.js";
2
2
  import z from "zod";
3
3
  import { createLogger, createLogger as createLogger$1, sanitizeEmail, sanitizeErrorMessage, sanitizePhone, sanitizeUrl, setLogLevel } from "@photon-ai/otel";
4
4
  import { mkdtemp, readFile, rm, writeFile } from "node:fs/promises";
@@ -422,4 +422,4 @@ const resumableOrderedStream = (options) => stream((emit, end) => {
422
422
  };
423
423
  });
424
424
  //#endregion
425
- export { addMemberSchema, asAttachment, asContact, asCustom, asGroup, asMarkdown, asPoll, asPollOption, asReaction, asRead, asReply, asRichlink, asText, asUnsend, asVoice, avatarSchema, buildPhotoAction, createLogger, ensureM4a, envAwareConfig, envFor, errorAttrs, fromEnv, groupSchema, leaveSpaceSchema, messageEffectSchema, photoActionSchema, reactionSchema, removeMemberSchema, renameSchema, renderInlineTokens, replySchema, resumableOrderedStream, sanitizeEmail, sanitizeErrorMessage, sanitizePhone, sanitizeUrl, setLogLevel, tracedFetch };
425
+ export { addMemberSchema, asAttachment, asContact, asCustom, asGroup, asMarkdown, asPoll, asPollOption, asReaction, asRead, asReply, asRichlink, asText, asUnsend, asVoice, avatarSchema, buildPhotoAction, createLogger, createTokenRenewal, ensureM4a, envAwareConfig, envFor, errorAttrs, fromEnv, groupSchema, leaveSpaceSchema, messageEffectSchema, photoActionSchema, reactionSchema, removeMemberSchema, renameSchema, renderInlineTokens, replySchema, resumableOrderedStream, sanitizeEmail, sanitizeErrorMessage, sanitizePhone, sanitizeUrl, setLogLevel, tracedFetch };
package/dist/index.d.ts CHANGED
@@ -1,2 +1,2 @@
1
- import { $ as DedicatedTokenData, $t as StreamTextSource, A as isFusorEvent, An as ContactInput, At as Reply, B as PlatformUser, Bn as AvatarInput, Bt as Poll, C as FusorVerify, Ct as typing, D as WebhookRawResult, Dn as ContactAddress, E as WebhookRawRequest, En as Contact, Et as Richlink, F as PlatformInstance, Fn as contact, Ft as rename, G as SpaceNamespace, Ht as PollChoiceInput, I as PlatformMessage, In as AgentSender, J as broadcast, Jn as AppOptions, Jt as Markdown, K as Broadcaster, Kn as App, Kt as option, L as PlatformProviderConfig, Ln as User, Lt as Read, M as EventProducer, Mn as ContactOrg, Mt as reply, N as Platform, Nn as ContactPhone, O as FusorEvent, On as ContactDetails, Ot as richlink, P as PlatformDef, Pt as Rename, Q as CloudPlatform, Qt as StreamText, R as PlatformRuntime, Rn as Avatar, S as FusorRespond, Sn as reaction, St as Typing, T as WebhookHandler, Tn as custom, Tt as text, Ut as PollOption, V as ProviderMessage, Vn as avatar, Vt as PollChoice, W as SchemaMessage, X as stream, Xn as app, Xt as markdown, Y as mergeStreams, Yn as AppUrl, Z as Store, Zn as appLayoutSchema, Zt as DeltaExtractor, _ as FusorClient, _n as removeMember, a as Content, an as Edit, at as ProjectProfile, b as FusorMessagesReturn, bn as ReactionBuilder, c as fromVCard, cn as Space, ct as SlackTokenData, d as UnsupportedKind, dn as MemberInput, dt as SubscriptionStatus, en as TextStreamOptions, et as FusorTokenData, f as Spectrum, fn as RemoveMember, ft as TokenData, g as isFusorClient, gt as Voice, h as fusor, hn as leaveSpace, ht as EmojiKey, i as attachment, it as ProjectData, j as AnyPlatformDef, jn as ContactName, k as fusorEvent, kn as ContactEmail, kt as resolveContents, l as toVCard, ln as AddMember, lt as SpectrumCloudError, m as definePlatform, mt as Emoji, n as AttachmentInput, nt as PlatformStatus, o as ContentBuilder, on as edit, ot as SharedTokenData, p as SpectrumInstance, pn as addMember, pt as cloud, q as ManagedStream, qn as AppLayout, qt as poll, rn as group, rt as PlatformsData, s as ContentInput, sn as Message, st as SlackTeamMeta, t as Attachment, tn as Group, tt as ImessageInfoData, u as UnsupportedError, un as LeaveSpace, ut as SubscriptionData, v as FusorMessages, vt as voice, w as FusorVerifyRequest, x as FusorReply, xt as unsend, y as FusorMessagesCtx, yn as Reaction, yt as Unsend, z as PlatformSpace, zn as AvatarData, zt as read } from "./attachment-DN82cCAP.js";
1
+ import { $ as DedicatedTokenData, $t as StreamTextSource, A as isFusorEvent, An as ContactInput, At as Reply, B as PlatformUser, Bn as AvatarInput, Bt as Poll, C as FusorVerify, Ct as typing, D as WebhookRawResult, Dn as ContactAddress, E as WebhookRawRequest, En as Contact, Et as Richlink, F as PlatformInstance, Fn as contact, Ft as rename, G as SpaceNamespace, Ht as PollChoiceInput, I as PlatformMessage, In as AgentSender, J as broadcast, Jn as AppOptions, Jt as Markdown, K as Broadcaster, Kn as App, Kt as option, L as PlatformProviderConfig, Ln as User, Lt as Read, M as EventProducer, Mn as ContactOrg, Mt as reply, N as Platform, Nn as ContactPhone, O as FusorEvent, On as ContactDetails, Ot as richlink, P as PlatformDef, Pt as Rename, Q as CloudPlatform, Qt as StreamText, R as PlatformRuntime, Rn as Avatar, S as FusorRespond, Sn as reaction, St as Typing, T as WebhookHandler, Tn as custom, Tt as text, Ut as PollOption, V as ProviderMessage, Vn as avatar, Vt as PollChoice, W as SchemaMessage, X as stream, Xn as app, Xt as markdown, Y as mergeStreams, Yn as AppUrl, Z as Store, Zn as appLayoutSchema, Zt as DeltaExtractor, _ as FusorClient, _n as removeMember, a as Content, an as Edit, at as ProjectProfile, b as FusorMessagesReturn, bn as ReactionBuilder, c as fromVCard, cn as Space, ct as SlackTokenData, d as UnsupportedKind, dn as MemberInput, dt as SubscriptionStatus, en as TextStreamOptions, et as FusorTokenData, f as Spectrum, fn as RemoveMember, ft as TokenData, g as isFusorClient, gt as Voice, h as fusor, hn as leaveSpace, ht as EmojiKey, i as attachment, it as ProjectData, j as AnyPlatformDef, jn as ContactName, k as fusorEvent, kn as ContactEmail, kt as resolveContents, l as toVCard, ln as AddMember, lt as SpectrumCloudError, m as definePlatform, mt as Emoji, n as AttachmentInput, nt as PlatformStatus, o as ContentBuilder, on as edit, ot as SharedTokenData, p as SpectrumInstance, pn as addMember, pt as cloud, q as ManagedStream, qn as AppLayout, qt as poll, rn as group, rt as PlatformsData, s as ContentInput, sn as Message, st as SlackTeamMeta, t as Attachment, tn as Group, tt as ImessageInfoData, u as UnsupportedError, un as LeaveSpace, ut as SubscriptionData, v as FusorMessages, vt as voice, w as FusorVerifyRequest, x as FusorReply, xt as unsend, y as FusorMessagesCtx, yn as Reaction, yt as Unsend, z as PlatformSpace, zn as AvatarData, zt as read } from "./attachment-CbNQEDfL.js";
2
2
  export { type AddMember, type AgentSender, type AnyPlatformDef, type App, type AppLayout, type AppOptions, type AppUrl, type Attachment, type AttachmentInput, type Avatar, type AvatarData, type AvatarInput, type Broadcaster, type CloudPlatform, type Contact, type ContactAddress, type ContactDetails, type ContactEmail, type ContactInput, type ContactName, type ContactOrg, type ContactPhone, type Content, type ContentBuilder, type ContentInput, type DedicatedTokenData, type DeltaExtractor, type Edit, Emoji, type EmojiKey, type EventProducer, type FusorClient, type FusorEvent, type FusorMessages, type FusorMessagesCtx, type FusorMessagesReturn, type FusorReply, type FusorRespond, type FusorTokenData, type FusorVerify, type FusorVerifyRequest, type Group, type ImessageInfoData, type LeaveSpace, type ManagedStream, type Markdown, type MemberInput, type Message, type Platform, type PlatformDef, type PlatformInstance, type PlatformMessage, type PlatformProviderConfig, type PlatformRuntime, type PlatformSpace, type PlatformStatus, type PlatformUser, type PlatformsData, type Poll, type PollChoice, type PollChoiceInput, type PollOption, type ProjectData, type ProjectProfile, type ProviderMessage, type Reaction, type ReactionBuilder, type Read, type RemoveMember, type Rename, type Reply, type Richlink, type SchemaMessage, type SharedTokenData, type SlackTeamMeta, type SlackTokenData, type Space, type SpaceNamespace, Spectrum, SpectrumCloudError, type SpectrumInstance, type Store, type StreamText, type StreamTextSource, type SubscriptionData, type SubscriptionStatus, type TextStreamOptions, type TokenData, type Typing, type Unsend, UnsupportedError, type UnsupportedKind, type User, type Voice, type WebhookHandler, type WebhookRawRequest, type WebhookRawResult, addMember, app, appLayoutSchema, attachment, avatar, broadcast, cloud, contact, custom, definePlatform, edit, fromVCard, fusor, fusorEvent, group, isFusorClient, isFusorEvent, leaveSpace, markdown, mergeStreams, option, poll, reaction, read, removeMember, rename, reply, resolveContents, richlink, stream, text, toVCard, typing, unsend, voice };
package/dist/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { $ as custom, B as asMarkdown, C as rename, E as read, F as addMemberSchema, I as leaveSpace, J as text, K as resolveContents, L as leaveSpaceSchema, M as option, N as poll, O as reaction, P as addMember, Q as asCustom, R as removeMember, V as markdown, W as group, X as StreamConsumedError, Z as drainStreamText, _ as unsend, a as contentAttrs, at as avatarSchema, c as markdownToPlainText, ct as asAttachment, d as envAwareConfig, dt as fetchUrlBytes, et as asContact, f as envFor, ft as tracedFetch, h as voice, i as stream, it as avatar, lt as attachment, m as asVoice, n as createAsyncQueue, nt as fromVCard, o as errorAttrs, q as asText, r as mergeStreams, rt as toVCard, s as senderAttrs, t as broadcast, tt as contact, u as classifyIdentifier, w as renameSchema, x as reply, y as richlink, z as removeMemberSchema } from "./stream-B6kth7y9.js";
1
+ import { $ as asCustom, B as removeMemberSchema, D as read, F as addMember, G as group, H as markdown, I as addMemberSchema, J as asText, L as leaveSpace, N as option, P as poll, Q as drainStreamText, R as leaveSpaceSchema, S as reply, T as renameSchema, V as asMarkdown, Y as text, Z as StreamConsumedError, a as createTokenRenewal, at as avatar, b as richlink, c as senderAttrs, d as classifyIdentifier, et as custom, f as envAwareConfig, ft as fetchUrlBytes, g as voice, h as asVoice, i as stream, it as toVCard, k as reaction, l as markdownToPlainText, lt as asAttachment, n as createAsyncQueue, nt as contact, o as contentAttrs, ot as avatarSchema, p as envFor, pt as tracedFetch, q as resolveContents, r as mergeStreams, rt as fromVCard, s as errorAttrs, t as broadcast, tt as asContact, ut as attachment, v as unsend, w as rename, z as removeMember } from "./stream-4VQBWgZQ.js";
2
2
  import z from "zod";
3
3
  import ogs from "open-graph-scraper";
4
4
  import { createLogger, setLogLevel, setupOtel, withSpan } from "@photon-ai/otel";
@@ -2806,6 +2806,11 @@ function buildMessage(params) {
2806
2806
  //#endregion
2807
2807
  //#region src/platform/define.ts
2808
2808
  const platformLog = createLogger("spectrum.platform");
2809
+ const PLATFORM_ID_PATTERN = /^[a-z][a-z0-9]*(?:_[a-z0-9]+)*$/;
2810
+ const assertValidPlatformId = (platformId) => {
2811
+ if (PLATFORM_ID_PATTERN.test(platformId)) return;
2812
+ throw new Error(`Invalid platform id "${platformId}". Platform ids must use lowercase snake_case (for example, "my_platform").`);
2813
+ };
2809
2814
  function buildInstanceActions(platformName, declared, reservedKeys, buildCtx) {
2810
2815
  const out = {};
2811
2816
  for (const key of PLATFORM_WISE_ACTION_KEYS) {
@@ -2948,33 +2953,34 @@ function createPlatformInstance(def, runtime) {
2948
2953
  }));
2949
2954
  return Object.assign(base, instanceActions, eventProperties);
2950
2955
  }
2951
- function definePlatform(name, rawDef) {
2956
+ function definePlatform(platformId, rawDef) {
2957
+ assertValidPlatformId(platformId);
2952
2958
  const def = rawDef;
2953
2959
  const fullDef = {
2954
2960
  ...def,
2955
- name,
2956
- config: envAwareConfig(name, def.config)
2961
+ name: platformId,
2962
+ config: envAwareConfig(platformId, def.config)
2957
2963
  };
2958
2964
  const platformCache = /* @__PURE__ */ new WeakMap();
2959
2965
  const narrowSpectrum = (spectrum) => {
2960
2966
  const cached = platformCache.get(spectrum);
2961
2967
  if (cached) return cached;
2962
- const runtime = spectrum.__internal.platforms.get(name);
2963
- if (!runtime) throw new Error(`Platform "${name}" is not registered`);
2968
+ const runtime = spectrum.__internal.platforms.get(platformId);
2969
+ if (!runtime) throw new Error(`Platform "${platformId}" is not registered`);
2964
2970
  const instance = createPlatformInstance(fullDef, runtime);
2965
2971
  platformCache.set(spectrum, instance);
2966
2972
  return instance;
2967
2973
  };
2968
2974
  const narrowSpace = (input) => {
2969
- if (input.__platform !== name) platformLog.warn("space platform mismatch; narrowing skipped", {
2970
- "spectrum.platform.expected": name,
2975
+ if (input.__platform !== platformId) platformLog.warn("space platform mismatch; narrowing skipped", {
2976
+ "spectrum.platform.expected": platformId,
2971
2977
  "spectrum.platform.actual": input.__platform
2972
2978
  });
2973
2979
  return input;
2974
2980
  };
2975
2981
  const narrowMessage = (input) => {
2976
- if (input.platform !== name) platformLog.warn("message platform mismatch; narrowing skipped", {
2977
- "spectrum.platform.expected": name,
2982
+ if (input.platform !== platformId) platformLog.warn("message platform mismatch; narrowing skipped", {
2983
+ "spectrum.platform.expected": platformId,
2978
2984
  "spectrum.platform.actual": input.platform
2979
2985
  });
2980
2986
  return input;
@@ -2989,15 +2995,15 @@ function definePlatform(name, rawDef) {
2989
2995
  return {
2990
2996
  __tag: "PlatformProviderConfig",
2991
2997
  __def: void 0,
2992
- __name: name,
2998
+ __name: platformId,
2993
2999
  config: config ?? {},
2994
3000
  __definition: fullDef
2995
3001
  };
2996
3002
  };
2997
3003
  narrower.is = ((input) => {
2998
3004
  if (typeof input !== "object" || input === null) return false;
2999
- if ("__platform" in input) return input.__platform === name;
3000
- if ("platform" in input) return input.platform === name;
3005
+ if ("__platform" in input) return input.__platform === platformId;
3006
+ if ("platform" in input) return input.platform === platformId;
3001
3007
  return false;
3002
3008
  });
3003
3009
  if (def.static) Object.assign(narrower, def.static);
@@ -3005,18 +3011,19 @@ function definePlatform(name, rawDef) {
3005
3011
  }
3006
3012
  //#endregion
3007
3013
  //#region src/build-env.ts
3008
- const SPECTRUM_SDK_VERSION = "12.0.0";
3014
+ const SPECTRUM_SDK_VERSION = "12.1.0";
3009
3015
  //#endregion
3010
3016
  //#region src/utils/provider-packages.ts
3011
3017
  const OFFICIAL_PROVIDER_PACKAGES = {
3012
3018
  imessage: "@spectrum-ts/imessage",
3019
+ local_imessage: "@spectrum-ts/imessage-local",
3013
3020
  slack: "@spectrum-ts/slack",
3014
3021
  telegram: "@spectrum-ts/telegram",
3015
3022
  terminal: "@spectrum-ts/terminal",
3016
- "whatsapp-business": "@spectrum-ts/whatsapp-business"
3023
+ whatsapp_business: "@spectrum-ts/whatsapp-business"
3017
3024
  };
3018
- const SEPARATORS = /[\s_]+/g;
3019
- const normalizePlatformKey = (platform) => platform.trim().toLowerCase().replace(SEPARATORS, "-");
3025
+ const LEGACY_SEPARATORS = /[\s-]+/g;
3026
+ const normalizePlatformKey = (platform) => platform.trim().toLowerCase().replace(LEGACY_SEPARATORS, "_");
3020
3027
  const officialProviderPackage = (platform) => OFFICIAL_PROVIDER_PACKAGES[normalizePlatformKey(platform)];
3021
3028
  const installCommand = (pkg) => process.versions.bun ? `bun add ${pkg}` : `npm install ${pkg}`;
3022
3029
  /**
@@ -3095,10 +3102,6 @@ const cloud = {
3095
3102
  };
3096
3103
  //#endregion
3097
3104
  //#region src/fusor/auth.ts
3098
- const log$2 = createLogger("spectrum.fusor.auth");
3099
- const RENEWAL_RATIO = .8;
3100
- const EXPIRY_BUFFER_MS = 3e4;
3101
- const RETRY_DELAY_MS = 3e4;
3102
3105
  /**
3103
3106
  * Single-token provider for the fusor stream. Mirrors the renewal cadence
3104
3107
  * of the slack provider package's auth but without per-team bookkeeping —
@@ -3107,83 +3110,23 @@ const RETRY_DELAY_MS = 3e4;
3107
3110
  function createFusorTokenProvider(projectId, projectSecret) {
3108
3111
  return (async () => {
3109
3112
  let tokenData = await cloud.issueFusorToken(projectId, projectSecret);
3110
- let tokenExpiresAt = Date.now() + tokenData.expiresIn * 1e3;
3111
- let disposed = false;
3112
- let renewalTimer;
3113
- let refreshFailures = 0;
3114
- const clearRenewalTimer = () => {
3115
- if (renewalTimer !== void 0) {
3116
- clearTimeout(renewalTimer);
3117
- renewalTimer = void 0;
3118
- }
3119
- };
3120
- const refresh = async () => {
3121
- tokenData = await cloud.issueFusorToken(projectId, projectSecret);
3122
- tokenExpiresAt = Date.now() + tokenData.expiresIn * 1e3;
3123
- };
3124
- const onRefreshSuccess = () => {
3125
- if (refreshFailures > 0) {
3126
- log$2.info("fusor token refresh recovered", { "spectrum.fusor.auth.attempt": refreshFailures });
3127
- refreshFailures = 0;
3113
+ const renewal = createTokenRenewal({
3114
+ expiresInSeconds: () => tokenData.expiresIn,
3115
+ name: "fusor",
3116
+ refresh: async () => {
3117
+ tokenData = await cloud.issueFusorToken(projectId, projectSecret);
3128
3118
  }
3129
- };
3130
- const onRefreshFailure = (error) => {
3131
- refreshFailures += 1;
3132
- log$2.warn("fusor token refresh failed; retrying", {
3133
- "spectrum.fusor.auth.attempt": refreshFailures,
3134
- "spectrum.fusor.auth.retry_in_ms": RETRY_DELAY_MS,
3135
- ...errorAttrs(error)
3136
- }, error);
3137
- };
3138
- const scheduleRetry = () => {
3139
- if (disposed) return;
3140
- clearRenewalTimer();
3141
- renewalTimer = setTimeout(async () => {
3142
- if (disposed) return;
3143
- try {
3144
- await refresh();
3145
- onRefreshSuccess();
3146
- scheduleRenewal();
3147
- } catch (retryErr) {
3148
- onRefreshFailure(retryErr);
3149
- scheduleRetry();
3150
- }
3151
- }, RETRY_DELAY_MS);
3152
- renewalTimer?.unref?.();
3153
- };
3154
- const scheduleRenewal = () => {
3155
- if (disposed) return;
3156
- clearRenewalTimer();
3157
- const ttlMs = tokenData.expiresIn * 1e3;
3158
- const renewInMs = Math.max(ttlMs * RENEWAL_RATIO, 5e3);
3159
- renewalTimer = setTimeout(async () => {
3160
- try {
3161
- await refresh();
3162
- onRefreshSuccess();
3163
- scheduleRenewal();
3164
- } catch (err) {
3165
- onRefreshFailure(err);
3166
- scheduleRetry();
3167
- }
3168
- }, renewInMs);
3169
- renewalTimer?.unref?.();
3170
- };
3171
- scheduleRenewal();
3119
+ });
3172
3120
  return {
3173
3121
  async getToken() {
3174
- if (Date.now() >= tokenExpiresAt - EXPIRY_BUFFER_MS) {
3175
- await refresh();
3176
- onRefreshSuccess();
3177
- scheduleRenewal();
3178
- }
3122
+ await renewal.refreshIfNeeded();
3179
3123
  return tokenData.token;
3180
3124
  },
3181
3125
  invalidate() {
3182
- tokenExpiresAt = 0;
3126
+ renewal.invalidate();
3183
3127
  },
3184
3128
  async dispose() {
3185
- disposed = true;
3186
- clearRenewalTimer();
3129
+ renewal.dispose();
3187
3130
  }
3188
3131
  };
3189
3132
  })();
@@ -3653,6 +3596,16 @@ var FusorCore = class {
3653
3596
  }
3654
3597
  };
3655
3598
  //#endregion
3599
+ //#region src/platform/unique-names.ts
3600
+ const assertUniquePlatformNames = (providers) => {
3601
+ const names = /* @__PURE__ */ new Set();
3602
+ for (const provider of providers) {
3603
+ const name = provider.__definition.name;
3604
+ if (names.has(name)) throw new Error(`Spectrum received multiple providers for platform "${name}". Register exactly one provider per platform.`);
3605
+ names.add(name);
3606
+ }
3607
+ };
3608
+ //#endregion
3656
3609
  //#region src/utils/store.ts
3657
3610
  const isRecordObject = (value) => {
3658
3611
  if (typeof value !== "object" || value === null || Array.isArray(value)) return false;
@@ -4077,6 +4030,7 @@ async function Spectrum(options) {
4077
4030
  projectId,
4078
4031
  projectSecret
4079
4032
  });
4033
+ assertUniquePlatformNames(options.providers);
4080
4034
  const { options: runtimeOptions, providers, telemetry, webhookSecret } = options;
4081
4035
  const flattenGroups = runtimeOptions?.flattenGroups ?? false;
4082
4036
  applyLogLevel(runtimeOptions?.logLevel);
@@ -1,5 +1,5 @@
1
1
  import z from "zod";
2
- import { createInstrumentedFetch, sanitizeEmail, sanitizeErrorMessage, sanitizePhone, sanitizeUrl } from "@photon-ai/otel";
2
+ import { createInstrumentedFetch, createLogger, sanitizeEmail, sanitizeErrorMessage, sanitizePhone, sanitizeUrl } from "@photon-ai/otel";
3
3
  import { randomUUID } from "node:crypto";
4
4
  import { createReadStream } from "node:fs";
5
5
  import { readFile, stat } from "node:fs/promises";
@@ -1249,8 +1249,8 @@ const fromEnv = (envKey, schema) => z.preprocess((value) => {
1249
1249
  * Normalize a platform id into the env-var prefix segment: upper-case, with any
1250
1250
  * run of non-alphanumeric characters collapsed to a single `_`. This is a
1251
1251
  * whole-name transform, NOT camelCase splitting, so it reproduces the prefixes
1252
- * the adapters used by hand `"telegram"` → `TELEGRAM`,
1253
- * `"WhatsApp Business"` `WHATSAPP_BUSINESS`, `"Slack"` `SLACK`.
1252
+ * canonical platform ids use lowercase snake_case, so `"telegram"` becomes
1253
+ * `TELEGRAM` and `"whatsapp_business"` becomes `WHATSAPP_BUSINESS`.
1254
1254
  */
1255
1255
  const NON_ALPHANUMERIC_RUN = /[^A-Z0-9]+/;
1256
1256
  const normalizePlatformName = (name) => name.toUpperCase().split(NON_ALPHANUMERIC_RUN).filter(Boolean).join("_");
@@ -1576,6 +1576,85 @@ function errorAttrs(error, prefix = "spectrum.error") {
1576
1576
  };
1577
1577
  }
1578
1578
  //#endregion
1579
+ //#region src/utils/token-renewal.ts
1580
+ const RENEWAL_RATIO = .8;
1581
+ const EXPIRY_BUFFER_MS = 3e4;
1582
+ const MIN_RENEWAL_DELAY_MS = 5e3;
1583
+ const RETRY_DELAY_MS = 3e4;
1584
+ const createTokenRenewal = (options) => {
1585
+ const telemetryPrefix = `spectrum.${options.name}.auth`;
1586
+ const log = createLogger(telemetryPrefix);
1587
+ let disposed = false;
1588
+ let refreshFailures = 0;
1589
+ let refreshInFlight;
1590
+ let renewalTimer;
1591
+ let tokenExpiresAt = Date.now() + options.expiresInSeconds() * 1e3;
1592
+ const clearRenewalTimer = () => {
1593
+ if (renewalTimer !== void 0) {
1594
+ clearTimeout(renewalTimer);
1595
+ renewalTimer = void 0;
1596
+ }
1597
+ };
1598
+ const onRefreshSuccess = () => {
1599
+ if (refreshFailures > 0) {
1600
+ log.info(`${options.name} token refresh recovered`, { [`${telemetryPrefix}.attempt`]: refreshFailures });
1601
+ refreshFailures = 0;
1602
+ }
1603
+ };
1604
+ const onRefreshFailure = (error) => {
1605
+ refreshFailures += 1;
1606
+ log.warn(`${options.name} token refresh failed; retrying`, {
1607
+ [`${telemetryPrefix}.attempt`]: refreshFailures,
1608
+ [`${telemetryPrefix}.retry_in_ms`]: RETRY_DELAY_MS,
1609
+ ...errorAttrs(error)
1610
+ }, error);
1611
+ };
1612
+ const refreshNow = async () => {
1613
+ await options.refresh();
1614
+ tokenExpiresAt = Date.now() + options.expiresInSeconds() * 1e3;
1615
+ onRefreshSuccess();
1616
+ scheduleRenewal();
1617
+ };
1618
+ const coalescedRefresh = () => {
1619
+ if (!refreshInFlight) refreshInFlight = refreshNow().finally(() => {
1620
+ refreshInFlight = void 0;
1621
+ });
1622
+ return refreshInFlight;
1623
+ };
1624
+ const runScheduledRefresh = () => {
1625
+ if (disposed) return;
1626
+ coalescedRefresh().catch((error) => {
1627
+ onRefreshFailure(error);
1628
+ if (disposed) return;
1629
+ renewalTimer = setTimeout(runScheduledRefresh, RETRY_DELAY_MS);
1630
+ renewalTimer?.unref?.();
1631
+ });
1632
+ };
1633
+ const scheduleRenewal = () => {
1634
+ if (disposed) return;
1635
+ clearRenewalTimer();
1636
+ const ttlMs = options.expiresInSeconds() * 1e3;
1637
+ const renewInMs = Math.max(ttlMs * RENEWAL_RATIO, MIN_RENEWAL_DELAY_MS);
1638
+ renewalTimer = setTimeout(runScheduledRefresh, renewInMs);
1639
+ renewalTimer?.unref?.();
1640
+ };
1641
+ scheduleRenewal();
1642
+ return {
1643
+ dispose() {
1644
+ disposed = true;
1645
+ clearRenewalTimer();
1646
+ },
1647
+ forceRefresh: coalescedRefresh,
1648
+ invalidate() {
1649
+ tokenExpiresAt = 0;
1650
+ },
1651
+ async refreshIfNeeded() {
1652
+ if (Date.now() < tokenExpiresAt - EXPIRY_BUFFER_MS) return;
1653
+ await coalescedRefresh();
1654
+ }
1655
+ };
1656
+ };
1657
+ //#endregion
1579
1658
  //#region src/utils/stream.ts
1580
1659
  /**
1581
1660
  * Unbounded FIFO queue with `AsyncIterable` consumer. Used by FusorCore to feed
@@ -1746,4 +1825,4 @@ function broadcast(source) {
1746
1825
  };
1747
1826
  }
1748
1827
  //#endregion
1749
- export { custom as $, asPoll as A, asMarkdown as B, rename as C, asReaction as D, read as E, addMemberSchema as F, groupSchema as G, markdownSchema as H, leaveSpace as I, text as J, resolveContents as K, leaveSpaceSchema as L, option as M, poll as N, reaction as O, addMember as P, asCustom as Q, removeMember as R, replySchema as S, asRead as T, asGroup as U, markdown as V, group as W, StreamConsumedError as X, textSchema as Y, drainStreamText as Z, unsend as _, contentAttrs as a, avatarSchema as at, asReply as b, markdownToPlainText as c, asAttachment as ct, envAwareConfig as d, fetchUrlBytes as dt, asContact as et, envFor as f, tracedFetch as ft, asUnsend as g, voice as h, stream as i, avatar as it, asPollOption as j, reactionSchema as k, renderInlineTokens as l, attachment as lt, asVoice as m, createAsyncQueue as n, fromVCard as nt, errorAttrs as o, buildPhotoAction as ot, fromEnv as p, asText as q, mergeStreams as r, toVCard as rt, senderAttrs as s, photoActionSchema as st, broadcast as t, contact as tt, classifyIdentifier as u, attachmentSchema as ut, asRichlink as v, renameSchema as w, reply as x, richlink as y, removeMemberSchema as z };
1828
+ export { asCustom as $, reactionSchema as A, removeMemberSchema as B, replySchema as C, read as D, asRead as E, addMember as F, group as G, markdown as H, addMemberSchema as I, asText as J, groupSchema as K, leaveSpace as L, asPollOption as M, option as N, asReaction as O, poll as P, drainStreamText as Q, leaveSpaceSchema as R, reply as S, renameSchema as T, markdownSchema as U, asMarkdown as V, asGroup as W, textSchema as X, text as Y, StreamConsumedError as Z, asUnsend as _, createTokenRenewal as a, avatar as at, richlink as b, senderAttrs as c, photoActionSchema as ct, classifyIdentifier as d, attachmentSchema as dt, custom as et, envAwareConfig as f, fetchUrlBytes as ft, voice as g, asVoice as h, stream as i, toVCard as it, asPoll as j, reaction as k, markdownToPlainText as l, asAttachment as lt, fromEnv as m, createAsyncQueue as n, contact as nt, contentAttrs as o, avatarSchema as ot, envFor as p, tracedFetch as pt, resolveContents as q, mergeStreams as r, fromVCard as rt, errorAttrs as s, buildPhotoAction as st, broadcast as t, asContact as tt, renderInlineTokens as u, attachment as ut, unsend as v, rename as w, asReply as x, asRichlink as y, removeMember as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spectrum-ts/core",
3
- "version": "12.0.0",
3
+ "version": "12.1.0",
4
4
  "description": "The spectrum-ts runtime — Spectrum, content builders, fusor, and the provider authoring API.",
5
5
  "repository": {
6
6
  "type": "git",