@codeworksh/aikit 0.11.0-dev.20261019181702 → 0.12.0-canary.47.1.g3f60acd1
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/cli.mjs
CHANGED
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
2
|
import { r as OpenAICodexOAuthClient, t as JsonOpenAICodexAuthStorage } from "./codex-CLDBTrFm.mjs";
|
|
3
|
-
import { t as ModelgenCommand } from "./modelgen-
|
|
3
|
+
import { t as ModelgenCommand } from "./modelgen-BdiCqi-R.mjs";
|
|
4
4
|
import { i as JsonGitHubCopilotAuthStorage, r as GitHubCopilotOAuthClient } from "./copilot-DvUXC6Kx.mjs";
|
|
5
5
|
import { n as promptLine, t as openBrowser } from "./interactive-eoNnscGB.mjs";
|
|
6
6
|
import { a as oauthNotice, c as summarizeGitHubCopilot, i as oauthLoginIssue, l as summarizeOpenAICodex, n as checkOAuthProvider, r as formatOAuthSummary, s as oauthRefreshIssue } from "./summary-C_QyCVWa.mjs";
|
|
7
7
|
import yargs from "yargs";
|
|
8
8
|
import { hideBin } from "yargs/helpers";
|
|
9
9
|
//#region package.json
|
|
10
|
-
var version = "0.
|
|
10
|
+
var version = "0.12.0-canary.47.1.g3f60acd1";
|
|
11
11
|
//#endregion
|
|
12
12
|
//#region src/cli/oauth.ts
|
|
13
13
|
async function runOpenAICodexAuth(args) {
|
|
@@ -440,7 +440,6 @@ const OPENAI_CODEX_MODELS = [
|
|
|
440
440
|
id: "gpt-5.3-codex-spark",
|
|
441
441
|
contextWindow: 128e3
|
|
442
442
|
},
|
|
443
|
-
{ id: "gpt-5.5" },
|
|
444
443
|
{ id: "gpt-5.6-luna" },
|
|
445
444
|
{ id: "gpt-5.6-sol" },
|
|
446
445
|
{ id: "gpt-5.6-terra" },
|
|
@@ -461,9 +460,7 @@ const OPENAI_CODEX_ADDITIONAL_TOOLS_MODEL_IDS = /* @__PURE__ */ new Set([
|
|
|
461
460
|
"gpt-6-sol",
|
|
462
461
|
"gpt-6.1-sol"
|
|
463
462
|
]);
|
|
464
|
-
const OPENAI_CODEX_TOOL_SEARCH_MODEL_IDS = /* @__PURE__ */ new Set(["gpt-5.5", ...OPENAI_CODEX_ADDITIONAL_TOOLS_MODEL_IDS]);
|
|
465
463
|
const OPENAI_CODEX_NONE_REASONING_MODEL_IDS = /* @__PURE__ */ new Set([
|
|
466
|
-
"gpt-5.5",
|
|
467
464
|
"gpt-5.6-luna",
|
|
468
465
|
"gpt-6-luna",
|
|
469
466
|
"gpt-6-sol"
|
|
@@ -500,8 +497,10 @@ function openAICodexBuiltInModels(openai) {
|
|
|
500
497
|
providerOptionsKey: OPENAI_CODEX_PROVIDER_ID,
|
|
501
498
|
compat: {
|
|
502
499
|
supportsOpenAIGrammarTools: true,
|
|
503
|
-
...
|
|
504
|
-
|
|
500
|
+
...OPENAI_CODEX_ADDITIONAL_TOOLS_MODEL_IDS.has(seed.id) ? {
|
|
501
|
+
supportsToolSearch: true,
|
|
502
|
+
supportsAdditionalTools: true
|
|
503
|
+
} : {}
|
|
505
504
|
},
|
|
506
505
|
protocol: KnownProviderEnum.openaiCodex
|
|
507
506
|
};
|
|
@@ -728,4 +727,4 @@ function applyModification(providerId, provider, model) {
|
|
|
728
727
|
//#endregion
|
|
729
728
|
export { personalize as i, generateModels as n, PROVIDER_ID as r, ModelgenCommand as t };
|
|
730
729
|
|
|
731
|
-
//# sourceMappingURL=modelgen-
|
|
730
|
+
//# sourceMappingURL=modelgen-BdiCqi-R.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelgen-BdiCqi-R.mjs","names":["Model.effortThinkingLevels","Model.normalizeInput","OpenRouter.BASE_URL","OpenRouter.PROVIDER_ID","Filesystem.readJson","Model.effortThinkingLevels","Model.isAnthropicAdaptiveThinkingModel","OpenRouter.catalog","path","ModelCatalog.path","Filesystem.writeJsonAtomic","Model.normalizeInput"],"sources":["../../src/model/openrouter.ts","../../src/cli/modelgen.ts"],"sourcesContent":["/*\n * @file OpenRouter's own model listing, read two ways.\n *\n * The generator builds the `openrouter` catalog from the public `GET /models` (pi): it carries\n * the reasoning efforts each model accepts, which models.dev only covers for some. At runtime\n * `GET /models/user` narrows that catalog to what one key may use, with that key's limits and\n * prices. Both go through the same field readers.\n */\nimport * as Model from \"./model.ts\";\n\nexport const PROVIDER_ID = \"openrouter\";\nexport const BASE_URL = \"https://openrouter.ai/api/v1\";\nconst NPM = \"@openrouter/ai-sdk-provider\";\nconst USER_MODELS_TIMEOUT_MS = 15_000;\n\n/** OpenRouter's per-token prices, as decimal strings. */\ninterface Pricing {\n\tprompt?: string;\n\tcompletion?: string;\n\tinput_cache_read?: string;\n\tinput_cache_write?: string;\n\t/** Conditional prices: `min_prompt_tokens` selects prompt-length pricing, `utc_*` time-of-day pricing. */\n\toverrides?: Array<{\n\t\tmin_prompt_tokens?: number;\n\t\tutc_start?: number;\n\t\tutc_end?: number;\n\t\tutc_days?: string[];\n\t\tprompt?: string;\n\t\tcompletion?: string;\n\t\tinput_cache_read?: string;\n\t\tinput_cache_write?: string;\n\t}>;\n}\n\n/** The fields read from an entry of `GET /models` and `GET /models/user`. */\nexport interface Entry {\n\tid: string;\n\tname?: string;\n\tcontext_length?: number | null;\n\ttop_provider?: { context_length?: number | null; max_completion_tokens?: number | null };\n\tpricing?: Pricing;\n\tsupported_parameters?: string[];\n\tarchitecture?: { input_modalities?: string[] };\n\treasoning?: {\n\t\tmandatory?: boolean;\n\t\tsupported_efforts?: string[];\n\t} | null;\n}\n\n/**\n * $/token to $/1M tokens. Missing, invalid and negative prices use the fallback: OpenRouter\n * reports -1 for router models such as `openrouter/auto`, whose price depends on the model it picks.\n */\nfunction perMillion(value: string | undefined, fallback: number): number {\n\tconst perToken = Number.parseFloat(value ?? \"\");\n\treturn perToken >= 0 ? Number((perToken * 1_000_000).toFixed(6)) : fallback;\n}\n\n/**\n * Prompt-length overrides become request-wide tiers; a rate a tier does not list keeps the base\n * price. Time-of-day overrides are skipped: the cost model cannot express them.\n */\nexport function cost(pricing: Pricing | undefined): Model.Info[\"cost\"] {\n\tconst base = {\n\t\tinput: perMillion(pricing?.prompt, 0),\n\t\toutput: perMillion(pricing?.completion, 0),\n\t\tcacheRead: perMillion(pricing?.input_cache_read, 0),\n\t\tcacheWrite: perMillion(pricing?.input_cache_write, 0),\n\t};\n\tconst tiers = (pricing?.overrides ?? []).flatMap((override) => {\n\t\tif (\n\t\t\toverride.min_prompt_tokens === undefined ||\n\t\t\toverride.utc_start !== undefined ||\n\t\t\toverride.utc_end !== undefined ||\n\t\t\toverride.utc_days !== undefined\n\t\t) {\n\t\t\treturn [];\n\t\t}\n\t\treturn [\n\t\t\t{\n\t\t\t\tinputTokensAbove: override.min_prompt_tokens,\n\t\t\t\tinput: perMillion(override.prompt, base.input),\n\t\t\t\toutput: perMillion(override.completion, base.output),\n\t\t\t\tcacheRead: perMillion(override.input_cache_read, base.cacheRead),\n\t\t\t\tcacheWrite: perMillion(override.input_cache_write, base.cacheWrite),\n\t\t\t},\n\t\t];\n\t});\n\treturn tiers.length > 0 ? { ...base, tiers } : base;\n}\n\n/**\n * `supported_efforts` uses models.dev's effort vocabulary. Off maps to `none` unless reasoning is\n * mandatory; a mandatory model without listed efforts can only refuse off.\n */\nexport function thinkingLevels(reasoning: Entry[\"reasoning\"]): Model.ThinkingLevelMap | undefined {\n\tif (!reasoning) return undefined;\n\tconst map = Model.effortThinkingLevels(reasoning.supported_efforts ?? []);\n\tif (!map) return reasoning.mandatory === true ? { off: null } : undefined;\n\treturn { ...map, off: reasoning.mandatory === true ? null : \"none\" };\n}\n\n/**\n * The catalog entry for one listed model, or undefined for one an agent cannot use: no tool\n * calling, or a `:batch` variant, whose asynchronous pricing an interactive turn never gets.\n */\nexport function toModel(entry: Entry): Model.Info | undefined {\n\tif (!entry.supported_parameters?.includes(\"tools\") || entry.id.endsWith(\":batch\")) return undefined;\n\tconst thinkingLevelMap = thinkingLevels(entry.reasoning);\n\treturn {\n\t\tid: entry.id,\n\t\tname: entry.name ?? entry.id,\n\t\tprovider: { id: PROVIDER_ID, name: \"OpenRouter\", source: \"api\", env: [\"OPENROUTER_API_KEY\"] },\n\t\tbaseUrl: BASE_URL,\n\t\treasoning: entry.supported_parameters.includes(\"reasoning\"),\n\t\t...(thinkingLevelMap ? { thinkingLevelMap } : {}),\n\t\tinput: Model.normalizeInput(entry.architecture?.input_modalities),\n\t\tcost: cost(entry.pricing),\n\t\t// `||`: OpenRouter reports a missing limit as absent, null or 0.\n\t\tcontextWindow: entry.top_provider?.context_length || entry.context_length || 4096,\n\t\tmaxTokens: entry.top_provider?.max_completion_tokens || 4096,\n\t\tnpm: NPM,\n\t\tapi: { id: entry.id, url: BASE_URL, method: Model.APIMethodEnum.languageModel },\n\t\tproviderOptionsKey: PROVIDER_ID,\n\t\tprotocol: Model.KnownProviderEnum.openrouter,\n\t};\n}\n\nfunction entries(body: unknown): Entry[] {\n\tif (typeof body !== \"object\" || body === null || !(\"data\" in body) || !Array.isArray(body.data)) {\n\t\tthrow new Error(\"invalid OpenRouter model list\");\n\t}\n\treturn body.data.filter(\n\t\t(entry: unknown): entry is Entry =>\n\t\t\ttypeof entry === \"object\" && entry !== null && \"id\" in entry && typeof entry.id === \"string\",\n\t);\n}\n\n/** The public `GET /models`, built into catalog entries keyed by id. */\nexport function catalog(body: unknown): Record<string, Model.Info> {\n\tconst models: Record<string, Model.Info> = {};\n\tfor (const entry of entries(body)) {\n\t\tconst model = toModel(entry);\n\t\tif (model) models[model.id] = model;\n\t}\n\treturn models;\n}\n\n/**\n * Restrict OpenRouter models to those `key` may use, with the key's limits and prices from\n * `GET /models/user` (pi). A missing limit keeps the catalog value. When the endpoint rejects the\n * key (401/403) or does not exist (404), or allows nothing, the models come back unchanged.\n */\nexport async function personalize(\n\tmodels: Record<string, Model.Info>,\n\tkey: string,\n\toptions: { readonly baseUrl?: string; readonly signal?: AbortSignal } = {},\n): Promise<Record<string, Model.Info>> {\n\tconst signal = AbortSignal.timeout(USER_MODELS_TIMEOUT_MS);\n\tconst response = await fetch(`${(options.baseUrl ?? BASE_URL).replace(/\\/+$/, \"\")}/models/user`, {\n\t\theaders: { accept: \"application/json\", authorization: `Bearer ${key}` },\n\t\tsignal: options.signal ? AbortSignal.any([options.signal, signal]) : signal,\n\t});\n\tif (response.status === 401 || response.status === 403 || response.status === 404) return models;\n\tif (!response.ok) throw new Error(`OpenRouter model list request failed: ${response.status}`);\n\tconst allowed = new Map(entries(await response.json()).map((entry) => [entry.id, entry]));\n\n\tconst personal: Record<string, Model.Info> = {};\n\tfor (const [id, model] of Object.entries(models)) {\n\t\tconst entry = allowed.get(id);\n\t\tif (!entry) continue;\n\t\tpersonal[id] = {\n\t\t\t...model,\n\t\t\tcontextWindow: entry.top_provider?.context_length || entry.context_length || model.contextWindow,\n\t\t\tmaxTokens: entry.top_provider?.max_completion_tokens || model.maxTokens,\n\t\t\tcost: entry.pricing ? cost(entry.pricing) : model.cost,\n\t\t};\n\t}\n\treturn Object.keys(personal).length > 0 ? personal : models;\n}\n\nexport * as OpenRouter from \"./openrouter.ts\";\n","import { resolve } from \"node:path\";\nimport { mapValues, pick, pickBy, pipe } from \"remeda\";\nimport type { CommandModule } from \"yargs\";\nimport { DEFAULT_AI_SDK_FALLBACK, isAISDKPackage, protocolForPackage } from \"../llm/registry.ts\";\nimport * as ModelCatalog from \"../model/catalog.ts\";\nimport * as Model from \"../model/model.ts\";\nimport { OpenRouter } from \"../model/openrouter.ts\";\nimport { GITHUB_COPILOT_STATIC_HEADERS } from \"../providers/github-copilot/copilot-headers.ts\";\nimport * as Filesystem from \"../utils/filesystem.ts\";\n\nconst DEFAULT_PROVIDER_BASE_URLS: Partial<Record<Model.KnownProviderEnum, string>> = {\n\t[Model.KnownProviderEnum.anthropic]: \"https://api.anthropic.com/v1\",\n\t[Model.KnownProviderEnum.openai]: \"https://api.openai.com/v1\",\n\t[Model.KnownProviderEnum.openrouter]: OpenRouter.BASE_URL,\n\t[Model.KnownProviderEnum.xai]: \"https://api.x.ai/v1\",\n};\n\ninterface ModelsDevCost {\n\tinput?: number;\n\toutput?: number;\n\tcache_read?: number;\n\tcache_write?: number;\n}\n\ninterface ModelsDevModel {\n\tid: string;\n\tname: string;\n\tfamily: string;\n\tattachment: boolean;\n\treasoning?: boolean;\n\ttool_call?: boolean;\n\ttemperature?: boolean;\n\tknowledge?: string | boolean;\n\trelease_date: string;\n\tlast_updated: string;\n\tmodalities: {\n\t\tinput?: string[];\n\t\toutput: string[];\n\t};\n\topen_weights: boolean;\n\tbaseUrl?: string;\n\theaders?: Record<string, string>;\n\tcost?: ModelsDevCost & {\n\t\ttiers?: Array<ModelsDevCost & { tier?: { type?: string; size?: number } }>;\n\t};\n\treasoning_options?: Array<{\n\t\ttype?: string;\n\t\tvalues?: Array<string | null>;\n\t\tmin?: number;\n\t\tmax?: number;\n\t}>;\n\tstatus?: string;\n\tlimit?: {\n\t\tcontext?: number;\n\t\toutput?: number;\n\t};\n\tstructured_output?: boolean;\n\tprovider?: {\n\t\tnpm?: string;\n\t\tapi?: string;\n\t\theaders?: Record<string, string>;\n\t};\n\t/** Request variants such as OpenAI's `service_tier: \"priority\"`, each with its own price. */\n\texperimental?: {\n\t\tmodes?: Record<string, { cost?: ModelsDevCost; provider?: { body?: Record<string, unknown> } }>;\n\t};\n}\n\ninterface ModelsDevProvider {\n\tid: string;\n\tenv: string[];\n\tnpm?: string;\n\tapi?: string;\n\tname: string;\n\tdoc?: string; // reference documentation link\n\tkey?: string; // runtime placeholder for api/oauth key\n\theaders?: Record<string, string>; // custom overrides at provider level\n\tmodels: Record<string, ModelsDevModel>;\n}\n\nexport type BuiltInModels = Model.BuiltInModels;\n\n// Doesn't represent the full spec from models.dev.\n// Represents the provider entries on a best-effort basis.\ntype ModelsDevCatalog = Record<string, ModelsDevProvider>;\n\n/** The catalog's sources, fetched: models.dev, and OpenRouter's own listing when it answered. */\nexport interface Sources {\n\treadonly modelsDev: ModelsDevCatalog;\n\treadonly openRouter?: unknown;\n}\n\n/** Providers bundled with aikit as the baseline catalog, read until a generated one exists. */\nexport const BASELINE_PROVIDERS = [\"anthropic\", \"openai\", OpenRouter.PROVIDER_ID] as const;\n\nfunction modelsDevURL(): string {\n\treturn process.env.CODEWORK_MODELS_DEV_URL || \"https://models.dev\";\n}\n\nfunction modelsDevPath(): string | undefined {\n\treturn process.env.CODEWORK_MODELS_DEV_FILE;\n}\n\nasync function pullModelsDevData(): Promise<ModelsDevCatalog> {\n\tconst path = modelsDevPath();\n\tif (path) {\n\t\tconst result = await Filesystem.readJson<ModelsDevCatalog>(path).catch(() => undefined);\n\t\tif (result) return result;\n\t}\n\n\tconst response = await fetch(`${modelsDevURL()}/api.json`);\n\tif (!response.ok) throw new Error(`models.dev responded ${response.status} ${response.statusText}`);\n\treturn (await response.json()) as ModelsDevCatalog;\n}\n\n/** OpenRouter's public listing, or undefined when it cannot be had: models.dev's copy stands in. */\nasync function pullOpenRouterData(): Promise<unknown> {\n\ttry {\n\t\tconst response = await fetch(`${OpenRouter.BASE_URL}/models`, { signal: AbortSignal.timeout(30_000) });\n\t\treturn response.ok ? await response.json() : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction toModelValue(providerId: string, provider: ModelsDevProvider, model: ModelsDevModel): Model.Info | undefined {\n\treturn applyModification(providerId, provider, model);\n}\n\n// models.dev lists this alias, but OpenAI's APIs do not accept it (pi).\nconst MODELS_DEV_UNSUPPORTED_MODEL_IDS = new Set([\"openai/gpt-5.6\"]);\n\nfunction usable(providerId: string, provider: ModelsDevProvider, model: ModelsDevModel): boolean {\n\treturn (\n\t\tBoolean(model.tool_call) &&\n\t\t!MODELS_DEV_UNSUPPORTED_MODEL_IDS.has(`${providerId}/${model.id}`) &&\n\t\t// If `resolveModelNpm` fallbacks to `@ai-sdk/openai-compatible`\n\t\t// isAISDKPakage will be truthy, modify resolveModelNpm for custom logic if needed.\n\t\t// Keep `isAISDKPackage` as readonly for supported implemenatations key check\n\t\tisAISDKPackage(resolveModelNpm(provider, model))\n\t);\n}\n\nfunction loadBuiltInFromModelsDev(catalog: ModelsDevCatalog) {\n\treturn pipe(\n\t\tcatalog,\n\t\tpickBy((provider, providerId) =>\n\t\t\tObject.values(provider.models).some((model) => usable(providerId, provider, model)),\n\t\t),\n\t\tmapValues((provider, providerId) =>\n\t\t\tpipe(\n\t\t\t\tprovider.models,\n\t\t\t\tpickBy((model) => usable(providerId, provider, model)),\n\t\t\t\tmapValues((model) => toModelValue(providerId, provider, model)),\n\t\t\t\tpickBy((model): model is Model.Info => model !== undefined),\n\t\t\t),\n\t\t),\n\t) as BuiltInModels;\n}\n\ntype ThinkingLevelMap = NonNullable<Model.Info[\"thinkingLevelMap\"]>;\n\nfunction resolveModelNpm(provider: ModelsDevProvider, model: ModelsDevModel): string {\n\treturn model.provider?.npm ?? provider.npm ?? DEFAULT_AI_SDK_FALLBACK;\n}\n\nfunction resolveModelBaseUrl(provider: ModelsDevProvider, model: ModelsDevModel): string {\n\tconst npm = resolveModelNpm(provider, model);\n\tconst protocol = protocolForPackage(npm);\n\treturn model.baseUrl ?? model.provider?.api ?? provider.api ?? DEFAULT_PROVIDER_BASE_URLS[protocol] ?? \"\";\n}\n\nfunction resolveModelAPIMethod(npm: string): Model.APIMethodEnum {\n\tconst protocol = protocolForPackage(npm);\n\t// `By default, xai(modelId) uses the Chat API.\n\t// To use the Responses API with server-side agentic tools, explicitly use xai.responses(modelId).`\n\t// References: https://ai-sdk.dev/providers/ai-sdk-providers/xai\n\tif (protocol === Model.KnownProviderEnum.openai || protocol === Model.KnownProviderEnum.xai) {\n\t\treturn Model.APIMethodEnum.responses;\n\t}\n\treturn Model.APIMethodEnum.languageModel;\n}\n\nfunction resolveProviderOptionsKey(protocol: Model.KnownProviderEnum): string {\n\tif (protocol === Model.KnownProviderEnum.openaiCompatible) return \"openai-compatible\";\n\tif (protocol === Model.KnownProviderEnum.googleVertex) return \"google-vertex\";\n\tif (protocol === Model.KnownProviderEnum.googleVertexAnthropic) return \"google-vertex-anthropic\";\n\treturn protocol;\n}\n\nfunction roundCost(value: number): number {\n\treturn Number(value.toFixed(6));\n}\n\n/** models.dev prices, with its context tiers; a rate a tier does not list keeps the base price (pi). */\nfunction modelsDevCost(cost: ModelsDevModel[\"cost\"]): Model.Info[\"cost\"] {\n\tconst base = {\n\t\tinput: cost?.input ?? 0,\n\t\toutput: cost?.output ?? 0,\n\t\tcacheRead: cost?.cache_read ?? 0,\n\t\tcacheWrite: cost?.cache_write ?? 0,\n\t};\n\tconst tiers = cost?.tiers?.flatMap((tier) => {\n\t\tconst context = tier.tier;\n\t\tif (context?.type !== \"context\" || context.size === undefined) return [];\n\t\treturn [\n\t\t\t{\n\t\t\t\tinputTokensAbove: context.size,\n\t\t\t\tinput: tier.input ?? base.input,\n\t\t\t\toutput: tier.output ?? base.output,\n\t\t\t\tcacheRead: tier.cache_read ?? base.cacheRead,\n\t\t\t\tcacheWrite: tier.cache_write ?? base.cacheWrite,\n\t\t\t},\n\t\t];\n\t});\n\treturn tiers && tiers.length > 0 ? { ...base, tiers } : base;\n}\n\n/** The efforts models.dev verified for a model, or undefined when it lists none. */\nfunction modelsDevEfforts(model: ModelsDevModel | undefined): Array<string | null> | undefined {\n\tconst efforts = model?.reasoning_options?.flatMap((option) =>\n\t\toption.type === \"effort\" && Array.isArray(option.values) ? option.values : [],\n\t);\n\treturn efforts && efforts.length > 0 ? efforts : undefined;\n}\n\nfunction mergeThinkingLevelMap(model: Model.Info, map: ThinkingLevelMap): void {\n\tmodel.thinkingLevelMap = { ...model.thinkingLevelMap, ...map };\n}\n\nfunction mergeCompat(model: Model.Info, compat: Model.Compatibility): void {\n\tmodel.compat = { ...model.compat, ...compat };\n}\n\n/** Merge the level map models.dev's verified efforts give, when it lists any. */\nfunction applyEffortThinkingLevels(model: Model.Info, source: ModelsDevModel | undefined): void {\n\tconst efforts = modelsDevEfforts(source);\n\tconst map = efforts ? Model.effortThinkingLevels(efforts) : undefined;\n\tif (map) mergeThinkingLevelMap(model, map);\n}\n\n//\n// OpenAI (pi).\nconst OPENAI_LONG_CONTEXT_INPUT_THRESHOLD = 272_000;\nconst OPENAI_MAX_TOKENS = 128_000;\n\nconst OPENAI_RESPONSES_NONE_REASONING_MODELS = new Set([\n\t\"gpt-5.1\",\n\t\"gpt-5.2\",\n\t\"gpt-5.3-codex\",\n\t\"gpt-5.4\",\n\t\"gpt-5.4-mini\",\n\t\"gpt-5.4-nano\",\n\t\"gpt-5.5\",\n\t\"gpt-5.6-luna\",\n\t\"gpt-5.6-sol\",\n\t\"gpt-5.6-terra\",\n\t\"gpt-6-luna\",\n\t\"gpt-6-sol\",\n]);\n\n// Every GPT-6 model takes low through max and rejects \"minimal\"; Astra and 6.1 Sol also reject \"none\".\nconst OPENAI_GPT6_MODELS = new Set([\"gpt-6-astra\", \"gpt-6-luna\", \"gpt-6-sol\", \"gpt-6.1-sol\"]);\nconst OPENAI_GPT6_NO_NONE_MODELS = new Set([\"gpt-6-astra\", \"gpt-6.1-sol\"]);\n\n// Checked live against the Responses and Codex APIs: these families reject\n// reasoning.effort \"minimal\".\nconst OPENAI_NO_MINIMAL_REASONING = /gpt-5\\.[456]|gpt-6/;\n\n// Direct requests stay in the short-context price tier by default; the long-context price stays in\n// `cost.tiers` for a settings entry that opts into the full window.\nconst OPENAI_SHORT_CONTEXT_CAPPED_MODELS = new Set([\n\t\"gpt-5.4\",\n\t\"gpt-5.5\",\n\t\"gpt-5.6-luna\",\n\t\"gpt-5.6-sol\",\n\t\"gpt-5.6-terra\",\n\t\"gpt-6-astra\",\n\t\"gpt-6-luna\",\n\t\"gpt-6-sol\",\n\t\"gpt-6.1-sol\",\n]);\n\n// Models billed at 2x input / 1.5x output above the threshold, when models.dev has no tier for them.\nconst OPENAI_LONG_CONTEXT_PRICING_MODELS = new Set([\n\t...OPENAI_SHORT_CONTEXT_CAPPED_MODELS,\n\t\"gpt-5.4-pro\",\n\t\"gpt-5.5-pro\",\n]);\n\nfunction isOpenAiResponses(model: Model.Info): boolean {\n\treturn model.protocol === Model.KnownProviderEnum.openai || model.protocol === Model.KnownProviderEnum.openaiCodex;\n}\n\nfunction isOpenAiDirect(model: Model.Info): boolean {\n\treturn model.protocol === Model.KnownProviderEnum.openai && model.provider.id === \"openai\";\n}\n\nfunction supportsOpenAiXhigh(model: Model.Info): boolean {\n\treturn /gpt-5\\.[2-6]|gpt-6/.test(model.id);\n}\n\nfunction supportsOpenAiMax(model: Model.Info): boolean {\n\treturn isOpenAiResponses(model) && /gpt-5\\.6|gpt-6/.test(model.id);\n}\n\nfunction withOpenAiLongContextPricing(cost: Model.Info[\"cost\"]): Model.Info[\"cost\"] {\n\treturn {\n\t\t...cost,\n\t\ttiers: [\n\t\t\t{\n\t\t\t\tinputTokensAbove: OPENAI_LONG_CONTEXT_INPUT_THRESHOLD,\n\t\t\t\tinput: roundCost(cost.input * 2),\n\t\t\t\toutput: roundCost(cost.output * 1.5),\n\t\t\t\tcacheRead: roundCost(cost.cacheRead * 2),\n\t\t\t\tcacheWrite: roundCost(cost.cacheWrite * 2),\n\t\t\t},\n\t\t],\n\t};\n}\n\n/**\n * Price multipliers per service tier: models.dev's modes that set `service_tier` (fast is\n * `priority`), over OpenAI's flex 0.5x / priority 2x list defaults.\n */\nfunction serviceTierMultipliers(model: Model.Info, source: ModelsDevModel | undefined): Record<string, number> {\n\tconst multipliers: Record<string, number> = { flex: 0.5, priority: 2 };\n\tfor (const mode of Object.values(source?.experimental?.modes ?? {})) {\n\t\tconst tier = mode.provider?.body?.service_tier;\n\t\tconst input = mode.cost?.input;\n\t\tif (typeof tier !== \"string\" || input === undefined || model.cost.input <= 0) continue;\n\t\tmultipliers[tier] = roundCost(input / model.cost.input);\n\t}\n\treturn multipliers;\n}\n\nfunction applyOpenAiMetadata(model: Model.Info, source: ModelsDevModel | undefined): void {\n\tconst id = model.id;\n\tif (isOpenAiDirect(model)) {\n\t\tif (OPENAI_SHORT_CONTEXT_CAPPED_MODELS.has(id)) {\n\t\t\tmodel.contextWindow = OPENAI_LONG_CONTEXT_INPUT_THRESHOLD;\n\t\t\tmodel.maxTokens = OPENAI_MAX_TOKENS;\n\t\t}\n\t\tif (OPENAI_LONG_CONTEXT_PRICING_MODELS.has(id) && !model.cost.tiers) {\n\t\t\tmodel.cost = withOpenAiLongContextPricing(model.cost);\n\t\t}\n\t\t// models.dev reports the input sub-limit as gpt-5-pro's output.\n\t\tif (id === \"gpt-5-pro\") model.maxTokens = OPENAI_MAX_TOKENS;\n\t}\n\tmodel.cost.serviceTierMultipliers = serviceTierMultipliers(model, source);\n\n\t// models.dev's verified efforts first, then the corrections checked against the API.\n\tapplyEffortThinkingLevels(model, source);\n\tif (model.protocol === Model.KnownProviderEnum.openai && id.startsWith(\"gpt-5\")) {\n\t\tmergeThinkingLevelMap(model, { off: null });\n\t}\n\tif (OPENAI_GPT6_MODELS.has(id)) {\n\t\tmergeThinkingLevelMap(model, {\n\t\t\toff: OPENAI_GPT6_NO_NONE_MODELS.has(id) ? null : \"none\",\n\t\t\tminimal: null,\n\t\t\tlow: \"low\",\n\t\t\tmedium: \"medium\",\n\t\t\thigh: \"high\",\n\t\t\txhigh: \"xhigh\",\n\t\t\tmax: \"max\",\n\t\t});\n\t}\n\tif (isOpenAiDirect(model) && OPENAI_RESPONSES_NONE_REASONING_MODELS.has(id)) {\n\t\tmergeThinkingLevelMap(model, { off: \"none\" });\n\t}\n\tif (supportsOpenAiMax(model)) mergeThinkingLevelMap(model, { max: \"max\" });\n\tif (OPENAI_NO_MINIMAL_REASONING.test(id)) mergeThinkingLevelMap(model, { minimal: null });\n\tif (id.endsWith(\"gpt-5.5-pro\")) mergeThinkingLevelMap(model, { off: null, minimal: null, low: null });\n}\n\n//\n// Anthropic (pi).\nfunction isAnthropicMessages(model: Model.Info): boolean {\n\treturn (\n\t\tmodel.protocol === Model.KnownProviderEnum.anthropic ||\n\t\tmodel.protocol === Model.KnownProviderEnum.googleVertexAnthropic\n\t);\n}\n\n// The Messages API rejects `temperature` on these.\nconst ANTHROPIC_NO_TEMPERATURE = /opus-4[-.][78]|opus-5|(sonnet|haiku)-5[-.]5/;\n\n// Checked live against the Messages API: effort levels each adaptive family\n// accepts, the 5.5 and Fable models that reject `thinking: {type: \"disabled\"}`, and\n// Sonnet 4.5's window, which is 1M only behind a beta header.\nfunction applyAnthropicMetadata(model: Model.Info): void {\n\tconst id = model.id;\n\tif (/sonnet-4[-.]5/.test(id)) model.contextWindow = 200_000;\n\t// Not models.dev's efforts: Anthropic disables thinking by a toggle, not an effort of \"none\" (pi).\n\tif (Model.isAnthropicAdaptiveThinkingModel(id)) mergeCompat(model, { forceAdaptiveThinking: true });\n\tif (/(opus|sonnet)-4[-.]6/.test(id)) {\n\t\tmergeThinkingLevelMap(model, { max: \"max\" });\n\t}\n\tif (/opus-4[-.][78]|(opus|sonnet|fable|haiku)-5/.test(id)) {\n\t\tmergeThinkingLevelMap(model, { xhigh: \"xhigh\", max: \"max\" });\n\t}\n\tif (/(opus|sonnet|haiku)-5[-.]5/.test(id)) {\n\t\t// Haiku 5.5 accepts disabled thinking; Opus 5.5 and Sonnet 5.5 reject it.\n\t\tmergeThinkingLevelMap(model, {\n\t\t\t...(id.includes(\"haiku\") ? {} : { off: null }),\n\t\t\tminimal: null,\n\t\t\tlow: \"low\",\n\t\t\tmedium: \"medium\",\n\t\t\thigh: \"high\",\n\t\t\txhigh: \"xhigh\",\n\t\t\tmax: \"max\",\n\t\t});\n\t}\n\tif (/fable-5/.test(id)) {\n\t\tmergeThinkingLevelMap(model, { off: null });\n\t}\n\tif (ANTHROPIC_NO_TEMPERATURE.test(id)) mergeCompat(model, { supportsTemperature: false });\n}\n\n//\n// Google.\nfunction applyGoogleThinkingMetadata(model: Model.Info): void {\n\tconst id = model.id.toLowerCase();\n\tconst supportsThinkingLevel =\n\t\t/gemini-3(?:\\.\\d+)?-(?:pro|flash)|gemma-?4/.test(id) ||\n\t\tid === \"gemini-flash-latest\" ||\n\t\tid === \"gemini-flash-lite-latest\";\n\tmergeCompat(model, { supportsThinkingLevel });\n\tif (supportsThinkingLevel) return;\n\n\t// Unknown budget-based families ask the provider to size thinking dynamically.\n\tconst defaults: Array<[string, Model.ThinkingBudgets]> = [\n\t\t[\"2.5-pro\", { minimal: 128, low: 2048, medium: 8192, high: 32768 }],\n\t\t[\"2.5-flash-lite\", { minimal: 512, low: 2048, medium: 8192, high: 24576 }],\n\t\t[\"2.5-flash\", { minimal: 128, low: 2048, medium: 8192, high: 24576 }],\n\t];\n\tmodel.thinkingBudgets = defaults.find(([family]) => id.includes(family))?.[1] ?? {\n\t\tminimal: -1,\n\t\tlow: -1,\n\t\tmedium: -1,\n\t\thigh: -1,\n\t};\n}\n\nfunction applyModelMetadata(model: Model.Info, source: ModelsDevModel | undefined): void {\n\tconst isGoogle =\n\t\tmodel.protocol === Model.KnownProviderEnum.google || model.protocol === Model.KnownProviderEnum.googleVertex;\n\tif (isGoogle) {\n\t\tapplyGoogleThinkingMetadata(model);\n\t\tif (/gemini-3(?:\\.\\d+)?-pro|gemini-3\\.[78]-flash/.test(model.id.toLowerCase())) {\n\t\t\t// These models cannot disable thinking or accept minimal. Expose supported\n\t\t\t// levels to callers and let the shared clamp promote minimal to low.\n\t\t\tmergeThinkingLevelMap(model, { off: \"low\", minimal: null });\n\t\t}\n\t}\n\t// Proxied Claude ids (Copilot) keep the effort aliases the Messages API takes.\n\tif (model.id.includes(\"opus-4-6\") || model.id.includes(\"opus-4.6\")) {\n\t\tmergeThinkingLevelMap(model, { xhigh: \"max\" });\n\t}\n\tif (model.id.includes(\"opus-4-7\") || model.id.includes(\"opus-4.7\")) {\n\t\tmergeThinkingLevelMap(model, { xhigh: \"xhigh\" });\n\t}\n\tif (isOpenAiResponses(model)) applyOpenAiMetadata(model, source);\n\t// By id, for every provider serving these GPT models (pi).\n\tif (supportsOpenAiXhigh(model)) mergeThinkingLevelMap(model, { xhigh: \"xhigh\" });\n\tif (isAnthropicMessages(model)) applyAnthropicMetadata(model);\n}\n\n//\n// OpenAI Codex (ChatGPT OAuth) models.\n// Built from the OpenAI entries: Codex serves the same models at the same list prices, so only\n// which models it offers, its window and its tool support are its own. Context windows are the\n// observed server limits (400s above them), not marketing numbers.\nconst OPENAI_CODEX_PROVIDER_ID = \"openai-codex\";\nconst OPENAI_CODEX_NPM = \"@codeworksh/ai-sdk-openai-codex\";\nconst OPENAI_CODEX_BASE_URL = \"https://chatgpt.com/backend-api\";\nconst OPENAI_CODEX_CONTEXT = 272_000;\nconst OPENAI_CODEX_MODELS: ReadonlyArray<{ readonly id: string; readonly contextWindow?: number }> = [\n\t{ id: \"gpt-5.3-codex-spark\", contextWindow: 128_000 },\n\t{ id: \"gpt-5.6-luna\" },\n\t{ id: \"gpt-5.6-sol\" },\n\t{ id: \"gpt-5.6-terra\" },\n\t{ id: \"gpt-6-astra\" },\n\t{ id: \"gpt-6-luna\" },\n\t{ id: \"gpt-6-sol\" },\n\t{ id: \"gpt-6.1-sol\", contextWindow: 500_000 },\n];\nconst OPENAI_CODEX_ADDITIONAL_TOOLS_MODEL_IDS = new Set([\n\t\"gpt-5.6-luna\",\n\t\"gpt-5.6-sol\",\n\t\"gpt-5.6-terra\",\n\t\"gpt-6-astra\",\n\t\"gpt-6-luna\",\n\t\"gpt-6-sol\",\n\t\"gpt-6.1-sol\",\n]);\n// Checked live: the Codex backend accepts reasoning.effort \"none\" for these.\nconst OPENAI_CODEX_NONE_REASONING_MODEL_IDS = new Set([\"gpt-5.6-luna\", \"gpt-6-luna\", \"gpt-6-sol\"]);\n\n/** The Codex models, from the generated `openai` entries; one models.dev does not list is skipped. */\nexport function openAICodexBuiltInModels(openai: Record<string, Model.Info>): Record<string, Model.Info> {\n\tconst models: Record<string, Model.Info> = {};\n\tfor (const seed of OPENAI_CODEX_MODELS) {\n\t\tconst base = openai[seed.id];\n\t\tif (!base) continue;\n\t\tconst info: Model.Info = {\n\t\t\t...base,\n\t\t\tprovider: {\n\t\t\t\tid: OPENAI_CODEX_PROVIDER_ID,\n\t\t\t\tname: \"OpenAI Codex (ChatGPT)\",\n\t\t\t\tsource: \"custom\",\n\t\t\t\tenv: [\"OPENAI_CODEX_API_KEY\"],\n\t\t\t},\n\t\t\tbaseUrl: OPENAI_CODEX_BASE_URL,\n\t\t\treasoning: true,\n\t\t\tthinkingLevelMap: {\n\t\t\t\t...base.thinkingLevelMap,\n\t\t\t\t// Codex models reason unless verified to accept \"none\".\n\t\t\t\toff: OPENAI_CODEX_NONE_REASONING_MODEL_IDS.has(seed.id) ? \"none\" : null,\n\t\t\t\t// The backend takes \"low\" where the API would reject \"minimal\" (pi).\n\t\t\t\t...(supportsOpenAiXhigh(base) ? { minimal: \"low\" } : {}),\n\t\t\t},\n\t\t\tcontextWindow: seed.contextWindow ?? OPENAI_CODEX_CONTEXT,\n\t\t\tmaxTokens: OPENAI_MAX_TOKENS,\n\t\t\tnpm: OPENAI_CODEX_NPM,\n\t\t\tapi: {\n\t\t\t\tid: seed.id,\n\t\t\t\turl: OPENAI_CODEX_BASE_URL,\n\t\t\t\tmethod: Model.APIMethodEnum.responses,\n\t\t\t},\n\t\t\tproviderOptionsKey: OPENAI_CODEX_PROVIDER_ID,\n\t\t\tcompat: {\n\t\t\t\tsupportsOpenAIGrammarTools: true,\n\t\t\t\t...(OPENAI_CODEX_ADDITIONAL_TOOLS_MODEL_IDS.has(seed.id)\n\t\t\t\t\t? { supportsToolSearch: true, supportsAdditionalTools: true }\n\t\t\t\t\t: {}),\n\t\t\t},\n\t\t\tprotocol: Model.KnownProviderEnum.openaiCodex,\n\t\t};\n\t\tdelete info.headers;\n\t\tmodels[seed.id] = info;\n\t}\n\treturn models;\n}\n\n//\n// GitHub Copilot models.\n// Sourced from models.dev, then rewritten onto the bundled provider: one\n// `github-copilot` protocol whose `api.method` selects between Chat\n// Completions, Responses, and Anthropic Messages.\nconst GITHUB_COPILOT_PROVIDER_ID = \"github-copilot\";\nconst GITHUB_COPILOT_NPM = \"@codeworksh/ai-sdk-github-copilot\";\nconst GITHUB_COPILOT_BASE_URL = \"https://api.githubcopilot.com\";\nconst GITHUB_COPILOT_EXTENDED_CONTEXT = 1_000_000;\n\n// GitHub's \"Models with extended capabilities\" table lists these Copilot\n// models as supporting the extended 1 million token context window (pi).\nconst GITHUB_COPILOT_EXTENDED_CONTEXT_MODELS = new Set([\n\t\"claude-fable-5\",\n\t\"claude-opus-4.6\",\n\t\"claude-opus-4.7\",\n\t\"claude-opus-4.8\",\n\t\"claude-opus-5\",\n\t\"claude-sonnet-4.6\",\n\t\"claude-sonnet-5\",\n\t\"gpt-5.3-codex\",\n\t\"gpt-5.4\",\n\t\"gpt-5.5\",\n]);\n\n// Checked manually against the authenticated GitHub Copilot /models endpoint\n// (pi). Narrow corrections over models.dev metadata, not a catalog snapshot.\nconst GITHUB_COPILOT_THINKING_LEVEL_OVERRIDES: Record<string, ThinkingLevelMap> = {\n\t\"claude-opus-4.7\": { minimal: \"low\" },\n\t\"claude-opus-4.8\": { minimal: \"low\" },\n\t\"claude-opus-5\": { minimal: \"low\" },\n\t\"claude-sonnet-4.6\": { minimal: \"low\", max: \"max\" },\n};\n\n/**\n * The offline routing approximation (pi). The live `/models` response's\n * `supported_endpoints` is authoritative at runtime.\n *\n * - `claude-(haiku|sonnet|opus|fable)-[45]` → Anthropic Messages\n * - `gpt-*`, `grok-*`, `oswe*`, `mai-*` → OpenAI Responses\n * - everything else → OpenAI Chat Completions\n */\nexport function githubCopilotApiMethod(modelId: string): Model.APIMethodEnum {\n\tif (/^claude-(haiku|sonnet|opus|fable)-[45]([.-]|$)/.test(modelId)) {\n\t\treturn Model.APIMethodEnum.messages;\n\t}\n\tconst gpt = /^gpt-(\\d+)/.exec(modelId);\n\tif (\n\t\t(gpt !== null && Number(gpt[1]) >= 5) ||\n\t\tmodelId.startsWith(\"grok-\") ||\n\t\tmodelId.startsWith(\"oswe\") ||\n\t\tmodelId.startsWith(\"mai-\")\n\t) {\n\t\treturn Model.APIMethodEnum.responses;\n\t}\n\treturn Model.APIMethodEnum.chat;\n}\n\n/**\n * Derive the level map from models.dev `reasoning_options`: a level maps to\n * itself only when the endpoint actually advertises it. `minimal` degrades to\n * `low` — the lowest effort every reasoning model accepts.\n */\nfunction githubCopilotThinkingLevels(model: ModelsDevModel, method: Model.APIMethodEnum): ThinkingLevelMap | undefined {\n\tconst listed = modelsDevEfforts(model);\n\tconst efforts = listed ? new Set(listed) : undefined;\n\tconst map: ThinkingLevelMap = {};\n\t// Copilot rejects `reasoningEffort: \"none\"` (pi), and the chat route has no\n\t// reasoning control, so only Messages models can disable thinking.\n\tif (method !== Model.APIMethodEnum.messages) map.off = null;\n\tif (!efforts) return Object.keys(map).length > 0 ? map : undefined;\n\n\tif (efforts.has(\"minimal\")) map.minimal = \"minimal\";\n\telse if (efforts.has(\"low\")) map.minimal = \"low\";\n\tfor (const level of [\"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const) {\n\t\tmap[level] = efforts.has(level) ? level : null;\n\t}\n\treturn map;\n}\n\nexport function githubCopilotBuiltInModels(provider: ModelsDevProvider | undefined): Record<string, Model.Info> {\n\tconst models: Record<string, Model.Info> = {};\n\tif (!provider) return models;\n\tfor (const [id, source] of Object.entries(provider.models)) {\n\t\tif (source.tool_call !== true) continue;\n\t\tif (source.status === \"deprecated\") continue;\n\t\t// The chat-latest alias races the Responses route for gpt-5 models.\n\t\tif (id === \"gpt-5-chat-latest\") continue;\n\n\t\tconst base = applyModification(GITHUB_COPILOT_PROVIDER_ID, provider, source);\n\t\tif (!base) continue;\n\n\t\tconst method = githubCopilotApiMethod(id);\n\t\tconst info: Model.Info = {\n\t\t\t...base,\n\t\t\tprovider: {\n\t\t\t\tid: GITHUB_COPILOT_PROVIDER_ID,\n\t\t\t\tname: \"GitHub Copilot\",\n\t\t\t\tsource: \"custom\",\n\t\t\t\tenv: [\"COPILOT_GITHUB_TOKEN\"],\n\t\t\t},\n\t\t\tbaseUrl: GITHUB_COPILOT_BASE_URL,\n\t\t\theaders: { ...GITHUB_COPILOT_STATIC_HEADERS },\n\t\t\tnpm: GITHUB_COPILOT_NPM,\n\t\t\tapi: { id, url: GITHUB_COPILOT_BASE_URL, method },\n\t\t\tproviderOptionsKey: GITHUB_COPILOT_PROVIDER_ID,\n\t\t\tprotocol: Model.KnownProviderEnum.githubCopilot,\n\t\t\t// Copilot's Responses route requires store=false + encrypted reasoning\n\t\t\t// content for thinking to round-trip.\n\t\t\t...(method === Model.APIMethodEnum.responses\n\t\t\t\t? {\n\t\t\t\t\t\tproviderOptions: {\n\t\t\t\t\t\t\t...base.providerOptions,\n\t\t\t\t\t\t\t[GITHUB_COPILOT_PROVIDER_ID]: {\n\t\t\t\t\t\t\t\tstore: false,\n\t\t\t\t\t\t\t\tinclude: [\"reasoning.encrypted_content\"],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t};\n\n\t\tif (GITHUB_COPILOT_EXTENDED_CONTEXT_MODELS.has(id)) info.contextWindow = GITHUB_COPILOT_EXTENDED_CONTEXT;\n\t\tif (method === Model.APIMethodEnum.messages && Model.isAnthropicAdaptiveThinkingModel(id)) {\n\t\t\tmergeCompat(info, { forceAdaptiveThinking: true });\n\t\t}\n\t\t// Copilot's Responses endpoint passes OpenAI custom grammar tools through\n\t\t// for GPT-5+ (verified by pi).\n\t\tconst gpt = /^gpt-(\\d+)/.exec(id);\n\t\tif (method === Model.APIMethodEnum.responses && gpt !== null && Number(gpt[1]) >= 5) {\n\t\t\tmergeCompat(info, { supportsOpenAIGrammarTools: true });\n\t\t}\n\t\tif (id.startsWith(\"gpt-5\")) mergeThinkingLevelMap(info, { off: null, minimal: \"low\" });\n\t\tif (id.includes(\"fable-5\")) mergeThinkingLevelMap(info, { off: null, xhigh: \"xhigh\", max: \"max\" });\n\n\t\tconst levels = githubCopilotThinkingLevels(source, method);\n\t\tif (levels) mergeThinkingLevelMap(info, levels);\n\t\tconst override = GITHUB_COPILOT_THINKING_LEVEL_OVERRIDES[id];\n\t\tif (override) mergeThinkingLevelMap(info, override);\n\n\t\tmodels[id] = info;\n\t}\n\treturn models;\n}\n\n/** OpenRouter's listing as catalog entries, or undefined when it is missing or unreadable. */\nfunction openRouterModels(listing: unknown): Record<string, Model.Info> | undefined {\n\tif (listing === undefined) return undefined;\n\ttry {\n\t\tconst models = OpenRouter.catalog(listing);\n\t\treturn Object.keys(models).length > 0 ? models : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** Object keys in order at every level, so identical content serializes to identical bytes. */\nfunction sortKeys(value: unknown): unknown {\n\tif (Array.isArray(value)) return value.map(sortKeys);\n\tif (typeof value !== \"object\" || value === null) return value;\n\treturn Object.fromEntries(\n\t\tObject.entries(value)\n\t\t\t.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n\t\t\t.map(([key, entry]) => [key, sortKeys(entry)]),\n\t);\n}\n\n/**\n * The catalog from fetched sources, keys sorted so identical content serializes to identical\n * bytes. OpenRouter's own listing replaces models.dev's copy of it.\n */\nexport function buildCatalog(sources: Sources): BuiltInModels {\n\tconst modelsDev = loadBuiltInFromModelsDev(sources.modelsDev);\n\tconst openrouter = openRouterModels(sources.openRouter);\n\tconst copilotProvider = sources.modelsDev[GITHUB_COPILOT_PROVIDER_ID];\n\treturn sortKeys({\n\t\t...modelsDev,\n\t\t...(openrouter ? { [OpenRouter.PROVIDER_ID]: openrouter } : {}),\n\t\t[OPENAI_CODEX_PROVIDER_ID]: openAICodexBuiltInModels(modelsDev.openai ?? {}),\n\t\t...(copilotProvider ? { [GITHUB_COPILOT_PROVIDER_ID]: githubCopilotBuiltInModels(copilotProvider) } : {}),\n\t}) as BuiltInModels;\n}\n\nexport interface GenerateOptions {\n\t/** Output file; defaults to `CODEWORK_MODELS_FILE` or `./models.gen.json`. */\n\treadonly path?: string | undefined;\n\t/** Keep only {@link BASELINE_PROVIDERS}, for the catalog bundled with aikit. */\n\treadonly baseline?: boolean | undefined;\n}\n\nexport async function generateModels(args: GenerateOptions = {}): Promise<string> {\n\tconst path = resolve(args.path ?? ModelCatalog.path());\n\tconst [modelsDev, openRouter] = await Promise.all([pullModelsDevData(), pullOpenRouterData()]);\n\tconst catalog = buildCatalog({ modelsDev, openRouter });\n\tawait Filesystem.writeJsonAtomic(path, args.baseline ? pick(catalog, BASELINE_PROVIDERS) : catalog);\n\treturn path;\n}\n\n//\n// CLI entry\nexport const ModelgenCommand: CommandModule<object, { path?: string | undefined; baseline?: boolean | undefined }> = {\n\tcommand: \"modelgen [path]\",\n\tdescribe: \"generate models.gen.json\",\n\tbuilder: (yargs) =>\n\t\tyargs\n\t\t\t.positional(\"path\", {\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescribe: \"output path (defaults to CODEWORK_MODELS_FILE or ./models.gen.json)\",\n\t\t\t})\n\t\t\t.option(\"baseline\", {\n\t\t\t\ttype: \"boolean\",\n\t\t\t\tdescribe: `keep only the bundled baseline providers (${BASELINE_PROVIDERS.join(\", \")})`,\n\t\t\t}),\n\thandler: async (args) => {\n\t\tconst path = await generateModels(args);\n\t\tconsole.log(`Generated model catalog at ${path}`);\n\t},\n};\n\nexport function applyModification(\n\tproviderId: string,\n\tprovider: ModelsDevProvider,\n\tmodel: ModelsDevModel,\n): Model.Info | undefined {\n\tconst npm = resolveModelNpm(provider, model);\n\tif (!isAISDKPackage(npm)) return;\n\n\tconst protocol = protocolForPackage(npm);\n\tconst baseUrl = resolveModelBaseUrl(provider, model);\n\tconst providerInfo: Model.ProviderInfo = {\n\t\tid: providerId,\n\t\tname: provider.name,\n\t\tsource: \"api\",\n\t\tenv: provider.env,\n\t};\n\tif (provider.key) providerInfo.key = provider.key;\n\tconst api: Model.APIMetadata = {\n\t\tid: model.id,\n\t\tmethod: resolveModelAPIMethod(npm),\n\t};\n\tif (baseUrl) api.url = baseUrl;\n\n\tconst info: Model.Info = {\n\t\tid: model.id,\n\t\tname: model.name,\n\t\tprovider: providerInfo,\n\t\tbaseUrl,\n\t\treasoning: Boolean(model.reasoning),\n\t\tinput: Model.normalizeInput(model.modalities.input),\n\t\tcost: modelsDevCost(model.cost),\n\t\tcontextWindow: model.limit?.context ?? 4096,\n\t\tmaxTokens: model.limit?.output ?? 4096,\n\t\theaders: {\n\t\t\t...provider.headers,\n\t\t\t...model.provider?.headers,\n\t\t\t...model.headers,\n\t\t},\n\t\tnpm,\n\t\tapi,\n\t\tproviderOptionsKey: resolveProviderOptionsKey(protocol),\n\t\tprotocol,\n\t};\n\tif (Object.keys(info.headers ?? {}).length === 0) delete info.headers;\n\tapplyModelMetadata(info, model);\n\treturn info;\n}\n"],"mappings":";;;;;;AAUA,MAAa,cAAc;AAC3B,MAAa,WAAW;AACxB,MAAM,MAAM;AACZ,MAAM,yBAAyB;;;;;AAwC/B,SAAS,WAAW,OAA2B,UAA0B;CACxE,MAAM,WAAW,OAAO,WAAW,SAAS,EAAE;CAC9C,OAAO,YAAY,IAAI,QAAQ,WAAW,IAAA,CAAW,QAAQ,CAAC,CAAC,IAAI;AACpE;;;;;AAMA,SAAgB,KAAK,SAAkD;CACtE,MAAM,OAAO;EACZ,OAAO,WAAW,SAAS,QAAQ,CAAC;EACpC,QAAQ,WAAW,SAAS,YAAY,CAAC;EACzC,WAAW,WAAW,SAAS,kBAAkB,CAAC;EAClD,YAAY,WAAW,SAAS,mBAAmB,CAAC;CACrD;CACA,MAAM,SAAS,SAAS,aAAa,CAAC,EAAA,CAAG,SAAS,aAAa;EAC9D,IACC,SAAS,sBAAsB,KAAA,KAC/B,SAAS,cAAc,KAAA,KACvB,SAAS,YAAY,KAAA,KACrB,SAAS,aAAa,KAAA,GAEtB,OAAO,CAAC;EAET,OAAO,CACN;GACC,kBAAkB,SAAS;GAC3B,OAAO,WAAW,SAAS,QAAQ,KAAK,KAAK;GAC7C,QAAQ,WAAW,SAAS,YAAY,KAAK,MAAM;GACnD,WAAW,WAAW,SAAS,kBAAkB,KAAK,SAAS;GAC/D,YAAY,WAAW,SAAS,mBAAmB,K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MAAM,OAAmB;EACxB,IAAI,MAAM;EACV,MAAM,MAAM;EACZ,UAAU;EACV;EACA,WAAW,QAAQ,MAAM,SAAS;EAClC,OAAOG,eAAqB,MAAM,WAAW,KAAK;EAClD,MAAM,cAAc,MAAM,IAAI;EAC9B,eAAe,MAAM,OAAO,WAAW;EACvC,WAAW,MAAM,OAAO,UAAU;EAClC,SAAS;GACR,GAAG,SAAS;GACZ,GAAG,MAAM,UAAU;GACnB,GAAG,MAAM;EACV;EACA;EACA;EACA,oBAAoB,0BAA0B,QAAQ;EACtD;CACD;CACA,IAAI,OAAO,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,GAAG,OAAO,KAAK;CAC9D,mBAAmB,MAAM,KAAK;CAC9B,OAAO;AACR"}
|
package/modelgen.mjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { T as writeJsonAtomic, i as KnownProviderEnum, t as APIMethodEnum, w as writeAtomic } from "./model-Cjp-Dr8V.mjs";
|
|
2
|
-
import { i as personalize, n as generateModels, r as PROVIDER_ID } from "./modelgen-
|
|
2
|
+
import { i as personalize, n as generateModels, r as PROVIDER_ID } from "./modelgen-BdiCqi-R.mjs";
|
|
3
3
|
import { dirname, join, resolve } from "node:path";
|
|
4
4
|
import { createHash } from "node:crypto";
|
|
5
5
|
import { readFile } from "node:fs/promises";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@codeworksh/aikit",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.12.0-canary.47.1.g3f60acd1",
|
|
4
4
|
"description": "TypeScript SDK that provides a unified API for working with multiple LLM providers, automatic model discovery, and more.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"agent",
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"modelgen-DDO_NHoQ.mjs","names":["Model.effortThinkingLevels","Model.normalizeInput","OpenRouter.BASE_URL","OpenRouter.PROVIDER_ID","Filesystem.readJson","Model.effortThinkingLevels","Model.isAnthropicAdaptiveThinkingModel","OpenRouter.catalog","path","ModelCatalog.path","Filesystem.writeJsonAtomic","Model.normalizeInput"],"sources":["../../src/model/openrouter.ts","../../src/cli/modelgen.ts"],"sourcesContent":["/*\n * @file OpenRouter's own model listing, read two ways.\n *\n * The generator builds the `openrouter` catalog from the public `GET /models` (pi): it carries\n * the reasoning efforts each model accepts, which models.dev only covers for some. At runtime\n * `GET /models/user` narrows that catalog to what one key may use, with that key's limits and\n * prices. Both go through the same field readers.\n */\nimport * as Model from \"./model.ts\";\n\nexport const PROVIDER_ID = \"openrouter\";\nexport const BASE_URL = \"https://openrouter.ai/api/v1\";\nconst NPM = \"@openrouter/ai-sdk-provider\";\nconst USER_MODELS_TIMEOUT_MS = 15_000;\n\n/** OpenRouter's per-token prices, as decimal strings. */\ninterface Pricing {\n\tprompt?: string;\n\tcompletion?: string;\n\tinput_cache_read?: string;\n\tinput_cache_write?: string;\n\t/** Conditional prices: `min_prompt_tokens` selects prompt-length pricing, `utc_*` time-of-day pricing. */\n\toverrides?: Array<{\n\t\tmin_prompt_tokens?: number;\n\t\tutc_start?: number;\n\t\tutc_end?: number;\n\t\tutc_days?: string[];\n\t\tprompt?: string;\n\t\tcompletion?: string;\n\t\tinput_cache_read?: string;\n\t\tinput_cache_write?: string;\n\t}>;\n}\n\n/** The fields read from an entry of `GET /models` and `GET /models/user`. */\nexport interface Entry {\n\tid: string;\n\tname?: string;\n\tcontext_length?: number | null;\n\ttop_provider?: { context_length?: number | null; max_completion_tokens?: number | null };\n\tpricing?: Pricing;\n\tsupported_parameters?: string[];\n\tarchitecture?: { input_modalities?: string[] };\n\treasoning?: {\n\t\tmandatory?: boolean;\n\t\tsupported_efforts?: string[];\n\t} | null;\n}\n\n/**\n * $/token to $/1M tokens. Missing, invalid and negative prices use the fallback: OpenRouter\n * reports -1 for router models such as `openrouter/auto`, whose price depends on the model it picks.\n */\nfunction perMillion(value: string | undefined, fallback: number): number {\n\tconst perToken = Number.parseFloat(value ?? \"\");\n\treturn perToken >= 0 ? Number((perToken * 1_000_000).toFixed(6)) : fallback;\n}\n\n/**\n * Prompt-length overrides become request-wide tiers; a rate a tier does not list keeps the base\n * price. Time-of-day overrides are skipped: the cost model cannot express them.\n */\nexport function cost(pricing: Pricing | undefined): Model.Info[\"cost\"] {\n\tconst base = {\n\t\tinput: perMillion(pricing?.prompt, 0),\n\t\toutput: perMillion(pricing?.completion, 0),\n\t\tcacheRead: perMillion(pricing?.input_cache_read, 0),\n\t\tcacheWrite: perMillion(pricing?.input_cache_write, 0),\n\t};\n\tconst tiers = (pricing?.overrides ?? []).flatMap((override) => {\n\t\tif (\n\t\t\toverride.min_prompt_tokens === undefined ||\n\t\t\toverride.utc_start !== undefined ||\n\t\t\toverride.utc_end !== undefined ||\n\t\t\toverride.utc_days !== undefined\n\t\t) {\n\t\t\treturn [];\n\t\t}\n\t\treturn [\n\t\t\t{\n\t\t\t\tinputTokensAbove: override.min_prompt_tokens,\n\t\t\t\tinput: perMillion(override.prompt, base.input),\n\t\t\t\toutput: perMillion(override.completion, base.output),\n\t\t\t\tcacheRead: perMillion(override.input_cache_read, base.cacheRead),\n\t\t\t\tcacheWrite: perMillion(override.input_cache_write, base.cacheWrite),\n\t\t\t},\n\t\t];\n\t});\n\treturn tiers.length > 0 ? { ...base, tiers } : base;\n}\n\n/**\n * `supported_efforts` uses models.dev's effort vocabulary. Off maps to `none` unless reasoning is\n * mandatory; a mandatory model without listed efforts can only refuse off.\n */\nexport function thinkingLevels(reasoning: Entry[\"reasoning\"]): Model.ThinkingLevelMap | undefined {\n\tif (!reasoning) return undefined;\n\tconst map = Model.effortThinkingLevels(reasoning.supported_efforts ?? []);\n\tif (!map) return reasoning.mandatory === true ? { off: null } : undefined;\n\treturn { ...map, off: reasoning.mandatory === true ? null : \"none\" };\n}\n\n/**\n * The catalog entry for one listed model, or undefined for one an agent cannot use: no tool\n * calling, or a `:batch` variant, whose asynchronous pricing an interactive turn never gets.\n */\nexport function toModel(entry: Entry): Model.Info | undefined {\n\tif (!entry.supported_parameters?.includes(\"tools\") || entry.id.endsWith(\":batch\")) return undefined;\n\tconst thinkingLevelMap = thinkingLevels(entry.reasoning);\n\treturn {\n\t\tid: entry.id,\n\t\tname: entry.name ?? entry.id,\n\t\tprovider: { id: PROVIDER_ID, name: \"OpenRouter\", source: \"api\", env: [\"OPENROUTER_API_KEY\"] },\n\t\tbaseUrl: BASE_URL,\n\t\treasoning: entry.supported_parameters.includes(\"reasoning\"),\n\t\t...(thinkingLevelMap ? { thinkingLevelMap } : {}),\n\t\tinput: Model.normalizeInput(entry.architecture?.input_modalities),\n\t\tcost: cost(entry.pricing),\n\t\t// `||`: OpenRouter reports a missing limit as absent, null or 0.\n\t\tcontextWindow: entry.top_provider?.context_length || entry.context_length || 4096,\n\t\tmaxTokens: entry.top_provider?.max_completion_tokens || 4096,\n\t\tnpm: NPM,\n\t\tapi: { id: entry.id, url: BASE_URL, method: Model.APIMethodEnum.languageModel },\n\t\tproviderOptionsKey: PROVIDER_ID,\n\t\tprotocol: Model.KnownProviderEnum.openrouter,\n\t};\n}\n\nfunction entries(body: unknown): Entry[] {\n\tif (typeof body !== \"object\" || body === null || !(\"data\" in body) || !Array.isArray(body.data)) {\n\t\tthrow new Error(\"invalid OpenRouter model list\");\n\t}\n\treturn body.data.filter(\n\t\t(entry: unknown): entry is Entry =>\n\t\t\ttypeof entry === \"object\" && entry !== null && \"id\" in entry && typeof entry.id === \"string\",\n\t);\n}\n\n/** The public `GET /models`, built into catalog entries keyed by id. */\nexport function catalog(body: unknown): Record<string, Model.Info> {\n\tconst models: Record<string, Model.Info> = {};\n\tfor (const entry of entries(body)) {\n\t\tconst model = toModel(entry);\n\t\tif (model) models[model.id] = model;\n\t}\n\treturn models;\n}\n\n/**\n * Restrict OpenRouter models to those `key` may use, with the key's limits and prices from\n * `GET /models/user` (pi). A missing limit keeps the catalog value. When the endpoint rejects the\n * key (401/403) or does not exist (404), or allows nothing, the models come back unchanged.\n */\nexport async function personalize(\n\tmodels: Record<string, Model.Info>,\n\tkey: string,\n\toptions: { readonly baseUrl?: string; readonly signal?: AbortSignal } = {},\n): Promise<Record<string, Model.Info>> {\n\tconst signal = AbortSignal.timeout(USER_MODELS_TIMEOUT_MS);\n\tconst response = await fetch(`${(options.baseUrl ?? BASE_URL).replace(/\\/+$/, \"\")}/models/user`, {\n\t\theaders: { accept: \"application/json\", authorization: `Bearer ${key}` },\n\t\tsignal: options.signal ? AbortSignal.any([options.signal, signal]) : signal,\n\t});\n\tif (response.status === 401 || response.status === 403 || response.status === 404) return models;\n\tif (!response.ok) throw new Error(`OpenRouter model list request failed: ${response.status}`);\n\tconst allowed = new Map(entries(await response.json()).map((entry) => [entry.id, entry]));\n\n\tconst personal: Record<string, Model.Info> = {};\n\tfor (const [id, model] of Object.entries(models)) {\n\t\tconst entry = allowed.get(id);\n\t\tif (!entry) continue;\n\t\tpersonal[id] = {\n\t\t\t...model,\n\t\t\tcontextWindow: entry.top_provider?.context_length || entry.context_length || model.contextWindow,\n\t\t\tmaxTokens: entry.top_provider?.max_completion_tokens || model.maxTokens,\n\t\t\tcost: entry.pricing ? cost(entry.pricing) : model.cost,\n\t\t};\n\t}\n\treturn Object.keys(personal).length > 0 ? personal : models;\n}\n\nexport * as OpenRouter from \"./openrouter.ts\";\n","import { resolve } from \"node:path\";\nimport { mapValues, pick, pickBy, pipe } from \"remeda\";\nimport type { CommandModule } from \"yargs\";\nimport { DEFAULT_AI_SDK_FALLBACK, isAISDKPackage, protocolForPackage } from \"../llm/registry.ts\";\nimport * as ModelCatalog from \"../model/catalog.ts\";\nimport * as Model from \"../model/model.ts\";\nimport { OpenRouter } from \"../model/openrouter.ts\";\nimport { GITHUB_COPILOT_STATIC_HEADERS } from \"../providers/github-copilot/copilot-headers.ts\";\nimport * as Filesystem from \"../utils/filesystem.ts\";\n\nconst DEFAULT_PROVIDER_BASE_URLS: Partial<Record<Model.KnownProviderEnum, string>> = {\n\t[Model.KnownProviderEnum.anthropic]: \"https://api.anthropic.com/v1\",\n\t[Model.KnownProviderEnum.openai]: \"https://api.openai.com/v1\",\n\t[Model.KnownProviderEnum.openrouter]: OpenRouter.BASE_URL,\n\t[Model.KnownProviderEnum.xai]: \"https://api.x.ai/v1\",\n};\n\ninterface ModelsDevCost {\n\tinput?: number;\n\toutput?: number;\n\tcache_read?: number;\n\tcache_write?: number;\n}\n\ninterface ModelsDevModel {\n\tid: string;\n\tname: string;\n\tfamily: string;\n\tattachment: boolean;\n\treasoning?: boolean;\n\ttool_call?: boolean;\n\ttemperature?: boolean;\n\tknowledge?: string | boolean;\n\trelease_date: string;\n\tlast_updated: string;\n\tmodalities: {\n\t\tinput?: string[];\n\t\toutput: string[];\n\t};\n\topen_weights: boolean;\n\tbaseUrl?: string;\n\theaders?: Record<string, string>;\n\tcost?: ModelsDevCost & {\n\t\ttiers?: Array<ModelsDevCost & { tier?: { type?: string; size?: number } }>;\n\t};\n\treasoning_options?: Array<{\n\t\ttype?: string;\n\t\tvalues?: Array<string | null>;\n\t\tmin?: number;\n\t\tmax?: number;\n\t}>;\n\tstatus?: string;\n\tlimit?: {\n\t\tcontext?: number;\n\t\toutput?: number;\n\t};\n\tstructured_output?: boolean;\n\tprovider?: {\n\t\tnpm?: string;\n\t\tapi?: string;\n\t\theaders?: Record<string, string>;\n\t};\n\t/** Request variants such as OpenAI's `service_tier: \"priority\"`, each with its own price. */\n\texperimental?: {\n\t\tmodes?: Record<string, { cost?: ModelsDevCost; provider?: { body?: Record<string, unknown> } }>;\n\t};\n}\n\ninterface ModelsDevProvider {\n\tid: string;\n\tenv: string[];\n\tnpm?: string;\n\tapi?: string;\n\tname: string;\n\tdoc?: string; // reference documentation link\n\tkey?: string; // runtime placeholder for api/oauth key\n\theaders?: Record<string, string>; // custom overrides at provider level\n\tmodels: Record<string, ModelsDevModel>;\n}\n\nexport type BuiltInModels = Model.BuiltInModels;\n\n// Doesn't represent the full spec from models.dev.\n// Represents the provider entries on a best-effort basis.\ntype ModelsDevCatalog = Record<string, ModelsDevProvider>;\n\n/** The catalog's sources, fetched: models.dev, and OpenRouter's own listing when it answered. */\nexport interface Sources {\n\treadonly modelsDev: ModelsDevCatalog;\n\treadonly openRouter?: unknown;\n}\n\n/** Providers bundled with aikit as the baseline catalog, read until a generated one exists. */\nexport const BASELINE_PROVIDERS = [\"anthropic\", \"openai\", OpenRouter.PROVIDER_ID] as const;\n\nfunction modelsDevURL(): string {\n\treturn process.env.CODEWORK_MODELS_DEV_URL || \"https://models.dev\";\n}\n\nfunction modelsDevPath(): string | undefined {\n\treturn process.env.CODEWORK_MODELS_DEV_FILE;\n}\n\nasync function pullModelsDevData(): Promise<ModelsDevCatalog> {\n\tconst path = modelsDevPath();\n\tif (path) {\n\t\tconst result = await Filesystem.readJson<ModelsDevCatalog>(path).catch(() => undefined);\n\t\tif (result) return result;\n\t}\n\n\tconst response = await fetch(`${modelsDevURL()}/api.json`);\n\tif (!response.ok) throw new Error(`models.dev responded ${response.status} ${response.statusText}`);\n\treturn (await response.json()) as ModelsDevCatalog;\n}\n\n/** OpenRouter's public listing, or undefined when it cannot be had: models.dev's copy stands in. */\nasync function pullOpenRouterData(): Promise<unknown> {\n\ttry {\n\t\tconst response = await fetch(`${OpenRouter.BASE_URL}/models`, { signal: AbortSignal.timeout(30_000) });\n\t\treturn response.ok ? await response.json() : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\nfunction toModelValue(providerId: string, provider: ModelsDevProvider, model: ModelsDevModel): Model.Info | undefined {\n\treturn applyModification(providerId, provider, model);\n}\n\n// models.dev lists this alias, but OpenAI's APIs do not accept it (pi).\nconst MODELS_DEV_UNSUPPORTED_MODEL_IDS = new Set([\"openai/gpt-5.6\"]);\n\nfunction usable(providerId: string, provider: ModelsDevProvider, model: ModelsDevModel): boolean {\n\treturn (\n\t\tBoolean(model.tool_call) &&\n\t\t!MODELS_DEV_UNSUPPORTED_MODEL_IDS.has(`${providerId}/${model.id}`) &&\n\t\t// If `resolveModelNpm` fallbacks to `@ai-sdk/openai-compatible`\n\t\t// isAISDKPakage will be truthy, modify resolveModelNpm for custom logic if needed.\n\t\t// Keep `isAISDKPackage` as readonly for supported implemenatations key check\n\t\tisAISDKPackage(resolveModelNpm(provider, model))\n\t);\n}\n\nfunction loadBuiltInFromModelsDev(catalog: ModelsDevCatalog) {\n\treturn pipe(\n\t\tcatalog,\n\t\tpickBy((provider, providerId) =>\n\t\t\tObject.values(provider.models).some((model) => usable(providerId, provider, model)),\n\t\t),\n\t\tmapValues((provider, providerId) =>\n\t\t\tpipe(\n\t\t\t\tprovider.models,\n\t\t\t\tpickBy((model) => usable(providerId, provider, model)),\n\t\t\t\tmapValues((model) => toModelValue(providerId, provider, model)),\n\t\t\t\tpickBy((model): model is Model.Info => model !== undefined),\n\t\t\t),\n\t\t),\n\t) as BuiltInModels;\n}\n\ntype ThinkingLevelMap = NonNullable<Model.Info[\"thinkingLevelMap\"]>;\n\nfunction resolveModelNpm(provider: ModelsDevProvider, model: ModelsDevModel): string {\n\treturn model.provider?.npm ?? provider.npm ?? DEFAULT_AI_SDK_FALLBACK;\n}\n\nfunction resolveModelBaseUrl(provider: ModelsDevProvider, model: ModelsDevModel): string {\n\tconst npm = resolveModelNpm(provider, model);\n\tconst protocol = protocolForPackage(npm);\n\treturn model.baseUrl ?? model.provider?.api ?? provider.api ?? DEFAULT_PROVIDER_BASE_URLS[protocol] ?? \"\";\n}\n\nfunction resolveModelAPIMethod(npm: string): Model.APIMethodEnum {\n\tconst protocol = protocolForPackage(npm);\n\t// `By default, xai(modelId) uses the Chat API.\n\t// To use the Responses API with server-side agentic tools, explicitly use xai.responses(modelId).`\n\t// References: https://ai-sdk.dev/providers/ai-sdk-providers/xai\n\tif (protocol === Model.KnownProviderEnum.openai || protocol === Model.KnownProviderEnum.xai) {\n\t\treturn Model.APIMethodEnum.responses;\n\t}\n\treturn Model.APIMethodEnum.languageModel;\n}\n\nfunction resolveProviderOptionsKey(protocol: Model.KnownProviderEnum): string {\n\tif (protocol === Model.KnownProviderEnum.openaiCompatible) return \"openai-compatible\";\n\tif (protocol === Model.KnownProviderEnum.googleVertex) return \"google-vertex\";\n\tif (protocol === Model.KnownProviderEnum.googleVertexAnthropic) return \"google-vertex-anthropic\";\n\treturn protocol;\n}\n\nfunction roundCost(value: number): number {\n\treturn Number(value.toFixed(6));\n}\n\n/** models.dev prices, with its context tiers; a rate a tier does not list keeps the base price (pi). */\nfunction modelsDevCost(cost: ModelsDevModel[\"cost\"]): Model.Info[\"cost\"] {\n\tconst base = {\n\t\tinput: cost?.input ?? 0,\n\t\toutput: cost?.output ?? 0,\n\t\tcacheRead: cost?.cache_read ?? 0,\n\t\tcacheWrite: cost?.cache_write ?? 0,\n\t};\n\tconst tiers = cost?.tiers?.flatMap((tier) => {\n\t\tconst context = tier.tier;\n\t\tif (context?.type !== \"context\" || context.size === undefined) return [];\n\t\treturn [\n\t\t\t{\n\t\t\t\tinputTokensAbove: context.size,\n\t\t\t\tinput: tier.input ?? base.input,\n\t\t\t\toutput: tier.output ?? base.output,\n\t\t\t\tcacheRead: tier.cache_read ?? base.cacheRead,\n\t\t\t\tcacheWrite: tier.cache_write ?? base.cacheWrite,\n\t\t\t},\n\t\t];\n\t});\n\treturn tiers && tiers.length > 0 ? { ...base, tiers } : base;\n}\n\n/** The efforts models.dev verified for a model, or undefined when it lists none. */\nfunction modelsDevEfforts(model: ModelsDevModel | undefined): Array<string | null> | undefined {\n\tconst efforts = model?.reasoning_options?.flatMap((option) =>\n\t\toption.type === \"effort\" && Array.isArray(option.values) ? option.values : [],\n\t);\n\treturn efforts && efforts.length > 0 ? efforts : undefined;\n}\n\nfunction mergeThinkingLevelMap(model: Model.Info, map: ThinkingLevelMap): void {\n\tmodel.thinkingLevelMap = { ...model.thinkingLevelMap, ...map };\n}\n\nfunction mergeCompat(model: Model.Info, compat: Model.Compatibility): void {\n\tmodel.compat = { ...model.compat, ...compat };\n}\n\n/** Merge the level map models.dev's verified efforts give, when it lists any. */\nfunction applyEffortThinkingLevels(model: Model.Info, source: ModelsDevModel | undefined): void {\n\tconst efforts = modelsDevEfforts(source);\n\tconst map = efforts ? Model.effortThinkingLevels(efforts) : undefined;\n\tif (map) mergeThinkingLevelMap(model, map);\n}\n\n//\n// OpenAI (pi).\nconst OPENAI_LONG_CONTEXT_INPUT_THRESHOLD = 272_000;\nconst OPENAI_MAX_TOKENS = 128_000;\n\nconst OPENAI_RESPONSES_NONE_REASONING_MODELS = new Set([\n\t\"gpt-5.1\",\n\t\"gpt-5.2\",\n\t\"gpt-5.3-codex\",\n\t\"gpt-5.4\",\n\t\"gpt-5.4-mini\",\n\t\"gpt-5.4-nano\",\n\t\"gpt-5.5\",\n\t\"gpt-5.6-luna\",\n\t\"gpt-5.6-sol\",\n\t\"gpt-5.6-terra\",\n\t\"gpt-6-luna\",\n\t\"gpt-6-sol\",\n]);\n\n// Every GPT-6 model takes low through max and rejects \"minimal\"; Astra and 6.1 Sol also reject \"none\".\nconst OPENAI_GPT6_MODELS = new Set([\"gpt-6-astra\", \"gpt-6-luna\", \"gpt-6-sol\", \"gpt-6.1-sol\"]);\nconst OPENAI_GPT6_NO_NONE_MODELS = new Set([\"gpt-6-astra\", \"gpt-6.1-sol\"]);\n\n// Checked live against the Responses and Codex APIs: these families reject\n// reasoning.effort \"minimal\".\nconst OPENAI_NO_MINIMAL_REASONING = /gpt-5\\.[456]|gpt-6/;\n\n// Direct requests stay in the short-context price tier by default; the long-context price stays in\n// `cost.tiers` for a settings entry that opts into the full window.\nconst OPENAI_SHORT_CONTEXT_CAPPED_MODELS = new Set([\n\t\"gpt-5.4\",\n\t\"gpt-5.5\",\n\t\"gpt-5.6-luna\",\n\t\"gpt-5.6-sol\",\n\t\"gpt-5.6-terra\",\n\t\"gpt-6-astra\",\n\t\"gpt-6-luna\",\n\t\"gpt-6-sol\",\n\t\"gpt-6.1-sol\",\n]);\n\n// Models billed at 2x input / 1.5x output above the threshold, when models.dev has no tier for them.\nconst OPENAI_LONG_CONTEXT_PRICING_MODELS = new Set([\n\t...OPENAI_SHORT_CONTEXT_CAPPED_MODELS,\n\t\"gpt-5.4-pro\",\n\t\"gpt-5.5-pro\",\n]);\n\nfunction isOpenAiResponses(model: Model.Info): boolean {\n\treturn model.protocol === Model.KnownProviderEnum.openai || model.protocol === Model.KnownProviderEnum.openaiCodex;\n}\n\nfunction isOpenAiDirect(model: Model.Info): boolean {\n\treturn model.protocol === Model.KnownProviderEnum.openai && model.provider.id === \"openai\";\n}\n\nfunction supportsOpenAiXhigh(model: Model.Info): boolean {\n\treturn /gpt-5\\.[2-6]|gpt-6/.test(model.id);\n}\n\nfunction supportsOpenAiMax(model: Model.Info): boolean {\n\treturn isOpenAiResponses(model) && /gpt-5\\.6|gpt-6/.test(model.id);\n}\n\nfunction withOpenAiLongContextPricing(cost: Model.Info[\"cost\"]): Model.Info[\"cost\"] {\n\treturn {\n\t\t...cost,\n\t\ttiers: [\n\t\t\t{\n\t\t\t\tinputTokensAbove: OPENAI_LONG_CONTEXT_INPUT_THRESHOLD,\n\t\t\t\tinput: roundCost(cost.input * 2),\n\t\t\t\toutput: roundCost(cost.output * 1.5),\n\t\t\t\tcacheRead: roundCost(cost.cacheRead * 2),\n\t\t\t\tcacheWrite: roundCost(cost.cacheWrite * 2),\n\t\t\t},\n\t\t],\n\t};\n}\n\n/**\n * Price multipliers per service tier: models.dev's modes that set `service_tier` (fast is\n * `priority`), over OpenAI's flex 0.5x / priority 2x list defaults.\n */\nfunction serviceTierMultipliers(model: Model.Info, source: ModelsDevModel | undefined): Record<string, number> {\n\tconst multipliers: Record<string, number> = { flex: 0.5, priority: 2 };\n\tfor (const mode of Object.values(source?.experimental?.modes ?? {})) {\n\t\tconst tier = mode.provider?.body?.service_tier;\n\t\tconst input = mode.cost?.input;\n\t\tif (typeof tier !== \"string\" || input === undefined || model.cost.input <= 0) continue;\n\t\tmultipliers[tier] = roundCost(input / model.cost.input);\n\t}\n\treturn multipliers;\n}\n\nfunction applyOpenAiMetadata(model: Model.Info, source: ModelsDevModel | undefined): void {\n\tconst id = model.id;\n\tif (isOpenAiDirect(model)) {\n\t\tif (OPENAI_SHORT_CONTEXT_CAPPED_MODELS.has(id)) {\n\t\t\tmodel.contextWindow = OPENAI_LONG_CONTEXT_INPUT_THRESHOLD;\n\t\t\tmodel.maxTokens = OPENAI_MAX_TOKENS;\n\t\t}\n\t\tif (OPENAI_LONG_CONTEXT_PRICING_MODELS.has(id) && !model.cost.tiers) {\n\t\t\tmodel.cost = withOpenAiLongContextPricing(model.cost);\n\t\t}\n\t\t// models.dev reports the input sub-limit as gpt-5-pro's output.\n\t\tif (id === \"gpt-5-pro\") model.maxTokens = OPENAI_MAX_TOKENS;\n\t}\n\tmodel.cost.serviceTierMultipliers = serviceTierMultipliers(model, source);\n\n\t// models.dev's verified efforts first, then the corrections checked against the API.\n\tapplyEffortThinkingLevels(model, source);\n\tif (model.protocol === Model.KnownProviderEnum.openai && id.startsWith(\"gpt-5\")) {\n\t\tmergeThinkingLevelMap(model, { off: null });\n\t}\n\tif (OPENAI_GPT6_MODELS.has(id)) {\n\t\tmergeThinkingLevelMap(model, {\n\t\t\toff: OPENAI_GPT6_NO_NONE_MODELS.has(id) ? null : \"none\",\n\t\t\tminimal: null,\n\t\t\tlow: \"low\",\n\t\t\tmedium: \"medium\",\n\t\t\thigh: \"high\",\n\t\t\txhigh: \"xhigh\",\n\t\t\tmax: \"max\",\n\t\t});\n\t}\n\tif (isOpenAiDirect(model) && OPENAI_RESPONSES_NONE_REASONING_MODELS.has(id)) {\n\t\tmergeThinkingLevelMap(model, { off: \"none\" });\n\t}\n\tif (supportsOpenAiMax(model)) mergeThinkingLevelMap(model, { max: \"max\" });\n\tif (OPENAI_NO_MINIMAL_REASONING.test(id)) mergeThinkingLevelMap(model, { minimal: null });\n\tif (id.endsWith(\"gpt-5.5-pro\")) mergeThinkingLevelMap(model, { off: null, minimal: null, low: null });\n}\n\n//\n// Anthropic (pi).\nfunction isAnthropicMessages(model: Model.Info): boolean {\n\treturn (\n\t\tmodel.protocol === Model.KnownProviderEnum.anthropic ||\n\t\tmodel.protocol === Model.KnownProviderEnum.googleVertexAnthropic\n\t);\n}\n\n// The Messages API rejects `temperature` on these.\nconst ANTHROPIC_NO_TEMPERATURE = /opus-4[-.][78]|opus-5|(sonnet|haiku)-5[-.]5/;\n\n// Checked live against the Messages API: effort levels each adaptive family\n// accepts, the 5.5 and Fable models that reject `thinking: {type: \"disabled\"}`, and\n// Sonnet 4.5's window, which is 1M only behind a beta header.\nfunction applyAnthropicMetadata(model: Model.Info): void {\n\tconst id = model.id;\n\tif (/sonnet-4[-.]5/.test(id)) model.contextWindow = 200_000;\n\t// Not models.dev's efforts: Anthropic disables thinking by a toggle, not an effort of \"none\" (pi).\n\tif (Model.isAnthropicAdaptiveThinkingModel(id)) mergeCompat(model, { forceAdaptiveThinking: true });\n\tif (/(opus|sonnet)-4[-.]6/.test(id)) {\n\t\tmergeThinkingLevelMap(model, { max: \"max\" });\n\t}\n\tif (/opus-4[-.][78]|(opus|sonnet|fable|haiku)-5/.test(id)) {\n\t\tmergeThinkingLevelMap(model, { xhigh: \"xhigh\", max: \"max\" });\n\t}\n\tif (/(opus|sonnet|haiku)-5[-.]5/.test(id)) {\n\t\t// Haiku 5.5 accepts disabled thinking; Opus 5.5 and Sonnet 5.5 reject it.\n\t\tmergeThinkingLevelMap(model, {\n\t\t\t...(id.includes(\"haiku\") ? {} : { off: null }),\n\t\t\tminimal: null,\n\t\t\tlow: \"low\",\n\t\t\tmedium: \"medium\",\n\t\t\thigh: \"high\",\n\t\t\txhigh: \"xhigh\",\n\t\t\tmax: \"max\",\n\t\t});\n\t}\n\tif (/fable-5/.test(id)) {\n\t\tmergeThinkingLevelMap(model, { off: null });\n\t}\n\tif (ANTHROPIC_NO_TEMPERATURE.test(id)) mergeCompat(model, { supportsTemperature: false });\n}\n\n//\n// Google.\nfunction applyGoogleThinkingMetadata(model: Model.Info): void {\n\tconst id = model.id.toLowerCase();\n\tconst supportsThinkingLevel =\n\t\t/gemini-3(?:\\.\\d+)?-(?:pro|flash)|gemma-?4/.test(id) ||\n\t\tid === \"gemini-flash-latest\" ||\n\t\tid === \"gemini-flash-lite-latest\";\n\tmergeCompat(model, { supportsThinkingLevel });\n\tif (supportsThinkingLevel) return;\n\n\t// Unknown budget-based families ask the provider to size thinking dynamically.\n\tconst defaults: Array<[string, Model.ThinkingBudgets]> = [\n\t\t[\"2.5-pro\", { minimal: 128, low: 2048, medium: 8192, high: 32768 }],\n\t\t[\"2.5-flash-lite\", { minimal: 512, low: 2048, medium: 8192, high: 24576 }],\n\t\t[\"2.5-flash\", { minimal: 128, low: 2048, medium: 8192, high: 24576 }],\n\t];\n\tmodel.thinkingBudgets = defaults.find(([family]) => id.includes(family))?.[1] ?? {\n\t\tminimal: -1,\n\t\tlow: -1,\n\t\tmedium: -1,\n\t\thigh: -1,\n\t};\n}\n\nfunction applyModelMetadata(model: Model.Info, source: ModelsDevModel | undefined): void {\n\tconst isGoogle =\n\t\tmodel.protocol === Model.KnownProviderEnum.google || model.protocol === Model.KnownProviderEnum.googleVertex;\n\tif (isGoogle) {\n\t\tapplyGoogleThinkingMetadata(model);\n\t\tif (/gemini-3(?:\\.\\d+)?-pro|gemini-3\\.[78]-flash/.test(model.id.toLowerCase())) {\n\t\t\t// These models cannot disable thinking or accept minimal. Expose supported\n\t\t\t// levels to callers and let the shared clamp promote minimal to low.\n\t\t\tmergeThinkingLevelMap(model, { off: \"low\", minimal: null });\n\t\t}\n\t}\n\t// Proxied Claude ids (Copilot) keep the effort aliases the Messages API takes.\n\tif (model.id.includes(\"opus-4-6\") || model.id.includes(\"opus-4.6\")) {\n\t\tmergeThinkingLevelMap(model, { xhigh: \"max\" });\n\t}\n\tif (model.id.includes(\"opus-4-7\") || model.id.includes(\"opus-4.7\")) {\n\t\tmergeThinkingLevelMap(model, { xhigh: \"xhigh\" });\n\t}\n\tif (isOpenAiResponses(model)) applyOpenAiMetadata(model, source);\n\t// By id, for every provider serving these GPT models (pi).\n\tif (supportsOpenAiXhigh(model)) mergeThinkingLevelMap(model, { xhigh: \"xhigh\" });\n\tif (isAnthropicMessages(model)) applyAnthropicMetadata(model);\n}\n\n//\n// OpenAI Codex (ChatGPT OAuth) models.\n// Built from the OpenAI entries: Codex serves the same models at the same list prices, so only\n// which models it offers, its window and its tool support are its own. Context windows are the\n// observed server limits (400s above them), not marketing numbers.\nconst OPENAI_CODEX_PROVIDER_ID = \"openai-codex\";\nconst OPENAI_CODEX_NPM = \"@codeworksh/ai-sdk-openai-codex\";\nconst OPENAI_CODEX_BASE_URL = \"https://chatgpt.com/backend-api\";\nconst OPENAI_CODEX_CONTEXT = 272_000;\nconst OPENAI_CODEX_MODELS: ReadonlyArray<{ readonly id: string; readonly contextWindow?: number }> = [\n\t{ id: \"gpt-5.3-codex-spark\", contextWindow: 128_000 },\n\t{ id: \"gpt-5.5\" },\n\t{ id: \"gpt-5.6-luna\" },\n\t{ id: \"gpt-5.6-sol\" },\n\t{ id: \"gpt-5.6-terra\" },\n\t{ id: \"gpt-6-astra\" },\n\t{ id: \"gpt-6-luna\" },\n\t{ id: \"gpt-6-sol\" },\n\t{ id: \"gpt-6.1-sol\", contextWindow: 500_000 },\n];\nconst OPENAI_CODEX_ADDITIONAL_TOOLS_MODEL_IDS = new Set([\n\t\"gpt-5.6-luna\",\n\t\"gpt-5.6-sol\",\n\t\"gpt-5.6-terra\",\n\t\"gpt-6-astra\",\n\t\"gpt-6-luna\",\n\t\"gpt-6-sol\",\n\t\"gpt-6.1-sol\",\n]);\nconst OPENAI_CODEX_TOOL_SEARCH_MODEL_IDS = new Set([\"gpt-5.5\", ...OPENAI_CODEX_ADDITIONAL_TOOLS_MODEL_IDS]);\n// Checked live: the Codex backend accepts reasoning.effort \"none\" for these.\nconst OPENAI_CODEX_NONE_REASONING_MODEL_IDS = new Set([\"gpt-5.5\", \"gpt-5.6-luna\", \"gpt-6-luna\", \"gpt-6-sol\"]);\n\n/** The Codex models, from the generated `openai` entries; one models.dev does not list is skipped. */\nexport function openAICodexBuiltInModels(openai: Record<string, Model.Info>): Record<string, Model.Info> {\n\tconst models: Record<string, Model.Info> = {};\n\tfor (const seed of OPENAI_CODEX_MODELS) {\n\t\tconst base = openai[seed.id];\n\t\tif (!base) continue;\n\t\tconst info: Model.Info = {\n\t\t\t...base,\n\t\t\tprovider: {\n\t\t\t\tid: OPENAI_CODEX_PROVIDER_ID,\n\t\t\t\tname: \"OpenAI Codex (ChatGPT)\",\n\t\t\t\tsource: \"custom\",\n\t\t\t\tenv: [\"OPENAI_CODEX_API_KEY\"],\n\t\t\t},\n\t\t\tbaseUrl: OPENAI_CODEX_BASE_URL,\n\t\t\treasoning: true,\n\t\t\tthinkingLevelMap: {\n\t\t\t\t...base.thinkingLevelMap,\n\t\t\t\t// Codex models reason unless verified to accept \"none\".\n\t\t\t\toff: OPENAI_CODEX_NONE_REASONING_MODEL_IDS.has(seed.id) ? \"none\" : null,\n\t\t\t\t// The backend takes \"low\" where the API would reject \"minimal\" (pi).\n\t\t\t\t...(supportsOpenAiXhigh(base) ? { minimal: \"low\" } : {}),\n\t\t\t},\n\t\t\tcontextWindow: seed.contextWindow ?? OPENAI_CODEX_CONTEXT,\n\t\t\tmaxTokens: OPENAI_MAX_TOKENS,\n\t\t\tnpm: OPENAI_CODEX_NPM,\n\t\t\tapi: {\n\t\t\t\tid: seed.id,\n\t\t\t\turl: OPENAI_CODEX_BASE_URL,\n\t\t\t\tmethod: Model.APIMethodEnum.responses,\n\t\t\t},\n\t\t\tproviderOptionsKey: OPENAI_CODEX_PROVIDER_ID,\n\t\t\tcompat: {\n\t\t\t\tsupportsOpenAIGrammarTools: true,\n\t\t\t\t...(OPENAI_CODEX_TOOL_SEARCH_MODEL_IDS.has(seed.id) ? { supportsToolSearch: true } : {}),\n\t\t\t\t...(OPENAI_CODEX_ADDITIONAL_TOOLS_MODEL_IDS.has(seed.id) ? { supportsAdditionalTools: true } : {}),\n\t\t\t},\n\t\t\tprotocol: Model.KnownProviderEnum.openaiCodex,\n\t\t};\n\t\tdelete info.headers;\n\t\tmodels[seed.id] = info;\n\t}\n\treturn models;\n}\n\n//\n// GitHub Copilot models.\n// Sourced from models.dev, then rewritten onto the bundled provider: one\n// `github-copilot` protocol whose `api.method` selects between Chat\n// Completions, Responses, and Anthropic Messages.\nconst GITHUB_COPILOT_PROVIDER_ID = \"github-copilot\";\nconst GITHUB_COPILOT_NPM = \"@codeworksh/ai-sdk-github-copilot\";\nconst GITHUB_COPILOT_BASE_URL = \"https://api.githubcopilot.com\";\nconst GITHUB_COPILOT_EXTENDED_CONTEXT = 1_000_000;\n\n// GitHub's \"Models with extended capabilities\" table lists these Copilot\n// models as supporting the extended 1 million token context window (pi).\nconst GITHUB_COPILOT_EXTENDED_CONTEXT_MODELS = new Set([\n\t\"claude-fable-5\",\n\t\"claude-opus-4.6\",\n\t\"claude-opus-4.7\",\n\t\"claude-opus-4.8\",\n\t\"claude-opus-5\",\n\t\"claude-sonnet-4.6\",\n\t\"claude-sonnet-5\",\n\t\"gpt-5.3-codex\",\n\t\"gpt-5.4\",\n\t\"gpt-5.5\",\n]);\n\n// Checked manually against the authenticated GitHub Copilot /models endpoint\n// (pi). Narrow corrections over models.dev metadata, not a catalog snapshot.\nconst GITHUB_COPILOT_THINKING_LEVEL_OVERRIDES: Record<string, ThinkingLevelMap> = {\n\t\"claude-opus-4.7\": { minimal: \"low\" },\n\t\"claude-opus-4.8\": { minimal: \"low\" },\n\t\"claude-opus-5\": { minimal: \"low\" },\n\t\"claude-sonnet-4.6\": { minimal: \"low\", max: \"max\" },\n};\n\n/**\n * The offline routing approximation (pi). The live `/models` response's\n * `supported_endpoints` is authoritative at runtime.\n *\n * - `claude-(haiku|sonnet|opus|fable)-[45]` → Anthropic Messages\n * - `gpt-*`, `grok-*`, `oswe*`, `mai-*` → OpenAI Responses\n * - everything else → OpenAI Chat Completions\n */\nexport function githubCopilotApiMethod(modelId: string): Model.APIMethodEnum {\n\tif (/^claude-(haiku|sonnet|opus|fable)-[45]([.-]|$)/.test(modelId)) {\n\t\treturn Model.APIMethodEnum.messages;\n\t}\n\tconst gpt = /^gpt-(\\d+)/.exec(modelId);\n\tif (\n\t\t(gpt !== null && Number(gpt[1]) >= 5) ||\n\t\tmodelId.startsWith(\"grok-\") ||\n\t\tmodelId.startsWith(\"oswe\") ||\n\t\tmodelId.startsWith(\"mai-\")\n\t) {\n\t\treturn Model.APIMethodEnum.responses;\n\t}\n\treturn Model.APIMethodEnum.chat;\n}\n\n/**\n * Derive the level map from models.dev `reasoning_options`: a level maps to\n * itself only when the endpoint actually advertises it. `minimal` degrades to\n * `low` — the lowest effort every reasoning model accepts.\n */\nfunction githubCopilotThinkingLevels(model: ModelsDevModel, method: Model.APIMethodEnum): ThinkingLevelMap | undefined {\n\tconst listed = modelsDevEfforts(model);\n\tconst efforts = listed ? new Set(listed) : undefined;\n\tconst map: ThinkingLevelMap = {};\n\t// Copilot rejects `reasoningEffort: \"none\"` (pi), and the chat route has no\n\t// reasoning control, so only Messages models can disable thinking.\n\tif (method !== Model.APIMethodEnum.messages) map.off = null;\n\tif (!efforts) return Object.keys(map).length > 0 ? map : undefined;\n\n\tif (efforts.has(\"minimal\")) map.minimal = \"minimal\";\n\telse if (efforts.has(\"low\")) map.minimal = \"low\";\n\tfor (const level of [\"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const) {\n\t\tmap[level] = efforts.has(level) ? level : null;\n\t}\n\treturn map;\n}\n\nexport function githubCopilotBuiltInModels(provider: ModelsDevProvider | undefined): Record<string, Model.Info> {\n\tconst models: Record<string, Model.Info> = {};\n\tif (!provider) return models;\n\tfor (const [id, source] of Object.entries(provider.models)) {\n\t\tif (source.tool_call !== true) continue;\n\t\tif (source.status === \"deprecated\") continue;\n\t\t// The chat-latest alias races the Responses route for gpt-5 models.\n\t\tif (id === \"gpt-5-chat-latest\") continue;\n\n\t\tconst base = applyModification(GITHUB_COPILOT_PROVIDER_ID, provider, source);\n\t\tif (!base) continue;\n\n\t\tconst method = githubCopilotApiMethod(id);\n\t\tconst info: Model.Info = {\n\t\t\t...base,\n\t\t\tprovider: {\n\t\t\t\tid: GITHUB_COPILOT_PROVIDER_ID,\n\t\t\t\tname: \"GitHub Copilot\",\n\t\t\t\tsource: \"custom\",\n\t\t\t\tenv: [\"COPILOT_GITHUB_TOKEN\"],\n\t\t\t},\n\t\t\tbaseUrl: GITHUB_COPILOT_BASE_URL,\n\t\t\theaders: { ...GITHUB_COPILOT_STATIC_HEADERS },\n\t\t\tnpm: GITHUB_COPILOT_NPM,\n\t\t\tapi: { id, url: GITHUB_COPILOT_BASE_URL, method },\n\t\t\tproviderOptionsKey: GITHUB_COPILOT_PROVIDER_ID,\n\t\t\tprotocol: Model.KnownProviderEnum.githubCopilot,\n\t\t\t// Copilot's Responses route requires store=false + encrypted reasoning\n\t\t\t// content for thinking to round-trip.\n\t\t\t...(method === Model.APIMethodEnum.responses\n\t\t\t\t? {\n\t\t\t\t\t\tproviderOptions: {\n\t\t\t\t\t\t\t...base.providerOptions,\n\t\t\t\t\t\t\t[GITHUB_COPILOT_PROVIDER_ID]: {\n\t\t\t\t\t\t\t\tstore: false,\n\t\t\t\t\t\t\t\tinclude: [\"reasoning.encrypted_content\"],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t};\n\n\t\tif (GITHUB_COPILOT_EXTENDED_CONTEXT_MODELS.has(id)) info.contextWindow = GITHUB_COPILOT_EXTENDED_CONTEXT;\n\t\tif (method === Model.APIMethodEnum.messages && Model.isAnthropicAdaptiveThinkingModel(id)) {\n\t\t\tmergeCompat(info, { forceAdaptiveThinking: true });\n\t\t}\n\t\t// Copilot's Responses endpoint passes OpenAI custom grammar tools through\n\t\t// for GPT-5+ (verified by pi).\n\t\tconst gpt = /^gpt-(\\d+)/.exec(id);\n\t\tif (method === Model.APIMethodEnum.responses && gpt !== null && Number(gpt[1]) >= 5) {\n\t\t\tmergeCompat(info, { supportsOpenAIGrammarTools: true });\n\t\t}\n\t\tif (id.startsWith(\"gpt-5\")) mergeThinkingLevelMap(info, { off: null, minimal: \"low\" });\n\t\tif (id.includes(\"fable-5\")) mergeThinkingLevelMap(info, { off: null, xhigh: \"xhigh\", max: \"max\" });\n\n\t\tconst levels = githubCopilotThinkingLevels(source, method);\n\t\tif (levels) mergeThinkingLevelMap(info, levels);\n\t\tconst override = GITHUB_COPILOT_THINKING_LEVEL_OVERRIDES[id];\n\t\tif (override) mergeThinkingLevelMap(info, override);\n\n\t\tmodels[id] = info;\n\t}\n\treturn models;\n}\n\n/** OpenRouter's listing as catalog entries, or undefined when it is missing or unreadable. */\nfunction openRouterModels(listing: unknown): Record<string, Model.Info> | undefined {\n\tif (listing === undefined) return undefined;\n\ttry {\n\t\tconst models = OpenRouter.catalog(listing);\n\t\treturn Object.keys(models).length > 0 ? models : undefined;\n\t} catch {\n\t\treturn undefined;\n\t}\n}\n\n/** Object keys in order at every level, so identical content serializes to identical bytes. */\nfunction sortKeys(value: unknown): unknown {\n\tif (Array.isArray(value)) return value.map(sortKeys);\n\tif (typeof value !== \"object\" || value === null) return value;\n\treturn Object.fromEntries(\n\t\tObject.entries(value)\n\t\t\t.sort(([a], [b]) => (a < b ? -1 : a > b ? 1 : 0))\n\t\t\t.map(([key, entry]) => [key, sortKeys(entry)]),\n\t);\n}\n\n/**\n * The catalog from fetched sources, keys sorted so identical content serializes to identical\n * bytes. OpenRouter's own listing replaces models.dev's copy of it.\n */\nexport function buildCatalog(sources: Sources): BuiltInModels {\n\tconst modelsDev = loadBuiltInFromModelsDev(sources.modelsDev);\n\tconst openrouter = openRouterModels(sources.openRouter);\n\tconst copilotProvider = sources.modelsDev[GITHUB_COPILOT_PROVIDER_ID];\n\treturn sortKeys({\n\t\t...modelsDev,\n\t\t...(openrouter ? { [OpenRouter.PROVIDER_ID]: openrouter } : {}),\n\t\t[OPENAI_CODEX_PROVIDER_ID]: openAICodexBuiltInModels(modelsDev.openai ?? {}),\n\t\t...(copilotProvider ? { [GITHUB_COPILOT_PROVIDER_ID]: githubCopilotBuiltInModels(copilotProvider) } : {}),\n\t}) as BuiltInModels;\n}\n\nexport interface GenerateOptions {\n\t/** Output file; defaults to `CODEWORK_MODELS_FILE` or `./models.gen.json`. */\n\treadonly path?: string | undefined;\n\t/** Keep only {@link BASELINE_PROVIDERS}, for the catalog bundled with aikit. */\n\treadonly baseline?: boolean | undefined;\n}\n\nexport async function generateModels(args: GenerateOptions = {}): Promise<string> {\n\tconst path = resolve(args.path ?? ModelCatalog.path());\n\tconst [modelsDev, openRouter] = await Promise.all([pullModelsDevData(), pullOpenRouterData()]);\n\tconst catalog = buildCatalog({ modelsDev, openRouter });\n\tawait Filesystem.writeJsonAtomic(path, args.baseline ? pick(catalog, BASELINE_PROVIDERS) : catalog);\n\treturn path;\n}\n\n//\n// CLI entry\nexport const ModelgenCommand: CommandModule<object, { path?: string | undefined; baseline?: boolean | undefined }> = {\n\tcommand: \"modelgen [path]\",\n\tdescribe: \"generate models.gen.json\",\n\tbuilder: (yargs) =>\n\t\tyargs\n\t\t\t.positional(\"path\", {\n\t\t\t\ttype: \"string\",\n\t\t\t\tdescribe: \"output path (defaults to CODEWORK_MODELS_FILE or ./models.gen.json)\",\n\t\t\t})\n\t\t\t.option(\"baseline\", {\n\t\t\t\ttype: \"boolean\",\n\t\t\t\tdescribe: `keep only the bundled baseline providers (${BASELINE_PROVIDERS.join(\", \")})`,\n\t\t\t}),\n\thandler: async (args) => {\n\t\tconst path = await generateModels(args);\n\t\tconsole.log(`Generated model catalog at ${path}`);\n\t},\n};\n\nexport function applyModification(\n\tproviderId: string,\n\tprovider: ModelsDevProvider,\n\tmodel: ModelsDevModel,\n): Model.Info | undefined {\n\tconst npm = resolveModelNpm(provider, model);\n\tif (!isAISDKPackage(npm)) return;\n\n\tconst protocol = protocolForPackage(npm);\n\tconst baseUrl = resolveModelBaseUrl(provider, model);\n\tconst providerInfo: Model.ProviderInfo = {\n\t\tid: providerId,\n\t\tname: provider.name,\n\t\tsource: \"api\",\n\t\tenv: provider.env,\n\t};\n\tif (provider.key) providerInfo.key = provider.key;\n\tconst api: Model.APIMetadata = {\n\t\tid: model.id,\n\t\tmethod: resolveModelAPIMethod(npm),\n\t};\n\tif (baseUrl) api.url = baseUrl;\n\n\tconst info: Model.Info = {\n\t\tid: model.id,\n\t\tname: model.name,\n\t\tprovider: providerInfo,\n\t\tbaseUrl,\n\t\treasoning: Boolean(model.reasoning),\n\t\tinput: Model.normalizeInput(model.modalities.input),\n\t\tcost: modelsDevCost(model.cost),\n\t\tcontextWindow: model.limit?.context ?? 4096,\n\t\tmaxTokens: model.limit?.output ?? 4096,\n\t\theaders: {\n\t\t\t...provider.headers,\n\t\t\t...model.provider?.headers,\n\t\t\t...model.headers,\n\t\t},\n\t\tnpm,\n\t\tapi,\n\t\tproviderOptionsKey: resolveProviderOptionsKey(protocol),\n\t\tprotocol,\n\t};\n\tif (Object.keys(info.headers ?? {}).length === 0) delete info.headers;\n\tapplyModelMetadata(info, model);\n\treturn info;\n}\n"],"mappings":";;;;;;AAUA,MAAa,cAAc;AAC3B,MAAa,WAAW;AACxB,MAAM,MAAM;AACZ,MAAM,yBAAyB;;;;;AAwC/B,SAAS,WAAW,OAA2B,UAA0B;CACxE,MAAM,WAAW,OAAO,WAAW,SAAS,EAAE;CAC9C,OAAO,YAAY,IAAI,QAAQ,WAAW,IAAA,CAAW,QAAQ,CAAC,CAAC,IAAI;AACpE;;;;;AAMA,SAAgB,KAAK,SAAkD;CACtE,MAAM,OAAO;EACZ,OAAO,WAAW,SAAS,QAAQ,CAAC;EACpC,QAAQ,WAAW,SAAS,YAAY,CAAC;EACzC,WAAW,WAAW,SAAS,kBAAkB,CAAC;EAClD,YAAY,WAAW,SAAS,mBAAmB,CAAC;CACrD;CACA,MAAM,SAAS,SAAS,aAAa,CAAC,EAAA,CAAG,SAAS,aAAa;EAC9D,IACC,SAAS,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