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.
Files changed (178) hide show
  1. package/README.md +41 -17
  2. package/dist/api/geminiClient.d.ts +2 -12
  3. package/dist/api/geminiClient.d.ts.map +1 -1
  4. package/dist/api/geminiClient.js +28 -56
  5. package/dist/api/geminiClient.js.map +1 -1
  6. package/dist/api/geminiTextClient.d.ts +42 -0
  7. package/dist/api/geminiTextClient.d.ts.map +1 -0
  8. package/dist/api/geminiTextClient.js +198 -0
  9. package/dist/api/geminiTextClient.js.map +1 -0
  10. package/dist/business/__tests__/mocks/mcpSamplingClient.mock.d.ts +84 -0
  11. package/dist/business/__tests__/mocks/mcpSamplingClient.mock.d.ts.map +1 -0
  12. package/dist/business/__tests__/mocks/mcpSamplingClient.mock.js +100 -0
  13. package/dist/business/__tests__/mocks/mcpSamplingClient.mock.js.map +1 -0
  14. package/dist/business/bestPracticesEngine.d.ts +149 -0
  15. package/dist/business/bestPracticesEngine.d.ts.map +1 -0
  16. package/dist/business/bestPracticesEngine.js +781 -0
  17. package/dist/business/bestPracticesEngine.js.map +1 -0
  18. package/dist/business/complexityAssessment.d.ts +132 -0
  19. package/dist/business/complexityAssessment.d.ts.map +1 -0
  20. package/dist/business/complexityAssessment.js +488 -0
  21. package/dist/business/complexityAssessment.js.map +1 -0
  22. package/dist/business/fallbackStrategies.d.ts +177 -0
  23. package/dist/business/fallbackStrategies.d.ts.map +1 -0
  24. package/dist/business/fallbackStrategies.js +368 -0
  25. package/dist/business/fallbackStrategies.js.map +1 -0
  26. package/dist/business/imageGenerator.d.ts.map +1 -1
  27. package/dist/business/imageGenerator.js +26 -5
  28. package/dist/business/imageGenerator.js.map +1 -1
  29. package/dist/business/multiImage/aspectRatioController.d.ts +77 -0
  30. package/dist/business/multiImage/aspectRatioController.d.ts.map +1 -0
  31. package/dist/business/multiImage/aspectRatioController.js +580 -0
  32. package/dist/business/multiImage/aspectRatioController.js.map +1 -0
  33. package/dist/business/multiImage/multiImageCoordinator.d.ts +142 -0
  34. package/dist/business/multiImage/multiImageCoordinator.d.ts.map +1 -0
  35. package/dist/business/multiImage/multiImageCoordinator.js +801 -0
  36. package/dist/business/multiImage/multiImageCoordinator.js.map +1 -0
  37. package/dist/business/pomlTemplateEngine.d.ts +206 -0
  38. package/dist/business/pomlTemplateEngine.d.ts.map +1 -0
  39. package/dist/business/pomlTemplateEngine.js +737 -0
  40. package/dist/business/pomlTemplateEngine.js.map +1 -0
  41. package/dist/business/promptOrchestrator.d.ts +173 -0
  42. package/dist/business/promptOrchestrator.d.ts.map +1 -0
  43. package/dist/business/promptOrchestrator.js +490 -0
  44. package/dist/business/promptOrchestrator.js.map +1 -0
  45. package/dist/business/responseBuilder.d.ts +2 -2
  46. package/dist/business/responseBuilder.d.ts.map +1 -1
  47. package/dist/business/responseBuilder.js +6 -1
  48. package/dist/business/responseBuilder.js.map +1 -1
  49. package/dist/business/structuredPromptGenerator.d.ts +54 -0
  50. package/dist/business/structuredPromptGenerator.d.ts.map +1 -0
  51. package/dist/business/structuredPromptGenerator.js +208 -0
  52. package/dist/business/structuredPromptGenerator.js.map +1 -0
  53. package/dist/business/templateNormalizer.d.ts +81 -0
  54. package/dist/business/templateNormalizer.d.ts.map +1 -0
  55. package/dist/business/templateNormalizer.js +659 -0
  56. package/dist/business/templateNormalizer.js.map +1 -0
  57. package/dist/documentation/apiContractValidation.d.ts +62 -0
  58. package/dist/documentation/apiContractValidation.d.ts.map +1 -0
  59. package/dist/documentation/apiContractValidation.js +305 -0
  60. package/dist/documentation/apiContractValidation.js.map +1 -0
  61. package/dist/infrastructure/concurrency/concurrencyManager.d.ts +101 -0
  62. package/dist/infrastructure/concurrency/concurrencyManager.d.ts.map +1 -0
  63. package/dist/infrastructure/concurrency/concurrencyManager.js +345 -0
  64. package/dist/infrastructure/concurrency/concurrencyManager.js.map +1 -0
  65. package/dist/infrastructure/config/secureConfigManager.d.ts +319 -0
  66. package/dist/infrastructure/config/secureConfigManager.d.ts.map +1 -0
  67. package/dist/infrastructure/config/secureConfigManager.js +600 -0
  68. package/dist/infrastructure/config/secureConfigManager.js.map +1 -0
  69. package/dist/infrastructure/errorHandling/orchestrationErrorHandler.d.ts +229 -0
  70. package/dist/infrastructure/errorHandling/orchestrationErrorHandler.d.ts.map +1 -0
  71. package/dist/infrastructure/errorHandling/orchestrationErrorHandler.js +61 -0
  72. package/dist/infrastructure/errorHandling/orchestrationErrorHandler.js.map +1 -0
  73. package/dist/infrastructure/errorHandling/orchestrationErrorHandlerImpl.d.ts +133 -0
  74. package/dist/infrastructure/errorHandling/orchestrationErrorHandlerImpl.d.ts.map +1 -0
  75. package/dist/infrastructure/errorHandling/orchestrationErrorHandlerImpl.js +569 -0
  76. package/dist/infrastructure/errorHandling/orchestrationErrorHandlerImpl.js.map +1 -0
  77. package/dist/infrastructure/mcp/MCPSamplingClient.d.ts +19 -0
  78. package/dist/infrastructure/mcp/MCPSamplingClient.d.ts.map +1 -0
  79. package/dist/infrastructure/mcp/MCPSamplingClient.js +31 -0
  80. package/dist/infrastructure/mcp/MCPSamplingClient.js.map +1 -0
  81. package/dist/infrastructure/mcp/RealMCPSamplingClient.d.ts +59 -0
  82. package/dist/infrastructure/mcp/RealMCPSamplingClient.d.ts.map +1 -0
  83. package/dist/infrastructure/mcp/RealMCPSamplingClient.js +271 -0
  84. package/dist/infrastructure/mcp/RealMCPSamplingClient.js.map +1 -0
  85. package/dist/infrastructure/metadata/generationMetadata.d.ts +72 -0
  86. package/dist/infrastructure/metadata/generationMetadata.d.ts.map +1 -0
  87. package/dist/infrastructure/metadata/generationMetadata.js +228 -0
  88. package/dist/infrastructure/metadata/generationMetadata.js.map +1 -0
  89. package/dist/infrastructure/monitoring/OrchestrationMetrics.d.ts +106 -0
  90. package/dist/infrastructure/monitoring/OrchestrationMetrics.d.ts.map +1 -0
  91. package/dist/infrastructure/monitoring/OrchestrationMetrics.js +456 -0
  92. package/dist/infrastructure/monitoring/OrchestrationMetrics.js.map +1 -0
  93. package/dist/infrastructure/monitoring/alertingSystem.d.ts +135 -0
  94. package/dist/infrastructure/monitoring/alertingSystem.d.ts.map +1 -0
  95. package/dist/infrastructure/monitoring/alertingSystem.js +549 -0
  96. package/dist/infrastructure/monitoring/alertingSystem.js.map +1 -0
  97. package/dist/infrastructure/optimization/performanceOptimizer.d.ts +89 -0
  98. package/dist/infrastructure/optimization/performanceOptimizer.d.ts.map +1 -0
  99. package/dist/infrastructure/optimization/performanceOptimizer.js +375 -0
  100. package/dist/infrastructure/optimization/performanceOptimizer.js.map +1 -0
  101. package/dist/infrastructure/security/AdvancedContentFilter.d.ts +99 -0
  102. package/dist/infrastructure/security/AdvancedContentFilter.d.ts.map +1 -0
  103. package/dist/infrastructure/security/AdvancedContentFilter.js +363 -0
  104. package/dist/infrastructure/security/AdvancedContentFilter.js.map +1 -0
  105. package/dist/infrastructure/security/MCPSecurityValidator.d.ts +62 -0
  106. package/dist/infrastructure/security/MCPSecurityValidator.d.ts.map +1 -0
  107. package/dist/infrastructure/security/MCPSecurityValidator.js +129 -0
  108. package/dist/infrastructure/security/MCPSecurityValidator.js.map +1 -0
  109. package/dist/infrastructure/security/OrchestrationSecurityMiddleware.d.ts +304 -0
  110. package/dist/infrastructure/security/OrchestrationSecurityMiddleware.d.ts.map +1 -0
  111. package/dist/infrastructure/security/OrchestrationSecurityMiddleware.js +61 -0
  112. package/dist/infrastructure/security/OrchestrationSecurityMiddleware.js.map +1 -0
  113. package/dist/infrastructure/security/OrchestrationSecurityMiddlewareImpl.d.ts +62 -0
  114. package/dist/infrastructure/security/OrchestrationSecurityMiddlewareImpl.d.ts.map +1 -0
  115. package/dist/infrastructure/security/OrchestrationSecurityMiddlewareImpl.js +591 -0
  116. package/dist/infrastructure/security/OrchestrationSecurityMiddlewareImpl.js.map +1 -0
  117. package/dist/infrastructure/security/SecureMCPClient.d.ts +154 -0
  118. package/dist/infrastructure/security/SecureMCPClient.d.ts.map +1 -0
  119. package/dist/infrastructure/security/SecureMCPClient.js +292 -0
  120. package/dist/infrastructure/security/SecureMCPClient.js.map +1 -0
  121. package/dist/infrastructure/security/SecurityIncidentManager.d.ts +142 -0
  122. package/dist/infrastructure/security/SecurityIncidentManager.d.ts.map +1 -0
  123. package/dist/infrastructure/security/SecurityIncidentManager.js +260 -0
  124. package/dist/infrastructure/security/SecurityIncidentManager.js.map +1 -0
  125. package/dist/infrastructure/security/apiKeyManager.d.ts +297 -0
  126. package/dist/infrastructure/security/apiKeyManager.d.ts.map +1 -0
  127. package/dist/infrastructure/security/apiKeyManager.js +254 -0
  128. package/dist/infrastructure/security/apiKeyManager.js.map +1 -0
  129. package/dist/infrastructure/security/dataSanitizer.d.ts +157 -0
  130. package/dist/infrastructure/security/dataSanitizer.d.ts.map +1 -0
  131. package/dist/infrastructure/security/dataSanitizer.js +525 -0
  132. package/dist/infrastructure/security/dataSanitizer.js.map +1 -0
  133. package/dist/infrastructure/validation/inputValidator.d.ts +54 -0
  134. package/dist/infrastructure/validation/inputValidator.d.ts.map +1 -0
  135. package/dist/infrastructure/validation/inputValidator.js +362 -0
  136. package/dist/infrastructure/validation/inputValidator.js.map +1 -0
  137. package/dist/integration/parameterOptimizer.d.ts +69 -0
  138. package/dist/integration/parameterOptimizer.d.ts.map +1 -0
  139. package/dist/integration/parameterOptimizer.js +317 -0
  140. package/dist/integration/parameterOptimizer.js.map +1 -0
  141. package/dist/integration/twoStageProcessor.d.ts +66 -0
  142. package/dist/integration/twoStageProcessor.d.ts.map +1 -0
  143. package/dist/integration/twoStageProcessor.js +348 -0
  144. package/dist/integration/twoStageProcessor.js.map +1 -0
  145. package/dist/server/handlers/structuredPromptHandler.d.ts +65 -0
  146. package/dist/server/handlers/structuredPromptHandler.d.ts.map +1 -0
  147. package/dist/server/handlers/structuredPromptHandler.js +314 -0
  148. package/dist/server/handlers/structuredPromptHandler.js.map +1 -0
  149. package/dist/server/mcpServer.d.ts +16 -35
  150. package/dist/server/mcpServer.d.ts.map +1 -1
  151. package/dist/server/mcpServer.js +111 -150
  152. package/dist/server/mcpServer.js.map +1 -1
  153. package/dist/server/mcpServerWithOrchestration.d.ts +98 -0
  154. package/dist/server/mcpServerWithOrchestration.d.ts.map +1 -0
  155. package/dist/server/mcpServerWithOrchestration.js +284 -0
  156. package/dist/server/mcpServerWithOrchestration.js.map +1 -0
  157. package/dist/types/mcpOrchestrationTypes.d.ts +135 -0
  158. package/dist/types/mcpOrchestrationTypes.d.ts.map +1 -0
  159. package/dist/types/mcpOrchestrationTypes.js +28 -0
  160. package/dist/types/mcpOrchestrationTypes.js.map +1 -0
  161. package/dist/types/multiImageTypes.d.ts +328 -0
  162. package/dist/types/multiImageTypes.d.ts.map +1 -0
  163. package/dist/types/multiImageTypes.js +27 -0
  164. package/dist/types/multiImageTypes.js.map +1 -0
  165. package/dist/types/performanceTypes.d.ts +300 -0
  166. package/dist/types/performanceTypes.d.ts.map +1 -0
  167. package/dist/types/performanceTypes.js +50 -0
  168. package/dist/types/performanceTypes.js.map +1 -0
  169. package/dist/types/twoStageTypes.d.ts +123 -0
  170. package/dist/types/twoStageTypes.d.ts.map +1 -0
  171. package/dist/types/twoStageTypes.js +7 -0
  172. package/dist/types/twoStageTypes.js.map +1 -0
  173. package/dist/utils/config.d.ts +1 -0
  174. package/dist/utils/config.d.ts.map +1 -1
  175. package/dist/utils/config.js +1 -0
  176. package/dist/utils/config.js.map +1 -1
  177. package/package.json +11 -4
  178. package/vitest.config.mjs +0 -47
@@ -0,0 +1,208 @@
1
+ "use strict";
2
+ /**
3
+ * Structured Prompt Generator
4
+ * Uses Gemini 2.0 Flash to generate optimized prompts for image generation
5
+ * Applies 7 best practices and 3 feature perspectives through intelligent selection
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.StructuredPromptGeneratorImpl = void 0;
9
+ exports.createStructuredPromptGenerator = createStructuredPromptGenerator;
10
+ const result_1 = require("../types/result");
11
+ const errors_1 = require("../utils/errors");
12
+ /**
13
+ * System prompt for structured prompt generation optimized for image generation
14
+ */
15
+ const SYSTEM_PROMPT = `You are an expert at crafting prompts for image generation models. Your role is to transform user requests into rich, detailed prompts that maximize image generation quality.
16
+
17
+ Core principles:
18
+ - Add specific details about lighting, materials, composition, and atmosphere
19
+ - Include photographic or artistic terminology when appropriate
20
+ - Maintain clarity while adding richness and specificity
21
+ - Preserve the user's original intent while enhancing detail
22
+ - Focus on what should be present rather than what should be absent
23
+
24
+ When describing scenes or subjects:
25
+ - Physical characteristics: textures, materials, colors, scale
26
+ - Lighting: direction, quality, color temperature, shadows
27
+ - Spatial relationships: foreground, midground, background, composition
28
+ - Atmosphere: mood, weather, time of day, environmental conditions
29
+ - Style: artistic direction, photographic techniques, visual treatment
30
+
31
+ Your output should be a single, vivid, coherent description that an image generation model can interpret unambiguously. Make it engaging, specific, and clear.`;
32
+ /**
33
+ * Additional system prompt for image editing mode (when input image is provided)
34
+ */
35
+ const IMAGE_EDITING_CONTEXT = `
36
+
37
+ IMPORTANT: An input image has been provided. Your task is to:
38
+ 1. Analyze the visual context, style, and atmosphere of the input image
39
+ 2. Preserve the original image's core characteristics (color palette, lighting style, composition) while applying the requested changes
40
+ 3. Focus on maintaining visual consistency - describe modifications relative to the existing image
41
+ 4. Be specific about what to keep unchanged vs what to modify
42
+ 5. Use phrases like "maintain the existing...", "preserve the original...", "keep the same..." to ensure fidelity to source`;
43
+ /**
44
+ * Implementation of StructuredPromptGenerator using Gemini 2.0 Flash
45
+ */
46
+ class StructuredPromptGeneratorImpl {
47
+ constructor(geminiTextClient) {
48
+ this.geminiTextClient = geminiTextClient;
49
+ }
50
+ async generateStructuredPrompt(userPrompt, features = {}, inputImageData) {
51
+ try {
52
+ // Validate input
53
+ if (!userPrompt || userPrompt.trim().length === 0) {
54
+ return (0, result_1.Err)(new errors_1.GeminiAPIError('User prompt cannot be empty'));
55
+ }
56
+ // Build complete prompt with system instruction and meta-prompt
57
+ const completePrompt = this.buildCompletePrompt(userPrompt, features, !!inputImageData);
58
+ // Combine system prompts for image editing mode
59
+ const systemInstruction = inputImageData
60
+ ? SYSTEM_PROMPT + IMAGE_EDITING_CONTEXT
61
+ : SYSTEM_PROMPT;
62
+ // Generate structured prompt using Gemini 2.0 Flash via pure API call
63
+ const config = {
64
+ temperature: 0.7,
65
+ maxTokens: 500,
66
+ systemInstruction,
67
+ ...(inputImageData && { inputImage: inputImageData }), // Only include if available
68
+ };
69
+ const result = await this.geminiTextClient.generateText(completePrompt, config);
70
+ if (!result.success) {
71
+ return (0, result_1.Err)(result.error);
72
+ }
73
+ // Extract selected practices from the response
74
+ const selectedPractices = this.inferSelectedPractices(result.data, features);
75
+ return (0, result_1.Ok)({
76
+ originalPrompt: userPrompt,
77
+ structuredPrompt: result.data,
78
+ selectedPractices,
79
+ });
80
+ }
81
+ catch (error) {
82
+ const errorMessage = error instanceof Error ? error.message : 'Unknown error';
83
+ return (0, result_1.Err)(new errors_1.GeminiAPIError(`Failed to generate structured prompt: ${errorMessage}`));
84
+ }
85
+ }
86
+ /**
87
+ * Build complete prompt with all optimization context
88
+ */
89
+ buildCompletePrompt(userPrompt, features, hasInputImage) {
90
+ const featureContext = this.buildEnhancedFeatureContext(features);
91
+ // Add image editing context if an input image is provided
92
+ const imageEditingInstruction = hasInputImage
93
+ ? `\nNOTE: An input image has been provided. Focus on preserving its original characteristics while applying the requested modifications. Maintain consistency with the source image's style, colors, and atmosphere.\n`
94
+ : '';
95
+ return `Transform this image generation request into a detailed, vivid prompt that will produce high-quality results:
96
+
97
+ "${userPrompt}"
98
+ ${imageEditingInstruction}
99
+ ${featureContext}
100
+
101
+ Consider these aspects as you enhance the prompt:
102
+ - Visual details: textures, lighting, colors, materials, composition
103
+ - Spatial relationships and scale between elements
104
+ - Artistic or photographic style that fits the subject
105
+ - Emotional tone and atmosphere
106
+ - Technical specifications if relevant (lens type, camera angle, etc.)
107
+
108
+ Create a natural, flowing description that brings the scene to life. Focus on what should be present rather than what should be absent.
109
+
110
+ Example of a well-enhanced prompt:
111
+ Input: "A happy dog in a park"
112
+ Enhanced: "Golden retriever mid-leap catching a red frisbee, ears flying, tongue out in joy, in a sunlit urban park. Soft morning light filtering through oak trees creates dappled shadows on emerald grass. Background shows families on picnic blankets, slightly out of focus. Shot from low angle emphasizing the dog's athletic movement, with motion blur on the paws suggesting speed."
113
+
114
+ Now transform the user's request with similar attention to detail and creative enhancement.`;
115
+ }
116
+ /**
117
+ * Build enhanced feature context based on flags with explicit requirements
118
+ */
119
+ buildEnhancedFeatureContext(features) {
120
+ const requirements = [];
121
+ if (features.maintainCharacterConsistency) {
122
+ requirements.push('Character consistency is CRITICAL - MUST include distinctive character features: This character needs at least 3 recognizable visual markers that would identify them across different scenes. Include specific details like "distinctive scar", "signature clothing item", "unique hairstyle", or "characteristic accessory". Use words like "signature", "distinctive", "always wears/has" to emphasize these consistent features.');
123
+ }
124
+ if (features.blendImages) {
125
+ requirements.push('MUST describe seamless integration: Multiple visual elements need to blend naturally. Use spatial relationship terms like "seamlessly blending", "harmoniously composed", "naturally integrated". Clearly describe foreground (X% of frame), midground, and background elements with their relative scales and how they interact within the composition.');
126
+ }
127
+ if (features.useWorldKnowledge) {
128
+ requirements.push('Apply accurate real-world knowledge - MUST incorporate authentic details: Apply accurate real-world knowledge about cultures, locations, or historical elements. Use specific terminology like "traditional [culture] style", "authentic [location] architecture", "typical of [region]", "historically accurate [period]". Be precise about cultural elements, geographical features, and factual details.');
129
+ }
130
+ if (requirements.length > 0) {
131
+ return `\nMANDATORY REQUIREMENTS - These MUST be clearly reflected in your enhanced prompt:\n\n${requirements.join('\n\n')}\n`;
132
+ }
133
+ return '';
134
+ }
135
+ /**
136
+ * Infer which best practices were selected based on the generated prompt
137
+ */
138
+ inferSelectedPractices(structuredPrompt, features) {
139
+ const selected = [];
140
+ const promptLower = structuredPrompt.toLowerCase();
141
+ // Check for detailed visual descriptions
142
+ if (promptLower.includes('lighting') ||
143
+ promptLower.includes('texture') ||
144
+ promptLower.includes('atmosphere') ||
145
+ promptLower.includes('shadow') ||
146
+ promptLower.includes('material')) {
147
+ selected.push('Hyper-Specific Details');
148
+ }
149
+ // Check for character consistency markers
150
+ if (features.maintainCharacterConsistency ||
151
+ promptLower.includes('distinctive') ||
152
+ promptLower.includes('signature') ||
153
+ promptLower.includes('characteristic') ||
154
+ promptLower.includes('always wears') ||
155
+ promptLower.includes('always has')) {
156
+ selected.push('Character Consistency');
157
+ }
158
+ // Check for multi-element blending
159
+ if (features.blendImages ||
160
+ promptLower.includes('seamlessly') ||
161
+ promptLower.includes('harmoniously') ||
162
+ promptLower.includes('naturally integrated') ||
163
+ promptLower.includes('foreground') ||
164
+ promptLower.includes('midground') ||
165
+ promptLower.includes('background')) {
166
+ selected.push('Compositional Integration');
167
+ }
168
+ // Check for world knowledge application
169
+ if (features.useWorldKnowledge ||
170
+ promptLower.includes('authentic') ||
171
+ promptLower.includes('traditional') ||
172
+ promptLower.includes('typical of') ||
173
+ promptLower.includes('historically accurate') ||
174
+ promptLower.includes('culturally')) {
175
+ selected.push('Real-World Accuracy');
176
+ }
177
+ // Check for photographic/artistic terminology
178
+ if (promptLower.includes('lens') ||
179
+ promptLower.includes('aperture') ||
180
+ promptLower.includes('f/') ||
181
+ promptLower.includes('mm ') ||
182
+ promptLower.includes('angle') ||
183
+ promptLower.includes('shot') ||
184
+ promptLower.includes('depth of field')) {
185
+ selected.push('Camera Control Terminology');
186
+ }
187
+ // Check for atmospheric and mood enhancement
188
+ if (promptLower.includes('mood') ||
189
+ promptLower.includes('emotion') ||
190
+ promptLower.includes('feeling') ||
191
+ promptLower.includes('ambiance')) {
192
+ selected.push('Atmospheric Enhancement');
193
+ }
194
+ // Ensure we have at least some practices selected
195
+ if (selected.length === 0) {
196
+ selected.push('General Enhancement');
197
+ }
198
+ return selected;
199
+ }
200
+ }
201
+ exports.StructuredPromptGeneratorImpl = StructuredPromptGeneratorImpl;
202
+ /**
203
+ * Factory function to create StructuredPromptGenerator
204
+ */
205
+ function createStructuredPromptGenerator(geminiTextClient) {
206
+ return new StructuredPromptGeneratorImpl(geminiTextClient);
207
+ }
208
+ //# sourceMappingURL=structuredPromptGenerator.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"structuredPromptGenerator.js","sourceRoot":"","sources":["../../src/business/structuredPromptGenerator.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAwRH,0EAIC;AAxRD,4CAAyC;AACzC,4CAAgD;AAEhD;;GAEG;AACH,MAAM,aAAa,GAAG;;;;;;;;;;;;;;;;+JAgByI,CAAA;AAE/J;;GAEG;AACH,MAAM,qBAAqB,GAAG;;;;;;;4HAO8F,CAAA;AA+B5H;;GAEG;AACH,MAAa,6BAA6B;IACxC,YAA6B,gBAAkC;QAAlC,qBAAgB,GAAhB,gBAAgB,CAAkB;IAAG,CAAC;IAEnE,KAAK,CAAC,wBAAwB,CAC5B,UAAkB,EAClB,WAAyB,EAAE,EAC3B,cAAuB;QAEvB,IAAI,CAAC;YACH,iBAAiB;YACjB,IAAI,CAAC,UAAU,IAAI,UAAU,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBAClD,OAAO,IAAA,YAAG,EAAC,IAAI,uBAAc,CAAC,6BAA6B,CAAC,CAAC,CAAA;YAC/D,CAAC;YAED,gEAAgE;YAChE,MAAM,cAAc,GAAG,IAAI,CAAC,mBAAmB,CAAC,UAAU,EAAE,QAAQ,EAAE,CAAC,CAAC,cAAc,CAAC,CAAA;YAEvF,gDAAgD;YAChD,MAAM,iBAAiB,GAAG,cAAc;gBACtC,CAAC,CAAC,aAAa,GAAG,qBAAqB;gBACvC,CAAC,CAAC,aAAa,CAAA;YAEjB,sEAAsE;YACtE,MAAM,MAAM,GAAG;gBACb,WAAW,EAAE,GAAG;gBAChB,SAAS,EAAE,GAAG;gBACd,iBAAiB;gBACjB,GAAG,CAAC,cAAc,IAAI,EAAE,UAAU,EAAE,cAAc,EAAE,CAAC,EAAE,4BAA4B;aACpF,CAA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AC,SAAS,CAAC;YAC/B,WAAW,CAAC,QAAQ,CAAC,UAAU,CAAC,EAChC,CAAC;YACD,QAAQ,CAAC,IAAI,CAAC,yBAAyB,CAAC,CAAA;QAC1C,CAAC;QAED,kDAAkD;QAClD,IAAI,QAAQ,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC1B,QAAQ,CAAC,IAAI,CAAC,qBAAqB,CAAC,CAAA;QACtC,CAAC;QAED,OAAO,QAAQ,CAAA;IACjB,CAAC;CACF;AA3MD,sEA2MC;AAED;;GAEG;AACH,SAAgB,+BAA+B,CAC7C,gBAAkC;IAElC,OAAO,IAAI,6BAA6B,CAAC,gBAAgB,CAAC,CAAA;AAC5D,CAAC"}
@@ -0,0 +1,81 @@
1
+ /**
2
+ * Template engine implementation with embedded best practice templates
3
+ * Provides static template loading and advanced processing capabilities
4
+ */
5
+ import type { NormalizationResult, PromptTemplate, TemplateMatch } from '../types/mcp';
6
+ /**
7
+ * BestPracticesTemplateNormalizer - orchestrates all 7 best practice templates
8
+ * Provides comprehensive prompt normalization with multiple rule application
9
+ */
10
+ export declare class BestPracticesTemplateNormalizer {
11
+ private engine;
12
+ private processor;
13
+ constructor();
14
+ /**
15
+ * Normalize prompt by applying all matching best practice templates
16
+ * Applies templates sequentially based on priority and handles conflicts
17
+ */
18
+ normalize(prompt: string): NormalizationResult;
19
+ /**
20
+ * Convert negative expressions to positive alternatives
21
+ * Transforms semantic negatives into constructive alternatives
22
+ */
23
+ convertNegativeToPositive(prompt: string): string;
24
+ /**
25
+ * Calculate confidence score for individual template matches
26
+ * Uses template priority and pattern specificity for scoring
27
+ */
28
+ private calculateTemplateConfidence;
29
+ /**
30
+ * Automatically inject camera controls for photo-related prompts
31
+ * Ensures professional camera settings are included when appropriate
32
+ */
33
+ private injectCameraControls;
34
+ }
35
+ /**
36
+ * Unified TemplateNormalizer interface with Result pattern for safe error handling
37
+ * Provides comprehensive normalization with fallback capabilities
38
+ */
39
+ export declare class TemplateNormalizer {
40
+ private bestPracticesNormalizer;
41
+ private staticEngine;
42
+ private processor;
43
+ constructor();
44
+ /**
45
+ * Normalize prompt using best practices with automatic fallback
46
+ * Uses Result pattern for safe error handling
47
+ */
48
+ normalize(prompt: string): NormalizationResult;
49
+ /**
50
+ * Get all available templates
51
+ */
52
+ getAvailableTemplates(): PromptTemplate[];
53
+ /**
54
+ * Calculate confidence score for template matches
55
+ */
56
+ calculateConfidence(matches: TemplateMatch[]): number;
57
+ /**
58
+ * Convert negative expressions to positive alternatives
59
+ * Exposes the convertNegativeToPositive functionality
60
+ */
61
+ convertNegativeToPositive(prompt: string): string;
62
+ }
63
+ /**
64
+ * Factory function to create a template normalizer with default configuration
65
+ * Provides a clean interface for prompt normalization using embedded templates
66
+ */
67
+ export declare function createTemplateNormalizer(): {
68
+ /**
69
+ * Normalize a prompt by applying the best matching template
70
+ */
71
+ normalizePrompt(prompt: string): NormalizationResult;
72
+ /**
73
+ * Get all available templates
74
+ */
75
+ getAvailableTemplates(): PromptTemplate[];
76
+ /**
77
+ * Calculate confidence score for template matches
78
+ */
79
+ calculateConfidence(matches: TemplateMatch[]): number;
80
+ };
81
+ //# sourceMappingURL=templateNormalizer.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"templateNormalizer.d.ts","sourceRoot":"","sources":["../../src/business/templateNormalizer.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAGH,OAAO,KAAK,EAAE,mBAAmB,EAAE,cAAc,EAAE,aAAa,EAAE,MAAM,cAAc,CAAA;AAsctF;;;GAGG;AACH,qBAAa,+BAA+B;IAC1C,OAAO,CAAC,MAAM,CAAsB;IACpC,OAAO,CAAC,SAAS,CAA2B;;IAO5C;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB;IAoF9C;;;OAGG;IACH,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;IA2BjD;;;OAGG;IACH,OAAO,CAAC,2BAA2B;IAyBnC;;;OAGG;IACH,OAAO,CAAC,oBAAoB;CA4B7B;AAED;;;GAGG;AACH,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,uBAAuB,CAAiC;IAChE,OAAO,CAAC,YAAY,CAAsB;IAC1C,OAAO,CAAC,SAAS,CAA2B;;IAQ5C;;;OAGG;IACH,SAAS,CAAC,MAAM,EAAE,MAAM,GAAG,mBAAmB;IAiC9C;;OAEG;IACH,qBAAqB,IAAI,cAAc,EAAE;IAIzC;;OAEG;IACH,mBAAmB,CAAC,OAAO,EAAE,aAAa,EAAE,GAAG,MAAM;IAIrD;;;OAGG;IACH,yBAAyB,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM;CAGlD;AAED;;;GAGG;AACH,wBAAgB,wBAAwB;IAKpC;;OAEG;4BACqB,MAAM,GAAG,mBAAmB;IAIpD;;OAEG;6BACsB,cAAc,EAAE;IAIzC;;OAEG;iCAC0B,aAAa,EAAE,GAAG,MAAM;EAIxD"}