@vfarcic/dot-ai 0.124.0 → 0.126.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/assets/project-setup/templates/.github/CODEOWNERS.hbs +25 -0
- package/assets/project-setup/templates/.github/FUNDING.yml.hbs +35 -0
- package/assets/project-setup/templates/.github/ISSUE_TEMPLATE/bug_report.yml.hbs +175 -0
- package/assets/project-setup/templates/.github/ISSUE_TEMPLATE/config.yml.hbs +32 -0
- package/assets/project-setup/templates/.github/ISSUE_TEMPLATE/feature_request.yml.hbs +134 -0
- package/assets/project-setup/templates/.github/PULL_REQUEST_TEMPLATE.md.hbs +172 -0
- package/assets/project-setup/templates/.github/labeler.yml.hbs +123 -0
- package/assets/project-setup/templates/.github/release.yml.hbs +51 -0
- package/assets/project-setup/templates/.github/workflows/labeler.yml.hbs +21 -0
- package/assets/project-setup/templates/.github/workflows/scorecard.yml.hbs +71 -0
- package/assets/project-setup/templates/.github/workflows/stale.yml.hbs +57 -0
- package/dist/core/ai-provider-factory.d.ts.map +1 -1
- package/dist/core/ai-provider-factory.js +22 -5
- package/dist/core/ai-provider.interface.d.ts +16 -0
- package/dist/core/ai-provider.interface.d.ts.map +1 -1
- package/dist/core/capability-scan-workflow.d.ts +4 -9
- package/dist/core/capability-scan-workflow.d.ts.map +1 -1
- package/dist/core/capability-scan-workflow.js +203 -456
- package/dist/core/discovery.d.ts +6 -0
- package/dist/core/discovery.d.ts.map +1 -1
- package/dist/core/discovery.js +39 -3
- package/dist/core/embedding-service.d.ts +9 -36
- package/dist/core/embedding-service.d.ts.map +1 -1
- package/dist/core/embedding-service.js +137 -246
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.js +2 -2
- package/dist/core/kubernetes-utils.d.ts +1 -0
- package/dist/core/kubernetes-utils.d.ts.map +1 -1
- package/dist/core/kubernetes-utils.js +53 -48
- package/dist/core/model-config.d.ts +2 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +3 -1
- package/dist/core/providers/anthropic-provider.d.ts.map +1 -1
- package/dist/core/providers/anthropic-provider.js +352 -282
- package/dist/core/providers/provider-debug-utils.d.ts +4 -0
- package/dist/core/providers/provider-debug-utils.d.ts.map +1 -1
- package/dist/core/providers/provider-debug-utils.js +25 -3
- package/dist/core/providers/vercel-provider.d.ts +1 -0
- package/dist/core/providers/vercel-provider.d.ts.map +1 -1
- package/dist/core/providers/vercel-provider.js +412 -345
- package/dist/core/tracing/ai-tracing.d.ts +80 -0
- package/dist/core/tracing/ai-tracing.d.ts.map +1 -0
- package/dist/core/tracing/ai-tracing.js +122 -0
- package/dist/core/tracing/config.d.ts +15 -0
- package/dist/core/tracing/config.d.ts.map +1 -0
- package/dist/core/tracing/config.js +133 -0
- package/dist/core/tracing/http-tracing.d.ts +28 -0
- package/dist/core/tracing/http-tracing.d.ts.map +1 -0
- package/dist/core/tracing/http-tracing.js +119 -0
- package/dist/core/tracing/index.d.ts +14 -0
- package/dist/core/tracing/index.d.ts.map +1 -0
- package/dist/core/tracing/index.js +40 -0
- package/dist/core/tracing/k8s-tracing.d.ts +57 -0
- package/dist/core/tracing/k8s-tracing.d.ts.map +1 -0
- package/dist/core/tracing/k8s-tracing.js +155 -0
- package/dist/core/tracing/qdrant-tracing.d.ts +68 -0
- package/dist/core/tracing/qdrant-tracing.d.ts.map +1 -0
- package/dist/core/tracing/qdrant-tracing.js +102 -0
- package/dist/core/tracing/tool-tracing.d.ts +31 -0
- package/dist/core/tracing/tool-tracing.d.ts.map +1 -0
- package/dist/core/tracing/tool-tracing.js +76 -0
- package/dist/core/tracing/tracer.d.ts +21 -0
- package/dist/core/tracing/tracer.d.ts.map +1 -0
- package/dist/core/tracing/tracer.js +215 -0
- package/dist/core/tracing/types.d.ts +86 -0
- package/dist/core/tracing/types.d.ts.map +1 -0
- package/dist/core/tracing/types.js +41 -0
- package/dist/core/unified-creation-session.js +1 -1
- package/dist/core/vector-db-service.d.ts.map +1 -1
- package/dist/core/vector-db-service.js +238 -163
- package/dist/interfaces/mcp.d.ts.map +1 -1
- package/dist/interfaces/mcp.js +71 -43
- package/dist/mcp/server.js +12 -2
- package/dist/tools/organizational-data.d.ts.map +1 -1
- package/dist/tools/organizational-data.js +2 -4
- package/dist/tools/version.d.ts +12 -1
- package/dist/tools/version.d.ts.map +1 -1
- package/dist/tools/version.js +24 -4
- package/package.json +11 -1
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* OpenTelemetry Tracing Types
|
|
3
|
+
*
|
|
4
|
+
* Type definitions for distributed tracing configuration and interfaces.
|
|
5
|
+
*/
|
|
6
|
+
import { Span, SpanOptions, Context } from '@opentelemetry/api';
|
|
7
|
+
/**
|
|
8
|
+
* Tracing configuration options
|
|
9
|
+
*/
|
|
10
|
+
export interface TracingConfig {
|
|
11
|
+
/** Service name for identification in traces (default: "dot-ai-mcp") */
|
|
12
|
+
serviceName: string;
|
|
13
|
+
/** Service version for tracking deployments (default: package.json version) */
|
|
14
|
+
serviceVersion: string;
|
|
15
|
+
/** Exporter type: console (dev), otlp (production), jaeger, zipkin */
|
|
16
|
+
exporterType: 'console' | 'otlp' | 'jaeger' | 'zipkin';
|
|
17
|
+
/** OTLP exporter endpoint (e.g., http://localhost:4318) */
|
|
18
|
+
otlpEndpoint?: string;
|
|
19
|
+
/** Enable tracing (default: true) */
|
|
20
|
+
enabled: boolean;
|
|
21
|
+
/** Sampling probability (0.0 to 1.0, default: 1.0 for always-on) */
|
|
22
|
+
samplingProbability: number;
|
|
23
|
+
/** Enable debug mode for verbose logging */
|
|
24
|
+
debug: boolean;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Span wrapper with utility methods
|
|
28
|
+
*/
|
|
29
|
+
export interface TracedSpan {
|
|
30
|
+
/** The underlying OpenTelemetry span */
|
|
31
|
+
span: Span;
|
|
32
|
+
/** End the span successfully */
|
|
33
|
+
end(): void;
|
|
34
|
+
/** End the span with an error */
|
|
35
|
+
endWithError(error: Error): void;
|
|
36
|
+
/** Add custom attributes to the span */
|
|
37
|
+
setAttributes(attributes: Record<string, string | number | boolean>): void;
|
|
38
|
+
/** Add an event to the span */
|
|
39
|
+
addEvent(name: string, attributes?: Record<string, string | number | boolean>): void;
|
|
40
|
+
}
|
|
41
|
+
/**
|
|
42
|
+
* Tracer service interface
|
|
43
|
+
*/
|
|
44
|
+
export interface TracerService {
|
|
45
|
+
/** Initialize the tracer (called lazily on first use) */
|
|
46
|
+
initialize(): void;
|
|
47
|
+
/** Check if tracing is enabled */
|
|
48
|
+
isEnabled(): boolean;
|
|
49
|
+
/** Create a new span */
|
|
50
|
+
startSpan(name: string, options?: SpanOptions, context?: Context): TracedSpan;
|
|
51
|
+
/** Shutdown the tracer gracefully */
|
|
52
|
+
shutdown(): Promise<void>;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Span kind enumeration (re-export for convenience)
|
|
56
|
+
*/
|
|
57
|
+
export declare enum SpanKind {
|
|
58
|
+
/** Internal operation (business logic, workflows) */
|
|
59
|
+
INTERNAL = 0,
|
|
60
|
+
/** Incoming request (HTTP server, MCP entry point) */
|
|
61
|
+
SERVER = 1,
|
|
62
|
+
/** Outgoing request (AI provider, K8s API, Vector DB, HTTP client) */
|
|
63
|
+
CLIENT = 2,
|
|
64
|
+
/** Message producer */
|
|
65
|
+
PRODUCER = 3,
|
|
66
|
+
/** Message consumer */
|
|
67
|
+
CONSUMER = 4
|
|
68
|
+
}
|
|
69
|
+
/**
|
|
70
|
+
* Common semantic convention attribute namespaces
|
|
71
|
+
*/
|
|
72
|
+
export declare const SemanticAttributes: {
|
|
73
|
+
/** HTTP attributes (http.request.method, http.response.status_code) */
|
|
74
|
+
readonly HTTP: "http";
|
|
75
|
+
/** GenAI attributes (gen_ai.operation.name, gen_ai.provider.name) */
|
|
76
|
+
readonly GEN_AI: "gen_ai";
|
|
77
|
+
/** Database attributes (db.system.name, db.operation.name, db.collection.name) */
|
|
78
|
+
readonly DATABASE: "db";
|
|
79
|
+
/** Kubernetes attributes (k8s.operation, k8s.resource.kind, k8s.namespace) */
|
|
80
|
+
readonly KUBERNETES: "k8s";
|
|
81
|
+
/** Server attributes (server.address, server.port) */
|
|
82
|
+
readonly SERVER: "server";
|
|
83
|
+
/** Network attributes (network.peer.address, network.peer.port) */
|
|
84
|
+
readonly NETWORK: "network";
|
|
85
|
+
};
|
|
86
|
+
//# sourceMappingURL=types.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/core/tracing/types.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,WAAW,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAEhE;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,wEAAwE;IACxE,WAAW,EAAE,MAAM,CAAC;IAEpB,+EAA+E;IAC/E,cAAc,EAAE,MAAM,CAAC;IAEvB,sEAAsE;IACtE,YAAY,EAAE,SAAS,GAAG,MAAM,GAAG,QAAQ,GAAG,QAAQ,CAAC;IAEvD,2DAA2D;IAC3D,YAAY,CAAC,EAAE,MAAM,CAAC;IAEtB,qCAAqC;IACrC,OAAO,EAAE,OAAO,CAAC;IAEjB,oEAAoE;IACpE,mBAAmB,EAAE,MAAM,CAAC;IAE5B,4CAA4C;IAC5C,KAAK,EAAE,OAAO,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,wCAAwC;IACxC,IAAI,EAAE,IAAI,CAAC;IAEX,gCAAgC;IAChC,GAAG,IAAI,IAAI,CAAC;IAEZ,iCAAiC;IACjC,YAAY,CAAC,KAAK,EAAE,KAAK,GAAG,IAAI,CAAC;IAEjC,wCAAwC;IACxC,aAAa,CAAC,UAAU,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC;IAE3E,+BAA+B;IAC/B,QAAQ,CAAC,IAAI,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,CAAC,GAAG,IAAI,CAAC;CACtF;AAED;;GAEG;AACH,MAAM,WAAW,aAAa;IAC5B,yDAAyD;IACzD,UAAU,IAAI,IAAI,CAAC;IAEnB,kCAAkC;IAClC,SAAS,IAAI,OAAO,CAAC;IAErB,wBAAwB;IACxB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,WAAW,EAAE,OAAO,CAAC,EAAE,OAAO,GAAG,UAAU,CAAC;IAE9E,qCAAqC;IACrC,QAAQ,IAAI,OAAO,CAAC,IAAI,CAAC,CAAC;CAC3B;AAED;;GAEG;AACH,oBAAY,QAAQ;IAClB,qDAAqD;IACrD,QAAQ,IAAI;IAEZ,sDAAsD;IACtD,MAAM,IAAI;IAEV,sEAAsE;IACtE,MAAM,IAAI;IAEV,uBAAuB;IACvB,QAAQ,IAAI;IAEZ,uBAAuB;IACvB,QAAQ,IAAI;CACb;AAED;;GAEG;AACH,eAAO,MAAM,kBAAkB;IAC7B,uEAAuE;;IAGvE,qEAAqE;;IAGrE,kFAAkF;;IAGlF,8EAA8E;;IAG9E,sDAAsD;;IAGtD,mEAAmE;;CAE3D,CAAC"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* OpenTelemetry Tracing Types
|
|
4
|
+
*
|
|
5
|
+
* Type definitions for distributed tracing configuration and interfaces.
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.SemanticAttributes = exports.SpanKind = void 0;
|
|
9
|
+
/**
|
|
10
|
+
* Span kind enumeration (re-export for convenience)
|
|
11
|
+
*/
|
|
12
|
+
var SpanKind;
|
|
13
|
+
(function (SpanKind) {
|
|
14
|
+
/** Internal operation (business logic, workflows) */
|
|
15
|
+
SpanKind[SpanKind["INTERNAL"] = 0] = "INTERNAL";
|
|
16
|
+
/** Incoming request (HTTP server, MCP entry point) */
|
|
17
|
+
SpanKind[SpanKind["SERVER"] = 1] = "SERVER";
|
|
18
|
+
/** Outgoing request (AI provider, K8s API, Vector DB, HTTP client) */
|
|
19
|
+
SpanKind[SpanKind["CLIENT"] = 2] = "CLIENT";
|
|
20
|
+
/** Message producer */
|
|
21
|
+
SpanKind[SpanKind["PRODUCER"] = 3] = "PRODUCER";
|
|
22
|
+
/** Message consumer */
|
|
23
|
+
SpanKind[SpanKind["CONSUMER"] = 4] = "CONSUMER";
|
|
24
|
+
})(SpanKind || (exports.SpanKind = SpanKind = {}));
|
|
25
|
+
/**
|
|
26
|
+
* Common semantic convention attribute namespaces
|
|
27
|
+
*/
|
|
28
|
+
exports.SemanticAttributes = {
|
|
29
|
+
/** HTTP attributes (http.request.method, http.response.status_code) */
|
|
30
|
+
HTTP: 'http',
|
|
31
|
+
/** GenAI attributes (gen_ai.operation.name, gen_ai.provider.name) */
|
|
32
|
+
GEN_AI: 'gen_ai',
|
|
33
|
+
/** Database attributes (db.system.name, db.operation.name, db.collection.name) */
|
|
34
|
+
DATABASE: 'db',
|
|
35
|
+
/** Kubernetes attributes (k8s.operation, k8s.resource.kind, k8s.namespace) */
|
|
36
|
+
KUBERNETES: 'k8s',
|
|
37
|
+
/** Server attributes (server.address, server.port) */
|
|
38
|
+
SERVER: 'server',
|
|
39
|
+
/** Network attributes (network.peer.address, network.peer.port) */
|
|
40
|
+
NETWORK: 'network'
|
|
41
|
+
};
|
|
@@ -833,7 +833,7 @@ Please try again or modify your policy description.`,
|
|
|
833
833
|
const capabilityService = new capability_vector_service_1.CapabilityVectorService(collection);
|
|
834
834
|
// Use existing searchCapabilities function - no fallback, let it throw if it fails
|
|
835
835
|
const searchResults = await capabilityService.searchCapabilities(searchQuery, {
|
|
836
|
-
limit:
|
|
836
|
+
limit: 30 // Reduced from 50 to stay within 200K token context limit (testing shows 35 still exceeds)
|
|
837
837
|
});
|
|
838
838
|
if (searchResults.length === 0) {
|
|
839
839
|
throw new Error(`No relevant capabilities found for policy description: "${policyDescription}"`);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"vector-db-service.d.ts","sourceRoot":"","sources":["../../src/core/vector-db-service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;
|
|
1
|
+
{"version":3,"file":"vector-db-service.d.ts","sourceRoot":"","sources":["../../src/core/vector-db-service.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAKH,MAAM,WAAW,cAAc;IAC7B,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC7B,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACnB;AAED,MAAM,WAAW,YAAY;IAC3B,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAC9B;AAED,MAAM,WAAW,aAAa;IAC5B,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,cAAc,CAAC,EAAE,MAAM,CAAC;CACzB;AAED,qBAAa,eAAe;IAC1B,OAAO,CAAC,MAAM,CAA6B;IAC3C,OAAO,CAAC,MAAM,CAAiB;IAC/B,OAAO,CAAC,cAAc,CAAS;gBAEnB,MAAM,GAAE,cAAmB;IAsBvC,OAAO,CAAC,cAAc;IAWtB,OAAO,CAAC,sBAAsB;IAM9B;;OAEG;IACG,oBAAoB,CAAC,UAAU,GAAE,MAAY,GAAG,OAAO,CAAC,IAAI,CAAC;IAiDnE;;OAEG;YACW,gBAAgB;IAkB9B;;OAEG;IACG,cAAc,CAAC,QAAQ,EAAE,cAAc,GAAG,OAAO,CAAC,IAAI,CAAC;IAqC7D;;OAEG;IACG,aAAa,CACjB,MAAM,EAAE,MAAM,EAAE,EAChB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,EAAE,CAAC;IAsC1B;;OAEG;IACG,gBAAgB,CACpB,QAAQ,EAAE,MAAM,EAAE,EAClB,OAAO,GAAE,aAAkB,GAC1B,OAAO,CAAC,YAAY,EAAE,CAAC;IAuD1B;;OAEG;IACG,WAAW,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,GAAG,IAAI,CAAC;IAqC7D;;OAEG;IACG,cAAc,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAyB/C;;;;OAIG;IACG,kBAAkB,IAAI,OAAO,CAAC,IAAI,CAAC;IAuCzC;;;OAGG;IACG,eAAe,CAAC,KAAK,GAAE,MAAc,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC;IAyCvE;;OAEG;IACG,iBAAiB,IAAI,OAAO,CAAC,GAAG,CAAC;IAqBvC;;OAEG;IACG,WAAW,IAAI,OAAO,CAAC,OAAO,CAAC;IAsBrC;;OAEG;IACH,aAAa,IAAI,OAAO;IAIxB;;OAEG;IACH,SAAS,IAAI,cAAc;CAG5B"}
|
|
@@ -7,6 +7,7 @@
|
|
|
7
7
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
8
|
exports.VectorDBService = void 0;
|
|
9
9
|
const js_client_rest_1 = require("@qdrant/js-client-rest");
|
|
10
|
+
const qdrant_tracing_1 = require("./tracing/qdrant-tracing");
|
|
10
11
|
class VectorDBService {
|
|
11
12
|
client = null;
|
|
12
13
|
config;
|
|
@@ -50,37 +51,44 @@ class VectorDBService {
|
|
|
50
51
|
if (!this.client) {
|
|
51
52
|
throw new Error('Vector DB client not initialized');
|
|
52
53
|
}
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
54
|
+
return (0, qdrant_tracing_1.withQdrantTracing)({
|
|
55
|
+
operation: 'collection.initialize',
|
|
56
|
+
collectionName: this.collectionName,
|
|
57
|
+
vectorSize,
|
|
58
|
+
serverUrl: this.config.url
|
|
59
|
+
}, async () => {
|
|
60
|
+
try {
|
|
61
|
+
// Check if collection exists
|
|
62
|
+
const collections = await this.client.getCollections();
|
|
63
|
+
const collectionExists = collections.collections.some(col => col.name === this.collectionName);
|
|
64
|
+
if (collectionExists) {
|
|
65
|
+
// Verify existing collection has correct vector dimensions
|
|
66
|
+
try {
|
|
67
|
+
const collectionInfo = await this.client.getCollection(this.collectionName);
|
|
68
|
+
const existingVectorSize = collectionInfo.config?.params?.vectors?.size;
|
|
69
|
+
if (existingVectorSize && existingVectorSize !== vectorSize) {
|
|
70
|
+
// Dimension mismatch - recreate collection
|
|
71
|
+
console.warn(`Vector dimension mismatch: existing collection has ${existingVectorSize} dimensions, but ${vectorSize} expected. Recreating collection.`);
|
|
72
|
+
await this.client.deleteCollection(this.collectionName);
|
|
73
|
+
await this.createCollection(vectorSize);
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
catch (error) {
|
|
77
|
+
// If we can't get collection info, assume it's corrupted and recreate
|
|
78
|
+
console.warn(`Failed to get collection info, recreating collection: ${error}`);
|
|
65
79
|
await this.client.deleteCollection(this.collectionName);
|
|
66
80
|
await this.createCollection(vectorSize);
|
|
67
81
|
}
|
|
68
82
|
}
|
|
69
|
-
|
|
70
|
-
//
|
|
71
|
-
console.warn(`Failed to get collection info, recreating collection: ${error}`);
|
|
72
|
-
await this.client.deleteCollection(this.collectionName);
|
|
83
|
+
else {
|
|
84
|
+
// Create new collection
|
|
73
85
|
await this.createCollection(vectorSize);
|
|
74
86
|
}
|
|
75
87
|
}
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
await this.createCollection(vectorSize);
|
|
88
|
+
catch (error) {
|
|
89
|
+
throw new Error(`Failed to initialize collection: ${error}`);
|
|
79
90
|
}
|
|
80
|
-
}
|
|
81
|
-
catch (error) {
|
|
82
|
-
throw new Error(`Failed to initialize collection: ${error}`);
|
|
83
|
-
}
|
|
91
|
+
});
|
|
84
92
|
}
|
|
85
93
|
/**
|
|
86
94
|
* Create collection with specified vector size
|
|
@@ -108,24 +116,32 @@ class VectorDBService {
|
|
|
108
116
|
if (!this.client) {
|
|
109
117
|
throw new Error('Vector DB client not initialized');
|
|
110
118
|
}
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
119
|
+
return (0, qdrant_tracing_1.withQdrantTracing)({
|
|
120
|
+
operation: 'vector.upsert',
|
|
121
|
+
collectionName: this.collectionName,
|
|
122
|
+
documentId: document.id,
|
|
123
|
+
vectorSize: document.vector?.length,
|
|
124
|
+
serverUrl: this.config.url
|
|
125
|
+
}, async () => {
|
|
126
|
+
try {
|
|
127
|
+
const point = {
|
|
128
|
+
id: document.id,
|
|
129
|
+
payload: document.payload,
|
|
130
|
+
vector: document.vector
|
|
131
|
+
};
|
|
132
|
+
// Validate vector is provided
|
|
133
|
+
if (!document.vector || document.vector.length === 0) {
|
|
134
|
+
throw new Error('Vector is required for vector database storage');
|
|
135
|
+
}
|
|
136
|
+
await this.client.upsert(this.collectionName, {
|
|
137
|
+
wait: true,
|
|
138
|
+
points: [point]
|
|
139
|
+
});
|
|
120
140
|
}
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
}
|
|
126
|
-
catch (error) {
|
|
127
|
-
throw new Error(`Failed to upsert document: ${error}`);
|
|
128
|
-
}
|
|
141
|
+
catch (error) {
|
|
142
|
+
throw new Error(`Failed to upsert document: ${error}`);
|
|
143
|
+
}
|
|
144
|
+
});
|
|
129
145
|
}
|
|
130
146
|
/**
|
|
131
147
|
* Search for similar documents using vector similarity
|
|
@@ -134,22 +150,33 @@ class VectorDBService {
|
|
|
134
150
|
if (!this.client) {
|
|
135
151
|
throw new Error('Vector DB client not initialized');
|
|
136
152
|
}
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
+
const limit = options.limit || 10;
|
|
154
|
+
const scoreThreshold = options.scoreThreshold || 0.5;
|
|
155
|
+
return (0, qdrant_tracing_1.withQdrantTracing)({
|
|
156
|
+
operation: 'vector.search',
|
|
157
|
+
collectionName: this.collectionName,
|
|
158
|
+
vectorSize: vector.length,
|
|
159
|
+
limit,
|
|
160
|
+
scoreThreshold,
|
|
161
|
+
serverUrl: this.config.url
|
|
162
|
+
}, async () => {
|
|
163
|
+
try {
|
|
164
|
+
const searchResult = await this.client.search(this.collectionName, {
|
|
165
|
+
vector,
|
|
166
|
+
limit,
|
|
167
|
+
score_threshold: scoreThreshold,
|
|
168
|
+
with_payload: true
|
|
169
|
+
});
|
|
170
|
+
return searchResult.map(result => ({
|
|
171
|
+
id: result.id.toString(),
|
|
172
|
+
score: result.score,
|
|
173
|
+
payload: result.payload || {}
|
|
174
|
+
}));
|
|
175
|
+
}
|
|
176
|
+
catch (error) {
|
|
177
|
+
throw new Error(`Failed to search documents: ${error}`);
|
|
178
|
+
}
|
|
179
|
+
});
|
|
153
180
|
}
|
|
154
181
|
/**
|
|
155
182
|
* Search for documents using payload filtering (keyword search)
|
|
@@ -158,34 +185,43 @@ class VectorDBService {
|
|
|
158
185
|
if (!this.client) {
|
|
159
186
|
throw new Error('Vector DB client not initialized');
|
|
160
187
|
}
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
188
|
+
const limit = options.limit || 10;
|
|
189
|
+
return (0, qdrant_tracing_1.withQdrantTracing)({
|
|
190
|
+
operation: 'vector.search_keywords',
|
|
191
|
+
collectionName: this.collectionName,
|
|
192
|
+
keywordCount: keywords.length,
|
|
193
|
+
limit,
|
|
194
|
+
serverUrl: this.config.url
|
|
195
|
+
}, async () => {
|
|
196
|
+
try {
|
|
197
|
+
// Fallback to JavaScript-based filtering due to Qdrant filter syntax issues
|
|
198
|
+
// Get all documents and filter in JavaScript for keyword matching
|
|
199
|
+
const scrollResult = await this.client.scroll(this.collectionName, {
|
|
200
|
+
limit: 1000, // Get all documents for filtering
|
|
201
|
+
with_payload: true,
|
|
202
|
+
with_vector: false
|
|
203
|
+
});
|
|
204
|
+
// Filter documents by checking if any keyword matches any trigger
|
|
205
|
+
const matchedPoints = scrollResult.points.filter(point => {
|
|
206
|
+
if (!point.payload || !point.payload.triggers || !Array.isArray(point.payload.triggers)) {
|
|
207
|
+
return false;
|
|
208
|
+
}
|
|
209
|
+
const triggers = point.payload.triggers.map((t) => t.toLowerCase());
|
|
210
|
+
return keywords.some(keyword => triggers.some(trigger => trigger.includes(keyword.toLowerCase()) ||
|
|
211
|
+
keyword.toLowerCase().includes(trigger)));
|
|
212
|
+
});
|
|
213
|
+
// Apply limit after filtering
|
|
214
|
+
const limitedResults = matchedPoints.slice(0, limit);
|
|
215
|
+
return limitedResults.map(point => ({
|
|
216
|
+
id: point.id.toString(),
|
|
217
|
+
score: 1.0, // Keyword matches get full score
|
|
218
|
+
payload: point.payload || {}
|
|
219
|
+
}));
|
|
220
|
+
}
|
|
221
|
+
catch (error) {
|
|
222
|
+
throw new Error(`Failed to search by keywords: ${error}`);
|
|
223
|
+
}
|
|
224
|
+
});
|
|
189
225
|
}
|
|
190
226
|
/**
|
|
191
227
|
* Get a document by ID
|
|
@@ -194,25 +230,32 @@ class VectorDBService {
|
|
|
194
230
|
if (!this.client) {
|
|
195
231
|
throw new Error('Vector DB client not initialized');
|
|
196
232
|
}
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
233
|
+
return (0, qdrant_tracing_1.withQdrantTracing)({
|
|
234
|
+
operation: 'vector.retrieve',
|
|
235
|
+
collectionName: this.collectionName,
|
|
236
|
+
documentId: id,
|
|
237
|
+
serverUrl: this.config.url
|
|
238
|
+
}, async () => {
|
|
239
|
+
try {
|
|
240
|
+
const result = await this.client.retrieve(this.collectionName, {
|
|
241
|
+
ids: [id],
|
|
242
|
+
with_payload: true,
|
|
243
|
+
with_vector: true
|
|
244
|
+
});
|
|
245
|
+
if (result.length === 0) {
|
|
246
|
+
return null;
|
|
247
|
+
}
|
|
248
|
+
const point = result[0];
|
|
249
|
+
return {
|
|
250
|
+
id: point.id.toString(),
|
|
251
|
+
payload: point.payload || {},
|
|
252
|
+
vector: point.vector || undefined
|
|
253
|
+
};
|
|
205
254
|
}
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
vector: point.vector || undefined
|
|
211
|
-
};
|
|
212
|
-
}
|
|
213
|
-
catch (error) {
|
|
214
|
-
throw new Error(`Failed to get document: ${error}`);
|
|
215
|
-
}
|
|
255
|
+
catch (error) {
|
|
256
|
+
throw new Error(`Failed to get document: ${error}`);
|
|
257
|
+
}
|
|
258
|
+
});
|
|
216
259
|
}
|
|
217
260
|
/**
|
|
218
261
|
* Delete a document by ID
|
|
@@ -221,15 +264,22 @@ class VectorDBService {
|
|
|
221
264
|
if (!this.client) {
|
|
222
265
|
throw new Error('Vector DB client not initialized');
|
|
223
266
|
}
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
}
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
267
|
+
return (0, qdrant_tracing_1.withQdrantTracing)({
|
|
268
|
+
operation: 'vector.delete',
|
|
269
|
+
collectionName: this.collectionName,
|
|
270
|
+
documentId: id,
|
|
271
|
+
serverUrl: this.config.url
|
|
272
|
+
}, async () => {
|
|
273
|
+
try {
|
|
274
|
+
await this.client.delete(this.collectionName, {
|
|
275
|
+
wait: true,
|
|
276
|
+
points: [id]
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
catch (error) {
|
|
280
|
+
throw new Error(`Failed to delete document: ${error}`);
|
|
281
|
+
}
|
|
282
|
+
});
|
|
233
283
|
}
|
|
234
284
|
/**
|
|
235
285
|
* Delete all documents by clearing all points from the collection
|
|
@@ -240,27 +290,33 @@ class VectorDBService {
|
|
|
240
290
|
if (!this.client) {
|
|
241
291
|
throw new Error('Vector DB client not initialized');
|
|
242
292
|
}
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
293
|
+
return (0, qdrant_tracing_1.withQdrantTracing)({
|
|
294
|
+
operation: 'vector.delete_all',
|
|
295
|
+
collectionName: this.collectionName,
|
|
296
|
+
serverUrl: this.config.url
|
|
297
|
+
}, async () => {
|
|
298
|
+
try {
|
|
299
|
+
// Check if collection exists first
|
|
300
|
+
const collections = await this.client.getCollections();
|
|
301
|
+
const collectionExists = collections.collections.some(col => col.name === this.collectionName);
|
|
302
|
+
if (!collectionExists) {
|
|
303
|
+
// Collection doesn't exist, nothing to delete
|
|
304
|
+
return;
|
|
305
|
+
}
|
|
306
|
+
// Delete all points from collection instead of deleting entire collection
|
|
307
|
+
// This avoids Qdrant's known storage directory cleanup bug
|
|
308
|
+
await this.client.delete(this.collectionName, {
|
|
309
|
+
filter: {
|
|
310
|
+
must: [] // Empty must array matches all points
|
|
311
|
+
},
|
|
312
|
+
wait: true // Wait for operation to complete synchronously
|
|
313
|
+
});
|
|
314
|
+
console.warn(`All points deleted from collection ${this.collectionName} (collection structure preserved)`);
|
|
250
315
|
}
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
must: [] // Empty must array matches all points
|
|
256
|
-
},
|
|
257
|
-
wait: true // Wait for operation to complete synchronously
|
|
258
|
-
});
|
|
259
|
-
console.warn(`All points deleted from collection ${this.collectionName} (collection structure preserved)`);
|
|
260
|
-
}
|
|
261
|
-
catch (error) {
|
|
262
|
-
throw new Error(`Failed to delete all documents: ${error}`);
|
|
263
|
-
}
|
|
316
|
+
catch (error) {
|
|
317
|
+
throw new Error(`Failed to delete all documents: ${error}`);
|
|
318
|
+
}
|
|
319
|
+
});
|
|
264
320
|
}
|
|
265
321
|
/**
|
|
266
322
|
* Get all documents (for listing)
|
|
@@ -270,26 +326,33 @@ class VectorDBService {
|
|
|
270
326
|
if (!this.client) {
|
|
271
327
|
throw new Error('Vector DB client not initialized');
|
|
272
328
|
}
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
329
|
+
return (0, qdrant_tracing_1.withQdrantTracing)({
|
|
330
|
+
operation: 'vector.list',
|
|
331
|
+
collectionName: this.collectionName,
|
|
332
|
+
limit,
|
|
333
|
+
serverUrl: this.config.url
|
|
334
|
+
}, async () => {
|
|
335
|
+
try {
|
|
336
|
+
// Check if collection exists first
|
|
337
|
+
const collections = await this.client.getCollections();
|
|
338
|
+
const collectionExists = collections.collections.some(col => col.name === this.collectionName);
|
|
339
|
+
if (!collectionExists) {
|
|
340
|
+
throw new Error(`Collection '${this.collectionName}' does not exist. No data has been stored yet.`);
|
|
341
|
+
}
|
|
342
|
+
const scrollResult = await this.client.scroll(this.collectionName, {
|
|
343
|
+
limit,
|
|
344
|
+
with_payload: true,
|
|
345
|
+
with_vector: false
|
|
346
|
+
});
|
|
347
|
+
return scrollResult.points.map(point => ({
|
|
348
|
+
id: point.id.toString(),
|
|
349
|
+
payload: point.payload || {}
|
|
350
|
+
}));
|
|
279
351
|
}
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
});
|
|
285
|
-
return scrollResult.points.map(point => ({
|
|
286
|
-
id: point.id.toString(),
|
|
287
|
-
payload: point.payload || {}
|
|
288
|
-
}));
|
|
289
|
-
}
|
|
290
|
-
catch (error) {
|
|
291
|
-
throw new Error(`Failed to get all documents: ${error}`);
|
|
292
|
-
}
|
|
352
|
+
catch (error) {
|
|
353
|
+
throw new Error(`Failed to get all documents: ${error}`);
|
|
354
|
+
}
|
|
355
|
+
});
|
|
293
356
|
}
|
|
294
357
|
/**
|
|
295
358
|
* Get collection info and statistics
|
|
@@ -298,12 +361,18 @@ class VectorDBService {
|
|
|
298
361
|
if (!this.client) {
|
|
299
362
|
throw new Error('Vector DB client not initialized');
|
|
300
363
|
}
|
|
301
|
-
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
364
|
+
return (0, qdrant_tracing_1.withQdrantTracing)({
|
|
365
|
+
operation: 'collection.get',
|
|
366
|
+
collectionName: this.collectionName,
|
|
367
|
+
serverUrl: this.config.url
|
|
368
|
+
}, async () => {
|
|
369
|
+
try {
|
|
370
|
+
return await this.client.getCollection(this.collectionName);
|
|
371
|
+
}
|
|
372
|
+
catch (error) {
|
|
373
|
+
throw new Error(`Failed to get collection info: ${error}`);
|
|
374
|
+
}
|
|
375
|
+
});
|
|
307
376
|
}
|
|
308
377
|
/**
|
|
309
378
|
* Check if Vector DB is available and responsive
|
|
@@ -312,13 +381,19 @@ class VectorDBService {
|
|
|
312
381
|
if (!this.client) {
|
|
313
382
|
return false;
|
|
314
383
|
}
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
384
|
+
return (0, qdrant_tracing_1.withQdrantTracing)({
|
|
385
|
+
operation: 'health_check',
|
|
386
|
+
collectionName: this.collectionName,
|
|
387
|
+
serverUrl: this.config.url
|
|
388
|
+
}, async () => {
|
|
389
|
+
try {
|
|
390
|
+
await this.client.getCollections();
|
|
391
|
+
return true;
|
|
392
|
+
}
|
|
393
|
+
catch (error) {
|
|
394
|
+
return false;
|
|
395
|
+
}
|
|
396
|
+
});
|
|
322
397
|
}
|
|
323
398
|
/**
|
|
324
399
|
* Check if client is initialized
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/interfaces/mcp.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"mcp.d.ts","sourceRoot":"","sources":["../../src/interfaces/mcp.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAWH,OAAO,EAAE,KAAK,EAAE,MAAM,eAAe,CAAC;AA0CtC,MAAM,WAAW,eAAe;IAC9B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,SAAS,CAAC,EAAE,OAAO,GAAG,MAAM,CAAC;IAC7B,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,WAAW,CAAC,EAAE,UAAU,GAAG,WAAW,CAAC;CACxC;AAED,qBAAa,SAAS;IACpB,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,KAAK,CAAQ;IACrB,OAAO,CAAC,WAAW,CAAkB;IACrC,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,gBAAgB,CAAa;IACrC,OAAO,CAAC,MAAM,CAAkB;IAChC,OAAO,CAAC,UAAU,CAAC,CAAkC;IACrD,OAAO,CAAC,aAAa,CAAC,CAAgC;IACtD,OAAO,CAAC,YAAY,CAAmB;IACvC,OAAO,CAAC,aAAa,CAAgB;gBAEzB,KAAK,EAAE,KAAK,EAAE,MAAM,EAAE,eAAe;IAsCjD;;OAEG;IACH,OAAO,CAAC,YAAY;IA2BpB;;OAEG;IACH,OAAO,CAAC,aAAa;IA2GrB;;OAEG;IACH,OAAO,CAAC,eAAe;IAqCvB,OAAO,CAAC,iBAAiB;IAInB,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;YAkBd,mBAAmB;YAMnB,kBAAkB;YAwGlB,gBAAgB;IAexB,IAAI,IAAI,OAAO,CAAC,IAAI,CAAC;IAgB3B,OAAO,IAAI,OAAO;CAGnB"}
|