Telegram integration + Herramientas (external connectors) section - #9
Merged
Conversation
Add a Telegram bot to drive the agents from a phone, and a new 'Herramientas' sidebar section (below Add-ons) to host external connectors (Telegram now; GitHub/Discord/Signal/Reddit shown as coming-soon). Backend - New apps/telegram-bot service (mirrors outbox-worker): long-polls the Telegram Bot API with native fetch (no telegram lib), relays messages to agents via POST /api/tasks (channel = agent id → deterministic orchestrator routing) and polls the task for the reply. Heartbeats to worker_status; hot-reloads config so enable/disable and token changes take effect without a restart. - Transport-agnostic command layer in telegram-bot/src/commands (agents/use/help/ whoami + one-off /<agentId> + active-agent fallback), decoupled from Telegram so a future global command system can reuse it as a shared package. - Access control: allowlist of Telegram user ids + pairing code (/start <code>). - Config: bot token is a secret → key store via PROVIDER_KEY_NAMES + envMapping (telegramBotToken), never DB/.env; non-secret config in system_configs (telegram_config). New GET/POST /system/integrations/telegram endpoints (report tokenConfigured without the value). Registered in KNOWN_SERVICES, desktop services supervisor (phase 2), and the backend bundler. Frontend - New Herramientas view + route + sidebar entry (icon 'tools', below Add-ons). - Telegram card: enable toggle, token field (reuses the key-store save flow), default-agent picker, pairing code, allowlist editor. - ApiService: TelegramIntegration type + get/saveTelegramIntegration, plus telegramBotToken on AppConfig. i18n for nav + herramientas namespace in 5 locales.
…ighlight Telegram bot - Send replies with parse_mode HTML so fenced code renders as a real code frame; new toTelegramHtml() converts markdown code to <pre><code>, HTML-escapes the rest, chunks under the size limit with a plain-text fallback on malformed HTML. - /use <id> <message> now switches AND sends that first message in one go. - Bot-created tasks post isRead:false so the agent shows unread activity in the app until the user opens that chat (POST /tasks honors an isRead flag). - Log relayed messages and agent replies for observability. App chat - Render fenced code as a framed, dark code block (global styles, since the markdown is injected via [innerHTML] and can't be reached by scoped rules). - Syntax highlighting via prismjs (already a dependency); Prism is put on the global eagerly in main.ts so language components load under esbuild. - Per-block copy button with language label (event delegation in the chat view). - Center the scroll-to-bottom button.
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.
Telegram integration + "Herramientas" (external connectors) section
Drive the HydraOps agents from a phone via a Telegram bot, and add a new
Herramientas section in the sidebar (below Add-ons) for connectors toward
external services (Telegram now; GitHub/Discord/Signal/Reddit shown as
coming-soon). Conceptually: Add-ons = tools the agents call; Herramientas =
connectors that operate on HydraOps from the outside.
How it works
POST /api/taskswithchannel = <agentId>(deterministicrouting in the orchestrator). Reply = poll
GET /api/tasks/:iduntil completed(no SSE/WebSocket in the stack). Loopback is auth-exempt, so no token needed.
Backend
apps/telegram-bot(mirrorsoutbox-worker): long-polls theTelegram Bot API with native
fetch(no telegram library), relays messages toagents, polls the task, and sends the reply back. Heartbeats to
worker_status;hot-reloads config so enabling/disabling and token changes take effect without a
restart. Registered in
KNOWN_SERVICES, the desktop services supervisor(phase 2), and the backend bundler.
telegram-bot/src/commands/):agents,use,help,whoami, one-off/<agentId> <msg>, and active-agent fallback —decoupled from Telegram so a future global command system can reuse it as a
shared package.
/use <id> <message>switches and sends in one step./start <code>).PROVIDER_KEY_NAMES+envMapping(telegramBotToken), never DB/.env; masked inGET /config.Non-secret config in
system_configs.telegram_config. NewGET/POST /system/integrations/telegram(reporttokenConfiguredwithout the value).parse_mode: HTMLso fenced code renders as a real codeframe;
POST /tasksacceptsisReadso bot tasks show unread activity in the app.Frontend
token field (reuses the key-store save flow), default-agent picker, pairing code,
allowlist editor; plus coming-soon placeholders. i18n in all 5 locales.
language label, a copy button, and syntax highlighting via
prismjs(already a dependency). Styles live in the global sheet because the markdown is
injected via
[innerHTML]; Prism is put on the global eagerly inmain.tssoits language components load under esbuild.
Verified end-to-end (live)
/start <code>),/agents,/elena …,/use sofia <msg>→ real agentreplies back to Telegram; token stays in the key store (
.env/DB showproxy).a headless browser (copy writes the code to the clipboard).
Out of scope (follow-ups): proactive push notifications (bot messages you when a
task/cron completes), attachments/voice, and the other connectors.