@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.
- package/README.md +1 -1
- package/dist/adapters/AdapterRegistry.d.ts.map +1 -1
- package/dist/adapters/AdapterRegistry.js +6 -0
- package/dist/adapters/AdapterRegistry.js.map +1 -1
- package/dist/context/VariableResolver.d.ts.map +1 -1
- package/dist/context/VariableResolver.js +7 -0
- package/dist/context/VariableResolver.js.map +1 -1
- package/dist/core/OrbytEngine.d.ts +19 -0
- package/dist/core/OrbytEngine.d.ts.map +1 -1
- package/dist/core/OrbytEngine.js +79 -3
- package/dist/core/OrbytEngine.js.map +1 -1
- package/dist/core/index.d.ts +1 -1
- package/dist/core/index.d.ts.map +1 -1
- package/dist/core/index.js +1 -1
- package/dist/core/index.js.map +1 -1
- package/dist/errors/ErrorCodes.d.ts +205 -6
- package/dist/errors/ErrorCodes.d.ts.map +1 -1
- package/dist/errors/ErrorCodes.js +398 -5
- package/dist/errors/ErrorCodes.js.map +1 -1
- package/dist/errors/ErrorDebugger.d.ts +98 -0
- package/dist/errors/ErrorDebugger.d.ts.map +1 -0
- package/dist/errors/ErrorDebugger.js +290 -0
- package/dist/errors/ErrorDebugger.js.map +1 -0
- package/dist/errors/ErrorDetector.d.ts +148 -0
- package/dist/errors/ErrorDetector.d.ts.map +1 -0
- package/dist/errors/ErrorDetector.js +370 -0
- package/dist/errors/ErrorDetector.js.map +1 -0
- package/dist/errors/ErrorFormatter.d.ts +92 -3
- package/dist/errors/ErrorFormatter.d.ts.map +1 -1
- package/dist/errors/ErrorFormatter.js +220 -4
- package/dist/errors/ErrorFormatter.js.map +1 -1
- package/dist/errors/ErrorHandler.d.ts +259 -0
- package/dist/errors/ErrorHandler.d.ts.map +1 -0
- package/dist/errors/ErrorHandler.js +378 -0
- package/dist/errors/ErrorHandler.js.map +1 -0
- package/dist/errors/FieldRegistry.d.ts +39 -0
- package/dist/errors/FieldRegistry.d.ts.map +1 -1
- package/dist/errors/FieldRegistry.js +172 -74
- package/dist/errors/FieldRegistry.js.map +1 -1
- package/dist/errors/OrbytError.d.ts +85 -3
- package/dist/errors/OrbytError.d.ts.map +1 -1
- package/dist/errors/OrbytError.js +151 -4
- package/dist/errors/OrbytError.js.map +1 -1
- package/dist/errors/SchedulerError.d.ts +93 -1
- package/dist/errors/SchedulerError.d.ts.map +1 -1
- package/dist/errors/SchedulerError.js +145 -1
- package/dist/errors/SchedulerError.js.map +1 -1
- package/dist/errors/SecurityErrors.d.ts +94 -12
- package/dist/errors/SecurityErrors.d.ts.map +1 -1
- package/dist/errors/SecurityErrors.js +162 -18
- package/dist/errors/SecurityErrors.js.map +1 -1
- package/dist/errors/StepError.d.ts +111 -1
- package/dist/errors/StepError.d.ts.map +1 -1
- package/dist/errors/StepError.js +182 -1
- package/dist/errors/StepError.js.map +1 -1
- package/dist/errors/WorkflowError.d.ts +139 -2
- package/dist/errors/WorkflowError.d.ts.map +1 -1
- package/dist/errors/WorkflowError.js +264 -22
- package/dist/errors/WorkflowError.js.map +1 -1
- package/dist/errors/index.d.ts +5 -1
- package/dist/errors/index.d.ts.map +1 -1
- package/dist/errors/index.js +7 -4
- package/dist/errors/index.js.map +1 -1
- package/dist/execution/ExecutionEngine.d.ts.map +1 -1
- package/dist/execution/ExecutionEngine.js +36 -6
- package/dist/execution/ExecutionEngine.js.map +1 -1
- package/dist/execution/ExecutionPlan.d.ts.map +1 -1
- package/dist/execution/ExecutionPlan.js +21 -1
- package/dist/execution/ExecutionPlan.js.map +1 -1
- package/dist/execution/IntentAnalyzer.d.ts.map +1 -1
- package/dist/execution/IntentAnalyzer.js +20 -0
- package/dist/execution/IntentAnalyzer.js.map +1 -1
- package/dist/execution/StepExecutor.d.ts.map +1 -1
- package/dist/execution/StepExecutor.js +109 -29
- package/dist/execution/StepExecutor.js.map +1 -1
- package/dist/execution/WorkflowExecutor.d.ts.map +1 -1
- package/dist/execution/WorkflowExecutor.js +31 -0
- package/dist/execution/WorkflowExecutor.js.map +1 -1
- package/dist/explanation/ExplanationGenerator.d.ts +105 -0
- package/dist/explanation/ExplanationGenerator.d.ts.map +1 -0
- package/dist/explanation/ExplanationGenerator.js +814 -0
- package/dist/explanation/ExplanationGenerator.js.map +1 -0
- package/dist/explanation/ExplanationLogger.d.ts +50 -0
- package/dist/explanation/ExplanationLogger.d.ts.map +1 -0
- package/dist/explanation/ExplanationLogger.js +284 -0
- package/dist/explanation/ExplanationLogger.js.map +1 -0
- package/dist/explanation/ExplanationTypes.d.ts +252 -0
- package/dist/explanation/ExplanationTypes.d.ts.map +1 -0
- package/dist/explanation/ExplanationTypes.js +10 -0
- package/dist/explanation/ExplanationTypes.js.map +1 -0
- package/dist/explanation/index.d.ts +12 -0
- package/dist/explanation/index.d.ts.map +1 -0
- package/dist/explanation/index.js +11 -0
- package/dist/explanation/index.js.map +1 -0
- package/dist/hooks/HookManager.d.ts.map +1 -1
- package/dist/hooks/HookManager.js +8 -0
- package/dist/hooks/HookManager.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -0
- package/dist/index.js.map +1 -1
- package/dist/lifecycle/ShutdownManager.d.ts.map +1 -1
- package/dist/lifecycle/ShutdownManager.js +22 -9
- package/dist/lifecycle/ShutdownManager.js.map +1 -1
- package/dist/lifecycle/StartupManager.d.ts.map +1 -1
- package/dist/lifecycle/StartupManager.js +16 -5
- package/dist/lifecycle/StartupManager.js.map +1 -1
- package/dist/loader/WorkflowLoader.d.ts +83 -21
- package/dist/loader/WorkflowLoader.d.ts.map +1 -1
- package/dist/loader/WorkflowLoader.js +169 -55
- package/dist/loader/WorkflowLoader.js.map +1 -1
- package/dist/logging/EngineLogger.d.ts +492 -0
- package/dist/logging/EngineLogger.d.ts.map +1 -0
- package/dist/logging/EngineLogger.js +1170 -0
- package/dist/logging/EngineLogger.js.map +1 -0
- package/dist/logging/LoggerManager.d.ts +49 -0
- package/dist/logging/LoggerManager.d.ts.map +1 -0
- package/dist/logging/LoggerManager.js +94 -0
- package/dist/logging/LoggerManager.js.map +1 -0
- package/dist/logging/index.d.ts +2 -1
- package/dist/logging/index.d.ts.map +1 -1
- package/dist/logging/index.js +2 -3
- package/dist/logging/index.js.map +1 -1
- package/dist/parser/SchemaValidator.d.ts.map +1 -1
- package/dist/parser/SchemaValidator.js +8 -1
- package/dist/parser/SchemaValidator.js.map +1 -1
- package/dist/parser/StepParser.d.ts +6 -1
- package/dist/parser/StepParser.d.ts.map +1 -1
- package/dist/parser/StepParser.js +14 -1
- package/dist/parser/StepParser.js.map +1 -1
- package/dist/parser/WorkflowParser.d.ts.map +1 -1
- package/dist/parser/WorkflowParser.js +53 -28
- package/dist/parser/WorkflowParser.js.map +1 -1
- package/dist/scheduling/ScheduleParser.d.ts.map +1 -1
- package/dist/scheduling/ScheduleParser.js +7 -0
- package/dist/scheduling/ScheduleParser.js.map +1 -1
- package/dist/scheduling/Scheduler.d.ts.map +1 -1
- package/dist/scheduling/Scheduler.js +13 -0
- package/dist/scheduling/Scheduler.js.map +1 -1
- package/dist/types/log-types.d.ts +105 -0
- package/dist/types/log-types.d.ts.map +1 -0
- package/dist/types/log-types.js +42 -0
- package/dist/types/log-types.js.map +1 -0
- package/package.json +1 -1
- package/dist/core/EngineLogger.d.ts +0 -182
- package/dist/core/EngineLogger.d.ts.map +0 -1
- package/dist/core/EngineLogger.js +0 -293
- package/dist/core/EngineLogger.js.map +0 -1
- package/dist/logging/LogLevel.d.ts +0 -2
- package/dist/logging/LogLevel.d.ts.map +0 -1
- package/dist/logging/LogLevel.js +0 -2
- package/dist/logging/LogLevel.js.map +0 -1
- package/dist/logging/Logger.d.ts +0 -2
- package/dist/logging/Logger.d.ts.map +0 -1
- package/dist/logging/Logger.js +0 -2
- package/dist/logging/Logger.js.map +0 -1
|
@@ -2,11 +2,36 @@
|
|
|
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 { ErrorSeverity } from './ErrorCodes.js';
|
|
34
|
+
import { LogLevel } from '@dev-ecosystem/core';
|
|
10
35
|
/**
|
|
11
36
|
* ANSI color codes for terminal output
|
|
12
37
|
*/
|
|
@@ -25,9 +50,10 @@ const colors = {
|
|
|
25
50
|
*
|
|
26
51
|
* @param error - Orbyt error to format
|
|
27
52
|
* @param useColors - Whether to use ANSI colors (default: true)
|
|
53
|
+
* @param verbose - Show additional diagnostic info (default: false)
|
|
28
54
|
* @returns Formatted error string
|
|
29
55
|
*/
|
|
30
|
-
export function formatError(error, useColors = true) {
|
|
56
|
+
export function formatError(error, useColors = true, verbose = false) {
|
|
31
57
|
const c = useColors ? colors : {
|
|
32
58
|
reset: '',
|
|
33
59
|
bold: '',
|
|
@@ -56,6 +82,26 @@ export function formatError(error, useColors = true) {
|
|
|
56
82
|
lines.push('');
|
|
57
83
|
lines.push(`${c.blue}\u2192 Hint:${c.reset} ${error.hint}`);
|
|
58
84
|
}
|
|
85
|
+
// Verbose mode: show additional diagnostics
|
|
86
|
+
if (verbose) {
|
|
87
|
+
lines.push('');
|
|
88
|
+
lines.push(`${c.dim}Exit Code:${c.reset} ${error.exitCode} (${error.getExitCodeDescription()})`);
|
|
89
|
+
lines.push(`${c.dim}Category:${c.reset} ${error.category}`);
|
|
90
|
+
const flags = [];
|
|
91
|
+
if (error.isUserError)
|
|
92
|
+
flags.push('User-fixable');
|
|
93
|
+
if (error.isRetryable)
|
|
94
|
+
flags.push('Retryable');
|
|
95
|
+
if (flags.length > 0) {
|
|
96
|
+
lines.push(`${c.dim}Flags:${c.reset} ${flags.join(', ')}`);
|
|
97
|
+
}
|
|
98
|
+
// Show context if available
|
|
99
|
+
if (error.diagnostic.context && Object.keys(error.diagnostic.context).length > 0) {
|
|
100
|
+
lines.push('');
|
|
101
|
+
lines.push(`${c.dim}Context:${c.reset}`);
|
|
102
|
+
lines.push(c.gray + JSON.stringify(error.diagnostic.context, null, 2) + c.reset);
|
|
103
|
+
}
|
|
104
|
+
}
|
|
59
105
|
return lines.join('\n');
|
|
60
106
|
}
|
|
61
107
|
/**
|
|
@@ -63,9 +109,10 @@ export function formatError(error, useColors = true) {
|
|
|
63
109
|
*
|
|
64
110
|
* @param errors - Array of Orbyt errors
|
|
65
111
|
* @param useColors - Whether to use ANSI colors
|
|
112
|
+
* @param verbose - Show additional diagnostic info
|
|
66
113
|
* @returns Formatted errors string
|
|
67
114
|
*/
|
|
68
|
-
export function formatErrors(errors, useColors = true) {
|
|
115
|
+
export function formatErrors(errors, useColors = true, verbose = false) {
|
|
69
116
|
const c = useColors ? colors : {
|
|
70
117
|
reset: '',
|
|
71
118
|
bold: '',
|
|
@@ -87,10 +134,67 @@ export function formatErrors(errors, useColors = true) {
|
|
|
87
134
|
lines.push(c.dim + '\u2500'.repeat(50) + c.reset);
|
|
88
135
|
lines.push('');
|
|
89
136
|
}
|
|
90
|
-
lines.push(formatError(error, useColors));
|
|
137
|
+
lines.push(formatError(error, useColors, verbose));
|
|
91
138
|
});
|
|
92
139
|
return lines.join('\n');
|
|
93
140
|
}
|
|
141
|
+
/**
|
|
142
|
+
* Format error with full diagnostic information
|
|
143
|
+
* Useful for debugging and detailed error analysis
|
|
144
|
+
*
|
|
145
|
+
* @param error - Orbyt error to format
|
|
146
|
+
* @param useColors - Whether to use ANSI colors
|
|
147
|
+
* @returns Detailed formatted error string
|
|
148
|
+
*/
|
|
149
|
+
export function formatDetailedError(error, useColors = true) {
|
|
150
|
+
const c = useColors ? colors : {
|
|
151
|
+
reset: '',
|
|
152
|
+
bold: '',
|
|
153
|
+
dim: '',
|
|
154
|
+
red: '',
|
|
155
|
+
yellow: '',
|
|
156
|
+
blue: '',
|
|
157
|
+
cyan: '',
|
|
158
|
+
gray: '',
|
|
159
|
+
};
|
|
160
|
+
// Use OrbytError's toDetailedString for comprehensive output
|
|
161
|
+
const detailed = error.toDetailedString();
|
|
162
|
+
// Colorize the output
|
|
163
|
+
if (useColors) {
|
|
164
|
+
return detailed
|
|
165
|
+
.replace(/\[ERROR\]/g, `${c.red}[ERROR]${c.reset}`)
|
|
166
|
+
.replace(/\[WARNING\]/g, `${c.yellow}[WARNING]${c.reset}`)
|
|
167
|
+
.replace(/\[INFO\]/g, `${c.blue}[INFO]${c.reset}`)
|
|
168
|
+
.replace(/Exit Code:/g, `${c.bold}Exit Code:${c.reset}`)
|
|
169
|
+
.replace(/Description:/g, `${c.bold}Description:${c.reset}`)
|
|
170
|
+
.replace(/Hint:/g, `${c.blue}Hint:${c.reset}`)
|
|
171
|
+
.replace(/Path:/g, `${c.cyan}Path:${c.reset}`)
|
|
172
|
+
.replace(/Context:/g, `${c.dim}Context:${c.reset}`);
|
|
173
|
+
}
|
|
174
|
+
return detailed;
|
|
175
|
+
}
|
|
176
|
+
/**
|
|
177
|
+
* Format error summary (one-line format)
|
|
178
|
+
* Useful for logging or compact display
|
|
179
|
+
*
|
|
180
|
+
* @param error - Orbyt error to format
|
|
181
|
+
* @param useColors - Whether to use ANSI colors
|
|
182
|
+
* @returns One-line error summary
|
|
183
|
+
*/
|
|
184
|
+
export function formatErrorSummary(error, useColors = true) {
|
|
185
|
+
const c = useColors ? colors : {
|
|
186
|
+
reset: '',
|
|
187
|
+
bold: '',
|
|
188
|
+
red: '',
|
|
189
|
+
yellow: '',
|
|
190
|
+
blue: '',
|
|
191
|
+
gray: '',
|
|
192
|
+
};
|
|
193
|
+
const color = getSeverityColor(error.severity, c);
|
|
194
|
+
const icon = getSeverityIcon(error.severity);
|
|
195
|
+
const path = error.path ? ` at ${error.path}` : '';
|
|
196
|
+
return `${color}${icon} ${error.code}${c.reset}${path}: ${c.bold}${error.message}${c.reset}`;
|
|
197
|
+
}
|
|
94
198
|
/**
|
|
95
199
|
* Get icon for error severity
|
|
96
200
|
*/
|
|
@@ -137,4 +241,116 @@ export function createBox(text, useColors = true) {
|
|
|
137
241
|
const boxedLines = lines.map(line => `${c.dim}\u2502${c.reset} ${line.padEnd(maxLength)} ${c.dim}\u2502${c.reset}`);
|
|
138
242
|
return [top, ...boxedLines, bottom].join('\n');
|
|
139
243
|
}
|
|
244
|
+
/**
|
|
245
|
+
* Map ErrorSeverity to LogLevel
|
|
246
|
+
* Converts Orbyt's error severity to ecosystem-core's log level
|
|
247
|
+
*
|
|
248
|
+
* @param severity - Error severity
|
|
249
|
+
* @returns Corresponding log level
|
|
250
|
+
*/
|
|
251
|
+
export function errorSeverityToLogLevel(severity) {
|
|
252
|
+
switch (severity) {
|
|
253
|
+
case ErrorSeverity.CRITICAL:
|
|
254
|
+
case ErrorSeverity.FATAL:
|
|
255
|
+
return LogLevel.FATAL;
|
|
256
|
+
case ErrorSeverity.ERROR:
|
|
257
|
+
return LogLevel.ERROR;
|
|
258
|
+
case ErrorSeverity.MEDIUM:
|
|
259
|
+
case ErrorSeverity.LOW:
|
|
260
|
+
case ErrorSeverity.WARNING:
|
|
261
|
+
return LogLevel.WARN;
|
|
262
|
+
case ErrorSeverity.INFO:
|
|
263
|
+
return LogLevel.INFO;
|
|
264
|
+
default:
|
|
265
|
+
return LogLevel.ERROR;
|
|
266
|
+
}
|
|
267
|
+
}
|
|
268
|
+
/**
|
|
269
|
+
* Log an error to EngineLogger with proper formatting
|
|
270
|
+
*
|
|
271
|
+
* This is the primary way to log errors during workflow loading and execution.
|
|
272
|
+
* It maps Orbyt's ErrorSeverity to ecosystem-core's LogLevel and includes
|
|
273
|
+
* all relevant context.
|
|
274
|
+
*
|
|
275
|
+
* @param error - Orbyt error to log
|
|
276
|
+
* @param logger - EngineLogger instance
|
|
277
|
+
* @param includeDebugInfo - Whether to include full diagnostic info (default: true)
|
|
278
|
+
*/
|
|
279
|
+
export function logErrorToEngine(error, logger, includeDebugInfo = true) {
|
|
280
|
+
const logLevel = errorSeverityToLogLevel(error.severity);
|
|
281
|
+
// Build context with error details
|
|
282
|
+
const context = {
|
|
283
|
+
errorCode: error.code,
|
|
284
|
+
exitCode: error.exitCode,
|
|
285
|
+
category: error.category,
|
|
286
|
+
severity: error.severity,
|
|
287
|
+
userError: error.isUserError,
|
|
288
|
+
retryable: error.isRetryable,
|
|
289
|
+
};
|
|
290
|
+
// Add path if available
|
|
291
|
+
if (error.path) {
|
|
292
|
+
context.path = error.path;
|
|
293
|
+
}
|
|
294
|
+
// Add hint if available
|
|
295
|
+
if (error.hint) {
|
|
296
|
+
context.hint = error.hint;
|
|
297
|
+
}
|
|
298
|
+
// Add diagnostic context
|
|
299
|
+
if (includeDebugInfo && error.diagnostic.context) {
|
|
300
|
+
context.diagnostic = error.diagnostic.context;
|
|
301
|
+
}
|
|
302
|
+
// Log based on severity
|
|
303
|
+
switch (logLevel) {
|
|
304
|
+
case LogLevel.FATAL:
|
|
305
|
+
logger.fatal(error.message, error, context);
|
|
306
|
+
break;
|
|
307
|
+
case LogLevel.ERROR:
|
|
308
|
+
logger.error(error.message, error, context);
|
|
309
|
+
break;
|
|
310
|
+
case LogLevel.WARN:
|
|
311
|
+
logger.warn(error.message, context);
|
|
312
|
+
break;
|
|
313
|
+
case LogLevel.INFO:
|
|
314
|
+
logger.info(error.message, context);
|
|
315
|
+
break;
|
|
316
|
+
default:
|
|
317
|
+
logger.error(error.message, error, context);
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
/**
|
|
321
|
+
* Log multiple errors to EngineLogger
|
|
322
|
+
*
|
|
323
|
+
* @param errors - Array of Orbyt errors
|
|
324
|
+
* @param logger - EngineLogger instance
|
|
325
|
+
* @param includeDebugInfo - Whether to include full diagnostic info
|
|
326
|
+
*/
|
|
327
|
+
export function logErrorsToEngine(errors, logger, includeDebugInfo = true) {
|
|
328
|
+
// Log summary first
|
|
329
|
+
logger.error(`Found ${errors.length} error(s) during workflow processing`, undefined, {
|
|
330
|
+
errorCount: errors.length,
|
|
331
|
+
errorCodes: errors.map(e => e.code),
|
|
332
|
+
});
|
|
333
|
+
// Log each error
|
|
334
|
+
errors.forEach((error) => {
|
|
335
|
+
logErrorToEngine(error, logger, includeDebugInfo);
|
|
336
|
+
});
|
|
337
|
+
}
|
|
338
|
+
/**
|
|
339
|
+
* Format and log error (combined operation)
|
|
340
|
+
* Returns formatted string AND logs to EngineLogger if provided
|
|
341
|
+
*
|
|
342
|
+
* @param error - Orbyt error
|
|
343
|
+
* @param logger - Optional EngineLogger instance
|
|
344
|
+
* @param options - Formatting options
|
|
345
|
+
* @returns Formatted error string
|
|
346
|
+
*/
|
|
347
|
+
export function formatAndLogError(error, logger, options) {
|
|
348
|
+
const { useColors = true, verbose = false, includeDebugInfo = true } = options || {};
|
|
349
|
+
// Log to engine if logger provided
|
|
350
|
+
if (logger) {
|
|
351
|
+
logErrorToEngine(error, logger, includeDebugInfo);
|
|
352
|
+
}
|
|
353
|
+
// Return formatted string for console/CLI
|
|
354
|
+
return formatError(error, useColors, verbose);
|
|
355
|
+
}
|
|
140
356
|
//# sourceMappingURL=ErrorFormatter.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ErrorFormatter.js","sourceRoot":"","sources":["../../src/errors/ErrorFormatter.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"ErrorFormatter.js","sourceRoot":"","sources":["../../src/errors/ErrorFormatter.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA+BG;AAGH,OAAO,EAAE,aAAa,EAAE,MAAM,iBAAiB,CAAC;AAEhD,OAAO,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,GAAG;IACb,KAAK,EAAE,SAAS;IAChB,IAAI,EAAE,SAAS;IACf,GAAG,EAAE,SAAS;IAEd,GAAG,EAAE,UAAU;IACf,MAAM,EAAE,UAAU;IAClB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;IAChB,IAAI,EAAE,UAAU;CACR,CAAC;AAEX;;;;;;;GAOG;AACH,MAAM,UAAU,WAAW,CACzB,KAAiB,EACjB,YAAqB,IAAI,EACzB,UAAmB,KAAK;IAExB,MAAM,CAAC,GAAG,SAAS,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC;QAC7B,KAAK,EAAE,EAAE;QACT,IAAI,EAAE,EAAE;QACR,GAAG,EAAE,EAAE;QACP,GAAG,EAAE,EAAE;QACP,MAAM,EAAE,EAAE;QACV,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,EAAE;QACR,IAAI,EAAE,EAAE;KACT,CAAC;IAEF,MAAM,KAAK,GAAa,EAAE,CAAC;IAE3B,yBAAyB;IACzB,MAAM,IAAI,GAAG,eAAe,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC;IAC7C,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC;IAElD,KAAK,CAAC,IAAI,CACR,GAAG,KAAK,GAAG,IAAI,IAAI,KAAK,CAAC,IAAI,GA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AAE,gBAAgB,CAAC,CAAC;IACpD,CAAC;IAED,0CAA0C;IAC1C,OAAO,WAAW,CAAC,KAAK,EAAE,SAAS,EAAE,OAAO,CAAC,CAAC;AAChD,CAAC"}
|
|
@@ -0,0 +1,259 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Error Handler (Automatic Error Management)
|
|
3
|
+
*
|
|
4
|
+
* Central error handling system that orchestrates detection, logging, and execution control.
|
|
5
|
+
* Designed to work automatically without manual error handling in engine.
|
|
6
|
+
*
|
|
7
|
+
* ARCHITECTURE:
|
|
8
|
+
* =============
|
|
9
|
+
* - AUTOMATIC in Engine: Errors are auto-detected and classified
|
|
10
|
+
* - MANUAL in CLI/API/SDK: Use ErrorHandler explicitly for custom handling
|
|
11
|
+
* - INTEGRATED with WorkflowLoader: Validates and detects errors on load
|
|
12
|
+
*
|
|
13
|
+
* EXECUTION CONTROL:
|
|
14
|
+
* ==================
|
|
15
|
+
* Based on severity, automatically determines what to do:
|
|
16
|
+
* - CRITICAL/FATAL → Stop entire workflow immediately
|
|
17
|
+
* - ERROR → Stop entire workflow
|
|
18
|
+
* - MEDIUM → Stop current step, try next step
|
|
19
|
+
* - LOW/WARNING/INFO → Log and continue
|
|
20
|
+
*
|
|
21
|
+
* USAGE:
|
|
22
|
+
* ======
|
|
23
|
+
* ```typescript
|
|
24
|
+
* // In Engine (automatic):
|
|
25
|
+
* try {
|
|
26
|
+
* await executeStep(step);
|
|
27
|
+
* } catch (error) {
|
|
28
|
+
* const result = await ErrorHandler.handle(error, {
|
|
29
|
+
* location: `steps[${index}]`,
|
|
30
|
+
* stepId: step.id
|
|
31
|
+
* });
|
|
32
|
+
*
|
|
33
|
+
* if (result.shouldStopWorkflow) {
|
|
34
|
+
* throw result.error;
|
|
35
|
+
* }
|
|
36
|
+
* if (result.shouldStopStep) {
|
|
37
|
+
* continue; // Skip to next step
|
|
38
|
+
* }
|
|
39
|
+
* // Continue current step
|
|
40
|
+
* }
|
|
41
|
+
*
|
|
42
|
+
* // In CLI/API (manual):
|
|
43
|
+
* try {
|
|
44
|
+
* const workflow = await WorkflowLoader.fromFile(path);
|
|
45
|
+
* } catch (error) {
|
|
46
|
+
* const result = await ErrorHandler.handle(error, { location: path });
|
|
47
|
+
* console.error(result.debug?.formatted);
|
|
48
|
+
* process.exit(result.error.exitCode);
|
|
49
|
+
* }
|
|
50
|
+
* ```
|
|
51
|
+
*
|
|
52
|
+
* @module errors/handler
|
|
53
|
+
*/
|
|
54
|
+
import { OrbytError } from './OrbytError.js';
|
|
55
|
+
import { type ErrorContext } from './ErrorDetector.js';
|
|
56
|
+
import { ExecutionControl } from './ErrorCodes.js';
|
|
57
|
+
/**
|
|
58
|
+
* Error handling result
|
|
59
|
+
* Contains all information needed to make execution decisions
|
|
60
|
+
*/
|
|
61
|
+
export interface ErrorHandlingResult {
|
|
62
|
+
/** The detected and classified OrbytError */
|
|
63
|
+
error: OrbytError;
|
|
64
|
+
/** Execution control action (STOP_WORKFLOW, STOP_STEP, CONTINUE) */
|
|
65
|
+
control: ExecutionControl;
|
|
66
|
+
/** Should stop entire workflow execution? */
|
|
67
|
+
shouldStopWorkflow: boolean;
|
|
68
|
+
/** Should stop current step execution? */
|
|
69
|
+
shouldStopStep: boolean;
|
|
70
|
+
/** Can continue execution? */
|
|
71
|
+
shouldContinue: boolean;
|
|
72
|
+
/** Debug information with solutions */
|
|
73
|
+
debug?: {
|
|
74
|
+
/** Plain English explanation */
|
|
75
|
+
explanation: string;
|
|
76
|
+
/** Root cause analysis */
|
|
77
|
+
cause: string;
|
|
78
|
+
/** Step-by-step fix instructions */
|
|
79
|
+
fixSteps: string[];
|
|
80
|
+
/** Quick one-line fix */
|
|
81
|
+
quickFix: string;
|
|
82
|
+
/** Formatted output for CLI display */
|
|
83
|
+
formatted: string;
|
|
84
|
+
/** Detailed output with all diagnostics */
|
|
85
|
+
detailed: string;
|
|
86
|
+
/** Common mistakes that lead to this error */
|
|
87
|
+
commonMistakes?: string[];
|
|
88
|
+
/** Estimated time to fix */
|
|
89
|
+
estimatedFixTime?: string;
|
|
90
|
+
};
|
|
91
|
+
/** Log entry (what was logged to console/logger) */
|
|
92
|
+
logEntry?: {
|
|
93
|
+
level: 'error' | 'warn' | 'info';
|
|
94
|
+
message: string;
|
|
95
|
+
metadata: Record<string, any>;
|
|
96
|
+
timestamp: Date;
|
|
97
|
+
};
|
|
98
|
+
}
|
|
99
|
+
/**
|
|
100
|
+
* Error handler configuration options
|
|
101
|
+
*/
|
|
102
|
+
export interface ErrorHandlerOptions {
|
|
103
|
+
/** Enable automatic logging to console/logger (default: true) */
|
|
104
|
+
enableLogging?: boolean;
|
|
105
|
+
/** Enable debug info generation for troubleshooting (default: false in engine, true in CLI) */
|
|
106
|
+
enableDebug?: boolean;
|
|
107
|
+
/** Use colored output for terminal (default: true) */
|
|
108
|
+
useColors?: boolean;
|
|
109
|
+
/** Custom logger implementation (defaults to console) */
|
|
110
|
+
logger?: {
|
|
111
|
+
error: (message: string, meta?: any) => void;
|
|
112
|
+
warn: (message: string, meta?: any) => void;
|
|
113
|
+
info: (message: string, meta?: any) => void;
|
|
114
|
+
};
|
|
115
|
+
/** Additional context to include in logs */
|
|
116
|
+
context?: Record<string, any>;
|
|
117
|
+
}
|
|
118
|
+
/**
|
|
119
|
+
* Error Handler
|
|
120
|
+
*
|
|
121
|
+
* Unified error handling system for Orbyt engine.
|
|
122
|
+
* Automatically detects, classifies, logs, and controls execution based on errors.
|
|
123
|
+
*/
|
|
124
|
+
export declare class ErrorHandler {
|
|
125
|
+
/**
|
|
126
|
+
* Handle any error - the main entry point
|
|
127
|
+
*
|
|
128
|
+
* Automatically:
|
|
129
|
+
* 1. Detects and classifies error type
|
|
130
|
+
* 2. Determines severity level
|
|
131
|
+
* 3. Logs appropriately
|
|
132
|
+
* 4. Generates debug info (if enabled)
|
|
133
|
+
* 5. Returns execution control decision
|
|
134
|
+
*
|
|
135
|
+
* @param error - Any error (OrbytError, Error, string, or error context)
|
|
136
|
+
* @param errorContext - Context about where error occurred
|
|
137
|
+
* @param options - Configuration options
|
|
138
|
+
* @returns Complete error handling result with execution decisions
|
|
139
|
+
*
|
|
140
|
+
* @example
|
|
141
|
+
* ```typescript
|
|
142
|
+
* // Automatic handling in engine
|
|
143
|
+
* const result = await ErrorHandler.handle(error, {
|
|
144
|
+
* location: 'workflow.steps[2]',
|
|
145
|
+
* stepId: 'fetch-data'
|
|
146
|
+
* });
|
|
147
|
+
*
|
|
148
|
+
* if (result.shouldStopWorkflow) {
|
|
149
|
+
* throw result.error; // Stop execution
|
|
150
|
+
* }
|
|
151
|
+
* ```
|
|
152
|
+
*/
|
|
153
|
+
static handle(error: unknown, errorContext?: Partial<ErrorContext>, options?: ErrorHandlerOptions): Promise<ErrorHandlingResult>;
|
|
154
|
+
/**
|
|
155
|
+
* Handle error from WorkflowLoader
|
|
156
|
+
* Special handling for load-time errors with file path context
|
|
157
|
+
*
|
|
158
|
+
* @param error - Error from loader
|
|
159
|
+
* @param filePath - Path to workflow file being loaded
|
|
160
|
+
* @param options - Handler options
|
|
161
|
+
* @returns Error handling result
|
|
162
|
+
*/
|
|
163
|
+
static handleLoaderError(error: unknown, filePath: string, options?: ErrorHandlerOptions): Promise<ErrorHandlingResult>;
|
|
164
|
+
/**
|
|
165
|
+
* Handle error from context object
|
|
166
|
+
* When you already know the error type and have context
|
|
167
|
+
*
|
|
168
|
+
* @param context - Error context with type and data
|
|
169
|
+
* @param options - Handler options
|
|
170
|
+
* @returns Error handling result
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* ```typescript
|
|
174
|
+
* const result = await ErrorHandler.handleContext({
|
|
175
|
+
* type: 'missing_field',
|
|
176
|
+
* field: 'version',
|
|
177
|
+
* location: 'workflow'
|
|
178
|
+
* });
|
|
179
|
+
* ```
|
|
180
|
+
*/
|
|
181
|
+
static handleContext(context: ErrorContext, options?: ErrorHandlerOptions): Promise<ErrorHandlingResult>;
|
|
182
|
+
/**
|
|
183
|
+
* Quick handle - simplified for common use cases
|
|
184
|
+
* Returns just a boolean: should stop execution?
|
|
185
|
+
*
|
|
186
|
+
* @param error - Error to handle
|
|
187
|
+
* @param location - Where error occurred
|
|
188
|
+
* @returns True if should stop execution, false if can continue
|
|
189
|
+
*
|
|
190
|
+
* @example
|
|
191
|
+
* ```typescript
|
|
192
|
+
* if (await ErrorHandler.shouldStop(error, 'workflow.steps[2]')) {
|
|
193
|
+
* throw error; // Stop execution
|
|
194
|
+
* }
|
|
195
|
+
* // Continue execution
|
|
196
|
+
* ```
|
|
197
|
+
*/
|
|
198
|
+
static shouldStop(error: unknown, location?: string): Promise<boolean>;
|
|
199
|
+
/**
|
|
200
|
+
* Batch handle multiple errors
|
|
201
|
+
* Useful for validation that collects multiple errors
|
|
202
|
+
*
|
|
203
|
+
* @param errors - Array of errors
|
|
204
|
+
* @param options - Handler options
|
|
205
|
+
* @returns Array of handling results
|
|
206
|
+
*/
|
|
207
|
+
static handleBatch(errors: unknown[], options?: ErrorHandlerOptions): Promise<ErrorHandlingResult[]>;
|
|
208
|
+
/**
|
|
209
|
+
* Get most severe error from batch
|
|
210
|
+
* Returns the error that should take precedence
|
|
211
|
+
*
|
|
212
|
+
* @param results - Array of error handling results
|
|
213
|
+
* @returns Most severe error result
|
|
214
|
+
*/
|
|
215
|
+
static getMostSevere(results: ErrorHandlingResult[]): ErrorHandlingResult | undefined;
|
|
216
|
+
/**
|
|
217
|
+
* Check if any errors in batch should stop workflow
|
|
218
|
+
*
|
|
219
|
+
* @param results - Array of error handling results
|
|
220
|
+
* @returns True if any error should stop workflow
|
|
221
|
+
*/
|
|
222
|
+
static shouldStopWorkflowForBatch(results: ErrorHandlingResult[]): boolean;
|
|
223
|
+
/**
|
|
224
|
+
* Detect and classify error into OrbytError
|
|
225
|
+
*/
|
|
226
|
+
private static detectError;
|
|
227
|
+
/**
|
|
228
|
+
* Detect error type from WorkflowLoader errors
|
|
229
|
+
*/
|
|
230
|
+
private static detectLoaderErrorType;
|
|
231
|
+
/**
|
|
232
|
+
* Log error with appropriate level
|
|
233
|
+
*/
|
|
234
|
+
private static logError;
|
|
235
|
+
/**
|
|
236
|
+
* Generate complete debug information
|
|
237
|
+
*/
|
|
238
|
+
private static generateDebugInfo;
|
|
239
|
+
}
|
|
240
|
+
/**
|
|
241
|
+
* Global error handler instance for convenience
|
|
242
|
+
* Can be used for setting default options
|
|
243
|
+
*/
|
|
244
|
+
export declare class GlobalErrorHandler {
|
|
245
|
+
private static defaultOptions;
|
|
246
|
+
/**
|
|
247
|
+
* Configure default options for all error handling
|
|
248
|
+
*/
|
|
249
|
+
static configure(options: Partial<ErrorHandlerOptions>): void;
|
|
250
|
+
/**
|
|
251
|
+
* Handle error with default options
|
|
252
|
+
*/
|
|
253
|
+
static handle(error: unknown, context?: Partial<ErrorContext>): Promise<ErrorHandlingResult>;
|
|
254
|
+
/**
|
|
255
|
+
* Get current default options
|
|
256
|
+
*/
|
|
257
|
+
static getOptions(): ErrorHandlerOptions;
|
|
258
|
+
}
|
|
259
|
+
//# sourceMappingURL=ErrorHandler.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ErrorHandler.d.ts","sourceRoot":"","sources":["../../src/errors/ErrorHandler.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAoDG;AAEH,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAC7C,OAAO,EAAiB,KAAK,YAAY,EAAE,MAAM,oBAAoB,CAAC;AAGtE,OAAO,EAEH,gBAAgB,EAInB,MAAM,iBAAiB,CAAC;AAEzB;;;GAGG;AACH,MAAM,WAAW,mBAAmB;IAChC,6CAA6C;IAC7C,KAAK,EAAE,UAAU,CAAC;IAElB,oEAAoE;IACpE,OAAO,EAAE,gBAAgB,CAAC;IAE1B,6CAA6C;IAC7C,kBAAkB,EAAE,OAAO,CAAC;IAE5B,0CAA0C;IAC1C,cAAc,EAAE,OAA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