PROJECT.md 2.7 KB

Project: mem0-auto-capture hook

Aim

Provide a standalone hook that keeps OpenClaw agents in sync with Mem0 by capturing meaningful turns, recalling personal and knowledge-base memories, and supporting audio transcripts.

Scope

  • Auto-capture incoming messages when triggers fire.
  • Auto-recall conversational (personal) memories only before each response; knowledge base is tool-driven.
  • Work with local STT for audio, deduplicate rapid captures, and gracefully degrade when Mem0 is unreachable.
  • If assistant lookup by session key fails, still capture by falling back to the latest assistant turn globally (with warning log).
  • Prefix injected personal memories with human-readable age labels from created_at metadata when available.
  • Ship as a repository-enable hook that anyone can install in their OpenClaw gateway.

Code layout

  • hook/handler.ts — business logic. Reads config from MEM0_* env vars or ~/.openclaw/mem0.json. Handles received/preprocessed/transcribed events and rewrites context.bodyForAgent with injected memory blocks when appropriate.
  • package.json & tsconfig.json — minimal metadata for building and for the OpenClaw hook loader.

Configuration

Defaults are documented in README.md. Keep a sample ~/.openclaw/mem0.json near the gateway so other developers can copy it.

Deployment

  1. npm install (growth step, optional). 2. openclaw hooks install --link /path/to/hook. 3. openclaw gateway restart. 4. openclaw hooks list → hook should be ready.

Testing

  • Use openclaw hooks simulate message or create fixtures and hit handler. Ensure STT and Mem0 endpoints are mocked.
  • Run while connected to the actual Mem0 server at http://192.168.0.200:8420 to validate capture/recall flows.

Release checklist

  • Update package.json version.
  • Document new env var defaults in README.
  • Tag a Git release (e.g., v1.0.0).
  • If releasing publicly, include a license (MIT/Apache/…?).

Operational notes

  • Development happens in /home/lucky/.openclaw/workspace/mem0-auto-capture-hook (the Git workspace that holds the docs and project files). Do not edit the installed hook copy directly.
  • The hook that OpenClaw loads at runtime lives in /home/lucky/.openclaw/workspace/hooks/mem0-auto-capture; keep it synced via openclaw hooks install --link /home/lucky/.openclaw/workspace/mem0-auto-capture-hook/hook whenever the handler changes.
  • There’s no manual compilation step—OpenClaw executes the TypeScript file directly—so reinstalling the hook and restarting the gateway is sufficient after edits (re-running the install command only matters if you need to refresh the symlink).

Maintainer: Lukas Goldschmidt / GOLEM assistant (builds, tests, deploys).