name: im-agy-codex-bridge
description: Setup, configure, verify, run as a background service, and troubleshoot the multi-channel Feishu/Lark and Telegram dual-bot bridge connecting local Antigravity (agy) and OpenAI Codex (acpx). Use when the user asks to connect Antigravity and Codex to Feishu/Lark or Telegram, verify dual-bot credentials, create a Feishu collaboration group, install or restart the launchd/systemd bridge daemon, configure TELEGRAM_PROXY_URL, file-delivery blocklists or timeouts, or debug WebSocket/polling, @mention relay, or permission errors.
IM Antigravity × Codex Bridge
Run a local dual-bot bridge service that connects Antigravity (agy) and Codex (acpx codex) into Feishu/Lark (WebSocket) and/or Telegram (long polling + optional HTTP proxy) with live progress streaming, [SEND_FILE] / [SEND_IMAGE] uploads, and bounded bot-to-bot @ relay.
1. Locate or Install the Bridge
2. Prerequisites
Verify local Node (>=20) and agent CLIs:
node -v
command -v agy
command -v acpx
If agy or acpx is outside default PATH, set AGY_BIN / ACPX_BIN in .env (auto-detection also checks /opt/homebrew/bin, /opt/homebrew/opt/node/bin, and /usr/local/bin).
3. First-Time Setup & Verification
Follow this order strictly because Feishu rejects saving Long Connection mode unless an active WebSocket client is already connected:
- If cloned from source without prebuilt
dist/, build once:npm install && npm run build
(Skip this step if installed from a Release zip/tarball or install.sh.)
- Configure
.env and verify bot tokens:
Run the interactive wizard (writes .env at mode 600, preserves existing keys, and checks both bots via Feishu API):npm run setup
Or copy .env.example to .env, fill AGY_FEISHU_APP_ID, AGY_FEISHU_APP_SECRET, CODEX_FEISHU_APP_ID, CODEX_FEISHU_APP_SECRET, and run npm run check-bots. See references/feishu-setup.md for app creation and batch permission JSON.
- Start the WebSocket bridge before saving Feishu Event Subscription:
npm start
Keep it running while enabling Long Connection + im.message.receive_v1 in both Feishu apps, then publish versions for both apps.
- Create the collaboration group:
npm run create-group
Copy the printed chat_id into ALLOWED_CHAT_IDS in .env, and lock ALLOWED_USER_UNION_IDS to authorized on_xxx union IDs (inspect inbound logs after sending a test message if unknown).
4. Background Daemon Management
macOS (launchd)
Install/reload (automatically rebuilds if src/ + tsc are present, or runs prebuilt dist/index.js directly):
bash scripts/install-launchd.sh
Check status and logs:
launchctl list | grep im-agy-codex-bridge
tail -n 50 data/logs/bridge.out.log
tail -n 50 data/logs/bridge.err.log
Uninstall:
bash scripts/install-launchd.sh --uninstall
Linux (systemd --user)
Adapt scripts/im-agy-codex-bridge.service.example to ~/.config/systemd/user/im-agy-codex-bridge.service, then run systemctl --user daemon-reload && systemctl --user enable --now im-agy-codex-bridge.
5. In-Chat Operations & Security
- Slash commands (executed once across both bots via shared
message_id dedup):
/help — Show collaboration guide and commands
/status — Show current cwd, agyConversationId, Codex session name, and queue counts
/projects — List project roots discovered in ~/.codex/state_5.sqlite
/cwd <index-or-path> — Switch working directory and start a fresh Codex session epoch
/reset — Clear Antigravity conversation ID, recent context, and rotate Codex session epoch
/stop — Abort running tasks for both bots in the current chat/thread
- File delivery security:
[SEND_FILE:/abs/path] and [SEND_IMAGE:/abs/path] automatically block .env, .ssh, .gnupg, .aws, .npmrc, .pypirc, id_rsa/id_ed25519, clientSecret, and any custom BLOCKED_PATH_PATTERNS configured in .env. Never print .env contents when inspecting config.
6. Troubleshooting
- Feishu refuses to save Long Connection:
npm start (or launchd) is not running yet, or credentials in .env are wrong. Run npm run check-bots first.
code=99991672 on file upload: Missing im:resource scope or app version was not republished after adding permissions.
- Error
230002 in DM (p2p): Only group chats support cross-bot @ relay; p2p disables relay automatically because the other bot is not a member of the DM.
- Long tasks cut off: Default
TASK_TIMEOUT_SEC=0 disables wall-clock limits and relies on IDLE_TIMEOUT_SEC=900 (kills only after 15 minutes of zero stdout/stderr activity).
- Detailed guides:
- Feishu Open Platform permissions, events, and group setup: references/feishu-setup.md
- Telegram
@BotFather setup, privacy mode, and TELEGRAM_PROXY_URL: references/telegram-setup.md
- Full
.env schema and daemon details: references/configuration.md
1---2name: im-agy-codex-bridge3description: Setup, configure, verify, run as a background service, and troubleshoot the multi-channel Feishu/Lark and Telegram dual-bot bridge connecting local Antigravity4---5---6name: im-agy-codex-bridge7description: Setup, configure, verify, run as a background service, and troubleshoot the multi-channel Feishu/Lark and Telegram dual-bot bridge connecting local Antigravity (agy) and OpenAI Codex (acpx). Use when the user asks to connect Antigravity and Codex to Feishu/Lark or Telegram, verify dual-bot credentials, create a Feishu collaboration group, install or restart the launchd/systemd bridge daemon, configure TELEGRAM_PROXY_URL, file-delivery blocklists or timeouts, or debug WebSocket/polling, @mention relay, or permission errors.8---910# IM Antigravity × Codex Bridge1112Run a local dual-bot bridge service that connects **Antigravity (`agy`)** and **Codex (`acpx codex`)** into **Feishu/Lark** (WebSocket) and/or **Telegram** (long polling + optional HTTP proxy) with live progress streaming, `[SEND_FILE]` / `[SEND_IMAGE]` uploads, and bounded bot-to-bot `@` relay.1314## 1. Locate or Install the Bridge1516- **Installed as an Antigravity plugin**: the runtime root sits two levels above this skill (`../..` from `SKILL.md`).17- **Prebuilt Release bundle** (no `npm install` or `tsc` needed): download `im-agy-codex-bridge-latest.zip` from GitHub Releases and run `bash install.sh` (or `npm run setup` inside the extracted folder).18- **One-command remote install**:19 ```bash20 curl -fsSL https://raw.githubusercontent.com/taobinxian/im-agy-codex-bridge/main/install.sh | bash21 ```22- Run all `npm` and `scripts/*` commands from the installed plugin/repo root.2324## 2. Prerequisites2526Verify local Node (`>=20`) and agent CLIs:2728```bash29node -v30command -v agy31command -v acpx32```3334If `agy` or `acpx` is outside default `PATH`, set `AGY_BIN` / `ACPX_BIN` in `.env` (auto-detection also checks `/opt/homebrew/bin`, `/opt/homebrew/opt/node/bin`, and `/usr/local/bin`).3536## 3. First-Time Setup & Verification3738Follow this order strictly because Feishu rejects saving Long Connection mode unless an active WebSocket client is already connected:39401. **If cloned from source without prebuilt `dist/`**, build once:41 ```bash42 npm install && npm run build43 ```44 *(Skip this step if installed from a Release zip/tarball or `install.sh`.)*452. **Configure `.env` and verify bot tokens**:46 Run the interactive wizard (writes `.env` at mode `600`, preserves existing keys, and checks both bots via Feishu API):47 ```bash48 npm run setup49 ```50 Or copy `.env.example` to `.env`, fill `AGY_FEISHU_APP_ID`, `AGY_FEISHU_APP_SECRET`, `CODEX_FEISHU_APP_ID`, `CODEX_FEISHU_APP_SECRET`, and run `npm run check-bots`. See [references/feishu-setup.md](references/feishu-setup.md) for app creation and batch permission JSON.513. **Start the WebSocket bridge before saving Feishu Event Subscription**:52 ```bash53 npm start54 ```55 Keep it running while enabling **Long Connection** + `im.message.receive_v1` in both Feishu apps, then publish versions for both apps.564. **Create the collaboration group**:57 ```bash58 npm run create-group59 ```60 Copy the printed `chat_id` into `ALLOWED_CHAT_IDS` in `.env`, and lock `ALLOWED_USER_UNION_IDS` to authorized `on_xxx` union IDs (inspect inbound logs after sending a test message if unknown).6162## 4. Background Daemon Management6364### macOS (`launchd`)6566Install/reload (automatically rebuilds if `src/` + `tsc` are present, or runs prebuilt `dist/index.js` directly):6768```bash69bash scripts/install-launchd.sh70```7172Check status and logs:7374```bash75launchctl list | grep im-agy-codex-bridge76tail -n 50 data/logs/bridge.out.log77tail -n 50 data/logs/bridge.err.log78```7980Uninstall:8182```bash83bash scripts/install-launchd.sh --uninstall84```8586### Linux (`systemd --user`)8788Adapt `scripts/im-agy-codex-bridge.service.example` to `~/.config/systemd/user/im-agy-codex-bridge.service`, then run `systemctl --user daemon-reload && systemctl --user enable --now im-agy-codex-bridge`.8990## 5. In-Chat Operations & Security9192- **Slash commands** (executed once across both bots via shared `message_id` dedup):93 - `/help` — Show collaboration guide and commands94 - `/status` — Show current `cwd`, `agyConversationId`, Codex session name, and queue counts95 - `/projects` — List project roots discovered in `~/.codex/state_5.sqlite`96 - `/cwd <index-or-path>` — Switch working directory and start a fresh Codex session epoch97 - `/reset` — Clear Antigravity conversation ID, recent context, and rotate Codex session epoch98 - `/stop` — Abort running tasks for both bots in the current chat/thread99- **File delivery security**: `[SEND_FILE:/abs/path]` and `[SEND_IMAGE:/abs/path]` automatically block `.env`, `.ssh`, `.gnupg`, `.aws`, `.npmrc`, `.pypirc`, `id_rsa`/`id_ed25519`, `clientSecret`, and any custom `BLOCKED_PATH_PATTERNS` configured in `.env`. Never print `.env` contents when inspecting config.100101## 6. Troubleshooting102103- **Feishu refuses to save Long Connection**: `npm start` (or `launchd`) is not running yet, or credentials in `.env` are wrong. Run `npm run check-bots` first.104- **`code=99991672` on file upload**: Missing `im:resource` scope or app version was not republished after adding permissions.105- **Error `230002` in DM (`p2p`)**: Only group chats support cross-bot `@` relay; `p2p` disables relay automatically because the other bot is not a member of the DM.106- **Long tasks cut off**: Default `TASK_TIMEOUT_SEC=0` disables wall-clock limits and relies on `IDLE_TIMEOUT_SEC=900` (kills only after 15 minutes of zero stdout/stderr activity).107- **Detailed guides**:108 - Feishu Open Platform permissions, events, and group setup: [references/feishu-setup.md](references/feishu-setup.md)109 - Telegram `@BotFather` setup, privacy mode, and `TELEGRAM_PROXY_URL`: [references/telegram-setup.md](references/telegram-setup.md)110 - Full `.env` schema and daemon details: [references/configuration.md](references/configuration.md)