export interface WebGpuDeviceLostDetails { recoverable: true; nextAction: 'reload-model'; stage: 'load' | 'generate' | 'score-sequence' | 'backend-report'; modelId: string; cpuFallbackAvailable: boolean; signal: { line: string; reason: number | null; message: string | null; }; } export class EngineRuntimeError extends Error { readonly code: string; readonly details?: unknown; constructor(code: string, message: string, details?: unknown) { super(message); this.name = 'EngineRuntimeError'; this.code = code; this.details = details; } } export function abortError(): DOMException { return new DOMException('The engine operation was aborted.', 'AbortError'); } export function throwIfAborted(signal: AbortSignal): void { if (signal.aborted) { throw abortError(); } }