跳到主要内容

Channels Reference

本页是 channel catalog status、config blocks、secret references、access policy fields、 doctor checks、live-smoke readiness 和 reload semantics 的权威参考。各 channel setup 页面应 链接到这里,而不是重复 field tables。

Setup 与运行循环

每个已实现 channel 都使用同一套循环:

anyy setup channels CHANNEL --write-config
anyy channels doctor CHANNEL
anyy gateway start
anyy channels reload

setup 写入 config 并保存提供的 secrets。doctor 检查本地 readiness。gateway start 运行 adapters。channels reload 要求正在运行的 gateway 应用编辑后的 channel config,而不必完整重启。

已实现 Channels

运行时 channel catalog 当前将这些 channels 标记为 implemented:

ChannelLabelAliases
telegramTelegramtg
discordDiscord-
slackSlack-
whatsappWhatsAppwa
facebookFacebook Messengerfacebook_messenger, messenger, meta
emailEmailimap, smtp
smsSMS (Twilio)twilio, sms_twilio
dingtalkDingTalkding_talk
feishuFeishu / Larklark
weixinWeixin / WeChatwechat, weixin_wechat
qqbotQQ Botqq, qq_bot
ircIRC-
lineLINE-

这些 catalog entries 已规划,但没有注册 runtime adapters:

ChannelLabel
yuanbaoYuanbao
google_chatGoogle Chat

Doctor 会把 planned channels 报为 configured/planned,而不会假装它们能投递消息。

能力矩阵

下表来自已注册 channel descriptors。它描述 runtime adapter 声明的能力;平台配置和 access policy 仍可能阻止某个 conversation 或 delivery path。

ChannelTransportConversationsThreadsInbound mediaOutbound mediaTypingLive smoke
telegrampollingDM, groupsNoYesNoYesYes
discordlifecycle/socketDM, groupsYesYesNoNoYes
slacklifecycle/socketDM, groupsYesYesNoNoYes
whatsapppollingDM, groupsNoYesNoYesYes
facebookwebhookDMNoYesNoYesYes
emailpollingmailboxYesNoNoNoYes
smswebhookDMNoNoNoNoYes
dingtalklifecycle/socketDM, groupsNoNoNoNoYes
feishulifecycle/websocket, webhook fallbackDM, groupsYesYesNoNoYes
weixinpollingDMNoYesimage, video, audio, voice, fileYesNo
qqbotlifecycle/socketDM, groupsNoNoNoNoYes
irclifecycle/socketDM, groupsNoNoNoNoYes
linewebhookDM, groupsNoNoNoNoYes

Channel Config Blocks

Channel blocks 位于 config.yamlchannels.<name> 下。常见字段:

字段含义
enabledGateway 是否应运行该 adapter。
account_id平台账号/bot 的本地标签,常用于 identity 和 secret paths。
dm_policyDirect-message access policy。
group_policyAdapter 支持 group conversations 时的 group/channel access policy。
allow_fromallowlist policies 允许的 sender/user IDs。
allow_groupsallowlist group policies 允许的 group/channel IDs。
send_chunk_chars对有 message-size limit 的 adapters,限制 outgoing text chunk size。
media_max_bytes会 fetch media 的 adapters 的最大 inbound media download size。

各 channel 在推荐 setup/default mode 下的字段:

ChannelRequired config fieldsRequired secret refsOptional secret refs
telegram-token_ref-
discord-bot_token_ref-
slack-bot_token_refapp_token_ref
weixin-token_ref-
dingtalkclient_idclient_secret_ref-
qqbotapp_idclient_secret_ref-
facebookpage_idpage_access_token_refwebhook_verify_token_ref, app_secret_ref
emailaddress, imap_host, smtp_hostpassword_ref-
irchost, nick-password_ref
smsaccount_sid, from_numberauth_token_ref-
line-channel_access_token_ref, channel_secret_ref-
whatsapp--bridge_token_ref
feishuapp_idapp_secret_reftenant_access_token_ref, verification_token_ref, encrypt_key_ref

可用时使用 anyy setup channels CHANNEL --write-config;它会写入 config block,并把提供的 secrets 存进 profile-local secret files。

上表遵循文档化 setup path 和默认 adapter mode。有些 adapter parser 可以接受更窄的配置块,但 setup 生成的 config 是推荐的运行基线。

Secret References

Channel secret fields 接受标准 secret ref scheme:

Ref含义
secret:path/name读取 <home>/secrets/path/name
env:NAME读取环境变量 NAME
file:/path/to/file读取任意文件。
literal:value使用 literal value。真实凭据应避免使用。

Doctor 会检查本地 channel probe 已知的 secret refs。缺失被 probe 标记为 required 的 refs 会让 该 channel doctor check 失败。Optional refs 只有在存在时才检查。

通过 doctor 不代表每种 adapter mode 都能完成认证。例如,文档化的 Feishu websocket setup 需要 app_idapp_secret_ref

注意

不要把平台 tokens 粘贴到 channel docs、chat messages、screenshots 或 issue reports。请把它们 保存为 secret: refs,或通过 service-manager environment 注入。

Access Policies

Access policies 是 adapter-owned strings,但已实现 channel setup 使用这些常见值:

Policy含义
open接受平台投递给 adapter 的任何人的消息。
allowlist只接受列在 allow_fromallow_groups 中的 IDs。
pairing接受已经 paired 的 identities。
mention在 groups 中,只在 bot 被提及或被明确寻址时回复。
disabled拒绝该 conversation type。

不是每个 adapter 都使用每种 policy。请查看该 channel 的 setup page,了解推荐 policy 和平台特定 identity format。

Access policy 是 channel-level authorization。它不会改变 Anyy 的 tool permissions、 provider credentials 或 profile boundaries。

Live Smoke Checks

anyy channels doctor CHANNEL 会报告 live-smoke readiness,但 doctor 本身不会联系外部平台 API。它只报告真正 live test 是否具备足够 environment。

所有 live tests 的 gate 是:

ANYY_LIVE_CHANNEL_TESTS=1

当 channel-specific variables 也设置完毕时,live-smoke plan 会报告 ready,并打印 Go test 命令,例如:

ANYY_LIVE_CHANNEL_TESTS=1 go test ./internal/channels/telegram -run TestLive -count=1

只用测试账号或安全平台目标运行 live smoke。

Reload Semantics

Channels 在 resident gateway 内运行。编辑 channel config 后,重启 gateway 或请求 channel reload:

anyy channels reload --home ~/.anyy
anyy channels reload --home ~/.anyy --json

Reload 通过本地 socket 把 channel configuration 应用到正在运行的 gateway。如果 gateway 未运行, 先启动它:

anyy gateway start --home ~/.anyy