clawvault 3.1.0 → 3.2.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 (289) hide show
  1. package/README.md +422 -141
  2. package/bin/clawvault.js +10 -2
  3. package/bin/command-registration.test.js +3 -1
  4. package/bin/command-runtime.js +9 -1
  5. package/bin/register-core-commands.js +23 -28
  6. package/bin/register-maintenance-commands.js +39 -3
  7. package/bin/register-query-commands.js +58 -29
  8. package/bin/register-tailscale-commands.js +106 -0
  9. package/bin/register-task-commands.js +18 -1
  10. package/bin/register-task-commands.test.js +16 -0
  11. package/bin/register-vault-operations-commands.js +29 -1
  12. package/bin/register-workgraph-commands.js +1368 -0
  13. package/dashboard/lib/graph-diff.js +104 -0
  14. package/dashboard/lib/graph-diff.test.js +75 -0
  15. package/dashboard/lib/vault-parser.js +556 -0
  16. package/dashboard/lib/vault-parser.test.js +254 -0
  17. package/dashboard/public/app.js +796 -0
  18. package/dashboard/public/index.html +52 -0
  19. package/dashboard/public/styles.css +221 -0
  20. package/dashboard/server.js +374 -0
  21. package/dist/{chunk-F2JEUD4J.js → chunk-23YDQ3QU.js} +6 -8
  22. package/dist/{chunk-C7OK5WKP.js → chunk-2JQ3O2YL.js} +4 -4
  23. package/dist/{chunk-VR5NE7PZ.js → chunk-2RAZ4ZFE.js} +1 -1
  24. package/dist/chunk-2ZDO52B4.js +52 -0
  25. package/dist/{chunk-ZZA73MFY.js → chunk-33DOSHTA.js} +176 -36
  26. package/dist/chunk-33VSQP4J.js +37 -0
  27. package/dist/chunk-4BQTQMJP.js +93 -0
  28. package/dist/{chunk-GUKMRGM7.js → chunk-4OXMU5S2.js} +1 -1
  29. package/dist/{chunk-62YTUT6J.js → chunk-4PY655YM.js} +15 -3
  30. package/dist/chunk-6FH3IULF.js +352 -0
  31. package/dist/{chunk-3NSBOUT3.js → chunk-77Q5CSPJ.js} +404 -80
  32. package/dist/{chunk-4VQTUVH7.js → chunk-7YZWHM36.js} +52 -26
  33. package/dist/chunk-BSJ6RIT7.js +447 -0
  34. package/dist/chunk-BUEW6IIK.js +364 -0
  35. package/dist/{chunk-LI4O6NVK.js → chunk-CLJTREDS.js} +74 -14
  36. package/dist/chunk-EK6S23ZB.js +469 -0
  37. package/dist/{chunk-LNJA2UGL.js → chunk-ESFLMDRB.js} +9 -86
  38. package/dist/{chunk-H34S76MB.js → chunk-ESVS6K2B.js} +6 -6
  39. package/dist/{chunk-WAZ3NLWL.js → chunk-F55HGNU4.js} +0 -47
  40. package/dist/{chunk-QK3UCXWL.js → chunk-FHFUXL6G.js} +2 -2
  41. package/dist/{chunk-H62BP7RI.js → chunk-GAOWA7GR.js} +212 -46
  42. package/dist/chunk-GGA32J2R.js +784 -0
  43. package/dist/chunk-GNJL4YGR.js +79 -0
  44. package/dist/chunk-IVRIKYFE.js +520 -0
  45. package/dist/chunk-MDIH26GC.js +183 -0
  46. package/dist/{chunk-LYHGEHXG.js → chunk-MFAWT5O5.js} +0 -1
  47. package/dist/chunk-MM6QGW3P.js +207 -0
  48. package/dist/{chunk-P5EPF6MB.js → chunk-MW5C6ZQA.js} +110 -13
  49. package/dist/chunk-NCKFNBHJ.js +257 -0
  50. package/dist/{chunk-QBLMXKF2.js → chunk-OIWVQYQF.js} +1 -1
  51. package/dist/{chunk-42MXU7A6.js → chunk-P62WHA27.js} +58 -47
  52. package/dist/chunk-PBACDKKP.js +66 -0
  53. package/dist/{chunk-VGLOTGAS.js → chunk-QSHD36LH.js} +2 -2
  54. package/dist/{chunk-OZ7RIXTO.js → chunk-QSRRMEYM.js} +2 -2
  55. package/dist/chunk-QVEERJSP.js +152 -0
  56. package/dist/{chunk-N2AXRYLC.js → chunk-QWQ3TIKS.js} +1 -1
  57. package/dist/{chunk-3DHXQHYG.js → chunk-R2MIW5G7.js} +1 -1
  58. package/dist/{chunk-SJSFRIYS.js → chunk-SLXOR3CC.js} +2 -2
  59. package/dist/chunk-SS4B7P7V.js +99 -0
  60. package/dist/{chunk-JY6FYXIT.js → chunk-STCQGCEQ.js} +6 -11
  61. package/dist/chunk-TIGW564L.js +628 -0
  62. package/dist/chunk-U4O6C46S.js +154 -0
  63. package/dist/{chunk-ITPEXLHA.js → chunk-URXDAUVH.js} +24 -5
  64. package/dist/chunk-VSL7KY3M.js +189 -0
  65. package/dist/{chunk-U55BGUAU.js → chunk-W4SPAEE7.js} +6 -6
  66. package/dist/chunk-WMGIIABP.js +15 -0
  67. package/dist/{chunk-33UGEQRT.js → chunk-X3SPPUFG.js} +151 -64
  68. package/dist/chunk-Y6VJKXGL.js +373 -0
  69. package/dist/{chunk-3WRJEKN4.js → chunk-ZN54U2OZ.js} +123 -10
  70. package/dist/cli/index.js +34 -24
  71. package/dist/commands/archive.js +3 -3
  72. package/dist/commands/backlog.js +3 -3
  73. package/dist/commands/blocked.js +3 -3
  74. package/dist/commands/canvas.d.ts +15 -0
  75. package/dist/commands/canvas.js +200 -0
  76. package/dist/commands/checkpoint.js +2 -2
  77. package/dist/commands/compat.js +2 -2
  78. package/dist/commands/context.js +8 -6
  79. package/dist/commands/doctor.d.ts +11 -7
  80. package/dist/commands/doctor.js +18 -16
  81. package/dist/commands/embed.js +5 -6
  82. package/dist/commands/entities.js +2 -2
  83. package/dist/commands/graph.js +4 -4
  84. package/dist/commands/inject.d.ts +1 -1
  85. package/dist/commands/inject.js +5 -6
  86. package/dist/commands/kanban.js +4 -4
  87. package/dist/commands/link.js +5 -5
  88. package/dist/commands/migrate-observations.js +4 -4
  89. package/dist/commands/observe.d.ts +0 -1
  90. package/dist/commands/observe.js +14 -13
  91. package/dist/commands/project.js +5 -5
  92. package/dist/commands/rebuild-embeddings.d.ts +21 -0
  93. package/dist/commands/rebuild-embeddings.js +91 -0
  94. package/dist/commands/rebuild.js +12 -11
  95. package/dist/commands/recover.js +3 -3
  96. package/dist/commands/reflect.js +6 -7
  97. package/dist/commands/repair-session.js +1 -1
  98. package/dist/commands/replay.js +14 -14
  99. package/dist/commands/session-recap.js +1 -1
  100. package/dist/commands/setup.d.ts +2 -89
  101. package/dist/commands/setup.js +3 -21
  102. package/dist/commands/shell-init.js +1 -1
  103. package/dist/commands/sleep.d.ts +1 -1
  104. package/dist/commands/sleep.js +20 -19
  105. package/dist/commands/status.d.ts +2 -0
  106. package/dist/commands/status.js +57 -35
  107. package/dist/commands/sync-bd.d.ts +10 -0
  108. package/dist/commands/sync-bd.js +10 -0
  109. package/dist/commands/tailscale.d.ts +52 -0
  110. package/dist/commands/tailscale.js +26 -0
  111. package/dist/commands/task.js +4 -4
  112. package/dist/commands/template.js +2 -2
  113. package/dist/commands/wake.d.ts +1 -1
  114. package/dist/commands/wake.js +11 -10
  115. package/dist/commands/workgraph.d.ts +124 -0
  116. package/dist/commands/workgraph.js +38 -0
  117. package/dist/index.d.ts +341 -191
  118. package/dist/index.js +446 -116
  119. package/dist/{inject-Bzi5E-By.d.ts → inject-DYUrDqQO.d.ts} +3 -3
  120. package/dist/ledger-B7g7jhqG.d.ts +44 -0
  121. package/dist/lib/auto-linker.js +2 -2
  122. package/dist/lib/canvas-layout.d.ts +115 -0
  123. package/dist/lib/canvas-layout.js +35 -0
  124. package/dist/lib/config.d.ts +27 -3
  125. package/dist/lib/config.js +4 -2
  126. package/dist/lib/entity-index.js +1 -1
  127. package/dist/lib/project-utils.js +4 -4
  128. package/dist/lib/session-repair.js +1 -1
  129. package/dist/lib/session-utils.js +1 -1
  130. package/dist/lib/tailscale.d.ts +225 -0
  131. package/dist/lib/tailscale.js +50 -0
  132. package/dist/lib/task-utils.js +3 -3
  133. package/dist/lib/template-engine.js +1 -1
  134. package/dist/lib/webdav.d.ts +109 -0
  135. package/dist/lib/webdav.js +35 -0
  136. package/dist/onnxruntime_binding-5QEF3SUC.node +0 -0
  137. package/dist/onnxruntime_binding-BKPKNEGC.node +0 -0
  138. package/dist/onnxruntime_binding-FMOXGIUT.node +0 -0
  139. package/dist/onnxruntime_binding-OI2KMXC5.node +0 -0
  140. package/dist/onnxruntime_binding-UX44MLAZ.node +0 -0
  141. package/dist/onnxruntime_binding-Y2W7N7WY.node +0 -0
  142. package/dist/openclaw-plugin.d.ts +8 -0
  143. package/dist/openclaw-plugin.js +14 -0
  144. package/dist/registry-BR4326o0.d.ts +30 -0
  145. package/dist/store-CA-6sKCJ.d.ts +34 -0
  146. package/dist/thread-B9LhXNU0.d.ts +41 -0
  147. package/dist/transformers.node-A2ZRORSQ.js +46775 -0
  148. package/dist/{types-Y2_Um2Ls.d.ts → types-BbWJoC1c.d.ts} +1 -44
  149. package/dist/workgraph/index.d.ts +5 -0
  150. package/dist/workgraph/index.js +23 -0
  151. package/dist/workgraph/ledger.d.ts +2 -0
  152. package/dist/workgraph/ledger.js +25 -0
  153. package/dist/workgraph/registry.d.ts +2 -0
  154. package/dist/workgraph/registry.js +19 -0
  155. package/dist/workgraph/store.d.ts +2 -0
  156. package/dist/workgraph/store.js +25 -0
  157. package/dist/workgraph/thread.d.ts +2 -0
  158. package/dist/workgraph/thread.js +25 -0
  159. package/dist/workgraph/types.d.ts +54 -0
  160. package/dist/workgraph/types.js +7 -0
  161. package/hooks/clawvault/HOOK.md +113 -0
  162. package/hooks/clawvault/handler.js +1561 -0
  163. package/hooks/clawvault/handler.test.js +510 -0
  164. package/hooks/clawvault/openclaw.plugin.json +72 -0
  165. package/openclaw.plugin.json +65 -38
  166. package/package.json +25 -22
  167. package/dist/chunk-3RG5ZIWI.js +0 -10
  168. package/dist/chunk-3ZIH425O.js +0 -871
  169. package/dist/chunk-6U6MK36V.js +0 -205
  170. package/dist/chunk-CMB7UL7C.js +0 -327
  171. package/dist/chunk-D2H45LON.js +0 -1074
  172. package/dist/chunk-E7MFQB6D.js +0 -163
  173. package/dist/chunk-GQSLDZTS.js +0 -560
  174. package/dist/chunk-MFM6K7PU.js +0 -374
  175. package/dist/chunk-MXSSG3QU.js +0 -42
  176. package/dist/chunk-OCGVIN3L.js +0 -88
  177. package/dist/chunk-PAH27GSN.js +0 -108
  178. package/dist/chunk-YCUNCH2I.js +0 -78
  179. package/dist/cli/index.cjs +0 -8584
  180. package/dist/cli/index.d.cts +0 -5
  181. package/dist/commands/archive.cjs +0 -287
  182. package/dist/commands/archive.d.cts +0 -11
  183. package/dist/commands/backlog.cjs +0 -721
  184. package/dist/commands/backlog.d.cts +0 -53
  185. package/dist/commands/blocked.cjs +0 -204
  186. package/dist/commands/blocked.d.cts +0 -26
  187. package/dist/commands/checkpoint.cjs +0 -244
  188. package/dist/commands/checkpoint.d.cts +0 -41
  189. package/dist/commands/compat.cjs +0 -294
  190. package/dist/commands/compat.d.cts +0 -28
  191. package/dist/commands/context.cjs +0 -2990
  192. package/dist/commands/context.d.cts +0 -2
  193. package/dist/commands/doctor.cjs +0 -2986
  194. package/dist/commands/doctor.d.cts +0 -21
  195. package/dist/commands/embed.cjs +0 -232
  196. package/dist/commands/embed.d.cts +0 -17
  197. package/dist/commands/entities.cjs +0 -141
  198. package/dist/commands/entities.d.cts +0 -7
  199. package/dist/commands/graph.cjs +0 -501
  200. package/dist/commands/graph.d.cts +0 -21
  201. package/dist/commands/inject.cjs +0 -1636
  202. package/dist/commands/inject.d.cts +0 -2
  203. package/dist/commands/kanban.cjs +0 -884
  204. package/dist/commands/kanban.d.cts +0 -63
  205. package/dist/commands/link.cjs +0 -965
  206. package/dist/commands/link.d.cts +0 -11
  207. package/dist/commands/migrate-observations.cjs +0 -362
  208. package/dist/commands/migrate-observations.d.cts +0 -19
  209. package/dist/commands/observe.cjs +0 -4099
  210. package/dist/commands/observe.d.cts +0 -23
  211. package/dist/commands/project.cjs +0 -1341
  212. package/dist/commands/project.d.cts +0 -85
  213. package/dist/commands/rebuild.cjs +0 -3136
  214. package/dist/commands/rebuild.d.cts +0 -11
  215. package/dist/commands/recover.cjs +0 -361
  216. package/dist/commands/recover.d.cts +0 -38
  217. package/dist/commands/reflect.cjs +0 -1008
  218. package/dist/commands/reflect.d.cts +0 -11
  219. package/dist/commands/repair-session.cjs +0 -457
  220. package/dist/commands/repair-session.d.cts +0 -38
  221. package/dist/commands/replay.cjs +0 -4103
  222. package/dist/commands/replay.d.cts +0 -16
  223. package/dist/commands/session-recap.cjs +0 -353
  224. package/dist/commands/session-recap.d.cts +0 -27
  225. package/dist/commands/setup.cjs +0 -1278
  226. package/dist/commands/setup.d.cts +0 -99
  227. package/dist/commands/shell-init.cjs +0 -75
  228. package/dist/commands/shell-init.d.cts +0 -7
  229. package/dist/commands/sleep.cjs +0 -6029
  230. package/dist/commands/sleep.d.cts +0 -36
  231. package/dist/commands/status.cjs +0 -2737
  232. package/dist/commands/status.d.cts +0 -52
  233. package/dist/commands/task.cjs +0 -1236
  234. package/dist/commands/task.d.cts +0 -97
  235. package/dist/commands/template.cjs +0 -457
  236. package/dist/commands/template.d.cts +0 -36
  237. package/dist/commands/wake.cjs +0 -2627
  238. package/dist/commands/wake.d.cts +0 -22
  239. package/dist/context-BUGaWpyL.d.cts +0 -46
  240. package/dist/index.cjs +0 -12373
  241. package/dist/index.d.cts +0 -854
  242. package/dist/inject-Bzi5E-By.d.cts +0 -137
  243. package/dist/lib/auto-linker.cjs +0 -176
  244. package/dist/lib/auto-linker.d.cts +0 -26
  245. package/dist/lib/config.cjs +0 -78
  246. package/dist/lib/config.d.cts +0 -11
  247. package/dist/lib/entity-index.cjs +0 -84
  248. package/dist/lib/entity-index.d.cts +0 -26
  249. package/dist/lib/project-utils.cjs +0 -864
  250. package/dist/lib/project-utils.d.cts +0 -97
  251. package/dist/lib/session-repair.cjs +0 -239
  252. package/dist/lib/session-repair.d.cts +0 -110
  253. package/dist/lib/session-utils.cjs +0 -209
  254. package/dist/lib/session-utils.d.cts +0 -63
  255. package/dist/lib/task-utils.cjs +0 -1137
  256. package/dist/lib/task-utils.d.cts +0 -208
  257. package/dist/lib/template-engine.cjs +0 -47
  258. package/dist/lib/template-engine.d.cts +0 -11
  259. package/dist/plugin/index.cjs +0 -1907
  260. package/dist/plugin/index.d.cts +0 -36
  261. package/dist/plugin/index.d.ts +0 -36
  262. package/dist/plugin/index.js +0 -572
  263. package/dist/plugin/inject.cjs +0 -356
  264. package/dist/plugin/inject.d.cts +0 -54
  265. package/dist/plugin/inject.d.ts +0 -54
  266. package/dist/plugin/inject.js +0 -17
  267. package/dist/plugin/observe.cjs +0 -631
  268. package/dist/plugin/observe.d.cts +0 -39
  269. package/dist/plugin/observe.d.ts +0 -39
  270. package/dist/plugin/observe.js +0 -18
  271. package/dist/plugin/templates.cjs +0 -593
  272. package/dist/plugin/templates.d.cts +0 -52
  273. package/dist/plugin/templates.d.ts +0 -52
  274. package/dist/plugin/templates.js +0 -25
  275. package/dist/plugin/types.cjs +0 -18
  276. package/dist/plugin/types.d.cts +0 -209
  277. package/dist/plugin/types.d.ts +0 -209
  278. package/dist/plugin/types.js +0 -0
  279. package/dist/plugin/vault.cjs +0 -927
  280. package/dist/plugin/vault.d.cts +0 -68
  281. package/dist/plugin/vault.d.ts +0 -68
  282. package/dist/plugin/vault.js +0 -22
  283. package/dist/types-Y2_Um2Ls.d.cts +0 -205
  284. package/templates/memory-event.md +0 -67
  285. package/templates/party.md +0 -63
  286. package/templates/primitive-registry.yaml +0 -551
  287. package/templates/run.md +0 -68
  288. package/templates/trigger.md +0 -68
  289. package/templates/workspace.md +0 -50
package/dist/index.d.ts CHANGED
@@ -1,27 +1,34 @@
1
1
  import { Command } from 'commander';
2
- import { V as VaultConfig, S as StoreOptions, D as Document, a as SearchOptions, b as SearchResult, c as SyncOptions, d as SyncResult, C as Category, M as MemoryType, H as HandoffDocument, e as SessionRecap, E as ExtractedDate, f as ExtractedPreference } from './types-Y2_Um2Ls.js';
3
- export { g as DEFAULT_CATEGORIES, h as DEFAULT_CONFIG, i as MEMORY_TYPES, T as TYPE_TO_CATEGORY, j as VaultMeta } from './types-Y2_Um2Ls.js';
2
+ import { V as VaultConfig, a as StoreOptions, D as Document, b as SearchOptions, c as SearchResult, d as SyncOptions, e as SyncResult, C as Category, M as MemoryType, H as HandoffDocument, S as SessionRecap } from './types-BbWJoC1c.js';
3
+ export { f as DEFAULT_CATEGORIES, g as DEFAULT_CONFIG, h as MEMORY_TYPES, T as TYPE_TO_CATEGORY, i as VaultMeta } from './types-BbWJoC1c.js';
4
4
  export { setupCommand } from './commands/setup.js';
5
5
  export { CompatCheck, CompatCommandOptions, CompatReport, CompatStatus, checkOpenClawCompatibility, compatCommand, compatibilityExitCode } from './commands/compat.js';
6
6
  export { GraphSummary, graphCommand, graphSummary } from './commands/graph.js';
7
7
  export { KanbanGroupBy, KanbanImportChange, KanbanImportOptions, KanbanImportResult, KanbanLane, KanbanSyncOptions, KanbanSyncResult, ParsedKanbanBoard, ParsedKanbanLane, buildKanbanLanes, extractCardSlug, formatKanbanCard, generateKanbanMarkdown, importKanbanBoard, kanbanCommand, parseKanbanMarkdown, syncKanbanBoard } from './commands/kanban.js';
8
8
  export { C as ContextEntry, a as ContextFormat, b as ContextOptions, c as ContextProfile, d as ContextProfileInput, e as ContextProfileOption, f as ContextResult, R as ResolvedContextProfile, g as buildContext, h as contextCommand, i as formatContextMarkdown, j as inferContextProfile, n as normalizeContextProfileInput, r as registerContextCommand, k as resolveContextProfile } from './context-BUGaWpyL.js';
9
- export { I as InjectCommandOptions, a as InjectFormat, b as InjectMatch, c as InjectMatchReason, d as InjectMatchSource, e as InjectResult, f as InjectRuntimeOptions, g as InjectSourceCategory, h as InjectableItem, L as LlmCompletionOptions, i as LlmProvider, M as MEMORY_GRAPH_SCHEMA_VERSION, j as MemoryGraph, k as MemoryGraphEdge, l as MemoryGraphEdgeType, m as MemoryGraphIndex, n as MemoryGraphNode, o as MemoryGraphNodeType, p as MemoryGraphStats, q as buildInjectionResult, r as buildOrUpdateMemoryGraphIndex, s as deterministicInjectMatches, t as getMemoryGraph, u as indexInjectableItems, v as injectCommand, w as loadMemoryGraphIndex, x as registerInjectCommand, y as requestLlmCompletion, z as resolveLlmProvider, A as runPromptInjection } from './inject-Bzi5E-By.js';
9
+ import { L as LlmProvider } from './inject-DYUrDqQO.js';
10
+ export { I as InjectCommandOptions, a as InjectFormat, b as InjectMatch, c as InjectMatchReason, d as InjectMatchSource, e as InjectResult, f as InjectRuntimeOptions, g as InjectSourceCategory, h as InjectableItem, i as LlmCompletionOptions, M as MEMORY_GRAPH_SCHEMA_VERSION, j as MemoryGraph, k as MemoryGraphEdge, l as MemoryGraphEdgeType, m as MemoryGraphIndex, n as MemoryGraphNode, o as MemoryGraphNodeType, p as MemoryGraphStats, q as buildInjectionResult, r as buildOrUpdateMemoryGraphIndex, s as deterministicInjectMatches, t as getMemoryGraph, u as indexInjectableItems, v as injectCommand, w as loadMemoryGraphIndex, x as registerInjectCommand, y as requestLlmCompletion, z as resolveLlmProvider, A as runPromptInjection } from './inject-DYUrDqQO.js';
10
11
  export { ObserveCommandOptions, observeCommand, registerObserveCommand } from './commands/observe.js';
11
12
  export { ReflectCommandOptions, reflectCommand, registerReflectCommand } from './commands/reflect.js';
12
13
  export { ArchiveCommandOptions, archiveCommand, registerArchiveCommand } from './commands/archive.js';
13
14
  export { RebuildCommandOptions, rebuildCommand, registerRebuildCommand } from './commands/rebuild.js';
14
- export { DoctorCheck, DoctorReport, DoctorStatus, doctor } from './commands/doctor.js';
15
+ import { MigrationIssueType } from './commands/doctor.js';
16
+ export { DoctorCheck, DoctorReport, DoctorStatus, MigrationIssue, doctor } from './commands/doctor.js';
15
17
  export { EmbedCommandOptions, EmbedCommandResult, embedCommand, registerEmbedCommand } from './commands/embed.js';
16
18
  export { ReplayCommandOptions, registerReplayCommand, replayCommand } from './commands/replay.js';
17
19
  export { MigrateObservationsOptions, MigrateObservationsResult, migrateObservations, migrateObservationsCommand, registerMigrateObservationsCommand } from './commands/migrate-observations.js';
20
+ export { SyncBdCommandOptions, registerSyncBdCommand, syncBdCommand } from './commands/sync-bd.js';
18
21
  export { SessionRecapFormat, SessionRecapOptions, SessionRecapResult, SessionTurn, buildSessionRecap, formatSessionRecapMarkdown, sessionRecapCommand } from './commands/session-recap.js';
19
22
  export { findNearestVaultPath, getVaultPath, resolveVaultPath } from './lib/config.js';
20
23
  export { registerCliCommands } from './cli/index.js';
21
24
  import { TaskStatus } from './lib/task-utils.js';
22
25
  export { completeTask, listDependentTasks, listSubtasks, updateTask } from './lib/task-utils.js';
26
+ export { CLAWVAULT_SERVE_PATH, DEFAULT_SERVE_PORT, ServeInstance, TailscalePeer, TailscaleServeConfig, TailscaleStatus, TailscaleSyncOptions, TailscaleSyncResult, VaultFileEntry, VaultManifest, checkPeerClawVault, compareManifests, configureTailscaleServe, discoverClawVaultPeers, fetchRemoteFile, fetchRemoteManifest, findPeer, generateVaultManifest, getOnlinePeers, getTailscaleStatus, getTailscaleVersion, hasTailscale, pushFileToRemote, resolvePeerIP, serveVault, stopTailscaleServe, syncWithPeer } from './lib/tailscale.js';
27
+ export { TailscaleDiscoverCommandOptions, TailscaleServeCommandOptions, TailscaleStatusCommandOptions, TailscaleSyncCommandOptions, registerTailscaleCommands, registerTailscaleDiscoverCommand, registerTailscaleServeCommand, registerTailscaleStatusCommand, registerTailscaleSyncCommand, tailscaleDiscoverCommand, tailscaleServeCommand, tailscaleStatusCommand, tailscaleSyncCommand } from './commands/tailscale.js';
23
28
  export { TemplateVariables, buildTemplateVariables, renderTemplate } from './lib/template-engine.js';
24
29
  export { Project, ProjectFrontmatter, ProjectStatus, archiveProject, createProject, getProjectActivity, getProjectTasks, listProjects, readProject, updateProject } from './lib/project-utils.js';
30
+ import 'child_process';
31
+ import 'http';
25
32
 
26
33
  /**
27
34
  * ClawVault - The elephant's memory
@@ -152,6 +159,16 @@ declare class ClawVault {
152
159
  * Parse a handoff document back into structured form
153
160
  */
154
161
  private parseHandoff;
162
+ /**
163
+ * Safely convert a date value to ISO string format.
164
+ * Handles Date objects, strings, and undefined values.
165
+ */
166
+ private toDateString;
167
+ /**
168
+ * Extract the date portion (YYYY-MM-DD) from an ISO date string or Date object.
169
+ * Provides safe handling for various date formats.
170
+ */
171
+ private extractDatePart;
155
172
  private applyQmdConfig;
156
173
  private slugify;
157
174
  private saveIndex;
@@ -174,137 +191,52 @@ declare function createVault(vaultPath: string, options?: Partial<VaultConfig>,
174
191
  skipGraph?: boolean;
175
192
  }): Promise<ClawVault>;
176
193
 
177
- interface ReweaveCommandOptions {
194
+ interface MigrateCommandOptions {
178
195
  vaultPath?: string;
179
- since?: string;
180
196
  dryRun?: boolean;
181
- threshold?: number;
197
+ force?: boolean;
198
+ json?: boolean;
182
199
  }
183
- declare function reweaveCommand(options: ReweaveCommandOptions): Promise<void>;
184
- declare function registerReweaveCommand(program: Command): void;
185
-
186
- declare const OBSERVATION_TYPES: readonly ["decision", "preference", "fact", "commitment", "task", "todo", "commitment-unresolved", "milestone", "lesson", "relationship", "project"];
187
- type ObservationType = typeof OBSERVATION_TYPES[number];
188
- type LegacyObservationPriority = '🔴' | '🟡' | '🟢';
189
- type ObservationLineKind = 'scored' | 'emoji';
190
- interface ParsedObservationRecord {
191
- date: string;
192
- type: ObservationType;
193
- confidence: number;
194
- importance: number;
195
- content: string;
196
- format: ObservationLineKind;
197
- priority?: LegacyObservationPriority;
198
- time?: string;
199
- rawLine: string;
200
- }
201
-
202
- /**
203
- * Reweave — Backward memory consolidation for ClawVault
204
- *
205
- * When new observations are written, reweave performs a backward pass over
206
- * existing observations to detect knowledge updates (same entity, new value).
207
- * Older observations are marked as superseded so search always returns the
208
- * latest version of a fact.
209
- *
210
- * Design inspired by Ars Contexta's "notes are hypotheses" philosophy —
211
- * every observation is a claim that can be superseded by newer evidence.
212
- */
213
-
214
- interface SupersessionRecord {
215
- /** The older observation that was superseded */
216
- oldObservation: ParsedObservationRecord;
217
- /** The newer observation that supersedes it */
218
- newObservation: ParsedObservationRecord;
219
- /** File path of the older observation */
220
- oldFile: string;
221
- /** File path of the newer observation */
222
- newFile: string;
223
- /** Reason for supersession */
224
- reason: string;
225
- /** Timestamp of detection */
226
- detectedAt: string;
227
- }
228
- interface ReweaveResult {
229
- /** Number of observation files scanned */
230
- filesScanned: number;
231
- /** Number of individual observations checked */
232
- observationsChecked: number;
233
- /** Supersession records found/applied */
234
- supersessions: SupersessionRecord[];
235
- /** Whether this was a dry run */
236
- dryRun: boolean;
200
+ interface MigrationAction {
201
+ type: MigrationIssueType;
202
+ description: string;
203
+ success: boolean;
204
+ error?: string;
237
205
  }
238
- interface ReweaveOptions {
206
+ interface MigrateResult {
239
207
  vaultPath: string;
240
- /** Only process observations since this date (YYYY-MM-DD) */
241
- since?: string;
242
- /** Dry run — report but don't write */
243
- dryRun?: boolean;
244
- /** Similarity threshold for entity matching (0-1). Default 0.6 */
245
- similarityThreshold?: number;
208
+ issuesFound: number;
209
+ issuesFixed: number;
210
+ actions: MigrationAction[];
211
+ dryRun: boolean;
246
212
  }
247
- declare function isSuperseded(line: string): boolean;
248
- declare function getSupersessionInfo(line: string): {
249
- supersededBy: string;
250
- detectedAt: string;
251
- } | null;
252
- /**
253
- * Extract key entities/subjects from an observation for matching.
254
- * Returns normalized tokens that represent the "what" of the observation.
255
- */
256
- declare function extractEntities(content: string): string[];
257
- /**
258
- * Compute similarity between two observations based on entity overlap.
259
- * Returns 0-1 where 1 = identical entities.
260
- */
261
- declare function entitySimilarity(a: string[], b: string[]): number;
262
- /**
263
- * Check if two observations represent a knowledge update.
264
- * Both must be about the same entity/subject but with different values.
265
- *
266
- * Heuristic: high entity overlap + different observation content = update.
267
- * Same content = duplicate, not update.
268
- */
269
- declare function isKnowledgeUpdate(older: ParsedObservationRecord, newer: ParsedObservationRecord, threshold?: number): {
270
- isUpdate: boolean;
271
- reason: string;
272
- };
273
- /**
274
- * Run backward consolidation across observations.
275
- *
276
- * For each newer observation, check all older observations for knowledge updates.
277
- * When found, mark the older one as superseded.
278
- */
279
- declare function reweave(options: ReweaveOptions): ReweaveResult;
280
- /**
281
- * Filter search results to prefer latest versions of superseded observations.
282
- * When multiple observations cover the same entity, only keep the newest.
283
- *
284
- * This is called from the search pipeline to boost knowledge update accuracy.
285
- */
286
- declare function filterSuperseded(lines: string[]): string[];
287
- /**
288
- * Given observation markdown content, return only non-superseded lines.
289
- * Preserves date headings and structure.
290
- */
291
- declare function stripSupersededObservations(markdown: string): string;
213
+ declare function migrate(options?: MigrateCommandOptions): Promise<MigrateResult>;
214
+ declare function migrateCommand(options?: MigrateCommandOptions): Promise<MigrateResult>;
215
+ declare function registerMigrateCommand(program: Command): void;
292
216
 
293
217
  /**
294
218
  * ClawVault Search Engine - qmd Backend
295
219
  * Uses qmd CLI for BM25 and vector search
296
- *
297
- * v2.7.0 enhancements:
298
- * 1. Chunk-level BM25 pre-filtering (from eval v4 adapter)
299
- * 2. Exhaustive threshold-based retrieval (from eval v6 adapter)
300
- * 3. Preference extraction pipeline (from eval v3 adapter)
301
- * 4. Temporal date indexing at ingest time (from eval v8 design)
302
220
  */
303
221
 
304
222
  declare const QMD_INSTALL_URL = "https://github.com/tobi/qmd";
305
223
  declare const QMD_INSTALL_COMMAND = "bun install -g github:tobi/qmd";
224
+ type QmdErrorCode = 'NOT_INSTALLED' | 'NOT_CONFIGURED' | 'COLLECTION_NOT_FOUND' | 'EXECUTION_FAILED';
225
+ interface QmdErrorDetails {
226
+ code: QmdErrorCode;
227
+ message: string;
228
+ hint: string;
229
+ }
306
230
  declare class QmdUnavailableError extends Error {
307
- constructor(message?: string);
231
+ readonly code: QmdErrorCode;
232
+ readonly hint: string;
233
+ constructor(code?: QmdErrorCode, additionalContext?: string);
234
+ toUserMessage(): string;
235
+ }
236
+ declare function getQmdErrorDetails(code: QmdErrorCode): QmdErrorDetails;
237
+ declare class QmdConfigurationError extends Error {
238
+ readonly hint?: string | undefined;
239
+ constructor(message: string, hint?: string | undefined);
308
240
  }
309
241
  /**
310
242
  * Check if qmd is available
@@ -318,31 +250,6 @@ declare function qmdUpdate(collection?: string, indexName?: string): void;
318
250
  * Trigger qmd embed (create/update vector embeddings)
319
251
  */
320
252
  declare function qmdEmbed(collection?: string, indexName?: string): void;
321
- /**
322
- * Split text into ~maxChars sentence-aligned chunks with overlap.
323
- */
324
- declare function sentenceChunk(text: string, maxChars?: number, overlapSentences?: number): string[];
325
- /**
326
- * BM25-rank chunks within a document by keyword overlap.
327
- * Returns the top `max` chunks sorted by relevance, always including the
328
- * first chunk (session context) when available.
329
- */
330
- declare function bm25RankChunks(chunks: string[], terms: string[], max?: number): {
331
- text: string;
332
- score: number;
333
- }[];
334
- /**
335
- * Extract all date references from text content. Designed to run at ingest
336
- * time so temporal queries can use structured dates + JS arithmetic instead
337
- * of relying on LLM date math at query time.
338
- */
339
- declare function extractDates(text: string, sessionDateStr?: string): ExtractedDate[];
340
- /**
341
- * Extract user preferences from conversation text. Runs at ingest time to
342
- * build a structured preference index for personalised recommendations.
343
- */
344
- declare function extractPreferences(text: string, documentId?: string): ExtractedPreference[];
345
- declare function classifyQuestion(q: string): 'preference' | 'temporal' | 'aggregation' | 'default';
346
253
  /**
347
254
  * QMD Search Engine - wraps qmd CLI
348
255
  */
@@ -352,16 +259,14 @@ declare class SearchEngine {
352
259
  private vaultPath;
353
260
  private collectionRoot;
354
261
  private qmdIndexName?;
355
- /** v2.7 — Per-document date index built at ingest time */
356
- private dateIndex;
357
- /** v2.7 — Per-document preference index built at ingest time */
358
- private preferenceIndex;
359
- /** v2.7 — Per-document chunk cache for BM25 pre-filtering */
360
- private chunkCache;
361
262
  /**
362
263
  * Set the collection name (usually vault name)
363
264
  */
364
265
  setCollection(name: string): void;
266
+ /**
267
+ * Get the current collection name
268
+ */
269
+ getCollection(): string;
365
270
  /**
366
271
  * Set the vault path for file resolution
367
272
  */
@@ -375,8 +280,7 @@ declare class SearchEngine {
375
280
  */
376
281
  setIndexName(indexName?: string): void;
377
282
  /**
378
- * Add or update a document in the local cache.
379
- * v2.7: also extracts dates, preferences, and chunks at ingest time.
283
+ * Add or update a document in the local cache
380
284
  * Note: qmd indexing happens via qmd update command
381
285
  */
382
286
  addDocument(doc: Document): void;
@@ -401,32 +305,6 @@ declare class SearchEngine {
401
305
  */
402
306
  query(query: string, options?: SearchOptions): SearchResult[];
403
307
  private runQmdQuery;
404
- /**
405
- * v2.7 — Chunk-level BM25 pre-filtered search. Ranks chunks within each
406
- * document by keyword relevance before semantic ranking, so relevant
407
- * content deep in long documents isn't missed.
408
- *
409
- * Returns results with snippets from the best-matching chunks.
410
- */
411
- chunkPrefilterSearch(query: string, options?: SearchOptions): SearchResult[];
412
- /**
413
- * v2.7 — Exhaustive threshold-based search for aggregation queries.
414
- * Keeps pulling results until relevance drops below threshold.
415
- */
416
- exhaustiveSearch(query: string, threshold?: number, maxResults?: number): SearchResult[];
417
- /**
418
- * v2.7 — Get all extracted dates, optionally filtered by document ids.
419
- */
420
- getDates(documentIds?: string[]): ExtractedDate[];
421
- /**
422
- * v2.7 — Get all extracted preferences, optionally filtered by document ids.
423
- */
424
- getPreferences(documentIds?: string[]): ExtractedPreference[];
425
- /**
426
- * v2.7 — Search with automatic strategy selection based on question type.
427
- * Classifies the query and routes to the appropriate pipeline.
428
- */
429
- smartQuery(query: string, options?: SearchOptions): SearchResult[];
430
308
  /**
431
309
  * Convert qmd results to ClawVault SearchResult format
432
310
  */
@@ -437,11 +315,6 @@ declare class SearchEngine {
437
315
  * Convert qmd:// URI to file path
438
316
  */
439
317
  private qmdUriToPath;
440
- /**
441
- * v2.8 — Filter superseded observation lines from snippet text.
442
- * Ensures search results prefer the latest version of knowledge.
443
- */
444
- private stripSupersededFromSnippet;
445
318
  /**
446
319
  * Clean up qmd snippet format
447
320
  */
@@ -455,7 +328,7 @@ declare class SearchEngine {
455
328
  */
456
329
  get size(): number;
457
330
  /**
458
- * Clear the local document cache and all v2.7 indices
331
+ * Clear the local document cache
459
332
  */
460
333
  clear(): void;
461
334
  /**
@@ -480,15 +353,93 @@ declare function extractWikiLinks(content: string): string[];
480
353
  */
481
354
  declare function extractTags(content: string): string[];
482
355
 
483
- declare const OBSERVE_PROVIDERS: readonly ["anthropic", "openai", "gemini"];
484
- declare const OBSERVER_COMPRESSION_PROVIDERS: readonly ["anthropic", "openai", "gemini", "openai-compatible", "ollama"];
356
+ /**
357
+ * ClawVault Hybrid Search BM25 + Semantic Embeddings + RRF
358
+ *
359
+ * Proven in LongMemEval benchmarks:
360
+ * - v28 pipeline: 57.0% overall (up from 52.6% with BM25-only)
361
+ * - Multi-session: 45.9% (up from 28.6%)
362
+ * - Single-session-user: 85.7% (up from 72.9%)
363
+ *
364
+ * Architecture:
365
+ * 1. BM25 via existing qmd search
366
+ * 2. Semantic via @huggingface/transformers (all-MiniLM-L6-v2)
367
+ * 3. Reciprocal Rank Fusion (k=60)
368
+ */
369
+
370
+ /**
371
+ * Compute embedding for a text string
372
+ */
373
+ declare function embed(text: string): Promise<Float32Array>;
374
+ /**
375
+ * Compute embeddings for multiple texts
376
+ */
377
+ declare function embedBatch(texts: string[]): Promise<Float32Array[]>;
378
+ /**
379
+ * Cosine similarity between two normalized vectors
380
+ */
381
+ declare function cosineSimilarity(a: Float32Array, b: Float32Array): number;
382
+ /**
383
+ * Embedding cache — stores embeddings on disk alongside vault files
384
+ */
385
+ declare class EmbeddingCache {
386
+ private cachePath;
387
+ private cache;
388
+ private dirty;
389
+ constructor(vaultPath: string);
390
+ /**
391
+ * Load cache from disk
392
+ */
393
+ load(): void;
394
+ /**
395
+ * Save cache to disk
396
+ */
397
+ save(): void;
398
+ get(key: string): Float32Array | undefined;
399
+ set(key: string, embedding: Float32Array): void;
400
+ has(key: string): boolean;
401
+ entries(): IterableIterator<[string, Float32Array]>;
402
+ get size(): number;
403
+ }
404
+ /**
405
+ * Reciprocal Rank Fusion of two ranked lists
406
+ */
407
+ declare function reciprocalRankFusion(list1: {
408
+ id: string;
409
+ score: number;
410
+ }[], list2: {
411
+ id: string;
412
+ score: number;
413
+ }[], k?: number): {
414
+ id: string;
415
+ score: number;
416
+ }[];
417
+ /**
418
+ * Semantic search against embedding cache
419
+ */
420
+ declare function semanticSearch(query: string, cache: EmbeddingCache, topK?: number): Promise<{
421
+ id: string;
422
+ score: number;
423
+ }[]>;
424
+ /**
425
+ * Hybrid search: combines BM25 results with semantic results via RRF
426
+ */
427
+ declare function hybridSearch(query: string, bm25Results: SearchResult[], cache: EmbeddingCache, options?: {
428
+ topK?: number;
429
+ rrfK?: number;
430
+ }): Promise<SearchResult[]>;
431
+
432
+ declare const OBSERVE_PROVIDERS: readonly ["anthropic", "openai", "gemini", "xai", "openclaw"];
433
+ declare const OBSERVER_COMPRESSION_PROVIDERS: readonly ["anthropic", "openai", "gemini", "xai", "openai-compatible", "ollama", "openclaw", "minimax", "zai"];
485
434
  declare const THEMES: readonly ["neural", "minimal", "none"];
486
435
  declare const CONTEXT_PROFILES: readonly ["default", "planning", "incident", "handoff", "auto"];
436
+ declare const FACT_EXTRACTION_MODES: readonly ["off", "rule", "llm", "hybrid"];
487
437
  type ObserveProvider = (typeof OBSERVE_PROVIDERS)[number];
488
438
  type ObserverCompressionProvider = (typeof OBSERVER_COMPRESSION_PROVIDERS)[number];
489
439
  type Theme = (typeof THEMES)[number];
490
440
  type ContextProfile = (typeof CONTEXT_PROFILES)[number];
491
- type ManagedConfigKey = 'name' | 'categories' | 'theme' | 'observe.model' | 'observe.provider' | 'observer.compression.provider' | 'observer.compression.model' | 'observer.compression.baseUrl' | 'observer.compression.apiKey' | 'context.maxResults' | 'context.defaultProfile' | 'graph.maxHops' | 'inject.maxResults' | 'inject.useLlm' | 'inject.scope';
441
+ type FactExtractionMode$1 = (typeof FACT_EXTRACTION_MODES)[number];
442
+ type ManagedConfigKey = 'name' | 'categories' | 'theme' | 'observe.model' | 'observe.provider' | 'observer.compression.provider' | 'observer.compression.model' | 'observer.compression.baseUrl' | 'observer.compression.apiKey' | 'observer.factExtractionMode' | 'context.maxResults' | 'context.defaultProfile' | 'graph.maxHops' | 'inject.maxResults' | 'inject.useLlm' | 'inject.scope';
492
443
  interface RouteRule {
493
444
  pattern: string;
494
445
  target: string;
@@ -509,6 +460,198 @@ declare function removeRouteRule(vaultPath: string, pattern: string): boolean;
509
460
  declare function matchRouteRule(text: string, routes: RouteRule[]): RouteRule | null;
510
461
  declare function testRouteRule(vaultPath: string, text: string): RouteRule | null;
511
462
 
463
+ /**
464
+ * LLM Adapter for fact extraction.
465
+ *
466
+ * Provides a unified interface for calling LLMs to extract facts from text.
467
+ * Currently supports Gemini Flash as the primary adapter, with fallback to
468
+ * the existing LLM provider infrastructure.
469
+ */
470
+
471
+ type FactExtractionMode = 'off' | 'rule' | 'llm' | 'hybrid';
472
+ interface LlmAdapterOptions {
473
+ provider?: LlmProvider | null;
474
+ model?: string;
475
+ temperature?: number;
476
+ maxTokens?: number;
477
+ fetchImpl?: typeof fetch;
478
+ }
479
+ interface LlmAdapter {
480
+ /**
481
+ * Call the LLM with a prompt and return the response text.
482
+ */
483
+ call(prompt: string): Promise<string>;
484
+ /**
485
+ * Check if the adapter is available (has valid credentials).
486
+ */
487
+ isAvailable(): boolean;
488
+ /**
489
+ * Get the provider name for this adapter.
490
+ */
491
+ getProvider(): LlmProvider | null;
492
+ }
493
+ /**
494
+ * Create a Gemini Flash adapter for fact extraction.
495
+ * Uses the Gemini API with the flash model optimized for speed.
496
+ */
497
+ declare function createGeminiFlashAdapter(options?: LlmAdapterOptions): LlmAdapter;
498
+ /**
499
+ * Create an LLM adapter using the default provider resolution.
500
+ * Falls back through providers: openclaw -> anthropic -> openai -> gemini -> xai
501
+ */
502
+ declare function createDefaultAdapter(options?: LlmAdapterOptions): LlmAdapter;
503
+ /**
504
+ * Create an LLM adapter for fact extraction based on configuration.
505
+ *
506
+ * Priority:
507
+ * 1. If provider is explicitly specified, use that
508
+ * 2. If Gemini API key is available, prefer Gemini Flash for speed
509
+ * 3. If Ollama is running locally, use Ollama (free, always available)
510
+ * 4. Fall back to default provider resolution
511
+ */
512
+ declare function createFactExtractionAdapter(options?: LlmAdapterOptions): LlmAdapter;
513
+ /**
514
+ * Create an LLM function compatible with extractFactsLlm.
515
+ * This wraps the adapter into the function signature expected by fact-extractor.ts.
516
+ */
517
+ declare function createLlmFunction(adapter: LlmAdapter): ((prompt: string) => Promise<string>) | undefined;
518
+ /**
519
+ * Resolve the effective fact extraction mode based on configuration and availability.
520
+ *
521
+ * - 'off': Never extract facts
522
+ * - 'rule': Only use rule-based extraction (no LLM)
523
+ * - 'llm': Prefer LLM extraction, fall back to rules if LLM unavailable
524
+ * - 'hybrid': Use both LLM and rules, merge results (future enhancement)
525
+ */
526
+ declare function resolveFactExtractionMode(configuredMode: FactExtractionMode | undefined, adapter?: LlmAdapter): {
527
+ mode: FactExtractionMode;
528
+ useLlm: boolean;
529
+ };
530
+
531
+ /**
532
+ * Write-time fact extraction for ClawVault v3.
533
+ *
534
+ * When a memory is stored, this module extracts structured facts:
535
+ * (entity, relation, value, timestamp, confidence)
536
+ *
537
+ * Two modes:
538
+ * 1. LLM extraction (accurate but requires API key)
539
+ * 2. Rule-based extraction (fast, no deps, lower quality)
540
+ *
541
+ * Extracted facts are stored alongside raw markdown in .clawvault/facts.jsonl
542
+ * and used to build the entity-relationship graph.
543
+ */
544
+ interface ExtractedFact {
545
+ /** Unique ID for this fact */
546
+ id: string;
547
+ /** The entity this fact is about (person, place, thing) */
548
+ entity: string;
549
+ /** Normalized entity name for dedup */
550
+ entityNorm: string;
551
+ /** Relationship type (e.g., "prefers", "works_at", "lives_in", "bought") */
552
+ relation: string;
553
+ /** The value/object of the relation */
554
+ value: string;
555
+ /** When this fact was established */
556
+ validFrom: string;
557
+ /** When this fact was superseded (null = still current) */
558
+ validUntil: string | null;
559
+ /** Confidence 0-1 */
560
+ confidence: number;
561
+ /** Category: preference, fact, decision, entity, event */
562
+ category: 'preference' | 'fact' | 'decision' | 'entity' | 'event' | 'other';
563
+ /** Source file path (relative to vault) */
564
+ source: string;
565
+ /** Raw text this was extracted from */
566
+ rawText: string;
567
+ }
568
+ interface ExtractionResult {
569
+ facts: ExtractedFact[];
570
+ /** Number of conflicts resolved (existing facts updated) */
571
+ conflictsResolved: number;
572
+ /** Processing time in ms */
573
+ durationMs: number;
574
+ }
575
+ /**
576
+ * Normalize an entity name for dedup matching.
577
+ * "Pedro Sobral" -> "pedro sobral"
578
+ * "pedro" -> "pedro"
579
+ * "Dr. Smith" -> "dr smith"
580
+ */
581
+ declare function normalizeEntity(name: string): string;
582
+ /**
583
+ * Generate a deterministic fact ID from entity + relation + value.
584
+ */
585
+ declare function factId(entity: string, relation: string, value: string): string;
586
+ /**
587
+ * Extract facts from raw text using rule-based patterns.
588
+ * Fast, no LLM needed, but lower quality.
589
+ */
590
+ declare function extractFactsRuleBased(text: string, source: string, timestamp?: string): ExtractedFact[];
591
+ /**
592
+ * Extract facts using an LLM. Higher quality but requires API key.
593
+ * Falls back to rule-based if LLM unavailable.
594
+ */
595
+ declare function extractFactsLlm(text: string, source: string, timestamp?: string, llmFn?: (prompt: string) => Promise<string>): Promise<ExtractedFact[]>;
596
+
597
+ /**
598
+ * Fact Store — persistent storage + conflict resolution for extracted facts.
599
+ *
600
+ * Facts are stored in .clawvault/facts.jsonl (append-only log).
601
+ * An in-memory index enables fast lookup by entity, relation, category.
602
+ * Conflict resolution: when a new fact matches an existing one by entity+relation,
603
+ * the old fact gets validUntil set and the new fact replaces it.
604
+ */
605
+
606
+ interface FactStoreStats {
607
+ totalFacts: number;
608
+ activeFacts: number;
609
+ supersededFacts: number;
610
+ entities: number;
611
+ relations: number;
612
+ }
613
+ declare class FactStore {
614
+ private facts;
615
+ private byEntity;
616
+ private byRelation;
617
+ private byCategory;
618
+ private factsPath;
619
+ private dirty;
620
+ constructor(vaultPath: string);
621
+ /** Load facts from disk */
622
+ load(): void;
623
+ /** Add facts with conflict resolution. Returns number of conflicts resolved. */
624
+ addFacts(newFacts: ExtractedFact[]): number;
625
+ /** Find an existing fact that conflicts with the new one */
626
+ private findConflict;
627
+ /** Check if two values are similar enough to be considered the same fact */
628
+ private isSimilarValue;
629
+ /** Relations where only one value can be active at a time */
630
+ private isExclusiveRelation;
631
+ /** Index a fact in all lookup maps */
632
+ private indexFact;
633
+ /** Save facts to disk (full rewrite for consistency) */
634
+ save(): void;
635
+ /** Append new facts to disk (faster than full rewrite) */
636
+ append(facts: ExtractedFact[]): void;
637
+ /** Get all active facts for an entity */
638
+ getEntityFacts(entity: string): ExtractedFact[];
639
+ /** Get all active facts for a relation */
640
+ getRelationFacts(relation: string): ExtractedFact[];
641
+ /** Get all active facts in a category */
642
+ getCategoryFacts(category: string): ExtractedFact[];
643
+ /** Get all active preferences */
644
+ getPreferences(): ExtractedFact[];
645
+ /** Search facts by text query (simple keyword match) */
646
+ searchFacts(query: string): ExtractedFact[];
647
+ /** Get facts valid at a specific time */
648
+ getFactsAt(timestamp: string): ExtractedFact[];
649
+ /** Get stats */
650
+ stats(): FactStoreStats;
651
+ /** Get all facts (for testing/debugging) */
652
+ getAllFacts(): ExtractedFact[];
653
+ }
654
+
512
655
  /**
513
656
  * Transition Ledger for ClawVault
514
657
  * Logs task status transitions to JSONL files and supports querying.
@@ -565,7 +708,7 @@ interface CompressorOptions {
565
708
  now?: () => Date;
566
709
  fetchImpl?: typeof fetch;
567
710
  }
568
- type CompressionProvider = 'anthropic' | 'openai' | 'gemini' | 'openai-compatible' | 'ollama';
711
+ type CompressionProvider = 'anthropic' | 'openai' | 'gemini' | 'xai' | 'openai-compatible' | 'ollama' | 'minimax' | 'zai';
569
712
  declare class Compressor {
570
713
  private readonly provider?;
571
714
  private readonly model?;
@@ -575,6 +718,13 @@ declare class Compressor {
575
718
  private readonly fetchImpl;
576
719
  constructor(options?: CompressorOptions);
577
720
  compress(messages: string[], existingObservations: string): Promise<string>;
721
+ private sanitizeIncomingMessages;
722
+ private sanitizeIncomingMessage;
723
+ private normalizeMessageRole;
724
+ private isConversationRolePrefix;
725
+ private shouldDropMessageRole;
726
+ private stripNoisyData;
727
+ private isLikelyStructuredNoise;
578
728
  private resolveProvider;
579
729
  private resolveConfiguredProvider;
580
730
  private resolveProviderFromEnv;
@@ -588,6 +738,7 @@ declare class Compressor {
588
738
  private extractOpenAIContent;
589
739
  private callAnthropic;
590
740
  private callOpenAI;
741
+ private callXAI;
591
742
  private callOpenAICompatible;
592
743
  private callGemini;
593
744
  private normalizeLlmOutput;
@@ -696,7 +847,6 @@ interface ActiveObserveOptions {
696
847
  reflectThreshold?: number;
697
848
  model?: string;
698
849
  extractTasks?: boolean;
699
- maxSessions?: number;
700
850
  }
701
851
  interface ActiveObservationCandidate {
702
852
  sessionId: string;
@@ -851,4 +1001,4 @@ declare function runReflection(options: ReflectOptions): Promise<ReflectResult>;
851
1001
  declare const VERSION: string;
852
1002
  declare function registerCommanderCommands(program: Command): Command;
853
1003
 
854
- export { type ActiveObservationCandidate, type ActiveObservationFailure, type ActiveObserveOptions, type ActiveObserveResult, type ArchiveObservationsOptions, type ArchiveObservationsResult, Category, ClawVault, type CompressionProvider, Compressor, type CompressorOptions, type ContextProfile as ConfigDefaultProfile, Document, ExtractedDate, ExtractedPreference, HandoffDocument, type ManagedConfigKey, MemoryType, type ObserveCursorEntry, type ObserveCursorStore, type ObserveProvider, Observer, type ObserverCompressionProvider, type ObserverCompressor, type ObserverOptions, type ObserverReflector, type ObserverStalenessResult, QMD_INSTALL_COMMAND, QMD_INSTALL_URL, QmdUnavailableError, type ReflectOptions, type ReflectResult, Reflector, type ReflectorOptions, type ReweaveOptions, type ReweaveResult, type RouteRule, SUPPORTED_CONFIG_KEYS, SearchEngine, SearchOptions, SearchResult, SessionRecap, SessionWatcher, type SessionWatcherOptions, StoreOptions, type SupersessionRecord, SyncOptions, SyncResult, type Theme, type TransitionEvent, VERSION, VaultConfig, addRouteRule, appendTransition, archiveObservations, bm25RankChunks, buildTransitionEvent, classifyQuestion, countBlockedTransitions, createVault, entitySimilarity, extractDates, extractEntities, extractPreferences, extractTags, extractWikiLinks, filterSuperseded, findVault, formatTransitionsTable, getConfig, getConfigValue, getObserverStaleness, getScaledObservationThresholdBytes, getSupersessionInfo, hasQmd, isKnowledgeUpdate, isRegression, isSuperseded, listConfig, listRouteRules, matchRouteRule, observeActiveSessions, parseSessionFile, parseSessionSourceLabel, qmdEmbed, qmdUpdate, queryTransitions, readAllTransitions, registerCommanderCommands, registerReweaveCommand, removeRouteRule, resetConfig, reweave, reweaveCommand, runReflection, sentenceChunk, setConfigValue, stripSupersededObservations, testRouteRule };
1004
+ export { type ActiveObservationCandidate, type ActiveObservationFailure, type ActiveObserveOptions, type ActiveObserveResult, type ArchiveObservationsOptions, type ArchiveObservationsResult, Category, ClawVault, type CompressionProvider, Compressor, type CompressorOptions, type ContextProfile as ConfigDefaultProfile, Document, EmbeddingCache, type ExtractedFact, type ExtractionResult, type FactExtractionMode$1 as FactExtractionMode, FactStore, type FactStoreStats, HandoffDocument, type LlmAdapter, type LlmAdapterOptions, LlmProvider, type ManagedConfigKey, MemoryType, type MigrateCommandOptions, type MigrateResult, type MigrationAction, MigrationIssueType, type ObserveCursorEntry, type ObserveCursorStore, type ObserveProvider, Observer, type ObserverCompressionProvider, type ObserverCompressor, type ObserverOptions, type ObserverReflector, type ObserverStalenessResult, QMD_INSTALL_COMMAND, QMD_INSTALL_URL, QmdConfigurationError, type QmdErrorCode, type QmdErrorDetails, QmdUnavailableError, type ReflectOptions, type ReflectResult, Reflector, type ReflectorOptions, type RouteRule, SUPPORTED_CONFIG_KEYS, SearchEngine, SearchOptions, SearchResult, SessionRecap, SessionWatcher, type SessionWatcherOptions, StoreOptions, SyncOptions, SyncResult, type Theme, type TransitionEvent, VERSION, VaultConfig, addRouteRule, appendTransition, archiveObservations, buildTransitionEvent, cosineSimilarity, countBlockedTransitions, createDefaultAdapter, createFactExtractionAdapter, createGeminiFlashAdapter, createLlmFunction, createVault, embed, embedBatch, extractFactsLlm, extractFactsRuleBased, extractTags, extractWikiLinks, factId, findVault, formatTransitionsTable, getConfig, getConfigValue, getObserverStaleness, getQmdErrorDetails, getScaledObservationThresholdBytes, hasQmd, hybridSearch, isRegression, listConfig, listRouteRules, matchRouteRule, migrate, migrateCommand, normalizeEntity, observeActiveSessions, parseSessionFile, parseSessionSourceLabel, qmdEmbed, qmdUpdate, queryTransitions, readAllTransitions, reciprocalRankFusion, registerCommanderCommands, registerMigrateCommand, removeRouteRule, resetConfig, resolveFactExtractionMode, runReflection, semanticSearch, setConfigValue, testRouteRule };