spectrum-ts 4.0.0 → 4.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (35) hide show
  1. package/dist/{attachment-CEpGtZLm.d.ts → attachment-CnivEhr6.d.ts} +1 -1
  2. package/dist/{authoring-CP3vRza8.d.ts → authoring-b9AhXgPI.d.ts} +2 -2
  3. package/dist/authoring.d.ts +3 -3
  4. package/dist/authoring.js +3 -3
  5. package/dist/{chunk-PV4AVMNN.js → chunk-ARL2NOBO.js} +4 -4
  6. package/dist/{chunk-OGTHPDG7.js → chunk-B52VPQO3.js} +69 -29
  7. package/dist/{chunk-5VCWWPFW.js → chunk-DMPDLSFU.js} +8 -4
  8. package/dist/{chunk-57NECZQZ.js → chunk-N6THJDZV.js} +6 -4
  9. package/dist/{chunk-W5HNZ7YT.js → chunk-NLMQ75LH.js} +33 -76
  10. package/dist/{chunk-VEF6FUE7.js → chunk-WXLQNANA.js} +4 -1
  11. package/dist/elysia.d.ts +94 -0
  12. package/dist/elysia.js +15 -0
  13. package/dist/express.d.ts +62 -0
  14. package/dist/express.js +19 -0
  15. package/dist/hono.d.ts +64 -0
  16. package/dist/hono.js +11 -0
  17. package/dist/index.d.ts +33 -18
  18. package/dist/index.js +428 -36
  19. package/dist/providers/imessage/index.d.ts +10 -32
  20. package/dist/providers/imessage/index.js +7 -6
  21. package/dist/providers/index.d.ts +4 -4
  22. package/dist/providers/index.js +16 -16
  23. package/dist/providers/slack/index.d.ts +1 -1
  24. package/dist/providers/slack/index.js +2 -2
  25. package/dist/providers/telegram/index.d.ts +2 -2
  26. package/dist/providers/telegram/index.js +3 -3
  27. package/dist/providers/terminal/index.d.ts +1 -1
  28. package/dist/providers/terminal/index.js +3 -3
  29. package/dist/providers/whatsapp-business/index.d.ts +1 -1
  30. package/dist/providers/whatsapp-business/index.js +4 -4
  31. package/dist/read-C4uvozGX.d.ts +53 -0
  32. package/dist/{types-Be0T6E0e.d.ts → types-CyfLJXgu.d.ts} +26 -1
  33. package/dist/{types-CDYXH2R7.d.ts → types-ZgFTj5hJ.d.ts} +11 -6
  34. package/package.json +25 -1
  35. package/dist/photo-content-BJKnqgN-.d.ts +0 -13
@@ -3,17 +3,17 @@ export { slack } from './slack/index.js';
3
3
  export { telegram } from './telegram/index.js';
4
4
  export { terminal } from './terminal/index.js';
5
5
  export { whatsappBusiness } from './whatsapp-business/index.js';
6
- import '../types-Be0T6E0e.js';
6
+ import '../types-CyfLJXgu.js';
7
7
  import 'hotscript';
8
8
  import 'zod';
9
9
  import 'zod/v4/core';
10
- import '../attachment-CEpGtZLm.js';
11
- import '../photo-content-BJKnqgN-.js';
10
+ import '../attachment-CnivEhr6.js';
11
+ import '../read-C4uvozGX.js';
12
12
  import '@photon-ai/advanced-imessage';
13
13
  import '@photon-ai/imessage-kit';
14
14
  import '@photon-ai/slack';
15
15
  import '@photon-ai/telegram-ts';
16
- import '../types-CDYXH2R7.js';
16
+ import '../types-ZgFTj5hJ.js';
17
17
  import 'node:child_process';
18
18
  import 'node:net';
19
19
  import '@photon-ai/whatsapp-business';
@@ -1,29 +1,29 @@
1
1
  import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
- import {
3
- imessage
4
- } from "../chunk-W5HNZ7YT.js";
5
- import "../chunk-ZR3TKZMT.js";
6
- import {
7
- slack
8
- } from "../chunk-VEF6FUE7.js";
9
2
  import {
10
3
  telegram
11
- } from "../chunk-57NECZQZ.js";
12
- import "../chunk-34FQGGD7.js";
13
- import "../chunk-LZXPLXZF.js";
4
+ } from "../chunk-N6THJDZV.js";
14
5
  import {
15
6
  terminal
16
- } from "../chunk-PV4AVMNN.js";
17
- import "../chunk-FAIFTUV2.js";
7
+ } from "../chunk-ARL2NOBO.js";
18
8
  import {
19
9
  whatsappBusiness
20
- } from "../chunk-5VCWWPFW.js";
10
+ } from "../chunk-DMPDLSFU.js";
11
+ import "../chunk-34FQGGD7.js";
12
+ import "../chunk-FAIFTUV2.js";
13
+ import {
14
+ imessage
15
+ } from "../chunk-NLMQ75LH.js";
16
+ import "../chunk-ZR3TKZMT.js";
17
+ import "../chunk-LZXPLXZF.js";
21
18
  import "../chunk-2D27WW5B.js";
22
- import "../chunk-3GEJYGZK.js";
23
19
  import "../chunk-A37PM5N2.js";
24
- import "../chunk-5XEFJBN2.js";
25
20
  import "../chunk-6UZFVXQF.js";
26
- import "../chunk-OGTHPDG7.js";
21
+ import {
22
+ slack
23
+ } from "../chunk-WXLQNANA.js";
24
+ import "../chunk-3GEJYGZK.js";
25
+ import "../chunk-5XEFJBN2.js";
26
+ import "../chunk-B52VPQO3.js";
27
27
  import "../chunk-UXAKIXVM.js";
28
28
  export {
29
29
  imessage,
@@ -1,4 +1,4 @@
1
- import { S as SchemaMessage, P as Platform, a as PlatformDef } from '../../types-Be0T6E0e.js';
1
+ import { a as SchemaMessage, P as Platform, b as PlatformDef } from '../../types-CyfLJXgu.js';
2
2
  import * as z from 'zod';
3
3
  import z__default from 'zod';
4
4
  import * as _photon_ai_slack from '@photon-ai/slack';
@@ -1,10 +1,10 @@
1
1
  import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
2
  import {
3
3
  slack
4
- } from "../../chunk-VEF6FUE7.js";
4
+ } from "../../chunk-WXLQNANA.js";
5
5
  import "../../chunk-3GEJYGZK.js";
6
6
  import "../../chunk-5XEFJBN2.js";
7
- import "../../chunk-OGTHPDG7.js";
7
+ import "../../chunk-B52VPQO3.js";
8
8
  import "../../chunk-UXAKIXVM.js";
9
9
  export {
10
10
  slack
@@ -1,9 +1,9 @@
1
- import { P as Platform, a as PlatformDef, g as ProviderMessage } from '../../types-Be0T6E0e.js';
1
+ import { P as Platform, b as PlatformDef, g as ProviderMessage } from '../../types-CyfLJXgu.js';
2
2
  import * as _photon_ai_telegram_ts from '@photon-ai/telegram-ts';
3
3
  import * as zod_v4_core from 'zod/v4/core';
4
4
  import * as z from 'zod';
5
5
  import z__default from 'zod';
6
- import { F as FusorClient } from '../../types-CDYXH2R7.js';
6
+ import { F as FusorClient } from '../../types-ZgFTj5hJ.js';
7
7
  import 'hotscript';
8
8
 
9
9
  interface TelegramSpace {
@@ -1,12 +1,12 @@
1
1
  import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
2
  import {
3
3
  telegram
4
- } from "../../chunk-57NECZQZ.js";
4
+ } from "../../chunk-N6THJDZV.js";
5
5
  import "../../chunk-34FQGGD7.js";
6
- import "../../chunk-LZXPLXZF.js";
7
6
  import "../../chunk-FAIFTUV2.js";
7
+ import "../../chunk-LZXPLXZF.js";
8
8
  import "../../chunk-6UZFVXQF.js";
9
- import "../../chunk-OGTHPDG7.js";
9
+ import "../../chunk-B52VPQO3.js";
10
10
  import "../../chunk-UXAKIXVM.js";
11
11
  export {
12
12
  telegram
@@ -1,4 +1,4 @@
1
- import { P as Platform, a as PlatformDef, f as contentSchema } from '../../types-Be0T6E0e.js';
1
+ import { P as Platform, b as PlatformDef, f as contentSchema } from '../../types-CyfLJXgu.js';
2
2
  import { ChildProcess } from 'node:child_process';
3
3
  import z__default from 'zod';
4
4
  import { Socket } from 'node:net';
@@ -1,12 +1,12 @@
1
1
  import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
2
  import {
3
3
  terminal
4
- } from "../../chunk-PV4AVMNN.js";
4
+ } from "../../chunk-ARL2NOBO.js";
5
5
  import "../../chunk-FAIFTUV2.js";
6
6
  import "../../chunk-A37PM5N2.js";
7
- import "../../chunk-5XEFJBN2.js";
8
7
  import "../../chunk-6UZFVXQF.js";
9
- import "../../chunk-OGTHPDG7.js";
8
+ import "../../chunk-5XEFJBN2.js";
9
+ import "../../chunk-B52VPQO3.js";
10
10
  import "../../chunk-UXAKIXVM.js";
11
11
  export {
12
12
  terminal
@@ -1,4 +1,4 @@
1
- import { S as SchemaMessage, P as Platform, a as PlatformDef } from '../../types-Be0T6E0e.js';
1
+ import { a as SchemaMessage, P as Platform, b as PlatformDef } from '../../types-CyfLJXgu.js';
2
2
  import { WhatsAppClient } from '@photon-ai/whatsapp-business';
3
3
  import * as z from 'zod';
4
4
  import z__default from 'zod';
@@ -1,13 +1,13 @@
1
1
  import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
2
  import {
3
3
  whatsappBusiness
4
- } from "../../chunk-5VCWWPFW.js";
4
+ } from "../../chunk-DMPDLSFU.js";
5
5
  import "../../chunk-2D27WW5B.js";
6
- import "../../chunk-3GEJYGZK.js";
7
6
  import "../../chunk-A37PM5N2.js";
8
- import "../../chunk-5XEFJBN2.js";
9
7
  import "../../chunk-6UZFVXQF.js";
10
- import "../../chunk-OGTHPDG7.js";
8
+ import "../../chunk-3GEJYGZK.js";
9
+ import "../../chunk-5XEFJBN2.js";
10
+ import "../../chunk-B52VPQO3.js";
11
11
  import "../../chunk-UXAKIXVM.js";
12
12
  export {
13
13
  whatsappBusiness
@@ -0,0 +1,53 @@
1
+ import z__default from 'zod';
2
+ import { M as Message, U as User, S as Space, C as ContentBuilder } from './types-CyfLJXgu.js';
3
+
4
+ /**
5
+ * Shared building blocks for photo-style content (chat background, group
6
+ * avatar/icon, …) whose builders all share the same `set | clear` shape and
7
+ * the same `"clear"` reserved-string sentinel.
8
+ *
9
+ * Keeping the action schema and `buildPhotoAction` factory here means both
10
+ * `background()` and `avatar()` parse against the same structural definition
11
+ * and any DX fix (mime inference, read caching, sentinel docs) lands once.
12
+ */
13
+ declare const CLEAR_SENTINEL: "clear";
14
+ type PhotoInput = typeof CLEAR_SENTINEL | string | Buffer | URL;
15
+
16
+ /**
17
+ * A `read` marks the conversation as read **up to** `target`, surfacing a
18
+ * read receipt to the sender where the platform supports one.
19
+ *
20
+ * `space.send(read(message))` is the canonical outbound API;
21
+ * `message.read()` and `space.read(message)` are sugar that delegate here.
22
+ * Reads are fire-and-forget — providers handle them inside their `send`
23
+ * action and the resolved value is `undefined`.
24
+ *
25
+ * Granularity is per-platform:
26
+ *
27
+ * - WhatsApp Business: per-message receipt via `markRead(target.id)`, which
28
+ * also marks every earlier message in the conversation as read.
29
+ * - iMessage (remote): chat-level `chats.markRead(chatGuid)` — `target` only
30
+ * identifies the chat, and **every** unread message in it is marked read.
31
+ * Local mode rejects with `UnsupportedError` (warned and skipped).
32
+ * - Telegram / Slack: silently no-op. Neither surfaces read state for bot
33
+ * conversations (Telegram bot chats are effectively auto-read), so the
34
+ * signal is vacuously satisfied — same best-effort contract as `typing`.
35
+ */
36
+ declare const readSchema: z__default.ZodObject<{
37
+ type: z__default.ZodLiteral<"read">;
38
+ target: z__default.ZodCustom<Message<string, User, Space<unknown>>, Message<string, User, Space<unknown>>>;
39
+ }, z__default.core.$strip>;
40
+ type Read = z__default.infer<typeof readSchema>;
41
+ /**
42
+ * Construct a `read` content value marking the conversation read up to
43
+ * `target`.
44
+ *
45
+ * Only inbound messages (those received from a user) can be marked read;
46
+ * calling this with an outbound target throws at build time so the misuse
47
+ * surfaces before the send pipeline runs. The target is required (not
48
+ * `Message | undefined` like `unsend`): read targets come from the inbound
49
+ * stream, never from a chainable `send()` result.
50
+ */
51
+ declare function read(target: Message): ContentBuilder;
52
+
53
+ export { type PhotoInput as P, type Read as R, read as r };
@@ -741,6 +741,9 @@ declare const contentSchema: z__default.ZodDiscriminatedUnion<[z__default.ZodObj
741
741
  }, z__default.core.$strip>, z__default.ZodObject<{
742
742
  type: z__default.ZodLiteral<"unsend">;
743
743
  target: z__default.ZodCustom<Message<string, User, Space<unknown>>, Message<string, User, Space<unknown>>>;
744
+ }, z__default.core.$strip>, z__default.ZodObject<{
745
+ type: z__default.ZodLiteral<"read">;
746
+ target: z__default.ZodCustom<Message<string, User, Space<unknown>>, Message<string, User, Space<unknown>>>;
744
747
  }, z__default.core.$strip>], "type">;
745
748
  type Content = z__default.infer<typeof contentSchema>;
746
749
  interface ContentBuilder {
@@ -832,6 +835,19 @@ interface Space<_Def = unknown> {
832
835
  */
833
836
  getMessage(id: string): Promise<Message | undefined>;
834
837
  readonly id: string;
838
+ /**
839
+ * Mark the conversation as read up to `message`, surfacing a read receipt
840
+ * to the sender where the platform supports one. Sugar for
841
+ * `send(read(message))`. Fire-and-forget; only inbound messages can be
842
+ * marked read.
843
+ *
844
+ * Granularity is per-platform: WhatsApp Business issues a receipt for
845
+ * `message` and everything before it; iMessage (remote) marks the whole
846
+ * chat read. Platforms with no read-receipt concept for bot conversations
847
+ * (Telegram, Slack) silently no-op, so the signal is best-effort
848
+ * everywhere — same contract as `startTyping()`.
849
+ */
850
+ read(message: Message): Promise<void>;
835
851
  /**
836
852
  * Rename the current chat. Sugar for `send(rename(displayName))`.
837
853
  *
@@ -882,6 +898,15 @@ interface Message<TPlatform extends string = string, TSender extends User = User
882
898
  react(reaction: string): Promise<(Message<TPlatform, AgentSender, TSpace> & {
883
899
  content: Reaction;
884
900
  }) | undefined>;
901
+ /**
902
+ * Mark this message (and everything before it in the conversation) as
903
+ * read. Sugar for `space.send(read(this))`. Reads are fire-and-forget;
904
+ * per-platform granularity and support (e.g. iMessage marks the whole
905
+ * chat; Telegram/Slack silently no-op) surface from the provider's send
906
+ * action. Only inbound messages can be marked read; calling this on an
907
+ * outbound message throws.
908
+ */
909
+ read(): Promise<void>;
885
910
  reply(content: ContentInput): Promise<Message<TPlatform, AgentSender, TSpace> | undefined>;
886
911
  reply(...content: [ContentInput, ContentInput, ...ContentInput[]]): Promise<Message<TPlatform, AgentSender, TSpace>[]>;
887
912
  sender: TSender | undefined;
@@ -1502,4 +1527,4 @@ interface Platform<Def extends AnyPlatformDef> {
1502
1527
  (message: Message): PlatformMessage<Def>;
1503
1528
  }
1504
1529
 
1505
- export { asReaction as $, type AgentSender as A, type Broadcaster as B, type ContentBuilder as C, type DedicatedTokenData as D, type EventProducer as E, type FusorTokenData as F, type ProjectProfile as G, type ReactionBuilder as H, type InstanceActionFn as I, type SharedTokenData as J, type SlackTeamMeta as K, type SlackTokenData as L, type Message as M, type SpaceNamespace as N, SpectrumCloudError as O, type Platform as P, type SubscriptionData as Q, type Reaction as R, type SchemaMessage as S, type SubscriptionStatus as T, type User as U, type TokenData as V, broadcast as W, cloud as X, mergeStreams as Y, reaction as Z, stream as _, type PlatformDef as a, type ProjectData as b, type Store as c, type ProviderMessageRecord as d, type Space as e, contentSchema as f, type ProviderMessage as g, type ContentInput as h, type Content as i, type SpaceActionFn as j, type MessageActionFn as k, type CreateClientContext as l, type PlatformProviderConfig as m, type SpectrumLike as n, type CustomEventStreams as o, type AnyPlatformDef as p, type CloudPlatform as q, type ImessageInfoData as r, type ManagedStream as s, type PlatformInstance as t, type PlatformMessage as u, type PlatformRuntime as v, type PlatformSpace as w, type PlatformStatus as x, type PlatformUser as y, type PlatformsData as z };
1530
+ export { asReaction as $, type AgentSender as A, type Broadcaster as B, type ContentBuilder as C, type DedicatedTokenData as D, type EventProducer as E, type FusorTokenData as F, type ProjectProfile as G, type ReactionBuilder as H, type InstanceActionFn as I, type SharedTokenData as J, type SlackTeamMeta as K, type SlackTokenData as L, type Message as M, type SpaceNamespace as N, SpectrumCloudError as O, type Platform as P, type SubscriptionData as Q, type Reaction as R, type Space as S, type SubscriptionStatus as T, type User as U, type TokenData as V, broadcast as W, cloud as X, mergeStreams as Y, reaction as Z, stream as _, type SchemaMessage as a, type PlatformDef as b, type ProjectData as c, type Store as d, type ProviderMessageRecord as e, contentSchema as f, type ProviderMessage as g, type ContentInput as h, type Content as i, type SpaceActionFn as j, type MessageActionFn as k, type CreateClientContext as l, type PlatformProviderConfig as m, type SpectrumLike as n, type CustomEventStreams as o, type AnyPlatformDef as p, type CloudPlatform as q, type ImessageInfoData as r, type ManagedStream as s, type PlatformInstance as t, type PlatformMessage as u, type PlatformRuntime as v, type PlatformSpace as w, type PlatformStatus as x, type PlatformUser as y, type PlatformsData as z };
@@ -1,4 +1,4 @@
1
- import { b as ProjectData, c as Store, d as ProviderMessageRecord, e as Space, M as Message } from './types-Be0T6E0e.js';
1
+ import { c as ProjectData, d as Store, e as ProviderMessageRecord, S as Space, M as Message } from './types-CyfLJXgu.js';
2
2
 
3
3
  declare const FUSOR_EVENT_BRAND: unique symbol;
4
4
  interface FusorEvent<TName extends string = string, TData = unknown> {
@@ -62,11 +62,16 @@ interface FusorClient<TPayload = unknown> {
62
62
  type WebhookHandler = (space: Space, message: Message) => void | Promise<void>;
63
63
  /**
64
64
  * Raw webhook input for HTTP servers without Web `Request`/`Response` (Express,
65
- * raw Node). `body` MUST be the exact bytes fusor POSTed — never a re-encoded
66
- * JSON/text body — so the protobuf decode works. `headers` are accepted (so the
67
- * natural `{ headers: req.headers, body: req.body }` shape keeps working) but are
68
- * not read: inbound authenticity is established by the per-platform `verify()`,
69
- * which reads the inner request reconstructed from the envelope.
65
+ * raw Node). `body` MUST be the exact bytes POSTed — never a re-encoded
66
+ * JSON/text body — so both the protobuf decode (fusor) and the HMAC
67
+ * verification (native Spectrum webhook) work.
68
+ *
69
+ * `headers` ARE read for **native Spectrum webhooks**: `X-Spectrum-Signature` /
70
+ * `X-Spectrum-Timestamp` carry the HMAC verified against
71
+ * `Spectrum({ webhookSecret })`, and the signature header also selects the
72
+ * native path. For **fusor** envelopes they are ignored (authenticity is the
73
+ * per-platform `verify()` reading the inner reconstructed request). The natural
74
+ * `{ headers: req.headers, body: req.body }` shape works for both.
70
75
  */
71
76
  interface WebhookRawRequest {
72
77
  body: Uint8Array | ArrayBuffer;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "spectrum-ts",
3
- "version": "4.0.0",
3
+ "version": "4.2.0",
4
4
  "description": "Bring agents to any interface — unified messaging SDK for TypeScript.",
5
5
  "repository": {
6
6
  "type": "git",
@@ -27,6 +27,18 @@
27
27
  "types": "./dist/authoring.d.ts",
28
28
  "default": "./dist/authoring.js"
29
29
  },
30
+ "./elysia": {
31
+ "types": "./dist/elysia.d.ts",
32
+ "default": "./dist/elysia.js"
33
+ },
34
+ "./express": {
35
+ "types": "./dist/express.d.ts",
36
+ "default": "./dist/express.js"
37
+ },
38
+ "./hono": {
39
+ "types": "./dist/hono.d.ts",
40
+ "default": "./dist/hono.js"
41
+ },
30
42
  "./providers": {
31
43
  "types": "./dist/providers/index.d.ts",
32
44
  "default": "./dist/providers/index.js"
@@ -55,12 +67,24 @@
55
67
  "zod": "^4.2.1"
56
68
  },
57
69
  "peerDependencies": {
70
+ "elysia": "^1",
71
+ "express": "^4 || ^5",
58
72
  "ffmpeg-static": "^5",
73
+ "hono": "^4",
59
74
  "typescript": "^5 || ^6.0.0"
60
75
  },
61
76
  "peerDependenciesMeta": {
77
+ "elysia": {
78
+ "optional": true
79
+ },
80
+ "express": {
81
+ "optional": true
82
+ },
62
83
  "ffmpeg-static": {
63
84
  "optional": true
85
+ },
86
+ "hono": {
87
+ "optional": true
64
88
  }
65
89
  },
66
90
  "license": "MIT"
@@ -1,13 +0,0 @@
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 | URL;
12
-
13
- export type { PhotoInput as P };