mcp-image 0.1.0 → 0.2.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/README.md +41 -17
- package/dist/api/geminiClient.d.ts +2 -12
- package/dist/api/geminiClient.d.ts.map +1 -1
- package/dist/api/geminiClient.js +28 -56
- package/dist/api/geminiClient.js.map +1 -1
- package/dist/api/geminiTextClient.d.ts +42 -0
- package/dist/api/geminiTextClient.d.ts.map +1 -0
- package/dist/api/geminiTextClient.js +198 -0
- package/dist/api/geminiTextClient.js.map +1 -0
- package/dist/business/__tests__/mocks/mcpSamplingClient.mock.d.ts +84 -0
- package/dist/business/__tests__/mocks/mcpSamplingClient.mock.d.ts.map +1 -0
- package/dist/business/__tests__/mocks/mcpSamplingClient.mock.js +100 -0
- package/dist/business/__tests__/mocks/mcpSamplingClient.mock.js.map +1 -0
- package/dist/business/bestPracticesEngine.d.ts +149 -0
- package/dist/business/bestPracticesEngine.d.ts.map +1 -0
- package/dist/business/bestPracticesEngine.js +781 -0
- package/dist/business/bestPracticesEngine.js.map +1 -0
- package/dist/business/complexityAssessment.d.ts +132 -0
- package/dist/business/complexityAssessment.d.ts.map +1 -0
- package/dist/business/complexityAssessment.js +488 -0
- package/dist/business/complexityAssessment.js.map +1 -0
- package/dist/business/fallbackStrategies.d.ts +177 -0
- package/dist/business/fallbackStrategies.d.ts.map +1 -0
- package/dist/business/fallbackStrategies.js +368 -0
- package/dist/business/fallbackStrategies.js.map +1 -0
- package/dist/business/imageGenerator.d.ts.map +1 -1
- package/dist/business/imageGenerator.js +26 -5
- package/dist/business/imageGenerator.js.map +1 -1
- package/dist/business/multiImage/aspectRatioController.d.ts +77 -0
- package/dist/business/multiImage/aspectRatioController.d.ts.map +1 -0
- package/dist/business/multiImage/aspectRatioController.js +580 -0
- package/dist/business/multiImage/aspectRatioController.js.map +1 -0
- package/dist/business/multiImage/multiImageCoordinator.d.ts +142 -0
- package/dist/business/multiImage/multiImageCoordinator.d.ts.map +1 -0
- package/dist/business/multiImage/multiImageCoordinator.js +801 -0
- package/dist/business/multiImage/multiImageCoordinator.js.map +1 -0
- package/dist/business/pomlTemplateEngine.d.ts +206 -0
- package/dist/business/pomlTemplateEngine.d.ts.map +1 -0
- package/dist/business/pomlTemplateEngine.js +737 -0
- package/dist/business/pomlTemplateEngine.js.map +1 -0
- package/dist/business/promptOrchestrator.d.ts +173 -0
- package/dist/business/promptOrchestrator.d.ts.map +1 -0
- package/dist/business/promptOrchestrator.js +490 -0
- package/dist/business/promptOrchestrator.js.map +1 -0
- package/dist/business/responseBuilder.d.ts +2 -2
- package/dist/business/responseBuilder.d.ts.map +1 -1
- package/dist/business/responseBuilder.js +6 -1
- package/dist/business/responseBuilder.js.map +1 -1
- package/dist/business/structuredPromptGenerator.d.ts +54 -0
- package/dist/business/structuredPromptGenerator.d.ts.map +1 -0
- package/dist/business/structuredPromptGenerator.js +208 -0
- package/dist/business/structuredPromptGenerator.js.map +1 -0
- package/dist/business/templateNormalizer.d.ts +81 -0
- package/dist/business/templateNormalizer.d.ts.map +1 -0
- package/dist/business/templateNormalizer.js +659 -0
- package/dist/business/templateNormalizer.js.map +1 -0
- package/dist/documentation/apiContractValidation.d.ts +62 -0
- package/dist/documentation/apiContractValidation.d.ts.map +1 -0
- package/dist/documentation/apiContractValidation.js +305 -0
- package/dist/documentation/apiContractValidation.js.map +1 -0
- package/dist/infrastructure/concurrency/concurrencyManager.d.ts +101 -0
- package/dist/infrastructure/concurrency/concurrencyManager.d.ts.map +1 -0
- package/dist/infrastructure/concurrency/concurrencyManager.js +345 -0
- package/dist/infrastructure/concurrency/concurrencyManager.js.map +1 -0
- package/dist/infrastructure/config/secureConfigManager.d.ts +319 -0
- package/dist/infrastructure/config/secureConfigManager.d.ts.map +1 -0
- package/dist/infrastructure/config/secureConfigManager.js +600 -0
- package/dist/infrastructure/config/secureConfigManager.js.map +1 -0
- package/dist/infrastructure/errorHandling/orchestrationErrorHandler.d.ts +229 -0
- package/dist/infrastructure/errorHandling/orchestrationErrorHandler.d.ts.map +1 -0
- package/dist/infrastructure/errorHandling/orchestrationErrorHandler.js +61 -0
- package/dist/infrastructure/errorHandling/orchestrationErrorHandler.js.map +1 -0
- package/dist/infrastructure/errorHandling/orchestrationErrorHandlerImpl.d.ts +133 -0
- package/dist/infrastructure/errorHandling/orchestrationErrorHandlerImpl.d.ts.map +1 -0
- package/dist/infrastructure/errorHandling/orchestrationErrorHandlerImpl.js +569 -0
- package/dist/infrastructure/errorHandling/orchestrationErrorHandlerImpl.js.map +1 -0
- package/dist/infrastructure/mcp/MCPSamplingClient.d.ts +19 -0
- package/dist/infrastructure/mcp/MCPSamplingClient.d.ts.map +1 -0
- package/dist/infrastructure/mcp/MCPSamplingClient.js +31 -0
- package/dist/infrastructure/mcp/MCPSamplingClient.js.map +1 -0
- package/dist/infrastructure/mcp/RealMCPSamplingClient.d.ts +59 -0
- package/dist/infrastructure/mcp/RealMCPSamplingClient.d.ts.map +1 -0
- package/dist/infrastructure/mcp/RealMCPSamplingClient.js +271 -0
- package/dist/infrastructure/mcp/RealMCPSamplingClient.js.map +1 -0
- package/dist/infrastructure/metadata/generationMetadata.d.ts +72 -0
- package/dist/infrastructure/metadata/generationMetadata.d.ts.map +1 -0
- package/dist/infrastructure/metadata/generationMetadata.js +228 -0
- package/dist/infrastructure/metadata/generationMetadata.js.map +1 -0
- package/dist/infrastructure/monitoring/OrchestrationMetrics.d.ts +106 -0
- package/dist/infrastructure/monitoring/OrchestrationMetrics.d.ts.map +1 -0
- package/dist/infrastructure/monitoring/OrchestrationMetrics.js +456 -0
- package/dist/infrastructure/monitoring/OrchestrationMetrics.js.map +1 -0
- package/dist/infrastructure/monitoring/alertingSystem.d.ts +135 -0
- package/dist/infrastructure/monitoring/alertingSystem.d.ts.map +1 -0
- package/dist/infrastructure/monitoring/alertingSystem.js +549 -0
- package/dist/infrastructure/monitoring/alertingSystem.js.map +1 -0
- package/dist/infrastructure/optimization/performanceOptimizer.d.ts +89 -0
- package/dist/infrastructure/optimization/performanceOptimizer.d.ts.map +1 -0
- package/dist/infrastructure/optimization/performanceOptimizer.js +375 -0
- package/dist/infrastructure/optimization/performanceOptimizer.js.map +1 -0
- package/dist/infrastructure/security/AdvancedContentFilter.d.ts +99 -0
- package/dist/infrastructure/security/AdvancedContentFilter.d.ts.map +1 -0
- package/dist/infrastructure/security/AdvancedContentFilter.js +363 -0
- package/dist/infrastructure/security/AdvancedContentFilter.js.map +1 -0
- package/dist/infrastructure/security/MCPSecurityValidator.d.ts +62 -0
- package/dist/infrastructure/security/MCPSecurityValidator.d.ts.map +1 -0
- package/dist/infrastructure/security/MCPSecurityValidator.js +129 -0
- package/dist/infrastructure/security/MCPSecurityValidator.js.map +1 -0
- package/dist/infrastructure/security/OrchestrationSecurityMiddleware.d.ts +304 -0
- package/dist/infrastructure/security/OrchestrationSecurityMiddleware.d.ts.map +1 -0
- package/dist/infrastructure/security/OrchestrationSecurityMiddleware.js +61 -0
- package/dist/infrastructure/security/OrchestrationSecurityMiddleware.js.map +1 -0
- package/dist/infrastructure/security/OrchestrationSecurityMiddlewareImpl.d.ts +62 -0
- package/dist/infrastructure/security/OrchestrationSecurityMiddlewareImpl.d.ts.map +1 -0
- package/dist/infrastructure/security/OrchestrationSecurityMiddlewareImpl.js +591 -0
- package/dist/infrastructure/security/OrchestrationSecurityMiddlewareImpl.js.map +1 -0
- package/dist/infrastructure/security/SecureMCPClient.d.ts +154 -0
- package/dist/infrastructure/security/SecureMCPClient.d.ts.map +1 -0
- package/dist/infrastructure/security/SecureMCPClient.js +292 -0
- package/dist/infrastructure/security/SecureMCPClient.js.map +1 -0
- package/dist/infrastructure/security/SecurityIncidentManager.d.ts +142 -0
- package/dist/infrastructure/security/SecurityIncidentManager.d.ts.map +1 -0
- package/dist/infrastructure/security/SecurityIncidentManager.js +260 -0
- package/dist/infrastructure/security/SecurityIncidentManager.js.map +1 -0
- package/dist/infrastructure/security/apiKeyManager.d.ts +297 -0
- package/dist/infrastructure/security/apiKeyManager.d.ts.map +1 -0
- package/dist/infrastructure/security/apiKeyManager.js +254 -0
- package/dist/infrastructure/security/apiKeyManager.js.map +1 -0
- package/dist/infrastructure/security/dataSanitizer.d.ts +157 -0
- package/dist/infrastructure/security/dataSanitizer.d.ts.map +1 -0
- package/dist/infrastructure/security/dataSanitizer.js +525 -0
- package/dist/infrastructure/security/dataSanitizer.js.map +1 -0
- package/dist/infrastructure/validation/inputValidator.d.ts +54 -0
- package/dist/infrastructure/validation/inputValidator.d.ts.map +1 -0
- package/dist/infrastructure/validation/inputValidator.js +362 -0
- package/dist/infrastructure/validation/inputValidator.js.map +1 -0
- package/dist/integration/parameterOptimizer.d.ts +69 -0
- package/dist/integration/parameterOptimizer.d.ts.map +1 -0
- package/dist/integration/parameterOptimizer.js +317 -0
- package/dist/integration/parameterOptimizer.js.map +1 -0
- package/dist/integration/twoStageProcessor.d.ts +66 -0
- package/dist/integration/twoStageProcessor.d.ts.map +1 -0
- package/dist/integration/twoStageProcessor.js +348 -0
- package/dist/integration/twoStageProcessor.js.map +1 -0
- package/dist/server/handlers/structuredPromptHandler.d.ts +65 -0
- package/dist/server/handlers/structuredPromptHandler.d.ts.map +1 -0
- package/dist/server/handlers/structuredPromptHandler.js +314 -0
- package/dist/server/handlers/structuredPromptHandler.js.map +1 -0
- package/dist/server/mcpServer.d.ts +16 -35
- package/dist/server/mcpServer.d.ts.map +1 -1
- package/dist/server/mcpServer.js +111 -150
- package/dist/server/mcpServer.js.map +1 -1
- package/dist/server/mcpServerWithOrchestration.d.ts +98 -0
- package/dist/server/mcpServerWithOrchestration.d.ts.map +1 -0
- package/dist/server/mcpServerWithOrchestration.js +284 -0
- package/dist/server/mcpServerWithOrchestration.js.map +1 -0
- package/dist/types/mcpOrchestrationTypes.d.ts +135 -0
- package/dist/types/mcpOrchestrationTypes.d.ts.map +1 -0
- package/dist/types/mcpOrchestrationTypes.js +28 -0
- package/dist/types/mcpOrchestrationTypes.js.map +1 -0
- package/dist/types/multiImageTypes.d.ts +328 -0
- package/dist/types/multiImageTypes.d.ts.map +1 -0
- package/dist/types/multiImageTypes.js +27 -0
- package/dist/types/multiImageTypes.js.map +1 -0
- package/dist/types/performanceTypes.d.ts +300 -0
- package/dist/types/performanceTypes.d.ts.map +1 -0
- package/dist/types/performanceTypes.js +50 -0
- package/dist/types/performanceTypes.js.map +1 -0
- package/dist/types/twoStageTypes.d.ts +123 -0
- package/dist/types/twoStageTypes.d.ts.map +1 -0
- package/dist/types/twoStageTypes.js +7 -0
- package/dist/types/twoStageTypes.js.map +1 -0
- package/dist/utils/config.d.ts +1 -0
- package/dist/utils/config.d.ts.map +1 -1
- package/dist/utils/config.js +1 -0
- package/dist/utils/config.js.map +1 -1
- package/package.json +11 -4
- package/vitest.config.mjs +0 -47
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Mock implementation of MCP Sampling Client for testing
|
|
4
|
+
* Provides predictable responses for testing the orchestrator
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.MockMCPSamplingClient = void 0;
|
|
8
|
+
exports.createMockMCPSamplingClient = createMockMCPSamplingClient;
|
|
9
|
+
/**
|
|
10
|
+
* Mock implementation of MCPSamplingClient for testing purposes
|
|
11
|
+
* Provides predictable behavior for orchestrator testing
|
|
12
|
+
*/
|
|
13
|
+
class MockMCPSamplingClient {
|
|
14
|
+
constructor(_config) {
|
|
15
|
+
this.config = {
|
|
16
|
+
timeout: 5000,
|
|
17
|
+
maxAttempts: 3,
|
|
18
|
+
enableLogging: false,
|
|
19
|
+
..._config,
|
|
20
|
+
};
|
|
21
|
+
this.mockDelay = 100; // Fast response for testing
|
|
22
|
+
this.shouldFail = false;
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Set whether the mock should simulate failures
|
|
26
|
+
*/
|
|
27
|
+
setShouldFail(shouldFail) {
|
|
28
|
+
this.shouldFail = shouldFail;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Set mock response delay for testing timing scenarios
|
|
32
|
+
*/
|
|
33
|
+
setMockDelay(delay) {
|
|
34
|
+
this.mockDelay = delay;
|
|
35
|
+
}
|
|
36
|
+
/**
|
|
37
|
+
* Mock implementation of prompt refinement
|
|
38
|
+
* Returns predictable enhanced prompts for testing
|
|
39
|
+
*/
|
|
40
|
+
async refinePrompt(prompt) {
|
|
41
|
+
// Simulate processing time
|
|
42
|
+
await new Promise((resolve) => setTimeout(resolve, this.mockDelay));
|
|
43
|
+
if (this.config.enableLogging) {
|
|
44
|
+
console.debug(`Mock MCP Sampling processing: ${prompt.substring(0, 50)}...`);
|
|
45
|
+
}
|
|
46
|
+
// Simulate security validation - reject sensitive information
|
|
47
|
+
const sensitivePatterns = /\b(api[_\s-]?key|secret|token|password|bearer|sk-\w+)\b/i;
|
|
48
|
+
if (sensitivePatterns.test(prompt)) {
|
|
49
|
+
return {
|
|
50
|
+
refinedPrompt: prompt, // Return original without enhancement
|
|
51
|
+
success: false,
|
|
52
|
+
processingTime: this.mockDelay,
|
|
53
|
+
metadata: {
|
|
54
|
+
model: 'mock-model-v1',
|
|
55
|
+
iterations: 0,
|
|
56
|
+
confidence: 0,
|
|
57
|
+
},
|
|
58
|
+
};
|
|
59
|
+
}
|
|
60
|
+
if (this.shouldFail) {
|
|
61
|
+
return {
|
|
62
|
+
refinedPrompt: prompt,
|
|
63
|
+
success: false,
|
|
64
|
+
processingTime: this.mockDelay,
|
|
65
|
+
metadata: {
|
|
66
|
+
model: 'mock-model-v1',
|
|
67
|
+
iterations: 0,
|
|
68
|
+
confidence: 0,
|
|
69
|
+
},
|
|
70
|
+
};
|
|
71
|
+
}
|
|
72
|
+
// Simulate advanced prompt refinement
|
|
73
|
+
const refinedPrompt = `${prompt}, highly detailed professional rendering with advanced lighting techniques, photorealistic quality, enhanced composition`;
|
|
74
|
+
return {
|
|
75
|
+
refinedPrompt,
|
|
76
|
+
success: true,
|
|
77
|
+
processingTime: this.mockDelay,
|
|
78
|
+
metadata: {
|
|
79
|
+
model: 'mock-model-v1',
|
|
80
|
+
iterations: 3,
|
|
81
|
+
confidence: 0.9,
|
|
82
|
+
},
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
/**
|
|
86
|
+
* Mock availability check - always returns true unless configured to fail
|
|
87
|
+
*/
|
|
88
|
+
async isAvailable() {
|
|
89
|
+
await new Promise((resolve) => setTimeout(resolve, 10));
|
|
90
|
+
return !this.shouldFail;
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
exports.MockMCPSamplingClient = MockMCPSamplingClient;
|
|
94
|
+
/**
|
|
95
|
+
* Factory function to create a mock MCP Sampling Client with default configuration
|
|
96
|
+
*/
|
|
97
|
+
function createMockMCPSamplingClient(config) {
|
|
98
|
+
return new MockMCPSamplingClient(config);
|
|
99
|
+
}
|
|
100
|
+
//# sourceMappingURL=mcpSamplingClient.mock.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"mcpSamplingClient.mock.js","sourceRoot":"","sources":["../../../../src/business/__tests__/mocks/mcpSamplingClient.mock.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AA2JH,kEAIC;AAzGD;;;GAGG;AACH,MAAa,qBAAqB;IAKhC,YAAY,OAAoC;QAC9C,IAAI,CAAC,MAAM,GAAG;YACZ,OAAO,EAAE,IAAI;YACb,WAAW,EAAE,CAAC;YACd,aAAa,EAAE,KAAK;YACpB,GAAG,OAAO;SACX,CAAA;QACD,IAAI,CAAC,SAAS,GAAG,GAAG,CAAA,CAAC,4BAA4B;QACjD,IAAI,CAAC,UAAU,GAAG,KAAK,CAAA;IACzB,CAAC;IAED;;OAEG;IACH,aAAa,CAAC,UAAmB;QAC/B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAA;IAC9B,CAAC;IAED;;OAEG;IACH,YAAY,CAAC,KAAa;QACxB,IAAI,CAAC,SAAS,GAAG,KAAK,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;aAChB;SACF,CAAA;IACH,CAAC;IAED;;OAEG;IACH,KAAK,CAAC,WAAW;QACf,MAAM,IAAI,OAAO,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAA;QACvD,OAAO,CAAC,IAAI,CAAC,UAAU,CAAA;IACzB,CAAC;CACF;AA5FD,sDA4FC;AAED;;GAEG;AACH,SAAgB,2BAA2B,CACzC,MAAmC;IAEnC,OAAO,IAAI,qBAAqB,CAAC,MAAM,CAAC,CAAA;AAC1C,CAAC"}
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Best Practices Engine for prompt optimization using 7 research-based strategies
|
|
3
|
+
* Implements hyper-specific conversion, semantic transformation, and structured enhancement
|
|
4
|
+
* for image generation prompts to improve output quality and consistency
|
|
5
|
+
*/
|
|
6
|
+
import type { GeminiTextClient } from '../api/geminiTextClient';
|
|
7
|
+
import type { Result } from '../types/result';
|
|
8
|
+
/**
|
|
9
|
+
* Configuration options for best practices application
|
|
10
|
+
*/
|
|
11
|
+
export interface BestPracticesOptions {
|
|
12
|
+
enabledPractices?: BestPracticeType[];
|
|
13
|
+
aspectRatio?: AspectRatio;
|
|
14
|
+
targetStyle?: string;
|
|
15
|
+
contextIntent?: string;
|
|
16
|
+
maintainCharacterConsistency?: boolean;
|
|
17
|
+
blendImages?: boolean;
|
|
18
|
+
useWorldKnowledge?: boolean;
|
|
19
|
+
}
|
|
20
|
+
/**
|
|
21
|
+
* Configuration for the Best Practices Engine
|
|
22
|
+
*/
|
|
23
|
+
export interface BestPracticesConfig {
|
|
24
|
+
timeout: number;
|
|
25
|
+
enableAllPractices: boolean;
|
|
26
|
+
performanceTarget: number;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Types of best practices available for prompt enhancement
|
|
30
|
+
*/
|
|
31
|
+
export type BestPracticeType = 'hyper-specific' | 'character-consistency' | 'multi-image-coordination' | 'iterative-refinement' | 'semantic-enhancement' | 'aspect-ratio-optimization' | 'camera-control-terminology';
|
|
32
|
+
/**
|
|
33
|
+
* Supported aspect ratios for image generation
|
|
34
|
+
*/
|
|
35
|
+
export type AspectRatio = '16:9' | '9:16' | '1:1' | '4:3' | '3:4';
|
|
36
|
+
/**
|
|
37
|
+
* Individual best practice item with application details
|
|
38
|
+
*/
|
|
39
|
+
export interface BestPracticeItem {
|
|
40
|
+
type: BestPracticeType;
|
|
41
|
+
applied: boolean;
|
|
42
|
+
enhancement: string;
|
|
43
|
+
metadata: {
|
|
44
|
+
processingTime: number;
|
|
45
|
+
confidence: number;
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
/**
|
|
49
|
+
* Analysis of which best practices are already present in a prompt
|
|
50
|
+
*/
|
|
51
|
+
export interface BestPracticeAnalysis {
|
|
52
|
+
existingPractices: BestPracticeType[];
|
|
53
|
+
missingPractices: BestPracticeType[];
|
|
54
|
+
overallScore: number;
|
|
55
|
+
recommendations: string[];
|
|
56
|
+
}
|
|
57
|
+
/**
|
|
58
|
+
* Enhanced prompt with applied best practices and metadata
|
|
59
|
+
*/
|
|
60
|
+
export interface EnhancedPrompt {
|
|
61
|
+
originalPrompt: string;
|
|
62
|
+
enhancedPrompt: string;
|
|
63
|
+
appliedPractices: BestPracticeItem[];
|
|
64
|
+
transformationMeta: TransformationMetadata;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Metadata about the transformation process
|
|
68
|
+
*/
|
|
69
|
+
export interface TransformationMetadata {
|
|
70
|
+
totalProcessingTime: number;
|
|
71
|
+
practicesAnalyzed: number;
|
|
72
|
+
practicesApplied: number;
|
|
73
|
+
qualityScore: number;
|
|
74
|
+
timestamp: Date;
|
|
75
|
+
}
|
|
76
|
+
/**
|
|
77
|
+
* Strategy for applying individual best practices
|
|
78
|
+
*/
|
|
79
|
+
export interface TransformationStrategy {
|
|
80
|
+
analyze(prompt: string): Promise<boolean>;
|
|
81
|
+
apply(prompt: string, options?: BestPracticesOptions): Promise<string>;
|
|
82
|
+
getMetadata(): {
|
|
83
|
+
confidence: number;
|
|
84
|
+
processingTime: number;
|
|
85
|
+
};
|
|
86
|
+
}
|
|
87
|
+
/**
|
|
88
|
+
* Interface for the Best Practices Engine
|
|
89
|
+
*/
|
|
90
|
+
export interface BestPracticesEngine {
|
|
91
|
+
/**
|
|
92
|
+
* Apply best practices to optimize a prompt for image generation
|
|
93
|
+
* @param prompt The original prompt to enhance
|
|
94
|
+
* @param options Optional configuration for practice application
|
|
95
|
+
* @returns Result containing enhanced prompt or error
|
|
96
|
+
*/
|
|
97
|
+
applyBestPractices(prompt: string, options?: BestPracticesOptions): Promise<Result<EnhancedPrompt, Error>>;
|
|
98
|
+
/**
|
|
99
|
+
* Analyze which best practices are already present in a prompt
|
|
100
|
+
* @param prompt The prompt to analyze
|
|
101
|
+
* @returns Analysis of current practice compliance
|
|
102
|
+
*/
|
|
103
|
+
analyzePracticeCompliance(prompt: string): Promise<BestPracticeAnalysis>;
|
|
104
|
+
/**
|
|
105
|
+
* Get list of available best practices and their status
|
|
106
|
+
* @returns Array of best practice items
|
|
107
|
+
*/
|
|
108
|
+
getAppliedPractices(): BestPracticeItem[];
|
|
109
|
+
}
|
|
110
|
+
/**
|
|
111
|
+
* Error for best practices engine operations
|
|
112
|
+
*/
|
|
113
|
+
export declare class BestPracticesError extends Error {
|
|
114
|
+
readonly code: string;
|
|
115
|
+
readonly details?: unknown | undefined;
|
|
116
|
+
constructor(message: string, code: string, details?: unknown | undefined);
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Factory function to create BestPracticesEngine instance
|
|
120
|
+
* @param config Optional configuration
|
|
121
|
+
* @returns BestPracticesEngine instance
|
|
122
|
+
*/
|
|
123
|
+
export declare function createBestPracticesEngine(config?: Partial<BestPracticesConfig>, geminiTextClient?: GeminiTextClient): BestPracticesEngine;
|
|
124
|
+
/**
|
|
125
|
+
* Implementation of the Best Practices Engine
|
|
126
|
+
*/
|
|
127
|
+
export declare class BestPracticesEngineImpl implements BestPracticesEngine {
|
|
128
|
+
private readonly strategies;
|
|
129
|
+
private readonly config;
|
|
130
|
+
private appliedPractices;
|
|
131
|
+
private geminiTextClient;
|
|
132
|
+
constructor(config?: Partial<BestPracticesConfig>, geminiTextClient?: GeminiTextClient);
|
|
133
|
+
applyBestPractices(prompt: string, options?: BestPracticesOptions): Promise<Result<EnhancedPrompt, Error>>;
|
|
134
|
+
analyzePracticeCompliance(prompt: string): Promise<BestPracticeAnalysis>;
|
|
135
|
+
getAppliedPractices(): BestPracticeItem[];
|
|
136
|
+
private initializeStrategies;
|
|
137
|
+
private getEnhancementDescription;
|
|
138
|
+
private calculateQualityScore;
|
|
139
|
+
private generateRecommendations;
|
|
140
|
+
/**
|
|
141
|
+
* Build AI enhancement prompt for Gemini 2.0 Flash
|
|
142
|
+
*/
|
|
143
|
+
private buildAIEnhancementPrompt;
|
|
144
|
+
/**
|
|
145
|
+
* Apply feature parameters as structured prompt instructions
|
|
146
|
+
*/
|
|
147
|
+
private applyFeatureParameters;
|
|
148
|
+
}
|
|
149
|
+
//# sourceMappingURL=bestPracticesEngine.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bestPracticesEngine.d.ts","sourceRoot":"","sources":["../../src/business/bestPracticesEngine.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAG7C;;GAEG;AACH,MAAM,WAAW,oBAAoB;IACnC,gBAAgB,CAAC,EAAE,gBAAgB,EAAE,CAAA;IACrC,WAAW,CAAC,EAAE,WAAW,CAAA;IACzB,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,aAAa,CAAC,EAAE,MAAM,CAAA;IAEtB,4BAA4B,CAAC,EAAE,OAAO,CAAA;IACtC,WAAW,CAAC,EAAE,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