Synthèse automatique
Ajoute le support Agent Swarm (Teams) à un canal Telegram déjà configuré, en donnant à chaque sous-agent sa propre identité de bot dans le groupe.
Points forts
- Décrit précisément le flux technique : fichier IPC avec champ sender, watcher côté hôte, attribution d'un bot du pool en round-robin stable par groupe
- Fournit les étapes concrètes côté BotFather (création des bots, désactivation du Group Privacy) et les ajouts de code TypeScript (config, initBotPool, Api Grammy sans polling)
- Sépare clairement l'agent principal (réception + réponses du lead) des bots du pool (envoi uniquement), ce qui évite des conflits de polling
Limites
- Suppose que /add-telegram est déjà exécuté et que src/telegram.ts ainsi que TELEGRAM_BOT_TOKEN existent ; sans cela le skill ne fait rien
- Demande à l'utilisateur de créer manuellement 3 à 5 bots et de coller leurs tokens, avec un risque de mauvaise manipulation des secrets
- Le renommage via setMyName modifie le nom du bot au niveau du compte, donc l'attribution d'un rôle par groupe peut se chevaucher entre plusieurs groupes
À utiliser quand un canal Telegram existe déjà et que l'on veut que les sous-agents d'une équipe apparaissent comme des bots distincts dans le groupe.
À éviter si Telegram n'est pas encore configuré ou si l'on n'a pas la main sur le code source de l'hôte pour modifier src/config.ts et src/telegram.ts.
Analyse de sécurité
PrudenceThis is a legitimate, fairly detailed integration guide for adding multi-bot Telegram identity support to an existing agent host. It touches powerful surfaces (source code edits, .env secret copies, npm/container builds, service restarts, network calls to api.telegram.org) but every action is purposeful and reversible, with no data exfiltration, obfuscated payloads, or destructive commands. The only meaningful concerns are operational hygiene around bot tokens and privileged service restarts, so it warrants caution rather than a risky rating.
- •Performs privileged host operations: rebuilds and restarts the running service via launchctl unload/load or systemctl --user restart, and edits the launchd plist systemd unit
- •Instructs copying secrets-bearing .env into data/env/env and adding multiple bot tokens to the environment; token handling is legitimate but expands secret surface if the target file is not access-controlled
- •Troubleshooting step suggests `curl -s "https://api.telegram.org/botTOKEN/getMe"` — putting a real token on the command line exposes it in shell history and process listings; better to use an env var/header
- •Modifies MCP tool schema and host IPC routing code, which if misapplied could route messages incorrectly, but the changes are scoped and reversible with a documented removal procedure
- •No exfiltration, obfuscation, destructive file operations, or safety-disabling instructions; no prompt-injection or role-manipulation attempts in the content
- •Requires handling Telegram bot tokens: instructs the user to provide tokens and writes them to .env, data/env/env, and the launchd plist, increasing secret exposure.
- •Troubleshooting suggests curl with the bot token embedded in the URL, which can leak tokens via shell history or process listings if a real token is used.
- •Runs build/deploy commands and restarts launchd/systemd services; legitimate but high-impact operational actions.
- •No allowed-tools are declared even though the skill requires shell access, file edits, and service restarts.
Exemples
Telegram is already connected via /add-telegram. Now add agent swarm support so each subagent in my team gets its own bot identity in the group.Set up TELEGRAM_BOT_POOL with the three bot tokens I just created in BotFather, and make sure each pool bot has Group Privacy turned off.When my Researcher subagent calls send_message, route it through a pool bot renamed to 'Researcher' so the group can tell the agents apart.name: add-telegram-swarm description: Add Agent Swarm (Teams) support to Telegram. Each subagent gets its own bot identity in the group. Requires Telegram channel to be set up first (use /add-telegram). Triggers on "agent swarm", "agent teams telegram", "telegram swarm", "bot pool". disable-model-invocation: true
Add Agent Swarm to Telegram
This skill adds Agent Teams (Swarm) support to an existing Telegram channel. Each subagent in a team gets its own bot identity in the Telegram group, so users can visually distinguish which agent is speaking.
Prerequisite: Telegram must already be set up via the /add-telegram skill. If src/telegram.ts does not exist or TELEGRAM_BOT_TOKEN is not configured, tell the user to run /add-telegram first.
How It Works
- The main bot receives messages and sends lead agent responses (already set up by
/add-telegram) - Pool bots are send-only — each gets a Grammy
Apiinstance (no polling) - When a subagent calls
send_messagewith asenderparameter, the host assigns a pool bot and renames it to match the sender's role - Messages appear in Telegram from different bot identities
Subagent calls send_message(text: "Found 3 results", sender: "Researcher")
→ MCP writes IPC file with sender field
→ Host IPC watcher picks it up
→ Assigns pool bot #2 to "Researcher" (round-robin, stable per-group)
→ Renames pool bot #2 to "Researcher" via setMyName
→ Sends message via pool bot #2's Api instance
→ Appears in Telegram from "Researcher" bot
Prerequisites
1. Create Pool Bots
Tell the user:
I need you to create 3-5 Telegram bots to use as the agent pool. These will be renamed dynamically to match agent roles.
- Open Telegram and search for
@BotFather- Send
/newbotfor each bot:
- Give them any placeholder name (e.g., "Bot 1", "Bot 2")
- Usernames like
myproject_swarm_1_bot,myproject_swarm_2_bot, etc.- Copy all the tokens
- Add all bots to your Telegram group(s) where you want agent teams
Wait for user to provide the tokens.
2. Disable Group Privacy for Pool Bots
Tell the user:
Important: Each pool bot needs Group Privacy disabled so it can send messages in groups.
For each pool bot in
@BotFather:
- Send
/mybotsand select the bot- Go to Bot Settings > Group Privacy > Turn off
Then add all pool bots to your Telegram group(s).
Implementation
Step 1: Update Configuration
Read src/config.ts and add the bot pool config near the other Telegram exports:
export const TELEGRAM_BOT_POOL = (process.env.TELEGRAM_BOT_POOL || '')
.split(',')
.map((t) => t.trim())
.filter(Boolean);
Step 2: Add Bot Pool to Telegram Module
Read src/telegram.ts and add the following:
- Update imports — add
Apito the Grammy import:
import { Api, Bot } from 'grammy';
- Add pool state after the existing
let botdeclaration:
// Bot pool for agent teams: send-only Api instances (no polling)
const poolApis: Api[] = [];
// Maps "{groupFolder}:{senderName}" → pool Api index for stable assignment
const senderBotMap = new Map<string, number>();
let nextPoolIndex = 0;
- Add pool functions — place these before the
isTelegramConnectedfunction:
/**
* Initialize send-only Api instances for the bot pool.
* Each pool bot can send messages but doesn't poll for updates.
*/
export async function initBotPool(tokens: string[]): Promise<void> {
for (const token of tokens) {
try {
const api = new Api(token);
const me = await api.getMe();
poolApis.push(api);
logger.info(
{ username: me.username, id: me.id, poolSize: poolApis.length },
'Pool bot initialized',
);
} catch (err) {
logger.error({ err }, 'Failed to initialize pool bot');
}
}
if (poolApis.length > 0) {
logger.info({ count: poolApis.length }, 'Telegram bot pool ready');
}
}
/**
* Send a message via a pool bot assigned to the given sender name.
* Assigns bots round-robin on first use; subsequent messages from the
* same sender in the same group always use the same bot.
* On first assignment, renames the bot to match the sender's role.
*/
export async function sendPoolMessage(
chatId: string,
text: string,
sender: string,
groupFolder: string,
): Promise<void> {
if (poolApis.length === 0) {
// No pool bots — fall back to main bot
await sendTelegramMessage(chatId, text);
return;
}
const key = `${groupFolder}:${sender}`;
let idx = senderBotMap.get(key);
if (idx === undefined) {
idx = nextPoolIndex % poolApis.length;
nextPoolIndex++;
senderBotMap.set(key, idx);
// Rename the bot to match the sender's role, then wait for Telegram to propagate
try {
await poolApis[idx].setMyName(sender);
await new Promise((r) => setTimeout(r, 2000));
logger.info({ sender, groupFolder, poolIndex: idx }, 'Assigned and renamed pool bot');
} catch (err) {
logger.warn({ sender, err }, 'Failed to rename pool bot (sending anyway)');
}
}
const api = poolApis[idx];
try {
const numericId = chatId.replace(/^tg:/, '');
const MAX_LENGTH = 4096;
if (text.length <= MAX_LENGTH) {
await api.sendMessage(numericId, text);
} else {
for (let i = 0; i < text.length; i += MAX_LENGTH) {
await api.sendMessage(numericId, text.slice(i, i + MAX_LENGTH));
}
}
logger.info({ chatId, sender, poolIndex: idx, length: text.length }, 'Pool message sent');
} catch (err) {
logger.error({ chatId, sender, err }, 'Failed to send pool message');
}
}
Step 3: Add sender Parameter to MCP Tool
Read container/agent-runner/src/ipc-mcp-stdio.ts and update the send_message tool to accept an optional sender parameter:
Change the tool's schema from:
{ text: z.string().describe('The message text to send') },
To:
{
text: z.string().describe('The message text to send'),
sender: z.string().optional().describe('Your role/identity name (e.g. "Researcher"). When set, messages appear from a dedicated bot in Telegram.'),
},
And update the handler to include sender in the IPC data:
async (args) => {
const data: Record<string, string | undefined> = {
type: 'message',
chatJid,
text: args.text,
sender: args.sender || undefined,
groupFolder,
timestamp: new Date().toISOString(),
};
writeIpcFile(MESSAGES_DIR, data);
return { content: [{ type: 'text' as const, text: 'Message sent.' }] };
},
Step 4: Update Host IPC Routing
Read src/ipc.ts and make these changes:
-
Add imports — add
sendPoolMessageandinitBotPoolfrom the Telegram swarm module, andTELEGRAM_BOT_POOLfrom config. -
Update IPC message routing — in
src/ipc.ts, find where thesendMessagedependency is called to deliver IPC messages (insideprocessIpcFiles). ThesendMessageis passed in via theIpcDepsparameter. Wrap it to route Telegram swarm messages through the bot pool:
if (data.sender && data.chatJid.startsWith('tg:')) {
await sendPoolMessage(
data.chatJid,
data.text,
data.sender,
sourceGroup,
);
} else {
await deps.sendMessage(data.chatJid, data.text);
}
Note: The assistant name prefix is handled by formatOutbound() in the router — Telegram channels have prefixAssistantName = false so no prefix is added for tg: JIDs.
- Initialize pool in
main()insrc/index.ts— after creating the Telegram channel, add:
if (TELEGRAM_BOT_POOL.length > 0) {
await initBotPool(TELEGRAM_BOT_POOL);
}
Step 5: Update CLAUDE.md Files
5a. Add global message formatting rules
Read groups/global/CLAUDE.md and add a Message Formatting section:
## Message Formatting
NEVER use markdown. Only use WhatsApp/Telegram formatting:
- *single asterisks* for bold (NEVER **double asterisks**)
- _underscores_ for italic
- • bullet points
- ```triple backticks``` for code
No ## headings. No [links](url). No **double stars**.
5b. Update existing group CLAUDE.md headings
In any group CLAUDE.md that has a "WhatsApp Formatting" section (e.g. groups/main/CLAUDE.md), rename the heading to reflect multi-channel support:
## WhatsApp Formatting (and other messaging apps)
5c. Add Agent Teams instructions to Telegram groups
For each Telegram group that will use agent teams, create or update its groups/{folder}/CLAUDE.md with these instructions. Read the existing CLAUDE.md first (or groups/global/CLAUDE.md as a base) and add the Agent Teams section:
## Agent Teams
When creating a team to tackle a complex task, follow these rules:
### CRITICAL: Follow the user's prompt exactly
Create *exactly* the team the user asked for — same number of agents, same roles, same names. Do NOT add extra agents, rename roles, or use generic names like "Researcher 1". If the user says "a marine biologist, a physicist, and Alexander Hamilton", create exactly those three agents with those exact names.
### Team member instructions
Each team member MUST be instructed to:
1. *Share progress in the group* via `mcp__deus__send_message` with a `sender` parameter matching their exact role/character name (e.g., `sender: "Marine Biologist"` or `sender: "Alexander Hamilton"`). This makes their messages appear from a dedicated bot in the Telegram group.
2. *Also communicate with teammates* via `SendMessage` as normal for coordination.
3. Keep group messages *short* — 2-4 sentences max per message. Break longer content into multiple `send_message` calls. No walls of text.
4. Use the `sender` parameter consistently — always the same name so the bot identity stays stable.
5. NEVER use markdown formatting. Use ONLY WhatsApp/Telegram formatting: single *asterisks* for bold (NOT **double**), _underscores_ for italic, • for bullets, ```backticks``` for code. No ## headings, no [links](url), no **double asterisks**.
### Example team creation prompt
When creating a teammate, include instructions like:
\```
You are the Marine Biologist. When you have findings or updates for the user, send them to the group using mcp__deus__send_message with sender set to "Marine Biologist". Keep each message short (2-4 sentences max). Use emojis for strong reactions. ONLY use single *asterisks* for bold (never **double**), _underscores_ for italic, • for bullets. No markdown. Also communicate with teammates via SendMessage.
\```
### Lead agent behavior
As the lead agent who created the team:
- You do NOT need to react to or relay every teammate message. The user sees those directly from the teammate bots.
- Send your own messages only to comment, share thoughts, synthesize, or direct the team.
- When processing an internal update from a teammate that doesn't need a user-facing response, wrap your *entire* output in `<internal>` tags.
- Focus on high-level coordination and the final synthesis.
Step 6: Update Environment
Add pool tokens to .env:
TELEGRAM_BOT_POOL=TOKEN1,TOKEN2,TOKEN3,...
Important: Sync to all required locations:
cp .env data/env/env
Also add TELEGRAM_BOT_POOL to the launchd plist (~/Library/LaunchAgents/com.deus.plist) in the EnvironmentVariables dict if using launchd.
Step 7: Rebuild and Restart
npm run build
./container/build.sh # Required — MCP tool changed
# macOS:
launchctl unload ~/Library/LaunchAgents/com.deus.plist
launchctl load ~/Library/LaunchAgents/com.deus.plist
# Linux:
# systemctl --user restart deus
Must use unload/load (macOS) or restart (Linux) because the service env vars changed.
Step 8: Test
Tell the user:
Send a message in your Telegram group asking for a multi-agent task, e.g.: "Assemble a team of a researcher and a coder to build me a hello world app"
You should see:
- The lead agent (main bot) acknowledging and creating the team
- Each subagent messaging from a different bot, renamed to their role
- Short, scannable messages from each agent
Check logs:
tail -f logs/deus.log | grep -i pool
Architecture Notes
- Pool bots use Grammy's
Apiclass — lightweight, no polling, just send - Bot names are set via
setMyName— changes are global to the bot, not per-chat - A 2-second delay after
setMyNameallows Telegram to propagate the name change before the first message - Sender→bot mapping is stable within a group (keyed as
{groupFolder}:{senderName}) - Mapping resets on service restart — pool bots get reassigned fresh
- If pool runs out, bots are reused (round-robin wraps)
Troubleshooting
Pool bots not sending messages
- Verify tokens:
curl -s "https://api.telegram.org/botTOKEN/getMe" - Check pool initialized:
grep "Pool bot" logs/deus.log - Ensure all pool bots are members of the Telegram group
- Check Group Privacy is disabled for each pool bot
Bot names not updating
Telegram caches bot names client-side. The 2-second delay after setMyName helps, but users may need to restart their Telegram client to see updated names immediately.
Subagents not using send_message
Check the group's CLAUDE.md has the Agent Teams instructions. The lead agent reads this when creating teammates and must include the send_message + sender instructions in each teammate's prompt.
Removal
To remove Agent Swarm support while keeping basic Telegram:
- Remove
TELEGRAM_BOT_POOLfromsrc/config.ts - Remove pool code from
src/telegram.ts(poolApis,senderBotMap,initBotPool,sendPoolMessage) - Remove pool routing from IPC handler in
src/index.ts(revert to plainsendMessage) - Remove
initBotPoolcall frommain() - Remove
senderparam from MCP tool incontainer/agent-runner/src/ipc-mcp-stdio.ts - Remove Agent Teams section from group CLAUDE.md files
- Remove
TELEGRAM_BOT_POOLfrom.env,data/env/env, and launchd plist/systemd unit - Rebuild:
npm run build && ./container/build.sh && launchctl unload ~/Library/LaunchAgents/com.deus.plist && launchctl load ~/Library/LaunchAgents/com.deus.plist(macOS) ornpm run build && ./container/build.sh && systemctl --user restart deus(Linux)
Du fichier au premier essai
Le téléchargement contient exactement le contenu affiché sur cette fiche. Cette copie peut différer de la dernière version du dépôt source.
Consulter la source et ses fichiers annexesCe téléchargement contient uniquement SKILL.md. Les scripts, références, modèles et dépendances éventuels ne sont pas inclus. Récupérez les fichiers nécessaires depuis la source en conservant leur arborescence avant de poursuivre.
1. Télécharger le fichier
Télécharger SKILL.mdDepuis la racine d’un projet de test, enregistrez le fichier sous .skill-downloads/add-agent-swarm-to-telegram-ms2s7dai/SKILL.md, ou utilisez la commande suivante. Ce dossier sert à examiner la skill avant son installation.
Commande pour macOS/Linux ou WSL : un shell POSIX et curl sont nécessaires. Sous Windows sans WSL, utilisez le bouton de téléchargement et créez le dossier manuellement.
mkdir -p '.skill-downloads/add-agent-swarm-to-telegram-ms2s7dai' && curl --fail --show-error --location 'https://skills-guides.com/api/skills/add-agent-swarm-to-telegram-ms2s7dai/download' --output '.skill-downloads/add-agent-swarm-to-telegram-ms2s7dai/SKILL.md.part' && mv '.skill-downloads/add-agent-swarm-to-telegram-ms2s7dai/SKILL.md.part' '.skill-downloads/add-agent-swarm-to-telegram-ms2s7dai/SKILL.md'2. Vérifier les prérequis
Lisez SKILL.md avant de l’utiliser. Si le fichier cite des scripts ou services externes, examinez-les et préparez les accès nécessaires dans votre environnement de test.
Extrait original : Prerequisites
1. Create Pool Bots
Tell the user:
I need you to create 3-5 Telegram bots to use as the agent pool. These will be renamed dynamically to match agent roles.
- Open Telegram and search for
@BotFather- Send
/newbotfor each bot:
- Give them any placeholder name (e.g., "Bot 1", "Bot 2")
- Usernames like
myproject_swarm_1_bot,myproject_swarm_2_bot, etc.- Copy all the tokens
- Add all bots to your Telegram group(s) where you want agent teams
Wait for user to provide the tokens.
2. Disable Group Privacy for Pool Bots
Tell the user:
Important: Each pool bot needs Group Privacy disabled so it can send messages in groups.
For each pool bot in
@BotFather:
- Send
/mybotsand select the bot- Go to Bot Settings > Group Privacy > Turn off
Then add all pool bots to your Telegram group(s).
Les plateformes de la fiche sont des indications du catalogue. Les chemins ci-dessous suivent la documentation des outils ; ils ne prouvent pas que cette skill y a été exécutée. Aucune version minimale de ces outils n’est attestée pour cette fiche.
3. Charger la skill
Après vérification, copiez le dossier complet dans le projet avec l’une des commandes ci-dessous, puis ouvrez une nouvelle session de l’outil. La commande s’arrête si un dossier du même nom existe déjà : comparez les fichiers avant de le remplacer.
Claude Code
test -f '.skill-downloads/add-agent-swarm-to-telegram-ms2s7dai/SKILL.md' && test -s '.skill-downloads/add-agent-swarm-to-telegram-ms2s7dai/SKILL.md' && mkdir -p '.claude/skills' && test ! -e '.claude/skills/add-telegram-swarm' && cp -R '.skill-downloads/add-agent-swarm-to-telegram-ms2s7dai' '.claude/skills/add-telegram-swarm'OpenSkills
OpenSkills doit déjà être installé. La procédure locale install/read est contrôlée avec OpenSkills 1.5.0, qui exige Node.js ≥ 20.6.0. Aucun slug du catalogue n’est résolu automatiquement.
Installation officielle d’OpenSkillsopenskills install './.skill-downloads/add-agent-swarm-to-telegram-ms2s7dai'openskills read 'add-agent-swarm-to-telegram-ms2s7dai'La lecture doit afficher le contenu du fichier installé et son dossier de base. Elle ne lance ni la skill ni ses dépendances.
Pour un agent qui lit AGENTS.md, synchronisez ensuite l’index. Cette commande modifie AGENTS.md : relisez le diff avant de l’utiliser.
openskills syncMode manuel ou autre outil : joignez SKILL.md à une conversation, ou ouvrez-le dans un agent capable de lire les fichiers. Ajoutez les ressources annexes nécessaires. Il n’existe pas de dossier universel reconnu par tous les outils.
4. Faire un premier essai
Utilisez une entrée courte et fictive : un endpoint d’API, un petit document ou un brief d’interface. Dans une nouvelle conversation, joignez le fichier ou donnez son chemin à l’agent, puis adaptez cette demande :
Lis .skill-downloads/add-agent-swarm-to-telegram-ms2s7dai/SKILL.md et applique ses instructions à cet exemple : [décrire une entrée de test]. Indique les fichiers, dépendances ou accès qui manquent. Produis le résultat demandé par la skill sans inventer de données ni exécuter de script non examiné.Résultat attendu : une sortie correspondant aux instructions de la skill, ou une liste précise des prérequis manquants. Une simple confirmation de lecture ne valide pas le premier usage. Si une ressource externe est indisponible, ce parcours reste à tester.
Bonnes pratiques React Hook Form
Developpement
Maîtrisez React Hook Form : évitez les anti-patterns, gérez les abonnements, et traitez correctement reset, dirty state et entrées contrôlées.
Migration Emotion vers Mantine
Developpement
Migrer les styled-components Emotion vers des composants Mantine avec style props et modules CSS. Pour convertir .styled.tsx ou supprimer les imports @emotion.
Détecteur de dérive de périmètre
Developpement
Analyse les diffs git par rapport à une intention pour détecter la dérive de périmètre, fichiers non liés et PR trop larges, puis suggère de garder, diviser ou justifier.