mem012 是一个面向 AI Agent 的 CLI 记忆系统,提供持久化记忆与 RAG 检索能力,并支持通过 Web 端管理记忆。
cp config.example.toml config.tomldocker build -t mem012-postgres:pg18 -f docker/postgres/Dockerfile docker/postgresexport MEM012_ADMIN_POSTGRES_USER='mem012_admin'
export MEM012_POSTGRES_PASSWORD='your_admin_password'
docker run -d \
--name mem012-postgres \
--restart unless-stopped \
--network 1panel-network \
-p 5632:5432 \
-e POSTGRES_USER="$MEM012_ADMIN_POSTGRES_USER" \
-e POSTGRES_PASSWORD="$MEM012_POSTGRES_PASSWORD" \
-v mem012_pg18_data:/var/lib/postgresql \
mem012-postgres:pg18统一通过顶层 install.sh 安装。前端默认发布到 /opt/1panel/www/sites/mem012/index;在使用 systemd 的 Linux 上,安装后端时会自动安装并启动 mem012.service。
# 同时安装前端和后端
sh install.sh
# 只安装前端到默认目录
sh install.sh --frontend
# 只安装前端到指定目录(必须使用绝对路径)
sh install.sh --frontend /opt/1panel/www/sites/custom-site
# 只安装后端
sh install.sh --backend每个agent可以独享一个profile,实现记忆隔离。
例如创建一个profile 给codex使用,同时会创建mem_codex库
export MEM012_ADMIN_DATABASE_URL="postgresql://${MEM012_ADMIN_POSTGRES_USER}:${MEM012_POSTGRES_PASSWORD}@127.0.0.1:5632/postgres"
mem012 --create_profile codex创建 profile 会更新 config.toml。重启服务以加载新配置,并确认服务仍在运行:
sudo systemctl restart mem012.service
sudo systemctl is-active --quiet mem012.service- 执行
sudo systemctl is-active --quiet mem012.service确认服务正在运行,再打开http://127.0.0.1:37777/auth获取 5 分钟有效的auth_token。 - 同一用户环境执行
mem012 --profile <profile> --auth <auth_token>,生成临时授权文件~/.auth/auth_file.mem。 - 通过
create_memory创建类别位init的记忆,会在初始化后读取。
下面的这段话加入全局引导文件。
## INIT
初始化触发条件:仅限首次对话,或上下文压缩后的首次对话。其余情况切勿重复执行。
我的profile: codex.
mem012 是我的记忆系统。启动后,我必须先执行 shell 命令 `mem012 --profile codex init`,完整读取返回内容,完成初始化后再继续处理用户请求。
记忆导出:
mem012 --profile maccodex --args '{"tool":"backup_memory","params":{"output_path":"/绝对路径/backup.json"}}'记忆导入:
mem012 --profile 目标profile --args '{"tool":"import_memory","params":{"input_path":"/绝对路径/backup.json"}}'