feat: package codex telegram bridge with uv entrypoints

This commit is contained in:
banteg
2025-12-28 21:29:34 +04:00
parent b8de3b4f6b
commit 5f4f97f529
8 changed files with 43 additions and 14 deletions
@@ -0,0 +1,27 @@
[project]
name = "codex-telegram-bridge"
version = "0.1.0"
description = "Telegram bridge tools for Codex."
readme = "readme.md"
requires-python = ">=3.10"
dependencies = [
"markdown-it-py",
"sulguk",
"tomli; python_version < '3.11'",
]
[project.scripts]
codex-telegram-exec-bridge = "codex_telegram_bridge.exec_bridge:main"
codex-telegram-mcp-bridge = "codex_telegram_bridge.mcp_bridge:main"
codex-telegram-tmux-notify = "codex_telegram_bridge.tmux_notify:main"
codex-telegram-tmux-reply = "codex_telegram_bridge.tmux_reply_bot:main"
[build-system]
requires = ["hatchling"]
build-backend = "hatchling.build"
[tool.hatch.build.targets.wheel]
packages = ["src/codex_telegram_bridge"]
[tool.hatch.build.targets.sdist]
include = ["src/codex_telegram_bridge", "readme.md"]
+10 -10
View File
@@ -11,7 +11,7 @@ All options store a mapping from `(chat_id, bot_message_id)` to a route so repli
## Install
1. Ensure `uv` is installed.
2. Use the scripts in this folder as-is; `uv run` will install the inline dependencies.
2. From this folder, run the entrypoints with `uv run` (uses `pyproject.toml` deps).
3. Put your Telegram credentials in `~/.codex/telegram.toml`.
Example `~/.codex/telegram.toml`:
@@ -35,7 +35,7 @@ Optional keys (by mode):
Run:
```bash
uv run exec_bridge.py
uv run codex-telegram-exec-bridge
```
## Option 2: MCP server
@@ -43,7 +43,7 @@ uv run exec_bridge.py
Run:
```bash
uv run mcp_bridge.py
uv run codex-telegram-mcp-bridge
```
## Option 3: tmux
@@ -51,21 +51,21 @@ uv run mcp_bridge.py
Reply injector:
```bash
uv run tmux_reply_bot.py
uv run codex-telegram-tmux-reply
```
Notifier (call from your existing hook):
```bash
uv run tmux_notify.py --tmux-target "codex1:0.0" --text "$TURN_TEXT"
uv run codex-telegram-tmux-notify --tmux-target "codex1:0.0" --text "$TURN_TEXT"
```
Add `--chat-id` if `chat_id` is not set in `~/.codex/telegram.toml`.
## Files
- `bridge_common.py`: shared Telegram client, chunking, and routing store
- `exec_bridge.py`: codex exec + resume bridge
- `mcp_bridge.py`: MCP stdio JSON-RPC bridge
- `tmux_notify.py`: tmux notifier helper
- `tmux_reply_bot.py`: tmux reply injector
- `src/codex_telegram_bridge/bridge_common.py`: shared Telegram client, chunking, and routing store
- `src/codex_telegram_bridge/exec_bridge.py`: codex exec + resume bridge
- `src/codex_telegram_bridge/mcp_bridge.py`: MCP stdio JSON-RPC bridge
- `src/codex_telegram_bridge/tmux_notify.py`: tmux notifier helper
- `src/codex_telegram_bridge/tmux_reply_bot.py`: tmux reply injector
@@ -0,0 +1,2 @@
"""Telegram Codex bridge package."""
@@ -14,7 +14,7 @@ import time
from concurrent.futures import ThreadPoolExecutor
from typing import Any, Callable, Dict, Optional, Tuple
from bridge_common import (
from .bridge_common import (
TelegramClient,
RouteStore,
TELEGRAM_HARD_LIMIT,
@@ -13,7 +13,7 @@ import time
from queue import Queue, Empty
from typing import Any, Dict, List, Optional, Tuple
from bridge_common import (
from .bridge_common import (
TelegramClient,
RouteStore,
config_get,
@@ -9,7 +9,7 @@ import argparse
import sys
from typing import Optional
from bridge_common import TelegramClient, RouteStore, config_get, load_telegram_config
from .bridge_common import TelegramClient, RouteStore, config_get, load_telegram_config
def main() -> None:
@@ -9,7 +9,7 @@ import subprocess
import time
from typing import Optional
from bridge_common import (
from .bridge_common import (
TelegramClient,
RouteStore,
config_get,