Open History to see the last commit
1import { openaiText } from '@tanstack/ai-openai'
2import { anthropicText } from '@tanstack/ai-anthropic'
3import { geminiText } from '@tanstack/ai-gemini'
4import { groqText } from '@tanstack/ai-groq'
5import { openRouterText } from '@tanstack/ai-openrouter'
6
7/**
8 * SERVER-ONLY adapter resolution for the MCP demo routes. Kept separate from
9 * `mcp-providers.ts` (the client-safe provider metadata) so pages that render
10 * the provider picker never pull the provider SDKs into the browser bundle —
11 * `@anthropic-ai/sdk` is in vite's `optimizeDeps.exclude`, and serving its
12 * CJS dep `standardwebhooks` un-prebundled crashes the page in dev.
13 */
14
15/**
16 * Resolve a request's `provider` (sent from the client via the chat body /
17 * AG-UI forwardedProps) to a configured text adapter. Defaults to OpenAI.
18 */
19export function resolveTextAdapter(provider: unknown) {
20 switch (provider) {
21 case 'openrouter':
22 return openRouterText('openai/gpt-5.5')
23 case 'anthropic':
24 return anthropicText('claude-sonnet-4-6')
25 case 'gemini':
26 return geminiText('gemini-3.5-flash')
27 case 'groq':
28 return groqText('llama-3.3-70b-versatile')
29 case 'openai':
30 default:
31 return openaiText('gpt-5.5')
32 }
33}