import { Promisable } from "./types-keN8L-ZK.js"; import { InferToolInput, InferToolOutput, Tool, ToolSet, UIMessage } from "ai"; //#region src/agent/ui.d.ts type UIOptionIcon = `lucide:${string}` | `simple-icons:${string}`; type UIOptionSelectValue = { readonly id: ID; readonly label: string; /** * description will provide additional context to the user in the UI. */ readonly description?: string | Array<{ readonly text: string; readonly color?: "primary" | "muted" | "warning"; }>; /** * icon is a slug of a Lucide or SimpleIcons icon. * This will only be rendered in a web-based UI. * * Find icons: * - https://simpleicons.org/ * - https://lucide.dev/icons/ */ readonly icon?: UIOptionIcon; }; type UIOptionSelect = { readonly type: "select"; /** * label indicates the purpose of the option. * If omitted, it will not be displayed in the UI. */ readonly label?: string; /** * icon is a slug of a Lucide or SimpleIcons icon. * This will only be rendered in a web-based UI. * * Find icons: * - https://simpleicons.org/ * - https://lucide.dev/icons/ */ readonly icon?: UIOptionIcon; /** * defaultValue is the default value for the option. * If omitted, the option will not be selected by default. */ readonly defaultValue: Values[number]["id"]; readonly values: Values; }; type UIOptions = Record; type WithUIOptions = MESSAGE & { readonly role: "user"; readonly metadata: MESSAGE["metadata"] & { readonly options?: OPTIONS; }; }; type ExtractUIOptions = M extends WithUIOptions ? O : UIOptions; type UIOptionsSchema = { [K in keyof OPTIONS]: UIOptionSelect>> }; interface UIEvent { readonly selectedOptions?: ExtractUIOptions; } type UIHandler = (event: UIEvent) => Promisable> | void>; /** * lastUIOptions finds the last user message with options. * Options are stored in message metadata to preserve the history * of changing options. * * @param messages - The messages to search. * @returns The last user message with options, or undefined if no such message exists. */ declare function lastUIOptions(messages: MESSAGE[]): ExtractUIOptions | undefined; //#endregion //#region src/agent/tools.d.ts /** * ToolWithContext is a tool that supports the "withContext" method. * * @param CONTEXT The context type. * @param TOOL The tool type. * @returns The tool with the given context. */ type ToolWithContext = TOOL & { withContext(context: CONTEXT): TOOL; }; /** * ToolWithApproval is a tool that supports the "autoApprove" method. * * @param TOOL The tool type. * @returns The tool with the given approval. */ type ToolWithApproval = Tool & { /** * autoApprove is a function that can be used to automatically approve * an approval tool call based on the input. * * @param input The input to the tool. * @returns Whether the tool call should be approved. */ autoApprove?: (input: INPUT) => Promise | boolean; }; type ToolSetWithApproval = { [K in keyof TOOLS]: ToolWithApproval, InferToolOutput> }; /** * toolWithApproval is a helper for inferring the execute and autoApprove * arguments of a tool. * * @param tool The tool to wrap. * @returns The wrapped tool. */ declare function toolWithApproval(tool: ToolWithApproval): ToolWithApproval; type ToolSetWithPrefix = { [K in keyof TOOLS as `${PREFIX}${K & string}`]: K extends string ? TOOLS[K] : never }; /** * Tools are helpers for managing tools. */ declare const tools: Readonly<{ /** * withContext adds context to a set of tools that supports the "withContext" method. * * @param context * @param tools * @returns */ withContext(tools: TOOLS, context: ContextFromTools): { [K in keyof TOOLS]: Tool }; /** * @internal * @deprecated Use withContext instead - it's the same thing. */ with(tools: TOOLS, context: ContextFromTools): { [K in keyof TOOLS]: Tool }; /** * withApproval ensures a set of tools need explicit user approval * before they are executed. * * This works by replacing the execution of all provided tools with * special output that interfaces must handle. * * On approval, the tool will be executed with the verbatim input. * * @returns Tools that should be sent in `streamText`. */ withApproval, MESSAGE extends UIMessage>(options: { messages: MESSAGE[]; tools: TOOLS; abortSignal?: AbortSignal; }): Promise; /** * prefix adds a prefix to all the tools in a tool set. * * @param tools The tool set to prefix. * @param prefix The prefix to add to the tools. * @returns The prefixed tool set. */ prefix(tools: TOOLS, prefix: PREFIX): ToolSetWithPrefix; }>; type ToolsWithContext = Record; type ContextFromTools = TOOLS[keyof TOOLS] extends { withContext(context: infer C): any; } ? C : never; /** * ToolApprovalOutput is the output of a tool that requires approval. * * This should be consumed by the UI to display an approval prompt. */ interface ToolApprovalOutput { type: "tool-approval"; outcome: "pending" | "approved" | "rejected"; reason?: string; } /** * isToolApprovalOutput checks if an output is a tool approval output. */ declare function isToolApprovalOutput(output: unknown): output is ToolApprovalOutput; //#endregion //#region src/agent/index.browser.d.ts type StreamResponseFormat = "ui-message" | "openai-chat" | "openai-response" | "anthropic" | "google" | "xai"; /** * StreamResponseFormatHeader indicates to a client the stream response * format that the agent is using. */ declare const StreamResponseFormatHeader = "x-blink-stream-response-format"; declare function withResponseFormat(response: Response, format: StreamResponseFormat): Response; //#endregion export { ContextFromTools, ExtractUIOptions, StreamResponseFormat, StreamResponseFormatHeader, ToolApprovalOutput, ToolSetWithApproval, ToolWithApproval, ToolWithContext, UIEvent, UIHandler, UIOptionSelect, UIOptionSelectValue, UIOptions, UIOptionsSchema, WithUIOptions, isToolApprovalOutput, lastUIOptions, toolWithApproval, tools, withResponseFormat };