@orbytautomation/engine 0.2.4 → 0.4.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 (156) hide show
  1. package/README.md +1 -1
  2. package/dist/adapters/AdapterRegistry.d.ts.map +1 -1
  3. package/dist/adapters/AdapterRegistry.js +6 -0
  4. package/dist/adapters/AdapterRegistry.js.map +1 -1
  5. package/dist/context/VariableResolver.d.ts.map +1 -1
  6. package/dist/context/VariableResolver.js +7 -0
  7. package/dist/context/VariableResolver.js.map +1 -1
  8. package/dist/core/OrbytEngine.d.ts +19 -0
  9. package/dist/core/OrbytEngine.d.ts.map +1 -1
  10. package/dist/core/OrbytEngine.js +79 -3
  11. package/dist/core/OrbytEngine.js.map +1 -1
  12. package/dist/core/index.d.ts +1 -1
  13. package/dist/core/index.d.ts.map +1 -1
  14. package/dist/core/index.js +1 -1
  15. package/dist/core/index.js.map +1 -1
  16. package/dist/errors/ErrorCodes.d.ts +205 -6
  17. package/dist/errors/ErrorCodes.d.ts.map +1 -1
  18. package/dist/errors/ErrorCodes.js +398 -5
  19. package/dist/errors/ErrorCodes.js.map +1 -1
  20. package/dist/errors/ErrorDebugger.d.ts +98 -0
  21. package/dist/errors/ErrorDebugger.d.ts.map +1 -0
  22. package/dist/errors/ErrorDebugger.js +290 -0
  23. package/dist/errors/ErrorDebugger.js.map +1 -0
  24. package/dist/errors/ErrorDetector.d.ts +148 -0
  25. package/dist/errors/ErrorDetector.d.ts.map +1 -0
  26. package/dist/errors/ErrorDetector.js +370 -0
  27. package/dist/errors/ErrorDetector.js.map +1 -0
  28. package/dist/errors/ErrorFormatter.d.ts +92 -3
  29. package/dist/errors/ErrorFormatter.d.ts.map +1 -1
  30. package/dist/errors/ErrorFormatter.js +220 -4
  31. package/dist/errors/ErrorFormatter.js.map +1 -1
  32. package/dist/errors/ErrorHandler.d.ts +259 -0
  33. package/dist/errors/ErrorHandler.d.ts.map +1 -0
  34. package/dist/errors/ErrorHandler.js +378 -0
  35. package/dist/errors/ErrorHandler.js.map +1 -0
  36. package/dist/errors/FieldRegistry.d.ts +39 -0
  37. package/dist/errors/FieldRegistry.d.ts.map +1 -1
  38. package/dist/errors/FieldRegistry.js +172 -74
  39. package/dist/errors/FieldRegistry.js.map +1 -1
  40. package/dist/errors/OrbytError.d.ts +85 -3
  41. package/dist/errors/OrbytError.d.ts.map +1 -1
  42. package/dist/errors/OrbytError.js +151 -4
  43. package/dist/errors/OrbytError.js.map +1 -1
  44. package/dist/errors/SchedulerError.d.ts +93 -1
  45. package/dist/errors/SchedulerError.d.ts.map +1 -1
  46. package/dist/errors/SchedulerError.js +145 -1
  47. package/dist/errors/SchedulerError.js.map +1 -1
  48. package/dist/errors/SecurityErrors.d.ts +94 -12
  49. package/dist/errors/SecurityErrors.d.ts.map +1 -1
  50. package/dist/errors/SecurityErrors.js +162 -18
  51. package/dist/errors/SecurityErrors.js.map +1 -1
  52. package/dist/errors/StepError.d.ts +111 -1
  53. package/dist/errors/StepError.d.ts.map +1 -1
  54. package/dist/errors/StepError.js +182 -1
  55. package/dist/errors/StepError.js.map +1 -1
  56. package/dist/errors/WorkflowError.d.ts +139 -2
  57. package/dist/errors/WorkflowError.d.ts.map +1 -1
  58. package/dist/errors/WorkflowError.js +264 -22
  59. package/dist/errors/WorkflowError.js.map +1 -1
  60. package/dist/errors/index.d.ts +5 -1
  61. package/dist/errors/index.d.ts.map +1 -1
  62. package/dist/errors/index.js +7 -4
  63. package/dist/errors/index.js.map +1 -1
  64. package/dist/execution/ExecutionEngine.d.ts.map +1 -1
  65. package/dist/execution/ExecutionEngine.js +36 -6
  66. package/dist/execution/ExecutionEngine.js.map +1 -1
  67. package/dist/execution/ExecutionPlan.d.ts.map +1 -1
  68. package/dist/execution/ExecutionPlan.js +21 -1
  69. package/dist/execution/ExecutionPlan.js.map +1 -1
  70. package/dist/execution/IntentAnalyzer.d.ts.map +1 -1
  71. package/dist/execution/IntentAnalyzer.js +20 -0
  72. package/dist/execution/IntentAnalyzer.js.map +1 -1
  73. package/dist/execution/StepExecutor.d.ts.map +1 -1
  74. package/dist/execution/StepExecutor.js +109 -29
  75. package/dist/execution/StepExecutor.js.map +1 -1
  76. package/dist/execution/WorkflowExecutor.d.ts.map +1 -1
  77. package/dist/execution/WorkflowExecutor.js +31 -0
  78. package/dist/execution/WorkflowExecutor.js.map +1 -1
  79. package/dist/explanation/ExplanationGenerator.d.ts +105 -0
  80. package/dist/explanation/ExplanationGenerator.d.ts.map +1 -0
  81. package/dist/explanation/ExplanationGenerator.js +814 -0
  82. package/dist/explanation/ExplanationGenerator.js.map +1 -0
  83. package/dist/explanation/ExplanationLogger.d.ts +50 -0
  84. package/dist/explanation/ExplanationLogger.d.ts.map +1 -0
  85. package/dist/explanation/ExplanationLogger.js +284 -0
  86. package/dist/explanation/ExplanationLogger.js.map +1 -0
  87. package/dist/explanation/ExplanationTypes.d.ts +252 -0
  88. package/dist/explanation/ExplanationTypes.d.ts.map +1 -0
  89. package/dist/explanation/ExplanationTypes.js +10 -0
  90. package/dist/explanation/ExplanationTypes.js.map +1 -0
  91. package/dist/explanation/index.d.ts +12 -0
  92. package/dist/explanation/index.d.ts.map +1 -0
  93. package/dist/explanation/index.js +11 -0
  94. package/dist/explanation/index.js.map +1 -0
  95. package/dist/hooks/HookManager.d.ts.map +1 -1
  96. package/dist/hooks/HookManager.js +8 -0
  97. package/dist/hooks/HookManager.js.map +1 -1
  98. package/dist/index.d.ts +3 -0
  99. package/dist/index.d.ts.map +1 -1
  100. package/dist/index.js +2 -0
  101. package/dist/index.js.map +1 -1
  102. package/dist/lifecycle/ShutdownManager.d.ts.map +1 -1
  103. package/dist/lifecycle/ShutdownManager.js +22 -9
  104. package/dist/lifecycle/ShutdownManager.js.map +1 -1
  105. package/dist/lifecycle/StartupManager.d.ts.map +1 -1
  106. package/dist/lifecycle/StartupManager.js +16 -5
  107. package/dist/lifecycle/StartupManager.js.map +1 -1
  108. package/dist/loader/WorkflowLoader.d.ts +83 -21
  109. package/dist/loader/WorkflowLoader.d.ts.map +1 -1
  110. package/dist/loader/WorkflowLoader.js +169 -55
  111. package/dist/loader/WorkflowLoader.js.map +1 -1
  112. package/dist/logging/EngineLogger.d.ts +492 -0
  113. package/dist/logging/EngineLogger.d.ts.map +1 -0
  114. package/dist/logging/EngineLogger.js +1170 -0
  115. package/dist/logging/EngineLogger.js.map +1 -0
  116. package/dist/logging/LoggerManager.d.ts +49 -0
  117. package/dist/logging/LoggerManager.d.ts.map +1 -0
  118. package/dist/logging/LoggerManager.js +94 -0
  119. package/dist/logging/LoggerManager.js.map +1 -0
  120. package/dist/logging/index.d.ts +2 -1
  121. package/dist/logging/index.d.ts.map +1 -1
  122. package/dist/logging/index.js +2 -3
  123. package/dist/logging/index.js.map +1 -1
  124. package/dist/parser/SchemaValidator.d.ts.map +1 -1
  125. package/dist/parser/SchemaValidator.js +8 -1
  126. package/dist/parser/SchemaValidator.js.map +1 -1
  127. package/dist/parser/StepParser.d.ts +6 -1
  128. package/dist/parser/StepParser.d.ts.map +1 -1
  129. package/dist/parser/StepParser.js +14 -1
  130. package/dist/parser/StepParser.js.map +1 -1
  131. package/dist/parser/WorkflowParser.d.ts.map +1 -1
  132. package/dist/parser/WorkflowParser.js +53 -28
  133. package/dist/parser/WorkflowParser.js.map +1 -1
  134. package/dist/scheduling/ScheduleParser.d.ts.map +1 -1
  135. package/dist/scheduling/ScheduleParser.js +7 -0
  136. package/dist/scheduling/ScheduleParser.js.map +1 -1
  137. package/dist/scheduling/Scheduler.d.ts.map +1 -1
  138. package/dist/scheduling/Scheduler.js +13 -0
  139. package/dist/scheduling/Scheduler.js.map +1 -1
  140. package/dist/types/log-types.d.ts +105 -0
  141. package/dist/types/log-types.d.ts.map +1 -0
  142. package/dist/types/log-types.js +42 -0
  143. package/dist/types/log-types.js.map +1 -0
  144. package/package.json +1 -1
  145. package/dist/core/EngineLogger.d.ts +0 -182
  146. package/dist/core/EngineLogger.d.ts.map +0 -1
  147. package/dist/core/EngineLogger.js +0 -293
  148. package/dist/core/EngineLogger.js.map +0 -1
  149. package/dist/logging/LogLevel.d.ts +0 -2
  150. package/dist/logging/LogLevel.d.ts.map +0 -1
  151. package/dist/logging/LogLevel.js +0 -2
  152. package/dist/logging/LogLevel.js.map +0 -1
  153. package/dist/logging/Logger.d.ts +0 -2
  154. package/dist/logging/Logger.d.ts.map +0 -1
  155. package/dist/logging/Logger.js +0 -2
  156. package/dist/logging/Logger.js.map +0 -1
@@ -0,0 +1,370 @@
1
+ /**
2
+ * Error Detector (Smart Error Classification)
3
+ *
4
+ * Automatically detects error types and assigns correct error codes.
5
+ * Makes the engine smart enough to classify errors without manual coding.
6
+ * Also enriches errors with debug information for developers.
7
+ *
8
+ * PHILOSOPHY:
9
+ * ==========
10
+ * Instead of manually throwing specific error codes everywhere,
11
+ * the detector analyzes the error context and assigns the right code.
12
+ * Debug information is automatically attached at detection time.
13
+ *
14
+ * USAGE:
15
+ * ======
16
+ * ```typescript
17
+ * // Instead of manual classification:
18
+ * if (field === 'version') {
19
+ * throw SchemaError.missingField('version', 'workflow');
20
+ * }
21
+ *
22
+ * // Let detector classify automatically:
23
+ * const error = ErrorDetector.detect({
24
+ * type: 'missing_field',
25
+ * field: 'version',
26
+ * location: 'workflow'
27
+ * });
28
+ * throw error; // Already has debug info attached!
29
+ * ```
30
+ *
31
+ * @module errors/detector
32
+ */
33
+ import { SchemaError, ValidationError } from './WorkflowError.js';
34
+ import { StepError } from './StepError.js';
35
+ import { SecurityError } from './SecurityErrors.js';
36
+ import { ErrorDebugger } from './ErrorDebugger.js';
37
+ import { RESERVED_WORKFLOW_FIELDS, RESERVED_CONTEXT_FIELDS, RESERVED_STEP_FIELDS, RESERVED_ANNOTATION_PREFIXES, ROOT_FIELDS, WORKFLOW_FIELDS, STEP_FIELDS, CONTEXT_FIELDS, METADATA_FIELDS } from './FieldRegistry.js';
38
+ import { findClosestMatch } from './TypoDetector.js';
39
+ import { LoggerManager } from '../logging/LoggerManager.js';
40
+ /**
41
+ * Error Detector
42
+ *
43
+ * Smart system that analyzes error context and produces correct OrbytError.
44
+ */
45
+ export class ErrorDetector {
46
+ /**
47
+ * Detect and create appropriate error from context
48
+ *
49
+ * @param context - Error context with information about what went wrong
50
+ * @returns Properly classified OrbytError
51
+ *
52
+ * @example
53
+ * ```typescript
54
+ * const error = ErrorDetector.detect({
55
+ * type: 'missing_field',
56
+ * field: 'version',
57
+ * location: 'workflow'
58
+ * });
59
+ * ```
60
+ */
61
+ /**
62
+ * Detect error from context and enrich with debug information
63
+ *
64
+ * This is the main entry point for error detection.
65
+ * All detected errors are automatically enriched with debug info.
66
+ *
67
+ * @param context - Error context
68
+ * @returns OrbytError with debug info attached
69
+ */
70
+ static detect(context) {
71
+ const logger = LoggerManager.getLogger();
72
+ let error;
73
+ logger.debug(`[ErrorDetector] Detecting error type: ${context.type}`, {
74
+ scenario: context.type,
75
+ field: context.field,
76
+ location: context.location,
77
+ });
78
+ // Auto-detect reserved fields
79
+ if (context.field && this.isReservedField(context.field)) {
80
+ error = this.handleReservedField(context);
81
+ logger.error(`[ErrorDetector] Reserved field detected: ${context.field}`, error, {
82
+ field: context.field,
83
+ location: context.location,
84
+ });
85
+ return this.enrichWithDebugInfo(error);
86
+ }
87
+ // Auto-detect reserved annotations
88
+ if (context.field && this.isReservedAnnotation(context.field)) {
89
+ error = SecurityError.reservedAnnotation(context.field, context.location || 'unknown');
90
+ logger.error(`[ErrorDetector] Reserved annotation detected: ${context.field}`, error);
91
+ return this.enrichWithDebugInfo(error);
92
+ }
93
+ // Dispatch to specific handlers based on scenario
94
+ switch (context.type) {
95
+ // Schema errors
96
+ case 'unknown_field':
97
+ error = this.handleUnknownField(context);
98
+ break;
99
+ case 'reserved_field':
100
+ error = this.handleReservedField(context);
101
+ break;
102
+ case 'invalid_type':
103
+ error = this.handleInvalidType(context);
104
+ break;
105
+ case 'missing_field':
106
+ error = this.handleMissingField(context);
107
+ break;
108
+ case 'invalid_enum':
109
+ error = this.handleInvalidEnum(context);
110
+ break;
111
+ case 'parse_error':
112
+ error = this.handleParseError(context);
113
+ break;
114
+ case 'invalid_adapter':
115
+ error = this.handleInvalidAdapter(context);
116
+ break;
117
+ // Validation errors
118
+ case 'duplicate_id':
119
+ error = this.handleDuplicateId(context);
120
+ break;
121
+ case 'unknown_step':
122
+ error = this.handleUnknownStep(context);
123
+ break;
124
+ case 'circular_dependency':
125
+ error = this.handleCircularDependency(context);
126
+ break;
127
+ case 'forward_reference':
128
+ error = this.handleForwardReference(context);
129
+ break;
130
+ case 'empty_workflow':
131
+ error = ValidationError.emptyWorkflow(context.location || 'workflow');
132
+ break;
133
+ case 'missing_input':
134
+ error = this.handleMissingInput(context);
135
+ break;
136
+ case 'invalid_condition':
137
+ error = this.handleInvalidCondition(context);
138
+ break;
139
+ case 'invalid_variable':
140
+ error = this.handleInvalidVariable(context);
141
+ break;
142
+ // Step errors
143
+ case 'step_not_found':
144
+ error = StepError.notFound(context.field || 'unknown', context.location || 'unknown');
145
+ break;
146
+ case 'step_timeout':
147
+ error = this.handleStepTimeout(context);
148
+ break;
149
+ case 'step_failed':
150
+ error = this.handleStepFailed(context);
151
+ break;
152
+ case 'step_dependency_failed':
153
+ error = this.handleStepDependencyFailed(context);
154
+ break;
155
+ case 'step_invalid_config':
156
+ error = this.handleStepInvalidConfig(context);
157
+ break;
158
+ // Security errors
159
+ case 'permission_denied':
160
+ error = this.handlePermissionDenied(context);
161
+ break;
162
+ // Unknown/generic
163
+ default:
164
+ error = this.handleUnknown(context);
165
+ }
166
+ // Enrich with debug information before returning
167
+ return this.enrichWithDebugInfo(error);
168
+ }
169
+ /**
170
+ * Detect error from raw exception
171
+ * Analyzes exception and tries to classify it
172
+ *
173
+ * @param error - Raw error/exception
174
+ * @param location - Where the error occurred
175
+ * @returns Classified OrbytError with debug info
176
+ */
177
+ static detectFromException(error, location) {
178
+ const message = error.message.toLowerCase();
179
+ const stack = error.stack;
180
+ // Try to detect error type from message
181
+ let scenario = 'unknown';
182
+ if (message.includes('yaml') || message.includes('parse') || message.includes('syntax')) {
183
+ scenario = 'parse_error';
184
+ }
185
+ else if (message.includes('unknown field') || message.includes('unexpected field')) {
186
+ scenario = 'unknown_field';
187
+ }
188
+ else if (message.includes('missing') || message.includes('required')) {
189
+ scenario = 'missing_field';
190
+ }
191
+ else if (message.includes('type') || message.includes('expected')) {
192
+ scenario = 'invalid_type';
193
+ }
194
+ else if (message.includes('circular') || message.includes('cycle')) {
195
+ scenario = 'circular_dependency';
196
+ }
197
+ else if (message.includes('duplicate')) {
198
+ scenario = 'duplicate_id';
199
+ }
200
+ else if (message.includes('timeout')) {
201
+ scenario = 'step_timeout';
202
+ }
203
+ else if (message.includes('permission') || message.includes('denied')) {
204
+ scenario = 'permission_denied';
205
+ }
206
+ // Use detect() which automatically enriches with debug info
207
+ return this.detect({
208
+ type: scenario,
209
+ location,
210
+ rawMessage: error.message,
211
+ stack,
212
+ });
213
+ }
214
+ // ==================== HELPER METHODS ====================
215
+ /**
216
+ * Check if field is reserved by engine
217
+ */
218
+ static isReservedField(field) {
219
+ return (RESERVED_WORKFLOW_FIELDS.includes(field) ||
220
+ RESERVED_CONTEXT_FIELDS.includes(field) ||
221
+ RESERVED_STEP_FIELDS.includes(field) ||
222
+ field.startsWith('_') ||
223
+ field.startsWith('__'));
224
+ }
225
+ /**
226
+ * Check if annotation uses reserved namespace
227
+ */
228
+ static isReservedAnnotation(annotation) {
229
+ return RESERVED_ANNOTATION_PREFIXES.some(prefix => annotation.startsWith(prefix));
230
+ }
231
+ /**
232
+ * Determine field type for security errors
233
+ */
234
+ static getFieldType(field) {
235
+ if (field.includes('billing') || field.includes('price') || field.includes('cost')) {
236
+ return 'billing';
237
+ }
238
+ if (field.includes('execution') || field.includes('run') || field.includes('workflow')) {
239
+ return 'execution';
240
+ }
241
+ if (field.includes('user') || field.includes('org') || field.includes('owner')) {
242
+ return 'identity';
243
+ }
244
+ if (field.includes('usage') || field.includes('counter') || field.includes('consumed')) {
245
+ return 'usage';
246
+ }
247
+ return 'internal';
248
+ }
249
+ // ==================== ERROR HANDLERS ====================
250
+ static handleUnknownField(context) {
251
+ const field = context.field || 'unknown';
252
+ const location = context.location || 'unknown';
253
+ // Get valid fields based on location
254
+ const validFields = this.getValidFieldsForLocation(location);
255
+ // Use TypoDetector to find closest match
256
+ const suggestion = findClosestMatch(field, validFields, 0.6);
257
+ return SchemaError.unknownField(field, location, suggestion);
258
+ }
259
+ /**
260
+ * Get valid field names based on location in workflow
261
+ */
262
+ static getValidFieldsForLocation(location) {
263
+ const locationLower = location.toLowerCase();
264
+ // Root level fields
265
+ if (locationLower === 'workflow' || locationLower.startsWith('workflow.')) {
266
+ if (locationLower.includes('steps[') || locationLower.includes('.step')) {
267
+ return [...STEP_FIELDS];
268
+ }
269
+ if (locationLower.includes('context')) {
270
+ return [...CONTEXT_FIELDS];
271
+ }
272
+ if (locationLower.includes('metadata')) {
273
+ return [...METADATA_FIELDS];
274
+ }
275
+ return [...ROOT_FIELDS, ...WORKFLOW_FIELDS];
276
+ }
277
+ // Step fields
278
+ if (locationLower.includes('step')) {
279
+ return [...STEP_FIELDS];
280
+ }
281
+ // Default: return all common fields
282
+ return [
283
+ ...ROOT_FIELDS,
284
+ ...WORKFLOW_FIELDS,
285
+ ...STEP_FIELDS,
286
+ ...CONTEXT_FIELDS,
287
+ ...METADATA_FIELDS
288
+ ];
289
+ }
290
+ static handleReservedField(context) {
291
+ const field = context.field || 'unknown';
292
+ const fieldType = this.getFieldType(field);
293
+ return SecurityError.reservedFieldOverride(field, context.location || 'unknown', fieldType);
294
+ }
295
+ static handleInvalidType(context) {
296
+ return SchemaError.invalidType(context.field || 'unknown', context.expected || 'unknown', context.actual || 'unknown', context.location || 'unknown');
297
+ }
298
+ static handleMissingField(context) {
299
+ return SchemaError.missingField(context.field || 'unknown', context.location || 'unknown');
300
+ }
301
+ static handleInvalidEnum(context) {
302
+ const validValues = context.data?.validValues || [];
303
+ return SchemaError.invalidEnum(context.field || 'unknown', context.actual || 'unknown', validValues, context.location || 'unknown');
304
+ }
305
+ static handleParseError(context) {
306
+ return SchemaError.parseError(context.location || 'unknown', context.data?.line, context.data?.column, context.rawMessage);
307
+ }
308
+ static handleInvalidAdapter(context) {
309
+ return SchemaError.invalidAdapter(context.field || context.actual || 'unknown', context.location || 'unknown', context.data?.validAdapters);
310
+ }
311
+ static handleDuplicateId(context) {
312
+ return ValidationError.duplicateId(context.field || 'unknown', context.location || 'unknown', context.data?.firstOccurrence);
313
+ }
314
+ static handleUnknownStep(context) {
315
+ return ValidationError.unknownStep(context.field || 'unknown', context.location || 'unknown', context.data?.availableSteps);
316
+ }
317
+ static handleCircularDependency(context) {
318
+ const cycle = context.data?.cycle || [context.field || 'unknown'];
319
+ return ValidationError.circularDependency(cycle, context.location || 'unknown');
320
+ }
321
+ static handleForwardReference(context) {
322
+ return ValidationError.forwardReference(context.field || 'unknown', context.data?.referencedStep || 'unknown', context.location || 'unknown');
323
+ }
324
+ static handleMissingInput(context) {
325
+ return ValidationError.missingInput(context.field || 'unknown', context.location || 'unknown');
326
+ }
327
+ static handleInvalidCondition(context) {
328
+ return ValidationError.invalidCondition(context.actual || context.rawMessage || 'unknown', context.location || 'unknown', context.data?.reason);
329
+ }
330
+ static handleInvalidVariable(context) {
331
+ return ValidationError.invalidVariable(context.field || 'unknown', context.location || 'unknown', context.data?.availableVars);
332
+ }
333
+ static handleStepTimeout(context) {
334
+ return StepError.timeout(context.field || 'unknown', context.location || 'unknown', context.data?.timeout);
335
+ }
336
+ static handleStepFailed(context) {
337
+ const error = context.rawMessage ? new Error(context.rawMessage) : new Error('Step execution failed');
338
+ return StepError.executionFailed(context.field || 'unknown', context.location || 'unknown', error, context.data?.exitCode);
339
+ }
340
+ static handleStepDependencyFailed(context) {
341
+ return StepError.dependencyFailed(context.field || 'unknown', context.data?.dependency || 'unknown', context.location || 'unknown');
342
+ }
343
+ static handleStepInvalidConfig(context) {
344
+ return StepError.invalidConfig(context.field || 'unknown', context.location || 'unknown', context.rawMessage);
345
+ }
346
+ static handlePermissionDenied(context) {
347
+ return SecurityError.permissionDenied(context.field || context.data?.resource || 'unknown', context.location || 'unknown', context.data?.requiredPermission);
348
+ }
349
+ static handleUnknown(context) {
350
+ // Create generic schema error for unknown cases
351
+ return SchemaError.parseError(context.location || 'unknown', undefined, undefined, context.rawMessage || 'Unknown error occurred');
352
+ }
353
+ /**
354
+ * Enrich error with debug information
355
+ *
356
+ * This is called automatically after error detection to attach
357
+ * detailed debug info including explanations, fix steps, examples, etc.
358
+ *
359
+ * @param error - Detected OrbytError
360
+ * @returns Same error with debug info attached (for console display)
361
+ * @private
362
+ */
363
+ static enrichWithDebugInfo(error) {
364
+ // Generate and store formatted debug output for console display
365
+ // This is done here so it's available when needed in WorkflowLoader
366
+ error.__debugOutput = ErrorDebugger.format(error);
367
+ return error;
368
+ }
369
+ }
370
+ //# sourceMappingURL=ErrorDetector.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ErrorDetector.js","sourceRoot":"","sources":["../../src/errors/ErrorDetector.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,oBAAoB,CAAC;AAClE,OAAO,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAC3C,OAAO,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,oBAAoB,CAAC;AACnD,OAAO,EACH,wBAAwB,EACxB,uBAAuB,EACvB,oBAAoB,EACpB,4BAA4B,EAC5B,WAAW,EACX,eAAe,EACf,WAAW,EACX,cAAc,EACd,eAAe,EAClB,MAAM,oBAAoB,CAAC;AAC5B,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,aAAa,EAAE,MAAM,6BAA6B,CAAC;AAsE5D;;;;GAIG;AACH,MAAM,OAAO,aAAa;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C,CAAC;QAE3D,OAAO,KAAK,CAAC;IACjB,CAAC;CACJ"}
@@ -2,27 +2,74 @@
2
2
  * Error Formatter
3
3
  *
4
4
  * Formats Orbyt errors for CLI display with colors and helpful formatting.
5
- * Provides human-readable error output for developers.
5
+ * Provides human-readable error output for developers with:
6
+ * - Colored output for severity levels
7
+ * - Exit code information
8
+ * - Error category and retryability
9
+ * - Contextual debugging information
10
+ * - Integration with EngineLogger for proper log management
11
+ *
12
+ * USAGE:
13
+ * =====
14
+ * ```typescript
15
+ * // Format single error
16
+ * const formatted = formatError(error);
17
+ * console.error(formatted);
18
+ *
19
+ * // Format multiple errors
20
+ * const formatted = formatErrors(errors);
21
+ * console.error(formatted);
22
+ *
23
+ * // Detailed format with all diagnostics
24
+ * const detailed = formatDetailedError(error);
25
+ * console.error(detailed);
26
+ *
27
+ * // Log error using EngineLogger
28
+ * logErrorToEngine(error, logger);
29
+ * ```
6
30
  *
7
31
  * @module errors
8
32
  */
9
33
  import { OrbytError } from './OrbytError.js';
34
+ import { ErrorSeverity } from './ErrorCodes.js';
35
+ import type { EngineLogger } from '../logging/EngineLogger.js';
36
+ import { LogLevel } from '@dev-ecosystem/core';
10
37
  /**
11
38
  * Format error for CLI display
12
39
  *
13
40
  * @param error - Orbyt error to format
14
41
  * @param useColors - Whether to use ANSI colors (default: true)
42
+ * @param verbose - Show additional diagnostic info (default: false)
15
43
  * @returns Formatted error string
16
44
  */
17
- export declare function formatError(error: OrbytError, useColors?: boolean): string;
45
+ export declare function formatError(error: OrbytError, useColors?: boolean, verbose?: boolean): string;
18
46
  /**
19
47
  * Format multiple errors for CLI display
20
48
  *
21
49
  * @param errors - Array of Orbyt errors
22
50
  * @param useColors - Whether to use ANSI colors
51
+ * @param verbose - Show additional diagnostic info
23
52
  * @returns Formatted errors string
24
53
  */
25
- export declare function formatErrors(errors: OrbytError[], useColors?: boolean): string;
54
+ export declare function formatErrors(errors: OrbytError[], useColors?: boolean, verbose?: boolean): string;
55
+ /**
56
+ * Format error with full diagnostic information
57
+ * Useful for debugging and detailed error analysis
58
+ *
59
+ * @param error - Orbyt error to format
60
+ * @param useColors - Whether to use ANSI colors
61
+ * @returns Detailed formatted error string
62
+ */
63
+ export declare function formatDetailedError(error: OrbytError, useColors?: boolean): string;
64
+ /**
65
+ * Format error summary (one-line format)
66
+ * Useful for logging or compact display
67
+ *
68
+ * @param error - Orbyt error to format
69
+ * @param useColors - Whether to use ANSI colors
70
+ * @returns One-line error summary
71
+ */
72
+ export declare function formatErrorSummary(error: OrbytError, useColors?: boolean): string;
26
73
  /**
27
74
  * Create a simple box around text (for emphasis)
28
75
  *
@@ -31,4 +78,46 @@ export declare function formatErrors(errors: OrbytError[], useColors?: boolean):
31
78
  * @returns Boxed text string
32
79
  */
33
80
  export declare function createBox(text: string, useColors?: boolean): string;
81
+ /**
82
+ * Map ErrorSeverity to LogLevel
83
+ * Converts Orbyt's error severity to ecosystem-core's log level
84
+ *
85
+ * @param severity - Error severity
86
+ * @returns Corresponding log level
87
+ */
88
+ export declare function errorSeverityToLogLevel(severity: ErrorSeverity): LogLevel;
89
+ /**
90
+ * Log an error to EngineLogger with proper formatting
91
+ *
92
+ * This is the primary way to log errors during workflow loading and execution.
93
+ * It maps Orbyt's ErrorSeverity to ecosystem-core's LogLevel and includes
94
+ * all relevant context.
95
+ *
96
+ * @param error - Orbyt error to log
97
+ * @param logger - EngineLogger instance
98
+ * @param includeDebugInfo - Whether to include full diagnostic info (default: true)
99
+ */
100
+ export declare function logErrorToEngine(error: OrbytError, logger: EngineLogger, includeDebugInfo?: boolean): void;
101
+ /**
102
+ * Log multiple errors to EngineLogger
103
+ *
104
+ * @param errors - Array of Orbyt errors
105
+ * @param logger - EngineLogger instance
106
+ * @param includeDebugInfo - Whether to include full diagnostic info
107
+ */
108
+ export declare function logErrorsToEngine(errors: OrbytError[], logger: EngineLogger, includeDebugInfo?: boolean): void;
109
+ /**
110
+ * Format and log error (combined operation)
111
+ * Returns formatted string AND logs to EngineLogger if provided
112
+ *
113
+ * @param error - Orbyt error
114
+ * @param logger - Optional EngineLogger instance
115
+ * @param options - Formatting options
116
+ * @returns Formatted error string
117
+ */
118
+ export declare function formatAndLogError(error: OrbytError, logger?: EngineLogger, options?: {
119
+ useColors?: boolean;
120
+ verbose?: boolean;
121
+ includeDebugInfo?: boolean;
122
+ }): string;
34
123
  //# sourceMappingURL=ErrorFormatter.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"ErrorFormatter.d.ts","sourceRoot":"","sources":["../../src/errors/ErrorFormatter.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAkB7C;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,KAAK,EAAE,UAAU,EAAE,SAAS,GAAE,OAAc,GAAG,MAAM,CAwChF;AAED;;;;;;GAMG;AACH,wBAAgB,YAAY,CAAC,MAAM,EAAE,UAAU,EAAE,EAAE,SAAS,GAAE,OAAc,GAAG,MAAM,CA6BpF;AAqCD;;;;;;GAMG;AACH,wBAAgB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,SAAS,GAAE,OAAc,GAAG,MAAM,CAazE"}
1
+ {"version":3,"file":"ErrorFormatter.d.ts","sourceRoot":"","sources":["../../src/errors/ErrorFormatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAChD,OAAO,KAAK,EAAE,YAAY,EAAE,MAAM,4BAA4B,CAAC;AAC/D,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAiB/C;;;;;;;GAOG;AACH,wBAAgB,WAAW,CACzB,KAAK,EAAE,UAAU,EACjB,SAAS,GAAE,OAAc,EACzB,OAAO,GAAE,OAAe,GACvB,MAAM,CA6DR;AAED;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