@dreb/ai 2.57.0 → 2.58.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/README.md CHANGED
@@ -794,7 +794,7 @@ interface OpenAICompletionsCompat {
794
794
  requiresToolResultName?: boolean; // Whether tool results require the `name` field (default: false)
795
795
  requiresAssistantAfterToolResult?: boolean; // Whether tool results must be followed by an assistant message (default: false)
796
796
  requiresThinkingAsText?: boolean; // Whether thinking blocks must be converted to text (default: false)
797
- thinkingFormat?: 'openai' | 'openrouter' | 'zai' | 'qwen' | 'qwen-chat-template' | 'kimi'; // Format for reasoning param: 'openai' uses reasoning_effort, 'openrouter' uses reasoning: { effort }, 'zai' uses top-level enable_thinking: boolean, 'qwen' uses top-level enable_thinking: boolean, 'qwen-chat-template' uses chat_template_kwargs.enable_thinking, and 'kimi' uses nested thinking: { type, effort? } plus prompt_cache_key (default: openai)
797
+ thinkingFormat?: 'openai' | 'openrouter' | 'zai' | 'qwen' | 'qwen-chat-template' | 'kimi'; // Format for reasoning param: 'openai' uses reasoning_effort, 'openrouter' uses reasoning: { effort }, 'zai' uses top-level enable_thinking: boolean, 'qwen' uses top-level enable_thinking: boolean, 'qwen-chat-template' uses chat_template_kwargs.enable_thinking plus a top-level mapped reasoning_effort (Qwen3.8+ models default-map dreb levels onto the native low/medium/xhigh tiers), and 'kimi' uses nested thinking: { type, effort? } plus prompt_cache_key (default: openai)
798
798
  openRouterRouting?: OpenRouterRouting; // OpenRouter routing preferences (default: {})
799
799
  vercelGatewayRouting?: VercelGatewayRouting; // Vercel AI Gateway routing preferences (default: {})
800
800
  }
package/dist/models.d.ts CHANGED
@@ -41,6 +41,11 @@ export declare function findModelInList(pattern: string, models: Model<Api>[]):
41
41
  export declare function getProviders(): KnownProvider[];
42
42
  export declare function getModels<TProvider extends KnownProvider>(provider: TProvider): Model<ModelApi<TProvider, keyof (typeof MODELS)[TProvider]>>[];
43
43
  export declare function calculateCost<TApi extends Api>(model: Model<TApi>, usage: Usage): Usage["cost"];
44
+ /**
45
+ * Check whether a model id belongs to Qwen 3.8 or a later Qwen generation — the first
46
+ * Qwen family with graded `reasoning_effort` tiers (low/medium/xhigh, default xhigh).
47
+ */
48
+ export declare function isQwen38OrLater(modelId: string): boolean;
44
49
  /**
45
50
  * Check if a model supports xhigh thinking level.
46
51
  *
@@ -48,6 +53,7 @@ export declare function calculateCost<TApi extends Api>(model: Model<TApi>, usag
48
53
  * - GPT-5.2 through GPT-5.6 model families
49
54
  * - Claude Opus 4.6–4.x and Claude 5 model families
50
55
  * - Kimi Code K3 (xhigh maps to its advertised "max" effort)
56
+ * - Qwen 3.8+ model families (xhigh is their top native effort tier)
51
57
  */
52
58
  export declare function supportsXhigh<TApi extends Api>(model: Model<TApi>): boolean;
53
59
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAanE,KAAK,QAAQ,CACZ,SAAS,SAAS,aAAa,EAC/B,QAAQ,SAAS,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,IAC9C,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,SAAS;IAAE,GAAG,EAAE,MAAM,IAAI,CAAA;CAAE,GAAG,CAAC,IAAI,SAAS,GAAG,GAAG,IAAI,GAAG,KAAK,CAAC,GAAG,KAAK,CAAC;AAEjH,wBAAgB,QAAQ,CAAC,SAAS,SAAS,aAAa,EAAE,QAAQ,SAAS,MAAM,CAAC,OAAO,MAAM,CAAC,CAAC,SAAS,CAAC,EAC1G,QAAQ,EAAE,SAAS,EACnB,OAAO,EAAE,QAAQ,GACf,KAAK,CAAC,QAAQ,CAAC,SAAS,EA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GAC/B,OAAO,CAGT","sourcesContent":["import { MODELS } from \"./models.generated.js\";\nimport type { Api, KnownProvider, Model, Usage } from \"./types.js\";\n\nconst modelRegistry: Map<string, Map<string, Model<Api>>> = new Map();\n\n// Initialize registry from MODELS on module load\nfor (const [provider, models] of Object.entries(MODELS)) {\n\tconst providerModels = new Map<string, Model<Api>>();\n\tfor (const [id, model] of Object.entries(models)) {\n\t\tproviderModels.set(id, model as Model<Api>);\n\t}\n\tmodelRegistry.set(provider, providerModels);\n}\n\ntype ModelApi<\n\tTProvider extends KnownProvider,\n\tTModelId extends keyof (typeof MODELS)[TProvider],\n> = (typeof MODELS)[TProvider][TModelId] extends { api: infer TApi } ? (TApi extends Api ? TApi : never) : never;\n\nexport function getModel<TProvider extends KnownProvider, TModelId extends keyof (typeof MODELS)[TProvider]>(\n\tprovider: TProvider,\n\tmodelId: TModelId,\n): Model<ModelApi<TProvider, TModelId>> {\n\tconst providerModels = modelRegistry.get(provider);\n\treturn providerModels?.get(modelId as string) as Model<ModelApi<TProvider, TModelId>>;\n}\n\n/**\n * Check if a model ID looks like an alias (no date suffix).\n * Aliases are preferred over dated versions when fuzzy matching.\n *\n * IDs ending with `-latest` are treated as aliases.\n * IDs ending with a date pattern (`-YYYYMMDD`) are treated as dated versions.\n */\nexport function isModelAlias(id: string): boolean {\n\tif (id.endsWith(\"-latest\")) return true;\n\treturn !/-\\d{8}$/.test(id);\n}\n\n/**\n * Find a model by fuzzy matching against the provider's registered models.\n *\n * Resolution order:\n * 1. Exact match by provider + model ID (via registry Map.get)\n * 2. Case-insensitive substring match against model ID and display name\n * 3. Among matches, prefer aliases (non-dated IDs) over dated versions\n * 4. Among ties, pick the lexicographically highest (latest) ID\n *\n * This is the same matching logic used by the CLI, subagent model resolution,\n * and interactive mode — centralised here so tests can exercise the real path.\n *\n * @example\n * findModel(\"anthropic\", \"sonnet\") // → latest claude-sonnet alias\n * findModel(\"anthropic\", \"haiku\") // → latest claude-haiku alias\n * findModel(\"openai\", \"gpt-5\") // → latest gpt-5 alias\n */\nexport function findModel(provider: string, pattern: string): Model<Api> | undefined {\n\tconst providerModels = modelRegistry.get(provider);\n\tif (!providerModels) return undefined;\n\n\t// Try exact match first\n\tconst exact = providerModels.get(pattern);\n\tif (exact) return exact;\n\n\t// Substring match (case-insensitive)\n\tconst normalizedPattern = pattern.toLowerCase();\n\tconst matches = Array.from(providerModels.values()).filter(\n\t\t(m) => m.id.toLowerCase().includes(normalizedPattern) || m.name?.toLowerCase().includes(normalizedPattern),\n\t);\n\n\tif (matches.length === 0) return undefined;\n\tif (matches.length === 1) return matches[0];\n\n\t// Multiple matches — separate into aliases and dated versions\n\tconst aliases = matches.filter((m) => isModelAlias(m.id));\n\tconst datedVersions = matches.filter((m) => !isModelAlias(m.id));\n\n\tif (aliases.length > 0) {\n\t\t// Prefer alias — if multiple, pick the lexicographically highest\n\t\taliases.sort((a, b) => b.id.localeCompare(a.id));\n\t\treturn aliases[0];\n\t}\n\n\t// All dated — prefer the latest\n\tdatedVersions.sort((a, b) => b.id.localeCompare(a.id));\n\treturn datedVersions[0];\n}\n\n/**\n * Find a model by fuzzy matching against a flat array of models.\n * Same algorithm as findModel() but operates on an arbitrary model list\n * instead of the built-in registry.\n *\n * Used by model-resolver.ts and other code that manages its own model lists.\n */\nexport function findModelInList(pattern: string, models: Model<Api>[]): Model<Api> | undefined {\n\tif (models.length === 0) return undefined;\n\n\tconst normalizedPattern = pattern.toLowerCase();\n\n\t// Exact ID match (case-insensitive)\n\tconst exactById = models.find((m) => m.id.toLowerCase() === normalizedPattern);\n\tif (exactById) return exactById;\n\n\t// Substring match (case-insensitive)\n\tconst matches = models.filter(\n\t\t(m) => m.id.toLowerCase().includes(normalizedPattern) || m.name?.toLowerCase().includes(normalizedPattern),\n\t);\n\n\tif (matches.length === 0) return undefined;\n\tif (matches.length === 1) return matches[0];\n\n\t// Multiple matches — separate into aliases and dated versions\n\tconst aliases = matches.filter((m) => isModelAlias(m.id));\n\tconst datedVersions = matches.filter((m) => !isModelAlias(m.id));\n\n\tif (aliases.length > 0) {\n\t\taliases.sort((a, b) => b.id.localeCompare(a.id));\n\t\treturn aliases[0];\n\t}\n\n\tdatedVersions.sort((a, b) => b.id.localeCompare(a.id));\n\treturn datedVersions[0];\n}\n\nexport function getProviders(): KnownProvider[] {\n\treturn Array.from(modelRegistry.keys()) as KnownProvider[];\n}\n\nexport function getModels<TProvider extends KnownProvider>(\n\tprovider: TProvider,\n): Model<ModelApi<TProvider, keyof (typeof MODELS)[TProvider]>>[] {\n\tconst models = modelRegistry.get(provider);\n\treturn models ? (Array.from(models.values()) as Model<ModelApi<TProvider, keyof (typeof MODELS)[TProvider]>>[]) : [];\n}\n\nexport function calculateCost<TApi extends Api>(model: Model<TApi>, usage: Usage): Usage[\"cost\"] {\n\tusage.cost.input = (model.cost.input / 1000000) * usage.input;\n\tusage.cost.output = (model.cost.output / 1000000) * usage.output;\n\tusage.cost.cacheRead = (model.cost.cacheRead / 1000000) * usage.cacheRead;\n\tusage.cost.cacheWrite = (model.cost.cacheWrite / 1000000) * usage.cacheWrite;\n\tusage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;\n\treturn usage.cost;\n}\n\ninterface ClaudeFamilyVersion {\n\tfamily: \"opus\" | \"sonnet\";\n\tmajor: number;\n\tminor?: number;\n}\n\n/** Parse Claude family versions without mistaking long date suffixes for versions. */\nfunction claudeFamilyVersion(modelId: string): ClaudeFamilyVersion | undefined {\n\tconst match = modelId.match(/(opus|sonnet)-(\\d{1,2})(?:[.-](\\d{1,2}))?(?!\\d)/);\n\tif (!match) return undefined;\n\treturn {\n\t\tfamily: match[1] as ClaudeFamilyVersion[\"family\"],\n\t\tmajor: Number.parseInt(match[2], 10),\n\t\tminor: match[3] === undefined ? undefined : Number.parseInt(match[3], 10),\n\t};\n}\n\n/**\n * Check if a model supports xhigh thinking level.\n *\n * Supported today:\n * - GPT-5.2 through GPT-5.6 model families\n * - Claude Opus 4.6–4.x and Claude 5 model families\n * - Kimi Code K3 (xhigh maps to its advertised \"max\" effort)\n */\nexport function supportsXhigh<TApi extends Api>(model: Model<TApi>): boolean {\n\tif (model.provider === \"kimi-coding-oauth\" && model.id === \"k3\") return true;\n\tif (\n\t\tmodel.id.includes(\"gpt-5.2\") ||\n\t\tmodel.id.includes(\"gpt-5.3\") ||\n\t\tmodel.id.includes(\"gpt-5.4\") ||\n\t\tmodel.id.includes(\"gpt-5.5\") ||\n\t\tmodel.id.includes(\"gpt-5.6\")\n\t) {\n\t\treturn true;\n\t}\n\n\tconst claude = claudeFamilyVersion(model.id);\n\tif (!claude) return false;\n\tif (claude.family === \"opus\") {\n\t\treturn claude.major >= 5 || (claude.major === 4 && (claude.minor ?? 0) >= 6);\n\t}\n\treturn claude.major >= 5;\n}\n\n/**\n * Check if a model uses adaptive thinking (Opus/Sonnet 4.6–4.x and Claude 5\n * families), where the `thinkingDisplay` option is honored. Mirrors the\n * per-provider internal checks.\n */\nexport function supportsAdaptiveThinking<TApi extends Api>(model: Model<TApi>): boolean {\n\tconst claude = claudeFamilyVersion(model.id);\n\treturn claude != null && (claude.major >= 5 || (claude.major === 4 && (claude.minor ?? 0) >= 6));\n}\n\n/**\n * Check if two models are equal by comparing both their id and provider.\n * Returns false if either model is null or undefined.\n */\nexport function modelsAreEqual<TApi extends Api>(\n\ta: Model<TApi> | null | undefined,\n\tb: Model<TApi> | null | undefined,\n): boolean {\n\tif (!a || !b) return false;\n\treturn a.id === b.id && a.provider === b.provider;\n}\n"]}
1
+ {"version":3,"file":"models.d.ts","sourceRoot":"","sources":["../src/models.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,uBAAuB,CAAC;AAC/C,OAAO,KAAK,EAAE,GAAG,EAAE,aAAa,EAAE,KAAK,EAAE,KAAK,EAAE,MAAM,YAAY,CAAC;AAanE,KAAK,QAAQ,CACZ,SAAS,SAAS,aAAa,EAC/B,QAAQ,SAAS,MAAM,CAAC,OAAO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;;GAGG;AACH,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAIxD;AAED;;;;;;;;GAQG;AACH,wBAAgB,aAAa,CAAC,IAAI,SAAS,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAmB3E;AAED;;;;GAIG;AACH,wBAAgB,wBAAwB,CAAC,IAAI,SAAS,GAAG,EAAE,KAAK,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,OAAO,CAGtF;AAED;;;GAGG;AACH,wBAAgB,cAAc,CAAC,IAAI,SAAS,GAAG,EAC9C,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,EACjC,CAAC,EAAE,KAAK,CAAC,IAAI,CAAC,GAAG,IAAI,GAAG,SAAS,GAC/B,OAAO,CAGT","sourcesContent":["import { MODELS } from \"./models.generated.js\";\nimport type { Api, KnownProvider, Model, Usage } from \"./types.js\";\n\nconst modelRegistry: Map<string, Map<string, Model<Api>>> = new Map();\n\n// Initialize registry from MODELS on module load\nfor (const [provider, models] of Object.entries(MODELS)) {\n\tconst providerModels = new Map<string, Model<Api>>();\n\tfor (const [id, model] of Object.entries(models)) {\n\t\tproviderModels.set(id, model as Model<Api>);\n\t}\n\tmodelRegistry.set(provider, providerModels);\n}\n\ntype ModelApi<\n\tTProvider extends KnownProvider,\n\tTModelId extends keyof (typeof MODELS)[TProvider],\n> = (typeof MODELS)[TProvider][TModelId] extends { api: infer TApi } ? (TApi extends Api ? TApi : never) : never;\n\nexport function getModel<TProvider extends KnownProvider, TModelId extends keyof (typeof MODELS)[TProvider]>(\n\tprovider: TProvider,\n\tmodelId: TModelId,\n): Model<ModelApi<TProvider, TModelId>> {\n\tconst providerModels = modelRegistry.get(provider);\n\treturn providerModels?.get(modelId as string) as Model<ModelApi<TProvider, TModelId>>;\n}\n\n/**\n * Check if a model ID looks like an alias (no date suffix).\n * Aliases are preferred over dated versions when fuzzy matching.\n *\n * IDs ending with `-latest` are treated as aliases.\n * IDs ending with a date pattern (`-YYYYMMDD`) are treated as dated versions.\n */\nexport function isModelAlias(id: string): boolean {\n\tif (id.endsWith(\"-latest\")) return true;\n\treturn !/-\\d{8}$/.test(id);\n}\n\n/**\n * Find a model by fuzzy matching against the provider's registered models.\n *\n * Resolution order:\n * 1. Exact match by provider + model ID (via registry Map.get)\n * 2. Case-insensitive substring match against model ID and display name\n * 3. Among matches, prefer aliases (non-dated IDs) over dated versions\n * 4. Among ties, pick the lexicographically highest (latest) ID\n *\n * This is the same matching logic used by the CLI, subagent model resolution,\n * and interactive mode — centralised here so tests can exercise the real path.\n *\n * @example\n * findModel(\"anthropic\", \"sonnet\") // → latest claude-sonnet alias\n * findModel(\"anthropic\", \"haiku\") // → latest claude-haiku alias\n * findModel(\"openai\", \"gpt-5\") // → latest gpt-5 alias\n */\nexport function findModel(provider: string, pattern: string): Model<Api> | undefined {\n\tconst providerModels = modelRegistry.get(provider);\n\tif (!providerModels) return undefined;\n\n\t// Try exact match first\n\tconst exact = providerModels.get(pattern);\n\tif (exact) return exact;\n\n\t// Substring match (case-insensitive)\n\tconst normalizedPattern = pattern.toLowerCase();\n\tconst matches = Array.from(providerModels.values()).filter(\n\t\t(m) => m.id.toLowerCase().includes(normalizedPattern) || m.name?.toLowerCase().includes(normalizedPattern),\n\t);\n\n\tif (matches.length === 0) return undefined;\n\tif (matches.length === 1) return matches[0];\n\n\t// Multiple matches — separate into aliases and dated versions\n\tconst aliases = matches.filter((m) => isModelAlias(m.id));\n\tconst datedVersions = matches.filter((m) => !isModelAlias(m.id));\n\n\tif (aliases.length > 0) {\n\t\t// Prefer alias — if multiple, pick the lexicographically highest\n\t\taliases.sort((a, b) => b.id.localeCompare(a.id));\n\t\treturn aliases[0];\n\t}\n\n\t// All dated — prefer the latest\n\tdatedVersions.sort((a, b) => b.id.localeCompare(a.id));\n\treturn datedVersions[0];\n}\n\n/**\n * Find a model by fuzzy matching against a flat array of models.\n * Same algorithm as findModel() but operates on an arbitrary model list\n * instead of the built-in registry.\n *\n * Used by model-resolver.ts and other code that manages its own model lists.\n */\nexport function findModelInList(pattern: string, models: Model<Api>[]): Model<Api> | undefined {\n\tif (models.length === 0) return undefined;\n\n\tconst normalizedPattern = pattern.toLowerCase();\n\n\t// Exact ID match (case-insensitive)\n\tconst exactById = models.find((m) => m.id.toLowerCase() === normalizedPattern);\n\tif (exactById) return exactById;\n\n\t// Substring match (case-insensitive)\n\tconst matches = models.filter(\n\t\t(m) => m.id.toLowerCase().includes(normalizedPattern) || m.name?.toLowerCase().includes(normalizedPattern),\n\t);\n\n\tif (matches.length === 0) return undefined;\n\tif (matches.length === 1) return matches[0];\n\n\t// Multiple matches — separate into aliases and dated versions\n\tconst aliases = matches.filter((m) => isModelAlias(m.id));\n\tconst datedVersions = matches.filter((m) => !isModelAlias(m.id));\n\n\tif (aliases.length > 0) {\n\t\taliases.sort((a, b) => b.id.localeCompare(a.id));\n\t\treturn aliases[0];\n\t}\n\n\tdatedVersions.sort((a, b) => b.id.localeCompare(a.id));\n\treturn datedVersions[0];\n}\n\nexport function getProviders(): KnownProvider[] {\n\treturn Array.from(modelRegistry.keys()) as KnownProvider[];\n}\n\nexport function getModels<TProvider extends KnownProvider>(\n\tprovider: TProvider,\n): Model<ModelApi<TProvider, keyof (typeof MODELS)[TProvider]>>[] {\n\tconst models = modelRegistry.get(provider);\n\treturn models ? (Array.from(models.values()) as Model<ModelApi<TProvider, keyof (typeof MODELS)[TProvider]>>[]) : [];\n}\n\nexport function calculateCost<TApi extends Api>(model: Model<TApi>, usage: Usage): Usage[\"cost\"] {\n\tusage.cost.input = (model.cost.input / 1000000) * usage.input;\n\tusage.cost.output = (model.cost.output / 1000000) * usage.output;\n\tusage.cost.cacheRead = (model.cost.cacheRead / 1000000) * usage.cacheRead;\n\tusage.cost.cacheWrite = (model.cost.cacheWrite / 1000000) * usage.cacheWrite;\n\tusage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;\n\treturn usage.cost;\n}\n\ninterface ClaudeFamilyVersion {\n\tfamily: \"opus\" | \"sonnet\";\n\tmajor: number;\n\tminor?: number;\n}\n\n/** Parse Claude family versions without mistaking long date suffixes for versions. */\nfunction claudeFamilyVersion(modelId: string): ClaudeFamilyVersion | undefined {\n\tconst match = modelId.match(/(opus|sonnet)-(\\d{1,2})(?:[.-](\\d{1,2}))?(?!\\d)/);\n\tif (!match) return undefined;\n\treturn {\n\t\tfamily: match[1] as ClaudeFamilyVersion[\"family\"],\n\t\tmajor: Number.parseInt(match[2], 10),\n\t\tminor: match[3] === undefined ? undefined : Number.parseInt(match[3], 10),\n\t};\n}\n\n/**\n * Parse Qwen family versions without mistaking parameter counts for minor versions.\n * Only a dot separates major from minor (qwen3.8-27b, Qwen-3.8); a hyphen after the\n * major version introduces the parameter size (qwen3-32b → 3.0, not 3.32). A capture\n * directly followed by a `b`-suffixed size token is a parameter count, not a version\n * (qwen-32b, Qwen-7B-Chat, deepseek-r1-distill-qwen-32b), and Qwen majors never reach\n * two digits, so only a single digit is accepted.\n */\nfunction qwenFamilyVersion(modelId: string): { major: number; minor: number } | undefined {\n\tconst match = modelId.match(/\\bqwen[\\s_-]*v?(\\d)(?:\\.(\\d+))?(?![\\d.]*b\\b)/i);\n\tif (!match) return undefined;\n\treturn {\n\t\tmajor: Number.parseInt(match[1], 10),\n\t\tminor: match[2] === undefined ? 0 : Number.parseInt(match[2], 10),\n\t};\n}\n\n/**\n * Check whether a model id belongs to Qwen 3.8 or a later Qwen generation — the first\n * Qwen family with graded `reasoning_effort` tiers (low/medium/xhigh, default xhigh).\n */\nexport function isQwen38OrLater(modelId: string): boolean {\n\tconst qwen = qwenFamilyVersion(modelId);\n\tif (!qwen) return false;\n\treturn qwen.major > 3 || (qwen.major === 3 && qwen.minor >= 8);\n}\n\n/**\n * Check if a model supports xhigh thinking level.\n *\n * Supported today:\n * - GPT-5.2 through GPT-5.6 model families\n * - Claude Opus 4.6–4.x and Claude 5 model families\n * - Kimi Code K3 (xhigh maps to its advertised \"max\" effort)\n * - Qwen 3.8+ model families (xhigh is their top native effort tier)\n */\nexport function supportsXhigh<TApi extends Api>(model: Model<TApi>): boolean {\n\tif (model.provider === \"kimi-coding-oauth\" && model.id === \"k3\") return true;\n\tif (isQwen38OrLater(model.id)) return true;\n\tif (\n\t\tmodel.id.includes(\"gpt-5.2\") ||\n\t\tmodel.id.includes(\"gpt-5.3\") ||\n\t\tmodel.id.includes(\"gpt-5.4\") ||\n\t\tmodel.id.includes(\"gpt-5.5\") ||\n\t\tmodel.id.includes(\"gpt-5.6\")\n\t) {\n\t\treturn true;\n\t}\n\n\tconst claude = claudeFamilyVersion(model.id);\n\tif (!claude) return false;\n\tif (claude.family === \"opus\") {\n\t\treturn claude.major >= 5 || (claude.major === 4 && (claude.minor ?? 0) >= 6);\n\t}\n\treturn claude.major >= 5;\n}\n\n/**\n * Check if a model uses adaptive thinking (Opus/Sonnet 4.6–4.x and Claude 5\n * families), where the `thinkingDisplay` option is honored. Mirrors the\n * per-provider internal checks.\n */\nexport function supportsAdaptiveThinking<TApi extends Api>(model: Model<TApi>): boolean {\n\tconst claude = claudeFamilyVersion(model.id);\n\treturn claude != null && (claude.major >= 5 || (claude.major === 4 && (claude.minor ?? 0) >= 6));\n}\n\n/**\n * Check if two models are equal by comparing both their id and provider.\n * Returns false if either model is null or undefined.\n */\nexport function modelsAreEqual<TApi extends Api>(\n\ta: Model<TApi> | null | undefined,\n\tb: Model<TApi> | null | undefined,\n): boolean {\n\tif (!a || !b) return false;\n\treturn a.id === b.id && a.provider === b.provider;\n}\n"]}
@@ -765,6 +765,57 @@ export declare const MODELS: {
765
765
  contextWindow: number;
766
766
  maxTokens: number;
767
767
  };
768
+ readonly "global.openai.gpt-5.6-luna": {
769
+ id: string;
770
+ name: string;
771
+ api: "bedrock-converse-stream";
772
+ provider: string;
773
+ baseUrl: string;
774
+ reasoning: true;
775
+ input: ("image" | "text")[];
776
+ cost: {
777
+ input: number;
778
+ output: number;
779
+ cacheRead: number;
780
+ cacheWrite: number;
781
+ };
782
+ contextWindow: number;
783
+ maxTokens: number;
784
+ };
785
+ readonly "global.openai.gpt-5.6-sol": {
786
+ id: string;
787
+ name: string;
788
+ api: "bedrock-converse-stream";
789
+ provider: string;
790
+ baseUrl: string;
791
+ reasoning: true;
792
+ input: ("image" | "text")[];
793
+ cost: {
794
+ input: number;
795
+ output: number;
796
+ cacheRead: number;
797
+ cacheWrite: number;
798
+ };
799
+ contextWindow: number;
800
+ maxTokens: number;
801
+ };
802
+ readonly "global.openai.gpt-5.6-terra": {
803
+ id: string;
804
+ name: string;
805
+ api: "bedrock-converse-stream";
806
+ provider: string;
807
+ baseUrl: string;
808
+ reasoning: true;
809
+ input: ("image" | "text")[];
810
+ cost: {
811
+ input: number;
812
+ output: number;
813
+ cacheRead: number;
814
+ cacheWrite: number;
815
+ };
816
+ contextWindow: number;
817
+ maxTokens: number;
818
+ };
768
819
  readonly "google.gemma-3-27b-it": {
769
820
  id: string;
770
821
  name: string;
@@ -3267,6 +3318,34 @@ export declare const MODELS: {
3267
3318
  contextWindow: number;
3268
3319
  maxTokens: number;
3269
3320
  };
3321
+ readonly "gemini-3.7-flash": {
3322
+ id: string;
3323
+ name: string;
3324
+ api: "openai-completions";
3325
+ provider: string;
3326
+ baseUrl: string;
3327
+ headers: {
3328
+ "User-Agent": string;
3329
+ "Editor-Version": string;
3330
+ "Editor-Plugin-Version": string;
3331
+ "Copilot-Integration-Id": string;
3332
+ };
3333
+ compat: {
3334
+ supportsStore: false;
3335
+ supportsDeveloperRole: false;
3336
+ supportsReasoningEffort: false;
3337
+ };
3338
+ reasoning: true;
3339
+ input: ("image" | "text")[];
3340
+ cost: {
3341
+ input: number;
3342
+ output: number;
3343
+ cacheRead: number;
3344
+ cacheWrite: number;
3345
+ };
3346
+ contextWindow: number;
3347
+ maxTokens: number;
3348
+ };
3270
3349
  readonly "gpt-4.1": {
3271
3350
  id: string;
3272
3351
  name: string;
@@ -3576,6 +3655,34 @@ export declare const MODELS: {
3576
3655
  contextWindow: number;
3577
3656
  maxTokens: number;
3578
3657
  };
3658
+ readonly "grok-4.6": {
3659
+ id: string;
3660
+ name: string;
3661
+ api: "openai-completions";
3662
+ provider: string;
3663
+ baseUrl: string;
3664
+ headers: {
3665
+ "User-Agent": string;
3666
+ "Editor-Version": string;
3667
+ "Editor-Plugin-Version": string;
3668
+ "Copilot-Integration-Id": string;
3669
+ };
3670
+ compat: {
3671
+ supportsStore: false;
3672
+ supportsDeveloperRole: false;
3673
+ supportsReasoningEffort: false;
3674
+ };
3675
+ reasoning: true;
3676
+ input: ("image" | "text")[];
3677
+ cost: {
3678
+ input: number;
3679
+ output: number;
3680
+ cacheRead: number;
3681
+ cacheWrite: number;
3682
+ };
3683
+ contextWindow: number;
3684
+ maxTokens: number;
3685
+ };
3579
3686
  readonly "kimi-k2.7-code": {
3580
3687
  id: string;
3581
3688
  name: string;
@@ -4735,6 +4842,26 @@ export declare const MODELS: {
4735
4842
  contextWindow: number;
4736
4843
  maxTokens: number;
4737
4844
  };
4845
+ readonly "Qwen/Qwen2.5-Coder-32B-Instruct": {
4846
+ id: string;
4847
+ name: string;
4848
+ api: "openai-completions";
4849
+ provider: string;
4850
+ baseUrl: string;
4851
+ compat: {
4852
+ supportsDeveloperRole: false;
4853
+ };
4854
+ reasoning: false;
4855
+ input: "text"[];
4856
+ cost: {
4857
+ input: number;
4858
+ output: number;
4859
+ cacheRead: number;
4860
+ cacheWrite: number;
4861
+ };
4862
+ contextWindow: number;
4863
+ maxTokens: number;
4864
+ };
4738
4865
  readonly "Qwen/Qwen3-235B-A22B": {
4739
4866
  id: string;
4740
4867
  name: string;
@@ -4795,6 +4922,26 @@ export declare const MODELS: {
4795
4922
  contextWindow: number;
4796
4923
  maxTokens: number;
4797
4924
  };
4925
+ readonly "Qwen/Qwen3-30B-A3B": {
4926
+ id: string;
4927
+ name: string;
4928
+ api: "openai-completions";
4929
+ provider: string;
4930
+ baseUrl: string;
4931
+ compat: {
4932
+ supportsDeveloperRole: false;
4933
+ };
4934
+ reasoning: true;
4935
+ input: "text"[];
4936
+ cost: {
4937
+ input: number;
4938
+ output: number;
4939
+ cacheRead: number;
4940
+ cacheWrite: number;
4941
+ };
4942
+ contextWindow: number;
4943
+ maxTokens: number;
4944
+ };
4798
4945
  readonly "Qwen/Qwen3-32B": {
4799
4946
  id: string;
4800
4947
  name: string;
@@ -5055,6 +5202,26 @@ export declare const MODELS: {
5055
5202
  contextWindow: number;
5056
5203
  maxTokens: number;
5057
5204
  };
5205
+ readonly "Qwen/Qwen3.8-2.4T-A95B": {
5206
+ id: string;
5207
+ name: string;
5208
+ api: "openai-completions";
5209
+ provider: string;
5210
+ baseUrl: string;
5211
+ compat: {
5212
+ supportsDeveloperRole: false;
5213
+ };
5214
+ reasoning: true;
5215
+ input: "text"[];
5216
+ cost: {
5217
+ input: number;
5218
+ output: number;
5219
+ cacheRead: number;
5220
+ cacheWrite: number;
5221
+ };
5222
+ contextWindow: number;
5223
+ maxTokens: number;
5224
+ };
5058
5225
  readonly "XiaomiMiMo/MiMo-V2-Flash": {
5059
5226
  id: string;
5060
5227
  name: string;
@@ -5175,6 +5342,26 @@ export declare const MODELS: {
5175
5342
  contextWindow: number;
5176
5343
  maxTokens: number;
5177
5344
  };
5345
+ readonly "deepseek-ai/DeepSeek-V3-0324": {
5346
+ id: string;
5347
+ name: string;
5348
+ api: "openai-completions";
5349
+ provider: string;
5350
+ baseUrl: string;
5351
+ compat: {
5352
+ supportsDeveloperRole: false;
5353
+ };
5354
+ reasoning: false;
5355
+ input: "text"[];
5356
+ cost: {
5357
+ input: number;
5358
+ output: number;
5359
+ cacheRead: number;
5360
+ cacheWrite: number;
5361
+ };
5362
+ contextWindow: number;
5363
+ maxTokens: number;
5364
+ };
5178
5365
  readonly "deepseek-ai/DeepSeek-V3.1": {
5179
5366
  id: string;
5180
5367
  name: string;
@@ -5275,6 +5462,26 @@ export declare const MODELS: {
5275
5462
  contextWindow: number;
5276
5463
  maxTokens: number;
5277
5464
  };
5465
+ readonly "deepseek-ai/DeepSeek-V4-Pro-0813": {
5466
+ id: string;
5467
+ name: string;
5468
+ api: "openai-completions";
5469
+ provider: string;
5470
+ baseUrl: string;
5471
+ compat: {
5472
+ supportsDeveloperRole: false;
5473
+ };
5474
+ reasoning: true;
5475
+ input: "text"[];
5476
+ cost: {
5477
+ input: number;
5478
+ output: number;
5479
+ cacheRead: number;
5480
+ cacheWrite: number;
5481
+ };
5482
+ contextWindow: number;
5483
+ maxTokens: number;
5484
+ };
5278
5485
  readonly "google/gemma-4-26B-A4B-it": {
5279
5486
  id: string;
5280
5487
  name: string;
@@ -5315,6 +5522,26 @@ export declare const MODELS: {
5315
5522
  contextWindow: number;
5316
5523
  maxTokens: number;
5317
5524
  };
5525
+ readonly "meta-llama/Llama-3.1-8B-Instruct": {
5526
+ id: string;
5527
+ name: string;
5528
+ api: "openai-completions";
5529
+ provider: string;
5530
+ baseUrl: string;
5531
+ compat: {
5532
+ supportsDeveloperRole: false;
5533
+ };
5534
+ reasoning: false;
5535
+ input: "text"[];
5536
+ cost: {
5537
+ input: number;
5538
+ output: number;
5539
+ cacheRead: number;
5540
+ cacheWrite: number;
5541
+ };
5542
+ contextWindow: number;
5543
+ maxTokens: number;
5544
+ };
5318
5545
  readonly "meta-llama/Llama-3.3-70B-Instruct": {
5319
5546
  id: string;
5320
5547
  name: string;
@@ -8411,6 +8638,23 @@ export declare const MODELS: {
8411
8638
  contextWindow: number;
8412
8639
  maxTokens: number;
8413
8640
  };
8641
+ readonly "muse-spark-1.2": {
8642
+ id: string;
8643
+ name: string;
8644
+ api: "openai-responses";
8645
+ provider: string;
8646
+ baseUrl: string;
8647
+ reasoning: true;
8648
+ input: ("image" | "text")[];
8649
+ cost: {
8650
+ input: number;
8651
+ output: number;
8652
+ cacheRead: number;
8653
+ cacheWrite: number;
8654
+ };
8655
+ contextWindow: number;
8656
+ maxTokens: number;
8657
+ };
8414
8658
  readonly "nemotron-3-ultra-free": {
8415
8659
  id: string;
8416
8660
  name: string;
@@ -8549,6 +8793,23 @@ export declare const MODELS: {
8549
8793
  contextWindow: number;
8550
8794
  maxTokens: number;
8551
8795
  };
8796
+ readonly "glm-5.3": {
8797
+ id: string;
8798
+ name: string;
8799
+ api: "openai-completions";
8800
+ provider: string;
8801
+ baseUrl: string;
8802
+ reasoning: true;
8803
+ input: "text"[];
8804
+ cost: {
8805
+ input: number;
8806
+ output: number;
8807
+ cacheRead: number;
8808
+ cacheWrite: number;
8809
+ };
8810
+ contextWindow: number;
8811
+ maxTokens: number;
8812
+ };
8552
8813
  readonly "gpt-5.6-luna": {
8553
8814
  id: string;
8554
8815
  name: string;
@@ -8722,7 +8983,7 @@ export declare const MODELS: {
8722
8983
  readonly "qwen3.6-plus": {
8723
8984
  id: string;
8724
8985
  name: string;
8725
- api: "anthropic-messages";
8986
+ api: "openai-completions";
8726
8987
  provider: string;
8727
8988
  baseUrl: string;
8728
8989
  reasoning: true;
@@ -8739,7 +9000,7 @@ export declare const MODELS: {
8739
9000
  readonly "qwen3.7-max": {
8740
9001
  id: string;
8741
9002
  name: string;
8742
- api: "anthropic-messages";
9003
+ api: "openai-completions";
8743
9004
  provider: string;
8744
9005
  baseUrl: string;
8745
9006
  reasoning: true;
@@ -8756,7 +9017,7 @@ export declare const MODELS: {
8756
9017
  readonly "qwen3.7-plus": {
8757
9018
  id: string;
8758
9019
  name: string;
8759
- api: "anthropic-messages";
9020
+ api: "openai-completions";
8760
9021
  provider: string;
8761
9022
  baseUrl: string;
8762
9023
  reasoning: true;
@@ -8773,7 +9034,7 @@ export declare const MODELS: {
8773
9034
  readonly "qwen3.8-max": {
8774
9035
  id: string;
8775
9036
  name: string;
8776
- api: "anthropic-messages";
9037
+ api: "openai-completions";
8777
9038
  provider: string;
8778
9039
  baseUrl: string;
8779
9040
  reasoning: true;
@@ -9826,6 +10087,23 @@ export declare const MODELS: {
9826
10087
  contextWindow: number;
9827
10088
  maxTokens: number;
9828
10089
  };
10090
+ readonly "dots-studio/dots-3-note-preview:free": {
10091
+ id: string;
10092
+ name: string;
10093
+ api: "openai-completions";
10094
+ provider: string;
10095
+ baseUrl: string;
10096
+ reasoning: true;
10097
+ input: ("image" | "text")[];
10098
+ cost: {
10099
+ input: number;
10100
+ output: number;
10101
+ cacheRead: number;
10102
+ cacheWrite: number;
10103
+ };
10104
+ contextWindow: number;
10105
+ maxTokens: number;
10106
+ };
9829
10107
  readonly "google/gemini-2.5-flash": {
9830
10108
  id: string;
9831
10109
  name: string;
@@ -13855,6 +14133,23 @@ export declare const MODELS: {
13855
14133
  contextWindow: number;
13856
14134
  maxTokens: number;
13857
14135
  };
14136
+ readonly "qwen/qwen3.8-27b": {
14137
+ id: string;
14138
+ name: string;
14139
+ api: "openai-completions";
14140
+ provider: string;
14141
+ baseUrl: string;
14142
+ reasoning: true;
14143
+ input: ("image" | "text")[];
14144
+ cost: {
14145
+ input: number;
14146
+ output: number;
14147
+ cacheRead: number;
14148
+ cacheWrite: number;
14149
+ };
14150
+ contextWindow: number;
14151
+ maxTokens: number;
14152
+ };
13858
14153
  readonly "qwen/qwen3.8-max": {
13859
14154
  id: string;
13860
14155
  name: string;
@@ -15098,6 +15393,23 @@ export declare const MODELS: {
15098
15393
  contextWindow: number;
15099
15394
  maxTokens: number;
15100
15395
  };
15396
+ readonly "alibaba/qwen3.8-27b": {
15397
+ id: string;
15398
+ name: string;
15399
+ api: "anthropic-messages";
15400
+ provider: string;
15401
+ baseUrl: string;
15402
+ reasoning: true;
15403
+ input: ("image" | "text")[];
15404
+ cost: {
15405
+ input: number;
15406
+ output: number;
15407
+ cacheRead: number;
15408
+ cacheWrite: number;
15409
+ };
15410
+ contextWindow: number;
15411
+ maxTokens: number;
15412
+ };
15101
15413
  readonly "alibaba/qwen3.8-max": {
15102
15414
  id: string;
15103
15415
  name: string;
@@ -15948,23 +16260,6 @@ export declare const MODELS: {
15948
16260
  contextWindow: number;
15949
16261
  maxTokens: number;
15950
16262
  };
15951
- readonly "inclusionai/ling-3.0-tiny-free": {
15952
- id: string;
15953
- name: string;
15954
- api: "anthropic-messages";
15955
- provider: string;
15956
- baseUrl: string;
15957
- reasoning: true;
15958
- input: "text"[];
15959
- cost: {
15960
- input: number;
15961
- output: number;
15962
- cacheRead: number;
15963
- cacheWrite: number;
15964
- };
15965
- contextWindow: number;
15966
- maxTokens: number;
15967
- };
15968
16263
  readonly "interfaze/interfaze-beta": {
15969
16264
  id: string;
15970
16265
  name: string;
@@ -16764,6 +17059,23 @@ export declare const MODELS: {
16764
17059
  contextWindow: number;
16765
17060
  maxTokens: number;
16766
17061
  };
17062
+ readonly "nvidia/nemotron-3.5-lightning": {
17063
+ id: string;
17064
+ name: string;
17065
+ api: "anthropic-messages";
17066
+ provider: string;
17067
+ baseUrl: string;
17068
+ reasoning: true;
17069
+ input: "text"[];
17070
+ cost: {
17071
+ input: number;
17072
+ output: number;
17073
+ cacheRead: number;
17074
+ cacheWrite: number;
17075
+ };
17076
+ contextWindow: number;
17077
+ maxTokens: number;
17078
+ };
16767
17079
  readonly "nvidia/nemotron-nano-12b-v2-vl": {
16768
17080
  id: string;
16769
17081
  name: string;
@@ -17774,7 +18086,7 @@ export declare const MODELS: {
17774
18086
  provider: string;
17775
18087
  baseUrl: string;
17776
18088
  reasoning: true;
17777
- input: "text"[];
18089
+ input: ("image" | "text")[];
17778
18090
  cost: {
17779
18091
  input: number;
17780
18092
  output: number;