@codeworksh/aikit 0.13.0 → 0.14.0-dev.20261106085021
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 +3 -3
- package/{copilot-D9T1jbpu.mjs → copilot-BnraENbo.mjs} +2 -2
- package/{copilot-D9T1jbpu.mjs.map → copilot-BnraENbo.mjs.map} +1 -1
- package/{copilot-headers-I-AOoDed.mjs → copilot-headers-O7LmAz_U.mjs} +2 -2
- package/{copilot-headers-I-AOoDed.mjs.map → copilot-headers-O7LmAz_U.mjs.map} +1 -1
- package/github-copilot-BqLzvkGs.mjs +3 -0
- package/{github-copilot-CdkIxdQS.mjs → github-copilot-OdlbT7il.mjs} +3 -3
- package/{github-copilot-CdkIxdQS.mjs.map → github-copilot-OdlbT7il.mjs.map} +1 -1
- package/index.mjs +14 -8
- package/index.mjs.map +1 -1
- package/{model-av44O6GQ.mjs → model-Bngx_P1p.mjs} +2 -2
- package/{model-av44O6GQ.mjs.map → model-Bngx_P1p.mjs.map} +1 -1
- package/{model-BZZZAySN.mjs → model-DHV-hzpF.mjs} +1 -59
- package/{model-BZZZAySN.mjs.map → model-DHV-hzpF.mjs.map} +1 -1
- package/{modelgen-f3yv7FiK.mjs → modelgen-BE_GuJZG.mjs} +9 -5
- package/modelgen-BE_GuJZG.mjs.map +1 -0
- package/modelgen.mjs +2 -2
- package/oauth/github/copilot.mjs +1 -1
- package/openai-codex-CLv1E2ED.mjs +2 -0
- package/{openai-codex-DL0lqVuN.mjs → openai-codex-DOAYxBAw.mjs} +2 -2
- package/{openai-codex-DL0lqVuN.mjs.map → openai-codex-DOAYxBAw.mjs.map} +1 -1
- package/package.json +1 -1
- package/{registry-BULNTLAP.mjs → registry-7CCwBZxQ.mjs} +4 -4
- package/{registry-BULNTLAP.mjs.map → registry-7CCwBZxQ.mjs.map} +1 -1
- package/github-copilot-C75m0xwW.mjs +0 -3
- package/modelgen-f3yv7FiK.mjs.map +0 -1
- package/openai-codex-BGNrJzTb.mjs +0 -2
|
@@ -546,64 +546,6 @@ var baseline_default = {
|
|
|
546
546
|
"xhigh": "xhigh"
|
|
547
547
|
}
|
|
548
548
|
},
|
|
549
|
-
"claude-sonnet-4-5": {
|
|
550
|
-
"api": {
|
|
551
|
-
"id": "claude-sonnet-4-5",
|
|
552
|
-
"method": "languageModel",
|
|
553
|
-
"url": "https://api.anthropic.com/v1"
|
|
554
|
-
},
|
|
555
|
-
"baseUrl": "https://api.anthropic.com/v1",
|
|
556
|
-
"contextWindow": 2e5,
|
|
557
|
-
"cost": {
|
|
558
|
-
"cacheRead": .3,
|
|
559
|
-
"cacheWrite": 3.75,
|
|
560
|
-
"input": 3,
|
|
561
|
-
"output": 15
|
|
562
|
-
},
|
|
563
|
-
"id": "claude-sonnet-4-5",
|
|
564
|
-
"input": ["text", "image"],
|
|
565
|
-
"maxTokens": 64e3,
|
|
566
|
-
"name": "Claude Sonnet 4.5 (latest)",
|
|
567
|
-
"npm": "@ai-sdk/anthropic",
|
|
568
|
-
"protocol": "anthropic",
|
|
569
|
-
"provider": {
|
|
570
|
-
"env": ["ANTHROPIC_API_KEY"],
|
|
571
|
-
"id": "anthropic",
|
|
572
|
-
"name": "Anthropic",
|
|
573
|
-
"source": "api"
|
|
574
|
-
},
|
|
575
|
-
"providerOptionsKey": "anthropic",
|
|
576
|
-
"reasoning": true
|
|
577
|
-
},
|
|
578
|
-
"claude-sonnet-4-5-20250929": {
|
|
579
|
-
"api": {
|
|
580
|
-
"id": "claude-sonnet-4-5-20250929",
|
|
581
|
-
"method": "languageModel",
|
|
582
|
-
"url": "https://api.anthropic.com/v1"
|
|
583
|
-
},
|
|
584
|
-
"baseUrl": "https://api.anthropic.com/v1",
|
|
585
|
-
"contextWindow": 2e5,
|
|
586
|
-
"cost": {
|
|
587
|
-
"cacheRead": .3,
|
|
588
|
-
"cacheWrite": 3.75,
|
|
589
|
-
"input": 3,
|
|
590
|
-
"output": 15
|
|
591
|
-
},
|
|
592
|
-
"id": "claude-sonnet-4-5-20250929",
|
|
593
|
-
"input": ["text", "image"],
|
|
594
|
-
"maxTokens": 64e3,
|
|
595
|
-
"name": "Claude Sonnet 4.5",
|
|
596
|
-
"npm": "@ai-sdk/anthropic",
|
|
597
|
-
"protocol": "anthropic",
|
|
598
|
-
"provider": {
|
|
599
|
-
"env": ["ANTHROPIC_API_KEY"],
|
|
600
|
-
"id": "anthropic",
|
|
601
|
-
"name": "Anthropic",
|
|
602
|
-
"source": "api"
|
|
603
|
-
},
|
|
604
|
-
"providerOptionsKey": "anthropic",
|
|
605
|
-
"reasoning": true
|
|
606
|
-
},
|
|
607
549
|
"claude-sonnet-4-6": {
|
|
608
550
|
"api": {
|
|
609
551
|
"id": "claude-sonnet-4-6",
|
|
@@ -13899,4 +13841,4 @@ function clampThinkingLevel(model, level) {
|
|
|
13899
13841
|
//#endregion
|
|
13900
13842
|
export { readJson as C, NamedError as E, path as S, writeJsonAtomic as T, modelsAreEqual as _, KnownProviderEnumSchema as a, registry as b, ThinkingLevel as c, effortThinkingLevels as d, getModel as f, model_exports as g, isAnthropicAdaptiveThinkingModel as h, KnownProviderEnum as i, calculateCost as l, getProviders as m, APIMethodEnumSchema as n, ProviderInfo as o, getModels as p, ActiveThinkingLevel as r, ThinkingBudgets as s, APIMethodEnum as t, clampThinkingLevel as u, normalizeInput as v, writeAtomic as w, thinkingTokenBudgetField as x, optionsKey as y };
|
|
13901
13843
|
|
|
13902
|
-
//# sourceMappingURL=model-
|
|
13844
|
+
//# sourceMappingURL=model-DHV-hzpF.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"model-BZZZAySN.mjs","names":["dirname","KnownProviderEnum","KnownProviderEnumSchema","Type","ModelCatalogLoadError","bundled","Filesystem.readText","ModelCatalog.KnownProviderEnum","ModelCatalog.KnownProviderEnumSchema","ModelCatalog.ModelCatalogLoadError","Type","ModelCatalog.path","ModelCatalog.get"],"sources":["../../src/utils/lazy.ts","../../src/utils/error.ts","../../src/utils/filesystem.ts","../../src/model/baseline.json","../../src/model/catalog.ts","../../src/model/model.ts"],"sourcesContent":["export function lazy<T>(fn: () => T) {\n\tlet value: T | undefined;\n\tlet loaded = false;\n\n\tconst result = (): T => {\n\t\tif (loaded) return value as T;\n\t\tvalue = fn();\n\t\tloaded = true;\n\t\treturn value as T;\n\t};\n\n\tresult.reset = () => {\n\t\tloaded = false;\n\t\tvalue = undefined;\n\t};\n\n\treturn result;\n}\n","import type { Static, TSchema } from \"typebox\";\n\ntype SchemaLike = TSchema;\ntype StaticData<Data extends SchemaLike> = Static<Data>;\n\nexport abstract class NamedError extends Error {\n\tabstract schema(): SchemaLike;\n\tabstract toObject(): { name: string; data: unknown };\n\n\tstatic create<Name extends string, Data extends SchemaLike>(name: Name, data: Data) {\n\t\tconst schema = {\n\t\t\t$id: name,\n\t\t\ttype: \"object\",\n\t\t\trequired: [\"name\", \"data\"],\n\t\t\tproperties: {\n\t\t\t\tname: {\n\t\t\t\t\tconst: name,\n\t\t\t\t},\n\t\t\t\tdata,\n\t\t\t},\n\t\t} as const;\n\n\t\tconst result = class extends NamedError {\n\t\t\tpublic static readonly Schema = schema;\n\n\t\t\tpublic override readonly name = name as Name;\n\n\t\t\tpublic readonly data: StaticData<Data>;\n\n\t\t\tconstructor(data: StaticData<Data>, options?: ErrorOptions) {\n\t\t\t\tsuper(name, options);\n\t\t\t\tthis.data = data;\n\t\t\t\tthis.name = name;\n\t\t\t}\n\n\t\t\tstatic isInstance(input: unknown): input is InstanceType<typeof result> {\n\t\t\t\treturn typeof input === \"object\" && input !== null && \"name\" in input && input.name === name;\n\t\t\t}\n\n\t\t\tschema() {\n\t\t\t\treturn schema;\n\t\t\t}\n\n\t\t\ttoObject() {\n\t\t\t\treturn {\n\t\t\t\t\tname,\n\t\t\t\t\tdata: this.data,\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\n\t\tObject.defineProperty(result, \"name\", { value: name });\n\t\treturn result;\n\t}\n\n\tpublic static readonly Unknown = NamedError.create(\"UnknownError\", {\n\t\ttype: \"object\",\n\t\trequired: [\"message\"],\n\t\tproperties: {\n\t\t\tmessage: {\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t},\n\t});\n}\n","import { mkdir, readFile, rename, rm, writeFile } from \"fs/promises\";\nimport { dirname } from \"path\";\n\nexport async function readText(path: string): Promise<string> {\n\treturn readFile(path, \"utf-8\");\n}\n\nexport async function readJson<T = unknown>(path: string): Promise<T> {\n\treturn JSON.parse(await readFile(path, \"utf-8\"));\n}\n\nfunction isEnoent(error: unknown): error is { code: \"ENOENT\" } {\n\treturn (\n\t\ttypeof error === \"object\" && error !== null && \"code\" in error && (error as { code: string }).code === \"ENOENT\"\n\t);\n}\n\nexport async function write(path: string, content: string | Buffer | Uint8Array, mode?: number): Promise<void> {\n\ttry {\n\t\tif (mode) {\n\t\t\tawait writeFile(path, content, { mode });\n\t\t} else {\n\t\t\tawait writeFile(path, content);\n\t\t}\n\t} catch (error) {\n\t\tif (isEnoent(error)) {\n\t\t\tawait mkdir(dirname(path), { recursive: true });\n\t\t\tif (mode) {\n\t\t\t\tawait writeFile(path, content, { mode });\n\t\t\t} else {\n\t\t\t\tawait writeFile(path, content);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tthrow error;\n\t}\n}\n\nexport async function writeJson(path: string, data: unknown, mode?: number): Promise<void> {\n\treturn write(path, JSON.stringify(data, null, 2), mode);\n}\n\n/**\n * Write through a temp file and rename it into place, so a concurrent reader\n * sees either the old content or the new, never a partial file.\n */\nexport async function writeAtomic(path: string, content: string | Buffer | Uint8Array): Promise<void> {\n\tconst temp = `${path}.${process.pid}.${Date.now()}.tmp`;\n\ttry {\n\t\tawait write(temp, content);\n\t\tawait rename(temp, path);\n\t} catch (error) {\n\t\tawait rm(temp, { force: true });\n\t\tthrow error;\n\t}\n}\n\nexport async function writeJsonAtomic(path: string, data: unknown): Promise<void> {\n\treturn writeAtomic(path, JSON.stringify(data, null, 2));\n}\n","","import { join, resolve } from \"node:path\";\nimport Type, { type Static } from \"typebox\";\nimport { NamedError } from \"../utils/error.ts\";\nimport * as Filesystem from \"../utils/filesystem.ts\";\nimport { lazy } from \"../utils/lazy.ts\";\nimport bundled from \"./baseline.json\" with { type: \"json\" };\n\n// known AI SDK LLM providers\n// used as the public protocol discriminator for the AI SDK transport layer\nexport const KnownProviderEnum = {\n\tanthropic: \"anthropic\",\n\tgoogle: \"google\",\n\tgoogleVertex: \"google-vertex\",\n\tgoogleVertexAnthropic: \"google-vertex-anthropic\",\n\tgithubCopilot: \"github-copilot\",\n\topenai: \"openai\",\n\topenaiCompatible: \"openai-compatible\",\n\topenaiCodex: \"openai-codex\",\n\topenrouter: \"openrouter\",\n\txai: \"xai\",\n} as const;\nexport const KnownProviderEnumSchema = Type.Union([\n\tType.Literal(KnownProviderEnum.anthropic),\n\tType.Literal(KnownProviderEnum.google),\n\tType.Literal(KnownProviderEnum.googleVertex),\n\tType.Literal(KnownProviderEnum.googleVertexAnthropic),\n\tType.Literal(KnownProviderEnum.githubCopilot),\n\tType.Literal(KnownProviderEnum.openai),\n\tType.Literal(KnownProviderEnum.openaiCompatible),\n\tType.Literal(KnownProviderEnum.openaiCodex),\n\tType.Literal(KnownProviderEnum.openrouter),\n\tType.Literal(KnownProviderEnum.xai),\n]);\nexport type KnownProviderEnum = Static<typeof KnownProviderEnumSchema>;\n\nexport type GeneratedCatalog = Partial<Record<string, Record<string, unknown>>>;\ntype LazyGeneratedCatalog = ReturnType<typeof lazy<Promise<GeneratedCatalog>>>;\n\nexport const ModelCatalogLoadError = NamedError.create(\n\t\"ModelCatalogLoadError\",\n\tType.Object({\n\t\tpath: Type.String(),\n\t\treason: Type.Union([Type.Literal(\"unreadable\"), Type.Literal(\"empty\"), Type.Literal(\"invalid\")]),\n\t\tmessage: Type.String(),\n\t}),\n);\nexport type ModelCatalogLoadError = InstanceType<typeof ModelCatalogLoadError>;\n\nexport function projectRoot(): string {\n\treturn process.cwd();\n}\n\nexport const filename = \"models.gen.json\";\n\nlet configured: string | undefined;\n\n/**\n * Read the catalog from `catalogPath` instead of `./models.gen.json`, for an\n * embedder that keeps it elsewhere. `CODEWORK_MODELS_FILE` still wins.\n */\nexport function configure(catalogPath: string): void {\n\tconfigured = resolve(catalogPath);\n\tdata.reset();\n}\n\nexport function path(): string {\n\treturn resolve(process.env.CODEWORK_MODELS_FILE ?? configured ?? join(projectRoot(), filename));\n}\n\n/**\n * The catalog bundled with aikit for OpenAI, Anthropic and OpenRouter (`aikit modelgen --baseline`),\n * so a first run works before any catalog was generated.\n */\nexport const baseline: GeneratedCatalog = bundled;\n\n/**\n * The catalog at `catalogPath` over the {@link baseline}: a provider the file lists replaces the\n * bundled one, so a fresh generated catalog wins and an older one still gets the bundled providers.\n * A missing file reads as the baseline alone.\n */\nexport async function load(catalogPath = path()): Promise<GeneratedCatalog> {\n\tlet content: string;\n\ttry {\n\t\tcontent = await Filesystem.readText(catalogPath);\n\t} catch (cause) {\n\t\tconst value =\n\t\t\ttypeof cause === \"object\" && cause !== null && \"code\" in cause && typeof cause.code === \"string\"\n\t\t\t\t? cause.code\n\t\t\t\t: undefined;\n\t\tif (value === \"ENOENT\") return { ...baseline };\n\t\tthrow new ModelCatalogLoadError(\n\t\t\t{ path: catalogPath, reason: \"unreadable\", message: `model catalog could not be read at ${catalogPath}` },\n\t\t\t{ cause },\n\t\t);\n\t}\n\tif (!content.trim()) {\n\t\tthrow new ModelCatalogLoadError({\n\t\t\tpath: catalogPath,\n\t\t\treason: \"empty\",\n\t\t\tmessage: `model catalog is empty at ${catalogPath}`,\n\t\t});\n\t}\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(content);\n\t\tif (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) throw new Error(\"expected an object\");\n\t\treturn { ...baseline, ...(parsed as GeneratedCatalog) };\n\t} catch (cause) {\n\t\tthrow new ModelCatalogLoadError(\n\t\t\t{\n\t\t\t\tpath: catalogPath,\n\t\t\t\treason: \"invalid\",\n\t\t\t\tmessage: `model catalog contains invalid json at ${catalogPath}`,\n\t\t\t},\n\t\t\t{ cause },\n\t\t);\n\t}\n}\n\nexport const data: LazyGeneratedCatalog = lazy(() => load());\n\nexport async function get(): Promise<GeneratedCatalog> {\n\treturn data();\n}\n","import Type, { type Static } from \"typebox\";\nimport { lazy } from \"../utils/lazy.ts\";\nimport * as ModelCatalog from \"./catalog.ts\";\n\n// re-export\nexport const KnownProviderEnum = ModelCatalog.KnownProviderEnum;\nexport const KnownProviderEnumSchema = ModelCatalog.KnownProviderEnumSchema;\nexport type KnownProviderEnum = ModelCatalog.KnownProviderEnum;\n\nexport const ModelCatalogLoadError = ModelCatalog.ModelCatalogLoadError;\nexport type ModelCatalogLoadError = ModelCatalog.ModelCatalogLoadError;\n\n// Common reasoning-effort levels used by adapters that expose model reasoning,\n// thinking, or deliberation controls. Protocol-specific layers can map these\n// values to native fields like OpenAI `reasoning_effort`, Anthropic `thinking`,\n// or Gemini `thinkingConfig`.\nexport const ThinkingLevelEnum = {\n\t// Disable explicit reasoning controls when the provider supports turning them off.\n\toff: \"off\",\n\t// Smallest reasoning budget/effort above off; useful for fastest low-cost responses.\n\tminimal: \"minimal\",\n\t// Light reasoning for simple tasks that still benefit from some deliberation.\n\tlow: \"low\",\n\t// Balanced default for general tasks.\n\tmedium: \"medium\",\n\t// Higher reasoning effort for complex coding, analysis, or planning.\n\thigh: \"high\",\n\t// Extra-high reasoning effort for difficult tasks when supported by the model.\n\txhigh: \"xhigh\",\n\t// Maximum provider-defined effort above xhigh when explicitly supported by the model.\n\tmax: \"max\",\n} as const;\n\nexport const ThinkingLevel = Type.Union([\n\tType.Literal(ThinkingLevelEnum.off),\n\tType.Literal(ThinkingLevelEnum.minimal),\n\tType.Literal(ThinkingLevelEnum.low),\n\tType.Literal(ThinkingLevelEnum.medium),\n\tType.Literal(ThinkingLevelEnum.high),\n\tType.Literal(ThinkingLevelEnum.xhigh),\n\tType.Literal(ThinkingLevelEnum.max),\n]);\nexport type ThinkingLevel = Static<typeof ThinkingLevel>;\n\nexport const ActiveThinkingLevel = Type.Union([\n\tType.Literal(ThinkingLevelEnum.minimal),\n\tType.Literal(ThinkingLevelEnum.low),\n\tType.Literal(ThinkingLevelEnum.medium),\n\tType.Literal(ThinkingLevelEnum.high),\n\tType.Literal(ThinkingLevelEnum.xhigh),\n\tType.Literal(ThinkingLevelEnum.max),\n]);\nexport type ActiveThinkingLevel = Static<typeof ActiveThinkingLevel>;\n\nexport const ThinkingBudgets = Type.Partial(Type.Record(ActiveThinkingLevel, Type.Number()));\nexport type ThinkingBudgets = Static<typeof ThinkingBudgets>;\n\n// Note: order of entries matters!\nconst ACTIVE_THINKING_LEVELS = [\n\tThinkingLevelEnum.minimal,\n\tThinkingLevelEnum.low,\n\tThinkingLevelEnum.medium,\n\tThinkingLevelEnum.high,\n\tThinkingLevelEnum.xhigh,\n\tThinkingLevelEnum.max,\n] as const satisfies readonly ActiveThinkingLevel[];\nconst MODEL_THINKING_LEVELS = [\n\tThinkingLevelEnum.off,\n\t...ACTIVE_THINKING_LEVELS,\n] as const satisfies readonly ThinkingLevel[];\n\nexport const ProviderInfo = Type.Object({\n\tid: Type.String(),\n\tname: Type.String(),\n\tsource: Type.Enum([\"env\", \"config\", \"custom\", \"api\", \"unknown\"]),\n\tenv: Type.Array(Type.String()),\n\tkey: Type.Optional(Type.String()), // runtime api/oauth key\n\toptions: Type.Optional(Type.Record(Type.String(), Type.Any())),\n});\nexport type ProviderInfo = Static<typeof ProviderInfo>;\n\nconst InputSchema = Type.Array(Type.Union([Type.Literal(\"text\"), Type.Literal(\"image\")]));\nconst CostRatesSchema = Type.Object({\n\tinput: Type.Number(),\n\toutput: Type.Number(),\n\tcacheRead: Type.Number(),\n\tcacheWrite: Type.Number(),\n});\nconst CostTierSchema = Type.Object({\n\t...CostRatesSchema.properties,\n\tinputTokensAbove: Type.Number(),\n});\nconst CostSchema = Type.Object({\n\t...CostRatesSchema.properties,\n\ttiers: Type.Optional(Type.Array(CostTierSchema)),\n\tserviceTierMultipliers: Type.Optional(Type.Record(Type.String(), Type.Number())),\n});\nconst SupportedProtocolsSchema = Type.Partial(\n\tType.Object({\n\t\tanthropic: KnownProviderEnumSchema,\n\t\tgoogle: KnownProviderEnumSchema,\n\t\tgoogleVertex: KnownProviderEnumSchema,\n\t\tgoogleVertexAnthropic: KnownProviderEnumSchema,\n\t\tgithubCopilot: KnownProviderEnumSchema,\n\t\topenai: KnownProviderEnumSchema,\n\t\topenaiCompatible: KnownProviderEnumSchema,\n\t\topenaiCodex: KnownProviderEnumSchema,\n\t\topenrouter: KnownProviderEnumSchema,\n\t\txai: KnownProviderEnumSchema,\n\t}),\n);\n\nexport const APIMethodEnum = {\n\tlanguageModel: \"languageModel\",\n\tchat: \"chat\",\n\tcompletion: \"completion\",\n\tcompletionModel: \"completionModel\",\n\tmessages: \"messages\",\n\tresponses: \"responses\",\n} as const;\nexport const APIMethodEnumSchema = Type.Union([\n\tType.Literal(APIMethodEnum.languageModel),\n\tType.Literal(APIMethodEnum.chat),\n\tType.Literal(APIMethodEnum.completion),\n\tType.Literal(APIMethodEnum.completionModel),\n\tType.Literal(APIMethodEnum.messages),\n\tType.Literal(APIMethodEnum.responses),\n]);\nexport type APIMethodEnum = Static<typeof APIMethodEnumSchema>;\n\nexport const APIMetadataSchema = Type.Object({\n\tid: Type.Optional(Type.String()),\n\turl: Type.Optional(Type.String()),\n\tmethod: Type.Optional(APIMethodEnumSchema),\n});\nexport type APIMetadata = Static<typeof APIMetadataSchema>;\n\nexport const ThinkingLevelMapSchema = Type.Partial(\n\tType.Record(\n\t\tThinkingLevel, // Safe key validation\n\t\tType.Union([Type.String(), Type.Null()]), // Allowed values\n\t),\n);\nexport type ThinkingLevelMap = Static<typeof ThinkingLevelMapSchema>;\n\n/**\n * The level map for a model that lists the reasoning efforts it accepts (models.dev\n * `reasoning_options`, OpenRouter `supported_efforts`): a level maps to itself only when listed,\n * and off maps to `none` only when `none` is listed (pi). Undefined when nothing usable is listed.\n */\nexport function effortThinkingLevels(efforts: ReadonlyArray<string | null>): ThinkingLevelMap | undefined {\n\tconst supported = new Set(efforts);\n\tif (!ACTIVE_THINKING_LEVELS.some((level) => supported.has(level)) && !supported.has(\"none\")) return undefined;\n\tconst map: ThinkingLevelMap = { off: supported.has(\"none\") ? \"none\" : null };\n\tfor (const level of ACTIVE_THINKING_LEVELS) map[level] = supported.has(level) ? level : null;\n\treturn map;\n}\n\nexport const CompatibilitySchema = Type.Object({\n\t/** The Google protocol accepts thinking levels rather than a token budget. */\n\tsupportsThinkingLevel: Type.Optional(Type.Boolean()),\n\tsupportsToolSearch: Type.Optional(Type.Boolean()),\n\t/**\n\t * Tool changes go in place: Responses `additional_tools` items, Anthropic tool references.\n\t * Requires `supportsMidConvoSystemMessages`.\n\t */\n\tsupportsAdditionalTools: Type.Optional(Type.Boolean()),\n\t/** The model accepts developer messages after the conversation has started. */\n\tsupportsMidConvoSystemMessages: Type.Optional(Type.Boolean()),\n\tsupportsStrictMode: Type.Optional(Type.Boolean()),\n\tsupportsOpenAIGrammarTools: Type.Optional(Type.Boolean()),\n\t/** The model takes a thinking-token budget as a top-level request field. */\n\tsupportsThinkingTokenBudget: Type.Optional(Type.Boolean()),\n\t/** Claude model that sizes its own thinking, driven by `effort` instead of a token budget. */\n\tforceAdaptiveThinking: Type.Optional(Type.Boolean()),\n\t/** False for a model that rejects a `temperature` field; the request then leaves it out. */\n\tsupportsTemperature: Type.Optional(Type.Boolean()),\n\t/** Name of that field, when it is not the conventional `thinking_token_budget`. */\n\tthinkingTokenBudgetField: Type.Optional(Type.String()),\n});\nexport type Compatibility = Static<typeof CompatibilitySchema>;\n\n/**\n * Claude models that decide their own thinking depth.\n *\n * These take an `effort` level and let the model size each turn's reasoning; the\n * older models take a fixed `budget_tokens` instead. Sending a budget to an\n * adaptive model pins it to one depth for every turn, which is the thing adaptive\n * thinking exists to avoid.\n */\nexport function isAnthropicAdaptiveThinkingModel(modelId: string): boolean {\n\treturn [\n\t\t\"opus-4-6\",\n\t\t\"opus-4.6\",\n\t\t\"opus-4-7\",\n\t\t\"opus-4.7\",\n\t\t\"opus-4-8\",\n\t\t\"opus-4.8\",\n\t\t\"opus-5\",\n\t\t\"opus.5\",\n\t\t\"sonnet-4-6\",\n\t\t\"sonnet-4.6\",\n\t\t\"sonnet-5\",\n\t\t\"sonnet.5\",\n\t\t\"fable-5\",\n\t\t\"haiku-5\",\n\t\t\"haiku.5\",\n\t].some((needle) => modelId.includes(needle));\n}\n\nexport const Schema = Type.Object({\n\tid: Type.String(),\n\tname: Type.String(),\n\tprovider: ProviderInfo,\n\tbaseUrl: Type.String(),\n\treasoning: Type.Boolean(),\n\tthinkingLevelMap: Type.Optional(ThinkingLevelMapSchema),\n\t/** Default budgets; request-level thinkingBudgets take precedence. */\n\tthinkingBudgets: Type.Optional(ThinkingBudgets),\n\tinput: InputSchema,\n\tcost: CostSchema,\n\tcontextWindow: Type.Number(),\n\tmaxTokens: Type.Number(),\n\theaders: Type.Optional(Type.Record(Type.String(), Type.String())),\n\tnpm: Type.Optional(Type.String()),\n\tapi: Type.Optional(APIMetadataSchema),\n\tproviderOptionsKey: Type.Optional(Type.String()),\n\toptions: Type.Optional(Type.Record(Type.String(), Type.Unknown())),\n\tproviderOptions: Type.Optional(Type.Record(Type.String(), Type.Unknown())),\n\tcompat: Type.Optional(CompatibilitySchema),\n\tprotocol: KnownProviderEnumSchema, // provider as the underlying protocol\n\tsupportedProtocols: Type.Optional(SupportedProtocolsSchema), // provider as the underlying supported protocols\n});\n\nexport const ExtrasSchema = Type.Object({});\n\nexport const Info = Type.Evaluate(Type.Intersect([Schema, ExtrasSchema]));\nexport type Info = Static<typeof Info>;\nexport type TModel<TProtocol extends KnownProviderEnum> = Omit<Info, \"protocol\"> & { protocol: TProtocol };\n\nexport function calculateCost(\n\tmodel: Info,\n\tusage: {\n\t\tinput: number;\n\t\toutput: number;\n\t\tcacheRead: number;\n\t\tcacheWrite: number;\n\t\tcacheWrite1h?: number;\n\t\tcost: {\n\t\t\tinput: number;\n\t\t\toutput: number;\n\t\t\tcacheRead: number;\n\t\t\tcacheWrite: number;\n\t\t\ttotal: number;\n\t\t};\n\t},\n): void {\n\tconst inputTokens = usage.input + usage.cacheRead + usage.cacheWrite;\n\tlet rates = model.cost;\n\tlet matchedThreshold = -1;\n\tfor (const tier of model.cost.tiers ?? []) {\n\t\tif (inputTokens > tier.inputTokensAbove && tier.inputTokensAbove > matchedThreshold) {\n\t\t\trates = tier;\n\t\t\tmatchedThreshold = tier.inputTokensAbove;\n\t\t}\n\t}\n\n\t// Anthropic charges 2x base input for 1h cache writes; `cost.cacheWrite` is the 5m rate.\n\tconst longWrite = usage.cacheWrite1h ?? 0;\n\tconst shortWrite = usage.cacheWrite - longWrite;\n\n\tusage.cost.input = (usage.input / 1_000_000) * rates.input;\n\tusage.cost.output = (usage.output / 1_000_000) * rates.output;\n\tusage.cost.cacheRead = (usage.cacheRead / 1_000_000) * rates.cacheRead;\n\tusage.cost.cacheWrite = (rates.cacheWrite * shortWrite + rates.input * 2 * longWrite) / 1_000_000;\n\tusage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;\n}\n\nexport type BuiltInModels = Partial<Record<string, Record<string, Info>>>;\n\nexport function normalizeInput(input?: string[]): Array<\"text\" | \"image\"> {\n\tconst normalized = new Set<\"text\" | \"image\">();\n\tfor (const modality of input ?? [\"text\"]) {\n\t\tif (modality === \"text\" || modality === \"image\") {\n\t\t\tnormalized.add(modality);\n\t\t}\n\t}\n\tif (normalized.size === 0) normalized.add(\"text\");\n\treturn [...normalized];\n}\n\n/** Where the catalog is read from: `CODEWORK_MODELS_FILE`, the configured path, or `./models.gen.json`. */\nexport const catalogPath = ModelCatalog.path;\n\n/** Read the catalog from `path` from now on, dropping whatever was already loaded. */\nexport function configureCatalog(path: string): void {\n\tModelCatalog.configure(path);\n\tregistry.reset();\n}\n\n/** Drop the loaded catalog, so the next lookup re-reads the file -- after it was regenerated. */\nexport function reloadCatalog(): void {\n\tModelCatalog.data.reset();\n\tregistry.reset();\n}\n\nexport async function getBuiltInModels(): Promise<BuiltInModels> {\n\treturn (await ModelCatalog.get()) as BuiltInModels;\n}\n\nexport const registry = lazy(async () => {\n\tconst registry: Map<string, Map<string, Info>> = new Map();\n\tconst models = await getBuiltInModels();\n\tfor (const [provider, value] of Object.entries(models) as Array<[string, Record<string, Info>]>) {\n\t\tconst providerModels = new Map<string, Info>();\n\t\tfor (const [id, model] of Object.entries(value)) {\n\t\t\tproviderModels.set(id, model);\n\t\t}\n\t\tregistry.set(provider, providerModels);\n\t}\n\treturn registry;\n});\n\n/**\n * The key a provider's own option bag is filed under.\n *\n * Providers that speak another provider's protocol still carry their own option\n * namespace, so this is not always the protocol.\n */\n/**\n * The request-body field a model takes its thinking-token budget in, if any.\n *\n * OpenAI-compatible endpoints have no standard place for this, so each one names\n * its own field; a bare `supportsThinkingTokenBudget` means the conventional name.\n */\nexport function thinkingTokenBudgetField(model: Info): string | undefined {\n\tif (model.compat?.thinkingTokenBudgetField) return model.compat.thinkingTokenBudgetField;\n\treturn model.compat?.supportsThinkingTokenBudget ? \"thinking_token_budget\" : undefined;\n}\n\nexport function optionsKey(model: Info): string {\n\treturn model.providerOptionsKey ?? model.protocol;\n}\n\nexport function supportsProtocol(model: Info, protocol: KnownProviderEnum): boolean {\n\tif (model.protocol === protocol) return true;\n\treturn Object.values(model.supportedProtocols ?? {}).includes(protocol);\n}\n\nexport type ProviderToProtocol<TProvider extends string> = TProvider extends KnownProviderEnum\n\t? TProvider\n\t: KnownProviderEnum;\n\nexport async function getModel<\n\tTProvider extends string,\n\tTProtocol extends KnownProviderEnum = ProviderToProtocol<TProvider>,\n>(\n\tprovider: TProvider,\n\tmodel: string,\n\toverrides?: Partial<Info> & { protocol?: TProtocol },\n): Promise<TModel<TProtocol> | undefined> {\n\tconst data = await registry();\n\tconst providerModels = data.get(provider);\n\tconst result = providerModels?.get(model);\n\tif (result && overrides) {\n\t\tif (overrides.protocol && !supportsProtocol(result, overrides.protocol)) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn {\n\t\t\t...result,\n\t\t\t...overrides,\n\t\t} as TModel<TProtocol>;\n\t}\n\treturn result as TModel<TProtocol> | undefined;\n}\n\nexport async function getProviders(): Promise<string[]> {\n\tconst data = await registry();\n\treturn Array.from(data.keys());\n}\n\nexport async function getModels<TProvider extends string>(provider: TProvider): Promise<Info[]> {\n\tconst data = await registry();\n\tconst models = data.get(provider);\n\treturn models ? Array.from(models.values()) : [];\n}\n\n/**\n * Check if two models are equal by comparing both their id and provider id.\n * Returns false if either model is null or undefined.\n */\nexport function modelsAreEqual(a: Info | null | undefined, b: Info | null | undefined): boolean {\n\tif (!a || !b) return false;\n\treturn a.id === b.id && a.provider.id === b.provider.id;\n}\n\nexport function getSupportedThinkingLevels<TProtocol extends KnownProviderEnum>(\n\tmodel: TModel<TProtocol>,\n): ThinkingLevel[] {\n\tif (!model.reasoning) return [\"off\"];\n\n\treturn MODEL_THINKING_LEVELS.filter((level) => {\n\t\tconst mapped = model.thinkingLevelMap?.[level];\n\t\tif (mapped === null) return false;\n\t\tif (level === \"xhigh\" || level === \"max\") return mapped !== undefined;\n\t\treturn true;\n\t});\n}\n\nexport function clampThinkingLevel<TProtocol extends KnownProviderEnum>(\n\tmodel: TModel<TProtocol>,\n\tlevel: ThinkingLevel,\n): ThinkingLevel {\n\tconst availableLevels = getSupportedThinkingLevels(model);\n\tif (availableLevels.includes(level)) return level;\n\n\tconst requestedIndex = MODEL_THINKING_LEVELS.indexOf(level);\n\tif (requestedIndex === -1) return availableLevels[0] ?? \"off\";\n\n\t// walk up the ladder from the point and pick first supported\n\t// biased to avail more thinking, then less not round to nearest.\n\tfor (let i = requestedIndex; i < MODEL_THINKING_LEVELS.length; i++) {\n\t\tconst candidate = MODEL_THINKING_LEVELS[i]!;\n\t\tif (availableLevels.includes(candidate)) return candidate;\n\t}\n\t// otherwise walk down from the point\n\tfor (let i = requestedIndex - 1; i >= 0; i--) {\n\t\tconst candidate = MODEL_THINKING_LEVELS[i]!;\n\t\tif (availableLevels.includes(candidate)) return candidate;\n\t}\n\treturn availableLevels[0] ?? \"off\";\n}\n"],"mappings":";;;;;;AAAA,SAAgB,KAAQ,IAAa;CACpC,IAAI;CACJ,IAAI,SAAS;CAEb,MAAM,eAAkB;EACvB,IAAI,QAAQ,OAAO;EACnB,QAAQ,GAAG;EACX,SAAS;EACT,OAAO;CACR;CAEA,OAAO,cAAc;EACpB,SAAS;EACT,QAAQ,KAAA;CACT;CAEA,OAAO;AACR;;;ACZA,IAAsB,aAAtB,MAAsB,mBAAmB,MAAM;CAI9C,OAAO,OAAqD,MAAY,MAAY;EACnF,MAAM,SAAS;GACd,KAAK;GACL,MAAM;GACN,UAAU,CAAC,QAAQ,MAAM;GACzB,YAAY;IACX,MAAM,EACL,OAAO,KACR;IACA;GACD;EACD;EAEA,MAAM,SAAS,cAAc,WAAW;GACvC,OAAuB,SAAS;GAEhC,OAAgC;GAEhC;GAEA,YAAY,MAAwB,SAAwB;IAC3D,MAAM,MAAM,OAAO;IACnB,KAAK,OAAO;IACZ,KAAK,OAAO;GACb;GAEA,OAAO,WAAW,OAAsD;IACvE,OAAO,OAAO,UAAU,YAAY,UAAU,QAAQ,UAAU,SAAS,MAAM,SAAS;GACzF;GAEA,SAAS;IACR,OAAO;GACR;GAEA,WAAW;IACV,OAAO;KACN;KACA,MAAM,KAAK;IACZ;GACD;EACD;EAEA,OAAO,eAAe,QAAQ,QAAQ,EAAE,OAAO,KAAK,CAAC;EACrD,OAAO;CACR;CAEA,OAAuB,UAAU,WAAW,OAAO,gBAAgB;EAClE,MAAM;EACN,UAAU,CAAC,SAAS;EACpB,YAAY,EACX,SAAS,EACR,MAAM,SACP,EACD;CACD,CAAC;AACF;;;AC7DA,eAAsB,SAAS,MAA+B;CAC7D,OAAO,SAAS,MAAM,OAAO;AAC9B;AAEA,eAAsB,SAAsB,MAA0B;CACrE,O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;;;;;AAMA,SAAgB,eAAe,GAA4B,GAAqC;CAC/F,IAAI,CAAC,KAAK,CAAC,GAAG,OAAO;CACrB,OAAO,EAAE,OAAO,EAAE,MAAM,EAAE,SAAS,OAAO,EAAE,SAAS;AACtD;AAEA,SAAgB,2BACf,OACkB;CAClB,IAAI,CAAC,MAAM,WAAW,OAAO,CAAC,KAAK;CAEnC,OAAO,sBAAsB,QAAQ,UAAU;EAC9C,MAAM,SAAS,MAAM,mBAAmB;EACxC,IAAI,WAAW,MAAM,OAAO;EAC5B,IAAI,UAAU,WAAW,UAAU,OAAO,OAAO,WAAW,KAAA;EAC5D,OAAO;CACR,CAAC;AACF;AAEA,SAAgB,mBACf,OACA,OACgB;CAChB,MAAM,kBAAkB,2BAA2B,KAAK;CACxD,IAAI,gBAAgB,SAAS,KAAK,GAAG,OAAO;CAE5C,MAAM,iBAAiB,sBAAsB,QAAQ,KAAK;CAC1D,IAAI,mBAAmB,IAAI,OAAO,gBAAgB,MAAM;CAIxD,KAAK,IAAI,IAAI,gBAAgB,IAAI,sBAAsB,QAAQ,KAAK;EACnE,MAAM,YAAY,sBAAsB;EACxC,IAAI,gBAAgB,SAAS,SAAS,GAAG,OAAO;CACjD;CAEA,KAAK,IAAI,IAAI,iBAAiB,GAAG,KAAK,GAAG,KAAK;EAC7C,MAAM,YAAY,sBAAsB;EACxC,IAAI,gBAAgB,SAAS,SAAS,GAAG,OAAO;CACjD;CACA,OAAO,gBAAgB,MAAM;AAC9B"}
|
|
1
|
+
{"version":3,"file":"model-DHV-hzpF.mjs","names":["dirname","KnownProviderEnum","KnownProviderEnumSchema","Type","ModelCatalogLoadError","bundled","Filesystem.readText","ModelCatalog.KnownProviderEnum","ModelCatalog.KnownProviderEnumSchema","ModelCatalog.ModelCatalogLoadError","Type","ModelCatalog.path","ModelCatalog.get"],"sources":["../../src/utils/lazy.ts","../../src/utils/error.ts","../../src/utils/filesystem.ts","../../src/model/baseline.json","../../src/model/catalog.ts","../../src/model/model.ts"],"sourcesContent":["export function lazy<T>(fn: () => T) {\n\tlet value: T | undefined;\n\tlet loaded = false;\n\n\tconst result = (): T => {\n\t\tif (loaded) return value as T;\n\t\tvalue = fn();\n\t\tloaded = true;\n\t\treturn value as T;\n\t};\n\n\tresult.reset = () => {\n\t\tloaded = false;\n\t\tvalue = undefined;\n\t};\n\n\treturn result;\n}\n","import type { Static, TSchema } from \"typebox\";\n\ntype SchemaLike = TSchema;\ntype StaticData<Data extends SchemaLike> = Static<Data>;\n\nexport abstract class NamedError extends Error {\n\tabstract schema(): SchemaLike;\n\tabstract toObject(): { name: string; data: unknown };\n\n\tstatic create<Name extends string, Data extends SchemaLike>(name: Name, data: Data) {\n\t\tconst schema = {\n\t\t\t$id: name,\n\t\t\ttype: \"object\",\n\t\t\trequired: [\"name\", \"data\"],\n\t\t\tproperties: {\n\t\t\t\tname: {\n\t\t\t\t\tconst: name,\n\t\t\t\t},\n\t\t\t\tdata,\n\t\t\t},\n\t\t} as const;\n\n\t\tconst result = class extends NamedError {\n\t\t\tpublic static readonly Schema = schema;\n\n\t\t\tpublic override readonly name = name as Name;\n\n\t\t\tpublic readonly data: StaticData<Data>;\n\n\t\t\tconstructor(data: StaticData<Data>, options?: ErrorOptions) {\n\t\t\t\tsuper(name, options);\n\t\t\t\tthis.data = data;\n\t\t\t\tthis.name = name;\n\t\t\t}\n\n\t\t\tstatic isInstance(input: unknown): input is InstanceType<typeof result> {\n\t\t\t\treturn typeof input === \"object\" && input !== null && \"name\" in input && input.name === name;\n\t\t\t}\n\n\t\t\tschema() {\n\t\t\t\treturn schema;\n\t\t\t}\n\n\t\t\ttoObject() {\n\t\t\t\treturn {\n\t\t\t\t\tname,\n\t\t\t\t\tdata: this.data,\n\t\t\t\t};\n\t\t\t}\n\t\t};\n\n\t\tObject.defineProperty(result, \"name\", { value: name });\n\t\treturn result;\n\t}\n\n\tpublic static readonly Unknown = NamedError.create(\"UnknownError\", {\n\t\ttype: \"object\",\n\t\trequired: [\"message\"],\n\t\tproperties: {\n\t\t\tmessage: {\n\t\t\t\ttype: \"string\",\n\t\t\t},\n\t\t},\n\t});\n}\n","import { mkdir, readFile, rename, rm, writeFile } from \"fs/promises\";\nimport { dirname } from \"path\";\n\nexport async function readText(path: string): Promise<string> {\n\treturn readFile(path, \"utf-8\");\n}\n\nexport async function readJson<T = unknown>(path: string): Promise<T> {\n\treturn JSON.parse(await readFile(path, \"utf-8\"));\n}\n\nfunction isEnoent(error: unknown): error is { code: \"ENOENT\" } {\n\treturn (\n\t\ttypeof error === \"object\" && error !== null && \"code\" in error && (error as { code: string }).code === \"ENOENT\"\n\t);\n}\n\nexport async function write(path: string, content: string | Buffer | Uint8Array, mode?: number): Promise<void> {\n\ttry {\n\t\tif (mode) {\n\t\t\tawait writeFile(path, content, { mode });\n\t\t} else {\n\t\t\tawait writeFile(path, content);\n\t\t}\n\t} catch (error) {\n\t\tif (isEnoent(error)) {\n\t\t\tawait mkdir(dirname(path), { recursive: true });\n\t\t\tif (mode) {\n\t\t\t\tawait writeFile(path, content, { mode });\n\t\t\t} else {\n\t\t\t\tawait writeFile(path, content);\n\t\t\t}\n\t\t\treturn;\n\t\t}\n\t\tthrow error;\n\t}\n}\n\nexport async function writeJson(path: string, data: unknown, mode?: number): Promise<void> {\n\treturn write(path, JSON.stringify(data, null, 2), mode);\n}\n\n/**\n * Write through a temp file and rename it into place, so a concurrent reader\n * sees either the old content or the new, never a partial file.\n */\nexport async function writeAtomic(path: string, content: string | Buffer | Uint8Array): Promise<void> {\n\tconst temp = `${path}.${process.pid}.${Date.now()}.tmp`;\n\ttry {\n\t\tawait write(temp, content);\n\t\tawait rename(temp, path);\n\t} catch (error) {\n\t\tawait rm(temp, { force: true });\n\t\tthrow error;\n\t}\n}\n\nexport async function writeJsonAtomic(path: string, data: unknown): Promise<void> {\n\treturn writeAtomic(path, JSON.stringify(data, null, 2));\n}\n","","import { join, resolve } from \"node:path\";\nimport Type, { type Static } from \"typebox\";\nimport { NamedError } from \"../utils/error.ts\";\nimport * as Filesystem from \"../utils/filesystem.ts\";\nimport { lazy } from \"../utils/lazy.ts\";\nimport bundled from \"./baseline.json\" with { type: \"json\" };\n\n// known AI SDK LLM providers\n// used as the public protocol discriminator for the AI SDK transport layer\nexport const KnownProviderEnum = {\n\tanthropic: \"anthropic\",\n\tgoogle: \"google\",\n\tgoogleVertex: \"google-vertex\",\n\tgoogleVertexAnthropic: \"google-vertex-anthropic\",\n\tgithubCopilot: \"github-copilot\",\n\topenai: \"openai\",\n\topenaiCompatible: \"openai-compatible\",\n\topenaiCodex: \"openai-codex\",\n\topenrouter: \"openrouter\",\n\txai: \"xai\",\n} as const;\nexport const KnownProviderEnumSchema = Type.Union([\n\tType.Literal(KnownProviderEnum.anthropic),\n\tType.Literal(KnownProviderEnum.google),\n\tType.Literal(KnownProviderEnum.googleVertex),\n\tType.Literal(KnownProviderEnum.googleVertexAnthropic),\n\tType.Literal(KnownProviderEnum.githubCopilot),\n\tType.Literal(KnownProviderEnum.openai),\n\tType.Literal(KnownProviderEnum.openaiCompatible),\n\tType.Literal(KnownProviderEnum.openaiCodex),\n\tType.Literal(KnownProviderEnum.openrouter),\n\tType.Literal(KnownProviderEnum.xai),\n]);\nexport type KnownProviderEnum = Static<typeof KnownProviderEnumSchema>;\n\nexport type GeneratedCatalog = Partial<Record<string, Record<string, unknown>>>;\ntype LazyGeneratedCatalog = ReturnType<typeof lazy<Promise<GeneratedCatalog>>>;\n\nexport const ModelCatalogLoadError = NamedError.create(\n\t\"ModelCatalogLoadError\",\n\tType.Object({\n\t\tpath: Type.String(),\n\t\treason: Type.Union([Type.Literal(\"unreadable\"), Type.Literal(\"empty\"), Type.Literal(\"invalid\")]),\n\t\tmessage: Type.String(),\n\t}),\n);\nexport type ModelCatalogLoadError = InstanceType<typeof ModelCatalogLoadError>;\n\nexport function projectRoot(): string {\n\treturn process.cwd();\n}\n\nexport const filename = \"models.gen.json\";\n\nlet configured: string | undefined;\n\n/**\n * Read the catalog from `catalogPath` instead of `./models.gen.json`, for an\n * embedder that keeps it elsewhere. `CODEWORK_MODELS_FILE` still wins.\n */\nexport function configure(catalogPath: string): void {\n\tconfigured = resolve(catalogPath);\n\tdata.reset();\n}\n\nexport function path(): string {\n\treturn resolve(process.env.CODEWORK_MODELS_FILE ?? configured ?? join(projectRoot(), filename));\n}\n\n/**\n * The catalog bundled with aikit for OpenAI, Anthropic and OpenRouter (`aikit modelgen --baseline`),\n * so a first run works before any catalog was generated.\n */\nexport const baseline: GeneratedCatalog = bundled;\n\n/**\n * The catalog at `catalogPath` over the {@link baseline}: a provider the file lists replaces the\n * bundled one, so a fresh generated catalog wins and an older one still gets the bundled providers.\n * A missing file reads as the baseline alone.\n */\nexport async function load(catalogPath = path()): Promise<GeneratedCatalog> {\n\tlet content: string;\n\ttry {\n\t\tcontent = await Filesystem.readText(catalogPath);\n\t} catch (cause) {\n\t\tconst value =\n\t\t\ttypeof cause === \"object\" && cause !== null && \"code\" in cause && typeof cause.code === \"string\"\n\t\t\t\t? cause.code\n\t\t\t\t: undefined;\n\t\tif (value === \"ENOENT\") return { ...baseline };\n\t\tthrow new ModelCatalogLoadError(\n\t\t\t{ path: catalogPath, reason: \"unreadable\", message: `model catalog could not be read at ${catalogPath}` },\n\t\t\t{ cause },\n\t\t);\n\t}\n\tif (!content.trim()) {\n\t\tthrow new ModelCatalogLoadError({\n\t\t\tpath: catalogPath,\n\t\t\treason: \"empty\",\n\t\t\tmessage: `model catalog is empty at ${catalogPath}`,\n\t\t});\n\t}\n\ttry {\n\t\tconst parsed: unknown = JSON.parse(content);\n\t\tif (typeof parsed !== \"object\" || parsed === null || Array.isArray(parsed)) throw new Error(\"expected an object\");\n\t\treturn { ...baseline, ...(parsed as GeneratedCatalog) };\n\t} catch (cause) {\n\t\tthrow new ModelCatalogLoadError(\n\t\t\t{\n\t\t\t\tpath: catalogPath,\n\t\t\t\treason: \"invalid\",\n\t\t\t\tmessage: `model catalog contains invalid json at ${catalogPath}`,\n\t\t\t},\n\t\t\t{ cause },\n\t\t);\n\t}\n}\n\nexport const data: LazyGeneratedCatalog = lazy(() => load());\n\nexport async function get(): Promise<GeneratedCatalog> {\n\treturn data();\n}\n","import Type, { type Static } from \"typebox\";\nimport { lazy } from \"../utils/lazy.ts\";\nimport * as ModelCatalog from \"./catalog.ts\";\n\n// re-export\nexport const KnownProviderEnum = ModelCatalog.KnownProviderEnum;\nexport const KnownProviderEnumSchema = ModelCatalog.KnownProviderEnumSchema;\nexport type KnownProviderEnum = ModelCatalog.KnownProviderEnum;\n\nexport const ModelCatalogLoadError = ModelCatalog.ModelCatalogLoadError;\nexport type ModelCatalogLoadError = ModelCatalog.ModelCatalogLoadError;\n\n// Common reasoning-effort levels used by adapters that expose model reasoning,\n// thinking, or deliberation controls. Protocol-specific layers can map these\n// values to native fields like OpenAI `reasoning_effort`, Anthropic `thinking`,\n// or Gemini `thinkingConfig`.\nexport const ThinkingLevelEnum = {\n\t// Disable explicit reasoning controls when the provider supports turning them off.\n\toff: \"off\",\n\t// Smallest reasoning budget/effort above off; useful for fastest low-cost responses.\n\tminimal: \"minimal\",\n\t// Light reasoning for simple tasks that still benefit from some deliberation.\n\tlow: \"low\",\n\t// Balanced default for general tasks.\n\tmedium: \"medium\",\n\t// Higher reasoning effort for complex coding, analysis, or planning.\n\thigh: \"high\",\n\t// Extra-high reasoning effort for difficult tasks when supported by the model.\n\txhigh: \"xhigh\",\n\t// Maximum provider-defined effort above xhigh when explicitly supported by the model.\n\tmax: \"max\",\n} as const;\n\nexport const ThinkingLevel = Type.Union([\n\tType.Literal(ThinkingLevelEnum.off),\n\tType.Literal(ThinkingLevelEnum.minimal),\n\tType.Literal(ThinkingLevelEnum.low),\n\tType.Literal(ThinkingLevelEnum.medium),\n\tType.Literal(ThinkingLevelEnum.high),\n\tType.Literal(ThinkingLevelEnum.xhigh),\n\tType.Literal(ThinkingLevelEnum.max),\n]);\nexport type ThinkingLevel = Static<typeof ThinkingLevel>;\n\nexport const ActiveThinkingLevel = Type.Union([\n\tType.Literal(ThinkingLevelEnum.minimal),\n\tType.Literal(ThinkingLevelEnum.low),\n\tType.Literal(ThinkingLevelEnum.medium),\n\tType.Literal(ThinkingLevelEnum.high),\n\tType.Literal(ThinkingLevelEnum.xhigh),\n\tType.Literal(ThinkingLevelEnum.max),\n]);\nexport type ActiveThinkingLevel = Static<typeof ActiveThinkingLevel>;\n\nexport const ThinkingBudgets = Type.Partial(Type.Record(ActiveThinkingLevel, Type.Number()));\nexport type ThinkingBudgets = Static<typeof ThinkingBudgets>;\n\n// Note: order of entries matters!\nconst ACTIVE_THINKING_LEVELS = [\n\tThinkingLevelEnum.minimal,\n\tThinkingLevelEnum.low,\n\tThinkingLevelEnum.medium,\n\tThinkingLevelEnum.high,\n\tThinkingLevelEnum.xhigh,\n\tThinkingLevelEnum.max,\n] as const satisfies readonly ActiveThinkingLevel[];\nconst MODEL_THINKING_LEVELS = [\n\tThinkingLevelEnum.off,\n\t...ACTIVE_THINKING_LEVELS,\n] as const satisfies readonly ThinkingLevel[];\n\nexport const ProviderInfo = Type.Object({\n\tid: Type.String(),\n\tname: Type.String(),\n\tsource: Type.Enum([\"env\", \"config\", \"custom\", \"api\", \"unknown\"]),\n\tenv: Type.Array(Type.String()),\n\tkey: Type.Optional(Type.String()), // runtime api/oauth key\n\toptions: Type.Optional(Type.Record(Type.String(), Type.Any())),\n});\nexport type ProviderInfo = Static<typeof ProviderInfo>;\n\nconst InputSchema = Type.Array(Type.Union([Type.Literal(\"text\"), Type.Literal(\"image\")]));\nconst CostRatesSchema = Type.Object({\n\tinput: Type.Number(),\n\toutput: Type.Number(),\n\tcacheRead: Type.Number(),\n\tcacheWrite: Type.Number(),\n});\nconst CostTierSchema = Type.Object({\n\t...CostRatesSchema.properties,\n\tinputTokensAbove: Type.Number(),\n});\nconst CostSchema = Type.Object({\n\t...CostRatesSchema.properties,\n\ttiers: Type.Optional(Type.Array(CostTierSchema)),\n\tserviceTierMultipliers: Type.Optional(Type.Record(Type.String(), Type.Number())),\n});\nconst SupportedProtocolsSchema = Type.Partial(\n\tType.Object({\n\t\tanthropic: KnownProviderEnumSchema,\n\t\tgoogle: KnownProviderEnumSchema,\n\t\tgoogleVertex: KnownProviderEnumSchema,\n\t\tgoogleVertexAnthropic: KnownProviderEnumSchema,\n\t\tgithubCopilot: KnownProviderEnumSchema,\n\t\topenai: KnownProviderEnumSchema,\n\t\topenaiCompatible: KnownProviderEnumSchema,\n\t\topenaiCodex: KnownProviderEnumSchema,\n\t\topenrouter: KnownProviderEnumSchema,\n\t\txai: KnownProviderEnumSchema,\n\t}),\n);\n\nexport const APIMethodEnum = {\n\tlanguageModel: \"languageModel\",\n\tchat: \"chat\",\n\tcompletion: \"completion\",\n\tcompletionModel: \"completionModel\",\n\tmessages: \"messages\",\n\tresponses: \"responses\",\n} as const;\nexport const APIMethodEnumSchema = Type.Union([\n\tType.Literal(APIMethodEnum.languageModel),\n\tType.Literal(APIMethodEnum.chat),\n\tType.Literal(APIMethodEnum.completion),\n\tType.Literal(APIMethodEnum.completionModel),\n\tType.Literal(APIMethodEnum.messages),\n\tType.Literal(APIMethodEnum.responses),\n]);\nexport type APIMethodEnum = Static<typeof APIMethodEnumSchema>;\n\nexport const APIMetadataSchema = Type.Object({\n\tid: Type.Optional(Type.String()),\n\turl: Type.Optional(Type.String()),\n\tmethod: Type.Optional(APIMethodEnumSchema),\n});\nexport type APIMetadata = Static<typeof APIMetadataSchema>;\n\nexport const ThinkingLevelMapSchema = Type.Partial(\n\tType.Record(\n\t\tThinkingLevel, // Safe key validation\n\t\tType.Union([Type.String(), Type.Null()]), // Allowed values\n\t),\n);\nexport type ThinkingLevelMap = Static<typeof ThinkingLevelMapSchema>;\n\n/**\n * The level map for a model that lists the reasoning efforts it accepts (models.dev\n * `reasoning_options`, OpenRouter `supported_efforts`): a level maps to itself only when listed,\n * and off maps to `none` only when `none` is listed (pi). Undefined when nothing usable is listed.\n */\nexport function effortThinkingLevels(efforts: ReadonlyArray<string | null>): ThinkingLevelMap | undefined {\n\tconst supported = new Set(efforts);\n\tif (!ACTIVE_THINKING_LEVELS.some((level) => supported.has(level)) && !supported.has(\"none\")) return undefined;\n\tconst map: ThinkingLevelMap = { off: supported.has(\"none\") ? \"none\" : null };\n\tfor (const level of ACTIVE_THINKING_LEVELS) map[level] = supported.has(level) ? level : null;\n\treturn map;\n}\n\nexport const CompatibilitySchema = Type.Object({\n\t/** The Google protocol accepts thinking levels rather than a token budget. */\n\tsupportsThinkingLevel: Type.Optional(Type.Boolean()),\n\tsupportsToolSearch: Type.Optional(Type.Boolean()),\n\t/**\n\t * Tool changes go in place: Responses `additional_tools` items, Anthropic tool references.\n\t * Requires `supportsMidConvoSystemMessages`.\n\t */\n\tsupportsAdditionalTools: Type.Optional(Type.Boolean()),\n\t/** The model accepts developer messages after the conversation has started. */\n\tsupportsMidConvoSystemMessages: Type.Optional(Type.Boolean()),\n\tsupportsStrictMode: Type.Optional(Type.Boolean()),\n\tsupportsOpenAIGrammarTools: Type.Optional(Type.Boolean()),\n\t/** The model takes a thinking-token budget as a top-level request field. */\n\tsupportsThinkingTokenBudget: Type.Optional(Type.Boolean()),\n\t/** Claude model that sizes its own thinking, driven by `effort` instead of a token budget. */\n\tforceAdaptiveThinking: Type.Optional(Type.Boolean()),\n\t/** False for a model that rejects a `temperature` field; the request then leaves it out. */\n\tsupportsTemperature: Type.Optional(Type.Boolean()),\n\t/** Name of that field, when it is not the conventional `thinking_token_budget`. */\n\tthinkingTokenBudgetField: Type.Optional(Type.String()),\n});\nexport type Compatibility = Static<typeof CompatibilitySchema>;\n\n/**\n * Claude models that decide their own thinking depth.\n *\n * These take an `effort` level and let the model size each turn's reasoning; the\n * older models take a fixed `budget_tokens` instead. Sending a budget to an\n * adaptive model pins it to one depth for every turn, which is the thing adaptive\n * thinking exists to avoid.\n */\nexport function isAnthropicAdaptiveThinkingModel(modelId: string): boolean {\n\treturn [\n\t\t\"opus-4-6\",\n\t\t\"opus-4.6\",\n\t\t\"opus-4-7\",\n\t\t\"opus-4.7\",\n\t\t\"opus-4-8\",\n\t\t\"opus-4.8\",\n\t\t\"opus-5\",\n\t\t\"opus.5\",\n\t\t\"sonnet-4-6\",\n\t\t\"sonnet-4.6\",\n\t\t\"sonnet-5\",\n\t\t\"sonnet.5\",\n\t\t\"fable-5\",\n\t\t\"haiku-5\",\n\t\t\"haiku.5\",\n\t].some((needle) => modelId.includes(needle));\n}\n\nexport const Schema = Type.Object({\n\tid: Type.String(),\n\tname: Type.String(),\n\tprovider: ProviderInfo,\n\tbaseUrl: Type.String(),\n\treasoning: Type.Boolean(),\n\tthinkingLevelMap: Type.Optional(ThinkingLevelMapSchema),\n\t/** Default budgets; request-level thinkingBudgets take precedence. */\n\tthinkingBudgets: Type.Optional(ThinkingBudgets),\n\tinput: InputSchema,\n\tcost: CostSchema,\n\tcontextWindow: Type.Number(),\n\tmaxTokens: Type.Number(),\n\theaders: Type.Optional(Type.Record(Type.String(), Type.String())),\n\tnpm: Type.Optional(Type.String()),\n\tapi: Type.Optional(APIMetadataSchema),\n\tproviderOptionsKey: Type.Optional(Type.String()),\n\toptions: Type.Optional(Type.Record(Type.String(), Type.Unknown())),\n\tproviderOptions: Type.Optional(Type.Record(Type.String(), Type.Unknown())),\n\tcompat: Type.Optional(CompatibilitySchema),\n\tprotocol: KnownProviderEnumSchema, // provider as the underlying protocol\n\tsupportedProtocols: Type.Optional(SupportedProtocolsSchema), // provider as the underlying supported protocols\n});\n\nexport const ExtrasSchema = Type.Object({});\n\nexport const Info = Type.Evaluate(Type.Intersect([Schema, ExtrasSchema]));\nexport type Info = Static<typeof Info>;\nexport type TModel<TProtocol extends KnownProviderEnum> = Omit<Info, \"protocol\"> & { protocol: TProtocol };\n\nexport function calculateCost(\n\tmodel: Info,\n\tusage: {\n\t\tinput: number;\n\t\toutput: number;\n\t\tcacheRead: number;\n\t\tcacheWrite: number;\n\t\tcacheWrite1h?: number;\n\t\tcost: {\n\t\t\tinput: number;\n\t\t\toutput: number;\n\t\t\tcacheRead: number;\n\t\t\tcacheWrite: number;\n\t\t\ttotal: number;\n\t\t};\n\t},\n): void {\n\tconst inputTokens = usage.input + usage.cacheRead + usage.cacheWrite;\n\tlet rates = model.cost;\n\tlet matchedThreshold = -1;\n\tfor (const tier of model.cost.tiers ?? []) {\n\t\tif (inputTokens > tier.inputTokensAbove && tier.inputTokensAbove > matchedThreshold) {\n\t\t\trates = tier;\n\t\t\tmatchedThreshold = tier.inputTokensAbove;\n\t\t}\n\t}\n\n\t// Anthropic charges 2x base input for 1h cache writes; `cost.cacheWrite` is the 5m rate.\n\tconst longWrite = usage.cacheWrite1h ?? 0;\n\tconst shortWrite = usage.cacheWrite - longWrite;\n\n\tusage.cost.input = (usage.input / 1_000_000) * rates.input;\n\tusage.cost.output = (usage.output / 1_000_000) * rates.output;\n\tusage.cost.cacheRead = (usage.cacheRead / 1_000_000) * rates.cacheRead;\n\tusage.cost.cacheWrite = (rates.cacheWrite * shortWrite + rates.input * 2 * longWrite) / 1_000_000;\n\tusage.cost.total = usage.cost.input + usage.cost.output + usage.cost.cacheRead + usage.cost.cacheWrite;\n}\n\nexport type BuiltInModels = Partial<Record<string, Record<string, Info>>>;\n\nexport function normalizeInput(input?: string[]): Array<\"text\" | \"image\"> {\n\tconst normalized = new Set<\"text\" | \"image\">();\n\tfor (const modality of input ?? [\"text\"]) {\n\t\tif (modality === \"text\" || modality === \"image\") {\n\t\t\tnormalized.add(modality);\n\t\t}\n\t}\n\tif (normalized.size === 0) normalized.add(\"text\");\n\treturn [...normalized];\n}\n\n/** Where the catalog is read from: `CODEWORK_MODELS_FILE`, the configured path, or `./models.gen.json`. */\nexport const catalogPath = ModelCatalog.path;\n\n/** Read the catalog from `path` from now on, dropping whatever was already loaded. */\nexport function configureCatalog(path: string): void {\n\tModelCatalog.configure(path);\n\tregistry.reset();\n}\n\n/** Drop the loaded catalog, so the next lookup re-reads the file -- after it was regenerated. */\nexport function reloadCatalog(): void {\n\tModelCatalog.data.reset();\n\tregistry.reset();\n}\n\nexport async function getBuiltInModels(): Promise<BuiltInModels> {\n\treturn (await ModelCatalog.get()) as BuiltInModels;\n}\n\nexport const registry = lazy(async () => {\n\tconst registry: Map<string, Map<string, Info>> = new Map();\n\tconst models = await getBuiltInModels();\n\tfor (const [provider, value] of Object.entries(models) as Array<[string, Record<string, Info>]>) {\n\t\tconst providerModels = new Map<string, Info>();\n\t\tfor (const [id, model] of Object.entries(value)) {\n\t\t\tproviderModels.set(id, model);\n\t\t}\n\t\tregistry.set(provider, providerModels);\n\t}\n\treturn registry;\n});\n\n/**\n * The key a provider's own option bag is filed under.\n *\n * Providers that speak another provider's protocol still carry their own option\n * namespace, so this is not always the protocol.\n */\n/**\n * The request-body field a model takes its thinking-token budget in, if any.\n *\n * OpenAI-compatible endpoints have no standard place for this, so each one names\n * its own field; a bare `supportsThinkingTokenBudget` means the conventional name.\n */\nexport function thinkingTokenBudgetField(model: Info): string | undefined {\n\tif (model.compat?.thinkingTokenBudgetField) return model.compat.thinkingTokenBudgetField;\n\treturn model.compat?.supportsThinkingTokenBudget ? \"thinking_token_budget\" : undefined;\n}\n\nexport function optionsKey(model: Info): string {\n\treturn model.providerOptionsKey ?? model.protocol;\n}\n\nexport function supportsProtocol(model: Info, protocol: KnownProviderEnum): boolean {\n\tif (model.protocol === protocol) return true;\n\treturn Object.values(model.supportedProtocols ?? {}).includes(protocol);\n}\n\nexport type ProviderToProtocol<TProvider extends string> = TProvider extends KnownProviderEnum\n\t? TProvider\n\t: KnownProviderEnum;\n\nexport async function getModel<\n\tTProvider extends string,\n\tTProtocol extends KnownProviderEnum = ProviderToProtocol<TProvider>,\n>(\n\tprovider: TProvider,\n\tmodel: string,\n\toverrides?: Partial<Info> & { protocol?: TProtocol },\n): Promise<TModel<TProtocol> | undefined> {\n\tconst data = await registry();\n\tconst providerModels = data.get(provider);\n\tconst result = providerModels?.get(model);\n\tif (result && overrides) {\n\t\tif (overrides.protocol && !supportsProtocol(result, overrides.protocol)) {\n\t\t\treturn undefined;\n\t\t}\n\t\treturn {\n\t\t\t...result,\n\t\t\t...overrides,\n\t\t} as TModel<TProtocol>;\n\t}\n\treturn result as TModel<TProtocol> | undefined;\n}\n\nexport async function getProviders(): Promise<string[]> {\n\tconst data = await registry();\n\treturn Array.from(data.keys());\n}\n\nexport async function getModels<TProvider extends string>(provider: TProvider): Promise<Info[]> {\n\tconst data = await registry();\n\tconst models = data.get(provider);\n\treturn models ? Array.from(models.values()) : [];\n}\n\n/**\n * Check if two models are equal by comparing both their id and provider id.\n * Returns false if either model is null or undefined.\n */\nexport function modelsAreEqual(a: Info | null | undefined, b: Info | null | undefined): boolean {\n\tif (!a || !b) return false;\n\treturn a.id === b.id && a.provider.id === b.provider.id;\n}\n\nexport function getSupportedThinkingLevels<TProtocol extends KnownProviderEnum>(\n\tmodel: TModel<TProtocol>,\n): ThinkingLevel[] {\n\tif (!model.reasoning) return [\"off\"];\n\n\treturn MODEL_THINKING_LEVELS.filter((level) => {\n\t\tconst mapped = model.thinkingLevelMap?.[level];\n\t\tif (mapped === null) return false;\n\t\tif (level === \"xhigh\" || level === \"max\") return mapped !== undefined;\n\t\treturn true;\n\t});\n}\n\nexport function clampThinkingLevel<TProtocol extends KnownProviderEnum>(\n\tmodel: TModel<TProtocol>,\n\tlevel: ThinkingLevel,\n): ThinkingLevel {\n\tconst availableLevels = getSupportedThinkingLevels(model);\n\tif (availableLevels.includes(level)) return level;\n\n\tconst requestedIndex = MODEL_THINKING_LEVELS.indexOf(level);\n\tif (requestedIndex === -1) return availableLevels[0] ?? \"off\";\n\n\t// walk up the ladder from the point and pick first supported\n\t// biased to avail more thinking, then less not round to nearest.\n\tfor (let i = requestedIndex; i < MODEL_THINKING_LEVELS.length; i++) {\n\t\tconst candidate = MODEL_THINKING_LEVELS[i]!;\n\t\tif (availableLevels.includes(candidate)) return candidate;\n\t}\n\t// otherwise walk down from the point\n\tfor (let i = requestedIndex - 1; i >= 0; i--) {\n\t\tconst candidate = MODEL_THINKING_LEVELS[i]!;\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AE,SAAS;AACtD;AAEA,SAAgB,2BACf,OACkB;CAClB,IAAI,CAAC,MAAM,WAAW,OAAO,CAAC,KAAK;CAEnC,OAAO,sBAAsB,QAAQ,UAAU;EAC9C,MAAM,SAAS,MAAM,mBAAmB;EACxC,IAAI,WAAW,MAAM,OAAO;EAC5B,IAAI,UAAU,WAAW,UAAU,OAAO,OAAO,WAAW,KAAA;EAC5D,OAAO;CACR,CAAC;AACF;AAEA,SAAgB,mBACf,OACA,OACgB;CAChB,MAAM,kBAAkB,2BAA2B,KAAK;CACxD,IAAI,gBAAgB,SAAS,KAAK,GAAG,OAAO;CAE5C,MAAM,iBAAiB,sBAAsB,QAAQ,KAAK;CAC1D,IAAI,mBAAmB,IAAI,OAAO,gBAAgB,MAAM;CAIxD,KAAK,IAAI,IAAI,gBAAgB,IAAI,sBAAsB,QAAQ,KAAK;EACnE,MAAM,YAAY,sBAAsB;EACxC,IAAI,gBAAgB,SAAS,SAAS,GAAG,OAAO;CACjD;CAEA,KAAK,IAAI,IAAI,iBAAiB,GAAG,KAAK,GAAG,KAAK;EAC7C,MAAM,YAAY,sBAAsB;EACxC,IAAI,gBAAgB,SAAS,SAAS,GAAG,OAAO;CACjD;CACA,OAAO,gBAAgB,MAAM;AAC9B"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import { C as readJson, S as path, T as writeJsonAtomic, d as effortThinkingLevels, h as isAnthropicAdaptiveThinkingModel, i as KnownProviderEnum, t as APIMethodEnum, v as normalizeInput } from "./model-
|
|
2
|
-
import { a as protocolForPackage, n as isAISDKPackage } from "./registry-
|
|
3
|
-
import { n as GITHUB_COPILOT_STATIC_HEADERS } from "./copilot-headers-
|
|
1
|
+
import { C as readJson, S as path, T as writeJsonAtomic, d as effortThinkingLevels, h as isAnthropicAdaptiveThinkingModel, i as KnownProviderEnum, t as APIMethodEnum, v as normalizeInput } from "./model-DHV-hzpF.mjs";
|
|
2
|
+
import { a as protocolForPackage, n as isAISDKPackage } from "./registry-7CCwBZxQ.mjs";
|
|
3
|
+
import { n as GITHUB_COPILOT_STATIC_HEADERS } from "./copilot-headers-O7LmAz_U.mjs";
|
|
4
4
|
import { resolve } from "node:path";
|
|
5
5
|
import { mapValues, pick, pickBy, pipe } from "remeda";
|
|
6
6
|
//#region src/model/openrouter.ts
|
|
@@ -173,7 +173,11 @@ async function pullOpenRouterData() {
|
|
|
173
173
|
function toModelValue(providerId, provider, model) {
|
|
174
174
|
return applyModification(providerId, provider, model);
|
|
175
175
|
}
|
|
176
|
-
const MODELS_DEV_UNSUPPORTED_MODEL_IDS = /* @__PURE__ */ new Set([
|
|
176
|
+
const MODELS_DEV_UNSUPPORTED_MODEL_IDS = /* @__PURE__ */ new Set([
|
|
177
|
+
"openai/gpt-5.6",
|
|
178
|
+
"anthropic/claude-sonnet-4-5",
|
|
179
|
+
"anthropic/claude-sonnet-4-5-20250929"
|
|
180
|
+
]);
|
|
177
181
|
function usable(providerId, provider, model) {
|
|
178
182
|
return Boolean(model.tool_call) && !MODELS_DEV_UNSUPPORTED_MODEL_IDS.has(`${providerId}/${model.id}`) && isAISDKPackage(resolveModelNpm(provider, model));
|
|
179
183
|
}
|
|
@@ -761,4 +765,4 @@ function applyModification(providerId, provider, model) {
|
|
|
761
765
|
//#endregion
|
|
762
766
|
export { personalize as i, generateModels as n, PROVIDER_ID as r, ModelgenCommand as t };
|
|
763
767
|
|
|
764
|
-
//# sourceMappingURL=modelgen-
|
|
768
|
+
//# sourceMappingURL=modelgen-BE_GuJZG.mjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"modelgen-BE_GuJZG.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 these, but the provider's API does not accept them: an OpenAI alias (pi),\n// and Claude Sonnet 4.5, retired from the Claude API on 2026-11-30.\nconst MODELS_DEV_UNSUPPORTED_MODEL_IDS = new Set([\n\t\"openai/gpt-5.6\",\n\t\"anthropic/claude-sonnet-4-5\",\n\t\"anthropic/claude-sonnet-4-5-20250929\",\n]);\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 openAiAcceptsNoReasoning(id: string): boolean {\n\treturn (\n\t\tOPENAI_RESPONSES_NONE_REASONING_MODELS.has(id) ||\n\t\t(OPENAI_GPT6_MODELS.has(id) && !OPENAI_GPT6_NO_NONE_MODELS.has(id))\n\t);\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\tif (model.api?.method === Model.APIMethodEnum.responses && OPENAI_MID_CONVO_SYSTEM_MESSAGE_MODEL_IDS.has(id)) {\n\t\t\tmergeCompat(model, { supportsMidConvoSystemMessages: true });\n\t\t}\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// These take system messages inside the conversation, verified live against the Messages API.\nconst ANTHROPIC_MID_CONVO_SYSTEM_MESSAGES =\n\t/^claude-(?:opus-(?:4[.-]8|5(?:[.-]5)?)|(?:sonnet|haiku)-5[.-]5|(?:fable|mythos)-5(?:[.-]1)?)(?:-\\d{8})?$/;\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\t// Copilot passes these system messages through but rejects tool changes in them.\n\tif (model.provider.id === \"anthropic\" && ANTHROPIC_MID_CONVO_SYSTEM_MESSAGES.test(id)) {\n\t\tmergeCompat(model, { supportsMidConvoSystemMessages: true, supportsAdditionalTools: true });\n\t}\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// These Responses models accept developer messages after the conversation has started (pi).\nconst OPENAI_MID_CONVO_SYSTEM_MESSAGE_MODEL_IDS = new Set([\n\t\"gpt-5.4\",\n\t\"gpt-5.4-mini\",\n\t\"gpt-5.4-pro\",\n\t\"gpt-5.5\",\n\t\"gpt-5.6-sol\",\n\t\"gpt-5.6-terra\",\n\t\"gpt-5.6-luna\",\n\t\"gpt-6-astra\",\n\t\"gpt-6-sol\",\n\t\"gpt-6-luna\",\n\t\"gpt-6.1-sol\",\n\t\"gpt-6.1-terra\",\n]);\n// Copilot passes `additional_tools` items through to OpenAI for these Responses models.\nconst GITHUB_COPILOT_ADDITIONAL_TOOLS_MODEL_IDS = new Set([\n\t\"gpt-5.4\",\n\t\"gpt-5.4-mini\",\n\t\"gpt-5.4-pro\",\n\t\"gpt-5.5\",\n\t\"gpt-5.6-sol\",\n\t\"gpt-5.6-terra\",\n\t\"gpt-5.6-luna\",\n\t\"gpt-6-astra\",\n\t\"gpt-6-sol\",\n\t\"gpt-6-luna\",\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_MID_CONVO_SYSTEM_MESSAGE_MODEL_IDS.has(seed.id) ? { supportsMidConvoSystemMessages: 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.8\",\n\t\"claude-opus-5\",\n\t\"claude-opus-5.5\",\n\t\"claude-sonnet-4.6\",\n\t\"claude-sonnet-5\",\n\t\"gpt-5.3-codex\",\n\t\"gpt-6-astra\",\n\t\"gpt-6-luna\",\n\t\"gpt-6-sol\",\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.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// Off is opt-in per model on Responses (Grok and MAI reject \"none\"), and the chat route\n\t// has no reasoning control.\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};\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 (method === Model.APIMethodEnum.responses && OPENAI_MID_CONVO_SYSTEM_MESSAGE_MODEL_IDS.has(id)) {\n\t\t\tmergeCompat(info, { supportsMidConvoSystemMessages: true });\n\t\t}\n\t\tif (method === Model.APIMethodEnum.messages && ANTHROPIC_MID_CONVO_SYSTEM_MESSAGES.test(id)) {\n\t\t\tmergeCompat(info, { supportsMidConvoSystemMessages: true });\n\t\t}\n\t\tif (method === Model.APIMethodEnum.responses && GITHUB_COPILOT_ADDITIONAL_TOOLS_MODEL_IDS.has(id)) {\n\t\t\tmergeCompat(info, { supportsAdditionalTools: 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\t\t// Copilot forwards reasoning.effort to OpenAI unchanged, so the GPT models OpenAI lets\n\t\t// turn reasoning off take \"none\" here too (checked live).\n\t\tif (method === Model.APIMethodEnum.responses && openAiAcceptsNoReasoning(id)) {\n\t\t\tmergeThinkingLevelMap(info, { off: \"none\" });\n\t\t}\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\tconst catalog = {\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};\n\treturn sortKeys(\n\t\tObject.fromEntries(Object.entries(catalog).filter(([, models]) => Object.keys(models ?? {}).length > 0)),\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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AG;CACvC,MAAM,UAAU,oBAAoB,UAAU,KAAK;CACnD,MAAM,eAAmC;EACxC,IAAI;EACJ,MAAM,SAAS;EACf,QAAQ;EACR,KAAK,SAAS;CACf;CACA,IAAI,SAAS,KAAK,aAAa,MAAM,SAAS;CAC9C,MAAM,MAAyB;EAC9B,IAAI,MAAM;EACV,QAAQ,sBAAsB,GAAG;CAClC;CACA,IAAI,SAAS,IAAI,MAAM;CAEvB,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
|
-
import { T as writeJsonAtomic, i as KnownProviderEnum, t as APIMethodEnum, w as writeAtomic } from "./model-
|
|
2
|
-
import { i as personalize, n as generateModels, r as PROVIDER_ID } from "./modelgen-
|
|
1
|
+
import { T as writeJsonAtomic, i as KnownProviderEnum, t as APIMethodEnum, w as writeAtomic } from "./model-DHV-hzpF.mjs";
|
|
2
|
+
import { i as personalize, n as generateModels, r as PROVIDER_ID } from "./modelgen-BE_GuJZG.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/oauth/github/copilot.mjs
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as createGitHubCopilotDeviceFlow, c as fetchGitHubCopilotUser, d as gitHubApiDomain, f as gitHubCopilotBaseUrl, g as pollGitHubCopilotDeviceToken, h as normalizeGitHubDomain, i as JsonGitHubCopilotAuthStorage, l as filterGitHubCopilotModels, m as gitHubCopilotHeaders, n as GITHUB_COPILOT_PROVIDER_ID, o as enableGitHubCopilotModels, p as gitHubCopilotEntitlementError, r as GitHubCopilotOAuthClient, s as fetchGitHubCopilotModels, t as GITHUB_COPILOT_API_KEY_ENV, u as getGitHubCopilotApiKey } from "../../copilot-
|
|
1
|
+
import { a as createGitHubCopilotDeviceFlow, c as fetchGitHubCopilotUser, d as gitHubApiDomain, f as gitHubCopilotBaseUrl, g as pollGitHubCopilotDeviceToken, h as normalizeGitHubDomain, i as JsonGitHubCopilotAuthStorage, l as filterGitHubCopilotModels, m as gitHubCopilotHeaders, n as GITHUB_COPILOT_PROVIDER_ID, o as enableGitHubCopilotModels, p as gitHubCopilotEntitlementError, r as GitHubCopilotOAuthClient, s as fetchGitHubCopilotModels, t as GITHUB_COPILOT_API_KEY_ENV, u as getGitHubCopilotApiKey } from "../../copilot-BnraENbo.mjs";
|
|
2
2
|
export { GITHUB_COPILOT_API_KEY_ENV, GITHUB_COPILOT_PROVIDER_ID, GitHubCopilotOAuthClient, JsonGitHubCopilotAuthStorage, createGitHubCopilotDeviceFlow, enableGitHubCopilotModels, fetchGitHubCopilotModels, fetchGitHubCopilotUser, filterGitHubCopilotModels, getGitHubCopilotApiKey, gitHubApiDomain, gitHubCopilotBaseUrl, gitHubCopilotEntitlementError, gitHubCopilotHeaders, normalizeGitHubDomain, pollGitHubCopilotDeviceToken };
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { n as clampPromptCacheKey, t as ResponsesLanguageModel } from "./model-
|
|
1
|
+
import { n as clampPromptCacheKey, t as ResponsesLanguageModel } from "./model-Bngx_P1p.mjs";
|
|
2
2
|
import { s as getOpenAICodexAccountId } from "./codex-DvULd3EJ.mjs";
|
|
3
3
|
import { LoadAPIKeyError, NoSuchModelError } from "@ai-sdk/provider";
|
|
4
4
|
//#region src/providers/openai-codex/codex-provider.ts
|
|
@@ -114,4 +114,4 @@ const openaiCodex = createOpenAICodex();
|
|
|
114
114
|
//#endregion
|
|
115
115
|
export { openaiCodex as a, openAICodexTools as i, OPENAI_CODEX_DEFAULT_BASE_URL as n, resolveOpenAICodexUrl as o, createOpenAICodex as r, OPENAI_CODEX_API_KEY_ENV as t };
|
|
116
116
|
|
|
117
|
-
//# sourceMappingURL=openai-codex-
|
|
117
|
+
//# sourceMappingURL=openai-codex-DOAYxBAw.mjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"openai-codex-
|
|
1
|
+
{"version":3,"file":"openai-codex-DOAYxBAw.mjs","names":[],"sources":["../../src/providers/openai-codex/codex-provider.ts"],"sourcesContent":["import { LoadAPIKeyError, NoSuchModelError, type LanguageModelV3, type ProviderV3 } from \"@ai-sdk/provider\";\nimport type { TSchema } from \"typebox\";\nimport type * as Message from \"../../message/message.ts\";\nimport { getOpenAICodexAccountId } from \"../../oauth/openai/codex.ts\";\nimport {\n\tResponsesLanguageModel,\n\tclampPromptCacheKey,\n\ttype ResponsesCompatibility,\n\ttype ResponsesRequestProfile,\n\ttype ResponsesServiceTier,\n} from \"../responses/model.ts\";\n\nexport const OPENAI_CODEX_API_KEY_ENV = \"OPENAI_CODEX_API_KEY\";\nexport const OPENAI_CODEX_DEFAULT_BASE_URL = \"https://chatgpt.com/backend-api\";\n\nexport type OpenAICodexModelId =\n\t| \"gpt-5.3-codex-spark\"\n\t| \"gpt-5.4\"\n\t| \"gpt-5.4-mini\"\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| (string & {});\n\nexport type OpenAICodexCompatibility = ResponsesCompatibility;\n\n/**\n * The ChatGPT Codex backend requires `instructions`, rejects `max_output_tokens`, and\n * takes a zstd-compressed body.\n */\nconst CODEX_REQUEST: ResponsesRequestProfile = {\n\tsystemPrompt: \"instructions\",\n\tmaxOutputTokens: false,\n\tencryptedReasoning: \"always\",\n\tcompress: true,\n\ttoolDefaults: true,\n\ttextVerbosity: \"low\",\n};\n\n/**\n * Resolve the Codex responses endpoint from a base URL that may already\n * include the `/codex` or `/codex/responses` suffix.\n */\nexport function resolveOpenAICodexUrl(baseUrl?: string): string {\n\tconst raw = baseUrl?.trim() ? baseUrl : OPENAI_CODEX_DEFAULT_BASE_URL;\n\tconst normalized = raw.replace(/\\/+$/, \"\");\n\tif (normalized.endsWith(\"/codex/responses\")) return normalized;\n\tif (normalized.endsWith(\"/codex\")) return `${normalized}/responses`;\n\treturn `${normalized}/codex/responses`;\n}\n\n/** Tool helpers for Responses-only tool kinds. */\nexport const openAICodexTools = {\n\tcustom<TParameters extends TSchema>(args: {\n\t\tname: string;\n\t\tdescription: string;\n\t\tparameters: TParameters;\n\t\tformat: { type: \"grammar\"; syntax: \"lark\" | \"regex\"; definition: string };\n\t}): Message.Tool<TParameters> {\n\t\treturn {\n\t\t\tname: args.name,\n\t\t\tdescription: args.description,\n\t\t\tparameters: args.parameters,\n\t\t\tconstrainedSampling: {\n\t\t\t\ttype: \"grammar\",\n\t\t\t\tvariants:\n\t\t\t\t\targs.format.syntax === \"lark\"\n\t\t\t\t\t\t? { openai_lark: args.format.definition }\n\t\t\t\t\t\t: { openai_regex: args.format.definition },\n\t\t\t},\n\t\t};\n\t},\n};\n\nconst DEFAULT_ORIGINATOR = \"codework\";\n\nexport interface OpenAICodexProvider extends ProviderV3 {\n\t(modelId: OpenAICodexModelId): LanguageModelV3;\n\n\tlanguageModel(modelId: OpenAICodexModelId): LanguageModelV3;\n\n\t/** Alias for `languageModel`; the Codex API only speaks the Responses protocol. */\n\tresponses(modelId: OpenAICodexModelId): LanguageModelV3;\n}\n\nexport interface OpenAICodexProviderSettings {\n\t/**\n\t * Base URL for the Codex backend.\n\t * Defaults to `https://chatgpt.com/backend-api`.\n\t */\n\tbaseURL?: string;\n\n\t/**\n\t * ChatGPT OAuth access token (JWT) used as the API key.\n\t * Defaults to the `OPENAI_CODEX_API_KEY` environment variable.\n\t * A function can be passed to resolve a fresh token per request.\n\t */\n\tapiKey?: string | (() => string | PromiseLike<string>);\n\n\t/**\n\t * ChatGPT account id sent as the `chatgpt-account-id` header.\n\t * Extracted from the JWT access token when omitted.\n\t */\n\taccountId?: string;\n\n\t/** Custom headers merged into every request. */\n\theaders?: Record<string, string>;\n\n\t/** Custom fetch implementation. */\n\tfetch?: typeof globalThis.fetch;\n\n\t/** Session id used for request identity, the `session-id` header, and prompt cache affinity. */\n\tsessionId?: string;\n\n\t/** Default service tier for requests. */\n\tserviceTier?: ResponsesServiceTier;\n\n\t/** `originator` header value; defaults to `codework`. */\n\toriginator?: string;\n\n\t/** Model capabilities supplied by aikit or the direct caller; absent flags are disabled. */\n\tcompat?: OpenAICodexCompatibility;\n}\n\nasync function resolveApiKey(settings: OpenAICodexProviderSettings): Promise<string> {\n\tconst apiKey =\n\t\ttypeof settings.apiKey === \"function\"\n\t\t\t? await settings.apiKey()\n\t\t\t: (settings.apiKey ?? (typeof process === \"undefined\" ? undefined : process.env[OPENAI_CODEX_API_KEY_ENV]));\n\n\tif (!apiKey) {\n\t\tthrow new LoadAPIKeyError({\n\t\t\tmessage: `OpenAI Codex API key is missing. Pass it using the 'apiKey' option or the ${OPENAI_CODEX_API_KEY_ENV} environment variable.`,\n\t\t});\n\t}\n\n\treturn apiKey;\n}\n\nfunction resolveAccountId(settings: OpenAICodexProviderSettings, apiKey: string): string {\n\tconst accountId = settings.accountId ?? getOpenAICodexAccountId(apiKey);\n\tif (!accountId) {\n\t\tthrow new LoadAPIKeyError({\n\t\t\tmessage:\n\t\t\t\t\"Failed to extract the ChatGPT account id from the OpenAI Codex access token. \" +\n\t\t\t\t\"Provide it using the 'accountId' option or pass a valid ChatGPT OAuth JWT as the API key.\",\n\t\t});\n\t}\n\treturn accountId;\n}\n\nexport function createOpenAICodex(options: OpenAICodexProviderSettings = {}): OpenAICodexProvider {\n\tconst baseURL = options.baseURL?.replace(/\\/+$/, \"\") || OPENAI_CODEX_DEFAULT_BASE_URL;\n\tconst sessionId = clampPromptCacheKey(options.sessionId);\n\n\tconst getHeaders = async (): Promise<Record<string, string | undefined>> => {\n\t\tconst apiKey = await resolveApiKey(options);\n\t\tconst accountId = resolveAccountId(options, apiKey);\n\n\t\treturn {\n\t\t\tAuthorization: `Bearer ${apiKey}`,\n\t\t\t\"chatgpt-account-id\": accountId,\n\t\t\t\"OpenAI-Beta\": \"responses=experimental\",\n\t\t\toriginator: options.originator ?? DEFAULT_ORIGINATOR,\n\t\t\taccept: \"text/event-stream\",\n\t\t\t\"content-type\": \"application/json\",\n\t\t\t...(sessionId ? { \"session-id\": sessionId, \"x-client-request-id\": sessionId } : {}),\n\t\t\t...options.headers,\n\t\t};\n\t};\n\n\tconst createLanguageModel = (modelId: OpenAICodexModelId) =>\n\t\tnew ResponsesLanguageModel(modelId, {\n\t\t\tprovider: \"openai-codex\",\n\t\t\tlabel: \"OpenAI Codex\",\n\t\t\turl: resolveOpenAICodexUrl(baseURL),\n\t\t\theaders: getHeaders,\n\t\t\trequest: CODEX_REQUEST,\n\t\t\t...(options.fetch !== undefined && { fetch: options.fetch }),\n\t\t\t...(sessionId !== undefined && { promptCacheKey: sessionId }),\n\t\t\t...(options.serviceTier !== undefined && { serviceTier: options.serviceTier }),\n\t\t\t...(options.compat !== undefined && { compat: options.compat }),\n\t\t});\n\n\tconst provider = function (modelId: OpenAICodexModelId) {\n\t\tif (new.target) {\n\t\t\tthrow new Error(\"openAI codex model function cannot be called with the new keyword.\");\n\t\t}\n\t\treturn createLanguageModel(modelId);\n\t};\n\n\tprovider.specificationVersion = \"v3\" as const;\n\tprovider.languageModel = createLanguageModel;\n\tprovider.responses = createLanguageModel;\n\n\tprovider.embeddingModel = (modelId: string) => {\n\t\tthrow new NoSuchModelError({ modelId, modelType: \"embeddingModel\" });\n\t};\n\tprovider.textEmbeddingModel = (modelId: string) => {\n\t\tthrow new NoSuchModelError({ modelId, modelType: \"embeddingModel\" });\n\t};\n\tprovider.imageModel = (modelId: string) => {\n\t\tthrow new NoSuchModelError({ modelId, modelType: \"imageModel\" });\n\t};\n\n\treturn provider as OpenAICodexProvider;\n}\n\n/**\n * Default provider instance using `OPENAI_CODEX_API_KEY`.\n */\nexport const openaiCodex = createOpenAICodex();\n"],"mappings":";;;;AAYA,MAAa,2BAA2B;AACxC,MAAa,gCAAgC;;;;;AAkB7C,MAAM,gBAAyC;CAC9C,cAAc;CACd,iBAAiB;CACjB,oBAAoB;CACpB,UAAU;CACV,cAAc;CACd,eAAe;AAChB;;;;;AAMA,SAAgB,sBAAsB,SAA0B;CAE/D,MAAM,cADM,SAAS,KAAK,IAAI,UAAU,8BAAA,CACjB,QAAQ,QAAQ,EAAE;CACzC,IAAI,WAAW,SAAS,kBAAkB,GAAG,OAAO;CACpD,IAAI,WAAW,SAAS,QAAQ,GAAG,OAAO,GAAG,WAAW;CACxD,OAAO,GAAG,WAAW;AACtB;;AAGA,MAAa,mBAAmB,EAC/B,OAAoC,MAKN;CAC7B,OAAO;EACN,MAAM,KAAK;EACX,aAAa,KAAK;EAClB,YAAY,KAAK;EACjB,qBAAqB;GACpB,MAAM;GACN,UACC,KAAK,OAAO,WAAW,SACpB,EAAE,aAAa,KAAK,OAAO,WAAW,IACtC,EAAE,cAAc,KAAK,OAAO,WAAW;EAC5C;CACD;AACD,EACD;AAEA,MAAM,qBAAqB;AAkD3B,eAAe,cAAc,UAAwD;CACpF,MAAM,SACL,OAAO,SAAS,WAAW,aACxB,MAAM,SAAS,OAAO,IACrB,SAAS,WAAW,OAAO,YAAY,cAAc,KAAA,IAAY,QAAQ,IAAA;CAE9E,IAAI,CAAC,QACJ,MAAM,IAAI,gBAAgB,EACzB,SAAS,6EAA6E,yBAAyB,wBAChH,CAAC;CAGF,OAAO;AACR;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AC;CACpE;CACA,SAAS,sBAAsB,YAAoB;EAClD,MAAM,IAAI,iBAAiB;GAAE;GAAS,WAAW;EAAiB,CAAC;CACpE;CACA,SAAS,cAAc,YAAoB;EAC1C,MAAM,IAAI,iBAAiB;GAAE;GAAS,WAAW;EAAa,CAAC;CAChE;CAEA,OAAO;AACR;;;;AAKA,MAAa,cAAc,kBAAkB"}
|
package/package.json
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { i as KnownProviderEnum, t as APIMethodEnum } from "./model-
|
|
1
|
+
import { i as KnownProviderEnum, t as APIMethodEnum } from "./model-DHV-hzpF.mjs";
|
|
2
2
|
//#region src/llm/registry.ts
|
|
3
3
|
const DEFAULT_AI_SDK_FALLBACK = "@ai-sdk/openai-compatible";
|
|
4
4
|
const AI_SDK_PACKAGE_TO_PROTOCOL = {
|
|
@@ -22,8 +22,8 @@ const PROVIDER_LOADERS = {
|
|
|
22
22
|
"@ai-sdk/openai-compatible": () => import("@ai-sdk/openai-compatible").then((m) => m.createOpenAICompatible),
|
|
23
23
|
"@openrouter/ai-sdk-provider": () => import("@openrouter/ai-sdk-provider").then((m) => m.createOpenRouter),
|
|
24
24
|
"@ai-sdk/xai": () => import("@ai-sdk/xai").then((m) => m.createXai),
|
|
25
|
-
"@codeworksh/ai-sdk-openai-codex": () => import("./openai-codex-
|
|
26
|
-
"@codeworksh/ai-sdk-github-copilot": () => import("./github-copilot-
|
|
25
|
+
"@codeworksh/ai-sdk-openai-codex": () => import("./openai-codex-CLv1E2ED.mjs").then((m) => m.createOpenAICodex),
|
|
26
|
+
"@codeworksh/ai-sdk-github-copilot": () => import("./github-copilot-BqLzvkGs.mjs").then((m) => m.createGitHubCopilot)
|
|
27
27
|
};
|
|
28
28
|
function isAISDKPackage(value) {
|
|
29
29
|
return value in AI_SDK_PACKAGE_TO_PROTOCOL;
|
|
@@ -68,4 +68,4 @@ function resolveLanguageModel(provider, model, methodOverride) {
|
|
|
68
68
|
//#endregion
|
|
69
69
|
export { protocolForPackage as a, packageForModel as i, isAISDKPackage as n, resolveLanguageModel as o, loadProviderFactory as r, resolveMethod as s, DEFAULT_AI_SDK_FALLBACK as t };
|
|
70
70
|
|
|
71
|
-
//# sourceMappingURL=registry-
|
|
71
|
+
//# sourceMappingURL=registry-7CCwBZxQ.mjs.map
|