import * as react_jsx_runtime from 'react/jsx-runtime';
import React, { ReactNode } from 'react';

type Props = {
    messages: {
        role: string;
        text: string;
    }[];
    onCommand: (input: string) => void;
    width?: number;
    isLoading?: boolean;
    activeTrace?: any[];
};
declare function CommandPanel({ messages, onCommand, width, isLoading, activeTrace }: Props): react_jsx_runtime.JSX.Element;

type AgentGroup = {
    id: string;
    name: string;
    intents: any[];
};
type AgentBarProps = {
    width?: number;
    onNavigate?: (key: string, meta?: any) => void;
    onClose?: () => void;
    activeKey?: string | null;
    fetchAgents: () => Promise<AgentGroup[]>;
    logoNode?: React.ReactNode;
    brandName?: string;
};
declare function AgentBar({ width, onNavigate, onClose, activeKey, fetchAgents, logoNode, brandName }: AgentBarProps): react_jsx_runtime.JSX.Element;

interface FieldComputedConfig {
    expression: string;
    dependsOn?: string[];
    precision?: number;
    format?: "currency" | "decimal" | "percentage" | string;
}
interface FieldUIConfig {
    component?: string;
    placeholder?: string;
    helperText?: string;
    lookupAction?: string;
    lookupLabelKey?: string;
    lookupValueKey?: string;
    computed?: FieldComputedConfig;
}
interface DynamicFieldSchema {
    name: string;
    label?: string;
    type: "string" | "number" | "boolean" | "date" | "object" | "array";
    description?: string;
    required?: boolean;
    fields?: DynamicFieldSchema[];
    items?: DynamicFieldSchema | DynamicFieldSchema[];
    options?: Array<{
        label: string;
        value: string | number | boolean;
    }>;
    ui?: FieldUIConfig;
}
interface ChartConfig {
    type?: "bar" | "line";
    xKey?: string;
    yKey?: string;
    seriesKey?: string;
    valueKey?: string;
}
interface DynamicViewSchema {
    id?: string;
    title?: string;
    type?: "object" | "array" | "chart";
    fields?: DynamicFieldSchema[];
    items?: DynamicFieldSchema | DynamicFieldSchema[];
    view?: {
        type?: string;
        chart?: ChartConfig;
    };
}

type ViewMode = "document" | "form" | "table" | "json";
interface FieldDescriptor {
    name: string;
    label: string;
    type: string;
    required?: boolean;
    hint?: string;
    description?: string;
    section?: string;
    order?: number;
    component?: string;
    items?: FieldDescriptor[];
    fields?: FieldDescriptor[];
}
interface ViewDescriptor {
    title?: string;
    description?: string;
    fields: FieldDescriptor[];
    values?: Record<string, any>;
    rows?: Array<Record<string, any>>;
    content?: any;
}
interface LegacyViewObject {
    type: "text" | "table" | "form";
    title?: string;
    content?: string;
    fields?: string[];
    rows?: any[];
    isHtml?: boolean;
}
type SemanticField = {
    type?: string;
    label?: string;
    required?: boolean;
    description?: string;
    hint?: string;
};
interface SemanticViewObject {
    intent: string;
    missing: string[];
    schema: Record<string, SemanticField> | DynamicViewSchema;
    values?: Record<string, any>;
    model?: Record<string, any>;
    rows?: Array<Record<string, any>>;
    content?: any;
    preferredView?: ViewMode;
    viewDescriptor?: ViewDescriptor;
    nextAction?: string | null;
    suggestedAction?: {
        id: string;
        label: string;
    } | null;
}
type ViewObject = LegacyViewObject | SemanticViewObject;

declare function DynamicViewSlot({ view, onQuickCommand, onViewChange, onActionComplete, quickCommands, }: {
    view: ViewObject | {
        type: "settings";
        dark: boolean;
        leftWidth: number;
        rightWidth: number;
        onToggleTheme: () => void;
        onLeftWidthChange: (n: number) => void;
        onRightWidthChange: (n: number) => void;
        onReset: () => void;
    } | null;
    onQuickCommand?: (text: string) => void;
    onViewChange?: (view: ViewObject | null) => void;
    /** Called when a suggested action completes. Use to inject a message into the chat. */
    onActionComplete?: (label: string, data: Record<string, any>) => void;
    /** Quick command chips shown on the empty state. Derived from agent intents in the host app. */
    quickCommands?: string[];
}): react_jsx_runtime.JSX.Element;

type EvoluteseContextType = {
    executeAction?: (payload: any) => Promise<any>;
    getAgentConfig?: (agentId: string) => Promise<any>;
    apiEndpoint?: string;
    tenantId: string | null;
    demoMode?: boolean;
};
declare function EvoluteseProvider({ children, executeAction, getAgentConfig, apiEndpoint, tenantId, demoMode }: EvoluteseContextType & {
    children: ReactNode;
}): react_jsx_runtime.JSX.Element;
declare function useEvolutese(): EvoluteseContextType;

interface UseEvoluteseActionOptions<TResponse> {
    endpoint?: string;
    defaultThreadId?: string;
    tenantId?: string;
    onEvent?: (event: any) => void;
    onComplete?: (data: TResponse) => void;
    onError?: (error: unknown) => void;
}
declare function useEvoluteseAction<TResponse = any>(options?: UseEvoluteseActionOptions<TResponse>): {
    execute: (payload: any) => Promise<TResponse | null>;
    isPending: boolean;
    stream: any[];
    data: TResponse | null;
    error: Error | null;
};

type AgentStatus = 'idle' | 'running' | 'streaming' | 'error';
/**
 * The shape of the agent's accumulated state.
 * Intentionally generic — no chat/UI assumptions.
 */
interface AgentState<TData = unknown> {
    /** Structured data returned by the last execution (result payload). */
    data: TData | null;
    /** Ordered list of raw SSE events received during execution. */
    events: AgentEvent[];
    /** Optional message list — only populated if the agent emits message events. */
    messages: AgentMessage[];
}
interface AgentEvent {
    type: string;
    [key: string]: unknown;
}
interface AgentMessage {
    role: 'user' | 'agent';
    content: string;
    timestamp: string;
}
/**
 * Input to useAgent.send().
 * Mirrors the Evolutese event protocol:
 *   { type, payload }  — structured event
 *   { text }           — free-text (maps to user.message internally)
 */
type AgentSendInput = {
    type: string;
    payload?: Record<string, unknown>;
} | {
    text: string;
    threadId?: string;
};
interface UseAgentOptions<TData = unknown> {
    /** HTTP endpoint to POST events to. Falls back to EvoluteseProvider.apiEndpoint. */
    endpoint?: string;
    /** Stable thread ID. Defaults to auto-generated per send() call if omitted. */
    threadId?: string;
    /** Tenant ID. Falls back to EvoluteseProvider.tenantId. */
    tenantId?: string;
    /** Called on every raw SSE event. */
    onEvent?: (event: AgentEvent) => void;
    /** Called when the execution completes successfully. */
    onComplete?: (data: TData) => void;
    /** Called on any execution error. */
    onError?: (error: Error) => void;
}
interface UseAgentReturn<TData = unknown> {
    state: AgentState<TData>;
    status: AgentStatus;
    error: Error | null;
    /**
     * Dispatch an event to the agent.
     * Accepts either a structured event { type, payload } or free-text { text }.
     */
    send: (input: AgentSendInput) => Promise<TData | null>;
    /** Reset local state back to idle. Does not cancel in-flight requests. */
    reset: () => void;
}
/**
 * useAgent — generic, headless agent hook.
 *
 * Does NOT assume:
 *   - a chat UI
 *   - a specific event structure
 *   - any Evolutese-specific view schema
 *
 * Does guarantee:
 *   - a stable `state` object (data, events, messages)
 *   - a `status` flag (idle | running | streaming | error)
 *   - a `send(event)` dispatcher
 *   - a `reset()` helper
 */
declare function useAgent<TData = unknown>(options?: UseAgentOptions<TData>): UseAgentReturn<TData>;

declare const VERSION = "0.1.0";

export { AgentBar, type AgentEvent, type AgentMessage, type AgentSendInput, type AgentState, type AgentStatus, CommandPanel, DynamicViewSlot, type EvoluteseContextType, EvoluteseProvider, type UseAgentOptions, type UseAgentReturn, type UseEvoluteseActionOptions, VERSION, useAgent, useEvolutese, useEvoluteseAction };
