openclaw-cortex-memory 0.1.0-Alpha.3 → 0.1.0-Alpha.31
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/LICENSE +21 -0
- package/README.md +296 -203
- package/SIGNATURE.md +7 -0
- package/SKILL.md +92 -268
- package/dist/index.d.ts +100 -22
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1249 -1252
- package/dist/index.js.map +1 -1
- package/dist/openclaw.plugin.json +501 -16
- package/dist/src/dedup/three_stage_deduplicator.d.ts +25 -0
- package/dist/src/dedup/three_stage_deduplicator.d.ts.map +1 -0
- package/dist/src/dedup/three_stage_deduplicator.js +224 -0
- package/dist/src/dedup/three_stage_deduplicator.js.map +1 -0
- package/dist/src/engine/memory_engine.d.ts +6 -1
- package/dist/src/engine/memory_engine.d.ts.map +1 -1
- package/dist/src/engine/ts_engine.d.ts +242 -0
- package/dist/src/engine/ts_engine.d.ts.map +1 -1
- package/dist/src/engine/ts_engine.js +1468 -52
- package/dist/src/engine/ts_engine.js.map +1 -1
- package/dist/src/engine/types.d.ts +29 -0
- package/dist/src/engine/types.d.ts.map +1 -1
- package/dist/src/graph/ontology.d.ts +125 -0
- package/dist/src/graph/ontology.d.ts.map +1 -0
- package/dist/src/graph/ontology.js +1237 -0
- package/dist/src/graph/ontology.js.map +1 -0
- package/dist/src/net/http_post.d.ts +17 -0
- package/dist/src/net/http_post.d.ts.map +1 -0
- package/dist/src/net/http_post.js +56 -0
- package/dist/src/net/http_post.js.map +1 -0
- package/dist/src/quality/llm_output_validator.d.ts +66 -0
- package/dist/src/quality/llm_output_validator.d.ts.map +1 -0
- package/dist/src/quality/llm_output_validator.js +659 -0
- package/dist/src/quality/llm_output_validator.js.map +1 -0
- package/dist/src/reflect/reflector.d.ts +7 -0
- package/dist/src/reflect/reflector.d.ts.map +1 -1
- package/dist/src/reflect/reflector.js +352 -8
- package/dist/src/reflect/reflector.js.map +1 -1
- package/dist/src/rules/rule_store.d.ts.map +1 -1
- package/dist/src/rules/rule_store.js +75 -16
- package/dist/src/rules/rule_store.js.map +1 -1
- package/dist/src/session/session_end.d.ts +33 -0
- package/dist/src/session/session_end.d.ts.map +1 -1
- package/dist/src/session/session_end.js +67 -64
- package/dist/src/session/session_end.js.map +1 -1
- package/dist/src/store/archive_store.d.ts +136 -0
- package/dist/src/store/archive_store.d.ts.map +1 -0
- package/dist/src/store/archive_store.js +635 -0
- package/dist/src/store/archive_store.js.map +1 -0
- package/dist/src/store/embedding_utils.d.ts +32 -0
- package/dist/src/store/embedding_utils.d.ts.map +1 -0
- package/dist/src/store/embedding_utils.js +173 -0
- package/dist/src/store/embedding_utils.js.map +1 -0
- package/dist/src/store/graph_memory_store.d.ts +114 -0
- package/dist/src/store/graph_memory_store.d.ts.map +1 -0
- package/dist/src/store/graph_memory_store.js +841 -0
- package/dist/src/store/graph_memory_store.js.map +1 -0
- package/dist/src/store/read_store.d.ts +89 -0
- package/dist/src/store/read_store.d.ts.map +1 -1
- package/dist/src/store/read_store.js +2459 -28
- package/dist/src/store/read_store.js.map +1 -1
- package/dist/src/store/vector_store.d.ts +45 -0
- package/dist/src/store/vector_store.d.ts.map +1 -0
- package/dist/src/store/vector_store.js +202 -0
- package/dist/src/store/vector_store.js.map +1 -0
- package/dist/src/store/write_store.d.ts +54 -0
- package/dist/src/store/write_store.d.ts.map +1 -1
- package/dist/src/store/write_store.js +284 -6
- package/dist/src/store/write_store.js.map +1 -1
- package/dist/src/sync/session_sync.d.ts +119 -2
- package/dist/src/sync/session_sync.d.ts.map +1 -1
- package/dist/src/sync/session_sync.js +2377 -31
- package/dist/src/sync/session_sync.js.map +1 -1
- package/dist/src/utils/runtime_env.d.ts +4 -0
- package/dist/src/utils/runtime_env.d.ts.map +1 -0
- package/dist/src/utils/runtime_env.js +51 -0
- package/dist/src/utils/runtime_env.js.map +1 -0
- package/dist/src/wiki/wiki_linter.d.ts +25 -0
- package/dist/src/wiki/wiki_linter.d.ts.map +1 -0
- package/dist/src/wiki/wiki_linter.js +268 -0
- package/dist/src/wiki/wiki_linter.js.map +1 -0
- package/dist/src/wiki/wiki_logger.d.ts +10 -0
- package/dist/src/wiki/wiki_logger.d.ts.map +1 -0
- package/dist/src/wiki/wiki_logger.js +78 -0
- package/dist/src/wiki/wiki_logger.js.map +1 -0
- package/dist/src/wiki/wiki_maintainer.d.ts +36 -0
- package/dist/src/wiki/wiki_maintainer.d.ts.map +1 -0
- package/dist/src/wiki/wiki_maintainer.js +38 -0
- package/dist/src/wiki/wiki_maintainer.js.map +1 -0
- package/dist/src/wiki/wiki_projector.d.ts +33 -0
- package/dist/src/wiki/wiki_projector.d.ts.map +1 -0
- package/dist/src/wiki/wiki_projector.js +633 -0
- package/dist/src/wiki/wiki_projector.js.map +1 -0
- package/dist/src/wiki/wiki_queue.d.ts +29 -0
- package/dist/src/wiki/wiki_queue.d.ts.map +1 -0
- package/dist/src/wiki/wiki_queue.js +137 -0
- package/dist/src/wiki/wiki_queue.js.map +1 -0
- package/openclaw.plugin.json +501 -16
- package/package.json +58 -7
- package/schema/graph.schema.yaml +330 -0
- package/scripts/cli.js +19 -14
- package/scripts/repair-memory.js +321 -0
- package/scripts/uninstall.js +22 -5
- package/skills/cortex-memory/SKILL.md +49 -0
- package/skills/cortex-memory/references/agent-manual.md +115 -0
- package/skills/cortex-memory/references/configuration.md +92 -0
- package/skills/cortex-memory/references/publish-checklist.md +46 -0
- package/skills/cortex-memory/references/system-prompt-template.md +27 -0
- package/skills/cortex-memory/references/tools.md +181 -0
- package/skills/cortex-memory/scripts/smoke-check.ps1 +56 -0
- package/index.ts +0 -2142
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
# Cortex Memory 系统提示词模板
|
|
2
|
+
|
|
3
|
+
可直接粘贴到 Agent 系统提示词中:
|
|
4
|
+
|
|
5
|
+
## Cortex Memory 记忆插件使用规则(核心规则,不允许删除)
|
|
6
|
+
|
|
7
|
+
你已接入 Cortex Memory。必须遵循以下规则:
|
|
8
|
+
|
|
9
|
+
1. 禁止臆造历史事实;凡涉及历史对话、用户偏好、项目既有决策,先检索再回答。
|
|
10
|
+
2. 单个任务内避免重复写入:`store_event` / `reflect_memory` 仅在关键节点或收尾触发一次。
|
|
11
|
+
3. 用户询问历史信息、偏好、项目上下文时:先调用 `search_memory`,再回答。
|
|
12
|
+
4. 需要当前会话热上下文时:调用 `get_hot_context`。
|
|
13
|
+
5. 需要自动召回相关记忆时:调用 `get_auto_context`。
|
|
14
|
+
6. 需要实体关系、依赖链路或路径关系时:调用 `query_graph`。
|
|
15
|
+
7. 仅在“重要事项已结束且结论明确”后调用 `store_event` 记录结果(过程进行中不频繁记录)。
|
|
16
|
+
8. 当任务经历“失败 -> 调整 -> 成功”时:先用 `store_event` 记录失败原因与成功方案,再调用 `reflect_memory` 沉淀可复用规则。
|
|
17
|
+
9. 需要导入历史会话时:调用 `sync_memory`。
|
|
18
|
+
10. 当 `diagnostics` 显示 active/archive 有未向量化记录,或迁移后需重建向量层时:调用 `backfill_embeddings`(按需选择 `incremental` / `vector_only` / `full`)。
|
|
19
|
+
11. 出现配置校验失败、记忆读写异常、检索结果异常或数据目录问题时:优先调用 `diagnostics`。
|
|
20
|
+
12. 仅在用户明确要求删除记忆,且已确认 `memory_id` 时,才调用 `delete_memory`;禁止在未确认情况下自动删除。
|
|
21
|
+
13. 任一工具调用失败时,先重试一次;仍失败则明确告知用户,并基于当前可得上下文继续完成任务。
|
|
22
|
+
14. 调用任意 Cortex Memory 工具前,先确认当前运行环境可见该工具;若工具不可见,必须立即报告“当前 lane 不可用”,不得虚构执行结果。
|
|
23
|
+
15. `sync_memory` 属于关键路径任务:执行前后应避免并发重复触发;若已有同任务进行中,复用当前结果或等待完成。
|
|
24
|
+
16. 当用户明确请求 Cortex Memory 任务(如 `sync_memory` / `search_memory` / `store_event`)时,禁止切换到无关流程(如心跳巡检、日报、闲聊任务);若被系统任务打断,先完成用户请求再处理后台任务。
|
|
25
|
+
17. 当 `query_graph` 返回 `conflict_hint` 时,不得静默覆盖冲突事实;先调用 `list_graph_conflicts` 并与用户确认,再调用 `resolve_graph_conflict`。
|
|
26
|
+
18. 需要说明图谱状态分布、冲突生命周期或可视化快照时,调用 `export_graph_view`。
|
|
27
|
+
19. 需要排查图谱与 Wiki 投影一致性时,调用 `lint_memory_wiki` 并按 `next_action` 执行修复。
|
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
# Cortex Memory Tool Reference
|
|
2
|
+
|
|
3
|
+
## Retrieval
|
|
4
|
+
|
|
5
|
+
### `search_memory`
|
|
6
|
+
|
|
7
|
+
Use for semantic recall of historical records.
|
|
8
|
+
|
|
9
|
+
Input:
|
|
10
|
+
|
|
11
|
+
```json
|
|
12
|
+
{
|
|
13
|
+
"query": "What did we decide about memory decay?",
|
|
14
|
+
"top_k": 8
|
|
15
|
+
}
|
|
16
|
+
```
|
|
17
|
+
|
|
18
|
+
### `query_graph`
|
|
19
|
+
|
|
20
|
+
Use for entity relationship lookup and path traversal.
|
|
21
|
+
|
|
22
|
+
Input:
|
|
23
|
+
|
|
24
|
+
```json
|
|
25
|
+
{
|
|
26
|
+
"entity": "memoryDecay",
|
|
27
|
+
"rel": "depends_on",
|
|
28
|
+
"dir": "both",
|
|
29
|
+
"path_to": "readFusion",
|
|
30
|
+
"max_depth": 3
|
|
31
|
+
}
|
|
32
|
+
```
|
|
33
|
+
|
|
34
|
+
Typical response highlights:
|
|
35
|
+
- `edges[].fact_status` (`active/pending_conflict/superseded/rejected`)
|
|
36
|
+
- `wiki_refs`
|
|
37
|
+
- `evidence_ids`
|
|
38
|
+
- `conflict_hint` (when conflict facts are hit)
|
|
39
|
+
|
|
40
|
+
### `export_graph_view`
|
|
41
|
+
|
|
42
|
+
Use for status-aware graph snapshot export and wiki graph projection files.
|
|
43
|
+
|
|
44
|
+
Input:
|
|
45
|
+
|
|
46
|
+
```json
|
|
47
|
+
{
|
|
48
|
+
"write_snapshot": true
|
|
49
|
+
}
|
|
50
|
+
```
|
|
51
|
+
|
|
52
|
+
### `lint_memory_wiki`
|
|
53
|
+
|
|
54
|
+
Run wiki + graph consistency lint checks and return structured repair actions.
|
|
55
|
+
|
|
56
|
+
Input:
|
|
57
|
+
|
|
58
|
+
```json
|
|
59
|
+
{}
|
|
60
|
+
```
|
|
61
|
+
|
|
62
|
+
## Conflict Governance
|
|
63
|
+
|
|
64
|
+
### `list_graph_conflicts`
|
|
65
|
+
|
|
66
|
+
List pending/handled conflicts that need confirmation.
|
|
67
|
+
|
|
68
|
+
Input:
|
|
69
|
+
|
|
70
|
+
```json
|
|
71
|
+
{
|
|
72
|
+
"status": "pending",
|
|
73
|
+
"limit": 20
|
|
74
|
+
}
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
### `resolve_graph_conflict`
|
|
78
|
+
|
|
79
|
+
Accept or reject a conflict candidate.
|
|
80
|
+
|
|
81
|
+
Input:
|
|
82
|
+
|
|
83
|
+
```json
|
|
84
|
+
{
|
|
85
|
+
"conflict_id": "gcf_xxx",
|
|
86
|
+
"action": "accept",
|
|
87
|
+
"note": "accepted with user confirmation"
|
|
88
|
+
}
|
|
89
|
+
```
|
|
90
|
+
|
|
91
|
+
## Persistence
|
|
92
|
+
|
|
93
|
+
### `store_event`
|
|
94
|
+
|
|
95
|
+
Persist durable decisions, outcomes, and entity relations.
|
|
96
|
+
|
|
97
|
+
Input:
|
|
98
|
+
|
|
99
|
+
```json
|
|
100
|
+
{
|
|
101
|
+
"summary": "Enabled strict graph quality mode for production.",
|
|
102
|
+
"entities": ["graphQualityMode", "production"],
|
|
103
|
+
"entity_types": {
|
|
104
|
+
"graphQualityMode": "config",
|
|
105
|
+
"production": "environment"
|
|
106
|
+
},
|
|
107
|
+
"outcome": "Reduced noisy relations in graph reads.",
|
|
108
|
+
"relations": [
|
|
109
|
+
{
|
|
110
|
+
"source": "graphQualityMode",
|
|
111
|
+
"target": "production",
|
|
112
|
+
"type": "applied_to",
|
|
113
|
+
"confidence": 0.92
|
|
114
|
+
}
|
|
115
|
+
]
|
|
116
|
+
}
|
|
117
|
+
```
|
|
118
|
+
|
|
119
|
+
### `delete_memory`
|
|
120
|
+
|
|
121
|
+
Delete a specific record by id.
|
|
122
|
+
|
|
123
|
+
Input:
|
|
124
|
+
|
|
125
|
+
```json
|
|
126
|
+
{
|
|
127
|
+
"memory_id": "mem_123"
|
|
128
|
+
}
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
## Session Context
|
|
132
|
+
|
|
133
|
+
### `get_hot_context`
|
|
134
|
+
|
|
135
|
+
Read currently hot records.
|
|
136
|
+
|
|
137
|
+
```json
|
|
138
|
+
{
|
|
139
|
+
"limit": 10
|
|
140
|
+
}
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
### `get_auto_context`
|
|
144
|
+
|
|
145
|
+
Read auto-selected context from recent messages.
|
|
146
|
+
|
|
147
|
+
```json
|
|
148
|
+
{
|
|
149
|
+
"include_hot": true
|
|
150
|
+
}
|
|
151
|
+
```
|
|
152
|
+
|
|
153
|
+
## Maintenance
|
|
154
|
+
|
|
155
|
+
### `sync_memory`
|
|
156
|
+
|
|
157
|
+
Import historical session data into memory.
|
|
158
|
+
|
|
159
|
+
### `reflect_memory`
|
|
160
|
+
|
|
161
|
+
Promote events into reusable rules.
|
|
162
|
+
|
|
163
|
+
### `backfill_embeddings`
|
|
164
|
+
|
|
165
|
+
Repair or rebuild missing vectors.
|
|
166
|
+
|
|
167
|
+
Input:
|
|
168
|
+
|
|
169
|
+
```json
|
|
170
|
+
{
|
|
171
|
+
"layer": "all",
|
|
172
|
+
"batch_size": 64,
|
|
173
|
+
"max_retries": 3,
|
|
174
|
+
"retry_failed_only": false,
|
|
175
|
+
"rebuild_mode": "incremental"
|
|
176
|
+
}
|
|
177
|
+
```
|
|
178
|
+
|
|
179
|
+
### `diagnostics`
|
|
180
|
+
|
|
181
|
+
Check model connectivity, registry status, and memory health.
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
param(
|
|
2
|
+
[switch]$Json
|
|
3
|
+
)
|
|
4
|
+
|
|
5
|
+
$requiredEnv = @(
|
|
6
|
+
"EMBEDDING_API_KEY",
|
|
7
|
+
"LLM_API_KEY",
|
|
8
|
+
"RERANKER_API_KEY"
|
|
9
|
+
)
|
|
10
|
+
|
|
11
|
+
$envStatus = @()
|
|
12
|
+
foreach ($name in $requiredEnv) {
|
|
13
|
+
$value = [Environment]::GetEnvironmentVariable($name)
|
|
14
|
+
$envStatus += [PSCustomObject]@{
|
|
15
|
+
name = $name
|
|
16
|
+
present = -not [string]::IsNullOrWhiteSpace($value)
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
$defaultConfigPath = Join-Path $HOME ".openclaw/openclaw.json"
|
|
21
|
+
$configPath = if ($env:OPENCLAW_CONFIG_PATH) { $env:OPENCLAW_CONFIG_PATH } else { $defaultConfigPath }
|
|
22
|
+
$configExists = Test-Path -LiteralPath $configPath
|
|
23
|
+
|
|
24
|
+
$summary = [PSCustomObject]@{
|
|
25
|
+
checkedAt = (Get-Date).ToString("o")
|
|
26
|
+
configPath = $configPath
|
|
27
|
+
configExists = $configExists
|
|
28
|
+
env = $envStatus
|
|
29
|
+
allRequiredEnvPresent = (($envStatus | Where-Object { -not $_.present }).Count -eq 0)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
if ($Json) {
|
|
33
|
+
$summary | ConvertTo-Json -Depth 6
|
|
34
|
+
exit 0
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
Write-Host "Cortex Memory smoke check"
|
|
38
|
+
Write-Host "Config path: $($summary.configPath)"
|
|
39
|
+
Write-Host "Config exists: $($summary.configExists)"
|
|
40
|
+
Write-Host ""
|
|
41
|
+
Write-Host "Required environment variables:"
|
|
42
|
+
foreach ($item in $envStatus) {
|
|
43
|
+
$state = if ($item.present) { "OK" } else { "MISSING" }
|
|
44
|
+
Write-Host ("- {0}: {1}" -f $item.name, $state)
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
if (-not $summary.allRequiredEnvPresent) {
|
|
48
|
+
Write-Host ""
|
|
49
|
+
Write-Host "One or more required environment variables are missing."
|
|
50
|
+
exit 1
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
Write-Host ""
|
|
54
|
+
Write-Host "All required environment variables are present."
|
|
55
|
+
exit 0
|
|
56
|
+
|