@codeworksh/aikit 0.8.0-dev.20260905193244 → 0.9.0-dev.20260922184333

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.
Files changed (47) hide show
  1. package/README.md +10 -1
  2. package/cli.mjs +75 -83
  3. package/cli.mjs.map +1 -1
  4. package/{codex-MtP1574D.mjs → codex-CLDBTrFm.mjs} +132 -134
  5. package/codex-CLDBTrFm.mjs.map +1 -0
  6. package/copilot-CcD3g6H8.mjs +425 -0
  7. package/copilot-CcD3g6H8.mjs.map +1 -0
  8. package/copilot-headers-DceqXlpj.mjs +104 -0
  9. package/copilot-headers-DceqXlpj.mjs.map +1 -0
  10. package/github-copilot-BJIrxOzT.mjs +3 -0
  11. package/github-copilot-SIUCJz1G.mjs +126 -0
  12. package/github-copilot-SIUCJz1G.mjs.map +1 -0
  13. package/index.d.mts +980 -932
  14. package/index.mjs +63 -11
  15. package/index.mjs.map +1 -1
  16. package/interactive-eoNnscGB.mjs +57 -0
  17. package/interactive-eoNnscGB.mjs.map +1 -0
  18. package/{model-CpX11Oob.d.mts → model-CrVLp622.d.mts} +159 -130
  19. package/{model-CBnredXj.mjs → model-gCDbmGqT.mjs} +31 -2
  20. package/model-gCDbmGqT.mjs.map +1 -0
  21. package/{modelgen-BjSsusLQ.mjs → modelgen-DvorXOjJ.mjs} +148 -29
  22. package/modelgen-DvorXOjJ.mjs.map +1 -0
  23. package/modelgen.d.mts +2 -3
  24. package/modelgen.mjs +1 -1
  25. package/oauth/github/copilot.d.mts +169 -0
  26. package/oauth/github/copilot.mjs +2 -0
  27. package/oauth/interactive.d.mts +21 -0
  28. package/oauth/interactive.mjs +2 -0
  29. package/oauth/openai/codex.d.mts +46 -28
  30. package/oauth/openai/codex.mjs +2 -2
  31. package/oauth/summary.d.mts +67 -0
  32. package/oauth/summary.mjs +2 -0
  33. package/{openai-codex-t4B7g-gv.mjs → openai-codex-Bqzti6Mc.mjs} +3 -3
  34. package/{openai-codex-t4B7g-gv.mjs.map → openai-codex-Bqzti6Mc.mjs.map} +1 -1
  35. package/openai-codex-DA1Q7mLN.mjs +2 -0
  36. package/package.json +34 -22
  37. package/{registry-DYdYTwFt.mjs → registry-ZxwIW0gX.mjs} +5 -3
  38. package/registry-ZxwIW0gX.mjs.map +1 -0
  39. package/storage-v6qjTQ0v.mjs +178 -0
  40. package/storage-v6qjTQ0v.mjs.map +1 -0
  41. package/summary-C_QyCVWa.mjs +68 -0
  42. package/summary-C_QyCVWa.mjs.map +1 -0
  43. package/codex-MtP1574D.mjs.map +0 -1
  44. package/model-CBnredXj.mjs.map +0 -1
  45. package/modelgen-BjSsusLQ.mjs.map +0 -1
  46. package/openai-codex-BRH4Qa7l.mjs +0 -2
  47. package/registry-DYdYTwFt.mjs.map +0 -1
@@ -1 +0,0 @@
1
- {"version":3,"file":"modelgen-BjSsusLQ.mjs","names":["Filesystem.readJson","path","ModelCatalog.path","Filesystem.writeJson","Model.normalizeInput"],"sources":["../../src/cli/modelgen.ts"],"sourcesContent":["import { resolve } from \"node:path\";\nimport { mapValues, 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 * as Filesystem from \"../utils/filesystem.ts\";\nimport { lazy } from \"../utils/lazy.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]: \"https://openrouter.ai/api/v1\",\n\t[Model.KnownProviderEnum.xai]: \"https://api.x.ai/v1\",\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?: {\n\t\tinput?: number;\n\t\toutput?: number;\n\t\tcache_read?: number;\n\t\tcache_write?: number;\n\t};\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}\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>;\ntype LazyModelsDevCatalog = ReturnType<typeof lazy<Promise<ModelsDevCatalog>>>;\n\nfunction modelsDevURL(): string {\n\treturn process.env.OPENCODE_MODELS_URL || \"https://models.dev\";\n}\n\nfunction modelsDevPath(): string | undefined {\n\treturn process.env.OPENCODE_MODELS_DEV_FILE;\n}\n\nconst modelsDevData: LazyModelsDevCatalog = lazy(async () => {\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 json = await fetch(`${modelsDevURL()}/api.json`).then((x) => x.text());\n\treturn JSON.parse(json) as ModelsDevCatalog;\n});\n\nasync function pullModelsDevData(): Promise<ModelsDevCatalog> {\n\treturn modelsDevData();\n}\n\nfunction toModelValue(providerId: string, provider: ModelsDevProvider, model: ModelsDevModel): Model.Info | undefined {\n\treturn applyModification(providerId, provider, model);\n}\n\nasync function loadBuiltInFromModelsDev() {\n\tconst catalog = await pullModelsDevData();\n\treturn pipe(\n\t\tcatalog,\n\t\tpickBy((provider) =>\n\t\t\tObject.values(provider.models).some(\n\t\t\t\t// If `resolveModelNpm` fallbacks to `@ai-sdk/openai-compatible`\n\t\t\t\t// isAISDKPakage will be truthy, modify resolveModelNpm for custom logic if needed.\n\t\t\t\t// Keep `isAISDKPackage` as readonly for supported implemenatations key check\n\t\t\t\t(model) => Boolean(model.tool_call) && isAISDKPackage(resolveModelNpm(provider, model)),\n\t\t\t),\n\t\t),\n\t\tmapValues((provider, providerId) =>\n\t\t\tpipe(\n\t\t\t\tprovider.models,\n\t\t\t\tpickBy((model) => Boolean(model.tool_call) && isAISDKPackage(resolveModelNpm(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\n//\n// adhoc helpers variations\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]);\n\nfunction supportsOpenAiXhigh(model: Model.Info): boolean {\n\tconst modelId = model.id;\n\treturn (\n\t\tmodelId.includes(\"gpt-5.2\") ||\n\t\tmodelId.includes(\"gpt-5.3\") ||\n\t\tmodelId.includes(\"gpt-5.4\") ||\n\t\tmodelId.includes(\"gpt-5.5\") ||\n\t\t(model.protocol === Model.KnownProviderEnum.openaiCodex && modelId.includes(\"gpt-5.6\"))\n\t);\n}\n\nfunction supportsOpenAiCodexMax(model: Model.Info): boolean {\n\treturn model.protocol === Model.KnownProviderEnum.openaiCodex && model.id.includes(\"gpt-5.6\");\n}\n\nfunction mergeThinkingLevelMap(model: Model.Info, map: ThinkingLevelMap): void {\n\tmodel.thinkingLevelMap = { ...model.thinkingLevelMap, ...map };\n}\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 */\nfunction 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].some((needle) => modelId.includes(needle));\n}\n\nfunction mergeCompat(model: Model.Info, compat: Model.Compatibility): void {\n\tmodel.compat = { ...model.compat, ...compat };\n}\n\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): void {\n\tif (model.protocol === Model.KnownProviderEnum.google || model.protocol === Model.KnownProviderEnum.googleVertex) {\n\t\tapplyGoogleThinkingMetadata(model);\n\t}\n\tif (model.protocol === Model.KnownProviderEnum.openai || model.protocol === Model.KnownProviderEnum.openaiCodex) {\n\t\tmodel.cost.serviceTierMultipliers = { flex: 0.5, priority: model.id === \"gpt-5.5\" ? 2.5 : 2 };\n\t}\n\tif (\n\t\t(model.protocol === Model.KnownProviderEnum.google || model.protocol === Model.KnownProviderEnum.googleVertex) &&\n\t\t/gemini-3(?:\\.\\d+)?-pro|gemini-3\\.[78]-flash/.test(model.id.toLowerCase())\n\t) {\n\t\t// These models cannot disable thinking or accept minimal. Expose supported\n\t\t// levels to callers and let the shared clamp promote minimal to low.\n\t\tmergeThinkingLevelMap(model, { off: \"low\", minimal: null });\n\t}\n\tif (\n\t\t(model.protocol === Model.KnownProviderEnum.anthropic ||\n\t\t\tmodel.protocol === Model.KnownProviderEnum.googleVertexAnthropic) &&\n\t\tisAnthropicAdaptiveThinkingModel(model.id)\n\t) {\n\t\tmergeCompat(model, { forceAdaptiveThinking: true });\n\t}\n\tif (model.protocol === Model.KnownProviderEnum.openai && model.id.startsWith(\"gpt-5\")) {\n\t\tmergeThinkingLevelMap(model, { off: null });\n\t}\n\tif (\n\t\tmodel.protocol === Model.KnownProviderEnum.openai &&\n\t\tmodel.provider.id === \"openai\" &&\n\t\tOPENAI_RESPONSES_NONE_REASONING_MODELS.has(model.id)\n\t) {\n\t\tmergeThinkingLevelMap(model, { off: \"none\" });\n\t}\n\tif (supportsOpenAiXhigh(model)) {\n\t\tmergeThinkingLevelMap(model, { xhigh: \"xhigh\" });\n\t}\n\tif (supportsOpenAiCodexMax(model)) {\n\t\tmergeThinkingLevelMap(model, { max: \"max\" });\n\t}\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}\n\n//\n// OpenAI Codex (ChatGPT OAuth) models.\n// NOTE: These are not fetched from models.dev; we keep a small, explicit list to avoid aliases.\n// Context window is based on observed server limits (400s above ~272k), 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_GPT_56_CONTEXT = 272_000;\nconst OPENAI_CODEX_SPARK_CONTEXT = 128_000;\nconst OPENAI_CODEX_MAX_TOKENS = 128_000;\nconst OPENAI_LONG_CONTEXT_INPUT_THRESHOLD = 272_000;\nconst OPENAI_CODEX_TOOL_SEARCH_MODEL_IDS = new Set([\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]);\nconst OPENAI_CODEX_ADDITIONAL_TOOLS_MODEL_IDS = new Set([\"gpt-5.6-luna\", \"gpt-5.6-sol\", \"gpt-5.6-terra\"]);\n\ntype OpenAICodexModelSeed = Pick<Model.Info, \"id\" | \"name\" | \"input\" | \"cost\" | \"contextWindow\" | \"thinkingLevelMap\">;\n\nfunction roundCost(value: number): number {\n\treturn Number(value.toFixed(6));\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\nconst OPENAI_CODEX_GPT_56_COSTS = {\n\t\"gpt-5.6-luna\": { input: 0.2, output: 1.2, cacheRead: 0.02, cacheWrite: 0.25 },\n\t\"gpt-5.6-terra\": { input: 2, output: 12, cacheRead: 0.2, cacheWrite: 2.5 },\n} satisfies Record<string, Model.Info[\"cost\"]>;\n\nconst OPENAI_CODEX_MODELS: OpenAICodexModelSeed[] = [\n\t{\n\t\tid: \"gpt-5.3-codex-spark\",\n\t\tname: \"GPT-5.3 Codex Spark\",\n\t\tinput: [\"text\"],\n\t\tcost: { input: 1.75, output: 14, cacheRead: 0.175, cacheWrite: 0 },\n\t\tcontextWindow: OPENAI_CODEX_SPARK_CONTEXT,\n\t},\n\t{\n\t\tid: \"gpt-5.4\",\n\t\tname: \"GPT-5.4\",\n\t\tinput: [\"text\", \"image\"],\n\t\tcost: withOpenAiLongContextPricing({ input: 2.5, output: 15, cacheRead: 0.25, cacheWrite: 0 }),\n\t\tcontextWindow: OPENAI_CODEX_CONTEXT,\n\t},\n\t{\n\t\tid: \"gpt-5.4-mini\",\n\t\tname: \"GPT-5.4 mini\",\n\t\tinput: [\"text\", \"image\"],\n\t\tcost: { input: 0.75, output: 4.5, cacheRead: 0.075, cacheWrite: 0 },\n\t\tcontextWindow: OPENAI_CODEX_CONTEXT,\n\t},\n\t{\n\t\tid: \"gpt-5.5\",\n\t\tname: \"GPT-5.5\",\n\t\tinput: [\"text\", \"image\"],\n\t\tcost: withOpenAiLongContextPricing({ input: 5, output: 30, cacheRead: 0.5, cacheWrite: 0 }),\n\t\tcontextWindow: OPENAI_CODEX_CONTEXT,\n\t},\n\t{\n\t\tid: \"gpt-5.6-luna\",\n\t\tname: \"GPT-5.6 Luna\",\n\t\tinput: [\"text\", \"image\"],\n\t\tcost: withOpenAiLongContextPricing(OPENAI_CODEX_GPT_56_COSTS[\"gpt-5.6-luna\"]),\n\t\tcontextWindow: OPENAI_CODEX_GPT_56_CONTEXT,\n\t\tthinkingLevelMap: { minimal: null },\n\t},\n\t{\n\t\tid: \"gpt-5.6-sol\",\n\t\tname: \"GPT-5.6 Sol\",\n\t\tinput: [\"text\", \"image\"],\n\t\tcost: withOpenAiLongContextPricing({ input: 5, output: 30, cacheRead: 0.5, cacheWrite: 6.25 }),\n\t\tcontextWindow: OPENAI_CODEX_GPT_56_CONTEXT,\n\t\tthinkingLevelMap: { minimal: null },\n\t},\n\t{\n\t\tid: \"gpt-5.6-terra\",\n\t\tname: \"GPT-5.6 Terra\",\n\t\tinput: [\"text\", \"image\"],\n\t\tcost: withOpenAiLongContextPricing(OPENAI_CODEX_GPT_56_COSTS[\"gpt-5.6-terra\"]),\n\t\tcontextWindow: OPENAI_CODEX_GPT_56_CONTEXT,\n\t\tthinkingLevelMap: { minimal: null },\n\t},\n];\n\nexport function openAICodexBuiltInModels(): Record<string, Model.Info> {\n\tconst models: Record<string, Model.Info> = {};\n\tfor (const seed of OPENAI_CODEX_MODELS) {\n\t\tconst supportsToolSearch = OPENAI_CODEX_TOOL_SEARCH_MODEL_IDS.has(seed.id);\n\t\tconst supportsAdditionalTools = OPENAI_CODEX_ADDITIONAL_TOOLS_MODEL_IDS.has(seed.id);\n\t\tconst info: Model.Info = {\n\t\t\t...seed,\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\t// Codex models always reason; the off level cannot be requested.\n\t\t\tthinkingLevelMap: { off: null, ...seed.thinkingLevelMap },\n\t\t\tmaxTokens: OPENAI_CODEX_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...(supportsToolSearch ? { supportsToolSearch: true } : {}),\n\t\t\t\t...(supportsAdditionalTools ? { supportsAdditionalTools: true } : {}),\n\t\t\t},\n\t\t\tprotocol: Model.KnownProviderEnum.openaiCodex,\n\t\t};\n\t\tapplyModelMetadata(info);\n\t\tmodels[seed.id] = info;\n\t}\n\treturn models;\n}\n\nexport async function generateModels(args: { path?: string | undefined } = {}): Promise<string> {\n\tconst path = resolve(args.path ?? ModelCatalog.path());\n\tconst modelsDev = await loadBuiltInFromModelsDev();\n\tconst customCodexModels = openAICodexBuiltInModels();\n\n\tconst allModels = { ...modelsDev, [OPENAI_CODEX_PROVIDER_ID]: customCodexModels };\n\tawait Filesystem.writeJson(path, allModels);\n\treturn path;\n}\n\n//\n// CLI entry\nexport const ModelgenCommand: CommandModule<object, { path?: string | undefined }> = {\n\tcommand: \"modelgen [path]\",\n\tdescribe: \"generate models.gen.json\",\n\tbuilder: (yargs) =>\n\t\tyargs.positional(\"path\", {\n\t\t\ttype: \"string\",\n\t\t\tdescribe: \"output path (defaults to CODEWORK_MODELS_FILE or ./models.gen.json)\",\n\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: {\n\t\t\tinput: model.cost?.input ?? 0,\n\t\t\toutput: model.cost?.output ?? 0,\n\t\t\tcacheRead: model.cost?.cache_read ?? 0,\n\t\t\tcacheWrite: model.cost?.cache_write ?? 0,\n\t\t},\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);\n\treturn info;\n}\n"],"mappings":";;;;;AASA,MAAM,6BAA+E;EAC3D,kBAAA,YAAY;EACZ,kBAAA,SAAS;EACT,kBAAA,aAAa;EACb,kBAAA,MAAM;AAChC;AAyDA,SAAS,eAAuB;CAC/B,OAAO,QAAQ,IAAI,uBAAuB;AAC3C;AAEA,SAAS,gBAAoC;CAC5C,OAAO,QAAQ,IAAI;AACpB;AAEA,MAAM,gBAAsC,KAAK,YAAY;CAC5D,MAAM,OAAO,cAAc;CAC3B,IAAI,MAAM;EACT,MAAM,SAAS,MAAMA,SAAsC,IAAI,CAAC,CAAC,YAAY,KAAA,CAAS;EACtF,IAAI,QAAQ,OAAO;CACpB;CAEA,MAAM,OAAO,MAAM,MAAM,GAAG,aAAa,EAAE,UAAU,CAAC,CAAC,MAAM,MAAM,EAAE,KAAK,CAAC;CAC3E,OAAO,KAAK,MAAM,IAAI;AACvB,CAAC;AAED,eAAe,oBAA+C;CAC7D,OAAO,cAAc;AACtB;AAEA,SAAS,aAAa,YAAoB,UAA6B,OAA+C;CACrH,OAAO,kBAAkB,YAAY,UAAU,KAAK;AACrD;AAEA,eAAe,2BAA2B;CACzC,MAAM,UAAU,MAAM,kBAAkB;CACxC,OAAO,KACN,SACA,QAAQ,aACP,OAAO,OAAO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AO,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,GAAG,OAAO,KAAK;CAC9D,mBAAmB,IAAI;CACvB,OAAO;AACR"}
@@ -1,2 +0,0 @@
1
- import { n as createOpenAICodex } from "./openai-codex-t4B7g-gv.mjs";
2
- export { createOpenAICodex };
@@ -1 +0,0 @@
1
- {"version":3,"file":"registry-DYdYTwFt.mjs","names":[],"sources":["../../src/llm/registry.ts"],"sourcesContent":["import type { LanguageModel } from \"ai\";\nimport * as Model from \"../model/model.ts\";\n\nexport const DEFAULT_AI_SDK_FALLBACK = \"@ai-sdk/openai-compatible\";\n\nexport const AI_SDK_PACKAGE_TO_PROTOCOL = {\n\t\"@ai-sdk/anthropic\": Model.KnownProviderEnum.anthropic,\n\t\"@ai-sdk/google\": Model.KnownProviderEnum.google,\n\t\"@ai-sdk/google-vertex\": Model.KnownProviderEnum.googleVertex,\n\t\"@ai-sdk/google-vertex/anthropic\": Model.KnownProviderEnum.googleVertexAnthropic,\n\t\"@ai-sdk/openai\": Model.KnownProviderEnum.openai,\n\t\"@ai-sdk/openai-compatible\": Model.KnownProviderEnum.openaiCompatible,\n\t\"@codeworksh/ai-sdk-openai-codex\": Model.KnownProviderEnum.openaiCodex, // custom provider npm ID\n\t\"@openrouter/ai-sdk-provider\": Model.KnownProviderEnum.openrouter,\n\t\"@ai-sdk/xai\": Model.KnownProviderEnum.xai,\n} as const;\n\nexport type AISDKPackage = keyof typeof AI_SDK_PACKAGE_TO_PROTOCOL;\nexport type AISDKProtocol = (typeof AI_SDK_PACKAGE_TO_PROTOCOL)[AISDKPackage];\n\ntype ProviderFactory = (options?: Record<string, unknown>) => unknown;\n\nconst PROVIDER_LOADERS: Record<AISDKPackage, () => Promise<ProviderFactory>> = {\n\t\"@ai-sdk/anthropic\": () => import(\"@ai-sdk/anthropic\").then((m) => m.createAnthropic as ProviderFactory),\n\t\"@ai-sdk/google\": () => import(\"@ai-sdk/google\").then((m) => m.createGoogleGenerativeAI as ProviderFactory),\n\t\"@ai-sdk/google-vertex\": () => import(\"@ai-sdk/google-vertex\").then((m) => m.createVertex as ProviderFactory),\n\t\"@ai-sdk/google-vertex/anthropic\": () =>\n\t\timport(\"@ai-sdk/google-vertex/anthropic\").then((m) => m.createVertexAnthropic as ProviderFactory),\n\t\"@ai-sdk/openai\": () => import(\"@ai-sdk/openai\").then((m) => m.createOpenAI as ProviderFactory),\n\t\"@ai-sdk/openai-compatible\": () =>\n\t\timport(\"@ai-sdk/openai-compatible\").then((m) => m.createOpenAICompatible as unknown as ProviderFactory),\n\t\"@openrouter/ai-sdk-provider\": () =>\n\t\timport(\"@openrouter/ai-sdk-provider\").then((m) => m.createOpenRouter as ProviderFactory),\n\t\"@ai-sdk/xai\": () => import(\"@ai-sdk/xai\").then((m) => m.createXai as ProviderFactory),\n\t// Local provider for OpenAI Codex subscriptions (ChatGPT OAuth); the package\n\t// name is virtual and resolves to src/providers/openai-codex.\n\t\"@codeworksh/ai-sdk-openai-codex\": () =>\n\t\timport(\"../providers/openai-codex/index.ts\").then((m) => m.createOpenAICodex as ProviderFactory),\n};\n\nexport function isAISDKPackage(value: string): value is AISDKPackage {\n\treturn value in AI_SDK_PACKAGE_TO_PROTOCOL;\n}\n\nexport function packageForModel(model: Model.Info): AISDKPackage {\n\tconst npm = model.npm ?? DEFAULT_AI_SDK_FALLBACK;\n\treturn isAISDKPackage(npm) ? npm : DEFAULT_AI_SDK_FALLBACK;\n}\n\nexport function protocolForPackage(npm: string | undefined): AISDKProtocol {\n\tconst resolved = npm && isAISDKPackage(npm) ? npm : DEFAULT_AI_SDK_FALLBACK;\n\treturn AI_SDK_PACKAGE_TO_PROTOCOL[resolved];\n}\n\nexport async function loadProviderFactory(npm: AISDKPackage): Promise<ProviderFactory> {\n\treturn PROVIDER_LOADERS[npm]();\n}\n\ntype ProviderWithMethods = {\n\t(modelId: string): LanguageModel;\n\tlanguageModel?: (modelId: string) => LanguageModel;\n\tchat?: (modelId: string) => LanguageModel;\n\tchatModel?: (modelId: string) => LanguageModel;\n\tcompletion?: (modelId: string) => LanguageModel;\n\tcompletionModel?: (modelId: string) => LanguageModel;\n\tmessages?: (modelId: string) => LanguageModel;\n\tresponses?: (modelId: string) => LanguageModel;\n};\n\nfunction defaultMethodForModel(model: Model.Info): Model.APIMethodEnum {\n\tif (\n\t\tmodel.protocol === Model.KnownProviderEnum.openai ||\n\t\tmodel.protocol === Model.KnownProviderEnum.openaiCodex ||\n\t\tmodel.protocol === Model.KnownProviderEnum.xai\n\t) {\n\t\treturn Model.APIMethodEnum.responses;\n\t}\n\treturn Model.APIMethodEnum.languageModel;\n}\n\nexport function resolveLanguageModel(\n\tprovider: unknown,\n\tmodel: Model.Info,\n\tmethodOverride?: Model.APIMethodEnum,\n): LanguageModel {\n\tconst modelId = model.api?.id ?? model.id;\n\tconst method = methodOverride ?? model.api?.method ?? defaultMethodForModel(model);\n\tconst callable = provider as ProviderWithMethods;\n\n\tif (method === Model.APIMethodEnum.responses && callable.responses) return callable.responses(modelId);\n\tif (method === Model.APIMethodEnum.messages && callable.messages) return callable.messages(modelId);\n\tif (method === Model.APIMethodEnum.chat) {\n\t\tif (callable.chat) return callable.chat(modelId);\n\t\tif (callable.chatModel) return callable.chatModel(modelId);\n\t}\n\tif (method === Model.APIMethodEnum.completion) {\n\t\tif (callable.completion) return callable.completion(modelId);\n\t\tif (callable.completionModel) return callable.completionModel(modelId);\n\t}\n\tif (method === Model.APIMethodEnum.completionModel && callable.completionModel) {\n\t\treturn callable.completionModel(modelId);\n\t}\n\tif (callable.languageModel) return callable.languageModel(modelId);\n\treturn callable(modelId);\n}\n"],"mappings":";;AAGA,MAAa,0BAA0B;AAEvC,MAAa,6BAA6B;CACzC,qBAAA,kBAA6C;CAC7C,kBAAA,kBAA0C;CAC1C,yBAAA,kBAAiD;CACjD,mCAAA,kBAA2D;CAC3D,kBAAA,kBAA0C;CAC1C,6BAAA,kBAAqD;CACrD,mCAAA,kBAA2D;CAC3D,+BAAA,kBAAuD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