/** * ChatGPT Apps SDK Integration * * Hooks and utilities for integrating Zendir UI components with ChatGPT's * window.openai API. Based on: https://developers.openai.com/apps-sdk/build/chatgpt-ui/ * * Key capabilities: * - window.openai.toolInput / toolOutput - Tool data from MCP server * - window.openai.widgetState / setWidgetState - Persistent UI state * - window.openai.callTool - Invoke other MCP tools from widget * - window.openai.sendFollowUpMessage - Insert user messages * - window.openai.theme - Light/dark theme detection * - window.openai.locale - Localization * - window.openai.requestDisplayMode - Fullscreen/PiP modes * - window.openai.notifyIntrinsicHeight - Dynamic height reporting */ export interface OpenAiGlobals { /** Arguments supplied when the tool was invoked */ toolInput?: Record; /** Your structuredContent - the model reads this */ toolOutput?: Record; /** Metadata payload - only widget sees it */ toolResponseMetadata?: Record; /** Snapshot of UI state persisted between renders */ widgetState?: Record; /** Current theme */ theme?: "light" | "dark"; /** Current locale (e.g., 'en-US') */ locale?: string; /** Display mode */ displayMode?: "inline" | "pip" | "fullscreen"; /** Maximum allowed height */ maxHeight?: number; /** View type */ view?: "conversation" | "modal"; /** User agent info */ userAgent?: string; /** Safe area insets */ safeArea?: { top: number; bottom: number; left: number; right: number; }; setWidgetState?: (state: Record) => void; callTool?: (name: string, args: Record) => Promise; sendFollowUpMessage?: (options: { prompt: string; }) => Promise; uploadFile?: (file: File) => Promise<{ fileId: string; }>; getFileDownloadUrl?: (options: { fileId: string; }) => Promise<{ downloadUrl: string; }>; requestDisplayMode?: (options: { mode: "inline" | "pip" | "fullscreen"; }) => Promise; requestModal?: (options: unknown) => Promise; notifyIntrinsicHeight?: (height: number) => void; openExternal?: (options: { href: string; }) => void; requestClose?: () => void; } declare global { interface Window { openai?: OpenAiGlobals; } } /** * Subscribe to a specific window.openai global value */ export declare function useOpenAiGlobal(key: K): OpenAiGlobals[K]; type SetStateAction = T | ((prevState: T) => T); /** * Manage widget state that persists across renders via window.openai.setWidgetState */ export declare function useWidgetState>(defaultState: T | (() => T)): readonly [T, (state: SetStateAction) => void]; /** * Read the tool output (structuredContent) from the MCP server response */ export declare function useToolOutput>(): T | undefined; /** * Read the tool input (arguments) from the tool invocation */ export declare function useToolInput>(): T | undefined; export type ThemeMode = "light" | "dark"; /** * Get current ChatGPT theme and provide CSS-friendly values * Named useChatGPTTheme to avoid conflict with the core useTheme from ThemeProvider */ export declare function useChatGPTTheme(): { theme: ThemeMode; isDark: boolean; colors: { background: string; surface: string; surfaceHover: string; border: string; text: string; textMuted: string; accent: string; }; }; /** * Get current locale for internationalization */ export declare function useLocale(): string; /** * Manage widget display mode (inline, PiP, fullscreen) */ export declare function useDisplayMode(): { mode: "inline" | "pip" | "fullscreen"; maxHeight?: number; requestMode: (mode: "inline" | "pip" | "fullscreen") => Promise; close: () => void; }; /** * Call another MCP tool from within a widget */ export declare function useCallTool(): { callTool: (name: string, args: Record) => Promise; isLoading: boolean; error: Error | null; }; /** * Send a follow-up message as if the user asked it */ export declare function useSendMessage(): (prompt: string) => Promise; /** * Get the maximum height available for the widget from the host environment. * This is the CORRECT pattern per OpenAI Apps SDK examples. * * The host (ChatGPT/MCPJam) provides maxHeight, and widgets should constrain * themselves to this height. Widgets should NOT report their height back. * * @returns The maximum height in pixels, or undefined if not available */ export declare function useMaxHeight(): number | undefined; /** * Open vetted external links in the user's browser */ export declare function useOpenExternal(): (href: string) => void; export declare function isInChatGPT(): boolean; export {};