import { SDKPluginOptions } from '../utils'; import { CSSProperties } from 'react'; export interface AiChatOptions extends SDKPluginOptions { /** * Custom endpoint for the chat API * @examples * chatApi: '/my/ai/chat' * chatApi: () => '/my/ai/chat' */ chatApi?: string | '__fn__'; /** * Customize or extend the default client-side tools * @examples * tools: ({ defaultTools, editor }) => ({ * ...defaultTools, * getUserLocation: { * async execute() { * const location = await getLocationViaBrowserAPI(); * return `User location: ${location.city}`; * } * } * }) */ tools?: '__fn__'; /** * Callback when a client tool call is made * @examples * onTool: ({ toolCall }) => { * console.log('Tool call:', toolCall); * } */ onTool?: '__fn__'; /** * Customize UI layout component props * @examples * layoutComponents: { * aiChatInput: () => ({ * maxImages: 3, * }), * } */ layoutComponents?: object; /** * Initial messages or async function to load messages * @examples * // Static messages * messages: [{ id: '1', role: 'user', ... }] * // Dynamic loading * messages: async () => { * return await loadFromDatabase(); * } */ messages?: object | '__fn__'; /** * Callback when messages are updated (for persistence) * @examples * onMessagesUpdate: async ({ messages }) => { * await saveToDatabase(messages); * } */ onMessagesUpdate?: '__fn__'; /** * Request body for API calls (merged with default body) * @examples * body: ({ body }) => ({ * ...body, * projectId: 'my-project' * }) * body: { projectId: 'my-project' } */ body?: object | '__fn__'; /** * Function to get the access token * @examples * getAccessToken: async () => { * const result = await fetch('/api/access-tokens', { * method: 'POST', * }).then(response => response.json()); * return result; * } */ getAccessToken?: '__fn__'; /** * Additional [chat options](https://ai-sdk.dev/docs/reference/ai-sdk-ui/use-chat). * @examples * chatOptions: { * onData: data => console.log('onData:', data), * onError: error => console.log('onError:', error), * onFinish: result => console.log('onFinish:', result) * } */ chatOptions?: object; } export interface CommonComponentPropsSchema { /** * Custom class name. */ className?: string; /** * Custom styles. */ style?: CSSProperties; } export interface AiChatPanelPropsSchema extends CommonComponentPropsSchema { /** * GrapesJS editor instance */ editor: object; /** * AI Chat plugin options */ pluginOptions: object; } export interface AiChatHeaderPropsSchema { /** * Custom title for the header. */ title?: string; /** * Custom layout rendered before the header content. */ layoutBefore?: '__fn__'; /** * Custom layout rendered after the header content. */ layoutAfter?: '__fn__'; /** * Props forwarded to the clear button. * Use `onClear` to customize clear behavior. */ clearButtonProps?: object; /** * Custom clear handler. * Receives `chatApi`, `clear`, and click `event`. */ onClear?: '__fn__'; } export interface AiChatErrorPropsSchema { } export interface AiChatLoadingStatePropsSchema { } export interface AiChatInputPropsSchema { /** * Maximum number of assets per message. Set to 0 to disable asset attachments. * @default 5 */ maxAssets?: number; /** * Accepted file types for attachments. * @default 'image/jpeg,image/png,image/gif,image/webp,application/pdf' */ acceptAssetType?: string; /** * Custom upload function for assets. * If not provided, the upload from AssetManager will be used. * @examples * uploadProjectAssets: async ({ files }) => { * const uploaded = await uploadToServer(files); * return uploaded.map(asset => ({ id: asset.id, src: asset.url, ... })); * } */ uploadProjectAssets?: '__fn__'; /** * Custom layout rendered before the main input container. */ layoutBefore?: '__fn__'; /** * Custom layout rendered after the main input container. */ layoutAfter?: '__fn__'; /** * Custom submit handler. When provided, the default submit is skipped. * Receives the form event, a `submit` callback to trigger the original submit, and the current input state. */ onSubmit?: '__fn__'; /** * Props forwarded to the context section (selected components indicator). */ contextSectionProps?: object; /** * Props forwarded to the textarea element. */ textareaProps?: object; /** * Props forwarded to the assets section. */ assetsSectionProps?: object; /** * Props forwarded to the attach button. */ attachButtonProps?: object; /** * Props forwarded to the dictate button. */ dictateButtonProps?: object; /** * Props forwarded to the submit button. */ submitButtonProps?: object; /** * Default value for the text input. */ value?: string; } export interface AiChatEmptyStatePropsSchema { /** * Suggestions to show in the empty state. * @examples * suggestions: [{ id: 'webHero', label: 'Create hero', prompt: 'Create a hero section' }] */ suggestions?: object[]; } export interface AiChatMessagePropsSchema { /** * Chat message to render */ message: object; /** * Indicates if the message is currently streaming */ isStreaming?: boolean; /** * Render source parts (source-url/source-document) when available. * @default false */ showSources?: boolean; /** * Custom layout before the message */ layoutBeforeMessage?: '__fn__'; /** * Custom layout after the message */ layoutAfterMessage?: '__fn__'; /** * Custom layout for message parts */ layoutPart?: '__fn__'; /** * Custom layout for tool label parts */ layoutPartToolLabel?: '__fn__'; /** * Custom layout for tool detail parts */ layoutPartToolDetail?: '__fn__'; /** * Custom layout for tool result parts */ layoutPartToolResult?: '__fn__'; } export interface AiChatMessagesPropsSchema { /** * GrapesJS editor instance */ editor: object; /** * Chat context */ chatContext: object; /** * Messages to render */ messages: object[]; /** * AI Chat plugin options */ pluginOptions: object; } export interface AiChatMessagesStatusPropsSchema { } export interface AiChatProviderPropsSchema { /** * Chat manager instance */ chatManager: object; /** * Provider children */ children: object; }