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