[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M75NG4N0WHDAQXQ5FK42GDH2":3,"skill-same:01M75NG4N0WHDAQXQ5FK42GDH2":61},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":19,"linkOnly":20,"markdownContent":21,"markdownBody":22,"frontMatter":23,"refName":38,"commitSha":39,"skillDirectory":40,"forksCount":41,"repositoryHtmlUrl":42,"repositoryHomepageUrl":6,"ownerHtmlUrl":43,"ownerBlogUrl":44,"ownerDescription":45,"updatedAt":46,"install":47,"resources":60},"01M75NG4N0WHDAQXQ5FK42GDH2","surrealdb-memory",null,"A comprehensive knowledge graph memory system with semantic search, episodic memory, working memory, automatic context injection, and per-agent isolation.","javimosch\u002Fopen-claw-skills","javimosch","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F12900508?v=4","01M6D3F2AS6PV75ET9PZ1QGP8J","Javier Leandro Arancibia","01M75B8NCTAJG9WH5YNZH7C3D8",0,"MIT","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fmaverick-software\u002Fsurrealdb-knowledge-graph-memory\u002FSKILL.md",[],[],"2026-11-12 13:55:43",false,"---\nname: surrealdb-memory\ndescription: \"A comprehensive knowledge graph memory system with semantic search, episodic memory, working memory, automatic context injection, and per-agent isolation.\"\nversion: 2.2.2\nmetadata:\n  openclaw:\n    requires:\n      env:\n        - OPENAI_API_KEY\n        - SURREAL_USER\n        - SURREAL_PASS\n        - SURREAL_URL\n      bins:\n        - surreal\n        - python3\n    primaryEnv: OPENAI_API_KEY\n    emoji: \"🧠\"\n    homepage: \"https:\u002F\u002Fclawhub.com\u002Fskills\u002Fsurrealdb-knowledge-graph-memory\"\n---\n\n# SurrealDB Knowledge Graph Memory v2.2\n\nA comprehensive knowledge graph memory system with semantic search, episodic memory, working memory, automatic context injection, and **per-agent isolation** — enabling every agent to become a continuously self-improving AI.\n\n## Description\n\nUse this skill for:\n- **Semantic Memory** — Store and retrieve facts with confidence-weighted vector search\n- **Episodic Memory** — Record task histories and learn from past experiences\n- **Working Memory** — Track active task state with crash recovery\n- **Auto-Injection** — Automatically inject relevant context into agent prompts\n- **Outcome Calibration** — Facts gain\u002Flose confidence based on task outcomes\n- **Self-Improvement** — Scheduled extraction and relation discovery make every agent smarter over time\n\n**Triggers:** \"remember this\", \"store fact\", \"what do you know about\", \"memory search\", \"find similar tasks\", \"learn from history\"\n\n> **Security:** This skill reads workspace memory files and sends their content to OpenAI for extraction. It registers two background cron jobs and (optionally) patches OpenClaw source files. All behaviors are opt-in or documented. See [SECURITY.md](SECURITY.md) for the full breakdown before enabling.\n>\n> **Required:** `OPENAI_API_KEY`, `surreal` binary, `python3` ≥3.10\n\n---\n\n## 🔄 Self-Improving Agent Loop\n\nThis is the core concept: **every agent equipped with this skill improves itself automatically**, with no manual intervention required. Two scheduled cron jobs — knowledge extraction and relationship correlation — run on a fixed schedule and continuously grow the knowledge graph. Combined with auto-injection, the agent gets progressively smarter with each conversation.\n\n### The Cycle\n\n```\n[Agent Conversation]\n       ↓  stores important facts via knowledge_store_sync\n[Memory Files]  ← agent writes to MEMORY.md \u002F daily memory\u002F*.md files\n       ↓  every 6 hours — extraction cron fires\n[Entity + Fact Extraction]  ← LLM reads files, extracts structured facts + entities\n       ↓  facts stored with embeddings + agent_id tag\n[Knowledge Graph]  ← SurrealDB: facts, entities, mentions\n       ↓  daily at 3 AM — relation discovery cron fires\n[Relationship Correlation]  ← AI finds semantic links between facts\n       ↓  relates_to edges created between connected facts\n[Richer Knowledge Graph]  ← facts are no longer isolated; they form a web\n       ↓  on every new message — auto-injection reads the graph\n[Context Window]  ← relevant facts + relations + episodes injected automatically\n       ↓\n[Better Responses]  ← agent uses accumulated knowledge to respond more accurately\n       ↑  new insights written back to memory files → cycle repeats\n```\n\n### What Each Scheduled Job Does\n\n#### Job 1 — Knowledge Extraction (every 6 hours)\n**Script:** `scripts\u002Fextract-knowledge.py extract`\n\n- Reads `MEMORY.md` and all `memory\u002FYYYY-MM-DD.md` files in the workspace\n- Uses an LLM (GPT-4) to extract structured facts, entities, and key concepts\n- Hashes file content to skip unchanged files — only processes diffs\n- Stores each fact with:\n  - A vector embedding (OpenAI `text-embedding-3-small`) for semantic search\n  - A `confidence` score (defaults to 0.9)\n  - An `agent_id` tag so facts stay isolated to the right agent\n  - `source` metadata pointing back to the originating file\n- Result: raw conversational knowledge becomes searchable, structured memory\n\n#### Job 2 — Relationship Correlation (daily at 3 AM)\n**Script:** `scripts\u002Fextract-knowledge.py discover-relations`\n\n- Queries the graph for facts that have no relationships yet (\"isolated facts\")\n- Batches them and asks an LLM to identify semantic connections between them\n- Creates `relates_to` edges in SurrealDB linking related facts\n- Result: isolated facts become a **connected knowledge web** — the agent can now traverse relationships, not just keyword-match\n- Over time, the graph evolves from a flat list into a rich semantic network\n\n#### Job 3 — Deduplication (daily at 4 AM)\n**Script:** `scripts\u002Fextract-knowledge.py dedupe --threshold 0.92`\n\n- Compares all facts using vector similarity (cosine distance)\n- Facts above the threshold (92% similar) are flagged as duplicates\n- Keeps the higher-confidence fact, removes the duplicate\n- Prevents extraction from creating bloat over time\n- Result: a clean, non-redundant knowledge base\n\n#### Job 4 — Reconciliation (weekly, Sundays at 5 AM)\n**Script:** `scripts\u002Fextract-knowledge.py reconcile --verbose`\n\n- Applies time-based confidence decay to aging facts\n- Prunes facts that have decayed below minimum confidence\n- Cleans orphaned entities with no linked facts\n- Consolidates near-duplicate entities\n- Result: the knowledge graph stays healthy, relevant, and pruned of stale information\n\n### Why This Makes Agents Self-Improving\n\nWhen auto-injection is enabled, every new conversation starts with the most relevant slice of the accumulated knowledge graph. As the agent:\n1. Has conversations → writes insights to memory files\n2. Extraction job fires → converts those insights into structured facts\n3. Relation job fires → connects those facts to existing knowledge\n4. Next conversation → auto-injection pulls in richer, more connected context\n\n...the agent effectively gets smarter with every cycle. It learns from its own outputs, grounds future responses in its accumulated history, and avoids repeating mistakes (via episodic memory and outcome calibration).\n\n### OpenClaw Cron Jobs (Required)\n\nThe skill requires **5 cron jobs** for full self-improving operation. All run as isolated background sessions with no delivery:\n\n| Job Name | Schedule | What it runs |\n|----------|----------|--------------|\n| Memory Knowledge Extraction | Every 6 hours (`0 *\u002F6 * * *`) | `extract-knowledge.py extract` — extracts facts from memory files |\n| Memory Relation Discovery | Daily at 3 AM (`0 3 * * *`) | `extract-knowledge.py discover-relations` — AI-powered relationship finding |\n| Memory Deduplication | Daily at 4 AM (`0 4 * * *`) | `extract-knowledge.py dedupe --threshold 0.92` — removes duplicate\u002Fnear-duplicate facts |\n| Memory Reconciliation | Weekly Sun 5 AM (`0 5 * * 0`) | `extract-knowledge.py reconcile --verbose` — prunes stale facts, applies confidence decay, cleans orphans |\n\n> All jobs use `sessionTarget: \"isolated\"` with `delivery: none`. They run in fully isolated background sessions and **never fire into the main agent session**. A bottom-right corner toast notification appears in the Control UI when each job starts and completes.\n\n**Setup commands** (run after installation):\n\n```bash\n# 1. Knowledge Extraction — every 6 hours\nopenclaw cron add \\\n  --name \"Memory Knowledge Extraction\" \\\n  --cron \"0 *\u002F6 * * *\" \\\n  --agent main --session isolated --no-deliver \\\n  --timeout-seconds 300 \\\n  --message \"Run memory knowledge extraction. Execute: cd SKILL_DIR && source .venv\u002Fbin\u002Factivate && python3 scripts\u002Fextract-knowledge.py extract\"\n\n# 2. Relation Discovery — daily at 3 AM\nopenclaw cron add \\\n  --name \"Memory Relation Discovery\" \\\n  --cron \"0 3 * * *\" --exact \\\n  --agent main --session isolated --no-deliver \\\n  --timeout-seconds 300 \\\n  --message \"Run memory relation discovery. Execute: cd SKILL_DIR && source .venv\u002Fbin\u002Factivate && python3 scripts\u002Fextract-knowledge.py discover-relations\"\n\n# 3. Deduplication — daily at 4 AM\nopenclaw cron add \\\n  --name \"Memory Deduplication\" \\\n  --cron \"0 4 * * *\" --exact \\\n  --agent main --session isolated --no-deliver \\\n  --timeout-seconds 120 \\\n  --message \"Run knowledge graph deduplication. Execute: cd SKILL_DIR && source .venv\u002Fbin\u002Factivate && python3 scripts\u002Fextract-knowledge.py dedupe --threshold 0.92\"\n\n# 4. Reconciliation — weekly on Sundays at 5 AM\nopenclaw cron add \\\n  --name \"Memory Reconciliation\" \\\n  --cron \"0 5 * * 0\" --exact \\\n  --agent main --session isolated --no-deliver \\\n  --timeout-seconds 180 \\\n  --message \"Run knowledge graph reconciliation. Execute: cd SKILL_DIR && source .venv\u002Fbin\u002Factivate && python3 scripts\u002Fextract-knowledge.py reconcile --verbose\"\n```\n\n> Replace `SKILL_DIR` with your actual skill path.\n\nTo check job status:\n```bash\nopenclaw cron list\n```\n\n### Adding Cron Jobs for a New Agent\n\nWhen spawning a new agent that should self-improve, register its own extraction job:\n\n```bash\n# OpenClaw cron add (via Koda) — example for a 'scout-monitor' agent\n# Schedule: every 6h, extract facts tagged to scout-monitor\npython3 scripts\u002Fextract-knowledge.py extract --agent-id scout-monitor\n```\n\nThe `--agent-id` flag ensures extracted facts are isolated to that agent's pool and don't pollute the main agent's knowledge. Each agent self-improves independently while still reading shared `scope='global'` facts.\n\n---\n\n## Features (v2.2)\n\n| Feature | Description |\n|---------|-------------|\n| **Semantic Facts** | Vector-indexed facts with confidence scoring |\n| **Episodic Memory** | Task histories with decisions, problems, solutions, learnings |\n| **Working Memory** | YAML-based task state that survives crashes |\n| **Outcome Calibration** | Facts used in successful tasks gain confidence |\n| **Auto-Injection** | Relevant facts\u002Fepisodes injected into prompts automatically |\n| **Entity Extraction** | Automatic entity linking and relationship discovery |\n| **Confidence Decay** | Stale facts naturally decay over time |\n| **Agent Isolation** | Each agent has its own scoped memory pool; `scope='global'` facts are shared across all agents |\n| **Self-Improving Loop** | Scheduled extraction + relation discovery automatically grow the graph |\n\n---\n\n## Agent Isolation (v2.2)\n\nEach agent in OpenClaw has its own scoped memory pool. Facts are tagged with `agent_id` on write; all read queries filter to `(agent_id = $agent_id OR scope = 'global')`.\n\n### How it works\n\n```\nAgent A (main)          Agent B (scout-monitor)\n   ┌──────────┐              ┌──────────┐\n   │ 391 facts│              │   0 facts│   ← isolated pools\n   └──────────┘              └──────────┘\n         ↑                         ↑\n         └──── scope='global' ─────┘   ← shared facts visible to both\n```\n\n### Storing facts\n\nAll `knowledge_store` \u002F `knowledge_store_sync` calls accept `agent_id`:\n\n```bash\n# Stored to scout-monitor's pool only\nmcporter call surrealdb-memory.knowledge_store \\\n    content=\"API is healthy at \u002Fping\" \\\n    agent_id='scout-monitor'\n\n# Stored globally (visible to all agents)\nmcporter call surrealdb-memory.knowledge_store \\\n    content=\"Project uses Python 3.12\" \\\n    agent_id='main' scope='global'\n```\n\n### Auto-injection (agent-aware)\n\nWith `references\u002Fenhanced-loop-hook-agent-isolation.md` applied to `src\u002Fagents\u002Fenhanced-loop-hook.ts`, the enhanced loop automatically extracts the agent ID from the session key and passes it to `memory_inject`. No manual configuration needed — each agent's auto-injection is silently scoped to its own facts.\n\n### Extraction (agent-aware)\n\nPass `--agent-id` to `extract-knowledge.py` so cron-extracted facts are correctly tagged:\n\n```bash\npython3 scripts\u002Fextract-knowledge.py extract --agent-id scout-monitor\n```\n\nDefault is `\"main\"`. Update cron jobs accordingly for non-main agents.\n\n### Backward compatibility\n\nExisting facts without an explicit `agent_id` are treated as owned by `\"main\"`. Nothing is lost on upgrade to v2.2.\n\n---\n\n## Dashboard UI\n\nThe Memory tab in the Control dashboard provides a two-column layout:\n\n### Left Column: Dashboard\n- **📊 Statistics** — Live counts of facts, entities, relations, and archived items\n- **Confidence Bar** — Visual display of average confidence score\n- **Sources Breakdown** — Facts grouped by source file\n- **🏥 System Health** — Status of SurrealDB, schema, and Python dependencies\n- **🔗 DB Studio** — Quick link to SurrealDB's web interface\n\n### Right Column: Operations\n- **📥 Knowledge Extraction**\n  - *Extract Changes* — Incrementally extract facts from modified files\n  - *Find Relations* — Discover semantic relationships between existing facts\n  - *Full Sync* — Complete extraction + relation discovery\n  - Progress bar with real-time status updates\n  \n- **🔧 Maintenance**\n  - *Apply Decay* — Reduce confidence of stale facts\n  - *Prune Stale* — Archive facts below threshold\n  - *Full Sweep* — Complete maintenance cycle\n\n- **💡 Tips** — Quick reference for operations\n\nWhen the system needs setup, an **Installation** section appears with manual controls.\n\n---\n\n## Prerequisites\n\n1. **SurrealDB** installed and running:\n   ```bash\n   # Install (one-time)\n   .\u002Fscripts\u002Finstall.sh\n   \n   # Start server\n   surreal start --bind 127.0.0.1:8000 --user root --pass root file:~\u002F.openclaw\u002Fmemory\u002Fknowledge.db\n   ```\n\n2. **Python dependencies** (use the skill's venv):\n   ```bash\n   cd \u002Fpath\u002Fto\u002Fsurrealdb-memory\n   python3 -m venv .venv\n   source .venv\u002Fbin\u002Factivate\n   pip install surrealdb openai pyyaml\n   ```\n\n3. **OpenAI API key** for embeddings (set in OpenClaw config or environment)\n\n4. **mcporter** configured with this skill's MCP server\n\n## MCP Server Setup\n\nAdd to your `config\u002Fmcporter.json`:\n\n```json\n{\n  \"servers\": {\n    \"surrealdb-memory\": {\n      \"command\": [\"python3\", \"\u002Fpath\u002Fto\u002Fsurrealdb-memory\u002Fscripts\u002Fmcp-server-v2.py\"],\n      \"env\": {\n        \"OPENAI_API_KEY\": \"${OPENAI_API_KEY}\",\n        \"SURREAL_URL\": \"http:\u002F\u002Flocalhost:8000\",\n        \"SURREAL_USER\": \"root\",\n        \"SURREAL_PASS\": \"root\"\n      }\n    }\n  }\n}\n```\n\n---\n\n## MCP Tools (11 total)\n\n### Core Tools\n| Tool | Description |\n|------|-------------|\n| `knowledge_search` | Semantic search for facts |\n| `knowledge_recall` | Get a fact with full context (relations, entities) |\n| `knowledge_store` | Store a new fact |\n| `knowledge_stats` | Get database statistics |\n\n### v2 Tools\n| Tool | Description |\n|------|-------------|\n| `knowledge_store_sync` | Store with importance routing (high importance = immediate write) |\n| `episode_search` | Find similar past tasks |\n| `episode_learnings` | Get actionable learnings from history |\n| `episode_store` | Record a completed task episode |\n| `working_memory_status` | Get current task state |\n| `context_aware_search` | Search with task context boosting |\n| `memory_inject` | **Intelligent context injection for prompts** |\n\n### memory_inject Tool\n\nThe `memory_inject` tool returns formatted context ready for prompt injection:\n\n```bash\n# Scoped to a specific agent (returns only that agent's facts + global facts)\nmcporter call surrealdb-memory.memory_inject \\\n    query=\"user message\" \\\n    max_facts:7 \\\n    max_episodes:3 \\\n    confidence_threshold:0.9 \\\n    include_relations:true \\\n    agent_id='scout-monitor'\n```\n\n**Output:**\n```markdown\n## Semantic Memory (Relevant Facts)\n📌 [60% relevant, 100% confidence] Relevant fact here...\n\n## Related Entities\n• Entity Name (type)\n\n## Episodic Memory (Past Experiences)\n✅ Task: Previous task goal [similarity]\n   → Key learning from that task\n```\n\n---\n\n## Auto-Injection (Enhanced Loop Integration)\n\nWhen enabled, memory is automatically injected into every agent turn:\n\n1. **Enable in Mode UI:**\n   - Open Control dashboard → Mode tab\n   - Scroll to \"🧠 Memory & Knowledge Graph\" section\n   - Toggle \"Auto-Inject Context\"\n   - Configure limits (max facts, max episodes, confidence threshold)\n\n2. **How it works:**\n   - On each user message, `memory_inject` is called automatically\n   - Relevant facts are searched based on the user's query\n   - If average fact confidence \u003C threshold, episodic memories are included\n   - Formatted context is injected into the agent's system prompt\n   - **v2.2:** With `references\u002Fenhanced-loop-hook-agent-isolation.md` applied, the active agent's ID is automatically extracted from the session key and passed as `agent_id` — each agent's injection is silently scoped to its own facts\n\n3. **Configuration (in Mode settings):**\n   | Setting | Default | Description |\n   |---------|---------|-------------|\n   | Auto-Inject Context | Off | Master toggle |\n   | Max Facts | 7 | Maximum semantic facts to inject |\n   | Max Episodes | 3 | Maximum episodic memories |\n   | Confidence Threshold | 90% | Include episodes when below this |\n   | Include Relations | On | Include entity relationships |\n\n---\n\n## CLI Commands\n\n```bash\n# Activate venv\nsource .venv\u002Fbin\u002Factivate\n\n# Store a fact\npython scripts\u002Fmemory-cli.py store \"Important fact\" --confidence 0.9\n\n# Search\npython scripts\u002Fmemory-cli.py search \"query\"\n\n# Get stats\npython scripts\u002Fknowledge-tool.py stats\n\n# Run maintenance\npython scripts\u002Fmemory-cli.py maintain\n\n# Extract from files (incremental)\npython scripts\u002Fextract-knowledge.py extract\n\n# Extract for a specific agent\npython scripts\u002Fextract-knowledge.py extract --agent-id scout-monitor\n\n# Force full extraction (all files, not just changed)\npython scripts\u002Fextract-knowledge.py extract --full\n\n# Discover semantic relationships\npython scripts\u002Fextract-knowledge.py discover-relations\n```\n\n---\n\n## Database Schema (v2)\n\n### Tables\n- `fact` — Semantic facts with embeddings and confidence\n- `entity` — Extracted entities (people, places, concepts)\n- `relates_to` — Relationships between facts\n- `mentions` — Fact-to-entity links\n- `episode` — Task histories with outcomes\n- `working_memory` — Active task snapshots\n\n### Key Fields (fact)\n- `content` — The fact text\n- `embedding` — Vector for semantic search\n- `confidence` — Base confidence (0-1)\n- `success_count` \u002F `failure_count` — Outcome tracking\n- `scope` — global, client, or agent\n- `agent_id` — Which agent owns this fact (v2.2)\n\n### Key Fields (episode)\n- `goal` — What was attempted\n- `outcome` — success, failure, abandoned\n- `decisions` — Key decisions made\n- `problems` — Problems encountered (structured)\n- `solutions` — Solutions applied (structured)\n- `key_learnings` — Extracted lessons\n\n---\n\n## Confidence Scoring\n\nEffective confidence is calculated from:\n- **Base confidence** (0.0–1.0)\n- **+ Inherited boost** from supporting facts\n- **+ Entity boost** from well-established entities\n- **+ Outcome adjustment** based on success\u002Ffailure history\n- **- Contradiction drain** from conflicting facts\n- **- Time decay** (configurable, ~5% per month)\n\n---\n\n## Maintenance\n\n### Automated — OpenClaw Cron (as deployed)\n\nThe self-improving loop runs via **4 registered OpenClaw cron jobs**:\n\n```\nEvery 6h     → extract-knowledge.py extract            (extract facts from memory files)\nDaily 3 AM   → extract-knowledge.py discover-relations  (find relationships between facts)\nDaily 4 AM   → extract-knowledge.py dedupe              (remove duplicate facts)\nWeekly Sun   → extract-knowledge.py reconcile            (prune stale, decay, clean orphans)\n```\n\nSee the \"OpenClaw Cron Jobs (Required)\" section above for setup commands.\n\nTo verify they're active:\n```bash\nopenclaw cron list\n```\n\nTo manually trigger any job:\n```bash\ncd SKILL_DIR && source .venv\u002Fbin\u002Factivate\npython3 scripts\u002Fextract-knowledge.py extract\npython3 scripts\u002Fextract-knowledge.py discover-relations\npython3 scripts\u002Fextract-knowledge.py dedupe --threshold 0.92\npython3 scripts\u002Fextract-knowledge.py reconcile --verbose\n```\n\n### Manual (UI)\nUse the **Maintenance** section in the Memory tab:\n- **Apply Decay** — Reduce confidence of stale facts\n- **Prune Stale** — Archive facts below 0.3 confidence\n- **Full Sweep** — Run complete maintenance cycle\n\n---\n\n## Files\n\n### Scripts\n| File | Purpose |\n|------|---------|\n| `mcp-server-v2.py` | MCP server with all 11 tools |\n| `mcp-server.py` | Legacy v1 MCP server |\n| `episodes.py` | Episodic memory module |\n| `working_memory.py` | Working memory module |\n| `memory-cli.py` | CLI for manual operations |\n| `extract-knowledge.py` | Bulk extraction from files (supports `--agent-id`) |\n| `knowledge-tools.py` | Higher-level extraction |\n| `schema-v2.sql` | v2 database schema |\n| `migrate-v2.py` | Migration script |\n\n### Integration\n| File | Purpose |\n|------|---------|\n| `openclaw-integration\u002Fgateway\u002Fmemory.ts` | Gateway server methods |\n| `openclaw-integration\u002Fui\u002Fmemory-view.ts` | Memory dashboard UI |\n| `openclaw-integration\u002Fui\u002Fmemory-controller.ts` | UI controller |\n\n---\n\n## Troubleshooting\n\n**\"Connection refused\"**\n→ Start SurrealDB: `surreal start --bind 127.0.0.1:8000 --user root --pass root file:~\u002F.openclaw\u002Fmemory\u002Fknowledge.db`\n\n**\"No MCP servers configured\"**\n→ Ensure mcporter is run from a directory containing `config\u002Fmcporter.json` with the surrealdb-memory server defined\n\n**Memory injection returning null**\n→ Check that `OPENAI_API_KEY` is set in the environment\n→ Verify SurrealDB is running and schema is initialized\n\n**Empty search results**\n→ Run extraction from the UI or via CLI: `python3 scripts\u002Fextract-knowledge.py extract`\n\n**\"No facts to analyze\" on relation discovery**\n→ This is normal if all facts are already related — the graph is well-connected. Run extraction first if the graph is empty.\n\n**Progress bar not updating**\n→ Ensure the gateway has been restarted after UI updates\n→ Check browser console for polling errors\n\n**Facts from wrong agent appearing**\n→ Check that `agent_id` is being passed correctly to all store\u002Fsearch calls\n→ Verify `references\u002Fenhanced-loop-hook-agent-isolation.md` is applied for auto-injection scoping\n\n---\n\n## Migration from v1 \u002F v2.1\n\n```bash\n# Apply v2 schema (additive, won't delete existing data)\n.\u002Fscripts\u002Fmigrate-v2.sh\n\n# Or manually:\nsource .venv\u002Fbin\u002Factivate\npython scripts\u002Fmigrate-v2.py\n```\n\nAll existing facts without an `agent_id` are treated as owned by `\"main\"` — backward compatible.\n\n---\n\n## Stats\n\nCheck your knowledge graph via UI (Dashboard section) or CLI:\n```bash\nmcporter call surrealdb-memory.knowledge_stats\n```\n\nExample output:\n```json\n{\n  \"facts\": 379,\n  \"entities\": 485,\n  \"relations\": 106,\n  \"episodes\": 3,\n  \"avg_confidence\": 0.99\n}\n```\n\n---\n\n*v2.2 — Agent isolation, self-improving loop, cron-based extraction & relationship correlation*\n","# SurrealDB Knowledge Graph Memory v2.2\n\nA comprehensive knowledge graph memory system with semantic search, episodic memory, working memory, automatic context injection, and **per-agent isolation** — enabling every agent to become a continuously self-improving AI.\n\n## Description\n\nUse this skill for:\n- **Semantic Memory** — Store and retrieve facts with confidence-weighted vector search\n- **Episodic Memory** — Record task histories and learn from past experiences\n- **Working Memory** — Track active task state with crash recovery\n- **Auto-Injection** — Automatically inject relevant context into agent prompts\n- **Outcome Calibration** — Facts gain\u002Flose confidence based on task outcomes\n- **Self-Improvement** — Scheduled extraction and relation discovery make every agent smarter over time\n\n**Triggers:** \"remember this\", \"store fact\", \"what do you know about\", \"memory search\", \"find similar tasks\", \"learn from history\"\n\n> **Security:** This skill reads workspace memory files and sends their content to OpenAI for extraction. It registers two background cron jobs and (optionally) patches OpenClaw source files. All behaviors are opt-in or documented. See [SECURITY.md](SECURITY.md) for the full breakdown before enabling.\n>\n> **Required:** `OPENAI_API_KEY`, `surreal` binary, `python3` ≥3.10\n\n---\n\n## 🔄 Self-Improving Agent Loop\n\nThis is the core concept: **every agent equipped with this skill improves itself automatically**, with no manual intervention required. Two scheduled cron jobs — knowledge extraction and relationship correlation — run on a fixed schedule and continuously grow the knowledge graph. Combined with auto-injection, the agent gets progressively smarter with each conversation.\n\n### The Cycle\n\n```\n[Agent Conversation]\n       ↓  stores important facts via knowledge_store_sync\n[Memory Files]  ← agent writes to MEMORY.md \u002F daily memory\u002F*.md files\n       ↓  every 6 hours — extraction cron fires\n[Entity + Fact Extraction]  ← LLM reads files, extracts structured facts + entities\n       ↓  facts stored with embeddings + agent_id tag\n[Knowledge Graph]  ← SurrealDB: facts, entities, mentions\n       ↓  daily at 3 AM — relation discovery cron fires\n[Relationship Correlation]  ← AI finds semantic links between facts\n       ↓  relates_to edges created between connected facts\n[Richer Knowledge Graph]  ← facts are no longer isolated; they form a web\n       ↓  on every new message — auto-injection reads the graph\n[Context Window]  ← relevant facts + relations + episodes injected automatically\n       ↓\n[Better Responses]  ← agent uses accumulated knowledge to respond more accurately\n       ↑  new insights written back to memory files → cycle repeats\n```\n\n### What Each Scheduled Job Does\n\n#### Job 1 — Knowledge Extraction (every 6 hours)\n**Script:** `scripts\u002Fextract-knowledge.py extract`\n\n- Reads `MEMORY.md` and all `memory\u002FYYYY-MM-DD.md` files in the workspace\n- Uses an LLM (GPT-4) to extract structured facts, entities, and key concepts\n- Hashes file content to skip unchanged files — only processes diffs\n- Stores each fact with:\n  - A vector embedding (OpenAI `text-embedding-3-small`) for semantic search\n  - A `confidence` score (defaults to 0.9)\n  - An `agent_id` tag so facts stay isolated to the right agent\n  - `source` metadata pointing back to the originating file\n- Result: raw conversational knowledge becomes searchable, structured memory\n\n#### Job 2 — Relationship Correlation (daily at 3 AM)\n**Script:** `scripts\u002Fextract-knowledge.py discover-relations`\n\n- Queries the graph for facts that have no relationships yet (\"isolated facts\")\n- Batches them and asks an LLM to identify semantic connections between them\n- Creates `relates_to` edges in SurrealDB linking related facts\n- Result: isolated facts become a **connected knowledge web** — the agent can now traverse relationships, not just keyword-match\n- Over time, the graph evolves from a flat list into a rich semantic network\n\n#### Job 3 — Deduplication (daily at 4 AM)\n**Script:** `scripts\u002Fextract-knowledge.py dedupe --threshold 0.92`\n\n- Compares all facts using vector similarity (cosine distance)\n- Facts above the threshold (92% similar) are flagged as duplicates\n- Keeps the higher-confidence fact, removes the duplicate\n- Prevents extraction from creating bloat over time\n- Result: a clean, non-redundant knowledge base\n\n#### Job 4 — Reconciliation (weekly, Sundays at 5 AM)\n**Script:** `scripts\u002Fextract-knowledge.py reconcile --verbose`\n\n- Applies time-based confidence decay to aging facts\n- Prunes facts that have decayed below minimum confidence\n- Cleans orphaned entities with no linked facts\n- Consolidates near-duplicate entities\n- Result: the knowledge graph stays healthy, relevant, and pruned of stale information\n\n### Why This Makes Agents Self-Improving\n\nWhen auto-injection is enabled, every new conversation starts with the most relevant slice of the accumulated knowledge graph. As the agent:\n1. Has conversations → writes insights to memory files\n2. Extraction job fires → converts those insights into structured facts\n3. Relation job fires → connects those facts to existing knowledge\n4. Next conversation → auto-injection pulls in richer, more connected context\n\n...the agent effectively gets smarter with every cycle. It learns from its own outputs, grounds future responses in its accumulated history, and avoids repeating mistakes (via episodic memory and outcome calibration).\n\n### OpenClaw Cron Jobs (Required)\n\nThe skill requires **5 cron jobs** for full self-improving operation. All run as isolated background sessions with no delivery:\n\n| Job Name | Schedule | What it runs |\n|----------|----------|--------------|\n| Memory Knowledge Extraction | Every 6 hours (`0 *\u002F6 * * *`) | `extract-knowledge.py extract` — extracts facts from memory files |\n| Memory Relation Discovery | Daily at 3 AM (`0 3 * * *`) | `extract-knowledge.py discover-relations` — AI-powered relationship finding |\n| Memory Deduplication | Daily at 4 AM (`0 4 * * *`) | `extract-knowledge.py dedupe --threshold 0.92` — removes duplicate\u002Fnear-duplicate facts |\n| Memory Reconciliation | Weekly Sun 5 AM (`0 5 * * 0`) | `extract-knowledge.py reconcile --verbose` — prunes stale facts, applies confidence decay, cleans orphans |\n\n> All jobs use `sessionTarget: \"isolated\"` with `delivery: none`. They run in fully isolated background sessions and **never fire into the main agent session**. A bottom-right corner toast notification appears in the Control UI when each job starts and completes.\n\n**Setup commands** (run after installation):\n\n```bash\n# 1. Knowledge Extraction — every 6 hours\nopenclaw cron add \\\n  --name \"Memory Knowledge Extraction\" \\\n  --cron \"0 *\u002F6 * * *\" \\\n  --agent main --session isolated --no-deliver \\\n  --timeout-seconds 300 \\\n  --message \"Run memory knowledge extraction. Execute: cd SKILL_DIR && source .venv\u002Fbin\u002Factivate && python3 scripts\u002Fextract-knowledge.py extract\"\n\n# 2. Relation Discovery — daily at 3 AM\nopenclaw cron add \\\n  --name \"Memory Relation Discovery\" \\\n  --cron \"0 3 * * *\" --exact \\\n  --agent main --session isolated --no-deliver \\\n  --timeout-seconds 300 \\\n  --message \"Run memory relation discovery. Execute: cd SKILL_DIR && source .venv\u002Fbin\u002Factivate && python3 scripts\u002Fextract-knowledge.py discover-relations\"\n\n# 3. Deduplication — daily at 4 AM\nopenclaw cron add \\\n  --name \"Memory Deduplication\" \\\n  --cron \"0 4 * * *\" --exact \\\n  --agent main --session isolated --no-deliver \\\n  --timeout-seconds 120 \\\n  --message \"Run knowledge graph deduplication. Execute: cd SKILL_DIR && source .venv\u002Fbin\u002Factivate && python3 scripts\u002Fextract-knowledge.py dedupe --threshold 0.92\"\n\n# 4. Reconciliation — weekly on Sundays at 5 AM\nopenclaw cron add \\\n  --name \"Memory Reconciliation\" \\\n  --cron \"0 5 * * 0\" --exact \\\n  --agent main --session isolated --no-deliver \\\n  --timeout-seconds 180 \\\n  --message \"Run knowledge graph reconciliation. Execute: cd SKILL_DIR && source .venv\u002Fbin\u002Factivate && python3 scripts\u002Fextract-knowledge.py reconcile --verbose\"\n```\n\n> Replace `SKILL_DIR` with your actual skill path.\n\nTo check job status:\n```bash\nopenclaw cron list\n```\n\n### Adding Cron Jobs for a New Agent\n\nWhen spawning a new agent that should self-improve, register its own extraction job:\n\n```bash\n# OpenClaw cron add (via Koda) — example for a 'scout-monitor' agent\n# Schedule: every 6h, extract facts tagged to scout-monitor\npython3 scripts\u002Fextract-knowledge.py extract --agent-id scout-monitor\n```\n\nThe `--agent-id` flag ensures extracted facts are isolated to that agent's pool and don't pollute the main agent's knowledge. Each agent self-improves independently while still reading shared `scope='global'` facts.\n\n---\n\n## Features (v2.2)\n\n| Feature | Description |\n|---------|-------------|\n| **Semantic Facts** | Vector-indexed facts with confidence scoring |\n| **Episodic Memory** | Task histories with decisions, problems, solutions, learnings |\n| **Working Memory** | YAML-based task state that survives crashes |\n| **Outcome Calibration** | Facts used in successful tasks gain confidence |\n| **Auto-Injection** | Relevant facts\u002Fepisodes injected into prompts automatically |\n| **Entity Extraction** | Automatic entity linking and relationship discovery |\n| **Confidence Decay** | Stale facts naturally decay over time |\n| **Agent Isolation** | Each agent has its own scoped memory pool; `scope='global'` facts are shared across all agents |\n| **Self-Improving Loop** | Scheduled extraction + relation discovery automatically grow the graph |\n\n---\n\n## Agent Isolation (v2.2)\n\nEach agent in OpenClaw has its own scoped memory pool. Facts are tagged with `agent_id` on write; all read queries filter to `(agent_id = $agent_id OR scope = 'global')`.\n\n### How it works\n\n```\nAgent A (main)          Agent B (scout-monitor)\n   ┌──────────┐              ┌──────────┐\n   │ 391 facts│              │   0 facts│   ← isolated pools\n   └──────────┘              └──────────┘\n         ↑                         ↑\n         └──── scope='global' ─────┘   ← shared facts visible to both\n```\n\n### Storing facts\n\nAll `knowledge_store` \u002F `knowledge_store_sync` calls accept `agent_id`:\n\n```bash\n# Stored to scout-monitor's pool only\nmcporter call surrealdb-memory.knowledge_store \\\n    content=\"API is healthy at \u002Fping\" \\\n    agent_id='scout-monitor'\n\n# Stored globally (visible to all agents)\nmcporter call surrealdb-memory.knowledge_store \\\n    content=\"Project uses Python 3.12\" \\\n    agent_id='main' scope='global'\n```\n\n### Auto-injection (agent-aware)\n\nWith `references\u002Fenhanced-loop-hook-agent-isolation.md` applied to `src\u002Fagents\u002Fenhanced-loop-hook.ts`, the enhanced loop automatically extracts the agent ID from the session key and passes it to `memory_inject`. No manual configuration needed — each agent's auto-injection is silently scoped to its own facts.\n\n### Extraction (agent-aware)\n\nPass `--agent-id` to `extract-knowledge.py` so cron-extracted facts are correctly tagged:\n\n```bash\npython3 scripts\u002Fextract-knowledge.py extract --agent-id scout-monitor\n```\n\nDefault is `\"main\"`. Update cron jobs accordingly for non-main agents.\n\n### Backward compatibility\n\nExisting facts without an explicit `agent_id` are treated as owned by `\"main\"`. Nothing is lost on upgrade to v2.2.\n\n---\n\n## Dashboard UI\n\nThe Memory tab in the Control dashboard provides a two-column layout:\n\n### Left Column: Dashboard\n- **📊 Statistics** — Live counts of facts, entities, relations, and archived items\n- **Confidence Bar** — Visual display of average confidence score\n- **Sources Breakdown** — Facts grouped by source file\n- **🏥 System Health** — Status of SurrealDB, schema, and Python dependencies\n- **🔗 DB Studio** — Quick link to SurrealDB's web interface\n\n### Right Column: Operations\n- **📥 Knowledge Extraction**\n  - *Extract Changes* — Incrementally extract facts from modified files\n  - *Find Relations* — Discover semantic relationships between existing facts\n  - *Full Sync* — Complete extraction + relation discovery\n  - Progress bar with real-time status updates\n  \n- **🔧 Maintenance**\n  - *Apply Decay* — Reduce confidence of stale facts\n  - *Prune Stale* — Archive facts below threshold\n  - *Full Sweep* — Complete maintenance cycle\n\n- **💡 Tips** — Quick reference for operations\n\nWhen the system needs setup, an **Installation** section appears with manual controls.\n\n---\n\n## Prerequisites\n\n1. **SurrealDB** installed and running:\n   ```bash\n   # Install (one-time)\n   .\u002Fscripts\u002Finstall.sh\n   \n   # Start server\n   surreal start --bind 127.0.0.1:8000 --user root --pass root file:~\u002F.openclaw\u002Fmemory\u002Fknowledge.db\n   ```\n\n2. **Python dependencies** (use the skill's venv):\n   ```bash\n   cd \u002Fpath\u002Fto\u002Fsurrealdb-memory\n   python3 -m venv .venv\n   source .venv\u002Fbin\u002Factivate\n   pip install surrealdb openai pyyaml\n   ```\n\n3. **OpenAI API key** for embeddings (set in OpenClaw config or environment)\n\n4. **mcporter** configured with this skill's MCP server\n\n## MCP Server Setup\n\nAdd to your `config\u002Fmcporter.json`:\n\n```json\n{\n  \"servers\": {\n    \"surrealdb-memory\": {\n      \"command\": [\"python3\", \"\u002Fpath\u002Fto\u002Fsurrealdb-memory\u002Fscripts\u002Fmcp-server-v2.py\"],\n      \"env\": {\n        \"OPENAI_API_KEY\": \"${OPENAI_API_KEY}\",\n        \"SURREAL_URL\": \"http:\u002F\u002Flocalhost:8000\",\n        \"SURREAL_USER\": \"root\",\n        \"SURREAL_PASS\": \"root\"\n      }\n    }\n  }\n}\n```\n\n---\n\n## MCP Tools (11 total)\n\n### Core Tools\n| Tool | Description |\n|------|-------------|\n| `knowledge_search` | Semantic search for facts |\n| `knowledge_recall` | Get a fact with full context (relations, entities) |\n| `knowledge_store` | Store a new fact |\n| `knowledge_stats` | Get database statistics |\n\n### v2 Tools\n| Tool | Description |\n|------|-------------|\n| `knowledge_store_sync` | Store with importance routing (high importance = immediate write) |\n| `episode_search` | Find similar past tasks |\n| `episode_learnings` | Get actionable learnings from history |\n| `episode_store` | Record a completed task episode |\n| `working_memory_status` | Get current task state |\n| `context_aware_search` | Search with task context boosting |\n| `memory_inject` | **Intelligent context injection for prompts** |\n\n### memory_inject Tool\n\nThe `memory_inject` tool returns formatted context ready for prompt injection:\n\n```bash\n# Scoped to a specific agent (returns only that agent's facts + global facts)\nmcporter call surrealdb-memory.memory_inject \\\n    query=\"user message\" \\\n    max_facts:7 \\\n    max_episodes:3 \\\n    confidence_threshold:0.9 \\\n    include_relations:true \\\n    agent_id='scout-monitor'\n```\n\n**Output:**\n```markdown\n## Semantic Memory (Relevant Facts)\n📌 [60% relevant, 100% confidence] Relevant fact here...\n\n## Related Entities\n• Entity Name (type)\n\n## Episodic Memory (Past Experiences)\n✅ Task: Previous task goal [similarity]\n   → Key learning from that task\n```\n\n---\n\n## Auto-Injection (Enhanced Loop Integration)\n\nWhen enabled, memory is automatically injected into every agent turn:\n\n1. **Enable in Mode UI:**\n   - Open Control dashboard → Mode tab\n   - Scroll to \"🧠 Memory & Knowledge Graph\" section\n   - Toggle \"Auto-Inject Context\"\n   - Configure limits (max facts, max episodes, confidence threshold)\n\n2. **How it works:**\n   - On each user message, `memory_inject` is called automatically\n   - Relevant facts are searched based on the user's query\n   - If average fact confidence \u003C threshold, episodic memories are included\n   - Formatted context is injected into the agent's system prompt\n   - **v2.2:** With `references\u002Fenhanced-loop-hook-agent-isolation.md` applied, the active agent's ID is automatically extracted from the session key and passed as `agent_id` — each agent's injection is silently scoped to its own facts\n\n3. **Configuration (in Mode settings):**\n   | Setting | Default | Description |\n   |---------|---------|-------------|\n   | Auto-Inject Context | Off | Master toggle |\n   | Max Facts | 7 | Maximum semantic facts to inject |\n   | Max Episodes | 3 | Maximum episodic memories |\n   | Confidence Threshold | 90% | Include episodes when below this |\n   | Include Relations | On | Include entity relationships |\n\n---\n\n## CLI Commands\n\n```bash\n# Activate venv\nsource .venv\u002Fbin\u002Factivate\n\n# Store a fact\npython scripts\u002Fmemory-cli.py store \"Important fact\" --confidence 0.9\n\n# Search\npython scripts\u002Fmemory-cli.py search \"query\"\n\n# Get stats\npython scripts\u002Fknowledge-tool.py stats\n\n# Run maintenance\npython scripts\u002Fmemory-cli.py maintain\n\n# Extract from files (incremental)\npython scripts\u002Fextract-knowledge.py extract\n\n# Extract for a specific agent\npython scripts\u002Fextract-knowledge.py extract --agent-id scout-monitor\n\n# Force full extraction (all files, not just changed)\npython scripts\u002Fextract-knowledge.py extract --full\n\n# Discover semantic relationships\npython scripts\u002Fextract-knowledge.py discover-relations\n```\n\n---\n\n## Database Schema (v2)\n\n### Tables\n- `fact` — Semantic facts with embeddings and confidence\n- `entity` — Extracted entities (people, places, concepts)\n- `relates_to` — Relationships between facts\n- `mentions` — Fact-to-entity links\n- `episode` — Task histories with outcomes\n- `working_memory` — Active task snapshots\n\n### Key Fields (fact)\n- `content` — The fact text\n- `embedding` — Vector for semantic search\n- `confidence` — Base confidence (0-1)\n- `success_count` \u002F `failure_count` — Outcome tracking\n- `scope` — global, client, or agent\n- `agent_id` — Which agent owns this fact (v2.2)\n\n### Key Fields (episode)\n- `goal` — What was attempted\n- `outcome` — success, failure, abandoned\n- `decisions` — Key decisions made\n- `problems` — Problems encountered (structured)\n- `solutions` — Solutions applied (structured)\n- `key_learnings` — Extracted lessons\n\n---\n\n## Confidence Scoring\n\nEffective confidence is calculated from:\n- **Base confidence** (0.0–1.0)\n- **+ Inherited boost** from supporting facts\n- **+ Entity boost** from well-established entities\n- **+ Outcome adjustment** based on success\u002Ffailure history\n- **- Contradiction drain** from conflicting facts\n- **- Time decay** (configurable, ~5% per month)\n\n---\n\n## Maintenance\n\n### Automated — OpenClaw Cron (as deployed)\n\nThe self-improving loop runs via **4 registered OpenClaw cron jobs**:\n\n```\nEvery 6h     → extract-knowledge.py extract            (extract facts from memory files)\nDaily 3 AM   → extract-knowledge.py discover-relations  (find relationships between facts)\nDaily 4 AM   → extract-knowledge.py dedupe              (remove duplicate facts)\nWeekly Sun   → extract-knowledge.py reconcile            (prune stale, decay, clean orphans)\n```\n\nSee the \"OpenClaw Cron Jobs (Required)\" section above for setup commands.\n\nTo verify they're active:\n```bash\nopenclaw cron list\n```\n\nTo manually trigger any job:\n```bash\ncd SKILL_DIR && source .venv\u002Fbin\u002Factivate\npython3 scripts\u002Fextract-knowledge.py extract\npython3 scripts\u002Fextract-knowledge.py discover-relations\npython3 scripts\u002Fextract-knowledge.py dedupe --threshold 0.92\npython3 scripts\u002Fextract-knowledge.py reconcile --verbose\n```\n\n### Manual (UI)\nUse the **Maintenance** section in the Memory tab:\n- **Apply Decay** — Reduce confidence of stale facts\n- **Prune Stale** — Archive facts below 0.3 confidence\n- **Full Sweep** — Run complete maintenance cycle\n\n---\n\n## Files\n\n### Scripts\n| File | Purpose |\n|------|---------|\n| `mcp-server-v2.py` | MCP server with all 11 tools |\n| `mcp-server.py` | Legacy v1 MCP server |\n| `episodes.py` | Episodic memory module |\n| `working_memory.py` | Working memory module |\n| `memory-cli.py` | CLI for manual operations |\n| `extract-knowledge.py` | Bulk extraction from files (supports `--agent-id`) |\n| `knowledge-tools.py` | Higher-level extraction |\n| `schema-v2.sql` | v2 database schema |\n| `migrate-v2.py` | Migration script |\n\n### Integration\n| File | Purpose |\n|------|---------|\n| `openclaw-integration\u002Fgateway\u002Fmemory.ts` | Gateway server methods |\n| `openclaw-integration\u002Fui\u002Fmemory-view.ts` | Memory dashboard UI |\n| `openclaw-integration\u002Fui\u002Fmemory-controller.ts` | UI controller |\n\n---\n\n## Troubleshooting\n\n**\"Connection refused\"**\n→ Start SurrealDB: `surreal start --bind 127.0.0.1:8000 --user root --pass root file:~\u002F.openclaw\u002Fmemory\u002Fknowledge.db`\n\n**\"No MCP servers configured\"**\n→ Ensure mcporter is run from a directory containing `config\u002Fmcporter.json` with the surrealdb-memory server defined\n\n**Memory injection returning null**\n→ Check that `OPENAI_API_KEY` is set in the environment\n→ Verify SurrealDB is running and schema is initialized\n\n**Empty search results**\n→ Run extraction from the UI or via CLI: `python3 scripts\u002Fextract-knowledge.py extract`\n\n**\"No facts to analyze\" on relation discovery**\n→ This is normal if all facts are already related — the graph is well-connected. Run extraction first if the graph is empty.\n\n**Progress bar not updating**\n→ Ensure the gateway has been restarted after UI updates\n→ Check browser console for polling errors\n\n**Facts from wrong agent appearing**\n→ Check that `agent_id` is being passed correctly to all store\u002Fsearch calls\n→ Verify `references\u002Fenhanced-loop-hook-agent-isolation.md` is applied for auto-injection scoping\n\n---\n\n## Migration from v1 \u002F v2.1\n\n```bash\n# Apply v2 schema (additive, won't delete existing data)\n.\u002Fscripts\u002Fmigrate-v2.sh\n\n# Or manually:\nsource .venv\u002Fbin\u002Factivate\npython scripts\u002Fmigrate-v2.py\n```\n\nAll existing facts without an `agent_id` are treated as owned by `\"main\"` — backward compatible.\n\n---\n\n## Stats\n\nCheck your knowledge graph via UI (Dashboard section) or CLI:\n```bash\nmcporter call surrealdb-memory.knowledge_stats\n```\n\nExample output:\n```json\n{\n  \"facts\": 379,\n  \"entities\": 485,\n  \"relations\": 106,\n  \"episodes\": 3,\n  \"avg_confidence\": 0.99\n}\n```\n\n---\n\n*v2.2 — Agent isolation, self-improving loop, cron-based extraction & relationship correlation*\n",{"name":5,"version":24,"metadata":25,"description":7},"2.2.2",{"openclaw":26},{"emoji":27,"homepage":28,"requires":29,"primaryEnv":31},"🧠","https:\u002F\u002Fclawhub.com\u002Fskills\u002Fsurrealdb-knowledge-graph-memory",{"env":30,"bins":35},[31,32,33,34],"OPENAI_API_KEY","SURREAL_USER","SURREAL_PASS","SURREAL_URL",[36,37],"surreal","python3","main","f9d3fe7cf9ac8f1ea63a0d96e98e1f510a3814db","skills\u002Fmaverick-software\u002Fsurrealdb-knowledge-graph-memory",1,"https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills","https:\u002F\u002Fgithub.com\u002Fjavimosch","intrane.fr","Building robust, open-source infrastructure for the commons. AI-leveraged, self-hosted, built to last.","2026-06-07 03:34:58",{"source":8,"skillName":5,"commands":48,"prompt":58,"zipAvailable":59},[49,52,55],{"tool":50,"command":51},"npx","npx skills add javimosch\u002Fopen-claw-skills --skill surrealdb-memory",{"tool":53,"command":54},"bunx","bunx skills add javimosch\u002Fopen-claw-skills --skill surrealdb-memory",{"tool":56,"command":57},"pnpm","pnpm dlx skills add javimosch\u002Fopen-claw-skills --skill surrealdb-memory","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fmaverick-software\u002Fsurrealdb-knowledge-graph-memory\u002FSKILL.md",true,[],[62,70,77,84,91,98],{"skillNo":63,"name":64,"nameZh":6,"description":65,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":66,"categories":67,"keywords":68,"publishedAt":69},"01M778GGXG2VQ0YF31W2MKGMQZ","crowd-prompting","A marketplace where AI agents improve prompts, system instructions, tool descriptions, and other text-based content with domain expertise from real-world operations — and earn tokens for valuable contributions.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzzadrian\u002Fcrowd-prompting\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":74,"categories":75,"keywords":76,"publishedAt":69},"01M778G7BH8SBJ9FJ6C3G7CB1K","ceaser","Interact with the Ceaser privacy protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- shield, unshield, note management, and protocol queries. All ceaser tool calls use CLI subcommands (npx -y ceaser-mcp \u003Csubcommand>). Ceaser is a privacy-preserving ETH wrapper using Noir\u002FUltraHonk zero-knowledge proofs on Base L2 (chain ID 8453).","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyra-v21\u002Fceaser\u002FSKILL.md",[],[],{"skillNo":78,"name":79,"nameZh":6,"description":80,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":81,"categories":82,"keywords":83,"publishedAt":69},"01M778FYCJQZWFKKX5FYMK3S47","ceaser-send","Fully automated private ETH transfer via Ceaser Protocol on Base L2 using the ceaser-mcp MCP tools. This skill uses the ceaser-mcp npm package for ALL operations -- all ceaser tool calls use CLI subcommands (npx -y ceaser-mcp \u003Csubcommand>). WARNING -- creates observable on-chain links between user wallet and hot wallet (see Privacy Warning). Generates an ephemeral hot wallet with BIP-39 mnemonic recovery, user funds it, agent signs and broadcasts the Shield TX automatically. Exactly one manual step required (funding the hot wallet with ETH). Uses Noir\u002FUltraHonk zero-knowledge proofs.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyra-v21\u002Fceaser-send\u002FSKILL.md",[],[],{"skillNo":85,"name":86,"nameZh":6,"description":87,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":88,"categories":89,"keywords":90,"publishedAt":69},"01M778FQQNSEYA3HJKZBPQ4M9Z","dilemm-ai","Compete in DilemmAI, the prisoner's dilemma AI arena at dilemm.ai. Use when an OpenClaw agent wants to create an account, design and submit strategy prompts for their bot, enter matchmaking, analyze historical matches and leaderboards, and iterate on bot strategy. Requires headless browser automation (no API available yet).","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyori\u002Fdilemm-ai\u002FSKILL.md",[],[],{"skillNo":92,"name":93,"nameZh":6,"description":94,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":95,"categories":96,"keywords":97,"publishedAt":69},"01M778FGVZX7QA2TF9BFMM37FY","moldium","Post and manage content on the Moldium blog platform. Triggered by \"post to Moldium\", \"write a blog post\", \"publish an article\", etc.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzyom45\u002Fmoldium\u002FSKILL.md",[],[],{"skillNo":99,"name":100,"nameZh":6,"description":101,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":102,"categories":103,"keywords":104,"publishedAt":69},"01M778F88D8PQ9MQ0KNW2TJ8ZH","arxiv-paper-reviews","Interact with arXiv Crawler API to fetch papers, read reviews, submit comments, search papers, and import papers. Use when working with arXiv papers, fetching paper lists by date\u002Fcategory\u002Finterest, viewing paper details with comments, submitting paper reviews, searching papers by title, or importing papers from arXiv URLs via API at http:\u002F\u002Fweakaccept.top:8000\u002F.","https:\u002F\u002Fgithub.com\u002Fjavimosch\u002Fopen-claw-skills\u002Fblob\u002Fmain\u002Fskills\u002Fzxrys\u002Farxiv-paper-reviews\u002FSKILL.md",[],[]]