creating-letta-code-channels
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseCreating Letta Code channels
创建Letta Code渠道
Use this when adding or debugging Letta Code channel support.
适用于添加或调试Letta Code渠道支持的场景。
First choice
首选方案
- User plugin () for headless experiments, community plugins, and fast workflow tests.
~/.letta/channels/<id>/ - First-party channel () when the channel needs bespoke Desktop UI, custom account snapshots, Slack/Discord-style auto-routing, rich protocol fields, or migration/compatibility shims.
src/channels/<id>/
User plugins cannot shadow first-party ids: , , and are ignored under . Use ids like , , or .
telegramslackdiscord~/.letta/channels/telegram-testwhatsapp-communitycustom-chat- 用户插件():适用于无头实验、社区插件以及快速工作流测试。
~/.letta/channels/<id>/ - 官方渠道():当渠道需要定制化桌面UI、自定义账户快照、Slack/Discord风格的自动路由、丰富的协议字段或迁移/兼容性垫片时使用。
src/channels/<id>/
用户插件不能覆盖官方ID:、和在下会被忽略。请使用类似、或的ID。
telegramslackdiscord~/.letta/channels/telegram-testwhatsapp-communitycustom-chatCore workflow
核心工作流
- Work in or a worktree.
~/letta/letta-code - Read on branches with dynamic plugins.
src/channels/README.md - For a user plugin, create:
~/.letta/channels/<id>/channel.json~/.letta/channels/<id>/plugin.mjs~/.letta/channels/<id>/accounts.json
- Always implement if agents should reply via
messageActions.MessageChannel - Start with for testing, or
dmPolicy: "pairing"/allowlistfor known headless deployments.open - Test all four legs:
- plugin discovery/import
- inbound to route/pairing
adapter.onMessage(msg) - routed channel notification reaches the agent
- outbound calls
MessageChannel→messageActions.handleActionadapter.sendMessage
- Run targeted tests, then ,
bun run typecheck,bun run lint.bun run build
- 在或工作树中开展工作。
~/letta/letta-code - 阅读支持动态插件分支上的文档。
src/channels/README.md - 若创建用户插件,需生成以下文件:
~/.letta/channels/<id>/channel.json~/.letta/channels/<id>/plugin.mjs~/.letta/channels/<id>/accounts.json
- 如果Agent需要通过回复,务必实现
MessageChannel。messageActions - 测试阶段先设置,对于已知的无头部署环境,可使用
dmPolicy: "pairing"或allowlist。open - 测试全部四个环节:
- 插件发现/导入
- 入站消息的路由/配对
adapter.onMessage(msg) - 路由后的渠道通知送达Agent
- 出站消息通过调用
MessageChannel→messageActions.handleActionadapter.sendMessage
- 运行针对性测试,然后执行、
bun run typecheck、bun run lint。bun run build
References
参考文档
Read only what is needed:
- — dynamic plugin manifest/account/runtime/headless flow and gotchas.
references/user-plugins.md - — first-party channel file cascade and safety checks.
references/first-party-channels.md - — smoke-test checklist and commands.
references/testing.md
按需阅读以下文档:
- — 动态插件清单/账户/运行时/无头流程及注意事项。
references/user-plugins.md - — 官方渠道文件层级及安全检查。
references/first-party-channels.md - — 冒烟测试清单及命令。
references/testing.md
Scaffold helper
脚手架工具
Use the bundled scaffold for a minimal user plugin skeleton. Replace with this skill directory path:
<path-to-this-skill>bash
npx tsx <path-to-this-skill>/scripts/scaffold-user-channel-plugin.ts \
my-channel "My Channel" \
--runtime-package some-sdk@1.0.0 \
--runtime-module some-sdkIt creates , , and . Replace the TODO inbound/outbound implementation with the real SDK calls.
channel.jsonplugin.mjsaccounts.example.json使用内置脚手架生成最小化的用户插件骨架。将替换为该技能目录路径:
<path-to-this-skill>bash
npx tsx <path-to-this-skill>/scripts/scaffold-user-channel-plugin.ts \
my-channel "My Channel" \
--runtime-package some-sdk@1.0.0 \
--runtime-module some-sdk它会生成、和。将TODO标记的入站/出站实现替换为真实的SDK调用。
channel.jsonplugin.mjsaccounts.example.jsonHard lessons
经验总结
- silently feels broken if
MessageChannelis missing. Every plugin that should reply needsplugin.messageActionsanddescribeMessageTool().handleAction() - For public channels, suppress tool approval/control prompts unless there is verified operator routing. Posting approval prompts publicly leaks tool input and invites forged replies.
approve - User plugin runtime resolution must not count parent/dev . Runtime modules should resolve from explicit runtime dirs only.
node_modules - Headless pairing is CLI-first: .
letta channels pair --channel <id> --code <code> --agent <agent-id> --conversation <conversation-id> - Running listeners reload and
pairing.yamlon the next inbound miss; restart only when adapter/account config itself changed.routing.yaml
- 如果缺少,
plugin.messageActions会看似无响应。所有需要回复的插件都必须实现MessageChannel和describeMessageTool()。handleAction() - 对于公开渠道,除非有已验证的操作员路由,否则应禁用工具审批/控制提示。在公开渠道发布审批提示会泄露工具输入,并可能招致伪造的回复。
approve - 用户插件运行时解析不能依赖父目录/开发环境的。运行时模块应仅从明确指定的运行时目录解析。
node_modules - 无头配对以CLI优先:。
letta channels pair --channel <id> --code <code> --agent <agent-id> --conversation <conversation-id> - 运行中的监听器会在下一次入站消息未匹配时重新加载和
pairing.yaml;仅当适配器/账户配置本身发生变化时才需要重启。routing.yaml