@devilsdev/rag-pipeline-utils 2.4.5 → 2.6.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 (258) hide show
  1. package/.ragrc.schema.json +83 -192
  2. package/CHANGELOG.md +431 -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 +6442 -1355
  9. package/dist/index.d.ts +129 -2
  10. package/dist/index.mjs +1 -1
  11. package/dist/testing.cjs +2 -0
  12. package/dist/testing.d.ts +1 -0
  13. package/dist/testing.mjs +5 -0
  14. package/dist/types/adapters/ai-sdk.d.ts +53 -0
  15. package/dist/types/agentic/agentic-pipeline.d.ts +103 -0
  16. package/dist/types/agentic/iterative-retriever.d.ts +85 -0
  17. package/dist/types/agentic/query-planner.d.ts +145 -0
  18. package/dist/types/agentic/self-critique.d.ts +45 -0
  19. package/dist/types/ai/adaptive-retrieval.d.ts +44 -0
  20. package/dist/types/ai/federation/federated-learning-coordinator.d.ts +62 -0
  21. package/dist/types/ai/multimodal-processing.d.ts +32 -0
  22. package/dist/types/ai/multimodal.d.ts +39 -0
  23. package/dist/types/ai/retrieval-engine.d.ts +37 -0
  24. package/dist/types/ai/training/model-training-orchestrator.d.ts +31 -0
  25. package/dist/types/cache/component-keys.d.ts +7 -0
  26. package/dist/types/cache/memory-cache.d.ts +54 -0
  27. package/dist/types/cache/pipeline-cache.d.ts +66 -0
  28. package/dist/types/cache/redis-cache.d.ts +46 -0
  29. package/dist/types/chunking/chunking-engine.d.ts +70 -0
  30. package/dist/types/chunking/strategies/fixed-size.d.ts +17 -0
  31. package/dist/types/chunking/strategies/recursive.d.ts +20 -0
  32. package/dist/types/chunking/strategies/semantic.d.ts +19 -0
  33. package/dist/types/chunking/strategies/sentence.d.ts +13 -0
  34. package/dist/types/chunking/strategies/structure-aware.d.ts +19 -0
  35. package/dist/types/citation/citation-tracker.d.ts +64 -0
  36. package/dist/types/citation/hallucination-detector.d.ts +40 -0
  37. package/dist/types/citation/source-mapper.d.ts +37 -0
  38. package/dist/types/connectors/anthropic-connector.d.ts +97 -0
  39. package/dist/types/connectors/base-connector.d.ts +87 -0
  40. package/dist/types/connectors/cohere-connector.d.ts +94 -0
  41. package/dist/types/connectors/connector-utils.d.ts +110 -0
  42. package/dist/types/connectors/local-embedder.d.ts +95 -0
  43. package/dist/types/connectors/memory-retriever.d.ts +99 -0
  44. package/dist/types/connectors/ollama-connector.d.ts +115 -0
  45. package/dist/types/connectors/openai-connector.d.ts +129 -0
  46. package/dist/types/connectors/rag-prompt.d.ts +40 -0
  47. package/dist/types/core/create-pipeline.d.ts +8 -0
  48. package/dist/types/core/plugin-registry.d.ts +136 -0
  49. package/dist/types/core/stage-contracts.d.ts +36 -0
  50. package/dist/types/core/validate-plugin.d.ts +45 -0
  51. package/dist/types/cost/cost-calculator.d.ts +152 -0
  52. package/dist/types/cost/cost-tracker.d.ts +126 -0
  53. package/dist/types/cost/token-budget.d.ts +110 -0
  54. package/dist/types/dag/core/error-context.d.ts +239 -0
  55. package/dist/types/dag/core/execution-scheduler.d.ts +191 -0
  56. package/dist/types/dag/core/topology-validation.d.ts +226 -0
  57. package/dist/types/dag/dag-engine.d.ts +156 -0
  58. package/dist/types/dag/dag-node.d.ts +37 -0
  59. package/dist/types/dashboard/dashboard-generator.d.ts +127 -0
  60. package/dist/types/dashboard/metrics-aggregator.d.ts +218 -0
  61. package/dist/types/debug/execution-tracer.d.ts +57 -0
  62. package/dist/types/debug/trace-inspector.d.ts +31 -0
  63. package/dist/types/ecosystem/plugin-certification.d.ts +169 -0
  64. package/dist/types/enterprise/data-governance.d.ts +203 -0
  65. package/dist/types/enterprise/multi-tenancy.d.ts +137 -0
  66. package/dist/types/enterprise/sso-integration.d.ts +420 -0
  67. package/dist/types/evaluate/context-metrics.d.ts +55 -0
  68. package/dist/types/evaluate/faithfulness.d.ts +41 -0
  69. package/dist/types/evaluate/groundedness.d.ts +60 -0
  70. package/dist/types/evaluate/pipeline-evaluator.d.ts +88 -0
  71. package/dist/types/evaluate/relevance.d.ts +21 -0
  72. package/dist/types/evaluate/scoring.d.ts +123 -0
  73. package/dist/types/evaluate/semantic-similarity.d.ts +14 -0
  74. package/dist/types/experimental.d.ts +15 -0
  75. package/dist/types/graph/entity-extractor.d.ts +84 -0
  76. package/dist/types/graph/graph-index.d.ts +49 -0
  77. package/dist/types/graph/graph-retriever.d.ts +81 -0
  78. package/dist/types/graph/knowledge-graph.d.ts +129 -0
  79. package/dist/types/grounding/check-answer.d.ts +101 -0
  80. package/dist/types/guardrails/guardrails-pipeline.d.ts +63 -0
  81. package/dist/types/guardrails/injection-detector.d.ts +47 -0
  82. package/dist/types/guardrails/post-generation-guard.d.ts +61 -0
  83. package/dist/types/guardrails/pre-retrieval-guard.d.ts +64 -0
  84. package/dist/types/guardrails/retrieval-guard.d.ts +57 -0
  85. package/dist/types/mcp/mcp-server.d.ts +85 -0
  86. package/dist/types/mcp/mcp-tool-builder.d.ts +55 -0
  87. package/dist/types/reranker/cascade-reranker.d.ts +40 -0
  88. package/dist/types/reranker/embedding-reranker.d.ts +77 -0
  89. package/dist/types/reranker/scoring-reranker.d.ts +41 -0
  90. package/dist/types/retrieval/bm25-search.d.ts +43 -0
  91. package/dist/types/retrieval/file-vector-store.d.ts +99 -0
  92. package/dist/types/retrieval/hybrid-retriever.d.ts +35 -0
  93. package/dist/types/retrieval/rank-fusion.d.ts +10 -0
  94. package/dist/types/security/jwt-config.d.ts +80 -0
  95. package/dist/types/security/jwt-validator.d.ts +195 -0
  96. package/dist/types/security/plugin-sandbox.d.ts +158 -0
  97. package/dist/types/security/plugin-signature-verifier.d.ts +139 -0
  98. package/dist/types/security/validator.d.ts +5 -0
  99. package/dist/types/streaming/embedding-stream.d.ts +65 -0
  100. package/dist/types/streaming/sse-adapter.d.ts +59 -0
  101. package/dist/types/streaming/stream-router.d.ts +88 -0
  102. package/dist/types/streaming/streaming-embedder.d.ts +99 -0
  103. package/dist/types/streaming/websocket-adapter.d.ts +71 -0
  104. package/dist/types/templates/scaffold.d.ts +55 -0
  105. package/dist/types/templates/template-registry.d.ts +63 -0
  106. package/dist/types/testing.d.ts +168 -0
  107. package/dist/types/utils/embed-query.d.ts +20 -0
  108. package/dist/types/utils/logger.d.ts +50 -0
  109. package/dist/types/utils/rate-limiter.d.ts +66 -0
  110. package/dist/types/utils/retry.d.ts +27 -0
  111. package/dist/types/utils/run-abort.d.ts +34 -0
  112. package/dist/types/utils/secure-logging.d.ts +51 -0
  113. package/dist/types/utils/structured-logger.d.ts +126 -0
  114. package/package.json +72 -33
  115. package/src/adapters/ai-sdk.js +215 -0
  116. package/src/agentic/agentic-pipeline.js +75 -7
  117. package/src/agentic/iterative-retriever.js +47 -10
  118. package/src/agentic/query-planner.js +329 -78
  119. package/src/cache/component-keys.js +38 -0
  120. package/src/cache/memory-cache.js +87 -0
  121. package/src/cache/pipeline-cache.js +260 -0
  122. package/src/cache/redis-cache.js +83 -0
  123. package/src/citation/citation-tracker.js +6 -4
  124. package/src/citation/hallucination-detector.js +2 -2
  125. package/src/citation/source-mapper.js +15 -28
  126. package/src/cli/commands/ai.js +106 -0
  127. package/src/cli/commands/plugin-hub/event-handlers.js +6 -0
  128. package/src/cli/commands/plugin-hub/hub-commands.js +0 -74
  129. package/src/cli/commands/plugin-hub/local-commands.js +143 -0
  130. package/src/cli/commands/plugin-hub.js +114 -49
  131. package/src/cli/diagnostics/config-checker.js +76 -63
  132. package/src/cli/diagnostics/environment-checker.js +62 -31
  133. package/src/cli/diagnostics/plugin-checker.js +36 -89
  134. package/src/cli/doctor-command.js +39 -5
  135. package/src/cli/enhanced-cli-commands.js +104 -233
  136. package/src/cli/handlers/ai-handler.js +364 -0
  137. package/src/cli/handlers/diagnostics-handler.js +78 -31
  138. package/src/cli/handlers/ingest-handler.js +28 -22
  139. package/src/cli/handlers/init-handler.js +148 -25
  140. package/src/cli/handlers/query-handler.js +203 -25
  141. package/src/cli/handlers/run-handler.js +16 -167
  142. package/src/cli/handlers/serve-handler.js +60 -0
  143. package/src/cli/services/bench-stats.js +54 -0
  144. package/src/cli/services/benchmark.js +161 -0
  145. package/src/cli/services/feedback.js +155 -0
  146. package/src/cli/services/instrument.js +83 -0
  147. package/src/cli/services/rag-service.js +361 -0
  148. package/src/cli/shared/cli-utils.js +24 -7
  149. package/src/cli/shared/config-context.js +21 -0
  150. package/src/cli/wizard/config-builder.js +81 -0
  151. package/src/cli/wizard/init-wizard.js +602 -0
  152. package/src/config/component-factory.js +125 -0
  153. package/src/config/enhanced-ragrc-schema.js +0 -2
  154. package/src/config/load-config.js +29 -10
  155. package/src/config/load-plugin-config.js +46 -2
  156. package/src/config/validate-schema.js +4 -1
  157. package/src/connectors/anthropic-connector.js +115 -57
  158. package/src/connectors/base-connector.js +74 -19
  159. package/src/connectors/cohere-connector.js +108 -34
  160. package/src/connectors/connector-utils.js +302 -0
  161. package/src/connectors/local-embedder.js +63 -5
  162. package/src/connectors/memory-retriever.js +125 -14
  163. package/src/connectors/ollama-connector.js +112 -51
  164. package/src/connectors/openai-connector.js +153 -44
  165. package/src/connectors/rag-prompt.js +88 -0
  166. package/src/core/create-pipeline.js +307 -61
  167. package/src/core/performance/parallel-processor.js +62 -1
  168. package/src/core/plugin-registry.js +125 -26
  169. package/src/core/stage-contracts.js +36 -0
  170. package/src/core/validate-plugin.js +85 -0
  171. package/src/cost/cost-calculator.js +205 -32
  172. package/src/debug/execution-tracer.js +14 -4
  173. package/src/dev/dev-server.js +173 -11
  174. package/src/dev/hot-reload.js +44 -4
  175. package/src/ecosystem/plugin-checks.js +181 -0
  176. package/src/ecosystem/plugin-hub.js +50 -125
  177. package/src/ecosystem/plugin-installer.js +298 -0
  178. package/src/ecosystem/plugin-probe.js +127 -0
  179. package/src/ecosystem/plugin-scanner.js +185 -0
  180. package/src/ecosystem/tar-extract.js +114 -0
  181. package/src/enterprise/audit-logging.js +158 -29
  182. package/src/enterprise/sso-integration.js +716 -228
  183. package/src/evaluate/context-metrics.js +28 -16
  184. package/src/evaluate/evaluator.js +3 -3
  185. package/src/evaluate/faithfulness.js +18 -14
  186. package/src/evaluate/groundedness.js +43 -12
  187. package/src/evaluate/pipeline-evaluator.js +35 -8
  188. package/src/evaluate/scoring.js +251 -3
  189. package/src/evaluate/semantic-similarity.js +79 -0
  190. package/src/experimental.js +71 -0
  191. package/src/grounding/check-answer.js +173 -0
  192. package/src/guardrails/guardrails-pipeline.js +69 -7
  193. package/src/guardrails/injection-detector.js +283 -0
  194. package/src/guardrails/post-generation-guard.js +19 -0
  195. package/src/guardrails/pre-retrieval-guard.js +36 -36
  196. package/src/guardrails/retrieval-guard.js +58 -8
  197. package/src/index.js +58 -1
  198. package/src/loader/csv-loader.js +3 -2
  199. package/src/loader/document-reader.js +91 -0
  200. package/src/loader/html-loader.js +3 -1
  201. package/src/loader/markdown-loader.js +3 -2
  202. package/src/reranker/cascade-reranker.js +3 -0
  203. package/src/reranker/embedding-reranker.js +136 -21
  204. package/src/reranker/llm-reranker.js +79 -12
  205. package/src/reranker/scoring-reranker.js +3 -0
  206. package/src/retrieval/bm25-search.js +12 -6
  207. package/src/retrieval/file-vector-store.js +241 -0
  208. package/src/retrieval/hybrid-retriever.js +22 -19
  209. package/src/security/jwt-config.js +13 -2
  210. package/src/security/jwt-validator.js +139 -34
  211. package/src/security/plugin-sandbox.js +18 -1
  212. package/src/security/plugin-signature-verifier.js +245 -70
  213. package/src/testing.js +254 -0
  214. package/src/utils/deprecate.js +69 -0
  215. package/src/utils/embed-query.js +33 -0
  216. package/src/utils/input-sanitizer.js +19 -4
  217. package/src/utils/logger.js +34 -4
  218. package/src/utils/run-abort.js +102 -0
  219. package/src/ai/federated-learning.js +0 -211
  220. package/src/ai/federation.js +0 -71
  221. package/src/ai/index.js +0 -22
  222. package/src/ai/model-trainer.js +0 -217
  223. package/src/ai/model-training.js +0 -202
  224. package/src/ai/multimodal/multi-modal-processor.js +0 -345
  225. package/src/ai/orchestrator.js +0 -65
  226. package/src/ai/retrieval/adaptive-retrieval-engine.js +0 -398
  227. package/src/cli/commands/ai-ml/adaptive-commands.js +0 -178
  228. package/src/cli/commands/ai-ml/federated-commands.js +0 -207
  229. package/src/cli/commands/ai-ml/index.js +0 -17
  230. package/src/cli/commands/ai-ml/multimodal-commands.js +0 -187
  231. package/src/cli/commands/ai-ml/shared.js +0 -51
  232. package/src/cli/commands/ai-ml/training-commands.js +0 -228
  233. package/src/cli/commands/ai-ml.js +0 -386
  234. package/src/cli/commands/docs.js +0 -228
  235. package/src/cli/commands/dx.js +0 -538
  236. package/src/cli/commands/wizard.js +0 -627
  237. package/src/cli/input-sanitization-middleware.js +0 -356
  238. package/src/cli/interactive-wizard.js +0 -373
  239. package/src/cli/templates/development.template.json +0 -64
  240. package/src/cli/templates/minimal.template.json +0 -33
  241. package/src/cli/templates/production.template.json +0 -104
  242. package/src/cli/templates/testing.template.json +0 -45
  243. package/src/cli/wizard/configuration.js +0 -148
  244. package/src/cli/wizard/observability.js +0 -79
  245. package/src/cli/wizard/performance.js +0 -76
  246. package/src/cli/wizard/plugin-selection.js +0 -297
  247. package/src/cli/wizard/preview-save.js +0 -172
  248. package/src/cli/wizard/project-setup.js +0 -66
  249. package/src/core/pipeline-factory.js +0 -59
  250. package/src/dag/enhanced-dag-engine.js +0 -894
  251. package/src/dx/index.js +0 -40
  252. package/src/dx/integration-templates.js +0 -662
  253. package/src/dx/performance-profiler.js +0 -968
  254. package/src/dx/realtime-debugger.js +0 -755
  255. package/src/dx/visual-pipeline-builder.js +0 -578
  256. package/src/ingest.js +0 -59
  257. package/src/pipeline/pipeline.js +0 -18
  258. package/src/query.js +0 -117
@@ -0,0 +1,66 @@
1
+ export = RateLimiter;
2
+ declare class RateLimiter {
3
+ /**
4
+ * Create a rate limiter instance
5
+ * @param {Object} options - Configuration options
6
+ * @param {number} options.maxAttempts - Maximum attempts allowed (default: 5)
7
+ * @param {number} options.windowMs - Time window in milliseconds (default: 15 minutes)
8
+ * @param {number} options.blockDurationMs - How long to block after exceeding limit (default: 1 hour)
9
+ * @param {number} options.cleanupIntervalMs - How often to cleanup expired entries (default: 5 minutes)
10
+ */
11
+ constructor(options?: {
12
+ maxAttempts: number;
13
+ windowMs: number;
14
+ blockDurationMs: number;
15
+ cleanupIntervalMs: number;
16
+ });
17
+ maxAttempts: number;
18
+ windowMs: number;
19
+ blockDurationMs: number;
20
+ cleanupIntervalMs: number;
21
+ store: Map<any, any>;
22
+ /**
23
+ * Check if a request should be allowed
24
+ * @param {string} identifier - Unique identifier (IP, userId, tenantId, etc.)
25
+ * @returns {Object} { allowed: boolean, remaining: number, resetAt: Date, blockedUntil: Date|null }
26
+ */
27
+ allowRequest(identifier: string): any;
28
+ /**
29
+ * Manually reset rate limit for an identifier
30
+ * @param {string} identifier - Identifier to reset
31
+ */
32
+ reset(identifier: string): void;
33
+ /**
34
+ * Get current status for an identifier
35
+ * @param {string} identifier - Identifier to check
36
+ * @returns {Object} Current rate limit status
37
+ */
38
+ getStatus(identifier: string): any;
39
+ /**
40
+ * Clean up expired entries
41
+ */
42
+ cleanup(): {
43
+ cleaned: number;
44
+ remaining: number;
45
+ };
46
+ /**
47
+ * Get statistics about rate limiter usage
48
+ * @returns {Object} Statistics
49
+ */
50
+ getStats(): any;
51
+ /**
52
+ * Stop the rate limiter and cleanup
53
+ */
54
+ destroy(): void;
55
+ _cleanupInterval: NodeJS.Timeout;
56
+ /**
57
+ * Hash identifier for storage (privacy)
58
+ * @private
59
+ */
60
+ private _hashIdentifier;
61
+ /**
62
+ * Start automatic cleanup timer
63
+ * @private
64
+ */
65
+ private _startCleanup;
66
+ }
@@ -0,0 +1,27 @@
1
+ /**
2
+ * Retry a function with exponential backoff.
3
+ *
4
+ * @param {Function} fn - async or sync function to call; receives (attempt)
5
+ * @param {Object} [opts]
6
+ * @param {number} [opts.retries=3] - number of *retries* (total attempts = retries + 1)
7
+ * @param {number} [opts.baseDelay=100] - initial delay in ms
8
+ * @param {number} [opts.multiplier=2] - backoff multiplier
9
+ * @param {boolean} [opts.jitter=false] - add +/-50% jitter if true
10
+ * @param {Function} [opts.sleep=defaultSleep] - injected sleeper for tests
11
+ * @param {Function} [opts.onDelay] - callback (delayMs, attempt, error) before each sleep
12
+ * @returns {Promise<*>}
13
+ */
14
+ export function retry(fn: Function, opts?: {
15
+ retries?: number;
16
+ baseDelay?: number;
17
+ multiplier?: number;
18
+ jitter?: boolean;
19
+ sleep?: Function;
20
+ onDelay?: Function;
21
+ }): Promise<any>;
22
+ export function withRetry(_fn: any, { retries, initialDelay, label }?: {
23
+ retries?: number;
24
+ initialDelay?: number;
25
+ label?: string;
26
+ }): Promise<any>;
27
+ export function defaultSleep(ms: any): Promise<any>;
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Per-run cancellation: one AbortController that is aborted when `timeout`
3
+ * elapses or when the caller's `signal` aborts. Its `signal` is handed to
4
+ * every component call; `race()` makes the run settle as soon as it is
5
+ * aborted even if a component ignores the signal; `throwIfAborted()` stops
6
+ * work between stages.
7
+ *
8
+ * @param {object} [options]
9
+ * @param {number} [options.timeout] - Milliseconds before the run is aborted
10
+ * @param {AbortSignal} [options.signal] - Caller's signal to follow
11
+ * @returns {{
12
+ * signal: AbortSignal,
13
+ * race: (promise: Promise<any>) => Promise<any>,
14
+ * throwIfAborted: () => void,
15
+ * clearTimer: () => void,
16
+ * detach: () => void,
17
+ * cleanup: () => void
18
+ * }}
19
+ */
20
+ export function createRunAbort({ timeout, signal }?: {
21
+ timeout?: number;
22
+ signal?: AbortSignal;
23
+ }): {
24
+ signal: AbortSignal;
25
+ race: (promise: Promise<any>) => Promise<any>;
26
+ throwIfAborted: () => void;
27
+ clearTimer: () => void;
28
+ detach: () => void;
29
+ cleanup: () => void;
30
+ };
31
+ /** Message used for a run that exceeded its timeout. */
32
+ export const TIMEOUT_MESSAGE: "Execution timeout";
33
+ /** Message used for a run cancelled through the caller's AbortSignal. */
34
+ export const ABORTED_MESSAGE: "Execution aborted";
@@ -0,0 +1,51 @@
1
+ /**
2
+ * Redact sensitive fields in an object
3
+ * @param {any} obj - Object to redact
4
+ * @param {number} depth - Current recursion depth
5
+ * @param {number} maxDepth - Maximum recursion depth
6
+ * @returns {any} Redacted object
7
+ */
8
+ export function redactObject(obj: any, depth?: number, maxDepth?: number): any;
9
+ /**
10
+ * Redact a string value if it contains secrets
11
+ * @param {string} value - String value to redact
12
+ * @returns {string} Redacted value if sensitive, original otherwise
13
+ */
14
+ export function redactStringValue(value: string): string;
15
+ /**
16
+ * Redact sensitive information from log data
17
+ * @param {string} message - Log message
18
+ * @param {object} meta - Log metadata object
19
+ * @returns {object} Redacted message and metadata
20
+ */
21
+ export function redactLogData(message: string, meta?: object): object;
22
+ /**
23
+ * Create a redacting wrapper for any logger
24
+ * @param {object} logger - Logger instance to wrap
25
+ * @returns {object} Wrapped logger with automatic redaction
26
+ */
27
+ export function createSecureLogger(logger: object): object;
28
+ /**
29
+ * Check if a field name is sensitive
30
+ * @param {string} fieldName - Field name to check
31
+ * @returns {boolean} True if sensitive
32
+ */
33
+ export function isSensitiveFieldName(fieldName: string): boolean;
34
+ /**
35
+ * Check if a value matches a secret pattern
36
+ * @param {string} value - Value to check
37
+ * @returns {boolean} True if matches secret pattern
38
+ */
39
+ export function matchesSecretPattern(value: string): boolean;
40
+ /**
41
+ * Sensitive field names that should be redacted
42
+ */
43
+ export const SENSITIVE_FIELD_NAMES: Set<string>;
44
+ /**
45
+ * Patterns that match secret-like values
46
+ */
47
+ export const SECRET_PATTERNS: RegExp[];
48
+ /**
49
+ * Redaction marker
50
+ */
51
+ export const REDACTED: "[REDACTED]";
@@ -0,0 +1,126 @@
1
+ /**
2
+ * Enterprise structured logger with correlation tracking
3
+ */
4
+ export class StructuredLogger {
5
+ constructor(options?: {});
6
+ serviceName: any;
7
+ environment: any;
8
+ logLevel: any;
9
+ enableCorrelation: boolean;
10
+ enableMetrics: boolean;
11
+ enableSecureLogging: boolean;
12
+ outputFormat: any;
13
+ metrics: {
14
+ logsWritten: number;
15
+ errorCount: number;
16
+ warnCount: number;
17
+ avgLatency: number;
18
+ };
19
+ /**
20
+ * Create correlation context for request tracking
21
+ * @param {string} correlationId - Optional correlation ID
22
+ * @param {Function} fn - Function to execute with context
23
+ * @returns {Promise} Result of function execution
24
+ */
25
+ withCorrelation(correlationId: string, fn: Function): Promise<any>;
26
+ /**
27
+ * Generate correlation ID
28
+ * @returns {string} Correlation ID
29
+ */
30
+ generateCorrelationId(): string;
31
+ /**
32
+ * Get current correlation context
33
+ * @returns {object|null} Current context
34
+ */
35
+ getContext(): object | null;
36
+ /**
37
+ * Create structured log entry
38
+ * @param {string} level - Log level
39
+ * @param {string} message - Log message
40
+ * @param {object} meta - Additional metadata
41
+ * @returns {object} Structured log entry
42
+ */
43
+ createLogEntry(level: string, message: string, meta?: object): object;
44
+ /**
45
+ * Check if log level should be written
46
+ * @param {string} level - Log level to check
47
+ * @returns {boolean} Whether to write log
48
+ */
49
+ shouldLog(level: string): boolean;
50
+ /**
51
+ * Write log entry to output
52
+ * @param {object} entry - Log entry
53
+ */
54
+ writeLog(entry: object): void;
55
+ /**
56
+ * Log error message
57
+ * @param {string} message - Error message
58
+ * @param {object} meta - Additional metadata
59
+ */
60
+ error(message: string, meta?: object): void;
61
+ /**
62
+ * Log warning message
63
+ * @param {string} message - Warning message
64
+ * @param {object} meta - Additional metadata
65
+ */
66
+ warn(message: string, meta?: object): void;
67
+ /**
68
+ * Log info message
69
+ * @param {string} message - Info message
70
+ * @param {object} meta - Additional metadata
71
+ */
72
+ info(message: string, meta?: object): void;
73
+ /**
74
+ * Log debug message
75
+ * @param {string} message - Debug message
76
+ * @param {object} meta - Additional metadata
77
+ */
78
+ debug(message: string, meta?: object): void;
79
+ /**
80
+ * Log trace message
81
+ * @param {string} message - Trace message
82
+ * @param {object} meta - Additional metadata
83
+ */
84
+ trace(message: string, meta?: object): void;
85
+ /**
86
+ * Create child logger with additional context
87
+ * @param {object} childMeta - Additional metadata for child logger
88
+ * @returns {ChildLogger} Child logger instance
89
+ */
90
+ child(childMeta?: object): ChildLogger;
91
+ /**
92
+ * Get logger metrics
93
+ * @returns {object} Logger performance metrics
94
+ */
95
+ getMetrics(): object;
96
+ /**
97
+ * Reset logger metrics
98
+ */
99
+ resetMetrics(): void;
100
+ }
101
+ /**
102
+ * Child logger with additional context
103
+ */
104
+ export class ChildLogger {
105
+ constructor(parent: any, childMeta: any);
106
+ parent: any;
107
+ childMeta: any;
108
+ error(message: any, meta?: {}): void;
109
+ warn(message: any, meta?: {}): void;
110
+ info(message: any, meta?: {}): void;
111
+ debug(message: any, meta?: {}): void;
112
+ trace(message: any, meta?: {}): void;
113
+ child(additionalMeta?: {}): ChildLogger;
114
+ withCorrelation(correlationId: any, fn: any): any;
115
+ getContext(): any;
116
+ getMetrics(): any;
117
+ }
118
+ /**
119
+ * Create structured logger instance
120
+ * @param {object} options - Logger configuration
121
+ * @returns {StructuredLogger} Logger instance
122
+ */
123
+ export function createLogger(options?: object): StructuredLogger;
124
+ declare const defaultLogger: StructuredLogger;
125
+ export declare let withCorrelation: any;
126
+ export { defaultLogger as logger };
package/package.json CHANGED
@@ -1,16 +1,36 @@
1
1
  {
2
2
  "name": "@devilsdev/rag-pipeline-utils",
3
- "version": "2.4.5",
4
- "description": "Composable RAG for Node.js — with built-in evaluation, citations, guardrails, and observability.",
3
+ "version": "2.6.0",
4
+ "description": "Composable retrieval-augmented generation (RAG) for Node.js: grounded citations, evaluation, guardrails, hybrid retrieval and a CLI.",
5
5
  "main": "dist/index.cjs",
6
6
  "type": "commonjs",
7
7
  "types": "dist/index.d.ts",
8
+ "typesVersions": {
9
+ "*": {
10
+ "experimental": [
11
+ "dist/experimental.d.ts"
12
+ ],
13
+ "testing": [
14
+ "dist/testing.d.ts"
15
+ ]
16
+ }
17
+ },
8
18
  "exports": {
9
19
  ".": {
10
20
  "types": "./dist/index.d.ts",
11
21
  "require": "./dist/index.cjs",
12
22
  "import": "./dist/index.mjs"
13
23
  },
24
+ "./experimental": {
25
+ "types": "./dist/experimental.d.ts",
26
+ "require": "./dist/experimental.cjs",
27
+ "import": "./dist/experimental.mjs"
28
+ },
29
+ "./testing": {
30
+ "types": "./dist/testing.d.ts",
31
+ "require": "./dist/testing.cjs",
32
+ "import": "./dist/testing.mjs"
33
+ },
14
34
  "./cli": "./bin/cli.js"
15
35
  },
16
36
  "bin": {
@@ -20,19 +40,21 @@
20
40
  "node": ">=18"
21
41
  },
22
42
  "scripts": {
23
- "build": "node scripts/build.js && node scripts/generate-types.js",
43
+ "build": "node scripts/build.js && node scripts/generate-types.js && node scripts/check-type-exports.js",
24
44
  "prepack": "npm run build",
25
45
  "docs:validate": "node scripts/validate-docs-examples.js",
26
46
  "verify:esm": "node scripts/verify-esm.mjs",
27
47
  "prepublishOnly": "npm run lint && npm test && npm run docs:validate && npm run verify:esm",
28
48
  "guard:cjs": "node scripts/guard-cjs.js",
29
49
  "pretest": "npm run guard:cjs && node scripts/setup.js",
30
- "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --runInBand --config jest.config.js",
50
+ "test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --maxWorkers=50% --config jest.config.js",
51
+ "test:serial": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --runInBand --config jest.config.js",
31
52
  "test:ci": "jest --coverage",
32
53
  "test:open-handles": "jest --detectOpenHandles --runInBand",
33
54
  "test:report": "node scripts/test-reporter.js",
34
55
  "posttest": "node scripts/generate-test-reports.js",
35
- "format": "prettier --write \"src/**/*.{js,json}\"",
56
+ "format": "prettier --write --ignore-unknown \"{__tests__,scripts,bin,docs-site,examples,contracts}/**/*.{js,jsx,ts,tsx,mjs,cjs}\" \"*.{js,mjs,cjs}\" \"**/*.{json,md,mdx,yml,yaml,css,scss,html}\"",
57
+ "format:check": "prettier --check --ignore-unknown \"{__tests__,scripts,bin,docs-site,examples,contracts}/**/*.{js,jsx,ts,tsx,mjs,cjs}\" \"*.{js,mjs,cjs}\" \"**/*.{json,md,mdx,yml,yaml,css,scss,html}\"",
36
58
  "test:watch": "jest --watch",
37
59
  "lint": "eslint src --ext .js --ignore-path .gitignore",
38
60
  "lint:fix": "eslint . --ext .js,.jsx --ignore-path .gitignore --fix",
@@ -45,16 +67,16 @@
45
67
  "lint-staged": "lint-staged",
46
68
  "postinstall": "husky install",
47
69
  "verify:mocks": "node scripts/verify-fixture-mocks.js",
48
- "build:docs": "npx docusaurus build docs-site",
70
+ "build:docs": "npm run docs:build",
49
71
  "ci": "node scripts/ci-runner.js",
50
- "docs:dev": "npx docusaurus start docs-site",
72
+ "docs:dev": "cd docs-site && npm run start",
51
73
  "docs:version": "npx docusaurus docs:version",
52
74
  "watch:lqip": "node docs-site/scripts/watch-images.js",
53
75
  "docs:clear": "docusaurus clear --site-dir docs-site",
54
- "docs:start": "docusaurus start docs-site",
76
+ "docs:start": "cd docs-site && npm run start",
55
77
  "docs:build": "cd docs-site && npm run build",
56
78
  "docs:serve": "docusaurus serve docs-site",
57
- "docs:deploy": "docusaurus deploy docs-site",
79
+ "docs:deploy": "node docs-site/scripts/sync-changelog.js && docusaurus deploy docs-site",
58
80
  "roadmap:close": "node scripts/close-done-roadmap-issues.js",
59
81
  "labels:sync": "node scripts/ensure-roadmap-labels.js",
60
82
  "release:tag": "node scripts/generate-release-note.js v$(node -p \"require('./package.json').version\")",
@@ -76,14 +98,8 @@
76
98
  "security:fix:force": "npm audit fix --force",
77
99
  "security:check": "npm audit --production && echo 'Production security check passed'",
78
100
  "security:report": "npm run security:audit:json && echo 'Security report generated: security-audit-report.json'",
79
- "ci:hardening": "node scripts/ci/harden-workflows.js",
80
101
  "ci:audit": "node scripts/audit/gha-audit.js",
81
- "ci:targeted-fixes": "node scripts/ci/targeted-security-fixes.js",
82
- "ci:comprehensive-hardening": "node scripts/ci/comprehensive-hardening.js",
83
- "ci:shell-security": "node scripts/ci/shell-security-hardening.js",
84
- "ci:final-fixes": "node scripts/ci/final-shell-injection-fixes.js",
85
102
  "ci:test-workflows": "node scripts/ci/test-workflows.js",
86
- "ci:fix-remaining": "node scripts/ci/fix-remaining-actions.js",
87
103
  "tests:categorize": "node scripts/test-categorizer.js",
88
104
  "tests:affected": "node scripts/run-affected.js",
89
105
  "tests:full": "jest --runInBand --reporters=default --json --outputFile=test-results-current.json",
@@ -92,6 +108,8 @@
92
108
  "test:integration": "jest __tests__/integration",
93
109
  "test:simple": "jest --maxWorkers=1 --no-coverage",
94
110
  "verify:pack": "node scripts/verify-npm-pack.js",
111
+ "smoke:pack": "node scripts/smoke-test-pack.js",
112
+ "demo:record": "vhs assets/demo.tape",
95
113
  "verify": "npm run lint && npm run typecheck --if-present && npm test",
96
114
  "sbom": "node scripts/generate-sbom.js",
97
115
  "observability:setup": "node scripts/setup-observability.js",
@@ -138,15 +156,12 @@
138
156
  "dist/",
139
157
  "src/",
140
158
  "!src/mocks/",
141
- "!src/ai/module-template.js",
142
- "!src/ai/index-fixed.js",
143
159
  "!src/dev/examples/",
144
160
  "!src/dev/README.md",
145
161
  "!src/utils/examples/",
146
162
  "!src/utils/ci/",
147
163
  "!src/ci/",
148
164
  "!src/scripts/",
149
- "!src/cli/plugin-marketplace-commands.js",
150
165
  "bin/",
151
166
  "contracts/",
152
167
  ".ragrc.schema.json",
@@ -162,13 +177,19 @@
162
177
  },
163
178
  "lint-staged": {
164
179
  "src/**/*.{js,ts,jsx,tsx}": "eslint --fix",
165
- "**/*.{js,ts,jsx,tsx,json,md,mdx,yml,yaml,css,scss,html}": "prettier --write --ignore-unknown"
180
+ "{__tests__,scripts,bin,docs-site,examples,contracts}/**/*.{js,jsx,ts,tsx,mjs,cjs}": "prettier --write --ignore-unknown",
181
+ "*.{js,mjs,cjs}": "prettier --write --ignore-unknown",
182
+ "**/*.{json,md,mdx,yml,yaml,css,scss,html}": "prettier --write --ignore-unknown"
166
183
  },
167
184
  "devDependencies": {
168
185
  "@babel/core": "^7.26.10",
169
186
  "@babel/preset-env": "^7.26.9",
170
- "@docusaurus/core": "3.5.2",
171
- "@docusaurus/preset-classic": "3.5.2",
187
+ "@docusaurus/core": "3.10.2",
188
+ "@docusaurus/preset-classic": "3.10.2",
189
+ "@docusaurus/theme-mermaid": "3.10.2",
190
+ "@easyops-cn/docusaurus-search-local": "0.55.3",
191
+ "@fontsource/inter": "5.3.0",
192
+ "@fontsource/jetbrains-mono": "5.3.0",
172
193
  "@octokit/rest": "^21.1.1",
173
194
  "@opentelemetry/api": "^1.9.0",
174
195
  "@opentelemetry/auto-instrumentations-node": "^0.52.1",
@@ -180,18 +201,14 @@
180
201
  "@opentelemetry/sdk-node": "^0.53.0",
181
202
  "@opentelemetry/sdk-trace-base": "^1.26.0",
182
203
  "@opentelemetry/semantic-conventions": "^1.27.0",
183
- "@semantic-release/changelog": "^6.0.3",
184
- "@semantic-release/commit-analyzer": "^13.0.1",
185
- "@semantic-release/git": "^10.0.1",
186
- "@semantic-release/github": "^9.2.6",
187
- "@semantic-release/npm": "^11.0.3",
188
- "@semantic-release/release-notes-generator": "^14.0.3",
189
204
  "@types/jest": "^29.5.14",
205
+ "@types/node": "22.14.1",
190
206
  "acorn": "8.15.0",
207
+ "ai": "6.0.317",
208
+ "ai-v7": "npm:ai@7.0.156",
191
209
  "babel-jest": "^29.7.0",
192
- "codecov": "3.6.2",
193
- "conventional-changelog-conventionalcommits": "^8.0.0",
194
210
  "cross-env": "7.0.3",
211
+ "docusaurus-plugin-llms": "0.6.1",
195
212
  "esbuild": "^0.25.2",
196
213
  "eslint": "^8.57.1",
197
214
  "eslint-plugin-storybook": "^0.12.0",
@@ -207,24 +224,46 @@
207
224
  "prettier": "^3.5.3",
208
225
  "prop-types": "^15.8.1",
209
226
  "rimraf": "^6.0.1",
210
- "semantic-release": "^21.1.2",
211
227
  "sharp": "^0.34.1",
212
228
  "ts-jest": "^29.3.2",
229
+ "typescript": "5.8.3",
213
230
  "why-is-node-running": "^3.2.2"
214
231
  },
215
232
  "dependencies": {
216
233
  "ajv": "^8.17.1",
217
- "axios": "^1.8.4",
218
- "chalk": "^5.4.1",
234
+ "ajv-formats": "2.1.1",
235
+ "axios": "^1.21.0",
236
+ "chalk": "4.1.2",
219
237
  "chokidar": "^4.0.3",
238
+ "cli-table3": "0.6.5",
220
239
  "commander": "^13.1.0",
221
240
  "csv-parse": "^5.6.0",
222
- "dotenv": "^16.5.0",
223
241
  "fast-glob": "^3.3.3",
224
242
  "inquirer": "^8.2.5",
225
243
  "jsdom": "^26.1.0",
226
244
  "jsonwebtoken": "9.0.2",
245
+ "marked": "15.0.12",
227
246
  "openai": "^4.93.0",
247
+ "ora": "5.4.1",
228
248
  "pino": "^9.6.0"
249
+ },
250
+ "peerDependencies": {
251
+ "isolated-vm": ">=5.0.0",
252
+ "pino-pretty": ">=10.0.0"
253
+ },
254
+ "peerDependenciesMeta": {
255
+ "isolated-vm": {
256
+ "optional": true
257
+ },
258
+ "pino-pretty": {
259
+ "optional": true
260
+ }
261
+ },
262
+ "overrides": {
263
+ "fast-uri": "^3.1.9",
264
+ "follow-redirects": "^1.16.2",
265
+ "form-data": "^4.0.6",
266
+ "ws@^8.0.0": "^8.21.0",
267
+ "zod": "^4.6.7"
229
268
  }
230
269
  }