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,490 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Structured Prompt Orchestrator - Coordinates 2-stage processing orchestration
|
|
4
|
+
* Integrates GeminiTextClient, BestPracticesEngine, and POMLTemplateEngine
|
|
5
|
+
* Manages complete structured prompt generation workflow with fallback strategies
|
|
6
|
+
*/
|
|
7
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
8
|
+
exports.StructuredPromptOrchestratorImpl = void 0;
|
|
9
|
+
const OrchestrationMetrics_1 = require("../infrastructure/monitoring/OrchestrationMetrics");
|
|
10
|
+
const alertingSystem_1 = require("../infrastructure/monitoring/alertingSystem");
|
|
11
|
+
const performanceOptimizer_1 = require("../infrastructure/optimization/performanceOptimizer");
|
|
12
|
+
const performanceTypes_1 = require("../types/performanceTypes");
|
|
13
|
+
const result_1 = require("../types/result");
|
|
14
|
+
const errors_1 = require("../utils/errors");
|
|
15
|
+
const bestPracticesEngine_1 = require("./bestPracticesEngine");
|
|
16
|
+
const logger_1 = require("../utils/logger");
|
|
17
|
+
/**
|
|
18
|
+
* Default orchestration configuration
|
|
19
|
+
*/
|
|
20
|
+
const DEFAULT_CONFIG = {
|
|
21
|
+
timeout: 20000,
|
|
22
|
+
enablePOML: true,
|
|
23
|
+
bestPracticesMode: 'complete',
|
|
24
|
+
fallbackStrategy: 'primary',
|
|
25
|
+
maxProcessingTime: 20000,
|
|
26
|
+
};
|
|
27
|
+
/**
|
|
28
|
+
* StructuredPromptOrchestrator implementation
|
|
29
|
+
* Orchestrates 2-stage processing: POML structuring -> Best practices enhancement
|
|
30
|
+
*/
|
|
31
|
+
class StructuredPromptOrchestratorImpl {
|
|
32
|
+
constructor(geminiTextClient, bestPracticesEngine, pomlTemplateEngine, config = DEFAULT_CONFIG) {
|
|
33
|
+
this.geminiTextClient = geminiTextClient;
|
|
34
|
+
this.bestPracticesEngine = bestPracticesEngine;
|
|
35
|
+
this.pomlTemplateEngine = pomlTemplateEngine;
|
|
36
|
+
this.config = config;
|
|
37
|
+
this.currentMetrics = this.initializeMetrics();
|
|
38
|
+
this.logger = new logger_1.Logger();
|
|
39
|
+
// Initialize monitoring infrastructure
|
|
40
|
+
this.metricsCollector = new OrchestrationMetrics_1.OrchestrationMetrics();
|
|
41
|
+
this.performanceOptimizer = new performanceOptimizer_1.PerformanceOptimizer(this.metricsCollector);
|
|
42
|
+
this.alertingSystem = new alertingSystem_1.AlertingSystem();
|
|
43
|
+
}
|
|
44
|
+
/**
|
|
45
|
+
* Generate structured prompt through 2-stage orchestration
|
|
46
|
+
* Stage 1: POML template structuring
|
|
47
|
+
* Stage 2: Best practices enhancement
|
|
48
|
+
*/
|
|
49
|
+
async generateStructuredPrompt(originalPrompt, options) {
|
|
50
|
+
const startTime = new Date();
|
|
51
|
+
const totalProcessingStartTime = Date.now();
|
|
52
|
+
const stages = [];
|
|
53
|
+
const appliedStrategies = [];
|
|
54
|
+
// Detailed orchestration start logging
|
|
55
|
+
this.logger.debug('PromptOrchestrator', 'generateStructuredPrompt STARTED', {
|
|
56
|
+
originalPromptLength: originalPrompt.length,
|
|
57
|
+
options,
|
|
58
|
+
effectiveOptionsWillBeMerged: true,
|
|
59
|
+
componentsAvailable: {
|
|
60
|
+
geminiTextClient: !!this.geminiTextClient,
|
|
61
|
+
bestPracticesEngine: !!this.bestPracticesEngine,
|
|
62
|
+
pomlTemplateEngine: !!this.pomlTemplateEngine
|
|
63
|
+
}
|
|
64
|
+
});
|
|
65
|
+
// Record memory usage at start
|
|
66
|
+
const initialMemory = {
|
|
67
|
+
heapUsed: process.memoryUsage().heapUsed,
|
|
68
|
+
heapTotal: process.memoryUsage().heapTotal,
|
|
69
|
+
external: process.memoryUsage().external,
|
|
70
|
+
arrayBuffers: process.memoryUsage().arrayBuffers,
|
|
71
|
+
timestamp: Date.now(),
|
|
72
|
+
};
|
|
73
|
+
this.metricsCollector.recordMemoryUsage('orchestration_start', initialMemory);
|
|
74
|
+
try {
|
|
75
|
+
// Validate input
|
|
76
|
+
if (!originalPrompt || originalPrompt.trim().length === 0) {
|
|
77
|
+
this.logger.error('PromptOrchestrator', 'Input validation FAILED - empty prompt');
|
|
78
|
+
return (0, result_1.Err)(new errors_1.GeminiAPIError('Original prompt cannot be empty'));
|
|
79
|
+
}
|
|
80
|
+
// Merge options with default config
|
|
81
|
+
const effectiveOptions = this.mergeOptions(options);
|
|
82
|
+
this.logger.debug('PromptOrchestrator', 'Options merged', {
|
|
83
|
+
originalOptions: options,
|
|
84
|
+
effectiveOptions,
|
|
85
|
+
enablePOML: effectiveOptions.enablePOML,
|
|
86
|
+
bestPracticesMode: effectiveOptions.bestPracticesMode
|
|
87
|
+
});
|
|
88
|
+
let structuredPrompt = originalPrompt;
|
|
89
|
+
// Stage 1: POML Template Structuring (if enabled)
|
|
90
|
+
if (effectiveOptions.enablePOML) {
|
|
91
|
+
this.logger.debug('PromptOrchestrator', 'Starting Stage 1 (POML Template Structuring)', {
|
|
92
|
+
inputPromptLength: originalPrompt.length
|
|
93
|
+
});
|
|
94
|
+
const stage1Result = await this.executeStage1(originalPrompt, stages, appliedStrategies);
|
|
95
|
+
this.logger.debug('PromptOrchestrator', 'Stage 1 (POML Template Structuring) COMPLETED', {
|
|
96
|
+
success: stage1Result.success,
|
|
97
|
+
outputPromptLength: stage1Result.success ? stage1Result.data.length : 0,
|
|
98
|
+
promptChanged: stage1Result.success ? originalPrompt !== stage1Result.data : false,
|
|
99
|
+
errorMessage: stage1Result.success ? null : stage1Result.error.message
|
|
100
|
+
});
|
|
101
|
+
if (!stage1Result.success) {
|
|
102
|
+
this.logger.error('PromptOrchestrator', 'Stage 1 (POML Template Structuring) FAILED', stage1Result.error, {
|
|
103
|
+
originalPromptLength: originalPrompt.length,
|
|
104
|
+
stage1Configuration: {
|
|
105
|
+
enablePOML: effectiveOptions.enablePOML
|
|
106
|
+
},
|
|
107
|
+
componentStates: {
|
|
108
|
+
geminiTextClient: !!this.geminiTextClient,
|
|
109
|
+
pomlTemplateEngine: !!this.pomlTemplateEngine
|
|
110
|
+
},
|
|
111
|
+
processingContext: {
|
|
112
|
+
stagesCompleted: stages.length,
|
|
113
|
+
appliedStrategies: appliedStrategies.length
|
|
114
|
+
}
|
|
115
|
+
});
|
|
116
|
+
return (0, result_1.Err)(stage1Result.error);
|
|
117
|
+
}
|
|
118
|
+
structuredPrompt = stage1Result.data;
|
|
119
|
+
}
|
|
120
|
+
else {
|
|
121
|
+
this.logger.debug('PromptOrchestrator', 'Stage 1 (POML Template Structuring) SKIPPED', {
|
|
122
|
+
enablePOML: effectiveOptions.enablePOML,
|
|
123
|
+
promptRemainsUnchanged: true
|
|
124
|
+
});
|
|
125
|
+
}
|
|
126
|
+
this.logger.debug('PromptOrchestrator', 'Starting Stage 2 (Best Practices Enhancement)', {
|
|
127
|
+
inputPromptLength: structuredPrompt.length,
|
|
128
|
+
bestPracticesMode: effectiveOptions.bestPracticesMode
|
|
129
|
+
});
|
|
130
|
+
// Stage 2: Best Practices Enhancement
|
|
131
|
+
const stage2Result = await this.executeStage2(structuredPrompt, effectiveOptions, stages, appliedStrategies);
|
|
132
|
+
this.logger.debug('PromptOrchestrator', 'Stage 2 (Best Practices Enhancement) COMPLETED', {
|
|
133
|
+
success: stage2Result.success,
|
|
134
|
+
outputPromptLength: stage2Result.success ? stage2Result.data.length : 0,
|
|
135
|
+
promptChanged: stage2Result.success ? structuredPrompt !== stage2Result.data : false,
|
|
136
|
+
errorMessage: stage2Result.success ? null : stage2Result.error.message
|
|
137
|
+
});
|
|
138
|
+
if (!stage2Result.success) {
|
|
139
|
+
this.logger.error('PromptOrchestrator', 'Stage 2 (Best Practices Enhancement) FAILED', stage2Result.error, {
|
|
140
|
+
originalPromptLength: originalPrompt.length,
|
|
141
|
+
stage1OutputLength: structuredPrompt.length,
|
|
142
|
+
stage2Configuration: {
|
|
143
|
+
bestPracticesMode: effectiveOptions.bestPracticesMode,
|
|
144
|
+
maintainCharacterConsistency: effectiveOptions.maintainCharacterConsistency,
|
|
145
|
+
blendImages: effectiveOptions.blendImages,
|
|
146
|
+
useWorldKnowledge: effectiveOptions.useWorldKnowledge
|
|
147
|
+
},
|
|
148
|
+
componentStates: {
|
|
149
|
+
geminiTextClient: !!this.geminiTextClient,
|
|
150
|
+
bestPracticesEngine: !!this.bestPracticesEngine
|
|
151
|
+
},
|
|
152
|
+
processingContext: {
|
|
153
|
+
stagesCompleted: stages.length,
|
|
154
|
+
appliedStrategies: appliedStrategies.length,
|
|
155
|
+
stage1Success: true
|
|
156
|
+
}
|
|
157
|
+
});
|
|
158
|
+
return (0, result_1.Err)(stage2Result.error);
|
|
159
|
+
}
|
|
160
|
+
// Compile final result
|
|
161
|
+
const endTime = new Date();
|
|
162
|
+
const totalProcessingTime = Date.now() - totalProcessingStartTime;
|
|
163
|
+
const metrics = this.calculateMetrics(startTime, endTime, stages);
|
|
164
|
+
// Record comprehensive performance metrics
|
|
165
|
+
this.metricsCollector.recordProcessingTime(performanceTypes_1.ProcessingStage.TOTAL_PROCESSING, totalProcessingTime);
|
|
166
|
+
// Record final memory usage
|
|
167
|
+
const finalMemory = {
|
|
168
|
+
heapUsed: process.memoryUsage().heapUsed,
|
|
169
|
+
heapTotal: process.memoryUsage().heapTotal,
|
|
170
|
+
external: process.memoryUsage().external,
|
|
171
|
+
arrayBuffers: process.memoryUsage().arrayBuffers,
|
|
172
|
+
timestamp: Date.now(),
|
|
173
|
+
};
|
|
174
|
+
this.metricsCollector.recordMemoryUsage('orchestration_end', finalMemory);
|
|
175
|
+
// Check alerts for performance issues
|
|
176
|
+
const currentMetrics = this.metricsCollector.getCurrentMetrics();
|
|
177
|
+
await this.alertingSystem.checkAlerts(currentMetrics);
|
|
178
|
+
// Enhanced result with monitoring data
|
|
179
|
+
const result = {
|
|
180
|
+
originalPrompt,
|
|
181
|
+
structuredPrompt: stage2Result.data,
|
|
182
|
+
processingStages: stages,
|
|
183
|
+
appliedStrategies,
|
|
184
|
+
metrics,
|
|
185
|
+
};
|
|
186
|
+
this.logger.info('PromptOrchestrator', 'generateStructuredPrompt SUCCESS - returning enhanced prompt', {
|
|
187
|
+
originalLength: originalPrompt.length,
|
|
188
|
+
finalLength: stage2Result.data.length,
|
|
189
|
+
totalProcessingTime: totalProcessingTime,
|
|
190
|
+
stagesCompleted: stages.length,
|
|
191
|
+
strategiesApplied: appliedStrategies.length,
|
|
192
|
+
promptActuallyChanged: originalPrompt !== stage2Result.data
|
|
193
|
+
});
|
|
194
|
+
this.currentMetrics = metrics;
|
|
195
|
+
return (0, result_1.Ok)(result);
|
|
196
|
+
}
|
|
197
|
+
catch (error) {
|
|
198
|
+
const processError = error instanceof Error ? error : new errors_1.GeminiAPIError(`Orchestration failed: ${error}`);
|
|
199
|
+
this.logger.error('PromptOrchestrator', 'generateStructuredPrompt UNEXPECTED EXCEPTION', processError, {
|
|
200
|
+
originalPromptLength: originalPrompt.length,
|
|
201
|
+
providedOptions: options,
|
|
202
|
+
componentStates: {
|
|
203
|
+
geminiTextClient: !!this.geminiTextClient,
|
|
204
|
+
bestPracticesEngine: !!this.bestPracticesEngine,
|
|
205
|
+
pomlTemplateEngine: !!this.pomlTemplateEngine
|
|
206
|
+
},
|
|
207
|
+
processingContext: {
|
|
208
|
+
stagesAttempted: stages.length,
|
|
209
|
+
appliedStrategies: appliedStrategies.length,
|
|
210
|
+
totalProcessingTime: Date.now() - totalProcessingStartTime
|
|
211
|
+
},
|
|
212
|
+
memoryUsage: process.memoryUsage()
|
|
213
|
+
});
|
|
214
|
+
const apiError = error instanceof errors_1.GeminiAPIError
|
|
215
|
+
? error
|
|
216
|
+
: new errors_1.GeminiAPIError(`Orchestration failed: ${error}`);
|
|
217
|
+
// Record error in monitoring system
|
|
218
|
+
this.metricsCollector.recordError(performanceTypes_1.ProcessingStage.TOTAL_PROCESSING, apiError);
|
|
219
|
+
return (0, result_1.Err)(apiError);
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
/**
|
|
223
|
+
* Execute Stage 1: POML Template Structuring
|
|
224
|
+
*/
|
|
225
|
+
async executeStage1(prompt, stages, appliedStrategies) {
|
|
226
|
+
const stage = {
|
|
227
|
+
name: 'POML Template Structuring',
|
|
228
|
+
status: 'processing',
|
|
229
|
+
startTime: new Date(),
|
|
230
|
+
};
|
|
231
|
+
stages.push(stage);
|
|
232
|
+
const stageStartTime = Date.now();
|
|
233
|
+
try {
|
|
234
|
+
const basicTemplate = {
|
|
235
|
+
id: 'basic-structure-v1',
|
|
236
|
+
name: 'basic-structure',
|
|
237
|
+
structure: {
|
|
238
|
+
role: 'You are an AI assistant specialized in image generation.',
|
|
239
|
+
task: 'Generate high-quality, detailed images based on the provided prompt.',
|
|
240
|
+
context: 'The prompt will be enhanced for optimal image generation results.',
|
|
241
|
+
constraints: {
|
|
242
|
+
quality: 'high',
|
|
243
|
+
style: 'enhanced',
|
|
244
|
+
technical: ['Maintain visual coherence', 'Follow safe content guidelines'],
|
|
245
|
+
},
|
|
246
|
+
},
|
|
247
|
+
features: [], // Empty for basic template
|
|
248
|
+
metadata: {
|
|
249
|
+
version: '1.0',
|
|
250
|
+
author: 'StructuredPromptOrchestrator',
|
|
251
|
+
description: 'Basic template for prompt structuring',
|
|
252
|
+
tags: ['image-generation', 'basic'],
|
|
253
|
+
created: new Date(),
|
|
254
|
+
lastModified: new Date(),
|
|
255
|
+
},
|
|
256
|
+
};
|
|
257
|
+
const pomlResult = await this.pomlTemplateEngine.applyTemplate(prompt, basicTemplate);
|
|
258
|
+
if (!pomlResult.success) {
|
|
259
|
+
stage.status = 'failed';
|
|
260
|
+
stage.endTime = new Date();
|
|
261
|
+
stage.error = new errors_1.GeminiAPIError('POML template application failed');
|
|
262
|
+
this.logger.error('PromptOrchestrator:Stage1', 'POML Template Application FAILED', pomlResult.error, {
|
|
263
|
+
inputPromptLength: prompt.length,
|
|
264
|
+
basicTemplate: {
|
|
265
|
+
id: basicTemplate.id,
|
|
266
|
+
name: basicTemplate.name,
|
|
267
|
+
version: basicTemplate.metadata.version
|
|
268
|
+
},
|
|
269
|
+
pomlEngineAvailable: !!this.pomlTemplateEngine,
|
|
270
|
+
processingTime: stage.endTime.getTime() - stage.startTime.getTime()
|
|
271
|
+
});
|
|
272
|
+
return (0, result_1.Err)(stage.error);
|
|
273
|
+
}
|
|
274
|
+
stage.status = 'completed';
|
|
275
|
+
stage.endTime = new Date();
|
|
276
|
+
stage.output = pomlResult.data.structuredPrompt;
|
|
277
|
+
// Record POML processing performance
|
|
278
|
+
const stageProcessingTime = Date.now() - stageStartTime;
|
|
279
|
+
this.metricsCollector.recordProcessingTime(performanceTypes_1.ProcessingStage.POML_PROCESSING, stageProcessingTime);
|
|
280
|
+
appliedStrategies.push({
|
|
281
|
+
strategy: 'POML Structuring',
|
|
282
|
+
applied: true,
|
|
283
|
+
processingTime: stage.endTime.getTime() - stage.startTime.getTime(),
|
|
284
|
+
});
|
|
285
|
+
return (0, result_1.Ok)(pomlResult.data.structuredPrompt);
|
|
286
|
+
}
|
|
287
|
+
catch (error) {
|
|
288
|
+
stage.status = 'failed';
|
|
289
|
+
stage.endTime = new Date();
|
|
290
|
+
stage.error = error instanceof Error ? error : new errors_1.GeminiAPIError('Stage 1 execution failed');
|
|
291
|
+
const processError = error instanceof Error ? error : new errors_1.GeminiAPIError('Stage 1 execution failed');
|
|
292
|
+
this.logger.error('PromptOrchestrator:Stage1', 'UNEXPECTED EXCEPTION in executeStage1', processError, {
|
|
293
|
+
inputPromptLength: prompt.length,
|
|
294
|
+
componentStates: {
|
|
295
|
+
pomlTemplateEngine: !!this.pomlTemplateEngine
|
|
296
|
+
},
|
|
297
|
+
stage: {
|
|
298
|
+
name: stage.name,
|
|
299
|
+
status: stage.status,
|
|
300
|
+
processingTime: stage.endTime.getTime() - stage.startTime.getTime()
|
|
301
|
+
}
|
|
302
|
+
});
|
|
303
|
+
// Record stage error
|
|
304
|
+
this.metricsCollector.recordError(performanceTypes_1.ProcessingStage.POML_PROCESSING, stage.error);
|
|
305
|
+
return (0, result_1.Err)(stage.error instanceof errors_1.GeminiAPIError
|
|
306
|
+
? stage.error
|
|
307
|
+
: new errors_1.GeminiAPIError(`Stage 1 failed: ${stage.error.message}`));
|
|
308
|
+
}
|
|
309
|
+
}
|
|
310
|
+
/**
|
|
311
|
+
* Execute Stage 2: Best Practices Enhancement
|
|
312
|
+
*/
|
|
313
|
+
async executeStage2(prompt, options, stages, appliedStrategies) {
|
|
314
|
+
// Skip if best practices mode is not enabled or is basic
|
|
315
|
+
if (!options.bestPracticesMode || options.bestPracticesMode === 'basic') {
|
|
316
|
+
// For basic mode or disabled, return the prompt unchanged
|
|
317
|
+
const stage = {
|
|
318
|
+
name: 'Best Practices Enhancement',
|
|
319
|
+
status: 'skipped',
|
|
320
|
+
startTime: new Date(),
|
|
321
|
+
endTime: new Date(),
|
|
322
|
+
output: prompt,
|
|
323
|
+
};
|
|
324
|
+
stages.push(stage);
|
|
325
|
+
return (0, result_1.Ok)(prompt);
|
|
326
|
+
}
|
|
327
|
+
const stage = {
|
|
328
|
+
name: 'Best Practices Enhancement',
|
|
329
|
+
status: 'processing',
|
|
330
|
+
startTime: new Date(),
|
|
331
|
+
};
|
|
332
|
+
stages.push(stage);
|
|
333
|
+
const stageStartTime = Date.now();
|
|
334
|
+
try {
|
|
335
|
+
const bestPracticesOptions = {
|
|
336
|
+
aspectRatio: '16:9',
|
|
337
|
+
targetStyle: 'enhanced',
|
|
338
|
+
contextIntent: 'image_generation',
|
|
339
|
+
// Pass through feature parameters from orchestration options (only when defined)
|
|
340
|
+
...(options.maintainCharacterConsistency !== undefined && {
|
|
341
|
+
maintainCharacterConsistency: options.maintainCharacterConsistency,
|
|
342
|
+
}),
|
|
343
|
+
...(options.blendImages !== undefined && { blendImages: options.blendImages }),
|
|
344
|
+
...(options.useWorldKnowledge !== undefined && {
|
|
345
|
+
useWorldKnowledge: options.useWorldKnowledge,
|
|
346
|
+
}),
|
|
347
|
+
};
|
|
348
|
+
// Create BestPracticesEngine with GeminiTextClient for AI-powered enhancement
|
|
349
|
+
const enhancedBestPracticesEngine = (0, bestPracticesEngine_1.createBestPracticesEngine)({ enableAllPractices: true }, this.geminiTextClient);
|
|
350
|
+
const bestPracticesResult = await enhancedBestPracticesEngine.applyBestPractices(prompt, bestPracticesOptions);
|
|
351
|
+
if (!bestPracticesResult.success) {
|
|
352
|
+
stage.status = 'failed';
|
|
353
|
+
stage.endTime = new Date();
|
|
354
|
+
stage.error = new errors_1.GeminiAPIError('Best practices enhancement failed');
|
|
355
|
+
return (0, result_1.Err)(stage.error);
|
|
356
|
+
}
|
|
357
|
+
stage.status = 'completed';
|
|
358
|
+
stage.endTime = new Date();
|
|
359
|
+
stage.output = bestPracticesResult.data.enhancedPrompt;
|
|
360
|
+
// Record best practices processing performance
|
|
361
|
+
const stageProcessingTime = Date.now() - stageStartTime;
|
|
362
|
+
this.metricsCollector.recordProcessingTime(performanceTypes_1.ProcessingStage.BEST_PRACTICES, stageProcessingTime);
|
|
363
|
+
appliedStrategies.push({
|
|
364
|
+
strategy: 'Best Practices Enhancement',
|
|
365
|
+
applied: true,
|
|
366
|
+
processingTime: stage.endTime.getTime() - stage.startTime.getTime(),
|
|
367
|
+
});
|
|
368
|
+
return (0, result_1.Ok)(bestPracticesResult.data.enhancedPrompt);
|
|
369
|
+
}
|
|
370
|
+
catch (error) {
|
|
371
|
+
stage.status = 'failed';
|
|
372
|
+
stage.endTime = new Date();
|
|
373
|
+
stage.error = error instanceof Error ? error : new errors_1.GeminiAPIError('Stage 2 execution failed');
|
|
374
|
+
// Record stage error
|
|
375
|
+
this.metricsCollector.recordError(performanceTypes_1.ProcessingStage.BEST_PRACTICES, stage.error);
|
|
376
|
+
return (0, result_1.Err)(stage.error instanceof errors_1.GeminiAPIError
|
|
377
|
+
? stage.error
|
|
378
|
+
: new errors_1.GeminiAPIError(`Stage 2 failed: ${stage.error.message}`));
|
|
379
|
+
}
|
|
380
|
+
}
|
|
381
|
+
/**
|
|
382
|
+
* Merge options with configuration defaults
|
|
383
|
+
*/
|
|
384
|
+
mergeOptions(options) {
|
|
385
|
+
return {
|
|
386
|
+
enablePOML: options?.enablePOML ?? this.config.enablePOML,
|
|
387
|
+
bestPracticesMode: options?.bestPracticesMode ?? this.config.bestPracticesMode,
|
|
388
|
+
fallbackStrategy: options?.fallbackStrategy ?? this.config.fallbackStrategy,
|
|
389
|
+
maxProcessingTime: options?.maxProcessingTime ?? this.config.maxProcessingTime,
|
|
390
|
+
};
|
|
391
|
+
}
|
|
392
|
+
/**
|
|
393
|
+
* Calculate processing metrics
|
|
394
|
+
*/
|
|
395
|
+
calculateMetrics(startTime, endTime, stages) {
|
|
396
|
+
const totalProcessingTime = endTime.getTime() - startTime.getTime();
|
|
397
|
+
const completedStages = stages.filter((stage) => stage.status === 'completed').length;
|
|
398
|
+
const failedStages = stages.filter((stage) => stage.status === 'failed').length;
|
|
399
|
+
return {
|
|
400
|
+
totalProcessingTime,
|
|
401
|
+
stageCount: stages.length,
|
|
402
|
+
successRate: stages.length > 0 ? completedStages / stages.length : 0,
|
|
403
|
+
failureCount: failedStages,
|
|
404
|
+
fallbacksUsed: 0, // Will be updated in fallback scenarios
|
|
405
|
+
timestamp: endTime,
|
|
406
|
+
};
|
|
407
|
+
}
|
|
408
|
+
/**
|
|
409
|
+
* Validate orchestration configuration
|
|
410
|
+
*/
|
|
411
|
+
async validateConfiguration() {
|
|
412
|
+
try {
|
|
413
|
+
// Validate component availability
|
|
414
|
+
if (!this.geminiTextClient || !this.bestPracticesEngine || !this.pomlTemplateEngine) {
|
|
415
|
+
return (0, result_1.Err)(new errors_1.InputValidationError('Required components not available', 'Ensure all components are properly initialized'));
|
|
416
|
+
}
|
|
417
|
+
// Validate configuration values
|
|
418
|
+
if (this.config.timeout <= 0 || this.config.maxProcessingTime <= 0) {
|
|
419
|
+
return (0, result_1.Err)(new errors_1.InputValidationError('Invalid timeout configuration', 'Set positive timeout values'));
|
|
420
|
+
}
|
|
421
|
+
return (0, result_1.Ok)(true);
|
|
422
|
+
}
|
|
423
|
+
catch (error) {
|
|
424
|
+
return (0, result_1.Err)(new errors_1.InputValidationError(`Configuration validation failed: ${error}`, 'Check orchestrator configuration parameters'));
|
|
425
|
+
}
|
|
426
|
+
}
|
|
427
|
+
/**
|
|
428
|
+
* Get current processing metrics
|
|
429
|
+
*/
|
|
430
|
+
getProcessingMetrics() {
|
|
431
|
+
return { ...this.currentMetrics };
|
|
432
|
+
}
|
|
433
|
+
/**
|
|
434
|
+
* Get comprehensive performance monitoring data
|
|
435
|
+
*/
|
|
436
|
+
async getPerformanceReport(timeRange) {
|
|
437
|
+
const defaultTimeRange = {
|
|
438
|
+
start: Date.now() - 3600000, // 1 hour ago
|
|
439
|
+
end: Date.now(),
|
|
440
|
+
};
|
|
441
|
+
return await this.metricsCollector.getPerformanceReport(timeRange || defaultTimeRange);
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Get cost analysis report
|
|
445
|
+
*/
|
|
446
|
+
async getCostAnalysis(period = performanceTypes_1.ReportingPeriod.LAST_HOUR) {
|
|
447
|
+
return await this.metricsCollector.getCostAnalysis(period);
|
|
448
|
+
}
|
|
449
|
+
/**
|
|
450
|
+
* Get current metrics snapshot
|
|
451
|
+
*/
|
|
452
|
+
getCurrentMetrics() {
|
|
453
|
+
return this.metricsCollector.getCurrentMetrics();
|
|
454
|
+
}
|
|
455
|
+
/**
|
|
456
|
+
* Get optimization recommendations
|
|
457
|
+
*/
|
|
458
|
+
async getOptimizationRecommendations() {
|
|
459
|
+
return await this.performanceOptimizer.getOptimizationRecommendations();
|
|
460
|
+
}
|
|
461
|
+
/**
|
|
462
|
+
* Get alert status
|
|
463
|
+
*/
|
|
464
|
+
async getAlertStatus() {
|
|
465
|
+
return await this.metricsCollector.getAlertStatus();
|
|
466
|
+
}
|
|
467
|
+
/**
|
|
468
|
+
* Cleanup monitoring resources
|
|
469
|
+
*/
|
|
470
|
+
destroy() {
|
|
471
|
+
this.metricsCollector.destroy();
|
|
472
|
+
this.performanceOptimizer.destroy();
|
|
473
|
+
this.alertingSystem.destroy();
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Initialize default metrics
|
|
477
|
+
*/
|
|
478
|
+
initializeMetrics() {
|
|
479
|
+
return {
|
|
480
|
+
totalProcessingTime: 0,
|
|
481
|
+
stageCount: 0,
|
|
482
|
+
successRate: 0,
|
|
483
|
+
failureCount: 0,
|
|
484
|
+
fallbacksUsed: 0,
|
|
485
|
+
timestamp: new Date(),
|
|
486
|
+
};
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
exports.StructuredPromptOrchestratorImpl = StructuredPromptOrchestratorImpl;
|
|
490
|
+
//# sourceMappingURL=promptOrchestrator.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"promptOrchestrator.js","sourceRoot":"","sources":["../../src/business/promptOrchestrator.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAGH,4FAA8G;AAC9G,gFAA4E;AAC5E,8FAA0F;AAC1F,gEAQkC;AAElC,4CAAyC;AACzC,4CAAsE;AACtE,+DAI8B;AAE9B,4CAAwC;AAkGxC;;GAEG;AACH,MAAM,cAAc,GAAwB;IAC1C,OAAO,EAAE,KAAK;IACd,U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,OAAO;QACL,IAAI,CAAC,gBAAgB,CAAC,OAAO,EAAE,CAAA;QAC/B,IAAI,CAAC,oBAAoB,CAAC,OAAO,EAAE,CAAA;QACnC,IAAI,CAAC,cAAc,CAAC,OAAO,EAAE,CAAA;IAC/B,CAAC;IAED;;OAEG;IACK,iBAAiB;QACvB,OAAO;YACL,mBAAmB,EAAE,CAAC;YACtB,UAAU,EAAE,CAAC;YACb,WAAW,EAAE,CAAC;YACd,YAAY,EAAE,CAAC;YACf,aAAa,EAAE,CAAC;YAChB,SAAS,EAAE,IAAI,IAAI,EAAE;SACtB,CAAA;IACH,CAAC;CACF;AAtkBD,4EAskBC"}
|
|
@@ -2,14 +2,14 @@
|
|
|
2
2
|
* Response Builder for MCP structured content responses
|
|
3
3
|
* Converts generation results and errors into MCP-compatible response format
|
|
4
4
|
*/
|
|
5
|
+
import type { GeneratedImageResult } from '../api/geminiClient';
|
|
5
6
|
import type { McpToolResponse } from '../types/mcp';
|
|
6
7
|
import { type BaseError } from '../utils/errors';
|
|
7
|
-
import type { GenerationResult } from './imageGenerator';
|
|
8
8
|
/**
|
|
9
9
|
* Interface for response builder functionality
|
|
10
10
|
*/
|
|
11
11
|
export interface ResponseBuilder {
|
|
12
|
-
buildSuccessResponse(generationResult:
|
|
12
|
+
buildSuccessResponse(generationResult: GeneratedImageResult, filePath: string): McpToolResponse;
|
|
13
13
|
buildErrorResponse(error: BaseError | Error): McpToolResponse;
|
|
14
14
|
}
|
|
15
15
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responseBuilder.d.ts","sourceRoot":"","sources":["../../src/business/responseBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,
|
|
1
|
+
{"version":3,"file":"responseBuilder.d.ts","sourceRoot":"","sources":["../../src/business/responseBuilder.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAA;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAqB,MAAM,cAAc,CAAA;AACtE,OAAO,EACL,KAAK,SAAS,EAOf,MAAM,iBAAiB,CAAA;AAmBxB;;GAEG;AACH,MAAM,WAAW,eAAe;IAC9B,oBAAoB,CAAC,gBAAgB,EAAE,oBAAoB,EAAE,QAAQ,EAAE,MAAM,GAAG,eAAe,CAAA;IAC/F,kBAAkB,CAAC,KAAK,EAAE,SAAS,GAAG,KAAK,GAAG,eAAe,CAAA;CAC9D;AA+DD;;;GAGG;AACH,wBAAgB,qBAAqB,IAAI,eAAe,CAgEvD"}
|
|
@@ -126,7 +126,12 @@ function createResponseBuilder() {
|
|
|
126
126
|
name: fileName,
|
|
127
127
|
mimeType,
|
|
128
128
|
},
|
|
129
|
-
metadata:
|
|
129
|
+
metadata: {
|
|
130
|
+
model: generationResult.metadata.model,
|
|
131
|
+
processingTime: 0, // Not tracked in simplified version
|
|
132
|
+
contextMethod: 'structured_prompt',
|
|
133
|
+
timestamp: generationResult.metadata.timestamp.toISOString(),
|
|
134
|
+
},
|
|
130
135
|
};
|
|
131
136
|
return {
|
|
132
137
|
content: [
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"responseBuilder.js","sourceRoot":"","sources":["../../src/business/responseBuilder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGH,
|
|
1
|
+
{"version":3,"file":"responseBuilder.js","sourceRoot":"","sources":["../../src/business/responseBuilder.ts"],"names":[],"mappings":";AAAA;;;GAGG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAyGH,sDAgEC;AAvKD,gDAAiC;AAGjC,4CAQwB;AAExB,8CAA8C;AAC9C,MAAM,UAAU,GAAG;IACjB,GAAG,EAAE,WAAW;IAChB,IAAI,EAAE,YAAY;IAClB,IAAI,EAAE,YAAY;CACV,CAAA;AAEV,MAAM,eAAe,GAAG;IACtB,GAAG,EAAE,CAA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CAAC,eAAe,CAAC;qBACtC;iBACF;gBACD,OAAO,EAAE,IAAI;aACd,CAAA;QACH,CAAC;KACF,CAAA;AACH,CAAC"}
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Structured Prompt Generator
|
|
3
|
+
* Uses Gemini 2.0 Flash to generate optimized prompts for image generation
|
|
4
|
+
* Applies 7 best practices and 3 feature perspectives through intelligent selection
|
|
5
|
+
*/
|
|
6
|
+
import type { GeminiTextClient } from '../api/geminiTextClient';
|
|
7
|
+
import type { Result } from '../types/result';
|
|
8
|
+
/**
|
|
9
|
+
* Feature flags for image generation
|
|
10
|
+
*/
|
|
11
|
+
export interface FeatureFlags {
|
|
12
|
+
maintainCharacterConsistency?: boolean;
|
|
13
|
+
blendImages?: boolean;
|
|
14
|
+
useWorldKnowledge?: boolean;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Result of structured prompt generation
|
|
18
|
+
*/
|
|
19
|
+
export interface StructuredPromptResult {
|
|
20
|
+
originalPrompt: string;
|
|
21
|
+
structuredPrompt: string;
|
|
22
|
+
selectedPractices: string[];
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Interface for structured prompt generation
|
|
26
|
+
*/
|
|
27
|
+
export interface StructuredPromptGenerator {
|
|
28
|
+
generateStructuredPrompt(userPrompt: string, features?: FeatureFlags, inputImageData?: string): Promise<Result<StructuredPromptResult, Error>>;
|
|
29
|
+
}
|
|
30
|
+
/**
|
|
31
|
+
* Implementation of StructuredPromptGenerator using Gemini 2.0 Flash
|
|
32
|
+
*/
|
|
33
|
+
export declare class StructuredPromptGeneratorImpl implements StructuredPromptGenerator {
|
|
34
|
+
private readonly geminiTextClient;
|
|
35
|
+
constructor(geminiTextClient: GeminiTextClient);
|
|
36
|
+
generateStructuredPrompt(userPrompt: string, features?: FeatureFlags, inputImageData?: string): Promise<Result<StructuredPromptResult, Error>>;
|
|
37
|
+
/**
|
|
38
|
+
* Build complete prompt with all optimization context
|
|
39
|
+
*/
|
|
40
|
+
private buildCompletePrompt;
|
|
41
|
+
/**
|
|
42
|
+
* Build enhanced feature context based on flags with explicit requirements
|
|
43
|
+
*/
|
|
44
|
+
private buildEnhancedFeatureContext;
|
|
45
|
+
/**
|
|
46
|
+
* Infer which best practices were selected based on the generated prompt
|
|
47
|
+
*/
|
|
48
|
+
private inferSelectedPractices;
|
|
49
|
+
}
|
|
50
|
+
/**
|
|
51
|
+
* Factory function to create StructuredPromptGenerator
|
|
52
|
+
*/
|
|
53
|
+
export declare function createStructuredPromptGenerator(geminiTextClient: GeminiTextClient): StructuredPromptGenerator;
|
|
54
|
+
//# sourceMappingURL=structuredPromptGenerator.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"structuredPromptGenerator.d.ts","sourceRoot":"","sources":["../../src/business/structuredPromptGenerator.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAA;AAC/D,OAAO,KAAK,EAAE,MAAM,EAAE,MAAM,iBAAiB,CAAA;AAqC7C;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,4BAA4B,CAAC,EAAE,OAAO,CAAA;IACtC,WAAW,CAAC,EAAE,OAAO,CAAA;IACrB,iBAAiB,CAAC,EAAE,OAAO,CAAA;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,sBAAsB;IACrC,cAAc,EAAE,MAAM,CAAA;IACtB,gBAAgB,EAAE,MAAM,CAAA;IACxB,iBAAiB,EAAE,MAAM,EAAE,CAAA;CAC5B;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC,wBAAwB,CACtB,UAAU,EAAE,MAAM,EAClB,QAAQ,CAAC,EAAE,YAAY,EACvB,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,MAAM,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC,CAAA;CAClD;AAED;;GAEG;AACH,qBAAa,6BAA8B,YAAW,yBAAyB;IACjE,OAAO,CAAC,QAAQ,CAAC,gBAAgB;gBAAhB,gBAAgB,EAAE,gBAAgB;IAEzD,wBAAwB,CAC5B,UAAU,EAAE,MAAM,EAClB,QAAQ,GAAE,YAAiB,EAC3B,cAAc,CAAC,EAAE,MAAM,GACtB,OAAO,CAAC,MAAM,CAAC,sBAAsB,EAAE,KAAK,CAAC,CAAC;IA2CjD;;OAEG;IACH,OAAO,CAAC,mBAAmB;IAkC3B;;OAEG;IACH,OAAO,CAAC,2BAA2B;IA4BnC;;OAEG;IACH,OAAO,CAAC,sBAAsB;CAkF/B;AAED;;GAEG;AACH,wBAAgB,+BAA+B,CAC7C,gBAAgB,EAAE,gBAAgB,GACjC,yBAAyB,CAE3B"}
|