@devilsdev/rag-pipeline-utils 2.3.1 → 2.4.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.
- package/README.md +293 -369
- package/contracts/loader-contract.json +11 -6
- package/contracts/reranker-contract.json +18 -26
- package/dist/index.cjs +21190 -47
- package/dist/index.d.ts +298 -68
- package/dist/index.mjs +9 -76
- package/package.json +20 -8
- package/src/agentic/agentic-pipeline.js +235 -0
- package/src/agentic/iterative-retriever.js +213 -0
- package/src/agentic/query-planner.js +208 -0
- package/src/agentic/self-critique.js +102 -0
- package/src/ai/adaptive-retrieval.js +0 -3
- package/src/ai/federated-learning.js +0 -3
- package/src/ai/federation.js +1 -6
- package/src/ai/index.js +9 -20
- package/src/ai/model-training.js +0 -3
- package/src/ai/multimodal-processing.js +0 -3
- package/src/ai/multimodal.js +1 -6
- package/src/ai/orchestrator.js +1 -6
- package/src/ai/retrieval-engine.js +1 -6
- package/src/chunking/chunking-engine.js +142 -0
- package/src/chunking/strategies/fixed-size.js +54 -0
- package/src/chunking/strategies/recursive.js +127 -0
- package/src/chunking/strategies/semantic.js +128 -0
- package/src/chunking/strategies/sentence.js +32 -0
- package/src/chunking/strategies/structure-aware.js +138 -0
- package/src/citation/citation-tracker.js +161 -0
- package/src/citation/hallucination-detector.js +74 -0
- package/src/citation/source-mapper.js +95 -0
- package/src/cli/commands/ai-ml/adaptive-commands.js +178 -0
- package/src/cli/commands/ai-ml/federated-commands.js +207 -0
- package/src/cli/commands/ai-ml/index.js +17 -0
- package/src/cli/commands/ai-ml/multimodal-commands.js +187 -0
- package/src/cli/commands/ai-ml/shared.js +51 -0
- package/src/cli/commands/ai-ml/training-commands.js +228 -0
- package/src/cli/commands/ai-ml.js +176 -757
- package/src/cli/commands/plugin-hub/certification-commands.js +221 -0
- package/src/cli/commands/plugin-hub/event-handlers.js +64 -0
- package/src/cli/commands/plugin-hub/hub-commands.js +290 -0
- package/src/cli/commands/plugin-hub/review-commands.js +78 -0
- package/src/cli/commands/plugin-hub.js +106 -782
- package/src/cli/diagnostics/config-checker.js +81 -0
- package/src/cli/diagnostics/dependency-checker.js +69 -0
- package/src/cli/diagnostics/environment-checker.js +45 -0
- package/src/cli/diagnostics/performance-checker.js +51 -0
- package/src/cli/diagnostics/plugin-checker.js +106 -0
- package/src/cli/diagnostics/security-checker.js +61 -0
- package/src/cli/doctor-command.js +70 -369
- package/src/cli/enhanced-cli-commands.js +162 -706
- package/src/cli/handlers/config-handler.js +126 -0
- package/src/cli/handlers/diagnostics-handler.js +113 -0
- package/src/cli/handlers/ingest-handler.js +42 -0
- package/src/cli/handlers/init-handler.js +51 -0
- package/src/cli/handlers/query-handler.js +45 -0
- package/src/cli/handlers/run-handler.js +181 -0
- package/src/cli/interactive-wizard.js +99 -723
- package/src/cli/shared/cli-utils.js +89 -0
- package/src/cli/wizard/configuration.js +148 -0
- package/src/cli/wizard/observability.js +79 -0
- package/src/cli/wizard/performance.js +76 -0
- package/src/cli/wizard/plugin-selection.js +297 -0
- package/src/cli/wizard/preview-save.js +172 -0
- package/src/cli/wizard/project-setup.js +66 -0
- package/src/config/memory-optimization.js +3 -3
- package/src/connectors/anthropic-connector.js +179 -0
- package/src/connectors/base-connector.js +94 -0
- package/src/connectors/cohere-connector.js +143 -0
- package/src/connectors/local-embedder.js +171 -0
- package/src/connectors/memory-retriever.js +150 -0
- package/src/connectors/ollama-connector.js +205 -0
- package/src/connectors/openai-connector.js +173 -0
- package/src/core/create-pipeline.js +21 -1
- package/src/core/observability/tracing.js +2 -1
- package/src/core/pipeline-factory.js +0 -1
- package/src/core/plugin-registry.js +14 -14
- package/src/cost/cost-calculator.js +146 -0
- package/src/cost/cost-tracker.js +260 -0
- package/src/cost/token-budget.js +245 -0
- package/src/dag/core/execution-scheduler.js +2 -1
- package/src/dag/core/topology-validation.js +0 -3
- package/src/dag/dag-engine.js +3 -5
- package/src/dag/dag-node.js +0 -1
- package/src/dag/enhanced-dag-engine.js +171 -99
- package/src/dashboard/dashboard-generator.js +642 -0
- package/src/dashboard/metrics-aggregator.js +409 -0
- package/src/debug/execution-tracer.js +210 -0
- package/src/debug/trace-inspector.js +281 -0
- package/src/dev/dev-server.js +5 -5
- package/src/dev/hot-reload.js +3 -2
- package/src/dx/integration-templates.js +0 -3
- package/src/ecosystem/plugin-analytics-dashboard.js +2 -2
- package/src/ecosystem/plugin-hub.js +2 -2
- package/src/enterprise/audit-logging.js +2 -2
- package/src/enterprise/sso-integration.js +52 -32
- package/src/evaluate/context-metrics.js +127 -0
- package/src/evaluate/evaluator.js +4 -2
- package/src/evaluate/faithfulness.js +117 -0
- package/src/evaluate/groundedness.js +60 -0
- package/src/evaluate/pipeline-evaluator.js +156 -0
- package/src/evaluate/relevance.js +129 -0
- package/src/evaluate/scoring.js +27 -0
- package/src/graph/entity-extractor.js +183 -0
- package/src/graph/graph-index.js +113 -0
- package/src/graph/graph-retriever.js +244 -0
- package/src/graph/knowledge-graph.js +256 -0
- package/src/guardrails/guardrails-pipeline.js +136 -0
- package/src/guardrails/post-generation-guard.js +170 -0
- package/src/guardrails/pre-retrieval-guard.js +161 -0
- package/src/guardrails/retrieval-guard.js +126 -0
- package/src/index.js +255 -9
- package/src/loader/html-loader.js +4 -15
- package/src/loader/markdown-loader.js +4 -15
- package/src/mcp/mcp-server.js +199 -0
- package/src/mcp/mcp-tool-builder.js +121 -0
- package/src/observability/audit-logger.js +0 -2
- package/src/observability/event-logger.js +2 -1
- package/src/observability/security-monitor.js +0 -2
- package/src/observability/telemetry.js +0 -2
- package/src/reranker/cascade-reranker.js +79 -0
- package/src/reranker/embedding-reranker.js +124 -0
- package/src/reranker/llm-reranker.js +6 -3
- package/src/reranker/scoring-reranker.js +123 -0
- package/src/retrieval/bm25-search.js +157 -0
- package/src/retrieval/hybrid-retriever.js +111 -0
- package/src/retrieval/rank-fusion.js +62 -0
- package/src/security/jwt-config.js +4 -3
- package/src/security/jwt-validator.js +2 -1
- package/src/security/plugin-sandbox.js +0 -3
- package/src/security/plugin-signature-verifier.js +4 -6
- package/src/security/validator.js +0 -2
- package/src/streaming/embedding-stream.js +197 -0
- package/src/streaming/sse-adapter.js +168 -0
- package/src/streaming/stream-router.js +210 -0
- package/src/streaming/streaming-embedder.js +231 -0
- package/src/streaming/websocket-adapter.js +171 -0
- package/src/templates/scaffold.js +147 -0
- package/src/templates/template-registry.js +272 -0
- package/src/utils/contract-validator.js +2 -1
- package/src/utils/input-sanitizer.js +80 -99
- package/src/utils/performance-monitor.js +0 -3
- package/src/utils/plugin-scaffolder.js +9 -16
- package/src/utils/rate-limiter.js +0 -1
- package/src/utils/retry-policy.js +0 -3
- package/src/utils/safe-expression-evaluator.js +0 -3
- package/src/utils/secure-logger-config.js +2 -4
- package/src/utils/secure-logging.js +0 -3
- package/src/utils/structured-logger.js +0 -3
- package/src/ai/index-fixed.js +0 -509
- package/src/ai/module-template.js +0 -37
- package/src/ci/workflow-analyzer.js +0 -71
- package/src/cli/plugin-marketplace-commands.js +0 -869
- package/src/dev/README.md +0 -126
- package/src/dev/examples/hot-reload-usage.js +0 -355
- package/src/mocks/openai-embedder.js +0 -119
- package/src/mocks/openai-llm.js +0 -77
- package/src/mocks/pdf-loader.js +0 -21
- package/src/mocks/pinecone-retriever.js +0 -106
- package/src/scripts/script-utilities.js +0 -36
- package/src/utils/ci/diagnostic-reporter.js +0 -57
- package/src/utils/examples/error-formatter-usage.js +0 -351
package/dist/index.d.ts
CHANGED
|
@@ -13,18 +13,36 @@ export interface RagPipelineConfig {
|
|
|
13
13
|
retriever?: string | RetrieverPlugin;
|
|
14
14
|
llm?: string | LLMPlugin;
|
|
15
15
|
reranker?: string | RerankerPlugin;
|
|
16
|
+
registry?: PluginRegistry;
|
|
16
17
|
[key: string]: any;
|
|
17
18
|
}
|
|
18
19
|
|
|
19
|
-
export interface
|
|
20
|
-
|
|
21
|
-
|
|
20
|
+
export interface PipelineRunOptions {
|
|
21
|
+
query?: string;
|
|
22
|
+
queryVector?: number[];
|
|
23
|
+
options?: {
|
|
24
|
+
timeout?: number;
|
|
25
|
+
stream?: boolean;
|
|
26
|
+
topK?: number;
|
|
27
|
+
[key: string]: any;
|
|
28
|
+
};
|
|
22
29
|
}
|
|
23
30
|
|
|
24
|
-
export interface
|
|
31
|
+
export interface PipelineRunResult {
|
|
32
|
+
success: boolean;
|
|
25
33
|
query?: string;
|
|
26
|
-
|
|
27
|
-
|
|
34
|
+
results?: any;
|
|
35
|
+
error?: string;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface Pipeline {
|
|
39
|
+
run(options: PipelineRunOptions): Promise<PipelineRunResult>;
|
|
40
|
+
cleanup(): void;
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
export interface LoadConfigOptions {
|
|
44
|
+
configPath?: string;
|
|
45
|
+
validate?: boolean;
|
|
28
46
|
}
|
|
29
47
|
|
|
30
48
|
// =============================================================================
|
|
@@ -66,69 +84,23 @@ export interface LLMResponse {
|
|
|
66
84
|
// Plugin Contract Interfaces
|
|
67
85
|
// =============================================================================
|
|
68
86
|
|
|
69
|
-
/**
|
|
70
|
-
* Loader plugin interface for loading documents from various sources
|
|
71
|
-
*/
|
|
72
87
|
export interface LoaderPlugin {
|
|
73
|
-
/**
|
|
74
|
-
* Load documents from a source
|
|
75
|
-
* @param source - Path or identifier of the source
|
|
76
|
-
* @param options - Optional loading parameters
|
|
77
|
-
* @returns Promise resolving to array of documents
|
|
78
|
-
*/
|
|
79
88
|
load(source: string, options?: any): Promise<Document[]>;
|
|
80
89
|
}
|
|
81
90
|
|
|
82
|
-
/**
|
|
83
|
-
* Embedder plugin interface for generating vector embeddings
|
|
84
|
-
*/
|
|
85
91
|
export interface EmbedderPlugin {
|
|
86
|
-
/**
|
|
87
|
-
* Generate embedding vector for text
|
|
88
|
-
* @param text - Input text to embed
|
|
89
|
-
* @param options - Optional embedding parameters
|
|
90
|
-
* @returns Promise resolving to embedding vector
|
|
91
|
-
*/
|
|
92
92
|
embed(text: string, options?: any): Promise<number[]>;
|
|
93
93
|
}
|
|
94
94
|
|
|
95
|
-
/**
|
|
96
|
-
* Retriever plugin interface for vector search and document retrieval
|
|
97
|
-
*/
|
|
98
95
|
export interface RetrieverPlugin {
|
|
99
|
-
/**
|
|
100
|
-
* Retrieve relevant documents based on query
|
|
101
|
-
* @param query - Search query (text or embedding)
|
|
102
|
-
* @param options - Retrieval options (topK, filters, etc.)
|
|
103
|
-
* @returns Promise resolving to search results
|
|
104
|
-
*/
|
|
105
96
|
retrieve(query: string | { embedding: number[] }, options?: RetrieveOptions): Promise<SearchResult[]>;
|
|
106
97
|
}
|
|
107
98
|
|
|
108
|
-
/**
|
|
109
|
-
* LLM plugin interface for text generation
|
|
110
|
-
*/
|
|
111
99
|
export interface LLMPlugin {
|
|
112
|
-
/**
|
|
113
|
-
* Generate text response based on prompt
|
|
114
|
-
* @param prompt - Input prompt for generation
|
|
115
|
-
* @param options - Generation parameters (temperature, maxTokens, etc.)
|
|
116
|
-
* @returns Promise resolving to LLM response
|
|
117
|
-
*/
|
|
118
100
|
generate(prompt: string, options?: any): Promise<LLMResponse>;
|
|
119
101
|
}
|
|
120
102
|
|
|
121
|
-
/**
|
|
122
|
-
* Reranker plugin interface for improving retrieval relevance
|
|
123
|
-
*/
|
|
124
103
|
export interface RerankerPlugin {
|
|
125
|
-
/**
|
|
126
|
-
* Rerank search results based on query
|
|
127
|
-
* @param results - Initial search results
|
|
128
|
-
* @param query - Original query
|
|
129
|
-
* @param options - Reranking parameters
|
|
130
|
-
* @returns Promise resolving to reranked results
|
|
131
|
-
*/
|
|
132
104
|
rerank(results: SearchResult[], query: string, options?: any): Promise<SearchResult[]>;
|
|
133
105
|
}
|
|
134
106
|
|
|
@@ -161,7 +133,7 @@ export interface DAGOptions {
|
|
|
161
133
|
// =============================================================================
|
|
162
134
|
|
|
163
135
|
export interface PluginRegistry {
|
|
164
|
-
register(type: string, name: string, implementation: any): void;
|
|
136
|
+
register(type: string, name: string, implementation: any, contract?: any): void;
|
|
165
137
|
get(type: string, name: string): any;
|
|
166
138
|
has(type: string, name: string): boolean;
|
|
167
139
|
list(type: string): any[];
|
|
@@ -174,12 +146,36 @@ export interface Logger {
|
|
|
174
146
|
debug(message: string, meta?: any): void;
|
|
175
147
|
}
|
|
176
148
|
|
|
149
|
+
export interface ErrorFormatter {
|
|
150
|
+
formatError(error: Error): string;
|
|
151
|
+
createError(code: string, message: string, details?: any): Error;
|
|
152
|
+
wrapError(error: Error, context: string): Error;
|
|
153
|
+
ERROR_CODES: Record<string, string>;
|
|
154
|
+
}
|
|
155
|
+
|
|
156
|
+
// =============================================================================
|
|
157
|
+
// Evaluation Types
|
|
158
|
+
// =============================================================================
|
|
159
|
+
|
|
160
|
+
export interface EvalResult {
|
|
161
|
+
question: string;
|
|
162
|
+
expected: string;
|
|
163
|
+
actual: string;
|
|
164
|
+
score: number;
|
|
165
|
+
bleu?: number;
|
|
166
|
+
rouge?: number;
|
|
167
|
+
}
|
|
168
|
+
|
|
169
|
+
// =============================================================================
|
|
177
170
|
// Core API
|
|
178
|
-
|
|
171
|
+
// =============================================================================
|
|
172
|
+
|
|
173
|
+
export function createRagPipeline(config: RagPipelineConfig): Pipeline;
|
|
179
174
|
export { createRagPipeline as createPipeline };
|
|
180
175
|
|
|
181
176
|
// Configuration
|
|
182
177
|
export function loadConfig(options?: LoadConfigOptions): Promise<RagPipelineConfig>;
|
|
178
|
+
export { loadConfig as loadRagConfig };
|
|
183
179
|
export function validateRagrc(config: any): boolean;
|
|
184
180
|
export function normalizeConfig(config: any): RagPipelineConfig;
|
|
185
181
|
|
|
@@ -188,36 +184,174 @@ export const pluginRegistry: PluginRegistry;
|
|
|
188
184
|
|
|
189
185
|
// Utilities
|
|
190
186
|
export const logger: Logger;
|
|
187
|
+
export const errorFormatter: ErrorFormatter;
|
|
188
|
+
export function createError(code: string, message: string, details?: any): Error;
|
|
189
|
+
export function wrapError(error: Error, context: string): Error;
|
|
190
|
+
export const ERROR_CODES: Record<string, string>;
|
|
191
191
|
|
|
192
|
-
//
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
192
|
+
// =============================================================================
|
|
193
|
+
// Utility Classes
|
|
194
|
+
// =============================================================================
|
|
195
|
+
|
|
196
|
+
export class BatchProcessor {
|
|
197
|
+
constructor(options?: {
|
|
198
|
+
batchSize?: number;
|
|
199
|
+
maxConcurrent?: number;
|
|
200
|
+
retryAttempts?: number;
|
|
201
|
+
onProgress?: (progress: any) => void;
|
|
202
|
+
[key: string]: any;
|
|
203
|
+
});
|
|
204
|
+
process(items: any[], handler: (batch: any[]) => Promise<any[]>): Promise<any[]>;
|
|
205
|
+
cancel(): void;
|
|
206
|
+
}
|
|
207
|
+
|
|
208
|
+
export class RateLimiter {
|
|
209
|
+
constructor(options?: {
|
|
210
|
+
maxRequests?: number;
|
|
211
|
+
windowMs?: number;
|
|
212
|
+
[key: string]: any;
|
|
213
|
+
});
|
|
214
|
+
tryAcquire(identifier?: string): boolean;
|
|
215
|
+
reset(identifier?: string): void;
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
export function retry<T>(fn: () => Promise<T>, options?: {
|
|
219
|
+
maxAttempts?: number;
|
|
220
|
+
delay?: number;
|
|
221
|
+
backoff?: number;
|
|
222
|
+
retryIf?: (error: Error) => boolean;
|
|
223
|
+
}): Promise<T>;
|
|
224
|
+
|
|
225
|
+
export function withRetry<T>(fn: () => Promise<T>, options?: {
|
|
226
|
+
maxAttempts?: number;
|
|
227
|
+
delay?: number;
|
|
228
|
+
backoff?: number;
|
|
229
|
+
}): Promise<T>;
|
|
230
|
+
|
|
231
|
+
export class ConnectionPoolManager {
|
|
232
|
+
constructor(options?: {
|
|
233
|
+
maxSockets?: number;
|
|
234
|
+
maxFreeSockets?: number;
|
|
235
|
+
timeout?: number;
|
|
236
|
+
[key: string]: any;
|
|
237
|
+
});
|
|
238
|
+
getPool(hostname: string): any;
|
|
239
|
+
getMetrics(): any;
|
|
240
|
+
destroy(): void;
|
|
199
241
|
}
|
|
200
242
|
|
|
243
|
+
// =============================================================================
|
|
244
|
+
// Security
|
|
245
|
+
// =============================================================================
|
|
246
|
+
|
|
247
|
+
export class JWTValidator {
|
|
248
|
+
constructor(options?: {
|
|
249
|
+
secret?: string;
|
|
250
|
+
algorithms?: string[];
|
|
251
|
+
issuer?: string;
|
|
252
|
+
audience?: string;
|
|
253
|
+
clockTolerance?: number;
|
|
254
|
+
maxAge?: string;
|
|
255
|
+
[key: string]: any;
|
|
256
|
+
});
|
|
257
|
+
sign(payload: any, options?: any): string;
|
|
258
|
+
verify(token: string, options?: any): any;
|
|
259
|
+
}
|
|
260
|
+
|
|
261
|
+
export class PluginSandbox {
|
|
262
|
+
constructor(options?: {
|
|
263
|
+
memoryLimit?: number;
|
|
264
|
+
timeout?: number;
|
|
265
|
+
permissions?: string[];
|
|
266
|
+
[key: string]: any;
|
|
267
|
+
});
|
|
268
|
+
execute(code: string, context?: any): Promise<any>;
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
export class PluginSignatureVerifier {
|
|
272
|
+
constructor(options?: {
|
|
273
|
+
trustedKeysPath?: string;
|
|
274
|
+
failClosed?: boolean;
|
|
275
|
+
[key: string]: any;
|
|
276
|
+
});
|
|
277
|
+
verify(pluginPath: string): Promise<boolean>;
|
|
278
|
+
}
|
|
279
|
+
|
|
280
|
+
export function validateInput(input: string, options?: any): { valid: boolean; errors?: string[] };
|
|
281
|
+
|
|
282
|
+
// =============================================================================
|
|
201
283
|
// AI/ML
|
|
284
|
+
// =============================================================================
|
|
285
|
+
|
|
202
286
|
export class MultiModalProcessor {
|
|
203
287
|
constructor(options?: any);
|
|
204
|
-
|
|
288
|
+
processContent(tenantId: string, content: any): Promise<any>;
|
|
289
|
+
generateEmbeddings(tenantId: string, content: any): Promise<any>;
|
|
290
|
+
crossModalSearch(tenantId: string, query: any): Promise<any>;
|
|
205
291
|
}
|
|
206
292
|
|
|
207
293
|
export class AdaptiveRetrievalEngine {
|
|
208
294
|
constructor(options?: any);
|
|
209
|
-
|
|
295
|
+
retrieveDocuments(tenantId: string, query: string, options?: any): Promise<any>;
|
|
296
|
+
optimizeRetrieval(tenantId: string, performanceData: any): Promise<any>;
|
|
210
297
|
}
|
|
211
298
|
|
|
212
|
-
|
|
299
|
+
export class FederatedLearningCoordinator {
|
|
300
|
+
constructor(options?: any);
|
|
301
|
+
createSession(config: any): Promise<any>;
|
|
302
|
+
submitUpdate(sessionId: string, update: any): Promise<any>;
|
|
303
|
+
aggregate(sessionId: string): Promise<any>;
|
|
304
|
+
}
|
|
305
|
+
|
|
306
|
+
export class ModelTrainingOrchestrator {
|
|
307
|
+
constructor(options?: any);
|
|
308
|
+
createTrainingJob(tenantId: string, config: any): Promise<any>;
|
|
309
|
+
getJobStatus(jobId: string): Promise<any>;
|
|
310
|
+
optimizeModel(config: any): Promise<any>;
|
|
311
|
+
deployModel(jobId: string, deployConfig: any): Promise<any>;
|
|
312
|
+
}
|
|
313
|
+
|
|
314
|
+
// =============================================================================
|
|
315
|
+
// Workflow Engine
|
|
316
|
+
// =============================================================================
|
|
317
|
+
|
|
318
|
+
export class DAGEngine {
|
|
319
|
+
constructor(options?: DAGOptions);
|
|
320
|
+
addNode(id: string, fn: (input: any) => Promise<any>, options?: Partial<DAGNode>): void;
|
|
321
|
+
connect(fromId: string, toId: string): void;
|
|
322
|
+
execute(seed?: any, options?: DAGOptions): Promise<Map<string, any>>;
|
|
323
|
+
validate(): void;
|
|
324
|
+
}
|
|
325
|
+
|
|
326
|
+
export { DAGEngine as DAG };
|
|
327
|
+
|
|
328
|
+
// =============================================================================
|
|
329
|
+
// Evaluation
|
|
330
|
+
// =============================================================================
|
|
331
|
+
|
|
332
|
+
export function evaluateRagDataset(dataset: Array<{
|
|
333
|
+
question: string;
|
|
334
|
+
expected: string;
|
|
335
|
+
actual: string;
|
|
336
|
+
}>): EvalResult[];
|
|
337
|
+
|
|
338
|
+
export function scoreAnswer(expected: string, actual: string): number;
|
|
339
|
+
export function computeBLEU(reference: string, hypothesis: string): number;
|
|
340
|
+
export function computeROUGE(reference: string, hypothesis: string): number;
|
|
341
|
+
|
|
342
|
+
// =============================================================================
|
|
343
|
+
// Performance & Observability
|
|
344
|
+
// =============================================================================
|
|
345
|
+
|
|
213
346
|
export class ParallelProcessor {
|
|
214
347
|
constructor(options?: any);
|
|
215
348
|
process(items: any[], handler: (item: any) => Promise<any>): Promise<any[]>;
|
|
216
349
|
}
|
|
217
350
|
|
|
218
|
-
// Observability
|
|
219
351
|
export const eventLogger: {
|
|
220
352
|
log(event: string, data?: any): void;
|
|
353
|
+
info(event: string, data?: any): void;
|
|
354
|
+
error(event: string, data?: any): void;
|
|
221
355
|
};
|
|
222
356
|
|
|
223
357
|
export const metrics: {
|
|
@@ -225,13 +359,109 @@ export const metrics: {
|
|
|
225
359
|
timer(name: string): { end(): void };
|
|
226
360
|
};
|
|
227
361
|
|
|
362
|
+
// =============================================================================
|
|
228
363
|
// Enterprise
|
|
364
|
+
// =============================================================================
|
|
365
|
+
|
|
229
366
|
export class AuditLogger {
|
|
230
367
|
constructor(options?: any);
|
|
231
|
-
|
|
368
|
+
logAuthentication(event: any): Promise<void>;
|
|
369
|
+
logDataAccess(event: any): Promise<void>;
|
|
370
|
+
logDataModification(event: any): Promise<void>;
|
|
232
371
|
}
|
|
233
372
|
|
|
234
373
|
export class DataGovernance {
|
|
235
374
|
constructor(options?: any);
|
|
236
|
-
|
|
237
|
-
|
|
375
|
+
classifyData(data: any): any;
|
|
376
|
+
enforceRetention(policy: any): Promise<void>;
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
export { DataGovernance as DataGovernanceManager };
|
|
380
|
+
|
|
381
|
+
export class TenantManager {
|
|
382
|
+
constructor(options?: any);
|
|
383
|
+
createTenant(config: any): Promise<any>;
|
|
384
|
+
getTenant(tenantId: string): any;
|
|
385
|
+
deleteTenant(tenantId: string): Promise<void>;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
export class ResourceMonitor {
|
|
389
|
+
constructor(options?: any);
|
|
390
|
+
getUsage(tenantId: string): any;
|
|
391
|
+
checkQuota(tenantId: string): boolean;
|
|
392
|
+
}
|
|
393
|
+
|
|
394
|
+
export class SSOManager {
|
|
395
|
+
constructor(options?: any);
|
|
396
|
+
authenticate(provider: string, credentials: any): Promise<any>;
|
|
397
|
+
getSession(sessionId: string): any;
|
|
398
|
+
}
|
|
399
|
+
|
|
400
|
+
export class SAMLProvider {
|
|
401
|
+
constructor(options?: any);
|
|
402
|
+
authenticate(request: any): Promise<any>;
|
|
403
|
+
}
|
|
404
|
+
|
|
405
|
+
export class OAuth2Provider {
|
|
406
|
+
constructor(options?: any);
|
|
407
|
+
authenticate(request: any): Promise<any>;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
export class ActiveDirectoryProvider {
|
|
411
|
+
constructor(options?: any);
|
|
412
|
+
authenticate(request: any): Promise<any>;
|
|
413
|
+
}
|
|
414
|
+
|
|
415
|
+
export class OIDCProvider {
|
|
416
|
+
constructor(options?: any);
|
|
417
|
+
authenticate(request: any): Promise<any>;
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// =============================================================================
|
|
421
|
+
// Ecosystem
|
|
422
|
+
// =============================================================================
|
|
423
|
+
|
|
424
|
+
export class PluginHub {
|
|
425
|
+
constructor(options?: any);
|
|
426
|
+
search(query: string, options?: any): Promise<any[]>;
|
|
427
|
+
install(pluginName: string, options?: any): Promise<any>;
|
|
428
|
+
publish(pluginPath: string, options?: any): Promise<any>;
|
|
429
|
+
}
|
|
430
|
+
|
|
431
|
+
export class PluginAnalytics {
|
|
432
|
+
constructor(options?: any);
|
|
433
|
+
trackDownload(pluginName: string): void;
|
|
434
|
+
getStats(pluginName: string): any;
|
|
435
|
+
}
|
|
436
|
+
|
|
437
|
+
export class PluginCertification {
|
|
438
|
+
constructor(options?: any);
|
|
439
|
+
certify(pluginName: string): Promise<any>;
|
|
440
|
+
verify(pluginName: string): Promise<boolean>;
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
export class PluginAnalyticsDashboard {
|
|
444
|
+
constructor(options?: any);
|
|
445
|
+
generateReport(options?: any): Promise<any>;
|
|
446
|
+
getMetrics(): any;
|
|
447
|
+
}
|
|
448
|
+
|
|
449
|
+
// =============================================================================
|
|
450
|
+
// Development Tools
|
|
451
|
+
// =============================================================================
|
|
452
|
+
|
|
453
|
+
export class HotReloadManager {
|
|
454
|
+
constructor(options?: any);
|
|
455
|
+
watch(paths: string[]): void;
|
|
456
|
+
stop(): void;
|
|
457
|
+
}
|
|
458
|
+
|
|
459
|
+
export function createHotReloadManager(options?: any): HotReloadManager;
|
|
460
|
+
|
|
461
|
+
export class DevServer {
|
|
462
|
+
constructor(options?: any);
|
|
463
|
+
start(port?: number): Promise<void>;
|
|
464
|
+
stop(): Promise<void>;
|
|
465
|
+
}
|
|
466
|
+
|
|
467
|
+
export function createDevServer(options?: any): DevServer;
|
package/dist/index.mjs
CHANGED
|
@@ -1,80 +1,13 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
*/
|
|
1
|
+
import { createRequire } from 'module';
|
|
2
|
+
import { fileURLToPath } from 'url';
|
|
3
|
+
import { dirname } from 'path';
|
|
5
4
|
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
*/
|
|
5
|
+
const __filename = fileURLToPath(import.meta.url);
|
|
6
|
+
const __dirname = dirname(__filename);
|
|
7
|
+
const require = createRequire(import.meta.url);
|
|
10
8
|
|
|
11
|
-
|
|
12
|
-
import createpipelineModule from '../src/core/create-pipeline.js';
|
|
13
|
-
const { createRagPipeline } = createpipelineModule;
|
|
9
|
+
const mod = require('./index.cjs');
|
|
14
10
|
|
|
15
|
-
|
|
16
|
-
import loadconfigModule from '../src/config/load-config.js';
|
|
17
|
-
const { loadConfig } = loadconfigModule;
|
|
18
|
-
import enhancedragrcschemaModule from '../src/config/enhanced-ragrc-schema.js';
|
|
19
|
-
const { validateRagrc } = enhancedragrcschemaModule;
|
|
20
|
-
import normalizeconfigModule from '../src/config/normalize-config.js';
|
|
21
|
-
const { normalizeConfig } = normalizeconfigModule;
|
|
11
|
+
export const { createRagPipeline, createPipeline, loadConfig, loadRagConfig, validateRagrc, normalizeConfig, pluginRegistry, logger, errorFormatter, createError, wrapError, ERROR_CODES, BatchProcessor, RateLimiter, retry, withRetry, ConnectionPoolManager, JWTValidator, PluginSandbox, PluginSignatureVerifier, validateInput, MultiModalProcessor, AdaptiveRetrievalEngine, FederatedLearningCoordinator, ModelTrainingOrchestrator, DAGEngine, DAG, evaluateRagDataset, scoreAnswer, computeBLEU, computeROUGE, computeFaithfulness, computeAnswerRelevance, computeContextPrecision, computeContextRecall, computeGroundedness, PipelineEvaluator, ChunkingEngine, CitationTracker, mapSentenceToSources, buildIDFWeights, detectHallucinations, BM25Search, reciprocalRankFusion, HybridRetriever, PreRetrievalGuard, RetrievalGuard, PostGenerationGuard, GuardrailsPipeline, QueryPlanner, IterativeRetriever, SelfCritiqueChecker, AgenticPipeline, CostCalculator, CostTracker, TokenBudget, ExecutionTracer, TraceInspector, MCPServer, MCPToolBuilder, ProjectScaffolder, TemplateRegistry, SSEAdapter, WebSocketAdapter, StreamRouter, BaseConnector, OllamaConnector, LocalEmbedder, MemoryRetriever, OpenAIConnector, AnthropicConnector, CohereConnector, StreamingEmbedder, createEmbeddingStream, ScoringReranker, EmbeddingReranker, CascadeReranker, KnowledgeGraph, EntityExtractor, GraphRetriever, GraphIndex, DashboardGenerator, MetricsAggregator, ParallelProcessor, eventLogger, metrics, AuditLogger, DataGovernance, DataGovernanceManager, TenantManager, ResourceMonitor, SSOManager, SAMLProvider, OAuth2Provider, ActiveDirectoryProvider, OIDCProvider, PluginHub, PluginAnalytics, PluginCertification, PluginAnalyticsDashboard, HotReloadManager, createHotReloadManager, DevServer, createDevServer } = mod;
|
|
22
12
|
|
|
23
|
-
|
|
24
|
-
import pluginRegistry from '../src/core/plugin-registry.js';
|
|
25
|
-
|
|
26
|
-
// Utilities
|
|
27
|
-
import logger from '../src/utils/logger.js';
|
|
28
|
-
import errorFormatter from '../src/utils/error-formatter.js';
|
|
29
|
-
|
|
30
|
-
// AI/ML capabilities
|
|
31
|
-
import MultiModalProcessor from '../src/ai/multimodal.js';
|
|
32
|
-
import AdaptiveRetrievalEngine from '../src/ai/retrieval-engine.js';
|
|
33
|
-
|
|
34
|
-
// DAG engine for complex workflows
|
|
35
|
-
import dagengineModule from '../src/dag/dag-engine.js';
|
|
36
|
-
const { DAGEngine } = dagengineModule;
|
|
37
|
-
|
|
38
|
-
// Performance and observability
|
|
39
|
-
import ParallelProcessor from '../src/core/performance/parallel-processor.js';
|
|
40
|
-
import eventLogger from '../src/core/observability/event-logger.js';
|
|
41
|
-
import metrics from '../src/core/observability/metrics.js';
|
|
42
|
-
|
|
43
|
-
// Enterprise features
|
|
44
|
-
import auditloggingModule from '../src/enterprise/audit-logging.js';
|
|
45
|
-
const { AuditLogger } = auditloggingModule;
|
|
46
|
-
import datagovernanceModule from '../src/enterprise/data-governance.js';
|
|
47
|
-
const { DataGovernance } = datagovernanceModule;
|
|
48
|
-
|
|
49
|
-
// Development tools
|
|
50
|
-
import hotreloadModule from '../src/dev/hot-reload.js';
|
|
51
|
-
const { HotReloadManager,
|
|
52
|
-
createHotReloadManager,
|
|
53
|
-
} = hotreloadModule;
|
|
54
|
-
import devserverModule from '../src/dev/dev-server.js';
|
|
55
|
-
const { DevServer, createDevServer } = devserverModule;
|
|
56
|
-
|
|
57
|
-
export {
|
|
58
|
-
createRagPipeline,
|
|
59
|
-
loadConfig,
|
|
60
|
-
validateRagrc,
|
|
61
|
-
normalizeConfig,
|
|
62
|
-
pluginRegistry,
|
|
63
|
-
logger,
|
|
64
|
-
errorFormatter,
|
|
65
|
-
MultiModalProcessor,
|
|
66
|
-
AdaptiveRetrievalEngine,
|
|
67
|
-
DAGEngine,
|
|
68
|
-
ParallelProcessor,
|
|
69
|
-
eventLogger,
|
|
70
|
-
metrics,
|
|
71
|
-
AuditLogger,
|
|
72
|
-
DataGovernance,
|
|
73
|
-
HotReloadManager,
|
|
74
|
-
createHotReloadManager,
|
|
75
|
-
DevServer,
|
|
76
|
-
createDevServer
|
|
77
|
-
};
|
|
78
|
-
|
|
79
|
-
// Backward compatibility aliases
|
|
80
|
-
export const createPipeline = createRagPipeline;
|
|
13
|
+
export default mod;
|
package/package.json
CHANGED
|
@@ -1,15 +1,15 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devilsdev/rag-pipeline-utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.4.0",
|
|
4
4
|
"description": "A comprehensive enterprise-grade toolkit for building RAG (Retrieval-Augmented Generation) pipelines with advanced AI/ML capabilities",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"type": "commonjs",
|
|
7
7
|
"types": "dist/index.d.ts",
|
|
8
8
|
"exports": {
|
|
9
9
|
".": {
|
|
10
|
+
"types": "./dist/index.d.ts",
|
|
10
11
|
"require": "./dist/index.cjs",
|
|
11
|
-
"import": "./dist/index.mjs"
|
|
12
|
-
"types": "./dist/index.d.ts"
|
|
12
|
+
"import": "./dist/index.mjs"
|
|
13
13
|
},
|
|
14
14
|
"./cli": "./bin/cli.js"
|
|
15
15
|
},
|
|
@@ -22,7 +22,9 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "node scripts/build.js && node scripts/generate-types.js",
|
|
24
24
|
"prepack": "npm run build",
|
|
25
|
-
"
|
|
25
|
+
"docs:validate": "node scripts/validate-docs-examples.js",
|
|
26
|
+
"verify:esm": "node scripts/verify-esm.mjs",
|
|
27
|
+
"prepublishOnly": "npm run lint && npm test && npm run docs:validate && npm run verify:esm",
|
|
26
28
|
"guard:cjs": "node scripts/guard-cjs.js",
|
|
27
29
|
"pretest": "npm run guard:cjs && node scripts/setup.js",
|
|
28
30
|
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --runInBand --config jest.config.js",
|
|
@@ -50,7 +52,7 @@
|
|
|
50
52
|
"watch:lqip": "node docs-site/scripts/watch-images.js",
|
|
51
53
|
"docs:clear": "docusaurus clear --site-dir docs-site",
|
|
52
54
|
"docs:start": "docusaurus start docs-site",
|
|
53
|
-
"docs:build": "
|
|
55
|
+
"docs:build": "cd docs-site && npm run build",
|
|
54
56
|
"docs:serve": "docusaurus serve docs-site",
|
|
55
57
|
"docs:deploy": "docusaurus deploy docs-site",
|
|
56
58
|
"roadmap:close": "node scripts/close-done-roadmap-issues.js",
|
|
@@ -121,6 +123,16 @@
|
|
|
121
123
|
"files": [
|
|
122
124
|
"dist/",
|
|
123
125
|
"src/",
|
|
126
|
+
"!src/mocks/",
|
|
127
|
+
"!src/ai/module-template.js",
|
|
128
|
+
"!src/ai/index-fixed.js",
|
|
129
|
+
"!src/dev/examples/",
|
|
130
|
+
"!src/dev/README.md",
|
|
131
|
+
"!src/utils/examples/",
|
|
132
|
+
"!src/utils/ci/",
|
|
133
|
+
"!src/ci/",
|
|
134
|
+
"!src/scripts/",
|
|
135
|
+
"!src/cli/plugin-marketplace-commands.js",
|
|
124
136
|
"bin/",
|
|
125
137
|
"contracts/",
|
|
126
138
|
".ragrc.schema.json",
|
|
@@ -137,8 +149,8 @@
|
|
|
137
149
|
"devDependencies": {
|
|
138
150
|
"@babel/core": "^7.26.10",
|
|
139
151
|
"@babel/preset-env": "^7.26.9",
|
|
140
|
-
"@docusaurus/core": "
|
|
141
|
-
"@docusaurus/preset-classic": "
|
|
152
|
+
"@docusaurus/core": "3.5.2",
|
|
153
|
+
"@docusaurus/preset-classic": "3.5.2",
|
|
142
154
|
"@octokit/rest": "^21.1.1",
|
|
143
155
|
"@opentelemetry/api": "^1.9.0",
|
|
144
156
|
"@opentelemetry/auto-instrumentations-node": "^0.52.1",
|
|
@@ -159,7 +171,7 @@
|
|
|
159
171
|
"@types/jest": "^29.5.14",
|
|
160
172
|
"acorn": "8.15.0",
|
|
161
173
|
"babel-jest": "^29.7.0",
|
|
162
|
-
"codecov": "
|
|
174
|
+
"codecov": "3.6.2",
|
|
163
175
|
"conventional-changelog-conventionalcommits": "^8.0.0",
|
|
164
176
|
"cross-env": "7.0.3",
|
|
165
177
|
"esbuild": "^0.25.2",
|