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
@@ -1,47 +0,0 @@
1
- /**
2
- * src/lib/answer/index.ts — Public API for P1 (T1-T4 + minimal T5 partial).
3
- *
4
- * Exports:
5
- * answer(opts) → AnswerResult
6
- * Types: AnswerOpts, AnswerResult, Citation, RetrievedChunk, AnswerMetadata
7
- * Helpers (re-export for adjacency modules): selectProvider, buildPrompt, retrieveContext
8
- *
9
- * Pipeline (T1-T4 scope + minimal T5/T6 anti-hallucination retry-once):
10
- * 1. resolveConfig(opts) → ResolvedConfig
11
- * 2. retrieveContext(question, topK) → RetrievedChunk[]
12
- * 3. buildPrompt(question, chunks) → {system, user}
13
- * 4. provider.complete(prompt + cfg) → LLMCallResult
14
- * 5. parseCitations(text, chunks) → { citations, hallucinated[] }
15
- * 6. If hallucinated.length > 0 → retry once with buildRetryPrompt()
16
- * 7. If retry still hallucinates → throw AnswerError('hallucination_after_retry')
17
- *
18
- * Empty retrieval → returns canonical "no memory matches" answer WITHOUT
19
- * calling the LLM (kickoff §6 retrieval_empty path).
20
- */
21
- import type { AnswerOpts, AnswerResult, AnswerMetadata, Citation, RetrievedChunk, AnswerFailureReason } from "./types.js";
22
- export type { AnswerOpts, AnswerResult, AnswerMetadata, Citation, RetrievedChunk, AnswerFailureReason, } from "./types.js";
23
- export { selectProvider, MockProvider } from "./provider.js";
24
- export type { LLMProvider, LLMCallOpts, LLMCallResult } from "./provider.js";
25
- export { buildPrompt, buildRetryPrompt } from "./prompt.js";
26
- export { retrieveContext, __setRawSearchForTests } from "./retrieval.js";
27
- export { resolveConfig } from "./config.js";
28
- /** Thrown when the pipeline produces an unrecoverable failure. */
29
- export declare class AnswerError extends Error {
30
- readonly reason: AnswerFailureReason;
31
- readonly metadata: Partial<AnswerMetadata>;
32
- constructor(reason: AnswerFailureReason, message: string, metadata: Partial<AnswerMetadata>);
33
- }
34
- export declare function answer(opts: AnswerOpts): Promise<AnswerResult>;
35
- interface ParsedCitations {
36
- citations: Citation[];
37
- /** Marker strings the LLM emitted that did NOT exist in the retrieval set. */
38
- hallucinated: string[];
39
- }
40
- /**
41
- * Extract `[chunk_N]` markers from LLM output, validate each against the
42
- * retrieval set, and return Citation objects + the list of hallucinated
43
- * markers (out-of-range N).
44
- *
45
- * Exported for testability.
46
- */
47
- export declare function parseCitations(text: string, chunks: RetrievedChunk[]): ParsedCitations;
@@ -1,37 +0,0 @@
1
- /**
2
- * src/lib/answer/prompt.ts — Prompt assembly for P1 (T3 scope).
3
- *
4
- * Two builders:
5
- * buildPrompt() — initial pass; standard anti-hallucination guard.
6
- * buildRetryPrompt() — stricter variant when first pass cited a marker
7
- * that did not exist in the retrieval set
8
- * (anti-hallucination retry, partial T5/T6).
9
- *
10
- * Design (kickoff §T3 + critical decision #1):
11
- * - LLM only ever sees marker_ids (`chunk_1`..`chunk_N`), never DB ids.
12
- * - System prompt = anti-hallucination guard + citation rule.
13
- * - User prompt = the question + the numbered context block.
14
- * - Token-budget truncation drops LOWEST-SCORE chunks first
15
- * (kickoff critical decision #2 — old chunks can be high-salience).
16
- *
17
- * Pure functions: no I/O, deterministic given inputs.
18
- */
19
- import type { RetrievedChunk } from "./types.js";
20
- /**
21
- * Assemble system + user prompt for the initial LLM call.
22
- *
23
- * @param question User question.
24
- * @param chunks Retrieved chunks with marker_id already assigned.
25
- * @param maxTokens Token budget for the full prompt (incl. completion reserve).
26
- */
27
- export declare function buildPrompt(question: string, chunks: RetrievedChunk[], maxTokens?: number): {
28
- system: string;
29
- user: string;
30
- };
31
- /**
32
- * Stricter retry variant. Same shape as buildPrompt; different system prompt.
33
- */
34
- export declare function buildRetryPrompt(question: string, chunks: RetrievedChunk[], maxTokens?: number): {
35
- system: string;
36
- user: string;
37
- };
@@ -1,47 +0,0 @@
1
- export interface LLMCallOpts {
2
- system: string;
3
- user: string;
4
- maxTokens: number;
5
- temperature: number;
6
- model: string;
7
- }
8
- export interface LLMCallResult {
9
- text: string;
10
- tokensIn: number;
11
- tokensOut: number;
12
- latencyMs: number;
13
- }
14
- export interface LLMProvider {
15
- readonly name: string;
16
- complete(opts: LLMCallOpts): Promise<LLMCallResult>;
17
- }
18
- /**
19
- * MockProvider — used by tests and by `--provider mock` CLI flag.
20
- *
21
- * Behaviour:
22
- * - If `responses` queue non-empty, dequeue one per call (deterministic).
23
- * - Else returns an echo of the question prefix + `[chunk_1]` citation,
24
- * useful for happy-path smoke tests without scripting.
25
- * - Token counts derived from text length / 4 (rough char-per-token).
26
- */
27
- export declare class MockProvider implements LLMProvider {
28
- readonly name = "mock";
29
- private readonly responses;
30
- /** Per-call delay in ms; lets tests assert latency_ms is set. */
31
- private readonly delayMs;
32
- /** Optional canned error to throw on next call. */
33
- private errorOnNextCall;
34
- constructor(responses?: string[], delayMs?: number);
35
- /** Test seam — force the next complete() to throw. */
36
- throwNext(err: Error): void;
37
- complete(opts: LLMCallOpts): Promise<LLMCallResult>;
38
- }
39
- /**
40
- * Select a provider by name. Honours `NOX_ANSWER_PROVIDER` env when no
41
- * explicit name is passed. Defaults to Gemini (D41 #1).
42
- *
43
- * Unknown name → falls back to Gemini default rather than throwing, so
44
- * a typo in CLI flag never causes a hard crash; metadata.provider will
45
- * surface the actual provider used.
46
- */
47
- export declare function selectProvider(name?: string): LLMProvider;
@@ -1,36 +0,0 @@
1
- /**
2
- * src/lib/answer/retrieval.ts — Hybrid-search wrapper for P1 (T2 scope).
3
- *
4
- * T1-T4 MVP: this module exposes `retrieveContext()` which is a thin
5
- * wrapper over the existing hybrid search (BM25 + sqlite-vec + RRF +
6
- * salience). In production this calls `src/lib/search/hybrid.ts`; here
7
- * (staged dir) we expose `defaultRawSearch` as a pluggable injection
8
- * point so the unit tests can inject deterministic fixtures.
9
- *
10
- * Responsibilities (kickoff §T2 DoD):
11
- * 1. Call hybrid search (or injected stub).
12
- * 2. Dedupe near-duplicates by content_hash (keep highest score).
13
- * 3. Cap to topK.
14
- * 4. Assign marker_id = "chunk_1".."chunk_N" stable to retrieved order.
15
- *
16
- * Pure function: no DB writes, no LLM calls.
17
- */
18
- import type { RawChunk, RetrievedChunk } from "./types.js";
19
- /**
20
- * Signature for the underlying hybrid search call.
21
- * In prod this is bound to `hybridSearch()` from existing search module.
22
- */
23
- export type RawSearchFn = (question: string, topK: number) => Promise<RawChunk[]>;
24
- /**
25
- * Test-only seam: replace the underlying raw search with a stub.
26
- * Pass `null` to restore real-prod hybridSearch binding (set by VPS adapter).
27
- */
28
- export declare function __setRawSearchForTests(fn: RawSearchFn | null): void;
29
- /**
30
- * Retrieve context chunks for a question.
31
- *
32
- * @param question Natural-language input.
33
- * @param topK Max chunks to return. Caller should pre-clamp via config.
34
- * @returns Deduplicated, marker-assigned chunks ordered by score desc.
35
- */
36
- export declare function retrieveContext(question: string, topK: number): Promise<RetrievedChunk[]>;
@@ -1,99 +0,0 @@
1
- /**
2
- * src/lib/answer/telemetry.ts — P1 T7 scope: persist per-call answer metadata.
3
- *
4
- * Writes one row to `answer_telemetry` (schema v11) per answer() invocation,
5
- * INCLUDING failures (LLM error, hallucination_after_retry, retrieval_empty).
6
- *
7
- * Privacy rule (kickoff §critical decision):
8
- * - NEVER log raw question or answer text.
9
- * - Store `question_hash = sha256(question)[:16]` instead.
10
- *
11
- * Storage abstraction:
12
- * - `TelemetryStore` interface decouples lib from better-sqlite3.
13
- * - `InMemoryTelemetryStore` for tests (push to array, query helpers).
14
- * - VPS apply step binds a `Sqlite3TelemetryStore` that targets
15
- * `nox-mem.db` opened by the rest of the codebase. We avoid hard-
16
- * coding `better-sqlite3` here to keep the staged dir installable
17
- * with zero runtime deps (tests use the in-memory store).
18
- *
19
- * Cost estimation:
20
- * - We accept `cost_estimate_usd` as input from caller (provider knows the
21
- * per-model unit price). When absent we derive a 0-USD estimate so the
22
- * column stays NOT NULL per v11 schema.
23
- *
24
- * Failure-reason mapping:
25
- * The v11 schema CHECK constrains `failed_reason IN ('hallucinated_citation',
26
- * 'provider_down', 'token_budget')` OR NULL. The lib's AnswerFailureReason
27
- * enum is broader (includes 'hallucination_after_retry', 'llm_timeout',
28
- * 'retrieval_empty', 'llm_error', 'invalid_input'). We map to the schema
29
- * alphabet in `mapFailureReason()` so the INSERT never violates CHECK.
30
- */
31
- import type { AnswerFailureReason, AnswerMetadata } from "./types.js";
32
- /** Subset of v11 schema column names — keeps the lib decoupled from SQL. */
33
- export interface AnswerTelemetryRow {
34
- question_hash: string;
35
- session_id: string | null;
36
- timestamp_ms: number;
37
- provider: string;
38
- model: string;
39
- retrieval_count: number;
40
- citation_count: number;
41
- tokens_in: number | null;
42
- tokens_out: number | null;
43
- latency_ms: number;
44
- fallback_used: 0 | 1;
45
- failed_reason: SchemaFailureReason | null;
46
- cost_estimate_usd: number;
47
- }
48
- /** Subset allowed by the v11 schema CHECK. */
49
- export type SchemaFailureReason = "hallucinated_citation" | "provider_down" | "token_budget";
50
- /** Storage seam: prod implementation wraps better-sqlite3 prepared insert. */
51
- export interface TelemetryStore {
52
- insert(row: AnswerTelemetryRow): void;
53
- }
54
- /** In-memory store for tests + dev. Keeps every row in `rows`. */
55
- export declare class InMemoryTelemetryStore implements TelemetryStore {
56
- readonly rows: AnswerTelemetryRow[];
57
- insert(row: AnswerTelemetryRow): void;
58
- /** Convenience: filter by `failed_reason` (or NULL for success rows). */
59
- byFailure(reason: SchemaFailureReason | null): AnswerTelemetryRow[];
60
- }
61
- /** sha256(question)[:16] — never store raw question text. */
62
- export declare function hashQuestion(question: string): string;
63
- /**
64
- * Map the lib's broader AnswerFailureReason → the narrow v11 schema alphabet.
65
- * Returns NULL for happy-path success (no failure reason on metadata).
66
- *
67
- * Mapping:
68
- * hallucinated_citation → hallucinated_citation
69
- * hallucination_after_retry → hallucinated_citation (root cause is same)
70
- * llm_error → provider_down
71
- * llm_timeout → provider_down
72
- * retrieval_empty → NULL (not a failure — surfaces via citations.length=0)
73
- * invalid_input → NULL (caller bug; we still record the row but no SQL-side failure tag)
74
- */
75
- export declare function mapFailureReason(reason: AnswerFailureReason | undefined): SchemaFailureReason | null;
76
- export declare function estimateCost(model: string, tokensIn: number, tokensOut: number): number;
77
- export interface RecordAnswerInput {
78
- question: string;
79
- citationCount: number;
80
- metadata: AnswerMetadata;
81
- /** Optional session correlation; pass-through from caller (CLI/HTTP/MCP). */
82
- sessionId?: string | null;
83
- /** Optional override; if absent we estimate from model + tokens. */
84
- costEstimateUsd?: number;
85
- /** Override clock — test seam; defaults to Date.now(). */
86
- now?: () => number;
87
- }
88
- /**
89
- * Persist one telemetry row. Returns the row written (useful in tests).
90
- * Never throws — telemetry failures must NOT break the user-facing answer call.
91
- * Errors are swallowed and surfaced via process.stderr in non-test mode.
92
- */
93
- export declare function recordAnswer(store: TelemetryStore, input: RecordAnswerInput): AnswerTelemetryRow;
94
- /**
95
- * Prepared INSERT string the VPS adapter should use. Exported so the apply
96
- * step can `const STMT = db.prepare(INSERT_SQL)` without re-deriving column
97
- * order from scratch.
98
- */
99
- export declare const INSERT_SQL: string;
@@ -1,108 +0,0 @@
1
- /**
2
- * src/lib/answer/types.ts — Public interfaces for P1 answer primitive.
3
- *
4
- * Per kickoff doc PR #18 §3:
5
- * - AnswerOpts: request shape (kickoff §6 contract simplified for T1-T4 MVP)
6
- * - AnswerResult: response shape with citations + metadata
7
- * - Citation: chunk_id + marker_id bridge (LLM never sees real ids)
8
- * - RetrievedChunk: shape returned by retrieval.ts wrapper
9
- *
10
- * Naming convention: kickoff doc uses AnswerRequest/AnswerResponse; T1-T4
11
- * spec from operator uses AnswerOpts/AnswerResult. We export BOTH aliases
12
- * so downstream T8 (CLI) and T9 (HTTP) can pick either without churn.
13
- */
14
- import type { LLMProvider } from "./provider.js";
15
- /** Request to answer(): {question, topK, maxTokens, provider, model, temperature}. */
16
- export interface AnswerOpts {
17
- /** Natural-language question. Required. */
18
- question: string;
19
- /** Top-K chunks from retrieval. Default 8. Range 1-20. */
20
- topK?: number;
21
- /** Max output tokens from LLM. Default 1500. */
22
- maxTokens?: number;
23
- /** Provider name: 'gemini' | 'mock' | future 'openai'/'anthropic'. Default 'gemini'. */
24
- provider?: string;
25
- /** Model id. Default 'gemini-2.5-flash-lite' (D41 #1 locked). */
26
- model?: string;
27
- /** LLM temperature. Default 0.2. */
28
- temperature?: number;
29
- /**
30
- * Optional injection point for testing. If set, used INSTEAD of selectProvider().
31
- * Production code should leave undefined and let config defaults flow.
32
- */
33
- providerOverride?: LLMProvider;
34
- /**
35
- * Optional retrieval injection point for testing/mocking.
36
- * If set, used INSTEAD of the real hybrid search wrapper.
37
- */
38
- retrieveOverride?: (question: string, topK: number) => Promise<RetrievedChunk[]>;
39
- }
40
- /** Alias kept for kickoff-doc consistency. */
41
- export type AnswerRequest = AnswerOpts;
42
- /** A chunk surfaced by retrieval, with marker_id assigned for LLM-side citation. */
43
- export interface RetrievedChunk {
44
- /** Real DB chunk id — server-side only, NEVER shown to LLM. */
45
- chunk_id: number;
46
- /** Display marker for LLM: "chunk_1", "chunk_2", ..., "chunk_N". */
47
- marker_id: string;
48
- /** Source file path (absolute or workspace-relative). */
49
- file_path: string;
50
- /** Optional "L42-L58" hint when chunk maps to specific lines. */
51
- line_range?: string;
52
- /** Chunk body text. */
53
- content: string;
54
- /** Optional content hash (sha256 hex) used by dedupe. */
55
- content_hash?: string;
56
- /** Optional fused score from hybrid search (RRF or similar). */
57
- score?: number;
58
- }
59
- /** A citation as returned to the caller — marker_id + real chunk pointer. */
60
- export interface Citation {
61
- chunk_id: number;
62
- marker_id: string;
63
- file_path: string;
64
- line_range?: string;
65
- /** Short excerpt (≤200 chars) for inline preview. */
66
- snippet: string;
67
- }
68
- /** Top-level answer() return shape. */
69
- export interface AnswerResult {
70
- /** Final answer text from LLM. May contain `[chunk_N]` markers inline. */
71
- answer: string;
72
- /** Citations parsed + validated against the retrieval set. */
73
- citations: Citation[];
74
- /** Telemetry/observability metadata. */
75
- metadata: AnswerMetadata;
76
- }
77
- export type AnswerResponse = AnswerResult;
78
- export interface AnswerMetadata {
79
- /** Wall-clock latency in milliseconds, end-to-end. */
80
- latency_ms: number;
81
- /** Input tokens billed to the LLM call. */
82
- tokens_in: number;
83
- /** Output tokens billed to the LLM call. */
84
- tokens_out: number;
85
- /** Provider name as actually selected. */
86
- provider: string;
87
- /** Model id as actually called. */
88
- model: string;
89
- /** Chunks returned by retrieval (post-dedupe, pre-prompt). */
90
- retrieval_count: number;
91
- /** Whether fallback retry path was exercised (e.g., hallucinated citation). */
92
- fallback_used?: boolean;
93
- /** If non-success path, machine-readable reason. */
94
- failed_reason?: AnswerFailureReason;
95
- /** Number of retries attempted (0 or 1 in T1-T4 MVP). */
96
- retry_count?: number;
97
- }
98
- /** Failure-reason enum, aligned with kickoff §6 contract + T5/T6 partial. */
99
- export type AnswerFailureReason = "hallucinated_citation" | "hallucination_after_retry" | "retrieval_empty" | "llm_error" | "llm_timeout" | "invalid_input";
100
- /** Internal: chunk before marker_id is assigned (raw from search). */
101
- export interface RawChunk {
102
- chunk_id: number;
103
- file_path: string;
104
- line_range?: string;
105
- content: string;
106
- content_hash?: string;
107
- score?: number;
108
- }
@@ -1,54 +0,0 @@
1
- /**
2
- * G12 — Adoption helpers for safeErrorMessage across staged-* handlers.
3
- *
4
- * This file ships drop-in replacements for the leaky `return { status: 500,
5
- * body: { error: (e as Error).message } }` pattern found in:
6
- *
7
- * - staged-P2/edits/src/api/hooks.ts:99 (G12 root)
8
- * - staged-L2/edits/src/api/conflict.ts:181 (resolution_failed message)
9
- * - staged-L3/edits/src/api/mark.ts (R-L3-3) (SQL fragment leak)
10
- *
11
- * Use the patch helpers below from each handler. Example (P2 hooks.ts L99):
12
- *
13
- * - return { status: 500, body: { error: (e as Error).message } };
14
- * + return { status: 500, body: safeError500(e, { context: "hooks.recent" }) };
15
- *
16
- * Logging: caller can pass an `onLog` callback to forward the raw error to
17
- * stderr / structured logger. The sanitized correlation_id is the link.
18
- */
19
- import { type SanitizeOptions } from "./safe-error-message.js";
20
- export interface SafeError500Options extends SanitizeOptions {
21
- /** Short context tag for log correlation (e.g. "hooks.recent", "conflict.resolve"). */
22
- context?: string;
23
- /** Logger override. Defaults to console.error. */
24
- onLog?: (info: {
25
- correlationId: string;
26
- raw: unknown;
27
- context?: string;
28
- }) => void;
29
- }
30
- /**
31
- * Build a sanitized 5xx response body. Always returns `{ error, correlation_id }`.
32
- * Side-effect: logs raw error to onLog (or console.error) with the correlation_id.
33
- */
34
- export declare function safeError500(e: unknown, opts?: SafeError500Options): {
35
- error: string;
36
- correlation_id: string;
37
- };
38
- /**
39
- * Convenience for the L2 conflict resolve path (`409 resolution_failed`).
40
- * Shape differs slightly — keeps the `error` discriminator for backward
41
- * compat while still sanitizing the inner message.
42
- */
43
- export declare function safeConflict409(e: unknown, opts?: SafeError500Options): {
44
- error: "resolution_failed";
45
- message: string;
46
- correlation_id: string;
47
- };
48
- /**
49
- * Convenience for the L3 mark path 500 leak. Same shape as `safeError500`.
50
- */
51
- export declare function safeMark500(e: unknown, opts?: SafeError500Options): {
52
- error: string;
53
- correlation_id: string;
54
- };
@@ -1,70 +0,0 @@
1
- /**
2
- * G12 — Safe error message helper (Wave G)
3
- *
4
- * Sanitize `(e as Error).message` before exposing it in 5xx responses across
5
- * `/api/hooks/recent` (P2), `/api/conflict/:id/resolve` (L2), `/api/mark` (L3),
6
- * and any future endpoint that may surface backend errors to clients.
7
- *
8
- * Complements G5 (Wave F) which strips `error.stack`. Even with stack gone,
9
- * `error.message` itself often contains:
10
- * - Absolute file paths (`/Users/.../db.ts:42:15`, `/root/.openclaw/...`)
11
- * - SQLite connection strings (`SQLITE_ERROR: ... /var/lib/nox-mem.db ...`)
12
- * - Env var values dumped by stricter ORMs (`ENV NOX_API_TOKEN=xyz ...`)
13
- * - Stack frame fragments embedded in long `Error.toString()` outputs
14
- *
15
- * Strategy:
16
- * 1. Walk through a small set of regex strippers (paths, DB strings, env).
17
- * 2. Generate a stable correlation ID (UUID-v4) to map sanitized error
18
- * → original (logged server-side via `onLog`).
19
- * 3. Return generic message + correlationId. Caller logs full error.
20
- *
21
- * Threats addressed (refs PR #58 §14):
22
- * - G12 (High) — `/api/hooks/recent` 500 leaks DB path.
23
- * - R-L3-3 — `/mark` 500 leaks SQL fragments.
24
- * - Cross-cutting hardening across staged-* edit dirs.
25
- *
26
- * Backward compat:
27
- * - Pure function. No deps on Express / Fastify / http. Caller wires it
28
- * into existing handlers.
29
- * - Env-opt-in for full passthrough during local dev:
30
- * NOX_ERROR_PASSTHROUGH=1 → returns raw message (NEVER set in prod).
31
- * A boot-time WARN should be emitted by the caller when active.
32
- */
33
- export interface SanitizeOptions {
34
- /** Cap on returned message length. Default 200. */
35
- maxLength?: number;
36
- /** Generic fallback when stripping leaves empty/garbage. Default 'internal_error'. */
37
- fallback?: string;
38
- /** Allow raw passthrough (DEV ONLY). Default false. */
39
- passthrough?: boolean;
40
- }
41
- export interface SafeErrorResult {
42
- /** Sanitized, length-capped message safe to expose in 5xx responses. */
43
- message: string;
44
- /** UUID-v4 correlation ID. Log server-side with the raw error for triage. */
45
- correlationId: string;
46
- }
47
- /**
48
- * Sanitize an arbitrary error/string for client exposure.
49
- */
50
- export declare function safeErrorMessage(e: unknown, opts?: SanitizeOptions): SafeErrorResult;
51
- /**
52
- * Build a complete `{ error, correlation_id }` body for HTTP 500 responses.
53
- * Optionally invoke a logging hook with the full original error.
54
- */
55
- export declare function buildSafeErrorBody(e: unknown, opts?: SanitizeOptions & {
56
- onLog?: (info: {
57
- correlationId: string;
58
- raw: unknown;
59
- }) => void;
60
- }): {
61
- error: string;
62
- correlation_id: string;
63
- };
64
- /**
65
- * Boot-time check — caller should invoke once on startup to emit a WARN
66
- * when passthrough is enabled.
67
- */
68
- export declare function checkErrorPassthroughAtBoot(logger?: {
69
- warn: (msg: string) => void;
70
- }, env?: NodeJS.ProcessEnv): boolean;
@@ -1,37 +0,0 @@
1
- /**
2
- * A2.1 T6 — Common-password dictionary.
3
- *
4
- * Top common passwords compiled from:
5
- * - SecLists 10k-most-common.txt (EN, top frequencies) — public domain
6
- * - HaveIBeenPwned top-200 (EN/global) — public/CC0
7
- * - Brazilian-Portuguese common passwords corpus (curated) — original
8
- *
9
- * Purpose: penalize passphrases that match (case-insensitive) entries here in
10
- * `estimateEntropyBits()`. This is NOT a blocklist — a single-word match drops
11
- * the entropy estimate to <=10 bits regardless of length, which the strength
12
- * tier then rejects under default (`good`, >=50 bits) policy.
13
- *
14
- * Deliberately small (≈1000 entries) to keep import cost low. zxcvbn carries
15
- * ~30k; we accept the lower coverage to remain zero-dep.
16
- *
17
- * To extend: append entries in lowercase, no trailing whitespace. Keep BR
18
- * patterns grouped separately for auditability. Never commit a passphrase
19
- * you have actually used.
20
- */
21
- /** Common passwords — lowercase. Order has no semantic meaning. */
22
- export declare const COMMON_PASSWORDS: ReadonlySet<string>;
23
- /**
24
- * Returns true when `lowercased` matches a common password entry directly.
25
- * Caller MUST pass already-lowercased string.
26
- */
27
- export declare function isCommonPassword(lowercased: string): boolean;
28
- /**
29
- * Returns true when `lowercased` CONTAINS a common substring of length >=4.
30
- * Heuristic — used to penalise "Password!23" → contains "password".
31
- *
32
- * Note: we restrict to substrings of length >=4 to avoid pathological cases
33
- * (e.g., "amor" inside "saudosamor" would trigger; that's acceptable for an
34
- * entropy *estimate*, since true random Brazilian-Portuguese is unlikely to
35
- * contain those exact 4-grams clustered).
36
- */
37
- export declare function containsCommonSubstring(lowercased: string): boolean;