/** * PhotonHost - Host-side manager for custom UI iframes * * Manages communication between the Photon runtime and custom UI components * rendered in iframes. Handles: * - Sending emit/progress events to the UI * - Routing elicitation requests and collecting responses * - Tool invocations from the UI * * Usage: * const host = new PhotonHost(iframe, { photon: 'demo', method: 'search' }); * host.sendEmit({ emit: 'progress', value: 0.5, message: 'Loading...' }); * const response = await host.askElicitation({ ask: 'text', message: 'Name?' }); */ interface HTMLIFrameElement { contentWindow: { postMessage(message: any, targetOrigin: string): void; } | null; } import type { EmitEvent, AskEvent, PhotonContext } from './photon-bridge.js'; export interface PhotonHostOptions { photon: string; method: string; toolInput: Record; theme?: 'light' | 'dark'; locale?: string; displayMode?: 'inline' | 'fullscreen' | 'modal'; hostName?: string; hostVersion?: string; onCallTool?: (toolName: string, args: Record) => Promise; onFollowUp?: (message: string) => void; onStateChange?: (state: any) => void; } /** * PhotonHost manages the host side of the photon bridge communication. * Create one instance per custom UI iframe. */ export declare class PhotonHost { private iframe; private context; private platformContext; private toolInput; private pendingElicitations; private readyPromise; private readyResolve; private messageHandler; private options; constructor(iframe: HTMLIFrameElement, options: PhotonHostOptions); /** * Wait for the iframe UI to be ready */ waitForReady(): Promise; /** * Initialize the bridge - call after iframe loads * Sends initialization messages for all supported platforms: * - MCP Apps Extension (JSON-RPC ui/initialize) * - Photon Bridge (photon:init) * - OpenAI Apps SDK compatible (openai:set_globals) */ initialize(): void; /** * Send an emit event (progress, status, stream) to the UI */ sendEmit(event: EmitEvent): void; /** * Send a progress event */ sendProgress(value: number, message?: string): void; /** * Send a status message */ sendStatus(message: string): void; /** * Request user input via elicitation * Returns a promise that resolves with the user's response */ askElicitation(ask: AskEvent): Promise; /** * Send the final result to the UI */ sendResult(data: any): void; /** * Send an error to the UI */ sendError(message: string, code?: string): void; /** * Update context (theme, locale, etc.) * Sends updates to all supported platforms. */ updateContext(context: Partial): void; /** * Update theme across all platforms */ setTheme(theme: 'light' | 'dark'): void; /** * Clean up - remove message listener */ destroy(): void; private send; private sendRaw; private handleMessage; } /** * Create an OutputHandler that forwards events to a PhotonHost */ export declare function createHostOutputHandler(host: PhotonHost): (yieldValue: any) => void; /** * Create an InputProvider that uses PhotonHost for elicitations */ export declare function createHostInputProvider(host: PhotonHost): (ask: any) => Promise; export {}; //# sourceMappingURL=photon-host.d.ts.map