@facthouse/mcp 0.26.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 (413) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +611 -0
  3. package/dist/cli/index.d.ts +30 -0
  4. package/dist/cli/index.d.ts.map +1 -0
  5. package/dist/cli/index.js +785 -0
  6. package/dist/cli/index.js.map +1 -0
  7. package/dist/cli/init-backfill.d.ts +26 -0
  8. package/dist/cli/init-backfill.d.ts.map +1 -0
  9. package/dist/cli/init-backfill.js +56 -0
  10. package/dist/cli/init-backfill.js.map +1 -0
  11. package/dist/cli/init-knobs.d.ts +137 -0
  12. package/dist/cli/init-knobs.d.ts.map +1 -0
  13. package/dist/cli/init-knobs.js +400 -0
  14. package/dist/cli/init-knobs.js.map +1 -0
  15. package/dist/cli/init-wizard.d.ts +67 -0
  16. package/dist/cli/init-wizard.d.ts.map +1 -0
  17. package/dist/cli/init-wizard.js +319 -0
  18. package/dist/cli/init-wizard.js.map +1 -0
  19. package/dist/cli/init.d.ts +124 -0
  20. package/dist/cli/init.d.ts.map +1 -0
  21. package/dist/cli/init.js +286 -0
  22. package/dist/cli/init.js.map +1 -0
  23. package/dist/cli/inspect-html.d.ts +15 -0
  24. package/dist/cli/inspect-html.d.ts.map +1 -0
  25. package/dist/cli/inspect-html.js +491 -0
  26. package/dist/cli/inspect-html.js.map +1 -0
  27. package/dist/cli/inspect-intelligence.d.ts +8 -0
  28. package/dist/cli/inspect-intelligence.d.ts.map +1 -0
  29. package/dist/cli/inspect-intelligence.js +103 -0
  30. package/dist/cli/inspect-intelligence.js.map +1 -0
  31. package/dist/cli/inspect-model.d.ts +42 -0
  32. package/dist/cli/inspect-model.d.ts.map +1 -0
  33. package/dist/cli/inspect-model.js +108 -0
  34. package/dist/cli/inspect-model.js.map +1 -0
  35. package/dist/cli/inspect-payload.d.ts +122 -0
  36. package/dist/cli/inspect-payload.d.ts.map +1 -0
  37. package/dist/cli/inspect-payload.js +338 -0
  38. package/dist/cli/inspect-payload.js.map +1 -0
  39. package/dist/cli/inspect-theme.d.ts +44 -0
  40. package/dist/cli/inspect-theme.d.ts.map +1 -0
  41. package/dist/cli/inspect-theme.js +118 -0
  42. package/dist/cli/inspect-theme.js.map +1 -0
  43. package/dist/cli/inspect.d.ts +24 -0
  44. package/dist/cli/inspect.d.ts.map +1 -0
  45. package/dist/cli/inspect.js +172 -0
  46. package/dist/cli/inspect.js.map +1 -0
  47. package/dist/cli/log-event.d.ts +55 -0
  48. package/dist/cli/log-event.d.ts.map +1 -0
  49. package/dist/cli/log-event.js +149 -0
  50. package/dist/cli/log-event.js.map +1 -0
  51. package/dist/cli/package-version.d.ts +2 -0
  52. package/dist/cli/package-version.d.ts.map +1 -0
  53. package/dist/cli/package-version.js +15 -0
  54. package/dist/cli/package-version.js.map +1 -0
  55. package/dist/cli/query.d.ts +53 -0
  56. package/dist/cli/query.d.ts.map +1 -0
  57. package/dist/cli/query.js +325 -0
  58. package/dist/cli/query.js.map +1 -0
  59. package/dist/cli/record.d.ts +55 -0
  60. package/dist/cli/record.d.ts.map +1 -0
  61. package/dist/cli/record.js +149 -0
  62. package/dist/cli/record.js.map +1 -0
  63. package/dist/cli/settings.d.ts +26 -0
  64. package/dist/cli/settings.d.ts.map +1 -0
  65. package/dist/cli/settings.js +161 -0
  66. package/dist/cli/settings.js.map +1 -0
  67. package/dist/cli/spend-dashboard.d.ts +53 -0
  68. package/dist/cli/spend-dashboard.d.ts.map +1 -0
  69. package/dist/cli/spend-dashboard.js +297 -0
  70. package/dist/cli/spend-dashboard.js.map +1 -0
  71. package/dist/cli/stats-html.d.ts +20 -0
  72. package/dist/cli/stats-html.d.ts.map +1 -0
  73. package/dist/cli/stats-html.js +879 -0
  74. package/dist/cli/stats-html.js.map +1 -0
  75. package/dist/cli/web.d.ts +60 -0
  76. package/dist/cli/web.d.ts.map +1 -0
  77. package/dist/cli/web.js +416 -0
  78. package/dist/cli/web.js.map +1 -0
  79. package/dist/config.d.ts +102 -0
  80. package/dist/config.d.ts.map +1 -0
  81. package/dist/config.js +302 -0
  82. package/dist/config.js.map +1 -0
  83. package/dist/db/connection.d.ts +96 -0
  84. package/dist/db/connection.d.ts.map +1 -0
  85. package/dist/db/connection.js +200 -0
  86. package/dist/db/connection.js.map +1 -0
  87. package/dist/db/consolidation-lock.d.ts +16 -0
  88. package/dist/db/consolidation-lock.d.ts.map +1 -0
  89. package/dist/db/consolidation-lock.js +67 -0
  90. package/dist/db/consolidation-lock.js.map +1 -0
  91. package/dist/db/consolidations.d.ts +41 -0
  92. package/dist/db/consolidations.d.ts.map +1 -0
  93. package/dist/db/consolidations.js +165 -0
  94. package/dist/db/consolidations.js.map +1 -0
  95. package/dist/db/disk-budget.d.ts +44 -0
  96. package/dist/db/disk-budget.d.ts.map +1 -0
  97. package/dist/db/disk-budget.js +177 -0
  98. package/dist/db/disk-budget.js.map +1 -0
  99. package/dist/db/domains.d.ts +14 -0
  100. package/dist/db/domains.d.ts.map +1 -0
  101. package/dist/db/domains.js +37 -0
  102. package/dist/db/domains.js.map +1 -0
  103. package/dist/db/embeddings-hnsw.d.ts +30 -0
  104. package/dist/db/embeddings-hnsw.d.ts.map +1 -0
  105. package/dist/db/embeddings-hnsw.js +129 -0
  106. package/dist/db/embeddings-hnsw.js.map +1 -0
  107. package/dist/db/embeddings.d.ts +68 -0
  108. package/dist/db/embeddings.d.ts.map +1 -0
  109. package/dist/db/embeddings.js +139 -0
  110. package/dist/db/embeddings.js.map +1 -0
  111. package/dist/db/entities.d.ts +157 -0
  112. package/dist/db/entities.d.ts.map +1 -0
  113. package/dist/db/entities.js +489 -0
  114. package/dist/db/entities.js.map +1 -0
  115. package/dist/db/extract-watermarks.d.ts +55 -0
  116. package/dist/db/extract-watermarks.d.ts.map +1 -0
  117. package/dist/db/extract-watermarks.js +171 -0
  118. package/dist/db/extract-watermarks.js.map +1 -0
  119. package/dist/db/facts.d.ts +117 -0
  120. package/dist/db/facts.d.ts.map +1 -0
  121. package/dist/db/facts.js +326 -0
  122. package/dist/db/facts.js.map +1 -0
  123. package/dist/db/index.d.ts +26 -0
  124. package/dist/db/index.d.ts.map +1 -0
  125. package/dist/db/index.js +23 -0
  126. package/dist/db/index.js.map +1 -0
  127. package/dist/db/inferences.d.ts +36 -0
  128. package/dist/db/inferences.d.ts.map +1 -0
  129. package/dist/db/inferences.js +212 -0
  130. package/dist/db/inferences.js.map +1 -0
  131. package/dist/db/intelligence-runs.d.ts +20 -0
  132. package/dist/db/intelligence-runs.d.ts.map +1 -0
  133. package/dist/db/intelligence-runs.js +60 -0
  134. package/dist/db/intelligence-runs.js.map +1 -0
  135. package/dist/db/pg-backend.d.ts +14 -0
  136. package/dist/db/pg-backend.d.ts.map +1 -0
  137. package/dist/db/pg-backend.js +53 -0
  138. package/dist/db/pg-backend.js.map +1 -0
  139. package/dist/db/postgres-schema.d.ts +13 -0
  140. package/dist/db/postgres-schema.d.ts.map +1 -0
  141. package/dist/db/postgres-schema.js +392 -0
  142. package/dist/db/postgres-schema.js.map +1 -0
  143. package/dist/db/postgres.d.ts +30 -0
  144. package/dist/db/postgres.d.ts.map +1 -0
  145. package/dist/db/postgres.js +154 -0
  146. package/dist/db/postgres.js.map +1 -0
  147. package/dist/db/prune.d.ts +67 -0
  148. package/dist/db/prune.d.ts.map +1 -0
  149. package/dist/db/prune.js +113 -0
  150. package/dist/db/prune.js.map +1 -0
  151. package/dist/db/scheduler-signal.d.ts +20 -0
  152. package/dist/db/scheduler-signal.d.ts.map +1 -0
  153. package/dist/db/scheduler-signal.js +32 -0
  154. package/dist/db/scheduler-signal.js.map +1 -0
  155. package/dist/db/schema-version.d.ts +7 -0
  156. package/dist/db/schema-version.d.ts.map +1 -0
  157. package/dist/db/schema-version.js +7 -0
  158. package/dist/db/schema-version.js.map +1 -0
  159. package/dist/db/schema.d.ts +12 -0
  160. package/dist/db/schema.d.ts.map +1 -0
  161. package/dist/db/schema.js +983 -0
  162. package/dist/db/schema.js.map +1 -0
  163. package/dist/db/session-facts.d.ts +108 -0
  164. package/dist/db/session-facts.d.ts.map +1 -0
  165. package/dist/db/session-facts.js +244 -0
  166. package/dist/db/session-facts.js.map +1 -0
  167. package/dist/db/sessions.d.ts +85 -0
  168. package/dist/db/sessions.d.ts.map +1 -0
  169. package/dist/db/sessions.js +169 -0
  170. package/dist/db/sessions.js.map +1 -0
  171. package/dist/db/sources.d.ts +22 -0
  172. package/dist/db/sources.d.ts.map +1 -0
  173. package/dist/db/sources.js +43 -0
  174. package/dist/db/sources.js.map +1 -0
  175. package/dist/db/stats.d.ts +94 -0
  176. package/dist/db/stats.d.ts.map +1 -0
  177. package/dist/db/stats.js +79 -0
  178. package/dist/db/stats.js.map +1 -0
  179. package/dist/db/store.d.ts +19 -0
  180. package/dist/db/store.d.ts.map +1 -0
  181. package/dist/db/store.js +58 -0
  182. package/dist/db/store.js.map +1 -0
  183. package/dist/db/watermarks.d.ts +20 -0
  184. package/dist/db/watermarks.d.ts.map +1 -0
  185. package/dist/db/watermarks.js +30 -0
  186. package/dist/db/watermarks.js.map +1 -0
  187. package/dist/embedding/ollama.d.ts +31 -0
  188. package/dist/embedding/ollama.d.ts.map +1 -0
  189. package/dist/embedding/ollama.js +148 -0
  190. package/dist/embedding/ollama.js.map +1 -0
  191. package/dist/embedding/provider.d.ts +37 -0
  192. package/dist/embedding/provider.d.ts.map +1 -0
  193. package/dist/embedding/provider.js +71 -0
  194. package/dist/embedding/provider.js.map +1 -0
  195. package/dist/embedding/types.d.ts +61 -0
  196. package/dist/embedding/types.d.ts.map +1 -0
  197. package/dist/embedding/types.js +13 -0
  198. package/dist/embedding/types.js.map +1 -0
  199. package/dist/embedding/voyage.d.ts +31 -0
  200. package/dist/embedding/voyage.d.ts.map +1 -0
  201. package/dist/embedding/voyage.js +105 -0
  202. package/dist/embedding/voyage.js.map +1 -0
  203. package/dist/identity.d.ts +32 -0
  204. package/dist/identity.d.ts.map +1 -0
  205. package/dist/identity.js +53 -0
  206. package/dist/identity.js.map +1 -0
  207. package/dist/index.d.ts +9 -0
  208. package/dist/index.d.ts.map +1 -0
  209. package/dist/index.js +275 -0
  210. package/dist/index.js.map +1 -0
  211. package/dist/intelligence/backing.d.ts +19 -0
  212. package/dist/intelligence/backing.d.ts.map +1 -0
  213. package/dist/intelligence/backing.js +88 -0
  214. package/dist/intelligence/backing.js.map +1 -0
  215. package/dist/intelligence/cli.d.ts +90 -0
  216. package/dist/intelligence/cli.d.ts.map +1 -0
  217. package/dist/intelligence/cli.js +823 -0
  218. package/dist/intelligence/cli.js.map +1 -0
  219. package/dist/intelligence/consolidate.d.ts +84 -0
  220. package/dist/intelligence/consolidate.d.ts.map +1 -0
  221. package/dist/intelligence/consolidate.js +1234 -0
  222. package/dist/intelligence/consolidate.js.map +1 -0
  223. package/dist/intelligence/extract-prompt.d.ts +78 -0
  224. package/dist/intelligence/extract-prompt.d.ts.map +1 -0
  225. package/dist/intelligence/extract-prompt.js +146 -0
  226. package/dist/intelligence/extract-prompt.js.map +1 -0
  227. package/dist/intelligence/heuristic.d.ts +15 -0
  228. package/dist/intelligence/heuristic.d.ts.map +1 -0
  229. package/dist/intelligence/heuristic.js +224 -0
  230. package/dist/intelligence/heuristic.js.map +1 -0
  231. package/dist/intelligence/http.d.ts +77 -0
  232. package/dist/intelligence/http.d.ts.map +1 -0
  233. package/dist/intelligence/http.js +496 -0
  234. package/dist/intelligence/http.js.map +1 -0
  235. package/dist/intelligence/provider-type.d.ts +6 -0
  236. package/dist/intelligence/provider-type.d.ts.map +1 -0
  237. package/dist/intelligence/provider-type.js +18 -0
  238. package/dist/intelligence/provider-type.js.map +1 -0
  239. package/dist/intelligence/provider.d.ts +49 -0
  240. package/dist/intelligence/provider.d.ts.map +1 -0
  241. package/dist/intelligence/provider.js +52 -0
  242. package/dist/intelligence/provider.js.map +1 -0
  243. package/dist/intelligence/related-k.d.ts +15 -0
  244. package/dist/intelligence/related-k.d.ts.map +1 -0
  245. package/dist/intelligence/related-k.js +57 -0
  246. package/dist/intelligence/related-k.js.map +1 -0
  247. package/dist/intelligence/routing-view.d.ts +33 -0
  248. package/dist/intelligence/routing-view.d.ts.map +1 -0
  249. package/dist/intelligence/routing-view.js +54 -0
  250. package/dist/intelligence/routing-view.js.map +1 -0
  251. package/dist/intelligence/sampling.d.ts +20 -0
  252. package/dist/intelligence/sampling.d.ts.map +1 -0
  253. package/dist/intelligence/sampling.js +324 -0
  254. package/dist/intelligence/sampling.js.map +1 -0
  255. package/dist/intelligence/stage-router.d.ts +32 -0
  256. package/dist/intelligence/stage-router.d.ts.map +1 -0
  257. package/dist/intelligence/stage-router.js +251 -0
  258. package/dist/intelligence/stage-router.js.map +1 -0
  259. package/dist/intelligence/steps.d.ts +65 -0
  260. package/dist/intelligence/steps.d.ts.map +1 -0
  261. package/dist/intelligence/steps.js +86 -0
  262. package/dist/intelligence/steps.js.map +1 -0
  263. package/dist/intelligence/subject.d.ts +42 -0
  264. package/dist/intelligence/subject.d.ts.map +1 -0
  265. package/dist/intelligence/subject.js +44 -0
  266. package/dist/intelligence/subject.js.map +1 -0
  267. package/dist/intelligence/token-budget.d.ts +86 -0
  268. package/dist/intelligence/token-budget.d.ts.map +1 -0
  269. package/dist/intelligence/token-budget.js +312 -0
  270. package/dist/intelligence/token-budget.js.map +1 -0
  271. package/dist/intelligence/types.d.ts +179 -0
  272. package/dist/intelligence/types.d.ts.map +1 -0
  273. package/dist/intelligence/types.js +7 -0
  274. package/dist/intelligence/types.js.map +1 -0
  275. package/dist/intelligence/usage.d.ts +104 -0
  276. package/dist/intelligence/usage.d.ts.map +1 -0
  277. package/dist/intelligence/usage.js +233 -0
  278. package/dist/intelligence/usage.js.map +1 -0
  279. package/dist/ipc/scheduler-ipc.d.ts +52 -0
  280. package/dist/ipc/scheduler-ipc.d.ts.map +1 -0
  281. package/dist/ipc/scheduler-ipc.js +214 -0
  282. package/dist/ipc/scheduler-ipc.js.map +1 -0
  283. package/dist/paths.d.ts +29 -0
  284. package/dist/paths.d.ts.map +1 -0
  285. package/dist/paths.js +47 -0
  286. package/dist/paths.js.map +1 -0
  287. package/dist/scheduler.d.ts +39 -0
  288. package/dist/scheduler.d.ts.map +1 -0
  289. package/dist/scheduler.js +93 -0
  290. package/dist/scheduler.js.map +1 -0
  291. package/dist/schemas/domains.d.ts +89 -0
  292. package/dist/schemas/domains.d.ts.map +1 -0
  293. package/dist/schemas/domains.js +160 -0
  294. package/dist/schemas/domains.js.map +1 -0
  295. package/dist/schemas/starter-vocabulary.d.ts +34 -0
  296. package/dist/schemas/starter-vocabulary.d.ts.map +1 -0
  297. package/dist/schemas/starter-vocabulary.js +91 -0
  298. package/dist/schemas/starter-vocabulary.js.map +1 -0
  299. package/dist/search/ann.d.ts +36 -0
  300. package/dist/search/ann.d.ts.map +1 -0
  301. package/dist/search/ann.js +59 -0
  302. package/dist/search/ann.js.map +1 -0
  303. package/dist/search/entity.d.ts +43 -0
  304. package/dist/search/entity.d.ts.map +1 -0
  305. package/dist/search/entity.js +147 -0
  306. package/dist/search/entity.js.map +1 -0
  307. package/dist/search/episodes.d.ts +28 -0
  308. package/dist/search/episodes.d.ts.map +1 -0
  309. package/dist/search/episodes.js +102 -0
  310. package/dist/search/episodes.js.map +1 -0
  311. package/dist/search/hnsw-graph.d.ts +35 -0
  312. package/dist/search/hnsw-graph.d.ts.map +1 -0
  313. package/dist/search/hnsw-graph.js +177 -0
  314. package/dist/search/hnsw-graph.js.map +1 -0
  315. package/dist/search/hnsw-ram.d.ts +29 -0
  316. package/dist/search/hnsw-ram.d.ts.map +1 -0
  317. package/dist/search/hnsw-ram.js +95 -0
  318. package/dist/search/hnsw-ram.js.map +1 -0
  319. package/dist/search/index.d.ts +119 -0
  320. package/dist/search/index.d.ts.map +1 -0
  321. package/dist/search/index.js +420 -0
  322. package/dist/search/index.js.map +1 -0
  323. package/dist/search/interlocutor-rank.d.ts +10 -0
  324. package/dist/search/interlocutor-rank.d.ts.map +1 -0
  325. package/dist/search/interlocutor-rank.js +21 -0
  326. package/dist/search/interlocutor-rank.js.map +1 -0
  327. package/dist/search/key-facts.d.ts +34 -0
  328. package/dist/search/key-facts.d.ts.map +1 -0
  329. package/dist/search/key-facts.js +43 -0
  330. package/dist/search/key-facts.js.map +1 -0
  331. package/dist/search/profile.d.ts +31 -0
  332. package/dist/search/profile.d.ts.map +1 -0
  333. package/dist/search/profile.js +43 -0
  334. package/dist/search/profile.js.map +1 -0
  335. package/dist/search/vector.d.ts +90 -0
  336. package/dist/search/vector.d.ts.map +1 -0
  337. package/dist/search/vector.js +187 -0
  338. package/dist/search/vector.js.map +1 -0
  339. package/dist/sources/claude-code.d.ts +35 -0
  340. package/dist/sources/claude-code.d.ts.map +1 -0
  341. package/dist/sources/claude-code.js +401 -0
  342. package/dist/sources/claude-code.js.map +1 -0
  343. package/dist/sources/copy.d.ts +58 -0
  344. package/dist/sources/copy.d.ts.map +1 -0
  345. package/dist/sources/copy.js +104 -0
  346. package/dist/sources/copy.js.map +1 -0
  347. package/dist/sources/cursor.d.ts +44 -0
  348. package/dist/sources/cursor.d.ts.map +1 -0
  349. package/dist/sources/cursor.js +99 -0
  350. package/dist/sources/cursor.js.map +1 -0
  351. package/dist/sources/jsonl-copy.d.ts +58 -0
  352. package/dist/sources/jsonl-copy.d.ts.map +1 -0
  353. package/dist/sources/jsonl-copy.js +195 -0
  354. package/dist/sources/jsonl-copy.js.map +1 -0
  355. package/dist/sources/jsonl-ingest.d.ts +58 -0
  356. package/dist/sources/jsonl-ingest.d.ts.map +1 -0
  357. package/dist/sources/jsonl-ingest.js +195 -0
  358. package/dist/sources/jsonl-ingest.js.map +1 -0
  359. package/dist/sources/pull.d.ts +85 -0
  360. package/dist/sources/pull.d.ts.map +1 -0
  361. package/dist/sources/pull.js +145 -0
  362. package/dist/sources/pull.js.map +1 -0
  363. package/dist/sources/resolve.d.ts +38 -0
  364. package/dist/sources/resolve.d.ts.map +1 -0
  365. package/dist/sources/resolve.js +91 -0
  366. package/dist/sources/resolve.js.map +1 -0
  367. package/dist/tools/capture-fact-description.d.ts +18 -0
  368. package/dist/tools/capture-fact-description.d.ts.map +1 -0
  369. package/dist/tools/capture-fact-description.js +41 -0
  370. package/dist/tools/capture-fact-description.js.map +1 -0
  371. package/dist/tools/fact-manager.d.ts +69 -0
  372. package/dist/tools/fact-manager.d.ts.map +1 -0
  373. package/dist/tools/fact-manager.js +332 -0
  374. package/dist/tools/fact-manager.js.map +1 -0
  375. package/dist/tools/inference-descriptions.d.ts +8 -0
  376. package/dist/tools/inference-descriptions.d.ts.map +1 -0
  377. package/dist/tools/inference-descriptions.js +16 -0
  378. package/dist/tools/inference-descriptions.js.map +1 -0
  379. package/dist/tools/inferences.d.ts +11 -0
  380. package/dist/tools/inferences.d.ts.map +1 -0
  381. package/dist/tools/inferences.js +98 -0
  382. package/dist/tools/inferences.js.map +1 -0
  383. package/dist/tools/read-tools.d.ts +21 -0
  384. package/dist/tools/read-tools.d.ts.map +1 -0
  385. package/dist/tools/read-tools.js +276 -0
  386. package/dist/tools/read-tools.js.map +1 -0
  387. package/dist/tools/resources.d.ts +62 -0
  388. package/dist/tools/resources.d.ts.map +1 -0
  389. package/dist/tools/resources.js +199 -0
  390. package/dist/tools/resources.js.map +1 -0
  391. package/dist/tools/session-manager.d.ts +44 -0
  392. package/dist/tools/session-manager.d.ts.map +1 -0
  393. package/dist/tools/session-manager.js +227 -0
  394. package/dist/tools/session-manager.js.map +1 -0
  395. package/dist/types/config.d.ts +400 -0
  396. package/dist/types/config.d.ts.map +1 -0
  397. package/dist/types/config.js +105 -0
  398. package/dist/types/config.js.map +1 -0
  399. package/dist/types/data.d.ts +357 -0
  400. package/dist/types/data.d.ts.map +1 -0
  401. package/dist/types/data.js +36 -0
  402. package/dist/types/data.js.map +1 -0
  403. package/dist/types/index.d.ts +6 -0
  404. package/dist/types/index.d.ts.map +1 -0
  405. package/dist/types/index.js +6 -0
  406. package/dist/types/index.js.map +1 -0
  407. package/dist/types.d.ts +115 -0
  408. package/dist/types.d.ts.map +1 -0
  409. package/dist/types.js +6 -0
  410. package/dist/types.js.map +1 -0
  411. package/dist/warnings.d.ts.map +1 -0
  412. package/dist/warnings.js.map +1 -0
  413. package/package.json +62 -0
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.d.ts","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAIH,OAAO,EAAE,oBAAoB,EAAY,MAAM,eAAe,CAAC;AAE/D,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAEhC,MAAM,WAAW,kBAAkB;IACjC,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,GAAG,CAAC,EAAE,MAAM,CAAC,UAAU,CAAC;CACzB;AAED,qDAAqD;AACrD,wBAAgB,iBAAiB,CAAC,IAAI,GAAE,MAAkB,GAAG,MAAM,CAElE;AAED;;;;;GAKG;AACH,wBAAgB,cAAc,CAAC,IAAI,GAAE,kBAAuB,GAAG,MAAM,CAMpE;AAED,qEAAqE;AACrE,wBAAgB,uBAAuB,CACrC,GAAG,GAAE,MAAM,CAAC,UAAwB,GACnC,MAAM,CAER;AAED,oEAAoE;AACpE,wBAAgB,WAAW,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAM7C;AAED,kDAAkD;AAClD,wBAAgB,eAAe,CAAC,CAAC,EAAE,MAAM,GAAG,MAAM,CAEjD"}
package/dist/paths.js ADDED
@@ -0,0 +1,47 @@
1
+ /**
2
+ * Data-directory defaults and tilde expansion.
3
+ *
4
+ * One function for the default store path and one expander for user-typed
5
+ * paths. The CLI, MCP server, and init snippet names must not each invent
6
+ * `path.join(homedir(), ".facthouse")`.
7
+ */
8
+ import { homedir } from "node:os";
9
+ import path from "node:path";
10
+ import { DEFAULT_DATA_DIRNAME, envValue } from "./identity.js";
11
+ export { DEFAULT_DATA_DIRNAME };
12
+ /** Absolute path of the default (`~/.facthouse`). */
13
+ export function newInstallDataDir(home = homedir()) {
14
+ return path.join(home, DEFAULT_DATA_DIRNAME);
15
+ }
16
+ /**
17
+ * Default store directory when the user did not pass `--data` / a positional.
18
+ *
19
+ * Order: FACTHOUSE_DATA, else `~/.facthouse`. Does not look at `.factmem` or
20
+ * `.openmemory`. Never copies or moves a directory.
21
+ */
22
+ export function defaultDataDir(opts = {}) {
23
+ const home = opts.home ?? homedir();
24
+ const env = opts.env ?? process.env;
25
+ const fromEnv = envValue("DATA", env);
26
+ if (fromEnv)
27
+ return path.resolve(expandTilde(fromEnv));
28
+ return path.join(home, DEFAULT_DATA_DIRNAME);
29
+ }
30
+ /** `--data` flag default: env override or {@link defaultDataDir}. */
31
+ export function dataDirFromEnvOrDefault(env = process.env) {
32
+ return envValue("DATA", env) ?? defaultDataDir({ env });
33
+ }
34
+ /** Expand a leading `~` without resolving against the local cwd. */
35
+ export function expandTilde(p) {
36
+ if (p === "~")
37
+ return homedir();
38
+ if (p.startsWith("~/") || p.startsWith("~\\")) {
39
+ return path.join(homedir(), p.slice(2));
40
+ }
41
+ return p;
42
+ }
43
+ /** Expand `~` and resolve to an absolute path. */
44
+ export function resolveUserPath(p) {
45
+ return path.resolve(expandTilde(p));
46
+ }
47
+ //# sourceMappingURL=paths.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"paths.js","sourceRoot":"","sources":["../src/paths.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AAEH,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,IAAI,MAAM,WAAW,CAAC;AAC7B,OAAO,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AAE/D,OAAO,EAAE,oBAAoB,EAAE,CAAC;AAOhC,qDAAqD;AACrD,MAAM,UAAU,iBAAiB,CAAC,OAAe,OAAO,EAAE;IACxD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;AAC/C,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,cAAc,CAAC,OAA2B,EAAE;IAC1D,MAAM,IAAI,GAAG,IAAI,CAAC,IAAI,IAAI,OAAO,EAAE,CAAC;IACpC,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,IAAI,OAAO,CAAC,GAAG,CAAC;IACpC,MAAM,OAAO,GAAG,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IACtC,IAAI,OAAO;QAAE,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC,CAAC;IACvD,OAAO,IAAI,CAAC,IAAI,CAAC,IAAI,EAAE,oBAAoB,CAAC,CAAC;AAC/C,CAAC;AAED,qEAAqE;AACrE,MAAM,UAAU,uBAAuB,CACrC,MAAyB,OAAO,CAAC,GAAG;IAEpC,OAAO,QAAQ,CAAC,MAAM,EAAE,GAAG,CAAC,IAAI,cAAc,CAAC,EAAE,GAAG,EAAE,CAAC,CAAC;AAC1D,CAAC;AAED,oEAAoE;AACpE,MAAM,UAAU,WAAW,CAAC,CAAS;IACnC,IAAI,CAAC,KAAK,GAAG;QAAE,OAAO,OAAO,EAAE,CAAC;IAChC,IAAI,CAAC,CAAC,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC,UAAU,CAAC,KAAK,CAAC,EAAE,CAAC;QAC9C,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAC1C,CAAC;IACD,OAAO,CAAC,CAAC;AACX,CAAC;AAED,kDAAkD;AAClD,MAAM,UAAU,eAAe,CAAC,CAAS;IACvC,OAAO,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,CAAC,CAAC,CAAC,CAAC;AACtC,CAAC"}
@@ -0,0 +1,39 @@
1
+ /**
2
+ * Consolidation scheduler.
3
+ *
4
+ * The scheduler is purely the coordinating layer around consolidate() — it
5
+ * owns the threshold check, the throttle, and the in-flight guard, and
6
+ * exposes run(moment) for callers that receive a wake-up.
7
+ *
8
+ * Which steps a moment runs, and whether it bypasses the gate, is the
9
+ * MOMENT_POLICY table in src/intelligence/steps.ts — one definition.
10
+ *
11
+ * Wake-up mechanisms live outside:
12
+ * - IPC moment from another process (src/ipc/scheduler-ipc.ts)
13
+ * - Lifecycle hooks in src/index.ts (session_start, shutdown)
14
+ * - Manual calls via the `consolidate` MCP tool
15
+ *
16
+ * This module intentionally knows nothing about sockets, pipes, or fs events.
17
+ */
18
+ import type { Db } from "./db/connection.js";
19
+ import type { ConsolidationResult } from "./intelligence/consolidate.js";
20
+ import { type ConsolidateSteps, type Moment } from "./intelligence/steps.js";
21
+ export interface SchedulerOpts {
22
+ db: Db;
23
+ /** Called when the scheduler decides to fire a consolidation run. */
24
+ runConsolidate: (steps: ConsolidateSteps, moment: Moment) => Promise<ConsolidationResult>;
25
+ /** Unexamined events at which a non-forced moment fires. */
26
+ threshold: number;
27
+ /** Minimum ms between non-forced runs. Protects LLM rate limits during
28
+ * event bursts. Forced moments bypass this throttle.
29
+ * Default 120_000 (2 minutes). */
30
+ minIntervalMs?: number;
31
+ }
32
+ export interface Scheduler {
33
+ /** Run the steps MOMENT_POLICY assigns to this moment. */
34
+ run(moment: Moment): Promise<ConsolidationResult | null>;
35
+ /** Release any internal resources. Idempotent. */
36
+ stop(): void;
37
+ }
38
+ export declare function startScheduler(opts: SchedulerOpts): Scheduler;
39
+ //# sourceMappingURL=scheduler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduler.d.ts","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAGH,OAAO,KAAK,EAAE,EAAE,EAAE,MAAM,oBAAoB,CAAC;AAE7C,OAAO,KAAK,EAAE,mBAAmB,EAAE,MAAM,+BAA+B,CAAC;AACzE,OAAO,EAEL,KAAK,gBAAgB,EACrB,KAAK,MAAM,EACZ,MAAM,yBAAyB,CAAC;AAEjC,MAAM,WAAW,aAAa;IAC5B,EAAE,EAAE,EAAE,CAAC;IACP,qEAAqE;IACrE,cAAc,EAAE,CACd,KAAK,EAAE,gBAAgB,EACvB,MAAM,EAAE,MAAM,KACX,OAAO,CAAC,mBAAmB,CAAC,CAAC;IAClC,4DAA4D;IAC5D,SAAS,EAAE,MAAM,CAAC;IAClB;;uCAEmC;IACnC,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB;AAED,MAAM,WAAW,SAAS;IACxB,0DAA0D;IAC1D,GAAG,CAAC,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,mBAAmB,GAAG,IAAI,CAAC,CAAC;IACzD,kDAAkD;IAClD,IAAI,IAAI,IAAI,CAAC;CACd;AAOD,wBAAgB,cAAc,CAAC,IAAI,EAAE,aAAa,GAAG,SAAS,CAmE7D"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * Consolidation scheduler.
3
+ *
4
+ * The scheduler is purely the coordinating layer around consolidate() — it
5
+ * owns the threshold check, the throttle, and the in-flight guard, and
6
+ * exposes run(moment) for callers that receive a wake-up.
7
+ *
8
+ * Which steps a moment runs, and whether it bypasses the gate, is the
9
+ * MOMENT_POLICY table in src/intelligence/steps.ts — one definition.
10
+ *
11
+ * Wake-up mechanisms live outside:
12
+ * - IPC moment from another process (src/ipc/scheduler-ipc.ts)
13
+ * - Lifecycle hooks in src/index.ts (session_start, shutdown)
14
+ * - Manual calls via the `consolidate` MCP tool
15
+ *
16
+ * This module intentionally knows nothing about sockets, pipes, or fs events.
17
+ */
18
+ import { pragmaRead } from "./db/connection.js";
19
+ import { unexaminedEventCount } from "./db/extract-watermarks.js";
20
+ import { MOMENT_POLICY, } from "./intelligence/steps.js";
21
+ async function readDataVersion(db) {
22
+ const v = await pragmaRead(db, "data_version");
23
+ return typeof v === "number" ? v : 0;
24
+ }
25
+ export function startScheduler(opts) {
26
+ const minIntervalMs = opts.minIntervalMs ?? 120_000;
27
+ // Last data_version we observed. When unchanged, the DB hasn't been
28
+ // committed to by another connection since the last run — skip the SQL
29
+ // count. Initialised to NaN so the first run always does a full check.
30
+ let lastDataVersion = Number.NaN;
31
+ // Timestamp of last completed consolidation. Used by the minIntervalMs
32
+ // throttle to prevent threshold-driven runs from firing too often.
33
+ let lastRunAt = 0;
34
+ // Serialises scheduler runs so overlapping moments don't start parallel
35
+ // consolidations. Assigned before the first await so two moments in one
36
+ // turn cannot both pass the check. The DB advisory lock is the
37
+ // authoritative guard; this just avoids the wasted call.
38
+ let inFlight = null;
39
+ function run(moment) {
40
+ if (inFlight)
41
+ return inFlight;
42
+ const policy = MOMENT_POLICY[moment];
43
+ inFlight = (async () => {
44
+ try {
45
+ if (!policy.force) {
46
+ if (Date.now() - lastRunAt < minIntervalMs)
47
+ return null;
48
+ try {
49
+ const current = await readDataVersion(opts.db);
50
+ if (current === lastDataVersion)
51
+ return null;
52
+ lastDataVersion = current;
53
+ const delta = await unexaminedEventCount(opts.db);
54
+ if (delta < opts.threshold)
55
+ return null;
56
+ }
57
+ catch {
58
+ // Schema not yet applied, DB closed, etc. Skip silently.
59
+ return null;
60
+ }
61
+ }
62
+ try {
63
+ return await opts.runConsolidate({ ...policy.steps }, moment);
64
+ }
65
+ catch {
66
+ // The scheduler must not crash the server. Failure is observable
67
+ // via the consolidations table (no new row written).
68
+ return null;
69
+ }
70
+ finally {
71
+ lastRunAt = Date.now();
72
+ try {
73
+ lastDataVersion = await readDataVersion(opts.db);
74
+ }
75
+ catch {
76
+ /* ignore */
77
+ }
78
+ }
79
+ }
80
+ finally {
81
+ inFlight = null;
82
+ }
83
+ })();
84
+ return inFlight;
85
+ }
86
+ return {
87
+ run,
88
+ stop: () => {
89
+ // Nothing to release now that the scheduler holds no timers or watchers.
90
+ },
91
+ };
92
+ }
93
+ //# sourceMappingURL=scheduler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"scheduler.js","sourceRoot":"","sources":["../src/scheduler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;GAgBG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AAEhD,OAAO,EAAE,oBAAoB,EAAE,MAAM,4BAA4B,CAAC;AAElE,OAAO,EACL,aAAa,GAGd,MAAM,yBAAyB,CAAC;AAwBjC,KAAK,UAAU,eAAe,CAAC,EAAM;IACnC,MAAM,CAAC,GAAG,MAAM,UAAU,CAAC,EAAE,EAAE,cAAc,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC,KAAK,QAAQ,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AACvC,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,IAAmB;IAChD,MAAM,aAAa,GAAG,IAAI,CAAC,aAAa,IAAI,OAAO,CAAC;IAEpD,oEAAoE;IACpE,uEAAuE;IACvE,uEAAuE;IACvE,IAAI,eAAe,GAAG,MAAM,CAAC,GAAG,CAAC;IAEjC,uEAAuE;IACvE,mEAAmE;IACnE,IAAI,SAAS,GAAG,CAAC,CAAC;IAElB,wEAAwE;IACxE,wEAAwE;IACxE,+DAA+D;IAC/D,yDAAyD;IACzD,IAAI,QAAQ,GAA+C,IAAI,CAAC;IAEhE,SAAS,GAAG,CAAC,MAAc;QACzB,IAAI,QAAQ;YAAE,OAAO,QAAQ,CAAC;QAC9B,MAAM,MAAM,GAAG,aAAa,CAAC,MAAM,CAAC,CAAC;QAErC,QAAQ,GAAG,CAAC,KAAK,IAAI,EAAE;YACrB,IAAI,CAAC;gBACH,IAAI,CAAC,MAAM,CAAC,KAAK,EAAE,CAAC;oBAClB,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,aAAa;wBAAE,OAAO,IAAI,CAAC;oBAExD,IAAI,CAAC;wBACH,MAAM,OAAO,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;wBAC/C,IAAI,OAAO,KAAK,eAAe;4BAAE,OAAO,IAAI,CAAC;wBAC7C,eAAe,GAAG,OAAO,CAAC;wBAE1B,MAAM,KAAK,GAAG,MAAM,oBAAoB,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;wBAClD,IAAI,KAAK,GAAG,IAAI,CAAC,SAAS;4BAAE,OAAO,IAAI,CAAC;oBAC1C,CAAC;oBAAC,MAAM,CAAC;wBACP,yDAAyD;wBACzD,OAAO,IAAI,CAAC;oBACd,CAAC;gBACH,CAAC;gBAED,IAAI,CAAC;oBACH,OAAO,MAAM,IAAI,CAAC,cAAc,CAAC,EAAE,GAAG,MAAM,CAAC,KAAK,EAAE,EAAE,MAAM,CAAC,CAAC;gBAChE,CAAC;gBAAC,MAAM,CAAC;oBACP,iEAAiE;oBACjE,qDAAqD;oBACrD,OAAO,IAAI,CAAC;gBACd,CAAC;wBAAS,CAAC;oBACT,SAAS,GAAG,IAAI,CAAC,GAAG,EAAE,CAAC;oBACvB,IAAI,CAAC;wBACH,eAAe,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,EAAE,CAAC,CAAC;oBACnD,CAAC;oBAAC,MAAM,CAAC;wBACP,YAAY;oBACd,CAAC;gBACH,CAAC;YACH,CAAC;oBAAS,CAAC;gBACT,QAAQ,GAAG,IAAI,CAAC;YAClB,CAAC;QACH,CAAC,CAAC,EAAE,CAAC;QACL,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED,OAAO;QACL,GAAG;QACH,IAAI,EAAE,GAAG,EAAE;YACT,yEAAyE;QAC3E,CAAC;KACF,CAAC;AACJ,CAAC"}
@@ -0,0 +1,89 @@
1
+ /**
2
+ * Domain mechanics. **The engine ships no vocabulary.**
3
+ *
4
+ * There is exactly one built-in domain: `general`, the fallback a fact lands in
5
+ * when nothing routes it. Everything else — which domains exist, what they mean,
6
+ * how the fallback classifier recognises them, how important their facts are —
7
+ * is data, supplied by the user's config and grown at runtime by whatever
8
+ * classifies.
9
+ *
10
+ * This file used to hold five domains called CORE: profile, preferences,
11
+ * medical, people, work. That was a personal vocabulary presented as a universal
12
+ * base, and it does not survive the question "what does a corporate user do with
13
+ * `medical`, and what does `work` mean when everything is work?" It doesn't. A
14
+ * research store wants papers, experiments, datasets; a corporate one wants
15
+ * clients, incidents, contracts. There is no universal core — and the word
16
+ * "core" was what disguised a preset as an invariant.
17
+ *
18
+ * The data model said so before any of this was written:
19
+ *
20
+ * > Domains are data, not code. [...] No prescribed defaults. The user's LLM
21
+ * > knows their life better than we do.
22
+ *
23
+ * What stays here is the machinery that is genuinely universal: the fallback
24
+ * domain, canonicalisation, and the instruction that steers a classifier toward
25
+ * the vocabulary that already exists rather than coining a synonym for it.
26
+ */
27
+ import type { DomainDef } from "../types/config.js";
28
+ /**
29
+ * Where a fact lands when nothing routes it.
30
+ *
31
+ * The only domain the engine knows by name. It is a fallback, never a
32
+ * destination: nothing routes *to* general, facts arrive there by default.
33
+ */
34
+ export declare const DEFAULT_DOMAIN = "general";
35
+ /**
36
+ * Canonicalise a domain's spelling — case and whitespace only.
37
+ *
38
+ * Deliberately does not coerce an unrecognised domain into the fallback: with no
39
+ * shipped vocabulary, "unrecognised" is the normal case and every domain is
40
+ * someone's. The label a classifier chose is the most informative thing about a
41
+ * fact that fits nothing else; discarding it is the lossy step.
42
+ *
43
+ * What it does prevent is one domain existing twice under different spellings —
44
+ * `Preferences` and `preferences` are one domain, not two.
45
+ */
46
+ export declare function normaliseDomainName(name: string | null | undefined): string;
47
+ /** Names from a configured vocabulary, canonicalised, excluding the fallback. */
48
+ export declare function routableNames(vocabulary: DomainDef[]): string[];
49
+ /** Comma-separated routable names for prose. Empty when none are configured. */
50
+ export declare function routableDomainList(vocabulary: DomainDef[]): string;
51
+ /**
52
+ * Compile a configured vocabulary into matchers for the fallback classifier.
53
+ *
54
+ * Order is the vocabulary's order: first match wins, so whoever writes the
55
+ * config decides precedence. Domains without patterns are skipped — only an LLM
56
+ * can route to those.
57
+ *
58
+ * An invalid regex is dropped rather than thrown: a typo in one domain's config
59
+ * must not stop the server booting. The cost is that one domain routing poorly,
60
+ * rather than nothing working at all.
61
+ */
62
+ export declare function compilePatterns(vocabulary: DomainDef[]): Array<{
63
+ name: string;
64
+ patterns: RegExp[];
65
+ }>;
66
+ /** Importance defaults declared by a vocabulary, keyed by canonical name. */
67
+ export declare function importanceDefaults(vocabulary: DomainDef[]): Record<string, number>;
68
+ /**
69
+ * The routing instruction given to a classifier.
70
+ *
71
+ * `known` is the vocabulary that exists in this store right now — the config's
72
+ * domains plus anything previously created. Naming it is what keeps the
73
+ * vocabulary stable: a classifier shown "medical" reuses it instead of coining
74
+ * "health", the drift that scatters related facts across synonyms. Reuse is
75
+ * steered by showing what exists, never by forbidding new labels — with no
76
+ * shipped vocabulary, forbidding them would mean routing nothing at all.
77
+ */
78
+ /**
79
+ * One vocabulary for routing: domains the store already created, overlaid
80
+ * with config (importance, description, patterns). Config-only names are
81
+ * appended. Canonical name is the key — `Warehouse` and `warehouse` are one.
82
+ *
83
+ * Extract and classify must call this (via `loadStoreVocabulary`) rather than
84
+ * reading `config.domains` alone. Config defaults to `[]`, so a used store
85
+ * would otherwise be told it has no domains and would coin synonyms.
86
+ */
87
+ export declare function mergeVocabulary(fromStore: DomainDef[], fromConfig?: DomainDef[]): DomainDef[];
88
+ export declare function domainRoutingInstruction(known?: DomainDef[]): string;
89
+ //# sourceMappingURL=domains.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domains.d.ts","sourceRoot":"","sources":["../../src/schemas/domains.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD;;;;;GAKG;AACH,eAAO,MAAM,cAAc,YAAY,CAAC;AAExC;;;;;;;;;;GAUG;AACH,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,GAAG,MAAM,CAI3E;AAED,iFAAiF;AACjF,wBAAgB,aAAa,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,MAAM,EAAE,CAI/D;AAED,gFAAgF;AAChF,wBAAgB,kBAAkB,CAAC,UAAU,EAAE,SAAS,EAAE,GAAG,MAAM,CAElE;AAED;;;;;;;;;;GAUG;AACH,wBAAgB,eAAe,CAC7B,UAAU,EAAE,SAAS,EAAE,GACtB,KAAK,CAAC;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,QAAQ,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAkB7C;AAED,6EAA6E;AAC7E,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,SAAS,EAAE,GACtB,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAQxB;AAED;;;;;;;;;GASG;AACH;;;;;;;;GAQG;AACH,wBAAgB,eAAe,CAC7B,SAAS,EAAE,SAAS,EAAE,EACtB,UAAU,GAAE,SAAS,EAAO,GAC3B,SAAS,EAAE,CAuBb;AAED,wBAAgB,wBAAwB,CAAC,KAAK,GAAE,SAAS,EAAO,GAAG,MAAM,CAmBxE"}
@@ -0,0 +1,160 @@
1
+ /**
2
+ * Domain mechanics. **The engine ships no vocabulary.**
3
+ *
4
+ * There is exactly one built-in domain: `general`, the fallback a fact lands in
5
+ * when nothing routes it. Everything else — which domains exist, what they mean,
6
+ * how the fallback classifier recognises them, how important their facts are —
7
+ * is data, supplied by the user's config and grown at runtime by whatever
8
+ * classifies.
9
+ *
10
+ * This file used to hold five domains called CORE: profile, preferences,
11
+ * medical, people, work. That was a personal vocabulary presented as a universal
12
+ * base, and it does not survive the question "what does a corporate user do with
13
+ * `medical`, and what does `work` mean when everything is work?" It doesn't. A
14
+ * research store wants papers, experiments, datasets; a corporate one wants
15
+ * clients, incidents, contracts. There is no universal core — and the word
16
+ * "core" was what disguised a preset as an invariant.
17
+ *
18
+ * The data model said so before any of this was written:
19
+ *
20
+ * > Domains are data, not code. [...] No prescribed defaults. The user's LLM
21
+ * > knows their life better than we do.
22
+ *
23
+ * What stays here is the machinery that is genuinely universal: the fallback
24
+ * domain, canonicalisation, and the instruction that steers a classifier toward
25
+ * the vocabulary that already exists rather than coining a synonym for it.
26
+ */
27
+ /**
28
+ * Where a fact lands when nothing routes it.
29
+ *
30
+ * The only domain the engine knows by name. It is a fallback, never a
31
+ * destination: nothing routes *to* general, facts arrive there by default.
32
+ */
33
+ export const DEFAULT_DOMAIN = "general";
34
+ /**
35
+ * Canonicalise a domain's spelling — case and whitespace only.
36
+ *
37
+ * Deliberately does not coerce an unrecognised domain into the fallback: with no
38
+ * shipped vocabulary, "unrecognised" is the normal case and every domain is
39
+ * someone's. The label a classifier chose is the most informative thing about a
40
+ * fact that fits nothing else; discarding it is the lossy step.
41
+ *
42
+ * What it does prevent is one domain existing twice under different spellings —
43
+ * `Preferences` and `preferences` are one domain, not two.
44
+ */
45
+ export function normaliseDomainName(name) {
46
+ if (!name)
47
+ return DEFAULT_DOMAIN;
48
+ const cleaned = name.trim().toLowerCase().replace(/\s+/g, "_");
49
+ return cleaned === "" ? DEFAULT_DOMAIN : cleaned;
50
+ }
51
+ /** Names from a configured vocabulary, canonicalised, excluding the fallback. */
52
+ export function routableNames(vocabulary) {
53
+ return vocabulary
54
+ .map((d) => normaliseDomainName(d.name))
55
+ .filter((n) => n !== DEFAULT_DOMAIN);
56
+ }
57
+ /** Comma-separated routable names for prose. Empty when none are configured. */
58
+ export function routableDomainList(vocabulary) {
59
+ return routableNames(vocabulary).join(", ");
60
+ }
61
+ /**
62
+ * Compile a configured vocabulary into matchers for the fallback classifier.
63
+ *
64
+ * Order is the vocabulary's order: first match wins, so whoever writes the
65
+ * config decides precedence. Domains without patterns are skipped — only an LLM
66
+ * can route to those.
67
+ *
68
+ * An invalid regex is dropped rather than thrown: a typo in one domain's config
69
+ * must not stop the server booting. The cost is that one domain routing poorly,
70
+ * rather than nothing working at all.
71
+ */
72
+ export function compilePatterns(vocabulary) {
73
+ const compiled = [];
74
+ for (const domain of vocabulary) {
75
+ const name = normaliseDomainName(domain.name);
76
+ if (name === DEFAULT_DOMAIN || !domain.patterns?.length)
77
+ continue;
78
+ const patterns = [];
79
+ for (const source of domain.patterns) {
80
+ try {
81
+ patterns.push(new RegExp(source, "i"));
82
+ }
83
+ catch {
84
+ console.error(`[facthouse] ignoring an invalid pattern for domain "${name}": ${source}`);
85
+ }
86
+ }
87
+ if (patterns.length)
88
+ compiled.push({ name, patterns });
89
+ }
90
+ return compiled;
91
+ }
92
+ /** Importance defaults declared by a vocabulary, keyed by canonical name. */
93
+ export function importanceDefaults(vocabulary) {
94
+ const defaults = {};
95
+ for (const domain of vocabulary) {
96
+ if (typeof domain.importance === "number") {
97
+ defaults[normaliseDomainName(domain.name)] = domain.importance;
98
+ }
99
+ }
100
+ return defaults;
101
+ }
102
+ /**
103
+ * The routing instruction given to a classifier.
104
+ *
105
+ * `known` is the vocabulary that exists in this store right now — the config's
106
+ * domains plus anything previously created. Naming it is what keeps the
107
+ * vocabulary stable: a classifier shown "medical" reuses it instead of coining
108
+ * "health", the drift that scatters related facts across synonyms. Reuse is
109
+ * steered by showing what exists, never by forbidding new labels — with no
110
+ * shipped vocabulary, forbidding them would mean routing nothing at all.
111
+ */
112
+ /**
113
+ * One vocabulary for routing: domains the store already created, overlaid
114
+ * with config (importance, description, patterns). Config-only names are
115
+ * appended. Canonical name is the key — `Warehouse` and `warehouse` are one.
116
+ *
117
+ * Extract and classify must call this (via `loadStoreVocabulary`) rather than
118
+ * reading `config.domains` alone. Config defaults to `[]`, so a used store
119
+ * would otherwise be told it has no domains and would coin synonyms.
120
+ */
121
+ export function mergeVocabulary(fromStore, fromConfig = []) {
122
+ const byName = new Map();
123
+ for (const d of fromStore) {
124
+ const name = normaliseDomainName(d.name);
125
+ byName.set(name, { ...d, name });
126
+ }
127
+ for (const d of fromConfig) {
128
+ const name = normaliseDomainName(d.name);
129
+ const existing = byName.get(name);
130
+ if (!existing) {
131
+ byName.set(name, { ...d, name });
132
+ continue;
133
+ }
134
+ byName.set(name, {
135
+ ...existing,
136
+ description: d.description ?? existing.description,
137
+ patterns: d.patterns ?? existing.patterns,
138
+ importance: d.importance ?? existing.importance,
139
+ subdomains: existing.subdomains.length > 0 ? existing.subdomains : d.subdomains,
140
+ });
141
+ }
142
+ return [...byName.values()];
143
+ }
144
+ export function domainRoutingInstruction(known = []) {
145
+ const described = known
146
+ .map((d) => {
147
+ const name = normaliseDomainName(d.name);
148
+ return { name, text: d.description ? `${name} (${d.description})` : name };
149
+ })
150
+ .filter((d) => d.name !== DEFAULT_DOMAIN)
151
+ .map((d) => d.text);
152
+ const vocabulary = described.length
153
+ ? `Domains already in use — reuse the exact spelling where one fits: ${described.join(", ")}. `
154
+ : `This store has no domains yet; you are choosing its vocabulary. `;
155
+ return (`Route each fact to one domain. ${vocabulary}` +
156
+ `Invent a new domain only when the fact genuinely fits none of them; if you ` +
157
+ `do, use a short lowercase noun. Never coin a synonym for a domain above. ` +
158
+ `Use "${DEFAULT_DOMAIN}" only when a fact belongs to no domain at all.`);
159
+ }
160
+ //# sourceMappingURL=domains.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"domains.js","sourceRoot":"","sources":["../../src/schemas/domains.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAIH;;;;;GAKG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,SAAS,CAAC;AAExC;;;;;;;;;;GAUG;AACH,MAAM,UAAU,mBAAmB,CAAC,IAA+B;IACjE,IAAI,CAAC,IAAI;QAAE,OAAO,cAAc,CAAC;IACjC,MAAM,OAAO,GAAG,IAAI,CAAC,IAAI,EAAE,CAAC,WAAW,EAAE,CAAC,OAAO,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/D,OAAO,OAAO,KAAK,EAAE,CAAC,CAAC,CAAC,cAAc,CAAC,CAAC,CAAC,OAAO,CAAC;AACnD,CAAC;AAED,iFAAiF;AACjF,MAAM,UAAU,aAAa,CAAC,UAAuB;IACnD,OAAO,UAAU;SACd,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;SACvC,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,KAAK,cAAc,CAAC,CAAC;AACzC,CAAC;AAED,gFAAgF;AAChF,MAAM,UAAU,kBAAkB,CAAC,UAAuB;IACxD,OAAO,aAAa,CAAC,UAAU,CAAC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AAC9C,CAAC;AAED;;;;;;;;;;GAUG;AACH,MAAM,UAAU,eAAe,CAC7B,UAAuB;IAEvB,MAAM,QAAQ,GAAgD,EAAE,CAAC;IACjE,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE,CAAC;QAChC,MAAM,IAAI,GAAG,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC;QAC9C,IAAI,IAAI,KAAK,cAAc,IAAI,CAAC,MAAM,CAAC,QAAQ,EAAE,MAAM;YAAE,SAAS;QAClE,MAAM,QAAQ,GAAa,EAAE,CAAC;QAC9B,KAAK,MAAM,MAAM,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACrC,IAAI,CAAC;gBACH,QAAQ,CAAC,IAAI,CAAC,IAAI,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAAC;YACzC,CAAC;YAAC,MAAM,CAAC;gBACP,OAAO,CAAC,KAAK,CACX,uDAAuD,IAAI,MAAM,MAAM,EAAE,CAC1E,CAAC;YACJ,CAAC;QACH,CAAC;QACD,IAAI,QAAQ,CAAC,MAAM;YAAE,QAAQ,CAAC,IAAI,CAAC,EAAE,IAAI,EAAE,QAAQ,EAAE,CAAC,CAAC;IACzD,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED,6EAA6E;AAC7E,MAAM,UAAU,kBAAkB,CAChC,UAAuB;IAEvB,MAAM,QAAQ,GAA2B,EAAE,CAAC;IAC5C,KAAK,MAAM,MAAM,IAAI,UAAU,EAAE,CAAC;QAChC,IAAI,OAAO,MAAM,CAAC,UAAU,KAAK,QAAQ,EAAE,CAAC;YAC1C,QAAQ,CAAC,mBAAmB,CAAC,MAAM,CAAC,IAAI,CAAC,CAAC,GAAG,MAAM,CAAC,UAAU,CAAC;QACjE,CAAC;IACH,CAAC;IACD,OAAO,QAAQ,CAAC;AAClB,CAAC;AAED;;;;;;;;;GASG;AACH;;;;;;;;GAQG;AACH,MAAM,UAAU,eAAe,CAC7B,SAAsB,EACtB,aAA0B,EAAE;IAE5B,MAAM,MAAM,GAAG,IAAI,GAAG,EAAqB,CAAC;IAC5C,KAAK,MAAM,CAAC,IAAI,SAAS,EAAE,CAAC;QAC1B,MAAM,IAAI,GAAG,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;IACnC,CAAC;IACD,KAAK,MAAM,CAAC,IAAI,UAAU,EAAE,CAAC;QAC3B,MAAM,IAAI,GAAG,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACzC,MAAM,QAAQ,GAAG,MAAM,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC;QAClC,IAAI,CAAC,QAAQ,EAAE,CAAC;YACd,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE,EAAE,GAAG,CAAC,EAAE,IAAI,EAAE,CAAC,CAAC;YACjC,SAAS;QACX,CAAC;QACD,MAAM,CAAC,GAAG,CAAC,IAAI,EAAE;YACf,GAAG,QAAQ;YACX,WAAW,EAAE,CAAC,CAAC,WAAW,IAAI,QAAQ,CAAC,WAAW;YAClD,QAAQ,EAAE,CAAC,CAAC,QAAQ,IAAI,QAAQ,CAAC,QAAQ;YACzC,UAAU,EAAE,CAAC,CAAC,UAAU,IAAI,QAAQ,CAAC,UAAU;YAC/C,UAAU,EACR,QAAQ,CAAC,UAAU,CAAC,MAAM,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,UAAU;SACtE,CAAC,CAAC;IACL,CAAC;IACD,OAAO,CAAC,GAAG,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC;AAC9B,CAAC;AAED,MAAM,UAAU,wBAAwB,CAAC,QAAqB,EAAE;IAC9D,MAAM,SAAS,GAAG,KAAK;SACpB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE;QACT,MAAM,IAAI,GAAG,mBAAmB,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;QACzC,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC,CAAC,WAAW,CAAC,CAAC,CAAC,GAAG,IAAI,KAAK,CAAC,CAAC,WAAW,GAAG,CAAC,CAAC,CAAC,IAAI,EAAE,CAAC;IAC7E,CAAC,CAAC;SACD,MAAM,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,cAAc,CAAC;SACxC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC;IAEtB,MAAM,UAAU,GAAG,SAAS,CAAC,MAAM;QACjC,CAAC,CAAC,qEAAqE,SAAS,CAAC,IAAI,CAAC,IAAI,CAAC,IAAI;QAC/F,CAAC,CAAC,kEAAkE,CAAC;IAEvE,OAAO,CACL,kCAAkC,UAAU,EAAE;QAC9C,6EAA6E;QAC7E,2EAA2E;QAC3E,QAAQ,cAAc,iDAAiD,CACxE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,34 @@
1
+ /**
2
+ * A starting vocabulary, written into the user's `config.json` at init.
3
+ *
4
+ * **This is not a core, and the engine does not know these names.** It is data:
5
+ * seeded once into a file the user owns, then read back like any other config.
6
+ * Delete it, rename it, replace it wholesale — nothing in `src/` refers to
7
+ * `medical` or `preferences`, and nothing breaks if they are gone. The only
8
+ * domain the engine knows is `general`, the fallback.
9
+ *
10
+ * It is personal-flavoured because personal is the use case OpenMemory is
11
+ * best at, and an empty vocabulary gives a classifier nothing to be consistent
12
+ * with on day one. It is *not* a claim about what domains are. A corporate store
13
+ * replaces this with clients, incidents, contracts, suppliers; a research store
14
+ * with papers, experiments, datasets. Both are equally correct, and the engine
15
+ * cannot tell the difference — which is the point.
16
+ *
17
+ * Each domain carries its own:
18
+ * - `description` — shown to a classifier so it routes on meaning, not a guess
19
+ * at what a bare name implies.
20
+ * - `patterns` — for the fallback classifier, when no LLM is available. These
21
+ * are the most obviously non-universal part: "allergic" and "partner" are
22
+ * noise in a corporate store, and "SLA" and "incident" would be noise here.
23
+ * - `importance` — because a missed allergy is the costliest error in a
24
+ * personal store, and a missed SLA breach in a corporate one.
25
+ *
26
+ * Patterns match how facts are actually written. `capture_fact` is called by an
27
+ * assistant recording a fact *about* its user, so content arrives in the third
28
+ * person ("The user prefers dark roast"), not the first ("I prefer dark roast").
29
+ * Verbs therefore need their -s form: `prefers?`, not `prefer` — `\bprefer\b`
30
+ * does not match "prefers".
31
+ */
32
+ import type { DomainDef } from "../types/config.js";
33
+ export declare const STARTER_VOCABULARY: DomainDef[];
34
+ //# sourceMappingURL=starter-vocabulary.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"starter-vocabulary.d.ts","sourceRoot":"","sources":["../../src/schemas/starter-vocabulary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,oBAAoB,CAAC;AAEpD,eAAO,MAAM,kBAAkB,EAAE,SAAS,EA0DzC,CAAC"}
@@ -0,0 +1,91 @@
1
+ /**
2
+ * A starting vocabulary, written into the user's `config.json` at init.
3
+ *
4
+ * **This is not a core, and the engine does not know these names.** It is data:
5
+ * seeded once into a file the user owns, then read back like any other config.
6
+ * Delete it, rename it, replace it wholesale — nothing in `src/` refers to
7
+ * `medical` or `preferences`, and nothing breaks if they are gone. The only
8
+ * domain the engine knows is `general`, the fallback.
9
+ *
10
+ * It is personal-flavoured because personal is the use case OpenMemory is
11
+ * best at, and an empty vocabulary gives a classifier nothing to be consistent
12
+ * with on day one. It is *not* a claim about what domains are. A corporate store
13
+ * replaces this with clients, incidents, contracts, suppliers; a research store
14
+ * with papers, experiments, datasets. Both are equally correct, and the engine
15
+ * cannot tell the difference — which is the point.
16
+ *
17
+ * Each domain carries its own:
18
+ * - `description` — shown to a classifier so it routes on meaning, not a guess
19
+ * at what a bare name implies.
20
+ * - `patterns` — for the fallback classifier, when no LLM is available. These
21
+ * are the most obviously non-universal part: "allergic" and "partner" are
22
+ * noise in a corporate store, and "SLA" and "incident" would be noise here.
23
+ * - `importance` — because a missed allergy is the costliest error in a
24
+ * personal store, and a missed SLA breach in a corporate one.
25
+ *
26
+ * Patterns match how facts are actually written. `capture_fact` is called by an
27
+ * assistant recording a fact *about* its user, so content arrives in the third
28
+ * person ("The user prefers dark roast"), not the first ("I prefer dark roast").
29
+ * Verbs therefore need their -s form: `prefers?`, not `prefer` — `\bprefer\b`
30
+ * does not match "prefers".
31
+ */
32
+ export const STARTER_VOCABULARY = [
33
+ {
34
+ // First: health information takes priority, and a false positive here is
35
+ // safer than a miss. Order is precedence — the fallback stops at the first
36
+ // match.
37
+ name: "medical",
38
+ description: "health conditions, allergies, medication, treatment",
39
+ subdomains: [],
40
+ patterns: [
41
+ "\\b(allerg|medicat|doctor|diagnosis|condition|symptom|treatment|prescription|health|hospital|clinic|vaccine|blood|surgery|therapy|illness|disease)",
42
+ ],
43
+ importance: 0.9,
44
+ },
45
+ {
46
+ name: "profile",
47
+ description: "core identity — name, demographics, location, occupation",
48
+ subdomains: [],
49
+ patterns: [
50
+ // First person, as a user states it.
51
+ "\\b(my name is|i am|i'm|born|nationality|age|birthday|occupation|job title)\\b",
52
+ "\\bi (live|lives) in\\b",
53
+ // Third person, as an assistant records it about its user.
54
+ "\\bthe user('s)? (is|was|has been)? ?(called|named)\\b",
55
+ "\\bthe user's (name|age|birthday|nationality|occupation|job title)\\b",
56
+ "\\b(the user|they) (lives?|moved|grew up|was born)\\b",
57
+ ],
58
+ importance: 0.85,
59
+ },
60
+ {
61
+ // Ahead of preferences: a relationship noun says who a fact is about, which
62
+ // outranks a preference verb saying what it mentions. "My partner Robin
63
+ // loves sushi" is a fact about Robin.
64
+ name: "people",
65
+ description: "relationships and the people in the user's life",
66
+ subdomains: [],
67
+ patterns: [
68
+ "\\b(partner|wife|husband|friend|colleague|boss|sister|brother|mother|father|son|daughter|neighbour|neighbor)\\b",
69
+ ],
70
+ importance: 0.6,
71
+ },
72
+ {
73
+ name: "work",
74
+ description: "employment, projects, teams, deadlines",
75
+ subdomains: [],
76
+ patterns: [
77
+ "\\b(project|sprint|deploy|meeting|team|company|client|deadline|standup|release|merge|repository|codebase)\\b",
78
+ ],
79
+ importance: 0.6,
80
+ },
81
+ {
82
+ name: "preferences",
83
+ description: "likes, dislikes, favourites, habits",
84
+ subdomains: [],
85
+ patterns: [
86
+ "\\b(prefers?|favourites?|favorites?|likes?|loves?|hates?|dislikes?|enjoys?|can't stand|would rather|rather)\\b",
87
+ ],
88
+ importance: 0.4,
89
+ },
90
+ ];
91
+ //# sourceMappingURL=starter-vocabulary.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"starter-vocabulary.js","sourceRoot":"","sources":["../../src/schemas/starter-vocabulary.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAIH,MAAM,CAAC,MAAM,kBAAkB,GAAgB;IAC7C;QACE,yEAAyE;QACzE,2EAA2E;QAC3E,SAAS;QACT,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,qDAAqD;QAClE,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE;YACR,oJAAoJ;SACrJ;QACD,UAAU,EAAE,GAAG;KAChB;IACD;QACE,IAAI,EAAE,SAAS;QACf,WAAW,EAAE,0DAA0D;QACvE,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE;YACR,qCAAqC;YACrC,gFAAgF;YAChF,yBAAyB;YACzB,2DAA2D;YAC3D,wDAAwD;YACxD,uEAAuE;YACvE,uDAAuD;SACxD;QACD,UAAU,EAAE,IAAI;KACjB;IACD;QACE,4EAA4E;QAC5E,wEAAwE;QACxE,sCAAsC;QACtC,IAAI,EAAE,QAAQ;QACd,WAAW,EAAE,iDAAiD;QAC9D,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE;YACR,iHAAiH;SAClH;QACD,UAAU,EAAE,GAAG;KAChB;IACD;QACE,IAAI,EAAE,MAAM;QACZ,WAAW,EAAE,wCAAwC;QACrD,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE;YACR,8GAA8G;SAC/G;QACD,UAAU,EAAE,GAAG;KAChB;IACD;QACE,IAAI,EAAE,aAAa;QACnB,WAAW,EAAE,qCAAqC;QAClD,UAAU,EAAE,EAAE;QACd,QAAQ,EAAE;YACR,gHAAgH;SACjH;QACD,UAAU,EAAE,GAAG;KAChB;CACF,CAAC"}
@@ -0,0 +1,36 @@
1
+ /**
2
+ * When meaning-search may use an HNSW index.
3
+ *
4
+ * Postgres: pgvector sidecar when the `vector` extension is present.
5
+ * SQLite: in-process graph rebuilt from BLOBs. The exact JavaScript scan is
6
+ * the default below the byte threshold and the fallback when the engine is
7
+ * missing. This module is the one definition of that gate and of the warning
8
+ * copy.
9
+ */
10
+ import type { Dialect } from "../db/connection.js";
11
+ export declare function embeddingWorkingSetBytes(count: number, dimensions: number): number;
12
+ /**
13
+ * `enginePresent` is the `vector` extension on Postgres and the in-process
14
+ * engine on SQLite. One flag so the auto / force / off rule is not copied.
15
+ */
16
+ export declare function shouldUseAnn(opts: {
17
+ dialect: Dialect;
18
+ ann: boolean | null | undefined;
19
+ bytes: number;
20
+ maxBytes: number;
21
+ enginePresent: boolean;
22
+ }): boolean;
23
+ /** Would want HNSW if the engine existed (for the missing-engine warning). */
24
+ export declare function wouldWantAnn(opts: {
25
+ dialect: Dialect;
26
+ ann: boolean | null | undefined;
27
+ bytes: number;
28
+ maxBytes: number;
29
+ }): boolean;
30
+ export declare function sqliteEngineMissingWarning(): string;
31
+ export declare function postgresMissingVectorWarning(): string;
32
+ export declare function postgresHnswFallbackWarning(detail: string): string;
33
+ export declare function emitAnnWarningOnce(key: string, message: string): void;
34
+ /** Test seam so "once" can be asserted without leaking across files. */
35
+ export declare function resetAnnWarningState(): void;
36
+ //# sourceMappingURL=ann.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ann.d.ts","sourceRoot":"","sources":["../../src/search/ann.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,qBAAqB,CAAC;AAGnD,wBAAgB,wBAAwB,CAAC,KAAK,EAAE,MAAM,EAAE,UAAU,EAAE,MAAM,GAAG,MAAM,CAElF;AAED;;;GAGG;AACH,wBAAgB,YAAY,CAAC,IAAI,EAAE;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;IACjB,aAAa,EAAE,OAAO,CAAC;CACxB,GAAG,OAAO,CAMV;AAED,8EAA8E;AAC9E,wBAAgB,YAAY,CAAC,IAAI,EAAE;IACjC,OAAO,EAAE,OAAO,CAAC;IACjB,GAAG,EAAE,OAAO,GAAG,IAAI,GAAG,SAAS,CAAC;IAChC,KAAK,EAAE,MAAM,CAAC;IACd,QAAQ,EAAE,MAAM,CAAC;CAClB,GAAG,OAAO,CAKV;AAED,wBAAgB,0BAA0B,IAAI,MAAM,CAKnD;AAED,wBAAgB,4BAA4B,IAAI,MAAM,CAKrD;AAED,wBAAgB,2BAA2B,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,CAElE;AAID,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAIrE;AAED,wEAAwE;AACxE,wBAAgB,oBAAoB,IAAI,IAAI,CAE3C"}