@orbytautomation/engine 0.5.0 → 0.6.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/dist/core/OrbytEngine.d.ts.map +1 -1
- package/dist/core/OrbytEngine.js +18 -4
- package/dist/core/OrbytEngine.js.map +1 -1
- package/dist/errors/ErrorDebugger.d.ts +78 -25
- package/dist/errors/ErrorDebugger.d.ts.map +1 -1
- package/dist/errors/ErrorDebugger.js +383 -2
- package/dist/errors/ErrorDebugger.js.map +1 -1
- package/dist/errors/ErrorDetector.d.ts +107 -5
- package/dist/errors/ErrorDetector.d.ts.map +1 -1
- package/dist/errors/ErrorDetector.js +195 -40
- package/dist/errors/ErrorDetector.js.map +1 -1
- package/dist/errors/ErrorFormatter.d.ts +51 -0
- package/dist/errors/ErrorFormatter.d.ts.map +1 -1
- package/dist/errors/ErrorFormatter.js +128 -0
- package/dist/errors/ErrorFormatter.js.map +1 -1
- package/dist/errors/ErrorHandler.d.ts +93 -7
- package/dist/errors/ErrorHandler.d.ts.map +1 -1
- package/dist/errors/ErrorHandler.js +91 -42
- package/dist/errors/ErrorHandler.js.map +1 -1
- package/dist/errors/OrbytError.d.ts +28 -0
- package/dist/errors/OrbytError.d.ts.map +1 -1
- package/dist/errors/OrbytError.js.map +1 -1
- package/dist/errors/SecurityErrors.d.ts +2 -25
- package/dist/errors/SecurityErrors.d.ts.map +1 -1
- package/dist/errors/SecurityErrors.js +5 -119
- package/dist/errors/SecurityErrors.js.map +1 -1
- package/dist/errors/WorkflowError.d.ts +11 -1
- package/dist/errors/WorkflowError.d.ts.map +1 -1
- package/dist/errors/WorkflowError.js +104 -0
- package/dist/errors/WorkflowError.js.map +1 -1
- package/dist/loader/WorkflowLoader.d.ts +71 -5
- package/dist/loader/WorkflowLoader.d.ts.map +1 -1
- package/dist/loader/WorkflowLoader.js +135 -50
- package/dist/loader/WorkflowLoader.js.map +1 -1
- package/dist/logging/EngineLogger.d.ts +252 -337
- package/dist/logging/EngineLogger.d.ts.map +1 -1
- package/dist/logging/EngineLogger.js +460 -1012
- package/dist/logging/EngineLogger.js.map +1 -1
- package/dist/logging/LoggerManager.d.ts +109 -33
- package/dist/logging/LoggerManager.d.ts.map +1 -1
- package/dist/logging/LoggerManager.js +136 -47
- package/dist/logging/LoggerManager.js.map +1 -1
- package/dist/logging/index.d.ts.map +1 -1
- package/dist/logging/index.js.map +1 -1
- package/dist/types/log-types.d.ts +50 -11
- package/dist/types/log-types.d.ts.map +1 -1
- package/dist/types/log-types.js.map +1 -1
- package/package.json +1 -1
|
@@ -20,334 +20,336 @@
|
|
|
20
20
|
* - Monitoring systems
|
|
21
21
|
* - Audit trails
|
|
22
22
|
*
|
|
23
|
-
* @module
|
|
23
|
+
* @module logging
|
|
24
24
|
*/
|
|
25
25
|
import { LogLevel, formatTimestamp } from '@dev-ecosystem/core';
|
|
26
|
-
import {
|
|
26
|
+
import { type EngineLoggerConfig, type EngineLogFormat, type EngineLogEvent, type ExportedLogs, type LogCategory, type WorkflowContext, EngineLogType } from '../types/log-types.js';
|
|
27
27
|
/**
|
|
28
|
-
*
|
|
29
|
-
*
|
|
28
|
+
* Internal contract used by CategoryLogger to call back into EngineLogger
|
|
29
|
+
* without a circular reference. Not part of the public API.
|
|
30
|
+
* @internal
|
|
30
31
|
*/
|
|
31
|
-
|
|
32
|
+
interface LogDispatcher {
|
|
33
|
+
_logWithCategory(level: LogLevel, message: string, context?: Record<string, unknown>, error?: Error, category?: LogCategory, typeOverride?: EngineLogType): void;
|
|
34
|
+
}
|
|
35
|
+
/**
|
|
36
|
+
* A thin wrapper that pins every log call to a specific category.
|
|
37
|
+
*
|
|
38
|
+
* Obtain instances via `EngineLogger.runtime`, `.analysis`, `.system`, or `.security`.
|
|
39
|
+
*
|
|
40
|
+
* ```typescript
|
|
41
|
+
* const logger = LoggerManager.getLogger();
|
|
42
|
+
*
|
|
43
|
+
* // inside run() — runtime category
|
|
44
|
+
* logger.runtime.info('Step started', { stepId });
|
|
45
|
+
*
|
|
46
|
+
* // inside explain() / validate() — analysis category
|
|
47
|
+
* logger.analysis.debug('Building execution plan');
|
|
48
|
+
* ```
|
|
49
|
+
*/
|
|
50
|
+
export declare class CategoryLogger {
|
|
51
|
+
private readonly parent;
|
|
52
|
+
private readonly category;
|
|
53
|
+
constructor(parent: LogDispatcher, category: LogCategory);
|
|
54
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
55
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
56
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
57
|
+
error(message: string, error?: Error, context?: Record<string, unknown>): void;
|
|
58
|
+
fatal(message: string, error?: Error, context?: Record<string, unknown>): void;
|
|
59
|
+
/**
|
|
60
|
+
* Measure execution time of `fn` and log the result under this category.
|
|
61
|
+
*
|
|
62
|
+
* ```typescript
|
|
63
|
+
* const result = await logger.runtime.measureExecution(
|
|
64
|
+
* 'step:http-request',
|
|
65
|
+
* () => httpAdapter.run(step),
|
|
66
|
+
* { warn: 3000, error: 10000 },
|
|
67
|
+
* );
|
|
68
|
+
* ```
|
|
69
|
+
*/
|
|
70
|
+
measureExecution<T>(label: string, fn: () => Promise<T>, thresholds?: {
|
|
71
|
+
warn?: number;
|
|
72
|
+
error?: number;
|
|
73
|
+
}): Promise<T>;
|
|
74
|
+
}
|
|
32
75
|
/**
|
|
33
76
|
* Engine Logger
|
|
34
77
|
*
|
|
35
78
|
* Wraps ecosystem-core logging utilities with engine-specific configuration.
|
|
79
|
+
* Emits structured JSON logs and maintains a typed log history.
|
|
80
|
+
*
|
|
81
|
+
* ### Category sub-loggers
|
|
82
|
+
* Every log is tagged with a phase-based category so tooling / formatters can
|
|
83
|
+
* filter or colour-code entries without parsing the message text.
|
|
84
|
+
*
|
|
85
|
+
* | Sub-logger | Category | When to use |
|
|
86
|
+
* |--------------------|--------------|---------------------------------------------------|
|
|
87
|
+
* | `logger.runtime` | `runtime` | `run()` — step start/complete/fail/retry |
|
|
88
|
+
* | `logger.analysis` | `analysis` | `explain()` / `validate()` — plan & parse phase |
|
|
89
|
+
* | `logger.system` | `system` | Engine init/shutdown, adapter registration |
|
|
90
|
+
* | `logger.security` | `security` | Reserved-field violations, permission rejections |
|
|
91
|
+
*
|
|
92
|
+
* Generic `logger.info(...)` etc. fall back to the category set at construction.
|
|
36
93
|
*/
|
|
37
|
-
export declare class EngineLogger {
|
|
94
|
+
export declare class EngineLogger implements LogDispatcher {
|
|
38
95
|
private config;
|
|
39
96
|
private formatOptions;
|
|
40
|
-
private
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
/**
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
97
|
+
private logHistory;
|
|
98
|
+
/** Workflow context set by the engine before run/explain/validate */
|
|
99
|
+
private workflowContext;
|
|
100
|
+
/** Use inside `run()` and step-execution paths. Category: `runtime` */
|
|
101
|
+
readonly runtime: CategoryLogger;
|
|
102
|
+
/** Use inside `explain()` and `validate()` paths. Category: `analysis` */
|
|
103
|
+
readonly analysis: CategoryLogger;
|
|
104
|
+
/** Use for engine init, shutdown, adapter registration. Category: `system` */
|
|
105
|
+
readonly system: CategoryLogger;
|
|
106
|
+
/** Use for reserved-field violations, permission rejections. Category: `security` */
|
|
107
|
+
readonly security: CategoryLogger;
|
|
49
108
|
constructor(config: EngineLoggerConfig);
|
|
50
109
|
/**
|
|
51
110
|
* Log a debug message
|
|
52
111
|
*/
|
|
112
|
+
debug(message: string, context?: Record<string, unknown>): void;
|
|
53
113
|
/**
|
|
54
|
-
* Log
|
|
55
|
-
*/
|
|
56
|
-
debug(message: string, context?: Record<string, unknown>, category?: LogCategory, source?: string): void;
|
|
57
|
-
/**
|
|
58
|
-
* Log an info message (category and source required)
|
|
59
|
-
*/
|
|
60
|
-
info(message: string, context?: Record<string, unknown>, category?: LogCategory, source?: string): void;
|
|
61
|
-
/**
|
|
62
|
-
* Log a warning message (category and source required)
|
|
63
|
-
*/
|
|
64
|
-
warn(message: string, context?: Record<string, unknown>, category?: LogCategory, source?: string): void;
|
|
65
|
-
/**
|
|
66
|
-
* Log an error message (category and source required)
|
|
67
|
-
*/
|
|
68
|
-
error(message: string, error?: Error, context?: Record<string, unknown>, category?: LogCategory, source?: string): void;
|
|
69
|
-
/**
|
|
70
|
-
* Log a fatal error message (category and source required)
|
|
114
|
+
* Log an info message
|
|
71
115
|
*/
|
|
72
|
-
|
|
116
|
+
info(message: string, context?: Record<string, unknown>): void;
|
|
73
117
|
/**
|
|
74
|
-
* Log
|
|
118
|
+
* Log a warning message
|
|
75
119
|
*/
|
|
120
|
+
warn(message: string, context?: Record<string, unknown>): void;
|
|
76
121
|
/**
|
|
77
|
-
* Log
|
|
122
|
+
* Log an error message
|
|
78
123
|
*/
|
|
79
|
-
|
|
80
|
-
/**
|
|
81
|
-
* Log workflow completed event
|
|
82
|
-
*/
|
|
83
|
-
/**
|
|
84
|
-
* Log workflow completed event (runtime phase)
|
|
85
|
-
*/
|
|
86
|
-
workflowCompleted(workflowName: string, duration: number, context?: Record<string, unknown>): void;
|
|
87
|
-
/**
|
|
88
|
-
* Log workflow failed event
|
|
89
|
-
*/
|
|
90
|
-
/**
|
|
91
|
-
* Log workflow failed event (runtime phase)
|
|
92
|
-
*/
|
|
93
|
-
workflowFailed(workflowName: string, error: Error, duration: number, context?: Record<string, unknown>): void;
|
|
94
|
-
/**
|
|
95
|
-
* Log workflow validation event
|
|
96
|
-
*/
|
|
97
|
-
/**
|
|
98
|
-
* Log workflow validation event (analysis phase)
|
|
99
|
-
*/
|
|
100
|
-
workflowValidation(workflowName: string, isValid: boolean, errors?: string[]): void;
|
|
101
|
-
/**
|
|
102
|
-
* Log step started event
|
|
103
|
-
*/
|
|
104
|
-
/**
|
|
105
|
-
* Log step started event (runtime phase)
|
|
106
|
-
*/
|
|
107
|
-
stepStarted(stepId: string, stepName: string, context?: Record<string, unknown>): void;
|
|
124
|
+
error(message: string, error?: Error, context?: Record<string, unknown>): void;
|
|
108
125
|
/**
|
|
109
|
-
* Log
|
|
126
|
+
* Log a fatal error message
|
|
110
127
|
*/
|
|
128
|
+
fatal(message: string, error?: Error, context?: Record<string, unknown>): void;
|
|
111
129
|
/**
|
|
112
|
-
* Log
|
|
113
|
-
*/
|
|
114
|
-
stepCompleted(stepId: string, stepName: string, duration: number, context?: Record<string, unknown>): void;
|
|
115
|
-
/**
|
|
116
|
-
* Log step failed event
|
|
117
|
-
*/
|
|
118
|
-
/**
|
|
119
|
-
* Log step failed event (runtime phase)
|
|
120
|
-
*/
|
|
121
|
-
stepFailed(stepId: string, stepName: string, error: Error, context?: Record<string, unknown>): void;
|
|
122
|
-
/**
|
|
123
|
-
* Log step retry event
|
|
124
|
-
*/
|
|
125
|
-
/**
|
|
126
|
-
* Log step retry event (runtime phase)
|
|
127
|
-
*/
|
|
128
|
-
stepRetry(stepId: string, stepName: string, attempt: number, maxAttempts: number): void;
|
|
129
|
-
/**
|
|
130
|
-
* Log step timeout event
|
|
131
|
-
*/
|
|
132
|
-
/**
|
|
133
|
-
* Log step timeout event (runtime phase)
|
|
134
|
-
*/
|
|
135
|
-
stepTimeout(stepId: string, stepName: string, timeout: number): void;
|
|
136
|
-
/**
|
|
137
|
-
* Log explanation generated event
|
|
138
|
-
*/
|
|
139
|
-
/**
|
|
140
|
-
* Log explanation generated event (analysis phase)
|
|
141
|
-
*/
|
|
142
|
-
explanationGenerated(workflowName: string, stepCount: number, strategy: string): void;
|
|
143
|
-
/**
|
|
144
|
-
* Log circular dependencies detected
|
|
145
|
-
*/
|
|
146
|
-
/**
|
|
147
|
-
* Log circular dependencies detected (analysis phase)
|
|
148
|
-
*/
|
|
149
|
-
explanationCycles(workflowName: string, cycles: string[][]): void;
|
|
150
|
-
/**
|
|
151
|
-
* Log adapter loaded event
|
|
152
|
-
*/
|
|
153
|
-
/**
|
|
154
|
-
* Log adapter loaded event (system phase)
|
|
155
|
-
*/
|
|
156
|
-
adapterLoaded(adapterName: string, version?: string): void;
|
|
157
|
-
/**
|
|
158
|
-
* Log adapter failed event
|
|
159
|
-
*/
|
|
160
|
-
/**
|
|
161
|
-
* Log adapter failed event (system phase)
|
|
130
|
+
* Log with a custom level
|
|
162
131
|
*/
|
|
163
|
-
|
|
132
|
+
logWithLevel(level: LogLevel, message: string, context?: Record<string, unknown>): void;
|
|
164
133
|
/**
|
|
165
|
-
* Log
|
|
134
|
+
* Log only if severity meets minimum threshold
|
|
166
135
|
*/
|
|
136
|
+
logIfSeverity(minSeverity: number, level: LogLevel, message: string, context?: Record<string, unknown>): void;
|
|
167
137
|
/**
|
|
168
|
-
*
|
|
138
|
+
* Measure and log execution time with appropriate log level based on duration.
|
|
139
|
+
*
|
|
140
|
+
* Pass `category` to override (`'runtime'` during `run()`, `'analysis'` during `explain()`).
|
|
141
|
+
* Prefer `logger.runtime.measureExecution(...)` or `logger.analysis.measureExecution(...)`.
|
|
169
142
|
*/
|
|
170
|
-
|
|
143
|
+
measureExecution<T>(label: string, fn: () => Promise<T>, thresholds?: {
|
|
144
|
+
warn?: number;
|
|
145
|
+
error?: number;
|
|
146
|
+
}, category?: LogCategory): Promise<T>;
|
|
171
147
|
/**
|
|
172
|
-
*
|
|
148
|
+
* Central log dispatcher — used directly by `CategoryLogger` sub-loggers
|
|
149
|
+
* and by the private `log()` helper below.
|
|
150
|
+
*
|
|
151
|
+
* @param level - Severity level
|
|
152
|
+
* @param message - Human-readable message
|
|
153
|
+
* @param context - Optional key-value metadata (merged with workflow ctx)
|
|
154
|
+
* @param error - Optional error object
|
|
155
|
+
* @param categoryOverride - Pin to a specific category (defaults to config category)
|
|
156
|
+
* @param typeOverride - Explicit `EngineLogType`; inferred from level when omitted
|
|
157
|
+
*
|
|
158
|
+
* @internal Called via sub-loggers (`runtime`, `analysis`, etc.) or internally.
|
|
173
159
|
*/
|
|
160
|
+
_logWithCategory(level: LogLevel, message: string, context?: Record<string, unknown>, error?: Error, categoryOverride?: LogCategory, typeOverride?: EngineLogType): void;
|
|
174
161
|
/**
|
|
175
|
-
*
|
|
162
|
+
* Private shorthand — uses the default category from config.
|
|
163
|
+
* Prefer the categorised sub-loggers (`runtime`, `analysis`, etc.) for new code.
|
|
176
164
|
*/
|
|
177
|
-
|
|
165
|
+
private log;
|
|
178
166
|
/**
|
|
179
|
-
*
|
|
167
|
+
* Export collected logs as a structured ExportedLogs object.
|
|
168
|
+
* Includes `byCategory` statistics and the active `workflowContext` snapshot.
|
|
180
169
|
*/
|
|
170
|
+
exportLogs(): ExportedLogs;
|
|
181
171
|
/**
|
|
182
|
-
*
|
|
172
|
+
* Get all collected logs as a JSON string
|
|
183
173
|
*/
|
|
184
|
-
|
|
174
|
+
getJSONLogs(): string;
|
|
185
175
|
/**
|
|
186
|
-
*
|
|
176
|
+
* Clear the log history (does NOT clear the workflow context)
|
|
187
177
|
*/
|
|
178
|
+
clearHistory(): void;
|
|
188
179
|
/**
|
|
189
|
-
*
|
|
180
|
+
* Attach workflow context so every subsequent log entry automatically
|
|
181
|
+
* includes a `workflow` field. Call this before `run()`, `explain()`,
|
|
182
|
+
* or `validate()` with the parsed workflow data.
|
|
183
|
+
*
|
|
184
|
+
* ```typescript
|
|
185
|
+
* logger.setWorkflowContext({
|
|
186
|
+
* name: workflow.name,
|
|
187
|
+
* version: workflow.version,
|
|
188
|
+
* kind: workflow.kind,
|
|
189
|
+
* stepCount: workflow.steps.length,
|
|
190
|
+
* filePath: resolvedPath,
|
|
191
|
+
* });
|
|
192
|
+
* ```
|
|
190
193
|
*/
|
|
191
|
-
|
|
192
|
-
explanation: string;
|
|
193
|
-
fixSteps: string[];
|
|
194
|
-
}): void;
|
|
194
|
+
setWorkflowContext(ctx: WorkflowContext): void;
|
|
195
195
|
/**
|
|
196
|
-
*
|
|
196
|
+
* Detach the workflow context (e.g. after a run completes).
|
|
197
|
+
* Logs emitted after this call will no longer include the `workflow` field.
|
|
197
198
|
*/
|
|
199
|
+
clearWorkflowContext(): void;
|
|
198
200
|
/**
|
|
199
|
-
*
|
|
201
|
+
* Returns a read-only snapshot of the currently active workflow context,
|
|
202
|
+
* or `null` if none has been set.
|
|
200
203
|
*/
|
|
201
|
-
|
|
204
|
+
getWorkflowContext(): Readonly<WorkflowContext> | null;
|
|
202
205
|
/**
|
|
203
|
-
*
|
|
206
|
+
* Partially update the active workflow context without replacing it.
|
|
207
|
+
* Only the supplied fields are merged in; the rest are preserved.
|
|
208
|
+
*
|
|
209
|
+
* Useful for enriching the context mid-run (e.g. after the execution
|
|
210
|
+
* strategy is determined):
|
|
211
|
+
*
|
|
212
|
+
* ```typescript
|
|
213
|
+
* logger.patchWorkflowContext({ executionStrategy: 'parallel' });
|
|
214
|
+
* ```
|
|
215
|
+
*
|
|
216
|
+
* If no context has been set yet, the patch is applied as if it were
|
|
217
|
+
* a fresh `setWorkflowContext` call.
|
|
204
218
|
*/
|
|
219
|
+
patchWorkflowContext(partial: Partial<WorkflowContext>): void;
|
|
205
220
|
/**
|
|
206
|
-
*
|
|
221
|
+
* Build a log-context object for a step event.
|
|
222
|
+
*
|
|
223
|
+
* Use this wherever you log step lifecycle events so context is consistent:
|
|
224
|
+
* ```typescript
|
|
225
|
+
* logger.runtime.info('Step started', logger.stepCtx({ id: step.id, adapter: step.adapter }));
|
|
226
|
+
* logger.runtime.error('Step failed', error, logger.stepCtx({ id: step.id, adapter: step.adapter }));
|
|
227
|
+
* ```
|
|
228
|
+
*/
|
|
229
|
+
stepCtx(step: {
|
|
230
|
+
id: string;
|
|
231
|
+
adapter?: string;
|
|
232
|
+
name?: string;
|
|
233
|
+
[extra: string]: unknown;
|
|
234
|
+
}): Record<string, unknown>;
|
|
235
|
+
/**
|
|
236
|
+
* Build a log-context object for a workflow-level event.
|
|
237
|
+
*
|
|
238
|
+
* Returns a flat object suitable for passing as `context` to any log call.
|
|
239
|
+
* If no workflow context is set, returns `{}`.
|
|
240
|
+
*
|
|
241
|
+
* ```typescript
|
|
242
|
+
* logger.system.info('Workflow validated', logger.workflowCtx());
|
|
243
|
+
* ```
|
|
207
244
|
*/
|
|
208
|
-
|
|
209
|
-
duration?: number;
|
|
210
|
-
memory?: number;
|
|
211
|
-
cpu?: number;
|
|
212
|
-
}): void;
|
|
245
|
+
workflowCtx(): Record<string, unknown>;
|
|
213
246
|
/**
|
|
214
|
-
* Log execution
|
|
247
|
+
* Log workflow execution started (runtime category).
|
|
248
|
+
* Called at the top of `WorkflowExecutor.execute()`.
|
|
215
249
|
*/
|
|
250
|
+
workflowStarted(workflowName: string, context?: Record<string, unknown>): void;
|
|
216
251
|
/**
|
|
217
|
-
* Log
|
|
252
|
+
* Log a workflow input field that was resolved (runtime category).
|
|
218
253
|
*/
|
|
219
|
-
|
|
254
|
+
inputProcessed(key: string, value: unknown, source: string): void;
|
|
220
255
|
/**
|
|
221
|
-
* Log
|
|
222
|
-
* This enables dynamic explanation generation from runtime logs
|
|
256
|
+
* Log a context field used during execution (runtime category).
|
|
223
257
|
*/
|
|
224
|
-
fieldExecution(
|
|
258
|
+
fieldExecution(fieldType: string, key: string, value: unknown): void;
|
|
225
259
|
/**
|
|
226
|
-
* Log
|
|
260
|
+
* Log step execution started (runtime category).
|
|
261
|
+
* ```typescript
|
|
262
|
+
* logger.stepStarted(step.id, step.name, { adapter: step.adapter });
|
|
263
|
+
* ```
|
|
227
264
|
*/
|
|
228
|
-
|
|
265
|
+
stepStarted(stepId: string, stepName: string, context?: Record<string, unknown>): void;
|
|
229
266
|
/**
|
|
230
|
-
* Log
|
|
267
|
+
* Log step execution completed (runtime category).
|
|
231
268
|
*/
|
|
232
|
-
|
|
269
|
+
stepCompleted(stepId: string, stepName: string, duration: number, context?: Record<string, unknown>): void;
|
|
233
270
|
/**
|
|
234
|
-
* Log
|
|
271
|
+
* Log step timeout (runtime category).
|
|
235
272
|
*/
|
|
236
|
-
|
|
273
|
+
stepTimeout(stepId: string, stepName: string, timeoutMs: number): void;
|
|
237
274
|
/**
|
|
238
|
-
* Log
|
|
275
|
+
* Log step retry attempt (runtime category).
|
|
239
276
|
*/
|
|
240
|
-
|
|
277
|
+
stepRetry(stepId: string, stepName: string, attempt: number, maxAttempts: number): void;
|
|
241
278
|
/**
|
|
242
|
-
* Log
|
|
279
|
+
* Log step failure after all attempts (runtime category).
|
|
243
280
|
*/
|
|
244
|
-
|
|
281
|
+
stepFailed(stepId: string, stepName: string, error: Error, context?: Record<string, unknown>): void;
|
|
245
282
|
/**
|
|
246
|
-
* Log adapter action execution
|
|
283
|
+
* Log adapter action execution result (runtime category).
|
|
247
284
|
*/
|
|
248
285
|
adapterActionExecuted(adapter: string, action: string, duration: number, success: boolean): void;
|
|
249
286
|
/**
|
|
250
|
-
* Log
|
|
287
|
+
* Log validation phase started (analysis category).
|
|
251
288
|
*/
|
|
252
|
-
|
|
289
|
+
validationStarted(type: string, schema: string): void;
|
|
253
290
|
/**
|
|
254
|
-
* Log
|
|
291
|
+
* Log validation passed (analysis category).
|
|
255
292
|
*/
|
|
256
|
-
|
|
293
|
+
validationPassed(type: string, schema: string): void;
|
|
257
294
|
/**
|
|
258
|
-
* Log
|
|
295
|
+
* Log validation failure (analysis category).
|
|
259
296
|
*/
|
|
260
|
-
|
|
297
|
+
validationFailed(type: string, schema: string, errors: string[]): void;
|
|
261
298
|
/**
|
|
262
|
-
* Log
|
|
299
|
+
* Log parsing started (analysis category).
|
|
263
300
|
*/
|
|
264
|
-
|
|
301
|
+
parsingStarted(format: string, source: string): void;
|
|
265
302
|
/**
|
|
266
|
-
* Log
|
|
303
|
+
* Log parsing completed (analysis category).
|
|
267
304
|
*/
|
|
268
|
-
|
|
305
|
+
parsingCompleted(format: string, duration: number, context?: Record<string, unknown>): void;
|
|
269
306
|
/**
|
|
270
|
-
* Log
|
|
307
|
+
* Log parsing failure (analysis category).
|
|
271
308
|
*/
|
|
272
|
-
|
|
309
|
+
parsingFailed(format: string, error: Error, context?: Record<string, unknown>): void;
|
|
273
310
|
/**
|
|
274
|
-
*
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
*
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
*
|
|
283
|
-
|
|
284
|
-
|
|
285
|
-
/**
|
|
286
|
-
* Log execution phase completion
|
|
287
|
-
*/
|
|
288
|
-
phaseCompleted(phase: number, duration: number, successCount: number, failureCount: number): void;
|
|
289
|
-
/**
|
|
290
|
-
* Format value for logging (truncate large values)
|
|
291
|
-
*/
|
|
292
|
-
private formatValue;
|
|
293
|
-
/**
|
|
294
|
-
* Sanitize value for logging (remove sensitive data)
|
|
295
|
-
*/
|
|
296
|
-
private sanitizeValue;
|
|
297
|
-
/**
|
|
298
|
-
* Check if field name suggests sensitive data
|
|
299
|
-
*/
|
|
300
|
-
private isSensitiveField;
|
|
301
|
-
/**
|
|
302
|
-
* Log with a custom level
|
|
303
|
-
*/
|
|
304
|
-
logWithLevel(level: LogLevel, message: string, context?: Record<string, unknown>): void;
|
|
305
|
-
/**
|
|
306
|
-
* Log only if severity meets minimum threshold
|
|
307
|
-
*/
|
|
308
|
-
logIfSeverity(minSeverity: number, level: LogLevel, message: string, context?: Record<string, unknown>): void;
|
|
309
|
-
/**
|
|
310
|
-
* Measure and log execution time with appropriate log level based on duration
|
|
311
|
-
*/
|
|
312
|
-
measureExecution<T>(label: string, fn: () => Promise<T>, thresholds?: {
|
|
313
|
-
warn?: number;
|
|
314
|
-
error?: number;
|
|
315
|
-
}): Promise<T>;
|
|
316
|
-
/**
|
|
317
|
-
* Log a structured engine event (category and source required)
|
|
318
|
-
* Uses EngineLog interface for strong typing.
|
|
319
|
-
*/
|
|
320
|
-
private logEvent;
|
|
321
|
-
/**
|
|
322
|
-
* Get appropriate log level for event type
|
|
323
|
-
*/
|
|
324
|
-
private getLogLevelForEventType;
|
|
325
|
-
/**
|
|
326
|
-
* Emit event to registered listeners
|
|
327
|
-
*/
|
|
328
|
-
private emitEvent;
|
|
329
|
-
/**
|
|
330
|
-
* Subscribe to specific log event types
|
|
331
|
-
*/
|
|
332
|
-
on(type: EngineLogType, listener: (event: EngineLogEvent) => void): () => void;
|
|
333
|
-
/**
|
|
334
|
-
* Internal log method
|
|
335
|
-
*/
|
|
336
|
-
/**
|
|
337
|
-
* Internal log method (category and source required)
|
|
338
|
-
*/
|
|
339
|
-
/**
|
|
340
|
-
* Internal log method (category and source required)
|
|
341
|
-
* Uses EngineLog interface for strong typing.
|
|
311
|
+
* Emit a log with an explicit `EngineLogType`.
|
|
312
|
+
*
|
|
313
|
+
* Useful when you want the structured event type to be distinct from the
|
|
314
|
+
* generic level-based inference — e.g. to mark a `STEP_RETRY` event:
|
|
315
|
+
*
|
|
316
|
+
* ```typescript
|
|
317
|
+
* logger.logEvent(EngineLogType.STEP_RETRY, LogLevel.WARN, 'Retrying step', {
|
|
318
|
+
* stepId: 'http-request',
|
|
319
|
+
* attempt: 2,
|
|
320
|
+
* }, 'runtime');
|
|
321
|
+
* ```
|
|
342
322
|
*/
|
|
343
|
-
|
|
323
|
+
logEvent(type: EngineLogType, level: LogLevel, message: string, context?: Record<string, unknown>, category?: LogCategory): void;
|
|
344
324
|
/**
|
|
345
|
-
*
|
|
346
|
-
|
|
325
|
+
* Return log events that match every supplied filter field.
|
|
326
|
+
* Omit a field to skip that filter.
|
|
327
|
+
*
|
|
328
|
+
* ```typescript
|
|
329
|
+
* // All runtime errors for the current workflow
|
|
330
|
+
* logger.filterHistory({ category: 'runtime', withErrors: true });
|
|
331
|
+
*
|
|
332
|
+
* // All analysis events since the explain started
|
|
333
|
+
* const since = new Date();
|
|
334
|
+
* logger.filterHistory({ category: 'analysis', since });
|
|
335
|
+
* ```
|
|
336
|
+
*/
|
|
337
|
+
filterHistory(filter?: {
|
|
338
|
+
category?: LogCategory;
|
|
339
|
+
type?: EngineLogType;
|
|
340
|
+
since?: Date;
|
|
341
|
+
until?: Date;
|
|
342
|
+
source?: string;
|
|
343
|
+
/** Filter to logs that contain a specific workflow name */
|
|
344
|
+
workflowName?: string;
|
|
345
|
+
/** Only return events that have an error attached */
|
|
346
|
+
withErrors?: boolean;
|
|
347
|
+
}): EngineLogEvent[];
|
|
347
348
|
/**
|
|
348
|
-
*
|
|
349
|
+
* Return all history entries grouped by category.
|
|
350
|
+
* Convenience wrapper around `filterHistory`.
|
|
349
351
|
*/
|
|
350
|
-
|
|
352
|
+
getHistoryByCategory(): Record<LogCategory, EngineLogEvent[]>;
|
|
351
353
|
/**
|
|
352
354
|
* Check if a level should be logged using severity comparison
|
|
353
355
|
*/
|
|
@@ -427,102 +429,15 @@ export declare class EngineLogger {
|
|
|
427
429
|
* Check if error logging is enabled
|
|
428
430
|
*/
|
|
429
431
|
isErrorEnabled(): boolean;
|
|
430
|
-
/**
|
|
431
|
-
* Add event to JSON log buffer
|
|
432
|
-
*/
|
|
433
|
-
private addToBuffer;
|
|
434
|
-
/**
|
|
435
|
-
* Get all logs as JSON array
|
|
436
|
-
* This is what CLI, API, dashboards, and explanation system will consume
|
|
437
|
-
*/
|
|
438
|
-
getJSONLogs(): EngineLogEvent[];
|
|
439
|
-
/**
|
|
440
|
-
* Get logs filtered by type
|
|
441
|
-
*/
|
|
442
|
-
getLogsByType(type: EngineLogType): EngineLogEvent[];
|
|
443
|
-
/**
|
|
444
|
-
* Get logs filtered by time range
|
|
445
|
-
*/
|
|
446
|
-
getLogsByTimeRange(startTime: Date, endTime: Date): EngineLogEvent[];
|
|
447
|
-
/**
|
|
448
|
-
* Get logs filtered by multiple criteria
|
|
449
|
-
*/
|
|
450
|
-
getLogsFiltered(filter: {
|
|
451
|
-
types?: EngineLogType[];
|
|
452
|
-
startTime?: Date;
|
|
453
|
-
endTime?: Date;
|
|
454
|
-
hasError?: boolean;
|
|
455
|
-
searchText?: string;
|
|
456
|
-
}): EngineLogEvent[];
|
|
457
|
-
/**
|
|
458
|
-
* Get logs by category: Parse events
|
|
459
|
-
*/
|
|
460
|
-
getParseLogEvents(): ParseLogEvent[];
|
|
461
|
-
/**
|
|
462
|
-
* Get logs by category: Validation events
|
|
463
|
-
*/
|
|
464
|
-
getValidationLogEvents(): ValidationLogEvent[];
|
|
465
|
-
/**
|
|
466
|
-
* Get logs by category: Execution events
|
|
467
|
-
*/
|
|
468
|
-
getExecutionLogEvents(): ExecutionLogEvent[];
|
|
469
|
-
/**
|
|
470
|
-
* Get logs by category: Error events
|
|
471
|
-
*/
|
|
472
|
-
getErrorLogEvents(): ErrorLogEvent[];
|
|
473
|
-
/**
|
|
474
|
-
* Get logs by category: Lifecycle events
|
|
475
|
-
*/
|
|
476
|
-
getLifecycleLogEvents(): LifecycleLogEvent[];
|
|
477
|
-
/**
|
|
478
|
-
* Get logs by category: Performance events
|
|
479
|
-
*/
|
|
480
|
-
getPerformanceLogEvents(): PerformanceLogEvent[];
|
|
481
|
-
/**
|
|
482
|
-
* Export logs as formatted JSON string
|
|
483
|
-
*/
|
|
484
|
-
exportLogsAsJSON(pretty?: boolean): string;
|
|
485
|
-
/**
|
|
486
|
-
* Export logs grouped by type
|
|
487
|
-
*/
|
|
488
|
-
exportLogsGrouped(): Record<string, EngineLogEvent[]>;
|
|
489
|
-
/**
|
|
490
|
-
* Get log statistics
|
|
491
|
-
*/
|
|
492
|
-
getLogStats(): {
|
|
493
|
-
total: number;
|
|
494
|
-
byType: Record<string, number>;
|
|
495
|
-
withErrors: number;
|
|
496
|
-
withMetrics: number;
|
|
497
|
-
timeRange: {
|
|
498
|
-
first?: Date;
|
|
499
|
-
last?: Date;
|
|
500
|
-
};
|
|
501
|
-
};
|
|
502
|
-
/**
|
|
503
|
-
* Clear log buffer
|
|
504
|
-
*/
|
|
505
|
-
clearLogs(): void;
|
|
506
|
-
/**
|
|
507
|
-
* Set maximum buffer size
|
|
508
|
-
*/
|
|
509
|
-
setMaxBufferSize(size: number): void;
|
|
510
|
-
/**
|
|
511
|
-
* Get current buffer size
|
|
512
|
-
*/
|
|
513
|
-
getBufferSize(): number;
|
|
514
|
-
/**
|
|
515
|
-
* Export logs in a comprehensive format for consumers (CLI, API, dashboards)
|
|
516
|
-
*/
|
|
517
|
-
exportLogs(): ExportedLogs;
|
|
518
|
-
/**
|
|
519
|
-
* Build execution summary from collected logs
|
|
520
|
-
* This powers dynamic explanation generation
|
|
521
|
-
*/
|
|
522
|
-
private buildExecutionSummary;
|
|
523
432
|
}
|
|
524
433
|
/**
|
|
525
434
|
* Create a logger instance from engine config
|
|
526
435
|
*/
|
|
527
|
-
export declare function createEngineLogger(
|
|
436
|
+
export declare function createEngineLogger(logLevel: 'debug' | 'info' | 'warn' | 'error' | 'silent', verbose?: boolean): EngineLogger | null;
|
|
437
|
+
export type { EngineLoggerConfig, EngineLogFormat };
|
|
438
|
+
/**
|
|
439
|
+
* Re-export formatTimestamp for external use
|
|
440
|
+
* Allows other parts of the system to format timestamps consistently
|
|
441
|
+
*/
|
|
442
|
+
export { formatTimestamp };
|
|
528
443
|
//# sourceMappingURL=EngineLogger.d.ts.map
|