@discomedia/utils 1.0.67 → 1.0.69

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 (34) hide show
  1. package/dist/index-frontend.cjs +90 -438
  2. package/dist/index-frontend.cjs.map +1 -1
  3. package/dist/index-frontend.mjs +88 -439
  4. package/dist/index-frontend.mjs.map +1 -1
  5. package/dist/index.cjs +90 -438
  6. package/dist/index.cjs.map +1 -1
  7. package/dist/index.mjs +88 -439
  8. package/dist/index.mjs.map +1 -1
  9. package/dist/package.json +4 -4
  10. package/dist/test.js +663 -3568
  11. package/dist/test.js.map +1 -1
  12. package/dist/types/index-frontend.d.ts +1 -0
  13. package/dist/types/index-frontend.d.ts.map +1 -1
  14. package/dist/types/index.d.ts +1 -0
  15. package/dist/types/index.d.ts.map +1 -1
  16. package/dist/types/llm-config.d.ts +2 -2
  17. package/dist/types/llm-config.d.ts.map +1 -1
  18. package/dist/types/llm-images.d.ts.map +1 -1
  19. package/dist/types/llm-openai.d.ts +4 -16
  20. package/dist/types/llm-openai.d.ts.map +1 -1
  21. package/dist/types/types/llm-types.d.ts +7 -2
  22. package/dist/types/types/llm-types.d.ts.map +1 -1
  23. package/dist/types-frontend/index-frontend.d.ts +1 -0
  24. package/dist/types-frontend/index-frontend.d.ts.map +1 -1
  25. package/dist/types-frontend/index.d.ts +1 -0
  26. package/dist/types-frontend/index.d.ts.map +1 -1
  27. package/dist/types-frontend/llm-config.d.ts +2 -2
  28. package/dist/types-frontend/llm-config.d.ts.map +1 -1
  29. package/dist/types-frontend/llm-images.d.ts.map +1 -1
  30. package/dist/types-frontend/llm-openai.d.ts +4 -16
  31. package/dist/types-frontend/llm-openai.d.ts.map +1 -1
  32. package/dist/types-frontend/types/llm-types.d.ts +7 -2
  33. package/dist/types-frontend/types/llm-types.d.ts.map +1 -1
  34. package/package.json +4 -4
package/dist/index.cjs CHANGED
@@ -1141,6 +1141,29 @@ function dateTimeForGS(date) {
1141
1141
  .replace(/\./g, '/');
1142
1142
  }
1143
1143
 
1144
+ /**
1145
+ * Represents OpenAI models
1146
+ */
1147
+ const OPENAI_MODELS = [
1148
+ 'gpt-5',
1149
+ 'gpt-5-mini',
1150
+ 'gpt-5.4-mini',
1151
+ 'gpt-5-nano',
1152
+ 'gpt-5.1',
1153
+ 'gpt-5.4',
1154
+ 'gpt-5.5',
1155
+ 'gpt-5.5-pro',
1156
+ 'gpt-5.2',
1157
+ 'gpt-5.2-pro',
1158
+ 'gpt-5.1-codex',
1159
+ 'gpt-5.1-codex-max',
1160
+ ];
1161
+ /**
1162
+ * Type guard to check if a model is a supported direct OpenAI model.
1163
+ */
1164
+ function isOpenAIModel(model) {
1165
+ return OPENAI_MODELS.includes(model);
1166
+ }
1144
1167
  /**
1145
1168
  * Type guard to check if a model is an OpenRouter model
1146
1169
  */
@@ -1153,6 +1176,8 @@ function isOpenRouterModel(model) {
1153
1176
  'openai/gpt-5.1',
1154
1177
  'openai/gpt-5.4',
1155
1178
  'openai/gpt-5.4-pro',
1179
+ 'openai/gpt-5.5',
1180
+ 'openai/gpt-5.5-pro',
1156
1181
  'openai/gpt-5.2',
1157
1182
  'openai/gpt-5.2-pro',
1158
1183
  'openai/gpt-5.1-codex',
@@ -1170,6 +1195,8 @@ function isOpenRouterModel(model) {
1170
1195
 
1171
1196
  var Types = /*#__PURE__*/Object.freeze({
1172
1197
  __proto__: null,
1198
+ OPENAI_MODELS: OPENAI_MODELS,
1199
+ isOpenAIModel: isOpenAIModel,
1173
1200
  isOpenRouterModel: isOpenRouterModel
1174
1201
  });
1175
1202
 
@@ -1648,7 +1675,7 @@ const safeJSON = (text) => {
1648
1675
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
1649
1676
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
1650
1677
 
1651
- const VERSION = '6.34.0'; // x-release-please-version
1678
+ const VERSION = '6.35.0'; // x-release-please-version
1652
1679
 
1653
1680
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
1654
1681
  const isRunningInBrowser = () => {
@@ -4976,8 +5003,8 @@ class Speech extends APIResource {
4976
5003
  * ```ts
4977
5004
  * const speech = await client.audio.speech.create({
4978
5005
  * input: 'input',
4979
- * model: 'string',
4980
- * voice: 'string',
5006
+ * model: 'tts-1',
5007
+ * voice: 'alloy',
4981
5008
  * });
4982
5009
  *
4983
5010
  * const content = await speech.blob();
@@ -5455,10 +5482,10 @@ const toFloat32Array = (base64Str) => {
5455
5482
  */
5456
5483
  const readEnv = (env) => {
5457
5484
  if (typeof globalThis.process !== 'undefined') {
5458
- return globalThis.process.env?.[env]?.trim() ?? undefined;
5485
+ return globalThis.process.env?.[env]?.trim() || undefined;
5459
5486
  }
5460
5487
  if (typeof globalThis.Deno !== 'undefined') {
5461
- return globalThis.Deno.env?.get?.(env)?.trim();
5488
+ return globalThis.Deno.env?.get?.(env)?.trim() || undefined;
5462
5489
  }
5463
5490
  return undefined;
5464
5491
  };
@@ -9044,7 +9071,6 @@ OpenAI.Containers = Containers;
9044
9071
  OpenAI.Skills = Skills;
9045
9072
  OpenAI.Videos = Videos;
9046
9073
 
9047
- // functions
9048
9074
  function getEnumValues(entries) {
9049
9075
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
9050
9076
  const values = Object.entries(entries)
@@ -9190,7 +9216,7 @@ function process$1(schema, ctx, _params = { path: [], schemaPath: [] }) {
9190
9216
  delete result.schema.default;
9191
9217
  }
9192
9218
  // set prefault as default
9193
- if (ctx.io === "input" && result.schema._prefault)
9219
+ if (ctx.io === "input" && "_prefault" in result.schema)
9194
9220
  (_a = result.schema).default ?? (_a.default = result.schema._prefault);
9195
9221
  delete result.schema._prefault;
9196
9222
  // pulling fresh from ctx.seen in case it was overwritten
@@ -9418,11 +9444,20 @@ function finalize(ctx, schema) {
9418
9444
  result.$id = ctx.external.uri(id);
9419
9445
  }
9420
9446
  Object.assign(result, root.def ?? root.schema);
9447
+ // The `id` in `.meta()` is a Zod-specific registration tag used to extract
9448
+ // schemas into $defs — it is not user-facing JSON Schema metadata. Strip it
9449
+ // from the output body where it would otherwise leak. The id is preserved
9450
+ // implicitly via the $defs key (and via $ref paths).
9451
+ const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
9452
+ if (rootMetaId !== undefined && result.id === rootMetaId)
9453
+ delete result.id;
9421
9454
  // build defs object
9422
9455
  const defs = ctx.external?.defs ?? {};
9423
9456
  for (const entry of ctx.seen.entries()) {
9424
9457
  const seen = entry[1];
9425
9458
  if (seen.def && seen.defId) {
9459
+ if (seen.def.id === seen.defId)
9460
+ delete seen.def.id;
9426
9461
  defs[seen.defId] = seen.def;
9427
9462
  }
9428
9463
  }
@@ -9490,6 +9525,8 @@ function isTransforming(_schema, _ctx) {
9490
9525
  return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
9491
9526
  }
9492
9527
  if (def.type === "pipe") {
9528
+ if (_schema._zod.traits.has("$ZodCodec"))
9529
+ return true;
9493
9530
  return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
9494
9531
  }
9495
9532
  if (def.type === "object") {
@@ -9578,8 +9615,12 @@ const numberProcessor = (schema, ctx, _json, _params) => {
9578
9615
  json.type = "integer";
9579
9616
  else
9580
9617
  json.type = "number";
9581
- if (typeof exclusiveMinimum === "number") {
9582
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
9618
+ // when both minimum and exclusiveMinimum exist, pick the more restrictive one
9619
+ const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
9620
+ const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
9621
+ const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
9622
+ if (exMin) {
9623
+ if (legacy) {
9583
9624
  json.minimum = exclusiveMinimum;
9584
9625
  json.exclusiveMinimum = true;
9585
9626
  }
@@ -9587,17 +9628,11 @@ const numberProcessor = (schema, ctx, _json, _params) => {
9587
9628
  json.exclusiveMinimum = exclusiveMinimum;
9588
9629
  }
9589
9630
  }
9590
- if (typeof minimum === "number") {
9631
+ else if (typeof minimum === "number") {
9591
9632
  json.minimum = minimum;
9592
- if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
9593
- if (exclusiveMinimum >= minimum)
9594
- delete json.minimum;
9595
- else
9596
- delete json.exclusiveMinimum;
9597
- }
9598
9633
  }
9599
- if (typeof exclusiveMaximum === "number") {
9600
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
9634
+ if (exMax) {
9635
+ if (legacy) {
9601
9636
  json.maximum = exclusiveMaximum;
9602
9637
  json.exclusiveMaximum = true;
9603
9638
  }
@@ -9605,14 +9640,8 @@ const numberProcessor = (schema, ctx, _json, _params) => {
9605
9640
  json.exclusiveMaximum = exclusiveMaximum;
9606
9641
  }
9607
9642
  }
9608
- if (typeof maximum === "number") {
9643
+ else if (typeof maximum === "number") {
9609
9644
  json.maximum = maximum;
9610
- if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
9611
- if (exclusiveMaximum <= maximum)
9612
- delete json.maximum;
9613
- else
9614
- delete json.exclusiveMaximum;
9615
- }
9616
9645
  }
9617
9646
  if (typeof multipleOf === "number")
9618
9647
  json.multipleOf = multipleOf;
@@ -9795,7 +9824,10 @@ const arrayProcessor = (schema, ctx, _json, params) => {
9795
9824
  if (typeof maximum === "number")
9796
9825
  json.maxItems = maximum;
9797
9826
  json.type = "array";
9798
- json.items = process$1(def.element, ctx, { ...params, path: [...params.path, "items"] });
9827
+ json.items = process$1(def.element, ctx, {
9828
+ ...params,
9829
+ path: [...params.path, "items"],
9830
+ });
9799
9831
  };
9800
9832
  const objectProcessor = (schema, ctx, _json, params) => {
9801
9833
  const json = _json;
@@ -10012,7 +10044,8 @@ const catchProcessor = (schema, ctx, json, params) => {
10012
10044
  };
10013
10045
  const pipeProcessor = (schema, ctx, _json, params) => {
10014
10046
  const def = schema._zod.def;
10015
- const innerType = ctx.io === "input" ? (def.in._zod.def.type === "transform" ? def.out : def.in) : def.out;
10047
+ const inIsTransform = def.in._zod.traits.has("$ZodTransform");
10048
+ const innerType = ctx.io === "input" ? (inIsTransform ? def.out : def.in) : def.out;
10016
10049
  process$1(innerType, ctx, params);
10017
10050
  const seen = ctx.seen.get(schema);
10018
10051
  seen.ref = innerType;
@@ -10210,235 +10243,6 @@ function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
10210
10243
  addErrorMessage(res, key, errorMessage, refs);
10211
10244
  }
10212
10245
 
10213
- var util;
10214
- (function (util) {
10215
- util.assertEqual = (_) => { };
10216
- function assertIs(_arg) { }
10217
- util.assertIs = assertIs;
10218
- function assertNever(_x) {
10219
- throw new Error();
10220
- }
10221
- util.assertNever = assertNever;
10222
- util.arrayToEnum = (items) => {
10223
- const obj = {};
10224
- for (const item of items) {
10225
- obj[item] = item;
10226
- }
10227
- return obj;
10228
- };
10229
- util.getValidEnumValues = (obj) => {
10230
- const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
10231
- const filtered = {};
10232
- for (const k of validKeys) {
10233
- filtered[k] = obj[k];
10234
- }
10235
- return util.objectValues(filtered);
10236
- };
10237
- util.objectValues = (obj) => {
10238
- return util.objectKeys(obj).map(function (e) {
10239
- return obj[e];
10240
- });
10241
- };
10242
- util.objectKeys = typeof Object.keys === "function" // eslint-disable-line ban/ban
10243
- ? (obj) => Object.keys(obj) // eslint-disable-line ban/ban
10244
- : (object) => {
10245
- const keys = [];
10246
- for (const key in object) {
10247
- if (Object.prototype.hasOwnProperty.call(object, key)) {
10248
- keys.push(key);
10249
- }
10250
- }
10251
- return keys;
10252
- };
10253
- util.find = (arr, checker) => {
10254
- for (const item of arr) {
10255
- if (checker(item))
10256
- return item;
10257
- }
10258
- return undefined;
10259
- };
10260
- util.isInteger = typeof Number.isInteger === "function"
10261
- ? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
10262
- : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
10263
- function joinValues(array, separator = " | ") {
10264
- return array.map((val) => (typeof val === "string" ? `'${val}'` : val)).join(separator);
10265
- }
10266
- util.joinValues = joinValues;
10267
- util.jsonStringifyReplacer = (_, value) => {
10268
- if (typeof value === "bigint") {
10269
- return value.toString();
10270
- }
10271
- return value;
10272
- };
10273
- })(util || (util = {}));
10274
- var objectUtil;
10275
- (function (objectUtil) {
10276
- objectUtil.mergeShapes = (first, second) => {
10277
- return {
10278
- ...first,
10279
- ...second, // second overwrites first
10280
- };
10281
- };
10282
- })(objectUtil || (objectUtil = {}));
10283
- util.arrayToEnum([
10284
- "string",
10285
- "nan",
10286
- "number",
10287
- "integer",
10288
- "float",
10289
- "boolean",
10290
- "date",
10291
- "bigint",
10292
- "symbol",
10293
- "function",
10294
- "undefined",
10295
- "null",
10296
- "array",
10297
- "object",
10298
- "unknown",
10299
- "promise",
10300
- "void",
10301
- "never",
10302
- "map",
10303
- "set",
10304
- ]);
10305
-
10306
- util.arrayToEnum([
10307
- "invalid_type",
10308
- "invalid_literal",
10309
- "custom",
10310
- "invalid_union",
10311
- "invalid_union_discriminator",
10312
- "invalid_enum_value",
10313
- "unrecognized_keys",
10314
- "invalid_arguments",
10315
- "invalid_return_type",
10316
- "invalid_date",
10317
- "invalid_string",
10318
- "too_small",
10319
- "too_big",
10320
- "invalid_intersection_types",
10321
- "not_multiple_of",
10322
- "not_finite",
10323
- ]);
10324
- class ZodError extends Error {
10325
- get errors() {
10326
- return this.issues;
10327
- }
10328
- constructor(issues) {
10329
- super();
10330
- this.issues = [];
10331
- this.addIssue = (sub) => {
10332
- this.issues = [...this.issues, sub];
10333
- };
10334
- this.addIssues = (subs = []) => {
10335
- this.issues = [...this.issues, ...subs];
10336
- };
10337
- const actualProto = new.target.prototype;
10338
- if (Object.setPrototypeOf) {
10339
- // eslint-disable-next-line ban/ban
10340
- Object.setPrototypeOf(this, actualProto);
10341
- }
10342
- else {
10343
- this.__proto__ = actualProto;
10344
- }
10345
- this.name = "ZodError";
10346
- this.issues = issues;
10347
- }
10348
- format(_mapper) {
10349
- const mapper = _mapper ||
10350
- function (issue) {
10351
- return issue.message;
10352
- };
10353
- const fieldErrors = { _errors: [] };
10354
- const processError = (error) => {
10355
- for (const issue of error.issues) {
10356
- if (issue.code === "invalid_union") {
10357
- issue.unionErrors.map(processError);
10358
- }
10359
- else if (issue.code === "invalid_return_type") {
10360
- processError(issue.returnTypeError);
10361
- }
10362
- else if (issue.code === "invalid_arguments") {
10363
- processError(issue.argumentsError);
10364
- }
10365
- else if (issue.path.length === 0) {
10366
- fieldErrors._errors.push(mapper(issue));
10367
- }
10368
- else {
10369
- let curr = fieldErrors;
10370
- let i = 0;
10371
- while (i < issue.path.length) {
10372
- const el = issue.path[i];
10373
- const terminal = i === issue.path.length - 1;
10374
- if (!terminal) {
10375
- curr[el] = curr[el] || { _errors: [] };
10376
- // if (typeof el === "string") {
10377
- // curr[el] = curr[el] || { _errors: [] };
10378
- // } else if (typeof el === "number") {
10379
- // const errorArray: any = [];
10380
- // errorArray._errors = [];
10381
- // curr[el] = curr[el] || errorArray;
10382
- // }
10383
- }
10384
- else {
10385
- curr[el] = curr[el] || { _errors: [] };
10386
- curr[el]._errors.push(mapper(issue));
10387
- }
10388
- curr = curr[el];
10389
- i++;
10390
- }
10391
- }
10392
- }
10393
- };
10394
- processError(this);
10395
- return fieldErrors;
10396
- }
10397
- static assert(value) {
10398
- if (!(value instanceof ZodError)) {
10399
- throw new Error(`Not a ZodError: ${value}`);
10400
- }
10401
- }
10402
- toString() {
10403
- return this.message;
10404
- }
10405
- get message() {
10406
- return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
10407
- }
10408
- get isEmpty() {
10409
- return this.issues.length === 0;
10410
- }
10411
- flatten(mapper = (issue) => issue.message) {
10412
- const fieldErrors = Object.create(null);
10413
- const formErrors = [];
10414
- for (const sub of this.issues) {
10415
- if (sub.path.length > 0) {
10416
- const firstEl = sub.path[0];
10417
- fieldErrors[firstEl] = fieldErrors[firstEl] || [];
10418
- fieldErrors[firstEl].push(mapper(sub));
10419
- }
10420
- else {
10421
- formErrors.push(mapper(sub));
10422
- }
10423
- }
10424
- return { formErrors, fieldErrors };
10425
- }
10426
- get formErrors() {
10427
- return this.flatten();
10428
- }
10429
- }
10430
- ZodError.create = (issues) => {
10431
- const error = new ZodError(issues);
10432
- return error;
10433
- };
10434
-
10435
- var errorUtil;
10436
- (function (errorUtil) {
10437
- errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
10438
- // biome-ignore lint:
10439
- errorUtil.toString = (message) => typeof message === "string" ? message : message?.message;
10440
- })(errorUtil || (errorUtil = {}));
10441
-
10442
10246
  var ZodFirstPartyTypeKind;
10443
10247
  (function (ZodFirstPartyTypeKind) {
10444
10248
  ZodFirstPartyTypeKind["ZodString"] = "ZodString";
@@ -11819,57 +11623,12 @@ function zodTextFormat(zodObject, name, props) {
11819
11623
  }
11820
11624
 
11821
11625
  // llm-openai-config.ts
11822
- const DEFAULT_MODEL = 'gpt-4.1-mini';
11823
- const GPT_5_4_HIGH_CONTEXT_THRESHOLD_TOKENS = 272_000;
11824
- const GPT_5_4_HIGH_CONTEXT_INPUT_MULTIPLIER = 2;
11825
- const GPT_5_4_HIGH_CONTEXT_OUTPUT_MULTIPLIER = 1.5;
11826
- /** Token costs in USD per 1M tokens. Last updated Mar 2026. */
11626
+ const DEFAULT_MODEL = 'gpt-5-mini';
11627
+ const GPT_5_HIGH_CONTEXT_THRESHOLD_TOKENS = 272_000;
11628
+ const GPT_5_HIGH_CONTEXT_INPUT_MULTIPLIER = 2;
11629
+ const GPT_5_HIGH_CONTEXT_OUTPUT_MULTIPLIER = 1.5;
11630
+ /** Token costs in USD per 1M tokens. Last updated May 2026. */
11827
11631
  const openAiModelCosts = {
11828
- 'gpt-4o': {
11829
- inputCost: 2.5 / 1_000_000,
11830
- cacheHitCost: 1.25 / 1_000_000,
11831
- outputCost: 10 / 1_000_000,
11832
- },
11833
- 'gpt-4o-mini': {
11834
- inputCost: 0.15 / 1_000_000,
11835
- cacheHitCost: 0.075 / 1_000_000,
11836
- outputCost: 0.6 / 1_000_000,
11837
- },
11838
- 'o1-mini': {
11839
- inputCost: 1.1 / 1_000_000,
11840
- cacheHitCost: 0.55 / 1_000_000,
11841
- outputCost: 4.4 / 1_000_000,
11842
- },
11843
- 'o1': {
11844
- inputCost: 15 / 1_000_000,
11845
- cacheHitCost: 7.5 / 1_000_000,
11846
- outputCost: 60 / 1_000_000,
11847
- },
11848
- 'o3-mini': {
11849
- inputCost: 1.1 / 1_000_000,
11850
- cacheHitCost: 0.55 / 1_000_000,
11851
- outputCost: 4.4 / 1_000_000,
11852
- },
11853
- 'o3': {
11854
- inputCost: 2 / 1_000_000,
11855
- cacheHitCost: 0.5 / 1_000_000,
11856
- outputCost: 8 / 1_000_000,
11857
- },
11858
- 'gpt-4.1': {
11859
- inputCost: 2 / 1_000_000,
11860
- cacheHitCost: 0.5 / 1_000_000,
11861
- outputCost: 8 / 1_000_000,
11862
- },
11863
- 'gpt-4.1-mini': {
11864
- inputCost: 0.4 / 1_000_000,
11865
- cacheHitCost: 0.1 / 1_000_000,
11866
- outputCost: 1.6 / 1_000_000,
11867
- },
11868
- 'gpt-4.1-nano': {
11869
- inputCost: 0.1 / 1_000_000,
11870
- cacheHitCost: 0.025 / 1_000_000,
11871
- outputCost: 0.4 / 1_000_000,
11872
- },
11873
11632
  'gpt-5': {
11874
11633
  inputCost: 1.25 / 1_000_000,
11875
11634
  cacheHitCost: 0.125 / 1_000_000,
@@ -11900,7 +11659,12 @@ const openAiModelCosts = {
11900
11659
  cacheHitCost: 0.25 / 1_000_000,
11901
11660
  outputCost: 15 / 1_000_000,
11902
11661
  },
11903
- 'gpt-5.4-pro': {
11662
+ 'gpt-5.5': {
11663
+ inputCost: 5 / 1_000_000,
11664
+ cacheHitCost: 0.5 / 1_000_000,
11665
+ outputCost: 30 / 1_000_000,
11666
+ },
11667
+ 'gpt-5.5-pro': {
11904
11668
  inputCost: 30 / 1_000_000,
11905
11669
  outputCost: 180 / 1_000_000,
11906
11670
  },
@@ -11923,11 +11687,6 @@ const openAiModelCosts = {
11923
11687
  cacheHitCost: 0.125 / 1_000_000,
11924
11688
  outputCost: 10 / 1_000_000,
11925
11689
  },
11926
- 'o4-mini': {
11927
- inputCost: 1.1 / 1_000_000,
11928
- cacheHitCost: 0.275 / 1_000_000,
11929
- outputCost: 4.4 / 1_000_000,
11930
- },
11931
11690
  };
11932
11691
  const deepseekModelCosts = {
11933
11692
  'deepseek-chat': {
@@ -11941,8 +11700,8 @@ const deepseekModelCosts = {
11941
11700
  outputCost: 2.19 / 1_000_000, // $2.19 per 1M tokens
11942
11701
  },
11943
11702
  };
11944
- function shouldUseGPT54HighContextPricing(model, inputTokens) {
11945
- return (model === 'gpt-5.4' || model === 'gpt-5.4-pro') && inputTokens > GPT_5_4_HIGH_CONTEXT_THRESHOLD_TOKENS;
11703
+ function shouldUseGPT5HighContextPricing(model, inputTokens) {
11704
+ return (model === 'gpt-5.4' || model === 'gpt-5.5') && inputTokens > GPT_5_HIGH_CONTEXT_THRESHOLD_TOKENS;
11946
11705
  }
11947
11706
  /** Image generation costs in USD per image. Based on OpenAI pricing as of Feb 2025. */
11948
11707
  const openAiImageCosts = {
@@ -11995,10 +11754,10 @@ function calculateCost(provider, model, inputTokens, outputTokens, reasoningToke
11995
11754
  }
11996
11755
  let outputCost = outputTokens * modelCosts.outputCost;
11997
11756
  let reasoningCost = (reasoningTokens || 0) * modelCosts.outputCost;
11998
- if (provider === 'openai' && shouldUseGPT54HighContextPricing(model, inputTokens)) {
11999
- inputCost *= GPT_5_4_HIGH_CONTEXT_INPUT_MULTIPLIER;
12000
- outputCost *= GPT_5_4_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
12001
- reasoningCost *= GPT_5_4_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
11757
+ if (provider === 'openai' && shouldUseGPT5HighContextPricing(model, inputTokens)) {
11758
+ inputCost *= GPT_5_HIGH_CONTEXT_INPUT_MULTIPLIER;
11759
+ outputCost *= GPT_5_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
11760
+ reasoningCost *= GPT_5_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
12002
11761
  }
12003
11762
  return inputCost + outputCost + reasoningCost;
12004
11763
  }
@@ -12383,94 +12142,13 @@ async function parseResponse(content, responseFormat) {
12383
12142
  }
12384
12143
 
12385
12144
  // llm-openai.ts
12386
- const isSupportedModel = (model) => {
12387
- return [
12388
- 'gpt-4o-mini',
12389
- 'gpt-4o',
12390
- 'o1-mini',
12391
- 'o1',
12392
- 'o3-mini',
12393
- 'gpt-4.1',
12394
- 'gpt-4.1-mini',
12395
- 'gpt-4.1-nano',
12396
- 'gpt-5',
12397
- 'gpt-5-mini',
12398
- 'gpt-5.4-mini',
12399
- 'gpt-5-nano',
12400
- 'gpt-5.1',
12401
- 'gpt-5.4',
12402
- 'gpt-5.4-pro',
12403
- 'gpt-5.2',
12404
- 'gpt-5.2-pro',
12405
- 'gpt-5.1-codex',
12406
- 'gpt-5.1-codex-max',
12407
- 'o4-mini',
12408
- 'o3',
12409
- ].includes(model);
12410
- };
12411
12145
  /**
12412
- * Checks if the given model supports the temperature parameter. Reasoning models (o1*, o3*, o4*) do not support temperature.
12146
+ * Checks if the given direct OpenAI model supports the temperature parameter.
12413
12147
  * @param model The model to check.
12414
12148
  * @returns True if the model supports the temperature parameter, false otherwise.
12415
12149
  */
12416
- function supportsTemperature(model) {
12417
- // Reasoning models don't support temperature
12418
- // GPT-5 models also do not support temperature
12419
- const reasoningAndGPT5Models = [
12420
- 'o1',
12421
- 'o1-mini',
12422
- 'o3-mini',
12423
- 'o4-mini',
12424
- 'o3',
12425
- 'gpt-5',
12426
- 'gpt-5-mini',
12427
- 'gpt-5.4-mini',
12428
- 'gpt-5-nano',
12429
- 'gpt-5.1',
12430
- 'gpt-5.4',
12431
- 'gpt-5.4-pro',
12432
- 'gpt-5.2',
12433
- 'gpt-5.2-pro',
12434
- 'gpt-5.1-codex',
12435
- 'gpt-5.1-codex-max',
12436
- ];
12437
- return !reasoningAndGPT5Models.includes(model);
12438
- }
12439
- /**
12440
- * Checks if the given model is a reasoning model. Reasoning models have different tool choice constraints.
12441
- * @param model The model to check.
12442
- * @returns True if the model is a reasoning model, false otherwise.
12443
- */
12444
- function isReasoningModel(model) {
12445
- const reasoningModels = ['o1', 'o1-mini', 'o3-mini', 'o4-mini', 'o3'];
12446
- return reasoningModels.includes(model);
12447
- }
12448
- /**
12449
- * Checks if the given model is a GPT-5 model. GPT-5 models don't support tool_choice other than 'auto'.
12450
- * @param model The model to check.
12451
- * @returns True if the model is a GPT-5 model, false otherwise.
12452
- */
12453
- function isGPT5Model(model) {
12454
- const gpt5Models = [
12455
- 'gpt-5',
12456
- 'gpt-5-mini',
12457
- 'gpt-5.4-mini',
12458
- 'gpt-5-nano',
12459
- 'gpt-5.1',
12460
- 'gpt-5.4',
12461
- 'gpt-5.4-pro',
12462
- 'gpt-5.2',
12463
- 'gpt-5.2-pro',
12464
- 'gpt-5.1-codex',
12465
- 'gpt-5.1-codex-max',
12466
- ];
12467
- return gpt5Models.includes(model);
12468
- }
12469
- function supportsStructuredOutputs(model) {
12470
- return normalizeModelName(model) !== 'gpt-5.4-pro';
12471
- }
12472
- function supportsDistillation(model) {
12473
- return normalizeModelName(model) !== 'gpt-5.4-pro';
12150
+ function supportsTemperature(_model) {
12151
+ return false;
12474
12152
  }
12475
12153
  function isZodSchema(schema) {
12476
12154
  return typeof schema === 'object' && schema !== null && 'safeParse' in schema;
@@ -12505,7 +12183,7 @@ function buildJsonSchemaFormat(schema, schemaName, schemaDescription, schemaStri
12505
12183
  * - Built-in tools (web search, file search, computer use, code interpreter, image generation)
12506
12184
  * - Background processing
12507
12185
  * - Conversation state management
12508
- * - Reasoning support for o-series models
12186
+ * - GPT-5 reasoning controls
12509
12187
  *
12510
12188
  * @example
12511
12189
  * // Basic text response
@@ -12526,6 +12204,9 @@ function buildJsonSchemaFormat(schema, schemaName, schemaDescription, schemaStri
12526
12204
  */
12527
12205
  const makeResponsesAPICall = async (input, options = {}) => {
12528
12206
  const normalizedModel = normalizeModelName(options.model || DEFAULT_MODEL);
12207
+ if (!isOpenAIModel(normalizedModel)) {
12208
+ throw new Error(`Unsupported OpenAI model: ${normalizedModel}. Please use a supported GPT-5 model.`);
12209
+ }
12529
12210
  const apiKey = options.apiKey || process.env.OPENAI_API_KEY;
12530
12211
  if (!apiKey) {
12531
12212
  throw new Error('OpenAI API key is not provided and OPENAI_API_KEY environment variable is not set');
@@ -12540,12 +12221,6 @@ const makeResponsesAPICall = async (input, options = {}) => {
12540
12221
  input,
12541
12222
  ...cleanOptions,
12542
12223
  };
12543
- if (requestBody.text?.format?.type === 'json_schema' && !supportsStructuredOutputs(normalizedModel)) {
12544
- throw new Error(`Model ${normalizedModel} does not support structured outputs`);
12545
- }
12546
- if (requestBody.store && !supportsDistillation(normalizedModel)) {
12547
- throw new Error(`Model ${normalizedModel} does not support distillation`);
12548
- }
12549
12224
  // Make the API call to the Responses endpoint
12550
12225
  const response = await openai.responses.create(requestBody);
12551
12226
  const cacheHitTokens = response.usage?.input_tokens_details?.cached_tokens || 0;
@@ -12652,8 +12327,8 @@ async function makeLLMCall(input, options = {}) {
12652
12327
  const { apiKey, model = DEFAULT_MODEL, responseFormat = 'text', schema, schemaName = 'response', schemaDescription, schemaStrict, tools, useCodeInterpreter = false, useWebSearch = false, imageBase64, imageDetail = 'high', context, } = options;
12653
12328
  // Validate model
12654
12329
  const normalizedModel = normalizeModelName(model);
12655
- if (!isSupportedModel(normalizedModel)) {
12656
- throw new Error(`Unsupported model: ${normalizedModel}. Please use one of the supported models.`);
12330
+ if (!isOpenAIModel(normalizedModel)) {
12331
+ throw new Error(`Unsupported OpenAI model: ${normalizedModel}. Please use a supported GPT-5 model.`);
12657
12332
  }
12658
12333
  // Process input for conversation context and image analysis
12659
12334
  let processedInput;
@@ -12722,10 +12397,6 @@ async function makeLLMCall(input, options = {}) {
12722
12397
  parallel_tool_calls: false,
12723
12398
  tools,
12724
12399
  };
12725
- // Only include temperature if the model supports it
12726
- if (supportsTemperature(normalizedModel)) {
12727
- responsesOptions.temperature = 0.2;
12728
- }
12729
12400
  // Configure response format
12730
12401
  if (schema) {
12731
12402
  responsesOptions.text = {
@@ -12741,39 +12412,17 @@ async function makeLLMCall(input, options = {}) {
12741
12412
  // Configure built-in tools
12742
12413
  if (useCodeInterpreter) {
12743
12414
  responsesOptions.tools = [{ type: 'code_interpreter', container: { type: 'auto' } }];
12744
- // For reasoning models, we can't force tool choice - they only support 'auto'
12745
- if (!isReasoningModel(normalizedModel)) {
12746
- responsesOptions.tool_choice = { type: 'code_interpreter' };
12747
- }
12748
12415
  responsesOptions.include = ['code_interpreter_call.outputs'];
12749
12416
  }
12750
12417
  if (useWebSearch) {
12751
12418
  responsesOptions.tools = [{ type: 'web_search_preview' }];
12752
- // For reasoning models and GPT-5 models, we can't force tool choice - they only support 'auto'
12753
- if (!isReasoningModel(normalizedModel) && !isGPT5Model(normalizedModel)) {
12754
- responsesOptions.tool_choice = { type: 'web_search_preview' };
12755
- }
12756
12419
  }
12757
12420
  return await makeResponsesAPICall(processedInput, responsesOptions);
12758
12421
  }
12759
12422
 
12760
12423
  const DEFAULT_IMAGE_MODEL = 'gpt-image-1.5';
12761
12424
  const resolveImageModel = (model) => model ?? DEFAULT_IMAGE_MODEL;
12762
- const MULTIMODAL_VISION_MODELS = new Set([
12763
- 'gpt-4o-mini',
12764
- 'gpt-4o',
12765
- 'gpt-5',
12766
- 'gpt-5-mini',
12767
- 'gpt-5.4-mini',
12768
- 'gpt-5-nano',
12769
- 'gpt-5.1',
12770
- 'gpt-5.4',
12771
- 'gpt-5.4-pro',
12772
- 'gpt-5.2',
12773
- 'gpt-5.2-pro',
12774
- 'gpt-5.1-codex',
12775
- 'gpt-5.1-codex-max',
12776
- ]);
12425
+ const MULTIMODAL_VISION_MODELS = new Set(OPENAI_MODELS);
12777
12426
  /**
12778
12427
  * Makes a call to the OpenAI Images API to generate images based on a text prompt.
12779
12428
  *
@@ -21917,6 +21566,9 @@ const disco = {
21917
21566
 
21918
21567
  exports.AlpacaMarketDataAPI = AlpacaMarketDataAPI;
21919
21568
  exports.AlpacaTradingAPI = AlpacaTradingAPI;
21569
+ exports.OPENAI_MODELS = OPENAI_MODELS;
21920
21570
  exports.disco = disco;
21571
+ exports.isOpenAIModel = isOpenAIModel;
21921
21572
  exports.isOpenRouterModel = isOpenRouterModel;
21573
+ exports.supportsTemperature = supportsTemperature;
21922
21574
  //# sourceMappingURL=index.cjs.map