@compilr-dev/sdk 0.1.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/LICENSE +21 -0
- package/dist/agent.d.ts +8 -0
- package/dist/agent.js +220 -0
- package/dist/config.d.ts +227 -0
- package/dist/config.js +4 -0
- package/dist/index.d.ts +49 -0
- package/dist/index.js +99 -0
- package/dist/models/index.d.ts +7 -0
- package/dist/models/index.js +11 -0
- package/dist/models/model-registry.d.ts +118 -0
- package/dist/models/model-registry.js +621 -0
- package/dist/models/model-tiers.d.ts +36 -0
- package/dist/models/model-tiers.js +105 -0
- package/dist/models/providers.d.ts +90 -0
- package/dist/models/providers.js +295 -0
- package/dist/models/types.d.ts +28 -0
- package/dist/models/types.js +30 -0
- package/dist/models.d.ts +21 -0
- package/dist/models.js +73 -0
- package/dist/presets/coding.d.ts +21 -0
- package/dist/presets/coding.js +61 -0
- package/dist/presets/index.d.ts +11 -0
- package/dist/presets/index.js +32 -0
- package/dist/presets/read-only.d.ts +8 -0
- package/dist/presets/read-only.js +44 -0
- package/dist/presets/types.d.ts +30 -0
- package/dist/presets/types.js +4 -0
- package/dist/provider.d.ts +28 -0
- package/dist/provider.js +88 -0
- package/dist/team.d.ts +10 -0
- package/dist/team.js +168 -0
- package/dist/tools.d.ts +18 -0
- package/dist/tools.js +95 -0
- package/package.json +70 -0
|
@@ -0,0 +1,621 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Registry
|
|
3
|
+
*
|
|
4
|
+
* Defines supported models with metadata for each provider.
|
|
5
|
+
* Used for:
|
|
6
|
+
* - Model selection UI (list instead of free text)
|
|
7
|
+
* - Session restore strategy (based on thinking format)
|
|
8
|
+
* - Status indicators and warnings
|
|
9
|
+
* - Context window resolution
|
|
10
|
+
*/
|
|
11
|
+
// =============================================================================
|
|
12
|
+
// Model Registry
|
|
13
|
+
// =============================================================================
|
|
14
|
+
/**
|
|
15
|
+
* Registry of known models with their metadata.
|
|
16
|
+
* Models are grouped by provider for easier maintenance.
|
|
17
|
+
*/
|
|
18
|
+
export const MODEL_REGISTRY = [
|
|
19
|
+
// ---------------------------------------------------------------------------
|
|
20
|
+
// Claude Models (Anthropic)
|
|
21
|
+
// ---------------------------------------------------------------------------
|
|
22
|
+
{
|
|
23
|
+
id: 'claude-haiku-4-5-20251001',
|
|
24
|
+
displayName: 'Haiku 4.5',
|
|
25
|
+
description: 'Fast, low cost',
|
|
26
|
+
provider: 'claude',
|
|
27
|
+
defaultTier: 'fast',
|
|
28
|
+
thinkingFormat: 'claude',
|
|
29
|
+
status: 'supported',
|
|
30
|
+
contextWindow: 200000,
|
|
31
|
+
},
|
|
32
|
+
{
|
|
33
|
+
id: 'claude-sonnet-4-5-20250929',
|
|
34
|
+
displayName: 'Sonnet 4.5',
|
|
35
|
+
description: 'Balanced (recommended)',
|
|
36
|
+
provider: 'claude',
|
|
37
|
+
defaultTier: 'balanced',
|
|
38
|
+
thinkingFormat: 'claude',
|
|
39
|
+
status: 'supported',
|
|
40
|
+
contextWindow: 200000,
|
|
41
|
+
},
|
|
42
|
+
{
|
|
43
|
+
id: 'claude-opus-4-5-20251101',
|
|
44
|
+
displayName: 'Opus 4.5',
|
|
45
|
+
description: 'Most capable',
|
|
46
|
+
provider: 'claude',
|
|
47
|
+
defaultTier: 'powerful',
|
|
48
|
+
thinkingFormat: 'claude',
|
|
49
|
+
status: 'supported',
|
|
50
|
+
contextWindow: 200000,
|
|
51
|
+
},
|
|
52
|
+
// Older Claude models (still supported)
|
|
53
|
+
{
|
|
54
|
+
id: 'claude-3-5-sonnet-20241022',
|
|
55
|
+
displayName: 'Sonnet 3.5',
|
|
56
|
+
description: 'Previous generation',
|
|
57
|
+
provider: 'claude',
|
|
58
|
+
thinkingFormat: 'claude',
|
|
59
|
+
status: 'supported',
|
|
60
|
+
contextWindow: 200000,
|
|
61
|
+
notes: 'Previous generation',
|
|
62
|
+
},
|
|
63
|
+
{
|
|
64
|
+
id: 'claude-3-5-haiku-20241022',
|
|
65
|
+
displayName: 'Haiku 3.5',
|
|
66
|
+
description: 'Previous generation',
|
|
67
|
+
provider: 'claude',
|
|
68
|
+
thinkingFormat: 'claude',
|
|
69
|
+
status: 'supported',
|
|
70
|
+
contextWindow: 200000,
|
|
71
|
+
notes: 'Previous generation',
|
|
72
|
+
},
|
|
73
|
+
// ---------------------------------------------------------------------------
|
|
74
|
+
// Gemini Models (Google)
|
|
75
|
+
// ---------------------------------------------------------------------------
|
|
76
|
+
// Gemini 2.x - Supported
|
|
77
|
+
{
|
|
78
|
+
id: 'gemini-2.0-flash',
|
|
79
|
+
displayName: 'Gemini 2.0 Flash',
|
|
80
|
+
description: 'Fast, no thinking',
|
|
81
|
+
provider: 'gemini',
|
|
82
|
+
thinkingFormat: 'none',
|
|
83
|
+
status: 'supported',
|
|
84
|
+
contextWindow: 1000000,
|
|
85
|
+
notes: 'Fast, no thinking blocks',
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
id: 'gemini-2.5-flash-lite',
|
|
89
|
+
displayName: 'Gemini 2.5 Flash Lite',
|
|
90
|
+
description: 'Fast, low cost',
|
|
91
|
+
provider: 'gemini',
|
|
92
|
+
defaultTier: 'fast',
|
|
93
|
+
thinkingFormat: 'gemini-v2',
|
|
94
|
+
status: 'supported',
|
|
95
|
+
contextWindow: 1000000,
|
|
96
|
+
},
|
|
97
|
+
{
|
|
98
|
+
id: 'gemini-2.5-flash',
|
|
99
|
+
displayName: 'Gemini 2.5 Flash',
|
|
100
|
+
description: 'Balanced (recommended)',
|
|
101
|
+
provider: 'gemini',
|
|
102
|
+
defaultTier: 'balanced',
|
|
103
|
+
thinkingFormat: 'gemini-v2',
|
|
104
|
+
status: 'supported',
|
|
105
|
+
contextWindow: 1000000,
|
|
106
|
+
},
|
|
107
|
+
{
|
|
108
|
+
id: 'gemini-2.5-pro',
|
|
109
|
+
displayName: 'Gemini 2.5 Pro',
|
|
110
|
+
description: 'Most capable',
|
|
111
|
+
provider: 'gemini',
|
|
112
|
+
defaultTier: 'powerful',
|
|
113
|
+
thinkingFormat: 'gemini-v2',
|
|
114
|
+
status: 'supported',
|
|
115
|
+
contextWindow: 1000000,
|
|
116
|
+
},
|
|
117
|
+
// Gemini 3.x - Preview, has stability issues with function calling
|
|
118
|
+
{
|
|
119
|
+
id: 'gemini-3-flash-preview',
|
|
120
|
+
displayName: 'Gemini 3 Flash (Preview)',
|
|
121
|
+
description: 'Preview - may have stability issues',
|
|
122
|
+
provider: 'gemini',
|
|
123
|
+
thinkingFormat: 'gemini-v3',
|
|
124
|
+
status: 'supported',
|
|
125
|
+
contextWindow: 1000000,
|
|
126
|
+
notes: 'Preview: 500 errors during function calling, high token usage',
|
|
127
|
+
},
|
|
128
|
+
{
|
|
129
|
+
id: 'gemini-3-pro-preview',
|
|
130
|
+
displayName: 'Gemini 3 Pro (Preview)',
|
|
131
|
+
description: 'Preview - may have stability issues',
|
|
132
|
+
provider: 'gemini',
|
|
133
|
+
thinkingFormat: 'gemini-v3',
|
|
134
|
+
status: 'supported',
|
|
135
|
+
contextWindow: 1000000,
|
|
136
|
+
notes: 'Preview: Works but very high token usage during function calling',
|
|
137
|
+
},
|
|
138
|
+
// ---------------------------------------------------------------------------
|
|
139
|
+
// OpenAI Models
|
|
140
|
+
// ---------------------------------------------------------------------------
|
|
141
|
+
{
|
|
142
|
+
id: 'gpt-4o',
|
|
143
|
+
displayName: 'GPT-4o',
|
|
144
|
+
description: 'Balanced (recommended)',
|
|
145
|
+
provider: 'openai',
|
|
146
|
+
defaultTier: 'balanced',
|
|
147
|
+
thinkingFormat: 'none',
|
|
148
|
+
status: 'supported',
|
|
149
|
+
contextWindow: 128000,
|
|
150
|
+
},
|
|
151
|
+
{
|
|
152
|
+
id: 'gpt-4o-mini',
|
|
153
|
+
displayName: 'GPT-4o Mini',
|
|
154
|
+
description: 'Fast, low cost',
|
|
155
|
+
provider: 'openai',
|
|
156
|
+
defaultTier: 'fast',
|
|
157
|
+
thinkingFormat: 'none',
|
|
158
|
+
status: 'supported',
|
|
159
|
+
contextWindow: 128000,
|
|
160
|
+
},
|
|
161
|
+
{
|
|
162
|
+
id: 'gpt-4-turbo',
|
|
163
|
+
displayName: 'GPT-4 Turbo',
|
|
164
|
+
description: 'Most capable',
|
|
165
|
+
provider: 'openai',
|
|
166
|
+
defaultTier: 'powerful',
|
|
167
|
+
thinkingFormat: 'none',
|
|
168
|
+
status: 'supported',
|
|
169
|
+
contextWindow: 128000,
|
|
170
|
+
},
|
|
171
|
+
// GPT-5 models (if available)
|
|
172
|
+
{
|
|
173
|
+
id: 'gpt-5-nano-2025-08-07',
|
|
174
|
+
displayName: 'GPT-5 Nano',
|
|
175
|
+
description: 'Fast, experimental',
|
|
176
|
+
provider: 'openai',
|
|
177
|
+
thinkingFormat: 'none',
|
|
178
|
+
status: 'experimental',
|
|
179
|
+
contextWindow: 128000,
|
|
180
|
+
notes: 'Latest generation',
|
|
181
|
+
},
|
|
182
|
+
{
|
|
183
|
+
id: 'gpt-5-mini-2025-08-07',
|
|
184
|
+
displayName: 'GPT-5 Mini',
|
|
185
|
+
description: 'Balanced, experimental',
|
|
186
|
+
provider: 'openai',
|
|
187
|
+
thinkingFormat: 'none',
|
|
188
|
+
status: 'experimental',
|
|
189
|
+
contextWindow: 128000,
|
|
190
|
+
notes: 'Latest generation',
|
|
191
|
+
},
|
|
192
|
+
{
|
|
193
|
+
id: 'gpt-5.2-2025-12-11',
|
|
194
|
+
displayName: 'GPT-5.2',
|
|
195
|
+
description: 'Most capable, experimental',
|
|
196
|
+
provider: 'openai',
|
|
197
|
+
thinkingFormat: 'none',
|
|
198
|
+
status: 'experimental',
|
|
199
|
+
contextWindow: 128000,
|
|
200
|
+
notes: 'Latest generation',
|
|
201
|
+
},
|
|
202
|
+
// ---------------------------------------------------------------------------
|
|
203
|
+
// Ollama Models (Local)
|
|
204
|
+
// ---------------------------------------------------------------------------
|
|
205
|
+
{
|
|
206
|
+
id: 'llama3.2:8b',
|
|
207
|
+
displayName: 'Llama 3.2 8B',
|
|
208
|
+
description: 'Fast, small',
|
|
209
|
+
provider: 'ollama',
|
|
210
|
+
defaultTier: 'fast',
|
|
211
|
+
thinkingFormat: 'none',
|
|
212
|
+
status: 'supported',
|
|
213
|
+
notes: 'Requires: ollama pull llama3.2:8b',
|
|
214
|
+
},
|
|
215
|
+
{
|
|
216
|
+
id: 'llama3.2:70b',
|
|
217
|
+
displayName: 'Llama 3.2 70B',
|
|
218
|
+
description: 'Most capable',
|
|
219
|
+
provider: 'ollama',
|
|
220
|
+
defaultTier: 'powerful',
|
|
221
|
+
thinkingFormat: 'none',
|
|
222
|
+
status: 'supported',
|
|
223
|
+
notes: 'Requires: ollama pull llama3.2:70b',
|
|
224
|
+
},
|
|
225
|
+
{
|
|
226
|
+
id: 'deepseek-r1:14b',
|
|
227
|
+
displayName: 'DeepSeek R1 14B',
|
|
228
|
+
description: 'Balanced, reasoning',
|
|
229
|
+
provider: 'ollama',
|
|
230
|
+
defaultTier: 'balanced',
|
|
231
|
+
thinkingFormat: 'none',
|
|
232
|
+
status: 'supported',
|
|
233
|
+
notes: 'Requires: ollama pull deepseek-r1:14b',
|
|
234
|
+
},
|
|
235
|
+
{
|
|
236
|
+
id: 'deepseek-r1:32b',
|
|
237
|
+
displayName: 'DeepSeek R1 32B',
|
|
238
|
+
description: 'Strong reasoning',
|
|
239
|
+
provider: 'ollama',
|
|
240
|
+
thinkingFormat: 'none',
|
|
241
|
+
status: 'supported',
|
|
242
|
+
notes: 'Requires: ollama pull deepseek-r1:32b',
|
|
243
|
+
},
|
|
244
|
+
{
|
|
245
|
+
id: 'qwen2.5:7b',
|
|
246
|
+
displayName: 'Qwen 2.5 7B',
|
|
247
|
+
description: 'Fast, multilingual',
|
|
248
|
+
provider: 'ollama',
|
|
249
|
+
thinkingFormat: 'none',
|
|
250
|
+
status: 'supported',
|
|
251
|
+
notes: 'Requires: ollama pull qwen2.5:7b',
|
|
252
|
+
},
|
|
253
|
+
{
|
|
254
|
+
id: 'qwen2.5:32b',
|
|
255
|
+
displayName: 'Qwen 2.5 32B',
|
|
256
|
+
description: 'Strong multilingual',
|
|
257
|
+
provider: 'ollama',
|
|
258
|
+
thinkingFormat: 'none',
|
|
259
|
+
status: 'supported',
|
|
260
|
+
notes: 'Requires: ollama pull qwen2.5:32b',
|
|
261
|
+
},
|
|
262
|
+
{
|
|
263
|
+
id: 'mistral:7b',
|
|
264
|
+
displayName: 'Mistral 7B',
|
|
265
|
+
description: 'Fast, efficient',
|
|
266
|
+
provider: 'ollama',
|
|
267
|
+
thinkingFormat: 'none',
|
|
268
|
+
status: 'supported',
|
|
269
|
+
notes: 'Requires: ollama pull mistral:7b',
|
|
270
|
+
},
|
|
271
|
+
{
|
|
272
|
+
id: 'codellama:13b',
|
|
273
|
+
displayName: 'Code Llama 13B',
|
|
274
|
+
description: 'Code-focused',
|
|
275
|
+
provider: 'ollama',
|
|
276
|
+
thinkingFormat: 'none',
|
|
277
|
+
status: 'supported',
|
|
278
|
+
notes: 'Optimized for code. Requires: ollama pull codellama:13b',
|
|
279
|
+
},
|
|
280
|
+
// ---------------------------------------------------------------------------
|
|
281
|
+
// Together AI Models (OpenAI-compatible)
|
|
282
|
+
// ---------------------------------------------------------------------------
|
|
283
|
+
{
|
|
284
|
+
id: 'meta-llama/Llama-3.2-8B-Instruct-Turbo',
|
|
285
|
+
displayName: 'Llama 3.2 8B Instruct',
|
|
286
|
+
description: 'Fast, low cost',
|
|
287
|
+
provider: 'together',
|
|
288
|
+
defaultTier: 'fast',
|
|
289
|
+
thinkingFormat: 'none',
|
|
290
|
+
status: 'supported',
|
|
291
|
+
},
|
|
292
|
+
{
|
|
293
|
+
id: 'meta-llama/Llama-3.2-70B-Instruct-Turbo',
|
|
294
|
+
displayName: 'Llama 3.2 70B Instruct',
|
|
295
|
+
description: 'Balanced',
|
|
296
|
+
provider: 'together',
|
|
297
|
+
defaultTier: 'balanced',
|
|
298
|
+
thinkingFormat: 'none',
|
|
299
|
+
status: 'supported',
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
id: 'deepseek-ai/DeepSeek-R1-Distill-Llama-70B',
|
|
303
|
+
displayName: 'DeepSeek R1 70B',
|
|
304
|
+
description: 'Most capable',
|
|
305
|
+
provider: 'together',
|
|
306
|
+
defaultTier: 'powerful',
|
|
307
|
+
thinkingFormat: 'none',
|
|
308
|
+
status: 'supported',
|
|
309
|
+
},
|
|
310
|
+
// ---------------------------------------------------------------------------
|
|
311
|
+
// Groq Models (OpenAI-compatible, fast inference)
|
|
312
|
+
// ---------------------------------------------------------------------------
|
|
313
|
+
{
|
|
314
|
+
id: 'llama-3.2-8b-instant',
|
|
315
|
+
displayName: 'Llama 3.2 8B',
|
|
316
|
+
description: 'Fast, low cost',
|
|
317
|
+
provider: 'groq',
|
|
318
|
+
defaultTier: 'fast',
|
|
319
|
+
thinkingFormat: 'none',
|
|
320
|
+
status: 'supported',
|
|
321
|
+
},
|
|
322
|
+
{
|
|
323
|
+
id: 'llama-3.2-70b-versatile',
|
|
324
|
+
displayName: 'Llama 3.2 70B',
|
|
325
|
+
description: 'Balanced',
|
|
326
|
+
provider: 'groq',
|
|
327
|
+
defaultTier: 'balanced',
|
|
328
|
+
thinkingFormat: 'none',
|
|
329
|
+
status: 'supported',
|
|
330
|
+
},
|
|
331
|
+
{
|
|
332
|
+
id: 'deepseek-r1-distill-llama-70b',
|
|
333
|
+
displayName: 'DeepSeek R1 70B',
|
|
334
|
+
description: 'Most capable',
|
|
335
|
+
provider: 'groq',
|
|
336
|
+
defaultTier: 'powerful',
|
|
337
|
+
thinkingFormat: 'none',
|
|
338
|
+
status: 'supported',
|
|
339
|
+
},
|
|
340
|
+
// ---------------------------------------------------------------------------
|
|
341
|
+
// Fireworks AI Models (OpenAI-compatible)
|
|
342
|
+
// ---------------------------------------------------------------------------
|
|
343
|
+
{
|
|
344
|
+
id: 'accounts/fireworks/models/llama-v3p2-8b-instruct',
|
|
345
|
+
displayName: 'Llama 3.2 8B',
|
|
346
|
+
description: 'Fast, low cost',
|
|
347
|
+
provider: 'fireworks',
|
|
348
|
+
defaultTier: 'fast',
|
|
349
|
+
thinkingFormat: 'none',
|
|
350
|
+
status: 'supported',
|
|
351
|
+
},
|
|
352
|
+
{
|
|
353
|
+
id: 'accounts/fireworks/models/llama-v3p2-70b-instruct',
|
|
354
|
+
displayName: 'Llama 3.2 70B',
|
|
355
|
+
description: 'Balanced',
|
|
356
|
+
provider: 'fireworks',
|
|
357
|
+
defaultTier: 'balanced',
|
|
358
|
+
thinkingFormat: 'none',
|
|
359
|
+
status: 'supported',
|
|
360
|
+
},
|
|
361
|
+
{
|
|
362
|
+
id: 'accounts/fireworks/models/deepseek-r1',
|
|
363
|
+
displayName: 'DeepSeek R1',
|
|
364
|
+
description: 'Most capable',
|
|
365
|
+
provider: 'fireworks',
|
|
366
|
+
defaultTier: 'powerful',
|
|
367
|
+
thinkingFormat: 'none',
|
|
368
|
+
status: 'supported',
|
|
369
|
+
},
|
|
370
|
+
// ---------------------------------------------------------------------------
|
|
371
|
+
// Perplexity Models (Search-augmented AI)
|
|
372
|
+
// ---------------------------------------------------------------------------
|
|
373
|
+
{
|
|
374
|
+
id: 'llama-3.1-sonar-small-128k-online',
|
|
375
|
+
displayName: 'Sonar Small',
|
|
376
|
+
description: 'Fast, low cost',
|
|
377
|
+
provider: 'perplexity',
|
|
378
|
+
defaultTier: 'fast',
|
|
379
|
+
thinkingFormat: 'none',
|
|
380
|
+
status: 'supported',
|
|
381
|
+
notes: 'Includes real-time web search',
|
|
382
|
+
},
|
|
383
|
+
{
|
|
384
|
+
id: 'llama-3.1-sonar-large-128k-online',
|
|
385
|
+
displayName: 'Sonar Large',
|
|
386
|
+
description: 'Balanced',
|
|
387
|
+
provider: 'perplexity',
|
|
388
|
+
defaultTier: 'balanced',
|
|
389
|
+
thinkingFormat: 'none',
|
|
390
|
+
status: 'supported',
|
|
391
|
+
notes: 'Includes real-time web search',
|
|
392
|
+
},
|
|
393
|
+
{
|
|
394
|
+
id: 'llama-3.1-sonar-huge-128k-online',
|
|
395
|
+
displayName: 'Sonar Huge',
|
|
396
|
+
description: 'Most capable',
|
|
397
|
+
provider: 'perplexity',
|
|
398
|
+
defaultTier: 'powerful',
|
|
399
|
+
thinkingFormat: 'none',
|
|
400
|
+
status: 'supported',
|
|
401
|
+
notes: 'Includes real-time web search',
|
|
402
|
+
},
|
|
403
|
+
// ---------------------------------------------------------------------------
|
|
404
|
+
// OpenRouter Models (Aggregator - access many providers)
|
|
405
|
+
// ---------------------------------------------------------------------------
|
|
406
|
+
{
|
|
407
|
+
id: 'meta-llama/llama-3.2-8b-instruct',
|
|
408
|
+
displayName: 'Llama 3.2 8B',
|
|
409
|
+
description: 'Fast, low cost',
|
|
410
|
+
provider: 'openrouter',
|
|
411
|
+
defaultTier: 'fast',
|
|
412
|
+
thinkingFormat: 'none',
|
|
413
|
+
status: 'supported',
|
|
414
|
+
},
|
|
415
|
+
{
|
|
416
|
+
id: 'anthropic/claude-3-5-sonnet',
|
|
417
|
+
displayName: 'Claude 3.5 Sonnet',
|
|
418
|
+
description: 'Balanced (via OpenRouter)',
|
|
419
|
+
provider: 'openrouter',
|
|
420
|
+
defaultTier: 'balanced',
|
|
421
|
+
thinkingFormat: 'none',
|
|
422
|
+
status: 'supported',
|
|
423
|
+
},
|
|
424
|
+
{
|
|
425
|
+
id: 'anthropic/claude-3-opus',
|
|
426
|
+
displayName: 'Claude 3 Opus',
|
|
427
|
+
description: 'Most capable (via OpenRouter)',
|
|
428
|
+
provider: 'openrouter',
|
|
429
|
+
defaultTier: 'powerful',
|
|
430
|
+
thinkingFormat: 'none',
|
|
431
|
+
status: 'supported',
|
|
432
|
+
},
|
|
433
|
+
];
|
|
434
|
+
// =============================================================================
|
|
435
|
+
// Helper Functions
|
|
436
|
+
// =============================================================================
|
|
437
|
+
/**
|
|
438
|
+
* Get all models for a specific provider.
|
|
439
|
+
*/
|
|
440
|
+
export function getModelsForProvider(provider) {
|
|
441
|
+
return MODEL_REGISTRY.filter((m) => m.provider === provider);
|
|
442
|
+
}
|
|
443
|
+
/**
|
|
444
|
+
* Get models for a provider, sorted for display.
|
|
445
|
+
* Order: supported first, then by defaultTier (fast->balanced->powerful), then alphabetical.
|
|
446
|
+
*/
|
|
447
|
+
export function getModelsSortedForDisplay(provider) {
|
|
448
|
+
const models = getModelsForProvider(provider);
|
|
449
|
+
return models.sort((a, b) => {
|
|
450
|
+
// Status priority: supported > experimental > unsupported
|
|
451
|
+
const statusOrder = {
|
|
452
|
+
supported: 0,
|
|
453
|
+
experimental: 1,
|
|
454
|
+
unsupported: 2,
|
|
455
|
+
};
|
|
456
|
+
const statusDiff = statusOrder[a.status] - statusOrder[b.status];
|
|
457
|
+
if (statusDiff !== 0)
|
|
458
|
+
return statusDiff;
|
|
459
|
+
// Default tier models first (they're the recommended ones)
|
|
460
|
+
const aHasDefault = a.defaultTier !== undefined ? 0 : 1;
|
|
461
|
+
const bHasDefault = b.defaultTier !== undefined ? 0 : 1;
|
|
462
|
+
if (aHasDefault !== bHasDefault)
|
|
463
|
+
return aHasDefault - bHasDefault;
|
|
464
|
+
// Alphabetical by display name
|
|
465
|
+
return a.displayName.localeCompare(b.displayName);
|
|
466
|
+
});
|
|
467
|
+
}
|
|
468
|
+
/**
|
|
469
|
+
* Get model info by ID.
|
|
470
|
+
* Returns undefined for unknown models.
|
|
471
|
+
*/
|
|
472
|
+
export function getModelInfo(modelId) {
|
|
473
|
+
return MODEL_REGISTRY.find((m) => m.id === modelId);
|
|
474
|
+
}
|
|
475
|
+
/**
|
|
476
|
+
* Check if a model is in the registry.
|
|
477
|
+
*/
|
|
478
|
+
export function isKnownModel(modelId) {
|
|
479
|
+
return MODEL_REGISTRY.some((m) => m.id === modelId);
|
|
480
|
+
}
|
|
481
|
+
/**
|
|
482
|
+
* Check if a model is supported.
|
|
483
|
+
* Returns false for unknown models (conservative default).
|
|
484
|
+
*/
|
|
485
|
+
export function isModelSupported(modelId) {
|
|
486
|
+
const model = getModelInfo(modelId);
|
|
487
|
+
return model?.status === 'supported';
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Get the thinking format for a model.
|
|
491
|
+
* Returns 'none' for unknown models (safe default).
|
|
492
|
+
*/
|
|
493
|
+
export function getThinkingFormat(modelId) {
|
|
494
|
+
const model = getModelInfo(modelId);
|
|
495
|
+
return model?.thinkingFormat ?? 'none';
|
|
496
|
+
}
|
|
497
|
+
/**
|
|
498
|
+
* Get status indicator for UI display.
|
|
499
|
+
*/
|
|
500
|
+
export function getStatusIndicator(status) {
|
|
501
|
+
switch (status) {
|
|
502
|
+
case 'supported':
|
|
503
|
+
return '✓';
|
|
504
|
+
case 'experimental':
|
|
505
|
+
return '~';
|
|
506
|
+
case 'unsupported':
|
|
507
|
+
return '⚠';
|
|
508
|
+
}
|
|
509
|
+
}
|
|
510
|
+
/**
|
|
511
|
+
* Get status label for UI display.
|
|
512
|
+
*/
|
|
513
|
+
export function getStatusLabel(status) {
|
|
514
|
+
switch (status) {
|
|
515
|
+
case 'supported':
|
|
516
|
+
return 'Supported';
|
|
517
|
+
case 'experimental':
|
|
518
|
+
return 'Experimental';
|
|
519
|
+
case 'unsupported':
|
|
520
|
+
return 'Unsupported';
|
|
521
|
+
}
|
|
522
|
+
}
|
|
523
|
+
/**
|
|
524
|
+
* Get the default model for a tier from the registry.
|
|
525
|
+
* Returns the first model with that defaultTier, or undefined if none.
|
|
526
|
+
*/
|
|
527
|
+
export function getDefaultModelForTier(provider, tier) {
|
|
528
|
+
return MODEL_REGISTRY.find((m) => m.provider === provider && m.defaultTier === tier && m.status === 'supported');
|
|
529
|
+
}
|
|
530
|
+
/**
|
|
531
|
+
* Check if two models have compatible thinking formats for session restore.
|
|
532
|
+
* Compatible means we can restore without clearing history.
|
|
533
|
+
*/
|
|
534
|
+
export function areThinkingFormatsCompatible(fromModelId, toModelId) {
|
|
535
|
+
if (!fromModelId)
|
|
536
|
+
return true; // No previous model = compatible
|
|
537
|
+
const fromFormat = getThinkingFormat(fromModelId);
|
|
538
|
+
const toFormat = getThinkingFormat(toModelId);
|
|
539
|
+
// Same format is always compatible
|
|
540
|
+
if (fromFormat === toFormat)
|
|
541
|
+
return true;
|
|
542
|
+
// 'none' is compatible with anything (no thinking blocks to worry about)
|
|
543
|
+
if (fromFormat === 'none' || toFormat === 'none')
|
|
544
|
+
return true;
|
|
545
|
+
// gemini-v3 is incompatible with everything else
|
|
546
|
+
if (fromFormat === 'gemini-v3' || toFormat === 'gemini-v3')
|
|
547
|
+
return false;
|
|
548
|
+
// claude and gemini-v2 are NOT directly compatible (different formats)
|
|
549
|
+
// but we can strip thinking blocks
|
|
550
|
+
return false;
|
|
551
|
+
}
|
|
552
|
+
/**
|
|
553
|
+
* Determine if session history should be cleared when switching models.
|
|
554
|
+
* Returns true if history must be cleared (incompatible), false if we can keep/strip.
|
|
555
|
+
*
|
|
556
|
+
* Note: Gemini v3 no longer requires clearing history since Session 119.
|
|
557
|
+
* The native @google/genai SDK handles thought signatures automatically.
|
|
558
|
+
*/
|
|
559
|
+
export function shouldClearHistoryOnModelChange(_fromModelId, _toModelId) {
|
|
560
|
+
// With native SDK support for all providers, no model switch requires clearing history.
|
|
561
|
+
// Thinking blocks from different providers can be stripped during restore.
|
|
562
|
+
return false;
|
|
563
|
+
}
|
|
564
|
+
// =============================================================================
|
|
565
|
+
// Context Window Resolution
|
|
566
|
+
// =============================================================================
|
|
567
|
+
/**
|
|
568
|
+
* Provider fallback context limits.
|
|
569
|
+
* Used when a model is not in the registry or has no contextWindow set.
|
|
570
|
+
*/
|
|
571
|
+
function getProviderContextLimitFallback(provider) {
|
|
572
|
+
switch (provider) {
|
|
573
|
+
case 'gemini':
|
|
574
|
+
return 1000000;
|
|
575
|
+
case 'claude':
|
|
576
|
+
return 200000;
|
|
577
|
+
case 'openai':
|
|
578
|
+
return 128000;
|
|
579
|
+
case 'ollama':
|
|
580
|
+
return 32000;
|
|
581
|
+
case 'together':
|
|
582
|
+
return 131072;
|
|
583
|
+
case 'groq':
|
|
584
|
+
return 131072;
|
|
585
|
+
case 'fireworks':
|
|
586
|
+
return 131072;
|
|
587
|
+
case 'perplexity':
|
|
588
|
+
return 131072;
|
|
589
|
+
case 'openrouter':
|
|
590
|
+
return 128000;
|
|
591
|
+
default:
|
|
592
|
+
return 200000;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
/**
|
|
596
|
+
* Get context window size for a model ID.
|
|
597
|
+
* Falls back to provider default if model not found or contextWindow not set.
|
|
598
|
+
*/
|
|
599
|
+
export function getModelContextWindow(modelId, provider) {
|
|
600
|
+
const info = getModelInfo(modelId);
|
|
601
|
+
if (info?.contextWindow) {
|
|
602
|
+
return info.contextWindow;
|
|
603
|
+
}
|
|
604
|
+
return getProviderContextLimitFallback(provider);
|
|
605
|
+
}
|
|
606
|
+
/**
|
|
607
|
+
* Get model display name by ID.
|
|
608
|
+
* Returns the model ID if not found in registry.
|
|
609
|
+
*/
|
|
610
|
+
export function getModelDisplayName(modelId) {
|
|
611
|
+
const model = getModelInfo(modelId);
|
|
612
|
+
return model?.displayName ?? modelId;
|
|
613
|
+
}
|
|
614
|
+
/**
|
|
615
|
+
* Get model description by ID.
|
|
616
|
+
* Returns empty string if not found.
|
|
617
|
+
*/
|
|
618
|
+
export function getModelDescription(modelId) {
|
|
619
|
+
const model = getModelInfo(modelId);
|
|
620
|
+
return model?.description ?? '';
|
|
621
|
+
}
|
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Model Tiers — Role-Based Model Selection (Pure/Settings-Free)
|
|
3
|
+
*
|
|
4
|
+
* Pure functions for tier-based model selection. The SDK version accepts
|
|
5
|
+
* optional override maps as parameters instead of reading from settings.
|
|
6
|
+
* CLI wraps these with its settings layer.
|
|
7
|
+
*/
|
|
8
|
+
import type { ProviderType } from '../config.js';
|
|
9
|
+
import type { ModelTier, ProviderModelMap } from './types.js';
|
|
10
|
+
/**
|
|
11
|
+
* Get the model ID for a given tier and provider.
|
|
12
|
+
* Checks overrides first, then falls back to registry defaults.
|
|
13
|
+
*
|
|
14
|
+
* @param provider - The provider type
|
|
15
|
+
* @param tier - The model tier
|
|
16
|
+
* @param overrides - Optional tier overrides (e.g., from user settings)
|
|
17
|
+
*/
|
|
18
|
+
export declare function getModelForTier(provider: ProviderType, tier: ModelTier, overrides?: Partial<Record<ProviderType, Partial<ProviderModelMap>>>): string;
|
|
19
|
+
/**
|
|
20
|
+
* Get all tier mappings for a provider (with optional overrides applied).
|
|
21
|
+
*/
|
|
22
|
+
export declare function getTierMappings(provider: ProviderType, overrides?: Partial<Record<ProviderType, Partial<ProviderModelMap>>>): ProviderModelMap;
|
|
23
|
+
/**
|
|
24
|
+
* Get the display name for a model tier.
|
|
25
|
+
*/
|
|
26
|
+
export declare function getTierDisplayName(tier: ModelTier): string;
|
|
27
|
+
/**
|
|
28
|
+
* Get short model name from full model ID (for display).
|
|
29
|
+
* e.g., "claude-sonnet-4-5-20250929" -> "Sonnet 4.5"
|
|
30
|
+
*/
|
|
31
|
+
export declare function getShortModelName(modelId: string): string;
|
|
32
|
+
/**
|
|
33
|
+
* Get the default tier mappings (without user overrides).
|
|
34
|
+
* Derived from MODEL_REGISTRY — single source of truth.
|
|
35
|
+
*/
|
|
36
|
+
export declare function getDefaultTierMappings(): Record<ProviderType, ProviderModelMap>;
|