@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)
toAgentMessages
Adapt AI SDK's `UIMessage[]` (from `useChat`) to the `AgentMessage[]` shape `<AgentChatLog>` consumes.
declare function toAgentMessages(uiMessages: ReadonlyArray<AiSdkUIMessage>, status: string): AgentMessage[];Interfaces(3)
AgentMessage
interface AgentMessage| Member | Type | Summary |
|---|---|---|
| id | string | |
| role | 'user' | 'assistant' | |
| status? | 'streaming' | 'done' | `streaming` while the model is still calling tools / writing text; `done` once the turn is final. |
| text | string | |
| 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'`. |
AgentToolCall
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| Member | Type | Summary |
|---|---|---|
| error? | string | Set when the call errored — surfaces in the timeline as failed. |
| id | string | Stable id for keying. |
| input? | unknown | JSON-able input the agent passed. Rendered in the expanded view. |
| name | string | Tool name (e.g. `read_document`, `add_comment`). |
| result? | string | Result text or summary. Set after the call completes. |
| status | 'running' | 'done' | 'error' | `running` while in flight, `done` on success, `error` on failure. |
AiSdkUIMessage
Minimal structural shape of a Vercel AI SDK `UIMessage`.
interface AiSdkUIMessage| Member | Type | Summary |
|---|---|---|
| id | string | |
| parts? | ReadonlyArray<{
type: string;
text?: string;
toolCallId?: string;
state?: string;
input?: unknown;
output?: unknown;
errorText?: string;
}> | |
| role | 'user' | 'assistant' | 'system' |