useCandorChat

Free · MIT

Wires a useChat() result to Candor: messages for <Thread>/<Message>, props for <Composer>, and the tool calls waiting on a person. Configure useChat however you like (transport, tools, onFinish); this only reads it.

Mentions in the composer are sent as structured references in the request body (references), not pasted into the text, so the server gets ids.

const chat = useChat({ transport }) const { messages, composer, approvals, respond } = useCandorChat(chat, { agent }) <Thread footer={<Composer {...composer} />}>{messages.map((m) => <Message key={m.id} message={m} />)}</Thread>

Markdown

Preview

It's types and helpers, listed below.

Install

With the Candor CLI

First time? Get started sets up the registry and theme. Or with shadcn directly: npx shadcn@latest add @candor/use-candor-chat

Brings in: ai-sdk, chat, composer · npm: @ai-sdk/react@^4.0.166, ai@^7.0.162

Functions

useCandorChat(chat: UseChatHelpers<UIMessage>, options: Omit<FromAiSdkOptions, "chatStatus">)

Wires a useChat() result to Candor: messages for <Thread>/<Message>, props for <Composer>, and the tool calls waiting on a person. Configure useChat however you like (transport, tools, onFinish); this only reads it.

Mentions in the composer are sent as structured references in the request body (references), not pasted into the text, so the server gets ids.

const chat = useChat({ transport }) const { messages, composer, approvals, respond } = useCandorChat(chat, { agent }) <Thread footer={<Composer {...composer} />}>{messages.map((m) => <Message key={m.id} message={m} />)}</Thread>

Types

PendingApproval
{ id: string; toolCallId: string; tool: string; input: unknown; reason?: string | undefined }