/** * UI Resource Handler * * Handles resources/read requests for ui:// URIs, serving widget HTML * from the ToolUIRegistry. * * Supported URI format: * - ui://widget/{toolName}.html - Static widget HTML (pre-compiled at startup) * * The static widget is registered at server startup for tools with * `servingMode: 'static'`. The widget HTML includes the FrontMCP Bridge * which reads tool output from the platform context at runtime. * * @example * ```typescript * // Client requests widget HTML (OpenAI discovery) * const result = await client.readResource({ * uri: 'ui://widget/get_weather.html' * }); * * // Returns pre-compiled widget with FrontMCP Bridge * // Widget reads tool output from window.openai.toolOutput at runtime * ``` */ import type { ReadResourceResult } from '@frontmcp/protocol'; import type { AIPlatformType } from '../../notification/notification.service'; import { type ToolUIRegistry } from './ui-shared'; /** * Result of handling a UI resource request */ export interface UIResourceHandleResult { /** Whether the URI was handled */ handled: boolean; /** The resource result if handled successfully */ result?: ReadResourceResult; /** Error message if handling failed */ error?: string; } /** * Options for handling a UI resource read request */ export interface HandleUIResourceOptions { /** The UI resource URI */ uri: string; /** The ToolUIRegistry containing cached HTML */ registry: ToolUIRegistry; /** Platform type of the connected client */ platformType?: AIPlatformType; } /** * Handle a UI resource read request * * @param uri - The UI resource URI * @param registry - The ToolUIRegistry containing cached HTML * @param platformType - Optional platform type for dynamic MIME type selection * @returns Handle result with content or error */ export declare function handleUIResourceRead(uri: string, registry: ToolUIRegistry, platformType?: AIPlatformType): UIResourceHandleResult; /** * Options for creating a UI resource handler */ export interface UIResourceHandlerOptions { /** ToolUIRegistry instance */ registry: ToolUIRegistry; /** Optional custom error handler */ onError?: (error: string, uri: string) => void; } /** * Create a UI resource handler function * * @param options - Handler options * @returns Handler function that can be used in the read-resource flow */ export declare function createUIResourceHandler(options: UIResourceHandlerOptions): (uri: string) => UIResourceHandleResult; //# sourceMappingURL=ui-resource.handler.d.ts.map