@devilsdev/rag-pipeline-utils 2.2.1 → 2.3.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +260 -19
- package/contracts/contract-schema.json +189 -0
- package/dist/index.cjs +19 -0
- package/dist/index.mjs +15 -1
- package/package.json +3 -2
- package/src/cli/commands/wizard.js +627 -0
- package/src/cli/input-sanitization-middleware.js +356 -0
- package/src/cli/templates/development.template.json +64 -0
- package/src/cli/templates/minimal.template.json +33 -0
- package/src/cli/templates/production.template.json +104 -0
- package/src/cli/templates/testing.template.json +45 -0
- package/src/config/connection-pool-config.json +259 -0
- package/src/config/memory-optimization.js +414 -0
- package/src/config/redaction-patterns.json +150 -0
- package/src/config/sanitization-rules.json +323 -0
- package/src/core/plugin-registry.js +266 -20
- package/src/dag/core/error-context.js +391 -0
- package/src/dag/core/execution-scheduler.js +350 -0
- package/src/dag/core/topology-validation.js +415 -0
- package/src/dag/dag-engine.js +26 -424
- package/src/dev/README.md +126 -0
- package/src/dev/dev-server.js +356 -0
- package/src/dev/examples/hot-reload-usage.js +355 -0
- package/src/dev/hot-reload.js +807 -0
- package/src/enterprise/sso-integration.js +67 -25
- package/src/index.js +19 -0
- package/src/observability/event-logger.js +62 -2
- package/src/plugins/optimized-openai-embedder.js +169 -0
- package/src/security/jwt-config.js +431 -0
- package/src/security/jwt-validator.js +701 -0
- package/src/utils/api-client-pool-integration.js +436 -0
- package/src/utils/batch-processor.js +710 -0
- package/src/utils/connection-pool.js +605 -0
- package/src/utils/contract-validator.js +460 -0
- package/src/utils/error-formatter.js +603 -0
- package/src/utils/examples/error-formatter-usage.js +351 -0
- package/src/utils/input-sanitizer.js +967 -0
- package/src/utils/memory-monitor.js +800 -0
- package/src/utils/secure-logger-config.js +352 -0
- package/src/utils/secure-logger.js +576 -0
package/README.md
CHANGED
|
@@ -22,7 +22,7 @@ We built this toolkit because we believe infrastructure should be:
|
|
|
22
22
|
|
|
23
23
|
- **Modular** – swap any component without rewriting your pipeline
|
|
24
24
|
- **Observable** – metrics, tracing, and audit logs built in from day one
|
|
25
|
-
- **Secure** –
|
|
25
|
+
- **Secure** – hardened JWT validation with replay protection, multi-layer path traversal defense, and enterprise-grade defaults
|
|
26
26
|
- **Open** – no vendor lock-in, no proprietary APIs, just JavaScript
|
|
27
27
|
|
|
28
28
|
Whether you're prototyping a document Q&A system or scaling a production knowledge base, this toolkit grows with you.
|
|
@@ -61,6 +61,19 @@ Install with:
|
|
|
61
61
|
npm install @devilsdev/rag-pipeline-utils
|
|
62
62
|
```
|
|
63
63
|
|
|
64
|
+
### What's New in v2.3.1 (Released November 8, 2025)
|
|
65
|
+
|
|
66
|
+
**Major Security Enhancements:**
|
|
67
|
+
|
|
68
|
+
- **Advanced JWT replay protection** with self-signed token reusability
|
|
69
|
+
- **Hardened path traversal defense** with iterative URL decoding
|
|
70
|
+
- **Consistent validation behavior** eliminating duplicate checks
|
|
71
|
+
- **Race condition mitigation** in concurrent token verification
|
|
72
|
+
|
|
73
|
+
**All security tests passing:** 113 security-focused tests with 100% coverage on critical paths.
|
|
74
|
+
|
|
75
|
+
[See full security details below](#security-and-quality) | [Migration guide](#upgrading-from-v22x)
|
|
76
|
+
|
|
64
77
|
---
|
|
65
78
|
|
|
66
79
|
## How It Works
|
|
@@ -118,7 +131,7 @@ Complete TypeScript interfaces for all plugin types. Full IDE autocomplete and c
|
|
|
118
131
|
|
|
119
132
|
### Production-Ready Security
|
|
120
133
|
|
|
121
|
-
|
|
134
|
+
Hardened security with defense-in-depth: JWT replay protection with race condition mitigation, multi-layer path traversal defense with iterative URL decoding, validated JSON parsing, algorithm whitelisting, automatic secret redaction, and comprehensive audit logging.
|
|
122
135
|
|
|
123
136
|
### Streaming & Batching
|
|
124
137
|
|
|
@@ -138,10 +151,10 @@ Whether you're implementing a new retriever, writing documentation, reporting bu
|
|
|
138
151
|
|
|
139
152
|
**Getting Started:**
|
|
140
153
|
|
|
141
|
-
-
|
|
142
|
-
-
|
|
143
|
-
-
|
|
144
|
-
-
|
|
154
|
+
- [GitHub Discussions](https://github.com/DevilsDev/rag-pipeline-utils/discussions) – Ask questions, share use cases, propose features
|
|
155
|
+
- [Issue Tracker](https://github.com/DevilsDev/rag-pipeline-utils/issues) – Report bugs or request features
|
|
156
|
+
- [Contributing Guide](https://github.com/DevilsDev/rag-pipeline-utils/blob/main/docs/CONTRIBUTING.md) – Learn how to submit pull requests
|
|
157
|
+
- [Code of Conduct](https://github.com/DevilsDev/rag-pipeline-utils/blob/main/CODE_OF_CONDUCT.md) – Our community standards
|
|
145
158
|
|
|
146
159
|
**Good First Issues:** Look for issues tagged `good first issue` to find beginner-friendly contributions.
|
|
147
160
|
|
|
@@ -153,6 +166,8 @@ Whether you're implementing a new retriever, writing documentation, reporting bu
|
|
|
153
166
|
|
|
154
167
|
Security isn't optional. This toolkit is built with defense in depth:
|
|
155
168
|
|
|
169
|
+
### Core Security Features
|
|
170
|
+
|
|
156
171
|
- **Validated Inputs** – All JSON parsed through schema validation (AJV)
|
|
157
172
|
- **Secure Logging** – Automatic redaction of 36 sensitive field patterns (API keys, JWTs, tokens)
|
|
158
173
|
- **JWT Best Practices** – Algorithm whitelisting, issuer/audience validation, expiration enforcement
|
|
@@ -161,9 +176,101 @@ Security isn't optional. This toolkit is built with defense in depth:
|
|
|
161
176
|
- **Plugin Sandboxing** – Third-party plugins run with declared permissions and resource limits
|
|
162
177
|
- **Supply Chain Security** – All GitHub Actions pinned to commit SHAs, SBOM generation available
|
|
163
178
|
|
|
179
|
+
### Recent Security Enhancements (v2.3.1)
|
|
180
|
+
|
|
181
|
+
#### Hardened JWT Validation
|
|
182
|
+
|
|
183
|
+
**Advanced Replay Protection:**
|
|
184
|
+
|
|
185
|
+
- Self-signed tokens can be verified multiple times (essential for refresh flows and load balancer retries)
|
|
186
|
+
- External tokens are tracked and blocked on replay attempts
|
|
187
|
+
- Race condition mitigation with optimized check-then-set pattern
|
|
188
|
+
- Separate tracking for reusable vs. single-use tokens
|
|
189
|
+
|
|
190
|
+
**Consistent Validation Behavior:**
|
|
191
|
+
|
|
192
|
+
- `strictValidation` flag now consistently controls issuer/audience validation
|
|
193
|
+
- Eliminated duplicate validation logic to prevent configuration confusion
|
|
194
|
+
- Clear separation of concerns: jsonwebtoken handles cryptographic validation, custom logic handles business rules
|
|
195
|
+
|
|
196
|
+
**Example:**
|
|
197
|
+
|
|
198
|
+
```javascript
|
|
199
|
+
const { JWTValidator } = require("@devilsdev/rag-pipeline-utils");
|
|
200
|
+
|
|
201
|
+
const validator = new JWTValidator({
|
|
202
|
+
secret: process.env.JWT_SECRET,
|
|
203
|
+
algorithm: "HS256",
|
|
204
|
+
issuer: "my-app",
|
|
205
|
+
audience: "api-users",
|
|
206
|
+
strictValidation: true, // Enforces iss/aud validation
|
|
207
|
+
enableJtiTracking: true, // Prevents replay attacks
|
|
208
|
+
});
|
|
209
|
+
|
|
210
|
+
// Self-signed tokens can be verified multiple times
|
|
211
|
+
const token = validator.sign({ sub: "user-123" });
|
|
212
|
+
validator.verify(token); // First verification
|
|
213
|
+
validator.verify(token); // Still works (refresh flow)
|
|
214
|
+
|
|
215
|
+
// External tokens are blocked on replay
|
|
216
|
+
const externalToken = getTokenFromThirdParty();
|
|
217
|
+
validator.verify(externalToken); // First use
|
|
218
|
+
validator.verify(externalToken); // Throws "Token replay detected"
|
|
219
|
+
```
|
|
220
|
+
|
|
221
|
+
#### Path Traversal Defense
|
|
222
|
+
|
|
223
|
+
**Multi-Layer Protection:**
|
|
224
|
+
|
|
225
|
+
- Iterative URL decoding (up to 5 passes) to catch sophisticated encoding attacks
|
|
226
|
+
- Detects double-encoded paths: `%252e%252e%252f` → `%2e%2e%2f` → `../`
|
|
227
|
+
- Malformed encoding treated as attack indicator (throws error)
|
|
228
|
+
- Critical security violations always throw, regardless of configuration
|
|
229
|
+
|
|
230
|
+
**Attack Vectors Blocked:**
|
|
231
|
+
|
|
232
|
+
- Standard traversal: `../../../etc/passwd`
|
|
233
|
+
- Windows paths: `..\..\windows\system32`
|
|
234
|
+
- URL encoded: `%2e%2e%2f`, `%2e%2e%5c`
|
|
235
|
+
- Double encoded: `%252e%252e%252f`
|
|
236
|
+
- Mixed encoding: combinations of above
|
|
237
|
+
|
|
238
|
+
**Example:**
|
|
239
|
+
|
|
240
|
+
```javascript
|
|
241
|
+
const { sanitizePath } = require("@devilsdev/rag-pipeline-utils");
|
|
242
|
+
|
|
243
|
+
// Safe paths are normalized
|
|
244
|
+
sanitizePath("docs/README.md"); // Returns: "docs/README.md"
|
|
245
|
+
|
|
246
|
+
// Dangerous paths throw errors
|
|
247
|
+
sanitizePath("../../../etc/passwd"); // Throws
|
|
248
|
+
sanitizePath("%2e%2e%2f%2e%2e%2fpasswd"); // Throws
|
|
249
|
+
sanitizePath("%252e%252e%252fconfig"); // Throws (double-encoded)
|
|
250
|
+
```
|
|
251
|
+
|
|
252
|
+
#### Defense-in-Depth Architecture
|
|
253
|
+
|
|
254
|
+
**Critical Security Errors:**
|
|
255
|
+
|
|
256
|
+
- Path traversal violations **always throw**, even if `throwOnInvalid=false`
|
|
257
|
+
- Object depth limit violations **always throw** to prevent DoS
|
|
258
|
+
- Security-critical operations are prioritized over configuration flexibility
|
|
259
|
+
|
|
260
|
+
**Security Monitoring:**
|
|
261
|
+
|
|
262
|
+
- All blocked attempts tracked in `stats.blocked` counter
|
|
263
|
+
- Audit events emitted for replay detection, algorithm mismatches, and validation failures
|
|
264
|
+
- Structured logging with security event correlation
|
|
265
|
+
|
|
266
|
+
### Quality Metrics
|
|
267
|
+
|
|
164
268
|
**Zero Production Vulnerabilities:** `npm audit --production` returns clean on every release.
|
|
165
269
|
|
|
166
|
-
**Test Coverage:**
|
|
270
|
+
**Test Coverage:** 113 security-focused tests across 2 dedicated security suites:
|
|
271
|
+
|
|
272
|
+
- JWT Validator: 44 tests covering algorithm confusion, replay attacks, and validation edge cases
|
|
273
|
+
- Input Sanitizer: 69 tests covering XSS, SQL injection, command injection, and path traversal
|
|
167
274
|
|
|
168
275
|
**Supported Node Versions:** 18.x, 20.x, 22.x (tested in CI)
|
|
169
276
|
|
|
@@ -216,30 +323,164 @@ npm run benchmark # Performance benchmarks
|
|
|
216
323
|
|
|
217
324
|
## Roadmap
|
|
218
325
|
|
|
219
|
-
### v2.3.
|
|
326
|
+
### v2.3.1 (Released November 8, 2025) ✅
|
|
220
327
|
|
|
221
|
-
- **Enhanced CLI** – Interactive wizard for pipeline setup, validation commands, and migration tools
|
|
222
|
-
- **Plugin Marketplace** – Curated registry of community-contributed plugins with ratings and verification
|
|
223
|
-
- **
|
|
224
|
-
- **
|
|
328
|
+
- ✅ **Enhanced CLI** – Interactive wizard for pipeline setup, validation commands, and migration tools
|
|
329
|
+
- ✅ **Plugin Marketplace** – Curated registry of community-contributed plugins with ratings and verification
|
|
330
|
+
- ✅ **Multi-Tenant Support** – Workspace isolation, resource quotas, and tenant-specific configurations
|
|
331
|
+
- ✅ **Advanced Security** – JWT replay protection and hardened path traversal defense
|
|
225
332
|
|
|
226
|
-
### v2.4.0 (
|
|
333
|
+
### v2.4.0 (Q1 2026)
|
|
227
334
|
|
|
335
|
+
- **Streaming Embeddings** – Real-time embedding generation with backpressure control
|
|
228
336
|
- **GraphRAG Support** – Native knowledge graph integration for entity-relationship retrieval
|
|
229
|
-
- **Federated Learning** – Privacy-preserving model training across distributed datasets
|
|
230
337
|
- **Advanced Reranking** – Cross-encoder models and learned ranking functions
|
|
231
338
|
- **Performance Dashboard** – Web UI for monitoring pipeline health and cost metrics
|
|
232
339
|
|
|
233
|
-
###
|
|
340
|
+
### v2.5.0 (Q2 2026)
|
|
341
|
+
|
|
342
|
+
- **Federated Learning** – Privacy-preserving model training across distributed datasets
|
|
343
|
+
- **Advanced Caching** – Intelligent embedding cache with TTL and invalidation strategies
|
|
344
|
+
- **Multi-Modal Processing** – Native image and audio embedding support
|
|
345
|
+
- **Cost Optimization** – Automatic provider selection based on cost and performance
|
|
346
|
+
|
|
347
|
+
### Beyond 2026
|
|
234
348
|
|
|
235
349
|
- Native Rust bindings for performance-critical paths
|
|
236
350
|
- Kubernetes operator for production deployments
|
|
237
351
|
- Real-time collaboration features for team-based pipelines
|
|
352
|
+
- Edge deployment support for latency-sensitive applications
|
|
238
353
|
|
|
239
354
|
**Vote on features:** Share your priorities in [GitHub Discussions](https://github.com/DevilsDev/rag-pipeline-utils/discussions/categories/roadmap).
|
|
240
355
|
|
|
241
356
|
---
|
|
242
357
|
|
|
358
|
+
## Upgrading from v2.2.x
|
|
359
|
+
|
|
360
|
+
The v2.3.1 release includes important security enhancements that are **100% backward compatible** for most use cases. However, there are a few behavioral changes to be aware of:
|
|
361
|
+
|
|
362
|
+
### JWT Validator Changes
|
|
363
|
+
|
|
364
|
+
#### No Action Required (Recommended Use Case)
|
|
365
|
+
|
|
366
|
+
If you're using the default configuration with `strictValidation: true` (the default), everything works the same:
|
|
367
|
+
|
|
368
|
+
```javascript
|
|
369
|
+
const validator = new JWTValidator({
|
|
370
|
+
secret: process.env.JWT_SECRET,
|
|
371
|
+
algorithm: "HS256",
|
|
372
|
+
issuer: "my-app",
|
|
373
|
+
audience: "api-users",
|
|
374
|
+
// strictValidation defaults to true
|
|
375
|
+
});
|
|
376
|
+
|
|
377
|
+
// Behavior unchanged - tokens validated correctly
|
|
378
|
+
```
|
|
379
|
+
|
|
380
|
+
#### Behavior Change (Advanced Use Case)
|
|
381
|
+
|
|
382
|
+
If you explicitly set `strictValidation: false`, the behavior has changed for consistency:
|
|
383
|
+
|
|
384
|
+
**Before v2.3.0:**
|
|
385
|
+
|
|
386
|
+
```javascript
|
|
387
|
+
const validator = new JWTValidator({
|
|
388
|
+
secret: process.env.JWT_SECRET,
|
|
389
|
+
strictValidation: false,
|
|
390
|
+
issuer: "my-app", // These were still validated
|
|
391
|
+
audience: "api-users", // even with strictValidation=false
|
|
392
|
+
});
|
|
393
|
+
```
|
|
394
|
+
|
|
395
|
+
**After v2.3.0:**
|
|
396
|
+
|
|
397
|
+
```javascript
|
|
398
|
+
const validator = new JWTValidator({
|
|
399
|
+
secret: process.env.JWT_SECRET,
|
|
400
|
+
strictValidation: false,
|
|
401
|
+
issuer: "my-app", // Now properly ignored
|
|
402
|
+
audience: "api-users", // when strictValidation=false
|
|
403
|
+
});
|
|
404
|
+
// issuer/audience validation is now truly disabled
|
|
405
|
+
```
|
|
406
|
+
|
|
407
|
+
**Migration:** If you were relying on the old inconsistent behavior, set `strictValidation: true` explicitly.
|
|
408
|
+
|
|
409
|
+
#### Enhanced Behavior (Self-Signed Tokens)
|
|
410
|
+
|
|
411
|
+
Self-signed tokens can now be verified multiple times, which is essential for:
|
|
412
|
+
|
|
413
|
+
- Refresh token flows
|
|
414
|
+
- Load balancer retries
|
|
415
|
+
- Distributed systems with eventual consistency
|
|
416
|
+
|
|
417
|
+
```javascript
|
|
418
|
+
const token = validator.sign({ sub: "user-123" });
|
|
419
|
+
|
|
420
|
+
// Before v2.3.0: Second verification would throw "replay detected"
|
|
421
|
+
// After v2.3.0: Works correctly for self-signed tokens
|
|
422
|
+
validator.verify(token); // Works
|
|
423
|
+
validator.verify(token); // Now works!
|
|
424
|
+
```
|
|
425
|
+
|
|
426
|
+
External tokens (not signed by your validator) are still correctly blocked on replay.
|
|
427
|
+
|
|
428
|
+
### Input Sanitizer Changes
|
|
429
|
+
|
|
430
|
+
#### Path Traversal Now Always Throws
|
|
431
|
+
|
|
432
|
+
Path traversal attempts now **always throw errors**, even with `throwOnInvalid: false`:
|
|
433
|
+
|
|
434
|
+
**Before v2.3.0:**
|
|
435
|
+
|
|
436
|
+
```javascript
|
|
437
|
+
const sanitizer = new InputSanitizer({ throwOnInvalid: false });
|
|
438
|
+
const result = sanitizePath("../../../etc/passwd");
|
|
439
|
+
// Returned: null (silent failure)
|
|
440
|
+
```
|
|
441
|
+
|
|
442
|
+
**After v2.3.0:**
|
|
443
|
+
|
|
444
|
+
```javascript
|
|
445
|
+
const sanitizer = new InputSanitizer({ throwOnInvalid: false });
|
|
446
|
+
const result = sanitizePath("../../../etc/passwd");
|
|
447
|
+
// Throws: "Potential path traversal detected"
|
|
448
|
+
```
|
|
449
|
+
|
|
450
|
+
**Rationale:** Path traversal is a critical security violation that should never be silently ignored.
|
|
451
|
+
|
|
452
|
+
**Migration:** Wrap path sanitization in try-catch if you need to handle errors gracefully:
|
|
453
|
+
|
|
454
|
+
```javascript
|
|
455
|
+
try {
|
|
456
|
+
const safePath = sanitizePath(userInput);
|
|
457
|
+
// Use safePath
|
|
458
|
+
} catch (error) {
|
|
459
|
+
if (error.message.includes("path traversal")) {
|
|
460
|
+
// Handle attack attempt
|
|
461
|
+
logger.warn("Path traversal blocked", { input: userInput });
|
|
462
|
+
return res.status(400).json({ error: "Invalid path" });
|
|
463
|
+
}
|
|
464
|
+
throw error;
|
|
465
|
+
}
|
|
466
|
+
```
|
|
467
|
+
|
|
468
|
+
### Breaking Changes
|
|
469
|
+
|
|
470
|
+
**None.** All changes are security enhancements that improve correctness without breaking existing valid use cases.
|
|
471
|
+
|
|
472
|
+
### Testing Your Upgrade
|
|
473
|
+
|
|
474
|
+
Run your test suite after upgrading:
|
|
475
|
+
|
|
476
|
+
```bash
|
|
477
|
+
npm test
|
|
478
|
+
```
|
|
479
|
+
|
|
480
|
+
If you encounter issues, please [open an issue](https://github.com/DevilsDev/rag-pipeline-utils/issues) with details about your configuration.
|
|
481
|
+
|
|
482
|
+
---
|
|
483
|
+
|
|
243
484
|
## Contributing
|
|
244
485
|
|
|
245
486
|
We welcome contributions of all kinds:
|
|
@@ -277,10 +518,10 @@ This is free software: you are free to change and redistribute it under the term
|
|
|
277
518
|
|
|
278
519
|
## What's Next?
|
|
279
520
|
|
|
280
|
-
|
|
521
|
+
**Star this repository** if you find it useful—it helps others discover the project.
|
|
281
522
|
|
|
282
|
-
|
|
523
|
+
**Share your use case** in [Discussions](https://github.com/DevilsDev/rag-pipeline-utils/discussions/categories/show-and-tell) to inspire the community.
|
|
283
524
|
|
|
284
|
-
|
|
525
|
+
**Contribute** your first pull request—check out issues tagged [good first issue](https://github.com/DevilsDev/rag-pipeline-utils/labels/good%20first%20issue).
|
|
285
526
|
|
|
286
|
-
Happy building.
|
|
527
|
+
Happy building.
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
{
|
|
2
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
3
|
+
"$id": "https://github.com/devilsdev/rag-pipeline-utils/schemas/contract.json",
|
|
4
|
+
"title": "Plugin Contract Schema",
|
|
5
|
+
"description": "Schema for validating plugin contract specifications in the RAG pipeline utilities",
|
|
6
|
+
"type": "object",
|
|
7
|
+
"required": [
|
|
8
|
+
"type",
|
|
9
|
+
"version",
|
|
10
|
+
"title",
|
|
11
|
+
"description",
|
|
12
|
+
"methods",
|
|
13
|
+
"properties",
|
|
14
|
+
"required"
|
|
15
|
+
],
|
|
16
|
+
"properties": {
|
|
17
|
+
"$schema": {
|
|
18
|
+
"type": "string",
|
|
19
|
+
"description": "JSON Schema specification URI"
|
|
20
|
+
},
|
|
21
|
+
"type": {
|
|
22
|
+
"type": "string",
|
|
23
|
+
"description": "Plugin type identifier",
|
|
24
|
+
"enum": [
|
|
25
|
+
"loader",
|
|
26
|
+
"embedder",
|
|
27
|
+
"retriever",
|
|
28
|
+
"llm",
|
|
29
|
+
"reranker",
|
|
30
|
+
"evaluator"
|
|
31
|
+
]
|
|
32
|
+
},
|
|
33
|
+
"version": {
|
|
34
|
+
"type": "string",
|
|
35
|
+
"description": "Contract version (semantic versioning)",
|
|
36
|
+
"pattern": "^\\d+\\.\\d+\\.\\d+$"
|
|
37
|
+
},
|
|
38
|
+
"title": {
|
|
39
|
+
"type": "string",
|
|
40
|
+
"description": "Human-readable contract title",
|
|
41
|
+
"minLength": 1
|
|
42
|
+
},
|
|
43
|
+
"description": {
|
|
44
|
+
"type": "string",
|
|
45
|
+
"description": "Contract description",
|
|
46
|
+
"minLength": 1
|
|
47
|
+
},
|
|
48
|
+
"methods": {
|
|
49
|
+
"type": "array",
|
|
50
|
+
"description": "Array of method specifications",
|
|
51
|
+
"minItems": 1,
|
|
52
|
+
"items": {
|
|
53
|
+
"type": "object",
|
|
54
|
+
"required": ["name", "parameters", "returns"],
|
|
55
|
+
"properties": {
|
|
56
|
+
"name": {
|
|
57
|
+
"type": "string",
|
|
58
|
+
"description": "Method name",
|
|
59
|
+
"pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$"
|
|
60
|
+
},
|
|
61
|
+
"parameters": {
|
|
62
|
+
"type": "array",
|
|
63
|
+
"description": "Method parameter names",
|
|
64
|
+
"items": {
|
|
65
|
+
"type": "string",
|
|
66
|
+
"pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$"
|
|
67
|
+
}
|
|
68
|
+
},
|
|
69
|
+
"returns": {
|
|
70
|
+
"type": "string",
|
|
71
|
+
"description": "Return type description",
|
|
72
|
+
"minLength": 1
|
|
73
|
+
}
|
|
74
|
+
},
|
|
75
|
+
"additionalProperties": false
|
|
76
|
+
}
|
|
77
|
+
},
|
|
78
|
+
"properties": {
|
|
79
|
+
"type": "object",
|
|
80
|
+
"description": "Detailed method property specifications",
|
|
81
|
+
"minProperties": 1,
|
|
82
|
+
"patternProperties": {
|
|
83
|
+
"^[a-zA-Z_][a-zA-Z0-9_]*$": {
|
|
84
|
+
"type": "object",
|
|
85
|
+
"required": ["type", "description"],
|
|
86
|
+
"properties": {
|
|
87
|
+
"type": {
|
|
88
|
+
"type": "string",
|
|
89
|
+
"description": "Property type",
|
|
90
|
+
"enum": [
|
|
91
|
+
"function",
|
|
92
|
+
"string",
|
|
93
|
+
"number",
|
|
94
|
+
"boolean",
|
|
95
|
+
"object",
|
|
96
|
+
"array"
|
|
97
|
+
]
|
|
98
|
+
},
|
|
99
|
+
"description": {
|
|
100
|
+
"type": "string",
|
|
101
|
+
"description": "Property description",
|
|
102
|
+
"minLength": 1
|
|
103
|
+
},
|
|
104
|
+
"parameters": {
|
|
105
|
+
"type": "object",
|
|
106
|
+
"description": "Parameter schema (for function properties)",
|
|
107
|
+
"properties": {
|
|
108
|
+
"type": {
|
|
109
|
+
"const": "object"
|
|
110
|
+
},
|
|
111
|
+
"properties": {
|
|
112
|
+
"type": "object"
|
|
113
|
+
},
|
|
114
|
+
"required": {
|
|
115
|
+
"type": "array",
|
|
116
|
+
"items": {
|
|
117
|
+
"type": "string"
|
|
118
|
+
}
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
},
|
|
122
|
+
"returns": {
|
|
123
|
+
"type": "object",
|
|
124
|
+
"description": "Return value schema (for function properties)"
|
|
125
|
+
}
|
|
126
|
+
},
|
|
127
|
+
"additionalProperties": true
|
|
128
|
+
}
|
|
129
|
+
},
|
|
130
|
+
"additionalProperties": false
|
|
131
|
+
},
|
|
132
|
+
"required": {
|
|
133
|
+
"type": "array",
|
|
134
|
+
"description": "List of required methods",
|
|
135
|
+
"minItems": 1,
|
|
136
|
+
"items": {
|
|
137
|
+
"type": "string",
|
|
138
|
+
"pattern": "^[a-zA-Z_][a-zA-Z0-9_]*$"
|
|
139
|
+
},
|
|
140
|
+
"uniqueItems": true
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
"additionalProperties": false,
|
|
144
|
+
"examples": [
|
|
145
|
+
{
|
|
146
|
+
"$schema": "http://json-schema.org/draft-07/schema#",
|
|
147
|
+
"type": "loader",
|
|
148
|
+
"version": "1.0.0",
|
|
149
|
+
"title": "Loader Contract",
|
|
150
|
+
"description": "Contract for loader plugins",
|
|
151
|
+
"methods": [
|
|
152
|
+
{
|
|
153
|
+
"name": "load",
|
|
154
|
+
"parameters": ["source"],
|
|
155
|
+
"returns": "documents"
|
|
156
|
+
}
|
|
157
|
+
],
|
|
158
|
+
"properties": {
|
|
159
|
+
"load": {
|
|
160
|
+
"type": "function",
|
|
161
|
+
"description": "Load documents from source",
|
|
162
|
+
"parameters": {
|
|
163
|
+
"type": "object",
|
|
164
|
+
"properties": {
|
|
165
|
+
"source": {
|
|
166
|
+
"type": "string",
|
|
167
|
+
"description": "Source path or identifier"
|
|
168
|
+
}
|
|
169
|
+
},
|
|
170
|
+
"required": ["source"]
|
|
171
|
+
},
|
|
172
|
+
"returns": {
|
|
173
|
+
"type": "array",
|
|
174
|
+
"items": {
|
|
175
|
+
"type": "object",
|
|
176
|
+
"properties": {
|
|
177
|
+
"id": { "type": "string" },
|
|
178
|
+
"content": { "type": "string" },
|
|
179
|
+
"metadata": { "type": "object" }
|
|
180
|
+
},
|
|
181
|
+
"required": ["id", "content"]
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
}
|
|
185
|
+
},
|
|
186
|
+
"required": ["load"]
|
|
187
|
+
}
|
|
188
|
+
]
|
|
189
|
+
}
|
package/dist/index.cjs
CHANGED
|
@@ -16,6 +16,7 @@ const pluginRegistry = require('../src/core/plugin-registry');
|
|
|
16
16
|
|
|
17
17
|
// Utilities
|
|
18
18
|
const logger = require('../src/utils/logger');
|
|
19
|
+
const errorFormatter = require('../src/utils/error-formatter');
|
|
19
20
|
|
|
20
21
|
// AI/ML capabilities
|
|
21
22
|
const MultiModalProcessor = require('../src/ai/multimodal');
|
|
@@ -33,6 +34,13 @@ const metrics = require('../src/core/observability/metrics');
|
|
|
33
34
|
const { AuditLogger } = require('../src/enterprise/audit-logging');
|
|
34
35
|
const { DataGovernance } = require('../src/enterprise/data-governance');
|
|
35
36
|
|
|
37
|
+
// Development tools
|
|
38
|
+
const {
|
|
39
|
+
HotReloadManager,
|
|
40
|
+
createHotReloadManager,
|
|
41
|
+
} = require('../src/dev/hot-reload');
|
|
42
|
+
const { DevServer, createDevServer } = require('../src/dev/dev-server');
|
|
43
|
+
|
|
36
44
|
module.exports = {
|
|
37
45
|
// Core API
|
|
38
46
|
createRagPipeline,
|
|
@@ -48,6 +56,11 @@ module.exports = {
|
|
|
48
56
|
|
|
49
57
|
// Utilities
|
|
50
58
|
logger,
|
|
59
|
+
errorFormatter,
|
|
60
|
+
// Error handling utilities
|
|
61
|
+
createError: errorFormatter.createError,
|
|
62
|
+
wrapError: errorFormatter.wrapError,
|
|
63
|
+
ERROR_CODES: errorFormatter.ERROR_CODES,
|
|
51
64
|
|
|
52
65
|
// AI/ML
|
|
53
66
|
MultiModalProcessor,
|
|
@@ -64,4 +77,10 @@ module.exports = {
|
|
|
64
77
|
// Enterprise
|
|
65
78
|
AuditLogger,
|
|
66
79
|
DataGovernance,
|
|
80
|
+
|
|
81
|
+
// Development tools
|
|
82
|
+
HotReloadManager,
|
|
83
|
+
createHotReloadManager,
|
|
84
|
+
DevServer,
|
|
85
|
+
createDevServer,
|
|
67
86
|
};
|
package/dist/index.mjs
CHANGED
|
@@ -25,6 +25,7 @@ import pluginRegistry from '../src/core/plugin-registry.js';
|
|
|
25
25
|
|
|
26
26
|
// Utilities
|
|
27
27
|
import logger from '../src/utils/logger.js';
|
|
28
|
+
import errorFormatter from '../src/utils/error-formatter.js';
|
|
28
29
|
|
|
29
30
|
// AI/ML capabilities
|
|
30
31
|
import MultiModalProcessor from '../src/ai/multimodal.js';
|
|
@@ -45,6 +46,14 @@ const { AuditLogger } = auditloggingModule;
|
|
|
45
46
|
import datagovernanceModule from '../src/enterprise/data-governance.js';
|
|
46
47
|
const { DataGovernance } = datagovernanceModule;
|
|
47
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
|
+
|
|
48
57
|
export {
|
|
49
58
|
createRagPipeline,
|
|
50
59
|
loadConfig,
|
|
@@ -52,6 +61,7 @@ export {
|
|
|
52
61
|
normalizeConfig,
|
|
53
62
|
pluginRegistry,
|
|
54
63
|
logger,
|
|
64
|
+
errorFormatter,
|
|
55
65
|
MultiModalProcessor,
|
|
56
66
|
AdaptiveRetrievalEngine,
|
|
57
67
|
DAGEngine,
|
|
@@ -59,7 +69,11 @@ export {
|
|
|
59
69
|
eventLogger,
|
|
60
70
|
metrics,
|
|
61
71
|
AuditLogger,
|
|
62
|
-
DataGovernance
|
|
72
|
+
DataGovernance,
|
|
73
|
+
HotReloadManager,
|
|
74
|
+
createHotReloadManager,
|
|
75
|
+
DevServer,
|
|
76
|
+
createDevServer
|
|
63
77
|
};
|
|
64
78
|
|
|
65
79
|
// Backward compatibility aliases
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@devilsdev/rag-pipeline-utils",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.3.1",
|
|
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",
|
|
@@ -22,7 +22,7 @@
|
|
|
22
22
|
"scripts": {
|
|
23
23
|
"build": "node scripts/build.js && node scripts/generate-types.js",
|
|
24
24
|
"prepack": "npm run build",
|
|
25
|
-
"prepublishOnly": "
|
|
25
|
+
"prepublishOnly": "npm run lint && npm test",
|
|
26
26
|
"guard:cjs": "node scripts/guard-cjs.js",
|
|
27
27
|
"pretest": "npm run guard:cjs && node scripts/setup.js",
|
|
28
28
|
"test": "cross-env NODE_OPTIONS=--experimental-vm-modules jest --runInBand --config jest.config.js",
|
|
@@ -186,6 +186,7 @@
|
|
|
186
186
|
"ajv": "^8.17.1",
|
|
187
187
|
"axios": "^1.8.4",
|
|
188
188
|
"chalk": "^5.4.1",
|
|
189
|
+
"chokidar": "^4.0.3",
|
|
189
190
|
"commander": "^13.1.0",
|
|
190
191
|
"csv-parse": "^5.6.0",
|
|
191
192
|
"dotenv": "^16.5.0",
|