Single-file OpenCode plugin that auto-starts the agentmemory backend on config load with 60s health-check supervision.
src/agentmemory-launcher.ts # Plugin entry
Flow: config hook → GET /agentmemory/livez (2s timeout) → spawns npx @agentmemory/agentmemory if down.
Source: rohitg00/agentmemory
npx @agentmemory/agentmemory (CLI + worker, ~15-30s startup)
└─ iii-engine (binary, detached, PID in ~/.agentmemory/iii.pid)
└─ iii-exec → worker (registers API routes, binds port)
| Endpoint | Auth | Use |
|---|---|---|
GET /agentmemory/livez |
public, no auth | Use for liveness checks |
GET /agentmemory/health |
requires auth when AGENTMEMORY_SECRET set |
Full health snapshot, 200/503 |
DO NOT switch back to
/health— it returns 401 when auth is enabled, causing infinite restart loops.
- StateKV timeout: after 12-24h uptime,
state::setmay timeout →/healthreturns 503./livezunaffected. - npx caching:
npx @agentmemory/agentmemorymay serve stale cached version; clear withnpx clear-npx-cache. - Engine version pin: agentmemory pins iii-engine to v0.11.2 (v0.11.6+ has incompatible sandbox model).
- Windows: no binary auto-download; Docker fallback needed.
Per OpenCode Plugin API — @opencode-ai/plugin v1.15+ (Hooks interface):
confighook: called on every config load. Guard withif (!timer)for once-only init. Signature:config?: (input: Config) => Promise<void>.eventhook: subscribe to lifecycle events includingserver.instance.disposed. Use for cleanup.timer.unref(): mark the health-check interval as non-blocking so it never prevents the Node process from exiting. Replaces the need for adisposehook.disposedoes NOT exist: the OpenCodeHooksinterface has nodisposeproperty. DO NOT return adisposeproperty from the plugin function — it will never be called. Usetimer.unref()+ theeventhook instead.client.app.log(): Use for structured logging, notconsole.error.
- TypeScript strict — no
any, no@ts-ignore - Single export:
AgentmemoryLauncherPlugin: Plugin - Stateless — process supervision via
child.unref(), no file I/O - Runtime dependency: only
@opencode-ai/plugin(devDeps inpackage.json)
| Workflow | Trigger | Action |
|---|---|---|
ci.yml |
push/PR to master/main (skip: **/*.md, LICENSE, .github/**) |
typecheck → build → test (Node 18/20/22) |
cd.yml |
push v* tag |
typecheck → build → npm publish --provenance → GitHub Release (src/agentmemory-launcher.ts) |
Release: npm version patch && git push --follow-tags
| Prefix | Use |
|---|---|
feat: / fix: |
feature / bug fix |
docs: |
documentation only |
ci: |
CI/CD workflows |
chore: |
build, deps, config |
refactor: |
code restructure (no behavior change) |
npm install # first time only
npm run typecheck # verify types
npm run build # compile to dist/
npm test # (placeholder, exits 0)Test locally: point OpenCode plugin config at this package.
AGPL-3.0-only — LICENSE