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,317 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Parameter optimizer for image generation based on structured prompts
|
|
4
|
+
* Analyzes structured prompts and optimizes image generation parameters
|
|
5
|
+
*/
|
|
6
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
+
exports.ParameterOptimizerImpl = void 0;
|
|
8
|
+
const result_1 = require("../types/result");
|
|
9
|
+
const errors_1 = require("../utils/errors");
|
|
10
|
+
/**
|
|
11
|
+
* Keywords for detecting different content types
|
|
12
|
+
*/
|
|
13
|
+
const CONTENT_TYPE_KEYWORDS = {
|
|
14
|
+
portrait: ['portrait', 'headshot', 'face', 'person', 'character', 'selfie'],
|
|
15
|
+
landscape: ['landscape', 'panoramic', 'vista', 'scenery', 'horizon', 'mountains', 'valley'],
|
|
16
|
+
object: ['object', 'product', 'item', 'tool', 'device', 'still life'],
|
|
17
|
+
scene: ['scene', 'environment', 'setting', 'room', 'interior', 'exterior', 'building'],
|
|
18
|
+
abstract: ['abstract', 'conceptual', 'artistic', 'pattern', 'texture', 'geometric'],
|
|
19
|
+
};
|
|
20
|
+
/**
|
|
21
|
+
* Keywords for detecting complexity levels
|
|
22
|
+
*/
|
|
23
|
+
const COMPLEXITY_KEYWORDS = {
|
|
24
|
+
simple: ['simple', 'minimal', 'clean', 'basic'],
|
|
25
|
+
complex: ['detailed', 'intricate', 'complex', 'elaborate', 'ornate', 'sophisticated'],
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* Keywords for detecting cinematic content
|
|
29
|
+
*/
|
|
30
|
+
const CINEMATIC_KEYWORDS = [
|
|
31
|
+
'cinematic',
|
|
32
|
+
'wide-angle',
|
|
33
|
+
'dramatic',
|
|
34
|
+
'professional photography',
|
|
35
|
+
'film',
|
|
36
|
+
'movie',
|
|
37
|
+
'camera angle',
|
|
38
|
+
'shot',
|
|
39
|
+
'lighting',
|
|
40
|
+
'composition',
|
|
41
|
+
];
|
|
42
|
+
/**
|
|
43
|
+
* Keywords for detecting character features
|
|
44
|
+
*/
|
|
45
|
+
const CHARACTER_KEYWORDS = [
|
|
46
|
+
'eyes',
|
|
47
|
+
'hair',
|
|
48
|
+
'face',
|
|
49
|
+
'facial features',
|
|
50
|
+
'expression',
|
|
51
|
+
'character',
|
|
52
|
+
'person',
|
|
53
|
+
];
|
|
54
|
+
/**
|
|
55
|
+
* Implementation of parameter optimization based on structured prompt analysis
|
|
56
|
+
*/
|
|
57
|
+
class ParameterOptimizerImpl {
|
|
58
|
+
/**
|
|
59
|
+
* Optimize parameters based on structured prompt analysis
|
|
60
|
+
*/
|
|
61
|
+
async optimizeForStructuredPrompt(structuredPrompt, baseParams) {
|
|
62
|
+
try {
|
|
63
|
+
const characteristics = this.analyzePromptCharacteristics(structuredPrompt);
|
|
64
|
+
const optimizationReasons = [];
|
|
65
|
+
// Start with base parameters
|
|
66
|
+
const optimized = {
|
|
67
|
+
...baseParams,
|
|
68
|
+
optimizationReasons,
|
|
69
|
+
};
|
|
70
|
+
// Optimize aspect ratio based on content type
|
|
71
|
+
if (!baseParams.aspectRatio ||
|
|
72
|
+
this.shouldOptimizeAspectRatio(characteristics, baseParams.aspectRatio)) {
|
|
73
|
+
optimized.aspectRatio = characteristics.suggestedAspectRatio;
|
|
74
|
+
optimizationReasons.push(`aspect ratio optimized for ${characteristics.contentType} content`);
|
|
75
|
+
}
|
|
76
|
+
else {
|
|
77
|
+
optimizationReasons.push('aspect ratio preserved - appropriate for content');
|
|
78
|
+
}
|
|
79
|
+
// Optimize quality based on complexity and content requirements
|
|
80
|
+
if (this.shouldUpgradeQuality(characteristics, baseParams.quality)) {
|
|
81
|
+
optimized.quality = characteristics.suggestedQuality;
|
|
82
|
+
optimizationReasons.push(`quality upgraded for ${characteristics.complexity} content`);
|
|
83
|
+
}
|
|
84
|
+
// Optimize style based on prompt analysis
|
|
85
|
+
// Only change style if no style was specified in baseParams
|
|
86
|
+
if (baseParams.style) {
|
|
87
|
+
// Keep the explicitly provided style
|
|
88
|
+
optimized.style = baseParams.style;
|
|
89
|
+
optimizationReasons.push('style preserved - explicitly provided');
|
|
90
|
+
}
|
|
91
|
+
else if (this.shouldOptimizeStyle(characteristics, baseParams.style)) {
|
|
92
|
+
optimized.style = characteristics.suggestedStyle;
|
|
93
|
+
optimizationReasons.push('style optimized for detected content characteristics');
|
|
94
|
+
}
|
|
95
|
+
// Apply feature recommendations
|
|
96
|
+
if (characteristics.recommendedFeatures.maintainCharacterConsistency &&
|
|
97
|
+
!baseParams.maintainCharacterConsistency) {
|
|
98
|
+
optimized.maintainCharacterConsistency = true;
|
|
99
|
+
optimizationReasons.push('character features detected - enabled consistency maintenance');
|
|
100
|
+
}
|
|
101
|
+
if (characteristics.recommendedFeatures.blendImages && !baseParams.blendImages) {
|
|
102
|
+
optimized.blendImages = true;
|
|
103
|
+
optimizationReasons.push('multiple elements detected - enabled blending');
|
|
104
|
+
}
|
|
105
|
+
if (characteristics.recommendedFeatures.useWorldKnowledge && !baseParams.useWorldKnowledge) {
|
|
106
|
+
optimized.useWorldKnowledge = true;
|
|
107
|
+
optimizationReasons.push('world knowledge requirements detected');
|
|
108
|
+
}
|
|
109
|
+
// Add cinematic optimization if detected
|
|
110
|
+
if (this.detectsCinematicContent(structuredPrompt)) {
|
|
111
|
+
optimizationReasons.push('cinematic composition detected');
|
|
112
|
+
if (optimized.aspectRatio === '1:1') {
|
|
113
|
+
optimized.aspectRatio = '16:9';
|
|
114
|
+
optimizationReasons.push('aspect ratio adjusted for cinematic content');
|
|
115
|
+
}
|
|
116
|
+
}
|
|
117
|
+
// Add macro photography detection
|
|
118
|
+
if (this.detectsMacroContent(structuredPrompt)) {
|
|
119
|
+
optimized.quality = 'high';
|
|
120
|
+
optimized.style = 'enhanced';
|
|
121
|
+
optimizationReasons.push('macro photography detected - enhanced quality and detail');
|
|
122
|
+
}
|
|
123
|
+
return (0, result_1.Ok)(optimized);
|
|
124
|
+
}
|
|
125
|
+
catch (error) {
|
|
126
|
+
return (0, result_1.Err)(new errors_1.GeminiAPIError(`Parameter optimization failed: ${error instanceof Error ? error.message : 'Unknown error'}`, 'Check prompt format and try again'));
|
|
127
|
+
}
|
|
128
|
+
}
|
|
129
|
+
/**
|
|
130
|
+
* Analyze prompt characteristics for optimization
|
|
131
|
+
*/
|
|
132
|
+
analyzePromptCharacteristics(prompt) {
|
|
133
|
+
const lowerPrompt = prompt.toLowerCase();
|
|
134
|
+
// Detect content type
|
|
135
|
+
const contentType = this.detectContentType(lowerPrompt);
|
|
136
|
+
// Detect complexity
|
|
137
|
+
const complexity = this.detectComplexity(lowerPrompt);
|
|
138
|
+
// Generate suggestions based on analysis
|
|
139
|
+
const suggestedAspectRatio = this.suggestAspectRatio(contentType, lowerPrompt);
|
|
140
|
+
const suggestedQuality = this.suggestQuality(complexity, lowerPrompt);
|
|
141
|
+
const suggestedStyle = this.suggestStyle(lowerPrompt);
|
|
142
|
+
// Extract detected elements
|
|
143
|
+
const detectedElements = this.extractElements(lowerPrompt);
|
|
144
|
+
// Recommend features based on content
|
|
145
|
+
const recommendedFeatures = this.recommendFeatures(lowerPrompt);
|
|
146
|
+
return {
|
|
147
|
+
complexity,
|
|
148
|
+
contentType,
|
|
149
|
+
suggestedAspectRatio,
|
|
150
|
+
suggestedQuality,
|
|
151
|
+
suggestedStyle,
|
|
152
|
+
detectedElements,
|
|
153
|
+
recommendedFeatures,
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Detect content type from prompt
|
|
158
|
+
*/
|
|
159
|
+
detectContentType(prompt) {
|
|
160
|
+
for (const [type, keywords] of Object.entries(CONTENT_TYPE_KEYWORDS)) {
|
|
161
|
+
if (keywords.some((keyword) => prompt.includes(keyword))) {
|
|
162
|
+
return type;
|
|
163
|
+
}
|
|
164
|
+
}
|
|
165
|
+
return 'scene'; // Default fallback
|
|
166
|
+
}
|
|
167
|
+
/**
|
|
168
|
+
* Detect complexity level
|
|
169
|
+
*/
|
|
170
|
+
detectComplexity(prompt) {
|
|
171
|
+
const simpleScore = COMPLEXITY_KEYWORDS.simple.filter((keyword) => prompt.includes(keyword)).length;
|
|
172
|
+
const complexScore = COMPLEXITY_KEYWORDS.complex.filter((keyword) => prompt.includes(keyword)).length;
|
|
173
|
+
if (complexScore > simpleScore)
|
|
174
|
+
return 'complex';
|
|
175
|
+
if (simpleScore > complexScore)
|
|
176
|
+
return 'simple';
|
|
177
|
+
return 'medium';
|
|
178
|
+
}
|
|
179
|
+
/**
|
|
180
|
+
* Suggest optimal aspect ratio based on content type
|
|
181
|
+
*/
|
|
182
|
+
suggestAspectRatio(contentType, prompt) {
|
|
183
|
+
// Check for specific aspect ratio hints in prompt
|
|
184
|
+
if (prompt.includes('panoramic') || prompt.includes('wide'))
|
|
185
|
+
return '21:9';
|
|
186
|
+
if (prompt.includes('cinematic'))
|
|
187
|
+
return '16:9';
|
|
188
|
+
if (prompt.includes('square') || prompt.includes('instagram'))
|
|
189
|
+
return '1:1';
|
|
190
|
+
// Default based on content type
|
|
191
|
+
switch (contentType) {
|
|
192
|
+
case 'portrait':
|
|
193
|
+
return '3:4';
|
|
194
|
+
case 'landscape':
|
|
195
|
+
return '16:9';
|
|
196
|
+
case 'object':
|
|
197
|
+
return '1:1';
|
|
198
|
+
case 'scene':
|
|
199
|
+
return '16:9';
|
|
200
|
+
case 'abstract':
|
|
201
|
+
return '1:1';
|
|
202
|
+
default:
|
|
203
|
+
return '16:9';
|
|
204
|
+
}
|
|
205
|
+
}
|
|
206
|
+
/**
|
|
207
|
+
* Suggest quality level based on complexity and requirements
|
|
208
|
+
*/
|
|
209
|
+
suggestQuality(complexity, prompt) {
|
|
210
|
+
if (prompt.includes('high detail') ||
|
|
211
|
+
prompt.includes('professional') ||
|
|
212
|
+
prompt.includes('macro')) {
|
|
213
|
+
return 'high';
|
|
214
|
+
}
|
|
215
|
+
if (prompt.includes('sketch') || prompt.includes('rough') || prompt.includes('simple')) {
|
|
216
|
+
return 'medium';
|
|
217
|
+
}
|
|
218
|
+
return complexity === 'complex' ? 'high' : 'medium';
|
|
219
|
+
}
|
|
220
|
+
/**
|
|
221
|
+
* Suggest style based on prompt content
|
|
222
|
+
*/
|
|
223
|
+
suggestStyle(prompt) {
|
|
224
|
+
if (prompt.includes('artistic') || prompt.includes('creative') || prompt.includes('stylized')) {
|
|
225
|
+
return 'artistic';
|
|
226
|
+
}
|
|
227
|
+
if (prompt.includes('enhanced') ||
|
|
228
|
+
prompt.includes('detailed') ||
|
|
229
|
+
prompt.includes('professional')) {
|
|
230
|
+
return 'enhanced';
|
|
231
|
+
}
|
|
232
|
+
return 'natural';
|
|
233
|
+
}
|
|
234
|
+
/**
|
|
235
|
+
* Extract key elements from prompt
|
|
236
|
+
*/
|
|
237
|
+
extractElements(prompt) {
|
|
238
|
+
const elements = [];
|
|
239
|
+
// Simple element extraction - can be enhanced with NLP
|
|
240
|
+
const elementPatterns = [
|
|
241
|
+
/\b(lighting|light)\b/g,
|
|
242
|
+
/\b(color|colours?)\b/g,
|
|
243
|
+
/\b(texture|textures?)\b/g,
|
|
244
|
+
/\b(composition)\b/g,
|
|
245
|
+
/\b(atmosphere|mood)\b/g,
|
|
246
|
+
/\b(details?)\b/g,
|
|
247
|
+
];
|
|
248
|
+
for (const pattern of elementPatterns) {
|
|
249
|
+
const matches = prompt.match(pattern);
|
|
250
|
+
if (matches) {
|
|
251
|
+
elements.push(...matches);
|
|
252
|
+
}
|
|
253
|
+
}
|
|
254
|
+
return [...new Set(elements)]; // Remove duplicates
|
|
255
|
+
}
|
|
256
|
+
/**
|
|
257
|
+
* Recommend features based on prompt analysis
|
|
258
|
+
*/
|
|
259
|
+
recommendFeatures(prompt) {
|
|
260
|
+
return {
|
|
261
|
+
blendImages: prompt.includes('blend') || prompt.includes('combine') || prompt.includes('merge'),
|
|
262
|
+
maintainCharacterConsistency: CHARACTER_KEYWORDS.some((keyword) => prompt.includes(keyword)),
|
|
263
|
+
useWorldKnowledge: prompt.includes('historical') || prompt.includes('real') || prompt.includes('accurate'),
|
|
264
|
+
};
|
|
265
|
+
}
|
|
266
|
+
/**
|
|
267
|
+
* Check if aspect ratio should be optimized
|
|
268
|
+
*/
|
|
269
|
+
shouldOptimizeAspectRatio(characteristics, currentRatio) {
|
|
270
|
+
if (!currentRatio)
|
|
271
|
+
return true;
|
|
272
|
+
// Don't optimize if current ratio matches suggestion
|
|
273
|
+
if (currentRatio === characteristics.suggestedAspectRatio)
|
|
274
|
+
return false;
|
|
275
|
+
// Optimize if current ratio is clearly inappropriate for content type
|
|
276
|
+
if (characteristics.contentType === 'portrait' &&
|
|
277
|
+
(currentRatio === '16:9' || currentRatio === '21:9')) {
|
|
278
|
+
return true;
|
|
279
|
+
}
|
|
280
|
+
if (characteristics.contentType === 'landscape' && currentRatio === '3:4') {
|
|
281
|
+
return true;
|
|
282
|
+
}
|
|
283
|
+
return false;
|
|
284
|
+
}
|
|
285
|
+
/**
|
|
286
|
+
* Check if quality should be upgraded
|
|
287
|
+
*/
|
|
288
|
+
shouldUpgradeQuality(characteristics, currentQuality) {
|
|
289
|
+
return (characteristics.suggestedQuality === 'high' &&
|
|
290
|
+
(currentQuality === 'low' || currentQuality === 'medium'));
|
|
291
|
+
}
|
|
292
|
+
/**
|
|
293
|
+
* Check if style should be optimized
|
|
294
|
+
*/
|
|
295
|
+
shouldOptimizeStyle(characteristics, currentStyle) {
|
|
296
|
+
return !currentStyle || currentStyle !== characteristics.suggestedStyle;
|
|
297
|
+
}
|
|
298
|
+
/**
|
|
299
|
+
* Detect cinematic content
|
|
300
|
+
*/
|
|
301
|
+
detectsCinematicContent(prompt) {
|
|
302
|
+
const lowerPrompt = prompt.toLowerCase();
|
|
303
|
+
return CINEMATIC_KEYWORDS.some((keyword) => lowerPrompt.includes(keyword));
|
|
304
|
+
}
|
|
305
|
+
/**
|
|
306
|
+
* Detect macro photography content
|
|
307
|
+
*/
|
|
308
|
+
detectsMacroContent(prompt) {
|
|
309
|
+
const lowerPrompt = prompt.toLowerCase();
|
|
310
|
+
return (lowerPrompt.includes('macro') ||
|
|
311
|
+
lowerPrompt.includes('close-up') ||
|
|
312
|
+
lowerPrompt.includes('extreme close-up') ||
|
|
313
|
+
lowerPrompt.includes('detailed texture'));
|
|
314
|
+
}
|
|
315
|
+
}
|
|
316
|
+
exports.ParameterOptimizerImpl = ParameterOptimizerImpl;
|
|
317
|
+
//# sourceMappingURL=parameterOptimizer.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"parameterOptimizer.js","sourceRoot":"","sources":["../../src/integration/parameterOptimizer.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;AAGH,4CAAyC;AAOzC,4CAAgD;AAEhD;;GAEG;AACH,MAAM,qBAAqB,GAAG;IAC5B,QAAQ,EAAE,CAAC,UAAU,EAAE,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,WAAW,EAAE,QAAQ,CAAC;IAC3E,SAAS,EAAE,CAAC,WAAW,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,SAAS,EAAE,WAAW,EAAE,QAAQ,CAAC;IAC3F,MAAM,EAAE,CAAC,QAAQ,EAAE,SAAS,EAAE,MAAM,EAAE,MAAM,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KAAK,eAAe,CAAC,cAAc,CAAA;IACzE,CAAC;IAED;;OAEG;IACK,uBAAuB,CAAC,MAAc;QAC5C,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;QACxC,OAAO,kBAAkB,CAAC,IAAI,CAAC,CAAC,OAAO,EAAE,EAAE,CAAC,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,CAAA;IAC5E,CAAC;IAED;;OAEG;IACK,mBAAmB,CAAC,MAAc;QACxC,MAAM,WAAW,GAAG,MAAM,CAAC,WAAW,EAAE,CAAA;QACxC,OAAO,CACL,WAAW,CAAC,QAAQ,CAAC,OAAO,CAAC;YAC7B,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC;YAChC,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC;YACxC,WAAW,CAAC,QAAQ,CAAC,kBAAkB,CAAC,CACzC,CAAA;IACH,CAAC;CACF;AA3UD,wDA2UC"}
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* TwoStageProcessor - Main integration point for 2-stage processing
|
|
3
|
+
* Coordinates structured prompt generation with image generation
|
|
4
|
+
* Implements complete workflow with performance tracking and fallback strategies
|
|
5
|
+
*/
|
|
6
|
+
import type { GeminiClient } from '../api/geminiClient';
|
|
7
|
+
import type { StructuredPromptOrchestrator } from '../business/promptOrchestrator';
|
|
8
|
+
import type { Result } from '../types/result';
|
|
9
|
+
import type { ImageGenerationRequest, ImageParameters, OptimizedParameters, ProcessingMetadata, TwoStageProcessor, TwoStageProcessorOptions, TwoStageResult } from '../types/twoStageTypes';
|
|
10
|
+
import { GeminiAPIError, NetworkError } from '../utils/errors';
|
|
11
|
+
/**
|
|
12
|
+
* Implementation of TwoStageProcessor with complete workflow coordination
|
|
13
|
+
*/
|
|
14
|
+
export declare class TwoStageProcessorImpl implements TwoStageProcessor {
|
|
15
|
+
private orchestrator;
|
|
16
|
+
private imageClient;
|
|
17
|
+
private options;
|
|
18
|
+
private metadataManager;
|
|
19
|
+
private parameterOptimizer;
|
|
20
|
+
constructor(orchestrator: StructuredPromptOrchestrator, imageClient: GeminiClient, options?: TwoStageProcessorOptions);
|
|
21
|
+
/**
|
|
22
|
+
* Generate image using complete 2-stage workflow
|
|
23
|
+
*/
|
|
24
|
+
generateImageWithStructuredPrompt(request: ImageGenerationRequest): Promise<Result<TwoStageResult, GeminiAPIError | NetworkError>>;
|
|
25
|
+
/**
|
|
26
|
+
* Execute the main processing workflow
|
|
27
|
+
*/
|
|
28
|
+
private executeProcessingWorkflow;
|
|
29
|
+
/**
|
|
30
|
+
* Optimize image parameters based on structured prompt
|
|
31
|
+
*/
|
|
32
|
+
optimizeImageParameters(structuredPrompt: string, baseParams: ImageParameters): Promise<Result<OptimizedParameters, GeminiAPIError>>;
|
|
33
|
+
/**
|
|
34
|
+
* Get processing metadata for a session
|
|
35
|
+
*/
|
|
36
|
+
getProcessingMetadata(sessionId: string): ProcessingMetadata | undefined;
|
|
37
|
+
/**
|
|
38
|
+
* Validate processor configuration
|
|
39
|
+
*/
|
|
40
|
+
validateConfiguration(): Promise<Result<boolean, GeminiAPIError>>;
|
|
41
|
+
/**
|
|
42
|
+
* Execute Stage 1: Structured Prompt Generation
|
|
43
|
+
*/
|
|
44
|
+
private executePromptGenerationStage;
|
|
45
|
+
/**
|
|
46
|
+
* Execute Stage 2: Image Generation
|
|
47
|
+
*/
|
|
48
|
+
private executeImageGenerationStage;
|
|
49
|
+
/**
|
|
50
|
+
* Handle fallback scenario when primary processing fails
|
|
51
|
+
*/
|
|
52
|
+
private handleFallbackScenario;
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* Factory for creating TwoStageProcessor instances with dependency injection
|
|
56
|
+
*/
|
|
57
|
+
export declare class TwoStageProcessorFactory {
|
|
58
|
+
private orchestrator;
|
|
59
|
+
private imageClient;
|
|
60
|
+
constructor(orchestrator: StructuredPromptOrchestrator, imageClient: GeminiClient);
|
|
61
|
+
/**
|
|
62
|
+
* Create a new TwoStageProcessor instance
|
|
63
|
+
*/
|
|
64
|
+
create(options?: Partial<TwoStageProcessorOptions>): TwoStageProcessor;
|
|
65
|
+
}
|
|
66
|
+
//# sourceMappingURL=twoStageProcessor.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"twoStageProcessor.d.ts","sourceRoot":"","sources":["../../src/integration/twoStageProcessor.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAmB,YAAY,EAAE,MAAM,qBAAqB,CAAA;AACxE,OAAO,KAAK,EAGV,4BAA4B,EAC7B,MAAM,gCAAgC,CAAA;AAEvC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAE7C,OAAO,KAAK,EACV,sBAAsB,EACtB,eAAe,EACf,mBAAmB,EAEnB,kBAAkB,EAClB,iBAAiB,EACjB,wBAAwB,EACxB,cAAc,EACf,MAAM,wBAAwB,CAAA;AAC/B,OAAO,EAAE,cAAc,EAAE,YAAY,EAAE,MAAM,iBAAiB,CAAA;AAc9D;;GAEG;AACH,qBAAa,qBAAsB,YAAW,iBAAiB;IAK3D,OAAO,CAAC,YAAY;IACpB,OAAO,CAAC,WAAW;IACnB,OAAO,CAAC,OAAO;IANjB,OAAO,CAAC,eAAe,CAA2B;IAClD,OAAO,CAAC,kBAAkB,CAAoB;gBAGpC,YAAY,EAAE,4BAA4B,EAC1C,WAAW,EAAE,YAAY,EACzB,OAAO,GAAE,wBAA0C;IAM7D;;OAEG;IACG,iCAAiC,CACrC,OAAO,EAAE,sBAAsB,GAC9B,OAAO,CAAC,MAAM,CAAC,cAAc,EAAE,cAAc,GAAG,YAAY,CAAC,CAAC;IAyCjE;;OAEG;YACW,yBAAyB;IAyFvC;;OAEG;IACG,uBAAuB,CAC3B,gBAAgB,EAAE,MAAM,EACxB,UAAU,EAAE,eAAe,GAC1B,OAAO,CAAC,MAAM,CAAC,mBAAmB,EAAE,cAAc,CAAC,CAA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