import { UiStreamEvent, FetchLike, RunState, PendingInteractionWire, InboxRun, UiNode } from '@reactive-agents/ui-core'; export { InboxRun, PendingInteractionWire, RunState, StatusTone, StatusView, TimeFormatOptions, UiNode, UiRunStatus, UiStreamEvent, formatClockTime, formatCost, formatRelativeTime, formatTokens, formatTurnDuration, modelWaitLabel, statusOfRun, statusOfSubAgent, statusOfTurn, uiTreeSchema } from '@reactive-agents/ui-core'; import * as React from 'react'; type AgentStreamEvent = UiStreamEvent; type AgentHookState = "idle" | "streaming" | "completed" | "error"; interface UseAgentStreamReturn { /** Accumulated text output so far (grows as TextDelta events arrive). */ text: string; /** All raw events received since the last run(). */ events: readonly AgentStreamEvent[]; /** Current execution status. */ status: AgentHookState; /** Error message if status === "error". */ error: string | null; /** Full output when status === "completed". */ output: string | null; /** Trigger a new run. Cancels any in-progress stream. */ run: (prompt: string, body?: Record) => void; /** Cancel the active stream. */ cancel: () => void; } interface UseAgentReturn { /** Final output when status === "completed". */ output: string | null; /** Whether the agent is currently running. */ loading: boolean; /** Error message if the run failed. */ error: string | null; /** Trigger a run. Resolves on completion. */ run: (prompt: string, body?: Record) => Promise; } /** * Stream agent output token-by-token from an SSE endpoint. * * The endpoint should return a Server-Sent Events response produced by * `AgentStream.toSSE(agent.runStream(prompt))` on the server. * * @param endpoint - URL of the server-side agent SSE endpoint * @param requestInit - Optional fetch options (headers, etc.) * * @example * ```tsx * function Chat() { * const { text, status, run } = useAgentStream("/api/agent"); * return ( *
* *

{text}

* {status === "streaming" && ●} *
* ); * } * ``` */ declare function useAgentStream(endpoint: string, requestInit?: Omit): UseAgentStreamReturn; /** * One-shot agent call — waits for completion, returns the full output. * For streaming token-by-token use `useAgentStream` instead. * * @param endpoint - URL of the server-side agent endpoint (POST, returns JSON with `output`) * * @example * ```tsx * function Summary({ text }: { text: string }) { * const { output, loading, error, run } = useAgent("/api/agent"); * return ( *
* * {output &&

{output}

} * {error &&

{error}

} *
* ); * } * ``` */ declare function useAgent(endpoint: string, requestInit?: Omit): UseAgentReturn; interface UseRunOptions { readonly endpoint: string; readonly fetchImpl?: FetchLike; readonly objectMode?: boolean; readonly auto?: { readonly prompt: string; readonly body?: Record; }; readonly attach?: { readonly runId: string; readonly cursor?: number; }; } interface UseRunReturn { readonly state: RunState; readonly run: (prompt: string, body?: Record) => void; readonly cancel: () => void; readonly reattach: (runId: string, cursor?: number) => void; } declare function useRun(opts: UseRunOptions): UseRunReturn; interface UseResumableRunOptions { readonly endpoint: string; readonly runId: string; readonly cursor?: number; readonly fetchImpl?: FetchLike; readonly objectMode?: boolean; } /** Reattach to a durable run on mount, replaying from the given cursor. */ declare function useResumableRun(opts: UseResumableRunOptions): UseRunReturn; interface UseInteractionsOptions { readonly interactionEndpoint: string; readonly fetchImpl?: FetchLike; } interface UseInteractionsReturn { readonly respond: (runId: string, interactionId: string, value: unknown) => Promise<{ success: boolean; output: string; }>; readonly pending: boolean; readonly error: string | null; } declare function useInteractions(opts: UseInteractionsOptions): UseInteractionsReturn; interface AgentPromptProps { readonly interaction: PendingInteractionWire; readonly onRespond: (value: unknown) => void; readonly className?: string; readonly children?: (ctx: { interaction: PendingInteractionWire; submit: (v: unknown) => void; }) => React.ReactNode; } declare function AgentPrompt({ interaction, onRespond, className, children }: AgentPromptProps): React.ReactElement; interface ChoiceCardProps { readonly options: readonly string[]; readonly onPick: (value: string) => void; readonly className?: string; } declare function ChoiceCard({ options, onPick, className }: ChoiceCardProps): React.ReactElement; interface ApprovalGateProps { readonly approval: { readonly runId: string; readonly gateId: string; readonly toolName: string; readonly args: unknown; }; readonly onDecide: (decision: "approve" | "deny", reason?: string) => void; readonly className?: string; } declare function ApprovalGate({ approval, onDecide, className }: ApprovalGateProps): React.ReactElement; interface UseTaskInboxOptions { readonly endpoint: string; readonly fetchImpl?: FetchLike; readonly pollMs?: number; } interface UseTaskInboxReturn { readonly runs: readonly InboxRun[]; readonly loading: boolean; readonly error: string | null; readonly refresh: () => void; } declare function useTaskInbox(opts: UseTaskInboxOptions): UseTaskInboxReturn; interface TaskInboxProps { readonly runs: readonly InboxRun[]; readonly onSelect?: (runId: string) => void; readonly className?: string; readonly renderRow?: (run: InboxRun) => React.ReactNode; } declare function TaskInbox({ runs, onSelect, className, renderRow }: TaskInboxProps): React.ReactElement; declare function useRunCost(state: RunState): { tokens: number; usd: number; }; interface StepEntry { readonly kind: "tool" | "thought" | "iteration"; readonly label: string; readonly seq?: number; readonly durationMs?: number; readonly success?: boolean; } declare function useRunSteps(state: RunState): readonly StepEntry[]; interface CostMeterProps { readonly state: RunState; readonly className?: string; } declare function CostMeter({ state, className }: CostMeterProps): React.ReactElement; interface StepTimelineProps { readonly state: RunState; readonly className?: string; } declare function StepTimeline({ state, className }: StepTimelineProps): React.ReactElement; /** React-specific: maps node `type` → the React component that renders it. */ type ComponentRegistry = Record>; interface AgentSurfaceProps { readonly tree: unknown; readonly registry: ComponentRegistry; readonly className?: string; } declare function AgentSurface({ tree, registry, className }: AgentSurfaceProps): React.ReactElement; interface AgentDevtoolsProps { readonly state: RunState; readonly enabled?: boolean; readonly onReplay?: () => void; readonly position?: "bottom-right" | "bottom-left"; } declare function AgentDevtools({ state, enabled, onReplay, position, }: AgentDevtoolsProps): React.ReactElement | null; export { AgentDevtools, type AgentDevtoolsProps, type AgentHookState, AgentPrompt, type AgentPromptProps, type AgentStreamEvent, AgentSurface, type AgentSurfaceProps, ApprovalGate, type ApprovalGateProps, ChoiceCard, type ChoiceCardProps, type ComponentRegistry, CostMeter, type CostMeterProps, type StepEntry, StepTimeline, type StepTimelineProps, TaskInbox, type TaskInboxProps, type UseAgentReturn, type UseAgentStreamReturn, type UseInteractionsOptions, type UseInteractionsReturn, type UseResumableRunOptions, type UseRunOptions, type UseRunReturn, type UseTaskInboxOptions, type UseTaskInboxReturn, useAgent, useAgentStream, useInteractions, useResumableRun, useRun, useRunCost, useRunSteps, useTaskInbox };