Skip to content

Commit f504302

Browse files
authored
fix(ai-openrouter): restore OpenRouterChatModelToolCapabilitiesByName (#582)
The mapped type was hand-added in #466 but never wired into the OpenRouter model generator. PR #581's wholesale regeneration dropped it, breaking the build and typecheck on main (index.ts, text.ts, responses-text.ts all import it). - Emit the type from scripts/convert-openrouter-models.ts so future syncs preserve it. - Restore the missing block in model-meta.ts (matches what the fixed generator now produces).
1 parent aa3acf1 commit f504302

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
---
2+
'@tanstack/ai-openrouter': patch
3+
---
4+
5+
Restore `OpenRouterChatModelToolCapabilitiesByName` export in `model-meta.ts` and emit it from the OpenRouter model generator so future syncs don't drop it.

packages/typescript/ai-openrouter/src/model-meta.ts

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16251,6 +16251,10 @@ export const OPENROUTER_CHAT_MODELS = [
1625116251
'openrouter/auto',
1625216252
] as const
1625316253

16254+
export type OpenRouterChatModelToolCapabilitiesByName = {
16255+
[K in (typeof OPENROUTER_CHAT_MODELS)[number]]: readonly ['web_search']
16256+
}
16257+
1625416258
export const OPENROUTER_IMAGE_MODELS = [
1625516259
GOOGLE_GEMINI_2_5_FLASH_IMAGE.id,
1625616260
GOOGLE_GEMINI_3_PRO_IMAGE_PREVIEW.id,

scripts/convert-openrouter-models.ts

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,19 @@ function generateChatModelsArray(): string {
6464
.join('\n')}\n] as const`
6565
}
6666

67+
/**
68+
* OpenRouter's web_search plugin works across all chat models via the gateway,
69+
* so the tool-capability map is structural and identical for every chat model.
70+
* Emitted as a mapped type to stay in sync with OPENROUTER_CHAT_MODELS without
71+
* touching each model constant.
72+
*/
73+
function generateChatToolCapabilitiesType(): string {
74+
if (chatModels.size === 0) {
75+
return ''
76+
}
77+
return `export type OpenRouterChatModelToolCapabilitiesByName = {\n [K in (typeof OPENROUTER_CHAT_MODELS)[number]]: readonly ['web_search']\n}`
78+
}
79+
6780
function generateImageModelsArray(): string {
6881
const modelIds = Array.from(imageModels)
6982
if (modelIds.length === 0) {
@@ -306,6 +319,8 @@ ${createPerModelModelOptions()}
306319
${createPerModelInputModalities()}
307320
308321
${generateChatModelsArray()}
322+
323+
${generateChatToolCapabilitiesType()}
309324
${generateVideoModelsArray()}
310325
${generateImageModelsArray()}
311326
`

0 commit comments

Comments
 (0)