@hongymagic/q 2026.303.0-next.8a37ded → 2026.303.0-next.a14183f
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/q.js +1849 -273
- package/package.json +10 -10
package/dist/q.js
CHANGED
|
@@ -11985,7 +11985,7 @@ var init_main_sync = __esm(() => {
|
|
|
11985
11985
|
|
|
11986
11986
|
// node_modules/execa/lib/ipc/get-one.js
|
|
11987
11987
|
import { once as once5, on as on2 } from "node:events";
|
|
11988
|
-
var getOneMessage = ({ anyProcess, channel, isSubprocess, ipc }, { reference = true, filter:
|
|
11988
|
+
var getOneMessage = ({ anyProcess, channel, isSubprocess, ipc }, { reference = true, filter: filter3 } = {}) => {
|
|
11989
11989
|
validateIpcMethod({
|
|
11990
11990
|
methodName: "getOneMessage",
|
|
11991
11991
|
isSubprocess,
|
|
@@ -11996,16 +11996,16 @@ var getOneMessage = ({ anyProcess, channel, isSubprocess, ipc }, { reference = t
|
|
|
11996
11996
|
anyProcess,
|
|
11997
11997
|
channel,
|
|
11998
11998
|
isSubprocess,
|
|
11999
|
-
filter:
|
|
11999
|
+
filter: filter3,
|
|
12000
12000
|
reference
|
|
12001
12001
|
});
|
|
12002
|
-
}, getOneMessageAsync = async ({ anyProcess, channel, isSubprocess, filter:
|
|
12002
|
+
}, getOneMessageAsync = async ({ anyProcess, channel, isSubprocess, filter: filter3, reference }) => {
|
|
12003
12003
|
addReference(channel, reference);
|
|
12004
12004
|
const ipcEmitter = getIpcEmitter(anyProcess, channel, isSubprocess);
|
|
12005
12005
|
const controller = new AbortController;
|
|
12006
12006
|
try {
|
|
12007
12007
|
return await Promise.race([
|
|
12008
|
-
getMessage(ipcEmitter,
|
|
12008
|
+
getMessage(ipcEmitter, filter3, controller),
|
|
12009
12009
|
throwOnDisconnect2(ipcEmitter, isSubprocess, controller),
|
|
12010
12010
|
throwOnStrictError(ipcEmitter, isSubprocess, controller)
|
|
12011
12011
|
]);
|
|
@@ -12016,13 +12016,13 @@ var getOneMessage = ({ anyProcess, channel, isSubprocess, ipc }, { reference = t
|
|
|
12016
12016
|
controller.abort();
|
|
12017
12017
|
removeReference(channel, reference);
|
|
12018
12018
|
}
|
|
12019
|
-
}, getMessage = async (ipcEmitter,
|
|
12020
|
-
if (
|
|
12019
|
+
}, getMessage = async (ipcEmitter, filter3, { signal }) => {
|
|
12020
|
+
if (filter3 === undefined) {
|
|
12021
12021
|
const [message] = await once5(ipcEmitter, "message", { signal });
|
|
12022
12022
|
return message;
|
|
12023
12023
|
}
|
|
12024
12024
|
for await (const [message] of on2(ipcEmitter, "message", { signal })) {
|
|
12025
|
-
if (
|
|
12025
|
+
if (filter3(message)) {
|
|
12026
12026
|
return message;
|
|
12027
12027
|
}
|
|
12028
12028
|
}
|
|
@@ -12373,7 +12373,7 @@ var getHighWaterMark = (streams, objectMode) => {
|
|
|
12373
12373
|
if (signal.aborted || !streams.has(stream)) {
|
|
12374
12374
|
return;
|
|
12375
12375
|
}
|
|
12376
|
-
if (
|
|
12376
|
+
if (isAbortError3(error48)) {
|
|
12377
12377
|
aborted2.add(stream);
|
|
12378
12378
|
} else {
|
|
12379
12379
|
errorStream(passThroughStream, error48);
|
|
@@ -12392,12 +12392,12 @@ var getHighWaterMark = (streams, objectMode) => {
|
|
|
12392
12392
|
stream.end();
|
|
12393
12393
|
}
|
|
12394
12394
|
}, errorOrAbortStream = (stream, error48) => {
|
|
12395
|
-
if (
|
|
12395
|
+
if (isAbortError3(error48)) {
|
|
12396
12396
|
abortStream(stream);
|
|
12397
12397
|
} else {
|
|
12398
12398
|
errorStream(stream, error48);
|
|
12399
12399
|
}
|
|
12400
|
-
},
|
|
12400
|
+
}, isAbortError3 = (error48) => error48?.code === "ERR_STREAM_PREMATURE_CLOSE", abortStream = (stream) => {
|
|
12401
12401
|
if (stream.readable || stream.writable) {
|
|
12402
12402
|
stream.destroy();
|
|
12403
12403
|
}
|
|
@@ -14641,7 +14641,7 @@ import { parseArgs } from "node:util";
|
|
|
14641
14641
|
// package.json
|
|
14642
14642
|
var package_default = {
|
|
14643
14643
|
name: "@hongymagic/q",
|
|
14644
|
-
version: "2026.303.0-next.
|
|
14644
|
+
version: "2026.303.0-next.a14183f",
|
|
14645
14645
|
description: "Quick AI answers from the command line",
|
|
14646
14646
|
main: "dist/q.js",
|
|
14647
14647
|
type: "module",
|
|
@@ -14691,22 +14691,22 @@ var package_default = {
|
|
|
14691
14691
|
"release:dry": "bun run scripts/release.ts --dry-run"
|
|
14692
14692
|
},
|
|
14693
14693
|
dependencies: {
|
|
14694
|
-
"@ai-sdk/amazon-bedrock": "4.0.
|
|
14695
|
-
"@ai-sdk/anthropic": "3.0.
|
|
14696
|
-
"@ai-sdk/azure": "3.0.
|
|
14697
|
-
"@ai-sdk/google": "3.0.
|
|
14698
|
-
"@ai-sdk/groq": "3.0.
|
|
14699
|
-
"@ai-sdk/openai": "3.0.
|
|
14700
|
-
"@ai-sdk/openai-compatible": "2.0.
|
|
14694
|
+
"@ai-sdk/amazon-bedrock": "4.0.72",
|
|
14695
|
+
"@ai-sdk/anthropic": "3.0.53",
|
|
14696
|
+
"@ai-sdk/azure": "3.0.40",
|
|
14697
|
+
"@ai-sdk/google": "3.0.36",
|
|
14698
|
+
"@ai-sdk/groq": "3.0.27",
|
|
14699
|
+
"@ai-sdk/openai": "3.0.39",
|
|
14700
|
+
"@ai-sdk/openai-compatible": "2.0.33",
|
|
14701
14701
|
"@t3-oss/env-core": "0.13.10",
|
|
14702
|
-
ai: "6.0.
|
|
14702
|
+
ai: "6.0.107",
|
|
14703
14703
|
clipboardy: "5.3.1",
|
|
14704
14704
|
"ollama-ai-provider-v2": "3.3.1",
|
|
14705
14705
|
zod: "4.3.6"
|
|
14706
14706
|
},
|
|
14707
14707
|
devDependencies: {
|
|
14708
14708
|
"@biomejs/biome": "2.4.5",
|
|
14709
|
-
"@types/bun": "1.3.
|
|
14709
|
+
"@types/bun": "1.3.10",
|
|
14710
14710
|
"@vitest/coverage-v8": "4.0.18",
|
|
14711
14711
|
lefthook: "2.1.2",
|
|
14712
14712
|
typescript: "5.9.3",
|
|
@@ -33731,7 +33731,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
33731
33731
|
normalizedHeaders.set("user-agent", [currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(" "));
|
|
33732
33732
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
33733
33733
|
}
|
|
33734
|
-
var VERSION2 = "4.0.
|
|
33734
|
+
var VERSION2 = "4.0.17";
|
|
33735
33735
|
var getOriginalFetch = () => globalThis.fetch;
|
|
33736
33736
|
var getFromApi = async ({
|
|
33737
33737
|
url: url2,
|
|
@@ -35470,6 +35470,10 @@ var createBinaryResponseHandler = () => async ({ response, url: url2, requestBod
|
|
|
35470
35470
|
});
|
|
35471
35471
|
}
|
|
35472
35472
|
};
|
|
35473
|
+
function stripFileExtension(filename) {
|
|
35474
|
+
const firstDotIndex = filename.indexOf(".");
|
|
35475
|
+
return firstDotIndex === -1 ? filename : filename.slice(0, firstDotIndex);
|
|
35476
|
+
}
|
|
35473
35477
|
function withoutTrailingSlash(url2) {
|
|
35474
35478
|
return url2 == null ? undefined : url2.replace(/\/$/, "");
|
|
35475
35479
|
}
|
|
@@ -35495,7 +35499,7 @@ async function* executeTool({
|
|
|
35495
35499
|
}
|
|
35496
35500
|
|
|
35497
35501
|
// node_modules/@ai-sdk/anthropic/dist/index.mjs
|
|
35498
|
-
var VERSION3 = "3.0.
|
|
35502
|
+
var VERSION3 = "3.0.53";
|
|
35499
35503
|
var anthropicErrorDataSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
35500
35504
|
type: exports_external.literal("error"),
|
|
35501
35505
|
error: exports_external.object({
|
|
@@ -36820,7 +36824,7 @@ var toolSearchRegex_20251119 = (args = {}) => {
|
|
|
36820
36824
|
};
|
|
36821
36825
|
function convertToString(data) {
|
|
36822
36826
|
if (typeof data === "string") {
|
|
36823
|
-
return
|
|
36827
|
+
return new TextDecoder().decode(convertBase64ToUint8Array(data));
|
|
36824
36828
|
}
|
|
36825
36829
|
if (data instanceof Uint8Array) {
|
|
36826
36830
|
return new TextDecoder().decode(data);
|
|
@@ -44981,7 +44985,7 @@ var azureOpenaiTools = {
|
|
|
44981
44985
|
imageGeneration,
|
|
44982
44986
|
webSearchPreview
|
|
44983
44987
|
};
|
|
44984
|
-
var VERSION4 = "3.0.
|
|
44988
|
+
var VERSION4 = "3.0.40";
|
|
44985
44989
|
function createAzure(options = {}) {
|
|
44986
44990
|
var _a16;
|
|
44987
44991
|
const getHeaders = () => {
|
|
@@ -47561,7 +47565,7 @@ async function shouldEnableCitations(providerMetadata) {
|
|
|
47561
47565
|
return (_b16 = (_a16 = bedrockOptions == null ? undefined : bedrockOptions.citations) == null ? undefined : _a16.enabled) != null ? _b16 : false;
|
|
47562
47566
|
}
|
|
47563
47567
|
async function convertToBedrockChatMessages(prompt, isMistral = false) {
|
|
47564
|
-
var _a16
|
|
47568
|
+
var _a16;
|
|
47565
47569
|
const blocks = groupIntoBlocks2(prompt);
|
|
47566
47570
|
let system = [];
|
|
47567
47571
|
const messages = [];
|
|
@@ -47626,7 +47630,7 @@ async function convertToBedrockChatMessages(prompt, isMistral = false) {
|
|
|
47626
47630
|
bedrockContent.push({
|
|
47627
47631
|
document: {
|
|
47628
47632
|
format: getBedrockDocumentFormat(part.mediaType),
|
|
47629
|
-
name:
|
|
47633
|
+
name: part.filename ? stripFileExtension(part.filename) : generateDocumentName(),
|
|
47630
47634
|
source: { bytes: convertToBase64(part.data) },
|
|
47631
47635
|
...enableCitations && {
|
|
47632
47636
|
citations: { enabled: true }
|
|
@@ -47681,7 +47685,7 @@ async function convertToBedrockChatMessages(prompt, isMistral = false) {
|
|
|
47681
47685
|
break;
|
|
47682
47686
|
case "execution-denied":
|
|
47683
47687
|
toolResultContent = [
|
|
47684
|
-
{ text: (
|
|
47688
|
+
{ text: (_a16 = output.reason) != null ? _a16 : "Tool execution denied." }
|
|
47685
47689
|
];
|
|
47686
47690
|
break;
|
|
47687
47691
|
case "json":
|
|
@@ -48974,7 +48978,7 @@ var bedrockImageResponseSchema = exports_external.object({
|
|
|
48974
48978
|
details: exports_external.record(exports_external.string(), exports_external.unknown()).optional(),
|
|
48975
48979
|
preview: exports_external.unknown().optional()
|
|
48976
48980
|
});
|
|
48977
|
-
var VERSION5 = "4.0.
|
|
48981
|
+
var VERSION5 = "4.0.72";
|
|
48978
48982
|
function createSigV4FetchFunction(getCredentials, fetch2 = globalThis.fetch) {
|
|
48979
48983
|
return async (input, init) => {
|
|
48980
48984
|
var _a16, _b16;
|
|
@@ -49270,7 +49274,7 @@ function createBedrockProvider(config2, providerName) {
|
|
|
49270
49274
|
}
|
|
49271
49275
|
|
|
49272
49276
|
// node_modules/@ai-sdk/google/dist/index.mjs
|
|
49273
|
-
var VERSION6 = "3.0.
|
|
49277
|
+
var VERSION6 = "3.0.36";
|
|
49274
49278
|
var googleErrorDataSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
49275
49279
|
error: exports_external.object({
|
|
49276
49280
|
code: exports_external.number().nullable(),
|
|
@@ -52094,7 +52098,7 @@ var browserSearch = createProviderToolFactory({
|
|
|
52094
52098
|
var groqTools = {
|
|
52095
52099
|
browserSearch
|
|
52096
52100
|
};
|
|
52097
|
-
var VERSION7 = "3.0.
|
|
52101
|
+
var VERSION7 = "3.0.27";
|
|
52098
52102
|
function createGroq(options = {}) {
|
|
52099
52103
|
var _a16;
|
|
52100
52104
|
const baseURL = (_a16 = withoutTrailingSlash(options.baseURL)) != null ? _a16 : "https://api.groq.com/openai/v1";
|
|
@@ -52155,204 +52159,1776 @@ function createGroqProvider(config2, providerName) {
|
|
|
52155
52159
|
});
|
|
52156
52160
|
}
|
|
52157
52161
|
|
|
52158
|
-
// node_modules/ollama-ai-provider-v2/dist/index.mjs
|
|
52159
|
-
function
|
|
52160
|
-
|
|
52161
|
-
|
|
52162
|
-
|
|
52162
|
+
// node_modules/ollama-ai-provider-v2/node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
52163
|
+
function combineHeaders2(...headers) {
|
|
52164
|
+
return headers.reduce((combinedHeaders, currentHeaders) => ({
|
|
52165
|
+
...combinedHeaders,
|
|
52166
|
+
...currentHeaders != null ? currentHeaders : {}
|
|
52167
|
+
}), {});
|
|
52168
|
+
}
|
|
52169
|
+
function extractResponseHeaders2(response) {
|
|
52170
|
+
return Object.fromEntries([...response.headers]);
|
|
52171
|
+
}
|
|
52172
|
+
var name16 = "AI_DownloadError";
|
|
52173
|
+
var marker17 = `vercel.ai.error.${name16}`;
|
|
52174
|
+
var symbol17 = Symbol.for(marker17);
|
|
52175
|
+
var _a17;
|
|
52176
|
+
var _b17;
|
|
52177
|
+
var DownloadError2 = class extends (_b17 = AISDKError, _a17 = symbol17, _b17) {
|
|
52178
|
+
constructor({
|
|
52179
|
+
url: url2,
|
|
52180
|
+
statusCode,
|
|
52181
|
+
statusText,
|
|
52182
|
+
cause,
|
|
52183
|
+
message = cause == null ? `Failed to download ${url2}: ${statusCode} ${statusText}` : `Failed to download ${url2}: ${cause}`
|
|
52184
|
+
}) {
|
|
52185
|
+
super({ name: name16, message, cause });
|
|
52186
|
+
this[_a17] = true;
|
|
52187
|
+
this.url = url2;
|
|
52188
|
+
this.statusCode = statusCode;
|
|
52189
|
+
this.statusText = statusText;
|
|
52190
|
+
}
|
|
52191
|
+
static isInstance(error48) {
|
|
52192
|
+
return AISDKError.hasMarker(error48, marker17);
|
|
52193
|
+
}
|
|
52194
|
+
};
|
|
52195
|
+
var DEFAULT_MAX_DOWNLOAD_SIZE2 = 2 * 1024 * 1024 * 1024;
|
|
52196
|
+
var createIdGenerator2 = ({
|
|
52197
|
+
prefix,
|
|
52198
|
+
size = 16,
|
|
52199
|
+
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
52200
|
+
separator = "-"
|
|
52201
|
+
} = {}) => {
|
|
52202
|
+
const generator = () => {
|
|
52203
|
+
const alphabetLength = alphabet.length;
|
|
52204
|
+
const chars = new Array(size);
|
|
52205
|
+
for (let i = 0;i < size; i++) {
|
|
52206
|
+
chars[i] = alphabet[Math.random() * alphabetLength | 0];
|
|
52207
|
+
}
|
|
52208
|
+
return chars.join("");
|
|
52209
|
+
};
|
|
52210
|
+
if (prefix == null) {
|
|
52211
|
+
return generator;
|
|
52212
|
+
}
|
|
52213
|
+
if (alphabet.includes(separator)) {
|
|
52214
|
+
throw new InvalidArgumentError({
|
|
52215
|
+
argument: "separator",
|
|
52216
|
+
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
52217
|
+
});
|
|
52218
|
+
}
|
|
52219
|
+
return () => `${prefix}${separator}${generator()}`;
|
|
52220
|
+
};
|
|
52221
|
+
var generateId2 = createIdGenerator2();
|
|
52222
|
+
function isAbortError2(error48) {
|
|
52223
|
+
return (error48 instanceof Error || error48 instanceof DOMException) && (error48.name === "AbortError" || error48.name === "ResponseAborted" || error48.name === "TimeoutError");
|
|
52224
|
+
}
|
|
52225
|
+
var FETCH_FAILED_ERROR_MESSAGES2 = ["fetch failed", "failed to fetch"];
|
|
52226
|
+
var BUN_ERROR_CODES2 = [
|
|
52227
|
+
"ConnectionRefused",
|
|
52228
|
+
"ConnectionClosed",
|
|
52229
|
+
"FailedToOpenSocket",
|
|
52230
|
+
"ECONNRESET",
|
|
52231
|
+
"ECONNREFUSED",
|
|
52232
|
+
"ETIMEDOUT",
|
|
52233
|
+
"EPIPE"
|
|
52234
|
+
];
|
|
52235
|
+
function isBunNetworkError2(error48) {
|
|
52236
|
+
if (!(error48 instanceof Error)) {
|
|
52237
|
+
return false;
|
|
52238
|
+
}
|
|
52239
|
+
const code = error48.code;
|
|
52240
|
+
if (typeof code === "string" && BUN_ERROR_CODES2.includes(code)) {
|
|
52241
|
+
return true;
|
|
52242
|
+
}
|
|
52243
|
+
return false;
|
|
52244
|
+
}
|
|
52245
|
+
function handleFetchError2({
|
|
52246
|
+
error: error48,
|
|
52247
|
+
url: url2,
|
|
52248
|
+
requestBodyValues
|
|
52163
52249
|
}) {
|
|
52164
|
-
|
|
52165
|
-
|
|
52166
|
-
text += `${prompt[0].content}
|
|
52167
|
-
|
|
52168
|
-
`;
|
|
52169
|
-
prompt = prompt.slice(1);
|
|
52250
|
+
if (isAbortError2(error48)) {
|
|
52251
|
+
return error48;
|
|
52170
52252
|
}
|
|
52171
|
-
|
|
52172
|
-
|
|
52173
|
-
|
|
52174
|
-
|
|
52175
|
-
|
|
52176
|
-
|
|
52177
|
-
|
|
52253
|
+
if (error48 instanceof TypeError && FETCH_FAILED_ERROR_MESSAGES2.includes(error48.message.toLowerCase())) {
|
|
52254
|
+
const cause = error48.cause;
|
|
52255
|
+
if (cause != null) {
|
|
52256
|
+
return new APICallError({
|
|
52257
|
+
message: `Cannot connect to API: ${cause.message}`,
|
|
52258
|
+
cause,
|
|
52259
|
+
url: url2,
|
|
52260
|
+
requestBodyValues,
|
|
52261
|
+
isRetryable: true
|
|
52262
|
+
});
|
|
52263
|
+
}
|
|
52264
|
+
}
|
|
52265
|
+
if (isBunNetworkError2(error48)) {
|
|
52266
|
+
return new APICallError({
|
|
52267
|
+
message: `Cannot connect to API: ${error48.message}`,
|
|
52268
|
+
cause: error48,
|
|
52269
|
+
url: url2,
|
|
52270
|
+
requestBodyValues,
|
|
52271
|
+
isRetryable: true
|
|
52272
|
+
});
|
|
52273
|
+
}
|
|
52274
|
+
return error48;
|
|
52275
|
+
}
|
|
52276
|
+
function getRuntimeEnvironmentUserAgent2(globalThisAny = globalThis) {
|
|
52277
|
+
var _a23, _b22, _c;
|
|
52278
|
+
if (globalThisAny.window) {
|
|
52279
|
+
return `runtime/browser`;
|
|
52280
|
+
}
|
|
52281
|
+
if ((_a23 = globalThisAny.navigator) == null ? undefined : _a23.userAgent) {
|
|
52282
|
+
return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
|
|
52283
|
+
}
|
|
52284
|
+
if ((_c = (_b22 = globalThisAny.process) == null ? undefined : _b22.versions) == null ? undefined : _c.node) {
|
|
52285
|
+
return `runtime/node.js/${globalThisAny.process.version.substring(0)}`;
|
|
52286
|
+
}
|
|
52287
|
+
if (globalThisAny.EdgeRuntime) {
|
|
52288
|
+
return `runtime/vercel-edge`;
|
|
52289
|
+
}
|
|
52290
|
+
return "runtime/unknown";
|
|
52291
|
+
}
|
|
52292
|
+
function normalizeHeaders2(headers) {
|
|
52293
|
+
if (headers == null) {
|
|
52294
|
+
return {};
|
|
52295
|
+
}
|
|
52296
|
+
const normalized = {};
|
|
52297
|
+
if (headers instanceof Headers) {
|
|
52298
|
+
headers.forEach((value, key) => {
|
|
52299
|
+
normalized[key.toLowerCase()] = value;
|
|
52300
|
+
});
|
|
52301
|
+
} else {
|
|
52302
|
+
if (!Array.isArray(headers)) {
|
|
52303
|
+
headers = Object.entries(headers);
|
|
52304
|
+
}
|
|
52305
|
+
for (const [key, value] of headers) {
|
|
52306
|
+
if (value != null) {
|
|
52307
|
+
normalized[key.toLowerCase()] = value;
|
|
52178
52308
|
}
|
|
52179
|
-
|
|
52180
|
-
|
|
52181
|
-
|
|
52182
|
-
|
|
52183
|
-
|
|
52184
|
-
|
|
52185
|
-
|
|
52186
|
-
|
|
52187
|
-
|
|
52188
|
-
|
|
52189
|
-
|
|
52190
|
-
|
|
52191
|
-
|
|
52309
|
+
}
|
|
52310
|
+
}
|
|
52311
|
+
return normalized;
|
|
52312
|
+
}
|
|
52313
|
+
function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
|
|
52314
|
+
const normalizedHeaders = new Headers(normalizeHeaders2(headers));
|
|
52315
|
+
const currentUserAgentHeader = normalizedHeaders.get("user-agent") || "";
|
|
52316
|
+
normalizedHeaders.set("user-agent", [currentUserAgentHeader, ...userAgentSuffixParts].filter(Boolean).join(" "));
|
|
52317
|
+
return Object.fromEntries(normalizedHeaders.entries());
|
|
52318
|
+
}
|
|
52319
|
+
var VERSION8 = "4.0.16";
|
|
52320
|
+
var suspectProtoRx2 = /"__proto__"\s*:/;
|
|
52321
|
+
var suspectConstructorRx2 = /"constructor"\s*:/;
|
|
52322
|
+
function _parse3(text) {
|
|
52323
|
+
const obj = JSON.parse(text);
|
|
52324
|
+
if (obj === null || typeof obj !== "object") {
|
|
52325
|
+
return obj;
|
|
52326
|
+
}
|
|
52327
|
+
if (suspectProtoRx2.test(text) === false && suspectConstructorRx2.test(text) === false) {
|
|
52328
|
+
return obj;
|
|
52329
|
+
}
|
|
52330
|
+
return filter2(obj);
|
|
52331
|
+
}
|
|
52332
|
+
function filter2(obj) {
|
|
52333
|
+
let next = [obj];
|
|
52334
|
+
while (next.length) {
|
|
52335
|
+
const nodes = next;
|
|
52336
|
+
next = [];
|
|
52337
|
+
for (const node of nodes) {
|
|
52338
|
+
if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
|
|
52339
|
+
throw new SyntaxError("Object contains forbidden prototype property");
|
|
52192
52340
|
}
|
|
52193
|
-
|
|
52194
|
-
|
|
52195
|
-
switch (part.type) {
|
|
52196
|
-
case "text": {
|
|
52197
|
-
return part.text;
|
|
52198
|
-
}
|
|
52199
|
-
case "tool-call": {
|
|
52200
|
-
throw new UnsupportedFunctionalityError({
|
|
52201
|
-
functionality: "tool-call messages"
|
|
52202
|
-
});
|
|
52203
|
-
}
|
|
52204
|
-
}
|
|
52205
|
-
}).join("");
|
|
52206
|
-
text += `${assistant}:
|
|
52207
|
-
${assistantMessage}
|
|
52208
|
-
|
|
52209
|
-
`;
|
|
52210
|
-
break;
|
|
52341
|
+
if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
52342
|
+
throw new SyntaxError("Object contains forbidden prototype property");
|
|
52211
52343
|
}
|
|
52212
|
-
|
|
52213
|
-
|
|
52214
|
-
|
|
52215
|
-
|
|
52344
|
+
for (const key in node) {
|
|
52345
|
+
const value = node[key];
|
|
52346
|
+
if (value && typeof value === "object") {
|
|
52347
|
+
next.push(value);
|
|
52348
|
+
}
|
|
52216
52349
|
}
|
|
52217
|
-
|
|
52218
|
-
|
|
52219
|
-
|
|
52350
|
+
}
|
|
52351
|
+
}
|
|
52352
|
+
return obj;
|
|
52353
|
+
}
|
|
52354
|
+
function secureJsonParse2(text) {
|
|
52355
|
+
const { stackTraceLimit } = Error;
|
|
52356
|
+
try {
|
|
52357
|
+
Error.stackTraceLimit = 0;
|
|
52358
|
+
} catch (e) {
|
|
52359
|
+
return _parse3(text);
|
|
52360
|
+
}
|
|
52361
|
+
try {
|
|
52362
|
+
return _parse3(text);
|
|
52363
|
+
} finally {
|
|
52364
|
+
Error.stackTraceLimit = stackTraceLimit;
|
|
52365
|
+
}
|
|
52366
|
+
}
|
|
52367
|
+
function addAdditionalPropertiesToJsonSchema2(jsonSchema2) {
|
|
52368
|
+
if (jsonSchema2.type === "object" || Array.isArray(jsonSchema2.type) && jsonSchema2.type.includes("object")) {
|
|
52369
|
+
jsonSchema2.additionalProperties = false;
|
|
52370
|
+
const { properties } = jsonSchema2;
|
|
52371
|
+
if (properties != null) {
|
|
52372
|
+
for (const key of Object.keys(properties)) {
|
|
52373
|
+
properties[key] = visit2(properties[key]);
|
|
52220
52374
|
}
|
|
52221
52375
|
}
|
|
52222
52376
|
}
|
|
52223
|
-
|
|
52224
|
-
|
|
52225
|
-
|
|
52226
|
-
|
|
52227
|
-
|
|
52228
|
-
|
|
52377
|
+
if (jsonSchema2.items != null) {
|
|
52378
|
+
jsonSchema2.items = Array.isArray(jsonSchema2.items) ? jsonSchema2.items.map(visit2) : visit2(jsonSchema2.items);
|
|
52379
|
+
}
|
|
52380
|
+
if (jsonSchema2.anyOf != null) {
|
|
52381
|
+
jsonSchema2.anyOf = jsonSchema2.anyOf.map(visit2);
|
|
52382
|
+
}
|
|
52383
|
+
if (jsonSchema2.allOf != null) {
|
|
52384
|
+
jsonSchema2.allOf = jsonSchema2.allOf.map(visit2);
|
|
52385
|
+
}
|
|
52386
|
+
if (jsonSchema2.oneOf != null) {
|
|
52387
|
+
jsonSchema2.oneOf = jsonSchema2.oneOf.map(visit2);
|
|
52388
|
+
}
|
|
52389
|
+
const { definitions } = jsonSchema2;
|
|
52390
|
+
if (definitions != null) {
|
|
52391
|
+
for (const key of Object.keys(definitions)) {
|
|
52392
|
+
definitions[key] = visit2(definitions[key]);
|
|
52393
|
+
}
|
|
52394
|
+
}
|
|
52395
|
+
return jsonSchema2;
|
|
52396
|
+
}
|
|
52397
|
+
function visit2(def) {
|
|
52398
|
+
if (typeof def === "boolean")
|
|
52399
|
+
return def;
|
|
52400
|
+
return addAdditionalPropertiesToJsonSchema2(def);
|
|
52401
|
+
}
|
|
52402
|
+
var ignoreOverride2 = Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
52403
|
+
var defaultOptions2 = {
|
|
52404
|
+
name: undefined,
|
|
52405
|
+
$refStrategy: "root",
|
|
52406
|
+
basePath: ["#"],
|
|
52407
|
+
effectStrategy: "input",
|
|
52408
|
+
pipeStrategy: "all",
|
|
52409
|
+
dateStrategy: "format:date-time",
|
|
52410
|
+
mapStrategy: "entries",
|
|
52411
|
+
removeAdditionalStrategy: "passthrough",
|
|
52412
|
+
allowedAdditionalProperties: true,
|
|
52413
|
+
rejectedAdditionalProperties: false,
|
|
52414
|
+
definitionPath: "definitions",
|
|
52415
|
+
strictUnions: false,
|
|
52416
|
+
definitions: {},
|
|
52417
|
+
errorMessages: false,
|
|
52418
|
+
patternStrategy: "escape",
|
|
52419
|
+
applyRegexFlags: false,
|
|
52420
|
+
emailStrategy: "format:email",
|
|
52421
|
+
base64Strategy: "contentEncoding:base64",
|
|
52422
|
+
nameStrategy: "ref"
|
|
52423
|
+
};
|
|
52424
|
+
var getDefaultOptions2 = (options) => typeof options === "string" ? {
|
|
52425
|
+
...defaultOptions2,
|
|
52426
|
+
name: options
|
|
52427
|
+
} : {
|
|
52428
|
+
...defaultOptions2,
|
|
52429
|
+
...options
|
|
52430
|
+
};
|
|
52431
|
+
function parseAnyDef2() {
|
|
52432
|
+
return {};
|
|
52433
|
+
}
|
|
52434
|
+
function parseArrayDef2(def, refs) {
|
|
52435
|
+
var _a23, _b22, _c;
|
|
52436
|
+
const res = {
|
|
52437
|
+
type: "array"
|
|
52229
52438
|
};
|
|
52439
|
+
if (((_a23 = def.type) == null ? undefined : _a23._def) && ((_c = (_b22 = def.type) == null ? undefined : _b22._def) == null ? undefined : _c.typeName) !== ZodFirstPartyTypeKind2.ZodAny) {
|
|
52440
|
+
res.items = parseDef2(def.type._def, {
|
|
52441
|
+
...refs,
|
|
52442
|
+
currentPath: [...refs.currentPath, "items"]
|
|
52443
|
+
});
|
|
52444
|
+
}
|
|
52445
|
+
if (def.minLength) {
|
|
52446
|
+
res.minItems = def.minLength.value;
|
|
52447
|
+
}
|
|
52448
|
+
if (def.maxLength) {
|
|
52449
|
+
res.maxItems = def.maxLength.value;
|
|
52450
|
+
}
|
|
52451
|
+
if (def.exactLength) {
|
|
52452
|
+
res.minItems = def.exactLength.value;
|
|
52453
|
+
res.maxItems = def.exactLength.value;
|
|
52454
|
+
}
|
|
52455
|
+
return res;
|
|
52230
52456
|
}
|
|
52231
|
-
function
|
|
52232
|
-
|
|
52233
|
-
|
|
52234
|
-
|
|
52235
|
-
|
|
52236
|
-
|
|
52237
|
-
|
|
52238
|
-
|
|
52239
|
-
|
|
52240
|
-
|
|
52241
|
-
|
|
52242
|
-
|
|
52243
|
-
|
|
52244
|
-
|
|
52245
|
-
|
|
52246
|
-
|
|
52247
|
-
|
|
52248
|
-
|
|
52249
|
-
|
|
52457
|
+
function parseBigintDef2(def) {
|
|
52458
|
+
const res = {
|
|
52459
|
+
type: "integer",
|
|
52460
|
+
format: "int64"
|
|
52461
|
+
};
|
|
52462
|
+
if (!def.checks)
|
|
52463
|
+
return res;
|
|
52464
|
+
for (const check2 of def.checks) {
|
|
52465
|
+
switch (check2.kind) {
|
|
52466
|
+
case "min":
|
|
52467
|
+
if (check2.inclusive) {
|
|
52468
|
+
res.minimum = check2.value;
|
|
52469
|
+
} else {
|
|
52470
|
+
res.exclusiveMinimum = check2.value;
|
|
52471
|
+
}
|
|
52472
|
+
break;
|
|
52473
|
+
case "max":
|
|
52474
|
+
if (check2.inclusive) {
|
|
52475
|
+
res.maximum = check2.value;
|
|
52476
|
+
} else {
|
|
52477
|
+
res.exclusiveMaximum = check2.value;
|
|
52478
|
+
}
|
|
52479
|
+
break;
|
|
52480
|
+
case "multipleOf":
|
|
52481
|
+
res.multipleOf = check2.value;
|
|
52482
|
+
break;
|
|
52483
|
+
}
|
|
52484
|
+
}
|
|
52485
|
+
return res;
|
|
52486
|
+
}
|
|
52487
|
+
function parseBooleanDef2() {
|
|
52488
|
+
return { type: "boolean" };
|
|
52489
|
+
}
|
|
52490
|
+
function parseBrandedDef2(_def, refs) {
|
|
52491
|
+
return parseDef2(_def.type._def, refs);
|
|
52492
|
+
}
|
|
52493
|
+
var parseCatchDef2 = (def, refs) => {
|
|
52494
|
+
return parseDef2(def.innerType._def, refs);
|
|
52495
|
+
};
|
|
52496
|
+
function parseDateDef2(def, refs, overrideDateStrategy) {
|
|
52497
|
+
const strategy = overrideDateStrategy != null ? overrideDateStrategy : refs.dateStrategy;
|
|
52498
|
+
if (Array.isArray(strategy)) {
|
|
52499
|
+
return {
|
|
52500
|
+
anyOf: strategy.map((item, i) => parseDateDef2(def, refs, item))
|
|
52501
|
+
};
|
|
52502
|
+
}
|
|
52503
|
+
switch (strategy) {
|
|
52504
|
+
case "string":
|
|
52505
|
+
case "format:date-time":
|
|
52250
52506
|
return {
|
|
52251
|
-
|
|
52252
|
-
|
|
52507
|
+
type: "string",
|
|
52508
|
+
format: "date-time"
|
|
52253
52509
|
};
|
|
52254
|
-
|
|
52510
|
+
case "format:date":
|
|
52255
52511
|
return {
|
|
52256
|
-
|
|
52257
|
-
|
|
52512
|
+
type: "string",
|
|
52513
|
+
format: "date"
|
|
52258
52514
|
};
|
|
52515
|
+
case "integer":
|
|
52516
|
+
return integerDateParser2(def);
|
|
52259
52517
|
}
|
|
52260
52518
|
}
|
|
52261
|
-
|
|
52262
|
-
|
|
52263
|
-
|
|
52264
|
-
|
|
52519
|
+
var integerDateParser2 = (def) => {
|
|
52520
|
+
const res = {
|
|
52521
|
+
type: "integer",
|
|
52522
|
+
format: "unix-time"
|
|
52523
|
+
};
|
|
52524
|
+
for (const check2 of def.checks) {
|
|
52525
|
+
switch (check2.kind) {
|
|
52526
|
+
case "min":
|
|
52527
|
+
res.minimum = check2.value;
|
|
52528
|
+
break;
|
|
52529
|
+
case "max":
|
|
52530
|
+
res.maximum = check2.value;
|
|
52531
|
+
break;
|
|
52532
|
+
}
|
|
52533
|
+
}
|
|
52534
|
+
return res;
|
|
52535
|
+
};
|
|
52536
|
+
function parseDefaultDef2(_def, refs) {
|
|
52265
52537
|
return {
|
|
52266
|
-
|
|
52267
|
-
|
|
52268
|
-
timestamp: created_at != null ? new Date(created_at) : undefined
|
|
52538
|
+
...parseDef2(_def.innerType._def, refs),
|
|
52539
|
+
default: _def.defaultValue()
|
|
52269
52540
|
};
|
|
52270
52541
|
}
|
|
52271
|
-
function
|
|
52272
|
-
return
|
|
52273
|
-
|
|
52274
|
-
|
|
52275
|
-
|
|
52276
|
-
|
|
52277
|
-
|
|
52278
|
-
|
|
52279
|
-
|
|
52280
|
-
|
|
52281
|
-
|
|
52282
|
-
|
|
52283
|
-
|
|
52284
|
-
|
|
52285
|
-
|
|
52286
|
-
|
|
52287
|
-
|
|
52288
|
-
|
|
52289
|
-
|
|
52290
|
-
|
|
52291
|
-
|
|
52292
|
-
|
|
52293
|
-
|
|
52294
|
-
|
|
52295
|
-
|
|
52296
|
-
|
|
52297
|
-
|
|
52298
|
-
|
|
52299
|
-
|
|
52300
|
-
|
|
52301
|
-
|
|
52302
|
-
|
|
52303
|
-
|
|
52304
|
-
|
|
52305
|
-
controller.enqueue({ success: true, value: validated, rawValue: validated });
|
|
52306
|
-
} catch (error48) {
|
|
52307
|
-
console.warn("Failed to parse NDJSON line:", error48);
|
|
52308
|
-
}
|
|
52309
|
-
}
|
|
52310
|
-
}
|
|
52311
|
-
}
|
|
52312
|
-
},
|
|
52313
|
-
cancel() {
|
|
52314
|
-
reader.cancel();
|
|
52542
|
+
function parseEffectsDef2(_def, refs) {
|
|
52543
|
+
return refs.effectStrategy === "input" ? parseDef2(_def.schema._def, refs) : parseAnyDef2();
|
|
52544
|
+
}
|
|
52545
|
+
function parseEnumDef2(def) {
|
|
52546
|
+
return {
|
|
52547
|
+
type: "string",
|
|
52548
|
+
enum: Array.from(def.values)
|
|
52549
|
+
};
|
|
52550
|
+
}
|
|
52551
|
+
var isJsonSchema7AllOfType2 = (type) => {
|
|
52552
|
+
if ("type" in type && type.type === "string")
|
|
52553
|
+
return false;
|
|
52554
|
+
return "allOf" in type;
|
|
52555
|
+
};
|
|
52556
|
+
function parseIntersectionDef2(def, refs) {
|
|
52557
|
+
const allOf = [
|
|
52558
|
+
parseDef2(def.left._def, {
|
|
52559
|
+
...refs,
|
|
52560
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
52561
|
+
}),
|
|
52562
|
+
parseDef2(def.right._def, {
|
|
52563
|
+
...refs,
|
|
52564
|
+
currentPath: [...refs.currentPath, "allOf", "1"]
|
|
52565
|
+
})
|
|
52566
|
+
].filter((x) => !!x);
|
|
52567
|
+
const mergedAllOf = [];
|
|
52568
|
+
allOf.forEach((schema) => {
|
|
52569
|
+
if (isJsonSchema7AllOfType2(schema)) {
|
|
52570
|
+
mergedAllOf.push(...schema.allOf);
|
|
52571
|
+
} else {
|
|
52572
|
+
let nestedSchema = schema;
|
|
52573
|
+
if ("additionalProperties" in schema && schema.additionalProperties === false) {
|
|
52574
|
+
const { additionalProperties, ...rest } = schema;
|
|
52575
|
+
nestedSchema = rest;
|
|
52315
52576
|
}
|
|
52316
|
-
|
|
52577
|
+
mergedAllOf.push(nestedSchema);
|
|
52578
|
+
}
|
|
52579
|
+
});
|
|
52580
|
+
return mergedAllOf.length ? { allOf: mergedAllOf } : undefined;
|
|
52581
|
+
}
|
|
52582
|
+
function parseLiteralDef2(def) {
|
|
52583
|
+
const parsedType2 = typeof def.value;
|
|
52584
|
+
if (parsedType2 !== "bigint" && parsedType2 !== "number" && parsedType2 !== "boolean" && parsedType2 !== "string") {
|
|
52317
52585
|
return {
|
|
52318
|
-
|
|
52319
|
-
value: stream
|
|
52586
|
+
type: Array.isArray(def.value) ? "array" : "object"
|
|
52320
52587
|
};
|
|
52588
|
+
}
|
|
52589
|
+
return {
|
|
52590
|
+
type: parsedType2 === "bigint" ? "integer" : parsedType2,
|
|
52591
|
+
const: def.value
|
|
52321
52592
|
};
|
|
52322
52593
|
}
|
|
52323
|
-
var
|
|
52324
|
-
|
|
52325
|
-
|
|
52326
|
-
|
|
52327
|
-
|
|
52328
|
-
|
|
52329
|
-
|
|
52330
|
-
|
|
52331
|
-
|
|
52332
|
-
|
|
52333
|
-
|
|
52334
|
-
}
|
|
52335
|
-
|
|
52336
|
-
|
|
52337
|
-
|
|
52338
|
-
|
|
52339
|
-
|
|
52340
|
-
})
|
|
52341
|
-
|
|
52342
|
-
|
|
52343
|
-
|
|
52344
|
-
|
|
52345
|
-
|
|
52346
|
-
|
|
52347
|
-
|
|
52348
|
-
|
|
52349
|
-
|
|
52350
|
-
|
|
52351
|
-
|
|
52352
|
-
|
|
52353
|
-
|
|
52354
|
-
|
|
52355
|
-
|
|
52594
|
+
var emojiRegex3 = undefined;
|
|
52595
|
+
var zodPatterns2 = {
|
|
52596
|
+
cuid: /^[cC][^\s-]{8,}$/,
|
|
52597
|
+
cuid2: /^[0-9a-z]+$/,
|
|
52598
|
+
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
52599
|
+
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
52600
|
+
emoji: () => {
|
|
52601
|
+
if (emojiRegex3 === undefined) {
|
|
52602
|
+
emojiRegex3 = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
|
|
52603
|
+
}
|
|
52604
|
+
return emojiRegex3;
|
|
52605
|
+
},
|
|
52606
|
+
uuid: /^[0-9a-fA-F]{8}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{4}\b-[0-9a-fA-F]{12}$/,
|
|
52607
|
+
ipv4: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])$/,
|
|
52608
|
+
ipv4Cidr: /^(?:(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\.){3}(?:25[0-5]|2[0-4][0-9]|1[0-9][0-9]|[1-9][0-9]|[0-9])\/(3[0-2]|[12]?[0-9])$/,
|
|
52609
|
+
ipv6: /^(([a-f0-9]{1,4}:){7}|::([a-f0-9]{1,4}:){0,6}|([a-f0-9]{1,4}:){1}:([a-f0-9]{1,4}:){0,5}|([a-f0-9]{1,4}:){2}:([a-f0-9]{1,4}:){0,4}|([a-f0-9]{1,4}:){3}:([a-f0-9]{1,4}:){0,3}|([a-f0-9]{1,4}:){4}:([a-f0-9]{1,4}:){0,2}|([a-f0-9]{1,4}:){5}:([a-f0-9]{1,4}:){0,1})([a-f0-9]{1,4}|(((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2}))\.){3}((25[0-5])|(2[0-4][0-9])|(1[0-9]{2})|([0-9]{1,2})))$/,
|
|
52610
|
+
ipv6Cidr: /^(([0-9a-fA-F]{1,4}:){7,7}[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,7}:|([0-9a-fA-F]{1,4}:){1,6}:[0-9a-fA-F]{1,4}|([0-9a-fA-F]{1,4}:){1,5}(:[0-9a-fA-F]{1,4}){1,2}|([0-9a-fA-F]{1,4}:){1,4}(:[0-9a-fA-F]{1,4}){1,3}|([0-9a-fA-F]{1,4}:){1,3}(:[0-9a-fA-F]{1,4}){1,4}|([0-9a-fA-F]{1,4}:){1,2}(:[0-9a-fA-F]{1,4}){1,5}|[0-9a-fA-F]{1,4}:((:[0-9a-fA-F]{1,4}){1,6})|:((:[0-9a-fA-F]{1,4}){1,7}|:)|fe80:(:[0-9a-fA-F]{0,4}){0,4}%[0-9a-zA-Z]{1,}|::(ffff(:0{1,4}){0,1}:){0,1}((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])|([0-9a-fA-F]{1,4}:){1,4}:((25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9])\.){3,3}(25[0-5]|(2[0-4]|1{0,1}[0-9]){0,1}[0-9]))\/(12[0-8]|1[01][0-9]|[1-9]?[0-9])$/,
|
|
52611
|
+
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
52612
|
+
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
52613
|
+
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
52614
|
+
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
52615
|
+
};
|
|
52616
|
+
function parseStringDef2(def, refs) {
|
|
52617
|
+
const res = {
|
|
52618
|
+
type: "string"
|
|
52619
|
+
};
|
|
52620
|
+
if (def.checks) {
|
|
52621
|
+
for (const check2 of def.checks) {
|
|
52622
|
+
switch (check2.kind) {
|
|
52623
|
+
case "min":
|
|
52624
|
+
res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check2.value) : check2.value;
|
|
52625
|
+
break;
|
|
52626
|
+
case "max":
|
|
52627
|
+
res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check2.value) : check2.value;
|
|
52628
|
+
break;
|
|
52629
|
+
case "email":
|
|
52630
|
+
switch (refs.emailStrategy) {
|
|
52631
|
+
case "format:email":
|
|
52632
|
+
addFormat2(res, "email", check2.message, refs);
|
|
52633
|
+
break;
|
|
52634
|
+
case "format:idn-email":
|
|
52635
|
+
addFormat2(res, "idn-email", check2.message, refs);
|
|
52636
|
+
break;
|
|
52637
|
+
case "pattern:zod":
|
|
52638
|
+
addPattern2(res, zodPatterns2.email, check2.message, refs);
|
|
52639
|
+
break;
|
|
52640
|
+
}
|
|
52641
|
+
break;
|
|
52642
|
+
case "url":
|
|
52643
|
+
addFormat2(res, "uri", check2.message, refs);
|
|
52644
|
+
break;
|
|
52645
|
+
case "uuid":
|
|
52646
|
+
addFormat2(res, "uuid", check2.message, refs);
|
|
52647
|
+
break;
|
|
52648
|
+
case "regex":
|
|
52649
|
+
addPattern2(res, check2.regex, check2.message, refs);
|
|
52650
|
+
break;
|
|
52651
|
+
case "cuid":
|
|
52652
|
+
addPattern2(res, zodPatterns2.cuid, check2.message, refs);
|
|
52653
|
+
break;
|
|
52654
|
+
case "cuid2":
|
|
52655
|
+
addPattern2(res, zodPatterns2.cuid2, check2.message, refs);
|
|
52656
|
+
break;
|
|
52657
|
+
case "startsWith":
|
|
52658
|
+
addPattern2(res, RegExp(`^${escapeLiteralCheckValue2(check2.value, refs)}`), check2.message, refs);
|
|
52659
|
+
break;
|
|
52660
|
+
case "endsWith":
|
|
52661
|
+
addPattern2(res, RegExp(`${escapeLiteralCheckValue2(check2.value, refs)}$`), check2.message, refs);
|
|
52662
|
+
break;
|
|
52663
|
+
case "datetime":
|
|
52664
|
+
addFormat2(res, "date-time", check2.message, refs);
|
|
52665
|
+
break;
|
|
52666
|
+
case "date":
|
|
52667
|
+
addFormat2(res, "date", check2.message, refs);
|
|
52668
|
+
break;
|
|
52669
|
+
case "time":
|
|
52670
|
+
addFormat2(res, "time", check2.message, refs);
|
|
52671
|
+
break;
|
|
52672
|
+
case "duration":
|
|
52673
|
+
addFormat2(res, "duration", check2.message, refs);
|
|
52674
|
+
break;
|
|
52675
|
+
case "length":
|
|
52676
|
+
res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check2.value) : check2.value;
|
|
52677
|
+
res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check2.value) : check2.value;
|
|
52678
|
+
break;
|
|
52679
|
+
case "includes": {
|
|
52680
|
+
addPattern2(res, RegExp(escapeLiteralCheckValue2(check2.value, refs)), check2.message, refs);
|
|
52681
|
+
break;
|
|
52682
|
+
}
|
|
52683
|
+
case "ip": {
|
|
52684
|
+
if (check2.version !== "v6") {
|
|
52685
|
+
addFormat2(res, "ipv4", check2.message, refs);
|
|
52686
|
+
}
|
|
52687
|
+
if (check2.version !== "v4") {
|
|
52688
|
+
addFormat2(res, "ipv6", check2.message, refs);
|
|
52689
|
+
}
|
|
52690
|
+
break;
|
|
52691
|
+
}
|
|
52692
|
+
case "base64url":
|
|
52693
|
+
addPattern2(res, zodPatterns2.base64url, check2.message, refs);
|
|
52694
|
+
break;
|
|
52695
|
+
case "jwt":
|
|
52696
|
+
addPattern2(res, zodPatterns2.jwt, check2.message, refs);
|
|
52697
|
+
break;
|
|
52698
|
+
case "cidr": {
|
|
52699
|
+
if (check2.version !== "v6") {
|
|
52700
|
+
addPattern2(res, zodPatterns2.ipv4Cidr, check2.message, refs);
|
|
52701
|
+
}
|
|
52702
|
+
if (check2.version !== "v4") {
|
|
52703
|
+
addPattern2(res, zodPatterns2.ipv6Cidr, check2.message, refs);
|
|
52704
|
+
}
|
|
52705
|
+
break;
|
|
52706
|
+
}
|
|
52707
|
+
case "emoji":
|
|
52708
|
+
addPattern2(res, zodPatterns2.emoji(), check2.message, refs);
|
|
52709
|
+
break;
|
|
52710
|
+
case "ulid": {
|
|
52711
|
+
addPattern2(res, zodPatterns2.ulid, check2.message, refs);
|
|
52712
|
+
break;
|
|
52713
|
+
}
|
|
52714
|
+
case "base64": {
|
|
52715
|
+
switch (refs.base64Strategy) {
|
|
52716
|
+
case "format:binary": {
|
|
52717
|
+
addFormat2(res, "binary", check2.message, refs);
|
|
52718
|
+
break;
|
|
52719
|
+
}
|
|
52720
|
+
case "contentEncoding:base64": {
|
|
52721
|
+
res.contentEncoding = "base64";
|
|
52722
|
+
break;
|
|
52723
|
+
}
|
|
52724
|
+
case "pattern:zod": {
|
|
52725
|
+
addPattern2(res, zodPatterns2.base64, check2.message, refs);
|
|
52726
|
+
break;
|
|
52727
|
+
}
|
|
52728
|
+
}
|
|
52729
|
+
break;
|
|
52730
|
+
}
|
|
52731
|
+
case "nanoid": {
|
|
52732
|
+
addPattern2(res, zodPatterns2.nanoid, check2.message, refs);
|
|
52733
|
+
}
|
|
52734
|
+
case "toLowerCase":
|
|
52735
|
+
case "toUpperCase":
|
|
52736
|
+
case "trim":
|
|
52737
|
+
break;
|
|
52738
|
+
default:
|
|
52739
|
+
}
|
|
52740
|
+
}
|
|
52741
|
+
}
|
|
52742
|
+
return res;
|
|
52743
|
+
}
|
|
52744
|
+
function escapeLiteralCheckValue2(literal2, refs) {
|
|
52745
|
+
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric2(literal2) : literal2;
|
|
52746
|
+
}
|
|
52747
|
+
var ALPHA_NUMERIC2 = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
52748
|
+
function escapeNonAlphaNumeric2(source) {
|
|
52749
|
+
let result = "";
|
|
52750
|
+
for (let i = 0;i < source.length; i++) {
|
|
52751
|
+
if (!ALPHA_NUMERIC2.has(source[i])) {
|
|
52752
|
+
result += "\\";
|
|
52753
|
+
}
|
|
52754
|
+
result += source[i];
|
|
52755
|
+
}
|
|
52756
|
+
return result;
|
|
52757
|
+
}
|
|
52758
|
+
function addFormat2(schema, value, message, refs) {
|
|
52759
|
+
var _a23;
|
|
52760
|
+
if (schema.format || ((_a23 = schema.anyOf) == null ? undefined : _a23.some((x) => x.format))) {
|
|
52761
|
+
if (!schema.anyOf) {
|
|
52762
|
+
schema.anyOf = [];
|
|
52763
|
+
}
|
|
52764
|
+
if (schema.format) {
|
|
52765
|
+
schema.anyOf.push({
|
|
52766
|
+
format: schema.format
|
|
52767
|
+
});
|
|
52768
|
+
delete schema.format;
|
|
52769
|
+
}
|
|
52770
|
+
schema.anyOf.push({
|
|
52771
|
+
format: value,
|
|
52772
|
+
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
52773
|
+
});
|
|
52774
|
+
} else {
|
|
52775
|
+
schema.format = value;
|
|
52776
|
+
}
|
|
52777
|
+
}
|
|
52778
|
+
function addPattern2(schema, regex, message, refs) {
|
|
52779
|
+
var _a23;
|
|
52780
|
+
if (schema.pattern || ((_a23 = schema.allOf) == null ? undefined : _a23.some((x) => x.pattern))) {
|
|
52781
|
+
if (!schema.allOf) {
|
|
52782
|
+
schema.allOf = [];
|
|
52783
|
+
}
|
|
52784
|
+
if (schema.pattern) {
|
|
52785
|
+
schema.allOf.push({
|
|
52786
|
+
pattern: schema.pattern
|
|
52787
|
+
});
|
|
52788
|
+
delete schema.pattern;
|
|
52789
|
+
}
|
|
52790
|
+
schema.allOf.push({
|
|
52791
|
+
pattern: stringifyRegExpWithFlags2(regex, refs),
|
|
52792
|
+
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
52793
|
+
});
|
|
52794
|
+
} else {
|
|
52795
|
+
schema.pattern = stringifyRegExpWithFlags2(regex, refs);
|
|
52796
|
+
}
|
|
52797
|
+
}
|
|
52798
|
+
function stringifyRegExpWithFlags2(regex, refs) {
|
|
52799
|
+
var _a23;
|
|
52800
|
+
if (!refs.applyRegexFlags || !regex.flags) {
|
|
52801
|
+
return regex.source;
|
|
52802
|
+
}
|
|
52803
|
+
const flags = {
|
|
52804
|
+
i: regex.flags.includes("i"),
|
|
52805
|
+
m: regex.flags.includes("m"),
|
|
52806
|
+
s: regex.flags.includes("s")
|
|
52807
|
+
};
|
|
52808
|
+
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
52809
|
+
let pattern = "";
|
|
52810
|
+
let isEscaped = false;
|
|
52811
|
+
let inCharGroup = false;
|
|
52812
|
+
let inCharRange = false;
|
|
52813
|
+
for (let i = 0;i < source.length; i++) {
|
|
52814
|
+
if (isEscaped) {
|
|
52815
|
+
pattern += source[i];
|
|
52816
|
+
isEscaped = false;
|
|
52817
|
+
continue;
|
|
52818
|
+
}
|
|
52819
|
+
if (flags.i) {
|
|
52820
|
+
if (inCharGroup) {
|
|
52821
|
+
if (source[i].match(/[a-z]/)) {
|
|
52822
|
+
if (inCharRange) {
|
|
52823
|
+
pattern += source[i];
|
|
52824
|
+
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
52825
|
+
inCharRange = false;
|
|
52826
|
+
} else if (source[i + 1] === "-" && ((_a23 = source[i + 2]) == null ? undefined : _a23.match(/[a-z]/))) {
|
|
52827
|
+
pattern += source[i];
|
|
52828
|
+
inCharRange = true;
|
|
52829
|
+
} else {
|
|
52830
|
+
pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
52831
|
+
}
|
|
52832
|
+
continue;
|
|
52833
|
+
}
|
|
52834
|
+
} else if (source[i].match(/[a-z]/)) {
|
|
52835
|
+
pattern += `[${source[i]}${source[i].toUpperCase()}]`;
|
|
52836
|
+
continue;
|
|
52837
|
+
}
|
|
52838
|
+
}
|
|
52839
|
+
if (flags.m) {
|
|
52840
|
+
if (source[i] === "^") {
|
|
52841
|
+
pattern += `(^|(?<=[\r
|
|
52842
|
+
]))`;
|
|
52843
|
+
continue;
|
|
52844
|
+
} else if (source[i] === "$") {
|
|
52845
|
+
pattern += `($|(?=[\r
|
|
52846
|
+
]))`;
|
|
52847
|
+
continue;
|
|
52848
|
+
}
|
|
52849
|
+
}
|
|
52850
|
+
if (flags.s && source[i] === ".") {
|
|
52851
|
+
pattern += inCharGroup ? `${source[i]}\r
|
|
52852
|
+
` : `[${source[i]}\r
|
|
52853
|
+
]`;
|
|
52854
|
+
continue;
|
|
52855
|
+
}
|
|
52856
|
+
pattern += source[i];
|
|
52857
|
+
if (source[i] === "\\") {
|
|
52858
|
+
isEscaped = true;
|
|
52859
|
+
} else if (inCharGroup && source[i] === "]") {
|
|
52860
|
+
inCharGroup = false;
|
|
52861
|
+
} else if (!inCharGroup && source[i] === "[") {
|
|
52862
|
+
inCharGroup = true;
|
|
52863
|
+
}
|
|
52864
|
+
}
|
|
52865
|
+
try {
|
|
52866
|
+
new RegExp(pattern);
|
|
52867
|
+
} catch (e) {
|
|
52868
|
+
console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
|
|
52869
|
+
return regex.source;
|
|
52870
|
+
}
|
|
52871
|
+
return pattern;
|
|
52872
|
+
}
|
|
52873
|
+
function parseRecordDef2(def, refs) {
|
|
52874
|
+
var _a23, _b22, _c, _d, _e, _f;
|
|
52875
|
+
const schema = {
|
|
52876
|
+
type: "object",
|
|
52877
|
+
additionalProperties: (_a23 = parseDef2(def.valueType._def, {
|
|
52878
|
+
...refs,
|
|
52879
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
52880
|
+
})) != null ? _a23 : refs.allowedAdditionalProperties
|
|
52881
|
+
};
|
|
52882
|
+
if (((_b22 = def.keyType) == null ? undefined : _b22._def.typeName) === ZodFirstPartyTypeKind2.ZodString && ((_c = def.keyType._def.checks) == null ? undefined : _c.length)) {
|
|
52883
|
+
const { type, ...keyType } = parseStringDef2(def.keyType._def, refs);
|
|
52884
|
+
return {
|
|
52885
|
+
...schema,
|
|
52886
|
+
propertyNames: keyType
|
|
52887
|
+
};
|
|
52888
|
+
} else if (((_d = def.keyType) == null ? undefined : _d._def.typeName) === ZodFirstPartyTypeKind2.ZodEnum) {
|
|
52889
|
+
return {
|
|
52890
|
+
...schema,
|
|
52891
|
+
propertyNames: {
|
|
52892
|
+
enum: def.keyType._def.values
|
|
52893
|
+
}
|
|
52894
|
+
};
|
|
52895
|
+
} else if (((_e = def.keyType) == null ? undefined : _e._def.typeName) === ZodFirstPartyTypeKind2.ZodBranded && def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind2.ZodString && ((_f = def.keyType._def.type._def.checks) == null ? undefined : _f.length)) {
|
|
52896
|
+
const { type, ...keyType } = parseBrandedDef2(def.keyType._def, refs);
|
|
52897
|
+
return {
|
|
52898
|
+
...schema,
|
|
52899
|
+
propertyNames: keyType
|
|
52900
|
+
};
|
|
52901
|
+
}
|
|
52902
|
+
return schema;
|
|
52903
|
+
}
|
|
52904
|
+
function parseMapDef2(def, refs) {
|
|
52905
|
+
if (refs.mapStrategy === "record") {
|
|
52906
|
+
return parseRecordDef2(def, refs);
|
|
52907
|
+
}
|
|
52908
|
+
const keys = parseDef2(def.keyType._def, {
|
|
52909
|
+
...refs,
|
|
52910
|
+
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
52911
|
+
}) || parseAnyDef2();
|
|
52912
|
+
const values = parseDef2(def.valueType._def, {
|
|
52913
|
+
...refs,
|
|
52914
|
+
currentPath: [...refs.currentPath, "items", "items", "1"]
|
|
52915
|
+
}) || parseAnyDef2();
|
|
52916
|
+
return {
|
|
52917
|
+
type: "array",
|
|
52918
|
+
maxItems: 125,
|
|
52919
|
+
items: {
|
|
52920
|
+
type: "array",
|
|
52921
|
+
items: [keys, values],
|
|
52922
|
+
minItems: 2,
|
|
52923
|
+
maxItems: 2
|
|
52924
|
+
}
|
|
52925
|
+
};
|
|
52926
|
+
}
|
|
52927
|
+
function parseNativeEnumDef2(def) {
|
|
52928
|
+
const object2 = def.values;
|
|
52929
|
+
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
52930
|
+
return typeof object2[object2[key]] !== "number";
|
|
52931
|
+
});
|
|
52932
|
+
const actualValues = actualKeys.map((key) => object2[key]);
|
|
52933
|
+
const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
|
|
52934
|
+
return {
|
|
52935
|
+
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
52936
|
+
enum: actualValues
|
|
52937
|
+
};
|
|
52938
|
+
}
|
|
52939
|
+
function parseNeverDef2() {
|
|
52940
|
+
return { not: parseAnyDef2() };
|
|
52941
|
+
}
|
|
52942
|
+
function parseNullDef2() {
|
|
52943
|
+
return {
|
|
52944
|
+
type: "null"
|
|
52945
|
+
};
|
|
52946
|
+
}
|
|
52947
|
+
var primitiveMappings2 = {
|
|
52948
|
+
ZodString: "string",
|
|
52949
|
+
ZodNumber: "number",
|
|
52950
|
+
ZodBigInt: "integer",
|
|
52951
|
+
ZodBoolean: "boolean",
|
|
52952
|
+
ZodNull: "null"
|
|
52953
|
+
};
|
|
52954
|
+
function parseUnionDef2(def, refs) {
|
|
52955
|
+
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
52956
|
+
if (options.every((x) => (x._def.typeName in primitiveMappings2) && (!x._def.checks || !x._def.checks.length))) {
|
|
52957
|
+
const types = options.reduce((types2, x) => {
|
|
52958
|
+
const type = primitiveMappings2[x._def.typeName];
|
|
52959
|
+
return type && !types2.includes(type) ? [...types2, type] : types2;
|
|
52960
|
+
}, []);
|
|
52961
|
+
return {
|
|
52962
|
+
type: types.length > 1 ? types : types[0]
|
|
52963
|
+
};
|
|
52964
|
+
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
52965
|
+
const types = options.reduce((acc, x) => {
|
|
52966
|
+
const type = typeof x._def.value;
|
|
52967
|
+
switch (type) {
|
|
52968
|
+
case "string":
|
|
52969
|
+
case "number":
|
|
52970
|
+
case "boolean":
|
|
52971
|
+
return [...acc, type];
|
|
52972
|
+
case "bigint":
|
|
52973
|
+
return [...acc, "integer"];
|
|
52974
|
+
case "object":
|
|
52975
|
+
if (x._def.value === null)
|
|
52976
|
+
return [...acc, "null"];
|
|
52977
|
+
case "symbol":
|
|
52978
|
+
case "undefined":
|
|
52979
|
+
case "function":
|
|
52980
|
+
default:
|
|
52981
|
+
return acc;
|
|
52982
|
+
}
|
|
52983
|
+
}, []);
|
|
52984
|
+
if (types.length === options.length) {
|
|
52985
|
+
const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
|
|
52986
|
+
return {
|
|
52987
|
+
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
52988
|
+
enum: options.reduce((acc, x) => {
|
|
52989
|
+
return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
|
|
52990
|
+
}, [])
|
|
52991
|
+
};
|
|
52992
|
+
}
|
|
52993
|
+
} else if (options.every((x) => x._def.typeName === "ZodEnum")) {
|
|
52994
|
+
return {
|
|
52995
|
+
type: "string",
|
|
52996
|
+
enum: options.reduce((acc, x) => [
|
|
52997
|
+
...acc,
|
|
52998
|
+
...x._def.values.filter((x2) => !acc.includes(x2))
|
|
52999
|
+
], [])
|
|
53000
|
+
};
|
|
53001
|
+
}
|
|
53002
|
+
return asAnyOf2(def, refs);
|
|
53003
|
+
}
|
|
53004
|
+
var asAnyOf2 = (def, refs) => {
|
|
53005
|
+
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef2(x._def, {
|
|
53006
|
+
...refs,
|
|
53007
|
+
currentPath: [...refs.currentPath, "anyOf", `${i}`]
|
|
53008
|
+
})).filter((x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0));
|
|
53009
|
+
return anyOf.length ? { anyOf } : undefined;
|
|
53010
|
+
};
|
|
53011
|
+
function parseNullableDef2(def, refs) {
|
|
53012
|
+
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
53013
|
+
return {
|
|
53014
|
+
type: [
|
|
53015
|
+
primitiveMappings2[def.innerType._def.typeName],
|
|
53016
|
+
"null"
|
|
53017
|
+
]
|
|
53018
|
+
};
|
|
53019
|
+
}
|
|
53020
|
+
const base = parseDef2(def.innerType._def, {
|
|
53021
|
+
...refs,
|
|
53022
|
+
currentPath: [...refs.currentPath, "anyOf", "0"]
|
|
53023
|
+
});
|
|
53024
|
+
return base && { anyOf: [base, { type: "null" }] };
|
|
53025
|
+
}
|
|
53026
|
+
function parseNumberDef2(def) {
|
|
53027
|
+
const res = {
|
|
53028
|
+
type: "number"
|
|
53029
|
+
};
|
|
53030
|
+
if (!def.checks)
|
|
53031
|
+
return res;
|
|
53032
|
+
for (const check2 of def.checks) {
|
|
53033
|
+
switch (check2.kind) {
|
|
53034
|
+
case "int":
|
|
53035
|
+
res.type = "integer";
|
|
53036
|
+
break;
|
|
53037
|
+
case "min":
|
|
53038
|
+
if (check2.inclusive) {
|
|
53039
|
+
res.minimum = check2.value;
|
|
53040
|
+
} else {
|
|
53041
|
+
res.exclusiveMinimum = check2.value;
|
|
53042
|
+
}
|
|
53043
|
+
break;
|
|
53044
|
+
case "max":
|
|
53045
|
+
if (check2.inclusive) {
|
|
53046
|
+
res.maximum = check2.value;
|
|
53047
|
+
} else {
|
|
53048
|
+
res.exclusiveMaximum = check2.value;
|
|
53049
|
+
}
|
|
53050
|
+
break;
|
|
53051
|
+
case "multipleOf":
|
|
53052
|
+
res.multipleOf = check2.value;
|
|
53053
|
+
break;
|
|
53054
|
+
}
|
|
53055
|
+
}
|
|
53056
|
+
return res;
|
|
53057
|
+
}
|
|
53058
|
+
function parseObjectDef2(def, refs) {
|
|
53059
|
+
const result = {
|
|
53060
|
+
type: "object",
|
|
53061
|
+
properties: {}
|
|
53062
|
+
};
|
|
53063
|
+
const required2 = [];
|
|
53064
|
+
const shape = def.shape();
|
|
53065
|
+
for (const propName in shape) {
|
|
53066
|
+
let propDef = shape[propName];
|
|
53067
|
+
if (propDef === undefined || propDef._def === undefined) {
|
|
53068
|
+
continue;
|
|
53069
|
+
}
|
|
53070
|
+
const propOptional = safeIsOptional2(propDef);
|
|
53071
|
+
const parsedDef = parseDef2(propDef._def, {
|
|
53072
|
+
...refs,
|
|
53073
|
+
currentPath: [...refs.currentPath, "properties", propName],
|
|
53074
|
+
propertyPath: [...refs.currentPath, "properties", propName]
|
|
53075
|
+
});
|
|
53076
|
+
if (parsedDef === undefined) {
|
|
53077
|
+
continue;
|
|
53078
|
+
}
|
|
53079
|
+
result.properties[propName] = parsedDef;
|
|
53080
|
+
if (!propOptional) {
|
|
53081
|
+
required2.push(propName);
|
|
53082
|
+
}
|
|
53083
|
+
}
|
|
53084
|
+
if (required2.length) {
|
|
53085
|
+
result.required = required2;
|
|
53086
|
+
}
|
|
53087
|
+
const additionalProperties = decideAdditionalProperties2(def, refs);
|
|
53088
|
+
if (additionalProperties !== undefined) {
|
|
53089
|
+
result.additionalProperties = additionalProperties;
|
|
53090
|
+
}
|
|
53091
|
+
return result;
|
|
53092
|
+
}
|
|
53093
|
+
function decideAdditionalProperties2(def, refs) {
|
|
53094
|
+
if (def.catchall._def.typeName !== "ZodNever") {
|
|
53095
|
+
return parseDef2(def.catchall._def, {
|
|
53096
|
+
...refs,
|
|
53097
|
+
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
53098
|
+
});
|
|
53099
|
+
}
|
|
53100
|
+
switch (def.unknownKeys) {
|
|
53101
|
+
case "passthrough":
|
|
53102
|
+
return refs.allowedAdditionalProperties;
|
|
53103
|
+
case "strict":
|
|
53104
|
+
return refs.rejectedAdditionalProperties;
|
|
53105
|
+
case "strip":
|
|
53106
|
+
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
53107
|
+
}
|
|
53108
|
+
}
|
|
53109
|
+
function safeIsOptional2(schema) {
|
|
53110
|
+
try {
|
|
53111
|
+
return schema.isOptional();
|
|
53112
|
+
} catch (e) {
|
|
53113
|
+
return true;
|
|
53114
|
+
}
|
|
53115
|
+
}
|
|
53116
|
+
var parseOptionalDef2 = (def, refs) => {
|
|
53117
|
+
var _a23;
|
|
53118
|
+
if (refs.currentPath.toString() === ((_a23 = refs.propertyPath) == null ? undefined : _a23.toString())) {
|
|
53119
|
+
return parseDef2(def.innerType._def, refs);
|
|
53120
|
+
}
|
|
53121
|
+
const innerSchema = parseDef2(def.innerType._def, {
|
|
53122
|
+
...refs,
|
|
53123
|
+
currentPath: [...refs.currentPath, "anyOf", "1"]
|
|
53124
|
+
});
|
|
53125
|
+
return innerSchema ? { anyOf: [{ not: parseAnyDef2() }, innerSchema] } : parseAnyDef2();
|
|
53126
|
+
};
|
|
53127
|
+
var parsePipelineDef2 = (def, refs) => {
|
|
53128
|
+
if (refs.pipeStrategy === "input") {
|
|
53129
|
+
return parseDef2(def.in._def, refs);
|
|
53130
|
+
} else if (refs.pipeStrategy === "output") {
|
|
53131
|
+
return parseDef2(def.out._def, refs);
|
|
53132
|
+
}
|
|
53133
|
+
const a = parseDef2(def.in._def, {
|
|
53134
|
+
...refs,
|
|
53135
|
+
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
53136
|
+
});
|
|
53137
|
+
const b = parseDef2(def.out._def, {
|
|
53138
|
+
...refs,
|
|
53139
|
+
currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
|
|
53140
|
+
});
|
|
53141
|
+
return {
|
|
53142
|
+
allOf: [a, b].filter((x) => x !== undefined)
|
|
53143
|
+
};
|
|
53144
|
+
};
|
|
53145
|
+
function parsePromiseDef2(def, refs) {
|
|
53146
|
+
return parseDef2(def.type._def, refs);
|
|
53147
|
+
}
|
|
53148
|
+
function parseSetDef2(def, refs) {
|
|
53149
|
+
const items = parseDef2(def.valueType._def, {
|
|
53150
|
+
...refs,
|
|
53151
|
+
currentPath: [...refs.currentPath, "items"]
|
|
53152
|
+
});
|
|
53153
|
+
const schema = {
|
|
53154
|
+
type: "array",
|
|
53155
|
+
uniqueItems: true,
|
|
53156
|
+
items
|
|
53157
|
+
};
|
|
53158
|
+
if (def.minSize) {
|
|
53159
|
+
schema.minItems = def.minSize.value;
|
|
53160
|
+
}
|
|
53161
|
+
if (def.maxSize) {
|
|
53162
|
+
schema.maxItems = def.maxSize.value;
|
|
53163
|
+
}
|
|
53164
|
+
return schema;
|
|
53165
|
+
}
|
|
53166
|
+
function parseTupleDef2(def, refs) {
|
|
53167
|
+
if (def.rest) {
|
|
53168
|
+
return {
|
|
53169
|
+
type: "array",
|
|
53170
|
+
minItems: def.items.length,
|
|
53171
|
+
items: def.items.map((x, i) => parseDef2(x._def, {
|
|
53172
|
+
...refs,
|
|
53173
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
53174
|
+
})).reduce((acc, x) => x === undefined ? acc : [...acc, x], []),
|
|
53175
|
+
additionalItems: parseDef2(def.rest._def, {
|
|
53176
|
+
...refs,
|
|
53177
|
+
currentPath: [...refs.currentPath, "additionalItems"]
|
|
53178
|
+
})
|
|
53179
|
+
};
|
|
53180
|
+
} else {
|
|
53181
|
+
return {
|
|
53182
|
+
type: "array",
|
|
53183
|
+
minItems: def.items.length,
|
|
53184
|
+
maxItems: def.items.length,
|
|
53185
|
+
items: def.items.map((x, i) => parseDef2(x._def, {
|
|
53186
|
+
...refs,
|
|
53187
|
+
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
53188
|
+
})).reduce((acc, x) => x === undefined ? acc : [...acc, x], [])
|
|
53189
|
+
};
|
|
53190
|
+
}
|
|
53191
|
+
}
|
|
53192
|
+
function parseUndefinedDef2() {
|
|
53193
|
+
return {
|
|
53194
|
+
not: parseAnyDef2()
|
|
53195
|
+
};
|
|
53196
|
+
}
|
|
53197
|
+
function parseUnknownDef2() {
|
|
53198
|
+
return parseAnyDef2();
|
|
53199
|
+
}
|
|
53200
|
+
var parseReadonlyDef2 = (def, refs) => {
|
|
53201
|
+
return parseDef2(def.innerType._def, refs);
|
|
53202
|
+
};
|
|
53203
|
+
var selectParser2 = (def, typeName, refs) => {
|
|
53204
|
+
switch (typeName) {
|
|
53205
|
+
case ZodFirstPartyTypeKind2.ZodString:
|
|
53206
|
+
return parseStringDef2(def, refs);
|
|
53207
|
+
case ZodFirstPartyTypeKind2.ZodNumber:
|
|
53208
|
+
return parseNumberDef2(def);
|
|
53209
|
+
case ZodFirstPartyTypeKind2.ZodObject:
|
|
53210
|
+
return parseObjectDef2(def, refs);
|
|
53211
|
+
case ZodFirstPartyTypeKind2.ZodBigInt:
|
|
53212
|
+
return parseBigintDef2(def);
|
|
53213
|
+
case ZodFirstPartyTypeKind2.ZodBoolean:
|
|
53214
|
+
return parseBooleanDef2();
|
|
53215
|
+
case ZodFirstPartyTypeKind2.ZodDate:
|
|
53216
|
+
return parseDateDef2(def, refs);
|
|
53217
|
+
case ZodFirstPartyTypeKind2.ZodUndefined:
|
|
53218
|
+
return parseUndefinedDef2();
|
|
53219
|
+
case ZodFirstPartyTypeKind2.ZodNull:
|
|
53220
|
+
return parseNullDef2();
|
|
53221
|
+
case ZodFirstPartyTypeKind2.ZodArray:
|
|
53222
|
+
return parseArrayDef2(def, refs);
|
|
53223
|
+
case ZodFirstPartyTypeKind2.ZodUnion:
|
|
53224
|
+
case ZodFirstPartyTypeKind2.ZodDiscriminatedUnion:
|
|
53225
|
+
return parseUnionDef2(def, refs);
|
|
53226
|
+
case ZodFirstPartyTypeKind2.ZodIntersection:
|
|
53227
|
+
return parseIntersectionDef2(def, refs);
|
|
53228
|
+
case ZodFirstPartyTypeKind2.ZodTuple:
|
|
53229
|
+
return parseTupleDef2(def, refs);
|
|
53230
|
+
case ZodFirstPartyTypeKind2.ZodRecord:
|
|
53231
|
+
return parseRecordDef2(def, refs);
|
|
53232
|
+
case ZodFirstPartyTypeKind2.ZodLiteral:
|
|
53233
|
+
return parseLiteralDef2(def);
|
|
53234
|
+
case ZodFirstPartyTypeKind2.ZodEnum:
|
|
53235
|
+
return parseEnumDef2(def);
|
|
53236
|
+
case ZodFirstPartyTypeKind2.ZodNativeEnum:
|
|
53237
|
+
return parseNativeEnumDef2(def);
|
|
53238
|
+
case ZodFirstPartyTypeKind2.ZodNullable:
|
|
53239
|
+
return parseNullableDef2(def, refs);
|
|
53240
|
+
case ZodFirstPartyTypeKind2.ZodOptional:
|
|
53241
|
+
return parseOptionalDef2(def, refs);
|
|
53242
|
+
case ZodFirstPartyTypeKind2.ZodMap:
|
|
53243
|
+
return parseMapDef2(def, refs);
|
|
53244
|
+
case ZodFirstPartyTypeKind2.ZodSet:
|
|
53245
|
+
return parseSetDef2(def, refs);
|
|
53246
|
+
case ZodFirstPartyTypeKind2.ZodLazy:
|
|
53247
|
+
return () => def.getter()._def;
|
|
53248
|
+
case ZodFirstPartyTypeKind2.ZodPromise:
|
|
53249
|
+
return parsePromiseDef2(def, refs);
|
|
53250
|
+
case ZodFirstPartyTypeKind2.ZodNaN:
|
|
53251
|
+
case ZodFirstPartyTypeKind2.ZodNever:
|
|
53252
|
+
return parseNeverDef2();
|
|
53253
|
+
case ZodFirstPartyTypeKind2.ZodEffects:
|
|
53254
|
+
return parseEffectsDef2(def, refs);
|
|
53255
|
+
case ZodFirstPartyTypeKind2.ZodAny:
|
|
53256
|
+
return parseAnyDef2();
|
|
53257
|
+
case ZodFirstPartyTypeKind2.ZodUnknown:
|
|
53258
|
+
return parseUnknownDef2();
|
|
53259
|
+
case ZodFirstPartyTypeKind2.ZodDefault:
|
|
53260
|
+
return parseDefaultDef2(def, refs);
|
|
53261
|
+
case ZodFirstPartyTypeKind2.ZodBranded:
|
|
53262
|
+
return parseBrandedDef2(def, refs);
|
|
53263
|
+
case ZodFirstPartyTypeKind2.ZodReadonly:
|
|
53264
|
+
return parseReadonlyDef2(def, refs);
|
|
53265
|
+
case ZodFirstPartyTypeKind2.ZodCatch:
|
|
53266
|
+
return parseCatchDef2(def, refs);
|
|
53267
|
+
case ZodFirstPartyTypeKind2.ZodPipeline:
|
|
53268
|
+
return parsePipelineDef2(def, refs);
|
|
53269
|
+
case ZodFirstPartyTypeKind2.ZodFunction:
|
|
53270
|
+
case ZodFirstPartyTypeKind2.ZodVoid:
|
|
53271
|
+
case ZodFirstPartyTypeKind2.ZodSymbol:
|
|
53272
|
+
return;
|
|
53273
|
+
default:
|
|
53274
|
+
return /* @__PURE__ */ ((_) => {
|
|
53275
|
+
return;
|
|
53276
|
+
})(typeName);
|
|
53277
|
+
}
|
|
53278
|
+
};
|
|
53279
|
+
var getRelativePath2 = (pathA, pathB) => {
|
|
53280
|
+
let i = 0;
|
|
53281
|
+
for (;i < pathA.length && i < pathB.length; i++) {
|
|
53282
|
+
if (pathA[i] !== pathB[i])
|
|
53283
|
+
break;
|
|
53284
|
+
}
|
|
53285
|
+
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
53286
|
+
};
|
|
53287
|
+
function parseDef2(def, refs, forceResolution = false) {
|
|
53288
|
+
var _a23;
|
|
53289
|
+
const seenItem = refs.seen.get(def);
|
|
53290
|
+
if (refs.override) {
|
|
53291
|
+
const overrideResult = (_a23 = refs.override) == null ? undefined : _a23.call(refs, def, refs, seenItem, forceResolution);
|
|
53292
|
+
if (overrideResult !== ignoreOverride2) {
|
|
53293
|
+
return overrideResult;
|
|
53294
|
+
}
|
|
53295
|
+
}
|
|
53296
|
+
if (seenItem && !forceResolution) {
|
|
53297
|
+
const seenSchema = get$ref2(seenItem, refs);
|
|
53298
|
+
if (seenSchema !== undefined) {
|
|
53299
|
+
return seenSchema;
|
|
53300
|
+
}
|
|
53301
|
+
}
|
|
53302
|
+
const newItem = { def, path: refs.currentPath, jsonSchema: undefined };
|
|
53303
|
+
refs.seen.set(def, newItem);
|
|
53304
|
+
const jsonSchemaOrGetter = selectParser2(def, def.typeName, refs);
|
|
53305
|
+
const jsonSchema2 = typeof jsonSchemaOrGetter === "function" ? parseDef2(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
53306
|
+
if (jsonSchema2) {
|
|
53307
|
+
addMeta2(def, refs, jsonSchema2);
|
|
53308
|
+
}
|
|
53309
|
+
if (refs.postProcess) {
|
|
53310
|
+
const postProcessResult = refs.postProcess(jsonSchema2, def, refs);
|
|
53311
|
+
newItem.jsonSchema = jsonSchema2;
|
|
53312
|
+
return postProcessResult;
|
|
53313
|
+
}
|
|
53314
|
+
newItem.jsonSchema = jsonSchema2;
|
|
53315
|
+
return jsonSchema2;
|
|
53316
|
+
}
|
|
53317
|
+
var get$ref2 = (item, refs) => {
|
|
53318
|
+
switch (refs.$refStrategy) {
|
|
53319
|
+
case "root":
|
|
53320
|
+
return { $ref: item.path.join("/") };
|
|
53321
|
+
case "relative":
|
|
53322
|
+
return { $ref: getRelativePath2(refs.currentPath, item.path) };
|
|
53323
|
+
case "none":
|
|
53324
|
+
case "seen": {
|
|
53325
|
+
if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
|
|
53326
|
+
console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
|
|
53327
|
+
return parseAnyDef2();
|
|
53328
|
+
}
|
|
53329
|
+
return refs.$refStrategy === "seen" ? parseAnyDef2() : undefined;
|
|
53330
|
+
}
|
|
53331
|
+
}
|
|
53332
|
+
};
|
|
53333
|
+
var addMeta2 = (def, refs, jsonSchema2) => {
|
|
53334
|
+
if (def.description) {
|
|
53335
|
+
jsonSchema2.description = def.description;
|
|
53336
|
+
}
|
|
53337
|
+
return jsonSchema2;
|
|
53338
|
+
};
|
|
53339
|
+
var getRefs2 = (options) => {
|
|
53340
|
+
const _options = getDefaultOptions2(options);
|
|
53341
|
+
const currentPath = _options.name !== undefined ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
|
|
53342
|
+
return {
|
|
53343
|
+
..._options,
|
|
53344
|
+
currentPath,
|
|
53345
|
+
propertyPath: undefined,
|
|
53346
|
+
seen: new Map(Object.entries(_options.definitions).map(([name22, def]) => [
|
|
53347
|
+
def._def,
|
|
53348
|
+
{
|
|
53349
|
+
def: def._def,
|
|
53350
|
+
path: [..._options.basePath, _options.definitionPath, name22],
|
|
53351
|
+
jsonSchema: undefined
|
|
53352
|
+
}
|
|
53353
|
+
]))
|
|
53354
|
+
};
|
|
53355
|
+
};
|
|
53356
|
+
var zod3ToJsonSchema2 = (schema, options) => {
|
|
53357
|
+
var _a23;
|
|
53358
|
+
const refs = getRefs2(options);
|
|
53359
|
+
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name32, schema2]) => {
|
|
53360
|
+
var _a32;
|
|
53361
|
+
return {
|
|
53362
|
+
...acc,
|
|
53363
|
+
[name32]: (_a32 = parseDef2(schema2._def, {
|
|
53364
|
+
...refs,
|
|
53365
|
+
currentPath: [...refs.basePath, refs.definitionPath, name32]
|
|
53366
|
+
}, true)) != null ? _a32 : parseAnyDef2()
|
|
53367
|
+
};
|
|
53368
|
+
}, {}) : undefined;
|
|
53369
|
+
const name22 = typeof options === "string" ? options : (options == null ? undefined : options.nameStrategy) === "title" ? undefined : options == null ? undefined : options.name;
|
|
53370
|
+
const main = (_a23 = parseDef2(schema._def, name22 === undefined ? refs : {
|
|
53371
|
+
...refs,
|
|
53372
|
+
currentPath: [...refs.basePath, refs.definitionPath, name22]
|
|
53373
|
+
}, false)) != null ? _a23 : parseAnyDef2();
|
|
53374
|
+
const title = typeof options === "object" && options.name !== undefined && options.nameStrategy === "title" ? options.name : undefined;
|
|
53375
|
+
if (title !== undefined) {
|
|
53376
|
+
main.title = title;
|
|
53377
|
+
}
|
|
53378
|
+
const combined = name22 === undefined ? definitions ? {
|
|
53379
|
+
...main,
|
|
53380
|
+
[refs.definitionPath]: definitions
|
|
53381
|
+
} : main : {
|
|
53382
|
+
$ref: [
|
|
53383
|
+
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
53384
|
+
refs.definitionPath,
|
|
53385
|
+
name22
|
|
53386
|
+
].join("/"),
|
|
53387
|
+
[refs.definitionPath]: {
|
|
53388
|
+
...definitions,
|
|
53389
|
+
[name22]: main
|
|
53390
|
+
}
|
|
53391
|
+
};
|
|
53392
|
+
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
53393
|
+
return combined;
|
|
53394
|
+
};
|
|
53395
|
+
var schemaSymbol2 = Symbol.for("vercel.ai.schema");
|
|
53396
|
+
function jsonSchema2(jsonSchema22, {
|
|
53397
|
+
validate
|
|
53398
|
+
} = {}) {
|
|
53399
|
+
return {
|
|
53400
|
+
[schemaSymbol2]: true,
|
|
53401
|
+
_type: undefined,
|
|
53402
|
+
get jsonSchema() {
|
|
53403
|
+
if (typeof jsonSchema22 === "function") {
|
|
53404
|
+
jsonSchema22 = jsonSchema22();
|
|
53405
|
+
}
|
|
53406
|
+
return jsonSchema22;
|
|
53407
|
+
},
|
|
53408
|
+
validate
|
|
53409
|
+
};
|
|
53410
|
+
}
|
|
53411
|
+
function isSchema2(value) {
|
|
53412
|
+
return typeof value === "object" && value !== null && schemaSymbol2 in value && value[schemaSymbol2] === true && "jsonSchema" in value && "validate" in value;
|
|
53413
|
+
}
|
|
53414
|
+
function asSchema2(schema) {
|
|
53415
|
+
return schema == null ? jsonSchema2({ properties: {}, additionalProperties: false }) : isSchema2(schema) ? schema : ("~standard" in schema) ? schema["~standard"].vendor === "zod" ? zodSchema2(schema) : standardSchema2(schema) : schema();
|
|
53416
|
+
}
|
|
53417
|
+
function standardSchema2(standardSchema22) {
|
|
53418
|
+
return jsonSchema2(() => addAdditionalPropertiesToJsonSchema2(standardSchema22["~standard"].jsonSchema.input({
|
|
53419
|
+
target: "draft-07"
|
|
53420
|
+
})), {
|
|
53421
|
+
validate: async (value) => {
|
|
53422
|
+
const result = await standardSchema22["~standard"].validate(value);
|
|
53423
|
+
return "value" in result ? { success: true, value: result.value } : {
|
|
53424
|
+
success: false,
|
|
53425
|
+
error: new TypeValidationError({
|
|
53426
|
+
value,
|
|
53427
|
+
cause: result.issues
|
|
53428
|
+
})
|
|
53429
|
+
};
|
|
53430
|
+
}
|
|
53431
|
+
});
|
|
53432
|
+
}
|
|
53433
|
+
function zod3Schema2(zodSchema2, options) {
|
|
53434
|
+
var _a23;
|
|
53435
|
+
const useReferences = (_a23 = options == null ? undefined : options.useReferences) != null ? _a23 : false;
|
|
53436
|
+
return jsonSchema2(() => zod3ToJsonSchema2(zodSchema2, {
|
|
53437
|
+
$refStrategy: useReferences ? "root" : "none"
|
|
53438
|
+
}), {
|
|
53439
|
+
validate: async (value) => {
|
|
53440
|
+
const result = await zodSchema2.safeParseAsync(value);
|
|
53441
|
+
return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
|
|
53442
|
+
}
|
|
53443
|
+
});
|
|
53444
|
+
}
|
|
53445
|
+
function zod4Schema2(zodSchema2, options) {
|
|
53446
|
+
var _a23;
|
|
53447
|
+
const useReferences = (_a23 = options == null ? undefined : options.useReferences) != null ? _a23 : false;
|
|
53448
|
+
return jsonSchema2(() => addAdditionalPropertiesToJsonSchema2(toJSONSchema(zodSchema2, {
|
|
53449
|
+
target: "draft-7",
|
|
53450
|
+
io: "input",
|
|
53451
|
+
reused: useReferences ? "ref" : "inline"
|
|
53452
|
+
})), {
|
|
53453
|
+
validate: async (value) => {
|
|
53454
|
+
const result = await safeParseAsync2(zodSchema2, value);
|
|
53455
|
+
return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
|
|
53456
|
+
}
|
|
53457
|
+
});
|
|
53458
|
+
}
|
|
53459
|
+
function isZod4Schema2(zodSchema2) {
|
|
53460
|
+
return "_zod" in zodSchema2;
|
|
53461
|
+
}
|
|
53462
|
+
function zodSchema2(zodSchema22, options) {
|
|
53463
|
+
if (isZod4Schema2(zodSchema22)) {
|
|
53464
|
+
return zod4Schema2(zodSchema22, options);
|
|
53465
|
+
} else {
|
|
53466
|
+
return zod3Schema2(zodSchema22, options);
|
|
53467
|
+
}
|
|
53468
|
+
}
|
|
53469
|
+
async function validateTypes2({
|
|
53470
|
+
value,
|
|
53471
|
+
schema,
|
|
53472
|
+
context
|
|
53473
|
+
}) {
|
|
53474
|
+
const result = await safeValidateTypes2({ value, schema, context });
|
|
53475
|
+
if (!result.success) {
|
|
53476
|
+
throw TypeValidationError.wrap({ value, cause: result.error, context });
|
|
53477
|
+
}
|
|
53478
|
+
return result.value;
|
|
53479
|
+
}
|
|
53480
|
+
async function safeValidateTypes2({
|
|
53481
|
+
value,
|
|
53482
|
+
schema,
|
|
53483
|
+
context
|
|
53484
|
+
}) {
|
|
53485
|
+
const actualSchema = asSchema2(schema);
|
|
53486
|
+
try {
|
|
53487
|
+
if (actualSchema.validate == null) {
|
|
53488
|
+
return { success: true, value, rawValue: value };
|
|
53489
|
+
}
|
|
53490
|
+
const result = await actualSchema.validate(value);
|
|
53491
|
+
if (result.success) {
|
|
53492
|
+
return { success: true, value: result.value, rawValue: value };
|
|
53493
|
+
}
|
|
53494
|
+
return {
|
|
53495
|
+
success: false,
|
|
53496
|
+
error: TypeValidationError.wrap({ value, cause: result.error, context }),
|
|
53497
|
+
rawValue: value
|
|
53498
|
+
};
|
|
53499
|
+
} catch (error48) {
|
|
53500
|
+
return {
|
|
53501
|
+
success: false,
|
|
53502
|
+
error: TypeValidationError.wrap({ value, cause: error48, context }),
|
|
53503
|
+
rawValue: value
|
|
53504
|
+
};
|
|
53505
|
+
}
|
|
53506
|
+
}
|
|
53507
|
+
async function parseJSON2({
|
|
53508
|
+
text,
|
|
53509
|
+
schema
|
|
53510
|
+
}) {
|
|
53511
|
+
try {
|
|
53512
|
+
const value = secureJsonParse2(text);
|
|
53513
|
+
if (schema == null) {
|
|
53514
|
+
return value;
|
|
53515
|
+
}
|
|
53516
|
+
return validateTypes2({ value, schema });
|
|
53517
|
+
} catch (error48) {
|
|
53518
|
+
if (JSONParseError.isInstance(error48) || TypeValidationError.isInstance(error48)) {
|
|
53519
|
+
throw error48;
|
|
53520
|
+
}
|
|
53521
|
+
throw new JSONParseError({ text, cause: error48 });
|
|
53522
|
+
}
|
|
53523
|
+
}
|
|
53524
|
+
async function safeParseJSON2({
|
|
53525
|
+
text,
|
|
53526
|
+
schema
|
|
53527
|
+
}) {
|
|
53528
|
+
try {
|
|
53529
|
+
const value = secureJsonParse2(text);
|
|
53530
|
+
if (schema == null) {
|
|
53531
|
+
return { success: true, value, rawValue: value };
|
|
53532
|
+
}
|
|
53533
|
+
return await safeValidateTypes2({ value, schema });
|
|
53534
|
+
} catch (error48) {
|
|
53535
|
+
return {
|
|
53536
|
+
success: false,
|
|
53537
|
+
error: JSONParseError.isInstance(error48) ? error48 : new JSONParseError({ text, cause: error48 }),
|
|
53538
|
+
rawValue: undefined
|
|
53539
|
+
};
|
|
53540
|
+
}
|
|
53541
|
+
}
|
|
53542
|
+
async function parseProviderOptions2({
|
|
53543
|
+
provider,
|
|
53544
|
+
providerOptions,
|
|
53545
|
+
schema
|
|
53546
|
+
}) {
|
|
53547
|
+
if ((providerOptions == null ? undefined : providerOptions[provider]) == null) {
|
|
53548
|
+
return;
|
|
53549
|
+
}
|
|
53550
|
+
const parsedProviderOptions = await safeValidateTypes2({
|
|
53551
|
+
value: providerOptions[provider],
|
|
53552
|
+
schema
|
|
53553
|
+
});
|
|
53554
|
+
if (!parsedProviderOptions.success) {
|
|
53555
|
+
throw new InvalidArgumentError({
|
|
53556
|
+
argument: "providerOptions",
|
|
53557
|
+
message: `invalid ${provider} provider options`,
|
|
53558
|
+
cause: parsedProviderOptions.error
|
|
53559
|
+
});
|
|
53560
|
+
}
|
|
53561
|
+
return parsedProviderOptions.value;
|
|
53562
|
+
}
|
|
53563
|
+
var getOriginalFetch22 = () => globalThis.fetch;
|
|
53564
|
+
var postJsonToApi2 = async ({
|
|
53565
|
+
url: url2,
|
|
53566
|
+
headers,
|
|
53567
|
+
body,
|
|
53568
|
+
failedResponseHandler,
|
|
53569
|
+
successfulResponseHandler,
|
|
53570
|
+
abortSignal,
|
|
53571
|
+
fetch: fetch2
|
|
53572
|
+
}) => postToApi2({
|
|
53573
|
+
url: url2,
|
|
53574
|
+
headers: {
|
|
53575
|
+
"Content-Type": "application/json",
|
|
53576
|
+
...headers
|
|
53577
|
+
},
|
|
53578
|
+
body: {
|
|
53579
|
+
content: JSON.stringify(body),
|
|
53580
|
+
values: body
|
|
53581
|
+
},
|
|
53582
|
+
failedResponseHandler,
|
|
53583
|
+
successfulResponseHandler,
|
|
53584
|
+
abortSignal,
|
|
53585
|
+
fetch: fetch2
|
|
53586
|
+
});
|
|
53587
|
+
var postToApi2 = async ({
|
|
53588
|
+
url: url2,
|
|
53589
|
+
headers = {},
|
|
53590
|
+
body,
|
|
53591
|
+
successfulResponseHandler,
|
|
53592
|
+
failedResponseHandler,
|
|
53593
|
+
abortSignal,
|
|
53594
|
+
fetch: fetch2 = getOriginalFetch22()
|
|
53595
|
+
}) => {
|
|
53596
|
+
try {
|
|
53597
|
+
const response = await fetch2(url2, {
|
|
53598
|
+
method: "POST",
|
|
53599
|
+
headers: withUserAgentSuffix2(headers, `ai-sdk/provider-utils/${VERSION8}`, getRuntimeEnvironmentUserAgent2()),
|
|
53600
|
+
body: body.content,
|
|
53601
|
+
signal: abortSignal
|
|
53602
|
+
});
|
|
53603
|
+
const responseHeaders = extractResponseHeaders2(response);
|
|
53604
|
+
if (!response.ok) {
|
|
53605
|
+
let errorInformation;
|
|
53606
|
+
try {
|
|
53607
|
+
errorInformation = await failedResponseHandler({
|
|
53608
|
+
response,
|
|
53609
|
+
url: url2,
|
|
53610
|
+
requestBodyValues: body.values
|
|
53611
|
+
});
|
|
53612
|
+
} catch (error48) {
|
|
53613
|
+
if (isAbortError2(error48) || APICallError.isInstance(error48)) {
|
|
53614
|
+
throw error48;
|
|
53615
|
+
}
|
|
53616
|
+
throw new APICallError({
|
|
53617
|
+
message: "Failed to process error response",
|
|
53618
|
+
cause: error48,
|
|
53619
|
+
statusCode: response.status,
|
|
53620
|
+
url: url2,
|
|
53621
|
+
responseHeaders,
|
|
53622
|
+
requestBodyValues: body.values
|
|
53623
|
+
});
|
|
53624
|
+
}
|
|
53625
|
+
throw errorInformation.value;
|
|
53626
|
+
}
|
|
53627
|
+
try {
|
|
53628
|
+
return await successfulResponseHandler({
|
|
53629
|
+
response,
|
|
53630
|
+
url: url2,
|
|
53631
|
+
requestBodyValues: body.values
|
|
53632
|
+
});
|
|
53633
|
+
} catch (error48) {
|
|
53634
|
+
if (error48 instanceof Error) {
|
|
53635
|
+
if (isAbortError2(error48) || APICallError.isInstance(error48)) {
|
|
53636
|
+
throw error48;
|
|
53637
|
+
}
|
|
53638
|
+
}
|
|
53639
|
+
throw new APICallError({
|
|
53640
|
+
message: "Failed to process successful response",
|
|
53641
|
+
cause: error48,
|
|
53642
|
+
statusCode: response.status,
|
|
53643
|
+
url: url2,
|
|
53644
|
+
responseHeaders,
|
|
53645
|
+
requestBodyValues: body.values
|
|
53646
|
+
});
|
|
53647
|
+
}
|
|
53648
|
+
} catch (error48) {
|
|
53649
|
+
throw handleFetchError2({ error: error48, url: url2, requestBodyValues: body.values });
|
|
53650
|
+
}
|
|
53651
|
+
};
|
|
53652
|
+
var createJsonErrorResponseHandler2 = ({
|
|
53653
|
+
errorSchema,
|
|
53654
|
+
errorToMessage,
|
|
53655
|
+
isRetryable
|
|
53656
|
+
}) => async ({ response, url: url2, requestBodyValues }) => {
|
|
53657
|
+
const responseBody = await response.text();
|
|
53658
|
+
const responseHeaders = extractResponseHeaders2(response);
|
|
53659
|
+
if (responseBody.trim() === "") {
|
|
53660
|
+
return {
|
|
53661
|
+
responseHeaders,
|
|
53662
|
+
value: new APICallError({
|
|
53663
|
+
message: response.statusText,
|
|
53664
|
+
url: url2,
|
|
53665
|
+
requestBodyValues,
|
|
53666
|
+
statusCode: response.status,
|
|
53667
|
+
responseHeaders,
|
|
53668
|
+
responseBody,
|
|
53669
|
+
isRetryable: isRetryable == null ? undefined : isRetryable(response)
|
|
53670
|
+
})
|
|
53671
|
+
};
|
|
53672
|
+
}
|
|
53673
|
+
try {
|
|
53674
|
+
const parsedError = await parseJSON2({
|
|
53675
|
+
text: responseBody,
|
|
53676
|
+
schema: errorSchema
|
|
53677
|
+
});
|
|
53678
|
+
return {
|
|
53679
|
+
responseHeaders,
|
|
53680
|
+
value: new APICallError({
|
|
53681
|
+
message: errorToMessage(parsedError),
|
|
53682
|
+
url: url2,
|
|
53683
|
+
requestBodyValues,
|
|
53684
|
+
statusCode: response.status,
|
|
53685
|
+
responseHeaders,
|
|
53686
|
+
responseBody,
|
|
53687
|
+
data: parsedError,
|
|
53688
|
+
isRetryable: isRetryable == null ? undefined : isRetryable(response, parsedError)
|
|
53689
|
+
})
|
|
53690
|
+
};
|
|
53691
|
+
} catch (parseError) {
|
|
53692
|
+
return {
|
|
53693
|
+
responseHeaders,
|
|
53694
|
+
value: new APICallError({
|
|
53695
|
+
message: response.statusText,
|
|
53696
|
+
url: url2,
|
|
53697
|
+
requestBodyValues,
|
|
53698
|
+
statusCode: response.status,
|
|
53699
|
+
responseHeaders,
|
|
53700
|
+
responseBody,
|
|
53701
|
+
isRetryable: isRetryable == null ? undefined : isRetryable(response)
|
|
53702
|
+
})
|
|
53703
|
+
};
|
|
53704
|
+
}
|
|
53705
|
+
};
|
|
53706
|
+
var createJsonResponseHandler2 = (responseSchema2) => async ({ response, url: url2, requestBodyValues }) => {
|
|
53707
|
+
const responseBody = await response.text();
|
|
53708
|
+
const parsedResult = await safeParseJSON2({
|
|
53709
|
+
text: responseBody,
|
|
53710
|
+
schema: responseSchema2
|
|
53711
|
+
});
|
|
53712
|
+
const responseHeaders = extractResponseHeaders2(response);
|
|
53713
|
+
if (!parsedResult.success) {
|
|
53714
|
+
throw new APICallError({
|
|
53715
|
+
message: "Invalid JSON response",
|
|
53716
|
+
cause: parsedResult.error,
|
|
53717
|
+
statusCode: response.status,
|
|
53718
|
+
responseHeaders,
|
|
53719
|
+
responseBody,
|
|
53720
|
+
url: url2,
|
|
53721
|
+
requestBodyValues
|
|
53722
|
+
});
|
|
53723
|
+
}
|
|
53724
|
+
return {
|
|
53725
|
+
responseHeaders,
|
|
53726
|
+
value: parsedResult.value,
|
|
53727
|
+
rawValue: parsedResult.rawValue
|
|
53728
|
+
};
|
|
53729
|
+
};
|
|
53730
|
+
function withoutTrailingSlash2(url2) {
|
|
53731
|
+
return url2 == null ? undefined : url2.replace(/\/$/, "");
|
|
53732
|
+
}
|
|
53733
|
+
|
|
53734
|
+
// node_modules/ollama-ai-provider-v2/dist/index.mjs
|
|
53735
|
+
function convertToOllamaCompletionPrompt({
|
|
53736
|
+
prompt,
|
|
53737
|
+
user = "user",
|
|
53738
|
+
assistant = "assistant"
|
|
53739
|
+
}) {
|
|
53740
|
+
let text = "";
|
|
53741
|
+
if (prompt[0].role === "system") {
|
|
53742
|
+
text += `${prompt[0].content}
|
|
53743
|
+
|
|
53744
|
+
`;
|
|
53745
|
+
prompt = prompt.slice(1);
|
|
53746
|
+
}
|
|
53747
|
+
for (const { role, content } of prompt) {
|
|
53748
|
+
switch (role) {
|
|
53749
|
+
case "system": {
|
|
53750
|
+
throw new InvalidPromptError({
|
|
53751
|
+
message: "Unexpected system message in prompt: ${content}",
|
|
53752
|
+
prompt
|
|
53753
|
+
});
|
|
53754
|
+
}
|
|
53755
|
+
case "user": {
|
|
53756
|
+
const userMessage = content.map((part) => {
|
|
53757
|
+
switch (part.type) {
|
|
53758
|
+
case "text": {
|
|
53759
|
+
return part.text;
|
|
53760
|
+
}
|
|
53761
|
+
}
|
|
53762
|
+
}).filter(Boolean).join("");
|
|
53763
|
+
text += `${user}:
|
|
53764
|
+
${userMessage}
|
|
53765
|
+
|
|
53766
|
+
`;
|
|
53767
|
+
break;
|
|
53768
|
+
}
|
|
53769
|
+
case "assistant": {
|
|
53770
|
+
const assistantMessage = content.map((part) => {
|
|
53771
|
+
switch (part.type) {
|
|
53772
|
+
case "text": {
|
|
53773
|
+
return part.text;
|
|
53774
|
+
}
|
|
53775
|
+
case "tool-call": {
|
|
53776
|
+
throw new UnsupportedFunctionalityError({
|
|
53777
|
+
functionality: "tool-call messages"
|
|
53778
|
+
});
|
|
53779
|
+
}
|
|
53780
|
+
}
|
|
53781
|
+
}).join("");
|
|
53782
|
+
text += `${assistant}:
|
|
53783
|
+
${assistantMessage}
|
|
53784
|
+
|
|
53785
|
+
`;
|
|
53786
|
+
break;
|
|
53787
|
+
}
|
|
53788
|
+
case "tool": {
|
|
53789
|
+
throw new UnsupportedFunctionalityError({
|
|
53790
|
+
functionality: "tool messages"
|
|
53791
|
+
});
|
|
53792
|
+
}
|
|
53793
|
+
default: {
|
|
53794
|
+
const _exhaustiveCheck = role;
|
|
53795
|
+
throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
|
|
53796
|
+
}
|
|
53797
|
+
}
|
|
53798
|
+
}
|
|
53799
|
+
text += `${assistant}:
|
|
53800
|
+
`;
|
|
53801
|
+
return {
|
|
53802
|
+
prompt: text,
|
|
53803
|
+
stopSequences: [`
|
|
53804
|
+
${user}:`]
|
|
53805
|
+
};
|
|
53806
|
+
}
|
|
53807
|
+
function mapOllamaFinishReason(finishReason) {
|
|
53808
|
+
switch (finishReason) {
|
|
53809
|
+
case "stop":
|
|
53810
|
+
return {
|
|
53811
|
+
raw: finishReason,
|
|
53812
|
+
unified: "stop"
|
|
53813
|
+
};
|
|
53814
|
+
case "length":
|
|
53815
|
+
return {
|
|
53816
|
+
raw: finishReason,
|
|
53817
|
+
unified: "length"
|
|
53818
|
+
};
|
|
53819
|
+
case "content_filter":
|
|
53820
|
+
return {
|
|
53821
|
+
raw: finishReason,
|
|
53822
|
+
unified: "content-filter"
|
|
53823
|
+
};
|
|
53824
|
+
case "function_call":
|
|
53825
|
+
case "tool_calls":
|
|
53826
|
+
return {
|
|
53827
|
+
raw: finishReason,
|
|
53828
|
+
unified: "tool-calls"
|
|
53829
|
+
};
|
|
53830
|
+
default:
|
|
53831
|
+
return {
|
|
53832
|
+
raw: finishReason,
|
|
53833
|
+
unified: "other"
|
|
53834
|
+
};
|
|
53835
|
+
}
|
|
53836
|
+
}
|
|
53837
|
+
function getResponseMetadata5({
|
|
53838
|
+
model,
|
|
53839
|
+
created_at
|
|
53840
|
+
}) {
|
|
53841
|
+
return {
|
|
53842
|
+
id: undefined,
|
|
53843
|
+
modelId: model != null ? model : undefined,
|
|
53844
|
+
timestamp: created_at != null ? new Date(created_at) : undefined
|
|
53845
|
+
};
|
|
53846
|
+
}
|
|
53847
|
+
function createNdjsonStreamResponseHandler(schema) {
|
|
53848
|
+
return async ({ response }) => {
|
|
53849
|
+
const responseHeaders = extractResponseHeaders2(response);
|
|
53850
|
+
if (response.body == null) {
|
|
53851
|
+
throw new Error("Response body is null");
|
|
53852
|
+
}
|
|
53853
|
+
const reader = response.body.getReader();
|
|
53854
|
+
const decoder = new TextDecoder;
|
|
53855
|
+
let buffer = "";
|
|
53856
|
+
const stream = new ReadableStream({
|
|
53857
|
+
async pull(controller) {
|
|
53858
|
+
while (true) {
|
|
53859
|
+
const { done, value } = await reader.read();
|
|
53860
|
+
if (done) {
|
|
53861
|
+
if (buffer.trim()) {
|
|
53862
|
+
try {
|
|
53863
|
+
const parsed = JSON.parse(buffer.trim());
|
|
53864
|
+
const validated = schema.parse(parsed);
|
|
53865
|
+
controller.enqueue({ success: true, value: validated, rawValue: validated });
|
|
53866
|
+
} catch (e) {}
|
|
53867
|
+
}
|
|
53868
|
+
controller.close();
|
|
53869
|
+
return;
|
|
53870
|
+
}
|
|
53871
|
+
buffer += decoder.decode(value, { stream: true });
|
|
53872
|
+
const lines = buffer.split(`
|
|
53873
|
+
`);
|
|
53874
|
+
buffer = lines.pop() || "";
|
|
53875
|
+
for (const line of lines) {
|
|
53876
|
+
const trimmedLine = line.trim();
|
|
53877
|
+
if (trimmedLine) {
|
|
53878
|
+
try {
|
|
53879
|
+
const parsed = JSON.parse(trimmedLine);
|
|
53880
|
+
const validated = schema.parse(parsed);
|
|
53881
|
+
controller.enqueue({ success: true, value: validated, rawValue: validated });
|
|
53882
|
+
} catch (error48) {
|
|
53883
|
+
console.warn("Failed to parse NDJSON line:", error48);
|
|
53884
|
+
}
|
|
53885
|
+
}
|
|
53886
|
+
}
|
|
53887
|
+
}
|
|
53888
|
+
},
|
|
53889
|
+
cancel() {
|
|
53890
|
+
reader.cancel();
|
|
53891
|
+
}
|
|
53892
|
+
});
|
|
53893
|
+
return {
|
|
53894
|
+
responseHeaders,
|
|
53895
|
+
value: stream
|
|
53896
|
+
};
|
|
53897
|
+
};
|
|
53898
|
+
}
|
|
53899
|
+
var ollamaErrorDataSchema = exports_external.object({
|
|
53900
|
+
error: exports_external.object({
|
|
53901
|
+
message: exports_external.string(),
|
|
53902
|
+
type: exports_external.string().nullish(),
|
|
53903
|
+
param: exports_external.any().nullish(),
|
|
53904
|
+
code: exports_external.union([exports_external.string(), exports_external.number()]).nullish()
|
|
53905
|
+
})
|
|
53906
|
+
});
|
|
53907
|
+
var ollamaFailedResponseHandler = createJsonErrorResponseHandler2({
|
|
53908
|
+
errorSchema: ollamaErrorDataSchema,
|
|
53909
|
+
errorToMessage: (data) => data.error.message
|
|
53910
|
+
});
|
|
53911
|
+
var ollamaCompletionProviderOptions = exports_external.object({
|
|
53912
|
+
think: exports_external.boolean().optional(),
|
|
53913
|
+
user: exports_external.string().optional(),
|
|
53914
|
+
suffix: exports_external.string().optional(),
|
|
53915
|
+
echo: exports_external.boolean().optional()
|
|
53916
|
+
});
|
|
53917
|
+
var OllamaCompletionLanguageModel = class {
|
|
53918
|
+
constructor(modelId, settings, config2) {
|
|
53919
|
+
this.specificationVersion = "v3";
|
|
53920
|
+
this.defaultObjectGenerationMode = undefined;
|
|
53921
|
+
this.supportsImageUrls = false;
|
|
53922
|
+
this.supportedUrls = {};
|
|
53923
|
+
this.modelId = modelId;
|
|
53924
|
+
this.settings = settings;
|
|
53925
|
+
this.config = config2;
|
|
53926
|
+
this.provider = config2.provider;
|
|
53927
|
+
}
|
|
53928
|
+
getArgs({
|
|
53929
|
+
prompt,
|
|
53930
|
+
maxOutputTokens,
|
|
53931
|
+
temperature,
|
|
52356
53932
|
topP,
|
|
52357
53933
|
topK,
|
|
52358
53934
|
frequencyPenalty,
|
|
@@ -52410,15 +53986,15 @@ var OllamaCompletionLanguageModel = class {
|
|
|
52410
53986
|
responseHeaders,
|
|
52411
53987
|
value: response,
|
|
52412
53988
|
rawValue: rawResponse
|
|
52413
|
-
} = await
|
|
53989
|
+
} = await postJsonToApi2({
|
|
52414
53990
|
url: this.config.url({
|
|
52415
53991
|
path: "/generate",
|
|
52416
53992
|
modelId: this.modelId
|
|
52417
53993
|
}),
|
|
52418
|
-
headers:
|
|
53994
|
+
headers: combineHeaders2(this.config.headers(), options.headers),
|
|
52419
53995
|
body: { ...body, stream: false },
|
|
52420
53996
|
failedResponseHandler: ollamaFailedResponseHandler,
|
|
52421
|
-
successfulResponseHandler:
|
|
53997
|
+
successfulResponseHandler: createJsonResponseHandler2(baseOllamaResponseSchema),
|
|
52422
53998
|
abortSignal: options.abortSignal,
|
|
52423
53999
|
fetch: this.config.fetch
|
|
52424
54000
|
});
|
|
@@ -52460,12 +54036,12 @@ var OllamaCompletionLanguageModel = class {
|
|
|
52460
54036
|
...args,
|
|
52461
54037
|
stream: true
|
|
52462
54038
|
};
|
|
52463
|
-
const { responseHeaders, value: response } = await
|
|
54039
|
+
const { responseHeaders, value: response } = await postJsonToApi2({
|
|
52464
54040
|
url: this.config.url({
|
|
52465
54041
|
path: "/generate",
|
|
52466
54042
|
modelId: this.modelId
|
|
52467
54043
|
}),
|
|
52468
|
-
headers:
|
|
54044
|
+
headers: combineHeaders2(this.config.headers(), options.headers),
|
|
52469
54045
|
body,
|
|
52470
54046
|
failedResponseHandler: ollamaFailedResponseHandler,
|
|
52471
54047
|
successfulResponseHandler: createNdjsonStreamResponseHandler(baseOllamaResponseSchema),
|
|
@@ -52489,7 +54065,7 @@ var OllamaCompletionLanguageModel = class {
|
|
|
52489
54065
|
};
|
|
52490
54066
|
let isFirstChunk = true;
|
|
52491
54067
|
let textStarted = false;
|
|
52492
|
-
const textId =
|
|
54068
|
+
const textId = generateId2();
|
|
52493
54069
|
return {
|
|
52494
54070
|
stream: response.pipeThrough(new TransformStream({
|
|
52495
54071
|
transform(chunk, controller) {
|
|
@@ -52603,7 +54179,7 @@ var OllamaEmbeddingModel = class {
|
|
|
52603
54179
|
values
|
|
52604
54180
|
});
|
|
52605
54181
|
}
|
|
52606
|
-
const ollamaOptions = await
|
|
54182
|
+
const ollamaOptions = await parseProviderOptions2({
|
|
52607
54183
|
provider: "ollama",
|
|
52608
54184
|
providerOptions,
|
|
52609
54185
|
schema: ollamaEmbeddingProviderOptions
|
|
@@ -52625,15 +54201,15 @@ var OllamaEmbeddingModel = class {
|
|
|
52625
54201
|
responseHeaders,
|
|
52626
54202
|
value: response,
|
|
52627
54203
|
rawValue
|
|
52628
|
-
} = await
|
|
54204
|
+
} = await postJsonToApi2({
|
|
52629
54205
|
url: this.config.url({
|
|
52630
54206
|
path: "/embed",
|
|
52631
54207
|
modelId: this.modelId
|
|
52632
54208
|
}),
|
|
52633
|
-
headers:
|
|
54209
|
+
headers: combineHeaders2(this.config.headers(), headers),
|
|
52634
54210
|
body: { ...body },
|
|
52635
54211
|
failedResponseHandler: ollamaFailedResponseHandler,
|
|
52636
|
-
successfulResponseHandler:
|
|
54212
|
+
successfulResponseHandler: createJsonResponseHandler2(ollamaTextEmbeddingResponseSchema),
|
|
52637
54213
|
abortSignal,
|
|
52638
54214
|
fetch: this.config.fetch
|
|
52639
54215
|
});
|
|
@@ -52713,7 +54289,7 @@ var OllamaResponseProcessor = class {
|
|
|
52713
54289
|
for (const toolCall of (_a16 = response.message.tool_calls) != null ? _a16 : []) {
|
|
52714
54290
|
content.push({
|
|
52715
54291
|
type: "tool-call",
|
|
52716
|
-
toolCallId: (_e = toolCall.id) != null ? _e : (_d = (_c = (_b16 = this.config).generateId) == null ? undefined : _c.call(_b16)) != null ? _d :
|
|
54292
|
+
toolCallId: (_e = toolCall.id) != null ? _e : (_d = (_c = (_b16 = this.config).generateId) == null ? undefined : _c.call(_b16)) != null ? _d : generateId2(),
|
|
52717
54293
|
toolName: toolCall.function.name,
|
|
52718
54294
|
input: JSON.stringify(toolCall.function.arguments)
|
|
52719
54295
|
});
|
|
@@ -53162,7 +54738,7 @@ var OllamaRequestBuilder = class {
|
|
|
53162
54738
|
return warnings;
|
|
53163
54739
|
}
|
|
53164
54740
|
async parseProviderOptions(providerOptions) {
|
|
53165
|
-
const result = await
|
|
54741
|
+
const result = await parseProviderOptions2({
|
|
53166
54742
|
provider: "ollama",
|
|
53167
54743
|
providerOptions,
|
|
53168
54744
|
schema: ollamaProviderOptions
|
|
@@ -53238,8 +54814,8 @@ var OllamaStreamProcessor = class {
|
|
|
53238
54814
|
hasReasoningStarted: false,
|
|
53239
54815
|
textEnded: false,
|
|
53240
54816
|
reasoningEnded: false,
|
|
53241
|
-
textId:
|
|
53242
|
-
reasoningId:
|
|
54817
|
+
textId: generateId2(),
|
|
54818
|
+
reasoningId: generateId2()
|
|
53243
54819
|
};
|
|
53244
54820
|
}
|
|
53245
54821
|
processChunk(chunk, controller, options) {
|
|
@@ -53350,7 +54926,7 @@ var OllamaStreamProcessor = class {
|
|
|
53350
54926
|
}
|
|
53351
54927
|
emitToolCall(toolCall, controller) {
|
|
53352
54928
|
var _a16, _b16, _c, _d;
|
|
53353
|
-
const id = (_d = toolCall.id) != null ? _d : (_c = (_b16 = (_a16 = this.config).generateId) == null ? undefined : _b16.call(_a16)) != null ? _c :
|
|
54929
|
+
const id = (_d = toolCall.id) != null ? _d : (_c = (_b16 = (_a16 = this.config).generateId) == null ? undefined : _b16.call(_a16)) != null ? _c : generateId2();
|
|
53354
54930
|
controller.enqueue({
|
|
53355
54931
|
type: "tool-input-start",
|
|
53356
54932
|
id,
|
|
@@ -53414,15 +54990,15 @@ var OllamaResponsesLanguageModel = class {
|
|
|
53414
54990
|
responseHeaders,
|
|
53415
54991
|
value: response,
|
|
53416
54992
|
rawValue: rawResponse
|
|
53417
|
-
} = await
|
|
54993
|
+
} = await postJsonToApi2({
|
|
53418
54994
|
url: this.config.url({
|
|
53419
54995
|
path: "/chat",
|
|
53420
54996
|
modelId: this.modelId
|
|
53421
54997
|
}),
|
|
53422
|
-
headers:
|
|
54998
|
+
headers: combineHeaders2(this.config.headers(), options.headers),
|
|
53423
54999
|
body: { ...body, stream: false },
|
|
53424
55000
|
failedResponseHandler: ollamaFailedResponseHandler,
|
|
53425
|
-
successfulResponseHandler:
|
|
55001
|
+
successfulResponseHandler: createJsonResponseHandler2(baseOllamaResponseSchema2),
|
|
53426
55002
|
abortSignal: options.abortSignal,
|
|
53427
55003
|
fetch: this.config.fetch
|
|
53428
55004
|
});
|
|
@@ -53441,12 +55017,12 @@ var OllamaResponsesLanguageModel = class {
|
|
|
53441
55017
|
}
|
|
53442
55018
|
async doStream(options) {
|
|
53443
55019
|
const { args: body, warnings } = await this.prepareRequest(options);
|
|
53444
|
-
const { responseHeaders, value: response } = await
|
|
55020
|
+
const { responseHeaders, value: response } = await postJsonToApi2({
|
|
53445
55021
|
url: this.config.url({
|
|
53446
55022
|
path: "/chat",
|
|
53447
55023
|
modelId: this.modelId
|
|
53448
55024
|
}),
|
|
53449
|
-
headers:
|
|
55025
|
+
headers: combineHeaders2(this.config.headers(), options.headers),
|
|
53450
55026
|
body: { ...body, stream: true },
|
|
53451
55027
|
failedResponseHandler: ollamaFailedResponseHandler,
|
|
53452
55028
|
successfulResponseHandler: createNdjsonStreamResponseHandler(baseOllamaResponseSchema2),
|
|
@@ -53470,7 +55046,7 @@ var OllamaResponsesLanguageModel = class {
|
|
|
53470
55046
|
};
|
|
53471
55047
|
function createOllama(options = {}) {
|
|
53472
55048
|
var _a16, _b16;
|
|
53473
|
-
const baseURL = (_a16 =
|
|
55049
|
+
const baseURL = (_a16 = withoutTrailingSlash2(options.baseURL)) != null ? _a16 : "http://127.0.0.1:11434/api";
|
|
53474
55050
|
const providerName = (_b16 = options.name) != null ? _b16 : "ollama";
|
|
53475
55051
|
const getHeaders = () => ({
|
|
53476
55052
|
"Ollama-Organization": options.organization,
|
|
@@ -56989,8 +58565,8 @@ async function prepareResponsesTools3({
|
|
|
56989
58565
|
value: tool2.args,
|
|
56990
58566
|
schema: mcpArgsSchema2
|
|
56991
58567
|
});
|
|
56992
|
-
const mapApprovalFilter = (
|
|
56993
|
-
tool_names:
|
|
58568
|
+
const mapApprovalFilter = (filter3) => ({
|
|
58569
|
+
tool_names: filter3.toolNames
|
|
56994
58570
|
});
|
|
56995
58571
|
const requireApproval = args.requireApproval;
|
|
56996
58572
|
const requireApprovalParam = requireApproval == null ? undefined : typeof requireApproval === "string" ? requireApproval : requireApproval.never != null ? { never: mapApprovalFilter(requireApproval.never) } : undefined;
|
|
@@ -58915,7 +60491,7 @@ var OpenAITranscriptionModel2 = class {
|
|
|
58915
60491
|
};
|
|
58916
60492
|
}
|
|
58917
60493
|
};
|
|
58918
|
-
var
|
|
60494
|
+
var VERSION9 = "3.0.39";
|
|
58919
60495
|
function createOpenAI(options = {}) {
|
|
58920
60496
|
var _a16, _b16;
|
|
58921
60497
|
const baseURL = (_a16 = withoutTrailingSlash(loadOptionalSetting({
|
|
@@ -58932,7 +60508,7 @@ function createOpenAI(options = {}) {
|
|
|
58932
60508
|
"OpenAI-Organization": options.organization,
|
|
58933
60509
|
"OpenAI-Project": options.project,
|
|
58934
60510
|
...options.headers
|
|
58935
|
-
}, `ai-sdk/openai/${
|
|
60511
|
+
}, `ai-sdk/openai/${VERSION9}`);
|
|
58936
60512
|
const createChatModel = (modelId) => new OpenAIChatLanguageModel2(modelId, {
|
|
58937
60513
|
provider: `${providerName}.chat`,
|
|
58938
60514
|
url: ({ path }) => `${baseURL}${path}`,
|
|
@@ -59157,7 +60733,7 @@ function convertToOpenAICompatibleChatMessages(prompt) {
|
|
|
59157
60733
|
};
|
|
59158
60734
|
}
|
|
59159
60735
|
if (part.mediaType.startsWith("text/")) {
|
|
59160
|
-
const textContent = part.data instanceof URL ? part.data.toString() : typeof part.data === "string" ? part.data : new TextDecoder().decode(part.data);
|
|
60736
|
+
const textContent = part.data instanceof URL ? part.data.toString() : typeof part.data === "string" ? new TextDecoder().decode(convertBase64ToUint8Array(part.data)) : new TextDecoder().decode(part.data);
|
|
59161
60737
|
return {
|
|
59162
60738
|
type: "text",
|
|
59163
60739
|
text: textContent,
|
|
@@ -60463,7 +62039,7 @@ async function fileToBlob3(file2) {
|
|
|
60463
62039
|
function toCamelCase(str) {
|
|
60464
62040
|
return str.replace(/[_-]([a-z])/g, (g) => g[1].toUpperCase());
|
|
60465
62041
|
}
|
|
60466
|
-
var
|
|
62042
|
+
var VERSION10 = "2.0.33";
|
|
60467
62043
|
function createOpenAICompatible(options) {
|
|
60468
62044
|
const baseURL = withoutTrailingSlash(options.baseURL);
|
|
60469
62045
|
const providerName = options.name;
|
|
@@ -60471,7 +62047,7 @@ function createOpenAICompatible(options) {
|
|
|
60471
62047
|
...options.apiKey && { Authorization: `Bearer ${options.apiKey}` },
|
|
60472
62048
|
...options.headers
|
|
60473
62049
|
};
|
|
60474
|
-
const getHeaders = () => withUserAgentSuffix(headers, `ai-sdk/openai-compatible/${
|
|
62050
|
+
const getHeaders = () => withUserAgentSuffix(headers, `ai-sdk/openai-compatible/${VERSION10}`);
|
|
60475
62051
|
const getCommonModelConfig = (modelType) => ({
|
|
60476
62052
|
provider: `${providerName}.${modelType}`,
|
|
60477
62053
|
url: ({ path }) => {
|
|
@@ -60679,11 +62255,11 @@ function listProviders(config2) {
|
|
|
60679
62255
|
// node_modules/@ai-sdk/gateway/dist/index.mjs
|
|
60680
62256
|
var import_oidc = __toESM(require_dist(), 1);
|
|
60681
62257
|
var import_oidc2 = __toESM(require_dist(), 1);
|
|
60682
|
-
var
|
|
60683
|
-
var
|
|
60684
|
-
var
|
|
60685
|
-
var
|
|
60686
|
-
var GatewayError = class _GatewayError extends (
|
|
62258
|
+
var marker18 = "vercel.ai.gateway.error";
|
|
62259
|
+
var symbol18 = Symbol.for(marker18);
|
|
62260
|
+
var _a18;
|
|
62261
|
+
var _b18;
|
|
62262
|
+
var GatewayError = class _GatewayError extends (_b18 = Error, _a18 = symbol18, _b18) {
|
|
60687
62263
|
constructor({
|
|
60688
62264
|
message,
|
|
60689
62265
|
statusCode = 500,
|
|
@@ -60691,7 +62267,7 @@ var GatewayError = class _GatewayError extends (_b17 = Error, _a17 = symbol17, _
|
|
|
60691
62267
|
generationId
|
|
60692
62268
|
}) {
|
|
60693
62269
|
super(generationId ? `${message} [${generationId}]` : message);
|
|
60694
|
-
this[
|
|
62270
|
+
this[_a18] = true;
|
|
60695
62271
|
this.statusCode = statusCode;
|
|
60696
62272
|
this.cause = cause;
|
|
60697
62273
|
this.generationId = generationId;
|
|
@@ -60700,11 +62276,11 @@ var GatewayError = class _GatewayError extends (_b17 = Error, _a17 = symbol17, _
|
|
|
60700
62276
|
return _GatewayError.hasMarker(error48);
|
|
60701
62277
|
}
|
|
60702
62278
|
static hasMarker(error48) {
|
|
60703
|
-
return typeof error48 === "object" && error48 !== null &&
|
|
62279
|
+
return typeof error48 === "object" && error48 !== null && symbol18 in error48 && error48[symbol18] === true;
|
|
60704
62280
|
}
|
|
60705
62281
|
};
|
|
60706
|
-
var
|
|
60707
|
-
var marker22 = `vercel.ai.gateway.error.${
|
|
62282
|
+
var name17 = "GatewayAuthenticationError";
|
|
62283
|
+
var marker22 = `vercel.ai.gateway.error.${name17}`;
|
|
60708
62284
|
var symbol23 = Symbol.for(marker22);
|
|
60709
62285
|
var _a23;
|
|
60710
62286
|
var _b22;
|
|
@@ -60717,7 +62293,7 @@ var GatewayAuthenticationError = class _GatewayAuthenticationError extends (_b22
|
|
|
60717
62293
|
} = {}) {
|
|
60718
62294
|
super({ message, statusCode, cause, generationId });
|
|
60719
62295
|
this[_a23] = true;
|
|
60720
|
-
this.name =
|
|
62296
|
+
this.name = name17;
|
|
60721
62297
|
this.type = "authentication_error";
|
|
60722
62298
|
}
|
|
60723
62299
|
static isInstance(error48) {
|
|
@@ -61742,7 +63318,7 @@ async function getVercelRequestId() {
|
|
|
61742
63318
|
var _a92;
|
|
61743
63319
|
return (_a92 = import_oidc.getContext().headers) == null ? undefined : _a92["x-vercel-id"];
|
|
61744
63320
|
}
|
|
61745
|
-
var
|
|
63321
|
+
var VERSION11 = "3.0.61";
|
|
61746
63322
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
61747
63323
|
function createGatewayProvider(options = {}) {
|
|
61748
63324
|
var _a92, _b92;
|
|
@@ -61759,7 +63335,7 @@ function createGatewayProvider(options = {}) {
|
|
|
61759
63335
|
"ai-gateway-protocol-version": AI_GATEWAY_PROTOCOL_VERSION,
|
|
61760
63336
|
[GATEWAY_AUTH_METHOD_HEADER]: auth.authMethod,
|
|
61761
63337
|
...options.headers
|
|
61762
|
-
}, `ai-sdk/gateway/${
|
|
63338
|
+
}, `ai-sdk/gateway/${VERSION11}`);
|
|
61763
63339
|
} catch (error48) {
|
|
61764
63340
|
throw GatewayAuthenticationError.createContextualError({
|
|
61765
63341
|
apiKeyProvided: false,
|
|
@@ -61906,10 +63482,10 @@ var __export2 = (target, all) => {
|
|
|
61906
63482
|
for (var name21 in all)
|
|
61907
63483
|
__defProp2(target, name21, { get: all[name21], enumerable: true });
|
|
61908
63484
|
};
|
|
61909
|
-
var
|
|
61910
|
-
var
|
|
61911
|
-
var
|
|
61912
|
-
var
|
|
63485
|
+
var name18 = "AI_InvalidArgumentError";
|
|
63486
|
+
var marker19 = `vercel.ai.error.${name18}`;
|
|
63487
|
+
var symbol19 = Symbol.for(marker19);
|
|
63488
|
+
var _a19;
|
|
61913
63489
|
var InvalidArgumentError2 = class extends AISDKError {
|
|
61914
63490
|
constructor({
|
|
61915
63491
|
parameter,
|
|
@@ -61917,18 +63493,18 @@ var InvalidArgumentError2 = class extends AISDKError {
|
|
|
61917
63493
|
message
|
|
61918
63494
|
}) {
|
|
61919
63495
|
super({
|
|
61920
|
-
name:
|
|
63496
|
+
name: name18,
|
|
61921
63497
|
message: `Invalid argument for parameter ${parameter}: ${message}`
|
|
61922
63498
|
});
|
|
61923
|
-
this[
|
|
63499
|
+
this[_a19] = true;
|
|
61924
63500
|
this.parameter = parameter;
|
|
61925
63501
|
this.value = value;
|
|
61926
63502
|
}
|
|
61927
63503
|
static isInstance(error48) {
|
|
61928
|
-
return AISDKError.hasMarker(error48,
|
|
63504
|
+
return AISDKError.hasMarker(error48, marker19);
|
|
61929
63505
|
}
|
|
61930
63506
|
};
|
|
61931
|
-
|
|
63507
|
+
_a19 = symbol19;
|
|
61932
63508
|
var name23 = "AI_InvalidStreamPartError";
|
|
61933
63509
|
var marker23 = `vercel.ai.error.${name23}`;
|
|
61934
63510
|
var symbol24 = Symbol.for(marker23);
|
|
@@ -62168,15 +63744,15 @@ var InvalidMessageRoleError = class extends AISDKError {
|
|
|
62168
63744
|
}
|
|
62169
63745
|
};
|
|
62170
63746
|
_a172 = symbol172;
|
|
62171
|
-
var
|
|
62172
|
-
var marker182 = `vercel.ai.error.${
|
|
63747
|
+
var name182 = "AI_MessageConversionError";
|
|
63748
|
+
var marker182 = `vercel.ai.error.${name182}`;
|
|
62173
63749
|
var symbol182 = Symbol.for(marker182);
|
|
62174
63750
|
var _a182;
|
|
62175
63751
|
_a182 = symbol182;
|
|
62176
63752
|
var name19 = "AI_RetryError";
|
|
62177
|
-
var
|
|
62178
|
-
var
|
|
62179
|
-
var
|
|
63753
|
+
var marker192 = `vercel.ai.error.${name19}`;
|
|
63754
|
+
var symbol192 = Symbol.for(marker192);
|
|
63755
|
+
var _a192;
|
|
62180
63756
|
var RetryError = class extends AISDKError {
|
|
62181
63757
|
constructor({
|
|
62182
63758
|
message,
|
|
@@ -62184,16 +63760,16 @@ var RetryError = class extends AISDKError {
|
|
|
62184
63760
|
errors: errors3
|
|
62185
63761
|
}) {
|
|
62186
63762
|
super({ name: name19, message });
|
|
62187
|
-
this[
|
|
63763
|
+
this[_a192] = true;
|
|
62188
63764
|
this.reason = reason;
|
|
62189
63765
|
this.errors = errors3;
|
|
62190
63766
|
this.lastError = errors3[errors3.length - 1];
|
|
62191
63767
|
}
|
|
62192
63768
|
static isInstance(error48) {
|
|
62193
|
-
return AISDKError.hasMarker(error48,
|
|
63769
|
+
return AISDKError.hasMarker(error48, marker192);
|
|
62194
63770
|
}
|
|
62195
63771
|
};
|
|
62196
|
-
|
|
63772
|
+
_a192 = symbol192;
|
|
62197
63773
|
function asArray(value) {
|
|
62198
63774
|
return value === undefined ? [] : Array.isArray(value) ? value : [value];
|
|
62199
63775
|
}
|
|
@@ -62488,7 +64064,7 @@ function detectMediaType({
|
|
|
62488
64064
|
}
|
|
62489
64065
|
return;
|
|
62490
64066
|
}
|
|
62491
|
-
var
|
|
64067
|
+
var VERSION12 = "6.0.107";
|
|
62492
64068
|
var download = async ({
|
|
62493
64069
|
url: url2,
|
|
62494
64070
|
maxBytes,
|
|
@@ -62498,7 +64074,7 @@ var download = async ({
|
|
|
62498
64074
|
const urlText = url2.toString();
|
|
62499
64075
|
try {
|
|
62500
64076
|
const response = await fetch(urlText, {
|
|
62501
|
-
headers: withUserAgentSuffix({}, `ai-sdk/${
|
|
64077
|
+
headers: withUserAgentSuffix({}, `ai-sdk/${VERSION12}`, getRuntimeEnvironmentUserAgent()),
|
|
62502
64078
|
signal: abortSignal
|
|
62503
64079
|
});
|
|
62504
64080
|
if (!response.ok) {
|
|
@@ -64320,9 +65896,9 @@ var object2 = ({
|
|
|
64320
65896
|
const schema = asSchema(inputSchema);
|
|
64321
65897
|
return {
|
|
64322
65898
|
name: "object",
|
|
64323
|
-
responseFormat: resolve(schema.jsonSchema).then((
|
|
65899
|
+
responseFormat: resolve(schema.jsonSchema).then((jsonSchema22) => ({
|
|
64324
65900
|
type: "json",
|
|
64325
|
-
schema:
|
|
65901
|
+
schema: jsonSchema22,
|
|
64326
65902
|
...name21 != null && { name: name21 },
|
|
64327
65903
|
...description != null && { description }
|
|
64328
65904
|
})),
|
|
@@ -64382,8 +65958,8 @@ var array2 = ({
|
|
|
64382
65958
|
const elementSchema = asSchema(inputElementSchema);
|
|
64383
65959
|
return {
|
|
64384
65960
|
name: "array",
|
|
64385
|
-
responseFormat: resolve(elementSchema.jsonSchema).then((
|
|
64386
|
-
const { $schema, ...itemSchema } =
|
|
65961
|
+
responseFormat: resolve(elementSchema.jsonSchema).then((jsonSchema22) => {
|
|
65962
|
+
const { $schema, ...itemSchema } = jsonSchema22;
|
|
64387
65963
|
return {
|
|
64388
65964
|
type: "json",
|
|
64389
65965
|
schema: {
|
|
@@ -66028,7 +67604,7 @@ function runToolsTransformation({
|
|
|
66028
67604
|
abortSignal,
|
|
66029
67605
|
repairToolCall,
|
|
66030
67606
|
experimental_context,
|
|
66031
|
-
generateId:
|
|
67607
|
+
generateId: generateId22,
|
|
66032
67608
|
stepNumber,
|
|
66033
67609
|
model,
|
|
66034
67610
|
onToolCallStart,
|
|
@@ -66157,14 +67733,14 @@ function runToolsTransformation({
|
|
|
66157
67733
|
})) {
|
|
66158
67734
|
toolResultsStreamController.enqueue({
|
|
66159
67735
|
type: "tool-approval-request",
|
|
66160
|
-
approvalId:
|
|
67736
|
+
approvalId: generateId22(),
|
|
66161
67737
|
toolCall
|
|
66162
67738
|
});
|
|
66163
67739
|
break;
|
|
66164
67740
|
}
|
|
66165
67741
|
toolInputs.set(toolCall.toolCallId, toolCall.input);
|
|
66166
67742
|
if (tool2.execute != null && toolCall.providerExecuted !== true) {
|
|
66167
|
-
const toolExecutionId =
|
|
67743
|
+
const toolExecutionId = generateId22();
|
|
66168
67744
|
outstandingToolResults.add(toolExecutionId);
|
|
66169
67745
|
executeToolCall({
|
|
66170
67746
|
toolCall,
|
|
@@ -66295,7 +67871,7 @@ function streamText({
|
|
|
66295
67871
|
experimental_onToolCallFinish: onToolCallFinish,
|
|
66296
67872
|
experimental_context,
|
|
66297
67873
|
experimental_include: include,
|
|
66298
|
-
_internal: { now: now2 = now, generateId:
|
|
67874
|
+
_internal: { now: now2 = now, generateId: generateId22 = originalGenerateId2 } = {},
|
|
66299
67875
|
...settings
|
|
66300
67876
|
}) {
|
|
66301
67877
|
const totalTimeoutMs = getTotalTimeoutMs(timeout);
|
|
@@ -66340,7 +67916,7 @@ function streamText({
|
|
|
66340
67916
|
onToolCallStart,
|
|
66341
67917
|
onToolCallFinish,
|
|
66342
67918
|
now: now2,
|
|
66343
|
-
generateId:
|
|
67919
|
+
generateId: generateId22,
|
|
66344
67920
|
experimental_context,
|
|
66345
67921
|
download: download2,
|
|
66346
67922
|
include
|
|
@@ -66434,7 +68010,7 @@ var DefaultStreamTextResult = class {
|
|
|
66434
68010
|
prepareStep,
|
|
66435
68011
|
includeRawChunks,
|
|
66436
68012
|
now: now2,
|
|
66437
|
-
generateId:
|
|
68013
|
+
generateId: generateId22,
|
|
66438
68014
|
timeout,
|
|
66439
68015
|
stopWhen,
|
|
66440
68016
|
originalAbortSignal,
|
|
@@ -67066,7 +68642,7 @@ var DefaultStreamTextResult = class {
|
|
|
67066
68642
|
repairToolCall,
|
|
67067
68643
|
abortSignal,
|
|
67068
68644
|
experimental_context,
|
|
67069
|
-
generateId:
|
|
68645
|
+
generateId: generateId22,
|
|
67070
68646
|
stepNumber: recordedSteps.length,
|
|
67071
68647
|
model: stepModelInfo,
|
|
67072
68648
|
onToolCallStart,
|
|
@@ -67083,7 +68659,7 @@ var DefaultStreamTextResult = class {
|
|
|
67083
68659
|
let stepProviderMetadata;
|
|
67084
68660
|
let stepFirstChunk = true;
|
|
67085
68661
|
let stepResponse = {
|
|
67086
|
-
id:
|
|
68662
|
+
id: generateId22(),
|
|
67087
68663
|
timestamp: /* @__PURE__ */ new Date,
|
|
67088
68664
|
modelId: modelInfo.modelId
|
|
67089
68665
|
};
|