@drakonkat/ai-helper 1.2.17 → 1.2.19

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,23 @@ 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, adoption settings).
95
+
96
+ Only containers labelled `io.aih.managed=true` are recreated. Any other container is
97
+ reused as is until the user adopts it (`update --adopt`): its image, ports, volume and
98
+ the environment it adds to its image become aih's settings, and aih recreates it.
99
+ Update stops the container, archives its volume to `~/.aih/backups` and only then
100
+ removes it; it never uses `docker rm -f`, which would SIGKILL the embedded database.
101
+
85
102
  ---
86
103
 
87
104
  ## 4. State Synchronization
package/CHANGELOG.md CHANGED
@@ -4,6 +4,34 @@ All notable changes to **`ai-helper` (`aih`)** are documented in this file.
4
4
 
5
5
  ---
6
6
 
7
+ ## [1.2.19] - 2026-11-10
8
+
9
+ ### Added
10
+ - **Adopt an existing Hindsight container**: `aih update hindsight --adopt`, or `u` twice in the live dashboard, imports the image, ports, data volume and environment of a container aih did not create (for example docker compose) into aih's settings and recreates it on the same volume. Without that explicit request such containers are still left untouched.
11
+ - `aih update hindsight` archives the data volume to `~/.aih/backups` (two most recent kept) before replacing the container; a failed archive leaves the old container running.
12
+
13
+ ### Changed
14
+ - `aih update hindsight` moves a version tag of the official image (e.g. `:1.1.0`) to the latest GitHub release and saves it in the settings, instead of pulling the same tag again. `:latest` and custom images behave as before.
15
+ - Hindsight updates stop the container before removing it instead of `docker rm -f`.
16
+
17
+ ## [1.2.18] - 2026-11-06
18
+
19
+ ### Changed
20
+ - **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.
21
+
22
+ ### Added
23
+ - 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.
24
+ - 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.
25
+ - 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.
26
+ - 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`.
27
+ - 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.
28
+ - The live dashboard (`aih status --ui`) is now entirely in English.
29
+
30
+ ### Removed
31
+ - The URL/GitHub line under the live dashboard table; the `URL` and `REPO` columns and the `o`/`g` keys cover it.
32
+
33
+ ---
34
+
7
35
  ## [1.2.17] - 2026-11-06
8
36
 
9
37
  ### Fixed
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,78 @@ 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 until you
116
+ adopt it.
117
+ - **adopt** (`aih update hindsight --adopt`, or `u` twice in the dashboard: the first
118
+ press explains, the second adopts) makes aih the owner of such a container. aih reads
119
+ its image, published ports, data volume and environment, saves provider, model and
120
+ base URL in the settings, the LLM key in `~/.aih/hindsight.env` and every other
121
+ variable set on top of the image (failover models, timeouts...) in
122
+ `~/.aih/hindsight-extra.env`, then stops it and recreates it on the same volume with
123
+ the same image. Ports are published on loopback only. Adoption is refused, changing
124
+ nothing, unless the data is in a single Docker volume mounted at
125
+ `/home/hindsight/.pg0`. Afterwards stop using the tool that created the container
126
+ (`docker compose up` would conflict on the name).
127
+ - Containers created by aih carry the labels `io.aih.managed=true` and a settings
128
+ fingerprint: after a settings change they are recreated on the next start (or by
129
+ *Save and apply now* if running), always keeping the data volume.
130
+ - **update** (`aih update hindsight` or `u`) works on containers created or adopted by
131
+ aih. When the image is the official one with a version tag (`:1.1.0`), it pulls the
132
+ latest GitHub release and saves the new tag in the settings; any other tag
133
+ (`:latest`, custom images) is pulled again and nothing happens if the image did not
134
+ change. Before replacing the container aih stops it and archives the data volume to
135
+ `~/.aih/backups/hindsight-<timestamp>.tgz` (the two most recent are kept), because a
136
+ newer version may migrate the database. If the archive fails, the old container is
137
+ started again and nothing changes. A running container is recreated and checked again
138
+ through `/health`. To go back, restore the archive into the volume with the container
139
+ stopped and set the previous tag in the settings:
140
+ `docker run --rm -v hindsight-data:/d -v ~/.aih/backups:/b alpine sh -c "rm -rf /d/* /d/.[!.]* && tar xzf /b/<file> -C /d"`.
141
+
142
+ Settings are edited in `aih status --ui` → **`c`** after selecting **hindsight** in the
143
+ Startup step: container name, image (default `ghcr.io/vectorize-io/hindsight:latest`),
144
+ API/UI ports, data volume, LLM provider (`HINDSIGHT_API_LLM_PROVIDER`, default `openai`),
145
+ model, OpenAI-compatible base URL (from the container use `host.docker.internal`, e.g.
146
+ `http://host.docker.internal:10100/v1` for OCX), API key and an optional extra
147
+ `--env-file` for advanced `HINDSIGHT_*` variables. Non-secret values are saved in
148
+ `state.config.hindsight`; the key is saved only in `~/.aih/hindsight.env` and passed with
149
+ `--env-file`, never on the command line. Without a saved key, `HINDSIGHT_API_LLM_API_KEY`
150
+ from aih's environment is forwarded. **Check** in the summary verifies Docker, key,
151
+ image, ports, container ownership and current health without changing anything.
152
+
153
+ Hindsight's health is its `/health` readiness (including the database); `VERSION`
154
+ comes from `/health/live`. See [Live health checks](#live-health-checks) for the dashboard columns.
155
+
156
+ Upgrading from agentmemory: saved Startup selections and `state.json` entries are
157
+ migrated automatically; aih no longer manages or stops a still-running agentmemory,
158
+ so stop it manually (`npx @agentmemory/agentmemory stop`) if needed.
159
+
99
160
  ---
100
161
 
101
162
  ## ✨ Key Features
102
163
 
103
164
  - 🔍 **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
165
  - 🌐 **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.
166
+ - 🛡️ **Clean Process Tree Termination**: Kills parent and all nested child worker processes (`node.exe`, `python.exe`, etc.) ensuring no ports remain locked.
106
167
  - 📜 **Live Log Streaming**: Unified stdout/stderr log capture per service with live real-time tailing (`aih logs <service> -f`).
107
168
  - 🤖 **Agent & Automation Friendly**: Native `--json` output format for IDE integrations, subagents, and automated workflows.
108
169
  - 🔀 **Compression Presets**: pxpipe as a library, Headroom compression, RTK stdin filtering, or ordered combinations.
@@ -121,12 +182,12 @@ spaces, such as `--interceptor "./my hooks/interceptor.mjs"`.
121
182
  | `status [services...] [--json] [--ui]` | `aih status ocx proxy --json`; `aih status --ui` |
122
183
  | `start [services...] [--models <list>] [--json]` | `aih start --models "gpt-6-astra,anthropic/claude-fable*"` |
123
184
  | `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` |
185
+ | `stop [services...]` | `aih stop ocx hindsight` |
186
+ | `restart [services...] [--json]` | `aih restart ocx hindsight --json` |
126
187
  | `restart proxy [upstream] [proxy options] [--json]` | `aih restart proxy --models="gpt-6-astra,anthropic/claude-fable*"` |
127
188
  | `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` |
189
+ | `update <services...> [--json] [--adopt]` | `aih update ocx hindsight --json`; `aih ocx update`; `aih update hindsight --adopt` |
190
+ | `open [services...] [--repo]` | `aih open hindsight`; `aih open proxy --repo` |
130
191
  | `logs <service> [-n <lines>] [-f]` | `aih logs proxy --lines=100 --follow` |
131
192
  | `stats proxy [--json]` | `aih stats proxy --json` |
132
193
  | `install` | `aih install` (build/install the standalone binary; requires Bun) |
@@ -155,21 +216,21 @@ SERVICE STATUS PID UPTIME ADDRESS REPO
155
216
  ─────────── ───────── ───── ────── ────────────────────── ───────────────────────────────────────── ────────────────────────────
156
217
  pxpipe ● RUNNING 36212 1h 42m http://localhost:47821 https://github.com/teamchong/pxpipe npx pxpipe-proxy
157
218
  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
219
+ hindsight ● RUNNING - 1h 32m http://localhost:9999 https://github.com/vectorize-io/hindsight docker container hindsight (ghcr.io/vectorize-io/hindsight:latest)
159
220
 
160
221
  Use 'aih open [service]' to open dashboards in browser or 'aih start' to launch.
161
222
  ```
162
223
 
163
224
  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`
225
+ `REPO` column shows the GitHub owner/repository and `URL` the dashboard address.
226
+ Press **`g`** to open the selected service's repository and **`o`** its dashboard.
227
+ Plain `status` prints full repository links, and `status --json`
167
228
  includes `repositoryUrl` (null for custom services without metadata). The built-in
168
229
  proxy links to ai-helper's repository, not its forwarding address.
169
230
 
170
231
  #### Guided proxy setup
171
232
 
172
- Press **`c` — setup proxy** from anywhere in `aih status --ui`, even before the
233
+ Press **`c` — setup** from anywhere in `aih status --ui`, even before the
173
234
  proxy's first start. The wizard edits a local draft: upstream/listener, supported
174
235
  ordered recipes, model list, Headroom URL, RTK filter, pxpipe native-image handling,
175
236
  interceptor `.mjs` and maximum body size. Tool-specific fields appear only when
@@ -183,14 +244,17 @@ that tool is enabled. pxpipe is bundled as a library; its separate daemon is not
183
244
  A stopped proxy is marked explicitly; an unconfigured proxy shows **not configured**.
184
245
  Pending saved settings can differ from the current worker. The editable line is the new draft.
185
246
  - 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.
247
+ or `aih up`: OCX, Hindsight, standalone pxpipe, Headroom and the built-in proxy.
187
248
  Use **Up/Down** to move, **Space** to toggle and **Enter** to continue. Select at
188
249
  least one service. Choices are saved with setup in `state.config.startServices`.
189
250
  Upstream services launch first, followed by the built-in proxy. Until configured,
190
- the defaults remain OCX, AgentMemory and proxy. Explicit targets such as
251
+ the defaults remain OCX, Hindsight and proxy. Explicit targets such as
191
252
  `aih start ocx` override the selection; `aih start --gpt` keeps its dedicated workflow.
192
253
  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.
254
+ selection takes effect on the next plain start/up. Apply now only starts/restarts the proxy
255
+ (and recreates a running aih-managed Hindsight container whose settings changed).
256
+ - When **hindsight** is selected in Startup, the wizard continues with its Docker
257
+ settings; see [Hindsight (Docker)](#hindsight-docker). Otherwise they are skipped and left unchanged.
194
258
  - **Esc** cancels; a modified draft asks for confirmation before discarding it.
195
259
  - The final summary marks differences from the running configuration. Use arrows
196
260
  and Enter to choose an action, and **PgUp/PgDn** to scroll details.
@@ -217,8 +281,8 @@ Empty optional values persist as resets, not as omitted overrides.
217
281
  The dashboard's
218
282
  `VERSION` column shows the running service version when available, otherwise the
219
283
  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
284
+ `up to date` when no newer version is found, or `n/a` when the check cannot be
285
+ completed. Checks query npm/PyPI (GitHub releases for Hindsight) in the background every five minutes and after
222
286
  a service restart; they never install or update services.
223
287
 
224
288
  Press **`u`** to update the selected service to the latest available release.
@@ -227,14 +291,36 @@ and refreshes version information even for stopped services. Repeated action
227
291
  keys are ignored while an operation is in progress. Only services that were
228
292
  running are stopped and restarted; stopped services stay stopped.
229
293
 
230
- Both `PIPELINE` and `STREAM RICHIESTE` read the native AIH proxy snapshot,
294
+ #### Live health checks
295
+
296
+ The **`HEALTH`** column shows the last health reading of each running service and
297
+ **`LAST CHECK`** its age (`3s ago`, yellow after 15 seconds). Readings are taken every
298
+ 5 seconds, in the background, and immediately after a start/stop/restart or PID change;
299
+ stopped services are not probed.
300
+
301
+ | Service | Endpoint | Healthy when |
302
+ | --- | --- | --- |
303
+ | `ocx` | `GET /healthz` | `service: "opencodex"` and `status: "ok"` |
304
+ | `headroom` | `GET /health` | a Headroom answer with `status: "healthy"` |
305
+ | `proxy` | `GET /__aih/health` (answered by the proxy itself, never forwarded or recorded) | `service: "aih-proxy"`, `status: "ok"` |
306
+ | `hindsight` | `GET /health` on the API port | HTTP 200 and `status: "healthy"` (database connected) |
307
+ | `pxpipe` | `GET /proxy-stats` | the standalone pxpipe answers with JSON (it has no health route) |
308
+
309
+ Values: `ok`, `degraded` (the service answers but reports a problem or an HTTP error),
310
+ `unreachable` (no answer or timeout), `unverified` (something answers on the port but it
311
+ is not the expected service), `stopped`, `no docker` (Docker unavailable) and `-` for
312
+ services without a health check. A proxy started by an older aih forwards
313
+ `/__aih/health` upstream and shows `unverified` until it is restarted. When the proxy is
314
+ verified, the pipeline shows `aih proxy: verified` instead of `process running`.
315
+
316
+ Both `PIPELINE` and `REQUEST STREAM` read the native AIH proxy snapshot,
231
317
  `~/.aih/proxy-stats.json` (`AIH_HOME` overrides the directory), not Headroom's
232
318
  metrics or savings event log. `PIPELINE` shows recorded requests, changed requests,
233
319
  preset errors, estimated token savings and each stage's application/measurement
234
- counts. `elab/s` measures preset processing between successful samples, not all
320
+ counts. `proc/s` measures preset processing between successful samples, not all
235
321
  proxy traffic or token-generation speed. Counters persist across restarts.
236
322
 
237
- `STREAM RICHIESTE` shows the latest recorded events with local time, model,
323
+ `REQUEST STREAM` shows the latest recorded events with local time, model,
238
324
  HTTP/WS transport, preset, changed/unchanged/error outcome, estimated savings
239
325
  and stage reasons. When Codex supplies `x-codex-turn-metadata`, events also show
240
326
  the session ID (falling back to the thread ID) and Git project (`owner/repo` from
@@ -262,7 +348,7 @@ only means no completion was recorded (for example after a proxy crash), not a
262
348
  global count of active calls. Updates do not bring evicted events back into the
263
349
  bounded recent list. WebSocket events report **only preset time**: connection
264
350
  duration and arbitrary response frames cannot safely be attributed to individual
265
- calls. Missing/older timings remain `n/d`. Error responses that arrive normally
351
+ calls. Missing/older timings remain `n/a`. Error responses that arrive normally
266
352
  (such as HTTP 500) retain their status; a transport failure is marked separately
267
353
  from a preset error. Preset `none` remains unrecorded.
268
354
 
@@ -304,8 +390,9 @@ built-in proxy with `aih restart proxy` to load the updated code.
304
390
  ```bash
305
391
  aih ocx update # update OpenCodex to the latest available release
306
392
  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
393
+ aih update ocx hindsight # update selected services
394
+ aih update hindsight --adopt # take over a Hindsight container not created by aih
395
+ aih update pxpipe ocx hindsight headroom # all managed services, not aih itself
309
396
  aih update ocx --json # JSON result array, exit code 1 on any failure
310
397
  ```
311
398
 
@@ -320,7 +407,7 @@ instead. The proxy's bundled pxpipe library is likewise updated with ai-helper,
320
407
  not by updating the separate `pxpipe` service.
321
408
 
322
409
  The Node services use `npm install --global <package>@latest` (`pxpipe-proxy`,
323
- `@bitkyc08/opencodex`, `@agentmemory/agentmemory`), so npm must be available and
410
+ `@bitkyc08/opencodex`), so npm must be available and
324
411
  its global installation directory writable and on PATH. Headroom is updated with its own
325
412
  `headroom update --yes` command to respect the existing Python installation.
326
413
  **If Headroom is not installed, the same command installs it** on the machine running aih:
@@ -342,7 +429,7 @@ the verified package version so an older project dependency/cache cannot win.
342
429
  aih open
343
430
 
344
431
  # Open only a specific dashboard
345
- aih open agentmemory # Opens http://localhost:3113
432
+ aih open hindsight # Opens http://localhost:9999 (Hindsight UI)
346
433
  aih open ocx # Opens http://localhost:10100
347
434
  aih open pxpipe # Opens http://localhost:47821
348
435
 
@@ -356,15 +443,15 @@ aih open proxy --repo
356
443
  ### 3. Start Services
357
444
 
358
445
  ```bash
359
- # Start ocx, agentmemory and the pxpipe proxy
446
+ # Start ocx, hindsight (Docker) and the pxpipe proxy
360
447
  aih start
361
448
 
362
449
  # Start a specific service
363
450
  aih start pxpipe
364
- aih start agentmemory
451
+ aih start hindsight
365
452
  ```
366
453
 
367
- Without service targets, `aih start` (or `aih up`) starts `ocx`, `agentmemory`,
454
+ Without service targets, `aih start` (or `aih up`) starts `ocx`, `hindsight`,
368
455
  then the built-in proxy with these options:
369
456
 
370
457
  ```bash
@@ -421,12 +508,12 @@ exists, successful starts retain their effective options in that setup instead.
421
508
  `aih config pxpipe-models=`
422
509
  saves pxpipe's default selection. Configuration does not restart a running proxy.
423
510
 
424
- The value is passed only to the built-in proxy; `ocx` and `agentmemory` start
511
+ The value is passed only to the built-in proxy; `ocx` and `hindsight` start
425
512
  normally. `--models=` passes an empty string; `--models ""` also works when your
426
513
  shell preserves empty arguments. A bare `--models` without a value is an error.
427
514
  See [Select models](#select-models) for matching and compression behavior.
428
515
 
429
- Without a saved Startup selection, no-target `start`/`up` launches OCX, AgentMemory
516
+ Without a saved Startup selection, no-target `start`/`up` launches OCX, Hindsight
430
517
  and proxy. Unless a dashboard setup has been saved, these commands supply the upstream, listener and preset above
431
518
  on every invocation, plus the configured model list (or the list above if unset),
432
519
  unless `--models` overrides it.
@@ -510,7 +597,7 @@ aih restart pxpipe
510
597
  aih logs pxpipe
511
598
 
512
599
  # View last 100 lines
513
- aih logs agentmemory -n 100
600
+ aih logs hindsight -n 100 # docker logs of the Hindsight container
514
601
 
515
602
  # Stream logs in real-time (like tail -f)
516
603
  aih logs ocx -f
@@ -922,15 +1009,18 @@ aih status --json
922
1009
  "logSize": 12480
923
1010
  },
924
1011
  {
925
- "id": "agentmemory",
926
- "name": "agentmemory",
927
- "command": "npx @agentmemory/agentmemory",
1012
+ "id": "hindsight",
1013
+ "name": "hindsight",
1014
+ "runtime": "docker",
928
1015
  "status": "running",
929
- "pid": 44600,
1016
+ "command": "docker container hindsight (ghcr.io/vectorize-io/hindsight:latest)",
930
1017
  "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",
1018
+ "url": "http://localhost:9999",
1019
+ "apiUrl": "http://127.0.0.1:8888",
1020
+ "containerName": "hindsight",
1021
+ "containerId": "0dac31334616",
1022
+ "description": "Long-term agent memory in Docker (vectorize-io/hindsight; API :8888, UI :9999)",
1023
+ "logPath": "C:\\Users\\user\\.aih\\logs\\hindsight.log",
934
1024
  "logSize": 85190
935
1025
  }
936
1026
  ]
@@ -941,7 +1031,8 @@ aih status --json
941
1031
  ## 📁 Configuration & State
942
1032
 
943
1033
  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).
1034
+ - **State File**: `~/.aih/state.json` (records active PIDs, start timestamps, URLs, status and the non-secret Hindsight settings).
1035
+ - **Hindsight API key**: `~/.aih/hindsight.env` (`HINDSIGHT_API_LLM_API_KEY=...`, passed to Docker with `--env-file`).
945
1036
  - **Proxy Statistics**: `~/.aih/proxy-stats.json` (cumulative estimates and the last 20 measurements).
946
1037
  - **Log Directory**: `~/.aih/logs/<service>.log` (stdout and stderr captured with startup banners).
947
1038
 
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@drakonkat/ai-helper",
3
- "version": "1.2.17",
4
- "description": "Zero-config background service manager, auto-discovery daemon & dashboard launcher for AI agent ecosystems (pxpipe, ocx, agentmemory, headroom)",
3
+ "version": "1.2.19",
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
+ }