spectrum-ts 1.17.1 → 2.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +11 -1
- package/dist/{attachment-DfWSZS5L.d.ts → attachment-B4nSrKVd.d.ts} +1 -1
- package/dist/{authoring-C9uDdZ2F.d.ts → authoring-BjE5BvlO.d.ts} +2 -2
- package/dist/authoring.d.ts +3 -3
- package/dist/authoring.js +6 -3
- package/dist/chunk-34FQGGD7.js +34 -0
- package/dist/chunk-3B4QH4JG.js +35 -0
- package/dist/chunk-3GEJYGZK.js +84 -0
- package/dist/chunk-5LT5J3NR.js +695 -0
- package/dist/{chunk-MC6ZKFSG.js → chunk-5XEFJBN2.js} +25 -103
- package/dist/{chunk-JQN6CRSC.js → chunk-6BI4PFTP.js} +10 -39
- package/dist/{chunk-QGJFZMD5.js → chunk-6UZFVXQF.js} +17 -101
- package/dist/{chunk-YJMPSD3S.js → chunk-ATNAE7OR.js} +196 -47
- package/dist/{chunk-IPOFBAIM.js → chunk-NGC4DJIX.js} +23 -19
- package/dist/{chunk-5TIF3FIE.js → chunk-Q537JPTG.js} +8 -6
- package/dist/{chunk-5BKZJMZV.js → chunk-U3LXXT3W.js} +61 -32
- package/dist/chunk-U7AWXDH6.js +91 -0
- package/dist/{chunk-3OTECDNH.js → chunk-WXY5QP3M.js} +5 -3
- package/dist/index.d.ts +71 -126
- package/dist/index.js +350 -90
- package/dist/manifest.json +6 -0
- package/dist/providers/imessage/index.d.ts +75 -3
- package/dist/providers/imessage/index.js +10 -5
- package/dist/providers/index.d.ts +5 -2
- package/dist/providers/index.js +16 -8
- package/dist/providers/slack/index.d.ts +1 -1
- package/dist/providers/slack/index.js +4 -3
- package/dist/providers/telegram/index.d.ts +47 -0
- package/dist/providers/telegram/index.js +13 -0
- package/dist/providers/terminal/index.d.ts +17 -419
- package/dist/providers/terminal/index.js +5 -3
- package/dist/providers/whatsapp-business/index.d.ts +1 -1
- package/dist/providers/whatsapp-business/index.js +6 -4
- package/dist/types-BD0-kKyv.d.ts +82 -0
- package/dist/{types-DcQ5a7PK.d.ts → types-Bje8aq1k.d.ts} +34 -4
- package/package.json +3 -2
package/README.md
CHANGED
|
@@ -1,6 +1,9 @@
|
|
|
1
1
|
<div align="center">
|
|
2
2
|
<h1>Spectrum</h1>
|
|
3
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
|
+
|
|
4
7
|
<p>
|
|
5
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>
|
|
6
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,7 +13,13 @@
|
|
|
10
13
|
</p>
|
|
11
14
|
</div>
|
|
12
15
|
|
|
13
|
-
|
|
16
|
+
## About Photon
|
|
17
|
+
|
|
18
|
+
**[Photon](https://photon.codes)** builds infrastructure for AI agents that operate over real communication channels.
|
|
19
|
+
|
|
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.
|
|
21
|
+
|
|
22
|
+
Learn more at **https://photon.codes**.
|
|
14
23
|
|
|
15
24
|
## Getting Started
|
|
16
25
|
|
|
@@ -54,6 +63,7 @@ Visit **[docs.photon.codes](https://docs.photon.codes)** to view the full docume
|
|
|
54
63
|
|----------|---------|
|
|
55
64
|
| iMessage | `spectrum-ts/providers/imessage` |
|
|
56
65
|
| WhatsApp | `spectrum-ts/providers/whatsapp` |
|
|
66
|
+
| Telegram | `spectrum-ts/providers/telegram` |
|
|
57
67
|
| Terminal | `spectrum-ts/providers/terminal` |
|
|
58
68
|
| Custom | `definePlatform` from `spectrum-ts` |
|
|
59
69
|
|
|
@@ -1,7 +1,7 @@
|
|
|
1
|
-
import './attachment-
|
|
1
|
+
import './attachment-B4nSrKVd.js';
|
|
2
2
|
import vCard from 'vcf';
|
|
3
3
|
import z__default from 'zod';
|
|
4
|
-
import { U as User, C as ContentBuilder, M as Message,
|
|
4
|
+
import { U as User, C as ContentBuilder, M as Message, e as Space, h as ContentInput } from './types-Bje8aq1k.js';
|
|
5
5
|
|
|
6
6
|
declare const nameSchema: z__default.ZodObject<{
|
|
7
7
|
formatted: z__default.ZodOptional<z__default.ZodString>;
|
package/dist/authoring.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
export { c as asAttachment } from './attachment-
|
|
2
|
-
export { s as asContact, u as asCustom, w as asGroup, x as asPoll, y as asPollOption, z as asReaction, A as asRichlink, B as asText, D as asVoice } from './authoring-
|
|
3
|
-
export {
|
|
1
|
+
export { c as asAttachment } from './attachment-B4nSrKVd.js';
|
|
2
|
+
export { s as asContact, u as asCustom, w as asGroup, x as asPoll, y as asPollOption, z as asReaction, A as asRichlink, B as asText, D as asVoice } from './authoring-BjE5BvlO.js';
|
|
3
|
+
export { d as ProviderMessageRecord } from './types-Bje8aq1k.js';
|
|
4
4
|
import 'zod';
|
|
5
5
|
import 'vcf';
|
|
6
6
|
import 'hotscript';
|
package/dist/authoring.js
CHANGED
|
@@ -1,8 +1,10 @@
|
|
|
1
1
|
import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
|
|
2
2
|
import {
|
|
3
|
-
asGroup,
|
|
4
3
|
asRichlink
|
|
5
|
-
} from "./chunk-
|
|
4
|
+
} from "./chunk-6BI4PFTP.js";
|
|
5
|
+
import {
|
|
6
|
+
asGroup
|
|
7
|
+
} from "./chunk-3B4QH4JG.js";
|
|
6
8
|
import {
|
|
7
9
|
asVoice
|
|
8
10
|
} from "./chunk-NNY6LMSC.js";
|
|
@@ -12,7 +14,8 @@ import {
|
|
|
12
14
|
} from "./chunk-2D27WW5B.js";
|
|
13
15
|
import {
|
|
14
16
|
asContact
|
|
15
|
-
} from "./chunk-
|
|
17
|
+
} from "./chunk-U7AWXDH6.js";
|
|
18
|
+
import "./chunk-6UZFVXQF.js";
|
|
16
19
|
import {
|
|
17
20
|
asAttachment,
|
|
18
21
|
asCustom,
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/fusor/event.ts
|
|
4
|
+
var FUSOR_EVENT_BRAND = /* @__PURE__ */ Symbol.for("spectrum.fusor.event");
|
|
5
|
+
var FUSOR_MESSAGES_CHANNEL = "messages";
|
|
6
|
+
function fusorEvent(name, data) {
|
|
7
|
+
return { [FUSOR_EVENT_BRAND]: true, name, data };
|
|
8
|
+
}
|
|
9
|
+
function isFusorEvent(value) {
|
|
10
|
+
return typeof value === "object" && value !== null && value[FUSOR_EVENT_BRAND] === true;
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
// src/fusor/types.ts
|
|
14
|
+
var FUSOR_BRAND = /* @__PURE__ */ Symbol.for("spectrum.fusor.client");
|
|
15
|
+
|
|
16
|
+
// src/fusor/index.ts
|
|
17
|
+
function fusor(platform, verify) {
|
|
18
|
+
return {
|
|
19
|
+
[FUSOR_BRAND]: true,
|
|
20
|
+
platform,
|
|
21
|
+
verify
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
function isFusorClient(value) {
|
|
25
|
+
return typeof value === "object" && value !== null && value[FUSOR_BRAND] === true;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export {
|
|
29
|
+
FUSOR_MESSAGES_CHANNEL,
|
|
30
|
+
fusorEvent,
|
|
31
|
+
isFusorEvent,
|
|
32
|
+
fusor,
|
|
33
|
+
isFusorClient
|
|
34
|
+
};
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
|
|
2
|
+
import {
|
|
3
|
+
resolveContents
|
|
4
|
+
} from "./chunk-2ILTJC35.js";
|
|
5
|
+
|
|
6
|
+
// src/content/group.ts
|
|
7
|
+
import z from "zod";
|
|
8
|
+
var isMessage = (v) => typeof v === "object" && v !== null && "id" in v && "content" in v;
|
|
9
|
+
var groupSchema = z.object({
|
|
10
|
+
type: z.literal("group"),
|
|
11
|
+
items: z.array(z.custom(isMessage)).min(2)
|
|
12
|
+
});
|
|
13
|
+
var asGroup = (input) => groupSchema.parse({ type: "group", items: input.items });
|
|
14
|
+
var stubOutboundMessage = (content) => ({ id: "", content });
|
|
15
|
+
function group(...items) {
|
|
16
|
+
return {
|
|
17
|
+
build: async () => {
|
|
18
|
+
const resolved = await resolveContents(items);
|
|
19
|
+
const members = [];
|
|
20
|
+
for (const item of resolved) {
|
|
21
|
+
if (item.type === "group" || item.type === "reaction") {
|
|
22
|
+
throw new Error(`group() cannot contain "${item.type}" items`);
|
|
23
|
+
}
|
|
24
|
+
members.push(stubOutboundMessage(item));
|
|
25
|
+
}
|
|
26
|
+
return asGroup({ items: members });
|
|
27
|
+
}
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
export {
|
|
32
|
+
groupSchema,
|
|
33
|
+
asGroup,
|
|
34
|
+
group
|
|
35
|
+
};
|
|
@@ -0,0 +1,84 @@
|
|
|
1
|
+
import { createRequire as __spectrumCreateRequire } from "node:module"; const require = __spectrumCreateRequire(import.meta.url);
|
|
2
|
+
|
|
3
|
+
// src/utils/cloud.ts
|
|
4
|
+
var SPECTRUM_CLOUD_URL = process.env.SPECTRUM_CLOUD_URL ?? "https://spectrum.photon.codes";
|
|
5
|
+
var SpectrumCloudError = class extends Error {
|
|
6
|
+
status;
|
|
7
|
+
code;
|
|
8
|
+
constructor(status, code, message) {
|
|
9
|
+
super(message);
|
|
10
|
+
this.name = "SpectrumCloudError";
|
|
11
|
+
this.status = status;
|
|
12
|
+
this.code = code;
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
var request = async (path, init) => {
|
|
16
|
+
const response = await fetch(`${SPECTRUM_CLOUD_URL}${path}`, init);
|
|
17
|
+
if (!response.ok) {
|
|
18
|
+
const body = await response.text().catch(() => "");
|
|
19
|
+
try {
|
|
20
|
+
const parsed = JSON.parse(body);
|
|
21
|
+
throw new SpectrumCloudError(
|
|
22
|
+
response.status,
|
|
23
|
+
parsed.code,
|
|
24
|
+
parsed.message
|
|
25
|
+
);
|
|
26
|
+
} catch (error) {
|
|
27
|
+
if (error instanceof SpectrumCloudError) {
|
|
28
|
+
throw error;
|
|
29
|
+
}
|
|
30
|
+
throw new SpectrumCloudError(
|
|
31
|
+
response.status,
|
|
32
|
+
"UNKNOWN",
|
|
33
|
+
body || response.statusText
|
|
34
|
+
);
|
|
35
|
+
}
|
|
36
|
+
}
|
|
37
|
+
const json = await response.json();
|
|
38
|
+
if (!json.succeed) {
|
|
39
|
+
throw new SpectrumCloudError(
|
|
40
|
+
response.status,
|
|
41
|
+
"UNKNOWN",
|
|
42
|
+
"Server returned succeed=false"
|
|
43
|
+
);
|
|
44
|
+
}
|
|
45
|
+
return json.data;
|
|
46
|
+
};
|
|
47
|
+
var basicAuth = (projectId, projectSecret) => `Basic ${btoa(`${projectId}:${projectSecret}`)}`;
|
|
48
|
+
var cloud = {
|
|
49
|
+
getProject: (projectId, projectSecret) => request(`/projects/${projectId}/`, {
|
|
50
|
+
headers: { Authorization: basicAuth(projectId, projectSecret) }
|
|
51
|
+
}),
|
|
52
|
+
getSubscription: (projectId) => request(`/projects/${projectId}/billing/subscription`),
|
|
53
|
+
issueImessageTokens: (projectId, projectSecret) => request(`/projects/${projectId}/imessage/tokens`, {
|
|
54
|
+
method: "POST",
|
|
55
|
+
headers: { Authorization: basicAuth(projectId, projectSecret) }
|
|
56
|
+
}),
|
|
57
|
+
getImessageInfo: (projectId) => request(`/projects/${projectId}/imessage/`),
|
|
58
|
+
issueWhatsappBusinessTokens: (projectId, projectSecret) => request(`/projects/${projectId}/whatsapp-business/tokens`, {
|
|
59
|
+
method: "POST",
|
|
60
|
+
headers: { Authorization: basicAuth(projectId, projectSecret) }
|
|
61
|
+
}),
|
|
62
|
+
issueSlackTokens: (projectId, projectSecret) => request(`/projects/${projectId}/slack/tokens`, {
|
|
63
|
+
method: "POST",
|
|
64
|
+
headers: { Authorization: basicAuth(projectId, projectSecret) }
|
|
65
|
+
}),
|
|
66
|
+
issueFusorToken: (projectId, projectSecret) => request(`/projects/${projectId}/fusor/token`, {
|
|
67
|
+
method: "POST",
|
|
68
|
+
headers: { Authorization: basicAuth(projectId, projectSecret) }
|
|
69
|
+
}),
|
|
70
|
+
getPlatforms: (projectId) => request(`/projects/${projectId}/platforms/`),
|
|
71
|
+
togglePlatform: (projectId, projectSecret, platform, enabled) => request(`/projects/${projectId}/platforms/`, {
|
|
72
|
+
method: "PATCH",
|
|
73
|
+
headers: {
|
|
74
|
+
Authorization: basicAuth(projectId, projectSecret),
|
|
75
|
+
"Content-Type": "application/json"
|
|
76
|
+
},
|
|
77
|
+
body: JSON.stringify({ platform, enabled })
|
|
78
|
+
})
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
export {
|
|
82
|
+
SpectrumCloudError,
|
|
83
|
+
cloud
|
|
84
|
+
};
|