@probelabs/visor 0.1.192-ee → 0.1.193-ee
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/736.index.js +124 -52
- package/dist/index.js +2890 -223
- package/dist/sdk/{a2a-frontend-XOLDANGJ.mjs → a2a-frontend-IN5D7IVC.mjs} +3 -3
- package/dist/sdk/{check-provider-registry-RWON6HOP.mjs → check-provider-registry-YYTCNHT6.mjs} +6 -6
- package/dist/sdk/{chunk-FYYKQCUJ.mjs → chunk-63MKHGBA.mjs} +2 -2
- package/dist/sdk/{chunk-CBVCFWI3.mjs → chunk-7QEVOF6T.mjs} +3 -3
- package/dist/sdk/{chunk-VNUP4Q25.mjs → chunk-BTRDMNJI.mjs} +2 -2
- package/dist/sdk/{chunk-QZKRJKD5.mjs → chunk-I6HELMNJ.mjs} +18 -18
- package/dist/sdk/{chunk-A64HFAOW.mjs → chunk-O3UWMGDE.mjs} +2 -2
- package/dist/sdk/{chunk-A64HFAOW.mjs.map → chunk-O3UWMGDE.mjs.map} +1 -1
- package/dist/sdk/{failure-condition-evaluator-ANS4WIEA.mjs → failure-condition-evaluator-EYLDH7BT.mjs} +4 -4
- package/dist/sdk/{github-frontend-TRETPEWZ.mjs → github-frontend-MZHXRIY7.mjs} +4 -4
- package/dist/sdk/{host-C3FMSKBX.mjs → host-3Y2RVF7E.mjs} +3 -3
- package/dist/sdk/{routing-GFHGNOMS.mjs → routing-Q5IPCQLI.mjs} +5 -5
- package/dist/sdk/{schedule-tool-3XCZR3NC.mjs → schedule-tool-MDPOLK4O.mjs} +6 -6
- package/dist/sdk/{schedule-tool-handler-4ECAAHEH.mjs → schedule-tool-handler-D2NV7ATP.mjs} +6 -6
- package/dist/sdk/sdk.js +1 -1
- package/dist/sdk/sdk.js.map +1 -1
- package/dist/sdk/sdk.mjs +5 -5
- package/dist/sdk/{trace-helpers-D67B7FOU.mjs → trace-helpers-SETVIO5T.mjs} +3 -3
- package/dist/sdk/{track-execution-DHQA6FAE.mjs → track-execution-6EWFXL34.mjs} +2 -2
- package/dist/sdk/{workflow-check-provider-DNPDEVSQ.mjs → workflow-check-provider-7U66H2MI.mjs} +6 -6
- package/package.json +2 -2
- /package/dist/sdk/{a2a-frontend-XOLDANGJ.mjs.map → a2a-frontend-IN5D7IVC.mjs.map} +0 -0
- /package/dist/sdk/{check-provider-registry-RWON6HOP.mjs.map → check-provider-registry-YYTCNHT6.mjs.map} +0 -0
- /package/dist/sdk/{chunk-FYYKQCUJ.mjs.map → chunk-63MKHGBA.mjs.map} +0 -0
- /package/dist/sdk/{chunk-CBVCFWI3.mjs.map → chunk-7QEVOF6T.mjs.map} +0 -0
- /package/dist/sdk/{chunk-VNUP4Q25.mjs.map → chunk-BTRDMNJI.mjs.map} +0 -0
- /package/dist/sdk/{chunk-QZKRJKD5.mjs.map → chunk-I6HELMNJ.mjs.map} +0 -0
- /package/dist/sdk/{failure-condition-evaluator-ANS4WIEA.mjs.map → failure-condition-evaluator-EYLDH7BT.mjs.map} +0 -0
- /package/dist/sdk/{github-frontend-TRETPEWZ.mjs.map → github-frontend-MZHXRIY7.mjs.map} +0 -0
- /package/dist/sdk/{host-C3FMSKBX.mjs.map → host-3Y2RVF7E.mjs.map} +0 -0
- /package/dist/sdk/{routing-GFHGNOMS.mjs.map → routing-Q5IPCQLI.mjs.map} +0 -0
- /package/dist/sdk/{schedule-tool-3XCZR3NC.mjs.map → schedule-tool-MDPOLK4O.mjs.map} +0 -0
- /package/dist/sdk/{schedule-tool-handler-4ECAAHEH.mjs.map → schedule-tool-handler-D2NV7ATP.mjs.map} +0 -0
- /package/dist/sdk/{trace-helpers-D67B7FOU.mjs.map → trace-helpers-SETVIO5T.mjs.map} +0 -0
- /package/dist/sdk/{track-execution-DHQA6FAE.mjs.map → track-execution-6EWFXL34.mjs.map} +0 -0
- /package/dist/sdk/{workflow-check-provider-DNPDEVSQ.mjs.map → workflow-check-provider-7U66H2MI.mjs.map} +0 -0
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
process.env.VISOR_VERSION = '0.1.
|
|
3
|
-
process.env.PROBE_VERSION = '0.6.0-
|
|
4
|
-
process.env.VISOR_COMMIT_SHA = '
|
|
5
|
-
process.env.VISOR_COMMIT_SHORT = '
|
|
2
|
+
process.env.VISOR_VERSION = '0.1.193';
|
|
3
|
+
process.env.PROBE_VERSION = '0.6.0-rc339';
|
|
4
|
+
process.env.VISOR_COMMIT_SHA = 'eda9853bb7a506ff2804af8a53a419885467cd8a';
|
|
5
|
+
process.env.VISOR_COMMIT_SHORT = 'eda9853';
|
|
6
6
|
/******/ (() => { // webpackBootstrap
|
|
7
7
|
/******/ var __webpack_modules__ = ({
|
|
8
8
|
|
|
@@ -475992,6 +475992,218 @@ var init_v3 = __esm({
|
|
|
475992
475992
|
}
|
|
475993
475993
|
});
|
|
475994
475994
|
|
|
475995
|
+
// node_modules/eventsource-parser/dist/index.js
|
|
475996
|
+
function noop(_arg) {
|
|
475997
|
+
}
|
|
475998
|
+
function createParser(config2) {
|
|
475999
|
+
if (typeof config2 == "function")
|
|
476000
|
+
throw new TypeError(
|
|
476001
|
+
"`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?"
|
|
476002
|
+
);
|
|
476003
|
+
const { onEvent = noop, onError = noop, onRetry = noop, onComment, maxBufferSize } = config2, pendingFragments = [];
|
|
476004
|
+
let pendingFragmentsLength = 0, isFirstChunk = true, id, data2 = "", dataLines = 0, eventType, terminated = false;
|
|
476005
|
+
function feed(chunk) {
|
|
476006
|
+
if (terminated)
|
|
476007
|
+
throw new Error(
|
|
476008
|
+
"Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing."
|
|
476009
|
+
);
|
|
476010
|
+
if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
476011
|
+
const trailing2 = processLines(chunk);
|
|
476012
|
+
trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
|
|
476013
|
+
return;
|
|
476014
|
+
}
|
|
476015
|
+
if (chunk.indexOf(`
|
|
476016
|
+
`) === -1 && chunk.indexOf("\r") === -1) {
|
|
476017
|
+
pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
|
|
476018
|
+
return;
|
|
476019
|
+
}
|
|
476020
|
+
pendingFragments.push(chunk);
|
|
476021
|
+
const input = pendingFragments.join("");
|
|
476022
|
+
pendingFragments.length = 0, pendingFragmentsLength = 0;
|
|
476023
|
+
const trailing = processLines(input);
|
|
476024
|
+
trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
|
|
476025
|
+
}
|
|
476026
|
+
function checkBufferSize() {
|
|
476027
|
+
maxBufferSize !== void 0 && (pendingFragmentsLength + data2.length <= maxBufferSize || (terminated = true, pendingFragments.length = 0, pendingFragmentsLength = 0, id = void 0, data2 = "", dataLines = 0, eventType = void 0, onError(
|
|
476028
|
+
new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, {
|
|
476029
|
+
type: "max-buffer-size-exceeded"
|
|
476030
|
+
})
|
|
476031
|
+
)));
|
|
476032
|
+
}
|
|
476033
|
+
function processLines(chunk) {
|
|
476034
|
+
let searchIndex = 0;
|
|
476035
|
+
if (chunk.indexOf("\r") === -1) {
|
|
476036
|
+
let lfIndex = chunk.indexOf(`
|
|
476037
|
+
`, searchIndex);
|
|
476038
|
+
for (; lfIndex !== -1; ) {
|
|
476039
|
+
if (searchIndex === lfIndex) {
|
|
476040
|
+
dataLines > 0 && onEvent({ id, event: eventType, data: data2 }), id = void 0, data2 = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
476041
|
+
`, searchIndex);
|
|
476042
|
+
continue;
|
|
476043
|
+
}
|
|
476044
|
+
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
476045
|
+
if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
|
|
476046
|
+
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
476047
|
+
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
|
|
476048
|
+
onEvent({ id, event: eventType, data: value }), id = void 0, data2 = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
476049
|
+
`, searchIndex);
|
|
476050
|
+
continue;
|
|
476051
|
+
}
|
|
476052
|
+
data2 = dataLines === 0 ? value : `${data2}
|
|
476053
|
+
${value}`, dataLines++;
|
|
476054
|
+
} else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
|
|
476055
|
+
chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
|
|
476056
|
+
lfIndex
|
|
476057
|
+
) || void 0 : parseLine(chunk, searchIndex, lfIndex);
|
|
476058
|
+
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
476059
|
+
`, searchIndex);
|
|
476060
|
+
}
|
|
476061
|
+
return chunk.slice(searchIndex);
|
|
476062
|
+
}
|
|
476063
|
+
for (; searchIndex < chunk.length; ) {
|
|
476064
|
+
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
476065
|
+
`, searchIndex);
|
|
476066
|
+
let lineEnd = -1;
|
|
476067
|
+
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)
|
|
476068
|
+
break;
|
|
476069
|
+
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
|
|
476070
|
+
}
|
|
476071
|
+
return chunk.slice(searchIndex);
|
|
476072
|
+
}
|
|
476073
|
+
function parseLine(chunk, start, end) {
|
|
476074
|
+
if (start === end) {
|
|
476075
|
+
dispatchEvent();
|
|
476076
|
+
return;
|
|
476077
|
+
}
|
|
476078
|
+
const firstCharCode = chunk.charCodeAt(start);
|
|
476079
|
+
if (isDataPrefix(chunk, start, firstCharCode)) {
|
|
476080
|
+
const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
|
|
476081
|
+
data2 = dataLines === 0 ? value2 : `${data2}
|
|
476082
|
+
${value2}`, dataLines++;
|
|
476083
|
+
return;
|
|
476084
|
+
}
|
|
476085
|
+
if (isEventPrefix(chunk, start, firstCharCode)) {
|
|
476086
|
+
eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
|
|
476087
|
+
return;
|
|
476088
|
+
}
|
|
476089
|
+
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
476090
|
+
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
|
|
476091
|
+
value2.includes("\0") || (id = value2);
|
|
476092
|
+
return;
|
|
476093
|
+
}
|
|
476094
|
+
if (firstCharCode === 58) {
|
|
476095
|
+
if (onComment) {
|
|
476096
|
+
const line2 = chunk.slice(start, end);
|
|
476097
|
+
onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
|
|
476098
|
+
}
|
|
476099
|
+
return;
|
|
476100
|
+
}
|
|
476101
|
+
const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
|
|
476102
|
+
if (fieldSeparatorIndex === -1) {
|
|
476103
|
+
processField(line, "", line);
|
|
476104
|
+
return;
|
|
476105
|
+
}
|
|
476106
|
+
const field = line.slice(0, fieldSeparatorIndex), offset2 = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset2);
|
|
476107
|
+
processField(field, value, line);
|
|
476108
|
+
}
|
|
476109
|
+
function processField(field, value, line) {
|
|
476110
|
+
switch (field) {
|
|
476111
|
+
case "event":
|
|
476112
|
+
eventType = value || void 0;
|
|
476113
|
+
break;
|
|
476114
|
+
case "data":
|
|
476115
|
+
data2 = dataLines === 0 ? value : `${data2}
|
|
476116
|
+
${value}`, dataLines++;
|
|
476117
|
+
break;
|
|
476118
|
+
case "id":
|
|
476119
|
+
value.includes("\0") || (id = value);
|
|
476120
|
+
break;
|
|
476121
|
+
case "retry":
|
|
476122
|
+
/^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
|
|
476123
|
+
new ParseError(`Invalid \`retry\` value: "${value}"`, {
|
|
476124
|
+
type: "invalid-retry",
|
|
476125
|
+
value,
|
|
476126
|
+
line
|
|
476127
|
+
})
|
|
476128
|
+
);
|
|
476129
|
+
break;
|
|
476130
|
+
default:
|
|
476131
|
+
onError(
|
|
476132
|
+
new ParseError(
|
|
476133
|
+
`Unknown field "${field.length > 20 ? `${field.slice(0, 20)}\u2026` : field}"`,
|
|
476134
|
+
{ type: "unknown-field", field, value, line }
|
|
476135
|
+
)
|
|
476136
|
+
);
|
|
476137
|
+
break;
|
|
476138
|
+
}
|
|
476139
|
+
}
|
|
476140
|
+
function dispatchEvent() {
|
|
476141
|
+
dataLines > 0 && onEvent({
|
|
476142
|
+
id,
|
|
476143
|
+
event: eventType,
|
|
476144
|
+
data: data2
|
|
476145
|
+
}), id = void 0, data2 = "", dataLines = 0, eventType = void 0;
|
|
476146
|
+
}
|
|
476147
|
+
function reset2(options = {}) {
|
|
476148
|
+
if (options.consume && pendingFragments.length > 0) {
|
|
476149
|
+
const incompleteLine = pendingFragments.join("");
|
|
476150
|
+
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
476151
|
+
}
|
|
476152
|
+
isFirstChunk = true, id = void 0, data2 = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = false;
|
|
476153
|
+
}
|
|
476154
|
+
return { feed, reset: reset2 };
|
|
476155
|
+
}
|
|
476156
|
+
function isDataPrefix(chunk, i, firstCharCode) {
|
|
476157
|
+
return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
|
|
476158
|
+
}
|
|
476159
|
+
function isEventPrefix(chunk, i, firstCharCode) {
|
|
476160
|
+
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;
|
|
476161
|
+
}
|
|
476162
|
+
var ParseError, LF, CR, SPACE;
|
|
476163
|
+
var init_dist2 = __esm({
|
|
476164
|
+
"node_modules/eventsource-parser/dist/index.js"() {
|
|
476165
|
+
ParseError = class extends Error {
|
|
476166
|
+
constructor(message, options) {
|
|
476167
|
+
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
476168
|
+
}
|
|
476169
|
+
};
|
|
476170
|
+
LF = 10;
|
|
476171
|
+
CR = 13;
|
|
476172
|
+
SPACE = 32;
|
|
476173
|
+
}
|
|
476174
|
+
});
|
|
476175
|
+
|
|
476176
|
+
// node_modules/eventsource-parser/dist/stream.js
|
|
476177
|
+
var EventSourceParserStream;
|
|
476178
|
+
var init_stream = __esm({
|
|
476179
|
+
"node_modules/eventsource-parser/dist/stream.js"() {
|
|
476180
|
+
init_dist2();
|
|
476181
|
+
EventSourceParserStream = class extends TransformStream {
|
|
476182
|
+
constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
|
|
476183
|
+
let parser;
|
|
476184
|
+
super({
|
|
476185
|
+
start(controller) {
|
|
476186
|
+
parser = createParser({
|
|
476187
|
+
onEvent: (event) => {
|
|
476188
|
+
controller.enqueue(event);
|
|
476189
|
+
},
|
|
476190
|
+
onError(error40) {
|
|
476191
|
+
typeof onError == "function" && onError(error40), (onError === "terminate" || error40.type === "max-buffer-size-exceeded") && controller.error(error40);
|
|
476192
|
+
},
|
|
476193
|
+
onRetry,
|
|
476194
|
+
onComment,
|
|
476195
|
+
maxBufferSize
|
|
476196
|
+
});
|
|
476197
|
+
},
|
|
476198
|
+
transform(chunk) {
|
|
476199
|
+
parser.feed(chunk);
|
|
476200
|
+
}
|
|
476201
|
+
});
|
|
476202
|
+
}
|
|
476203
|
+
};
|
|
476204
|
+
}
|
|
476205
|
+
});
|
|
476206
|
+
|
|
475995
476207
|
// node_modules/@ai-sdk/provider-utils/dist/index.mjs
|
|
475996
476208
|
function combineHeaders(...headers) {
|
|
475997
476209
|
return headers.reduce(
|
|
@@ -476005,6 +476217,11 @@ function combineHeaders(...headers) {
|
|
|
476005
476217
|
function extractResponseHeaders(response) {
|
|
476006
476218
|
return Object.fromEntries([...response.headers]);
|
|
476007
476219
|
}
|
|
476220
|
+
function convertBase64ToUint8Array(base64String) {
|
|
476221
|
+
const base64Url = base64String.replace(/-/g, "+").replace(/_/g, "/");
|
|
476222
|
+
const latin1string = atob2(base64Url);
|
|
476223
|
+
return Uint8Array.from(latin1string, (byte) => byte.codePointAt(0));
|
|
476224
|
+
}
|
|
476008
476225
|
function convertUint8ArrayToBase64(array2) {
|
|
476009
476226
|
let latin1string = "";
|
|
476010
476227
|
for (let i = 0; i < array2.length; i++) {
|
|
@@ -476015,6 +476232,28 @@ function convertUint8ArrayToBase64(array2) {
|
|
|
476015
476232
|
function convertToBase64(value) {
|
|
476016
476233
|
return value instanceof Uint8Array ? convertUint8ArrayToBase64(value) : value;
|
|
476017
476234
|
}
|
|
476235
|
+
function convertToFormData(input, options = {}) {
|
|
476236
|
+
const { useArrayBrackets = true } = options;
|
|
476237
|
+
const formData = new FormData();
|
|
476238
|
+
for (const [key, value] of Object.entries(input)) {
|
|
476239
|
+
if (value == null) {
|
|
476240
|
+
continue;
|
|
476241
|
+
}
|
|
476242
|
+
if (Array.isArray(value)) {
|
|
476243
|
+
if (value.length === 1) {
|
|
476244
|
+
formData.append(key, value[0]);
|
|
476245
|
+
continue;
|
|
476246
|
+
}
|
|
476247
|
+
const arrayKey = useArrayBrackets ? `${key}[]` : key;
|
|
476248
|
+
for (const item of value) {
|
|
476249
|
+
formData.append(arrayKey, item);
|
|
476250
|
+
}
|
|
476251
|
+
continue;
|
|
476252
|
+
}
|
|
476253
|
+
formData.append(key, value);
|
|
476254
|
+
}
|
|
476255
|
+
return formData;
|
|
476256
|
+
}
|
|
476018
476257
|
async function cancelResponseBody(response) {
|
|
476019
476258
|
var _a22;
|
|
476020
476259
|
try {
|
|
@@ -476022,6 +476261,202 @@ async function cancelResponseBody(response) {
|
|
|
476022
476261
|
} catch (e) {
|
|
476023
476262
|
}
|
|
476024
476263
|
}
|
|
476264
|
+
function isBrowserRuntime(globalThisAny = globalThis) {
|
|
476265
|
+
return globalThisAny.window != null;
|
|
476266
|
+
}
|
|
476267
|
+
function validateDownloadUrl(url2) {
|
|
476268
|
+
let parsed;
|
|
476269
|
+
try {
|
|
476270
|
+
parsed = new URL(url2);
|
|
476271
|
+
} catch (e) {
|
|
476272
|
+
throw new DownloadError({
|
|
476273
|
+
url: url2,
|
|
476274
|
+
message: `Invalid URL: ${url2}`
|
|
476275
|
+
});
|
|
476276
|
+
}
|
|
476277
|
+
if (parsed.protocol === "data:") {
|
|
476278
|
+
return;
|
|
476279
|
+
}
|
|
476280
|
+
if (parsed.protocol !== "http:" && parsed.protocol !== "https:") {
|
|
476281
|
+
throw new DownloadError({
|
|
476282
|
+
url: url2,
|
|
476283
|
+
message: `URL scheme must be http, https, or data, got ${parsed.protocol}`
|
|
476284
|
+
});
|
|
476285
|
+
}
|
|
476286
|
+
const hostname2 = parsed.hostname.toLowerCase().replace(/\.+$/, "");
|
|
476287
|
+
if (!hostname2) {
|
|
476288
|
+
throw new DownloadError({
|
|
476289
|
+
url: url2,
|
|
476290
|
+
message: `URL must have a hostname`
|
|
476291
|
+
});
|
|
476292
|
+
}
|
|
476293
|
+
if (hostname2 === "localhost" || hostname2.endsWith(".local") || hostname2.endsWith(".localhost")) {
|
|
476294
|
+
throw new DownloadError({
|
|
476295
|
+
url: url2,
|
|
476296
|
+
message: `URL with hostname ${hostname2} is not allowed`
|
|
476297
|
+
});
|
|
476298
|
+
}
|
|
476299
|
+
if (hostname2.startsWith("[") && hostname2.endsWith("]")) {
|
|
476300
|
+
const ipv63 = hostname2.slice(1, -1);
|
|
476301
|
+
if (isPrivateIPv6(ipv63)) {
|
|
476302
|
+
throw new DownloadError({
|
|
476303
|
+
url: url2,
|
|
476304
|
+
message: `URL with IPv6 address ${hostname2} is not allowed`
|
|
476305
|
+
});
|
|
476306
|
+
}
|
|
476307
|
+
return;
|
|
476308
|
+
}
|
|
476309
|
+
if (isIPv4(hostname2)) {
|
|
476310
|
+
if (isPrivateIPv4(hostname2)) {
|
|
476311
|
+
throw new DownloadError({
|
|
476312
|
+
url: url2,
|
|
476313
|
+
message: `URL with IP address ${hostname2} is not allowed`
|
|
476314
|
+
});
|
|
476315
|
+
}
|
|
476316
|
+
return;
|
|
476317
|
+
}
|
|
476318
|
+
}
|
|
476319
|
+
function validateDownloadAddress({
|
|
476320
|
+
address,
|
|
476321
|
+
family,
|
|
476322
|
+
hostname: hostname2
|
|
476323
|
+
}) {
|
|
476324
|
+
const isUnsafe = family === 4 ? !isIPv4(address) || isPrivateIPv4(address) : family === 6 ? isPrivateIPv6(address) : true;
|
|
476325
|
+
if (isUnsafe) {
|
|
476326
|
+
throw new DownloadError({
|
|
476327
|
+
url: hostname2,
|
|
476328
|
+
message: `Hostname ${hostname2} resolved to disallowed IP address ${address}`
|
|
476329
|
+
});
|
|
476330
|
+
}
|
|
476331
|
+
}
|
|
476332
|
+
function isIPv4(hostname2) {
|
|
476333
|
+
const parts = hostname2.split(".");
|
|
476334
|
+
if (parts.length !== 4) return false;
|
|
476335
|
+
return parts.every((part) => {
|
|
476336
|
+
const num = Number(part);
|
|
476337
|
+
return Number.isInteger(num) && num >= 0 && num <= 255 && String(num) === part;
|
|
476338
|
+
});
|
|
476339
|
+
}
|
|
476340
|
+
function isPrivateIPv4(ip) {
|
|
476341
|
+
const parts = ip.split(".").map(Number);
|
|
476342
|
+
const [a, b, c] = parts;
|
|
476343
|
+
if (a === 0) return true;
|
|
476344
|
+
if (a === 10) return true;
|
|
476345
|
+
if (a === 100 && b >= 64 && b <= 127) return true;
|
|
476346
|
+
if (a === 127) return true;
|
|
476347
|
+
if (a === 169 && b === 254) return true;
|
|
476348
|
+
if (a === 172 && b >= 16 && b <= 31) return true;
|
|
476349
|
+
if (a === 192 && b === 0 && c === 0) return true;
|
|
476350
|
+
if (a === 192 && b === 168) return true;
|
|
476351
|
+
if (a === 198 && (b === 18 || b === 19)) return true;
|
|
476352
|
+
if (a >= 240) return true;
|
|
476353
|
+
return false;
|
|
476354
|
+
}
|
|
476355
|
+
function parseIPv6(ip) {
|
|
476356
|
+
let address = ip.toLowerCase();
|
|
476357
|
+
const zoneIndex = address.indexOf("%");
|
|
476358
|
+
if (zoneIndex !== -1) {
|
|
476359
|
+
address = address.slice(0, zoneIndex);
|
|
476360
|
+
}
|
|
476361
|
+
const halves = address.split("::");
|
|
476362
|
+
if (halves.length > 2) return null;
|
|
476363
|
+
const toGroups = (segment) => {
|
|
476364
|
+
if (segment === "") return [];
|
|
476365
|
+
const groups = [];
|
|
476366
|
+
const parts = segment.split(":");
|
|
476367
|
+
for (let i = 0; i < parts.length; i++) {
|
|
476368
|
+
const part = parts[i];
|
|
476369
|
+
if (part.includes(".")) {
|
|
476370
|
+
if (i !== parts.length - 1 || !isIPv4(part)) return null;
|
|
476371
|
+
const [a, b, c, d] = part.split(".").map(Number);
|
|
476372
|
+
groups.push(a << 8 | b, c << 8 | d);
|
|
476373
|
+
continue;
|
|
476374
|
+
}
|
|
476375
|
+
if (!/^[0-9a-f]{1,4}$/.test(part)) return null;
|
|
476376
|
+
groups.push(parseInt(part, 16));
|
|
476377
|
+
}
|
|
476378
|
+
return groups;
|
|
476379
|
+
};
|
|
476380
|
+
const head2 = toGroups(halves[0]);
|
|
476381
|
+
if (head2 === null) return null;
|
|
476382
|
+
if (halves.length === 2) {
|
|
476383
|
+
const tail = toGroups(halves[1]);
|
|
476384
|
+
if (tail === null) return null;
|
|
476385
|
+
const fill = 8 - head2.length - tail.length;
|
|
476386
|
+
if (fill < 0) return null;
|
|
476387
|
+
return [...head2, ...new Array(fill).fill(0), ...tail];
|
|
476388
|
+
}
|
|
476389
|
+
return head2.length === 8 ? head2 : null;
|
|
476390
|
+
}
|
|
476391
|
+
function isPrivateIPv6(ip) {
|
|
476392
|
+
const groups = parseIPv6(ip);
|
|
476393
|
+
if (groups === null) return true;
|
|
476394
|
+
const topZero = (count) => groups.slice(0, count).every((group) => group === 0);
|
|
476395
|
+
if (topZero(7) && (groups[7] === 0 || groups[7] === 1)) return true;
|
|
476396
|
+
if ((groups[0] & 65024) === 64512) return true;
|
|
476397
|
+
if ((groups[0] & 65472) === 65152) return true;
|
|
476398
|
+
if ((groups[0] & 65472) === 65216) return true;
|
|
476399
|
+
if ((groups[0] & 65280) === 65280) return true;
|
|
476400
|
+
const embedsIPv4 = (
|
|
476401
|
+
// ::/96 — IPv4-compatible (deprecated)
|
|
476402
|
+
topZero(6) || // ::ffff:0:0/96 — IPv4-mapped (ffff in group 5)
|
|
476403
|
+
topZero(5) && groups[5] === 65535 || // ::ffff:0:0/96 — IPv4-translated form (ffff in group 4, group 5 zero)
|
|
476404
|
+
topZero(4) && groups[4] === 65535 && groups[5] === 0 || // 64:ff9b::/96 — NAT64 well-known prefix
|
|
476405
|
+
groups[0] === 100 && groups[1] === 65435 && groups[2] === 0 && groups[3] === 0 && groups[4] === 0 && groups[5] === 0 || // 64:ff9b:1::/48 — NAT64 local-use prefix
|
|
476406
|
+
groups[0] === 100 && groups[1] === 65435 && groups[2] === 1
|
|
476407
|
+
);
|
|
476408
|
+
if (embedsIPv4) {
|
|
476409
|
+
const a = groups[6] >> 8 & 255;
|
|
476410
|
+
const b = groups[6] & 255;
|
|
476411
|
+
const c = groups[7] >> 8 & 255;
|
|
476412
|
+
const d = groups[7] & 255;
|
|
476413
|
+
return isPrivateIPv4(`${a}.${b}.${c}.${d}`);
|
|
476414
|
+
}
|
|
476415
|
+
return false;
|
|
476416
|
+
}
|
|
476417
|
+
function createSafeLookup(lookup) {
|
|
476418
|
+
return ((hostname2, options, callback) => {
|
|
476419
|
+
lookup(hostname2, { ...options, all: true }, (error40, addresses) => {
|
|
476420
|
+
if (error40) {
|
|
476421
|
+
callback(error40);
|
|
476422
|
+
return;
|
|
476423
|
+
}
|
|
476424
|
+
try {
|
|
476425
|
+
const [firstAddress] = addresses;
|
|
476426
|
+
if (firstAddress == null) {
|
|
476427
|
+
throw new Error(`Hostname ${hostname2} did not resolve to an address`);
|
|
476428
|
+
}
|
|
476429
|
+
for (const { address, family } of addresses) {
|
|
476430
|
+
validateDownloadAddress({ address, family, hostname: hostname2 });
|
|
476431
|
+
}
|
|
476432
|
+
if (options.all === true) {
|
|
476433
|
+
callback(null, addresses);
|
|
476434
|
+
} else {
|
|
476435
|
+
callback(
|
|
476436
|
+
null,
|
|
476437
|
+
firstAddress.address,
|
|
476438
|
+
firstAddress.family
|
|
476439
|
+
);
|
|
476440
|
+
}
|
|
476441
|
+
} catch (error210) {
|
|
476442
|
+
callback(
|
|
476443
|
+
error210 instanceof Error ? error210 : new Error(String(error210))
|
|
476444
|
+
);
|
|
476445
|
+
}
|
|
476446
|
+
});
|
|
476447
|
+
});
|
|
476448
|
+
}
|
|
476449
|
+
function isNodeRuntime() {
|
|
476450
|
+
var _a22, _b22;
|
|
476451
|
+
const runtimeProcess = globalThis.process;
|
|
476452
|
+
return ((_a22 = runtimeProcess == null ? void 0 : runtimeProcess.release) == null ? void 0 : _a22.name) === "node" && ((_b22 = runtimeProcess.versions) == null ? void 0 : _b22.bun) == null;
|
|
476453
|
+
}
|
|
476454
|
+
async function getDefaultDownloadFetch() {
|
|
476455
|
+
if (!isNodeRuntime() || !initialGlobalFetchIsNodeDefault || globalThis.fetch !== initialGlobalFetch) {
|
|
476456
|
+
return globalThis.fetch;
|
|
476457
|
+
}
|
|
476458
|
+
return safeNodeFetchPromise != null ? safeNodeFetchPromise : safeNodeFetchPromise = createSafeNodeFetch();
|
|
476459
|
+
}
|
|
476025
476460
|
function isNodeDefaultFetch(fetch2) {
|
|
476026
476461
|
if (typeof fetch2 !== "function") {
|
|
476027
476462
|
return false;
|
|
@@ -476029,6 +476464,92 @@ function isNodeDefaultFetch(fetch2) {
|
|
|
476029
476464
|
const source = Function.prototype.toString.call(fetch2);
|
|
476030
476465
|
return source.includes("internal/deps/undici") || source.includes("lazy loading of undici");
|
|
476031
476466
|
}
|
|
476467
|
+
async function createSafeNodeFetch() {
|
|
476468
|
+
const [{ createRequire: createRequire2 }, { lookup }] = await Promise.all([
|
|
476469
|
+
loadNodeModule("node:module"),
|
|
476470
|
+
loadNodeModule("node:dns")
|
|
476471
|
+
]);
|
|
476472
|
+
const { Agent, fetch: fetch2 } = createRequire2(getCurrentModulePath())(
|
|
476473
|
+
"undici"
|
|
476474
|
+
);
|
|
476475
|
+
const dispatcher = new Agent({
|
|
476476
|
+
connect: {
|
|
476477
|
+
lookup: createSafeLookup(lookup)
|
|
476478
|
+
}
|
|
476479
|
+
});
|
|
476480
|
+
return ((input, init) => fetch2(
|
|
476481
|
+
input,
|
|
476482
|
+
{
|
|
476483
|
+
...init,
|
|
476484
|
+
dispatcher
|
|
476485
|
+
}
|
|
476486
|
+
));
|
|
476487
|
+
}
|
|
476488
|
+
async function loadNodeModule(id) {
|
|
476489
|
+
var _a22;
|
|
476490
|
+
const processWithBuiltins = globalThis.process;
|
|
476491
|
+
const builtinModule = (_a22 = processWithBuiltins == null ? void 0 : processWithBuiltins.getBuiltinModule) == null ? void 0 : _a22.call(processWithBuiltins, id);
|
|
476492
|
+
if (builtinModule == null) {
|
|
476493
|
+
throw new Error(`Node.js built-in module ${id} is unavailable`);
|
|
476494
|
+
}
|
|
476495
|
+
return builtinModule;
|
|
476496
|
+
}
|
|
476497
|
+
function getCurrentModulePath() {
|
|
476498
|
+
const originalPrepareStackTrace = Error.prepareStackTrace;
|
|
476499
|
+
try {
|
|
476500
|
+
Error.prepareStackTrace = (_error, callSites) => callSites;
|
|
476501
|
+
const error40 = new Error("Capture current module path");
|
|
476502
|
+
Error.captureStackTrace(error40, getCurrentModulePath);
|
|
476503
|
+
const [caller] = error40.stack;
|
|
476504
|
+
const fileName = caller == null ? void 0 : caller.getFileName();
|
|
476505
|
+
if (fileName == null) {
|
|
476506
|
+
throw new Error("Unable to determine the current module path");
|
|
476507
|
+
}
|
|
476508
|
+
return fileName;
|
|
476509
|
+
} finally {
|
|
476510
|
+
Error.prepareStackTrace = originalPrepareStackTrace;
|
|
476511
|
+
}
|
|
476512
|
+
}
|
|
476513
|
+
async function fetchWithValidatedRedirects({
|
|
476514
|
+
url: url2,
|
|
476515
|
+
headers,
|
|
476516
|
+
abortSignal,
|
|
476517
|
+
maxRedirects = MAX_DOWNLOAD_REDIRECTS
|
|
476518
|
+
}) {
|
|
476519
|
+
const baseInit = { signal: abortSignal };
|
|
476520
|
+
if (headers !== void 0) {
|
|
476521
|
+
baseInit.headers = headers;
|
|
476522
|
+
}
|
|
476523
|
+
let currentUrl = url2;
|
|
476524
|
+
for (let redirectCount = 0; redirectCount <= maxRedirects; redirectCount++) {
|
|
476525
|
+
validateDownloadUrl(currentUrl);
|
|
476526
|
+
const fetch2 = await getDefaultDownloadFetch();
|
|
476527
|
+
const response = await fetch2(currentUrl, {
|
|
476528
|
+
...baseInit,
|
|
476529
|
+
redirect: "manual"
|
|
476530
|
+
});
|
|
476531
|
+
if (response.type === "opaqueredirect") {
|
|
476532
|
+
if (!isBrowserRuntime()) {
|
|
476533
|
+
throw new DownloadError({
|
|
476534
|
+
url: url2,
|
|
476535
|
+
message: `Redirect from ${currentUrl} could not be validated and was blocked`
|
|
476536
|
+
});
|
|
476537
|
+
}
|
|
476538
|
+
return await fetch2(currentUrl, { ...baseInit, redirect: "follow" });
|
|
476539
|
+
}
|
|
476540
|
+
const location = response.headers.get("location");
|
|
476541
|
+
if (response.status >= 300 && response.status < 400 && location) {
|
|
476542
|
+
await cancelResponseBody(response);
|
|
476543
|
+
currentUrl = new URL(location, currentUrl).toString();
|
|
476544
|
+
continue;
|
|
476545
|
+
}
|
|
476546
|
+
return response;
|
|
476547
|
+
}
|
|
476548
|
+
throw new DownloadError({
|
|
476549
|
+
url: url2,
|
|
476550
|
+
message: `Too many redirects (max ${maxRedirects})`
|
|
476551
|
+
});
|
|
476552
|
+
}
|
|
476032
476553
|
async function readResponseWithSizeLimit({
|
|
476033
476554
|
response,
|
|
476034
476555
|
url: url2,
|
|
@@ -476083,6 +476604,35 @@ async function readResponseWithSizeLimit({
|
|
|
476083
476604
|
}
|
|
476084
476605
|
return result;
|
|
476085
476606
|
}
|
|
476607
|
+
async function downloadBlob(url2, options) {
|
|
476608
|
+
var _a22, _b22;
|
|
476609
|
+
try {
|
|
476610
|
+
const response = await fetchWithValidatedRedirects({
|
|
476611
|
+
url: url2,
|
|
476612
|
+
abortSignal: options == null ? void 0 : options.abortSignal
|
|
476613
|
+
});
|
|
476614
|
+
if (!response.ok) {
|
|
476615
|
+
await cancelResponseBody(response);
|
|
476616
|
+
throw new DownloadError({
|
|
476617
|
+
url: url2,
|
|
476618
|
+
statusCode: response.status,
|
|
476619
|
+
statusText: response.statusText
|
|
476620
|
+
});
|
|
476621
|
+
}
|
|
476622
|
+
const data2 = await readResponseWithSizeLimit({
|
|
476623
|
+
response,
|
|
476624
|
+
url: url2,
|
|
476625
|
+
maxBytes: (_a22 = options == null ? void 0 : options.maxBytes) != null ? _a22 : DEFAULT_MAX_DOWNLOAD_SIZE
|
|
476626
|
+
});
|
|
476627
|
+
const contentType = (_b22 = response.headers.get("content-type")) != null ? _b22 : void 0;
|
|
476628
|
+
return new Blob([data2], contentType ? { type: contentType } : void 0);
|
|
476629
|
+
} catch (error40) {
|
|
476630
|
+
if (DownloadError.isInstance(error40)) {
|
|
476631
|
+
throw error40;
|
|
476632
|
+
}
|
|
476633
|
+
throw new DownloadError({ url: url2, cause: error40 });
|
|
476634
|
+
}
|
|
476635
|
+
}
|
|
476086
476636
|
function isAbortError(error40) {
|
|
476087
476637
|
return (error40 instanceof Error || error40 instanceof DOMException) && (error40.name === "AbortError" || error40.name === "ResponseAborted" || // Next.js
|
|
476088
476638
|
error40.name === "TimeoutError");
|
|
@@ -477302,6 +477852,21 @@ async function safeParseJSON({
|
|
|
477302
477852
|
};
|
|
477303
477853
|
}
|
|
477304
477854
|
}
|
|
477855
|
+
function parseJsonEventStream({
|
|
477856
|
+
stream: stream2,
|
|
477857
|
+
schema
|
|
477858
|
+
}) {
|
|
477859
|
+
return stream2.pipeThrough(new TextDecoderStream()).pipeThrough(new EventSourceParserStream()).pipeThrough(
|
|
477860
|
+
new TransformStream({
|
|
477861
|
+
async transform({ data: data2 }, controller) {
|
|
477862
|
+
if (data2 === "[DONE]") {
|
|
477863
|
+
return;
|
|
477864
|
+
}
|
|
477865
|
+
controller.enqueue(await safeParseJSON({ text: data2, schema }));
|
|
477866
|
+
}
|
|
477867
|
+
})
|
|
477868
|
+
);
|
|
477869
|
+
}
|
|
477305
477870
|
async function parseProviderOptions({
|
|
477306
477871
|
provider,
|
|
477307
477872
|
providerOptions,
|
|
@@ -477329,6 +477894,62 @@ async function resolve(value) {
|
|
|
477329
477894
|
}
|
|
477330
477895
|
return Promise.resolve(value);
|
|
477331
477896
|
}
|
|
477897
|
+
function wrapResponseBodyStream({
|
|
477898
|
+
stream: stream2,
|
|
477899
|
+
url: url2,
|
|
477900
|
+
requestBodyValues,
|
|
477901
|
+
statusCode,
|
|
477902
|
+
responseHeaders
|
|
477903
|
+
}) {
|
|
477904
|
+
const reader = stream2.getReader();
|
|
477905
|
+
let readerReleased = false;
|
|
477906
|
+
const releaseReader = () => {
|
|
477907
|
+
if (!readerReleased) {
|
|
477908
|
+
reader.releaseLock();
|
|
477909
|
+
readerReleased = true;
|
|
477910
|
+
}
|
|
477911
|
+
};
|
|
477912
|
+
return new ReadableStream({
|
|
477913
|
+
async pull(controller) {
|
|
477914
|
+
try {
|
|
477915
|
+
const { done, value } = await reader.read();
|
|
477916
|
+
if (done) {
|
|
477917
|
+
releaseReader();
|
|
477918
|
+
controller.close();
|
|
477919
|
+
} else {
|
|
477920
|
+
controller.enqueue(value);
|
|
477921
|
+
}
|
|
477922
|
+
} catch (error40) {
|
|
477923
|
+
releaseReader();
|
|
477924
|
+
if (isAbortError(error40)) {
|
|
477925
|
+
controller.error(error40);
|
|
477926
|
+
return;
|
|
477927
|
+
}
|
|
477928
|
+
controller.error(
|
|
477929
|
+
handleFetchError({
|
|
477930
|
+
error: new APICallError({
|
|
477931
|
+
message: "Failed to process successful response",
|
|
477932
|
+
cause: error40,
|
|
477933
|
+
statusCode,
|
|
477934
|
+
url: url2,
|
|
477935
|
+
responseHeaders,
|
|
477936
|
+
requestBodyValues
|
|
477937
|
+
}),
|
|
477938
|
+
url: url2,
|
|
477939
|
+
requestBodyValues
|
|
477940
|
+
})
|
|
477941
|
+
);
|
|
477942
|
+
}
|
|
477943
|
+
},
|
|
477944
|
+
async cancel(reason) {
|
|
477945
|
+
try {
|
|
477946
|
+
await reader.cancel(reason);
|
|
477947
|
+
} finally {
|
|
477948
|
+
releaseReader();
|
|
477949
|
+
}
|
|
477950
|
+
}
|
|
477951
|
+
});
|
|
477952
|
+
}
|
|
477332
477953
|
async function readResponseBodyAsText({
|
|
477333
477954
|
response,
|
|
477334
477955
|
url: url2
|
|
@@ -477347,8 +477968,8 @@ function stripFileExtension(filename) {
|
|
|
477347
477968
|
function withoutTrailingSlash(url2) {
|
|
477348
477969
|
return url2 == null ? void 0 : url2.replace(/\/$/, "");
|
|
477349
477970
|
}
|
|
477350
|
-
var btoa2, atob2, name14, marker15, symbol16, _a15, _b15, DownloadError, initialGlobalFetch, initialGlobalFetchIsNodeDefault, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator, generateId, FETCH_FAILED_ERROR_MESSAGES, RETRYABLE_NETWORK_ERROR_CODES, VERSION, DEFAULT_SCHEMA_PREFIX, DEFAULT_SCHEMA_SUFFIX, DEFAULT_GENERIC_SUFFIX, suspectProtoRx, suspectConstructorRx, ignoreOverride, defaultOptions, getDefaultOptions, parseCatchDef, integerDateParser, isJsonSchema7AllOfType, emojiRegex2, zodPatterns, ALPHA_NUMERIC, primitiveMappings, asAnyOf, parseOptionalDef, parsePipelineDef, parseReadonlyDef, selectParser, getRelativePath, get$ref, addMeta, getRefs, zod3ToJsonSchema, schemaSymbol, getOriginalFetch2, postJsonToApi, postToApi, textDecoder, createJsonErrorResponseHandler, createJsonResponseHandler;
|
|
477351
|
-
var
|
|
477971
|
+
var btoa2, atob2, name14, marker15, symbol16, _a15, _b15, DownloadError, safeNodeFetchPromise, initialGlobalFetch, initialGlobalFetchIsNodeDefault, MAX_DOWNLOAD_REDIRECTS, DEFAULT_MAX_DOWNLOAD_SIZE, createIdGenerator, generateId, FETCH_FAILED_ERROR_MESSAGES, RETRYABLE_NETWORK_ERROR_CODES, VERSION, DEFAULT_SCHEMA_PREFIX, DEFAULT_SCHEMA_SUFFIX, DEFAULT_GENERIC_SUFFIX, suspectProtoRx, suspectConstructorRx, ignoreOverride, defaultOptions, getDefaultOptions, parseCatchDef, integerDateParser, isJsonSchema7AllOfType, emojiRegex2, zodPatterns, ALPHA_NUMERIC, primitiveMappings, asAnyOf, parseOptionalDef, parsePipelineDef, parseReadonlyDef, selectParser, getRelativePath, get$ref, addMeta, getRefs, zod3ToJsonSchema, schemaSymbol, getOriginalFetch2, postJsonToApi, postFormDataToApi, postToApi, textDecoder, createJsonErrorResponseHandler, createEventSourceResponseHandler, createJsonResponseHandler;
|
|
477972
|
+
var init_dist3 = __esm({
|
|
477352
477973
|
"node_modules/@ai-sdk/provider-utils/dist/index.mjs"() {
|
|
477353
477974
|
init_dist();
|
|
477354
477975
|
init_dist();
|
|
@@ -477361,6 +477982,7 @@ var init_dist2 = __esm({
|
|
|
477361
477982
|
init_v3();
|
|
477362
477983
|
init_v3();
|
|
477363
477984
|
init_v3();
|
|
477985
|
+
init_stream();
|
|
477364
477986
|
init_dist();
|
|
477365
477987
|
init_dist();
|
|
477366
477988
|
init_dist();
|
|
@@ -477388,6 +478010,7 @@ var init_dist2 = __esm({
|
|
|
477388
478010
|
};
|
|
477389
478011
|
initialGlobalFetch = globalThis.fetch;
|
|
477390
478012
|
initialGlobalFetchIsNodeDefault = isNodeDefaultFetch(initialGlobalFetch);
|
|
478013
|
+
MAX_DOWNLOAD_REDIRECTS = 10;
|
|
477391
478014
|
DEFAULT_MAX_DOWNLOAD_SIZE = 2 * 1024 * 1024 * 1024;
|
|
477392
478015
|
createIdGenerator = ({
|
|
477393
478016
|
prefix,
|
|
@@ -477796,6 +478419,26 @@ var init_dist2 = __esm({
|
|
|
477796
478419
|
abortSignal,
|
|
477797
478420
|
fetch: fetch2
|
|
477798
478421
|
});
|
|
478422
|
+
postFormDataToApi = async ({
|
|
478423
|
+
url: url2,
|
|
478424
|
+
headers,
|
|
478425
|
+
formData,
|
|
478426
|
+
failedResponseHandler,
|
|
478427
|
+
successfulResponseHandler,
|
|
478428
|
+
abortSignal,
|
|
478429
|
+
fetch: fetch2
|
|
478430
|
+
}) => postToApi({
|
|
478431
|
+
url: url2,
|
|
478432
|
+
headers,
|
|
478433
|
+
body: {
|
|
478434
|
+
content: formData,
|
|
478435
|
+
values: Object.fromEntries(formData.entries())
|
|
478436
|
+
},
|
|
478437
|
+
failedResponseHandler,
|
|
478438
|
+
successfulResponseHandler,
|
|
478439
|
+
abortSignal,
|
|
478440
|
+
fetch: fetch2
|
|
478441
|
+
});
|
|
477799
478442
|
postToApi = async ({
|
|
477800
478443
|
url: url2,
|
|
477801
478444
|
headers = {},
|
|
@@ -477920,6 +478563,25 @@ var init_dist2 = __esm({
|
|
|
477920
478563
|
};
|
|
477921
478564
|
}
|
|
477922
478565
|
};
|
|
478566
|
+
createEventSourceResponseHandler = (chunkSchema) => async ({ response, url: url2, requestBodyValues }) => {
|
|
478567
|
+
const responseHeaders = extractResponseHeaders(response);
|
|
478568
|
+
if (response.body == null) {
|
|
478569
|
+
throw new EmptyResponseBodyError({});
|
|
478570
|
+
}
|
|
478571
|
+
return {
|
|
478572
|
+
responseHeaders,
|
|
478573
|
+
value: parseJsonEventStream({
|
|
478574
|
+
stream: wrapResponseBodyStream({
|
|
478575
|
+
stream: response.body,
|
|
478576
|
+
url: url2,
|
|
478577
|
+
requestBodyValues,
|
|
478578
|
+
statusCode: response.status,
|
|
478579
|
+
responseHeaders
|
|
478580
|
+
}),
|
|
478581
|
+
schema: chunkSchema
|
|
478582
|
+
})
|
|
478583
|
+
};
|
|
478584
|
+
};
|
|
477923
478585
|
createJsonResponseHandler = (responseSchema) => async ({ response, url: url2, requestBodyValues }) => {
|
|
477924
478586
|
const responseBody = await readResponseBodyAsText({ response, url: url2 });
|
|
477925
478587
|
const parsedResult = await safeParseJSON({
|
|
@@ -477947,6 +478609,1758 @@ var init_dist2 = __esm({
|
|
|
477947
478609
|
}
|
|
477948
478610
|
});
|
|
477949
478611
|
|
|
478612
|
+
// node_modules/@ai-sdk/openai-compatible/dist/index.mjs
|
|
478613
|
+
function toCamelCase(str) {
|
|
478614
|
+
return str.replace(/[_-]([a-z])/g, (g) => g[1].toUpperCase());
|
|
478615
|
+
}
|
|
478616
|
+
function resolveProviderOptionsKey(rawName, providerOptions) {
|
|
478617
|
+
const camelName = toCamelCase(rawName);
|
|
478618
|
+
if (camelName !== rawName && (providerOptions == null ? void 0 : providerOptions[camelName]) != null) {
|
|
478619
|
+
return camelName;
|
|
478620
|
+
}
|
|
478621
|
+
return rawName;
|
|
478622
|
+
}
|
|
478623
|
+
function convertOpenAICompatibleChatUsage(usage) {
|
|
478624
|
+
var _a17, _b16, _c, _d, _e, _f;
|
|
478625
|
+
if (usage == null) {
|
|
478626
|
+
return {
|
|
478627
|
+
inputTokens: {
|
|
478628
|
+
total: void 0,
|
|
478629
|
+
noCache: void 0,
|
|
478630
|
+
cacheRead: void 0,
|
|
478631
|
+
cacheWrite: void 0
|
|
478632
|
+
},
|
|
478633
|
+
outputTokens: {
|
|
478634
|
+
total: void 0,
|
|
478635
|
+
text: void 0,
|
|
478636
|
+
reasoning: void 0
|
|
478637
|
+
},
|
|
478638
|
+
raw: void 0
|
|
478639
|
+
};
|
|
478640
|
+
}
|
|
478641
|
+
const promptTokens = (_a17 = usage.prompt_tokens) != null ? _a17 : 0;
|
|
478642
|
+
const completionTokens = (_b16 = usage.completion_tokens) != null ? _b16 : 0;
|
|
478643
|
+
const cacheReadTokens = (_d = (_c = usage.prompt_tokens_details) == null ? void 0 : _c.cached_tokens) != null ? _d : 0;
|
|
478644
|
+
const reasoningTokens = (_f = (_e = usage.completion_tokens_details) == null ? void 0 : _e.reasoning_tokens) != null ? _f : 0;
|
|
478645
|
+
return {
|
|
478646
|
+
inputTokens: {
|
|
478647
|
+
total: promptTokens,
|
|
478648
|
+
noCache: promptTokens - cacheReadTokens,
|
|
478649
|
+
cacheRead: cacheReadTokens,
|
|
478650
|
+
cacheWrite: void 0
|
|
478651
|
+
},
|
|
478652
|
+
outputTokens: {
|
|
478653
|
+
total: completionTokens,
|
|
478654
|
+
text: Math.max(0, completionTokens - reasoningTokens),
|
|
478655
|
+
reasoning: reasoningTokens
|
|
478656
|
+
},
|
|
478657
|
+
raw: usage
|
|
478658
|
+
};
|
|
478659
|
+
}
|
|
478660
|
+
function getOpenAIMetadata(message) {
|
|
478661
|
+
var _a17, _b16;
|
|
478662
|
+
return (_b16 = (_a17 = message == null ? void 0 : message.providerOptions) == null ? void 0 : _a17.openaiCompatible) != null ? _b16 : {};
|
|
478663
|
+
}
|
|
478664
|
+
function getAudioFormat(mediaType) {
|
|
478665
|
+
switch (mediaType) {
|
|
478666
|
+
case "audio/wav":
|
|
478667
|
+
return "wav";
|
|
478668
|
+
case "audio/mp3":
|
|
478669
|
+
case "audio/mpeg":
|
|
478670
|
+
return "mp3";
|
|
478671
|
+
default:
|
|
478672
|
+
return null;
|
|
478673
|
+
}
|
|
478674
|
+
}
|
|
478675
|
+
function convertToOpenAICompatibleChatMessages(prompt) {
|
|
478676
|
+
var _a17, _b16, _c;
|
|
478677
|
+
const messages = [];
|
|
478678
|
+
for (const { role, content, ...message } of prompt) {
|
|
478679
|
+
const metadata = getOpenAIMetadata({ ...message });
|
|
478680
|
+
switch (role) {
|
|
478681
|
+
case "system": {
|
|
478682
|
+
messages.push({ role: "system", content, ...metadata });
|
|
478683
|
+
break;
|
|
478684
|
+
}
|
|
478685
|
+
case "user": {
|
|
478686
|
+
if (content.length === 1 && content[0].type === "text") {
|
|
478687
|
+
messages.push({
|
|
478688
|
+
role: "user",
|
|
478689
|
+
content: content[0].text,
|
|
478690
|
+
...getOpenAIMetadata(content[0])
|
|
478691
|
+
});
|
|
478692
|
+
break;
|
|
478693
|
+
}
|
|
478694
|
+
messages.push({
|
|
478695
|
+
role: "user",
|
|
478696
|
+
content: content.map((part) => {
|
|
478697
|
+
var _a22;
|
|
478698
|
+
const partMetadata = getOpenAIMetadata(part);
|
|
478699
|
+
switch (part.type) {
|
|
478700
|
+
case "text": {
|
|
478701
|
+
return { type: "text", text: part.text, ...partMetadata };
|
|
478702
|
+
}
|
|
478703
|
+
case "file": {
|
|
478704
|
+
if (part.mediaType.startsWith("image/")) {
|
|
478705
|
+
const mediaType = part.mediaType === "image/*" ? "image/jpeg" : part.mediaType;
|
|
478706
|
+
return {
|
|
478707
|
+
type: "image_url",
|
|
478708
|
+
image_url: {
|
|
478709
|
+
url: part.data instanceof URL ? part.data.toString() : `data:${mediaType};base64,${convertToBase64(part.data)}`
|
|
478710
|
+
},
|
|
478711
|
+
...partMetadata
|
|
478712
|
+
};
|
|
478713
|
+
}
|
|
478714
|
+
if (part.mediaType.startsWith("audio/")) {
|
|
478715
|
+
if (part.data instanceof URL) {
|
|
478716
|
+
throw new UnsupportedFunctionalityError({
|
|
478717
|
+
functionality: "audio file parts with URLs"
|
|
478718
|
+
});
|
|
478719
|
+
}
|
|
478720
|
+
const format2 = getAudioFormat(part.mediaType);
|
|
478721
|
+
if (format2 === null) {
|
|
478722
|
+
throw new UnsupportedFunctionalityError({
|
|
478723
|
+
functionality: `audio media type ${part.mediaType}`
|
|
478724
|
+
});
|
|
478725
|
+
}
|
|
478726
|
+
return {
|
|
478727
|
+
type: "input_audio",
|
|
478728
|
+
input_audio: {
|
|
478729
|
+
data: convertToBase64(part.data),
|
|
478730
|
+
format: format2
|
|
478731
|
+
},
|
|
478732
|
+
...partMetadata
|
|
478733
|
+
};
|
|
478734
|
+
}
|
|
478735
|
+
if (part.mediaType === "application/pdf") {
|
|
478736
|
+
if (part.data instanceof URL) {
|
|
478737
|
+
throw new UnsupportedFunctionalityError({
|
|
478738
|
+
functionality: "PDF file parts with URLs"
|
|
478739
|
+
});
|
|
478740
|
+
}
|
|
478741
|
+
return {
|
|
478742
|
+
type: "file",
|
|
478743
|
+
file: {
|
|
478744
|
+
filename: (_a22 = part.filename) != null ? _a22 : "document.pdf",
|
|
478745
|
+
file_data: `data:application/pdf;base64,${convertToBase64(part.data)}`
|
|
478746
|
+
},
|
|
478747
|
+
...partMetadata
|
|
478748
|
+
};
|
|
478749
|
+
}
|
|
478750
|
+
if (part.mediaType.startsWith("text/")) {
|
|
478751
|
+
const textContent = part.data instanceof URL ? part.data.toString() : typeof part.data === "string" ? new TextDecoder().decode(
|
|
478752
|
+
convertBase64ToUint8Array(part.data)
|
|
478753
|
+
) : new TextDecoder().decode(part.data);
|
|
478754
|
+
return {
|
|
478755
|
+
type: "text",
|
|
478756
|
+
text: textContent,
|
|
478757
|
+
...partMetadata
|
|
478758
|
+
};
|
|
478759
|
+
}
|
|
478760
|
+
throw new UnsupportedFunctionalityError({
|
|
478761
|
+
functionality: `file part media type ${part.mediaType}`
|
|
478762
|
+
});
|
|
478763
|
+
}
|
|
478764
|
+
}
|
|
478765
|
+
}),
|
|
478766
|
+
...metadata
|
|
478767
|
+
});
|
|
478768
|
+
break;
|
|
478769
|
+
}
|
|
478770
|
+
case "assistant": {
|
|
478771
|
+
let text = "";
|
|
478772
|
+
let reasoning = "";
|
|
478773
|
+
const toolCalls = [];
|
|
478774
|
+
for (const part of content) {
|
|
478775
|
+
const partMetadata = getOpenAIMetadata(part);
|
|
478776
|
+
switch (part.type) {
|
|
478777
|
+
case "text": {
|
|
478778
|
+
text += part.text;
|
|
478779
|
+
break;
|
|
478780
|
+
}
|
|
478781
|
+
case "reasoning": {
|
|
478782
|
+
reasoning += part.text;
|
|
478783
|
+
break;
|
|
478784
|
+
}
|
|
478785
|
+
case "tool-call": {
|
|
478786
|
+
const thoughtSignature = (_b16 = (_a17 = part.providerOptions) == null ? void 0 : _a17.google) == null ? void 0 : _b16.thoughtSignature;
|
|
478787
|
+
toolCalls.push({
|
|
478788
|
+
id: part.toolCallId,
|
|
478789
|
+
type: "function",
|
|
478790
|
+
function: {
|
|
478791
|
+
name: part.toolName,
|
|
478792
|
+
arguments: JSON.stringify(part.input)
|
|
478793
|
+
},
|
|
478794
|
+
...partMetadata,
|
|
478795
|
+
// Include extra_content for Google Gemini thought signatures
|
|
478796
|
+
...thoughtSignature ? {
|
|
478797
|
+
extra_content: {
|
|
478798
|
+
google: {
|
|
478799
|
+
thought_signature: String(thoughtSignature)
|
|
478800
|
+
}
|
|
478801
|
+
}
|
|
478802
|
+
} : {}
|
|
478803
|
+
});
|
|
478804
|
+
break;
|
|
478805
|
+
}
|
|
478806
|
+
}
|
|
478807
|
+
}
|
|
478808
|
+
messages.push({
|
|
478809
|
+
role: "assistant",
|
|
478810
|
+
content: toolCalls.length > 0 ? text || null : text,
|
|
478811
|
+
...reasoning.length > 0 ? { reasoning_content: reasoning } : {},
|
|
478812
|
+
tool_calls: toolCalls.length > 0 ? toolCalls : void 0,
|
|
478813
|
+
...metadata
|
|
478814
|
+
});
|
|
478815
|
+
break;
|
|
478816
|
+
}
|
|
478817
|
+
case "tool": {
|
|
478818
|
+
for (const toolResponse of content) {
|
|
478819
|
+
if (toolResponse.type === "tool-approval-response") {
|
|
478820
|
+
continue;
|
|
478821
|
+
}
|
|
478822
|
+
const output = toolResponse.output;
|
|
478823
|
+
let contentValue;
|
|
478824
|
+
switch (output.type) {
|
|
478825
|
+
case "text":
|
|
478826
|
+
case "error-text":
|
|
478827
|
+
contentValue = output.value;
|
|
478828
|
+
break;
|
|
478829
|
+
case "execution-denied":
|
|
478830
|
+
contentValue = (_c = output.reason) != null ? _c : "Tool call execution denied.";
|
|
478831
|
+
break;
|
|
478832
|
+
case "content":
|
|
478833
|
+
case "json":
|
|
478834
|
+
case "error-json":
|
|
478835
|
+
contentValue = JSON.stringify(output.value);
|
|
478836
|
+
break;
|
|
478837
|
+
}
|
|
478838
|
+
const toolResponseMetadata = getOpenAIMetadata(toolResponse);
|
|
478839
|
+
messages.push({
|
|
478840
|
+
role: "tool",
|
|
478841
|
+
tool_call_id: toolResponse.toolCallId,
|
|
478842
|
+
content: contentValue,
|
|
478843
|
+
...toolResponseMetadata
|
|
478844
|
+
});
|
|
478845
|
+
}
|
|
478846
|
+
break;
|
|
478847
|
+
}
|
|
478848
|
+
default: {
|
|
478849
|
+
const _exhaustiveCheck = role;
|
|
478850
|
+
throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
|
|
478851
|
+
}
|
|
478852
|
+
}
|
|
478853
|
+
}
|
|
478854
|
+
return messages;
|
|
478855
|
+
}
|
|
478856
|
+
function getResponseMetadata({
|
|
478857
|
+
id,
|
|
478858
|
+
model,
|
|
478859
|
+
created
|
|
478860
|
+
}) {
|
|
478861
|
+
return {
|
|
478862
|
+
id: id != null ? id : void 0,
|
|
478863
|
+
modelId: model != null ? model : void 0,
|
|
478864
|
+
timestamp: created != null ? new Date(created * 1e3) : void 0
|
|
478865
|
+
};
|
|
478866
|
+
}
|
|
478867
|
+
function mapOpenAICompatibleFinishReason(finishReason) {
|
|
478868
|
+
switch (finishReason) {
|
|
478869
|
+
case "stop":
|
|
478870
|
+
return "stop";
|
|
478871
|
+
case "length":
|
|
478872
|
+
return "length";
|
|
478873
|
+
case "content_filter":
|
|
478874
|
+
return "content-filter";
|
|
478875
|
+
case "function_call":
|
|
478876
|
+
case "tool_calls":
|
|
478877
|
+
return "tool-calls";
|
|
478878
|
+
default:
|
|
478879
|
+
return "other";
|
|
478880
|
+
}
|
|
478881
|
+
}
|
|
478882
|
+
function prepareTools({
|
|
478883
|
+
tools: tools2,
|
|
478884
|
+
toolChoice
|
|
478885
|
+
}) {
|
|
478886
|
+
tools2 = (tools2 == null ? void 0 : tools2.length) ? tools2 : void 0;
|
|
478887
|
+
const toolWarnings = [];
|
|
478888
|
+
if (tools2 == null) {
|
|
478889
|
+
return { tools: void 0, toolChoice: void 0, toolWarnings };
|
|
478890
|
+
}
|
|
478891
|
+
const openaiCompatTools = [];
|
|
478892
|
+
for (const tool6 of tools2) {
|
|
478893
|
+
if (tool6.type === "provider") {
|
|
478894
|
+
toolWarnings.push({
|
|
478895
|
+
type: "unsupported",
|
|
478896
|
+
feature: `provider-defined tool ${tool6.id}`
|
|
478897
|
+
});
|
|
478898
|
+
} else {
|
|
478899
|
+
openaiCompatTools.push({
|
|
478900
|
+
type: "function",
|
|
478901
|
+
function: {
|
|
478902
|
+
name: tool6.name,
|
|
478903
|
+
description: tool6.description,
|
|
478904
|
+
parameters: tool6.inputSchema,
|
|
478905
|
+
...tool6.strict != null ? { strict: tool6.strict } : {}
|
|
478906
|
+
}
|
|
478907
|
+
});
|
|
478908
|
+
}
|
|
478909
|
+
}
|
|
478910
|
+
if (toolChoice == null) {
|
|
478911
|
+
return { tools: openaiCompatTools, toolChoice: void 0, toolWarnings };
|
|
478912
|
+
}
|
|
478913
|
+
const type = toolChoice.type;
|
|
478914
|
+
switch (type) {
|
|
478915
|
+
case "auto":
|
|
478916
|
+
case "none":
|
|
478917
|
+
case "required":
|
|
478918
|
+
return { tools: openaiCompatTools, toolChoice: type, toolWarnings };
|
|
478919
|
+
case "tool":
|
|
478920
|
+
return {
|
|
478921
|
+
tools: openaiCompatTools,
|
|
478922
|
+
toolChoice: {
|
|
478923
|
+
type: "function",
|
|
478924
|
+
function: { name: toolChoice.toolName }
|
|
478925
|
+
},
|
|
478926
|
+
toolWarnings
|
|
478927
|
+
};
|
|
478928
|
+
default: {
|
|
478929
|
+
const _exhaustiveCheck = type;
|
|
478930
|
+
throw new UnsupportedFunctionalityError({
|
|
478931
|
+
functionality: `tool choice type: ${_exhaustiveCheck}`
|
|
478932
|
+
});
|
|
478933
|
+
}
|
|
478934
|
+
}
|
|
478935
|
+
}
|
|
478936
|
+
function convertOpenAICompatibleContent(content) {
|
|
478937
|
+
if (content == null) {
|
|
478938
|
+
return [];
|
|
478939
|
+
}
|
|
478940
|
+
if (typeof content === "string") {
|
|
478941
|
+
return content.length > 0 ? [{ type: "text", text: content }] : [];
|
|
478942
|
+
}
|
|
478943
|
+
const result = [];
|
|
478944
|
+
for (const part of content) {
|
|
478945
|
+
if (part.type === "text" && typeof part.text === "string") {
|
|
478946
|
+
if (part.text.length > 0) {
|
|
478947
|
+
result.push({ type: "text", text: part.text });
|
|
478948
|
+
}
|
|
478949
|
+
} else if (part.type === "thinking" && Array.isArray(part.thinking)) {
|
|
478950
|
+
const reasoningText = part.thinking.filter(
|
|
478951
|
+
(chunk) => chunk != null && typeof chunk === "object" && "type" in chunk && chunk.type === "text" && "text" in chunk && typeof chunk.text === "string"
|
|
478952
|
+
).map((chunk) => chunk.text).join("");
|
|
478953
|
+
if (reasoningText.length > 0) {
|
|
478954
|
+
result.push({ type: "reasoning", text: reasoningText });
|
|
478955
|
+
}
|
|
478956
|
+
}
|
|
478957
|
+
}
|
|
478958
|
+
return result;
|
|
478959
|
+
}
|
|
478960
|
+
function convertOpenAICompatibleCompletionUsage(usage) {
|
|
478961
|
+
var _a17, _b16;
|
|
478962
|
+
if (usage == null) {
|
|
478963
|
+
return {
|
|
478964
|
+
inputTokens: {
|
|
478965
|
+
total: void 0,
|
|
478966
|
+
noCache: void 0,
|
|
478967
|
+
cacheRead: void 0,
|
|
478968
|
+
cacheWrite: void 0
|
|
478969
|
+
},
|
|
478970
|
+
outputTokens: {
|
|
478971
|
+
total: void 0,
|
|
478972
|
+
text: void 0,
|
|
478973
|
+
reasoning: void 0
|
|
478974
|
+
},
|
|
478975
|
+
raw: void 0
|
|
478976
|
+
};
|
|
478977
|
+
}
|
|
478978
|
+
const promptTokens = (_a17 = usage.prompt_tokens) != null ? _a17 : 0;
|
|
478979
|
+
const completionTokens = (_b16 = usage.completion_tokens) != null ? _b16 : 0;
|
|
478980
|
+
return {
|
|
478981
|
+
inputTokens: {
|
|
478982
|
+
total: promptTokens,
|
|
478983
|
+
noCache: promptTokens,
|
|
478984
|
+
cacheRead: void 0,
|
|
478985
|
+
cacheWrite: void 0
|
|
478986
|
+
},
|
|
478987
|
+
outputTokens: {
|
|
478988
|
+
total: completionTokens,
|
|
478989
|
+
text: completionTokens,
|
|
478990
|
+
reasoning: void 0
|
|
478991
|
+
},
|
|
478992
|
+
raw: usage
|
|
478993
|
+
};
|
|
478994
|
+
}
|
|
478995
|
+
function convertToOpenAICompatibleCompletionPrompt({
|
|
478996
|
+
prompt,
|
|
478997
|
+
user = "user",
|
|
478998
|
+
assistant = "assistant"
|
|
478999
|
+
}) {
|
|
479000
|
+
let text = "";
|
|
479001
|
+
if (prompt[0].role === "system") {
|
|
479002
|
+
text += `${prompt[0].content}
|
|
479003
|
+
|
|
479004
|
+
`;
|
|
479005
|
+
prompt = prompt.slice(1);
|
|
479006
|
+
}
|
|
479007
|
+
for (const { role, content } of prompt) {
|
|
479008
|
+
switch (role) {
|
|
479009
|
+
case "system": {
|
|
479010
|
+
throw new InvalidPromptError({
|
|
479011
|
+
message: "Unexpected system message in prompt: ${content}",
|
|
479012
|
+
prompt
|
|
479013
|
+
});
|
|
479014
|
+
}
|
|
479015
|
+
case "user": {
|
|
479016
|
+
const userMessage = content.map((part) => {
|
|
479017
|
+
switch (part.type) {
|
|
479018
|
+
case "text": {
|
|
479019
|
+
return part.text;
|
|
479020
|
+
}
|
|
479021
|
+
}
|
|
479022
|
+
}).filter(Boolean).join("");
|
|
479023
|
+
text += `${user}:
|
|
479024
|
+
${userMessage}
|
|
479025
|
+
|
|
479026
|
+
`;
|
|
479027
|
+
break;
|
|
479028
|
+
}
|
|
479029
|
+
case "assistant": {
|
|
479030
|
+
const assistantMessage = content.map((part) => {
|
|
479031
|
+
switch (part.type) {
|
|
479032
|
+
case "text": {
|
|
479033
|
+
return part.text;
|
|
479034
|
+
}
|
|
479035
|
+
case "tool-call": {
|
|
479036
|
+
throw new UnsupportedFunctionalityError({
|
|
479037
|
+
functionality: "tool-call messages"
|
|
479038
|
+
});
|
|
479039
|
+
}
|
|
479040
|
+
}
|
|
479041
|
+
}).join("");
|
|
479042
|
+
text += `${assistant}:
|
|
479043
|
+
${assistantMessage}
|
|
479044
|
+
|
|
479045
|
+
`;
|
|
479046
|
+
break;
|
|
479047
|
+
}
|
|
479048
|
+
case "tool": {
|
|
479049
|
+
throw new UnsupportedFunctionalityError({
|
|
479050
|
+
functionality: "tool messages"
|
|
479051
|
+
});
|
|
479052
|
+
}
|
|
479053
|
+
default: {
|
|
479054
|
+
const _exhaustiveCheck = role;
|
|
479055
|
+
throw new Error(`Unsupported role: ${_exhaustiveCheck}`);
|
|
479056
|
+
}
|
|
479057
|
+
}
|
|
479058
|
+
}
|
|
479059
|
+
text += `${assistant}:
|
|
479060
|
+
`;
|
|
479061
|
+
return {
|
|
479062
|
+
prompt: text,
|
|
479063
|
+
stopSequences: [`
|
|
479064
|
+
${user}:`]
|
|
479065
|
+
};
|
|
479066
|
+
}
|
|
479067
|
+
function getResponseMetadata2({
|
|
479068
|
+
id,
|
|
479069
|
+
model,
|
|
479070
|
+
created
|
|
479071
|
+
}) {
|
|
479072
|
+
return {
|
|
479073
|
+
id: id != null ? id : void 0,
|
|
479074
|
+
modelId: model != null ? model : void 0,
|
|
479075
|
+
timestamp: created != null ? new Date(created * 1e3) : void 0
|
|
479076
|
+
};
|
|
479077
|
+
}
|
|
479078
|
+
function mapOpenAICompatibleFinishReason2(finishReason) {
|
|
479079
|
+
switch (finishReason) {
|
|
479080
|
+
case "stop":
|
|
479081
|
+
return "stop";
|
|
479082
|
+
case "length":
|
|
479083
|
+
return "length";
|
|
479084
|
+
case "content_filter":
|
|
479085
|
+
return "content-filter";
|
|
479086
|
+
case "function_call":
|
|
479087
|
+
case "tool_calls":
|
|
479088
|
+
return "tool-calls";
|
|
479089
|
+
default:
|
|
479090
|
+
return "other";
|
|
479091
|
+
}
|
|
479092
|
+
}
|
|
479093
|
+
async function fileToBlob(file2) {
|
|
479094
|
+
if (file2.type === "url") {
|
|
479095
|
+
return downloadBlob(file2.url);
|
|
479096
|
+
}
|
|
479097
|
+
const data2 = file2.data instanceof Uint8Array ? file2.data : convertBase64ToUint8Array(file2.data);
|
|
479098
|
+
return new Blob([data2], { type: file2.mediaType });
|
|
479099
|
+
}
|
|
479100
|
+
function createOpenAICompatible(options) {
|
|
479101
|
+
const baseURL = withoutTrailingSlash(options.baseURL);
|
|
479102
|
+
const providerName = options.name;
|
|
479103
|
+
const headers = {
|
|
479104
|
+
...options.apiKey && { Authorization: `Bearer ${options.apiKey}` },
|
|
479105
|
+
...options.headers
|
|
479106
|
+
};
|
|
479107
|
+
const getHeaders = () => withUserAgentSuffix(headers, `ai-sdk/openai-compatible/${VERSION2}`);
|
|
479108
|
+
const getCommonModelConfig = (modelType) => ({
|
|
479109
|
+
provider: `${providerName}.${modelType}`,
|
|
479110
|
+
url: ({ path: path9 }) => {
|
|
479111
|
+
const url2 = new URL(`${baseURL}${path9}`);
|
|
479112
|
+
if (options.queryParams) {
|
|
479113
|
+
url2.search = new URLSearchParams(options.queryParams).toString();
|
|
479114
|
+
}
|
|
479115
|
+
return url2.toString();
|
|
479116
|
+
},
|
|
479117
|
+
headers: getHeaders,
|
|
479118
|
+
fetch: options.fetch
|
|
479119
|
+
});
|
|
479120
|
+
const createLanguageModel2 = (modelId) => createChatModel(modelId);
|
|
479121
|
+
const createChatModel = (modelId) => new OpenAICompatibleChatLanguageModel(modelId, {
|
|
479122
|
+
...getCommonModelConfig("chat"),
|
|
479123
|
+
includeUsage: options.includeUsage,
|
|
479124
|
+
supportsStructuredOutputs: options.supportsStructuredOutputs,
|
|
479125
|
+
supportedUrls: options.supportedUrls,
|
|
479126
|
+
transformRequestBody: options.transformRequestBody,
|
|
479127
|
+
metadataExtractor: options.metadataExtractor,
|
|
479128
|
+
convertUsage: options.convertUsage
|
|
479129
|
+
});
|
|
479130
|
+
const createCompletionModel = (modelId) => new OpenAICompatibleCompletionLanguageModel(modelId, {
|
|
479131
|
+
...getCommonModelConfig("completion"),
|
|
479132
|
+
includeUsage: options.includeUsage
|
|
479133
|
+
});
|
|
479134
|
+
const createEmbeddingModel = (modelId) => new OpenAICompatibleEmbeddingModel(modelId, {
|
|
479135
|
+
...getCommonModelConfig("embedding")
|
|
479136
|
+
});
|
|
479137
|
+
const createImageModel = (modelId) => new OpenAICompatibleImageModel(modelId, getCommonModelConfig("image"));
|
|
479138
|
+
const provider = (modelId) => createLanguageModel2(modelId);
|
|
479139
|
+
provider.specificationVersion = "v3";
|
|
479140
|
+
provider.languageModel = createLanguageModel2;
|
|
479141
|
+
provider.chatModel = createChatModel;
|
|
479142
|
+
provider.completionModel = createCompletionModel;
|
|
479143
|
+
provider.embeddingModel = createEmbeddingModel;
|
|
479144
|
+
provider.textEmbeddingModel = createEmbeddingModel;
|
|
479145
|
+
provider.imageModel = createImageModel;
|
|
479146
|
+
return provider;
|
|
479147
|
+
}
|
|
479148
|
+
var openaiCompatibleErrorDataSchema, defaultOpenAICompatibleErrorStructure, openaiCompatibleLanguageModelChatOptions, OpenAICompatibleChatLanguageModel, openaiCompatibleTokenUsageSchema, openAICompatibleContentSchema, OpenAICompatibleChatResponseSchema, chunkBaseSchema, createOpenAICompatibleChatChunkSchema, openaiCompatibleLanguageModelCompletionOptions, OpenAICompatibleCompletionLanguageModel, usageSchema, openaiCompatibleCompletionResponseSchema, createOpenAICompatibleCompletionChunkSchema, openaiCompatibleEmbeddingModelOptions, OpenAICompatibleEmbeddingModel, openaiTextEmbeddingResponseSchema, OpenAICompatibleImageModel, openaiCompatibleImageResponseSchema, VERSION2;
|
|
479149
|
+
var init_dist4 = __esm({
|
|
479150
|
+
"node_modules/@ai-sdk/openai-compatible/dist/index.mjs"() {
|
|
479151
|
+
init_dist();
|
|
479152
|
+
init_dist3();
|
|
479153
|
+
init_v4();
|
|
479154
|
+
init_v4();
|
|
479155
|
+
init_dist();
|
|
479156
|
+
init_dist3();
|
|
479157
|
+
init_v4();
|
|
479158
|
+
init_dist();
|
|
479159
|
+
init_dist3();
|
|
479160
|
+
init_v4();
|
|
479161
|
+
init_dist();
|
|
479162
|
+
init_v4();
|
|
479163
|
+
init_dist();
|
|
479164
|
+
init_dist3();
|
|
479165
|
+
init_v4();
|
|
479166
|
+
init_v4();
|
|
479167
|
+
init_dist3();
|
|
479168
|
+
init_v4();
|
|
479169
|
+
init_dist3();
|
|
479170
|
+
openaiCompatibleErrorDataSchema = external_exports.object({
|
|
479171
|
+
error: external_exports.object({
|
|
479172
|
+
message: external_exports.string(),
|
|
479173
|
+
// The additional information below is handled loosely to support
|
|
479174
|
+
// OpenAI-compatible providers that have slightly different error
|
|
479175
|
+
// responses:
|
|
479176
|
+
type: external_exports.string().nullish(),
|
|
479177
|
+
param: external_exports.any().nullish(),
|
|
479178
|
+
code: external_exports.union([external_exports.string(), external_exports.number()]).nullish()
|
|
479179
|
+
})
|
|
479180
|
+
});
|
|
479181
|
+
defaultOpenAICompatibleErrorStructure = {
|
|
479182
|
+
errorSchema: openaiCompatibleErrorDataSchema,
|
|
479183
|
+
errorToMessage: (data2) => data2.error.message
|
|
479184
|
+
};
|
|
479185
|
+
openaiCompatibleLanguageModelChatOptions = external_exports.object({
|
|
479186
|
+
/**
|
|
479187
|
+
* A unique identifier representing your end-user, which can help the provider to
|
|
479188
|
+
* monitor and detect abuse.
|
|
479189
|
+
*/
|
|
479190
|
+
user: external_exports.string().optional(),
|
|
479191
|
+
/**
|
|
479192
|
+
* Reasoning effort for reasoning models. Defaults to `medium`.
|
|
479193
|
+
*/
|
|
479194
|
+
reasoningEffort: external_exports.string().optional(),
|
|
479195
|
+
/**
|
|
479196
|
+
* Controls the verbosity of the generated text. Defaults to `medium`.
|
|
479197
|
+
*/
|
|
479198
|
+
textVerbosity: external_exports.string().optional(),
|
|
479199
|
+
/**
|
|
479200
|
+
* Whether to use strict JSON schema validation.
|
|
479201
|
+
* When true, the model uses constrained decoding to guarantee schema compliance.
|
|
479202
|
+
* Only used when the provider supports structured outputs and a schema is provided.
|
|
479203
|
+
*
|
|
479204
|
+
* @default true
|
|
479205
|
+
*/
|
|
479206
|
+
strictJsonSchema: external_exports.boolean().optional()
|
|
479207
|
+
});
|
|
479208
|
+
OpenAICompatibleChatLanguageModel = class {
|
|
479209
|
+
// type inferred via constructor
|
|
479210
|
+
constructor(modelId, config2) {
|
|
479211
|
+
this.specificationVersion = "v3";
|
|
479212
|
+
var _a17, _b16;
|
|
479213
|
+
this.modelId = modelId;
|
|
479214
|
+
this.config = config2;
|
|
479215
|
+
const errorStructure = (_a17 = config2.errorStructure) != null ? _a17 : defaultOpenAICompatibleErrorStructure;
|
|
479216
|
+
this.chunkSchema = createOpenAICompatibleChatChunkSchema(
|
|
479217
|
+
errorStructure.errorSchema
|
|
479218
|
+
);
|
|
479219
|
+
this.failedResponseHandler = createJsonErrorResponseHandler(errorStructure);
|
|
479220
|
+
this.supportsStructuredOutputs = (_b16 = config2.supportsStructuredOutputs) != null ? _b16 : false;
|
|
479221
|
+
}
|
|
479222
|
+
get provider() {
|
|
479223
|
+
return this.config.provider;
|
|
479224
|
+
}
|
|
479225
|
+
get providerOptionsName() {
|
|
479226
|
+
return this.config.provider.split(".")[0].trim();
|
|
479227
|
+
}
|
|
479228
|
+
get supportedUrls() {
|
|
479229
|
+
var _a17, _b16, _c;
|
|
479230
|
+
return (_c = (_b16 = (_a17 = this.config).supportedUrls) == null ? void 0 : _b16.call(_a17)) != null ? _c : {};
|
|
479231
|
+
}
|
|
479232
|
+
transformRequestBody(args) {
|
|
479233
|
+
var _a17, _b16, _c;
|
|
479234
|
+
return (_c = (_b16 = (_a17 = this.config).transformRequestBody) == null ? void 0 : _b16.call(_a17, args)) != null ? _c : args;
|
|
479235
|
+
}
|
|
479236
|
+
convertUsage(usage) {
|
|
479237
|
+
var _a17, _b16, _c;
|
|
479238
|
+
return (_c = (_b16 = (_a17 = this.config).convertUsage) == null ? void 0 : _b16.call(_a17, usage)) != null ? _c : convertOpenAICompatibleChatUsage(usage);
|
|
479239
|
+
}
|
|
479240
|
+
async getArgs({
|
|
479241
|
+
prompt,
|
|
479242
|
+
maxOutputTokens,
|
|
479243
|
+
temperature,
|
|
479244
|
+
topP,
|
|
479245
|
+
topK,
|
|
479246
|
+
frequencyPenalty,
|
|
479247
|
+
presencePenalty,
|
|
479248
|
+
providerOptions,
|
|
479249
|
+
stopSequences,
|
|
479250
|
+
responseFormat,
|
|
479251
|
+
seed,
|
|
479252
|
+
toolChoice,
|
|
479253
|
+
tools: tools2
|
|
479254
|
+
}) {
|
|
479255
|
+
var _a17, _b16, _c, _d, _e;
|
|
479256
|
+
const warnings = [];
|
|
479257
|
+
const deprecatedOptions = await parseProviderOptions({
|
|
479258
|
+
provider: "openai-compatible",
|
|
479259
|
+
providerOptions,
|
|
479260
|
+
schema: openaiCompatibleLanguageModelChatOptions
|
|
479261
|
+
});
|
|
479262
|
+
if (deprecatedOptions != null) {
|
|
479263
|
+
warnings.push({
|
|
479264
|
+
type: "other",
|
|
479265
|
+
message: `The 'openai-compatible' key in providerOptions is deprecated. Use 'openaiCompatible' instead.`
|
|
479266
|
+
});
|
|
479267
|
+
}
|
|
479268
|
+
const compatibleOptions = Object.assign(
|
|
479269
|
+
deprecatedOptions != null ? deprecatedOptions : {},
|
|
479270
|
+
(_a17 = await parseProviderOptions({
|
|
479271
|
+
provider: "openaiCompatible",
|
|
479272
|
+
providerOptions,
|
|
479273
|
+
schema: openaiCompatibleLanguageModelChatOptions
|
|
479274
|
+
})) != null ? _a17 : {},
|
|
479275
|
+
(_b16 = await parseProviderOptions({
|
|
479276
|
+
provider: this.providerOptionsName,
|
|
479277
|
+
providerOptions,
|
|
479278
|
+
schema: openaiCompatibleLanguageModelChatOptions
|
|
479279
|
+
})) != null ? _b16 : {},
|
|
479280
|
+
(_c = await parseProviderOptions({
|
|
479281
|
+
provider: toCamelCase(this.providerOptionsName),
|
|
479282
|
+
providerOptions,
|
|
479283
|
+
schema: openaiCompatibleLanguageModelChatOptions
|
|
479284
|
+
})) != null ? _c : {}
|
|
479285
|
+
);
|
|
479286
|
+
const strictJsonSchema = (_d = compatibleOptions == null ? void 0 : compatibleOptions.strictJsonSchema) != null ? _d : true;
|
|
479287
|
+
if (topK != null) {
|
|
479288
|
+
warnings.push({ type: "unsupported", feature: "topK" });
|
|
479289
|
+
}
|
|
479290
|
+
if ((responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !this.supportsStructuredOutputs) {
|
|
479291
|
+
warnings.push({
|
|
479292
|
+
type: "unsupported",
|
|
479293
|
+
feature: "responseFormat",
|
|
479294
|
+
details: "JSON response format schema is only supported with structuredOutputs"
|
|
479295
|
+
});
|
|
479296
|
+
}
|
|
479297
|
+
const {
|
|
479298
|
+
tools: openaiTools,
|
|
479299
|
+
toolChoice: openaiToolChoice,
|
|
479300
|
+
toolWarnings
|
|
479301
|
+
} = prepareTools({
|
|
479302
|
+
tools: tools2,
|
|
479303
|
+
toolChoice
|
|
479304
|
+
});
|
|
479305
|
+
const metadataKey = resolveProviderOptionsKey(
|
|
479306
|
+
this.providerOptionsName,
|
|
479307
|
+
providerOptions
|
|
479308
|
+
);
|
|
479309
|
+
return {
|
|
479310
|
+
metadataKey,
|
|
479311
|
+
args: {
|
|
479312
|
+
// model id:
|
|
479313
|
+
model: this.modelId,
|
|
479314
|
+
// model specific settings:
|
|
479315
|
+
user: compatibleOptions.user,
|
|
479316
|
+
// standardized settings:
|
|
479317
|
+
max_tokens: maxOutputTokens,
|
|
479318
|
+
temperature,
|
|
479319
|
+
top_p: topP,
|
|
479320
|
+
frequency_penalty: frequencyPenalty,
|
|
479321
|
+
presence_penalty: presencePenalty,
|
|
479322
|
+
response_format: (responseFormat == null ? void 0 : responseFormat.type) === "json" ? this.supportsStructuredOutputs === true && responseFormat.schema != null ? {
|
|
479323
|
+
type: "json_schema",
|
|
479324
|
+
json_schema: {
|
|
479325
|
+
schema: responseFormat.schema,
|
|
479326
|
+
strict: strictJsonSchema,
|
|
479327
|
+
name: (_e = responseFormat.name) != null ? _e : "response",
|
|
479328
|
+
description: responseFormat.description
|
|
479329
|
+
}
|
|
479330
|
+
} : { type: "json_object" } : void 0,
|
|
479331
|
+
stop: stopSequences,
|
|
479332
|
+
seed,
|
|
479333
|
+
...Object.fromEntries(
|
|
479334
|
+
Object.entries({
|
|
479335
|
+
...providerOptions == null ? void 0 : providerOptions[this.providerOptionsName],
|
|
479336
|
+
...providerOptions == null ? void 0 : providerOptions[toCamelCase(this.providerOptionsName)]
|
|
479337
|
+
}).filter(
|
|
479338
|
+
([key]) => !Object.keys(
|
|
479339
|
+
openaiCompatibleLanguageModelChatOptions.shape
|
|
479340
|
+
).includes(key)
|
|
479341
|
+
)
|
|
479342
|
+
),
|
|
479343
|
+
reasoning_effort: compatibleOptions.reasoningEffort,
|
|
479344
|
+
verbosity: compatibleOptions.textVerbosity,
|
|
479345
|
+
// messages:
|
|
479346
|
+
messages: convertToOpenAICompatibleChatMessages(prompt),
|
|
479347
|
+
// tools:
|
|
479348
|
+
tools: openaiTools,
|
|
479349
|
+
tool_choice: openaiToolChoice
|
|
479350
|
+
},
|
|
479351
|
+
warnings: [...warnings, ...toolWarnings]
|
|
479352
|
+
};
|
|
479353
|
+
}
|
|
479354
|
+
async doGenerate(options) {
|
|
479355
|
+
var _a17, _b16, _c, _d, _e, _f, _g, _h;
|
|
479356
|
+
const { args, warnings, metadataKey } = await this.getArgs({ ...options });
|
|
479357
|
+
const transformedBody = this.transformRequestBody(args);
|
|
479358
|
+
const body = JSON.stringify(transformedBody);
|
|
479359
|
+
const {
|
|
479360
|
+
responseHeaders,
|
|
479361
|
+
value: responseBody,
|
|
479362
|
+
rawValue: rawResponse
|
|
479363
|
+
} = await postJsonToApi({
|
|
479364
|
+
url: this.config.url({
|
|
479365
|
+
path: "/chat/completions",
|
|
479366
|
+
modelId: this.modelId
|
|
479367
|
+
}),
|
|
479368
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
479369
|
+
body: transformedBody,
|
|
479370
|
+
failedResponseHandler: this.failedResponseHandler,
|
|
479371
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
479372
|
+
OpenAICompatibleChatResponseSchema
|
|
479373
|
+
),
|
|
479374
|
+
abortSignal: options.abortSignal,
|
|
479375
|
+
fetch: this.config.fetch
|
|
479376
|
+
});
|
|
479377
|
+
const choice = responseBody.choices[0];
|
|
479378
|
+
const content = [];
|
|
479379
|
+
content.push(...convertOpenAICompatibleContent(choice.message.content));
|
|
479380
|
+
const reasoning = (_a17 = choice.message.reasoning_content) != null ? _a17 : choice.message.reasoning;
|
|
479381
|
+
if (reasoning != null && reasoning.length > 0) {
|
|
479382
|
+
content.push({
|
|
479383
|
+
type: "reasoning",
|
|
479384
|
+
text: reasoning
|
|
479385
|
+
});
|
|
479386
|
+
}
|
|
479387
|
+
if (choice.message.tool_calls != null) {
|
|
479388
|
+
for (const toolCall of choice.message.tool_calls) {
|
|
479389
|
+
const thoughtSignature = (_c = (_b16 = toolCall.extra_content) == null ? void 0 : _b16.google) == null ? void 0 : _c.thought_signature;
|
|
479390
|
+
content.push({
|
|
479391
|
+
type: "tool-call",
|
|
479392
|
+
toolCallId: (_d = toolCall.id) != null ? _d : generateId(),
|
|
479393
|
+
toolName: toolCall.function.name,
|
|
479394
|
+
input: toolCall.function.arguments,
|
|
479395
|
+
...thoughtSignature ? {
|
|
479396
|
+
providerMetadata: {
|
|
479397
|
+
[metadataKey]: { thoughtSignature }
|
|
479398
|
+
}
|
|
479399
|
+
} : {}
|
|
479400
|
+
});
|
|
479401
|
+
}
|
|
479402
|
+
}
|
|
479403
|
+
const providerMetadata = {
|
|
479404
|
+
[metadataKey]: {},
|
|
479405
|
+
...await ((_f = (_e = this.config.metadataExtractor) == null ? void 0 : _e.extractMetadata) == null ? void 0 : _f.call(_e, {
|
|
479406
|
+
parsedBody: rawResponse
|
|
479407
|
+
}))
|
|
479408
|
+
};
|
|
479409
|
+
const completionTokenDetails = (_g = responseBody.usage) == null ? void 0 : _g.completion_tokens_details;
|
|
479410
|
+
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens) != null) {
|
|
479411
|
+
providerMetadata[metadataKey].acceptedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.accepted_prediction_tokens;
|
|
479412
|
+
}
|
|
479413
|
+
if ((completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens) != null) {
|
|
479414
|
+
providerMetadata[metadataKey].rejectedPredictionTokens = completionTokenDetails == null ? void 0 : completionTokenDetails.rejected_prediction_tokens;
|
|
479415
|
+
}
|
|
479416
|
+
return {
|
|
479417
|
+
content,
|
|
479418
|
+
finishReason: {
|
|
479419
|
+
unified: mapOpenAICompatibleFinishReason(choice.finish_reason),
|
|
479420
|
+
raw: (_h = choice.finish_reason) != null ? _h : void 0
|
|
479421
|
+
},
|
|
479422
|
+
usage: this.convertUsage(responseBody.usage),
|
|
479423
|
+
providerMetadata,
|
|
479424
|
+
request: { body },
|
|
479425
|
+
response: {
|
|
479426
|
+
...getResponseMetadata(responseBody),
|
|
479427
|
+
headers: responseHeaders,
|
|
479428
|
+
body: rawResponse
|
|
479429
|
+
},
|
|
479430
|
+
warnings
|
|
479431
|
+
};
|
|
479432
|
+
}
|
|
479433
|
+
async doStream(options) {
|
|
479434
|
+
var _a17;
|
|
479435
|
+
const { args, warnings, metadataKey } = await this.getArgs({ ...options });
|
|
479436
|
+
const body = this.transformRequestBody({
|
|
479437
|
+
...args,
|
|
479438
|
+
stream: true,
|
|
479439
|
+
// only include stream_options when in strict compatibility mode:
|
|
479440
|
+
stream_options: this.config.includeUsage ? { include_usage: true } : void 0
|
|
479441
|
+
});
|
|
479442
|
+
const metadataExtractor = (_a17 = this.config.metadataExtractor) == null ? void 0 : _a17.createStreamExtractor();
|
|
479443
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
479444
|
+
url: this.config.url({
|
|
479445
|
+
path: "/chat/completions",
|
|
479446
|
+
modelId: this.modelId
|
|
479447
|
+
}),
|
|
479448
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
479449
|
+
body,
|
|
479450
|
+
failedResponseHandler: this.failedResponseHandler,
|
|
479451
|
+
successfulResponseHandler: createEventSourceResponseHandler(
|
|
479452
|
+
this.chunkSchema
|
|
479453
|
+
),
|
|
479454
|
+
abortSignal: options.abortSignal,
|
|
479455
|
+
fetch: this.config.fetch
|
|
479456
|
+
});
|
|
479457
|
+
const toolCalls = [];
|
|
479458
|
+
const pendingToolCalls = /* @__PURE__ */ new Map();
|
|
479459
|
+
let finishReason;
|
|
479460
|
+
let usage = void 0;
|
|
479461
|
+
let isFirstChunk = true;
|
|
479462
|
+
const providerOptionsName = metadataKey;
|
|
479463
|
+
let isActiveReasoning = false;
|
|
479464
|
+
let isActiveText = false;
|
|
479465
|
+
const convertUsage = (usage2) => this.convertUsage(usage2);
|
|
479466
|
+
return {
|
|
479467
|
+
stream: response.pipeThrough(
|
|
479468
|
+
new TransformStream({
|
|
479469
|
+
start(controller) {
|
|
479470
|
+
controller.enqueue({ type: "stream-start", warnings });
|
|
479471
|
+
},
|
|
479472
|
+
transform(chunk, controller) {
|
|
479473
|
+
var _a22, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
479474
|
+
if (options.includeRawChunks) {
|
|
479475
|
+
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
479476
|
+
}
|
|
479477
|
+
if (!chunk.success) {
|
|
479478
|
+
finishReason = { unified: "error", raw: void 0 };
|
|
479479
|
+
controller.enqueue({ type: "error", error: chunk.error });
|
|
479480
|
+
return;
|
|
479481
|
+
}
|
|
479482
|
+
metadataExtractor == null ? void 0 : metadataExtractor.processChunk(chunk.rawValue);
|
|
479483
|
+
if ("error" in chunk.value) {
|
|
479484
|
+
finishReason = { unified: "error", raw: void 0 };
|
|
479485
|
+
controller.enqueue({
|
|
479486
|
+
type: "error",
|
|
479487
|
+
error: chunk.value.error
|
|
479488
|
+
});
|
|
479489
|
+
return;
|
|
479490
|
+
}
|
|
479491
|
+
const value = chunk.value;
|
|
479492
|
+
if (isFirstChunk) {
|
|
479493
|
+
isFirstChunk = false;
|
|
479494
|
+
controller.enqueue({
|
|
479495
|
+
type: "response-metadata",
|
|
479496
|
+
...getResponseMetadata(value)
|
|
479497
|
+
});
|
|
479498
|
+
}
|
|
479499
|
+
if (value.usage != null) {
|
|
479500
|
+
usage = value.usage;
|
|
479501
|
+
}
|
|
479502
|
+
const choice = value.choices[0];
|
|
479503
|
+
if ((choice == null ? void 0 : choice.finish_reason) != null) {
|
|
479504
|
+
finishReason = {
|
|
479505
|
+
unified: mapOpenAICompatibleFinishReason(choice.finish_reason),
|
|
479506
|
+
raw: (_a22 = choice.finish_reason) != null ? _a22 : void 0
|
|
479507
|
+
};
|
|
479508
|
+
}
|
|
479509
|
+
if ((choice == null ? void 0 : choice.delta) == null) {
|
|
479510
|
+
return;
|
|
479511
|
+
}
|
|
479512
|
+
const delta = choice.delta;
|
|
479513
|
+
const enqueueReasoningDelta = (reasoningDelta) => {
|
|
479514
|
+
if (isActiveText) {
|
|
479515
|
+
controller.enqueue({ type: "text-end", id: "txt-0" });
|
|
479516
|
+
isActiveText = false;
|
|
479517
|
+
}
|
|
479518
|
+
if (!isActiveReasoning) {
|
|
479519
|
+
controller.enqueue({
|
|
479520
|
+
type: "reasoning-start",
|
|
479521
|
+
id: "reasoning-0"
|
|
479522
|
+
});
|
|
479523
|
+
isActiveReasoning = true;
|
|
479524
|
+
}
|
|
479525
|
+
controller.enqueue({
|
|
479526
|
+
type: "reasoning-delta",
|
|
479527
|
+
id: "reasoning-0",
|
|
479528
|
+
delta: reasoningDelta
|
|
479529
|
+
});
|
|
479530
|
+
};
|
|
479531
|
+
const enqueueTextDelta = (textDelta) => {
|
|
479532
|
+
if (isActiveReasoning) {
|
|
479533
|
+
controller.enqueue({
|
|
479534
|
+
type: "reasoning-end",
|
|
479535
|
+
id: "reasoning-0"
|
|
479536
|
+
});
|
|
479537
|
+
isActiveReasoning = false;
|
|
479538
|
+
}
|
|
479539
|
+
if (!isActiveText) {
|
|
479540
|
+
controller.enqueue({ type: "text-start", id: "txt-0" });
|
|
479541
|
+
isActiveText = true;
|
|
479542
|
+
}
|
|
479543
|
+
controller.enqueue({
|
|
479544
|
+
type: "text-delta",
|
|
479545
|
+
id: "txt-0",
|
|
479546
|
+
delta: textDelta
|
|
479547
|
+
});
|
|
479548
|
+
};
|
|
479549
|
+
const reasoningContent = (_b16 = delta.reasoning_content) != null ? _b16 : delta.reasoning;
|
|
479550
|
+
if (reasoningContent) {
|
|
479551
|
+
enqueueReasoningDelta(reasoningContent);
|
|
479552
|
+
}
|
|
479553
|
+
for (const contentPart of convertOpenAICompatibleContent(
|
|
479554
|
+
delta.content
|
|
479555
|
+
)) {
|
|
479556
|
+
if (contentPart.type === "reasoning") {
|
|
479557
|
+
enqueueReasoningDelta(contentPart.text);
|
|
479558
|
+
} else {
|
|
479559
|
+
enqueueTextDelta(contentPart.text);
|
|
479560
|
+
}
|
|
479561
|
+
}
|
|
479562
|
+
if (delta.tool_calls != null) {
|
|
479563
|
+
if (isActiveReasoning) {
|
|
479564
|
+
controller.enqueue({
|
|
479565
|
+
type: "reasoning-end",
|
|
479566
|
+
id: "reasoning-0"
|
|
479567
|
+
});
|
|
479568
|
+
isActiveReasoning = false;
|
|
479569
|
+
}
|
|
479570
|
+
for (const toolCallDelta of delta.tool_calls) {
|
|
479571
|
+
const index = (_c = toolCallDelta.index) != null ? _c : toolCalls.length;
|
|
479572
|
+
if (toolCalls[index] == null) {
|
|
479573
|
+
if (toolCallDelta.index != null) {
|
|
479574
|
+
let pending = pendingToolCalls.get(index);
|
|
479575
|
+
if (pending == null) {
|
|
479576
|
+
pending = {
|
|
479577
|
+
id: (_d = toolCallDelta.id) != null ? _d : null,
|
|
479578
|
+
bufferedArguments: "",
|
|
479579
|
+
thoughtSignature: (_g = (_f = (_e = toolCallDelta.extra_content) == null ? void 0 : _e.google) == null ? void 0 : _f.thought_signature) != null ? _g : void 0
|
|
479580
|
+
};
|
|
479581
|
+
pendingToolCalls.set(index, pending);
|
|
479582
|
+
} else {
|
|
479583
|
+
if (pending.id == null && toolCallDelta.id != null) {
|
|
479584
|
+
pending.id = toolCallDelta.id;
|
|
479585
|
+
}
|
|
479586
|
+
if (pending.thoughtSignature == null && ((_i = (_h = toolCallDelta.extra_content) == null ? void 0 : _h.google) == null ? void 0 : _i.thought_signature) != null) {
|
|
479587
|
+
pending.thoughtSignature = toolCallDelta.extra_content.google.thought_signature;
|
|
479588
|
+
}
|
|
479589
|
+
}
|
|
479590
|
+
const argumentsDelta = (_j = toolCallDelta.function) == null ? void 0 : _j.arguments;
|
|
479591
|
+
if (argumentsDelta != null) {
|
|
479592
|
+
pending.bufferedArguments += argumentsDelta;
|
|
479593
|
+
}
|
|
479594
|
+
const name15 = (_k = toolCallDelta.function) == null ? void 0 : _k.name;
|
|
479595
|
+
if (name15 == null) {
|
|
479596
|
+
continue;
|
|
479597
|
+
}
|
|
479598
|
+
pendingToolCalls.delete(index);
|
|
479599
|
+
if (pending.id == null) {
|
|
479600
|
+
throw new InvalidResponseDataError({
|
|
479601
|
+
data: toolCallDelta,
|
|
479602
|
+
message: `Expected 'id' to be a string.`
|
|
479603
|
+
});
|
|
479604
|
+
}
|
|
479605
|
+
controller.enqueue({
|
|
479606
|
+
type: "tool-input-start",
|
|
479607
|
+
id: pending.id,
|
|
479608
|
+
toolName: name15
|
|
479609
|
+
});
|
|
479610
|
+
toolCalls[index] = {
|
|
479611
|
+
id: pending.id,
|
|
479612
|
+
type: "function",
|
|
479613
|
+
function: {
|
|
479614
|
+
name: name15,
|
|
479615
|
+
arguments: pending.bufferedArguments
|
|
479616
|
+
},
|
|
479617
|
+
hasFinished: false,
|
|
479618
|
+
thoughtSignature: pending.thoughtSignature
|
|
479619
|
+
};
|
|
479620
|
+
} else {
|
|
479621
|
+
if (toolCallDelta.id == null) {
|
|
479622
|
+
throw new InvalidResponseDataError({
|
|
479623
|
+
data: toolCallDelta,
|
|
479624
|
+
message: `Expected 'id' to be a string.`
|
|
479625
|
+
});
|
|
479626
|
+
}
|
|
479627
|
+
if (((_l = toolCallDelta.function) == null ? void 0 : _l.name) == null) {
|
|
479628
|
+
throw new InvalidResponseDataError({
|
|
479629
|
+
data: toolCallDelta,
|
|
479630
|
+
message: `Expected 'function.name' to be a string.`
|
|
479631
|
+
});
|
|
479632
|
+
}
|
|
479633
|
+
controller.enqueue({
|
|
479634
|
+
type: "tool-input-start",
|
|
479635
|
+
id: toolCallDelta.id,
|
|
479636
|
+
toolName: toolCallDelta.function.name
|
|
479637
|
+
});
|
|
479638
|
+
toolCalls[index] = {
|
|
479639
|
+
id: toolCallDelta.id,
|
|
479640
|
+
type: "function",
|
|
479641
|
+
function: {
|
|
479642
|
+
name: toolCallDelta.function.name,
|
|
479643
|
+
arguments: (_m = toolCallDelta.function.arguments) != null ? _m : ""
|
|
479644
|
+
},
|
|
479645
|
+
hasFinished: false,
|
|
479646
|
+
thoughtSignature: (_p = (_o = (_n = toolCallDelta.extra_content) == null ? void 0 : _n.google) == null ? void 0 : _o.thought_signature) != null ? _p : void 0
|
|
479647
|
+
};
|
|
479648
|
+
}
|
|
479649
|
+
const toolCall2 = toolCalls[index];
|
|
479650
|
+
if (((_q = toolCall2.function) == null ? void 0 : _q.name) != null && ((_r = toolCall2.function) == null ? void 0 : _r.arguments) != null) {
|
|
479651
|
+
if (toolCall2.function.arguments.length > 0) {
|
|
479652
|
+
controller.enqueue({
|
|
479653
|
+
type: "tool-input-delta",
|
|
479654
|
+
id: toolCall2.id,
|
|
479655
|
+
delta: toolCall2.function.arguments
|
|
479656
|
+
});
|
|
479657
|
+
}
|
|
479658
|
+
}
|
|
479659
|
+
continue;
|
|
479660
|
+
}
|
|
479661
|
+
const toolCall = toolCalls[index];
|
|
479662
|
+
if (toolCall.hasFinished) {
|
|
479663
|
+
continue;
|
|
479664
|
+
}
|
|
479665
|
+
if (((_s = toolCallDelta.function) == null ? void 0 : _s.arguments) != null) {
|
|
479666
|
+
toolCall.function.arguments += (_u = (_t = toolCallDelta.function) == null ? void 0 : _t.arguments) != null ? _u : "";
|
|
479667
|
+
}
|
|
479668
|
+
controller.enqueue({
|
|
479669
|
+
type: "tool-input-delta",
|
|
479670
|
+
id: toolCall.id,
|
|
479671
|
+
delta: (_v = toolCallDelta.function.arguments) != null ? _v : ""
|
|
479672
|
+
});
|
|
479673
|
+
}
|
|
479674
|
+
}
|
|
479675
|
+
},
|
|
479676
|
+
flush(controller) {
|
|
479677
|
+
var _a22, _b16, _c, _d, _e;
|
|
479678
|
+
if (isActiveReasoning) {
|
|
479679
|
+
controller.enqueue({ type: "reasoning-end", id: "reasoning-0" });
|
|
479680
|
+
}
|
|
479681
|
+
if (isActiveText) {
|
|
479682
|
+
controller.enqueue({ type: "text-end", id: "txt-0" });
|
|
479683
|
+
}
|
|
479684
|
+
for (const [index, pending] of pendingToolCalls) {
|
|
479685
|
+
throw new InvalidResponseDataError({
|
|
479686
|
+
data: {
|
|
479687
|
+
index,
|
|
479688
|
+
id: pending.id,
|
|
479689
|
+
function: { arguments: pending.bufferedArguments }
|
|
479690
|
+
},
|
|
479691
|
+
message: `Expected 'function.name' to be a string.`
|
|
479692
|
+
});
|
|
479693
|
+
}
|
|
479694
|
+
for (const toolCall of toolCalls.filter(
|
|
479695
|
+
(toolCall2) => !toolCall2.hasFinished
|
|
479696
|
+
)) {
|
|
479697
|
+
controller.enqueue({
|
|
479698
|
+
type: "tool-input-end",
|
|
479699
|
+
id: toolCall.id
|
|
479700
|
+
});
|
|
479701
|
+
controller.enqueue({
|
|
479702
|
+
type: "tool-call",
|
|
479703
|
+
toolCallId: (_a22 = toolCall.id) != null ? _a22 : generateId(),
|
|
479704
|
+
toolName: toolCall.function.name,
|
|
479705
|
+
input: toolCall.function.arguments,
|
|
479706
|
+
...toolCall.thoughtSignature ? {
|
|
479707
|
+
providerMetadata: {
|
|
479708
|
+
[providerOptionsName]: {
|
|
479709
|
+
thoughtSignature: toolCall.thoughtSignature
|
|
479710
|
+
}
|
|
479711
|
+
}
|
|
479712
|
+
} : {}
|
|
479713
|
+
});
|
|
479714
|
+
}
|
|
479715
|
+
if (finishReason == null) {
|
|
479716
|
+
finishReason = { unified: "error", raw: void 0 };
|
|
479717
|
+
controller.enqueue({
|
|
479718
|
+
type: "error",
|
|
479719
|
+
error: new InvalidResponseDataError({
|
|
479720
|
+
data: void 0,
|
|
479721
|
+
message: "Response stream ended without a finish reason."
|
|
479722
|
+
})
|
|
479723
|
+
});
|
|
479724
|
+
}
|
|
479725
|
+
const providerMetadata = {
|
|
479726
|
+
[providerOptionsName]: {},
|
|
479727
|
+
...metadataExtractor == null ? void 0 : metadataExtractor.buildMetadata()
|
|
479728
|
+
};
|
|
479729
|
+
if (((_b16 = usage == null ? void 0 : usage.completion_tokens_details) == null ? void 0 : _b16.accepted_prediction_tokens) != null) {
|
|
479730
|
+
providerMetadata[providerOptionsName].acceptedPredictionTokens = (_c = usage == null ? void 0 : usage.completion_tokens_details) == null ? void 0 : _c.accepted_prediction_tokens;
|
|
479731
|
+
}
|
|
479732
|
+
if (((_d = usage == null ? void 0 : usage.completion_tokens_details) == null ? void 0 : _d.rejected_prediction_tokens) != null) {
|
|
479733
|
+
providerMetadata[providerOptionsName].rejectedPredictionTokens = (_e = usage == null ? void 0 : usage.completion_tokens_details) == null ? void 0 : _e.rejected_prediction_tokens;
|
|
479734
|
+
}
|
|
479735
|
+
controller.enqueue({
|
|
479736
|
+
type: "finish",
|
|
479737
|
+
finishReason,
|
|
479738
|
+
usage: convertUsage(usage),
|
|
479739
|
+
providerMetadata
|
|
479740
|
+
});
|
|
479741
|
+
}
|
|
479742
|
+
})
|
|
479743
|
+
),
|
|
479744
|
+
request: { body },
|
|
479745
|
+
response: { headers: responseHeaders }
|
|
479746
|
+
};
|
|
479747
|
+
}
|
|
479748
|
+
};
|
|
479749
|
+
openaiCompatibleTokenUsageSchema = external_exports.looseObject({
|
|
479750
|
+
prompt_tokens: external_exports.number().nullish(),
|
|
479751
|
+
completion_tokens: external_exports.number().nullish(),
|
|
479752
|
+
total_tokens: external_exports.number().nullish(),
|
|
479753
|
+
prompt_tokens_details: external_exports.looseObject({
|
|
479754
|
+
cached_tokens: external_exports.number().nullish()
|
|
479755
|
+
}).nullish(),
|
|
479756
|
+
completion_tokens_details: external_exports.looseObject({
|
|
479757
|
+
reasoning_tokens: external_exports.number().nullish(),
|
|
479758
|
+
accepted_prediction_tokens: external_exports.number().nullish(),
|
|
479759
|
+
rejected_prediction_tokens: external_exports.number().nullish()
|
|
479760
|
+
}).nullish()
|
|
479761
|
+
}).nullish();
|
|
479762
|
+
openAICompatibleContentSchema = external_exports.union([
|
|
479763
|
+
external_exports.string(),
|
|
479764
|
+
external_exports.array(
|
|
479765
|
+
external_exports.looseObject({
|
|
479766
|
+
type: external_exports.string()
|
|
479767
|
+
})
|
|
479768
|
+
)
|
|
479769
|
+
]).nullish();
|
|
479770
|
+
OpenAICompatibleChatResponseSchema = external_exports.looseObject({
|
|
479771
|
+
id: external_exports.string().nullish(),
|
|
479772
|
+
created: external_exports.number().nullish(),
|
|
479773
|
+
model: external_exports.string().nullish(),
|
|
479774
|
+
choices: external_exports.array(
|
|
479775
|
+
external_exports.object({
|
|
479776
|
+
message: external_exports.object({
|
|
479777
|
+
role: external_exports.literal("assistant").nullish(),
|
|
479778
|
+
content: openAICompatibleContentSchema,
|
|
479779
|
+
reasoning_content: external_exports.string().nullish(),
|
|
479780
|
+
reasoning: external_exports.string().nullish(),
|
|
479781
|
+
tool_calls: external_exports.array(
|
|
479782
|
+
external_exports.object({
|
|
479783
|
+
id: external_exports.string().nullish(),
|
|
479784
|
+
function: external_exports.object({
|
|
479785
|
+
name: external_exports.string(),
|
|
479786
|
+
arguments: external_exports.string()
|
|
479787
|
+
}),
|
|
479788
|
+
// Support for Google Gemini thought signatures via OpenAI compatibility
|
|
479789
|
+
extra_content: external_exports.object({
|
|
479790
|
+
google: external_exports.object({
|
|
479791
|
+
thought_signature: external_exports.string().nullish()
|
|
479792
|
+
}).nullish()
|
|
479793
|
+
}).nullish()
|
|
479794
|
+
})
|
|
479795
|
+
).nullish()
|
|
479796
|
+
}),
|
|
479797
|
+
finish_reason: external_exports.string().nullish()
|
|
479798
|
+
})
|
|
479799
|
+
),
|
|
479800
|
+
usage: openaiCompatibleTokenUsageSchema
|
|
479801
|
+
});
|
|
479802
|
+
chunkBaseSchema = external_exports.looseObject({
|
|
479803
|
+
id: external_exports.string().nullish(),
|
|
479804
|
+
created: external_exports.number().nullish(),
|
|
479805
|
+
model: external_exports.string().nullish(),
|
|
479806
|
+
choices: external_exports.array(
|
|
479807
|
+
external_exports.object({
|
|
479808
|
+
delta: external_exports.object({
|
|
479809
|
+
role: external_exports.enum(["assistant", ""]).nullish(),
|
|
479810
|
+
content: openAICompatibleContentSchema,
|
|
479811
|
+
// Most openai-compatible models set `reasoning_content`, but some
|
|
479812
|
+
// providers serving `gpt-oss` set `reasoning`. See #7866
|
|
479813
|
+
reasoning_content: external_exports.string().nullish(),
|
|
479814
|
+
reasoning: external_exports.string().nullish(),
|
|
479815
|
+
tool_calls: external_exports.array(
|
|
479816
|
+
external_exports.object({
|
|
479817
|
+
index: external_exports.number().nullish(),
|
|
479818
|
+
//google does not send index
|
|
479819
|
+
id: external_exports.string().nullish(),
|
|
479820
|
+
function: external_exports.object({
|
|
479821
|
+
name: external_exports.string().nullish(),
|
|
479822
|
+
arguments: external_exports.string().nullish()
|
|
479823
|
+
}),
|
|
479824
|
+
// Support for Google Gemini thought signatures via OpenAI compatibility
|
|
479825
|
+
extra_content: external_exports.object({
|
|
479826
|
+
google: external_exports.object({
|
|
479827
|
+
thought_signature: external_exports.string().nullish()
|
|
479828
|
+
}).nullish()
|
|
479829
|
+
}).nullish()
|
|
479830
|
+
})
|
|
479831
|
+
).nullish()
|
|
479832
|
+
}).nullish(),
|
|
479833
|
+
finish_reason: external_exports.string().nullish()
|
|
479834
|
+
})
|
|
479835
|
+
),
|
|
479836
|
+
usage: openaiCompatibleTokenUsageSchema
|
|
479837
|
+
});
|
|
479838
|
+
createOpenAICompatibleChatChunkSchema = (errorSchema) => external_exports.union([chunkBaseSchema, errorSchema]);
|
|
479839
|
+
openaiCompatibleLanguageModelCompletionOptions = external_exports.object({
|
|
479840
|
+
/**
|
|
479841
|
+
* Echo back the prompt in addition to the completion.
|
|
479842
|
+
*/
|
|
479843
|
+
echo: external_exports.boolean().optional(),
|
|
479844
|
+
/**
|
|
479845
|
+
* Modify the likelihood of specified tokens appearing in the completion.
|
|
479846
|
+
*
|
|
479847
|
+
* Accepts a JSON object that maps tokens (specified by their token ID in
|
|
479848
|
+
* the GPT tokenizer) to an associated bias value from -100 to 100.
|
|
479849
|
+
*/
|
|
479850
|
+
logitBias: external_exports.record(external_exports.string(), external_exports.number()).optional(),
|
|
479851
|
+
/**
|
|
479852
|
+
* The suffix that comes after a completion of inserted text.
|
|
479853
|
+
*/
|
|
479854
|
+
suffix: external_exports.string().optional(),
|
|
479855
|
+
/**
|
|
479856
|
+
* A unique identifier representing your end-user, which can help providers to
|
|
479857
|
+
* monitor and detect abuse.
|
|
479858
|
+
*/
|
|
479859
|
+
user: external_exports.string().optional()
|
|
479860
|
+
});
|
|
479861
|
+
OpenAICompatibleCompletionLanguageModel = class {
|
|
479862
|
+
// type inferred via constructor
|
|
479863
|
+
constructor(modelId, config2) {
|
|
479864
|
+
this.specificationVersion = "v3";
|
|
479865
|
+
var _a17;
|
|
479866
|
+
this.modelId = modelId;
|
|
479867
|
+
this.config = config2;
|
|
479868
|
+
const errorStructure = (_a17 = config2.errorStructure) != null ? _a17 : defaultOpenAICompatibleErrorStructure;
|
|
479869
|
+
this.chunkSchema = createOpenAICompatibleCompletionChunkSchema(
|
|
479870
|
+
errorStructure.errorSchema
|
|
479871
|
+
);
|
|
479872
|
+
this.failedResponseHandler = createJsonErrorResponseHandler(errorStructure);
|
|
479873
|
+
}
|
|
479874
|
+
get provider() {
|
|
479875
|
+
return this.config.provider;
|
|
479876
|
+
}
|
|
479877
|
+
get providerOptionsName() {
|
|
479878
|
+
return this.config.provider.split(".")[0].trim();
|
|
479879
|
+
}
|
|
479880
|
+
get supportedUrls() {
|
|
479881
|
+
var _a17, _b16, _c;
|
|
479882
|
+
return (_c = (_b16 = (_a17 = this.config).supportedUrls) == null ? void 0 : _b16.call(_a17)) != null ? _c : {};
|
|
479883
|
+
}
|
|
479884
|
+
async getArgs({
|
|
479885
|
+
prompt,
|
|
479886
|
+
maxOutputTokens,
|
|
479887
|
+
temperature,
|
|
479888
|
+
topP,
|
|
479889
|
+
topK,
|
|
479890
|
+
frequencyPenalty,
|
|
479891
|
+
presencePenalty,
|
|
479892
|
+
stopSequences: userStopSequences,
|
|
479893
|
+
responseFormat,
|
|
479894
|
+
seed,
|
|
479895
|
+
providerOptions,
|
|
479896
|
+
tools: tools2,
|
|
479897
|
+
toolChoice
|
|
479898
|
+
}) {
|
|
479899
|
+
var _a17, _b16;
|
|
479900
|
+
const warnings = [];
|
|
479901
|
+
const completionOptions = Object.assign(
|
|
479902
|
+
(_a17 = await parseProviderOptions({
|
|
479903
|
+
provider: this.providerOptionsName,
|
|
479904
|
+
providerOptions,
|
|
479905
|
+
schema: openaiCompatibleLanguageModelCompletionOptions
|
|
479906
|
+
})) != null ? _a17 : {},
|
|
479907
|
+
(_b16 = await parseProviderOptions({
|
|
479908
|
+
provider: toCamelCase(this.providerOptionsName),
|
|
479909
|
+
providerOptions,
|
|
479910
|
+
schema: openaiCompatibleLanguageModelCompletionOptions
|
|
479911
|
+
})) != null ? _b16 : {}
|
|
479912
|
+
);
|
|
479913
|
+
if (topK != null) {
|
|
479914
|
+
warnings.push({ type: "unsupported", feature: "topK" });
|
|
479915
|
+
}
|
|
479916
|
+
if (tools2 == null ? void 0 : tools2.length) {
|
|
479917
|
+
warnings.push({ type: "unsupported", feature: "tools" });
|
|
479918
|
+
}
|
|
479919
|
+
if (toolChoice != null) {
|
|
479920
|
+
warnings.push({ type: "unsupported", feature: "toolChoice" });
|
|
479921
|
+
}
|
|
479922
|
+
if (responseFormat != null && responseFormat.type !== "text") {
|
|
479923
|
+
warnings.push({
|
|
479924
|
+
type: "unsupported",
|
|
479925
|
+
feature: "responseFormat",
|
|
479926
|
+
details: "JSON response format is not supported."
|
|
479927
|
+
});
|
|
479928
|
+
}
|
|
479929
|
+
const { prompt: completionPrompt, stopSequences } = convertToOpenAICompatibleCompletionPrompt({ prompt });
|
|
479930
|
+
const stop = [...stopSequences != null ? stopSequences : [], ...userStopSequences != null ? userStopSequences : []];
|
|
479931
|
+
return {
|
|
479932
|
+
args: {
|
|
479933
|
+
// model id:
|
|
479934
|
+
model: this.modelId,
|
|
479935
|
+
// model specific settings:
|
|
479936
|
+
echo: completionOptions.echo,
|
|
479937
|
+
logit_bias: completionOptions.logitBias,
|
|
479938
|
+
suffix: completionOptions.suffix,
|
|
479939
|
+
user: completionOptions.user,
|
|
479940
|
+
// standardized settings:
|
|
479941
|
+
max_tokens: maxOutputTokens,
|
|
479942
|
+
temperature,
|
|
479943
|
+
top_p: topP,
|
|
479944
|
+
frequency_penalty: frequencyPenalty,
|
|
479945
|
+
presence_penalty: presencePenalty,
|
|
479946
|
+
seed,
|
|
479947
|
+
...providerOptions == null ? void 0 : providerOptions[this.providerOptionsName],
|
|
479948
|
+
...providerOptions == null ? void 0 : providerOptions[toCamelCase(this.providerOptionsName)],
|
|
479949
|
+
// prompt:
|
|
479950
|
+
prompt: completionPrompt,
|
|
479951
|
+
// stop sequences:
|
|
479952
|
+
stop: stop.length > 0 ? stop : void 0
|
|
479953
|
+
},
|
|
479954
|
+
warnings
|
|
479955
|
+
};
|
|
479956
|
+
}
|
|
479957
|
+
async doGenerate(options) {
|
|
479958
|
+
const { args, warnings } = await this.getArgs(options);
|
|
479959
|
+
const {
|
|
479960
|
+
responseHeaders,
|
|
479961
|
+
value: response,
|
|
479962
|
+
rawValue: rawResponse
|
|
479963
|
+
} = await postJsonToApi({
|
|
479964
|
+
url: this.config.url({
|
|
479965
|
+
path: "/completions",
|
|
479966
|
+
modelId: this.modelId
|
|
479967
|
+
}),
|
|
479968
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
479969
|
+
body: args,
|
|
479970
|
+
failedResponseHandler: this.failedResponseHandler,
|
|
479971
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
479972
|
+
openaiCompatibleCompletionResponseSchema
|
|
479973
|
+
),
|
|
479974
|
+
abortSignal: options.abortSignal,
|
|
479975
|
+
fetch: this.config.fetch
|
|
479976
|
+
});
|
|
479977
|
+
const choice = response.choices[0];
|
|
479978
|
+
const content = [];
|
|
479979
|
+
if (choice.text != null && choice.text.length > 0) {
|
|
479980
|
+
content.push({ type: "text", text: choice.text });
|
|
479981
|
+
}
|
|
479982
|
+
return {
|
|
479983
|
+
content,
|
|
479984
|
+
usage: convertOpenAICompatibleCompletionUsage(response.usage),
|
|
479985
|
+
finishReason: {
|
|
479986
|
+
unified: mapOpenAICompatibleFinishReason2(choice.finish_reason),
|
|
479987
|
+
raw: choice.finish_reason
|
|
479988
|
+
},
|
|
479989
|
+
request: { body: args },
|
|
479990
|
+
response: {
|
|
479991
|
+
...getResponseMetadata2(response),
|
|
479992
|
+
headers: responseHeaders,
|
|
479993
|
+
body: rawResponse
|
|
479994
|
+
},
|
|
479995
|
+
warnings
|
|
479996
|
+
};
|
|
479997
|
+
}
|
|
479998
|
+
async doStream(options) {
|
|
479999
|
+
const { args, warnings } = await this.getArgs(options);
|
|
480000
|
+
const body = {
|
|
480001
|
+
...args,
|
|
480002
|
+
stream: true,
|
|
480003
|
+
// only include stream_options when in strict compatibility mode:
|
|
480004
|
+
stream_options: this.config.includeUsage ? { include_usage: true } : void 0
|
|
480005
|
+
};
|
|
480006
|
+
const { responseHeaders, value: response } = await postJsonToApi({
|
|
480007
|
+
url: this.config.url({
|
|
480008
|
+
path: "/completions",
|
|
480009
|
+
modelId: this.modelId
|
|
480010
|
+
}),
|
|
480011
|
+
headers: combineHeaders(this.config.headers(), options.headers),
|
|
480012
|
+
body,
|
|
480013
|
+
failedResponseHandler: this.failedResponseHandler,
|
|
480014
|
+
successfulResponseHandler: createEventSourceResponseHandler(
|
|
480015
|
+
this.chunkSchema
|
|
480016
|
+
),
|
|
480017
|
+
abortSignal: options.abortSignal,
|
|
480018
|
+
fetch: this.config.fetch
|
|
480019
|
+
});
|
|
480020
|
+
let finishReason = {
|
|
480021
|
+
unified: "other",
|
|
480022
|
+
raw: void 0
|
|
480023
|
+
};
|
|
480024
|
+
let usage = void 0;
|
|
480025
|
+
let isFirstChunk = true;
|
|
480026
|
+
return {
|
|
480027
|
+
stream: response.pipeThrough(
|
|
480028
|
+
new TransformStream({
|
|
480029
|
+
start(controller) {
|
|
480030
|
+
controller.enqueue({ type: "stream-start", warnings });
|
|
480031
|
+
},
|
|
480032
|
+
transform(chunk, controller) {
|
|
480033
|
+
var _a17;
|
|
480034
|
+
if (options.includeRawChunks) {
|
|
480035
|
+
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
480036
|
+
}
|
|
480037
|
+
if (!chunk.success) {
|
|
480038
|
+
finishReason = { unified: "error", raw: void 0 };
|
|
480039
|
+
controller.enqueue({ type: "error", error: chunk.error });
|
|
480040
|
+
return;
|
|
480041
|
+
}
|
|
480042
|
+
const value = chunk.value;
|
|
480043
|
+
if ("error" in value) {
|
|
480044
|
+
finishReason = { unified: "error", raw: void 0 };
|
|
480045
|
+
controller.enqueue({ type: "error", error: value.error });
|
|
480046
|
+
return;
|
|
480047
|
+
}
|
|
480048
|
+
if (isFirstChunk) {
|
|
480049
|
+
isFirstChunk = false;
|
|
480050
|
+
controller.enqueue({
|
|
480051
|
+
type: "response-metadata",
|
|
480052
|
+
...getResponseMetadata2(value)
|
|
480053
|
+
});
|
|
480054
|
+
controller.enqueue({
|
|
480055
|
+
type: "text-start",
|
|
480056
|
+
id: "0"
|
|
480057
|
+
});
|
|
480058
|
+
}
|
|
480059
|
+
if (value.usage != null) {
|
|
480060
|
+
usage = value.usage;
|
|
480061
|
+
}
|
|
480062
|
+
const choice = value.choices[0];
|
|
480063
|
+
if ((choice == null ? void 0 : choice.finish_reason) != null) {
|
|
480064
|
+
finishReason = {
|
|
480065
|
+
unified: mapOpenAICompatibleFinishReason2(choice.finish_reason),
|
|
480066
|
+
raw: (_a17 = choice.finish_reason) != null ? _a17 : void 0
|
|
480067
|
+
};
|
|
480068
|
+
}
|
|
480069
|
+
if ((choice == null ? void 0 : choice.text) != null) {
|
|
480070
|
+
controller.enqueue({
|
|
480071
|
+
type: "text-delta",
|
|
480072
|
+
id: "0",
|
|
480073
|
+
delta: choice.text
|
|
480074
|
+
});
|
|
480075
|
+
}
|
|
480076
|
+
},
|
|
480077
|
+
flush(controller) {
|
|
480078
|
+
if (!isFirstChunk) {
|
|
480079
|
+
controller.enqueue({ type: "text-end", id: "0" });
|
|
480080
|
+
}
|
|
480081
|
+
controller.enqueue({
|
|
480082
|
+
type: "finish",
|
|
480083
|
+
finishReason,
|
|
480084
|
+
usage: convertOpenAICompatibleCompletionUsage(usage)
|
|
480085
|
+
});
|
|
480086
|
+
}
|
|
480087
|
+
})
|
|
480088
|
+
),
|
|
480089
|
+
request: { body },
|
|
480090
|
+
response: { headers: responseHeaders }
|
|
480091
|
+
};
|
|
480092
|
+
}
|
|
480093
|
+
};
|
|
480094
|
+
usageSchema = external_exports.looseObject({
|
|
480095
|
+
prompt_tokens: external_exports.number(),
|
|
480096
|
+
completion_tokens: external_exports.number(),
|
|
480097
|
+
total_tokens: external_exports.number()
|
|
480098
|
+
});
|
|
480099
|
+
openaiCompatibleCompletionResponseSchema = external_exports.object({
|
|
480100
|
+
id: external_exports.string().nullish(),
|
|
480101
|
+
created: external_exports.number().nullish(),
|
|
480102
|
+
model: external_exports.string().nullish(),
|
|
480103
|
+
choices: external_exports.array(
|
|
480104
|
+
external_exports.object({
|
|
480105
|
+
text: external_exports.string(),
|
|
480106
|
+
finish_reason: external_exports.string()
|
|
480107
|
+
})
|
|
480108
|
+
),
|
|
480109
|
+
usage: usageSchema.nullish()
|
|
480110
|
+
});
|
|
480111
|
+
createOpenAICompatibleCompletionChunkSchema = (errorSchema) => external_exports.union([
|
|
480112
|
+
external_exports.object({
|
|
480113
|
+
id: external_exports.string().nullish(),
|
|
480114
|
+
created: external_exports.number().nullish(),
|
|
480115
|
+
model: external_exports.string().nullish(),
|
|
480116
|
+
choices: external_exports.array(
|
|
480117
|
+
external_exports.object({
|
|
480118
|
+
text: external_exports.string(),
|
|
480119
|
+
finish_reason: external_exports.string().nullish(),
|
|
480120
|
+
index: external_exports.number()
|
|
480121
|
+
})
|
|
480122
|
+
),
|
|
480123
|
+
usage: usageSchema.nullish()
|
|
480124
|
+
}),
|
|
480125
|
+
errorSchema
|
|
480126
|
+
]);
|
|
480127
|
+
openaiCompatibleEmbeddingModelOptions = external_exports.object({
|
|
480128
|
+
/**
|
|
480129
|
+
* The number of dimensions the resulting output embeddings should have.
|
|
480130
|
+
* Only supported in text-embedding-3 and later models.
|
|
480131
|
+
*/
|
|
480132
|
+
dimensions: external_exports.number().optional(),
|
|
480133
|
+
/**
|
|
480134
|
+
* A unique identifier representing your end-user, which can help providers to
|
|
480135
|
+
* monitor and detect abuse.
|
|
480136
|
+
*/
|
|
480137
|
+
user: external_exports.string().optional()
|
|
480138
|
+
});
|
|
480139
|
+
OpenAICompatibleEmbeddingModel = class {
|
|
480140
|
+
constructor(modelId, config2) {
|
|
480141
|
+
this.specificationVersion = "v3";
|
|
480142
|
+
this.modelId = modelId;
|
|
480143
|
+
this.config = config2;
|
|
480144
|
+
}
|
|
480145
|
+
get provider() {
|
|
480146
|
+
return this.config.provider;
|
|
480147
|
+
}
|
|
480148
|
+
get maxEmbeddingsPerCall() {
|
|
480149
|
+
var _a17;
|
|
480150
|
+
return (_a17 = this.config.maxEmbeddingsPerCall) != null ? _a17 : 2048;
|
|
480151
|
+
}
|
|
480152
|
+
get supportsParallelCalls() {
|
|
480153
|
+
var _a17;
|
|
480154
|
+
return (_a17 = this.config.supportsParallelCalls) != null ? _a17 : true;
|
|
480155
|
+
}
|
|
480156
|
+
get providerOptionsName() {
|
|
480157
|
+
return this.config.provider.split(".")[0].trim();
|
|
480158
|
+
}
|
|
480159
|
+
async doEmbed({
|
|
480160
|
+
values: values2,
|
|
480161
|
+
headers,
|
|
480162
|
+
abortSignal,
|
|
480163
|
+
providerOptions
|
|
480164
|
+
}) {
|
|
480165
|
+
var _a17, _b16, _c;
|
|
480166
|
+
const warnings = [];
|
|
480167
|
+
const deprecatedOptions = await parseProviderOptions({
|
|
480168
|
+
provider: "openai-compatible",
|
|
480169
|
+
providerOptions,
|
|
480170
|
+
schema: openaiCompatibleEmbeddingModelOptions
|
|
480171
|
+
});
|
|
480172
|
+
if (deprecatedOptions != null) {
|
|
480173
|
+
warnings.push({
|
|
480174
|
+
type: "other",
|
|
480175
|
+
message: `The 'openai-compatible' key in providerOptions is deprecated. Use 'openaiCompatible' instead.`
|
|
480176
|
+
});
|
|
480177
|
+
}
|
|
480178
|
+
const compatibleOptions = Object.assign(
|
|
480179
|
+
deprecatedOptions != null ? deprecatedOptions : {},
|
|
480180
|
+
(_a17 = await parseProviderOptions({
|
|
480181
|
+
provider: "openaiCompatible",
|
|
480182
|
+
providerOptions,
|
|
480183
|
+
schema: openaiCompatibleEmbeddingModelOptions
|
|
480184
|
+
})) != null ? _a17 : {},
|
|
480185
|
+
(_b16 = await parseProviderOptions({
|
|
480186
|
+
provider: this.providerOptionsName,
|
|
480187
|
+
providerOptions,
|
|
480188
|
+
schema: openaiCompatibleEmbeddingModelOptions
|
|
480189
|
+
})) != null ? _b16 : {}
|
|
480190
|
+
);
|
|
480191
|
+
if (values2.length > this.maxEmbeddingsPerCall) {
|
|
480192
|
+
throw new TooManyEmbeddingValuesForCallError({
|
|
480193
|
+
provider: this.provider,
|
|
480194
|
+
modelId: this.modelId,
|
|
480195
|
+
maxEmbeddingsPerCall: this.maxEmbeddingsPerCall,
|
|
480196
|
+
values: values2
|
|
480197
|
+
});
|
|
480198
|
+
}
|
|
480199
|
+
const {
|
|
480200
|
+
responseHeaders,
|
|
480201
|
+
value: response,
|
|
480202
|
+
rawValue
|
|
480203
|
+
} = await postJsonToApi({
|
|
480204
|
+
url: this.config.url({
|
|
480205
|
+
path: "/embeddings",
|
|
480206
|
+
modelId: this.modelId
|
|
480207
|
+
}),
|
|
480208
|
+
headers: combineHeaders(this.config.headers(), headers),
|
|
480209
|
+
body: {
|
|
480210
|
+
model: this.modelId,
|
|
480211
|
+
input: values2,
|
|
480212
|
+
encoding_format: "float",
|
|
480213
|
+
dimensions: compatibleOptions.dimensions,
|
|
480214
|
+
user: compatibleOptions.user
|
|
480215
|
+
},
|
|
480216
|
+
failedResponseHandler: createJsonErrorResponseHandler(
|
|
480217
|
+
(_c = this.config.errorStructure) != null ? _c : defaultOpenAICompatibleErrorStructure
|
|
480218
|
+
),
|
|
480219
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
480220
|
+
openaiTextEmbeddingResponseSchema
|
|
480221
|
+
),
|
|
480222
|
+
abortSignal,
|
|
480223
|
+
fetch: this.config.fetch
|
|
480224
|
+
});
|
|
480225
|
+
return {
|
|
480226
|
+
warnings,
|
|
480227
|
+
embeddings: response.data.map((item) => item.embedding),
|
|
480228
|
+
usage: response.usage ? { tokens: response.usage.prompt_tokens } : void 0,
|
|
480229
|
+
providerMetadata: response.providerMetadata,
|
|
480230
|
+
response: { headers: responseHeaders, body: rawValue }
|
|
480231
|
+
};
|
|
480232
|
+
}
|
|
480233
|
+
};
|
|
480234
|
+
openaiTextEmbeddingResponseSchema = external_exports.object({
|
|
480235
|
+
data: external_exports.array(external_exports.object({ embedding: external_exports.array(external_exports.number()) })),
|
|
480236
|
+
usage: external_exports.object({ prompt_tokens: external_exports.number() }).nullish(),
|
|
480237
|
+
providerMetadata: external_exports.record(external_exports.string(), external_exports.record(external_exports.string(), external_exports.any())).optional()
|
|
480238
|
+
});
|
|
480239
|
+
OpenAICompatibleImageModel = class {
|
|
480240
|
+
constructor(modelId, config2) {
|
|
480241
|
+
this.modelId = modelId;
|
|
480242
|
+
this.config = config2;
|
|
480243
|
+
this.specificationVersion = "v3";
|
|
480244
|
+
this.maxImagesPerCall = 10;
|
|
480245
|
+
}
|
|
480246
|
+
get provider() {
|
|
480247
|
+
return this.config.provider;
|
|
480248
|
+
}
|
|
480249
|
+
/**
|
|
480250
|
+
* The provider options key used to extract provider-specific options.
|
|
480251
|
+
*/
|
|
480252
|
+
get providerOptionsKey() {
|
|
480253
|
+
return this.config.provider.split(".")[0].trim();
|
|
480254
|
+
}
|
|
480255
|
+
// TODO: deprecate non-camelCase keys and remove in future major version
|
|
480256
|
+
getArgs(providerOptions) {
|
|
480257
|
+
return {
|
|
480258
|
+
...providerOptions[this.providerOptionsKey],
|
|
480259
|
+
...providerOptions[toCamelCase(this.providerOptionsKey)]
|
|
480260
|
+
};
|
|
480261
|
+
}
|
|
480262
|
+
async doGenerate({
|
|
480263
|
+
prompt,
|
|
480264
|
+
n,
|
|
480265
|
+
size,
|
|
480266
|
+
aspectRatio,
|
|
480267
|
+
seed,
|
|
480268
|
+
providerOptions,
|
|
480269
|
+
headers,
|
|
480270
|
+
abortSignal,
|
|
480271
|
+
files,
|
|
480272
|
+
mask
|
|
480273
|
+
}) {
|
|
480274
|
+
var _a17, _b16, _c, _d, _e;
|
|
480275
|
+
const warnings = [];
|
|
480276
|
+
if (aspectRatio != null) {
|
|
480277
|
+
warnings.push({
|
|
480278
|
+
type: "unsupported",
|
|
480279
|
+
feature: "aspectRatio",
|
|
480280
|
+
details: "This model does not support aspect ratio. Use `size` instead."
|
|
480281
|
+
});
|
|
480282
|
+
}
|
|
480283
|
+
if (seed != null) {
|
|
480284
|
+
warnings.push({ type: "unsupported", feature: "seed" });
|
|
480285
|
+
}
|
|
480286
|
+
const currentDate = (_c = (_b16 = (_a17 = this.config._internal) == null ? void 0 : _a17.currentDate) == null ? void 0 : _b16.call(_a17)) != null ? _c : /* @__PURE__ */ new Date();
|
|
480287
|
+
const args = this.getArgs(providerOptions);
|
|
480288
|
+
if (files != null && files.length > 0) {
|
|
480289
|
+
const { value: response2, responseHeaders: responseHeaders2 } = await postFormDataToApi({
|
|
480290
|
+
url: this.config.url({
|
|
480291
|
+
path: "/images/edits",
|
|
480292
|
+
modelId: this.modelId
|
|
480293
|
+
}),
|
|
480294
|
+
headers: combineHeaders(this.config.headers(), headers),
|
|
480295
|
+
formData: convertToFormData({
|
|
480296
|
+
model: this.modelId,
|
|
480297
|
+
prompt,
|
|
480298
|
+
image: await Promise.all(files.map((file2) => fileToBlob(file2))),
|
|
480299
|
+
mask: mask != null ? await fileToBlob(mask) : void 0,
|
|
480300
|
+
n,
|
|
480301
|
+
size,
|
|
480302
|
+
...args
|
|
480303
|
+
}),
|
|
480304
|
+
failedResponseHandler: createJsonErrorResponseHandler(
|
|
480305
|
+
(_d = this.config.errorStructure) != null ? _d : defaultOpenAICompatibleErrorStructure
|
|
480306
|
+
),
|
|
480307
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
480308
|
+
openaiCompatibleImageResponseSchema
|
|
480309
|
+
),
|
|
480310
|
+
abortSignal,
|
|
480311
|
+
fetch: this.config.fetch
|
|
480312
|
+
});
|
|
480313
|
+
return {
|
|
480314
|
+
images: response2.data.map((item) => item.b64_json),
|
|
480315
|
+
warnings,
|
|
480316
|
+
response: {
|
|
480317
|
+
timestamp: currentDate,
|
|
480318
|
+
modelId: this.modelId,
|
|
480319
|
+
headers: responseHeaders2
|
|
480320
|
+
}
|
|
480321
|
+
};
|
|
480322
|
+
}
|
|
480323
|
+
const { value: response, responseHeaders } = await postJsonToApi({
|
|
480324
|
+
url: this.config.url({
|
|
480325
|
+
path: "/images/generations",
|
|
480326
|
+
modelId: this.modelId
|
|
480327
|
+
}),
|
|
480328
|
+
headers: combineHeaders(this.config.headers(), headers),
|
|
480329
|
+
body: {
|
|
480330
|
+
model: this.modelId,
|
|
480331
|
+
prompt,
|
|
480332
|
+
n,
|
|
480333
|
+
size,
|
|
480334
|
+
...args,
|
|
480335
|
+
response_format: "b64_json"
|
|
480336
|
+
},
|
|
480337
|
+
failedResponseHandler: createJsonErrorResponseHandler(
|
|
480338
|
+
(_e = this.config.errorStructure) != null ? _e : defaultOpenAICompatibleErrorStructure
|
|
480339
|
+
),
|
|
480340
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
480341
|
+
openaiCompatibleImageResponseSchema
|
|
480342
|
+
),
|
|
480343
|
+
abortSignal,
|
|
480344
|
+
fetch: this.config.fetch
|
|
480345
|
+
});
|
|
480346
|
+
return {
|
|
480347
|
+
images: response.data.map((item) => item.b64_json),
|
|
480348
|
+
warnings,
|
|
480349
|
+
response: {
|
|
480350
|
+
timestamp: currentDate,
|
|
480351
|
+
modelId: this.modelId,
|
|
480352
|
+
headers: responseHeaders
|
|
480353
|
+
}
|
|
480354
|
+
};
|
|
480355
|
+
}
|
|
480356
|
+
};
|
|
480357
|
+
openaiCompatibleImageResponseSchema = external_exports.object({
|
|
480358
|
+
data: external_exports.array(external_exports.object({ b64_json: external_exports.string() }))
|
|
480359
|
+
});
|
|
480360
|
+
VERSION2 = true ? "2.0.74" : 0;
|
|
480361
|
+
}
|
|
480362
|
+
});
|
|
480363
|
+
|
|
477950
480364
|
// node_modules/@smithy/core/dist-es/submodules/serde/is-array-buffer/is-array-buffer.js
|
|
477951
480365
|
var isArrayBuffer;
|
|
477952
480366
|
var init_is_array_buffer = __esm({
|
|
@@ -482584,16 +484998,17 @@ var init_aws4fetch_esm = __esm({
|
|
|
482584
484998
|
|
|
482585
484999
|
// node_modules/@ai-sdk/amazon-bedrock/dist/index.mjs
|
|
482586
485000
|
function supportsStrictTools(modelId) {
|
|
482587
|
-
return !
|
|
485001
|
+
return !matchesModel(modelId, MODELS_WITHOUT_STRICT_TOOL_SUPPORT);
|
|
482588
485002
|
}
|
|
482589
485003
|
function supportsNativeStructuredOutput(modelId) {
|
|
482590
|
-
return !
|
|
482591
|
-
|
|
482592
|
-
|
|
482593
|
-
return MODELS_REJECTING_NEWER_SCHEMA_FIELDS.some(
|
|
482594
|
-
(model) => modelId.includes(model)
|
|
485004
|
+
return !matchesModel(
|
|
485005
|
+
modelId,
|
|
485006
|
+
MODELS_WITHOUT_RELIABLE_NATIVE_STRUCTURED_OUTPUT
|
|
482595
485007
|
);
|
|
482596
485008
|
}
|
|
485009
|
+
function matchesModel(modelId, models) {
|
|
485010
|
+
return models.some((model) => modelId.includes(model));
|
|
485011
|
+
}
|
|
482597
485012
|
function createBedrockEventStreamDecoder(body, processEvent) {
|
|
482598
485013
|
const codec = new import_eventstream_codec.EventStreamCodec(import_util_utf8.toUtf8, import_util_utf8.fromUtf8);
|
|
482599
485014
|
let buffer = new Uint8Array(0);
|
|
@@ -482638,7 +485053,7 @@ function createBedrockEventStreamDecoder(body, processEvent) {
|
|
|
482638
485053
|
})
|
|
482639
485054
|
);
|
|
482640
485055
|
}
|
|
482641
|
-
async function
|
|
485056
|
+
async function prepareTools2({
|
|
482642
485057
|
tools: tools2,
|
|
482643
485058
|
toolChoice,
|
|
482644
485059
|
modelId,
|
|
@@ -483291,6 +485706,9 @@ function mapBedrockFinishReason(finishReason, isJsonResponseFromTool) {
|
|
|
483291
485706
|
return "other";
|
|
483292
485707
|
}
|
|
483293
485708
|
}
|
|
485709
|
+
function isJsonResponseToolName(name15) {
|
|
485710
|
+
return name15 === "json" || name15 === "json<|channel|>commentary";
|
|
485711
|
+
}
|
|
483294
485712
|
function isCohereEmbeddingModel(modelId) {
|
|
483295
485713
|
return modelId.includes("cohere.embed-");
|
|
483296
485714
|
}
|
|
@@ -483322,7 +485740,7 @@ function createSigV4FetchFunction(getCredentials, fetch2, service = "bedrock") {
|
|
|
483322
485740
|
);
|
|
483323
485741
|
const headersWithUserAgent = withUserAgentSuffix(
|
|
483324
485742
|
originalHeaders,
|
|
483325
|
-
`ai-sdk/amazon-bedrock/${
|
|
485743
|
+
`ai-sdk/amazon-bedrock/${VERSION3}`,
|
|
483326
485744
|
getRuntimeEnvironmentUserAgent()
|
|
483327
485745
|
);
|
|
483328
485746
|
let effectiveBody = (_a17 = init == null ? void 0 : init.body) != null ? _a17 : void 0;
|
|
@@ -483380,7 +485798,7 @@ function createApiKeyFetchFunction(apiKey, fetch2) {
|
|
|
483380
485798
|
const originalHeaders = normalizeHeaders(init == null ? void 0 : init.headers);
|
|
483381
485799
|
const headersWithUserAgent = withUserAgentSuffix(
|
|
483382
485800
|
originalHeaders,
|
|
483383
|
-
`ai-sdk/amazon-bedrock/${
|
|
485801
|
+
`ai-sdk/amazon-bedrock/${VERSION3}`,
|
|
483384
485802
|
getRuntimeEnvironmentUserAgent()
|
|
483385
485803
|
);
|
|
483386
485804
|
const finalHeaders = combineHeaders(headersWithUserAgent, {
|
|
@@ -483462,7 +485880,7 @@ Original error: ${errorMessage}`
|
|
|
483462
485880
|
const getHeaders = () => {
|
|
483463
485881
|
var _a17;
|
|
483464
485882
|
const baseHeaders = (_a17 = options.headers) != null ? _a17 : {};
|
|
483465
|
-
return withUserAgentSuffix(baseHeaders, `ai-sdk/amazon-bedrock/${
|
|
485883
|
+
return withUserAgentSuffix(baseHeaders, `ai-sdk/amazon-bedrock/${VERSION3}`);
|
|
483466
485884
|
};
|
|
483467
485885
|
const getBedrockRuntimeBaseUrl = () => {
|
|
483468
485886
|
var _a17, _b16;
|
|
@@ -483535,38 +485953,38 @@ Original error: ${errorMessage}`
|
|
|
483535
485953
|
provider.tools = import_internal.anthropicTools;
|
|
483536
485954
|
return provider;
|
|
483537
485955
|
}
|
|
483538
|
-
var import_internal, import_internal2, import_eventstream_codec, import_util_utf8, import_internal3, BEDROCK_STOP_REASONS, BEDROCK_IMAGE_MIME_TYPES, BEDROCK_DOCUMENT_MIME_TYPES, bedrockFilePartProviderOptions, amazonBedrockLanguageModelOptions,
|
|
483539
|
-
var
|
|
485956
|
+
var import_internal, import_internal2, import_eventstream_codec, import_util_utf8, import_internal3, BEDROCK_STOP_REASONS, BEDROCK_IMAGE_MIME_TYPES, BEDROCK_DOCUMENT_MIME_TYPES, bedrockFilePartProviderOptions, amazonBedrockLanguageModelOptions, MODELS_WITHOUT_STRICT_TOOL_SUPPORT, MODELS_WITHOUT_RELIABLE_NATIVE_STRUCTURED_OUTPUT, BedrockErrorSchema, createBedrockEventStreamResponseHandler, bedrockReasoningMetadataSchema, anthropicProviderOptions, BedrockChatLanguageModel, JsonObjectTextExtractor, BedrockStopReasonSchema, BedrockAdditionalModelResponseFieldsSchema, BedrockToolUseSchema, BedrockReasoningTextSchema, BedrockRedactedReasoningSchema, AmazonBedrockCacheDetailSchema, BedrockResponseSchema, BedrockStreamSchema, amazonBedrockEmbeddingModelOptionsSchema, BedrockEmbeddingModel, BedrockEmbeddingResponseSchema, modelMaxImagesPerCall, BedrockImageModel, bedrockImageResponseSchema, VERSION3, bedrockRerankingResponseSchema, amazonBedrockRerankingModelOptionsSchema, BedrockRerankingModel, bedrock;
|
|
485957
|
+
var init_dist5 = __esm({
|
|
483540
485958
|
"node_modules/@ai-sdk/amazon-bedrock/dist/index.mjs"() {
|
|
483541
485959
|
import_internal = __nccwpck_require__(27595);
|
|
483542
|
-
|
|
483543
|
-
|
|
485960
|
+
init_dist3();
|
|
485961
|
+
init_dist3();
|
|
483544
485962
|
import_internal2 = __nccwpck_require__(27595);
|
|
483545
485963
|
init_v4();
|
|
483546
485964
|
init_v4();
|
|
483547
485965
|
init_v4();
|
|
483548
485966
|
init_dist();
|
|
483549
|
-
|
|
485967
|
+
init_dist3();
|
|
483550
485968
|
import_eventstream_codec = __toESM(require_dist_cjs2(), 1);
|
|
483551
485969
|
import_util_utf8 = __toESM(require_dist_cjs3(), 1);
|
|
483552
485970
|
init_dist();
|
|
483553
|
-
|
|
485971
|
+
init_dist3();
|
|
483554
485972
|
import_internal3 = __nccwpck_require__(27595);
|
|
483555
485973
|
init_dist();
|
|
483556
|
-
|
|
485974
|
+
init_dist3();
|
|
483557
485975
|
init_v4();
|
|
483558
485976
|
init_dist();
|
|
483559
|
-
|
|
485977
|
+
init_dist3();
|
|
483560
485978
|
init_v4();
|
|
483561
485979
|
init_v4();
|
|
483562
|
-
|
|
485980
|
+
init_dist3();
|
|
483563
485981
|
init_v4();
|
|
483564
|
-
|
|
485982
|
+
init_dist3();
|
|
483565
485983
|
init_aws4fetch_esm();
|
|
483566
|
-
|
|
483567
|
-
|
|
485984
|
+
init_dist3();
|
|
485985
|
+
init_dist3();
|
|
483568
485986
|
init_v4();
|
|
483569
|
-
|
|
485987
|
+
init_dist3();
|
|
483570
485988
|
init_v4();
|
|
483571
485989
|
BEDROCK_STOP_REASONS = [
|
|
483572
485990
|
"stop",
|
|
@@ -483610,6 +486028,14 @@ var init_dist3 = __esm({
|
|
|
483610
486028
|
}).optional()
|
|
483611
486029
|
});
|
|
483612
486030
|
amazonBedrockLanguageModelOptions = external_exports.object({
|
|
486031
|
+
/**
|
|
486032
|
+
* Determines how structured outputs are generated for Anthropic models.
|
|
486033
|
+
*
|
|
486034
|
+
* - `outputFormat`: Use the native `output_config.format` parameter.
|
|
486035
|
+
* - `jsonTool`: Use a special 'json' tool to specify the structured output format.
|
|
486036
|
+
* - `auto`: Use `outputFormat` when supported, otherwise use `jsonTool` (default).
|
|
486037
|
+
*/
|
|
486038
|
+
structuredOutputMode: external_exports.enum(["outputFormat", "jsonTool", "auto"]).optional(),
|
|
483613
486039
|
/**
|
|
483614
486040
|
* Additional inference parameters that the model supports,
|
|
483615
486041
|
* beyond the base set of inference parameters that Converse
|
|
@@ -483641,13 +486067,18 @@ var init_dist3 = __esm({
|
|
|
483641
486067
|
*/
|
|
483642
486068
|
serviceTier: external_exports.enum(["reserved", "priority", "default", "flex"]).optional()
|
|
483643
486069
|
});
|
|
483644
|
-
|
|
486070
|
+
MODELS_WITHOUT_STRICT_TOOL_SUPPORT = [
|
|
483645
486071
|
"claude-opus-4-7",
|
|
483646
486072
|
"claude-opus-4-8",
|
|
483647
486073
|
"claude-opus-5",
|
|
483648
486074
|
"claude-fable-5",
|
|
483649
486075
|
"claude-sonnet-5"
|
|
483650
486076
|
];
|
|
486077
|
+
MODELS_WITHOUT_RELIABLE_NATIVE_STRUCTURED_OUTPUT = [
|
|
486078
|
+
...MODELS_WITHOUT_STRICT_TOOL_SUPPORT,
|
|
486079
|
+
"claude-sonnet-4-6",
|
|
486080
|
+
"claude-haiku-4-5"
|
|
486081
|
+
];
|
|
483651
486082
|
BedrockErrorSchema = external_exports.object({
|
|
483652
486083
|
message: external_exports.string(),
|
|
483653
486084
|
type: external_exports.string().nullish()
|
|
@@ -483698,7 +486129,8 @@ var init_dist3 = __esm({
|
|
|
483698
486129
|
redactedContent: external_exports.string().optional()
|
|
483699
486130
|
});
|
|
483700
486131
|
anthropicProviderOptions = external_exports.object({
|
|
483701
|
-
disableParallelToolUse: external_exports.boolean().optional()
|
|
486132
|
+
disableParallelToolUse: external_exports.boolean().optional(),
|
|
486133
|
+
structuredOutputMode: external_exports.enum(["outputFormat", "jsonTool", "auto"]).optional()
|
|
483702
486134
|
});
|
|
483703
486135
|
BedrockChatLanguageModel = class {
|
|
483704
486136
|
constructor(modelId, config2) {
|
|
@@ -483725,7 +486157,7 @@ var init_dist3 = __esm({
|
|
|
483725
486157
|
toolChoice,
|
|
483726
486158
|
providerOptions
|
|
483727
486159
|
}) {
|
|
483728
|
-
var _a17, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
486160
|
+
var _a17, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s;
|
|
483729
486161
|
const bedrockOptions = (_a17 = await parseProviderOptions({
|
|
483730
486162
|
provider: "bedrock",
|
|
483731
486163
|
providerOptions,
|
|
@@ -483783,15 +486215,33 @@ var init_dist3 = __esm({
|
|
|
483783
486215
|
const isOpenAIGptOssModel = (_d = openAIModelId == null ? void 0 : openAIModelId.startsWith("openai.gpt-oss-")) != null ? _d : false;
|
|
483784
486216
|
const isThinkingEnabled = ((_e = bedrockOptions.reasoningConfig) == null ? void 0 : _e.type) === "enabled" || ((_f = bedrockOptions.reasoningConfig) == null ? void 0 : _f.type) === "adaptive";
|
|
483785
486217
|
const { supportsStructuredOutput: modelSupportsStructuredOutput } = (0, import_internal2.getModelCapabilities)(this.modelId);
|
|
483786
|
-
const
|
|
483787
|
-
|
|
486218
|
+
const structuredOutputMode = (_h = (_g = bedrockOptions.structuredOutputMode) != null ? _g : anthropicOptions == null ? void 0 : anthropicOptions.structuredOutputMode) != null ? _h : "auto";
|
|
486219
|
+
if (structuredOutputMode === "jsonTool") {
|
|
486220
|
+
const additionalModelRequestFields = {
|
|
486221
|
+
...bedrockOptions.additionalModelRequestFields
|
|
486222
|
+
};
|
|
486223
|
+
const outputConfig = additionalModelRequestFields.output_config;
|
|
486224
|
+
if (outputConfig != null && typeof outputConfig === "object" && !Array.isArray(outputConfig)) {
|
|
486225
|
+
const outputConfigWithoutFormat = { ...outputConfig };
|
|
486226
|
+
delete outputConfigWithoutFormat.format;
|
|
486227
|
+
if (Object.keys(outputConfigWithoutFormat).length > 0) {
|
|
486228
|
+
additionalModelRequestFields.output_config = outputConfigWithoutFormat;
|
|
486229
|
+
} else {
|
|
486230
|
+
delete additionalModelRequestFields.output_config;
|
|
486231
|
+
}
|
|
486232
|
+
bedrockOptions.additionalModelRequestFields = additionalModelRequestFields;
|
|
486233
|
+
}
|
|
486234
|
+
}
|
|
486235
|
+
const modelSupportsNativeStructuredOutput = supportsNativeStructuredOutput(this.modelId) && (modelSupportsStructuredOutput || isThinkingEnabled);
|
|
486236
|
+
const useNativeStructuredOutput = isAnthropicModel && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && (structuredOutputMode === "outputFormat" || structuredOutputMode === "auto" && modelSupportsNativeStructuredOutput);
|
|
486237
|
+
const useJsonInstructionForStructuredOutput = !useNativeStructuredOutput && structuredOutputMode !== "jsonTool" && isAnthropicModel && !supportsStrictTools(this.modelId) && (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && tools2 != null && tools2.length > 0;
|
|
483788
486238
|
const jsonResponseTool = (responseFormat == null ? void 0 : responseFormat.type) === "json" && responseFormat.schema != null && !useNativeStructuredOutput && !useJsonInstructionForStructuredOutput ? {
|
|
483789
486239
|
type: "function",
|
|
483790
486240
|
name: "json",
|
|
483791
486241
|
description: "Respond with a JSON object.",
|
|
483792
486242
|
inputSchema: responseFormat.schema
|
|
483793
486243
|
} : void 0;
|
|
483794
|
-
const { toolConfig, additionalTools, toolWarnings, betas } = await
|
|
486244
|
+
const { toolConfig, additionalTools, toolWarnings, betas } = await prepareTools2({
|
|
483795
486245
|
tools: jsonResponseTool ? [...tools2 != null ? tools2 : [], jsonResponseTool] : tools2,
|
|
483796
486246
|
toolChoice: jsonResponseTool != null ? { type: "required" } : toolChoice,
|
|
483797
486247
|
modelId: this.modelId,
|
|
@@ -483805,16 +486255,16 @@ var init_dist3 = __esm({
|
|
|
483805
486255
|
};
|
|
483806
486256
|
}
|
|
483807
486257
|
if (betas.size > 0 || bedrockOptions.anthropicBeta) {
|
|
483808
|
-
const existingBetas = (
|
|
486258
|
+
const existingBetas = (_i = bedrockOptions.anthropicBeta) != null ? _i : [];
|
|
483809
486259
|
const mergedBetas = betas.size > 0 ? [...existingBetas, ...Array.from(betas)] : existingBetas;
|
|
483810
486260
|
bedrockOptions.additionalModelRequestFields = {
|
|
483811
486261
|
...bedrockOptions.additionalModelRequestFields,
|
|
483812
486262
|
anthropic_beta: mergedBetas
|
|
483813
486263
|
};
|
|
483814
486264
|
}
|
|
483815
|
-
const thinkingType = (
|
|
483816
|
-
const thinkingBudget = thinkingType === "enabled" ? (
|
|
483817
|
-
const thinkingDisplay = thinkingType === "adaptive" ? (
|
|
486265
|
+
const thinkingType = (_j = bedrockOptions.reasoningConfig) == null ? void 0 : _j.type;
|
|
486266
|
+
const thinkingBudget = thinkingType === "enabled" ? (_k = bedrockOptions.reasoningConfig) == null ? void 0 : _k.budgetTokens : void 0;
|
|
486267
|
+
const thinkingDisplay = thinkingType === "adaptive" ? (_l = bedrockOptions.reasoningConfig) == null ? void 0 : _l.display : void 0;
|
|
483818
486268
|
const isAnthropicThinkingEnabled = isAnthropicModel && isThinkingEnabled;
|
|
483819
486269
|
const inferenceConfig = {
|
|
483820
486270
|
...maxOutputTokens != null && { maxTokens: maxOutputTokens },
|
|
@@ -483847,7 +486297,7 @@ var init_dist3 = __esm({
|
|
|
483847
486297
|
};
|
|
483848
486298
|
}
|
|
483849
486299
|
} else if (!isAnthropicModel) {
|
|
483850
|
-
if (((
|
|
486300
|
+
if (((_m = bedrockOptions.reasoningConfig) == null ? void 0 : _m.budgetTokens) != null) {
|
|
483851
486301
|
warnings.push({
|
|
483852
486302
|
type: "unsupported",
|
|
483853
486303
|
feature: "budgetTokens",
|
|
@@ -483862,13 +486312,13 @@ var init_dist3 = __esm({
|
|
|
483862
486312
|
});
|
|
483863
486313
|
}
|
|
483864
486314
|
}
|
|
483865
|
-
const maxReasoningEffort = (
|
|
486315
|
+
const maxReasoningEffort = (_n = bedrockOptions.reasoningConfig) == null ? void 0 : _n.maxReasoningEffort;
|
|
483866
486316
|
if (maxReasoningEffort != null) {
|
|
483867
486317
|
if (isAnthropicModel) {
|
|
483868
486318
|
bedrockOptions.additionalModelRequestFields = {
|
|
483869
486319
|
...bedrockOptions.additionalModelRequestFields,
|
|
483870
486320
|
output_config: {
|
|
483871
|
-
...(
|
|
486321
|
+
...(_o = bedrockOptions.additionalModelRequestFields) == null ? void 0 : _o.output_config,
|
|
483872
486322
|
effort: maxReasoningEffort
|
|
483873
486323
|
}
|
|
483874
486324
|
};
|
|
@@ -483879,7 +486329,7 @@ var init_dist3 = __esm({
|
|
|
483879
486329
|
} : {
|
|
483880
486330
|
...bedrockOptions.additionalModelRequestFields,
|
|
483881
486331
|
reasoning: {
|
|
483882
|
-
...(
|
|
486332
|
+
...(_p = bedrockOptions.additionalModelRequestFields) == null ? void 0 : _p.reasoning,
|
|
483883
486333
|
effort: maxReasoningEffort
|
|
483884
486334
|
}
|
|
483885
486335
|
};
|
|
@@ -483898,7 +486348,7 @@ var init_dist3 = __esm({
|
|
|
483898
486348
|
bedrockOptions.additionalModelRequestFields = {
|
|
483899
486349
|
...bedrockOptions.additionalModelRequestFields,
|
|
483900
486350
|
output_config: {
|
|
483901
|
-
...(
|
|
486351
|
+
...(_q = bedrockOptions.additionalModelRequestFields) == null ? void 0 : _q.output_config,
|
|
483902
486352
|
format: {
|
|
483903
486353
|
type: "json_schema",
|
|
483904
486354
|
schema: (0, import_internal2.sanitizeJsonSchema)(responseFormat.schema)
|
|
@@ -483930,7 +486380,7 @@ var init_dist3 = __esm({
|
|
|
483930
486380
|
details: "topK is not supported when thinking is enabled"
|
|
483931
486381
|
});
|
|
483932
486382
|
}
|
|
483933
|
-
const hasAnyTools = ((
|
|
486383
|
+
const hasAnyTools = ((_s = (_r = toolConfig.tools) == null ? void 0 : _r.length) != null ? _s : 0) > 0 || additionalTools;
|
|
483934
486384
|
let filteredPrompt = prompt;
|
|
483935
486385
|
if (!hasAnyTools) {
|
|
483936
486386
|
const hasToolContent = prompt.some(
|
|
@@ -483972,6 +486422,7 @@ var init_dist3 = __esm({
|
|
|
483972
486422
|
reasoningConfig: _,
|
|
483973
486423
|
additionalModelRequestFields: __,
|
|
483974
486424
|
serviceTier: ___,
|
|
486425
|
+
structuredOutputMode: ____,
|
|
483975
486426
|
...filteredBedrockOptions
|
|
483976
486427
|
} = (providerOptions == null ? void 0 : providerOptions.bedrock) || {};
|
|
483977
486428
|
const additionalModelResponseFieldPaths = isAnthropicModel ? ["/delta/stop_sequence"] : void 0;
|
|
@@ -484006,7 +486457,7 @@ var init_dist3 = __esm({
|
|
|
484006
486457
|
return combineHeaders(await resolve(this.config.headers), headers);
|
|
484007
486458
|
}
|
|
484008
486459
|
async doGenerate(options) {
|
|
484009
|
-
var _a17, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o;
|
|
486460
|
+
var _a17, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r;
|
|
484010
486461
|
const {
|
|
484011
486462
|
command: args,
|
|
484012
486463
|
warnings,
|
|
@@ -484035,10 +486486,12 @@ var init_dist3 = __esm({
|
|
|
484035
486486
|
let isJsonResponseFromTool = false;
|
|
484036
486487
|
const jsonObjectTextExtractor = usesJsonInstruction ? new JsonObjectTextExtractor() : void 0;
|
|
484037
486488
|
for (const part of response.output.message.content) {
|
|
484038
|
-
|
|
486489
|
+
const citationText = (_b16 = (_a17 = part.citationsContent) == null ? void 0 : _a17.content) == null ? void 0 : _b16.map((generatedContent) => generatedContent.text).filter((text2) => text2 != null).join("");
|
|
486490
|
+
const text = (_c = part.text) != null ? _c : citationText ? citationText : void 0;
|
|
486491
|
+
if (text != null) {
|
|
484039
486492
|
content.push({
|
|
484040
486493
|
type: "text",
|
|
484041
|
-
text: (
|
|
486494
|
+
text: (_d = jsonObjectTextExtractor == null ? void 0 : jsonObjectTextExtractor.process(text)) != null ? _d : text
|
|
484042
486495
|
});
|
|
484043
486496
|
}
|
|
484044
486497
|
if (part.reasoningContent) {
|
|
@@ -484061,7 +486514,7 @@ var init_dist3 = __esm({
|
|
|
484061
486514
|
text: "",
|
|
484062
486515
|
providerMetadata: {
|
|
484063
486516
|
bedrock: {
|
|
484064
|
-
redactedData: (
|
|
486517
|
+
redactedData: (_e = part.reasoningContent.redactedReasoning.data) != null ? _e : ""
|
|
484065
486518
|
}
|
|
484066
486519
|
}
|
|
484067
486520
|
});
|
|
@@ -484078,7 +486531,7 @@ var init_dist3 = __esm({
|
|
|
484078
486531
|
}
|
|
484079
486532
|
}
|
|
484080
486533
|
if (part.toolUse) {
|
|
484081
|
-
const isJsonResponseTool = usesJsonResponseTool && part.toolUse.name
|
|
486534
|
+
const isJsonResponseTool = usesJsonResponseTool && isJsonResponseToolName(part.toolUse.name);
|
|
484082
486535
|
if (isJsonResponseTool) {
|
|
484083
486536
|
isJsonResponseFromTool = true;
|
|
484084
486537
|
content.push({
|
|
@@ -484087,17 +486540,17 @@ var init_dist3 = __esm({
|
|
|
484087
486540
|
});
|
|
484088
486541
|
} else {
|
|
484089
486542
|
const isMistral = isMistralModel(this.modelId);
|
|
484090
|
-
const rawToolCallId = (
|
|
486543
|
+
const rawToolCallId = (_g = (_f = part.toolUse) == null ? void 0 : _f.toolUseId) != null ? _g : this.config.generateId();
|
|
484091
486544
|
content.push({
|
|
484092
486545
|
type: "tool-call",
|
|
484093
486546
|
toolCallId: normalizeToolCallId(rawToolCallId, isMistral),
|
|
484094
|
-
toolName: (
|
|
484095
|
-
input: JSON.stringify((
|
|
486547
|
+
toolName: (_i = (_h = part.toolUse) == null ? void 0 : _h.name) != null ? _i : `tool-${this.config.generateId()}`,
|
|
486548
|
+
input: JSON.stringify((_k = (_j = part.toolUse) == null ? void 0 : _j.input) != null ? _k : {})
|
|
484096
486549
|
});
|
|
484097
486550
|
}
|
|
484098
486551
|
}
|
|
484099
486552
|
}
|
|
484100
|
-
const stopSequence = (
|
|
486553
|
+
const stopSequence = (_n = (_m = (_l = response.additionalModelResponseFields) == null ? void 0 : _l.delta) == null ? void 0 : _m.stop_sequence) != null ? _n : null;
|
|
484101
486554
|
const providerMetadata = response.trace || response.usage || response.performanceConfig || response.serviceTier || isJsonResponseFromTool || stopSequence ? {
|
|
484102
486555
|
bedrock: {
|
|
484103
486556
|
...response.trace && typeof response.trace === "object" ? { trace: response.trace } : {},
|
|
@@ -484107,7 +486560,7 @@ var init_dist3 = __esm({
|
|
|
484107
486560
|
...response.serviceTier && {
|
|
484108
486561
|
serviceTier: response.serviceTier
|
|
484109
486562
|
},
|
|
484110
|
-
...(((
|
|
486563
|
+
...(((_o = response.usage) == null ? void 0 : _o.cacheWriteInputTokens) != null || ((_p = response.usage) == null ? void 0 : _p.cacheDetails) != null) && {
|
|
484111
486564
|
usage: {
|
|
484112
486565
|
...response.usage.cacheWriteInputTokens != null && {
|
|
484113
486566
|
cacheWriteInputTokens: response.usage.cacheWriteInputTokens
|
|
@@ -484128,11 +486581,11 @@ var init_dist3 = __esm({
|
|
|
484128
486581
|
response.stopReason,
|
|
484129
486582
|
isJsonResponseFromTool
|
|
484130
486583
|
),
|
|
484131
|
-
raw: (
|
|
486584
|
+
raw: (_q = response.stopReason) != null ? _q : void 0
|
|
484132
486585
|
},
|
|
484133
486586
|
usage: convertBedrockUsage(response.usage),
|
|
484134
486587
|
response: {
|
|
484135
|
-
id: (
|
|
486588
|
+
id: (_r = responseHeaders == null ? void 0 : responseHeaders["x-amzn-requestid"]) != null ? _r : void 0,
|
|
484136
486589
|
timestamp: (responseHeaders == null ? void 0 : responseHeaders["date"]) != null ? new Date(responseHeaders["date"]) : void 0,
|
|
484137
486590
|
modelId: this.modelId,
|
|
484138
486591
|
headers: responseHeaders
|
|
@@ -484413,7 +486866,7 @@ var init_dist3 = __esm({
|
|
|
484413
486866
|
if (((_q = contentBlockStart == null ? void 0 : contentBlockStart.start) == null ? void 0 : _q.toolUse) != null) {
|
|
484414
486867
|
const toolUse = contentBlockStart.start.toolUse;
|
|
484415
486868
|
const blockIndex = contentBlockStart.contentBlockIndex;
|
|
484416
|
-
const isJsonResponseTool = usesJsonResponseTool && toolUse.name
|
|
486869
|
+
const isJsonResponseTool = usesJsonResponseTool && isJsonResponseToolName(toolUse.name);
|
|
484417
486870
|
const normalizedToolCallId = normalizeToolCallId(
|
|
484418
486871
|
toolUse.toolUseId,
|
|
484419
486872
|
isMistral
|
|
@@ -484573,6 +487026,13 @@ var init_dist3 = __esm({
|
|
|
484573
487026
|
content: external_exports.array(
|
|
484574
487027
|
external_exports.object({
|
|
484575
487028
|
text: external_exports.string().nullish(),
|
|
487029
|
+
citationsContent: external_exports.object({
|
|
487030
|
+
content: external_exports.array(
|
|
487031
|
+
external_exports.object({
|
|
487032
|
+
text: external_exports.string().nullish()
|
|
487033
|
+
})
|
|
487034
|
+
).nullish()
|
|
487035
|
+
}).nullish(),
|
|
484576
487036
|
toolUse: BedrockToolUseSchema.nullish(),
|
|
484577
487037
|
reasoningContent: external_exports.union([
|
|
484578
487038
|
external_exports.object({
|
|
@@ -485035,7 +487495,7 @@ var init_dist3 = __esm({
|
|
|
485035
487495
|
details: external_exports.record(external_exports.string(), external_exports.unknown()).optional(),
|
|
485036
487496
|
preview: external_exports.unknown().optional()
|
|
485037
487497
|
});
|
|
485038
|
-
|
|
487498
|
+
VERSION3 = true ? "4.0.172" : 0;
|
|
485039
487499
|
bedrockRerankingResponseSchema = lazySchema(
|
|
485040
487500
|
() => zodSchema(
|
|
485041
487501
|
external_exports.object({
|
|
@@ -485153,10 +487613,17 @@ function createProviderInstance(config2) {
|
|
|
485153
487613
|
...config2.baseURL && { baseURL: config2.baseURL }
|
|
485154
487614
|
});
|
|
485155
487615
|
case "openai": {
|
|
487616
|
+
if (config2.baseURL) {
|
|
487617
|
+
const provider = createOpenAICompatible({
|
|
487618
|
+
name: "openai-compatible",
|
|
487619
|
+
baseURL: config2.baseURL,
|
|
487620
|
+
apiKey: config2.apiKey
|
|
487621
|
+
});
|
|
487622
|
+
return provider;
|
|
487623
|
+
}
|
|
485156
487624
|
const openai = (0, import_openai.createOpenAI)({
|
|
485157
487625
|
compatibility: "strict",
|
|
485158
|
-
apiKey: config2.apiKey
|
|
485159
|
-
...config2.baseURL && { baseURL: config2.baseURL }
|
|
487626
|
+
apiKey: config2.apiKey
|
|
485160
487627
|
});
|
|
485161
487628
|
const chatProvider = (modelId, settings) => openai.chat(modelId, settings);
|
|
485162
487629
|
chatProvider.chat = openai.chat.bind(openai);
|
|
@@ -485236,8 +487703,9 @@ var init_provider = __esm({
|
|
|
485236
487703
|
"use strict";
|
|
485237
487704
|
import_anthropic = __nccwpck_require__(93201);
|
|
485238
487705
|
import_openai = __nccwpck_require__(87635);
|
|
487706
|
+
init_dist4();
|
|
485239
487707
|
import_google = __nccwpck_require__(30260);
|
|
485240
|
-
|
|
487708
|
+
init_dist5();
|
|
485241
487709
|
DEFAULT_MODELS = {
|
|
485242
487710
|
anthropic: "claude-sonnet-4-6",
|
|
485243
487711
|
openai: "gpt-5.2",
|
|
@@ -491338,7 +493806,7 @@ var require_parser = __commonJS({
|
|
|
491338
493806
|
/* LispType.None */
|
|
491339
493807
|
});
|
|
491340
493808
|
var lispTypes = /* @__PURE__ */ new Map();
|
|
491341
|
-
var
|
|
493809
|
+
var ParseError2 = class extends Error {
|
|
491342
493810
|
constructor(message, code) {
|
|
491343
493811
|
super(message + ": " + code.substring(0, 40));
|
|
491344
493812
|
this.code = code;
|
|
@@ -492273,7 +494741,7 @@ var require_parser = __commonJS({
|
|
|
492273
494741
|
lispTypes.get(type)?.(constants, type, part, res, expect, ctx);
|
|
492274
494742
|
} catch (e) {
|
|
492275
494743
|
if (topLevel && e instanceof SyntaxError) {
|
|
492276
|
-
throw new
|
|
494744
|
+
throw new ParseError2(e.message, str);
|
|
492277
494745
|
}
|
|
492278
494746
|
throw e;
|
|
492279
494747
|
}
|
|
@@ -492285,7 +494753,7 @@ var require_parser = __commonJS({
|
|
|
492285
494753
|
}
|
|
492286
494754
|
if (!res && part.length) {
|
|
492287
494755
|
if (topLevel) {
|
|
492288
|
-
throw new
|
|
494756
|
+
throw new ParseError2(`Unexpected token after ${lastType}: ${part.char(0)}`, str);
|
|
492289
494757
|
}
|
|
492290
494758
|
throw new SyntaxError(`Unexpected token after ${lastType}: ${part.char(0)}`);
|
|
492291
494759
|
}
|
|
@@ -492580,7 +495048,7 @@ var require_parser = __commonJS({
|
|
|
492580
495048
|
}
|
|
492581
495049
|
function parse11(code, eager = false, expression = false) {
|
|
492582
495050
|
if (typeof code !== "string")
|
|
492583
|
-
throw new
|
|
495051
|
+
throw new ParseError2(`Cannot parse ${code}`, code);
|
|
492584
495052
|
let str = " " + code;
|
|
492585
495053
|
const constants = { strings: [], literals: [], regexes: [], eager };
|
|
492586
495054
|
str = extractConstants(constants, str).str;
|
|
@@ -492590,7 +495058,7 @@ var require_parser = __commonJS({
|
|
|
492590
495058
|
}
|
|
492591
495059
|
return { tree: lispifyFunction(new utils.CodeString(str), constants, expression), constants };
|
|
492592
495060
|
}
|
|
492593
|
-
exports2.ParseError =
|
|
495061
|
+
exports2.ParseError = ParseError2;
|
|
492594
495062
|
exports2.checkRegex = checkRegex;
|
|
492595
495063
|
exports2.default = parse11;
|
|
492596
495064
|
exports2.expectTypes = expectTypes;
|
|
@@ -512932,12 +515400,12 @@ var init_apply = __esm({
|
|
|
512932
515400
|
});
|
|
512933
515401
|
|
|
512934
515402
|
// node_modules/lodash-es/noop.js
|
|
512935
|
-
function
|
|
515403
|
+
function noop2() {
|
|
512936
515404
|
}
|
|
512937
515405
|
var noop_default;
|
|
512938
515406
|
var init_noop = __esm({
|
|
512939
515407
|
"node_modules/lodash-es/noop.js"() {
|
|
512940
|
-
noop_default =
|
|
515408
|
+
noop_default = noop2;
|
|
512941
515409
|
}
|
|
512942
515410
|
});
|
|
512943
515411
|
|
|
@@ -534886,9 +537354,9 @@ var require_arrayIncludesWith = __commonJS({
|
|
|
534886
537354
|
// node_modules/lodash/noop.js
|
|
534887
537355
|
var require_noop = __commonJS({
|
|
534888
537356
|
"node_modules/lodash/noop.js"(exports2, module2) {
|
|
534889
|
-
function
|
|
537357
|
+
function noop3() {
|
|
534890
537358
|
}
|
|
534891
|
-
module2.exports =
|
|
537359
|
+
module2.exports = noop3;
|
|
534892
537360
|
}
|
|
534893
537361
|
});
|
|
534894
537362
|
|
|
@@ -534896,10 +537364,10 @@ var require_noop = __commonJS({
|
|
|
534896
537364
|
var require_createSet = __commonJS({
|
|
534897
537365
|
"node_modules/lodash/_createSet.js"(exports2, module2) {
|
|
534898
537366
|
var Set3 = require_Set();
|
|
534899
|
-
var
|
|
537367
|
+
var noop3 = require_noop();
|
|
534900
537368
|
var setToArray2 = require_setToArray();
|
|
534901
537369
|
var INFINITY5 = 1 / 0;
|
|
534902
|
-
var createSet2 = !(Set3 && 1 / setToArray2(new Set3([, -0]))[1] == INFINITY5) ?
|
|
537370
|
+
var createSet2 = !(Set3 && 1 / setToArray2(new Set3([, -0]))[1] == INFINITY5) ? noop3 : function(values2) {
|
|
534903
537371
|
return new Set3(values2);
|
|
534904
537372
|
};
|
|
534905
537373
|
module2.exports = createSet2;
|
|
@@ -546016,7 +548484,8 @@ var require_utils2 = __commonJS({
|
|
|
546016
548484
|
"node_modules/fast-uri/lib/utils.js"(exports2, module2) {
|
|
546017
548485
|
"use strict";
|
|
546018
548486
|
var isUUID = RegExp.prototype.test.bind(/^[\da-f]{8}-[\da-f]{4}-[\da-f]{4}-[\da-f]{4}-[\da-f]{12}$/iu);
|
|
546019
|
-
var
|
|
548487
|
+
var isIPv42 = RegExp.prototype.test.bind(/^(?:(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)\.){3}(?:25[0-5]|2[0-4]\d|1\d{2}|[1-9]\d|\d)$/u);
|
|
548488
|
+
var isPort = RegExp.prototype.test.bind(/^\d*$/u);
|
|
546020
548489
|
var isHexPair = RegExp.prototype.test.bind(/^[\da-f]{2}$/iu);
|
|
546021
548490
|
var isUnreserved = RegExp.prototype.test.bind(/^[\da-z\-._~]$/iu);
|
|
546022
548491
|
var isPathCharacter = RegExp.prototype.test.bind(/^[A-Za-z0-9\-._~!$&'()*+,;=:@/]$/u);
|
|
@@ -546116,7 +548585,7 @@ var require_utils2 = __commonJS({
|
|
|
546116
548585
|
const part = parts[i];
|
|
546117
548586
|
if (part === "") return void 0;
|
|
546118
548587
|
if (part.indexOf(".") !== -1) {
|
|
546119
|
-
if (i !== parts.length - 1 || compression !== -1 && right.length === 0 || !
|
|
548588
|
+
if (i !== parts.length - 1 || compression !== -1 && right.length === 0 || !isIPv42(part)) return void 0;
|
|
546120
548589
|
hextetCount += 2;
|
|
546121
548590
|
continue;
|
|
546122
548591
|
}
|
|
@@ -546467,7 +548936,7 @@ var require_utils2 = __commonJS({
|
|
|
546467
548936
|
}
|
|
546468
548937
|
if (component.host !== void 0) {
|
|
546469
548938
|
let host = component.host;
|
|
546470
|
-
if (!
|
|
548939
|
+
if (!isIPv42(host)) {
|
|
546471
548940
|
let ipV6res = normalizeIPv6(host);
|
|
546472
548941
|
if (ipV6res.isIPV6 !== true && ipV6res.isIPVFuture !== true) {
|
|
546473
548942
|
host = normalizePercentEncoding(host, true);
|
|
@@ -546482,8 +548951,12 @@ var require_utils2 = __commonJS({
|
|
|
546482
548951
|
uriTokens.push(host);
|
|
546483
548952
|
}
|
|
546484
548953
|
if (typeof component.port === "number" || typeof component.port === "string") {
|
|
548954
|
+
const port = String(component.port);
|
|
548955
|
+
if (!isPort(port)) {
|
|
548956
|
+
throw new TypeError("URI port is malformed.");
|
|
548957
|
+
}
|
|
546485
548958
|
uriTokens.push(":");
|
|
546486
|
-
uriTokens.push(
|
|
548959
|
+
uriTokens.push(port);
|
|
546487
548960
|
}
|
|
546488
548961
|
return uriTokens.length ? uriTokens.join("") : void 0;
|
|
546489
548962
|
}
|
|
@@ -546500,7 +548973,7 @@ var require_utils2 = __commonJS({
|
|
|
546500
548973
|
encodeFragment,
|
|
546501
548974
|
escapePreservingEscapes,
|
|
546502
548975
|
removeDotSegments,
|
|
546503
|
-
isIPv4,
|
|
548976
|
+
isIPv4: isIPv42,
|
|
546504
548977
|
isUUID,
|
|
546505
548978
|
normalizeIPv6,
|
|
546506
548979
|
stringArrayToHexStripped
|
|
@@ -546723,7 +549196,7 @@ var require_schemes = __commonJS({
|
|
|
546723
549196
|
var require_fast_uri = __commonJS({
|
|
546724
549197
|
"node_modules/fast-uri/index.js"(exports2, module2) {
|
|
546725
549198
|
"use strict";
|
|
546726
|
-
var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4, nonSimpleDomain } = require_utils2();
|
|
549199
|
+
var { normalizeIPv6, removeDotSegments, recomposeAuthority, normalizePercentEncoding, normalizePathEncoding, serializePathEncoding, normalizeQueryFragmentEncoding, encodeQuery, encodeFragment, reescapeHostDelimiters, isIPv4: isIPv42, nonSimpleDomain } = require_utils2();
|
|
546727
549200
|
var { SCHEMES, getSchemeHandler } = require_schemes();
|
|
546728
549201
|
var VALID_SCHEME = /^[A-Za-z][A-Za-z0-9+.-]*$/u;
|
|
546729
549202
|
var MALFORMED_SCHEME_ERROR = "URI scheme is malformed.";
|
|
@@ -546768,7 +549241,7 @@ var require_fast_uri = __commonJS({
|
|
|
546768
549241
|
const resolved = resolveComponent(baseParsed, relativeParsed, schemelessOptions, true);
|
|
546769
549242
|
const resolvedSchemeHandler = getSchemeHandler(options && options.scheme || resolved.scheme);
|
|
546770
549243
|
const resolvedHost = resolved.host;
|
|
546771
|
-
const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (
|
|
549244
|
+
const resolvedHostIsIP = resolvedHost !== void 0 && resolvedHost !== "" && (isIPv42(resolvedHost) || normalizeIPv6(resolvedHost).isIPV6);
|
|
546772
549245
|
canonicalizeHost(resolved, options || {}, resolvedSchemeHandler, resolvedHostIsIP);
|
|
546773
549246
|
const encodedASCIIHost = resolvedHost && resolvedHost.indexOf("%") !== -1 && !/\P{ASCII}/u.test(resolvedHost);
|
|
546774
549247
|
if (resolved.error && !encodedASCIIHost) {
|
|
@@ -546926,12 +549399,15 @@ var require_fast_uri = __commonJS({
|
|
|
546926
549399
|
}
|
|
546927
549400
|
return false;
|
|
546928
549401
|
}
|
|
549402
|
+
function isIPLiteral(host) {
|
|
549403
|
+
return host[0] === "[" && host[host.length - 1] === "]";
|
|
549404
|
+
}
|
|
546929
549405
|
function hasMalformedComponentPercentEncoding(matches) {
|
|
546930
549406
|
const host = matches[4];
|
|
546931
|
-
return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !(host
|
|
549407
|
+
return hasMalformedPercentEncoding(matches[3]) || host !== void 0 && !isIPLiteral(host) && hasMalformedPercentEncoding(host) || hasMalformedPercentEncoding(matches[6]) || hasMalformedPercentEncoding(matches[7]) || hasMalformedPercentEncoding(matches[8]);
|
|
546932
549408
|
}
|
|
546933
549409
|
function canonicalizeHost(parsed, options, schemeHandler, isIP) {
|
|
546934
|
-
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && parsed.host
|
|
549410
|
+
if (!options.unicodeSupport && (!schemeHandler || !schemeHandler.unicodeSupport) && parsed.host && !isIPLiteral(parsed.host) && (options.domainHost || schemeHandler && schemeHandler.domainHost) && isIP === false && nonSimpleDomain(parsed.host)) {
|
|
546935
549411
|
try {
|
|
546936
549412
|
parsed.host = new URL("http://" + parsed.host).hostname;
|
|
546937
549413
|
} catch (e) {
|
|
@@ -547016,12 +549492,13 @@ var require_fast_uri = __commonJS({
|
|
|
547016
549492
|
malformedAuthorityOrPort = true;
|
|
547017
549493
|
}
|
|
547018
549494
|
if (parsed.host) {
|
|
547019
|
-
const ipv4result =
|
|
549495
|
+
const ipv4result = isIPv42(parsed.host);
|
|
547020
549496
|
if (ipv4result === false) {
|
|
547021
|
-
const bracketedIPLiteral = parsed.host
|
|
549497
|
+
const bracketedIPLiteral = isIPLiteral(parsed.host);
|
|
549498
|
+
const hasIPLiteralBracket = parsed.host.indexOf("[") !== -1 || parsed.host.indexOf("]") !== -1;
|
|
547022
549499
|
const ipv6result = normalizeIPv6(parsed.host);
|
|
547023
549500
|
isIP = ipv6result.isIPV6 || ipv6result.isIPVFuture === true;
|
|
547024
|
-
malformedIPLiteral =
|
|
549501
|
+
malformedIPLiteral = hasIPLiteralBracket && (!bracketedIPLiteral || ipv6result.error === true);
|
|
547025
549502
|
parsed.host = isIP ? ipv6result.host : ipv6result.host.toLowerCase();
|
|
547026
549503
|
if (malformedIPLiteral) {
|
|
547027
549504
|
parsed.error = parsed.error || "URI host is malformed.";
|
|
@@ -547044,7 +549521,9 @@ var require_fast_uri = __commonJS({
|
|
|
547044
549521
|
parsed.error = parsed.error || "URI is not a " + options.reference + " reference.";
|
|
547045
549522
|
}
|
|
547046
549523
|
const schemeHandler = getSchemeHandler(options.scheme || parsed.scheme);
|
|
547047
|
-
|
|
549524
|
+
if (!malformedIPLiteral) {
|
|
549525
|
+
malformedHost = canonicalizeHost(parsed, options, schemeHandler, isIP);
|
|
549526
|
+
}
|
|
547048
549527
|
if (!schemeHandler || schemeHandler && !schemeHandler.skipNormalize) {
|
|
547049
549528
|
if (uri.indexOf("%") !== -1) {
|
|
547050
549529
|
if (parsed.host !== void 0 && !malformedIPLiteral) {
|
|
@@ -551729,51 +554208,23 @@ function createTransport(serverConfig) {
|
|
|
551729
554208
|
throw new Error(`Invalid WebSocket URL: ${url2}`);
|
|
551730
554209
|
}
|
|
551731
554210
|
case "http":
|
|
551732
|
-
case "streamable":
|
|
554211
|
+
case "streamable": {
|
|
551733
554212
|
if (!url2) {
|
|
551734
554213
|
throw new Error("HTTP transport requires a URL");
|
|
551735
554214
|
}
|
|
551736
|
-
|
|
551737
|
-
|
|
551738
|
-
|
|
551739
|
-
}
|
|
551740
|
-
}
|
|
551741
|
-
function createHttpTransport(url2) {
|
|
551742
|
-
return {
|
|
551743
|
-
async start() {
|
|
551744
|
-
const response = await fetch(`${url2}/initialize`, {
|
|
551745
|
-
method: "POST",
|
|
551746
|
-
headers: { "Content-Type": "application/json" },
|
|
551747
|
-
body: JSON.stringify({
|
|
551748
|
-
protocolVersion: "2024-11-05",
|
|
551749
|
-
capabilities: {}
|
|
551750
|
-
})
|
|
551751
|
-
});
|
|
551752
|
-
if (!response.ok) {
|
|
551753
|
-
throw new Error(`HTTP initialization failed: ${response.statusText}`);
|
|
554215
|
+
const requestInit = {};
|
|
554216
|
+
if (serverConfig.headers && typeof serverConfig.headers === "object") {
|
|
554217
|
+
requestInit.headers = { ...serverConfig.headers };
|
|
551754
554218
|
}
|
|
551755
|
-
return
|
|
551756
|
-
|
|
551757
|
-
async send(message) {
|
|
551758
|
-
const response = await fetch(`${url2}/message`, {
|
|
551759
|
-
method: "POST",
|
|
551760
|
-
headers: { "Content-Type": "application/json" },
|
|
551761
|
-
body: JSON.stringify(message)
|
|
551762
|
-
});
|
|
551763
|
-
if (!response.ok) {
|
|
551764
|
-
throw new Error(`HTTP request failed: ${response.statusText}`);
|
|
551765
|
-
}
|
|
551766
|
-
return response.json();
|
|
551767
|
-
},
|
|
551768
|
-
async close() {
|
|
551769
|
-
await fetch(`${url2}/close`, {
|
|
551770
|
-
method: "POST"
|
|
551771
|
-
}).catch(() => {
|
|
554219
|
+
return new import_streamableHttp.StreamableHTTPClientTransport(new URL(url2), {
|
|
554220
|
+
requestInit: Object.keys(requestInit).length > 0 ? requestInit : void 0
|
|
551772
554221
|
});
|
|
551773
554222
|
}
|
|
551774
|
-
|
|
554223
|
+
default:
|
|
554224
|
+
throw new Error(`Unknown transport type: ${transport}`);
|
|
554225
|
+
}
|
|
551775
554226
|
}
|
|
551776
|
-
var import_client, import_stdio, import_sse, import_websocket, MCPClientManager;
|
|
554227
|
+
var import_client, import_stdio, import_sse, import_websocket, import_streamableHttp, MCPClientManager;
|
|
551777
554228
|
var init_client = __esm({
|
|
551778
554229
|
"src/agent/mcp/client.js"() {
|
|
551779
554230
|
"use strict";
|
|
@@ -551781,6 +554232,7 @@ var init_client = __esm({
|
|
|
551781
554232
|
import_stdio = __nccwpck_require__(55387);
|
|
551782
554233
|
import_sse = __nccwpck_require__(73131);
|
|
551783
554234
|
import_websocket = __nccwpck_require__(2605);
|
|
554235
|
+
import_streamableHttp = __nccwpck_require__(41772);
|
|
551784
554236
|
init_config2();
|
|
551785
554237
|
MCPClientManager = class {
|
|
551786
554238
|
constructor(options = {}) {
|
|
@@ -552482,7 +554934,7 @@ function abortable(promise2, signal) {
|
|
|
552482
554934
|
});
|
|
552483
554935
|
});
|
|
552484
554936
|
}
|
|
552485
|
-
var import_http, import_events2, import_crypto5, import_server, import_sse2,
|
|
554937
|
+
var import_http, import_events2, import_crypto5, import_server, import_sse2, import_streamableHttp2, import_ai5, import_types5, TOOL_DESCRIPTORS, ARGUMENT_DOMAIN, GOVERNED_CODEX_PROFILE_V2, GOVERNED_CALL_LIMIT, InMemoryEventStore, BuiltInMCPServer;
|
|
552486
554938
|
var init_built_in_server = __esm({
|
|
552487
554939
|
"src/agent/mcp/built-in-server.js"() {
|
|
552488
554940
|
"use strict";
|
|
@@ -552491,7 +554943,7 @@ var init_built_in_server = __esm({
|
|
|
552491
554943
|
import_crypto5 = __nccwpck_require__(76982);
|
|
552492
554944
|
import_server = __nccwpck_require__(2630);
|
|
552493
554945
|
import_sse2 = __nccwpck_require__(50303);
|
|
552494
|
-
|
|
554946
|
+
import_streamableHttp2 = __nccwpck_require__(1048);
|
|
552495
554947
|
import_ai5 = __nccwpck_require__(86619);
|
|
552496
554948
|
init_common();
|
|
552497
554949
|
import_types5 = __nccwpck_require__(84293);
|
|
@@ -552745,7 +555197,7 @@ var init_built_in_server = __esm({
|
|
|
552745
555197
|
console.log("[MCP] Creating new Streamable HTTP transport for initialization");
|
|
552746
555198
|
}
|
|
552747
555199
|
const eventStore = new InMemoryEventStore();
|
|
552748
|
-
transport = new
|
|
555200
|
+
transport = new import_streamableHttp2.StreamableHTTPServerTransport({
|
|
552749
555201
|
sessionIdGenerator: () => (0, import_crypto5.randomUUID)(),
|
|
552750
555202
|
eventStore,
|
|
552751
555203
|
// Enable resumability
|
|
@@ -562015,7 +564467,7 @@ var init_governed_codex_profile = __esm({
|
|
|
562015
564467
|
function governedAttestationPredicate(error40) {
|
|
562016
564468
|
return error40 instanceof TypeError ? GOVERNED_ATTESTATION_ERROR_PREDICATES.get(error40.message) ?? null : null;
|
|
562017
564469
|
}
|
|
562018
|
-
function governedAnswerFailure(stage, nativeEventFailureBoundary = null, nativeEventFailureSubreason = null, nativeEventFailureCorrelationOperand = null, nativeEventFailureAttestationPredicate = null, schemaResultValidationSubreason = null, schemaResultValidationKeyword = null) {
|
|
564470
|
+
function governedAnswerFailure(stage, nativeEventFailureBoundary = null, nativeEventFailureSubreason = null, nativeEventFailureCorrelationOperand = null, nativeEventFailureAttestationPredicate = null, schemaResultValidationSubreason = null, schemaResultValidationKeyword = null, providerEngineFailureBoundary = null) {
|
|
562019
564471
|
return new GovernedAnswerFailure(
|
|
562020
564472
|
stage,
|
|
562021
564473
|
nativeEventFailureBoundary,
|
|
@@ -562023,21 +564475,23 @@ function governedAnswerFailure(stage, nativeEventFailureBoundary = null, nativeE
|
|
|
562023
564475
|
nativeEventFailureCorrelationOperand,
|
|
562024
564476
|
nativeEventFailureAttestationPredicate,
|
|
562025
564477
|
schemaResultValidationSubreason,
|
|
562026
|
-
schemaResultValidationKeyword
|
|
564478
|
+
schemaResultValidationKeyword,
|
|
564479
|
+
providerEngineFailureBoundary
|
|
562027
564480
|
);
|
|
562028
564481
|
}
|
|
562029
|
-
function normalizeGovernedAnswerFailure(error40, fallback = "unknown", nativeEventFailureBoundary = null, nativeEventFailureSubreason = null, nativeEventFailureCorrelationOperand = null, schemaResultValidationSubreason = null, schemaResultValidationKeyword = null) {
|
|
564482
|
+
function normalizeGovernedAnswerFailure(error40, fallback = "unknown", nativeEventFailureBoundary = null, nativeEventFailureSubreason = null, nativeEventFailureCorrelationOperand = null, schemaResultValidationSubreason = null, schemaResultValidationKeyword = null, providerEngineFailureBoundary = null, nativeEventFailureAttestationPredicate = null) {
|
|
562030
564483
|
return error40 instanceof GovernedAnswerFailure ? error40 : governedAnswerFailure(
|
|
562031
564484
|
fallback,
|
|
562032
564485
|
nativeEventFailureBoundary,
|
|
562033
564486
|
nativeEventFailureSubreason,
|
|
562034
564487
|
nativeEventFailureCorrelationOperand,
|
|
562035
|
-
fallback === "native_event_grammar" && nativeEventFailureBoundary === "live_envelope_session" && nativeEventFailureSubreason === "attestation" ? governedAttestationPredicate(error40) : null,
|
|
564488
|
+
fallback === "native_event_grammar" && nativeEventFailureBoundary === "live_envelope_session" && nativeEventFailureSubreason === "attestation" ? nativeEventFailureAttestationPredicate ?? governedAttestationPredicate(error40) : null,
|
|
562036
564489
|
schemaResultValidationSubreason,
|
|
562037
|
-
schemaResultValidationKeyword
|
|
564490
|
+
schemaResultValidationKeyword,
|
|
564491
|
+
providerEngineFailureBoundary
|
|
562038
564492
|
);
|
|
562039
564493
|
}
|
|
562040
|
-
var GOVERNED_ANSWER_FAILURE_STAGES, GOVERNED_NATIVE_EVENT_FAILURE_BOUNDARIES, GOVERNED_NATIVE_EVENT_FAILURE_SUBREASONS, GOVERNED_NATIVE_EVENT_FAILURE_CORRELATION_OPERANDS, GOVERNED_NATIVE_EVENT_FAILURE_ATTESTATION_PREDICATES, GOVERNED_SCHEMA_RESULT_VALIDATION_SUBREASONS, GOVERNED_SCHEMA_RESULT_VALIDATION_KEYWORDS, GOVERNED_ATTESTATION_ERROR_PREDICATES, GovernedAnswerFailure;
|
|
564494
|
+
var GOVERNED_ANSWER_FAILURE_STAGES, GOVERNED_PROVIDER_ENGINE_FAILURE_BOUNDARIES, GOVERNED_NATIVE_EVENT_FAILURE_BOUNDARIES, GOVERNED_NATIVE_EVENT_FAILURE_SUBREASONS, GOVERNED_NATIVE_EVENT_FAILURE_CORRELATION_OPERANDS, GOVERNED_NATIVE_EVENT_FAILURE_ATTESTATION_PREDICATES, GOVERNED_SCHEMA_RESULT_VALIDATION_SUBREASONS, GOVERNED_SCHEMA_RESULT_VALIDATION_KEYWORDS, GOVERNED_ATTESTATION_ERROR_PREDICATES, GovernedAnswerFailure;
|
|
562041
564495
|
var init_governed_answer_failure = __esm({
|
|
562042
564496
|
"src/agent/engines/governed-answer-failure.js"() {
|
|
562043
564497
|
"use strict";
|
|
@@ -562045,8 +564499,10 @@ var init_governed_answer_failure = __esm({
|
|
|
562045
564499
|
"native_event_grammar",
|
|
562046
564500
|
"provider_engine",
|
|
562047
564501
|
"schema_result_validation",
|
|
564502
|
+
"internal_contract",
|
|
562048
564503
|
"unknown"
|
|
562049
564504
|
]);
|
|
564505
|
+
GOVERNED_PROVIDER_ENGINE_FAILURE_BOUNDARIES = /* @__PURE__ */ new Set(["acquire", "query", "close"]);
|
|
562050
564506
|
GOVERNED_NATIVE_EVENT_FAILURE_BOUNDARIES = /* @__PURE__ */ new Set([
|
|
562051
564507
|
"raw_item_predicate",
|
|
562052
564508
|
"live_envelope_session"
|
|
@@ -562090,7 +564546,9 @@ var init_governed_answer_failure = __esm({
|
|
|
562090
564546
|
"value_shape",
|
|
562091
564547
|
"kind",
|
|
562092
564548
|
"native_tool_evidence",
|
|
562093
|
-
"internal_contract"
|
|
564549
|
+
"internal_contract",
|
|
564550
|
+
"invocation_attestation",
|
|
564551
|
+
"native_capability_aggregate"
|
|
562094
564552
|
]);
|
|
562095
564553
|
GOVERNED_SCHEMA_RESULT_VALIDATION_SUBREASONS = /* @__PURE__ */ new Set([
|
|
562096
564554
|
"response_json",
|
|
@@ -562173,7 +564631,7 @@ var init_governed_answer_failure = __esm({
|
|
|
562173
564631
|
["Invalid profile capability overlap", "internal_contract"]
|
|
562174
564632
|
]);
|
|
562175
564633
|
GovernedAnswerFailure = class extends Error {
|
|
562176
|
-
constructor(stage, nativeEventFailureBoundary = null, nativeEventFailureSubreason = null, nativeEventFailureCorrelationOperand = null, nativeEventFailureAttestationPredicate = null, schemaResultValidationSubreason = null, schemaResultValidationKeyword = null) {
|
|
564634
|
+
constructor(stage, nativeEventFailureBoundary = null, nativeEventFailureSubreason = null, nativeEventFailureCorrelationOperand = null, nativeEventFailureAttestationPredicate = null, schemaResultValidationSubreason = null, schemaResultValidationKeyword = null, providerEngineFailureBoundary = null) {
|
|
562177
564635
|
super();
|
|
562178
564636
|
delete this.stack;
|
|
562179
564637
|
const answerFailureStage = GOVERNED_ANSWER_FAILURE_STAGES.has(stage) ? stage : "unknown";
|
|
@@ -562182,6 +564640,10 @@ var init_governed_answer_failure = __esm({
|
|
|
562182
564640
|
value: answerFailureStage,
|
|
562183
564641
|
enumerable: true
|
|
562184
564642
|
});
|
|
564643
|
+
if (answerFailureStage === "provider_engine") Object.defineProperty(this, "providerEngineFailureBoundary", {
|
|
564644
|
+
value: GOVERNED_PROVIDER_ENGINE_FAILURE_BOUNDARIES.has(providerEngineFailureBoundary) ? providerEngineFailureBoundary : null,
|
|
564645
|
+
enumerable: true
|
|
564646
|
+
});
|
|
562185
564647
|
if (answerFailureStage === "native_event_grammar") Object.defineProperty(this, "nativeEventFailureBoundary", {
|
|
562186
564648
|
value: GOVERNED_NATIVE_EVENT_FAILURE_BOUNDARIES.has(nativeEventFailureBoundary) ? nativeEventFailureBoundary : null,
|
|
562187
564649
|
enumerable: true
|
|
@@ -563192,7 +565654,9 @@ async function createCodexEngine(options = {}) {
|
|
|
563192
565654
|
}
|
|
563193
565655
|
});
|
|
563194
565656
|
if (opts.abortSignal) {
|
|
563195
|
-
if (opts.abortSignal.aborted)
|
|
565657
|
+
if (opts.abortSignal.aborted) {
|
|
565658
|
+
throw governedProfile ? governedAnswerFailure("provider_engine", null, null, null, null, null, null, "query") : new Error("Codex query cancelled");
|
|
565659
|
+
}
|
|
563196
565660
|
abortHandler = () => {
|
|
563197
565661
|
void cleanup(new Error("Codex query cancelled")).catch(() => {
|
|
563198
565662
|
});
|
|
@@ -563225,7 +565689,16 @@ async function createCodexEngine(options = {}) {
|
|
|
563225
565689
|
try {
|
|
563226
565690
|
result = await resultPromise;
|
|
563227
565691
|
} catch (error40) {
|
|
563228
|
-
throw governedProfile ?
|
|
565692
|
+
throw governedProfile ? evidenceFailure || normalizeGovernedAnswerFailure(
|
|
565693
|
+
error40,
|
|
565694
|
+
"provider_engine",
|
|
565695
|
+
null,
|
|
565696
|
+
null,
|
|
565697
|
+
null,
|
|
565698
|
+
null,
|
|
565699
|
+
null,
|
|
565700
|
+
"query"
|
|
565701
|
+
) : error40;
|
|
563229
565702
|
}
|
|
563230
565703
|
eventHandlers.delete(reqId);
|
|
563231
565704
|
governedEvidenceHandlers.delete(reqId);
|
|
@@ -563243,17 +565716,50 @@ async function createCodexEngine(options = {}) {
|
|
|
563243
565716
|
profile: governedProfile,
|
|
563244
565717
|
events: governedProfile.version === "probe.governed-codex-profile/v2" ? [collected.sessionEvent, collected.capabilities.nativeTools] : [collected.sessionEvent]
|
|
563245
565718
|
});
|
|
565719
|
+
} catch (error40) {
|
|
565720
|
+
throw normalizeGovernedAnswerFailure(
|
|
565721
|
+
error40,
|
|
565722
|
+
"native_event_grammar",
|
|
565723
|
+
"live_envelope_session",
|
|
565724
|
+
"attestation"
|
|
565725
|
+
);
|
|
565726
|
+
}
|
|
565727
|
+
try {
|
|
563246
565728
|
probeMcpCallCount = governedProfile.version === "probe.governed-codex-profile/v2" ? governedProbeMcpCallCount(mcpServer?.getGovernedCallEvidence()) : 0;
|
|
563247
565729
|
} catch (error40) {
|
|
563248
|
-
throw normalizeGovernedAnswerFailure(
|
|
563249
|
-
|
|
563250
|
-
|
|
563251
|
-
|
|
563252
|
-
|
|
563253
|
-
|
|
563254
|
-
|
|
563255
|
-
|
|
563256
|
-
|
|
565730
|
+
throw normalizeGovernedAnswerFailure(
|
|
565731
|
+
error40,
|
|
565732
|
+
"native_event_grammar",
|
|
565733
|
+
"live_envelope_session",
|
|
565734
|
+
"attestation",
|
|
565735
|
+
null,
|
|
565736
|
+
null,
|
|
565737
|
+
null,
|
|
565738
|
+
null,
|
|
565739
|
+
"native_capability_aggregate"
|
|
565740
|
+
);
|
|
565741
|
+
}
|
|
565742
|
+
try {
|
|
565743
|
+
attestation = hasInvocationDigest ? externalBoundReceipt(internal, dispatch, invocationDigest, {
|
|
565744
|
+
nativeCallCount: collected.capabilities.nativeTools.total,
|
|
565745
|
+
probeMcpCallCount
|
|
565746
|
+
}) : externalReceipt(internal, {
|
|
565747
|
+
nativeCallCount: collected.capabilities.nativeTools.total,
|
|
565748
|
+
probeMcpCallCount
|
|
565749
|
+
});
|
|
565750
|
+
} catch (error40) {
|
|
565751
|
+
throw normalizeGovernedAnswerFailure(
|
|
565752
|
+
error40,
|
|
565753
|
+
"native_event_grammar",
|
|
565754
|
+
"live_envelope_session",
|
|
565755
|
+
"attestation",
|
|
565756
|
+
null,
|
|
565757
|
+
null,
|
|
565758
|
+
null,
|
|
565759
|
+
null,
|
|
565760
|
+
"invocation_attestation"
|
|
565761
|
+
);
|
|
565762
|
+
}
|
|
563257
565763
|
session.setConversationId(collected.sessionEvent.params.msg.session_id);
|
|
563258
565764
|
}
|
|
563259
565765
|
if (result && result.content && Array.isArray(result.content)) {
|
|
@@ -563290,7 +565796,7 @@ async function createCodexEngine(options = {}) {
|
|
|
563290
565796
|
}
|
|
563291
565797
|
};
|
|
563292
565798
|
} catch (error40) {
|
|
563293
|
-
if (governedProfile) error40 = normalizeGovernedAnswerFailure(error40, "
|
|
565799
|
+
if (governedProfile) error40 = normalizeGovernedAnswerFailure(error40, "internal_contract");
|
|
563294
565800
|
queryError = error40;
|
|
563295
565801
|
if (debug) {
|
|
563296
565802
|
console.error("[DEBUG] Codex query error:", error40);
|
|
@@ -563305,7 +565811,16 @@ async function createCodexEngine(options = {}) {
|
|
|
563305
565811
|
try {
|
|
563306
565812
|
await cleanup();
|
|
563307
565813
|
} catch (cleanupError) {
|
|
563308
|
-
if (!queryError) throw
|
|
565814
|
+
if (!queryError) throw normalizeGovernedAnswerFailure(
|
|
565815
|
+
cleanupError,
|
|
565816
|
+
"provider_engine",
|
|
565817
|
+
null,
|
|
565818
|
+
null,
|
|
565819
|
+
null,
|
|
565820
|
+
null,
|
|
565821
|
+
null,
|
|
565822
|
+
"close"
|
|
565823
|
+
);
|
|
563309
565824
|
}
|
|
563310
565825
|
}
|
|
563311
565826
|
}
|
|
@@ -565392,7 +567907,6 @@ var init_ProbeAgent = __esm({
|
|
|
565392
567907
|
agent: this,
|
|
565393
567908
|
// Pass reference to ProbeAgent for tool access
|
|
565394
567909
|
systemPrompt,
|
|
565395
|
-
customPrompt: this.customPrompt,
|
|
565396
567910
|
sessionId: this.options?.sessionId,
|
|
565397
567911
|
debug: this.debug,
|
|
565398
567912
|
allowedTools: this.allowedTools,
|
|
@@ -565409,7 +567923,18 @@ var init_ProbeAgent = __esm({
|
|
|
565409
567923
|
}
|
|
565410
567924
|
return this.engine;
|
|
565411
567925
|
} catch (error40) {
|
|
565412
|
-
if (this.governedCodexProfile)
|
|
567926
|
+
if (this.governedCodexProfile) {
|
|
567927
|
+
throw normalizeGovernedAnswerFailure(
|
|
567928
|
+
error40,
|
|
567929
|
+
"provider_engine",
|
|
567930
|
+
null,
|
|
567931
|
+
null,
|
|
567932
|
+
null,
|
|
567933
|
+
null,
|
|
567934
|
+
null,
|
|
567935
|
+
"acquire"
|
|
567936
|
+
);
|
|
567937
|
+
}
|
|
565413
567938
|
console.warn("[WARNING] Failed to load Codex CLI engine:", error40.message);
|
|
565414
567939
|
console.warn("[WARNING] Falling back to Vercel AI SDK");
|
|
565415
567940
|
this.clientApiProvider = null;
|
|
@@ -566090,7 +568615,7 @@ Workspace: ${this.allowedFolders.join(", ")}`;
|
|
|
566090
568615
|
const { prompt } = this._prepareGovernedAnswerPrompt(message, options);
|
|
566091
568616
|
const systemPrompt = await this._getCachedCodexNativeSystemPrompt();
|
|
566092
568617
|
const { previewGovernedCodexInitialDispatch: previewGovernedCodexInitialDispatch2 } = await Promise.resolve().then(() => (init_codex(), codex_exports));
|
|
566093
|
-
return previewGovernedCodexInitialDispatch2({ systemPrompt,
|
|
568618
|
+
return previewGovernedCodexInitialDispatch2({ systemPrompt, prompt });
|
|
566094
568619
|
}
|
|
566095
568620
|
/**
|
|
566096
568621
|
* Get the system message with instructions for the AI (XML Tool Format)
|
|
@@ -566280,38 +568805,99 @@ You are working with a workspace. Available paths: ${workspaceDesc}
|
|
|
566280
568805
|
try {
|
|
566281
568806
|
try {
|
|
566282
568807
|
engine = await this.getEngine();
|
|
566283
|
-
} catch {
|
|
566284
|
-
throw
|
|
568808
|
+
} catch (error40) {
|
|
568809
|
+
throw normalizeGovernedAnswerFailure(
|
|
568810
|
+
error40,
|
|
568811
|
+
"provider_engine",
|
|
568812
|
+
null,
|
|
568813
|
+
null,
|
|
568814
|
+
null,
|
|
568815
|
+
null,
|
|
568816
|
+
null,
|
|
568817
|
+
"acquire"
|
|
568818
|
+
);
|
|
566285
568819
|
}
|
|
566286
|
-
if (!engine?.query) throw governedAnswerFailure("
|
|
568820
|
+
if (!engine?.query) throw governedAnswerFailure("internal_contract");
|
|
566287
568821
|
const candidateChunks = [];
|
|
566288
568822
|
let runtimeAttestation;
|
|
566289
568823
|
let attestationCount = 0;
|
|
566290
568824
|
let nativeToolBatch;
|
|
566291
568825
|
let nativeToolBatchCount = 0;
|
|
566292
568826
|
const queryOptions = hasInvocationDigest ? { abortSignal: this._abortController.signal, invocationDigest } : { abortSignal: this._abortController.signal };
|
|
566293
|
-
|
|
566294
|
-
|
|
566295
|
-
|
|
566296
|
-
|
|
566297
|
-
|
|
566298
|
-
|
|
566299
|
-
|
|
566300
|
-
|
|
566301
|
-
|
|
568827
|
+
try {
|
|
568828
|
+
for await (const chunk of engine.query(prompt, queryOptions)) {
|
|
568829
|
+
if (chunk.type === "text" && chunk.content) candidateChunks.push(chunk.content);
|
|
568830
|
+
else if (chunk.type === "metadata" && chunk.data?.attestation) {
|
|
568831
|
+
runtimeAttestation = chunk.data.attestation;
|
|
568832
|
+
attestationCount++;
|
|
568833
|
+
} else if (chunk.type === "toolBatch") {
|
|
568834
|
+
nativeToolBatch = chunk;
|
|
568835
|
+
nativeToolBatchCount++;
|
|
568836
|
+
} else if (chunk.type === "error") {
|
|
568837
|
+
throw normalizeGovernedAnswerFailure(
|
|
568838
|
+
chunk.error,
|
|
568839
|
+
"provider_engine",
|
|
568840
|
+
null,
|
|
568841
|
+
null,
|
|
568842
|
+
null,
|
|
568843
|
+
null,
|
|
568844
|
+
null,
|
|
568845
|
+
"query"
|
|
568846
|
+
);
|
|
568847
|
+
}
|
|
568848
|
+
}
|
|
568849
|
+
} catch (error40) {
|
|
568850
|
+
throw normalizeGovernedAnswerFailure(
|
|
568851
|
+
error40,
|
|
568852
|
+
"provider_engine",
|
|
568853
|
+
null,
|
|
568854
|
+
null,
|
|
568855
|
+
null,
|
|
568856
|
+
null,
|
|
568857
|
+
null,
|
|
568858
|
+
"query"
|
|
568859
|
+
);
|
|
566302
568860
|
}
|
|
566303
568861
|
if (hasInvocationDigest) {
|
|
566304
568862
|
const expectedAttestation = this.governedCodexProfile?.version === "probe.governed-codex-profile/v2" ? "probe.governed-codex-attestation/v3" : "probe.governed-codex-attestation/v2";
|
|
566305
568863
|
if (attestationCount !== 1 || runtimeAttestation?.version !== expectedAttestation || runtimeAttestation?.executionContext?.source !== "caller" || runtimeAttestation?.executionContext?.invocationDigest !== invocationDigest) {
|
|
566306
|
-
throw
|
|
568864
|
+
throw governedAnswerFailure(
|
|
568865
|
+
"native_event_grammar",
|
|
568866
|
+
"live_envelope_session",
|
|
568867
|
+
"attestation",
|
|
568868
|
+
null,
|
|
568869
|
+
"invocation_attestation"
|
|
568870
|
+
);
|
|
566307
568871
|
}
|
|
566308
|
-
} else if (attestationCount !== 1)
|
|
568872
|
+
} else if (attestationCount !== 1) {
|
|
568873
|
+
throw governedAnswerFailure(
|
|
568874
|
+
"native_event_grammar",
|
|
568875
|
+
"live_envelope_session",
|
|
568876
|
+
"attestation",
|
|
568877
|
+
null,
|
|
568878
|
+
"invocation_attestation"
|
|
568879
|
+
);
|
|
568880
|
+
}
|
|
566309
568881
|
if (this.governedCodexProfile?.version === "probe.governed-codex-profile/v2") {
|
|
566310
568882
|
if (nativeToolBatchCount !== 1 || !Number.isSafeInteger(nativeToolBatch?.total) || !Array.isArray(nativeToolBatch?.tools) || nativeToolBatch.total !== runtimeAttestation?.observed?.nativeTools?.total || JSON.stringify(nativeToolBatch.tools) !== JSON.stringify(runtimeAttestation?.observed?.nativeTools?.tools)) {
|
|
566311
|
-
throw
|
|
568883
|
+
throw governedAnswerFailure(
|
|
568884
|
+
"native_event_grammar",
|
|
568885
|
+
"live_envelope_session",
|
|
568886
|
+
"attestation",
|
|
568887
|
+
null,
|
|
568888
|
+
"native_capability_aggregate"
|
|
568889
|
+
);
|
|
566312
568890
|
}
|
|
566313
568891
|
for (const toolEvent of nativeToolBatch.tools) this.events.emit("toolCall", toolEvent);
|
|
566314
|
-
} else if (nativeToolBatchCount !== 0)
|
|
568892
|
+
} else if (nativeToolBatchCount !== 0) {
|
|
568893
|
+
throw governedAnswerFailure(
|
|
568894
|
+
"native_event_grammar",
|
|
568895
|
+
"live_envelope_session",
|
|
568896
|
+
"attestation",
|
|
568897
|
+
null,
|
|
568898
|
+
"native_capability_aggregate"
|
|
568899
|
+
);
|
|
568900
|
+
}
|
|
566315
568901
|
const validation = validateJsonResponse(candidateChunks.join(""), { debug: this.debug, schema });
|
|
566316
568902
|
if (!validation.isValid) throw governedSchemaResultValidationFailure(validation);
|
|
566317
568903
|
if (hasResultIdentity) {
|
|
@@ -566327,14 +568913,23 @@ You are working with a workspace. Available paths: ${workspaceDesc}
|
|
|
566327
568913
|
}
|
|
566328
568914
|
return { data: validation.parsed, runtimeAttestation };
|
|
566329
568915
|
} catch (error40) {
|
|
566330
|
-
answerFailure = normalizeGovernedAnswerFailure(error40, "
|
|
568916
|
+
answerFailure = normalizeGovernedAnswerFailure(error40, "internal_contract");
|
|
566331
568917
|
throw answerFailure;
|
|
566332
568918
|
} finally {
|
|
566333
568919
|
if (engine) {
|
|
566334
568920
|
try {
|
|
566335
568921
|
await engine.close();
|
|
566336
|
-
} catch {
|
|
566337
|
-
if (!answerFailure) throw
|
|
568922
|
+
} catch (error40) {
|
|
568923
|
+
if (!answerFailure) throw normalizeGovernedAnswerFailure(
|
|
568924
|
+
error40,
|
|
568925
|
+
"provider_engine",
|
|
568926
|
+
null,
|
|
568927
|
+
null,
|
|
568928
|
+
null,
|
|
568929
|
+
null,
|
|
568930
|
+
null,
|
|
568931
|
+
"close"
|
|
568932
|
+
);
|
|
566338
568933
|
}
|
|
566339
568934
|
}
|
|
566340
568935
|
}
|
|
@@ -598023,49 +600618,131 @@ class ParseError extends Error {
|
|
|
598023
600618
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
598024
600619
|
}
|
|
598025
600620
|
}
|
|
600621
|
+
const LF = 10, CR = 13, SPACE = 32;
|
|
598026
600622
|
function noop(_arg) {
|
|
598027
600623
|
}
|
|
598028
|
-
function createParser(
|
|
598029
|
-
if (typeof
|
|
600624
|
+
function createParser(config) {
|
|
600625
|
+
if (typeof config == "function")
|
|
598030
600626
|
throw new TypeError(
|
|
598031
|
-
"`
|
|
600627
|
+
"`config` must be an object, got a function instead. Did you mean `createParser({onEvent: fn})`?"
|
|
598032
600628
|
);
|
|
598033
|
-
const { onEvent = noop, onError = noop, onRetry = noop, onComment } =
|
|
598034
|
-
let
|
|
598035
|
-
function feed(
|
|
598036
|
-
|
|
598037
|
-
|
|
598038
|
-
|
|
598039
|
-
|
|
598040
|
-
|
|
598041
|
-
|
|
598042
|
-
|
|
600629
|
+
const { onEvent = noop, onError = noop, onRetry = noop, onComment, maxBufferSize } = config, pendingFragments = [];
|
|
600630
|
+
let pendingFragmentsLength = 0, isFirstChunk = !0, id, data = "", dataLines = 0, eventType, terminated = !1;
|
|
600631
|
+
function feed(chunk) {
|
|
600632
|
+
if (terminated)
|
|
600633
|
+
throw new Error(
|
|
600634
|
+
"Cannot feed parser: it was terminated after exceeding the configured max buffer size. Call `reset()` to resume parsing."
|
|
600635
|
+
);
|
|
600636
|
+
if (isFirstChunk && (isFirstChunk = !1, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
600637
|
+
const trailing2 = processLines(chunk);
|
|
600638
|
+
trailing2 !== "" && (pendingFragments.push(trailing2), pendingFragmentsLength = trailing2.length), checkBufferSize();
|
|
600639
|
+
return;
|
|
600640
|
+
}
|
|
600641
|
+
if (chunk.indexOf(`
|
|
600642
|
+
`) === -1 && chunk.indexOf("\r") === -1) {
|
|
600643
|
+
pendingFragments.push(chunk), pendingFragmentsLength += chunk.length, checkBufferSize();
|
|
600644
|
+
return;
|
|
600645
|
+
}
|
|
600646
|
+
pendingFragments.push(chunk);
|
|
600647
|
+
const input = pendingFragments.join("");
|
|
600648
|
+
pendingFragments.length = 0, pendingFragmentsLength = 0;
|
|
600649
|
+
const trailing = processLines(input);
|
|
600650
|
+
trailing !== "" && (pendingFragments.push(trailing), pendingFragmentsLength = trailing.length), checkBufferSize();
|
|
600651
|
+
}
|
|
600652
|
+
function checkBufferSize() {
|
|
600653
|
+
maxBufferSize !== void 0 && (pendingFragmentsLength + data.length <= maxBufferSize || (terminated = !0, pendingFragments.length = 0, pendingFragmentsLength = 0, id = void 0, data = "", dataLines = 0, eventType = void 0, onError(
|
|
600654
|
+
new ParseError(`Buffered data exceeded max buffer size of ${maxBufferSize} characters`, {
|
|
600655
|
+
type: "max-buffer-size-exceeded"
|
|
600656
|
+
})
|
|
600657
|
+
)));
|
|
600658
|
+
}
|
|
600659
|
+
function processLines(chunk) {
|
|
600660
|
+
let searchIndex = 0;
|
|
600661
|
+
if (chunk.indexOf("\r") === -1) {
|
|
600662
|
+
let lfIndex = chunk.indexOf(`
|
|
600663
|
+
`, searchIndex);
|
|
600664
|
+
for (; lfIndex !== -1; ) {
|
|
600665
|
+
if (searchIndex === lfIndex) {
|
|
600666
|
+
dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
600667
|
+
`, searchIndex);
|
|
600668
|
+
continue;
|
|
600669
|
+
}
|
|
600670
|
+
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
600671
|
+
if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
|
|
600672
|
+
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
600673
|
+
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
|
|
600674
|
+
onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
600675
|
+
`, searchIndex);
|
|
600676
|
+
continue;
|
|
600677
|
+
}
|
|
600678
|
+
data = dataLines === 0 ? value : `${data}
|
|
600679
|
+
${value}`, dataLines++;
|
|
600680
|
+
} else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
|
|
600681
|
+
chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
|
|
600682
|
+
lfIndex
|
|
600683
|
+
) || void 0 : parseLine(chunk, searchIndex, lfIndex);
|
|
600684
|
+
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
600685
|
+
`, searchIndex);
|
|
600686
|
+
}
|
|
600687
|
+
return chunk.slice(searchIndex);
|
|
600688
|
+
}
|
|
600689
|
+
for (; searchIndex < chunk.length; ) {
|
|
600690
|
+
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
600691
|
+
`, searchIndex);
|
|
600692
|
+
let lineEnd = -1;
|
|
600693
|
+
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)
|
|
600694
|
+
break;
|
|
600695
|
+
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
|
|
600696
|
+
}
|
|
600697
|
+
return chunk.slice(searchIndex);
|
|
600698
|
+
}
|
|
600699
|
+
function parseLine(chunk, start, end) {
|
|
600700
|
+
if (start === end) {
|
|
598043
600701
|
dispatchEvent();
|
|
598044
600702
|
return;
|
|
598045
600703
|
}
|
|
598046
|
-
|
|
598047
|
-
|
|
600704
|
+
const firstCharCode = chunk.charCodeAt(start);
|
|
600705
|
+
if (isDataPrefix(chunk, start, firstCharCode)) {
|
|
600706
|
+
const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
|
|
600707
|
+
data = dataLines === 0 ? value2 : `${data}
|
|
600708
|
+
${value2}`, dataLines++;
|
|
600709
|
+
return;
|
|
600710
|
+
}
|
|
600711
|
+
if (isEventPrefix(chunk, start, firstCharCode)) {
|
|
600712
|
+
eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
|
|
598048
600713
|
return;
|
|
598049
600714
|
}
|
|
598050
|
-
|
|
598051
|
-
|
|
598052
|
-
|
|
598053
|
-
processField(field, value, line);
|
|
600715
|
+
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
600716
|
+
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
|
|
600717
|
+
value2.includes("\0") || (id = value2);
|
|
598054
600718
|
return;
|
|
598055
600719
|
}
|
|
598056
|
-
|
|
600720
|
+
if (firstCharCode === 58) {
|
|
600721
|
+
if (onComment) {
|
|
600722
|
+
const line2 = chunk.slice(start, end);
|
|
600723
|
+
onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
|
|
600724
|
+
}
|
|
600725
|
+
return;
|
|
600726
|
+
}
|
|
600727
|
+
const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
|
|
600728
|
+
if (fieldSeparatorIndex === -1) {
|
|
600729
|
+
processField(line, "", line);
|
|
600730
|
+
return;
|
|
600731
|
+
}
|
|
600732
|
+
const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
600733
|
+
processField(field, value, line);
|
|
598057
600734
|
}
|
|
598058
600735
|
function processField(field, value, line) {
|
|
598059
600736
|
switch (field) {
|
|
598060
600737
|
case "event":
|
|
598061
|
-
eventType = value;
|
|
600738
|
+
eventType = value || void 0;
|
|
598062
600739
|
break;
|
|
598063
600740
|
case "data":
|
|
598064
|
-
data = `${data}
|
|
598065
|
-
|
|
600741
|
+
data = dataLines === 0 ? value : `${data}
|
|
600742
|
+
${value}`, dataLines++;
|
|
598066
600743
|
break;
|
|
598067
600744
|
case "id":
|
|
598068
|
-
|
|
600745
|
+
value.includes("\0") || (id = value);
|
|
598069
600746
|
break;
|
|
598070
600747
|
case "retry":
|
|
598071
600748
|
/^\d+$/.test(value) ? onRetry(parseInt(value, 10)) : onError(
|
|
@@ -598087,37 +600764,26 @@ function createParser(callbacks) {
|
|
|
598087
600764
|
}
|
|
598088
600765
|
}
|
|
598089
600766
|
function dispatchEvent() {
|
|
598090
|
-
|
|
600767
|
+
dataLines > 0 && onEvent({
|
|
598091
600768
|
id,
|
|
598092
|
-
event: eventType
|
|
598093
|
-
|
|
598094
|
-
|
|
598095
|
-
data: data.endsWith(`
|
|
598096
|
-
`) ? data.slice(0, -1) : data
|
|
598097
|
-
}), id = void 0, data = "", eventType = "";
|
|
600769
|
+
event: eventType,
|
|
600770
|
+
data
|
|
600771
|
+
}), id = void 0, data = "", dataLines = 0, eventType = void 0;
|
|
598098
600772
|
}
|
|
598099
600773
|
function reset(options = {}) {
|
|
598100
|
-
|
|
600774
|
+
if (options.consume && pendingFragments.length > 0) {
|
|
600775
|
+
const incompleteLine = pendingFragments.join("");
|
|
600776
|
+
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
600777
|
+
}
|
|
600778
|
+
isFirstChunk = !0, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0, pendingFragmentsLength = 0, terminated = !1;
|
|
598101
600779
|
}
|
|
598102
600780
|
return { feed, reset };
|
|
598103
600781
|
}
|
|
598104
|
-
function
|
|
598105
|
-
|
|
598106
|
-
|
|
598107
|
-
|
|
598108
|
-
|
|
598109
|
-
`, searchIndex);
|
|
598110
|
-
let lineEnd = -1;
|
|
598111
|
-
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) {
|
|
598112
|
-
incompleteLine = chunk.slice(searchIndex);
|
|
598113
|
-
break;
|
|
598114
|
-
} else {
|
|
598115
|
-
const line = chunk.slice(searchIndex, lineEnd);
|
|
598116
|
-
lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
|
|
598117
|
-
` && searchIndex++;
|
|
598118
|
-
}
|
|
598119
|
-
}
|
|
598120
|
-
return [lines, incompleteLine];
|
|
600782
|
+
function isDataPrefix(chunk, i, firstCharCode) {
|
|
600783
|
+
return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
|
|
600784
|
+
}
|
|
600785
|
+
function isEventPrefix(chunk, i, firstCharCode) {
|
|
600786
|
+
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;
|
|
598121
600787
|
}
|
|
598122
600788
|
exports.ParseError = ParseError;
|
|
598123
600789
|
exports.createParser = createParser;
|
|
@@ -598134,7 +600800,7 @@ exports.createParser = createParser;
|
|
|
598134
600800
|
Object.defineProperty(exports, "__esModule", ({ value: !0 }));
|
|
598135
600801
|
var index = __nccwpck_require__(39107);
|
|
598136
600802
|
class EventSourceParserStream extends TransformStream {
|
|
598137
|
-
constructor({ onError, onRetry, onComment } = {}) {
|
|
600803
|
+
constructor({ onError, onRetry, onComment, maxBufferSize } = {}) {
|
|
598138
600804
|
let parser;
|
|
598139
600805
|
super({
|
|
598140
600806
|
start(controller) {
|
|
@@ -598143,10 +600809,11 @@ class EventSourceParserStream extends TransformStream {
|
|
|
598143
600809
|
controller.enqueue(event);
|
|
598144
600810
|
},
|
|
598145
600811
|
onError(error) {
|
|
598146
|
-
onError
|
|
600812
|
+
typeof onError == "function" && onError(error), (onError === "terminate" || error.type === "max-buffer-size-exceeded") && controller.error(error);
|
|
598147
600813
|
},
|
|
598148
600814
|
onRetry,
|
|
598149
|
-
onComment
|
|
600815
|
+
onComment,
|
|
600816
|
+
maxBufferSize
|
|
598150
600817
|
});
|
|
598151
600818
|
},
|
|
598152
600819
|
transform(chunk) {
|
|
@@ -637347,7 +640014,7 @@ module.exports = /*#__PURE__*/JSON.parse('["aaa","aarp","abb","abbott","abbvie",
|
|
|
637347
640014
|
/***/ ((module) => {
|
|
637348
640015
|
|
|
637349
640016
|
"use strict";
|
|
637350
|
-
module.exports = /*#__PURE__*/JSON.parse('{"name":"@probelabs/visor","version":"0.1.42","main":"dist/index.js","bin":{"visor":"./dist/index.js"},"exports":{".":{"require":"./dist/index.js","import":"./dist/index.js"},"./sdk":{"types":"./dist/sdk/sdk.d.ts","import":"./dist/sdk/sdk.mjs","require":"./dist/sdk/sdk.js"},"./cli":{"require":"./dist/index.js"}},"files":["dist/","defaults/","action.yml","README.md","LICENSE"],"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"scripts":{"build:cli":"ncc build src/index.ts -o dist && cp -r defaults dist/ && cp -r output dist/ && cp -r docs dist/ && cp -r examples dist/ && cp -r src/debug-visualizer/ui dist/debug-visualizer/ && node scripts/inject-version.js && echo \'#!/usr/bin/env node\' | cat - dist/index.js > temp && mv temp dist/index.js && chmod +x dist/index.js","build:sdk":"tsup src/sdk.ts --dts --sourcemap --format esm,cjs --out-dir dist/sdk","build":"npm run build:oss","build:oss":"./scripts/build-oss.sh","build:ee":"npm run build:cli && npm run build:sdk","test":"jest && npm run test:yaml","test:unit":"jest","prepublishOnly":"npm run build","test:watch":"jest --watch","test:coverage":"jest --coverage","test:ee":"jest --testPathPatterns=\'tests/ee\' --testPathIgnorePatterns=\'/node_modules/\' --no-coverage","test:manual:bash":"RUN_MANUAL_TESTS=true jest tests/manual/bash-config-manual.test.ts","lint":"eslint src tests --ext .ts","lint:fix":"eslint src tests --ext .ts --fix","format":"prettier --write src tests","format:check":"prettier --check src tests","clean":"","clean:traces":"node scripts/clean-traces.js","prebuild":"npm run clean && node scripts/generate-config-schema.js","pretest":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","pretest:unit":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","test:with-build":"npm run build:cli && jest","test:yaml":"node dist/index.js test --progress compact","test:yaml:parallel":"node dist/index.js test --progress compact --max-parallel 4","prepare":"husky","pre-commit":"lint-staged","deploy:site":"cd site && npx wrangler pages deploy . --project-name=visor-site --commit-dirty=true","deploy:worker":"npx wrangler deploy","deploy":"npm run deploy:site && npm run deploy:worker","publish:ee":"./scripts/publish-ee.sh","release":"./scripts/release.sh","release:patch":"./scripts/release.sh patch","release:minor":"./scripts/release.sh minor","release:major":"./scripts/release.sh major","release:prerelease":"./scripts/release.sh prerelease","docs:validate":"node scripts/validate-readme-links.js","workshop:setup":"npm install -D reveal-md@6.1.2","workshop:serve":"cd workshop && reveal-md slides.md -w","workshop:export":"reveal-md workshop/slides.md --static workshop/build","workshop:pdf":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter","workshop:pdf:ci":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter --puppeteer-launch-args=\\"--no-sandbox --disable-dev-shm-usage\\"","workshop:pdf:a4":"reveal-md workshop/slides.md --print workshop/Visor-Workshop-A4.pdf --print-size A4","workshop:build":"npm run workshop:export && npm run workshop:pdf","simulate:issue":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issues --action opened --debug","simulate:comment":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issue_comment --action created --debug"},"keywords":["code-review","ai","github-action","cli","pr-review","visor"],"author":"Probe Labs","license":"MIT","description":"AI workflow engine for code review, assistants, and automation — orchestrate checks, MCP tools, and AI providers with YAML-driven pipelines","repository":{"type":"git","url":"git+https://github.com/probelabs/visor.git"},"bugs":{"url":"https://github.com/probelabs/visor/issues"},"homepage":"https://github.com/probelabs/visor#readme","dependencies":{"@actions/core":"^1.11.1","@apidevtools/swagger-parser":"^12.1.0","@grammyjs/runner":"^2.0.3","@modelcontextprotocol/sdk":"^1.25.3","@nyariv/sandboxjs":"github:probelabs/SandboxJS#d0d8c8ab3113d3b73e08b79b88a4b834ba3fae11","@octokit/action":"^8.0.2","@octokit/auth-app":"^8.1.0","@octokit/core":"^7.0.3","@octokit/rest":"^22.0.0","@opentelemetry/api":"^1.9.0","@opentelemetry/api-logs":"^0.203.0","@opentelemetry/core":"^1.30.1","@opentelemetry/exporter-logs-otlp-http":"^0.203.0","@opentelemetry/exporter-metrics-otlp-http":"^0.203.0","@opentelemetry/exporter-trace-otlp-grpc":"^0.203.0","@opentelemetry/exporter-trace-otlp-http":"^0.203.0","@opentelemetry/instrumentation":"^0.203.0","@opentelemetry/resources":"^1.30.1","@opentelemetry/sdk-logs":"^0.203.0","@opentelemetry/sdk-metrics":"^1.30.1","@opentelemetry/sdk-node":"^0.203.0","@opentelemetry/sdk-trace-base":"^1.30.1","@opentelemetry/semantic-conventions":"^1.30.1","@probelabs/probe":"^0.6.0-
|
|
640017
|
+
module.exports = /*#__PURE__*/JSON.parse('{"name":"@probelabs/visor","version":"0.1.42","main":"dist/index.js","bin":{"visor":"./dist/index.js"},"exports":{".":{"require":"./dist/index.js","import":"./dist/index.js"},"./sdk":{"types":"./dist/sdk/sdk.d.ts","import":"./dist/sdk/sdk.mjs","require":"./dist/sdk/sdk.js"},"./cli":{"require":"./dist/index.js"}},"files":["dist/","defaults/","action.yml","README.md","LICENSE"],"publishConfig":{"access":"public","registry":"https://registry.npmjs.org/"},"scripts":{"build:cli":"ncc build src/index.ts -o dist && cp -r defaults dist/ && cp -r output dist/ && cp -r docs dist/ && cp -r examples dist/ && cp -r src/debug-visualizer/ui dist/debug-visualizer/ && node scripts/inject-version.js && echo \'#!/usr/bin/env node\' | cat - dist/index.js > temp && mv temp dist/index.js && chmod +x dist/index.js","build:sdk":"tsup src/sdk.ts --dts --sourcemap --format esm,cjs --out-dir dist/sdk","build":"npm run build:oss","build:oss":"./scripts/build-oss.sh","build:ee":"npm run build:cli && npm run build:sdk","test":"jest && npm run test:yaml","test:unit":"jest","prepublishOnly":"npm run build","test:watch":"jest --watch","test:coverage":"jest --coverage","test:ee":"jest --testPathPatterns=\'tests/ee\' --testPathIgnorePatterns=\'/node_modules/\' --no-coverage","test:manual:bash":"RUN_MANUAL_TESTS=true jest tests/manual/bash-config-manual.test.ts","lint":"eslint src tests --ext .ts","lint:fix":"eslint src tests --ext .ts --fix","format":"prettier --write src tests","format:check":"prettier --check src tests","clean":"","clean:traces":"node scripts/clean-traces.js","prebuild":"npm run clean && node scripts/generate-config-schema.js","pretest":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","pretest:unit":"npm run clean:traces && node scripts/generate-config-schema.js && npm run build:cli","test:with-build":"npm run build:cli && jest","test:yaml":"node dist/index.js test --progress compact","test:yaml:parallel":"node dist/index.js test --progress compact --max-parallel 4","prepare":"husky","pre-commit":"lint-staged","deploy:site":"cd site && npx wrangler pages deploy . --project-name=visor-site --commit-dirty=true","deploy:worker":"npx wrangler deploy","deploy":"npm run deploy:site && npm run deploy:worker","publish:ee":"./scripts/publish-ee.sh","release":"./scripts/release.sh","release:patch":"./scripts/release.sh patch","release:minor":"./scripts/release.sh minor","release:major":"./scripts/release.sh major","release:prerelease":"./scripts/release.sh prerelease","docs:validate":"node scripts/validate-readme-links.js","workshop:setup":"npm install -D reveal-md@6.1.2","workshop:serve":"cd workshop && reveal-md slides.md -w","workshop:export":"reveal-md workshop/slides.md --static workshop/build","workshop:pdf":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter","workshop:pdf:ci":"reveal-md workshop/slides.md --print workshop/Visor-Workshop.pdf --print-size letter --puppeteer-launch-args=\\"--no-sandbox --disable-dev-shm-usage\\"","workshop:pdf:a4":"reveal-md workshop/slides.md --print workshop/Visor-Workshop-A4.pdf --print-size A4","workshop:build":"npm run workshop:export && npm run workshop:pdf","simulate:issue":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issues --action opened --debug","simulate:comment":"TS_NODE_TRANSPILE_ONLY=1 ts-node scripts/simulate-gh-run.ts --event issue_comment --action created --debug"},"keywords":["code-review","ai","github-action","cli","pr-review","visor"],"author":"Probe Labs","license":"MIT","description":"AI workflow engine for code review, assistants, and automation — orchestrate checks, MCP tools, and AI providers with YAML-driven pipelines","repository":{"type":"git","url":"git+https://github.com/probelabs/visor.git"},"bugs":{"url":"https://github.com/probelabs/visor/issues"},"homepage":"https://github.com/probelabs/visor#readme","dependencies":{"@actions/core":"^1.11.1","@apidevtools/swagger-parser":"^12.1.0","@grammyjs/runner":"^2.0.3","@modelcontextprotocol/sdk":"^1.25.3","@nyariv/sandboxjs":"github:probelabs/SandboxJS#d0d8c8ab3113d3b73e08b79b88a4b834ba3fae11","@octokit/action":"^8.0.2","@octokit/auth-app":"^8.1.0","@octokit/core":"^7.0.3","@octokit/rest":"^22.0.0","@opentelemetry/api":"^1.9.0","@opentelemetry/api-logs":"^0.203.0","@opentelemetry/core":"^1.30.1","@opentelemetry/exporter-logs-otlp-http":"^0.203.0","@opentelemetry/exporter-metrics-otlp-http":"^0.203.0","@opentelemetry/exporter-trace-otlp-grpc":"^0.203.0","@opentelemetry/exporter-trace-otlp-http":"^0.203.0","@opentelemetry/instrumentation":"^0.203.0","@opentelemetry/resources":"^1.30.1","@opentelemetry/sdk-logs":"^0.203.0","@opentelemetry/sdk-metrics":"^1.30.1","@opentelemetry/sdk-node":"^0.203.0","@opentelemetry/sdk-trace-base":"^1.30.1","@opentelemetry/semantic-conventions":"^1.30.1","@probelabs/probe":"^0.6.0-rc339","@types/commander":"^2.12.0","@types/uuid":"^10.0.0","@utcp/file":"^1.1.0","@utcp/http":"^1.1.0","@utcp/sdk":"^1.1.0","@utcp/text":"^1.1.0","acorn":"^8.16.0","acorn-walk":"^8.3.5","ajv":"^8.17.1","ajv-formats":"^3.0.1","better-sqlite3":"^11.0.0","blessed":"^0.1.81","botbuilder":"^4.23.3","botframework-connector":"^4.23.3","cli-table3":"^0.6.5","commander":"^14.0.0","deepmerge":"^4.3.1","dotenv":"^17.2.3","grammy":"^1.41.1","ignore":"^7.0.5","imapflow":"^1.2.12","js-yaml":"^4.1.0","jsonpath-plus":"^10.4.0","liquidjs":"^10.21.1","mailparser":"^3.9.3","minimatch":"^10.2.2","node-cron":"^3.0.3","nodemailer":"^8.0.1","open":"^9.1.0","resend":"^6.9.3","simple-git":"^3.28.0","uuid":"^11.1.0","ws":"^8.18.3"},"optionalDependencies":{"@anthropic/claude-code-sdk":"npm:null@*","@open-policy-agent/opa-wasm":"^1.10.0","knex":"^3.1.0","mysql2":"^3.11.0","pg":"^8.13.0","tedious":"^19.0.0"},"devDependencies":{"@eslint/js":"^9.34.0","@kie/act-js":"^2.6.2","@kie/mock-github":"^2.0.1","@swc/core":"^1.13.2","@swc/jest":"^0.2.37","@types/better-sqlite3":"^7.6.0","@types/blessed":"^0.1.27","@types/jest":"^30.0.0","@types/js-yaml":"^4.0.9","@types/mailparser":"^3.4.6","@types/node":"^24.3.0","@types/node-cron":"^3.0.11","@types/nodemailer":"^7.0.11","@types/ws":"^8.18.1","@typescript-eslint/eslint-plugin":"^8.42.0","@typescript-eslint/parser":"^8.42.0","@vercel/ncc":"^0.38.4","eslint":"^9.34.0","eslint-config-prettier":"^10.1.8","eslint-plugin-prettier":"^5.5.4","husky":"^9.1.7","jest":"^30.1.3","lint-staged":"^16.1.6","prettier":"^3.6.2","reveal-md":"^6.1.2","ts-json-schema-generator":"^1.5.1","ts-node":"^10.9.2","tsup":"^8.5.0","typescript":"^5.9.2","wrangler":"^3.0.0"},"peerDependenciesMeta":{"@anthropic/claude-code-sdk":{"optional":true}},"directories":{"test":"tests"},"lint-staged":{"src/**/*.{ts,js}":["eslint --fix","prettier --write"],"tests/**/*.{ts,js}":["eslint --fix","prettier --write"],"*.{json,md,yml,yaml}":["prettier --write"]}}');
|
|
637351
640018
|
|
|
637352
640019
|
/***/ })
|
|
637353
640020
|
|