opencode-mem-agents
v0.3.2
Published
Self-contained memory plugin for OpenCode — cross-session persistence with SQLite + FTS5, signal-based capture, role-scoped context, and agent coordination
Downloads
61
Readme
opencode-mem-agents
Persistent local memory plugin for OpenCode with:
- SQLite + FTS5 storage
- Automatic tool-result capture
- Team-scoped memory tools
- Local dashboard UI
- Request/response trace journal for observability
Runtime
- Node.js
>=18 - Default worker:
http://127.0.0.1:37778 - Default DB:
~/.opencode-mem/opencode-mem.db
Install
npm install
npm run buildDevelopment
npm run build
npm testWorker API
GET /api/healthGET /api/searchGET /api/timeline(format=text|json)POST /api/observations/batch(optionalprojectfilter enforced server-side)POST /api/memory/savePOST /api/session/tool-resultGET /api/context/sessionGET /api/activityGET /api/traces
All JSON responses include traceId for request correlation.
Architecture
Worker internals are split for maintainability:
src/worker/server.ts- HTTP lifecycle, auth/CORS, routing dispatchsrc/worker/routes.ts- request parsing + response shapingsrc/worker/repository.ts- SQLite schema + query/write logicsrc/worker/http.ts- transport helpers + boundary error handlingsrc/worker/config.ts- runtime config loading
Observability
/api/traces returns recent inbound/outbound/error events from the worker trace journal.
Trace payloads are:
- redacted for sensitive keys (
authorization,token,password,secret,apiKey,cookie) - redacted for common secret-like inline values in free text (
Bearer ...,sk-...,AKIA...) - size-capped before persistence
- pruned by age (
OPENCODE_MEM_TRACE_RETENTION_DAYS, default7)
Example:
curl "http://127.0.0.1:37778/api/traces?limit=50"Security Controls
- Optional API auth token:
- set
OPENCODE_MEM_API_TOKEN - send
Authorization: Bearer <token>on/api/*(except health/readiness)
- set
- Dashboard auth for protected endpoints:
- use the in-memory token button in the UI (
Set Token) - or open with
?token=...or#token=...(token is stripped from URL on load) - token is never persisted to localStorage/sessionStorage
- use the in-memory token button in the UI (
- CORS defaults to localhost origins only
- Optional explicit CORS origin override:
OPENCODE_MEM_CORS_ORIGIN=https://your-origin.example
- 500 responses are intentionally generic (
Internal server error) to avoid leaking internals
Reliability Controls
- Buffered observations are persisted to process-scoped disk queues (
pending-observations-<pid>.json) - Failed sends are retried from the persisted queue
- Flush retries are bounded and delivery concurrency is capped
- Tool-result writes are deduped using
(sessionId, callId, tool)capture keys - Timeline queries resolve around the true anchor at scale (not bounded to a fixed first-window scan)
- Context injection cache is scoped by
(sessionId, workflowId, agent, phase)to prevent cross-session leakage
Build Artifacts
The dashboard is built from dashboard/ and embedded into src/dashboard-html.ts during npm run build.
