import { z } from 'zod'; import { ComponentType, ReactNode } from 'react'; import { AgentAttachment, AgentToolCall, ModelOption } from '@multiplayer-app/ai-agent-types'; import { Translations } from './translations'; export type AgentTransportMode = 'proxy' | 'direct'; export declare class HttpError extends Error { readonly statusCode: number; constructor(message: string, statusCode: number); } export interface AgentToolHandlerContext { chatId: string; agentId?: string; workspaceId?: string; appendSystemMessage: (message: string) => void; } export type AgentToolInvoke = (input: Record, ctx: AgentToolHandlerContext) => Promise | void>; export interface AgentToolDefinition { name: string; label: string; description?: string; icon?: string; schema?: Record; confirmation?: 'auto' | 'manual'; category?: string; handler?: AgentToolInvoke; } export type AgentThemeColorMode = 'light' | 'dark'; export interface AgentThemeTokens { background: string; surface: string; text: string; subtext: string; border: string; accent: string; accentSoft: string; warning: string; danger: string; fontFamily: string; radius: string; fontSize: string; colorMode: AgentThemeColorMode; } export declare const themeTokenSchema: z.ZodObject<{ background: z.ZodString; surface: z.ZodString; text: z.ZodString; subtext: z.ZodString; border: z.ZodString; accent: z.ZodString; accentSoft: z.ZodString; warning: z.ZodString; danger: z.ZodString; fontFamily: z.ZodString; radius: z.ZodString; fontSize: z.ZodString; colorMode: z.ZodEnum<["light", "dark"]>; }, "strip", z.ZodTypeAny, { background: string; surface: string; text: string; subtext: string; border: string; accent: string; accentSoft: string; warning: string; danger: string; fontFamily: string; radius: string; fontSize: string; colorMode: "light" | "dark"; }, { background: string; surface: string; text: string; subtext: string; border: string; accent: string; accentSoft: string; warning: string; danger: string; fontFamily: string; radius: string; fontSize: string; colorMode: "light" | "dark"; }>; export interface ContextKeyConfig { key: string; label: string; description?: string; tools: string[]; defaultModel?: string; autoConfirmTools?: string[]; } export type ConfirmationMode = 'auto' | 'human'; export interface AgentFeatureFlags { /** * Whether to render inline reasoning traces (AgentMessage.reasoning) * above assistant messages. When omitted, defaults to true. */ reasoning?: boolean; artifactsPanel?: boolean; modelSwitching?: boolean; toolConfiguration?: boolean; /** Show the composer file-attach (paperclip) button. */ fileAttachments?: boolean; /** Show the composer attach-selection (web snippet) button. */ selectionAttachments?: boolean; multiAgentControl?: boolean; sandboxControls?: boolean; /** * Whether to show the chat history sidebar. Defaults to true. */ historySidebar?: boolean; /** * Strategy for generating chat titles: * - "local" (default): use cheap, local heuristics. * - "llm": allow an LLM-backed strategy when the transport supports it. */ titleGeneration?: 'local' | 'llm'; /** * Automatically attach "page context" (URL + metadata) to every outbound user message. * Defaults to true. */ pageContextAttachments?: boolean; } export type PageContextInput = { url?: string; route?: string; title?: string; }; export interface PageContextConfig { /** * Default options for the built-in `pageContext` attachment generation. * These are forwarded into `createPageContextAttachment(...)`. */ includeUserAgent?: boolean; includeReferrer?: boolean; includeViewport?: boolean; includeTitle?: boolean; name?: string; /** * Optional host hook to add additional structured metadata. * Returned object is merged into `metadata.data`. * * Keep this pure and fast; it runs on attach and on route changes. */ getData?: (input: PageContextInput) => Record | undefined; } /** Input passed to chat-metadata providers when a new chat is created. */ export type ChatMetadataInput = { contextKey: string; }; export interface ChatMetadataConfig { /** * Optional host hook contributing metadata persisted on the chat * (`AgentChat.metadata`). Unlike `pageContext.getData` (per-message), this * runs ONCE when a new chat is created; the returned object is merged into * the new chat's `metadata`. Use for stable, chat-scoped facts (e.g. the * active document name/path, a tenant or record id). * * Keep this pure and fast. Returning `title` overrides the auto-generated * chat title. */ getMetadata?: (input: ChatMetadataInput) => Record | undefined; } export type TransportBaseConfig = { mode: AgentTransportMode; timeoutMs?: number; headers?: Record; /** * Optional error handler invoked whenever the transport encounters an HTTP or streaming error. * Use this to surface errors to your own error reporting system or UI toast layer. */ onError?: (error: Error) => void; }; export interface ProxyTransportConfig extends TransportBaseConfig { mode: 'proxy'; baseUrl: string; apiKey?: string; socketPath?: string; /** * Optional Socket.IO namespace to connect to, e.g. "/ai-agent". * When provided, the client will connect to `${socketUrl}${socketNamespace}`. */ socketNamespace?: string; } export interface DirectTransportConfig extends TransportBaseConfig { mode: 'direct'; provider: 'openrouter' | 'openai' | 'custom'; endpoint?: string; apiKey?: string; model?: string; /** * Optional model to use specifically for title generation. * If not provided, falls back to the default `model`. * Useful for using a cheaper/faster model for titles while using * a more capable model for actual conversations. */ titleGenerationModel?: string; } export type AgentTransportConfig = ProxyTransportConfig | DirectTransportConfig; export interface ToolRendererProps { call: AgentToolCall; contextKey: string; chatId: string; rejectButtonText?: string; applyAllButtonText?: string; showStatus?: boolean; } export type ToolRendererComponent = ComponentType; export type ToolRendererRegistry = Record; export type AgentPlanTaskStatus = 'pending' | 'in_progress' | 'done' | 'skipped'; export interface AgentPlanTask { id: string; title: string; status: AgentPlanTaskStatus; } /** A point-in-time snapshot of the agent's task plan. */ export interface AgentPlan { title?: string; tasks: AgentPlanTask[]; } /** * Maps a tool call to a plan snapshot, or undefined when the call carries * none. The newest snapshot across the chat's tool calls drives the pinned * plan-progress panel above the composer; hosts register one extractor per * agent (e.g. reading `createBuildPlan` / `updateBuildTask` outputs). */ export type PlanExtractor = (call: AgentToolCall) => AgentPlan | undefined; export interface ComposerAttachmentActionsProps { /** Active chat id, or draft key when no chat is selected yet. */ chatKey: string; activeChatId?: string; attachments: AgentAttachment[]; addAttachments: (attachments: AgentAttachment[]) => void; removeAttachment: (attachmentId: string) => void; } export type ComposerAttachmentActionsComponent = ComponentType; export interface AgentFrontendConfig { appId: string; workspaceId?: string; debug?: boolean; user?: { id: string; displayName?: string; email?: string; avatarUrl?: string; }; contextKeys: ContextKeyConfig[]; transport: AgentTransportConfig; theme?: Partial; tools?: AgentToolDefinition[]; models?: ModelOption[]; features?: AgentFeatureFlags; /** * Optional page context attachment configuration. * Useful for adding host-specific metadata (e.g. current tenant/project id). */ pageContext?: PageContextConfig; /** * Optional chat-level metadata configuration. Lets the host attach stable * metadata to a chat at creation time (persisted as `AgentChat.metadata`). */ chatMetadata?: ChatMetadataConfig; defaultContextKey?: string; messagesPageSize?: number; toolRenderers?: ToolRendererRegistry; /** * Extracts plan snapshots from tool calls. When set, ChatWindow pins a * minimal plan-progress panel above the composer (collapsed: title + * progress + current task; expanded: the full task list). The panel hides * when the active chat has no plan-carrying tool calls. */ planExtractor?: PlanExtractor; /** * Optional React component rendered in the composer toolbar for host-defined attachment actions. * Use `addAttachments` to attach custom `AgentAttachment` payloads (e.g. context, links). */ composerAttachmentActions?: ComposerAttachmentActionsComponent; /** * Optional translations to override default English strings. * Partial translations are merged with defaults. */ translations?: Partial; /** * Custom icons for context attachments keyed by `metadata.kind`. * When provided, overrides the default icon for that kind. * Example: `{ pageContext: , formSnapshot: }` */ contextAttachmentIcons?: Record; } export declare const contextKeySchema: z.ZodObject<{ key: z.ZodString; label: z.ZodString; description: z.ZodOptional; tools: z.ZodDefault>; defaultModel: z.ZodOptional; autoConfirmTools: z.ZodOptional>; }, "strip", z.ZodTypeAny, { key: string; label: string; tools: string[]; description?: string | undefined; defaultModel?: string | undefined; autoConfirmTools?: string[] | undefined; }, { key: string; label: string; description?: string | undefined; tools?: string[] | undefined; defaultModel?: string | undefined; autoConfirmTools?: string[] | undefined; }>; export declare const frontendConfigSchema: z.ZodObject<{ appId: z.ZodString; workspaceId: z.ZodOptional; debug: z.ZodOptional; user: z.ZodOptional; email: z.ZodOptional; avatarUrl: z.ZodOptional; }, "strip", z.ZodTypeAny, { id: string; displayName?: string | undefined; email?: string | undefined; avatarUrl?: string | undefined; }, { id: string; displayName?: string | undefined; email?: string | undefined; avatarUrl?: string | undefined; }>>; contextKeys: z.ZodArray; tools: z.ZodDefault>; defaultModel: z.ZodOptional; autoConfirmTools: z.ZodOptional>; }, "strip", z.ZodTypeAny, { key: string; label: string; tools: string[]; description?: string | undefined; defaultModel?: string | undefined; autoConfirmTools?: string[] | undefined; }, { key: string; label: string; description?: string | undefined; tools?: string[] | undefined; defaultModel?: string | undefined; autoConfirmTools?: string[] | undefined; }>, "many">; transport: z.ZodUnion<[z.ZodObject<{ mode: z.ZodLiteral<"proxy">; baseUrl: z.ZodString; apiKey: z.ZodOptional; socketPath: z.ZodOptional; socketNamespace: z.ZodOptional; timeoutMs: z.ZodOptional; headers: z.ZodOptional>; }, "strip", z.ZodTypeAny, { mode: "proxy"; baseUrl: string; apiKey?: string | undefined; socketPath?: string | undefined; socketNamespace?: string | undefined; timeoutMs?: number | undefined; headers?: Record | undefined; }, { mode: "proxy"; baseUrl: string; apiKey?: string | undefined; socketPath?: string | undefined; socketNamespace?: string | undefined; timeoutMs?: number | undefined; headers?: Record | undefined; }>, z.ZodObject<{ mode: z.ZodLiteral<"direct">; provider: z.ZodEnum<["openrouter", "openai", "custom"]>; endpoint: z.ZodOptional; apiKey: z.ZodOptional; model: z.ZodOptional; titleGenerationModel: z.ZodOptional; timeoutMs: z.ZodOptional; headers: z.ZodOptional>; }, "strip", z.ZodTypeAny, { mode: "direct"; provider: "custom" | "openrouter" | "openai"; apiKey?: string | undefined; timeoutMs?: number | undefined; headers?: Record | undefined; endpoint?: string | undefined; model?: string | undefined; titleGenerationModel?: string | undefined; }, { mode: "direct"; provider: "custom" | "openrouter" | "openai"; apiKey?: string | undefined; timeoutMs?: number | undefined; headers?: Record | undefined; endpoint?: string | undefined; model?: string | undefined; titleGenerationModel?: string | undefined; }>]>; theme: z.ZodOptional; surface: z.ZodOptional; text: z.ZodOptional; subtext: z.ZodOptional; border: z.ZodOptional; accent: z.ZodOptional; accentSoft: z.ZodOptional; warning: z.ZodOptional; danger: z.ZodOptional; fontFamily: z.ZodOptional; radius: z.ZodOptional; fontSize: z.ZodOptional; colorMode: z.ZodOptional>; }, "strip", z.ZodTypeAny, { background?: string | undefined; surface?: string | undefined; text?: string | undefined; subtext?: string | undefined; border?: string | undefined; accent?: string | undefined; accentSoft?: string | undefined; warning?: string | undefined; danger?: string | undefined; fontFamily?: string | undefined; radius?: string | undefined; fontSize?: string | undefined; colorMode?: "light" | "dark" | undefined; }, { background?: string | undefined; surface?: string | undefined; text?: string | undefined; subtext?: string | undefined; border?: string | undefined; accent?: string | undefined; accentSoft?: string | undefined; warning?: string | undefined; danger?: string | undefined; fontFamily?: string | undefined; radius?: string | undefined; fontSize?: string | undefined; colorMode?: "light" | "dark" | undefined; }>>; tools: z.ZodOptional; icon: z.ZodOptional; schema: z.ZodOptional>; confirmation: z.ZodOptional>; category: z.ZodOptional; }, "strip", z.ZodTypeAny, { label: string; name: string; description?: string | undefined; icon?: string | undefined; schema?: Record | undefined; confirmation?: "auto" | "manual" | undefined; category?: string | undefined; }, { label: string; name: string; description?: string | undefined; icon?: string | undefined; schema?: Record | undefined; confirmation?: "auto" | "manual" | undefined; category?: string | undefined; }>, "many">>; models: z.ZodOptional; reasoning: z.ZodOptional>; contexts: z.ZodOptional>; }, "strip", z.ZodTypeAny, { label: string; id: string; provider?: string | undefined; reasoning?: "disabled" | "concise" | "deep" | undefined; contexts?: string[] | undefined; }, { label: string; id: string; provider?: string | undefined; reasoning?: "disabled" | "concise" | "deep" | undefined; contexts?: string[] | undefined; }>, "many">>; features: z.ZodOptional; artifactsPanel: z.ZodOptional; modelSwitching: z.ZodOptional; toolConfiguration: z.ZodOptional; fileAttachments: z.ZodOptional; selectionAttachments: z.ZodOptional; multiAgentControl: z.ZodOptional; sandboxControls: z.ZodOptional; historySidebar: z.ZodOptional; titleGeneration: z.ZodOptional>; pageContextAttachments: z.ZodOptional; }, "strip", z.ZodTypeAny, { reasoning?: boolean | undefined; artifactsPanel?: boolean | undefined; modelSwitching?: boolean | undefined; toolConfiguration?: boolean | undefined; fileAttachments?: boolean | undefined; selectionAttachments?: boolean | undefined; multiAgentControl?: boolean | undefined; sandboxControls?: boolean | undefined; historySidebar?: boolean | undefined; titleGeneration?: "local" | "llm" | undefined; pageContextAttachments?: boolean | undefined; }, { reasoning?: boolean | undefined; artifactsPanel?: boolean | undefined; modelSwitching?: boolean | undefined; toolConfiguration?: boolean | undefined; fileAttachments?: boolean | undefined; selectionAttachments?: boolean | undefined; multiAgentControl?: boolean | undefined; sandboxControls?: boolean | undefined; historySidebar?: boolean | undefined; titleGeneration?: "local" | "llm" | undefined; pageContextAttachments?: boolean | undefined; }>>; pageContext: z.ZodOptional; includeReferrer: z.ZodOptional; includeViewport: z.ZodOptional; includeTitle: z.ZodOptional; name: z.ZodOptional; }, "strip", z.ZodTypeAny, { name?: string | undefined; includeUserAgent?: boolean | undefined; includeReferrer?: boolean | undefined; includeViewport?: boolean | undefined; includeTitle?: boolean | undefined; }, { name?: string | undefined; includeUserAgent?: boolean | undefined; includeReferrer?: boolean | undefined; includeViewport?: boolean | undefined; includeTitle?: boolean | undefined; }>>; chatMetadata: z.ZodOptional>; defaultContextKey: z.ZodOptional; messagesPageSize: z.ZodOptional; translations: z.ZodOptional; followUp: z.ZodOptional; sendMessage: z.ZodOptional; stopStreaming: z.ZodOptional; typeMessageToSend: z.ZodOptional; attachFiles: z.ZodOptional; attachSelectionToContext: z.ZodOptional; attachments: z.ZodOptional; chats: z.ZodOptional; multiUserChats: z.ZodOptional; noMultiUserChats: z.ZodOptional; noChatsYet: z.ZodOptional; untitledChat: z.ZodOptional; deleteChat: z.ZodOptional; showChatHistory: z.ZodOptional; hideChatHistory: z.ZodOptional; fetchingChats: z.ZodOptional; fetchingChatError: z.ZodOptional; helloThere: z.ZodOptional; howCanIHelpYou: z.ZodOptional; }, "strip", z.ZodTypeAny, { newChat?: string | undefined; followUp?: string | undefined; sendMessage?: string | undefined; stopStreaming?: string | undefined; typeMessageToSend?: string | undefined; attachFiles?: string | undefined; attachSelectionToContext?: string | undefined; attachments?: string | undefined; chats?: string | undefined; multiUserChats?: string | undefined; noMultiUserChats?: string | undefined; noChatsYet?: string | undefined; untitledChat?: string | undefined; deleteChat?: string | undefined; showChatHistory?: string | undefined; hideChatHistory?: string | undefined; fetchingChats?: string | undefined; fetchingChatError?: string | undefined; helloThere?: string | undefined; howCanIHelpYou?: string | undefined; }, { newChat?: string | undefined; followUp?: string | undefined; sendMessage?: string | undefined; stopStreaming?: string | undefined; typeMessageToSend?: string | undefined; attachFiles?: string | undefined; attachSelectionToContext?: string | undefined; attachments?: string | undefined; chats?: string | undefined; multiUserChats?: string | undefined; noMultiUserChats?: string | undefined; noChatsYet?: string | undefined; untitledChat?: string | undefined; deleteChat?: string | undefined; showChatHistory?: string | undefined; hideChatHistory?: string | undefined; fetchingChats?: string | undefined; fetchingChatError?: string | undefined; helloThere?: string | undefined; howCanIHelpYou?: string | undefined; }>>; }, "strip", z.ZodTypeAny, { appId: string; contextKeys: { key: string; label: string; tools: string[]; description?: string | undefined; defaultModel?: string | undefined; autoConfirmTools?: string[] | undefined; }[]; transport: { mode: "proxy"; baseUrl: string; apiKey?: string | undefined; socketPath?: string | undefined; socketNamespace?: string | undefined; timeoutMs?: number | undefined; headers?: Record | undefined; } | { mode: "direct"; provider: "custom" | "openrouter" | "openai"; apiKey?: string | undefined; timeoutMs?: number | undefined; headers?: Record | undefined; endpoint?: string | undefined; model?: string | undefined; titleGenerationModel?: string | undefined; }; tools?: { label: string; name: string; description?: string | undefined; icon?: string | undefined; schema?: Record | undefined; confirmation?: "auto" | "manual" | undefined; category?: string | undefined; }[] | undefined; workspaceId?: string | undefined; debug?: boolean | undefined; user?: { id: string; displayName?: string | undefined; email?: string | undefined; avatarUrl?: string | undefined; } | undefined; theme?: { background?: string | undefined; surface?: string | undefined; text?: string | undefined; subtext?: string | undefined; border?: string | undefined; accent?: string | undefined; accentSoft?: string | undefined; warning?: string | undefined; danger?: string | undefined; fontFamily?: string | undefined; radius?: string | undefined; fontSize?: string | undefined; colorMode?: "light" | "dark" | undefined; } | undefined; models?: { label: string; id: string; provider?: string | undefined; reasoning?: "disabled" | "concise" | "deep" | undefined; contexts?: string[] | undefined; }[] | undefined; features?: { reasoning?: boolean | undefined; artifactsPanel?: boolean | undefined; modelSwitching?: boolean | undefined; toolConfiguration?: boolean | undefined; fileAttachments?: boolean | undefined; selectionAttachments?: boolean | undefined; multiAgentControl?: boolean | undefined; sandboxControls?: boolean | undefined; historySidebar?: boolean | undefined; titleGeneration?: "local" | "llm" | undefined; pageContextAttachments?: boolean | undefined; } | undefined; pageContext?: { name?: string | undefined; includeUserAgent?: boolean | undefined; includeReferrer?: boolean | undefined; includeViewport?: boolean | undefined; includeTitle?: boolean | undefined; } | undefined; chatMetadata?: {} | undefined; defaultContextKey?: string | undefined; messagesPageSize?: number | undefined; translations?: { newChat?: string | undefined; followUp?: string | undefined; sendMessage?: string | undefined; stopStreaming?: string | undefined; typeMessageToSend?: string | undefined; attachFiles?: string | undefined; attachSelectionToContext?: string | undefined; attachments?: string | undefined; chats?: string | undefined; multiUserChats?: string | undefined; noMultiUserChats?: string | undefined; noChatsYet?: string | undefined; untitledChat?: string | undefined; deleteChat?: string | undefined; showChatHistory?: string | undefined; hideChatHistory?: string | undefined; fetchingChats?: string | undefined; fetchingChatError?: string | undefined; helloThere?: string | undefined; howCanIHelpYou?: string | undefined; } | undefined; }, { appId: string; contextKeys: { key: string; label: string; description?: string | undefined; tools?: string[] | undefined; defaultModel?: string | undefined; autoConfirmTools?: string[] | undefined; }[]; transport: { mode: "proxy"; baseUrl: string; apiKey?: string | undefined; socketPath?: string | undefined; socketNamespace?: string | undefined; timeoutMs?: number | undefined; headers?: Record | undefined; } | { mode: "direct"; provider: "custom" | "openrouter" | "openai"; apiKey?: string | undefined; timeoutMs?: number | undefined; headers?: Record | undefined; endpoint?: string | undefined; model?: string | undefined; titleGenerationModel?: string | undefined; }; tools?: { label: string; name: string; description?: string | undefined; icon?: string | undefined; schema?: Record | undefined; confirmation?: "auto" | "manual" | undefined; category?: string | undefined; }[] | undefined; workspaceId?: string | undefined; debug?: boolean | undefined; user?: { id: string; displayName?: string | undefined; email?: string | undefined; avatarUrl?: string | undefined; } | undefined; theme?: { background?: string | undefined; surface?: string | undefined; text?: string | undefined; subtext?: string | undefined; border?: string | undefined; accent?: string | undefined; accentSoft?: string | undefined; warning?: string | undefined; danger?: string | undefined; fontFamily?: string | undefined; radius?: string | undefined; fontSize?: string | undefined; colorMode?: "light" | "dark" | undefined; } | undefined; models?: { label: string; id: string; provider?: string | undefined; reasoning?: "disabled" | "concise" | "deep" | undefined; contexts?: string[] | undefined; }[] | undefined; features?: { reasoning?: boolean | undefined; artifactsPanel?: boolean | undefined; modelSwitching?: boolean | undefined; toolConfiguration?: boolean | undefined; fileAttachments?: boolean | undefined; selectionAttachments?: boolean | undefined; multiAgentControl?: boolean | undefined; sandboxControls?: boolean | undefined; historySidebar?: boolean | undefined; titleGeneration?: "local" | "llm" | undefined; pageContextAttachments?: boolean | undefined; } | undefined; pageContext?: { name?: string | undefined; includeUserAgent?: boolean | undefined; includeReferrer?: boolean | undefined; includeViewport?: boolean | undefined; includeTitle?: boolean | undefined; } | undefined; chatMetadata?: {} | undefined; defaultContextKey?: string | undefined; messagesPageSize?: number | undefined; translations?: { newChat?: string | undefined; followUp?: string | undefined; sendMessage?: string | undefined; stopStreaming?: string | undefined; typeMessageToSend?: string | undefined; attachFiles?: string | undefined; attachSelectionToContext?: string | undefined; attachments?: string | undefined; chats?: string | undefined; multiUserChats?: string | undefined; noMultiUserChats?: string | undefined; noChatsYet?: string | undefined; untitledChat?: string | undefined; deleteChat?: string | undefined; showChatHistory?: string | undefined; hideChatHistory?: string | undefined; fetchingChats?: string | undefined; fetchingChatError?: string | undefined; helloThere?: string | undefined; howCanIHelpYou?: string | undefined; } | undefined; }>; export type ValidatedAgentFrontendConfig = z.infer & Pick & { translations: Translations; }; //# sourceMappingURL=types.d.ts.map