nox-mem 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 (398) hide show
  1. package/README.md +24 -16
  2. package/dist/__tests__/brief-diversity.test.js +266 -0
  3. package/dist/__tests__/brief.test.js +287 -0
  4. package/dist/__tests__/churn.test.js +66 -0
  5. package/dist/__tests__/edge-typing.test.js +99 -0
  6. package/dist/__tests__/ingest-event.test.js +151 -0
  7. package/dist/__tests__/op-audit-e2e.test.js +130 -0
  8. package/dist/__tests__/pragma-alignment.test.js +123 -0
  9. package/dist/__tests__/reranker.test.js +326 -0
  10. package/dist/__tests__/retention.test.js +99 -0
  11. package/dist/__tests__/search-track-access.test.js +49 -0
  12. package/dist/__tests__/spo-injection.test.js +172 -0
  13. package/dist/__tests__/temporal-detector.test.js +103 -0
  14. package/dist/api/wire-up.js +12 -381
  15. package/dist/api-server.js +6 -102
  16. package/dist/db.js +61 -2
  17. package/dist/embed.js +23 -2
  18. package/dist/index.js +3 -23
  19. package/dist/knowledge-graph.js +20 -0
  20. package/dist/lib/answer/__tests__/e2e-gemini.test.js +229 -0
  21. package/dist/lib/answer/__tests__/integration-sqlite.test.js +388 -0
  22. package/dist/lib/answer/__tests__/integration.test.js +347 -0
  23. package/dist/lib/answer/__tests__/prompt.test.js +117 -0
  24. package/dist/lib/answer/__tests__/t5-t10.test.js +501 -0
  25. package/dist/lib/answer/provider.js +29 -4
  26. package/dist/lib/api/__tests__/safe-error-message.test.js +155 -0
  27. package/dist/lib/auth/__tests__/localhost-guard.test.js +144 -0
  28. package/dist/lib/error-sanitizer/__tests__/sanitize.test.js +354 -0
  29. package/dist/lib/events/__tests__/bus.test.js +208 -0
  30. package/dist/lib/ingest-router.js +0 -43
  31. package/dist/lib/op-audit-extension/__tests__/ran-at-guard.test.js +109 -0
  32. package/dist/lib/regex-extract/__tests__/extractor.test.js +197 -0
  33. package/dist/lib/regex-extract/__tests__/frontmatter.test.js +75 -0
  34. package/dist/lib/regex-extract/__tests__/ingest-router-l4.test.js +139 -0
  35. package/dist/lib/regex-extract/__tests__/production-wire.test.js +177 -0
  36. package/dist/lib/regex-extract/__tests__/reconcile.test.js +170 -0
  37. package/dist/lib/regex-extract/__tests__/strip-code.test.js +36 -0
  38. package/dist/mcp-server.js +2 -1
  39. package/dist/privacy/__tests__/filter.test.js +352 -0
  40. package/dist/providers/__tests__/conformance-extended.test.js +249 -0
  41. package/dist/providers/__tests__/conformance.test.js +98 -0
  42. package/dist/providers/__tests__/cost-cap.test.js +151 -0
  43. package/dist/providers/__tests__/e2e-real.test.js +79 -0
  44. package/dist/providers/__tests__/factory.test.js +80 -0
  45. package/dist/providers/__tests__/fallback.test.js +223 -0
  46. package/dist/providers/__tests__/gemini.test.js +191 -0
  47. package/dist/providers/__tests__/health.test.js +128 -0
  48. package/dist/providers/__tests__/telemetry.test.js +219 -0
  49. package/dist/reindex.js +2 -2
  50. package/dist/version.js +22 -0
  51. package/package.json +3 -4
  52. package/dist/api/answer.d.ts +0 -116
  53. package/dist/api/answer.validate-patch.d.ts +0 -72
  54. package/dist/api/brief-diversity.d.ts +0 -64
  55. package/dist/api/brief.d.ts +0 -114
  56. package/dist/api/conflict.d.ts +0 -33
  57. package/dist/api/conflict.js +0 -143
  58. package/dist/api/cors.d.ts +0 -73
  59. package/dist/api/events-stream-limited.d.ts +0 -133
  60. package/dist/api/events-stream-limited.js +0 -217
  61. package/dist/api/events-stream.d.ts +0 -53
  62. package/dist/api/events-stream.js +0 -125
  63. package/dist/api/export.d.ts +0 -42
  64. package/dist/api/export.js +0 -85
  65. package/dist/api/health-confidence-adapter.d.ts +0 -29
  66. package/dist/api/health-confidence-adapter.js +0 -73
  67. package/dist/api/health-confidence.d.ts +0 -36
  68. package/dist/api/health-confidence.js +0 -141
  69. package/dist/api/hooks.d.ts +0 -50
  70. package/dist/api/hooks.js +0 -115
  71. package/dist/api/import.d.ts +0 -38
  72. package/dist/api/import.js +0 -87
  73. package/dist/api/ingest-event.d.ts +0 -65
  74. package/dist/api/mark.d.ts +0 -42
  75. package/dist/api/mark.js +0 -127
  76. package/dist/api/server-deps-a2.d.ts +0 -55
  77. package/dist/api/server-deps-a2.js +0 -138
  78. package/dist/api/server-deps-l2-l3.d.ts +0 -68
  79. package/dist/api/server-deps-l2-l3.js +0 -123
  80. package/dist/api/server-deps-p1.d.ts +0 -84
  81. package/dist/api/server-deps-p2.d.ts +0 -32
  82. package/dist/api/server-deps-p2.js +0 -84
  83. package/dist/api/server-deps-p5.d.ts +0 -66
  84. package/dist/api/server-deps-p5.js +0 -139
  85. package/dist/api/viewer-static.d.ts +0 -30
  86. package/dist/api/viewer-static.js +0 -102
  87. package/dist/api/wire-up.d.ts +0 -54
  88. package/dist/api-impact.d.ts +0 -30
  89. package/dist/api-server.d.ts +0 -2
  90. package/dist/backfill-fts-anchor.d.ts +0 -15
  91. package/dist/backfill-source-type.d.ts +0 -20
  92. package/dist/churn.d.ts +0 -31
  93. package/dist/cli/answer.d.ts +0 -66
  94. package/dist/cli/conflict.d.ts +0 -38
  95. package/dist/cli/conflict.js +0 -282
  96. package/dist/cli/export.d.ts +0 -51
  97. package/dist/cli/export.js +0 -280
  98. package/dist/cli/hooks.d.ts +0 -54
  99. package/dist/cli/hooks.js +0 -133
  100. package/dist/cli/import.d.ts +0 -52
  101. package/dist/cli/import.js +0 -274
  102. package/dist/cli/mark.d.ts +0 -33
  103. package/dist/cli/mark.js +0 -130
  104. package/dist/cli/ocr-batch.d.ts +0 -12
  105. package/dist/cli/ocr-batch.js +0 -411
  106. package/dist/cli/snapshot-main.d.ts +0 -30
  107. package/dist/cli/snapshot-main.js +0 -47
  108. package/dist/cli/viewer.d.ts +0 -35
  109. package/dist/cli/viewer.js +0 -71
  110. package/dist/cli-telemetry.d.ts +0 -36
  111. package/dist/cli-telemetry.js +0 -150
  112. package/dist/compact.d.ts +0 -7
  113. package/dist/consolidate.d.ts +0 -18
  114. package/dist/consolidation.d.ts +0 -32
  115. package/dist/cross-agent-v2.d.ts +0 -45
  116. package/dist/cross-search.d.ts +0 -11
  117. package/dist/crystallize.d.ts +0 -43
  118. package/dist/db.d.ts +0 -11
  119. package/dist/dedup.d.ts +0 -1
  120. package/dist/detect-changes.d.ts +0 -29
  121. package/dist/digest.d.ts +0 -1
  122. package/dist/doctor.d.ts +0 -1
  123. package/dist/embed.d.ts +0 -57
  124. package/dist/evals.d.ts +0 -176
  125. package/dist/evals.js +0 -351
  126. package/dist/generate-user-profile.d.ts +0 -18
  127. package/dist/graphify-ingest.d.ts +0 -18
  128. package/dist/impact.d.ts +0 -39
  129. package/dist/index.d.ts +0 -2
  130. package/dist/ingest-entity.d.ts +0 -44
  131. package/dist/ingest.d.ts +0 -13
  132. package/dist/kg-llm.d.ts +0 -39
  133. package/dist/knowledge-graph.d.ts +0 -72
  134. package/dist/lib/answer/config.d.ts +0 -41
  135. package/dist/lib/answer/index.d.ts +0 -47
  136. package/dist/lib/answer/prompt.d.ts +0 -37
  137. package/dist/lib/answer/provider.d.ts +0 -47
  138. package/dist/lib/answer/retrieval.d.ts +0 -36
  139. package/dist/lib/answer/telemetry.d.ts +0 -99
  140. package/dist/lib/answer/types.d.ts +0 -108
  141. package/dist/lib/api/error-leak-fix.d.ts +0 -54
  142. package/dist/lib/api/safe-error-message.d.ts +0 -70
  143. package/dist/lib/archive/common-passwords.d.ts +0 -37
  144. package/dist/lib/archive/common-passwords.js +0 -753
  145. package/dist/lib/archive/encryption.d.ts +0 -81
  146. package/dist/lib/archive/encryption.js +0 -236
  147. package/dist/lib/archive/enforce-strength.d.ts +0 -54
  148. package/dist/lib/archive/enforce-strength.js +0 -70
  149. package/dist/lib/archive/entropy.d.ts +0 -34
  150. package/dist/lib/archive/entropy.js +0 -180
  151. package/dist/lib/archive/export-locking.d.ts +0 -102
  152. package/dist/lib/archive/export-locking.js +0 -202
  153. package/dist/lib/archive/format.d.ts +0 -20
  154. package/dist/lib/archive/format.js +0 -174
  155. package/dist/lib/archive/index.d.ts +0 -23
  156. package/dist/lib/archive/index.js +0 -17
  157. package/dist/lib/archive/manifest.d.ts +0 -53
  158. package/dist/lib/archive/manifest.js +0 -183
  159. package/dist/lib/archive/migration.d.ts +0 -36
  160. package/dist/lib/archive/migration.js +0 -100
  161. package/dist/lib/archive/migrations/v18_to_v19.d.ts +0 -16
  162. package/dist/lib/archive/migrations/v18_to_v19.js +0 -18
  163. package/dist/lib/archive/orchestrator.d.ts +0 -166
  164. package/dist/lib/archive/orchestrator.js +0 -428
  165. package/dist/lib/archive/serializers/chunks.d.ts +0 -30
  166. package/dist/lib/archive/serializers/chunks.js +0 -113
  167. package/dist/lib/archive/serializers/embeddings.d.ts +0 -36
  168. package/dist/lib/archive/serializers/embeddings.js +0 -115
  169. package/dist/lib/archive/serializers/kg.d.ts +0 -28
  170. package/dist/lib/archive/serializers/kg.js +0 -184
  171. package/dist/lib/archive/serializers/ops_audit.d.ts +0 -21
  172. package/dist/lib/archive/serializers/ops_audit.js +0 -97
  173. package/dist/lib/archive/server-deps.d.ts +0 -131
  174. package/dist/lib/archive/server-deps.js +0 -232
  175. package/dist/lib/archive/strength.d.ts +0 -50
  176. package/dist/lib/archive/strength.js +0 -77
  177. package/dist/lib/archive/types.d.ts +0 -159
  178. package/dist/lib/archive/types.js +0 -45
  179. package/dist/lib/archive/unpack-streaming.d.ts +0 -70
  180. package/dist/lib/archive/unpack-streaming.js +0 -255
  181. package/dist/lib/auth/localhost-guard.d.ts +0 -106
  182. package/dist/lib/confidence/config.d.ts +0 -37
  183. package/dist/lib/confidence/config.js +0 -107
  184. package/dist/lib/confidence/db-shim-singleton.d.ts +0 -20
  185. package/dist/lib/confidence/db-shim-singleton.js +0 -41
  186. package/dist/lib/confidence/db-shim.d.ts +0 -47
  187. package/dist/lib/confidence/db-shim.js +0 -141
  188. package/dist/lib/confidence/mark.d.ts +0 -58
  189. package/dist/lib/confidence/mark.js +0 -168
  190. package/dist/lib/confidence/ranking.d.ts +0 -69
  191. package/dist/lib/confidence/ranking.js +0 -101
  192. package/dist/lib/confidence/search-filter.d.ts +0 -44
  193. package/dist/lib/confidence/search-filter.js +0 -103
  194. package/dist/lib/confidence/types.d.ts +0 -146
  195. package/dist/lib/confidence/types.js +0 -20
  196. package/dist/lib/confidence/write-hooks.d.ts +0 -50
  197. package/dist/lib/confidence/write-hooks.js +0 -159
  198. package/dist/lib/conflict/audit-fk-check.d.ts +0 -72
  199. package/dist/lib/conflict/audit-fk-check.js +0 -131
  200. package/dist/lib/conflict/audit-writer.d.ts +0 -39
  201. package/dist/lib/conflict/audit-writer.js +0 -133
  202. package/dist/lib/conflict/db-singleton.d.ts +0 -28
  203. package/dist/lib/conflict/db-singleton.js +0 -61
  204. package/dist/lib/conflict/db.d.ts +0 -27
  205. package/dist/lib/conflict/db.js +0 -20
  206. package/dist/lib/conflict/detector-direct.d.ts +0 -21
  207. package/dist/lib/conflict/detector-direct.js +0 -105
  208. package/dist/lib/conflict/evidence.d.ts +0 -24
  209. package/dist/lib/conflict/evidence.js +0 -76
  210. package/dist/lib/conflict/index.d.ts +0 -14
  211. package/dist/lib/conflict/index.js +0 -12
  212. package/dist/lib/conflict/scheduler.d.ts +0 -78
  213. package/dist/lib/conflict/scheduler.js +0 -111
  214. package/dist/lib/conflict/shadow.d.ts +0 -75
  215. package/dist/lib/conflict/shadow.js +0 -161
  216. package/dist/lib/conflict/types.d.ts +0 -133
  217. package/dist/lib/conflict/types.js +0 -19
  218. package/dist/lib/cost-cap.d.ts +0 -94
  219. package/dist/lib/deps/deps-registry.d.ts +0 -111
  220. package/dist/lib/error-sanitizer/middleware.d.ts +0 -43
  221. package/dist/lib/error-sanitizer/sanitize.d.ts +0 -78
  222. package/dist/lib/eval-batch.d.ts +0 -34
  223. package/dist/lib/eval-batch.js +0 -103
  224. package/dist/lib/eval-metrics.d.ts +0 -36
  225. package/dist/lib/eval-metrics.js +0 -95
  226. package/dist/lib/eval.d.ts +0 -106
  227. package/dist/lib/eval.js +0 -343
  228. package/dist/lib/events/bus.d.ts +0 -135
  229. package/dist/lib/fts-anchor.d.ts +0 -1
  230. package/dist/lib/hooks/classifier.d.ts +0 -47
  231. package/dist/lib/hooks/classifier.js +0 -129
  232. package/dist/lib/hooks/config.d.ts +0 -49
  233. package/dist/lib/hooks/config.js +0 -106
  234. package/dist/lib/hooks/decorators.d.ts +0 -35
  235. package/dist/lib/hooks/decorators.js +0 -59
  236. package/dist/lib/hooks/pipeline.d.ts +0 -76
  237. package/dist/lib/hooks/pipeline.js +0 -213
  238. package/dist/lib/hooks/privacy-filter-adapter.d.ts +0 -55
  239. package/dist/lib/hooks/privacy-filter-adapter.js +0 -84
  240. package/dist/lib/hooks/rate-limit-constant-time.d.ts +0 -57
  241. package/dist/lib/hooks/rate-limit-constant-time.js +0 -69
  242. package/dist/lib/hooks/rate-limit-dryrun-fix.d.ts +0 -71
  243. package/dist/lib/hooks/rate-limit-dryrun-fix.js +0 -110
  244. package/dist/lib/hooks/rate-limit.d.ts +0 -54
  245. package/dist/lib/hooks/rate-limit.js +0 -122
  246. package/dist/lib/hooks/server-deps.d.ts +0 -61
  247. package/dist/lib/hooks/server-deps.js +0 -92
  248. package/dist/lib/hooks/source-allowlist.d.ts +0 -26
  249. package/dist/lib/hooks/source-allowlist.js +0 -53
  250. package/dist/lib/hooks/types.d.ts +0 -129
  251. package/dist/lib/hooks/types.js +0 -24
  252. package/dist/lib/hooks/worker.d.ts +0 -56
  253. package/dist/lib/hooks/worker.js +0 -150
  254. package/dist/lib/ingest-router.d.ts +0 -25
  255. package/dist/lib/ocr-detector.d.ts +0 -61
  256. package/dist/lib/ocr-detector.js +0 -138
  257. package/dist/lib/ocr-engine-stub.d.ts +0 -48
  258. package/dist/lib/ocr-engine-stub.js +0 -190
  259. package/dist/lib/ocr-engines/google-doc-ai.d.ts +0 -36
  260. package/dist/lib/ocr-engines/google-doc-ai.js +0 -164
  261. package/dist/lib/ocr-jobs.d.ts +0 -67
  262. package/dist/lib/ocr-jobs.js +0 -129
  263. package/dist/lib/op-audit-extension/ran-at-guard.d.ts +0 -86
  264. package/dist/lib/op-audit.d.ts +0 -71
  265. package/dist/lib/privacy-br/detector.d.ts +0 -42
  266. package/dist/lib/privacy-br/detector.js +0 -130
  267. package/dist/lib/privacy-br/index.d.ts +0 -20
  268. package/dist/lib/privacy-br/index.js +0 -20
  269. package/dist/lib/privacy-br/integration.d.ts +0 -71
  270. package/dist/lib/privacy-br/integration.js +0 -74
  271. package/dist/lib/privacy-br/patterns.d.ts +0 -117
  272. package/dist/lib/privacy-br/patterns.js +0 -434
  273. package/dist/lib/privacy-br/redact.d.ts +0 -42
  274. package/dist/lib/privacy-br/redact.js +0 -103
  275. package/dist/lib/privacy-br/types.d.ts +0 -55
  276. package/dist/lib/privacy-br/types.js +0 -25
  277. package/dist/lib/regex-extract/extractor.d.ts +0 -30
  278. package/dist/lib/regex-extract/frontmatter.d.ts +0 -44
  279. package/dist/lib/regex-extract/index.d.ts +0 -14
  280. package/dist/lib/regex-extract/ingest-router-l4.d.ts +0 -76
  281. package/dist/lib/regex-extract/patterns.d.ts +0 -61
  282. package/dist/lib/regex-extract/production-wire.d.ts +0 -128
  283. package/dist/lib/regex-extract/reconcile.d.ts +0 -162
  284. package/dist/lib/regex-extract/strip-code.d.ts +0 -24
  285. package/dist/lib/regex-extract/types.d.ts +0 -48
  286. package/dist/lib/reranker.d.ts +0 -80
  287. package/dist/lib/shadow-tracker.d.ts +0 -191
  288. package/dist/lib/shadow-tracker.js +0 -384
  289. package/dist/lib/spo-injection.d.ts +0 -52
  290. package/dist/lib/telemetry-collector.d.ts +0 -158
  291. package/dist/lib/telemetry-collector.js +0 -249
  292. package/dist/lib/temporal-detector.d.ts +0 -27
  293. package/dist/lib/viewer/auth.d.ts +0 -37
  294. package/dist/lib/viewer/auth.js +0 -70
  295. package/dist/lib/viewer/backpressure.d.ts +0 -59
  296. package/dist/lib/viewer/backpressure.js +0 -100
  297. package/dist/lib/viewer/broadcast-singleton.d.ts +0 -34
  298. package/dist/lib/viewer/broadcast-singleton.js +0 -49
  299. package/dist/lib/viewer/broadcast.d.ts +0 -66
  300. package/dist/lib/viewer/broadcast.js +0 -96
  301. package/dist/lib/viewer/event-types.d.ts +0 -132
  302. package/dist/lib/viewer/event-types.js +0 -74
  303. package/dist/lib/viewer/instrumentation.d.ts +0 -106
  304. package/dist/lib/viewer/instrumentation.js +0 -224
  305. package/dist/lib/viewer/migration.d.ts +0 -23
  306. package/dist/lib/viewer/migration.js +0 -56
  307. package/dist/lib/viewer/redaction.d.ts +0 -44
  308. package/dist/lib/viewer/redaction.js +0 -139
  309. package/dist/lib/viewer/session.d.ts +0 -51
  310. package/dist/lib/viewer/session.js +0 -87
  311. package/dist/mcp/tools/answer.d.ts +0 -94
  312. package/dist/mcp/tools/archive.d.ts +0 -152
  313. package/dist/mcp/tools/archive.js +0 -170
  314. package/dist/mcp/tools/conflict.d.ts +0 -44
  315. package/dist/mcp/tools/conflict.js +0 -130
  316. package/dist/mcp/tools/hooks.d.ts +0 -29
  317. package/dist/mcp/tools/hooks.js +0 -78
  318. package/dist/mcp/tools/mark.d.ts +0 -38
  319. package/dist/mcp/tools/mark.js +0 -82
  320. package/dist/mcp/tools/viewer.d.ts +0 -58
  321. package/dist/mcp/tools/viewer.js +0 -64
  322. package/dist/mcp-server.d.ts +0 -2
  323. package/dist/metrics.d.ts +0 -3
  324. package/dist/noise-filter.d.ts +0 -18
  325. package/dist/notion-sync.d.ts +0 -7
  326. package/dist/notion-sync.js +0 -97
  327. package/dist/observability/adapters/a3-adapter.d.ts +0 -63
  328. package/dist/observability/adapters/a3-adapter.js +0 -83
  329. package/dist/observability/adapters/p1-adapter.d.ts +0 -49
  330. package/dist/observability/adapters/p1-adapter.js +0 -63
  331. package/dist/observability/adapters/p5-adapter.d.ts +0 -36
  332. package/dist/observability/adapters/p5-adapter.js +0 -71
  333. package/dist/observability/cardinality.d.ts +0 -61
  334. package/dist/observability/cardinality.js +0 -300
  335. package/dist/observability/collectors/db-stats.collector.d.ts +0 -9
  336. package/dist/observability/collectors/db-stats.collector.js +0 -88
  337. package/dist/observability/collectors/eventbus.collector.d.ts +0 -6
  338. package/dist/observability/collectors/eventbus.collector.js +0 -50
  339. package/dist/observability/collectors/process.collector.d.ts +0 -7
  340. package/dist/observability/collectors/process.collector.js +0 -93
  341. package/dist/observability/collectors/provider-telemetry.collector.d.ts +0 -11
  342. package/dist/observability/collectors/provider-telemetry.collector.js +0 -112
  343. package/dist/observability/collectors/search-telemetry.collector.d.ts +0 -12
  344. package/dist/observability/collectors/search-telemetry.collector.js +0 -76
  345. package/dist/observability/exporter.d.ts +0 -30
  346. package/dist/observability/exporter.js +0 -182
  347. package/dist/observability/index.d.ts +0 -22
  348. package/dist/observability/index.js +0 -21
  349. package/dist/observability/metrics.d.ts +0 -53
  350. package/dist/observability/metrics.js +0 -213
  351. package/dist/observability/privacy-guard.d.ts +0 -32
  352. package/dist/observability/privacy-guard.js +0 -116
  353. package/dist/observability/record.d.ts +0 -83
  354. package/dist/observability/record.js +0 -217
  355. package/dist/observability/registry.d.ts +0 -60
  356. package/dist/observability/registry.js +0 -93
  357. package/dist/observability/types.d.ts +0 -115
  358. package/dist/observability/types.js +0 -235
  359. package/dist/observability.d.ts +0 -131
  360. package/dist/plugins/nox-hooks/index.d.ts +0 -61
  361. package/dist/plugins/nox-hooks/index.js +0 -99
  362. package/dist/primer.d.ts +0 -1
  363. package/dist/privacy/filter.d.ts +0 -27
  364. package/dist/privacy/patterns.d.ts +0 -29
  365. package/dist/privacy/tag-parser.d.ts +0 -24
  366. package/dist/project-context-gen.d.ts +0 -10
  367. package/dist/providers/embedding/gemini.d.ts +0 -73
  368. package/dist/providers/embedding/openai.d.ts +0 -76
  369. package/dist/providers/embedding/types.d.ts +0 -39
  370. package/dist/providers/embedding/voyage.d.ts +0 -36
  371. package/dist/providers/index.d.ts +0 -116
  372. package/dist/providers/llm/anthropic.d.ts +0 -29
  373. package/dist/providers/llm/chain.d.ts +0 -99
  374. package/dist/providers/llm/gemini.d.ts +0 -48
  375. package/dist/providers/llm/openai.d.ts +0 -64
  376. package/dist/providers/llm/types.d.ts +0 -47
  377. package/dist/providers/telemetry.d.ts +0 -87
  378. package/dist/providers/types.d.ts +0 -42
  379. package/dist/query-entity-count.d.ts +0 -54
  380. package/dist/reflect.d.ts +0 -26
  381. package/dist/reindex-errors.d.ts +0 -7
  382. package/dist/reindex.d.ts +0 -16
  383. package/dist/retention.d.ts +0 -40
  384. package/dist/salience.d.ts +0 -85
  385. package/dist/scripts/migrate-v17-ops-audit.d.ts +0 -17
  386. package/dist/search-dedup.d.ts +0 -44
  387. package/dist/search-expansion.d.ts +0 -20
  388. package/dist/search.d.ts +0 -62
  389. package/dist/seh-detector.d.ts +0 -31
  390. package/dist/self-improve.d.ts +0 -1
  391. package/dist/session-distill.d.ts +0 -29
  392. package/dist/session-update.d.ts +0 -1
  393. package/dist/shared-memory.d.ts +0 -24
  394. package/dist/stats.d.ts +0 -1
  395. package/dist/temporal-retrieval.d.ts +0 -132
  396. package/dist/tier-manager.d.ts +0 -69
  397. package/dist/vectorize.d.ts +0 -16
  398. package/dist/watch.d.ts +0 -8
package/dist/evals.js DELETED
@@ -1,351 +0,0 @@
1
- /**
2
- * evals.ts — F10 Phase B endpoint (Eval Dashboard)
3
- *
4
- * Adds one read-only endpoint under `/api/observability/*`:
5
- *
6
- * GET /api/observability/evals?db_source=<filter>&limit=<n>
7
- * Returns the historical ablation/gate runs aggregated from `audits/data-G*`
8
- * directories on disk. Each row carries enough metric breadth to drive the
9
- * dashboard (nDCG@10, MRR, recall@10), the DB it ran against (for the post-G6
10
- * fiasco filter — see [[g6-ablation-results-2026-05-20]]), and a list of gate
11
- * annotations that match its run date.
12
- *
13
- * Source data layer
14
- * -----------------
15
- * The audits directory is heterogeneous:
16
- *
17
- * audits/data-g10b/*.json → {summary, per_category} per run (a8 mutex active/disabled)
18
- * audits/data-g10c/*.json → derived aggregate: {aggregate.active, aggregate.disabled,
19
- * per_style_active, per_style_disabled}
20
- * audits/data-g10d/*.json → {summary, per_category} per t-threshold (a8d_t1/t2/baseline/control)
21
- * audits/data-g10e/*.json → derived per-query diff array (NOT a run aggregate — skipped)
22
- *
23
- * Each "summary" block has:
24
- * { label, toggles, n_queries, fixture_dir, endpoint, ndcg_at_10, mrr,
25
- * recall_at_10, precision_at_5, mean_latency_ms, p95_latency_ms,
26
- * n_valid_queries, wallclock_s }
27
- *
28
- * Adapter strategy:
29
- * - Walk `audits/data-<X>/` directories.
30
- * - For each .json file, sniff the shape:
31
- * (a) `{ summary, per_category, ... }` → emit one row from summary
32
- * (b) `{ aggregate: { active, disabled }, ... }` → emit two rows (one per agg key)
33
- * (c) anything else (e.g. per-query derived array) → skip with a warn to stderr
34
- * - `ran_at` = file mtime (UTC ISO), since aggregate JSONs don't carry a wall-clock.
35
- * - `db_source` = parsed from `summary.fixture_dir` (last path component → e.g.
36
- * "g9-g5db-2026-05-20" → "g5.db"; the convention is documented in
37
- * [[g6-ablation-results-2026-05-20]] and [[g10-mutex-validated-2026-05-20]]).
38
- * - `config_id` = `summary.label` (already unique per run).
39
- * - `run_id` = `<G-bucket>::<label>` for stability across reads.
40
- *
41
- * Annotations:
42
- * - Loaded from `public/observability/gate-annotations.json` once per process.
43
- * - A row gets every annotation whose date falls on the same UTC calendar day.
44
- *
45
- * Caching:
46
- * - 5-minute in-memory TTL (spec allows). Single-process server, no infra.
47
- * - Test harness exposes `_resetEvalsCache()` to clear state between cases.
48
- *
49
- * Spec: specs/2026-05-01-F10-observability-dashboard.md §"P1 EVAL DASHBOARD"
50
- * Status: Phase B implementation-ready
51
- */
52
- import { readdirSync, readFileSync, statSync } from "fs";
53
- import { join } from "path";
54
- // ── DB-source heuristic ───────────────────────────────────────────────────────
55
- /**
56
- * Maps the fixture_dir leaf to the canonical DB filename, the way the team
57
- * tracks DBs in audits. The convention (per [[g6-ablation-results-2026-05-20]]
58
- * and follow-ups) is that a fixture directory contains a substring naming the
59
- * DB the eval was actually run against.
60
- *
61
- * Examples seen on disk:
62
- * /path/to/workspace/eval-data/g9-g5db-2026-05-20 → "g5.db"
63
- * /…/eval-data/entity-eval-v2 → "entity-eval-v2.db"
64
- * /…/eval-data/entity-eval → "entity-eval.db"
65
- * /…/eval-data/g9 → "g9.db"
66
- *
67
- * Returns "unknown.db" if no match. Tests must cover the unknown fallback.
68
- */
69
- export function inferDbSource(fixtureDir) {
70
- if (!fixtureDir)
71
- return "unknown.db";
72
- const leaf = fixtureDir.split("/").filter((s) => s.length > 0).pop() ?? "";
73
- const lower = leaf.toLowerCase();
74
- // Specific names first (longest-prefix wins)
75
- if (lower.includes("entity-eval-v2"))
76
- return "entity-eval-v2.db";
77
- if (lower.includes("entity-eval"))
78
- return "entity-eval.db";
79
- if (lower.includes("g5db") || lower.includes("g5-db") || lower.includes("g5.db"))
80
- return "g5.db";
81
- if (lower.includes("g9-g5db"))
82
- return "g5.db";
83
- if (lower.includes("g9"))
84
- return "g9.db";
85
- if (lower.includes("g10"))
86
- return "g10.db";
87
- return "unknown.db";
88
- }
89
- /**
90
- * Bucket key derived from the data-Gxx directory name. Used for stable run_ids
91
- * and as a fallback config grouping in the UI.
92
- */
93
- export function gateBucketFromDir(dir) {
94
- // dir like "data-g10b" → "g10b"
95
- const leaf = dir.split("/").filter((s) => s.length > 0).pop() ?? "";
96
- const m = /^data-([A-Za-z0-9._-]+)$/.exec(leaf);
97
- return m && m[1] ? m[1] : leaf;
98
- }
99
- // ── Number coercion ───────────────────────────────────────────────────────────
100
- function toNumOrNull(v) {
101
- if (typeof v === "number" && Number.isFinite(v))
102
- return v;
103
- return null;
104
- }
105
- function toStringOrNull(v) {
106
- return typeof v === "string" ? v : null;
107
- }
108
- // ── Annotation matching ───────────────────────────────────────────────────────
109
- /**
110
- * Returns the YYYY-MM-DD UTC calendar string for an ms timestamp. ISO substring
111
- * is intentional — keeps the implementation portable across Node versions and
112
- * avoids a Date locale dependency.
113
- */
114
- export function isoDay(ms) {
115
- return new Date(ms).toISOString().slice(0, 10);
116
- }
117
- /**
118
- * Picks every annotation whose `date` matches the run's UTC calendar day.
119
- * Returns label strings (not the full object) — the UI only needs the labels
120
- * to overlay vertical lines + tooltips, and richer data lives in the gate file.
121
- */
122
- export function matchAnnotations(ranAtMs, annotations) {
123
- const day = isoDay(ranAtMs);
124
- const out = [];
125
- for (const a of annotations) {
126
- if (a.date === day)
127
- out.push(a.label);
128
- }
129
- return out;
130
- }
131
- // ── Adapter: parse one JSON file → 0..N rows ──────────────────────────────────
132
- /**
133
- * Parses one audit JSON file into a list of normalized EvalRow.
134
- *
135
- * Returns `[]` (with stderr warning) when the file is unreadable, malformed,
136
- * or carries a shape we explicitly do not aggregate (e.g. per-query diff arrays).
137
- * Never throws — endpoint hardening per spec.
138
- */
139
- export function parseAuditFile(filePath, fileMtimeMs, bucket, annotations) {
140
- let raw;
141
- try {
142
- raw = readFileSync(filePath, "utf-8");
143
- }
144
- catch (err) {
145
- process.stderr.write(`[evals] read failed: ${filePath}: ${String(err)}\n`);
146
- return [];
147
- }
148
- let parsed;
149
- try {
150
- parsed = JSON.parse(raw);
151
- }
152
- catch (err) {
153
- process.stderr.write(`[evals] JSON parse failed: ${filePath}: ${String(err)}\n`);
154
- return [];
155
- }
156
- if (parsed === null || typeof parsed !== "object" || Array.isArray(parsed)) {
157
- // Per-query derived arrays (g10e) or other non-object shapes → skip silently.
158
- return [];
159
- }
160
- const obj = parsed;
161
- const ranAtMs = fileMtimeMs;
162
- const ranAt = new Date(ranAtMs).toISOString();
163
- const matched = matchAnnotations(ranAtMs, annotations);
164
- // Shape (b): derived aggregate { aggregate: { active, disabled }, ... }
165
- if (obj["aggregate"] && typeof obj["aggregate"] === "object" && !Array.isArray(obj["aggregate"])) {
166
- const agg = obj["aggregate"];
167
- const rows = [];
168
- for (const key of Object.keys(agg)) {
169
- const sub = agg[key];
170
- if (sub && typeof sub === "object" && !Array.isArray(sub)) {
171
- const row = rowFromSummary(sub, filePath, bucket, ranAt, ranAtMs, matched, `${key}`);
172
- if (row)
173
- rows.push(row);
174
- }
175
- }
176
- return rows;
177
- }
178
- // Shape (a): { summary, per_category, ... }
179
- if (obj["summary"] && typeof obj["summary"] === "object" && !Array.isArray(obj["summary"])) {
180
- const row = rowFromSummary(obj["summary"], filePath, bucket, ranAt, ranAtMs, matched, null);
181
- return row ? [row] : [];
182
- }
183
- // Unknown shape → skip silently.
184
- return [];
185
- }
186
- function rowFromSummary(s, filePath, bucket, ranAt, ranAtMs, annotations, configSuffix) {
187
- const label = toStringOrNull(s.label);
188
- const configIdBase = label ?? "unknown";
189
- const configId = configSuffix ? `${configIdBase}::${configSuffix}` : configIdBase;
190
- const fixtureDir = toStringOrNull(s.fixture_dir);
191
- const dbSource = inferDbSource(fixtureDir);
192
- const nQueries = toNumOrNull(s.n_queries) ?? toNumOrNull(s.n_valid_queries);
193
- return {
194
- run_id: `${bucket}::${configId}`,
195
- config_id: configId,
196
- db_source: dbSource,
197
- ndcg_at_10: toNumOrNull(s.ndcg_at_10),
198
- mrr: toNumOrNull(s.mrr),
199
- recall_at_10: toNumOrNull(s.recall_at_10),
200
- precision_at_5: toNumOrNull(s.precision_at_5),
201
- mean_latency_ms: toNumOrNull(s.mean_latency_ms),
202
- p95_latency_ms: toNumOrNull(s.p95_latency_ms),
203
- n_queries: nQueries,
204
- ran_at: ranAt,
205
- ran_at_ms: ranAtMs,
206
- source_path: filePath,
207
- annotations,
208
- };
209
- }
210
- // ── Directory walker ──────────────────────────────────────────────────────────
211
- /**
212
- * Returns the sorted absolute paths of `audits/data-*` JSON files under the
213
- * given root. Best-effort: directories that disappear mid-walk are skipped.
214
- */
215
- export function collectAuditFiles(auditsRoot) {
216
- const out = [];
217
- let entries;
218
- try {
219
- entries = readdirSync(auditsRoot);
220
- }
221
- catch {
222
- return out;
223
- }
224
- for (const name of entries) {
225
- if (!name.startsWith("data-"))
226
- continue;
227
- const dir = join(auditsRoot, name);
228
- let st;
229
- try {
230
- st = statSync(dir);
231
- }
232
- catch {
233
- continue;
234
- }
235
- if (!st.isDirectory())
236
- continue;
237
- const bucket = gateBucketFromDir(dir);
238
- let files;
239
- try {
240
- files = readdirSync(dir);
241
- }
242
- catch {
243
- continue;
244
- }
245
- for (const f of files) {
246
- if (!f.endsWith(".json"))
247
- continue;
248
- const fp = join(dir, f);
249
- let fst;
250
- try {
251
- fst = statSync(fp);
252
- }
253
- catch {
254
- continue;
255
- }
256
- if (!fst.isFile())
257
- continue;
258
- out.push({ file: fp, bucket, mtimeMs: fst.mtimeMs });
259
- }
260
- }
261
- return out;
262
- }
263
- // ── Annotations loader ────────────────────────────────────────────────────────
264
- /**
265
- * Best-effort load of the gate-annotations.json file. Returns `[]` on missing
266
- * file, parse error, or wrong shape — callers tolerate empty annotation list.
267
- */
268
- export function loadAnnotations(filePath) {
269
- let raw;
270
- try {
271
- raw = readFileSync(filePath, "utf-8");
272
- }
273
- catch {
274
- return [];
275
- }
276
- let parsed;
277
- try {
278
- parsed = JSON.parse(raw);
279
- }
280
- catch (err) {
281
- process.stderr.write(`[evals] annotations JSON parse failed: ${String(err)}\n`);
282
- return [];
283
- }
284
- if (!Array.isArray(parsed))
285
- return [];
286
- const out = [];
287
- for (const item of parsed) {
288
- if (!item || typeof item !== "object" || Array.isArray(item))
289
- continue;
290
- const rec = item;
291
- const date = toStringOrNull(rec["date"]);
292
- const label = toStringOrNull(rec["label"]);
293
- if (!date || !label)
294
- continue;
295
- const description = toStringOrNull(rec["description"]) ?? undefined;
296
- const ann = description !== undefined
297
- ? { date, label, description }
298
- : { date, label };
299
- out.push(ann);
300
- }
301
- return out;
302
- }
303
- const DEFAULT_TTL_MS = 5 * 60 * 1000;
304
- let cached = null;
305
- /** Exposed for tests. */
306
- export function _resetEvalsCache() {
307
- cached = null;
308
- }
309
- /**
310
- * Build the row list from disk (no cache). Useful for tests.
311
- */
312
- export function buildEvalRows(opts = {}) {
313
- const auditsRoot = opts.auditsRoot ?? join(process.cwd(), "..", "audits");
314
- const annotationsPath = opts.annotationsPath
315
- ?? join(process.cwd(), "public", "observability", "gate-annotations.json");
316
- const annotations = loadAnnotations(annotationsPath);
317
- const files = collectAuditFiles(auditsRoot);
318
- const rows = [];
319
- for (const f of files) {
320
- const parsed = parseAuditFile(f.file, f.mtimeMs, f.bucket, annotations);
321
- for (const r of parsed)
322
- rows.push(r);
323
- }
324
- rows.sort((a, b) => a.ran_at_ms - b.ran_at_ms);
325
- return rows;
326
- }
327
- /**
328
- * Endpoint handler. Returns an array of EvalRow already sorted by ran_at ASC,
329
- * filtered by db_source if requested, and capped to `limit`.
330
- */
331
- export function handleObsEvals(query = {}, opts = {}) {
332
- const ttlMs = opts.ttlMs ?? DEFAULT_TTL_MS;
333
- const now = opts.now ? opts.now() : Date.now();
334
- const fresh = cached && !query.force && now - cached.generatedAtMs < ttlMs;
335
- if (!fresh) {
336
- const rows = buildEvalRows(opts);
337
- cached = { generatedAtMs: now, rows };
338
- }
339
- const rows = cached.rows;
340
- const dbFilter = query.dbSource && query.dbSource !== "all" ? query.dbSource : null;
341
- const limit = Math.max(1, Math.min(2000, Math.floor(query.limit ?? 500)));
342
- const filtered = dbFilter ? rows.filter((r) => r.db_source === dbFilter) : rows;
343
- return filtered.slice(0, limit);
344
- }
345
- // ── _internals for tests ──────────────────────────────────────────────────────
346
- export const _internals = {
347
- DEFAULT_TTL_MS,
348
- toNumOrNull,
349
- toStringOrNull,
350
- rowFromSummary,
351
- };
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * generate-user-profile.ts — Fase 1.7a
4
- *
5
- * Generates `shared/USER-PROFILE.md` from KG + chunks. Agents read this file
6
- * at boot to have rich context without a search round-trip each turn.
7
- *
8
- * Sections:
9
- * 1. Top 20 entities (by mention_count) with relevant attributes
10
- * 2. Active projects (status != closed)
11
- * 3. Decisions in the last 30 days
12
- * 4. Declared preferences (chunks of type lesson/preference)
13
- *
14
- * Run: node dist/generate-user-profile.js
15
- * NOX_PROFILE_OUTPUT: optional absolute path for the output file.
16
- * Defaults to $OPENCLAW_WORKSPACE/shared/USER-PROFILE.md (or ./USER-PROFILE.md).
17
- */
18
- export declare function generateUserProfile(): string;
@@ -1,18 +0,0 @@
1
- #!/usr/bin/env node
2
- /**
3
- * graphify-ingest.ts — Fase 2: ingest graphify output into nox-mem
4
- *
5
- * Converte graph.json (graphify) em chunks no nox-mem com rate-limit.
6
- * Cada node graphify vira 1 chunk com chunk_type='graph_node', source_type='external',
7
- * is_compiled=1. Edges são embutidas no chunk_text como "Links: rel → target".
8
- *
9
- * Rate-limit: batch 500 chunks, pause 5min (300s) entre batches.
10
- * Janela proibida: 22:30-01:30 BRT (não concorre com nightly-maintenance).
11
- *
12
- * Usage:
13
- * node dist/graphify-ingest.js <graph.json path> <repo-name>
14
- *
15
- * Example:
16
- * node dist/graphify-ingest.js /path/to/your/graphify-out/graph.json YourProject
17
- */
18
- export {};
package/dist/impact.d.ts DELETED
@@ -1,39 +0,0 @@
1
- export interface ImpactNeighbor {
2
- entity_id: number;
3
- name: string;
4
- entity_type: string;
5
- mention_count: number;
6
- direction: 'outgoing' | 'incoming';
7
- relation_type: string;
8
- relation_reason: string;
9
- confidence: number;
10
- }
11
- export interface ImpactGroup {
12
- reason: string;
13
- count: number;
14
- neighbors: ImpactNeighbor[];
15
- }
16
- export interface ImpactResult {
17
- query: string;
18
- resolved_entity: {
19
- id: number;
20
- name: string;
21
- type: string;
22
- mention_count: number;
23
- } | null;
24
- ambiguous_matches?: Array<{
25
- id: number;
26
- name: string;
27
- type: string;
28
- mention_count: number;
29
- }>;
30
- total_neighbors: number;
31
- unique_entities: number;
32
- by_reason: ImpactGroup[];
33
- blast_radius_score: number;
34
- duration_ms: number;
35
- }
36
- export declare function computeImpact(opts: {
37
- query: string;
38
- }): ImpactResult;
39
- export declare function formatImpact(r: ImpactResult, mode?: 'json' | 'text'): string;
package/dist/index.d.ts DELETED
@@ -1,2 +0,0 @@
1
- #!/usr/bin/env node
2
- export {};
@@ -1,44 +0,0 @@
1
- import Database from "better-sqlite3";
2
- export interface EntityFrontmatter {
3
- name?: string;
4
- description?: string;
5
- type?: string;
6
- [key: string]: unknown;
7
- }
8
- export interface ParsedEntity {
9
- frontmatter: EntityFrontmatter;
10
- frontmatterRaw: string;
11
- compiled: string;
12
- timeline: string[];
13
- }
14
- /**
15
- * Section boost values by section type. Multiplicative in search ranking but
16
- * applied additively when combined with tier/importance boosts to avoid
17
- * stacking (v3.4 lesson). Compiled is the current truth → highest weight.
18
- */
19
- export declare const SECTION_BOOST: Record<string, number>;
20
- /**
21
- * Parse an entity file into frontmatter + compiled truth + timeline entries.
22
- * Returns null if the file doesn't match the expected format (caller falls
23
- * back to regular ingest).
24
- *
25
- * Expected structure:
26
- * 1. YAML frontmatter block (--- ... ---) at top
27
- * 2. Compiled truth section (free-form markdown until "## Timeline" or EOF)
28
- * 3. Optional "## Timeline" section with `- **DATE** — [tag] description` bullets
29
- */
30
- export declare function parseEntityFile(content: string): ParsedEntity | null;
31
- /**
32
- * Ingest a single entity file as 1 frontmatter chunk + 1 compiled chunk
33
- * + N timeline chunks. All chunks share the same source_file relative path.
34
- *
35
- * chunk_type is inferred from directory:
36
- * memory/entities/agents/ → 'person' (never-decay)
37
- * memory/entities/projects/ → 'project' (365d retention)
38
- * memory/entities/systems/ → 'other' (90d — system state evolves)
39
- * memory/entities/people/ → 'person'
40
- */
41
- export declare function ingestEntityFile(filePath: string, externalDb?: Database.Database): Promise<{
42
- parsed: boolean;
43
- chunks: number;
44
- }>;
package/dist/ingest.d.ts DELETED
@@ -1,13 +0,0 @@
1
- import Database from "better-sqlite3";
2
- export declare function detectChunkType(relPath: string): string;
3
- export declare function extractDate(relPath: string): string | null;
4
- export declare function chunkMarkdown(content: string): string[];
5
- export declare function chunkJson(content: string): string[];
6
- /**
7
- * @param filePath — absolute path to .md or .json file
8
- * @param externalDb — optional db connection (used by reindex for single-connection)
9
- * @param skipDelete — skip DELETE before insert (used by reindex since table is already cleared)
10
- */
11
- export declare function ingestFile(filePath: string, externalDb?: Database.Database, skipDelete?: boolean): Promise<{
12
- chunks: number;
13
- }>;
package/dist/kg-llm.d.ts DELETED
@@ -1,39 +0,0 @@
1
- /**
2
- * kg-llm.ts — LLM-powered entity and relation extraction for Knowledge Graph v2
3
- * Uses Gemini 2.5 Flash (free tier, 500 RPM) for rich extraction.
4
- * Migrated from Ollama llama3.2:3b (2026-04-11) — Ollama was inactive since ~March.
5
- *
6
- * Fase 1.7a (2026-04-19):
7
- * - Ontology grounding: campos ricos por tipo (project.value_brl, person.whatsapp_number, etc)
8
- * - Multi-stage fast-path regex PT-BR: detecta entidades óbvias sem chamar Gemini
9
- * (valores R$/US$, CNPJ/CPF, datas BR, telefones +55, emails, URLs)
10
- * - Economia esperada: 30-40% de chamadas Gemini em chunks densos
11
- */
12
- type EntityType = "person" | "project" | "agent" | "tool" | "concept" | "organization" | "technology" | "document" | "decision" | "metric";
13
- interface LLMEntity {
14
- name: string;
15
- type: EntityType;
16
- attributes?: Record<string, string | number | boolean>;
17
- }
18
- export type RelationReason = 'depends_on' | 'derived_from' | 'opposes' | 'extends' | 'replaces' | 'mentions' | 'unknown';
19
- export declare const VALID_RELATION_REASONS: RelationReason[];
20
- export declare function mapRelationTypeToReason(relationType: string | undefined): RelationReason | null;
21
- export declare function normalizeRelationReason(raw: any, relationType?: string): RelationReason;
22
- interface LLMRelation {
23
- source: string;
24
- relation: string;
25
- target: string;
26
- reason?: RelationReason;
27
- }
28
- interface LLMExtraction {
29
- entities: LLMEntity[];
30
- relations: LLMRelation[];
31
- fast_path_used?: boolean;
32
- }
33
- interface FastPathHit {
34
- kind: "value_brl" | "value_usd" | "value_eur" | "cnpj" | "cpf" | "date" | "phone" | "email" | "url" | "percent" | "proper_noun";
35
- match: string;
36
- }
37
- export declare function fastPathExtract(text: string): FastPathHit[];
38
- export declare function extractWithLLM(text: string): Promise<LLMExtraction>;
39
- export {};
@@ -1,72 +0,0 @@
1
- export declare function ensureGraphTables(): void;
2
- export declare function buildGraph(limit?: number): {
3
- entities: number;
4
- relations: number;
5
- };
6
- export interface GraphNode {
7
- id: number;
8
- name: string;
9
- entityType: string;
10
- mentionCount: number;
11
- }
12
- export interface GraphEdge {
13
- source: string;
14
- relation: string;
15
- target: string;
16
- }
17
- export declare function queryEntity(name: string): {
18
- entity: GraphNode | null;
19
- relations: GraphEdge[];
20
- };
21
- export declare function mergeEntities(): {
22
- merged: number;
23
- };
24
- /**
25
- * Read-only preview of mergeEntities() — reports what would be merged without
26
- * mutating the graph. Backs `kg-merge --dry-run` (CLAUDE.md rule #6: destructive
27
- * ops must support dry-run). Mirrors the canonicalization logic of mergeEntities.
28
- */
29
- export declare function previewMergeEntities(): {
30
- wouldMerge: number;
31
- groups: Array<{
32
- entityType: string;
33
- canonicalName: string;
34
- duplicates: number;
35
- }>;
36
- };
37
- export declare function getGraphStats(): string;
38
- export declare function formatEntityQuery(name: string): string;
39
- export interface PruneResult {
40
- expired: number;
41
- decayed: number;
42
- confirmed: number;
43
- }
44
- /**
45
- * Decay confidence on relations not recently confirmed.
46
- * Relations lose 0.1 confidence every 30 days without re-confirmation.
47
- * Relations below 0.3 confidence are marked for expiry.
48
- * Relations past expires_at are deleted.
49
- */
50
- export declare function pruneKnowledgeGraph(dryRun?: boolean): PruneResult;
51
- /**
52
- * Re-confirm a relation (reset confidence to 0.9, extend TTL 90 days).
53
- * Call this when a relation is observed again in new chunks.
54
- */
55
- export declare function confirmRelation(sourceId: number, targetId: number, relationType: string): void;
56
- export declare function formatPruneResult(result: PruneResult): string;
57
- export declare function ensureDecisionVersionTable(): void;
58
- export declare function upsertDecision(key: string, content: string, sourceFile?: string, author?: string): number;
59
- export declare function getDecisionHistory(key: string): Array<{
60
- version: number;
61
- content: string;
62
- created_at: string;
63
- superseded_at: string | null;
64
- is_current: number;
65
- }>;
66
- export declare function getCurrentDecision(key: string): string | null;
67
- export declare function listDecisions(): Array<{
68
- decision_key: string;
69
- version: number;
70
- content: string;
71
- created_at: string;
72
- }>;
@@ -1,41 +0,0 @@
1
- /**
2
- * src/lib/answer/config.ts — Defaults + env overrides for P1.
3
- *
4
- * D41 #1 locks `gemini-2.5-flash-lite` as default.
5
- * CLAUDE.md regra #3 forbids silent fallback to `gemini-2.5-flash`.
6
- *
7
- * Env overrides honoured:
8
- * NOX_ANSWER_MODEL — overrides default model id
9
- * NOX_ANSWER_PROVIDER — overrides provider name
10
- * NOX_ANSWER_TEMPERATURE — overrides temperature (parse-float, clamped 0..1)
11
- * NOX_ANSWER_TOPK — overrides top-K (parse-int, clamped 1..20)
12
- * NOX_ANSWER_MAX_TOKENS — overrides max output tokens (parse-int, clamped 64..8192)
13
- * NOX_ANSWER_TIMEOUT_MS — overrides per-LLM timeout (parse-int, ≥1000)
14
- */
15
- export declare const DEFAULT_MODEL = "gemini-2.5-flash-lite";
16
- export declare const DEFAULT_PROVIDER = "gemini";
17
- export declare const DEFAULT_TOPK = 8;
18
- export declare const DEFAULT_MAX_TOKENS = 1500;
19
- export declare const DEFAULT_TEMPERATURE = 0.2;
20
- export declare const DEFAULT_TIMEOUT_MS = 15000;
21
- /** Hard limits — never widen without spec update. */
22
- export declare const TOPK_MIN = 1;
23
- export declare const TOPK_MAX = 20;
24
- export declare const MAX_TOKENS_MIN = 64;
25
- export declare const MAX_TOKENS_MAX = 8192;
26
- /** Resolved config object — env wins over hardcoded default, opts win over env. */
27
- export interface ResolvedConfig {
28
- provider: string;
29
- model: string;
30
- topK: number;
31
- maxTokens: number;
32
- temperature: number;
33
- timeoutMs: number;
34
- }
35
- export declare function resolveConfig(opts: {
36
- provider?: string;
37
- model?: string;
38
- topK?: number;
39
- maxTokens?: number;
40
- temperature?: number;
41
- }): ResolvedConfig;