外观主题
阅读语言

MemoryPool —— 跨进程共享的智能体持久记忆池:评分检索 + JSONL 落盘

软件 本站软件 1天前 更新于 20小时前
https://yxp.hk/p/3DsJPr

📦 开源仓库:yxpil/MemoryPool

gh-card · yxpil/MemoryPool

📦 仓库名片 · Powered by gh-card


MemoryPool

为 AI 智能体提供跨进程、可持久化的共享记忆:独立于 BIT 自带的 memories.json,可作为多个智能体共享的中央记忆服务,通过 CLI、HTTP API、BIT Remote 协议或 MCP 四种方式接入。Rust 单一静态二进制,零运行时依赖。

记忆模型

每条记忆存储于 ~/.memorypool/memories.jsonl(MEMORYPOOL_DATA_DIR 可覆盖):

字段 类型 说明
id uuid 稳定标识
text string 记忆内容
tags string[] 自由标签
importance float 0.0–1.0 重要程度,默认 0.5
source string 来源,默认 "cli"(智能体建议用 "bit")
created_at / updated_at RFC 3339 UTC 时间戳

写入持久可靠:add 追加一行 JSON,修改/删除走临时文件 + rename 原子落盘;损坏行跳过并警告,不影响整个记忆池。

评分检索

关键词搜索按综合得分排序:正文命中 + 标签精确命中 + importance 加权 + 时间指数衰减(半衰期 30 天)——越重要、越新、越相关的记忆排得越靠前。

接入方式

  • CLI 优先:add / search / list / get / delete / tag / stats / serve,全部支持 --json;stdin 为管道时读 JSON 合并参数(stdin 优先)——正是 BIT exec 运行时的调用方式。
  • HTTP 服务(serve,默认 127.0.0.1:8751):REST 端点(POST /mem、GET /mem/search?q=&tag=&limit=、DELETE /mem/{id}…)+ BIT Remote /invoke + MCP(/mcp,6 个工具:add/search/list/get/delete/stats)。
  • BIT Remote 工具:一条 curl POST /api/tools 注册即用,Agent 参数直接路由到对应动作。
  • 可选 --token Bearer 鉴权(覆盖除 /health 外所有端点,含 MCP)。

安装

从 Releases 下载,或 cargo install --git https://github.com/yxpil/MemoryPool:

memorypool serve --host 127.0.0.1 --port 8751
# 可选鉴权:memorypool serve --token s3cret

安全

默认只绑定 127.0.0.1;数据全部在本机,不上传任何内容;请勿在共享记忆池中存入密钥、密码等敏感信息。

许可

Apache-2.0

🛠 技术栈与开发

  • 开发语言:Rust 100%(edition 2021)—— 单一静态二进制,零运行时依赖
  • 存储引擎:JSONL 追加写 + 临时文件 rename 原子落盘(~/.memorypool/memories.jsonl,MEMORYPOOL_DATA_DIR 可覆盖);损坏行跳过并警告,不影响整个记忆池
  • 检索算法:正文关键词命中 + 标签精确命中 + importance 加权 + 时间指数衰减(半衰期 30 天),综合评分排序
  • 接入面:CLI(stdin JSON 契约,正是 BIT exec 调用方式)· REST 端点 · BIT Remote /invoke · MCP(6 工具,/mcp);--token Bearer 鉴权覆盖除 /health 外全部端点

📚 文档与链接

  • 仓库:https://github.com/yxpil/MemoryPool · Releases 四平台预编译包或 cargo install --git https://github.com/yxpil/MemoryPool
  • 30 秒体验:memorypool add "周五部署 redis" --tags ops --importance 0.9 → memorypool search "redis" → memorypool serve 起服务(默认 127.0.0.1:8751)