Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -156,15 +156,15 @@ openclaw plugins install /path/to/openclaw-extension-powermem
openclaw plugins install -l /path/to/openclaw-extension-powermem
```

**Note:** Running `npm i openclaw-extension-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 openclaw-extension-powermem` (or install from a path as above), then configure OpenClaw and restart the gateway.
**Note:** Running `npm i openclaw-extension-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 openclaw-extension-powermem` (or install from a path as above), then restart the gateway.

After install, run `openclaw plugins list` and confirm `memory-powermem` is listed.
After install, run `openclaw plugins list` and confirm `memory-powermem` is listed. The plugin uses **default config** when none is set: `baseUrl: "http://localhost:8000"`, `autoCapture`, `autoRecall`, and `inferOnAdd` enabled — so you do not need to edit `~/.openclaw/openclaw.json` for the typical setup (PowerMem on localhost:8000).

---

## Step 3: Configure OpenClaw to use the plugin
## Step 3: Configure OpenClaw (optional)

Edit OpenClaws config (e.g. `~/.openclaw/openclaw.json`). At the **root level**, add or merge the `plugins` section: set `plugins.slots.memory` and `plugins.entries["memory-powermem"]`, and set the PowerMem URL.
If you use PowerMem at **http://localhost:8000** with the default options, skip this step. To **customize** (e.g. different URL, API key, or CLI mode), edit OpenClaw's config (e.g. `~/.openclaw/openclaw.json`) and add or merge the `plugins` section.

**Example (JSON):**

Expand Down
10 changes: 5 additions & 5 deletions README_CN.md
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@

# OpenClaw Memory (PowerMem) 插件

本插件让 [OpenClaw](https://github.com/openclaw/openclaw) 通过 [PowerMem](https://github.com/oceanbase/powermem) 的 HTTP API 使用长期记忆:智能抽取、艾宾浩斯遗忘曲线、多 Agent 隔离。
本插件让 [OpenClaw](https://github.com/openclaw/openclaw) 通过 [PowerMem](https://github.com/oceanbase/powermem) 使用长期记忆:智能抽取、艾宾浩斯遗忘曲线、多 Agent 隔离。

按顺序操作:先安装并启动 PowerMem,再安装插件、配置 OpenClaw,最后验证。

Expand Down Expand Up @@ -157,15 +157,15 @@ openclaw plugins install /path/to/openclaw-extension-powermem
openclaw plugins install -l /path/to/openclaw-extension-powermem
```

**说明:** 在某个 Node 项目里执行 `npm i openclaw-extension-powermem` 只会把包装进该项目的 `node_modules`,**不会**在 OpenClaw 里注册插件。若要在 OpenClaw 里使用本插件,必须执行 `openclaw plugins install openclaw-extension-powermem`(或按上面用本地路径安装),再在 OpenClaw 中配置并重启 gateway。
**说明:** 在某个 Node 项目里执行 `npm i openclaw-extension-powermem` 只会把包装进该项目的 `node_modules`,**不会**在 OpenClaw 里注册插件。若要在 OpenClaw 里使用本插件,必须执行 `openclaw plugins install openclaw-extension-powermem`(或按上面用本地路径安装),再重启 gateway。

安装成功后,可用 `openclaw plugins list` 确认能看到 `memory-powermem`。
安装成功后,可用 `openclaw plugins list` 确认能看到 `memory-powermem`。未在配置中书写本插件 config 时,插件会使用 **默认配置**:`baseUrl: "http://localhost:8000"`,并开启 `autoCapture`、`autoRecall`、`inferOnAdd`,因此典型情况(PowerMem 跑在 localhost:8000)下无需编辑 `~/.openclaw/openclaw.json`。

---

## 第三步:配置 OpenClaw 使用本插件
## 第三步:配置 OpenClaw(可选)

编辑 OpenClaw 的配置文件(常见位置:`~/.openclaw/openclaw.json`),在 **根级** 增加或合并 `plugins` 段,并把记忆槽指向本插件,并写上 PowerMem 的地址
若 PowerMem 在 **http://localhost:8000** 且使用默认选项,可跳过本步。若要 **自定义**(如改 URL、API Key 或使用 CLI 模式),请编辑 OpenClaw 配置文件(如 `~/.openclaw/openclaw.json`),增加或合并 `plugins` 段。

**示例(JSON):**

Expand Down
12 changes: 12 additions & 0 deletions config.ts
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,18 @@ function toRecallScoreThreshold(v: unknown): number {
export const DEFAULT_USER_ID = "openclaw-user";
export const DEFAULT_AGENT_ID = "openclaw-agent";

/**
* Default plugin config when openclaw.json has no plugins.entries["memory-powermem"].config.
* Allows "openclaw plugins install openclaw-extension-powermem" to work without manual config.
*/
export const DEFAULT_PLUGIN_CONFIG: PowerMemConfig = {
mode: "http",
baseUrl: "http://localhost:8000",
autoCapture: true,
autoRecall: true,
inferOnAdd: true,
};

export function resolveUserId(cfg: PowerMemConfig): string {
return cfg.userId ?? DEFAULT_USER_ID;
}
Expand Down
11 changes: 10 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,7 @@ import type { OpenClawPluginServiceContext } from "openclaw/plugin-sdk";

import {
powerMemConfigSchema,
DEFAULT_PLUGIN_CONFIG,
resolveUserId,
resolveAgentId,
type PowerMemConfig,
Expand All @@ -36,7 +37,15 @@ const memoryPlugin = {
configSchema: powerMemConfigSchema,

register(api: OpenClawPluginApi) {
const cfg = powerMemConfigSchema.parse(api.pluginConfig) as PowerMemConfig;
const raw = api.pluginConfig;
const toParse =
raw &&
typeof raw === "object" &&
!Array.isArray(raw) &&
Object.keys(raw).length > 0
? { ...DEFAULT_PLUGIN_CONFIG, ...raw }
: DEFAULT_PLUGIN_CONFIG;
const cfg = powerMemConfigSchema.parse(toParse) as PowerMemConfig;
const userId = resolveUserId(cfg);
const agentId = resolveAgentId(cfg);
const client =
Expand Down
Loading