@devilsdev/rag-pipeline-utils 2.3.1 → 2.4.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 +94 -480
- 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 +37 -11
- 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
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Configuration checker for RAG Pipeline Diagnostics
|
|
3
|
+
* Checks configuration file existence, validity, and schema compliance
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const fs = require("fs/promises");
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Check configuration issues
|
|
10
|
+
* @param {object} options - Doctor options (must include configPath)
|
|
11
|
+
* @returns {Promise<Array>} Array of configuration issues
|
|
12
|
+
*/
|
|
13
|
+
async function checkConfiguration(options) {
|
|
14
|
+
const issues = [];
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
await fs.access(options.configPath);
|
|
18
|
+
} catch (error) {
|
|
19
|
+
issues.push({
|
|
20
|
+
category: "configuration",
|
|
21
|
+
severity: "error",
|
|
22
|
+
code: "CONFIG_MISSING",
|
|
23
|
+
message: `Configuration file not found: ${options.configPath}`,
|
|
24
|
+
fix: 'Run "rag-pipeline init" to create a configuration file',
|
|
25
|
+
autoFixable: false,
|
|
26
|
+
});
|
|
27
|
+
return issues;
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
try {
|
|
31
|
+
const configContent = await fs.readFile(options.configPath, "utf8");
|
|
32
|
+
const config = JSON.parse(configContent);
|
|
33
|
+
|
|
34
|
+
// Check if config is empty
|
|
35
|
+
if (Object.keys(config).length === 0 || !config.plugins) {
|
|
36
|
+
issues.push({
|
|
37
|
+
category: "configuration",
|
|
38
|
+
severity: "warning",
|
|
39
|
+
code: "CONFIG_EMPTY",
|
|
40
|
+
message: "Configuration file is empty or missing required sections",
|
|
41
|
+
fix: "Add plugin configurations and pipeline settings",
|
|
42
|
+
autoFixable: false,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
|
|
46
|
+
// Validate schema if available
|
|
47
|
+
try {
|
|
48
|
+
const {
|
|
49
|
+
validateEnhancedRagrcSchema,
|
|
50
|
+
} = require("../../config/enhanced-ragrc-schema.js");
|
|
51
|
+
const validation = validateEnhancedRagrcSchema(config);
|
|
52
|
+
if (!validation.valid && validation.errors) {
|
|
53
|
+
validation.errors.forEach((error) => {
|
|
54
|
+
issues.push({
|
|
55
|
+
category: "configuration",
|
|
56
|
+
severity: "error",
|
|
57
|
+
code: "CONFIG_SCHEMA_ERROR",
|
|
58
|
+
message: `Schema validation failed: ${error.instancePath} ${error.message}`,
|
|
59
|
+
fix: "Fix configuration schema errors",
|
|
60
|
+
autoFixable: false,
|
|
61
|
+
});
|
|
62
|
+
});
|
|
63
|
+
}
|
|
64
|
+
} catch (schemaError) {
|
|
65
|
+
// Schema validation not available, skip
|
|
66
|
+
}
|
|
67
|
+
} catch (parseError) {
|
|
68
|
+
issues.push({
|
|
69
|
+
category: "configuration",
|
|
70
|
+
severity: "error",
|
|
71
|
+
code: "CONFIG_INVALID_JSON",
|
|
72
|
+
message: "Configuration file contains invalid JSON syntax",
|
|
73
|
+
fix: `Fix JSON syntax errors in ${options.configPath}`,
|
|
74
|
+
autoFixable: false,
|
|
75
|
+
});
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
return issues;
|
|
79
|
+
}
|
|
80
|
+
|
|
81
|
+
module.exports = { checkConfiguration };
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Dependency checker for RAG Pipeline Diagnostics
|
|
3
|
+
* Checks Node.js version, package.json, and npm dependencies
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const fs = require("fs/promises");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Check dependency issues
|
|
11
|
+
* @param {object} _options - Doctor options (unused but kept for consistent interface)
|
|
12
|
+
* @returns {Promise<Array>} Array of dependency issues
|
|
13
|
+
*/
|
|
14
|
+
async function checkDependencies(_options) {
|
|
15
|
+
const issues = [];
|
|
16
|
+
|
|
17
|
+
// Check Node.js version
|
|
18
|
+
const nodeVersion = process.version;
|
|
19
|
+
const majorVersion = parseInt(nodeVersion.slice(1).split(".")[0]);
|
|
20
|
+
if (majorVersion < 18) {
|
|
21
|
+
issues.push({
|
|
22
|
+
category: "dependencies",
|
|
23
|
+
severity: "error",
|
|
24
|
+
code: "NODE_VERSION_INCOMPATIBLE",
|
|
25
|
+
message: `Node.js version ${nodeVersion} is not supported (required: >=18.0.0)`,
|
|
26
|
+
fix: "Upgrade Node.js to version 18.0.0 or higher",
|
|
27
|
+
autoFixable: false,
|
|
28
|
+
});
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
// Check package.json
|
|
32
|
+
try {
|
|
33
|
+
await fs.access("package.json");
|
|
34
|
+
const packageContent = await fs.readFile("package.json", "utf8");
|
|
35
|
+
const packageJson = JSON.parse(packageContent);
|
|
36
|
+
|
|
37
|
+
if (packageJson.dependencies) {
|
|
38
|
+
for (const [depName, version] of Object.entries(
|
|
39
|
+
packageJson.dependencies,
|
|
40
|
+
)) {
|
|
41
|
+
try {
|
|
42
|
+
await fs.access(path.join("node_modules", depName));
|
|
43
|
+
} catch (error) {
|
|
44
|
+
issues.push({
|
|
45
|
+
category: "dependencies",
|
|
46
|
+
severity: "error",
|
|
47
|
+
code: "NPM_DEPENDENCY_MISSING",
|
|
48
|
+
message: `NPM dependency missing: ${depName}`,
|
|
49
|
+
fix: "Install missing dependencies: npm install",
|
|
50
|
+
autoFixable: true,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
} catch (error) {
|
|
56
|
+
issues.push({
|
|
57
|
+
category: "dependencies",
|
|
58
|
+
severity: "warning",
|
|
59
|
+
code: "PACKAGE_JSON_MISSING",
|
|
60
|
+
message: "package.json not found in current directory",
|
|
61
|
+
fix: "Initialize npm project: npm init",
|
|
62
|
+
autoFixable: false,
|
|
63
|
+
});
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
return issues;
|
|
67
|
+
}
|
|
68
|
+
|
|
69
|
+
module.exports = { checkDependencies };
|
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Environment checker for RAG Pipeline Diagnostics
|
|
3
|
+
* Checks for missing environment variables referenced in configuration
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const fs = require("fs/promises");
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Check environment issues
|
|
10
|
+
* @param {object} options - Doctor options (must include configPath)
|
|
11
|
+
* @returns {Promise<Array>} Array of environment issues
|
|
12
|
+
*/
|
|
13
|
+
async function checkEnvironment(options) {
|
|
14
|
+
const issues = [];
|
|
15
|
+
|
|
16
|
+
try {
|
|
17
|
+
const configContent = await fs.readFile(options.configPath, "utf8");
|
|
18
|
+
const config = JSON.parse(configContent);
|
|
19
|
+
|
|
20
|
+
// Check for missing environment variables
|
|
21
|
+
const configStr = JSON.stringify(config);
|
|
22
|
+
const envVarMatches = configStr.match(/\$\{([^}]+)\}/g);
|
|
23
|
+
if (envVarMatches) {
|
|
24
|
+
envVarMatches.forEach((match) => {
|
|
25
|
+
const envVar = match.slice(2, -1);
|
|
26
|
+
if (!process.env[envVar]) {
|
|
27
|
+
issues.push({
|
|
28
|
+
category: "environment",
|
|
29
|
+
severity: "error",
|
|
30
|
+
code: "ENV_VAR_MISSING",
|
|
31
|
+
message: `Required environment variable missing: ${envVar}`,
|
|
32
|
+
fix: `Set environment variable: export ${envVar}=your_key`,
|
|
33
|
+
autoFixable: false,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
});
|
|
37
|
+
}
|
|
38
|
+
} catch (error) {
|
|
39
|
+
// Config issues handled elsewhere
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
return issues;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
module.exports = { checkEnvironment };
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Performance checker for RAG Pipeline Diagnostics
|
|
3
|
+
* Checks memory usage and configuration file size
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const fs = require("fs/promises");
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Check performance issues
|
|
10
|
+
* @param {object} options - Doctor options (must include configPath)
|
|
11
|
+
* @returns {Promise<Array>} Array of performance issues
|
|
12
|
+
*/
|
|
13
|
+
async function checkPerformance(options) {
|
|
14
|
+
const issues = [];
|
|
15
|
+
|
|
16
|
+
// Check memory usage
|
|
17
|
+
const memUsage = process.memoryUsage();
|
|
18
|
+
const heapUsedMB = Math.round(memUsage.heapUsed / 1024 / 1024);
|
|
19
|
+
if (heapUsedMB > 512) {
|
|
20
|
+
issues.push({
|
|
21
|
+
category: "performance",
|
|
22
|
+
severity: "warning",
|
|
23
|
+
code: "MEMORY_USAGE_HIGH",
|
|
24
|
+
message: `High memory usage detected: ${heapUsedMB}MB used`,
|
|
25
|
+
fix: "Consider reducing batch sizes or enabling streaming",
|
|
26
|
+
autoFixable: false,
|
|
27
|
+
});
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
// Check config file size
|
|
31
|
+
try {
|
|
32
|
+
const stats = await fs.stat(options.configPath);
|
|
33
|
+
const sizeMB = stats.size / 1024 / 1024;
|
|
34
|
+
if (sizeMB > 1) {
|
|
35
|
+
issues.push({
|
|
36
|
+
category: "performance",
|
|
37
|
+
severity: "warning",
|
|
38
|
+
code: "CONFIG_FILE_LARGE",
|
|
39
|
+
message: `Configuration file is unusually large: ${sizeMB.toFixed(1)}MB`,
|
|
40
|
+
fix: "Consider splitting configuration or removing unused sections",
|
|
41
|
+
autoFixable: false,
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
} catch (error) {
|
|
45
|
+
// File doesn't exist, handled elsewhere
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
return issues;
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
module.exports = { checkPerformance };
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Plugin checker for RAG Pipeline Diagnostics
|
|
3
|
+
* Checks plugin availability, version conflicts, and outdated plugins
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const fs = require("fs/promises");
|
|
7
|
+
const path = require("path");
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Check plugin issues
|
|
11
|
+
* @param {object} options - Doctor options (must include configPath)
|
|
12
|
+
* @returns {Promise<Array>} Array of plugin issues
|
|
13
|
+
*/
|
|
14
|
+
async function checkPlugins(options) {
|
|
15
|
+
const issues = [];
|
|
16
|
+
|
|
17
|
+
try {
|
|
18
|
+
// First check if config file exists
|
|
19
|
+
await fs.access(options.configPath);
|
|
20
|
+
|
|
21
|
+
const configContent = await fs.readFile(options.configPath, "utf8");
|
|
22
|
+
const config = JSON.parse(configContent);
|
|
23
|
+
|
|
24
|
+
if (config.plugins) {
|
|
25
|
+
// Process plugins in the order expected by tests: loader first, then embedder
|
|
26
|
+
const categories = ["loader", "embedder"];
|
|
27
|
+
for (const category of categories) {
|
|
28
|
+
if (config.plugins[category]) {
|
|
29
|
+
const plugins = config.plugins[category];
|
|
30
|
+
const sortedPlugins = Object.keys(plugins).sort();
|
|
31
|
+
for (const pluginName of sortedPlugins) {
|
|
32
|
+
try {
|
|
33
|
+
// Check if plugin file exists (simplified check)
|
|
34
|
+
await fs.access(path.join("node_modules", pluginName));
|
|
35
|
+
} catch (error) {
|
|
36
|
+
issues.push({
|
|
37
|
+
category: "plugins",
|
|
38
|
+
severity: "error",
|
|
39
|
+
code: "PLUGIN_MISSING",
|
|
40
|
+
message: `Plugin not found: ${pluginName}`,
|
|
41
|
+
fix: `Install plugin: npm install ${pluginName}`,
|
|
42
|
+
autoFixable: true,
|
|
43
|
+
});
|
|
44
|
+
}
|
|
45
|
+
}
|
|
46
|
+
}
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
// Check for version conflicts
|
|
50
|
+
try {
|
|
51
|
+
const {
|
|
52
|
+
resolvePluginVersions,
|
|
53
|
+
} = require("../../core/plugin-marketplace/version-resolver.js");
|
|
54
|
+
const resolution = await resolvePluginVersions(config.plugins);
|
|
55
|
+
if (resolution.conflicts) {
|
|
56
|
+
resolution.conflicts.forEach((conflict) => {
|
|
57
|
+
issues.push({
|
|
58
|
+
category: "plugins",
|
|
59
|
+
severity: "warning",
|
|
60
|
+
code: "PLUGIN_VERSION_CONFLICT",
|
|
61
|
+
message: `Version conflict: ${conflict.plugin} - ${conflict.conflict}`,
|
|
62
|
+
fix: "Update plugin versions to resolve conflicts",
|
|
63
|
+
autoFixable: false,
|
|
64
|
+
});
|
|
65
|
+
});
|
|
66
|
+
}
|
|
67
|
+
} catch (resolverError) {
|
|
68
|
+
// Version resolver not available, skip
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
// Check for outdated plugins
|
|
72
|
+
try {
|
|
73
|
+
const registryUrl = "https://registry.rag-pipeline.dev";
|
|
74
|
+
const response = await fetch(`${registryUrl}/plugins`);
|
|
75
|
+
if (response.ok) {
|
|
76
|
+
const registry = await response.json();
|
|
77
|
+
for (const [category, plugins] of Object.entries(config.plugins)) {
|
|
78
|
+
for (const [pluginName, version] of Object.entries(plugins)) {
|
|
79
|
+
if (registry.plugins && registry.plugins[pluginName]) {
|
|
80
|
+
const latest = registry.plugins[pluginName].versions.latest;
|
|
81
|
+
if (version !== "latest" && version !== latest) {
|
|
82
|
+
issues.push({
|
|
83
|
+
category: "plugins",
|
|
84
|
+
severity: "info",
|
|
85
|
+
code: "PLUGIN_OUTDATED",
|
|
86
|
+
message: `Plugin outdated: ${pluginName}@${version} (latest: ${latest})`,
|
|
87
|
+
fix: `Update to latest version: rag-pipeline plugin install ${pluginName}@latest`,
|
|
88
|
+
autoFixable: true,
|
|
89
|
+
});
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
} catch (fetchError) {
|
|
96
|
+
// Registry not available, skip
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
} catch (configError) {
|
|
100
|
+
// Config issues handled in checkConfiguration
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
return issues;
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
module.exports = { checkPlugins };
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Security checker for RAG Pipeline Diagnostics
|
|
3
|
+
* Checks for hardcoded API keys and insecure file permissions
|
|
4
|
+
*/
|
|
5
|
+
|
|
6
|
+
const fs = require("fs/promises");
|
|
7
|
+
|
|
8
|
+
/**
|
|
9
|
+
* Check security issues
|
|
10
|
+
* @param {object} options - Doctor options (must include configPath)
|
|
11
|
+
* @returns {Promise<Array>} Array of security issues
|
|
12
|
+
*/
|
|
13
|
+
async function checkSecurity(options) {
|
|
14
|
+
const issues = [];
|
|
15
|
+
|
|
16
|
+
// Check for hardcoded API keys in config content
|
|
17
|
+
try {
|
|
18
|
+
const configContent = await fs.readFile(options.configPath, "utf8");
|
|
19
|
+
const config = JSON.parse(configContent);
|
|
20
|
+
|
|
21
|
+
const configStr = JSON.stringify(config);
|
|
22
|
+
if (
|
|
23
|
+
configStr.includes("sk-") ||
|
|
24
|
+
configStr.includes("apiKey") ||
|
|
25
|
+
configStr.includes("api_key")
|
|
26
|
+
) {
|
|
27
|
+
issues.push({
|
|
28
|
+
category: "security",
|
|
29
|
+
severity: "error",
|
|
30
|
+
code: "HARDCODED_API_KEY",
|
|
31
|
+
message: "Hardcoded API key detected in configuration",
|
|
32
|
+
fix: "Move API keys to environment variables",
|
|
33
|
+
autoFixable: false,
|
|
34
|
+
});
|
|
35
|
+
}
|
|
36
|
+
} catch (configError) {
|
|
37
|
+
// Config reading issues handled elsewhere
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
// Check file permissions (independent of config content)
|
|
41
|
+
try {
|
|
42
|
+
const stats = await fs.stat(options.configPath);
|
|
43
|
+
const mode = stats.mode & 0o777;
|
|
44
|
+
if (mode === 0o777) {
|
|
45
|
+
issues.push({
|
|
46
|
+
category: "security",
|
|
47
|
+
severity: "warning",
|
|
48
|
+
code: "INSECURE_PERMISSIONS",
|
|
49
|
+
message: "Configuration file has insecure permissions (777)",
|
|
50
|
+
fix: `Set secure permissions: chmod 600 ${options.configPath}`,
|
|
51
|
+
autoFixable: true,
|
|
52
|
+
});
|
|
53
|
+
}
|
|
54
|
+
} catch (statError) {
|
|
55
|
+
// File stat issues handled elsewhere
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
return issues;
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
module.exports = { checkSecurity };
|