
cosmicstack-labs/mercury-agent
Developer toolsSoul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access. Runs 24/7 from CLI or Telegram.
Overview
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. — downloads the latest standalone binary for your OS: Or via npm if you already have Node.js 20+: 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): Every AI agent can read files, run commands, and fetch URLs. Most do it silently. - — Shell blocklist (sudo, rm -rf /, etc. never execute). Folder-level read/write scoping. Pending approval flow. Ask Me or Allow All per session. No surprises. - — Persistent, structured memory with SQLite + FTS5 full-text search.
README
The soul-driven AI agent that lives on your machine.It asks before it acts, remembers what matters, and keeps working when you walk away.
Website · Docs · Quickstart · Changelog · Discord · 简体中文
Most AI agents forget you by morning, run whatever the model decides, and stop the moment you close the laptop. Mercury doesn’t.
Mercury is an open-source agent with a personality you write yourself, a memory that stays on your disk, and a permission system that sits between the model and your machine. Message it from your terminal, Telegram, Discord, Slack or Signal and you reach the same agent, with the same memory, running as one background process you own.
It reads and writes your files, runs commands, ships code through git and GitHub, researches the web and keeps a schedule. Every one of those actions is checked against rules you set, and every turn stays inside a daily token budget.
Then it goes further:
- Mercury Code turns it into a careful pair programmer inside your repository, one that only says “done” after the tests pass.
- Mercury Bots gives it a team. Persistent specialists research, write and ship on their own schedule, then drop finished files in a folder you can open, or straight into your Telegram chat.
Install it in one line. Talk to it from anywhere. It is still there tomorrow, and it still remembers.
At a glance
| Install | One-line installer with no Node.js required, or npm i -g @cosmicstack/mercury-agent on Node.js 22+ |
| Runs on | macOS, Linux, Windows, and Android via Termux |
| Talk to it from | Terminal UI, Telegram, Discord, Slack, Signal, and a local web dashboard |
| Models | DeepSeek, OpenAI, Anthropic, Grok, Ollama (cloud and local), LM Studio, any OpenAI-compatible endpoint, Mercury Cloud, and more, with automatic fallback |
| Safety | Shell blocklist, per-folder read/write scopes, approval prompts, SSRF-guarded fetches, secret redaction in logs |
| Memory | Second Brain: typed, deduplicated facts in SQLite with full-text search, all on your disk |
| Tools | About 50 built in (files, shell, git, GitHub, web, scheduler, memory, sub-agents) plus installable skills |
| Always on | Background daemon with crash recovery and a login service on every OS |
| License | MIT |
Why Mercury
Most agents can read files, run commands and fetch pages. The differences are in what happens around those actions, and that is where Mercury puts its effort.
It asks before it acts. File access is scoped per folder, shell commands pass through a blocklist and an approval step, and outbound requests are checked against private address ranges. You choose per session whether Mercury asks every time or runs freely, and members of a shared Telegram or Discord channel cannot widen their own access.
It remembers you without being told to. After each conversation Mercury extracts a few durable facts (preferences, goals, projects, decisions) with confidence scores, resolves conflicts with what it already knows, and recalls the relevant ones before the next answer. Everything lives in a SQLite file under ~/.mercury, and /memory lets you inspect, pause or clear it.
It respects a budget. A daily token budget is enforced on every turn. When usage climbs, Token Saver mode trims context and can route routine work to a cheaper model. /budget shows where you stand.
It is one runtime, not a collection of scripts. A single background process owns your channels, your bots and the web dashboard. Running mercury in a terminal attaches to that process instantly, so closing the terminal never stops a running task or a bot.
It writes code like a careful engineer. Mercury Code plans and builds in one flow, shows a live checklist, asks once before large changes, and only reports success after a build, test or typecheck actually passes.
It works while you are away. Mercury Bots are persistent specialists with their own persona, model, memory, permissions and daily budget. They run on schedules, hand work to each other, and deliver finished files to ~/Documents/Mercury//. You can manage the whole fleet from Telegram with buttons.
You own the personality. Mercury’s character is defined by plain Markdown files (soul.md, persona.md, taste.md, heartbeat.md) that you can edit.
Quickstart
1. Install. The installer downloads a standalone binary for your OS and CPU and verifies its checksum. No Node.js needed.
# macOS / Linux
curl -fsSL https://mercuryagent.sh/install.sh | sh
# Windows (PowerShell)
irm https://mercuryagent.sh/install.ps1 | iex
Prefer npm? Mercury needs Node.js 22 or newer on that path.
npm i -g @cosmicstack/mercury-agent
2. Run it.
mercury
The first run starts a short setup wizard: your name, the agent’s name, Mercury Cloud or your own API keys, and optional channels such as Telegram. Mercury then starts its background service and opens the terminal UI.
3. Use it every day.
mercury # open a chat (attaches to the running Mercury)
mercury code . # open Mercury Code in the current repository
mercury doctor # change providers, keys or channels; applies immediately
mercury status # see what is running
Upgrades are one command: mercury upgrade. It does nothing if you are already on the latest version.
How it works
flowchart LR
subgraph You
T[Terminal UI]
TG[Telegram]
DC[Discord / Slack / Signal]
W[Web dashboard]
end
subgraph Runtime["Mercury runtime (one background process)"]
A[Agent loop]
P[Permissions]
M[(Second BrainSQLite)]
B[Mercury Bots]
S[Scheduler]
end
LLM[LLM providerswith fallback]
T -- attach --> A
TG --> A
DC --> A
W --> A
A --> P
A M
A --> LLM
B --> LLM
S --> A
S --> B
The runtime runs as a login service (LaunchAgent on macOS, systemd on Linux, Task Scheduler on Windows) and restarts itself after a crash. Every channel talks to the same agent, the same permissions and the same memory. The terminal is a client: mercury attaches to the runtime, and mercury code opens a coding session beside it.
Features
Channels
| Channel | Access model | Highlights |
|---|---|---|
| Terminal | Single user | Full-screen UI with live streaming, a command picker (/menu), approval prompts, background tasks |
| Telegram | Admins and members, pairing codes | Streaming replies, file delivery, inline buttons for approvals and bot control |
| Discord | Admin role, guild and channel scoping | Slash commands, streaming edits, DMs and channels |
| Slack | Admins and members | Socket Mode (no public endpoint), streaming edits, /mercury command |
| Signal | Pairing codes | End-to-end encrypted through signal-cli, groups and DMs |
| Web | Local login | Chat, Kanban, bots cockpit, memory explorer, providers and skills |
When more than one channel is configured, notifications go to the first available one in order: Signal, Telegram, Discord, Slack, terminal.
Mercury Code
A full-screen coding environment that works inside a repository.
mercury code [dir] # from the shell
/code # from a running chat
- AUTO mode: plans and builds in one pass, and asks once before large or risky changes.
- Verified completion: a task ends as done only when a build, test or typecheck ran and passed. Otherwise it stops and names the blocker.
- Live plan: every step is shown as pending, active or done.
- Background work:
/code agenthands a task to a sub-agent while you keep working. - Workspace view:
/wsto browse, stage, commit and undo;/code difffor a colored diff.
Mercury Bots
Persistent specialist agents that run next to the main agent without blocking it.
- Onboard with
/bots createfrom the terminal, Telegram or the web dashboard: persona, permission tier, solo or fleet, daily budget. - Fleets: a lead bot delegates typed tasks to its crew, runs pipelines defined in
bot.yaml, and gets one summary when the work is done. - Deliverables: finished files land in
~/Documents/Mercury//, with work in progress underwork/. On Telegram, results arrive as attached files. - Governed: per-turn limits, a daily token budget per bot and per fleet, outcomes judged from what the bot actually did, routines that cool down instead of burning tokens.
- Operate:
/botsroster with Stop, Start and Run buttons on Telegram;/bots cost,/bots show,/bots doctor,/bots stop all.
Design notes: BOTS-ARCHITECTURE.md.
Second Brain
- 10 memory types: identity, preference, goal, project, habit, decision, constraint, relationship, episode, reflection.
- Automatic extraction of up to three facts per conversation, with confidence, importance and durability scores.
- Recall of the most relevant memories before each answer, within a fixed budget.
- Consolidation every hour into a profile and an active-state summary; stale and low-confidence facts age out.
- Local only:
~/.mercury/memory/second-brain/second-brain.db(SQLite with FTS5). Turn it off withmemory.secondBrain.enabled: false.
Permissions and safety
- Shell: a blocklist that cannot be overridden (
sudo,rm -rf /and its variants), plus approval for everything outside your allowed scopes. - Files: read and write scopes per folder, per channel and per role.
- Network:
fetch_urlblocks private address ranges and caps response sizes. - Modes: Ask Me or Allow All per session, changeable with
/permissions. - Secrets: API keys live in
~/.mercury/.env, logs redact them, and the dashboard password is random on first run.
Report a vulnerability through SECURITY.md.
Skills
Install community skills from skills.mercuryagent.sh, based on the Agent Skills specification.
mercury skills search prompt
mercury skills view ai-ml/prompt-engineering # read it before installing
mercury skills install ai-ml/prompt-engineering
Skills are community contributed and not audited, so review them first. They can also be installed from the web dashboard or, by admins, from Telegram.
Web dashboard, Kanban and scheduler
- Dashboard at
http://127.0.0.1:6174, bound to localhost: chat, bots cockpit, memory explorer, providers, skills, permissions, schedules and usage. - Kanban boards that Mercury works through card by card, in dependency order, with per-card token tracking.
- Scheduler: cron schedules and one-shot delays through
schedule_task. Results go back to the channel that created them.
Providers
Mercury tries your default provider first and falls back to the others if it fails. A provider whose key is rejected is skipped until you fix the key, and mercury doctor warns about keys that cannot be valid.
Reference
Build from source
Requirements: Node.js 22+, and Bun 1.3+ only if you want standalone binaries.
git clone https://github.com/cosmicstack-labs/mercury-agent.git
cd mercury-agent
npm install
npm run build # dist/ plus the web UI
npm test # vitest
node dist/index.js # run your build
Standalone binaries:
npm run build:bin # this machine only (release/smoke/)
npm run build:bin:all # all targets: macOS arm64/x64, Linux x64/arm64 (+ no-AVX2 build), Windows x64 (+ no-AVX2 build)
Release binaries are unsigned. On macOS, sign with codesign and notarize before distributing your own builds.
Documentation
| Resource | |
|---|---|
| mercuryagent.sh/docs | Guides, platform setup, channel setup, reference |
| ARCHITECTURE.md | How the runtime is put together |
| BOTS-ARCHITECTURE.md | Bots, fleets and their governance |
| DECISIONS.md | Architecture decision records |
| CHANGELOG.md | Every release |
| SECURITY.md | Reporting vulnerabilities |
Contributing
Contributions are welcome, from bug reports to new tools. Mercury is an agent that runs unattended for days, so a few principles matter more here than in a typical library:
- Every external action goes through permissions. Files, shell, network and git never bypass the permission system or the SSRF guard.
- Assume no human and no terminal. Tools must behave the same on every channel.
- Spend tokens carefully. Keep tool output small; it ends up in the model’s context.
- Fail soft. A provider outage or a missing file should produce an honest message, not a crash.
- Test the loop, not only the function. A tool that works alone can still stall a multi-step turn.
Getting started:
- Fork and clone the repository, then
npm install. - Make your change with tests next to it.
- Run
npm run lint,npm run typecheckandnpm test. - Open a pull request that explains what changed and why, one change per PR.
Questions are welcome on Discord or at [email protected].
Community
- Discord: discord.gg/5emMpMJy5J for help, ideas and show-and-tell.
- Issues: GitHub Issues for bugs and feature requests.
License
Mercury is an AI agent and can make mistakes. Review what it does, especially in Allow All mode.
Recommended Tools
Try a different keyword or remove a filter.
Install
npx skillfish add cosmicstack-labs/mercury-agent