Add Memory Gateway agent plugin
This commit is contained in:
112
README.md
112
README.md
@ -349,6 +349,21 @@ obsidian-vault/Reviews/Queue/
|
||||
integrations/hermes/memory-gateway/
|
||||
```
|
||||
|
||||
安装或更新到本机 Hermes skill 目录:
|
||||
|
||||
```bash
|
||||
mkdir -p /home/tom/.hermes/skills/memory-gateway
|
||||
rsync -a --delete \
|
||||
/home/tom/memory-gateway/integrations/hermes/memory-gateway/ \
|
||||
/home/tom/.hermes/skills/memory-gateway/
|
||||
```
|
||||
|
||||
使用方式:
|
||||
|
||||
- Hermes 对话中可以加载 `memory-gateway` skill,让 agent 按 skill 文档主动调用脚本。
|
||||
- skill 不等于自动记忆;只有 agent 根据 skill/policy 主动调用脚本时才会写入或检索记忆。
|
||||
- 适合人工可控的显式操作:创建用户、检索记忆、追加 episode、commit session、上传知识和检查 EverMemOS。
|
||||
|
||||
主要脚本:
|
||||
|
||||
```text
|
||||
@ -444,12 +459,109 @@ python /home/tom/.hermes/skills/memory-gateway/scripts/memory_search.py \
|
||||
--limit 5
|
||||
```
|
||||
|
||||
## Hermes / OpenClaw Agent Plugin
|
||||
|
||||
通用 Agent plugin 位于:
|
||||
|
||||
```text
|
||||
plugins/memory-gateway-agent/
|
||||
```
|
||||
|
||||
它是独立 adapter,不 import Gateway 内部 `services/repositories/server`,所有调用都通过现有 `/v1` HTTP API。它面向 Hermes/OpenClaw 这类 agent runtime 暴露统一工具:
|
||||
|
||||
- `memory_search`
|
||||
- `memory_append_episode`
|
||||
- `memory_commit_session`
|
||||
- `memory_upsert`
|
||||
- `memory_feedback`
|
||||
|
||||
Hermes 本机安装:
|
||||
|
||||
```bash
|
||||
mkdir -p /home/tom/.hermes/plugins
|
||||
ln -s /home/tom/memory-gateway/plugins/memory-gateway-agent \
|
||||
/home/tom/.hermes/plugins/memory-gateway-agent
|
||||
hermes plugins enable memory-gateway-agent
|
||||
hermes plugins list
|
||||
hermes tools list
|
||||
```
|
||||
|
||||
如果软链接已存在,先确认它指向当前仓库:
|
||||
|
||||
```bash
|
||||
ls -l /home/tom/.hermes/plugins/memory-gateway-agent
|
||||
```
|
||||
|
||||
运行配置:
|
||||
|
||||
```bash
|
||||
export MEMORY_GATEWAY_URL=http://127.0.0.1:1934
|
||||
export MEMORY_GATEWAY_API_KEY=
|
||||
export MEMORY_GATEWAY_DEFAULT_USER_ID=test_user_memory_gateway_plugin
|
||||
export MEMORY_GATEWAY_DEFAULT_AGENT_ID=test_hermes_memory_gateway_plugin
|
||||
export MEMORY_GATEWAY_DEFAULT_WORKSPACE_ID=test_workspace_memory_gateway_plugin
|
||||
export MEMORY_GATEWAY_AUTO_SEARCH=true
|
||||
export MEMORY_GATEWAY_AUTO_APPEND_EPISODE=true
|
||||
export MEMORY_GATEWAY_AUTO_COMMIT_SESSION=false
|
||||
```
|
||||
|
||||
Hermes plugin 已验证:
|
||||
|
||||
- `hermes plugins list` 可发现并启用 `memory-gateway-agent`。
|
||||
- `hermes tools list` 可看到 `memory_gateway` toolset。
|
||||
- `pre_llm_call` 会自动检索 Memory Gateway。
|
||||
- `post_llm_call` 会按 policy 写入摘要型 candidate episode。
|
||||
- `on_session_end` 默认不会 commit;只有 `MEMORY_GATEWAY_AUTO_COMMIT_SESSION=true` 才会 commit。
|
||||
|
||||
真实 Hermes chat 验证:
|
||||
|
||||
```bash
|
||||
PYTHONPATH=/home/tom/memory-gateway/plugins/memory-gateway-agent \
|
||||
python /home/tom/memory-gateway/plugins/memory-gateway-agent/scripts/hermes_interactive_session_check.py
|
||||
```
|
||||
|
||||
插件 E2E 验证:
|
||||
|
||||
```bash
|
||||
PYTHONPATH=/home/tom/memory-gateway/plugins/memory-gateway-agent \
|
||||
python /home/tom/memory-gateway/plugins/memory-gateway-agent/scripts/gateway_e2e_check.py
|
||||
|
||||
PYTHONPATH=/home/tom/memory-gateway/plugins/memory-gateway-agent \
|
||||
python /home/tom/memory-gateway/plugins/memory-gateway-agent/scripts/hermes_hook_probe.py
|
||||
```
|
||||
|
||||
清理测试数据:
|
||||
|
||||
```bash
|
||||
PYTHONPATH=/home/tom/memory-gateway/plugins/memory-gateway-agent \
|
||||
python /home/tom/memory-gateway/plugins/memory-gateway-agent/scripts/cleanup_test_memories.py
|
||||
```
|
||||
|
||||
安全边界:
|
||||
|
||||
- plugin 不保存完整原始对话,只写摘要型 episode。
|
||||
- 默认拒绝 password、token、API key、cookie、private key、完整 transcript 和大段日志。
|
||||
- `memory_upsert` 是高风险长期记忆写入,不会自动触发。
|
||||
- 用户要求 forget/delete 时,应走 `memory_feedback` 或 delete 能力。
|
||||
- hook trace 默认关闭;需要排查时设置 `MEMORY_GATEWAY_PLUGIN_TRACE_HOOKS=true`,只会写入 hook 名称、短 session id、Gateway action 和状态到 `plugins/memory-gateway-agent/.tmp/hook_trace.log`。
|
||||
|
||||
OpenClaw manifest 目前是 best-effort 草案:
|
||||
|
||||
```text
|
||||
plugins/memory-gateway-agent/openclaw.plugin.yaml
|
||||
```
|
||||
|
||||
需要等 OpenClaw runtime 可用后再做第五阶段实测。
|
||||
|
||||
## 测试
|
||||
|
||||
```bash
|
||||
cd /home/tom/memory-gateway
|
||||
source /home/tom/OpenViking/.venv/bin/activate
|
||||
PYTHONPATH=/home/tom/memory-gateway pytest -q
|
||||
|
||||
PYTHONPATH=/home/tom/memory-gateway/plugins/memory-gateway-agent \
|
||||
pytest -q plugins/memory-gateway-agent/tests
|
||||
```
|
||||
|
||||
当前测试覆盖:
|
||||
|
||||
Reference in New Issue
Block a user