@drakonkat/ai-helper 1.2.6 → 1.2.7
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 +96 -10
- package/package.json +1 -1
- package/src/index.js +86 -40
- package/src/service-updates.js +4 -44
- package/src/update.js +11 -1
- package/src/utils/update-installer.js +50 -0
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,26 @@ 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
|
+
The value is passed only to the built-in proxy; `ocx` and `agentmemory` start
|
|
300
|
+
normally. `--models=` passes an empty string; `--models ""` also works when your
|
|
301
|
+
shell preserves empty arguments. A bare `--models` without a value is an error.
|
|
302
|
+
See [Select models](#select-models) for matching and compression behavior.
|
|
303
|
+
|
|
304
|
+
The no-target `start`/`up` commands supply the upstream, listener and preset above
|
|
305
|
+
on every invocation, plus that model list unless `--models` overrides it.
|
|
306
|
+
Other saved proxy options are retained.
|
|
307
|
+
A first `aih start proxy <upstream>` instead uses listener `http://127.0.0.1:10101`
|
|
308
|
+
and preset `none` unless specified. After configuration, `aih start proxy` reuses
|
|
309
|
+
saved options, including the upstream. Use the dedicated `start proxy` /
|
|
310
|
+
`restart proxy` forms for `--listen`, `--preset` and other proxy options.
|
|
311
|
+
|
|
253
312
|
If the proxy is already running with different options, use `aih restart proxy`
|
|
254
|
-
|
|
313
|
+
to apply changes, for example `aih restart proxy --models "gpt-6-astra"`.
|
|
314
|
+
Omitted proxy options retain their saved values.
|
|
255
315
|
|
|
256
316
|
`aih start` (also `aih up` and starts targeting individual services) checks npm's
|
|
257
317
|
`latest` release of `@drakonkat/ai-helper`. If a newer version exists, it prints
|
|
@@ -296,6 +356,9 @@ aih logs agentmemory -n 100
|
|
|
296
356
|
|
|
297
357
|
# Stream logs in real-time (like tail -f)
|
|
298
358
|
aih logs ocx -f
|
|
359
|
+
|
|
360
|
+
# Long options and equals syntax
|
|
361
|
+
aih logs proxy --lines=100 --follow
|
|
299
362
|
```
|
|
300
363
|
|
|
301
364
|
---
|
|
@@ -305,6 +368,26 @@ aih logs ocx -f
|
|
|
305
368
|
Requires **Node.js 20.19+** (also on PATH when using the Bun CLI or compiled executable).
|
|
306
369
|
Use **Node.js 24+ for Codex**, whose Zstandard request compression needs Node.js 22.15+.
|
|
307
370
|
|
|
371
|
+
### Proxy option values
|
|
372
|
+
|
|
373
|
+
Use `aih start proxy <upstream> [options]` on first configuration, or
|
|
374
|
+
`aih restart proxy [upstream] [options]` to change it. The upstream is an HTTP(S)
|
|
375
|
+
destination, for example `http://127.0.0.1:10100/`. Unspecified values reuse saved
|
|
376
|
+
options; defaults in this table apply when no saved value exists.
|
|
377
|
+
|
|
378
|
+
| Option and example value | Meaning / default |
|
|
379
|
+
| --- | --- |
|
|
380
|
+
| `--listen http://127.0.0.1:10102` | Loopback HTTP listener; default `http://127.0.0.1:10101`. |
|
|
381
|
+
| `--preset headroom-pxpipe` | Pipeline; default `none`. Choices: `none`, `pxpipe`, `headroom`, `rtk`, `headroom-pxpipe`, `rtk-pxpipe`, `rtk-headroom-pxpipe`. |
|
|
382
|
+
| `--models "gpt-6-astra,anthropic/claude-fable*"` | pxpipe model selection; `--models=` restores pxpipe's defaults. Also accepted by generic `start`/`up`. |
|
|
383
|
+
| `--interceptor "./my hooks/interceptor.mjs"` | Custom JavaScript hooks, loaded at startup; default none. `--interceptor=` clears the saved path. |
|
|
384
|
+
| `--headroom-url http://127.0.0.1:8787` | Headroom compression service; default shown. |
|
|
385
|
+
| `--rtk-filter grep` | Fixed RTK filter for matching tool output; default auto-detection. `--rtk-filter=` resets it. |
|
|
386
|
+
| `--max-body-bytes 67108864` | Buffered HTTP / WebSocket limit in bytes; default 64 MiB. |
|
|
387
|
+
| `--json` | Emit the proxy start/restart result as JSON. |
|
|
388
|
+
|
|
389
|
+
String options accept both `--option value` and `--option=value`.
|
|
390
|
+
|
|
308
391
|
### Start a compression pipeline
|
|
309
392
|
|
|
310
393
|
For a local OpenCodex upstream on port `10100`, with the aih listener on `10102`:
|
|
@@ -420,9 +503,10 @@ aih restart proxy --models "gpt-5.5,gpt-5.6*,gpt-6-astra,google-antigravity/gemi
|
|
|
420
503
|
aih restart proxy --models=
|
|
421
504
|
```
|
|
422
505
|
|
|
423
|
-
An explicit list **replaces** the saved list.
|
|
424
|
-
|
|
425
|
-
|
|
506
|
+
An explicit list **replaces** the saved list. A trailing `*` matches a prefix:
|
|
507
|
+
`anthropic/claude-fable*` includes `anthropic/claude-fable-5-1`. Other wildcard
|
|
508
|
+
positions are unsupported; use the exact IDs from your client's model catalog.
|
|
509
|
+
Selecting a model allows compression but does not force it: pxpipe can leave short or unprofitable
|
|
426
510
|
requests unchanged. The upstream must support the selected model/API format.
|
|
427
511
|
|
|
428
512
|
### Transport and lifecycle
|
|
@@ -451,7 +535,8 @@ listening and the interceptor has loaded. One proxy is managed at a time;
|
|
|
451
535
|
`restart proxy <upstream> [options]` changes its configuration. Omitted options
|
|
452
536
|
reuse the last successful configuration, stored in `~/.aih/state.json`.
|
|
453
537
|
Use `--interceptor=` to clear an interceptor. Once configured, the proxy also
|
|
454
|
-
participates in unqualified `
|
|
538
|
+
participates in unqualified `stop`, `restart` and `status` commands. Unqualified
|
|
539
|
+
`start` applies the [default startup options](#3-start-services) described above.
|
|
455
540
|
|
|
456
541
|
HTTP methods, paths, queries, authentication headers, status codes, cookies and
|
|
457
542
|
payload bytes are forwarded. SSE stays streaming, with backpressure and upstream
|
|
@@ -637,7 +722,8 @@ Requests are never retried automatically.
|
|
|
637
722
|
|
|
638
723
|
## 🤖 Programmatic JSON API
|
|
639
724
|
|
|
640
|
-
For AI agents, scripts, and CI/CD pipelines,
|
|
725
|
+
For AI agents, scripts, and CI/CD pipelines, `status`, `start`/`up`, `restart`,
|
|
726
|
+
`update` and `stats proxy` support `--json`:
|
|
641
727
|
|
|
642
728
|
```bash
|
|
643
729
|
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.7",
|
|
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,73 @@ 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("install")}
|
|
41
|
-
${yellow("version")}, ${yellow("-v")}
|
|
42
|
-
${yellow("help")}, ${yellow("-h")}
|
|
43
|
+
${yellow("stats proxy")} [--json] Show proxy token savings estimates and recent requests
|
|
44
|
+
${yellow("install")} Build standalone binary to ~/.local/bin and verify PATH
|
|
45
|
+
${yellow("version")}, ${yellow("-v")}, ${yellow("--version")} Show version information
|
|
46
|
+
${yellow("help")}, ${yellow("-h")}, ${yellow("--help")} Show this help message
|
|
47
|
+
|
|
48
|
+
Other aliases: status = ls/list; open = dashboard; logs = log.
|
|
49
|
+
Service lists use spaces: ocx agentmemory. Omitting the command shows status.
|
|
43
50
|
|
|
44
51
|
${bold("SERVICES MANAGED:")}
|
|
45
52
|
${SERVICE_IDS.map(id => {
|
|
46
53
|
const svc = SERVICES[id];
|
|
47
54
|
return ` ${cyan(svc.id.padEnd(14))} ${svc.description} ${dim(`(${svc.defaultUrl})`)}`;
|
|
48
55
|
}).join("\n")}
|
|
56
|
+
${cyan("proxy".padEnd(14))} Built-in HTTP/SSE/WebSocket proxy (no web dashboard)
|
|
49
57
|
|
|
50
58
|
${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")}
|
|
59
|
+
${gray("-n, --lines <num>")} Number of log lines to show (logs only; default: 50)
|
|
60
|
+
${gray("-f, --follow")} Follow log output in real-time (logs only)
|
|
61
|
+
${gray("--json")} JSON for status, start/up, restart, update and stats
|
|
54
62
|
${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
63
|
${gray("-ui, --ui")} Open the interactive dashboard (status only, requires a TTY)
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
64
|
+
${gray("--models <list>")} pxpipe model allowlist (start/up and start/up/restart proxy)
|
|
65
|
+
|
|
66
|
+
${bold("PROXY OPTIONS (start/up/restart proxy):")}
|
|
67
|
+
Put proxy immediately after the command, then the upstream URL and options.
|
|
68
|
+
${gray("--listen <url>")} HTTP loopback address (fresh default: http://127.0.0.1:10101)
|
|
69
|
+
${gray("--interceptor <file.mjs>")} JavaScript hooks loaded at startup; quote paths with spaces
|
|
70
|
+
${gray("--preset <name>")} pxpipe | headroom | rtk | headroom-pxpipe | rtk-pxpipe |
|
|
71
|
+
rtk-headroom-pxpipe | none (fresh default: none)
|
|
72
|
+
${gray("--headroom-url <url>")} Headroom service (default: http://127.0.0.1:8787)
|
|
73
|
+
${gray("--rtk-filter <name>")} Fixed rtk pipe filter; --rtk-filter= restores auto-detection
|
|
74
|
+
${gray("--max-body-bytes <num>")} Positive integer; buffered request / WebSocket limit
|
|
75
|
+
(default: 67108864 bytes = 64 MiB)
|
|
76
|
+
Saved proxy options are reused when omitted. To change a running proxy, use restart proxy.
|
|
77
|
+
|
|
78
|
+
${bold("START DEFAULTS AND MODEL VALUES:")}
|
|
79
|
+
Without service targets, start/up launches ocx, agentmemory, then proxy with:
|
|
80
|
+
upstream: http://127.0.0.1:10100/ listen: http://127.0.0.1:10102 preset: pxpipe
|
|
81
|
+
models: gpt-6-astra,google-antigravity/gemini-3.8*,anthropic/claude-fable*
|
|
82
|
+
--models on start/up replaces this list for the proxy only.
|
|
83
|
+
Model names are comma-separated; a trailing * matches a prefix (include provider names).
|
|
84
|
+
All models are forwarded; the list selects which ones pxpipe may process.
|
|
85
|
+
Value options accept --flag value or --flag=value. Quote lists, wildcards and spaced paths.
|
|
86
|
+
--models= restores pxpipe's default model selection; --models "" also works if the shell
|
|
87
|
+
preserves empty arguments. Bare --models without a value is an error.
|
|
88
|
+
|
|
89
|
+
${bold("SELF AND SERVICE UPDATES:")}
|
|
90
|
+
'update' without targets updates aih's global npm installation, not managed services.
|
|
91
|
+
Standalone executables must be rebuilt; npm updates do not replace them.
|
|
92
|
+
To update all managed services: aih update pxpipe ocx agentmemory headroom
|
|
66
93
|
In the live dashboard, select a service with up/down and press u to update it.
|
|
67
94
|
Only running services are restarted; stopped services stay stopped.
|
|
68
95
|
|
|
@@ -70,17 +97,36 @@ ${bold("CODEX CONFIGURATION:")}
|
|
|
70
97
|
Starting aih's proxy, or ocx with an active proxy, updates Codex's two base URLs.
|
|
71
98
|
Respects CODEX_HOME; set AIH_CODEX_AUTOCONFIG=0 to leave config.toml untouched.
|
|
72
99
|
|
|
73
|
-
${bold("EXAMPLES:")}
|
|
74
|
-
${dim("$")} ${cyan("npx ai-helper")} status
|
|
75
|
-
${dim("$")} ${cyan(CLI_NAME)}
|
|
76
|
-
${dim("$")} ${cyan(CLI_NAME)}
|
|
100
|
+
${bold("EXAMPLES - STATUS, DASHBOARDS AND LOGS:")}
|
|
101
|
+
${dim("$")} ${cyan("npx @drakonkat/ai-helper")} status
|
|
102
|
+
${dim("$")} ${cyan(CLI_NAME)} status ocx proxy --json
|
|
103
|
+
${dim("$")} ${cyan(CLI_NAME)} status --ui
|
|
104
|
+
${dim("$")} ${cyan(CLI_NAME)} open agentmemory
|
|
105
|
+
${dim("$")} ${cyan(CLI_NAME)} open ocx proxy --repo
|
|
106
|
+
${dim("$")} ${cyan(CLI_NAME)} logs proxy --lines 100 --follow
|
|
107
|
+
${dim("$")} ${cyan(CLI_NAME)} logs ocx -n=20
|
|
108
|
+
${dim("$")} ${cyan(CLI_NAME)} stats proxy --json
|
|
109
|
+
|
|
110
|
+
${bold("EXAMPLES - START, STOP AND UPDATE:")}
|
|
77
111
|
${dim("$")} ${cyan(CLI_NAME)} start
|
|
78
|
-
${dim("$")} ${cyan(CLI_NAME)} start --models "gpt-6-astra,anthropic/claude-fable*"
|
|
79
|
-
${dim("$")} ${cyan(CLI_NAME)}
|
|
80
|
-
${dim("$")} ${cyan(CLI_NAME)}
|
|
112
|
+
${dim("$")} ${cyan(CLI_NAME)} start --models "gpt-6-astra,anthropic/claude-fable*" --json
|
|
113
|
+
${dim("$")} ${cyan(CLI_NAME)} up --models="google-antigravity/gemini-3.8*"
|
|
114
|
+
${dim("$")} ${cyan(CLI_NAME)} start --models= ${dim("# Use pxpipe's default model selection")}
|
|
115
|
+
${dim("$")} ${cyan(CLI_NAME)} start ocx agentmemory
|
|
116
|
+
${dim("$")} ${cyan(CLI_NAME)} stop ocx agentmemory proxy
|
|
117
|
+
${dim("$")} ${cyan(CLI_NAME)} restart ocx --json
|
|
118
|
+
${dim("$")} ${cyan(CLI_NAME)} update ${dim("# Update aih itself from npm")}
|
|
81
119
|
${dim("$")} ${cyan(CLI_NAME)} ocx update
|
|
82
120
|
${dim("$")} ${cyan(CLI_NAME)} update ocx agentmemory --json
|
|
83
|
-
${dim("$")} ${cyan(CLI_NAME)}
|
|
121
|
+
${dim("$")} ${cyan(CLI_NAME)} install ${dim("# Build/install standalone binary; requires Bun")}
|
|
122
|
+
|
|
123
|
+
${bold("EXAMPLES - PROXY CONFIGURATION:")}
|
|
124
|
+
${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*"
|
|
125
|
+
${dim("$")} ${cyan(CLI_NAME)} restart proxy --models "google-antigravity/gemini-3.8*"
|
|
126
|
+
${dim("$")} ${cyan(CLI_NAME)} restart proxy --preset headroom-pxpipe --headroom-url http://127.0.0.1:8787
|
|
127
|
+
${dim("$")} ${cyan(CLI_NAME)} restart proxy --preset rtk-pxpipe --rtk-filter git-diff
|
|
128
|
+
${dim("$")} ${cyan(CLI_NAME)} restart proxy --models= --rtk-filter=
|
|
129
|
+
${dim("$")} ${cyan(CLI_NAME)} restart proxy --interceptor "./my hooks/interceptor.mjs" --max-body-bytes=33554432
|
|
84
130
|
`);
|
|
85
131
|
}
|
|
86
132
|
|
|
@@ -156,7 +202,7 @@ async function runInstall() {
|
|
|
156
202
|
}
|
|
157
203
|
}
|
|
158
204
|
|
|
159
|
-
export async function main() {
|
|
205
|
+
export async function main({ updateSelfImpl = updateSelf } = {}) {
|
|
160
206
|
const rawArgs = process.argv.slice(2);
|
|
161
207
|
|
|
162
208
|
if (["start", "up", "restart"].includes(rawArgs[0]) && rawArgs[1] === "proxy" && !rawArgs.includes("--help") && !rawArgs.includes("-h")) {
|
|
@@ -239,7 +285,7 @@ export async function main() {
|
|
|
239
285
|
|
|
240
286
|
switch (command) {
|
|
241
287
|
case "update": {
|
|
242
|
-
const ids = [...new Set(targets
|
|
288
|
+
const ids = [...new Set(targets)];
|
|
243
289
|
const invalid = ids.filter(id => !SERVICE_IDS.includes(id));
|
|
244
290
|
const invalidOption = rawArgs.find(arg => arg.startsWith("-") && arg !== "--json");
|
|
245
291
|
let results;
|
|
@@ -251,16 +297,16 @@ export async function main() {
|
|
|
251
297
|
results = [{ id: targets[0], success: false, message: `Usage: ${CLI_NAME} <service> update [--json]; use '${CLI_NAME} update <services...>' for multiple services.` }];
|
|
252
298
|
} else if (invalid.length) {
|
|
253
299
|
results = invalid.map(id => ({ id, success: false, message: id === "proxy"
|
|
254
|
-
? "The built-in proxy is updated with ai-helper itself;
|
|
300
|
+
? "The built-in proxy is updated with ai-helper itself; run 'aih update' or rebuild its standalone executable."
|
|
255
301
|
: `Unsupported service '${id}'. Updatable services: ${SERVICE_IDS.join(", ")}.` }));
|
|
256
302
|
} else {
|
|
257
303
|
if (!jsonOutput) printBanner();
|
|
258
304
|
results = [];
|
|
259
|
-
for (const id of ids) {
|
|
305
|
+
for (const id of ids.length ? ids : [CLI_NAME]) {
|
|
260
306
|
if (!jsonOutput) process.stdout.write(` Updating ${bold(id)}... `);
|
|
261
307
|
let result;
|
|
262
308
|
try {
|
|
263
|
-
result = await manager.updateService(id);
|
|
309
|
+
result = id === CLI_NAME ? await updateSelfImpl() : await manager.updateService(id);
|
|
264
310
|
} catch (err) {
|
|
265
311
|
result = { success: false, message: err?.message || String(err) };
|
|
266
312
|
}
|
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
|
+
}
|