import type { StandardSchemaV1 } from '@standard-schema/spec';
import { type CSSProperties, type ReactNode } from 'react';
import { type UiAction } from '../../../genui/actions.js';
import { type SandboxPolicy, type SandboxProps } from '../../../genui/sandbox.js';
import type { JsonSchema } from '../../../genui/schema.js';
import { type SandboxConfigSource } from './sandbox-assets.js';
import type { GenuiRenderer } from './types.js';
/** What a drawn component calls to hand an action back to the agent (the next user turn). */
export type GenuiActionHandler = (action: UiAction) => void;
/**
 * Where UI actions go — a sandbox's `agent.send(…)`, an app component's button. Typically the chat's
 * `sendUiAction`, which sends the action as the next user message:
 *
 * ```tsx
 * const chat = useAgentChat()
 * <GenuiActionProvider onAction={chat.sendUiAction}>…</GenuiActionProvider>
 * ```
 */
export declare function GenuiActionProvider({ onAction, children, }: {
    onAction: GenuiActionHandler;
    children?: ReactNode;
}): import("react").JSX.Element;
/** The enclosing {@link GenuiActionProvider}'s handler, or `null` outside one. */
export declare function useGenuiAction(): GenuiActionHandler | null;
/** Why the host refused something a sandbox sent. */
export type SandboxRefusal = {
    reason: 'too-large';
    bytes: number;
    limit: number;
} | {
    reason: 'too-soon';
    waitMs: number;
} | {
    reason: 'too-many';
    limit: number;
} | {
    reason: 'not-json';
} | {
    reason: 'invalid';
    issues: {
        path: (string | number)[];
        message: string;
    }[];
} | {
    reason: 'declined';
} | {
    reason: 'no-handler';
};
export interface SandboxRendererOptions {
    /**
     * The policy the frame runs under. Default: the one the catalog's definition carries
     * (`defineSandbox({ policy })`, read through the enclosing `GenuiProvider`'s catalog), else none
     * — no network, the default limits.
     */
    policy?: SandboxPolicy;
    /** Checks the values of every `agent.send(…)` (a Zod object, any Standard Schema, or a JSON Schema). */
    schema?: StandardSchemaV1 | JsonSchema;
    /** Last word on an action before it is sent — e.g. a confirmation dialog. Falsy → dropped. */
    confirm?: (action: UiAction) => boolean | Promise<boolean>;
    /** Where actions go. Default: the enclosing {@link GenuiActionProvider}. */
    onAction?: GenuiActionHandler;
    /** Something the frame sent was refused (see {@link SandboxRefusal}). */
    onRefused?: (refusal: SandboxRefusal) => void;
    /** An uncaught error in the generated code. */
    onError?: (message: string) => void;
    /**
     * Where the theme and the kit's assets (components, styles, Tailwind) come from: default the agent's `GET /config`
     * (`genui.sandbox`, through the enclosing `AgentProvider`, else same-origin `/agent`); a url, an
     * object, or `false` (theme only).
     */
    config?: SandboxConfigSource;
    /** Pass the host's theme in (CSS custom properties, light/dark). Default: the config's, else on. */
    theme?: boolean;
    /**
     * How a frame gets the app's styles, the Tailwind runtime and the kit. `'shared'` (default): the
     * page fetches each once and posts it to each frame when the frame asks (`load`), which puts it
     * in inline elements of its own — each `srcdoc` is a few KB instead of every asset inlined into it,
     * under the same CSP. `'inline'`: every asset in every frame's `srcdoc`, as before 0.78.
     */
    assets?: 'shared' | 'inline';
    /** What to draw while nothing is drawable yet. Default: a busy box of `initialHeight` with the placeholder lines. */
    placeholder?: (state: {
        height: number;
        messages: string[];
        title?: string;
    }) => ReactNode;
    className?: string;
    style?: CSSProperties;
}
/**
 * A renderer for the sandbox component (`Sandbox`): the model's HTML, CSS and JS in an isolated
 * iframe — `srcdoc`, `sandbox="allow-scripts"` (never `allow-same-origin`, so its origin is opaque
 * and it reaches no cookie, storage or DOM of the page), a strict CSP, sized to its content.
 *
 * While the model writes it (a tree node flagged `incomplete`): a placeholder of `initialHeight`,
 * then a preview of the styled markup (no code runs), then — once the markup is done — the live
 * view, whose `jsFunctions` and `jsExpressions` run as each one closes (only for a node the server
 * trimmed; anything else runs its code once complete).
 *
 * The frame's only way out is `agent.send(values)`. The host accepts it only from this frame's
 * window, with this frame's token, from the opaque origin, within the size, rate and count limits,
 * past `schema` and `confirm` — and hands it on as a {@link UiAction}.
 */
export declare function createSandboxRenderer(options?: SandboxRendererOptions): GenuiRenderer<SandboxProps>;
/** The sandbox renderer with its defaults — register it as `Sandbox` in a genui registry. */
export declare const SandboxView: GenuiRenderer<SandboxProps>;
//# sourceMappingURL=sandbox.d.ts.map