sensorium-mcp 2.7.0 → 2.8.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +125 -70
- package/dist/index.js +624 -28
- package/dist/index.js.map +1 -1
- package/dist/memory.d.ts +193 -0
- package/dist/memory.d.ts.map +1 -0
- package/dist/memory.js +825 -0
- package/dist/memory.js.map +1 -0
- package/package.json +3 -1
package/README.md
CHANGED
|
@@ -1,103 +1,158 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
An MCP (Model Context Protocol) server for remote control of AI assistants via Telegram.
|
|
1
|
+
[](https://www.npmjs.com/package/sensorium-mcp)
|
|
2
|
+
[](LICENSE)
|
|
4
3
|
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
This server exposes four tools that allow an AI assistant (e.g. GitHub Copilot) to be operated remotely through a Telegram bot:
|
|
4
|
+
# sensorium-mcp
|
|
8
5
|
|
|
9
|
-
|
|
10
|
-
|------|-------------|
|
|
11
|
-
| `start_session` | Begin or resume a sensorium session. Creates a dedicated Telegram topic thread (or resumes an existing one by name or thread ID). |
|
|
12
|
-
| `remote_copilot_wait_for_instructions` | Blocks until a new message (text, photo, document, or voice) arrives in the active topic or the timeout elapses. |
|
|
13
|
-
| `report_progress` | Sends a progress update back to the operator using standard Markdown (auto-converted to Telegram MarkdownV2). |
|
|
14
|
-
| `send_file` | Sends a file or image to the operator via Telegram (base64-encoded). Images are sent as photos; everything else as documents. |
|
|
15
|
-
| `send_voice` | Sends a voice message to the operator via Telegram. Text is converted to speech using OpenAI TTS (max 4096 chars). |
|
|
6
|
+
MCP server with 5-layer memory, voice analysis, and Telegram bridge for AI assistants.
|
|
16
7
|
|
|
17
|
-
##
|
|
8
|
+
## Why?
|
|
18
9
|
|
|
19
|
-
|
|
20
|
-
- **Named session persistence** — Sessions are mapped by name to Telegram thread IDs in `~/.remote-copilot-mcp-sessions.json`. Calling `start_session({ name: "Fix auth bug" })` always resumes the same thread, even across VS Code restarts.
|
|
21
|
-
- **Image & document support** — Send photos or documents to the agent from Telegram; the agent receives them as native MCP image content blocks or base64 text. The agent can also send files back via the `send_file` tool.
|
|
22
|
-
- **Voice message support** — Send voice messages from Telegram; they are automatically transcribed using OpenAI Whisper and delivered as text to the agent. The agent can also send voice responses back via OpenAI TTS. Requires `OPENAI_API_KEY`.
|
|
23
|
-
- **Automatic Markdown conversion** — Standard Markdown in `report_progress` is automatically converted to Telegram MarkdownV2, including code blocks, tables, blockquotes, and special characters.
|
|
24
|
-
- **Keep-alive pings** — Periodic heartbeat messages to Telegram so the operator knows the agent is still alive during long idle periods.
|
|
10
|
+
AI assistants forget everything between sessions. Every restart is a blank slate — no memory of your preferences, past decisions, or ongoing projects. Voice messages arrive as opaque audio blobs. And there's no way to talk to your agent when it's running headless in CI or on a remote machine.
|
|
25
11
|
|
|
26
|
-
|
|
12
|
+
**sensorium-mcp** fixes all three problems:
|
|
27
13
|
|
|
28
|
-
-
|
|
29
|
-
-
|
|
30
|
-
-
|
|
31
|
-
- In Telegram: create a group → *Edit → Topics → Enable*
|
|
32
|
-
- Add your bot as admin and grant it *Manage Topics*
|
|
33
|
-
- Copy the group's chat ID (e.g. `-1001234567890`) as `TELEGRAM_CHAT_ID`
|
|
14
|
+
- **Persistent memory** that survives across sessions, automatically capturing episodes and consolidating knowledge
|
|
15
|
+
- **Voice understanding** with transcription and real-time emotion analysis
|
|
16
|
+
- **Remote control** via Telegram — give instructions, send files, receive progress updates from anywhere
|
|
34
17
|
|
|
35
|
-
##
|
|
18
|
+
## Quickstart
|
|
36
19
|
|
|
37
20
|
```bash
|
|
38
|
-
|
|
39
|
-
npm run build
|
|
21
|
+
npx sensorium-mcp@latest
|
|
40
22
|
```
|
|
41
23
|
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
Set the following environment variables:
|
|
45
|
-
|
|
46
|
-
| Variable | Required | Default | Description |
|
|
47
|
-
|----------|----------|---------|-------------|
|
|
48
|
-
| `TELEGRAM_TOKEN` | ✅ | — | Telegram Bot API token from @BotFather |
|
|
49
|
-
| `TELEGRAM_CHAT_ID` | ✅ | — | Chat ID of the forum supergroup (e.g. `-1001234567890`). The bot must be admin with Manage Topics right. |
|
|
50
|
-
| `WAIT_TIMEOUT_MINUTES` | ❌ | `120` | Minutes to wait for a message before timing out |
|
|
51
|
-
| `OPENAI_API_KEY` | ❌ | — | OpenAI API key for voice message transcription (Whisper) and TTS (`send_voice`). Without it, voice messages show a placeholder instead of a transcript. |
|
|
52
|
-
| `VOICE_ANALYSIS_URL` | ❌ | — | URL of the voice emotion analysis microservice (e.g. `https://voice-analysis.example.com`). When set, voice messages are analyzed for emotion and the result is included with the transcript. See `voice-analysis/` for the deployable service. |
|
|
53
|
-
|
|
54
|
-
## Usage
|
|
55
|
-
|
|
56
|
-
### Simply use this prompt
|
|
57
|
-
|
|
58
|
-
```bash
|
|
59
|
-
Start remote copilot session
|
|
60
|
-
```
|
|
61
|
-
|
|
62
|
-
### Configure in MCP client (e.g. VS Code Copilot)
|
|
63
|
-
|
|
64
|
-
Add to your MCP configuration:
|
|
24
|
+
Or add to your VS Code `mcp.json`:
|
|
65
25
|
|
|
66
26
|
```json
|
|
67
27
|
{
|
|
68
|
-
"
|
|
28
|
+
"servers": {
|
|
69
29
|
"sensorium-mcp": {
|
|
70
30
|
"command": "npx",
|
|
71
|
-
"args": [
|
|
72
|
-
"sensorium-mcp@latest"
|
|
73
|
-
],
|
|
31
|
+
"args": ["sensorium-mcp@latest"],
|
|
74
32
|
"env": {
|
|
75
|
-
"TELEGRAM_TOKEN": "
|
|
76
|
-
"TELEGRAM_CHAT_ID": "
|
|
33
|
+
"TELEGRAM_TOKEN": "...",
|
|
34
|
+
"TELEGRAM_CHAT_ID": "...",
|
|
35
|
+
"OPENAI_API_KEY": "...",
|
|
77
36
|
"WAIT_TIMEOUT_MINUTES": "30"
|
|
78
|
-
}
|
|
79
|
-
"type": "stdio"
|
|
37
|
+
}
|
|
80
38
|
}
|
|
81
39
|
}
|
|
82
40
|
}
|
|
83
41
|
```
|
|
84
42
|
|
|
85
|
-
|
|
43
|
+
Then tell your agent:
|
|
44
|
+
|
|
45
|
+
```
|
|
46
|
+
Start remote copilot session
|
|
47
|
+
```
|
|
48
|
+
|
|
49
|
+
## Features
|
|
50
|
+
|
|
51
|
+
### 5-Layer Memory System
|
|
52
|
+
|
|
53
|
+
Every operator message is automatically captured. Knowledge is extracted and consolidated during idle time using GPT-5 mini.
|
|
54
|
+
|
|
55
|
+
| Layer | What it stores |
|
|
56
|
+
|-------|---------------|
|
|
57
|
+
| **Working Memory** | Current session context — active goals, recent messages |
|
|
58
|
+
| **Episodic Memory** | Auto-saved conversation episodes (every operator message) |
|
|
59
|
+
| **Semantic Memory** | Extracted facts, preferences, patterns, entities, relationships |
|
|
60
|
+
| **Procedural Memory** | Multi-step procedures and workflows |
|
|
61
|
+
| **Meta-Memory** | Confidence scores, decay tracking, topic indexing |
|
|
86
62
|
|
|
87
|
-
|
|
88
|
-
2. A shared **dispatcher** runs a single `getUpdates` poller (elected via a lock file at `~/.remote-copilot-mcp/poller.lock`). It writes incoming messages to per-thread JSONL files under `~/.remote-copilot-mcp/threads/`. Each MCP instance reads from its own thread file — no 409 conflicts between concurrent sessions.
|
|
89
|
-
3. When a message arrives (text, photo, or document), the tool downloads any media, converts it to MCP content blocks (image or text with base64), and instructs the AI to act on it.
|
|
90
|
-
4. The AI calls `report_progress` to post status updates and `send_file` to send files/images back to the operator.
|
|
91
|
-
5. If the timeout elapses with no message, the tool tells the AI to call `remote_copilot_wait_for_instructions` again immediately.
|
|
63
|
+
Storage: SQLite at `~/.sensorium-mcp/memory.db`. No external database required.
|
|
92
64
|
|
|
93
|
-
|
|
65
|
+
**Auto-bootstrap** — session start auto-injects a memory briefing so the agent immediately knows who you are and what you've been working on.
|
|
66
|
+
|
|
67
|
+
**Auto-ingest** — every operator message is saved as an episode automatically.
|
|
68
|
+
|
|
69
|
+
**Intelligent consolidation** — GPT-5 mini analyzes accumulated episodes and extracts durable knowledge (facts, preferences, patterns) during idle periods.
|
|
70
|
+
|
|
71
|
+
### Remote Control via Telegram
|
|
72
|
+
|
|
73
|
+
Operate your AI assistant from anywhere through a Telegram forum supergroup.
|
|
74
|
+
|
|
75
|
+
- Concurrent sessions with a shared file-based dispatcher (no 409 conflicts)
|
|
76
|
+
- Named session persistence across VS Code restarts
|
|
77
|
+
- Image, document, and video note support
|
|
78
|
+
- Voice messages with Whisper transcription
|
|
79
|
+
- Automatic Markdown → Telegram MarkdownV2 conversion
|
|
80
|
+
|
|
81
|
+
### Voice Analysis
|
|
82
|
+
|
|
83
|
+
Real-time voice emotion analysis via an optional microservice (see `voice-analysis/`).
|
|
84
|
+
|
|
85
|
+
- Detects emotions, gender, arousal/dominance/valence
|
|
86
|
+
- Video note (circle video) support with audio extraction
|
|
87
|
+
- Deployable via Docker
|
|
88
|
+
|
|
89
|
+
### Scheduler
|
|
90
|
+
|
|
91
|
+
Schedule tasks that fire during `wait_for_instructions`.
|
|
92
|
+
|
|
93
|
+
- **One-shot**: `runAt` — trigger at a specific time
|
|
94
|
+
- **Idle-triggered**: `afterIdleMinutes` — trigger after N minutes of inactivity
|
|
95
|
+
|
|
96
|
+
### Dead Session Detection
|
|
97
|
+
|
|
98
|
+
Automatic alert when no tool calls arrive for 60 minutes. Single alert per downtime — no spam. Replaces annoying keep-alive pings.
|
|
99
|
+
|
|
100
|
+
## Tools
|
|
101
|
+
|
|
102
|
+
| Tool | Description |
|
|
103
|
+
|------|-------------|
|
|
104
|
+
| `start_session` | Begin or resume a session with optional memory bootstrap |
|
|
105
|
+
| `remote_copilot_wait_for_instructions` | Block until operator message, scheduled task, or timeout |
|
|
106
|
+
| `report_progress` | Send Markdown progress update to operator |
|
|
107
|
+
| `send_file` | Send file or image to operator |
|
|
108
|
+
| `send_voice` | Text-to-speech voice message via OpenAI TTS |
|
|
109
|
+
| `schedule_wake_up` | Schedule a one-shot or idle task |
|
|
110
|
+
| `memory_bootstrap` | Load memory briefing into context |
|
|
111
|
+
| `memory_search` | Search episodic/semantic memory by query |
|
|
112
|
+
| `memory_save` | Save a fact, preference, pattern, entity, or relationship |
|
|
113
|
+
| `memory_save_procedure` | Save a multi-step procedure |
|
|
114
|
+
| `memory_update` | Update or supersede an existing note |
|
|
115
|
+
| `memory_consolidate` | Run intelligent consolidation (GPT-5 mini) |
|
|
116
|
+
| `memory_status` | Check memory health and statistics |
|
|
117
|
+
| `memory_forget` | Delete a specific memory note |
|
|
118
|
+
|
|
119
|
+
## Environment Variables
|
|
120
|
+
|
|
121
|
+
| Variable | Required | Default | Description |
|
|
122
|
+
|----------|----------|---------|-------------|
|
|
123
|
+
| `TELEGRAM_TOKEN` | Yes | — | Telegram Bot API token |
|
|
124
|
+
| `TELEGRAM_CHAT_ID` | Yes | — | Forum supergroup chat ID |
|
|
125
|
+
| `OPENAI_API_KEY` | No | — | For voice transcription (Whisper), TTS, and memory consolidation |
|
|
126
|
+
| `VOICE_ANALYSIS_URL` | No | — | Voice emotion analysis microservice URL |
|
|
127
|
+
| `WAIT_TIMEOUT_MINUTES` | No | `120` | Wait timeout in minutes |
|
|
128
|
+
|
|
129
|
+
## Prerequisites
|
|
130
|
+
|
|
131
|
+
- Node.js 18+ (uses native `fetch`)
|
|
132
|
+
- A [Telegram bot token](https://core.telegram.org/bots#botfather)
|
|
133
|
+
- A Telegram **forum supergroup** with the bot as admin (Manage Topics right)
|
|
134
|
+
|
|
135
|
+
## How It Works
|
|
136
|
+
|
|
137
|
+
1. `start_session` creates a Telegram topic (or resumes one by name). Memory bootstrap auto-loads your context.
|
|
138
|
+
2. A shared **dispatcher** runs a single `getUpdates` poller (elected via lock file). Messages are written to per-thread JSONL files — each MCP instance reads its own.
|
|
139
|
+
3. Incoming messages (text, photo, document, voice, video note) are processed, transcribed, and delivered as MCP content blocks. Every operator message is auto-saved as an episode.
|
|
140
|
+
4. The agent works, calls `report_progress` / `send_file` / `send_voice`, and loops back to `wait_for_instructions`.
|
|
141
|
+
5. During idle periods, the scheduler fires pending tasks and memory consolidation extracts durable knowledge from episodes.
|
|
142
|
+
|
|
143
|
+
## Architecture
|
|
94
144
|
|
|
95
145
|
```
|
|
96
|
-
~/.
|
|
146
|
+
~/.sensorium-mcp/
|
|
97
147
|
poller.lock ← PID + timestamp; first instance becomes the poller
|
|
98
148
|
offset ← shared getUpdates offset
|
|
149
|
+
memory.db ← SQLite: episodes, semantic notes, procedures, voice signatures
|
|
99
150
|
threads/
|
|
100
151
|
<threadId>.jsonl ← messages for each topic thread
|
|
101
152
|
general.jsonl ← messages with no thread ID
|
|
102
|
-
~/.
|
|
153
|
+
~/.sensorium-mcp-sessions.json ← name → threadId mapping
|
|
103
154
|
```
|
|
155
|
+
|
|
156
|
+
## License
|
|
157
|
+
|
|
158
|
+
[MIT](LICENSE)
|