@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.
@@ -12,6 +12,8 @@ function isOpenRouterModel(model) {
12
12
  'openai/gpt-5.1',
13
13
  'openai/gpt-5.4',
14
14
  'openai/gpt-5.4-pro',
15
+ 'openai/gpt-5.5',
16
+ 'openai/gpt-5.5-pro',
15
17
  'openai/gpt-5.2',
16
18
  'openai/gpt-5.2-pro',
17
19
  'openai/gpt-5.1-codex',
@@ -294,7 +296,7 @@ const safeJSON = (text) => {
294
296
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
295
297
  const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
296
298
 
297
- const VERSION = '6.34.0'; // x-release-please-version
299
+ const VERSION = '6.35.0'; // x-release-please-version
298
300
 
299
301
  // File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
300
302
  const isRunningInBrowser = () => {
@@ -3622,8 +3624,8 @@ class Speech extends APIResource {
3622
3624
  * ```ts
3623
3625
  * const speech = await client.audio.speech.create({
3624
3626
  * input: 'input',
3625
- * model: 'string',
3626
- * voice: 'string',
3627
+ * model: 'tts-1',
3628
+ * voice: 'alloy',
3627
3629
  * });
3628
3630
  *
3629
3631
  * const content = await speech.blob();
@@ -4101,10 +4103,10 @@ const toFloat32Array = (base64Str) => {
4101
4103
  */
4102
4104
  const readEnv = (env) => {
4103
4105
  if (typeof globalThis.process !== 'undefined') {
4104
- return globalThis.process.env?.[env]?.trim() ?? undefined;
4106
+ return globalThis.process.env?.[env]?.trim() || undefined;
4105
4107
  }
4106
4108
  if (typeof globalThis.Deno !== 'undefined') {
4107
- return globalThis.Deno.env?.get?.(env)?.trim();
4109
+ return globalThis.Deno.env?.get?.(env)?.trim() || undefined;
4108
4110
  }
4109
4111
  return undefined;
4110
4112
  };
@@ -7690,7 +7692,6 @@ OpenAI.Containers = Containers;
7690
7692
  OpenAI.Skills = Skills;
7691
7693
  OpenAI.Videos = Videos;
7692
7694
 
7693
- // functions
7694
7695
  function getEnumValues(entries) {
7695
7696
  const numericValues = Object.values(entries).filter((v) => typeof v === "number");
7696
7697
  const values = Object.entries(entries)
@@ -7836,7 +7837,7 @@ function process$1(schema, ctx, _params = { path: [], schemaPath: [] }) {
7836
7837
  delete result.schema.default;
7837
7838
  }
7838
7839
  // set prefault as default
7839
- if (ctx.io === "input" && result.schema._prefault)
7840
+ if (ctx.io === "input" && "_prefault" in result.schema)
7840
7841
  (_a = result.schema).default ?? (_a.default = result.schema._prefault);
7841
7842
  delete result.schema._prefault;
7842
7843
  // pulling fresh from ctx.seen in case it was overwritten
@@ -8064,11 +8065,20 @@ function finalize(ctx, schema) {
8064
8065
  result.$id = ctx.external.uri(id);
8065
8066
  }
8066
8067
  Object.assign(result, root.def ?? root.schema);
8068
+ // The `id` in `.meta()` is a Zod-specific registration tag used to extract
8069
+ // schemas into $defs — it is not user-facing JSON Schema metadata. Strip it
8070
+ // from the output body where it would otherwise leak. The id is preserved
8071
+ // implicitly via the $defs key (and via $ref paths).
8072
+ const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
8073
+ if (rootMetaId !== undefined && result.id === rootMetaId)
8074
+ delete result.id;
8067
8075
  // build defs object
8068
8076
  const defs = ctx.external?.defs ?? {};
8069
8077
  for (const entry of ctx.seen.entries()) {
8070
8078
  const seen = entry[1];
8071
8079
  if (seen.def && seen.defId) {
8080
+ if (seen.def.id === seen.defId)
8081
+ delete seen.def.id;
8072
8082
  defs[seen.defId] = seen.def;
8073
8083
  }
8074
8084
  }
@@ -8136,6 +8146,8 @@ function isTransforming(_schema, _ctx) {
8136
8146
  return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
8137
8147
  }
8138
8148
  if (def.type === "pipe") {
8149
+ if (_schema._zod.traits.has("$ZodCodec"))
8150
+ return true;
8139
8151
  return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
8140
8152
  }
8141
8153
  if (def.type === "object") {
@@ -8224,8 +8236,12 @@ const numberProcessor = (schema, ctx, _json, _params) => {
8224
8236
  json.type = "integer";
8225
8237
  else
8226
8238
  json.type = "number";
8227
- if (typeof exclusiveMinimum === "number") {
8228
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
8239
+ // when both minimum and exclusiveMinimum exist, pick the more restrictive one
8240
+ const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
8241
+ const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
8242
+ const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
8243
+ if (exMin) {
8244
+ if (legacy) {
8229
8245
  json.minimum = exclusiveMinimum;
8230
8246
  json.exclusiveMinimum = true;
8231
8247
  }
@@ -8233,17 +8249,11 @@ const numberProcessor = (schema, ctx, _json, _params) => {
8233
8249
  json.exclusiveMinimum = exclusiveMinimum;
8234
8250
  }
8235
8251
  }
8236
- if (typeof minimum === "number") {
8252
+ else if (typeof minimum === "number") {
8237
8253
  json.minimum = minimum;
8238
- if (typeof exclusiveMinimum === "number" && ctx.target !== "draft-04") {
8239
- if (exclusiveMinimum >= minimum)
8240
- delete json.minimum;
8241
- else
8242
- delete json.exclusiveMinimum;
8243
- }
8244
8254
  }
8245
- if (typeof exclusiveMaximum === "number") {
8246
- if (ctx.target === "draft-04" || ctx.target === "openapi-3.0") {
8255
+ if (exMax) {
8256
+ if (legacy) {
8247
8257
  json.maximum = exclusiveMaximum;
8248
8258
  json.exclusiveMaximum = true;
8249
8259
  }
@@ -8251,14 +8261,8 @@ const numberProcessor = (schema, ctx, _json, _params) => {
8251
8261
  json.exclusiveMaximum = exclusiveMaximum;
8252
8262
  }
8253
8263
  }
8254
- if (typeof maximum === "number") {
8264
+ else if (typeof maximum === "number") {
8255
8265
  json.maximum = maximum;
8256
- if (typeof exclusiveMaximum === "number" && ctx.target !== "draft-04") {
8257
- if (exclusiveMaximum <= maximum)
8258
- delete json.maximum;
8259
- else
8260
- delete json.exclusiveMaximum;
8261
- }
8262
8266
  }
8263
8267
  if (typeof multipleOf === "number")
8264
8268
  json.multipleOf = multipleOf;
@@ -8441,7 +8445,10 @@ const arrayProcessor = (schema, ctx, _json, params) => {
8441
8445
  if (typeof maximum === "number")
8442
8446
  json.maxItems = maximum;
8443
8447
  json.type = "array";
8444
- json.items = process$1(def.element, ctx, { ...params, path: [...params.path, "items"] });
8448
+ json.items = process$1(def.element, ctx, {
8449
+ ...params,
8450
+ path: [...params.path, "items"],
8451
+ });
8445
8452
  };
8446
8453
  const objectProcessor = (schema, ctx, _json, params) => {
8447
8454
  const json = _json;
@@ -8658,7 +8665,8 @@ const catchProcessor = (schema, ctx, json, params) => {
8658
8665
  };
8659
8666
  const pipeProcessor = (schema, ctx, _json, params) => {
8660
8667
  const def = schema._zod.def;
8661
- const innerType = ctx.io === "input" ? (def.in._zod.def.type === "transform" ? def.out : def.in) : def.out;
8668
+ const inIsTransform = def.in._zod.traits.has("$ZodTransform");
8669
+ const innerType = ctx.io === "input" ? (inIsTransform ? def.out : def.in) : def.out;
8662
8670
  process$1(innerType, ctx, params);
8663
8671
  const seen = ctx.seen.get(schema);
8664
8672
  seen.ref = innerType;
@@ -8856,235 +8864,6 @@ function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
8856
8864
  addErrorMessage(res, key, errorMessage, refs);
8857
8865
  }
8858
8866
 
8859
- var util;
8860
- (function (util) {
8861
- util.assertEqual = (_) => { };
8862
- function assertIs(_arg) { }
8863
- util.assertIs = assertIs;
8864
- function assertNever(_x) {
8865
- throw new Error();
8866
- }
8867
- util.assertNever = assertNever;
8868
- util.arrayToEnum = (items) => {
8869
- const obj = {};
8870
- for (const item of items) {
8871
- obj[item] = item;
8872
- }
8873
- return obj;
8874
- };
8875
- util.getValidEnumValues = (obj) => {
8876
- const validKeys = util.objectKeys(obj).filter((k) => typeof obj[obj[k]] !== "number");
8877
- const filtered = {};
8878
- for (const k of validKeys) {
8879
- filtered[k] = obj[k];
8880
- }
8881
- return util.objectValues(filtered);
8882
- };
8883
- util.objectValues = (obj) => {
8884
- return util.objectKeys(obj).map(function (e) {
8885
- return obj[e];
8886
- });
8887
- };
8888
- util.objectKeys = typeof Object.keys === "function" // eslint-disable-line ban/ban
8889
- ? (obj) => Object.keys(obj) // eslint-disable-line ban/ban
8890
- : (object) => {
8891
- const keys = [];
8892
- for (const key in object) {
8893
- if (Object.prototype.hasOwnProperty.call(object, key)) {
8894
- keys.push(key);
8895
- }
8896
- }
8897
- return keys;
8898
- };
8899
- util.find = (arr, checker) => {
8900
- for (const item of arr) {
8901
- if (checker(item))
8902
- return item;
8903
- }
8904
- return undefined;
8905
- };
8906
- util.isInteger = typeof Number.isInteger === "function"
8907
- ? (val) => Number.isInteger(val) // eslint-disable-line ban/ban
8908
- : (val) => typeof val === "number" && Number.isFinite(val) && Math.floor(val) === val;
8909
- function joinValues(array, separator = " | ") {
8910
- return array.map((val) => (typeof val === "string" ? `'${val}'` : val)).join(separator);
8911
- }
8912
- util.joinValues = joinValues;
8913
- util.jsonStringifyReplacer = (_, value) => {
8914
- if (typeof value === "bigint") {
8915
- return value.toString();
8916
- }
8917
- return value;
8918
- };
8919
- })(util || (util = {}));
8920
- var objectUtil;
8921
- (function (objectUtil) {
8922
- objectUtil.mergeShapes = (first, second) => {
8923
- return {
8924
- ...first,
8925
- ...second, // second overwrites first
8926
- };
8927
- };
8928
- })(objectUtil || (objectUtil = {}));
8929
- util.arrayToEnum([
8930
- "string",
8931
- "nan",
8932
- "number",
8933
- "integer",
8934
- "float",
8935
- "boolean",
8936
- "date",
8937
- "bigint",
8938
- "symbol",
8939
- "function",
8940
- "undefined",
8941
- "null",
8942
- "array",
8943
- "object",
8944
- "unknown",
8945
- "promise",
8946
- "void",
8947
- "never",
8948
- "map",
8949
- "set",
8950
- ]);
8951
-
8952
- util.arrayToEnum([
8953
- "invalid_type",
8954
- "invalid_literal",
8955
- "custom",
8956
- "invalid_union",
8957
- "invalid_union_discriminator",
8958
- "invalid_enum_value",
8959
- "unrecognized_keys",
8960
- "invalid_arguments",
8961
- "invalid_return_type",
8962
- "invalid_date",
8963
- "invalid_string",
8964
- "too_small",
8965
- "too_big",
8966
- "invalid_intersection_types",
8967
- "not_multiple_of",
8968
- "not_finite",
8969
- ]);
8970
- class ZodError extends Error {
8971
- get errors() {
8972
- return this.issues;
8973
- }
8974
- constructor(issues) {
8975
- super();
8976
- this.issues = [];
8977
- this.addIssue = (sub) => {
8978
- this.issues = [...this.issues, sub];
8979
- };
8980
- this.addIssues = (subs = []) => {
8981
- this.issues = [...this.issues, ...subs];
8982
- };
8983
- const actualProto = new.target.prototype;
8984
- if (Object.setPrototypeOf) {
8985
- // eslint-disable-next-line ban/ban
8986
- Object.setPrototypeOf(this, actualProto);
8987
- }
8988
- else {
8989
- this.__proto__ = actualProto;
8990
- }
8991
- this.name = "ZodError";
8992
- this.issues = issues;
8993
- }
8994
- format(_mapper) {
8995
- const mapper = _mapper ||
8996
- function (issue) {
8997
- return issue.message;
8998
- };
8999
- const fieldErrors = { _errors: [] };
9000
- const processError = (error) => {
9001
- for (const issue of error.issues) {
9002
- if (issue.code === "invalid_union") {
9003
- issue.unionErrors.map(processError);
9004
- }
9005
- else if (issue.code === "invalid_return_type") {
9006
- processError(issue.returnTypeError);
9007
- }
9008
- else if (issue.code === "invalid_arguments") {
9009
- processError(issue.argumentsError);
9010
- }
9011
- else if (issue.path.length === 0) {
9012
- fieldErrors._errors.push(mapper(issue));
9013
- }
9014
- else {
9015
- let curr = fieldErrors;
9016
- let i = 0;
9017
- while (i < issue.path.length) {
9018
- const el = issue.path[i];
9019
- const terminal = i === issue.path.length - 1;
9020
- if (!terminal) {
9021
- curr[el] = curr[el] || { _errors: [] };
9022
- // if (typeof el === "string") {
9023
- // curr[el] = curr[el] || { _errors: [] };
9024
- // } else if (typeof el === "number") {
9025
- // const errorArray: any = [];
9026
- // errorArray._errors = [];
9027
- // curr[el] = curr[el] || errorArray;
9028
- // }
9029
- }
9030
- else {
9031
- curr[el] = curr[el] || { _errors: [] };
9032
- curr[el]._errors.push(mapper(issue));
9033
- }
9034
- curr = curr[el];
9035
- i++;
9036
- }
9037
- }
9038
- }
9039
- };
9040
- processError(this);
9041
- return fieldErrors;
9042
- }
9043
- static assert(value) {
9044
- if (!(value instanceof ZodError)) {
9045
- throw new Error(`Not a ZodError: ${value}`);
9046
- }
9047
- }
9048
- toString() {
9049
- return this.message;
9050
- }
9051
- get message() {
9052
- return JSON.stringify(this.issues, util.jsonStringifyReplacer, 2);
9053
- }
9054
- get isEmpty() {
9055
- return this.issues.length === 0;
9056
- }
9057
- flatten(mapper = (issue) => issue.message) {
9058
- const fieldErrors = Object.create(null);
9059
- const formErrors = [];
9060
- for (const sub of this.issues) {
9061
- if (sub.path.length > 0) {
9062
- const firstEl = sub.path[0];
9063
- fieldErrors[firstEl] = fieldErrors[firstEl] || [];
9064
- fieldErrors[firstEl].push(mapper(sub));
9065
- }
9066
- else {
9067
- formErrors.push(mapper(sub));
9068
- }
9069
- }
9070
- return { formErrors, fieldErrors };
9071
- }
9072
- get formErrors() {
9073
- return this.flatten();
9074
- }
9075
- }
9076
- ZodError.create = (issues) => {
9077
- const error = new ZodError(issues);
9078
- return error;
9079
- };
9080
-
9081
- var errorUtil;
9082
- (function (errorUtil) {
9083
- errorUtil.errToObj = (message) => typeof message === "string" ? { message } : message || {};
9084
- // biome-ignore lint:
9085
- errorUtil.toString = (message) => typeof message === "string" ? message : message?.message;
9086
- })(errorUtil || (errorUtil = {}));
9087
-
9088
8867
  var ZodFirstPartyTypeKind;
9089
8868
  (function (ZodFirstPartyTypeKind) {
9090
8869
  ZodFirstPartyTypeKind["ZodString"] = "ZodString";
@@ -10466,10 +10245,10 @@ function zodTextFormat(zodObject, name, props) {
10466
10245
 
10467
10246
  // llm-openai-config.ts
10468
10247
  const DEFAULT_MODEL = 'gpt-4.1-mini';
10469
- const GPT_5_4_HIGH_CONTEXT_THRESHOLD_TOKENS = 272_000;
10470
- const GPT_5_4_HIGH_CONTEXT_INPUT_MULTIPLIER = 2;
10471
- const GPT_5_4_HIGH_CONTEXT_OUTPUT_MULTIPLIER = 1.5;
10472
- /** Token costs in USD per 1M tokens. Last updated Mar 2026. */
10248
+ const GPT_5_HIGH_CONTEXT_THRESHOLD_TOKENS = 272_000;
10249
+ const GPT_5_HIGH_CONTEXT_INPUT_MULTIPLIER = 2;
10250
+ const GPT_5_HIGH_CONTEXT_OUTPUT_MULTIPLIER = 1.5;
10251
+ /** Token costs in USD per 1M tokens. Last updated May 2026. */
10473
10252
  const openAiModelCosts = {
10474
10253
  'gpt-4o': {
10475
10254
  inputCost: 2.5 / 1_000_000,
@@ -10550,6 +10329,15 @@ const openAiModelCosts = {
10550
10329
  inputCost: 30 / 1_000_000,
10551
10330
  outputCost: 180 / 1_000_000,
10552
10331
  },
10332
+ 'gpt-5.5': {
10333
+ inputCost: 5 / 1_000_000,
10334
+ cacheHitCost: 0.5 / 1_000_000,
10335
+ outputCost: 30 / 1_000_000,
10336
+ },
10337
+ 'gpt-5.5-pro': {
10338
+ inputCost: 30 / 1_000_000,
10339
+ outputCost: 180 / 1_000_000,
10340
+ },
10553
10341
  'gpt-5.2': {
10554
10342
  inputCost: 1.75 / 1_000_000,
10555
10343
  cacheHitCost: 0.175 / 1_000_000,
@@ -10587,8 +10375,9 @@ const deepseekModelCosts = {
10587
10375
  outputCost: 2.19 / 1_000_000, // $2.19 per 1M tokens
10588
10376
  },
10589
10377
  };
10590
- function shouldUseGPT54HighContextPricing(model, inputTokens) {
10591
- return (model === 'gpt-5.4' || model === 'gpt-5.4-pro') && inputTokens > GPT_5_4_HIGH_CONTEXT_THRESHOLD_TOKENS;
10378
+ function shouldUseGPT5HighContextPricing(model, inputTokens) {
10379
+ return ((model === 'gpt-5.4' || model === 'gpt-5.4-pro' || model === 'gpt-5.5') &&
10380
+ inputTokens > GPT_5_HIGH_CONTEXT_THRESHOLD_TOKENS);
10592
10381
  }
10593
10382
  /** Image generation costs in USD per image. Based on OpenAI pricing as of Feb 2025. */
10594
10383
  const openAiImageCosts = {
@@ -10641,10 +10430,10 @@ function calculateCost(provider, model, inputTokens, outputTokens, reasoningToke
10641
10430
  }
10642
10431
  let outputCost = outputTokens * modelCosts.outputCost;
10643
10432
  let reasoningCost = (reasoningTokens || 0) * modelCosts.outputCost;
10644
- if (provider === 'openai' && shouldUseGPT54HighContextPricing(model, inputTokens)) {
10645
- inputCost *= GPT_5_4_HIGH_CONTEXT_INPUT_MULTIPLIER;
10646
- outputCost *= GPT_5_4_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
10647
- reasoningCost *= GPT_5_4_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
10433
+ if (provider === 'openai' && shouldUseGPT5HighContextPricing(model, inputTokens)) {
10434
+ inputCost *= GPT_5_HIGH_CONTEXT_INPUT_MULTIPLIER;
10435
+ outputCost *= GPT_5_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
10436
+ reasoningCost *= GPT_5_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
10648
10437
  }
10649
10438
  return inputCost + outputCost + reasoningCost;
10650
10439
  }
@@ -11046,6 +10835,8 @@ const isSupportedModel = (model) => {
11046
10835
  'gpt-5.1',
11047
10836
  'gpt-5.4',
11048
10837
  'gpt-5.4-pro',
10838
+ 'gpt-5.5',
10839
+ 'gpt-5.5-pro',
11049
10840
  'gpt-5.2',
11050
10841
  'gpt-5.2-pro',
11051
10842
  'gpt-5.1-codex',
@@ -11075,6 +10866,8 @@ function supportsTemperature(model) {
11075
10866
  'gpt-5.1',
11076
10867
  'gpt-5.4',
11077
10868
  'gpt-5.4-pro',
10869
+ 'gpt-5.5',
10870
+ 'gpt-5.5-pro',
11078
10871
  'gpt-5.2',
11079
10872
  'gpt-5.2-pro',
11080
10873
  'gpt-5.1-codex',
@@ -11105,6 +10898,8 @@ function isGPT5Model(model) {
11105
10898
  'gpt-5.1',
11106
10899
  'gpt-5.4',
11107
10900
  'gpt-5.4-pro',
10901
+ 'gpt-5.5',
10902
+ 'gpt-5.5-pro',
11108
10903
  'gpt-5.2',
11109
10904
  'gpt-5.2-pro',
11110
10905
  'gpt-5.1-codex',
@@ -11415,6 +11210,8 @@ const MULTIMODAL_VISION_MODELS = new Set([
11415
11210
  'gpt-5.1',
11416
11211
  'gpt-5.4',
11417
11212
  'gpt-5.4-pro',
11213
+ 'gpt-5.5',
11214
+ 'gpt-5.5-pro',
11418
11215
  'gpt-5.2',
11419
11216
  'gpt-5.2-pro',
11420
11217
  'gpt-5.1-codex',