New

docx-editor 1.x has shipped. Vue support, i18n, agents. Read the migration guide →

API Referencev1.0.2

@eigenpal/docx-editor-agents/ai-sdk/react

Vercel AI SDK adapter (React side). Opt-in.

Use this if you're driving the chat with `useChat` from `@ai-sdk/react`. The library's `<AgentChatLog>` consumes a flat `AgentMessage[]` shape; AI SDK's `useChat` produces `UIMessage[]` with structured `parts`. `toAgentMessages()` is the bridge.

Functions(1)

Adapt AI SDK's `UIMessage[]` (from `useChat`) to the `AgentMessage[]` shape `<AgentChatLog>` consumes.

declare function toAgentMessages(uiMessages: ReadonlyArray<AiSdkUIMessage>, status: string): AgentMessage[];

Interfaces(3)

interface AgentMessage
MemberTypeSummary
idstring
role'user' | 'assistant'
status?'streaming' | 'done'`streaming` while the model is still calling tools / writing text; `done` once the turn is final.
textstring
toolCalls?AgentToolCall[]Tool calls the assistant made for this turn, in order. The timeline stays expanded while `status === 'streaming'` and auto-collapses to an "N steps" summary when the message hits `status === 'done'`.

Shared agent UI types — framework-agnostic. Both React and Vue adapters (and the AI SDK adapters) consume this single declaration.

Keeping the types here lets us tweak the chat schema without writing the same drift fix in four files.

interface AgentToolCall
MemberTypeSummary
error?stringSet when the call errored — surfaces in the timeline as failed.
idstringStable id for keying.
input?unknownJSON-able input the agent passed. Rendered in the expanded view.
namestringTool name (e.g. `read_document`, `add_comment`).
result?stringResult text or summary. Set after the call completes.
status'running' | 'done' | 'error'`running` while in flight, `done` on success, `error` on failure.

Minimal structural shape of a Vercel AI SDK `UIMessage`.

interface AiSdkUIMessage
MemberTypeSummary
idstring
parts?ReadonlyArray<{ type: string; text?: string; toolCallId?: string; state?: string; input?: unknown; output?: unknown; errorText?: string; }>
role'user' | 'assistant' | 'system'