import { WireMessage } from '@theokit/presenter/wire'; export { WireMessage } from '@theokit/presenter/wire'; import { R as RequestContext, U as UseAgentStatus, P as PendingApproval, A as ApprovalDecision, a as AgentHandle, b as AgentTransport } from './agent-handle-rEWdERuv.js'; import '@theokit/sdk/errors'; interface UseAgentReturn { /** The CURRENT turn's assistant messages (per-turn; reset each `send`). Back-compat since M41. */ messages: WireMessage[]; /** * M46 — the full conversation to render: committed turns + the current turn's user + in-flight * assistant, accumulated across sends with stable ids. Prefer this over hand-rolling a transcript * from `messages`. Same shape on every surface (web/desktop/TUI) — it lives in the core store. */ thread: WireMessage[]; status: UseAgentStatus; /** The last error, or `undefined`. */ error: Error | undefined; /** Send a request; opens a new stream. Typed to the agent's `input` schema. */ send: (input: TInput) => void; /** Abort an in-flight stream. */ abort: () => void; /** Clear messages + error, back to idle. */ reset: () => void; /** * The HITL decisions this turn is parked on — empty whenever nothing is outstanding * (usetheokit/theokit#392). * * Each entry carries the id `approve` takes plus what a prompt needs to name the action: the * tool, its resolved input, the declared question and the window. Render it directly: * * ```tsx * {pendingApprovals.map((a) => ( *
* {a.question ?? `Run ${a.toolName}?`} * * *
* ))} * ``` * * The same decision is on the transcript too — the gated tool's part sits in * `state: 'approval-requested'` with the id under `approval.id` — so a surface that renders tool * parts inline can read it there instead. This field exists so one does not have to. */ pendingApprovals: PendingApproval[]; /** Settle a paused HITL approval (HTTP `POST /approve/` for web; the inline callback in-process). */ approve: (approvalId: string, decision: ApprovalDecision) => Promise; /** Resume an interrupted stream (M37 durable transport for web; a no-op in-process). */ reconnect: () => void; /** * The union of tool names this agent can emit (M8), carried end-to-end from the `agent()` builder's * accumulated tool-name type through the generated `@theo/agents` client. Type-only witness (never * populated at runtime). Resolves to the literal union for builder agents, `string` otherwise. */ readonly __toolNames?: TToolNames; } interface UseAgentOptions { /** * Extra request headers (e.g., auth) — applied when a string path builds an `HttpTransport`. Read on * EVERY request, so a value that changes across renders (a rotating JWT) is never sent stale. */ headers?: Record; /** Override fetch (primarily for tests) — captured when a string path builds an `HttpTransport`. */ fetch?: typeof fetch; /** * M43 — per-request context attached uniformly to EVERY transport (`headers` → HTTP request headers; * `metadata` → the in-process runner / Tauri invoke). A value OR a resolver evaluated on every * send/reconnect, so a rotating token/tenant is never stale. */ context?: RequestContext | (() => RequestContext | undefined); } /** * Bind to an agent by endpoint path (`/api/agents/`), by a typed {@link AgentHandle} (M47 — the * generated `chat` handle; kills the magic string + duplicated input type), or by an explicit * {@link AgentTransport}. Prefer the generated `useAgent` from `@theo/agents` (typed by agent name or * handle); this base accepts all three. The store is created once per binding identity — memoize a * transport before passing it. */ declare function useAgent(binding: string | AgentHandle | AgentTransport, options?: UseAgentOptions): UseAgentReturn; export { PendingApproval, type UseAgentOptions, type UseAgentReturn, UseAgentStatus, useAgent };