/** * Rendering pipeline interface and public API. * * ## Pipeline (3 steps) * * 1. **Resolve** — A source node (config, agent) implements `IRenderingSource`. Given a * `IRenderingContext` (graph, source id, callbacks), it produces a `IResolveResult`: * resolved string, which output type to use, and optional reasoning text. * * 2. **Render** — The output type (e.g. plantuml, markdown, wireframe) implements * `IOutputTypeRenderer`. It turns the resolved string into HTML or SVG via `render()`. * Config types in configTypes.ts are the built-in implementations. * * 3. **Display** — The Rendering node picks a view (image viewport vs markdown content) * from `outputType` on the renderer and shows the result. Output menu items (e.g. Export) * come from the source/renderer via `outputMenuDescriptor`. * * ## Implementing a new source * - Implement `IRenderingSource` (resolve + optional output menu). * - Register with `registerSourceRenderingLogic(nodeType, logic)`. * * ## Implementing a new output type * - Add a config type (or equivalent) fulfilling `IOutputTypeRenderer`. * - Register in CONFIG_TYPES and use `getConfigType(id)` in the resolve step. */ import type { ConfigTypeId, ConfigOutputType, OutputMenuDescriptor, OutputMenuItemDescriptor, OutputMenuAction, RenderOptions, } from './configTypes' import type { SourceRenderingLogicContext, ResolvedContentResult, SourceRenderingLogic, } from './sourceRenderingLogic' // --------------------------------------------------------------------------- // Contracts (interfaces) // --------------------------------------------------------------------------- /** Input to the resolve step: graph state and callbacks for the source to use. */ export type IRenderingContext = SourceRenderingLogicContext /** * Result of the resolve step. The source produces a resolved string and declares * which output type (renderer) to use for the render step. */ export interface IResolveResult { /** Resolved content (e.g. after Nunjucks, or agent output). */ resolved: string /** Which output type will render this (e.g. 'plantuml', 'markdown'). */ outputTypeId: ConfigTypeId /** Optional reasoning block for the UI (e.g. agent reasoning). */ reasoning?: string } /** * Contract for a node type that can feed the Rendering node (config, agent, etc.). * Register via registerSourceRenderingLogic(nodeType, logic). * Output menu content is registered per output type in the frontend (outputMenuRegistry). */ export interface IRenderingSource { /** When to re-run: 'auto' on upstream changes, 'manual' only on Run. */ defaultUpdateMode: 'auto' | 'manual' /** Resolve step: produce content and choose output type. */ getResolvedContent(context: IRenderingContext): Promise } /** * Contract for an output type that turns resolved content into HTML/SVG. * Config types (plantuml, markdown, wireframe) implement this. */ export interface IOutputTypeRenderer { id: ConfigTypeId /** How to display: 'image' (viewport) or 'html' (scrollable div). */ outputType: ConfigOutputType /** Render resolved content to HTML or SVG string. */ render(content: string, options?: RenderOptions): Promise /** Optional: output menu items when this type is shown (e.g. Export). */ outputMenuDescriptor?: OutputMenuDescriptor } // --------------------------------------------------------------------------- // Re-exports: source logic (resolve step) // --------------------------------------------------------------------------- export type { SourceRenderingLogic, ResolvedContentResult, SourceRenderingLogicContext } export { registerSourceRenderingLogic, getSourceRenderingLogic } from './sourceRenderingLogic' // --------------------------------------------------------------------------- // Re-exports: output types (render step) and menu // --------------------------------------------------------------------------- export type { ConfigTypeId, ConfigOutputType, OutputMenuDescriptor, OutputMenuItemDescriptor, OutputMenuAction, RenderOptions } export { getConfigType, getConfigTypeId, getConfigContent, outputMenuActionRequiresSvg } from './configTypes' // --------------------------------------------------------------------------- // Re-exports: shared utils (pure helpers used by hook and views) // --------------------------------------------------------------------------- export { parseThinkSections, processSvgDisplay, stripTemplateSyntax } from './renderingUtils'