@hongymagic/q 2026.422.0 → 2026.427.0-next.679f78a
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 +399 -1867
- package/package.json +3 -3
package/dist/q.js
CHANGED
|
@@ -3949,14 +3949,14 @@ var require_cross_spawn = __commonJS((exports, module) => {
|
|
|
3949
3949
|
// node_modules/run-jxa/node_modules/execa/node_modules/strip-final-newline/index.js
|
|
3950
3950
|
var require_strip_final_newline = __commonJS((exports, module) => {
|
|
3951
3951
|
module.exports = (input) => {
|
|
3952
|
-
const
|
|
3952
|
+
const LF2 = typeof input === "string" ? `
|
|
3953
3953
|
` : `
|
|
3954
3954
|
`.charCodeAt();
|
|
3955
|
-
const
|
|
3956
|
-
if (input[input.length - 1] ===
|
|
3955
|
+
const CR2 = typeof input === "string" ? "\r" : "\r".charCodeAt();
|
|
3956
|
+
if (input[input.length - 1] === LF2) {
|
|
3957
3957
|
input = input.slice(0, input.length - 1);
|
|
3958
3958
|
}
|
|
3959
|
-
if (input[input.length - 1] ===
|
|
3959
|
+
if (input[input.length - 1] === CR2) {
|
|
3960
3960
|
input = input.slice(0, input.length - 1);
|
|
3961
3961
|
}
|
|
3962
3962
|
return input;
|
|
@@ -7826,11 +7826,11 @@ import { stripVTControlCharacters } from "node:util";
|
|
|
7826
7826
|
var joinCommand = (filePath, rawArguments) => {
|
|
7827
7827
|
const fileAndArguments = [filePath, ...rawArguments];
|
|
7828
7828
|
const command = fileAndArguments.join(" ");
|
|
7829
|
-
const escapedCommand = fileAndArguments.map((fileAndArgument) => quoteString(
|
|
7829
|
+
const escapedCommand = fileAndArguments.map((fileAndArgument) => quoteString(escapeControlCharacters2(fileAndArgument))).join(" ");
|
|
7830
7830
|
return { command, escapedCommand };
|
|
7831
7831
|
}, escapeLines = (lines) => stripVTControlCharacters(lines).split(`
|
|
7832
|
-
`).map((line) =>
|
|
7833
|
-
`),
|
|
7832
|
+
`).map((line) => escapeControlCharacters2(line)).join(`
|
|
7833
|
+
`), escapeControlCharacters2 = (line) => line.replaceAll(SPECIAL_CHAR_REGEXP, (character) => escapeControlCharacter(character)), escapeControlCharacter = (character) => {
|
|
7834
7834
|
const commonEscape = COMMON_ESCAPES[character];
|
|
7835
7835
|
if (commonEscape !== undefined) {
|
|
7836
7836
|
return commonEscape;
|
|
@@ -9827,11 +9827,11 @@ function stripFinalNewline(input) {
|
|
|
9827
9827
|
}
|
|
9828
9828
|
return stripFinalNewlineBinary(input);
|
|
9829
9829
|
}
|
|
9830
|
-
var stripFinalNewlineString = (input) => input.at(-1) ===
|
|
9831
|
-
`, LF_BINARY,
|
|
9830
|
+
var stripFinalNewlineString = (input) => input.at(-1) === LF2 ? input.slice(0, input.at(-2) === CR2 ? -2 : -1) : input, stripFinalNewlineBinary = (input) => input.at(-1) === LF_BINARY ? input.subarray(0, input.at(-2) === CR_BINARY ? -2 : -1) : input, LF2 = `
|
|
9831
|
+
`, LF_BINARY, CR2 = "\r", CR_BINARY;
|
|
9832
9832
|
var init_strip_final_newline = __esm(() => {
|
|
9833
|
-
LF_BINARY =
|
|
9834
|
-
CR_BINARY =
|
|
9833
|
+
LF_BINARY = LF2.codePointAt(0);
|
|
9834
|
+
CR_BINARY = CR2.codePointAt(0);
|
|
9835
9835
|
});
|
|
9836
9836
|
|
|
9837
9837
|
// node_modules/is-stream/index.js
|
|
@@ -11486,8 +11486,8 @@ var getSplitLinesGenerator = (binary, preserveNewlines, skipped, state) => binar
|
|
|
11486
11486
|
yield previousChunks;
|
|
11487
11487
|
}
|
|
11488
11488
|
}, getAppendNewlineGenerator = ({ binary, preserveNewlines, readableObjectMode, state }) => binary || preserveNewlines || readableObjectMode ? undefined : { transform: appendNewlineGenerator.bind(undefined, state) }, appendNewlineGenerator = function* ({ isWindowsNewline = false }, chunk) {
|
|
11489
|
-
const { unixNewline, windowsNewline, LF:
|
|
11490
|
-
if (chunk.at(-1) ===
|
|
11489
|
+
const { unixNewline, windowsNewline, LF: LF3, concatBytes } = typeof chunk === "string" ? linesStringInfo : linesUint8ArrayInfo;
|
|
11490
|
+
if (chunk.at(-1) === LF3) {
|
|
11491
11491
|
yield chunk;
|
|
11492
11492
|
return;
|
|
11493
11493
|
}
|
|
@@ -12115,7 +12115,7 @@ var init_main_sync = __esm(() => {
|
|
|
12115
12115
|
|
|
12116
12116
|
// node_modules/execa/lib/ipc/get-one.js
|
|
12117
12117
|
import { once as once5, on as on2 } from "node:events";
|
|
12118
|
-
var getOneMessage = ({ anyProcess, channel, isSubprocess, ipc }, { reference = true, filter:
|
|
12118
|
+
var getOneMessage = ({ anyProcess, channel, isSubprocess, ipc }, { reference = true, filter: filter2 } = {}) => {
|
|
12119
12119
|
validateIpcMethod({
|
|
12120
12120
|
methodName: "getOneMessage",
|
|
12121
12121
|
isSubprocess,
|
|
@@ -12126,16 +12126,16 @@ var getOneMessage = ({ anyProcess, channel, isSubprocess, ipc }, { reference = t
|
|
|
12126
12126
|
anyProcess,
|
|
12127
12127
|
channel,
|
|
12128
12128
|
isSubprocess,
|
|
12129
|
-
filter:
|
|
12129
|
+
filter: filter2,
|
|
12130
12130
|
reference
|
|
12131
12131
|
});
|
|
12132
|
-
}, getOneMessageAsync = async ({ anyProcess, channel, isSubprocess, filter:
|
|
12132
|
+
}, getOneMessageAsync = async ({ anyProcess, channel, isSubprocess, filter: filter2, reference }) => {
|
|
12133
12133
|
addReference(channel, reference);
|
|
12134
12134
|
const ipcEmitter = getIpcEmitter(anyProcess, channel, isSubprocess);
|
|
12135
12135
|
const controller = new AbortController;
|
|
12136
12136
|
try {
|
|
12137
12137
|
return await Promise.race([
|
|
12138
|
-
getMessage(ipcEmitter,
|
|
12138
|
+
getMessage(ipcEmitter, filter2, controller),
|
|
12139
12139
|
throwOnDisconnect2(ipcEmitter, isSubprocess, controller),
|
|
12140
12140
|
throwOnStrictError(ipcEmitter, isSubprocess, controller)
|
|
12141
12141
|
]);
|
|
@@ -12146,13 +12146,13 @@ var getOneMessage = ({ anyProcess, channel, isSubprocess, ipc }, { reference = t
|
|
|
12146
12146
|
controller.abort();
|
|
12147
12147
|
removeReference(channel, reference);
|
|
12148
12148
|
}
|
|
12149
|
-
}, getMessage = async (ipcEmitter,
|
|
12150
|
-
if (
|
|
12149
|
+
}, getMessage = async (ipcEmitter, filter2, { signal }) => {
|
|
12150
|
+
if (filter2 === undefined) {
|
|
12151
12151
|
const [message] = await once5(ipcEmitter, "message", { signal });
|
|
12152
12152
|
return message;
|
|
12153
12153
|
}
|
|
12154
12154
|
for await (const [message] of on2(ipcEmitter, "message", { signal })) {
|
|
12155
|
-
if (
|
|
12155
|
+
if (filter2(message)) {
|
|
12156
12156
|
return message;
|
|
12157
12157
|
}
|
|
12158
12158
|
}
|
|
@@ -12503,7 +12503,7 @@ var getHighWaterMark = (streams, objectMode) => {
|
|
|
12503
12503
|
if (signal.aborted || !streams.has(stream)) {
|
|
12504
12504
|
return;
|
|
12505
12505
|
}
|
|
12506
|
-
if (
|
|
12506
|
+
if (isAbortError2(error48)) {
|
|
12507
12507
|
aborted2.add(stream);
|
|
12508
12508
|
} else {
|
|
12509
12509
|
errorStream(passThroughStream, error48);
|
|
@@ -12522,12 +12522,12 @@ var getHighWaterMark = (streams, objectMode) => {
|
|
|
12522
12522
|
stream.end();
|
|
12523
12523
|
}
|
|
12524
12524
|
}, errorOrAbortStream = (stream, error48) => {
|
|
12525
|
-
if (
|
|
12525
|
+
if (isAbortError2(error48)) {
|
|
12526
12526
|
abortStream(stream);
|
|
12527
12527
|
} else {
|
|
12528
12528
|
errorStream(stream, error48);
|
|
12529
12529
|
}
|
|
12530
|
-
},
|
|
12530
|
+
}, isAbortError2 = (error48) => error48?.code === "ERR_STREAM_PREMATURE_CLOSE", abortStream = (stream) => {
|
|
12531
12531
|
if (stream.readable || stream.writable) {
|
|
12532
12532
|
stream.destroy();
|
|
12533
12533
|
}
|
|
@@ -14720,6 +14720,7 @@ var init_clipboardy = __esm(() => {
|
|
|
14720
14720
|
var exports_ansi = {};
|
|
14721
14721
|
__export(exports_ansi, {
|
|
14722
14722
|
stripAnsi: () => stripAnsi2,
|
|
14723
|
+
sanitizeForTerminal: () => sanitizeForTerminal2,
|
|
14723
14724
|
sanitizeForClipboard: () => sanitizeForClipboard,
|
|
14724
14725
|
createAnsiStripper: () => createAnsiStripper2
|
|
14725
14726
|
});
|
|
@@ -14728,15 +14729,24 @@ function stripAnsi2(str) {
|
|
|
14728
14729
|
return str;
|
|
14729
14730
|
return str.replace(ANSI_REGEX2, "");
|
|
14730
14731
|
}
|
|
14731
|
-
function
|
|
14732
|
-
|
|
14733
|
-
|
|
14734
|
-
|
|
14735
|
-
return stripped.replace(/[\x00-\x08\x0B\x0C\x0E-\x1F\x7F-\x9F]/g, (char) => {
|
|
14732
|
+
function escapeControlCharacters3(str) {
|
|
14733
|
+
const normalised = str.replace(/\r\n/g, `
|
|
14734
|
+
`);
|
|
14735
|
+
return normalised.replace(/[\x00-\x08\x0B-\x1F\x7F-\x9F]/g, (char) => {
|
|
14736
14736
|
const hex3 = char.charCodeAt(0).toString(16).padStart(2, "0").toUpperCase();
|
|
14737
14737
|
return `\\x${hex3}`;
|
|
14738
14738
|
});
|
|
14739
14739
|
}
|
|
14740
|
+
function sanitizeForClipboard(str) {
|
|
14741
|
+
if (!str)
|
|
14742
|
+
return str;
|
|
14743
|
+
return escapeControlCharacters3(stripAnsi2(str));
|
|
14744
|
+
}
|
|
14745
|
+
function sanitizeForTerminal2(str) {
|
|
14746
|
+
if (!str)
|
|
14747
|
+
return str;
|
|
14748
|
+
return escapeControlCharacters3(str);
|
|
14749
|
+
}
|
|
14740
14750
|
function createAnsiStripper2() {
|
|
14741
14751
|
let buffer = "";
|
|
14742
14752
|
return (chunk) => {
|
|
@@ -14772,7 +14782,7 @@ import { parseArgs } from "node:util";
|
|
|
14772
14782
|
// package.json
|
|
14773
14783
|
var package_default = {
|
|
14774
14784
|
name: "@hongymagic/q",
|
|
14775
|
-
version: "2026.
|
|
14785
|
+
version: "2026.427.0-next.679f78a",
|
|
14776
14786
|
description: "Quick AI answers from the command line",
|
|
14777
14787
|
main: "dist/q.js",
|
|
14778
14788
|
type: "module",
|
|
@@ -14838,8 +14848,8 @@ var package_default = {
|
|
|
14838
14848
|
zod: "4.3.6"
|
|
14839
14849
|
},
|
|
14840
14850
|
devDependencies: {
|
|
14841
|
-
"@biomejs/biome": "2.4.
|
|
14842
|
-
"@types/bun": "1.3.
|
|
14851
|
+
"@biomejs/biome": "2.4.13",
|
|
14852
|
+
"@types/bun": "1.3.13",
|
|
14843
14853
|
"@vitest/coverage-v8": "4.1.5",
|
|
14844
14854
|
lefthook: "2.1.6",
|
|
14845
14855
|
typescript: "6.0.3",
|
|
@@ -29203,8 +29213,7 @@ class Config {
|
|
|
29203
29213
|
};
|
|
29204
29214
|
const mergedProviders = {
|
|
29205
29215
|
...getBuiltInProviderConfigs(),
|
|
29206
|
-
...xdgConfig?.providers ?? {}
|
|
29207
|
-
...cwdConfig?.providers ?? {}
|
|
29216
|
+
...xdgConfig?.providers ?? {}
|
|
29208
29217
|
};
|
|
29209
29218
|
const inferredProvider = await Config.inferDefaultProvider(mergedDefault);
|
|
29210
29219
|
const providerForDefaultModel = env.Q_PROVIDER ?? mergedDefault.provider ?? inferredProvider;
|
|
@@ -29390,10 +29399,14 @@ async function runConfigDoctor() {
|
|
|
29390
29399
|
}
|
|
29391
29400
|
];
|
|
29392
29401
|
const providerIssues = [];
|
|
29393
|
-
const configuredProviderNames = new Set(
|
|
29394
|
-
|
|
29395
|
-
|
|
29396
|
-
|
|
29402
|
+
const configuredProviderNames = new Set(Object.keys((xdgData ?? {}).providers ?? {}));
|
|
29403
|
+
const cwdProviderNames = Object.keys((cwdData ?? {}).providers ?? {});
|
|
29404
|
+
if (cwdProviderNames.length > 0) {
|
|
29405
|
+
providerIssues.push({
|
|
29406
|
+
provider: "(cwd config)",
|
|
29407
|
+
issue: `Provider definitions in '${cwdPath}' are ignored for security. Define providers only in '${xdgPath}'. Ignored: ${cwdProviderNames.join(", ")}`
|
|
29408
|
+
});
|
|
29409
|
+
}
|
|
29397
29410
|
try {
|
|
29398
29411
|
const config2 = await Config.load();
|
|
29399
29412
|
if (!xdgExists && !cwdExists) {
|
|
@@ -30155,7 +30168,10 @@ function formatSessionContext() {
|
|
|
30155
30168
|
if (sessionContext2.size === 0) {
|
|
30156
30169
|
return "(none)";
|
|
30157
30170
|
}
|
|
30158
|
-
return [...sessionContext2.entries()].sort(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey)).map(([key, value]) =>
|
|
30171
|
+
return [...sessionContext2.entries()].sort(([leftKey], [rightKey]) => leftKey.localeCompare(rightKey)).map(([key, value]) => {
|
|
30172
|
+
const display = isSensitiveKey(key) ? "[REDACTED]" : String(value);
|
|
30173
|
+
return `${key}: ${display}`;
|
|
30174
|
+
}).join(`
|
|
30159
30175
|
`);
|
|
30160
30176
|
}
|
|
30161
30177
|
function formatSessionEntries() {
|
|
@@ -34567,43 +34583,114 @@ class ParseError extends Error {
|
|
|
34567
34583
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
34568
34584
|
}
|
|
34569
34585
|
}
|
|
34586
|
+
var LF = 10;
|
|
34587
|
+
var CR = 13;
|
|
34588
|
+
var SPACE = 32;
|
|
34570
34589
|
function noop(_arg) {}
|
|
34571
34590
|
function createParser(callbacks) {
|
|
34572
34591
|
if (typeof callbacks == "function")
|
|
34573
34592
|
throw new TypeError("`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?");
|
|
34574
|
-
const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
|
|
34575
|
-
let
|
|
34576
|
-
function feed(
|
|
34577
|
-
|
|
34578
|
-
|
|
34579
|
-
|
|
34580
|
-
|
|
34581
|
-
|
|
34582
|
-
|
|
34583
|
-
|
|
34593
|
+
const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks, pendingFragments = [];
|
|
34594
|
+
let isFirstChunk = true, id, data = "", dataLines = 0, eventType;
|
|
34595
|
+
function feed(chunk) {
|
|
34596
|
+
if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
34597
|
+
const trailing2 = processLines(chunk);
|
|
34598
|
+
trailing2 !== "" && pendingFragments.push(trailing2);
|
|
34599
|
+
return;
|
|
34600
|
+
}
|
|
34601
|
+
if (chunk.indexOf(`
|
|
34602
|
+
`) === -1 && chunk.indexOf("\r") === -1) {
|
|
34603
|
+
pendingFragments.push(chunk);
|
|
34604
|
+
return;
|
|
34605
|
+
}
|
|
34606
|
+
pendingFragments.push(chunk);
|
|
34607
|
+
const input = pendingFragments.join("");
|
|
34608
|
+
pendingFragments.length = 0;
|
|
34609
|
+
const trailing = processLines(input);
|
|
34610
|
+
trailing !== "" && pendingFragments.push(trailing);
|
|
34611
|
+
}
|
|
34612
|
+
function processLines(chunk) {
|
|
34613
|
+
let searchIndex = 0;
|
|
34614
|
+
if (chunk.indexOf("\r") === -1) {
|
|
34615
|
+
let lfIndex = chunk.indexOf(`
|
|
34616
|
+
`, searchIndex);
|
|
34617
|
+
for (;lfIndex !== -1; ) {
|
|
34618
|
+
if (searchIndex === lfIndex) {
|
|
34619
|
+
dataLines > 0 && onEvent({ id, event: eventType, data }), id = undefined, data = "", dataLines = 0, eventType = undefined, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
34620
|
+
`, searchIndex);
|
|
34621
|
+
continue;
|
|
34622
|
+
}
|
|
34623
|
+
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
34624
|
+
if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
|
|
34625
|
+
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
34626
|
+
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
|
|
34627
|
+
onEvent({ id, event: eventType, data: value }), id = undefined, data = "", eventType = undefined, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
34628
|
+
`, searchIndex);
|
|
34629
|
+
continue;
|
|
34630
|
+
}
|
|
34631
|
+
data = dataLines === 0 ? value : `${data}
|
|
34632
|
+
${value}`, dataLines++;
|
|
34633
|
+
} else
|
|
34634
|
+
isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6, lfIndex) || undefined : parseLine(chunk, searchIndex, lfIndex);
|
|
34635
|
+
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
34636
|
+
`, searchIndex);
|
|
34637
|
+
}
|
|
34638
|
+
return chunk.slice(searchIndex);
|
|
34639
|
+
}
|
|
34640
|
+
for (;searchIndex < chunk.length; ) {
|
|
34641
|
+
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
34642
|
+
`, searchIndex);
|
|
34643
|
+
let lineEnd = -1;
|
|
34644
|
+
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = crIndex < lfIndex ? crIndex : lfIndex : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1)
|
|
34645
|
+
break;
|
|
34646
|
+
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
|
|
34647
|
+
}
|
|
34648
|
+
return chunk.slice(searchIndex);
|
|
34649
|
+
}
|
|
34650
|
+
function parseLine(chunk, start, end) {
|
|
34651
|
+
if (start === end) {
|
|
34584
34652
|
dispatchEvent();
|
|
34585
34653
|
return;
|
|
34586
34654
|
}
|
|
34587
|
-
|
|
34588
|
-
|
|
34655
|
+
const firstCharCode = chunk.charCodeAt(start);
|
|
34656
|
+
if (isDataPrefix(chunk, start, firstCharCode)) {
|
|
34657
|
+
const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
|
|
34658
|
+
data = dataLines === 0 ? value2 : `${data}
|
|
34659
|
+
${value2}`, dataLines++;
|
|
34660
|
+
return;
|
|
34661
|
+
}
|
|
34662
|
+
if (isEventPrefix(chunk, start, firstCharCode)) {
|
|
34663
|
+
eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || undefined;
|
|
34664
|
+
return;
|
|
34665
|
+
}
|
|
34666
|
+
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
34667
|
+
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
|
|
34668
|
+
id = value2.includes("\x00") ? undefined : value2;
|
|
34669
|
+
return;
|
|
34670
|
+
}
|
|
34671
|
+
if (firstCharCode === 58) {
|
|
34672
|
+
if (onComment) {
|
|
34673
|
+
const line2 = chunk.slice(start, end);
|
|
34674
|
+
onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
|
|
34675
|
+
}
|
|
34589
34676
|
return;
|
|
34590
34677
|
}
|
|
34591
|
-
const fieldSeparatorIndex = line.indexOf(":");
|
|
34592
|
-
if (fieldSeparatorIndex
|
|
34593
|
-
|
|
34594
|
-
processField(field, value, line);
|
|
34678
|
+
const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
|
|
34679
|
+
if (fieldSeparatorIndex === -1) {
|
|
34680
|
+
processField(line, "", line);
|
|
34595
34681
|
return;
|
|
34596
34682
|
}
|
|
34597
|
-
|
|
34683
|
+
const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
34684
|
+
processField(field, value, line);
|
|
34598
34685
|
}
|
|
34599
34686
|
function processField(field, value, line) {
|
|
34600
34687
|
switch (field) {
|
|
34601
34688
|
case "event":
|
|
34602
|
-
eventType = value;
|
|
34689
|
+
eventType = value || undefined;
|
|
34603
34690
|
break;
|
|
34604
34691
|
case "data":
|
|
34605
|
-
data = `${data}
|
|
34606
|
-
|
|
34692
|
+
data = dataLines === 0 ? value : `${data}
|
|
34693
|
+
${value}`, dataLines++;
|
|
34607
34694
|
break;
|
|
34608
34695
|
case "id":
|
|
34609
34696
|
id = value.includes("\x00") ? undefined : value;
|
|
@@ -34621,35 +34708,26 @@ function createParser(callbacks) {
|
|
|
34621
34708
|
}
|
|
34622
34709
|
}
|
|
34623
34710
|
function dispatchEvent() {
|
|
34624
|
-
|
|
34711
|
+
dataLines > 0 && onEvent({
|
|
34625
34712
|
id,
|
|
34626
|
-
event: eventType
|
|
34627
|
-
data
|
|
34628
|
-
|
|
34629
|
-
}), id = undefined, data = "", eventType = "";
|
|
34713
|
+
event: eventType,
|
|
34714
|
+
data
|
|
34715
|
+
}), id = undefined, data = "", dataLines = 0, eventType = undefined;
|
|
34630
34716
|
}
|
|
34631
34717
|
function reset(options = {}) {
|
|
34632
|
-
|
|
34718
|
+
if (options.consume && pendingFragments.length > 0) {
|
|
34719
|
+
const incompleteLine = pendingFragments.join("");
|
|
34720
|
+
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
34721
|
+
}
|
|
34722
|
+
isFirstChunk = true, id = undefined, data = "", dataLines = 0, eventType = undefined, pendingFragments.length = 0;
|
|
34633
34723
|
}
|
|
34634
34724
|
return { feed, reset };
|
|
34635
34725
|
}
|
|
34636
|
-
function
|
|
34637
|
-
|
|
34638
|
-
|
|
34639
|
-
|
|
34640
|
-
|
|
34641
|
-
`, searchIndex);
|
|
34642
|
-
let lineEnd = -1;
|
|
34643
|
-
if (crIndex !== -1 && lfIndex !== -1 ? lineEnd = Math.min(crIndex, lfIndex) : crIndex !== -1 ? crIndex === chunk.length - 1 ? lineEnd = -1 : lineEnd = crIndex : lfIndex !== -1 && (lineEnd = lfIndex), lineEnd === -1) {
|
|
34644
|
-
incompleteLine = chunk.slice(searchIndex);
|
|
34645
|
-
break;
|
|
34646
|
-
} else {
|
|
34647
|
-
const line = chunk.slice(searchIndex, lineEnd);
|
|
34648
|
-
lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
|
|
34649
|
-
` && searchIndex++;
|
|
34650
|
-
}
|
|
34651
|
-
}
|
|
34652
|
-
return [lines, incompleteLine];
|
|
34726
|
+
function isDataPrefix(chunk, i, firstCharCode) {
|
|
34727
|
+
return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
|
|
34728
|
+
}
|
|
34729
|
+
function isEventPrefix(chunk, i, firstCharCode) {
|
|
34730
|
+
return firstCharCode === 101 && chunk.charCodeAt(i + 1) === 118 && chunk.charCodeAt(i + 2) === 101 && chunk.charCodeAt(i + 3) === 110 && chunk.charCodeAt(i + 4) === 116 && chunk.charCodeAt(i + 5) === 58;
|
|
34653
34731
|
}
|
|
34654
34732
|
|
|
34655
34733
|
// node_modules/eventsource-parser/dist/stream.js
|
|
@@ -49160,6 +49238,19 @@ class HeaderMarshaller {
|
|
|
49160
49238
|
return out;
|
|
49161
49239
|
}
|
|
49162
49240
|
}
|
|
49241
|
+
var HEADER_VALUE_TYPE;
|
|
49242
|
+
(function(HEADER_VALUE_TYPE2) {
|
|
49243
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["boolTrue"] = 0] = "boolTrue";
|
|
49244
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["boolFalse"] = 1] = "boolFalse";
|
|
49245
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["byte"] = 2] = "byte";
|
|
49246
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["short"] = 3] = "short";
|
|
49247
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["integer"] = 4] = "integer";
|
|
49248
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["long"] = 5] = "long";
|
|
49249
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["byteArray"] = 6] = "byteArray";
|
|
49250
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["string"] = 7] = "string";
|
|
49251
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["timestamp"] = 8] = "timestamp";
|
|
49252
|
+
HEADER_VALUE_TYPE2[HEADER_VALUE_TYPE2["uuid"] = 9] = "uuid";
|
|
49253
|
+
})(HEADER_VALUE_TYPE || (HEADER_VALUE_TYPE = {}));
|
|
49163
49254
|
var BOOLEAN_TAG = "boolean";
|
|
49164
49255
|
var BYTE_TAG = "byte";
|
|
49165
49256
|
var SHORT_TAG = "short";
|
|
@@ -55084,1741 +55175,169 @@ function createGroqProvider(config2, providerName) {
|
|
|
55084
55175
|
});
|
|
55085
55176
|
}
|
|
55086
55177
|
|
|
55087
|
-
// node_modules/ollama-ai-provider-v2/
|
|
55088
|
-
function
|
|
55089
|
-
|
|
55090
|
-
|
|
55091
|
-
|
|
55092
|
-
}), {});
|
|
55093
|
-
}
|
|
55094
|
-
function extractResponseHeaders2(response) {
|
|
55095
|
-
return Object.fromEntries([...response.headers]);
|
|
55096
|
-
}
|
|
55097
|
-
var name16 = "AI_DownloadError";
|
|
55098
|
-
var marker17 = `vercel.ai.error.${name16}`;
|
|
55099
|
-
var symbol17 = Symbol.for(marker17);
|
|
55100
|
-
var _a17;
|
|
55101
|
-
var _b17;
|
|
55102
|
-
var DownloadError2 = class extends (_b17 = AISDKError, _a17 = symbol17, _b17) {
|
|
55103
|
-
constructor({
|
|
55104
|
-
url: url2,
|
|
55105
|
-
statusCode,
|
|
55106
|
-
statusText,
|
|
55107
|
-
cause,
|
|
55108
|
-
message = cause == null ? `Failed to download ${url2}: ${statusCode} ${statusText}` : `Failed to download ${url2}: ${cause}`
|
|
55109
|
-
}) {
|
|
55110
|
-
super({ name: name16, message, cause });
|
|
55111
|
-
this[_a17] = true;
|
|
55112
|
-
this.url = url2;
|
|
55113
|
-
this.statusCode = statusCode;
|
|
55114
|
-
this.statusText = statusText;
|
|
55115
|
-
}
|
|
55116
|
-
static isInstance(error48) {
|
|
55117
|
-
return AISDKError.hasMarker(error48, marker17);
|
|
55118
|
-
}
|
|
55119
|
-
};
|
|
55120
|
-
var DEFAULT_MAX_DOWNLOAD_SIZE2 = 2 * 1024 * 1024 * 1024;
|
|
55121
|
-
var createIdGenerator2 = ({
|
|
55122
|
-
prefix,
|
|
55123
|
-
size = 16,
|
|
55124
|
-
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
55125
|
-
separator = "-"
|
|
55126
|
-
} = {}) => {
|
|
55127
|
-
const generator = () => {
|
|
55128
|
-
const alphabetLength = alphabet.length;
|
|
55129
|
-
const chars = new Array(size);
|
|
55130
|
-
for (let i = 0;i < size; i++) {
|
|
55131
|
-
chars[i] = alphabet[Math.random() * alphabetLength | 0];
|
|
55132
|
-
}
|
|
55133
|
-
return chars.join("");
|
|
55134
|
-
};
|
|
55135
|
-
if (prefix == null) {
|
|
55136
|
-
return generator;
|
|
55137
|
-
}
|
|
55138
|
-
if (alphabet.includes(separator)) {
|
|
55139
|
-
throw new InvalidArgumentError({
|
|
55140
|
-
argument: "separator",
|
|
55141
|
-
message: `The separator "${separator}" must not be part of the alphabet "${alphabet}".`
|
|
55142
|
-
});
|
|
55143
|
-
}
|
|
55144
|
-
return () => `${prefix}${separator}${generator()}`;
|
|
55145
|
-
};
|
|
55146
|
-
var generateId2 = createIdGenerator2();
|
|
55147
|
-
function isAbortError2(error48) {
|
|
55148
|
-
return (error48 instanceof Error || error48 instanceof DOMException) && (error48.name === "AbortError" || error48.name === "ResponseAborted" || error48.name === "TimeoutError");
|
|
55149
|
-
}
|
|
55150
|
-
var FETCH_FAILED_ERROR_MESSAGES2 = ["fetch failed", "failed to fetch"];
|
|
55151
|
-
var BUN_ERROR_CODES2 = [
|
|
55152
|
-
"ConnectionRefused",
|
|
55153
|
-
"ConnectionClosed",
|
|
55154
|
-
"FailedToOpenSocket",
|
|
55155
|
-
"ECONNRESET",
|
|
55156
|
-
"ECONNREFUSED",
|
|
55157
|
-
"ETIMEDOUT",
|
|
55158
|
-
"EPIPE"
|
|
55159
|
-
];
|
|
55160
|
-
function isBunNetworkError2(error48) {
|
|
55161
|
-
if (!(error48 instanceof Error)) {
|
|
55162
|
-
return false;
|
|
55163
|
-
}
|
|
55164
|
-
const code = error48.code;
|
|
55165
|
-
if (typeof code === "string" && BUN_ERROR_CODES2.includes(code)) {
|
|
55166
|
-
return true;
|
|
55167
|
-
}
|
|
55168
|
-
return false;
|
|
55169
|
-
}
|
|
55170
|
-
function handleFetchError2({
|
|
55171
|
-
error: error48,
|
|
55172
|
-
url: url2,
|
|
55173
|
-
requestBodyValues
|
|
55178
|
+
// node_modules/ollama-ai-provider-v2/dist/index.mjs
|
|
55179
|
+
function convertToOllamaCompletionPrompt({
|
|
55180
|
+
prompt,
|
|
55181
|
+
user = "user",
|
|
55182
|
+
assistant = "assistant"
|
|
55174
55183
|
}) {
|
|
55175
|
-
|
|
55176
|
-
|
|
55177
|
-
|
|
55178
|
-
|
|
55179
|
-
|
|
55180
|
-
|
|
55181
|
-
return new APICallError({
|
|
55182
|
-
message: `Cannot connect to API: ${cause.message}`,
|
|
55183
|
-
cause,
|
|
55184
|
-
url: url2,
|
|
55185
|
-
requestBodyValues,
|
|
55186
|
-
isRetryable: true
|
|
55187
|
-
});
|
|
55188
|
-
}
|
|
55189
|
-
}
|
|
55190
|
-
if (isBunNetworkError2(error48)) {
|
|
55191
|
-
return new APICallError({
|
|
55192
|
-
message: `Cannot connect to API: ${error48.message}`,
|
|
55193
|
-
cause: error48,
|
|
55194
|
-
url: url2,
|
|
55195
|
-
requestBodyValues,
|
|
55196
|
-
isRetryable: true
|
|
55197
|
-
});
|
|
55198
|
-
}
|
|
55199
|
-
return error48;
|
|
55200
|
-
}
|
|
55201
|
-
function getRuntimeEnvironmentUserAgent2(globalThisAny = globalThis) {
|
|
55202
|
-
var _a23, _b22, _c;
|
|
55203
|
-
if (globalThisAny.window) {
|
|
55204
|
-
return `runtime/browser`;
|
|
55205
|
-
}
|
|
55206
|
-
if ((_a23 = globalThisAny.navigator) == null ? undefined : _a23.userAgent) {
|
|
55207
|
-
return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
|
|
55208
|
-
}
|
|
55209
|
-
if ((_c = (_b22 = globalThisAny.process) == null ? undefined : _b22.versions) == null ? undefined : _c.node) {
|
|
55210
|
-
return `runtime/node.js/${globalThisAny.process.version.substring(0)}`;
|
|
55211
|
-
}
|
|
55212
|
-
if (globalThisAny.EdgeRuntime) {
|
|
55213
|
-
return `runtime/vercel-edge`;
|
|
55214
|
-
}
|
|
55215
|
-
return "runtime/unknown";
|
|
55216
|
-
}
|
|
55217
|
-
function normalizeHeaders2(headers) {
|
|
55218
|
-
if (headers == null) {
|
|
55219
|
-
return {};
|
|
55184
|
+
let text = "";
|
|
55185
|
+
if (prompt[0].role === "system") {
|
|
55186
|
+
text += `${prompt[0].content}
|
|
55187
|
+
|
|
55188
|
+
`;
|
|
55189
|
+
prompt = prompt.slice(1);
|
|
55220
55190
|
}
|
|
55221
|
-
const
|
|
55222
|
-
|
|
55223
|
-
|
|
55224
|
-
|
|
55225
|
-
|
|
55226
|
-
|
|
55227
|
-
|
|
55228
|
-
headers = Object.entries(headers);
|
|
55229
|
-
}
|
|
55230
|
-
for (const [key, value] of headers) {
|
|
55231
|
-
if (value != null) {
|
|
55232
|
-
normalized[key.toLowerCase()] = value;
|
|
55191
|
+
for (const { role, content } of prompt) {
|
|
55192
|
+
switch (role) {
|
|
55193
|
+
case "system": {
|
|
55194
|
+
throw new InvalidPromptError({
|
|
55195
|
+
message: "Unexpected system message in prompt: ${content}",
|
|
55196
|
+
prompt
|
|
55197
|
+
});
|
|
55233
55198
|
}
|
|
55234
|
-
|
|
55235
|
-
|
|
55236
|
-
|
|
55237
|
-
|
|
55238
|
-
|
|
55239
|
-
|
|
55240
|
-
|
|
55241
|
-
|
|
55242
|
-
|
|
55243
|
-
}
|
|
55244
|
-
|
|
55245
|
-
|
|
55246
|
-
|
|
55247
|
-
function _parse3(text) {
|
|
55248
|
-
const obj = JSON.parse(text);
|
|
55249
|
-
if (obj === null || typeof obj !== "object") {
|
|
55250
|
-
return obj;
|
|
55251
|
-
}
|
|
55252
|
-
if (suspectProtoRx2.test(text) === false && suspectConstructorRx2.test(text) === false) {
|
|
55253
|
-
return obj;
|
|
55254
|
-
}
|
|
55255
|
-
return filter2(obj);
|
|
55256
|
-
}
|
|
55257
|
-
function filter2(obj) {
|
|
55258
|
-
let next = [obj];
|
|
55259
|
-
while (next.length) {
|
|
55260
|
-
const nodes = next;
|
|
55261
|
-
next = [];
|
|
55262
|
-
for (const node of nodes) {
|
|
55263
|
-
if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
|
|
55264
|
-
throw new SyntaxError("Object contains forbidden prototype property");
|
|
55199
|
+
case "user": {
|
|
55200
|
+
const userMessage = content.map((part) => {
|
|
55201
|
+
switch (part.type) {
|
|
55202
|
+
case "text": {
|
|
55203
|
+
return part.text;
|
|
55204
|
+
}
|
|
55205
|
+
}
|
|
55206
|
+
}).filter(Boolean).join("");
|
|
55207
|
+
text += `${user}:
|
|
55208
|
+
${userMessage}
|
|
55209
|
+
|
|
55210
|
+
`;
|
|
55211
|
+
break;
|
|
55265
55212
|
}
|
|
55266
|
-
|
|
55267
|
-
|
|
55213
|
+
case "assistant": {
|
|
55214
|
+
const assistantMessage = content.map((part) => {
|
|
55215
|
+
switch (part.type) {
|
|
55216
|
+
case "text": {
|
|
55217
|
+
return part.text;
|
|
55218
|
+
}
|
|
55219
|
+
case "tool-call": {
|
|
55220
|
+
throw new UnsupportedFunctionalityError({
|
|
55221
|
+
functionality: "tool-call messages"
|
|
55222
|
+
});
|
|
55223
|
+
}
|
|
55224
|
+
}
|
|
55225
|
+
}).join("");
|
|
55226
|
+
text += `${assistant}:
|
|
55227
|
+
${assistantMessage}
|
|
55228
|
+
|
|
55229
|
+
`;
|
|
55230
|
+
break;
|
|
55268
55231
|
}
|
|
55269
|
-
|
|
55270
|
-
|
|
55271
|
-
|
|
55272
|
-
|
|
55273
|
-
}
|
|
55232
|
+
case "tool": {
|
|
55233
|
+
throw new UnsupportedFunctionalityError({
|
|
55234
|
+
functionality: "tool messages"
|
|
55235
|
+
});
|
|
55274
55236
|
}
|
|
55275
|
-
|
|
55276
|
-
|
|
55277
|
-
|
|
55278
|
-
}
|
|
55279
|
-
function secureJsonParse2(text) {
|
|
55280
|
-
const { stackTraceLimit } = Error;
|
|
55281
|
-
try {
|
|
55282
|
-
Error.stackTraceLimit = 0;
|
|
55283
|
-
} catch (e) {
|
|
55284
|
-
return _parse3(text);
|
|
55285
|
-
}
|
|
55286
|
-
try {
|
|
55287
|
-
return _parse3(text);
|
|
55288
|
-
} finally {
|
|
55289
|
-
Error.stackTraceLimit = stackTraceLimit;
|
|
55290
|
-
}
|
|
55291
|
-
}
|
|
55292
|
-
function addAdditionalPropertiesToJsonSchema2(jsonSchema2) {
|
|
55293
|
-
if (jsonSchema2.type === "object" || Array.isArray(jsonSchema2.type) && jsonSchema2.type.includes("object")) {
|
|
55294
|
-
jsonSchema2.additionalProperties = false;
|
|
55295
|
-
const { properties } = jsonSchema2;
|
|
55296
|
-
if (properties != null) {
|
|
55297
|
-
for (const key of Object.keys(properties)) {
|
|
55298
|
-
properties[key] = visit2(properties[key]);
|
|
55237
|
+
default: {
|
|
55238
|
+
const _exhaustiveCheck = role;
|
|
55239
|
+
throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
|
|
55299
55240
|
}
|
|
55300
55241
|
}
|
|
55301
55242
|
}
|
|
55302
|
-
|
|
55303
|
-
|
|
55304
|
-
|
|
55305
|
-
|
|
55306
|
-
|
|
55307
|
-
|
|
55308
|
-
if (jsonSchema2.allOf != null) {
|
|
55309
|
-
jsonSchema2.allOf = jsonSchema2.allOf.map(visit2);
|
|
55310
|
-
}
|
|
55311
|
-
if (jsonSchema2.oneOf != null) {
|
|
55312
|
-
jsonSchema2.oneOf = jsonSchema2.oneOf.map(visit2);
|
|
55313
|
-
}
|
|
55314
|
-
const { definitions } = jsonSchema2;
|
|
55315
|
-
if (definitions != null) {
|
|
55316
|
-
for (const key of Object.keys(definitions)) {
|
|
55317
|
-
definitions[key] = visit2(definitions[key]);
|
|
55318
|
-
}
|
|
55319
|
-
}
|
|
55320
|
-
return jsonSchema2;
|
|
55321
|
-
}
|
|
55322
|
-
function visit2(def) {
|
|
55323
|
-
if (typeof def === "boolean")
|
|
55324
|
-
return def;
|
|
55325
|
-
return addAdditionalPropertiesToJsonSchema2(def);
|
|
55326
|
-
}
|
|
55327
|
-
var ignoreOverride2 = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
55328
|
-
var defaultOptions2 = {
|
|
55329
|
-
name: undefined,
|
|
55330
|
-
$refStrategy: "root",
|
|
55331
|
-
basePath: ["#"],
|
|
55332
|
-
effectStrategy: "input",
|
|
55333
|
-
pipeStrategy: "all",
|
|
55334
|
-
dateStrategy: "format:date-time",
|
|
55335
|
-
mapStrategy: "entries",
|
|
55336
|
-
removeAdditionalStrategy: "passthrough",
|
|
55337
|
-
allowedAdditionalProperties: true,
|
|
55338
|
-
rejectedAdditionalProperties: false,
|
|
55339
|
-
definitionPath: "definitions",
|
|
55340
|
-
strictUnions: false,
|
|
55341
|
-
definitions: {},
|
|
55342
|
-
errorMessages: false,
|
|
55343
|
-
patternStrategy: "escape",
|
|
55344
|
-
applyRegexFlags: false,
|
|
55345
|
-
emailStrategy: "format:email",
|
|
55346
|
-
base64Strategy: "contentEncoding:base64",
|
|
55347
|
-
nameStrategy: "ref"
|
|
55348
|
-
};
|
|
55349
|
-
var getDefaultOptions2 = (options) => typeof options === "string" ? {
|
|
55350
|
-
...defaultOptions2,
|
|
55351
|
-
name: options
|
|
55352
|
-
} : {
|
|
55353
|
-
...defaultOptions2,
|
|
55354
|
-
...options
|
|
55355
|
-
};
|
|
55356
|
-
function parseAnyDef2() {
|
|
55357
|
-
return {};
|
|
55358
|
-
}
|
|
55359
|
-
function parseArrayDef2(def, refs) {
|
|
55360
|
-
var _a23, _b22, _c;
|
|
55361
|
-
const res = {
|
|
55362
|
-
type: "array"
|
|
55363
|
-
};
|
|
55364
|
-
if (((_a23 = def.type) == null ? undefined : _a23._def) && ((_c = (_b22 = def.type) == null ? undefined : _b22._def) == null ? undefined : _c.typeName) !== ZodFirstPartyTypeKind2.ZodAny) {
|
|
55365
|
-
res.items = parseDef2(def.type._def, {
|
|
55366
|
-
...refs,
|
|
55367
|
-
currentPath: [...refs.currentPath, "items"]
|
|
55368
|
-
});
|
|
55369
|
-
}
|
|
55370
|
-
if (def.minLength) {
|
|
55371
|
-
res.minItems = def.minLength.value;
|
|
55372
|
-
}
|
|
55373
|
-
if (def.maxLength) {
|
|
55374
|
-
res.maxItems = def.maxLength.value;
|
|
55375
|
-
}
|
|
55376
|
-
if (def.exactLength) {
|
|
55377
|
-
res.minItems = def.exactLength.value;
|
|
55378
|
-
res.maxItems = def.exactLength.value;
|
|
55379
|
-
}
|
|
55380
|
-
return res;
|
|
55381
|
-
}
|
|
55382
|
-
function parseBigintDef2(def) {
|
|
55383
|
-
const res = {
|
|
55384
|
-
type: "integer",
|
|
55385
|
-
format: "int64"
|
|
55243
|
+
text += `${assistant}:
|
|
55244
|
+
`;
|
|
55245
|
+
return {
|
|
55246
|
+
prompt: text,
|
|
55247
|
+
stopSequences: [`
|
|
55248
|
+
${user}:`]
|
|
55386
55249
|
};
|
|
55387
|
-
if (!def.checks)
|
|
55388
|
-
return res;
|
|
55389
|
-
for (const check2 of def.checks) {
|
|
55390
|
-
switch (check2.kind) {
|
|
55391
|
-
case "min":
|
|
55392
|
-
if (check2.inclusive) {
|
|
55393
|
-
res.minimum = check2.value;
|
|
55394
|
-
} else {
|
|
55395
|
-
res.exclusiveMinimum = check2.value;
|
|
55396
|
-
}
|
|
55397
|
-
break;
|
|
55398
|
-
case "max":
|
|
55399
|
-
if (check2.inclusive) {
|
|
55400
|
-
res.maximum = check2.value;
|
|
55401
|
-
} else {
|
|
55402
|
-
res.exclusiveMaximum = check2.value;
|
|
55403
|
-
}
|
|
55404
|
-
break;
|
|
55405
|
-
case "multipleOf":
|
|
55406
|
-
res.multipleOf = check2.value;
|
|
55407
|
-
break;
|
|
55408
|
-
}
|
|
55409
|
-
}
|
|
55410
|
-
return res;
|
|
55411
55250
|
}
|
|
55412
|
-
function
|
|
55413
|
-
|
|
55414
|
-
|
|
55415
|
-
function parseBrandedDef2(_def, refs) {
|
|
55416
|
-
return parseDef2(_def.type._def, refs);
|
|
55417
|
-
}
|
|
55418
|
-
var parseCatchDef2 = (def, refs) => {
|
|
55419
|
-
return parseDef2(def.innerType._def, refs);
|
|
55420
|
-
};
|
|
55421
|
-
function parseDateDef2(def, refs, overrideDateStrategy) {
|
|
55422
|
-
const strategy = overrideDateStrategy != null ? overrideDateStrategy : refs.dateStrategy;
|
|
55423
|
-
if (Array.isArray(strategy)) {
|
|
55424
|
-
return {
|
|
55425
|
-
anyOf: strategy.map((item, i) => parseDateDef2(def, refs, item))
|
|
55426
|
-
};
|
|
55427
|
-
}
|
|
55428
|
-
switch (strategy) {
|
|
55429
|
-
case "string":
|
|
55430
|
-
case "format:date-time":
|
|
55251
|
+
function mapOllamaFinishReason(finishReason) {
|
|
55252
|
+
switch (finishReason) {
|
|
55253
|
+
case "stop":
|
|
55431
55254
|
return {
|
|
55432
|
-
|
|
55433
|
-
|
|
55255
|
+
raw: finishReason,
|
|
55256
|
+
unified: "stop"
|
|
55434
55257
|
};
|
|
55435
|
-
case "
|
|
55258
|
+
case "length":
|
|
55436
55259
|
return {
|
|
55437
|
-
|
|
55438
|
-
|
|
55260
|
+
raw: finishReason,
|
|
55261
|
+
unified: "length"
|
|
55262
|
+
};
|
|
55263
|
+
case "content_filter":
|
|
55264
|
+
return {
|
|
55265
|
+
raw: finishReason,
|
|
55266
|
+
unified: "content-filter"
|
|
55267
|
+
};
|
|
55268
|
+
case "function_call":
|
|
55269
|
+
case "tool_calls":
|
|
55270
|
+
return {
|
|
55271
|
+
raw: finishReason,
|
|
55272
|
+
unified: "tool-calls"
|
|
55273
|
+
};
|
|
55274
|
+
default:
|
|
55275
|
+
return {
|
|
55276
|
+
raw: finishReason,
|
|
55277
|
+
unified: "other"
|
|
55439
55278
|
};
|
|
55440
|
-
case "integer":
|
|
55441
|
-
return integerDateParser2(def);
|
|
55442
55279
|
}
|
|
55443
55280
|
}
|
|
55444
|
-
|
|
55445
|
-
|
|
55446
|
-
|
|
55447
|
-
|
|
55448
|
-
};
|
|
55449
|
-
for (const check2 of def.checks) {
|
|
55450
|
-
switch (check2.kind) {
|
|
55451
|
-
case "min":
|
|
55452
|
-
res.minimum = check2.value;
|
|
55453
|
-
break;
|
|
55454
|
-
case "max":
|
|
55455
|
-
res.maximum = check2.value;
|
|
55456
|
-
break;
|
|
55457
|
-
}
|
|
55458
|
-
}
|
|
55459
|
-
return res;
|
|
55460
|
-
};
|
|
55461
|
-
function parseDefaultDef2(_def, refs) {
|
|
55281
|
+
function getResponseMetadata5({
|
|
55282
|
+
model,
|
|
55283
|
+
created_at
|
|
55284
|
+
}) {
|
|
55462
55285
|
return {
|
|
55463
|
-
|
|
55464
|
-
|
|
55286
|
+
id: undefined,
|
|
55287
|
+
modelId: model != null ? model : undefined,
|
|
55288
|
+
timestamp: created_at != null ? new Date(created_at) : undefined
|
|
55465
55289
|
};
|
|
55466
55290
|
}
|
|
55467
|
-
function
|
|
55468
|
-
return
|
|
55469
|
-
|
|
55470
|
-
|
|
55471
|
-
|
|
55472
|
-
|
|
55473
|
-
|
|
55474
|
-
|
|
55475
|
-
|
|
55476
|
-
|
|
55477
|
-
|
|
55478
|
-
|
|
55479
|
-
|
|
55480
|
-
|
|
55481
|
-
|
|
55482
|
-
|
|
55483
|
-
|
|
55484
|
-
|
|
55485
|
-
|
|
55486
|
-
|
|
55487
|
-
|
|
55488
|
-
|
|
55489
|
-
|
|
55490
|
-
|
|
55491
|
-
|
|
55492
|
-
|
|
55493
|
-
|
|
55494
|
-
|
|
55495
|
-
|
|
55496
|
-
|
|
55497
|
-
|
|
55498
|
-
|
|
55499
|
-
|
|
55500
|
-
|
|
55501
|
-
|
|
55502
|
-
|
|
55503
|
-
|
|
55504
|
-
|
|
55505
|
-
|
|
55506
|
-
}
|
|
55507
|
-
|
|
55508
|
-
|
|
55509
|
-
|
|
55510
|
-
|
|
55511
|
-
|
|
55512
|
-
};
|
|
55513
|
-
|
|
55514
|
-
|
|
55515
|
-
|
|
55516
|
-
|
|
55517
|
-
};
|
|
55518
|
-
}
|
|
55519
|
-
var emojiRegex3 = undefined;
|
|
55520
|
-
var zodPatterns2 = {
|
|
55521
|
-
cuid: /^[cC][^\s-]{8,}$/,
|
|
55522
|
-
cuid2: /^[0-9a-z]+$/,
|
|
55523
|
-
ulid: /^[0-9A-HJKMNP-TV-Z]{26}$/,
|
|
55524
|
-
email: /^(?!\.)(?!.*\.\.)([a-zA-Z0-9_'+\-\.]*)[a-zA-Z0-9_+-]@([a-zA-Z0-9][a-zA-Z0-9\-]*\.)+[a-zA-Z]{2,}$/,
|
|
55525
|
-
emoji: () => {
|
|
55526
|
-
if (emojiRegex3 === undefined) {
|
|
55527
|
-
emojiRegex3 = RegExp("^(\\p{Extended_Pictographic}|\\p{Emoji_Component})+$", "u");
|
|
55528
|
-
}
|
|
55529
|
-
return emojiRegex3;
|
|
55530
|
-
},
|
|
55531
|
-
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}$/,
|
|
55532
|
-
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])$/,
|
|
55533
|
-
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])$/,
|
|
55534
|
-
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})))$/,
|
|
55535
|
-
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])$/,
|
|
55536
|
-
base64: /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/,
|
|
55537
|
-
base64url: /^([0-9a-zA-Z-_]{4})*(([0-9a-zA-Z-_]{2}(==)?)|([0-9a-zA-Z-_]{3}(=)?))?$/,
|
|
55538
|
-
nanoid: /^[a-zA-Z0-9_-]{21}$/,
|
|
55539
|
-
jwt: /^[A-Za-z0-9-_]+\.[A-Za-z0-9-_]+\.[A-Za-z0-9-_]*$/
|
|
55540
|
-
};
|
|
55541
|
-
function parseStringDef2(def, refs) {
|
|
55542
|
-
const res = {
|
|
55543
|
-
type: "string"
|
|
55544
|
-
};
|
|
55545
|
-
if (def.checks) {
|
|
55546
|
-
for (const check2 of def.checks) {
|
|
55547
|
-
switch (check2.kind) {
|
|
55548
|
-
case "min":
|
|
55549
|
-
res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check2.value) : check2.value;
|
|
55550
|
-
break;
|
|
55551
|
-
case "max":
|
|
55552
|
-
res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check2.value) : check2.value;
|
|
55553
|
-
break;
|
|
55554
|
-
case "email":
|
|
55555
|
-
switch (refs.emailStrategy) {
|
|
55556
|
-
case "format:email":
|
|
55557
|
-
addFormat2(res, "email", check2.message, refs);
|
|
55558
|
-
break;
|
|
55559
|
-
case "format:idn-email":
|
|
55560
|
-
addFormat2(res, "idn-email", check2.message, refs);
|
|
55561
|
-
break;
|
|
55562
|
-
case "pattern:zod":
|
|
55563
|
-
addPattern2(res, zodPatterns2.email, check2.message, refs);
|
|
55564
|
-
break;
|
|
55565
|
-
}
|
|
55566
|
-
break;
|
|
55567
|
-
case "url":
|
|
55568
|
-
addFormat2(res, "uri", check2.message, refs);
|
|
55569
|
-
break;
|
|
55570
|
-
case "uuid":
|
|
55571
|
-
addFormat2(res, "uuid", check2.message, refs);
|
|
55572
|
-
break;
|
|
55573
|
-
case "regex":
|
|
55574
|
-
addPattern2(res, check2.regex, check2.message, refs);
|
|
55575
|
-
break;
|
|
55576
|
-
case "cuid":
|
|
55577
|
-
addPattern2(res, zodPatterns2.cuid, check2.message, refs);
|
|
55578
|
-
break;
|
|
55579
|
-
case "cuid2":
|
|
55580
|
-
addPattern2(res, zodPatterns2.cuid2, check2.message, refs);
|
|
55581
|
-
break;
|
|
55582
|
-
case "startsWith":
|
|
55583
|
-
addPattern2(res, RegExp(`^${escapeLiteralCheckValue2(check2.value, refs)}`), check2.message, refs);
|
|
55584
|
-
break;
|
|
55585
|
-
case "endsWith":
|
|
55586
|
-
addPattern2(res, RegExp(`${escapeLiteralCheckValue2(check2.value, refs)}$`), check2.message, refs);
|
|
55587
|
-
break;
|
|
55588
|
-
case "datetime":
|
|
55589
|
-
addFormat2(res, "date-time", check2.message, refs);
|
|
55590
|
-
break;
|
|
55591
|
-
case "date":
|
|
55592
|
-
addFormat2(res, "date", check2.message, refs);
|
|
55593
|
-
break;
|
|
55594
|
-
case "time":
|
|
55595
|
-
addFormat2(res, "time", check2.message, refs);
|
|
55596
|
-
break;
|
|
55597
|
-
case "duration":
|
|
55598
|
-
addFormat2(res, "duration", check2.message, refs);
|
|
55599
|
-
break;
|
|
55600
|
-
case "length":
|
|
55601
|
-
res.minLength = typeof res.minLength === "number" ? Math.max(res.minLength, check2.value) : check2.value;
|
|
55602
|
-
res.maxLength = typeof res.maxLength === "number" ? Math.min(res.maxLength, check2.value) : check2.value;
|
|
55603
|
-
break;
|
|
55604
|
-
case "includes": {
|
|
55605
|
-
addPattern2(res, RegExp(escapeLiteralCheckValue2(check2.value, refs)), check2.message, refs);
|
|
55606
|
-
break;
|
|
55607
|
-
}
|
|
55608
|
-
case "ip": {
|
|
55609
|
-
if (check2.version !== "v6") {
|
|
55610
|
-
addFormat2(res, "ipv4", check2.message, refs);
|
|
55611
|
-
}
|
|
55612
|
-
if (check2.version !== "v4") {
|
|
55613
|
-
addFormat2(res, "ipv6", check2.message, refs);
|
|
55614
|
-
}
|
|
55615
|
-
break;
|
|
55616
|
-
}
|
|
55617
|
-
case "base64url":
|
|
55618
|
-
addPattern2(res, zodPatterns2.base64url, check2.message, refs);
|
|
55619
|
-
break;
|
|
55620
|
-
case "jwt":
|
|
55621
|
-
addPattern2(res, zodPatterns2.jwt, check2.message, refs);
|
|
55622
|
-
break;
|
|
55623
|
-
case "cidr": {
|
|
55624
|
-
if (check2.version !== "v6") {
|
|
55625
|
-
addPattern2(res, zodPatterns2.ipv4Cidr, check2.message, refs);
|
|
55626
|
-
}
|
|
55627
|
-
if (check2.version !== "v4") {
|
|
55628
|
-
addPattern2(res, zodPatterns2.ipv6Cidr, check2.message, refs);
|
|
55629
|
-
}
|
|
55630
|
-
break;
|
|
55631
|
-
}
|
|
55632
|
-
case "emoji":
|
|
55633
|
-
addPattern2(res, zodPatterns2.emoji(), check2.message, refs);
|
|
55634
|
-
break;
|
|
55635
|
-
case "ulid": {
|
|
55636
|
-
addPattern2(res, zodPatterns2.ulid, check2.message, refs);
|
|
55637
|
-
break;
|
|
55638
|
-
}
|
|
55639
|
-
case "base64": {
|
|
55640
|
-
switch (refs.base64Strategy) {
|
|
55641
|
-
case "format:binary": {
|
|
55642
|
-
addFormat2(res, "binary", check2.message, refs);
|
|
55643
|
-
break;
|
|
55644
|
-
}
|
|
55645
|
-
case "contentEncoding:base64": {
|
|
55646
|
-
res.contentEncoding = "base64";
|
|
55647
|
-
break;
|
|
55648
|
-
}
|
|
55649
|
-
case "pattern:zod": {
|
|
55650
|
-
addPattern2(res, zodPatterns2.base64, check2.message, refs);
|
|
55651
|
-
break;
|
|
55652
|
-
}
|
|
55653
|
-
}
|
|
55654
|
-
break;
|
|
55655
|
-
}
|
|
55656
|
-
case "nanoid": {
|
|
55657
|
-
addPattern2(res, zodPatterns2.nanoid, check2.message, refs);
|
|
55658
|
-
}
|
|
55659
|
-
case "toLowerCase":
|
|
55660
|
-
case "toUpperCase":
|
|
55661
|
-
case "trim":
|
|
55662
|
-
break;
|
|
55663
|
-
default:
|
|
55664
|
-
}
|
|
55665
|
-
}
|
|
55666
|
-
}
|
|
55667
|
-
return res;
|
|
55668
|
-
}
|
|
55669
|
-
function escapeLiteralCheckValue2(literal2, refs) {
|
|
55670
|
-
return refs.patternStrategy === "escape" ? escapeNonAlphaNumeric2(literal2) : literal2;
|
|
55671
|
-
}
|
|
55672
|
-
var ALPHA_NUMERIC2 = new Set("ABCDEFGHIJKLMNOPQRSTUVXYZabcdefghijklmnopqrstuvxyz0123456789");
|
|
55673
|
-
function escapeNonAlphaNumeric2(source) {
|
|
55674
|
-
let result = "";
|
|
55675
|
-
for (let i = 0;i < source.length; i++) {
|
|
55676
|
-
if (!ALPHA_NUMERIC2.has(source[i])) {
|
|
55677
|
-
result += "\\";
|
|
55678
|
-
}
|
|
55679
|
-
result += source[i];
|
|
55680
|
-
}
|
|
55681
|
-
return result;
|
|
55682
|
-
}
|
|
55683
|
-
function addFormat2(schema, value, message, refs) {
|
|
55684
|
-
var _a23;
|
|
55685
|
-
if (schema.format || ((_a23 = schema.anyOf) == null ? undefined : _a23.some((x) => x.format))) {
|
|
55686
|
-
if (!schema.anyOf) {
|
|
55687
|
-
schema.anyOf = [];
|
|
55688
|
-
}
|
|
55689
|
-
if (schema.format) {
|
|
55690
|
-
schema.anyOf.push({
|
|
55691
|
-
format: schema.format
|
|
55692
|
-
});
|
|
55693
|
-
delete schema.format;
|
|
55694
|
-
}
|
|
55695
|
-
schema.anyOf.push({
|
|
55696
|
-
format: value,
|
|
55697
|
-
...message && refs.errorMessages && { errorMessage: { format: message } }
|
|
55698
|
-
});
|
|
55699
|
-
} else {
|
|
55700
|
-
schema.format = value;
|
|
55701
|
-
}
|
|
55702
|
-
}
|
|
55703
|
-
function addPattern2(schema, regex, message, refs) {
|
|
55704
|
-
var _a23;
|
|
55705
|
-
if (schema.pattern || ((_a23 = schema.allOf) == null ? undefined : _a23.some((x) => x.pattern))) {
|
|
55706
|
-
if (!schema.allOf) {
|
|
55707
|
-
schema.allOf = [];
|
|
55708
|
-
}
|
|
55709
|
-
if (schema.pattern) {
|
|
55710
|
-
schema.allOf.push({
|
|
55711
|
-
pattern: schema.pattern
|
|
55712
|
-
});
|
|
55713
|
-
delete schema.pattern;
|
|
55714
|
-
}
|
|
55715
|
-
schema.allOf.push({
|
|
55716
|
-
pattern: stringifyRegExpWithFlags2(regex, refs),
|
|
55717
|
-
...message && refs.errorMessages && { errorMessage: { pattern: message } }
|
|
55718
|
-
});
|
|
55719
|
-
} else {
|
|
55720
|
-
schema.pattern = stringifyRegExpWithFlags2(regex, refs);
|
|
55721
|
-
}
|
|
55722
|
-
}
|
|
55723
|
-
function stringifyRegExpWithFlags2(regex, refs) {
|
|
55724
|
-
var _a23;
|
|
55725
|
-
if (!refs.applyRegexFlags || !regex.flags) {
|
|
55726
|
-
return regex.source;
|
|
55727
|
-
}
|
|
55728
|
-
const flags = {
|
|
55729
|
-
i: regex.flags.includes("i"),
|
|
55730
|
-
m: regex.flags.includes("m"),
|
|
55731
|
-
s: regex.flags.includes("s")
|
|
55732
|
-
};
|
|
55733
|
-
const source = flags.i ? regex.source.toLowerCase() : regex.source;
|
|
55734
|
-
let pattern = "";
|
|
55735
|
-
let isEscaped = false;
|
|
55736
|
-
let inCharGroup = false;
|
|
55737
|
-
let inCharRange = false;
|
|
55738
|
-
for (let i = 0;i < source.length; i++) {
|
|
55739
|
-
if (isEscaped) {
|
|
55740
|
-
pattern += source[i];
|
|
55741
|
-
isEscaped = false;
|
|
55742
|
-
continue;
|
|
55743
|
-
}
|
|
55744
|
-
if (flags.i) {
|
|
55745
|
-
if (inCharGroup) {
|
|
55746
|
-
if (source[i].match(/[a-z]/)) {
|
|
55747
|
-
if (inCharRange) {
|
|
55748
|
-
pattern += source[i];
|
|
55749
|
-
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
55750
|
-
inCharRange = false;
|
|
55751
|
-
} else if (source[i + 1] === "-" && ((_a23 = source[i + 2]) == null ? undefined : _a23.match(/[a-z]/))) {
|
|
55752
|
-
pattern += source[i];
|
|
55753
|
-
inCharRange = true;
|
|
55754
|
-
} else {
|
|
55755
|
-
pattern += `${source[i]}${source[i].toUpperCase()}`;
|
|
55756
|
-
}
|
|
55757
|
-
continue;
|
|
55758
|
-
}
|
|
55759
|
-
} else if (source[i].match(/[a-z]/)) {
|
|
55760
|
-
pattern += `[${source[i]}${source[i].toUpperCase()}]`;
|
|
55761
|
-
continue;
|
|
55762
|
-
}
|
|
55763
|
-
}
|
|
55764
|
-
if (flags.m) {
|
|
55765
|
-
if (source[i] === "^") {
|
|
55766
|
-
pattern += `(^|(?<=[\r
|
|
55767
|
-
]))`;
|
|
55768
|
-
continue;
|
|
55769
|
-
} else if (source[i] === "$") {
|
|
55770
|
-
pattern += `($|(?=[\r
|
|
55771
|
-
]))`;
|
|
55772
|
-
continue;
|
|
55773
|
-
}
|
|
55774
|
-
}
|
|
55775
|
-
if (flags.s && source[i] === ".") {
|
|
55776
|
-
pattern += inCharGroup ? `${source[i]}\r
|
|
55777
|
-
` : `[${source[i]}\r
|
|
55778
|
-
]`;
|
|
55779
|
-
continue;
|
|
55780
|
-
}
|
|
55781
|
-
pattern += source[i];
|
|
55782
|
-
if (source[i] === "\\") {
|
|
55783
|
-
isEscaped = true;
|
|
55784
|
-
} else if (inCharGroup && source[i] === "]") {
|
|
55785
|
-
inCharGroup = false;
|
|
55786
|
-
} else if (!inCharGroup && source[i] === "[") {
|
|
55787
|
-
inCharGroup = true;
|
|
55788
|
-
}
|
|
55789
|
-
}
|
|
55790
|
-
try {
|
|
55791
|
-
new RegExp(pattern);
|
|
55792
|
-
} catch (e) {
|
|
55793
|
-
console.warn(`Could not convert regex pattern at ${refs.currentPath.join("/")} to a flag-independent form! Falling back to the flag-ignorant source`);
|
|
55794
|
-
return regex.source;
|
|
55795
|
-
}
|
|
55796
|
-
return pattern;
|
|
55797
|
-
}
|
|
55798
|
-
function parseRecordDef2(def, refs) {
|
|
55799
|
-
var _a23, _b22, _c, _d, _e, _f;
|
|
55800
|
-
const schema = {
|
|
55801
|
-
type: "object",
|
|
55802
|
-
additionalProperties: (_a23 = parseDef2(def.valueType._def, {
|
|
55803
|
-
...refs,
|
|
55804
|
-
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
55805
|
-
})) != null ? _a23 : refs.allowedAdditionalProperties
|
|
55806
|
-
};
|
|
55807
|
-
if (((_b22 = def.keyType) == null ? undefined : _b22._def.typeName) === ZodFirstPartyTypeKind2.ZodString && ((_c = def.keyType._def.checks) == null ? undefined : _c.length)) {
|
|
55808
|
-
const { type, ...keyType } = parseStringDef2(def.keyType._def, refs);
|
|
55809
|
-
return {
|
|
55810
|
-
...schema,
|
|
55811
|
-
propertyNames: keyType
|
|
55812
|
-
};
|
|
55813
|
-
} else if (((_d = def.keyType) == null ? undefined : _d._def.typeName) === ZodFirstPartyTypeKind2.ZodEnum) {
|
|
55814
|
-
return {
|
|
55815
|
-
...schema,
|
|
55816
|
-
propertyNames: {
|
|
55817
|
-
enum: def.keyType._def.values
|
|
55818
|
-
}
|
|
55819
|
-
};
|
|
55820
|
-
} 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)) {
|
|
55821
|
-
const { type, ...keyType } = parseBrandedDef2(def.keyType._def, refs);
|
|
55822
|
-
return {
|
|
55823
|
-
...schema,
|
|
55824
|
-
propertyNames: keyType
|
|
55825
|
-
};
|
|
55826
|
-
}
|
|
55827
|
-
return schema;
|
|
55828
|
-
}
|
|
55829
|
-
function parseMapDef2(def, refs) {
|
|
55830
|
-
if (refs.mapStrategy === "record") {
|
|
55831
|
-
return parseRecordDef2(def, refs);
|
|
55832
|
-
}
|
|
55833
|
-
const keys = parseDef2(def.keyType._def, {
|
|
55834
|
-
...refs,
|
|
55835
|
-
currentPath: [...refs.currentPath, "items", "items", "0"]
|
|
55836
|
-
}) || parseAnyDef2();
|
|
55837
|
-
const values = parseDef2(def.valueType._def, {
|
|
55838
|
-
...refs,
|
|
55839
|
-
currentPath: [...refs.currentPath, "items", "items", "1"]
|
|
55840
|
-
}) || parseAnyDef2();
|
|
55841
|
-
return {
|
|
55842
|
-
type: "array",
|
|
55843
|
-
maxItems: 125,
|
|
55844
|
-
items: {
|
|
55845
|
-
type: "array",
|
|
55846
|
-
items: [keys, values],
|
|
55847
|
-
minItems: 2,
|
|
55848
|
-
maxItems: 2
|
|
55849
|
-
}
|
|
55850
|
-
};
|
|
55851
|
-
}
|
|
55852
|
-
function parseNativeEnumDef2(def) {
|
|
55853
|
-
const object2 = def.values;
|
|
55854
|
-
const actualKeys = Object.keys(def.values).filter((key) => {
|
|
55855
|
-
return typeof object2[object2[key]] !== "number";
|
|
55856
|
-
});
|
|
55857
|
-
const actualValues = actualKeys.map((key) => object2[key]);
|
|
55858
|
-
const parsedTypes = Array.from(new Set(actualValues.map((values) => typeof values)));
|
|
55859
|
-
return {
|
|
55860
|
-
type: parsedTypes.length === 1 ? parsedTypes[0] === "string" ? "string" : "number" : ["string", "number"],
|
|
55861
|
-
enum: actualValues
|
|
55862
|
-
};
|
|
55863
|
-
}
|
|
55864
|
-
function parseNeverDef2() {
|
|
55865
|
-
return { not: parseAnyDef2() };
|
|
55866
|
-
}
|
|
55867
|
-
function parseNullDef2() {
|
|
55868
|
-
return {
|
|
55869
|
-
type: "null"
|
|
55870
|
-
};
|
|
55871
|
-
}
|
|
55872
|
-
var primitiveMappings2 = {
|
|
55873
|
-
ZodString: "string",
|
|
55874
|
-
ZodNumber: "number",
|
|
55875
|
-
ZodBigInt: "integer",
|
|
55876
|
-
ZodBoolean: "boolean",
|
|
55877
|
-
ZodNull: "null"
|
|
55878
|
-
};
|
|
55879
|
-
function parseUnionDef2(def, refs) {
|
|
55880
|
-
const options = def.options instanceof Map ? Array.from(def.options.values()) : def.options;
|
|
55881
|
-
if (options.every((x) => (x._def.typeName in primitiveMappings2) && (!x._def.checks || !x._def.checks.length))) {
|
|
55882
|
-
const types = options.reduce((types2, x) => {
|
|
55883
|
-
const type = primitiveMappings2[x._def.typeName];
|
|
55884
|
-
return type && !types2.includes(type) ? [...types2, type] : types2;
|
|
55885
|
-
}, []);
|
|
55886
|
-
return {
|
|
55887
|
-
type: types.length > 1 ? types : types[0]
|
|
55888
|
-
};
|
|
55889
|
-
} else if (options.every((x) => x._def.typeName === "ZodLiteral" && !x.description)) {
|
|
55890
|
-
const types = options.reduce((acc, x) => {
|
|
55891
|
-
const type = typeof x._def.value;
|
|
55892
|
-
switch (type) {
|
|
55893
|
-
case "string":
|
|
55894
|
-
case "number":
|
|
55895
|
-
case "boolean":
|
|
55896
|
-
return [...acc, type];
|
|
55897
|
-
case "bigint":
|
|
55898
|
-
return [...acc, "integer"];
|
|
55899
|
-
case "object":
|
|
55900
|
-
if (x._def.value === null)
|
|
55901
|
-
return [...acc, "null"];
|
|
55902
|
-
case "symbol":
|
|
55903
|
-
case "undefined":
|
|
55904
|
-
case "function":
|
|
55905
|
-
default:
|
|
55906
|
-
return acc;
|
|
55907
|
-
}
|
|
55908
|
-
}, []);
|
|
55909
|
-
if (types.length === options.length) {
|
|
55910
|
-
const uniqueTypes = types.filter((x, i, a) => a.indexOf(x) === i);
|
|
55911
|
-
return {
|
|
55912
|
-
type: uniqueTypes.length > 1 ? uniqueTypes : uniqueTypes[0],
|
|
55913
|
-
enum: options.reduce((acc, x) => {
|
|
55914
|
-
return acc.includes(x._def.value) ? acc : [...acc, x._def.value];
|
|
55915
|
-
}, [])
|
|
55916
|
-
};
|
|
55917
|
-
}
|
|
55918
|
-
} else if (options.every((x) => x._def.typeName === "ZodEnum")) {
|
|
55919
|
-
return {
|
|
55920
|
-
type: "string",
|
|
55921
|
-
enum: options.reduce((acc, x) => [
|
|
55922
|
-
...acc,
|
|
55923
|
-
...x._def.values.filter((x2) => !acc.includes(x2))
|
|
55924
|
-
], [])
|
|
55925
|
-
};
|
|
55926
|
-
}
|
|
55927
|
-
return asAnyOf2(def, refs);
|
|
55928
|
-
}
|
|
55929
|
-
var asAnyOf2 = (def, refs) => {
|
|
55930
|
-
const anyOf = (def.options instanceof Map ? Array.from(def.options.values()) : def.options).map((x, i) => parseDef2(x._def, {
|
|
55931
|
-
...refs,
|
|
55932
|
-
currentPath: [...refs.currentPath, "anyOf", `${i}`]
|
|
55933
|
-
})).filter((x) => !!x && (!refs.strictUnions || typeof x === "object" && Object.keys(x).length > 0));
|
|
55934
|
-
return anyOf.length ? { anyOf } : undefined;
|
|
55935
|
-
};
|
|
55936
|
-
function parseNullableDef2(def, refs) {
|
|
55937
|
-
if (["ZodString", "ZodNumber", "ZodBigInt", "ZodBoolean", "ZodNull"].includes(def.innerType._def.typeName) && (!def.innerType._def.checks || !def.innerType._def.checks.length)) {
|
|
55938
|
-
return {
|
|
55939
|
-
type: [
|
|
55940
|
-
primitiveMappings2[def.innerType._def.typeName],
|
|
55941
|
-
"null"
|
|
55942
|
-
]
|
|
55943
|
-
};
|
|
55944
|
-
}
|
|
55945
|
-
const base = parseDef2(def.innerType._def, {
|
|
55946
|
-
...refs,
|
|
55947
|
-
currentPath: [...refs.currentPath, "anyOf", "0"]
|
|
55948
|
-
});
|
|
55949
|
-
return base && { anyOf: [base, { type: "null" }] };
|
|
55950
|
-
}
|
|
55951
|
-
function parseNumberDef2(def) {
|
|
55952
|
-
const res = {
|
|
55953
|
-
type: "number"
|
|
55954
|
-
};
|
|
55955
|
-
if (!def.checks)
|
|
55956
|
-
return res;
|
|
55957
|
-
for (const check2 of def.checks) {
|
|
55958
|
-
switch (check2.kind) {
|
|
55959
|
-
case "int":
|
|
55960
|
-
res.type = "integer";
|
|
55961
|
-
break;
|
|
55962
|
-
case "min":
|
|
55963
|
-
if (check2.inclusive) {
|
|
55964
|
-
res.minimum = check2.value;
|
|
55965
|
-
} else {
|
|
55966
|
-
res.exclusiveMinimum = check2.value;
|
|
55967
|
-
}
|
|
55968
|
-
break;
|
|
55969
|
-
case "max":
|
|
55970
|
-
if (check2.inclusive) {
|
|
55971
|
-
res.maximum = check2.value;
|
|
55972
|
-
} else {
|
|
55973
|
-
res.exclusiveMaximum = check2.value;
|
|
55974
|
-
}
|
|
55975
|
-
break;
|
|
55976
|
-
case "multipleOf":
|
|
55977
|
-
res.multipleOf = check2.value;
|
|
55978
|
-
break;
|
|
55979
|
-
}
|
|
55980
|
-
}
|
|
55981
|
-
return res;
|
|
55982
|
-
}
|
|
55983
|
-
function parseObjectDef2(def, refs) {
|
|
55984
|
-
const result = {
|
|
55985
|
-
type: "object",
|
|
55986
|
-
properties: {}
|
|
55987
|
-
};
|
|
55988
|
-
const required2 = [];
|
|
55989
|
-
const shape = def.shape();
|
|
55990
|
-
for (const propName in shape) {
|
|
55991
|
-
let propDef = shape[propName];
|
|
55992
|
-
if (propDef === undefined || propDef._def === undefined) {
|
|
55993
|
-
continue;
|
|
55994
|
-
}
|
|
55995
|
-
const propOptional = safeIsOptional2(propDef);
|
|
55996
|
-
const parsedDef = parseDef2(propDef._def, {
|
|
55997
|
-
...refs,
|
|
55998
|
-
currentPath: [...refs.currentPath, "properties", propName],
|
|
55999
|
-
propertyPath: [...refs.currentPath, "properties", propName]
|
|
56000
|
-
});
|
|
56001
|
-
if (parsedDef === undefined) {
|
|
56002
|
-
continue;
|
|
56003
|
-
}
|
|
56004
|
-
result.properties[propName] = parsedDef;
|
|
56005
|
-
if (!propOptional) {
|
|
56006
|
-
required2.push(propName);
|
|
56007
|
-
}
|
|
56008
|
-
}
|
|
56009
|
-
if (required2.length) {
|
|
56010
|
-
result.required = required2;
|
|
56011
|
-
}
|
|
56012
|
-
const additionalProperties = decideAdditionalProperties2(def, refs);
|
|
56013
|
-
if (additionalProperties !== undefined) {
|
|
56014
|
-
result.additionalProperties = additionalProperties;
|
|
56015
|
-
}
|
|
56016
|
-
return result;
|
|
56017
|
-
}
|
|
56018
|
-
function decideAdditionalProperties2(def, refs) {
|
|
56019
|
-
if (def.catchall._def.typeName !== "ZodNever") {
|
|
56020
|
-
return parseDef2(def.catchall._def, {
|
|
56021
|
-
...refs,
|
|
56022
|
-
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
56023
|
-
});
|
|
56024
|
-
}
|
|
56025
|
-
switch (def.unknownKeys) {
|
|
56026
|
-
case "passthrough":
|
|
56027
|
-
return refs.allowedAdditionalProperties;
|
|
56028
|
-
case "strict":
|
|
56029
|
-
return refs.rejectedAdditionalProperties;
|
|
56030
|
-
case "strip":
|
|
56031
|
-
return refs.removeAdditionalStrategy === "strict" ? refs.allowedAdditionalProperties : refs.rejectedAdditionalProperties;
|
|
56032
|
-
}
|
|
56033
|
-
}
|
|
56034
|
-
function safeIsOptional2(schema) {
|
|
56035
|
-
try {
|
|
56036
|
-
return schema.isOptional();
|
|
56037
|
-
} catch (e) {
|
|
56038
|
-
return true;
|
|
56039
|
-
}
|
|
56040
|
-
}
|
|
56041
|
-
var parseOptionalDef2 = (def, refs) => {
|
|
56042
|
-
var _a23;
|
|
56043
|
-
if (refs.currentPath.toString() === ((_a23 = refs.propertyPath) == null ? undefined : _a23.toString())) {
|
|
56044
|
-
return parseDef2(def.innerType._def, refs);
|
|
56045
|
-
}
|
|
56046
|
-
const innerSchema = parseDef2(def.innerType._def, {
|
|
56047
|
-
...refs,
|
|
56048
|
-
currentPath: [...refs.currentPath, "anyOf", "1"]
|
|
56049
|
-
});
|
|
56050
|
-
return innerSchema ? { anyOf: [{ not: parseAnyDef2() }, innerSchema] } : parseAnyDef2();
|
|
56051
|
-
};
|
|
56052
|
-
var parsePipelineDef2 = (def, refs) => {
|
|
56053
|
-
if (refs.pipeStrategy === "input") {
|
|
56054
|
-
return parseDef2(def.in._def, refs);
|
|
56055
|
-
} else if (refs.pipeStrategy === "output") {
|
|
56056
|
-
return parseDef2(def.out._def, refs);
|
|
56057
|
-
}
|
|
56058
|
-
const a = parseDef2(def.in._def, {
|
|
56059
|
-
...refs,
|
|
56060
|
-
currentPath: [...refs.currentPath, "allOf", "0"]
|
|
56061
|
-
});
|
|
56062
|
-
const b = parseDef2(def.out._def, {
|
|
56063
|
-
...refs,
|
|
56064
|
-
currentPath: [...refs.currentPath, "allOf", a ? "1" : "0"]
|
|
56065
|
-
});
|
|
56066
|
-
return {
|
|
56067
|
-
allOf: [a, b].filter((x) => x !== undefined)
|
|
56068
|
-
};
|
|
56069
|
-
};
|
|
56070
|
-
function parsePromiseDef2(def, refs) {
|
|
56071
|
-
return parseDef2(def.type._def, refs);
|
|
56072
|
-
}
|
|
56073
|
-
function parseSetDef2(def, refs) {
|
|
56074
|
-
const items = parseDef2(def.valueType._def, {
|
|
56075
|
-
...refs,
|
|
56076
|
-
currentPath: [...refs.currentPath, "items"]
|
|
56077
|
-
});
|
|
56078
|
-
const schema = {
|
|
56079
|
-
type: "array",
|
|
56080
|
-
uniqueItems: true,
|
|
56081
|
-
items
|
|
56082
|
-
};
|
|
56083
|
-
if (def.minSize) {
|
|
56084
|
-
schema.minItems = def.minSize.value;
|
|
56085
|
-
}
|
|
56086
|
-
if (def.maxSize) {
|
|
56087
|
-
schema.maxItems = def.maxSize.value;
|
|
56088
|
-
}
|
|
56089
|
-
return schema;
|
|
56090
|
-
}
|
|
56091
|
-
function parseTupleDef2(def, refs) {
|
|
56092
|
-
if (def.rest) {
|
|
56093
|
-
return {
|
|
56094
|
-
type: "array",
|
|
56095
|
-
minItems: def.items.length,
|
|
56096
|
-
items: def.items.map((x, i) => parseDef2(x._def, {
|
|
56097
|
-
...refs,
|
|
56098
|
-
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
56099
|
-
})).reduce((acc, x) => x === undefined ? acc : [...acc, x], []),
|
|
56100
|
-
additionalItems: parseDef2(def.rest._def, {
|
|
56101
|
-
...refs,
|
|
56102
|
-
currentPath: [...refs.currentPath, "additionalItems"]
|
|
56103
|
-
})
|
|
56104
|
-
};
|
|
56105
|
-
} else {
|
|
56106
|
-
return {
|
|
56107
|
-
type: "array",
|
|
56108
|
-
minItems: def.items.length,
|
|
56109
|
-
maxItems: def.items.length,
|
|
56110
|
-
items: def.items.map((x, i) => parseDef2(x._def, {
|
|
56111
|
-
...refs,
|
|
56112
|
-
currentPath: [...refs.currentPath, "items", `${i}`]
|
|
56113
|
-
})).reduce((acc, x) => x === undefined ? acc : [...acc, x], [])
|
|
56114
|
-
};
|
|
56115
|
-
}
|
|
56116
|
-
}
|
|
56117
|
-
function parseUndefinedDef2() {
|
|
56118
|
-
return {
|
|
56119
|
-
not: parseAnyDef2()
|
|
56120
|
-
};
|
|
56121
|
-
}
|
|
56122
|
-
function parseUnknownDef2() {
|
|
56123
|
-
return parseAnyDef2();
|
|
56124
|
-
}
|
|
56125
|
-
var parseReadonlyDef2 = (def, refs) => {
|
|
56126
|
-
return parseDef2(def.innerType._def, refs);
|
|
56127
|
-
};
|
|
56128
|
-
var selectParser2 = (def, typeName, refs) => {
|
|
56129
|
-
switch (typeName) {
|
|
56130
|
-
case ZodFirstPartyTypeKind2.ZodString:
|
|
56131
|
-
return parseStringDef2(def, refs);
|
|
56132
|
-
case ZodFirstPartyTypeKind2.ZodNumber:
|
|
56133
|
-
return parseNumberDef2(def);
|
|
56134
|
-
case ZodFirstPartyTypeKind2.ZodObject:
|
|
56135
|
-
return parseObjectDef2(def, refs);
|
|
56136
|
-
case ZodFirstPartyTypeKind2.ZodBigInt:
|
|
56137
|
-
return parseBigintDef2(def);
|
|
56138
|
-
case ZodFirstPartyTypeKind2.ZodBoolean:
|
|
56139
|
-
return parseBooleanDef2();
|
|
56140
|
-
case ZodFirstPartyTypeKind2.ZodDate:
|
|
56141
|
-
return parseDateDef2(def, refs);
|
|
56142
|
-
case ZodFirstPartyTypeKind2.ZodUndefined:
|
|
56143
|
-
return parseUndefinedDef2();
|
|
56144
|
-
case ZodFirstPartyTypeKind2.ZodNull:
|
|
56145
|
-
return parseNullDef2();
|
|
56146
|
-
case ZodFirstPartyTypeKind2.ZodArray:
|
|
56147
|
-
return parseArrayDef2(def, refs);
|
|
56148
|
-
case ZodFirstPartyTypeKind2.ZodUnion:
|
|
56149
|
-
case ZodFirstPartyTypeKind2.ZodDiscriminatedUnion:
|
|
56150
|
-
return parseUnionDef2(def, refs);
|
|
56151
|
-
case ZodFirstPartyTypeKind2.ZodIntersection:
|
|
56152
|
-
return parseIntersectionDef2(def, refs);
|
|
56153
|
-
case ZodFirstPartyTypeKind2.ZodTuple:
|
|
56154
|
-
return parseTupleDef2(def, refs);
|
|
56155
|
-
case ZodFirstPartyTypeKind2.ZodRecord:
|
|
56156
|
-
return parseRecordDef2(def, refs);
|
|
56157
|
-
case ZodFirstPartyTypeKind2.ZodLiteral:
|
|
56158
|
-
return parseLiteralDef2(def);
|
|
56159
|
-
case ZodFirstPartyTypeKind2.ZodEnum:
|
|
56160
|
-
return parseEnumDef2(def);
|
|
56161
|
-
case ZodFirstPartyTypeKind2.ZodNativeEnum:
|
|
56162
|
-
return parseNativeEnumDef2(def);
|
|
56163
|
-
case ZodFirstPartyTypeKind2.ZodNullable:
|
|
56164
|
-
return parseNullableDef2(def, refs);
|
|
56165
|
-
case ZodFirstPartyTypeKind2.ZodOptional:
|
|
56166
|
-
return parseOptionalDef2(def, refs);
|
|
56167
|
-
case ZodFirstPartyTypeKind2.ZodMap:
|
|
56168
|
-
return parseMapDef2(def, refs);
|
|
56169
|
-
case ZodFirstPartyTypeKind2.ZodSet:
|
|
56170
|
-
return parseSetDef2(def, refs);
|
|
56171
|
-
case ZodFirstPartyTypeKind2.ZodLazy:
|
|
56172
|
-
return () => def.getter()._def;
|
|
56173
|
-
case ZodFirstPartyTypeKind2.ZodPromise:
|
|
56174
|
-
return parsePromiseDef2(def, refs);
|
|
56175
|
-
case ZodFirstPartyTypeKind2.ZodNaN:
|
|
56176
|
-
case ZodFirstPartyTypeKind2.ZodNever:
|
|
56177
|
-
return parseNeverDef2();
|
|
56178
|
-
case ZodFirstPartyTypeKind2.ZodEffects:
|
|
56179
|
-
return parseEffectsDef2(def, refs);
|
|
56180
|
-
case ZodFirstPartyTypeKind2.ZodAny:
|
|
56181
|
-
return parseAnyDef2();
|
|
56182
|
-
case ZodFirstPartyTypeKind2.ZodUnknown:
|
|
56183
|
-
return parseUnknownDef2();
|
|
56184
|
-
case ZodFirstPartyTypeKind2.ZodDefault:
|
|
56185
|
-
return parseDefaultDef2(def, refs);
|
|
56186
|
-
case ZodFirstPartyTypeKind2.ZodBranded:
|
|
56187
|
-
return parseBrandedDef2(def, refs);
|
|
56188
|
-
case ZodFirstPartyTypeKind2.ZodReadonly:
|
|
56189
|
-
return parseReadonlyDef2(def, refs);
|
|
56190
|
-
case ZodFirstPartyTypeKind2.ZodCatch:
|
|
56191
|
-
return parseCatchDef2(def, refs);
|
|
56192
|
-
case ZodFirstPartyTypeKind2.ZodPipeline:
|
|
56193
|
-
return parsePipelineDef2(def, refs);
|
|
56194
|
-
case ZodFirstPartyTypeKind2.ZodFunction:
|
|
56195
|
-
case ZodFirstPartyTypeKind2.ZodVoid:
|
|
56196
|
-
case ZodFirstPartyTypeKind2.ZodSymbol:
|
|
56197
|
-
return;
|
|
56198
|
-
default:
|
|
56199
|
-
return /* @__PURE__ */ ((_) => {
|
|
56200
|
-
return;
|
|
56201
|
-
})(typeName);
|
|
56202
|
-
}
|
|
56203
|
-
};
|
|
56204
|
-
var getRelativePath2 = (pathA, pathB) => {
|
|
56205
|
-
let i = 0;
|
|
56206
|
-
for (;i < pathA.length && i < pathB.length; i++) {
|
|
56207
|
-
if (pathA[i] !== pathB[i])
|
|
56208
|
-
break;
|
|
56209
|
-
}
|
|
56210
|
-
return [(pathA.length - i).toString(), ...pathB.slice(i)].join("/");
|
|
56211
|
-
};
|
|
56212
|
-
function parseDef2(def, refs, forceResolution = false) {
|
|
56213
|
-
var _a23;
|
|
56214
|
-
const seenItem = refs.seen.get(def);
|
|
56215
|
-
if (refs.override) {
|
|
56216
|
-
const overrideResult = (_a23 = refs.override) == null ? undefined : _a23.call(refs, def, refs, seenItem, forceResolution);
|
|
56217
|
-
if (overrideResult !== ignoreOverride2) {
|
|
56218
|
-
return overrideResult;
|
|
56219
|
-
}
|
|
56220
|
-
}
|
|
56221
|
-
if (seenItem && !forceResolution) {
|
|
56222
|
-
const seenSchema = get$ref2(seenItem, refs);
|
|
56223
|
-
if (seenSchema !== undefined) {
|
|
56224
|
-
return seenSchema;
|
|
56225
|
-
}
|
|
56226
|
-
}
|
|
56227
|
-
const newItem = { def, path: refs.currentPath, jsonSchema: undefined };
|
|
56228
|
-
refs.seen.set(def, newItem);
|
|
56229
|
-
const jsonSchemaOrGetter = selectParser2(def, def.typeName, refs);
|
|
56230
|
-
const jsonSchema2 = typeof jsonSchemaOrGetter === "function" ? parseDef2(jsonSchemaOrGetter(), refs) : jsonSchemaOrGetter;
|
|
56231
|
-
if (jsonSchema2) {
|
|
56232
|
-
addMeta2(def, refs, jsonSchema2);
|
|
56233
|
-
}
|
|
56234
|
-
if (refs.postProcess) {
|
|
56235
|
-
const postProcessResult = refs.postProcess(jsonSchema2, def, refs);
|
|
56236
|
-
newItem.jsonSchema = jsonSchema2;
|
|
56237
|
-
return postProcessResult;
|
|
56238
|
-
}
|
|
56239
|
-
newItem.jsonSchema = jsonSchema2;
|
|
56240
|
-
return jsonSchema2;
|
|
56241
|
-
}
|
|
56242
|
-
var get$ref2 = (item, refs) => {
|
|
56243
|
-
switch (refs.$refStrategy) {
|
|
56244
|
-
case "root":
|
|
56245
|
-
return { $ref: item.path.join("/") };
|
|
56246
|
-
case "relative":
|
|
56247
|
-
return { $ref: getRelativePath2(refs.currentPath, item.path) };
|
|
56248
|
-
case "none":
|
|
56249
|
-
case "seen": {
|
|
56250
|
-
if (item.path.length < refs.currentPath.length && item.path.every((value, index) => refs.currentPath[index] === value)) {
|
|
56251
|
-
console.warn(`Recursive reference detected at ${refs.currentPath.join("/")}! Defaulting to any`);
|
|
56252
|
-
return parseAnyDef2();
|
|
56253
|
-
}
|
|
56254
|
-
return refs.$refStrategy === "seen" ? parseAnyDef2() : undefined;
|
|
56255
|
-
}
|
|
56256
|
-
}
|
|
56257
|
-
};
|
|
56258
|
-
var addMeta2 = (def, refs, jsonSchema2) => {
|
|
56259
|
-
if (def.description) {
|
|
56260
|
-
jsonSchema2.description = def.description;
|
|
56261
|
-
}
|
|
56262
|
-
return jsonSchema2;
|
|
56263
|
-
};
|
|
56264
|
-
var getRefs2 = (options) => {
|
|
56265
|
-
const _options = getDefaultOptions2(options);
|
|
56266
|
-
const currentPath = _options.name !== undefined ? [..._options.basePath, _options.definitionPath, _options.name] : _options.basePath;
|
|
56267
|
-
return {
|
|
56268
|
-
..._options,
|
|
56269
|
-
currentPath,
|
|
56270
|
-
propertyPath: undefined,
|
|
56271
|
-
seen: new Map(Object.entries(_options.definitions).map(([name22, def]) => [
|
|
56272
|
-
def._def,
|
|
56273
|
-
{
|
|
56274
|
-
def: def._def,
|
|
56275
|
-
path: [..._options.basePath, _options.definitionPath, name22],
|
|
56276
|
-
jsonSchema: undefined
|
|
56277
|
-
}
|
|
56278
|
-
]))
|
|
56279
|
-
};
|
|
56280
|
-
};
|
|
56281
|
-
var zod3ToJsonSchema2 = (schema, options) => {
|
|
56282
|
-
var _a23;
|
|
56283
|
-
const refs = getRefs2(options);
|
|
56284
|
-
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name32, schema2]) => {
|
|
56285
|
-
var _a32;
|
|
56286
|
-
return {
|
|
56287
|
-
...acc,
|
|
56288
|
-
[name32]: (_a32 = parseDef2(schema2._def, {
|
|
56289
|
-
...refs,
|
|
56290
|
-
currentPath: [...refs.basePath, refs.definitionPath, name32]
|
|
56291
|
-
}, true)) != null ? _a32 : parseAnyDef2()
|
|
56292
|
-
};
|
|
56293
|
-
}, {}) : undefined;
|
|
56294
|
-
const name22 = typeof options === "string" ? options : (options == null ? undefined : options.nameStrategy) === "title" ? undefined : options == null ? undefined : options.name;
|
|
56295
|
-
const main = (_a23 = parseDef2(schema._def, name22 === undefined ? refs : {
|
|
56296
|
-
...refs,
|
|
56297
|
-
currentPath: [...refs.basePath, refs.definitionPath, name22]
|
|
56298
|
-
}, false)) != null ? _a23 : parseAnyDef2();
|
|
56299
|
-
const title = typeof options === "object" && options.name !== undefined && options.nameStrategy === "title" ? options.name : undefined;
|
|
56300
|
-
if (title !== undefined) {
|
|
56301
|
-
main.title = title;
|
|
56302
|
-
}
|
|
56303
|
-
const combined = name22 === undefined ? definitions ? {
|
|
56304
|
-
...main,
|
|
56305
|
-
[refs.definitionPath]: definitions
|
|
56306
|
-
} : main : {
|
|
56307
|
-
$ref: [
|
|
56308
|
-
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
56309
|
-
refs.definitionPath,
|
|
56310
|
-
name22
|
|
56311
|
-
].join("/"),
|
|
56312
|
-
[refs.definitionPath]: {
|
|
56313
|
-
...definitions,
|
|
56314
|
-
[name22]: main
|
|
56315
|
-
}
|
|
56316
|
-
};
|
|
56317
|
-
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
56318
|
-
return combined;
|
|
56319
|
-
};
|
|
56320
|
-
var schemaSymbol2 = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
|
|
56321
|
-
function jsonSchema2(jsonSchema22, {
|
|
56322
|
-
validate
|
|
56323
|
-
} = {}) {
|
|
56324
|
-
return {
|
|
56325
|
-
[schemaSymbol2]: true,
|
|
56326
|
-
_type: undefined,
|
|
56327
|
-
get jsonSchema() {
|
|
56328
|
-
if (typeof jsonSchema22 === "function") {
|
|
56329
|
-
jsonSchema22 = jsonSchema22();
|
|
56330
|
-
}
|
|
56331
|
-
return jsonSchema22;
|
|
56332
|
-
},
|
|
56333
|
-
validate
|
|
56334
|
-
};
|
|
56335
|
-
}
|
|
56336
|
-
function isSchema2(value) {
|
|
56337
|
-
return typeof value === "object" && value !== null && schemaSymbol2 in value && value[schemaSymbol2] === true && "jsonSchema" in value && "validate" in value;
|
|
56338
|
-
}
|
|
56339
|
-
function asSchema2(schema) {
|
|
56340
|
-
return schema == null ? jsonSchema2({ properties: {}, additionalProperties: false }) : isSchema2(schema) ? schema : ("~standard" in schema) ? schema["~standard"].vendor === "zod" ? zodSchema2(schema) : standardSchema2(schema) : schema();
|
|
56341
|
-
}
|
|
56342
|
-
function standardSchema2(standardSchema22) {
|
|
56343
|
-
return jsonSchema2(() => addAdditionalPropertiesToJsonSchema2(standardSchema22["~standard"].jsonSchema.input({
|
|
56344
|
-
target: "draft-07"
|
|
56345
|
-
})), {
|
|
56346
|
-
validate: async (value) => {
|
|
56347
|
-
const result = await standardSchema22["~standard"].validate(value);
|
|
56348
|
-
return "value" in result ? { success: true, value: result.value } : {
|
|
56349
|
-
success: false,
|
|
56350
|
-
error: new TypeValidationError({
|
|
56351
|
-
value,
|
|
56352
|
-
cause: result.issues
|
|
56353
|
-
})
|
|
56354
|
-
};
|
|
56355
|
-
}
|
|
56356
|
-
});
|
|
56357
|
-
}
|
|
56358
|
-
function zod3Schema2(zodSchema2, options) {
|
|
56359
|
-
var _a23;
|
|
56360
|
-
const useReferences = (_a23 = options == null ? undefined : options.useReferences) != null ? _a23 : false;
|
|
56361
|
-
return jsonSchema2(() => zod3ToJsonSchema2(zodSchema2, {
|
|
56362
|
-
$refStrategy: useReferences ? "root" : "none"
|
|
56363
|
-
}), {
|
|
56364
|
-
validate: async (value) => {
|
|
56365
|
-
const result = await zodSchema2.safeParseAsync(value);
|
|
56366
|
-
return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
|
|
56367
|
-
}
|
|
56368
|
-
});
|
|
56369
|
-
}
|
|
56370
|
-
function zod4Schema2(zodSchema2, options) {
|
|
56371
|
-
var _a23;
|
|
56372
|
-
const useReferences = (_a23 = options == null ? undefined : options.useReferences) != null ? _a23 : false;
|
|
56373
|
-
return jsonSchema2(() => addAdditionalPropertiesToJsonSchema2(toJSONSchema(zodSchema2, {
|
|
56374
|
-
target: "draft-7",
|
|
56375
|
-
io: "input",
|
|
56376
|
-
reused: useReferences ? "ref" : "inline"
|
|
56377
|
-
})), {
|
|
56378
|
-
validate: async (value) => {
|
|
56379
|
-
const result = await safeParseAsync2(zodSchema2, value);
|
|
56380
|
-
return result.success ? { success: true, value: result.data } : { success: false, error: result.error };
|
|
56381
|
-
}
|
|
56382
|
-
});
|
|
56383
|
-
}
|
|
56384
|
-
function isZod4Schema2(zodSchema2) {
|
|
56385
|
-
return "_zod" in zodSchema2;
|
|
56386
|
-
}
|
|
56387
|
-
function zodSchema2(zodSchema22, options) {
|
|
56388
|
-
if (isZod4Schema2(zodSchema22)) {
|
|
56389
|
-
return zod4Schema2(zodSchema22, options);
|
|
56390
|
-
} else {
|
|
56391
|
-
return zod3Schema2(zodSchema22, options);
|
|
56392
|
-
}
|
|
56393
|
-
}
|
|
56394
|
-
async function validateTypes2({
|
|
56395
|
-
value,
|
|
56396
|
-
schema,
|
|
56397
|
-
context
|
|
56398
|
-
}) {
|
|
56399
|
-
const result = await safeValidateTypes2({ value, schema, context });
|
|
56400
|
-
if (!result.success) {
|
|
56401
|
-
throw TypeValidationError.wrap({ value, cause: result.error, context });
|
|
56402
|
-
}
|
|
56403
|
-
return result.value;
|
|
56404
|
-
}
|
|
56405
|
-
async function safeValidateTypes2({
|
|
56406
|
-
value,
|
|
56407
|
-
schema,
|
|
56408
|
-
context
|
|
56409
|
-
}) {
|
|
56410
|
-
const actualSchema = asSchema2(schema);
|
|
56411
|
-
try {
|
|
56412
|
-
if (actualSchema.validate == null) {
|
|
56413
|
-
return { success: true, value, rawValue: value };
|
|
56414
|
-
}
|
|
56415
|
-
const result = await actualSchema.validate(value);
|
|
56416
|
-
if (result.success) {
|
|
56417
|
-
return { success: true, value: result.value, rawValue: value };
|
|
56418
|
-
}
|
|
56419
|
-
return {
|
|
56420
|
-
success: false,
|
|
56421
|
-
error: TypeValidationError.wrap({ value, cause: result.error, context }),
|
|
56422
|
-
rawValue: value
|
|
56423
|
-
};
|
|
56424
|
-
} catch (error48) {
|
|
56425
|
-
return {
|
|
56426
|
-
success: false,
|
|
56427
|
-
error: TypeValidationError.wrap({ value, cause: error48, context }),
|
|
56428
|
-
rawValue: value
|
|
56429
|
-
};
|
|
56430
|
-
}
|
|
56431
|
-
}
|
|
56432
|
-
async function parseJSON2({
|
|
56433
|
-
text,
|
|
56434
|
-
schema
|
|
56435
|
-
}) {
|
|
56436
|
-
try {
|
|
56437
|
-
const value = secureJsonParse2(text);
|
|
56438
|
-
if (schema == null) {
|
|
56439
|
-
return value;
|
|
56440
|
-
}
|
|
56441
|
-
return validateTypes2({ value, schema });
|
|
56442
|
-
} catch (error48) {
|
|
56443
|
-
if (JSONParseError.isInstance(error48) || TypeValidationError.isInstance(error48)) {
|
|
56444
|
-
throw error48;
|
|
56445
|
-
}
|
|
56446
|
-
throw new JSONParseError({ text, cause: error48 });
|
|
56447
|
-
}
|
|
56448
|
-
}
|
|
56449
|
-
async function safeParseJSON2({
|
|
56450
|
-
text,
|
|
56451
|
-
schema
|
|
56452
|
-
}) {
|
|
56453
|
-
try {
|
|
56454
|
-
const value = secureJsonParse2(text);
|
|
56455
|
-
if (schema == null) {
|
|
56456
|
-
return { success: true, value, rawValue: value };
|
|
56457
|
-
}
|
|
56458
|
-
return await safeValidateTypes2({ value, schema });
|
|
56459
|
-
} catch (error48) {
|
|
56460
|
-
return {
|
|
56461
|
-
success: false,
|
|
56462
|
-
error: JSONParseError.isInstance(error48) ? error48 : new JSONParseError({ text, cause: error48 }),
|
|
56463
|
-
rawValue: undefined
|
|
56464
|
-
};
|
|
56465
|
-
}
|
|
56466
|
-
}
|
|
56467
|
-
async function parseProviderOptions2({
|
|
56468
|
-
provider,
|
|
56469
|
-
providerOptions,
|
|
56470
|
-
schema
|
|
56471
|
-
}) {
|
|
56472
|
-
if ((providerOptions == null ? undefined : providerOptions[provider]) == null) {
|
|
56473
|
-
return;
|
|
56474
|
-
}
|
|
56475
|
-
const parsedProviderOptions = await safeValidateTypes2({
|
|
56476
|
-
value: providerOptions[provider],
|
|
56477
|
-
schema
|
|
56478
|
-
});
|
|
56479
|
-
if (!parsedProviderOptions.success) {
|
|
56480
|
-
throw new InvalidArgumentError({
|
|
56481
|
-
argument: "providerOptions",
|
|
56482
|
-
message: `invalid ${provider} provider options`,
|
|
56483
|
-
cause: parsedProviderOptions.error
|
|
56484
|
-
});
|
|
56485
|
-
}
|
|
56486
|
-
return parsedProviderOptions.value;
|
|
56487
|
-
}
|
|
56488
|
-
var getOriginalFetch22 = () => globalThis.fetch;
|
|
56489
|
-
var postJsonToApi2 = async ({
|
|
56490
|
-
url: url2,
|
|
56491
|
-
headers,
|
|
56492
|
-
body,
|
|
56493
|
-
failedResponseHandler,
|
|
56494
|
-
successfulResponseHandler,
|
|
56495
|
-
abortSignal,
|
|
56496
|
-
fetch: fetch2
|
|
56497
|
-
}) => postToApi2({
|
|
56498
|
-
url: url2,
|
|
56499
|
-
headers: {
|
|
56500
|
-
"Content-Type": "application/json",
|
|
56501
|
-
...headers
|
|
56502
|
-
},
|
|
56503
|
-
body: {
|
|
56504
|
-
content: JSON.stringify(body),
|
|
56505
|
-
values: body
|
|
56506
|
-
},
|
|
56507
|
-
failedResponseHandler,
|
|
56508
|
-
successfulResponseHandler,
|
|
56509
|
-
abortSignal,
|
|
56510
|
-
fetch: fetch2
|
|
56511
|
-
});
|
|
56512
|
-
var postToApi2 = async ({
|
|
56513
|
-
url: url2,
|
|
56514
|
-
headers = {},
|
|
56515
|
-
body,
|
|
56516
|
-
successfulResponseHandler,
|
|
56517
|
-
failedResponseHandler,
|
|
56518
|
-
abortSignal,
|
|
56519
|
-
fetch: fetch2 = getOriginalFetch22()
|
|
56520
|
-
}) => {
|
|
56521
|
-
try {
|
|
56522
|
-
const response = await fetch2(url2, {
|
|
56523
|
-
method: "POST",
|
|
56524
|
-
headers: withUserAgentSuffix2(headers, `ai-sdk/provider-utils/${VERSION8}`, getRuntimeEnvironmentUserAgent2()),
|
|
56525
|
-
body: body.content,
|
|
56526
|
-
signal: abortSignal
|
|
56527
|
-
});
|
|
56528
|
-
const responseHeaders = extractResponseHeaders2(response);
|
|
56529
|
-
if (!response.ok) {
|
|
56530
|
-
let errorInformation;
|
|
56531
|
-
try {
|
|
56532
|
-
errorInformation = await failedResponseHandler({
|
|
56533
|
-
response,
|
|
56534
|
-
url: url2,
|
|
56535
|
-
requestBodyValues: body.values
|
|
56536
|
-
});
|
|
56537
|
-
} catch (error48) {
|
|
56538
|
-
if (isAbortError2(error48) || APICallError.isInstance(error48)) {
|
|
56539
|
-
throw error48;
|
|
56540
|
-
}
|
|
56541
|
-
throw new APICallError({
|
|
56542
|
-
message: "Failed to process error response",
|
|
56543
|
-
cause: error48,
|
|
56544
|
-
statusCode: response.status,
|
|
56545
|
-
url: url2,
|
|
56546
|
-
responseHeaders,
|
|
56547
|
-
requestBodyValues: body.values
|
|
56548
|
-
});
|
|
56549
|
-
}
|
|
56550
|
-
throw errorInformation.value;
|
|
56551
|
-
}
|
|
56552
|
-
try {
|
|
56553
|
-
return await successfulResponseHandler({
|
|
56554
|
-
response,
|
|
56555
|
-
url: url2,
|
|
56556
|
-
requestBodyValues: body.values
|
|
56557
|
-
});
|
|
56558
|
-
} catch (error48) {
|
|
56559
|
-
if (error48 instanceof Error) {
|
|
56560
|
-
if (isAbortError2(error48) || APICallError.isInstance(error48)) {
|
|
56561
|
-
throw error48;
|
|
56562
|
-
}
|
|
56563
|
-
}
|
|
56564
|
-
throw new APICallError({
|
|
56565
|
-
message: "Failed to process successful response",
|
|
56566
|
-
cause: error48,
|
|
56567
|
-
statusCode: response.status,
|
|
56568
|
-
url: url2,
|
|
56569
|
-
responseHeaders,
|
|
56570
|
-
requestBodyValues: body.values
|
|
56571
|
-
});
|
|
56572
|
-
}
|
|
56573
|
-
} catch (error48) {
|
|
56574
|
-
throw handleFetchError2({ error: error48, url: url2, requestBodyValues: body.values });
|
|
56575
|
-
}
|
|
56576
|
-
};
|
|
56577
|
-
var createJsonErrorResponseHandler2 = ({
|
|
56578
|
-
errorSchema,
|
|
56579
|
-
errorToMessage,
|
|
56580
|
-
isRetryable
|
|
56581
|
-
}) => async ({ response, url: url2, requestBodyValues }) => {
|
|
56582
|
-
const responseBody = await response.text();
|
|
56583
|
-
const responseHeaders = extractResponseHeaders2(response);
|
|
56584
|
-
if (responseBody.trim() === "") {
|
|
56585
|
-
return {
|
|
56586
|
-
responseHeaders,
|
|
56587
|
-
value: new APICallError({
|
|
56588
|
-
message: response.statusText,
|
|
56589
|
-
url: url2,
|
|
56590
|
-
requestBodyValues,
|
|
56591
|
-
statusCode: response.status,
|
|
56592
|
-
responseHeaders,
|
|
56593
|
-
responseBody,
|
|
56594
|
-
isRetryable: isRetryable == null ? undefined : isRetryable(response)
|
|
56595
|
-
})
|
|
56596
|
-
};
|
|
56597
|
-
}
|
|
56598
|
-
try {
|
|
56599
|
-
const parsedError = await parseJSON2({
|
|
56600
|
-
text: responseBody,
|
|
56601
|
-
schema: errorSchema
|
|
56602
|
-
});
|
|
56603
|
-
return {
|
|
56604
|
-
responseHeaders,
|
|
56605
|
-
value: new APICallError({
|
|
56606
|
-
message: errorToMessage(parsedError),
|
|
56607
|
-
url: url2,
|
|
56608
|
-
requestBodyValues,
|
|
56609
|
-
statusCode: response.status,
|
|
56610
|
-
responseHeaders,
|
|
56611
|
-
responseBody,
|
|
56612
|
-
data: parsedError,
|
|
56613
|
-
isRetryable: isRetryable == null ? undefined : isRetryable(response, parsedError)
|
|
56614
|
-
})
|
|
56615
|
-
};
|
|
56616
|
-
} catch (parseError) {
|
|
56617
|
-
return {
|
|
56618
|
-
responseHeaders,
|
|
56619
|
-
value: new APICallError({
|
|
56620
|
-
message: response.statusText,
|
|
56621
|
-
url: url2,
|
|
56622
|
-
requestBodyValues,
|
|
56623
|
-
statusCode: response.status,
|
|
56624
|
-
responseHeaders,
|
|
56625
|
-
responseBody,
|
|
56626
|
-
isRetryable: isRetryable == null ? undefined : isRetryable(response)
|
|
56627
|
-
})
|
|
56628
|
-
};
|
|
56629
|
-
}
|
|
56630
|
-
};
|
|
56631
|
-
var createJsonResponseHandler2 = (responseSchema2) => async ({ response, url: url2, requestBodyValues }) => {
|
|
56632
|
-
const responseBody = await response.text();
|
|
56633
|
-
const parsedResult = await safeParseJSON2({
|
|
56634
|
-
text: responseBody,
|
|
56635
|
-
schema: responseSchema2
|
|
56636
|
-
});
|
|
56637
|
-
const responseHeaders = extractResponseHeaders2(response);
|
|
56638
|
-
if (!parsedResult.success) {
|
|
56639
|
-
throw new APICallError({
|
|
56640
|
-
message: "Invalid JSON response",
|
|
56641
|
-
cause: parsedResult.error,
|
|
56642
|
-
statusCode: response.status,
|
|
56643
|
-
responseHeaders,
|
|
56644
|
-
responseBody,
|
|
56645
|
-
url: url2,
|
|
56646
|
-
requestBodyValues
|
|
56647
|
-
});
|
|
56648
|
-
}
|
|
56649
|
-
return {
|
|
56650
|
-
responseHeaders,
|
|
56651
|
-
value: parsedResult.value,
|
|
56652
|
-
rawValue: parsedResult.rawValue
|
|
56653
|
-
};
|
|
56654
|
-
};
|
|
56655
|
-
function withoutTrailingSlash2(url2) {
|
|
56656
|
-
return url2 == null ? undefined : url2.replace(/\/$/, "");
|
|
56657
|
-
}
|
|
56658
|
-
|
|
56659
|
-
// node_modules/ollama-ai-provider-v2/dist/index.mjs
|
|
56660
|
-
function convertToOllamaCompletionPrompt({
|
|
56661
|
-
prompt,
|
|
56662
|
-
user = "user",
|
|
56663
|
-
assistant = "assistant"
|
|
56664
|
-
}) {
|
|
56665
|
-
let text = "";
|
|
56666
|
-
if (prompt[0].role === "system") {
|
|
56667
|
-
text += `${prompt[0].content}
|
|
56668
|
-
|
|
56669
|
-
`;
|
|
56670
|
-
prompt = prompt.slice(1);
|
|
56671
|
-
}
|
|
56672
|
-
for (const { role, content } of prompt) {
|
|
56673
|
-
switch (role) {
|
|
56674
|
-
case "system": {
|
|
56675
|
-
throw new InvalidPromptError({
|
|
56676
|
-
message: "Unexpected system message in prompt: ${content}",
|
|
56677
|
-
prompt
|
|
56678
|
-
});
|
|
56679
|
-
}
|
|
56680
|
-
case "user": {
|
|
56681
|
-
const userMessage = content.map((part) => {
|
|
56682
|
-
switch (part.type) {
|
|
56683
|
-
case "text": {
|
|
56684
|
-
return part.text;
|
|
56685
|
-
}
|
|
56686
|
-
}
|
|
56687
|
-
}).filter(Boolean).join("");
|
|
56688
|
-
text += `${user}:
|
|
56689
|
-
${userMessage}
|
|
56690
|
-
|
|
56691
|
-
`;
|
|
56692
|
-
break;
|
|
56693
|
-
}
|
|
56694
|
-
case "assistant": {
|
|
56695
|
-
const assistantMessage = content.map((part) => {
|
|
56696
|
-
switch (part.type) {
|
|
56697
|
-
case "text": {
|
|
56698
|
-
return part.text;
|
|
56699
|
-
}
|
|
56700
|
-
case "tool-call": {
|
|
56701
|
-
throw new UnsupportedFunctionalityError({
|
|
56702
|
-
functionality: "tool-call messages"
|
|
56703
|
-
});
|
|
56704
|
-
}
|
|
56705
|
-
}
|
|
56706
|
-
}).join("");
|
|
56707
|
-
text += `${assistant}:
|
|
56708
|
-
${assistantMessage}
|
|
56709
|
-
|
|
56710
|
-
`;
|
|
56711
|
-
break;
|
|
56712
|
-
}
|
|
56713
|
-
case "tool": {
|
|
56714
|
-
throw new UnsupportedFunctionalityError({
|
|
56715
|
-
functionality: "tool messages"
|
|
56716
|
-
});
|
|
56717
|
-
}
|
|
56718
|
-
default: {
|
|
56719
|
-
const _exhaustiveCheck = role;
|
|
56720
|
-
throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
|
|
56721
|
-
}
|
|
56722
|
-
}
|
|
56723
|
-
}
|
|
56724
|
-
text += `${assistant}:
|
|
56725
|
-
`;
|
|
56726
|
-
return {
|
|
56727
|
-
prompt: text,
|
|
56728
|
-
stopSequences: [`
|
|
56729
|
-
${user}:`]
|
|
56730
|
-
};
|
|
56731
|
-
}
|
|
56732
|
-
function mapOllamaFinishReason(finishReason) {
|
|
56733
|
-
switch (finishReason) {
|
|
56734
|
-
case "stop":
|
|
56735
|
-
return {
|
|
56736
|
-
raw: finishReason,
|
|
56737
|
-
unified: "stop"
|
|
56738
|
-
};
|
|
56739
|
-
case "length":
|
|
56740
|
-
return {
|
|
56741
|
-
raw: finishReason,
|
|
56742
|
-
unified: "length"
|
|
56743
|
-
};
|
|
56744
|
-
case "content_filter":
|
|
56745
|
-
return {
|
|
56746
|
-
raw: finishReason,
|
|
56747
|
-
unified: "content-filter"
|
|
56748
|
-
};
|
|
56749
|
-
case "function_call":
|
|
56750
|
-
case "tool_calls":
|
|
56751
|
-
return {
|
|
56752
|
-
raw: finishReason,
|
|
56753
|
-
unified: "tool-calls"
|
|
56754
|
-
};
|
|
56755
|
-
default:
|
|
56756
|
-
return {
|
|
56757
|
-
raw: finishReason,
|
|
56758
|
-
unified: "other"
|
|
56759
|
-
};
|
|
56760
|
-
}
|
|
56761
|
-
}
|
|
56762
|
-
function getResponseMetadata5({
|
|
56763
|
-
model,
|
|
56764
|
-
created_at
|
|
56765
|
-
}) {
|
|
56766
|
-
return {
|
|
56767
|
-
id: undefined,
|
|
56768
|
-
modelId: model != null ? model : undefined,
|
|
56769
|
-
timestamp: created_at != null ? new Date(created_at) : undefined
|
|
56770
|
-
};
|
|
56771
|
-
}
|
|
56772
|
-
function createNdjsonStreamResponseHandler(schema) {
|
|
56773
|
-
return async ({ response }) => {
|
|
56774
|
-
const responseHeaders = extractResponseHeaders2(response);
|
|
56775
|
-
if (response.body == null) {
|
|
56776
|
-
throw new Error("Response body is null");
|
|
56777
|
-
}
|
|
56778
|
-
const reader = response.body.getReader();
|
|
56779
|
-
const decoder = new TextDecoder;
|
|
56780
|
-
let buffer = "";
|
|
56781
|
-
const stream = new ReadableStream({
|
|
56782
|
-
async pull(controller) {
|
|
56783
|
-
while (true) {
|
|
56784
|
-
const { done, value } = await reader.read();
|
|
56785
|
-
if (done) {
|
|
56786
|
-
if (buffer.trim()) {
|
|
56787
|
-
try {
|
|
56788
|
-
const parsed = JSON.parse(buffer.trim());
|
|
56789
|
-
const validated = schema.parse(parsed);
|
|
56790
|
-
controller.enqueue({ success: true, value: validated, rawValue: validated });
|
|
56791
|
-
} catch (e) {}
|
|
56792
|
-
}
|
|
56793
|
-
controller.close();
|
|
56794
|
-
return;
|
|
56795
|
-
}
|
|
56796
|
-
buffer += decoder.decode(value, { stream: true });
|
|
56797
|
-
const lines = buffer.split(`
|
|
56798
|
-
`);
|
|
56799
|
-
buffer = lines.pop() || "";
|
|
56800
|
-
for (const line of lines) {
|
|
56801
|
-
const trimmedLine = line.trim();
|
|
56802
|
-
if (trimmedLine) {
|
|
56803
|
-
try {
|
|
56804
|
-
const parsed = JSON.parse(trimmedLine);
|
|
56805
|
-
const validated = schema.parse(parsed);
|
|
56806
|
-
controller.enqueue({ success: true, value: validated, rawValue: validated });
|
|
56807
|
-
} catch (error48) {
|
|
56808
|
-
console.warn("Failed to parse NDJSON line:", error48);
|
|
56809
|
-
}
|
|
56810
|
-
}
|
|
56811
|
-
}
|
|
56812
|
-
}
|
|
56813
|
-
},
|
|
56814
|
-
cancel() {
|
|
56815
|
-
reader.cancel();
|
|
56816
|
-
}
|
|
56817
|
-
});
|
|
56818
|
-
return {
|
|
56819
|
-
responseHeaders,
|
|
56820
|
-
value: stream
|
|
56821
|
-
};
|
|
55291
|
+
function createNdjsonStreamResponseHandler(schema) {
|
|
55292
|
+
return async ({ response }) => {
|
|
55293
|
+
const responseHeaders = extractResponseHeaders(response);
|
|
55294
|
+
if (response.body == null) {
|
|
55295
|
+
throw new Error("Response body is null");
|
|
55296
|
+
}
|
|
55297
|
+
const reader = response.body.getReader();
|
|
55298
|
+
const decoder = new TextDecoder;
|
|
55299
|
+
let buffer = "";
|
|
55300
|
+
const stream = new ReadableStream({
|
|
55301
|
+
async pull(controller) {
|
|
55302
|
+
while (true) {
|
|
55303
|
+
const { done, value } = await reader.read();
|
|
55304
|
+
if (done) {
|
|
55305
|
+
if (buffer.trim()) {
|
|
55306
|
+
try {
|
|
55307
|
+
const parsed = JSON.parse(buffer.trim());
|
|
55308
|
+
const validated = schema.parse(parsed);
|
|
55309
|
+
controller.enqueue({ success: true, value: validated, rawValue: validated });
|
|
55310
|
+
} catch (e) {}
|
|
55311
|
+
}
|
|
55312
|
+
controller.close();
|
|
55313
|
+
return;
|
|
55314
|
+
}
|
|
55315
|
+
buffer += decoder.decode(value, { stream: true });
|
|
55316
|
+
const lines = buffer.split(`
|
|
55317
|
+
`);
|
|
55318
|
+
buffer = lines.pop() || "";
|
|
55319
|
+
for (const line of lines) {
|
|
55320
|
+
const trimmedLine = line.trim();
|
|
55321
|
+
if (trimmedLine) {
|
|
55322
|
+
try {
|
|
55323
|
+
const parsed = JSON.parse(trimmedLine);
|
|
55324
|
+
const validated = schema.parse(parsed);
|
|
55325
|
+
controller.enqueue({ success: true, value: validated, rawValue: validated });
|
|
55326
|
+
} catch (error48) {
|
|
55327
|
+
console.warn("Failed to parse NDJSON line:", error48);
|
|
55328
|
+
}
|
|
55329
|
+
}
|
|
55330
|
+
}
|
|
55331
|
+
}
|
|
55332
|
+
},
|
|
55333
|
+
cancel() {
|
|
55334
|
+
reader.cancel();
|
|
55335
|
+
}
|
|
55336
|
+
});
|
|
55337
|
+
return {
|
|
55338
|
+
responseHeaders,
|
|
55339
|
+
value: stream
|
|
55340
|
+
};
|
|
56822
55341
|
};
|
|
56823
55342
|
}
|
|
56824
55343
|
var ollamaErrorDataSchema = exports_external.object({
|
|
@@ -56829,7 +55348,7 @@ var ollamaErrorDataSchema = exports_external.object({
|
|
|
56829
55348
|
code: exports_external.union([exports_external.string(), exports_external.number()]).nullish()
|
|
56830
55349
|
})
|
|
56831
55350
|
});
|
|
56832
|
-
var ollamaFailedResponseHandler =
|
|
55351
|
+
var ollamaFailedResponseHandler = createJsonErrorResponseHandler({
|
|
56833
55352
|
errorSchema: ollamaErrorDataSchema,
|
|
56834
55353
|
errorToMessage: (data) => data.error.message
|
|
56835
55354
|
});
|
|
@@ -56911,15 +55430,15 @@ var OllamaCompletionLanguageModel = class {
|
|
|
56911
55430
|
responseHeaders,
|
|
56912
55431
|
value: response,
|
|
56913
55432
|
rawValue: rawResponse
|
|
56914
|
-
} = await
|
|
55433
|
+
} = await postJsonToApi({
|
|
56915
55434
|
url: this.config.url({
|
|
56916
55435
|
path: "/generate",
|
|
56917
55436
|
modelId: this.modelId
|
|
56918
55437
|
}),
|
|
56919
|
-
headers:
|
|
55438
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
56920
55439
|
body: { ...body, stream: false },
|
|
56921
55440
|
failedResponseHandler: ollamaFailedResponseHandler,
|
|
56922
|
-
successfulResponseHandler:
|
|
55441
|
+
successfulResponseHandler: createJsonResponseHandler(baseOllamaResponseSchema),
|
|
56923
55442
|
abortSignal: options.abortSignal,
|
|
56924
55443
|
fetch: this.config.fetch
|
|
56925
55444
|
});
|
|
@@ -56961,12 +55480,12 @@ var OllamaCompletionLanguageModel = class {
|
|
|
56961
55480
|
...args,
|
|
56962
55481
|
stream: true
|
|
56963
55482
|
};
|
|
56964
|
-
const { responseHeaders, value: response } = await
|
|
55483
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
56965
55484
|
url: this.config.url({
|
|
56966
55485
|
path: "/generate",
|
|
56967
55486
|
modelId: this.modelId
|
|
56968
55487
|
}),
|
|
56969
|
-
headers:
|
|
55488
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
56970
55489
|
body,
|
|
56971
55490
|
failedResponseHandler: ollamaFailedResponseHandler,
|
|
56972
55491
|
successfulResponseHandler: createNdjsonStreamResponseHandler(baseOllamaResponseSchema),
|
|
@@ -56990,7 +55509,7 @@ var OllamaCompletionLanguageModel = class {
|
|
|
56990
55509
|
};
|
|
56991
55510
|
let isFirstChunk = true;
|
|
56992
55511
|
let textStarted = false;
|
|
56993
|
-
const textId =
|
|
55512
|
+
const textId = generateId();
|
|
56994
55513
|
return {
|
|
56995
55514
|
stream: response.pipeThrough(new TransformStream({
|
|
56996
55515
|
transform(chunk, controller) {
|
|
@@ -57104,7 +55623,7 @@ var OllamaEmbeddingModel = class {
|
|
|
57104
55623
|
values
|
|
57105
55624
|
});
|
|
57106
55625
|
}
|
|
57107
|
-
const ollamaOptions = await
|
|
55626
|
+
const ollamaOptions = await parseProviderOptions({
|
|
57108
55627
|
provider: "ollama",
|
|
57109
55628
|
providerOptions,
|
|
57110
55629
|
schema: ollamaEmbeddingProviderOptions
|
|
@@ -57126,15 +55645,15 @@ var OllamaEmbeddingModel = class {
|
|
|
57126
55645
|
responseHeaders,
|
|
57127
55646
|
value: response,
|
|
57128
55647
|
rawValue
|
|
57129
|
-
} = await
|
|
55648
|
+
} = await postJsonToApi({
|
|
57130
55649
|
url: this.config.url({
|
|
57131
55650
|
path: "/embed",
|
|
57132
55651
|
modelId: this.modelId
|
|
57133
55652
|
}),
|
|
57134
|
-
headers:
|
|
55653
|
+
headers: combineHeaders(this.config.headers(), headers),
|
|
57135
55654
|
body: { ...body },
|
|
57136
55655
|
failedResponseHandler: ollamaFailedResponseHandler,
|
|
57137
|
-
successfulResponseHandler:
|
|
55656
|
+
successfulResponseHandler: createJsonResponseHandler(ollamaTextEmbeddingResponseSchema),
|
|
57138
55657
|
abortSignal,
|
|
57139
55658
|
fetch: this.config.fetch
|
|
57140
55659
|
});
|
|
@@ -57216,7 +55735,7 @@ var OllamaResponseProcessor = class {
|
|
|
57216
55735
|
for (const toolCall of (_a16 = response.message.tool_calls) != null ? _a16 : []) {
|
|
57217
55736
|
content.push({
|
|
57218
55737
|
type: "tool-call",
|
|
57219
|
-
toolCallId: (_e = toolCall.id) != null ? _e : (_d = (_c = (_b16 = this.config).generateId) == null ? undefined : _c.call(_b16)) != null ? _d :
|
|
55738
|
+
toolCallId: (_e = toolCall.id) != null ? _e : (_d = (_c = (_b16 = this.config).generateId) == null ? undefined : _c.call(_b16)) != null ? _d : generateId(),
|
|
57220
55739
|
toolName: toolCall.function.name,
|
|
57221
55740
|
input: JSON.stringify(toolCall.function.arguments)
|
|
57222
55741
|
});
|
|
@@ -57665,7 +56184,7 @@ var OllamaRequestBuilder = class {
|
|
|
57665
56184
|
return warnings;
|
|
57666
56185
|
}
|
|
57667
56186
|
async parseProviderOptions(providerOptions) {
|
|
57668
|
-
const result = await
|
|
56187
|
+
const result = await parseProviderOptions({
|
|
57669
56188
|
provider: "ollama",
|
|
57670
56189
|
providerOptions,
|
|
57671
56190
|
schema: ollamaProviderOptions
|
|
@@ -57741,8 +56260,8 @@ var OllamaStreamProcessor = class {
|
|
|
57741
56260
|
hasReasoningStarted: false,
|
|
57742
56261
|
textEnded: false,
|
|
57743
56262
|
reasoningEnded: false,
|
|
57744
|
-
textId:
|
|
57745
|
-
reasoningId:
|
|
56263
|
+
textId: generateId(),
|
|
56264
|
+
reasoningId: generateId()
|
|
57746
56265
|
};
|
|
57747
56266
|
}
|
|
57748
56267
|
processChunk(chunk, controller, options) {
|
|
@@ -57853,7 +56372,7 @@ var OllamaStreamProcessor = class {
|
|
|
57853
56372
|
}
|
|
57854
56373
|
emitToolCall(toolCall, controller) {
|
|
57855
56374
|
var _a16, _b16, _c, _d;
|
|
57856
|
-
const id = (_d = toolCall.id) != null ? _d : (_c = (_b16 = (_a16 = this.config).generateId) == null ? undefined : _b16.call(_a16)) != null ? _c :
|
|
56375
|
+
const id = (_d = toolCall.id) != null ? _d : (_c = (_b16 = (_a16 = this.config).generateId) == null ? undefined : _b16.call(_a16)) != null ? _c : generateId();
|
|
57857
56376
|
controller.enqueue({
|
|
57858
56377
|
type: "tool-input-start",
|
|
57859
56378
|
id,
|
|
@@ -57918,15 +56437,15 @@ var OllamaResponsesLanguageModel = class {
|
|
|
57918
56437
|
responseHeaders,
|
|
57919
56438
|
value: response,
|
|
57920
56439
|
rawValue: rawResponse
|
|
57921
|
-
} = await
|
|
56440
|
+
} = await postJsonToApi({
|
|
57922
56441
|
url: this.config.url({
|
|
57923
56442
|
path: "/chat",
|
|
57924
56443
|
modelId: this.modelId
|
|
57925
56444
|
}),
|
|
57926
|
-
headers:
|
|
56445
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
57927
56446
|
body: { ...body, stream: false },
|
|
57928
56447
|
failedResponseHandler: ollamaFailedResponseHandler,
|
|
57929
|
-
successfulResponseHandler:
|
|
56448
|
+
successfulResponseHandler: createJsonResponseHandler(baseOllamaResponseSchema2),
|
|
57930
56449
|
abortSignal: options.abortSignal,
|
|
57931
56450
|
fetch: this.config.fetch
|
|
57932
56451
|
});
|
|
@@ -57945,12 +56464,12 @@ var OllamaResponsesLanguageModel = class {
|
|
|
57945
56464
|
}
|
|
57946
56465
|
async doStream(options) {
|
|
57947
56466
|
const { args: body, warnings } = await this.prepareRequest(options);
|
|
57948
|
-
const { responseHeaders, value: response } = await
|
|
56467
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
57949
56468
|
url: this.config.url({
|
|
57950
56469
|
path: "/chat",
|
|
57951
56470
|
modelId: this.modelId
|
|
57952
56471
|
}),
|
|
57953
|
-
headers:
|
|
56472
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
57954
56473
|
body: { ...body, stream: true },
|
|
57955
56474
|
failedResponseHandler: ollamaFailedResponseHandler,
|
|
57956
56475
|
successfulResponseHandler: createNdjsonStreamResponseHandler(baseOllamaResponseSchema2),
|
|
@@ -57974,7 +56493,7 @@ var OllamaResponsesLanguageModel = class {
|
|
|
57974
56493
|
};
|
|
57975
56494
|
function createOllama(options = {}) {
|
|
57976
56495
|
var _a16, _b16;
|
|
57977
|
-
const baseURL = (_a16 =
|
|
56496
|
+
const baseURL = (_a16 = withoutTrailingSlash(options.baseURL)) != null ? _a16 : "http://127.0.0.1:11434/api";
|
|
57978
56497
|
const providerName = (_b16 = options.name) != null ? _b16 : "ollama";
|
|
57979
56498
|
const getHeaders = () => ({
|
|
57980
56499
|
"Ollama-Organization": options.organization,
|
|
@@ -61679,8 +60198,8 @@ async function prepareResponsesTools3({
|
|
|
61679
60198
|
value: tool2.args,
|
|
61680
60199
|
schema: mcpArgsSchema2
|
|
61681
60200
|
});
|
|
61682
|
-
const mapApprovalFilter = (
|
|
61683
|
-
tool_names:
|
|
60201
|
+
const mapApprovalFilter = (filter2) => ({
|
|
60202
|
+
tool_names: filter2.toolNames
|
|
61684
60203
|
});
|
|
61685
60204
|
const requireApproval = args.requireApproval;
|
|
61686
60205
|
const requireApprovalParam = requireApproval == null ? undefined : typeof requireApproval === "string" ? requireApproval : requireApproval.never != null ? { never: mapApprovalFilter(requireApproval.never) } : undefined;
|
|
@@ -63741,7 +62260,7 @@ var OpenAITranscriptionModel2 = class {
|
|
|
63741
62260
|
};
|
|
63742
62261
|
}
|
|
63743
62262
|
};
|
|
63744
|
-
var
|
|
62263
|
+
var VERSION8 = "3.0.53";
|
|
63745
62264
|
function createOpenAI(options = {}) {
|
|
63746
62265
|
var _a16, _b16;
|
|
63747
62266
|
const baseURL = (_a16 = withoutTrailingSlash(loadOptionalSetting({
|
|
@@ -63758,7 +62277,7 @@ function createOpenAI(options = {}) {
|
|
|
63758
62277
|
"OpenAI-Organization": options.organization,
|
|
63759
62278
|
"OpenAI-Project": options.project,
|
|
63760
62279
|
...options.headers
|
|
63761
|
-
}, `ai-sdk/openai/${
|
|
62280
|
+
}, `ai-sdk/openai/${VERSION8}`);
|
|
63762
62281
|
const createChatModel = (modelId) => new OpenAIChatLanguageModel2(modelId, {
|
|
63763
62282
|
provider: `${providerName}.chat`,
|
|
63764
62283
|
url: ({ path: path2 }) => `${baseURL}${path2}`,
|
|
@@ -65310,7 +63829,7 @@ async function fileToBlob3(file2) {
|
|
|
65310
63829
|
const data = file2.data instanceof Uint8Array ? file2.data : convertBase64ToUint8Array(file2.data);
|
|
65311
63830
|
return new Blob([data], { type: file2.mediaType });
|
|
65312
63831
|
}
|
|
65313
|
-
var
|
|
63832
|
+
var VERSION9 = "2.0.41";
|
|
65314
63833
|
function createOpenAICompatible(options) {
|
|
65315
63834
|
const baseURL = withoutTrailingSlash(options.baseURL);
|
|
65316
63835
|
const providerName = options.name;
|
|
@@ -65318,7 +63837,7 @@ function createOpenAICompatible(options) {
|
|
|
65318
63837
|
...options.apiKey && { Authorization: `Bearer ${options.apiKey}` },
|
|
65319
63838
|
...options.headers
|
|
65320
63839
|
};
|
|
65321
|
-
const getHeaders = () => withUserAgentSuffix(headers, `ai-sdk/openai-compatible/${
|
|
63840
|
+
const getHeaders = () => withUserAgentSuffix(headers, `ai-sdk/openai-compatible/${VERSION9}`);
|
|
65322
63841
|
const getCommonModelConfig = (modelType) => ({
|
|
65323
63842
|
provider: `${providerName}.${modelType}`,
|
|
65324
63843
|
url: ({ path: path2 }) => {
|
|
@@ -65546,11 +64065,11 @@ function listProviders(config2) {
|
|
|
65546
64065
|
// node_modules/@ai-sdk/gateway/dist/index.mjs
|
|
65547
64066
|
var import_oidc = __toESM(require_dist(), 1);
|
|
65548
64067
|
var import_oidc2 = __toESM(require_dist(), 1);
|
|
65549
|
-
var
|
|
65550
|
-
var
|
|
65551
|
-
var
|
|
65552
|
-
var
|
|
65553
|
-
var GatewayError = class _GatewayError extends (
|
|
64068
|
+
var marker17 = "vercel.ai.gateway.error";
|
|
64069
|
+
var symbol17 = Symbol.for(marker17);
|
|
64070
|
+
var _a17;
|
|
64071
|
+
var _b17;
|
|
64072
|
+
var GatewayError = class _GatewayError extends (_b17 = Error, _a17 = symbol17, _b17) {
|
|
65554
64073
|
constructor({
|
|
65555
64074
|
message,
|
|
65556
64075
|
statusCode = 500,
|
|
@@ -65558,7 +64077,7 @@ var GatewayError = class _GatewayError extends (_b18 = Error, _a18 = symbol18, _
|
|
|
65558
64077
|
generationId
|
|
65559
64078
|
}) {
|
|
65560
64079
|
super(generationId ? `${message} [${generationId}]` : message);
|
|
65561
|
-
this[
|
|
64080
|
+
this[_a17] = true;
|
|
65562
64081
|
this.statusCode = statusCode;
|
|
65563
64082
|
this.cause = cause;
|
|
65564
64083
|
this.generationId = generationId;
|
|
@@ -65567,11 +64086,11 @@ var GatewayError = class _GatewayError extends (_b18 = Error, _a18 = symbol18, _
|
|
|
65567
64086
|
return _GatewayError.hasMarker(error48);
|
|
65568
64087
|
}
|
|
65569
64088
|
static hasMarker(error48) {
|
|
65570
|
-
return typeof error48 === "object" && error48 !== null &&
|
|
64089
|
+
return typeof error48 === "object" && error48 !== null && symbol17 in error48 && error48[symbol17] === true;
|
|
65571
64090
|
}
|
|
65572
64091
|
};
|
|
65573
|
-
var
|
|
65574
|
-
var marker22 = `vercel.ai.gateway.error.${
|
|
64092
|
+
var name16 = "GatewayAuthenticationError";
|
|
64093
|
+
var marker22 = `vercel.ai.gateway.error.${name16}`;
|
|
65575
64094
|
var symbol23 = Symbol.for(marker22);
|
|
65576
64095
|
var _a23;
|
|
65577
64096
|
var _b22;
|
|
@@ -65584,7 +64103,7 @@ var GatewayAuthenticationError = class _GatewayAuthenticationError extends (_b22
|
|
|
65584
64103
|
} = {}) {
|
|
65585
64104
|
super({ message, statusCode, cause, generationId });
|
|
65586
64105
|
this[_a23] = true;
|
|
65587
|
-
this.name =
|
|
64106
|
+
this.name = name16;
|
|
65588
64107
|
this.type = "authentication_error";
|
|
65589
64108
|
}
|
|
65590
64109
|
static isInstance(error48) {
|
|
@@ -66846,7 +65365,7 @@ async function getVercelRequestId() {
|
|
|
66846
65365
|
var _a92;
|
|
66847
65366
|
return (_a92 = import_oidc.getContext().headers) == null ? undefined : _a92["x-vercel-id"];
|
|
66848
65367
|
}
|
|
66849
|
-
var
|
|
65368
|
+
var VERSION10 = "3.0.104";
|
|
66850
65369
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
66851
65370
|
function createGatewayProvider(options = {}) {
|
|
66852
65371
|
var _a92, _b92;
|
|
@@ -66863,7 +65382,7 @@ function createGatewayProvider(options = {}) {
|
|
|
66863
65382
|
"ai-gateway-protocol-version": AI_GATEWAY_PROTOCOL_VERSION,
|
|
66864
65383
|
[GATEWAY_AUTH_METHOD_HEADER]: auth.authMethod,
|
|
66865
65384
|
...options.headers
|
|
66866
|
-
}, `ai-sdk/gateway/${
|
|
65385
|
+
}, `ai-sdk/gateway/${VERSION10}`);
|
|
66867
65386
|
} catch (error48) {
|
|
66868
65387
|
throw GatewayAuthenticationError.createContextualError({
|
|
66869
65388
|
apiKeyProvided: false,
|
|
@@ -67041,10 +65560,10 @@ var __export2 = (target, all) => {
|
|
|
67041
65560
|
for (var name21 in all)
|
|
67042
65561
|
__defProp2(target, name21, { get: all[name21], enumerable: true });
|
|
67043
65562
|
};
|
|
67044
|
-
var
|
|
67045
|
-
var
|
|
67046
|
-
var
|
|
67047
|
-
var
|
|
65563
|
+
var name17 = "AI_InvalidArgumentError";
|
|
65564
|
+
var marker18 = `vercel.ai.error.${name17}`;
|
|
65565
|
+
var symbol18 = Symbol.for(marker18);
|
|
65566
|
+
var _a18;
|
|
67048
65567
|
var InvalidArgumentError2 = class extends AISDKError {
|
|
67049
65568
|
constructor({
|
|
67050
65569
|
parameter,
|
|
@@ -67052,18 +65571,18 @@ var InvalidArgumentError2 = class extends AISDKError {
|
|
|
67052
65571
|
message
|
|
67053
65572
|
}) {
|
|
67054
65573
|
super({
|
|
67055
|
-
name:
|
|
65574
|
+
name: name17,
|
|
67056
65575
|
message: `Invalid argument for parameter ${parameter}: ${message}`
|
|
67057
65576
|
});
|
|
67058
|
-
this[
|
|
65577
|
+
this[_a18] = true;
|
|
67059
65578
|
this.parameter = parameter;
|
|
67060
65579
|
this.value = value;
|
|
67061
65580
|
}
|
|
67062
65581
|
static isInstance(error48) {
|
|
67063
|
-
return AISDKError.hasMarker(error48,
|
|
65582
|
+
return AISDKError.hasMarker(error48, marker18);
|
|
67064
65583
|
}
|
|
67065
65584
|
};
|
|
67066
|
-
|
|
65585
|
+
_a18 = symbol18;
|
|
67067
65586
|
var name23 = "AI_InvalidStreamPartError";
|
|
67068
65587
|
var marker23 = `vercel.ai.error.${name23}`;
|
|
67069
65588
|
var symbol24 = Symbol.for(marker23);
|
|
@@ -67303,15 +65822,15 @@ var InvalidMessageRoleError = class extends AISDKError {
|
|
|
67303
65822
|
}
|
|
67304
65823
|
};
|
|
67305
65824
|
_a172 = symbol172;
|
|
67306
|
-
var
|
|
67307
|
-
var marker182 = `vercel.ai.error.${
|
|
65825
|
+
var name18 = "AI_MessageConversionError";
|
|
65826
|
+
var marker182 = `vercel.ai.error.${name18}`;
|
|
67308
65827
|
var symbol182 = Symbol.for(marker182);
|
|
67309
65828
|
var _a182;
|
|
67310
65829
|
_a182 = symbol182;
|
|
67311
65830
|
var name19 = "AI_RetryError";
|
|
67312
|
-
var
|
|
67313
|
-
var
|
|
67314
|
-
var
|
|
65831
|
+
var marker19 = `vercel.ai.error.${name19}`;
|
|
65832
|
+
var symbol19 = Symbol.for(marker19);
|
|
65833
|
+
var _a19;
|
|
67315
65834
|
var RetryError = class extends AISDKError {
|
|
67316
65835
|
constructor({
|
|
67317
65836
|
message,
|
|
@@ -67319,16 +65838,16 @@ var RetryError = class extends AISDKError {
|
|
|
67319
65838
|
errors: errors3
|
|
67320
65839
|
}) {
|
|
67321
65840
|
super({ name: name19, message });
|
|
67322
|
-
this[
|
|
65841
|
+
this[_a19] = true;
|
|
67323
65842
|
this.reason = reason;
|
|
67324
65843
|
this.errors = errors3;
|
|
67325
65844
|
this.lastError = errors3[errors3.length - 1];
|
|
67326
65845
|
}
|
|
67327
65846
|
static isInstance(error48) {
|
|
67328
|
-
return AISDKError.hasMarker(error48,
|
|
65847
|
+
return AISDKError.hasMarker(error48, marker19);
|
|
67329
65848
|
}
|
|
67330
65849
|
};
|
|
67331
|
-
|
|
65850
|
+
_a19 = symbol19;
|
|
67332
65851
|
function asArray(value) {
|
|
67333
65852
|
return value === undefined ? [] : Array.isArray(value) ? value : [value];
|
|
67334
65853
|
}
|
|
@@ -67625,7 +66144,7 @@ function detectMediaType({
|
|
|
67625
66144
|
}
|
|
67626
66145
|
return;
|
|
67627
66146
|
}
|
|
67628
|
-
var
|
|
66147
|
+
var VERSION11 = "6.0.168";
|
|
67629
66148
|
var download = async ({
|
|
67630
66149
|
url: url2,
|
|
67631
66150
|
maxBytes,
|
|
@@ -67636,7 +66155,7 @@ var download = async ({
|
|
|
67636
66155
|
validateDownloadUrl(urlText);
|
|
67637
66156
|
try {
|
|
67638
66157
|
const response = await fetch(urlText, {
|
|
67639
|
-
headers: withUserAgentSuffix({}, `ai-sdk/${
|
|
66158
|
+
headers: withUserAgentSuffix({}, `ai-sdk/${VERSION11}`, getRuntimeEnvironmentUserAgent()),
|
|
67640
66159
|
signal: abortSignal
|
|
67641
66160
|
});
|
|
67642
66161
|
if (response.redirected) {
|
|
@@ -69490,9 +68009,9 @@ var object2 = ({
|
|
|
69490
68009
|
const schema = asSchema(inputSchema);
|
|
69491
68010
|
return {
|
|
69492
68011
|
name: "object",
|
|
69493
|
-
responseFormat: resolve(schema.jsonSchema).then((
|
|
68012
|
+
responseFormat: resolve(schema.jsonSchema).then((jsonSchema2) => ({
|
|
69494
68013
|
type: "json",
|
|
69495
|
-
schema:
|
|
68014
|
+
schema: jsonSchema2,
|
|
69496
68015
|
...name21 != null && { name: name21 },
|
|
69497
68016
|
...description != null && { description }
|
|
69498
68017
|
})),
|
|
@@ -69552,8 +68071,8 @@ var array2 = ({
|
|
|
69552
68071
|
const elementSchema = asSchema(inputElementSchema);
|
|
69553
68072
|
return {
|
|
69554
68073
|
name: "array",
|
|
69555
|
-
responseFormat: resolve(elementSchema.jsonSchema).then((
|
|
69556
|
-
const { $schema, ...itemSchema } =
|
|
68074
|
+
responseFormat: resolve(elementSchema.jsonSchema).then((jsonSchema2) => {
|
|
68075
|
+
const { $schema, ...itemSchema } = jsonSchema2;
|
|
69557
68076
|
return {
|
|
69558
68077
|
type: "json",
|
|
69559
68078
|
schema: {
|
|
@@ -71219,7 +69738,7 @@ function runToolsTransformation({
|
|
|
71219
69738
|
abortSignal,
|
|
71220
69739
|
repairToolCall,
|
|
71221
69740
|
experimental_context,
|
|
71222
|
-
generateId:
|
|
69741
|
+
generateId: generateId2,
|
|
71223
69742
|
stepNumber,
|
|
71224
69743
|
model,
|
|
71225
69744
|
onToolCallStart,
|
|
@@ -71349,14 +69868,14 @@ function runToolsTransformation({
|
|
|
71349
69868
|
})) {
|
|
71350
69869
|
toolResultsStreamController.enqueue({
|
|
71351
69870
|
type: "tool-approval-request",
|
|
71352
|
-
approvalId:
|
|
69871
|
+
approvalId: generateId2(),
|
|
71353
69872
|
toolCall
|
|
71354
69873
|
});
|
|
71355
69874
|
break;
|
|
71356
69875
|
}
|
|
71357
69876
|
toolInputs.set(toolCall.toolCallId, toolCall.input);
|
|
71358
69877
|
if (tool2.execute != null && toolCall.providerExecuted !== true) {
|
|
71359
|
-
const toolExecutionId =
|
|
69878
|
+
const toolExecutionId = generateId2();
|
|
71360
69879
|
outstandingToolResults.add(toolExecutionId);
|
|
71361
69880
|
executeToolCall({
|
|
71362
69881
|
toolCall,
|
|
@@ -71489,7 +70008,7 @@ function streamText({
|
|
|
71489
70008
|
experimental_onToolCallFinish: onToolCallFinish,
|
|
71490
70009
|
experimental_context,
|
|
71491
70010
|
experimental_include: include,
|
|
71492
|
-
_internal: { now: now2 = now, generateId:
|
|
70011
|
+
_internal: { now: now2 = now, generateId: generateId2 = originalGenerateId2 } = {},
|
|
71493
70012
|
...settings
|
|
71494
70013
|
}) {
|
|
71495
70014
|
const totalTimeoutMs = getTotalTimeoutMs(timeout);
|
|
@@ -71534,7 +70053,7 @@ function streamText({
|
|
|
71534
70053
|
onToolCallStart,
|
|
71535
70054
|
onToolCallFinish,
|
|
71536
70055
|
now: now2,
|
|
71537
|
-
generateId:
|
|
70056
|
+
generateId: generateId2,
|
|
71538
70057
|
experimental_context,
|
|
71539
70058
|
download: download2,
|
|
71540
70059
|
include
|
|
@@ -71628,7 +70147,7 @@ var DefaultStreamTextResult = class {
|
|
|
71628
70147
|
prepareStep,
|
|
71629
70148
|
includeRawChunks,
|
|
71630
70149
|
now: now2,
|
|
71631
|
-
generateId:
|
|
70150
|
+
generateId: generateId2,
|
|
71632
70151
|
timeout,
|
|
71633
70152
|
stopWhen,
|
|
71634
70153
|
originalAbortSignal,
|
|
@@ -72274,7 +70793,7 @@ var DefaultStreamTextResult = class {
|
|
|
72274
70793
|
repairToolCall,
|
|
72275
70794
|
abortSignal,
|
|
72276
70795
|
experimental_context,
|
|
72277
|
-
generateId:
|
|
70796
|
+
generateId: generateId2,
|
|
72278
70797
|
stepNumber: recordedSteps.length,
|
|
72279
70798
|
model: stepModelInfo,
|
|
72280
70799
|
onToolCallStart: [
|
|
@@ -72297,7 +70816,7 @@ var DefaultStreamTextResult = class {
|
|
|
72297
70816
|
let stepProviderMetadata;
|
|
72298
70817
|
let stepFirstChunk = true;
|
|
72299
70818
|
let stepResponse = {
|
|
72300
|
-
id:
|
|
70819
|
+
id: generateId2(),
|
|
72301
70820
|
timestamp: /* @__PURE__ */ new Date,
|
|
72302
70821
|
modelId: modelInfo.modelId
|
|
72303
70822
|
};
|
|
@@ -73345,6 +71864,19 @@ function stripAnsi(str) {
|
|
|
73345
71864
|
return str;
|
|
73346
71865
|
return str.replace(ANSI_REGEX, "");
|
|
73347
71866
|
}
|
|
71867
|
+
function escapeControlCharacters(str) {
|
|
71868
|
+
const normalised = str.replace(/\r\n/g, `
|
|
71869
|
+
`);
|
|
71870
|
+
return normalised.replace(/[\x00-\x08\x0B-\x1F\x7F-\x9F]/g, (char) => {
|
|
71871
|
+
const hex3 = char.charCodeAt(0).toString(16).padStart(2, "0").toUpperCase();
|
|
71872
|
+
return `\\x${hex3}`;
|
|
71873
|
+
});
|
|
71874
|
+
}
|
|
71875
|
+
function sanitizeForTerminal(str) {
|
|
71876
|
+
if (!str)
|
|
71877
|
+
return str;
|
|
71878
|
+
return escapeControlCharacters(str);
|
|
71879
|
+
}
|
|
73348
71880
|
function createAnsiStripper() {
|
|
73349
71881
|
let buffer = "";
|
|
73350
71882
|
return (chunk) => {
|
|
@@ -73403,7 +71935,7 @@ async function runQuery(options) {
|
|
|
73403
71935
|
sawTextChunk = true;
|
|
73404
71936
|
onFirstChunk?.();
|
|
73405
71937
|
}
|
|
73406
|
-
const safeText = stripper(textPart);
|
|
71938
|
+
const safeText = sanitizeForTerminal(stripper(textPart));
|
|
73407
71939
|
process.stdout.write(safeText);
|
|
73408
71940
|
fullText += textPart;
|
|
73409
71941
|
}
|