Open History to see the last commit
1import type { Provider, Feature } from '@/lib/types'
2
3/**
4 * Single source of truth for provider × feature support.
5 *
6 * This matrix is imported by `tests/test-matrix.ts` (Playwright specs) and
7 * by the dev routes under `src/routes/` to decide which provider/feature
8 * combinations to render and test. Update this file only — do not fork.
9 */
10export const matrix: Record<Feature, Set<Provider>> = {
11 chat: new Set([
12 'openai',
13 'anthropic',
14 'gemini',
15 'ollama',
16 'groq',
17 'grok',
18 'openrouter',
19 ]),
20 'one-shot-text': new Set([
21 'openai',
22 'anthropic',
23 'gemini',
24 'ollama',
25 'groq',
26 'grok',
27 'openrouter',
28 ]),
29 reasoning: new Set(['openai', 'anthropic', 'gemini']),
30 'multi-turn': new Set([
31 'openai',
32 'anthropic',
33 'gemini',
34 'ollama',
35 'groq',
36 'grok',
37 'openrouter',
38 ]),
39 'tool-calling': new Set([
40 'openai',
41 'anthropic',
42 'gemini',
43 'ollama',
44 'groq',
45 'grok',
46 'openrouter',
47 ]),
48 'parallel-tool-calls': new Set([
49 'openai',
50 'anthropic',
51 'gemini',
52 'groq',
53 'grok',
54 'openrouter',
55 ]),
56 // Gemini excluded: approval flow timing issues with Gemini's streaming format
57 'tool-approval': new Set([
58 'openai',
59 'anthropic',
60 'ollama',
61 'groq',
62 'grok',
63 'openrouter',
64 ]),
65 // Ollama excluded: aimock doesn't support content+toolCalls for /api/chat format
66 'text-tool-text': new Set([
67 'openai',
68 'anthropic',
69 'gemini',
70 'groq',
71 'grok',
72 'openrouter',
73 ]),
74 'structured-output': new Set([
75 'openai',
76 'anthropic',
77 'gemini',
78 'ollama',
79 'groq',
80 'grok',
81 'openrouter',
82 ]),
83 // Streaming structured output: only providers with native streaming JSON
84 // schema support are listed here. Other providers fall back to the
85 // activity-layer `fallbackStructuredOutputStream` (which wraps the
86 // non-streaming `structuredOutput`) but aren't exercised by E2E yet.
87 'structured-output-stream': new Set(['openai', 'groq', 'grok', 'openrouter']),
88 // Multi-turn structured output: every turn produces its own typed
89 // `structured-output` part on the assistant message, and historical
90 // turns stay renderable. Works for every provider that supports both
91 // multi-turn and structured-output — non-native-streaming adapters
92 // (anthropic, gemini, ollama) fall back to a single
93 // `structured-output.complete` event per turn, but the per-message
94 // typed part still lands and the round-trip is identical.
95 'multi-turn-structured': new Set([
96 'openai',
97 'anthropic',
98 'gemini',
99 'ollama',
100 'groq',
101 'grok',
102 'openrouter',
103 ]),
104 'agentic-structured': new Set([
105 'openai',
106 'anthropic',
107 'gemini',
108 'ollama',
109 'groq',
110 'grok',
111 'openrouter',
112 ]),
113 'multimodal-image': new Set([
114 'openai',
115 'anthropic',
116 'gemini',
117 'grok',
118 'openrouter',
119 ]),
120 'multimodal-structured': new Set([
121 'openai',
122 'anthropic',
123 'gemini',
124 'grok',
125 'openrouter',
126 ]),
127 summarize: new Set([
128 'openai',
129 'anthropic',
130 'gemini',
131 'ollama',
132 'grok',
133 'openrouter',
134 ]),
135 'summarize-stream': new Set([
136 'openai',
137 'anthropic',
138 'gemini',
139 'ollama',
140 'grok',
141 'openrouter',
142 ]),
143 // Gemini excluded: aimock doesn't mock Gemini's Imagen predict endpoint format
144 'image-gen': new Set(['openai', 'grok']),
145 tts: new Set(['openai', 'grok']),
146 transcription: new Set(['openai', 'grok']),
147 'video-gen': new Set(['openai']),
148}
149
150export function isSupported(provider: Provider, feature: Feature): boolean {
151 return matrix[feature]?.has(provider) ?? false
152}
153
154export function getSupportedFeatures(provider: Provider): Feature[] {
155 return (Object.entries(matrix) as Array<[Feature, Set<Provider>]>)
156 .filter(([_, providers]) => providers.has(provider))
157 .map(([feature]) => feature)
158}