@codeworksh/aikit 0.9.2 → 0.9.3-canary.10.1.g65d5c167

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/llm/failure.mjs CHANGED
@@ -1,3 +1,3 @@
1
1
  import { a as FailureSchema, c as ModelUnavailable, d as Timeout, f as Transport, h as isFailure, i as ContentPolicy, l as Quota, m as Unknown, n as Authorization, o as InvalidRequest, p as Unavailable, r as Configuration, s as InvalidResponse, t as Authentication, u as RateLimit } from "../schema-rXSoWhic.mjs";
2
- import { n as fromMessage, r as normalize } from "../failure-SAPyG-w2.mjs";
2
+ import { n as fromMessage, r as normalize } from "../failure-Bm4tDJMr.mjs";
3
3
  export { Authentication, Authorization, Configuration, ContentPolicy, FailureSchema, InvalidRequest, InvalidResponse, ModelUnavailable, Quota, RateLimit, Timeout, Transport, Unavailable, Unknown, fromMessage, isFailure, normalize };
@@ -61,11 +61,11 @@ declare const ModelCatalogLoadError$1: {
61
61
  };
62
62
  message: string;
63
63
  stack?: string;
64
- readonly "~effect/Runtime/errorExitCode"?: number;
65
- readonly "~effect/Runtime/errorReported"?: boolean;
66
64
  readonly "~effect/ErrorReporter/ignore"?: boolean;
67
65
  readonly "~effect/ErrorReporter/severity"?: import("effect/LogLevel").Severity;
68
66
  readonly "~effect/ErrorReporter/attributes"?: import("effect/Record").ReadonlyRecord<string, unknown>;
67
+ readonly "~effect/Runtime/errorExitCode"?: number;
68
+ readonly "~effect/Runtime/errorReported"?: boolean;
69
69
  };
70
70
  readonly Schema: {
71
71
  readonly $id: "ModelCatalogLoadError";
@@ -115,11 +115,11 @@ declare const ModelCatalogLoadError$1: {
115
115
  };
116
116
  message: string;
117
117
  stack?: string;
118
- readonly "~effect/Runtime/errorExitCode"?: number;
119
- readonly "~effect/Runtime/errorReported"?: boolean;
120
118
  readonly "~effect/ErrorReporter/ignore"?: boolean;
121
119
  readonly "~effect/ErrorReporter/severity"?: import("effect/LogLevel").Severity;
122
120
  readonly "~effect/ErrorReporter/attributes"?: import("effect/Record").ReadonlyRecord<string, unknown>;
121
+ readonly "~effect/Runtime/errorExitCode"?: number;
122
+ readonly "~effect/Runtime/errorReported"?: boolean;
123
123
  };
124
124
  create<Name extends string, Data extends Type$1.TSchema>(name: Name, data: Data): {
125
125
  new (data: import("typebox").StaticType<[], "Encode", {}, {}, Data>, options?: ErrorOptions): {
@@ -143,11 +143,11 @@ declare const ModelCatalogLoadError$1: {
143
143
  };
144
144
  message: string;
145
145
  stack?: string;
146
- readonly "~effect/Runtime/errorExitCode"?: number;
147
- readonly "~effect/Runtime/errorReported"?: boolean;
148
146
  readonly "~effect/ErrorReporter/ignore"?: boolean;
149
147
  readonly "~effect/ErrorReporter/severity"?: import("effect/LogLevel").Severity;
150
148
  readonly "~effect/ErrorReporter/attributes"?: import("effect/Record").ReadonlyRecord<string, unknown>;
149
+ readonly "~effect/Runtime/errorExitCode"?: number;
150
+ readonly "~effect/Runtime/errorReported"?: boolean;
151
151
  };
152
152
  readonly Schema: {
153
153
  readonly $id: Name;
@@ -198,11 +198,11 @@ declare const ModelCatalogLoadError$1: {
198
198
  };
199
199
  message: string;
200
200
  stack?: string;
201
- readonly "~effect/Runtime/errorExitCode"?: number;
202
- readonly "~effect/Runtime/errorReported"?: boolean;
203
201
  readonly "~effect/ErrorReporter/ignore"?: boolean;
204
202
  readonly "~effect/ErrorReporter/severity"?: import("effect/LogLevel").Severity;
205
203
  readonly "~effect/ErrorReporter/attributes"?: import("effect/Record").ReadonlyRecord<string, unknown>;
204
+ readonly "~effect/Runtime/errorExitCode"?: number;
205
+ readonly "~effect/Runtime/errorReported"?: boolean;
206
206
  };
207
207
  readonly Schema: {
208
208
  readonly $id: "UnknownError";
@@ -256,11 +256,11 @@ declare const ModelCatalogLoadError$1: {
256
256
  };
257
257
  message: string;
258
258
  stack?: string;
259
- readonly "~effect/Runtime/errorExitCode"?: number;
260
- readonly "~effect/Runtime/errorReported"?: boolean;
261
259
  readonly "~effect/ErrorReporter/ignore"?: boolean;
262
260
  readonly "~effect/ErrorReporter/severity"?: import("effect/LogLevel").Severity;
263
261
  readonly "~effect/ErrorReporter/attributes"?: import("effect/Record").ReadonlyRecord<string, unknown>;
262
+ readonly "~effect/Runtime/errorExitCode"?: number;
263
+ readonly "~effect/Runtime/errorReported"?: boolean;
264
264
  };
265
265
  create<Name extends string, Data extends Type$1.TSchema>(name: Name, data: Data): /*elided*/ any;
266
266
  readonly Unknown: /*elided*/ any;
@@ -308,11 +308,11 @@ declare const ModelCatalogLoadError$1: {
308
308
  };
309
309
  message: string;
310
310
  stack?: string;
311
- readonly "~effect/Runtime/errorExitCode"?: number;
312
- readonly "~effect/Runtime/errorReported"?: boolean;
313
311
  readonly "~effect/ErrorReporter/ignore"?: boolean;
314
312
  readonly "~effect/ErrorReporter/severity"?: import("effect/LogLevel").Severity;
315
313
  readonly "~effect/ErrorReporter/attributes"?: import("effect/Record").ReadonlyRecord<string, unknown>;
314
+ readonly "~effect/Runtime/errorExitCode"?: number;
315
+ readonly "~effect/Runtime/errorReported"?: boolean;
316
316
  };
317
317
  readonly Schema: {
318
318
  readonly $id: "UnknownError";
@@ -366,11 +366,11 @@ declare const ModelCatalogLoadError$1: {
366
366
  };
367
367
  message: string;
368
368
  stack?: string;
369
- readonly "~effect/Runtime/errorExitCode"?: number;
370
- readonly "~effect/Runtime/errorReported"?: boolean;
371
369
  readonly "~effect/ErrorReporter/ignore"?: boolean;
372
370
  readonly "~effect/ErrorReporter/severity"?: import("effect/LogLevel").Severity;
373
371
  readonly "~effect/ErrorReporter/attributes"?: import("effect/Record").ReadonlyRecord<string, unknown>;
372
+ readonly "~effect/Runtime/errorExitCode"?: number;
373
+ readonly "~effect/Runtime/errorReported"?: boolean;
374
374
  };
375
375
  create<Name extends string, Data extends Type$1.TSchema>(name: Name, data: Data): {
376
376
  new (data: import("typebox").StaticType<[], "Encode", {}, {}, Data>, options?: ErrorOptions): {
@@ -394,11 +394,11 @@ declare const ModelCatalogLoadError$1: {
394
394
  };
395
395
  message: string;
396
396
  stack?: string;
397
- readonly "~effect/Runtime/errorExitCode"?: number;
398
- readonly "~effect/Runtime/errorReported"?: boolean;
399
397
  readonly "~effect/ErrorReporter/ignore"?: boolean;
400
398
  readonly "~effect/ErrorReporter/severity"?: import("effect/LogLevel").Severity;
401
399
  readonly "~effect/ErrorReporter/attributes"?: import("effect/Record").ReadonlyRecord<string, unknown>;
400
+ readonly "~effect/Runtime/errorExitCode"?: number;
401
+ readonly "~effect/Runtime/errorReported"?: boolean;
402
402
  };
403
403
  readonly Schema: {
404
404
  readonly $id: Name;
@@ -494,11 +494,11 @@ declare const ModelCatalogLoadError: {
494
494
  };
495
495
  message: string;
496
496
  stack?: string;
497
- readonly "~effect/Runtime/errorExitCode"?: number;
498
- readonly "~effect/Runtime/errorReported"?: boolean;
499
497
  readonly "~effect/ErrorReporter/ignore"?: boolean;
500
498
  readonly "~effect/ErrorReporter/severity"?: import("effect/LogLevel").Severity;
501
499
  readonly "~effect/ErrorReporter/attributes"?: import("effect/Record").ReadonlyRecord<string, unknown>;
500
+ readonly "~effect/Runtime/errorExitCode"?: number;
501
+ readonly "~effect/Runtime/errorReported"?: boolean;
502
502
  };
503
503
  readonly Schema: {
504
504
  readonly $id: "ModelCatalogLoadError";
@@ -548,11 +548,11 @@ declare const ModelCatalogLoadError: {
548
548
  };
549
549
  message: string;
550
550
  stack?: string;
551
- readonly "~effect/Runtime/errorExitCode"?: number;
552
- readonly "~effect/Runtime/errorReported"?: boolean;
553
551
  readonly "~effect/ErrorReporter/ignore"?: boolean;
554
552
  readonly "~effect/ErrorReporter/severity"?: import("effect/LogLevel").Severity;
555
553
  readonly "~effect/ErrorReporter/attributes"?: import("effect/Record").ReadonlyRecord<string, unknown>;
554
+ readonly "~effect/Runtime/errorExitCode"?: number;
555
+ readonly "~effect/Runtime/errorReported"?: boolean;
556
556
  };
557
557
  create<Name extends string, Data extends Type$1.TSchema>(name: Name, data: Data): {
558
558
  new (data: import("typebox").StaticType<[], "Encode", {}, {}, Data>, options?: ErrorOptions): {
@@ -576,11 +576,11 @@ declare const ModelCatalogLoadError: {
576
576
  };
577
577
  message: string;
578
578
  stack?: string;
579
- readonly "~effect/Runtime/errorExitCode"?: number;
580
- readonly "~effect/Runtime/errorReported"?: boolean;
581
579
  readonly "~effect/ErrorReporter/ignore"?: boolean;
582
580
  readonly "~effect/ErrorReporter/severity"?: import("effect/LogLevel").Severity;
583
581
  readonly "~effect/ErrorReporter/attributes"?: import("effect/Record").ReadonlyRecord<string, unknown>;
582
+ readonly "~effect/Runtime/errorExitCode"?: number;
583
+ readonly "~effect/Runtime/errorReported"?: boolean;
584
584
  };
585
585
  readonly Schema: {
586
586
  readonly $id: Name;
@@ -631,11 +631,11 @@ declare const ModelCatalogLoadError: {
631
631
  };
632
632
  message: string;
633
633
  stack?: string;
634
- readonly "~effect/Runtime/errorExitCode"?: number;
635
- readonly "~effect/Runtime/errorReported"?: boolean;
636
634
  readonly "~effect/ErrorReporter/ignore"?: boolean;
637
635
  readonly "~effect/ErrorReporter/severity"?: import("effect/LogLevel").Severity;
638
636
  readonly "~effect/ErrorReporter/attributes"?: import("effect/Record").ReadonlyRecord<string, unknown>;
637
+ readonly "~effect/Runtime/errorExitCode"?: number;
638
+ readonly "~effect/Runtime/errorReported"?: boolean;
639
639
  };
640
640
  readonly Schema: {
641
641
  readonly $id: "UnknownError";
@@ -689,11 +689,11 @@ declare const ModelCatalogLoadError: {
689
689
  };
690
690
  message: string;
691
691
  stack?: string;
692
- readonly "~effect/Runtime/errorExitCode"?: number;
693
- readonly "~effect/Runtime/errorReported"?: boolean;
694
692
  readonly "~effect/ErrorReporter/ignore"?: boolean;
695
693
  readonly "~effect/ErrorReporter/severity"?: import("effect/LogLevel").Severity;
696
694
  readonly "~effect/ErrorReporter/attributes"?: import("effect/Record").ReadonlyRecord<string, unknown>;
695
+ readonly "~effect/Runtime/errorExitCode"?: number;
696
+ readonly "~effect/Runtime/errorReported"?: boolean;
697
697
  };
698
698
  create<Name extends string, Data extends Type$1.TSchema>(name: Name, data: Data): /*elided*/ any;
699
699
  readonly Unknown: /*elided*/ any;
@@ -741,11 +741,11 @@ declare const ModelCatalogLoadError: {
741
741
  };
742
742
  message: string;
743
743
  stack?: string;
744
- readonly "~effect/Runtime/errorExitCode"?: number;
745
- readonly "~effect/Runtime/errorReported"?: boolean;
746
744
  readonly "~effect/ErrorReporter/ignore"?: boolean;
747
745
  readonly "~effect/ErrorReporter/severity"?: import("effect/LogLevel").Severity;
748
746
  readonly "~effect/ErrorReporter/attributes"?: import("effect/Record").ReadonlyRecord<string, unknown>;
747
+ readonly "~effect/Runtime/errorExitCode"?: number;
748
+ readonly "~effect/Runtime/errorReported"?: boolean;
749
749
  };
750
750
  readonly Schema: {
751
751
  readonly $id: "UnknownError";
@@ -799,11 +799,11 @@ declare const ModelCatalogLoadError: {
799
799
  };
800
800
  message: string;
801
801
  stack?: string;
802
- readonly "~effect/Runtime/errorExitCode"?: number;
803
- readonly "~effect/Runtime/errorReported"?: boolean;
804
802
  readonly "~effect/ErrorReporter/ignore"?: boolean;
805
803
  readonly "~effect/ErrorReporter/severity"?: import("effect/LogLevel").Severity;
806
804
  readonly "~effect/ErrorReporter/attributes"?: import("effect/Record").ReadonlyRecord<string, unknown>;
805
+ readonly "~effect/Runtime/errorExitCode"?: number;
806
+ readonly "~effect/Runtime/errorReported"?: boolean;
807
807
  };
808
808
  create<Name extends string, Data extends Type$1.TSchema>(name: Name, data: Data): {
809
809
  new (data: import("typebox").StaticType<[], "Encode", {}, {}, Data>, options?: ErrorOptions): {
@@ -827,11 +827,11 @@ declare const ModelCatalogLoadError: {
827
827
  };
828
828
  message: string;
829
829
  stack?: string;
830
- readonly "~effect/Runtime/errorExitCode"?: number;
831
- readonly "~effect/Runtime/errorReported"?: boolean;
832
830
  readonly "~effect/ErrorReporter/ignore"?: boolean;
833
831
  readonly "~effect/ErrorReporter/severity"?: import("effect/LogLevel").Severity;
834
832
  readonly "~effect/ErrorReporter/attributes"?: import("effect/Record").ReadonlyRecord<string, unknown>;
833
+ readonly "~effect/Runtime/errorExitCode"?: number;
834
+ readonly "~effect/Runtime/errorReported"?: boolean;
835
835
  };
836
836
  readonly Schema: {
837
837
  readonly $id: Name;
@@ -1255,4 +1255,4 @@ declare function getSupportedThinkingLevels<TProtocol extends KnownProviderEnum>
1255
1255
  declare function clampThinkingLevel<TProtocol extends KnownProviderEnum>(model: TModel<TProtocol>, level: ThinkingLevel): ThinkingLevel;
1256
1256
  //#endregion
1257
1257
  export { KnownProviderEnum as a, ThinkingBudgets as c, getProviders as d, model_d_exports as f, Info as i, getModel as l, registry as m, ActiveThinkingLevel as n, ProviderToProtocol as o, modelsAreEqual as p, Compatibility as r, TModel as s, APIMethodEnum as t, getModels as u };
1258
- //# sourceMappingURL=model-BetbWJV7.d.mts.map
1258
+ //# sourceMappingURL=model-yhqJA3dm.d.mts.map
@@ -1,5 +1,5 @@
1
1
  import { S as writeJsonAtomic, b as path, g as normalizeInput, i as KnownProviderEnum, p as isAnthropicAdaptiveThinkingModel, t as APIMethodEnum, x as readJson } from "./model-Czo0SKj0.mjs";
2
- import { a as protocolForPackage, n as isAISDKPackage } from "./registry-vtzL8QxA.mjs";
2
+ import { a as protocolForPackage, n as isAISDKPackage } from "./registry-CZtcfRPL.mjs";
3
3
  import { n as GITHUB_COPILOT_STATIC_HEADERS } from "./copilot-headers-01-kLz8g.mjs";
4
4
  import { resolve } from "node:path";
5
5
  import { mapValues, pickBy, pipe } from "remeda";
@@ -58,14 +58,22 @@ const OPENAI_RESPONSES_NONE_REASONING_MODELS = /* @__PURE__ */ new Set([
58
58
  "gpt-5.4",
59
59
  "gpt-5.4-mini",
60
60
  "gpt-5.4-nano",
61
- "gpt-5.5"
61
+ "gpt-5.5",
62
+ "gpt-5.6-luna",
63
+ "gpt-5.6-sol",
64
+ "gpt-5.6-terra",
65
+ "gpt-6-luna",
66
+ "gpt-6-sol"
62
67
  ]);
68
+ const OPENAI_NO_MINIMAL_REASONING = /gpt-5\.[456]|gpt-6/;
69
+ function isOpenAiResponses(model) {
70
+ return model.protocol === KnownProviderEnum.openai || model.protocol === KnownProviderEnum.openaiCodex;
71
+ }
63
72
  function supportsOpenAiXhigh(model) {
64
- const modelId = model.id;
65
- return modelId.includes("gpt-5.2") || modelId.includes("gpt-5.3") || modelId.includes("gpt-5.4") || modelId.includes("gpt-5.5") || model.protocol === KnownProviderEnum.openaiCodex && modelId.includes("gpt-5.6");
73
+ return /gpt-5\.[2-5]/.test(model.id) || supportsOpenAiMax(model);
66
74
  }
67
- function supportsOpenAiCodexMax(model) {
68
- return model.protocol === KnownProviderEnum.openaiCodex && model.id.includes("gpt-5.6");
75
+ function supportsOpenAiMax(model) {
76
+ return isOpenAiResponses(model) && /gpt-5\.6|gpt-6/.test(model.id);
69
77
  }
70
78
  function mergeThinkingLevelMap(model, map) {
71
79
  model.thinkingLevelMap = {
@@ -124,9 +132,28 @@ function applyModelMetadata(model) {
124
132
  if (model.protocol === KnownProviderEnum.openai && model.id.startsWith("gpt-5")) mergeThinkingLevelMap(model, { off: null });
125
133
  if (model.protocol === KnownProviderEnum.openai && model.provider.id === "openai" && OPENAI_RESPONSES_NONE_REASONING_MODELS.has(model.id)) mergeThinkingLevelMap(model, { off: "none" });
126
134
  if (supportsOpenAiXhigh(model)) mergeThinkingLevelMap(model, { xhigh: "xhigh" });
127
- if (supportsOpenAiCodexMax(model)) mergeThinkingLevelMap(model, { max: "max" });
135
+ if (isOpenAiResponses(model) && OPENAI_NO_MINIMAL_REASONING.test(model.id)) mergeThinkingLevelMap(model, { minimal: null });
136
+ if (supportsOpenAiMax(model)) mergeThinkingLevelMap(model, { max: "max" });
128
137
  if (model.id.includes("opus-4-6") || model.id.includes("opus-4.6")) mergeThinkingLevelMap(model, { xhigh: "max" });
129
138
  if (model.id.includes("opus-4-7") || model.id.includes("opus-4.7")) mergeThinkingLevelMap(model, { xhigh: "xhigh" });
139
+ if (isAnthropicMessages(model)) applyAnthropicMetadata(model);
140
+ }
141
+ function isAnthropicMessages(model) {
142
+ return model.protocol === KnownProviderEnum.anthropic || model.protocol === KnownProviderEnum.googleVertexAnthropic;
143
+ }
144
+ function applyAnthropicMetadata(model) {
145
+ const id = model.id;
146
+ if (/sonnet-4[-.]5/.test(id)) model.contextWindow = 2e5;
147
+ if (/(opus|sonnet)-4[-.]6/.test(id)) mergeThinkingLevelMap(model, { max: "max" });
148
+ if (/opus-4[-.][78]|(opus|sonnet|fable)-5/.test(id)) mergeThinkingLevelMap(model, {
149
+ xhigh: "xhigh",
150
+ max: "max"
151
+ });
152
+ if (/(opus|sonnet)-5[-.]5/.test(id)) mergeThinkingLevelMap(model, {
153
+ off: null,
154
+ minimal: null
155
+ });
156
+ if (/fable-5/.test(id)) mergeThinkingLevelMap(model, { off: null });
130
157
  }
131
158
  const OPENAI_CODEX_PROVIDER_ID = "openai-codex";
132
159
  const OPENAI_CODEX_NPM = "@codeworksh/ai-sdk-openai-codex";
@@ -142,12 +169,19 @@ const OPENAI_CODEX_TOOL_SEARCH_MODEL_IDS = /* @__PURE__ */ new Set([
142
169
  "gpt-5.5",
143
170
  "gpt-5.6-luna",
144
171
  "gpt-5.6-sol",
145
- "gpt-5.6-terra"
172
+ "gpt-5.6-terra",
173
+ "gpt-6-luna"
146
174
  ]);
147
175
  const OPENAI_CODEX_ADDITIONAL_TOOLS_MODEL_IDS = /* @__PURE__ */ new Set([
148
176
  "gpt-5.6-luna",
149
177
  "gpt-5.6-sol",
150
- "gpt-5.6-terra"
178
+ "gpt-5.6-terra",
179
+ "gpt-6-luna"
180
+ ]);
181
+ const OPENAI_CODEX_NONE_REASONING_MODEL_IDS = /* @__PURE__ */ new Set([
182
+ "gpt-5.5",
183
+ "gpt-5.6-luna",
184
+ "gpt-6-luna"
151
185
  ]);
152
186
  function roundCost(value) {
153
187
  return Number(value.toFixed(6));
@@ -164,7 +198,7 @@ function withOpenAiLongContextPricing(cost) {
164
198
  }]
165
199
  };
166
200
  }
167
- const OPENAI_CODEX_GPT_56_COSTS = {
201
+ const OPENAI_CODEX_COSTS = {
168
202
  "gpt-5.6-luna": {
169
203
  input: .2,
170
204
  output: 1.2,
@@ -176,6 +210,12 @@ const OPENAI_CODEX_GPT_56_COSTS = {
176
210
  output: 12,
177
211
  cacheRead: .2,
178
212
  cacheWrite: 2.5
213
+ },
214
+ "gpt-6-luna": {
215
+ input: .1,
216
+ output: .5,
217
+ cacheRead: .01,
218
+ cacheWrite: .125
179
219
  }
180
220
  };
181
221
  const OPENAI_CODEX_MODELS = [
@@ -231,7 +271,7 @@ const OPENAI_CODEX_MODELS = [
231
271
  id: "gpt-5.6-luna",
232
272
  name: "GPT-5.6 Luna",
233
273
  input: ["text", "image"],
234
- cost: withOpenAiLongContextPricing(OPENAI_CODEX_GPT_56_COSTS["gpt-5.6-luna"]),
274
+ cost: withOpenAiLongContextPricing(OPENAI_CODEX_COSTS["gpt-5.6-luna"]),
235
275
  contextWindow: OPENAI_CODEX_GPT_56_CONTEXT,
236
276
  thinkingLevelMap: { minimal: null }
237
277
  },
@@ -252,9 +292,16 @@ const OPENAI_CODEX_MODELS = [
252
292
  id: "gpt-5.6-terra",
253
293
  name: "GPT-5.6 Terra",
254
294
  input: ["text", "image"],
255
- cost: withOpenAiLongContextPricing(OPENAI_CODEX_GPT_56_COSTS["gpt-5.6-terra"]),
295
+ cost: withOpenAiLongContextPricing(OPENAI_CODEX_COSTS["gpt-5.6-terra"]),
256
296
  contextWindow: OPENAI_CODEX_GPT_56_CONTEXT,
257
297
  thinkingLevelMap: { minimal: null }
298
+ },
299
+ {
300
+ id: "gpt-6-luna",
301
+ name: "GPT-6 Luna",
302
+ input: ["text", "image"],
303
+ cost: withOpenAiLongContextPricing(OPENAI_CODEX_COSTS["gpt-6-luna"]),
304
+ contextWindow: OPENAI_CODEX_GPT_56_CONTEXT
258
305
  }
259
306
  ];
260
307
  function openAICodexBuiltInModels() {
@@ -273,7 +320,7 @@ function openAICodexBuiltInModels() {
273
320
  baseUrl: OPENAI_CODEX_BASE_URL,
274
321
  reasoning: true,
275
322
  thinkingLevelMap: {
276
- off: null,
323
+ off: OPENAI_CODEX_NONE_REASONING_MODEL_IDS.has(seed.id) ? "none" : null,
277
324
  ...seed.thinkingLevelMap
278
325
  },
279
326
  maxTokens: OPENAI_CODEX_MAX_TOKENS,
@@ -511,4 +558,4 @@ function applyModification(providerId, provider, model) {
511
558
  //#endregion
512
559
  export { generateModels as n, ModelgenCommand as t };
513
560
 
514
- //# sourceMappingURL=modelgen-DR-uhl3l.mjs.map
561
+ //# sourceMappingURL=modelgen-BHm-jA64.mjs.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"modelgen-BHm-jA64.mjs","names":["Filesystem.readJson","Model.isAnthropicAdaptiveThinkingModel","path","ModelCatalog.path","Filesystem.writeJsonAtomic","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 { 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]: \"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\ttiers?: Array<{\n\t\t\tinput?: number;\n\t\t\toutput?: number;\n\t\t\tcache_read?: number;\n\t\t\tcache_write?: number;\n\t\t\ttier?: { type?: string; size?: number };\n\t\t}>;\n\t};\n\treasoning_options?: Array<{\n\t\ttype?: string;\n\t\tvalues?: string[];\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}\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\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\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\nfunction toModelValue(providerId: string, provider: ModelsDevProvider, model: ModelsDevModel): Model.Info | undefined {\n\treturn applyModification(providerId, provider, model);\n}\n\nfunction loadBuiltInFromModelsDev(catalog: ModelsDevCatalog) {\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\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// 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\nfunction isOpenAiResponses(model: Model.Info): boolean {\n\treturn model.protocol === Model.KnownProviderEnum.openai || model.protocol === Model.KnownProviderEnum.openaiCodex;\n}\n\nfunction supportsOpenAiXhigh(model: Model.Info): boolean {\n\treturn /gpt-5\\.[2-5]/.test(model.id) || supportsOpenAiMax(model);\n}\n\nfunction supportsOpenAiMax(model: Model.Info): boolean {\n\treturn isOpenAiResponses(model) && /gpt-5\\.6|gpt-6/.test(model.id);\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\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\tModel.isAnthropicAdaptiveThinkingModel(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 (isOpenAiResponses(model) && OPENAI_NO_MINIMAL_REASONING.test(model.id)) {\n\t\tmergeThinkingLevelMap(model, { minimal: null });\n\t}\n\tif (supportsOpenAiMax(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\tif (isAnthropicMessages(model)) applyAnthropicMetadata(model);\n}\n\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// 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\tif (/(opus|sonnet)-4[-.]6/.test(id)) {\n\t\tmergeThinkingLevelMap(model, { max: \"max\" });\n\t}\n\tif (/opus-4[-.][78]|(opus|sonnet|fable)-5/.test(id)) {\n\t\tmergeThinkingLevelMap(model, { xhigh: \"xhigh\", max: \"max\" });\n\t}\n\tif (/(opus|sonnet)-5[-.]5/.test(id)) {\n\t\tmergeThinkingLevelMap(model, { off: null, minimal: null });\n\t}\n\tif (/fable-5/.test(id)) {\n\t\tmergeThinkingLevelMap(model, { off: null });\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\t\"gpt-6-luna\",\n]);\nconst OPENAI_CODEX_ADDITIONAL_TOOLS_MODEL_IDS = new Set([\"gpt-5.6-luna\", \"gpt-5.6-sol\", \"gpt-5.6-terra\", \"gpt-6-luna\"]);\n// Checked live: the Codex backend accepts reasoning.effort \"none\" for these.\nconst OPENAI_CODEX_NONE_REASONING_MODEL_IDS = new Set([\"gpt-5.5\", \"gpt-5.6-luna\", \"gpt-6-luna\"]);\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_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\t\"gpt-6-luna\": { input: 0.1, output: 0.5, cacheRead: 0.01, cacheWrite: 0.125 },\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_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_COSTS[\"gpt-5.6-terra\"]),\n\t\tcontextWindow: OPENAI_CODEX_GPT_56_CONTEXT,\n\t\tthinkingLevelMap: { minimal: null },\n\t},\n\t{\n\t\tid: \"gpt-6-luna\",\n\t\tname: \"GPT-6 Luna\",\n\t\tinput: [\"text\", \"image\"],\n\t\tcost: withOpenAiLongContextPricing(OPENAI_CODEX_COSTS[\"gpt-6-luna\"]),\n\t\tcontextWindow: OPENAI_CODEX_GPT_56_CONTEXT,\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 reason unless verified to accept \"none\".\n\t\t\tthinkingLevelMap: {\n\t\t\t\toff: OPENAI_CODEX_NONE_REASONING_MODEL_IDS.has(seed.id) ? \"none\" : null,\n\t\t\t\t...seed.thinkingLevelMap,\n\t\t\t},\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\n//\n// GitHub Copilot models.\n// Sourced from models.dev, then rewritten onto the bundled provider: one\n// `github-copilot` protocol whose `api.method` selects between Chat\n// Completions, Responses, and Anthropic Messages.\nconst GITHUB_COPILOT_PROVIDER_ID = \"github-copilot\";\nconst GITHUB_COPILOT_NPM = \"@codeworksh/ai-sdk-github-copilot\";\nconst GITHUB_COPILOT_BASE_URL = \"https://api.githubcopilot.com\";\nconst GITHUB_COPILOT_EXTENDED_CONTEXT = 1_000_000;\n\n// GitHub's \"Models with extended capabilities\" table lists these Copilot\n// models as supporting the extended 1 million token context window (pi).\nconst GITHUB_COPILOT_EXTENDED_CONTEXT_MODELS = new Set([\n\t\"claude-fable-5\",\n\t\"claude-opus-4.6\",\n\t\"claude-opus-4.7\",\n\t\"claude-opus-4.8\",\n\t\"claude-opus-5\",\n\t\"claude-sonnet-4.6\",\n\t\"claude-sonnet-5\",\n\t\"gpt-5.3-codex\",\n\t\"gpt-5.4\",\n\t\"gpt-5.5\",\n]);\n\n// Checked manually against the authenticated GitHub Copilot /models endpoint\n// (pi). Narrow corrections over models.dev metadata, not a catalog snapshot.\nconst GITHUB_COPILOT_THINKING_LEVEL_OVERRIDES: Record<string, ThinkingLevelMap> = {\n\t\"claude-opus-4.7\": { minimal: \"low\" },\n\t\"claude-opus-4.8\": { minimal: \"low\" },\n\t\"claude-opus-5\": { minimal: \"low\" },\n\t\"claude-sonnet-4.6\": { minimal: \"low\", max: \"max\" },\n};\n\n/**\n * The offline routing approximation (pi). The live `/models` response's\n * `supported_endpoints` is authoritative at runtime.\n *\n * - `claude-(haiku|sonnet|opus|fable)-[45]` → Anthropic Messages\n * - `gpt-*`, `grok-*`, `oswe*`, `mai-*` → OpenAI Responses\n * - everything else → OpenAI Chat Completions\n */\nexport function githubCopilotApiMethod(modelId: string): Model.APIMethodEnum {\n\tif (/^claude-(haiku|sonnet|opus|fable)-[45]([.-]|$)/.test(modelId)) {\n\t\treturn Model.APIMethodEnum.messages;\n\t}\n\tconst gpt = /^gpt-(\\d+)/.exec(modelId);\n\tif (\n\t\t(gpt !== null && Number(gpt[1]) >= 5) ||\n\t\tmodelId.startsWith(\"grok-\") ||\n\t\tmodelId.startsWith(\"oswe\") ||\n\t\tmodelId.startsWith(\"mai-\")\n\t) {\n\t\treturn Model.APIMethodEnum.responses;\n\t}\n\treturn Model.APIMethodEnum.chat;\n}\n\n/** Effort values models.dev advertises for a model, when it lists any. */\nfunction githubCopilotEffortValues(model: ModelsDevModel): Set<string> | undefined {\n\tfor (const option of model.reasoning_options ?? []) {\n\t\tif (option.type === \"effort\" && Array.isArray(option.values)) return new Set(option.values);\n\t}\n\treturn undefined;\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 efforts = githubCopilotEffortValues(model);\n\tconst map: ThinkingLevelMap = {};\n\t// Copilot rejects `reasoningEffort: \"none\"` (pi), and the chat route has no\n\t// reasoning control, so only Messages models can disable thinking.\n\tif (method !== Model.APIMethodEnum.messages) map.off = null;\n\tif (!efforts) return Object.keys(map).length > 0 ? map : undefined;\n\n\tif (efforts.has(\"minimal\")) map.minimal = \"minimal\";\n\telse if (efforts.has(\"low\")) map.minimal = \"low\";\n\tfor (const level of [\"low\", \"medium\", \"high\", \"xhigh\", \"max\"] as const) {\n\t\tmap[level] = efforts.has(level) ? level : null;\n\t}\n\treturn map;\n}\n\nfunction githubCopilotCostTiers(model: ModelsDevModel): Model.Info[\"cost\"][\"tiers\"] | undefined {\n\tconst tiers = model.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 ?? 0,\n\t\t\t\toutput: tier.output ?? 0,\n\t\t\t\tcacheRead: tier.cache_read ?? 0,\n\t\t\t\tcacheWrite: tier.cache_write ?? 0,\n\t\t\t},\n\t\t];\n\t});\n\treturn tiers && tiers.length > 0 ? tiers : undefined;\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 tiers = githubCopilotCostTiers(source);\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\tcost: { ...base.cost, ...(tiers ? { tiers } : {}) },\n\t\t\tnpm: GITHUB_COPILOT_NPM,\n\t\t\tapi: { id, url: GITHUB_COPILOT_BASE_URL, method },\n\t\t\tproviderOptionsKey: GITHUB_COPILOT_PROVIDER_ID,\n\t\t\tprotocol: Model.KnownProviderEnum.githubCopilot,\n\t\t\t// Copilot's Responses route requires store=false + encrypted reasoning\n\t\t\t// content for thinking to round-trip.\n\t\t\t...(method === Model.APIMethodEnum.responses\n\t\t\t\t? {\n\t\t\t\t\t\tproviderOptions: {\n\t\t\t\t\t\t\t...base.providerOptions,\n\t\t\t\t\t\t\t[GITHUB_COPILOT_PROVIDER_ID]: {\n\t\t\t\t\t\t\t\tstore: false,\n\t\t\t\t\t\t\t\tinclude: [\"reasoning.encrypted_content\"],\n\t\t\t\t\t\t\t},\n\t\t\t\t\t\t},\n\t\t\t\t\t}\n\t\t\t\t: {}),\n\t\t};\n\n\t\tif (GITHUB_COPILOT_EXTENDED_CONTEXT_MODELS.has(id)) info.contextWindow = GITHUB_COPILOT_EXTENDED_CONTEXT;\n\t\tif (method === Model.APIMethodEnum.messages && Model.isAnthropicAdaptiveThinkingModel(id)) {\n\t\t\tmergeCompat(info, { forceAdaptiveThinking: true });\n\t\t}\n\t\t// Copilot's Responses endpoint passes OpenAI custom grammar tools through\n\t\t// for GPT-5+ (verified by pi).\n\t\tconst gpt = /^gpt-(\\d+)/.exec(id);\n\t\tif (method === Model.APIMethodEnum.responses && gpt !== null && Number(gpt[1]) >= 5) {\n\t\t\tmergeCompat(info, { supportsOpenAIGrammarTools: true });\n\t\t}\n\t\tif (id.startsWith(\"gpt-5\")) mergeThinkingLevelMap(info, { off: null, minimal: \"low\" });\n\t\tif (id.includes(\"fable-5\")) mergeThinkingLevelMap(info, { off: null, xhigh: \"xhigh\", max: \"max\" });\n\n\t\tconst levels = githubCopilotThinkingLevels(source, method);\n\t\tif (levels) mergeThinkingLevelMap(info, levels);\n\t\tconst override = GITHUB_COPILOT_THINKING_LEVEL_OVERRIDES[id];\n\t\tif (override) mergeThinkingLevelMap(info, override);\n\n\t\tmodels[id] = info;\n\t}\n\treturn models;\n}\n\nexport async function generateModels(args: { path?: string | undefined } = {}): Promise<string> {\n\tconst path = resolve(args.path ?? ModelCatalog.path());\n\tconst catalog = await pullModelsDevData();\n\tconst modelsDev = loadBuiltInFromModelsDev(catalog);\n\tconst customCodexModels = openAICodexBuiltInModels();\n\tconst copilotProvider = catalog[GITHUB_COPILOT_PROVIDER_ID];\n\n\tconst allModels = {\n\t\t...modelsDev,\n\t\t[OPENAI_CODEX_PROVIDER_ID]: customCodexModels,\n\t\t...(copilotProvider ? { [GITHUB_COPILOT_PROVIDER_ID]: githubCopilotBuiltInModels(copilotProvider) } : {}),\n\t};\n\tawait Filesystem.writeJsonAtomic(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;AAsEA,SAAS,eAAuB;CAC/B,OAAO,QAAQ,IAAI,uBAAuB;AAC3C;AAEA,SAAS,gBAAoC;CAC5C,OAAO,QAAQ,IAAI;AACpB;AAEA,eAAe,oBAA+C;CAC7D,MAAM,OAAO,cAAc;CAC3B,IAAI,MAAM;EACT,MAAM,SAAS,MAAMA,SAAsC,IAAI,CAAC,CAAC,YAAY,KAAA,CAAS;EACtF,IAAI,QAAQ,OAAO;CACpB;CAEA,MAAM,WAAW,MAAM,MAAM,GAAG,aAAa,EAAE,UAAU;CACzD,IAAI,CAAC,SAAS,IAAI,MAAM,IAAI,MAAM,wBAAwB,SAAS,OAAO,GAAG,SAAS,YAAY;CAClG,OAAQ,MAAM,SAAS,KAAK;AAC7B;AAEA,SAAS,aAAa,YAAoB,UAA6B,OAA+C;CACrH,OAAO,kBAAkB,YAAY,UAAU,KAAK;AACrD;AAEA,SAAS,yBAAyB,SAA2B;CAC5D,OAAO,KACN,SACA,QAAQ,aACP,OAAO,OAAO,SAAS,MAAM,CAAC,CAAC,MAI7B,UAAU,QAAQ,MAAM,SAAS,KAAK,eAAe,gBAAgB,UAAU,KAAK,CAAC,CACvF,CACD,GACA,WAAW,UAAU,eACpB,KACC,SAAS,QACT,QAAQ,UAAU,QAAQ,MAAM,SAAS,KAAK,eAAe,gBAAgB,UAAU,KAAK,CAAC,CAAC,GAC9F,WAAW,UAAU,aAAa,YAAY,UAAU,KAAK,CAAC,GAC9D,QAAQ,UAA+B,UAAU,KAAA,CAAS,CAC3D,CACD,CACD;AACD;AAIA,SAAS,gBAAgB,UAA6B,OAA+B;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EACA;EACA,oBAAoB,0BAA0B,QAAQ;EACtD;CACD;CACA,IAAI,OAAO,KAAK,KAAK,WAAW,CAAC,CAAC,CAAC,CAAC,WAAW,GAAG,OAAO,KAAK;CAC9D,mBAAmB,IAAI;CACvB,OAAO;AACR"}
package/modelgen.d.mts CHANGED
@@ -1,4 +1,4 @@
1
- import "./model-BetbWJV7.mjs";
1
+ import "./model-yhqJA3dm.mjs";
2
2
  import "yargs";
3
3
  //#region src/cli/modelgen.d.ts
4
4
  export declare function generateModels(args?: {
package/modelgen.mjs CHANGED
@@ -1,2 +1,2 @@
1
- import { n as generateModels } from "./modelgen-DR-uhl3l.mjs";
1
+ import { n as generateModels } from "./modelgen-BHm-jA64.mjs";
2
2
  export { generateModels };
@@ -0,0 +1,2 @@
1
+ import { n as createOpenAICodex } from "./openai-codex-MpxV35tx.mjs";
2
+ export { createOpenAICodex };
@@ -290,12 +290,37 @@ function syntheticSkippedToolCall(toolCall) {
290
290
  }
291
291
  };
292
292
  }
293
+ const USER_IMAGE_PLACEHOLDER = "(image omitted: model does not support images)";
294
+ const TOOL_IMAGE_PLACEHOLDER = "(tool image omitted: model does not support images)";
295
+ function omitImages(content, placeholder) {
296
+ const result = [];
297
+ for (const [index, block] of content.entries()) if (block.type === "text") result.push(block);
298
+ else if (content[index - 1]?.type !== "image") result.push({
299
+ type: "text",
300
+ text: placeholder
301
+ });
302
+ return result;
303
+ }
304
+ function omitToolImages(toolCall) {
305
+ if (!("result" in toolCall) || !toolCall.result.content.some((content) => content.type === "image")) return toolCall;
306
+ return {
307
+ ...toolCall,
308
+ result: {
309
+ ...toolCall.result,
310
+ content: omitImages(toolCall.result.content, TOOL_IMAGE_PLACEHOLDER)
311
+ }
312
+ };
313
+ }
293
314
  function transformMessages(messages, model, normalizeToolCallId) {
294
315
  const toolCallIDMap = /* @__PURE__ */ new Map();
316
+ const supportsImages = model.input.includes("image");
295
317
  const transformed = [];
296
318
  for (const msg of messages) {
297
319
  if (msg.role === "user") {
298
- transformed.push(msg);
320
+ transformed.push(supportsImages ? msg : {
321
+ ...msg,
322
+ parts: omitImages(msg.parts, USER_IMAGE_PLACEHOLDER)
323
+ });
299
324
  continue;
300
325
  }
301
326
  const assistantMsg = msg;
@@ -343,8 +368,9 @@ function transformMessages(messages, model, normalizeToolCallId) {
343
368
  }
344
369
  return block;
345
370
  }).map((block) => {
346
- if (block.type === "toolCall" && isUnresolvedToolCall(block)) return syntheticSkippedToolCall(block);
347
- return block;
371
+ if (block.type !== "toolCall") return block;
372
+ const toolCall = isUnresolvedToolCall(block) ? syntheticSkippedToolCall(block) : block;
373
+ return supportsImages ? toolCall : omitToolImages(toolCall);
348
374
  });
349
375
  transformed.push({
350
376
  ...assistantMsg,
@@ -1592,4 +1618,4 @@ const openaiCodex = createOpenAICodex();
1592
1618
  //#endregion
1593
1619
  export { ToolCallSchema as C, transformMessages as D, resolveJsonSchemaConstraint as E, AssistantMessageSchema as S, message_exports as T, appendOpenAICodexGrammarInputJsonDelta as _, OpenAICodexLanguageModel as a, resolveOpenAICodexDeferredToolsMode as b, convertOpenAICodexUsage as c, convertToOpenAICodexPrompt as d, joinToolCallId as f, shortHash as g, openAICodexErrorMessage as h, OPENAI_CODEX_DEFAULT_BASE_URL as i, mapOpenAICodexFinishReason as l, createOpenAICodexAPICallError as m, createOpenAICodex as n, clampOpenAICodexPromptCacheKey as o, splitToolCallId as p, openaiCodex as r, resolveOpenAICodexUrl as s, OPENAI_CODEX_API_KEY_ENV as t, collectOpenAICodexDeferredToolNames as u, openAICodexTools as v, createAssistantMessage as w, resolveOpenAICodexToolConstraint as x, prepareOpenAICodexTools as y };
1594
1620
 
1595
- //# sourceMappingURL=openai-codex-CpaJcE8Q.mjs.map
1621
+ //# sourceMappingURL=openai-codex-MpxV35tx.mjs.map