TanStack AI
Keep the SDK hook in charge and render its projected messages through Ghost.
Use the native connection
Install the checked @tanstack/ai, @tanstack/ai-client and @tanstack/ai-react versions in stability. Supply a real ConnectionAdapter, such as your application’s HTTP or AG-UI connection. It owns the request, stream and cancellation. Follow AI installation for styles and view peers. The same MessageParts composition also accepts plain data.
Commands and extension points
The hook owns messages and transport. Ghost binds text send, stop and latest-answer regeneration; optional setMessages enables local edit/resubmit. Editing truncates local history before resending, so reconcile persistence and a failed resend in your application. Native tool schemas, execution, request authentication and storage remain outside Ghost.
Supply the adapter's normalization options for deliberate part mappings and reasoning summaries. Supply runtime availability to disable actions for application policy. Attachments need the explicit outbound converter described in runtime integration; unsupported files are rejected rather than dropped.
Troubleshooting and native APIs
A missing answer usually indicates a protocol/transport mismatch. Inspect native errors first, then capability support/availability. Keep one hook owner per context and advance the identity revision on replacement. Retain the native hook for capabilities whose semantics are richer than a generic message command.
TanStack AI documentation covers connection adapters, client tools and state. The AG-UI connection is optional; direct AG-UI preserves an existing HttpAgent client.
AG-UI through a TanStack connection
Keep this route when TanStack already owns your chat client. Supply your authenticated endpoint and real thread ID. The connection decodes AG-UI through TanStack; it does not adopt a second native AG-UI client. For an existing HttpAgent and its shared state, choose the direct client.