import { WorkflowEvent, Result } from 'awaitly'; export { ScopeType } from 'awaitly'; import { g as DiagramSource, h as ExportFormat, i as ExportOptions, D as DecisionStartEvent, a as DecisionBranchEvent, b as DecisionEndEvent, S as ScopeStartEvent, c as ScopeEndEvent, W as WorkflowIR, O as OutputFormat, V as VisualizerOptions } from './url-CKfrOJ3y.js'; export { A as ActiveStepSnapshot, B as BaseNode, C as ColorScheme, d as DecisionBranch, e as DecisionEvent, f as DecisionNode, E as EnhancedRenderOptions, F as FlowNode, j as FlowchartRenderOptions, H as HTMLRenderOptions, k as HTMLTheme, l as HeatLevel, m as HeatmapData, n as HookExecution, o as HookState, I as IRSnapshot, K as KrokiExportOptions, p as KrokiFormat, L as LayoutDirection, q as LiveVisualizerOptions, M as MermaidInkExportOptions, r as MermaidRenderOptions, N as NodePerformance, P as ParallelNode, R as RaceNode, s as RenderOptions, t as Renderer, u as ScopeEvent, v as SequenceNode, w as ServerMessage, x as StepNode, y as StepSkippedEvent, z as StepState, G as StreamNode, T as TimeTravelState, U as UrlGeneratorOptions, J as VisualizingWorkflowOptions, Q as WebVisualizerMessage, X as WorkflowHooks, Y as WorkflowNode, Z as createUrlGenerator, _ as hasChildren, $ as isDecisionNode, a0 as isParallelNode, a1 as isRaceNode, a2 as isSequenceNode, a3 as isStepNode, a4 as isStreamNode, a5 as toKrokiPngUrl, a6 as toKrokiSvgUrl, a7 as toKrokiUrl } from './url-CKfrOJ3y.js'; export { D as DecisionTracker, H as HookLog, I as IRBuilderOptions, a as IfTracker, L as LiveVisualizer, b as LoggerOutput, c as LoggerRenderOptions, P as ParallelDetectorOptions, d as PerformanceAnalyzer, S as StepLog, e as SwitchTracker, T as TimeTravelController, f as TimeTravelOptions, W as WorkflowRun, g as WorkflowSummary, h as asciiRenderer, i as createIRBuilder, x as createLiveVisualizer, j as createParallelDetector, k as createPerformanceAnalyzer, l as createTimeTravelController, m as defaultColorScheme, n as detectParallelGroups, o as flowchartRenderer, p as getHeatLevel, q as htmlRenderer, r as loggerRenderer, s as mermaidRenderer, t as renderToHTML, u as trackDecision, v as trackIf, w as trackSwitch } from './performance-analyzer-DC60uCY-.js'; export { D as DiagramProvider, K as KrokiProviderOptions, M as MermaidInkFormat, a as MermaidInkGenerator, b as MermaidInkImageType, c as MermaidInkOptions, d as MermaidInkPaperSize, e as MermaidInkProviderOptions, f as MermaidInkTheme, P as ProviderOptions, g as buildMermaidInkUrl, h as createMermaidInkGenerator, i as encodeForMermaidInk, t as toMermaidInkJpegUrl, j as toMermaidInkPdfUrl, k as toMermaidInkPngUrl, l as toMermaidInkSvgUrl, m as toMermaidInkUrl, n as toMermaidInkWebpUrl } from './types-DjSWix07.js'; /** * devEvents — stream workflow events into the awaitly dev inspector. * * Wire it to any workflow's onEvent and every run appears live in the * inspector page served by `awaitly-analyze --dev`: * * ```typescript * import { devEvents } from "awaitly-visualizer"; * * const workflow = createWorkflow("checkout", deps, { * onEvent: devEvents("http://localhost:4747"), * }); * ``` * * Events are batched per microtask and POSTed fire-and-forget; a dead or * absent inspector never affects the workflow. */ declare function devEvents(url?: string): (event: WorkflowEvent) => void; /** * Unified Export URL Generation * * Generates export URLs from diagram sources using configured providers. * Decoupled from IR - takes already-rendered diagram text. */ /** * Error types for export URL generation. */ type ExportUrlError = "UNSUPPORTED_DIAGRAM_KIND" | "UNSUPPORTED_FORMAT" | "UNKNOWN_PROVIDER"; /** * Internal context for export operations. * Used to provide caller context in error messages. */ interface ExportContext { /** The calling method name (e.g., "toSvgUrl") */ caller?: string; } /** * Generate export URL from diagram source. * Decoupled from IR - takes already-rendered diagram text. * * @param diagram - The diagram source (kind + text) * @param format - Export format (svg, png, pdf) * @param options - Provider-specific options * @param ctx - Optional context for error messages * @returns Result with export URL or ExportUrlError * * @example * ```typescript * const result = toExportUrl( * { kind: "mermaid", source: "flowchart TD\n A-->B" }, * "svg", * { provider: "kroki" } * ); * if (result.ok) { * console.log(result.value); * } * ``` */ declare function toExportUrl(diagram: DiagramSource, format: ExportFormat, options: ExportOptions, ctx?: ExportContext): Result; /** * Interactive Mermaid CDN HTML Generator * * Generates a self-contained HTML file that uses Mermaid CDN to render * workflow diagrams with click-to-inspect interactivity, 6 themes, * and a theme picker. * * Moved from awaitly-analyze so the template is reusable across packages. * * Pipeline: * mermaidText + WorkflowMetadata → generateInteractiveHTML() → .html file */ /** Source location for a node in the analyzed source. */ interface MermaidHTMLSourceLocation { filePath: string; line: number; column: number; } /** Retry configuration for display in the inspector panel. */ interface MermaidHTMLRetryConfig { attempts?: number | string; backoff?: string; baseDelay?: number | string; retryOn?: string; } /** Timeout configuration for display in the inspector panel. */ interface MermaidHTMLTimeoutConfig { ms?: number | string; } interface NodeMetadata { /** Allow extra properties (e.g. errorType from analyzer) so consumers can assign without casting. */ [key: string]: unknown; /** Mermaid node ID (matches the ID in the rendered diagram) */ mermaidId: string; /** Node type from the IR */ type: string; /** Human-readable name */ name: string; /** Step ID (for step nodes) */ stepId?: string; /** Function callee */ callee?: string; /** Description */ description?: string; /** Source location */ location?: MermaidHTMLSourceLocation; /** Retry configuration */ retry?: MermaidHTMLRetryConfig; /** Timeout configuration */ timeout?: MermaidHTMLTimeoutConfig; /** Condition expression (for decisions/conditionals) */ condition?: string; /** Helper used (when/unless) */ helper?: string; /** Error tags */ errors?: string[]; /** Input type */ inputType?: string; /** Output type */ outputType?: string; /** Error type (from Result/AsyncResult, e.g. "NOT_FOUND" | "FETCH_ERROR") */ errorType?: string; /** Output key */ out?: string; /** Keys this step reads */ reads?: string[]; /** Parallel mode */ mode?: string; /** Children count */ childCount?: number; /** Loop type */ loopType?: string; /** Iteration source */ iterSource?: string; /** Bound count for loops */ boundCount?: number; /** Stream type */ streamType?: string; /** Stream namespace */ namespace?: string; /** Referenced workflow name */ workflowName?: string; /** Whether reference is resolved */ resolved?: boolean; /** Has compensation (saga steps) */ hasCompensation?: boolean; /** Compensation callee */ compensationCallee?: string; /** Switch expression */ expression?: string; /** Switch cases */ cases?: Array<{ value?: string; isDefault: boolean; }>; /** Connected incoming edges */ incomingFrom?: string[]; /** Connected outgoing edges */ outgoingTo?: string[]; } interface WorkflowMetadata { /** Workflow name */ workflowName: string; /** Workflow description */ description?: string; /** Source file */ filePath: string; /** Analysis stats */ stats: { totalSteps: number; conditionalCount: number; parallelCount: number; raceCount: number; loopCount: number; }; /** Node metadata keyed by Mermaid node ID */ nodes: Record; } interface InteractiveHTMLOptions { /** Page title (defaults to workflow name) */ title?: string; /** Initial theme name (defaults to system preference auto-detection) */ theme?: string; /** Mermaid CDN URL (defaults to latest) */ mermaidCdnUrl?: string; /** Diagram direction for display */ direction?: "TB" | "LR" | "BT" | "RL"; } /** * Generate a self-contained interactive HTML file. * * @param mermaidText - Mermaid flowchart text from renderStaticMermaid() * @param metadata - Workflow metadata from extractNodeMetadata() * @param options - HTML generation options */ declare function generateInteractiveHTML(mermaidText: string, metadata: WorkflowMetadata, options?: InteractiveHTMLOptions): string; declare function escapeHtml(str: string): string; /** * Workflow Visualization Module * * Provides tools for visualizing workflow execution with color-coded * step states and support for parallel/race operations. * * @example * ```typescript * import { createVisualizer } from 'awaitly-visualizer'; * * const viz = createVisualizer({ workflowName: 'checkout' }); * const workflow = createWorkflow(deps, { onEvent: viz.handleEvent }); * * await workflow.run(async ({ step }) => { * await step(() => validateCart(cart), 'Validate cart'); * await step(() => processPayment(payment), 'Process payment'); * }); * * console.log(viz.render()); * ``` */ /** * Workflow visualizer that processes events and renders output. */ interface WorkflowVisualizer { /** Process a workflow event */ handleEvent: (event: WorkflowEvent) => void; /** Process a scope event (parallel/race) */ handleScopeEvent: (event: ScopeStartEvent | ScopeEndEvent) => void; /** Process a decision event (conditional branches) */ handleDecisionEvent: (event: DecisionStartEvent | DecisionBranchEvent | DecisionEndEvent) => void; /** Get current IR state */ getIR: () => WorkflowIR; /** Render current state using the default renderer */ render: () => string; /** Render to a specific format */ renderAs: (format: OutputFormat) => string; /** Reset state for a new workflow */ reset: () => void; /** Subscribe to IR updates (for live visualization) */ onUpdate: (callback: (ir: WorkflowIR) => void) => () => void; /** * Generate export URL for the current workflow diagram. * Requires explicit provider unless export.default is configured. * * @param format - Export format (svg, png, pdf) * @param options - Provider options (required unless default configured) * @returns The export URL * @throws If no provider configured and none passed * @throws If format not supported by provider */ toUrl: (format: ExportFormat, options?: ExportOptions) => string; /** * Generate SVG export URL for the current workflow diagram. * Requires explicit provider unless export.default is configured. * * @param options - Provider options (required unless default configured) * @returns The SVG export URL * @throws If no provider configured and none passed */ toSvgUrl: (options?: ExportOptions) => string; /** * Generate PNG export URL for the current workflow diagram. * Requires explicit provider unless export.default is configured. * * @param options - Provider options (required unless default configured) * @returns The PNG export URL * @throws If no provider configured and none passed */ toPngUrl: (options?: ExportOptions) => string; /** * Generate PDF export URL for the current workflow diagram. * Requires explicit provider unless export.default is configured. * Note: Kroki does not support PDF for mermaid diagrams. * * @param options - Provider options (required unless default configured) * @returns The PDF export URL * @throws If no provider configured and none passed * @throws If provider doesn't support PDF (e.g., Kroki for mermaid) */ toPdfUrl: (options?: ExportOptions) => string; } /** * Create a workflow visualizer. * * @example * ```typescript * const viz = createVisualizer({ workflowName: 'my-workflow' }); * * const workflow = createWorkflow(deps, { * onEvent: viz.handleEvent, * }); * * await workflow.run(async ({ step }) => { ... }); * * console.log(viz.render()); * ``` */ declare function createVisualizer(options?: VisualizerOptions): WorkflowVisualizer; /** * Combine multiple event handlers into one. * Use when you need visualization + logging + custom handlers. * * @example * ```typescript * const viz = createVisualizer({ workflowName: 'checkout' }); * const workflow = createWorkflow(deps, { * onEvent: combineEventHandlers( * viz.handleEvent, * (e) => console.log(e.type), * (e) => metrics.track(e), * ), * }); * ``` */ declare function combineEventHandlers(...handlers: Array<(event: WorkflowEvent, ctx?: C) => void>): (event: WorkflowEvent, ctx: C) => void; /** * Union type for all collectable/visualizable events (workflow + decision). */ type CollectableEvent = WorkflowEvent | DecisionStartEvent | DecisionBranchEvent | DecisionEndEvent; /** * Visualize collected events (post-execution). * * Supports both workflow events (from onEvent) and decision events * (from trackDecision/trackIf/trackSwitch). * * @example * ```typescript * const events: CollectableEvent[] = []; * const workflow = createWorkflow(deps, { * onEvent: (e) => events.push(e), * }); * * await workflow.run(async ({ step }) => { * const decision = trackIf('check', condition, { * emit: (e) => events.push(e), * }); * // ... * }); * * console.log(visualizeEvents(events)); * ``` */ declare function visualizeEvents(events: CollectableEvent[], options?: VisualizerOptions): string; /** * Create an event collector for later visualization. * * Supports both workflow events (from onEvent) and decision events * (from trackDecision/trackIf/trackSwitch). * * @example * ```typescript * const collector = createEventCollector(); * * const workflow = createWorkflow(deps, { * onEvent: collector.handleEvent, * }); * * await workflow.run(async ({ step }) => { * // Decision events can also be collected * const decision = trackIf('check', condition, { * emit: collector.handleDecisionEvent, * }); * // ... * }); * * console.log(collector.visualize()); * ``` */ declare function createEventCollector(options?: VisualizerOptions): { /** Handle a workflow event */ handleEvent: (event: WorkflowEvent) => void; /** Handle a decision event */ handleDecisionEvent: (event: DecisionStartEvent | DecisionBranchEvent | DecisionEndEvent) => void; /** Get all collected events */ getEvents: () => CollectableEvent[]; /** Get workflow events only */ getWorkflowEvents: () => WorkflowEvent[]; /** Get decision events only */ getDecisionEvents: () => (DecisionStartEvent | DecisionBranchEvent | DecisionEndEvent)[]; /** Clear collected events */ clear: () => void; /** Visualize collected events */ visualize: () => string; /** Visualize in a specific format */ visualizeAs: (format: OutputFormat) => string; }; export { type CollectableEvent, DecisionBranchEvent, DecisionEndEvent, DecisionStartEvent, DiagramSource, ExportFormat, ExportOptions, type InteractiveHTMLOptions, type MermaidHTMLRetryConfig, type MermaidHTMLSourceLocation, type MermaidHTMLTimeoutConfig, type NodeMetadata, OutputFormat, ScopeEndEvent, ScopeStartEvent, VisualizerOptions, WorkflowIR, type WorkflowMetadata, type WorkflowVisualizer, combineEventHandlers, createEventCollector, createVisualizer, devEvents, escapeHtml, generateInteractiveHTML, toExportUrl, visualizeEvents };