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,229 @@
1
+ /**
2
+ * Orchestration Error Handler - Comprehensive error management system
3
+ * Handles all error scenarios for structured prompt generation orchestration
4
+ * Provides intelligent recovery, fallback strategies, and user-friendly error communication
5
+ */
6
+ import type { Result } from '../../types/result';
7
+ /**
8
+ * Error severity classification for appropriate response handling
9
+ */
10
+ export declare enum ErrorSeverity {
11
+ RECOVERABLE = "recoverable",// Can retry or apply fallback
12
+ DEGRADED = "degraded",// Partial functionality available
13
+ FATAL = "fatal"
14
+ }
15
+ /**
16
+ * Processing stages for error context tracking
17
+ */
18
+ export declare enum ProcessingStage {
19
+ INPUT_VALIDATION = "input_validation",
20
+ POML_STRUCTURING = "poml_structuring",
21
+ BEST_PRACTICES = "best_practices",
22
+ OUTPUT_FORMATTING = "output_formatting",
23
+ FINALIZATION = "finalization"
24
+ }
25
+ /**
26
+ * Recovery actions that can be taken when errors occur
27
+ */
28
+ export declare enum RecoveryAction {
29
+ RETRY = "retry",
30
+ FALLBACK = "fallback",
31
+ GRACEFUL_DEGRADATION = "graceful_degradation",
32
+ FAIL_SAFE = "fail_safe"
33
+ }
34
+ /**
35
+ * Error context information for comprehensive error handling
36
+ */
37
+ export interface ErrorContext {
38
+ operation: string;
39
+ stage: ProcessingStage;
40
+ sessionId: string;
41
+ retryCount: number;
42
+ userFacing: boolean;
43
+ metadata?: Record<string, unknown>;
44
+ }
45
+ /**
46
+ * Recovery options for error handling strategies
47
+ */
48
+ export interface RecoveryOptions {
49
+ maxRetries: number;
50
+ retryDelay: number;
51
+ enableFallback: boolean;
52
+ fallbackStrategy: string;
53
+ gracefulDegradation: boolean;
54
+ }
55
+ /**
56
+ * Diagnostic information for error analysis
57
+ */
58
+ export interface DiagnosticInfo {
59
+ errorCode: string;
60
+ timestamp: Date;
61
+ stackTrace?: string;
62
+ contextData: Record<string, unknown>;
63
+ userAgent?: string;
64
+ requestId?: string;
65
+ }
66
+ /**
67
+ * Complete error handling result
68
+ */
69
+ export interface ErrorHandlingResult<T> {
70
+ success: boolean;
71
+ data?: T;
72
+ fallbackApplied: boolean;
73
+ userMessage: string;
74
+ diagnosticInfo: DiagnosticInfo;
75
+ recoveryAction: RecoveryAction;
76
+ }
77
+ /**
78
+ * Network error classification for specific handling
79
+ */
80
+ export declare enum NetworkErrorType {
81
+ TIMEOUT = "timeout",
82
+ RATE_LIMIT = "rate_limit",
83
+ CONNECTION_FAILED = "connection_failed",
84
+ SERVICE_UNAVAILABLE = "service_unavailable",
85
+ AUTHENTICATION_FAILED = "authentication_failed",
86
+ UNKNOWN = "unknown"
87
+ }
88
+ /**
89
+ * Network error information
90
+ */
91
+ export interface NetworkError extends Error {
92
+ type: NetworkErrorType;
93
+ statusCode?: number;
94
+ retryAfter?: number;
95
+ originalError?: Error;
96
+ }
97
+ /**
98
+ * Recovery result for error handling operations
99
+ */
100
+ export interface RecoveryResult {
101
+ action: RecoveryAction;
102
+ message: string;
103
+ userFacing: boolean;
104
+ estimatedRecoveryTime?: number;
105
+ additionalData?: Record<string, unknown>;
106
+ }
107
+ /**
108
+ * Validation result for input processing
109
+ */
110
+ export interface ValidationResult {
111
+ valid: boolean;
112
+ errors: ValidationError[];
113
+ warnings: ValidationWarning[];
114
+ normalizedInput?: unknown;
115
+ }
116
+ /**
117
+ * Individual validation error
118
+ */
119
+ export interface ValidationError {
120
+ field: string;
121
+ message: string;
122
+ severity: ErrorSeverity;
123
+ suggestion?: string;
124
+ code: string;
125
+ }
126
+ /**
127
+ * Individual validation warning
128
+ */
129
+ export interface ValidationWarning {
130
+ field: string;
131
+ message: string;
132
+ suggestion?: string;
133
+ code: string;
134
+ }
135
+ /**
136
+ * Validation schema for input validation
137
+ */
138
+ export interface ValidationSchema {
139
+ type: string;
140
+ properties?: Record<string, ValidationPropertySchema>;
141
+ required?: string[];
142
+ minLength?: number;
143
+ maxLength?: number;
144
+ pattern?: RegExp;
145
+ }
146
+ /**
147
+ * Property-specific validation schema
148
+ */
149
+ export interface ValidationPropertySchema {
150
+ type: string;
151
+ required?: boolean;
152
+ minLength?: number;
153
+ maxLength?: number;
154
+ pattern?: RegExp;
155
+ validator?: (value: unknown) => boolean;
156
+ }
157
+ /**
158
+ * Concurrent operation information
159
+ */
160
+ export interface ConcurrentOperation {
161
+ id: string;
162
+ type: string;
163
+ priority: OperationPriority;
164
+ startTime: Date;
165
+ estimatedDuration: number;
166
+ resourceRequirements: ResourceRequirements;
167
+ }
168
+ /**
169
+ * Operation priority levels
170
+ */
171
+ export declare enum OperationPriority {
172
+ LOW = "low",
173
+ NORMAL = "normal",
174
+ HIGH = "high",
175
+ CRITICAL = "critical"
176
+ }
177
+ /**
178
+ * Resource requirements for operations
179
+ */
180
+ export interface ResourceRequirements {
181
+ memory: number;
182
+ cpu: number;
183
+ networkBandwidth: number;
184
+ concurrentConnections: number;
185
+ }
186
+ /**
187
+ * Resource limits configuration
188
+ */
189
+ export interface ResourceLimits {
190
+ maxMemory: number;
191
+ maxCpu: number;
192
+ maxNetworkBandwidth: number;
193
+ maxConcurrentOperations: number;
194
+ maxConcurrentConnections: number;
195
+ }
196
+ /**
197
+ * Main orchestration error handler interface
198
+ */
199
+ export interface OrchestrationErrorHandler {
200
+ /**
201
+ * Handle errors with comprehensive recovery strategies
202
+ */
203
+ handleError<T>(error: Error, context: ErrorContext, recoveryOptions?: RecoveryOptions): Promise<ErrorHandlingResult<T>>;
204
+ /**
205
+ * Validate input with detailed error reporting
206
+ */
207
+ validateInput(input: unknown, schema: ValidationSchema): Promise<ValidationResult>;
208
+ /**
209
+ * Manage resource contention for concurrent operations
210
+ */
211
+ manageResourceContention(operation: ConcurrentOperation): Promise<Result<unknown, Error>>;
212
+ /**
213
+ * Handle network-specific errors with intelligent retry
214
+ */
215
+ handleNetworkErrors(networkError: NetworkError, context: ErrorContext): Promise<RecoveryResult>;
216
+ /**
217
+ * Classify errors for appropriate handling strategy
218
+ */
219
+ classifyError(error: Error): ErrorSeverity;
220
+ /**
221
+ * Generate user-friendly error messages
222
+ */
223
+ generateUserMessage(error: Error, context: ErrorContext): string;
224
+ /**
225
+ * Create diagnostic information for debugging
226
+ */
227
+ createDiagnosticInfo(error: Error, context: ErrorContext): DiagnosticInfo;
228
+ }
229
+ //# sourceMappingURL=orchestrationErrorHandler.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrationErrorHandler.d.ts","sourceRoot":"","sources":["../../../src/infrastructure/errorHandling/orchestrationErrorHandler.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AAEH,OA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AAE,MAAM,CAAA;IACjB,MAAM,EAAE,MAAM,CAAA;IACd,mBAAmB,EAAE,MAAM,CAAA;IAC3B,uBAAuB,EAAE,MAAM,CAAA;IAC/B,wBAAwB,EAAE,MAAM,CAAA;CACjC;AAED;;GAEG;AACH,MAAM,WAAW,yBAAyB;IACxC;;OAEG;IACH,WAAW,CAAC,CAAC,EACX,KAAK,EAAE,KAAK,EACZ,OAAO,EAAE,YAAY,EACrB,eAAe,CAAC,EAAE,eAAe,GAChC,OAAO,CAAC,mBAAmB,CAAC,CAAC,CAAC,CAAC,CAAA;IAElC;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAA;IAElF;;OAEG;IACH,wBAAwB,CAAC,SAAS,EAAE,mBAAmB,GAAG,OAAO,CAAC,MAAM,CAAC,OAAO,EAAE,KAAK,CAAC,CAAC,CAAA;IAEzF;;OAEG;IACH,mBAAmB,CAAC,YAAY,EAAE,YAAY,EAAE,OAAO,EAAE,YAAY,GAAG,OAAO,CAAC,cAAc,CAAC,CAAA;IAE/F;;OAEG;IACH,aAAa,CAAC,KAAK,EAAE,KAAK,GAAG,aAAa,CAAA;IAE1C;;OAEG;IACH,mBAAmB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,GAAG,MAAM,CAAA;IAEhE;;OAEG;IACH,oBAAoB,CAAC,KAAK,EAAE,KAAK,EAAE,OAAO,EAAE,YAAY,GAAG,cAAc,CAAA;CAC1E"}
@@ -0,0 +1,61 @@
1
+ "use strict";
2
+ /**
3
+ * Orchestration Error Handler - Comprehensive error management system
4
+ * Handles all error scenarios for structured prompt generation orchestration
5
+ * Provides intelligent recovery, fallback strategies, and user-friendly error communication
6
+ */
7
+ Object.defineProperty(exports, "__esModule", { value: true });
8
+ exports.OperationPriority = exports.NetworkErrorType = exports.RecoveryAction = exports.ProcessingStage = exports.ErrorSeverity = void 0;
9
+ /**
10
+ * Error severity classification for appropriate response handling
11
+ */
12
+ var ErrorSeverity;
13
+ (function (ErrorSeverity) {
14
+ ErrorSeverity["RECOVERABLE"] = "recoverable";
15
+ ErrorSeverity["DEGRADED"] = "degraded";
16
+ ErrorSeverity["FATAL"] = "fatal";
17
+ })(ErrorSeverity || (exports.ErrorSeverity = ErrorSeverity = {}));
18
+ /**
19
+ * Processing stages for error context tracking
20
+ */
21
+ var ProcessingStage;
22
+ (function (ProcessingStage) {
23
+ ProcessingStage["INPUT_VALIDATION"] = "input_validation";
24
+ ProcessingStage["POML_STRUCTURING"] = "poml_structuring";
25
+ ProcessingStage["BEST_PRACTICES"] = "best_practices";
26
+ ProcessingStage["OUTPUT_FORMATTING"] = "output_formatting";
27
+ ProcessingStage["FINALIZATION"] = "finalization";
28
+ })(ProcessingStage || (exports.ProcessingStage = ProcessingStage = {}));
29
+ /**
30
+ * Recovery actions that can be taken when errors occur
31
+ */
32
+ var RecoveryAction;
33
+ (function (RecoveryAction) {
34
+ RecoveryAction["RETRY"] = "retry";
35
+ RecoveryAction["FALLBACK"] = "fallback";
36
+ RecoveryAction["GRACEFUL_DEGRADATION"] = "graceful_degradation";
37
+ RecoveryAction["FAIL_SAFE"] = "fail_safe";
38
+ })(RecoveryAction || (exports.RecoveryAction = RecoveryAction = {}));
39
+ /**
40
+ * Network error classification for specific handling
41
+ */
42
+ var NetworkErrorType;
43
+ (function (NetworkErrorType) {
44
+ NetworkErrorType["TIMEOUT"] = "timeout";
45
+ NetworkErrorType["RATE_LIMIT"] = "rate_limit";
46
+ NetworkErrorType["CONNECTION_FAILED"] = "connection_failed";
47
+ NetworkErrorType["SERVICE_UNAVAILABLE"] = "service_unavailable";
48
+ NetworkErrorType["AUTHENTICATION_FAILED"] = "authentication_failed";
49
+ NetworkErrorType["UNKNOWN"] = "unknown";
50
+ })(NetworkErrorType || (exports.NetworkErrorType = NetworkErrorType = {}));
51
+ /**
52
+ * Operation priority levels
53
+ */
54
+ var OperationPriority;
55
+ (function (OperationPriority) {
56
+ OperationPriority["LOW"] = "low";
57
+ OperationPriority["NORMAL"] = "normal";
58
+ OperationPriority["HIGH"] = "high";
59
+ OperationPriority["CRITICAL"] = "critical";
60
+ })(OperationPriority || (exports.OperationPriority = OperationPriority = {}));
61
+ //# sourceMappingURL=orchestrationErrorHandler.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestrationErrorHandler.js","sourceRoot":"","sources":["../../../src/infrastructure/errorHandling/orchestrationErrorHandler.ts"],"names":[],"mappings":";AAAA;;;;GAIG;;;AAIH;;GAEG;AACH,IAAY,aAIX;AAJD,WAAY,aAAa;IACvB,4CAA2B,CAAA;IAC3B,sCAAqB,CAAA;IACrB,gCAAe,CAAA;AACjB,CAAC,EAJW,aAAa,6BAAb,aAAa,QAIxB;AAED;;GAEG;AACH,IAAY,eAMX;AAND,WAAY,eAAe;IACzB,wDAAqC,CAAA;IACrC,wDAAqC,CAAA;IACrC,oDAAiC,CAAA;IACjC,0DAAuC,CAAA;IACvC,gDAA6B,CAAA;AAC/B,CAAC,EANW,eAAe,+BAAf,eAAe,QAM1B;AAED;;GAEG;AACH,IAAY,cAKX;AALD,WAAY,cAAc;IACxB,iCAAe,CAAA;IACf,uCAAqB,CAAA;IACrB,+DAA6C,CAAA;IAC7C,yCAAuB,CAAA;AACzB,CAAC,EALW,cAAc,8BAAd,cAAc,QAKzB;AAiDD;;GAEG;AACH,IAAY,gBAOX;AAPD,WAAY,gBAAgB;IAC1B,uCAAmB,CAAA;IACnB,6CAAyB,CAAA;IACzB,2DAAuC,CAAA;IACvC,+DAA2C,CAAA;IAC3C,mEAA+C,CAAA;IAC/C,uCAAmB,CAAA;AACrB,CAAC,EAPW,gBAAgB,gCAAhB,gBAAgB,QAO3B;AA0FD;;GAEG;AACH,IAAY,iBAKX;AALD,WAAY,iBAAiB;IAC3B,gCAAW,CAAA;IACX,sCAAiB,CAAA;IACjB,kCAAa,CAAA;IACb,0CAAqB,CAAA;AACvB,CAAC,EALW,iBAAiB,iCAAjB,iBAAiB,QAK5B"}
@@ -0,0 +1,133 @@
1
+ /**
2
+ * Orchestration Error Handler Implementation - Comprehensive error management
3
+ * Provides intelligent recovery, fallback strategies, and robust error handling
4
+ * Implements all error scenarios for structured prompt generation orchestration
5
+ */
6
+ import type { Result } from '../../types/result';
7
+ import type { ConcurrentOperation, DiagnosticInfo, ErrorContext, ErrorHandlingResult, NetworkError, OrchestrationErrorHandler, RecoveryOptions, RecoveryResult, ValidationResult, ValidationSchema } from './orchestrationErrorHandler';
8
+ import { ErrorSeverity } from './orchestrationErrorHandler';
9
+ /**
10
+ * Network error recovery configuration
11
+ */
12
+ interface NetworkRecoveryConfig {
13
+ maxRetries: number;
14
+ baseDelay: number;
15
+ maxDelay: number;
16
+ timeoutMultiplier: number;
17
+ enableExponentialBackoff: boolean;
18
+ }
19
+ /**
20
+ * OrchestrationErrorHandler implementation with comprehensive error management
21
+ */
22
+ export declare class OrchestrationErrorHandlerImpl implements OrchestrationErrorHandler {
23
+ private readonly networkConfig;
24
+ private readonly errorCounts;
25
+ private readonly errorTimestamps;
26
+ constructor(networkConfig?: NetworkRecoveryConfig);
27
+ /**
28
+ * Handle errors with comprehensive recovery strategies
29
+ */
30
+ handleError<T>(error: Error, context: ErrorContext, recoveryOptions?: RecoveryOptions): Promise<ErrorHandlingResult<T>>;
31
+ /**
32
+ * Validate input with detailed error reporting
33
+ */
34
+ validateInput(input: unknown, schema: ValidationSchema): Promise<ValidationResult>;
35
+ /**
36
+ * Manage resource contention for concurrent operations
37
+ */
38
+ manageResourceContention(operation: ConcurrentOperation): Promise<Result<unknown, Error>>;
39
+ /**
40
+ * Handle network-specific errors with intelligent retry
41
+ */
42
+ handleNetworkErrors(networkError: NetworkError, context: ErrorContext): Promise<RecoveryResult>;
43
+ /**
44
+ * Classify errors for appropriate handling strategy
45
+ */
46
+ classifyError(error: Error): ErrorSeverity;
47
+ /**
48
+ * Generate user-friendly error messages
49
+ */
50
+ generateUserMessage(error: Error, context: ErrorContext): string;
51
+ /**
52
+ * Create diagnostic information for debugging
53
+ */
54
+ createDiagnosticInfo(error: Error, context: ErrorContext): DiagnosticInfo;
55
+ /**
56
+ * Track error occurrence for pattern detection
57
+ */
58
+ private trackErrorOccurrence;
59
+ /**
60
+ * Determine appropriate recovery action
61
+ */
62
+ private determineRecoveryAction;
63
+ /**
64
+ * Attempt retry with exponential backoff
65
+ */
66
+ private attemptRetry;
67
+ /**
68
+ * Apply fallback processing
69
+ */
70
+ private applyFallback;
71
+ /**
72
+ * Apply graceful degradation
73
+ */
74
+ private applyGracefulDegradation;
75
+ /**
76
+ * Generate fallback user message when recovery fails
77
+ */
78
+ private generateFallbackUserMessage;
79
+ /**
80
+ * Check if operation can proceed given current constraints
81
+ */
82
+ private checkOperationViability;
83
+ /**
84
+ * Classify network error for specific handling
85
+ */
86
+ private classifyNetworkError;
87
+ /**
88
+ * Handle timeout errors
89
+ */
90
+ private handleTimeout;
91
+ /**
92
+ * Handle rate limit errors
93
+ */
94
+ private handleRateLimit;
95
+ /**
96
+ * Handle connection failures
97
+ */
98
+ private handleConnectionFailure;
99
+ /**
100
+ * Handle service unavailable errors
101
+ */
102
+ private handleServiceUnavailable;
103
+ /**
104
+ * Handle authentication failures
105
+ */
106
+ private handleAuthenticationFailure;
107
+ /**
108
+ * Handle unknown network errors
109
+ */
110
+ private handleUnknownNetworkError;
111
+ /**
112
+ * Calculate retry delay with exponential backoff
113
+ */
114
+ private calculateRetryDelay;
115
+ /**
116
+ * Calculate exponential backoff delay
117
+ */
118
+ private calculateExponentialBackoff;
119
+ /**
120
+ * Sleep for specified milliseconds
121
+ */
122
+ private delay;
123
+ /**
124
+ * Generate error code based on error and context
125
+ */
126
+ private generateErrorCode;
127
+ /**
128
+ * Generate unique request ID
129
+ */
130
+ private generateRequestId;
131
+ }
132
+ export {};
133
+ //# sourceMappingURL=orchestrationErrorHandlerImpl.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"orchestration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