Skip to content

Add limbo gateway: Telegram and personal WeChat channels - #96

Open
killpanda wants to merge 1 commit into
mainfrom
claude/project-thread-c3oi1f
Open

killpanda wants to merge 1 commit into
mainfrom
claude/project-thread-c3oi1f

Conversation

@killpanda

Copy link
Copy Markdown
Owner

Requested by jack mini · project thread

Summary

Adds limbo gateway, a long-running process that lets owners talk to limbo from Telegram (hand-written Bot API client) and personal WeChat (iLink bot protocol, QR login). It also adds limbo gateway install, which sets up a launchd agent on macOS or a systemd user unit on Linux.

How it works:

  • Sessions. Each chat gets its own session, in daily posture by default. /sessions and /resume <id> switch between that chat's sessions.
  • Access. Owners only. Owners are recorded at login (the first private message on Telegram, the scanning account on WeChat). Strangers are ignored.
  • Messaging. Telegram replies stream by editing the message in place and render Markdown as Telegram HTML. WeChat sends paragraph chunks as plain text. A message sent while a turn is running steers that turn, and /stop interrupts it.
  • Attachments.
    • Photos, files and voice are downloaded and attached; WeChat media is decrypted with AES-128-ECB.
    • The agent can send files back with a new send_file tool (provider channel, effect mutate).
  • Questions. ask_user shows inline buttons on Telegram and a numbered list on WeChat.
  • Outbox. Each chat's outbox:
    • follows the channel's rate limit and retries on 429 and transient errors;
    • merges repeated edits to the same message;
    • holds replies while a WeChat context token is expired and sends them after the next message.
  • State. Kept in ~/.limbo/channels/: credentials (mode 0600), polling cursors, the chat → session map, and a single-instance lock.

Structure

  • src/conversation.rs: Conversation<S: Sink> is pulled out of headless.rs. It is frontend-neutral and shared by headless mode and the gateway workers.
  • src/channels/:
    • the Channel trait and message types;
    • Markdown rendering and splitting;
    • the store;
    • telegram.rs;
    • weixin/ (api, cdn, login).
  • src/gateway/:
    • the router (dedup, access, group addressing);
    • per-chat worker, render, outbox, sessions, send_file;
    • service.rs (launchd and systemd).
  • background.rs: events can now be routed per session, so subagent events reach the right chat; without a route they fall back to the global channel.
  • New CLI commands: limbo gateway [run|install|uninstall] and limbo channels login|logout|status.
  • New config sections: [gateway], [channels.telegram], [channels.weixin].
  • New crates: aes, md-5, qrcode.
  • Docs: new docs/gateway.md; updates to AGENTS.md, CONTEXT.md and README.

Test plan

  • cargo fmt --check, cargo clippy --all-targets -- -D warnings, cargo test (163 pass)
  • Unit tests for:
    • Markdown → Telegram HTML and splitting
    • Telegram update parsing
    • iLink headers and error mapping
    • AES-ECB (FIPS-197 vector), key encodings
    • dedup and access, the session map, the renderer, send_file
    • plist and systemd generation
  • An end-to-end worker test with a mock channel and a fake LLM server: a chat message runs a turn, the reply reaches the chat, the session map is recorded, and /status answers.
  • Not tested live: no real Telegram bot token or WeChat account was available. The WeChat protocol follows the reference ClawBot plugin and is still unverified against the real server.
  • macOS: plist generation is unit-tested; this PR's publish dry run builds the macOS wheel. launchctl bootstrap itself was not run.

Generated by Claude Code

A long-running `limbo gateway` connects chat apps to agents. Each chat
gets its own Conversation (daily posture by default), owners-only access,
streamed replies where the channel can edit, attachments in both
directions (send_file tool), and per-chat session switching.

- conversation.rs: frontend-neutral Conversation<S: Sink> extracted from
  headless, shared by headless and gateway workers
- channels/: Channel trait, Markdown rendering/splitting, credential and
  cursor store, hand-written Telegram Bot API client, WeChat iLink client
  (QR login, AES-128-ECB CDN media)
- gateway/: router (dedup, owners, group addressing), per-chat workers,
  renderer, outbox (rate limits, retries, context parking), send_file,
  launchd (macOS) and systemd (Linux) service install
- background: per-session routing so subagent events reach the right chat
- docs/gateway.md, AGENTS.md, CONTEXT.md, README

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Claude-Session: https://claude.ai/code/session_014BrrmXNfubbsTMK4xeEmP5
@killpanda killpanda self-assigned this Nov 9, 2026
@graphify-labs

graphify-labs Bot commented Nov 9, 2026

Copy link
Copy Markdown

Graphify reviews are paused for this workspace because nobody has used it in 7 days. A workspace owner can resume reviews from the Repositories page: https://app.graphify.com/angus-lab/repositories

This branch has not been deployed

No deployments
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants