@t0ken.ai/memoryx-openclaw-plugin 1.0.3 → 1.0.6

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 CHANGED
@@ -1,35 +1,128 @@
1
1
  # MemoryX OpenClaw Plugin
2
2
 
3
- Real-time memory capture and recall plugin for OpenClaw.
3
+ Official MemoryX plugin for OpenClaw. Enables long-term memory for agents by recalling context before execution and saving conversations after each run.
4
4
 
5
5
  ## Features
6
6
 
7
- - **Conversation Buffer**: Automatically buffers conversations with token counting
7
+ - **Recall**: `before_agent_start` semantic search for relevant memories
8
+ - **Add**: `message_received` + `assistant_response` → buffer and flush to MemoryX API
8
9
  - **Auto Registration**: Agents auto-register with machine fingerprint
9
- - **Memory Recall**: Semantic search for relevant memories
10
- - **Configurable API**: Custom API base URL support
10
+ - **Conversation Buffer**: Smart buffering with token counting and round-based flushing
11
11
 
12
- ## Installation
12
+ ## Install
13
+
14
+ ### Option A — NPM (Recommended)
15
+
16
+ ```bash
17
+ openclaw plugins install @t0ken.ai/memoryx-openclaw-plugin
18
+ openclaw gateway restart
19
+ ```
20
+
21
+ Make sure it's enabled in `~/.openclaw/openclaw.json`:
22
+
23
+ ```json
24
+ {
25
+ "plugins": {
26
+ "entries": {
27
+ "@t0ken.ai/memoryx-openclaw-plugin": { "enabled": true }
28
+ }
29
+ }
30
+ }
31
+ ```
32
+
33
+ ### Option B — GitHub
13
34
 
14
35
  ```bash
15
- npm install @t0ken.ai/memoryx-openclaw-plugin
36
+ openclaw plugins install github:t0ken-ai/MemoryX#plugins/memoryx-realtime-plugin
37
+ openclaw gateway restart
38
+ ```
39
+
40
+ ### Option C — Local path
41
+
42
+ Copy this folder into an OpenClaw plugin path (e.g. `~/.openclaw/extensions/`) or use `plugins.load.paths` to point at it.
43
+
44
+ Example `~/.openclaw/openclaw.json`:
45
+
46
+ ```json
47
+ {
48
+ "plugins": {
49
+ "entries": {
50
+ "memoryx-openclaw-plugin": { "enabled": true }
51
+ },
52
+ "load": { "paths": ["/path/to/memoryx-openclaw-plugin"] }
53
+ }
54
+ }
16
55
  ```
17
56
 
57
+ Restart the gateway after config changes.
58
+
18
59
  ## Configuration
19
60
 
61
+ ### Plugin Config
62
+
63
+ In `plugins.entries.memoryx-openclaw-plugin.config`:
64
+
20
65
  ```json
21
66
  {
22
67
  "apiBaseUrl": "https://t0ken.ai/api"
23
68
  }
24
69
  ```
25
70
 
26
- ## Usage
71
+ For self-hosted MemoryX:
72
+
73
+ ```json
74
+ {
75
+ "apiBaseUrl": "http://192.168.31.65:8000/api"
76
+ }
77
+ ```
78
+
79
+ ### Environment Variables
80
+
81
+ The plugin stores credentials locally in `~/.t0ken/memoryx.sqlite`.
82
+
83
+ ## How it Works
84
+
85
+ ### Recall (`before_agent_start`)
86
+
87
+ - Builds a `/v1/memories/search` request using the current prompt
88
+ - Injects relevant memories via `prependContext`:
89
+ ```
90
+ [相关记忆]
91
+ - [preference] User prefers dark mode
92
+ - [fact] User's timezone is UTC+8
93
+ [End of memories]
94
+ ```
95
+
96
+ ### Add (`message_received` + `assistant_response`)
97
+
98
+ - Buffers messages with precise token counting (tiktoken)
99
+ - Flushes to `/v1/conversations/flush` when:
100
+ - 2 conversation rounds completed (user + assistant = 1 round)
101
+ - 30 minutes timeout
102
+ - Server extracts entities, facts, and preferences automatically
103
+
104
+ ### Auto Registration
105
+
106
+ On first run, the plugin:
107
+ 1. Generates a machine fingerprint
108
+ 2. Calls `/agents/auto-register` to get API key
109
+ 3. Stores credentials locally for future sessions
110
+
111
+ ## Memory Categories
112
+
113
+ Memories are categorized by the server:
114
+ - **preference**: User preferences and settings
115
+ - **fact**: Factual information about the user
116
+ - **plan**: Future plans and goals
117
+ - **experience**: Past experiences
118
+ - **opinion**: User opinions and views
119
+
120
+ ## Notes
27
121
 
28
- The plugin automatically:
29
- 1. Captures user and assistant messages
30
- 2. Buffers conversations until threshold (2 rounds)
31
- 3. Flushes to MemoryX API for memory extraction
32
- 4. Recalls relevant memories before agent starts
122
+ - Conversation buffer uses `cl100k_base` encoding (GPT-4 compatible)
123
+ - Maximum 8000 tokens per message
124
+ - Minimum 2 characters per message
125
+ - Short messages like "ok", "thanks" are skipped
33
126
 
34
127
  ## License
35
128
 
package/dist/index.d.ts CHANGED
@@ -93,10 +93,13 @@ declare class MemoryXPlugin {
93
93
  };
94
94
  };
95
95
  }
96
- export declare function onMessage(message: string, context: Record<string, any>): Promise<{
97
- context: Record<string, any>;
98
- }>;
99
- export declare function onResponse(response: string, context: Record<string, any>): string;
100
- export declare function register(api: any, pluginConfig?: PluginConfig): void;
96
+ declare const _default: {
97
+ id: string;
98
+ name: string;
99
+ version: string;
100
+ description: string;
101
+ register(api: any, pluginConfig?: PluginConfig): void;
102
+ };
103
+ export default _default;
101
104
  export { MemoryXPlugin, ConversationBuffer };
102
105
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;GAcG;AAWH,UAAU,YAAY;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;CACvB;AAUD,UAAU,OAAO;IACb,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;CACrB;AAED,UAAU,YAAY;IAClB,QAAQ,EAAE,KAAK,CAAC;QACZ,EAAE,EAAE,MAAM,CAAC;QACX,OAAO,EAAE,MAAM,CAAC;QAChB,QAAQ,EAAE,MAAM,CAAC;QACjB,KAAK,EAAE,MAAM,CAAC;KACjB,CAAC,CAAC;IACH,SAAS,EAAE,OAAO,CAAC;IACnB,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,cAAM,kBAAkB;IACpB,OAAO,CAAC,QAAQ,CAAiB;IACjC,OAAO,CAAC,UAAU,CAAa;IAC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AAgD;IAC9D,OAAO,CAAC,UAAU,CAAa;IAC/B,OAAO,CAAC,QAAQ,CAAC,oBAAoB,CAAS;IAC9C,OAAO,CAAC,YAAY,CAA6B;gBAErC,YAAY,CAAC,EAAE,YAAY;IAQvC,OAAO,KAAK,OAAO,GAElB;YAEa,IAAI;YAWJ,UAAU;IAgBxB,OAAO,CAAC,UAAU;YAQJ,YAAY;YAgCZ,qBAAqB;IAkBnC,OAAO,CAAC,eAAe;YAQT,iBAAiB;IAqClB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,OAAO,CAAC;IAyB1D,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,KAAK,GAAE,MAAU,GAAG,OAAO,CAAC,YAAY,CAAC;IAoD/D,eAAe,IAAI,OAAO,CAAC,IAAI,CAAC;IAKtC,SAAS,IAAI;QAChB,WAAW,EAAE,OAAO,CAAC;QACrB,SAAS,EAAE,OAAO,CAAC;QACnB,YAAY,EAAE;YAAE,YAAY,EAAE,MAAM,CAAC;YAAC,UAAU,EAAE,MAAM,CAAA;SAAE,CAAA;KAC7D;CAOJ;;;;;;kBAUiB,GAAG,iBAAiB,YAAY,GAAG,IAAI;;AANzD,wBAwEE;AAEF,OAAO,EAAE,aAAa,EAAE,kBAAkB,EAAE,CAAC"}
package/dist/index.js CHANGED
@@ -320,64 +320,65 @@ class MemoryXPlugin {
320
320
  }
321
321
  }
322
322
  let plugin;
323
- export async function onMessage(message, context) {
324
- if (message && plugin) {
325
- await plugin.onMessage("user", message);
326
- }
327
- return { context };
328
- }
329
- export function onResponse(response, context) {
330
- return response;
331
- }
332
- export function register(api, pluginConfig) {
333
- api.logger.info("[MemoryX] Plugin registering (Phase 1 - Cloud with Buffer)...");
334
- if (pluginConfig?.apiBaseUrl) {
335
- api.logger.info(`[MemoryX] Using custom API base URL: ${pluginConfig.apiBaseUrl}`);
336
- }
337
- plugin = new MemoryXPlugin(pluginConfig);
338
- api.on("message_received", async (event, ctx) => {
339
- const { content, from, timestamp } = event;
340
- if (content && plugin) {
341
- await plugin.onMessage("user", content);
323
+ export default {
324
+ id: "@t0ken.ai/memoryx-openclaw-plugin",
325
+ name: "MemoryX Real-time Plugin",
326
+ version: "1.0.6",
327
+ description: "Real-time memory capture and recall for OpenClaw",
328
+ register(api, pluginConfig) {
329
+ api.logger.info("[MemoryX] Plugin registering...");
330
+ if (pluginConfig?.apiBaseUrl) {
331
+ api.logger.info(`[MemoryX] API Base: \`${pluginConfig.apiBaseUrl}\``);
342
332
  }
343
- });
344
- api.on("assistant_response", async (event, ctx) => {
345
- const { content } = event;
346
- if (content && plugin) {
347
- await plugin.onMessage("assistant", content);
333
+ const storedConfig = localStorage.getItem("memoryx_config");
334
+ if (storedConfig) {
335
+ api.logger.info(`[MemoryX] Database: ${storedConfig.split('"apiBaseUrl"')[0].match(/"([^"]+)"/)?.[1] || 'unknown'}`);
348
336
  }
349
- });
350
- api.on("before_agent_start", async (event, ctx) => {
351
- const { prompt } = event;
352
- if (!prompt || prompt.length < 2 || !plugin)
353
- return;
354
- try {
355
- const result = await plugin.recall(prompt, 5);
356
- if (result.isLimited) {
357
- api.logger.warn(`[MemoryX] ${result.upgradeHint}`);
337
+ plugin = new MemoryXPlugin(pluginConfig);
338
+ api.on("message_received", async (event, ctx) => {
339
+ const { content, from, timestamp } = event;
340
+ if (content && plugin) {
341
+ await plugin.onMessage("user", content);
342
+ }
343
+ });
344
+ api.on("assistant_response", async (event, ctx) => {
345
+ const { content } = event;
346
+ if (content && plugin) {
347
+ await plugin.onMessage("assistant", content);
348
+ }
349
+ });
350
+ api.on("before_agent_start", async (event, ctx) => {
351
+ const { prompt } = event;
352
+ if (!prompt || prompt.length < 2 || !plugin)
353
+ return;
354
+ try {
355
+ const result = await plugin.recall(prompt, 5);
356
+ if (result.isLimited) {
357
+ api.logger.warn(`[MemoryX] ${result.upgradeHint}`);
358
+ return {
359
+ prependContext: `[系统提示] ${result.upgradeHint}\n`
360
+ };
361
+ }
362
+ if (result.memories.length === 0)
363
+ return;
364
+ const memories = result.memories
365
+ .map(m => `- [${m.category}] ${m.content}`)
366
+ .join("\n");
367
+ api.logger.info(`[MemoryX] Recalled ${result.memories.length} memories from cloud`);
358
368
  return {
359
- prependContext: `[系统提示] ${result.upgradeHint}\n`
369
+ prependContext: `[相关记忆]\n${memories}\n[End of memories]\n`
360
370
  };
361
371
  }
362
- if (result.memories.length === 0)
363
- return;
364
- const memories = result.memories
365
- .map(m => `- [${m.category}] ${m.content}`)
366
- .join("\n");
367
- api.logger.info(`[MemoryX] Recalled ${result.memories.length} memories from cloud`);
368
- return {
369
- prependContext: `[相关记忆]\n${memories}\n[End of memories]\n`
370
- };
371
- }
372
- catch (error) {
373
- api.logger.warn(`[MemoryX] Recall failed: ${error}`);
374
- }
375
- });
376
- api.on("conversation_end", async (event, ctx) => {
377
- if (plugin) {
378
- await plugin.endConversation();
379
- }
380
- });
381
- api.logger.info("[MemoryX] Plugin registered successfully");
382
- }
372
+ catch (error) {
373
+ api.logger.warn(`[MemoryX] Recall failed: ${error}`);
374
+ }
375
+ });
376
+ api.on("conversation_end", async (event, ctx) => {
377
+ if (plugin) {
378
+ await plugin.endConversation();
379
+ }
380
+ });
381
+ api.logger.info("[MemoryX] Plugin registered successfully");
382
+ }
383
+ };
383
384
  export { MemoryXPlugin, ConversationBuffer };
@@ -1,16 +1,18 @@
1
1
  {
2
2
  "id": "@t0ken.ai/memoryx-openclaw-plugin",
3
3
  "name": "MemoryX Real-time Plugin",
4
- "version": "1.0.3",
4
+ "version": "1.0.6",
5
5
  "description": "Real-time memory capture and recall for OpenClaw",
6
- "entry": "./dist/index.js",
7
6
  "kind": "memory",
7
+ "main": "./dist/index.js",
8
8
  "configSchema": {
9
9
  "type": "object",
10
10
  "properties": {
11
11
  "apiBaseUrl": {
12
- "type": "string"
12
+ "type": "string",
13
+ "description": "MemoryX API base URL (default: https://t0ken.ai/api)"
13
14
  }
14
- }
15
+ },
16
+ "additionalProperties": false
15
17
  }
16
18
  }
package/package.json CHANGED
@@ -1,18 +1,18 @@
1
1
  {
2
2
  "name": "@t0ken.ai/memoryx-openclaw-plugin",
3
- "version": "1.0.3",
3
+ "version": "1.0.6",
4
4
  "description": "MemoryX real-time memory capture and recall plugin for OpenClaw",
5
5
  "type": "module",
6
- "main": "dist/index.js",
7
- "types": "dist/index.d.ts",
6
+ "author": "MemoryX Team",
7
+ "license": "MIT",
8
+ "main": "./dist/index.js",
8
9
  "files": [
9
10
  "dist",
10
11
  "openclaw.plugin.json",
11
12
  "README.md"
12
13
  ],
13
14
  "scripts": {
14
- "build": "tsc",
15
- "prepare": "npm run build"
15
+ "build": "tsc"
16
16
  },
17
17
  "keywords": [
18
18
  "openclaw",
@@ -20,17 +20,13 @@
20
20
  "memory",
21
21
  "plugin"
22
22
  ],
23
- "author": "MemoryX Team",
24
- "license": "MIT",
25
23
  "repository": {
26
24
  "type": "git",
27
25
  "url": "https://github.com/t0ken-ai/MemoryX.git",
28
26
  "directory": "plugins/memoryx-realtime-plugin"
29
27
  },
30
28
  "openclaw": {
31
- "extensions": [
32
- "./dist/index.js"
33
- ]
29
+ "extensions": ["./dist/index.js"]
34
30
  },
35
31
  "devDependencies": {
36
32
  "@types/node": "^20.0.0",