UNPKG

@gati-framework/runtime

Version:

Gati runtime execution engine for running handler-based applications

72 lines 1.85 kB
/** * @module runtime/playground/hook-playback * @description Hook execution recording and playback for Playground visualization * * Implements Task 21 Phase 4: Hook Playback API * - Records hook execution traces with timing * - Captures errors and execution order * - Supports replay functionality for debugging */ /** * Hook playback system for recording and replaying hook executions */ export class HookPlayback { traces = new Map(); enabled = false; enable() { this.enabled = true; } disable() { this.enabled = false; } isEnabled() { return this.enabled; } startRequest(requestId) { if (!this.enabled) return; this.traces.set(requestId, { requestId, traces: [], startTime: Date.now(), }); } endRequest(requestId) { if (!this.enabled) return; const trace = this.traces.get(requestId); if (trace) trace.endTime = Date.now(); } recordHookExecution(requestId, hookId, type, level, startTime, endTime, success, error) { if (!this.enabled) return; const trace = this.traces.get(requestId); if (!trace) return; trace.traces.push({ hookId, type, level, startTime, endTime, duration: endTime - startTime, success, error, order: trace.traces.length, }); } getHookTrace(requestId) { return this.traces.get(requestId); } getAllTraces() { return Array.from(this.traces.values()); } clear() { this.traces.clear(); } clearRequest(requestId) { this.traces.delete(requestId); } } //# sourceMappingURL=hook-playback.js.map