@mastra/agent-builder 0.0.0-studio-deploy-20260404182525 → 0.0.0-studio-cli-20260504022012
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 +267 -4
- package/dist/index.js +229 -138
- package/dist/index.js.map +1 -1
- package/package.json +19 -19
- package/dist/chunk-DAXABV7F.js +0 -84
- package/dist/chunk-DAXABV7F.js.map +0 -1
- package/dist/chunk-XAK5QGHN.js +0 -439
- package/dist/chunk-XAK5QGHN.js.map +0 -1
- package/dist/token-APYSY3BW-IQ2CXU3Y.js +0 -61
- package/dist/token-APYSY3BW-IQ2CXU3Y.js.map +0 -1
- package/dist/token-util-RMHT2CPJ-Z4NYHFEI.js +0 -9
- package/dist/token-util-RMHT2CPJ-Z4NYHFEI.js.map +0 -1
package/dist/index.js
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
import { __commonJS, require_token_error, __toESM } from './chunk-DAXABV7F.js';
|
|
2
1
|
import { Agent, isSupportedLanguageModel, tryGenerateWithJsonFallback, tryStreamWithJsonFallback } from '@mastra/core/agent';
|
|
3
2
|
import { InMemoryStore } from '@mastra/core/storage';
|
|
4
3
|
import { Memory } from '@mastra/memory';
|
|
@@ -21,6 +20,7 @@ import * as z4 from 'zod/v4';
|
|
|
21
20
|
import { z as z$1 } from 'zod/v4';
|
|
22
21
|
import { ZodFirstPartyTypeKind } from 'zod/v3';
|
|
23
22
|
|
|
23
|
+
// src/agent/index.ts
|
|
24
24
|
var UNIT_KINDS = ["mcp-server", "tool", "workflow", "agent", "integration", "network", "other"];
|
|
25
25
|
var TemplateUnitSchema = z.object({
|
|
26
26
|
kind: z.enum(UNIT_KINDS),
|
|
@@ -1828,7 +1828,7 @@ export const mastra = new Mastra({
|
|
|
1828
1828
|
const output = data.toString();
|
|
1829
1829
|
const lines = output.split("\n").filter((line) => line.trim());
|
|
1830
1830
|
stdoutLines.push(...lines);
|
|
1831
|
-
if (output.includes("Mastra API running
|
|
1831
|
+
if (output.includes("Mastra API running")) {
|
|
1832
1832
|
clearTimeout(timeout);
|
|
1833
1833
|
resolve5({
|
|
1834
1834
|
success: true,
|
|
@@ -5199,7 +5199,7 @@ function withUserAgentSuffix(headers, ...userAgentSuffixParts) {
|
|
|
5199
5199
|
);
|
|
5200
5200
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
5201
5201
|
}
|
|
5202
|
-
var VERSION = "3.0.
|
|
5202
|
+
var VERSION = "3.0.23";
|
|
5203
5203
|
var getOriginalFetch = () => globalThis.fetch;
|
|
5204
5204
|
var getFromApi = async ({
|
|
5205
5205
|
url,
|
|
@@ -6861,138 +6861,17 @@ function asSchema(schema) {
|
|
|
6861
6861
|
function withoutTrailingSlash(url) {
|
|
6862
6862
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
6863
6863
|
}
|
|
6864
|
-
|
|
6865
|
-
|
|
6866
|
-
|
|
6867
|
-
|
|
6868
|
-
|
|
6869
|
-
|
|
6870
|
-
|
|
6871
|
-
|
|
6872
|
-
__defProp2(target, name16, { get: all[name16], enumerable: true });
|
|
6873
|
-
};
|
|
6874
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6875
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
6876
|
-
for (let key of __getOwnPropNames(from))
|
|
6877
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
6878
|
-
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
6879
|
-
}
|
|
6880
|
-
return to;
|
|
6881
|
-
};
|
|
6882
|
-
var __toCommonJS = (mod) => __copyProps(__defProp2({}, "__esModule", { value: true }), mod);
|
|
6883
|
-
var get_context_exports = {};
|
|
6884
|
-
__export2(get_context_exports, {
|
|
6885
|
-
SYMBOL_FOR_REQ_CONTEXT: () => SYMBOL_FOR_REQ_CONTEXT,
|
|
6886
|
-
getContext: () => getContext3
|
|
6887
|
-
});
|
|
6888
|
-
module.exports = __toCommonJS(get_context_exports);
|
|
6889
|
-
var SYMBOL_FOR_REQ_CONTEXT = /* @__PURE__ */ Symbol.for("@vercel/request-context");
|
|
6890
|
-
function getContext3() {
|
|
6891
|
-
const fromSymbol = globalThis;
|
|
6892
|
-
return fromSymbol[SYMBOL_FOR_REQ_CONTEXT]?.get?.() ?? {};
|
|
6893
|
-
}
|
|
6894
|
-
}
|
|
6895
|
-
});
|
|
6896
|
-
var require_get_vercel_oidc_token = __commonJS({
|
|
6897
|
-
"../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports$1, module) {
|
|
6898
|
-
var __defProp2 = Object.defineProperty;
|
|
6899
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6900
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6901
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6902
|
-
var __export2 = (target, all) => {
|
|
6903
|
-
for (var name16 in all)
|
|
6904
|
-
__defProp2(target, name16, { get: all[name16], enumerable: true });
|
|
6905
|
-
};
|
|
6906
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6907
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
6908
|
-
for (let key of __getOwnPropNames(from))
|
|
6909
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
6910
|
-
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
6911
|
-
}
|
|
6912
|
-
return to;
|
|
6913
|
-
};
|
|
6914
|
-
var __toCommonJS = (mod) => __copyProps(__defProp2({}, "__esModule", { value: true }), mod);
|
|
6915
|
-
var get_vercel_oidc_token_exports = {};
|
|
6916
|
-
__export2(get_vercel_oidc_token_exports, {
|
|
6917
|
-
getVercelOidcToken: () => getVercelOidcToken3,
|
|
6918
|
-
getVercelOidcTokenSync: () => getVercelOidcTokenSync2
|
|
6919
|
-
});
|
|
6920
|
-
module.exports = __toCommonJS(get_vercel_oidc_token_exports);
|
|
6921
|
-
var import_get_context = require_get_context();
|
|
6922
|
-
var import_token_error = require_token_error();
|
|
6923
|
-
async function getVercelOidcToken3() {
|
|
6924
|
-
let token = "";
|
|
6925
|
-
let err;
|
|
6926
|
-
try {
|
|
6927
|
-
token = getVercelOidcTokenSync2();
|
|
6928
|
-
} catch (error) {
|
|
6929
|
-
err = error;
|
|
6930
|
-
}
|
|
6931
|
-
try {
|
|
6932
|
-
const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
|
|
6933
|
-
await import('./token-util-RMHT2CPJ-Z4NYHFEI.js'),
|
|
6934
|
-
await import('./token-APYSY3BW-IQ2CXU3Y.js')
|
|
6935
|
-
]);
|
|
6936
|
-
if (!token || isExpired(getTokenPayload(token))) {
|
|
6937
|
-
await refreshToken();
|
|
6938
|
-
token = getVercelOidcTokenSync2();
|
|
6939
|
-
}
|
|
6940
|
-
} catch (error) {
|
|
6941
|
-
let message = err instanceof Error ? err.message : "";
|
|
6942
|
-
if (error instanceof Error) {
|
|
6943
|
-
message = `${message}
|
|
6944
|
-
${error.message}`;
|
|
6945
|
-
}
|
|
6946
|
-
if (message) {
|
|
6947
|
-
throw new import_token_error.VercelOidcTokenError(message);
|
|
6948
|
-
}
|
|
6949
|
-
throw error;
|
|
6950
|
-
}
|
|
6951
|
-
return token;
|
|
6952
|
-
}
|
|
6953
|
-
function getVercelOidcTokenSync2() {
|
|
6954
|
-
const token = (0, import_get_context.getContext)().headers?.["x-vercel-oidc-token"] ?? process.env.VERCEL_OIDC_TOKEN;
|
|
6955
|
-
if (!token) {
|
|
6956
|
-
throw new Error(
|
|
6957
|
-
`The 'x-vercel-oidc-token' header is missing from the request. Do you have the OIDC option enabled in the Vercel project settings?`
|
|
6958
|
-
);
|
|
6959
|
-
}
|
|
6960
|
-
return token;
|
|
6961
|
-
}
|
|
6962
|
-
}
|
|
6963
|
-
});
|
|
6964
|
-
var require_dist = __commonJS({
|
|
6965
|
-
"../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/index.js"(exports$1, module) {
|
|
6966
|
-
var __defProp2 = Object.defineProperty;
|
|
6967
|
-
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
6968
|
-
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6969
|
-
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6970
|
-
var __export2 = (target, all) => {
|
|
6971
|
-
for (var name16 in all)
|
|
6972
|
-
__defProp2(target, name16, { get: all[name16], enumerable: true });
|
|
6973
|
-
};
|
|
6974
|
-
var __copyProps = (to, from, except, desc) => {
|
|
6975
|
-
if (from && typeof from === "object" || typeof from === "function") {
|
|
6976
|
-
for (let key of __getOwnPropNames(from))
|
|
6977
|
-
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
6978
|
-
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
6979
|
-
}
|
|
6980
|
-
return to;
|
|
6981
|
-
};
|
|
6982
|
-
var __toCommonJS = (mod) => __copyProps(__defProp2({}, "__esModule", { value: true }), mod);
|
|
6983
|
-
var src_exports = {};
|
|
6984
|
-
__export2(src_exports, {
|
|
6985
|
-
getContext: () => import_get_context.getContext,
|
|
6986
|
-
getVercelOidcToken: () => import_get_vercel_oidc_token.getVercelOidcToken,
|
|
6987
|
-
getVercelOidcTokenSync: () => import_get_vercel_oidc_token.getVercelOidcTokenSync
|
|
6988
|
-
});
|
|
6989
|
-
module.exports = __toCommonJS(src_exports);
|
|
6990
|
-
var import_get_vercel_oidc_token = require_get_vercel_oidc_token();
|
|
6991
|
-
var import_get_context = require_get_context();
|
|
6864
|
+
function getContext() {
|
|
6865
|
+
return {
|
|
6866
|
+
headers: {}
|
|
6867
|
+
};
|
|
6868
|
+
}
|
|
6869
|
+
async function getVercelOidcToken() {
|
|
6870
|
+
if (process.env.VERCEL_OIDC_TOKEN) {
|
|
6871
|
+
return process.env.VERCEL_OIDC_TOKEN ?? "";
|
|
6992
6872
|
}
|
|
6993
|
-
|
|
6994
|
-
|
|
6995
|
-
var import_oidc2 = __toESM(require_dist(), 1);
|
|
6873
|
+
throw new Error("@vercel/oidc is not available in the vendored @internal AI packages. Provide an API key instead.");
|
|
6874
|
+
}
|
|
6996
6875
|
var marker16 = "vercel.ai.gateway.error";
|
|
6997
6876
|
var symbol16 = Symbol.for(marker16);
|
|
6998
6877
|
var _a16;
|
|
@@ -7367,6 +7246,7 @@ async function parseAuthMethod(headers) {
|
|
|
7367
7246
|
var gatewayAuthMethodSchema = lazyValidator(
|
|
7368
7247
|
() => zodSchema(z$1.union([z$1.literal("api-key"), z$1.literal("oidc")]))
|
|
7369
7248
|
);
|
|
7249
|
+
var KNOWN_MODEL_TYPES = ["embedding", "image", "language"];
|
|
7370
7250
|
var GatewayFetchMetadata = class {
|
|
7371
7251
|
constructor(config) {
|
|
7372
7252
|
this.config = config;
|
|
@@ -7437,8 +7317,12 @@ var gatewayAvailableModelsResponseSchema = lazyValidator(
|
|
|
7437
7317
|
provider: z$1.string(),
|
|
7438
7318
|
modelId: z$1.string()
|
|
7439
7319
|
}),
|
|
7440
|
-
modelType: z$1.
|
|
7320
|
+
modelType: z$1.string().nullish()
|
|
7441
7321
|
})
|
|
7322
|
+
).transform(
|
|
7323
|
+
(models) => models.filter(
|
|
7324
|
+
(m) => m.modelType == null || KNOWN_MODEL_TYPES.includes(m.modelType)
|
|
7325
|
+
)
|
|
7442
7326
|
)
|
|
7443
7327
|
})
|
|
7444
7328
|
)
|
|
@@ -7454,6 +7338,187 @@ var gatewayCreditsResponseSchema = lazyValidator(
|
|
|
7454
7338
|
}))
|
|
7455
7339
|
)
|
|
7456
7340
|
);
|
|
7341
|
+
var GatewaySpendReport = class {
|
|
7342
|
+
constructor(config) {
|
|
7343
|
+
this.config = config;
|
|
7344
|
+
}
|
|
7345
|
+
async getSpendReport(params) {
|
|
7346
|
+
try {
|
|
7347
|
+
const baseUrl = new URL(this.config.baseURL);
|
|
7348
|
+
const searchParams = new URLSearchParams();
|
|
7349
|
+
searchParams.set("start_date", params.startDate);
|
|
7350
|
+
searchParams.set("end_date", params.endDate);
|
|
7351
|
+
if (params.groupBy) {
|
|
7352
|
+
searchParams.set("group_by", params.groupBy);
|
|
7353
|
+
}
|
|
7354
|
+
if (params.datePart) {
|
|
7355
|
+
searchParams.set("date_part", params.datePart);
|
|
7356
|
+
}
|
|
7357
|
+
if (params.userId) {
|
|
7358
|
+
searchParams.set("user_id", params.userId);
|
|
7359
|
+
}
|
|
7360
|
+
if (params.model) {
|
|
7361
|
+
searchParams.set("model", params.model);
|
|
7362
|
+
}
|
|
7363
|
+
if (params.provider) {
|
|
7364
|
+
searchParams.set("provider", params.provider);
|
|
7365
|
+
}
|
|
7366
|
+
if (params.credentialType) {
|
|
7367
|
+
searchParams.set("credential_type", params.credentialType);
|
|
7368
|
+
}
|
|
7369
|
+
if (params.tags && params.tags.length > 0) {
|
|
7370
|
+
searchParams.set("tags", params.tags.join(","));
|
|
7371
|
+
}
|
|
7372
|
+
const { value } = await getFromApi({
|
|
7373
|
+
url: `${baseUrl.origin}/v1/report?${searchParams.toString()}`,
|
|
7374
|
+
headers: await resolve4(this.config.headers()),
|
|
7375
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
7376
|
+
gatewaySpendReportResponseSchema
|
|
7377
|
+
),
|
|
7378
|
+
failedResponseHandler: createJsonErrorResponseHandler({
|
|
7379
|
+
errorSchema: z$1.any(),
|
|
7380
|
+
errorToMessage: (data) => data
|
|
7381
|
+
}),
|
|
7382
|
+
fetch: this.config.fetch
|
|
7383
|
+
});
|
|
7384
|
+
return value;
|
|
7385
|
+
} catch (error) {
|
|
7386
|
+
throw await asGatewayError(error);
|
|
7387
|
+
}
|
|
7388
|
+
}
|
|
7389
|
+
};
|
|
7390
|
+
var gatewaySpendReportResponseSchema = lazySchema(
|
|
7391
|
+
() => zodSchema(
|
|
7392
|
+
z$1.object({
|
|
7393
|
+
results: z$1.array(
|
|
7394
|
+
z$1.object({
|
|
7395
|
+
day: z$1.string().optional(),
|
|
7396
|
+
hour: z$1.string().optional(),
|
|
7397
|
+
user: z$1.string().optional(),
|
|
7398
|
+
model: z$1.string().optional(),
|
|
7399
|
+
tag: z$1.string().optional(),
|
|
7400
|
+
provider: z$1.string().optional(),
|
|
7401
|
+
credential_type: z$1.enum(["byok", "system"]).optional(),
|
|
7402
|
+
total_cost: z$1.number(),
|
|
7403
|
+
market_cost: z$1.number().optional(),
|
|
7404
|
+
input_tokens: z$1.number().optional(),
|
|
7405
|
+
output_tokens: z$1.number().optional(),
|
|
7406
|
+
cached_input_tokens: z$1.number().optional(),
|
|
7407
|
+
cache_creation_input_tokens: z$1.number().optional(),
|
|
7408
|
+
reasoning_tokens: z$1.number().optional(),
|
|
7409
|
+
request_count: z$1.number().optional()
|
|
7410
|
+
}).transform(
|
|
7411
|
+
({
|
|
7412
|
+
credential_type,
|
|
7413
|
+
total_cost,
|
|
7414
|
+
market_cost,
|
|
7415
|
+
input_tokens,
|
|
7416
|
+
output_tokens,
|
|
7417
|
+
cached_input_tokens,
|
|
7418
|
+
cache_creation_input_tokens,
|
|
7419
|
+
reasoning_tokens,
|
|
7420
|
+
request_count,
|
|
7421
|
+
...rest
|
|
7422
|
+
}) => ({
|
|
7423
|
+
...rest,
|
|
7424
|
+
...credential_type !== void 0 ? { credentialType: credential_type } : {},
|
|
7425
|
+
totalCost: total_cost,
|
|
7426
|
+
...market_cost !== void 0 ? { marketCost: market_cost } : {},
|
|
7427
|
+
...input_tokens !== void 0 ? { inputTokens: input_tokens } : {},
|
|
7428
|
+
...output_tokens !== void 0 ? { outputTokens: output_tokens } : {},
|
|
7429
|
+
...cached_input_tokens !== void 0 ? { cachedInputTokens: cached_input_tokens } : {},
|
|
7430
|
+
...cache_creation_input_tokens !== void 0 ? { cacheCreationInputTokens: cache_creation_input_tokens } : {},
|
|
7431
|
+
...reasoning_tokens !== void 0 ? { reasoningTokens: reasoning_tokens } : {},
|
|
7432
|
+
...request_count !== void 0 ? { requestCount: request_count } : {}
|
|
7433
|
+
})
|
|
7434
|
+
)
|
|
7435
|
+
)
|
|
7436
|
+
})
|
|
7437
|
+
)
|
|
7438
|
+
);
|
|
7439
|
+
var GatewayGenerationInfoFetcher = class {
|
|
7440
|
+
constructor(config) {
|
|
7441
|
+
this.config = config;
|
|
7442
|
+
}
|
|
7443
|
+
async getGenerationInfo(params) {
|
|
7444
|
+
try {
|
|
7445
|
+
const baseUrl = new URL(this.config.baseURL);
|
|
7446
|
+
const { value } = await getFromApi({
|
|
7447
|
+
url: `${baseUrl.origin}/v1/generation?id=${encodeURIComponent(params.id)}`,
|
|
7448
|
+
headers: await resolve4(this.config.headers()),
|
|
7449
|
+
successfulResponseHandler: createJsonResponseHandler(
|
|
7450
|
+
gatewayGenerationInfoResponseSchema
|
|
7451
|
+
),
|
|
7452
|
+
failedResponseHandler: createJsonErrorResponseHandler({
|
|
7453
|
+
errorSchema: z$1.any(),
|
|
7454
|
+
errorToMessage: (data) => data
|
|
7455
|
+
}),
|
|
7456
|
+
fetch: this.config.fetch
|
|
7457
|
+
});
|
|
7458
|
+
return value;
|
|
7459
|
+
} catch (error) {
|
|
7460
|
+
throw await asGatewayError(error);
|
|
7461
|
+
}
|
|
7462
|
+
}
|
|
7463
|
+
};
|
|
7464
|
+
var gatewayGenerationInfoResponseSchema = lazySchema(
|
|
7465
|
+
() => zodSchema(
|
|
7466
|
+
z$1.object({
|
|
7467
|
+
data: z$1.object({
|
|
7468
|
+
id: z$1.string(),
|
|
7469
|
+
total_cost: z$1.number(),
|
|
7470
|
+
upstream_inference_cost: z$1.number(),
|
|
7471
|
+
usage: z$1.number(),
|
|
7472
|
+
created_at: z$1.string(),
|
|
7473
|
+
model: z$1.string(),
|
|
7474
|
+
is_byok: z$1.boolean(),
|
|
7475
|
+
provider_name: z$1.string(),
|
|
7476
|
+
streamed: z$1.boolean(),
|
|
7477
|
+
finish_reason: z$1.string(),
|
|
7478
|
+
latency: z$1.number(),
|
|
7479
|
+
generation_time: z$1.number(),
|
|
7480
|
+
native_tokens_prompt: z$1.number(),
|
|
7481
|
+
native_tokens_completion: z$1.number(),
|
|
7482
|
+
native_tokens_reasoning: z$1.number(),
|
|
7483
|
+
native_tokens_cached: z$1.number(),
|
|
7484
|
+
native_tokens_cache_creation: z$1.number(),
|
|
7485
|
+
billable_web_search_calls: z$1.number()
|
|
7486
|
+
}).transform(
|
|
7487
|
+
({
|
|
7488
|
+
total_cost,
|
|
7489
|
+
upstream_inference_cost,
|
|
7490
|
+
created_at,
|
|
7491
|
+
is_byok,
|
|
7492
|
+
provider_name,
|
|
7493
|
+
finish_reason,
|
|
7494
|
+
generation_time,
|
|
7495
|
+
native_tokens_prompt,
|
|
7496
|
+
native_tokens_completion,
|
|
7497
|
+
native_tokens_reasoning,
|
|
7498
|
+
native_tokens_cached,
|
|
7499
|
+
native_tokens_cache_creation,
|
|
7500
|
+
billable_web_search_calls,
|
|
7501
|
+
...rest
|
|
7502
|
+
}) => ({
|
|
7503
|
+
...rest,
|
|
7504
|
+
totalCost: total_cost,
|
|
7505
|
+
upstreamInferenceCost: upstream_inference_cost,
|
|
7506
|
+
createdAt: created_at,
|
|
7507
|
+
isByok: is_byok,
|
|
7508
|
+
providerName: provider_name,
|
|
7509
|
+
finishReason: finish_reason,
|
|
7510
|
+
generationTime: generation_time,
|
|
7511
|
+
promptTokens: native_tokens_prompt,
|
|
7512
|
+
completionTokens: native_tokens_completion,
|
|
7513
|
+
reasoningTokens: native_tokens_reasoning,
|
|
7514
|
+
cachedTokens: native_tokens_cached,
|
|
7515
|
+
cacheCreationTokens: native_tokens_cache_creation,
|
|
7516
|
+
billableWebSearchCalls: billable_web_search_calls
|
|
7517
|
+
})
|
|
7518
|
+
)
|
|
7519
|
+
}).transform(({ data }) => data)
|
|
7520
|
+
)
|
|
7521
|
+
);
|
|
7457
7522
|
var GatewayLanguageModel = class {
|
|
7458
7523
|
constructor(modelId, config) {
|
|
7459
7524
|
this.modelId = modelId;
|
|
@@ -7954,9 +8019,9 @@ var gatewayTools = {
|
|
|
7954
8019
|
};
|
|
7955
8020
|
async function getVercelRequestId() {
|
|
7956
8021
|
var _a93;
|
|
7957
|
-
return (_a93 =
|
|
8022
|
+
return (_a93 = getContext().headers) == null ? void 0 : _a93["x-vercel-id"];
|
|
7958
8023
|
}
|
|
7959
|
-
var VERSION2 = "2.0.
|
|
8024
|
+
var VERSION2 = "2.0.82";
|
|
7960
8025
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
7961
8026
|
function createGatewayProvider(options = {}) {
|
|
7962
8027
|
var _a93, _b92;
|
|
@@ -8054,6 +8119,30 @@ function createGatewayProvider(options = {}) {
|
|
|
8054
8119
|
);
|
|
8055
8120
|
});
|
|
8056
8121
|
};
|
|
8122
|
+
const getSpendReport = async (params) => {
|
|
8123
|
+
return new GatewaySpendReport({
|
|
8124
|
+
baseURL,
|
|
8125
|
+
headers: getHeaders,
|
|
8126
|
+
fetch: options.fetch
|
|
8127
|
+
}).getSpendReport(params).catch(async (error) => {
|
|
8128
|
+
throw await asGatewayError(
|
|
8129
|
+
error,
|
|
8130
|
+
await parseAuthMethod(await getHeaders())
|
|
8131
|
+
);
|
|
8132
|
+
});
|
|
8133
|
+
};
|
|
8134
|
+
const getGenerationInfo = async (params) => {
|
|
8135
|
+
return new GatewayGenerationInfoFetcher({
|
|
8136
|
+
baseURL,
|
|
8137
|
+
headers: getHeaders,
|
|
8138
|
+
fetch: options.fetch
|
|
8139
|
+
}).getGenerationInfo(params).catch(async (error) => {
|
|
8140
|
+
throw await asGatewayError(
|
|
8141
|
+
error,
|
|
8142
|
+
await parseAuthMethod(await getHeaders())
|
|
8143
|
+
);
|
|
8144
|
+
});
|
|
8145
|
+
};
|
|
8057
8146
|
const provider = function(modelId) {
|
|
8058
8147
|
if (new.target) {
|
|
8059
8148
|
throw new Error(
|
|
@@ -8064,6 +8153,8 @@ function createGatewayProvider(options = {}) {
|
|
|
8064
8153
|
};
|
|
8065
8154
|
provider.getAvailableModels = getAvailableModels;
|
|
8066
8155
|
provider.getCredits = getCredits;
|
|
8156
|
+
provider.getSpendReport = getSpendReport;
|
|
8157
|
+
provider.getGenerationInfo = getGenerationInfo;
|
|
8067
8158
|
provider.imageModel = (modelId) => {
|
|
8068
8159
|
return new GatewayImageModel(modelId, {
|
|
8069
8160
|
provider: "gateway",
|
|
@@ -8099,7 +8190,7 @@ async function getGatewayAuthToken(options) {
|
|
|
8099
8190
|
};
|
|
8100
8191
|
}
|
|
8101
8192
|
try {
|
|
8102
|
-
const oidcToken = await
|
|
8193
|
+
const oidcToken = await getVercelOidcToken();
|
|
8103
8194
|
return {
|
|
8104
8195
|
token: oidcToken,
|
|
8105
8196
|
authMethod: "oidc"
|