[feat] Add TelegramModule for Telegram Bot API integration#10
Open
johnsonice wants to merge 1 commit intomainfrom
Open
[feat] Add TelegramModule for Telegram Bot API integration#10johnsonice wants to merge 1 commit intomainfrom
johnsonice wants to merge 1 commit intomainfrom
Conversation
Add Telegram as the second IM channel (after Matrix), enabling agents to receive and respond to messages via Telegram Bot API. V1 scope: - Full duplex: inbound conversation + outbound notifications - One bot token per agent (registered via telegram_register MCP tool) - Long-polling transport with sub-second latency - Text messages + /start and /help commands - DM support + group chat with @mention-required activation - Typing indicator, message chunking (>4096 chars), HTML formatting - Two-tier dedup (in-memory + DB), per-chat rate limiting New files: - module/telegram_module/ (9 files): module, trigger, client, hooks, MCP tools, credential manager, dedup, context builder - Table management scripts for telegram_credentials and telegram_processed_updates - start/telegram-trigger.sh + tmux integration Modified: WorkingSource enum, ChannelTag factory, MODULE_MAP, ALWAYS_LOAD_MODULES, module_runner ports, settings, control panel, run.sh service launcher. Design spec: docs/superpowers/specs/2026-03-29-telegram-integration-design.md Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
BinLiang2021
added a commit
that referenced
this pull request
Apr 10, 2026
- Add 铁律 #10: tier-2 mirror md sync requirement - Add 三级文档体系 section pointing to .nac_doc/README.md - Add 工作流启动 section (scan index → read playbook → read mirror → sync) - Add 深度文档索引 with "何时读" triggers for every reference and playbook - Trim 新建 Module 步骤 to a pointer + 铁律 summary (moved to playbook) - Add .nac_doc/ and scripts/nac_doc_*.py to 目录结构参考 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
BinLiang2021
added a commit
that referenced
this pull request
Apr 10, 2026
Generated by make scaffold-nac-doc. All stubs have frontmatter stub: true and <!-- TODO: intent --> placeholders. Phase 2 (hand-writing critical file intent) happens in a separate session; Phase 3 (lazy fill) is triggered by CLAUDE.md ironclad rule #10 during normal development. Covered by check_nac_doc.py Layer 1 structural invariants (all hold). 326 stub files total across src/xyz_agent_context/, backend/, frontend/src/, and tauri/src-tauri/src/. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
BinLiang2021
added a commit
that referenced
this pull request
Apr 10, 2026
… fallback Two improvements from dogfood testing (simulating a zero-context new contributor reading the docs): 1. .nac_doc/_overview.md now leads with a "项目速览 60 秒版" section: - One-line project description - ASCII architecture diagram (API → AgentRuntime → Services → Repo) - The four dev process commands (dev-backend, dev-frontend, dev-mcp, dev-poller) - Reminder about 铁律 #7 (双运行方式对齐) Previously the overview jumped straight to the reading path, leaving a new contributor without a project-level grounding until they followed the reading path 2-3 layers deep. 2. CLAUDE.md "深度文档索引" fallback note rewritten from "按 .nac_doc/README.md 现场推断" (which doesn't actually work — README.md is project-agnostic methodology) to a concrete 4-step fallback chain: i. Read CLAUDE.md itself (four sections that cover most on-boarding) ii. Read the corresponding mirror md (frontmatter points at source) iii. Read the source file directly (docstrings are in English per 铁律 #1) iv. On completion, fill in the mirror md per 铁律 #10 Plus explicit note that README.md is methodology, NOT project knowledge. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
BinLiang2021
added a commit
that referenced
this pull request
Apr 13, 2026
… cleanup) Fixes today's documented doc debt. Per CLAUDE.md 铁律 #10: "对 .py/.tsx/.ts/.rs 做行为性修改时,必须...更新 md。新增代码文件 → 同一 commit 新增对应 mirror md" — violated across 6 commits today. This commit settles that debt. New mirror md (13 files created over today's dev but mirror never landed): Backend: backend/routes/_dashboard_schema.md backend/routes/_dashboard_helpers.md backend/routes/_rate_limiter.md Frontend dashboard components: AttentionBanners.md · JobsSection.md · MetricsRow.md · QueueBar.md RecentFeed.md · SessionSection.md · Sparkline.md · DashboardSummary.md expandState.md · healthColors.md Updated mirror md (stubs promoted to full intent + stale references fixed): frontend/src/components/dashboard/ AgentCard.md — stub → full (rewritten 3 times in v2/v2.1/v2.1.1/v2.1.2; documents OwnedCard/PublicCard split as permission boundary, expand semantics, stopPropagation contract, rail-dim behavior) ConcurrencyBadge.md — stub → full (v2.1.1 removed owned branch; reasoning for "×N" confusion + public bucket as privacy measure) StatusBadge.md — stub → full (8-kind → icon/color table + extension guide) DurationDisplay.md — stub → full (Date.now() purity exception + polling tick refresh cadence trade-off) frontend/src/pages/DashboardPage.md — updated render section to reflect v2.1.1+ structure (AgentCard self-manages expand, AgentCardExpanded removed, DashboardSummary added); added single-expandedId strategy note Dead code removal: frontend/src/components/dashboard/AgentCardExpanded.tsx — orphaned since v2.1.1 retire; DashboardPage.tsx already explicitly did not render it. Removed file + its mirror md in this commit per 铁律 #10 ("删除代码文件 → 同一 commit 删除对应 mirror md"). Stale "intentionally NOT rendered" comment in DashboardPage.tsx also removed. Not in this commit (acknowledged gaps, separate cleanup): - Tier-3 reference (`.mindflow/project/references/dashboard_system.md`) — dashboard is now substantial enough to warrant one, but user scoped this task to "补文档" (fix debt), not "add tier-3". Separate followup. - pre-commit hook to mechanically enforce 铁律 #10 going forward. Same followup. - last_verified timestamp refresh on mirrors whose underlying code was modified but intent didn't change (active_sessions, dashboardStore, lib/tauri, commands/tray, backend/main, backend/auth, backend/routes/websocket). Their intent descriptions remain accurate; leaving timestamps alone rather than rubber-stamping. tsc -b: exit 0. Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
6 tasks
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
Add Telegram as the second IM channel (after Matrix), enabling agents to receive and respond to messages via Telegram Bot API. Mirrors the MatrixModule architecture pattern.
V1 Scope
telegram_registerMCP tool)getUpdates(timeout=30))/startand/helpcommandstelegram_register,telegram_send_message,telegram_reply_to_messageNew Files (13)
module/telegram_module/— 9 files: module, trigger, client, hooks, MCP tools, credential manager, dedup, context builderutils/database_table_management/create_telegram_credentials_table.pyutils/database_table_management/create_telegram_processed_updates_table.pystart/telegram-trigger.shdocs/superpowers/specs/2026-03-29-telegram-integration-design.mdModified Files (9)
schema/hook_schema.py— addedTELEGRAMtoWorkingSourceenumschema/channel_tag.py— addedChannelTag.telegram()factorymodule/__init__.py— registeredTelegramModuleinMODULE_MAPmodule/_module_impl/loader.py— added toDEFAULT_MODULE_LIST+ALWAYS_LOAD_MODULESmodule/module_runner.py— MCP port 7812settings.py—telegram_bot_token,telegram_allowed_user_idsstart/all.sh,start/control.sh,run.sh— telegram-trigger service integrationDesign Decisions
telegram_registertool is available before any credential existsPre-merge Checklist
import xyz_agent_context.module; .narrative; .services)CREATE TABLE IF NOT EXISTS)Test Plan
TELEGRAM_BOT_TOKENvia agent chat (telegram_registertool)/startto bot in Telegram → welcome message@botname hello→ bot respondstelegram-triggertmux window shows in control panel~/.narranexus/logs/telegram_trigger/🤖 Generated with Claude Code