cyberine
UsageRun recipes

Shared memory backend — ContextQ (or any similar server)

The local episodic store above is the canonical record store and is always on. An OPTIONAL augmentation backend, selected purely by config, ALSO receives each terminal run and serves a token-budgeted "shared context" block back into the MEMORY preamble at dispatch — cross-project recall across every run. The backend is a port (src/store/memoryBackend.ts); ContextQ (the Shared Context Server) is the first adapter, enabled by config only, no code change:

export CYBERINE_CONTEXTQ=1                          # master switch
export CYBERINE_CONTEXTQ_URL=http://localhost:38200  # server base URL (health: <url>/health)
export CYBERINE_CONTEXTQ_API_KEY=sk_live_xxx        # mint in the ContextQ dashboard, scope read + write
export CYBERINE_CONTEXTQ_WORKSPACE=cyberine              # workspace to write into (auto-creates server-side)
npm run wf -- --sample                         # the run's outcome now lands in ContextQ too

All calls are best-effort and never block or fail a run; the local file store is always written first. What flows:

  • Write: each terminal run is saved as a ContextQ context (type project/lesson) AND as an agent_session whose NEXT items become pending tasks and ISSUES become lessons, closed with the run's terminal status. Cyberine lineage rides in the session metadata.
  • Read: buildMemoryPreamble calls agent_boot (token-budgeted handoff + lessons + facts), falling back to /api/search when the boot pack is empty, rendering a SHARED CONTEXT block inside the MEMORY markers.
  • Offline-safe: an unreachable server degrades silently to local-only (bounded by CYBERINE_CONTEXTQ_TIMEOUT_MS). Force local with CYBERINE_MEMORY_BACKEND=local even when a key is present.

Vendor-independent: the backend is a port (src/store/memoryBackend.ts), ContextQ is one adapter. CYBERINE_MEMORY_BACKEND=mcp swaps in a generic MCP-backed adapter that talks to ANY MCP knowledge server exposing save/search tools (via McpToolAdapter) — defaulting to ContextQ's own /mcp endpoint, or point CYBERINE_MEMORY_MCP_SERVER at another server. Tool names are configurable (CYBERINE_MEMORY_MCP_SAVE_TOOL / _SEARCH_TOOL, default ctx_save / ctx_search).