synthetic-supermemory
Full memory pipeline for OpenClaw agents. Three components that work together:
CODEBLOCK0
No gateway involvement. No context bloat. Fully automated.
⚠️ Privacy notice
INLINECODE0 sends conversation transcript content to an external LLM (OpenAI or Anthropic) for summarization. If your sessions contain secrets, API keys, or PII — be aware that content will be sent to the provider. Use a dedicated low-privilege API key with spend limits.
Quick setup
CODEBLOCK1
Cron setup (add via crontab -e)
CODEBLOCK2
Scripts
| Script | Purpose | Usage |
|---|
| INLINECODE2 | Summarize session transcripts → daily memory files + Supermemory | Hourly cron |
| INLINECODE3 |
Ingest changed memory files → Supermemory (upsert, change-tracked) | Every 2h cron |
|
recall.js | Retrieve context at session startup | Session start |
|
add.js | Add a single memory from CLI or stdin | On demand |
|
search.js | Semantic search across memories | On demand |
scribe.js options
| Flag | Description | Default |
|---|
| INLINECODE7 | OpenClaw agents directory | — |
| INLINECODE8 |
Scribe all recently active sessions | — |
|
--sessions <dir> | Single agent sessions directory | — |
|
--session-id <id> | Specific session UUID | — |
|
--auto-session <key> | Auto-resolve session by key suffix | — |
|
--memory-dir <dir> | Directory for daily memory files | required |
|
--provider <name> | LLM provider:
openai or
anthropic | auto-detected |
|
--model <model> | Summarization model |
gpt-4o-mini |
|
--api-key-file <path> | LLM API key file (600 permissions) | — |
|
--sm-container <tag> | Supermemory container override |
--agent value |
|
--agent <id> | Agent label for memory headers |
agent |
|
--active-within-hours <n> | Only scribe sessions active within window |
1 |
|
--min-turns <n> | Minimum new turns before scribing |
3 |
|
--dry-run | Print without writing | false |
ingest.js / recall.js / search.js / add.js options
All take --container <tag> to namespace memories per agent.
CODEBLOCK3
References
synthetic-supermemory
为OpenClaw代理提供的完整记忆管道。三个组件协同工作:
会话记录
↓ scribe.js(每小时系统定时任务)
memory/YYYY-MM-DD.md
↓ ingest.js(每2小时系统定时任务)
Supermemory(每个代理的容器标签)
↓ recall.js(会话启动时)
增强的上下文
无需网关介入。无上下文膨胀。完全自动化。
⚠️ 隐私声明
scribe.js 将会话记录内容发送至外部LLM(OpenAI或Anthropic)进行摘要生成。如果您的会话包含密钥、API密钥或PII(个人身份信息),请注意内容将被发送至提供商。请使用专用的低权限API密钥并设置消费限额。
快速设置
bash
安装依赖
cd /path/to/skills/synthetic-supermemory && npm install
安全存储密钥(请勿将密钥放入crontab)
mkdir -p ~/.openclaw/secrets
echo sk-your-openai-key > ~/.openclaw/secrets/scribe-key && chmod 600 ~/.openclaw/secrets/scribe-key
echo sm-your-supermemory-key > ~/.openclaw/secrets/supermemory-key && chmod 600 ~/.openclaw/secrets/supermemory-key
测试scribe(试运行)
SUPERMEMORY
APIKEY=$(cat ~/.openclaw/secrets/supermemory-key) \
node scripts/scribe.js \
--agents-dir ~/.openclaw/agents \
--all-sessions \
--memory-dir ~/.openclaw/workspace/memory \
--api-key-file ~/.openclaw/secrets/scribe-key \
--dry-run
测试recall
SUPERMEMORY
APIKEY=$(cat ~/.openclaw/secrets/supermemory-key) \
node scripts/recall.js --container my-agent
Cron设置(通过 crontab -e 添加)
bash
每小时记录活跃会话
0
SUPERMEMORY
APIKEY=$(cat ~/.openclaw/secrets/supermemory-key) node /path/to/synthetic-supermemory/scripts/scribe.js --agents-dir ~/.openclaw/agents --all-sessions --memory-dir ~/.openclaw/workspace/memory --api-key-file ~/.openclaw/secrets/scribe-key >> /tmp/scribe.log 2>&1
每2小时将变更的记忆文件导入Supermemory
0
/2 SUPERMEMORY
APIKEY=$(cat ~/.openclaw/secrets/supermemory-key) node /path/to/synthetic-supermemory/scripts/ingest.js --dir ~/.openclaw/workspace/memory --container my-agent >> /tmp/ingest.log 2>&1
脚本
| 脚本 | 用途 | 使用方式 |
|---|
| scribe.js | 将会话记录摘要 → 每日记忆文件 + Supermemory | 每小时定时任务 |
| ingest.js |
将变更的记忆文件导入Supermemory(upsert,变更追踪) | 每2小时定时任务 |
| recall.js | 在会话启动时检索上下文 | 会话启动 |
| add.js | 通过CLI或标准输入添加单条记忆 | 按需使用 |
| search.js | 跨记忆进行语义搜索 | 按需使用 |
scribe.js 选项
| 标志 | 描述 | 默认值 |
|---|
| --agents-dir <dir> | OpenClaw代理目录 | — |
| --all-sessions |
记录所有近期活跃会话 | — |
| --sessions
| 单个代理会话目录 | — |
| --session-id | 特定会话UUID | — |
| --auto-session | 通过键后缀自动解析会话 | — |
| --memory-dir | 每日记忆文件目录 | 必需 |
| --provider | LLM提供商:openai 或 anthropic | 自动检测 |
| --model | 摘要模型 | gpt-4o-mini |
| --api-key-file | LLM API密钥文件(600权限) | — |
| --sm-container | Supermemory容器覆盖 | --agent 值 |
| --agent | 记忆头部的代理标签 | agent |
| --active-within-hours | 仅记录窗口内活跃的会话 | 1 |
| --min-turns | 记录前的最小新轮次数量 | 3 |
| --dry-run | 仅打印不写入 | false |
ingest.js / recall.js / search.js / add.js 选项
所有脚本均使用 --container 为每个代理命名空间化记忆。
bash
导入目录
node scripts/ingest.js --dir ~/.openclaw/workspace/memory --container sapphire
在会话启动时检索上下文
node scripts/recall.js --container sapphire --query recent projects and identity
添加单条记忆
node scripts/add.js --container sapphire --content Kitsune prefers dark mode
搜索
node scripts/search.js --container sapphire --query TokTeam deployment
参考资料