@drakonkat/ai-helper 1.2.6 → 1.2.8
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/CHANGELOG.md +7 -0
- package/README.md +109 -10
- package/package.json +1 -1
- package/src/index.js +99 -41
- package/src/manager.js +5 -1
- package/src/service-updates.js +4 -44
- package/src/update.js +11 -1
- package/src/utils/update-installer.js +50 -0
package/CHANGELOG.md
CHANGED
|
@@ -4,6 +4,13 @@ All notable changes to **`ai-helper` (`aih`)** are documented in this file.
|
|
|
4
4
|
|
|
5
5
|
---
|
|
6
6
|
|
|
7
|
+
## [1.2.8] - 2026-09-24
|
|
8
|
+
|
|
9
|
+
### Added
|
|
10
|
+
- Persist the proxy model selection with `aih config pxpipe-models="model1,model2"`. Subsequent starts reuse it; explicit `--models` overrides the saved preference.
|
|
11
|
+
|
|
12
|
+
---
|
|
13
|
+
|
|
7
14
|
## [Unreleased]
|
|
8
15
|
|
|
9
16
|
### Added
|
package/README.md
CHANGED
|
@@ -21,6 +21,7 @@
|
|
|
21
21
|
- [Key Features](#-key-features)
|
|
22
22
|
- [CLI Reference](#-cli-reference)
|
|
23
23
|
- [HTTP / WebSocket Proxy](#http--websocket-proxy)
|
|
24
|
+
- [Proxy option values](#proxy-option-values)
|
|
24
25
|
- [Start a compression pipeline](#start-a-compression-pipeline)
|
|
25
26
|
- [Select models](#select-models)
|
|
26
27
|
- [Proxy token savings](#proxy-token-savings)
|
|
@@ -111,6 +112,31 @@ bun add -g @drakonkat/ai-helper
|
|
|
111
112
|
|
|
112
113
|
## 💻 CLI Reference
|
|
113
114
|
|
|
115
|
+
Run `aih --help` for the command summary and examples. Replace `<values>` with
|
|
116
|
+
your own values; brackets below mark optional arguments. Quote values containing
|
|
117
|
+
spaces, such as `--interceptor "./my hooks/interceptor.mjs"`.
|
|
118
|
+
|
|
119
|
+
| Command syntax | Example |
|
|
120
|
+
| --- | --- |
|
|
121
|
+
| `status [services...] [--json] [--ui]` | `aih status ocx proxy --json`; `aih status --ui` |
|
|
122
|
+
| `start [services...] [--models <list>] [--json]` | `aih start --models "gpt-6-astra,anthropic/claude-fable*"` |
|
|
123
|
+
| `start proxy [upstream] [proxy options] [--json]` | `aih start proxy http://127.0.0.1:10100/ --listen http://127.0.0.1:10102 --preset pxpipe` |
|
|
124
|
+
| `stop [services...]` | `aih stop ocx agentmemory` |
|
|
125
|
+
| `restart [services...] [--json]` | `aih restart ocx agentmemory --json` |
|
|
126
|
+
| `restart proxy [upstream] [proxy options] [--json]` | `aih restart proxy --models="gpt-6-astra,anthropic/claude-fable*"` |
|
|
127
|
+
| `update [--json]` | `aih update` (update aih itself from npm) |
|
|
128
|
+
| `update <services...> [--json]` | `aih update ocx agentmemory --json`; `aih ocx update` |
|
|
129
|
+
| `open [services...] [--repo]` | `aih open agentmemory`; `aih open proxy --repo` |
|
|
130
|
+
| `logs <service> [-n <lines>] [-f]` | `aih logs proxy --lines=100 --follow` |
|
|
131
|
+
| `stats proxy [--json]` | `aih stats proxy --json` |
|
|
132
|
+
| `install` | `aih install` (build/install the standalone binary; requires Bun) |
|
|
133
|
+
| `version`, `help` | `aih --version`; `aih --help` |
|
|
134
|
+
|
|
135
|
+
Aliases: `ps`, `ls`, `list` for `status`; `up` for `start`; `down` for `stop`;
|
|
136
|
+
`dashboard`, `dash` for `open`; `log` for `logs`. `-ui` also enables the status
|
|
137
|
+
dashboard, `--lines`/`--follow` are the long log options, and `-v`/`-h` show
|
|
138
|
+
version/help. Proxy URL and option values are detailed [below](#proxy-option-values).
|
|
139
|
+
|
|
114
140
|
### 1. Status Overview
|
|
115
141
|
|
|
116
142
|
```bash
|
|
@@ -123,7 +149,7 @@ aih
|
|
|
123
149
|
|
|
124
150
|
*Output:*
|
|
125
151
|
```text
|
|
126
|
-
ai-helper v1.
|
|
152
|
+
ai-helper v1.2.6 — Background AI Ecosystem Service Manager
|
|
127
153
|
|
|
128
154
|
SERVICE STATUS PID UPTIME ADDRESS REPO COMMAND
|
|
129
155
|
─────────── ───────── ───── ────── ────────────────────── ───────────────────────────────────────── ────────────────────────────
|
|
@@ -177,13 +203,32 @@ Narrow terminals keep space for the newest events and service controls.
|
|
|
177
203
|
|
|
178
204
|
---
|
|
179
205
|
|
|
206
|
+
### Update aih
|
|
207
|
+
|
|
208
|
+
```bash
|
|
209
|
+
aih update # update aih itself to the latest npm release
|
|
210
|
+
aih update --json # JSON result array, exit code 1 on failure
|
|
211
|
+
aih --version # verify the installed version
|
|
212
|
+
```
|
|
213
|
+
|
|
214
|
+
Without service targets, `aih update` runs
|
|
215
|
+
`npm install --global @drakonkat/ai-helper@latest --no-audit --no-fund`.
|
|
216
|
+
It does not update or restart managed services. npm must be on PATH and its
|
|
217
|
+
global installation directory writable. Installer output is captured in
|
|
218
|
+
`~/.aih/logs/aih.log` (or under `AIH_HOME`), with failure details in the result.
|
|
219
|
+
|
|
220
|
+
This updates the global npm installation, not a source checkout, local dependency,
|
|
221
|
+
or standalone executable. Rebuild standalone executables separately and ensure
|
|
222
|
+
your shell resolves `aih` to the installation you intend to use. Restart a running
|
|
223
|
+
built-in proxy with `aih restart proxy` to load the updated code.
|
|
224
|
+
|
|
180
225
|
### Update Managed Services
|
|
181
226
|
|
|
182
227
|
```bash
|
|
183
228
|
aih ocx update # update OpenCodex to the latest available release
|
|
184
229
|
aih update ocx # equivalent command-first form
|
|
185
230
|
aih update ocx agentmemory # update selected services
|
|
186
|
-
aih update
|
|
231
|
+
aih update pxpipe ocx agentmemory headroom # all managed services, not aih itself
|
|
187
232
|
aih update ocx --json # JSON result array, exit code 1 on any failure
|
|
188
233
|
```
|
|
189
234
|
|
|
@@ -192,8 +237,8 @@ installation is left unchanged. Running services are restarted after an update;
|
|
|
192
237
|
stopped services are not started. If installation fails after stopping a running
|
|
193
238
|
service, aih attempts to start it again and reports any recovery failure.
|
|
194
239
|
Unknown/custom service targets are rejected before any selected service is
|
|
195
|
-
changed. The built-in `proxy` is part of ai-helper itself and
|
|
196
|
-
`aih update
|
|
240
|
+
changed. The built-in `proxy` is part of ai-helper itself and cannot be updated
|
|
241
|
+
as a service: use `aih update` without targets or rebuild the standalone executable
|
|
197
242
|
instead. The proxy's bundled pxpipe library is likewise updated with ai-helper,
|
|
198
243
|
not by updating the separate `pxpipe` service.
|
|
199
244
|
|
|
@@ -247,11 +292,39 @@ Pass `--models` to `aih start` (or `aih up`) to override the proxy's model list:
|
|
|
247
292
|
|
|
248
293
|
```bash
|
|
249
294
|
aih start --models "gpt-6-astra,anthropic/claude-fable*"
|
|
295
|
+
aih up --models="gpt-6-astra,anthropic/claude-fable*" # Equivalent value syntax
|
|
250
296
|
aih start --models= # Use pxpipe's default model selection
|
|
251
297
|
```
|
|
252
298
|
|
|
299
|
+
To save a model list once and reuse it on subsequent starts:
|
|
300
|
+
|
|
301
|
+
```bash
|
|
302
|
+
aih config pxpipe-models="gpt-6-astra,claude-opus-5-5"
|
|
303
|
+
aih start
|
|
304
|
+
```
|
|
305
|
+
|
|
306
|
+
The preference is saved in `~/.aih/state.json` (or `AIH_HOME/state.json`).
|
|
307
|
+
It applies to `start`/`up` and proxy starts/restarts; an explicit `--models`
|
|
308
|
+
takes precedence without changing the preference. `aih config pxpipe-models=`
|
|
309
|
+
saves pxpipe's default selection. Configuration does not restart a running proxy.
|
|
310
|
+
|
|
311
|
+
The value is passed only to the built-in proxy; `ocx` and `agentmemory` start
|
|
312
|
+
normally. `--models=` passes an empty string; `--models ""` also works when your
|
|
313
|
+
shell preserves empty arguments. A bare `--models` without a value is an error.
|
|
314
|
+
See [Select models](#select-models) for matching and compression behavior.
|
|
315
|
+
|
|
316
|
+
The no-target `start`/`up` commands supply the upstream, listener and preset above
|
|
317
|
+
on every invocation, plus the configured model list (or the list above if unset),
|
|
318
|
+
unless `--models` overrides it.
|
|
319
|
+
Other saved proxy options are retained.
|
|
320
|
+
A first `aih start proxy <upstream>` instead uses listener `http://127.0.0.1:10101`
|
|
321
|
+
and preset `none` unless specified. After configuration, `aih start proxy` reuses
|
|
322
|
+
saved options, including the upstream. Use the dedicated `start proxy` /
|
|
323
|
+
`restart proxy` forms for `--listen`, `--preset` and other proxy options.
|
|
324
|
+
|
|
253
325
|
If the proxy is already running with different options, use `aih restart proxy`
|
|
254
|
-
|
|
326
|
+
to apply changes, for example `aih restart proxy --models "gpt-6-astra"`.
|
|
327
|
+
Omitted proxy options retain their saved values.
|
|
255
328
|
|
|
256
329
|
`aih start` (also `aih up` and starts targeting individual services) checks npm's
|
|
257
330
|
`latest` release of `@drakonkat/ai-helper`. If a newer version exists, it prints
|
|
@@ -296,6 +369,9 @@ aih logs agentmemory -n 100
|
|
|
296
369
|
|
|
297
370
|
# Stream logs in real-time (like tail -f)
|
|
298
371
|
aih logs ocx -f
|
|
372
|
+
|
|
373
|
+
# Long options and equals syntax
|
|
374
|
+
aih logs proxy --lines=100 --follow
|
|
299
375
|
```
|
|
300
376
|
|
|
301
377
|
---
|
|
@@ -305,6 +381,26 @@ aih logs ocx -f
|
|
|
305
381
|
Requires **Node.js 20.19+** (also on PATH when using the Bun CLI or compiled executable).
|
|
306
382
|
Use **Node.js 24+ for Codex**, whose Zstandard request compression needs Node.js 22.15+.
|
|
307
383
|
|
|
384
|
+
### Proxy option values
|
|
385
|
+
|
|
386
|
+
Use `aih start proxy <upstream> [options]` on first configuration, or
|
|
387
|
+
`aih restart proxy [upstream] [options]` to change it. The upstream is an HTTP(S)
|
|
388
|
+
destination, for example `http://127.0.0.1:10100/`. Unspecified values reuse saved
|
|
389
|
+
options; defaults in this table apply when no saved value exists.
|
|
390
|
+
|
|
391
|
+
| Option and example value | Meaning / default |
|
|
392
|
+
| --- | --- |
|
|
393
|
+
| `--listen http://127.0.0.1:10102` | Loopback HTTP listener; default `http://127.0.0.1:10101`. |
|
|
394
|
+
| `--preset headroom-pxpipe` | Pipeline; default `none`. Choices: `none`, `pxpipe`, `headroom`, `rtk`, `headroom-pxpipe`, `rtk-pxpipe`, `rtk-headroom-pxpipe`. |
|
|
395
|
+
| `--models "gpt-6-astra,anthropic/claude-fable*"` | pxpipe model selection; `--models=` restores pxpipe's defaults. Also accepted by generic `start`/`up`. |
|
|
396
|
+
| `--interceptor "./my hooks/interceptor.mjs"` | Custom JavaScript hooks, loaded at startup; default none. `--interceptor=` clears the saved path. |
|
|
397
|
+
| `--headroom-url http://127.0.0.1:8787` | Headroom compression service; default shown. |
|
|
398
|
+
| `--rtk-filter grep` | Fixed RTK filter for matching tool output; default auto-detection. `--rtk-filter=` resets it. |
|
|
399
|
+
| `--max-body-bytes 67108864` | Buffered HTTP / WebSocket limit in bytes; default 64 MiB. |
|
|
400
|
+
| `--json` | Emit the proxy start/restart result as JSON. |
|
|
401
|
+
|
|
402
|
+
String options accept both `--option value` and `--option=value`.
|
|
403
|
+
|
|
308
404
|
### Start a compression pipeline
|
|
309
405
|
|
|
310
406
|
For a local OpenCodex upstream on port `10100`, with the aih listener on `10102`:
|
|
@@ -420,9 +516,10 @@ aih restart proxy --models "gpt-5.5,gpt-5.6*,gpt-6-astra,google-antigravity/gemi
|
|
|
420
516
|
aih restart proxy --models=
|
|
421
517
|
```
|
|
422
518
|
|
|
423
|
-
An explicit list **replaces** the saved list.
|
|
424
|
-
|
|
425
|
-
|
|
519
|
+
An explicit list **replaces** the saved list. A trailing `*` matches a prefix:
|
|
520
|
+
`anthropic/claude-fable*` includes `anthropic/claude-fable-5-1`. Other wildcard
|
|
521
|
+
positions are unsupported; use the exact IDs from your client's model catalog.
|
|
522
|
+
Selecting a model allows compression but does not force it: pxpipe can leave short or unprofitable
|
|
426
523
|
requests unchanged. The upstream must support the selected model/API format.
|
|
427
524
|
|
|
428
525
|
### Transport and lifecycle
|
|
@@ -451,7 +548,8 @@ listening and the interceptor has loaded. One proxy is managed at a time;
|
|
|
451
548
|
`restart proxy <upstream> [options]` changes its configuration. Omitted options
|
|
452
549
|
reuse the last successful configuration, stored in `~/.aih/state.json`.
|
|
453
550
|
Use `--interceptor=` to clear an interceptor. Once configured, the proxy also
|
|
454
|
-
participates in unqualified `
|
|
551
|
+
participates in unqualified `stop`, `restart` and `status` commands. Unqualified
|
|
552
|
+
`start` applies the [default startup options](#3-start-services) described above.
|
|
455
553
|
|
|
456
554
|
HTTP methods, paths, queries, authentication headers, status codes, cookies and
|
|
457
555
|
payload bytes are forwarded. SSE stays streaming, with backpressure and upstream
|
|
@@ -637,7 +735,8 @@ Requests are never retried automatically.
|
|
|
637
735
|
|
|
638
736
|
## 🤖 Programmatic JSON API
|
|
639
737
|
|
|
640
|
-
For AI agents, scripts, and CI/CD pipelines,
|
|
738
|
+
For AI agents, scripts, and CI/CD pipelines, `status`, `start`/`up`, `restart`,
|
|
739
|
+
`update` and `stats proxy` support `--json`:
|
|
641
740
|
|
|
642
741
|
```bash
|
|
643
742
|
aih status --json
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@drakonkat/ai-helper",
|
|
3
|
-
"version": "1.2.
|
|
3
|
+
"version": "1.2.8",
|
|
4
4
|
"description": "Zero-config background service manager, auto-discovery daemon & dashboard launcher for AI agent ecosystems (pxpipe, ocx, agentmemory, headroom)",
|
|
5
5
|
"main": "src/index.js",
|
|
6
6
|
"module": "src/index.js",
|
package/src/index.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { APP_NAME, CLI_NAME, SERVICES, SERVICE_IDS, VERSION } from "./config.js";
|
|
2
2
|
import { manager } from "./manager.js";
|
|
3
|
-
import { checkForUpdates } from "./update.js";
|
|
3
|
+
import { checkForUpdates, updateSelf } from "./update.js";
|
|
4
4
|
import { readProxyStats, proxyStatsLines } from "./proxy-stats.js";
|
|
5
5
|
import {
|
|
6
6
|
badgeStatus,
|
|
@@ -23,46 +23,74 @@ import { parseArgs } from "node:util";
|
|
|
23
23
|
function printHelp() {
|
|
24
24
|
printBanner();
|
|
25
25
|
console.log(`${bold("USAGE:")}
|
|
26
|
-
${cyan(CLI_NAME)} ${yellow("<command>")} [
|
|
26
|
+
${cyan(CLI_NAME)} ${yellow("<command>")} [services...] [options]
|
|
27
|
+
${cyan(CLI_NAME)} start proxy <http(s)://upstream> [proxy-options]
|
|
28
|
+
${cyan(CLI_NAME)} restart proxy [http(s)://upstream] [proxy-options]
|
|
27
29
|
|
|
28
30
|
${bold("COMMANDS:")}
|
|
29
|
-
${yellow("status")}, ${yellow("ps")}
|
|
30
|
-
${yellow("status -ui")}
|
|
31
|
-
${yellow("open")}, ${yellow("dash")} [services...]
|
|
32
|
-
${yellow("start")}, ${yellow("up")} [services...]
|
|
33
|
-
${yellow("start proxy")}
|
|
31
|
+
${yellow("status")}, ${yellow("ps")} [services...] Show status, PID, uptime, dashboards and repositories
|
|
32
|
+
${yellow("status -ui")} Interactive live dashboard: manage services and watch the AI pipeline
|
|
33
|
+
${yellow("open")}, ${yellow("dash")} [services...] Open web dashboard(s) directly in your default browser
|
|
34
|
+
${yellow("start")}, ${yellow("up")} [services...] Start ocx, agentmemory and the pxpipe proxy, or specified services
|
|
35
|
+
${yellow("start proxy")} [upstream] Start HTTP/SSE/WebSocket proxy; first start requires upstream
|
|
34
36
|
${yellow("stop")}, ${yellow("down")} [services...] Stop all or specified services
|
|
35
|
-
${yellow("restart")} [services...]
|
|
36
|
-
${yellow("
|
|
37
|
-
${yellow("
|
|
37
|
+
${yellow("restart")} [services...] Restart all or specified services
|
|
38
|
+
${yellow("restart proxy")} [upstream] Restart proxy, overriding only the supplied options
|
|
39
|
+
${yellow("update")} Update aih itself to the latest npm release
|
|
40
|
+
${yellow("update")} <services...> Update the specified managed services
|
|
41
|
+
${yellow("<service> update")} Update one service (for example: aih ocx update)
|
|
38
42
|
${yellow("logs")} <service> [-n 50] [-f] View or stream live logs for a service
|
|
39
|
-
${yellow("stats proxy")} [--json]
|
|
40
|
-
${yellow("
|
|
41
|
-
${yellow("
|
|
42
|
-
${yellow("
|
|
43
|
+
${yellow("stats proxy")} [--json] Show proxy token savings estimates and recent requests
|
|
44
|
+
${yellow("config")} pxpipe-models=<list> Save the proxy model list for future starts
|
|
45
|
+
${yellow("install")} Build standalone binary to ~/.local/bin and verify PATH
|
|
46
|
+
${yellow("version")}, ${yellow("-v")}, ${yellow("--version")} Show version information
|
|
47
|
+
${yellow("help")}, ${yellow("-h")}, ${yellow("--help")} Show this help message
|
|
48
|
+
|
|
49
|
+
Other aliases: status = ls/list; open = dashboard; logs = log.
|
|
50
|
+
Service lists use spaces: ocx agentmemory. Omitting the command shows status.
|
|
43
51
|
|
|
44
52
|
${bold("SERVICES MANAGED:")}
|
|
45
53
|
${SERVICE_IDS.map(id => {
|
|
46
54
|
const svc = SERVICES[id];
|
|
47
55
|
return ` ${cyan(svc.id.padEnd(14))} ${svc.description} ${dim(`(${svc.defaultUrl})`)}`;
|
|
48
56
|
}).join("\n")}
|
|
57
|
+
${cyan("proxy".padEnd(14))} Built-in HTTP/SSE/WebSocket proxy (no web dashboard)
|
|
49
58
|
|
|
50
59
|
${bold("OPTIONS:")}
|
|
51
|
-
${gray("-n, --lines <num>")} Number of log lines to show (default: 50)
|
|
52
|
-
${gray("-f, --follow")} Follow log output in real-time
|
|
53
|
-
${gray("--json")}
|
|
60
|
+
${gray("-n, --lines <num>")} Number of log lines to show (logs only; default: 50)
|
|
61
|
+
${gray("-f, --follow")} Follow log output in real-time (logs only)
|
|
62
|
+
${gray("--json")} JSON for status, start/up, restart, update and stats
|
|
54
63
|
${gray("--repo")} Open GitHub repositories instead of dashboards (open only)
|
|
55
|
-
${gray("--listen <http://host:port>")} Proxy loopback listening address
|
|
56
|
-
${gray("--interceptor <file.mjs>")} Proxy JavaScript hooks (loaded at startup)
|
|
57
|
-
${gray("--preset <name>")} pxpipe | headroom | rtk | headroom-pxpipe | rtk-pxpipe | rtk-headroom-pxpipe | none
|
|
58
|
-
${gray("--models <list>")} pxpipe model allowlist, comma-separated (trailing * supported)
|
|
59
|
-
${gray("--headroom-url <url>")} Headroom service (default: http://127.0.0.1:8787)
|
|
60
|
-
${gray("--rtk-filter <name>")} Fixed rtk pipe filter (default: auto-detect)
|
|
61
|
-
${gray("--max-body-bytes <num>")} Proxy buffered request / WebSocket limit (default: 67108864)
|
|
62
64
|
${gray("-ui, --ui")} Open the interactive dashboard (status only, requires a TTY)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
65
|
+
${gray("--models <list>")} pxpipe model allowlist (start/up and start/up/restart proxy)
|
|
66
|
+
|
|
67
|
+
${bold("PROXY OPTIONS (start/up/restart proxy):")}
|
|
68
|
+
Put proxy immediately after the command, then the upstream URL and options.
|
|
69
|
+
${gray("--listen <url>")} HTTP loopback address (fresh default: http://127.0.0.1:10101)
|
|
70
|
+
${gray("--interceptor <file.mjs>")} JavaScript hooks loaded at startup; quote paths with spaces
|
|
71
|
+
${gray("--preset <name>")} pxpipe | headroom | rtk | headroom-pxpipe | rtk-pxpipe |
|
|
72
|
+
rtk-headroom-pxpipe | none (fresh default: none)
|
|
73
|
+
${gray("--headroom-url <url>")} Headroom service (default: http://127.0.0.1:8787)
|
|
74
|
+
${gray("--rtk-filter <name>")} Fixed rtk pipe filter; --rtk-filter= restores auto-detection
|
|
75
|
+
${gray("--max-body-bytes <num>")} Positive integer; buffered request / WebSocket limit
|
|
76
|
+
(default: 67108864 bytes = 64 MiB)
|
|
77
|
+
Saved proxy options are reused when omitted. To change a running proxy, use restart proxy.
|
|
78
|
+
|
|
79
|
+
${bold("START DEFAULTS AND MODEL VALUES:")}
|
|
80
|
+
Without service targets, start/up launches ocx, agentmemory, then proxy with:
|
|
81
|
+
upstream: http://127.0.0.1:10100/ listen: http://127.0.0.1:10102 preset: pxpipe
|
|
82
|
+
models: gpt-6-astra,google-antigravity/gemini-3.8*,anthropic/claude-fable*
|
|
83
|
+
config pxpipe-models=<list> saves a replacement list; --models overrides it.
|
|
84
|
+
Model names are comma-separated; a trailing * matches a prefix (include provider names).
|
|
85
|
+
All models are forwarded; the list selects which ones pxpipe may process.
|
|
86
|
+
Value options accept --flag value or --flag=value. Quote lists, wildcards and spaced paths.
|
|
87
|
+
--models= restores pxpipe's default model selection; --models "" also works if the shell
|
|
88
|
+
preserves empty arguments. Bare --models without a value is an error.
|
|
89
|
+
|
|
90
|
+
${bold("SELF AND SERVICE UPDATES:")}
|
|
91
|
+
'update' without targets updates aih's global npm installation, not managed services.
|
|
92
|
+
Standalone executables must be rebuilt; npm updates do not replace them.
|
|
93
|
+
To update all managed services: aih update pxpipe ocx agentmemory headroom
|
|
66
94
|
In the live dashboard, select a service with up/down and press u to update it.
|
|
67
95
|
Only running services are restarted; stopped services stay stopped.
|
|
68
96
|
|
|
@@ -70,17 +98,37 @@ ${bold("CODEX CONFIGURATION:")}
|
|
|
70
98
|
Starting aih's proxy, or ocx with an active proxy, updates Codex's two base URLs.
|
|
71
99
|
Respects CODEX_HOME; set AIH_CODEX_AUTOCONFIG=0 to leave config.toml untouched.
|
|
72
100
|
|
|
73
|
-
${bold("EXAMPLES:")}
|
|
74
|
-
${dim("$")} ${cyan("npx ai-helper")} status
|
|
75
|
-
${dim("$")} ${cyan(CLI_NAME)}
|
|
76
|
-
${dim("$")} ${cyan(CLI_NAME)}
|
|
101
|
+
${bold("EXAMPLES - STATUS, DASHBOARDS AND LOGS:")}
|
|
102
|
+
${dim("$")} ${cyan("npx @drakonkat/ai-helper")} status
|
|
103
|
+
${dim("$")} ${cyan(CLI_NAME)} status ocx proxy --json
|
|
104
|
+
${dim("$")} ${cyan(CLI_NAME)} status --ui
|
|
105
|
+
${dim("$")} ${cyan(CLI_NAME)} open agentmemory
|
|
106
|
+
${dim("$")} ${cyan(CLI_NAME)} open ocx proxy --repo
|
|
107
|
+
${dim("$")} ${cyan(CLI_NAME)} logs proxy --lines 100 --follow
|
|
108
|
+
${dim("$")} ${cyan(CLI_NAME)} logs ocx -n=20
|
|
109
|
+
${dim("$")} ${cyan(CLI_NAME)} stats proxy --json
|
|
110
|
+
|
|
111
|
+
${bold("EXAMPLES - START, STOP AND UPDATE:")}
|
|
77
112
|
${dim("$")} ${cyan(CLI_NAME)} start
|
|
78
|
-
${dim("$")} ${cyan(CLI_NAME)}
|
|
79
|
-
${dim("$")} ${cyan(CLI_NAME)}
|
|
80
|
-
${dim("$")} ${cyan(CLI_NAME)}
|
|
113
|
+
${dim("$")} ${cyan(CLI_NAME)} config pxpipe-models="gpt-6-astra,claude-opus-5-5"
|
|
114
|
+
${dim("$")} ${cyan(CLI_NAME)} start --models "gpt-6-astra,anthropic/claude-fable*" --json
|
|
115
|
+
${dim("$")} ${cyan(CLI_NAME)} up --models="google-antigravity/gemini-3.8*"
|
|
116
|
+
${dim("$")} ${cyan(CLI_NAME)} start --models= ${dim("# Use pxpipe's default model selection")}
|
|
117
|
+
${dim("$")} ${cyan(CLI_NAME)} start ocx agentmemory
|
|
118
|
+
${dim("$")} ${cyan(CLI_NAME)} stop ocx agentmemory proxy
|
|
119
|
+
${dim("$")} ${cyan(CLI_NAME)} restart ocx --json
|
|
120
|
+
${dim("$")} ${cyan(CLI_NAME)} update ${dim("# Update aih itself from npm")}
|
|
81
121
|
${dim("$")} ${cyan(CLI_NAME)} ocx update
|
|
82
122
|
${dim("$")} ${cyan(CLI_NAME)} update ocx agentmemory --json
|
|
83
|
-
${dim("$")} ${cyan(CLI_NAME)}
|
|
123
|
+
${dim("$")} ${cyan(CLI_NAME)} install ${dim("# Build/install standalone binary; requires Bun")}
|
|
124
|
+
|
|
125
|
+
${bold("EXAMPLES - PROXY CONFIGURATION:")}
|
|
126
|
+
${dim("$")} ${cyan(CLI_NAME)} start proxy http://127.0.0.1:10100/ --listen http://127.0.0.1:10102 --preset pxpipe --models "gpt-6-astra,anthropic/claude-fable*"
|
|
127
|
+
${dim("$")} ${cyan(CLI_NAME)} restart proxy --models "google-antigravity/gemini-3.8*"
|
|
128
|
+
${dim("$")} ${cyan(CLI_NAME)} restart proxy --preset headroom-pxpipe --headroom-url http://127.0.0.1:8787
|
|
129
|
+
${dim("$")} ${cyan(CLI_NAME)} restart proxy --preset rtk-pxpipe --rtk-filter git-diff
|
|
130
|
+
${dim("$")} ${cyan(CLI_NAME)} restart proxy --models= --rtk-filter=
|
|
131
|
+
${dim("$")} ${cyan(CLI_NAME)} restart proxy --interceptor "./my hooks/interceptor.mjs" --max-body-bytes=33554432
|
|
84
132
|
`);
|
|
85
133
|
}
|
|
86
134
|
|
|
@@ -156,7 +204,7 @@ async function runInstall() {
|
|
|
156
204
|
}
|
|
157
205
|
}
|
|
158
206
|
|
|
159
|
-
export async function main() {
|
|
207
|
+
export async function main({ updateSelfImpl = updateSelf } = {}) {
|
|
160
208
|
const rawArgs = process.argv.slice(2);
|
|
161
209
|
|
|
162
210
|
if (["start", "up", "restart"].includes(rawArgs[0]) && rawArgs[1] === "proxy" && !rawArgs.includes("--help") && !rawArgs.includes("-h")) {
|
|
@@ -238,8 +286,18 @@ export async function main() {
|
|
|
238
286
|
const targets = serviceFirstUpdate ? [positionalArgs[0].toLowerCase()] : positionalArgs.slice(1);
|
|
239
287
|
|
|
240
288
|
switch (command) {
|
|
289
|
+
case "config": {
|
|
290
|
+
if (targets.length !== 1 || !targets[0].startsWith("pxpipe-models=") || rawArgs.some(arg => arg.startsWith("-"))) {
|
|
291
|
+
throw new Error('Usage: aih config pxpipe-models="model1,model2" (use pxpipe-models= for pxpipe defaults)');
|
|
292
|
+
}
|
|
293
|
+
const state = manager.readState();
|
|
294
|
+
state.config = { ...state.config, pxpipeModels: targets[0].slice("pxpipe-models=".length) };
|
|
295
|
+
manager.saveState(state);
|
|
296
|
+
console.log(green(`Saved pxpipe-models=${state.config.pxpipeModels}; applies on the next proxy start or restart.`));
|
|
297
|
+
break;
|
|
298
|
+
}
|
|
241
299
|
case "update": {
|
|
242
|
-
const ids = [...new Set(targets
|
|
300
|
+
const ids = [...new Set(targets)];
|
|
243
301
|
const invalid = ids.filter(id => !SERVICE_IDS.includes(id));
|
|
244
302
|
const invalidOption = rawArgs.find(arg => arg.startsWith("-") && arg !== "--json");
|
|
245
303
|
let results;
|
|
@@ -251,16 +309,16 @@ export async function main() {
|
|
|
251
309
|
results = [{ id: targets[0], success: false, message: `Usage: ${CLI_NAME} <service> update [--json]; use '${CLI_NAME} update <services...>' for multiple services.` }];
|
|
252
310
|
} else if (invalid.length) {
|
|
253
311
|
results = invalid.map(id => ({ id, success: false, message: id === "proxy"
|
|
254
|
-
? "The built-in proxy is updated with ai-helper itself;
|
|
312
|
+
? "The built-in proxy is updated with ai-helper itself; run 'aih update' or rebuild its standalone executable."
|
|
255
313
|
: `Unsupported service '${id}'. Updatable services: ${SERVICE_IDS.join(", ")}.` }));
|
|
256
314
|
} else {
|
|
257
315
|
if (!jsonOutput) printBanner();
|
|
258
316
|
results = [];
|
|
259
|
-
for (const id of ids) {
|
|
317
|
+
for (const id of ids.length ? ids : [CLI_NAME]) {
|
|
260
318
|
if (!jsonOutput) process.stdout.write(` Updating ${bold(id)}... `);
|
|
261
319
|
let result;
|
|
262
320
|
try {
|
|
263
|
-
result = await manager.updateService(id);
|
|
321
|
+
result = id === CLI_NAME ? await updateSelfImpl() : await manager.updateService(id);
|
|
264
322
|
} catch (err) {
|
|
265
323
|
result = { success: false, message: err?.message || String(err) };
|
|
266
324
|
}
|
|
@@ -382,7 +440,7 @@ export async function main() {
|
|
|
382
440
|
upstream: "http://127.0.0.1:10100/",
|
|
383
441
|
listen: "http://127.0.0.1:10102",
|
|
384
442
|
preset: "pxpipe",
|
|
385
|
-
models: models ?? "gpt-6-astra,google-antigravity/gemini-3.8*,anthropic/claude-fable*",
|
|
443
|
+
models: models ?? manager.readState().config?.pxpipeModels ?? "gpt-6-astra,google-antigravity/gemini-3.8*,anthropic/claude-fable*",
|
|
386
444
|
} : id === "proxy" && models !== undefined ? { models } : undefined);
|
|
387
445
|
results.push({ id, ...res });
|
|
388
446
|
if (jsonOutput) continue;
|
package/src/manager.js
CHANGED
|
@@ -399,7 +399,11 @@ export class ServiceManager {
|
|
|
399
399
|
async startProxyService(options) {
|
|
400
400
|
const state = this.loadState();
|
|
401
401
|
const current = state.services.proxy;
|
|
402
|
-
const config = normalizeProxyOptions({
|
|
402
|
+
const config = normalizeProxyOptions({
|
|
403
|
+
...current?.proxyOptions,
|
|
404
|
+
...(state.config?.pxpipeModels !== undefined ? { models: state.config.pxpipeModels } : {}),
|
|
405
|
+
...options,
|
|
406
|
+
});
|
|
403
407
|
if (current?.status === "running" && isPidRunning(current.pid)) {
|
|
404
408
|
if (JSON.stringify(config) !== JSON.stringify(current.proxyOptions)) {
|
|
405
409
|
throw new Error("Proxy is already running with different options; use 'aih restart proxy <upstream> [options]'");
|
package/src/service-updates.js
CHANGED
|
@@ -1,8 +1,6 @@
|
|
|
1
|
-
import { spawn } from "node:child_process";
|
|
2
|
-
import { closeSync, openSync, writeSync } from "node:fs";
|
|
3
1
|
import { SERVICE_PACKAGES, SERVICES } from "./config.js";
|
|
4
2
|
import { compareVersions } from "./utils/versions.js";
|
|
5
|
-
import {
|
|
3
|
+
import { npmUpdateInvocation, runUpdateInstaller } from "./utils/update-installer.js";
|
|
6
4
|
|
|
7
5
|
/** Only allowlisted services/arguments reach an installer; never execute user input. */
|
|
8
6
|
export function serviceUpdateInvocation(id, platform = process.platform) {
|
|
@@ -11,12 +9,7 @@ export function serviceUpdateInvocation(id, platform = process.platform) {
|
|
|
11
9
|
// Headroom detects its own Python environment (uv, pipx, pip/venv).
|
|
12
10
|
// Do not run an arbitrary `pip` from PATH against a different interpreter.
|
|
13
11
|
if (pkg.pypi) return { command: "headroom", args: ["update", "--yes"] };
|
|
14
|
-
|
|
15
|
-
// npm.cmd cannot be spawned directly on Windows. These are fixed arguments,
|
|
16
|
-
// not paths or user-provided shell text; no shell is used on Unix.
|
|
17
|
-
return platform === "win32"
|
|
18
|
-
? { command: "cmd.exe", args: ["/d", "/s", "/c", `npm ${args.join(" ")}`] }
|
|
19
|
-
: { command: "npm", args };
|
|
12
|
+
return npmUpdateInvocation(pkg.name, platform);
|
|
20
13
|
}
|
|
21
14
|
|
|
22
15
|
/** Pin npx after an explicit update, so a project's old dependency/cache cannot win. */
|
|
@@ -30,39 +23,6 @@ export function serviceStartCommand(id, state) {
|
|
|
30
23
|
}
|
|
31
24
|
|
|
32
25
|
/** Capture installer output, keeping --json/TUI clean and full diagnostics in the service log. */
|
|
33
|
-
export function installServiceUpdate(id, { spawnImpl
|
|
34
|
-
|
|
35
|
-
ensureDir(getLogsDir());
|
|
36
|
-
const logPath = getServiceLogPath(id);
|
|
37
|
-
const fd = openSync(logPath, "a");
|
|
38
|
-
writeSync(fd, `\n[aih] Update ${new Date().toISOString()}: ${command} ${args.join(" ")}\n`);
|
|
39
|
-
return new Promise(resolve => {
|
|
40
|
-
let tail = "";
|
|
41
|
-
let finished = false;
|
|
42
|
-
const finish = (exitCode, message) => {
|
|
43
|
-
if (finished) return;
|
|
44
|
-
finished = true;
|
|
45
|
-
closeSync(fd);
|
|
46
|
-
resolve({ success: exitCode === 0, exitCode, logPath,
|
|
47
|
-
message: message || (exitCode === 0 ? "Installer completed" : `Installer failed (${exitCode}): ${tail.trim() || "no output"}`) });
|
|
48
|
-
};
|
|
49
|
-
const collect = data => {
|
|
50
|
-
// Bound memory, not the log: package managers can produce many megabytes.
|
|
51
|
-
const text = String(data);
|
|
52
|
-
tail = (tail + text).slice(-4000);
|
|
53
|
-
if (!finished) { try { writeSync(fd, text); } catch {} }
|
|
54
|
-
};
|
|
55
|
-
try {
|
|
56
|
-
const child = spawnImpl(command, args, {
|
|
57
|
-
windowsHide: true, stdio: ["ignore", "pipe", "pipe"],
|
|
58
|
-
env: { ...process.env, CI: "1", npm_config_yes: "true", PIP_NO_INPUT: "1", NO_COLOR: "1" },
|
|
59
|
-
});
|
|
60
|
-
child.stdout?.on("data", collect);
|
|
61
|
-
child.stderr?.on("data", collect);
|
|
62
|
-
child.once("error", error => finish(1, `Cannot update '${id}': ${error.message}`));
|
|
63
|
-
// `close`, not `exit`: Headroom on Windows hands pip off to a child that
|
|
64
|
-
// inherits these pipes. Wait for that installer too before restarting.
|
|
65
|
-
child.once("close", (code, signal) => finish(code ?? 1, signal ? `Installer terminated by ${signal}` : undefined));
|
|
66
|
-
} catch (error) { finish(1, error.message); }
|
|
67
|
-
});
|
|
26
|
+
export function installServiceUpdate(id, { spawnImpl, platform = process.platform } = {}) {
|
|
27
|
+
return runUpdateInstaller(id, serviceUpdateInvocation(id, platform), { spawnImpl });
|
|
68
28
|
}
|
package/src/update.js
CHANGED
|
@@ -1,4 +1,14 @@
|
|
|
1
1
|
import { PACKAGE_NAME, VERSION } from "./config.js";
|
|
2
|
+
import { npmUpdateInvocation, runUpdateInstaller } from "./utils/update-installer.js";
|
|
3
|
+
|
|
4
|
+
/** Update only the global npm installation; managed services are left untouched. */
|
|
5
|
+
export async function updateSelf({ spawnImpl, platform = process.platform } = {}) {
|
|
6
|
+
const result = await runUpdateInstaller("aih", npmUpdateInvocation(PACKAGE_NAME, platform), { spawnImpl });
|
|
7
|
+
return { ...result, package: PACKAGE_NAME,
|
|
8
|
+
message: result.success
|
|
9
|
+
? `Global npm installation of ${PACKAGE_NAME} updated to latest. Run aih --version to verify; standalone executables still require a rebuild.`
|
|
10
|
+
: result.message };
|
|
11
|
+
}
|
|
2
12
|
|
|
3
13
|
export function isNewerVersion(latest, current) {
|
|
4
14
|
const parse = value => typeof value === "string"
|
|
@@ -33,7 +43,7 @@ export async function checkForUpdates({ fetchImpl = globalThis.fetch, notify = c
|
|
|
33
43
|
if (!response.ok) return;
|
|
34
44
|
const { version } = await response.json();
|
|
35
45
|
if (isNewerVersion(version, VERSION)) {
|
|
36
|
-
notify(`[aih] Update available: ${VERSION} -> ${version}. Run: npm install -g ${PACKAGE_NAME}@latest`);
|
|
46
|
+
notify(`[aih] Update available: ${VERSION} -> ${version}. Run: aih update (or: npm install -g ${PACKAGE_NAME}@latest)`);
|
|
37
47
|
}
|
|
38
48
|
} catch {
|
|
39
49
|
// An unavailable registry must not prevent services from starting.
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
import { spawn } from "node:child_process";
|
|
2
|
+
import { closeSync, openSync, writeSync } from "node:fs";
|
|
3
|
+
import { ensureDir, getLogsDir, getServiceLogPath } from "./path.js";
|
|
4
|
+
|
|
5
|
+
/** Call only with package names from config, never user-provided shell text. */
|
|
6
|
+
export function npmUpdateInvocation(packageName, platform = process.platform) {
|
|
7
|
+
const args = ["install", "--global", `${packageName}@latest`, "--no-audit", "--no-fund"];
|
|
8
|
+
// npm.cmd cannot be spawned directly on Windows. These are fixed arguments,
|
|
9
|
+
// not paths or user-provided shell text; no shell is used on Unix.
|
|
10
|
+
return platform === "win32"
|
|
11
|
+
? { command: "cmd.exe", args: ["/d", "/s", "/c", `npm ${args.join(" ")}`] }
|
|
12
|
+
: { command: "npm", args };
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** Capture installer output, keeping --json/TUI clean and full diagnostics in the log. */
|
|
16
|
+
export function runUpdateInstaller(id, { command, args }, { spawnImpl = spawn } = {}) {
|
|
17
|
+
ensureDir(getLogsDir());
|
|
18
|
+
const logPath = getServiceLogPath(id);
|
|
19
|
+
const fd = openSync(logPath, "a");
|
|
20
|
+
writeSync(fd, `\n[aih] Update ${new Date().toISOString()}: ${command} ${args.join(" ")}\n`);
|
|
21
|
+
return new Promise(resolve => {
|
|
22
|
+
let tail = "";
|
|
23
|
+
let finished = false;
|
|
24
|
+
const finish = (exitCode, message) => {
|
|
25
|
+
if (finished) return;
|
|
26
|
+
finished = true;
|
|
27
|
+
closeSync(fd);
|
|
28
|
+
resolve({ success: exitCode === 0, exitCode, logPath,
|
|
29
|
+
message: message || (exitCode === 0 ? "Installer completed" : `Installer failed (${exitCode}): ${tail.trim() || "no output"}`) });
|
|
30
|
+
};
|
|
31
|
+
const collect = data => {
|
|
32
|
+
// Bound memory, not the log: package managers can produce many megabytes.
|
|
33
|
+
const text = String(data);
|
|
34
|
+
tail = (tail + text).slice(-4000);
|
|
35
|
+
if (!finished) { try { writeSync(fd, text); } catch {} }
|
|
36
|
+
};
|
|
37
|
+
try {
|
|
38
|
+
const child = spawnImpl(command, args, {
|
|
39
|
+
windowsHide: true, stdio: ["ignore", "pipe", "pipe"],
|
|
40
|
+
env: { ...process.env, CI: "1", npm_config_yes: "true", PIP_NO_INPUT: "1", NO_COLOR: "1" },
|
|
41
|
+
});
|
|
42
|
+
child.stdout?.on("data", collect);
|
|
43
|
+
child.stderr?.on("data", collect);
|
|
44
|
+
child.once("error", error => finish(1, `Cannot update '${id}': ${error.message}`));
|
|
45
|
+
// `close`, not `exit`: Headroom on Windows hands pip off to a child that
|
|
46
|
+
// inherits these pipes. Wait for that installer too before restarting.
|
|
47
|
+
child.once("close", (code, signal) => finish(signal ? 1 : (code ?? 1), signal ? `Installer terminated by ${signal}` : undefined));
|
|
48
|
+
} catch (error) { finish(1, error.message); }
|
|
49
|
+
});
|
|
50
|
+
}
|