@mastra/memory 1.17.0 → 1.17.1
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/CHANGELOG.md +18 -0
- package/dist/{chunk-MPBMHIAQ.js → chunk-7742VTN5.js} +100 -44
- package/dist/chunk-7742VTN5.js.map +1 -0
- package/dist/{chunk-5MTY2UYL.cjs → chunk-J2XQSPAB.cjs} +100 -44
- package/dist/chunk-J2XQSPAB.cjs.map +1 -0
- package/dist/{constants-HXOCZPB7.cjs → constants-PJXB7ZIS.cjs} +2 -2
- package/dist/{constants-HXOCZPB7.cjs.map → constants-PJXB7ZIS.cjs.map} +1 -1
- package/dist/{constants-BDOITAO3.js → constants-XEHPYRDJ.js} +2 -2
- package/dist/{constants-BDOITAO3.js.map → constants-XEHPYRDJ.js.map} +1 -1
- package/dist/docs/SKILL.md +1 -1
- package/dist/docs/assets/SOURCE_MAP.json +39 -39
- package/dist/docs/references/docs-memory-working-memory.md +1 -1
- package/dist/index.cjs +785 -384
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +776 -375
- package/dist/index.js.map +1 -1
- package/dist/{observational-memory-UCFGVLVW.cjs → observational-memory-ISRI7QGE.cjs} +26 -26
- package/dist/{observational-memory-UCFGVLVW.cjs.map → observational-memory-ISRI7QGE.cjs.map} +1 -1
- package/dist/{observational-memory-7YYZIIX4.js → observational-memory-YYO73QMY.js} +3 -3
- package/dist/{observational-memory-7YYZIIX4.js.map → observational-memory-YYO73QMY.js.map} +1 -1
- package/dist/processors/index.cjs +24 -24
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/observation-strategies/async-buffer.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-strategies/base.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-turn/step.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-turn/turn.d.ts +3 -2
- package/dist/processors/observational-memory/observation-turn/turn.d.ts.map +1 -1
- package/dist/processors/observational-memory/observation-turn/types.d.ts +1 -0
- package/dist/processors/observational-memory/observation-turn/types.d.ts.map +1 -1
- package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
- package/dist/processors/observational-memory/processor.d.ts.map +1 -1
- package/dist/processors/observational-memory/reflector-runner.d.ts +1 -0
- package/dist/processors/observational-memory/reflector-runner.d.ts.map +1 -1
- package/package.json +10 -10
- package/dist/chunk-3PUO6DLX.js +0 -439
- package/dist/chunk-3PUO6DLX.js.map +0 -1
- package/dist/chunk-5MTY2UYL.cjs.map +0 -1
- package/dist/chunk-CK4U3AYR.cjs +0 -84
- package/dist/chunk-CK4U3AYR.cjs.map +0 -1
- package/dist/chunk-DAJJSFVA.cjs +0 -441
- package/dist/chunk-DAJJSFVA.cjs.map +0 -1
- package/dist/chunk-DGUM43GV.js +0 -10
- package/dist/chunk-DGUM43GV.js.map +0 -1
- package/dist/chunk-EQ4M72KU.js +0 -439
- package/dist/chunk-EQ4M72KU.js.map +0 -1
- package/dist/chunk-IDRQZVB4.cjs +0 -84
- package/dist/chunk-IDRQZVB4.cjs.map +0 -1
- package/dist/chunk-JEQ2X3Z6.cjs +0 -12
- package/dist/chunk-JEQ2X3Z6.cjs.map +0 -1
- package/dist/chunk-MPBMHIAQ.js.map +0 -1
- package/dist/chunk-RC6RZVYE.js +0 -79
- package/dist/chunk-RC6RZVYE.js.map +0 -1
- package/dist/chunk-SVPZMV27.js +0 -79
- package/dist/chunk-SVPZMV27.js.map +0 -1
- package/dist/chunk-ZD3BKU5O.cjs +0 -441
- package/dist/chunk-ZD3BKU5O.cjs.map +0 -1
- package/dist/token-APYSY3BW-2DN6RAUY.js +0 -61
- package/dist/token-APYSY3BW-2DN6RAUY.js.map +0 -1
- package/dist/token-APYSY3BW-POD4OUWN.cjs +0 -63
- package/dist/token-APYSY3BW-POD4OUWN.cjs.map +0 -1
- package/dist/token-APYSY3BW-YTVQELJT.js +0 -61
- package/dist/token-APYSY3BW-YTVQELJT.js.map +0 -1
- package/dist/token-APYSY3BW-ZQ7TMBY7.cjs +0 -63
- package/dist/token-APYSY3BW-ZQ7TMBY7.cjs.map +0 -1
- package/dist/token-util-RMHT2CPJ-6TGPE335.cjs +0 -10
- package/dist/token-util-RMHT2CPJ-6TGPE335.cjs.map +0 -1
- package/dist/token-util-RMHT2CPJ-77HHGIQN.cjs +0 -10
- package/dist/token-util-RMHT2CPJ-77HHGIQN.cjs.map +0 -1
- package/dist/token-util-RMHT2CPJ-RJEA3FAN.js +0 -8
- package/dist/token-util-RMHT2CPJ-RJEA3FAN.js.map +0 -1
- package/dist/token-util-RMHT2CPJ-WJZ2SYAR.js +0 -8
- package/dist/token-util-RMHT2CPJ-WJZ2SYAR.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
|
|
3
|
-
import { truncateStringByTokens, resolveToolResultValue, formatToolResultForObserver } from './chunk-MPBMHIAQ.js';
|
|
4
|
-
export { ModelByInputTokens, getObservationsAsOf } from './chunk-MPBMHIAQ.js';
|
|
1
|
+
import { truncateStringByTokens, resolveToolResultValue, formatToolResultForObserver } from './chunk-7742VTN5.js';
|
|
2
|
+
export { ModelByInputTokens, getObservationsAsOf } from './chunk-7742VTN5.js';
|
|
5
3
|
import { ZodFirstPartyTypeKind } from 'zod/v3';
|
|
6
4
|
import { z } from 'zod';
|
|
7
5
|
import * as z4 from 'zod/v4';
|
|
@@ -27,7 +25,7 @@ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
|
27
25
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
28
26
|
var __getProtoOf = Object.getPrototypeOf;
|
|
29
27
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
30
|
-
var
|
|
28
|
+
var __commonJS = (cb, mod) => function __require2() {
|
|
31
29
|
return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
|
|
32
30
|
};
|
|
33
31
|
var __copyProps = (to, from, except, desc) => {
|
|
@@ -38,7 +36,7 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
38
36
|
}
|
|
39
37
|
return to;
|
|
40
38
|
};
|
|
41
|
-
var
|
|
39
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
42
40
|
// If the importer is in node compatibility mode or this is not an ESM
|
|
43
41
|
// file that has been converted to a CommonJS file using a Babel-
|
|
44
42
|
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
@@ -46,7 +44,7 @@ var __toESM3 = (mod, isNodeMode, target) => (target = mod != null ? __create(__g
|
|
|
46
44
|
__defProp(target, "default", { value: mod, enumerable: true }),
|
|
47
45
|
mod
|
|
48
46
|
));
|
|
49
|
-
var require_secure_json_parse =
|
|
47
|
+
var require_secure_json_parse = __commonJS({
|
|
50
48
|
"../../../node_modules/.pnpm/secure-json-parse@2.7.0/node_modules/secure-json-parse/index.js"(exports$1, module) {
|
|
51
49
|
var hasBuffer = typeof Buffer !== "undefined";
|
|
52
50
|
var suspectProtoRx3 = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
|
|
@@ -317,7 +315,7 @@ var customAlphabet = (alphabet, defaultSize = 21) => {
|
|
|
317
315
|
return id;
|
|
318
316
|
};
|
|
319
317
|
};
|
|
320
|
-
var import_secure_json_parse =
|
|
318
|
+
var import_secure_json_parse = __toESM(require_secure_json_parse());
|
|
321
319
|
function convertAsyncIteratorToReadableStream(iterator) {
|
|
322
320
|
return new ReadableStream({
|
|
323
321
|
/**
|
|
@@ -4294,6 +4292,9 @@ var ParseError = class extends Error {
|
|
|
4294
4292
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
4295
4293
|
}
|
|
4296
4294
|
};
|
|
4295
|
+
var LF = 10;
|
|
4296
|
+
var CR = 13;
|
|
4297
|
+
var SPACE = 32;
|
|
4297
4298
|
function noop(_arg) {
|
|
4298
4299
|
}
|
|
4299
4300
|
function createParser(callbacks) {
|
|
@@ -4301,39 +4302,109 @@ function createParser(callbacks) {
|
|
|
4301
4302
|
throw new TypeError(
|
|
4302
4303
|
"`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
|
|
4303
4304
|
);
|
|
4304
|
-
const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
|
|
4305
|
-
let
|
|
4306
|
-
function feed(
|
|
4307
|
-
|
|
4308
|
-
|
|
4309
|
-
|
|
4310
|
-
|
|
4311
|
-
|
|
4312
|
-
|
|
4313
|
-
|
|
4305
|
+
const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks, pendingFragments = [];
|
|
4306
|
+
let isFirstChunk = true, id, data = "", dataLines = 0, eventType;
|
|
4307
|
+
function feed(chunk) {
|
|
4308
|
+
if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
4309
|
+
const trailing2 = processLines(chunk);
|
|
4310
|
+
trailing2 !== "" && pendingFragments.push(trailing2);
|
|
4311
|
+
return;
|
|
4312
|
+
}
|
|
4313
|
+
if (chunk.indexOf(`
|
|
4314
|
+
`) === -1 && chunk.indexOf("\r") === -1) {
|
|
4315
|
+
pendingFragments.push(chunk);
|
|
4316
|
+
return;
|
|
4317
|
+
}
|
|
4318
|
+
pendingFragments.push(chunk);
|
|
4319
|
+
const input = pendingFragments.join("");
|
|
4320
|
+
pendingFragments.length = 0;
|
|
4321
|
+
const trailing = processLines(input);
|
|
4322
|
+
trailing !== "" && pendingFragments.push(trailing);
|
|
4323
|
+
}
|
|
4324
|
+
function processLines(chunk) {
|
|
4325
|
+
let searchIndex = 0;
|
|
4326
|
+
if (chunk.indexOf("\r") === -1) {
|
|
4327
|
+
let lfIndex = chunk.indexOf(`
|
|
4328
|
+
`, searchIndex);
|
|
4329
|
+
for (; lfIndex !== -1; ) {
|
|
4330
|
+
if (searchIndex === lfIndex) {
|
|
4331
|
+
dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
4332
|
+
`, searchIndex);
|
|
4333
|
+
continue;
|
|
4334
|
+
}
|
|
4335
|
+
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
4336
|
+
if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
|
|
4337
|
+
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
4338
|
+
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
|
|
4339
|
+
onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
4340
|
+
`, searchIndex);
|
|
4341
|
+
continue;
|
|
4342
|
+
}
|
|
4343
|
+
data = dataLines === 0 ? value : `${data}
|
|
4344
|
+
${value}`, dataLines++;
|
|
4345
|
+
} else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
|
|
4346
|
+
chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
|
|
4347
|
+
lfIndex
|
|
4348
|
+
) || void 0 : parseLine(chunk, searchIndex, lfIndex);
|
|
4349
|
+
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
4350
|
+
`, searchIndex);
|
|
4351
|
+
}
|
|
4352
|
+
return chunk.slice(searchIndex);
|
|
4353
|
+
}
|
|
4354
|
+
for (; searchIndex < chunk.length; ) {
|
|
4355
|
+
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
4356
|
+
`, searchIndex);
|
|
4357
|
+
let lineEnd = -1;
|
|
4358
|
+
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)
|
|
4359
|
+
break;
|
|
4360
|
+
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
|
|
4361
|
+
}
|
|
4362
|
+
return chunk.slice(searchIndex);
|
|
4363
|
+
}
|
|
4364
|
+
function parseLine(chunk, start, end) {
|
|
4365
|
+
if (start === end) {
|
|
4314
4366
|
dispatchEvent();
|
|
4315
4367
|
return;
|
|
4316
4368
|
}
|
|
4317
|
-
|
|
4318
|
-
|
|
4369
|
+
const firstCharCode = chunk.charCodeAt(start);
|
|
4370
|
+
if (isDataPrefix(chunk, start, firstCharCode)) {
|
|
4371
|
+
const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
|
|
4372
|
+
data = dataLines === 0 ? value2 : `${data}
|
|
4373
|
+
${value2}`, dataLines++;
|
|
4319
4374
|
return;
|
|
4320
4375
|
}
|
|
4321
|
-
|
|
4322
|
-
|
|
4323
|
-
const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
4324
|
-
processField(field, value, line);
|
|
4376
|
+
if (isEventPrefix(chunk, start, firstCharCode)) {
|
|
4377
|
+
eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
|
|
4325
4378
|
return;
|
|
4326
4379
|
}
|
|
4327
|
-
|
|
4380
|
+
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
4381
|
+
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
|
|
4382
|
+
id = value2.includes("\0") ? void 0 : value2;
|
|
4383
|
+
return;
|
|
4384
|
+
}
|
|
4385
|
+
if (firstCharCode === 58) {
|
|
4386
|
+
if (onComment) {
|
|
4387
|
+
const line2 = chunk.slice(start, end);
|
|
4388
|
+
onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
|
|
4389
|
+
}
|
|
4390
|
+
return;
|
|
4391
|
+
}
|
|
4392
|
+
const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
|
|
4393
|
+
if (fieldSeparatorIndex === -1) {
|
|
4394
|
+
processField(line, "", line);
|
|
4395
|
+
return;
|
|
4396
|
+
}
|
|
4397
|
+
const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
4398
|
+
processField(field, value, line);
|
|
4328
4399
|
}
|
|
4329
4400
|
function processField(field, value, line) {
|
|
4330
4401
|
switch (field) {
|
|
4331
4402
|
case "event":
|
|
4332
|
-
eventType = value;
|
|
4403
|
+
eventType = value || void 0;
|
|
4333
4404
|
break;
|
|
4334
4405
|
case "data":
|
|
4335
|
-
data = `${data}
|
|
4336
|
-
|
|
4406
|
+
data = dataLines === 0 ? value : `${data}
|
|
4407
|
+
${value}`, dataLines++;
|
|
4337
4408
|
break;
|
|
4338
4409
|
case "id":
|
|
4339
4410
|
id = value.includes("\0") ? void 0 : value;
|
|
@@ -4358,37 +4429,26 @@ function createParser(callbacks) {
|
|
|
4358
4429
|
}
|
|
4359
4430
|
}
|
|
4360
4431
|
function dispatchEvent() {
|
|
4361
|
-
|
|
4432
|
+
dataLines > 0 && onEvent({
|
|
4362
4433
|
id,
|
|
4363
|
-
event: eventType
|
|
4364
|
-
|
|
4365
|
-
|
|
4366
|
-
data: data.endsWith(`
|
|
4367
|
-
`) ? data.slice(0, -1) : data
|
|
4368
|
-
}), id = void 0, data = "", eventType = "";
|
|
4434
|
+
event: eventType,
|
|
4435
|
+
data
|
|
4436
|
+
}), id = void 0, data = "", dataLines = 0, eventType = void 0;
|
|
4369
4437
|
}
|
|
4370
4438
|
function reset(options = {}) {
|
|
4371
|
-
|
|
4439
|
+
if (options.consume && pendingFragments.length > 0) {
|
|
4440
|
+
const incompleteLine = pendingFragments.join("");
|
|
4441
|
+
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
4442
|
+
}
|
|
4443
|
+
isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0;
|
|
4372
4444
|
}
|
|
4373
4445
|
return { feed, reset };
|
|
4374
4446
|
}
|
|
4375
|
-
function
|
|
4376
|
-
|
|
4377
|
-
|
|
4378
|
-
|
|
4379
|
-
|
|
4380
|
-
`, searchIndex);
|
|
4381
|
-
let lineEnd = -1;
|
|
4382
|
-
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) {
|
|
4383
|
-
incompleteLine = chunk.slice(searchIndex);
|
|
4384
|
-
break;
|
|
4385
|
-
} else {
|
|
4386
|
-
const line = chunk.slice(searchIndex, lineEnd);
|
|
4387
|
-
lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
|
|
4388
|
-
` && searchIndex++;
|
|
4389
|
-
}
|
|
4390
|
-
}
|
|
4391
|
-
return [lines, incompleteLine];
|
|
4447
|
+
function isDataPrefix(chunk, i, firstCharCode) {
|
|
4448
|
+
return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
|
|
4449
|
+
}
|
|
4450
|
+
function isEventPrefix(chunk, i, firstCharCode) {
|
|
4451
|
+
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;
|
|
4392
4452
|
}
|
|
4393
4453
|
var EventSourceParserStream = class extends TransformStream {
|
|
4394
4454
|
constructor({ onError, onRetry, onComment } = {}) {
|
|
@@ -4564,7 +4624,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
4564
4624
|
);
|
|
4565
4625
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
4566
4626
|
}
|
|
4567
|
-
var VERSION2 = "3.0.
|
|
4627
|
+
var VERSION2 = "3.0.23";
|
|
4568
4628
|
var getOriginalFetch = () => globalThis.fetch;
|
|
4569
4629
|
var getFromApi = async ({
|
|
4570
4630
|
url,
|
|
@@ -6226,138 +6286,17 @@ function asSchema2(schema) {
|
|
|
6226
6286
|
function withoutTrailingSlash(url) {
|
|
6227
6287
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
6228
6288
|
}
|
|
6229
|
-
|
|
6230
|
-
|
|
6231
|
-
|
|
6232
|
-
|
|
6233
|
-
|
|
6234
|
-
|
|
6235
|
-
|
|
6236
|
-
|
|
6237
|
-
__defProp22(target, name163, { get: all[name163], enumerable: true });
|
|
6238
|
-
};
|
|
6239
|
-
var __copyProps2 = (to, from, except, desc) => {
|
|
6240
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
6241
|
-
for (let key of __getOwnPropNames2(from))
|
|
6242
|
-
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
6243
|
-
__defProp22(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
6244
|
-
}
|
|
6245
|
-
return to;
|
|
6246
|
-
};
|
|
6247
|
-
var __toCommonJS = (mod) => __copyProps2(__defProp22({}, "__esModule", { value: true }), mod);
|
|
6248
|
-
var get_context_exports = {};
|
|
6249
|
-
__export22(get_context_exports, {
|
|
6250
|
-
SYMBOL_FOR_REQ_CONTEXT: () => SYMBOL_FOR_REQ_CONTEXT,
|
|
6251
|
-
getContext: () => getContext3
|
|
6252
|
-
});
|
|
6253
|
-
module.exports = __toCommonJS(get_context_exports);
|
|
6254
|
-
var SYMBOL_FOR_REQ_CONTEXT = /* @__PURE__ */ Symbol.for("@vercel/request-context");
|
|
6255
|
-
function getContext3() {
|
|
6256
|
-
const fromSymbol = globalThis;
|
|
6257
|
-
return fromSymbol[SYMBOL_FOR_REQ_CONTEXT]?.get?.() ?? {};
|
|
6258
|
-
}
|
|
6259
|
-
}
|
|
6260
|
-
});
|
|
6261
|
-
var require_get_vercel_oidc_token = __commonJS({
|
|
6262
|
-
"../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports$1, module) {
|
|
6263
|
-
var __defProp22 = Object.defineProperty;
|
|
6264
|
-
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
6265
|
-
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
6266
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
6267
|
-
var __export22 = (target, all) => {
|
|
6268
|
-
for (var name163 in all)
|
|
6269
|
-
__defProp22(target, name163, { get: all[name163], enumerable: true });
|
|
6270
|
-
};
|
|
6271
|
-
var __copyProps2 = (to, from, except, desc) => {
|
|
6272
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
6273
|
-
for (let key of __getOwnPropNames2(from))
|
|
6274
|
-
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
6275
|
-
__defProp22(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
6276
|
-
}
|
|
6277
|
-
return to;
|
|
6278
|
-
};
|
|
6279
|
-
var __toCommonJS = (mod) => __copyProps2(__defProp22({}, "__esModule", { value: true }), mod);
|
|
6280
|
-
var get_vercel_oidc_token_exports = {};
|
|
6281
|
-
__export22(get_vercel_oidc_token_exports, {
|
|
6282
|
-
getVercelOidcToken: () => getVercelOidcToken3,
|
|
6283
|
-
getVercelOidcTokenSync: () => getVercelOidcTokenSync2
|
|
6284
|
-
});
|
|
6285
|
-
module.exports = __toCommonJS(get_vercel_oidc_token_exports);
|
|
6286
|
-
var import_get_context = require_get_context();
|
|
6287
|
-
var import_token_error = require_token_error();
|
|
6288
|
-
async function getVercelOidcToken3() {
|
|
6289
|
-
let token = "";
|
|
6290
|
-
let err;
|
|
6291
|
-
try {
|
|
6292
|
-
token = getVercelOidcTokenSync2();
|
|
6293
|
-
} catch (error) {
|
|
6294
|
-
err = error;
|
|
6295
|
-
}
|
|
6296
|
-
try {
|
|
6297
|
-
const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
|
|
6298
|
-
await import('./token-util-RMHT2CPJ-WJZ2SYAR.js'),
|
|
6299
|
-
await import('./token-APYSY3BW-YTVQELJT.js')
|
|
6300
|
-
]);
|
|
6301
|
-
if (!token || isExpired(getTokenPayload(token))) {
|
|
6302
|
-
await refreshToken();
|
|
6303
|
-
token = getVercelOidcTokenSync2();
|
|
6304
|
-
}
|
|
6305
|
-
} catch (error) {
|
|
6306
|
-
let message = err instanceof Error ? err.message : "";
|
|
6307
|
-
if (error instanceof Error) {
|
|
6308
|
-
message = `${message}
|
|
6309
|
-
${error.message}`;
|
|
6310
|
-
}
|
|
6311
|
-
if (message) {
|
|
6312
|
-
throw new import_token_error.VercelOidcTokenError(message);
|
|
6313
|
-
}
|
|
6314
|
-
throw error;
|
|
6315
|
-
}
|
|
6316
|
-
return token;
|
|
6317
|
-
}
|
|
6318
|
-
function getVercelOidcTokenSync2() {
|
|
6319
|
-
const token = (0, import_get_context.getContext)().headers?.["x-vercel-oidc-token"] ?? process.env.VERCEL_OIDC_TOKEN;
|
|
6320
|
-
if (!token) {
|
|
6321
|
-
throw new Error(
|
|
6322
|
-
`The 'x-vercel-oidc-token' header is missing from the request. Do you have the OIDC option enabled in the Vercel project settings?`
|
|
6323
|
-
);
|
|
6324
|
-
}
|
|
6325
|
-
return token;
|
|
6326
|
-
}
|
|
6327
|
-
}
|
|
6328
|
-
});
|
|
6329
|
-
var require_dist = __commonJS({
|
|
6330
|
-
"../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/index.js"(exports$1, module) {
|
|
6331
|
-
var __defProp22 = Object.defineProperty;
|
|
6332
|
-
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
6333
|
-
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
6334
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
6335
|
-
var __export22 = (target, all) => {
|
|
6336
|
-
for (var name163 in all)
|
|
6337
|
-
__defProp22(target, name163, { get: all[name163], enumerable: true });
|
|
6338
|
-
};
|
|
6339
|
-
var __copyProps2 = (to, from, except, desc) => {
|
|
6340
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
6341
|
-
for (let key of __getOwnPropNames2(from))
|
|
6342
|
-
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
6343
|
-
__defProp22(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
6344
|
-
}
|
|
6345
|
-
return to;
|
|
6346
|
-
};
|
|
6347
|
-
var __toCommonJS = (mod) => __copyProps2(__defProp22({}, "__esModule", { value: true }), mod);
|
|
6348
|
-
var src_exports = {};
|
|
6349
|
-
__export22(src_exports, {
|
|
6350
|
-
getContext: () => import_get_context.getContext,
|
|
6351
|
-
getVercelOidcToken: () => import_get_vercel_oidc_token.getVercelOidcToken,
|
|
6352
|
-
getVercelOidcTokenSync: () => import_get_vercel_oidc_token.getVercelOidcTokenSync
|
|
6353
|
-
});
|
|
6354
|
-
module.exports = __toCommonJS(src_exports);
|
|
6355
|
-
var import_get_vercel_oidc_token = require_get_vercel_oidc_token();
|
|
6356
|
-
var import_get_context = require_get_context();
|
|
6289
|
+
function getContext() {
|
|
6290
|
+
return {
|
|
6291
|
+
headers: {}
|
|
6292
|
+
};
|
|
6293
|
+
}
|
|
6294
|
+
async function getVercelOidcToken() {
|
|
6295
|
+
if (process.env.VERCEL_OIDC_TOKEN) {
|
|
6296
|
+
return process.env.VERCEL_OIDC_TOKEN ?? "";
|
|
6357
6297
|
}
|
|
6358
|
-
|
|
6359
|
-
|
|
6360
|
-
var import_oidc2 = __toESM(require_dist(), 1);
|
|
6298
|
+
throw new Error("@vercel/oidc is not available in the vendored @internal AI packages. Provide an API key instead.");
|
|
6299
|
+
}
|
|
6361
6300
|
var marker18 = "vercel.ai.gateway.error";
|
|
6362
6301
|
var symbol18 = Symbol.for(marker18);
|
|
6363
6302
|
var _a18;
|
|
@@ -6732,6 +6671,7 @@ async function parseAuthMethod(headers) {
|
|
|
6732
6671
|
var gatewayAuthMethodSchema = lazyValidator(
|
|
6733
6672
|
() => zodSchema2(z$1.union([z$1.literal("api-key"), z$1.literal("oidc")]))
|
|
6734
6673
|
);
|
|
6674
|
+
var KNOWN_MODEL_TYPES = ["embedding", "image", "language"];
|
|
6735
6675
|
var GatewayFetchMetadata = class {
|
|
6736
6676
|
constructor(config) {
|
|
6737
6677
|
this.config = config;
|
|
@@ -6802,8 +6742,12 @@ var gatewayAvailableModelsResponseSchema = lazyValidator(
|
|
|
6802
6742
|
provider: z$1.string(),
|
|
6803
6743
|
modelId: z$1.string()
|
|
6804
6744
|
}),
|
|
6805
|
-
modelType: z$1.
|
|
6745
|
+
modelType: z$1.string().nullish()
|
|
6806
6746
|
})
|
|
6747
|
+
).transform(
|
|
6748
|
+
(models) => models.filter(
|
|
6749
|
+
(m) => m.modelType == null || KNOWN_MODEL_TYPES.includes(m.modelType)
|
|
6750
|
+
)
|
|
6807
6751
|
)
|
|
6808
6752
|
})
|
|
6809
6753
|
)
|
|
@@ -6819,6 +6763,187 @@ var gatewayCreditsResponseSchema = lazyValidator(
|
|
|
6819
6763
|
}))
|
|
6820
6764
|
)
|
|
6821
6765
|
);
|
|
6766
|
+
var GatewaySpendReport = class {
|
|
6767
|
+
constructor(config) {
|
|
6768
|
+
this.config = config;
|
|
6769
|
+
}
|
|
6770
|
+
async getSpendReport(params) {
|
|
6771
|
+
try {
|
|
6772
|
+
const baseUrl = new URL(this.config.baseURL);
|
|
6773
|
+
const searchParams = new URLSearchParams();
|
|
6774
|
+
searchParams.set("start_date", params.startDate);
|
|
6775
|
+
searchParams.set("end_date", params.endDate);
|
|
6776
|
+
if (params.groupBy) {
|
|
6777
|
+
searchParams.set("group_by", params.groupBy);
|
|
6778
|
+
}
|
|
6779
|
+
if (params.datePart) {
|
|
6780
|
+
searchParams.set("date_part", params.datePart);
|
|
6781
|
+
}
|
|
6782
|
+
if (params.userId) {
|
|
6783
|
+
searchParams.set("user_id", params.userId);
|
|
6784
|
+
}
|
|
6785
|
+
if (params.model) {
|
|
6786
|
+
searchParams.set("model", params.model);
|
|
6787
|
+
}
|
|
6788
|
+
if (params.provider) {
|
|
6789
|
+
searchParams.set("provider", params.provider);
|
|
6790
|
+
}
|
|
6791
|
+
if (params.credentialType) {
|
|
6792
|
+
searchParams.set("credential_type", params.credentialType);
|
|
6793
|
+
}
|
|
6794
|
+
if (params.tags && params.tags.length > 0) {
|
|
6795
|
+
searchParams.set("tags", params.tags.join(","));
|
|
6796
|
+
}
|
|
6797
|
+
const { value } = await getFromApi({
|
|
6798
|
+
url: `${baseUrl.origin}/v1/report?${searchParams.toString()}`,
|
|
6799
|
+
headers: await resolve(this.config.headers()),
|
|
6800
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
6801
|
+
gatewaySpendReportResponseSchema
|
|
6802
|
+
),
|
|
6803
|
+
failedResponseHandler: createJsonErrorResponseHandler({
|
|
6804
|
+
errorSchema: z$1.any(),
|
|
6805
|
+
errorToMessage: (data) => data
|
|
6806
|
+
}),
|
|
6807
|
+
fetch: this.config.fetch
|
|
6808
|
+
});
|
|
6809
|
+
return value;
|
|
6810
|
+
} catch (error) {
|
|
6811
|
+
throw await asGatewayError(error);
|
|
6812
|
+
}
|
|
6813
|
+
}
|
|
6814
|
+
};
|
|
6815
|
+
var gatewaySpendReportResponseSchema = lazySchema(
|
|
6816
|
+
() => zodSchema2(
|
|
6817
|
+
z$1.object({
|
|
6818
|
+
results: z$1.array(
|
|
6819
|
+
z$1.object({
|
|
6820
|
+
day: z$1.string().optional(),
|
|
6821
|
+
hour: z$1.string().optional(),
|
|
6822
|
+
user: z$1.string().optional(),
|
|
6823
|
+
model: z$1.string().optional(),
|
|
6824
|
+
tag: z$1.string().optional(),
|
|
6825
|
+
provider: z$1.string().optional(),
|
|
6826
|
+
credential_type: z$1.enum(["byok", "system"]).optional(),
|
|
6827
|
+
total_cost: z$1.number(),
|
|
6828
|
+
market_cost: z$1.number().optional(),
|
|
6829
|
+
input_tokens: z$1.number().optional(),
|
|
6830
|
+
output_tokens: z$1.number().optional(),
|
|
6831
|
+
cached_input_tokens: z$1.number().optional(),
|
|
6832
|
+
cache_creation_input_tokens: z$1.number().optional(),
|
|
6833
|
+
reasoning_tokens: z$1.number().optional(),
|
|
6834
|
+
request_count: z$1.number().optional()
|
|
6835
|
+
}).transform(
|
|
6836
|
+
({
|
|
6837
|
+
credential_type,
|
|
6838
|
+
total_cost,
|
|
6839
|
+
market_cost,
|
|
6840
|
+
input_tokens,
|
|
6841
|
+
output_tokens,
|
|
6842
|
+
cached_input_tokens,
|
|
6843
|
+
cache_creation_input_tokens,
|
|
6844
|
+
reasoning_tokens,
|
|
6845
|
+
request_count,
|
|
6846
|
+
...rest
|
|
6847
|
+
}) => ({
|
|
6848
|
+
...rest,
|
|
6849
|
+
...credential_type !== void 0 ? { credentialType: credential_type } : {},
|
|
6850
|
+
totalCost: total_cost,
|
|
6851
|
+
...market_cost !== void 0 ? { marketCost: market_cost } : {},
|
|
6852
|
+
...input_tokens !== void 0 ? { inputTokens: input_tokens } : {},
|
|
6853
|
+
...output_tokens !== void 0 ? { outputTokens: output_tokens } : {},
|
|
6854
|
+
...cached_input_tokens !== void 0 ? { cachedInputTokens: cached_input_tokens } : {},
|
|
6855
|
+
...cache_creation_input_tokens !== void 0 ? { cacheCreationInputTokens: cache_creation_input_tokens } : {},
|
|
6856
|
+
...reasoning_tokens !== void 0 ? { reasoningTokens: reasoning_tokens } : {},
|
|
6857
|
+
...request_count !== void 0 ? { requestCount: request_count } : {}
|
|
6858
|
+
})
|
|
6859
|
+
)
|
|
6860
|
+
)
|
|
6861
|
+
})
|
|
6862
|
+
)
|
|
6863
|
+
);
|
|
6864
|
+
var GatewayGenerationInfoFetcher = class {
|
|
6865
|
+
constructor(config) {
|
|
6866
|
+
this.config = config;
|
|
6867
|
+
}
|
|
6868
|
+
async getGenerationInfo(params) {
|
|
6869
|
+
try {
|
|
6870
|
+
const baseUrl = new URL(this.config.baseURL);
|
|
6871
|
+
const { value } = await getFromApi({
|
|
6872
|
+
url: `${baseUrl.origin}/v1/generation?id=${encodeURIComponent(params.id)}`,
|
|
6873
|
+
headers: await resolve(this.config.headers()),
|
|
6874
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
6875
|
+
gatewayGenerationInfoResponseSchema
|
|
6876
|
+
),
|
|
6877
|
+
failedResponseHandler: createJsonErrorResponseHandler({
|
|
6878
|
+
errorSchema: z$1.any(),
|
|
6879
|
+
errorToMessage: (data) => data
|
|
6880
|
+
}),
|
|
6881
|
+
fetch: this.config.fetch
|
|
6882
|
+
});
|
|
6883
|
+
return value;
|
|
6884
|
+
} catch (error) {
|
|
6885
|
+
throw await asGatewayError(error);
|
|
6886
|
+
}
|
|
6887
|
+
}
|
|
6888
|
+
};
|
|
6889
|
+
var gatewayGenerationInfoResponseSchema = lazySchema(
|
|
6890
|
+
() => zodSchema2(
|
|
6891
|
+
z$1.object({
|
|
6892
|
+
data: z$1.object({
|
|
6893
|
+
id: z$1.string(),
|
|
6894
|
+
total_cost: z$1.number(),
|
|
6895
|
+
upstream_inference_cost: z$1.number(),
|
|
6896
|
+
usage: z$1.number(),
|
|
6897
|
+
created_at: z$1.string(),
|
|
6898
|
+
model: z$1.string(),
|
|
6899
|
+
is_byok: z$1.boolean(),
|
|
6900
|
+
provider_name: z$1.string(),
|
|
6901
|
+
streamed: z$1.boolean(),
|
|
6902
|
+
finish_reason: z$1.string(),
|
|
6903
|
+
latency: z$1.number(),
|
|
6904
|
+
generation_time: z$1.number(),
|
|
6905
|
+
native_tokens_prompt: z$1.number(),
|
|
6906
|
+
native_tokens_completion: z$1.number(),
|
|
6907
|
+
native_tokens_reasoning: z$1.number(),
|
|
6908
|
+
native_tokens_cached: z$1.number(),
|
|
6909
|
+
native_tokens_cache_creation: z$1.number(),
|
|
6910
|
+
billable_web_search_calls: z$1.number()
|
|
6911
|
+
}).transform(
|
|
6912
|
+
({
|
|
6913
|
+
total_cost,
|
|
6914
|
+
upstream_inference_cost,
|
|
6915
|
+
created_at,
|
|
6916
|
+
is_byok,
|
|
6917
|
+
provider_name,
|
|
6918
|
+
finish_reason,
|
|
6919
|
+
generation_time,
|
|
6920
|
+
native_tokens_prompt,
|
|
6921
|
+
native_tokens_completion,
|
|
6922
|
+
native_tokens_reasoning,
|
|
6923
|
+
native_tokens_cached,
|
|
6924
|
+
native_tokens_cache_creation,
|
|
6925
|
+
billable_web_search_calls,
|
|
6926
|
+
...rest
|
|
6927
|
+
}) => ({
|
|
6928
|
+
...rest,
|
|
6929
|
+
totalCost: total_cost,
|
|
6930
|
+
upstreamInferenceCost: upstream_inference_cost,
|
|
6931
|
+
createdAt: created_at,
|
|
6932
|
+
isByok: is_byok,
|
|
6933
|
+
providerName: provider_name,
|
|
6934
|
+
finishReason: finish_reason,
|
|
6935
|
+
generationTime: generation_time,
|
|
6936
|
+
promptTokens: native_tokens_prompt,
|
|
6937
|
+
completionTokens: native_tokens_completion,
|
|
6938
|
+
reasoningTokens: native_tokens_reasoning,
|
|
6939
|
+
cachedTokens: native_tokens_cached,
|
|
6940
|
+
cacheCreationTokens: native_tokens_cache_creation,
|
|
6941
|
+
billableWebSearchCalls: billable_web_search_calls
|
|
6942
|
+
})
|
|
6943
|
+
)
|
|
6944
|
+
}).transform(({ data }) => data)
|
|
6945
|
+
)
|
|
6946
|
+
);
|
|
6822
6947
|
var GatewayLanguageModel = class {
|
|
6823
6948
|
constructor(modelId, config) {
|
|
6824
6949
|
this.modelId = modelId;
|
|
@@ -7319,9 +7444,9 @@ var gatewayTools = {
|
|
|
7319
7444
|
};
|
|
7320
7445
|
async function getVercelRequestId() {
|
|
7321
7446
|
var _a932;
|
|
7322
|
-
return (_a932 =
|
|
7447
|
+
return (_a932 = getContext().headers) == null ? void 0 : _a932["x-vercel-id"];
|
|
7323
7448
|
}
|
|
7324
|
-
var VERSION3 = "2.0.
|
|
7449
|
+
var VERSION3 = "2.0.82";
|
|
7325
7450
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
7326
7451
|
function createGatewayProvider(options = {}) {
|
|
7327
7452
|
var _a932, _b93;
|
|
@@ -7419,6 +7544,30 @@ function createGatewayProvider(options = {}) {
|
|
|
7419
7544
|
);
|
|
7420
7545
|
});
|
|
7421
7546
|
};
|
|
7547
|
+
const getSpendReport = async (params) => {
|
|
7548
|
+
return new GatewaySpendReport({
|
|
7549
|
+
baseURL,
|
|
7550
|
+
headers: getHeaders,
|
|
7551
|
+
fetch: options.fetch
|
|
7552
|
+
}).getSpendReport(params).catch(async (error) => {
|
|
7553
|
+
throw await asGatewayError(
|
|
7554
|
+
error,
|
|
7555
|
+
await parseAuthMethod(await getHeaders())
|
|
7556
|
+
);
|
|
7557
|
+
});
|
|
7558
|
+
};
|
|
7559
|
+
const getGenerationInfo = async (params) => {
|
|
7560
|
+
return new GatewayGenerationInfoFetcher({
|
|
7561
|
+
baseURL,
|
|
7562
|
+
headers: getHeaders,
|
|
7563
|
+
fetch: options.fetch
|
|
7564
|
+
}).getGenerationInfo(params).catch(async (error) => {
|
|
7565
|
+
throw await asGatewayError(
|
|
7566
|
+
error,
|
|
7567
|
+
await parseAuthMethod(await getHeaders())
|
|
7568
|
+
);
|
|
7569
|
+
});
|
|
7570
|
+
};
|
|
7422
7571
|
const provider = function(modelId) {
|
|
7423
7572
|
if (new.target) {
|
|
7424
7573
|
throw new Error(
|
|
@@ -7429,6 +7578,8 @@ function createGatewayProvider(options = {}) {
|
|
|
7429
7578
|
};
|
|
7430
7579
|
provider.getAvailableModels = getAvailableModels;
|
|
7431
7580
|
provider.getCredits = getCredits;
|
|
7581
|
+
provider.getSpendReport = getSpendReport;
|
|
7582
|
+
provider.getGenerationInfo = getGenerationInfo;
|
|
7432
7583
|
provider.imageModel = (modelId) => {
|
|
7433
7584
|
return new GatewayImageModel(modelId, {
|
|
7434
7585
|
provider: "gateway",
|
|
@@ -7464,7 +7615,7 @@ async function getGatewayAuthToken(options) {
|
|
|
7464
7615
|
};
|
|
7465
7616
|
}
|
|
7466
7617
|
try {
|
|
7467
|
-
const oidcToken = await
|
|
7618
|
+
const oidcToken = await getVercelOidcToken();
|
|
7468
7619
|
return {
|
|
7469
7620
|
token: oidcToken,
|
|
7470
7621
|
authMethod: "oidc"
|
|
@@ -8282,7 +8433,7 @@ function getGlobalProvider() {
|
|
|
8282
8433
|
var _a163;
|
|
8283
8434
|
return (_a163 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a163 : gateway;
|
|
8284
8435
|
}
|
|
8285
|
-
var VERSION32 = "5.0.
|
|
8436
|
+
var VERSION32 = "5.0.179";
|
|
8286
8437
|
var dataContentSchema2 = z$1.union([
|
|
8287
8438
|
z$1.string(),
|
|
8288
8439
|
z$1.instanceof(Uint8Array),
|
|
@@ -9587,6 +9738,9 @@ var ParseError2 = class extends Error {
|
|
|
9587
9738
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
9588
9739
|
}
|
|
9589
9740
|
};
|
|
9741
|
+
var LF2 = 10;
|
|
9742
|
+
var CR2 = 13;
|
|
9743
|
+
var SPACE2 = 32;
|
|
9590
9744
|
function noop2(_arg) {
|
|
9591
9745
|
}
|
|
9592
9746
|
function createParser2(callbacks) {
|
|
@@ -9594,39 +9748,109 @@ function createParser2(callbacks) {
|
|
|
9594
9748
|
throw new TypeError(
|
|
9595
9749
|
"`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
|
|
9596
9750
|
);
|
|
9597
|
-
const { onEvent = noop2, onError = noop2, onRetry = noop2, onComment } = callbacks;
|
|
9598
|
-
let
|
|
9599
|
-
function feed(
|
|
9600
|
-
|
|
9601
|
-
|
|
9602
|
-
|
|
9603
|
-
|
|
9604
|
-
|
|
9605
|
-
|
|
9606
|
-
|
|
9751
|
+
const { onEvent = noop2, onError = noop2, onRetry = noop2, onComment } = callbacks, pendingFragments = [];
|
|
9752
|
+
let isFirstChunk = true, id, data = "", dataLines = 0, eventType;
|
|
9753
|
+
function feed(chunk) {
|
|
9754
|
+
if (isFirstChunk && (isFirstChunk = false, chunk.charCodeAt(0) === 239 && chunk.charCodeAt(1) === 187 && chunk.charCodeAt(2) === 191 && (chunk = chunk.slice(3))), pendingFragments.length === 0) {
|
|
9755
|
+
const trailing2 = processLines(chunk);
|
|
9756
|
+
trailing2 !== "" && pendingFragments.push(trailing2);
|
|
9757
|
+
return;
|
|
9758
|
+
}
|
|
9759
|
+
if (chunk.indexOf(`
|
|
9760
|
+
`) === -1 && chunk.indexOf("\r") === -1) {
|
|
9761
|
+
pendingFragments.push(chunk);
|
|
9762
|
+
return;
|
|
9763
|
+
}
|
|
9764
|
+
pendingFragments.push(chunk);
|
|
9765
|
+
const input = pendingFragments.join("");
|
|
9766
|
+
pendingFragments.length = 0;
|
|
9767
|
+
const trailing = processLines(input);
|
|
9768
|
+
trailing !== "" && pendingFragments.push(trailing);
|
|
9769
|
+
}
|
|
9770
|
+
function processLines(chunk) {
|
|
9771
|
+
let searchIndex = 0;
|
|
9772
|
+
if (chunk.indexOf("\r") === -1) {
|
|
9773
|
+
let lfIndex = chunk.indexOf(`
|
|
9774
|
+
`, searchIndex);
|
|
9775
|
+
for (; lfIndex !== -1; ) {
|
|
9776
|
+
if (searchIndex === lfIndex) {
|
|
9777
|
+
dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
9778
|
+
`, searchIndex);
|
|
9779
|
+
continue;
|
|
9780
|
+
}
|
|
9781
|
+
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
9782
|
+
if (isDataPrefix2(chunk, searchIndex, firstCharCode)) {
|
|
9783
|
+
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE2 ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
9784
|
+
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF2) {
|
|
9785
|
+
onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
9786
|
+
`, searchIndex);
|
|
9787
|
+
continue;
|
|
9788
|
+
}
|
|
9789
|
+
data = dataLines === 0 ? value : `${data}
|
|
9790
|
+
${value}`, dataLines++;
|
|
9791
|
+
} else isEventPrefix2(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
|
|
9792
|
+
chunk.charCodeAt(searchIndex + 6) === SPACE2 ? searchIndex + 7 : searchIndex + 6,
|
|
9793
|
+
lfIndex
|
|
9794
|
+
) || void 0 : parseLine(chunk, searchIndex, lfIndex);
|
|
9795
|
+
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
9796
|
+
`, searchIndex);
|
|
9797
|
+
}
|
|
9798
|
+
return chunk.slice(searchIndex);
|
|
9799
|
+
}
|
|
9800
|
+
for (; searchIndex < chunk.length; ) {
|
|
9801
|
+
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
9802
|
+
`, searchIndex);
|
|
9803
|
+
let lineEnd = -1;
|
|
9804
|
+
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)
|
|
9805
|
+
break;
|
|
9806
|
+
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR2 && chunk.charCodeAt(searchIndex) === LF2 && searchIndex++;
|
|
9807
|
+
}
|
|
9808
|
+
return chunk.slice(searchIndex);
|
|
9809
|
+
}
|
|
9810
|
+
function parseLine(chunk, start, end) {
|
|
9811
|
+
if (start === end) {
|
|
9607
9812
|
dispatchEvent();
|
|
9608
9813
|
return;
|
|
9609
9814
|
}
|
|
9610
|
-
|
|
9611
|
-
|
|
9815
|
+
const firstCharCode = chunk.charCodeAt(start);
|
|
9816
|
+
if (isDataPrefix2(chunk, start, firstCharCode)) {
|
|
9817
|
+
const valueStart = chunk.charCodeAt(start + 5) === SPACE2 ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
|
|
9818
|
+
data = dataLines === 0 ? value2 : `${data}
|
|
9819
|
+
${value2}`, dataLines++;
|
|
9820
|
+
return;
|
|
9821
|
+
}
|
|
9822
|
+
if (isEventPrefix2(chunk, start, firstCharCode)) {
|
|
9823
|
+
eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE2 ? start + 7 : start + 6, end) || void 0;
|
|
9824
|
+
return;
|
|
9825
|
+
}
|
|
9826
|
+
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
9827
|
+
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE2 ? start + 4 : start + 3, end);
|
|
9828
|
+
id = value2.includes("\0") ? void 0 : value2;
|
|
9829
|
+
return;
|
|
9830
|
+
}
|
|
9831
|
+
if (firstCharCode === 58) {
|
|
9832
|
+
if (onComment) {
|
|
9833
|
+
const line2 = chunk.slice(start, end);
|
|
9834
|
+
onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE2 ? 2 : 1));
|
|
9835
|
+
}
|
|
9612
9836
|
return;
|
|
9613
9837
|
}
|
|
9614
|
-
const fieldSeparatorIndex = line.indexOf(":");
|
|
9615
|
-
if (fieldSeparatorIndex
|
|
9616
|
-
|
|
9617
|
-
processField(field, value, line);
|
|
9838
|
+
const line = chunk.slice(start, end), fieldSeparatorIndex = line.indexOf(":");
|
|
9839
|
+
if (fieldSeparatorIndex === -1) {
|
|
9840
|
+
processField(line, "", line);
|
|
9618
9841
|
return;
|
|
9619
9842
|
}
|
|
9620
|
-
|
|
9843
|
+
const field = line.slice(0, fieldSeparatorIndex), offset = line.charCodeAt(fieldSeparatorIndex + 1) === SPACE2 ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
9844
|
+
processField(field, value, line);
|
|
9621
9845
|
}
|
|
9622
9846
|
function processField(field, value, line) {
|
|
9623
9847
|
switch (field) {
|
|
9624
9848
|
case "event":
|
|
9625
|
-
eventType = value;
|
|
9849
|
+
eventType = value || void 0;
|
|
9626
9850
|
break;
|
|
9627
9851
|
case "data":
|
|
9628
|
-
data = `${data}
|
|
9629
|
-
|
|
9852
|
+
data = dataLines === 0 ? value : `${data}
|
|
9853
|
+
${value}`, dataLines++;
|
|
9630
9854
|
break;
|
|
9631
9855
|
case "id":
|
|
9632
9856
|
id = value.includes("\0") ? void 0 : value;
|
|
@@ -9651,37 +9875,26 @@ function createParser2(callbacks) {
|
|
|
9651
9875
|
}
|
|
9652
9876
|
}
|
|
9653
9877
|
function dispatchEvent() {
|
|
9654
|
-
|
|
9878
|
+
dataLines > 0 && onEvent({
|
|
9655
9879
|
id,
|
|
9656
|
-
event: eventType
|
|
9657
|
-
|
|
9658
|
-
|
|
9659
|
-
data: data.endsWith(`
|
|
9660
|
-
`) ? data.slice(0, -1) : data
|
|
9661
|
-
}), id = void 0, data = "", eventType = "";
|
|
9880
|
+
event: eventType,
|
|
9881
|
+
data
|
|
9882
|
+
}), id = void 0, data = "", dataLines = 0, eventType = void 0;
|
|
9662
9883
|
}
|
|
9663
9884
|
function reset(options = {}) {
|
|
9664
|
-
|
|
9885
|
+
if (options.consume && pendingFragments.length > 0) {
|
|
9886
|
+
const incompleteLine = pendingFragments.join("");
|
|
9887
|
+
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
9888
|
+
}
|
|
9889
|
+
isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0;
|
|
9665
9890
|
}
|
|
9666
9891
|
return { feed, reset };
|
|
9667
9892
|
}
|
|
9668
|
-
function
|
|
9669
|
-
|
|
9670
|
-
|
|
9671
|
-
|
|
9672
|
-
|
|
9673
|
-
`, searchIndex);
|
|
9674
|
-
let lineEnd = -1;
|
|
9675
|
-
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) {
|
|
9676
|
-
incompleteLine = chunk.slice(searchIndex);
|
|
9677
|
-
break;
|
|
9678
|
-
} else {
|
|
9679
|
-
const line = chunk.slice(searchIndex, lineEnd);
|
|
9680
|
-
lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
|
|
9681
|
-
` && searchIndex++;
|
|
9682
|
-
}
|
|
9683
|
-
}
|
|
9684
|
-
return [lines, incompleteLine];
|
|
9893
|
+
function isDataPrefix2(chunk, i, firstCharCode) {
|
|
9894
|
+
return firstCharCode === 100 && chunk.charCodeAt(i + 1) === 97 && chunk.charCodeAt(i + 2) === 116 && chunk.charCodeAt(i + 3) === 97 && chunk.charCodeAt(i + 4) === 58;
|
|
9895
|
+
}
|
|
9896
|
+
function isEventPrefix2(chunk, i, firstCharCode) {
|
|
9897
|
+
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;
|
|
9685
9898
|
}
|
|
9686
9899
|
var EventSourceParserStream2 = class extends TransformStream {
|
|
9687
9900
|
constructor({ onError, onRetry, onComment } = {}) {
|
|
@@ -9893,7 +10106,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
|
|
|
9893
10106
|
);
|
|
9894
10107
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
9895
10108
|
}
|
|
9896
|
-
var VERSION4 = "4.0.
|
|
10109
|
+
var VERSION4 = "4.0.23";
|
|
9897
10110
|
var getOriginalFetch3 = () => globalThis.fetch;
|
|
9898
10111
|
var getFromApi2 = async ({
|
|
9899
10112
|
url,
|
|
@@ -11553,138 +11766,17 @@ var createJsonResponseHandler2 = (responseSchema) => async ({ response, url, req
|
|
|
11553
11766
|
function withoutTrailingSlash2(url) {
|
|
11554
11767
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
11555
11768
|
}
|
|
11556
|
-
|
|
11557
|
-
|
|
11558
|
-
|
|
11559
|
-
|
|
11560
|
-
|
|
11561
|
-
|
|
11562
|
-
|
|
11563
|
-
|
|
11564
|
-
__defProp22(target, name21, { get: all[name21], enumerable: true });
|
|
11565
|
-
};
|
|
11566
|
-
var __copyProps2 = (to, from, except, desc) => {
|
|
11567
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11568
|
-
for (let key of __getOwnPropNames2(from))
|
|
11569
|
-
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
11570
|
-
__defProp22(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
11571
|
-
}
|
|
11572
|
-
return to;
|
|
11573
|
-
};
|
|
11574
|
-
var __toCommonJS = (mod) => __copyProps2(__defProp22({}, "__esModule", { value: true }), mod);
|
|
11575
|
-
var get_context_exports = {};
|
|
11576
|
-
__export22(get_context_exports, {
|
|
11577
|
-
SYMBOL_FOR_REQ_CONTEXT: () => SYMBOL_FOR_REQ_CONTEXT,
|
|
11578
|
-
getContext: () => getContext3
|
|
11579
|
-
});
|
|
11580
|
-
module.exports = __toCommonJS(get_context_exports);
|
|
11581
|
-
var SYMBOL_FOR_REQ_CONTEXT = /* @__PURE__ */ Symbol.for("@vercel/request-context");
|
|
11582
|
-
function getContext3() {
|
|
11583
|
-
const fromSymbol = globalThis;
|
|
11584
|
-
return fromSymbol[SYMBOL_FOR_REQ_CONTEXT]?.get?.() ?? {};
|
|
11585
|
-
}
|
|
11586
|
-
}
|
|
11587
|
-
});
|
|
11588
|
-
var require_get_vercel_oidc_token2 = __commonJS$1({
|
|
11589
|
-
"../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports$1, module) {
|
|
11590
|
-
var __defProp22 = Object.defineProperty;
|
|
11591
|
-
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
11592
|
-
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
11593
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
11594
|
-
var __export22 = (target, all) => {
|
|
11595
|
-
for (var name21 in all)
|
|
11596
|
-
__defProp22(target, name21, { get: all[name21], enumerable: true });
|
|
11597
|
-
};
|
|
11598
|
-
var __copyProps2 = (to, from, except, desc) => {
|
|
11599
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11600
|
-
for (let key of __getOwnPropNames2(from))
|
|
11601
|
-
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
11602
|
-
__defProp22(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
11603
|
-
}
|
|
11604
|
-
return to;
|
|
11605
|
-
};
|
|
11606
|
-
var __toCommonJS = (mod) => __copyProps2(__defProp22({}, "__esModule", { value: true }), mod);
|
|
11607
|
-
var get_vercel_oidc_token_exports = {};
|
|
11608
|
-
__export22(get_vercel_oidc_token_exports, {
|
|
11609
|
-
getVercelOidcToken: () => getVercelOidcToken3,
|
|
11610
|
-
getVercelOidcTokenSync: () => getVercelOidcTokenSync2
|
|
11611
|
-
});
|
|
11612
|
-
module.exports = __toCommonJS(get_vercel_oidc_token_exports);
|
|
11613
|
-
var import_get_context = require_get_context2();
|
|
11614
|
-
var import_token_error = require_token_error$1();
|
|
11615
|
-
async function getVercelOidcToken3() {
|
|
11616
|
-
let token = "";
|
|
11617
|
-
let err;
|
|
11618
|
-
try {
|
|
11619
|
-
token = getVercelOidcTokenSync2();
|
|
11620
|
-
} catch (error) {
|
|
11621
|
-
err = error;
|
|
11622
|
-
}
|
|
11623
|
-
try {
|
|
11624
|
-
const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
|
|
11625
|
-
await import('./token-util-RMHT2CPJ-RJEA3FAN.js'),
|
|
11626
|
-
await import('./token-APYSY3BW-2DN6RAUY.js')
|
|
11627
|
-
]);
|
|
11628
|
-
if (!token || isExpired(getTokenPayload(token))) {
|
|
11629
|
-
await refreshToken();
|
|
11630
|
-
token = getVercelOidcTokenSync2();
|
|
11631
|
-
}
|
|
11632
|
-
} catch (error) {
|
|
11633
|
-
let message = err instanceof Error ? err.message : "";
|
|
11634
|
-
if (error instanceof Error) {
|
|
11635
|
-
message = `${message}
|
|
11636
|
-
${error.message}`;
|
|
11637
|
-
}
|
|
11638
|
-
if (message) {
|
|
11639
|
-
throw new import_token_error.VercelOidcTokenError(message);
|
|
11640
|
-
}
|
|
11641
|
-
throw error;
|
|
11642
|
-
}
|
|
11643
|
-
return token;
|
|
11644
|
-
}
|
|
11645
|
-
function getVercelOidcTokenSync2() {
|
|
11646
|
-
const token = (0, import_get_context.getContext)().headers?.["x-vercel-oidc-token"] ?? process.env.VERCEL_OIDC_TOKEN;
|
|
11647
|
-
if (!token) {
|
|
11648
|
-
throw new Error(
|
|
11649
|
-
`The 'x-vercel-oidc-token' header is missing from the request. Do you have the OIDC option enabled in the Vercel project settings?`
|
|
11650
|
-
);
|
|
11651
|
-
}
|
|
11652
|
-
return token;
|
|
11653
|
-
}
|
|
11654
|
-
}
|
|
11655
|
-
});
|
|
11656
|
-
var require_dist2 = __commonJS$1({
|
|
11657
|
-
"../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/index.js"(exports$1, module) {
|
|
11658
|
-
var __defProp22 = Object.defineProperty;
|
|
11659
|
-
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
11660
|
-
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
11661
|
-
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
11662
|
-
var __export22 = (target, all) => {
|
|
11663
|
-
for (var name21 in all)
|
|
11664
|
-
__defProp22(target, name21, { get: all[name21], enumerable: true });
|
|
11665
|
-
};
|
|
11666
|
-
var __copyProps2 = (to, from, except, desc) => {
|
|
11667
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
11668
|
-
for (let key of __getOwnPropNames2(from))
|
|
11669
|
-
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
11670
|
-
__defProp22(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
11671
|
-
}
|
|
11672
|
-
return to;
|
|
11673
|
-
};
|
|
11674
|
-
var __toCommonJS = (mod) => __copyProps2(__defProp22({}, "__esModule", { value: true }), mod);
|
|
11675
|
-
var src_exports = {};
|
|
11676
|
-
__export22(src_exports, {
|
|
11677
|
-
getContext: () => import_get_context.getContext,
|
|
11678
|
-
getVercelOidcToken: () => import_get_vercel_oidc_token.getVercelOidcToken,
|
|
11679
|
-
getVercelOidcTokenSync: () => import_get_vercel_oidc_token.getVercelOidcTokenSync
|
|
11680
|
-
});
|
|
11681
|
-
module.exports = __toCommonJS(src_exports);
|
|
11682
|
-
var import_get_vercel_oidc_token = require_get_vercel_oidc_token2();
|
|
11683
|
-
var import_get_context = require_get_context2();
|
|
11769
|
+
function getContext2() {
|
|
11770
|
+
return {
|
|
11771
|
+
headers: {}
|
|
11772
|
+
};
|
|
11773
|
+
}
|
|
11774
|
+
async function getVercelOidcToken2() {
|
|
11775
|
+
if (process.env.VERCEL_OIDC_TOKEN) {
|
|
11776
|
+
return process.env.VERCEL_OIDC_TOKEN ?? "";
|
|
11684
11777
|
}
|
|
11685
|
-
|
|
11686
|
-
|
|
11687
|
-
var import_oidc22 = __toESM$1(require_dist2(), 1);
|
|
11778
|
+
throw new Error("@vercel/oidc is not available in the vendored @internal AI packages. Provide an API key instead.");
|
|
11779
|
+
}
|
|
11688
11780
|
var marker20 = "vercel.ai.gateway.error";
|
|
11689
11781
|
var symbol20 = Symbol.for(marker20);
|
|
11690
11782
|
var _a20;
|
|
@@ -12099,6 +12191,13 @@ async function parseAuthMethod2(headers) {
|
|
|
12099
12191
|
var gatewayAuthMethodSchema2 = lazySchema2(
|
|
12100
12192
|
() => zodSchema3(z$1.union([z$1.literal("api-key"), z$1.literal("oidc")]))
|
|
12101
12193
|
);
|
|
12194
|
+
var KNOWN_MODEL_TYPES2 = [
|
|
12195
|
+
"embedding",
|
|
12196
|
+
"image",
|
|
12197
|
+
"language",
|
|
12198
|
+
"reranking",
|
|
12199
|
+
"video"
|
|
12200
|
+
];
|
|
12102
12201
|
var GatewayFetchMetadata2 = class {
|
|
12103
12202
|
constructor(config) {
|
|
12104
12203
|
this.config = config;
|
|
@@ -12169,8 +12268,12 @@ var gatewayAvailableModelsResponseSchema2 = lazySchema2(
|
|
|
12169
12268
|
provider: z$1.string(),
|
|
12170
12269
|
modelId: z$1.string()
|
|
12171
12270
|
}),
|
|
12172
|
-
modelType: z$1.
|
|
12271
|
+
modelType: z$1.string().nullish()
|
|
12173
12272
|
})
|
|
12273
|
+
).transform(
|
|
12274
|
+
(models) => models.filter(
|
|
12275
|
+
(m) => m.modelType == null || KNOWN_MODEL_TYPES2.includes(m.modelType)
|
|
12276
|
+
)
|
|
12174
12277
|
)
|
|
12175
12278
|
})
|
|
12176
12279
|
)
|
|
@@ -12186,6 +12289,187 @@ var gatewayCreditsResponseSchema2 = lazySchema2(
|
|
|
12186
12289
|
}))
|
|
12187
12290
|
)
|
|
12188
12291
|
);
|
|
12292
|
+
var GatewaySpendReport2 = class {
|
|
12293
|
+
constructor(config) {
|
|
12294
|
+
this.config = config;
|
|
12295
|
+
}
|
|
12296
|
+
async getSpendReport(params) {
|
|
12297
|
+
try {
|
|
12298
|
+
const baseUrl = new URL(this.config.baseURL);
|
|
12299
|
+
const searchParams = new URLSearchParams();
|
|
12300
|
+
searchParams.set("start_date", params.startDate);
|
|
12301
|
+
searchParams.set("end_date", params.endDate);
|
|
12302
|
+
if (params.groupBy) {
|
|
12303
|
+
searchParams.set("group_by", params.groupBy);
|
|
12304
|
+
}
|
|
12305
|
+
if (params.datePart) {
|
|
12306
|
+
searchParams.set("date_part", params.datePart);
|
|
12307
|
+
}
|
|
12308
|
+
if (params.userId) {
|
|
12309
|
+
searchParams.set("user_id", params.userId);
|
|
12310
|
+
}
|
|
12311
|
+
if (params.model) {
|
|
12312
|
+
searchParams.set("model", params.model);
|
|
12313
|
+
}
|
|
12314
|
+
if (params.provider) {
|
|
12315
|
+
searchParams.set("provider", params.provider);
|
|
12316
|
+
}
|
|
12317
|
+
if (params.credentialType) {
|
|
12318
|
+
searchParams.set("credential_type", params.credentialType);
|
|
12319
|
+
}
|
|
12320
|
+
if (params.tags && params.tags.length > 0) {
|
|
12321
|
+
searchParams.set("tags", params.tags.join(","));
|
|
12322
|
+
}
|
|
12323
|
+
const { value } = await getFromApi2({
|
|
12324
|
+
url: `${baseUrl.origin}/v1/report?${searchParams.toString()}`,
|
|
12325
|
+
headers: await resolve2(this.config.headers()),
|
|
12326
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
12327
|
+
gatewaySpendReportResponseSchema2
|
|
12328
|
+
),
|
|
12329
|
+
failedResponseHandler: createJsonErrorResponseHandler2({
|
|
12330
|
+
errorSchema: z$1.any(),
|
|
12331
|
+
errorToMessage: (data) => data
|
|
12332
|
+
}),
|
|
12333
|
+
fetch: this.config.fetch
|
|
12334
|
+
});
|
|
12335
|
+
return value;
|
|
12336
|
+
} catch (error) {
|
|
12337
|
+
throw await asGatewayError2(error);
|
|
12338
|
+
}
|
|
12339
|
+
}
|
|
12340
|
+
};
|
|
12341
|
+
var gatewaySpendReportResponseSchema2 = lazySchema2(
|
|
12342
|
+
() => zodSchema3(
|
|
12343
|
+
z$1.object({
|
|
12344
|
+
results: z$1.array(
|
|
12345
|
+
z$1.object({
|
|
12346
|
+
day: z$1.string().optional(),
|
|
12347
|
+
hour: z$1.string().optional(),
|
|
12348
|
+
user: z$1.string().optional(),
|
|
12349
|
+
model: z$1.string().optional(),
|
|
12350
|
+
tag: z$1.string().optional(),
|
|
12351
|
+
provider: z$1.string().optional(),
|
|
12352
|
+
credential_type: z$1.enum(["byok", "system"]).optional(),
|
|
12353
|
+
total_cost: z$1.number(),
|
|
12354
|
+
market_cost: z$1.number().optional(),
|
|
12355
|
+
input_tokens: z$1.number().optional(),
|
|
12356
|
+
output_tokens: z$1.number().optional(),
|
|
12357
|
+
cached_input_tokens: z$1.number().optional(),
|
|
12358
|
+
cache_creation_input_tokens: z$1.number().optional(),
|
|
12359
|
+
reasoning_tokens: z$1.number().optional(),
|
|
12360
|
+
request_count: z$1.number().optional()
|
|
12361
|
+
}).transform(
|
|
12362
|
+
({
|
|
12363
|
+
credential_type,
|
|
12364
|
+
total_cost,
|
|
12365
|
+
market_cost,
|
|
12366
|
+
input_tokens,
|
|
12367
|
+
output_tokens,
|
|
12368
|
+
cached_input_tokens,
|
|
12369
|
+
cache_creation_input_tokens,
|
|
12370
|
+
reasoning_tokens,
|
|
12371
|
+
request_count,
|
|
12372
|
+
...rest
|
|
12373
|
+
}) => ({
|
|
12374
|
+
...rest,
|
|
12375
|
+
...credential_type !== void 0 ? { credentialType: credential_type } : {},
|
|
12376
|
+
totalCost: total_cost,
|
|
12377
|
+
...market_cost !== void 0 ? { marketCost: market_cost } : {},
|
|
12378
|
+
...input_tokens !== void 0 ? { inputTokens: input_tokens } : {},
|
|
12379
|
+
...output_tokens !== void 0 ? { outputTokens: output_tokens } : {},
|
|
12380
|
+
...cached_input_tokens !== void 0 ? { cachedInputTokens: cached_input_tokens } : {},
|
|
12381
|
+
...cache_creation_input_tokens !== void 0 ? { cacheCreationInputTokens: cache_creation_input_tokens } : {},
|
|
12382
|
+
...reasoning_tokens !== void 0 ? { reasoningTokens: reasoning_tokens } : {},
|
|
12383
|
+
...request_count !== void 0 ? { requestCount: request_count } : {}
|
|
12384
|
+
})
|
|
12385
|
+
)
|
|
12386
|
+
)
|
|
12387
|
+
})
|
|
12388
|
+
)
|
|
12389
|
+
);
|
|
12390
|
+
var GatewayGenerationInfoFetcher2 = class {
|
|
12391
|
+
constructor(config) {
|
|
12392
|
+
this.config = config;
|
|
12393
|
+
}
|
|
12394
|
+
async getGenerationInfo(params) {
|
|
12395
|
+
try {
|
|
12396
|
+
const baseUrl = new URL(this.config.baseURL);
|
|
12397
|
+
const { value } = await getFromApi2({
|
|
12398
|
+
url: `${baseUrl.origin}/v1/generation?id=${encodeURIComponent(params.id)}`,
|
|
12399
|
+
headers: await resolve2(this.config.headers()),
|
|
12400
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
12401
|
+
gatewayGenerationInfoResponseSchema2
|
|
12402
|
+
),
|
|
12403
|
+
failedResponseHandler: createJsonErrorResponseHandler2({
|
|
12404
|
+
errorSchema: z$1.any(),
|
|
12405
|
+
errorToMessage: (data) => data
|
|
12406
|
+
}),
|
|
12407
|
+
fetch: this.config.fetch
|
|
12408
|
+
});
|
|
12409
|
+
return value;
|
|
12410
|
+
} catch (error) {
|
|
12411
|
+
throw await asGatewayError2(error);
|
|
12412
|
+
}
|
|
12413
|
+
}
|
|
12414
|
+
};
|
|
12415
|
+
var gatewayGenerationInfoResponseSchema2 = lazySchema2(
|
|
12416
|
+
() => zodSchema3(
|
|
12417
|
+
z$1.object({
|
|
12418
|
+
data: z$1.object({
|
|
12419
|
+
id: z$1.string(),
|
|
12420
|
+
total_cost: z$1.number(),
|
|
12421
|
+
upstream_inference_cost: z$1.number(),
|
|
12422
|
+
usage: z$1.number(),
|
|
12423
|
+
created_at: z$1.string(),
|
|
12424
|
+
model: z$1.string(),
|
|
12425
|
+
is_byok: z$1.boolean(),
|
|
12426
|
+
provider_name: z$1.string(),
|
|
12427
|
+
streamed: z$1.boolean(),
|
|
12428
|
+
finish_reason: z$1.string(),
|
|
12429
|
+
latency: z$1.number(),
|
|
12430
|
+
generation_time: z$1.number(),
|
|
12431
|
+
native_tokens_prompt: z$1.number(),
|
|
12432
|
+
native_tokens_completion: z$1.number(),
|
|
12433
|
+
native_tokens_reasoning: z$1.number(),
|
|
12434
|
+
native_tokens_cached: z$1.number(),
|
|
12435
|
+
native_tokens_cache_creation: z$1.number(),
|
|
12436
|
+
billable_web_search_calls: z$1.number()
|
|
12437
|
+
}).transform(
|
|
12438
|
+
({
|
|
12439
|
+
total_cost,
|
|
12440
|
+
upstream_inference_cost,
|
|
12441
|
+
created_at,
|
|
12442
|
+
is_byok,
|
|
12443
|
+
provider_name,
|
|
12444
|
+
finish_reason,
|
|
12445
|
+
generation_time,
|
|
12446
|
+
native_tokens_prompt,
|
|
12447
|
+
native_tokens_completion,
|
|
12448
|
+
native_tokens_reasoning,
|
|
12449
|
+
native_tokens_cached,
|
|
12450
|
+
native_tokens_cache_creation,
|
|
12451
|
+
billable_web_search_calls,
|
|
12452
|
+
...rest
|
|
12453
|
+
}) => ({
|
|
12454
|
+
...rest,
|
|
12455
|
+
totalCost: total_cost,
|
|
12456
|
+
upstreamInferenceCost: upstream_inference_cost,
|
|
12457
|
+
createdAt: created_at,
|
|
12458
|
+
isByok: is_byok,
|
|
12459
|
+
providerName: provider_name,
|
|
12460
|
+
finishReason: finish_reason,
|
|
12461
|
+
generationTime: generation_time,
|
|
12462
|
+
promptTokens: native_tokens_prompt,
|
|
12463
|
+
completionTokens: native_tokens_completion,
|
|
12464
|
+
reasoningTokens: native_tokens_reasoning,
|
|
12465
|
+
cachedTokens: native_tokens_cached,
|
|
12466
|
+
cacheCreationTokens: native_tokens_cache_creation,
|
|
12467
|
+
billableWebSearchCalls: billable_web_search_calls
|
|
12468
|
+
})
|
|
12469
|
+
)
|
|
12470
|
+
}).transform(({ data }) => data)
|
|
12471
|
+
)
|
|
12472
|
+
);
|
|
12189
12473
|
var GatewayLanguageModel2 = class {
|
|
12190
12474
|
constructor(modelId, config) {
|
|
12191
12475
|
this.modelId = modelId;
|
|
@@ -12733,6 +13017,86 @@ var gatewayVideoEventSchema = z$1.discriminatedUnion("type", [
|
|
|
12733
13017
|
param: z$1.unknown().nullable()
|
|
12734
13018
|
})
|
|
12735
13019
|
]);
|
|
13020
|
+
var GatewayRerankingModel = class {
|
|
13021
|
+
constructor(modelId, config) {
|
|
13022
|
+
this.modelId = modelId;
|
|
13023
|
+
this.config = config;
|
|
13024
|
+
this.specificationVersion = "v3";
|
|
13025
|
+
}
|
|
13026
|
+
get provider() {
|
|
13027
|
+
return this.config.provider;
|
|
13028
|
+
}
|
|
13029
|
+
async doRerank({
|
|
13030
|
+
documents,
|
|
13031
|
+
query,
|
|
13032
|
+
topN,
|
|
13033
|
+
headers,
|
|
13034
|
+
abortSignal,
|
|
13035
|
+
providerOptions
|
|
13036
|
+
}) {
|
|
13037
|
+
const resolvedHeaders = await resolve2(this.config.headers());
|
|
13038
|
+
try {
|
|
13039
|
+
const {
|
|
13040
|
+
responseHeaders,
|
|
13041
|
+
value: responseBody,
|
|
13042
|
+
rawValue
|
|
13043
|
+
} = await postJsonToApi2({
|
|
13044
|
+
url: this.getUrl(),
|
|
13045
|
+
headers: combineHeaders2(
|
|
13046
|
+
resolvedHeaders,
|
|
13047
|
+
headers != null ? headers : {},
|
|
13048
|
+
this.getModelConfigHeaders(),
|
|
13049
|
+
await resolve2(this.config.o11yHeaders)
|
|
13050
|
+
),
|
|
13051
|
+
body: {
|
|
13052
|
+
documents,
|
|
13053
|
+
query,
|
|
13054
|
+
...topN != null ? { topN } : {},
|
|
13055
|
+
...providerOptions ? { providerOptions } : {}
|
|
13056
|
+
},
|
|
13057
|
+
successfulResponseHandler: createJsonResponseHandler2(
|
|
13058
|
+
gatewayRerankingResponseSchema
|
|
13059
|
+
),
|
|
13060
|
+
failedResponseHandler: createJsonErrorResponseHandler2({
|
|
13061
|
+
errorSchema: z$1.any(),
|
|
13062
|
+
errorToMessage: (data) => data
|
|
13063
|
+
}),
|
|
13064
|
+
...abortSignal && { abortSignal },
|
|
13065
|
+
fetch: this.config.fetch
|
|
13066
|
+
});
|
|
13067
|
+
return {
|
|
13068
|
+
ranking: responseBody.ranking,
|
|
13069
|
+
providerMetadata: responseBody.providerMetadata,
|
|
13070
|
+
response: { headers: responseHeaders, body: rawValue },
|
|
13071
|
+
warnings: []
|
|
13072
|
+
};
|
|
13073
|
+
} catch (error) {
|
|
13074
|
+
throw await asGatewayError2(error, await parseAuthMethod2(resolvedHeaders));
|
|
13075
|
+
}
|
|
13076
|
+
}
|
|
13077
|
+
getUrl() {
|
|
13078
|
+
return `${this.config.baseURL}/reranking-model`;
|
|
13079
|
+
}
|
|
13080
|
+
getModelConfigHeaders() {
|
|
13081
|
+
return {
|
|
13082
|
+
"ai-reranking-model-specification-version": "3",
|
|
13083
|
+
"ai-model-id": this.modelId
|
|
13084
|
+
};
|
|
13085
|
+
}
|
|
13086
|
+
};
|
|
13087
|
+
var gatewayRerankingResponseSchema = lazySchema2(
|
|
13088
|
+
() => zodSchema3(
|
|
13089
|
+
z$1.object({
|
|
13090
|
+
ranking: z$1.array(
|
|
13091
|
+
z$1.object({
|
|
13092
|
+
index: z$1.number(),
|
|
13093
|
+
relevanceScore: z$1.number()
|
|
13094
|
+
})
|
|
13095
|
+
),
|
|
13096
|
+
providerMetadata: z$1.record(z$1.string(), z$1.record(z$1.string(), z$1.unknown())).optional()
|
|
13097
|
+
})
|
|
13098
|
+
)
|
|
13099
|
+
);
|
|
12736
13100
|
var parallelSearchInputSchema2 = lazySchema2(
|
|
12737
13101
|
() => zodSchema3(
|
|
12738
13102
|
z.object({
|
|
@@ -12907,9 +13271,9 @@ var gatewayTools2 = {
|
|
|
12907
13271
|
};
|
|
12908
13272
|
async function getVercelRequestId2() {
|
|
12909
13273
|
var _a932;
|
|
12910
|
-
return (_a932 = (
|
|
13274
|
+
return (_a932 = getContext2().headers) == null ? void 0 : _a932["x-vercel-id"];
|
|
12911
13275
|
}
|
|
12912
|
-
var VERSION5 = "3.0.
|
|
13276
|
+
var VERSION5 = "3.0.104";
|
|
12913
13277
|
var AI_GATEWAY_PROTOCOL_VERSION2 = "0.0.1";
|
|
12914
13278
|
function createGatewayProvider2(options = {}) {
|
|
12915
13279
|
var _a932, _b93;
|
|
@@ -13009,6 +13373,30 @@ function createGatewayProvider2(options = {}) {
|
|
|
13009
13373
|
);
|
|
13010
13374
|
});
|
|
13011
13375
|
};
|
|
13376
|
+
const getSpendReport = async (params) => {
|
|
13377
|
+
return new GatewaySpendReport2({
|
|
13378
|
+
baseURL,
|
|
13379
|
+
headers: getHeaders,
|
|
13380
|
+
fetch: options.fetch
|
|
13381
|
+
}).getSpendReport(params).catch(async (error) => {
|
|
13382
|
+
throw await asGatewayError2(
|
|
13383
|
+
error,
|
|
13384
|
+
await parseAuthMethod2(await getHeaders())
|
|
13385
|
+
);
|
|
13386
|
+
});
|
|
13387
|
+
};
|
|
13388
|
+
const getGenerationInfo = async (params) => {
|
|
13389
|
+
return new GatewayGenerationInfoFetcher2({
|
|
13390
|
+
baseURL,
|
|
13391
|
+
headers: getHeaders,
|
|
13392
|
+
fetch: options.fetch
|
|
13393
|
+
}).getGenerationInfo(params).catch(async (error) => {
|
|
13394
|
+
throw await asGatewayError2(
|
|
13395
|
+
error,
|
|
13396
|
+
await parseAuthMethod2(await getHeaders())
|
|
13397
|
+
);
|
|
13398
|
+
});
|
|
13399
|
+
};
|
|
13012
13400
|
const provider = function(modelId) {
|
|
13013
13401
|
if (new.target) {
|
|
13014
13402
|
throw new Error(
|
|
@@ -13020,6 +13408,8 @@ function createGatewayProvider2(options = {}) {
|
|
|
13020
13408
|
provider.specificationVersion = "v3";
|
|
13021
13409
|
provider.getAvailableModels = getAvailableModels;
|
|
13022
13410
|
provider.getCredits = getCredits;
|
|
13411
|
+
provider.getSpendReport = getSpendReport;
|
|
13412
|
+
provider.getGenerationInfo = getGenerationInfo;
|
|
13023
13413
|
provider.imageModel = (modelId) => {
|
|
13024
13414
|
return new GatewayImageModel2(modelId, {
|
|
13025
13415
|
provider: "gateway",
|
|
@@ -13050,6 +13440,17 @@ function createGatewayProvider2(options = {}) {
|
|
|
13050
13440
|
o11yHeaders: createO11yHeaders()
|
|
13051
13441
|
});
|
|
13052
13442
|
};
|
|
13443
|
+
const createRerankingModel = (modelId) => {
|
|
13444
|
+
return new GatewayRerankingModel(modelId, {
|
|
13445
|
+
provider: "gateway",
|
|
13446
|
+
baseURL,
|
|
13447
|
+
headers: getHeaders,
|
|
13448
|
+
fetch: options.fetch,
|
|
13449
|
+
o11yHeaders: createO11yHeaders()
|
|
13450
|
+
});
|
|
13451
|
+
};
|
|
13452
|
+
provider.rerankingModel = createRerankingModel;
|
|
13453
|
+
provider.reranking = createRerankingModel;
|
|
13053
13454
|
provider.chat = provider.languageModel;
|
|
13054
13455
|
provider.embedding = provider.embeddingModel;
|
|
13055
13456
|
provider.image = provider.imageModel;
|
|
@@ -13069,7 +13470,7 @@ async function getGatewayAuthToken2(options) {
|
|
|
13069
13470
|
authMethod: "api-key"
|
|
13070
13471
|
};
|
|
13071
13472
|
}
|
|
13072
|
-
const oidcToken = await (
|
|
13473
|
+
const oidcToken = await getVercelOidcToken2();
|
|
13073
13474
|
return {
|
|
13074
13475
|
token: oidcToken,
|
|
13075
13476
|
authMethod: "oidc"
|
|
@@ -13982,7 +14383,7 @@ function getTotalTimeoutMs(timeout) {
|
|
|
13982
14383
|
}
|
|
13983
14384
|
return timeout.totalMs;
|
|
13984
14385
|
}
|
|
13985
|
-
var VERSION33 = "6.0.
|
|
14386
|
+
var VERSION33 = "6.0.168";
|
|
13986
14387
|
var dataContentSchema3 = z$1.union([
|
|
13987
14388
|
z$1.string(),
|
|
13988
14389
|
z$1.instanceof(Uint8Array),
|
|
@@ -17479,7 +17880,7 @@ ${workingMemory}`;
|
|
|
17479
17880
|
if (obsSystemMessage) {
|
|
17480
17881
|
systemParts.push(obsSystemMessage);
|
|
17481
17882
|
}
|
|
17482
|
-
const { OBSERVATION_CONTINUATION_HINT } = await import('./constants-
|
|
17883
|
+
const { OBSERVATION_CONTINUATION_HINT } = await import('./constants-XEHPYRDJ.js');
|
|
17483
17884
|
continuationMessage = {
|
|
17484
17885
|
id: "om-continuation",
|
|
17485
17886
|
role: "user",
|
|
@@ -17579,7 +17980,7 @@ ${workingMemory}`;
|
|
|
17579
17980
|
"Observational memory requires @mastra/core support for request-response-id-rotation. Please bump @mastra/core to a newer version."
|
|
17580
17981
|
);
|
|
17581
17982
|
}
|
|
17582
|
-
const { ObservationalMemory: OMClass } = await import('./observational-memory-
|
|
17983
|
+
const { ObservationalMemory: OMClass } = await import('./observational-memory-YYO73QMY.js');
|
|
17583
17984
|
const onIndexObservations = this.hasRetrievalSearch(omConfig.retrieval) ? async (observation) => {
|
|
17584
17985
|
await this.indexObservation(observation);
|
|
17585
17986
|
} : void 0;
|
|
@@ -18504,7 +18905,7 @@ Notes:
|
|
|
18504
18905
|
if (!effectiveConfig) return null;
|
|
18505
18906
|
const engine = await this.omEngine;
|
|
18506
18907
|
if (!engine) return null;
|
|
18507
|
-
const { ObservationalMemoryProcessor } = await import('./observational-memory-
|
|
18908
|
+
const { ObservationalMemoryProcessor } = await import('./observational-memory-YYO73QMY.js');
|
|
18508
18909
|
return new ObservationalMemoryProcessor(engine, this, {
|
|
18509
18910
|
temporalMarkers: effectiveConfig.temporalMarkers
|
|
18510
18911
|
});
|