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