breath103/serverless-agent/features
Claude Code and agent skill by breath103/serverless-agent
- community
Checking that the SKILL.md file is still in the repository.
Install
npx vskill@latest install breath103/serverless-agent/featuresSKILL.md
The same SKILL.md was published earlier as breath103/serverless-agent/features.
Telegram — channel-style skill
Status: proposed Issue: #5 — Telegram as a channel-style skill (bidirectional mirror) Date: 2026-05-15 Prior art: documents/features/2026-05-15_google-calendar-skill.md — establishes the per-user user_skills row, install/uninstall hooks, and the InstallableSkillConfig tagged-union pattern. This doc reuses that foundation and adds the channel-vs-tool distinction.
Problem
Today every entry in user_skills is tool-style: instantiated via loadSkill(...) in agent-runtime/skills.ts, proxy-wrapped, declared in the LLM sandbox via a .generated.d.ts, and called as skill.method(...) from inside executeCode.
Telegram doesn't fit that shape. It's not a tool the LLM calls — it's a channel that:
- ferries inbound user messages from Telegram into one of our chat sessions, and
- mirrors outbound assistant messages back to the same Telegram chat.
The chat session is the source of truth; Telegram is a one-to-one mirror. So we need:
- A persistent binding between a
user_skillsrow and achat_sessionsrow. - An inbound webhook that converts Telegram Updates into chat messages.
- An outbound hook that fires after the agent finishes a turn and posts the assistant text back to Telegram.
- A way to exclude channel-style skills from the LLM tool list — they must never appear in the agent's sandbox declarations.
Approach
Reuse the existing user_skills table and defineSkill abstraction. Add a new install.type === "telegram" variant alongside "builtin" and "oauth2". The discriminator on install.type is what cleanly partitions:
- Tool skills (
builtin,oauth2) — go throughloadSkill, get a.generated.d.ts, appear in the sandbox. - Channel skills (
telegram) — skipped bybuildSkills, no declaration, never reach the LLM. Their behaviour is driven by webhook routes and a dispatch hook inorchestrate.ts.
No new table. No new abstraction layer. Just one more variant + two new files (route + dispatcher) + a one-line filter in buildSkills + a one-call hook in orchestrate.ts.
Why install.type as the discriminator (not a separate kind: "tool" | "channel" field)
The frontend already filters skills by install.type (InstallTypeFilteredSkillMap<"oauth2"> in skills/index.ts:30). Adding kind would create two parallel discriminators that have to stay aligned. Letting install.type carry the channel/tool distinction keeps a single source of truth: if you want a "send-and-receive" channel skill you write install: { type: "telegram", ... } and the type system carries it everywhere automatically.
Data shape
user_skills row — new tagged variant
InstallableSkillConfig gains a { skill_id: "telegram"; config: TelegramSkillConfig } arm automatically by the existing tagged-union machinery in skills/index.ts.
UserSkillRow shape is unchanged. The discriminated union does its job.
No new tables, no new GSIs
Inbound webhook path is /api/telegram/webhook/:userSkillId, so the row is fetched by (user_id, id) — but we don't have user_id in the URL.
Two options:
- (A) Embed user_id in the URL:
/api/telegram/webhook/:userId/:userSkillId. Two unpredictable segments. Fetch by primary key. Cheap. - (B) Add a GSI on `id` alone: lets us look up a skill row by id without knowing user_id. Costs one GSI.
Going with (A) — both segments are server-generated UUIDs and the user never sees the URL. The URL is what we hand to Telegram at install time. No GSI cost, no scan, two key lookups per webhook hit.
Inbound flow
Unsupported media
Telegram Updates carry text for text messages, but photo/video/voice/audio/document/sticker for media. We render media as a single placeholder string and feed it to the chat session:
If a single Update has both text and media (e.g., a photo with a caption), join them: <caption>\n[image] - not supported yet.
The LLM sees the placeholder and replies naturally ("sorry, I can't read images yet"), which the outbound hook posts back to Telegram. No special prompting needed.
No new ChatSessionKind
A chat is a chat — Telegram is just another input device. A Telegram-initiated chat gets kind: "user", exactly as if the user had typed it into the web app. The user can keep going on the same chat from web OR from Telegram; nothing in the backend cares which client the latest message came through, and any assistant reply mirrors back to Telegram regardless of which side asked the question.
If we later want a "via Telegram" badge in the sidebar, it can be derived at render time by checking whether any installed Telegram skill row has chat_session_id === thisChat.id. That's a frontend concern, not a stored attribute. Deferring.
Outbound flow
After runChatTurn generates an assistant text block, the existing persistAssistantBlock(block) writes the row. We add one call right after the row write, only in the case "text" branch:
dispatchAssistantTextToChannels:
- Loads
user_skillsrows for the user (already cached for the turn? — no, the rows are loaded inbuildSkillswhich has its own scope. A second read per turn is fine — a few items, single Query). - Filters to rows where
data.skill_id === "telegram"ANDdata.config.chat_session_id === sessionId. - For each match, POSTs to
https://api.telegram.org/bot<token>/sendMessagewith{ chat_id: telegram_chat_id, text, parse_mode: "HTML" }, wheretextis the agent's Markdown converted to Telegram's tiny HTML subset (<b>,<i>,<code>,<pre>,<a href>). On a parse-error 400 the helper retries once with the raw text and noparse_modeso delivery never drops. - Per-row failures are logged + swallowed (a revoked bot token or a deleted Telegram chat must not crash the turn or affect web-UI delivery).
Why only text blocks
tool_use/tool_call rows are internal agent state — sending them to Telegram would surface raw executeCode { code: "..." } payloads to the user, which is noise. Only text is user-facing prose.
Recursion safety
User messages (role=user) are written before the agent loop starts in runChatInBackground. The outbound hook is in persistAssistantBlock, which only runs on assistant content. So inbound→outbound→inbound recursion can't happen by construction.
Markdown → Telegram HTML
The agent emits Markdown; Telegram renders either MarkdownV2 (finicky — every literal ., !, -, (, ), etc. must be escaped outside markers) or a small HTML subset. We picked HTML because it's a closed grammar that's easy to generate correctly:
- HTML-escape the input (
&,<,>) first, so any LLM-emitted<tag>shows as text. - Convert
**bold**/__bold__→<b>,*italic*/_italic_→<i>,~~s~~→<s>, `code→<code>,``code`→<pre>,[label](url)→<a href="url">label</a>. - Headers (
# x) collapse to<b>x</b>(Telegram has no header tag). - Bullets
- itembecome• item(Telegram has no list tag). - Tables (
| a | b |) flatten toa · b(Telegram has no table support at all). - Horizontal rules (
---) become—.
Fallback: if Telegram still rejects (some pathological combination), the helper retries once without parse_mode — delivery survives, formatting is lost for that message only.
Excluding channel skills from the LLM
Single point of exclusion. In agent-runtime/skills.ts's loop over userSkillsRepo.listForUser(...):
Why this is enough:
loadSkill(inskill-runtimes/index.ts) never gets a telegram row → no runtime instance.- No
telegram.generated.d.tsis written → nothing for the agent's sandbox to see. - No proxy binding → telegram methods aren't typeable inside
executeCode.
The exhaustiveness check in loadSkill's switch keeps working: it's exhaustive over InstallableSkillConfig["skill_id"] minus the channel ones we've filtered above. Adding a second channel skill (Slack, Discord) means widening the filter, not the switch.
Type-level partition
Mirror the frontend's Oauth2InstallSkillMap with a sibling type:
This lets the route handler and the dispatcher narrow to telegram skill rows without as.
Install / uninstall
Install — token-based, not OAuth
A new route shape, since OAuth doesn't apply:
Handler:
- Generate
webhook_secret(random 32 bytes hex). - Call
getMeon the Telegram Bot API to verify the token and capturebot_username. Fail 422 with Telegram's error if invalid. userSkillsRepo.upsert({ userId, skillId: "telegram", config: { bot_token, telegram_chat_id: null, chat_session_id: null, webhook_secret, bot_username } }).- Register the webhook with Telegram:
POST https://api.telegram.org/bot<token>/setWebhook { url: <edge>/api/telegram/webhook/<userId>/<userSkillId>, secret_token: webhook_secret, drop_pending_updates: true }. publishRealtimeEventfor the row → frontend settings page reflects connect.
This is the start of the file. Read the full SKILL.md on GitHub.
Security
- Security scanPassed, 95 of 100Pattern checks on the skill's files.
- Model reviewPassed
Quality evaluation
- Task evaluationNot runNo evaluation yet. Run one in Skill Studio.
Source
- SKILL.md in the repositoryCheckingdocuments/features/2026-05-15_telegram-channel-skill.md
Popularity
- Repository stars
- 16
- Repository forks
- 3
- 7-day trend score
- 14
Stars and forks are for the whole GitHub repository, not this skill alone. Not refreshed yet.
Works with
Any agent vskill installs to: 56 targets in all. These 39 have a page on this site.
- Claude Code
- Cursor
- GitHub Copilot
- Windsurf
- Codex
- Gemini CLI
- Cline
- Amp
- Roo Code
- Goose
- Continue
- Kilo Code
- Junie
- Trae
- OpenHands
- Qwen Code
- AI Agent
- Tabnine Chat
- Sourcegraph Cody
- Amazon Q
- Firebase Genkit
- Sweep
- Devin
- Phind
- Mentat
- Claude Desktop
- Aider
- GPT Pilot
- Plandex
- bolt.new
- v0
- Replit Agent
- Anse
- TypingMind
- BetterChatGPT
- LibreChat
- Warp AI
- Pieces
- Fig AI
Embed badge
[](https://verified-skill.com/skills/breath103/serverless-agent/features)