Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI or Telegram.
3,084
stars
253
commits
TypeScript
primary language
Sep 11, 2026
updated
Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access.
Remembers what matters. Asks before it acts. Runs 24/7 from CLI, Telegram, or Web. 31 built-in tools, Kanban boards, extensible skills, SQLite-backed Second Brain memory.
🔖 Current Stable: v1.1.13
English | 简体中文
One-liner install (no Node.js required) — downloads the latest standalone binary for your OS:
# macOS / Linux
curl -fsSL https://mercuryagent.sh/install.sh | sh
# Windows
irm https://mercuryagent.sh/install.ps1 | iex
Or via npm if you already have Node.js 20+:
npx @cosmicstack/mercury-agent
Or install the npm package globally:
npm i -g @cosmicstack/mercury-agent
mercury
First run triggers the setup wizard (name, provider, optional Telegram). After setup, Mercury opens the Ink TUI startup screen and asks for your permission mode (Ask Me or Allow All) before chat starts.
To reconfigure later (change keys, name, settings):
mercury doctor
mercury doctor --platform
Every AI agent can read files, run commands, and fetch URLs. Most do it silently. Mercury asks first — and remembers what matters.
sudo, rm -rf /, etc. never execute). Folder-level read/write scoping. Pending approval flow. Ask Me or Allow All per session. No surprises.soul.md, persona.md, taste.md, heartbeat.md). No corporate wrapper./budget command to check, reset, or override.Mercury now seeds a default web-search skill on first run in ~/.mercury/skills/web-search/SKILL.md.
One command to make Mercury persistent:
mercury up
This installs the system service (if not installed), starts the background daemon, and ensures Mercury is running. Use this as your go-to command.
If Mercury is already running, mercury up just confirms it and shows the PID.
mercury restart # Restart the background process
mercury stop # Stop the background process
mercury start -d # Start in background (without service install)
mercury logs # View recent daemon logs
mercury status # Show if daemon is running
Daemon mode includes built-in crash recovery — if the process crashes, it restarts automatically with exponential backoff (up to 10 restarts per minute).
mercury up installs this automatically. You can also manage it directly:
mercury service install
| Platform | Method | Requires Admin |
|---|---|---|
| macOS | LaunchAgent (~/Library/LaunchAgents/) | No |
| Linux | systemd user unit (~/.config/systemd/user/) | No (linger for boot) |
| Windows | Task Scheduler (schtasks) | No |
mercury service status # Check if service is running
mercury service uninstall # Remove the system service
In daemon mode, Telegram becomes your primary channel — CLI is log-only since there's no terminal for input.
| Command | Description |
|---|---|
mercury up | Recommended. Install service + start daemon + ensure running |
mercury | Start the agent (same as mercury start) |
mercury start | Start in foreground |
mercury start -d | Start in background (daemon mode) |
mercury restart | Restart the background process |
mercury stop | Stop a background process |
mercury logs | View recent daemon logs |
mercury doctor | Reconfigure setup (name, providers, channels, permissions defaults) |
mercury doctor --platform | Show cross-platform terminal/daemon compatibility diagnostics |
mercury setup | Re-run the setup wizard |
mercury status | Show config and daemon status |
mercury help | Show full manual |
mercury upgrade | Upgrade to latest version |
mercury telegram list | List approved and pending Telegram users |
mercury telegram approve <code|id> | Approve a pairing code or pending request |
mercury telegram reject <id> | Reject a pending Telegram access request |
mercury telegram remove <id> | Remove an approved Telegram user |
mercury telegram promote <id> | Promote a Telegram member to admin |
mercury telegram demote <id> | Demote a Telegram admin to member |
mercury telegram reset | Clear all Telegram access and start fresh |
mercury service install | Install as system service (auto-start on boot) |
mercury service uninstall | Uninstall system service |
mercury service status | Show system service status |
mercury --verbose | Start with debug logging |
Type these during a conversation — they don't consume API tokens. Work on both CLI and Telegram.
| Command | Description |
|---|---|
/help | Show the full manual |
/status | Show agent config, budget, and usage |
/tools | List all loaded tools |
/skills | List installed skills |
/stream | Toggle Telegram text streaming |
/stream off | Disable streaming (single message) |
/budget | Show token budget status |
/budget override | Override budget for one request |
/budget reset | Reset usage to zero |
/budget set <n> | Change daily token budget |
/permissions | Change permission mode (Ask Me / Allow All) |
/view | Toggle progress view (balanced/detailed) |
/view balanced | Set compact progress view |
/view detailed | Set full progress view |
/code agent <task> | Delegate a coding task to a sub-agent in background |
/ws exit | Exit workspace IDE mode back to general chat |
/tasks | List scheduled tasks |
/memory | View and manage second brain memory |
/unpair | Telegram: reset all access |
| Category | Tools |
|---|---|
| Filesystem | read_file, write_file, create_file, edit_file, list_dir, delete_file, send_file, approve_scope |
| Shell | run_command, cd, approve_command |
| Messaging | send_message |
| Git | git_status, git_diff, git_log, git_add, git_commit, git_push |
| Web | fetch_url |
| Skills | install_skill, list_skills, use_skill |
| Scheduler | schedule_task, list_scheduled_tasks, cancel_scheduled_task |
| System | budget_status |
Mercury can pull community-contributed skills from the registry at skills.mercuryagent.sh (126+ skills, no auth required).
mercury skills search prompt # search the registry
mercury skills browse ai-ml # browse by category
mercury skills view ai-ml/prompt-engineering # render SKILL.md in the terminal
mercury skills view ai-ml/prompt-engineering --web # open the registry page
mercury skills install ai-ml/prompt-engineering # install to ~/.mercury/skills/
mercury skills list # show installed skills
mercury skills update # refresh all installed skills
mercury skills remove ai-ml/prompt-engineering
mercury skills doctor # check install root + registry
Installed skills land at ~/.mercury/skills/<category>/<slug>/SKILL.md and are
picked up by the agent on the next boot — they're treated identically to
built-in skills.
Review before you ship. Skills are community-contributed and unaudited. Run
mercury skills view <id>before installing.
Overrides: --registry <url> (or MERCURY_SKILLS_REGISTRY) for self-hosted
registries, MERCURY_SKILLS_INSTALL_ROOT for an alternate install path,
--json for machine-readable output.
Also installable from:
http://127.0.0.1:6174/skills has a registry installer (paste category/slug) and a URL installer side by side./skills, /skills search <q>, /skills view <id>, /skills install <id> (admin-only). Every result includes the registry URL so you can review before installing.See the Skills reference for the full command surface, frontmatter spec, and API endpoints.
Mercury includes a built-in web UI at http://127.0.0.1:6174:
mercury doctor # Enable web during setup
Or set in ~/.mercury/mercury.yaml:
web:
enabled: true
port: 6174
Features: Chat with SSE streaming, Kanban boards, Second Brain visualization, Workspace IDE, provider/skill/permission/schedule management, usage tracking, dark/light theme.
Default credentials: mercury / Mercury@123. Binds to localhost only.
Persistent task boards with agent execution. Create boards, add cards, and let Mercury process them autonomously.
Access via Web Dashboard or API (/api/boards/*).
| Channel | Features |
|---|---|
| CLI | Ink TUI, startup permission mode picker, interactive permission prompts (arrow keys + Enter; Y/N/A shortcuts), progress views (balanced/detailed), real-time streaming |
| Web | React SPA dashboard, chat with SSE streaming, Kanban boards, Second Brain visualization, Workspace IDE, dark/light theme |
| Telegram | HTML formatting, editable streaming messages, file uploads, typing indicators, multi-user access with admin/member roles |
Ctrl+P → switch to Plan modeCtrl+X → switch to Execute modeEsc or Ctrl+Q → exit workspace to general chatCtrl+V → toggle progress view (/view is fallback when terminal intercepts Ctrl+V)N next, P previous, +/- volume, Z now playing.MERCURY_SPOTIFY_ART=1Mercury uses an organization access model with admins and members.
/start to your bot, receive a pairing code, enter it in the CLI with mercury telegram approve <code>. You become the first admin./start to request access. Admins approve or reject from the CLI./unpair in Telegram or run mercury telegram reset in the CLI to clear all access and start fresh.CLI commands: mercury telegram list|approve|reject|remove|promote|demote|reset
schedule_task with cron expressions (0 9 * * * for daily at 9am)schedule_task with delay_seconds (e.g. 15 seconds)~/.mercury/schedules.yaml and restore on restartMercury builds a structured, persistent memory that grows with every conversation. Enabled by default, it automatically extracts, stores, and recalls facts about you.
/memory for overview, search, pause, resume, and clearSECOND_BRAIN_ENABLED=false env var or memory.secondBrain.enabled: false in configAll data stays on your machine in ~/.mercury/memory/second-brain/second-brain.db (SQLite + FTS5). No cloud.
All runtime data lives in ~/.mercury/ — not in your project directory.
| Path | Purpose |
|---|---|
~/.mercury/mercury.yaml | Main config (providers, channels, budget) |
~/.mercury/.env | API keys and tokens (loaded alongside project .env) |
~/.mercury/soul/*.md | Agent personality (soul, persona, taste, heartbeat) |
~/.mercury/permissions.yaml | Capabilities and approval rules |
~/.mercury/skills/ | Installed skills |
~/.mercury/schedules.yaml | Scheduled tasks |
~/.mercury/token-usage.json | Daily token usage tracking |
~/.mercury/memory/short-term/ | Per-conversation JSON files |
~/.mercury/memory/long-term/ | Auto-extracted facts (JSONL) |
~/.mercury/memory/episodic/ | Timestamped event log (JSONL) |
~/.mercury/memory/second-brain/ | Structured memory database (SQLite + FTS5) |
~/.mercury/daemon.pid | Background process PID |
~/.mercury/daemon.log | Daemon mode logs |
~/.mercury/boards.db | Kanban boards database (SQLite) |
Configure multiple LLM providers. Mercury tries them in order and falls back automatically:
| Provider | Default Model | API Key | Notes |
|---|---|---|---|
| DeepSeek | deepseek-chat | DEEPSEEK_API_KEY | Default, cost-effective |
| OpenAI | gpt-4o-mini | OPENAI_API_KEY | GPT-4o, o3, etc. |
| Anthropic | claude-sonnet-4 | ANTHROPIC_API_KEY | Claude Sonnet, Haiku, Opus |
| Grok (xAI) | grok-4 | GROK_API_KEY | OpenAI-compatible endpoint |
| Ollama Cloud | gpt-oss:120b | OLLAMA_CLOUD_API_KEY | Remote Ollama via API |
| Ollama Local | gpt-oss:20b | No key needed | Local Ollama instance |
When a provider fails, Mercury automatically tries the next one. It remembers the last successful provider and starts there on the next request.
More providers incoming — Google Gemini, Mistral, and others are on the roadmap. Mercury's OpenAI-compatible architecture also supports custom endpoints via base URL configuration.
generateText + streamText, 10-step agentic loop, provider fallbackYou can build Mercury yourself from source — either the standard Node bundle (for npm link / local development) or a standalone executable that bundles the entire runtime, so end-users don't need Node.js installed at all.
curl -fsSL https://bun.sh/install | bash)git clone https://github.com/cosmicstack-labs/mercury-agent.git
cd mercury-agent
npm install
npm run build # builds dist/ via tsup + post-build (UI, static assets)
npm start # node dist/index.js
Mercury can be compiled into a single self-contained binary using bun build --compile. The resulting file embeds the Bun runtime and the full Mercury bundle.
npm run build:bin # host platform only
npm run build:bin:all # clean release: all 5 targets plus web archive and checksums
npm run build:bin:force # rebuild (overwrite existing binary for the same version)
npm run build:bin:all:force # replace an existing release directory, then rebuild all targets
node scripts/verify-standalone-release.cjs # verify an already-built publishable release
Output is versioned so older builds are never overwritten:
release/
├── latest → symlink to most-recent version
├── v1.1.9/
│ ├── mercury-macos-arm64
│ ├── mercury-macos-x64
│ ├── mercury-linux-x64
│ ├── mercury-linux-arm64
│ ├── mercury-win-x64.exe
│ ├── web.tar.gz
│ └── checksums.txt (SHA-256 for downloadable binaries and web.tar.gz)
├── smoke/v1.2.0/ (host-only local builds; never publish)
└── v1.2.0/ …
The version is read from package.json. Host-only smoke builds are isolated from publishable releases. build:bin:all refuses to reuse a non-empty version directory; use build:bin:all:force to delete and recreate it so assets from different revisions cannot be mixed.
Cross-compilation: Bun produces the JavaScript binaries for every target from a single host. Native addons such as better-sqlite3 still require target-compatible packaging. sql.js is used by a narrow web API fallback; it is not a general substitute for all better-sqlite3-backed features.
macOS Gatekeeper: unsigned binaries trigger a warning on first launch. For distribution, sign with codesign --sign "Developer ID" release/v<version>/mercury-macos-arm64 and notarize.
MIT © Cosmic Stack
This is AI - it can break sometimes, please use this at your own risk.
We're open to contributions! Mercury is built to evolve, and we welcome help from the community. Whether it's fixing a bug, adding a tool, improving memory, or refining the soul — all quality contributions are appreciated.
Mercury isn't just another open-source project — it's a soul-driven agent that runs 24/7, manages permissions, remembers context, and interacts across channels. If you're contributing, you must think like an agent builder, not just a library contributor. These are non-negotiable principles every contributor should internalize:
| Principle | What It Means |
|---|---|
| 🧠 Think in loops | Mercury operates in a 10-step agentic loop. Your tool or feature will be called multiple times per conversation. Make it idempotent where possible. |
| 🔐 Permission-first | Every action that touches the outside world (files, shell, network, git) must go through the permission system. Never assume approval. |
| 💾 Memory-aware | If your feature generates facts about the user, consider hooking into the Second Brain. If it reads user data, check memory first. |
| 📏 Token-conscious | Mercury has a daily token budget. Logging, verbose outputs, and large context dumps burn tokens fast. Keep it lean. |
| 🔌 Channel-agnostic | Tools should work identically on CLI and Telegram. Don't assume a terminal, a keyboard, or even a human on the other end. |
| 🔁 Graceful degradation | If a provider fails, a tool errors, or a file doesn't exist — Mercury should recover, not crash. Always handle edge cases. |
| 📋 Self-documenting | Your tool's name and description are what Mercury reads to decide when to use it. Make them clear, specific, and action-oriented. |
| 🧪 Test the loop, not just the function | A tool that works in isolation may fail in the agentic loop (e.g., returns too much data, blocks the next step). Test end-to-end. |
| Do | Why |
|---|---|
| ✅ Write clean, readable TypeScript with explicit types | Mercury's codebase is type-safe — keep it that way |
| ✅ Add JSDoc comments on public functions and tools | Helps other contributors and the agent understand intent |
| ✅ Keep functions small and single-purpose | Easier to test, review, and reason about |
| ✅ Use async/await over raw promises | Consistent error handling and readability |
| ✅ Write tests for new tools and memory features | Reliability matters for a 24/7 agent |
✅ Follow the existing project structure (src/tools/, src/memory/, src/channels/) | Keeps the codebase navigable |
| ✅ Use the Agent Skills spec for new skill-based features | Ensures compatibility with the skills ecosystem |
| ✅ Document breaking changes in PR descriptions | Helps maintainers version properly |
| Don't | Why |
|---|---|
| ❌ Don't add dependencies without discussion | Mercury is lean — every dep adds surface area |
| ❌ Don't hardcode API keys, tokens, or paths | Use config/env vars like the rest of the codebase |
| ❌ Don't bypass the permission system | Tools must ask before acting — that's Mercury's core promise |
| ❌ Don't introduce sync/blocking I/O in hot paths | Mercury is async-first for a reason |
| ❌ Don't commit large binary files or secrets | Use .gitignore and env files |
| ❌ Don't change the soul/persona system without discussion | It's the heart of Mercury — changes need care |
| ❌ Don't submit untested Telegram or daemon changes | These are hard to debug post-merge |
| ❌ Don't ignore the token budget system | Every tool should be mindful of token consumption |
npm installnpm run build to verify it compilesmercury locallyOpen an issue or reach out at mercury@cosmicstack.org. We're friendly.
TypeScript
88.3%
MDX
8.1%
CSS
1.6%
JavaScript
1.3%
Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI or Telegram.
3,084
stars
253
commits
TypeScript
primary language
Sep 11, 2026
updated
Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access.
Remembers what matters. Asks before it acts. Runs 24/7 from CLI, Telegram, or Web. 31 built-in tools, Kanban boards, extensible skills, SQLite-backed Second Brain memory.
🔖 Current Stable: v1.1.13
English | 简体中文
One-liner install (no Node.js required) — downloads the latest standalone binary for your OS:
# macOS / Linux
curl -fsSL https://mercuryagent.sh/install.sh | sh
# Windows
irm https://mercuryagent.sh/install.ps1 | iex
Or via npm if you already have Node.js 20+:
npx @cosmicstack/mercury-agent
Or install the npm package globally:
npm i -g @cosmicstack/mercury-agent
mercury
First run triggers the setup wizard (name, provider, optional Telegram). After setup, Mercury opens the Ink TUI startup screen and asks for your permission mode (Ask Me or Allow All) before chat starts.
To reconfigure later (change keys, name, settings):
mercury doctor
mercury doctor --platform
Every AI agent can read files, run commands, and fetch URLs. Most do it silently. Mercury asks first — and remembers what matters.
sudo, rm -rf /, etc. never execute). Folder-level read/write scoping. Pending approval flow. Ask Me or Allow All per session. No surprises.soul.md, persona.md, taste.md, heartbeat.md). No corporate wrapper./budget command to check, reset, or override.Mercury now seeds a default web-search skill on first run in ~/.mercury/skills/web-search/SKILL.md.
One command to make Mercury persistent:
mercury up
This installs the system service (if not installed), starts the background daemon, and ensures Mercury is running. Use this as your go-to command.
If Mercury is already running, mercury up just confirms it and shows the PID.
mercury restart # Restart the background process
mercury stop # Stop the background process
mercury start -d # Start in background (without service install)
mercury logs # View recent daemon logs
mercury status # Show if daemon is running
Daemon mode includes built-in crash recovery — if the process crashes, it restarts automatically with exponential backoff (up to 10 restarts per minute).
mercury up installs this automatically. You can also manage it directly:
mercury service install
| Platform | Method | Requires Admin |
|---|---|---|
| macOS | LaunchAgent (~/Library/LaunchAgents/) | No |
| Linux | systemd user unit (~/.config/systemd/user/) | No (linger for boot) |
| Windows | Task Scheduler (schtasks) | No |
mercury service status # Check if service is running
mercury service uninstall # Remove the system service
In daemon mode, Telegram becomes your primary channel — CLI is log-only since there's no terminal for input.
| Command | Description |
|---|---|
mercury up | Recommended. Install service + start daemon + ensure running |
mercury | Start the agent (same as mercury start) |
mercury start | Start in foreground |
mercury start -d | Start in background (daemon mode) |
mercury restart | Restart the background process |
mercury stop | Stop a background process |
mercury logs | View recent daemon logs |
mercury doctor | Reconfigure setup (name, providers, channels, permissions defaults) |
mercury doctor --platform | Show cross-platform terminal/daemon compatibility diagnostics |
mercury setup | Re-run the setup wizard |
mercury status | Show config and daemon status |
mercury help | Show full manual |
mercury upgrade | Upgrade to latest version |
mercury telegram list | List approved and pending Telegram users |
mercury telegram approve <code|id> | Approve a pairing code or pending request |
mercury telegram reject <id> | Reject a pending Telegram access request |
mercury telegram remove <id> | Remove an approved Telegram user |
mercury telegram promote <id> | Promote a Telegram member to admin |
mercury telegram demote <id> | Demote a Telegram admin to member |
mercury telegram reset | Clear all Telegram access and start fresh |
mercury service install | Install as system service (auto-start on boot) |
mercury service uninstall | Uninstall system service |
mercury service status | Show system service status |
mercury --verbose | Start with debug logging |
Type these during a conversation — they don't consume API tokens. Work on both CLI and Telegram.
| Command | Description |
|---|---|
/help | Show the full manual |
/status | Show agent config, budget, and usage |
/tools | List all loaded tools |
/skills | List installed skills |
/stream | Toggle Telegram text streaming |
/stream off | Disable streaming (single message) |
/budget | Show token budget status |
/budget override | Override budget for one request |
/budget reset | Reset usage to zero |
/budget set <n> | Change daily token budget |
/permissions | Change permission mode (Ask Me / Allow All) |
/view | Toggle progress view (balanced/detailed) |
/view balanced | Set compact progress view |
/view detailed | Set full progress view |
/code agent <task> | Delegate a coding task to a sub-agent in background |
/ws exit | Exit workspace IDE mode back to general chat |
/tasks | List scheduled tasks |
/memory | View and manage second brain memory |
/unpair | Telegram: reset all access |
| Category | Tools |
|---|---|
| Filesystem | read_file, write_file, create_file, edit_file, list_dir, delete_file, send_file, approve_scope |
| Shell | run_command, cd, approve_command |
| Messaging | send_message |
| Git | git_status, git_diff, git_log, git_add, git_commit, git_push |
| Web | fetch_url |
| Skills | install_skill, list_skills, use_skill |
| Scheduler | schedule_task, list_scheduled_tasks, cancel_scheduled_task |
| System | budget_status |
Mercury can pull community-contributed skills from the registry at skills.mercuryagent.sh (126+ skills, no auth required).
mercury skills search prompt # search the registry
mercury skills browse ai-ml # browse by category
mercury skills view ai-ml/prompt-engineering # render SKILL.md in the terminal
mercury skills view ai-ml/prompt-engineering --web # open the registry page
mercury skills install ai-ml/prompt-engineering # install to ~/.mercury/skills/
mercury skills list # show installed skills
mercury skills update # refresh all installed skills
mercury skills remove ai-ml/prompt-engineering
mercury skills doctor # check install root + registry
Installed skills land at ~/.mercury/skills/<category>/<slug>/SKILL.md and are
picked up by the agent on the next boot — they're treated identically to
built-in skills.
Review before you ship. Skills are community-contributed and unaudited. Run
mercury skills view <id>before installing.
Overrides: --registry <url> (or MERCURY_SKILLS_REGISTRY) for self-hosted
registries, MERCURY_SKILLS_INSTALL_ROOT for an alternate install path,
--json for machine-readable output.
Also installable from:
http://127.0.0.1:6174/skills has a registry installer (paste category/slug) and a URL installer side by side./skills, /skills search <q>, /skills view <id>, /skills install <id> (admin-only). Every result includes the registry URL so you can review before installing.See the Skills reference for the full command surface, frontmatter spec, and API endpoints.
Mercury includes a built-in web UI at http://127.0.0.1:6174:
mercury doctor # Enable web during setup
Or set in ~/.mercury/mercury.yaml:
web:
enabled: true
port: 6174
Features: Chat with SSE streaming, Kanban boards, Second Brain visualization, Workspace IDE, provider/skill/permission/schedule management, usage tracking, dark/light theme.
Default credentials: mercury / Mercury@123. Binds to localhost only.
Persistent task boards with agent execution. Create boards, add cards, and let Mercury process them autonomously.
Access via Web Dashboard or API (/api/boards/*).
| Channel | Features |
|---|---|
| CLI | Ink TUI, startup permission mode picker, interactive permission prompts (arrow keys + Enter; Y/N/A shortcuts), progress views (balanced/detailed), real-time streaming |
| Web | React SPA dashboard, chat with SSE streaming, Kanban boards, Second Brain visualization, Workspace IDE, dark/light theme |
| Telegram | HTML formatting, editable streaming messages, file uploads, typing indicators, multi-user access with admin/member roles |
Ctrl+P → switch to Plan modeCtrl+X → switch to Execute modeEsc or Ctrl+Q → exit workspace to general chatCtrl+V → toggle progress view (/view is fallback when terminal intercepts Ctrl+V)N next, P previous, +/- volume, Z now playing.MERCURY_SPOTIFY_ART=1Mercury uses an organization access model with admins and members.
/start to your bot, receive a pairing code, enter it in the CLI with mercury telegram approve <code>. You become the first admin./start to request access. Admins approve or reject from the CLI./unpair in Telegram or run mercury telegram reset in the CLI to clear all access and start fresh.CLI commands: mercury telegram list|approve|reject|remove|promote|demote|reset
schedule_task with cron expressions (0 9 * * * for daily at 9am)schedule_task with delay_seconds (e.g. 15 seconds)~/.mercury/schedules.yaml and restore on restartMercury builds a structured, persistent memory that grows with every conversation. Enabled by default, it automatically extracts, stores, and recalls facts about you.
/memory for overview, search, pause, resume, and clearSECOND_BRAIN_ENABLED=false env var or memory.secondBrain.enabled: false in configAll data stays on your machine in ~/.mercury/memory/second-brain/second-brain.db (SQLite + FTS5). No cloud.
All runtime data lives in ~/.mercury/ — not in your project directory.
| Path | Purpose |
|---|---|
~/.mercury/mercury.yaml | Main config (providers, channels, budget) |
~/.mercury/.env | API keys and tokens (loaded alongside project .env) |
~/.mercury/soul/*.md | Agent personality (soul, persona, taste, heartbeat) |
~/.mercury/permissions.yaml | Capabilities and approval rules |
~/.mercury/skills/ | Installed skills |
~/.mercury/schedules.yaml | Scheduled tasks |
~/.mercury/token-usage.json | Daily token usage tracking |
~/.mercury/memory/short-term/ | Per-conversation JSON files |
~/.mercury/memory/long-term/ | Auto-extracted facts (JSONL) |
~/.mercury/memory/episodic/ | Timestamped event log (JSONL) |
~/.mercury/memory/second-brain/ | Structured memory database (SQLite + FTS5) |
~/.mercury/daemon.pid | Background process PID |
~/.mercury/daemon.log | Daemon mode logs |
~/.mercury/boards.db | Kanban boards database (SQLite) |
Configure multiple LLM providers. Mercury tries them in order and falls back automatically:
| Provider | Default Model | API Key | Notes |
|---|---|---|---|
| DeepSeek | deepseek-chat | DEEPSEEK_API_KEY | Default, cost-effective |
| OpenAI | gpt-4o-mini | OPENAI_API_KEY | GPT-4o, o3, etc. |
| Anthropic | claude-sonnet-4 | ANTHROPIC_API_KEY | Claude Sonnet, Haiku, Opus |
| Grok (xAI) | grok-4 | GROK_API_KEY | OpenAI-compatible endpoint |
| Ollama Cloud | gpt-oss:120b | OLLAMA_CLOUD_API_KEY | Remote Ollama via API |
| Ollama Local | gpt-oss:20b | No key needed | Local Ollama instance |
When a provider fails, Mercury automatically tries the next one. It remembers the last successful provider and starts there on the next request.
More providers incoming — Google Gemini, Mistral, and others are on the roadmap. Mercury's OpenAI-compatible architecture also supports custom endpoints via base URL configuration.
generateText + streamText, 10-step agentic loop, provider fallbackYou can build Mercury yourself from source — either the standard Node bundle (for npm link / local development) or a standalone executable that bundles the entire runtime, so end-users don't need Node.js installed at all.
curl -fsSL https://bun.sh/install | bash)git clone https://github.com/cosmicstack-labs/mercury-agent.git
cd mercury-agent
npm install
npm run build # builds dist/ via tsup + post-build (UI, static assets)
npm start # node dist/index.js
Mercury can be compiled into a single self-contained binary using bun build --compile. The resulting file embeds the Bun runtime and the full Mercury bundle.
npm run build:bin # host platform only
npm run build:bin:all # clean release: all 5 targets plus web archive and checksums
npm run build:bin:force # rebuild (overwrite existing binary for the same version)
npm run build:bin:all:force # replace an existing release directory, then rebuild all targets
node scripts/verify-standalone-release.cjs # verify an already-built publishable release
Output is versioned so older builds are never overwritten:
release/
├── latest → symlink to most-recent version
├── v1.1.9/
│ ├── mercury-macos-arm64
│ ├── mercury-macos-x64
│ ├── mercury-linux-x64
│ ├── mercury-linux-arm64
│ ├── mercury-win-x64.exe
│ ├── web.tar.gz
│ └── checksums.txt (SHA-256 for downloadable binaries and web.tar.gz)
├── smoke/v1.2.0/ (host-only local builds; never publish)
└── v1.2.0/ …
The version is read from package.json. Host-only smoke builds are isolated from publishable releases. build:bin:all refuses to reuse a non-empty version directory; use build:bin:all:force to delete and recreate it so assets from different revisions cannot be mixed.
Cross-compilation: Bun produces the JavaScript binaries for every target from a single host. Native addons such as better-sqlite3 still require target-compatible packaging. sql.js is used by a narrow web API fallback; it is not a general substitute for all better-sqlite3-backed features.
macOS Gatekeeper: unsigned binaries trigger a warning on first launch. For distribution, sign with codesign --sign "Developer ID" release/v<version>/mercury-macos-arm64 and notarize.
MIT © Cosmic Stack
This is AI - it can break sometimes, please use this at your own risk.
We're open to contributions! Mercury is built to evolve, and we welcome help from the community. Whether it's fixing a bug, adding a tool, improving memory, or refining the soul — all quality contributions are appreciated.
Mercury isn't just another open-source project — it's a soul-driven agent that runs 24/7, manages permissions, remembers context, and interacts across channels. If you're contributing, you must think like an agent builder, not just a library contributor. These are non-negotiable principles every contributor should internalize:
| Principle | What It Means |
|---|---|
| 🧠 Think in loops | Mercury operates in a 10-step agentic loop. Your tool or feature will be called multiple times per conversation. Make it idempotent where possible. |
| 🔐 Permission-first | Every action that touches the outside world (files, shell, network, git) must go through the permission system. Never assume approval. |
| 💾 Memory-aware | If your feature generates facts about the user, consider hooking into the Second Brain. If it reads user data, check memory first. |
| 📏 Token-conscious | Mercury has a daily token budget. Logging, verbose outputs, and large context dumps burn tokens fast. Keep it lean. |
| 🔌 Channel-agnostic | Tools should work identically on CLI and Telegram. Don't assume a terminal, a keyboard, or even a human on the other end. |
| 🔁 Graceful degradation | If a provider fails, a tool errors, or a file doesn't exist — Mercury should recover, not crash. Always handle edge cases. |
| 📋 Self-documenting | Your tool's name and description are what Mercury reads to decide when to use it. Make them clear, specific, and action-oriented. |
| 🧪 Test the loop, not just the function | A tool that works in isolation may fail in the agentic loop (e.g., returns too much data, blocks the next step). Test end-to-end. |
| Do | Why |
|---|---|
| ✅ Write clean, readable TypeScript with explicit types | Mercury's codebase is type-safe — keep it that way |
| ✅ Add JSDoc comments on public functions and tools | Helps other contributors and the agent understand intent |
| ✅ Keep functions small and single-purpose | Easier to test, review, and reason about |
| ✅ Use async/await over raw promises | Consistent error handling and readability |
| ✅ Write tests for new tools and memory features | Reliability matters for a 24/7 agent |
✅ Follow the existing project structure (src/tools/, src/memory/, src/channels/) | Keeps the codebase navigable |
| ✅ Use the Agent Skills spec for new skill-based features | Ensures compatibility with the skills ecosystem |
| ✅ Document breaking changes in PR descriptions | Helps maintainers version properly |
| Don't | Why |
|---|---|
| ❌ Don't add dependencies without discussion | Mercury is lean — every dep adds surface area |
| ❌ Don't hardcode API keys, tokens, or paths | Use config/env vars like the rest of the codebase |
| ❌ Don't bypass the permission system | Tools must ask before acting — that's Mercury's core promise |
| ❌ Don't introduce sync/blocking I/O in hot paths | Mercury is async-first for a reason |
| ❌ Don't commit large binary files or secrets | Use .gitignore and env files |
| ❌ Don't change the soul/persona system without discussion | It's the heart of Mercury — changes need care |
| ❌ Don't submit untested Telegram or daemon changes | These are hard to debug post-merge |
| ❌ Don't ignore the token budget system | Every tool should be mindful of token consumption |
npm installnpm run build to verify it compilesmercury locallyOpen an issue or reach out at mercury@cosmicstack.org. We're friendly.
TypeScript
88.3%
MDX
8.1%
CSS
1.6%
JavaScript
1.3%