* feat(skill): add reactions skill (emoji reactions + status tracker) * refactor(reactions): minimize overlays per upstream review Address gavrielc's review on qwibitai/nanoclaw#509: - SKILL.md: remove all inline code, follow add-telegram/add-whatsapp pattern (465→79 lines) - Rebuild overlays as minimal deltas against upstream/main base - ipc-mcp-stdio.ts: upstream base + only react_to_message tool (8% delta) - ipc.ts: upstream base + only reactions delta (14% delta) - group-queue.test.ts: upstream base + isActive tests only (5% delta) - Remove group-queue.ts overlay (isActive provided by container-hardening) - Remove group-queue.ts from manifest modifies list Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com> --------- Co-authored-by: Claude Opus 4.6 <noreply@anthropic.com>
3.4 KiB
3.4 KiB
name, description
| name | description |
|---|---|
| add-reactions | Add WhatsApp emoji reaction support — receive, send, store, and search reactions. |
Add Reactions
This skill adds emoji reaction support to NanoClaw's WhatsApp channel: receive and store reactions, send reactions from the container agent via MCP tool, and query reaction history from SQLite.
Phase 1: Pre-flight
Check if already applied
Read .nanoclaw/state.yaml. If reactions is in applied_skills, skip to Phase 3 (Verify). The code changes are already in place.
Phase 2: Apply Code Changes
Run the skills engine to apply this skill's code package. The package files are in this directory alongside this SKILL.md.
Apply the skill
npx tsx scripts/apply-skill.ts .claude/skills/add-reactions
This deterministically:
- Adds
scripts/migrate-reactions.ts(database migration forreactionstable with composite PK and indexes) - Adds
src/status-tracker.ts(forward-only emoji state machine for message lifecycle signaling, with persistence and retry) - Adds
src/status-tracker.test.ts(unit tests for StatusTracker) - Adds
container/skills/reactions/SKILL.md(agent-facing documentation for thereact_to_messageMCP tool) - Modifies
src/db.ts— addsReactioninterface,reactionstable schema,storeReaction,getReactionsForMessage,getMessagesByReaction,getReactionsByUser,getReactionStats,getLatestMessage,getMessageFromMe - Modifies
src/channels/whatsapp.ts— addsmessages.reactionevent handler,sendReaction(),reactToLatestMessage()methods - Modifies
src/types.ts— adds optionalsendReactionandreactToLatestMessagetoChannelinterface - Modifies
src/ipc.ts— addstype: 'reaction'IPC handler with group-scoped authorization - Modifies
src/index.ts— wiressendReactiondependency into IPC watcher - Modifies
src/group-queue.ts—GroupQueueclass for per-group container concurrency with retry - Modifies
container/agent-runner/src/ipc-mcp-stdio.ts— addsreact_to_messageMCP tool exposed to container agents - Records the application in
.nanoclaw/state.yaml
Run database migration
npx tsx scripts/migrate-reactions.ts
Validate code changes
npm test
npm run build
All tests must pass and build must be clean before proceeding.
Phase 3: Verify
Build and restart
npm run build
Linux:
systemctl --user restart nanoclaw
macOS:
launchctl kickstart -k gui/$(id -u)/com.nanoclaw
Test receiving reactions
- Send a message from your phone
- React to it with an emoji on WhatsApp
- Check the database:
sqlite3 store/messages.db "SELECT * FROM reactions ORDER BY timestamp DESC LIMIT 5;"
Test sending reactions
Ask the agent to react to a message via the react_to_message MCP tool. Check your phone — the reaction should appear on the message.
Troubleshooting
Reactions not appearing in database
- Check NanoClaw logs for
Failed to process reactionerrors - Verify the chat is registered
- Confirm the service is running
Migration fails
- Ensure
store/messages.dbexists and is accessible - If "table reactions already exists", the migration already ran — skip it
Agent can't send reactions
- Check IPC logs for
Unauthorized IPC reaction attempt blocked— the agent can only react in its own group's chat - Verify WhatsApp is connected: check logs for connection status