openclaw-memory-decay 0.1.7 → 0.1.9
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +45 -14
- package/openclaw.plugin.json +2 -2
- package/package.json +1 -1
- package/scripts/detect-python-lib.mjs +5 -1
- package/src/index.ts +3 -2
- package/src/legacy-config.ts +35 -0
- package/src/python-env.ts +5 -1
package/README.md
CHANGED
|
@@ -67,7 +67,7 @@ python3 -m venv ~/.openclaw/venvs/memory-decay
|
|
|
67
67
|
openclaw plugins install openclaw-memory-decay
|
|
68
68
|
|
|
69
69
|
# 3. (Optional but recommended) Restrict auto-load to trusted plugins only
|
|
70
|
-
openclaw config set plugins.allow '["memory-decay"]'
|
|
70
|
+
openclaw config set plugins.allow '["openclaw-memory-decay"]'
|
|
71
71
|
|
|
72
72
|
# 4. Restart the gateway
|
|
73
73
|
openclaw gateway restart
|
|
@@ -86,41 +86,52 @@ openclaw gateway restart
|
|
|
86
86
|
If you previously installed this plugin from a local checkout via `openclaw plugins install -l .`, migrate to the npm package. Local/path-based installs are now deprecated in favor of the published npm package.
|
|
87
87
|
|
|
88
88
|
```bash
|
|
89
|
-
# 1.
|
|
89
|
+
# 1. Remove the old pre-0.1.8 plugin install if it exists
|
|
90
|
+
openclaw plugins uninstall memory-decay
|
|
91
|
+
|
|
92
|
+
# 2. Install from npm instead
|
|
90
93
|
openclaw plugins install openclaw-memory-decay
|
|
91
94
|
|
|
92
|
-
#
|
|
95
|
+
# 3. Restart gateway
|
|
93
96
|
openclaw gateway restart
|
|
94
97
|
|
|
95
|
-
#
|
|
96
|
-
openclaw plugins list | grep memory-decay # should show: memory-decay | loaded
|
|
98
|
+
# 4. Verify
|
|
99
|
+
openclaw plugins list | grep openclaw-memory-decay # should show: openclaw-memory-decay | loaded
|
|
97
100
|
curl -s http://127.0.0.1:8100/health # should show: {"status":"ok","current_tick":0}
|
|
98
101
|
```
|
|
99
102
|
|
|
103
|
+
If the old install is already gone, `openclaw plugins uninstall memory-decay` will simply report that nothing was removed.
|
|
104
|
+
|
|
100
105
|
If auto-detection does not recover your backend path after migration, set the interpreter explicitly:
|
|
101
106
|
|
|
102
107
|
```bash
|
|
103
|
-
openclaw config set plugins.entries.memory-decay.config.pythonPath "~/.openclaw/venvs/memory-decay/bin/python"
|
|
108
|
+
openclaw config set plugins.entries.openclaw-memory-decay.config.pythonPath "~/.openclaw/venvs/memory-decay/bin/python"
|
|
104
109
|
openclaw gateway restart
|
|
105
110
|
```
|
|
106
111
|
|
|
112
|
+
If you are upgrading from an older release, note the plugin id changed from `memory-decay` to `openclaw-memory-decay` in `0.1.8`.
|
|
113
|
+
|
|
114
|
+
- New installs should use `plugins.entries.openclaw-memory-decay`.
|
|
115
|
+
- Older configs under `plugins.entries.memory-decay.config` are still read as a compatibility fallback.
|
|
116
|
+
- For a clean config, migrate to the new key when convenient.
|
|
117
|
+
|
|
107
118
|
**Your memories are safe.** The SQLite database (`memories.db`) is not affected by plugin reinstallation or migration to npm install.
|
|
108
119
|
|
|
109
120
|
To update in the future:
|
|
110
121
|
```bash
|
|
111
|
-
openclaw plugins update memory-decay
|
|
122
|
+
openclaw plugins update openclaw-memory-decay
|
|
112
123
|
openclaw gateway restart
|
|
113
124
|
```
|
|
114
125
|
|
|
115
126
|
## Configuration
|
|
116
127
|
|
|
117
|
-
Add to `~/.openclaw/openclaw.json` under `plugins.entries.memory-decay.config`:
|
|
128
|
+
Add to `~/.openclaw/openclaw.json` under `plugins.entries.openclaw-memory-decay.config`:
|
|
118
129
|
|
|
119
130
|
```json
|
|
120
131
|
{
|
|
121
132
|
"plugins": {
|
|
122
133
|
"entries": {
|
|
123
|
-
"memory-decay": {
|
|
134
|
+
"openclaw-memory-decay": {
|
|
124
135
|
"enabled": true,
|
|
125
136
|
"config": {
|
|
126
137
|
"dbPath": "~/.openclaw/memory-decay-data/memories.db",
|
|
@@ -136,8 +147,8 @@ Add to `~/.openclaw/openclaw.json` under `plugins.entries.memory-decay.config`:
|
|
|
136
147
|
| Option | Default | Description |
|
|
137
148
|
|--------|---------|-------------|
|
|
138
149
|
| `serverPort` | `8100` | Port for the memory-decay HTTP server |
|
|
139
|
-
| `memoryDecayPath` | (auto) | Path to memory-decay-core. Auto-detected from the
|
|
140
|
-
| `pythonPath` | `python3` | Path to Python interpreter. Set this explicitly if you
|
|
150
|
+
| `memoryDecayPath` | (auto) | Path to memory-decay-core. Auto-detected at runtime from the documented default venv or from explicit config |
|
|
151
|
+
| `pythonPath` | `python3` | Path to Python interpreter. Set this explicitly if you do not use `~/.openclaw/venvs/memory-decay` |
|
|
141
152
|
| `dbPath` | `~/.openclaw/memory-decay-data/memories.db` | SQLite database location |
|
|
142
153
|
| `autoSave` | `true` | Auto-save every conversation turn at low importance. Set `false` to let the agent decide what to save |
|
|
143
154
|
| `embeddingProvider` | `local` | Embedding provider: `local`, `openai`, or `gemini` |
|
|
@@ -243,7 +254,7 @@ The plugin registers these tools:
|
|
|
243
254
|
This warning appears when `plugins.allow` is not set. While the plugin still loads (since it is explicitly configured in `plugins.entries`), it is good practice to restrict auto-load to trusted plugins only:
|
|
244
255
|
|
|
245
256
|
```bash
|
|
246
|
-
openclaw config set plugins.allow '["memory-decay"]'
|
|
257
|
+
openclaw config set plugins.allow '["openclaw-memory-decay"]'
|
|
247
258
|
openclaw gateway restart
|
|
248
259
|
```
|
|
249
260
|
|
|
@@ -263,12 +274,32 @@ openclaw plugins install openclaw-memory-decay
|
|
|
263
274
|
curl http://127.0.0.1:8100/health
|
|
264
275
|
```
|
|
265
276
|
|
|
266
|
-
If the import check fails, install the backend into
|
|
277
|
+
If the import check fails, install the backend into the documented default venv path or set `pythonPath` explicitly:
|
|
267
278
|
```bash
|
|
268
279
|
python3 -m venv ~/.openclaw/venvs/memory-decay
|
|
269
280
|
~/.openclaw/venvs/memory-decay/bin/pip install memory-decay
|
|
270
281
|
```
|
|
271
282
|
|
|
283
|
+
If `memory-decay` is only installed in your system Python or in some other venv, the plugin may still fail to auto-detect it. In that case, point the plugin at the exact Python you want it to use:
|
|
284
|
+
|
|
285
|
+
```bash
|
|
286
|
+
openclaw config set plugins.entries.openclaw-memory-decay.config.pythonPath "/absolute/path/to/python"
|
|
287
|
+
openclaw gateway restart
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
Sanity check the exact interpreter before restarting:
|
|
291
|
+
|
|
292
|
+
```bash
|
|
293
|
+
/absolute/path/to/python -c "import memory_decay.server; print('ok')"
|
|
294
|
+
```
|
|
295
|
+
|
|
296
|
+
If you use a different venv path, configure it directly:
|
|
297
|
+
|
|
298
|
+
```bash
|
|
299
|
+
openclaw config set plugins.entries.openclaw-memory-decay.config.pythonPath "/absolute/path/to/venv/bin/python"
|
|
300
|
+
openclaw gateway restart
|
|
301
|
+
```
|
|
302
|
+
|
|
272
303
|
### `error: externally-managed-environment`
|
|
273
304
|
|
|
274
305
|
Your system Python is PEP 668 managed. Install `memory-decay` into a virtualenv instead of the system interpreter:
|
|
@@ -304,7 +335,7 @@ openclaw gateway restart
|
|
|
304
335
|
|
|
305
336
|
# 4. Verify plugin is loaded
|
|
306
337
|
openclaw plugins list
|
|
307
|
-
# Look for: memory-decay | loaded
|
|
338
|
+
# Look for: openclaw-memory-decay | loaded
|
|
308
339
|
|
|
309
340
|
# 5. Check server health
|
|
310
341
|
curl -s http://127.0.0.1:8100/health
|
package/openclaw.plugin.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
|
-
"id": "memory-decay",
|
|
2
|
+
"id": "openclaw-memory-decay",
|
|
3
3
|
"name": "Memory Decay",
|
|
4
4
|
"description": "Human-like memory with decay and reinforcement for OpenClaw agents",
|
|
5
|
-
"version": "0.1.
|
|
5
|
+
"version": "0.1.9",
|
|
6
6
|
"configSchema": {
|
|
7
7
|
"type": "object",
|
|
8
8
|
"additionalProperties": true,
|
package/package.json
CHANGED
|
@@ -3,6 +3,10 @@ import { existsSync as nodeExistsSync, mkdtempSync, readFileSync, rmSync } from
|
|
|
3
3
|
import { homedir as nodeHomedir, tmpdir } from "node:os";
|
|
4
4
|
import { basename, dirname, isAbsolute, join, resolve } from "node:path";
|
|
5
5
|
|
|
6
|
+
const PYTHON_COMMAND_CANDIDATES = process.platform === "win32"
|
|
7
|
+
? ["python"]
|
|
8
|
+
: ["python3", "python", "python3.13", "python3.12", "python3.11", "python3.10"];
|
|
9
|
+
|
|
6
10
|
function resolvePythonPath(command, { execFileSync = nodeExecFileSync, isWin = process.platform === "win32" } = {}) {
|
|
7
11
|
if (isAbsolute(command)) {
|
|
8
12
|
return command;
|
|
@@ -43,7 +47,7 @@ export function buildPythonCandidates({
|
|
|
43
47
|
pathCandidates.push(join(root, isWin ? ".venv/Scripts/python.exe" : ".venv/bin/python"));
|
|
44
48
|
}
|
|
45
49
|
|
|
46
|
-
const commandCandidates = isWin ? ["python"] :
|
|
50
|
+
const commandCandidates = isWin ? ["python"] : PYTHON_COMMAND_CANDIDATES;
|
|
47
51
|
return [...new Set([
|
|
48
52
|
...pathCandidates.filter((candidate) => existsSync(candidate)),
|
|
49
53
|
...commandCandidates,
|
package/src/index.ts
CHANGED
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import type { OpenClawPluginApi } from "openclaw/plugin-sdk";
|
|
2
2
|
import { emptyPluginConfigSchema } from "openclaw/plugin-sdk";
|
|
3
3
|
import { MemoryDecayClient } from "./client.js";
|
|
4
|
+
import { loadLegacyPluginConfig } from "./legacy-config.js";
|
|
4
5
|
import { MemoryDecayService, type ServiceConfig } from "./service.js";
|
|
5
6
|
import { shouldMigrate, migrateMarkdownMemories } from "./migrator.js";
|
|
6
7
|
import { detectPythonEnv, mergePythonEnv } from "./python-env.js";
|
|
@@ -39,14 +40,14 @@ Your memories naturally decay over time. Frequently recalled memories grow stron
|
|
|
39
40
|
const MIN_MESSAGE_LENGTH = 20;
|
|
40
41
|
|
|
41
42
|
const memoryDecayPlugin = {
|
|
42
|
-
id: "memory-decay",
|
|
43
|
+
id: "openclaw-memory-decay",
|
|
43
44
|
name: "Memory Decay",
|
|
44
45
|
description: "Human-like memory with decay and reinforcement",
|
|
45
46
|
kind: "memory" as const,
|
|
46
47
|
configSchema: emptyPluginConfigSchema(),
|
|
47
48
|
|
|
48
49
|
register(api: OpenClawPluginApi) {
|
|
49
|
-
const cfg = api.pluginConfig ?? {};
|
|
50
|
+
const cfg = loadLegacyPluginConfig((api.pluginConfig ?? {}) as Record<string, unknown>);
|
|
50
51
|
const port = (cfg.serverPort as number) ?? 8100;
|
|
51
52
|
const autoSave = cfg.autoSave !== false; // default true
|
|
52
53
|
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
import { existsSync, readFileSync } from "node:fs";
|
|
2
|
+
import { homedir } from "node:os";
|
|
3
|
+
import { join, resolve } from "node:path";
|
|
4
|
+
|
|
5
|
+
export type PluginConfigLike = Record<string, unknown>;
|
|
6
|
+
|
|
7
|
+
function resolveOpenClawConfigPath(env: NodeJS.ProcessEnv = process.env): string {
|
|
8
|
+
return resolve(env.OPENCLAW_HOME || homedir(), ".openclaw", "openclaw.json");
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
export function loadLegacyPluginConfig(
|
|
12
|
+
currentConfig: PluginConfigLike,
|
|
13
|
+
{
|
|
14
|
+
env = process.env,
|
|
15
|
+
configPath = resolveOpenClawConfigPath(env),
|
|
16
|
+
}: { env?: NodeJS.ProcessEnv; configPath?: string } = {},
|
|
17
|
+
): PluginConfigLike {
|
|
18
|
+
if (Object.keys(currentConfig).length > 0) {
|
|
19
|
+
return currentConfig;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
if (!existsSync(configPath)) {
|
|
23
|
+
return currentConfig;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
try {
|
|
27
|
+
const root = JSON.parse(readFileSync(configPath, "utf8"));
|
|
28
|
+
const legacyConfig = root?.plugins?.entries?.["memory-decay"]?.config;
|
|
29
|
+
return legacyConfig && typeof legacyConfig === "object"
|
|
30
|
+
? { ...legacyConfig }
|
|
31
|
+
: currentConfig;
|
|
32
|
+
} catch {
|
|
33
|
+
return currentConfig;
|
|
34
|
+
}
|
|
35
|
+
}
|
package/src/python-env.ts
CHANGED
|
@@ -20,6 +20,10 @@ interface DetectPythonEnvOptions {
|
|
|
20
20
|
removeTempDir?: (path: string) => void;
|
|
21
21
|
}
|
|
22
22
|
|
|
23
|
+
const PYTHON_COMMAND_CANDIDATES = process.platform === "win32"
|
|
24
|
+
? ["python"]
|
|
25
|
+
: ["python3", "python", "python3.13", "python3.12", "python3.11", "python3.10"];
|
|
26
|
+
|
|
23
27
|
export function mergePythonEnv(
|
|
24
28
|
configured: PythonEnvLike,
|
|
25
29
|
detected: PythonEnvLike = {},
|
|
@@ -73,7 +77,7 @@ export function buildPythonCandidates({
|
|
|
73
77
|
join(root, isWin ? ".venv/Scripts/python.exe" : ".venv/bin/python")),
|
|
74
78
|
].filter((candidate): candidate is string => typeof candidate === "string" && candidate.length > 0 && existsSync(candidate));
|
|
75
79
|
|
|
76
|
-
const commandCandidates = isWin ? ["python"] :
|
|
80
|
+
const commandCandidates = isWin ? ["python"] : PYTHON_COMMAND_CANDIDATES;
|
|
77
81
|
return [...new Set([...pathCandidates, ...commandCandidates])];
|
|
78
82
|
}
|
|
79
83
|
|