teleo-infrastructure/docs/telegram-leo-x402-bridge-pr-packet.md
2026-06-19 19:28:04 +02:00

83 lines
3.3 KiB
Markdown

# Telegram Leo x402 Bridge PR Packet
## Working Target
Run Leo as a Telegram bot without duplicating Leo/x402 logic: Telegram receives
a user message, forwards it to `https://leo.livingip.xyz/api/agents/leo/chat`,
and replies with the hosted Leo answer.
## Non-Destructive Boundary
- This PR does not start, stop, restart, or mutate any live Telegram service.
- Deployment sync is updated to copy `telegram/` into both
`/opt/teleo-eval/pipeline/telegram/` and `/opt/teleo-eval/telegram/`, matching
the current `teleo-agent@.service` runtime path.
- Existing Rio and Theseus configs do not set `http_chat_proxy_url`, so their
current KB/retrieval path stays unchanged.
- Leo opts into the bridge with `telegram/agents/leo.yaml`.
- The live token's Telegram username readback is `@TeleoHumanBot`; `@teLEOhuman`
remains an alias for continuity with Leo's X identity.
- Secret contents are not stored or printed. The config references only the
expected token-file name: `leo-telegram-bot-token`.
## Local Proof Commands
```sh
.venv/bin/python -m pytest tests/test_telegram_leo_x402_bridge.py
.venv/bin/python -m py_compile telegram/agent_config.py telegram/http_chat_proxy.py telegram/bot.py telegram/agent_runner.py
.venv/bin/python telegram/agent_runner.py --agent leo --validate
.venv/bin/python scripts/check_telegram_leo_x402_bridge.py
bash -n deploy/deploy.sh deploy/auto-deploy.sh
git diff --check
```
Primary retained proof path:
```text
docs/reports/telegram-leo-x402-bridge-proof.json
```
## Production Promotion Commands
Run only after review and after confirming the token filename exists on the VPS:
```sh
test -f /opt/teleo-eval/secrets/leo-telegram-bot-token
test -f /opt/teleo-eval/telegram/agents/leo.yaml
test -f /opt/teleo-eval/telegram/http_chat_proxy.py
/opt/teleo-eval/pipeline/.venv/bin/python3 /opt/teleo-eval/telegram/agent_runner.py --agent leo --validate
systemctl start teleo-agent@leo
journalctl -u teleo-agent@leo -n 100 --no-pager
```
Then send Leo a Telegram DM or tag the configured handle and retain:
- Telegram message/reply screenshot or export.
- `journalctl -u teleo-agent@leo` lines showing the proxy path.
- Caddy access log line for `POST /api/agents/leo/chat` on `leo.livingip.xyz`.
## Reviewer CTA
Approve deploying this as the next non-destructive Telegram step if these facts
are acceptable:
- `leo-telegram-bot-token` exists on the VPS.
- Telegram `getMe` for that token reports bot username `TeleoHumanBot`.
- `teleo-agent@leo.service` is currently inactive, so this is an additive new
agent process rather than a restart of Rio or Theseus.
- The public Leo HTTP route already returns a parseable Leo reply.
- Existing Rio/Theseus configs do not set `http_chat_proxy_url`.
- The deploy-path mismatch is fixed by syncing Telegram files to the runtime
path used by `teleo-agent@.service`.
## Strongest Claim Before Promotion
PR-ready local bridge only: config and parser tests prove Telegram can be wired
to the hosted Leo HTTP route without changing existing Rio/Theseus behavior.
## Strongest Claim After Promotion
If the production commands pass and a Telegram message returns a hosted Leo
answer, Telegram Leo is a live transport for Leo's public HTTP chat route.
Payment and external research claims still come from retained HTTP/x402 proof
artifacts, not from Telegram by itself.