@discomedia/utils 1.0.67 → 1.0.68

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/dist/index.mjs CHANGED
@@ -1151,6 +1151,8 @@ function isOpenRouterModel(model) {
1151
1151
  'openai/gpt-5.1',
1152
1152
  'openai/gpt-5.4',
1153
1153
  'openai/gpt-5.4-pro',
1154
+ 'openai/gpt-5.5',
1155
+ 'openai/gpt-5.5-pro',
1154
1156
  'openai/gpt-5.2',
1155
1157
  'openai/gpt-5.2-pro',
1156
1158
  'openai/gpt-5.1-codex',
@@ -1646,7 +1648,7 @@ const safeJSON = (text) => {
1646
1648
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
1647
1649
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
1648
1650
 
1649
- const VERSION = '6.34.0'; // x-release-please-version
1651
+ const VERSION = '6.35.0'; // x-release-please-version
1650
1652
 
1651
1653
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
1652
1654
  const isRunningInBrowser = () => {
@@ -4974,8 +4976,8 @@ class Speech extends APIResource {
4974
4976
  * ```ts
4975
4977
  * const speech = await client.audio.speech.create({
4976
4978
  * input: 'input',
4977
- * model: 'string',
4978
- * voice: 'string',
4979
+ * model: 'tts-1',
4980
+ * voice: 'alloy',
4979
4981
  * });
4980
4982
  *
4981
4983
  * const content = await speech.blob();
@@ -5453,10 +5455,10 @@ const toFloat32Array = (base64Str) => {
5453
5455
  */
5454
5456
  const readEnv = (env) => {
5455
5457
  if (typeof globalThis.process !== 'undefined') {
5456
- return globalThis.process.env?.[env]?.trim() ?? undefined;
5458
+ return globalThis.process.env?.[env]?.trim() || undefined;
5457
5459
  }
5458
5460
  if (typeof globalThis.Deno !== 'undefined') {
5459
- return globalThis.Deno.env?.get?.(env)?.trim();
5461
+ return globalThis.Deno.env?.get?.(env)?.trim() || undefined;
5460
5462
  }
5461
5463
  return undefined;
5462
5464
  };
@@ -9042,7 +9044,6 @@ OpenAI.Containers = Containers;
9042
9044
  OpenAI.Skills = Skills;
9043
9045
  OpenAI.Videos = Videos;
9044
9046
 
9045
- // functions
9046
9047
  function getEnumValues(entries) {
9047
9048
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
9048
9049
  const values = Object.entries(entries)
@@ -9188,7 +9189,7 @@ function process$1(schema, ctx, _params = { path: [], schemaPath: [] }) {
9188
9189
  delete result.schema.default;
9189
9190
  }
9190
9191
  // set prefault as default
9191
- if (ctx.io === "input" && result.schema._prefault)
9192
+ if (ctx.io === "input" && "_prefault" in result.schema)
9192
9193
  (_a = result.schema).default ?? (_a.default = result.schema._prefault);
9193
9194
  delete result.schema._prefault;
9194
9195
  // pulling fresh from ctx.seen in case it was overwritten
@@ -9416,11 +9417,20 @@ function finalize(ctx, schema) {
9416
9417
  result.$id = ctx.external.uri(id);
9417
9418
  }
9418
9419
  Object.assign(result, root.def ?? root.schema);
9420
+ // The `id` in `.meta()` is a Zod-specific registration tag used to extract
9421
+ // schemas into $defs — it is not user-facing JSON Schema metadata. Strip it
9422
+ // from the output body where it would otherwise leak. The id is preserved
9423
+ // implicitly via the $defs key (and via $ref paths).
9424
+ const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
9425
+ if (rootMetaId !== undefined && result.id === rootMetaId)
9426
+ delete result.id;
9419
9427
  // build defs object
9420
9428
  const defs = ctx.external?.defs ?? {};
9421
9429
  for (const entry of ctx.seen.entries()) {
9422
9430
  const seen = entry[1];
9423
9431
  if (seen.def && seen.defId) {
9432
+ if (seen.def.id === seen.defId)
9433
+ delete seen.def.id;
9424
9434
  defs[seen.defId] = seen.def;
9425
9435
  }
9426
9436
  }
@@ -9488,6 +9498,8 @@ function isTransforming(_schema, _ctx) {
9488
9498
  return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
9489
9499
  }
9490
9500
  if (def.type === "pipe") {
9501
+ if (_schema._zod.traits.has("$ZodCodec"))
9502
+ return true;
9491
9503
  return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
9492
9504
  }
9493
9505
  if (def.type === "object") {
@@ -9576,8 +9588,12 @@ const numberProcessor = (schema, ctx, _json, _params) => {
9576
9588
  json.type = "integer";
9577
9589
  else
9578
9590
  json.type = "number";
9579
- if (typeof exclusiveMinimum === "number") {
9580
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
9591
+ // when both minimum and exclusiveMinimum exist, pick the more restrictive one
9592
+ const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
9593
+ const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
9594
+ const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
9595
+ if (exMin) {
9596
+ if (legacy) {
9581
9597
  json.minimum = exclusiveMinimum;
9582
9598
  json.exclusiveMinimum = true;
9583
9599
  }
@@ -9585,17 +9601,11 @@ const numberProcessor = (schema, ctx, _json, _params) => {
9585
9601
  json.exclusiveMinimum = exclusiveMinimum;
9586
9602
  }
9587
9603
  }
9588
- if (typeof minimum === "number") {
9604
+ else if (typeof minimum === "number") {
9589
9605
  json.minimum = minimum;
9590
- if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
9591
- if (exclusiveMinimum >= minimum)
9592
- delete json.minimum;
9593
- else
9594
- delete json.exclusiveMinimum;
9595
- }
9596
9606
  }
9597
- if (typeof exclusiveMaximum === "number") {
9598
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
9607
+ if (exMax) {
9608
+ if (legacy) {
9599
9609
  json.maximum = exclusiveMaximum;
9600
9610
  json.exclusiveMaximum = true;
9601
9611
  }
@@ -9603,14 +9613,8 @@ const numberProcessor = (schema, ctx, _json, _params) => {
9603
9613
  json.exclusiveMaximum = exclusiveMaximum;
9604
9614
  }
9605
9615
  }
9606
- if (typeof maximum === "number") {
9616
+ else if (typeof maximum === "number") {
9607
9617
  json.maximum = maximum;
9608
- if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
9609
- if (exclusiveMaximum <= maximum)
9610
- delete json.maximum;
9611
- else
9612
- delete json.exclusiveMaximum;
9613
- }
9614
9618
  }
9615
9619
  if (typeof multipleOf === "number")
9616
9620
  json.multipleOf = multipleOf;
@@ -9793,7 +9797,10 @@ const arrayProcessor = (schema, ctx, _json, params) => {
9793
9797
  if (typeof maximum === "number")
9794
9798
  json.maxItems = maximum;
9795
9799
  json.type = "array";
9796
- json.items = process$1(def.element, ctx, { ...params, path: [...params.path, "items"] });
9800
+ json.items = process$1(def.element, ctx, {
9801
+ ...params,
9802
+ path: [...params.path, "items"],
9803
+ });
9797
9804
  };
9798
9805
  const objectProcessor = (schema, ctx, _json, params) => {
9799
9806
  const json = _json;
@@ -10010,7 +10017,8 @@ const catchProcessor = (schema, ctx, json, params) => {
10010
10017
  };
10011
10018
  const pipeProcessor = (schema, ctx, _json, params) => {
10012
10019
  const def = schema._zod.def;
10013
- const innerType = ctx.io === "input" ? (def.in._zod.def.type === "transform" ? def.out : def.in) : def.out;
10020
+ const inIsTransform = def.in._zod.traits.has("$ZodTransform");
10021
+ const innerType = ctx.io === "input" ? (inIsTransform ? def.out : def.in) : def.out;
10014
10022
  process$1(innerType, ctx, params);
10015
10023
  const seen = ctx.seen.get(schema);
10016
10024
  seen.ref = innerType;
@@ -10208,235 +10216,6 @@ function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
10208
10216
  addErrorMessage(res, key, errorMessage, refs);
10209
10217
  }
10210
10218
 
10211
- var util;
10212
- (function (util) {
10213
- util.assertEqual = (_) => { };
10214
- function assertIs(_arg) { }
10215
- util.assertIs = assertIs;
10216
- function assertNever(_x) {
10217
- throw new Error();
10218
- }
10219
- util.assertNever = assertNever;
10220
- util.arrayToEnum = (items) => {
10221
- const obj = {};
10222
- for (const item of items) {
10223
- obj[item] = item;
10224
- }
10225
- return obj;
10226
- };
10227
- util.getValidEnumValues = (obj) => {
10228
- const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
10229
- const filtered = {};
10230
- for (const k of validKeys) {
10231
- filtered[k] = obj[k];
10232
- }
10233
- return util.objectValues(filtered);
10234
- };
10235
- util.objectValues = (obj) => {
10236
- return util.objectKeys(obj).map(function (e) {
10237
- return obj[e];
10238
- });
10239
- };
10240
- util.objectKeys = typeof Object.keys === "function" // eslint-disable-line ban/ban
10241
- ? (obj) => Object.keys(obj) // eslint-disable-line ban/ban
10242
- : (object) => {
10243
- const keys = [];
10244
- for (const key in object) {
10245
- if (Object.prototype.hasOwnProperty.call(object, key)) {
10246
- keys.push(key);
10247
- }
10248
- }
10249
- return keys;
10250
- };
10251
- util.find = (arr, checker) => {
10252
- for (const item of arr) {
10253
- if (checker(item))
10254
- return item;
10255
- }
10256
- return undefined;
10257
- };
10258
- util.isInteger = typeof Number.isInteger === "function"
10259
- ? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
10260
- : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
10261
- function joinValues(array, separator = " | ") {
10262
- return array.map((val) => (typeof val === "string" ? `'${val}'` : val)).join(separator);
10263
- }
10264
- util.joinValues = joinValues;
10265
- util.jsonStringifyReplacer = (_, value) => {
10266
- if (typeof value === "bigint") {
10267
- return value.toString();
10268
- }
10269
- return value;
10270
- };
10271
- })(util || (util = {}));
10272
- var objectUtil;
10273
- (function (objectUtil) {
10274
- objectUtil.mergeShapes = (first, second) => {
10275
- return {
10276
- ...first,
10277
- ...second, // second overwrites first
10278
- };
10279
- };
10280
- })(objectUtil || (objectUtil = {}));
10281
- util.arrayToEnum([
10282
- "string",
10283
- "nan",
10284
- "number",
10285
- "integer",
10286
- "float",
10287
- "boolean",
10288
- "date",
10289
- "bigint",
10290
- "symbol",
10291
- "function",
10292
- "undefined",
10293
- "null",
10294
- "array",
10295
- "object",
10296
- "unknown",
10297
- "promise",
10298
- "void",
10299
- "never",
10300
- "map",
10301
- "set",
10302
- ]);
10303
-
10304
- util.arrayToEnum([
10305
- "invalid_type",
10306
- "invalid_literal",
10307
- "custom",
10308
- "invalid_union",
10309
- "invalid_union_discriminator",
10310
- "invalid_enum_value",
10311
- "unrecognized_keys",
10312
- "invalid_arguments",
10313
- "invalid_return_type",
10314
- "invalid_date",
10315
- "invalid_string",
10316
- "too_small",
10317
- "too_big",
10318
- "invalid_intersection_types",
10319
- "not_multiple_of",
10320
- "not_finite",
10321
- ]);
10322
- class ZodError extends Error {
10323
- get errors() {
10324
- return this.issues;
10325
- }
10326
- constructor(issues) {
10327
- super();
10328
- this.issues = [];
10329
- this.addIssue = (sub) => {
10330
- this.issues = [...this.issues, sub];
10331
- };
10332
- this.addIssues = (subs = []) => {
10333
- this.issues = [...this.issues, ...subs];
10334
- };
10335
- const actualProto = new.target.prototype;
10336
- if (Object.setPrototypeOf) {
10337
- // eslint-disable-next-line ban/ban
10338
- Object.setPrototypeOf(this, actualProto);
10339
- }
10340
- else {
10341
- this.__proto__ = actualProto;
10342
- }
10343
- this.name = "ZodError";
10344
- this.issues = issues;
10345
- }
10346
- format(_mapper) {
10347
- const mapper = _mapper ||
10348
- function (issue) {
10349
- return issue.message;
10350
- };
10351
- const fieldErrors = { _errors: [] };
10352
- const processError = (error) => {
10353
- for (const issue of error.issues) {
10354
- if (issue.code === "invalid_union") {
10355
- issue.unionErrors.map(processError);
10356
- }
10357
- else if (issue.code === "invalid_return_type") {
10358
- processError(issue.returnTypeError);
10359
- }
10360
- else if (issue.code === "invalid_arguments") {
10361
- processError(issue.argumentsError);
10362
- }
10363
- else if (issue.path.length === 0) {
10364
- fieldErrors._errors.push(mapper(issue));
10365
- }
10366
- else {
10367
- let curr = fieldErrors;
10368
- let i = 0;
10369
- while (i < issue.path.length) {
10370
- const el = issue.path[i];
10371
- const terminal = i === issue.path.length - 1;
10372
- if (!terminal) {
10373
- curr[el] = curr[el] || { _errors: [] };
10374
- // if (typeof el === "string") {
10375
- // curr[el] = curr[el] || { _errors: [] };
10376
- // } else if (typeof el === "number") {
10377
- // const errorArray: any = [];
10378
- // errorArray._errors = [];
10379
- // curr[el] = curr[el] || errorArray;
10380
- // }
10381
- }
10382
- else {
10383
- curr[el] = curr[el] || { _errors: [] };
10384
- curr[el]._errors.push(mapper(issue));
10385
- }
10386
- curr = curr[el];
10387
- i++;
10388
- }
10389
- }
10390
- }
10391
- };
10392
- processError(this);
10393
- return fieldErrors;
10394
- }
10395
- static assert(value) {
10396
- if (!(value instanceof ZodError)) {
10397
- throw new Error(`Not a ZodError: ${value}`);
10398
- }
10399
- }
10400
- toString() {
10401
- return this.message;
10402
- }
10403
- get message() {
10404
- return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
10405
- }
10406
- get isEmpty() {
10407
- return this.issues.length === 0;
10408
- }
10409
- flatten(mapper = (issue) => issue.message) {
10410
- const fieldErrors = Object.create(null);
10411
- const formErrors = [];
10412
- for (const sub of this.issues) {
10413
- if (sub.path.length > 0) {
10414
- const firstEl = sub.path[0];
10415
- fieldErrors[firstEl] = fieldErrors[firstEl] || [];
10416
- fieldErrors[firstEl].push(mapper(sub));
10417
- }
10418
- else {
10419
- formErrors.push(mapper(sub));
10420
- }
10421
- }
10422
- return { formErrors, fieldErrors };
10423
- }
10424
- get formErrors() {
10425
- return this.flatten();
10426
- }
10427
- }
10428
- ZodError.create = (issues) => {
10429
- const error = new ZodError(issues);
10430
- return error;
10431
- };
10432
-
10433
- var errorUtil;
10434
- (function (errorUtil) {
10435
- errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
10436
- // biome-ignore lint:
10437
- errorUtil.toString = (message) => typeof message === "string" ? message : message?.message;
10438
- })(errorUtil || (errorUtil = {}));
10439
-
10440
10219
  var ZodFirstPartyTypeKind;
10441
10220
  (function (ZodFirstPartyTypeKind) {
10442
10221
  ZodFirstPartyTypeKind["ZodString"] = "ZodString";
@@ -11818,10 +11597,10 @@ function zodTextFormat(zodObject, name, props) {
11818
11597
 
11819
11598
  // llm-openai-config.ts
11820
11599
  const DEFAULT_MODEL = 'gpt-4.1-mini';
11821
- const GPT_5_4_HIGH_CONTEXT_THRESHOLD_TOKENS = 272_000;
11822
- const GPT_5_4_HIGH_CONTEXT_INPUT_MULTIPLIER = 2;
11823
- const GPT_5_4_HIGH_CONTEXT_OUTPUT_MULTIPLIER = 1.5;
11824
- /** Token costs in USD per 1M tokens. Last updated Mar 2026. */
11600
+ const GPT_5_HIGH_CONTEXT_THRESHOLD_TOKENS = 272_000;
11601
+ const GPT_5_HIGH_CONTEXT_INPUT_MULTIPLIER = 2;
11602
+ const GPT_5_HIGH_CONTEXT_OUTPUT_MULTIPLIER = 1.5;
11603
+ /** Token costs in USD per 1M tokens. Last updated May 2026. */
11825
11604
  const openAiModelCosts = {
11826
11605
  'gpt-4o': {
11827
11606
  inputCost: 2.5 / 1_000_000,
@@ -11902,6 +11681,15 @@ const openAiModelCosts = {
11902
11681
  inputCost: 30 / 1_000_000,
11903
11682
  outputCost: 180 / 1_000_000,
11904
11683
  },
11684
+ 'gpt-5.5': {
11685
+ inputCost: 5 / 1_000_000,
11686
+ cacheHitCost: 0.5 / 1_000_000,
11687
+ outputCost: 30 / 1_000_000,
11688
+ },
11689
+ 'gpt-5.5-pro': {
11690
+ inputCost: 30 / 1_000_000,
11691
+ outputCost: 180 / 1_000_000,
11692
+ },
11905
11693
  'gpt-5.2': {
11906
11694
  inputCost: 1.75 / 1_000_000,
11907
11695
  cacheHitCost: 0.175 / 1_000_000,
@@ -11939,8 +11727,9 @@ const deepseekModelCosts = {
11939
11727
  outputCost: 2.19 / 1_000_000, // $2.19 per 1M tokens
11940
11728
  },
11941
11729
  };
11942
- function shouldUseGPT54HighContextPricing(model, inputTokens) {
11943
- return (model === 'gpt-5.4' || model === 'gpt-5.4-pro') && inputTokens > GPT_5_4_HIGH_CONTEXT_THRESHOLD_TOKENS;
11730
+ function shouldUseGPT5HighContextPricing(model, inputTokens) {
11731
+ return ((model === 'gpt-5.4' || model === 'gpt-5.4-pro' || model === 'gpt-5.5') &&
11732
+ inputTokens > GPT_5_HIGH_CONTEXT_THRESHOLD_TOKENS);
11944
11733
  }
11945
11734
  /** Image generation costs in USD per image. Based on OpenAI pricing as of Feb 2025. */
11946
11735
  const openAiImageCosts = {
@@ -11993,10 +11782,10 @@ function calculateCost(provider, model, inputTokens, outputTokens, reasoningToke
11993
11782
  }
11994
11783
  let outputCost = outputTokens * modelCosts.outputCost;
11995
11784
  let reasoningCost = (reasoningTokens || 0) * modelCosts.outputCost;
11996
- if (provider === 'openai' && shouldUseGPT54HighContextPricing(model, inputTokens)) {
11997
- inputCost *= GPT_5_4_HIGH_CONTEXT_INPUT_MULTIPLIER;
11998
- outputCost *= GPT_5_4_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
11999
- reasoningCost *= GPT_5_4_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
11785
+ if (provider === 'openai' && shouldUseGPT5HighContextPricing(model, inputTokens)) {
11786
+ inputCost *= GPT_5_HIGH_CONTEXT_INPUT_MULTIPLIER;
11787
+ outputCost *= GPT_5_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
11788
+ reasoningCost *= GPT_5_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
12000
11789
  }
12001
11790
  return inputCost + outputCost + reasoningCost;
12002
11791
  }
@@ -12398,6 +12187,8 @@ const isSupportedModel = (model) => {
12398
12187
  'gpt-5.1',
12399
12188
  'gpt-5.4',
12400
12189
  'gpt-5.4-pro',
12190
+ 'gpt-5.5',
12191
+ 'gpt-5.5-pro',
12401
12192
  'gpt-5.2',
12402
12193
  'gpt-5.2-pro',
12403
12194
  'gpt-5.1-codex',
@@ -12427,6 +12218,8 @@ function supportsTemperature(model) {
12427
12218
  'gpt-5.1',
12428
12219
  'gpt-5.4',
12429
12220
  'gpt-5.4-pro',
12221
+ 'gpt-5.5',
12222
+ 'gpt-5.5-pro',
12430
12223
  'gpt-5.2',
12431
12224
  'gpt-5.2-pro',
12432
12225
  'gpt-5.1-codex',
@@ -12457,6 +12250,8 @@ function isGPT5Model(model) {
12457
12250
  'gpt-5.1',
12458
12251
  'gpt-5.4',
12459
12252
  'gpt-5.4-pro',
12253
+ 'gpt-5.5',
12254
+ 'gpt-5.5-pro',
12460
12255
  'gpt-5.2',
12461
12256
  'gpt-5.2-pro',
12462
12257
  'gpt-5.1-codex',
@@ -12767,6 +12562,8 @@ const MULTIMODAL_VISION_MODELS = new Set([
12767
12562
  'gpt-5.1',
12768
12563
  'gpt-5.4',
12769
12564
  'gpt-5.4-pro',
12565
+ 'gpt-5.5',
12566
+ 'gpt-5.5-pro',
12770
12567
  'gpt-5.2',
12771
12568
  'gpt-5.2-pro',
12772
12569
  'gpt-5.1-codex',