@cosmicstack/mercury-agent 0.1.0 → 0.2.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 CHANGED
@@ -1,12 +1,6 @@
1
- <h1 align="center">
2
- <pre>
3
- __ _____________ ________ ________ __
4
- / |/ / ____/ __ \/ ____/ / / / __ \ \/ /
5
- / /|_/ / __/ / /_/ / / / / / / /_/ /\ /
6
- / / / / /___/ _, _/ /___/ /_/ / _, _/ / /
7
- /_/ /_/_____/_/ |_|\____/\____/_/ |_| /_/
8
- </pre>
9
- </h1>
1
+ <p align="center">
2
+ <img src="docs/card.png" alt="Mercury — Soul-Driven AI Agent" width="600">
3
+ </p>
10
4
 
11
5
  <p align="center">
12
6
  <strong>Soul-driven AI agent with permission-hardened tools, token budgets, and multi-channel access.</strong>
@@ -39,6 +33,12 @@ mercury
39
33
 
40
34
  First run triggers the setup wizard — enter your name, an API key, and optionally a Telegram bot token. Takes 30 seconds.
41
35
 
36
+ To reconfigure later (change keys, name, settings):
37
+
38
+ ```bash
39
+ mercury doctor
40
+ ```
41
+
42
42
  ## Why Mercury?
43
43
 
44
44
  Every AI agent can read files, run commands, and fetch URLs. Most do it silently. **Mercury asks first.**
@@ -47,9 +47,91 @@ Every AI agent can read files, run commands, and fetch URLs. Most do it silently
47
47
  - **Soul-driven** — Personality defined by markdown files you own (`soul.md`, `persona.md`, `taste.md`, `heartbeat.md`). No corporate wrapper.
48
48
  - **Token-aware** — Daily budget enforcement. Auto-concise when over 70%. `/budget` command to check, reset, or override.
49
49
  - **Multi-channel** — CLI with real-time streaming. Telegram with HTML formatting, file uploads, and typing indicators.
50
- - **Always on** — Cron scheduling, delayed reminders, heartbeat monitoring, and proactive notifications.
50
+ - **Always on** — Run as a background daemon on any OS. Auto-restarts on crash. Starts on boot. Cron scheduling, heartbeat monitoring, and proactive notifications.
51
51
  - **Extensible** — Install community skills with a single command. Schedule skills as recurring tasks. Based on the [Agent Skills](https://agentskills.io) specification.
52
52
 
53
+ ## Daemon Mode
54
+
55
+ **One command to make Mercury persistent:**
56
+
57
+ ```bash
58
+ mercury up
59
+ ```
60
+
61
+ This installs the system service (if not installed), starts the background daemon, and ensures Mercury is running. Use this as your go-to command.
62
+
63
+ If Mercury is already running, `mercury up` just confirms it and shows the PID.
64
+
65
+ ### Other daemon commands
66
+
67
+ ```bash
68
+ mercury restart # Restart the background process
69
+ mercury stop # Stop the background process
70
+ mercury start -d # Start in background (without service install)
71
+ mercury logs # View recent daemon logs
72
+ mercury status # Show if daemon is running
73
+ ```
74
+
75
+ Daemon mode includes built-in crash recovery — if the process crashes, it restarts automatically with exponential backoff (up to 10 restarts per minute).
76
+
77
+ ### System Service (auto-start on boot)
78
+
79
+ `mercury up` installs this automatically. You can also manage it directly:
80
+
81
+ ```bash
82
+ mercury service install
83
+ ```
84
+
85
+ | Platform | Method | Requires Admin |
86
+ |----------|--------|---------------|
87
+ | **macOS** | LaunchAgent (`~/Library/LaunchAgents/`) | No |
88
+ | **Linux** | systemd user unit (`~/.config/systemd/user/`) | No (linger for boot) |
89
+ | **Windows** | Task Scheduler (`schtasks`) | No |
90
+
91
+ ```bash
92
+ mercury service status # Check if service is running
93
+ mercury service uninstall # Remove the system service
94
+ ```
95
+
96
+ In daemon mode, Telegram becomes your primary channel — CLI is log-only since there's no terminal for input.
97
+
98
+ ## CLI Commands
99
+
100
+ | Command | Description |
101
+ |---------|-------------|
102
+ | `mercury up` | **Recommended.** Install service + start daemon + ensure running |
103
+ | `mercury` | Start the agent (same as `mercury start`) |
104
+ | `mercury start` | Start in foreground |
105
+ | `mercury start -d` | Start in background (daemon mode) |
106
+ | `mercury restart` | Restart the background process |
107
+ | `mercury stop` | Stop a background process |
108
+ | `mercury logs` | View recent daemon logs |
109
+ | `mercury doctor` | Reconfigure (Enter to keep current values) |
110
+ | `mercury setup` | Re-run the setup wizard |
111
+ | `mercury status` | Show config and daemon status |
112
+ | `mercury help` | Show full manual |
113
+ | `mercury service install` | Install as system service (auto-start on boot) |
114
+ | `mercury service uninstall` | Uninstall system service |
115
+ | `mercury service status` | Show system service status |
116
+ | `mercury --verbose` | Start with debug logging |
117
+
118
+ ## In-Chat Commands
119
+
120
+ Type these during a conversation — they don't consume API tokens. Work on both CLI and Telegram.
121
+
122
+ | Command | Description |
123
+ |---------|-------------|
124
+ | `/help` | Show the full manual |
125
+ | `/status` | Show agent config, budget, and usage |
126
+ | `/tools` | List all loaded tools |
127
+ | `/skills` | List installed skills |
128
+ | `/stream` | Toggle Telegram text streaming |
129
+ | `/stream off` | Disable streaming (single message) |
130
+ | `/budget` | Show token budget status |
131
+ | `/budget override` | Override budget for one request |
132
+ | `/budget reset` | Reset usage to zero |
133
+ | `/budget set <n>` | Change daily token budget |
134
+
53
135
  ## Built-in Tools
54
136
 
55
137
  | Category | Tools |
@@ -89,6 +171,8 @@ All runtime data lives in `~/.mercury/` — not in your project directory.
89
171
  | `~/.mercury/schedules.yaml` | Scheduled tasks |
90
172
  | `~/.mercury/token-usage.json` | Daily token usage tracking |
91
173
  | `~/.mercury/memory/` | Short-term, long-term, episodic memory |
174
+ | `~/.mercury/daemon.pid` | Background process PID |
175
+ | `~/.mercury/daemon.log` | Daemon mode logs |
92
176
 
93
177
  ## Provider Fallback
94
178
 
@@ -104,7 +188,21 @@ Configure multiple LLM providers. Mercury tries them in order and falls back aut
104
188
  - **Vercel AI SDK v4** — `generateText` + `streamText`, 10-step agentic loop, provider fallback
105
189
  - **grammY** — Telegram bot with typing indicators and file uploads
106
190
  - **Flat-file persistence** — No database. YAML + JSON in `~/.mercury/`
191
+ - **Daemon manager** — Background spawn + PID file + watchdog crash recovery
192
+ - **System services** — macOS LaunchAgent, Linux systemd, Windows Task Scheduler
107
193
 
108
194
  ## License
109
195
 
110
- MIT © [Cosmic Stack](https://github.com/cosmicstack-labs)
196
+ MIT © [Cosmic Stack](https://github.com/cosmicstack-labs)
197
+
198
+ ---
199
+
200
+ ## Disclaimer
201
+
202
+ **This is AI - it can break sometimes, please use this at your own risk.**
203
+
204
+ ---
205
+
206
+ ## Suggestions and Contributions
207
+
208
+ For suggestions, contributions, or any inquiries, please reach out to us at [support@cosmicstack.org](mailto:support@cosmicstack.org).