@vfarcic/dot-ai 0.111.0 → 0.112.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 +5 -0
- package/dist/core/ai-provider-factory.d.ts.map +1 -1
- package/dist/core/ai-provider-factory.js +13 -2
- package/dist/core/ai-provider.interface.d.ts +16 -1
- package/dist/core/ai-provider.interface.d.ts.map +1 -1
- package/dist/core/capabilities.d.ts +1 -1
- package/dist/core/capabilities.d.ts.map +1 -1
- package/dist/core/capabilities.js +7 -4
- package/dist/core/capability-scan-workflow.js +2 -2
- package/dist/core/model-config.d.ts +17 -0
- package/dist/core/model-config.d.ts.map +1 -0
- package/dist/core/model-config.js +22 -0
- package/dist/core/platform-operations.d.ts.map +1 -1
- package/dist/core/platform-operations.js +3 -5
- package/dist/core/platform-utils.d.ts +3 -2
- package/dist/core/platform-utils.d.ts.map +1 -1
- package/dist/core/platform-utils.js +35 -9
- package/dist/core/providers/anthropic-provider.d.ts +4 -1
- package/dist/core/providers/anthropic-provider.d.ts.map +1 -1
- package/dist/core/providers/anthropic-provider.js +89 -27
- package/dist/core/providers/provider-debug-utils.d.ts +49 -20
- package/dist/core/providers/provider-debug-utils.d.ts.map +1 -1
- package/dist/core/providers/provider-debug-utils.js +117 -51
- package/dist/core/providers/vercel-provider.d.ts +4 -1
- package/dist/core/providers/vercel-provider.d.ts.map +1 -1
- package/dist/core/providers/vercel-provider.js +105 -114
- package/dist/core/schema.d.ts +1 -5
- package/dist/core/schema.d.ts.map +1 -1
- package/dist/core/schema.js +16 -42
- package/dist/core/unified-creation-session.d.ts.map +1 -1
- package/dist/core/unified-creation-session.js +12 -6
- package/dist/evaluation/dataset-analyzer.d.ts +118 -0
- package/dist/evaluation/dataset-analyzer.d.ts.map +1 -0
- package/dist/evaluation/dataset-analyzer.js +234 -0
- package/dist/evaluation/datasets/loader.d.ts +42 -0
- package/dist/evaluation/datasets/loader.d.ts.map +1 -0
- package/dist/evaluation/datasets/loader.js +104 -0
- package/dist/evaluation/eval-runner.d.ts +9 -0
- package/dist/evaluation/eval-runner.d.ts.map +1 -0
- package/dist/evaluation/eval-runner.js +255 -0
- package/dist/evaluation/evaluators/base-comparative.d.ts +91 -0
- package/dist/evaluation/evaluators/base-comparative.d.ts.map +1 -0
- package/dist/evaluation/evaluators/base-comparative.js +152 -0
- package/dist/evaluation/evaluators/base.d.ts +47 -0
- package/dist/evaluation/evaluators/base.d.ts.map +1 -0
- package/dist/evaluation/evaluators/base.js +10 -0
- package/dist/evaluation/evaluators/capability-comparative.d.ts +32 -0
- package/dist/evaluation/evaluators/capability-comparative.d.ts.map +1 -0
- package/dist/evaluation/evaluators/capability-comparative.js +104 -0
- package/dist/evaluation/evaluators/pattern-comparative.d.ts +31 -0
- package/dist/evaluation/evaluators/pattern-comparative.d.ts.map +1 -0
- package/dist/evaluation/evaluators/pattern-comparative.js +97 -0
- package/dist/evaluation/evaluators/policy-comparative.d.ts +31 -0
- package/dist/evaluation/evaluators/policy-comparative.d.ts.map +1 -0
- package/dist/evaluation/evaluators/policy-comparative.js +97 -0
- package/dist/evaluation/evaluators/recommendation-comparative.d.ts +25 -0
- package/dist/evaluation/evaluators/recommendation-comparative.d.ts.map +1 -0
- package/dist/evaluation/evaluators/recommendation-comparative.js +55 -0
- package/dist/evaluation/evaluators/remediation-comparative.d.ts +25 -0
- package/dist/evaluation/evaluators/remediation-comparative.d.ts.map +1 -0
- package/dist/evaluation/evaluators/remediation-comparative.js +54 -0
- package/dist/interfaces/rest-api.d.ts.map +1 -1
- package/dist/tools/answer-question.d.ts +2 -0
- package/dist/tools/answer-question.d.ts.map +1 -1
- package/dist/tools/answer-question.js +18 -11
- package/dist/tools/generate-manifests.d.ts +2 -0
- package/dist/tools/generate-manifests.d.ts.map +1 -1
- package/dist/tools/generate-manifests.js +8 -4
- package/dist/tools/organizational-data.d.ts +1 -0
- package/dist/tools/organizational-data.d.ts.map +1 -1
- package/dist/tools/organizational-data.js +2 -1
- package/dist/tools/recommend.d.ts +1 -0
- package/dist/tools/recommend.d.ts.map +1 -1
- package/dist/tools/recommend.js +10 -5
- package/dist/tools/remediate.d.ts +3 -0
- package/dist/tools/remediate.d.ts.map +1 -1
- package/dist/tools/remediate.js +25 -12
- package/dist/tools/test-docs.d.ts +1 -0
- package/dist/tools/test-docs.d.ts.map +1 -1
- package/dist/tools/test-docs.js +4 -2
- package/dist/tools/version.d.ts +4 -1
- package/dist/tools/version.d.ts.map +1 -1
- package/dist/tools/version.js +12 -4
- package/package.json +5 -1
|
@@ -56,6 +56,11 @@ export declare class AIProviderFactory {
|
|
|
56
56
|
* @private
|
|
57
57
|
*/
|
|
58
58
|
private static createOpenAIProvider;
|
|
59
|
+
/**
|
|
60
|
+
* Create OpenAI Pro provider instance
|
|
61
|
+
* @private
|
|
62
|
+
*/
|
|
63
|
+
private static createOpenAIProProvider;
|
|
59
64
|
/**
|
|
60
65
|
* Create Google provider instance
|
|
61
66
|
* @private
|
|
@@ -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;AAsBjC;;;;;;;;;;;;;;GAcG;AACH,qBAAa,iBAAiB;IAC5B;;;;;;OAMG;IACH,MAAM,CAAC,MAAM,CAAC,MAAM,EAAE,gBAAgB,GAAG,UAAU;IAuCnD;;;;;;;;;;;;OAYG;IACH,MAAM,CAAC,aAAa,IAAI,UAAU;IA+ClC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAItC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAInC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;IAItC;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,oBAAoB;IAInC;;;;;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"}
|
|
@@ -16,16 +16,18 @@ const vercel_provider_1 = require("./providers/vercel-provider");
|
|
|
16
16
|
/**
|
|
17
17
|
* Provider environment variable mappings
|
|
18
18
|
* Phase 1 (PRD 73): anthropic, openai, google
|
|
19
|
+
* Phase 2 (PRD 154): openai_pro for GPT-5 Pro
|
|
19
20
|
*/
|
|
20
21
|
const PROVIDER_ENV_KEYS = {
|
|
21
22
|
anthropic: 'ANTHROPIC_API_KEY',
|
|
22
23
|
openai: 'OPENAI_API_KEY',
|
|
24
|
+
openai_pro: 'OPENAI_API_KEY', // Uses same API key as regular OpenAI
|
|
23
25
|
google: 'GOOGLE_API_KEY',
|
|
24
26
|
};
|
|
25
27
|
/**
|
|
26
|
-
* Providers implemented in Phase 1
|
|
28
|
+
* Providers implemented in Phase 1-2
|
|
27
29
|
*/
|
|
28
|
-
const IMPLEMENTED_PROVIDERS = ['anthropic', 'openai', 'google'];
|
|
30
|
+
const IMPLEMENTED_PROVIDERS = ['anthropic', 'openai', 'openai_pro', 'google'];
|
|
29
31
|
/**
|
|
30
32
|
* Factory for creating AI provider instances
|
|
31
33
|
*
|
|
@@ -69,6 +71,8 @@ class AIProviderFactory {
|
|
|
69
71
|
return this.createAnthropicProvider(config);
|
|
70
72
|
case 'openai':
|
|
71
73
|
return this.createOpenAIProvider(config);
|
|
74
|
+
case 'openai_pro':
|
|
75
|
+
return this.createOpenAIProProvider(config);
|
|
72
76
|
case 'google':
|
|
73
77
|
return this.createGoogleProvider(config);
|
|
74
78
|
default:
|
|
@@ -140,6 +144,13 @@ class AIProviderFactory {
|
|
|
140
144
|
static createOpenAIProvider(config) {
|
|
141
145
|
return new vercel_provider_1.VercelProvider(config);
|
|
142
146
|
}
|
|
147
|
+
/**
|
|
148
|
+
* Create OpenAI Pro provider instance
|
|
149
|
+
* @private
|
|
150
|
+
*/
|
|
151
|
+
static createOpenAIProProvider(config) {
|
|
152
|
+
return new vercel_provider_1.VercelProvider(config);
|
|
153
|
+
}
|
|
143
154
|
/**
|
|
144
155
|
* Create Google provider instance
|
|
145
156
|
* @private
|
|
@@ -109,6 +109,12 @@ export interface ToolLoopConfig {
|
|
|
109
109
|
onIteration?: (iteration: number, toolCalls: any[]) => void;
|
|
110
110
|
/** Optional operation identifier for metrics and debugging */
|
|
111
111
|
operation?: string;
|
|
112
|
+
/** PRD #154: Evaluation context for dataset generation */
|
|
113
|
+
evaluationContext?: {
|
|
114
|
+
user_intent?: string;
|
|
115
|
+
};
|
|
116
|
+
/** PRD #154: Interaction ID for dataset generation pairing */
|
|
117
|
+
interaction_id?: string;
|
|
112
118
|
}
|
|
113
119
|
/**
|
|
114
120
|
* Result from agentic tool loop
|
|
@@ -137,6 +143,11 @@ export interface AgenticResult {
|
|
|
137
143
|
completionReason?: 'investigation_complete' | 'max_iterations' | 'parse_failure' | 'model_stopped' | 'error';
|
|
138
144
|
/** Specific model version used (PRD #143 Decision 5) */
|
|
139
145
|
modelVersion?: string;
|
|
146
|
+
/** Debug files created during toolLoop execution (PRD #154) */
|
|
147
|
+
debugFiles?: {
|
|
148
|
+
full_prompt: string;
|
|
149
|
+
full_response: string;
|
|
150
|
+
};
|
|
140
151
|
}
|
|
141
152
|
/**
|
|
142
153
|
* AI Provider Interface
|
|
@@ -154,9 +165,13 @@ export interface AIProvider {
|
|
|
154
165
|
*
|
|
155
166
|
* @param message The message/prompt to send
|
|
156
167
|
* @param operation Optional operation identifier for debugging (e.g., 'deployment', 'intent-analysis')
|
|
168
|
+
* @param evaluationContext Optional evaluation context for dataset generation (PRD #154)
|
|
157
169
|
* @returns AI response with content and usage statistics
|
|
158
170
|
*/
|
|
159
|
-
sendMessage(message: string, operation?: string
|
|
171
|
+
sendMessage(message: string, operation?: string, evaluationContext?: {
|
|
172
|
+
user_intent?: string;
|
|
173
|
+
interaction_id?: string;
|
|
174
|
+
}): Promise<AIResponse>;
|
|
160
175
|
/**
|
|
161
176
|
* Check if the provider is properly initialized
|
|
162
177
|
*
|
|
@@ -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,EAAE,MAAM,CAAC;QACrC,uBAAuB,CAAC,EAAE,MAAM,CAAC;KAClC,CAAC;CACH;AAED;;GAEG;AACH,MAAM,MAAM,WAAW,GAAG,MAAM,GAAG,QAAQ,GAAG,KAAK,CAAC;AAEpD;;GAEG;AACH,MAAM,MAAM,qBAAqB,GAC7B,0BAA0B,GAC1B,uBAAuB,GACvB,0BAA0B,GAC1B,qBAAqB,GACrB,0BAA0B,CAAC;AAE/B;;GAEG;AACH,MAAM,WAAW,wBAAwB;IACvC,QAAQ,EAAE,qBAAqB,CAAC;IAChC,cAAc,EAAE,MAAM,CAAC;IACvB,WAAW,EAAE,WAAW,CAAC;IACzB,SAAS,EAAE,MAAM,CAAC;IAClB,kBAAkB,CAAC,EAAE,MAAM,EAAE,CAAC;IAC9B,gBAAgB,CAAC,EAAE,MAA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QACrB,cAAc,CAAC,EAAE,MAAM,CAAC;KACzB,GACA,OAAO,CAAC,UAAU,CAAC,CAAC;IAEvB;;;;;;OAMG;IACH,aAAa,IAAI,OAAO,CAAC;IAEzB;;;;;;;OAOG;IACH,eAAe,IAAI,MAAM,CAAC;IAE1B;;;;;;OAMG;IACH,eAAe,IAAI,MAAM,CAAC;IAE1B;;;;;;;;;;;;;;;OAeG;IACH,QAAQ,CAAC,MAAM,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC,CAAC;CAE1D"}
|
|
@@ -39,7 +39,7 @@ export declare class CapabilityInferenceEngine {
|
|
|
39
39
|
* @param resourceName - Full resource name (e.g., "resourcegroups.azure.upbound.io")
|
|
40
40
|
* @throws Error if capability inference fails for any reason
|
|
41
41
|
*/
|
|
42
|
-
inferCapabilities(resourceName: string, resourceDefinition?: string): Promise<ResourceCapability>;
|
|
42
|
+
inferCapabilities(resourceName: string, resourceDefinition?: string, interaction_id?: string): Promise<ResourceCapability>;
|
|
43
43
|
/**
|
|
44
44
|
* Use AI to infer capabilities from all available resource context
|
|
45
45
|
*
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"capabilities.d.ts","sourceRoot":"","sources":["../../src/core/capabilities.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,kBAAkB,CAAC;AAC1C,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AAIrD;;GAEG;AACH,MAAM,WAAW,kBAAkB;IAEjC,YAAY,EAAE,MAAM,CAAC;IAGrB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,SAAS,EAAE,MAAM,EAAE,CAAC;IACpB,YAAY,EAAE,MAAM,EAAE,CAAC;IACvB,UAAU,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;IAGtC,WAAW,EAAE,MAAM,CAAC;IACpB,OAAO,EAAE,MAAM,CAAC;IAGhB,SAAS,CAAC,EAAE,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IA2B9B;;;;OAIG;YACW,WAAW;IA8BzB;;;;OAIG;YACW,oBAAoB;IAalC;;;;OAIG;IACH,OAAO,CAAC,uBAAuB;IAwD/B;;OAEG;IACH,OAAO,CAAC,uBAAuB;IAyB/B;;;OAGG;IACH,MAAM,CAAC,oBAAoB,CAAC,YAAY,EAAE,MAAM,GAAG,MAAM;CAQ1D"}
|
|
@@ -29,7 +29,7 @@ class CapabilityInferenceEngine {
|
|
|
29
29
|
* @param resourceName - Full resource name (e.g., "resourcegroups.azure.upbound.io")
|
|
30
30
|
* @throws Error if capability inference fails for any reason
|
|
31
31
|
*/
|
|
32
|
-
async inferCapabilities(resourceName, resourceDefinition) {
|
|
32
|
+
async inferCapabilities(resourceName, resourceDefinition, interaction_id) {
|
|
33
33
|
const requestId = `capability-inference-${Date.now()}`;
|
|
34
34
|
this.logger.info('Starting capability inference', {
|
|
35
35
|
requestId,
|
|
@@ -37,7 +37,7 @@ class CapabilityInferenceEngine {
|
|
|
37
37
|
hasDefinition: !!resourceDefinition
|
|
38
38
|
});
|
|
39
39
|
// Use AI to analyze all available information
|
|
40
|
-
const aiResult = await this.inferWithAI(resourceName, resourceDefinition, requestId);
|
|
40
|
+
const aiResult = await this.inferWithAI(resourceName, resourceDefinition, requestId, interaction_id);
|
|
41
41
|
// Convert AI result to final capability structure
|
|
42
42
|
const finalCapability = this.buildResourceCapability(resourceName, aiResult);
|
|
43
43
|
this.logger.info('Capability inference completed', {
|
|
@@ -55,10 +55,13 @@ class CapabilityInferenceEngine {
|
|
|
55
55
|
*
|
|
56
56
|
* @throws Error if AI inference fails
|
|
57
57
|
*/
|
|
58
|
-
async inferWithAI(resourceName, resourceDefinition, requestId) {
|
|
58
|
+
async inferWithAI(resourceName, resourceDefinition, requestId, interaction_id) {
|
|
59
59
|
try {
|
|
60
60
|
const prompt = await this.buildInferencePrompt(resourceName, resourceDefinition);
|
|
61
|
-
const response = await this.aiProvider.sendMessage(prompt
|
|
61
|
+
const response = await this.aiProvider.sendMessage(prompt, 'capability-inference', {
|
|
62
|
+
user_intent: `Analyze capabilities of Kubernetes resource: ${resourceName}`,
|
|
63
|
+
interaction_id: interaction_id || 'inference'
|
|
64
|
+
});
|
|
62
65
|
return this.parseCapabilitiesFromAI(response.content);
|
|
63
66
|
}
|
|
64
67
|
catch (error) {
|
|
@@ -530,7 +530,7 @@ async function handleScanning(session, args, logger, requestId, capabilityServic
|
|
|
530
530
|
});
|
|
531
531
|
if (session.processingMode === 'manual') {
|
|
532
532
|
// Manual mode: Show capability data for user review
|
|
533
|
-
const capability = await engine.inferCapabilities(resourceName, resourceDefinition);
|
|
533
|
+
const capability = await engine.inferCapabilities(resourceName, resourceDefinition, args.interaction_id);
|
|
534
534
|
const capabilityId = capabilities_1.CapabilityInferenceEngine.generateCapabilityId(resourceName);
|
|
535
535
|
return {
|
|
536
536
|
success: true,
|
|
@@ -671,7 +671,7 @@ async function handleScanning(session, args, logger, requestId, capabilityServic
|
|
|
671
671
|
resource: currentResource,
|
|
672
672
|
percentage: Math.round(((i + 1) / totalResources) * 100)
|
|
673
673
|
});
|
|
674
|
-
const capability = await engine.inferCapabilities(currentResource, currentResourceDefinition);
|
|
674
|
+
const capability = await engine.inferCapabilities(currentResource, currentResourceDefinition, args.interaction_id);
|
|
675
675
|
const capabilityId = capabilities_1.CapabilityInferenceEngine.generateCapabilityId(currentResource);
|
|
676
676
|
// Store capability in Vector DB
|
|
677
677
|
await capabilityService.storeCapability(capability);
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Centralized Model Configuration
|
|
3
|
+
*
|
|
4
|
+
* Single source of truth for model versions currently used across the system.
|
|
5
|
+
* Update versions here to change them everywhere.
|
|
6
|
+
*/
|
|
7
|
+
export declare const CURRENT_MODELS: {
|
|
8
|
+
readonly anthropic: "claude-sonnet-4-5-20250929";
|
|
9
|
+
readonly openai: "gpt-5";
|
|
10
|
+
readonly openai_pro: "gpt-5-pro";
|
|
11
|
+
readonly google: "gemini-2.5-pro";
|
|
12
|
+
};
|
|
13
|
+
/**
|
|
14
|
+
* Get current model for a provider
|
|
15
|
+
*/
|
|
16
|
+
export declare function getCurrentModel(provider: keyof typeof CURRENT_MODELS): string;
|
|
17
|
+
//# sourceMappingURL=model-config.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"model-config.d.ts","sourceRoot":"","sources":["../../src/core/model-config.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,eAAO,MAAM,cAAc;;;;;CAKjB,CAAC;AAEX;;GAEG;AACH,wBAAgB,eAAe,CAAC,QAAQ,EAAE,MAAM,OAAO,cAAc,GAAG,MAAM,CAE7E"}
|
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Centralized Model Configuration
|
|
4
|
+
*
|
|
5
|
+
* Single source of truth for model versions currently used across the system.
|
|
6
|
+
* Update versions here to change them everywhere.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.CURRENT_MODELS = void 0;
|
|
10
|
+
exports.getCurrentModel = getCurrentModel;
|
|
11
|
+
exports.CURRENT_MODELS = {
|
|
12
|
+
anthropic: 'claude-sonnet-4-5-20250929',
|
|
13
|
+
openai: 'gpt-5',
|
|
14
|
+
openai_pro: 'gpt-5-pro',
|
|
15
|
+
google: 'gemini-2.5-pro'
|
|
16
|
+
};
|
|
17
|
+
/**
|
|
18
|
+
* Get current model for a provider
|
|
19
|
+
*/
|
|
20
|
+
function getCurrentModel(provider) {
|
|
21
|
+
return exports.CURRENT_MODELS[provider];
|
|
22
|
+
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"platform-operations.d.ts","sourceRoot":"","sources":["../../src/core/platform-operations.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAC;AACrD,OAAO,EAAE,MAAM,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,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,SAAS,EAAE,CAAC,CAkCtB;AAED;;GAEG;AACH,wBAAsB,oBAAoB,CACxC,MAAM,EAAE,MAAM,EACd,UAAU,EAAE,SAAS,EAAE,EACvB,UAAU,EAAE,UAAU,EACtB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,aAAa,CAAC,CAoCxB;AAED;;GAEG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,MAAM,EAAE,EACjB,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,iBAAiB,EAAE,CAAC,CAuE9B;AAED;;GAEG;AACH,wBAAsB,aAAa,CACjC,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,EACd,gBAAgB,EAAE,gBAAgB,EAClC,UAAU,EAAE,iBAAiB,EAAE,EAC/B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,eAAe,CAAC,CA8B1B;AAED;;GAEG;AACH,wBAAgB,WAAW,CACzB,SAAS,EAAE,MAAM,EACjB,MAAM,EAAE,MAAM,GACb,eAAe,GAAG,IAAI,CAmBxB;AAED;;GAEG;AACH,wBAAsB,gBAAgB,CACpC,OAAO,EAAE,eAAe,EACxB,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,EAC5B,MAAM,EAAE,MAAM,GACb,OAAO,CAAC;IAAE,OAAO,EAAE,OAAO,CAAC;IAAC,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,iBAAiB,CAAC,EAAE,MAAM,EAAE,CAAA;CAAE,CAAC,CAkE/F"}
|
|
@@ -69,8 +69,7 @@ async function discoverOperations(aiProvider, logger) {
|
|
|
69
69
|
// Single AI call with injected data
|
|
70
70
|
const response = await aiProvider.sendMessage(prompt, 'platform-discover-operations');
|
|
71
71
|
// Parse operations from AI response
|
|
72
|
-
const
|
|
73
|
-
const operations = JSON.parse(jsonContent);
|
|
72
|
+
const operations = (0, platform_utils_1.extractJsonFromAIResponse)(response.content);
|
|
74
73
|
logger.info?.('Discovered operations from Nu scripts', {
|
|
75
74
|
count: operations.length
|
|
76
75
|
});
|
|
@@ -95,9 +94,8 @@ async function mapIntentToOperation(intent, operations, aiProvider, logger) {
|
|
|
95
94
|
.replace('{operations}', JSON.stringify(operations, null, 2));
|
|
96
95
|
// Send to AI provider for AI-powered intent matching
|
|
97
96
|
const response = await aiProvider.sendMessage(prompt, 'platform-map-intent');
|
|
98
|
-
//
|
|
99
|
-
const
|
|
100
|
-
const mapping = JSON.parse(jsonContent);
|
|
97
|
+
// Extract JSON from AI response with robust parsing
|
|
98
|
+
const mapping = (0, platform_utils_1.extractJsonFromAIResponse)(response.content);
|
|
101
99
|
// Validate that AI returned required fields
|
|
102
100
|
if (mapping.matched && mapping.operation) {
|
|
103
101
|
if (!mapping.operation.command || !Array.isArray(mapping.operation.command)) {
|
|
@@ -10,7 +10,8 @@ export declare const execAsync: typeof exec.__promisify__;
|
|
|
10
10
|
*/
|
|
11
11
|
export declare function getScriptsDir(): string;
|
|
12
12
|
/**
|
|
13
|
-
*
|
|
13
|
+
* Extract JSON object from AI response with robust parsing
|
|
14
|
+
* Handles markdown code blocks and finds proper JSON boundaries
|
|
14
15
|
*/
|
|
15
|
-
export declare function
|
|
16
|
+
export declare function extractJsonFromAIResponse(aiResponse: string): any;
|
|
16
17
|
//# 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;
|
|
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"}
|
|
@@ -40,7 +40,7 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
40
40
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
41
41
|
exports.execAsync = void 0;
|
|
42
42
|
exports.getScriptsDir = getScriptsDir;
|
|
43
|
-
exports.
|
|
43
|
+
exports.extractJsonFromAIResponse = extractJsonFromAIResponse;
|
|
44
44
|
const child_process_1 = require("child_process");
|
|
45
45
|
const util_1 = require("util");
|
|
46
46
|
const path = __importStar(require("path"));
|
|
@@ -54,15 +54,41 @@ function getScriptsDir() {
|
|
|
54
54
|
return path.join(__dirname, '..', '..', 'scripts');
|
|
55
55
|
}
|
|
56
56
|
/**
|
|
57
|
-
*
|
|
57
|
+
* Extract JSON object from AI response with robust parsing
|
|
58
|
+
* Handles markdown code blocks and finds proper JSON boundaries
|
|
58
59
|
*/
|
|
59
|
-
function
|
|
60
|
-
let jsonContent =
|
|
61
|
-
|
|
62
|
-
|
|
60
|
+
function extractJsonFromAIResponse(aiResponse) {
|
|
61
|
+
let jsonContent = aiResponse;
|
|
62
|
+
// First try to find JSON wrapped in code blocks
|
|
63
|
+
const codeBlockMatch = aiResponse.match(/```(?:json)?\s*(\{[\s\S]*?\})\s*```/);
|
|
64
|
+
if (codeBlockMatch) {
|
|
65
|
+
jsonContent = codeBlockMatch[1];
|
|
63
66
|
}
|
|
64
|
-
else
|
|
65
|
-
|
|
67
|
+
else {
|
|
68
|
+
// Try to find JSON that starts with { and find the matching closing }
|
|
69
|
+
const startIndex = aiResponse.indexOf('{');
|
|
70
|
+
if (startIndex !== -1) {
|
|
71
|
+
let braceCount = 0;
|
|
72
|
+
let endIndex = startIndex;
|
|
73
|
+
for (let i = startIndex; i < aiResponse.length; i++) {
|
|
74
|
+
if (aiResponse[i] === '{')
|
|
75
|
+
braceCount++;
|
|
76
|
+
if (aiResponse[i] === '}')
|
|
77
|
+
braceCount--;
|
|
78
|
+
if (braceCount === 0) {
|
|
79
|
+
endIndex = i;
|
|
80
|
+
break;
|
|
81
|
+
}
|
|
82
|
+
}
|
|
83
|
+
if (endIndex > startIndex) {
|
|
84
|
+
jsonContent = aiResponse.substring(startIndex, endIndex + 1);
|
|
85
|
+
}
|
|
86
|
+
}
|
|
87
|
+
}
|
|
88
|
+
try {
|
|
89
|
+
return JSON.parse(jsonContent.trim());
|
|
90
|
+
}
|
|
91
|
+
catch (error) {
|
|
92
|
+
throw new Error(`Failed to parse JSON from AI response: ${error}`);
|
|
66
93
|
}
|
|
67
|
-
return jsonContent;
|
|
68
94
|
}
|
|
@@ -19,7 +19,10 @@ export declare class AnthropicProvider implements AIProvider {
|
|
|
19
19
|
* Helper method to log debug information if debug mode is enabled
|
|
20
20
|
*/
|
|
21
21
|
private logDebugIfEnabled;
|
|
22
|
-
sendMessage(message: string, operation?: string
|
|
22
|
+
sendMessage(message: string, operation?: string, evaluationContext?: {
|
|
23
|
+
user_intent?: string;
|
|
24
|
+
interaction_id?: string;
|
|
25
|
+
}): Promise<AIResponse>;
|
|
23
26
|
/**
|
|
24
27
|
* Agentic tool loop implementation
|
|
25
28
|
*
|
|
@@ -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;
|
|
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;IAWpC,OAAO,CAAC,cAAc;IAStB,eAAe,IAAI,MAAM;IAIzB,eAAe,IAAI,MAAM;IAIzB,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"}
|
|
@@ -12,6 +12,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
|
|
|
12
12
|
exports.AnthropicProvider = void 0;
|
|
13
13
|
const sdk_1 = __importDefault(require("@anthropic-ai/sdk"));
|
|
14
14
|
const provider_debug_utils_1 = require("./provider-debug-utils");
|
|
15
|
+
const model_config_1 = require("../model-config");
|
|
15
16
|
class AnthropicProvider {
|
|
16
17
|
client;
|
|
17
18
|
apiKey;
|
|
@@ -38,7 +39,7 @@ class AnthropicProvider {
|
|
|
38
39
|
return 'anthropic';
|
|
39
40
|
}
|
|
40
41
|
getDefaultModel() {
|
|
41
|
-
return '
|
|
42
|
+
return (0, model_config_1.getCurrentModel)('anthropic');
|
|
42
43
|
}
|
|
43
44
|
isInitialized() {
|
|
44
45
|
return this.client !== undefined;
|
|
@@ -46,22 +47,18 @@ class AnthropicProvider {
|
|
|
46
47
|
/**
|
|
47
48
|
* Helper method to log debug information if debug mode is enabled
|
|
48
49
|
*/
|
|
49
|
-
logDebugIfEnabled(operation, prompt, response
|
|
50
|
+
logDebugIfEnabled(operation, prompt, response) {
|
|
50
51
|
if (!this.debugMode)
|
|
51
|
-
return;
|
|
52
|
+
return null;
|
|
52
53
|
const debugId = (0, provider_debug_utils_1.generateDebugId)(operation);
|
|
53
54
|
(0, provider_debug_utils_1.debugLogInteraction)(debugId, prompt, response, operation, this.getProviderType(), this.model, this.debugMode);
|
|
54
|
-
//
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
cacheCreation: response.usage.cache_creation_input_tokens,
|
|
60
|
-
cacheRead: response.usage.cache_read_input_tokens
|
|
61
|
-
}
|
|
62
|
-
}, durationMs, this.debugMode);
|
|
55
|
+
// Return the actual debug file names created
|
|
56
|
+
return {
|
|
57
|
+
promptFile: `${debugId}_prompt.md`,
|
|
58
|
+
responseFile: `${debugId}_response.md`
|
|
59
|
+
};
|
|
63
60
|
}
|
|
64
|
-
async sendMessage(message, operation = 'generic') {
|
|
61
|
+
async sendMessage(message, operation = 'generic', evaluationContext) {
|
|
65
62
|
if (!this.client) {
|
|
66
63
|
throw new Error('Anthropic client not initialized');
|
|
67
64
|
}
|
|
@@ -97,9 +94,32 @@ class AnthropicProvider {
|
|
|
97
94
|
output_tokens
|
|
98
95
|
}
|
|
99
96
|
};
|
|
100
|
-
const durationMs = Date.now() - startTime;
|
|
101
97
|
// Debug log the interaction if enabled
|
|
102
|
-
this.logDebugIfEnabled(operation, message, response
|
|
98
|
+
this.logDebugIfEnabled(operation, message, response);
|
|
99
|
+
// PRD #154: Log evaluation dataset if evaluation context is provided
|
|
100
|
+
if (this.debugMode && evaluationContext?.interaction_id) {
|
|
101
|
+
const durationMs = Date.now() - startTime;
|
|
102
|
+
const evaluationMetrics = {
|
|
103
|
+
// Core execution data
|
|
104
|
+
operation,
|
|
105
|
+
sdk: this.getProviderType(),
|
|
106
|
+
inputTokens: input_tokens,
|
|
107
|
+
outputTokens: output_tokens,
|
|
108
|
+
durationMs,
|
|
109
|
+
// Required fields
|
|
110
|
+
iterationCount: 1,
|
|
111
|
+
toolCallCount: 0,
|
|
112
|
+
status: 'completed',
|
|
113
|
+
completionReason: 'stop',
|
|
114
|
+
modelVersion: this.model,
|
|
115
|
+
// Required evaluation context - NO DEFAULTS, must be provided
|
|
116
|
+
test_scenario: operation,
|
|
117
|
+
ai_response_summary: content,
|
|
118
|
+
user_intent: evaluationContext?.user_intent || '',
|
|
119
|
+
interaction_id: evaluationContext?.interaction_id || '',
|
|
120
|
+
};
|
|
121
|
+
(0, provider_debug_utils_1.logEvaluationDataset)(evaluationMetrics, this.debugMode);
|
|
122
|
+
}
|
|
103
123
|
return response;
|
|
104
124
|
}
|
|
105
125
|
catch (error) {
|
|
@@ -167,7 +187,40 @@ class AnthropicProvider {
|
|
|
167
187
|
try {
|
|
168
188
|
while (iterations < maxIterations) {
|
|
169
189
|
iterations++;
|
|
170
|
-
|
|
190
|
+
// Build current prompt for debug logging
|
|
191
|
+
const currentPrompt = `System: ${config.systemPrompt}\n\n${conversationHistory.map(msg => {
|
|
192
|
+
let content = '';
|
|
193
|
+
if (typeof msg.content === 'string') {
|
|
194
|
+
content = msg.content;
|
|
195
|
+
}
|
|
196
|
+
else if (Array.isArray(msg.content)) {
|
|
197
|
+
// Extract text from content blocks
|
|
198
|
+
content = msg.content.map(block => {
|
|
199
|
+
if (block.type === 'text') {
|
|
200
|
+
return block.text;
|
|
201
|
+
}
|
|
202
|
+
else if (block.type === 'tool_use') {
|
|
203
|
+
return `[TOOL_USE: ${block.name}]`;
|
|
204
|
+
}
|
|
205
|
+
else if (block.type === 'tool_result') {
|
|
206
|
+
const content = block.content;
|
|
207
|
+
if (typeof content === 'string') {
|
|
208
|
+
return `[TOOL_RESULT: ${block.tool_use_id}]\n${content}`;
|
|
209
|
+
}
|
|
210
|
+
else if (Array.isArray(content)) {
|
|
211
|
+
const textContent = content.map(c => c.type === 'text' ? c.text : `[${c.type}]`).join(' ');
|
|
212
|
+
return `[TOOL_RESULT: ${block.tool_use_id}]\n${textContent}`;
|
|
213
|
+
}
|
|
214
|
+
return `[TOOL_RESULT: ${block.tool_use_id}]`;
|
|
215
|
+
}
|
|
216
|
+
return `[${block.type}]`;
|
|
217
|
+
}).join(' ');
|
|
218
|
+
}
|
|
219
|
+
else {
|
|
220
|
+
content = '[complex_content]';
|
|
221
|
+
}
|
|
222
|
+
return `${msg.role}: ${content}`;
|
|
223
|
+
}).join('\n\n')}`;
|
|
171
224
|
// Call Anthropic API with tools and cached system prompt
|
|
172
225
|
const response = await this.client.messages.create({
|
|
173
226
|
model: this.model,
|
|
@@ -186,11 +239,16 @@ class AnthropicProvider {
|
|
|
186
239
|
if ('cache_read_input_tokens' in response.usage) {
|
|
187
240
|
totalTokens.cacheRead += response.usage.cache_read_input_tokens || 0;
|
|
188
241
|
}
|
|
189
|
-
//
|
|
190
|
-
|
|
191
|
-
|
|
242
|
+
// Check if AI wants to use tools
|
|
243
|
+
const toolUses = response.content.filter((c) => c.type === 'tool_use');
|
|
244
|
+
// Log debug for final iteration to capture complete prompts/responses for evaluation
|
|
245
|
+
let debugFiles = null;
|
|
246
|
+
if (toolUses.length === 0) {
|
|
192
247
|
const aiResponse = {
|
|
193
|
-
content: response.content
|
|
248
|
+
content: response.content
|
|
249
|
+
.filter((c) => c.type === 'text')
|
|
250
|
+
.map(c => c.text)
|
|
251
|
+
.join('\n\n'),
|
|
194
252
|
usage: {
|
|
195
253
|
input_tokens: response.usage.input_tokens,
|
|
196
254
|
output_tokens: response.usage.output_tokens,
|
|
@@ -198,11 +256,8 @@ class AnthropicProvider {
|
|
|
198
256
|
cache_read_input_tokens: response.usage.cache_read_input_tokens
|
|
199
257
|
}
|
|
200
258
|
};
|
|
201
|
-
|
|
202
|
-
this.logDebugIfEnabled(`${operation}-iter${iterations}`, currentPrompt, aiResponse, iterationDurationMs);
|
|
259
|
+
debugFiles = this.logDebugIfEnabled(`${config.operation}-summary`, currentPrompt, aiResponse);
|
|
203
260
|
}
|
|
204
|
-
// Check if AI wants to use tools
|
|
205
|
-
const toolUses = response.content.filter((c) => c.type === 'tool_use');
|
|
206
261
|
if (toolUses.length === 0) {
|
|
207
262
|
// AI is done - extract final text message
|
|
208
263
|
const textContent = response.content.find((c) => c.type === 'text');
|
|
@@ -222,7 +277,10 @@ class AnthropicProvider {
|
|
|
222
277
|
operation: `${operation}-summary`,
|
|
223
278
|
sdk: this.getProviderType(),
|
|
224
279
|
startTime,
|
|
225
|
-
debugMode: this.debugMode
|
|
280
|
+
debugMode: this.debugMode,
|
|
281
|
+
debugFiles,
|
|
282
|
+
evaluationContext: config.evaluationContext,
|
|
283
|
+
interaction_id: config.interaction_id
|
|
226
284
|
});
|
|
227
285
|
}
|
|
228
286
|
// Execute all requested tools in parallel
|
|
@@ -295,7 +353,9 @@ class AnthropicProvider {
|
|
|
295
353
|
operation: `${operation}-max-iterations`,
|
|
296
354
|
sdk: this.getProviderType(),
|
|
297
355
|
startTime,
|
|
298
|
-
debugMode: this.debugMode
|
|
356
|
+
debugMode: this.debugMode,
|
|
357
|
+
evaluationContext: config.evaluationContext,
|
|
358
|
+
interaction_id: config.interaction_id
|
|
299
359
|
});
|
|
300
360
|
}
|
|
301
361
|
catch (error) {
|
|
@@ -316,7 +376,9 @@ class AnthropicProvider {
|
|
|
316
376
|
operation: `${operation}-error`,
|
|
317
377
|
sdk: this.getProviderType(),
|
|
318
378
|
startTime,
|
|
319
|
-
debugMode: this.debugMode
|
|
379
|
+
debugMode: this.debugMode,
|
|
380
|
+
evaluationContext: config.evaluationContext,
|
|
381
|
+
interaction_id: config.interaction_id
|
|
320
382
|
});
|
|
321
383
|
}
|
|
322
384
|
}
|