spectrum-ts 4.2.0 → 5.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.
Files changed (46) hide show
  1. package/README.md +29 -67
  2. package/dist/authoring.d.ts +1 -6
  3. package/dist/authoring.js +2 -36
  4. package/dist/elysia.d.ts +1 -94
  5. package/dist/elysia.js +2 -15
  6. package/dist/express.d.ts +1 -62
  7. package/dist/express.js +2 -19
  8. package/dist/hono.d.ts +1 -64
  9. package/dist/hono.js +2 -11
  10. package/dist/index.d.ts +1 -2851
  11. package/dist/index.js +2 -3763
  12. package/dist/manifest.json +5 -5
  13. package/dist/providers/imessage/index.d.ts +1 -222
  14. package/dist/providers/imessage/index.js +2 -25
  15. package/dist/providers/index.d.ts +6 -19
  16. package/dist/providers/index.js +6 -34
  17. package/dist/providers/slack/index.d.ts +1 -46
  18. package/dist/providers/slack/index.js +2 -11
  19. package/dist/providers/telegram/index.d.ts +1 -45
  20. package/dist/providers/telegram/index.js +2 -13
  21. package/dist/providers/terminal/index.d.ts +1 -119
  22. package/dist/providers/terminal/index.js +2 -13
  23. package/dist/providers/whatsapp-business/index.d.ts +1 -27
  24. package/dist/providers/whatsapp-business/index.js +2 -14
  25. package/package.json +11 -38
  26. package/dist/attachment-CnivEhr6.d.ts +0 -29
  27. package/dist/authoring-b9AhXgPI.d.ts +0 -304
  28. package/dist/chunk-2D27WW5B.js +0 -63
  29. package/dist/chunk-34FQGGD7.js +0 -34
  30. package/dist/chunk-3GEJYGZK.js +0 -84
  31. package/dist/chunk-5XEFJBN2.js +0 -197
  32. package/dist/chunk-6UZFVXQF.js +0 -374
  33. package/dist/chunk-A37PM5N2.js +0 -91
  34. package/dist/chunk-ARL2NOBO.js +0 -887
  35. package/dist/chunk-B52VPQO3.js +0 -1379
  36. package/dist/chunk-DMPDLSFU.js +0 -864
  37. package/dist/chunk-FAIFTUV2.js +0 -139
  38. package/dist/chunk-LZXPLXZF.js +0 -35
  39. package/dist/chunk-N6THJDZV.js +0 -929
  40. package/dist/chunk-NLMQ75LH.js +0 -2980
  41. package/dist/chunk-UXAKIXVM.js +0 -409
  42. package/dist/chunk-WXLQNANA.js +0 -539
  43. package/dist/chunk-ZR3TKZMT.js +0 -129
  44. package/dist/read-C4uvozGX.d.ts +0 -53
  45. package/dist/types-CyfLJXgu.d.ts +0 -1530
  46. package/dist/types-ZgFTj5hJ.d.ts +0 -87
package/README.md CHANGED
@@ -1,80 +1,42 @@
1
- <div align="center">
2
- <h1>Spectrum</h1>
3
- <p><strong>Bring agents to any interface.</strong></p>
4
-
5
- Photon (photon.codes) builds Spectrum, a multi-channel agent framework that makes AI agents reachable over real conversation surfaces like iMessage, SMS, and email instead of trapping them in web chat.
6
-
7
- <p>
8
- <a href="https://www.npmjs.com/package/spectrum-ts"><img src="https://img.shields.io/npm/v/spectrum-ts.svg?style=flat&colorA=1a1a1a&colorB=3178c6" alt="npm version" /></a>
9
- <a href="https://www.npmjs.com/package/spectrum-ts"><img src="https://img.shields.io/npm/dm/spectrum-ts.svg?style=flat&colorA=1a1a1a&colorB=3178c6" alt="npm downloads" /></a>
10
- <a href="https://github.com/photon-hq/spectrum-ts/blob/main/LICENSE"><img src="https://img.shields.io/npm/l/spectrum-ts.svg?style=flat&colorA=1a1a1a&colorB=3178c6" alt="license" /></a>
11
- <a href="https://www.typescriptlang.org/"><img src="https://img.shields.io/badge/TypeScript-5+-3178c6?style=flat&colorA=1a1a1a&colorB=3178c6" alt="TypeScript" /></a>
12
- <a href="https://github.com/photon-hq/spectrum-ts/stargazers"><img src="https://img.shields.io/github/stars/photon-hq/spectrum-ts.svg?style=flat&colorA=1a1a1a&colorB=3178c6" alt="github stars" /></a>
13
- </p>
14
- </div>
1
+ # spectrum-ts
15
2
 
16
- ## About Photon
3
+ Bring agents to any interface — a unified messaging SDK for TypeScript.
17
4
 
18
- **[Photon](https://photon.codes)** builds infrastructure for AI agents that operate over real communication channels.
5
+ `spectrum-ts` is the **batteries-included** package: it bundles the runtime
6
+ ([`@spectrum-ts/core`](https://npmjs.com/package/@spectrum-ts/core)) plus
7
+ every official provider, so one install gets you everything.
19
8
 
20
- Spectrum is Photon’s open-source multi-channel agent framework, enabling AI agents to communicate through interfaces people already use—such as iMessage, SMS, email, Slack, Discord, and voice—instead of being confined to web chat.
9
+ ```sh
10
+ bun add spectrum-ts
11
+ ```
21
12
 
22
- Learn more at **https://photon.codes**.
13
+ ```ts
14
+ import { Spectrum } from "spectrum-ts";
15
+ import { telegram } from "spectrum-ts/providers/telegram";
23
16
 
24
- ## Getting Started
17
+ const app = await Spectrum({ providers: [telegram.config({ botToken: "…" })] });
18
+ ```
25
19
 
26
- The fastest way to ship is with **Spectrum Cloud** — hosted infrastructure for platforms like iMessage, with credentials ready in minutes.
20
+ ## Lean installs
27
21
 
28
- 1. Sign up at **[app.photon.codes](https://app.photon.codes)** to get your project ID and secret.
29
- 2. Install the SDK:
22
+ If you only use a couple of platforms and want a smaller install, depend on the
23
+ runtime and just the providers you need instead of this metapackage:
30
24
 
31
- ```bash
32
- bun add spectrum-ts
33
- ```
25
+ ```sh
26
+ bun add @spectrum-ts/core @spectrum-ts/telegram
27
+ ```
34
28
 
35
- 3. Start your app:
36
-
37
- ```typescript
38
- import { Spectrum } from "spectrum-ts";
39
- import { imessage } from "spectrum-ts/providers/imessage";
40
-
41
- const app = await Spectrum({
42
- projectId: process.env.PROJECT_ID,
43
- projectSecret: process.env.PROJECT_SECRET,
44
- providers: [imessage.config()],
45
- });
46
-
47
- for await (const [space, message] of app.messages) {
48
- await space.responding(async () => {
49
- await message.reply("Hello from Spectrum.");
50
- });
51
- }
52
- ```
53
-
54
- Spectrum also runs fully standalone — you can connect to a local iMessage database, bring your own gRPC endpoints, or build your own platform provider. See the [docs](https://docs.photon.codes) for self-hosted setups.
55
-
56
- ## Documentation
57
-
58
- Visit **[docs.photon.codes](https://docs.photon.codes)** to view the full documentation.
59
-
60
- ## Platforms
29
+ ```ts
30
+ import { Spectrum } from "@spectrum-ts/core";
31
+ import { telegram } from "@spectrum-ts/telegram";
32
+ ```
61
33
 
62
34
  | Platform | Package |
63
35
  |----------|---------|
64
- | iMessage | `spectrum-ts/providers/imessage` |
65
- | WhatsApp | `spectrum-ts/providers/whatsapp` |
66
- | Telegram | `spectrum-ts/providers/telegram` |
67
- | Terminal | `spectrum-ts/providers/terminal` |
68
- | Custom | `definePlatform` from `spectrum-ts` |
69
-
70
- ## Issues
71
-
72
- Found a bug or have a feature request? Please [open an issue](https://github.com/photon-hq/spectrum-ts/issues) on GitHub. Before filing, search existing issues to avoid duplicates.
73
-
74
- ## Contributing
75
-
76
- Contributions are welcome. Please read [CONTRIBUTING.md](./CONTRIBUTING.md) for details on our code of conduct and the process for submitting pull requests.
77
-
78
- ## License
36
+ | iMessage | [`@spectrum-ts/imessage`](https://npmjs.com/package/@spectrum-ts/imessage) |
37
+ | Telegram | [`@spectrum-ts/telegram`](https://npmjs.com/package/@spectrum-ts/telegram) |
38
+ | Slack | [`@spectrum-ts/slack`](https://npmjs.com/package/@spectrum-ts/slack) |
39
+ | WhatsApp Business | [`@spectrum-ts/whatsapp-business`](https://npmjs.com/package/@spectrum-ts/whatsapp-business) |
40
+ | Terminal | [`@spectrum-ts/terminal`](https://npmjs.com/package/@spectrum-ts/terminal) |
79
41
 
80
- [MIT](./LICENSE) © [Photon](https://photon.codes)
42
+ See the [documentation](https://photon.codes/spectrum) for the full guide.
@@ -1,6 +1 @@
1
- export { c as asAttachment } from './attachment-CnivEhr6.js';
2
- export { q as asContact, s as asCustom, u as asGroup, w as asPoll, x as asPollOption, y as asRichlink, z as asText, A as asVoice } from './authoring-b9AhXgPI.js';
3
- export { e as ProviderMessageRecord, $ as asReaction } from './types-CyfLJXgu.js';
4
- import 'zod';
5
- import 'vcf';
6
- import 'hotscript';
1
+ export * from "@spectrum-ts/core/authoring";
package/dist/authoring.js CHANGED
@@ -1,36 +1,2 @@
1
- import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
- import {
3
- asVoice
4
- } from "./chunk-FAIFTUV2.js";
5
- import {
6
- asRichlink
7
- } from "./chunk-ZR3TKZMT.js";
8
- import {
9
- asGroup
10
- } from "./chunk-LZXPLXZF.js";
11
- import {
12
- asPoll,
13
- asPollOption
14
- } from "./chunk-2D27WW5B.js";
15
- import {
16
- asContact
17
- } from "./chunk-A37PM5N2.js";
18
- import "./chunk-6UZFVXQF.js";
19
- import {
20
- asAttachment,
21
- asCustom,
22
- asReaction,
23
- asText
24
- } from "./chunk-UXAKIXVM.js";
25
- export {
26
- asAttachment,
27
- asContact,
28
- asCustom,
29
- asGroup,
30
- asPoll,
31
- asPollOption,
32
- asReaction,
33
- asRichlink,
34
- asText,
35
- asVoice
36
- };
1
+ export * from "@spectrum-ts/core/authoring";
2
+ export {};
package/dist/elysia.d.ts CHANGED
@@ -1,94 +1 @@
1
- import { Elysia } from 'elysia';
2
- import { W as WebhookHandler } from './types-ZgFTj5hJ.js';
3
- export { M as Message, S as Space } from './types-CyfLJXgu.js';
4
- import 'hotscript';
5
- import 'zod';
6
-
7
- /**
8
- * The minimal structural surface of a Spectrum instance the plugin needs. Kept
9
- * structural (rather than importing the generic `SpectrumInstance<Providers>`)
10
- * so the plugin stays decoupled from provider typing; a real instance is
11
- * assignable via its Web `Request` webhook overload.
12
- */
13
- interface WebhookReceiver {
14
- webhook(request: Request, handler: WebhookHandler): Promise<Response>;
15
- }
16
- interface SpectrumPluginOptions {
17
- /** The Spectrum instance returned by `await Spectrum({...})`. */
18
- app: WebhookReceiver;
19
- /**
20
- * Invoked once per inbound message, fire-and-forget after the response — the
21
- * same `(space, message)` contract as `app.webhook(request, handler)`. Covers
22
- * both native Spectrum webhooks and fusor webhooks identically.
23
- */
24
- onMessage: WebhookHandler;
25
- /**
26
- * Route the webhook is mounted on.
27
- *
28
- * @default "/spectrum/webhook"
29
- */
30
- path?: string;
31
- }
32
- /**
33
- * Mount a Spectrum webhook endpoint on an Elysia app.
34
- *
35
- * @example
36
- * ```ts
37
- * import { Elysia } from "elysia";
38
- * import { Spectrum } from "spectrum-ts";
39
- * import { spectrum } from "spectrum-ts/elysia";
40
- *
41
- * const app = await Spectrum({ ..., webhookSecret: process.env.SPECTRUM_WEBHOOK_SECRET });
42
- *
43
- * new Elysia()
44
- * .use(spectrum({
45
- * app,
46
- * onMessage: async (space, message) => {
47
- * if (message.content.type === "text") await space.send(`echo: ${message.content.text}`);
48
- * },
49
- * }))
50
- * .listen(3000);
51
- * ```
52
- */
53
- declare function spectrum(options: SpectrumPluginOptions): Elysia<"", {
54
- decorator: {};
55
- store: {};
56
- derive: {};
57
- resolve: {};
58
- }, {
59
- typebox: {};
60
- error: {};
61
- }, {
62
- schema: {};
63
- standaloneSchema: {};
64
- macro: {};
65
- macroFn: {};
66
- parser: {};
67
- response: {};
68
- }, {
69
- [x: string]: {
70
- post: {
71
- body: unknown;
72
- params: {};
73
- query: unknown;
74
- headers: unknown;
75
- response: {
76
- 200: Response;
77
- };
78
- };
79
- };
80
- }, {
81
- derive: {};
82
- resolve: {};
83
- schema: {};
84
- standaloneSchema: {};
85
- response: {};
86
- }, {
87
- derive: {};
88
- resolve: {};
89
- schema: {};
90
- standaloneSchema: {};
91
- response: {};
92
- }>;
93
-
94
- export { type SpectrumPluginOptions, WebhookHandler, spectrum };
1
+ export * from "@spectrum-ts/core/elysia";
package/dist/elysia.js CHANGED
@@ -1,15 +1,2 @@
1
- import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
-
3
- // src/elysia.ts
4
- import { Elysia } from "elysia";
5
- function spectrum(options) {
6
- const { app, onMessage, path = "/spectrum/webhook" } = options;
7
- return new Elysia({ name: "spectrum-webhook", seed: path }).post(
8
- path,
9
- ({ request }) => app.webhook(request, onMessage),
10
- { parse: "none" }
11
- );
12
- }
13
- export {
14
- spectrum
15
- };
1
+ export * from "@spectrum-ts/core/elysia";
2
+ export {};
package/dist/express.d.ts CHANGED
@@ -1,62 +1 @@
1
- import { Router } from 'express';
2
- import { W as WebhookHandler } from './types-ZgFTj5hJ.js';
3
- export { M as Message, S as Space } from './types-CyfLJXgu.js';
4
- import 'hotscript';
5
- import 'zod';
6
-
7
- /**
8
- * The minimal structural surface of a Spectrum instance the plugin needs. Kept
9
- * structural (rather than importing the generic `SpectrumInstance<Providers>`)
10
- * so the plugin stays decoupled from provider typing; a real instance is
11
- * assignable via its raw (`{ body, headers }`) webhook overload.
12
- */
13
- interface WebhookReceiver {
14
- webhook(request: {
15
- body: Uint8Array | ArrayBuffer;
16
- headers?: Record<string, string>;
17
- }, handler: WebhookHandler): Promise<{
18
- body: Uint8Array;
19
- headers: Record<string, string>;
20
- status: number;
21
- }>;
22
- }
23
- interface SpectrumPluginOptions {
24
- /** The Spectrum instance returned by `await Spectrum({...})`. */
25
- app: WebhookReceiver;
26
- /**
27
- * Invoked once per inbound message, fire-and-forget after the response — the
28
- * same `(space, message)` contract as `app.webhook(request, handler)`. Covers
29
- * both native Spectrum webhooks and fusor webhooks identically.
30
- */
31
- onMessage: WebhookHandler;
32
- /**
33
- * Route the webhook is mounted on.
34
- *
35
- * @default "/spectrum/webhook"
36
- */
37
- path?: string;
38
- }
39
- /**
40
- * Mount a Spectrum webhook endpoint on an Express app.
41
- *
42
- * @example
43
- * ```ts
44
- * import express from "express";
45
- * import { Spectrum } from "spectrum-ts";
46
- * import { spectrum } from "spectrum-ts/express";
47
- *
48
- * const app = await Spectrum({ ..., webhookSecret: process.env.SPECTRUM_WEBHOOK_SECRET });
49
- *
50
- * const server = express();
51
- * server.use(spectrum({ // mount before any global express.json()
52
- * app,
53
- * onMessage: async (space, message) => {
54
- * if (message.content.type === "text") await space.send(`echo: ${message.content.text}`);
55
- * },
56
- * }));
57
- * server.listen(3000);
58
- * ```
59
- */
60
- declare function spectrum(options: SpectrumPluginOptions): Router;
61
-
62
- export { type SpectrumPluginOptions, WebhookHandler, spectrum };
1
+ export * from "@spectrum-ts/core/express";
package/dist/express.js CHANGED
@@ -1,19 +1,2 @@
1
- import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
-
3
- // src/express.ts
4
- import express from "express";
5
- function spectrum(options) {
6
- const { app, onMessage, path = "/spectrum/webhook" } = options;
7
- const router = express.Router();
8
- router.post(path, express.raw({ type: "*/*" }), async (req, res) => {
9
- const result = await app.webhook(
10
- { body: req.body, headers: req.headers },
11
- onMessage
12
- );
13
- res.status(result.status).set(result.headers).send(Buffer.from(result.body));
14
- });
15
- return router;
16
- }
17
- export {
18
- spectrum
19
- };
1
+ export * from "@spectrum-ts/core/express";
2
+ export {};
package/dist/hono.d.ts CHANGED
@@ -1,64 +1 @@
1
- import * as hono_hono_base from 'hono/hono-base';
2
- import * as hono_utils_http_status from 'hono/utils/http-status';
3
- import * as hono_types from 'hono/types';
4
- import { W as WebhookHandler } from './types-ZgFTj5hJ.js';
5
- export { M as Message, S as Space } from './types-CyfLJXgu.js';
6
- import 'hotscript';
7
- import 'zod';
8
-
9
- /**
10
- * The minimal structural surface of a Spectrum instance the plugin needs. Kept
11
- * structural (rather than importing the generic `SpectrumInstance<Providers>`)
12
- * so the plugin stays decoupled from provider typing; a real instance is
13
- * assignable via its Web `Request` webhook overload.
14
- */
15
- interface WebhookReceiver {
16
- webhook(request: Request, handler: WebhookHandler): Promise<Response>;
17
- }
18
- interface SpectrumPluginOptions {
19
- /** The Spectrum instance returned by `await Spectrum({...})`. */
20
- app: WebhookReceiver;
21
- /**
22
- * Invoked once per inbound message, fire-and-forget after the response — the
23
- * same `(space, message)` contract as `app.webhook(request, handler)`. Covers
24
- * both native Spectrum webhooks and fusor webhooks identically.
25
- */
26
- onMessage: WebhookHandler;
27
- /**
28
- * Route the webhook is mounted on.
29
- *
30
- * @default "/spectrum/webhook"
31
- */
32
- path?: string;
33
- }
34
- /**
35
- * Mount a Spectrum webhook endpoint on a Hono app.
36
- *
37
- * @example
38
- * ```ts
39
- * import { Hono } from "hono";
40
- * import { Spectrum } from "spectrum-ts";
41
- * import { spectrum } from "spectrum-ts/hono";
42
- *
43
- * const app = await Spectrum({ ..., webhookSecret: process.env.SPECTRUM_WEBHOOK_SECRET });
44
- *
45
- * const server = new Hono().route("/", spectrum({
46
- * app,
47
- * onMessage: async (space, message) => {
48
- * if (message.content.type === "text") await space.send(`echo: ${message.content.text}`);
49
- * },
50
- * }));
51
- * ```
52
- */
53
- declare function spectrum(options: SpectrumPluginOptions): hono_hono_base.HonoBase<hono_types.BlankEnv, {
54
- [x: string]: {
55
- $post: {
56
- input: {};
57
- output: {};
58
- outputFormat: string;
59
- status: hono_utils_http_status.StatusCode;
60
- };
61
- };
62
- }, "/", string>;
63
-
64
- export { type SpectrumPluginOptions, WebhookHandler, spectrum };
1
+ export * from "@spectrum-ts/core/hono";
package/dist/hono.js CHANGED
@@ -1,11 +1,2 @@
1
- import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
2
-
3
- // src/hono.ts
4
- import { Hono } from "hono";
5
- function spectrum(options) {
6
- const { app, onMessage, path = "/spectrum/webhook" } = options;
7
- return new Hono().post(path, (c) => app.webhook(c.req.raw, onMessage));
8
- }
9
- export {
10
- spectrum
11
- };
1
+ export * from "@spectrum-ts/core/hono";
2
+ export {};