@devilsdev/rag-pipeline-utils 2.1.12 → 2.2.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/.ragrc.schema.json +218 -0
- package/README.md +178 -550
- package/bin/cli.js +8 -14
- package/contracts/reranker-contract.json +69 -0
- package/dist/index.d.ts +237 -0
- package/dist/index.mjs +22 -7
- package/package.json +18 -13
- package/src/ai/adaptive-retrieval.js +191 -0
- package/src/ai/federated-learning.js +214 -0
- package/src/ai/federation/federated-learning-coordinator.js +345 -0
- package/src/ai/federation.js +76 -0
- package/src/ai/index-fixed.js +509 -0
- package/src/ai/index.js +33 -0
- package/src/ai/model-trainer.js +217 -0
- package/src/ai/model-training.js +205 -0
- package/src/ai/module-template.js +37 -0
- package/src/ai/multimodal/multi-modal-processor.js +345 -0
- package/src/ai/multimodal-processing.js +268 -0
- package/src/ai/multimodal.js +71 -0
- package/src/ai/orchestrator.js +70 -0
- package/src/ai/retrieval/adaptive-retrieval-engine.js +398 -0
- package/src/ai/retrieval-engine.js +69 -0
- package/src/ai/training/model-training-orchestrator.js +228 -0
- package/src/ci/workflow-analyzer.js +71 -0
- package/src/cli/commands/ai-ml.js +967 -0
- package/src/cli/commands/docs.js +228 -0
- package/src/cli/commands/dx.js +538 -0
- package/src/cli/commands/plugin-hub.js +875 -0
- package/src/cli/doctor-command.js +639 -0
- package/src/cli/enhanced-cli-commands.js +945 -0
- package/src/cli/interactive-wizard.js +997 -0
- package/src/cli/plugin-marketplace-commands.js +869 -0
- package/src/cli.js +17 -0
- package/src/config/enhanced-ragrc-schema.js +632 -0
- package/src/config/load-config.js +54 -0
- package/src/config/load-plugin-config.js +69 -0
- package/src/config/normalize-config.js +105 -0
- package/src/config/schema-validator.js +315 -0
- package/src/config/validate-plugin-schema.js +35 -0
- package/src/config/validate-schema.js +113 -0
- package/src/contracts/plugin-contracts.js +33 -0
- package/src/core/create-pipeline.js +99 -0
- package/src/core/dependency-injection.js +242 -0
- package/src/core/observability/event-logger.js +241 -0
- package/src/core/observability/instrumented-pipeline.js +609 -0
- package/src/core/observability/metrics.js +497 -0
- package/src/core/observability/tracing.js +781 -0
- package/src/core/performance/benchmark.js +516 -0
- package/src/core/performance/parallel-processor.js +240 -0
- package/src/core/performance/streaming-safeguards.js +620 -0
- package/src/core/pipeline-factory.js +60 -0
- package/src/core/plugin-contracts.js +89 -0
- package/src/core/plugin-marketplace/plugin-metadata.js +485 -0
- package/src/core/plugin-marketplace/plugin-publisher.js +574 -0
- package/src/core/plugin-marketplace/plugin-registry-format.js +419 -0
- package/src/core/plugin-marketplace/version-resolver.js +61 -0
- package/src/core/plugin-registry.js +294 -0
- package/src/dag/dag-engine.js +954 -0
- package/src/dag/dag-node.js +76 -0
- package/src/dag/enhanced-dag-engine.js +822 -0
- package/src/dx/index.js +40 -0
- package/src/dx/integration-templates.js +665 -0
- package/src/dx/performance-profiler.js +968 -0
- package/src/dx/realtime-debugger.js +755 -0
- package/src/dx/visual-pipeline-builder.js +578 -0
- package/src/ecosystem/plugin-analytics-dashboard.js +778 -0
- package/src/ecosystem/plugin-certification.js +580 -0
- package/src/ecosystem/plugin-hub.js +821 -0
- package/src/enterprise/audit-logging.js +967 -0
- package/src/enterprise/data-governance.js +408 -0
- package/src/enterprise/multi-tenancy.js +496 -0
- package/src/enterprise/sso-integration.js +1030 -0
- package/src/evaluate/evaluator.js +52 -0
- package/src/evaluate/scoring.js +91 -0
- package/src/index.js +67 -0
- package/src/ingest.js +59 -0
- package/src/loader/csv-loader.js +38 -0
- package/src/loader/directory-loader.js +48 -0
- package/src/loader/html-loader.js +62 -0
- package/src/loader/markdown-loader.js +67 -0
- package/src/mocks/openai-embedder.js +119 -0
- package/src/mocks/openai-llm.js +77 -0
- package/src/mocks/pdf-loader.js +21 -0
- package/src/mocks/pinecone-retriever.js +106 -0
- package/src/observability/audit-logger.js +758 -0
- package/src/observability/dashboard-config.json +675 -0
- package/src/observability/event-logger.js +310 -0
- package/src/observability/metrics.js +691 -0
- package/src/observability/security-monitor.js +830 -0
- package/src/observability/slo-monitor.js +319 -0
- package/src/observability/telemetry.js +686 -0
- package/src/pipeline/pipeline.js +18 -0
- package/src/plugins/sample-embedder.js +53 -0
- package/src/plugins/sample-llm.js +30 -0
- package/src/plugins/sample-loader.js +24 -0
- package/src/plugins/sample-retriever.js +84 -0
- package/src/query.js +117 -0
- package/src/reranker/llm-reranker.js +111 -0
- package/src/scripts/script-utilities.js +36 -0
- package/src/security/plugin-sandbox.js +586 -0
- package/src/security/plugin-signature-verifier.js +414 -0
- package/src/security/validator.js +36 -0
- package/src/utils/ci/diagnostic-reporter.js +57 -0
- package/src/utils/logger.js +211 -0
- package/src/utils/performance-monitor.js +561 -0
- package/src/utils/plugin-scaffolder.js +447 -0
- package/src/utils/rate-limiter.js +244 -0
- package/src/utils/retry-policy.js +443 -0
- package/src/utils/retry.js +107 -0
- package/src/utils/safe-expression-evaluator.js +579 -0
- package/src/utils/secure-logging.js +338 -0
- package/src/utils/structured-logger.js +388 -0
- package/src/utils/validate-plugin-contract.js +42 -0
package/src/dx/index.js
ADDED
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Developer Experience (DX) Enhancements
|
|
3
|
+
*
|
|
4
|
+
* This module provides advanced developer tools and interfaces for the RAG pipeline:
|
|
5
|
+
* - Visual Pipeline Builder: Web-based drag-and-drop interface
|
|
6
|
+
* - Real-time Debugging: Live pipeline inspection and debugging
|
|
7
|
+
* - Performance Profiler: Detailed bottleneck analysis
|
|
8
|
+
* - Integration Templates: Pre-built connectors for popular services
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
const VisualPipelineBuilder = require("./visual-pipeline-builder");
|
|
12
|
+
// eslint-disable-line global-require
|
|
13
|
+
const RealtimeDebugger = require("./realtime-debugger");
|
|
14
|
+
// eslint-disable-line global-require
|
|
15
|
+
const PerformanceProfiler = require("./performance-profiler");
|
|
16
|
+
// eslint-disable-line global-require
|
|
17
|
+
const IntegrationTemplates = require("./integration-templates");
|
|
18
|
+
// eslint-disable-line global-require
|
|
19
|
+
|
|
20
|
+
module.exports = {
|
|
21
|
+
VisualPipelineBuilder,
|
|
22
|
+
RealtimeDebugger,
|
|
23
|
+
PerformanceProfiler,
|
|
24
|
+
IntegrationTemplates,
|
|
25
|
+
|
|
26
|
+
// Convenience factory methods
|
|
27
|
+
createVisualBuilder: (_options = {}) => new VisualPipelineBuilder(_options),
|
|
28
|
+
createDebugger: (_options = {}) => new RealtimeDebugger(_options),
|
|
29
|
+
createProfiler: (_options = {}) => new PerformanceProfiler(_options),
|
|
30
|
+
getTemplates: () => IntegrationTemplates.getAllTemplates(),
|
|
31
|
+
|
|
32
|
+
// DX utilities
|
|
33
|
+
getDXInfo: () => ({
|
|
34
|
+
version: "1.0.0",
|
|
35
|
+
components: ["visual-builder", "debugger", "profiler", "templates"],
|
|
36
|
+
status: "active",
|
|
37
|
+
}),
|
|
38
|
+
};
|
|
39
|
+
|
|
40
|
+
// Ensure module.exports is properly defined
|
|
@@ -0,0 +1,665 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Integration Templates
|
|
3
|
+
*
|
|
4
|
+
* Pre-built connectors and templates for popular services and platforms.
|
|
5
|
+
* Provides ready-to-use configurations for common RAG pipeline integrations.
|
|
6
|
+
*/
|
|
7
|
+
|
|
8
|
+
const fs = require("fs").promises; // eslint-disable-line global-require
|
|
9
|
+
const path = require("path"); // eslint-disable-line global-require
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Normalize template shape and keep back-compat.
|
|
13
|
+
* Google-style: small helpers, explicit transformation.
|
|
14
|
+
*/
|
|
15
|
+
function normalize(t) {
|
|
16
|
+
return {
|
|
17
|
+
id: t.id,
|
|
18
|
+
name: t.name,
|
|
19
|
+
description: t.description,
|
|
20
|
+
type: t.type ?? t._type,
|
|
21
|
+
config: t.config ?? t._config,
|
|
22
|
+
generateIntegrationCode: t.generateIntegrationCode,
|
|
23
|
+
category: t.category,
|
|
24
|
+
dependencies: t.dependencies,
|
|
25
|
+
usage: t.usage,
|
|
26
|
+
};
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
function addBackCompat(template) {
|
|
30
|
+
if (!Object.getOwnPropertyDescriptor(template, "_type")) {
|
|
31
|
+
Object.defineProperty(template, "_type", {
|
|
32
|
+
get() {
|
|
33
|
+
return template.type;
|
|
34
|
+
},
|
|
35
|
+
});
|
|
36
|
+
}
|
|
37
|
+
if (!Object.getOwnPropertyDescriptor(template, "_config")) {
|
|
38
|
+
Object.defineProperty(template, "_config", {
|
|
39
|
+
get() {
|
|
40
|
+
return template.config;
|
|
41
|
+
},
|
|
42
|
+
});
|
|
43
|
+
}
|
|
44
|
+
return template;
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
class IntegrationTemplates {
|
|
48
|
+
constructor() {
|
|
49
|
+
this.templates = new Map();
|
|
50
|
+
this.categories = new Map();
|
|
51
|
+
|
|
52
|
+
this.initializeTemplates();
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
/**
|
|
56
|
+
* Initialize built-in integration templates
|
|
57
|
+
*/
|
|
58
|
+
initializeTemplates() {
|
|
59
|
+
// Data Source Templates
|
|
60
|
+
this.addTemplate("confluence", {
|
|
61
|
+
name: "Atlassian Confluence",
|
|
62
|
+
category: "data-sources",
|
|
63
|
+
description: "Connect to Confluence spaces and pages",
|
|
64
|
+
type: "loader",
|
|
65
|
+
config: {
|
|
66
|
+
baseUrl: {
|
|
67
|
+
_type: "string",
|
|
68
|
+
required: true,
|
|
69
|
+
description: "Confluence base URL",
|
|
70
|
+
},
|
|
71
|
+
username: {
|
|
72
|
+
_type: "string",
|
|
73
|
+
required: true,
|
|
74
|
+
description: "Username or email",
|
|
75
|
+
},
|
|
76
|
+
apiToken: {
|
|
77
|
+
_type: "string",
|
|
78
|
+
required: true,
|
|
79
|
+
secret: true,
|
|
80
|
+
description: "API token",
|
|
81
|
+
},
|
|
82
|
+
spaceKey: {
|
|
83
|
+
_type: "string",
|
|
84
|
+
required: false,
|
|
85
|
+
description: "Specific space key (optional)",
|
|
86
|
+
},
|
|
87
|
+
pageLimit: {
|
|
88
|
+
_type: "number",
|
|
89
|
+
default: 100,
|
|
90
|
+
description: "Maximum pages to fetch",
|
|
91
|
+
},
|
|
92
|
+
},
|
|
93
|
+
dependencies: ["axios"],
|
|
94
|
+
usage: "Load documents from Confluence spaces and pages",
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
this.addTemplate("notion", {
|
|
98
|
+
name: "Notion Database",
|
|
99
|
+
category: "data-sources",
|
|
100
|
+
description: "Connect to Notion databases and pages",
|
|
101
|
+
type: "loader",
|
|
102
|
+
config: {
|
|
103
|
+
apiToken: {
|
|
104
|
+
_type: "string",
|
|
105
|
+
required: true,
|
|
106
|
+
secret: true,
|
|
107
|
+
description: "Notion API token",
|
|
108
|
+
},
|
|
109
|
+
databaseId: {
|
|
110
|
+
_type: "string",
|
|
111
|
+
required: true,
|
|
112
|
+
description: "Database ID to query",
|
|
113
|
+
},
|
|
114
|
+
filter: {
|
|
115
|
+
_type: "object",
|
|
116
|
+
required: false,
|
|
117
|
+
description: "Query filter (optional)",
|
|
118
|
+
},
|
|
119
|
+
pageSize: {
|
|
120
|
+
_type: "number",
|
|
121
|
+
default: 100,
|
|
122
|
+
description: "Results per page",
|
|
123
|
+
},
|
|
124
|
+
},
|
|
125
|
+
dependencies: ["@notionhq/client"],
|
|
126
|
+
usage: "Load documents from Notion databases",
|
|
127
|
+
});
|
|
128
|
+
|
|
129
|
+
this.addTemplate("sharepoint", {
|
|
130
|
+
name: "Microsoft SharePoint",
|
|
131
|
+
category: "data-sources",
|
|
132
|
+
description: "Connect to SharePoint document libraries",
|
|
133
|
+
type: "loader",
|
|
134
|
+
config: {
|
|
135
|
+
siteUrl: {
|
|
136
|
+
_type: "string",
|
|
137
|
+
required: true,
|
|
138
|
+
description: "SharePoint site URL",
|
|
139
|
+
},
|
|
140
|
+
clientId: {
|
|
141
|
+
_type: "string",
|
|
142
|
+
required: true,
|
|
143
|
+
description: "Azure app client ID",
|
|
144
|
+
},
|
|
145
|
+
clientSecret: {
|
|
146
|
+
_type: "string",
|
|
147
|
+
required: true,
|
|
148
|
+
secret: true,
|
|
149
|
+
description: "Azure app client secret",
|
|
150
|
+
},
|
|
151
|
+
tenantId: {
|
|
152
|
+
_type: "string",
|
|
153
|
+
required: true,
|
|
154
|
+
description: "Azure tenant ID",
|
|
155
|
+
},
|
|
156
|
+
libraryName: {
|
|
157
|
+
_type: "string",
|
|
158
|
+
default: "Documents",
|
|
159
|
+
description: "Document library name",
|
|
160
|
+
},
|
|
161
|
+
},
|
|
162
|
+
dependencies: ["@microsoft/microsoft-graph-client", "@azure/identity"],
|
|
163
|
+
usage: "Load documents from SharePoint libraries",
|
|
164
|
+
});
|
|
165
|
+
|
|
166
|
+
// Vector Database Templates
|
|
167
|
+
this.addTemplate("pinecone", {
|
|
168
|
+
name: "Pinecone Vector Database",
|
|
169
|
+
category: "vector-stores",
|
|
170
|
+
description: "Connect to Pinecone for vector storage and retrieval",
|
|
171
|
+
type: "retriever",
|
|
172
|
+
config: {
|
|
173
|
+
apiKey: {
|
|
174
|
+
_type: "string",
|
|
175
|
+
required: true,
|
|
176
|
+
secret: true,
|
|
177
|
+
description: "Pinecone API key",
|
|
178
|
+
},
|
|
179
|
+
environment: {
|
|
180
|
+
_type: "string",
|
|
181
|
+
required: true,
|
|
182
|
+
description: "Pinecone environment",
|
|
183
|
+
},
|
|
184
|
+
indexName: {
|
|
185
|
+
_type: "string",
|
|
186
|
+
required: true,
|
|
187
|
+
description: "Index name",
|
|
188
|
+
},
|
|
189
|
+
topK: {
|
|
190
|
+
_type: "number",
|
|
191
|
+
default: 5,
|
|
192
|
+
description: "Number of results to return",
|
|
193
|
+
},
|
|
194
|
+
includeMetadata: {
|
|
195
|
+
_type: "boolean",
|
|
196
|
+
default: true,
|
|
197
|
+
description: "Include metadata in results",
|
|
198
|
+
},
|
|
199
|
+
},
|
|
200
|
+
dependencies: ["@pinecone-database/pinecone"],
|
|
201
|
+
usage: "Store and retrieve vectors from Pinecone",
|
|
202
|
+
});
|
|
203
|
+
|
|
204
|
+
this.addTemplate("weaviate", {
|
|
205
|
+
name: "Weaviate Vector Database",
|
|
206
|
+
category: "vector-stores",
|
|
207
|
+
description: "Connect to Weaviate for semantic search",
|
|
208
|
+
type: "retriever",
|
|
209
|
+
config: {
|
|
210
|
+
host: {
|
|
211
|
+
_type: "string",
|
|
212
|
+
required: true,
|
|
213
|
+
description: "Weaviate host URL",
|
|
214
|
+
},
|
|
215
|
+
apiKey: {
|
|
216
|
+
_type: "string",
|
|
217
|
+
required: false,
|
|
218
|
+
secret: true,
|
|
219
|
+
description: "API key (if required)",
|
|
220
|
+
},
|
|
221
|
+
className: {
|
|
222
|
+
_type: "string",
|
|
223
|
+
required: true,
|
|
224
|
+
description: "Weaviate class name",
|
|
225
|
+
},
|
|
226
|
+
limit: {
|
|
227
|
+
_type: "number",
|
|
228
|
+
default: 5,
|
|
229
|
+
description: "Number of results to return",
|
|
230
|
+
},
|
|
231
|
+
},
|
|
232
|
+
dependencies: ["weaviate-ts-client"],
|
|
233
|
+
usage: "Semantic search with Weaviate",
|
|
234
|
+
});
|
|
235
|
+
|
|
236
|
+
// LLM Provider Templates
|
|
237
|
+
this.addTemplate("openai-gpt4", {
|
|
238
|
+
name: "OpenAI GPT-4",
|
|
239
|
+
category: "llm-providers",
|
|
240
|
+
description: "OpenAI GPT-4 language model integration",
|
|
241
|
+
type: "llm",
|
|
242
|
+
config: {
|
|
243
|
+
apiKey: {
|
|
244
|
+
_type: "string",
|
|
245
|
+
required: true,
|
|
246
|
+
secret: true,
|
|
247
|
+
description: "OpenAI API key",
|
|
248
|
+
},
|
|
249
|
+
model: { _type: "string", default: "gpt-4", description: "Model name" },
|
|
250
|
+
temperature: {
|
|
251
|
+
_type: "number",
|
|
252
|
+
default: 0.7,
|
|
253
|
+
description: "Sampling temperature",
|
|
254
|
+
},
|
|
255
|
+
maxTokens: {
|
|
256
|
+
_type: "number",
|
|
257
|
+
default: 1000,
|
|
258
|
+
description: "Maximum tokens to generate",
|
|
259
|
+
},
|
|
260
|
+
systemPrompt: {
|
|
261
|
+
_type: "string",
|
|
262
|
+
required: false,
|
|
263
|
+
description: "System prompt",
|
|
264
|
+
},
|
|
265
|
+
},
|
|
266
|
+
dependencies: ["openai"],
|
|
267
|
+
usage: "Generate responses using OpenAI GPT-4",
|
|
268
|
+
});
|
|
269
|
+
|
|
270
|
+
this.addTemplate("anthropic-claude", {
|
|
271
|
+
name: "Anthropic Claude",
|
|
272
|
+
category: "llm-providers",
|
|
273
|
+
description: "Anthropic Claude language model integration",
|
|
274
|
+
type: "llm",
|
|
275
|
+
config: {
|
|
276
|
+
apiKey: {
|
|
277
|
+
_type: "string",
|
|
278
|
+
required: true,
|
|
279
|
+
secret: true,
|
|
280
|
+
description: "Anthropic API key",
|
|
281
|
+
},
|
|
282
|
+
model: {
|
|
283
|
+
_type: "string",
|
|
284
|
+
default: "claude-3-sonnet-20240229",
|
|
285
|
+
description: "Model name",
|
|
286
|
+
},
|
|
287
|
+
maxTokens: {
|
|
288
|
+
_type: "number",
|
|
289
|
+
default: 1000,
|
|
290
|
+
description: "Maximum tokens to generate",
|
|
291
|
+
},
|
|
292
|
+
systemPrompt: {
|
|
293
|
+
_type: "string",
|
|
294
|
+
required: false,
|
|
295
|
+
description: "System prompt",
|
|
296
|
+
},
|
|
297
|
+
},
|
|
298
|
+
dependencies: ["@anthropic-ai/sdk"],
|
|
299
|
+
usage: "Generate responses using Anthropic Claude",
|
|
300
|
+
});
|
|
301
|
+
|
|
302
|
+
// Embedding Provider Templates
|
|
303
|
+
this.addTemplate("openai-embeddings", {
|
|
304
|
+
name: "OpenAI Embeddings",
|
|
305
|
+
category: "embedding-providers",
|
|
306
|
+
description: "OpenAI text embedding models",
|
|
307
|
+
type: "embedder",
|
|
308
|
+
config: {
|
|
309
|
+
apiKey: {
|
|
310
|
+
_type: "string",
|
|
311
|
+
required: true,
|
|
312
|
+
secret: true,
|
|
313
|
+
description: "OpenAI API key",
|
|
314
|
+
},
|
|
315
|
+
model: {
|
|
316
|
+
_type: "string",
|
|
317
|
+
default: "text-embedding-3-small",
|
|
318
|
+
description: "Embedding model",
|
|
319
|
+
},
|
|
320
|
+
batchSize: {
|
|
321
|
+
_type: "number",
|
|
322
|
+
default: 100,
|
|
323
|
+
description: "Batch size for processing",
|
|
324
|
+
},
|
|
325
|
+
},
|
|
326
|
+
dependencies: ["openai"],
|
|
327
|
+
usage: "Generate text embeddings using OpenAI",
|
|
328
|
+
});
|
|
329
|
+
|
|
330
|
+
// Monitoring & Analytics Templates
|
|
331
|
+
this.addTemplate("datadog", {
|
|
332
|
+
name: "Datadog Monitoring",
|
|
333
|
+
category: "monitoring",
|
|
334
|
+
description: "Send metrics and logs to Datadog",
|
|
335
|
+
type: "monitor",
|
|
336
|
+
config: {
|
|
337
|
+
apiKey: {
|
|
338
|
+
_type: "string",
|
|
339
|
+
required: true,
|
|
340
|
+
secret: true,
|
|
341
|
+
description: "Datadog API key",
|
|
342
|
+
},
|
|
343
|
+
site: {
|
|
344
|
+
_type: "string",
|
|
345
|
+
default: "datadoghq.com",
|
|
346
|
+
description: "Datadog site",
|
|
347
|
+
},
|
|
348
|
+
service: {
|
|
349
|
+
_type: "string",
|
|
350
|
+
default: "rag-pipeline",
|
|
351
|
+
description: "Service name",
|
|
352
|
+
},
|
|
353
|
+
environment: {
|
|
354
|
+
_type: "string",
|
|
355
|
+
default: "production",
|
|
356
|
+
description: "Environment",
|
|
357
|
+
},
|
|
358
|
+
},
|
|
359
|
+
dependencies: ["node-statsd", "axios"],
|
|
360
|
+
usage: "Monitor pipeline performance with Datadog",
|
|
361
|
+
});
|
|
362
|
+
|
|
363
|
+
// Initialize categories
|
|
364
|
+
this.categories.set("data-sources", {
|
|
365
|
+
name: "Data Sources",
|
|
366
|
+
description:
|
|
367
|
+
"Connectors for various data sources and content management systems",
|
|
368
|
+
});
|
|
369
|
+
|
|
370
|
+
this.categories.set("vector-stores", {
|
|
371
|
+
name: "Vector Databases",
|
|
372
|
+
description: "Vector database integrations for semantic search",
|
|
373
|
+
});
|
|
374
|
+
|
|
375
|
+
this.categories.set("llm-providers", {
|
|
376
|
+
name: "LLM Providers",
|
|
377
|
+
description: "Language model provider integrations",
|
|
378
|
+
});
|
|
379
|
+
|
|
380
|
+
this.categories.set("embedding-providers", {
|
|
381
|
+
name: "Embedding Providers",
|
|
382
|
+
description: "Text embedding service integrations",
|
|
383
|
+
});
|
|
384
|
+
|
|
385
|
+
this.categories.set("monitoring", {
|
|
386
|
+
name: "Monitoring & Analytics",
|
|
387
|
+
description: "Monitoring, logging, and analytics integrations",
|
|
388
|
+
});
|
|
389
|
+
}
|
|
390
|
+
|
|
391
|
+
/**
|
|
392
|
+
* Add a new template
|
|
393
|
+
*/
|
|
394
|
+
addTemplate(id, template) {
|
|
395
|
+
this.templates.set(id, {
|
|
396
|
+
id,
|
|
397
|
+
...template,
|
|
398
|
+
created: new Date().toISOString(),
|
|
399
|
+
});
|
|
400
|
+
}
|
|
401
|
+
|
|
402
|
+
/**
|
|
403
|
+
* Get template by ID
|
|
404
|
+
*/
|
|
405
|
+
getTemplate(id) {
|
|
406
|
+
const t = this.templates.get(id);
|
|
407
|
+
return t ? addBackCompat(normalize(t)) : undefined;
|
|
408
|
+
}
|
|
409
|
+
|
|
410
|
+
/**
|
|
411
|
+
* Get all templates
|
|
412
|
+
*/
|
|
413
|
+
getAllTemplates() {
|
|
414
|
+
return Array.from(this.templates.values());
|
|
415
|
+
}
|
|
416
|
+
|
|
417
|
+
/**
|
|
418
|
+
* Get templates by category
|
|
419
|
+
*/
|
|
420
|
+
getTemplatesByCategory(category) {
|
|
421
|
+
return Array.from(this.templates.values()).filter(
|
|
422
|
+
(template) => template.category === category,
|
|
423
|
+
);
|
|
424
|
+
}
|
|
425
|
+
|
|
426
|
+
/**
|
|
427
|
+
* Get templates by type
|
|
428
|
+
*/
|
|
429
|
+
getTemplatesByType(type) {
|
|
430
|
+
return Array.from(this.templates.values())
|
|
431
|
+
.filter((t) => (t.type ?? t._type) === type)
|
|
432
|
+
.map((t) => addBackCompat(normalize(t)));
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
/**
|
|
436
|
+
* Search templates
|
|
437
|
+
*/
|
|
438
|
+
searchTemplates(query) {
|
|
439
|
+
const searchTerm = query.toLowerCase();
|
|
440
|
+
return Array.from(this.templates.values()).filter(
|
|
441
|
+
(template) =>
|
|
442
|
+
template.name.toLowerCase().includes(searchTerm) ||
|
|
443
|
+
template.description.toLowerCase().includes(searchTerm) ||
|
|
444
|
+
template.category.toLowerCase().includes(searchTerm),
|
|
445
|
+
);
|
|
446
|
+
}
|
|
447
|
+
|
|
448
|
+
/**
|
|
449
|
+
* Generate integration code from template
|
|
450
|
+
*/
|
|
451
|
+
generateIntegration(templateId, userConfig = {}) {
|
|
452
|
+
const template = this.templates.get(templateId);
|
|
453
|
+
if (!template) {
|
|
454
|
+
throw new Error(`Template ${templateId} not found`);
|
|
455
|
+
}
|
|
456
|
+
|
|
457
|
+
// Validate required config
|
|
458
|
+
const missingRequired = [];
|
|
459
|
+
Object.entries(template.config).forEach(([key, configDef]) => {
|
|
460
|
+
if (configDef.required && !userConfig[key]) {
|
|
461
|
+
missingRequired.push(key);
|
|
462
|
+
}
|
|
463
|
+
});
|
|
464
|
+
|
|
465
|
+
if (missingRequired.length > 0) {
|
|
466
|
+
throw new Error(
|
|
467
|
+
`Missing required configuration: ${missingRequired.join(", ")}`,
|
|
468
|
+
);
|
|
469
|
+
}
|
|
470
|
+
|
|
471
|
+
// Merge with defaults
|
|
472
|
+
const finalConfig = {};
|
|
473
|
+
Object.entries(template.config).forEach(([key, configDef]) => {
|
|
474
|
+
finalConfig[key] =
|
|
475
|
+
userConfig[key] !== undefined ? userConfig[key] : configDef.default;
|
|
476
|
+
});
|
|
477
|
+
|
|
478
|
+
return {
|
|
479
|
+
name: template.name,
|
|
480
|
+
type: template.type,
|
|
481
|
+
config: finalConfig,
|
|
482
|
+
dependencies: template.dependencies || [],
|
|
483
|
+
usage: template.usage,
|
|
484
|
+
setupInstructions: this.generateSetupInstructions(template, finalConfig),
|
|
485
|
+
};
|
|
486
|
+
}
|
|
487
|
+
|
|
488
|
+
/**
|
|
489
|
+
* Generate setup instructions
|
|
490
|
+
*/
|
|
491
|
+
generateSetupInstructions(template, _config) {
|
|
492
|
+
const instructions = [];
|
|
493
|
+
|
|
494
|
+
instructions.push(`# ${template.name} Integration Setup`);
|
|
495
|
+
instructions.push("");
|
|
496
|
+
instructions.push("## 1. Install Dependencies");
|
|
497
|
+
instructions.push("```bash");
|
|
498
|
+
instructions.push(`npm install ${template.dependencies.join(" ")}`);
|
|
499
|
+
instructions.push("```");
|
|
500
|
+
instructions.push("");
|
|
501
|
+
instructions.push("## 2. Configuration");
|
|
502
|
+
instructions.push("```javascript");
|
|
503
|
+
instructions.push(`const _config = ${JSON.stringify(_config, null, 2)};`);
|
|
504
|
+
instructions.push("```");
|
|
505
|
+
instructions.push("");
|
|
506
|
+
instructions.push("## 3. Usage");
|
|
507
|
+
instructions.push(`${template.usage}`);
|
|
508
|
+
|
|
509
|
+
return instructions.join("\n");
|
|
510
|
+
}
|
|
511
|
+
|
|
512
|
+
/**
|
|
513
|
+
* Get all categories
|
|
514
|
+
*/
|
|
515
|
+
getAllCategories() {
|
|
516
|
+
return Array.from(this.categories.values());
|
|
517
|
+
}
|
|
518
|
+
|
|
519
|
+
/**
|
|
520
|
+
* Export template as file
|
|
521
|
+
*/
|
|
522
|
+
async exportTemplate(templateId, outputDir = "./templates") {
|
|
523
|
+
const template = this.templates.get(templateId);
|
|
524
|
+
if (!template) {
|
|
525
|
+
throw new Error(`Template ${templateId} not found`);
|
|
526
|
+
}
|
|
527
|
+
|
|
528
|
+
await fs.mkdir(outputDir, { recursive: true });
|
|
529
|
+
|
|
530
|
+
const _filePath = path.join(outputDir, `${templateId}.json`);
|
|
531
|
+
await fs.writeFile(_filePath, JSON.stringify(template, null, 2));
|
|
532
|
+
|
|
533
|
+
return _filePath;
|
|
534
|
+
}
|
|
535
|
+
|
|
536
|
+
/**
|
|
537
|
+
* Import template from file
|
|
538
|
+
*/
|
|
539
|
+
async importTemplate(_filePath) {
|
|
540
|
+
const data = await fs.readFile(_filePath, "utf8");
|
|
541
|
+
const template = JSON.parse(data);
|
|
542
|
+
|
|
543
|
+
if (!template.id) {
|
|
544
|
+
throw new Error("Template must have an id field");
|
|
545
|
+
}
|
|
546
|
+
|
|
547
|
+
this.addTemplate(template.id, template);
|
|
548
|
+
return template.id;
|
|
549
|
+
}
|
|
550
|
+
|
|
551
|
+
/**
|
|
552
|
+
* Get template statistics
|
|
553
|
+
*/
|
|
554
|
+
getStatistics() {
|
|
555
|
+
const templates = Array.from(this.templates.values());
|
|
556
|
+
const categories = {};
|
|
557
|
+
const types = {};
|
|
558
|
+
|
|
559
|
+
templates.forEach((template) => {
|
|
560
|
+
categories[template.category] = (categories[template.category] || 0) + 1;
|
|
561
|
+
types[template.type] = (types[template.type] || 0) + 1;
|
|
562
|
+
});
|
|
563
|
+
|
|
564
|
+
return {
|
|
565
|
+
totalTemplates: templates.length,
|
|
566
|
+
categoryCounts: categories,
|
|
567
|
+
typeCounts: types,
|
|
568
|
+
totalCategories: this.categories.size,
|
|
569
|
+
};
|
|
570
|
+
}
|
|
571
|
+
|
|
572
|
+
/**
|
|
573
|
+
* Get template statistics (alias for tests)
|
|
574
|
+
*/
|
|
575
|
+
getTemplateStats() {
|
|
576
|
+
return this.getStatistics();
|
|
577
|
+
}
|
|
578
|
+
}
|
|
579
|
+
|
|
580
|
+
// Create a singleton instance for module-level exports
|
|
581
|
+
const defaultInstance = new IntegrationTemplates();
|
|
582
|
+
|
|
583
|
+
// Module-level _config object with templates
|
|
584
|
+
const _config = {
|
|
585
|
+
llm: {
|
|
586
|
+
"openai-gpt4": {
|
|
587
|
+
name: "OpenAI GPT-4",
|
|
588
|
+
category: "llm-providers",
|
|
589
|
+
description: "OpenAI GPT-4 language model integration",
|
|
590
|
+
type: "llm",
|
|
591
|
+
config: {
|
|
592
|
+
apiKey: {
|
|
593
|
+
_type: "string",
|
|
594
|
+
required: true,
|
|
595
|
+
secret: true,
|
|
596
|
+
description: "OpenAI API key",
|
|
597
|
+
},
|
|
598
|
+
model: { _type: "string", default: "gpt-4", description: "Model name" },
|
|
599
|
+
temperature: {
|
|
600
|
+
_type: "number",
|
|
601
|
+
default: 0.7,
|
|
602
|
+
description: "Sampling temperature",
|
|
603
|
+
},
|
|
604
|
+
maxTokens: {
|
|
605
|
+
_type: "number",
|
|
606
|
+
default: 1000,
|
|
607
|
+
description: "Maximum tokens to generate",
|
|
608
|
+
},
|
|
609
|
+
},
|
|
610
|
+
dependencies: ["openai"],
|
|
611
|
+
usage: "Generate responses using OpenAI GPT-4",
|
|
612
|
+
},
|
|
613
|
+
},
|
|
614
|
+
loader: {
|
|
615
|
+
confluence: {
|
|
616
|
+
name: "Atlassian Confluence",
|
|
617
|
+
category: "data-sources",
|
|
618
|
+
description: "Connect to Confluence spaces and pages",
|
|
619
|
+
type: "loader",
|
|
620
|
+
config: {
|
|
621
|
+
baseUrl: {
|
|
622
|
+
_type: "string",
|
|
623
|
+
required: true,
|
|
624
|
+
description: "Confluence base URL",
|
|
625
|
+
},
|
|
626
|
+
username: {
|
|
627
|
+
_type: "string",
|
|
628
|
+
required: true,
|
|
629
|
+
description: "Username or email",
|
|
630
|
+
},
|
|
631
|
+
apiToken: {
|
|
632
|
+
_type: "string",
|
|
633
|
+
required: true,
|
|
634
|
+
secret: true,
|
|
635
|
+
description: "API token",
|
|
636
|
+
},
|
|
637
|
+
},
|
|
638
|
+
dependencies: ["axios"],
|
|
639
|
+
usage: "Load documents from Confluence spaces and pages",
|
|
640
|
+
},
|
|
641
|
+
},
|
|
642
|
+
};
|
|
643
|
+
|
|
644
|
+
// Module-level functions
|
|
645
|
+
function generateIntegration(templateKey, userConfig = {}) {
|
|
646
|
+
return defaultInstance.generateIntegration(templateKey, userConfig);
|
|
647
|
+
}
|
|
648
|
+
|
|
649
|
+
function getTemplateStats() {
|
|
650
|
+
return defaultInstance.getTemplateStats();
|
|
651
|
+
}
|
|
652
|
+
|
|
653
|
+
function addTemplate(key, def) {
|
|
654
|
+
return defaultInstance.addTemplate(key, def);
|
|
655
|
+
}
|
|
656
|
+
|
|
657
|
+
// Export both class and module-level API
|
|
658
|
+
module.exports = IntegrationTemplates;
|
|
659
|
+
module.exports._config = _config;
|
|
660
|
+
module.exports.generateIntegration = generateIntegration;
|
|
661
|
+
module.exports.getTemplateStats = getTemplateStats;
|
|
662
|
+
module.exports.addTemplate = addTemplate;
|
|
663
|
+
|
|
664
|
+
// CJS+ESM interop pattern
|
|
665
|
+
module.exports.default = module.exports;
|