@devilsdev/rag-pipeline-utils 2.4.4 → 2.5.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 (225) hide show
  1. package/.ragrc.schema.json +83 -192
  2. package/CHANGELOG.md +345 -0
  3. package/README.md +418 -117
  4. package/SECURITY.md +5 -5
  5. package/dist/experimental.cjs +2 -0
  6. package/dist/experimental.d.ts +1 -0
  7. package/dist/experimental.mjs +5 -0
  8. package/dist/index.cjs +4992 -1242
  9. package/dist/index.d.ts +80 -2
  10. package/dist/index.mjs +1 -1
  11. package/dist/types/agentic/agentic-pipeline.d.ts +103 -0
  12. package/dist/types/agentic/iterative-retriever.d.ts +85 -0
  13. package/dist/types/agentic/query-planner.d.ts +145 -0
  14. package/dist/types/agentic/self-critique.d.ts +45 -0
  15. package/dist/types/ai/adaptive-retrieval.d.ts +44 -0
  16. package/dist/types/ai/federation/federated-learning-coordinator.d.ts +62 -0
  17. package/dist/types/ai/multimodal-processing.d.ts +32 -0
  18. package/dist/types/ai/multimodal.d.ts +39 -0
  19. package/dist/types/ai/retrieval-engine.d.ts +37 -0
  20. package/dist/types/ai/training/model-training-orchestrator.d.ts +31 -0
  21. package/dist/types/chunking/chunking-engine.d.ts +70 -0
  22. package/dist/types/chunking/strategies/fixed-size.d.ts +17 -0
  23. package/dist/types/chunking/strategies/recursive.d.ts +20 -0
  24. package/dist/types/chunking/strategies/semantic.d.ts +19 -0
  25. package/dist/types/chunking/strategies/sentence.d.ts +13 -0
  26. package/dist/types/chunking/strategies/structure-aware.d.ts +19 -0
  27. package/dist/types/citation/citation-tracker.d.ts +64 -0
  28. package/dist/types/citation/hallucination-detector.d.ts +40 -0
  29. package/dist/types/citation/source-mapper.d.ts +37 -0
  30. package/dist/types/connectors/anthropic-connector.d.ts +92 -0
  31. package/dist/types/connectors/base-connector.d.ts +87 -0
  32. package/dist/types/connectors/cohere-connector.d.ts +89 -0
  33. package/dist/types/connectors/connector-utils.d.ts +110 -0
  34. package/dist/types/connectors/local-embedder.d.ts +86 -0
  35. package/dist/types/connectors/memory-retriever.d.ts +91 -0
  36. package/dist/types/connectors/ollama-connector.d.ts +110 -0
  37. package/dist/types/connectors/openai-connector.d.ts +114 -0
  38. package/dist/types/connectors/rag-prompt.d.ts +40 -0
  39. package/dist/types/cost/cost-calculator.d.ts +152 -0
  40. package/dist/types/cost/cost-tracker.d.ts +126 -0
  41. package/dist/types/cost/token-budget.d.ts +110 -0
  42. package/dist/types/dag/core/error-context.d.ts +239 -0
  43. package/dist/types/dag/core/execution-scheduler.d.ts +191 -0
  44. package/dist/types/dag/core/topology-validation.d.ts +226 -0
  45. package/dist/types/dag/dag-engine.d.ts +156 -0
  46. package/dist/types/dag/dag-node.d.ts +37 -0
  47. package/dist/types/dashboard/dashboard-generator.d.ts +127 -0
  48. package/dist/types/dashboard/metrics-aggregator.d.ts +218 -0
  49. package/dist/types/debug/execution-tracer.d.ts +57 -0
  50. package/dist/types/debug/trace-inspector.d.ts +31 -0
  51. package/dist/types/ecosystem/plugin-certification.d.ts +169 -0
  52. package/dist/types/enterprise/data-governance.d.ts +203 -0
  53. package/dist/types/enterprise/multi-tenancy.d.ts +137 -0
  54. package/dist/types/enterprise/sso-integration.d.ts +420 -0
  55. package/dist/types/evaluate/context-metrics.d.ts +55 -0
  56. package/dist/types/evaluate/faithfulness.d.ts +41 -0
  57. package/dist/types/evaluate/groundedness.d.ts +60 -0
  58. package/dist/types/evaluate/pipeline-evaluator.d.ts +88 -0
  59. package/dist/types/evaluate/relevance.d.ts +21 -0
  60. package/dist/types/evaluate/scoring.d.ts +123 -0
  61. package/dist/types/experimental.d.ts +15 -0
  62. package/dist/types/graph/entity-extractor.d.ts +84 -0
  63. package/dist/types/graph/graph-index.d.ts +49 -0
  64. package/dist/types/graph/graph-retriever.d.ts +81 -0
  65. package/dist/types/graph/knowledge-graph.d.ts +129 -0
  66. package/dist/types/guardrails/guardrails-pipeline.d.ts +63 -0
  67. package/dist/types/guardrails/injection-detector.d.ts +47 -0
  68. package/dist/types/guardrails/post-generation-guard.d.ts +61 -0
  69. package/dist/types/guardrails/pre-retrieval-guard.d.ts +64 -0
  70. package/dist/types/guardrails/retrieval-guard.d.ts +57 -0
  71. package/dist/types/mcp/mcp-server.d.ts +85 -0
  72. package/dist/types/mcp/mcp-tool-builder.d.ts +55 -0
  73. package/dist/types/reranker/cascade-reranker.d.ts +40 -0
  74. package/dist/types/reranker/embedding-reranker.d.ts +77 -0
  75. package/dist/types/reranker/scoring-reranker.d.ts +41 -0
  76. package/dist/types/retrieval/bm25-search.d.ts +43 -0
  77. package/dist/types/retrieval/file-vector-store.d.ts +87 -0
  78. package/dist/types/retrieval/hybrid-retriever.d.ts +35 -0
  79. package/dist/types/retrieval/rank-fusion.d.ts +10 -0
  80. package/dist/types/security/jwt-config.d.ts +80 -0
  81. package/dist/types/security/jwt-validator.d.ts +195 -0
  82. package/dist/types/security/plugin-sandbox.d.ts +158 -0
  83. package/dist/types/security/plugin-signature-verifier.d.ts +139 -0
  84. package/dist/types/security/validator.d.ts +5 -0
  85. package/dist/types/streaming/embedding-stream.d.ts +65 -0
  86. package/dist/types/streaming/sse-adapter.d.ts +59 -0
  87. package/dist/types/streaming/stream-router.d.ts +88 -0
  88. package/dist/types/streaming/streaming-embedder.d.ts +99 -0
  89. package/dist/types/streaming/websocket-adapter.d.ts +71 -0
  90. package/dist/types/templates/scaffold.d.ts +55 -0
  91. package/dist/types/templates/template-registry.d.ts +63 -0
  92. package/dist/types/utils/embed-query.d.ts +20 -0
  93. package/dist/types/utils/logger.d.ts +50 -0
  94. package/dist/types/utils/rate-limiter.d.ts +66 -0
  95. package/dist/types/utils/retry.d.ts +27 -0
  96. package/dist/types/utils/run-abort.d.ts +34 -0
  97. package/dist/types/utils/secure-logging.d.ts +51 -0
  98. package/dist/types/utils/structured-logger.d.ts +126 -0
  99. package/package.json +53 -29
  100. package/src/agentic/agentic-pipeline.js +75 -7
  101. package/src/agentic/iterative-retriever.js +47 -10
  102. package/src/agentic/query-planner.js +329 -78
  103. package/src/citation/citation-tracker.js +6 -4
  104. package/src/citation/hallucination-detector.js +2 -2
  105. package/src/citation/source-mapper.js +15 -28
  106. package/src/cli/commands/ai.js +101 -0
  107. package/src/cli/commands/plugin-hub/event-handlers.js +6 -0
  108. package/src/cli/commands/plugin-hub/hub-commands.js +0 -74
  109. package/src/cli/commands/plugin-hub/local-commands.js +143 -0
  110. package/src/cli/commands/plugin-hub.js +96 -36
  111. package/src/cli/diagnostics/config-checker.js +76 -63
  112. package/src/cli/diagnostics/environment-checker.js +62 -31
  113. package/src/cli/diagnostics/plugin-checker.js +36 -89
  114. package/src/cli/doctor-command.js +39 -5
  115. package/src/cli/enhanced-cli-commands.js +72 -217
  116. package/src/cli/handlers/ai-handler.js +364 -0
  117. package/src/cli/handlers/diagnostics-handler.js +78 -31
  118. package/src/cli/handlers/ingest-handler.js +28 -22
  119. package/src/cli/handlers/init-handler.js +148 -25
  120. package/src/cli/handlers/query-handler.js +41 -26
  121. package/src/cli/handlers/run-handler.js +16 -167
  122. package/src/cli/handlers/serve-handler.js +60 -0
  123. package/src/cli/services/bench-stats.js +54 -0
  124. package/src/cli/services/benchmark.js +161 -0
  125. package/src/cli/services/feedback.js +155 -0
  126. package/src/cli/services/rag-service.js +322 -0
  127. package/src/cli/shared/cli-utils.js +24 -7
  128. package/src/cli/shared/config-context.js +21 -0
  129. package/src/cli/wizard/config-builder.js +81 -0
  130. package/src/cli/wizard/init-wizard.js +617 -0
  131. package/src/config/component-factory.js +125 -0
  132. package/src/config/load-config.js +29 -10
  133. package/src/config/load-plugin-config.js +46 -2
  134. package/src/connectors/anthropic-connector.js +93 -55
  135. package/src/connectors/base-connector.js +74 -19
  136. package/src/connectors/cohere-connector.js +88 -32
  137. package/src/connectors/connector-utils.js +302 -0
  138. package/src/connectors/local-embedder.js +43 -5
  139. package/src/connectors/memory-retriever.js +108 -15
  140. package/src/connectors/ollama-connector.js +83 -49
  141. package/src/connectors/openai-connector.js +108 -44
  142. package/src/connectors/rag-prompt.js +88 -0
  143. package/src/core/create-pipeline.js +209 -60
  144. package/src/core/plugin-registry.js +87 -11
  145. package/src/cost/cost-calculator.js +205 -32
  146. package/src/dev/dev-server.js +166 -11
  147. package/src/dev/hot-reload.js +40 -1
  148. package/src/ecosystem/plugin-checks.js +181 -0
  149. package/src/ecosystem/plugin-hub.js +50 -125
  150. package/src/ecosystem/plugin-installer.js +298 -0
  151. package/src/ecosystem/plugin-probe.js +127 -0
  152. package/src/ecosystem/plugin-scanner.js +185 -0
  153. package/src/ecosystem/tar-extract.js +114 -0
  154. package/src/enterprise/audit-logging.js +158 -29
  155. package/src/enterprise/sso-integration.js +715 -228
  156. package/src/evaluate/context-metrics.js +28 -16
  157. package/src/evaluate/evaluator.js +3 -3
  158. package/src/evaluate/faithfulness.js +18 -14
  159. package/src/evaluate/groundedness.js +43 -12
  160. package/src/evaluate/pipeline-evaluator.js +35 -8
  161. package/src/evaluate/scoring.js +251 -3
  162. package/src/experimental.js +71 -0
  163. package/src/guardrails/guardrails-pipeline.js +69 -7
  164. package/src/guardrails/injection-detector.js +283 -0
  165. package/src/guardrails/post-generation-guard.js +19 -0
  166. package/src/guardrails/pre-retrieval-guard.js +36 -36
  167. package/src/guardrails/retrieval-guard.js +58 -8
  168. package/src/index.js +36 -1
  169. package/src/loader/document-reader.js +91 -0
  170. package/src/reranker/cascade-reranker.js +3 -0
  171. package/src/reranker/embedding-reranker.js +136 -21
  172. package/src/reranker/llm-reranker.js +79 -12
  173. package/src/reranker/scoring-reranker.js +3 -0
  174. package/src/retrieval/bm25-search.js +12 -6
  175. package/src/retrieval/file-vector-store.js +212 -0
  176. package/src/retrieval/hybrid-retriever.js +22 -19
  177. package/src/security/jwt-config.js +13 -2
  178. package/src/security/jwt-validator.js +134 -30
  179. package/src/security/plugin-sandbox.js +18 -1
  180. package/src/security/plugin-signature-verifier.js +245 -70
  181. package/src/utils/deprecate.js +69 -0
  182. package/src/utils/embed-query.js +33 -0
  183. package/src/utils/input-sanitizer.js +19 -4
  184. package/src/utils/logger.js +34 -4
  185. package/src/utils/run-abort.js +102 -0
  186. package/src/ai/federated-learning.js +0 -211
  187. package/src/ai/federation.js +0 -71
  188. package/src/ai/index.js +0 -22
  189. package/src/ai/model-trainer.js +0 -217
  190. package/src/ai/model-training.js +0 -202
  191. package/src/ai/multimodal/multi-modal-processor.js +0 -345
  192. package/src/ai/orchestrator.js +0 -65
  193. package/src/ai/retrieval/adaptive-retrieval-engine.js +0 -398
  194. package/src/cli/commands/ai-ml/adaptive-commands.js +0 -178
  195. package/src/cli/commands/ai-ml/federated-commands.js +0 -207
  196. package/src/cli/commands/ai-ml/index.js +0 -17
  197. package/src/cli/commands/ai-ml/multimodal-commands.js +0 -187
  198. package/src/cli/commands/ai-ml/shared.js +0 -51
  199. package/src/cli/commands/ai-ml/training-commands.js +0 -228
  200. package/src/cli/commands/ai-ml.js +0 -386
  201. package/src/cli/commands/docs.js +0 -228
  202. package/src/cli/commands/dx.js +0 -538
  203. package/src/cli/commands/wizard.js +0 -627
  204. package/src/cli/input-sanitization-middleware.js +0 -356
  205. package/src/cli/interactive-wizard.js +0 -373
  206. package/src/cli/templates/development.template.json +0 -64
  207. package/src/cli/templates/minimal.template.json +0 -33
  208. package/src/cli/templates/production.template.json +0 -104
  209. package/src/cli/templates/testing.template.json +0 -45
  210. package/src/cli/wizard/configuration.js +0 -148
  211. package/src/cli/wizard/observability.js +0 -79
  212. package/src/cli/wizard/performance.js +0 -76
  213. package/src/cli/wizard/plugin-selection.js +0 -297
  214. package/src/cli/wizard/preview-save.js +0 -172
  215. package/src/cli/wizard/project-setup.js +0 -66
  216. package/src/core/pipeline-factory.js +0 -59
  217. package/src/dag/enhanced-dag-engine.js +0 -894
  218. package/src/dx/index.js +0 -40
  219. package/src/dx/integration-templates.js +0 -662
  220. package/src/dx/performance-profiler.js +0 -968
  221. package/src/dx/realtime-debugger.js +0 -755
  222. package/src/dx/visual-pipeline-builder.js +0 -578
  223. package/src/ingest.js +0 -59
  224. package/src/pipeline/pipeline.js +0 -18
  225. package/src/query.js +0 -117
@@ -1,218 +1,109 @@
1
1
  {
2
2
  "$schema": "http://json-schema.org/draft-07/schema#",
3
3
  "$id": "https://raw.githubusercontent.com/DevilsDev/rag-pipeline-utils/main/.ragrc.schema.json",
4
- "title": "RAG Pipeline Configuration Schema",
5
- "description": "Configuration schema for @devilsdev/rag-pipeline-utils",
4
+ "title": "rag-pipeline configuration (.ragrc.json)",
5
+ "description": "Configuration read by the rag-pipeline CLI and loadRagConfig() in @devilsdev/rag-pipeline-utils. Each pipeline entry names a built-in component, a custom module under \"plugins\", or a plugin registered on pluginRegistry.",
6
6
  "type": "object",
7
- "required": ["plugins"],
7
+ "required": ["pipeline"],
8
8
  "properties": {
9
- "plugins": {
9
+ "$schema": { "type": "string" },
10
+ "namespace": {
11
+ "type": "string",
12
+ "minLength": 1,
13
+ "default": "default",
14
+ "description": "Logical name for this configuration."
15
+ },
16
+ "metadata": {
10
17
  "type": "object",
11
- "description": "Plugin specifications for RAG pipeline components",
12
- "required": ["loader", "embedder", "retriever", "llm"],
18
+ "description": "Free-form information about the configuration.",
13
19
  "properties": {
14
- "loader": {
15
- "type": "object",
16
- "description": "Document loader plugins",
17
- "minProperties": 1,
18
- "additionalProperties": {
19
- "oneOf": [
20
- { "type": "string" },
21
- {
22
- "type": "object",
23
- "required": ["name"],
24
- "properties": {
25
- "name": { "type": "string" },
26
- "version": { "type": "string" },
27
- "source": {
28
- "type": "string",
29
- "enum": ["registry", "local", "git", "npm"]
30
- },
31
- "path": { "type": "string" },
32
- "config": { "type": "object" },
33
- "enabled": { "type": "boolean" }
34
- }
35
- }
36
- ]
37
- }
38
- },
39
- "embedder": {
40
- "type": "object",
41
- "description": "Text embedding plugins",
42
- "minProperties": 1,
43
- "additionalProperties": {
44
- "oneOf": [
45
- { "type": "string" },
46
- {
47
- "type": "object",
48
- "required": ["name"],
49
- "properties": {
50
- "name": { "type": "string" },
51
- "version": { "type": "string" },
52
- "source": {
53
- "type": "string",
54
- "enum": ["registry", "local", "git", "npm"]
55
- },
56
- "path": { "type": "string" },
57
- "config": { "type": "object" },
58
- "enabled": { "type": "boolean" }
59
- }
60
- }
61
- ]
62
- }
63
- },
64
- "retriever": {
65
- "type": "object",
66
- "description": "Vector retrieval plugins",
67
- "minProperties": 1,
68
- "additionalProperties": {
69
- "oneOf": [
70
- { "type": "string" },
71
- {
72
- "type": "object",
73
- "required": ["name"],
74
- "properties": {
75
- "name": { "type": "string" },
76
- "version": { "type": "string" },
77
- "source": {
78
- "type": "string",
79
- "enum": ["registry", "local", "git", "npm"]
80
- },
81
- "path": { "type": "string" },
82
- "config": { "type": "object" },
83
- "enabled": { "type": "boolean" }
84
- }
85
- }
86
- ]
87
- }
88
- },
89
- "llm": {
90
- "type": "object",
91
- "description": "Language model plugins",
92
- "minProperties": 1,
93
- "additionalProperties": {
94
- "oneOf": [
95
- { "type": "string" },
96
- {
97
- "type": "object",
98
- "required": ["name"],
99
- "properties": {
100
- "name": { "type": "string" },
101
- "version": { "type": "string" },
102
- "source": {
103
- "type": "string",
104
- "enum": ["registry", "local", "git", "npm"]
105
- },
106
- "path": { "type": "string" },
107
- "config": { "type": "object" },
108
- "enabled": { "type": "boolean" }
109
- }
110
- }
111
- ]
112
- }
113
- },
114
- "reranker": {
115
- "type": "object",
116
- "description": "Result reranking plugins (optional)",
117
- "minProperties": 1,
118
- "additionalProperties": {
119
- "oneOf": [
120
- { "type": "string" },
121
- {
122
- "type": "object",
123
- "required": ["name"],
124
- "properties": {
125
- "name": { "type": "string" },
126
- "version": { "type": "string" },
127
- "source": {
128
- "type": "string",
129
- "enum": ["registry", "local", "git", "npm"]
130
- },
131
- "path": { "type": "string" },
132
- "config": { "type": "object" },
133
- "enabled": { "type": "boolean" }
134
- }
135
- }
136
- ]
137
- }
138
- }
139
- },
140
- "additionalProperties": false
20
+ "name": { "type": "string" },
21
+ "version": { "type": "string" },
22
+ "description": { "type": "string" },
23
+ "createdAt": { "type": "string" }
24
+ }
141
25
  },
142
26
  "pipeline": {
27
+ "type": "array",
28
+ "description": "Components in pipeline order. At least an embedder and a retriever are needed for ingest and query.",
29
+ "items": { "$ref": "#/definitions/pipelineEntry" }
30
+ },
31
+ "plugins": {
143
32
  "type": "object",
144
- "description": "Pipeline execution configuration",
145
- "properties": {
146
- "stages": {
147
- "type": "array",
148
- "description": "Pipeline execution stages",
149
- "items": {
150
- "type": "string",
151
- "enum": ["loader", "embedder", "retriever", "llm", "reranker"]
152
- }
153
- },
154
- "mode": {
33
+ "description": "Custom plugin modules by stage and name. Paths are relative to the configuration file; the module exports a class (constructed with the entry's config) or an object.",
34
+ "propertyNames": { "$ref": "#/definitions/stage" },
35
+ "additionalProperties": {
36
+ "type": "object",
37
+ "additionalProperties": {
155
38
  "type": "string",
156
- "description": "Pipeline execution mode",
157
- "enum": ["sequential", "parallel", "dag"],
158
- "default": "sequential"
39
+ "description": "Path to the plugin module, e.g. \"./plugins/my-llm.js\"."
159
40
  }
160
- }
41
+ },
42
+ "examples": [{ "llm": { "my-llm": "./plugins/my-llm.js" } }]
161
43
  },
162
44
  "performance": {
163
45
  "type": "object",
164
- "description": "Performance and optimization settings",
165
- "properties": {
166
- "parallel": {
167
- "type": "object",
168
- "properties": {
169
- "enabled": { "type": "boolean", "default": false },
170
- "maxConcurrency": { "type": "number", "default": 5 },
171
- "batchSize": { "type": "number", "default": 10 }
172
- }
173
- },
174
- "streaming": {
175
- "type": "object",
176
- "properties": {
177
- "enabled": { "type": "boolean", "default": false },
178
- "maxMemoryMB": { "type": "number", "default": 512 },
179
- "bufferSize": { "type": "number", "default": 100 }
180
- }
181
- }
182
- }
46
+ "description": "Optional performance settings, preserved for plugins and tooling."
183
47
  },
184
48
  "observability": {
185
49
  "type": "object",
186
- "description": "Logging and monitoring configuration",
50
+ "description": "Optional logging and metrics settings, preserved for plugins and tooling."
51
+ },
52
+ "cache": { "type": "object" },
53
+ "limits": { "type": "object" },
54
+ "storage": { "type": "object" }
55
+ },
56
+ "definitions": {
57
+ "stage": {
58
+ "type": "string",
59
+ "enum": ["loader", "embedder", "retriever", "reranker", "llm"]
60
+ },
61
+ "pipelineEntry": {
62
+ "type": "object",
63
+ "required": ["stage", "name"],
187
64
  "properties": {
188
- "logging": {
189
- "type": "object",
190
- "properties": {
191
- "level": {
192
- "type": "string",
193
- "enum": ["debug", "info", "warn", "error"],
194
- "default": "info"
195
- },
196
- "structured": { "type": "boolean", "default": true }
197
- }
65
+ "stage": { "$ref": "#/definitions/stage" },
66
+ "name": {
67
+ "type": "string",
68
+ "minLength": 1,
69
+ "description": "Built-in names: loader \"auto\"; embedder \"local\", \"openai\", \"ollama\", \"cohere\"; retriever \"file-store\", \"memory\"; llm \"openai\", \"anthropic\", \"ollama\"; reranker \"scoring\". Any other name must be declared under \"plugins\" or registered on pluginRegistry.",
70
+ "examples": [
71
+ "auto",
72
+ "local",
73
+ "openai",
74
+ "ollama",
75
+ "cohere",
76
+ "file-store",
77
+ "memory",
78
+ "anthropic",
79
+ "scoring"
80
+ ]
198
81
  },
199
- "metrics": {
82
+ "version": { "type": "string" },
83
+ "config": {
200
84
  "type": "object",
201
- "properties": {
202
- "enabled": { "type": "boolean", "default": false },
203
- "exportFormat": {
204
- "type": "string",
205
- "enum": ["prometheus", "json", "statsd"],
206
- "default": "json"
207
- }
208
- }
85
+ "description": "Options passed to the component's constructor, e.g. { \"model\": \"gpt-4o-mini\" } or { \"path\": \".rag/index.json\" } for file-store. Do not put API keys here; use environment variables."
209
86
  }
210
87
  }
211
- },
212
- "namespace": {
213
- "type": "string",
214
- "description": "Configuration namespace for isolation"
215
88
  }
216
89
  },
217
- "additionalProperties": false
90
+ "examples": [
91
+ {
92
+ "namespace": "default",
93
+ "pipeline": [
94
+ { "stage": "loader", "name": "auto" },
95
+ { "stage": "embedder", "name": "local" },
96
+ {
97
+ "stage": "retriever",
98
+ "name": "file-store",
99
+ "config": { "path": ".rag/index.json" }
100
+ },
101
+ {
102
+ "stage": "llm",
103
+ "name": "openai",
104
+ "config": { "model": "gpt-4o-mini" }
105
+ }
106
+ ]
107
+ }
108
+ ]
218
109
  }
package/CHANGELOG.md CHANGED
@@ -9,6 +9,350 @@ Older history (pre-2.4.0) is preserved in the
9
9
  [GitHub releases](https://github.com/DevilsDev/rag-pipeline-utils/releases)
10
10
  page.
11
11
 
12
+ ## [2.5.0] - 2026-10-28
13
+
14
+ ### Added
15
+
16
+ - **Cancellation**: `createRagPipeline` creates an AbortController per run
17
+ and passes its signal to every component (`retriever.retrieve({ signal })`,
18
+ `embedder.embedQuery/embed(text, { signal })`, `reranker.rerank(q, docs,
19
+ { signal })`, `llm.generate(q, docs, { signal })`); a new `options.signal`
20
+ lets callers cancel. All built-in connectors and rerankers honour it.
21
+ `AgenticPipeline` and `IterativeRetriever` propagate it too.
22
+ - `QueryPlanner.plan(query, { llm, signal })`: LLM-proposed sub-queries with
23
+ strict JSON validation and heuristic fallback (returns a Promise);
24
+ `AgenticPipeline` option `enableLlmPlanning` (default `false`).
25
+ - `checkNumericConsistency`, `extractNumbers`, `detectInjection` and
26
+ `PRICING_METADATA` exports.
27
+ - Opt-in `detectInjection` on `RetrievalGuard` to scan retrieved documents for
28
+ indirect prompt injection.
29
+ - `CostCalculator`: pricing provenance (`source`, `asOf`, `verified`), a
30
+ `pricing` override, one-time unknown-model warnings
31
+ (`RAG_UNKNOWN_MODEL_PRICING`), longest-match model resolution.
32
+ - `EmbeddingReranker` `cacheSize` (LRU of document embeddings) and
33
+ `concurrency` options; `MemoryRetriever` `eviction: 'fifo'` option.
34
+ - Plugin signatures: `computeContentDigest()`, a signed `contentDigest` that
35
+ binds plugin code, opt-in `requireContentDigest` and `requireSignedPlugins`,
36
+ and `register()`'s optional `{ content }` argument.
37
+ - `JWTValidator` options `singleUseTokens` (default `true`) and
38
+ `maxTrackedJtis` (default 100000).
39
+ - `AuditLogger` reads its key from `encryptionKey` or
40
+ `RAG_AUDIT_ENCRYPTION_KEY`; `requireEncryption: true` makes a missing key an
41
+ error.
42
+ - `.env.example` for `docker compose`.
43
+ - `npm run test:serial` and `npm run format:check`.
44
+ - **Working CLI workflow**: `rag-pipeline init`, `ingest <path>`, `query
45
+ <question>` and `run` now do real work against a persistent local index.
46
+ `init` writes a pipeline of built-in components (`--template local |
47
+ openai | ollama | anthropic`, or interactive prompts in a terminal).
48
+ - **`FileVectorStore`** (exported): JSON-file vector index with atomic
49
+ writes, embedder/dimension tracking and per-source re-ingestion.
50
+ - **`.ragrc.json` pipeline resolution**: entries `{ stage, name, config }`
51
+ resolve to built-in components, custom plugin modules under `plugins`, or
52
+ plugins registered on `pluginRegistry`.
53
+ - **`rag-pipeline serve`** and a working **`DevServer`**: local HTTP API
54
+ (`GET /health`, `POST /query`) bound to 127.0.0.1, JSON only, 64 KB body
55
+ limit, no CORS.
56
+ - `LocalEmbedder.getState()` / `setState()`.
57
+ - **`rag-pipeline hub install <source>`** installs plugins from a local
58
+ directory, `.tgz`, single `.js` file, `npm:<package>` or a registry
59
+ (sha256-verified). It contains extraction to `.rag/plugins`, runs a static
60
+ security scan (high-risk findings block unless `--allow-risky`), checks the
61
+ stage contract in a separate process, and registers the plugin in
62
+ `.ragrc.json`. `PluginHub.installPlugin()` uses the same installer.
63
+ - **`rag-pipeline hub certify submit|check <path>`** scores a local plugin
64
+ from its files (contract, security scan, tests, documentation) against the
65
+ BASIC/VERIFIED/ENTERPRISE automated thresholds.
66
+ - **`rag-pipeline hub list`** lists plugins registered in the config.
67
+ - **`rag-pipeline init` setup wizard**: chooses the embedder, LLM, retriever and an optional reranker, using only built-ins or custom plugin modules. Connector options are pre-filled with the connector defaults. Each custom plugin is loaded and its stage method checked before it is accepted. The wizard reports which API key environment variables are missing, can run a connection test on request, and previews the JSON before writing.
68
+ - **`rag-pipeline ai`**, built on the configured pipeline and index:
69
+ `ai train embedding [path]` refits the `local` TF-IDF embedder and
70
+ re-embeds the index; `ai benchmark` reports measured p50/p95/mean latency
71
+ per stage; `ai feedback <question> <docId> --rating up|down` stores votes in
72
+ `.rag/feedback.json` and `ai search` applies them as a capped,
73
+ explained score adjustment; `ai multimodal process <path>` reports type,
74
+ characters and chunks for text files (images exit 1: no built-in connector
75
+ accepts image input).
76
+
77
+ ### Deprecated
78
+
79
+ - **Experimental modules moved to `@devilsdev/rag-pipeline-utils/experimental`**:
80
+ `ModelTrainingOrchestrator`, `FederatedLearningCoordinator`,
81
+ `MultiModalProcessor`, `AdaptiveRetrievalEngine`, `SSOManager`,
82
+ `SAMLProvider`, `OAuth2Provider`, `ActiveDirectoryProvider`, `OIDCProvider`,
83
+ `TenantManager`, `ResourceMonitor`, `DataGovernanceManager` /
84
+ `DataGovernance`, `PluginSandbox` and `PluginCertification`. They are
85
+ simulated or incomplete (random metrics, SSO that accepts any code outside
86
+ production and does not verify SAML or OIDC tokens, random quotas, erasure
87
+ that deletes nothing, a non-functional sandbox, fixed certification
88
+ scores); see the Experimental docs page. Their main-entry exports still
89
+ work but emit a one-time `DeprecationWarning` (`RAG_DEP_*` codes) when
90
+ used, are marked `@deprecated` in the types, and will be removed from the
91
+ main entry in the next major release. The same classes are shared by both
92
+ entries, so `instanceof` checks keep working.
93
+
94
+ ### Removed
95
+
96
+ - Unused CLI config templates under `src/cli/templates/` (old format,
97
+ referenced a schema path that did not exist).
98
+ - Ten unreachable duplicate modules under `src/ai/` and the internal
99
+ `src/dag/enhanced-dag-engine.js` (never reachable from the package entries;
100
+ the exported classes are unchanged).
101
+ - semantic-release configuration and dependencies (releases use
102
+ `npm publish --provenance` from the release workflow), duplicate
103
+ `.eslintrc.json` and `.babelrc`, about 50 one-off fix scripts and their
104
+ `ci:*` npm scripts, the tracked `junit.xml`, and 14 test suites that never
105
+ exercised `src/` (fake pipelines, mocks, empty timing loops).
106
+ - CLI placeholders that printed success without doing anything (`ingest`,
107
+ `query`, `doctor`, `validate`, `plugin search|install|publish`) and
108
+ options that had no effect (`--trace`, `--stats`, `--parallel`,
109
+ `--streaming`, `--max-memory`, `--preview`, `--validate`, `--explain`,
110
+ `--abort-timeout`, `--quiet`, `config show --format`).
111
+ - The interactive wizard built on hard-coded mock registry data.
112
+ - The unregistered `src/cli/commands/ai-ml*` command modules: federated
113
+ learning, LLM fine-tuning, `ai train status|deploy`, `ai dashboard`,
114
+ adaptive profiles and multimodal `search`/`describe`. They called methods
115
+ missing from the `src/ai` engines, exited 0 on failure and printed
116
+ hard-coded or simulated numbers. The `src/ai` library modules are unchanged.
117
+ - Unreachable modules that were never exported or registered: `src/dx/`
118
+ (including a realtime debugger exposing an unauthenticated WebSocket),
119
+ `src/cli/commands/{dx,docs}.js`, `src/cli/input-sanitization-middleware.js`,
120
+ `src/cli/plugin-marketplace-commands.js`, `src/query.js`, `src/ingest.js`,
121
+ `src/pipeline/pipeline.js`, `src/core/pipeline-factory.js`. The package
122
+ `exports` map only exposes `.` and `./cli`, so these were never public.
123
+
124
+ ### Fixed
125
+
126
+ - **`evaluateRagDataset`** scores the generated answer; it scored the
127
+ retrieved documents, so every case failed with zero scores.
128
+ - **`RetrievalGuard`** with `enforceACL` also reads a top-level `acl` /
129
+ `requiredRole` on results that have `metadata` (it read only `metadata`
130
+ then).
131
+ - **`createRagPipeline`**: timeouts now cancel work and no stage starts after
132
+ an abort (a timeout still resolves `{ success: false, error: 'Execution
133
+ timeout' }`; a caller abort resolves `'Execution aborted'`). Without an llm
134
+ it runs retrieval only and returns `answer: null` instead of `'ok'`. Stream
135
+ mode with `citations` or `evaluate` ends with one `{ token: '', done: true,
136
+ citations, evaluation }` chunk. The artificial 5 ms delay is removed.
137
+ - **Connectors** retry only transient failures (network, 408/409/425/429/5xx)
138
+ with exponential backoff, jitter and `Retry-After`; SDK-internal retries are
139
+ disabled. API keys are read at construction, and calls without a key fail
140
+ fast with `MISSING_API_KEY`.
141
+ - **`MemoryRetriever`** enforces `maxDocuments` and rejects mismatched vector
142
+ dimensions instead of truncating them.
143
+ - **`AuditLogger`** no longer encrypts with a random per-process key that made
144
+ logs unreadable after a restart; legacy `createCipher` records decrypt on
145
+ Node 22+.
146
+ - **`JWTValidator` / `jwt-config`** honour an explicit `clockTolerance` /
147
+ `notBeforeTolerance` of 0 (it became 30); the expired-token test is enabled.
148
+ - **`loadPluginsFromJson`** awaits registration and verifies signed manifests
149
+ and plugin files before importing them.
150
+ - **`rag-pipeline init`**: the connection test aborts its calls after the 15 s
151
+ timeout and the CLI exits afterwards.
152
+ - **Benchmarks** accept `--iterations=N`, no longer abort on the retry
153
+ benchmarks' deliberate warm-up failures, and exit when done.
154
+ - **Docs generation** no longer hangs: the JSDoc regex backtracked
155
+ exponentially on an unterminated `/**`.
156
+ - **Tests** run in parallel again (a suite destroyed the Jest worker's own
157
+ stdio streams), no longer rewrite tracked fixtures, and coverage works on
158
+ Windows (the test setup no longer patches `path.resolve`).
159
+ - **Package import**: `require()` / `import` of 2.4.5 failed in every clean
160
+ install with `Cannot find module 'isolated-vm'`. `isolated-vm` is now
161
+ loaded only when `PluginSandbox` runs and is an optional peer dependency;
162
+ `pino-pretty` is an optional peer as well. Added the missing `ajv-formats`
163
+ and `marked` dependencies, pinned `chalk` to 4.x (5.x is ESM-only), removed
164
+ unused `dotenv`. Importing the bundle no longer prints "Missing Contract"
165
+ warnings. A tarball smoke test (`npm run smoke:pack`) now runs in CI and
166
+ before publish.
167
+ - **`createRagPipeline`**: the `embedder` result was computed and discarded,
168
+ so vector retrievers never received a `queryVector`. Plugins registered on
169
+ the exported `pluginRegistry` are now resolvable by name, and the timeout
170
+ timer is cleared when a run finishes.
171
+ - **`MemoryRetriever`** throws a clear error when no `queryVector` is given
172
+ instead of crashing inside cosine similarity.
173
+ - **README / docs quick start** now passes an `embedder`; as previously
174
+ written it could not retrieve anything from `MemoryRetriever`.
175
+ - **Citations** with zero retrieved documents no longer fail the run; every
176
+ sentence is reported as unsupported.
177
+ - **`HybridRetriever`** passes the full request (including `queryVector`) to
178
+ `retrieve()`, so vector results are no longer silently dropped, and throws
179
+ when every retriever fails.
180
+ - **Guardrails**: the retrieval guard (ACL, relevance, freshness) now runs
181
+ before generation via the new `options.filterResults` hook; removed
182
+ documents are reported by id only; strict-mode blocks no longer return the
183
+ raw answer; PII is redacted in citations and evaluation details too.
184
+ - **`AuditLogger`**: tenant/user/action filters never matched, so queries and
185
+ compliance reports returned every tenant's records. Encryption now uses
186
+ `createCipheriv` with a random IV per field (it threw on Node 22 and reused
187
+ the nonce on Node 18/20). The integrity hash now covers action and tenant.
188
+ - **`InputSanitizer`**: a regex state bug let command-injection payloads
189
+ through after a previously blocked input.
190
+ - **`LLMReranker`** sends an actual ranking prompt instead of the raw
191
+ question, keeps documents the LLM omits, and honours `topK`.
192
+ - **Agentic RAG**: with an `embedder`, each sub-query and refined query is
193
+ embedded on its own instead of reusing the original query vector.
194
+ - **TypeScript**: 52 runtime exports (citations, guardrails, hybrid
195
+ retrieval, agentic RAG, connectors, rerankers, GraphRAG, ...) had no
196
+ declarations. They are now generated from JSDoc at build time into
197
+ `dist/types/` and re-exported from `dist/index.d.ts`; the build fails if
198
+ any export is undeclared, and the smoke test compiles a TypeScript consumer.
199
+ - **`doctor` / `validate`** report real findings (unknown components,
200
+ missing stages, missing API keys, broken custom plugins) and exit 1 on
201
+ errors. `doctor --auto-fix` no longer lets callers re-enable a shell, no
202
+ longer strips Windows path separators, and runs npm on Windows.
203
+ - **`hub`** (alias `plugin`) commands are registered. There is no default
204
+ registry (the old default host does not exist): pass `--registry <url>` or
205
+ set `RAG_PLUGIN_REGISTRY` for registry operations.
206
+ - **Hot reload** ignore patterns work again (chokidar 4 dropped glob support)
207
+ and only JavaScript changes trigger a reload.
208
+ - `loadRagConfig()` accepts a config file path as well as a directory and no
209
+ longer logs to stdout.
210
+ - `LocalEmbedder` produced all-zero vectors for corpora of two or fewer
211
+ documents (IDF is now smoothed).
212
+ - **Logger**: console-style calls such as `logger.error("Failed:", msg)` no
213
+ longer log the message as one key per character.
214
+
215
+ ### Changed
216
+
217
+ - **Documentation**: the README is rewritten with use cases whose code runs
218
+ in CI (`__tests__/docs/readme-examples.test.js` executes every README
219
+ example), and `.ragrc.json`'s JSON schema (`.ragrc.schema.json`, shipped in
220
+ the package) now describes the `pipeline` + `plugins` format the CLI and
221
+ `loadRagConfig()` actually use.
222
+ - **Metric changes**:
223
+ - Context recall now measures how much of a reference (ground-truth) answer
224
+ the retrieved documents support. Pass it via
225
+ `PipelineEvaluator.evaluate(result, { referenceAnswer })` or
226
+ `run({ options: { evaluate: true, referenceAnswer } })`. Without one,
227
+ `scores.contextRecall` is omitted, `details.contextRecall` is
228
+ `{ score: null, skipped: true, reason }`, and `metadata.metricsSkipped`
229
+ lists it.
230
+ - `computeGroundedness` is a weighted mean over the available components;
231
+ without a reference it is `(0.4 * faithfulness + 0.3 * contextPrecision)
232
+ / 0.7`.
233
+ - Claim support checks numbers: a sentence whose numbers (digits, decimals,
234
+ percentages, number words) are not in the source scores below 0.4 and is
235
+ not grounded. This affects citations, faithfulness, recall,
236
+ `PostGenerationGuard` and `SelfCritiqueChecker`. "20" equals "twenty".
237
+ - **`createRagPipeline`** results always include `answer` when an llm is
238
+ configured.
239
+ - **`QueryPlanner`** splits only at clause or question boundaries, keeps
240
+ "salt and pepper"-style phrases intact, and expands comparisons into one
241
+ sub-query per entity plus the comparison; results carry `source`.
242
+ - **Prompts**: built-in connectors put retrieved context in the user message
243
+ as delimited, untrusted reference data, with a system prompt telling the
244
+ model to treat it as data. Answers may differ.
245
+ - **`PreRetrievalGuard`** returns the query unchanged (no partial deletion) and
246
+ reports detections in `injection`; strict mode still blocks. Detection
247
+ normalises input first. To cut false positives, bare "act as", "jailbreak",
248
+ uppercase "DAN", mid-line "system:" and "you are now ready" are no longer
249
+ flagged; chat role markers, prompt-exfiltration phrasing and normalisation
250
+ bypasses now are.
251
+ - **`CostCalculator`** prices `gpt-4o-mini-*` and `claude-3-5-sonnet-*`
252
+ correctly (previously gpt-4 pricing and $0); `customPricing` entries without
253
+ `unit` default to per-1000 tokens. Built-in prices are marked unverified:
254
+ their `asOf` is when they were added, not when they were checked.
255
+ - **`EmbeddingReranker`** limits concurrency to 4 by default; call
256
+ `clearCache()` after retraining an embedder.
257
+ - **`AuditLogger`** with encryption enabled and no key now disables
258
+ encryption with a warning instead of using a throwaway key.
259
+ - **Plugin trust store** is empty by default (the placeholder key is gone).
260
+ - **`docker compose`** requires `POSTGRES_PASSWORD`, `REDIS_PASSWORD` and
261
+ `GRAFANA_ADMIN_PASSWORD`, publishes ports on 127.0.0.1 only, and drops the
262
+ debugger port and the Prometheus lifecycle API; the image build fails on
263
+ critical runtime vulnerabilities.
264
+ - **CI**: one `ci.yml` workflow (required checks `Test & Lint (18|20|22)`)
265
+ that also enforces `format:check` and the tarball smoke test, and runs for
266
+ pull requests into any branch. `npm test` runs Jest in parallel.
267
+ - **`DevServer`** now really listens: `start()` binds port 3000 by default
268
+ (pass `port: 0` for a free port), so existing callers may see
269
+ `EADDRINUSE`. Default host is `127.0.0.1` (was `localhost`), default
270
+ `watchPaths` is `[]` (was `./src/plugins`, `./src/mocks`), and requests
271
+ must use a loopback `Host` header while bound to loopback.
272
+ - **`loadRagConfig()`** error messages now include details
273
+ (`Config validation failed: ...`, `Invalid JSON in config file <path>: ...`)
274
+ and it no longer logs.
275
+ - **`rag-pipeline plugin` / `hub`** registry operations require
276
+ `--registry <url>` or `RAG_PLUGIN_REGISTRY`. `hub certify submit` takes a
277
+ local plugin path and reports computed scores; it previously issued
278
+ certificates from fixed placeholder scores. `PluginHub.installPlugin()` now
279
+ installs into `<project>/.rag/plugins` and registers the plugin in the
280
+ config (it previously only wrote `metadata.json` to `localCacheDir`), and
281
+ `getInstalledPlugins()` reads the config.
282
+ - **`FileVectorStore`** index files store mostly-zero vectors sparsely and
283
+ round values to 7 significant digits (about 10x smaller for the `local`
284
+ embedder).
285
+
286
+ - **Grounding scores** (citations, faithfulness, context precision/recall,
287
+ groundedness, `PostGenerationGuard`, `SelfCritiqueChecker`) now measure the
288
+ share of a sentence's content words found in a document, optionally
289
+ IDF-weighted. They previously used Jaccard similarity against the whole
290
+ document, which shrinks with document length: an answer copied verbatim
291
+ from a ~70-word chunk scored 0. Scores will be noticeably higher for
292
+ grounded answers.
293
+ - Default per-sentence similarity threshold raised from 0.3 to 0.5
294
+ (`CitationTracker.similarityThreshold`, `PipelineEvaluator.threshold`,
295
+ faithfulness/recall/hallucination-detector `threshold`). Aggregate
296
+ thresholds (`groundednessThreshold`, `approvalThreshold`) are unchanged.
297
+ - The tokenizer keeps non-ASCII letters (`Política` no longer becomes
298
+ `poltica`) and splits on newlines and hyphens instead of gluing words
299
+ together. This also affects BM25, BLEU/ROUGE and the scoring reranker.
300
+ - `RetrievalGuard` with `enforceACL` now fails closed when
301
+ `context.userPermissions` is missing.
302
+ - `CitationTracker.track()` non-array error message is now
303
+ "retrievedDocs must be an array".
304
+
305
+ ### Security
306
+
307
+ - Production dependencies: `npm audit --omit=dev` reports no high or critical
308
+ findings (axios ^1.21.0; overrides for fast-uri, follow-redirects,
309
+ form-data, ws and zod).
310
+ - Experimental SSO: the development bypass that accepted any authorization
311
+ code requires `devBypass: true` and a non-production `NODE_ENV` and is
312
+ refused in production; OIDC id_tokens are validated (JWKS signature, iss,
313
+ aud, exp, nonce); OAuth2/OIDC use PKCE (S256); `redirect_uri` comes only
314
+ from configuration; callbacks must match the stored login request's
315
+ provider.
316
+ - Plugin signatures: Ed25519 verification works (`crypto.verify` with
317
+ KeyObjects); a signed `contentDigest` binds plugin code and is always
318
+ enforced when present.
319
+ - `AuditLogger` compares HMAC signatures in constant time; `JWTValidator`'s
320
+ replay store is bounded and expires entries.
321
+ - Retrieved documents are no longer placed in the LLM system role; prompt
322
+ injection detection normalises homoglyphs, leetspeak and zero-width
323
+ characters.
324
+ - `.secrets` is no longer tracked in git (rotate anything it held) and is
325
+ excluded from Docker builds.
326
+
327
+ ### Known limitations
328
+
329
+ - Grounding is lexical plus a numeric-consistency check. Not checked:
330
+ negation ("not twenty days"), units ("20 hours" vs "20 days"), ordinals, a
331
+ lone "one", differently split decimals, and claims that combine facts from
332
+ several documents. Document-side matching is lenient ("twenty-five" in a
333
+ source also supports "twenty" or "five").
334
+ - The `openai` SDK stays on 4.x: newer majors need Node 20+ and will come with
335
+ 3.0. `csv-parse` has one moderate advisory whose fix is a major release.
336
+ - Experimental SSO cannot refresh OIDC sessions, and `SAMLProvider` refuses
337
+ to authenticate.
338
+ - `AuditLogger`'s HMAC signing key is random per process unless `signingKey`
339
+ is passed, so `verifyIntegrity` flags records written before a restart.
340
+
341
+ ## [2.4.5] - 2026-04-19
342
+
343
+ ### Changed
344
+
345
+ - **Supply chain**: first release published via GitHub Actions OIDC trusted
346
+ publishing with `--provenance` attached. Tarball now ships with a SLSA
347
+ build provenance attestation signed via Sigstore; consumers can verify
348
+ the git-commit → tarball-bytes chain with `npm audit signatures`. No
349
+ long-lived `NPM_TOKEN` involved.
350
+ - Publish workflow (`.github/workflows/release.yml`): switched from
351
+ `NODE_AUTH_TOKEN` to OIDC, upgraded npm CLI to 11.5.1+ at job start,
352
+ added `--provenance` and `--ignore-scripts` to the publish step.
353
+
354
+ No API, behavior, or documented-surface changes from 2.4.4.
355
+
12
356
  ## [2.4.4] - 2026-04-16
13
357
 
14
358
  ### Added
@@ -124,6 +468,7 @@ First public release on the 2.4 line, introducing the v2.4 feature set.
124
468
  For release notes prior to v2.4.0, see
125
469
  [github.com/DevilsDev/rag-pipeline-utils/releases](https://github.com/DevilsDev/rag-pipeline-utils/releases).
126
470
 
471
+ [2.4.5]: https://github.com/DevilsDev/rag-pipeline-utils/releases/tag/v2.4.5
127
472
  [2.4.4]: https://github.com/DevilsDev/rag-pipeline-utils/releases/tag/v2.4.4
128
473
  [2.4.3]: https://github.com/DevilsDev/rag-pipeline-utils/releases/tag/v2.4.3
129
474
  [2.4.2]: https://github.com/DevilsDev/rag-pipeline-utils/releases/tag/v2.4.2