openclaw-cortex-memory 0.1.0-Alpha.1
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 +198 -0
- package/SKILL.md +263 -0
- package/dist/index.d.ts +90 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +1871 -0
- package/dist/index.js.map +1 -0
- package/dist/openclaw.plugin.json +295 -0
- package/dist/src/engine/memory_engine.d.ts +20 -0
- package/dist/src/engine/memory_engine.d.ts.map +1 -0
- package/dist/src/engine/memory_engine.js +3 -0
- package/dist/src/engine/memory_engine.js.map +1 -0
- package/dist/src/engine/ts_engine.d.ts +69 -0
- package/dist/src/engine/ts_engine.d.ts.map +1 -0
- package/dist/src/engine/ts_engine.js +390 -0
- package/dist/src/engine/ts_engine.js.map +1 -0
- package/dist/src/engine/types.d.ts +53 -0
- package/dist/src/engine/types.d.ts.map +1 -0
- package/dist/src/engine/types.js +3 -0
- package/dist/src/engine/types.js.map +1 -0
- package/dist/src/reflect/reflector.d.ts +32 -0
- package/dist/src/reflect/reflector.d.ts.map +1 -0
- package/dist/src/reflect/reflector.js +124 -0
- package/dist/src/reflect/reflector.js.map +1 -0
- package/dist/src/rules/rule_store.d.ts +22 -0
- package/dist/src/rules/rule_store.d.ts.map +1 -0
- package/dist/src/rules/rule_store.js +102 -0
- package/dist/src/rules/rule_store.js.map +1 -0
- package/dist/src/session/session_end.d.ts +30 -0
- package/dist/src/session/session_end.d.ts.map +1 -0
- package/dist/src/session/session_end.js +209 -0
- package/dist/src/session/session_end.js.map +1 -0
- package/dist/src/store/read_store.d.ts +44 -0
- package/dist/src/store/read_store.d.ts.map +1 -0
- package/dist/src/store/read_store.js +239 -0
- package/dist/src/store/read_store.js.map +1 -0
- package/dist/src/store/write_store.d.ts +31 -0
- package/dist/src/store/write_store.d.ts.map +1 -0
- package/dist/src/store/write_store.js +138 -0
- package/dist/src/store/write_store.js.map +1 -0
- package/dist/src/sync/session_sync.d.ts +28 -0
- package/dist/src/sync/session_sync.d.ts.map +1 -0
- package/dist/src/sync/session_sync.js +214 -0
- package/dist/src/sync/session_sync.js.map +1 -0
- package/index.ts +2071 -0
- package/openclaw.plugin.json +295 -0
- package/package.json +55 -0
- package/scripts/cli.js +262 -0
- package/scripts/install.js +27 -0
- package/scripts/uninstall.js +212 -0
|
@@ -0,0 +1,295 @@
|
|
|
1
|
+
{
|
|
2
|
+
"id": "openclaw-cortex-memory",
|
|
3
|
+
"name": "Cortex Memory",
|
|
4
|
+
"version": "0.1.0-Alpha.1",
|
|
5
|
+
"description": "Long-term memory system with semantic, episodic, and procedural memory for AI Agents",
|
|
6
|
+
"main": "dist/index.js",
|
|
7
|
+
"author": "OpenClaw Community",
|
|
8
|
+
"license": "MIT",
|
|
9
|
+
"type": "memory",
|
|
10
|
+
"repository": {
|
|
11
|
+
"type": "git",
|
|
12
|
+
"url": "https://github.com/deki18/openclaw-cortex-memory"
|
|
13
|
+
},
|
|
14
|
+
"capabilities": {
|
|
15
|
+
"tools": true,
|
|
16
|
+
"hooks": true,
|
|
17
|
+
"cli": true,
|
|
18
|
+
"channels": false,
|
|
19
|
+
"memory": true
|
|
20
|
+
},
|
|
21
|
+
"hooks": [
|
|
22
|
+
"message_received",
|
|
23
|
+
"session_end"
|
|
24
|
+
],
|
|
25
|
+
"tools": [
|
|
26
|
+
{
|
|
27
|
+
"name": "search_memory",
|
|
28
|
+
"description": "Search long-term memory for relevant information",
|
|
29
|
+
"parameters": {
|
|
30
|
+
"type": "object",
|
|
31
|
+
"properties": {
|
|
32
|
+
"query": {
|
|
33
|
+
"type": "string",
|
|
34
|
+
"description": "Search query"
|
|
35
|
+
},
|
|
36
|
+
"top_k": {
|
|
37
|
+
"type": "integer",
|
|
38
|
+
"description": "Number of results to return"
|
|
39
|
+
}
|
|
40
|
+
},
|
|
41
|
+
"required": ["query"],
|
|
42
|
+
"additionalProperties": false
|
|
43
|
+
}
|
|
44
|
+
},
|
|
45
|
+
{
|
|
46
|
+
"name": "store_event",
|
|
47
|
+
"description": "Store a new event in memory",
|
|
48
|
+
"parameters": {
|
|
49
|
+
"type": "object",
|
|
50
|
+
"properties": {
|
|
51
|
+
"summary": {
|
|
52
|
+
"type": "string",
|
|
53
|
+
"description": "Event summary"
|
|
54
|
+
},
|
|
55
|
+
"entities": {
|
|
56
|
+
"type": "array",
|
|
57
|
+
"description": "Involved entities",
|
|
58
|
+
"items": {
|
|
59
|
+
"type": "string"
|
|
60
|
+
}
|
|
61
|
+
},
|
|
62
|
+
"outcome": {
|
|
63
|
+
"type": "string",
|
|
64
|
+
"description": "Event outcome"
|
|
65
|
+
},
|
|
66
|
+
"relations": {
|
|
67
|
+
"type": "array",
|
|
68
|
+
"description": "Entity relationships",
|
|
69
|
+
"items": {
|
|
70
|
+
"type": "string"
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
},
|
|
74
|
+
"required": ["summary"],
|
|
75
|
+
"additionalProperties": false
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
{
|
|
79
|
+
"name": "query_graph",
|
|
80
|
+
"description": "Query memory graph for entity relationships",
|
|
81
|
+
"parameters": {
|
|
82
|
+
"type": "object",
|
|
83
|
+
"properties": {
|
|
84
|
+
"entity": {
|
|
85
|
+
"type": "string",
|
|
86
|
+
"description": "Entity name"
|
|
87
|
+
}
|
|
88
|
+
},
|
|
89
|
+
"required": ["entity"],
|
|
90
|
+
"additionalProperties": false
|
|
91
|
+
}
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"name": "get_hot_context",
|
|
95
|
+
"description": "Get hot memory context for current session",
|
|
96
|
+
"parameters": {
|
|
97
|
+
"type": "object",
|
|
98
|
+
"properties": {
|
|
99
|
+
"limit": {
|
|
100
|
+
"type": "integer",
|
|
101
|
+
"description": "Maximum number of hot context items"
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
"required": [],
|
|
105
|
+
"additionalProperties": false
|
|
106
|
+
}
|
|
107
|
+
},
|
|
108
|
+
{
|
|
109
|
+
"name": "get_auto_context",
|
|
110
|
+
"description": "Get relevant memories based on recent messages",
|
|
111
|
+
"parameters": {
|
|
112
|
+
"type": "object",
|
|
113
|
+
"properties": {
|
|
114
|
+
"include_hot": {
|
|
115
|
+
"type": "boolean",
|
|
116
|
+
"description": "Include hot context"
|
|
117
|
+
}
|
|
118
|
+
},
|
|
119
|
+
"required": [],
|
|
120
|
+
"additionalProperties": false
|
|
121
|
+
}
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
"name": "reflect_memory",
|
|
125
|
+
"description": "Convert events into semantic knowledge",
|
|
126
|
+
"parameters": {
|
|
127
|
+
"type": "object",
|
|
128
|
+
"properties": {},
|
|
129
|
+
"required": [],
|
|
130
|
+
"additionalProperties": false
|
|
131
|
+
}
|
|
132
|
+
},
|
|
133
|
+
{
|
|
134
|
+
"name": "sync_memory",
|
|
135
|
+
"description": "Import historical session data into memory",
|
|
136
|
+
"parameters": {
|
|
137
|
+
"type": "object",
|
|
138
|
+
"properties": {},
|
|
139
|
+
"required": [],
|
|
140
|
+
"additionalProperties": false
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
{
|
|
144
|
+
"name": "delete_memory",
|
|
145
|
+
"description": "Delete a memory by ID",
|
|
146
|
+
"parameters": {
|
|
147
|
+
"type": "object",
|
|
148
|
+
"properties": {
|
|
149
|
+
"memory_id": {
|
|
150
|
+
"type": "string",
|
|
151
|
+
"description": "Memory ID"
|
|
152
|
+
}
|
|
153
|
+
},
|
|
154
|
+
"required": ["memory_id"],
|
|
155
|
+
"additionalProperties": false
|
|
156
|
+
}
|
|
157
|
+
},
|
|
158
|
+
{
|
|
159
|
+
"name": "diagnostics",
|
|
160
|
+
"description": "Check memory system status",
|
|
161
|
+
"parameters": {
|
|
162
|
+
"type": "object",
|
|
163
|
+
"properties": {},
|
|
164
|
+
"required": [],
|
|
165
|
+
"additionalProperties": false
|
|
166
|
+
}
|
|
167
|
+
}
|
|
168
|
+
],
|
|
169
|
+
"configSchema": {
|
|
170
|
+
"type": "object",
|
|
171
|
+
"properties": {
|
|
172
|
+
"enabled": {
|
|
173
|
+
"type": "boolean",
|
|
174
|
+
"description": "Enable or disable Cortex Memory plugin",
|
|
175
|
+
"default": true
|
|
176
|
+
},
|
|
177
|
+
"apiUrl": {
|
|
178
|
+
"type": "string",
|
|
179
|
+
"description": "URL of the memory service API",
|
|
180
|
+
"default": "http://127.0.0.1:8765"
|
|
181
|
+
},
|
|
182
|
+
"engineMode": {
|
|
183
|
+
"type": "string",
|
|
184
|
+
"description": "Memory engine mode",
|
|
185
|
+
"enum": ["ts"],
|
|
186
|
+
"default": "ts"
|
|
187
|
+
},
|
|
188
|
+
"dbPath": {
|
|
189
|
+
"type": "string",
|
|
190
|
+
"description": "Path to the memory database directory"
|
|
191
|
+
},
|
|
192
|
+
"autoSync": {
|
|
193
|
+
"type": "boolean",
|
|
194
|
+
"description": "Automatically sync memory on session end",
|
|
195
|
+
"default": true
|
|
196
|
+
},
|
|
197
|
+
"autoReflect": {
|
|
198
|
+
"type": "boolean",
|
|
199
|
+
"description": "Automatically trigger reflection periodically",
|
|
200
|
+
"default": false
|
|
201
|
+
},
|
|
202
|
+
"embedding": {
|
|
203
|
+
"type": "object",
|
|
204
|
+
"description": "Embedding model configuration",
|
|
205
|
+
"properties": {
|
|
206
|
+
"provider": {
|
|
207
|
+
"type": "string",
|
|
208
|
+
"description": "Embedding provider name"
|
|
209
|
+
},
|
|
210
|
+
"model": {
|
|
211
|
+
"type": "string",
|
|
212
|
+
"description": "Embedding model name"
|
|
213
|
+
},
|
|
214
|
+
"apiKey": {
|
|
215
|
+
"type": "string",
|
|
216
|
+
"description": "Embedding API key"
|
|
217
|
+
},
|
|
218
|
+
"baseURL": {
|
|
219
|
+
"type": "string",
|
|
220
|
+
"description": "Embedding API base URL"
|
|
221
|
+
},
|
|
222
|
+
"baseUrl": {
|
|
223
|
+
"type": "string",
|
|
224
|
+
"description": "Embedding API base URL (camelCase alias)"
|
|
225
|
+
},
|
|
226
|
+
"dimensions": {
|
|
227
|
+
"type": "integer",
|
|
228
|
+
"description": "Embedding dimensions"
|
|
229
|
+
}
|
|
230
|
+
},
|
|
231
|
+
"additionalProperties": false
|
|
232
|
+
},
|
|
233
|
+
"llm": {
|
|
234
|
+
"type": "object",
|
|
235
|
+
"description": "LLM configuration",
|
|
236
|
+
"properties": {
|
|
237
|
+
"provider": {
|
|
238
|
+
"type": "string",
|
|
239
|
+
"description": "LLM provider name"
|
|
240
|
+
},
|
|
241
|
+
"model": {
|
|
242
|
+
"type": "string",
|
|
243
|
+
"description": "LLM model name"
|
|
244
|
+
},
|
|
245
|
+
"apiKey": {
|
|
246
|
+
"type": "string",
|
|
247
|
+
"description": "LLM API key"
|
|
248
|
+
},
|
|
249
|
+
"baseURL": {
|
|
250
|
+
"type": "string",
|
|
251
|
+
"description": "LLM API base URL"
|
|
252
|
+
},
|
|
253
|
+
"baseUrl": {
|
|
254
|
+
"type": "string",
|
|
255
|
+
"description": "LLM API base URL (camelCase alias)"
|
|
256
|
+
}
|
|
257
|
+
},
|
|
258
|
+
"additionalProperties": false
|
|
259
|
+
},
|
|
260
|
+
"reranker": {
|
|
261
|
+
"type": "object",
|
|
262
|
+
"description": "Reranker configuration",
|
|
263
|
+
"properties": {
|
|
264
|
+
"provider": {
|
|
265
|
+
"type": "string",
|
|
266
|
+
"description": "Reranker provider name"
|
|
267
|
+
},
|
|
268
|
+
"model": {
|
|
269
|
+
"type": "string",
|
|
270
|
+
"description": "Reranker model name"
|
|
271
|
+
},
|
|
272
|
+
"apiKey": {
|
|
273
|
+
"type": "string",
|
|
274
|
+
"description": "Reranker API key"
|
|
275
|
+
},
|
|
276
|
+
"baseURL": {
|
|
277
|
+
"type": "string",
|
|
278
|
+
"description": "Reranker API base URL"
|
|
279
|
+
},
|
|
280
|
+
"baseUrl": {
|
|
281
|
+
"type": "string",
|
|
282
|
+
"description": "Reranker API base URL (camelCase alias)"
|
|
283
|
+
}
|
|
284
|
+
},
|
|
285
|
+
"additionalProperties": false
|
|
286
|
+
},
|
|
287
|
+
"fallbackToBuiltin": {
|
|
288
|
+
"type": "boolean",
|
|
289
|
+
"description": "Fallback to OpenClaw builtin memory when Cortex Memory fails",
|
|
290
|
+
"default": true
|
|
291
|
+
}
|
|
292
|
+
},
|
|
293
|
+
"additionalProperties": false
|
|
294
|
+
}
|
|
295
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "openclaw-cortex-memory",
|
|
3
|
+
"version": "0.1.0-Alpha.1",
|
|
4
|
+
"description": "Long-term memory system for OpenClaw AI Agent",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"types": "dist/index.d.ts",
|
|
7
|
+
"bin": {
|
|
8
|
+
"cortex-memory": "scripts/cli.js"
|
|
9
|
+
},
|
|
10
|
+
"scripts": {
|
|
11
|
+
"build": "tsc && node -e \"require('fs').copyFileSync('openclaw.plugin.json','dist/openclaw.plugin.json')\"",
|
|
12
|
+
"dev": "tsc --watch",
|
|
13
|
+
"prepublishOnly": "npm run build",
|
|
14
|
+
"postinstall": "node scripts/install.js"
|
|
15
|
+
},
|
|
16
|
+
"keywords": [
|
|
17
|
+
"openclaw",
|
|
18
|
+
"memory",
|
|
19
|
+
"ai",
|
|
20
|
+
"agent",
|
|
21
|
+
"rag"
|
|
22
|
+
],
|
|
23
|
+
"author": "",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"dependencies": {
|
|
26
|
+
"undici": "^6.21.0"
|
|
27
|
+
},
|
|
28
|
+
"devDependencies": {
|
|
29
|
+
"@types/node": "^22.19.15",
|
|
30
|
+
"typescript": "^5.7.2"
|
|
31
|
+
},
|
|
32
|
+
"peerDependencies": {
|
|
33
|
+
"openclaw": ">=2026.3.8"
|
|
34
|
+
},
|
|
35
|
+
"engines": {
|
|
36
|
+
"node": ">=22.0.0"
|
|
37
|
+
},
|
|
38
|
+
"files": [
|
|
39
|
+
"dist/",
|
|
40
|
+
"index.ts",
|
|
41
|
+
"scripts/cli.js",
|
|
42
|
+
"scripts/install.js",
|
|
43
|
+
"scripts/uninstall.js",
|
|
44
|
+
"openclaw.plugin.json",
|
|
45
|
+
"SKILL.md"
|
|
46
|
+
],
|
|
47
|
+
"openclaw": {
|
|
48
|
+
"plugin": true,
|
|
49
|
+
"requiresPython": false,
|
|
50
|
+
"cli": "cortex-memory",
|
|
51
|
+
"extensions": [
|
|
52
|
+
"./dist/index.js"
|
|
53
|
+
]
|
|
54
|
+
}
|
|
55
|
+
}
|
package/scripts/cli.js
ADDED
|
@@ -0,0 +1,262 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
const { spawn } = require('child_process');
|
|
6
|
+
|
|
7
|
+
const PLUGIN_NAME = 'openclaw-cortex-memory';
|
|
8
|
+
|
|
9
|
+
function findOpenClawConfig() {
|
|
10
|
+
const explicitConfigPath = process.env.OPENCLAW_CONFIG_PATH || '';
|
|
11
|
+
const basePath = process.env.OPENCLAW_BASE_PATH || '';
|
|
12
|
+
const homePath = process.env.USERPROFILE || process.env.HOME || '';
|
|
13
|
+
const possiblePaths = [
|
|
14
|
+
explicitConfigPath,
|
|
15
|
+
basePath ? path.join(basePath, 'openclaw.json') : '',
|
|
16
|
+
path.join(process.cwd(), 'openclaw.json'),
|
|
17
|
+
homePath ? path.join(homePath, '.openclaw', 'openclaw.json') : '',
|
|
18
|
+
];
|
|
19
|
+
|
|
20
|
+
for (const p of possiblePaths) {
|
|
21
|
+
if (p && fs.existsSync(p)) {
|
|
22
|
+
return p;
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
return null;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
function loadConfig(configPath) {
|
|
29
|
+
if (!configPath || !fs.existsSync(configPath)) {
|
|
30
|
+
return { plugins: {} };
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
try {
|
|
34
|
+
const content = fs.readFileSync(configPath, 'utf-8');
|
|
35
|
+
return JSON.parse(content);
|
|
36
|
+
} catch (e) {
|
|
37
|
+
console.error(`Error loading config: ${e.message}`);
|
|
38
|
+
return { plugins: {} };
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function saveConfig(configPath, config) {
|
|
43
|
+
const dir = path.dirname(configPath);
|
|
44
|
+
if (!fs.existsSync(dir)) {
|
|
45
|
+
fs.mkdirSync(dir, { recursive: true });
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
|
|
49
|
+
console.log(`Configuration saved to: ${configPath}`);
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
function enablePlugin() {
|
|
53
|
+
const configPath = findOpenClawConfig();
|
|
54
|
+
|
|
55
|
+
if (!configPath) {
|
|
56
|
+
const defaultPath = path.join(process.env.USERPROFILE || process.env.HOME || '', '.openclaw', 'openclaw.json');
|
|
57
|
+
console.log(`No config file found. Creating: ${defaultPath}`);
|
|
58
|
+
|
|
59
|
+
const config = {
|
|
60
|
+
plugins: {
|
|
61
|
+
allow: [PLUGIN_NAME],
|
|
62
|
+
slots: {
|
|
63
|
+
memory: PLUGIN_NAME
|
|
64
|
+
},
|
|
65
|
+
entries: {
|
|
66
|
+
[PLUGIN_NAME]: {
|
|
67
|
+
enabled: true
|
|
68
|
+
}
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
};
|
|
72
|
+
saveConfig(defaultPath, config);
|
|
73
|
+
console.log(`Plugin '${PLUGIN_NAME}' has been enabled.`);
|
|
74
|
+
return;
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
const config = loadConfig(configPath);
|
|
78
|
+
|
|
79
|
+
if (!config.plugins) {
|
|
80
|
+
config.plugins = {};
|
|
81
|
+
}
|
|
82
|
+
if (!Array.isArray(config.plugins.allow)) {
|
|
83
|
+
config.plugins.allow = [];
|
|
84
|
+
}
|
|
85
|
+
if (!config.plugins.allow.includes(PLUGIN_NAME)) {
|
|
86
|
+
config.plugins.allow.push(PLUGIN_NAME);
|
|
87
|
+
}
|
|
88
|
+
if (!config.plugins.entries) {
|
|
89
|
+
config.plugins.entries = {};
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
if (config.plugins.entries[PLUGIN_NAME]?.enabled === true) {
|
|
93
|
+
console.log(`Plugin '${PLUGIN_NAME}' is already enabled.`);
|
|
94
|
+
return;
|
|
95
|
+
}
|
|
96
|
+
|
|
97
|
+
config.plugins.entries[PLUGIN_NAME] = {
|
|
98
|
+
...config.plugins.entries[PLUGIN_NAME],
|
|
99
|
+
enabled: true
|
|
100
|
+
};
|
|
101
|
+
|
|
102
|
+
if (!config.plugins.slots) {
|
|
103
|
+
config.plugins.slots = {};
|
|
104
|
+
}
|
|
105
|
+
config.plugins.slots.memory = PLUGIN_NAME;
|
|
106
|
+
|
|
107
|
+
saveConfig(configPath, config);
|
|
108
|
+
console.log(`Plugin '${PLUGIN_NAME}' has been enabled.`);
|
|
109
|
+
console.log('The plugin will be activated on the next OpenClaw restart or config reload.');
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
function disablePlugin() {
|
|
113
|
+
const configPath = findOpenClawConfig();
|
|
114
|
+
|
|
115
|
+
if (!configPath) {
|
|
116
|
+
console.error('No OpenClaw configuration file found.');
|
|
117
|
+
console.error('Please create an openclaw.json file first.');
|
|
118
|
+
process.exit(1);
|
|
119
|
+
}
|
|
120
|
+
|
|
121
|
+
const config = loadConfig(configPath);
|
|
122
|
+
|
|
123
|
+
if (!config.plugins?.entries?.[PLUGIN_NAME] || config.plugins.entries[PLUGIN_NAME].enabled !== false) {
|
|
124
|
+
if (!config.plugins) {
|
|
125
|
+
config.plugins = {};
|
|
126
|
+
}
|
|
127
|
+
if (!config.plugins.entries) {
|
|
128
|
+
config.plugins.entries = {};
|
|
129
|
+
}
|
|
130
|
+
|
|
131
|
+
config.plugins.entries[PLUGIN_NAME] = {
|
|
132
|
+
...config.plugins.entries[PLUGIN_NAME],
|
|
133
|
+
enabled: false
|
|
134
|
+
};
|
|
135
|
+
|
|
136
|
+
saveConfig(configPath, config);
|
|
137
|
+
console.log(`Plugin '${PLUGIN_NAME}' has been disabled.`);
|
|
138
|
+
console.log('The plugin will be deactivated on the next OpenClaw restart or config reload.');
|
|
139
|
+
} else {
|
|
140
|
+
console.log(`Plugin '${PLUGIN_NAME}' is already disabled.`);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
|
|
144
|
+
function getStatus() {
|
|
145
|
+
const configPath = findOpenClawConfig();
|
|
146
|
+
|
|
147
|
+
console.log('Cortex Memory Plugin Status');
|
|
148
|
+
console.log('='.repeat(40));
|
|
149
|
+
|
|
150
|
+
if (!configPath) {
|
|
151
|
+
console.log('Config file: Not found');
|
|
152
|
+
console.log('Status: Enabled (default)');
|
|
153
|
+
console.log('\nNote: Plugin is enabled by default when no config exists.');
|
|
154
|
+
return;
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
console.log(`Config file: ${configPath}`);
|
|
158
|
+
|
|
159
|
+
const config = loadConfig(configPath);
|
|
160
|
+
const pluginConfig = config.plugins?.entries?.[PLUGIN_NAME];
|
|
161
|
+
|
|
162
|
+
if (!pluginConfig) {
|
|
163
|
+
console.log('Status: Enabled (default)');
|
|
164
|
+
} else {
|
|
165
|
+
console.log(`Status: ${pluginConfig.enabled === false ? 'Disabled' : 'Enabled'}`);
|
|
166
|
+
}
|
|
167
|
+
|
|
168
|
+
console.log('\nConfiguration:');
|
|
169
|
+
console.log(JSON.stringify(pluginConfig || { enabled: true }, null, 2));
|
|
170
|
+
}
|
|
171
|
+
|
|
172
|
+
function runUninstall(args) {
|
|
173
|
+
const uninstallScript = path.join(__dirname, 'uninstall.js');
|
|
174
|
+
|
|
175
|
+
if (!fs.existsSync(uninstallScript)) {
|
|
176
|
+
console.error('Uninstall script not found.');
|
|
177
|
+
process.exit(1);
|
|
178
|
+
}
|
|
179
|
+
|
|
180
|
+
const child = spawn(process.execPath, [uninstallScript, 'uninstall', ...args], {
|
|
181
|
+
stdio: 'inherit',
|
|
182
|
+
cwd: process.cwd()
|
|
183
|
+
});
|
|
184
|
+
|
|
185
|
+
child.on('exit', (code) => {
|
|
186
|
+
process.exit(code || 0);
|
|
187
|
+
});
|
|
188
|
+
}
|
|
189
|
+
|
|
190
|
+
function showHelp() {
|
|
191
|
+
console.log(`
|
|
192
|
+
Cortex Memory Plugin CLI
|
|
193
|
+
|
|
194
|
+
Usage: cortex-memory <command> [options]
|
|
195
|
+
|
|
196
|
+
Commands:
|
|
197
|
+
enable Enable the Cortex Memory plugin
|
|
198
|
+
disable Disable the Cortex Memory plugin (fallback to builtin memory)
|
|
199
|
+
status Show the current plugin status
|
|
200
|
+
uninstall [options] Uninstall the plugin completely
|
|
201
|
+
help Show this help message
|
|
202
|
+
|
|
203
|
+
Uninstall Options:
|
|
204
|
+
--keep-data Keep memory data files (LanceDB, episodic memory, etc.)
|
|
205
|
+
--keep-config Keep plugin entry in openclaw.json
|
|
206
|
+
|
|
207
|
+
Examples:
|
|
208
|
+
cortex-memory enable Enable the plugin
|
|
209
|
+
cortex-memory disable Disable the plugin
|
|
210
|
+
cortex-memory status Check current status
|
|
211
|
+
cortex-memory uninstall Full uninstall (removes everything)
|
|
212
|
+
cortex-memory uninstall --keep-data Keep memory data files
|
|
213
|
+
|
|
214
|
+
Configuration:
|
|
215
|
+
The plugin state is stored in openclaw.json under:
|
|
216
|
+
{
|
|
217
|
+
"plugins": {
|
|
218
|
+
"allow": ["openclaw-cortex-memory"],
|
|
219
|
+
"entries": {
|
|
220
|
+
"openclaw-cortex-memory": {
|
|
221
|
+
"enabled": true/false
|
|
222
|
+
}
|
|
223
|
+
}
|
|
224
|
+
}
|
|
225
|
+
}
|
|
226
|
+
|
|
227
|
+
Fallback Behavior:
|
|
228
|
+
When disabled, the plugin will fall back to OpenClaw's builtin
|
|
229
|
+
memory system if fallbackToBuiltin is true (default).
|
|
230
|
+
`);
|
|
231
|
+
}
|
|
232
|
+
|
|
233
|
+
function main() {
|
|
234
|
+
const args = process.argv.slice(2);
|
|
235
|
+
const command = args[0] || 'help';
|
|
236
|
+
|
|
237
|
+
switch (command) {
|
|
238
|
+
case 'enable':
|
|
239
|
+
enablePlugin();
|
|
240
|
+
break;
|
|
241
|
+
case 'disable':
|
|
242
|
+
disablePlugin();
|
|
243
|
+
break;
|
|
244
|
+
case 'status':
|
|
245
|
+
getStatus();
|
|
246
|
+
break;
|
|
247
|
+
case 'uninstall':
|
|
248
|
+
runUninstall(args.slice(1));
|
|
249
|
+
break;
|
|
250
|
+
case 'help':
|
|
251
|
+
case '--help':
|
|
252
|
+
case '-h':
|
|
253
|
+
showHelp();
|
|
254
|
+
break;
|
|
255
|
+
default:
|
|
256
|
+
console.error(`Unknown command: ${command}`);
|
|
257
|
+
showHelp();
|
|
258
|
+
process.exit(1);
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
|
|
262
|
+
main();
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
const { execSync } = require("child_process");
|
|
2
|
+
const fs = require("fs");
|
|
3
|
+
const path = require("path");
|
|
4
|
+
|
|
5
|
+
const rootDir = path.resolve(__dirname, "..");
|
|
6
|
+
|
|
7
|
+
console.log("[Cortex Memory] Setting up TypeScript runtime...\n");
|
|
8
|
+
|
|
9
|
+
try {
|
|
10
|
+
execSync("npm run build", {
|
|
11
|
+
cwd: rootDir,
|
|
12
|
+
stdio: "inherit",
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const srcManifest = path.join(rootDir, "openclaw.plugin.json");
|
|
16
|
+
const distManifest = path.join(rootDir, "dist", "openclaw.plugin.json");
|
|
17
|
+
if (fs.existsSync(srcManifest)) {
|
|
18
|
+
fs.copyFileSync(srcManifest, distManifest);
|
|
19
|
+
console.log("Plugin manifest copied to dist/");
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
console.log("\n[SUCCESS] TypeScript setup complete");
|
|
23
|
+
} catch (error) {
|
|
24
|
+
console.error("\n[ERROR] TypeScript setup failed");
|
|
25
|
+
console.error(error?.stack || error?.message || String(error));
|
|
26
|
+
process.exit(1);
|
|
27
|
+
}
|