From bd6a26a002998a196ddde698077be0df7fc3bd2b Mon Sep 17 00:00:00 2001 From: Koshkoshinsk Date: Wed, 15 Apr 2026 10:31:46 +0000 Subject: [PATCH] docs(skills): print pairing code as final message; drop log-tail verify - Reword pair-code instruction across add-telegram-v2, manage-channels, and init-first-agent so the very last user-visible message after generating the code MUST be a plain-text print of it. - Replace init-first-agent's tail -f based verify step with a plain-text prompt asking the user to confirm receipt of the welcome DM, falling back to DB-based diagnostics only on non-arrival. Avoids harness blocks on long leading sleeps and fragile log-string greps. Co-Authored-By: Claude Opus 4.6 (1M context) --- .claude/skills/add-telegram-v2/SKILL.md | 2 +- .claude/skills/init-first-agent/SKILL.md | 18 ++++++++---------- .claude/skills/manage-channels/SKILL.md | 2 +- 3 files changed, 10 insertions(+), 12 deletions(-) diff --git a/.claude/skills/add-telegram-v2/SKILL.md b/.claude/skills/add-telegram-v2/SKILL.md index 6f389f0..deca592 100644 --- a/.claude/skills/add-telegram-v2/SKILL.md +++ b/.claude/skills/add-telegram-v2/SKILL.md @@ -68,7 +68,7 @@ Otherwise, run `/manage-channels` to wire this channel to an agent group. - **type**: `telegram` - **terminology**: Telegram calls them "groups" and "chats." A "group" has multiple members; a "chat" is a 1:1 conversation with the bot. -- **how-to-find-id**: Do NOT ask the user for a chat ID. Telegram registration uses pairing — run `npx tsx setup/index.ts --step pair-telegram -- --intent `, the user needs to receive the 4-digit `CODE` from the `PAIR_TELEGRAM_ISSUED` block in print, but Claude runs the step in a bash tool call and Claude Code's UI collapses that output — so the user never sees the code. Your very last message visible to the user at this step MUST be a plain-text print of the pairing code (e.g. "Your pairing code is **1234**"). Then tell them to send just the 4 digits as a message from the chat they want to register (DM the bot for `main`, post in the group otherwise). In groups with Group Privacy ON, prefix with the bot handle: `@ CODE`. Wrong guesses invalidate the code — if a `PAIR_TELEGRAM_ATTEMPT` block arrives with a mismatched `RECEIVED_CODE`, a `PAIR_TELEGRAM_NEW_CODE` block will follow automatically (up to 5 regenerations); show the new code. On `PAIR_TELEGRAM STATUS=failed ERROR=max-regenerations-exceeded`, ask the user if they want to try again and re-invoke the step — each invocation starts a fresh 5-attempt batch. Success emits `PAIR_TELEGRAM STATUS=success` with `PLATFORM_ID`, `IS_GROUP`, and `ADMIN_USER_ID`. The service must be running for this to work (the polling adapter is what observes the code). +- **how-to-find-id**: Do NOT ask the user for a chat ID. Telegram registration uses pairing — run `npx tsx setup/index.ts --step pair-telegram -- --intent `, the user needs to receive the 4-digit `CODE` from the `PAIR_TELEGRAM_ISSUED` block in print, but Claude runs the step in a bash tool call and Claude Code's UI collapses that output — so the user never sees the code. Your very last message visible to the user after generating the pairing code MUST be a plain-text print of the pairing code (e.g. "Your pairing code is **1234**"). Then tell them to send just the 4 digits as a message from the chat they want to register (DM the bot for `main`, post in the group otherwise). In groups with Group Privacy ON, prefix with the bot handle: `@ CODE`. Wrong guesses invalidate the code — if a `PAIR_TELEGRAM_ATTEMPT` block arrives with a mismatched `RECEIVED_CODE`, a `PAIR_TELEGRAM_NEW_CODE` block will follow automatically (up to 5 regenerations); show the new code. On `PAIR_TELEGRAM STATUS=failed ERROR=max-regenerations-exceeded`, ask the user if they want to try again and re-invoke the step — each invocation starts a fresh 5-attempt batch. Success emits `PAIR_TELEGRAM STATUS=success` with `PLATFORM_ID`, `IS_GROUP`, and `ADMIN_USER_ID`. The service must be running for this to work (the polling adapter is what observes the code). - **supports-threads**: no - **typical-use**: Interactive chat — direct messages or small groups - **default-isolation**: Same agent group if you're the only participant across multiple chats. Separate agent group if different people are in different groups. diff --git a/.claude/skills/init-first-agent/SKILL.md b/.claude/skills/init-first-agent/SKILL.md index ef65268..fade964 100644 --- a/.claude/skills/init-first-agent/SKILL.md +++ b/.claude/skills/init-first-agent/SKILL.md @@ -67,7 +67,7 @@ For Telegram only, there's an existing pair-code primitive: npx tsx setup/index.ts --step pair-telegram -- --intent new-agent:dm-with- ``` -Parse the `PAIR_TELEGRAM_ISSUED` status block for `CODE`. Tell the user to DM the bot with exactly the 4-digit code. Wait for the `PAIR_TELEGRAM` block — read `PLATFORM_ID` and `PAIRED_USER_ID` from it. telegram.ts's interceptor has already upserted the user and granted owner if none existed yet. Use `PLATFORM_ID` and `PAIRED_USER_ID` directly in step 4. +Parse the `PAIR_TELEGRAM_ISSUED` status block for `CODE`. The user needs to receive the 4-digit code in print, but Claude runs the step in a bash tool call and Claude Code's UI collapses that output — so the user never sees the code. Your very last message visible to the user after generating the pairing code MUST be a plain-text print of the pairing code (e.g. "Your pairing code is **1234**"). Then tell the user to DM the bot with exactly those 4 digits. Wait for the `PAIR_TELEGRAM` block — read `PLATFORM_ID` and `PAIRED_USER_ID` from it. telegram.ts's interceptor has already upserted the user and granted owner if none existed yet. Use `PLATFORM_ID` and `PAIRED_USER_ID` directly in step 4. ## 4. Run the init script @@ -96,19 +96,17 @@ Show the script's output to the user. Host sweep runs every ~60s. Within one sweep window the container wakes, the agent processes the system message, and the reply flows through `outbound.db` to the channel. -Tail the log to watch it happen: +Do not tail the log or poll in a sleep loop. Ask the user in plain text: -```bash -tail -f logs/nanoclaw.log -``` +> The welcome DM should arrive within ~60 seconds. Let me know when you've received it (or if it doesn't arrive within two minutes). -If nothing arrives within two minutes: +Wait for the user's reply. If they confirm receipt, the skill is done. +If they say it didn't arrive, then diagnose using the DB directly (no waiting loops required — the message either delivered or it didn't): + +- `sqlite3 data/v2-sessions//sessions//outbound.db "SELECT id, status, created_at FROM messages_out ORDER BY created_at DESC LIMIT 5"` — check for stuck `pending` rows. Replace `` and `` with the values from the script's output. - `grep -E 'Unauthorized channel destination|container.*exited|error' logs/nanoclaw.log | tail -20` — look for ACL rejections or container crashes. -- `ls data/v2-sessions//sessions/*/outbound.db` — confirm the session exists. Replace `` with the value from the script's output. -- `sqlite3 data/v2-sessions//sessions//outbound.db "SELECT id, status, created_at FROM messages_out ORDER BY created_at DESC LIMIT 5"` — check for stuck `pending` rows. - -Once the welcome DM arrives, confirm with the user and the skill is done. +- `ls data/v2-sessions//sessions/*/outbound.db` — confirm the session exists. ## Troubleshooting diff --git a/.claude/skills/manage-channels/SKILL.md b/.claude/skills/manage-channels/SKILL.md index bb00fc9..99c8c22 100644 --- a/.claude/skills/manage-channels/SKILL.md +++ b/.claude/skills/manage-channels/SKILL.md @@ -58,7 +58,7 @@ For separate agents, also ask for a folder name and optionally a different assis When adding another group/chat on an already-configured platform (e.g. a second Telegram group): -1. **Telegram:** ask the isolation question first to determine intent (`wire-to:` for an existing agent, `new-agent:` for a fresh one). Run `npx tsx setup/index.ts --step pair-telegram -- --intent `, the user needs to receive the CODE in print, but Claude runs the step in a bash tool call and Claude Code's UI collapses that output — so the user never sees the code. Your very last message visible to the user at this step MUST be a plain-text print of the pairing code (e.g. "Your pairing code is **1234**"). Then tell the user to post `@ CODE` in the target group (or DM the bot for a private chat). Wait for the `PAIR_TELEGRAM` block. The inbound interceptor has already created the `messaging_groups` row with `unknown_sender_policy = 'strict'` and upserted the paired user — `register` only needs to add the wiring: +1. **Telegram:** ask the isolation question first to determine intent (`wire-to:` for an existing agent, `new-agent:` for a fresh one). Run `npx tsx setup/index.ts --step pair-telegram -- --intent `, the user needs to receive the CODE in print, but Claude runs the step in a bash tool call and Claude Code's UI collapses that output — so the user never sees the code. Your very last message visible to the user after generating the pairing code MUST be a plain-text print of the pairing code (e.g. "Your pairing code is **1234**"). Then tell the user to post `@ CODE` in the target group (or DM the bot for a private chat). Wait for the `PAIR_TELEGRAM` block. The inbound interceptor has already created the `messaging_groups` row with `unknown_sender_policy = 'strict'` and upserted the paired user — `register` only needs to add the wiring: ```bash npx tsx setup/index.ts --step register -- \