routstrd 0.4.10 → 0.4.12
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 +55 -15
- package/SECURITY.md +0 -1
- package/SKILL.md +267 -52
- package/dist/daemon/index.js +93747 -70861
- package/dist/index.js +65958 -42561
- package/package.json +3 -2
- package/src/cli.ts +358 -23
- package/src/daemon/http/index.ts +323 -38
- package/src/daemon/http/request-body.ts +67 -0
- package/src/daemon/http/request-path.ts +39 -0
- package/src/daemon/index.ts +1 -1
- package/src/daemon/models.ts +46 -11
- package/src/daemon/wallet/auto-refill.ts +20 -8
- package/src/daemon/wallet/cleanup.ts +16 -2
- package/src/daemon/wallet/coco-client.ts +941 -115
- package/src/daemon/wallet/index.ts +168 -50
- package/src/daemon/wallet/mint-quote-recovery.ts +119 -0
- package/src/daemon/wallet/recovery-probe.ts +312 -0
- package/src/daemon/wallet/recovery-work.ts +45 -0
- package/src/daemon/wallet/testing/fake-mint.ts +347 -0
- package/src/daemon/wallet/trusted-mints.ts +87 -0
- package/src/daemon/wallet/wallet-client.ts +206 -0
- package/src/integrations/pi.ts +189 -34
- package/src/integrations/registry.ts +14 -0
- package/src/tui/usage/render.ts +161 -22
- package/src/utils/config.ts +3 -2
- package/src/utils/cooldowns.ts +134 -0
- package/src/utils/daemon-client.ts +53 -9
- package/src/utils/history.ts +9 -0
- package/src/utils/with-timeout.ts +21 -0
- package/src/TUI refactor.md +0 -113
- package/src/daemon/wallet/cocod-client.ts +0 -505
package/README.md
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
# routstrd
|
|
2
2
|
|
|
3
|
-
Routstr daemon - A CLI tool for managing routstr processes,
|
|
3
|
+
Routstr daemon - A CLI tool for managing routstr processes, with a built-in Cashu wallet.
|
|
4
4
|
|
|
5
5
|
## Overview
|
|
6
6
|
|
|
7
|
-
routstrd is a Bun-based CLI tool that provides a background daemon for the Routstr protocol. It
|
|
7
|
+
routstrd is a Bun-based CLI tool that provides a background daemon for the Routstr protocol. It carries an in-process Cashu wallet (coco) for payments and uses the Routstr SDK to handle provider routing and model discovery.
|
|
8
8
|
|
|
9
9
|
## Routstr for Teams
|
|
10
10
|
|
|
@@ -13,7 +13,7 @@ For team-based routing, see [routstrd-auth](https://github.com/Routstr/routstrd-
|
|
|
13
13
|
## Features
|
|
14
14
|
|
|
15
15
|
- **Daemon Mode**: Run routstrd as a background HTTP server
|
|
16
|
-
- **Wallet Integration**:
|
|
16
|
+
- **Wallet Integration**: In-process Cashu wallet, with Lightning, NWC, and NPC support
|
|
17
17
|
- **Provider Routing**: Automatically discovers and routes requests to available providers
|
|
18
18
|
- **Config Management**: Stores configuration in `~/.routstrd/`
|
|
19
19
|
|
|
@@ -102,6 +102,9 @@ routstrd clients add --claude-code # or --pi-agent / --opencode
|
|
|
102
102
|
> **Tip:** You can also install the [routstrd skill](https://github.com/Routstr/routstrd/blob/main/SKILL.md) so the agent can manage routstrd for you.
|
|
103
103
|
|
|
104
104
|
## More Commands
|
|
105
|
+
|
|
106
|
+
[`SKILL.md`](SKILL.md) is the complete per-command reference — every command,
|
|
107
|
+
subcommand, and flag. The sections below cover the common ones.
|
|
105
108
|
### Start Daemon
|
|
106
109
|
|
|
107
110
|
Start the background daemon:
|
|
@@ -160,6 +163,12 @@ Stop the daemon:
|
|
|
160
163
|
routstrd stop
|
|
161
164
|
```
|
|
162
165
|
|
|
166
|
+
See which providers/models the router is currently skipping (cooldowns):
|
|
167
|
+
```sh
|
|
168
|
+
routstrd cooldowns
|
|
169
|
+
routstrd cooldowns --json
|
|
170
|
+
```
|
|
171
|
+
|
|
163
172
|
### NPC (Lightning Address)
|
|
164
173
|
|
|
165
174
|
The in-process wallet registers the NPC (npubx.cash) plugin, which gives the
|
|
@@ -191,6 +200,16 @@ The daemon exposes an HTTP server (default port 8008) with the following endpoin
|
|
|
191
200
|
GET /health
|
|
192
201
|
```
|
|
193
202
|
|
|
203
|
+
#### Cooldowns
|
|
204
|
+
```
|
|
205
|
+
GET /cooldowns
|
|
206
|
+
```
|
|
207
|
+
|
|
208
|
+
Providers and models the router is currently skipping. Each entry reports its
|
|
209
|
+
scope (`provider` blocks every model on that provider, `model` blocks one),
|
|
210
|
+
when the cooldown started, and when it lifts. Expired entries are filtered out,
|
|
211
|
+
and the cooldown window comes from the SDK (`cooldownDurationMs`).
|
|
212
|
+
|
|
194
213
|
#### Automatic Refresh Settings
|
|
195
214
|
```
|
|
196
215
|
POST /settings/auto-refresh
|
|
@@ -207,9 +226,13 @@ daemon restart is required.
|
|
|
207
226
|
|
|
208
227
|
#### Route Request
|
|
209
228
|
```
|
|
210
|
-
POST /
|
|
229
|
+
POST /v1/chat/completions
|
|
211
230
|
```
|
|
212
231
|
|
|
232
|
+
Any unmatched `POST` path is proxied to the selected provider with the incoming
|
|
233
|
+
path preserved, so `POST /v1/messages` (Anthropic Messages API) and
|
|
234
|
+
`POST /v1/responses` (OpenAI Responses API) work in their own formats too.
|
|
235
|
+
|
|
213
236
|
Request body:
|
|
214
237
|
```json
|
|
215
238
|
{
|
|
@@ -252,7 +275,7 @@ Configuration is stored in `~/.routstrd/config.json`:
|
|
|
252
275
|
"port": 8008,
|
|
253
276
|
"host": "127.0.0.1",
|
|
254
277
|
"provider": null,
|
|
255
|
-
"
|
|
278
|
+
"autoModelPath": false,
|
|
256
279
|
"autoRefresh": { "enabled": true }
|
|
257
280
|
}
|
|
258
281
|
```
|
|
@@ -264,11 +287,18 @@ every 21 minutes. Set it to `false` (or run
|
|
|
264
287
|
refresh manually with `routstrd clients --manual-refresh`. `autoRefresh.intervalMs`
|
|
265
288
|
overrides the 21-minute interval.
|
|
266
289
|
|
|
290
|
+
`autoModelPath` defaults to `false`. Set it to `true` to let the SDK automatically
|
|
291
|
+
choose and pin an advertised model path for `deepseek-v4.1-flash` requests.
|
|
292
|
+
Explicit `x-routstr-model-path` request headers work independently of this
|
|
293
|
+
setting and take precedence. Restart the daemon after changing `autoModelPath`.
|
|
294
|
+
|
|
267
295
|
### Environment Variables
|
|
268
296
|
|
|
269
297
|
- `ROUTSTRD_DIR` - Config directory (default: `~/.routstrd`)
|
|
270
298
|
- `ROUTSTRD_SOCKET` - Socket path (default: `~/.routstrd/routstrd.sock`)
|
|
271
299
|
- `ROUTSTRD_PID` - PID file path (default: `~/.routstrd/routstrd.pid`)
|
|
300
|
+
- `ROUTSTRD_WALLET_DIR` - Wallet data directory (default: `~/.routstrd/wallet`)
|
|
301
|
+
- `COCOD_DIR` - Legacy external cocod directory, used only for migration and exclusion (default: `~/.cocod`)
|
|
272
302
|
|
|
273
303
|
## Development
|
|
274
304
|
|
|
@@ -277,16 +307,21 @@ Install dependencies:
|
|
|
277
307
|
bun install
|
|
278
308
|
```
|
|
279
309
|
|
|
280
|
-
Run CLI:
|
|
310
|
+
Run the CLI from source:
|
|
281
311
|
```sh
|
|
282
|
-
bun
|
|
312
|
+
bun src/index.ts <command>
|
|
283
313
|
```
|
|
284
314
|
|
|
285
|
-
Run daemon:
|
|
315
|
+
Run the daemon:
|
|
286
316
|
```sh
|
|
287
317
|
bun run start
|
|
288
318
|
```
|
|
289
319
|
|
|
320
|
+
Run the tests:
|
|
321
|
+
```sh
|
|
322
|
+
bun test
|
|
323
|
+
```
|
|
324
|
+
|
|
290
325
|
Build a standalone executable for the current platform:
|
|
291
326
|
|
|
292
327
|
```sh
|
|
@@ -326,7 +361,7 @@ more current model IDs to the smoke script:
|
|
|
326
361
|
|
|
327
362
|
```sh
|
|
328
363
|
routstrd clients add --name smoke-test
|
|
329
|
-
ROUTSTRD_API_KEY=<api-key>
|
|
364
|
+
ROUTSTRD_API_KEY=<api-key> bun run smoke <model> [model ...]
|
|
330
365
|
```
|
|
331
366
|
|
|
332
367
|
Set `ROUTSTRD_BASE_URL` to test a daemon at a different address. The script
|
|
@@ -356,12 +391,17 @@ not part of `bun test`.
|
|
|
356
391
|
```
|
|
357
392
|
routstrd/
|
|
358
393
|
├── src/
|
|
359
|
-
│ ├── index.ts
|
|
360
|
-
│ ├── cli.ts
|
|
361
|
-
│ ├──
|
|
362
|
-
│ ├── daemon.ts
|
|
363
|
-
│
|
|
364
|
-
│
|
|
394
|
+
│ ├── index.ts # CLI entry point with shebang
|
|
395
|
+
│ ├── cli.ts # Commander CLI commands
|
|
396
|
+
│ ├── daemon.ts # Compatibility daemon entrypoint (legacy PM2 registrations)
|
|
397
|
+
│ ├── start-daemon.ts # Daemon process launcher
|
|
398
|
+
│ ├── daemon/ # HTTP server, wallet, provider routing
|
|
399
|
+
│ ├── integrations/ # Client integrations (Claude Code, pi, OpenCode, ...)
|
|
400
|
+
│ ├── tui/ # Interactive usage monitor (`routstrd monitor`)
|
|
401
|
+
│ └── utils/ # Config, paths, daemon client, update checker
|
|
402
|
+
├── tests/ # Integration tests (unit tests sit beside their source)
|
|
403
|
+
├── scripts/smoke/ # Manual end-to-end smoke test
|
|
404
|
+
├── docs/plans/ # Design/migration plans not yet executed
|
|
365
405
|
├── package.json
|
|
366
406
|
└── tsconfig.json
|
|
367
407
|
```
|
package/SECURITY.md
CHANGED
package/SKILL.md
CHANGED
|
@@ -1,27 +1,45 @@
|
|
|
1
1
|
# routstrd CLI Reference
|
|
2
2
|
|
|
3
|
-
Routstr daemon — a Bun-based CLI tool that runs a background HTTP server for the
|
|
3
|
+
Routstr daemon — a Bun-based CLI tool that runs a background HTTP server for the
|
|
4
|
+
Routstr protocol. It carries an in-process Cashu wallet (coco) for payments and
|
|
5
|
+
routes LLM requests to available providers.
|
|
4
6
|
|
|
5
7
|
## Quick Start
|
|
6
8
|
|
|
7
9
|
```sh
|
|
8
|
-
routstrd onboard # Initialize (creates config, sets up
|
|
10
|
+
routstrd onboard # Initialize (creates config, sets up the wallet)
|
|
11
|
+
routstrd receive 2100 # Top up over Lightning
|
|
9
12
|
routstrd start # Start the daemon
|
|
10
13
|
routstrd stop # Stop the daemon
|
|
11
14
|
```
|
|
12
15
|
|
|
13
|
-
After onboarding, the daemon listens at `http://localhost:8008` and exposes an
|
|
16
|
+
After onboarding, the daemon listens at `http://localhost:8008` and exposes an
|
|
17
|
+
OpenAI-compatible API.
|
|
14
18
|
|
|
15
19
|
## Commands
|
|
16
20
|
|
|
17
21
|
### `routstrd onboard`
|
|
18
22
|
|
|
19
23
|
Initialize routstrd for the first time:
|
|
20
|
-
- Creates `~/.routstrd/` config
|
|
21
|
-
|
|
22
|
-
-
|
|
23
|
-
-
|
|
24
|
-
|
|
24
|
+
- Creates `~/.routstrd/` (mode 0700) and `~/.routstrd/config.json` (mode 0600)
|
|
25
|
+
with defaults (port 8008, host 127.0.0.1, apikeys mode)
|
|
26
|
+
- Generates a Nostr identity (`nsec`) for NIP-98 authentication
|
|
27
|
+
- Migrates a legacy `~/.cocod` wallet to `~/.routstrd/wallet` if one is present,
|
|
28
|
+
stopping any running external `cocod` first
|
|
29
|
+
- Initializes the in-process Cashu wallet
|
|
30
|
+
- Starts the daemon and configures a client integration
|
|
31
|
+
|
|
32
|
+
| Option | Description |
|
|
33
|
+
|--------|-------------|
|
|
34
|
+
| `--opencode` | Set up OpenCode integration (non-interactive) |
|
|
35
|
+
| `--openclaw` | Set up OpenClaw integration (non-interactive) |
|
|
36
|
+
| `--pi-agent` | Set up Pi Agent integration (non-interactive) |
|
|
37
|
+
| `--claude-code` | Set up Claude Code integration (non-interactive) |
|
|
38
|
+
| `--hermes` | Set up Hermes integration (non-interactive) |
|
|
39
|
+
| `--skip-integration` | Skip integration setup |
|
|
40
|
+
|
|
41
|
+
Use at most one integration flag. For several clients, run `routstrd clients add`
|
|
42
|
+
afterwards. `--skip-integration` cannot be combined with an integration flag.
|
|
25
43
|
|
|
26
44
|
### `routstrd start`
|
|
27
45
|
|
|
@@ -30,28 +48,50 @@ Start the background daemon process.
|
|
|
30
48
|
| Option | Description |
|
|
31
49
|
|--------|-------------|
|
|
32
50
|
| `--port <port>` | Port to listen on (default: 8008) |
|
|
51
|
+
| `--host <host>` | Bind address (default: 127.0.0.1) |
|
|
33
52
|
| `-p, --provider <provider>` | Default provider to use |
|
|
34
53
|
|
|
54
|
+
### `routstrd daemon`
|
|
55
|
+
|
|
56
|
+
Run the daemon in the foreground (same options as `start`). Useful for debugging
|
|
57
|
+
and for process supervisors that expect a non-forking process.
|
|
58
|
+
|
|
35
59
|
### `routstrd stop`
|
|
36
60
|
|
|
37
61
|
Stop the background daemon.
|
|
38
62
|
|
|
39
63
|
### `routstrd restart`
|
|
40
64
|
|
|
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 |
|
|
65
|
+
Restart the daemon (stops if running, then starts). Same options as `start`.
|
|
47
66
|
|
|
48
67
|
### `routstrd status`
|
|
49
68
|
|
|
50
69
|
Check daemon and wallet status. Returns JSON with current state.
|
|
51
70
|
|
|
71
|
+
### `routstrd ping`
|
|
72
|
+
|
|
73
|
+
Test connectivity to the daemon.
|
|
74
|
+
|
|
52
75
|
### `routstrd balance`
|
|
53
76
|
|
|
54
|
-
Get wallet and API key balances. Shows per-mint wallet balances, per-key API
|
|
77
|
+
Get wallet and API key balances. Shows per-mint wallet balances, per-key API
|
|
78
|
+
balances, and a grand total (all in sats).
|
|
79
|
+
|
|
80
|
+
| Option | Description |
|
|
81
|
+
|--------|-------------|
|
|
82
|
+
| `--api-keys` | List all stored API keys (baseUrl + key + balance) |
|
|
83
|
+
| `--delete-api-keys <baseUrl>` | Delete the API key stored for a provider base URL (refunds its balance first) |
|
|
84
|
+
| `--mint-url <url>` | Mint to refund the deleted API key balance to (defaults to the active wallet mint) |
|
|
85
|
+
|
|
86
|
+
### `routstrd refund`
|
|
87
|
+
|
|
88
|
+
Refund pending tokens and API keys to a mint.
|
|
89
|
+
|
|
90
|
+
| Option | Default | Description |
|
|
91
|
+
|--------|---------|-------------|
|
|
92
|
+
| `-m, --mint-url <mintUrl>` | active wallet mint | Mint URL to refund to |
|
|
93
|
+
| `-y, --yes` | false | Skip confirmation prompt |
|
|
94
|
+
| `--xcashu` | false | Refund xcashu tokens only |
|
|
55
95
|
|
|
56
96
|
### `routstrd models`
|
|
57
97
|
|
|
@@ -60,6 +100,7 @@ List available routstr21 models (discovered via Nostr).
|
|
|
60
100
|
| Option | Description |
|
|
61
101
|
|--------|-------------|
|
|
62
102
|
| `-r, --refresh` | Force refresh models from Nostr |
|
|
103
|
+
| `-m, --model <id>` | Show the providers serving a specific model |
|
|
63
104
|
|
|
64
105
|
### `routstrd usage`
|
|
65
106
|
|
|
@@ -69,7 +110,21 @@ Show recent usage logs and total sats cost.
|
|
|
69
110
|
|--------|---------|-------------|
|
|
70
111
|
| `-n, --limit <number>` | 10 | Number of recent entries (max 1000) |
|
|
71
112
|
|
|
72
|
-
Shows timestamp, model, provider, sats cost, token counts, and request ID for
|
|
113
|
+
Shows timestamp, model, provider, sats cost, token counts, and request ID for
|
|
114
|
+
each entry.
|
|
115
|
+
|
|
116
|
+
### `routstrd history`
|
|
117
|
+
|
|
118
|
+
Show wallet transaction history.
|
|
119
|
+
|
|
120
|
+
| Option | Default | Description |
|
|
121
|
+
|--------|---------|-------------|
|
|
122
|
+
| `-n, --limit <number>` | 50 | Number of entries to show |
|
|
123
|
+
| `--offset <number>` | 0 | Number of entries to skip |
|
|
124
|
+
| `-t, --type <type...>` | all | Filter by transaction type (`send`, `receive`, `mint`, `melt`). Repeatable or comma-separated |
|
|
125
|
+
| `-i, --id <id>` | | Show a single transaction by its ID (prints one summary line; add `--verbose` for full details) |
|
|
126
|
+
| `-v, --verbose` | false | Show full details including encoded Cashu tokens |
|
|
127
|
+
| `--json` | false | Output raw JSON with token objects (no encoding) |
|
|
73
128
|
|
|
74
129
|
### `routstrd providers`
|
|
75
130
|
|
|
@@ -77,7 +132,12 @@ List and manage providers (subcommand required).
|
|
|
77
132
|
|
|
78
133
|
#### `routstrd providers list`
|
|
79
134
|
|
|
80
|
-
List all providers with their enabled/disabled status. Shows index, status, and
|
|
135
|
+
List all providers with their enabled/disabled status. Shows index, status, and
|
|
136
|
+
base URL.
|
|
137
|
+
|
|
138
|
+
| Option | Description |
|
|
139
|
+
|--------|-------------|
|
|
140
|
+
| `--refresh` | Force re-fetch all Nostr events and refresh models from every enabled provider |
|
|
81
141
|
|
|
82
142
|
```
|
|
83
143
|
Providers (12 total, 2 disabled):
|
|
@@ -103,6 +163,34 @@ Enable providers by their index numbers.
|
|
|
103
163
|
routstrd providers enable 0 2 5
|
|
104
164
|
```
|
|
105
165
|
|
|
166
|
+
#### `routstrd providers reviews`
|
|
167
|
+
|
|
168
|
+
Show all known providers with their stored review events and event IDs.
|
|
169
|
+
|
|
170
|
+
### `routstrd cooldowns`
|
|
171
|
+
|
|
172
|
+
List every provider and model the router is currently skipping because of a
|
|
173
|
+
cooldown. Cooldowns are scoped: a provider-wide entry blocks every model on
|
|
174
|
+
that provider, a model-scoped entry blocks only that model. Entries lift
|
|
175
|
+
automatically once the cooldown window (210s) elapses — nothing needs to be
|
|
176
|
+
cleared by hand.
|
|
177
|
+
|
|
178
|
+
| Option | Default | Description |
|
|
179
|
+
|--------|---------|-------------|
|
|
180
|
+
| `--json` | false | Print the raw daemon response (timestamps and remaining ms per entry) |
|
|
181
|
+
|
|
182
|
+
```
|
|
183
|
+
Cooldowns (210s window)
|
|
184
|
+
|
|
185
|
+
2 active across 2 providers:
|
|
186
|
+
|
|
187
|
+
PROVIDER https://api.nonkycai.com/ expires in 3m 20s
|
|
188
|
+
MODEL https://ai.redsh1ft.com/ deepseek-v4.1-flash expires in 2m 30s
|
|
189
|
+
```
|
|
190
|
+
|
|
191
|
+
Reads `GET /cooldowns` from the daemon; a daemon built before this command
|
|
192
|
+
existed has no such endpoint and must be restarted on a newer build.
|
|
193
|
+
|
|
106
194
|
### `routstrd clients`
|
|
107
195
|
|
|
108
196
|
List and manage API clients (subcommand required).
|
|
@@ -113,7 +201,11 @@ List and manage API clients (subcommand required).
|
|
|
113
201
|
| `--disable-automatic-refresh` | Disable the daemon's scheduled refresh job |
|
|
114
202
|
| `--enable-automatic-refresh` | Re-enable the daemon's scheduled refresh job |
|
|
115
203
|
|
|
116
|
-
The daemon refreshes models and client integrations on a schedule (every 21
|
|
204
|
+
The daemon refreshes models and client integrations on a schedule (every 21
|
|
205
|
+
minutes by default). Use `--manual-refresh` to do it on demand, and
|
|
206
|
+
`--disable-automatic-refresh` to stop the scheduled job — the setting is stored
|
|
207
|
+
in the daemon's `config.json` (`autoRefresh.enabled`) and takes effect without a
|
|
208
|
+
restart.
|
|
117
209
|
|
|
118
210
|
```sh
|
|
119
211
|
routstrd clients --manual-refresh # refresh models + integrations now
|
|
@@ -125,7 +217,6 @@ routstrd clients --enable-automatic-refresh # scheduled refresh back on
|
|
|
125
217
|
|
|
126
218
|
List all registered clients with their ID, name, API key, and creation date.
|
|
127
219
|
|
|
128
|
-
|
|
129
220
|
#### `routstrd clients add`
|
|
130
221
|
|
|
131
222
|
Add a new client or set up a client integration.
|
|
@@ -137,10 +228,11 @@ Add a new client or set up a client integration.
|
|
|
137
228
|
| `--openclaw` | Set up OpenClaw integration |
|
|
138
229
|
| `--pi-agent` | Set up Pi Agent integration |
|
|
139
230
|
| `--claude-code` | Set up Claude Code integration |
|
|
231
|
+
| `--hermes` | Set up Hermes integration |
|
|
140
232
|
|
|
141
233
|
```sh
|
|
142
234
|
routstrd clients add --opencode --pi-agent --claude-code # multiple integrations
|
|
143
|
-
routstrd clients add -n "My App"
|
|
235
|
+
routstrd clients add -n "My App" # generic client
|
|
144
236
|
```
|
|
145
237
|
|
|
146
238
|
Returns the client ID and API key for use with the OpenAI-compatible API.
|
|
@@ -151,56 +243,58 @@ Delete a registered client by its ID.
|
|
|
151
243
|
|
|
152
244
|
### `routstrd npubs`
|
|
153
245
|
|
|
154
|
-
Manage registered npubs and their roles/names (subcommand required). Management
|
|
246
|
+
Manage registered npubs and their roles/names (subcommand required). Management
|
|
247
|
+
commands route through the auth proxy (`--auth-url`) and use NIP-98 auth.
|
|
155
248
|
|
|
156
249
|
| Command | Description |
|
|
157
250
|
|---------|-------------|
|
|
158
251
|
| `routstrd npubs list` | List registered npubs with role and display name |
|
|
159
252
|
| `routstrd npubs register [--name <name>]` | Register yourself as the first admin (bootstrap only) |
|
|
160
|
-
| `routstrd npubs add <npub> [--role <role>] [--name <name>]` | Add an npub (accepts hex or npub1...) |
|
|
253
|
+
| `routstrd npubs add <npub> [--role <role>] [--name <name>]` | Add an npub (accepts hex or npub1...); defaults to the `user` role |
|
|
161
254
|
| `routstrd npubs update <npub> [--role <role>] [--name <name>]` | Update role and/or name (admin only) |
|
|
162
255
|
| `routstrd npubs delete <npub>` | Delete an npub |
|
|
163
256
|
|
|
164
|
-
### `routstrd remote
|
|
257
|
+
### `routstrd remote [url]`
|
|
165
258
|
|
|
166
|
-
|
|
259
|
+
With no URL, print the configured remote daemon. Pass a URL to configure one — a
|
|
260
|
+
Nostr identity (nsec/npub) is generated automatically for NIP-98 authentication.
|
|
261
|
+
|
|
262
|
+
| Option | Description |
|
|
263
|
+
|--------|-------------|
|
|
264
|
+
| `--auth-url <authUrl>` | URL of the auth proxy used by management commands (`npubs`, `clients`, `usage`) |
|
|
167
265
|
|
|
168
266
|
```sh
|
|
169
|
-
routstrd remote
|
|
267
|
+
routstrd remote # show current remote
|
|
268
|
+
routstrd remote https://your-remote-daemon.com # configure one
|
|
170
269
|
```
|
|
171
270
|
|
|
271
|
+
### `routstrd local`
|
|
272
|
+
|
|
273
|
+
Switch back to local daemon mode (clears the configured remote daemon URL).
|
|
274
|
+
|
|
172
275
|
### `routstrd refresh`
|
|
173
276
|
|
|
174
|
-
Refresh routstr21 models from Nostr and re-run integrations for all registered
|
|
277
|
+
Refresh routstr21 models from Nostr and re-run integrations for all registered
|
|
278
|
+
clients. Equivalent to `routstrd clients --manual-refresh`.
|
|
175
279
|
|
|
176
|
-
|
|
177
|
-
|-------|------|---------|-------------|
|
|
178
|
-
| `port` | number | 8008 | Daemon HTTP port |
|
|
179
|
-
| `provider` | string\|null | null | Default provider URL |
|
|
180
|
-
| `daemonUrl` | string\|null | null | Remote daemon URL |
|
|
181
|
-
| `nsec` | string\|null | null | Nostr secret key for NIP-98 auth |
|
|
182
|
-
| `cocodPath` | string\|null | null | Custom path to cocod executable |
|
|
183
|
-
| `mode` | string | `"apikeys"` | Client mode (`apikeys` or `xcashu`) |
|
|
184
|
-
| `autoRefresh` | object | `{ enabled: true }` | Scheduled refresh job settings (`enabled`, `intervalMs`) |
|
|
280
|
+
### `routstrd update`
|
|
185
281
|
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
| `ROUTSTRD_DIR` | `~/.routstrd` | Config directory |
|
|
189
|
-
| `ROUTSTRD_WALLET_DIR` | `~/.routstrd/wallet` | In-process Cashu wallet data directory |
|
|
190
|
-
| `ROUTSTRD_WALLET_PID` | `<wallet>/wallet.pid` | In-process wallet lock path |
|
|
191
|
-
| `COCOD_DIR` | `~/.cocod` | Legacy external cocod compatibility directory |
|
|
282
|
+
Update routstrd to the latest version. Standalone-binary installs update
|
|
283
|
+
in place; npm/bun installs are updated through the package manager.
|
|
192
284
|
|
|
193
285
|
### `routstrd mode`
|
|
194
286
|
|
|
195
287
|
Interactive prompt to set the client mode:
|
|
196
|
-
1. **lazyrefund/apikeys** (default) — Pseudonymous accounts kept with Routstr
|
|
197
|
-
|
|
288
|
+
1. **lazyrefund/apikeys** (default) — Pseudonymous accounts kept with Routstr
|
|
289
|
+
nodes, refunded after 5 mins if unused.
|
|
290
|
+
2. **xcashu** (coming soon) — Balances never kept with nodes, all refunded in
|
|
291
|
+
response.
|
|
198
292
|
|
|
199
293
|
Changing mode restarts the daemon automatically.
|
|
200
294
|
|
|
201
|
-
### `routstrd monitor`
|
|
295
|
+
### `routstrd monitor` / `routstrd top`
|
|
202
296
|
|
|
203
|
-
Open an interactive TUI (htop-like) for usage monitoring.
|
|
297
|
+
Open an interactive TUI (htop-like) for usage monitoring. `top` is an alias.
|
|
204
298
|
|
|
205
299
|
### `routstrd logs`
|
|
206
300
|
|
|
@@ -211,17 +305,54 @@ View daemon logs.
|
|
|
211
305
|
| `-f, --follow` | false | Follow log output (like `tail -f`) |
|
|
212
306
|
| `-c, --coco` | false | Show Cashu wallet-engine (coco) logs instead of daemon logs |
|
|
213
307
|
| `-n, --lines <number>` | 50 | Number of lines to show |
|
|
308
|
+
| `-r, --recent` | false | List recent request IDs with their model |
|
|
309
|
+
| `-i, --request-id <id>` | | Only show log lines for a specific request ID |
|
|
310
|
+
|
|
311
|
+
Log files are stored at `~/.routstrd/logs/YYYY-MM-DD.log`. Wallet-engine
|
|
312
|
+
(Cashu/coco) diagnostics go to a separate `~/.routstrd/coco-logs/YYYY-MM-DD.log`
|
|
313
|
+
so they don't pollute the main daemon logs.
|
|
214
314
|
|
|
215
|
-
|
|
315
|
+
### `routstrd service`
|
|
316
|
+
|
|
317
|
+
Manage routstrd as a system service using PM2, so it survives reboots.
|
|
318
|
+
|
|
319
|
+
| Command | Description |
|
|
320
|
+
|---------|-------------|
|
|
321
|
+
| `routstrd service install` | Install and start routstrd under PM2 |
|
|
322
|
+
| `routstrd service uninstall` | Stop and remove routstrd from PM2 |
|
|
323
|
+
| `routstrd service logs` | View PM2 logs for routstrd |
|
|
216
324
|
|
|
217
325
|
## Wallet Commands
|
|
218
326
|
|
|
219
|
-
New wallets
|
|
327
|
+
New wallets trust two mints out of the box: `https://mint.minibits.cash/Bitcoin`
|
|
328
|
+
and `https://mint.cubabitcoin.org`. `https://mint.minibits.cash/Bitcoin` is the
|
|
329
|
+
default mint, and the default is used when a wallet command does not include
|
|
330
|
+
`--mint-url`. An existing wallet keeps whatever default it already has; the
|
|
331
|
+
shipped mints are only added as trusted, never as the default. Use
|
|
332
|
+
`routstrd wallet mints add <url>` to trust another mint.
|
|
333
|
+
|
|
334
|
+
### `routstrd send <target>` / `routstrd receive <value>`
|
|
335
|
+
|
|
336
|
+
Shortcuts for the common wallet operations:
|
|
337
|
+
|
|
338
|
+
| Command | Behaviour |
|
|
339
|
+
|---------|-----------|
|
|
340
|
+
| `routstrd send 2100` | Numeric target → create a Cashu token for that many sats |
|
|
341
|
+
| `routstrd send lnbc1...` | Non-numeric target → pay that Lightning invoice |
|
|
342
|
+
| `routstrd receive 2100` | Numeric value → create a Lightning invoice for that many sats and wait for payment |
|
|
343
|
+
| `routstrd receive cashuB...` | Non-numeric value → receive that Cashu token |
|
|
344
|
+
|
|
345
|
+
Both accept `--mint-url <url>`.
|
|
220
346
|
|
|
221
347
|
### `routstrd wallet status`
|
|
222
348
|
|
|
223
349
|
Check wallet status.
|
|
224
350
|
|
|
351
|
+
### `routstrd wallet doctor`
|
|
352
|
+
|
|
353
|
+
Diagnose conflicting wallets — the current routstrd wallet versus a legacy
|
|
354
|
+
`cocod` wallet.
|
|
355
|
+
|
|
225
356
|
### `routstrd wallet unlock <passphrase>`
|
|
226
357
|
|
|
227
358
|
Unlock the wallet with a passphrase.
|
|
@@ -230,6 +361,17 @@ Unlock the wallet with a passphrase.
|
|
|
230
361
|
|
|
231
362
|
Get wallet balance.
|
|
232
363
|
|
|
364
|
+
### `routstrd wallet cleanup`
|
|
365
|
+
|
|
366
|
+
Clear stuck pending/in-flight wallet operations.
|
|
367
|
+
|
|
368
|
+
| Option | Default | Description |
|
|
369
|
+
|--------|---------|-------------|
|
|
370
|
+
| `--mint-url <url>` | all mints | Only clean up operations for this mint URL |
|
|
371
|
+
| `--min-age <hours>` | 168 | Minimum age for reclaiming sends and cancelling melts (expired mint quotes are always failed) |
|
|
372
|
+
| `--dry-run` | false | Report what would be cleaned without applying changes |
|
|
373
|
+
| `-y, --yes` | false | Skip confirmation prompt |
|
|
374
|
+
|
|
233
375
|
### `routstrd wallet receive cashu <token>`
|
|
234
376
|
|
|
235
377
|
Receive funds via a Cashu token.
|
|
@@ -260,7 +402,7 @@ Pay a Lightning invoice.
|
|
|
260
402
|
|
|
261
403
|
### `routstrd wallet mints list`
|
|
262
404
|
|
|
263
|
-
List configured wallet mints.
|
|
405
|
+
List configured wallet mints. Includes the mints trusted by default (`https://mint.minibits.cash/Bitcoin`, `https://mint.cubabitcoin.org`) plus any added manually.
|
|
264
406
|
|
|
265
407
|
### `routstrd wallet mints add <url>`
|
|
266
408
|
|
|
@@ -274,6 +416,41 @@ Set the persistent default mint. If necessary, the mint is added as trusted firs
|
|
|
274
416
|
|
|
275
417
|
Get info about a specific mint.
|
|
276
418
|
|
|
419
|
+
### `routstrd wallet npc`
|
|
420
|
+
|
|
421
|
+
NPC (npubx.cash) Lightning address operations.
|
|
422
|
+
|
|
423
|
+
| Command | Description |
|
|
424
|
+
|---------|-------------|
|
|
425
|
+
| `routstrd wallet npc address` | Show this wallet's NPC Lightning address |
|
|
426
|
+
| `routstrd wallet npc username <name> [--confirm]` | Claim an NPC username; `--confirm` pays the claim fee |
|
|
427
|
+
| `routstrd wallet npc sync` | Manually sync paid NPC quotes into the wallet |
|
|
428
|
+
|
|
429
|
+
## NWC (Nostr Wallet Connect)
|
|
430
|
+
|
|
431
|
+
Connect an external Lightning wallet and let it fund the Cashu wallet.
|
|
432
|
+
|
|
433
|
+
| Command | Description |
|
|
434
|
+
|---------|-------------|
|
|
435
|
+
| `routstrd nwc connect [connection-string]` | Connect via `nostr+walletconnect://...` (prompts if omitted) |
|
|
436
|
+
| `routstrd nwc disconnect` | Disconnect from the NWC wallet |
|
|
437
|
+
| `routstrd nwc status` | Show connection status and wallet info |
|
|
438
|
+
| `routstrd nwc fund <amount>` | Manually fund the Cashu wallet from the connected NWC wallet |
|
|
439
|
+
|
|
440
|
+
### `routstrd nwc auto-refill on`
|
|
441
|
+
|
|
442
|
+
Enable automatic wallet refill from NWC.
|
|
443
|
+
|
|
444
|
+
| Option | Default | Description |
|
|
445
|
+
|--------|---------|-------------|
|
|
446
|
+
| `--threshold <sats>` | 500 | Refill when the Cashu balance drops below this |
|
|
447
|
+
| `--amount <sats>` | 1000 | Refill this many sats at a time |
|
|
448
|
+
| `--cooldown <seconds>` | 300 | Minimum time between refills |
|
|
449
|
+
|
|
450
|
+
### `routstrd nwc auto-refill off`
|
|
451
|
+
|
|
452
|
+
Disable auto-refill.
|
|
453
|
+
|
|
277
454
|
## Daemon API
|
|
278
455
|
|
|
279
456
|
The daemon exposes an OpenAI-compatible HTTP API at `http://localhost:8008`:
|
|
@@ -298,6 +475,10 @@ Route a chat completion request.
|
|
|
298
475
|
}
|
|
299
476
|
```
|
|
300
477
|
|
|
478
|
+
The incoming request path is forwarded to the provider, so the Anthropic
|
|
479
|
+
Messages API (`POST /v1/messages`) and the OpenAI Responses API
|
|
480
|
+
(`POST /v1/responses`) are proxied in their own formats as well.
|
|
481
|
+
|
|
301
482
|
## Configuration
|
|
302
483
|
|
|
303
484
|
Config file: `~/.routstrd/config.json`
|
|
@@ -305,10 +486,19 @@ Config file: `~/.routstrd/config.json`
|
|
|
305
486
|
| Field | Type | Default | Description |
|
|
306
487
|
|-------|------|---------|-------------|
|
|
307
488
|
| `port` | number | 8008 | Daemon HTTP port |
|
|
489
|
+
| `host` | string | `"127.0.0.1"` | Bind address |
|
|
308
490
|
| `provider` | string\|null | null | Default provider URL |
|
|
309
|
-
| `cocodPath` | string\|null | null | Custom path to cocod executable |
|
|
310
491
|
| `mode` | string | `"apikeys"` | Client mode (`apikeys` or `xcashu`) |
|
|
492
|
+
| `maxTokens` | number | 64000 | Completion budget applied when a client sets no output-token limit |
|
|
493
|
+
| `daemonUrl` | string | — | Remote daemon URL (set by `routstrd remote`) |
|
|
494
|
+
| `authUrl` | string | — | Auth proxy URL for management commands |
|
|
495
|
+
| `nsec` | string | — | Nostr secret key for NIP-98 auth |
|
|
496
|
+
| `relays` | string[] | — | Nostr relays to use for discovery |
|
|
497
|
+
| `routstrPubkey` | string | — | Override the Routstr announcement pubkey |
|
|
498
|
+
| `routstrModelsPubkey` | string | — | Override the routstr21 models pubkey |
|
|
499
|
+
| `nwc` | object | — | NWC settings (`mode`, `connectionString`, `autoRefill`) |
|
|
311
500
|
| `autoRefresh` | object | `{ enabled: true }` | Scheduled refresh job settings (`enabled`, `intervalMs`) |
|
|
501
|
+
| `requestResponseLogging` | object | — | Request/response log sink settings |
|
|
312
502
|
|
|
313
503
|
### Environment Variables
|
|
314
504
|
|
|
@@ -317,17 +507,26 @@ Config file: `~/.routstrd/config.json`
|
|
|
317
507
|
| `ROUTSTRD_DIR` | `~/.routstrd` | Config directory |
|
|
318
508
|
| `ROUTSTRD_SOCKET` | `~/.routstrd/routstrd.sock` | IPC socket path |
|
|
319
509
|
| `ROUTSTRD_PID` | `~/.routstrd/routstrd.pid` | PID file path |
|
|
510
|
+
| `ROUTSTRD_WALLET_DIR` | `~/.routstrd/wallet` | In-process Cashu wallet data directory |
|
|
511
|
+
| `ROUTSTRD_WALLET_PID` | `<wallet>/wallet.pid` | In-process wallet lock path |
|
|
512
|
+
| `COCOD_DIR` | `~/.cocod` | Legacy external cocod compatibility directory |
|
|
320
513
|
|
|
321
514
|
## Remote Mode
|
|
322
515
|
|
|
323
|
-
When `daemonUrl` is configured, commands connect to a remote daemon instead of a
|
|
516
|
+
When `daemonUrl` is configured, commands connect to a remote daemon instead of a
|
|
517
|
+
local one:
|
|
324
518
|
- Client names are suffixed with the last 7 chars of your npub
|
|
325
519
|
- All requests are automatically NIP-98 signed using your local nsec
|
|
326
|
-
- Local-only commands (`onboard`, `start`, `restart`, `mode`, `logs`, `service`)
|
|
520
|
+
- Local-only commands (`onboard`, `start`, `restart`, `mode`, `logs`, `service`)
|
|
521
|
+
are disabled
|
|
522
|
+
|
|
523
|
+
Run `routstrd local` to switch back.
|
|
327
524
|
|
|
328
525
|
## Pi Integration
|
|
329
526
|
|
|
330
|
-
When `routstrd onboard` runs, it automatically configures a `routstr` provider in
|
|
527
|
+
When `routstrd onboard` runs, it automatically configures a `routstr` provider in
|
|
528
|
+
`pi`'s `models.json` with an OpenAI-compatible base URL and API key. This allows
|
|
529
|
+
pi (the AI coding agent) to use Routstr providers seamlessly.
|
|
331
530
|
|
|
332
531
|
## File Locations
|
|
333
532
|
|
|
@@ -337,5 +536,21 @@ When `routstrd onboard` runs, it automatically configures a `routstr` provider i
|
|
|
337
536
|
| `~/.routstrd/routstr.db` | SQLite database |
|
|
338
537
|
| `~/.routstrd/routstrd.sock` | IPC socket |
|
|
339
538
|
| `~/.routstrd/routstrd.pid` | PID file |
|
|
539
|
+
| `~/.routstrd/wallet/` | In-process Cashu wallet data (`config.json`, `coco.db`, `wallet.pid`) |
|
|
340
540
|
| `~/.routstrd/logs/YYYY-MM-DD.log` | Daily daemon log files |
|
|
341
541
|
| `~/.routstrd/coco-logs/YYYY-MM-DD.log` | Daily Cashu wallet-engine (coco) log files |
|
|
542
|
+
|
|
543
|
+
## Development
|
|
544
|
+
|
|
545
|
+
```sh
|
|
546
|
+
bun install
|
|
547
|
+
bun run lint # tsc --noEmit
|
|
548
|
+
bun test
|
|
549
|
+
bun run build # bundles dist/index.js and dist/daemon/index.js
|
|
550
|
+
```
|
|
551
|
+
|
|
552
|
+
End-to-end smoke test against a running daemon (needs a funded client API key):
|
|
553
|
+
|
|
554
|
+
```sh
|
|
555
|
+
ROUTSTRD_API_KEY=<api-key> bun run smoke <model-id> [model-id ...]
|
|
556
|
+
```
|