@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.
Files changed (79) hide show
  1. package/assets/project-setup/templates/.github/CODEOWNERS.hbs +25 -0
  2. package/assets/project-setup/templates/.github/FUNDING.yml.hbs +35 -0
  3. package/assets/project-setup/templates/.github/ISSUE_TEMPLATE/bug_report.yml.hbs +175 -0
  4. package/assets/project-setup/templates/.github/ISSUE_TEMPLATE/config.yml.hbs +32 -0
  5. package/assets/project-setup/templates/.github/ISSUE_TEMPLATE/feature_request.yml.hbs +134 -0
  6. package/assets/project-setup/templates/.github/PULL_REQUEST_TEMPLATE.md.hbs +172 -0
  7. package/assets/project-setup/templates/.github/labeler.yml.hbs +123 -0
  8. package/assets/project-setup/templates/.github/release.yml.hbs +51 -0
  9. package/assets/project-setup/templates/.github/workflows/labeler.yml.hbs +21 -0
  10. package/assets/project-setup/templates/.github/workflows/scorecard.yml.hbs +71 -0
  11. package/assets/project-setup/templates/.github/workflows/stale.yml.hbs +57 -0
  12. package/dist/core/ai-provider-factory.d.ts.map +1 -1
  13. package/dist/core/ai-provider-factory.js +22 -5
  14. package/dist/core/ai-provider.interface.d.ts +16 -0
  15. package/dist/core/ai-provider.interface.d.ts.map +1 -1
  16. package/dist/core/capability-scan-workflow.d.ts +4 -9
  17. package/dist/core/capability-scan-workflow.d.ts.map +1 -1
  18. package/dist/core/capability-scan-workflow.js +203 -456
  19. package/dist/core/discovery.d.ts +6 -0
  20. package/dist/core/discovery.d.ts.map +1 -1
  21. package/dist/core/discovery.js +39 -3
  22. package/dist/core/embedding-service.d.ts +9 -36
  23. package/dist/core/embedding-service.d.ts.map +1 -1
  24. package/dist/core/embedding-service.js +137 -246
  25. package/dist/core/index.d.ts +1 -1
  26. package/dist/core/index.js +2 -2
  27. package/dist/core/kubernetes-utils.d.ts +1 -0
  28. package/dist/core/kubernetes-utils.d.ts.map +1 -1
  29. package/dist/core/kubernetes-utils.js +53 -48
  30. package/dist/core/model-config.d.ts +2 -0
  31. package/dist/core/model-config.d.ts.map +1 -1
  32. package/dist/core/model-config.js +3 -1
  33. package/dist/core/providers/anthropic-provider.d.ts.map +1 -1
  34. package/dist/core/providers/anthropic-provider.js +352 -282
  35. package/dist/core/providers/provider-debug-utils.d.ts +4 -0
  36. package/dist/core/providers/provider-debug-utils.d.ts.map +1 -1
  37. package/dist/core/providers/provider-debug-utils.js +25 -3
  38. package/dist/core/providers/vercel-provider.d.ts +1 -0
  39. package/dist/core/providers/vercel-provider.d.ts.map +1 -1
  40. package/dist/core/providers/vercel-provider.js +412 -345
  41. package/dist/core/tracing/ai-tracing.d.ts +80 -0
  42. package/dist/core/tracing/ai-tracing.d.ts.map +1 -0
  43. package/dist/core/tracing/ai-tracing.js +122 -0
  44. package/dist/core/tracing/config.d.ts +15 -0
  45. package/dist/core/tracing/config.d.ts.map +1 -0
  46. package/dist/core/tracing/config.js +133 -0
  47. package/dist/core/tracing/http-tracing.d.ts +28 -0
  48. package/dist/core/tracing/http-tracing.d.ts.map +1 -0
  49. package/dist/core/tracing/http-tracing.js +119 -0
  50. package/dist/core/tracing/index.d.ts +14 -0
  51. package/dist/core/tracing/index.d.ts.map +1 -0
  52. package/dist/core/tracing/index.js +40 -0
  53. package/dist/core/tracing/k8s-tracing.d.ts +57 -0
  54. package/dist/core/tracing/k8s-tracing.d.ts.map +1 -0
  55. package/dist/core/tracing/k8s-tracing.js +155 -0
  56. package/dist/core/tracing/qdrant-tracing.d.ts +68 -0
  57. package/dist/core/tracing/qdrant-tracing.d.ts.map +1 -0
  58. package/dist/core/tracing/qdrant-tracing.js +102 -0
  59. package/dist/core/tracing/tool-tracing.d.ts +31 -0
  60. package/dist/core/tracing/tool-tracing.d.ts.map +1 -0
  61. package/dist/core/tracing/tool-tracing.js +76 -0
  62. package/dist/core/tracing/tracer.d.ts +21 -0
  63. package/dist/core/tracing/tracer.d.ts.map +1 -0
  64. package/dist/core/tracing/tracer.js +215 -0
  65. package/dist/core/tracing/types.d.ts +86 -0
  66. package/dist/core/tracing/types.d.ts.map +1 -0
  67. package/dist/core/tracing/types.js +41 -0
  68. package/dist/core/unified-creation-session.js +1 -1
  69. package/dist/core/vector-db-service.d.ts.map +1 -1
  70. package/dist/core/vector-db-service.js +238 -163
  71. package/dist/interfaces/mcp.d.ts.map +1 -1
  72. package/dist/interfaces/mcp.js +71 -43
  73. package/dist/mcp/server.js +12 -2
  74. package/dist/tools/organizational-data.d.ts.map +1 -1
  75. package/dist/tools/organizational-data.js +2 -4
  76. package/dist/tools/version.d.ts +12 -1
  77. package/dist/tools/version.d.ts.map +1 -1
  78. package/dist/tools/version.js +24 -4
  79. 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,EAA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AAI,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: 50 // Higher limit to get more relevant resources - aligns with recommendation tool
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;AAIH,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,eAA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AG,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
- try {
54
- // Check if collection exists
55
- const collections = await this.client.getCollections();
56
- const collectionExists = collections.collections.some(col => col.name === this.collectionName);
57
- if (collectionExists) {
58
- // Verify existing collection has correct vector dimensions
59
- try {
60
- const collectionInfo = await this.client.getCollection(this.collectionName);
61
- const existingVectorSize = collectionInfo.config?.params?.vectors?.size;
62
- if (existingVectorSize && existingVectorSize !== vectorSize) {
63
- // Dimension mismatch - recreate collection
64
- console.warn(`Vector dimension mismatch: existing collection has ${existingVectorSize} dimensions, but ${vectorSize} expected. Recreating collection.`);
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
- catch (error) {
70
- // If we can't get collection info, assume it's corrupted and recreate
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
- else {
77
- // Create new collection
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
- try {
112
- const point = {
113
- id: document.id,
114
- payload: document.payload,
115
- vector: document.vector
116
- };
117
- // Validate vector is provided
118
- if (!document.vector || document.vector.length === 0) {
119
- throw new Error('Vector is required for vector database storage');
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
- await this.client.upsert(this.collectionName, {
122
- wait: true,
123
- points: [point]
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
- try {
138
- const searchResult = await this.client.search(this.collectionName, {
139
- vector,
140
- limit: options.limit || 10,
141
- score_threshold: options.scoreThreshold || 0.5,
142
- with_payload: true
143
- });
144
- return searchResult.map(result => ({
145
- id: result.id.toString(),
146
- score: result.score,
147
- payload: result.payload || {}
148
- }));
149
- }
150
- catch (error) {
151
- throw new Error(`Failed to search documents: ${error}`);
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
- try {
162
- // Fallback to JavaScript-based filtering due to Qdrant filter syntax issues
163
- // Get all documents and filter in JavaScript for keyword matching
164
- const scrollResult = await this.client.scroll(this.collectionName, {
165
- limit: 1000, // Get all documents for filtering
166
- with_payload: true,
167
- with_vector: false
168
- });
169
- // Filter documents by checking if any keyword matches any trigger
170
- const matchedPoints = scrollResult.points.filter(point => {
171
- if (!point.payload || !point.payload.triggers || !Array.isArray(point.payload.triggers)) {
172
- return false;
173
- }
174
- const triggers = point.payload.triggers.map((t) => t.toLowerCase());
175
- return keywords.some(keyword => triggers.some(trigger => trigger.includes(keyword.toLowerCase()) ||
176
- keyword.toLowerCase().includes(trigger)));
177
- });
178
- // Apply limit after filtering
179
- const limitedResults = matchedPoints.slice(0, options.limit || 10);
180
- return limitedResults.map(point => ({
181
- id: point.id.toString(),
182
- score: 1.0, // Keyword matches get full score
183
- payload: point.payload || {}
184
- }));
185
- }
186
- catch (error) {
187
- throw new Error(`Failed to search by keywords: ${error}`);
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
- try {
198
- const result = await this.client.retrieve(this.collectionName, {
199
- ids: [id],
200
- with_payload: true,
201
- with_vector: true
202
- });
203
- if (result.length === 0) {
204
- return null;
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
- const point = result[0];
207
- return {
208
- id: point.id.toString(),
209
- payload: point.payload || {},
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
- try {
225
- await this.client.delete(this.collectionName, {
226
- wait: true,
227
- points: [id]
228
- });
229
- }
230
- catch (error) {
231
- throw new Error(`Failed to delete document: ${error}`);
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
- try {
244
- // Check if collection exists first
245
- const collections = await this.client.getCollections();
246
- const collectionExists = collections.collections.some(col => col.name === this.collectionName);
247
- if (!collectionExists) {
248
- // Collection doesn't exist, nothing to delete
249
- return;
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
- // Delete all points from collection instead of deleting entire collection
252
- // This avoids Qdrant's known storage directory cleanup bug
253
- await this.client.delete(this.collectionName, {
254
- filter: {
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
- try {
274
- // Check if collection exists first
275
- const collections = await this.client.getCollections();
276
- const collectionExists = collections.collections.some(col => col.name === this.collectionName);
277
- if (!collectionExists) {
278
- throw new Error(`Collection '${this.collectionName}' does not exist. No data has been stored yet.`);
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
- const scrollResult = await this.client.scroll(this.collectionName, {
281
- limit,
282
- with_payload: true,
283
- with_vector: false
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
- try {
302
- return await this.client.getCollection(this.collectionName);
303
- }
304
- catch (error) {
305
- throw new Error(`Failed to get collection info: ${error}`);
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
- try {
316
- await this.client.getCollections();
317
- return true;
318
- }
319
- catch (error) {
320
- return false;
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;AAwCtC,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,OAA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