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>
This commit is contained in:
RichardDillman
2025-11-23 17:27:24 -05:00
parent 82f46c4569
commit fd750d9b50
4 changed files with 381 additions and 2 deletions

61
PHASE1-TESTING.md Normal file
View File

@@ -0,0 +1,61 @@
# Phase 1 Testing Guide
## What Was Built
✅ Multi-project session tracking with project context display
### Features
- Auto-generate unique session IDs for each Claude instance
- Track project name and path from working directory
- Show project context in all Telegram messages: `📁 ProjectName [#shortId]`
- `/sessions` command to list all active Claude instances
- Auto-expire inactive sessions after 30 minutes
## How to Test
### 1. Restart Claude Code
**Important:** You need to restart Claude Code to load the new MCP server code.
```bash
# Exit your current Claude Code sessions
# Then restart in your project
cd /path/to/your/project
claude
```
### 2. Test Project Context
Send a notification and you should see the project name:
```
📁 ESO-MCP [#1a2b3c4]
Your message here
```
### 3. Test Multi-Project Sessions
1. Open Claude in **ESO-MCP** project
2. Open another terminal and start Claude in **innervoice** project
3. In Telegram, type `/sessions`
4. You should see both projects listed:
```
Active Claude Sessions (2)
1. 🟢 ESO-MCP [#1a2b3c4]
Last active: 0m ago
2. 🟢 innervoice [#5d6e7f8]
Last active: 2m ago
```
### 4. Test Session Auto-Expire
Wait 30 minutes of inactivity, then run `/sessions` again.
Inactive sessions should be removed automatically.
## Known Issues
- You must restart Claude Code for changes to take effect
- Old MCP server processes won't pick up new code automatically
## Next: Phase 2
Message queue system for offline/inactive projects coming next!