@vfarcic/dot-ai 0.112.0 → 0.113.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/dist/core/ai-provider-factory.d.ts +0 -15
- package/dist/core/ai-provider-factory.d.ts.map +1 -1
- package/dist/core/ai-provider-factory.js +12 -33
- package/dist/core/ai-provider.interface.d.ts +12 -0
- package/dist/core/ai-provider.interface.d.ts.map +1 -1
- package/dist/core/embedding-service.d.ts +35 -2
- package/dist/core/embedding-service.d.ts.map +1 -1
- package/dist/core/embedding-service.js +228 -15
- package/dist/core/model-config.d.ts +6 -0
- package/dist/core/model-config.d.ts.map +1 -1
- package/dist/core/model-config.js +7 -1
- package/dist/core/platform-utils.d.ts +10 -0
- package/dist/core/platform-utils.d.ts.map +1 -1
- package/dist/core/platform-utils.js +56 -0
- package/dist/core/providers/anthropic-provider.d.ts +2 -0
- package/dist/core/providers/anthropic-provider.d.ts.map +1 -1
- package/dist/core/providers/anthropic-provider.js +10 -0
- package/dist/core/providers/provider-debug-utils.d.ts +5 -1
- package/dist/core/providers/provider-debug-utils.d.ts.map +1 -1
- package/dist/core/providers/provider-debug-utils.js +13 -24
- package/dist/core/providers/vercel-provider.d.ts +2 -0
- package/dist/core/providers/vercel-provider.d.ts.map +1 -1
- package/dist/core/providers/vercel-provider.js +154 -63
- package/dist/core/schema.d.ts +0 -96
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/schema.js +4 -112
- package/dist/core/unified-creation-session.d.ts.map +1 -1
- package/dist/core/unified-creation-session.js +3 -1
- package/dist/evaluation/eval-runner.js +185 -41
- package/dist/evaluation/evaluators/base-comparative.d.ts +4 -1
- package/dist/evaluation/evaluators/base-comparative.d.ts.map +1 -1
- package/dist/evaluation/evaluators/base-comparative.js +36 -1
- package/dist/evaluation/platform-synthesizer.d.ts +54 -0
- package/dist/evaluation/platform-synthesizer.d.ts.map +1 -0
- package/dist/evaluation/platform-synthesizer.js +368 -0
- package/dist/evaluation/run-platform-synthesis.d.ts +9 -0
- package/dist/evaluation/run-platform-synthesis.d.ts.map +1 -0
- package/dist/evaluation/run-platform-synthesis.js +45 -0
- package/dist/interfaces/mcp.d.ts.map +1 -1
- package/dist/interfaces/mcp.js +23 -29
- package/dist/tools/generate-manifests.d.ts.map +1 -1
- package/dist/tools/generate-manifests.js +3 -8
- package/dist/tools/recommend.d.ts.map +1 -1
- package/dist/tools/recommend.js +3 -16
- package/dist/tools/remediate.d.ts.map +1 -1
- package/dist/tools/remediate.js +10 -2
- package/dist/tools/version.d.ts +1 -0
- package/dist/tools/version.d.ts.map +1 -1
- package/dist/tools/version.js +11 -4
- package/package.json +15 -1
|
@@ -51,21 +51,6 @@ export declare class AIProviderFactory {
|
|
|
51
51
|
* @private
|
|
52
52
|
*/
|
|
53
53
|
private static createAnthropicProvider;
|
|
54
|
-
/**
|
|
55
|
-
* Create OpenAI provider instance
|
|
56
|
-
* @private
|
|
57
|
-
*/
|
|
58
|
-
private static createOpenAIProvider;
|
|
59
|
-
/**
|
|
60
|
-
* Create OpenAI Pro provider instance
|
|
61
|
-
* @private
|
|
62
|
-
*/
|
|
63
|
-
private static createOpenAIProProvider;
|
|
64
|
-
/**
|
|
65
|
-
* Create Google provider instance
|
|
66
|
-
* @private
|
|
67
|
-
*/
|
|
68
|
-
private static createGoogleProvider;
|
|
69
54
|
/**
|
|
70
55
|
* Check if a provider is available (has API key configured)
|
|
71
56
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-provider-factory.d.ts","sourceRoot":"","sources":["../../src/core/ai-provider-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,UAAU,EACV,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;
|
|
1
|
+
{"version":3,"file":"ai-provider-factory.d.ts","sourceRoot":"","sources":["../../src/core/ai-provider-factory.ts"],"names":[],"mappings":"AAAA;;;;;;;;GAQG;AAEH,OAAO,EACL,UAAU,EACV,gBAAgB,EACjB,MAAM,yBAAyB,CAAC;AA8BjC;;;;;;;;;;;;;;GAcG;AACH,qBAAa,iBAAiB;IAC5B;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU;IAgCnD;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,aAAa,IAAI,UAAU;IA+ClC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAItC;;;;;OAKG;IACH,MAAM,CAAC,mBAAmB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;IAMrD;;;;OAIG;IACH,MAAM,CAAC,qBAAqB,IAAI,MAAM,EAAE;IAMxC;;;;;OAKG;IACH,MAAM,CAAC,qBAAqB,CAAC,QAAQ,EAAE,MAAM,GAAG,OAAO;CAGxD;AAED;;;GAGG;AACH,wBAAgB,gBAAgB,IAAI,UAAU,CAE7C"}
|
|
@@ -13,6 +13,7 @@ exports.AIProviderFactory = void 0;
|
|
|
13
13
|
exports.createAIProvider = createAIProvider;
|
|
14
14
|
const anthropic_provider_1 = require("./providers/anthropic-provider");
|
|
15
15
|
const vercel_provider_1 = require("./providers/vercel-provider");
|
|
16
|
+
const model_config_1 = require("./model-config");
|
|
16
17
|
/**
|
|
17
18
|
* Provider environment variable mappings
|
|
18
19
|
* Phase 1 (PRD 73): anthropic, openai, google
|
|
@@ -20,14 +21,17 @@ const vercel_provider_1 = require("./providers/vercel-provider");
|
|
|
20
21
|
*/
|
|
21
22
|
const PROVIDER_ENV_KEYS = {
|
|
22
23
|
anthropic: 'ANTHROPIC_API_KEY',
|
|
24
|
+
anthropic_haiku: 'ANTHROPIC_API_KEY', // Uses same API key as regular Anthropic
|
|
23
25
|
openai: 'OPENAI_API_KEY',
|
|
24
26
|
openai_pro: 'OPENAI_API_KEY', // Uses same API key as regular OpenAI
|
|
25
27
|
google: 'GOOGLE_API_KEY',
|
|
28
|
+
google_fast: 'GOOGLE_API_KEY', // Uses same API key as regular Google
|
|
29
|
+
xai: 'XAI_API_KEY',
|
|
30
|
+
xai_fast: 'XAI_API_KEY', // Uses same API key as regular xAI
|
|
31
|
+
mistral: 'MISTRAL_API_KEY',
|
|
32
|
+
deepseek: 'DEEPSEEK_API_KEY',
|
|
26
33
|
};
|
|
27
|
-
|
|
28
|
-
* Providers implemented in Phase 1-2
|
|
29
|
-
*/
|
|
30
|
-
const IMPLEMENTED_PROVIDERS = ['anthropic', 'openai', 'openai_pro', 'google'];
|
|
34
|
+
const IMPLEMENTED_PROVIDERS = Object.keys(model_config_1.CURRENT_MODELS);
|
|
31
35
|
/**
|
|
32
36
|
* Factory for creating AI provider instances
|
|
33
37
|
*
|
|
@@ -68,16 +72,12 @@ class AIProviderFactory {
|
|
|
68
72
|
// Create provider based on type
|
|
69
73
|
switch (config.provider) {
|
|
70
74
|
case 'anthropic':
|
|
75
|
+
case 'anthropic_haiku':
|
|
71
76
|
return this.createAnthropicProvider(config);
|
|
72
|
-
case 'openai':
|
|
73
|
-
return this.createOpenAIProvider(config);
|
|
74
|
-
case 'openai_pro':
|
|
75
|
-
return this.createOpenAIProProvider(config);
|
|
76
|
-
case 'google':
|
|
77
|
-
return this.createGoogleProvider(config);
|
|
78
77
|
default:
|
|
79
|
-
//
|
|
80
|
-
|
|
78
|
+
// All non-Anthropic providers use VercelProvider
|
|
79
|
+
// This matches the integration test behavior with AI_PROVIDER_SDK=vercel
|
|
80
|
+
return new vercel_provider_1.VercelProvider(config);
|
|
81
81
|
}
|
|
82
82
|
}
|
|
83
83
|
/**
|
|
@@ -137,27 +137,6 @@ class AIProviderFactory {
|
|
|
137
137
|
static createAnthropicProvider(config) {
|
|
138
138
|
return new anthropic_provider_1.AnthropicProvider(config);
|
|
139
139
|
}
|
|
140
|
-
/**
|
|
141
|
-
* Create OpenAI provider instance
|
|
142
|
-
* @private
|
|
143
|
-
*/
|
|
144
|
-
static createOpenAIProvider(config) {
|
|
145
|
-
return new vercel_provider_1.VercelProvider(config);
|
|
146
|
-
}
|
|
147
|
-
/**
|
|
148
|
-
* Create OpenAI Pro provider instance
|
|
149
|
-
* @private
|
|
150
|
-
*/
|
|
151
|
-
static createOpenAIProProvider(config) {
|
|
152
|
-
return new vercel_provider_1.VercelProvider(config);
|
|
153
|
-
}
|
|
154
|
-
/**
|
|
155
|
-
* Create Google provider instance
|
|
156
|
-
* @private
|
|
157
|
-
*/
|
|
158
|
-
static createGoogleProvider(config) {
|
|
159
|
-
return new vercel_provider_1.VercelProvider(config);
|
|
160
|
-
}
|
|
161
140
|
/**
|
|
162
141
|
* Check if a provider is available (has API key configured)
|
|
163
142
|
*
|
|
@@ -197,6 +197,18 @@ export interface AIProvider {
|
|
|
197
197
|
* @returns Provider identifier (e.g., 'anthropic', 'openai', 'google')
|
|
198
198
|
*/
|
|
199
199
|
getProviderType(): string;
|
|
200
|
+
/**
|
|
201
|
+
* Get the current model name being used
|
|
202
|
+
*
|
|
203
|
+
* @returns Model name (e.g., 'grok-4-fast-reasoning', 'claude-3-5-sonnet-20241022')
|
|
204
|
+
*/
|
|
205
|
+
getModelName(): string;
|
|
206
|
+
/**
|
|
207
|
+
* Get the underlying SDK provider being used (for Vercel AI SDK)
|
|
208
|
+
*
|
|
209
|
+
* @returns SDK provider name (e.g., 'xai', 'anthropic', 'openai') or the provider type for native SDKs
|
|
210
|
+
*/
|
|
211
|
+
getSDKProvider(): string;
|
|
200
212
|
/**
|
|
201
213
|
* Execute agentic loop with tool calling (NEW - PRD #136)
|
|
202
214
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ai-provider.interface.d.ts","sourceRoot":"","sources":["../../src/core/ai-provider.interface.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;GAWG;AAEH;;GAEG;AACH,MAAM,WAAW,UAAU;IACzB,OAAO,EAAE,MAAM,CAAC;IAChB,KAAK,EAAE;QACL,YAAY,EAAE,MAAM,CAAC;QACrB,aAAa,EAAE,MAAM,CAAC;QACtB,2BAA2B,CAAC,EA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Embedding Service
|
|
3
3
|
*
|
|
4
4
|
* Optional semantic search enhancement for pattern matching.
|
|
5
|
-
* Gracefully falls back to keyword-only search when
|
|
5
|
+
* Gracefully falls back to keyword-only search when embedding providers are not available.
|
|
6
6
|
*/
|
|
7
7
|
export interface EmbeddingConfig {
|
|
8
|
-
provider?: 'openai';
|
|
8
|
+
provider?: 'openai' | 'google' | 'mistral';
|
|
9
9
|
apiKey?: string;
|
|
10
10
|
model?: string;
|
|
11
11
|
dimensions?: number;
|
|
@@ -15,6 +15,7 @@ export interface EmbeddingProvider {
|
|
|
15
15
|
generateEmbeddings(texts: string[]): Promise<number[][]>;
|
|
16
16
|
isAvailable(): boolean;
|
|
17
17
|
getDimensions(): number;
|
|
18
|
+
getModel(): string;
|
|
18
19
|
}
|
|
19
20
|
/**
|
|
20
21
|
* OpenAI Embedding Provider
|
|
@@ -32,6 +33,38 @@ export declare class OpenAIEmbeddingProvider implements EmbeddingProvider {
|
|
|
32
33
|
getDimensions(): number;
|
|
33
34
|
getModel(): string;
|
|
34
35
|
}
|
|
36
|
+
/**
|
|
37
|
+
* Google Embedding Provider
|
|
38
|
+
* Optional provider using Google's text-embedding-004 model
|
|
39
|
+
*/
|
|
40
|
+
export declare class GoogleEmbeddingProvider implements EmbeddingProvider {
|
|
41
|
+
private apiKey;
|
|
42
|
+
private model;
|
|
43
|
+
private dimensions;
|
|
44
|
+
private available;
|
|
45
|
+
constructor(config?: EmbeddingConfig);
|
|
46
|
+
generateEmbedding(text: string): Promise<number[]>;
|
|
47
|
+
generateEmbeddings(texts: string[]): Promise<number[][]>;
|
|
48
|
+
isAvailable(): boolean;
|
|
49
|
+
getDimensions(): number;
|
|
50
|
+
getModel(): string;
|
|
51
|
+
}
|
|
52
|
+
/**
|
|
53
|
+
* Mistral Embedding Provider
|
|
54
|
+
* Optional provider using Mistral's text-embedding-v1 model
|
|
55
|
+
*/
|
|
56
|
+
export declare class MistralEmbeddingProvider implements EmbeddingProvider {
|
|
57
|
+
private apiKey;
|
|
58
|
+
private model;
|
|
59
|
+
private dimensions;
|
|
60
|
+
private available;
|
|
61
|
+
constructor(config?: EmbeddingConfig);
|
|
62
|
+
generateEmbedding(text: string): Promise<number[]>;
|
|
63
|
+
generateEmbeddings(texts: string[]): Promise<number[][]>;
|
|
64
|
+
isAvailable(): boolean;
|
|
65
|
+
getDimensions(): number;
|
|
66
|
+
getModel(): string;
|
|
67
|
+
}
|
|
35
68
|
/**
|
|
36
69
|
* Main Embedding Service
|
|
37
70
|
* Provides optional semantic search capabilities with graceful degradation
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"embedding-service.d.ts","sourceRoot":"","sources":["../../src/core/embedding-service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;
|
|
1
|
+
{"version":3,"file":"embedding-service.d.ts","sourceRoot":"","sources":["../../src/core/embedding-service.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAOH,MAAM,WAAW,eAAe;IAC9B,QAAQ,CAAC,EAAE,QAAQ,GAAG,QAAQ,GAAG,SAAS,CAAC;IAC3C,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,UAAU,CAAC,EAAE,MAAM,CAAC;CACrB;AAED,MAAM,WAAW,iBAAiB;IAChC,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,CAAC;IACnD,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IACzD,WAAW,IAAI,OAAO,CAAC;IACvB,aAAa,IAAI,MAAM,CAAC;IACxB,QAAQ,IAAI,MAAM,CAAC;CACpB;AAED;;;GAGG;AACH,qBAAa,uBAAwB,YAAW,iBAAiB;IAC/D,OAAO,CAAC,MAAM,CAAuB;IACrC,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,UAAU,CAAS;IAC3B,OAAO,CAAC,SAAS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,QAAQ,CAA2B;gBAE/B,MAAM,GAAE,eAAoB;IAKxC;;;OAGG;IACG,iBAAiB,CAAC,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC;IAaxD;;;OAGG;IACG,kBAAkB,CAAC,KAAK,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC;IAc9D;;OAEG;IACH,WAAW,IAAI,OAAO;IAItB;;OAEG;IACH,aAAa,IAAI,MAAM;IAIvB;;OAEG;IACH,SAAS,IAAI;QACX,SAAS,EAAE,OAAO,CAAC;QACnB,QAAQ,EAAE,MAAM,GAAG,IAAI,CAAC;QACxB,KAAK,CAAC,EAAE,MAAM,CAAC;QACf,UAAU,CAAC,EAAE,MAAM,CAAC;QACpB,MAAM,CAAC,EAAE,MAAM,CAAC;KACjB;IAqCD;;OAEG;IACH,uBAAuB,CAAC,OAAO,EAAE;QAC/B,WAAW,EAAE,MAAM,CAAC;QACpB,QAAQ,EAAE,MAAM,EAAE,CAAC;QACnB,kBAAkB,EAAE,MAAM,EAAE,CAAC;QAC7B,SAAS,EAAE,MAAM,CAAC;KACnB,GAAG,MAAM;CASX"}
|
|
@@ -3,14 +3,17 @@
|
|
|
3
3
|
* Embedding Service
|
|
4
4
|
*
|
|
5
5
|
* Optional semantic search enhancement for pattern matching.
|
|
6
|
-
* Gracefully falls back to keyword-only search when
|
|
6
|
+
* Gracefully falls back to keyword-only search when embedding providers are not available.
|
|
7
7
|
*/
|
|
8
8
|
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
9
9
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
10
10
|
};
|
|
11
11
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.EmbeddingService = exports.OpenAIEmbeddingProvider = void 0;
|
|
12
|
+
exports.EmbeddingService = exports.MistralEmbeddingProvider = exports.GoogleEmbeddingProvider = exports.OpenAIEmbeddingProvider = void 0;
|
|
13
13
|
const openai_1 = __importDefault(require("openai"));
|
|
14
|
+
const google_1 = require("@ai-sdk/google");
|
|
15
|
+
const mistral_1 = require("@ai-sdk/mistral");
|
|
16
|
+
const ai_1 = require("ai");
|
|
14
17
|
/**
|
|
15
18
|
* OpenAI Embedding Provider
|
|
16
19
|
* Optional provider for semantic search enhancement
|
|
@@ -102,21 +105,211 @@ class OpenAIEmbeddingProvider {
|
|
|
102
105
|
}
|
|
103
106
|
exports.OpenAIEmbeddingProvider = OpenAIEmbeddingProvider;
|
|
104
107
|
/**
|
|
105
|
-
*
|
|
106
|
-
*
|
|
108
|
+
* Google Embedding Provider
|
|
109
|
+
* Optional provider using Google's text-embedding-004 model
|
|
107
110
|
*/
|
|
108
|
-
class
|
|
109
|
-
|
|
111
|
+
class GoogleEmbeddingProvider {
|
|
112
|
+
apiKey = null;
|
|
113
|
+
model;
|
|
114
|
+
dimensions;
|
|
115
|
+
available;
|
|
110
116
|
constructor(config = {}) {
|
|
111
|
-
|
|
117
|
+
this.apiKey = config.apiKey || process.env.GOOGLE_API_KEY || null;
|
|
118
|
+
this.model = config.model || 'text-embedding-004';
|
|
119
|
+
this.dimensions = config.dimensions || 768; // text-embedding-004 default
|
|
120
|
+
this.available = !!this.apiKey;
|
|
121
|
+
// Set the environment variable that Google SDK expects
|
|
122
|
+
if (this.apiKey) {
|
|
123
|
+
process.env.GOOGLE_GENERATIVE_AI_API_KEY = this.apiKey;
|
|
124
|
+
}
|
|
125
|
+
}
|
|
126
|
+
async generateEmbedding(text) {
|
|
127
|
+
if (!this.isAvailable()) {
|
|
128
|
+
throw new Error('Google embedding provider not available');
|
|
129
|
+
}
|
|
130
|
+
if (!text || text.trim().length === 0) {
|
|
131
|
+
throw new Error('Text cannot be empty for embedding generation');
|
|
132
|
+
}
|
|
112
133
|
try {
|
|
113
|
-
const
|
|
114
|
-
|
|
134
|
+
const model = google_1.google.textEmbedding(this.model);
|
|
135
|
+
const result = await (0, ai_1.embed)({
|
|
136
|
+
model,
|
|
137
|
+
value: text.trim(),
|
|
138
|
+
providerOptions: {
|
|
139
|
+
google: {
|
|
140
|
+
outputDimensionality: this.dimensions,
|
|
141
|
+
taskType: 'SEMANTIC_SIMILARITY'
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
});
|
|
145
|
+
return result.embedding;
|
|
115
146
|
}
|
|
116
147
|
catch (error) {
|
|
117
|
-
|
|
148
|
+
if (error instanceof Error) {
|
|
149
|
+
throw new Error(`Google embedding failed: ${error.message}`);
|
|
150
|
+
}
|
|
151
|
+
throw new Error(`Google embedding failed: ${String(error)}`);
|
|
118
152
|
}
|
|
119
153
|
}
|
|
154
|
+
async generateEmbeddings(texts) {
|
|
155
|
+
if (!this.isAvailable()) {
|
|
156
|
+
throw new Error('Google embedding provider not available');
|
|
157
|
+
}
|
|
158
|
+
if (!texts || texts.length === 0) {
|
|
159
|
+
return [];
|
|
160
|
+
}
|
|
161
|
+
const validTexts = texts
|
|
162
|
+
.map(t => t?.trim())
|
|
163
|
+
.filter(t => t && t.length > 0);
|
|
164
|
+
if (validTexts.length === 0) {
|
|
165
|
+
return [];
|
|
166
|
+
}
|
|
167
|
+
try {
|
|
168
|
+
const model = google_1.google.textEmbedding(this.model);
|
|
169
|
+
const results = await Promise.all(validTexts.map(text => (0, ai_1.embed)({
|
|
170
|
+
model,
|
|
171
|
+
value: text,
|
|
172
|
+
providerOptions: {
|
|
173
|
+
google: {
|
|
174
|
+
outputDimensionality: this.dimensions,
|
|
175
|
+
taskType: 'SEMANTIC_SIMILARITY'
|
|
176
|
+
}
|
|
177
|
+
}
|
|
178
|
+
})));
|
|
179
|
+
return results.map(result => result.embedding);
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
if (error instanceof Error) {
|
|
183
|
+
throw new Error(`Google batch embedding failed: ${error.message}`);
|
|
184
|
+
}
|
|
185
|
+
throw new Error(`Google batch embedding failed: ${String(error)}`);
|
|
186
|
+
}
|
|
187
|
+
}
|
|
188
|
+
isAvailable() {
|
|
189
|
+
return this.available;
|
|
190
|
+
}
|
|
191
|
+
getDimensions() {
|
|
192
|
+
return this.dimensions;
|
|
193
|
+
}
|
|
194
|
+
getModel() {
|
|
195
|
+
return this.model;
|
|
196
|
+
}
|
|
197
|
+
}
|
|
198
|
+
exports.GoogleEmbeddingProvider = GoogleEmbeddingProvider;
|
|
199
|
+
/**
|
|
200
|
+
* Mistral Embedding Provider
|
|
201
|
+
* Optional provider using Mistral's text-embedding-v1 model
|
|
202
|
+
*/
|
|
203
|
+
class MistralEmbeddingProvider {
|
|
204
|
+
apiKey = null;
|
|
205
|
+
model;
|
|
206
|
+
dimensions;
|
|
207
|
+
available;
|
|
208
|
+
constructor(config = {}) {
|
|
209
|
+
this.apiKey = config.apiKey || process.env.MISTRAL_API_KEY || null;
|
|
210
|
+
this.model = config.model || 'mistral-embed';
|
|
211
|
+
this.dimensions = config.dimensions || 1024; // mistral-embed default
|
|
212
|
+
this.available = !!this.apiKey;
|
|
213
|
+
}
|
|
214
|
+
async generateEmbedding(text) {
|
|
215
|
+
if (!this.isAvailable()) {
|
|
216
|
+
throw new Error('Mistral embedding provider not available');
|
|
217
|
+
}
|
|
218
|
+
if (!text || text.trim().length === 0) {
|
|
219
|
+
throw new Error('Text cannot be empty for embedding generation');
|
|
220
|
+
}
|
|
221
|
+
try {
|
|
222
|
+
const mistral = (0, mistral_1.createMistral)({ apiKey: this.apiKey });
|
|
223
|
+
const model = mistral.textEmbedding(this.model);
|
|
224
|
+
const result = await (0, ai_1.embed)({
|
|
225
|
+
model,
|
|
226
|
+
value: text.trim()
|
|
227
|
+
});
|
|
228
|
+
return result.embedding;
|
|
229
|
+
}
|
|
230
|
+
catch (error) {
|
|
231
|
+
if (error instanceof Error) {
|
|
232
|
+
throw new Error(`Mistral embedding failed: ${error.message}`);
|
|
233
|
+
}
|
|
234
|
+
throw new Error(`Mistral embedding failed: ${String(error)}`);
|
|
235
|
+
}
|
|
236
|
+
}
|
|
237
|
+
async generateEmbeddings(texts) {
|
|
238
|
+
if (!this.isAvailable()) {
|
|
239
|
+
throw new Error('Mistral embedding provider not available');
|
|
240
|
+
}
|
|
241
|
+
if (!texts || texts.length === 0) {
|
|
242
|
+
return [];
|
|
243
|
+
}
|
|
244
|
+
const validTexts = texts
|
|
245
|
+
.map(t => t?.trim())
|
|
246
|
+
.filter(t => t && t.length > 0);
|
|
247
|
+
if (validTexts.length === 0) {
|
|
248
|
+
return [];
|
|
249
|
+
}
|
|
250
|
+
try {
|
|
251
|
+
const mistral = (0, mistral_1.createMistral)({ apiKey: this.apiKey });
|
|
252
|
+
const model = mistral.textEmbedding(this.model);
|
|
253
|
+
const results = await Promise.all(validTexts.map(text => (0, ai_1.embed)({
|
|
254
|
+
model,
|
|
255
|
+
value: text
|
|
256
|
+
})));
|
|
257
|
+
return results.map(result => result.embedding);
|
|
258
|
+
}
|
|
259
|
+
catch (error) {
|
|
260
|
+
if (error instanceof Error) {
|
|
261
|
+
throw new Error(`Mistral batch embedding failed: ${error.message}`);
|
|
262
|
+
}
|
|
263
|
+
throw new Error(`Mistral batch embedding failed: ${String(error)}`);
|
|
264
|
+
}
|
|
265
|
+
}
|
|
266
|
+
isAvailable() {
|
|
267
|
+
return this.available;
|
|
268
|
+
}
|
|
269
|
+
getDimensions() {
|
|
270
|
+
return this.dimensions;
|
|
271
|
+
}
|
|
272
|
+
getModel() {
|
|
273
|
+
return this.model;
|
|
274
|
+
}
|
|
275
|
+
}
|
|
276
|
+
exports.MistralEmbeddingProvider = MistralEmbeddingProvider;
|
|
277
|
+
/**
|
|
278
|
+
* Factory function to create embedding provider based on configuration
|
|
279
|
+
*/
|
|
280
|
+
function createEmbeddingProvider(config = {}) {
|
|
281
|
+
const provider = config.provider || process.env.EMBEDDINGS_PROVIDER || 'openai';
|
|
282
|
+
try {
|
|
283
|
+
switch (provider.toLowerCase()) {
|
|
284
|
+
case 'google': {
|
|
285
|
+
const googleProvider = new GoogleEmbeddingProvider(config);
|
|
286
|
+
return googleProvider.isAvailable() ? googleProvider : null;
|
|
287
|
+
}
|
|
288
|
+
case 'mistral': {
|
|
289
|
+
const mistralProvider = new MistralEmbeddingProvider(config);
|
|
290
|
+
return mistralProvider.isAvailable() ? mistralProvider : null;
|
|
291
|
+
}
|
|
292
|
+
case 'openai':
|
|
293
|
+
default: {
|
|
294
|
+
const openaiProvider = new OpenAIEmbeddingProvider(config);
|
|
295
|
+
return openaiProvider.isAvailable() ? openaiProvider : null;
|
|
296
|
+
}
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
catch (error) {
|
|
300
|
+
return null;
|
|
301
|
+
}
|
|
302
|
+
}
|
|
303
|
+
/**
|
|
304
|
+
* Main Embedding Service
|
|
305
|
+
* Provides optional semantic search capabilities with graceful degradation
|
|
306
|
+
*/
|
|
307
|
+
class EmbeddingService {
|
|
308
|
+
provider;
|
|
309
|
+
constructor(config = {}) {
|
|
310
|
+
// Use factory to initialize appropriate provider
|
|
311
|
+
this.provider = createEmbeddingProvider(config);
|
|
312
|
+
}
|
|
120
313
|
/**
|
|
121
314
|
* Generate embedding for text
|
|
122
315
|
* Throws error if embeddings not available or generation fails
|
|
@@ -167,18 +360,38 @@ class EmbeddingService {
|
|
|
167
360
|
*/
|
|
168
361
|
getStatus() {
|
|
169
362
|
if (this.isAvailable()) {
|
|
170
|
-
|
|
363
|
+
// Determine provider type based on instance
|
|
364
|
+
let providerName;
|
|
365
|
+
if (this.provider instanceof GoogleEmbeddingProvider) {
|
|
366
|
+
providerName = 'google';
|
|
367
|
+
}
|
|
368
|
+
else if (this.provider instanceof MistralEmbeddingProvider) {
|
|
369
|
+
providerName = 'mistral';
|
|
370
|
+
}
|
|
371
|
+
else if (this.provider instanceof OpenAIEmbeddingProvider) {
|
|
372
|
+
providerName = 'openai';
|
|
373
|
+
}
|
|
374
|
+
else {
|
|
375
|
+
providerName = 'unknown';
|
|
376
|
+
}
|
|
171
377
|
return {
|
|
172
378
|
available: true,
|
|
173
|
-
provider:
|
|
174
|
-
model:
|
|
175
|
-
dimensions:
|
|
379
|
+
provider: providerName,
|
|
380
|
+
model: this.provider.getModel(),
|
|
381
|
+
dimensions: this.provider.getDimensions()
|
|
176
382
|
};
|
|
177
383
|
}
|
|
384
|
+
const requestedProvider = process.env.EMBEDDINGS_PROVIDER || 'openai';
|
|
385
|
+
const keyMap = {
|
|
386
|
+
'openai': 'OPENAI_API_KEY',
|
|
387
|
+
'google': 'GOOGLE_API_KEY',
|
|
388
|
+
'mistral': 'MISTRAL_API_KEY'
|
|
389
|
+
};
|
|
390
|
+
const requiredKey = keyMap[requestedProvider] || 'OPENAI_API_KEY';
|
|
178
391
|
return {
|
|
179
392
|
available: false,
|
|
180
393
|
provider: null,
|
|
181
|
-
reason:
|
|
394
|
+
reason: `${requiredKey} not set - vector operations will fail`
|
|
182
395
|
};
|
|
183
396
|
}
|
|
184
397
|
/**
|
|
@@ -6,9 +6,15 @@
|
|
|
6
6
|
*/
|
|
7
7
|
export declare const CURRENT_MODELS: {
|
|
8
8
|
readonly anthropic: "claude-sonnet-4-5-20250929";
|
|
9
|
+
readonly anthropic_haiku: "claude-haiku-4-5-20251001";
|
|
9
10
|
readonly openai: "gpt-5";
|
|
10
11
|
readonly openai_pro: "gpt-5-pro";
|
|
11
12
|
readonly google: "gemini-2.5-pro";
|
|
13
|
+
readonly google_fast: "gemini-2.5-flash";
|
|
14
|
+
readonly xai: "grok-4";
|
|
15
|
+
readonly xai_fast: "grok-4-fast-reasoning";
|
|
16
|
+
readonly mistral: "mistral-large-latest";
|
|
17
|
+
readonly deepseek: "deepseek-reasoner";
|
|
12
18
|
};
|
|
13
19
|
/**
|
|
14
20
|
* Get current model for a provider
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-config.d.ts","sourceRoot":"","sources":["../../src/core/model-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,cAAc
|
|
1
|
+
{"version":3,"file":"model-config.d.ts","sourceRoot":"","sources":["../../src/core/model-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,cAAc;;;;;;;;;;;CAWjB,CAAC;AAEX;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,OAAO,cAAc,GAAG,MAAM,CAE7E"}
|
|
@@ -10,9 +10,15 @@ exports.CURRENT_MODELS = void 0;
|
|
|
10
10
|
exports.getCurrentModel = getCurrentModel;
|
|
11
11
|
exports.CURRENT_MODELS = {
|
|
12
12
|
anthropic: 'claude-sonnet-4-5-20250929',
|
|
13
|
+
anthropic_haiku: 'claude-haiku-4-5-20251001',
|
|
13
14
|
openai: 'gpt-5',
|
|
14
15
|
openai_pro: 'gpt-5-pro',
|
|
15
|
-
google: 'gemini-2.5-pro'
|
|
16
|
+
google: 'gemini-2.5-pro',
|
|
17
|
+
google_fast: 'gemini-2.5-flash',
|
|
18
|
+
xai: 'grok-4',
|
|
19
|
+
xai_fast: 'grok-4-fast-reasoning',
|
|
20
|
+
mistral: 'mistral-large-latest',
|
|
21
|
+
deepseek: 'deepseek-reasoner'
|
|
16
22
|
};
|
|
17
23
|
/**
|
|
18
24
|
* Get current model for a provider
|
|
@@ -14,4 +14,14 @@ export declare function getScriptsDir(): string;
|
|
|
14
14
|
* Handles markdown code blocks and finds proper JSON boundaries
|
|
15
15
|
*/
|
|
16
16
|
export declare function extractJsonFromAIResponse(aiResponse: string): any;
|
|
17
|
+
/**
|
|
18
|
+
* Extract content from markdown code blocks in AI responses
|
|
19
|
+
* Handles various code block formats: ```yaml, ```yml, ```json, or plain ```
|
|
20
|
+
*/
|
|
21
|
+
export declare function extractContentFromMarkdownCodeBlocks(content: string, language?: string): string;
|
|
22
|
+
/**
|
|
23
|
+
* Extract JSON array from AI response with robust parsing
|
|
24
|
+
* Handles markdown code blocks and finds proper array boundaries
|
|
25
|
+
*/
|
|
26
|
+
export declare function extractJsonArrayFromAIResponse(aiResponse: string): any[];
|
|
17
27
|
//# sourceMappingURL=platform-utils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-utils.d.ts","sourceRoot":"","sources":["../../src/core/platform-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAIrC,eAAO,MAAM,SAAS,2BAAkB,CAAC;AAEzC;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAItC;AAGD;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAkCjE"}
|
|
1
|
+
{"version":3,"file":"platform-utils.d.ts","sourceRoot":"","sources":["../../src/core/platform-utils.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,EAAE,IAAI,EAAE,MAAM,eAAe,CAAC;AAIrC,eAAO,MAAM,SAAS,2BAAkB,CAAC;AAEzC;;GAEG;AACH,wBAAgB,aAAa,IAAI,MAAM,CAItC;AAGD;;;GAGG;AACH,wBAAgB,yBAAyB,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,CAkCjE;AAED;;;GAGG;AACH,wBAAgB,oCAAoC,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,MAAM,CAY/F;AAED;;;GAGG;AACH,wBAAgB,8BAA8B,CAAC,UAAU,EAAE,MAAM,GAAG,GAAG,EAAE,CAkCxE"}
|
|
@@ -41,6 +41,8 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
41
41
|
exports.execAsync = void 0;
|
|
42
42
|
exports.getScriptsDir = getScriptsDir;
|
|
43
43
|
exports.extractJsonFromAIResponse = extractJsonFromAIResponse;
|
|
44
|
+
exports.extractContentFromMarkdownCodeBlocks = extractContentFromMarkdownCodeBlocks;
|
|
45
|
+
exports.extractJsonArrayFromAIResponse = extractJsonArrayFromAIResponse;
|
|
44
46
|
const child_process_1 = require("child_process");
|
|
45
47
|
const util_1 = require("util");
|
|
46
48
|
const path = __importStar(require("path"));
|
|
@@ -92,3 +94,57 @@ function extractJsonFromAIResponse(aiResponse) {
|
|
|
92
94
|
throw new Error(`Failed to parse JSON from AI response: ${error}`);
|
|
93
95
|
}
|
|
94
96
|
}
|
|
97
|
+
/**
|
|
98
|
+
* Extract content from markdown code blocks in AI responses
|
|
99
|
+
* Handles various code block formats: ```yaml, ```yml, ```json, or plain ```
|
|
100
|
+
*/
|
|
101
|
+
function extractContentFromMarkdownCodeBlocks(content, language) {
|
|
102
|
+
// Create regex pattern for the specified language or any language
|
|
103
|
+
const languagePattern = language ? `(?:${language})` : '(?:yaml|yml|json)?';
|
|
104
|
+
const regex = new RegExp(`\`\`\`${languagePattern}\\s*([\\s\\S]*?)\\s*\`\`\``, 'g');
|
|
105
|
+
const match = regex.exec(content);
|
|
106
|
+
if (match && match[1]) {
|
|
107
|
+
return match[1].trim();
|
|
108
|
+
}
|
|
109
|
+
// Return original content if no code blocks found
|
|
110
|
+
return content.trim();
|
|
111
|
+
}
|
|
112
|
+
/**
|
|
113
|
+
* Extract JSON array from AI response with robust parsing
|
|
114
|
+
* Handles markdown code blocks and finds proper array boundaries
|
|
115
|
+
*/
|
|
116
|
+
function extractJsonArrayFromAIResponse(aiResponse) {
|
|
117
|
+
let jsonContent = aiResponse;
|
|
118
|
+
// First try to find JSON array wrapped in code blocks
|
|
119
|
+
const codeBlockMatch = aiResponse.match(/```(?:json)?\s*(\[[\s\S]*?\])\s*```/);
|
|
120
|
+
if (codeBlockMatch) {
|
|
121
|
+
jsonContent = codeBlockMatch[1];
|
|
122
|
+
}
|
|
123
|
+
else {
|
|
124
|
+
// Try to find JSON array that starts with [ and find the matching closing ]
|
|
125
|
+
const startIndex = aiResponse.indexOf('[');
|
|
126
|
+
if (startIndex !== -1) {
|
|
127
|
+
let bracketCount = 0;
|
|
128
|
+
let endIndex = startIndex;
|
|
129
|
+
for (let i = startIndex; i < aiResponse.length; i++) {
|
|
130
|
+
if (aiResponse[i] === '[')
|
|
131
|
+
bracketCount++;
|
|
132
|
+
if (aiResponse[i] === ']')
|
|
133
|
+
bracketCount--;
|
|
134
|
+
if (bracketCount === 0) {
|
|
135
|
+
endIndex = i;
|
|
136
|
+
break;
|
|
137
|
+
}
|
|
138
|
+
}
|
|
139
|
+
if (bracketCount === 0) {
|
|
140
|
+
jsonContent = aiResponse.substring(startIndex, endIndex + 1);
|
|
141
|
+
}
|
|
142
|
+
}
|
|
143
|
+
}
|
|
144
|
+
try {
|
|
145
|
+
return JSON.parse(jsonContent.trim());
|
|
146
|
+
}
|
|
147
|
+
catch (error) {
|
|
148
|
+
throw new Error(`Failed to parse JSON array from AI response: ${error}`);
|
|
149
|
+
}
|
|
150
|
+
}
|
|
@@ -14,6 +14,8 @@ export declare class AnthropicProvider implements AIProvider {
|
|
|
14
14
|
private validateApiKey;
|
|
15
15
|
getProviderType(): string;
|
|
16
16
|
getDefaultModel(): string;
|
|
17
|
+
getModelName(): string;
|
|
18
|
+
getSDKProvider(): string;
|
|
17
19
|
isInitialized(): boolean;
|
|
18
20
|
/**
|
|
19
21
|
* Helper method to log debug information if debug mode is enabled
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"anthropic-provider.d.ts","sourceRoot":"","sources":["../../../src/core/providers/anthropic-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,aAAa,EACd,MAAM,0BAA0B,CAAC;AAIlC,qBAAa,iBAAkB,YAAW,UAAU;IAClD,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,SAAS,CAAU;gBAEf,MAAM,EAAE,gBAAgB;
|
|
1
|
+
{"version":3,"file":"anthropic-provider.d.ts","sourceRoot":"","sources":["../../../src/core/providers/anthropic-provider.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAGH,OAAO,EACL,UAAU,EACV,UAAU,EACV,gBAAgB,EAChB,cAAc,EACd,aAAa,EACd,MAAM,0BAA0B,CAAC;AAIlC,qBAAa,iBAAkB,YAAW,UAAU;IAClD,OAAO,CAAC,MAAM,CAAY;IAC1B,OAAO,CAAC,MAAM,CAAS;IACvB,OAAO,CAAC,KAAK,CAAS;IACtB,OAAO,CAAC,SAAS,CAAU;gBAEf,MAAM,EAAE,gBAAgB;IAepC,OAAO,CAAC,cAAc;IAStB,eAAe,IAAI,MAAM;IAIzB,eAAe,IAAI,MAAM;IAIzB,YAAY,IAAI,MAAM;IAItB,cAAc,IAAI,MAAM;IAIxB,aAAa,IAAI,OAAO;IAIxB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAiBnB,WAAW,CACf,OAAO,EAAE,MAAM,EACf,SAAS,GAAE,MAAkB,EAC7B,iBAAiB,CAAC,EAAE;QAClB,WAAW,CAAC,EAAE,MAAM,CAAC;QACrB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GACA,OAAO,CAAC,UAAU,CAAC;IA+EtB;;;;;;;;;;;;;;;;;;;OAmBG;IACG,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;CAsQ/D"}
|