clawvault 3.2.1 → 3.3.0

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 (150) hide show
  1. package/README.md +56 -16
  2. package/bin/clawvault.js +0 -2
  3. package/bin/command-registration.test.js +13 -1
  4. package/bin/help-contract.test.js +14 -0
  5. package/bin/register-core-commands.js +88 -0
  6. package/bin/register-core-commands.test.js +80 -0
  7. package/bin/register-maintenance-commands.js +57 -6
  8. package/bin/register-query-commands.js +10 -28
  9. package/bin/test-helpers/cli-command-fixtures.js +1 -0
  10. package/dist/chunk-2PKBIKDH.js +130 -0
  11. package/dist/{chunk-U67V476Y.js → chunk-2ZDO52B4.js} +18 -1
  12. package/dist/{chunk-ZZA73MFY.js → chunk-33DOSHTA.js} +176 -36
  13. package/dist/{chunk-AZYOKJYC.js → chunk-4PY655YM.js} +13 -1
  14. package/dist/{chunk-2JQ3O2YL.js → chunk-5EFSWZO6.js} +3 -3
  15. package/dist/{chunk-Y3TIJEBP.js → chunk-7SWP5FKU.js} +34 -613
  16. package/dist/{chunk-4VQTUVH7.js → chunk-7YZWHM36.js} +52 -26
  17. package/dist/{chunk-URXDAUVH.js → chunk-AXSJIFOJ.js} +174 -1
  18. package/dist/{chunk-4ITRXIVT.js → chunk-BLQXXX7Q.js} +6 -6
  19. package/dist/chunk-CSHO3PJB.js +684 -0
  20. package/dist/{chunk-S5OJEGFG.js → chunk-DOIUYIXV.js} +2 -2
  21. package/dist/{chunk-YXQCA6B7.js → chunk-DVOUSOR3.js} +112 -7
  22. package/dist/{chunk-YDWHS4LJ.js → chunk-ECGJYWNA.js} +205 -33
  23. package/dist/{chunk-QMHPQYUV.js → chunk-EL6UBSX5.js} +7 -6
  24. package/dist/chunk-FZ5I2NF7.js +352 -0
  25. package/dist/{chunk-WJVWINEM.js → chunk-GFCHWMGD.js} +55 -6
  26. package/dist/{chunk-GNJL4YGR.js → chunk-GJO3CFUN.js} +30 -6
  27. package/dist/chunk-H3JZIB5O.js +322 -0
  28. package/dist/chunk-HEHO7SMV.js +51 -0
  29. package/dist/{chunk-UCQAOZHW.js → chunk-HGDDW24U.js} +3 -3
  30. package/dist/chunk-J3YUXVID.js +907 -0
  31. package/dist/{chunk-Y6VJKXGL.js → chunk-KCYWJDDW.js} +1 -1
  32. package/dist/{chunk-P5EPF6MB.js → chunk-MW5C6ZQA.js} +110 -13
  33. package/dist/{chunk-YNIPYN4F.js → chunk-OFOCU2V4.js} +6 -5
  34. package/dist/{chunk-42MXU7A6.js → chunk-P62WHA27.js} +58 -47
  35. package/dist/chunk-PTWPPVC7.js +972 -0
  36. package/dist/{chunk-FAKNOB7Y.js → chunk-QFWERBDP.js} +2 -2
  37. package/dist/{chunk-IIOU45CK.js → chunk-S7N7HI5E.js} +2 -2
  38. package/dist/{chunk-ECRZL5XR.js → chunk-T7E764W3.js} +23 -7
  39. package/dist/chunk-TDWFBDAQ.js +1016 -0
  40. package/dist/{chunk-MNPUYCHQ.js → chunk-TWMI3SNN.js} +6 -5
  41. package/dist/{chunk-2RAZ4ZFE.js → chunk-VBILES4B.js} +1 -1
  42. package/dist/{chunk-PI4WMLMG.js → chunk-VXAGOLDP.js} +1 -1
  43. package/dist/chunk-YCUVAOFC.js +158 -0
  44. package/dist/{chunk-SS4B7P7V.js → chunk-YIDV4VV2.js} +1 -1
  45. package/dist/chunk-ZKWPCBYT.js +600 -0
  46. package/dist/cli/index.js +27 -21
  47. package/dist/commands/archive.js +3 -3
  48. package/dist/commands/backlog.js +1 -1
  49. package/dist/commands/benchmark.d.ts +12 -0
  50. package/dist/commands/benchmark.js +12 -0
  51. package/dist/commands/blocked.js +1 -1
  52. package/dist/commands/canvas.js +2 -2
  53. package/dist/commands/checkpoint.js +1 -1
  54. package/dist/commands/compat.js +1 -1
  55. package/dist/commands/context.js +8 -7
  56. package/dist/commands/doctor.d.ts +8 -3
  57. package/dist/commands/doctor.js +8 -22
  58. package/dist/commands/embed.js +6 -5
  59. package/dist/commands/entities.js +2 -2
  60. package/dist/commands/graph.js +4 -4
  61. package/dist/commands/inbox.d.ts +23 -0
  62. package/dist/commands/inbox.js +11 -0
  63. package/dist/commands/inject.d.ts +1 -1
  64. package/dist/commands/inject.js +5 -5
  65. package/dist/commands/kanban.js +1 -1
  66. package/dist/commands/link.js +9 -9
  67. package/dist/commands/maintain.d.ts +32 -0
  68. package/dist/commands/maintain.js +12 -0
  69. package/dist/commands/migrate-observations.js +3 -3
  70. package/dist/commands/observe.js +11 -10
  71. package/dist/commands/project.js +2 -2
  72. package/dist/commands/rebuild-embeddings.js +48 -17
  73. package/dist/commands/rebuild.js +9 -8
  74. package/dist/commands/recover.js +1 -1
  75. package/dist/commands/reflect.js +6 -6
  76. package/dist/commands/repair-session.js +1 -1
  77. package/dist/commands/replay.js +10 -9
  78. package/dist/commands/session-recap.js +1 -1
  79. package/dist/commands/setup.js +4 -3
  80. package/dist/commands/shell-init.js +1 -1
  81. package/dist/commands/sleep.d.ts +1 -1
  82. package/dist/commands/sleep.js +20 -18
  83. package/dist/commands/status.js +40 -26
  84. package/dist/commands/sync-bd.js +3 -3
  85. package/dist/commands/tailscale.js +3 -3
  86. package/dist/commands/task.js +1 -1
  87. package/dist/commands/template.js +1 -1
  88. package/dist/commands/wake.d.ts +1 -1
  89. package/dist/commands/wake.js +10 -9
  90. package/dist/index.d.ts +175 -16
  91. package/dist/index.js +277 -108
  92. package/dist/{inject-DYUrDqQO.d.ts → inject-DEb_jpLi.d.ts} +3 -1
  93. package/dist/lib/auto-linker.js +2 -2
  94. package/dist/lib/canvas-layout.js +1 -1
  95. package/dist/lib/config.js +2 -2
  96. package/dist/lib/entity-index.js +1 -1
  97. package/dist/lib/project-utils.js +2 -2
  98. package/dist/lib/session-repair.js +1 -1
  99. package/dist/lib/session-utils.js +1 -1
  100. package/dist/lib/tailscale.js +1 -1
  101. package/dist/lib/task-utils.js +1 -1
  102. package/dist/lib/template-engine.js +1 -1
  103. package/dist/lib/webdav.js +1 -1
  104. package/dist/onnxruntime_binding-5QEF3SUC.node +0 -0
  105. package/dist/onnxruntime_binding-BKPKNEGC.node +0 -0
  106. package/dist/onnxruntime_binding-FMOXGIUT.node +0 -0
  107. package/dist/onnxruntime_binding-OI2KMXC5.node +0 -0
  108. package/dist/onnxruntime_binding-UX44MLAZ.node +0 -0
  109. package/dist/onnxruntime_binding-Y2W7N7WY.node +0 -0
  110. package/dist/openclaw-plugin.d.ts +8 -0
  111. package/dist/openclaw-plugin.js +14 -0
  112. package/dist/transformers.node-A2ZRORSQ.js +46775 -0
  113. package/dist/{types-BbWJoC1c.d.ts → types-DslKvCaj.d.ts} +51 -1
  114. package/hooks/clawvault/HOOK.md +25 -8
  115. package/hooks/clawvault/handler.js +215 -78
  116. package/hooks/clawvault/handler.test.js +109 -43
  117. package/hooks/clawvault/integrity.js +112 -0
  118. package/hooks/clawvault/integrity.test.js +32 -0
  119. package/hooks/clawvault/openclaw.plugin.json +133 -15
  120. package/openclaw.plugin.json +131 -203
  121. package/package.json +10 -7
  122. package/bin/register-workgraph-commands.js +0 -451
  123. package/dist/chunk-5PJ4STIC.js +0 -465
  124. package/dist/chunk-ERNE2FZ5.js +0 -189
  125. package/dist/chunk-HR4KN6S2.js +0 -152
  126. package/dist/chunk-IJBFGPCS.js +0 -33
  127. package/dist/chunk-K7PNYS45.js +0 -93
  128. package/dist/chunk-NTOPJI7W.js +0 -207
  129. package/dist/chunk-PG56HX5T.js +0 -154
  130. package/dist/chunk-QPDDIHXE.js +0 -501
  131. package/dist/chunk-WIOLLGAD.js +0 -190
  132. package/dist/chunk-WMGIIABP.js +0 -15
  133. package/dist/ledger-B7g7jhqG.d.ts +0 -44
  134. package/dist/plugin/index.d.ts +0 -352
  135. package/dist/plugin/index.js +0 -4264
  136. package/dist/registry-BR4326o0.d.ts +0 -30
  137. package/dist/store-CA-6sKCJ.d.ts +0 -34
  138. package/dist/thread-B9LhXNU0.d.ts +0 -41
  139. package/dist/workgraph/index.d.ts +0 -5
  140. package/dist/workgraph/index.js +0 -23
  141. package/dist/workgraph/ledger.d.ts +0 -2
  142. package/dist/workgraph/ledger.js +0 -25
  143. package/dist/workgraph/registry.d.ts +0 -2
  144. package/dist/workgraph/registry.js +0 -19
  145. package/dist/workgraph/store.d.ts +0 -2
  146. package/dist/workgraph/store.js +0 -25
  147. package/dist/workgraph/thread.d.ts +0 -2
  148. package/dist/workgraph/thread.js +0 -25
  149. package/dist/workgraph/types.d.ts +0 -54
  150. package/dist/workgraph/types.js +0 -7
package/dist/index.js CHANGED
@@ -1,7 +1,15 @@
1
+ import {
2
+ registerSyncBdCommand,
3
+ syncBdCommand
4
+ } from "./chunk-YIDV4VV2.js";
5
+ import {
6
+ rebuildCommand,
7
+ registerRebuildCommand
8
+ } from "./chunk-QFWERBDP.js";
1
9
  import {
2
10
  registerReplayCommand,
3
11
  replayCommand
4
- } from "./chunk-UCQAOZHW.js";
12
+ } from "./chunk-HGDDW24U.js";
5
13
  import {
6
14
  buildSessionRecap,
7
15
  formatSessionRecapMarkdown,
@@ -9,52 +17,37 @@ import {
9
17
  } from "./chunk-ZKGY7WTT.js";
10
18
  import {
11
19
  setupCommand
12
- } from "./chunk-QMHPQYUV.js";
20
+ } from "./chunk-EL6UBSX5.js";
13
21
  import {
14
- registerSyncBdCommand,
15
- syncBdCommand
16
- } from "./chunk-SS4B7P7V.js";
22
+ buildKanbanLanes,
23
+ extractCardSlug,
24
+ formatKanbanCard,
25
+ generateKanbanMarkdown,
26
+ importKanbanBoard,
27
+ kanbanCommand,
28
+ parseKanbanMarkdown,
29
+ syncKanbanBoard
30
+ } from "./chunk-4OXMU5S2.js";
17
31
  import {
18
32
  migrateObservations,
19
33
  migrateObservationsCommand,
20
34
  registerMigrateObservationsCommand
21
- } from "./chunk-2JQ3O2YL.js";
22
- import {
23
- EmbeddingCache,
24
- cosineSimilarity,
25
- embed,
26
- embedBatch,
27
- hybridSearch,
28
- reciprocalRankFusion,
29
- semanticSearch
30
- } from "./chunk-PG56HX5T.js";
35
+ } from "./chunk-5EFSWZO6.js";
31
36
  import {
32
- rebuildCommand,
33
- registerRebuildCommand
34
- } from "./chunk-FAKNOB7Y.js";
37
+ checkOpenClawCompatibility,
38
+ compatCommand,
39
+ compatibilityExitCode
40
+ } from "./chunk-X3SPPUFG.js";
35
41
  import {
36
42
  doctor
37
- } from "./chunk-QPDDIHXE.js";
38
- import "./chunk-7ZRP733D.js";
43
+ } from "./chunk-CSHO3PJB.js";
39
44
  import {
40
45
  graphCommand,
41
46
  graphSummary
42
- } from "./chunk-IIOU45CK.js";
43
- import {
44
- buildKanbanLanes,
45
- extractCardSlug,
46
- formatKanbanCard,
47
- generateKanbanMarkdown,
48
- importKanbanBoard,
49
- kanbanCommand,
50
- parseKanbanMarkdown,
51
- syncKanbanBoard
52
- } from "./chunk-4OXMU5S2.js";
53
- import "./chunk-4VQTUVH7.js";
54
- import "./chunk-J7ZWCI2C.js";
47
+ } from "./chunk-S7N7HI5E.js";
55
48
  import {
56
49
  registerCliCommands
57
- } from "./chunk-IJBFGPCS.js";
50
+ } from "./chunk-YCUVAOFC.js";
58
51
  import {
59
52
  registerTailscaleCommands,
60
53
  registerTailscaleDiscoverCommand,
@@ -65,7 +58,7 @@ import {
65
58
  tailscaleServeCommand,
66
59
  tailscaleStatusCommand,
67
60
  tailscaleSyncCommand
68
- } from "./chunk-Y6VJKXGL.js";
61
+ } from "./chunk-KCYWJDDW.js";
69
62
  import {
70
63
  CLAWVAULT_SERVE_PATH,
71
64
  DEFAULT_SERVE_PORT,
@@ -88,38 +81,37 @@ import {
88
81
  syncWithPeer
89
82
  } from "./chunk-TIGW564L.js";
90
83
  import "./chunk-IVRIKYFE.js";
91
- import {
92
- SessionWatcher,
93
- observeCommand,
94
- registerObserveCommand
95
- } from "./chunk-4ITRXIVT.js";
96
- import {
97
- parseSessionFile
98
- } from "./chunk-P5EPF6MB.js";
99
84
  import {
100
85
  reflectCommand,
101
86
  registerReflectCommand
102
- } from "./chunk-S5OJEGFG.js";
87
+ } from "./chunk-DOIUYIXV.js";
103
88
  import {
104
89
  runReflection
105
- } from "./chunk-MNPUYCHQ.js";
90
+ } from "./chunk-TWMI3SNN.js";
106
91
  import {
107
- buildContext,
108
- contextCommand,
109
- formatContextMarkdown,
110
- inferContextProfile,
111
- normalizeContextProfileInput,
112
- registerContextCommand,
113
- resolveContextProfile
114
- } from "./chunk-WJVWINEM.js";
92
+ buildInjectionResult,
93
+ deterministicInjectMatches,
94
+ indexInjectableItems,
95
+ injectCommand,
96
+ registerInjectCommand,
97
+ runPromptInjection
98
+ } from "./chunk-OFOCU2V4.js";
99
+ import {
100
+ maintainCommand,
101
+ registerMaintainCommand
102
+ } from "./chunk-TDWFBDAQ.js";
103
+ import {
104
+ SessionWatcher,
105
+ observeCommand,
106
+ registerObserveCommand
107
+ } from "./chunk-BLQXXX7Q.js";
115
108
  import {
116
109
  getObserverStaleness,
117
110
  getScaledObservationThresholdBytes,
118
111
  observeActiveSessions,
119
112
  parseSessionSourceLabel
120
- } from "./chunk-PI4WMLMG.js";
113
+ } from "./chunk-VXAGOLDP.js";
121
114
  import {
122
- Compressor,
123
115
  Observer,
124
116
  Reflector,
125
117
  createDefaultAdapter,
@@ -127,7 +119,12 @@ import {
127
119
  createGeminiFlashAdapter,
128
120
  createLlmFunction,
129
121
  resolveFactExtractionMode
130
- } from "./chunk-Y3TIJEBP.js";
122
+ } from "./chunk-7SWP5FKU.js";
123
+ import "./chunk-HRLWZGMA.js";
124
+ import {
125
+ requestLlmCompletion,
126
+ resolveLlmProvider
127
+ } from "./chunk-DVOUSOR3.js";
131
128
  import {
132
129
  archiveProject,
133
130
  createProject,
@@ -136,13 +133,29 @@ import {
136
133
  listProjects,
137
134
  readProject,
138
135
  updateProject
139
- } from "./chunk-AZYOKJYC.js";
140
- import "./chunk-HRLWZGMA.js";
136
+ } from "./chunk-4PY655YM.js";
141
137
  import {
142
- ClawVault,
143
- createVault,
144
- findVault
145
- } from "./chunk-YDWHS4LJ.js";
138
+ SUPPORTED_CONFIG_KEYS,
139
+ addRouteRule,
140
+ getConfig,
141
+ getConfigValue,
142
+ listConfig,
143
+ listRouteRules,
144
+ matchRouteRule,
145
+ removeRouteRule,
146
+ resetConfig,
147
+ setConfigValue,
148
+ testRouteRule
149
+ } from "./chunk-AXSJIFOJ.js";
150
+ import {
151
+ buildContext,
152
+ contextCommand,
153
+ formatContextMarkdown,
154
+ inferContextProfile,
155
+ normalizeContextProfileInput,
156
+ registerContextCommand,
157
+ resolveContextProfile
158
+ } from "./chunk-GFCHWMGD.js";
146
159
  import {
147
160
  FactStore,
148
161
  extractFactsLlm,
@@ -150,15 +163,25 @@ import {
150
163
  factId,
151
164
  normalizeEntity
152
165
  } from "./chunk-BSJ6RIT7.js";
153
- import "./chunk-FHFUXL6G.js";
166
+ import {
167
+ ClawVault,
168
+ createVault,
169
+ findVault
170
+ } from "./chunk-ECGJYWNA.js";
171
+ import {
172
+ DEFAULT_CATEGORIES,
173
+ DEFAULT_CONFIG,
174
+ MEMORY_TYPES,
175
+ TYPE_TO_CATEGORY
176
+ } from "./chunk-2CDEETQN.js";
154
177
  import {
155
178
  embedCommand,
156
179
  registerEmbedCommand
157
- } from "./chunk-ECRZL5XR.js";
180
+ } from "./chunk-T7E764W3.js";
158
181
  import {
159
182
  loadVaultQmdConfig,
160
183
  removeQmdCollection
161
- } from "./chunk-WIOLLGAD.js";
184
+ } from "./chunk-FZ5I2NF7.js";
162
185
  import {
163
186
  QMD_INSTALL_COMMAND,
164
187
  QMD_INSTALL_URL,
@@ -171,42 +194,17 @@ import {
171
194
  hasQmd,
172
195
  qmdEmbed,
173
196
  qmdUpdate
174
- } from "./chunk-5PJ4STIC.js";
175
- import {
176
- buildInjectionResult,
177
- deterministicInjectMatches,
178
- indexInjectableItems,
179
- injectCommand,
180
- registerInjectCommand,
181
- runPromptInjection
182
- } from "./chunk-YNIPYN4F.js";
183
- import {
184
- SUPPORTED_CONFIG_KEYS,
185
- addRouteRule,
186
- getConfig,
187
- getConfigValue,
188
- listConfig,
189
- listRouteRules,
190
- matchRouteRule,
191
- removeRouteRule,
192
- resetConfig,
193
- setConfigValue,
194
- testRouteRule
195
- } from "./chunk-URXDAUVH.js";
197
+ } from "./chunk-PTWPPVC7.js";
198
+ import "./chunk-H3JZIB5O.js";
196
199
  import {
197
- requestLlmCompletion,
198
- resolveLlmProvider
199
- } from "./chunk-YXQCA6B7.js";
200
- import {
201
- DEFAULT_CATEGORIES,
202
- DEFAULT_CONFIG,
203
- MEMORY_TYPES,
204
- TYPE_TO_CATEGORY
205
- } from "./chunk-2CDEETQN.js";
200
+ inboxAddCommand,
201
+ registerInboxCommand
202
+ } from "./chunk-HEHO7SMV.js";
203
+ import "./chunk-2PKBIKDH.js";
206
204
  import {
207
205
  archiveCommand,
208
206
  registerArchiveCommand
209
- } from "./chunk-2RAZ4ZFE.js";
207
+ } from "./chunk-VBILES4B.js";
210
208
  import {
211
209
  archiveObservations
212
210
  } from "./chunk-MQUJNOHK.js";
@@ -214,13 +212,31 @@ import {
214
212
  findNearestVaultPath,
215
213
  getVaultPath,
216
214
  resolveVaultPath
217
- } from "./chunk-GNJL4YGR.js";
215
+ } from "./chunk-GJO3CFUN.js";
216
+ import {
217
+ benchmarkObserverCommand,
218
+ compareObservationText,
219
+ extractKeywordSetFromTranscript,
220
+ formatObserverBenchmarkSummary,
221
+ loadObserverBenchmarkFixtures,
222
+ matchObservationRecords,
223
+ registerBenchmarkCommand,
224
+ runObserverBenchmark,
225
+ scoreFixtureObservations
226
+ } from "./chunk-ZKWPCBYT.js";
227
+ import {
228
+ parseSessionFile
229
+ } from "./chunk-MW5C6ZQA.js";
230
+ import {
231
+ Compressor
232
+ } from "./chunk-J3YUXVID.js";
233
+ import "./chunk-FHFUXL6G.js";
218
234
  import {
219
235
  MEMORY_GRAPH_SCHEMA_VERSION,
220
236
  buildOrUpdateMemoryGraphIndex,
221
237
  getMemoryGraph,
222
238
  loadMemoryGraphIndex
223
- } from "./chunk-ZZA73MFY.js";
239
+ } from "./chunk-33DOSHTA.js";
224
240
  import "./chunk-Z2XBWN7A.js";
225
241
  import {
226
242
  appendTransition,
@@ -240,22 +256,17 @@ import {
240
256
  buildTemplateVariables,
241
257
  renderTemplate
242
258
  } from "./chunk-7766SIJP.js";
243
- import {
244
- checkOpenClawCompatibility,
245
- compatCommand,
246
- compatibilityExitCode
247
- } from "./chunk-X3SPPUFG.js";
248
- import "./chunk-U67V476Y.js";
259
+ import "./chunk-2ZDO52B4.js";
249
260
 
250
261
  // src/index.ts
251
- import * as fs2 from "fs";
262
+ import * as fs3 from "fs";
252
263
 
253
264
  // src/commands/migrate.ts
254
265
  import * as fs from "fs";
255
266
  import * as path from "path";
256
267
  import { execFileSync } from "child_process";
257
268
  function addQmdCollection(name, rootPath) {
258
- execFileSync("qmd", ["collection", "add", name, rootPath], { stdio: "ignore" });
269
+ execFileSync("qmd", ["collection", "add", name, rootPath], { stdio: "ignore", shell: process.platform === "win32" });
259
270
  }
260
271
  function updateVaultConfig(vaultPath, updates) {
261
272
  const configPath = path.join(vaultPath, ".clawvault.json");
@@ -487,11 +498,156 @@ function registerMigrateCommand(program) {
487
498
  });
488
499
  }
489
500
 
501
+ // src/lib/hybrid-search.ts
502
+ import * as fs2 from "fs";
503
+ import * as path2 from "path";
504
+ var embeddingPipeline = null;
505
+ var pipelineLoading = null;
506
+ async function getEmbeddingPipeline() {
507
+ if (embeddingPipeline) return embeddingPipeline;
508
+ if (pipelineLoading) return pipelineLoading;
509
+ pipelineLoading = (async () => {
510
+ const { pipeline } = await import("./transformers.node-A2ZRORSQ.js");
511
+ embeddingPipeline = await pipeline("feature-extraction", "Xenova/all-MiniLM-L6-v2", {
512
+ dtype: "fp32"
513
+ });
514
+ return embeddingPipeline;
515
+ })();
516
+ return pipelineLoading;
517
+ }
518
+ async function embed(text) {
519
+ const pipe = await getEmbeddingPipeline();
520
+ const result = await pipe(text, { pooling: "mean", normalize: true });
521
+ return new Float32Array(result.data);
522
+ }
523
+ async function embedBatch(texts) {
524
+ const pipe = await getEmbeddingPipeline();
525
+ const results = [];
526
+ const batchSize = 32;
527
+ for (let i = 0; i < texts.length; i += batchSize) {
528
+ const batch = texts.slice(i, i + batchSize);
529
+ for (const text of batch) {
530
+ const result = await pipe(text, { pooling: "mean", normalize: true });
531
+ results.push(new Float32Array(result.data));
532
+ }
533
+ }
534
+ return results;
535
+ }
536
+ function cosineSimilarity(a, b) {
537
+ let dot = 0;
538
+ for (let i = 0; i < a.length; i++) {
539
+ dot += a[i] * b[i];
540
+ }
541
+ return dot;
542
+ }
543
+ var EmbeddingCache = class {
544
+ cachePath;
545
+ cache = /* @__PURE__ */ new Map();
546
+ dirty = false;
547
+ constructor(vaultPath) {
548
+ this.cachePath = path2.join(vaultPath, ".clawvault", "embeddings.bin");
549
+ }
550
+ /**
551
+ * Load cache from disk
552
+ */
553
+ load() {
554
+ try {
555
+ if (!fs2.existsSync(this.cachePath)) return;
556
+ const data = JSON.parse(fs2.readFileSync(this.cachePath + ".json", "utf-8"));
557
+ for (const [key, arr] of Object.entries(data)) {
558
+ this.cache.set(key, new Float32Array(arr));
559
+ }
560
+ } catch {
561
+ }
562
+ }
563
+ /**
564
+ * Save cache to disk
565
+ */
566
+ save() {
567
+ if (!this.dirty) return;
568
+ const dir = path2.dirname(this.cachePath);
569
+ if (!fs2.existsSync(dir)) fs2.mkdirSync(dir, { recursive: true });
570
+ const data = {};
571
+ for (const [key, arr] of this.cache.entries()) {
572
+ data[key] = Array.from(arr);
573
+ }
574
+ fs2.writeFileSync(this.cachePath + ".json", JSON.stringify(data));
575
+ this.dirty = false;
576
+ }
577
+ get(key) {
578
+ return this.cache.get(key);
579
+ }
580
+ set(key, embedding) {
581
+ this.cache.set(key, embedding);
582
+ this.dirty = true;
583
+ }
584
+ has(key) {
585
+ return this.cache.has(key);
586
+ }
587
+ entries() {
588
+ return this.cache.entries();
589
+ }
590
+ get size() {
591
+ return this.cache.size;
592
+ }
593
+ };
594
+ function reciprocalRankFusion(list1, list2, k = 60) {
595
+ const scores = /* @__PURE__ */ new Map();
596
+ for (let rank = 0; rank < list1.length; rank++) {
597
+ const { id } = list1[rank];
598
+ scores.set(id, (scores.get(id) || 0) + 1 / (k + rank + 1));
599
+ }
600
+ for (let rank = 0; rank < list2.length; rank++) {
601
+ const { id } = list2[rank];
602
+ scores.set(id, (scores.get(id) || 0) + 1 / (k + rank + 1));
603
+ }
604
+ return Array.from(scores.entries()).map(([id, score]) => ({ id, score })).sort((a, b) => b.score - a.score);
605
+ }
606
+ async function semanticSearch(query, cache, topK = 20) {
607
+ const queryEmb = await embed(query);
608
+ const results = [];
609
+ for (const [id, docEmb] of cache.entries()) {
610
+ results.push({ id, score: cosineSimilarity(queryEmb, docEmb) });
611
+ }
612
+ results.sort((a, b) => b.score - a.score);
613
+ return results.slice(0, topK);
614
+ }
615
+ async function hybridSearch(query, bm25Results, cache, options = {}) {
616
+ const { topK = 20, rrfK = 60 } = options;
617
+ const bm25Ranked = bm25Results.map((r) => ({ id: r.document.path || r.document.id, score: r.score }));
618
+ const semanticRanked = await semanticSearch(query, cache, topK);
619
+ const fused = reciprocalRankFusion(bm25Ranked, semanticRanked, rrfK);
620
+ const bm25Map = new Map(bm25Results.map((r) => [r.document.path || r.document.id, r]));
621
+ return fused.slice(0, topK).map(({ id, score }) => {
622
+ const existing = bm25Map.get(id);
623
+ if (existing) {
624
+ return { ...existing, score };
625
+ }
626
+ const minimalDoc = {
627
+ id: id.replace(/\.md$/, ""),
628
+ path: id.endsWith(".md") ? id : id + ".md",
629
+ title: (id.split("/").pop() || id).replace(/\.md$/, ""),
630
+ content: "",
631
+ category: id.split("/")[0] || "root",
632
+ frontmatter: {},
633
+ links: [],
634
+ tags: [],
635
+ modified: /* @__PURE__ */ new Date()
636
+ };
637
+ return {
638
+ document: minimalDoc,
639
+ score,
640
+ snippet: "",
641
+ matchedTerms: []
642
+ };
643
+ });
644
+ }
645
+
490
646
  // src/index.ts
491
647
  function readPackageVersion() {
492
648
  try {
493
649
  const pkgUrl = new URL("../package.json", import.meta.url);
494
- const pkg = JSON.parse(fs2.readFileSync(pkgUrl, "utf-8"));
650
+ const pkg = JSON.parse(fs3.readFileSync(pkgUrl, "utf-8"));
495
651
  return pkg.version ?? "0.0.0";
496
652
  } catch {
497
653
  return "0.0.0";
@@ -528,6 +684,7 @@ export {
528
684
  archiveCommand,
529
685
  archiveObservations,
530
686
  archiveProject,
687
+ benchmarkObserverCommand,
531
688
  buildContext,
532
689
  buildInjectionResult,
533
690
  buildKanbanLanes,
@@ -538,6 +695,7 @@ export {
538
695
  checkOpenClawCompatibility,
539
696
  checkPeerClawVault,
540
697
  compareManifests,
698
+ compareObservationText,
541
699
  compatCommand,
542
700
  compatibilityExitCode,
543
701
  completeTask,
@@ -560,6 +718,7 @@ export {
560
718
  extractCardSlug,
561
719
  extractFactsLlm,
562
720
  extractFactsRuleBased,
721
+ extractKeywordSetFromTranscript,
563
722
  extractTags,
564
723
  extractWikiLinks,
565
724
  factId,
@@ -570,6 +729,7 @@ export {
570
729
  findVault,
571
730
  formatContextMarkdown,
572
731
  formatKanbanCard,
732
+ formatObserverBenchmarkSummary,
573
733
  formatSessionRecapMarkdown,
574
734
  formatTransitionsTable,
575
735
  generateKanbanMarkdown,
@@ -592,6 +752,7 @@ export {
592
752
  hasTailscale,
593
753
  hybridSearch,
594
754
  importKanbanBoard,
755
+ inboxAddCommand,
595
756
  indexInjectableItems,
596
757
  inferContextProfile,
597
758
  injectCommand,
@@ -603,6 +764,9 @@ export {
603
764
  listRouteRules,
604
765
  listSubtasks,
605
766
  loadMemoryGraphIndex,
767
+ loadObserverBenchmarkFixtures,
768
+ maintainCommand,
769
+ matchObservationRecords,
606
770
  matchRouteRule,
607
771
  migrate,
608
772
  migrateCommand,
@@ -625,11 +789,14 @@ export {
625
789
  reciprocalRankFusion,
626
790
  reflectCommand,
627
791
  registerArchiveCommand,
792
+ registerBenchmarkCommand,
628
793
  registerCliCommands,
629
794
  registerCommanderCommands,
630
795
  registerContextCommand,
631
796
  registerEmbedCommand,
797
+ registerInboxCommand,
632
798
  registerInjectCommand,
799
+ registerMaintainCommand,
633
800
  registerMigrateCommand,
634
801
  registerMigrateObservationsCommand,
635
802
  registerObserveCommand,
@@ -652,8 +819,10 @@ export {
652
819
  resolveLlmProvider,
653
820
  resolvePeerIP,
654
821
  resolveVaultPath,
822
+ runObserverBenchmark,
655
823
  runPromptInjection,
656
824
  runReflection,
825
+ scoreFixtureObservations,
657
826
  semanticSearch,
658
827
  serveVault,
659
828
  sessionRecapCommand,
@@ -58,10 +58,12 @@ declare function getMemoryGraph(vaultPath: string, options?: {
58
58
  }): Promise<MemoryGraph>;
59
59
 
60
60
  type LlmProvider = 'anthropic' | 'openai' | 'gemini' | 'xai' | 'openclaw';
61
+ type LlmModelTier = 'background' | 'default' | 'complex';
61
62
  interface LlmCompletionOptions {
62
63
  prompt: string;
63
64
  provider?: LlmProvider | null;
64
65
  model?: string;
66
+ tier?: LlmModelTier;
65
67
  systemPrompt?: string;
66
68
  temperature?: number;
67
69
  maxTokens?: number;
@@ -134,4 +136,4 @@ declare function buildInjectionResult(message: string, options: InjectCommandOpt
134
136
  declare function injectCommand(message: string, options: InjectCommandOptions): Promise<void>;
135
137
  declare function registerInjectCommand(program: Command): void;
136
138
 
137
- export { runPromptInjection as A, type InjectCommandOptions as I, type LlmProvider as L, MEMORY_GRAPH_SCHEMA_VERSION as M, type InjectFormat as a, type InjectMatch as b, type InjectMatchReason as c, type InjectMatchSource as d, type InjectResult as e, type InjectRuntimeOptions as f, type InjectSourceCategory as g, type InjectableItem as h, type LlmCompletionOptions as i, type MemoryGraph as j, type MemoryGraphEdge as k, type MemoryGraphEdgeType as l, type MemoryGraphIndex as m, type MemoryGraphNode as n, type MemoryGraphNodeType as o, type MemoryGraphStats as p, buildInjectionResult as q, buildOrUpdateMemoryGraphIndex as r, deterministicInjectMatches as s, getMemoryGraph as t, indexInjectableItems as u, injectCommand as v, loadMemoryGraphIndex as w, registerInjectCommand as x, requestLlmCompletion as y, resolveLlmProvider as z };
139
+ export { resolveLlmProvider as A, runPromptInjection as B, type InjectCommandOptions as I, type LlmProvider as L, MEMORY_GRAPH_SCHEMA_VERSION as M, type LlmModelTier as a, type InjectFormat as b, type InjectMatch as c, type InjectMatchReason as d, type InjectMatchSource as e, type InjectResult as f, type InjectRuntimeOptions as g, type InjectSourceCategory as h, type InjectableItem as i, type LlmCompletionOptions as j, type MemoryGraph as k, type MemoryGraphEdge as l, type MemoryGraphEdgeType as m, type MemoryGraphIndex as n, type MemoryGraphNode as o, type MemoryGraphNodeType as p, type MemoryGraphStats as q, buildInjectionResult as r, buildOrUpdateMemoryGraphIndex as s, deterministicInjectMatches as t, getMemoryGraph as u, indexInjectableItems as v, injectCommand as w, loadMemoryGraphIndex as x, registerInjectCommand as y, requestLlmCompletion as z };
@@ -2,9 +2,9 @@ import {
2
2
  autoLink,
3
3
  dryRunLink,
4
4
  findUnlinkedMentions
5
- } from "../chunk-42MXU7A6.js";
5
+ } from "../chunk-P62WHA27.js";
6
6
  import "../chunk-J7ZWCI2C.js";
7
- import "../chunk-U67V476Y.js";
7
+ import "../chunk-2ZDO52B4.js";
8
8
  export {
9
9
  autoLink,
10
10
  dryRunLink,
@@ -15,7 +15,7 @@ import {
15
15
  stackNodesVertically,
16
16
  truncateText
17
17
  } from "../chunk-MDIH26GC.js";
18
- import "../chunk-U67V476Y.js";
18
+ import "../chunk-2ZDO52B4.js";
19
19
  export {
20
20
  CANVAS_COLORS,
21
21
  LAYOUT,
@@ -3,8 +3,8 @@ import {
3
3
  getVaultPath,
4
4
  resolveAgentVaultPath,
5
5
  resolveVaultPath
6
- } from "../chunk-GNJL4YGR.js";
7
- import "../chunk-U67V476Y.js";
6
+ } from "../chunk-GJO3CFUN.js";
7
+ import "../chunk-2ZDO52B4.js";
8
8
  export {
9
9
  findNearestVaultPath,
10
10
  getVaultPath,
@@ -2,7 +2,7 @@ import {
2
2
  buildEntityIndex,
3
3
  getSortedAliases
4
4
  } from "../chunk-J7ZWCI2C.js";
5
- import "../chunk-U67V476Y.js";
5
+ import "../chunk-2ZDO52B4.js";
6
6
  export {
7
7
  buildEntityIndex,
8
8
  getSortedAliases
@@ -6,11 +6,11 @@ import {
6
6
  listProjects,
7
7
  readProject,
8
8
  updateProject
9
- } from "../chunk-AZYOKJYC.js";
9
+ } from "../chunk-4PY655YM.js";
10
10
  import "../chunk-QWQ3TIKS.js";
11
11
  import "../chunk-MFAWT5O5.js";
12
12
  import "../chunk-7766SIJP.js";
13
- import "../chunk-U67V476Y.js";
13
+ import "../chunk-2ZDO52B4.js";
14
14
  export {
15
15
  archiveProject,
16
16
  createProject,
@@ -6,7 +6,7 @@ import {
6
6
  parseTranscript,
7
7
  repairSession
8
8
  } from "../chunk-L53L5FCL.js";
9
- import "../chunk-U67V476Y.js";
9
+ import "../chunk-2ZDO52B4.js";
10
10
  export {
11
11
  analyzeSession,
12
12
  computeParentRelinks,
@@ -11,7 +11,7 @@ import {
11
11
  listSessions,
12
12
  loadSessionsStore
13
13
  } from "../chunk-HRLWZGMA.js";
14
- import "../chunk-U67V476Y.js";
14
+ import "../chunk-2ZDO52B4.js";
15
15
  export {
16
16
  backupSession,
17
17
  findMainSession,
@@ -23,7 +23,7 @@ import {
23
23
  syncWithPeer
24
24
  } from "../chunk-TIGW564L.js";
25
25
  import "../chunk-IVRIKYFE.js";
26
- import "../chunk-U67V476Y.js";
26
+ import "../chunk-2ZDO52B4.js";
27
27
  export {
28
28
  CLAWVAULT_SERVE_PATH,
29
29
  DEFAULT_SERVE_PORT,
@@ -26,7 +26,7 @@ import {
26
26
  } from "../chunk-QWQ3TIKS.js";
27
27
  import "../chunk-MFAWT5O5.js";
28
28
  import "../chunk-7766SIJP.js";
29
- import "../chunk-U67V476Y.js";
29
+ import "../chunk-2ZDO52B4.js";
30
30
  export {
31
31
  completeTask,
32
32
  createBacklogItem,