import * as react_jsx_runtime from 'react/jsx-runtime'; import { ReactNode } from 'react'; import { AgentBuilderConfig, Message, ThreadMessage, SubagentThreadMessage, GroupedThreadMessage, ConnectionStatus as ConnectionStatus$1, SendMessagePayload, ThreadFile, PendingAttachment } from '@standardagents/client'; export { AgentBuilderClient, AgentBuilderConfig, AttachmentPayload, AttachmentRef, CreateThreadPayload, CustomEvent, ErrorEvent, FileUploadManager, GetMessagesOptions, GroupedThreadMessage, LogDataEvent, LogStreamEvent, LogWebSocketCallbacks, Message, MessageChunkEvent, MessageDataEvent, MessageStreamEvent, MessageWebSocketCallbacks, PendingAttachment, SendMessagePayload, StatusMessage, StoppedByUserEvent, SubagentBlockMessage, SubagentThreadMessage, Thread, ThreadConnectionCallbacks, ThreadConnectionManager, ThreadConnectionOptions, ThreadEvent, ThreadFile, ThreadMessage, WorkItem, WorkMessage, generatePendingFileId, isImageMimeType, messagesToFiles, parseAttachments, readFileAsDataUrl, transformToSubagentBlocks, transformToWorkblocks } from '@standardagents/client'; interface AgentBuilderProviderProps { config: AgentBuilderConfig; children: ReactNode; } /** * AgentBuilderProvider provides the AgentBuilder client instance to all child components. * This should wrap the part of your app where you want to use AgentBuilder functionality. * * @example * ```tsx * * * * ``` */ declare function AgentBuilderProvider({ config, children }: AgentBuilderProviderProps): react_jsx_runtime.JSX.Element; interface ThreadProviderOptions { /** Whether to preload messages on mount (default: true) */ preload?: boolean; /** Whether to connect to live updates (default: true) */ live?: boolean; /** Transform messages to workblocks (default: false) */ useWorkblocks?: boolean; /** Transform messages to subagent blocks (default: false) */ useSubagentBlocks?: boolean; /** Maximum message depth to fetch/stream (default: 0) */ depth?: number; /** Whether to include silent messages (default: false) */ includeSilent?: boolean; } /** * Event listener callback type */ type EventListener = (data: T) => void; /** * WebSocket connection status */ type ConnectionStatus = ConnectionStatus$1; /** * Thread context value - the public interface returned by useThread() */ interface ThreadContextValue { /** The thread ID */ threadId: string; /** Current messages in the thread */ messages: Message[]; /** Messages transformed to workblocks (if useWorkblocks is true) */ workblocks: ThreadMessage[]; /** Messages transformed to subagent blocks (if useSubagentBlocks is true) */ subagentBlocks: SubagentThreadMessage[]; /** Active grouped message view based on options (subagent blocks > workblocks > raw) */ groupedMessages: GroupedThreadMessage[]; /** Whether messages are currently loading (alias: isLoading) */ loading: boolean; /** Whether messages are currently loading (alias for loading) */ isLoading: boolean; /** Any error that occurred */ error: Error | null; /** WebSocket connection status (alias: status) */ connectionStatus: ConnectionStatus; /** WebSocket connection status (alias for connectionStatus) */ status: ConnectionStatus; /** Subscribe to a specific event type (alias: onEvent) */ subscribeToEvent: (eventType: string, listener: EventListener) => () => void; /** Subscribe to a specific event type (alias for subscribeToEvent) */ onEvent: (eventType: string, listener: EventListener) => () => void; /** Options passed to the provider */ options: ThreadProviderOptions; /** Send a message to the thread (auto-includes pending attachments) */ sendMessage: (payload: Omit) => Promise; /** Stop the current execution */ stopExecution: () => Promise; /** Delete a message from the thread (optimistically removes from UI) */ deleteMessage: (messageId: string) => Promise; /** All files in the thread (pending uploads + committed from messages) */ files: ThreadFile[]; /** Add files and start uploading immediately to filesystem */ addFiles: (files: File[] | FileList) => void; /** Remove a pending file (cannot remove committed files) */ removeFile: (id: string) => void; /** Get the full URL for a file */ getFileUrl: (file: ThreadFile) => string; /** Get the thumbnail URL for an image file */ getThumbnailUrl: (file: ThreadFile) => string; /** Get preview URL - localPreviewUrl for pending images, thumbnail for committed */ getPreviewUrl: (file: ThreadFile) => string | null; /** Pending attachments to be sent with next message */ attachments: PendingAttachment[]; /** Add attachment(s) to be sent with next message (no upload, stored locally) */ addAttachment: (files: File | File[] | FileList) => void; /** Remove a pending attachment */ removeAttachment: (id: string) => void; /** Clear all pending attachments */ clearAttachments: () => void; } interface ThreadProviderProps { /** The thread ID to connect to */ threadId: string; /** Provider options */ options?: ThreadProviderOptions; /** Whether to preload messages on mount (default: true) */ preload?: boolean; /** Whether to enable live updates via WebSocket (default: true) */ live?: boolean; /** Transform messages to workblocks (default: false) */ useWorkblocks?: boolean; /** Transform messages to subagent blocks (default: false) */ useSubagentBlocks?: boolean; /** Maximum message depth to fetch/stream (default: 0 for top-level only) */ depth?: number; /** Whether to include silent messages (default: false) */ includeSilent?: boolean; /** Optional endpoint override */ endpoint?: string; children: ReactNode; } /** * ThreadProvider establishes a WebSocket connection to a thread and provides * context for child components to access messages and events. * * Must be nested inside AgentBuilderProvider. * * @example * ```tsx * * * * * * ``` */ declare function ThreadProvider({ threadId, options, preload, live, useWorkblocks, useSubagentBlocks, depth, includeSilent, endpoint: endpointOverride, children, }: ThreadProviderProps): react_jsx_runtime.JSX.Element; /** * @deprecated Use `useThread()` instead. * * Hook to access the thread context. * Must be used within a ThreadProvider. * * @throws Error if used outside of ThreadProvider */ declare function useThreadContext(): ThreadContextValue; /** * Hook to get the current thread ID from context. * Must be used within a ThreadProvider. */ declare function useThreadId(): string; /** * Hook to access the thread context. * * Must be used within a ThreadProvider. Returns the full thread context * including messages, actions, and file management. * * @returns The thread context value * * @example * ```tsx * function ChatMessages() { * const { messages, sendMessage, files } = useThread() * * return ( *
* {messages.map(msg => )} * *
* ) * } * * // Wrap with ThreadProvider * * * * ``` */ declare function useThread(): ThreadContextValue; /** * Hook to listen for custom events emitted from a thread via the stream WebSocket. * Calls the provided callback whenever an event of the specified type is received. * * Must be used within a ThreadProvider. Events are emitted from the backend * using `emitThreadEvent(flow, 'event-type', data)`. * * @param type - The custom event type to filter for * @param callback - Function to call when an event of this type is received * * @example * ```tsx * function GamePreview() { * const [gameHtml, setGameHtml] = useState(null) * * onThreadEvent('game_built', (data: { success: boolean }) => { * if (data.success) { * fetchGameHtml() * } * }) * * return