import "@standard-schema/spec"; import { ComponentType } from "react"; import { FieldValues, UseFormProps, UseFormReturn } from "react-hook-form"; import { z } from "zod"; type BaseAttachment = { id: string; type: "image" | "document" | "file" | (string & {}); name: string; contentType?: string | undefined; file?: File; content?: ThreadUserMessagePart[]; }; type BaseThreadMessage = { readonly status?: ThreadAssistantMessage["status"]; readonly metadata: { readonly unstable_state?: ReadonlyJSONValue; readonly unstable_annotations?: readonly ReadonlyJSONValue[]; readonly unstable_data?: readonly ReadonlyJSONValue[]; readonly steps?: readonly ThreadStep[]; readonly submittedFeedback?: { readonly type: "negative" | "positive"; }; readonly timing?: MessageTiming; readonly isOptimistic?: boolean; readonly custom: Record; }; readonly attachments?: ThreadUserMessage["attachments"]; }; type CompleteAttachment = BaseAttachment & { status: CompleteAttachmentStatus; content: ThreadUserMessagePart[]; }; type CompleteAttachmentStatus = { type: "complete"; }; type DataMessagePart = { readonly type: "data"; readonly name: string; readonly data: T; }; type FileMessagePart = { readonly type: "file"; readonly filename?: string; readonly data: string; readonly mimeType: string; readonly parentId?: string; }; type GenerativeUIMessagePart = { readonly type: "generative-ui"; readonly spec: GenerativeUISpec; readonly id?: string; readonly parentId?: string; }; type GenerativeUINode = string | { readonly component: string; readonly props?: Record; readonly children?: readonly GenerativeUINode[]; readonly key?: string; }; type GenerativeUISpec = { readonly root: GenerativeUINode | readonly GenerativeUINode[]; }; type ImageMessagePart = { readonly type: "image"; readonly image: string; readonly filename?: string; }; type McpAppMetadata = { readonly resourceUri: string; readonly mimeType?: string; readonly visibility?: readonly ("app" | "model")[]; }; type MessageCommonProps = { readonly id: string; readonly createdAt: Date; }; type MessagePartState = (ThreadUserMessagePart | ThreadAssistantMessagePart) & { readonly status: MessagePartStatus | ToolCallMessagePartStatus; }; type MessagePartStatus = { readonly type: "running"; } | { readonly type: "complete"; } | { readonly type: "incomplete"; readonly reason: "cancelled" | "content-filter" | "error" | "length" | "other"; readonly error?: unknown; }; type MessageStatus = { readonly type: "running"; } | { readonly type: "requires-action"; readonly reason: "interrupt" | "tool-calls"; } | { readonly type: "complete"; readonly reason: "stop" | "unknown"; } | { readonly type: "incomplete"; readonly reason: "cancelled" | "content-filter" | "error" | "length" | "other" | "tool-calls"; readonly error?: ReadonlyJSONValue; }; type MessageTiming = { readonly streamStartTime: number; readonly firstTokenTime?: number; readonly totalStreamTime?: number; readonly tokenCount?: number; readonly tokensPerSecond?: number; readonly totalChunks: number; readonly toolCallCount: number; }; type PartProviderMetadata = { readonly [providerName: string]: ReadonlyJSONObject; }; type ReadonlyJSONArray = readonly ReadonlyJSONValue[]; type ReadonlyJSONObject = { readonly [key: string]: ReadonlyJSONValue; }; type ReadonlyJSONValue = null | string | number | boolean | ReadonlyJSONObject | ReadonlyJSONArray; type ReasoningMessagePart = { readonly type: "reasoning"; readonly text: string; readonly providerMetadata?: PartProviderMetadata; readonly parentId?: string; }; type SourceMessagePart = { readonly type: "source"; readonly sourceType: "url"; readonly id: string; readonly url: string; readonly title?: string; readonly providerMetadata?: SourceProviderMetadata; readonly parentId?: string; } | { readonly type: "source"; readonly sourceType: "document"; readonly id: string; readonly url?: undefined; readonly title: string; readonly mediaType: string; readonly filename?: string; readonly providerMetadata?: SourceProviderMetadata; readonly parentId?: string; }; type SourceProviderMetadata = PartProviderMetadata; interface SpeechRecognitionConstructor { new (): SpeechRecognitionInstance; } interface SpeechRecognitionInstance extends EventTarget { lang: string; continuous: boolean; interimResults: boolean; start(): void; stop(): void; abort(): void; } declare const TOOL_RESPONSE_SYMBOL: unique symbol; type TextMessagePart = { readonly type: "text"; readonly text: string; readonly providerMetadata?: PartProviderMetadata; readonly parentId?: string; }; type ThreadAssistantMessage = MessageCommonProps & { readonly role: "assistant"; readonly content: readonly ThreadAssistantMessagePart[]; readonly status: MessageStatus; readonly metadata: { readonly unstable_state: ReadonlyJSONValue; readonly unstable_annotations: readonly ReadonlyJSONValue[]; readonly unstable_data: readonly ReadonlyJSONValue[]; readonly steps: readonly ThreadStep[]; readonly submittedFeedback?: { readonly type: "negative" | "positive"; }; readonly timing?: MessageTiming; readonly isOptimistic?: boolean; readonly custom: Record; }; }; type ThreadAssistantMessagePart = TextMessagePart | ReasoningMessagePart | ToolCallMessagePart | SourceMessagePart | FileMessagePart | ImageMessagePart | DataMessagePart | GenerativeUIMessagePart; type ThreadMessage = BaseThreadMessage & (ThreadSystemMessage | ThreadUserMessage | ThreadAssistantMessage); type ThreadStep = { readonly messageId?: string; readonly usage?: { readonly inputTokens: number; readonly outputTokens: number; } | undefined; }; type ThreadSystemMessage = MessageCommonProps & { readonly role: "system"; readonly content: readonly [ TextMessagePart ]; readonly metadata: { readonly unstable_state?: undefined; readonly unstable_annotations?: undefined; readonly unstable_data?: undefined; readonly steps?: undefined; readonly submittedFeedback?: undefined; readonly timing?: undefined; readonly custom: Record; }; }; type ThreadUserMessage = MessageCommonProps & { readonly role: "user"; readonly content: readonly ThreadUserMessagePart[]; readonly attachments: readonly CompleteAttachment[]; readonly metadata: { readonly unstable_state?: undefined; readonly unstable_annotations?: undefined; readonly unstable_data?: undefined; readonly steps?: undefined; readonly submittedFeedback?: undefined; readonly timing?: undefined; readonly custom: Record; }; }; type ThreadUserMessagePart = TextMessagePart | ImageMessagePart | FileMessagePart | DataMessagePart | Unstable_AudioMessagePart; type ToolApprovalOption = { readonly id: string; readonly kind: ToolApprovalOptionKind | (string & {}); readonly label?: string; readonly description?: string; readonly grants?: readonly string[]; readonly confirm?: boolean | { title?: string; description?: string; }; }; type ToolApprovalOptionKind = "allow-always" | "allow-once" | "reject-always" | "reject-once"; type ToolApprovalResponse = { readonly approved: boolean; readonly reason?: string; } | { readonly optionId: string; readonly reason?: string; } | { readonly approved: boolean; readonly optionId: string; readonly reason?: string; }; type ToolCallMessagePart = { readonly type: "tool-call"; readonly toolCallId: string; readonly toolName: string; readonly args: TArgs; readonly result?: TResult | undefined; readonly isError?: boolean | undefined; readonly argsText: string; readonly artifact?: unknown; readonly timing?: ToolCallTiming; readonly mcp?: ToolCallMessagePartMcpMetadata; readonly providerMetadata?: PartProviderMetadata; readonly modelContent?: readonly ToolModelContentPart[] | undefined; readonly interrupt?: { type: "human"; payload: unknown; }; readonly approval?: { readonly id: string; readonly approved?: boolean; readonly reason?: string; readonly isAutomatic?: boolean; readonly options?: readonly ToolApprovalOption[]; readonly optionId?: string; readonly resolution?: "cancelled" | "expired"; }; readonly parentId?: string; readonly messages?: readonly ThreadMessage[]; }; type ToolCallMessagePartComponent = ComponentType>; type ToolCallMessagePartMcpMetadata = { readonly app?: McpAppMetadata; }; type ToolCallMessagePartProps = MessagePartState & ToolCallMessagePart & { addResult: (result: TResult | ToolResponse) => void; resume: (payload: unknown) => void; respondToApproval: (response: ToolApprovalResponse) => void; }; type ToolCallMessagePartStatus = { readonly type: "requires-action"; readonly reason: "interrupt"; } | MessagePartStatus; type ToolCallTiming = { readonly startedAt: number; readonly completedAt?: number; }; type ToolModelContentPart = { readonly type: "text"; readonly text: string; } | { readonly type: "file"; readonly data: string; readonly mediaType: string; readonly filename?: string; }; declare class ToolResponse { get [TOOL_RESPONSE_SYMBOL](): boolean; readonly artifact?: ReadonlyJSONValue; readonly result: TResult; readonly isError: boolean; readonly modelContent?: readonly ToolModelContentPart[]; readonly messages?: ReadonlyJSONValue; constructor(options: ToolResponseLike); static [Symbol.hasInstance](obj: unknown): obj is ToolResponse; static toResponse(result: any | ToolResponse): ToolResponse; } type ToolResponseLike = { result: TResult; artifact?: ReadonlyJSONValue | undefined; isError?: boolean | undefined; modelContent?: readonly ToolModelContentPart[] | undefined; messages?: ReadonlyJSONValue | undefined; }; type Unstable_AudioMessagePart = { readonly type: "audio"; readonly audio: { readonly data: string; readonly format: "mp3" | "wav"; }; }; type UseAssistantFormProps = UseFormProps & { assistant?: { tools?: { set_form_field?: { render?: ToolCallMessagePartComponent, unknown> | undefined; } | undefined; submit_form?: { render?: ToolCallMessagePartComponent, unknown> | undefined; } | undefined; reset_form?: { render?: ToolCallMessagePartComponent, unknown> | undefined; } | undefined; } | undefined; } | undefined; }; declare const formTools: { set_form_field: { description: string; parameters: z.ZodObject<{ name: z.ZodString; value: z.ZodString; }, z.core.$strip>; }; submit_form: { description: string; parameters: z.ZodObject<{}, z.core.$strip>; }; reset_form: { description: string; parameters: z.ZodObject<{}, z.core.$strip>; }; }; declare global { interface Window { SpeechRecognition?: SpeechRecognitionConstructor; webkitSpeechRecognition?: SpeechRecognitionConstructor; } } declare namespace entry_root_exports { export { UseAssistantFormProps, formTools, useAssistantForm }; } declare const useAssistantForm: (props?: UseAssistantFormProps) => UseFormReturn; export { entry_root_exports as entry_root };