@dreb/telegram

中文文档
2.83.0发布于 2026/11/13MITTypeScriptES Module构建来源已验证近 30 天下载 3693

Telegram bot frontend for dreb coding agent

原始使用文档
文档目录12 节
  1. Setup
  2. 1. Create a Telegram bot
  3. 2. Get your Telegram user ID
  4. 3. Configure environment variables
  5. 4. Create secrets file
  6. 5. Install and run
  7. 6. Systemd service (recommended)
  8. Commands
  9. Session
  10. Agent
  11. Control
  12. Features

@dreb/telegram

Telegram bot frontend for the dreb coding agent. Communicates with dreb via its native RPC protocol (stdin/stdout JSONL).

Setup

1. Create a Telegram bot

Talk to @BotFather on Telegram and create a new bot with /newbot. Copy the token.

2. Get your Telegram user ID

Message @userinfobot to get your numeric user ID.

3. Configure environment variables

VariableRequiredDescription
TELEGRAM_BOT_TOKEN✅Bot API token from BotFather
ALLOWED_USER_IDS✅Comma-separated authorized user IDs
DREB_WORKING_DIRWorking directory for sessions (default: $HOME)
DREB_PATHPath to dreb binary (default: dreb)
DREB_TELEGRAM_SERVICESystemd service name (default: dreb-telegram)
DREB_PROVIDERLLM provider (e.g., anthropic)
DREB_MODELModel ID (e.g., claude-sonnet-4)

4. Create secrets file

The bot loads secrets from ~/.dreb/secrets/telegram.env automatically — both when run directly and via systemd.

mkdir -p ~/.dreb/secrets
cat > ~/.dreb/secrets/telegram.env << 'EOF'
TELEGRAM_BOT_TOKEN=your-token-here
ALLOWED_USER_IDS=your-user-id-here
EOF
chmod 600 ~/.dreb/secrets/telegram.env

This file is gitignored. Explicit environment variables take priority over the file.

5. Install and run

npm install -g @dreb/telegram

Set up your secrets (see step 4), then run:

dreb-telegram

The bot auto-loads secrets from ~/.dreb/secrets/telegram.env.

Building from source
# From the monorepo root
npm run build
node packages/telegram/dist/index.js
cp packages/telegram/dreb-telegram.service.template ~/.config/systemd/user/dreb-telegram.service
systemctl --user daemon-reload
systemctl --user enable --now dreb-telegram

Commands

Session

  • /start — Help & command list
  • /new — Start fresh session (preserves current working directory)
  • /new <path> — Start fresh session in the specified directory
  • /new <segment> ... — Mobile shorthand for home-relative paths, e.g. /new projects dreb resolves to ~/projects/dreb; quoted spans work for segments containing spaces, e.g. /new "My Projects" dreb
  • /sessions — List recent sessions
  • /resume <id> — Resume by session ID prefix
  • /recent [N] — Resend last N assistant messages

Agent

  • /status — Connection & version info
  • /stats — Token usage, cost, and per-model latest-100 median TPS with long-term delta (matching the TUI and dashboard)
  • /compact — Compact context
  • /model [pattern] — View/switch model
  • /thinking [level] — View/set thinking level
  • /agents — Background subagent status

Control

  • /cwd — Working directory
  • /stop — Interrupt & clear queue
  • /restart — Restart the bot service

Features

  • Per-user message queue — one prompt at a time, incoming messages queued
  • Live tool display — ephemeral status message shows tools, task lists, subagents, and key parameters
  • Visible tool results — permanent messages show user-facing results from tools such as suggest_next, search, and wait
  • Rate-limited status updates — debounced to avoid Telegram 429 errors
  • File upload — documents, photos, voice, audio, video with 3s batching
  • File download — [[telegram:send:/path]] markers in assistant text
  • Session management — auto-resume latest, prefix matching, persistence
  • Markdown with fallback — tries Markdown first, falls back to plain text
  • Process isolation — one RPC subprocess per user, auto-restart on crash

版本与发布记录

@dreb/telegram 共发布 160 个版本,首次发布于 2026/04/09;过去 12 个月发布了 160 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
2.83.0latest2026/11/13今天
2.82.02026/11/112 天前
2.81.02026/11/102 天前
2.80.02026/11/103 天前
2.79.12026/11/103 天前
2.79.02026/11/076 天前

关于 @dreb/telegram 的常见问题

@dreb/telegram 是什么?

Telegram bot frontend for dreb coding agent

如何安装 @dreb/telegram?

在项目目录运行 npm install @dreb/telegram,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 dreb-telegram,可以用 npx dreb-telegram 直接运行。

@dreb/telegram 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@dreb/telegram 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@dreb/telegram 需要什么版本的 Node.js?

package.json 的 engines 字段要求 Node.js ^26.13.0。版本不符时 npm 默认只给出警告,开启 engine-strict 后会拒绝安装。

@dreb/telegram 可以商用吗?

@dreb/telegram 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@dreb/telegram 的下载量有多少?

根据 npm 官方下载统计,@dreb/telegram 在 2026/10/13 – 2026/11/11 这 30 天内被下载 3,693 次,日均约 123 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@dreb/telegram 还在维护吗?

最新版本 2.83.0 发布于 2026/11/13(今天);至今共发布 160 个版本,其中过去 12 个月发布了 160 个;首次发布于 2026/04/09。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。