14 Commits

Author SHA1 Message Date
root
df1bbdcc8b feat: контекст чата — бот помнит последние N сообщений
Бот подхватывает последние 20 (настраивается) сообщений из чата
как контекст при ответе. Команда /context для просмотра и настройки.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 17:11:26 +00:00
root
b3fdd383ac feat: task manager — фоновые задачи без таймаута через /task
Новый модуль task-manager.ts: очередь задач с файловым хранением,
worker loop каждые 5 сек, Claude CLI с --max-turns 50 без таймаута,
Telegram-уведомления по завершении. Команды /task, /task list,
/task N, /task cancel N. HTTP API /tasks.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
2026-02-19 17:03:32 +00:00
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
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
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
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