codex-on-telegram / lib
AGENTS.md2 starsChanged 5 months agoMITView on GitHub
This repository is the shared Telegram bridge core used by local host wrappers such as ../claude-to-im. It should stay small, transport-focused, and reusable.
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.
- AGENTS.mdAGENTS.md
- claude-to-imSkill
The file
We split this AGENTS.md into the rules it gives an agent
4 rules. About 0 are common, 1 is distinctive, and 3 are very specific to this project.
≈0
Common · estimate
Many files like this have a rule of this kind.
≈1
Distinctive · estimate
This author's own choices. Worth a look.
3
Very specific
Tied to their project's names, files or tools. Probably skip.
- Common
- Distinctive
- Very specific
- could be automatic: a setting could enforce it
- Distinctive: line 59
Do not reintroduce hidden session creation for read-only commands.
- Very specific: line 60
Do not ship any change without tests and a rebuilt dist/.
- Very specific: line 61
Keep plan.md in sync with scope and verification state.
- Very specific: line 62
Verify with npm run typecheck, npm run test:unit, and npm run build.
≈ “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.md
Purpose
This repository is the shared Telegram bridge core used by local host wrappers such as ../claude-to-im.
It should stay small, transport-focused, and reusable.
What this repo owns
src/lib/bridge/host.ts: host contractssrc/lib/bridge/bridge-manager.ts: bridge orchestration and message handlingsrc/lib/bridge/adapters/telegram-adapter.ts: built-in Telegram transportsrc/lib/bridge/channel-router.ts: chat-to-session bindingsrc/lib/bridge/delivery-layer.ts: outbound send / retry / dedupsrc/lib/bridge/permission-broker.ts: permission prompt and callback handlingsrc/lib/bridge/security/*: validation and rate limitingsrc/lib/bridge/local-codex-sessions.ts: local Codex session discoverysrc/__tests__/unit/*: thin-bridge safety and regression tests
Message flow
- Adapter receives a Telegram update.
bridge-manager.tsconsumes the queued update.- Commands such as
/new,/bind,/sessions, and/permare handled directly. - First normal messages in a Telegram DM, group, or topic can auto-create and bind a bridge session when no active binding exists.
- Normal messages are routed to the bound session.
conversation-engine.tsstreams runtime output.delivery-layer.tssends the reply back through Telegram.- Bridge-backed session titles should reflect the Telegram chat or topic name and sync back into the local Codex recent-task index when possible.
Current Telegram semantics
- Group chats and Telegram topics are first-class routes, not private-chat fallbacks.
- One Telegram group can hold separate bindings per topic.
- Group commands with
@botnamesuffix must resolve like the plain command. - Permission handling can flow through inline buttons,
1/2/3quick replies, or/perm. - Built-in Telegram display names should prefer the group title for group traffic and the person/chat name for DMs.
- Local Codex title sync should append a new
session_index.jsonlrecord instead of rewriting the whole file.
Keep this repo focused
- Telegram transport only
- Shared bridge behavior only
- Session routing, delivery, permission, security, and discovery only
- Tests that stop false success and silent message loss
Do not add back
- Discord
- Feishu / Lark
- Weixin
- Host-specific login, QR, account, or device flows
- Duplicate internal docs spread across the tree
Editing rules
- Fix shared runtime bugs here; fix local machine boot logic in the consuming host repo.
- Do not reintroduce hidden session creation for read-only commands.
- Do not ship any change without tests and a rebuilt
dist/. - Keep
plan.mdin sync with scope and verification state. - Verify with
npm run typecheck,npm run test:unit, andnpm run build.
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.

