Files
Rohit Ghumare e04ba88819 fix(cli): make fresh installs portable and persistent (#892)
* fix(cli): anchor engine cwd and rewrite bundled config with absolute paths

The bundled iii-config.yaml uses cwd-relative paths and the engine was
spawned without a cwd, so on global and npx installs ./data/state_store.db
and ./data/stream_store landed in whatever directory the user ran the CLI
from, and the iii-exec supervision block (src/**/*.ts watch, node
dist/index.mjs exec) never resolved, meaning the engine never supervised a
worker and nothing respawned it after the in-process worker died. That
surfaced as all data gone reports against a live REST port.

startIiiBin now prepares the launch: when the resolved config is the
bundled one it writes ~/.agentmemory/iii-config.runtime.yaml (regenerated
each boot) with absolute data paths under ~/.agentmemory/data and an
absolute node exec line for the installed worker entry, copies any legacy
./data stores from the invocation directory on first run, and spawns the
engine with cwd anchored at ~/.agentmemory. Repo checkouts keep the cwd
config and repo-root cwd, so dev behavior is unchanged. User overrides
via env or ~/.agentmemory/iii-config.yaml are passed through verbatim.

agentmemory remove gains a plan item for the generated runtime config.

Covered by test/engine-launch.test.ts including a drift guard that
rewrites the repo's real iii-config.yaml and asserts no relative paths
remain.

* fix: make fresh installs portable and persistent

* docs: refresh generated config reference
2026-08-23 15:54:08 +01:00

57 lines
2.4 KiB
YAML

services:
# One-shot init container: docker creates named volumes root:root mode
# 755, but the iii-engine image is distroless and runs as UID 65532
# with no `chown` of its own. Without this, /data is unwritable, the
# engine silently buffers in RAM, and state evaporates on every
# restart — the exact symptom v0.9.7's working-directory fix set out
# to solve. Runs once at compose-up and exits.
iii-init:
image: busybox:1.36
user: "0:0"
environment:
AGENTMEMORY_DOCKER_UID: "${AGENTMEMORY_DOCKER_UID:-65532}"
AGENTMEMORY_DOCKER_GID: "${AGENTMEMORY_DOCKER_GID:-65532}"
AGENTMEMORY_DOCKER_SKIP_CHOWN: "${AGENTMEMORY_DOCKER_SKIP_CHOWN:-0}"
volumes:
- "${AGENTMEMORY_DATA_DIR:-iii-data}:/data"
entrypoint: ["sh", "-c", "if [ \"$${AGENTMEMORY_DOCKER_SKIP_CHOWN}\" = \"1\" ]; then exit 0; fi; chown -R $${AGENTMEMORY_DOCKER_UID}:$${AGENTMEMORY_DOCKER_GID} /data && chmod 755 /data"]
restart: "no"
iii-engine:
# Pinned to v0.11.2 — the last engine that runs agentmemory's current
# direct-registration worker cleanly. v0.11.6 introduces a new sandbox-everything-
# via-`iii worker add` model that agentmemory hasn't been refactored
# for yet; the architectural mismatch surfaces as EPIPE reconnect
# loops and empty search after save. Bump only after agentmemory is
# refactored to register as a sandboxed worker.
#
# Override per-shell or via .env file:
# AGENTMEMORY_III_VERSION=0.11.7 docker compose up
image: iiidev/iii:${AGENTMEMORY_III_VERSION:-0.11.2}
user: "${AGENTMEMORY_DOCKER_UID:-65532}:${AGENTMEMORY_DOCKER_GID:-65532}"
depends_on:
iii-init:
condition: service_completed_successfully
environment:
III_REST_PORT: "${III_REST_PORT:-3111}"
III_STREAM_PORT: "${III_STREAM_PORT:-3112}"
III_VIEWER_PORT: "${III_VIEWER_PORT:-3113}"
III_ENGINE_PORT: "${III_ENGINE_PORT:-49134}"
ports:
- "127.0.0.1:${III_ENGINE_PORT:-49134}:${III_ENGINE_PORT:-49134}"
- "127.0.0.1:${III_REST_PORT:-3111}:${III_REST_PORT:-3111}"
- "127.0.0.1:${III_STREAM_PORT:-3112}:${III_STREAM_PORT:-3112}"
- "127.0.0.1:${AGENTMEMORY_METRICS_PORT:-9464}:9464"
volumes:
- "${AGENTMEMORY_DATA_DIR:-iii-data}:/data"
- ./iii-config.docker.yaml:/app/config.yaml:ro
restart: unless-stopped
logging:
driver: json-file
options:
max-size: "10m"
max-file: "3"
volumes:
iii-data: