export { BEARER_PROTOCOL_PREFIX, BFF_CHAT_WS_PATH, BffSession, BffSessionOptions, CHAT_CONTRACT_VERSION, CHAT_LIMITS, CHAT_SUBPROTOCOL, CLOSE_CODE, ChannelAuthor, ChannelFrame, ChannelParticipant, ChannelReadiness, ChatActivity, ChatAuthor, ChatClient, ChatClientOptions, ChatConnection, ChatCredential, ChatCredentialProvider, ChatError, ChatErrorCode, ChatEvent, ChatFormSubmission, ChatHistoryPage, ChatHumanAction, ChatHumanActionOperation, ChatHumanActionRead, ChatHumanActionResource, ChatHumanActionScope, ChatHumanActionStatus, ChatInterrupt, ChatMessage, ChatPart, ChatParticipant, ChatProgress, ChatSendableType, ChatSnapshot, ChatStatus, ChatTarget, ChatThreadState, ChatUnknownSend, Conversation, ConversationError, ConversationErrorKind, ConversationPage, ConversationsApi, ConversationsApiOptions, CreateConversationInput, FRAME_TYPE, KEY_PROTOCOL_PREFIX, ListConversationsInput, MASCOT_ERROR_MS, MASCOT_SLEEP_MS, MASCOT_SUCCESS_MS, MascotSnapshot, MascotState, MascotUi, ONE_CHAT_PATH, ONE_CHAT_READINESS_PATH, PageContext, ReadinessProbe, SendFrameOptions, SendHandle, SendOutcome, SendResult, SessionCommand, SocketFactory, SocketLike, addLocalSend, applyFrame, chatUrl, classifyReadiness, closeStream, contentText, createBffSession, createChatClient, createConversationsApi, decodeFrame, defaultProbe, deriveChatStatus, dropLocalSend, emptyThread, kindForStatus, markFormSubmitted, markFrameGap, markInterruptRequested, markInterruptSettled, markSendDismissed, markSendResent, markSendSettled, mascotFailure, mascotStateOf, messageText, newClientMessageId, oneReadinessProbe, readinessProbeFor } from './chat/index.js';

type AppActionBinding = {
    event_id: string;
    payload_template?: Record<string, unknown>;
};
type AppEffect = {
    type: 'navigate' | 'open_form' | 'toast' | string;
    payload?: Record<string, unknown>;
};
type AppEventRequest = {
    request_id?: string;
    payload?: Record<string, unknown>;
    form_data?: Record<string, unknown>;
    ui_context?: Record<string, unknown>;
    expected_state_version: number;
};
type ViewerApiError = {
    status?: number;
    error?: {
        code?: string;
        message?: string;
        details?: Record<string, unknown>;
    };
};

type AppFieldOption = {
    value: string;
    label: string;
};
type AppFieldDefinition = {
    name: string;
    type: 'text' | 'email' | 'textarea' | 'select' | 'combobox' | 'file' | 'file_upload' | 'date' | 'checkbox' | 'number' | 'boolean' | 'url' | string;
    required?: boolean;
    /** Label shown to the user (Workflow V2 forms.fields[].title); defaults to name. */
    title?: string;
    description?: string;
    default?: unknown;
    options?: AppFieldOption[];
    accept?: string;
    max_size_mb?: number;
    auto_fill?: string;
    hidden_if_auto_filled?: boolean;
};
type AppFormDefinition = {
    id: string;
    title: string;
    fields: AppFieldDefinition[];
    next?: string;
    actions_on_submit?: string[];
};

declare const APP_RUNTIME_CONTRACT: "agentmaurice-miniapp-runtime-v2";
declare const APP_INSTANCE_STATUSES: readonly ["created", "active", "completed", "archived", "errored"];
declare const APP_UI_NODE_TYPES: readonly ["separator", "accordion", "metric", "steps", "text", "button", "stat", "kpi_grid", "list", "tabs", "filter_bar", "callout", "action_bar", "badge_row", "empty_state", "chart", "table", "section", "card", "form_link"];
declare const APP_UI_LAYOUTS: readonly ["column", "row"];
declare const APP_UI_CALLOUT_TONES: readonly ["info", "success", "warning", "error", "neutral"];
type GeneratedAppRuntimeContract = typeof APP_RUNTIME_CONTRACT;
type GeneratedAppInstanceStatus = (typeof APP_INSTANCE_STATUSES)[number];
type GeneratedAppUINodeType = (typeof APP_UI_NODE_TYPES)[number];
type GeneratedAppUILayout = (typeof APP_UI_LAYOUTS)[number];
type GeneratedAppUICalloutTone = (typeof APP_UI_CALLOUT_TONES)[number];
type GeneratedTextNode = {
    type: 'text';
    value: string;
    [key: string]: unknown;
};
type GeneratedButtonNode = {
    type: 'button';
    label: string;
    on_click: string;
    [key: string]: unknown;
};
type GeneratedStatNode = {
    type: 'stat';
    label: string;
    value: string | number;
    [key: string]: unknown;
};
type GeneratedKPIGridNode = {
    type: 'kpi_grid';
    items: Array<{
        label: string;
        value: string | number;
        tone?: GeneratedAppUICalloutTone;
        [key: string]: unknown;
    }>;
    [key: string]: unknown;
};
type GeneratedListNode = {
    type: 'list';
    source: unknown[];
    item_template: GeneratedAppNode;
    on_item_click?: string;
    [key: string]: unknown;
};
type GeneratedTabsNode = {
    type: 'tabs';
    items: string[];
    active?: string;
    on_tab_click: string;
    [key: string]: unknown;
};
type GeneratedFilterBarNode = {
    type: 'filter_bar';
    filters: Array<{
        label: string;
        value: string;
        on_click: string;
        active?: boolean;
        [key: string]: unknown;
    }>;
    [key: string]: unknown;
};
type GeneratedActionBarNode = {
    type: 'action_bar';
    actions: Array<{
        label: string;
        variant?: 'primary' | 'secondary';
        on_click?: string;
        form_id?: string;
        submit_event?: string;
        [key: string]: unknown;
    }>;
    [key: string]: unknown;
};
type GeneratedBadgeRowNode = {
    type: 'badge_row';
    items: Array<{
        label: string;
        value: string;
        tone?: GeneratedAppUICalloutTone;
        [key: string]: unknown;
    }>;
    [key: string]: unknown;
};
type GeneratedCalloutNode = {
    type: 'callout';
    title?: string;
    value: string;
    tone?: GeneratedAppUICalloutTone;
    [key: string]: unknown;
};
type GeneratedEmptyStateNode = {
    type: 'empty_state';
    title: string;
    description: string;
    action_label?: string;
    on_click?: string;
    [key: string]: unknown;
};
type GeneratedChartNode = {
    type: 'chart';
    chart_type: 'bar' | 'line' | 'area' | 'pie' | 'horizontal_bar';
    title?: string;
    data: unknown[] | string;
    x_key: string;
    y_key: string;
    [key: string]: unknown;
};
type GeneratedTableNode = {
    type: 'table';
    columns: string[];
    rows: unknown[] | string;
    column_labels?: Record<string, string>;
    on_row_click?: string;
    [key: string]: unknown;
};
type GeneratedSectionNode = {
    type: 'section';
    title?: string;
    subtitle?: string;
    layout?: GeneratedAppUILayout;
    children: GeneratedAppNode[];
    [key: string]: unknown;
};
type GeneratedCardNode = {
    type: 'card';
    title?: string;
    subtitle?: string;
    layout?: GeneratedAppUILayout;
    children: GeneratedAppNode[];
    [key: string]: unknown;
};
type GeneratedFormLinkNode = {
    type: 'form_link';
    label: string;
    form_id: string;
    submit_event?: string;
    [key: string]: unknown;
};
type GeneratedSeparatorNode = {
    type: 'separator';
    [key: string]: unknown;
};
type GeneratedAccordionNode = {
    type: 'accordion';
    items: Array<{
        title: string;
        children: GeneratedAppNode[];
        [key: string]: unknown;
    }>;
    [key: string]: unknown;
};
type GeneratedMetricNode = {
    type: 'metric';
    label: string;
    value: string | number;
    delta?: string | number;
    trend?: 'up' | 'down' | 'neutral';
    caption?: string;
    [key: string]: unknown;
};
type GeneratedStepsNode = {
    type: 'steps';
    items: Array<{
        title: string;
        description?: string;
        status?: 'done' | 'current' | 'todo';
        [key: string]: unknown;
    }>;
    [key: string]: unknown;
};
type GeneratedGroupNode = {
    children: GeneratedAppNode[];
    layout?: GeneratedAppUILayout;
    [key: string]: unknown;
};
type GeneratedAppNode = GeneratedTextNode | GeneratedButtonNode | GeneratedStatNode | GeneratedKPIGridNode | GeneratedListNode | GeneratedTabsNode | GeneratedFilterBarNode | GeneratedActionBarNode | GeneratedBadgeRowNode | GeneratedCalloutNode | GeneratedEmptyStateNode | GeneratedChartNode | GeneratedTableNode | GeneratedSectionNode | GeneratedCardNode | GeneratedFormLinkNode | GeneratedSeparatorNode | GeneratedAccordionNode | GeneratedMetricNode | GeneratedStepsNode | GeneratedGroupNode;
type GeneratedAppUISchema = {
    initial_view?: string;
    views: Record<string, GeneratedAppNode>;
    [key: string]: unknown;
};
type GeneratedAppUIRender = {
    view: string;
    tree?: GeneratedAppNode;
    format?: string;
    library?: string;
    program?: string;
    initial_state?: Record<string, unknown>;
    fallback_tree?: GeneratedAppNode;
    [key: string]: unknown;
};
type GeneratedMiniAppRuntimePayload = {
    contract: GeneratedAppRuntimeContract;
    app_instance_id: string;
    agent_id: string;
    workspace_id?: string;
    miniapp_id: string;
    miniapp_version?: string;
    management_mode: 'managed' | 'unmanaged';
    owner_agent_spec_id: string;
    owner_revision: number;
    content_hash: string;
    resource_version: number;
    status: GeneratedAppInstanceStatus;
    state: Record<string, unknown>;
    state_version: number;
    ui?: GeneratedAppUIRender | null;
    action_bindings?: Record<string, AppActionBinding>;
    forms?: Record<string, AppFormDefinition>;
    effects?: AppEffect[];
};
declare const APP_RUNTIME_SCHEMA: {
    readonly $schema: "https://json-schema.org/draft/2020-12/schema";
    readonly title: "AgentMauriceMiniAppRuntimeV2";
    readonly type: "object";
    readonly required: readonly ["contract", "app_instance_id", "agent_id", "miniapp_id", "management_mode", "owner_agent_spec_id", "owner_revision", "content_hash", "resource_version", "status", "state", "state_version"];
    readonly properties: {
        readonly contract: {
            readonly const: "agentmaurice-miniapp-runtime-v2";
        };
        readonly app_instance_id: {
            readonly type: "string";
        };
        readonly application_id: {
            readonly type: "string";
        };
        readonly conversation_id: {
            readonly type: "string";
        };
        readonly agent_id: {
            readonly type: "string";
            readonly minLength: 1;
        };
        readonly workspace_id: {
            readonly type: "string";
        };
        readonly miniapp_id: {
            readonly type: "string";
        };
        readonly miniapp_version: {
            readonly type: "string";
        };
        readonly management_mode: {
            readonly type: "string";
            readonly enum: readonly ["managed", "unmanaged"];
        };
        readonly owner_agent_spec_id: {
            readonly type: "string";
        };
        readonly owner_revision: {
            readonly type: "integer";
            readonly minimum: 0;
        };
        readonly content_hash: {
            readonly type: "string";
        };
        readonly resource_version: {
            readonly type: "integer";
            readonly minimum: 1;
        };
        readonly status: {
            readonly type: "string";
            readonly enum: readonly ["created", "active", "completed", "archived", "errored"];
        };
        readonly state: {
            readonly type: "object";
        };
        readonly state_version: {
            readonly type: "integer";
            readonly minimum: 1;
        };
        readonly ui: {
            readonly type: "object";
            readonly properties: {
                readonly view: {
                    readonly type: "string";
                };
                readonly tree: {
                    readonly type: "object";
                };
                readonly format: {
                    readonly type: "string";
                };
                readonly library: {
                    readonly type: "string";
                };
                readonly program: {
                    readonly type: "string";
                };
                readonly initial_state: {
                    readonly type: "object";
                };
                readonly fallback_tree: {
                    readonly type: "object";
                };
            };
            readonly required: readonly ["view"];
            readonly additionalProperties: true;
        };
        readonly action_bindings: {
            readonly type: "object";
            readonly additionalProperties: {
                readonly type: "object";
                readonly required: readonly ["event_id"];
                readonly properties: {
                    readonly event_id: {
                        readonly type: "string";
                    };
                    readonly payload_template: {
                        readonly type: "object";
                    };
                };
                readonly additionalProperties: true;
            };
        };
        readonly forms: {
            readonly type: "object";
            readonly additionalProperties: {
                readonly type: "object";
                readonly required: readonly ["id", "title", "fields"];
                readonly properties: {
                    readonly id: {
                        readonly type: "string";
                    };
                    readonly title: {
                        readonly type: "string";
                    };
                    readonly fields: {
                        readonly type: "array";
                    };
                };
                readonly additionalProperties: true;
            };
        };
        readonly effects: {
            readonly type: "array";
            readonly items: {
                readonly type: "object";
                readonly required: readonly ["type"];
                readonly properties: {
                    readonly type: {
                        readonly type: "string";
                    };
                    readonly payload: {
                        readonly type: "object";
                    };
                };
                readonly additionalProperties: true;
            };
        };
    };
    readonly unevaluatedProperties: false;
};
declare const APP_UI_SCHEMA: {
    readonly $schema: "https://json-schema.org/draft/2020-12/schema";
    readonly title: "MiniAppUISchema";
    readonly type: "object";
    readonly required: readonly ["views"];
    readonly properties: {
        readonly initial_view: {
            readonly type: "string";
        };
        readonly views: {
            readonly type: "object";
        };
    };
    readonly additionalProperties: true;
    readonly $defs: {
        readonly node: {
            readonly type: "object";
            readonly oneOf: readonly [{
                readonly $ref: "#/$defs/textNode";
            }, {
                readonly $ref: "#/$defs/buttonNode";
            }, {
                readonly $ref: "#/$defs/statNode";
            }, {
                readonly $ref: "#/$defs/kpiGridNode";
            }, {
                readonly $ref: "#/$defs/listNode";
            }, {
                readonly $ref: "#/$defs/tabsNode";
            }, {
                readonly $ref: "#/$defs/filterBarNode";
            }, {
                readonly $ref: "#/$defs/actionBarNode";
            }, {
                readonly $ref: "#/$defs/badgeRowNode";
            }, {
                readonly $ref: "#/$defs/calloutNode";
            }, {
                readonly $ref: "#/$defs/emptyStateNode";
            }, {
                readonly $ref: "#/$defs/chartNode";
            }, {
                readonly $ref: "#/$defs/tableNode";
            }, {
                readonly $ref: "#/$defs/sectionNode";
            }, {
                readonly $ref: "#/$defs/cardNode";
            }, {
                readonly $ref: "#/$defs/formLinkNode";
            }, {
                readonly $ref: "#/$defs/separatorNode";
            }, {
                readonly $ref: "#/$defs/accordionNode";
            }, {
                readonly $ref: "#/$defs/metricNode";
            }, {
                readonly $ref: "#/$defs/stepsNode";
            }, {
                readonly $ref: "#/$defs/groupNode";
            }];
        };
        readonly separatorNode: {
            readonly type: "object";
            readonly required: readonly ["type"];
            readonly properties: {
                readonly type: {
                    readonly const: "separator";
                };
            };
            readonly additionalProperties: true;
        };
        readonly accordionNode: {
            readonly type: "object";
            readonly required: readonly ["type", "items"];
            readonly properties: {
                readonly type: {
                    readonly const: "accordion";
                };
                readonly items: {
                    readonly type: "array";
                    readonly items: {
                        readonly type: "object";
                        readonly required: readonly ["title", "children"];
                        readonly properties: {
                            readonly title: {
                                readonly type: "string";
                            };
                            readonly children: {
                                readonly type: "array";
                                readonly items: {
                                    readonly $ref: "#/$defs/node";
                                };
                            };
                        };
                        readonly additionalProperties: true;
                    };
                };
            };
            readonly additionalProperties: true;
        };
        readonly metricNode: {
            readonly type: "object";
            readonly required: readonly ["type", "label", "value"];
            readonly properties: {
                readonly type: {
                    readonly const: "metric";
                };
                readonly label: {
                    readonly type: "string";
                };
                readonly value: {
                    readonly oneOf: readonly [{
                        readonly type: "string";
                    }, {
                        readonly type: "number";
                    }];
                };
                readonly delta: {
                    readonly oneOf: readonly [{
                        readonly type: "string";
                    }, {
                        readonly type: "number";
                    }];
                };
                readonly trend: {
                    readonly type: "string";
                    readonly enum: readonly ["up", "down", "neutral"];
                };
                readonly caption: {
                    readonly type: "string";
                };
            };
            readonly additionalProperties: true;
        };
        readonly stepsNode: {
            readonly type: "object";
            readonly required: readonly ["type", "items"];
            readonly properties: {
                readonly type: {
                    readonly const: "steps";
                };
                readonly items: {
                    readonly type: "array";
                    readonly items: {
                        readonly type: "object";
                        readonly required: readonly ["title"];
                        readonly properties: {
                            readonly title: {
                                readonly type: "string";
                            };
                            readonly description: {
                                readonly type: "string";
                            };
                            readonly status: {
                                readonly type: "string";
                                readonly enum: readonly ["done", "current", "todo"];
                            };
                        };
                        readonly additionalProperties: true;
                    };
                };
            };
            readonly additionalProperties: true;
        };
        readonly textNode: {
            readonly type: "object";
            readonly required: readonly ["type", "value"];
            readonly properties: {
                readonly type: {
                    readonly const: "text";
                };
                readonly value: {
                    readonly type: "string";
                };
            };
            readonly additionalProperties: true;
        };
        readonly buttonNode: {
            readonly type: "object";
            readonly required: readonly ["type", "label", "on_click"];
            readonly properties: {
                readonly type: {
                    readonly const: "button";
                };
                readonly label: {
                    readonly type: "string";
                };
                readonly on_click: {
                    readonly type: "string";
                };
            };
            readonly additionalProperties: true;
        };
        readonly statNode: {
            readonly type: "object";
            readonly required: readonly ["type", "label", "value"];
            readonly properties: {
                readonly type: {
                    readonly const: "stat";
                };
                readonly label: {
                    readonly type: "string";
                };
                readonly value: {
                    readonly oneOf: readonly [{
                        readonly type: "string";
                    }, {
                        readonly type: "number";
                    }];
                };
            };
            readonly additionalProperties: true;
        };
        readonly kpiGridNode: {
            readonly type: "object";
            readonly required: readonly ["type", "items"];
            readonly properties: {
                readonly type: {
                    readonly const: "kpi_grid";
                };
                readonly items: {
                    readonly type: "array";
                };
            };
            readonly additionalProperties: true;
        };
        readonly listNode: {
            readonly type: "object";
            readonly required: readonly ["type", "source", "item_template"];
            readonly properties: {
                readonly type: {
                    readonly const: "list";
                };
                readonly source: {
                    readonly type: "array";
                };
                readonly item_template: {
                    readonly $ref: "#/$defs/node";
                };
                readonly on_item_click: {
                    readonly type: "string";
                };
            };
            readonly additionalProperties: true;
        };
        readonly tabsNode: {
            readonly type: "object";
            readonly required: readonly ["type", "items", "on_tab_click"];
            readonly properties: {
                readonly type: {
                    readonly const: "tabs";
                };
                readonly items: {
                    readonly type: "array";
                    readonly items: {
                        readonly type: "string";
                    };
                };
                readonly active: {
                    readonly type: "string";
                };
                readonly on_tab_click: {
                    readonly type: "string";
                };
            };
            readonly additionalProperties: true;
        };
        readonly filterBarNode: {
            readonly type: "object";
            readonly required: readonly ["type", "filters"];
            readonly properties: {
                readonly type: {
                    readonly const: "filter_bar";
                };
                readonly filters: {
                    readonly type: "array";
                    readonly items: {
                        readonly type: "object";
                        readonly required: readonly ["label", "value", "on_click"];
                        readonly properties: {
                            readonly label: {
                                readonly type: "string";
                            };
                            readonly value: {
                                readonly type: "string";
                            };
                            readonly on_click: {
                                readonly type: "string";
                            };
                            readonly active: {
                                readonly type: "boolean";
                            };
                        };
                        readonly additionalProperties: true;
                    };
                };
            };
            readonly additionalProperties: true;
        };
        readonly calloutNode: {
            readonly type: "object";
            readonly required: readonly ["type", "value"];
            readonly properties: {
                readonly type: {
                    readonly const: "callout";
                };
                readonly title: {
                    readonly type: "string";
                };
                readonly value: {
                    readonly type: "string";
                };
                readonly tone: {
                    readonly type: "string";
                    readonly enum: readonly ["info", "success", "warning", "error", "neutral"];
                };
            };
            readonly additionalProperties: true;
        };
        readonly actionBarNode: {
            readonly type: "object";
            readonly required: readonly ["type", "actions"];
            readonly properties: {
                readonly type: {
                    readonly const: "action_bar";
                };
                readonly actions: {
                    readonly type: "array";
                    readonly items: {
                        readonly type: "object";
                        readonly required: readonly ["label"];
                        readonly properties: {
                            readonly label: {
                                readonly type: "string";
                            };
                            readonly variant: {
                                readonly type: "string";
                                readonly enum: readonly ["primary", "secondary"];
                            };
                            readonly on_click: {
                                readonly type: "string";
                            };
                            readonly form_id: {
                                readonly type: "string";
                            };
                            readonly submit_event: {
                                readonly type: "string";
                            };
                        };
                        readonly additionalProperties: true;
                    };
                };
            };
            readonly additionalProperties: true;
        };
        readonly badgeRowNode: {
            readonly type: "object";
            readonly required: readonly ["type", "items"];
            readonly properties: {
                readonly type: {
                    readonly const: "badge_row";
                };
                readonly items: {
                    readonly type: "array";
                    readonly items: {
                        readonly type: "object";
                        readonly required: readonly ["label", "value"];
                        readonly properties: {
                            readonly label: {
                                readonly type: "string";
                            };
                            readonly value: {
                                readonly type: "string";
                            };
                            readonly tone: {
                                readonly type: "string";
                                readonly enum: readonly ["info", "success", "warning", "error", "neutral"];
                            };
                        };
                        readonly additionalProperties: true;
                    };
                };
            };
            readonly additionalProperties: true;
        };
        readonly emptyStateNode: {
            readonly type: "object";
            readonly required: readonly ["type", "title", "description"];
            readonly properties: {
                readonly type: {
                    readonly const: "empty_state";
                };
                readonly title: {
                    readonly type: "string";
                };
                readonly description: {
                    readonly type: "string";
                };
                readonly action_label: {
                    readonly type: "string";
                };
                readonly on_click: {
                    readonly type: "string";
                };
            };
            readonly additionalProperties: true;
        };
        readonly chartNode: {
            readonly type: "object";
            readonly required: readonly ["type", "chart_type", "data", "x_key", "y_key"];
            readonly properties: {
                readonly type: {
                    readonly const: "chart";
                };
                readonly chart_type: {
                    readonly type: "string";
                    readonly enum: readonly ["bar", "line", "area", "pie", "horizontal_bar"];
                };
                readonly title: {
                    readonly type: "string";
                };
                readonly data: {
                    readonly oneOf: readonly [{
                        readonly type: "array";
                    }, {
                        readonly type: "string";
                    }];
                };
                readonly x_key: {
                    readonly type: "string";
                };
                readonly y_key: {
                    readonly type: "string";
                };
            };
            readonly additionalProperties: true;
        };
        readonly tableNode: {
            readonly type: "object";
            readonly required: readonly ["type", "columns", "rows"];
            readonly properties: {
                readonly type: {
                    readonly const: "table";
                };
                readonly columns: {
                    readonly type: "array";
                    readonly items: {
                        readonly type: "string";
                    };
                };
                readonly rows: {
                    readonly oneOf: readonly [{
                        readonly type: "array";
                    }, {
                        readonly type: "string";
                    }];
                };
                readonly column_labels: {
                    readonly type: "object";
                    readonly additionalProperties: {
                        readonly type: "string";
                    };
                };
                readonly on_row_click: {
                    readonly type: "string";
                };
            };
            readonly additionalProperties: true;
        };
        readonly sectionNode: {
            readonly type: "object";
            readonly required: readonly ["type", "children"];
            readonly properties: {
                readonly type: {
                    readonly const: "section";
                };
                readonly title: {
                    readonly type: "string";
                };
                readonly subtitle: {
                    readonly type: "string";
                };
                readonly layout: {
                    readonly type: "string";
                    readonly enum: readonly ["column", "row"];
                };
                readonly children: {
                    readonly type: "array";
                    readonly items: {
                        readonly $ref: "#/$defs/node";
                    };
                };
            };
            readonly additionalProperties: true;
        };
        readonly cardNode: {
            readonly type: "object";
            readonly required: readonly ["type", "children"];
            readonly properties: {
                readonly type: {
                    readonly const: "card";
                };
                readonly title: {
                    readonly type: "string";
                };
                readonly subtitle: {
                    readonly type: "string";
                };
                readonly layout: {
                    readonly type: "string";
                    readonly enum: readonly ["column", "row"];
                };
                readonly children: {
                    readonly type: "array";
                    readonly items: {
                        readonly $ref: "#/$defs/node";
                    };
                };
            };
            readonly additionalProperties: true;
        };
        readonly formLinkNode: {
            readonly type: "object";
            readonly required: readonly ["type", "label", "form_id"];
            readonly properties: {
                readonly type: {
                    readonly const: "form_link";
                };
                readonly label: {
                    readonly type: "string";
                };
                readonly form_id: {
                    readonly type: "string";
                };
                readonly submit_event: {
                    readonly type: "string";
                };
            };
            readonly additionalProperties: true;
        };
        readonly groupNode: {
            readonly type: "object";
            readonly required: readonly ["children"];
            readonly properties: {
                readonly children: {
                    readonly type: "array";
                    readonly items: {
                        readonly $ref: "#/$defs/node";
                    };
                };
                readonly layout: {
                    readonly type: "string";
                    readonly enum: readonly ["column", "row"];
                };
            };
            readonly additionalProperties: true;
        };
    };
};

interface AuthUser {
    id: string;
    displayName?: string;
    email?: string;
    avatarUrl?: string;
}
interface AuthResult {
    user: AuthUser;
    token: string;
}
type AuthStateCallback = (user: AuthUser | null) => void;
interface AuthAdapter {
    authenticate(): Promise<AuthResult>;
    getToken(): Promise<string>;
    logout(): Promise<void>;
    onAuthStateChange(callback: AuthStateCallback): () => void;
}

type ViewerPhase = "idle" | "loading" | "ready" | "sending" | "error";
type ViewerState = {
    phase: ViewerPhase;
    runtime: MiniAppRuntimePayload | null;
    error: string | null;
};
type ViewerStateListener = (state: ViewerState) => void;
interface ViewerStateController {
    getState(): ViewerState;
    subscribe(listener: ViewerStateListener): () => void;
    dispatchEvent(eventId: string, payload: Record<string, unknown>, formData?: Record<string, unknown>): Promise<void>;
}

type ViewerAuthMode = "none" | "api_key" | "firebase" | "supabase" | "oidc" | "external" | string;
type ManagementMode = "managed" | "unmanaged";
interface ResourceManagementMetadata {
    management_mode?: ManagementMode;
    owner_agent_spec_id?: string;
    owner_revision?: number;
    content_hash?: string;
    resource_version?: number;
}
interface ViewerBootstrapMiniApp extends ResourceManagementMetadata {
    id: string;
    miniapp_id?: string;
    name: string;
    description?: string;
    version?: string;
}
interface ViewerBootstrapConfigResponse {
    default_miniapp_id?: string;
    auth_mode: ViewerAuthMode;
    auth_provider_config?: Record<string, unknown>;
    enabled: boolean;
    title?: string;
    slug?: string;
}
interface ViewerBootstrapResponse {
    agent_id: string;
    organization_id?: string;
    api_base_url: string;
    config: ViewerBootstrapConfigResponse;
    miniapps?: ViewerBootstrapMiniApp[];
}
interface ViewerBootstrapConfig {
    agentId?: string;
    slug?: string;
    miniAppId?: string;
    applicationKey?: string;
    moduleKey?: string;
    appKey?: string;
    apiKey?: string;
    apiBaseUrl?: string;
    authAdapter?: AuthAdapter;
    seedState?: Record<string, unknown>;
    onReady?: (instance: ViewerInstance) => void;
    onError?: (error: ViewerError) => void;
}
interface ViewerInstance {
    readonly state: ViewerState;
    readonly bootstrapResponse: ViewerBootstrapResponse;
    subscribe(listener: (state: ViewerState) => void): () => void;
    sendEvent(eventId: string, payload?: Record<string, unknown>, formData?: Record<string, unknown>): Promise<void>;
    sendAction(action: AppActionBinding): Promise<void>;
    destroy(): void;
}
declare class ViewerError extends Error {
    readonly code: string;
    readonly details?: Record<string, unknown>;
    constructor(code: string, message: string, details?: Record<string, unknown>);
}

/** Runtime version contract */
declare const MINIAPP_RUNTIME_CONTRACT: "agentmaurice-miniapp-runtime-v2";
/** Possible MiniApp instance statuses */
type AppInstanceStatus = GeneratedAppInstanceStatus | 'waiting_for_form';
type AppUILayout = GeneratedAppUILayout;
type AppUICalloutTone = GeneratedAppUICalloutTone;
type TextNode = GeneratedTextNode;
type ButtonNode = GeneratedButtonNode;
type StatNode = GeneratedStatNode;
type KPIGridNode = GeneratedKPIGridNode;
type ListNode = GeneratedListNode;
type FilterBarNode = GeneratedFilterBarNode;
type ActionBarNode = GeneratedActionBarNode;
type BadgeRowNode = GeneratedBadgeRowNode;
type CalloutNode = GeneratedCalloutNode;
type EmptyStateNode = GeneratedEmptyStateNode;
type ChartNode = GeneratedChartNode & {
    data: Array<Record<string, unknown> | unknown[]>;
};
type TableNode = GeneratedTableNode & {
    rows: Array<Record<string, unknown> | unknown[]>;
};
type SectionNode = GeneratedSectionNode | GeneratedCardNode;
type FormLinkNode = GeneratedFormLinkNode;
type GenericNode = GeneratedGroupNode & {
    type?: string;
};
type AppNode = GeneratedAppNode;
type AppUIRender = GeneratedAppUIRender;
type MiniAppRuntimePayload = {
    application_id?: string;
    conversation_id?: string;
    contract: GeneratedMiniAppRuntimePayload['contract'];
    app_instance_id: string;
    agent_id: string;
    workspace_id?: string;
    miniapp_id: string;
    miniapp_version?: string;
    management_mode: ManagementMode;
    owner_agent_spec_id: string;
    owner_revision: number;
    content_hash: string;
    resource_version: number;
    status: AppInstanceStatus;
    state: Record<string, unknown>;
    state_version: number;
    ui?: AppUIRender | null;
    action_bindings?: Record<string, AppActionBinding>;
    forms?: Record<string, AppFormDefinition>;
    effects?: AppEffect[];
};

type ViewerAPIConfig = {
    baseURL: string;
    applicationSession?: {
        applicationKey: string;
        miniApp?: {
            agentId: string;
            id: string;
        };
    };
    fetch?: typeof globalThis.fetch;
    authAdapter?: AuthAdapter;
    apiKey?: string;
    getAuthToken?: () => Promise<string | null>;
    headers?: Record<string, string>;
    onErrorResponse?: (context: {
        response: Response;
        body: ViewerApiError;
    }) => Promise<void> | void;
};
declare class ViewerAPIClientError extends Error {
    code: string;
    status?: number | undefined;
    details?: Record<string, unknown> | undefined;
    constructor(code: string, message: string, status?: number | undefined, details?: Record<string, unknown> | undefined);
}
declare class ViewerAPIClient {
    private config;
    private fetchFn;
    constructor(config: ViewerAPIConfig);
    getApplicationCapabilities(applicationKey: string, moduleKey: string): Promise<ApplicationModuleCapabilitiesResponse>;
    private buildHeaders;
    private request;
    createInstance(agentId: string, miniAppId: string, options?: {
        miniAppVersion?: string;
        seedState?: Record<string, unknown>;
        seedData?: Record<string, unknown>;
    }): Promise<MiniAppRuntimePayload>;
    getInstance(appInstanceId: string): Promise<MiniAppRuntimePayload>;
    sendEvent(appInstanceId: string, eventId: string, payload: AppEventRequest): Promise<MiniAppRuntimePayload>;
    private applicationMiniAppPath;
    createApplicationAppSession(applicationKey: string, moduleKey: string, appKey: string, options?: {
        seedState?: Record<string, unknown>;
        seedData?: Record<string, unknown>;
        userId?: string;
        tenantId?: string;
    }): Promise<MiniAppRuntimePayload>;
    getApplicationAppSession(applicationKey: string, moduleKey: string, appKey: string, instanceId: string): Promise<MiniAppRuntimePayload>;
    sendApplicationAppEvent(applicationKey: string, moduleKey: string, appKey: string, appInstanceId: string, eventId: string, payload: AppEventRequest): Promise<MiniAppRuntimePayload>;
}
type ApplicationModuleCapabilitiesResponse = {
    module_key: string;
    agent_id: string;
    capabilities?: {
        actions?: ApplicationModuleCapability[];
        queries?: ApplicationModuleCapability[];
        apps?: ApplicationModuleCapability[];
        [key: string]: ApplicationModuleCapability[] | undefined;
    };
};
type ApplicationModuleCapability = ResourceManagementMetadata & {
    key: string;
    workflow_id?: string;
    workflow_version?: string;
    miniapp_id?: string;
    miniapp_version?: string;
    description?: string;
    [key: string]: unknown;
};
type ApplicationAppRuntimeResponse = {
    instance?: Partial<MiniAppRuntimePayload>;
    ui?: MiniAppRuntimePayload["ui"] | null;
    effects?: MiniAppRuntimePayload["effects"];
};
declare function normalizeApplicationAppRuntime(response: ApplicationAppRuntimeResponse): MiniAppRuntimePayload;

interface ApplicationAppTarget {
    applicationKey: string;
    moduleKey: string;
    appKey: string;
}
declare class ViewerStateMachine {
    private requestStorage?;
    private state;
    private listeners;
    private client;
    private agentId?;
    private miniAppId?;
    private applicationAppTarget?;
    private seedState?;
    private inFlight?;
    private pending;
    constructor(client: ViewerAPIClient, agentId?: string, miniAppId?: string, seedState?: Record<string, unknown>, applicationAppTarget?: ApplicationAppTarget, requestStorage?: Pick<Storage, "getItem" | "setItem" | "removeItem"> | undefined);
    getState(): ViewerState;
    subscribe(listener: ViewerStateListener): () => void;
    private setState;
    init(agentId: string, miniAppId: string, options?: {
        seedState?: Record<string, unknown>;
    }): Promise<void>;
    initApplicationApp(target: ApplicationAppTarget, options?: {
        seedState?: Record<string, unknown>;
    }): Promise<void>;
    initialize(): Promise<void>;
    resume(appInstanceId: string): Promise<void>;
    hasPendingRequest(): boolean;
    retryPendingRequest(): Promise<void>;
    dispatchEvent(eventId: string, payload: Record<string, unknown>, formData?: Record<string, unknown>): Promise<void>;
    private performEvent;
    destroy(): void;
}

type TemplateContext = Record<string, unknown>;
declare function resolveTemplate(template: string, context: TemplateContext): string;
declare function resolveTemplateInTree<T extends Record<string, unknown>>(node: T, context: TemplateContext): T;

declare class ComponentRegistry<T> {
    private components;
    private parent?;
    constructor(parent?: ComponentRegistry<T>);
    register(nodeType: string, component: T): this;
    get(nodeType: string): T | undefined;
    has(nodeType: string): boolean;
    types(): string[];
    extend(): ComponentRegistry<T>;
}

declare function resolvePayloadTemplate(template: unknown, actionPayload: Record<string, unknown>): Record<string, unknown>;

declare function parseViewerApiError(error: unknown): ViewerApiError | null;

declare function normalizeFieldType(type: string): string;
declare function isFieldVisible(field: Pick<AppFieldDefinition, 'auto_fill' | 'hidden_if_auto_filled'> & Record<string, unknown>): boolean;

declare function normalizeAppNode(value: unknown): AppNode | null;
declare function normalizeAppUIRender(value: unknown): AppUIRender | null;

declare function normalizeFormsMap(value: unknown): Record<string, AppFormDefinition> | undefined;
declare function normalizeActionBindingsMap(value: unknown): Record<string, AppActionBinding> | undefined;
declare function normalizeEffects(value: unknown): AppEffect[] | undefined;

type ConflictRuntimeResolution = {
    runtime: MiniAppRuntimePayload;
    hasNewerVersion: boolean;
};
declare function reconcileConflictRuntime(runtime: MiniAppRuntimePayload, details: unknown): ConflictRuntimeResolution;

declare function isAppInstanceStatus(value: unknown): value is AppInstanceStatus;
declare function normalizeMiniAppRuntimePayload(payload: unknown): MiniAppRuntimePayload | null;

declare function isVersionConflict(clientVersion: number, serverVersion: number): boolean;
declare function canRetryAfterConflict(clientVersion: number, serverVersion: number): boolean;

declare class APIKeyAuthAdapter implements AuthAdapter {
    private readonly apiKey;
    private readonly user;
    private readonly listeners;
    constructor(apiKey: string);
    authenticate(): Promise<AuthResult>;
    getToken(): Promise<string>;
    logout(): Promise<void>;
    onAuthStateChange(callback: AuthStateCallback): () => void;
}

interface ExternalAuthConfig {
    user: AuthUser;
    getToken: () => Promise<string>;
    onLogout?: () => void | Promise<void>;
}
declare class ExternalAuthAdapter implements AuthAdapter {
    private readonly config;
    private readonly listeners;
    constructor(config: ExternalAuthConfig);
    authenticate(): Promise<AuthResult>;
    getToken(): Promise<string>;
    logout(): Promise<void>;
    onAuthStateChange(callback: AuthStateCallback): () => void;
}

interface BootstrapFetchOptions {
    agentId?: string;
    slug?: string;
    apiBaseUrl: string;
    fetch?: typeof globalThis.fetch;
    headers?: HeadersInit;
}
declare function fetchBootstrapConfig(options: BootstrapFetchOptions & {
    agentId: string;
}): Promise<ViewerBootstrapResponse>;
declare function resolveSlug(options: BootstrapFetchOptions & {
    slug: string;
}): Promise<ViewerBootstrapResponse>;

interface ViewerBootstrapInitConfig extends ViewerBootstrapConfig {
    fetch?: typeof globalThis.fetch;
}
declare class ViewerBootstrap {
    static init(config: ViewerBootstrapInitConfig): Promise<ViewerInstance>;
}

export { APIKeyAuthAdapter, APP_INSTANCE_STATUSES, APP_RUNTIME_CONTRACT, APP_RUNTIME_SCHEMA, APP_UI_CALLOUT_TONES, APP_UI_LAYOUTS, APP_UI_NODE_TYPES, APP_UI_SCHEMA, type ActionBarNode, type AppActionBinding, type AppEffect, type AppEventRequest, type AppFieldDefinition, type AppFieldOption, type AppFormDefinition, type AppInstanceStatus, type AppNode, type AppUICalloutTone, type AppUILayout, type AppUIRender, type ApplicationAppRuntimeResponse, type ApplicationAppTarget, type ApplicationModuleCapabilitiesResponse, type ApplicationModuleCapability, type AuthAdapter, type AuthResult, type AuthStateCallback, type AuthUser, type BadgeRowNode, type BootstrapFetchOptions, type ButtonNode, type CalloutNode, type ChartNode, ComponentRegistry, type ConflictRuntimeResolution, type EmptyStateNode, ExternalAuthAdapter, type ExternalAuthConfig, type FilterBarNode, type FormLinkNode, type GeneratedAccordionNode, type GeneratedActionBarNode, type GeneratedAppInstanceStatus, type GeneratedAppNode, type GeneratedAppRuntimeContract, type GeneratedAppUICalloutTone, type GeneratedAppUILayout, type GeneratedAppUINodeType, type GeneratedAppUIRender, type GeneratedAppUISchema, type GeneratedBadgeRowNode, type GeneratedButtonNode, type GeneratedCalloutNode, type GeneratedCardNode, type GeneratedChartNode, type GeneratedEmptyStateNode, type GeneratedFilterBarNode, type GeneratedFormLinkNode, type GeneratedGroupNode, type GeneratedKPIGridNode, type GeneratedListNode, type GeneratedMetricNode, type GeneratedMiniAppRuntimePayload, type GeneratedSectionNode, type GeneratedSeparatorNode, type GeneratedStatNode, type GeneratedStepsNode, type GeneratedTableNode, type GeneratedTabsNode, type GeneratedTextNode, type GenericNode, type KPIGridNode, type ListNode, MINIAPP_RUNTIME_CONTRACT, type ManagementMode, type MiniAppRuntimePayload, type ResourceManagementMetadata, type SectionNode, type StatNode, type TableNode, type TemplateContext, type TextNode, ViewerAPIClient, ViewerAPIClientError, type ViewerAPIConfig, type ViewerApiError, type ViewerAuthMode, ViewerBootstrap, type ViewerBootstrapConfig, type ViewerBootstrapConfigResponse, type ViewerBootstrapInitConfig, type ViewerBootstrapMiniApp, type ViewerBootstrapResponse, ViewerError, type ViewerInstance, type ViewerPhase, type ViewerState, type ViewerStateController, type ViewerStateListener, ViewerStateMachine, canRetryAfterConflict, fetchBootstrapConfig, isAppInstanceStatus, isFieldVisible, isVersionConflict, normalizeActionBindingsMap, normalizeAppNode, normalizeAppUIRender, normalizeApplicationAppRuntime, normalizeEffects, normalizeFieldType, normalizeFormsMap, normalizeMiniAppRuntimePayload, parseViewerApiError, reconcileConflictRuntime, resolvePayloadTemplate, resolveSlug, resolveTemplate, resolveTemplateInTree };
