spectrum

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

Spectrum

Spectrum

Spectrum is Photon's unified messaging SDK. Write your handler logic once against a single
app.messages
stream and deliver it across every platform — iMessage, WhatsApp Business, your terminal, or a custom platform you build yourself.
The current SDK is
spectrum-ts
(TypeScript). Spectrum is multi-platform by design and multi-language is on the roadmap — additional language SDKs (e.g. Python, Go, Swift) will join the family. The architecture, primitives, and patterns described in this skill are intended to be language-neutral; code samples in the topic files are currently TypeScript and are flagged where the API surface is language-specific (imports, syntax, runtime types).
Spectrum是Photon推出的统一消息SDK。只需针对单一
app.messages
流编写一次处理逻辑,即可将其部署到所有平台——iMessage、WhatsApp Business、终端,或是你自行构建的自定义平台。
当前的SDK为**
spectrum-ts
(TypeScript)。Spectrum从设计之初就支持多平台,且多语言版本已在规划路线图中**——未来将推出更多语言的SDK(如Python、Go、Swift)。本技能中描述的架构、原语与模式均为语言无关;主题文件中的代码示例目前为TypeScript,当API表面存在语言特定内容(导入语句、语法、运行时类型)时会进行标记。

How this skill is organized

本技能的组织结构

Each topic lives in its own file in this directory. Read the file relevant to the user's question.
FileWhen to consult
getting-started.md
Installation, the
Spectrum()
app instance, multi-platform setup, the four core primitives.
messages.md
Receiving messages, the
Message
shape, narrowing on
content.type
, filtering own messages.
content.md
Content builders for outgoing messages:
text
,
attachment
,
voice
,
contact
,
richlink
,
poll
,
group
,
custom
.
spaces-and-users.md
The
Space
interface, typing indicators,
responding
, creating DMs and groups.
reactions-and-replies.md
message.react(...)
, threaded
message.reply(...)
, when to use which.
platform-narrowing.md
Recovering platform-specific types from generic Spectrum primitives.
providers/imessage.md
iMessage provider — cloud, local, dedicated modes, line model, per-phone routing, message effects, tapbacks.
providers/terminal.md
Terminal TUI provider — chat sidebar, reactions, replies, attachments, slash commands.
providers/whatsapp-business.md
WhatsApp Business Cloud API. 1:1 only.
custom-events-and-lifecycle.md
Per-provider event streams (
app.typing
, etc.),
app.stop()
, signal handling.
custom-platforms.md
Authoring your own provider with
definePlatform
— full field reference.
best-practices.md
Production architecture patterns Photon uses internally — debounce pipeline, in-flight cancellation, carry-forward, idempotent retries, per-resource memory, job-failure audit log.
每个主题都存放在本目录下的独立文件中。请根据你的问题查阅对应的文件。
文件适用场景
getting-started.md
安装、
Spectrum()
应用实例、多平台配置、四大核心原语。
messages.md
消息接收、
Message
结构、按
content.type
筛选、过滤自身发送的消息。
content.md
用于发送消息的内容构建器:
text
attachment
voice
contact
richlink
poll
group
custom
spaces-and-users.md
Space
接口、输入状态指示器、
responding
、创建私聊与群组。
reactions-and-replies.md
message.react(...)
、线程化
message.reply(...)
、两种方式的适用场景。
platform-narrowing.md
从通用Spectrum原语中恢复平台特定类型。
providers/imessage.md
iMessage提供商——云、本地、专用模式、线路模型、按手机路由、消息特效、轻触反馈(tapbacks)。
providers/terminal.md
终端TUI提供商——聊天侧边栏、消息反应、回复、附件、斜杠命令。
providers/whatsapp-business.md
WhatsApp Business云API。仅支持一对一消息
custom-events-and-lifecycle.md
按提供商划分的事件流(
app.typing
等)、
app.stop()
、信号处理。
custom-platforms.md
使用
definePlatform
编写自定义提供商——完整字段参考。
best-practices.md
Photon内部采用的生产架构模式——防抖流水线、在途请求取消、状态延续、幂等重试、按资源划分内存、作业失败审计日志。

See also

另请参阅