跳转到内容

通道

Bub 使用 channel 适配器在不同 I/O 端点上运行同一套 pipeline。Hook 不感知当前处于哪个 channel。

  • cli:本地交互终端 — 参见 CLI
  • telegram:Telegram 机器人 — 参见 Telegram

本地交互模式:

uv run bub chat

Channel 监听模式(默认启用所有非 cli channel):

uv run bub gateway

仅启用 Telegram:

uv run bub gateway --enable-channel telegram
  • run 命令的默认 session id:<channel>:<chat_id>
  • Telegram channel 的 session id:telegram:<chat_id>
  • chat 命令的默认 session id:cli_session(可通过 --session-id 覆盖)
  • chat 命令的默认 chat id:local

Channel 适配器可以通过两种形式接收出站数据:

  • send(message):最终渲染的出站消息
  • on_event(event, message):模型仍在生成输出时发出的流式事件

使用 on_event 实现增量 UX,如实时文本更新、输入指示器、进度条或块级日志。使用 send 传递最终的持久化出站载荷。

on_event 是可选的。不需要流式行为的 channel 可以忽略它,仅实现 send

  • cli 不做 debounce;每次输入立即处理。
  • 其他 channel 可以按 session 对入站消息进行 debounce 和批处理。
  • 逗号命令(, 前缀)始终绕过 debounce,立即执行。

Bub 核心目前不包含内置的 Discord 适配器。 如需 Discord 支持,请通过 provide_channels 在外部插件中实现。