import type { AIUIComponent } from '../AIComponents/GenerativeUI/AIUIComponent'; import type { AIUIComponentDefinition } from '../AIComponents/GenerativeUI/AIUIComponentDefinition'; import type { AIUIClientToolDefinition } from '../AIComponents/GenerativeUI/AIUITools'; /** * What an agent is told to write replies' UI in A2UI with: the basic catalog, or the part of it * `keep` names, with the app's components, and what the app adds. The same as the * `prompt.json` StreamChatA2UI's instructions are written from. */ export type A2UIInstructionsConfig = { /** The id of the catalog with the app's components, as the renderer names it. */ catalogId?: string; /** The app's components, or their portable definitions, such as a `UIComponents.json`. */ components?: (AIUIComponent | AIUIComponentDefinition)[]; /** * Replies with their UI, as the agent should write them. Each block must render with the * catalog, or no instructions are written: a broken example teaches the model broken UI. */ examples?: string[]; /** The info string of a reply's UI block, as the agents router reads it. */ fence?: string; /** The basic catalog's components and functions to describe; all of them when absent. */ keep?: string[]; /** Guidance on using the app's components. */ notes?: string[]; /** What the model is told first, such as which answers to write as UI. */ preamble?: string; /** The basic catalog's components and functions to leave out, as the renderer does. */ remove?: string[]; /** Rules added after the protocol's. */ rules?: string[]; /** The app's tools the UI can call, each run on the person's device. */ tools?: AIUIClientToolDefinition[]; }; /** The A2UI an example holds that would not render, and why. */ export declare class A2UIInstructionsError extends Error { readonly problems: string[]; constructor(problems: string[]); } /** A description of the A2UI v1.0 messages and the rules that keep what they make valid. */ export declare const A2UI_PROTOCOL_OVERVIEW = "# Generating user interfaces with A2UI v1.0\n\nYou render user interfaces by emitting A2UI messages. Every message is a JSON object with a `\"version\": \"1.0\"` field plus exactly one of these keys:\n\n- `createSurface`: creates a surface. Requires `surfaceId`, and accepts `catalogId`, `sendDataModel`, `components` and `dataModel` so a complete UI can be sent in one message.\n- `updateComponents`: adds or replaces components of an existing surface. Requires `surfaceId` and `components`.\n- `updateDataModel`: writes to the surface data model. Requires `surfaceId` and `value`, and accepts a JSON Pointer `path`. Setting `value` to `null` deletes the entry at `path`.\n- `deleteSurface`: removes a surface. Requires `surfaceId`.\n- `callRendererFunction`: asks the renderer to run one of its functions.\n- `agentFunctionResponse`: answers a `callAgentFunction` request from the renderer.\n\nRules:\n\n1. Components are a flat adjacency list. Each component has a unique `id`, a `component` type, and its properties inline. Exactly one component must have the id `root`. An id is an identifier: letters, digits and underscores, not starting with a digit, such as `saturday_plan` (never `saturday-plan`).\n2. Children are referenced by id, never nested inline. Use an array of ids, or `{\"componentId\": \"...\", \"path\": \"/items\"}` to repeat a template for every item of a data model list.\n3. Any property may be a literal, a data binding `{\"@path\": \"/a/b\"}` or a function call `{\"@call\": \"name\", \"args\": {...}}`. Inside a list template, paths without a leading slash resolve relative to the current item, and `{\"@call\": \"@index\"}` returns the item's position. A literal object key that starts with `@` is written with `@@`, so `\"@@type\"` means `\"@type\"`.\n4. Put content that changes in the data model and bind to it, so you can update values with `updateDataModel` instead of resending components.\n5. Interactive components declare an `action`, which either dispatches an event to you (`{\"event\": {\"name\": \"...\", \"context\": {...}}}`) or runs a renderer function (`{\"functionCall\": {\"@call\": \"openUrl\", \"args\": {\"url\": \"...\"}}}`).\n6. Surface ids must be unique for the lifetime of the renderer. Creating a surface that already exists is an error: delete it first, or send `updateComponents` and `updateDataModel` to change it."; export declare const writing: (fence: string, catalogId: string) => string; /** How the app's tools are introduced to the model, as StreamChatA2UI introduces them. */ export declare const TOOLS_INTRODUCTION = "## The app's tools\n\nThese run on the person's device. Call one as you call a function the catalog doesn't define, with `{\"@call\": \"\", \"args\": {\u2026}}`, and its output is the call's value. A read-only tool runs wherever you call it, such as in a binding that shows its output. Any other runs only from a button's `functionCall` action, when the person taps it."; /** * One of the app's tools as the agent's instructions list it: its name, whether it only reads, * what it does, and the schema of its arguments. */ export declare const toolLine: ({ description, inputSchema, name, readOnly, }: AIUIClientToolDefinition) => string; export declare const sorted: (value: unknown) => unknown; export declare const fenceOf: (fence?: string) => string; export declare const blocksIn: (example: string, fence: string) => string[]; /** * The instructions that teach an agent's model to write A2UI with the basic catalog and the * app's components, in Markdown, from the A2UI core's own catalog: the counterpart of * StreamChatA2UI's `A2UIInstructions`, from the same configuration as its `prompt.json`. Give * them to the agent's backend, as the part of its instructions about UI. It runs on a server or * in a build too, and rejects with an `A2UIInstructionsError` when an example would not render. */ export declare const a2uiInstructions: (config?: A2UIInstructionsConfig) => Promise; /** * What is wrong with the A2UI messages of `text`, such as an agent's example, for the catalog * `config` makes, or nothing when they render as written: messages the renderer can't read, * components it doesn't have or that don't fit their schemas, and references that lead nowhere. * The counterpart of StreamChatA2UI's `A2UIProgram.problems`. */ export declare const a2uiProblems: (text: string, config?: Pick) => Promise; //# sourceMappingURL=A2UIInstructions.d.ts.map