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
|
@@ -8,6 +8,7 @@ exports.createImageGenerator = createImageGenerator;
|
|
|
8
8
|
const result_1 = require("../types/result");
|
|
9
9
|
const errors_1 = require("../utils/errors");
|
|
10
10
|
const inputValidator_1 = require("./inputValidator");
|
|
11
|
+
const logger_1 = require("../utils/logger");
|
|
11
12
|
const MODEL_NAME = 'gemini-2.5-flash-image-preview';
|
|
12
13
|
/**
|
|
13
14
|
* Validates input parameters using the validation module
|
|
@@ -43,16 +44,16 @@ function validateInput(params) {
|
|
|
43
44
|
/**
|
|
44
45
|
* Executes the Gemini API call with proper error handling
|
|
45
46
|
*/
|
|
46
|
-
async function executeApiCall(geminiClient, params) {
|
|
47
|
+
async function executeApiCall(geminiClient, params, logger) {
|
|
47
48
|
try {
|
|
48
49
|
const apiParams = {
|
|
49
50
|
prompt: params.prompt,
|
|
50
51
|
};
|
|
51
|
-
// Add input image if provided
|
|
52
|
+
// Add input image if provided (pass base64 string directly)
|
|
52
53
|
if (params.inputImage) {
|
|
53
|
-
//
|
|
54
|
+
// Clean the base64 data and pass directly to API
|
|
54
55
|
const cleanedData = params.inputImage.replace(/^data:image\/[a-z]+;base64,/, '');
|
|
55
|
-
apiParams.inputImage =
|
|
56
|
+
apiParams.inputImage = cleanedData;
|
|
56
57
|
}
|
|
57
58
|
// Add new feature parameters if provided
|
|
58
59
|
if (params.blendImages !== undefined) {
|
|
@@ -66,6 +67,16 @@ async function executeApiCall(geminiClient, params) {
|
|
|
66
67
|
}
|
|
67
68
|
const apiResult = await geminiClient.generateImage(apiParams);
|
|
68
69
|
if (!apiResult.success) {
|
|
70
|
+
logger.error('ImageGenerator:API', 'Gemini API call failed', apiResult.error, {
|
|
71
|
+
promptLength: params.prompt.length,
|
|
72
|
+
hasInputImage: !!params.inputImage,
|
|
73
|
+
apiParams: {
|
|
74
|
+
blendImages: apiParams.blendImages,
|
|
75
|
+
maintainCharacterConsistency: apiParams.maintainCharacterConsistency,
|
|
76
|
+
useWorldKnowledge: apiParams.useWorldKnowledge,
|
|
77
|
+
hasInputImage: !!apiParams.inputImage
|
|
78
|
+
}
|
|
79
|
+
});
|
|
69
80
|
return (0, result_1.Err)(apiResult.error);
|
|
70
81
|
}
|
|
71
82
|
return (0, result_1.Ok)({ imageData: apiResult.data.imageData });
|
|
@@ -115,6 +126,7 @@ function handleUnexpectedError(error) {
|
|
|
115
126
|
* @returns ImageGenerator implementation
|
|
116
127
|
*/
|
|
117
128
|
function createImageGenerator(geminiClient) {
|
|
129
|
+
const logger = new logger_1.Logger();
|
|
118
130
|
return {
|
|
119
131
|
/**
|
|
120
132
|
* Generates an image from a text prompt with optional URL context processing
|
|
@@ -123,6 +135,11 @@ function createImageGenerator(geminiClient) {
|
|
|
123
135
|
*/
|
|
124
136
|
async generateImage(params) {
|
|
125
137
|
const startTime = Date.now();
|
|
138
|
+
// Log received prompt for debugging
|
|
139
|
+
logger.debug('ImageGenerator', 'received prompt', {
|
|
140
|
+
promptLength: params.prompt.length,
|
|
141
|
+
hasInputImage: !!params.inputImage
|
|
142
|
+
});
|
|
126
143
|
// Step 1: Validate input parameters
|
|
127
144
|
const validationResult = validateInput(params);
|
|
128
145
|
if (!validationResult.success) {
|
|
@@ -130,7 +147,11 @@ function createImageGenerator(geminiClient) {
|
|
|
130
147
|
}
|
|
131
148
|
const validatedParams = validationResult.data;
|
|
132
149
|
// Step 2: Execute API call (URL Context is handled automatically by GeminiClient)
|
|
133
|
-
|
|
150
|
+
// Log prompt before passing to geminiClient
|
|
151
|
+
logger.debug('ImageGenerator', 'passing prompt to geminiClient', {
|
|
152
|
+
promptLength: params.prompt.length
|
|
153
|
+
});
|
|
154
|
+
const apiResult = await executeApiCall(geminiClient, params, logger);
|
|
134
155
|
if (!apiResult.success) {
|
|
135
156
|
return (0, result_1.Err)(apiResult.error);
|
|
136
157
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"imageGenerator.js","sourceRoot":"","sources":["../../src/business/imageGenerator.ts"],"names":[],"mappings":";AAAA;;;GAGG;;
|
|
1
|
+
{"version":3,"file":"imageGenerator.js","sourceRoot":"","sources":["../../src/business/imageGenerator.ts"],"names":[],"mappings":";AAAA;;;GAGG;;AAmOH,oDAqDC;AAnRD,4CAAyC;AACzC,4CAKwB;AACxB,qDAAsE;AACtE,4CAAwC;AA+DxC,MAAM,UAAU,GAAG,gCAAyC,CAAA;AAE5D;;GAEG;AACH,SAAS,aAAa,CACpB,MAA4B;IAE5B,kBAAkB;IAClB,MAAM,YAAY,GAAG,IAAA,+BAAc,EAAC,MAAM,CAAC,MAAM,CAAC,CAAA;IAClD,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAC;QAC1B,OAAO,IAAA,YAAG,EAAC,YAAY,CAAC,KAAK,CAAC,CAAA;IAChC,CAAC;IAED,mCAAmC;IACnC,IAAI,MAAM,CAAC,UAAU,EAAE,CAAC;QACtB,MAAM,WAAW,GAAG,IAAA,oCAAmB,EAAC,MAAM,CAAC,UAAU,EAAE,MAAM,CAAC,kBAAkB,CAAC,CAAA;QACrF,IAAI,CAAC,WAAW,CAAC,OAAO,EAAE,CAAC;YACzB,OAAO,IAAA,YAAG,EAAC,WAAW,CAAC,KAAK,CAAC,CA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EAAE,iBAAiB,EAAE;gBAChD,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM;gBAClC,aAAa,EAAE,CAAC,CAAC,MAAM,CAAC,UAAU;aACnC,CAAC,CAAA;YAEF,oCAAoC;YACpC,MAAM,gBAAgB,GAAG,aAAa,CAAC,MAAM,CAAC,CAAA;YAC9C,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAC;gBAC9B,OAAO,IAAA,YAAG,EAAC,gBAAgB,CAAC,KAAK,CAAC,CAAA;YACpC,CAAC;YACD,MAAM,eAAe,GAAG,gBAAgB,CAAC,IAAI,CAAA;YAE7C,kFAAkF;YAClF,4CAA4C;YAC5C,MAAM,CAAC,KAAK,CAAC,gBAAgB,EAAE,gCAAgC,EAAE;gBAC/D,YAAY,EAAE,MAAM,CAAC,MAAM,CAAC,MAAM;aACnC,CAAC,CAAA;YAEF,MAAM,SAAS,GAAG,MAAM,cAAc,CAAC,YAAY,EAAE,MAAM,EAAE,MAAM,CAAC,CAAA;YACpE,IAAI,CAAC,SAAS,CAAC,OAAO,EAAE,CAAC;gBACvB,OAAO,IAAA,YAAG,EAAC,SAAS,CAAC,KAAK,CAAC,CAAA;YAC7B,CAAC;YAED,8CAA8C;YAC9C,MAAM,cAAc,GAAG,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC,CAAA;YAC1D,MAAM,QAAQ,GAAG,gBAAgB,CAAC,cAAc,EAAE,eAAe,CAAC,CAAA;YAElE,OAAO,IAAA,WAAE,EAAC;gBACR,SAAS,EAAE,SAAS,CAAC,IAAI,CAAC,SAAS;gBACnC,QAAQ;aACT,CAAC,CAAA;QACJ,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* AspectRatioController - Intelligent aspect ratio optimization for multi-image processing
|
|
3
|
+
* Supports adaptive, uniform, content-driven, and last-image strategies
|
|
4
|
+
*/
|
|
5
|
+
import { type AspectRatio, type AspectRatioController, AspectRatioStrategy, type ContentAnalysis, type ImageRequirement, type OptimizedAspectRatios } from '../../types/multiImageTypes';
|
|
6
|
+
import type { Result } from '../../types/result';
|
|
7
|
+
import { GeminiAPIError } from '../../utils/errors';
|
|
8
|
+
/**
|
|
9
|
+
* Implementation of AspectRatioController with intelligent optimization strategies
|
|
10
|
+
*/
|
|
11
|
+
export declare class AspectRatioControllerImpl implements AspectRatioController {
|
|
12
|
+
/**
|
|
13
|
+
* Optimize aspect ratios for multiple image requirements based on strategy
|
|
14
|
+
*/
|
|
15
|
+
optimizeAspectRatios(requirements: ImageRequirement[], strategy: AspectRatioStrategy): Promise<Result<OptimizedAspectRatios, GeminiAPIError>>;
|
|
16
|
+
/**
|
|
17
|
+
* Analyze content to determine optimal aspect ratio
|
|
18
|
+
*/
|
|
19
|
+
analyzeContentForAspectRatio(prompt: string): Promise<Result<ContentAnalysis, GeminiAPIError>>;
|
|
20
|
+
/**
|
|
21
|
+
* Select optimal aspect ratio based on content analysis
|
|
22
|
+
*/
|
|
23
|
+
selectOptimalRatio(analysis: ContentAnalysis): AspectRatio;
|
|
24
|
+
/**
|
|
25
|
+
* Adaptive optimization - choose best ratio for each image individually
|
|
26
|
+
*/
|
|
27
|
+
private adaptiveOptimization;
|
|
28
|
+
/**
|
|
29
|
+
* Uniform optimization - use same ratio for all images
|
|
30
|
+
*/
|
|
31
|
+
private uniformOptimization;
|
|
32
|
+
/**
|
|
33
|
+
* Content-driven optimization - detailed content analysis for each image
|
|
34
|
+
*/
|
|
35
|
+
private contentDrivenOptimization;
|
|
36
|
+
/**
|
|
37
|
+
* Last image optimization - use aspect ratio from the last uploaded/specified image
|
|
38
|
+
*/
|
|
39
|
+
private lastImageOptimization;
|
|
40
|
+
/**
|
|
41
|
+
* Default optimization - balanced approach
|
|
42
|
+
*/
|
|
43
|
+
private defaultOptimization;
|
|
44
|
+
/**
|
|
45
|
+
* Detect primary subject type from prompt
|
|
46
|
+
*/
|
|
47
|
+
private detectPrimarySubject;
|
|
48
|
+
/**
|
|
49
|
+
* Determine composition orientation from prompt and subject
|
|
50
|
+
*/
|
|
51
|
+
private determineComposition;
|
|
52
|
+
/**
|
|
53
|
+
* Extract relevant elements from prompt
|
|
54
|
+
*/
|
|
55
|
+
private extractElements;
|
|
56
|
+
/**
|
|
57
|
+
* Generate rationale for aspect ratio selection
|
|
58
|
+
*/
|
|
59
|
+
private generateRationale;
|
|
60
|
+
/**
|
|
61
|
+
* Calculate confidence score for content analysis
|
|
62
|
+
*/
|
|
63
|
+
private calculateConfidenceScore;
|
|
64
|
+
/**
|
|
65
|
+
* Calculate confidence score for uniform optimization
|
|
66
|
+
*/
|
|
67
|
+
private calculateUniformConfidenceScore;
|
|
68
|
+
/**
|
|
69
|
+
* Calculate confidence score for content-driven optimization
|
|
70
|
+
*/
|
|
71
|
+
private calculateContentDrivenConfidence;
|
|
72
|
+
/**
|
|
73
|
+
* Calculate overall coherence of optimizations
|
|
74
|
+
*/
|
|
75
|
+
private calculateOverallCoherence;
|
|
76
|
+
}
|
|
77
|
+
//# sourceMappingURL=aspectRatioController.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"aspectRatioController.d.ts","sourceRoot":"","sources":["../../../src/business/multiImage/aspectRatioController.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EACL,KAAK,WAAW,EAChB,KAAK,qBAAqB,EAE1B,mBAAmB,EACnB,KAAK,eAAe,EACpB,KAAK,gBAAgB,EACrB,KAAK,qBAAqB,EAC3B,MAAM,6BAA6B,CAAA;AACpC,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,oBAAoB,CAAA;AAEhD,OAAO,EAAE,cAAc,EAAE,MAAM,oBAAoB,CAAA;AAqCnD;;GAEG;AACH,qBAAa,yBAA0B,YAAW,qBAAqB;IACrE;;OAEG;IACG,oBAAoB,CACxB,YAAY,EAAE,gBAAgB,EAAE,EAChC,QAAQ,EAAE,mBAAmB,GAC5B,OAAO,CAAC,MAAM,CAAC,qBAAqB,EAAE,cAAc,CAAC,CAAC;IA4CzD;;OAEG;IACG,4BAA4B,CAChC,MAAM,EAAE,MAAM,GACb,OAAO,CAAC,MAAM,CAAC,eAAe,EAAE,cAAc,CAAC,CAAC;IA8BnD;;OAEG;IACH,kBAAkB,CAAC,QAAQ,EAAE,eAAe,GAAG,WAAW;IAsB1D;;OAEG;YACW,oBAAoB;IAwElC;;OAEG;YACW,mBAAmB;IA+DjC;;OAEG;YACW,yBAAyB;IAwDvC;;OAEG;YACW,qBAAqB;IAuDnC;;OAEG;YACW,mBAAmB;IA4BjC;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAwD5B;;OAEG;IACH,OAAO,CAAC,oBAAoB;IAqD5B;;OAEG;IACH,OAAO,CAAC,eAAe;IAoDvB;;OAEG;IACH,OAAO,CAAC,iBAAiB;IAczB;;OAEG;IACH,OAAO,CAAC,wBAAwB;IAqBhC;;OAEG;IACH,OAAO,CAAC,+BAA+B;IAqBvC;;OAEG;IACH,OAAO,CAAC,gCAAgC;IAwBxC;;OAEG;IACH,OAAO,CAAC,yBAAyB;CAiBlC"}
|