@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.
- package/dist/index-frontend.cjs +90 -438
- package/dist/index-frontend.cjs.map +1 -1
- package/dist/index-frontend.mjs +88 -439
- package/dist/index-frontend.mjs.map +1 -1
- package/dist/index.cjs +90 -438
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +88 -439
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +4 -4
- package/dist/test.js +663 -3568
- package/dist/test.js.map +1 -1
- package/dist/types/index-frontend.d.ts +1 -0
- package/dist/types/index-frontend.d.ts.map +1 -1
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/llm-config.d.ts +2 -2
- package/dist/types/llm-config.d.ts.map +1 -1
- package/dist/types/llm-images.d.ts.map +1 -1
- package/dist/types/llm-openai.d.ts +4 -16
- package/dist/types/llm-openai.d.ts.map +1 -1
- package/dist/types/types/llm-types.d.ts +7 -2
- package/dist/types/types/llm-types.d.ts.map +1 -1
- package/dist/types-frontend/index-frontend.d.ts +1 -0
- package/dist/types-frontend/index-frontend.d.ts.map +1 -1
- package/dist/types-frontend/index.d.ts +1 -0
- package/dist/types-frontend/index.d.ts.map +1 -1
- package/dist/types-frontend/llm-config.d.ts +2 -2
- package/dist/types-frontend/llm-config.d.ts.map +1 -1
- package/dist/types-frontend/llm-images.d.ts.map +1 -1
- package/dist/types-frontend/llm-openai.d.ts +4 -16
- package/dist/types-frontend/llm-openai.d.ts.map +1 -1
- package/dist/types-frontend/types/llm-types.d.ts +7 -2
- package/dist/types-frontend/types/llm-types.d.ts.map +1 -1
- package/package.json +4 -4
package/dist/index-frontend.cjs
CHANGED
|
@@ -1,5 +1,28 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
|
+
/**
|
|
4
|
+
* Represents OpenAI models
|
|
5
|
+
*/
|
|
6
|
+
const OPENAI_MODELS = [
|
|
7
|
+
'gpt-5',
|
|
8
|
+
'gpt-5-mini',
|
|
9
|
+
'gpt-5.4-mini',
|
|
10
|
+
'gpt-5-nano',
|
|
11
|
+
'gpt-5.1',
|
|
12
|
+
'gpt-5.4',
|
|
13
|
+
'gpt-5.5',
|
|
14
|
+
'gpt-5.5-pro',
|
|
15
|
+
'gpt-5.2',
|
|
16
|
+
'gpt-5.2-pro',
|
|
17
|
+
'gpt-5.1-codex',
|
|
18
|
+
'gpt-5.1-codex-max',
|
|
19
|
+
];
|
|
20
|
+
/**
|
|
21
|
+
* Type guard to check if a model is a supported direct OpenAI model.
|
|
22
|
+
*/
|
|
23
|
+
function isOpenAIModel(model) {
|
|
24
|
+
return OPENAI_MODELS.includes(model);
|
|
25
|
+
}
|
|
3
26
|
/**
|
|
4
27
|
* Type guard to check if a model is an OpenRouter model
|
|
5
28
|
*/
|
|
@@ -12,6 +35,8 @@ function isOpenRouterModel(model) {
|
|
|
12
35
|
'openai/gpt-5.1',
|
|
13
36
|
'openai/gpt-5.4',
|
|
14
37
|
'openai/gpt-5.4-pro',
|
|
38
|
+
'openai/gpt-5.5',
|
|
39
|
+
'openai/gpt-5.5-pro',
|
|
15
40
|
'openai/gpt-5.2',
|
|
16
41
|
'openai/gpt-5.2-pro',
|
|
17
42
|
'openai/gpt-5.1-codex',
|
|
@@ -29,6 +54,8 @@ function isOpenRouterModel(model) {
|
|
|
29
54
|
|
|
30
55
|
var Types = /*#__PURE__*/Object.freeze({
|
|
31
56
|
__proto__: null,
|
|
57
|
+
OPENAI_MODELS: OPENAI_MODELS,
|
|
58
|
+
isOpenAIModel: isOpenAIModel,
|
|
32
59
|
isOpenRouterModel: isOpenRouterModel
|
|
33
60
|
});
|
|
34
61
|
|
|
@@ -294,7 +321,7 @@ const safeJSON = (text) => {
|
|
|
294
321
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
295
322
|
const sleep = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
|
|
296
323
|
|
|
297
|
-
const VERSION = '6.
|
|
324
|
+
const VERSION = '6.35.0'; // x-release-please-version
|
|
298
325
|
|
|
299
326
|
// File generated from our OpenAPI spec by Stainless. See CONTRIBUTING.md for details.
|
|
300
327
|
const isRunningInBrowser = () => {
|
|
@@ -3622,8 +3649,8 @@ class Speech extends APIResource {
|
|
|
3622
3649
|
* ```ts
|
|
3623
3650
|
* const speech = await client.audio.speech.create({
|
|
3624
3651
|
* input: 'input',
|
|
3625
|
-
* model: '
|
|
3626
|
-
* voice: '
|
|
3652
|
+
* model: 'tts-1',
|
|
3653
|
+
* voice: 'alloy',
|
|
3627
3654
|
* });
|
|
3628
3655
|
*
|
|
3629
3656
|
* const content = await speech.blob();
|
|
@@ -4101,10 +4128,10 @@ const toFloat32Array = (base64Str) => {
|
|
|
4101
4128
|
*/
|
|
4102
4129
|
const readEnv = (env) => {
|
|
4103
4130
|
if (typeof globalThis.process !== 'undefined') {
|
|
4104
|
-
return globalThis.process.env?.[env]?.trim()
|
|
4131
|
+
return globalThis.process.env?.[env]?.trim() || undefined;
|
|
4105
4132
|
}
|
|
4106
4133
|
if (typeof globalThis.Deno !== 'undefined') {
|
|
4107
|
-
return globalThis.Deno.env?.get?.(env)?.trim();
|
|
4134
|
+
return globalThis.Deno.env?.get?.(env)?.trim() || undefined;
|
|
4108
4135
|
}
|
|
4109
4136
|
return undefined;
|
|
4110
4137
|
};
|
|
@@ -7690,7 +7717,6 @@ OpenAI.Containers = Containers;
|
|
|
7690
7717
|
OpenAI.Skills = Skills;
|
|
7691
7718
|
OpenAI.Videos = Videos;
|
|
7692
7719
|
|
|
7693
|
-
// functions
|
|
7694
7720
|
function getEnumValues(entries) {
|
|
7695
7721
|
const numericValues = Object.values(entries).filter((v) => typeof v === "number");
|
|
7696
7722
|
const values = Object.entries(entries)
|
|
@@ -7836,7 +7862,7 @@ function process$1(schema, ctx, _params = { path: [], schemaPath: [] }) {
|
|
|
7836
7862
|
delete result.schema.default;
|
|
7837
7863
|
}
|
|
7838
7864
|
// set prefault as default
|
|
7839
|
-
if (ctx.io === "input" && result.schema
|
|
7865
|
+
if (ctx.io === "input" && "_prefault" in result.schema)
|
|
7840
7866
|
(_a = result.schema).default ?? (_a.default = result.schema._prefault);
|
|
7841
7867
|
delete result.schema._prefault;
|
|
7842
7868
|
// pulling fresh from ctx.seen in case it was overwritten
|
|
@@ -8064,11 +8090,20 @@ function finalize(ctx, schema) {
|
|
|
8064
8090
|
result.$id = ctx.external.uri(id);
|
|
8065
8091
|
}
|
|
8066
8092
|
Object.assign(result, root.def ?? root.schema);
|
|
8093
|
+
// The `id` in `.meta()` is a Zod-specific registration tag used to extract
|
|
8094
|
+
// schemas into $defs — it is not user-facing JSON Schema metadata. Strip it
|
|
8095
|
+
// from the output body where it would otherwise leak. The id is preserved
|
|
8096
|
+
// implicitly via the $defs key (and via $ref paths).
|
|
8097
|
+
const rootMetaId = ctx.metadataRegistry.get(schema)?.id;
|
|
8098
|
+
if (rootMetaId !== undefined && result.id === rootMetaId)
|
|
8099
|
+
delete result.id;
|
|
8067
8100
|
// build defs object
|
|
8068
8101
|
const defs = ctx.external?.defs ?? {};
|
|
8069
8102
|
for (const entry of ctx.seen.entries()) {
|
|
8070
8103
|
const seen = entry[1];
|
|
8071
8104
|
if (seen.def && seen.defId) {
|
|
8105
|
+
if (seen.def.id === seen.defId)
|
|
8106
|
+
delete seen.def.id;
|
|
8072
8107
|
defs[seen.defId] = seen.def;
|
|
8073
8108
|
}
|
|
8074
8109
|
}
|
|
@@ -8136,6 +8171,8 @@ function isTransforming(_schema, _ctx) {
|
|
|
8136
8171
|
return isTransforming(def.keyType, ctx) || isTransforming(def.valueType, ctx);
|
|
8137
8172
|
}
|
|
8138
8173
|
if (def.type === "pipe") {
|
|
8174
|
+
if (_schema._zod.traits.has("$ZodCodec"))
|
|
8175
|
+
return true;
|
|
8139
8176
|
return isTransforming(def.in, ctx) || isTransforming(def.out, ctx);
|
|
8140
8177
|
}
|
|
8141
8178
|
if (def.type === "object") {
|
|
@@ -8224,8 +8261,12 @@ const numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
8224
8261
|
json.type = "integer";
|
|
8225
8262
|
else
|
|
8226
8263
|
json.type = "number";
|
|
8227
|
-
|
|
8228
|
-
|
|
8264
|
+
// when both minimum and exclusiveMinimum exist, pick the more restrictive one
|
|
8265
|
+
const exMin = typeof exclusiveMinimum === "number" && exclusiveMinimum >= (minimum ?? Number.NEGATIVE_INFINITY);
|
|
8266
|
+
const exMax = typeof exclusiveMaximum === "number" && exclusiveMaximum <= (maximum ?? Number.POSITIVE_INFINITY);
|
|
8267
|
+
const legacy = ctx.target === "draft-04" || ctx.target === "openapi-3.0";
|
|
8268
|
+
if (exMin) {
|
|
8269
|
+
if (legacy) {
|
|
8229
8270
|
json.minimum = exclusiveMinimum;
|
|
8230
8271
|
json.exclusiveMinimum = true;
|
|
8231
8272
|
}
|
|
@@ -8233,17 +8274,11 @@ const numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
8233
8274
|
json.exclusiveMinimum = exclusiveMinimum;
|
|
8234
8275
|
}
|
|
8235
8276
|
}
|
|
8236
|
-
if (typeof minimum === "number") {
|
|
8277
|
+
else if (typeof minimum === "number") {
|
|
8237
8278
|
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
8279
|
}
|
|
8245
|
-
if (
|
|
8246
|
-
if (
|
|
8280
|
+
if (exMax) {
|
|
8281
|
+
if (legacy) {
|
|
8247
8282
|
json.maximum = exclusiveMaximum;
|
|
8248
8283
|
json.exclusiveMaximum = true;
|
|
8249
8284
|
}
|
|
@@ -8251,14 +8286,8 @@ const numberProcessor = (schema, ctx, _json, _params) => {
|
|
|
8251
8286
|
json.exclusiveMaximum = exclusiveMaximum;
|
|
8252
8287
|
}
|
|
8253
8288
|
}
|
|
8254
|
-
if (typeof maximum === "number") {
|
|
8289
|
+
else if (typeof maximum === "number") {
|
|
8255
8290
|
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
8291
|
}
|
|
8263
8292
|
if (typeof multipleOf === "number")
|
|
8264
8293
|
json.multipleOf = multipleOf;
|
|
@@ -8441,7 +8470,10 @@ const arrayProcessor = (schema, ctx, _json, params) => {
|
|
|
8441
8470
|
if (typeof maximum === "number")
|
|
8442
8471
|
json.maxItems = maximum;
|
|
8443
8472
|
json.type = "array";
|
|
8444
|
-
json.items = process$1(def.element, ctx, {
|
|
8473
|
+
json.items = process$1(def.element, ctx, {
|
|
8474
|
+
...params,
|
|
8475
|
+
path: [...params.path, "items"],
|
|
8476
|
+
});
|
|
8445
8477
|
};
|
|
8446
8478
|
const objectProcessor = (schema, ctx, _json, params) => {
|
|
8447
8479
|
const json = _json;
|
|
@@ -8658,7 +8690,8 @@ const catchProcessor = (schema, ctx, json, params) => {
|
|
|
8658
8690
|
};
|
|
8659
8691
|
const pipeProcessor = (schema, ctx, _json, params) => {
|
|
8660
8692
|
const def = schema._zod.def;
|
|
8661
|
-
const
|
|
8693
|
+
const inIsTransform = def.in._zod.traits.has("$ZodTransform");
|
|
8694
|
+
const innerType = ctx.io === "input" ? (inIsTransform ? def.out : def.in) : def.out;
|
|
8662
8695
|
process$1(innerType, ctx, params);
|
|
8663
8696
|
const seen = ctx.seen.get(schema);
|
|
8664
8697
|
seen.ref = innerType;
|
|
@@ -8856,235 +8889,6 @@ function setResponseValueAndErrors(res, key, value, errorMessage, refs) {
|
|
|
8856
8889
|
addErrorMessage(res, key, errorMessage, refs);
|
|
8857
8890
|
}
|
|
8858
8891
|
|
|
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
8892
|
var ZodFirstPartyTypeKind;
|
|
9089
8893
|
(function (ZodFirstPartyTypeKind) {
|
|
9090
8894
|
ZodFirstPartyTypeKind["ZodString"] = "ZodString";
|
|
@@ -10465,57 +10269,12 @@ function zodTextFormat(zodObject, name, props) {
|
|
|
10465
10269
|
}
|
|
10466
10270
|
|
|
10467
10271
|
// llm-openai-config.ts
|
|
10468
|
-
const DEFAULT_MODEL = 'gpt-
|
|
10469
|
-
const
|
|
10470
|
-
const
|
|
10471
|
-
const
|
|
10472
|
-
/** Token costs in USD per 1M tokens. Last updated
|
|
10272
|
+
const DEFAULT_MODEL = 'gpt-5-mini';
|
|
10273
|
+
const GPT_5_HIGH_CONTEXT_THRESHOLD_TOKENS = 272_000;
|
|
10274
|
+
const GPT_5_HIGH_CONTEXT_INPUT_MULTIPLIER = 2;
|
|
10275
|
+
const GPT_5_HIGH_CONTEXT_OUTPUT_MULTIPLIER = 1.5;
|
|
10276
|
+
/** Token costs in USD per 1M tokens. Last updated May 2026. */
|
|
10473
10277
|
const openAiModelCosts = {
|
|
10474
|
-
'gpt-4o': {
|
|
10475
|
-
inputCost: 2.5 / 1_000_000,
|
|
10476
|
-
cacheHitCost: 1.25 / 1_000_000,
|
|
10477
|
-
outputCost: 10 / 1_000_000,
|
|
10478
|
-
},
|
|
10479
|
-
'gpt-4o-mini': {
|
|
10480
|
-
inputCost: 0.15 / 1_000_000,
|
|
10481
|
-
cacheHitCost: 0.075 / 1_000_000,
|
|
10482
|
-
outputCost: 0.6 / 1_000_000,
|
|
10483
|
-
},
|
|
10484
|
-
'o1-mini': {
|
|
10485
|
-
inputCost: 1.1 / 1_000_000,
|
|
10486
|
-
cacheHitCost: 0.55 / 1_000_000,
|
|
10487
|
-
outputCost: 4.4 / 1_000_000,
|
|
10488
|
-
},
|
|
10489
|
-
'o1': {
|
|
10490
|
-
inputCost: 15 / 1_000_000,
|
|
10491
|
-
cacheHitCost: 7.5 / 1_000_000,
|
|
10492
|
-
outputCost: 60 / 1_000_000,
|
|
10493
|
-
},
|
|
10494
|
-
'o3-mini': {
|
|
10495
|
-
inputCost: 1.1 / 1_000_000,
|
|
10496
|
-
cacheHitCost: 0.55 / 1_000_000,
|
|
10497
|
-
outputCost: 4.4 / 1_000_000,
|
|
10498
|
-
},
|
|
10499
|
-
'o3': {
|
|
10500
|
-
inputCost: 2 / 1_000_000,
|
|
10501
|
-
cacheHitCost: 0.5 / 1_000_000,
|
|
10502
|
-
outputCost: 8 / 1_000_000,
|
|
10503
|
-
},
|
|
10504
|
-
'gpt-4.1': {
|
|
10505
|
-
inputCost: 2 / 1_000_000,
|
|
10506
|
-
cacheHitCost: 0.5 / 1_000_000,
|
|
10507
|
-
outputCost: 8 / 1_000_000,
|
|
10508
|
-
},
|
|
10509
|
-
'gpt-4.1-mini': {
|
|
10510
|
-
inputCost: 0.4 / 1_000_000,
|
|
10511
|
-
cacheHitCost: 0.1 / 1_000_000,
|
|
10512
|
-
outputCost: 1.6 / 1_000_000,
|
|
10513
|
-
},
|
|
10514
|
-
'gpt-4.1-nano': {
|
|
10515
|
-
inputCost: 0.1 / 1_000_000,
|
|
10516
|
-
cacheHitCost: 0.025 / 1_000_000,
|
|
10517
|
-
outputCost: 0.4 / 1_000_000,
|
|
10518
|
-
},
|
|
10519
10278
|
'gpt-5': {
|
|
10520
10279
|
inputCost: 1.25 / 1_000_000,
|
|
10521
10280
|
cacheHitCost: 0.125 / 1_000_000,
|
|
@@ -10546,7 +10305,12 @@ const openAiModelCosts = {
|
|
|
10546
10305
|
cacheHitCost: 0.25 / 1_000_000,
|
|
10547
10306
|
outputCost: 15 / 1_000_000,
|
|
10548
10307
|
},
|
|
10549
|
-
'gpt-5.
|
|
10308
|
+
'gpt-5.5': {
|
|
10309
|
+
inputCost: 5 / 1_000_000,
|
|
10310
|
+
cacheHitCost: 0.5 / 1_000_000,
|
|
10311
|
+
outputCost: 30 / 1_000_000,
|
|
10312
|
+
},
|
|
10313
|
+
'gpt-5.5-pro': {
|
|
10550
10314
|
inputCost: 30 / 1_000_000,
|
|
10551
10315
|
outputCost: 180 / 1_000_000,
|
|
10552
10316
|
},
|
|
@@ -10569,11 +10333,6 @@ const openAiModelCosts = {
|
|
|
10569
10333
|
cacheHitCost: 0.125 / 1_000_000,
|
|
10570
10334
|
outputCost: 10 / 1_000_000,
|
|
10571
10335
|
},
|
|
10572
|
-
'o4-mini': {
|
|
10573
|
-
inputCost: 1.1 / 1_000_000,
|
|
10574
|
-
cacheHitCost: 0.275 / 1_000_000,
|
|
10575
|
-
outputCost: 4.4 / 1_000_000,
|
|
10576
|
-
},
|
|
10577
10336
|
};
|
|
10578
10337
|
const deepseekModelCosts = {
|
|
10579
10338
|
'deepseek-chat': {
|
|
@@ -10587,8 +10346,8 @@ const deepseekModelCosts = {
|
|
|
10587
10346
|
outputCost: 2.19 / 1_000_000, // $2.19 per 1M tokens
|
|
10588
10347
|
},
|
|
10589
10348
|
};
|
|
10590
|
-
function
|
|
10591
|
-
return (model === 'gpt-5.4' || model === 'gpt-5.
|
|
10349
|
+
function shouldUseGPT5HighContextPricing(model, inputTokens) {
|
|
10350
|
+
return (model === 'gpt-5.4' || model === 'gpt-5.5') && inputTokens > GPT_5_HIGH_CONTEXT_THRESHOLD_TOKENS;
|
|
10592
10351
|
}
|
|
10593
10352
|
/** Image generation costs in USD per image. Based on OpenAI pricing as of Feb 2025. */
|
|
10594
10353
|
const openAiImageCosts = {
|
|
@@ -10641,10 +10400,10 @@ function calculateCost(provider, model, inputTokens, outputTokens, reasoningToke
|
|
|
10641
10400
|
}
|
|
10642
10401
|
let outputCost = outputTokens * modelCosts.outputCost;
|
|
10643
10402
|
let reasoningCost = (reasoningTokens || 0) * modelCosts.outputCost;
|
|
10644
|
-
if (provider === 'openai' &&
|
|
10645
|
-
inputCost *=
|
|
10646
|
-
outputCost *=
|
|
10647
|
-
reasoningCost *=
|
|
10403
|
+
if (provider === 'openai' && shouldUseGPT5HighContextPricing(model, inputTokens)) {
|
|
10404
|
+
inputCost *= GPT_5_HIGH_CONTEXT_INPUT_MULTIPLIER;
|
|
10405
|
+
outputCost *= GPT_5_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
|
|
10406
|
+
reasoningCost *= GPT_5_HIGH_CONTEXT_OUTPUT_MULTIPLIER;
|
|
10648
10407
|
}
|
|
10649
10408
|
return inputCost + outputCost + reasoningCost;
|
|
10650
10409
|
}
|
|
@@ -11029,94 +10788,13 @@ async function parseResponse(content, responseFormat) {
|
|
|
11029
10788
|
}
|
|
11030
10789
|
|
|
11031
10790
|
// llm-openai.ts
|
|
11032
|
-
const isSupportedModel = (model) => {
|
|
11033
|
-
return [
|
|
11034
|
-
'gpt-4o-mini',
|
|
11035
|
-
'gpt-4o',
|
|
11036
|
-
'o1-mini',
|
|
11037
|
-
'o1',
|
|
11038
|
-
'o3-mini',
|
|
11039
|
-
'gpt-4.1',
|
|
11040
|
-
'gpt-4.1-mini',
|
|
11041
|
-
'gpt-4.1-nano',
|
|
11042
|
-
'gpt-5',
|
|
11043
|
-
'gpt-5-mini',
|
|
11044
|
-
'gpt-5.4-mini',
|
|
11045
|
-
'gpt-5-nano',
|
|
11046
|
-
'gpt-5.1',
|
|
11047
|
-
'gpt-5.4',
|
|
11048
|
-
'gpt-5.4-pro',
|
|
11049
|
-
'gpt-5.2',
|
|
11050
|
-
'gpt-5.2-pro',
|
|
11051
|
-
'gpt-5.1-codex',
|
|
11052
|
-
'gpt-5.1-codex-max',
|
|
11053
|
-
'o4-mini',
|
|
11054
|
-
'o3',
|
|
11055
|
-
].includes(model);
|
|
11056
|
-
};
|
|
11057
10791
|
/**
|
|
11058
|
-
* Checks if the given model supports the temperature parameter.
|
|
10792
|
+
* Checks if the given direct OpenAI model supports the temperature parameter.
|
|
11059
10793
|
* @param model The model to check.
|
|
11060
10794
|
* @returns True if the model supports the temperature parameter, false otherwise.
|
|
11061
10795
|
*/
|
|
11062
|
-
function supportsTemperature(
|
|
11063
|
-
|
|
11064
|
-
// GPT-5 models also do not support temperature
|
|
11065
|
-
const reasoningAndGPT5Models = [
|
|
11066
|
-
'o1',
|
|
11067
|
-
'o1-mini',
|
|
11068
|
-
'o3-mini',
|
|
11069
|
-
'o4-mini',
|
|
11070
|
-
'o3',
|
|
11071
|
-
'gpt-5',
|
|
11072
|
-
'gpt-5-mini',
|
|
11073
|
-
'gpt-5.4-mini',
|
|
11074
|
-
'gpt-5-nano',
|
|
11075
|
-
'gpt-5.1',
|
|
11076
|
-
'gpt-5.4',
|
|
11077
|
-
'gpt-5.4-pro',
|
|
11078
|
-
'gpt-5.2',
|
|
11079
|
-
'gpt-5.2-pro',
|
|
11080
|
-
'gpt-5.1-codex',
|
|
11081
|
-
'gpt-5.1-codex-max',
|
|
11082
|
-
];
|
|
11083
|
-
return !reasoningAndGPT5Models.includes(model);
|
|
11084
|
-
}
|
|
11085
|
-
/**
|
|
11086
|
-
* Checks if the given model is a reasoning model. Reasoning models have different tool choice constraints.
|
|
11087
|
-
* @param model The model to check.
|
|
11088
|
-
* @returns True if the model is a reasoning model, false otherwise.
|
|
11089
|
-
*/
|
|
11090
|
-
function isReasoningModel(model) {
|
|
11091
|
-
const reasoningModels = ['o1', 'o1-mini', 'o3-mini', 'o4-mini', 'o3'];
|
|
11092
|
-
return reasoningModels.includes(model);
|
|
11093
|
-
}
|
|
11094
|
-
/**
|
|
11095
|
-
* Checks if the given model is a GPT-5 model. GPT-5 models don't support tool_choice other than 'auto'.
|
|
11096
|
-
* @param model The model to check.
|
|
11097
|
-
* @returns True if the model is a GPT-5 model, false otherwise.
|
|
11098
|
-
*/
|
|
11099
|
-
function isGPT5Model(model) {
|
|
11100
|
-
const gpt5Models = [
|
|
11101
|
-
'gpt-5',
|
|
11102
|
-
'gpt-5-mini',
|
|
11103
|
-
'gpt-5.4-mini',
|
|
11104
|
-
'gpt-5-nano',
|
|
11105
|
-
'gpt-5.1',
|
|
11106
|
-
'gpt-5.4',
|
|
11107
|
-
'gpt-5.4-pro',
|
|
11108
|
-
'gpt-5.2',
|
|
11109
|
-
'gpt-5.2-pro',
|
|
11110
|
-
'gpt-5.1-codex',
|
|
11111
|
-
'gpt-5.1-codex-max',
|
|
11112
|
-
];
|
|
11113
|
-
return gpt5Models.includes(model);
|
|
11114
|
-
}
|
|
11115
|
-
function supportsStructuredOutputs(model) {
|
|
11116
|
-
return normalizeModelName(model) !== 'gpt-5.4-pro';
|
|
11117
|
-
}
|
|
11118
|
-
function supportsDistillation(model) {
|
|
11119
|
-
return normalizeModelName(model) !== 'gpt-5.4-pro';
|
|
10796
|
+
function supportsTemperature(_model) {
|
|
10797
|
+
return false;
|
|
11120
10798
|
}
|
|
11121
10799
|
function isZodSchema(schema) {
|
|
11122
10800
|
return typeof schema === 'object' && schema !== null && 'safeParse' in schema;
|
|
@@ -11151,7 +10829,7 @@ function buildJsonSchemaFormat(schema, schemaName, schemaDescription, schemaStri
|
|
|
11151
10829
|
* - Built-in tools (web search, file search, computer use, code interpreter, image generation)
|
|
11152
10830
|
* - Background processing
|
|
11153
10831
|
* - Conversation state management
|
|
11154
|
-
* -
|
|
10832
|
+
* - GPT-5 reasoning controls
|
|
11155
10833
|
*
|
|
11156
10834
|
* @example
|
|
11157
10835
|
* // Basic text response
|
|
@@ -11172,6 +10850,9 @@ function buildJsonSchemaFormat(schema, schemaName, schemaDescription, schemaStri
|
|
|
11172
10850
|
*/
|
|
11173
10851
|
const makeResponsesAPICall = async (input, options = {}) => {
|
|
11174
10852
|
const normalizedModel = normalizeModelName(options.model || DEFAULT_MODEL);
|
|
10853
|
+
if (!isOpenAIModel(normalizedModel)) {
|
|
10854
|
+
throw new Error(`Unsupported OpenAI model: ${normalizedModel}. Please use a supported GPT-5 model.`);
|
|
10855
|
+
}
|
|
11175
10856
|
const apiKey = options.apiKey || process.env.OPENAI_API_KEY;
|
|
11176
10857
|
if (!apiKey) {
|
|
11177
10858
|
throw new Error('OpenAI API key is not provided and OPENAI_API_KEY environment variable is not set');
|
|
@@ -11186,12 +10867,6 @@ const makeResponsesAPICall = async (input, options = {}) => {
|
|
|
11186
10867
|
input,
|
|
11187
10868
|
...cleanOptions,
|
|
11188
10869
|
};
|
|
11189
|
-
if (requestBody.text?.format?.type === 'json_schema' && !supportsStructuredOutputs(normalizedModel)) {
|
|
11190
|
-
throw new Error(`Model ${normalizedModel} does not support structured outputs`);
|
|
11191
|
-
}
|
|
11192
|
-
if (requestBody.store && !supportsDistillation(normalizedModel)) {
|
|
11193
|
-
throw new Error(`Model ${normalizedModel} does not support distillation`);
|
|
11194
|
-
}
|
|
11195
10870
|
// Make the API call to the Responses endpoint
|
|
11196
10871
|
const response = await openai.responses.create(requestBody);
|
|
11197
10872
|
const cacheHitTokens = response.usage?.input_tokens_details?.cached_tokens || 0;
|
|
@@ -11298,8 +10973,8 @@ async function makeLLMCall(input, options = {}) {
|
|
|
11298
10973
|
const { apiKey, model = DEFAULT_MODEL, responseFormat = 'text', schema, schemaName = 'response', schemaDescription, schemaStrict, tools, useCodeInterpreter = false, useWebSearch = false, imageBase64, imageDetail = 'high', context, } = options;
|
|
11299
10974
|
// Validate model
|
|
11300
10975
|
const normalizedModel = normalizeModelName(model);
|
|
11301
|
-
if (!
|
|
11302
|
-
throw new Error(`Unsupported model: ${normalizedModel}. Please use
|
|
10976
|
+
if (!isOpenAIModel(normalizedModel)) {
|
|
10977
|
+
throw new Error(`Unsupported OpenAI model: ${normalizedModel}. Please use a supported GPT-5 model.`);
|
|
11303
10978
|
}
|
|
11304
10979
|
// Process input for conversation context and image analysis
|
|
11305
10980
|
let processedInput;
|
|
@@ -11368,10 +11043,6 @@ async function makeLLMCall(input, options = {}) {
|
|
|
11368
11043
|
parallel_tool_calls: false,
|
|
11369
11044
|
tools,
|
|
11370
11045
|
};
|
|
11371
|
-
// Only include temperature if the model supports it
|
|
11372
|
-
if (supportsTemperature(normalizedModel)) {
|
|
11373
|
-
responsesOptions.temperature = 0.2;
|
|
11374
|
-
}
|
|
11375
11046
|
// Configure response format
|
|
11376
11047
|
if (schema) {
|
|
11377
11048
|
responsesOptions.text = {
|
|
@@ -11387,39 +11058,17 @@ async function makeLLMCall(input, options = {}) {
|
|
|
11387
11058
|
// Configure built-in tools
|
|
11388
11059
|
if (useCodeInterpreter) {
|
|
11389
11060
|
responsesOptions.tools = [{ type: 'code_interpreter', container: { type: 'auto' } }];
|
|
11390
|
-
// For reasoning models, we can't force tool choice - they only support 'auto'
|
|
11391
|
-
if (!isReasoningModel(normalizedModel)) {
|
|
11392
|
-
responsesOptions.tool_choice = { type: 'code_interpreter' };
|
|
11393
|
-
}
|
|
11394
11061
|
responsesOptions.include = ['code_interpreter_call.outputs'];
|
|
11395
11062
|
}
|
|
11396
11063
|
if (useWebSearch) {
|
|
11397
11064
|
responsesOptions.tools = [{ type: 'web_search_preview' }];
|
|
11398
|
-
// For reasoning models and GPT-5 models, we can't force tool choice - they only support 'auto'
|
|
11399
|
-
if (!isReasoningModel(normalizedModel) && !isGPT5Model(normalizedModel)) {
|
|
11400
|
-
responsesOptions.tool_choice = { type: 'web_search_preview' };
|
|
11401
|
-
}
|
|
11402
11065
|
}
|
|
11403
11066
|
return await makeResponsesAPICall(processedInput, responsesOptions);
|
|
11404
11067
|
}
|
|
11405
11068
|
|
|
11406
11069
|
const DEFAULT_IMAGE_MODEL = 'gpt-image-1.5';
|
|
11407
11070
|
const resolveImageModel = (model) => model ?? DEFAULT_IMAGE_MODEL;
|
|
11408
|
-
const MULTIMODAL_VISION_MODELS = new Set(
|
|
11409
|
-
'gpt-4o-mini',
|
|
11410
|
-
'gpt-4o',
|
|
11411
|
-
'gpt-5',
|
|
11412
|
-
'gpt-5-mini',
|
|
11413
|
-
'gpt-5.4-mini',
|
|
11414
|
-
'gpt-5-nano',
|
|
11415
|
-
'gpt-5.1',
|
|
11416
|
-
'gpt-5.4',
|
|
11417
|
-
'gpt-5.4-pro',
|
|
11418
|
-
'gpt-5.2',
|
|
11419
|
-
'gpt-5.2-pro',
|
|
11420
|
-
'gpt-5.1-codex',
|
|
11421
|
-
'gpt-5.1-codex-max',
|
|
11422
|
-
]);
|
|
11071
|
+
const MULTIMODAL_VISION_MODELS = new Set(OPENAI_MODELS);
|
|
11423
11072
|
/**
|
|
11424
11073
|
* Makes a call to the OpenAI Images API to generate images based on a text prompt.
|
|
11425
11074
|
*
|
|
@@ -12881,6 +12530,9 @@ const disco = {
|
|
|
12881
12530
|
time,
|
|
12882
12531
|
};
|
|
12883
12532
|
|
|
12533
|
+
exports.OPENAI_MODELS = OPENAI_MODELS;
|
|
12884
12534
|
exports.disco = disco;
|
|
12535
|
+
exports.isOpenAIModel = isOpenAIModel;
|
|
12885
12536
|
exports.isOpenRouterModel = isOpenRouterModel;
|
|
12537
|
+
exports.supportsTemperature = supportsTemperature;
|
|
12886
12538
|
//# sourceMappingURL=index-frontend.cjs.map
|