routstrd 0.3.0 → 0.3.2
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/bun.lock +103 -17
- package/dist/daemon/index.js +18402 -8458
- package/dist/index.js +147 -88
- package/package.json +2 -2
- package/say_hi.sh +32 -0
- package/src/cli.ts +53 -23
- package/src/daemon/models.ts +55 -0
- package/src/daemon/types.ts +6 -0
- package/src/integrations/claudecode.ts +9 -10
- package/src/integrations/hermes.ts +10 -11
- package/src/integrations/openclaw.ts +5 -6
- package/src/integrations/opencode.ts +5 -6
- package/src/integrations/pi.ts +13 -9
- package/src/integrations/registry.ts +1 -0
- package/src/tui/usage/data.ts +6 -2
- package/src/tui/usage/render.ts +20 -5
- package/src/utils/config.ts +6 -0
- package/src/utils/daemon-client.ts +32 -5
- package/new-task.md +0 -60
|
@@ -35,13 +35,20 @@ export function getDaemonBaseUrl(config: RoutstrdConfig): string {
|
|
|
35
35
|
);
|
|
36
36
|
}
|
|
37
37
|
|
|
38
|
-
export
|
|
38
|
+
export function getAuthBaseUrl(config: RoutstrdConfig): string {
|
|
39
|
+
if (config.authUrl) {
|
|
40
|
+
return config.authUrl.replace(/\/$/, "");
|
|
41
|
+
}
|
|
42
|
+
return getDaemonBaseUrl(config);
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
async function _callUrl(
|
|
46
|
+
baseUrl: string,
|
|
39
47
|
path: string,
|
|
40
|
-
options: { method?: "GET" | "POST" | "PATCH" | "DELETE"; body?: object }
|
|
48
|
+
options: { method?: "GET" | "POST" | "PATCH" | "DELETE"; body?: object },
|
|
49
|
+
config: RoutstrdConfig,
|
|
41
50
|
): Promise<CommandResponse> {
|
|
42
51
|
const { method = "GET", body } = options;
|
|
43
|
-
const config = await loadConfig();
|
|
44
|
-
const baseUrl = getDaemonBaseUrl(config);
|
|
45
52
|
const url = `${baseUrl}${path}`;
|
|
46
53
|
|
|
47
54
|
const bodyString = body ? JSON.stringify(body) : undefined;
|
|
@@ -50,7 +57,7 @@ export async function callDaemon(
|
|
|
50
57
|
: undefined;
|
|
51
58
|
|
|
52
59
|
let authorization: string | undefined;
|
|
53
|
-
if (config.daemonUrl && config.nsec) {
|
|
60
|
+
if ((config.daemonUrl || config.authUrl) && config.nsec) {
|
|
54
61
|
const secretKey = parseSecretKey(config.nsec);
|
|
55
62
|
authorization = await createNIP98Authorization(
|
|
56
63
|
secretKey,
|
|
@@ -77,6 +84,26 @@ export async function callDaemon(
|
|
|
77
84
|
return response.json() as Promise<CommandResponse>;
|
|
78
85
|
}
|
|
79
86
|
|
|
87
|
+
export async function callDaemon(
|
|
88
|
+
path: string,
|
|
89
|
+
options: { method?: "GET" | "POST" | "PATCH" | "DELETE"; body?: object } = {},
|
|
90
|
+
): Promise<CommandResponse> {
|
|
91
|
+
const config = await loadConfig();
|
|
92
|
+
const baseUrl = getDaemonBaseUrl(config);
|
|
93
|
+
return _callUrl(baseUrl, path, options, config);
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
/** Like callDaemon but sends requests to the auth proxy URL instead.
|
|
97
|
+
* Falls back to the daemon URL if no authUrl is configured. */
|
|
98
|
+
export async function callAuth(
|
|
99
|
+
path: string,
|
|
100
|
+
options: { method?: "GET" | "POST" | "PATCH" | "DELETE"; body?: object } = {},
|
|
101
|
+
): Promise<CommandResponse> {
|
|
102
|
+
const config = await loadConfig();
|
|
103
|
+
const baseUrl = getAuthBaseUrl(config);
|
|
104
|
+
return _callUrl(baseUrl, path, options, config);
|
|
105
|
+
}
|
|
106
|
+
|
|
80
107
|
export async function isDaemonRunning(): Promise<boolean> {
|
|
81
108
|
try {
|
|
82
109
|
const config = await loadConfig();
|
package/new-task.md
DELETED
|
@@ -1,60 +0,0 @@
|
|
|
1
|
-
# Hot-reload NWC connection (remove restart requirement)
|
|
2
|
-
|
|
3
|
-
## Problem
|
|
4
|
-
|
|
5
|
-
`nwc connect` and `nwc disconnect` require a daemon restart to take effect. The
|
|
6
|
-
CLI writes the new connection string to disk, but the daemon never re-reads it.
|
|
7
|
-
|
|
8
|
-
## Current flow
|
|
9
|
-
|
|
10
|
-
1. **Startup** — `createWalletAdapter` reads `options.nwcConnectionString` and
|
|
11
|
-
creates a `WalletConnect` (relay pool + NWC wallet service) once:
|
|
12
|
-
```ts
|
|
13
|
-
// src/daemon/wallet/index.ts:70-78
|
|
14
|
-
if (options.nwcConnectionString) {
|
|
15
|
-
wallet = WalletConnect.fromConnectURI(options.nwcConnectionString, { pool });
|
|
16
|
-
}
|
|
17
|
-
```
|
|
18
|
-
|
|
19
|
-
2. **CLI `nwc connect`** — HTTP handler at `POST /nwc/connect` only calls
|
|
20
|
-
`saveDaemonConfig(config)`. The running `WalletConnect` instance is untouched.
|
|
21
|
-
|
|
22
|
-
3. **Result** — the old connection (or lack thereof) stays active until restart.
|
|
23
|
-
|
|
24
|
-
## What needs to happen
|
|
25
|
-
|
|
26
|
-
Provide a way for the daemon to tear down the old `WalletConnect` and create a
|
|
27
|
-
new one from the updated connection string, triggered by the HTTP handler,
|
|
28
|
-
**without restarting the process**.
|
|
29
|
-
|
|
30
|
-
### Key pieces
|
|
31
|
-
|
|
32
|
-
- **`src/daemon/wallet/index.ts`** — `createWalletAdapter` needs to expose a
|
|
33
|
-
`reconnect(connectionString: string)` method that:
|
|
34
|
-
- Closes the old relay pool / WalletConnect
|
|
35
|
-
- Creates a new `WalletConnect` from the new connection string
|
|
36
|
-
- Updates the adapter's internal `wallet` reference
|
|
37
|
-
- If connection string is empty/undefined, disconnects and sets `wallet` to
|
|
38
|
-
`undefined`
|
|
39
|
-
|
|
40
|
-
- **`src/daemon/http/index.ts`** — `POST /nwc/connect` and `POST /nwc/disconnect`
|
|
41
|
-
handlers should call `reconnect()` after saving config, and drop the "Restart
|
|
42
|
-
daemon" message.
|
|
43
|
-
|
|
44
|
-
- **`src/daemon/index.ts`** — may need to store the `reconnect` function and pass
|
|
45
|
-
it through `DaemonDeps` to the HTTP handler.
|
|
46
|
-
|
|
47
|
-
- **`src/cli.ts`** — remove `console.log("\nRun 'routstrd restart' to connect...")`
|
|
48
|
-
from the connect/disconnect commands.
|
|
49
|
-
|
|
50
|
-
### Considerations
|
|
51
|
-
|
|
52
|
-
- The `WalletConnect` instance is referenced in the auto-refill loop (passed to
|
|
53
|
-
`startAutoRefillLoop`). After a reconnect, the auto-refill loop's captured
|
|
54
|
-
`wallet` reference would be stale. The loop already reads config from disk
|
|
55
|
-
each cycle, so it should also reference the latest `wallet` instance.
|
|
56
|
-
- Could make the auto-refill loop accept a `getWallet: () => WalletConnect |
|
|
57
|
-
undefined` getter, same pattern as the config getter.
|
|
58
|
-
- Relay pool cleanup — `applesauce-wallet-connect` / `applesauce-relay` may need
|
|
59
|
-
explicit `pool.close()` or `pool.destroy()` to free connections.
|
|
60
|
-
- Edge case: a refill is in progress when reconnect is triggered.
|