A TypeScript service that bridges DingTalk / Feishu / Telegram messages to local AI CLIs (such as codex and claude).
- Supports 1:1 chat integration for
dingtalk,feishu, andtelegram - Supports multiple local agent CLIs and runtime switching via
/use <agent> - Supports streaming replies and automatic long-message chunking
- Isolates sessions per user while preserving provider sessions for continuation
- Includes whitelist control, deduplication, and debug logs
- Supports image input on DingTalk/Feishu (single image,
codexonly) - Includes
doctor,setup, andservicecommands for operations
| Platform | Supported Agents | Supported Capabilities |
|---|---|---|
| DingTalk | codex, claude (and any configured local CLI) |
1:1 text chat, /help /new /use /set_working_dir /status /interrupt, streaming replies, chunked long replies, whitelist, dedupe, debug logs, single-image input (codex only) |
| Feishu | codex, claude (and any configured local CLI) |
1:1 text chat, /help /new /use /set_working_dir /status /interrupt, streaming replies, chunked long replies, whitelist, dedupe, debug logs, single-image input (codex only) |
| Telegram | codex, claude (and any configured local CLI) |
1:1 text chat, /help /new /use /set_working_dir /status /interrupt, streaming replies, chunked long replies, whitelist, dedupe, debug logs, poll/webhook modes (image input not supported yet) |
- Node.js
>= 20 - Target local AI CLI installed and executable (for example
codexorclaude)
npm i -g im-agent-bridge
im-agent-bridge --helpnpm install
npm run dev -- --helpDefault config path: ~/.im-agent-bridge/config.toml
# 1) Generate config (will not overwrite existing file)
im-agent-bridge setup
# 2) Run local checks
im-agent-bridge doctor
# 3) Start service in foreground
im-agent-bridge serve
# 4) Start background service (macOS, first run installs + starts)
im-agent-bridge service install --config ~/.im-agent-bridge/config.tomlWhen you see [serve] <platform> client connected, the platform connection is ready.
im-agent-bridge serve runs in foreground and occupies the current terminal (Ctrl + C to stop).
# global install usage (recommended)
# first time: install and start background service
im-agent-bridge service install --config ~/.im-agent-bridge/config.toml
# later runs: start already installed background service
im-agent-bridge service start
# check status / logs
im-agent-bridge service status
im-agent-bridge service logs --lines 120
# run from source (build first)
npm run build
# first time: install and start background service
node dist/cli.js service install --config ~/.im-agent-bridge/config.toml
# later runs: start already installed background service
node dist/cli.js service start
# check status / logs
node dist/cli.js service status
node dist/cli.js service logs --lines 120nohup im-agent-bridge serve --config ~/.im-agent-bridge/config.toml \
> ~/.im-agent-bridge/serve.log 2>&1 &For long-running production deployments on Linux, prefer systemd or pm2.
Use config.example.toml as reference. Minimum required fields:
platform.kind:dingtalk/feishu/telegram<platform>.*: platform credentials (for example DingTalkclient_idandclient_secret)<platform>.allowed_user_ids: whitelist ([]means allow all)bridge.default_agent: default agentbridge.working_dir: default working directoryagents.<name>.bin: local executable path or command nameagents.<name>.<ENV_NAME>: add environment variables directly under the agent section, useful forCODEX_HOME,OPENAI_API_KEY,CLAUDE_CONFIG_DIR,ANTHROPIC_BASE_URL, andANTHROPIC_AUTH_TOKEN.
Common optional fields:
bridge.reply_mode:stream(default) /final_onlybridge.reply_chunk_chars: chunk size for long repliesbridge.image_enabled,bridge.image_max_mb: image input controlsbridge.debug: debug logs (or setIAB_DEBUG=1)
im-agent-bridge --help
im-agent-bridge setup [--config <path>]
im-agent-bridge doctor [--config <path>] [--remote]
im-agent-bridge serve [--config <path>]
im-agent-bridge service [install|start|stop|restart|status|logs|uninstall]Extra flags for service:
--label <value>: customlaunchdlabel--keepawake none|idle|system|on_ac: only forservice install--lines <number>: only forservice logs- Note:
servicesubcommands are only supported on macOS. - Note:
launchddoes not inherit environment variables from your interactive shell. - If
codex/claudeworks in foreground but fails in background, add the required environment variables directly under[agents.codex]and[agents.claude]. - Prefer setting each CLI's config directory and gateway variables explicitly instead of relying on shell
exports. - Recommended for
codexin background mode:CODEX_HOME,OPENAI_API_KEY - Recommended for
claudein background mode:CLAUDE_CONFIG_DIR,ANTHROPIC_BASE_URL,ANTHROPIC_AUTH_TOKEN - Do not set
HOMEto~/.codexor~/.claude; that points the CLI at the wrong config root.
[agents.codex]
bin = "codex"
CODEX_HOME = "/Users/yourname/.codex"
OPENAI_API_KEY = "sk-..."
[agents.claude]
bin = "claude"
CLAUDE_CONFIG_DIR = "/Users/yourname/.claude"
ANTHROPIC_BASE_URL = "https://api-ai-cn.pingpongx.com"
ANTHROPIC_AUTH_TOKEN = "sk-..."Available in IM chat:
/help: show help/new: create a new logical session/use codex: switch current agent/set_working_dir ~/workspace/project-a: set working directory for current session/status: show current session / agent / working dir state/interrupt: interrupt the current running model task
You can send plain text directly to get replies.
telegram.modesupportspollandwebhookpollis good for local quick usagewebhookrequires a public HTTPStelegram.webhook_url- You can auto-clear webhook when switching back to
poll
- No reply: run
im-agent-bridge doctor --remotefirst - Permission denied: verify sender ID is included in
allowed_user_ids - Agent unavailable: ensure
agents.<name>.binis executable from terminal - Telegram webhook not receiving updates: verify public URL reachability and
webhook_pathmatch - Stops receiving after lock/close lid: verify the machine has not entered sleep
npm run dev -- serve --config ~/.im-agent-bridge/config.toml
npm run doctor -- --config ~/.im-agent-bridge/config.toml --remote
npm test
npm run build
node dist/cli.js serve --config ~/.im-agent-bridge/config.tomlsrc/cli.ts: CLI entrypointsrc/bridge/: core bridge logicsrc/client/: IM platform client implementationssrc/agent/: agent CLI abstraction and implementationssrc/config/: config loading, normalization, and validationsrc/storage/: session / dedupe / logger backends