Commit Graph

19 Commits

Author SHA1 Message Date
root
18fcc06626 fix: осмысленный fallback вместо «пустой ответ», chatbot только по @mention/reply
- Пустой result при error_max_turns → «Принято. Выполнил N действий...»
- Пустой result в остальных случаях → «Принято.»
- Chatbot отвечает только при @упоминании или reply на сообщение бота

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 14:24:22 +00:00
root
d589e3128d feat: chatbot отвечает только при @упоминании или reply на его сообщение
Бот больше не реагирует на все сообщения в чате.
Отвечает только когда:
- упомянут через @username в тексте
- сообщение является ответом (reply) на сообщение бота

@mention автоматически вырезается из текста перед отправкой в Claude.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 13:55:29 +00:00
root
dc92c7fcf6 feat: chatbot mode — Claude CLI отвечает на сообщения в Telegram
Добавлен режим чат-бота: каждое текстовое сообщение в Telegram
обрабатывается через `claude -p` CLI с контекстом проекта (CLAUDE.md).
Поддержка продолжения диалога через --resume session_id.

Новое:
- src/chatbot.ts: модуль чат-бота (spawn, сессии, retry, split)
- Команды /chatbot (статус) и /chatreset (сброс диалога)
- Конфиг через CHATBOT_* переменные в .env
- Typing-индикатор, блокировка конкурентных запросов
- Безопасная отправка Markdown с fallback на plain text

Изменения в index.ts:
- Интеграция chatbot в bot.on('text') fallback
- handlerTimeout увеличен до 5 мин
- Очистка stale-сессий при отсутствии запущенного Claude

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 13:43:53 +00:00
RichardDillman
e26d94dcc2 Fix: Multi-line messages now captured in project routing
Added 's' flag (dotall) to regex so . matches newlines.
Previously only first line of multi-line messages was captured.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 16:31:22 -05:00
RichardDillman
93d65d9a34 Fix: Add -p flag when spawning Claude with a prompt
Without -p flag, Claude expects input from stdin and fails with:
"Input must be provided either through stdin or as a prompt argument"

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-12-07 16:21:36 -05:00
RichardDillman
0ce65d7120 fix: load project .env vars and cleanup stale sessions
- Load project's .env file when spawning Claude so API credentials work
- Check isClaudeRunning() before routing messages to sessions
- Auto-cleanup stale sessions when Claude has exited
- Fixes ESO Logs API access from spawned Claude instances

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 18:22:46 -05:00
RichardDillman
0d277e4ae2 fix: add comprehensive debugging for Claude spawner Telegram output
Added detailed logging throughout the Claude spawning and output callback chain to diagnose why spawned Claude process output is logged but not sent to Telegram.

Changes:
- claude-spawner.ts: Added debug logs when onOutput callback is invoked, with try-catch error handling
- claude-spawner.ts: Added warning when no callback is provided
- index.ts: Added debug logs in all three spawn locations (/spawn command, auto-spawn, HTTP /spawn endpoint)
- index.ts: Added logging to show chatId availability and callback creation
- index.ts: Added detailed logging inside callbacks to trace Telegram sendMessage calls

This will help identify if the issue is:
1. Callback not being passed to spawner
2. Callback not being invoked by spawner
3. chatId not being set
4. Telegram API call failing

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-25 17:22:28 -05:00
RichardDillman
abde877912 docs: comprehensive documentation for all three phases
Added complete documentation covering all InnerVoice features:

Feature Documentation:
- Core communication features
- Multi-project support and session tracking
- Message queue system for offline projects
- Remote Claude spawner and project registry

Usage Scenarios (6 detailed examples):
1. Single Active Project - Basic workflow
2. Multiple Active Projects - Cross-project messaging
3. Offline Project Queuing - Send work before Claude starts
4. Remote Claude Spawning - Start work remotely
5. Auto-Spawn Projects - Automatic project startup
6. Managing Multiple Projects - Full lifecycle management

Bot Commands:
- Complete reference for all Telegram commands
- Session management (/sessions, /queue)
- Project management (/register, /spawn, /kill, etc.)
- Bot control commands

MCP Tools Reference:
- Added telegram_check_queue documentation
- Updated all tool descriptions with project context

API Endpoints:
- Session management endpoints
- Queue management endpoints
- Project registry endpoints
- Claude spawner endpoints
- Complete request/response examples

Communication Patterns:
- Basic message flow
- Targeted messages to specific projects
- Notifications with project context
- Question/answer flow
- Queued message delivery

Updated Sections:
- Features section with categorized capabilities
- How It Works with multi-project context
- All usage scenarios with concrete examples
- Complete API reference with all new endpoints

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 17:37:20 -05:00
RichardDillman
bdfe51fedf feat(phase3): add remote Claude spawner and project registry
Phase 3 adds the ability to spawn Claude Code instances remotely from Telegram in registered projects.

New Features:
- Project registry system (~/.innervoice/projects.json)
- Remote Claude spawner with process management
- Auto-spawn capability for projects
- Full CRUD operations for projects via Telegram

Telegram Bot Commands:
- /projects - List all registered projects
- /register ProjectName /path [--auto-spawn]
- /unregister ProjectName
- /spawn ProjectName [initial prompt]
- /spawned - List running spawned processes
- /kill ProjectName

API Endpoints:
- GET /projects - List registered projects
- POST /projects/register - Register new project
- DELETE /projects/:name - Unregister project
- GET /projects/:name - Get project details
- POST /spawn - Spawn Claude in project
- POST /kill/:projectName - Kill spawned process
- GET /spawned - List all spawned processes
- GET /spawned/:projectName - Check if project running

Files Added:
- src/project-registry.ts - Project registry management
- src/claude-spawner.ts - Claude process spawning

Files Modified:
- src/index.ts - Added spawner integration, bot commands, API endpoints

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 17:33:30 -05:00
RichardDillman
fd750d9b50 feat(phase2): add message queue system for offline projects
Phase 2 Complete: Message queuing for offline/inactive projects

Queue Storage:
- File-based queue in ~/.innervoice/queues/
- Separate JSON file per project
- Persistent storage survives restarts
- Auto-cleanup of old delivered tasks (7 days)

Queue Manager (queue-manager.ts):
- enqueueTask() - Add task to project queue
- getPendingTasks() - Get undelivered tasks
- markTaskDelivered() - Mark task as complete
- getQueueSummary() - Get overview of all queues
- cleanupOldTasks() - Remove old delivered tasks

API Endpoints:
- POST /queue/add - Queue message for project
- GET /queue/:projectName - Get pending tasks
- POST /queue/:projectName/mark-delivered - Mark delivered
- GET /queue/summary - Get all project summaries

Telegram Bot Features:
- /queue command - Show all queued messages
- Project-targeted messages: "ProjectName: message"
- Auto-detect if project is online or offline
- Queue for offline, deliver immediately if online

MCP Tool:
- telegram_check_queue - Check for queued messages on startup
- Shows pending messages with timestamps
- Perfect for checking what happened while offline

Usage Scenarios:

1. Send to offline project:
   You: "ESO-MCP: Continue with roadmap"
   Bot: "📥 Message queued for ESO-MCP (offline)"

2. Open Claude in ESO-MCP:
   Claude auto-checks queue on startup
   Shows: "📬 You have 1 queued message: Continue with roadmap"

3. Check queue status:
   You: "/queue"
   Bot: Shows all projects with pending messages

This solves the "no one listening" problem - messages are stored
and delivered when Claude opens in that project.

Next: Phase 3 (remote Claude spawner)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 17:27:24 -05:00
RichardDillman
82f46c4569 feat(phase1): add project context and session tracking
Phase 1 Complete: Multi-project session management with context display

Session Tracking:
- Auto-generate unique session IDs for each Claude instance
- Track project name and path from working directory
- Register sessions automatically on MCP server startup
- Expire inactive sessions after 30 minutes
- Session heartbeat to track activity

Project Context in Messages:
- All notifications now show: 📁 ProjectName [#shortId]
- Session ID automatically included in all notify calls
- Project context helps identify which Claude sent the message
- Short session ID (first 7 chars) for easy reference

New API Endpoints:
- POST /session/register - Register/update a Claude session
- POST /session/heartbeat - Update session activity
- GET /sessions - List all active sessions with idle times

Telegram Bot Commands:
- /sessions - View all active Claude sessions
- Shows project name, session ID, and idle time
- Status indicators: 🟢 active, 🟡 idle
- Updated /help with new multi-project features

MCP Server Changes:
- getSessionId() - Generate/retrieve session ID
- getProjectInfo() - Extract project name from cwd
- registerSession() - Auto-register on startup
- Include sessionId in all notify API calls

This enables working with multiple Claude instances across different
projects simultaneously, with clear visual indication of which project
each message comes from.

Next: Phase 2 (message queuing) and Phase 3 (remote spawner)

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 15:47:16 -05:00
RichardDillman
0584ac6c5f feat: make /afk command and permission hook globally available
Changed from per-project to global installation by default, making
InnerVoice features available across all projects automatically.

Global Installation:
- /afk slash command now in ~/.claude/commands/afk.md
- Permission hook now in ~/.claude/hooks/PermissionRequest.sh
- Both work in ALL projects without per-project setup

Install Script Updates:
- Added --global flag for global installation (recommended)
- Still supports per-project installation if needed
- Clear scope indication in output messages
- Updated uninstall instructions for both scopes

Documentation:
- Updated README to recommend global installation
- Added examples for both global and per-project setup
- Clearer uninstall instructions for each scope

Benefits:
- Users install once, works everywhere
- No per-project configuration needed
- Easier maintenance and updates
- Consistent behavior across all projects

Breaking Changes: None
- Per-project installation still supported
- Existing installations continue to work

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 15:13:01 -05:00
RichardDillman
6dcb4a888c feat: add optional permission notification hook for AFK mode
Added optional hook that sends Telegram notifications when Claude
requests tool permissions, solving the issue where users in AFK mode
don't get notified about pending permission prompts.

Features:
- Self-contained hook in hooks/PermissionRequest.sh
- Easy installation script (scripts/install-hook.sh)
- Opt-in per project - users choose where to install
- Sends Telegram alert with tool name and description
- Shows ⏸️ warning icon for permission requests

Installation:
Users can now run ./scripts/install-hook.sh from any project to
enable permission notifications. The hook integrates with the
existing InnerVoice bridge.

Documentation:
- Added "Optional: Install Permission Notification Hook" section
- Includes installation and uninstallation instructions
- Example notification message format

This keeps InnerVoice self-contained while allowing users to opt-in
to enhanced AFK mode notifications.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 14:53:23 -05:00
RichardDillman
c45fe4d509 feat: add auto-start, AFK mode, and comprehensive cross-platform setup
Major Features:
- Auto-start: MCP server now automatically starts Telegram bridge on demand
- AFK Mode: Toggle notifications on/off with /afk slash command
- New telegram_toggle_afk MCP tool for controlling notification state
- Dynamic enable/disable via new /toggle and /status API endpoints

MCP Server Improvements:
- Auto-detects if bridge is running and starts it automatically
- Monitors bridge process health and logs output
- Clean shutdown handling for both MCP server and bridge
- Process spawning with proper environment variable passing

Telegram Bridge Updates:
- Runtime toggle for ENABLED state (was previously static)
- POST /toggle endpoint to toggle notifications with Telegram confirmation
- GET /status endpoint to check current notification state
- Telegram messages sent when state changes (🟢/🔴 indicators)

Documentation:
- Cross-platform setup instructions (Mac, Linux, Windows)
- Claude Code CLI setup guide with claude mcp add commands
- Global vs project-specific MCP configuration explained
- Troubleshooting section for fixing configuration scope issues
- Complete AFK mode usage documentation
- All new API endpoints documented

Slash Commands:
- Created /afk command in .claude/commands/afk.md
- Available in both InnerVoice and ESO-MCP projects

Files Changed:
- src/mcp-server.ts: Auto-start logic and telegram_toggle_afk tool
- src/index.ts: Dynamic ENABLED toggle and new API endpoints
- README.md: Comprehensive setup and troubleshooting guide
- mcp-config.json: Updated with correct absolute path
- .claude/commands/afk.md: New slash command for AFK mode

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 14:15:46 -05:00
RichardDillman
c4cfcf6eb8 cleanup 2025-11-23 01:33:33 -05:00
RichardDillman
1a41318db5 docs: add comprehensive beginner's guide
Added BEGINNER-GUIDE.md with step-by-step instructions for complete
beginners with zero MCP knowledge. Covers:

- Clear explanation of what this is and why you'd want it
- Prerequisites checklist
- Detailed Telegram bot creation (with example Q&A)
- Installation with multiple methods (git and download)
- MCP configuration for different Claude installations
- Testing and verification steps
- Comprehensive troubleshooting section
- Keeping the bridge running after restarts

Changes:
- Created BEGINNER-GUIDE.md with hand-holding explanations
- Added prominent link to beginner guide in README
- Assumes zero prior knowledge of MCP or Telegram bots
- Includes real examples and expected outputs
- Troubleshooting for common beginner mistakes

This ensures anyone can set up the bridge, regardless of technical
experience level.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 01:14:02 -05:00
RichardDillman
0a0e23c810 docs: consolidate documentation structure
Simplifies documentation by removing redundant multi-project setup guide
and consolidating into:
- README.md - User-facing installation and usage
- CONTRIBUTING.md - Developer guide for local development

Changes:
- Removed SETUP-FOR-OTHER-PROJECTS.md (redundant)
- Created CONTRIBUTING.md with development workflow
- Simplified README "How It Works" section
- Added proper Development and License sections to README
- Improved contact information with issue tracker link

The bridge works as a standard MCP server - no special multi-project
setup needed. Just configure MCP and use the tools.

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 01:11:16 -05:00
RichardDillman
fdb1fa74b4 feat: add easy multi-project setup and tool discovery
Makes it simple to use the Telegram bridge MCP server in multiple
Claude projects with minimal configuration.

New Features:
- Auto-generate MCP config: `pnpm config`
- List available tools: `pnpm tools`
- Multi-project setup guide (SETUP-FOR-OTHER-PROJECTS.md)
- MCP config template (.claude-mcp-template.json)
- Helper scripts for config generation

Changes:
- Added scripts/get-mcp-config.sh - Auto-generates MCP config with correct paths
- Added scripts/list-tools.js - Lists all 5 MCP tools with descriptions
- Added SETUP-FOR-OTHER-PROJECTS.md - Guide for using in multiple projects
- Updated README with easier setup options
- Added npm scripts: `tools` and `config`

Now you can:
1. Install bridge once
2. Run `pnpm config` to get MCP config
3. Copy to any project's .claude/mcp.json
4. Use Telegram tools in that project!

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 01:04:16 -05:00
RichardDillman
6c8c9350a1 feat: Claude Telegram Bridge MCP server
A Model Context Protocol (MCP) server that enables Claude to communicate
with users via Telegram. Provides two-way communication, notifications,
question/answer flows, and message queuing.

Features:
- MCP server implementation with 5 tools
- HTTP bridge for Telegram Bot API
- Real-time notifications with priority levels
- Question/answer blocking flow
- Message queue for async communication
- Background daemon support

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
2025-11-23 00:55:30 -05:00