# install-memory-powermem

Adopt this skill: https://proskills.md/skills/other/ob-labs-memory-powermem-skills-install-memory-powermem

Page: https://proskills.md/skills/other/ob-labs-memory-powermem-skills-install-memory-powermem
This document is the public skill bundle for that page. It contains SKILL.md and every helper file the catalog carries. No login is required.

## File: skills/install-memory-powermem/SKILL.md
size: 5636
sha: 59ee11cbc335a6179623c564b3976a9cddd05d53
upstream: https://github.com/ob-labs/memory-powermem/blob/main/skills/install-memory-powermem/SKILL.md

````text
---
name: install-memory-powermem
description: OpenClaw skill「快速安装」路径（skill id 与目录名均为 install-memory-powermem）：memory-powermem + PowerMem 最少步骤，面向个人用户；默认 powermem-ts（npm 包 powermem）CLI，无需 Python；无需单独配置 powermem.env，复用 OpenClaw 里已配好的对话模型。可独立分发；完整选项、工具说明与排错见 install-memory-powermem-full。
triggers:
  - "PowerMem 快速安装"
  - "PowerMem 最简单安装"
  - "memory-powermem 最小安装"
  - "怎么装 PowerMem 记忆"
  - "OpenClaw 记忆 怎么装"
  - "安装长期记忆"
  - "Quick install PowerMem"
  - "PowerMem quickstart"
  - "Easiest PowerMem setup"
  - "Minimal install memory-powermem"
  - "Install memory powermem minimal"
---

# PowerMem 记忆 · 快速安装（个人用户）

本 skill 在 OpenClaw 中的标识与建议目录名为 **`install-memory-powermem`**。若需要 HTTP/多实例、工具表与详细排错，请改用 **`install-memory-powermem-full`**（仓库内 `skills/install-memory-powermem-full/`，需一并拷贝该目录下全部 `.md`）。

你只要记住几件事：**OpenClaw 能正常聊天**、**装上 memory-powermem 插件**。默认走 **powermem-ts**（npm 包名 `powermem`，由插件依赖提供，**不需要**先装 Python）。不用手写 `powermem.env`，记忆用的模型和 Key 会跟你在 OpenClaw 里配的一样。

---

## 你要做什么（按顺序）

1. **确认 OpenClaw 已经能用**  
   终端执行 `openclaw --version`，并且你已经在 OpenClaw 里配好了**平时对话用的模型**（能正常回复即可）。

2. **安装 memory-powermem 插件**  
   任选其一：  
   - **registry：** `openclaw plugins install memory-powermem`  
   - **一键脚本（Mac / Linux）：**
     ```bash
     curl -fsSL https://raw.githubusercontent.com/ob-labs/memory-powermem/main/install.sh | bash -s -y
     ```
     已克隆本仓库时可在根目录执行 `bash install.sh`（可加 `-y`；多实例：`bash -s -- --workdir ~/.openclaw-second`）。  
   - **本地克隆：** `openclaw plugins install /path/to/memory-powermem` 或 **`openclaw plugins install -l`**（软链开发）  
   默认 **`pmemPath: bundled`**：使用插件依赖里的 **powermem-ts**（npm 包名 **`powermem`**）提供的 CLI，**不需要**本机 `pip install powermem`。

3. **若从本地路径安装：在插件目录安装 Node 依赖**  
   从 **npm registry** 安装或 **`install.sh`** 已在插件目录执行过依赖安装时，**可跳过本步**。否则进入 OpenClaw 指向的插件目录（或克隆根目录），执行 **`pnpm install` / `npm install`**，确保拉取 **`powermem`**、**`@langchain/openai`** 等。使用 **pnpm 10+** 时若 **`better-sqlite3`** 未编译，可执行 **`pnpm rebuild better-sqlite3`**（仓库 `package.json` 已配置 **`pnpm.onlyBuiltDependencies`** 时一般可自动构建）。

4. **（可选）改用 Python 版 `pmem`**  
   若你希望使用 [oceanbase/powermem](https://github.com/oceanbase/powermem) 的 **Python CLI**：**Python ≥ 3.10**，`pip install powermem`，并在插件配置里将 **`pmemPath`** 设为 venv 中 `pmem` 的**绝对路径**。详见 **`install-memory-powermem-full`** 与 **config-reference.md**。

5. **重启网关并检查**  
   ```bash
   openclaw gateway restart
   ```
   另开终端，**先**确认插件已被网关加载：
   ```bash
   openclaw plugins list
   ```
   输出里要有 **memory-powermem**，且其状态为 **loaded**（已加载）。若只有安装记录、状态不是 loaded，先按下面「若某一步失败」处理，**不要**跳过这步直接去测 `ltm`。  
   通过后再检查记忆健康并试写读：
   ```bash
   openclaw ltm health
   ```
   显示健康后试一句：
   ```bash
   openclaw ltm add "我喜欢喝美式"
   openclaw ltm search "咖啡"
   ```

---

## 若某一步失败

| 情况 | 怎么办 |
|------|--------|
| `pmem` / CLI 找不到、`ERR_MODULE_NOT_FOUND`（如 `@langchain/openai`） | 在插件目录执行 **`pnpm install` / `npm install`**；路径安装用 **`openclaw plugins install -l`** 时确保依赖完整。 |
| `better-sqlite3` 未编译（pnpm 忽略构建脚本） | 在插件目录 **`pnpm rebuild better-sqlite3`**，或配置 **`pnpm.onlyBuiltDependencies`** 后重装依赖（见仓库 `package.json`）。 |
| 坚持用 **Python** `pmem` 但找不到命令 | 激活 venv，或配置 **`pmemPath`** 为 `which pmem` 的绝对路径。 |
| `plugins list` 没有 **memory-powermem**，或状态不是 **loaded** | 确认已执行安装脚本或 `openclaw plugins install`；`plugins.enabled` 为 true、`plugins.slots.memory` 为 **memory-powermem**；改完后**重启 gateway**，再执行 `openclaw plugins list` 复查。 |
| `ltm health` 不健康 | 确认 OpenClaw 里**默认模型**和 API Key 本身能聊天；升级 OpenClaw 到较新版本后再试。 |
| 想要更多选项（多实例、HTTP、`install.sh` 细节、工具与排错表等） | 使用 **`install-memory-powermem-full`** skill（含 **config-reference.md**），或查阅 **[memory-powermem](https://github.com/ob-labs/memory-powermem)** 的 **README**。 |

---

## 说明（一句话）

记忆数据默认存在本机 OpenClaw 数据目录下的 SQLite 里；默认 CLI 为 **powermem-ts（npm）**；**不需要**你再单独维护一份 PowerMem 的 `.env`，除非你熟悉进阶配置。`userId/agentId` 未配置会自动生成并持久化。HTTP + `dualWrite` 场景可选 `localVector`（sqlite-vec）提升本地兜底搜索质量。
````

## File: README.md
upstream: https://github.com/ob-labs/memory-powermem/blob/main/README.md

````text
<p align="center">

*[PowerMem](https://github.com/oceanbase/powermem) + [OpenClaw](https://github.com/openclaw/openclaw): maximum token savings for AI agents.*

<img src="docs/images/openclaw_powermem.jpeg" alt="PowerMem with OpenClaw" width="900"/>

</p>

# OpenClaw Memory (PowerMem) Plugin

This plugin lets [OpenClaw](https://github.com/openclaw/openclaw) use long-term memory via [PowerMem](https://github.com/oceanbase/powermem): intelligent extraction, Ebbinghaus forgetting curve, multi-agent isolation. Supports HTTP v2 (per-request config + agent memory sharing), LLM-based experience extraction, and optional dual-write to local SQLite.

**Default:** **CLI mode** — the plugin runs `pmem` locally (no `powermem-server`). Use **HTTP mode** when you already run a shared PowerMem API (teams / enterprise).

Follow the steps in order: install PowerMem, then install the plugin, configure OpenClaw (defaults work for CLI + `~/.openclaw/powermem/powermem.env`), and verify.

---

## Prerequisites

- **OpenClaw** installed (CLI + gateway working)
- **PowerMem** installed (`pip install powermem`) with `pmem` available — either on PATH when you start the gateway, or via absolute `pmemPath` in plugin config
- **`.env` for PowerMem** with at least database + LLM + Embedding (see [PowerMem `.env.example`](https://github.com/oceanbase/powermem/blob/master/.env.example)); for individuals, prefer `~/.openclaw/powermem/powermem.env` and SQLite

---

## Step 1: Install and start PowerMem

Choose **Option A (CLI, recommended for OpenClaw individuals)**, **Option B (HTTP + pip)**, or **Option C (Docker)**.

### Option A: CLI + SQLite (recommended for individuals)

No HTTP server. Matches the plugin’s **default** (`mode: cli`).

1. **Install PowerMem** (venv recommended):

   ```bash
   python3 -m venv ~/.openclaw/powermem/.venv
   source ~/.openclaw/powermem/.venv/bin/activate
   pip install powermem
   ```

2. **Config** — From a clone of this repo, run `bash install.sh` (or the curl one-liner under **Install options** below) to create an optional `~/.openclaw/powermem/powermem.env` template, or copy from PowerMem’s `.env.example`. Set `LLM_*` and `EMBEDDING_*` when not relying on OpenClaw-injected models.

3. If `pmem` exists only inside the venv, set `pmemPath` in the plugin `config` to the absolute path of `pmem` in that venv.

4. **Verify** — With venv activated: `pmem --version`. After gateway start: `openclaw ltm health`.

---

### Option B: Install with pip (run HTTP server locally)

Use this when you want a **standalone API** or are not using CLI mode. Best if you already have Python 3.11+ on the machine.

**1. Install PowerMem**

```bash
pip install powermem
```

**2. Prepare config**

In **any directory** where you want to keep config (e.g. `~/powermem`):

```bash
mkdir -p ~/powermem && cd ~/powermem
# Copy from PowerMem repo: if you cloned it, run: cp /path/to/powermem/.env.example .env
```

If you did not clone the PowerMem repo, create a `.env` with at least: database + LLM + Embedding. Here is a **minimal working example** (OceanBase + Qwen; replace with your API key and DB credentials):

```bash
# Create .env in ~/powermem (replace your_api_key_here and your_password)
cat > .env << 'EOF'
TIMEZONE=Asia/Shanghai
DATABASE_PROVIDER=oceanbase

OCEANBASE_HOST=127.0.0.1
OCEANBASE_PORT=2881
OCEANBASE_USER=root@sys
OCEANBASE_PASSWORD=your_password
OCEANBASE_DATABASE=powermem
OCEANBASE_COLLECTION=memories

LLM_PROVIDER=qwen
LLM_API_KEY=your_api_key_here
LLM_MODEL=qwen-plus

EMBEDDING_PROVIDER=qwen
EMBEDDING_API_KEY=your_api_key_here
EMBEDDING_MODEL=text-embedding-v4
EMBEDDING_DIMS=1536
EOF
```

Replace `your_api_key_here` with your Tongyi Qwen API key (and set `your_password` and other DB fields as needed for OceanBase). For OpenAI or other providers, see PowerMem’s [.env.example](https://github.com/oceanbase/powermem/blob/master/.env.example) for `LLM_*` and `EMBEDDING_*`.

**3. Start the HTTP server**

Run this **in the same directory as `.env`**:

```bash
cd ~/powermem   # or wherever .env lives
powermem-server --host 0.0.0.0 --port 8000
```

You should see something like `Uvicorn running on http://0.0.0.0:8000`. Leave this terminal open.

**4. Verify PowerMem**

In a new terminal:

```bash
curl -s http://localhost:8000/api/v1/system/health
```

If you get JSON (e.g. with `"status":"healthy"`), PowerMem is ready.

---

### Option C: Run with Docker (no Python needed)

Best if you have Docker and prefer not to install Python.

**1. Clone PowerMem and prepare .env**

```bash
git clone https://github.com/oceanbase/powermem.git
cd powermem
cp .env.example .env
```

Edit `.env` and set at least:

- `LLM_API_KEY`, `LLM_PROVIDER`, `LLM_MODEL`
- `EMBEDDING_API_KEY`, `EMBEDDING_PROVIDER`, `EMBEDDING_MODEL`

Database: OceanBase is recommended.

**2. Start the container**

From the **powermem project root** (same level as `.env`):

```bash
docker-compose -f docker/docker-compose.yml up -d
```

**3. Verify**

```bash
curl -s http://localhost:8000/api/v1/system/health
```

JSON response means the server is up. API docs: `http://localhost:8000/docs`.

---

## Install options

- **One-click (Linux/macOS):**  
  ```bash
  curl -fsSL https://raw.githubusercontent.com/ob-labs/memory-powermem/main/install.sh | bash
  ```  
  From a clone: `cd /path/to/memory-powermem && bash install.sh`. Non-interactive: same URL but pipe to `bash -s -y`. Another OpenClaw instance: `bash -s -- --workdir ~/.openclaw-second`. Details and troubleshooting: OpenClaw skill **`install-memory-powermem-full`** ([skills/install-memory-powermem-full/](skills/install-memory-powermem-full/)).
- **OpenClaw skill — quickstart (`install-memory-powermem`):** Copy [skills/install-memory-powermem/SKILL.md](skills/install-memory-powermem/SKILL.md) to `~/.openclaw/skills/install-memory-powermem/`, then say **「PowerMem 快速安装」** / **“PowerMem quickstart”** or **“Minimal install memory-powermem”** / **“Install memory powermem minimal”**.  
- **OpenClaw skill — full guide (`install-memory-powermem-full`):** Copy [skills/install-memory-powermem-full/SKILL.md](skills/install-memory-powermem-full/SKILL.md) (and its sibling `.md` files in that folder if you mirror the repo) to `~/.openclaw/skills/install-memory-powermem-full/`, then say **「安装 PowerMem 记忆」** / **“Install PowerMem memory”**. The quickstart and full-guide skills are **independent**; use whichever fits your workflow.
- **Manual:** Steps below.

---

## Step 2: Install the plugin into OpenClaw

On your machine (use your actual plugin path):

```bash
# Install from npm (recommended for end users; downloads and installs from the official npm registry)
openclaw plugins install memory-powermem

# Install from a local directory (e.g. cloned repo)
cd /path/to/memory-powermem && npm install && npm run build
openclaw plugins install /path/to/memory-powermem

# For development (symlink, no copy)
cd /path/to/memory-powermem && npm install && npm run build
openclaw plugins install -l /path/to/memory-powermem
```

**Note:** Starting with OpenClaw 2026.5.4, local path installs require the TypeScript plugin entry to be compiled to runtime JS first, so run `npm run build` before installing from a local clone. Running `npm i memory-powermem` in a Node project only adds the package to that project’s `node_modules`; it does **not** register the plugin with OpenClaw. To use this as an OpenClaw plugin, you must run `openclaw plugins install memory-powermem` (or install from a path as above), then restart the gateway.

After install, run `openclaw plugins list` and confirm `memory-powermem` is listed. With **no** `plugins.entries["memory-powermem"].config`, the plugin uses **defaults**: `mode: "cli"`, `pmemPath: "bundled"` (npm `powermem` from plugin dependencies), `useOpenClawModel: true` (SQLite under OpenClaw state + LLM from `agents.defaults.model`), plus `autoCapture` / `autoRecall` / `inferOnAdd` enabled. No separate `powermem.env` is required unless you opt out of OpenClaw mod
````
