routstrd 0.1.1 → 0.1.4

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/SKILL.md ADDED
@@ -0,0 +1,260 @@
1
+ # routstrd CLI Reference
2
+
3
+ Routstr daemon — a Bun-based CLI tool that runs a background HTTP server for the Routstr protocol. It integrates with `cocod` for Cashu wallet management and routes LLM requests to available providers.
4
+
5
+ ## Quick Start
6
+
7
+ ```sh
8
+ routstrd onboard # Initialize (creates config, sets up cocod)
9
+ routstrd start # Start the daemon
10
+ routstrd stop # Stop the daemon
11
+ ```
12
+
13
+ After onboarding, the daemon listens at `http://localhost:8008` and exposes an OpenAI-compatible API.
14
+
15
+ ## Commands
16
+
17
+ ### `routstrd onboard`
18
+
19
+ Initialize routstrd for the first time:
20
+ - Creates `~/.routstrd/` config directory
21
+ - Creates `~/.routstrd/config.json` with defaults (port 8008, apikeys mode)
22
+ - Installs `cocod` globally via bun if not present
23
+ - Runs `cocod init` to set up the wallet
24
+ - Starts the daemon and configures integrations
25
+
26
+ ### `routstrd start`
27
+
28
+ Start the background daemon process.
29
+
30
+ | Option | Description |
31
+ |--------|-------------|
32
+ | `--port <port>` | Port to listen on (default: 8008) |
33
+ | `-p, --provider <provider>` | Default provider to use |
34
+
35
+ ### `routstrd stop`
36
+
37
+ Stop the background daemon.
38
+
39
+ ### `routstrd restart`
40
+
41
+ Restart the daemon (stops if running, then starts).
42
+
43
+ | Option | Description |
44
+ |--------|-------------|
45
+ | `--port <port>` | Port to listen on |
46
+ | `-p, --provider <provider>` | Default provider to use |
47
+
48
+ ### `routstrd status`
49
+
50
+ Check daemon and wallet status. Returns JSON with current state.
51
+
52
+ ### `routstrd ping`
53
+
54
+ Test connection to the daemon.
55
+
56
+ ### `routstrd balance`
57
+
58
+ Get wallet and API key balances. Shows per-mint wallet balances, per-key API balances, and a grand total (all in sats).
59
+
60
+ ### `routstrd models`
61
+
62
+ List available routstr21 models (discovered via Nostr).
63
+
64
+ | Option | Description |
65
+ |--------|-------------|
66
+ | `-r, --refresh` | Force refresh models from Nostr |
67
+
68
+ ### `routstrd usage`
69
+
70
+ Show recent usage logs and total sats cost.
71
+
72
+ | Option | Default | Description |
73
+ |--------|---------|-------------|
74
+ | `-n, --limit <number>` | 10 | Number of recent entries (max 1000) |
75
+
76
+ Shows timestamp, model, provider, sats cost, token counts, and request ID for each entry.
77
+
78
+ ### `routstrd providers`
79
+
80
+ List and manage providers (subcommand required).
81
+
82
+ #### `routstrd providers list`
83
+
84
+ List all providers with their enabled/disabled status. Shows index, status, and base URL.
85
+
86
+ ```
87
+ Providers (12 total, 2 disabled):
88
+
89
+ [0] enabled https://provider1.example.com
90
+ [1] enabled https://provider2.example.com
91
+ [2] DISABLED https://provider3.example.com
92
+ ```
93
+
94
+ #### `routstrd providers disable <indices...>`
95
+
96
+ Disable providers by their index numbers.
97
+
98
+ ```sh
99
+ routstrd providers disable 0 2 5
100
+ ```
101
+
102
+ #### `routstrd providers enable <indices...>`
103
+
104
+ Enable providers by their index numbers.
105
+
106
+ ```sh
107
+ routstrd providers enable 0 2 5
108
+ ```
109
+
110
+ ### `routstrd clients`
111
+
112
+ List and manage API clients (subcommand required).
113
+
114
+ #### `routstrd clients list`
115
+
116
+ List all registered clients with their ID, name, API key, and creation date.
117
+
118
+ #### `routstrd clients add`
119
+
120
+ Add a new client.
121
+
122
+ | Option | Description |
123
+ |--------|-------------|
124
+ | `-n, --name <name>` | **Required.** Client name |
125
+
126
+ Returns the client ID and API key for use with the OpenAI-compatible API.
127
+
128
+ ### `routstrd mode`
129
+
130
+ Interactive prompt to set the client mode:
131
+ 1. **lazyrefund/apikeys** (default) — Pseudonymous accounts kept with Routstr nodes, refunded after 5 mins if unused.
132
+ 2. **xcashu** (coming soon) — Balances never kept with nodes, all refunded in response.
133
+
134
+ Changing mode restarts the daemon automatically.
135
+
136
+ ### `routstrd monitor`
137
+
138
+ Open an interactive TUI (htop-like) for usage monitoring.
139
+
140
+ ### `routstrd logs`
141
+
142
+ View daemon logs.
143
+
144
+ | Option | Default | Description |
145
+ |--------|---------|-------------|
146
+ | `-f, --follow` | false | Follow log output (like `tail -f`) |
147
+ | `-n, --lines <number>` | 50 | Number of lines to show |
148
+
149
+ Log files are stored at `~/.routstrd/logs/YYYY-MM-DD.log`.
150
+
151
+ ## Wallet Commands
152
+
153
+ ### `routstrd wallet status`
154
+
155
+ Check wallet status.
156
+
157
+ ### `routstrd wallet unlock <passphrase>`
158
+
159
+ Unlock the wallet with a passphrase.
160
+
161
+ ### `routstrd wallet balance`
162
+
163
+ Get wallet balance.
164
+
165
+ ### `routstrd wallet receive cashu <token>`
166
+
167
+ Receive funds via a Cashu token.
168
+
169
+ ### `routstrd wallet receive bolt11 <amount>`
170
+
171
+ Create a Lightning invoice to receive funds. Displays a QR code.
172
+
173
+ | Option | Description |
174
+ |--------|-------------|
175
+ | `--mint-url <url>` | Mint URL to use |
176
+
177
+ ### `routstrd wallet send cashu <amount>`
178
+
179
+ Create a Cashu token to send.
180
+
181
+ | Option | Description |
182
+ |--------|-------------|
183
+ | `--mint-url <url>` | Mint URL to use |
184
+
185
+ ### `routstrd wallet send bolt11 <invoice>`
186
+
187
+ Pay a Lightning invoice.
188
+
189
+ | Option | Description |
190
+ |--------|-------------|
191
+ | `--mint-url <url>` | Mint URL to use |
192
+
193
+ ### `routstrd wallet mints list`
194
+
195
+ List configured wallet mints.
196
+
197
+ ### `routstrd wallet mints add <url>`
198
+
199
+ Add a new mint by URL.
200
+
201
+ ### `routstrd wallet mints info <url>`
202
+
203
+ Get info about a specific mint.
204
+
205
+ ## Daemon API
206
+
207
+ The daemon exposes an OpenAI-compatible HTTP API at `http://localhost:8008`:
208
+
209
+ ### `GET /health`
210
+
211
+ Health check endpoint.
212
+
213
+ ### `GET /v1/models`
214
+
215
+ List available models (OpenAI-compatible).
216
+
217
+ ### `POST /v1/chat/completions`
218
+
219
+ Route a chat completion request.
220
+
221
+ ```json
222
+ {
223
+ "model": "model-id",
224
+ "messages": [{ "role": "user", "content": "Hello" }],
225
+ "stream": false
226
+ }
227
+ ```
228
+
229
+ ## Configuration
230
+
231
+ Config file: `~/.routstrd/config.json`
232
+
233
+ | Field | Type | Default | Description |
234
+ |-------|------|---------|-------------|
235
+ | `port` | number | 8008 | Daemon HTTP port |
236
+ | `provider` | string\|null | null | Default provider URL |
237
+ | `cocodPath` | string\|null | null | Custom path to cocod executable |
238
+ | `mode` | string | `"apikeys"` | Client mode (`apikeys` or `xcashu`) |
239
+
240
+ ### Environment Variables
241
+
242
+ | Variable | Default | Description |
243
+ |----------|---------|-------------|
244
+ | `ROUTSTRD_DIR` | `~/.routstrd` | Config directory |
245
+ | `ROUTSTRD_SOCKET` | `~/.routstrd/routstrd.sock` | IPC socket path |
246
+ | `ROUTSTRD_PID` | `~/.routstrd/routstrd.pid` | PID file path |
247
+
248
+ ## Pi Integration
249
+
250
+ When `routstrd onboard` runs, it automatically configures a `routstr` provider in `pi`'s `models.json` with an OpenAI-compatible base URL and API key. This allows pi (the AI coding agent) to use Routstr providers seamlessly.
251
+
252
+ ## File Locations
253
+
254
+ | Path | Description |
255
+ |------|-------------|
256
+ | `~/.routstrd/config.json` | Configuration |
257
+ | `~/.routstrd/routstr.db` | SQLite database |
258
+ | `~/.routstrd/routstrd.sock` | IPC socket |
259
+ | `~/.routstrd/routstrd.pid` | PID file |
260
+ | `~/.routstrd/logs/YYYY-MM-DD.log` | Daily log files |