← 返回 Skills 市场
liliang-cn

CortexDB Agent Memory

作者 Liang Li · GitHub ↗ · v1.0.0 · MIT-0
cross-platform ✓ 安全检测通过
42
总下载
1
收藏
1
当前安装
1
版本数
在 OpenClaw 中安装
/install cortexdb-agent-memory
功能描述
Give a Node.js agent (such as OpenClaw) durable, local-first memory plus a queryable SPARQL knowledge graph, backed by CortexDB through its gRPC sidecar and...
使用说明 (SKILL.md)

CortexDB memory for a Node agent (OpenClaw)

Wire CortexDB in as the memory layer for a Node.js agent. CortexDB is a pure-Go, single-file database; the Node agent talks to it over gRPC via the cortexdb-client package. Beyond vector/lexical recall, it gives the agent a real knowledge graph (RDF + SPARQL) — the thing most agent-memory layers lack. It fits OpenClaw's local-first philosophy: one binary, one SQLite file, no separate service to stand up.

When to use this

  • The agent should remember user facts/preferences across turns or sessions.
  • The agent should recall memories by meaning, not exact match.
  • The agent needs entities + relations and multi-hop questions ("who, among the people Alice knows, works on X").
  • You're integrating with OpenClaw (or any Node agent/skill).

Step 1 — Run the sidecar (once)

# install the binary (or download a prebuilt release)
go install github.com/liliang-cn/cortexdb/v2/cmd/cortexdb-grpc@latest

# lexical mode — zero config, no API key:
CORTEXDB_PATH=agent.db CORTEXDB_GRPC_TOKEN=s3cret cortexdb-grpc
# → listening on 127.0.0.1:47821

Enable vector/semantic recall by pointing it at any OpenAI-compatible embeddings endpoint (e.g. a local Ollama):

OPENAI_BASE_URL=http://localhost:11434/v1 \
CORTEXDB_EMBED_MODEL=embeddinggemma CORTEXDB_EMBED_DIM=768 \
CORTEXDB_PATH=agent.db CORTEXDB_GRPC_TOKEN=s3cret cortexdb-grpc

Step 2 — Install the client

npm install cortexdb-client

Step 3 — The two core moves: remember + recall

const { CortexClient } = require('cortexdb-client');

const client = CortexClient.connect('127.0.0.1:47821', { token: 's3cret' });

// remember a fact about the user (scoped per user)
await client.memory.SaveMemory({
  memoryId: 'pref-coffee', userId: 'alice', scope: 'user',
  content: 'Alice prefers dark roast coffee and runs OpenClaw locally.',
});

// later turn / next session: recall by meaning
const hits = await client.memory.SearchMemory({
  query: 'what does the user like to drink?',
  userId: 'alice', scope: 'user', topK: 3,
});
for (const h of hits.results) console.log(h.memory.content, h.score);

Every RPC is a promise; request fields are camelCase. Memory scopes isolate data: scope: 'user' (per userId), scope: 'session' (per sessionId), or scope: 'global'.

Step 4 — Knowledge instead of plain memory (RAG)

await client.knowledge.SaveKnowledge({
  knowledgeId: 'doc-1', title: 'Project brief',
  content: 'The user is building an autonomous agent in TypeScript.',
});
const res = await client.knowledge.SearchKnowledge({
  query: 'what is the user building?', topK: 3,
});

Step 5 — The differentiator: a knowledge graph

const iri = (v) => ({ kind: 'iri', value: v });
await client.graph.UpsertNamespace({ prefix: 'ex', uri: 'https://example.com/' });
await client.graph.UpsertKnowledgeGraph({ triples: [
  { subject: iri('ex:alice'), predicate: iri('ex:knows'), object: iri('ex:bob') },
] });
const ans = await client.graph.QuerySparql({
  query: 'SELECT ?o WHERE { \x3Chttps://example.com/alice> \x3Chttps://example.com/knows> ?o . }',
});
console.log(ans.result.count, 'result(s)');

Expose CortexDB as OpenClaw tools

OpenClaw skills teach the agent how and when to call tools. A ready-to-use helper module wraps the calls above into remember, recall, saveKnowledge, searchKnowledge, relate, and askGraph:

  • scripts/memory-tools.js — import these and register them as OpenClaw tools, or call them directly from a custom skill/plugin.

In your skill's instructions, tell the agent: to remember a durable fact about the user, call remember(text); to recall, call recall(query); to record a relationship, call relate(subject, predicate, object); to answer a structured "who/what is related to X" question, call askGraph(sparql).

Install this skill into OpenClaw

OpenClaw follows the agentskills.io spec and discovers skills under \x3Cworkspace>/skills, \x3Cworkspace>/.agents/skills, ~/.agents/skills, and ~/.openclaw/skills.

# from this repo (local directory):
openclaw skills install ./skills/cortexdb-memory-openclaw --as cortexdb-memory

# or from git / ClawHub:
openclaw skills install git:liliang-cn/cortexdb@main --global

--global installs to ~/.openclaw/skills. The skill becomes eligible automatically once the cortexdb-grpc binary is present and a sidecar is running.

Sub-clients (full surface)

client.knowledge, client.memory, client.graph (RDF/SPARQL/SHACL/inference/ ontology), client.graphrag, client.tools (generic dispatch, same shape as MCP), client.admin. Each RPC is available in both PascalCase (SaveMemory) and camelCase (saveMemory). Auth is a bearer token; pass { token } to connect.

Notes & gotchas

  • Zero-key default: without an embedder the sidecar uses lexical retrieval — good enough to start, no credentials needed.
  • One file, one process: the sidecar owns one SQLite file. Isolate multiple users via memory scopes (above), not multiple files.
  • Plaintext localhost: the bearer token rides plain gRPC; fine on localhost, add TLS / a reverse proxy for cross-machine use.
  • No build step: the npm client loads the proto contract at runtime.
  • Package and docs: https://www.npmjs.com/package/cortexdb-client · https://github.com/liliang-cn/cortexdb
安全使用建议
Install only if you want an agent to keep local long-term memory. Avoid storing secrets or sensitive personal data, use a real sidecar token, keep the gRPC endpoint local unless you add transport security, and make sure you know how to inspect or delete the CortexDB database file.
能力标签
cryptorequires-oauth-tokenrequires-sensitive-credentials
能力评估
Purpose & Capability
The stated purpose is durable CortexDB-backed memory, recall, knowledge storage, and SPARQL graph querying for Node/OpenClaw agents, and the included helper functions match that purpose.
Instruction Scope
The trigger wording is broad for memory, RAG, knowledge graph, and 'remember this' requests, but it stays within the advertised memory/knowledge-graph domain rather than steering unrelated tasks.
Install Mechanism
Installation is explicit: users install the CortexDB gRPC sidecar and npm client. The artifact contains one markdown skill file and one helper script, with no hidden install hooks.
Credentials
The helper defaults to a localhost gRPC endpoint and optional embedding endpoint; this is proportionate for a local-first memory database, and no unrelated network or filesystem access is instructed.
Persistence & Privilege
The skill intentionally persists memories and knowledge in a local database and documents user/session/global scopes, but it does not give strong consent, retention, review, or deletion guidance.
如何使用
  1. 确保已安装 OpenClaw(本地或 Docker 部署)
  2. 在对话框中输入安装命令:/install cortexdb-agent-memory
  3. 安装完成后,直接呼叫该 Skill 的名称或使用 /cortexdb-agent-memory 触发
  4. 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
- Initial release providing durable, local-first agent memory for Node.js (e.g. OpenClaw), powered by CortexDB. - Adds queryable SPARQL knowledge graph and multi-hop question answering, alongside standard memory/recall features. - Requires only Node.js, npm, CortexDB gRPC sidecar, and the cortexdb-client npm package. - Supports both lexical and optional vector/semantic recall with any OpenAI-compatible embeddings endpoint. - Exposes high-level "remember", "recall", "relate", and "askGraph" tool functions for easy agent integration. - Compatible with the agentskills.io skill discovery structure and OpenClaw tool registration.
元数据
Slug cortexdb-agent-memory
版本 1.0.0
许可证 MIT-0
累计安装 1
当前安装数 1
历史版本数 1
常见问题

CortexDB Agent Memory 是什么?

Give a Node.js agent (such as OpenClaw) durable, local-first memory plus a queryable SPARQL knowledge graph, backed by CortexDB through its gRPC sidecar and... 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 42 次。

如何安装 CortexDB Agent Memory?

在 OpenClaw 或 Claude Code 对话框中运行命令「/install cortexdb-agent-memory」即可一键安装,无需额外配置。

CortexDB Agent Memory 是免费的吗?

是的,CortexDB Agent Memory 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。

CortexDB Agent Memory 支持哪些平台?

CortexDB Agent Memory 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。

谁开发了 CortexDB Agent Memory?

由 Liang Li(@liliang-cn)开发并维护,当前版本 v1.0.0。

💬 留言讨论