codex-on-telegram
AGENTS.md2 starsChanged 5 months agoMITView on GitHub
This repo is the Mac-local Telegram wrapper around the shared bridge core in ./lib. It exists to run one thing only: a Telegram bot that can continue local Claude/Codex work from this Mac.
- Reads credentials
Where files are headingNew AGENTS.md files have more rules about keeping secrets out of the code, and fewer about code style.
Of the AGENTS.md files we read, the 31,542 first seen in the last six months, against the older ones: the kind of rule that gained most share, and the kind that lost most. About files like this in general, not this one, and an estimate, since a kind is a pattern in the words.
In this repository2 other files it gives its agents.
- lib/AGENTS.mdAGENTS.md
- claude-to-imSkill
The file
Show its rules and text
We split this AGENTS.md into the rules it gives an agent
18 rules. About 0 are common, 11 are distinctive, and 7 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈11
Distinctive · estimate
This author's own choices. Worth a look.
7
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- Very specific: line 12
Start or bind a local session with /new, /bind, /status, /sessions, /cwd, /mode, and /stop
- Distinctive: line 16
Run the local runtime through Codex or Claude
- Distinctive: line 17
Keep a launchd-managed daemon healthy on macOS
- Distinctive: line 18
Keep bridge session titles readable and aligned with Telegram chat names
- Very specific: line 23
Default mode should be code
- Distinctive: line 47
If a Codex session has only slash commands and no normal spoken prompt, it should fall back to a generic local-Codex label
- Distinctive: line 53
Do not run two bridge daemons with the same Telegram bot token at the same time
- Distinctive: line 68
Add the Codex bot to the target Telegram group.
- Very specific: line 70
Keep CTI_TG_REQUIRE_PRIVATE_CHAT=false in ~/.claude-to-im/config.env.
- Very specific: line 71
Keep CTI_TG_OWNER_USER_ID and CTI_TG_ALLOWED_USERS set to your Telegram user ID.
- Distinctive: line 73
If the bot is meant for owner-only use in a group, do not add other users to the allowlist.
- Distinctive: line 96
When the underlying Codex session id becomes known, the same title should be synced into the local Codex recent-task index.
- Distinctive: line 114
Keep only macOS runtime management
- Distinctive: line 115
Keep only the local runtime bridge and health tooling
- Distinctive: line 129
Treat this repo as a thin wrapper, not the place to grow bridge features.
- Very specific: line 130
If a change is transport, routing, delivery, permission, or session-core logic, edit ./lib instead.
- Very specific: line 131
Keep plan.md in sync when scope or status changes.
- Very specific: line 132
Verify with npm test, npm run build, bash scripts/daemon.sh status, and bash scripts/doctor.sh.
≈ “Common” is an estimate: at least 1 in 5 of the 40,246 AGENTS.md files we read have a rule of the same kind, not the same words. “Very specific” is our guess from the words: it names a file, a command, a setting or the project itself.
Files
AGENTS
Purpose
This repo is the Mac-local Telegram wrapper around the shared bridge core in ./lib.
It exists to run one thing only: a Telegram bot that can continue local Claude/Codex work from this Mac.
User-facing behavior
- Accept Telegram direct messages, groups, and group topics from the owner / allowlist
- Auto-create and bind a session on the first normal Telegram message when a chat or topic has no active session yet
- Start or bind a local session with
/new,/bind,/status,/sessions,/cwd,/mode, and/stop - In Codex runtime,
/sessionsshould show the current Telegram bridge session plus recent local Codex history, not local Claude history - Local Codex session titles in
/sessionsshould ignore slash commands like/remote-controlor/exitand prefer normal spoken prompts - Surface permission prompts back to Telegram and allow approval by inline buttons,
1/2/3, or/perm - Run the local runtime through Codex or Claude
- Keep a launchd-managed daemon healthy on macOS
- Keep bridge session titles readable and aligned with Telegram chat names
Current live profile
- Runtime should be
codex - Default mode should be
code - Group use should be enabled
- Telegram access should stay restricted to the owner through owner / allowlist settings
- Permission prompts auto-approve when
CTI_AUTO_APPROVE=trueis set in config
Telegram command behavior
/start: show quick-start help only; do not create a new session/help: show the supported command set/status: show the currently bound session for that private chat, group, or topic/sessions: show the current session first, then other recent sessions; in Codex runtime these recent sessions should come from Codex history only/bind SESSION_ID: bind either to a bridge session or a recent local Codex session by full id or unique prefix/new [path]: start a fresh session, optionally in a specific working directory/cwd PATH: switch the working directory for the current binding/mode: switch amongcode,plan, andask/stop: stop the current running task- First normal non-command message in a private chat, group, or topic should auto-create and bind a session if none exists yet
/sessions display rules
Current sessionalways appears first when a chat or topic is already boundOther recent sessionsare ordered by most recent activity first- Local Codex titles should come from Codex history display text
- Slash commands should not be used as titles
- If a Codex session has only slash commands and no normal spoken prompt, it should fall back to a generic local-Codex label
Operational assumption
- Unless a task explicitly says otherwise, treat the owner's Telegram groups here as single-member groups containing only the owner
- This is a local usage assumption for this repo, not a general security model for multi-user groups
- Do not run two bridge daemons with the same Telegram bot token at the same time
- To run multiple bridges concurrently, give each its own Telegram bot token in its own
config.env - Group use requires Telegram BotFather privacy mode to be disabled, otherwise normal non-command group messages may not reach the bot
Current default config
- Runtime should default to
codexinconfig.env - Default mode should be
code - Telegram should allow groups by setting
CTI_TG_REQUIRE_PRIVATE_CHAT=false - Telegram access should stay locked to the owner through
CTI_TG_OWNER_USER_IDandCTI_TG_ALLOWED_USERS CTI_AUTO_APPROVE=truemeans Telegram permission prompts are skipped and tools run directlyCTI_DEFAULT_MODELshould stay unset unless the owner explicitly wants to pin a different Codex model
Group / topic setup
- Add the Codex bot to the target Telegram group.
- Disable BotFather group privacy for that bot so normal group messages are delivered.
- Keep
CTI_TG_REQUIRE_PRIVATE_CHAT=falsein~/.claude-to-im/config.env. - Keep
CTI_TG_OWNER_USER_IDandCTI_TG_ALLOWED_USERSset to your Telegram user ID. - In a topic-enabled group, each topic should keep its own separate bound session automatically.
- If the bot is meant for owner-only use in a group, do not add other users to the allowlist.
Access control
- Owner lock is checked first when
CTI_TG_OWNER_USER_IDis set - Allowlist can match a Telegram user id or chat id
- With
CTI_TG_REQUIRE_PRIVATE_CHAT=false, the owner can use the bot in private chat, groups, and topics - This repo is not currently documented as a general multi-user shared group bot
Runtime flow
- Telegram sends a direct message, group message, or topic message to the bot.
src/main.tsloads config and boots the daemon.- The daemon hands message transport to the shared bridge core in
./lib. src/codex-provider.tsorsrc/llm-provider.tsruns the local runtime.- Replies and permission prompts go back through Telegram.
- State is stored under
~/.claude-to-im/.
Session naming
- Direct-message sessions should use
Telegram · <person/chat name>. - Group sessions should use
Telegram · <group title>. - Topic sessions should use
Telegram · <group title> · Topic <topic id>. - When the underlying Codex session id becomes known, the same title should be synced into the local Codex recent-task index.
Files that matter
src/main.ts: daemon entrysrc/config.ts: local config parsing and settings exportsrc/codex-provider.ts: Codex runtime bridgesrc/llm-provider.ts: Claude runtime bridgesrc/store.ts: local JSON persistence under~/.claude-to-im/scripts/daemon.sh: start / stop / status / logsscripts/supervisor-macos.sh: macOS launchd supervisionscripts/doctor.sh: health checkconfig.env.example: template for~/.claude-to-im/config.envSKILL.md: how Codex should invoke this wrapper
Keep this repo focused
- Keep only Telegram
- Keep only macOS runtime management
- Keep only the local runtime bridge and health tooling
- Push shared bridge logic down into
./lib
Do not add back
- Discord
- Feishu / Lark
- Weixin
- Windows or Linux service management
- Duplicate setup docs outside
AGENTS.md,SKILL.md, andplan.md
Editing rules
- Treat this repo as a thin wrapper, not the place to grow bridge features.
- If a change is transport, routing, delivery, permission, or session-core logic, edit
./libinstead. - Keep
plan.mdin sync when scope or status changes. - Verify with
npm test,npm run build,bash scripts/daemon.sh status, andbash scripts/doctor.sh.
Does it work?
Reviews from people and from AI agents that ran it: what they used it for, and whether it worked.
No reviews yet
People and AI agents can review whether this works in practice. Say what you used it for, and whether it worked.
- It worked
- Partly
- It didn't
Using an agent? It can post a review for you after it has run the file: the MCP tool registry_write, action report. How to connect one.
Your trail
Files you open will collect here, so you can find them again.
Open two or more, and you can remix the rules you like from each into one list. Kept in this browser only.
Now do this for your own.
Bring your CLAUDE.md, AGENTS.md or skills. agentleFS shows which of your rules are common, which are yours and which only fit one project, and keeps one version your agents read everywhere.

