nox-mem 3.1.1 → 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 (397) 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 +1 -22
  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/privacy/__tests__/filter.test.js +352 -0
  39. package/dist/providers/__tests__/conformance-extended.test.js +249 -0
  40. package/dist/providers/__tests__/conformance.test.js +98 -0
  41. package/dist/providers/__tests__/cost-cap.test.js +151 -0
  42. package/dist/providers/__tests__/e2e-real.test.js +79 -0
  43. package/dist/providers/__tests__/factory.test.js +80 -0
  44. package/dist/providers/__tests__/fallback.test.js +223 -0
  45. package/dist/providers/__tests__/gemini.test.js +191 -0
  46. package/dist/providers/__tests__/health.test.js +128 -0
  47. package/dist/providers/__tests__/telemetry.test.js +219 -0
  48. package/dist/reindex.js +2 -2
  49. package/package.json +3 -4
  50. package/dist/api/answer.d.ts +0 -116
  51. package/dist/api/answer.validate-patch.d.ts +0 -72
  52. package/dist/api/brief-diversity.d.ts +0 -64
  53. package/dist/api/brief.d.ts +0 -114
  54. package/dist/api/conflict.d.ts +0 -33
  55. package/dist/api/conflict.js +0 -143
  56. package/dist/api/cors.d.ts +0 -73
  57. package/dist/api/events-stream-limited.d.ts +0 -133
  58. package/dist/api/events-stream-limited.js +0 -217
  59. package/dist/api/events-stream.d.ts +0 -53
  60. package/dist/api/events-stream.js +0 -125
  61. package/dist/api/export.d.ts +0 -42
  62. package/dist/api/export.js +0 -85
  63. package/dist/api/health-confidence-adapter.d.ts +0 -29
  64. package/dist/api/health-confidence-adapter.js +0 -73
  65. package/dist/api/health-confidence.d.ts +0 -36
  66. package/dist/api/health-confidence.js +0 -141
  67. package/dist/api/hooks.d.ts +0 -50
  68. package/dist/api/hooks.js +0 -115
  69. package/dist/api/import.d.ts +0 -38
  70. package/dist/api/import.js +0 -87
  71. package/dist/api/ingest-event.d.ts +0 -65
  72. package/dist/api/mark.d.ts +0 -42
  73. package/dist/api/mark.js +0 -127
  74. package/dist/api/server-deps-a2.d.ts +0 -55
  75. package/dist/api/server-deps-a2.js +0 -138
  76. package/dist/api/server-deps-l2-l3.d.ts +0 -68
  77. package/dist/api/server-deps-l2-l3.js +0 -123
  78. package/dist/api/server-deps-p1.d.ts +0 -84
  79. package/dist/api/server-deps-p2.d.ts +0 -32
  80. package/dist/api/server-deps-p2.js +0 -84
  81. package/dist/api/server-deps-p5.d.ts +0 -66
  82. package/dist/api/server-deps-p5.js +0 -139
  83. package/dist/api/viewer-static.d.ts +0 -30
  84. package/dist/api/viewer-static.js +0 -102
  85. package/dist/api/wire-up.d.ts +0 -54
  86. package/dist/api-impact.d.ts +0 -30
  87. package/dist/api-server.d.ts +0 -2
  88. package/dist/backfill-fts-anchor.d.ts +0 -15
  89. package/dist/backfill-source-type.d.ts +0 -20
  90. package/dist/churn.d.ts +0 -31
  91. package/dist/cli/answer.d.ts +0 -66
  92. package/dist/cli/conflict.d.ts +0 -38
  93. package/dist/cli/conflict.js +0 -282
  94. package/dist/cli/export.d.ts +0 -51
  95. package/dist/cli/export.js +0 -280
  96. package/dist/cli/hooks.d.ts +0 -54
  97. package/dist/cli/hooks.js +0 -133
  98. package/dist/cli/import.d.ts +0 -52
  99. package/dist/cli/import.js +0 -274
  100. package/dist/cli/mark.d.ts +0 -33
  101. package/dist/cli/mark.js +0 -130
  102. package/dist/cli/ocr-batch.d.ts +0 -12
  103. package/dist/cli/ocr-batch.js +0 -411
  104. package/dist/cli/snapshot-main.d.ts +0 -30
  105. package/dist/cli/snapshot-main.js +0 -47
  106. package/dist/cli/viewer.d.ts +0 -35
  107. package/dist/cli/viewer.js +0 -71
  108. package/dist/cli-telemetry.d.ts +0 -36
  109. package/dist/cli-telemetry.js +0 -150
  110. package/dist/compact.d.ts +0 -7
  111. package/dist/consolidate.d.ts +0 -18
  112. package/dist/consolidation.d.ts +0 -32
  113. package/dist/cross-agent-v2.d.ts +0 -45
  114. package/dist/cross-search.d.ts +0 -11
  115. package/dist/crystallize.d.ts +0 -43
  116. package/dist/db.d.ts +0 -11
  117. package/dist/dedup.d.ts +0 -1
  118. package/dist/detect-changes.d.ts +0 -29
  119. package/dist/digest.d.ts +0 -1
  120. package/dist/doctor.d.ts +0 -1
  121. package/dist/embed.d.ts +0 -57
  122. package/dist/evals.d.ts +0 -176
  123. package/dist/evals.js +0 -351
  124. package/dist/generate-user-profile.d.ts +0 -18
  125. package/dist/graphify-ingest.d.ts +0 -18
  126. package/dist/impact.d.ts +0 -39
  127. package/dist/index.d.ts +0 -2
  128. package/dist/ingest-entity.d.ts +0 -44
  129. package/dist/ingest.d.ts +0 -13
  130. package/dist/kg-llm.d.ts +0 -39
  131. package/dist/knowledge-graph.d.ts +0 -72
  132. package/dist/lib/answer/config.d.ts +0 -41
  133. package/dist/lib/answer/index.d.ts +0 -47
  134. package/dist/lib/answer/prompt.d.ts +0 -37
  135. package/dist/lib/answer/provider.d.ts +0 -47
  136. package/dist/lib/answer/retrieval.d.ts +0 -36
  137. package/dist/lib/answer/telemetry.d.ts +0 -99
  138. package/dist/lib/answer/types.d.ts +0 -108
  139. package/dist/lib/api/error-leak-fix.d.ts +0 -54
  140. package/dist/lib/api/safe-error-message.d.ts +0 -70
  141. package/dist/lib/archive/common-passwords.d.ts +0 -37
  142. package/dist/lib/archive/common-passwords.js +0 -753
  143. package/dist/lib/archive/encryption.d.ts +0 -81
  144. package/dist/lib/archive/encryption.js +0 -236
  145. package/dist/lib/archive/enforce-strength.d.ts +0 -54
  146. package/dist/lib/archive/enforce-strength.js +0 -70
  147. package/dist/lib/archive/entropy.d.ts +0 -34
  148. package/dist/lib/archive/entropy.js +0 -180
  149. package/dist/lib/archive/export-locking.d.ts +0 -102
  150. package/dist/lib/archive/export-locking.js +0 -202
  151. package/dist/lib/archive/format.d.ts +0 -20
  152. package/dist/lib/archive/format.js +0 -174
  153. package/dist/lib/archive/index.d.ts +0 -23
  154. package/dist/lib/archive/index.js +0 -17
  155. package/dist/lib/archive/manifest.d.ts +0 -53
  156. package/dist/lib/archive/manifest.js +0 -183
  157. package/dist/lib/archive/migration.d.ts +0 -36
  158. package/dist/lib/archive/migration.js +0 -100
  159. package/dist/lib/archive/migrations/v18_to_v19.d.ts +0 -16
  160. package/dist/lib/archive/migrations/v18_to_v19.js +0 -18
  161. package/dist/lib/archive/orchestrator.d.ts +0 -166
  162. package/dist/lib/archive/orchestrator.js +0 -428
  163. package/dist/lib/archive/serializers/chunks.d.ts +0 -30
  164. package/dist/lib/archive/serializers/chunks.js +0 -113
  165. package/dist/lib/archive/serializers/embeddings.d.ts +0 -36
  166. package/dist/lib/archive/serializers/embeddings.js +0 -115
  167. package/dist/lib/archive/serializers/kg.d.ts +0 -28
  168. package/dist/lib/archive/serializers/kg.js +0 -184
  169. package/dist/lib/archive/serializers/ops_audit.d.ts +0 -21
  170. package/dist/lib/archive/serializers/ops_audit.js +0 -97
  171. package/dist/lib/archive/server-deps.d.ts +0 -131
  172. package/dist/lib/archive/server-deps.js +0 -232
  173. package/dist/lib/archive/strength.d.ts +0 -50
  174. package/dist/lib/archive/strength.js +0 -77
  175. package/dist/lib/archive/types.d.ts +0 -159
  176. package/dist/lib/archive/types.js +0 -45
  177. package/dist/lib/archive/unpack-streaming.d.ts +0 -70
  178. package/dist/lib/archive/unpack-streaming.js +0 -255
  179. package/dist/lib/auth/localhost-guard.d.ts +0 -106
  180. package/dist/lib/confidence/config.d.ts +0 -37
  181. package/dist/lib/confidence/config.js +0 -107
  182. package/dist/lib/confidence/db-shim-singleton.d.ts +0 -20
  183. package/dist/lib/confidence/db-shim-singleton.js +0 -41
  184. package/dist/lib/confidence/db-shim.d.ts +0 -47
  185. package/dist/lib/confidence/db-shim.js +0 -141
  186. package/dist/lib/confidence/mark.d.ts +0 -58
  187. package/dist/lib/confidence/mark.js +0 -168
  188. package/dist/lib/confidence/ranking.d.ts +0 -69
  189. package/dist/lib/confidence/ranking.js +0 -101
  190. package/dist/lib/confidence/search-filter.d.ts +0 -44
  191. package/dist/lib/confidence/search-filter.js +0 -103
  192. package/dist/lib/confidence/types.d.ts +0 -146
  193. package/dist/lib/confidence/types.js +0 -20
  194. package/dist/lib/confidence/write-hooks.d.ts +0 -50
  195. package/dist/lib/confidence/write-hooks.js +0 -159
  196. package/dist/lib/conflict/audit-fk-check.d.ts +0 -72
  197. package/dist/lib/conflict/audit-fk-check.js +0 -131
  198. package/dist/lib/conflict/audit-writer.d.ts +0 -39
  199. package/dist/lib/conflict/audit-writer.js +0 -133
  200. package/dist/lib/conflict/db-singleton.d.ts +0 -28
  201. package/dist/lib/conflict/db-singleton.js +0 -61
  202. package/dist/lib/conflict/db.d.ts +0 -27
  203. package/dist/lib/conflict/db.js +0 -20
  204. package/dist/lib/conflict/detector-direct.d.ts +0 -21
  205. package/dist/lib/conflict/detector-direct.js +0 -105
  206. package/dist/lib/conflict/evidence.d.ts +0 -24
  207. package/dist/lib/conflict/evidence.js +0 -76
  208. package/dist/lib/conflict/index.d.ts +0 -14
  209. package/dist/lib/conflict/index.js +0 -12
  210. package/dist/lib/conflict/scheduler.d.ts +0 -78
  211. package/dist/lib/conflict/scheduler.js +0 -111
  212. package/dist/lib/conflict/shadow.d.ts +0 -75
  213. package/dist/lib/conflict/shadow.js +0 -161
  214. package/dist/lib/conflict/types.d.ts +0 -133
  215. package/dist/lib/conflict/types.js +0 -19
  216. package/dist/lib/cost-cap.d.ts +0 -94
  217. package/dist/lib/deps/deps-registry.d.ts +0 -111
  218. package/dist/lib/error-sanitizer/middleware.d.ts +0 -43
  219. package/dist/lib/error-sanitizer/sanitize.d.ts +0 -78
  220. package/dist/lib/eval-batch.d.ts +0 -34
  221. package/dist/lib/eval-batch.js +0 -103
  222. package/dist/lib/eval-metrics.d.ts +0 -36
  223. package/dist/lib/eval-metrics.js +0 -95
  224. package/dist/lib/eval.d.ts +0 -106
  225. package/dist/lib/eval.js +0 -343
  226. package/dist/lib/events/bus.d.ts +0 -135
  227. package/dist/lib/fts-anchor.d.ts +0 -1
  228. package/dist/lib/hooks/classifier.d.ts +0 -47
  229. package/dist/lib/hooks/classifier.js +0 -129
  230. package/dist/lib/hooks/config.d.ts +0 -49
  231. package/dist/lib/hooks/config.js +0 -106
  232. package/dist/lib/hooks/decorators.d.ts +0 -35
  233. package/dist/lib/hooks/decorators.js +0 -59
  234. package/dist/lib/hooks/pipeline.d.ts +0 -76
  235. package/dist/lib/hooks/pipeline.js +0 -213
  236. package/dist/lib/hooks/privacy-filter-adapter.d.ts +0 -55
  237. package/dist/lib/hooks/privacy-filter-adapter.js +0 -84
  238. package/dist/lib/hooks/rate-limit-constant-time.d.ts +0 -57
  239. package/dist/lib/hooks/rate-limit-constant-time.js +0 -69
  240. package/dist/lib/hooks/rate-limit-dryrun-fix.d.ts +0 -71
  241. package/dist/lib/hooks/rate-limit-dryrun-fix.js +0 -110
  242. package/dist/lib/hooks/rate-limit.d.ts +0 -54
  243. package/dist/lib/hooks/rate-limit.js +0 -122
  244. package/dist/lib/hooks/server-deps.d.ts +0 -61
  245. package/dist/lib/hooks/server-deps.js +0 -92
  246. package/dist/lib/hooks/source-allowlist.d.ts +0 -26
  247. package/dist/lib/hooks/source-allowlist.js +0 -53
  248. package/dist/lib/hooks/types.d.ts +0 -129
  249. package/dist/lib/hooks/types.js +0 -24
  250. package/dist/lib/hooks/worker.d.ts +0 -56
  251. package/dist/lib/hooks/worker.js +0 -150
  252. package/dist/lib/ingest-router.d.ts +0 -25
  253. package/dist/lib/ocr-detector.d.ts +0 -61
  254. package/dist/lib/ocr-detector.js +0 -138
  255. package/dist/lib/ocr-engine-stub.d.ts +0 -48
  256. package/dist/lib/ocr-engine-stub.js +0 -190
  257. package/dist/lib/ocr-engines/google-doc-ai.d.ts +0 -36
  258. package/dist/lib/ocr-engines/google-doc-ai.js +0 -164
  259. package/dist/lib/ocr-jobs.d.ts +0 -67
  260. package/dist/lib/ocr-jobs.js +0 -129
  261. package/dist/lib/op-audit-extension/ran-at-guard.d.ts +0 -86
  262. package/dist/lib/op-audit.d.ts +0 -71
  263. package/dist/lib/privacy-br/detector.d.ts +0 -42
  264. package/dist/lib/privacy-br/detector.js +0 -130
  265. package/dist/lib/privacy-br/index.d.ts +0 -20
  266. package/dist/lib/privacy-br/index.js +0 -20
  267. package/dist/lib/privacy-br/integration.d.ts +0 -71
  268. package/dist/lib/privacy-br/integration.js +0 -74
  269. package/dist/lib/privacy-br/patterns.d.ts +0 -117
  270. package/dist/lib/privacy-br/patterns.js +0 -434
  271. package/dist/lib/privacy-br/redact.d.ts +0 -42
  272. package/dist/lib/privacy-br/redact.js +0 -103
  273. package/dist/lib/privacy-br/types.d.ts +0 -55
  274. package/dist/lib/privacy-br/types.js +0 -25
  275. package/dist/lib/regex-extract/extractor.d.ts +0 -30
  276. package/dist/lib/regex-extract/frontmatter.d.ts +0 -44
  277. package/dist/lib/regex-extract/index.d.ts +0 -14
  278. package/dist/lib/regex-extract/ingest-router-l4.d.ts +0 -76
  279. package/dist/lib/regex-extract/patterns.d.ts +0 -61
  280. package/dist/lib/regex-extract/production-wire.d.ts +0 -128
  281. package/dist/lib/regex-extract/reconcile.d.ts +0 -162
  282. package/dist/lib/regex-extract/strip-code.d.ts +0 -24
  283. package/dist/lib/regex-extract/types.d.ts +0 -48
  284. package/dist/lib/reranker.d.ts +0 -80
  285. package/dist/lib/shadow-tracker.d.ts +0 -191
  286. package/dist/lib/shadow-tracker.js +0 -384
  287. package/dist/lib/spo-injection.d.ts +0 -52
  288. package/dist/lib/telemetry-collector.d.ts +0 -158
  289. package/dist/lib/telemetry-collector.js +0 -249
  290. package/dist/lib/temporal-detector.d.ts +0 -27
  291. package/dist/lib/viewer/auth.d.ts +0 -37
  292. package/dist/lib/viewer/auth.js +0 -70
  293. package/dist/lib/viewer/backpressure.d.ts +0 -59
  294. package/dist/lib/viewer/backpressure.js +0 -100
  295. package/dist/lib/viewer/broadcast-singleton.d.ts +0 -34
  296. package/dist/lib/viewer/broadcast-singleton.js +0 -49
  297. package/dist/lib/viewer/broadcast.d.ts +0 -66
  298. package/dist/lib/viewer/broadcast.js +0 -96
  299. package/dist/lib/viewer/event-types.d.ts +0 -132
  300. package/dist/lib/viewer/event-types.js +0 -74
  301. package/dist/lib/viewer/instrumentation.d.ts +0 -106
  302. package/dist/lib/viewer/instrumentation.js +0 -224
  303. package/dist/lib/viewer/migration.d.ts +0 -23
  304. package/dist/lib/viewer/migration.js +0 -56
  305. package/dist/lib/viewer/redaction.d.ts +0 -44
  306. package/dist/lib/viewer/redaction.js +0 -139
  307. package/dist/lib/viewer/session.d.ts +0 -51
  308. package/dist/lib/viewer/session.js +0 -87
  309. package/dist/mcp/tools/answer.d.ts +0 -94
  310. package/dist/mcp/tools/archive.d.ts +0 -152
  311. package/dist/mcp/tools/archive.js +0 -170
  312. package/dist/mcp/tools/conflict.d.ts +0 -44
  313. package/dist/mcp/tools/conflict.js +0 -130
  314. package/dist/mcp/tools/hooks.d.ts +0 -29
  315. package/dist/mcp/tools/hooks.js +0 -78
  316. package/dist/mcp/tools/mark.d.ts +0 -38
  317. package/dist/mcp/tools/mark.js +0 -82
  318. package/dist/mcp/tools/viewer.d.ts +0 -58
  319. package/dist/mcp/tools/viewer.js +0 -64
  320. package/dist/mcp-server.d.ts +0 -2
  321. package/dist/metrics.d.ts +0 -3
  322. package/dist/noise-filter.d.ts +0 -18
  323. package/dist/notion-sync.d.ts +0 -7
  324. package/dist/notion-sync.js +0 -97
  325. package/dist/observability/adapters/a3-adapter.d.ts +0 -63
  326. package/dist/observability/adapters/a3-adapter.js +0 -83
  327. package/dist/observability/adapters/p1-adapter.d.ts +0 -49
  328. package/dist/observability/adapters/p1-adapter.js +0 -63
  329. package/dist/observability/adapters/p5-adapter.d.ts +0 -36
  330. package/dist/observability/adapters/p5-adapter.js +0 -71
  331. package/dist/observability/cardinality.d.ts +0 -61
  332. package/dist/observability/cardinality.js +0 -300
  333. package/dist/observability/collectors/db-stats.collector.d.ts +0 -9
  334. package/dist/observability/collectors/db-stats.collector.js +0 -88
  335. package/dist/observability/collectors/eventbus.collector.d.ts +0 -6
  336. package/dist/observability/collectors/eventbus.collector.js +0 -50
  337. package/dist/observability/collectors/process.collector.d.ts +0 -7
  338. package/dist/observability/collectors/process.collector.js +0 -93
  339. package/dist/observability/collectors/provider-telemetry.collector.d.ts +0 -11
  340. package/dist/observability/collectors/provider-telemetry.collector.js +0 -112
  341. package/dist/observability/collectors/search-telemetry.collector.d.ts +0 -12
  342. package/dist/observability/collectors/search-telemetry.collector.js +0 -76
  343. package/dist/observability/exporter.d.ts +0 -30
  344. package/dist/observability/exporter.js +0 -182
  345. package/dist/observability/index.d.ts +0 -22
  346. package/dist/observability/index.js +0 -21
  347. package/dist/observability/metrics.d.ts +0 -53
  348. package/dist/observability/metrics.js +0 -213
  349. package/dist/observability/privacy-guard.d.ts +0 -32
  350. package/dist/observability/privacy-guard.js +0 -116
  351. package/dist/observability/record.d.ts +0 -83
  352. package/dist/observability/record.js +0 -217
  353. package/dist/observability/registry.d.ts +0 -60
  354. package/dist/observability/registry.js +0 -93
  355. package/dist/observability/types.d.ts +0 -115
  356. package/dist/observability/types.js +0 -235
  357. package/dist/observability.d.ts +0 -131
  358. package/dist/plugins/nox-hooks/index.d.ts +0 -61
  359. package/dist/plugins/nox-hooks/index.js +0 -99
  360. package/dist/primer.d.ts +0 -1
  361. package/dist/privacy/filter.d.ts +0 -27
  362. package/dist/privacy/patterns.d.ts +0 -29
  363. package/dist/privacy/tag-parser.d.ts +0 -24
  364. package/dist/project-context-gen.d.ts +0 -10
  365. package/dist/providers/embedding/gemini.d.ts +0 -73
  366. package/dist/providers/embedding/openai.d.ts +0 -76
  367. package/dist/providers/embedding/types.d.ts +0 -39
  368. package/dist/providers/embedding/voyage.d.ts +0 -36
  369. package/dist/providers/index.d.ts +0 -116
  370. package/dist/providers/llm/anthropic.d.ts +0 -29
  371. package/dist/providers/llm/chain.d.ts +0 -99
  372. package/dist/providers/llm/gemini.d.ts +0 -48
  373. package/dist/providers/llm/openai.d.ts +0 -64
  374. package/dist/providers/llm/types.d.ts +0 -47
  375. package/dist/providers/telemetry.d.ts +0 -87
  376. package/dist/providers/types.d.ts +0 -42
  377. package/dist/query-entity-count.d.ts +0 -54
  378. package/dist/reflect.d.ts +0 -26
  379. package/dist/reindex-errors.d.ts +0 -7
  380. package/dist/reindex.d.ts +0 -16
  381. package/dist/retention.d.ts +0 -40
  382. package/dist/salience.d.ts +0 -85
  383. package/dist/scripts/migrate-v17-ops-audit.d.ts +0 -17
  384. package/dist/search-dedup.d.ts +0 -44
  385. package/dist/search-expansion.d.ts +0 -20
  386. package/dist/search.d.ts +0 -62
  387. package/dist/seh-detector.d.ts +0 -31
  388. package/dist/self-improve.d.ts +0 -1
  389. package/dist/session-distill.d.ts +0 -29
  390. package/dist/session-update.d.ts +0 -1
  391. package/dist/shared-memory.d.ts +0 -24
  392. package/dist/stats.d.ts +0 -1
  393. package/dist/temporal-retrieval.d.ts +0 -132
  394. package/dist/tier-manager.d.ts +0 -69
  395. package/dist/vectorize.d.ts +0 -16
  396. package/dist/version.d.ts +0 -1
  397. package/dist/watch.d.ts +0 -8
@@ -1,71 +0,0 @@
1
- export declare function assertDbPathConsistency(opName: string): void;
2
- export interface OpResult {
3
- affected_rows?: number;
4
- notes?: string;
5
- }
6
- /**
7
- * Heartbeat: update last_heartbeat_at em uma op em execução.
8
- * Fase 3 / Gap D (2026-05-15) — necessário pra watchdog detectar ops zombies
9
- * (>20min sem heartbeat = considered stale, candidata pra reap pelo ocr-watchdog).
10
- *
11
- * Usage no caller:
12
- * const hbInterval = setInterval(() => recordHeartbeat('ocr-batch-cloud'), 5*60*1000);
13
- * try { ... } finally { clearInterval(hbInterval); }
14
- *
15
- * Idempotent: UPDATE com WHERE filtro de op_name + pid + status='running' garante que
16
- * só toca a row da operação em curso (não interfere em outras ops paralelas).
17
- * Trigger trg_ops_audit_terminal_immutable permite UPDATE pq status atual é 'running'.
18
- */
19
- export declare function recordHeartbeat(opName: string, pid?: number): void;
20
- /**
21
- * Reaper: zombie 'running' rows from crashes (SIGKILL, OOM).
22
- * Run on startup of any caller importing this module via reapZombies().
23
- * Fix CRIT-4.
24
- */
25
- export declare function reapZombies(): number;
26
- /**
27
- * Fix SEC HIGH #5 (audit 04-26): redact secrets in error_message before persisting to ops_audit.
28
- * Audit table is exposed via /api/health.opsAudit; raw stack traces leak Gemini API keys
29
- * (AIza...), Anthropic OAuth tokens (sk-ant-oat-..., oat_...), and absolute paths.
30
- */
31
- export declare function scrubSecrets(s: string): string;
32
- export declare function withOpAudit<T extends OpResult>(opName: string, fn: () => Promise<T>): Promise<T>;
33
- /**
34
- * Stats helper for /api/health (Fix L2: single transaction for consistent reads).
35
- */
36
- export interface OpsAuditStats {
37
- total_24h: number;
38
- success_24h: number;
39
- failed_24h: number;
40
- crashed_24h: number;
41
- last_op: {
42
- op_name: string;
43
- status: string;
44
- finished_at: string;
45
- } | null;
46
- byDbSource: Record<string, {
47
- total: number;
48
- success: number;
49
- failed: number;
50
- crashed: number;
51
- running: number;
52
- }>;
53
- }
54
- export declare function getOpAuditStats(): OpsAuditStats;
55
- /**
56
- * safeRestore — recovery helper que faz restore seguro removendo WAL/SHM órfãos
57
- * e validando schema_user_version. Fix H3 (WAL/SHM órfãos) + H7 (schema mismatch).
58
- *
59
- * Caller deve PARAR serviços que escrevem no DB ANTES de chamar:
60
- * systemctl stop nox-mem-api nox-mem-watcher openclaw-gateway
61
- * # snapshot path = your configured snapshot dir (NOX_PRE_OP_SNAPSHOT_DIR, or the
62
- * # default: /var/backups/nox-mem/pre-op on origin, <NOX_MEM_DIR|DB dir>/.nox-snapshots standalone)
63
- * node -e "import('./dist/lib/op-audit.js').then(m => m.safeRestore('<SNAPSHOT_DIR>/reindex-XXX.db'))"
64
- * systemctl start nox-mem-api nox-mem-watcher openclaw-gateway
65
- */
66
- export declare function safeRestore(snapshotPath: string, opts?: {
67
- force?: boolean;
68
- }): {
69
- ok: boolean;
70
- warnings: string[];
71
- };
@@ -1,42 +0,0 @@
1
- /**
2
- * privacy-br/detector.ts — A1.1 BR PII detection orchestrator.
3
- *
4
- * Roda todos os padrões BR_PATTERNS sobre o texto e devolve matches
5
- * deduplicados, com overlap resolution (prefer longest match).
6
- *
7
- * Estratégia:
8
- * 1. Para cada pattern do catálogo, coleta todos os matches no texto.
9
- * 2. Aplica validate() se disponível — ajusta confidence em vez de descartar.
10
- * 3. Sort por position ASC, depois por length DESC (longer wins ties).
11
- * 4. Walk linearmente: descarta matches que overlapam com previously-accepted.
12
- *
13
- * Performance: O(N * P) onde N = len(text), P = #patterns. Não exec por chunk;
14
- * é chamado uma vez por documento. Para chunks de 1-5KB e 12 patterns, ~µs.
15
- */
16
- import { BR_PATTERN_BY_KIND } from "./patterns.js";
17
- import { BrPatternKind, BrPatternMatch } from "./types.js";
18
- /**
19
- * Detecta toda PII brasileira no texto.
20
- *
21
- * @param text Texto bruto pra escanear
22
- * @param options.minConfidence Filtra matches abaixo deste threshold (default 0)
23
- * @param options.includePixCpf Se true, CPF puro também produz match pix_cpf
24
- * além de cpf. Default false (evita dup).
25
- * @returns Array de matches, ordenado por position ASC.
26
- */
27
- export declare function detectBrPii(text: string, options?: {
28
- minConfidence?: number;
29
- includePixCpf?: boolean;
30
- }): BrPatternMatch[];
31
- /**
32
- * Variante: detecta apenas matches de tipos específicos.
33
- * Útil pra integrations que querem só CPF/CNPJ sem PIX/CEP.
34
- */
35
- export declare function detectBrPiiByKinds(text: string, kinds: BrPatternKind[], options?: {
36
- minConfidence?: number;
37
- }): BrPatternMatch[];
38
- /**
39
- * Helper de debug — agrupa matches por kind, útil pra eval/telemetria.
40
- */
41
- export declare function groupMatchesByKind(matches: BrPatternMatch[]): Record<BrPatternKind, BrPatternMatch[]>;
42
- export { BR_PATTERN_BY_KIND };
@@ -1,130 +0,0 @@
1
- /**
2
- * privacy-br/detector.ts — A1.1 BR PII detection orchestrator.
3
- *
4
- * Roda todos os padrões BR_PATTERNS sobre o texto e devolve matches
5
- * deduplicados, com overlap resolution (prefer longest match).
6
- *
7
- * Estratégia:
8
- * 1. Para cada pattern do catálogo, coleta todos os matches no texto.
9
- * 2. Aplica validate() se disponível — ajusta confidence em vez de descartar.
10
- * 3. Sort por position ASC, depois por length DESC (longer wins ties).
11
- * 4. Walk linearmente: descarta matches que overlapam com previously-accepted.
12
- *
13
- * Performance: O(N * P) onde N = len(text), P = #patterns. Não exec por chunk;
14
- * é chamado uma vez por documento. Para chunks de 1-5KB e 12 patterns, ~µs.
15
- */
16
- import { BR_PATTERNS, BR_PATTERN_BY_KIND } from "./patterns.js";
17
- import { CONFIDENCE } from "./types.js";
18
- /**
19
- * Detecta toda PII brasileira no texto.
20
- *
21
- * @param text Texto bruto pra escanear
22
- * @param options.minConfidence Filtra matches abaixo deste threshold (default 0)
23
- * @param options.includePixCpf Se true, CPF puro também produz match pix_cpf
24
- * além de cpf. Default false (evita dup).
25
- * @returns Array de matches, ordenado por position ASC.
26
- */
27
- export function detectBrPii(text, options = {}) {
28
- const { minConfidence = 0, includePixCpf = false } = options;
29
- if (typeof text !== "string" || text.length === 0)
30
- return [];
31
- const rawMatches = [];
32
- for (const def of BR_PATTERNS) {
33
- // Skip pix_cpf por default (covered por cpf; só inclui se caller pediu)
34
- if (def.kind === "pix_cpf" && !includePixCpf)
35
- continue;
36
- const regex = def.getRegex();
37
- // matchAll é mais seguro que while(exec) — não precisa gerir lastIndex
38
- // manualmente e funciona com regex /g.
39
- const iter = text.matchAll(regex);
40
- for (const m of iter) {
41
- const raw = m[1] !== undefined ? m[1] : m[0];
42
- const matchIndex = m.index ?? 0;
43
- // m.index aponta pro início do MATCH completo, incluindo qualquer
44
- // lookbehind. Lookbehind é zero-width, então matchIndex já está correto.
45
- // Mas o capture group (m[1]) pode começar depois (ex: regex com prefixo).
46
- // Calculamos position real procurando raw a partir de matchIndex.
47
- let start = matchIndex;
48
- if (m[0] !== raw) {
49
- const offset = m[0].indexOf(raw);
50
- if (offset >= 0)
51
- start = matchIndex + offset;
52
- }
53
- const end = start + raw.length;
54
- const normalized = def.normalize(raw);
55
- let confidence = def.confidenceWhenValid;
56
- if (def.validate) {
57
- const ok = def.validate(normalized);
58
- confidence = ok
59
- ? def.confidenceWhenValid
60
- : def.confidenceWhenInvalid ?? CONFIDENCE.VERY_LOW;
61
- }
62
- if (confidence < minConfidence)
63
- continue;
64
- rawMatches.push({
65
- kind: def.kind,
66
- raw,
67
- normalized,
68
- position: [start, end],
69
- confidence,
70
- });
71
- }
72
- }
73
- // ── Overlap resolution ─────────────────────────────────────────────────────
74
- //
75
- // Sort: position ASC, then length DESC (longer first), then confidence DESC,
76
- // then catalog order (BR_PATTERNS ordering).
77
- rawMatches.sort((a, b) => {
78
- if (a.position[0] !== b.position[0])
79
- return a.position[0] - b.position[0];
80
- const lenA = a.position[1] - a.position[0];
81
- const lenB = b.position[1] - b.position[0];
82
- if (lenA !== lenB)
83
- return lenB - lenA;
84
- if (a.confidence !== b.confidence)
85
- return b.confidence - a.confidence;
86
- // Catalog order — find index in BR_PATTERNS
87
- const ia = BR_PATTERNS.findIndex((p) => p.kind === a.kind);
88
- const ib = BR_PATTERNS.findIndex((p) => p.kind === b.kind);
89
- return ia - ib;
90
- });
91
- // Walk + drop overlaps
92
- const accepted = [];
93
- let lastEnd = -1;
94
- for (const m of rawMatches) {
95
- if (m.position[0] >= lastEnd) {
96
- accepted.push(m);
97
- lastEnd = m.position[1];
98
- }
99
- // else: overlap — descarta (sorted longest-first garante que mantemos o melhor)
100
- }
101
- return accepted;
102
- }
103
- /**
104
- * Variante: detecta apenas matches de tipos específicos.
105
- * Útil pra integrations que querem só CPF/CNPJ sem PIX/CEP.
106
- */
107
- export function detectBrPiiByKinds(text, kinds, options = {}) {
108
- const all = detectBrPii(text, options);
109
- const set = new Set(kinds);
110
- return all.filter((m) => set.has(m.kind));
111
- }
112
- /**
113
- * Helper de debug — agrupa matches por kind, útil pra eval/telemetria.
114
- */
115
- export function groupMatchesByKind(matches) {
116
- const out = {};
117
- for (const m of matches) {
118
- if (!out[m.kind])
119
- out[m.kind] = [];
120
- out[m.kind].push(m);
121
- }
122
- // Garante todas as keys presentes (mesmo vazias) — facilita iteração
123
- for (const def of BR_PATTERNS) {
124
- if (!out[def.kind])
125
- out[def.kind] = [];
126
- }
127
- return out;
128
- }
129
- // Re-export pra consumidores externos
130
- export { BR_PATTERN_BY_KIND };
@@ -1,20 +0,0 @@
1
- /**
2
- * privacy-br — A1.1 BR PII filter, public API.
3
- *
4
- * Uso típico:
5
- *
6
- * import { redactBrPii } from "./lib/privacy-br";
7
- * const r = redactBrPii("CPF do João: 111.444.777-35");
8
- * // r.redacted === "CPF do João: [REDACTED:cpf]"
9
- *
10
- * Integração com A1 (US):
11
- *
12
- * import { redact as redactUs } from "../privacy/filter.js";
13
- * import { redactAll } from "./lib/privacy-br";
14
- * const r = redactAll(text, redactUs);
15
- */
16
- export * from "./types.js";
17
- export { validateCpf, validateCnpj, validateCnh, validateTituloEleitor, validateCep, luhn, BR_PATTERNS, BR_PATTERN_BY_KIND, } from "./patterns.js";
18
- export { detectBrPii, detectBrPiiByKinds, groupMatchesByKind } from "./detector.js";
19
- export { redactBrPii, summarizeMatches } from "./redact.js";
20
- export { redactAll, redactBrOnly, noopUsRedactor, type CombinedRedactResult, type UsRedactorFn, } from "./integration.js";
@@ -1,20 +0,0 @@
1
- /**
2
- * privacy-br — A1.1 BR PII filter, public API.
3
- *
4
- * Uso típico:
5
- *
6
- * import { redactBrPii } from "./lib/privacy-br";
7
- * const r = redactBrPii("CPF do João: 111.444.777-35");
8
- * // r.redacted === "CPF do João: [REDACTED:cpf]"
9
- *
10
- * Integração com A1 (US):
11
- *
12
- * import { redact as redactUs } from "../privacy/filter.js";
13
- * import { redactAll } from "./lib/privacy-br";
14
- * const r = redactAll(text, redactUs);
15
- */
16
- export * from "./types.js";
17
- export { validateCpf, validateCnpj, validateCnh, validateTituloEleitor, validateCep, luhn, BR_PATTERNS, BR_PATTERN_BY_KIND, } from "./patterns.js";
18
- export { detectBrPii, detectBrPiiByKinds, groupMatchesByKind } from "./detector.js";
19
- export { redactBrPii, summarizeMatches } from "./redact.js";
20
- export { redactAll, redactBrOnly, noopUsRedactor, } from "./integration.js";
@@ -1,71 +0,0 @@
1
- /**
2
- * privacy-br/integration.ts — combina A1 (US) + A1.1 (BR) em pipeline único.
3
- *
4
- * Ordem:
5
- * 1. A1.1 BR primeiro — padrões mais específicos (CNPJ 14 dig, CEP hífenado).
6
- * Se rodássemos A1 antes, o pattern genérico `credit-card` poderia
7
- * engolir 16 dígitos que na verdade são parte de cartão BR + CNPJ
8
- * adjacente (raro mas possível em logs CSV).
9
- * 2. A1 US depois — padrões genéricos (env vars, JWT, AWS, etc).
10
- *
11
- * Como A1 lives em `staged-privacy/` (sibling), o consumidor deve importar
12
- * a função `redact` de lá e passar como argumento. Mantemos `combineRedactors`
13
- * agnostic da implementação A1 — facilita testar em isolamento.
14
- *
15
- * Contrato esperado do A1: função (text) => { text, redactionCount, kinds }
16
- */
17
- import type { BrPatternMatch } from "./types.js";
18
- /**
19
- * Resultado agregado A1 + A1.1.
20
- */
21
- export interface CombinedRedactResult {
22
- /** Texto final, após BR e US redaction */
23
- text: string;
24
- /** Total de redações (BR + US) */
25
- redactionCount: number;
26
- /** Breakdown por source */
27
- bySource: {
28
- br: {
29
- count: number;
30
- kinds: string[];
31
- };
32
- us: {
33
- count: number;
34
- kinds: string[];
35
- };
36
- };
37
- /** Matches BR detalhados — útil pra telemetria/audit */
38
- brMatches: BrPatternMatch[];
39
- }
40
- /**
41
- * Tipo do redactor A1 (US) — assinatura do `redact` em
42
- * `staged-privacy/edits/privacy/filter.ts`.
43
- */
44
- export type UsRedactorFn = (text: string) => {
45
- text: string;
46
- redactionCount: number;
47
- kinds: string[];
48
- };
49
- /**
50
- * Roda BR (A1.1) seguido de US (A1) sobre o mesmo texto.
51
- *
52
- * @param text Texto bruto
53
- * @param usRedactor Função A1 importada do staged-privacy
54
- * @param options Override de confidence threshold (default 0.5) e mode
55
- */
56
- export declare function redactAll(text: string, usRedactor: UsRedactorFn, options?: {
57
- minConfidence?: number;
58
- mode?: "default" | "preserve" | "hash";
59
- }): CombinedRedactResult;
60
- /**
61
- * Versão standalone (só BR) — útil quando A1 não está disponível ou
62
- * quando o caller só quer testar o A1.1.
63
- */
64
- export declare function redactBrOnly(text: string, options?: {
65
- minConfidence?: number;
66
- mode?: "default" | "preserve" | "hash";
67
- }): CombinedRedactResult;
68
- /**
69
- * No-op US redactor (pra testes que só rodam BR).
70
- */
71
- export declare const noopUsRedactor: UsRedactorFn;
@@ -1,74 +0,0 @@
1
- /**
2
- * privacy-br/integration.ts — combina A1 (US) + A1.1 (BR) em pipeline único.
3
- *
4
- * Ordem:
5
- * 1. A1.1 BR primeiro — padrões mais específicos (CNPJ 14 dig, CEP hífenado).
6
- * Se rodássemos A1 antes, o pattern genérico `credit-card` poderia
7
- * engolir 16 dígitos que na verdade são parte de cartão BR + CNPJ
8
- * adjacente (raro mas possível em logs CSV).
9
- * 2. A1 US depois — padrões genéricos (env vars, JWT, AWS, etc).
10
- *
11
- * Como A1 lives em `staged-privacy/` (sibling), o consumidor deve importar
12
- * a função `redact` de lá e passar como argumento. Mantemos `combineRedactors`
13
- * agnostic da implementação A1 — facilita testar em isolamento.
14
- *
15
- * Contrato esperado do A1: função (text) => { text, redactionCount, kinds }
16
- */
17
- import { redactBrPii } from "./redact.js";
18
- /**
19
- * Roda BR (A1.1) seguido de US (A1) sobre o mesmo texto.
20
- *
21
- * @param text Texto bruto
22
- * @param usRedactor Função A1 importada do staged-privacy
23
- * @param options Override de confidence threshold (default 0.5) e mode
24
- */
25
- export function redactAll(text, usRedactor, options = {}) {
26
- const { minConfidence = 0.5, mode = "default" } = options;
27
- if (typeof text !== "string" || text.length === 0) {
28
- return {
29
- text: text ?? "",
30
- redactionCount: 0,
31
- bySource: { br: { count: 0, kinds: [] }, us: { count: 0, kinds: [] } },
32
- brMatches: [],
33
- };
34
- }
35
- // Phase 1: BR
36
- const br = redactBrPii(text, { minConfidence, mode });
37
- const brKinds = Array.from(new Set(br.matches.map((m) => m.kind)));
38
- // Phase 2: US (sobre texto já redactado com BR)
39
- const us = usRedactor(br.redacted);
40
- return {
41
- text: us.text,
42
- redactionCount: br.redactionCount + us.redactionCount,
43
- bySource: {
44
- br: { count: br.redactionCount, kinds: brKinds },
45
- us: { count: us.redactionCount, kinds: us.kinds },
46
- },
47
- brMatches: br.matches,
48
- };
49
- }
50
- /**
51
- * Versão standalone (só BR) — útil quando A1 não está disponível ou
52
- * quando o caller só quer testar o A1.1.
53
- */
54
- export function redactBrOnly(text, options = {}) {
55
- const br = redactBrPii(text, options);
56
- const brKinds = Array.from(new Set(br.matches.map((m) => m.kind)));
57
- return {
58
- text: br.redacted,
59
- redactionCount: br.redactionCount,
60
- bySource: {
61
- br: { count: br.redactionCount, kinds: brKinds },
62
- us: { count: 0, kinds: [] },
63
- },
64
- brMatches: br.matches,
65
- };
66
- }
67
- /**
68
- * No-op US redactor (pra testes que só rodam BR).
69
- */
70
- export const noopUsRedactor = (text) => ({
71
- text,
72
- redactionCount: 0,
73
- kinds: [],
74
- });
@@ -1,117 +0,0 @@
1
- /**
2
- * privacy-br/patterns.ts — A1.1 BR PII regex catalog + validators.
3
- *
4
- * Padrões com:
5
- * - Boundaries Unicode-safe via lookbehind/lookahead (NUNCA \b — falha em ç/ã/ê).
6
- * Ref: feedback_js_regex_unicode_word_boundary_fails (CLAUDE.md memory).
7
- * - Validação de dígito verificador onde aplicável (CPF, CNPJ, cartão Luhn).
8
- * - Confidence assignada por tipo + por resultado de validação.
9
- *
10
- * Performance: regex compiladas uma vez no module-load (não dentro de loop).
11
- * Cada `getPattern()` retorna instância fresh com lastIndex=0 pra uso em
12
- * `String.matchAll` sem state leak entre chamadas concorrentes.
13
- *
14
- * Ordem do catálogo importa pra detector — mais específico/longo primeiro
15
- * (CNPJ antes de CPF, telefone BR antes de CEP).
16
- */
17
- import { BrPatternKind } from "./types.js";
18
- /**
19
- * CPF check-digit validation.
20
- *
21
- * Algoritmo oficial Receita Federal:
22
- * - Pega primeiros 9 dígitos; multiplica cada um pelos pesos [10..2]; soma.
23
- * - mod = sum % 11; dv1 = mod < 2 ? 0 : 11 - mod.
24
- * - Pega primeiros 10 dígitos (incl dv1); pesos [11..2]; soma; dv2 idem.
25
- * - Rejeita sequências triviais (00000000000, 11111111111, ...) — são
26
- * formalmente válidos mas usados como placeholders. Causa FP em docs.
27
- *
28
- * @param digits Exatamente 11 dígitos, só números (sem pontuação).
29
- * @returns true se dígitos verificadores batem E não é sequência trivial.
30
- */
31
- export declare function validateCpf(digits: string): boolean;
32
- /**
33
- * CNPJ check-digit validation.
34
- *
35
- * Pesos diferentes do CPF, conforme spec Receita Federal:
36
- * - DV1: weights [5,4,3,2,9,8,7,6,5,4,3,2] sobre primeiros 12 dígitos.
37
- * - DV2: weights [6,5,4,3,2,9,8,7,6,5,4,3,2] sobre primeiros 13 dígitos.
38
- * - Rejeita 14 dígitos idênticos (placeholder).
39
- *
40
- * @param digits Exatamente 14 dígitos, só números.
41
- */
42
- export declare function validateCnpj(digits: string): boolean;
43
- /**
44
- * Luhn algorithm para cartões de crédito (igual A1 US, replicado aqui pra
45
- * desacoplar A1.1 do staged-privacy original).
46
- */
47
- export declare function luhn(digits: string): boolean;
48
- /**
49
- * CEP validation — formato 5+3 dígitos.
50
- * Não tem dígito verificador oficial; aceita 8 dígitos exatos com
51
- * faixa de prefixos plausíveis (00000-999 = inválidos por convenção
52
- * Correios pra alguns ranges, mas mantemos permissivo).
53
- *
54
- * Range válido: 01000-000 a 99999-999. Os Correios usam 00000-000 só
55
- * como placeholder; tratamos como inválido.
56
- */
57
- export declare function validateCep(digits: string): boolean;
58
- /**
59
- * Interface interna do catálogo. Cada entry define:
60
- * - kind : tag canônica
61
- * - getRegex() : factory fresh com lastIndex=0
62
- * - validate? : função opcional sobre normalized; se retorna false,
63
- * confidence é rebaixada (não descartado — o detector
64
- * pode aceitar matches low-confidence com flag).
65
- * - confidenceWhenValid : confiança quando validate=true OU sem validate
66
- * - confidenceWhenInvalid? : confiança quando validate=false (default: rebaixa)
67
- * - normalize : produz a `normalized` string a partir do raw match
68
- */
69
- export interface BrPatternDef {
70
- kind: BrPatternKind;
71
- getRegex: () => RegExp;
72
- validate?: (normalized: string) => boolean;
73
- confidenceWhenValid: number;
74
- confidenceWhenInvalid?: number;
75
- normalize: (raw: string) => string;
76
- }
77
- /**
78
- * Catálogo principal. Ordem importa pra resolução de overlap:
79
- * CNPJ (14 dig) > telefone BR (11 dig) > CPF (11 dig) > cartão (13-19) > resto.
80
- *
81
- * O detector usa essa ordem como tiebreaker quando dois matches começam
82
- * na mesma posição.
83
- */
84
- export declare const BR_PATTERNS: BrPatternDef[];
85
- /**
86
- * CNH check-digit validation.
87
- *
88
- * Algoritmo DETRAN:
89
- * - DV1: pesos [9,8,7,6,5,4,3,2,1] sobre primeiros 9 dígitos. soma % 11.
90
- * Se soma % 11 >= 10, dv1 = 0; senão dv1 = soma % 11.
91
- * Se houve resíduo (mais de 1 dv invertido), aplica delta — ver código.
92
- * - DV2: pesos [1,2,3,4,5,6,7,8,9] sobre primeiros 9 dígitos. soma % 11
93
- * ajustada com dsv (delta da DV1) e fórmula similar.
94
- *
95
- * Ref: https://www.macoratti.net/alg_cnh.htm (algoritmo público DETRAN)
96
- *
97
- * @param digits 11 dígitos puros
98
- */
99
- export declare function validateCnh(digits: string): boolean;
100
- /**
101
- * Título de Eleitor check-digit validation.
102
- *
103
- * Algoritmo TSE:
104
- * - 12 dígitos: 8 base + 2 estado (UF) + 2 DV.
105
- * - DV1: pesos [2..9] sobre primeiros 8 dígitos. mod = sum % 11.
106
- * Se mod == 10, dv1 = 0; senão dv1 = mod.
107
- * Casos especiais: SP/MG (UF=01/02) — se mod == 0 e UF nesses estados, dv1 = 1.
108
- * - DV2: pesos [7..9] sobre dígitos 9,10 (UF) + dv1. mod = sum % 11.
109
- * Mesmo tratamento SP/MG.
110
- *
111
- * @param digits 12 dígitos puros
112
- */
113
- export declare function validateTituloEleitor(digits: string): boolean;
114
- /**
115
- * Lookup map por kind — útil pra detector.
116
- */
117
- export declare const BR_PATTERN_BY_KIND: Map<BrPatternKind, BrPatternDef>;