@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.
- package/.ragrc.schema.json +83 -192
- package/CHANGELOG.md +431 -0
- package/README.md +418 -117
- package/SECURITY.md +5 -5
- package/dist/experimental.cjs +2 -0
- package/dist/experimental.d.ts +1 -0
- package/dist/experimental.mjs +5 -0
- package/dist/index.cjs +6442 -1355
- package/dist/index.d.ts +129 -2
- package/dist/index.mjs +1 -1
- package/dist/testing.cjs +2 -0
- package/dist/testing.d.ts +1 -0
- package/dist/testing.mjs +5 -0
- package/dist/types/adapters/ai-sdk.d.ts +53 -0
- package/dist/types/agentic/agentic-pipeline.d.ts +103 -0
- package/dist/types/agentic/iterative-retriever.d.ts +85 -0
- package/dist/types/agentic/query-planner.d.ts +145 -0
- package/dist/types/agentic/self-critique.d.ts +45 -0
- package/dist/types/ai/adaptive-retrieval.d.ts +44 -0
- package/dist/types/ai/federation/federated-learning-coordinator.d.ts +62 -0
- package/dist/types/ai/multimodal-processing.d.ts +32 -0
- package/dist/types/ai/multimodal.d.ts +39 -0
- package/dist/types/ai/retrieval-engine.d.ts +37 -0
- package/dist/types/ai/training/model-training-orchestrator.d.ts +31 -0
- package/dist/types/cache/component-keys.d.ts +7 -0
- package/dist/types/cache/memory-cache.d.ts +54 -0
- package/dist/types/cache/pipeline-cache.d.ts +66 -0
- package/dist/types/cache/redis-cache.d.ts +46 -0
- package/dist/types/chunking/chunking-engine.d.ts +70 -0
- package/dist/types/chunking/strategies/fixed-size.d.ts +17 -0
- package/dist/types/chunking/strategies/recursive.d.ts +20 -0
- package/dist/types/chunking/strategies/semantic.d.ts +19 -0
- package/dist/types/chunking/strategies/sentence.d.ts +13 -0
- package/dist/types/chunking/strategies/structure-aware.d.ts +19 -0
- package/dist/types/citation/citation-tracker.d.ts +64 -0
- package/dist/types/citation/hallucination-detector.d.ts +40 -0
- package/dist/types/citation/source-mapper.d.ts +37 -0
- package/dist/types/connectors/anthropic-connector.d.ts +97 -0
- package/dist/types/connectors/base-connector.d.ts +87 -0
- package/dist/types/connectors/cohere-connector.d.ts +94 -0
- package/dist/types/connectors/connector-utils.d.ts +110 -0
- package/dist/types/connectors/local-embedder.d.ts +95 -0
- package/dist/types/connectors/memory-retriever.d.ts +99 -0
- package/dist/types/connectors/ollama-connector.d.ts +115 -0
- package/dist/types/connectors/openai-connector.d.ts +129 -0
- package/dist/types/connectors/rag-prompt.d.ts +40 -0
- package/dist/types/core/create-pipeline.d.ts +8 -0
- package/dist/types/core/plugin-registry.d.ts +136 -0
- package/dist/types/core/stage-contracts.d.ts +36 -0
- package/dist/types/core/validate-plugin.d.ts +45 -0
- package/dist/types/cost/cost-calculator.d.ts +152 -0
- package/dist/types/cost/cost-tracker.d.ts +126 -0
- package/dist/types/cost/token-budget.d.ts +110 -0
- package/dist/types/dag/core/error-context.d.ts +239 -0
- package/dist/types/dag/core/execution-scheduler.d.ts +191 -0
- package/dist/types/dag/core/topology-validation.d.ts +226 -0
- package/dist/types/dag/dag-engine.d.ts +156 -0
- package/dist/types/dag/dag-node.d.ts +37 -0
- package/dist/types/dashboard/dashboard-generator.d.ts +127 -0
- package/dist/types/dashboard/metrics-aggregator.d.ts +218 -0
- package/dist/types/debug/execution-tracer.d.ts +57 -0
- package/dist/types/debug/trace-inspector.d.ts +31 -0
- package/dist/types/ecosystem/plugin-certification.d.ts +169 -0
- package/dist/types/enterprise/data-governance.d.ts +203 -0
- package/dist/types/enterprise/multi-tenancy.d.ts +137 -0
- package/dist/types/enterprise/sso-integration.d.ts +420 -0
- package/dist/types/evaluate/context-metrics.d.ts +55 -0
- package/dist/types/evaluate/faithfulness.d.ts +41 -0
- package/dist/types/evaluate/groundedness.d.ts +60 -0
- package/dist/types/evaluate/pipeline-evaluator.d.ts +88 -0
- package/dist/types/evaluate/relevance.d.ts +21 -0
- package/dist/types/evaluate/scoring.d.ts +123 -0
- package/dist/types/evaluate/semantic-similarity.d.ts +14 -0
- package/dist/types/experimental.d.ts +15 -0
- package/dist/types/graph/entity-extractor.d.ts +84 -0
- package/dist/types/graph/graph-index.d.ts +49 -0
- package/dist/types/graph/graph-retriever.d.ts +81 -0
- package/dist/types/graph/knowledge-graph.d.ts +129 -0
- package/dist/types/grounding/check-answer.d.ts +101 -0
- package/dist/types/guardrails/guardrails-pipeline.d.ts +63 -0
- package/dist/types/guardrails/injection-detector.d.ts +47 -0
- package/dist/types/guardrails/post-generation-guard.d.ts +61 -0
- package/dist/types/guardrails/pre-retrieval-guard.d.ts +64 -0
- package/dist/types/guardrails/retrieval-guard.d.ts +57 -0
- package/dist/types/mcp/mcp-server.d.ts +85 -0
- package/dist/types/mcp/mcp-tool-builder.d.ts +55 -0
- package/dist/types/reranker/cascade-reranker.d.ts +40 -0
- package/dist/types/reranker/embedding-reranker.d.ts +77 -0
- package/dist/types/reranker/scoring-reranker.d.ts +41 -0
- package/dist/types/retrieval/bm25-search.d.ts +43 -0
- package/dist/types/retrieval/file-vector-store.d.ts +99 -0
- package/dist/types/retrieval/hybrid-retriever.d.ts +35 -0
- package/dist/types/retrieval/rank-fusion.d.ts +10 -0
- package/dist/types/security/jwt-config.d.ts +80 -0
- package/dist/types/security/jwt-validator.d.ts +195 -0
- package/dist/types/security/plugin-sandbox.d.ts +158 -0
- package/dist/types/security/plugin-signature-verifier.d.ts +139 -0
- package/dist/types/security/validator.d.ts +5 -0
- package/dist/types/streaming/embedding-stream.d.ts +65 -0
- package/dist/types/streaming/sse-adapter.d.ts +59 -0
- package/dist/types/streaming/stream-router.d.ts +88 -0
- package/dist/types/streaming/streaming-embedder.d.ts +99 -0
- package/dist/types/streaming/websocket-adapter.d.ts +71 -0
- package/dist/types/templates/scaffold.d.ts +55 -0
- package/dist/types/templates/template-registry.d.ts +63 -0
- package/dist/types/testing.d.ts +168 -0
- package/dist/types/utils/embed-query.d.ts +20 -0
- package/dist/types/utils/logger.d.ts +50 -0
- package/dist/types/utils/rate-limiter.d.ts +66 -0
- package/dist/types/utils/retry.d.ts +27 -0
- package/dist/types/utils/run-abort.d.ts +34 -0
- package/dist/types/utils/secure-logging.d.ts +51 -0
- package/dist/types/utils/structured-logger.d.ts +126 -0
- package/package.json +72 -33
- package/src/adapters/ai-sdk.js +215 -0
- package/src/agentic/agentic-pipeline.js +75 -7
- package/src/agentic/iterative-retriever.js +47 -10
- package/src/agentic/query-planner.js +329 -78
- package/src/cache/component-keys.js +38 -0
- package/src/cache/memory-cache.js +87 -0
- package/src/cache/pipeline-cache.js +260 -0
- package/src/cache/redis-cache.js +83 -0
- package/src/citation/citation-tracker.js +6 -4
- package/src/citation/hallucination-detector.js +2 -2
- package/src/citation/source-mapper.js +15 -28
- package/src/cli/commands/ai.js +106 -0
- package/src/cli/commands/plugin-hub/event-handlers.js +6 -0
- package/src/cli/commands/plugin-hub/hub-commands.js +0 -74
- package/src/cli/commands/plugin-hub/local-commands.js +143 -0
- package/src/cli/commands/plugin-hub.js +114 -49
- package/src/cli/diagnostics/config-checker.js +76 -63
- package/src/cli/diagnostics/environment-checker.js +62 -31
- package/src/cli/diagnostics/plugin-checker.js +36 -89
- package/src/cli/doctor-command.js +39 -5
- package/src/cli/enhanced-cli-commands.js +104 -233
- package/src/cli/handlers/ai-handler.js +364 -0
- package/src/cli/handlers/diagnostics-handler.js +78 -31
- package/src/cli/handlers/ingest-handler.js +28 -22
- package/src/cli/handlers/init-handler.js +148 -25
- package/src/cli/handlers/query-handler.js +203 -25
- package/src/cli/handlers/run-handler.js +16 -167
- package/src/cli/handlers/serve-handler.js +60 -0
- package/src/cli/services/bench-stats.js +54 -0
- package/src/cli/services/benchmark.js +161 -0
- package/src/cli/services/feedback.js +155 -0
- package/src/cli/services/instrument.js +83 -0
- package/src/cli/services/rag-service.js +361 -0
- package/src/cli/shared/cli-utils.js +24 -7
- package/src/cli/shared/config-context.js +21 -0
- package/src/cli/wizard/config-builder.js +81 -0
- package/src/cli/wizard/init-wizard.js +602 -0
- package/src/config/component-factory.js +125 -0
- package/src/config/enhanced-ragrc-schema.js +0 -2
- package/src/config/load-config.js +29 -10
- package/src/config/load-plugin-config.js +46 -2
- package/src/config/validate-schema.js +4 -1
- package/src/connectors/anthropic-connector.js +115 -57
- package/src/connectors/base-connector.js +74 -19
- package/src/connectors/cohere-connector.js +108 -34
- package/src/connectors/connector-utils.js +302 -0
- package/src/connectors/local-embedder.js +63 -5
- package/src/connectors/memory-retriever.js +125 -14
- package/src/connectors/ollama-connector.js +112 -51
- package/src/connectors/openai-connector.js +153 -44
- package/src/connectors/rag-prompt.js +88 -0
- package/src/core/create-pipeline.js +307 -61
- package/src/core/performance/parallel-processor.js +62 -1
- package/src/core/plugin-registry.js +125 -26
- package/src/core/stage-contracts.js +36 -0
- package/src/core/validate-plugin.js +85 -0
- package/src/cost/cost-calculator.js +205 -32
- package/src/debug/execution-tracer.js +14 -4
- package/src/dev/dev-server.js +173 -11
- package/src/dev/hot-reload.js +44 -4
- package/src/ecosystem/plugin-checks.js +181 -0
- package/src/ecosystem/plugin-hub.js +50 -125
- package/src/ecosystem/plugin-installer.js +298 -0
- package/src/ecosystem/plugin-probe.js +127 -0
- package/src/ecosystem/plugin-scanner.js +185 -0
- package/src/ecosystem/tar-extract.js +114 -0
- package/src/enterprise/audit-logging.js +158 -29
- package/src/enterprise/sso-integration.js +716 -228
- package/src/evaluate/context-metrics.js +28 -16
- package/src/evaluate/evaluator.js +3 -3
- package/src/evaluate/faithfulness.js +18 -14
- package/src/evaluate/groundedness.js +43 -12
- package/src/evaluate/pipeline-evaluator.js +35 -8
- package/src/evaluate/scoring.js +251 -3
- package/src/evaluate/semantic-similarity.js +79 -0
- package/src/experimental.js +71 -0
- package/src/grounding/check-answer.js +173 -0
- package/src/guardrails/guardrails-pipeline.js +69 -7
- package/src/guardrails/injection-detector.js +283 -0
- package/src/guardrails/post-generation-guard.js +19 -0
- package/src/guardrails/pre-retrieval-guard.js +36 -36
- package/src/guardrails/retrieval-guard.js +58 -8
- package/src/index.js +58 -1
- package/src/loader/csv-loader.js +3 -2
- package/src/loader/document-reader.js +91 -0
- package/src/loader/html-loader.js +3 -1
- package/src/loader/markdown-loader.js +3 -2
- package/src/reranker/cascade-reranker.js +3 -0
- package/src/reranker/embedding-reranker.js +136 -21
- package/src/reranker/llm-reranker.js +79 -12
- package/src/reranker/scoring-reranker.js +3 -0
- package/src/retrieval/bm25-search.js +12 -6
- package/src/retrieval/file-vector-store.js +241 -0
- package/src/retrieval/hybrid-retriever.js +22 -19
- package/src/security/jwt-config.js +13 -2
- package/src/security/jwt-validator.js +139 -34
- package/src/security/plugin-sandbox.js +18 -1
- package/src/security/plugin-signature-verifier.js +245 -70
- package/src/testing.js +254 -0
- package/src/utils/deprecate.js +69 -0
- package/src/utils/embed-query.js +33 -0
- package/src/utils/input-sanitizer.js +19 -4
- package/src/utils/logger.js +34 -4
- package/src/utils/run-abort.js +102 -0
- package/src/ai/federated-learning.js +0 -211
- package/src/ai/federation.js +0 -71
- package/src/ai/index.js +0 -22
- package/src/ai/model-trainer.js +0 -217
- package/src/ai/model-training.js +0 -202
- package/src/ai/multimodal/multi-modal-processor.js +0 -345
- package/src/ai/orchestrator.js +0 -65
- package/src/ai/retrieval/adaptive-retrieval-engine.js +0 -398
- package/src/cli/commands/ai-ml/adaptive-commands.js +0 -178
- package/src/cli/commands/ai-ml/federated-commands.js +0 -207
- package/src/cli/commands/ai-ml/index.js +0 -17
- package/src/cli/commands/ai-ml/multimodal-commands.js +0 -187
- package/src/cli/commands/ai-ml/shared.js +0 -51
- package/src/cli/commands/ai-ml/training-commands.js +0 -228
- package/src/cli/commands/ai-ml.js +0 -386
- package/src/cli/commands/docs.js +0 -228
- package/src/cli/commands/dx.js +0 -538
- package/src/cli/commands/wizard.js +0 -627
- package/src/cli/input-sanitization-middleware.js +0 -356
- package/src/cli/interactive-wizard.js +0 -373
- package/src/cli/templates/development.template.json +0 -64
- package/src/cli/templates/minimal.template.json +0 -33
- package/src/cli/templates/production.template.json +0 -104
- package/src/cli/templates/testing.template.json +0 -45
- package/src/cli/wizard/configuration.js +0 -148
- package/src/cli/wizard/observability.js +0 -79
- package/src/cli/wizard/performance.js +0 -76
- package/src/cli/wizard/plugin-selection.js +0 -297
- package/src/cli/wizard/preview-save.js +0 -172
- package/src/cli/wizard/project-setup.js +0 -66
- package/src/core/pipeline-factory.js +0 -59
- package/src/dag/enhanced-dag-engine.js +0 -894
- package/src/dx/index.js +0 -40
- package/src/dx/integration-templates.js +0 -662
- package/src/dx/performance-profiler.js +0 -968
- package/src/dx/realtime-debugger.js +0 -755
- package/src/dx/visual-pipeline-builder.js +0 -578
- package/src/ingest.js +0 -59
- package/src/pipeline/pipeline.js +0 -18
- package/src/query.js +0 -117
|
@@ -0,0 +1,127 @@
|
|
|
1
|
+
export type DashboardGeneratorConfig = {
|
|
2
|
+
/**
|
|
3
|
+
* - Dashboard title (default: 'RAG Pipeline Dashboard')
|
|
4
|
+
*/
|
|
5
|
+
title: string;
|
|
6
|
+
/**
|
|
7
|
+
* - Auto-refresh interval in ms (default: 5000)
|
|
8
|
+
*/
|
|
9
|
+
refreshInterval: number;
|
|
10
|
+
/**
|
|
11
|
+
* - Color theme (default: 'dark')
|
|
12
|
+
*/
|
|
13
|
+
theme: "dark" | "light";
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Generates standalone HTML dashboards from pipeline metrics snapshots.
|
|
17
|
+
* @extends EventEmitter
|
|
18
|
+
*/
|
|
19
|
+
export class DashboardGenerator extends EventEmitter<[never]> {
|
|
20
|
+
/**
|
|
21
|
+
* @param {Partial<DashboardGeneratorConfig>} options
|
|
22
|
+
*/
|
|
23
|
+
constructor(options?: Partial<DashboardGeneratorConfig>);
|
|
24
|
+
config: {
|
|
25
|
+
/**
|
|
26
|
+
* - Dashboard title (default: 'RAG Pipeline Dashboard')
|
|
27
|
+
*/
|
|
28
|
+
title: string;
|
|
29
|
+
/**
|
|
30
|
+
* - Auto-refresh interval in ms (default: 5000)
|
|
31
|
+
*/
|
|
32
|
+
refreshInterval: number;
|
|
33
|
+
/**
|
|
34
|
+
* - Color theme (default: 'dark')
|
|
35
|
+
*/
|
|
36
|
+
theme: string;
|
|
37
|
+
};
|
|
38
|
+
/**
|
|
39
|
+
* Generate a complete standalone HTML dashboard page.
|
|
40
|
+
* @param {Object} metricsSnapshot - Snapshot from MetricsAggregator.getSnapshot()
|
|
41
|
+
* @returns {string} Complete HTML document string
|
|
42
|
+
*/
|
|
43
|
+
generate(metricsSnapshot: any): string;
|
|
44
|
+
/**
|
|
45
|
+
* Generate a single metric card HTML snippet.
|
|
46
|
+
* @param {string} title - Card title
|
|
47
|
+
* @param {string} value - Primary display value
|
|
48
|
+
* @param {string} subtitle - Secondary info line
|
|
49
|
+
* @param {string} color - Accent color (CSS value)
|
|
50
|
+
* @returns {string} HTML string
|
|
51
|
+
*/
|
|
52
|
+
_generateCard(title: string, value: string, subtitle: string, color: string): string;
|
|
53
|
+
/**
|
|
54
|
+
* Generate an inline SVG bar chart.
|
|
55
|
+
* @param {Array<{label: string, value: number}>} data - Chart data points
|
|
56
|
+
* @param {number} width - SVG width in pixels
|
|
57
|
+
* @param {number} height - SVG height in pixels
|
|
58
|
+
* @returns {string} SVG markup string
|
|
59
|
+
*/
|
|
60
|
+
_generateBarChart(data: Array<{
|
|
61
|
+
label: string;
|
|
62
|
+
value: number;
|
|
63
|
+
}>, width: number, height: number): string;
|
|
64
|
+
/**
|
|
65
|
+
* Generate CSS styles for the specified theme.
|
|
66
|
+
* @param {'dark'|'light'} theme
|
|
67
|
+
* @returns {string} CSS string
|
|
68
|
+
*/
|
|
69
|
+
_generateStyles(theme: "dark" | "light"): string;
|
|
70
|
+
/**
|
|
71
|
+
* Generate an HTML table for detailed metrics.
|
|
72
|
+
* @param {Array<{label: string, value: string|number, unit: string}>} rows
|
|
73
|
+
* @returns {string} HTML table string
|
|
74
|
+
*/
|
|
75
|
+
_generateTable(rows: Array<{
|
|
76
|
+
label: string;
|
|
77
|
+
value: string | number;
|
|
78
|
+
unit: string;
|
|
79
|
+
}>): string;
|
|
80
|
+
/**
|
|
81
|
+
* Generate a plain-text summary report (for CLI/logs).
|
|
82
|
+
* @param {Object} metricsSnapshot - Snapshot from MetricsAggregator.getSnapshot()
|
|
83
|
+
* @returns {string} Formatted text report
|
|
84
|
+
*/
|
|
85
|
+
generateReport(metricsSnapshot: any): string;
|
|
86
|
+
/**
|
|
87
|
+
* Return an empty metrics snapshot with zeroed values.
|
|
88
|
+
* @returns {Object}
|
|
89
|
+
* @private
|
|
90
|
+
*/
|
|
91
|
+
private _emptySnapshot;
|
|
92
|
+
/**
|
|
93
|
+
* Escape HTML special characters.
|
|
94
|
+
* @param {string} str
|
|
95
|
+
* @returns {string}
|
|
96
|
+
* @private
|
|
97
|
+
*/
|
|
98
|
+
private _escapeHtml;
|
|
99
|
+
/**
|
|
100
|
+
* Format a number with locale-aware separators.
|
|
101
|
+
* @param {number} n
|
|
102
|
+
* @returns {string}
|
|
103
|
+
* @private
|
|
104
|
+
*/
|
|
105
|
+
private _formatNumber;
|
|
106
|
+
/**
|
|
107
|
+
* Format uptime duration to human-readable string.
|
|
108
|
+
* @param {number} ms - Uptime in milliseconds
|
|
109
|
+
* @returns {string}
|
|
110
|
+
* @private
|
|
111
|
+
*/
|
|
112
|
+
private _formatUptime;
|
|
113
|
+
/**
|
|
114
|
+
* Right-align a value within a given width.
|
|
115
|
+
* @param {string|number} val
|
|
116
|
+
* @param {number} width
|
|
117
|
+
* @returns {string}
|
|
118
|
+
* @private
|
|
119
|
+
*/
|
|
120
|
+
private _padLeft;
|
|
121
|
+
}
|
|
122
|
+
export namespace DEFAULT_CONFIG {
|
|
123
|
+
let title: string;
|
|
124
|
+
let refreshInterval: number;
|
|
125
|
+
let theme: string;
|
|
126
|
+
}
|
|
127
|
+
import { EventEmitter } from "events";
|
|
@@ -0,0 +1,218 @@
|
|
|
1
|
+
export type MetricsAggregatorConfig = {
|
|
2
|
+
/**
|
|
3
|
+
* - Rolling window in seconds (default: 60)
|
|
4
|
+
*/
|
|
5
|
+
windowSize: number;
|
|
6
|
+
/**
|
|
7
|
+
* - Milliseconds between samples (default: 1000)
|
|
8
|
+
*/
|
|
9
|
+
sampleInterval: number;
|
|
10
|
+
/**
|
|
11
|
+
* - Maximum data points to keep (default: 3600)
|
|
12
|
+
*/
|
|
13
|
+
maxHistory: number;
|
|
14
|
+
};
|
|
15
|
+
export type QueryData = {
|
|
16
|
+
/**
|
|
17
|
+
* - Duration in milliseconds
|
|
18
|
+
*/
|
|
19
|
+
duration: number;
|
|
20
|
+
/**
|
|
21
|
+
* - Token count
|
|
22
|
+
*/
|
|
23
|
+
tokens?: number;
|
|
24
|
+
/**
|
|
25
|
+
* - Cost in USD
|
|
26
|
+
*/
|
|
27
|
+
cost?: number;
|
|
28
|
+
/**
|
|
29
|
+
* - Whether the operation succeeded
|
|
30
|
+
*/
|
|
31
|
+
success?: boolean;
|
|
32
|
+
/**
|
|
33
|
+
* - Unix timestamp (defaults to Date.now())
|
|
34
|
+
*/
|
|
35
|
+
timestamp?: number;
|
|
36
|
+
};
|
|
37
|
+
export type ErrorData = {
|
|
38
|
+
/**
|
|
39
|
+
* - Error message
|
|
40
|
+
*/
|
|
41
|
+
message: string;
|
|
42
|
+
/**
|
|
43
|
+
* - Error code
|
|
44
|
+
*/
|
|
45
|
+
code?: string;
|
|
46
|
+
/**
|
|
47
|
+
* - Error source component
|
|
48
|
+
*/
|
|
49
|
+
source?: string;
|
|
50
|
+
/**
|
|
51
|
+
* - Unix timestamp
|
|
52
|
+
*/
|
|
53
|
+
timestamp?: number;
|
|
54
|
+
};
|
|
55
|
+
/**
|
|
56
|
+
* @typedef {Object} QueryData
|
|
57
|
+
* @property {number} duration - Duration in milliseconds
|
|
58
|
+
* @property {number} [tokens] - Token count
|
|
59
|
+
* @property {number} [cost] - Cost in USD
|
|
60
|
+
* @property {boolean} [success] - Whether the operation succeeded
|
|
61
|
+
* @property {number} [timestamp] - Unix timestamp (defaults to Date.now())
|
|
62
|
+
*/
|
|
63
|
+
/**
|
|
64
|
+
* @typedef {Object} ErrorData
|
|
65
|
+
* @property {string} message - Error message
|
|
66
|
+
* @property {string} [code] - Error code
|
|
67
|
+
* @property {string} [source] - Error source component
|
|
68
|
+
* @property {number} [timestamp] - Unix timestamp
|
|
69
|
+
*/
|
|
70
|
+
/**
|
|
71
|
+
* Collects and aggregates pipeline metrics into dashboard-ready snapshots.
|
|
72
|
+
* @extends EventEmitter
|
|
73
|
+
*/
|
|
74
|
+
export class MetricsAggregator extends EventEmitter<[never]> {
|
|
75
|
+
/**
|
|
76
|
+
* @param {Partial<MetricsAggregatorConfig>} options
|
|
77
|
+
*/
|
|
78
|
+
constructor(options?: Partial<MetricsAggregatorConfig>);
|
|
79
|
+
config: {
|
|
80
|
+
/**
|
|
81
|
+
* - Rolling window in seconds (default: 60)
|
|
82
|
+
*/
|
|
83
|
+
windowSize: number;
|
|
84
|
+
/**
|
|
85
|
+
* - Milliseconds between samples (default: 1000)
|
|
86
|
+
*/
|
|
87
|
+
sampleInterval: number;
|
|
88
|
+
/**
|
|
89
|
+
* - Maximum data points to keep (default: 3600)
|
|
90
|
+
*/
|
|
91
|
+
maxHistory: number;
|
|
92
|
+
};
|
|
93
|
+
startTime: number;
|
|
94
|
+
/** @type {{ queries: number, embeddings: number, retrievals: number, generations: number, errors: number }} */
|
|
95
|
+
counters: {
|
|
96
|
+
queries: number;
|
|
97
|
+
embeddings: number;
|
|
98
|
+
retrievals: number;
|
|
99
|
+
generations: number;
|
|
100
|
+
errors: number;
|
|
101
|
+
};
|
|
102
|
+
/** @type {Array<{ value: number, timestamp: number }>} */
|
|
103
|
+
latencies: Array<{
|
|
104
|
+
value: number;
|
|
105
|
+
timestamp: number;
|
|
106
|
+
}>;
|
|
107
|
+
/** @type {Array<{ value: number, timestamp: number }>} */
|
|
108
|
+
costs: Array<{
|
|
109
|
+
value: number;
|
|
110
|
+
timestamp: number;
|
|
111
|
+
}>;
|
|
112
|
+
/** @type {Array<{ heapUsed: number, heapTotal: number, rss: number, timestamp: number }>} */
|
|
113
|
+
memory: Array<{
|
|
114
|
+
heapUsed: number;
|
|
115
|
+
heapTotal: number;
|
|
116
|
+
rss: number;
|
|
117
|
+
timestamp: number;
|
|
118
|
+
}>;
|
|
119
|
+
/** @type {Array<{ message: string, code: string, source: string, timestamp: number }>} */
|
|
120
|
+
errors: Array<{
|
|
121
|
+
message: string;
|
|
122
|
+
code: string;
|
|
123
|
+
source: string;
|
|
124
|
+
timestamp: number;
|
|
125
|
+
}>;
|
|
126
|
+
/** @type {Array<{ type: string, timestamp: number, duration: number }>} */
|
|
127
|
+
history: Array<{
|
|
128
|
+
type: string;
|
|
129
|
+
timestamp: number;
|
|
130
|
+
duration: number;
|
|
131
|
+
}>;
|
|
132
|
+
/**
|
|
133
|
+
* Record a query operation metric.
|
|
134
|
+
* @param {QueryData} data
|
|
135
|
+
*/
|
|
136
|
+
recordQuery(data: QueryData): void;
|
|
137
|
+
/**
|
|
138
|
+
* Record an embedding operation metric.
|
|
139
|
+
* @param {QueryData} data
|
|
140
|
+
*/
|
|
141
|
+
recordEmbedding(data: QueryData): void;
|
|
142
|
+
/**
|
|
143
|
+
* Record a retrieval operation metric.
|
|
144
|
+
* @param {QueryData} data
|
|
145
|
+
*/
|
|
146
|
+
recordRetrieval(data: QueryData): void;
|
|
147
|
+
/**
|
|
148
|
+
* Record a generation operation metric.
|
|
149
|
+
* @param {QueryData} data
|
|
150
|
+
*/
|
|
151
|
+
recordGeneration(data: QueryData): void;
|
|
152
|
+
/**
|
|
153
|
+
* Record an error event.
|
|
154
|
+
* @param {ErrorData} data
|
|
155
|
+
*/
|
|
156
|
+
recordError(data: ErrorData): void;
|
|
157
|
+
/**
|
|
158
|
+
* Record a memory sample.
|
|
159
|
+
* @param {{ heapUsed?: number, heapTotal?: number, rss?: number }} [data]
|
|
160
|
+
*/
|
|
161
|
+
recordMemory(data?: {
|
|
162
|
+
heapUsed?: number;
|
|
163
|
+
heapTotal?: number;
|
|
164
|
+
rss?: number;
|
|
165
|
+
}): void;
|
|
166
|
+
/**
|
|
167
|
+
* Return a complete dashboard snapshot of current metrics.
|
|
168
|
+
* @returns {Object} Dashboard-ready metrics snapshot
|
|
169
|
+
*/
|
|
170
|
+
getSnapshot(): any;
|
|
171
|
+
/**
|
|
172
|
+
* Return time-bucketed data for charting a given metric.
|
|
173
|
+
* @param {'latency'|'throughput'|'cost'|'memory'|'errors'} metric
|
|
174
|
+
* @param {number} [windowSeconds] - Time window in seconds (defaults to config.windowSize)
|
|
175
|
+
* @returns {Array<{ bucket: number, value: number, label: string }>}
|
|
176
|
+
*/
|
|
177
|
+
getTimeSeries(metric: "latency" | "throughput" | "cost" | "memory" | "errors", windowSeconds?: number): Array<{
|
|
178
|
+
bucket: number;
|
|
179
|
+
value: number;
|
|
180
|
+
label: string;
|
|
181
|
+
}>;
|
|
182
|
+
/**
|
|
183
|
+
* Reset all counters, history, and collected metrics.
|
|
184
|
+
*/
|
|
185
|
+
reset(): void;
|
|
186
|
+
/**
|
|
187
|
+
* Record a generic pipeline operation.
|
|
188
|
+
* @param {string} type - Counter key (queries, embeddings, etc.)
|
|
189
|
+
* @param {QueryData} data
|
|
190
|
+
* @private
|
|
191
|
+
*/
|
|
192
|
+
private _recordOperation;
|
|
193
|
+
/**
|
|
194
|
+
* Trim an array to maxHistory length, removing oldest entries.
|
|
195
|
+
* @param {Array} arr
|
|
196
|
+
* @private
|
|
197
|
+
*/
|
|
198
|
+
private _trimArray;
|
|
199
|
+
/**
|
|
200
|
+
* Compute percentile statistics from a sorted array of values.
|
|
201
|
+
* @param {number[]} values
|
|
202
|
+
* @returns {{ avg: number, p50: number, p95: number, p99: number, min: number, max: number }}
|
|
203
|
+
* @private
|
|
204
|
+
*/
|
|
205
|
+
private _computePercentiles;
|
|
206
|
+
/**
|
|
207
|
+
* Compute memory usage trend (positive = increasing, negative = decreasing).
|
|
208
|
+
* @returns {'increasing'|'decreasing'|'stable'}
|
|
209
|
+
* @private
|
|
210
|
+
*/
|
|
211
|
+
private _computeMemoryTrend;
|
|
212
|
+
}
|
|
213
|
+
export namespace DEFAULT_CONFIG {
|
|
214
|
+
let windowSize: number;
|
|
215
|
+
let sampleInterval: number;
|
|
216
|
+
let maxHistory: number;
|
|
217
|
+
}
|
|
218
|
+
import { EventEmitter } from "events";
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Execution tracer that wraps pipelines to capture run traces
|
|
3
|
+
* @extends EventEmitter
|
|
4
|
+
*/
|
|
5
|
+
export class ExecutionTracer extends EventEmitter<[never]> {
|
|
6
|
+
/**
|
|
7
|
+
* Create a new ExecutionTracer
|
|
8
|
+
* @param {object} [options] - Tracer configuration
|
|
9
|
+
* @param {boolean} [options.captureInputs=true] - Whether to capture step inputs
|
|
10
|
+
* @param {boolean} [options.captureOutputs=true] - Whether to capture step outputs
|
|
11
|
+
* @param {number} [options.maxPayloadSize=10000] - Max characters before payload truncation
|
|
12
|
+
*/
|
|
13
|
+
constructor(options?: {
|
|
14
|
+
captureInputs?: boolean;
|
|
15
|
+
captureOutputs?: boolean;
|
|
16
|
+
maxPayloadSize?: number;
|
|
17
|
+
});
|
|
18
|
+
config: {
|
|
19
|
+
captureInputs: boolean;
|
|
20
|
+
captureOutputs: boolean;
|
|
21
|
+
maxPayloadSize: number;
|
|
22
|
+
};
|
|
23
|
+
traces: any[];
|
|
24
|
+
/**
|
|
25
|
+
* Wrap a pipeline to record execution traces on each run
|
|
26
|
+
* @param {object} pipeline - Pipeline instance with a .run() method
|
|
27
|
+
* @returns {object} Wrapped pipeline with instrumented .run()
|
|
28
|
+
*/
|
|
29
|
+
trace(pipeline: object): object;
|
|
30
|
+
/**
|
|
31
|
+
* Return all recorded traces
|
|
32
|
+
* @returns {Array<object>} Array of trace records
|
|
33
|
+
*/
|
|
34
|
+
getTraces(): Array<object>;
|
|
35
|
+
/**
|
|
36
|
+
* Return a specific trace by ID
|
|
37
|
+
* @param {string} traceId - The trace ID to look up
|
|
38
|
+
* @returns {object|undefined} The trace record, or undefined if not found
|
|
39
|
+
*/
|
|
40
|
+
getTrace(traceId: string): object | undefined;
|
|
41
|
+
/**
|
|
42
|
+
* Clear all recorded traces
|
|
43
|
+
*/
|
|
44
|
+
clear(): void;
|
|
45
|
+
/**
|
|
46
|
+
* Export traces as a serialized string
|
|
47
|
+
* @param {string} [format='json'] - Export format (currently only 'json')
|
|
48
|
+
* @returns {string} Serialized traces
|
|
49
|
+
*/
|
|
50
|
+
exportTraces(format?: string): string;
|
|
51
|
+
}
|
|
52
|
+
export namespace DEFAULT_CONFIG {
|
|
53
|
+
let captureInputs: boolean;
|
|
54
|
+
let captureOutputs: boolean;
|
|
55
|
+
let maxPayloadSize: number;
|
|
56
|
+
}
|
|
57
|
+
import { EventEmitter } from "events";
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Trace inspector that analyzes execution traces produced by ExecutionTracer
|
|
3
|
+
* @extends EventEmitter
|
|
4
|
+
*/
|
|
5
|
+
export class TraceInspector extends EventEmitter<[never]> {
|
|
6
|
+
/**
|
|
7
|
+
* Create a new TraceInspector
|
|
8
|
+
* @param {object} [options] - Inspector configuration
|
|
9
|
+
*/
|
|
10
|
+
constructor(options?: object);
|
|
11
|
+
config: any;
|
|
12
|
+
/**
|
|
13
|
+
* Analyze a single trace for performance and quality insights
|
|
14
|
+
* @param {object} trace - Trace record from ExecutionTracer
|
|
15
|
+
* @returns {object} Analysis result with summary, breakdown, bottleneck, quality, and recommendations
|
|
16
|
+
*/
|
|
17
|
+
analyze(trace: object): object;
|
|
18
|
+
/**
|
|
19
|
+
* Compare multiple traces for consistency and trends
|
|
20
|
+
* @param {Array<object>} traces - Array of trace records
|
|
21
|
+
* @returns {object} Comparison result with averages, ranges, and quality trend
|
|
22
|
+
*/
|
|
23
|
+
compare(traces: Array<object>): object;
|
|
24
|
+
/**
|
|
25
|
+
* Find anomalous traces that deviate significantly from the norm
|
|
26
|
+
* @param {Array<object>} traces - Array of trace records
|
|
27
|
+
* @returns {Array<object>} Array of anomaly descriptors with traceId, anomalyType, details
|
|
28
|
+
*/
|
|
29
|
+
findAnomalies(traces: Array<object>): Array<object>;
|
|
30
|
+
}
|
|
31
|
+
import { EventEmitter } from "events";
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
export class PluginCertification extends EventEmitter<[never]> {
|
|
2
|
+
constructor(_options?: {});
|
|
3
|
+
_config: {
|
|
4
|
+
registryUrl: any;
|
|
5
|
+
apiKey: any;
|
|
6
|
+
fetch: any;
|
|
7
|
+
certificationLevels: {
|
|
8
|
+
BASIC: {
|
|
9
|
+
score: number;
|
|
10
|
+
automated: boolean;
|
|
11
|
+
};
|
|
12
|
+
VERIFIED: {
|
|
13
|
+
score: number;
|
|
14
|
+
manual: boolean;
|
|
15
|
+
};
|
|
16
|
+
ENTERPRISE: {
|
|
17
|
+
score: number;
|
|
18
|
+
manual: boolean;
|
|
19
|
+
audit: boolean;
|
|
20
|
+
};
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
validators: Map<any, any>;
|
|
24
|
+
/**
|
|
25
|
+
* Submit plugin for certification
|
|
26
|
+
*/
|
|
27
|
+
submitForCertification(pluginId: any, level?: string): Promise<{
|
|
28
|
+
id: `${string}-${string}-${string}-${string}-${string}`;
|
|
29
|
+
pluginId: any;
|
|
30
|
+
level: any;
|
|
31
|
+
score: any;
|
|
32
|
+
issuedAt: string;
|
|
33
|
+
expiresAt: string;
|
|
34
|
+
results: {
|
|
35
|
+
automated: any;
|
|
36
|
+
manual: any;
|
|
37
|
+
audit: any;
|
|
38
|
+
};
|
|
39
|
+
badge: any;
|
|
40
|
+
certificate: {
|
|
41
|
+
id: any;
|
|
42
|
+
pluginId: any;
|
|
43
|
+
level: any;
|
|
44
|
+
issuedAt: any;
|
|
45
|
+
issuer: string;
|
|
46
|
+
signature: string;
|
|
47
|
+
verificationUrl: string;
|
|
48
|
+
};
|
|
49
|
+
}>;
|
|
50
|
+
/**
|
|
51
|
+
* Verify plugin certification
|
|
52
|
+
*/
|
|
53
|
+
verifyCertification(pluginId: any, certificationId: any): Promise<{
|
|
54
|
+
valid: any;
|
|
55
|
+
certification: any;
|
|
56
|
+
expiresAt: any;
|
|
57
|
+
verifiedAt: string;
|
|
58
|
+
}>;
|
|
59
|
+
/**
|
|
60
|
+
* Get certification requirements for a level
|
|
61
|
+
*/
|
|
62
|
+
getCertificationRequirements(level: any): any;
|
|
63
|
+
/**
|
|
64
|
+
* Get publisher verification status
|
|
65
|
+
*/
|
|
66
|
+
getPublisherStatus(publisherId: any): Promise<{
|
|
67
|
+
verified: any;
|
|
68
|
+
level: any;
|
|
69
|
+
badges: any;
|
|
70
|
+
certifiedPlugins: any;
|
|
71
|
+
reputation: any;
|
|
72
|
+
joinedAt: any;
|
|
73
|
+
lastActivity: any;
|
|
74
|
+
}>;
|
|
75
|
+
/**
|
|
76
|
+
* Apply for publisher verification
|
|
77
|
+
*/
|
|
78
|
+
applyForPublisherVerification(publisherInfo: any): Promise<{
|
|
79
|
+
applicationId: `${string}-${string}-${string}-${string}-${string}`;
|
|
80
|
+
status: any;
|
|
81
|
+
estimatedReviewTime: any;
|
|
82
|
+
requirements: any;
|
|
83
|
+
}>;
|
|
84
|
+
_initializeValidators(): void;
|
|
85
|
+
_runAutomatedChecks(pluginId: any): Promise<{}>;
|
|
86
|
+
_calculateScore(results: any): number;
|
|
87
|
+
_submitForManualReview(pluginId: any, level: any, automatedResults: any): Promise<{
|
|
88
|
+
reviewId: any;
|
|
89
|
+
status: any;
|
|
90
|
+
estimatedCompletion: any;
|
|
91
|
+
reviewers: any;
|
|
92
|
+
}>;
|
|
93
|
+
_performSecurityAudit(pluginId: any): Promise<{
|
|
94
|
+
auditId: any;
|
|
95
|
+
status: any;
|
|
96
|
+
estimatedCompletion: any;
|
|
97
|
+
auditor: any;
|
|
98
|
+
}>;
|
|
99
|
+
_generateCertification(pluginId: any, level: any, results: any): Promise<{
|
|
100
|
+
id: `${string}-${string}-${string}-${string}-${string}`;
|
|
101
|
+
pluginId: any;
|
|
102
|
+
level: any;
|
|
103
|
+
score: any;
|
|
104
|
+
issuedAt: string;
|
|
105
|
+
expiresAt: string;
|
|
106
|
+
results: {
|
|
107
|
+
automated: any;
|
|
108
|
+
manual: any;
|
|
109
|
+
audit: any;
|
|
110
|
+
};
|
|
111
|
+
badge: any;
|
|
112
|
+
certificate: {
|
|
113
|
+
id: any;
|
|
114
|
+
pluginId: any;
|
|
115
|
+
level: any;
|
|
116
|
+
issuedAt: any;
|
|
117
|
+
issuer: string;
|
|
118
|
+
signature: string;
|
|
119
|
+
verificationUrl: string;
|
|
120
|
+
};
|
|
121
|
+
}>;
|
|
122
|
+
_generateBadge(level: any, score: any): any;
|
|
123
|
+
_generateBadgeSVG(badge: any, score: any): string;
|
|
124
|
+
_generateCertificate(pluginId: any, level: any, certificationId: any, issuedAt: any): {
|
|
125
|
+
id: any;
|
|
126
|
+
pluginId: any;
|
|
127
|
+
level: any;
|
|
128
|
+
issuedAt: any;
|
|
129
|
+
issuer: string;
|
|
130
|
+
signature: string;
|
|
131
|
+
verificationUrl: string;
|
|
132
|
+
};
|
|
133
|
+
_generateSignature(certificationId: any, pluginId: any, level: any, issuedAt: any): string;
|
|
134
|
+
_analyzeCodeQuality(): Promise<{
|
|
135
|
+
overallScore: number;
|
|
136
|
+
details: {
|
|
137
|
+
complexity: string;
|
|
138
|
+
maintainability: string;
|
|
139
|
+
reliability: string;
|
|
140
|
+
};
|
|
141
|
+
issues: any[];
|
|
142
|
+
}>;
|
|
143
|
+
_scanSecurity(): Promise<{
|
|
144
|
+
securityScore: number;
|
|
145
|
+
vulnerabilities: any[];
|
|
146
|
+
recommendations: any[];
|
|
147
|
+
}>;
|
|
148
|
+
_benchmarkPerformance(): Promise<{
|
|
149
|
+
performanceScore: number;
|
|
150
|
+
metrics: {
|
|
151
|
+
avgResponseTime: string;
|
|
152
|
+
throughput: string;
|
|
153
|
+
memoryUsage: string;
|
|
154
|
+
};
|
|
155
|
+
bottlenecks: any[];
|
|
156
|
+
}>;
|
|
157
|
+
_analyzeDocumentation(): Promise<{
|
|
158
|
+
completenessScore: number;
|
|
159
|
+
coverage: number;
|
|
160
|
+
quality: string;
|
|
161
|
+
}>;
|
|
162
|
+
_analyzeTests(): Promise<{
|
|
163
|
+
testScore: number;
|
|
164
|
+
coverage: number;
|
|
165
|
+
testQuality: string;
|
|
166
|
+
}>;
|
|
167
|
+
_makeRequest(method: any, endpoint: any, data?: {}): Promise<any>;
|
|
168
|
+
}
|
|
169
|
+
import { EventEmitter } from "events";
|