@drakonkat/ai-helper 1.2.16 → 1.2.18

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/ARCHITECTURE.md CHANGED
@@ -35,16 +35,16 @@ This document details the architectural principles, process lifecycles, auto-dis
35
35
  ## 2. Process Tree Management
36
36
 
37
37
  ### The Orphan Process Problem
38
- When background daemons are spawned via npm or shell wrappers (`npx pxpipe-proxy`, `ocx start`, `npx @agentmemory/agentmemory`), the spawned process hierarchy often looks like:
38
+ When background daemons are spawned via npm or shell wrappers (`npx pxpipe-proxy`, `ocx start`, `headroom proxy`), the spawned process hierarchy often looks like:
39
39
 
40
40
  ```text
41
41
  cmd.exe (or sh)
42
42
  └─► node.exe (npx-cli wrapper)
43
43
  └─► node.exe (actual worker / proxy server)
44
- └─► iii.exe (sub-process engine / binary)
44
+ └─► python.exe / native sub-process
45
45
  ```
46
46
 
47
- If a process manager kills only the parent PID, the child `node.exe` and `iii.exe` processes remain running as orphans in the background, keeping network ports locked.
47
+ If a process manager kills only the parent PID, the child `node.exe` and native worker processes remain running as orphans in the background, keeping network ports locked.
48
48
 
49
49
  ### Solution in ai-helper
50
50
  1. **Windows**: Uses `taskkill.exe /pid <PID> /T /F`:
@@ -64,7 +64,7 @@ Even if services are started outside `aih` (e.g. from separate PowerShell tabs,
64
64
  In a single fast PowerShell CIM query:
65
65
  ```powershell
66
66
  $procs = Get-CimInstance Win32_Process | Where-Object {
67
- $_.CommandLine -and ($_.CommandLine -match 'pxpipe|ocx|agentmemory|iii')
67
+ $_.CommandLine -and ($_.CommandLine -match 'pxpipe|ocx|headroom')
68
68
  } | Select-Object ProcessId, ParentProcessId, Name, CommandLine, CreationDate
69
69
 
70
70
  $ports = Get-NetTCPConnection -State Listen | Select-Object LocalPort, OwningProcess
@@ -82,6 +82,17 @@ external-process discovery.
82
82
  ### Unix Implementation
83
83
  Uses `ps -eo pid,command` to match command line strings and extract active PIDs.
84
84
 
85
+ ### Docker services (Hindsight)
86
+ Services with `runtime: "docker"` in `src/config.js` are never discovered from the
87
+ process table. `syncState` reads `docker container inspect <name>` instead, so status,
88
+ start time and container ID come from Docker and no PID is recorded. Stop runs
89
+ `docker stop` and never kills listeners on the published ports: on Windows those
90
+ belong to Docker Desktop (`com.docker.backend`, `wslrelay`). Readiness is the HTTP
91
+ status of Hindsight's `GET /health`; the live dashboard polls it every 5 seconds.
92
+ When Docker is unavailable, inspection is retried at most every 10 seconds so the
93
+ one-second dashboard refresh never blocks on a stopped daemon. Implementation:
94
+ `src/hindsight.js` (validation, docker argv, health probe, preflight).
95
+
85
96
  ---
86
97
 
87
98
  ## 4. State Synchronization
package/CHANGELOG.md CHANGED
@@ -4,6 +4,31 @@ All notable changes to **`ai-helper` (`aih`)** are documented in this file.
4
4
 
5
5
  ---
6
6
 
7
+ ## [1.2.18] - 2026-11-06
8
+
9
+ ### Changed
10
+ - **Hindsight replaces agentmemory** as the managed memory service. It runs as a Docker container (`ghcr.io/vectorize-io/hindsight`, API `127.0.0.1:8888`, UI `localhost:9999`, data in the `hindsight-data` volume) and is part of the default `aih start` / `aih up` selection. Saved Startup selections and state entries naming `agentmemory` migrate automatically; aih no longer discovers, starts or stops agentmemory.
11
+
12
+ ### Added
13
+ - Docker-aware lifecycle: container state instead of PIDs, `docker start`/`run`/`stop` without killing Docker Desktop's port owners, `aih logs hindsight` via `docker logs`, start reported successful only after `/health` returns HTTP 200.
14
+ - Existing containers with the configured name (e.g. docker compose) are reused untouched; containers created by aih are labelled and recreated when their settings change, keeping the data volume. `aih update hindsight` pulls the image and recreates only aih-managed containers.
15
+ - Setup (`c` in `aih status --ui`) continues with Hindsight settings when it is selected in Startup: container, image, ports, volume, LLM provider/model/base URL, API key (stored only in `~/.aih/hindsight.env`) and an extra env file. Check verifies Docker, key, image, ports, ownership and health.
16
+ - Live dashboard `HEALTH` and `LAST CHECK` columns for ocx (`/healthz`), headroom (`/health`), the built-in proxy, hindsight (`/health`) and standalone pxpipe (`/proxy-stats`), refreshed every 5 seconds and right after start/stop. Answers from a different service on the same port show as `unverified`.
17
+ - The built-in proxy answers `GET /__aih/health` itself (never forwarded, recorded or passed to interceptors); a verified proxy is shown as `verified` in the pipeline.
18
+ - The live dashboard (`aih status --ui`) is now entirely in English.
19
+
20
+ ### Removed
21
+ - The URL/GitHub line under the live dashboard table; the `URL` and `REPO` columns and the `o`/`g` keys cover it.
22
+
23
+ ---
24
+
25
+ ## [1.2.17] - 2026-11-06
26
+
27
+ ### Fixed
28
+ - Windows: updating Headroom from the TUI or `aih update headroom` no longer fails with "`uv` was not found on PATH". aih now also looks for tools installed with `pip install --user` (`%APPDATA%\Python\Python3XX\Scripts`, and `~/Library/Python/3.X/bin` on macOS), where it bootstraps uv.
29
+
30
+ ---
31
+
7
32
  ## [1.2.16] - 2026-10-28
8
33
 
9
34
  ### Changed
package/README.md CHANGED
@@ -39,7 +39,7 @@
39
39
  When building, testing, and collaborating with local AI agents, coding assistants, and MCP servers, multiple background services must run simultaneously:
40
40
  1. **`pxpipe`**: LLM & MCP protocol reverse proxy bridge (`npx pxpipe-proxy`).
41
41
  2. **`ocx`**: OpenCode interpreter and execution daemon (`ocx start`).
42
- 3. **`agentmemory`**: Persistent long-term agent memory server (`npx @agentmemory/agentmemory`).
42
+ 3. **`hindsight`**: Long-term agent memory ([vectorize-io/hindsight](https://github.com/vectorize-io/hindsight)), run as a Docker container.
43
43
  4. **`headroom`**: LLM context optimization & compression proxy (`headroom proxy`).
44
44
 
45
45
  Manually opening separate terminal tabs for each service is messy, clutters your workspace, and easily leads to orphaned background processes and blocked ports.
@@ -64,7 +64,7 @@ npx @drakonkat/ai-helper status
64
64
  # Open service web dashboards in your default browser
65
65
  npx @drakonkat/ai-helper open
66
66
 
67
- # Start ocx, agentmemory and the pxpipe proxy
67
+ # Start ocx, hindsight (Docker) and the pxpipe proxy
68
68
  npx @drakonkat/ai-helper start
69
69
  ```
70
70
 
@@ -92,17 +92,59 @@ bun add -g @drakonkat/ai-helper
92
92
  | :--- | :--- | :--- | :--- | :--- |
93
93
  | **`pxpipe`** | `npx pxpipe-proxy` | [`http://localhost:47821`](http://localhost:47821) | [teamchong/pxpipe](https://github.com/teamchong/pxpipe) | AI LLM & MCP protocol reverse proxy bridge |
94
94
  | **`ocx`** | `ocx start` | [`http://localhost:10100`](http://localhost:10100) | [lidge-jun/opencodex](https://github.com/lidge-jun/opencodex) | OpenCode interpreter execution daemon |
95
- | **`agentmemory`** | `npx @agentmemory/agentmemory` | [`http://localhost:3113`](http://localhost:3113) | [rohitg00/agentmemory](https://github.com/rohitg00/agentmemory) | Persistent agent long-term memory server & viewer |
95
+ | **`hindsight`** | Docker container `hindsight` (`ghcr.io/vectorize-io/hindsight`) | [`http://localhost:9999`](http://localhost:9999) (UI), API `http://127.0.0.1:8888` | [vectorize-io/hindsight](https://github.com/vectorize-io/hindsight) | Long-term agent memory; requires Docker; health from `/health` |
96
96
  | **`headroom`** | `headroom proxy` | [`http://localhost:8787/dashboard`](http://localhost:8787/dashboard) | [headroomlabs-ai/headroom](https://github.com/headroomlabs-ai/headroom) | Context optimization & LLM compression proxy |
97
97
  | **`proxy`** | `aih start proxy <upstream>` | `http://127.0.0.1:10101` | [drakonkat/ai-helper](https://github.com/drakonkat/ai-helper) | HTTP/SSE/WebSocket forwarding with optional presets; **no web dashboard** |
98
98
 
99
+ ### Hindsight (Docker)
100
+
101
+ [Hindsight](https://github.com/vectorize-io/hindsight) replaces agentmemory as the
102
+ memory service. It runs in Docker, so **Docker Desktop (Windows/macOS) or Docker
103
+ Engine (Linux) must be installed and running**. aih tracks it by container state,
104
+ not by PID, and never kills processes on its ports (on Windows they belong to Docker).
105
+
106
+ - **start** checks Docker, then starts the container named `hindsight` or, when it
107
+ does not exist, pulls the image if needed and creates it with
108
+ `docker run -d --restart unless-stopped --shm-size 1g`, loopback ports
109
+ `127.0.0.1:8888` (API) and `127.0.0.1:9999` (UI) and the volume
110
+ `hindsight-data:/home/hindsight/.pg0`. Start succeeds only when `GET /health`
111
+ answers HTTP 200 (up to 3 minutes; the first boot initializes the database).
112
+ - **stop** runs `docker stop`; data stays in the volume. **logs** shows `docker logs`;
113
+ the docker commands run by aih are recorded in `~/.aih/logs/hindsight.log`.
114
+ - **An existing container with the same name is reused as is**, for example one created
115
+ by docker compose. aih starts/stops it but never recreates or updates it.
116
+ - Containers created by aih carry the labels `io.aih.managed=true` and a settings
117
+ fingerprint: after a settings change they are recreated on the next start (or by
118
+ *Save and apply now* if running), always keeping the data volume.
119
+ - **update** (`aih update hindsight` or `u`) pulls the configured image and recreates
120
+ an aih-managed container only if the image changed; a running one is restarted and
121
+ checked again through `/health`.
122
+
123
+ Settings are edited in `aih status --ui` → **`c`** after selecting **hindsight** in the
124
+ Startup step: container name, image (default `ghcr.io/vectorize-io/hindsight:latest`),
125
+ API/UI ports, data volume, LLM provider (`HINDSIGHT_API_LLM_PROVIDER`, default `openai`),
126
+ model, OpenAI-compatible base URL (from the container use `host.docker.internal`, e.g.
127
+ `http://host.docker.internal:10100/v1` for OCX), API key and an optional extra
128
+ `--env-file` for advanced `HINDSIGHT_*` variables. Non-secret values are saved in
129
+ `state.config.hindsight`; the key is saved only in `~/.aih/hindsight.env` and passed with
130
+ `--env-file`, never on the command line. Without a saved key, `HINDSIGHT_API_LLM_API_KEY`
131
+ from aih's environment is forwarded. **Check** in the summary verifies Docker, key,
132
+ image, ports, container ownership and current health without changing anything.
133
+
134
+ Hindsight's health is its `/health` readiness (including the database); `VERSION`
135
+ comes from `/health/live`. See [Live health checks](#live-health-checks) for the dashboard columns.
136
+
137
+ Upgrading from agentmemory: saved Startup selections and `state.json` entries are
138
+ migrated automatically; aih no longer manages or stops a still-running agentmemory,
139
+ so stop it manually (`npx @agentmemory/agentmemory stop`) if needed.
140
+
99
141
  ---
100
142
 
101
143
  ## ✨ Key Features
102
144
 
103
145
  - 🔍 **Real-Time Auto-Discovery**: Automatically queries OS process tables (`Win32_Process` and TCP listening connections on Windows, `ps` on Unix) to discover and manage processes started from external terminal windows.
104
146
  - 🌐 **One-Click Dashboard Launcher**: Run `aih open` to launch service dashboards in your browser in separate tabs.
105
- - 🛡️ **Clean Process Tree Termination**: Kills parent and all nested child worker processes (`node.exe`, `iii.exe`, etc.) ensuring no ports remain locked.
147
+ - 🛡️ **Clean Process Tree Termination**: Kills parent and all nested child worker processes (`node.exe`, `python.exe`, etc.) ensuring no ports remain locked.
106
148
  - 📜 **Live Log Streaming**: Unified stdout/stderr log capture per service with live real-time tailing (`aih logs <service> -f`).
107
149
  - 🤖 **Agent & Automation Friendly**: Native `--json` output format for IDE integrations, subagents, and automated workflows.
108
150
  - 🔀 **Compression Presets**: pxpipe as a library, Headroom compression, RTK stdin filtering, or ordered combinations.
@@ -121,12 +163,12 @@ spaces, such as `--interceptor "./my hooks/interceptor.mjs"`.
121
163
  | `status [services...] [--json] [--ui]` | `aih status ocx proxy --json`; `aih status --ui` |
122
164
  | `start [services...] [--models <list>] [--json]` | `aih start --models "gpt-6-astra,anthropic/claude-fable*"` |
123
165
  | `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` |
166
+ | `stop [services...]` | `aih stop ocx hindsight` |
167
+ | `restart [services...] [--json]` | `aih restart ocx hindsight --json` |
126
168
  | `restart proxy [upstream] [proxy options] [--json]` | `aih restart proxy --models="gpt-6-astra,anthropic/claude-fable*"` |
127
169
  | `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` |
170
+ | `update <services...> [--json]` | `aih update ocx hindsight --json`; `aih ocx update` |
171
+ | `open [services...] [--repo]` | `aih open hindsight`; `aih open proxy --repo` |
130
172
  | `logs <service> [-n <lines>] [-f]` | `aih logs proxy --lines=100 --follow` |
131
173
  | `stats proxy [--json]` | `aih stats proxy --json` |
132
174
  | `install` | `aih install` (build/install the standalone binary; requires Bun) |
@@ -155,21 +197,21 @@ SERVICE STATUS PID UPTIME ADDRESS REPO
155
197
  ─────────── ───────── ───── ────── ────────────────────── ───────────────────────────────────────── ────────────────────────────
156
198
  pxpipe ● RUNNING 36212 1h 42m http://localhost:47821 https://github.com/teamchong/pxpipe npx pxpipe-proxy
157
199
  ocx ● RUNNING 31540 54s http://localhost:10100 https://github.com/lidge-jun/opencodex ocx start
158
- agentmemory ● RUNNING 44600 1h 32m http://localhost:3113 https://github.com/rohitg00/agentmemory npx @agentmemory/agentmemory
200
+ hindsight ● RUNNING - 1h 32m http://localhost:9999 https://github.com/vectorize-io/hindsight docker container hindsight (ghcr.io/vectorize-io/hindsight:latest)
159
201
 
160
202
  Use 'aih open [service]' to open dashboards in browser or 'aih start' to launch.
161
203
  ```
162
204
 
163
205
  Run `aih status --ui` in a terminal for the interactive live dashboard. Its
164
- `REPO` column shows the GitHub owner/repository; the selected service's full
165
- repository and dashboard URLs appear below the table. Press **`g`** to open its
166
- repository. Plain `status` prints full repository links, and `status --json`
206
+ `REPO` column shows the GitHub owner/repository and `URL` the dashboard address.
207
+ Press **`g`** to open the selected service's repository and **`o`** its dashboard.
208
+ Plain `status` prints full repository links, and `status --json`
167
209
  includes `repositoryUrl` (null for custom services without metadata). The built-in
168
210
  proxy links to ai-helper's repository, not its forwarding address.
169
211
 
170
212
  #### Guided proxy setup
171
213
 
172
- Press **`c` — setup proxy** from anywhere in `aih status --ui`, even before the
214
+ Press **`c` — setup** from anywhere in `aih status --ui`, even before the
173
215
  proxy's first start. The wizard edits a local draft: upstream/listener, supported
174
216
  ordered recipes, model list, Headroom URL, RTK filter, pxpipe native-image handling,
175
217
  interceptor `.mjs` and maximum body size. Tool-specific fields appear only when
@@ -183,14 +225,17 @@ that tool is enabled. pxpipe is bundled as a library; its separate daemon is not
183
225
  A stopped proxy is marked explicitly; an unconfigured proxy shows **not configured**.
184
226
  Pending saved settings can differ from the current worker. The editable line is the new draft.
185
227
  - The **Startup** step selects which services launch together with plain `aih start`
186
- or `aih up`: OCX, AgentMemory, standalone pxpipe, Headroom and the built-in proxy.
228
+ or `aih up`: OCX, Hindsight, standalone pxpipe, Headroom and the built-in proxy.
187
229
  Use **Up/Down** to move, **Space** to toggle and **Enter** to continue. Select at
188
230
  least one service. Choices are saved with setup in `state.config.startServices`.
189
231
  Upstream services launch first, followed by the built-in proxy. Until configured,
190
- the defaults remain OCX, AgentMemory and proxy. Explicit targets such as
232
+ the defaults remain OCX, Hindsight and proxy. Explicit targets such as
191
233
  `aih start ocx` override the selection; `aih start --gpt` keeps its dedicated workflow.
192
234
  Saving/applying setup does not launch the selected services immediately: the
193
- selection takes effect on the next plain start/up. Apply now only starts/restarts the proxy.
235
+ selection takes effect on the next plain start/up. Apply now only starts/restarts the proxy
236
+ (and recreates a running aih-managed Hindsight container whose settings changed).
237
+ - When **hindsight** is selected in Startup, the wizard continues with its Docker
238
+ settings; see [Hindsight (Docker)](#hindsight-docker). Otherwise they are skipped and left unchanged.
194
239
  - **Esc** cancels; a modified draft asks for confirmation before discarding it.
195
240
  - The final summary marks differences from the running configuration. Use arrows
196
241
  and Enter to choose an action, and **PgUp/PgDn** to scroll details.
@@ -217,8 +262,8 @@ Empty optional values persist as resets, not as omitted overrides.
217
262
  The dashboard's
218
263
  `VERSION` column shows the running service version when available, otherwise the
219
264
  installed version. `UPDATE` shows `↑ <version>` for an available update,
220
- `aggiornato` when no newer version is found, or `n/d` when the check cannot be
221
- completed. Checks query npm/PyPI in the background every five minutes and after
265
+ `up to date` when no newer version is found, or `n/a` when the check cannot be
266
+ completed. Checks query npm/PyPI (GitHub releases for Hindsight) in the background every five minutes and after
222
267
  a service restart; they never install or update services.
223
268
 
224
269
  Press **`u`** to update the selected service to the latest available release.
@@ -227,14 +272,36 @@ and refreshes version information even for stopped services. Repeated action
227
272
  keys are ignored while an operation is in progress. Only services that were
228
273
  running are stopped and restarted; stopped services stay stopped.
229
274
 
230
- Both `PIPELINE` and `STREAM RICHIESTE` read the native AIH proxy snapshot,
275
+ #### Live health checks
276
+
277
+ The **`HEALTH`** column shows the last health reading of each running service and
278
+ **`LAST CHECK`** its age (`3s ago`, yellow after 15 seconds). Readings are taken every
279
+ 5 seconds, in the background, and immediately after a start/stop/restart or PID change;
280
+ stopped services are not probed.
281
+
282
+ | Service | Endpoint | Healthy when |
283
+ | --- | --- | --- |
284
+ | `ocx` | `GET /healthz` | `service: "opencodex"` and `status: "ok"` |
285
+ | `headroom` | `GET /health` | a Headroom answer with `status: "healthy"` |
286
+ | `proxy` | `GET /__aih/health` (answered by the proxy itself, never forwarded or recorded) | `service: "aih-proxy"`, `status: "ok"` |
287
+ | `hindsight` | `GET /health` on the API port | HTTP 200 and `status: "healthy"` (database connected) |
288
+ | `pxpipe` | `GET /proxy-stats` | the standalone pxpipe answers with JSON (it has no health route) |
289
+
290
+ Values: `ok`, `degraded` (the service answers but reports a problem or an HTTP error),
291
+ `unreachable` (no answer or timeout), `unverified` (something answers on the port but it
292
+ is not the expected service), `stopped`, `no docker` (Docker unavailable) and `-` for
293
+ services without a health check. A proxy started by an older aih forwards
294
+ `/__aih/health` upstream and shows `unverified` until it is restarted. When the proxy is
295
+ verified, the pipeline shows `aih proxy: verified` instead of `process running`.
296
+
297
+ Both `PIPELINE` and `REQUEST STREAM` read the native AIH proxy snapshot,
231
298
  `~/.aih/proxy-stats.json` (`AIH_HOME` overrides the directory), not Headroom's
232
299
  metrics or savings event log. `PIPELINE` shows recorded requests, changed requests,
233
300
  preset errors, estimated token savings and each stage's application/measurement
234
- counts. `elab/s` measures preset processing between successful samples, not all
301
+ counts. `proc/s` measures preset processing between successful samples, not all
235
302
  proxy traffic or token-generation speed. Counters persist across restarts.
236
303
 
237
- `STREAM RICHIESTE` shows the latest recorded events with local time, model,
304
+ `REQUEST STREAM` shows the latest recorded events with local time, model,
238
305
  HTTP/WS transport, preset, changed/unchanged/error outcome, estimated savings
239
306
  and stage reasons. When Codex supplies `x-codex-turn-metadata`, events also show
240
307
  the session ID (falling back to the thread ID) and Git project (`owner/repo` from
@@ -262,7 +329,7 @@ only means no completion was recorded (for example after a proxy crash), not a
262
329
  global count of active calls. Updates do not bring evicted events back into the
263
330
  bounded recent list. WebSocket events report **only preset time**: connection
264
331
  duration and arbitrary response frames cannot safely be attributed to individual
265
- calls. Missing/older timings remain `n/d`. Error responses that arrive normally
332
+ calls. Missing/older timings remain `n/a`. Error responses that arrive normally
266
333
  (such as HTTP 500) retain their status; a transport failure is marked separately
267
334
  from a preset error. Preset `none` remains unrecorded.
268
335
 
@@ -304,8 +371,8 @@ built-in proxy with `aih restart proxy` to load the updated code.
304
371
  ```bash
305
372
  aih ocx update # update OpenCodex to the latest available release
306
373
  aih update ocx # equivalent command-first form
307
- aih update ocx agentmemory # update selected services
308
- aih update pxpipe ocx agentmemory headroom # all managed services, not aih itself
374
+ aih update ocx hindsight # update selected services
375
+ aih update pxpipe ocx hindsight headroom # all managed services, not aih itself
309
376
  aih update ocx --json # JSON result array, exit code 1 on any failure
310
377
  ```
311
378
 
@@ -320,7 +387,7 @@ instead. The proxy's bundled pxpipe library is likewise updated with ai-helper,
320
387
  not by updating the separate `pxpipe` service.
321
388
 
322
389
  The Node services use `npm install --global <package>@latest` (`pxpipe-proxy`,
323
- `@bitkyc08/opencodex`, `@agentmemory/agentmemory`), so npm must be available and
390
+ `@bitkyc08/opencodex`), so npm must be available and
324
391
  its global installation directory writable and on PATH. Headroom is updated with its own
325
392
  `headroom update --yes` command to respect the existing Python installation.
326
393
  **If Headroom is not installed, the same command installs it** on the machine running aih:
@@ -342,7 +409,7 @@ the verified package version so an older project dependency/cache cannot win.
342
409
  aih open
343
410
 
344
411
  # Open only a specific dashboard
345
- aih open agentmemory # Opens http://localhost:3113
412
+ aih open hindsight # Opens http://localhost:9999 (Hindsight UI)
346
413
  aih open ocx # Opens http://localhost:10100
347
414
  aih open pxpipe # Opens http://localhost:47821
348
415
 
@@ -356,15 +423,15 @@ aih open proxy --repo
356
423
  ### 3. Start Services
357
424
 
358
425
  ```bash
359
- # Start ocx, agentmemory and the pxpipe proxy
426
+ # Start ocx, hindsight (Docker) and the pxpipe proxy
360
427
  aih start
361
428
 
362
429
  # Start a specific service
363
430
  aih start pxpipe
364
- aih start agentmemory
431
+ aih start hindsight
365
432
  ```
366
433
 
367
- Without service targets, `aih start` (or `aih up`) starts `ocx`, `agentmemory`,
434
+ Without service targets, `aih start` (or `aih up`) starts `ocx`, `hindsight`,
368
435
  then the built-in proxy with these options:
369
436
 
370
437
  ```bash
@@ -421,12 +488,12 @@ exists, successful starts retain their effective options in that setup instead.
421
488
  `aih config pxpipe-models=`
422
489
  saves pxpipe's default selection. Configuration does not restart a running proxy.
423
490
 
424
- The value is passed only to the built-in proxy; `ocx` and `agentmemory` start
491
+ The value is passed only to the built-in proxy; `ocx` and `hindsight` start
425
492
  normally. `--models=` passes an empty string; `--models ""` also works when your
426
493
  shell preserves empty arguments. A bare `--models` without a value is an error.
427
494
  See [Select models](#select-models) for matching and compression behavior.
428
495
 
429
- Without a saved Startup selection, no-target `start`/`up` launches OCX, AgentMemory
496
+ Without a saved Startup selection, no-target `start`/`up` launches OCX, Hindsight
430
497
  and proxy. Unless a dashboard setup has been saved, these commands supply the upstream, listener and preset above
431
498
  on every invocation, plus the configured model list (or the list above if unset),
432
499
  unless `--models` overrides it.
@@ -510,7 +577,7 @@ aih restart pxpipe
510
577
  aih logs pxpipe
511
578
 
512
579
  # View last 100 lines
513
- aih logs agentmemory -n 100
580
+ aih logs hindsight -n 100 # docker logs of the Hindsight container
514
581
 
515
582
  # Stream logs in real-time (like tail -f)
516
583
  aih logs ocx -f
@@ -922,15 +989,18 @@ aih status --json
922
989
  "logSize": 12480
923
990
  },
924
991
  {
925
- "id": "agentmemory",
926
- "name": "agentmemory",
927
- "command": "npx @agentmemory/agentmemory",
992
+ "id": "hindsight",
993
+ "name": "hindsight",
994
+ "runtime": "docker",
928
995
  "status": "running",
929
- "pid": 44600,
996
+ "command": "docker container hindsight (ghcr.io/vectorize-io/hindsight:latest)",
930
997
  "uptime": "1h 32m",
931
- "url": "http://localhost:3113",
932
- "description": "Long-term persistent agent memory service (@agentmemory/agentmemory)",
933
- "logPath": "C:\\Users\\user\\.aih\\logs\\agentmemory.log",
998
+ "url": "http://localhost:9999",
999
+ "apiUrl": "http://127.0.0.1:8888",
1000
+ "containerName": "hindsight",
1001
+ "containerId": "0dac31334616",
1002
+ "description": "Long-term agent memory in Docker (vectorize-io/hindsight; API :8888, UI :9999)",
1003
+ "logPath": "C:\\Users\\user\\.aih\\logs\\hindsight.log",
934
1004
  "logSize": 85190
935
1005
  }
936
1006
  ]
@@ -941,7 +1011,8 @@ aih status --json
941
1011
  ## 📁 Configuration & State
942
1012
 
943
1013
  State and log files are stored in the user's home directory under `~/.aih`:
944
- - **State File**: `~/.aih/state.json` (records active PIDs, start timestamps, URLs, and status).
1014
+ - **State File**: `~/.aih/state.json` (records active PIDs, start timestamps, URLs, status and the non-secret Hindsight settings).
1015
+ - **Hindsight API key**: `~/.aih/hindsight.env` (`HINDSIGHT_API_LLM_API_KEY=...`, passed to Docker with `--env-file`).
945
1016
  - **Proxy Statistics**: `~/.aih/proxy-stats.json` (cumulative estimates and the last 20 measurements).
946
1017
  - **Log Directory**: `~/.aih/logs/<service>.log` (stdout and stderr captured with startup banners).
947
1018
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@drakonkat/ai-helper",
3
- "version": "1.2.16",
4
- "description": "Zero-config background service manager, auto-discovery daemon & dashboard launcher for AI agent ecosystems (pxpipe, ocx, agentmemory, headroom)",
3
+ "version": "1.2.18",
4
+ "description": "Zero-config background service manager, auto-discovery daemon & dashboard launcher for AI agent ecosystems (pxpipe, ocx, hindsight, headroom)",
5
5
  "main": "src/index.js",
6
6
  "module": "src/index.js",
7
7
  "type": "module",
@@ -40,7 +40,7 @@
40
40
  "postinstall": "node scripts/patch-pxpipe.js",
41
41
  "start": "node ./bin/cli.js",
42
42
  "dev": "node ./bin/cli.js",
43
- "test": "bun test test/aih.test.js test/metrics.test.js test/discovery.test.js test/tui-pipeline.test.js test/tui-versions.test.js test/versions.test.js test/repositories.test.js test/service-updates.test.js test/headroom-install.test.js && node --test test/proxy-setup.test.js test/proxy.test.js test/pxpipe-performance.test.js test/codex-config.test.js test/codex-routing.test.js test/codex-manager.test.js test/benchmark-live.test.js test/benchmark-measurement.test.js test/benchmark-quality.test.js test/benchmark-report.test.js test/benchmark-runner.test.js test/benchmark-multimodal.test.js",
43
+ "test": "bun test test/aih.test.js test/metrics.test.js test/discovery.test.js test/tui-pipeline.test.js test/tui-versions.test.js test/versions.test.js test/repositories.test.js test/service-updates.test.js test/headroom-install.test.js && node --test test/proxy-setup.test.js test/hindsight.test.js test/health.test.js test/proxy.test.js test/pxpipe-performance.test.js test/codex-config.test.js test/codex-routing.test.js test/codex-manager.test.js test/benchmark-live.test.js test/benchmark-measurement.test.js test/benchmark-quality.test.js test/benchmark-report.test.js test/benchmark-runner.test.js test/benchmark-multimodal.test.js",
44
44
  "bench:proxy": "node scripts/bench-proxy.js",
45
45
  "bench:models": "node scripts/bench-proxy.js --compare-models gpt-6-astra,anthropic/claude-fable-5-1 --formats responses",
46
46
  "test:benchmark": "node --test test/benchmark-live.test.js test/benchmark-measurement.test.js test/benchmark-quality.test.js test/benchmark-report.test.js test/benchmark-runner.test.js test/benchmark-multimodal.test.js",
@@ -53,7 +53,8 @@
53
53
  "agent",
54
54
  "pxpipe",
55
55
  "ocx",
56
- "agentmemory",
56
+ "hindsight",
57
+ "docker",
57
58
  "headroom",
58
59
  "mcp",
59
60
  "npx",
package/src/config.js CHANGED
@@ -30,17 +30,18 @@ export const SERVICES = {
30
30
  defaultUrl: "http://localhost:10100",
31
31
  ports: [10100],
32
32
  },
33
- agentmemory: {
34
- id: "agentmemory",
35
- name: "agentmemory",
36
- command: "npx @agentmemory/agentmemory",
37
- stopCommand: "npx @agentmemory/agentmemory stop --force",
38
- repositoryUrl: "https://github.com/rohitg00/agentmemory",
39
- description: "Long-term persistent agent memory service (@agentmemory/agentmemory)",
40
- defaultPort: 3113,
41
- defaultUrl: "http://localhost:3113",
42
- ports: [3111, 3112, 3113, 49134],
43
- },
33
+ hindsight: {
34
+ id: "hindsight",
35
+ name: "hindsight",
36
+ // Docker container, not a host process: no PID, port cleanup or npm updates.
37
+ runtime: "docker",
38
+ command: "docker container hindsight",
39
+ repositoryUrl: "https://github.com/vectorize-io/hindsight",
40
+ description: "Long-term agent memory in Docker (vectorize-io/hindsight; API :8888, UI :9999)",
41
+ defaultPort: 9999,
42
+ defaultUrl: "http://localhost:9999",
43
+ ports: [],
44
+ },
44
45
  headroom: {
45
46
  id: "headroom",
46
47
  name: "headroom",
@@ -59,7 +60,6 @@ export const SERVICE_IDS = Object.keys(SERVICES);
59
60
  export const SERVICE_PACKAGES = {
60
61
  pxpipe: { name: "pxpipe-proxy", bin: "pxpipe", npx: true },
61
62
  ocx: { name: "@bitkyc08/opencodex", bin: "ocx", health: "/healthz", service: "opencodex" },
62
- agentmemory: { name: "@agentmemory/agentmemory", bin: "agentmemory", npx: true, health: "/agentmemory/health", service: "agentmemory" },
63
63
  headroom: { name: "headroom-ai", bin: "headroom", health: "/health", pypi: true },
64
64
  };
65
65
 
package/src/health.js ADDED
@@ -0,0 +1,81 @@
1
+ import { baseUrl } from "./utils/metrics.js";
2
+ import { probeHindsightHealth } from "./hindsight.js";
3
+ import { PROXY_HEALTH_PATH } from "./proxy.js";
4
+
5
+ export { PROXY_HEALTH_PATH };
6
+
7
+ const obj = value => value && typeof value === "object" && !Array.isArray(value);
8
+ const str = value => typeof value === "string" ? value : null;
9
+ const num = value => Number.isFinite(value) ? value : null;
10
+
11
+ /**
12
+ * Per-service HTTP health checks. "identity" proves the answer comes from the
13
+ * expected service (a port can be reused or forwarded); "ok" decides health.
14
+ */
15
+ export const HEALTH_CHECKS = {
16
+ ocx: {
17
+ path: "/healthz",
18
+ identity: b => b.service === "opencodex",
19
+ ok: b => b.status === "ok",
20
+ uptime: b => b.uptime,
21
+ },
22
+ headroom: {
23
+ path: "/health",
24
+ identity: b => b.service ? /^headroom/.test(b.service) : typeof b.status === "string",
25
+ ok: b => b.status === "healthy",
26
+ uptime: b => b.uptime_seconds,
27
+ },
28
+ proxy: {
29
+ path: PROXY_HEALTH_PATH,
30
+ identity: b => b.service === "aih-proxy",
31
+ ok: b => b.status === "ok",
32
+ uptime: b => b.uptime_seconds,
33
+ // Proxies started by older aih releases forward this path to their upstream.
34
+ unverified: "no aih health endpoint (restart the proxy)",
35
+ },
36
+ pxpipe: {
37
+ // pxpipe has no health route; its JSON stats endpoint proves the server answers.
38
+ path: "/proxy-stats",
39
+ identity: () => true,
40
+ ok: () => true,
41
+ },
42
+ };
43
+
44
+ export function hasHealthCheck(svc) {
45
+ return Boolean(svc && (svc.runtime === "docker" || Object.hasOwn(HEALTH_CHECKS, svc.id)));
46
+ }
47
+
48
+ /**
49
+ * healthy: identified and OK | degraded: identified, not OK (or HTTP error)
50
+ * unverified: something answers but is not the expected service | unreachable: no answer.
51
+ */
52
+ export async function probeHttpHealth(id, url, { fetchImpl = fetch, timeoutMs = 2000, now = Date.now } = {}) {
53
+ const check = HEALTH_CHECKS[id];
54
+ const base = baseUrl(url);
55
+ const checkedAt = now();
56
+ if (!check || !base) return { state: "unreachable", error: "no URL", checkedAt };
57
+ const target = base + check.path;
58
+ try {
59
+ const response = await fetchImpl(target, { signal: AbortSignal.timeout(timeoutMs), redirect: "manual" });
60
+ let body = null;
61
+ try { body = await response.json(); } catch {}
62
+ if (!obj(body) || !check.identity(body)) {
63
+ return { state: "unverified", httpStatus: response.status, url: target, checkedAt,
64
+ error: check.unverified || "unexpected response" };
65
+ }
66
+ return {
67
+ state: response.ok && check.ok(body) ? "healthy" : "degraded",
68
+ httpStatus: response.status, status: str(body.status), version: str(body.version),
69
+ uptimeSeconds: num(check.uptime?.(body)), url: target, checkedAt,
70
+ };
71
+ } catch (error) {
72
+ return { state: "unreachable", url: target, checkedAt,
73
+ error: error?.name === "TimeoutError" ? "timeout" : error?.cause?.code || error?.message || String(error) };
74
+ }
75
+ }
76
+
77
+ /** One entry point for every service status object shown in the dashboard. */
78
+ export function probeServiceHealth(svc, options) {
79
+ if (svc.runtime === "docker") return probeHindsightHealth(svc.apiUrl, options);
80
+ return probeHttpHealth(svc.id, svc.url, options);
81
+ }