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.
Files changed (49) hide show
  1. package/README.md +198 -0
  2. package/SKILL.md +263 -0
  3. package/dist/index.d.ts +90 -0
  4. package/dist/index.d.ts.map +1 -0
  5. package/dist/index.js +1871 -0
  6. package/dist/index.js.map +1 -0
  7. package/dist/openclaw.plugin.json +295 -0
  8. package/dist/src/engine/memory_engine.d.ts +20 -0
  9. package/dist/src/engine/memory_engine.d.ts.map +1 -0
  10. package/dist/src/engine/memory_engine.js +3 -0
  11. package/dist/src/engine/memory_engine.js.map +1 -0
  12. package/dist/src/engine/ts_engine.d.ts +69 -0
  13. package/dist/src/engine/ts_engine.d.ts.map +1 -0
  14. package/dist/src/engine/ts_engine.js +390 -0
  15. package/dist/src/engine/ts_engine.js.map +1 -0
  16. package/dist/src/engine/types.d.ts +53 -0
  17. package/dist/src/engine/types.d.ts.map +1 -0
  18. package/dist/src/engine/types.js +3 -0
  19. package/dist/src/engine/types.js.map +1 -0
  20. package/dist/src/reflect/reflector.d.ts +32 -0
  21. package/dist/src/reflect/reflector.d.ts.map +1 -0
  22. package/dist/src/reflect/reflector.js +124 -0
  23. package/dist/src/reflect/reflector.js.map +1 -0
  24. package/dist/src/rules/rule_store.d.ts +22 -0
  25. package/dist/src/rules/rule_store.d.ts.map +1 -0
  26. package/dist/src/rules/rule_store.js +102 -0
  27. package/dist/src/rules/rule_store.js.map +1 -0
  28. package/dist/src/session/session_end.d.ts +30 -0
  29. package/dist/src/session/session_end.d.ts.map +1 -0
  30. package/dist/src/session/session_end.js +209 -0
  31. package/dist/src/session/session_end.js.map +1 -0
  32. package/dist/src/store/read_store.d.ts +44 -0
  33. package/dist/src/store/read_store.d.ts.map +1 -0
  34. package/dist/src/store/read_store.js +239 -0
  35. package/dist/src/store/read_store.js.map +1 -0
  36. package/dist/src/store/write_store.d.ts +31 -0
  37. package/dist/src/store/write_store.d.ts.map +1 -0
  38. package/dist/src/store/write_store.js +138 -0
  39. package/dist/src/store/write_store.js.map +1 -0
  40. package/dist/src/sync/session_sync.d.ts +28 -0
  41. package/dist/src/sync/session_sync.d.ts.map +1 -0
  42. package/dist/src/sync/session_sync.js +214 -0
  43. package/dist/src/sync/session_sync.js.map +1 -0
  44. package/index.ts +2071 -0
  45. package/openclaw.plugin.json +295 -0
  46. package/package.json +55 -0
  47. package/scripts/cli.js +262 -0
  48. package/scripts/install.js +27 -0
  49. package/scripts/uninstall.js +212 -0
@@ -0,0 +1,212 @@
1
+ #!/usr/bin/env node
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ const PLUGIN_NAME = 'openclaw-cortex-memory';
7
+
8
+ function findProjectRoot() {
9
+ let current = __dirname;
10
+ while (current !== path.dirname(current)) {
11
+ if (fs.existsSync(path.join(current, 'package.json')) && fs.existsSync(path.join(current, 'openclaw.plugin.json'))) {
12
+ return current;
13
+ }
14
+ current = path.dirname(current);
15
+ }
16
+ return __dirname;
17
+ }
18
+
19
+ function findOpenClawConfig() {
20
+ const possiblePaths = [
21
+ path.join(process.cwd(), 'openclaw.json'),
22
+ path.join(process.env.USERPROFILE || process.env.HOME || '', '.openclaw', 'openclaw.json'),
23
+ path.join(process.env.OPENCLAW_BASE_PATH || '', 'openclaw.json'),
24
+ ];
25
+
26
+ for (const p of possiblePaths) {
27
+ if (fs.existsSync(p)) {
28
+ return p;
29
+ }
30
+ }
31
+ return null;
32
+ }
33
+
34
+ function removeVenv(projectRoot) {
35
+ const venvPath = path.join(projectRoot, 'venv');
36
+ if (fs.existsSync(venvPath)) {
37
+ console.log(`Removing virtual environment: ${venvPath}`);
38
+ try {
39
+ fs.rmSync(venvPath, { recursive: true, force: true });
40
+ console.log('Virtual environment removed.');
41
+ } catch (e) {
42
+ console.error(`Failed to remove venv: ${e.message}`);
43
+ }
44
+ } else {
45
+ console.log('No virtual environment found.');
46
+ }
47
+ }
48
+
49
+ function removeBuildArtifacts(projectRoot) {
50
+ const distPath = path.join(projectRoot, 'dist');
51
+ const nodeModulesPath = path.join(projectRoot, 'node_modules');
52
+
53
+ if (fs.existsSync(distPath)) {
54
+ console.log(`Removing dist: ${distPath}`);
55
+ try {
56
+ fs.rmSync(distPath, { recursive: true, force: true });
57
+ } catch (e) {
58
+ console.error(`Failed to remove dist: ${e.message}`);
59
+ }
60
+ }
61
+
62
+ if (fs.existsSync(nodeModulesPath)) {
63
+ console.log(`Removing node_modules: ${nodeModulesPath}`);
64
+ try {
65
+ fs.rmSync(nodeModulesPath, { recursive: true, force: true });
66
+ } catch (e) {
67
+ console.error(`Failed to remove node_modules: ${e.message}`);
68
+ }
69
+ }
70
+
71
+ console.log('Build artifacts removed.');
72
+ }
73
+
74
+ function removeDataFiles(projectRoot, keepData) {
75
+ if (keepData) {
76
+ console.log('Keeping data files (--keep-data flag).');
77
+ return;
78
+ }
79
+
80
+ const dataPaths = [
81
+ path.join(projectRoot, 'data', 'memory'),
82
+ path.join(projectRoot, 'data', 'lancedb_store'),
83
+ ];
84
+
85
+ const homeDataPaths = [
86
+ path.join(process.env.USERPROFILE || process.env.HOME || '', '.openclaw', 'agents', 'main', 'lancedb_store'),
87
+ path.join(process.env.USERPROFILE || process.env.HOME || '', '.openclaw', 'episodic_memory.jsonl'),
88
+ path.join(process.env.USERPROFILE || process.env.HOME || '', '.openclaw', 'memory_graph.json'),
89
+ ];
90
+
91
+ for (const dataPath of [...dataPaths, ...homeDataPaths]) {
92
+ if (fs.existsSync(dataPath)) {
93
+ console.log(`Removing data: ${dataPath}`);
94
+ try {
95
+ fs.rmSync(dataPath, { recursive: true, force: true });
96
+ } catch (e) {
97
+ console.error(`Failed to remove ${dataPath}: ${e.message}`);
98
+ }
99
+ }
100
+ }
101
+
102
+ console.log('Data files removed.');
103
+ }
104
+
105
+ function removeFromConfig() {
106
+ const configPath = findOpenClawConfig();
107
+
108
+ if (!configPath) {
109
+ console.log('No OpenClaw config file found.');
110
+ return;
111
+ }
112
+
113
+ try {
114
+ const content = fs.readFileSync(configPath, 'utf-8');
115
+ const config = JSON.parse(content);
116
+
117
+ if (config.plugins?.entries?.[PLUGIN_NAME]) {
118
+ delete config.plugins.entries[PLUGIN_NAME];
119
+
120
+ if (config.plugins.slots?.memory === PLUGIN_NAME) {
121
+ delete config.plugins.slots.memory;
122
+ }
123
+
124
+ fs.writeFileSync(configPath, JSON.stringify(config, null, 2));
125
+ console.log(`Removed plugin from config: ${configPath}`);
126
+ } else {
127
+ console.log('Plugin not found in config.');
128
+ }
129
+ } catch (e) {
130
+ console.error(`Failed to update config: ${e.message}`);
131
+ }
132
+ }
133
+
134
+ function showHelp() {
135
+ console.log(`
136
+ Cortex Memory Plugin Uninstaller
137
+
138
+ Usage: cortex-memory uninstall [options]
139
+
140
+ Options:
141
+ --keep-data Keep memory data files (LanceDB, episodic memory, etc.)
142
+ --keep-config Keep plugin entry in openclaw.json
143
+ --help Show this help message
144
+
145
+ Examples:
146
+ cortex-memory uninstall # Full uninstall (removes everything)
147
+ cortex-memory uninstall --keep-data # Keep memory data files
148
+
149
+ This will:
150
+ 1. Remove local virtual environment folder (if exists)
151
+ 2. Remove node_modules and build artifacts
152
+ 3. Remove memory data files (unless --keep-data)
153
+ 4. Remove plugin from openclaw.json (unless --keep-config)
154
+ `);
155
+ }
156
+
157
+ function uninstall(args) {
158
+ const keepData = args.includes('--keep-data');
159
+ const keepConfig = args.includes('--keep-config');
160
+
161
+ console.log('='.repeat(50));
162
+ console.log('Cortex Memory Plugin Uninstaller');
163
+ console.log('='.repeat(50));
164
+ console.log('');
165
+
166
+ const projectRoot = findProjectRoot();
167
+ console.log(`Project root: ${projectRoot}`);
168
+ console.log('');
169
+
170
+ removeVenv(projectRoot);
171
+
172
+ removeBuildArtifacts(projectRoot);
173
+
174
+ removeDataFiles(projectRoot, keepData);
175
+
176
+ if (!keepConfig) {
177
+ removeFromConfig();
178
+ } else {
179
+ console.log('Keeping config entry (--keep-config flag).');
180
+ }
181
+
182
+ console.log('');
183
+ console.log('='.repeat(50));
184
+ console.log('Uninstall complete!');
185
+ console.log('='.repeat(50));
186
+
187
+ if (keepData) {
188
+ console.log('\nNote: Memory data files were preserved. To remove them manually:');
189
+ console.log(` - ${path.join(process.env.USERPROFILE || process.env.HOME || '', '.openclaw', 'agents', 'main', 'lancedb_store')}`);
190
+ }
191
+
192
+ console.log('\nTo reinstall the plugin:');
193
+ console.log(' cd /path/to/openclaw-cortex-memory/plugin');
194
+ console.log(' npm install');
195
+ }
196
+
197
+ function main() {
198
+ const args = process.argv.slice(2);
199
+ const command = args[0];
200
+
201
+ if (command === 'uninstall') {
202
+ uninstall(args.slice(1));
203
+ } else if (command === '--help' || command === '-h' || command === 'help') {
204
+ showHelp();
205
+ } else {
206
+ console.log(`Unknown command: ${command}`);
207
+ console.log('Run "cortex-memory uninstall --help" for usage information.');
208
+ process.exit(1);
209
+ }
210
+ }
211
+
212
+ main();