Telegram surface: DM turns, delivery polling, and a generalized core client - #196
Open
BeAChanger wants to merge 1 commit into
Open
Telegram surface: DM turns, delivery polling, and a generalized core client#196BeAChanger wants to merge 1 commit into
BeAChanger wants to merge 1 commit into
Conversation
…lized core client The Slack plugin's core client hard-coded the "slack" surface name, so a second in-process surface had nowhere to stand. Parameterize the client (createCoreClient(deps, surface)) and move the turn bridge into src/api so both surfaces share it. The new src/telegram plugin mirrors the Slack one: long-poll getUpdates for inbound messages, POST turns with surface "telegram", reply into the same chat (threaded when replying to the bot), and claim type "telegram" deliveries for cron/monitor/agent-initiated posts. DM-only for now; group chats are refused out loud rather than mis-scoped. Tests mock the Bot API via an injected fetch and exercise the full path: message to turn, reply posting, long-reply splitting, reply-thread continuation, chat allowlisting, delivery claim/ack, and the surface parameterization itself.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Adds Telegram as a first-class surface alongside Slack and the web:
src/telegram/— a new in-process plugin mirroring the Slack one. Long-pollsgetUpdates(no public URL or TLS needed), bridges each DM message to a turn withsurface: "telegram", posts the reply back to the same chat (threaded when replying to the bot), splits replies > 4096 chars, and claimstype: "telegram"deliveries for cron / monitor / agent-initiated posts (including file documents). Group chats are refused out loud rather than mis-scoped; DM-only for now.src/api/slack-core-client.ts→src/api/core-client.ts:createCoreClient(deps, surface)parameterizes the surface name (default"slack"), and the turn bridge moved tosrc/api/core-bridge.tsso both surfaces share one implementation.wiring.tsnow exposestelegramCorealongsideslackCore;src/index.tsboots the plugin whenTELEGRAM_BOT_TOKENis set.Why
QM's core speaks surfaces generically —
TurnRequest.surfaceflows into session scoping, deliverydestination.type, and the surface tool name (the pi-tools test already asserts atelegramsurface produces atelegramtool). Only the Slack plugin's client was hard-coded to"slack", which blocked a second surface. This change removes that coupling and demonstrates the pattern with a working Telegram surface.Setup
BotFather →
/newbot→ put the token inTELEGRAM_BOT_TOKEN. OptionalTELEGRAM_ALLOWED_CHAT_IDSto restrict which chats the bot answers. Seesrc/telegram/README.md.Test plan
test/telegram-plugin.test.ts(new): mocks the Bot API via an injectedfetchImpland covers message→turn→reply, long-reply splitting, reply-thread continuation, chat allowlisting, delivery claim/ack, and the surface parameterization.test/slack-index.integration.test.tsand the other slack/delivery suites: all still green (216 + 116 tests run locally).tsc --noEmit,eslint,prettier --check, and the root-test-shard plan check all pass.Screenshot: no UI surface — this is a headless plugin; behavior is covered by the tests above.
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.