openclaw-cortex-memory 0.1.0-Alpha.3 → 0.1.0-Alpha.30

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 (82) hide show
  1. package/README.md +263 -204
  2. package/SKILL.md +77 -268
  3. package/dist/index.d.ts +92 -22
  4. package/dist/index.d.ts.map +1 -1
  5. package/dist/index.js +1062 -1207
  6. package/dist/index.js.map +1 -1
  7. package/dist/openclaw.plugin.json +384 -15
  8. package/dist/src/dedup/three_stage_deduplicator.d.ts +25 -0
  9. package/dist/src/dedup/three_stage_deduplicator.d.ts.map +1 -0
  10. package/dist/src/dedup/three_stage_deduplicator.js +224 -0
  11. package/dist/src/dedup/three_stage_deduplicator.js.map +1 -0
  12. package/dist/src/engine/memory_engine.d.ts +2 -1
  13. package/dist/src/engine/memory_engine.d.ts.map +1 -1
  14. package/dist/src/engine/ts_engine.d.ts +126 -0
  15. package/dist/src/engine/ts_engine.d.ts.map +1 -1
  16. package/dist/src/engine/ts_engine.js +1145 -44
  17. package/dist/src/engine/ts_engine.js.map +1 -1
  18. package/dist/src/engine/types.d.ts +12 -0
  19. package/dist/src/engine/types.d.ts.map +1 -1
  20. package/dist/src/graph/ontology.d.ts +103 -0
  21. package/dist/src/graph/ontology.d.ts.map +1 -0
  22. package/dist/src/graph/ontology.js +564 -0
  23. package/dist/src/graph/ontology.js.map +1 -0
  24. package/dist/src/net/http_post.d.ts +17 -0
  25. package/dist/src/net/http_post.d.ts.map +1 -0
  26. package/dist/src/net/http_post.js +56 -0
  27. package/dist/src/net/http_post.js.map +1 -0
  28. package/dist/src/quality/llm_output_validator.d.ts +48 -0
  29. package/dist/src/quality/llm_output_validator.d.ts.map +1 -0
  30. package/dist/src/quality/llm_output_validator.js +404 -0
  31. package/dist/src/quality/llm_output_validator.js.map +1 -0
  32. package/dist/src/reflect/reflector.d.ts +7 -0
  33. package/dist/src/reflect/reflector.d.ts.map +1 -1
  34. package/dist/src/reflect/reflector.js +352 -8
  35. package/dist/src/reflect/reflector.js.map +1 -1
  36. package/dist/src/rules/rule_store.d.ts.map +1 -1
  37. package/dist/src/rules/rule_store.js +75 -16
  38. package/dist/src/rules/rule_store.js.map +1 -1
  39. package/dist/src/session/session_end.d.ts +33 -0
  40. package/dist/src/session/session_end.d.ts.map +1 -1
  41. package/dist/src/session/session_end.js +67 -64
  42. package/dist/src/session/session_end.js.map +1 -1
  43. package/dist/src/store/archive_store.d.ts +128 -0
  44. package/dist/src/store/archive_store.d.ts.map +1 -0
  45. package/dist/src/store/archive_store.js +475 -0
  46. package/dist/src/store/archive_store.js.map +1 -0
  47. package/dist/src/store/embedding_utils.d.ts +32 -0
  48. package/dist/src/store/embedding_utils.d.ts.map +1 -0
  49. package/dist/src/store/embedding_utils.js +173 -0
  50. package/dist/src/store/embedding_utils.js.map +1 -0
  51. package/dist/src/store/graph_memory_store.d.ts +44 -0
  52. package/dist/src/store/graph_memory_store.d.ts.map +1 -0
  53. package/dist/src/store/graph_memory_store.js +168 -0
  54. package/dist/src/store/graph_memory_store.js.map +1 -0
  55. package/dist/src/store/read_store.d.ts +86 -0
  56. package/dist/src/store/read_store.d.ts.map +1 -1
  57. package/dist/src/store/read_store.js +1661 -25
  58. package/dist/src/store/read_store.js.map +1 -1
  59. package/dist/src/store/vector_store.d.ts +44 -0
  60. package/dist/src/store/vector_store.d.ts.map +1 -0
  61. package/dist/src/store/vector_store.js +201 -0
  62. package/dist/src/store/vector_store.js.map +1 -0
  63. package/dist/src/store/write_store.d.ts +52 -0
  64. package/dist/src/store/write_store.d.ts.map +1 -1
  65. package/dist/src/store/write_store.js +239 -3
  66. package/dist/src/store/write_store.js.map +1 -1
  67. package/dist/src/sync/session_sync.d.ts +100 -2
  68. package/dist/src/sync/session_sync.d.ts.map +1 -1
  69. package/dist/src/sync/session_sync.js +725 -28
  70. package/dist/src/sync/session_sync.js.map +1 -1
  71. package/dist/src/utils/runtime_env.d.ts +4 -0
  72. package/dist/src/utils/runtime_env.d.ts.map +1 -0
  73. package/dist/src/utils/runtime_env.js +51 -0
  74. package/dist/src/utils/runtime_env.js.map +1 -0
  75. package/openclaw.plugin.json +384 -15
  76. package/package.json +53 -7
  77. package/schema/graph.schema.yaml +175 -0
  78. package/scripts/cli.js +19 -14
  79. package/scripts/repair-memory.js +321 -0
  80. package/scripts/uninstall.js +22 -5
  81. package/index.ts +0 -2142
  82. package/scripts/install.js +0 -27
@@ -1,12 +1,12 @@
1
1
  {
2
2
  "id": "openclaw-cortex-memory",
3
3
  "name": "Cortex Memory",
4
- "version": "0.1.0-Alpha.1",
4
+ "version": "0.1.0-Alpha.30",
5
5
  "description": "Long-term memory system with semantic, episodic, and procedural memory for AI Agents",
6
6
  "main": "dist/index.js",
7
- "author": "OpenClaw Community",
7
+ "author": "deki18",
8
8
  "license": "MIT",
9
- "type": "memory",
9
+ "kind": "memory",
10
10
  "repository": {
11
11
  "type": "git",
12
12
  "url": "https://github.com/deki18/openclaw-cortex-memory"
@@ -18,6 +18,27 @@
18
18
  "channels": false,
19
19
  "memory": true
20
20
  },
21
+ "runtimeRequirements": {
22
+ "requiresCredentials": true,
23
+ "requiresNetwork": true,
24
+ "credentialSources": {
25
+ "env": [
26
+ "EMBEDDING_API_KEY",
27
+ "LLM_API_KEY",
28
+ "RERANKER_API_KEY"
29
+ ],
30
+ "pluginConfig": [
31
+ "embedding.apiKey",
32
+ "llm.apiKey",
33
+ "reranker.apiKey"
34
+ ]
35
+ },
36
+ "externalEndpoints": {
37
+ "embedding": "OpenAI-compatible /embeddings endpoint",
38
+ "llm": "OpenAI-compatible /chat/completions endpoint",
39
+ "reranker": "Reranker /rerank endpoint"
40
+ }
41
+ },
21
42
  "hooks": [
22
43
  "message_received",
23
44
  "session_end"
@@ -56,6 +77,32 @@
56
77
  "type": "array",
57
78
  "description": "Involved entities",
58
79
  "items": {
80
+ "oneOf": [
81
+ {
82
+ "type": "string"
83
+ },
84
+ {
85
+ "type": "object",
86
+ "properties": {
87
+ "id": {
88
+ "type": "string"
89
+ },
90
+ "name": {
91
+ "type": "string"
92
+ },
93
+ "type": {
94
+ "type": "string"
95
+ }
96
+ },
97
+ "additionalProperties": false
98
+ }
99
+ ]
100
+ }
101
+ },
102
+ "entity_types": {
103
+ "type": "object",
104
+ "description": "Entity type map, key is entity name and value is type",
105
+ "additionalProperties": {
59
106
  "type": "string"
60
107
  }
61
108
  },
@@ -67,7 +114,33 @@
67
114
  "type": "array",
68
115
  "description": "Entity relationships",
69
116
  "items": {
70
- "type": "string"
117
+ "oneOf": [
118
+ {
119
+ "type": "string"
120
+ },
121
+ {
122
+ "type": "object",
123
+ "properties": {
124
+ "source": {
125
+ "type": "string"
126
+ },
127
+ "target": {
128
+ "type": "string"
129
+ },
130
+ "type": {
131
+ "type": "string"
132
+ },
133
+ "evidence_span": {
134
+ "type": "string"
135
+ },
136
+ "confidence": {
137
+ "type": "number"
138
+ }
139
+ },
140
+ "required": ["source", "target"],
141
+ "additionalProperties": false
142
+ }
143
+ ]
71
144
  }
72
145
  }
73
146
  },
@@ -84,6 +157,23 @@
84
157
  "entity": {
85
158
  "type": "string",
86
159
  "description": "Entity name"
160
+ },
161
+ "rel": {
162
+ "type": "string",
163
+ "description": "Optional relation type filter"
164
+ },
165
+ "dir": {
166
+ "type": "string",
167
+ "description": "Relation direction filter",
168
+ "enum": ["incoming", "outgoing", "both"]
169
+ },
170
+ "path_to": {
171
+ "type": "string",
172
+ "description": "Find path from entity to this target entity"
173
+ },
174
+ "max_depth": {
175
+ "type": "integer",
176
+ "description": "Path query max depth (2~4)"
87
177
  }
88
178
  },
89
179
  "required": ["entity"],
@@ -140,6 +230,39 @@
140
230
  "additionalProperties": false
141
231
  }
142
232
  },
233
+ {
234
+ "name": "backfill_embeddings",
235
+ "description": "Backfill missing embeddings for active/archive records",
236
+ "parameters": {
237
+ "type": "object",
238
+ "properties": {
239
+ "layer": {
240
+ "type": "string",
241
+ "enum": ["active", "archive", "all"],
242
+ "description": "Target layer to backfill"
243
+ },
244
+ "batch_size": {
245
+ "type": "integer",
246
+ "description": "Batch size per processing window"
247
+ },
248
+ "max_retries": {
249
+ "type": "integer",
250
+ "description": "Max retry count for failed records"
251
+ },
252
+ "retry_failed_only": {
253
+ "type": "boolean",
254
+ "description": "Only retry failed records"
255
+ },
256
+ "rebuild_mode": {
257
+ "type": "string",
258
+ "enum": ["incremental", "vector_only", "full"],
259
+ "description": "Rebuild mode"
260
+ }
261
+ },
262
+ "required": [],
263
+ "additionalProperties": false
264
+ }
265
+ },
143
266
  {
144
267
  "name": "delete_memory",
145
268
  "description": "Delete a memory by ID",
@@ -174,17 +297,6 @@
174
297
  "description": "Enable or disable Cortex Memory plugin",
175
298
  "default": true
176
299
  },
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
300
  "dbPath": {
189
301
  "type": "string",
190
302
  "description": "Path to the memory database directory"
@@ -199,6 +311,17 @@
199
311
  "description": "Automatically trigger reflection periodically",
200
312
  "default": false
201
313
  },
314
+ "autoReflectIntervalMinutes": {
315
+ "type": "integer",
316
+ "description": "Auto reflection scan interval in minutes",
317
+ "default": 30
318
+ },
319
+ "graphQualityMode": {
320
+ "type": "string",
321
+ "description": "Graph extraction quality gate mode",
322
+ "enum": ["off", "warn", "strict"],
323
+ "default": "warn"
324
+ },
202
325
  "embedding": {
203
326
  "type": "object",
204
327
  "description": "Embedding model configuration",
@@ -226,8 +349,19 @@
226
349
  "dimensions": {
227
350
  "type": "integer",
228
351
  "description": "Embedding dimensions"
352
+ },
353
+ "timeoutMs": {
354
+ "type": "integer",
355
+ "description": "Embedding request timeout in milliseconds",
356
+ "default": 20000
357
+ },
358
+ "maxRetries": {
359
+ "type": "integer",
360
+ "description": "Maximum retry attempts for embedding requests",
361
+ "default": 4
229
362
  }
230
363
  },
364
+ "required": ["provider", "model"],
231
365
  "additionalProperties": false
232
366
  },
233
367
  "llm": {
@@ -255,6 +389,7 @@
255
389
  "description": "LLM API base URL (camelCase alias)"
256
390
  }
257
391
  },
392
+ "required": ["provider", "model"],
258
393
  "additionalProperties": false
259
394
  },
260
395
  "reranker": {
@@ -282,12 +417,246 @@
282
417
  "description": "Reranker API base URL (camelCase alias)"
283
418
  }
284
419
  },
420
+ "required": ["model"],
285
421
  "additionalProperties": false
286
422
  },
287
423
  "fallbackToBuiltin": {
288
424
  "type": "boolean",
289
425
  "description": "Fallback to OpenClaw builtin memory when Cortex Memory fails",
290
426
  "default": true
427
+ },
428
+ "readFusion": {
429
+ "type": "object",
430
+ "description": "Post-rerank LLM fusion for multi-route retrieval results",
431
+ "properties": {
432
+ "enabled": {
433
+ "type": "boolean",
434
+ "description": "Enable LLM fusion after rerank",
435
+ "default": true
436
+ },
437
+ "maxCandidates": {
438
+ "type": "integer",
439
+ "description": "Maximum reranked candidates used for fusion",
440
+ "default": 10
441
+ },
442
+ "authoritative": {
443
+ "type": "boolean",
444
+ "description": "Return only fused authoritative memory package to agent",
445
+ "default": true
446
+ },
447
+ "channelWeights": {
448
+ "type": "object",
449
+ "description": "Channel score multiplier overrides",
450
+ "properties": {
451
+ "rules": { "type": "number" },
452
+ "archive": { "type": "number" },
453
+ "vector": { "type": "number" },
454
+ "graph": { "type": "number" }
455
+ },
456
+ "additionalProperties": false
457
+ },
458
+ "channelTopK": {
459
+ "type": "object",
460
+ "description": "Per-channel pre-merge candidate quotas",
461
+ "properties": {
462
+ "rules": { "type": "integer" },
463
+ "archive": { "type": "integer" },
464
+ "vector": { "type": "integer" },
465
+ "graph": { "type": "integer" }
466
+ },
467
+ "additionalProperties": false
468
+ },
469
+ "minLexicalHits": {
470
+ "type": "integer",
471
+ "description": "Ensure lexical-hit coverage in final ranked set"
472
+ },
473
+ "minSemanticHits": {
474
+ "type": "integer",
475
+ "description": "Ensure semantic-hit coverage in final ranked set"
476
+ },
477
+ "lengthNorm": {
478
+ "type": "object",
479
+ "description": "Length normalization settings for semantic score",
480
+ "properties": {
481
+ "enabled": { "type": "boolean", "default": true },
482
+ "pivotChars": { "type": "integer", "default": 1200 },
483
+ "strength": { "type": "number", "default": 0.75 },
484
+ "minFactor": { "type": "number", "default": 0.45 }
485
+ },
486
+ "additionalProperties": false
487
+ }
488
+ },
489
+ "additionalProperties": false
490
+ },
491
+ "vectorChunking": {
492
+ "type": "object",
493
+ "description": "Vector chunking controls for active/archive full-text chunk embeddings",
494
+ "properties": {
495
+ "chunkSize": {
496
+ "type": "integer",
497
+ "description": "Chunk size in characters",
498
+ "default": 600
499
+ },
500
+ "chunkOverlap": {
501
+ "type": "integer",
502
+ "description": "Chunk overlap in characters",
503
+ "default": 100
504
+ },
505
+ "evidenceMaxChunks": {
506
+ "type": "integer",
507
+ "description": "Maximum evidence chunks per archive event",
508
+ "default": 2
509
+ }
510
+ },
511
+ "additionalProperties": false
512
+ },
513
+ "writePolicy": {
514
+ "type": "object",
515
+ "description": "Write-path quality thresholds and limits",
516
+ "properties": {
517
+ "archiveMinConfidence": {
518
+ "type": "number",
519
+ "description": "Minimum confidence for archiving events",
520
+ "default": 0.35
521
+ },
522
+ "archiveMinQualityScore": {
523
+ "type": "number",
524
+ "description": "Minimum quality score for archive events",
525
+ "default": 0.4
526
+ },
527
+ "activeMinQualityScore": {
528
+ "type": "number",
529
+ "description": "Minimum quality score for active records",
530
+ "default": 0.45
531
+ },
532
+ "activeDedupTailLines": {
533
+ "type": "integer",
534
+ "description": "Active-layer dedup tail line window",
535
+ "default": 200
536
+ },
537
+ "activeTextMaxChars": {
538
+ "type": "integer",
539
+ "description": "Maximum chars for active text payload",
540
+ "default": 4000
541
+ },
542
+ "archiveSourceTextMaxChars": {
543
+ "type": "integer",
544
+ "description": "Maximum chars for archive source_text payload",
545
+ "default": 8000
546
+ }
547
+ },
548
+ "additionalProperties": false
549
+ },
550
+ "memoryDecay": {
551
+ "type": "object",
552
+ "description": "Time-decay controls for retrieval ranking by event_type",
553
+ "properties": {
554
+ "enabled": {
555
+ "type": "boolean",
556
+ "description": "Enable event-type half-life decay in retrieval ranking",
557
+ "default": true
558
+ },
559
+ "minFloor": {
560
+ "type": "number",
561
+ "description": "Minimum decay factor floor in [0,1]",
562
+ "default": 0.15
563
+ },
564
+ "defaultHalfLifeDays": {
565
+ "type": "number",
566
+ "description": "Default half-life in days for unconfigured event types",
567
+ "default": 90
568
+ },
569
+ "halfLifeByEventType": {
570
+ "type": "object",
571
+ "description": "Half-life days overrides by event_type",
572
+ "additionalProperties": {
573
+ "type": "number"
574
+ }
575
+ },
576
+ "antiDecay": {
577
+ "type": "object",
578
+ "description": "Hit-frequency anti-decay controls",
579
+ "properties": {
580
+ "enabled": {
581
+ "type": "boolean",
582
+ "description": "Enable anti-decay boost for frequently hit memories",
583
+ "default": true
584
+ },
585
+ "maxBoost": {
586
+ "type": "number",
587
+ "description": "Maximum multiplicative anti-decay boost (>=1)",
588
+ "default": 1.6
589
+ },
590
+ "hitWeight": {
591
+ "type": "number",
592
+ "description": "Hit count to boost conversion weight",
593
+ "default": 0.08
594
+ },
595
+ "recentWindowDays": {
596
+ "type": "number",
597
+ "description": "Recent hit window in days for freshness contribution",
598
+ "default": 30
599
+ }
600
+ },
601
+ "additionalProperties": false
602
+ }
603
+ },
604
+ "additionalProperties": false
605
+ },
606
+ "readTuning": {
607
+ "type": "object",
608
+ "description": "Read-path ranking and recency tuning",
609
+ "properties": {
610
+ "scoring": {
611
+ "type": "object",
612
+ "properties": {
613
+ "lexicalWeight": { "type": "number", "default": 0.2 },
614
+ "bm25Scale": { "type": "number", "default": 2 },
615
+ "semanticWeight": { "type": "number", "default": 0.3 },
616
+ "recencyWeight": { "type": "number", "default": 0.1 },
617
+ "qualityWeight": { "type": "number", "default": 0.15 },
618
+ "typeMatchWeight": { "type": "number", "default": 0.15 },
619
+ "graphMatchWeight": { "type": "number", "default": 0.1 }
620
+ },
621
+ "additionalProperties": false
622
+ },
623
+ "rrf": {
624
+ "type": "object",
625
+ "properties": {
626
+ "k": { "type": "integer", "default": 60 },
627
+ "weight": { "type": "number", "default": 1.5 }
628
+ },
629
+ "additionalProperties": false
630
+ },
631
+ "recency": {
632
+ "type": "object",
633
+ "properties": {
634
+ "buckets": {
635
+ "type": "array",
636
+ "items": {
637
+ "type": "object",
638
+ "properties": {
639
+ "maxAgeHours": { "type": "number" },
640
+ "score": { "type": "number" },
641
+ "bonus": { "type": "number" }
642
+ },
643
+ "required": ["maxAgeHours", "score", "bonus"],
644
+ "additionalProperties": false
645
+ }
646
+ }
647
+ },
648
+ "additionalProperties": false
649
+ },
650
+ "autoContext": {
651
+ "type": "object",
652
+ "properties": {
653
+ "queryMaxChars": { "type": "integer", "default": 80 },
654
+ "lightweightSearch": { "type": "boolean", "default": true }
655
+ },
656
+ "additionalProperties": false
657
+ }
658
+ },
659
+ "additionalProperties": false
291
660
  }
292
661
  },
293
662
  "additionalProperties": false
@@ -0,0 +1,25 @@
1
+ interface LoggerLike {
2
+ debug: (message: string, ...args: unknown[]) => void;
3
+ info: (message: string, ...args: unknown[]) => void;
4
+ warn: (message: string, ...args: unknown[]) => void;
5
+ }
6
+ interface DedupInput {
7
+ id: string;
8
+ summary: string;
9
+ embedding?: number[];
10
+ }
11
+ interface DedupResult {
12
+ duplicate: boolean;
13
+ stage?: "simhash" | "minhash" | "vector";
14
+ matchedId?: string;
15
+ }
16
+ interface DeduplicatorOptions {
17
+ memoryRoot: string;
18
+ logger: LoggerLike;
19
+ }
20
+ export declare function createThreeStageDeduplicator(options: DeduplicatorOptions): {
21
+ check(input: DedupInput): DedupResult;
22
+ append(input: DedupInput): void;
23
+ };
24
+ export {};
25
+ //# sourceMappingURL=three_stage_deduplicator.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"three_stage_deduplicator.d.ts","sourceRoot":"","sources":["../../../src/dedup/three_stage_deduplicator.ts"],"names":[],"mappings":"AAIA,UAAU,UAAU;IAClB,KAAK,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACrD,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;IACpD,IAAI,EAAE,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,IAAI,EAAE,OAAO,EAAE,KAAK,IAAI,CAAC;CACrD;AAeD,UAAU,UAAU;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,EAAE,CAAC;CACtB;AAED,UAAU,WAAW;IACnB,SAAS,EAAE,OAAO,CAAC;IACnB,KAAK,CAAC,EAAE,SAAS,GAAG,SAAS,GAAG,QAAQ,CAAC;IACzC,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,UAAU,mBAAmB;IAC3B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,UAAU,CAAC;CACpB;AAgJD,wBAAgB,4BAA4B,CAAC,OAAO,EAAE,mBAAmB,GAAG;IAC1E,KAAK,CAAC,KAAK,EAAE,UAAU,GAAG,WAAW,CAAC;IACtC,MAAM,CAAC,KAAK,EAAE,UAAU,GAAG,IAAI,CAAC;CACjC,CAsDA"}