nox-mem 3.1.1 → 3.2.1

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/crystallize.js +3 -5
  17. package/dist/db.js +61 -2
  18. package/dist/embed.js +23 -2
  19. package/dist/index.js +1 -22
  20. package/dist/knowledge-graph.js +20 -0
  21. package/dist/lib/answer/__tests__/e2e-gemini.test.js +229 -0
  22. package/dist/lib/answer/__tests__/integration-sqlite.test.js +388 -0
  23. package/dist/lib/answer/__tests__/integration.test.js +347 -0
  24. package/dist/lib/answer/__tests__/prompt.test.js +117 -0
  25. package/dist/lib/answer/__tests__/t5-t10.test.js +501 -0
  26. package/dist/lib/answer/provider.js +29 -4
  27. package/dist/lib/api/__tests__/safe-error-message.test.js +155 -0
  28. package/dist/lib/auth/__tests__/localhost-guard.test.js +144 -0
  29. package/dist/lib/error-sanitizer/__tests__/sanitize.test.js +354 -0
  30. package/dist/lib/events/__tests__/bus.test.js +208 -0
  31. package/dist/lib/ingest-router.js +0 -43
  32. package/dist/lib/op-audit-extension/__tests__/ran-at-guard.test.js +109 -0
  33. package/dist/lib/regex-extract/__tests__/extractor.test.js +197 -0
  34. package/dist/lib/regex-extract/__tests__/frontmatter.test.js +75 -0
  35. package/dist/lib/regex-extract/__tests__/ingest-router-l4.test.js +139 -0
  36. package/dist/lib/regex-extract/__tests__/production-wire.test.js +177 -0
  37. package/dist/lib/regex-extract/__tests__/reconcile.test.js +170 -0
  38. package/dist/lib/regex-extract/__tests__/strip-code.test.js +36 -0
  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/package.json +3 -4
  51. package/dist/api/answer.d.ts +0 -116
  52. package/dist/api/answer.validate-patch.d.ts +0 -72
  53. package/dist/api/brief-diversity.d.ts +0 -64
  54. package/dist/api/brief.d.ts +0 -114
  55. package/dist/api/conflict.d.ts +0 -33
  56. package/dist/api/conflict.js +0 -143
  57. package/dist/api/cors.d.ts +0 -73
  58. package/dist/api/events-stream-limited.d.ts +0 -133
  59. package/dist/api/events-stream-limited.js +0 -217
  60. package/dist/api/events-stream.d.ts +0 -53
  61. package/dist/api/events-stream.js +0 -125
  62. package/dist/api/export.d.ts +0 -42
  63. package/dist/api/export.js +0 -85
  64. package/dist/api/health-confidence-adapter.d.ts +0 -29
  65. package/dist/api/health-confidence-adapter.js +0 -73
  66. package/dist/api/health-confidence.d.ts +0 -36
  67. package/dist/api/health-confidence.js +0 -141
  68. package/dist/api/hooks.d.ts +0 -50
  69. package/dist/api/hooks.js +0 -115
  70. package/dist/api/import.d.ts +0 -38
  71. package/dist/api/import.js +0 -87
  72. package/dist/api/ingest-event.d.ts +0 -65
  73. package/dist/api/mark.d.ts +0 -42
  74. package/dist/api/mark.js +0 -127
  75. package/dist/api/server-deps-a2.d.ts +0 -55
  76. package/dist/api/server-deps-a2.js +0 -138
  77. package/dist/api/server-deps-l2-l3.d.ts +0 -68
  78. package/dist/api/server-deps-l2-l3.js +0 -123
  79. package/dist/api/server-deps-p1.d.ts +0 -84
  80. package/dist/api/server-deps-p2.d.ts +0 -32
  81. package/dist/api/server-deps-p2.js +0 -84
  82. package/dist/api/server-deps-p5.d.ts +0 -66
  83. package/dist/api/server-deps-p5.js +0 -139
  84. package/dist/api/viewer-static.d.ts +0 -30
  85. package/dist/api/viewer-static.js +0 -102
  86. package/dist/api/wire-up.d.ts +0 -54
  87. package/dist/api-impact.d.ts +0 -30
  88. package/dist/api-server.d.ts +0 -2
  89. package/dist/backfill-fts-anchor.d.ts +0 -15
  90. package/dist/backfill-source-type.d.ts +0 -20
  91. package/dist/churn.d.ts +0 -31
  92. package/dist/cli/answer.d.ts +0 -66
  93. package/dist/cli/conflict.d.ts +0 -38
  94. package/dist/cli/conflict.js +0 -282
  95. package/dist/cli/export.d.ts +0 -51
  96. package/dist/cli/export.js +0 -280
  97. package/dist/cli/hooks.d.ts +0 -54
  98. package/dist/cli/hooks.js +0 -133
  99. package/dist/cli/import.d.ts +0 -52
  100. package/dist/cli/import.js +0 -274
  101. package/dist/cli/mark.d.ts +0 -33
  102. package/dist/cli/mark.js +0 -130
  103. package/dist/cli/ocr-batch.d.ts +0 -12
  104. package/dist/cli/ocr-batch.js +0 -411
  105. package/dist/cli/snapshot-main.d.ts +0 -30
  106. package/dist/cli/snapshot-main.js +0 -47
  107. package/dist/cli/viewer.d.ts +0 -35
  108. package/dist/cli/viewer.js +0 -71
  109. package/dist/cli-telemetry.d.ts +0 -36
  110. package/dist/cli-telemetry.js +0 -150
  111. package/dist/compact.d.ts +0 -7
  112. package/dist/consolidate.d.ts +0 -18
  113. package/dist/consolidation.d.ts +0 -32
  114. package/dist/cross-agent-v2.d.ts +0 -45
  115. package/dist/cross-search.d.ts +0 -11
  116. package/dist/crystallize.d.ts +0 -43
  117. package/dist/db.d.ts +0 -11
  118. package/dist/dedup.d.ts +0 -1
  119. package/dist/detect-changes.d.ts +0 -29
  120. package/dist/digest.d.ts +0 -1
  121. package/dist/doctor.d.ts +0 -1
  122. package/dist/embed.d.ts +0 -57
  123. package/dist/evals.d.ts +0 -176
  124. package/dist/evals.js +0 -351
  125. package/dist/generate-user-profile.d.ts +0 -18
  126. package/dist/graphify-ingest.d.ts +0 -18
  127. package/dist/impact.d.ts +0 -39
  128. package/dist/index.d.ts +0 -2
  129. package/dist/ingest-entity.d.ts +0 -44
  130. package/dist/ingest.d.ts +0 -13
  131. package/dist/kg-llm.d.ts +0 -39
  132. package/dist/knowledge-graph.d.ts +0 -72
  133. package/dist/lib/answer/config.d.ts +0 -41
  134. package/dist/lib/answer/index.d.ts +0 -47
  135. package/dist/lib/answer/prompt.d.ts +0 -37
  136. package/dist/lib/answer/provider.d.ts +0 -47
  137. package/dist/lib/answer/retrieval.d.ts +0 -36
  138. package/dist/lib/answer/telemetry.d.ts +0 -99
  139. package/dist/lib/answer/types.d.ts +0 -108
  140. package/dist/lib/api/error-leak-fix.d.ts +0 -54
  141. package/dist/lib/api/safe-error-message.d.ts +0 -70
  142. package/dist/lib/archive/common-passwords.d.ts +0 -37
  143. package/dist/lib/archive/common-passwords.js +0 -753
  144. package/dist/lib/archive/encryption.d.ts +0 -81
  145. package/dist/lib/archive/encryption.js +0 -236
  146. package/dist/lib/archive/enforce-strength.d.ts +0 -54
  147. package/dist/lib/archive/enforce-strength.js +0 -70
  148. package/dist/lib/archive/entropy.d.ts +0 -34
  149. package/dist/lib/archive/entropy.js +0 -180
  150. package/dist/lib/archive/export-locking.d.ts +0 -102
  151. package/dist/lib/archive/export-locking.js +0 -202
  152. package/dist/lib/archive/format.d.ts +0 -20
  153. package/dist/lib/archive/format.js +0 -174
  154. package/dist/lib/archive/index.d.ts +0 -23
  155. package/dist/lib/archive/index.js +0 -17
  156. package/dist/lib/archive/manifest.d.ts +0 -53
  157. package/dist/lib/archive/manifest.js +0 -183
  158. package/dist/lib/archive/migration.d.ts +0 -36
  159. package/dist/lib/archive/migration.js +0 -100
  160. package/dist/lib/archive/migrations/v18_to_v19.d.ts +0 -16
  161. package/dist/lib/archive/migrations/v18_to_v19.js +0 -18
  162. package/dist/lib/archive/orchestrator.d.ts +0 -166
  163. package/dist/lib/archive/orchestrator.js +0 -428
  164. package/dist/lib/archive/serializers/chunks.d.ts +0 -30
  165. package/dist/lib/archive/serializers/chunks.js +0 -113
  166. package/dist/lib/archive/serializers/embeddings.d.ts +0 -36
  167. package/dist/lib/archive/serializers/embeddings.js +0 -115
  168. package/dist/lib/archive/serializers/kg.d.ts +0 -28
  169. package/dist/lib/archive/serializers/kg.js +0 -184
  170. package/dist/lib/archive/serializers/ops_audit.d.ts +0 -21
  171. package/dist/lib/archive/serializers/ops_audit.js +0 -97
  172. package/dist/lib/archive/server-deps.d.ts +0 -131
  173. package/dist/lib/archive/server-deps.js +0 -232
  174. package/dist/lib/archive/strength.d.ts +0 -50
  175. package/dist/lib/archive/strength.js +0 -77
  176. package/dist/lib/archive/types.d.ts +0 -159
  177. package/dist/lib/archive/types.js +0 -45
  178. package/dist/lib/archive/unpack-streaming.d.ts +0 -70
  179. package/dist/lib/archive/unpack-streaming.js +0 -255
  180. package/dist/lib/auth/localhost-guard.d.ts +0 -106
  181. package/dist/lib/confidence/config.d.ts +0 -37
  182. package/dist/lib/confidence/config.js +0 -107
  183. package/dist/lib/confidence/db-shim-singleton.d.ts +0 -20
  184. package/dist/lib/confidence/db-shim-singleton.js +0 -41
  185. package/dist/lib/confidence/db-shim.d.ts +0 -47
  186. package/dist/lib/confidence/db-shim.js +0 -141
  187. package/dist/lib/confidence/mark.d.ts +0 -58
  188. package/dist/lib/confidence/mark.js +0 -168
  189. package/dist/lib/confidence/ranking.d.ts +0 -69
  190. package/dist/lib/confidence/ranking.js +0 -101
  191. package/dist/lib/confidence/search-filter.d.ts +0 -44
  192. package/dist/lib/confidence/search-filter.js +0 -103
  193. package/dist/lib/confidence/types.d.ts +0 -146
  194. package/dist/lib/confidence/types.js +0 -20
  195. package/dist/lib/confidence/write-hooks.d.ts +0 -50
  196. package/dist/lib/confidence/write-hooks.js +0 -159
  197. package/dist/lib/conflict/audit-fk-check.d.ts +0 -72
  198. package/dist/lib/conflict/audit-fk-check.js +0 -131
  199. package/dist/lib/conflict/audit-writer.d.ts +0 -39
  200. package/dist/lib/conflict/audit-writer.js +0 -133
  201. package/dist/lib/conflict/db-singleton.d.ts +0 -28
  202. package/dist/lib/conflict/db-singleton.js +0 -61
  203. package/dist/lib/conflict/db.d.ts +0 -27
  204. package/dist/lib/conflict/db.js +0 -20
  205. package/dist/lib/conflict/detector-direct.d.ts +0 -21
  206. package/dist/lib/conflict/detector-direct.js +0 -105
  207. package/dist/lib/conflict/evidence.d.ts +0 -24
  208. package/dist/lib/conflict/evidence.js +0 -76
  209. package/dist/lib/conflict/index.d.ts +0 -14
  210. package/dist/lib/conflict/index.js +0 -12
  211. package/dist/lib/conflict/scheduler.d.ts +0 -78
  212. package/dist/lib/conflict/scheduler.js +0 -111
  213. package/dist/lib/conflict/shadow.d.ts +0 -75
  214. package/dist/lib/conflict/shadow.js +0 -161
  215. package/dist/lib/conflict/types.d.ts +0 -133
  216. package/dist/lib/conflict/types.js +0 -19
  217. package/dist/lib/cost-cap.d.ts +0 -94
  218. package/dist/lib/deps/deps-registry.d.ts +0 -111
  219. package/dist/lib/error-sanitizer/middleware.d.ts +0 -43
  220. package/dist/lib/error-sanitizer/sanitize.d.ts +0 -78
  221. package/dist/lib/eval-batch.d.ts +0 -34
  222. package/dist/lib/eval-batch.js +0 -103
  223. package/dist/lib/eval-metrics.d.ts +0 -36
  224. package/dist/lib/eval-metrics.js +0 -95
  225. package/dist/lib/eval.d.ts +0 -106
  226. package/dist/lib/eval.js +0 -343
  227. package/dist/lib/events/bus.d.ts +0 -135
  228. package/dist/lib/fts-anchor.d.ts +0 -1
  229. package/dist/lib/hooks/classifier.d.ts +0 -47
  230. package/dist/lib/hooks/classifier.js +0 -129
  231. package/dist/lib/hooks/config.d.ts +0 -49
  232. package/dist/lib/hooks/config.js +0 -106
  233. package/dist/lib/hooks/decorators.d.ts +0 -35
  234. package/dist/lib/hooks/decorators.js +0 -59
  235. package/dist/lib/hooks/pipeline.d.ts +0 -76
  236. package/dist/lib/hooks/pipeline.js +0 -213
  237. package/dist/lib/hooks/privacy-filter-adapter.d.ts +0 -55
  238. package/dist/lib/hooks/privacy-filter-adapter.js +0 -84
  239. package/dist/lib/hooks/rate-limit-constant-time.d.ts +0 -57
  240. package/dist/lib/hooks/rate-limit-constant-time.js +0 -69
  241. package/dist/lib/hooks/rate-limit-dryrun-fix.d.ts +0 -71
  242. package/dist/lib/hooks/rate-limit-dryrun-fix.js +0 -110
  243. package/dist/lib/hooks/rate-limit.d.ts +0 -54
  244. package/dist/lib/hooks/rate-limit.js +0 -122
  245. package/dist/lib/hooks/server-deps.d.ts +0 -61
  246. package/dist/lib/hooks/server-deps.js +0 -92
  247. package/dist/lib/hooks/source-allowlist.d.ts +0 -26
  248. package/dist/lib/hooks/source-allowlist.js +0 -53
  249. package/dist/lib/hooks/types.d.ts +0 -129
  250. package/dist/lib/hooks/types.js +0 -24
  251. package/dist/lib/hooks/worker.d.ts +0 -56
  252. package/dist/lib/hooks/worker.js +0 -150
  253. package/dist/lib/ingest-router.d.ts +0 -25
  254. package/dist/lib/ocr-detector.d.ts +0 -61
  255. package/dist/lib/ocr-detector.js +0 -138
  256. package/dist/lib/ocr-engine-stub.d.ts +0 -48
  257. package/dist/lib/ocr-engine-stub.js +0 -190
  258. package/dist/lib/ocr-engines/google-doc-ai.d.ts +0 -36
  259. package/dist/lib/ocr-engines/google-doc-ai.js +0 -164
  260. package/dist/lib/ocr-jobs.d.ts +0 -67
  261. package/dist/lib/ocr-jobs.js +0 -129
  262. package/dist/lib/op-audit-extension/ran-at-guard.d.ts +0 -86
  263. package/dist/lib/op-audit.d.ts +0 -71
  264. package/dist/lib/privacy-br/detector.d.ts +0 -42
  265. package/dist/lib/privacy-br/detector.js +0 -130
  266. package/dist/lib/privacy-br/index.d.ts +0 -20
  267. package/dist/lib/privacy-br/index.js +0 -20
  268. package/dist/lib/privacy-br/integration.d.ts +0 -71
  269. package/dist/lib/privacy-br/integration.js +0 -74
  270. package/dist/lib/privacy-br/patterns.d.ts +0 -117
  271. package/dist/lib/privacy-br/patterns.js +0 -434
  272. package/dist/lib/privacy-br/redact.d.ts +0 -42
  273. package/dist/lib/privacy-br/redact.js +0 -103
  274. package/dist/lib/privacy-br/types.d.ts +0 -55
  275. package/dist/lib/privacy-br/types.js +0 -25
  276. package/dist/lib/regex-extract/extractor.d.ts +0 -30
  277. package/dist/lib/regex-extract/frontmatter.d.ts +0 -44
  278. package/dist/lib/regex-extract/index.d.ts +0 -14
  279. package/dist/lib/regex-extract/ingest-router-l4.d.ts +0 -76
  280. package/dist/lib/regex-extract/patterns.d.ts +0 -61
  281. package/dist/lib/regex-extract/production-wire.d.ts +0 -128
  282. package/dist/lib/regex-extract/reconcile.d.ts +0 -162
  283. package/dist/lib/regex-extract/strip-code.d.ts +0 -24
  284. package/dist/lib/regex-extract/types.d.ts +0 -48
  285. package/dist/lib/reranker.d.ts +0 -80
  286. package/dist/lib/shadow-tracker.d.ts +0 -191
  287. package/dist/lib/shadow-tracker.js +0 -384
  288. package/dist/lib/spo-injection.d.ts +0 -52
  289. package/dist/lib/telemetry-collector.d.ts +0 -158
  290. package/dist/lib/telemetry-collector.js +0 -249
  291. package/dist/lib/temporal-detector.d.ts +0 -27
  292. package/dist/lib/viewer/auth.d.ts +0 -37
  293. package/dist/lib/viewer/auth.js +0 -70
  294. package/dist/lib/viewer/backpressure.d.ts +0 -59
  295. package/dist/lib/viewer/backpressure.js +0 -100
  296. package/dist/lib/viewer/broadcast-singleton.d.ts +0 -34
  297. package/dist/lib/viewer/broadcast-singleton.js +0 -49
  298. package/dist/lib/viewer/broadcast.d.ts +0 -66
  299. package/dist/lib/viewer/broadcast.js +0 -96
  300. package/dist/lib/viewer/event-types.d.ts +0 -132
  301. package/dist/lib/viewer/event-types.js +0 -74
  302. package/dist/lib/viewer/instrumentation.d.ts +0 -106
  303. package/dist/lib/viewer/instrumentation.js +0 -224
  304. package/dist/lib/viewer/migration.d.ts +0 -23
  305. package/dist/lib/viewer/migration.js +0 -56
  306. package/dist/lib/viewer/redaction.d.ts +0 -44
  307. package/dist/lib/viewer/redaction.js +0 -139
  308. package/dist/lib/viewer/session.d.ts +0 -51
  309. package/dist/lib/viewer/session.js +0 -87
  310. package/dist/mcp/tools/answer.d.ts +0 -94
  311. package/dist/mcp/tools/archive.d.ts +0 -152
  312. package/dist/mcp/tools/archive.js +0 -170
  313. package/dist/mcp/tools/conflict.d.ts +0 -44
  314. package/dist/mcp/tools/conflict.js +0 -130
  315. package/dist/mcp/tools/hooks.d.ts +0 -29
  316. package/dist/mcp/tools/hooks.js +0 -78
  317. package/dist/mcp/tools/mark.d.ts +0 -38
  318. package/dist/mcp/tools/mark.js +0 -82
  319. package/dist/mcp/tools/viewer.d.ts +0 -58
  320. package/dist/mcp/tools/viewer.js +0 -64
  321. package/dist/mcp-server.d.ts +0 -2
  322. package/dist/metrics.d.ts +0 -3
  323. package/dist/noise-filter.d.ts +0 -18
  324. package/dist/notion-sync.d.ts +0 -7
  325. package/dist/notion-sync.js +0 -97
  326. package/dist/observability/adapters/a3-adapter.d.ts +0 -63
  327. package/dist/observability/adapters/a3-adapter.js +0 -83
  328. package/dist/observability/adapters/p1-adapter.d.ts +0 -49
  329. package/dist/observability/adapters/p1-adapter.js +0 -63
  330. package/dist/observability/adapters/p5-adapter.d.ts +0 -36
  331. package/dist/observability/adapters/p5-adapter.js +0 -71
  332. package/dist/observability/cardinality.d.ts +0 -61
  333. package/dist/observability/cardinality.js +0 -300
  334. package/dist/observability/collectors/db-stats.collector.d.ts +0 -9
  335. package/dist/observability/collectors/db-stats.collector.js +0 -88
  336. package/dist/observability/collectors/eventbus.collector.d.ts +0 -6
  337. package/dist/observability/collectors/eventbus.collector.js +0 -50
  338. package/dist/observability/collectors/process.collector.d.ts +0 -7
  339. package/dist/observability/collectors/process.collector.js +0 -93
  340. package/dist/observability/collectors/provider-telemetry.collector.d.ts +0 -11
  341. package/dist/observability/collectors/provider-telemetry.collector.js +0 -112
  342. package/dist/observability/collectors/search-telemetry.collector.d.ts +0 -12
  343. package/dist/observability/collectors/search-telemetry.collector.js +0 -76
  344. package/dist/observability/exporter.d.ts +0 -30
  345. package/dist/observability/exporter.js +0 -182
  346. package/dist/observability/index.d.ts +0 -22
  347. package/dist/observability/index.js +0 -21
  348. package/dist/observability/metrics.d.ts +0 -53
  349. package/dist/observability/metrics.js +0 -213
  350. package/dist/observability/privacy-guard.d.ts +0 -32
  351. package/dist/observability/privacy-guard.js +0 -116
  352. package/dist/observability/record.d.ts +0 -83
  353. package/dist/observability/record.js +0 -217
  354. package/dist/observability/registry.d.ts +0 -60
  355. package/dist/observability/registry.js +0 -93
  356. package/dist/observability/types.d.ts +0 -115
  357. package/dist/observability/types.js +0 -235
  358. package/dist/observability.d.ts +0 -131
  359. package/dist/plugins/nox-hooks/index.d.ts +0 -61
  360. package/dist/plugins/nox-hooks/index.js +0 -99
  361. package/dist/primer.d.ts +0 -1
  362. package/dist/privacy/filter.d.ts +0 -27
  363. package/dist/privacy/patterns.d.ts +0 -29
  364. package/dist/privacy/tag-parser.d.ts +0 -24
  365. package/dist/project-context-gen.d.ts +0 -10
  366. package/dist/providers/embedding/gemini.d.ts +0 -73
  367. package/dist/providers/embedding/openai.d.ts +0 -76
  368. package/dist/providers/embedding/types.d.ts +0 -39
  369. package/dist/providers/embedding/voyage.d.ts +0 -36
  370. package/dist/providers/index.d.ts +0 -116
  371. package/dist/providers/llm/anthropic.d.ts +0 -29
  372. package/dist/providers/llm/chain.d.ts +0 -99
  373. package/dist/providers/llm/gemini.d.ts +0 -48
  374. package/dist/providers/llm/openai.d.ts +0 -64
  375. package/dist/providers/llm/types.d.ts +0 -47
  376. package/dist/providers/telemetry.d.ts +0 -87
  377. package/dist/providers/types.d.ts +0 -42
  378. package/dist/query-entity-count.d.ts +0 -54
  379. package/dist/reflect.d.ts +0 -26
  380. package/dist/reindex-errors.d.ts +0 -7
  381. package/dist/reindex.d.ts +0 -16
  382. package/dist/retention.d.ts +0 -40
  383. package/dist/salience.d.ts +0 -85
  384. package/dist/scripts/migrate-v17-ops-audit.d.ts +0 -17
  385. package/dist/search-dedup.d.ts +0 -44
  386. package/dist/search-expansion.d.ts +0 -20
  387. package/dist/search.d.ts +0 -62
  388. package/dist/seh-detector.d.ts +0 -31
  389. package/dist/self-improve.d.ts +0 -1
  390. package/dist/session-distill.d.ts +0 -29
  391. package/dist/session-update.d.ts +0 -1
  392. package/dist/shared-memory.d.ts +0 -24
  393. package/dist/stats.d.ts +0 -1
  394. package/dist/temporal-retrieval.d.ts +0 -132
  395. package/dist/tier-manager.d.ts +0 -69
  396. package/dist/vectorize.d.ts +0 -16
  397. package/dist/version.d.ts +0 -1
  398. package/dist/watch.d.ts +0 -8
@@ -1,99 +0,0 @@
1
- /**
2
- * src/plugins/nox-hooks/index.ts — T8: OpenClaw plugin entrypoint.
3
- *
4
- * OpenClaw lifecycle (see ~/Claude/Projetos/openclaw-vps/infra/CLAUDE.md):
5
- * afterTurn(payload) → fires after each user/assistant turn
6
- * sessionStart(meta) → fires once at session boot
7
- * sessionEnd(summary) → fires at session close
8
- *
9
- * This plugin:
10
- * 1. Constructs HookEvent from OpenClaw payload (role + content + meta).
11
- * 2. Enqueues into the worker (non-blocking).
12
- * 3. Never throws — failures are logged via the host's logger and
13
- * reported as telemetry; the host turn is unaffected.
14
- *
15
- * The worker is created lazily on first afterTurn so the plugin loads
16
- * even when NOX_HOOKS_ENABLED=0 (Layer 1 will reject the events cheaply).
17
- */
18
- import { randomUUID } from "node:crypto";
19
- import { createPipeline } from "../../lib/hooks/pipeline.js";
20
- import { createWorker } from "../../lib/hooks/worker.js";
21
- import { loadConfig } from "../../lib/hooks/config.js";
22
- function normalizeRole(r) {
23
- const s = (r || "").toLowerCase();
24
- if (s === "user" || s === "assistant" || s === "system" || s === "tool")
25
- return s;
26
- return "unknown";
27
- }
28
- function projectSlugFromCwd(cwd) {
29
- if (!cwd)
30
- return "unknown";
31
- const parts = cwd.split("/").filter(Boolean);
32
- return parts[parts.length - 1] ?? "unknown";
33
- }
34
- /**
35
- * Build a plugin handle. Worker starts on first afterTurn().
36
- * Each plugin instance owns a single pipeline + worker.
37
- */
38
- export function createPlugin(deps) {
39
- const config = loadConfig();
40
- const pipeline = createPipeline({
41
- config,
42
- ...(deps.redact ? { redact: deps.redact } : {}),
43
- ingest: deps.ingest,
44
- telemetry: deps.telemetry,
45
- });
46
- const worker = createWorker({
47
- pipeline,
48
- maxSize: config.queueSize,
49
- telemetry: deps.telemetry,
50
- });
51
- let started = false;
52
- let sessionId;
53
- let cwd;
54
- let autoStart = true;
55
- function ensureStarted() {
56
- if (autoStart && !started) {
57
- worker.start();
58
- started = true;
59
- }
60
- }
61
- return {
62
- afterTurn(payload) {
63
- ensureStarted();
64
- try {
65
- const content = payload.content ?? payload.text ?? "";
66
- const role = normalizeRole(payload.role);
67
- const event = {
68
- event_id: `evt_${randomUUID()}`,
69
- source: "openclaw",
70
- role,
71
- content,
72
- session_id: payload.session_id ?? sessionId ?? "openclaw-session",
73
- project_slug: projectSlugFromCwd(payload.cwd ?? cwd),
74
- ts: new Date().toISOString(),
75
- ...(payload.meta ? { meta: payload.meta } : {}),
76
- };
77
- const res = worker.enqueue(event);
78
- return { accepted: res.accepted, reason: res.reason };
79
- }
80
- catch (e) {
81
- return { accepted: false, reason: `plugin_error:${e.message}` };
82
- }
83
- },
84
- sessionStart(meta = {}) {
85
- sessionId = meta.session_id ?? `s_${randomUUID()}`;
86
- cwd = meta.cwd;
87
- ensureStarted();
88
- },
89
- async sessionEnd() {
90
- if (started) {
91
- await worker.stop();
92
- started = false;
93
- }
94
- },
95
- inspect() {
96
- return { config, queueDepth: worker.stats().queueDepth };
97
- },
98
- };
99
- }
package/dist/primer.d.ts DELETED
@@ -1 +0,0 @@
1
- export declare function primer(): string;
@@ -1,27 +0,0 @@
1
- /**
2
- * privacy/filter.ts — Pre-storage redaction pipeline.
3
- *
4
- * Hook into ingest BEFORE chunk text is written to nox-mem.db.
5
- * Pipeline:
6
- * 1. Strip <private>...</private> blocks (tag-parser)
7
- * 2. Apply regex patterns in sequence (patterns.ts)
8
- * 3. Credit card candidates filtered through Luhn check
9
- *
10
- * Returns cleaned text + telemetry (count + kinds[]).
11
- * NEVER logs the original text or the values that were redacted.
12
- */
13
- export interface RedactResult {
14
- /** Text with secrets replaced */
15
- text: string;
16
- /** Total number of redactions applied */
17
- redactionCount: number;
18
- /** Deduplicated list of pattern names that fired */
19
- kinds: string[];
20
- }
21
- /**
22
- * Redact secrets from `text` before it is stored as a chunk.
23
- *
24
- * @param rawText Full raw text string (entity content, markdown body, etc.)
25
- * @returns { text, redactionCount, kinds }
26
- */
27
- export declare function redact(rawText: string): RedactResult;
@@ -1,29 +0,0 @@
1
- /**
2
- * privacy/patterns.ts — Regex patterns for secret/credential redaction.
3
- *
4
- * Each pattern covers a distinct secret type. The order matters:
5
- * - PEM blocks first (multiline, greedy — must match before base64 checks)
6
- * - Specific prefixed tokens before generic base64 matchers
7
- * - Credit card last (requires Luhn validation, most expensive)
8
- *
9
- * Replacement format: `[REDACTED:<name>]`
10
- *
11
- * NOTE: example values below are SYNTHETIC TEST FIXTURES, not real secrets.
12
- * gitleaks:allow — this file is the pattern library, not a credential store.
13
- */
14
- export interface RedactionPattern {
15
- /** Short name used in telemetry kinds[] and replacement string */
16
- name: string;
17
- /** Regex — must have no capturing groups that interfere with replace() */
18
- regex: RegExp;
19
- /** Replacement string. Use `[REDACTED:<name>]` convention. */
20
- replacement: string;
21
- /** Safe synthetic examples (for tests — NOT real secrets) */
22
- examples: string[];
23
- }
24
- /**
25
- * Luhn algorithm check for credit card numbers.
26
- * Returns true if number passes (likely a real CC, not a random 16-digit string).
27
- */
28
- export declare function luhn(digits: string): boolean;
29
- export declare const REDACTION_PATTERNS: RedactionPattern[];
@@ -1,24 +0,0 @@
1
- /**
2
- * privacy/tag-parser.ts — Handle user-marked <private>...</private> blocks.
3
- *
4
- * Strips content inside <private> tags BEFORE the regex redaction pass.
5
- * Tags are case-insensitive, allow whitespace before/after, and work across
6
- * multiple lines. The replacement is `[REDACTED:user-marked]`.
7
- *
8
- * Design decision: tag stripping is independent and runs first so that any
9
- * secrets explicitly marked by the author are handled even if the regex pass
10
- * would miss them (e.g., non-standard formats, obfuscated values).
11
- *
12
- * Nesting: nested tags are NOT supported — the first `</private>` closes the
13
- * block. This is intentional: nested marks are unlikely in practice and
14
- * supporting them adds regex complexity with no real benefit.
15
- */
16
- export interface TagStripResult {
17
- text: string;
18
- tagCount: number;
19
- }
20
- /**
21
- * Strip all `<private>...</private>` blocks from text.
22
- * Returns the cleaned text and the number of blocks removed.
23
- */
24
- export declare function stripPrivateTags(text: string): TagStripResult;
@@ -1,10 +0,0 @@
1
- /**
2
- * project-context-gen.ts - Auto-generate PROJECT_CONTEXT.md from memory chunks
3
- * Each project gets status extracted from latest memory entries
4
- */
5
- export declare function syncProjectContexts(): {
6
- updated: number;
7
- created: number;
8
- errors: number;
9
- };
10
- export declare function listProjects(): void;
@@ -1,73 +0,0 @@
1
- /**
2
- * src/providers/embedding/gemini.ts — Gemini embedding provider (T3).
3
- *
4
- * Real impl wrapping `generativelanguage.googleapis.com/v1beta`.
5
- * D41 default model: `gemini-embedding-001` at 3072 dimensions.
6
- *
7
- * Design notes:
8
- * - Uses `fetch` (Node 18+) — no SDK dependency. The live `src/embedder.ts`
9
- * in prod uses the official SDK; this staged path mirrors its wire shape
10
- * so behaviour is byte-equivalent for the same model + input.
11
- * - `apiKey` resolved from `GEMINI_API_KEY` env at construction. Stored
12
- * privately and NEVER echoed in errors (regex-blocked).
13
- * - `fetchFn` is injectable for tests — production passes nothing and the
14
- * global `fetch` is used. Tests pass a stub to avoid network calls.
15
- * - `healthCheck()` calls the `:embedContent` endpoint with a 1-token input
16
- * ("ping") — cheapest possible probe per spec §4 (T9 conformance: probes
17
- * never cost > $0.01).
18
- * - All errors redacted: never include the API key value, never echo upstream
19
- * 401/403 body verbatim (some Gemini errors echo bearer prefix).
20
- */
21
- import type { EmbeddingProvider } from "./types.js";
22
- import type { HealthStatus } from "../types.js";
23
- /** Default model + dim per D41. */
24
- export declare const GEMINI_EMBED_DEFAULT_MODEL = "gemini-embedding-001";
25
- export declare const GEMINI_EMBED_DEFAULT_DIM = 3072;
26
- /** Public list price (USD per 1M tokens) — gemini-embedding-001 as of 2026-05. */
27
- export declare const GEMINI_EMBED_COST_PER_M_TOKENS = 0.15;
28
- /** Per-input token ceiling (Gemini hard limit ~2048 input tokens / item). */
29
- export declare const GEMINI_EMBED_MAX_TOKENS = 2048;
30
- /** Minimal fetch type compatible with Node 18+ global fetch (avoid lib.dom dep). */
31
- export type FetchLike = (input: string, init?: {
32
- method?: string;
33
- headers?: Record<string, string>;
34
- body?: string;
35
- signal?: AbortSignal;
36
- }) => Promise<{
37
- ok: boolean;
38
- status: number;
39
- statusText: string;
40
- text: () => Promise<string>;
41
- json: () => Promise<unknown>;
42
- }>;
43
- export interface GeminiEmbeddingOpts {
44
- /** Override model (e.g., 'text-embedding-004'). Default: gemini-embedding-001. */
45
- model?: string;
46
- /** Override dimensions. Default: 3072. */
47
- dimensions?: number;
48
- /** Override API key (else read GEMINI_API_KEY env). */
49
- apiKey?: string;
50
- /** Injected fetch for tests; defaults to globalThis.fetch. */
51
- fetchFn?: FetchLike;
52
- /** Base URL override (lets tests point at fixture server). */
53
- baseUrl?: string;
54
- }
55
- export declare class GeminiEmbeddingProvider implements EmbeddingProvider {
56
- readonly name = "gemini";
57
- readonly dimensions: number;
58
- readonly maxTokens: number;
59
- readonly costPerMillionTokens: number;
60
- readonly model: string;
61
- private readonly apiKey;
62
- private readonly fetchFn;
63
- private readonly baseUrl;
64
- constructor(opts?: GeminiEmbeddingOpts);
65
- embed(texts: string[]): Promise<Float32Array[]>;
66
- healthCheck(): Promise<HealthStatus>;
67
- }
68
- /**
69
- * Strip anything that looks like an API key from error text before surfacing.
70
- * Gemini keys are typically 39 chars starting "AIza"; we also catch generic
71
- * long base64-ish tokens to be defensive (covers OpenAI sk-... etc).
72
- */
73
- export declare function redactSecrets(s: string): string;
@@ -1,76 +0,0 @@
1
- /**
2
- * src/providers/embedding/openai.ts — OpenAI-compatible embedding provider (A3.1, real).
3
- *
4
- * Talks the OpenAI Embeddings wire shape:
5
- * POST {baseUrl}/embeddings
6
- * Authorization: Bearer <apiKey>
7
- * body: { model, input: string[], dimensions? }
8
- * parse: data[].embedding (sorted by data[].index to preserve input order)
9
- *
10
- * Single class drives any OpenAI-compatible embedding endpoint via `baseUrl`:
11
- *
12
- * | Backend | baseUrl | example model |
13
- * |-------------|----------------------------------------|--------------------------|
14
- * | OpenAI | https://api.openai.com/v1 (default) | text-embedding-3-small |
15
- * | Together | https://api.together.xyz/v1 | BAAI/bge-large-en-v1.5 |
16
- * | OpenRouter | https://openrouter.ai/api/v1 | (varies by listing) |
17
- * | DeepInfra | https://api.deepinfra.com/v1/openai | BAAI/bge-m3 |
18
- * | local | http://127.0.0.1:11434/v1 (ollama) | nomic-embed-text |
19
- *
20
- * ⚠ EMBEDDING DIMENSION CAVEAT (read before switching):
21
- * The DB / sqlite-vec virtual table is fixed at the dim it was created with
22
- * (nox-mem prod = 3072, from gemini-embedding-001). Mixing dims, or even the
23
- * same dim from a different model, corrupts semantic search — vectors are not
24
- * comparable across models. To swap to OpenAI you MUST re-embed the whole
25
- * corpus with a single model at a single dim, and that dim MUST equal the
26
- * vec0 table dim. `text-embedding-3-large` supports dimensions=3072 (parity
27
- * with the existing table); `text-embedding-3-small` defaults to 1536 and is
28
- * only safe on a fresh 1536-dim table. Set `NOX_EMBEDDING_MODEL` +
29
- * `NOX_EMBEDDING_DIM` deliberately.
30
- *
31
- * Design parity with GeminiEmbeddingProvider:
32
- * - `fetch` (Node 18+), no SDK. `fetchFn` injectable for tests.
33
- * - Key from constructor arg → OPENAI_API_KEY env. Stored privately, redacted
34
- * from all error text.
35
- * - Construction is NON-throwing when no key present (factory conformance). The
36
- * missing key surfaces as MissingKeyError on the first embed()/healthCheck().
37
- * - Returns Float32Array[] (one per input, in input order), each length = dim.
38
- * Per-vector copy into a fresh Float32Array (no Buffer aliasing — lesson
39
- * 2026-05-03).
40
- */
41
- import type { EmbeddingProvider } from "./types.js";
42
- import type { HealthStatus } from "../types.js";
43
- import { type FetchLike } from "./gemini.js";
44
- export declare const OPENAI_EMBED_DEFAULT_MODEL = "text-embedding-3-small";
45
- /** Default dim for `text-embedding-3-small`. `text-embedding-3-large` supports 3072. */
46
- export declare const OPENAI_EMBED_DEFAULT_DIM = 1536;
47
- /** Per OpenAI public pricing 2026-05: $0.02 / 1M for 3-small, $0.13 / 1M for 3-large. */
48
- export declare const OPENAI_EMBED_DEFAULT_COST = 0.02;
49
- export declare const OPENAI_EMBED_MAX_TOKENS = 8191;
50
- /** Default endpoint. Override for Together/OpenRouter/DeepInfra/local. */
51
- export declare const OPENAI_EMBED_DEFAULT_BASE_URL = "https://api.openai.com/v1";
52
- export interface OpenAIEmbeddingOpts {
53
- /** Override model. Default: text-embedding-3-small. */
54
- model?: string;
55
- /** Override output dimensions. Default: 1536. MUST equal the vec0 table dim. */
56
- dimensions?: number;
57
- /** Override API key. Else read OPENAI_API_KEY. */
58
- apiKey?: string;
59
- /** Injected fetch for tests; defaults to globalThis.fetch. */
60
- fetchFn?: FetchLike;
61
- /** Base URL override (no trailing slash). Default https://api.openai.com/v1. */
62
- baseUrl?: string;
63
- }
64
- export declare class OpenAIEmbeddingProvider implements EmbeddingProvider {
65
- readonly name = "openai";
66
- readonly model: string;
67
- readonly dimensions: number;
68
- readonly maxTokens: number;
69
- readonly costPerMillionTokens: number;
70
- private readonly apiKey;
71
- private readonly baseUrl;
72
- private readonly fetchFn;
73
- constructor(opts?: OpenAIEmbeddingOpts);
74
- embed(texts: string[]): Promise<Float32Array[]>;
75
- healthCheck(): Promise<HealthStatus>;
76
- }
@@ -1,39 +0,0 @@
1
- /**
2
- * src/providers/embedding/types.ts — EmbeddingProvider interface (T1).
3
- *
4
- * A3 spec §3 (locked from user task description):
5
- * readonly name, dimensions, maxTokens, costPerMillionTokens
6
- * embed(texts: string[]): Promise<Float32Array[]>
7
- * healthCheck(): Promise<HealthStatus>
8
- *
9
- * Notes:
10
- * - `Float32Array[]` — one vector per input text. Avoid Buffer typed-array aliasing
11
- * (lesson 2026-05-03: Node Buffer pool corrupts Float32Array views; cache impls
12
- * must copy via Uint8Array intermediate).
13
- * - Implementations may also expose `task_type` (retrieval.query|document) via
14
- * provider-specific options; this base interface keeps the signature minimal
15
- * per the locked spec to keep the swap surface narrow.
16
- * - Stubs may throw "not implemented" from `embed()`; `healthCheck()` MUST still
17
- * return a deterministic shape so the registry's boot-time ping is uniform.
18
- */
19
- import type { HealthStatus } from "../types.js";
20
- export interface EmbeddingProvider {
21
- /** Provider id: 'gemini' | 'openai' | 'voyage' | future ids. */
22
- readonly name: string;
23
- /** Output vector dimensionality. Pre-A3.1: must match active corpus dim. */
24
- readonly dimensions: number;
25
- /** Max input tokens per single embed() input element (provider-side limit). */
26
- readonly maxTokens: number;
27
- /** Public list price in USD per 1,000,000 input tokens. */
28
- readonly costPerMillionTokens: number;
29
- /**
30
- * Compute embeddings for an ordered batch of texts.
31
- * Returns one Float32Array (length = `dimensions`) per input, in order.
32
- */
33
- embed(texts: string[]): Promise<Float32Array[]>;
34
- /**
35
- * Boot-time / on-demand health probe.
36
- * MUST be cheap (no token consumption) and complete within ~5s.
37
- */
38
- healthCheck(): Promise<HealthStatus>;
39
- }
@@ -1,36 +0,0 @@
1
- /**
2
- * src/providers/embedding/voyage.ts — Voyage embedding stub (T7).
3
- *
4
- * Interface conformance only — throws `NotImplementedError` on `embed()`.
5
- * Real impl deferred to A3.1.
6
- *
7
- * Models reserved:
8
- * - voyage-3 (1024d) ← default
9
- * - voyage-3-large (1024d)
10
- * - voyage-code-2 (1536d) ← code-aware retrieval
11
- *
12
- * Note: 1024d ≠ Gemini's 3072d — swap to Voyage requires A3.1 reembed.
13
- * Stub `healthCheck()` flags this to surface as a clear error before any
14
- * user accidentally points the corpus at a dim-mismatched provider.
15
- */
16
- import type { EmbeddingProvider } from "./types.js";
17
- import type { HealthStatus } from "../types.js";
18
- export declare const VOYAGE_EMBED_DEFAULT_MODEL = "voyage-3";
19
- export declare const VOYAGE_EMBED_DEFAULT_DIM = 1024;
20
- export declare const VOYAGE_EMBED_DEFAULT_COST = 0.06;
21
- export declare const VOYAGE_EMBED_MAX_TOKENS = 32000;
22
- export interface VoyageEmbeddingOpts {
23
- model?: string;
24
- dimensions?: number;
25
- apiKey?: string;
26
- }
27
- export declare class VoyageEmbeddingProvider implements EmbeddingProvider {
28
- readonly name = "voyage";
29
- readonly model: string;
30
- readonly dimensions: number;
31
- readonly maxTokens: number;
32
- readonly costPerMillionTokens: number;
33
- constructor(opts?: VoyageEmbeddingOpts);
34
- embed(_texts: string[]): Promise<Float32Array[]>;
35
- healthCheck(): Promise<HealthStatus>;
36
- }
@@ -1,116 +0,0 @@
1
- /**
2
- * src/providers/index.ts — Public registry / factories (T2 + T8).
3
- *
4
- * Two factories drive provider selection:
5
- * - selectEmbeddingProvider(name?)
6
- * - selectLLMProvider(name?)
7
- *
8
- * Resolution order:
9
- * 1. explicit `name` arg
10
- * 2. env var `NOX_EMBEDDING_PROVIDER` / `NOX_LLM_PROVIDER`
11
- * 3. default = 'gemini' (D41)
12
- *
13
- * Model override:
14
- * - `NOX_EMBEDDING_MODEL=text-embedding-3-large` (alias: NOX_EMBED_MODEL)
15
- * - `NOX_LLM_MODEL=gemini-2.5-flash` (CLAUDE.md regra #3 — explicit only)
16
- *
17
- * OpenAI-compatible overrides (A3.1 — DeepSeek/OpenRouter/Together/local):
18
- * LLM:
19
- * - `NOX_LLM_BASE_URL` (default https://api.openai.com/v1 for openai)
20
- * - `NOX_LLM_API_KEY` (fallback: GEMINI_API_KEY for gemini, OPENAI_API_KEY for openai)
21
- * Embedding (canonical prefix is NOX_EMBEDDING_*; NOX_EMBED_* accepted as alias):
22
- * - `NOX_EMBEDDING_BASE_URL` (alias NOX_EMBED_BASE_URL)
23
- * - `NOX_EMBEDDING_API_KEY` (alias NOX_EMBED_API_KEY; fallback GEMINI_API_KEY/OPENAI_API_KEY)
24
- * - `NOX_EMBEDDING_DIM` (alias NOX_EMBED_DIM) — MUST equal the vec0 table dim
25
- *
26
- * Boot-time health check (T8):
27
- * - `bootProviderHealth({ embedding?, llm?, failFast? })`
28
- * - failFast=true (default) throws `ProviderHealthError` on any down provider
29
- * - failFast=false logs a warning via `onWarn` callback; caller continues
30
- * - Driven by `NOX_PROVIDER_HEALTH_FAIL_FAST` env (default '1')
31
- *
32
- * Stubs (openai/anthropic/voyage) return `ok=false` from healthCheck() by
33
- * design. boot health by default ONLY probes the *selected* providers, NOT
34
- * every registered one — so a user who keeps Gemini defaults never gets
35
- * spurious failures from un-activated stubs.
36
- */
37
- import type { EmbeddingProvider } from "./embedding/types.js";
38
- import type { LLMProvider } from "./llm/types.js";
39
- import { type HealthStatus } from "./types.js";
40
- import { type LLMFallbackChain, type FallbackChainOpts } from "./llm/chain.js";
41
- export type { EmbeddingProvider } from "./embedding/types.js";
42
- export type { LLMProvider, CompleteOpts, CompleteResult } from "./llm/types.js";
43
- export type { HealthStatus } from "./types.js";
44
- export { MissingKeyError, UnknownProviderError, NotImplementedError, ProviderHealthError, } from "./types.js";
45
- export declare const KNOWN_EMBEDDING_PROVIDERS: readonly ["gemini", "openai", "voyage"];
46
- export declare const KNOWN_LLM_PROVIDERS: readonly ["gemini", "openai", "anthropic"];
47
- export type EmbeddingProviderName = (typeof KNOWN_EMBEDDING_PROVIDERS)[number];
48
- export type LLMProviderName = (typeof KNOWN_LLM_PROVIDERS)[number];
49
- /**
50
- * Factory: returns an EmbeddingProvider.
51
- *
52
- * @param name explicit provider name; else `NOX_EMBEDDING_PROVIDER` env; else 'gemini'
53
- * @param env optional env override (test seam)
54
- *
55
- * Throws `UnknownProviderError` if name is not in `KNOWN_EMBEDDING_PROVIDERS`.
56
- * May throw `MissingKeyError` (Gemini) at construction.
57
- */
58
- export declare function selectEmbeddingProvider(name?: string, env?: NodeJS.ProcessEnv): EmbeddingProvider;
59
- /**
60
- * Factory: returns an LLMProvider.
61
- *
62
- * @param name explicit provider name; else `NOX_LLM_PROVIDER` env; else 'gemini'
63
- * @param env optional env override (test seam)
64
- *
65
- * Throws `UnknownProviderError` if unknown. Gemini may throw `MissingKeyError`
66
- * at construction.
67
- *
68
- * Default model for gemini is `gemini-2.5-flash-lite` (D41). Override via
69
- * `NOX_LLM_MODEL` env (CLAUDE.md regra #3: switching to flash full is opt-in).
70
- */
71
- export declare function selectLLMProvider(name?: string, env?: NodeJS.ProcessEnv): LLMProvider;
72
- /**
73
- * Select the primary LLM provider AND, if `NOX_LLM_FALLBACK` is set, wrap it in
74
- * an env-driven fallback chain — injecting `selectLLMProvider` as the factory so
75
- * `chain.ts` stays free of a circular import.
76
- *
77
- * Returns the bare primary provider when no fallback is configured. Either way
78
- * the result implements `LLMProvider`, so callers can swap this in for
79
- * `selectLLMProvider()` transparently.
80
- */
81
- export declare function selectLLMProviderWithFallback(name?: string, env?: NodeJS.ProcessEnv, chainOpts?: Omit<FallbackChainOpts, "primary" | "fallbacks">): LLMProvider | LLMFallbackChain;
82
- export interface BootHealthOpts {
83
- embedding?: EmbeddingProvider;
84
- llm?: LLMProvider;
85
- /** Override env-driven fail-fast (`NOX_PROVIDER_HEALTH_FAIL_FAST=0` to soft-warn). */
86
- failFast?: boolean;
87
- /** Per-probe timeout in ms. Default 5000. */
88
- timeoutMs?: number;
89
- /** Hook for soft-warn mode; receives `{providerName, kind, error}`. */
90
- onWarn?: (warning: {
91
- providerName: string;
92
- kind: "embedding" | "llm";
93
- error: string;
94
- }) => void;
95
- /** Env override for tests. */
96
- env?: NodeJS.ProcessEnv;
97
- }
98
- export interface BootHealthReport {
99
- embedding?: HealthStatus & {
100
- providerName: string;
101
- };
102
- llm?: HealthStatus & {
103
- providerName: string;
104
- };
105
- /** True iff every probed provider returned ok=true. */
106
- allOk: boolean;
107
- }
108
- /**
109
- * Probe configured providers and (by default) throw if any are down.
110
- *
111
- * Returns a structured report regardless of failFast: in soft-warn mode
112
- * the caller gets the full picture and can decide. In fail-fast mode the
113
- * report is also returned (alongside the throw) so caller's stack trace
114
- * shows the actual probe latencies for forensics.
115
- */
116
- export declare function bootProviderHealth(opts?: BootHealthOpts): Promise<BootHealthReport>;
@@ -1,29 +0,0 @@
1
- /**
2
- * src/providers/llm/anthropic.ts — Anthropic LLM stub (T6).
3
- *
4
- * Interface conformance only — throws `NotImplementedError` on `complete()`.
5
- *
6
- * Real impl deferred to A3.1. No embedding sibling: Anthropic has no public
7
- * embedding API as of 2026-05 (A3 spec §T6).
8
- *
9
- * Models reserved:
10
- * - claude-3-5-haiku ← cheap fallback default
11
- * - claude-3-5-sonnet ← opt-in heavy reasoning
12
- */
13
- import type { LLMProvider, CompleteOpts, CompleteResult } from "./types.js";
14
- import type { HealthStatus } from "../types.js";
15
- export declare const ANTHROPIC_LLM_DEFAULT_MODEL = "claude-3-5-haiku";
16
- export declare const ANTHROPIC_LLM_CONTEXT_WINDOWS: Record<string, number>;
17
- export interface AnthropicLLMOpts {
18
- model?: string;
19
- apiKey?: string;
20
- contextWindow?: number;
21
- }
22
- export declare class AnthropicLLMProvider implements LLMProvider {
23
- readonly name = "anthropic";
24
- readonly model: string;
25
- readonly contextWindow: number;
26
- constructor(opts?: AnthropicLLMOpts);
27
- complete(_opts: CompleteOpts): Promise<CompleteResult>;
28
- healthCheck(): Promise<HealthStatus>;
29
- }
@@ -1,99 +0,0 @@
1
- /**
2
- * src/providers/llm/chain.ts — LLM fallback chain (T9).
3
- *
4
- * `LLMFallbackChain` wraps a primary + ordered list of fallback providers.
5
- * Activation: gated by `NOX_LLM_FALLBACK` env var (otherwise primary-only).
6
- *
7
- * Retry / fallback policy (per A3 spec §T10):
8
- * - primary timeout (default 30s) → try fallback[0], then fallback[1], etc.
9
- * - HTTP 429 (rate limit) → mark primary cooldown 60s, try next provider
10
- * - HTTP 401/403 (auth) → fail-fast, do NOT try fallback (user config bug)
11
- * - max 1 retry per provider in a single call
12
- * - `CompleteResult.providerId` filled so callers attribute telemetry correctly
13
- *
14
- * EMBEDDINGS ARE NOT CHAINED: mixing embedding providers mid-corpus silently
15
- * corrupts semantic search (A3 spec §5). Only LLM calls go through this chain.
16
- *
17
- * Building the chain from env:
18
- * NOX_LLM_FALLBACK=anthropic:claude-3-5-haiku,openai:gpt-4o-mini
19
- * → chain = [primary, anthropicProvider, openaiProvider]
20
- *
21
- * Use `buildFallbackChain(env?)` to construct from env vars.
22
- */
23
- import type { LLMProvider, CompleteOpts, CompleteResult } from "./types.js";
24
- import type { HealthStatus } from "../types.js";
25
- /** Clear all cooldowns (test utility). */
26
- export declare function clearAllCooldowns(): void;
27
- export interface FallbackEvent {
28
- kind: "primary_ok" | "primary_fail_try_next" | "fallback_ok" | "all_fail" | "auth_fail";
29
- usedProviderId: string;
30
- attemptIndex: number;
31
- errorKind?: "timeout" | "rate_limit" | "auth" | "network" | "unknown";
32
- latencyMs: number;
33
- }
34
- export interface FallbackChainOpts {
35
- /** Primary provider. REQUIRED. */
36
- primary: LLMProvider;
37
- /** Ordered fallbacks. Empty = no fallback (primary-only). */
38
- fallbacks?: LLMProvider[];
39
- /** Per-provider call timeout in ms. Default: 30_000. */
40
- timeoutMs?: number;
41
- /** Rate-limit cooldown in ms. Default: 60_000. */
42
- cooldownMs?: number;
43
- /** Optional telemetry callback. Never throws. */
44
- onEvent?: (event: FallbackEvent) => void;
45
- }
46
- export declare class LLMFallbackChain implements LLMProvider {
47
- readonly name: string;
48
- readonly model: string;
49
- readonly contextWindow: number;
50
- private readonly primary;
51
- private readonly fallbacks;
52
- private readonly timeoutMs;
53
- private readonly cooldownMs;
54
- private readonly onEvent?;
55
- constructor(opts: FallbackChainOpts);
56
- /** Attempt a `complete()` call on `provider` with timeout enforcement. */
57
- private attemptProvider;
58
- complete(opts: CompleteOpts): Promise<CompleteResult & {
59
- providerId: string;
60
- }>;
61
- healthCheck(): Promise<HealthStatus>;
62
- private emit;
63
- }
64
- /**
65
- * A factory that builds an LLM provider from a provider name + optional model
66
- * override. Normally `selectLLMProvider` from index.ts; injected here to keep
67
- * chain.ts free of a circular import (index.ts → chain.ts → index.ts).
68
- */
69
- export type LLMProviderFactory = (name: string, env?: NodeJS.ProcessEnv) => LLMProvider;
70
- /** One parsed `provider:model` (model optional) fallback spec. */
71
- export interface FallbackSpec {
72
- provider: string;
73
- model?: string;
74
- }
75
- /** Parse `provider:model,provider2` → ordered FallbackSpec[]. */
76
- export declare function parseFallbackSpec(raw: string): FallbackSpec[];
77
- /**
78
- * Parse `NOX_LLM_FALLBACK` env var and build the LLMFallbackChain.
79
- *
80
- * Format: `NOX_LLM_FALLBACK=anthropic:claude-3-5-haiku,openai:gpt-4o-mini`
81
- * Each entry is `provider` or `provider:model`. Built in order; each becomes a
82
- * fallback after `primary`.
83
- *
84
- * Returns `null` when `NOX_LLM_FALLBACK` is not set (primary-only mode).
85
- *
86
- * @param factory Provider factory (inject `selectLLMProvider`). Required when
87
- * NOX_LLM_FALLBACK is set — keeps chain.ts free of circular import.
88
- * When omitted with a non-empty fallback spec we throw so the
89
- * misconfiguration is loud rather than silently primary-only.
90
- */
91
- export declare function buildFallbackChainFromEnv(primary: LLMProvider, factory: LLMProviderFactory | undefined, env?: NodeJS.ProcessEnv, opts?: Omit<FallbackChainOpts, "primary" | "fallbacks">): LLMFallbackChain | null;
92
- /**
93
- * Build fallback chain using a provider factory (seam for tests and for index.ts).
94
- *
95
- * @param primary Pre-constructed primary provider.
96
- * @param fallbacks Pre-constructed ordered fallback providers.
97
- * @param opts Chain tuning options.
98
- */
99
- export declare function buildFallbackChain(primary: LLMProvider, fallbacks: LLMProvider[], opts?: Omit<FallbackChainOpts, "primary" | "fallbacks">): LLMFallbackChain;