morpheus-cli 0.2.5 → 0.2.6

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 CHANGED
@@ -1,493 +1,549 @@
1
- <div align="center">
2
- <img src="./assets/logo.png" alt="Morpheus Logo" width="220" />
3
- </div>
4
-
5
- # Morpheus
6
-
7
- > **Morpheus is a local-first AI operator that bridges developers and machines.**
8
-
9
- Morpheus is a local AI agent for developers, running as a CLI daemon that connects to **LLMs**, **local tools**, and **MCPs**, enabling interaction via **Terminal, Telegram, and Discord**. Inspired by the character Morpheus from *The Matrix*, the project acts as an **intelligent orchestrator**, bridging the gap between the developer and complex systems.
10
-
11
- ## Installation
12
-
13
- Install Morpheus globally via npm:
14
-
15
- ```bash
16
- npm install -g morpheus-cli
17
- ```
18
-
19
- ## Quick Start
20
-
21
- ### 1. Initialize
22
-
23
- Set up your configuration (API keys, preferences):
24
-
25
- ```bash
26
- morpheus init
27
- ```
28
-
29
- ### 2. Start the Agent
30
-
31
- Run the background daemon and Web UI:
32
-
33
- ```bash
34
- morpheus start
35
- ```
36
-
37
- This will:
38
- - Start the agent process
39
- - Launch the Web UI at http://localhost:3333
40
-
41
- ### Other Commands
42
-
43
- ```bash
44
- # Check if Morpheus is running
45
- morpheus status
46
-
47
- # Stop the agent
48
- morpheus stop
49
-
50
- # Diagnose issues
51
- morpheus doctor
52
- ```
53
-
54
- ## Troubleshooting
55
-
56
- ### Command not found
57
-
58
- If you installed successfully but can't run the `morpheus` command:
59
-
60
- 1. **Check your PATH**: Ensure your global npm bin directory is in your system PATH.
61
- - Run `npm bin -g` to see the folder.
62
- - On Windows, this is usually `%APPDATA%\npm`.
63
- - On Linux/Mac, verify `echo $PATH`.
64
- 2. **Restart Terminal**: New installations might not be visible until you restart your shell.
65
-
66
- ## Using NPX
67
- You can run Morpheus without installing it globally using `npx`:
68
-
69
- ```bash
70
-
71
- npx morpheus-cli init
72
-
73
- npx morpheus-cli start
74
-
75
- ```
76
-
77
- ## Technical Overview
78
-
79
- Morpheus is built with **Node.js** and **TypeScript**, using **LangChain** as the orchestration engine. It runs as a background daemon process, managing connections to LLM providers (OpenAI, Anthropic, Ollama) and external channels (Telegram, Discord).
80
-
81
- ### Core Components
82
-
83
- - **Runtime (`src/runtime/`)**: The heart of the application. Manages the Oracle (agent) lifecycle, provider instantiation, and command execution.
84
- - **CLI (`src/cli/`)**: Built with `commander`, handles user interaction, configuration, and daemon control (`start`, `stop`, `status`).
85
- - **Configuration (`src/config/`)**: Singleton-based configuration manager using `zod` for validation and `js-yaml` for persistence (`~/.morpheus/zaion.yaml`).
86
- - **Channels (`src/channels/`)**: Adapters for external communication. Currently supports Telegram (`telegraf`) with strict user whitelisting.
87
-
88
- ## Features
89
-
90
- ### 🖥️ Web Dashboard
91
- Local React-based UI to manage recordings, chat history, and system status across your agent instances.
92
-
93
- #### 🔒 UI Authentication
94
- To protect your Web UI, use the `THE_ARCHITECT_PASS` environment variable. This ensures only authorized users can access the dashboard and API.
95
-
96
- Additionally, you can use environment variables for API keys instead of storing them in the configuration file:
97
-
98
- | Variable | Description | Required |
99
- |----------|-------------|----------|
100
- | `OPENAI_API_KEY` | OpenAI API key (if using GPT) | No |
101
- | `ANTHROPIC_API_KEY` | Anthropic API key (if using Claude) | No |
102
- | `GOOGLE_API_KEY` | Google AI key (for Gemini and Audio) | Yes (for audio) |
103
- | `OPENROUTER_API_KEY` | OpenRouter API key (if using OpenRouter) | No |
104
- | `THE_ARCHITECT_PASS` | Web Dashboard access password | Recommended |
105
- | `TELEGRAM_BOT_TOKEN` | Telegram BotFather token | No |
106
-
107
- If these environment variables are set, they will take precedence over values stored in the configuration file.
108
-
109
- The system also supports generic environment variables that apply to all providers:
110
-
111
- | Variable | Description | Applies To |
112
- |----------|-------------|------------|
113
- | `MORPHEUS_AGENT_NAME` | Name of the agent | agent.name |
114
- | `MORPHEUS_AGENT_PERSONALITY` | Personality of the agent | agent.personality |
115
- | `MORPHEUS_LLM_PROVIDER` | LLM provider to use | llm.provider |
116
- | `MORPHEUS_LLM_MODEL` | Model name for LLM | llm.model |
117
- | `MORPHEUS_LLM_TEMPERATURE` | Temperature setting for LLM | llm.temperature |
118
- | `MORPHEUS_LLM_MAX_TOKENS` | Maximum tokens for LLM | llm.max_tokens |
119
- | `MORPHEUS_LLM_CONTEXT_WINDOW` | Context window size for LLM | llm.context_window |
120
- | `MORPHEUS_LLM_API_KEY` | Generic API key for LLM (lower precedence than provider-specific keys) | llm.api_key |
121
- | `MORPHEUS_SANTI_PROVIDER` | Sati provider to use | santi.provider |
122
- | `MORPHEUS_SANTI_MODEL` | Model name for Sati | santi.model |
123
- | `MORPHEUS_SANTI_TEMPERATURE` | Temperature setting for Sati | santi.temperature |
124
- | `MORPHEUS_SANTI_MAX_TOKENS` | Maximum tokens for Sati | santi.max_tokens |
125
- | `MORPHEUS_SANTI_CONTEXT_WINDOW` | Context window size for Sati | santi.context_window |
126
- | `MORPHEUS_SANTI_API_KEY` | Generic API key for Sati (lower precedence than provider-specific keys) | santi.api_key |
127
- | `MORPHEUS_SANTI_MEMORY_LIMIT` | Memory retrieval limit for Sati | santi.memory_limit |
128
- | `MORPHEUS_AUDIO_MODEL` | Model name for audio processing | audio.model |
129
- | `MORPHEUS_AUDIO_ENABLED` | Enable/disable audio processing | audio.enabled |
130
- | `MORPHEUS_AUDIO_API_KEY` | Generic API key for audio (lower precedence than provider-specific keys) | audio.apiKey |
131
- | `MORPHEUS_AUDIO_MAX_DURATION` | Max duration for audio processing | audio.maxDurationSeconds |
132
- | `MORPHEUS_TELEGRAM_ENABLED` | Enable/disable Telegram channel | channels.telegram.enabled |
133
- | `MORPHEUS_TELEGRAM_TOKEN` | Telegram bot token | channels.telegram.token |
134
- | `MORPHEUS_TELEGRAM_ALLOWED_USERS` | Comma-separated list of allowed Telegram user IDs | channels.telegram.allowedUsers |
135
- | `MORPHEUS_UI_ENABLED` | Enable/disable Web UI | ui.enabled |
136
- | `MORPHEUS_UI_PORT` | Port for Web UI | ui.port |
137
- | `MORPHEUS_LOGGING_ENABLED` | Enable/disable logging | logging.enabled |
138
- | `MORPHEUS_LOGGING_LEVEL` | Logging level | logging.level |
139
- | `MORPHEUS_LOGGING_RETENTION` | Log retention period | logging.retention |
140
-
141
- **Precedence Order**: The system follows this order of precedence when resolving configuration values:
142
- 1. Provider-specific environment variable (e.g., `OPENAI_API_KEY`) - Highest priority
143
- 2. Generic environment variable (e.g., `MORPHEUS_LLM_API_KEY`) - Medium priority
144
- 3. Configuration file value (e.g., `config.llm.api_key`) - Lower priority
145
- 4. Default value - Lowest priority
146
-
147
- > **Note**: If `THE_ARCHITECT_PASS` is not set, the system will use the default password `iamthearchitect`. This is less secure and it's recommended to set your own password in production environments.
148
-
149
- **Option 1: Using a `.env` file**
150
- Create a `.env` file in the root of your project:
151
-
152
- ```env
153
- OPENAI_API_KEY="your-openai-api-key"
154
- ANTHROPIC_API_KEY="your-anthropic-api-key"
155
- GOOGLE_API_KEY="your-google-api-key"
156
- THE_ARCHITECT_PASS="your-secure-password"
157
- TELEGRAM_BOT_TOKEN="your-telegram-bot-token"
158
- OPENROUTER_API_KEY="your-openrouter-api-key"
159
- ```
160
-
161
- **Option 2: Using Shell export**
162
-
163
- ```bash
164
- export OPENAI_API_KEY="your-openai-api-key"
165
- export ANTHROPIC_API_KEY="your-anthropic-api-key"
166
- export GOOGLE_API_KEY="your-google-api-key"
167
- export OPENROUTER_API_KEY="your-openrouter-api-key"
168
- export THE_ARCHITECT_PASS="your-secure-password"
169
- export TELEGRAM_BOT_TOKEN="your-telegram-bot-token"
170
- morpheus start
171
- ```
172
-
173
- When enabled:
174
- - The Web UI will redirect to a Login page.
175
- - API requests require the `x-architect-pass` header.
176
- - The session is persisted locally in your browser.
177
-
178
- ### 🧩 MCP Support (Model Context Protocol)
179
- Full integration with [Model Context Protocol](https://modelcontextprotocol.io/), allowing Morpheus to use standardized tools from any MCP-compatible server.
180
-
181
- ### 🧠 Sati (Long-Term Memory)
182
- Morpheus features a dedicated middleware system called **Sati** (Mindfulness) that provides long-term memory capabilities.
183
- - **Automated Storage**: Automatically extracts and saves preferences, project details, and facts from conversations.
184
- - **Contextual Retrieval**: Injects relevant memories into the context based on your current query.
185
- - **Data Privacy**: Stored in a local, independent SQLite database (`santi-memory.db`), ensuring sensitive data is handled securely and reducing context window usage.
186
- - **Memory Management**: View and manage your long-term memories through the Web UI or via API endpoints.
187
-
188
- ### 📊 Usage Analytics
189
- Track your token usage across different providers and models directly from the Web UI. View detailed breakdowns of input/output tokens and message counts to monitor costs and activity.
190
-
191
- ### 🎙️ Audio Transcription (Telegram)
192
- Send voice messages directly to the Telegram bot. Morpheus will:
193
- 1. Transcribe the audio using **Google Gemini**.
194
- 2. Process the text as a standard prompt.
195
- 3. Reply with the answer.
196
-
197
- *Requires a Google Gemini API Key.*
198
-
199
- ## Development Setup
200
-
201
- This guide is for developers contributing to the Morpheus codebase.
202
-
203
- ### Prerequisites
204
-
205
- - **Node.js**: >= 18.x
206
- - **npm**: >= 9.x
207
- - **TypeScript**: >= 5.x
208
-
209
- ### 1. Clone & Install
210
-
211
- ```bash
212
- git clone https://github.com/your-org/morpheus.git
213
- cd morpheus
214
- npm install
215
- ```
216
-
217
- ### 2. Build
218
-
219
- Compile TypeScript source to `dist/` and build the Web UI.
220
-
221
- ```bash
222
- npm run build
223
- ```
224
-
225
- ### 3. Run the CLI
226
-
227
- You can run the CLI directly from the source using `npm start`.
228
-
229
- ```bash
230
- # Initialize configuration (creates ~/.morpheus)
231
- npm start -- init
232
-
233
- # Start the daemon
234
- npm start -- start
235
-
236
- # Check status
237
- npm start -- status
238
- ```
239
-
240
- ### 4. Configuration
241
-
242
- The configuration file is located at `~/.morpheus/zaion.yaml`. You can edit it manually or use the `morpheus config` command.
243
-
244
- ```yaml
245
- agent:
246
- name: "Morpheus"
247
- personality: "stoic, wise, and helpful"
248
- llm:
249
- provider: "openai" # options: openai, anthropic, ollama, gemini
250
- model: "gpt-4-turbo"
251
- temperature: 0.7
252
- context_window: 100 # Number of messages to load into LLM context
253
- api_key: "sk-..."
254
- santi: # Optional: Sati (Long-Term Memory) specific settings
255
- provider: "openai" # defaults to llm.provider
256
- model: "gpt-4o"
257
- memory_limit: 1000 # Number of messages/items to retrieve
258
- channels:
259
- telegram:
260
- enabled: true
261
- token: "YOUR_TELEGRAM_BOT_TOKEN"
262
- allowedUsers: ["123456789"] # Your Telegram User ID
263
- discord:
264
- enabled: false # Coming soon
265
-
266
- # Web UI Dashboard
267
- ui:
268
- enabled: true
269
- port: 3333
270
-
271
- # Audio Transcription Support
272
- audio:
273
- enabled: true
274
- apiKey: "YOUR_GEMINI_API_KEY" # Optional if llm.provider is 'gemini'
275
- maxDurationSeconds: 300
276
- ```
277
-
278
- ### 5. MCP Configuration
279
-
280
- Morpheus supports external tools via **MCP (Model Context Protocol)**. Configure your MCP servers in `~/.morpheus/mcps.json`:
281
-
282
- ```json
283
- {
284
- "coolify": {
285
- "transport": "stdio",
286
- "command": "npx",
287
- "args": ["-y", "@coolify/mcp-server"],
288
- "env": {
289
- "COOLIFY_URL": "https://app.coolify.io",
290
- "COOLIFY_TOKEN": "your-token"
291
- }
292
- },
293
- "coingecko": {
294
- "transport": "http",
295
- "url": "https://mcps.mnunes.xyz/coingecko/mcp"
296
- }
297
- }
298
- ```
299
-
300
- ## API Endpoints
301
-
302
- Morpheus exposes several API endpoints for programmatic access to its features:
303
-
304
- ### Sati Memories Endpoints
305
-
306
- #### GET `/api/sati/memories`
307
- Retrieve all memories stored by the Sati agent (long-term memory).
308
-
309
- * **Authentication:** Requires `Authorization` header with the password set in `THE_ARCHITECT_PASS`.
310
- * **Response:**
311
- ```json
312
- [
313
- {
314
- "id": "unique-id",
315
- "category": "work",
316
- "importance": "high",
317
- "summary": "Memory summary",
318
- "details": "Additional details of the memory",
319
- "hash": "unique-hash",
320
- "source": "source",
321
- "created_at": "2023-01-01T00:00:00.000Z",
322
- "updated_at": "2023-01-01T00:00:00.000Z",
323
- "last_accessed_at": "2023-01-01T00:00:00.000Z",
324
- "access_count": 5,
325
- "version": 1,
326
- "archived": false
327
- }
328
- ]
329
- ```
330
-
331
- #### DELETE `/api/sati/memories/:id`
332
- Archive (soft delete) a specific memory from the Sati agent.
333
-
334
- * **Authentication:** Requires `Authorization` header with the password set in `THE_ARCHITECT_PASS`.
335
- * **Parameters:** `id` - ID of the memory to archive.
336
- * **Response:**
337
- ```json
338
- {
339
- "success": true,
340
- "message": "Memory archived successfully"
341
- }
342
- ```
343
-
344
- #### POST `/api/sati/memories/bulk-delete`
345
- Archive (soft delete) multiple memories from the Sati agent at once.
346
-
347
- * **Authentication:** Requires `Authorization` header with the password set in `THE_ARCHITECT_PASS`.
348
- * **Body:**
349
- ```json
350
- {
351
- "ids": ["id1", "id2", "id3"]
352
- }
353
- ```
354
- * **Response:**
355
- ```json
356
- {
357
- "success": true,
358
- "message": "X memories archived successfully",
359
- "deletedCount": X
360
- }
361
- ```
362
-
363
- ## Testing
364
-
365
- We use **Vitest** for testing.
366
-
367
- ```bash
368
- # Run unit tests
369
- npm test
370
-
371
- # Run tests in watch mode
372
- npm run test:watch
373
- ```
374
-
375
- ## Project Structure
376
-
377
- ```text
378
- .
379
- ├── assets/ # Static assets
380
- ├── bin/ # CLI entry point (morpheus.js)
381
- ├── specs/ # Technical specifications & documentation
382
- ├── src/
383
- │ ├── channels/ # Communication adapters (Telegram, etc.)
384
- │ ├── cli/ # CLI commands and logic
385
- │ ├── config/ # Configuration management
386
- │ ├── runtime/ # Core agent logic, lifecycle, and providers
387
- │ ├── types/ # Shared TypeScript definitions
388
- │ └── ui/ # React Web UI Dashboard
389
- └── package.json
390
- ```
391
-
392
- ## Roadmap
393
-
394
- - [x] **Web Dashboard**: Local UI for management and logs.
395
- - [x] **MCP Support**: Full integration with Model Context Protocol.
396
- - [ ] **Discord Adapter**: Support for Discord interactions.
397
- - [ ] **Plugin System**: Extend functionality via external modules.
398
-
399
- ## 🕵️ Privacy Protection
400
-
401
- The Web UI includes privacy protection headers to prevent indexing by search engines:
402
- - HTML meta tags: `<meta name="robots" content="noindex, nofollow">`
403
- - HTTP header: `X-Robots-Tag: noindex, nofollow`
404
-
405
- This ensures that your private agent dashboard remains private and is not discoverable by search engines.
406
-
407
- ## 🐳 Running with Docker
408
-
409
- Morpheus can be easily deployed using Docker and Docker Compose. The container supports all environment variables for configuration.
410
-
411
- ### Prerequisites
412
-
413
- - Docker Engine
414
- - Docker Compose
415
-
416
- ### Quick Start
417
-
418
- 1. Create a `.env` file with your configuration:
419
-
420
- ```bash
421
- cp .env.example .env
422
- # Edit .env with your actual API keys and settings
423
- ```
424
-
425
- 2. Build and start the container:
426
-
427
- ```bash
428
- docker-compose up -d
429
- ```
430
-
431
- 3. Access the Web UI at `http://localhost:3333`
432
-
433
- ### Using Docker Directly
434
-
435
- ```bash
436
- # Build the image
437
- docker build -t morpheus .
438
-
439
- # Run with environment variables
440
- docker run -d \
441
- --name morpheus-agent \
442
- -p 3333:3333 \
443
- -v morpheus_data:/root/.morpheus \
444
- -e MORPHEUS_LLM_PROVIDER=openai \
445
- -e OPENAI_API_KEY=your-api-key-here \
446
- -e THE_ARCHITECT_PASS=your-password \
447
- morpheus
448
- ```
449
-
450
- ### Environment Variables in Docker
451
-
452
- All environment variables described above work in Docker. The precedence order remains the same:
453
- 1. Container environment variables
454
- 2. Configuration file values
455
- 3. Default values
456
-
457
- ### Persistent Data
458
-
459
- The container stores configuration and data in `/root/.morpheus`. Mount a volume to persist data between container restarts:
460
-
461
- ```yaml
462
- volumes:
463
- - morpheus_data:/root/.morpheus # Recommended for persistence
464
- ```
465
-
466
- ### Health Check
467
-
468
- The container includes a health check that verifies the health endpoint is accessible. The application exposes a public `/health` endpoint that doesn't require authentication:
469
-
470
- ```bash
471
- curl http://localhost:3333/health
472
- ```
473
-
474
- Response:
475
- ```json
476
- {
477
- "status": "healthy",
478
- "timestamp": "2026-02-05T21:30:00.000Z",
479
- "uptime": 123.45
480
- }
481
- ```
482
-
483
- ## Contributing
484
-
485
- 1. Fork the repository.
486
- 2. Create a feature branch (`git checkout -b feature/amazing-feature`).
487
- 3. Commit your changes (`git commit -m 'feat: Add amazing feature'`).
488
- 4. Push to the branch (`git push origin feature/amazing-feature`).
489
- 5. Open a Pull Request.
490
-
491
- ## License
492
-
493
- MIT
1
+ <div align="center">
2
+ <img src="./assets/logo.png" alt="Morpheus Logo" width="220" />
3
+ </div>
4
+
5
+ # Morpheus
6
+
7
+ > **Morpheus is a local-first AI operator that bridges developers and machines.**
8
+
9
+ Morpheus is a local AI agent for developers, running as a CLI daemon that connects to **LLMs**, **local tools**, and **MCPs**, enabling interaction via **Terminal, Telegram, and Discord**. Inspired by the character Morpheus from *The Matrix*, the project acts as an **intelligent orchestrator**, bridging the gap between the developer and complex systems.
10
+
11
+ ## Installation
12
+
13
+ Install Morpheus globally via npm:
14
+
15
+ ```bash
16
+ npm install -g morpheus-cli
17
+ ```
18
+
19
+ ## Quick Start
20
+
21
+ ### 1. Initialize
22
+
23
+ Set up your configuration (API keys, preferences):
24
+
25
+ ```bash
26
+ morpheus init
27
+ ```
28
+
29
+ ### 2. Start the Agent
30
+
31
+ Run the background daemon and Web UI:
32
+
33
+ ```bash
34
+ morpheus start
35
+ ```
36
+
37
+ This will:
38
+ - Start the agent process
39
+ - Launch the Web UI at http://localhost:3333
40
+
41
+ ### Other Commands
42
+
43
+ ```bash
44
+ # Check if Morpheus is running
45
+ morpheus status
46
+
47
+ # Stop the agent
48
+ morpheus stop
49
+
50
+ # Restart the agent
51
+ morpheus restart
52
+
53
+ # Diagnose issues
54
+ morpheus doctor
55
+ ```
56
+
57
+ ## Troubleshooting
58
+
59
+ ### Command not found
60
+
61
+ If you installed successfully but can't run the `morpheus` command:
62
+
63
+ 1. **Check your PATH**: Ensure your global npm bin directory is in your system PATH.
64
+ - Run `npm bin -g` to see the folder.
65
+ - On Windows, this is usually `%APPDATA%\npm`.
66
+ - On Linux/Mac, verify `echo $PATH`.
67
+ 2. **Restart Terminal**: New installations might not be visible until you restart your shell.
68
+
69
+ ## Using NPX
70
+ You can run Morpheus without installing it globally using `npx`:
71
+
72
+ ```bash
73
+
74
+ npx morpheus-cli init
75
+
76
+ npx morpheus-cli start
77
+
78
+ ```
79
+
80
+ ## Technical Overview
81
+
82
+ Morpheus is built with **Node.js** and **TypeScript**, using **LangChain** as the orchestration engine. It runs as a background daemon process, managing connections to LLM providers (OpenAI, Anthropic, Ollama) and external channels (Telegram, Discord).
83
+
84
+ ### Core Components
85
+
86
+ - **Runtime (`src/runtime/`)**: The heart of the application. Manages the Oracle (agent) lifecycle, provider instantiation, and command execution.
87
+ - **CLI (`src/cli/`)**: Built with `commander`, handles user interaction, configuration, and daemon control (`start`, `stop`, `status`).
88
+ - **Configuration (`src/config/`)**: Singleton-based configuration manager using `zod` for validation and `js-yaml` for persistence (`~/.morpheus/zaion.yaml`).
89
+ - **Channels (`src/channels/`)**: Adapters for external communication. Currently supports Telegram (`telegraf`) with strict user whitelisting.
90
+
91
+ ## Features
92
+
93
+ ### 🖥️ Web Dashboard
94
+ Local React-based UI to manage recordings, chat history, and system status across your agent instances.
95
+
96
+ #### 🔒 UI Authentication
97
+ To protect your Web UI, use the `THE_ARCHITECT_PASS` environment variable. This ensures only authorized users can access the dashboard and API.
98
+
99
+ Additionally, you can use environment variables for API keys instead of storing them in the configuration file:
100
+
101
+ | Variable | Description | Required |
102
+ |----------|-------------|----------|
103
+ | `OPENAI_API_KEY` | OpenAI API key (if using GPT) | No |
104
+ | `ANTHROPIC_API_KEY` | Anthropic API key (if using Claude) | No |
105
+ | `GOOGLE_API_KEY` | Google AI key (for Gemini and Audio) | Yes (for audio) |
106
+ | `OPENROUTER_API_KEY` | OpenRouter API key (if using OpenRouter) | No |
107
+ | `THE_ARCHITECT_PASS` | Web Dashboard access password | Recommended |
108
+ | `TELEGRAM_BOT_TOKEN` | Telegram BotFather token | No |
109
+
110
+ If these environment variables are set, they will take precedence over values stored in the configuration file.
111
+
112
+ The system also supports generic environment variables that apply to all providers:
113
+
114
+ | Variable | Description | Applies To |
115
+ |----------|-------------|------------|
116
+ | `MORPHEUS_AGENT_NAME` | Name of the agent | agent.name |
117
+ | `MORPHEUS_AGENT_PERSONALITY` | Personality of the agent | agent.personality |
118
+ | `MORPHEUS_LLM_PROVIDER` | LLM provider to use | llm.provider |
119
+ | `MORPHEUS_LLM_MODEL` | Model name for LLM | llm.model |
120
+ | `MORPHEUS_LLM_TEMPERATURE` | Temperature setting for LLM | llm.temperature |
121
+ | `MORPHEUS_LLM_MAX_TOKENS` | Maximum tokens for LLM | llm.max_tokens |
122
+ | `MORPHEUS_LLM_CONTEXT_WINDOW` | Context window size for LLM | llm.context_window |
123
+ | `MORPHEUS_LLM_API_KEY` | Generic API key for LLM (lower precedence than provider-specific keys) | llm.api_key |
124
+ | `MORPHEUS_SANTI_PROVIDER` | Sati provider to use | santi.provider |
125
+ | `MORPHEUS_SANTI_MODEL` | Model name for Sati | santi.model |
126
+ | `MORPHEUS_SANTI_TEMPERATURE` | Temperature setting for Sati | santi.temperature |
127
+ | `MORPHEUS_SANTI_MAX_TOKENS` | Maximum tokens for Sati | santi.max_tokens |
128
+ | `MORPHEUS_SANTI_CONTEXT_WINDOW` | Context window size for Sati | santi.context_window |
129
+ | `MORPHEUS_SANTI_API_KEY` | Generic API key for Sati (lower precedence than provider-specific keys) | santi.api_key |
130
+ | `MORPHEUS_SANTI_MEMORY_LIMIT` | Memory retrieval limit for Sati | santi.memory_limit |
131
+ | `MORPHEUS_AUDIO_MODEL` | Model name for audio processing | audio.model |
132
+ | `MORPHEUS_AUDIO_ENABLED` | Enable/disable audio processing | audio.enabled |
133
+ | `MORPHEUS_AUDIO_API_KEY` | Generic API key for audio (lower precedence than provider-specific keys) | audio.apiKey |
134
+ | `MORPHEUS_AUDIO_MAX_DURATION` | Max duration for audio processing | audio.maxDurationSeconds |
135
+ | `MORPHEUS_TELEGRAM_ENABLED` | Enable/disable Telegram channel | channels.telegram.enabled |
136
+ | `MORPHEUS_TELEGRAM_TOKEN` | Telegram bot token | channels.telegram.token |
137
+ | `MORPHEUS_TELEGRAM_ALLOWED_USERS` | Comma-separated list of allowed Telegram user IDs | channels.telegram.allowedUsers |
138
+ | `MORPHEUS_UI_ENABLED` | Enable/disable Web UI | ui.enabled |
139
+ | `MORPHEUS_UI_PORT` | Port for Web UI | ui.port |
140
+ | `MORPHEUS_LOGGING_ENABLED` | Enable/disable logging | logging.enabled |
141
+ | `MORPHEUS_LOGGING_LEVEL` | Logging level | logging.level |
142
+ | `MORPHEUS_LOGGING_RETENTION` | Log retention period | logging.retention |
143
+
144
+ **Precedence Order**: The system follows this order of precedence when resolving configuration values:
145
+ 1. Provider-specific environment variable (e.g., `OPENAI_API_KEY`) - Highest priority
146
+ 2. Generic environment variable (e.g., `MORPHEUS_LLM_API_KEY`) - Medium priority
147
+ 3. Configuration file value (e.g., `config.llm.api_key`) - Lower priority
148
+ 4. Default value - Lowest priority
149
+
150
+ > **Note**: If `THE_ARCHITECT_PASS` is not set, the system will use the default password `iamthearchitect`. This is less secure and it's recommended to set your own password in production environments.
151
+
152
+ **Option 1: Using a `.env` file**
153
+ Create a `.env` file in the root of your project:
154
+
155
+ ```env
156
+ OPENAI_API_KEY="your-openai-api-key"
157
+ ANTHROPIC_API_KEY="your-anthropic-api-key"
158
+ GOOGLE_API_KEY="your-google-api-key"
159
+ THE_ARCHITECT_PASS="your-secure-password"
160
+ TELEGRAM_BOT_TOKEN="your-telegram-bot-token"
161
+ OPENROUTER_API_KEY="your-openrouter-api-key"
162
+ ```
163
+
164
+ **Option 2: Using Shell export**
165
+
166
+ ```bash
167
+ export OPENAI_API_KEY="your-openai-api-key"
168
+ export ANTHROPIC_API_KEY="your-anthropic-api-key"
169
+ export GOOGLE_API_KEY="your-google-api-key"
170
+ export OPENROUTER_API_KEY="your-openrouter-api-key"
171
+ export THE_ARCHITECT_PASS="your-secure-password"
172
+ export TELEGRAM_BOT_TOKEN="your-telegram-bot-token"
173
+ morpheus start
174
+ ```
175
+
176
+ When enabled:
177
+ - The Web UI will redirect to a Login page.
178
+ - API requests require the `x-architect-pass` header.
179
+ - The session is persisted locally in your browser.
180
+
181
+ ### 🧩 MCP Support (Model Context Protocol)
182
+ Full integration with [Model Context Protocol](https://modelcontextprotocol.io/), allowing Morpheus to use standardized tools from any MCP-compatible server.
183
+
184
+ ### 🧠 Sati (Long-Term Memory)
185
+ Morpheus features a dedicated middleware system called **Sati** (Mindfulness) that provides long-term memory capabilities.
186
+ - **Automated Storage**: Automatically extracts and saves preferences, project details, and facts from conversations.
187
+ - **Contextual Retrieval**: Injects relevant memories into the context based on your current query.
188
+ - **Data Privacy**: Stored in a local, independent SQLite database (`santi-memory.db`), ensuring sensitive data is handled securely and reducing context window usage.
189
+ - **Memory Management**: View and manage your long-term memories through the Web UI or via API endpoints.
190
+
191
+ ### 📊 Usage Analytics
192
+ Track your token usage across different providers and models directly from the Web UI. View detailed breakdowns of input/output tokens and message counts to monitor costs and activity.
193
+
194
+ ### 🎙️ Audio Transcription (Telegram)
195
+ Send voice messages directly to the Telegram bot. Morpheus will:
196
+ 1. Transcribe the audio using **Google Gemini**.
197
+ 2. Process the text as a standard prompt.
198
+ 3. Reply with the answer.
199
+
200
+ *Requires a Google Gemini API Key.*
201
+
202
+ ### 🤖 Telegram Commands
203
+ The Morpheus Telegram bot supports several commands for interacting with the agent:
204
+
205
+ - `/start` - Show welcome message and available commands
206
+ - `/status` - Check the status of the Morpheus agent
207
+ - `/doctor` - Diagnose environment and configuration issues
208
+ - `/stats` - Show token usage statistics
209
+ - `/help` - Show available commands
210
+ - `/zaion` - Show system configurations
211
+ - `/sati <qnt>` - Show specific memories
212
+ - `/restart` - **New!** Restart the Morpheus agent
213
+
214
+ ## Development Setup
215
+
216
+ This guide is for developers contributing to the Morpheus codebase.
217
+
218
+ ### Prerequisites
219
+
220
+ - **Node.js**: >= 18.x
221
+ - **npm**: >= 9.x
222
+ - **TypeScript**: >= 5.x
223
+
224
+ ### 1. Clone & Install
225
+
226
+ ```bash
227
+ git clone https://github.com/your-org/morpheus.git
228
+ cd morpheus
229
+ npm install
230
+ ```
231
+
232
+ ### 2. Build
233
+
234
+ Compile TypeScript source to `dist/` and build the Web UI.
235
+
236
+ ```bash
237
+ npm run build
238
+ ```
239
+
240
+ ### 3. Run the CLI
241
+
242
+ You can run the CLI directly from the source using `npm start`.
243
+
244
+ ```bash
245
+ # Initialize configuration (creates ~/.morpheus)
246
+ npm start -- init
247
+
248
+ # Start the daemon
249
+ npm start -- start
250
+
251
+ # Check status
252
+ npm start -- status
253
+ ```
254
+
255
+ ### 4. Configuration
256
+
257
+ The configuration file is located at `~/.morpheus/zaion.yaml`. You can edit it manually or use the `morpheus config` command.
258
+
259
+ ```yaml
260
+ agent:
261
+ name: "Morpheus"
262
+ personality: "stoic, wise, and helpful"
263
+ llm:
264
+ provider: "openai" # options: openai, anthropic, ollama, gemini
265
+ model: "gpt-4-turbo"
266
+ temperature: 0.7
267
+ context_window: 100 # Number of messages to load into LLM context
268
+ api_key: "sk-..."
269
+ santi: # Optional: Sati (Long-Term Memory) specific settings
270
+ provider: "openai" # defaults to llm.provider
271
+ model: "gpt-4o"
272
+ memory_limit: 1000 # Number of messages/items to retrieve
273
+ channels:
274
+ telegram:
275
+ enabled: true
276
+ token: "YOUR_TELEGRAM_BOT_TOKEN"
277
+ allowedUsers: ["123456789"] # Your Telegram User ID
278
+ discord:
279
+ enabled: false # Coming soon
280
+
281
+ # Web UI Dashboard
282
+ ui:
283
+ enabled: true
284
+ port: 3333
285
+
286
+ # Audio Transcription Support
287
+ audio:
288
+ enabled: true
289
+ apiKey: "YOUR_GEMINI_API_KEY" # Optional if llm.provider is 'gemini'
290
+ maxDurationSeconds: 300
291
+ ```
292
+
293
+ ### 5. MCP Configuration
294
+
295
+ Morpheus supports external tools via **MCP (Model Context Protocol)**. Configure your MCP servers in `~/.morpheus/mcps.json`:
296
+
297
+ ```json
298
+ {
299
+ "coolify": {
300
+ "transport": "stdio",
301
+ "command": "npx",
302
+ "args": ["-y", "@coolify/mcp-server"],
303
+ "env": {
304
+ "COOLIFY_URL": "https://app.coolify.io",
305
+ "COOLIFY_TOKEN": "your-token"
306
+ }
307
+ },
308
+ "coingecko": {
309
+ "transport": "http",
310
+ "url": "https://mcps.mnunes.xyz/coingecko/mcp"
311
+ }
312
+ }
313
+ ```
314
+
315
+ ## API Endpoints
316
+
317
+ Morpheus exposes several API endpoints for programmatic access to its features:
318
+
319
+ ### Sati Memories Endpoints
320
+
321
+ #### GET `/api/sati/memories`
322
+ Retrieve all memories stored by the Sati agent (long-term memory).
323
+
324
+ * **Authentication:** Requires `Authorization` header with the password set in `THE_ARCHITECT_PASS`.
325
+ * **Response:**
326
+ ```json
327
+ [
328
+ {
329
+ "id": "unique-id",
330
+ "category": "work",
331
+ "importance": "high",
332
+ "summary": "Memory summary",
333
+ "details": "Additional details of the memory",
334
+ "hash": "unique-hash",
335
+ "source": "source",
336
+ "created_at": "2023-01-01T00:00:00.000Z",
337
+ "updated_at": "2023-01-01T00:00:00.000Z",
338
+ "last_accessed_at": "2023-01-01T00:00:00.000Z",
339
+ "access_count": 5,
340
+ "version": 1,
341
+ "archived": false
342
+ }
343
+ ]
344
+ ```
345
+
346
+ #### DELETE `/api/sati/memories/:id`
347
+ Archive (soft delete) a specific memory from the Sati agent.
348
+
349
+ * **Authentication:** Requires `Authorization` header with the password set in `THE_ARCHITECT_PASS`.
350
+ * **Parameters:** `id` - ID of the memory to archive.
351
+ * **Response:**
352
+ ```json
353
+ {
354
+ "success": true,
355
+ "message": "Memory archived successfully"
356
+ }
357
+ ```
358
+
359
+ #### POST `/api/sati/memories/bulk-delete`
360
+ Archive (soft delete) multiple memories from the Sati agent at once.
361
+
362
+ * **Authentication:** Requires `Authorization` header with the password set in `THE_ARCHITECT_PASS`.
363
+ * **Body:**
364
+ ```json
365
+ {
366
+ "ids": ["id1", "id2", "id3"]
367
+ }
368
+ ```
369
+ * **Response:**
370
+ ```json
371
+ {
372
+ "success": true,
373
+ "message": "X memories archived successfully",
374
+ "deletedCount": X
375
+ }
376
+ ```
377
+
378
+ ## Testing
379
+
380
+ We use **Vitest** for testing.
381
+
382
+ ```bash
383
+ # Run unit tests
384
+ npm test
385
+
386
+ # Run tests in watch mode
387
+ npm run test:watch
388
+ ```
389
+
390
+ ## Project Structure
391
+
392
+ ```text
393
+ .
394
+ ├── assets/ # Static assets
395
+ ├── bin/ # CLI entry point (morpheus.js)
396
+ ├── specs/ # Technical specifications & documentation
397
+ ├── src/
398
+ │ ├── channels/ # Communication adapters (Telegram, etc.)
399
+ │ ├── cli/ # CLI commands and logic
400
+ │ ├── config/ # Configuration management
401
+ │ ├── runtime/ # Core agent logic, lifecycle, and providers
402
+ │ ├── types/ # Shared TypeScript definitions
403
+ │ └── ui/ # React Web UI Dashboard
404
+ └── package.json
405
+ ```
406
+
407
+ ## Roadmap
408
+
409
+ - [x] **Web Dashboard**: Local UI for management and logs.
410
+ - [x] **MCP Support**: Full integration with Model Context Protocol.
411
+ - [ ] **Discord Adapter**: Support for Discord interactions.
412
+ - [ ] **Plugin System**: Extend functionality via external modules.
413
+
414
+ ## 🕵️ Privacy Protection
415
+
416
+ The Web UI includes privacy protection headers to prevent indexing by search engines:
417
+ - HTML meta tags: `<meta name="robots" content="noindex, nofollow">`
418
+ - HTTP header: `X-Robots-Tag: noindex, nofollow`
419
+
420
+ This ensures that your private agent dashboard remains private and is not discoverable by search engines.
421
+
422
+ ## 🐳 Running with Docker
423
+
424
+ Morpheus can be easily deployed using Docker and Docker Compose. The container supports all environment variables for configuration.
425
+ The Docker image is publicly available at [Docker Hub](https://hub.docker.com/r/marcosnunesmbs/morpheus).
426
+
427
+ ### Prerequisites
428
+
429
+ - Docker Engine
430
+ - Docker Compose
431
+
432
+ ### Quick Start
433
+
434
+ 1. Create a `.env` file with your configuration:
435
+
436
+ ```bash
437
+ cp .env.example .env
438
+ # Edit .env with your actual API keys and settings
439
+ ```
440
+
441
+ 2. Build and start the container:
442
+
443
+ ```bash
444
+ docker-compose up -d
445
+ ```
446
+
447
+ 3. Access the Web UI at `http://localhost:3333`
448
+
449
+ ### Docker Compose Example
450
+
451
+ Here's a complete example of how to run Morpheus using Docker Compose:
452
+
453
+ ```yaml
454
+ version: '3.8'
455
+
456
+ services:
457
+ morpheus:
458
+ image: morpheus/morpheus-agent:latest
459
+ container_name: morpheus-agent
460
+ ports:
461
+ - "3333:3333"
462
+ volumes:
463
+ - morpheus_data:/root/.morpheus
464
+ environment:
465
+ # LLM Configuration
466
+ - MORPHEUS_LLM_PROVIDER=openai
467
+ - MORPHEUS_LLM_MODEL=gpt-4o
468
+ - MORPHEUS_LLM_TEMPERATURE=0.7
469
+
470
+ # API Keys
471
+ - OPENAI_API_KEY=your-openai-api-key
472
+ - ANTHROPIC_API_KEY=your-anthropic-api-key
473
+ - GOOGLE_API_KEY=your-google-api-key
474
+ - OPENROUTER_API_KEY=your-openrouter-api-key
475
+
476
+ # Security
477
+ - THE_ARCHITECT_PASS=your-secure-password
478
+
479
+ # Agent Configuration
480
+ - MORPHEUS_AGENT_NAME=morpheus
481
+ - MORPHEUS_AGENT_PERSONALITY=helpful_dev
482
+
483
+ # UI Configuration
484
+ - MORPHEUS_UI_ENABLED=true
485
+ - MORPHEUS_UI_PORT=3333
486
+ restart: unless-stopped
487
+ ```
488
+
489
+ ### Using Docker Directly
490
+
491
+ ```bash
492
+ # Build the image
493
+ docker build -t morpheus .
494
+
495
+ # Run with environment variables
496
+ docker run -d \
497
+ --name morpheus-agent \
498
+ -p 3333:3333 \
499
+ -v morpheus_data:/root/.morpheus \
500
+ -e MORPHEUS_LLM_PROVIDER=openai \
501
+ -e OPENAI_API_KEY=your-api-key-here \
502
+ -e THE_ARCHITECT_PASS=your-password \
503
+ morpheus
504
+ ```
505
+
506
+ ### Environment Variables in Docker
507
+
508
+ All environment variables described above work in Docker. The precedence order remains the same:
509
+ 1. Container environment variables
510
+ 2. Configuration file values
511
+ 3. Default values
512
+
513
+ ### Persistent Data
514
+
515
+ The container stores configuration and data in `/root/.morpheus`. Mount a volume to persist data between container restarts:
516
+
517
+ ```yaml
518
+ volumes:
519
+ - morpheus_data:/root/.morpheus # Recommended for persistence
520
+ ```
521
+
522
+ ### Health Check
523
+
524
+ The container includes a health check that verifies the health endpoint is accessible. The application exposes a public `/health` endpoint that doesn't require authentication:
525
+
526
+ ```bash
527
+ curl http://localhost:3333/health
528
+ ```
529
+
530
+ Response:
531
+ ```json
532
+ {
533
+ "status": "healthy",
534
+ "timestamp": "2026-02-05T21:30:00.000Z",
535
+ "uptime": 123.45
536
+ }
537
+ ```
538
+
539
+ ## Contributing
540
+
541
+ 1. Fork the repository.
542
+ 2. Create a feature branch (`git checkout -b feature/amazing-feature`).
543
+ 3. Commit your changes (`git commit -m 'feat: Add amazing feature'`).
544
+ 4. Push to the branch (`git push origin feature/amazing-feature`).
545
+ 5. Open a Pull Request.
546
+
547
+ ## License
548
+
549
+ MIT