@mastra/agent-builder 1.0.29 → 1.0.30-alpha.0
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 +8 -0
- package/dist/index.js +48 -322
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @mastra/agent-builder
|
|
2
2
|
|
|
3
|
+
## 1.0.30-alpha.0
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies [[`c1ae974`](https://github.com/mastra-ai/mastra/commit/c1ae97491f6e57378ce880c3a397778c42adcdf1), [`13b4d7c`](https://github.com/mastra-ai/mastra/commit/13b4d7c16de34dff9095d1cd80f22f544b6cfe75), [`5a4b1ee`](https://github.com/mastra-ai/mastra/commit/5a4b1ee80212969621228104995589c0fa59e575), [`5a4b1ee`](https://github.com/mastra-ai/mastra/commit/5a4b1ee80212969621228104995589c0fa59e575), [`5a4b1ee`](https://github.com/mastra-ai/mastra/commit/5a4b1ee80212969621228104995589c0fa59e575), [`6c8c6c7`](https://github.com/mastra-ai/mastra/commit/6c8c6c71518394321a4692614aa4b11f3bb0a343), [`5a4b1ee`](https://github.com/mastra-ai/mastra/commit/5a4b1ee80212969621228104995589c0fa59e575), [`ec4cb26`](https://github.com/mastra-ai/mastra/commit/ec4cb26919972eb2031fea510f8f013e1d5b7ee2), [`8c39f81`](https://github.com/mastra-ai/mastra/commit/8c39f815c7d06f2cd11bb099a72805a20f2ab755)]:
|
|
8
|
+
- @mastra/core@1.29.0-alpha.6
|
|
9
|
+
- @mastra/memory@1.17.2-alpha.0
|
|
10
|
+
|
|
3
11
|
## 1.0.29
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/dist/index.js
CHANGED
|
@@ -4969,9 +4969,6 @@ var ParseError = class extends Error {
|
|
|
4969
4969
|
super(message), this.name = "ParseError", this.type = options.type, this.field = options.field, this.value = options.value, this.line = options.line;
|
|
4970
4970
|
}
|
|
4971
4971
|
};
|
|
4972
|
-
var LF = 10;
|
|
4973
|
-
var CR = 13;
|
|
4974
|
-
var SPACE = 32;
|
|
4975
4972
|
function noop(_arg) {
|
|
4976
4973
|
}
|
|
4977
4974
|
function createParser(callbacks) {
|
|
@@ -4979,109 +4976,39 @@ function createParser(callbacks) {
|
|
|
4979
4976
|
throw new TypeError(
|
|
4980
4977
|
"`callbacks` must be an object, got a function instead. Did you mean `{onEvent: fn}`?"
|
|
4981
4978
|
);
|
|
4982
|
-
const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks
|
|
4983
|
-
let isFirstChunk = true, id, data = "",
|
|
4984
|
-
function feed(
|
|
4985
|
-
|
|
4986
|
-
|
|
4987
|
-
|
|
4988
|
-
|
|
4989
|
-
|
|
4990
|
-
|
|
4991
|
-
|
|
4992
|
-
pendingFragments.push(chunk);
|
|
4993
|
-
return;
|
|
4994
|
-
}
|
|
4995
|
-
pendingFragments.push(chunk);
|
|
4996
|
-
const input = pendingFragments.join("");
|
|
4997
|
-
pendingFragments.length = 0;
|
|
4998
|
-
const trailing = processLines(input);
|
|
4999
|
-
trailing !== "" && pendingFragments.push(trailing);
|
|
5000
|
-
}
|
|
5001
|
-
function processLines(chunk) {
|
|
5002
|
-
let searchIndex = 0;
|
|
5003
|
-
if (chunk.indexOf("\r") === -1) {
|
|
5004
|
-
let lfIndex = chunk.indexOf(`
|
|
5005
|
-
`, searchIndex);
|
|
5006
|
-
for (; lfIndex !== -1; ) {
|
|
5007
|
-
if (searchIndex === lfIndex) {
|
|
5008
|
-
dataLines > 0 && onEvent({ id, event: eventType, data }), id = void 0, data = "", dataLines = 0, eventType = void 0, searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
5009
|
-
`, searchIndex);
|
|
5010
|
-
continue;
|
|
5011
|
-
}
|
|
5012
|
-
const firstCharCode = chunk.charCodeAt(searchIndex);
|
|
5013
|
-
if (isDataPrefix(chunk, searchIndex, firstCharCode)) {
|
|
5014
|
-
const valueStart = chunk.charCodeAt(searchIndex + 5) === SPACE ? searchIndex + 6 : searchIndex + 5, value = chunk.slice(valueStart, lfIndex);
|
|
5015
|
-
if (dataLines === 0 && chunk.charCodeAt(lfIndex + 1) === LF) {
|
|
5016
|
-
onEvent({ id, event: eventType, data: value }), id = void 0, data = "", eventType = void 0, searchIndex = lfIndex + 2, lfIndex = chunk.indexOf(`
|
|
5017
|
-
`, searchIndex);
|
|
5018
|
-
continue;
|
|
5019
|
-
}
|
|
5020
|
-
data = dataLines === 0 ? value : `${data}
|
|
5021
|
-
${value}`, dataLines++;
|
|
5022
|
-
} else isEventPrefix(chunk, searchIndex, firstCharCode) ? eventType = chunk.slice(
|
|
5023
|
-
chunk.charCodeAt(searchIndex + 6) === SPACE ? searchIndex + 7 : searchIndex + 6,
|
|
5024
|
-
lfIndex
|
|
5025
|
-
) || void 0 : parseLine(chunk, searchIndex, lfIndex);
|
|
5026
|
-
searchIndex = lfIndex + 1, lfIndex = chunk.indexOf(`
|
|
5027
|
-
`, searchIndex);
|
|
5028
|
-
}
|
|
5029
|
-
return chunk.slice(searchIndex);
|
|
5030
|
-
}
|
|
5031
|
-
for (; searchIndex < chunk.length; ) {
|
|
5032
|
-
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
5033
|
-
`, searchIndex);
|
|
5034
|
-
let lineEnd = -1;
|
|
5035
|
-
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)
|
|
5036
|
-
break;
|
|
5037
|
-
parseLine(chunk, searchIndex, lineEnd), searchIndex = lineEnd + 1, chunk.charCodeAt(searchIndex - 1) === CR && chunk.charCodeAt(searchIndex) === LF && searchIndex++;
|
|
5038
|
-
}
|
|
5039
|
-
return chunk.slice(searchIndex);
|
|
5040
|
-
}
|
|
5041
|
-
function parseLine(chunk, start, end) {
|
|
5042
|
-
if (start === end) {
|
|
4979
|
+
const { onEvent = noop, onError = noop, onRetry = noop, onComment } = callbacks;
|
|
4980
|
+
let incompleteLine = "", isFirstChunk = true, id, data = "", eventType = "";
|
|
4981
|
+
function feed(newChunk) {
|
|
4982
|
+
const chunk = isFirstChunk ? newChunk.replace(/^\xEF\xBB\xBF/, "") : newChunk, [complete, incomplete] = splitLines(`${incompleteLine}${chunk}`);
|
|
4983
|
+
for (const line of complete)
|
|
4984
|
+
parseLine(line);
|
|
4985
|
+
incompleteLine = incomplete, isFirstChunk = false;
|
|
4986
|
+
}
|
|
4987
|
+
function parseLine(line) {
|
|
4988
|
+
if (line === "") {
|
|
5043
4989
|
dispatchEvent();
|
|
5044
4990
|
return;
|
|
5045
4991
|
}
|
|
5046
|
-
|
|
5047
|
-
|
|
5048
|
-
const valueStart = chunk.charCodeAt(start + 5) === SPACE ? start + 6 : start + 5, value2 = chunk.slice(valueStart, end);
|
|
5049
|
-
data = dataLines === 0 ? value2 : `${data}
|
|
5050
|
-
${value2}`, dataLines++;
|
|
5051
|
-
return;
|
|
5052
|
-
}
|
|
5053
|
-
if (isEventPrefix(chunk, start, firstCharCode)) {
|
|
5054
|
-
eventType = chunk.slice(chunk.charCodeAt(start + 6) === SPACE ? start + 7 : start + 6, end) || void 0;
|
|
5055
|
-
return;
|
|
5056
|
-
}
|
|
5057
|
-
if (firstCharCode === 105 && chunk.charCodeAt(start + 1) === 100 && chunk.charCodeAt(start + 2) === 58) {
|
|
5058
|
-
const value2 = chunk.slice(chunk.charCodeAt(start + 3) === SPACE ? start + 4 : start + 3, end);
|
|
5059
|
-
id = value2.includes("\0") ? void 0 : value2;
|
|
5060
|
-
return;
|
|
5061
|
-
}
|
|
5062
|
-
if (firstCharCode === 58) {
|
|
5063
|
-
if (onComment) {
|
|
5064
|
-
const line2 = chunk.slice(start, end);
|
|
5065
|
-
onComment(line2.slice(chunk.charCodeAt(start + 1) === SPACE ? 2 : 1));
|
|
5066
|
-
}
|
|
4992
|
+
if (line.startsWith(":")) {
|
|
4993
|
+
onComment && onComment(line.slice(line.startsWith(": ") ? 2 : 1));
|
|
5067
4994
|
return;
|
|
5068
4995
|
}
|
|
5069
|
-
const
|
|
5070
|
-
if (fieldSeparatorIndex
|
|
5071
|
-
|
|
4996
|
+
const fieldSeparatorIndex = line.indexOf(":");
|
|
4997
|
+
if (fieldSeparatorIndex !== -1) {
|
|
4998
|
+
const field = line.slice(0, fieldSeparatorIndex), offset = line[fieldSeparatorIndex + 1] === " " ? 2 : 1, value = line.slice(fieldSeparatorIndex + offset);
|
|
4999
|
+
processField(field, value, line);
|
|
5072
5000
|
return;
|
|
5073
5001
|
}
|
|
5074
|
-
|
|
5075
|
-
processField(field, value, line);
|
|
5002
|
+
processField(line, "", line);
|
|
5076
5003
|
}
|
|
5077
5004
|
function processField(field, value, line) {
|
|
5078
5005
|
switch (field) {
|
|
5079
5006
|
case "event":
|
|
5080
|
-
eventType = value
|
|
5007
|
+
eventType = value;
|
|
5081
5008
|
break;
|
|
5082
5009
|
case "data":
|
|
5083
|
-
data =
|
|
5084
|
-
|
|
5010
|
+
data = `${data}${value}
|
|
5011
|
+
`;
|
|
5085
5012
|
break;
|
|
5086
5013
|
case "id":
|
|
5087
5014
|
id = value.includes("\0") ? void 0 : value;
|
|
@@ -5106,26 +5033,37 @@ ${value}`, dataLines++;
|
|
|
5106
5033
|
}
|
|
5107
5034
|
}
|
|
5108
5035
|
function dispatchEvent() {
|
|
5109
|
-
|
|
5036
|
+
data.length > 0 && onEvent({
|
|
5110
5037
|
id,
|
|
5111
|
-
event: eventType,
|
|
5112
|
-
data
|
|
5113
|
-
|
|
5038
|
+
event: eventType || void 0,
|
|
5039
|
+
// If the data buffer's last character is a U+000A LINE FEED (LF) character,
|
|
5040
|
+
// then remove the last character from the data buffer.
|
|
5041
|
+
data: data.endsWith(`
|
|
5042
|
+
`) ? data.slice(0, -1) : data
|
|
5043
|
+
}), id = void 0, data = "", eventType = "";
|
|
5114
5044
|
}
|
|
5115
5045
|
function reset(options = {}) {
|
|
5116
|
-
|
|
5117
|
-
const incompleteLine = pendingFragments.join("");
|
|
5118
|
-
parseLine(incompleteLine, 0, incompleteLine.length);
|
|
5119
|
-
}
|
|
5120
|
-
isFirstChunk = true, id = void 0, data = "", dataLines = 0, eventType = void 0, pendingFragments.length = 0;
|
|
5046
|
+
incompleteLine && options.consume && parseLine(incompleteLine), isFirstChunk = true, id = void 0, data = "", eventType = "", incompleteLine = "";
|
|
5121
5047
|
}
|
|
5122
5048
|
return { feed, reset };
|
|
5123
5049
|
}
|
|
5124
|
-
function
|
|
5125
|
-
|
|
5126
|
-
|
|
5127
|
-
|
|
5128
|
-
|
|
5050
|
+
function splitLines(chunk) {
|
|
5051
|
+
const lines = [];
|
|
5052
|
+
let incompleteLine = "", searchIndex = 0;
|
|
5053
|
+
for (; searchIndex < chunk.length; ) {
|
|
5054
|
+
const crIndex = chunk.indexOf("\r", searchIndex), lfIndex = chunk.indexOf(`
|
|
5055
|
+
`, searchIndex);
|
|
5056
|
+
let lineEnd = -1;
|
|
5057
|
+
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) {
|
|
5058
|
+
incompleteLine = chunk.slice(searchIndex);
|
|
5059
|
+
break;
|
|
5060
|
+
} else {
|
|
5061
|
+
const line = chunk.slice(searchIndex, lineEnd);
|
|
5062
|
+
lines.push(line), searchIndex = lineEnd + 1, chunk[searchIndex - 1] === "\r" && chunk[searchIndex] === `
|
|
5063
|
+
` && searchIndex++;
|
|
5064
|
+
}
|
|
5065
|
+
}
|
|
5066
|
+
return [lines, incompleteLine];
|
|
5129
5067
|
}
|
|
5130
5068
|
var EventSourceParserStream = class extends TransformStream {
|
|
5131
5069
|
constructor({ onError, onRetry, onComment } = {}) {
|
|
@@ -5261,7 +5199,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
5261
5199
|
);
|
|
5262
5200
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
5263
5201
|
}
|
|
5264
|
-
var VERSION = "3.0.
|
|
5202
|
+
var VERSION = "3.0.22";
|
|
5265
5203
|
var getOriginalFetch = () => globalThis.fetch;
|
|
5266
5204
|
var getFromApi = async ({
|
|
5267
5205
|
url,
|
|
@@ -7308,7 +7246,6 @@ async function parseAuthMethod(headers) {
|
|
|
7308
7246
|
var gatewayAuthMethodSchema = lazyValidator(
|
|
7309
7247
|
() => zodSchema(z$1.union([z$1.literal("api-key"), z$1.literal("oidc")]))
|
|
7310
7248
|
);
|
|
7311
|
-
var KNOWN_MODEL_TYPES = ["embedding", "image", "language"];
|
|
7312
7249
|
var GatewayFetchMetadata = class {
|
|
7313
7250
|
constructor(config) {
|
|
7314
7251
|
this.config = config;
|
|
@@ -7379,12 +7316,8 @@ var gatewayAvailableModelsResponseSchema = lazyValidator(
|
|
|
7379
7316
|
provider: z$1.string(),
|
|
7380
7317
|
modelId: z$1.string()
|
|
7381
7318
|
}),
|
|
7382
|
-
modelType: z$1.
|
|
7319
|
+
modelType: z$1.enum(["language", "embedding", "image"]).nullish()
|
|
7383
7320
|
})
|
|
7384
|
-
).transform(
|
|
7385
|
-
(models) => models.filter(
|
|
7386
|
-
(m) => m.modelType == null || KNOWN_MODEL_TYPES.includes(m.modelType)
|
|
7387
|
-
)
|
|
7388
7321
|
)
|
|
7389
7322
|
})
|
|
7390
7323
|
)
|
|
@@ -7400,187 +7333,6 @@ var gatewayCreditsResponseSchema = lazyValidator(
|
|
|
7400
7333
|
}))
|
|
7401
7334
|
)
|
|
7402
7335
|
);
|
|
7403
|
-
var GatewaySpendReport = class {
|
|
7404
|
-
constructor(config) {
|
|
7405
|
-
this.config = config;
|
|
7406
|
-
}
|
|
7407
|
-
async getSpendReport(params) {
|
|
7408
|
-
try {
|
|
7409
|
-
const baseUrl = new URL(this.config.baseURL);
|
|
7410
|
-
const searchParams = new URLSearchParams();
|
|
7411
|
-
searchParams.set("start_date", params.startDate);
|
|
7412
|
-
searchParams.set("end_date", params.endDate);
|
|
7413
|
-
if (params.groupBy) {
|
|
7414
|
-
searchParams.set("group_by", params.groupBy);
|
|
7415
|
-
}
|
|
7416
|
-
if (params.datePart) {
|
|
7417
|
-
searchParams.set("date_part", params.datePart);
|
|
7418
|
-
}
|
|
7419
|
-
if (params.userId) {
|
|
7420
|
-
searchParams.set("user_id", params.userId);
|
|
7421
|
-
}
|
|
7422
|
-
if (params.model) {
|
|
7423
|
-
searchParams.set("model", params.model);
|
|
7424
|
-
}
|
|
7425
|
-
if (params.provider) {
|
|
7426
|
-
searchParams.set("provider", params.provider);
|
|
7427
|
-
}
|
|
7428
|
-
if (params.credentialType) {
|
|
7429
|
-
searchParams.set("credential_type", params.credentialType);
|
|
7430
|
-
}
|
|
7431
|
-
if (params.tags && params.tags.length > 0) {
|
|
7432
|
-
searchParams.set("tags", params.tags.join(","));
|
|
7433
|
-
}
|
|
7434
|
-
const { value } = await getFromApi({
|
|
7435
|
-
url: `${baseUrl.origin}/v1/report?${searchParams.toString()}`,
|
|
7436
|
-
headers: await resolve4(this.config.headers()),
|
|
7437
|
-
successfulResponseHandler: createJsonResponseHandler(
|
|
7438
|
-
gatewaySpendReportResponseSchema
|
|
7439
|
-
),
|
|
7440
|
-
failedResponseHandler: createJsonErrorResponseHandler({
|
|
7441
|
-
errorSchema: z$1.any(),
|
|
7442
|
-
errorToMessage: (data) => data
|
|
7443
|
-
}),
|
|
7444
|
-
fetch: this.config.fetch
|
|
7445
|
-
});
|
|
7446
|
-
return value;
|
|
7447
|
-
} catch (error) {
|
|
7448
|
-
throw await asGatewayError(error);
|
|
7449
|
-
}
|
|
7450
|
-
}
|
|
7451
|
-
};
|
|
7452
|
-
var gatewaySpendReportResponseSchema = lazySchema(
|
|
7453
|
-
() => zodSchema(
|
|
7454
|
-
z$1.object({
|
|
7455
|
-
results: z$1.array(
|
|
7456
|
-
z$1.object({
|
|
7457
|
-
day: z$1.string().optional(),
|
|
7458
|
-
hour: z$1.string().optional(),
|
|
7459
|
-
user: z$1.string().optional(),
|
|
7460
|
-
model: z$1.string().optional(),
|
|
7461
|
-
tag: z$1.string().optional(),
|
|
7462
|
-
provider: z$1.string().optional(),
|
|
7463
|
-
credential_type: z$1.enum(["byok", "system"]).optional(),
|
|
7464
|
-
total_cost: z$1.number(),
|
|
7465
|
-
market_cost: z$1.number().optional(),
|
|
7466
|
-
input_tokens: z$1.number().optional(),
|
|
7467
|
-
output_tokens: z$1.number().optional(),
|
|
7468
|
-
cached_input_tokens: z$1.number().optional(),
|
|
7469
|
-
cache_creation_input_tokens: z$1.number().optional(),
|
|
7470
|
-
reasoning_tokens: z$1.number().optional(),
|
|
7471
|
-
request_count: z$1.number().optional()
|
|
7472
|
-
}).transform(
|
|
7473
|
-
({
|
|
7474
|
-
credential_type,
|
|
7475
|
-
total_cost,
|
|
7476
|
-
market_cost,
|
|
7477
|
-
input_tokens,
|
|
7478
|
-
output_tokens,
|
|
7479
|
-
cached_input_tokens,
|
|
7480
|
-
cache_creation_input_tokens,
|
|
7481
|
-
reasoning_tokens,
|
|
7482
|
-
request_count,
|
|
7483
|
-
...rest
|
|
7484
|
-
}) => ({
|
|
7485
|
-
...rest,
|
|
7486
|
-
...credential_type !== void 0 ? { credentialType: credential_type } : {},
|
|
7487
|
-
totalCost: total_cost,
|
|
7488
|
-
...market_cost !== void 0 ? { marketCost: market_cost } : {},
|
|
7489
|
-
...input_tokens !== void 0 ? { inputTokens: input_tokens } : {},
|
|
7490
|
-
...output_tokens !== void 0 ? { outputTokens: output_tokens } : {},
|
|
7491
|
-
...cached_input_tokens !== void 0 ? { cachedInputTokens: cached_input_tokens } : {},
|
|
7492
|
-
...cache_creation_input_tokens !== void 0 ? { cacheCreationInputTokens: cache_creation_input_tokens } : {},
|
|
7493
|
-
...reasoning_tokens !== void 0 ? { reasoningTokens: reasoning_tokens } : {},
|
|
7494
|
-
...request_count !== void 0 ? { requestCount: request_count } : {}
|
|
7495
|
-
})
|
|
7496
|
-
)
|
|
7497
|
-
)
|
|
7498
|
-
})
|
|
7499
|
-
)
|
|
7500
|
-
);
|
|
7501
|
-
var GatewayGenerationInfoFetcher = class {
|
|
7502
|
-
constructor(config) {
|
|
7503
|
-
this.config = config;
|
|
7504
|
-
}
|
|
7505
|
-
async getGenerationInfo(params) {
|
|
7506
|
-
try {
|
|
7507
|
-
const baseUrl = new URL(this.config.baseURL);
|
|
7508
|
-
const { value } = await getFromApi({
|
|
7509
|
-
url: `${baseUrl.origin}/v1/generation?id=${encodeURIComponent(params.id)}`,
|
|
7510
|
-
headers: await resolve4(this.config.headers()),
|
|
7511
|
-
successfulResponseHandler: createJsonResponseHandler(
|
|
7512
|
-
gatewayGenerationInfoResponseSchema
|
|
7513
|
-
),
|
|
7514
|
-
failedResponseHandler: createJsonErrorResponseHandler({
|
|
7515
|
-
errorSchema: z$1.any(),
|
|
7516
|
-
errorToMessage: (data) => data
|
|
7517
|
-
}),
|
|
7518
|
-
fetch: this.config.fetch
|
|
7519
|
-
});
|
|
7520
|
-
return value;
|
|
7521
|
-
} catch (error) {
|
|
7522
|
-
throw await asGatewayError(error);
|
|
7523
|
-
}
|
|
7524
|
-
}
|
|
7525
|
-
};
|
|
7526
|
-
var gatewayGenerationInfoResponseSchema = lazySchema(
|
|
7527
|
-
() => zodSchema(
|
|
7528
|
-
z$1.object({
|
|
7529
|
-
data: z$1.object({
|
|
7530
|
-
id: z$1.string(),
|
|
7531
|
-
total_cost: z$1.number(),
|
|
7532
|
-
upstream_inference_cost: z$1.number(),
|
|
7533
|
-
usage: z$1.number(),
|
|
7534
|
-
created_at: z$1.string(),
|
|
7535
|
-
model: z$1.string(),
|
|
7536
|
-
is_byok: z$1.boolean(),
|
|
7537
|
-
provider_name: z$1.string(),
|
|
7538
|
-
streamed: z$1.boolean(),
|
|
7539
|
-
finish_reason: z$1.string(),
|
|
7540
|
-
latency: z$1.number(),
|
|
7541
|
-
generation_time: z$1.number(),
|
|
7542
|
-
native_tokens_prompt: z$1.number(),
|
|
7543
|
-
native_tokens_completion: z$1.number(),
|
|
7544
|
-
native_tokens_reasoning: z$1.number(),
|
|
7545
|
-
native_tokens_cached: z$1.number(),
|
|
7546
|
-
native_tokens_cache_creation: z$1.number(),
|
|
7547
|
-
billable_web_search_calls: z$1.number()
|
|
7548
|
-
}).transform(
|
|
7549
|
-
({
|
|
7550
|
-
total_cost,
|
|
7551
|
-
upstream_inference_cost,
|
|
7552
|
-
created_at,
|
|
7553
|
-
is_byok,
|
|
7554
|
-
provider_name,
|
|
7555
|
-
finish_reason,
|
|
7556
|
-
generation_time,
|
|
7557
|
-
native_tokens_prompt,
|
|
7558
|
-
native_tokens_completion,
|
|
7559
|
-
native_tokens_reasoning,
|
|
7560
|
-
native_tokens_cached,
|
|
7561
|
-
native_tokens_cache_creation,
|
|
7562
|
-
billable_web_search_calls,
|
|
7563
|
-
...rest
|
|
7564
|
-
}) => ({
|
|
7565
|
-
...rest,
|
|
7566
|
-
totalCost: total_cost,
|
|
7567
|
-
upstreamInferenceCost: upstream_inference_cost,
|
|
7568
|
-
createdAt: created_at,
|
|
7569
|
-
isByok: is_byok,
|
|
7570
|
-
providerName: provider_name,
|
|
7571
|
-
finishReason: finish_reason,
|
|
7572
|
-
generationTime: generation_time,
|
|
7573
|
-
promptTokens: native_tokens_prompt,
|
|
7574
|
-
completionTokens: native_tokens_completion,
|
|
7575
|
-
reasoningTokens: native_tokens_reasoning,
|
|
7576
|
-
cachedTokens: native_tokens_cached,
|
|
7577
|
-
cacheCreationTokens: native_tokens_cache_creation,
|
|
7578
|
-
billableWebSearchCalls: billable_web_search_calls
|
|
7579
|
-
})
|
|
7580
|
-
)
|
|
7581
|
-
}).transform(({ data }) => data)
|
|
7582
|
-
)
|
|
7583
|
-
);
|
|
7584
7336
|
var GatewayLanguageModel = class {
|
|
7585
7337
|
constructor(modelId, config) {
|
|
7586
7338
|
this.modelId = modelId;
|
|
@@ -8083,7 +7835,7 @@ async function getVercelRequestId() {
|
|
|
8083
7835
|
var _a93;
|
|
8084
7836
|
return (_a93 = getContext().headers) == null ? void 0 : _a93["x-vercel-id"];
|
|
8085
7837
|
}
|
|
8086
|
-
var VERSION2 = "2.0.
|
|
7838
|
+
var VERSION2 = "2.0.59";
|
|
8087
7839
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
8088
7840
|
function createGatewayProvider(options = {}) {
|
|
8089
7841
|
var _a93, _b92;
|
|
@@ -8181,30 +7933,6 @@ function createGatewayProvider(options = {}) {
|
|
|
8181
7933
|
);
|
|
8182
7934
|
});
|
|
8183
7935
|
};
|
|
8184
|
-
const getSpendReport = async (params) => {
|
|
8185
|
-
return new GatewaySpendReport({
|
|
8186
|
-
baseURL,
|
|
8187
|
-
headers: getHeaders,
|
|
8188
|
-
fetch: options.fetch
|
|
8189
|
-
}).getSpendReport(params).catch(async (error) => {
|
|
8190
|
-
throw await asGatewayError(
|
|
8191
|
-
error,
|
|
8192
|
-
await parseAuthMethod(await getHeaders())
|
|
8193
|
-
);
|
|
8194
|
-
});
|
|
8195
|
-
};
|
|
8196
|
-
const getGenerationInfo = async (params) => {
|
|
8197
|
-
return new GatewayGenerationInfoFetcher({
|
|
8198
|
-
baseURL,
|
|
8199
|
-
headers: getHeaders,
|
|
8200
|
-
fetch: options.fetch
|
|
8201
|
-
}).getGenerationInfo(params).catch(async (error) => {
|
|
8202
|
-
throw await asGatewayError(
|
|
8203
|
-
error,
|
|
8204
|
-
await parseAuthMethod(await getHeaders())
|
|
8205
|
-
);
|
|
8206
|
-
});
|
|
8207
|
-
};
|
|
8208
7936
|
const provider = function(modelId) {
|
|
8209
7937
|
if (new.target) {
|
|
8210
7938
|
throw new Error(
|
|
@@ -8215,8 +7943,6 @@ function createGatewayProvider(options = {}) {
|
|
|
8215
7943
|
};
|
|
8216
7944
|
provider.getAvailableModels = getAvailableModels;
|
|
8217
7945
|
provider.getCredits = getCredits;
|
|
8218
|
-
provider.getSpendReport = getSpendReport;
|
|
8219
|
-
provider.getGenerationInfo = getGenerationInfo;
|
|
8220
7946
|
provider.imageModel = (modelId) => {
|
|
8221
7947
|
return new GatewayImageModel(modelId, {
|
|
8222
7948
|
provider: "gateway",
|