@proxysoul/soulforge 2.12.3 → 2.13.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/dist/index.js +15329 -8052
- package/dist/workers/intelligence.worker.js +11342 -5544
- package/dist/workers/io.worker.js +1340 -371
- package/package.json +19 -19
|
@@ -23093,13 +23093,14 @@ var require_auth_config = __commonJS((exports, module) => {
|
|
|
23093
23093
|
}
|
|
23094
23094
|
fs.writeFileSync(authPath, JSON.stringify(config2, null, 2), { mode: 384 });
|
|
23095
23095
|
}
|
|
23096
|
-
function isValidAccessToken(authConfig) {
|
|
23096
|
+
function isValidAccessToken(authConfig, expirationBufferMs = 0) {
|
|
23097
23097
|
if (!authConfig.token)
|
|
23098
23098
|
return false;
|
|
23099
23099
|
if (typeof authConfig.expiresAt !== "number")
|
|
23100
23100
|
return true;
|
|
23101
23101
|
const nowInSeconds = Math.floor(Date.now() / 1000);
|
|
23102
|
-
|
|
23102
|
+
const bufferInSeconds = expirationBufferMs / 1000;
|
|
23103
|
+
return authConfig.expiresAt >= nowInSeconds + bufferInSeconds;
|
|
23103
23104
|
}
|
|
23104
23105
|
});
|
|
23105
23106
|
|
|
@@ -23189,6 +23190,47 @@ var require_oauth = __commonJS((exports, module) => {
|
|
|
23189
23190
|
}
|
|
23190
23191
|
});
|
|
23191
23192
|
|
|
23193
|
+
// node_modules/@vercel/oidc/dist/auth-errors.js
|
|
23194
|
+
var require_auth_errors = __commonJS((exports, module) => {
|
|
23195
|
+
var __defProp2 = Object.defineProperty;
|
|
23196
|
+
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
23197
|
+
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
23198
|
+
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
23199
|
+
var __export2 = (target, all) => {
|
|
23200
|
+
for (var name15 in all)
|
|
23201
|
+
__defProp2(target, name15, { get: all[name15], enumerable: true });
|
|
23202
|
+
};
|
|
23203
|
+
var __copyProps = (to, from, except, desc) => {
|
|
23204
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
23205
|
+
for (let key of __getOwnPropNames2(from))
|
|
23206
|
+
if (!__hasOwnProp2.call(to, key) && key !== except)
|
|
23207
|
+
__defProp2(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc2(from, key)) || desc.enumerable });
|
|
23208
|
+
}
|
|
23209
|
+
return to;
|
|
23210
|
+
};
|
|
23211
|
+
var __toCommonJS2 = (mod) => __copyProps(__defProp2({}, "__esModule", { value: true }), mod);
|
|
23212
|
+
var auth_errors_exports = {};
|
|
23213
|
+
__export2(auth_errors_exports, {
|
|
23214
|
+
AccessTokenMissingError: () => AccessTokenMissingError2,
|
|
23215
|
+
RefreshAccessTokenFailedError: () => RefreshAccessTokenFailedError2
|
|
23216
|
+
});
|
|
23217
|
+
module.exports = __toCommonJS2(auth_errors_exports);
|
|
23218
|
+
|
|
23219
|
+
class AccessTokenMissingError2 extends Error {
|
|
23220
|
+
constructor() {
|
|
23221
|
+
super("No authentication found. Please log in with the Vercel CLI (vercel login).");
|
|
23222
|
+
this.name = "AccessTokenMissingError";
|
|
23223
|
+
}
|
|
23224
|
+
}
|
|
23225
|
+
|
|
23226
|
+
class RefreshAccessTokenFailedError2 extends Error {
|
|
23227
|
+
constructor(cause) {
|
|
23228
|
+
super("Failed to refresh authentication token.", { cause });
|
|
23229
|
+
this.name = "RefreshAccessTokenFailedError";
|
|
23230
|
+
}
|
|
23231
|
+
}
|
|
23232
|
+
});
|
|
23233
|
+
|
|
23192
23234
|
// node_modules/@vercel/oidc/dist/token-util.js
|
|
23193
23235
|
var require_token_util = __commonJS((exports, module) => {
|
|
23194
23236
|
var __create2 = Object.create;
|
|
@@ -23216,9 +23258,9 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
23216
23258
|
assertVercelOidcTokenResponse: () => assertVercelOidcTokenResponse,
|
|
23217
23259
|
findProjectInfo: () => findProjectInfo,
|
|
23218
23260
|
getTokenPayload: () => getTokenPayload,
|
|
23219
|
-
getVercelCliToken: () => getVercelCliToken,
|
|
23220
23261
|
getVercelDataDir: () => getVercelDataDir,
|
|
23221
23262
|
getVercelOidcToken: () => getVercelOidcToken2,
|
|
23263
|
+
getVercelToken: () => getVercelToken2,
|
|
23222
23264
|
isExpired: () => isExpired,
|
|
23223
23265
|
loadToken: () => loadToken,
|
|
23224
23266
|
saveToken: () => saveToken
|
|
@@ -23230,6 +23272,7 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
23230
23272
|
var import_token_io = require_token_io();
|
|
23231
23273
|
var import_auth_config = require_auth_config();
|
|
23232
23274
|
var import_oauth = require_oauth();
|
|
23275
|
+
var import_auth_errors = require_auth_errors();
|
|
23233
23276
|
function getVercelDataDir() {
|
|
23234
23277
|
const vercelFolder = "com.vercel.cli";
|
|
23235
23278
|
const dataDir = (0, import_token_io.getUserDataDir)();
|
|
@@ -23238,17 +23281,17 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
23238
23281
|
}
|
|
23239
23282
|
return path.join(dataDir, vercelFolder);
|
|
23240
23283
|
}
|
|
23241
|
-
async function
|
|
23284
|
+
async function getVercelToken2(options) {
|
|
23242
23285
|
const authConfig = (0, import_auth_config.readAuthConfig)();
|
|
23243
|
-
if (!authConfig) {
|
|
23244
|
-
|
|
23286
|
+
if (!authConfig?.token) {
|
|
23287
|
+
throw new import_auth_errors.AccessTokenMissingError;
|
|
23245
23288
|
}
|
|
23246
|
-
if ((0, import_auth_config.isValidAccessToken)(authConfig)) {
|
|
23247
|
-
return authConfig.token
|
|
23289
|
+
if ((0, import_auth_config.isValidAccessToken)(authConfig, options?.expirationBufferMs)) {
|
|
23290
|
+
return authConfig.token;
|
|
23248
23291
|
}
|
|
23249
23292
|
if (!authConfig.refreshToken) {
|
|
23250
23293
|
(0, import_auth_config.writeAuthConfig)({});
|
|
23251
|
-
|
|
23294
|
+
throw new import_auth_errors.RefreshAccessTokenFailedError("No refresh token available");
|
|
23252
23295
|
}
|
|
23253
23296
|
try {
|
|
23254
23297
|
const tokenResponse = await (0, import_oauth.refreshTokenRequest)({
|
|
@@ -23257,7 +23300,7 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
23257
23300
|
const [tokensError, tokens] = await (0, import_oauth.processTokenResponse)(tokenResponse);
|
|
23258
23301
|
if (tokensError || !tokens) {
|
|
23259
23302
|
(0, import_auth_config.writeAuthConfig)({});
|
|
23260
|
-
|
|
23303
|
+
throw new import_auth_errors.RefreshAccessTokenFailedError(tokensError);
|
|
23261
23304
|
}
|
|
23262
23305
|
const updatedConfig = {
|
|
23263
23306
|
token: tokens.access_token,
|
|
@@ -23267,10 +23310,13 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
23267
23310
|
updatedConfig.refreshToken = tokens.refresh_token;
|
|
23268
23311
|
}
|
|
23269
23312
|
(0, import_auth_config.writeAuthConfig)(updatedConfig);
|
|
23270
|
-
return updatedConfig.token
|
|
23313
|
+
return updatedConfig.token;
|
|
23271
23314
|
} catch (error48) {
|
|
23272
23315
|
(0, import_auth_config.writeAuthConfig)({});
|
|
23273
|
-
|
|
23316
|
+
if (error48 instanceof import_auth_errors.AccessTokenMissingError || error48 instanceof import_auth_errors.RefreshAccessTokenFailedError) {
|
|
23317
|
+
throw error48;
|
|
23318
|
+
}
|
|
23319
|
+
throw new import_auth_errors.RefreshAccessTokenFailedError(error48);
|
|
23274
23320
|
}
|
|
23275
23321
|
}
|
|
23276
23322
|
async function getVercelOidcToken2(authToken, projectId, teamId) {
|
|
@@ -23345,8 +23391,8 @@ var require_token_util = __commonJS((exports, module) => {
|
|
|
23345
23391
|
const padded = base643.padEnd(base643.length + (4 - base643.length % 4) % 4, "=");
|
|
23346
23392
|
return JSON.parse(Buffer.from(padded, "base64").toString("utf8"));
|
|
23347
23393
|
}
|
|
23348
|
-
function isExpired(token) {
|
|
23349
|
-
return token.exp * 1000 < Date.now();
|
|
23394
|
+
function isExpired(token, bufferMs = 0) {
|
|
23395
|
+
return token.exp * 1000 < Date.now() + bufferMs;
|
|
23350
23396
|
}
|
|
23351
23397
|
});
|
|
23352
23398
|
|
|
@@ -23376,17 +23422,26 @@ var require_token = __commonJS((exports, module) => {
|
|
|
23376
23422
|
module.exports = __toCommonJS2(token_exports);
|
|
23377
23423
|
var import_token_error = require_token_error();
|
|
23378
23424
|
var import_token_util = require_token_util();
|
|
23379
|
-
async function refreshToken() {
|
|
23380
|
-
|
|
23425
|
+
async function refreshToken(options) {
|
|
23426
|
+
let projectId = options?.project;
|
|
23427
|
+
let teamId = options?.team;
|
|
23428
|
+
if (!projectId && !teamId) {
|
|
23429
|
+
const projectInfo = (0, import_token_util.findProjectInfo)();
|
|
23430
|
+
projectId = projectInfo.projectId;
|
|
23431
|
+
teamId = projectInfo.teamId;
|
|
23432
|
+
} else if (!projectId || !teamId) {
|
|
23433
|
+
const projectInfo = (0, import_token_util.findProjectInfo)();
|
|
23434
|
+
projectId = projectId ?? projectInfo.projectId;
|
|
23435
|
+
teamId = teamId ?? projectInfo.teamId;
|
|
23436
|
+
}
|
|
23437
|
+
if (!projectId) {
|
|
23438
|
+
throw new import_token_error.VercelOidcTokenError("Failed to refresh OIDC token: No project specified. Try re-linking your project with `vc link`");
|
|
23439
|
+
}
|
|
23381
23440
|
let maybeToken = (0, import_token_util.loadToken)(projectId);
|
|
23382
|
-
if (!maybeToken || (0, import_token_util.isExpired)((0, import_token_util.getTokenPayload)(maybeToken.token))) {
|
|
23383
|
-
const authToken = await (0, import_token_util.
|
|
23384
|
-
|
|
23385
|
-
|
|
23386
|
-
}
|
|
23387
|
-
if (!projectId) {
|
|
23388
|
-
throw new import_token_error.VercelOidcTokenError("Failed to refresh OIDC token: Try re-linking your project with `vc link`");
|
|
23389
|
-
}
|
|
23441
|
+
if (!maybeToken || (0, import_token_util.isExpired)((0, import_token_util.getTokenPayload)(maybeToken.token), options?.expirationBufferMs)) {
|
|
23442
|
+
const authToken = await (0, import_token_util.getVercelToken)({
|
|
23443
|
+
expirationBufferMs: options?.expirationBufferMs
|
|
23444
|
+
});
|
|
23390
23445
|
maybeToken = await (0, import_token_util.getVercelOidcToken)(authToken, projectId, teamId);
|
|
23391
23446
|
if (!maybeToken) {
|
|
23392
23447
|
throw new import_token_error.VercelOidcTokenError("Failed to refresh OIDC token");
|
|
@@ -23425,7 +23480,7 @@ var require_get_vercel_oidc_token = __commonJS((exports, module) => {
|
|
|
23425
23480
|
module.exports = __toCommonJS2(get_vercel_oidc_token_exports);
|
|
23426
23481
|
var import_get_context = require_get_context();
|
|
23427
23482
|
var import_token_error = require_token_error();
|
|
23428
|
-
async function getVercelOidcToken2() {
|
|
23483
|
+
async function getVercelOidcToken2(options) {
|
|
23429
23484
|
let token = "";
|
|
23430
23485
|
let err;
|
|
23431
23486
|
try {
|
|
@@ -23438,8 +23493,8 @@ var require_get_vercel_oidc_token = __commonJS((exports, module) => {
|
|
|
23438
23493
|
await Promise.resolve().then(() => __toESM(require_token_util())),
|
|
23439
23494
|
await Promise.resolve().then(() => __toESM(require_token()))
|
|
23440
23495
|
]);
|
|
23441
|
-
if (!token || isExpired(getTokenPayload(token))) {
|
|
23442
|
-
await refreshToken();
|
|
23496
|
+
if (!token || isExpired(getTokenPayload(token), options?.expirationBufferMs)) {
|
|
23497
|
+
await refreshToken(options);
|
|
23443
23498
|
token = getVercelOidcTokenSync2();
|
|
23444
23499
|
}
|
|
23445
23500
|
} catch (error48) {
|
|
@@ -23485,13 +23540,18 @@ var require_dist = __commonJS((exports, module) => {
|
|
|
23485
23540
|
var __toCommonJS2 = (mod) => __copyProps(__defProp2({}, "__esModule", { value: true }), mod);
|
|
23486
23541
|
var src_exports = {};
|
|
23487
23542
|
__export2(src_exports, {
|
|
23543
|
+
AccessTokenMissingError: () => import_auth_errors.AccessTokenMissingError,
|
|
23544
|
+
RefreshAccessTokenFailedError: () => import_auth_errors.RefreshAccessTokenFailedError,
|
|
23488
23545
|
getContext: () => import_get_context.getContext,
|
|
23489
23546
|
getVercelOidcToken: () => import_get_vercel_oidc_token.getVercelOidcToken,
|
|
23490
|
-
getVercelOidcTokenSync: () => import_get_vercel_oidc_token.getVercelOidcTokenSync
|
|
23547
|
+
getVercelOidcTokenSync: () => import_get_vercel_oidc_token.getVercelOidcTokenSync,
|
|
23548
|
+
getVercelToken: () => import_token_util.getVercelToken
|
|
23491
23549
|
});
|
|
23492
23550
|
module.exports = __toCommonJS2(src_exports);
|
|
23493
23551
|
var import_get_vercel_oidc_token = require_get_vercel_oidc_token();
|
|
23494
23552
|
var import_get_context = require_get_context();
|
|
23553
|
+
var import_auth_errors = require_auth_errors();
|
|
23554
|
+
var import_token_util = require_token_util();
|
|
23495
23555
|
});
|
|
23496
23556
|
|
|
23497
23557
|
// node_modules/@ai-sdk/gateway/dist/index.mjs
|
|
@@ -23848,7 +23908,7 @@ async function getGatewayAuthToken(options) {
|
|
|
23848
23908
|
authMethod: "oidc"
|
|
23849
23909
|
};
|
|
23850
23910
|
}
|
|
23851
|
-
var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _a18, _b17, GatewayError, name16 = "GatewayAuthenticationError", marker22, symbol22, _a22, _b22, GatewayAuthenticationError, name22 = "GatewayInvalidRequestError", marker32, symbol32, _a32, _b32, GatewayInvalidRequestError, name32 = "GatewayRateLimitError", marker42, symbol42, _a42, _b42, GatewayRateLimitError, name42 = "GatewayModelNotFoundError", marker52, symbol52, modelNotFoundParamSchema, _a52, _b52, GatewayModelNotFoundError, name52 = "GatewayInternalServerError", marker62, symbol62, _a62, _b62, GatewayInternalServerError, name62 = "GatewayResponseError", marker72, symbol72, _a72, _b72, GatewayResponseError, gatewayErrorResponseSchema, name72 = "GatewayTimeoutError", marker82, symbol82, _a82, _b82, GatewayTimeoutError, GATEWAY_AUTH_METHOD_HEADER = "ai-gateway-auth-method", gatewayAuthMethodSchema, GatewayFetchMetadata = class {
|
|
23911
|
+
var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _a18, _b17, GatewayError, name16 = "GatewayAuthenticationError", marker22, symbol22, _a22, _b22, GatewayAuthenticationError, name22 = "GatewayInvalidRequestError", marker32, symbol32, _a32, _b32, GatewayInvalidRequestError, name32 = "GatewayRateLimitError", marker42, symbol42, _a42, _b42, GatewayRateLimitError, name42 = "GatewayModelNotFoundError", marker52, symbol52, modelNotFoundParamSchema, _a52, _b52, GatewayModelNotFoundError, name52 = "GatewayInternalServerError", marker62, symbol62, _a62, _b62, GatewayInternalServerError, name62 = "GatewayResponseError", marker72, symbol72, _a72, _b72, GatewayResponseError, gatewayErrorResponseSchema, name72 = "GatewayTimeoutError", marker82, symbol82, _a82, _b82, GatewayTimeoutError, GATEWAY_AUTH_METHOD_HEADER = "ai-gateway-auth-method", gatewayAuthMethodSchema, KNOWN_MODEL_TYPES, GatewayFetchMetadata = class {
|
|
23852
23912
|
constructor(config2) {
|
|
23853
23913
|
this.config = config2;
|
|
23854
23914
|
}
|
|
@@ -24411,7 +24471,7 @@ var import_oidc, import_oidc2, marker17 = "vercel.ai.gateway.error", symbol18, _
|
|
|
24411
24471
|
"ai-model-id": this.modelId
|
|
24412
24472
|
};
|
|
24413
24473
|
}
|
|
24414
|
-
}, gatewayRerankingResponseSchema, parallelSearchInputSchema, parallelSearchOutputSchema, parallelSearchToolFactory, parallelSearch = (config2 = {}) => parallelSearchToolFactory(config2), perplexitySearchInputSchema, perplexitySearchOutputSchema, perplexitySearchToolFactory, perplexitySearch = (config2 = {}) => perplexitySearchToolFactory(config2), gatewayTools, VERSION2 = "3.0.
|
|
24474
|
+
}, gatewayRerankingResponseSchema, parallelSearchInputSchema, parallelSearchOutputSchema, parallelSearchToolFactory, parallelSearch = (config2 = {}) => parallelSearchToolFactory(config2), perplexitySearchInputSchema, perplexitySearchOutputSchema, perplexitySearchToolFactory, perplexitySearch = (config2 = {}) => perplexitySearchToolFactory(config2), gatewayTools, VERSION2 = "3.0.104", AI_GATEWAY_PROTOCOL_VERSION = "0.0.1", gateway;
|
|
24415
24475
|
var init_dist4 = __esm(() => {
|
|
24416
24476
|
init_dist3();
|
|
24417
24477
|
init_dist();
|
|
@@ -24665,6 +24725,13 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
24665
24725
|
}
|
|
24666
24726
|
};
|
|
24667
24727
|
gatewayAuthMethodSchema = lazySchema(() => zodSchema(exports_external.union([exports_external.literal("api-key"), exports_external.literal("oidc")])));
|
|
24728
|
+
KNOWN_MODEL_TYPES = [
|
|
24729
|
+
"embedding",
|
|
24730
|
+
"image",
|
|
24731
|
+
"language",
|
|
24732
|
+
"reranking",
|
|
24733
|
+
"video"
|
|
24734
|
+
];
|
|
24668
24735
|
gatewayAvailableModelsResponseSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
24669
24736
|
models: exports_external.array(exports_external.object({
|
|
24670
24737
|
id: exports_external.string(),
|
|
@@ -24686,8 +24753,8 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
24686
24753
|
provider: exports_external.string(),
|
|
24687
24754
|
modelId: exports_external.string()
|
|
24688
24755
|
}),
|
|
24689
|
-
modelType: exports_external.
|
|
24690
|
-
}))
|
|
24756
|
+
modelType: exports_external.string().nullish()
|
|
24757
|
+
})).transform((models) => models.filter((m) => m.modelType == null || KNOWN_MODEL_TYPES.includes(m.modelType)))
|
|
24691
24758
|
})));
|
|
24692
24759
|
gatewayCreditsResponseSchema = lazySchema(() => zodSchema(exports_external.object({
|
|
24693
24760
|
balance: exports_external.string(),
|
|
@@ -28243,7 +28310,7 @@ async function toResponseMessages({
|
|
|
28243
28310
|
type: "tool-call",
|
|
28244
28311
|
toolCallId: part.toolCallId,
|
|
28245
28312
|
toolName: part.toolName,
|
|
28246
|
-
input: part.input,
|
|
28313
|
+
input: part.invalid && typeof part.input !== "object" ? {} : part.input,
|
|
28247
28314
|
providerExecuted: part.providerExecuted,
|
|
28248
28315
|
providerOptions: part.providerMetadata
|
|
28249
28316
|
});
|
|
@@ -28523,22 +28590,6 @@ async function generateText({
|
|
|
28523
28590
|
content: toolContent
|
|
28524
28591
|
});
|
|
28525
28592
|
}
|
|
28526
|
-
const providerExecutedToolApprovals = [
|
|
28527
|
-
...approvedToolApprovals,
|
|
28528
|
-
...deniedToolApprovals
|
|
28529
|
-
].filter((toolApproval) => toolApproval.toolCall.providerExecuted);
|
|
28530
|
-
if (providerExecutedToolApprovals.length > 0) {
|
|
28531
|
-
responseMessages.push({
|
|
28532
|
-
role: "tool",
|
|
28533
|
-
content: providerExecutedToolApprovals.map((toolApproval) => ({
|
|
28534
|
-
type: "tool-approval-response",
|
|
28535
|
-
approvalId: toolApproval.approvalResponse.approvalId,
|
|
28536
|
-
approved: toolApproval.approvalResponse.approved,
|
|
28537
|
-
reason: toolApproval.approvalResponse.reason,
|
|
28538
|
-
providerExecuted: true
|
|
28539
|
-
}))
|
|
28540
|
-
});
|
|
28541
|
-
}
|
|
28542
28593
|
const callSettings2 = prepareCallSettings(settings);
|
|
28543
28594
|
let currentModelResponse;
|
|
28544
28595
|
let clientToolCalls = [];
|
|
@@ -29116,7 +29167,7 @@ var import_api, import_api2, __defProp2, __export2 = (target, all) => {
|
|
|
29116
29167
|
const bytes = typeof data === "string" ? convertBase64ToUint8Array(data) : data;
|
|
29117
29168
|
const id3Size = (bytes[6] & 127) << 21 | (bytes[7] & 127) << 14 | (bytes[8] & 127) << 7 | bytes[9] & 127;
|
|
29118
29169
|
return bytes.slice(id3Size + 10);
|
|
29119
|
-
}, VERSION3 = "6.0.
|
|
29170
|
+
}, VERSION3 = "6.0.168", download = async ({
|
|
29120
29171
|
url: url2,
|
|
29121
29172
|
maxBytes,
|
|
29122
29173
|
abortSignal
|
|
@@ -30857,9 +30908,10 @@ async function prepareTools({
|
|
|
30857
30908
|
disableParallelToolUse,
|
|
30858
30909
|
cacheControlValidator,
|
|
30859
30910
|
supportsStructuredOutput,
|
|
30860
|
-
supportsStrictTools
|
|
30911
|
+
supportsStrictTools,
|
|
30912
|
+
defaultEagerInputStreaming = false
|
|
30861
30913
|
}) {
|
|
30862
|
-
var _a21;
|
|
30914
|
+
var _a21, _b16;
|
|
30863
30915
|
tools = (tools == null ? undefined : tools.length) ? tools : undefined;
|
|
30864
30916
|
const toolWarnings = [];
|
|
30865
30917
|
const betas = /* @__PURE__ */ new Set;
|
|
@@ -30876,7 +30928,7 @@ async function prepareTools({
|
|
|
30876
30928
|
canCache: true
|
|
30877
30929
|
});
|
|
30878
30930
|
const anthropicOptions = (_a21 = tool2.providerOptions) == null ? undefined : _a21.anthropic;
|
|
30879
|
-
const eagerInputStreaming = anthropicOptions == null ? undefined : anthropicOptions.eagerInputStreaming;
|
|
30931
|
+
const eagerInputStreaming = (_b16 = anthropicOptions == null ? undefined : anthropicOptions.eagerInputStreaming) != null ? _b16 : defaultEagerInputStreaming;
|
|
30880
30932
|
const deferLoading = anthropicOptions == null ? undefined : anthropicOptions.deferLoading;
|
|
30881
30933
|
const allowedCallers = anthropicOptions == null ? undefined : anthropicOptions.allowedCallers;
|
|
30882
30934
|
if (!supportsStrictTools && tool2.strict != null) {
|
|
@@ -32073,46 +32125,60 @@ function createCitationSource(citation, citationDocuments, generateId3) {
|
|
|
32073
32125
|
};
|
|
32074
32126
|
}
|
|
32075
32127
|
function getModelCapabilities(modelId) {
|
|
32076
|
-
if (modelId.includes("claude-
|
|
32128
|
+
if (modelId.includes("claude-opus-4-7")) {
|
|
32077
32129
|
return {
|
|
32078
32130
|
maxOutputTokens: 128000,
|
|
32079
32131
|
supportsStructuredOutput: true,
|
|
32132
|
+
rejectsSamplingParameters: true,
|
|
32133
|
+
isKnownModel: true
|
|
32134
|
+
};
|
|
32135
|
+
} else if (modelId.includes("claude-sonnet-4-6") || modelId.includes("claude-opus-4-6")) {
|
|
32136
|
+
return {
|
|
32137
|
+
maxOutputTokens: 128000,
|
|
32138
|
+
supportsStructuredOutput: true,
|
|
32139
|
+
rejectsSamplingParameters: false,
|
|
32080
32140
|
isKnownModel: true
|
|
32081
32141
|
};
|
|
32082
32142
|
} else if (modelId.includes("claude-sonnet-4-5") || modelId.includes("claude-opus-4-5") || modelId.includes("claude-haiku-4-5")) {
|
|
32083
32143
|
return {
|
|
32084
32144
|
maxOutputTokens: 64000,
|
|
32085
32145
|
supportsStructuredOutput: true,
|
|
32146
|
+
rejectsSamplingParameters: false,
|
|
32086
32147
|
isKnownModel: true
|
|
32087
32148
|
};
|
|
32088
32149
|
} else if (modelId.includes("claude-opus-4-1")) {
|
|
32089
32150
|
return {
|
|
32090
32151
|
maxOutputTokens: 32000,
|
|
32091
32152
|
supportsStructuredOutput: true,
|
|
32153
|
+
rejectsSamplingParameters: false,
|
|
32092
32154
|
isKnownModel: true
|
|
32093
32155
|
};
|
|
32094
32156
|
} else if (modelId.includes("claude-sonnet-4-")) {
|
|
32095
32157
|
return {
|
|
32096
32158
|
maxOutputTokens: 64000,
|
|
32097
32159
|
supportsStructuredOutput: false,
|
|
32160
|
+
rejectsSamplingParameters: false,
|
|
32098
32161
|
isKnownModel: true
|
|
32099
32162
|
};
|
|
32100
32163
|
} else if (modelId.includes("claude-opus-4-")) {
|
|
32101
32164
|
return {
|
|
32102
32165
|
maxOutputTokens: 32000,
|
|
32103
32166
|
supportsStructuredOutput: false,
|
|
32167
|
+
rejectsSamplingParameters: false,
|
|
32104
32168
|
isKnownModel: true
|
|
32105
32169
|
};
|
|
32106
32170
|
} else if (modelId.includes("claude-3-haiku")) {
|
|
32107
32171
|
return {
|
|
32108
32172
|
maxOutputTokens: 4096,
|
|
32109
32173
|
supportsStructuredOutput: false,
|
|
32174
|
+
rejectsSamplingParameters: false,
|
|
32110
32175
|
isKnownModel: true
|
|
32111
32176
|
};
|
|
32112
32177
|
} else {
|
|
32113
32178
|
return {
|
|
32114
32179
|
maxOutputTokens: 4096,
|
|
32115
32180
|
supportsStructuredOutput: false,
|
|
32181
|
+
rejectsSamplingParameters: false,
|
|
32116
32182
|
isKnownModel: false
|
|
32117
32183
|
};
|
|
32118
32184
|
}
|
|
@@ -32221,7 +32287,7 @@ function createAnthropic(options = {}) {
|
|
|
32221
32287
|
provider.tools = anthropicTools;
|
|
32222
32288
|
return provider;
|
|
32223
32289
|
}
|
|
32224
|
-
var VERSION4 = "3.0.
|
|
32290
|
+
var VERSION4 = "3.0.71", anthropicErrorDataSchema, anthropicFailedResponseHandler, anthropicMessagesResponseSchema, anthropicMessagesChunkSchema, anthropicReasoningMetadataSchema, anthropicFilePartProviderOptions, anthropicLanguageModelOptions, MAX_CACHE_BREAKPOINTS = 4, CacheControlValidator = class {
|
|
32225
32291
|
constructor() {
|
|
32226
32292
|
this.breakpointCount = 0;
|
|
32227
32293
|
this.warnings = [];
|
|
@@ -32311,7 +32377,7 @@ var VERSION4 = "3.0.68", anthropicErrorDataSchema, anthropicFailedResponseHandle
|
|
|
32311
32377
|
providerOptions,
|
|
32312
32378
|
stream
|
|
32313
32379
|
}) {
|
|
32314
|
-
var _a21, _b16, _c, _d, _e, _f, _g, _h, _i;
|
|
32380
|
+
var _a21, _b16, _c, _d, _e, _f, _g, _h, _i, _j;
|
|
32315
32381
|
const warnings = [];
|
|
32316
32382
|
if (frequencyPenalty != null) {
|
|
32317
32383
|
warnings.push({ type: "unsupported", feature: "frequencyPenalty" });
|
|
@@ -32362,8 +32428,35 @@ var VERSION4 = "3.0.68", anthropicErrorDataSchema, anthropicFailedResponseHandle
|
|
|
32362
32428
|
const {
|
|
32363
32429
|
maxOutputTokens: maxOutputTokensForModel,
|
|
32364
32430
|
supportsStructuredOutput: modelSupportsStructuredOutput,
|
|
32431
|
+
rejectsSamplingParameters,
|
|
32365
32432
|
isKnownModel
|
|
32366
32433
|
} = getModelCapabilities(this.modelId);
|
|
32434
|
+
if (rejectsSamplingParameters) {
|
|
32435
|
+
if (temperature != null) {
|
|
32436
|
+
warnings.push({
|
|
32437
|
+
type: "unsupported",
|
|
32438
|
+
feature: "temperature",
|
|
32439
|
+
details: `temperature is not supported by ${this.modelId} and will be ignored`
|
|
32440
|
+
});
|
|
32441
|
+
temperature = undefined;
|
|
32442
|
+
}
|
|
32443
|
+
if (topK != null) {
|
|
32444
|
+
warnings.push({
|
|
32445
|
+
type: "unsupported",
|
|
32446
|
+
feature: "topK",
|
|
32447
|
+
details: `topK is not supported by ${this.modelId} and will be ignored`
|
|
32448
|
+
});
|
|
32449
|
+
topK = undefined;
|
|
32450
|
+
}
|
|
32451
|
+
if (topP != null) {
|
|
32452
|
+
warnings.push({
|
|
32453
|
+
type: "unsupported",
|
|
32454
|
+
feature: "topP",
|
|
32455
|
+
details: `topP is not supported by ${this.modelId} and will be ignored`
|
|
32456
|
+
});
|
|
32457
|
+
topP = undefined;
|
|
32458
|
+
}
|
|
32459
|
+
}
|
|
32367
32460
|
const isAnthropicModel = isKnownModel || this.modelId.startsWith("claude-");
|
|
32368
32461
|
const supportsStructuredOutput = ((_a21 = this.config.supportsNativeStructuredOutput) != null ? _a21 : true) && modelSupportsStructuredOutput;
|
|
32369
32462
|
const supportsStrictTools = ((_b16 = this.config.supportsStrictTools) != null ? _b16 : true) && modelSupportsStructuredOutput;
|
|
@@ -32410,6 +32503,7 @@ var VERSION4 = "3.0.68", anthropicErrorDataSchema, anthropicFailedResponseHandle
|
|
|
32410
32503
|
const thinkingType = (_e = anthropicOptions == null ? undefined : anthropicOptions.thinking) == null ? undefined : _e.type;
|
|
32411
32504
|
const isThinking = thinkingType === "enabled" || thinkingType === "adaptive";
|
|
32412
32505
|
let thinkingBudget = thinkingType === "enabled" ? (_f = anthropicOptions == null ? undefined : anthropicOptions.thinking) == null ? undefined : _f.budgetTokens : undefined;
|
|
32506
|
+
const thinkingDisplay = thinkingType === "adaptive" ? (_g = anthropicOptions == null ? undefined : anthropicOptions.thinking) == null ? undefined : _g.display : undefined;
|
|
32413
32507
|
const maxTokens = maxOutputTokens != null ? maxOutputTokens : maxOutputTokensForModel;
|
|
32414
32508
|
const baseArgs = {
|
|
32415
32509
|
model: this.modelId,
|
|
@@ -32421,14 +32515,24 @@ var VERSION4 = "3.0.68", anthropicErrorDataSchema, anthropicFailedResponseHandle
|
|
|
32421
32515
|
...isThinking && {
|
|
32422
32516
|
thinking: {
|
|
32423
32517
|
type: thinkingType,
|
|
32424
|
-
...thinkingBudget != null && { budget_tokens: thinkingBudget }
|
|
32518
|
+
...thinkingBudget != null && { budget_tokens: thinkingBudget },
|
|
32519
|
+
...thinkingDisplay != null && { display: thinkingDisplay }
|
|
32425
32520
|
}
|
|
32426
32521
|
},
|
|
32427
|
-
...((anthropicOptions == null ? undefined : anthropicOptions.effort) || useStructuredOutput && (responseFormat == null ? undefined : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
32522
|
+
...((anthropicOptions == null ? undefined : anthropicOptions.effort) || (anthropicOptions == null ? undefined : anthropicOptions.taskBudget) || useStructuredOutput && (responseFormat == null ? undefined : responseFormat.type) === "json" && responseFormat.schema != null) && {
|
|
32428
32523
|
output_config: {
|
|
32429
32524
|
...(anthropicOptions == null ? undefined : anthropicOptions.effort) && {
|
|
32430
32525
|
effort: anthropicOptions.effort
|
|
32431
32526
|
},
|
|
32527
|
+
...(anthropicOptions == null ? undefined : anthropicOptions.taskBudget) && {
|
|
32528
|
+
task_budget: {
|
|
32529
|
+
type: anthropicOptions.taskBudget.type,
|
|
32530
|
+
total: anthropicOptions.taskBudget.total,
|
|
32531
|
+
...anthropicOptions.taskBudget.remaining != null && {
|
|
32532
|
+
remaining: anthropicOptions.taskBudget.remaining
|
|
32533
|
+
}
|
|
32534
|
+
}
|
|
32535
|
+
},
|
|
32432
32536
|
...useStructuredOutput && (responseFormat == null ? undefined : responseFormat.type) === "json" && responseFormat.schema != null && {
|
|
32433
32537
|
format: {
|
|
32434
32538
|
type: "json_schema",
|
|
@@ -32440,10 +32544,13 @@ var VERSION4 = "3.0.68", anthropicErrorDataSchema, anthropicFailedResponseHandle
|
|
|
32440
32544
|
...(anthropicOptions == null ? undefined : anthropicOptions.speed) && {
|
|
32441
32545
|
speed: anthropicOptions.speed
|
|
32442
32546
|
},
|
|
32547
|
+
...(anthropicOptions == null ? undefined : anthropicOptions.inferenceGeo) && {
|
|
32548
|
+
inference_geo: anthropicOptions.inferenceGeo
|
|
32549
|
+
},
|
|
32443
32550
|
...(anthropicOptions == null ? undefined : anthropicOptions.cacheControl) && {
|
|
32444
32551
|
cache_control: anthropicOptions.cacheControl
|
|
32445
32552
|
},
|
|
32446
|
-
...((
|
|
32553
|
+
...((_h = anthropicOptions == null ? undefined : anthropicOptions.metadata) == null ? undefined : _h.userId) != null && {
|
|
32447
32554
|
metadata: { user_id: anthropicOptions.metadata.userId }
|
|
32448
32555
|
},
|
|
32449
32556
|
...(anthropicOptions == null ? undefined : anthropicOptions.mcpServers) && anthropicOptions.mcpServers.length > 0 && {
|
|
@@ -32602,12 +32709,13 @@ var VERSION4 = "3.0.68", anthropicErrorDataSchema, anthropicFailedResponseHandle
|
|
|
32602
32709
|
if (anthropicOptions == null ? undefined : anthropicOptions.effort) {
|
|
32603
32710
|
betas.add("effort-2025-11-24");
|
|
32604
32711
|
}
|
|
32712
|
+
if (anthropicOptions == null ? undefined : anthropicOptions.taskBudget) {
|
|
32713
|
+
betas.add("task-budgets-2026-03-13");
|
|
32714
|
+
}
|
|
32605
32715
|
if ((anthropicOptions == null ? undefined : anthropicOptions.speed) === "fast") {
|
|
32606
32716
|
betas.add("fast-mode-2026-02-01");
|
|
32607
32717
|
}
|
|
32608
|
-
|
|
32609
|
-
betas.add("fine-grained-tool-streaming-2025-05-14");
|
|
32610
|
-
}
|
|
32718
|
+
const defaultEagerInputStreaming = stream && ((_i = anthropicOptions == null ? undefined : anthropicOptions.toolStreaming) != null ? _i : true);
|
|
32611
32719
|
const {
|
|
32612
32720
|
tools: anthropicTools2,
|
|
32613
32721
|
toolChoice: anthropicToolChoice,
|
|
@@ -32619,14 +32727,16 @@ var VERSION4 = "3.0.68", anthropicErrorDataSchema, anthropicFailedResponseHandle
|
|
|
32619
32727
|
disableParallelToolUse: true,
|
|
32620
32728
|
cacheControlValidator,
|
|
32621
32729
|
supportsStructuredOutput: false,
|
|
32622
|
-
supportsStrictTools
|
|
32730
|
+
supportsStrictTools,
|
|
32731
|
+
defaultEagerInputStreaming
|
|
32623
32732
|
} : {
|
|
32624
32733
|
tools: tools != null ? tools : [],
|
|
32625
32734
|
toolChoice,
|
|
32626
32735
|
disableParallelToolUse: anthropicOptions == null ? undefined : anthropicOptions.disableParallelToolUse,
|
|
32627
32736
|
cacheControlValidator,
|
|
32628
32737
|
supportsStructuredOutput,
|
|
32629
|
-
supportsStrictTools
|
|
32738
|
+
supportsStrictTools,
|
|
32739
|
+
defaultEagerInputStreaming
|
|
32630
32740
|
});
|
|
32631
32741
|
const cacheWarnings = cacheControlValidator.getWarnings();
|
|
32632
32742
|
return {
|
|
@@ -32641,7 +32751,7 @@ var VERSION4 = "3.0.68", anthropicErrorDataSchema, anthropicFailedResponseHandle
|
|
|
32641
32751
|
...betas,
|
|
32642
32752
|
...toolsBetas,
|
|
32643
32753
|
...userSuppliedBetas,
|
|
32644
|
-
...(
|
|
32754
|
+
...(_j = anthropicOptions == null ? undefined : anthropicOptions.anthropicBeta) != null ? _j : []
|
|
32645
32755
|
]),
|
|
32646
32756
|
usesJsonResponseTool: jsonResponseTool != null,
|
|
32647
32757
|
toolNameMapping,
|
|
@@ -34587,7 +34697,8 @@ var init_dist6 = __esm(() => {
|
|
|
34587
34697
|
structuredOutputMode: exports_external.enum(["outputFormat", "jsonTool", "auto"]).optional(),
|
|
34588
34698
|
thinking: exports_external.discriminatedUnion("type", [
|
|
34589
34699
|
exports_external.object({
|
|
34590
|
-
type: exports_external.literal("adaptive")
|
|
34700
|
+
type: exports_external.literal("adaptive"),
|
|
34701
|
+
display: exports_external.enum(["omitted", "summarized"]).optional()
|
|
34591
34702
|
}),
|
|
34592
34703
|
exports_external.object({
|
|
34593
34704
|
type: exports_external.literal("enabled"),
|
|
@@ -34624,8 +34735,14 @@ var init_dist6 = __esm(() => {
|
|
|
34624
34735
|
})).optional()
|
|
34625
34736
|
}).optional(),
|
|
34626
34737
|
toolStreaming: exports_external.boolean().optional(),
|
|
34627
|
-
effort: exports_external.enum(["low", "medium", "high", "max"]).optional(),
|
|
34738
|
+
effort: exports_external.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
34739
|
+
taskBudget: exports_external.object({
|
|
34740
|
+
type: exports_external.literal("tokens"),
|
|
34741
|
+
total: exports_external.number().int().min(20000),
|
|
34742
|
+
remaining: exports_external.number().int().min(0).optional()
|
|
34743
|
+
}).optional(),
|
|
34628
34744
|
speed: exports_external.enum(["fast", "standard"]).optional(),
|
|
34745
|
+
inferenceGeo: exports_external.enum(["us", "global"]).optional(),
|
|
34629
34746
|
anthropicBeta: exports_external.array(exports_external.string()).optional(),
|
|
34630
34747
|
contextManagement: exports_external.object({
|
|
34631
34748
|
edits: exports_external.array(exports_external.discriminatedUnion("type", [
|
|
@@ -35331,7 +35448,7 @@ var init_anthropic = __esm(() => {
|
|
|
35331
35448
|
};
|
|
35332
35449
|
});
|
|
35333
35450
|
|
|
35334
|
-
// node_modules/@ai-sdk/
|
|
35451
|
+
// node_modules/@ai-sdk/anthropic/dist/internal/index.mjs
|
|
35335
35452
|
function getCacheControl2(providerMetadata) {
|
|
35336
35453
|
var _a21;
|
|
35337
35454
|
const anthropic3 = providerMetadata == null ? undefined : providerMetadata.anthropic;
|
|
@@ -35344,9 +35461,10 @@ async function prepareTools2({
|
|
|
35344
35461
|
disableParallelToolUse,
|
|
35345
35462
|
cacheControlValidator,
|
|
35346
35463
|
supportsStructuredOutput,
|
|
35347
|
-
supportsStrictTools
|
|
35464
|
+
supportsStrictTools,
|
|
35465
|
+
defaultEagerInputStreaming = false
|
|
35348
35466
|
}) {
|
|
35349
|
-
var _a21;
|
|
35467
|
+
var _a21, _b16;
|
|
35350
35468
|
tools = (tools == null ? undefined : tools.length) ? tools : undefined;
|
|
35351
35469
|
const toolWarnings = [];
|
|
35352
35470
|
const betas = /* @__PURE__ */ new Set;
|
|
@@ -35363,7 +35481,7 @@ async function prepareTools2({
|
|
|
35363
35481
|
canCache: true
|
|
35364
35482
|
});
|
|
35365
35483
|
const anthropicOptions = (_a21 = tool2.providerOptions) == null ? undefined : _a21.anthropic;
|
|
35366
|
-
const eagerInputStreaming = anthropicOptions == null ? undefined : anthropicOptions.eagerInputStreaming;
|
|
35484
|
+
const eagerInputStreaming = (_b16 = anthropicOptions == null ? undefined : anthropicOptions.eagerInputStreaming) != null ? _b16 : defaultEagerInputStreaming;
|
|
35367
35485
|
const deferLoading = anthropicOptions == null ? undefined : anthropicOptions.deferLoading;
|
|
35368
35486
|
const allowedCallers = anthropicOptions == null ? undefined : anthropicOptions.allowedCallers;
|
|
35369
35487
|
if (!supportsStrictTools && tool2.strict != null) {
|
|
@@ -36464,7 +36582,8 @@ var init_internal = __esm(() => {
|
|
|
36464
36582
|
structuredOutputMode: exports_external.enum(["outputFormat", "jsonTool", "auto"]).optional(),
|
|
36465
36583
|
thinking: exports_external.discriminatedUnion("type", [
|
|
36466
36584
|
exports_external.object({
|
|
36467
|
-
type: exports_external.literal("adaptive")
|
|
36585
|
+
type: exports_external.literal("adaptive"),
|
|
36586
|
+
display: exports_external.enum(["omitted", "summarized"]).optional()
|
|
36468
36587
|
}),
|
|
36469
36588
|
exports_external.object({
|
|
36470
36589
|
type: exports_external.literal("enabled"),
|
|
@@ -36501,7 +36620,12 @@ var init_internal = __esm(() => {
|
|
|
36501
36620
|
})).optional()
|
|
36502
36621
|
}).optional(),
|
|
36503
36622
|
toolStreaming: exports_external.boolean().optional(),
|
|
36504
|
-
effort: exports_external.enum(["low", "medium", "high", "max"]).optional(),
|
|
36623
|
+
effort: exports_external.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
36624
|
+
taskBudget: exports_external.object({
|
|
36625
|
+
type: exports_external.literal("tokens"),
|
|
36626
|
+
total: exports_external.number().int().min(20000),
|
|
36627
|
+
remaining: exports_external.number().int().min(0).optional()
|
|
36628
|
+
}).optional(),
|
|
36505
36629
|
speed: exports_external.enum(["fast", "standard"]).optional(),
|
|
36506
36630
|
inferenceGeo: exports_external.enum(["us", "global"]).optional(),
|
|
36507
36631
|
anthropicBeta: exports_external.array(exports_external.string()).optional(),
|
|
@@ -39691,7 +39815,7 @@ var BEDROCK_STOP_REASONS, BEDROCK_IMAGE_MIME_TYPES, BEDROCK_DOCUMENT_MIME_TYPES,
|
|
|
39691
39815
|
toolChoice,
|
|
39692
39816
|
providerOptions
|
|
39693
39817
|
}) {
|
|
39694
|
-
var _a21, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
39818
|
+
var _a21, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m;
|
|
39695
39819
|
const bedrockOptions = (_a21 = await parseProviderOptions({
|
|
39696
39820
|
provider: "bedrock",
|
|
39697
39821
|
providerOptions,
|
|
@@ -39769,6 +39893,7 @@ var BEDROCK_STOP_REASONS, BEDROCK_IMAGE_MIME_TYPES, BEDROCK_DOCUMENT_MIME_TYPES,
|
|
|
39769
39893
|
}
|
|
39770
39894
|
const thinkingType = (_e = bedrockOptions.reasoningConfig) == null ? undefined : _e.type;
|
|
39771
39895
|
const thinkingBudget = thinkingType === "enabled" ? (_f = bedrockOptions.reasoningConfig) == null ? undefined : _f.budgetTokens : undefined;
|
|
39896
|
+
const thinkingDisplay = thinkingType === "adaptive" ? (_g = bedrockOptions.reasoningConfig) == null ? undefined : _g.display : undefined;
|
|
39772
39897
|
const isAnthropicThinkingEnabled = isAnthropicModel && isThinkingEnabled;
|
|
39773
39898
|
const inferenceConfig = {
|
|
39774
39899
|
...maxOutputTokens != null && { maxTokens: maxOutputTokens },
|
|
@@ -39795,12 +39920,13 @@ var BEDROCK_STOP_REASONS, BEDROCK_IMAGE_MIME_TYPES, BEDROCK_DOCUMENT_MIME_TYPES,
|
|
|
39795
39920
|
bedrockOptions.additionalModelRequestFields = {
|
|
39796
39921
|
...bedrockOptions.additionalModelRequestFields,
|
|
39797
39922
|
thinking: {
|
|
39798
|
-
type: "adaptive"
|
|
39923
|
+
type: "adaptive",
|
|
39924
|
+
...thinkingDisplay != null && { display: thinkingDisplay }
|
|
39799
39925
|
}
|
|
39800
39926
|
};
|
|
39801
39927
|
}
|
|
39802
39928
|
} else if (!isAnthropicModel) {
|
|
39803
|
-
if (((
|
|
39929
|
+
if (((_h = bedrockOptions.reasoningConfig) == null ? undefined : _h.budgetTokens) != null) {
|
|
39804
39930
|
warnings.push({
|
|
39805
39931
|
type: "unsupported",
|
|
39806
39932
|
feature: "budgetTokens",
|
|
@@ -39815,14 +39941,14 @@ var BEDROCK_STOP_REASONS, BEDROCK_IMAGE_MIME_TYPES, BEDROCK_DOCUMENT_MIME_TYPES,
|
|
|
39815
39941
|
});
|
|
39816
39942
|
}
|
|
39817
39943
|
}
|
|
39818
|
-
const maxReasoningEffort = (
|
|
39944
|
+
const maxReasoningEffort = (_i = bedrockOptions.reasoningConfig) == null ? undefined : _i.maxReasoningEffort;
|
|
39819
39945
|
const isOpenAIModel = this.modelId.startsWith("openai.");
|
|
39820
39946
|
if (maxReasoningEffort != null) {
|
|
39821
39947
|
if (isAnthropicModel) {
|
|
39822
39948
|
bedrockOptions.additionalModelRequestFields = {
|
|
39823
39949
|
...bedrockOptions.additionalModelRequestFields,
|
|
39824
39950
|
output_config: {
|
|
39825
|
-
...(
|
|
39951
|
+
...(_j = bedrockOptions.additionalModelRequestFields) == null ? undefined : _j.output_config,
|
|
39826
39952
|
effort: maxReasoningEffort
|
|
39827
39953
|
}
|
|
39828
39954
|
};
|
|
@@ -39846,7 +39972,7 @@ var BEDROCK_STOP_REASONS, BEDROCK_IMAGE_MIME_TYPES, BEDROCK_DOCUMENT_MIME_TYPES,
|
|
|
39846
39972
|
bedrockOptions.additionalModelRequestFields = {
|
|
39847
39973
|
...bedrockOptions.additionalModelRequestFields,
|
|
39848
39974
|
output_config: {
|
|
39849
|
-
...(
|
|
39975
|
+
...(_k = bedrockOptions.additionalModelRequestFields) == null ? undefined : _k.output_config,
|
|
39850
39976
|
format: {
|
|
39851
39977
|
type: "json_schema",
|
|
39852
39978
|
schema: responseFormat.schema
|
|
@@ -39878,7 +40004,7 @@ var BEDROCK_STOP_REASONS, BEDROCK_IMAGE_MIME_TYPES, BEDROCK_DOCUMENT_MIME_TYPES,
|
|
|
39878
40004
|
details: "topK is not supported when thinking is enabled"
|
|
39879
40005
|
});
|
|
39880
40006
|
}
|
|
39881
|
-
const hasAnyTools = ((
|
|
40007
|
+
const hasAnyTools = ((_m = (_l = toolConfig.tools) == null ? undefined : _l.length) != null ? _m : 0) > 0 || additionalTools;
|
|
39882
40008
|
let filteredPrompt = prompt;
|
|
39883
40009
|
if (!hasAnyTools) {
|
|
39884
40010
|
const hasToolContent = prompt.some((message) => ("content" in message) && Array.isArray(message.content) && message.content.some((part) => part.type === "tool-call" || part.type === "tool-result"));
|
|
@@ -40245,6 +40371,13 @@ var BEDROCK_STOP_REASONS, BEDROCK_IMAGE_MIME_TYPES, BEDROCK_DOCUMENT_MIME_TYPES,
|
|
|
40245
40371
|
delta: reasoningContent.text
|
|
40246
40372
|
});
|
|
40247
40373
|
} else if ("signature" in reasoningContent && reasoningContent.signature) {
|
|
40374
|
+
if (contentBlocks[blockIndex] == null) {
|
|
40375
|
+
contentBlocks[blockIndex] = { type: "reasoning" };
|
|
40376
|
+
controller.enqueue({
|
|
40377
|
+
type: "reasoning-start",
|
|
40378
|
+
id: String(blockIndex)
|
|
40379
|
+
});
|
|
40380
|
+
}
|
|
40248
40381
|
controller.enqueue({
|
|
40249
40382
|
type: "reasoning-delta",
|
|
40250
40383
|
id: String(blockIndex),
|
|
@@ -40256,6 +40389,13 @@ var BEDROCK_STOP_REASONS, BEDROCK_IMAGE_MIME_TYPES, BEDROCK_DOCUMENT_MIME_TYPES,
|
|
|
40256
40389
|
}
|
|
40257
40390
|
});
|
|
40258
40391
|
} else if ("data" in reasoningContent && reasoningContent.data) {
|
|
40392
|
+
if (contentBlocks[blockIndex] == null) {
|
|
40393
|
+
contentBlocks[blockIndex] = { type: "reasoning" };
|
|
40394
|
+
controller.enqueue({
|
|
40395
|
+
type: "reasoning-start",
|
|
40396
|
+
id: String(blockIndex)
|
|
40397
|
+
});
|
|
40398
|
+
}
|
|
40259
40399
|
controller.enqueue({
|
|
40260
40400
|
type: "reasoning-delta",
|
|
40261
40401
|
id: String(blockIndex),
|
|
@@ -40595,7 +40735,7 @@ var BEDROCK_STOP_REASONS, BEDROCK_IMAGE_MIME_TYPES, BEDROCK_DOCUMENT_MIME_TYPES,
|
|
|
40595
40735
|
}
|
|
40596
40736
|
};
|
|
40597
40737
|
}
|
|
40598
|
-
}, bedrockImageResponseSchema, VERSION5 = "4.0.
|
|
40738
|
+
}, bedrockImageResponseSchema, VERSION5 = "4.0.96", bedrockRerankingResponseSchema, amazonBedrockRerankingModelOptionsSchema, BedrockRerankingModel = class {
|
|
40599
40739
|
constructor(modelId, config2) {
|
|
40600
40740
|
this.modelId = modelId;
|
|
40601
40741
|
this.config = config2;
|
|
@@ -40740,7 +40880,8 @@ var init_dist7 = __esm(() => {
|
|
|
40740
40880
|
exports_external.literal("adaptive")
|
|
40741
40881
|
]).optional(),
|
|
40742
40882
|
budgetTokens: exports_external.number().optional(),
|
|
40743
|
-
maxReasoningEffort: exports_external.enum(["low", "medium", "high", "max"]).optional()
|
|
40883
|
+
maxReasoningEffort: exports_external.enum(["low", "medium", "high", "xhigh", "max"]).optional(),
|
|
40884
|
+
display: exports_external.enum(["omitted", "summarized"]).optional()
|
|
40744
40885
|
}).optional(),
|
|
40745
40886
|
anthropicBeta: exports_external.array(exports_external.string()).optional(),
|
|
40746
40887
|
serviceTier: exports_external.enum(["reserved", "priority", "default", "flex"]).optional()
|
|
@@ -43575,6 +43716,9 @@ function convertOpenAIChatUsage(usage) {
|
|
|
43575
43716
|
raw: usage
|
|
43576
43717
|
};
|
|
43577
43718
|
}
|
|
43719
|
+
function serializeToolCallArguments(input) {
|
|
43720
|
+
return JSON.stringify(input === undefined ? {} : input);
|
|
43721
|
+
}
|
|
43578
43722
|
function convertToOpenAIChatMessages({
|
|
43579
43723
|
prompt,
|
|
43580
43724
|
systemMessageMode = "system"
|
|
@@ -43702,7 +43846,7 @@ function convertToOpenAIChatMessages({
|
|
|
43702
43846
|
type: "function",
|
|
43703
43847
|
function: {
|
|
43704
43848
|
name: part.toolName,
|
|
43705
|
-
arguments:
|
|
43849
|
+
arguments: serializeToolCallArguments(part.input)
|
|
43706
43850
|
}
|
|
43707
43851
|
});
|
|
43708
43852
|
break;
|
|
@@ -44037,6 +44181,9 @@ function convertOpenAIResponsesUsage(usage) {
|
|
|
44037
44181
|
raw: usage
|
|
44038
44182
|
};
|
|
44039
44183
|
}
|
|
44184
|
+
function serializeToolCallArguments2(input) {
|
|
44185
|
+
return JSON.stringify(input === undefined ? {} : input);
|
|
44186
|
+
}
|
|
44040
44187
|
function isFileId(data, prefixes) {
|
|
44041
44188
|
if (!prefixes)
|
|
44042
44189
|
return false;
|
|
@@ -44257,7 +44404,7 @@ async function convertToOpenAIResponsesInput({
|
|
|
44257
44404
|
type: "function_call",
|
|
44258
44405
|
call_id: part.toolCallId,
|
|
44259
44406
|
name: resolvedToolName,
|
|
44260
|
-
arguments:
|
|
44407
|
+
arguments: serializeToolCallArguments2(part.input),
|
|
44261
44408
|
id
|
|
44262
44409
|
});
|
|
44263
44410
|
break;
|
|
@@ -47725,7 +47872,7 @@ var openaiErrorDataSchema, openaiFailedResponseHandler, openaiChatResponseSchema
|
|
|
47725
47872
|
}
|
|
47726
47873
|
};
|
|
47727
47874
|
}
|
|
47728
|
-
}, VERSION6 = "3.0.
|
|
47875
|
+
}, VERSION6 = "3.0.53", openai;
|
|
47729
47876
|
var init_dist8 = __esm(() => {
|
|
47730
47877
|
init_dist3();
|
|
47731
47878
|
init_dist();
|
|
@@ -49368,7 +49515,7 @@ var package_default;
|
|
|
49368
49515
|
var init_package = __esm(() => {
|
|
49369
49516
|
package_default = {
|
|
49370
49517
|
name: "@proxysoul/soulforge",
|
|
49371
|
-
version: "2.
|
|
49518
|
+
version: "2.13.0",
|
|
49372
49519
|
description: "Graph-powered code intelligence \u2014 multi-agent coding with codebase-aware AI",
|
|
49373
49520
|
repository: {
|
|
49374
49521
|
type: "git",
|
|
@@ -49419,47 +49566,47 @@ var init_package = __esm(() => {
|
|
|
49419
49566
|
},
|
|
49420
49567
|
devDependencies: {
|
|
49421
49568
|
"@babel/core": "7.29.0",
|
|
49422
|
-
"@biomejs/biome": "2.4.
|
|
49569
|
+
"@biomejs/biome": "2.4.12",
|
|
49423
49570
|
"@types/babel__core": "7.20.5",
|
|
49424
|
-
"@types/bun": "1.3.
|
|
49571
|
+
"@types/bun": "1.3.12",
|
|
49425
49572
|
"@types/linkify-it": "5.0.0",
|
|
49426
|
-
"@types/node": "25.
|
|
49573
|
+
"@types/node": "25.6.0",
|
|
49427
49574
|
"@types/react": "19.2.14",
|
|
49428
49575
|
"babel-plugin-react-compiler": "1.0.0",
|
|
49429
|
-
"bun-types": "1.3.
|
|
49430
|
-
typescript: "6.0.
|
|
49576
|
+
"bun-types": "1.3.12",
|
|
49577
|
+
typescript: "6.0.3"
|
|
49431
49578
|
},
|
|
49432
49579
|
dependencies: {
|
|
49433
|
-
"@ai-sdk/amazon-bedrock": "^4.0.
|
|
49434
|
-
"@ai-sdk/anthropic": "3.0.
|
|
49580
|
+
"@ai-sdk/amazon-bedrock": "^4.0.96",
|
|
49581
|
+
"@ai-sdk/anthropic": "3.0.71",
|
|
49435
49582
|
"@ai-sdk/deepseek": "^2.0.29",
|
|
49436
49583
|
"@ai-sdk/fireworks": "^2.0.46",
|
|
49437
|
-
"@ai-sdk/google": "3.0.
|
|
49584
|
+
"@ai-sdk/google": "3.0.64",
|
|
49438
49585
|
"@ai-sdk/groq": "^3.0.35",
|
|
49439
49586
|
"@ai-sdk/mcp": "^1.0.35",
|
|
49440
49587
|
"@ai-sdk/mistral": "^3.0.30",
|
|
49441
|
-
"@ai-sdk/openai": "3.0.
|
|
49588
|
+
"@ai-sdk/openai": "3.0.53",
|
|
49442
49589
|
"@ai-sdk/openai-compatible": "^2.0.41",
|
|
49443
|
-
"@ai-sdk/xai": "3.0.
|
|
49444
|
-
"@anthropic-ai/sdk": "0.
|
|
49445
|
-
"@llmgateway/ai-sdk-provider": "3.
|
|
49590
|
+
"@ai-sdk/xai": "3.0.83",
|
|
49591
|
+
"@anthropic-ai/sdk": "0.90.0",
|
|
49592
|
+
"@llmgateway/ai-sdk-provider": "3.6.0",
|
|
49446
49593
|
"@modelcontextprotocol/sdk": "^1.29.0",
|
|
49447
49594
|
"@mozilla/readability": "0.6.0",
|
|
49448
|
-
"@openrouter/ai-sdk-provider": "2.
|
|
49449
|
-
"@opentui/react": "0.1.
|
|
49450
|
-
ai: "6.0.
|
|
49595
|
+
"@openrouter/ai-sdk-provider": "2.8.0",
|
|
49596
|
+
"@opentui/react": "0.1.100",
|
|
49597
|
+
ai: "6.0.168",
|
|
49451
49598
|
"ghostty-opentui": "1.4.10",
|
|
49452
49599
|
isbinaryfile: "6.0.0",
|
|
49453
|
-
jsonrepair: "^3.
|
|
49600
|
+
jsonrepair: "^3.14.0",
|
|
49454
49601
|
linkedom: "0.18.12",
|
|
49455
49602
|
"linkify-it": "5.0.0",
|
|
49456
|
-
marked: "
|
|
49603
|
+
marked: "18.0.1",
|
|
49457
49604
|
neovim: "5.4.0",
|
|
49458
49605
|
react: "19.2.5",
|
|
49459
49606
|
shiki: "4.0.2",
|
|
49460
49607
|
"strip-ansi": "7.2.0",
|
|
49461
49608
|
"tree-sitter-wasms": "0.1.13",
|
|
49462
|
-
"ts-morph": "
|
|
49609
|
+
"ts-morph": "28.0.0",
|
|
49463
49610
|
"vercel-minimax-ai-provider": "^0.0.2",
|
|
49464
49611
|
"web-tree-sitter": "0.25.10",
|
|
49465
49612
|
zod: "4.3.6",
|
|
@@ -53185,6 +53332,52 @@ function prepareTools6({
|
|
|
53185
53332
|
}
|
|
53186
53333
|
}
|
|
53187
53334
|
}
|
|
53335
|
+
function parsePath(rawPath) {
|
|
53336
|
+
const segments = [];
|
|
53337
|
+
for (const part of rawPath.split(".")) {
|
|
53338
|
+
const bracketIdx = part.indexOf("[");
|
|
53339
|
+
if (bracketIdx === -1) {
|
|
53340
|
+
segments.push(part);
|
|
53341
|
+
} else {
|
|
53342
|
+
if (bracketIdx > 0)
|
|
53343
|
+
segments.push(part.slice(0, bracketIdx));
|
|
53344
|
+
for (const m of part.matchAll(/\[(\d+)\]/g)) {
|
|
53345
|
+
segments.push(parseInt(m[1], 10));
|
|
53346
|
+
}
|
|
53347
|
+
}
|
|
53348
|
+
}
|
|
53349
|
+
return segments;
|
|
53350
|
+
}
|
|
53351
|
+
function getNestedValue(obj, segments) {
|
|
53352
|
+
let current = obj;
|
|
53353
|
+
for (const seg of segments) {
|
|
53354
|
+
if (current == null || typeof current !== "object")
|
|
53355
|
+
return;
|
|
53356
|
+
current = current[seg];
|
|
53357
|
+
}
|
|
53358
|
+
return current;
|
|
53359
|
+
}
|
|
53360
|
+
function setNestedValue(obj, segments, value) {
|
|
53361
|
+
let current = obj;
|
|
53362
|
+
for (let i = 0;i < segments.length - 1; i++) {
|
|
53363
|
+
const seg = segments[i];
|
|
53364
|
+
const nextSeg = segments[i + 1];
|
|
53365
|
+
if (current[seg] == null) {
|
|
53366
|
+
current[seg] = typeof nextSeg === "number" ? [] : {};
|
|
53367
|
+
}
|
|
53368
|
+
current = current[seg];
|
|
53369
|
+
}
|
|
53370
|
+
current[segments[segments.length - 1]] = value;
|
|
53371
|
+
}
|
|
53372
|
+
function resolvePartialArgValue(arg) {
|
|
53373
|
+
var _a21, _b16;
|
|
53374
|
+
const value = (_b16 = (_a21 = arg.stringValue) != null ? _a21 : arg.numberValue) != null ? _b16 : arg.boolValue;
|
|
53375
|
+
if (value != null)
|
|
53376
|
+
return { value, json: JSON.stringify(value) };
|
|
53377
|
+
if ("nullValue" in arg)
|
|
53378
|
+
return { value: null, json: "null" };
|
|
53379
|
+
return;
|
|
53380
|
+
}
|
|
53188
53381
|
function mapGoogleGenerativeAIFinishReason({
|
|
53189
53382
|
finishReason,
|
|
53190
53383
|
hasToolCalls
|
|
@@ -53209,24 +53402,6 @@ function mapGoogleGenerativeAIFinishReason({
|
|
|
53209
53402
|
return "other";
|
|
53210
53403
|
}
|
|
53211
53404
|
}
|
|
53212
|
-
function getToolCallsFromParts({
|
|
53213
|
-
parts,
|
|
53214
|
-
generateId: generateId3,
|
|
53215
|
-
providerOptionsName
|
|
53216
|
-
}) {
|
|
53217
|
-
const functionCallParts = parts == null ? undefined : parts.filter((part) => ("functionCall" in part));
|
|
53218
|
-
return functionCallParts == null || functionCallParts.length === 0 ? undefined : functionCallParts.map((part) => ({
|
|
53219
|
-
type: "tool-call",
|
|
53220
|
-
toolCallId: generateId3(),
|
|
53221
|
-
toolName: part.functionCall.name,
|
|
53222
|
-
args: JSON.stringify(part.functionCall.args),
|
|
53223
|
-
providerMetadata: part.thoughtSignature ? {
|
|
53224
|
-
[providerOptionsName]: {
|
|
53225
|
-
thoughtSignature: part.thoughtSignature
|
|
53226
|
-
}
|
|
53227
|
-
} : undefined
|
|
53228
|
-
}));
|
|
53229
|
-
}
|
|
53230
53405
|
function extractSources({
|
|
53231
53406
|
groundingMetadata,
|
|
53232
53407
|
generateId: generateId3
|
|
@@ -53394,7 +53569,7 @@ function createGoogleGenerativeAI(options = {}) {
|
|
|
53394
53569
|
provider.tools = googleTools;
|
|
53395
53570
|
return provider;
|
|
53396
53571
|
}
|
|
53397
|
-
var VERSION10 = "3.0.
|
|
53572
|
+
var VERSION10 = "3.0.64", googleErrorDataSchema, googleFailedResponseHandler, googleEmbeddingContentPartSchema, googleEmbeddingModelOptions, GoogleGenerativeAIEmbeddingModel = class {
|
|
53398
53573
|
constructor(modelId, config2) {
|
|
53399
53574
|
this.specificationVersion = "v3";
|
|
53400
53575
|
this.maxEmbeddingsPerCall = 2048;
|
|
@@ -53494,7 +53669,126 @@ var VERSION10 = "3.0.60", googleErrorDataSchema, googleFailedResponseHandler, go
|
|
|
53494
53669
|
response: { headers: responseHeaders, body: rawValue }
|
|
53495
53670
|
};
|
|
53496
53671
|
}
|
|
53497
|
-
}, googleGenerativeAITextEmbeddingResponseSchema, googleGenerativeAISingleEmbeddingResponseSchema, dataUrlRegex, googleLanguageModelOptions,
|
|
53672
|
+
}, googleGenerativeAITextEmbeddingResponseSchema, googleGenerativeAISingleEmbeddingResponseSchema, dataUrlRegex, googleLanguageModelOptions, VertexServiceTierMap, GoogleJSONAccumulator = class {
|
|
53673
|
+
constructor() {
|
|
53674
|
+
this.accumulatedArgs = {};
|
|
53675
|
+
this.jsonText = "";
|
|
53676
|
+
this.pathStack = [];
|
|
53677
|
+
this.stringOpen = false;
|
|
53678
|
+
}
|
|
53679
|
+
processPartialArgs(partialArgs) {
|
|
53680
|
+
let delta = "";
|
|
53681
|
+
for (const arg of partialArgs) {
|
|
53682
|
+
const rawPath = arg.jsonPath.replace(/^\$\./, "");
|
|
53683
|
+
if (!rawPath)
|
|
53684
|
+
continue;
|
|
53685
|
+
const segments = parsePath(rawPath);
|
|
53686
|
+
const existingValue = getNestedValue(this.accumulatedArgs, segments);
|
|
53687
|
+
const isStringContinuation = arg.stringValue != null && existingValue !== undefined;
|
|
53688
|
+
if (isStringContinuation) {
|
|
53689
|
+
const escaped = JSON.stringify(arg.stringValue).slice(1, -1);
|
|
53690
|
+
setNestedValue(this.accumulatedArgs, segments, existingValue + arg.stringValue);
|
|
53691
|
+
delta += escaped;
|
|
53692
|
+
continue;
|
|
53693
|
+
}
|
|
53694
|
+
const resolved = resolvePartialArgValue(arg);
|
|
53695
|
+
if (resolved == null)
|
|
53696
|
+
continue;
|
|
53697
|
+
setNestedValue(this.accumulatedArgs, segments, resolved.value);
|
|
53698
|
+
delta += this.emitNavigationTo(segments, arg, resolved.json);
|
|
53699
|
+
}
|
|
53700
|
+
this.jsonText += delta;
|
|
53701
|
+
return {
|
|
53702
|
+
currentJSON: this.accumulatedArgs,
|
|
53703
|
+
textDelta: delta
|
|
53704
|
+
};
|
|
53705
|
+
}
|
|
53706
|
+
finalize() {
|
|
53707
|
+
const finalArgs = JSON.stringify(this.accumulatedArgs);
|
|
53708
|
+
const closingDelta = finalArgs.slice(this.jsonText.length);
|
|
53709
|
+
return { finalJSON: finalArgs, closingDelta };
|
|
53710
|
+
}
|
|
53711
|
+
ensureRoot() {
|
|
53712
|
+
if (this.pathStack.length === 0) {
|
|
53713
|
+
this.pathStack.push({ segment: "", isArray: false, childCount: 0 });
|
|
53714
|
+
return "{";
|
|
53715
|
+
}
|
|
53716
|
+
return "";
|
|
53717
|
+
}
|
|
53718
|
+
emitNavigationTo(targetSegments, arg, valueJson) {
|
|
53719
|
+
let fragment = "";
|
|
53720
|
+
if (this.stringOpen) {
|
|
53721
|
+
fragment += '"';
|
|
53722
|
+
this.stringOpen = false;
|
|
53723
|
+
}
|
|
53724
|
+
fragment += this.ensureRoot();
|
|
53725
|
+
const targetContainerSegments = targetSegments.slice(0, -1);
|
|
53726
|
+
const leafSegment = targetSegments[targetSegments.length - 1];
|
|
53727
|
+
const commonDepth = this.findCommonStackDepth(targetContainerSegments);
|
|
53728
|
+
fragment += this.closeDownTo(commonDepth);
|
|
53729
|
+
fragment += this.openDownTo(targetContainerSegments, leafSegment);
|
|
53730
|
+
fragment += this.emitLeaf(leafSegment, arg, valueJson);
|
|
53731
|
+
return fragment;
|
|
53732
|
+
}
|
|
53733
|
+
findCommonStackDepth(targetContainer) {
|
|
53734
|
+
const maxDepth = Math.min(this.pathStack.length - 1, targetContainer.length);
|
|
53735
|
+
let common = 0;
|
|
53736
|
+
for (let i = 0;i < maxDepth; i++) {
|
|
53737
|
+
if (this.pathStack[i + 1].segment === targetContainer[i]) {
|
|
53738
|
+
common++;
|
|
53739
|
+
} else {
|
|
53740
|
+
break;
|
|
53741
|
+
}
|
|
53742
|
+
}
|
|
53743
|
+
return common + 1;
|
|
53744
|
+
}
|
|
53745
|
+
closeDownTo(targetDepth) {
|
|
53746
|
+
let fragment = "";
|
|
53747
|
+
while (this.pathStack.length > targetDepth) {
|
|
53748
|
+
const entry = this.pathStack.pop();
|
|
53749
|
+
fragment += entry.isArray ? "]" : "}";
|
|
53750
|
+
}
|
|
53751
|
+
return fragment;
|
|
53752
|
+
}
|
|
53753
|
+
openDownTo(targetContainer, leafSegment) {
|
|
53754
|
+
let fragment = "";
|
|
53755
|
+
const startIdx = this.pathStack.length - 1;
|
|
53756
|
+
for (let i = startIdx;i < targetContainer.length; i++) {
|
|
53757
|
+
const seg = targetContainer[i];
|
|
53758
|
+
const parentEntry = this.pathStack[this.pathStack.length - 1];
|
|
53759
|
+
if (parentEntry.childCount > 0) {
|
|
53760
|
+
fragment += ",";
|
|
53761
|
+
}
|
|
53762
|
+
parentEntry.childCount++;
|
|
53763
|
+
if (typeof seg === "string") {
|
|
53764
|
+
fragment += `${JSON.stringify(seg)}:`;
|
|
53765
|
+
}
|
|
53766
|
+
const childSeg = i + 1 < targetContainer.length ? targetContainer[i + 1] : leafSegment;
|
|
53767
|
+
const isArray = typeof childSeg === "number";
|
|
53768
|
+
fragment += isArray ? "[" : "{";
|
|
53769
|
+
this.pathStack.push({ segment: seg, isArray, childCount: 0 });
|
|
53770
|
+
}
|
|
53771
|
+
return fragment;
|
|
53772
|
+
}
|
|
53773
|
+
emitLeaf(leafSegment, arg, valueJson) {
|
|
53774
|
+
let fragment = "";
|
|
53775
|
+
const container = this.pathStack[this.pathStack.length - 1];
|
|
53776
|
+
if (container.childCount > 0) {
|
|
53777
|
+
fragment += ",";
|
|
53778
|
+
}
|
|
53779
|
+
container.childCount++;
|
|
53780
|
+
if (typeof leafSegment === "string") {
|
|
53781
|
+
fragment += `${JSON.stringify(leafSegment)}:`;
|
|
53782
|
+
}
|
|
53783
|
+
if (arg.stringValue != null && arg.willContinue) {
|
|
53784
|
+
fragment += valueJson.slice(0, -1);
|
|
53785
|
+
this.stringOpen = true;
|
|
53786
|
+
} else {
|
|
53787
|
+
fragment += valueJson;
|
|
53788
|
+
}
|
|
53789
|
+
return fragment;
|
|
53790
|
+
}
|
|
53791
|
+
}, GoogleGenerativeAILanguageModel = class {
|
|
53498
53792
|
constructor(modelId, config2) {
|
|
53499
53793
|
this.specificationVersion = "v3";
|
|
53500
53794
|
var _a21;
|
|
@@ -53523,8 +53817,8 @@ var VERSION10 = "3.0.60", googleErrorDataSchema, googleFailedResponseHandler, go
|
|
|
53523
53817
|
tools,
|
|
53524
53818
|
toolChoice,
|
|
53525
53819
|
providerOptions
|
|
53526
|
-
}) {
|
|
53527
|
-
var _a21;
|
|
53820
|
+
}, { isStreaming = false } = {}) {
|
|
53821
|
+
var _a21, _b16;
|
|
53528
53822
|
const warnings = [];
|
|
53529
53823
|
const providerOptionsName = this.config.provider.includes("vertex") ? "vertex" : "google";
|
|
53530
53824
|
let googleOptions = await parseProviderOptions({
|
|
@@ -53539,12 +53833,23 @@ var VERSION10 = "3.0.60", googleErrorDataSchema, googleFailedResponseHandler, go
|
|
|
53539
53833
|
schema: googleLanguageModelOptions
|
|
53540
53834
|
});
|
|
53541
53835
|
}
|
|
53542
|
-
|
|
53836
|
+
const isVertexProvider = this.config.provider.startsWith("google.vertex.");
|
|
53837
|
+
if ((tools == null ? undefined : tools.some((tool2) => tool2.type === "provider" && tool2.id === "google.vertex_rag_store")) && !isVertexProvider) {
|
|
53543
53838
|
warnings.push({
|
|
53544
53839
|
type: "other",
|
|
53545
53840
|
message: `The 'vertex_rag_store' tool is only supported with the Google Vertex provider and might not be supported or could behave unexpectedly with the current Google provider (${this.config.provider}).`
|
|
53546
53841
|
});
|
|
53547
53842
|
}
|
|
53843
|
+
if ((googleOptions == null ? undefined : googleOptions.streamFunctionCallArguments) && !isVertexProvider) {
|
|
53844
|
+
warnings.push({
|
|
53845
|
+
type: "other",
|
|
53846
|
+
message: `'streamFunctionCallArguments' is only supported on the Vertex AI API and will be ignored with the current Google provider (${this.config.provider}). See https://docs.cloud.google.com/vertex-ai/generative-ai/docs/multimodal/function-calling#streaming-fc`
|
|
53847
|
+
});
|
|
53848
|
+
}
|
|
53849
|
+
let sanitizedServiceTier = googleOptions == null ? undefined : googleOptions.serviceTier;
|
|
53850
|
+
if ((googleOptions == null ? undefined : googleOptions.serviceTier) && isVertexProvider) {
|
|
53851
|
+
sanitizedServiceTier = VertexServiceTierMap[googleOptions.serviceTier];
|
|
53852
|
+
}
|
|
53548
53853
|
const isGemmaModel = this.modelId.toLowerCase().startsWith("gemma-");
|
|
53549
53854
|
const supportsFunctionResponseParts = this.modelId.startsWith("gemini-3");
|
|
53550
53855
|
const { contents, systemInstruction } = convertToGoogleGenerativeAIMessages(prompt, {
|
|
@@ -53561,6 +53866,19 @@ var VERSION10 = "3.0.60", googleErrorDataSchema, googleFailedResponseHandler, go
|
|
|
53561
53866
|
toolChoice,
|
|
53562
53867
|
modelId: this.modelId
|
|
53563
53868
|
});
|
|
53869
|
+
const streamFunctionCallArguments = isStreaming && isVertexProvider ? (_a21 = googleOptions == null ? undefined : googleOptions.streamFunctionCallArguments) != null ? _a21 : false : undefined;
|
|
53870
|
+
const toolConfig = googleToolConfig || streamFunctionCallArguments || (googleOptions == null ? undefined : googleOptions.retrievalConfig) ? {
|
|
53871
|
+
...googleToolConfig,
|
|
53872
|
+
...streamFunctionCallArguments && {
|
|
53873
|
+
functionCallingConfig: {
|
|
53874
|
+
...googleToolConfig == null ? undefined : googleToolConfig.functionCallingConfig,
|
|
53875
|
+
streamFunctionCallArguments: true
|
|
53876
|
+
}
|
|
53877
|
+
},
|
|
53878
|
+
...(googleOptions == null ? undefined : googleOptions.retrievalConfig) && {
|
|
53879
|
+
retrievalConfig: googleOptions.retrievalConfig
|
|
53880
|
+
}
|
|
53881
|
+
} : undefined;
|
|
53564
53882
|
return {
|
|
53565
53883
|
args: {
|
|
53566
53884
|
generationConfig: {
|
|
@@ -53573,7 +53891,7 @@ var VERSION10 = "3.0.60", googleErrorDataSchema, googleFailedResponseHandler, go
|
|
|
53573
53891
|
stopSequences,
|
|
53574
53892
|
seed,
|
|
53575
53893
|
responseMimeType: (responseFormat == null ? undefined : responseFormat.type) === "json" ? "application/json" : undefined,
|
|
53576
|
-
responseSchema: (responseFormat == null ? undefined : responseFormat.type) === "json" && responseFormat.schema != null && ((
|
|
53894
|
+
responseSchema: (responseFormat == null ? undefined : responseFormat.type) === "json" && responseFormat.schema != null && ((_b16 = googleOptions == null ? undefined : googleOptions.structuredOutputs) != null ? _b16 : true) ? convertJSONSchemaToOpenAPISchema(responseFormat.schema) : undefined,
|
|
53577
53895
|
...(googleOptions == null ? undefined : googleOptions.audioTimestamp) && {
|
|
53578
53896
|
audioTimestamp: googleOptions.audioTimestamp
|
|
53579
53897
|
},
|
|
@@ -53590,13 +53908,10 @@ var VERSION10 = "3.0.60", googleErrorDataSchema, googleFailedResponseHandler, go
|
|
|
53590
53908
|
systemInstruction: isGemmaModel ? undefined : systemInstruction,
|
|
53591
53909
|
safetySettings: googleOptions == null ? undefined : googleOptions.safetySettings,
|
|
53592
53910
|
tools: googleTools2,
|
|
53593
|
-
toolConfig
|
|
53594
|
-
...googleToolConfig,
|
|
53595
|
-
retrievalConfig: googleOptions.retrievalConfig
|
|
53596
|
-
} : googleToolConfig,
|
|
53911
|
+
toolConfig,
|
|
53597
53912
|
cachedContent: googleOptions == null ? undefined : googleOptions.cachedContent,
|
|
53598
53913
|
labels: googleOptions == null ? undefined : googleOptions.labels,
|
|
53599
|
-
serviceTier:
|
|
53914
|
+
serviceTier: sanitizedServiceTier
|
|
53600
53915
|
},
|
|
53601
53916
|
warnings: [...warnings, ...toolWarnings],
|
|
53602
53917
|
providerOptionsName
|
|
@@ -53665,7 +53980,7 @@ var VERSION10 = "3.0.60", googleErrorDataSchema, googleFailedResponseHandler, go
|
|
|
53665
53980
|
providerMetadata: thoughtSignatureMetadata
|
|
53666
53981
|
});
|
|
53667
53982
|
}
|
|
53668
|
-
} else if ("functionCall" in part) {
|
|
53983
|
+
} else if ("functionCall" in part && part.functionCall.name != null && part.functionCall.args != null) {
|
|
53669
53984
|
content.push({
|
|
53670
53985
|
type: "tool-call",
|
|
53671
53986
|
toolCallId: this.config.generateId(),
|
|
@@ -53774,7 +54089,7 @@ var VERSION10 = "3.0.60", googleErrorDataSchema, googleFailedResponseHandler, go
|
|
|
53774
54089
|
};
|
|
53775
54090
|
}
|
|
53776
54091
|
async doStream(options) {
|
|
53777
|
-
const { args, warnings, providerOptionsName } = await this.getArgs(options);
|
|
54092
|
+
const { args, warnings, providerOptionsName } = await this.getArgs(options, { isStreaming: true });
|
|
53778
54093
|
const headers = combineHeaders(await resolve(this.config.headers), options.headers);
|
|
53779
54094
|
const { responseHeaders, value: response } = await postJsonToApi({
|
|
53780
54095
|
url: `${this.config.baseURL}/${getModelPath(this.modelId)}:streamGenerateContent?alt=sse`,
|
|
@@ -53802,13 +54117,14 @@ var VERSION10 = "3.0.60", googleErrorDataSchema, googleFailedResponseHandler, go
|
|
|
53802
54117
|
const emittedSourceUrls = /* @__PURE__ */ new Set;
|
|
53803
54118
|
let lastCodeExecutionToolCallId;
|
|
53804
54119
|
let lastServerToolCallId;
|
|
54120
|
+
const activeStreamingToolCalls = [];
|
|
53805
54121
|
return {
|
|
53806
54122
|
stream: response.pipeThrough(new TransformStream({
|
|
53807
54123
|
start(controller) {
|
|
53808
54124
|
controller.enqueue({ type: "stream-start", warnings });
|
|
53809
54125
|
},
|
|
53810
54126
|
transform(chunk, controller) {
|
|
53811
|
-
var _a21, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
54127
|
+
var _a21, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l;
|
|
53812
54128
|
if (options.includeRawChunks) {
|
|
53813
54129
|
controller.enqueue({ type: "raw", rawValue: chunk.rawValue });
|
|
53814
54130
|
}
|
|
@@ -54001,36 +54317,107 @@ var VERSION10 = "3.0.60", googleErrorDataSchema, googleFailedResponseHandler, go
|
|
|
54001
54317
|
lastServerToolCallId = undefined;
|
|
54002
54318
|
}
|
|
54003
54319
|
}
|
|
54004
|
-
const
|
|
54005
|
-
|
|
54006
|
-
|
|
54007
|
-
|
|
54008
|
-
|
|
54009
|
-
|
|
54010
|
-
|
|
54320
|
+
for (const part of parts) {
|
|
54321
|
+
if (!("functionCall" in part))
|
|
54322
|
+
continue;
|
|
54323
|
+
const providerMeta = part.thoughtSignature ? {
|
|
54324
|
+
[providerOptionsName]: {
|
|
54325
|
+
thoughtSignature: part.thoughtSignature
|
|
54326
|
+
}
|
|
54327
|
+
} : undefined;
|
|
54328
|
+
const isStreamingChunk = part.functionCall.partialArgs != null || part.functionCall.name != null && part.functionCall.willContinue === true;
|
|
54329
|
+
const isTerminalChunk = part.functionCall.name == null && part.functionCall.args == null && part.functionCall.partialArgs == null && part.functionCall.willContinue == null;
|
|
54330
|
+
const isCompleteCall = part.functionCall.name != null && part.functionCall.args != null && part.functionCall.partialArgs == null;
|
|
54331
|
+
if (isStreamingChunk) {
|
|
54332
|
+
if (part.functionCall.name != null && part.functionCall.willContinue === true) {
|
|
54333
|
+
const toolCallId = generateId3();
|
|
54334
|
+
const accumulator = new GoogleJSONAccumulator;
|
|
54335
|
+
activeStreamingToolCalls.push({
|
|
54336
|
+
toolCallId,
|
|
54337
|
+
toolName: part.functionCall.name,
|
|
54338
|
+
accumulator,
|
|
54339
|
+
providerMetadata: providerMeta
|
|
54340
|
+
});
|
|
54341
|
+
controller.enqueue({
|
|
54342
|
+
type: "tool-input-start",
|
|
54343
|
+
id: toolCallId,
|
|
54344
|
+
toolName: part.functionCall.name,
|
|
54345
|
+
providerMetadata: providerMeta
|
|
54346
|
+
});
|
|
54347
|
+
if (part.functionCall.partialArgs != null) {
|
|
54348
|
+
const { textDelta } = accumulator.processPartialArgs(part.functionCall.partialArgs);
|
|
54349
|
+
if (textDelta.length > 0) {
|
|
54350
|
+
controller.enqueue({
|
|
54351
|
+
type: "tool-input-delta",
|
|
54352
|
+
id: toolCallId,
|
|
54353
|
+
delta: textDelta,
|
|
54354
|
+
providerMetadata: providerMeta
|
|
54355
|
+
});
|
|
54356
|
+
}
|
|
54357
|
+
}
|
|
54358
|
+
} else if (part.functionCall.partialArgs != null && activeStreamingToolCalls.length > 0) {
|
|
54359
|
+
const active = activeStreamingToolCalls[activeStreamingToolCalls.length - 1];
|
|
54360
|
+
const { textDelta } = active.accumulator.processPartialArgs(part.functionCall.partialArgs);
|
|
54361
|
+
if (textDelta.length > 0) {
|
|
54362
|
+
controller.enqueue({
|
|
54363
|
+
type: "tool-input-delta",
|
|
54364
|
+
id: active.toolCallId,
|
|
54365
|
+
delta: textDelta,
|
|
54366
|
+
providerMetadata: providerMeta
|
|
54367
|
+
});
|
|
54368
|
+
}
|
|
54369
|
+
}
|
|
54370
|
+
} else if (isTerminalChunk && activeStreamingToolCalls.length > 0) {
|
|
54371
|
+
const active = activeStreamingToolCalls.pop();
|
|
54372
|
+
const { finalJSON, closingDelta } = active.accumulator.finalize();
|
|
54373
|
+
if (closingDelta.length > 0) {
|
|
54374
|
+
controller.enqueue({
|
|
54375
|
+
type: "tool-input-delta",
|
|
54376
|
+
id: active.toolCallId,
|
|
54377
|
+
delta: closingDelta,
|
|
54378
|
+
providerMetadata: active.providerMetadata
|
|
54379
|
+
});
|
|
54380
|
+
}
|
|
54381
|
+
controller.enqueue({
|
|
54382
|
+
type: "tool-input-end",
|
|
54383
|
+
id: active.toolCallId,
|
|
54384
|
+
providerMetadata: active.providerMetadata
|
|
54385
|
+
});
|
|
54386
|
+
controller.enqueue({
|
|
54387
|
+
type: "tool-call",
|
|
54388
|
+
toolCallId: active.toolCallId,
|
|
54389
|
+
toolName: active.toolName,
|
|
54390
|
+
input: finalJSON,
|
|
54391
|
+
providerMetadata: active.providerMetadata
|
|
54392
|
+
});
|
|
54393
|
+
hasToolCalls = true;
|
|
54394
|
+
} else if (isCompleteCall) {
|
|
54395
|
+
const toolCallId = generateId3();
|
|
54396
|
+
const toolName = part.functionCall.name;
|
|
54397
|
+
const args2 = typeof part.functionCall.args === "string" ? part.functionCall.args : JSON.stringify((_i = part.functionCall.args) != null ? _i : {});
|
|
54011
54398
|
controller.enqueue({
|
|
54012
54399
|
type: "tool-input-start",
|
|
54013
|
-
id:
|
|
54014
|
-
toolName
|
|
54015
|
-
providerMetadata:
|
|
54400
|
+
id: toolCallId,
|
|
54401
|
+
toolName,
|
|
54402
|
+
providerMetadata: providerMeta
|
|
54016
54403
|
});
|
|
54017
54404
|
controller.enqueue({
|
|
54018
54405
|
type: "tool-input-delta",
|
|
54019
|
-
id:
|
|
54020
|
-
delta:
|
|
54021
|
-
providerMetadata:
|
|
54406
|
+
id: toolCallId,
|
|
54407
|
+
delta: args2,
|
|
54408
|
+
providerMetadata: providerMeta
|
|
54022
54409
|
});
|
|
54023
54410
|
controller.enqueue({
|
|
54024
54411
|
type: "tool-input-end",
|
|
54025
|
-
id:
|
|
54026
|
-
providerMetadata:
|
|
54412
|
+
id: toolCallId,
|
|
54413
|
+
providerMetadata: providerMeta
|
|
54027
54414
|
});
|
|
54028
54415
|
controller.enqueue({
|
|
54029
54416
|
type: "tool-call",
|
|
54030
|
-
toolCallId
|
|
54031
|
-
toolName
|
|
54032
|
-
input:
|
|
54033
|
-
providerMetadata:
|
|
54417
|
+
toolCallId,
|
|
54418
|
+
toolName,
|
|
54419
|
+
input: args2,
|
|
54420
|
+
providerMetadata: providerMeta
|
|
54034
54421
|
});
|
|
54035
54422
|
hasToolCalls = true;
|
|
54036
54423
|
}
|
|
@@ -54046,12 +54433,12 @@ var VERSION10 = "3.0.60", googleErrorDataSchema, googleFailedResponseHandler, go
|
|
|
54046
54433
|
};
|
|
54047
54434
|
providerMetadata = {
|
|
54048
54435
|
[providerOptionsName]: {
|
|
54049
|
-
promptFeedback: (
|
|
54436
|
+
promptFeedback: (_j = value.promptFeedback) != null ? _j : null,
|
|
54050
54437
|
groundingMetadata: lastGroundingMetadata,
|
|
54051
54438
|
urlContextMetadata: lastUrlContextMetadata,
|
|
54052
|
-
safetyRatings: (
|
|
54439
|
+
safetyRatings: (_k = candidate.safetyRatings) != null ? _k : null,
|
|
54053
54440
|
usageMetadata: usageMetadata != null ? usageMetadata : null,
|
|
54054
|
-
finishMessage: (
|
|
54441
|
+
finishMessage: (_l = candidate.finishMessage) != null ? _l : null,
|
|
54055
54442
|
serviceTier
|
|
54056
54443
|
}
|
|
54057
54444
|
};
|
|
@@ -54126,12 +54513,14 @@ var VERSION10 = "3.0.60", googleErrorDataSchema, googleFailedResponseHandler, go
|
|
|
54126
54513
|
}),
|
|
54127
54514
|
exports_external.object({})
|
|
54128
54515
|
]).nullish()
|
|
54129
|
-
}), getContentSchema = () => exports_external.object({
|
|
54516
|
+
}), partialArgSchema, getContentSchema = () => exports_external.object({
|
|
54130
54517
|
parts: exports_external.array(exports_external.union([
|
|
54131
54518
|
exports_external.object({
|
|
54132
54519
|
functionCall: exports_external.object({
|
|
54133
|
-
name: exports_external.string(),
|
|
54134
|
-
args: exports_external.unknown()
|
|
54520
|
+
name: exports_external.string().nullish(),
|
|
54521
|
+
args: exports_external.unknown().nullish(),
|
|
54522
|
+
partialArgs: exports_external.array(partialArgSchema).nullish(),
|
|
54523
|
+
willContinue: exports_external.boolean().nullish()
|
|
54135
54524
|
}),
|
|
54136
54525
|
thoughtSignature: exports_external.string().nullish()
|
|
54137
54526
|
}),
|
|
@@ -54734,8 +55123,22 @@ var init_dist12 = __esm(() => {
|
|
|
54734
55123
|
longitude: exports_external.number()
|
|
54735
55124
|
}).optional()
|
|
54736
55125
|
}).optional(),
|
|
55126
|
+
streamFunctionCallArguments: exports_external.boolean().optional(),
|
|
54737
55127
|
serviceTier: exports_external.enum(["standard", "flex", "priority"]).optional()
|
|
54738
55128
|
})));
|
|
55129
|
+
VertexServiceTierMap = {
|
|
55130
|
+
standard: "SERVICE_TIER_STANDARD",
|
|
55131
|
+
flex: "SERVICE_TIER_FLEX",
|
|
55132
|
+
priority: "SERVICE_TIER_PRIORITY"
|
|
55133
|
+
};
|
|
55134
|
+
partialArgSchema = exports_external.object({
|
|
55135
|
+
jsonPath: exports_external.string(),
|
|
55136
|
+
stringValue: exports_external.string().nullish(),
|
|
55137
|
+
numberValue: exports_external.number().nullish(),
|
|
55138
|
+
boolValue: exports_external.boolean().nullish(),
|
|
55139
|
+
nullValue: exports_external.unknown().nullish(),
|
|
55140
|
+
willContinue: exports_external.boolean().nullish()
|
|
55141
|
+
});
|
|
54739
55142
|
tokenDetailsSchema = exports_external.array(exports_external.object({
|
|
54740
55143
|
modality: exports_external.string(),
|
|
54741
55144
|
tokenCount: exports_external.number()
|
|
@@ -57072,16 +57475,16 @@ function withoutTrailingSlash2(url2) {
|
|
|
57072
57475
|
function mapLLMGatewayFinishReason(finishReason) {
|
|
57073
57476
|
switch (finishReason) {
|
|
57074
57477
|
case "stop":
|
|
57075
|
-
return "stop";
|
|
57478
|
+
return { unified: "stop", raw: finishReason };
|
|
57076
57479
|
case "length":
|
|
57077
|
-
return "length";
|
|
57480
|
+
return { unified: "length", raw: finishReason };
|
|
57078
57481
|
case "content_filter":
|
|
57079
|
-
return "content-filter";
|
|
57482
|
+
return { unified: "content-filter", raw: finishReason };
|
|
57080
57483
|
case "function_call":
|
|
57081
57484
|
case "tool_calls":
|
|
57082
|
-
return "tool-calls";
|
|
57485
|
+
return { unified: "tool-calls", raw: finishReason };
|
|
57083
57486
|
default:
|
|
57084
|
-
return "
|
|
57487
|
+
return { unified: "other", raw: finishReason != null ? finishReason : undefined };
|
|
57085
57488
|
}
|
|
57086
57489
|
}
|
|
57087
57490
|
function isUrl({
|
|
@@ -57272,6 +57675,8 @@ function convertToLLMGatewayChatMessages(prompt) {
|
|
|
57272
57675
|
}
|
|
57273
57676
|
case "tool": {
|
|
57274
57677
|
for (const toolResponse of content) {
|
|
57678
|
+
if (toolResponse.type !== "tool-result")
|
|
57679
|
+
continue;
|
|
57275
57680
|
const content2 = getToolResultContent(toolResponse);
|
|
57276
57681
|
messages.push({
|
|
57277
57682
|
role: "tool",
|
|
@@ -57290,7 +57695,14 @@ function convertToLLMGatewayChatMessages(prompt) {
|
|
|
57290
57695
|
return messages;
|
|
57291
57696
|
}
|
|
57292
57697
|
function getToolResultContent(input) {
|
|
57293
|
-
|
|
57698
|
+
switch (input.output.type) {
|
|
57699
|
+
case "text":
|
|
57700
|
+
return input.output.value;
|
|
57701
|
+
case "json":
|
|
57702
|
+
return JSON.stringify(input.output.value);
|
|
57703
|
+
default:
|
|
57704
|
+
return JSON.stringify(input.output);
|
|
57705
|
+
}
|
|
57294
57706
|
}
|
|
57295
57707
|
function getChatCompletionToolChoice(toolChoice) {
|
|
57296
57708
|
switch (toolChoice.type) {
|
|
@@ -57883,9 +58295,8 @@ var __defProp3, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
|
|
|
57883
58295
|
};
|
|
57884
58296
|
}, ReasoningDetailSummarySchema, ReasoningDetailEncryptedSchema, ReasoningDetailTextSchema, ReasoningDetailUnionSchema, ReasoningDetailsWithUnknownSchema, ReasoningDetailArraySchema, LLMGatewayErrorResponseSchema, llmgatewayFailedResponseHandler, ChatCompletionToolChoiceSchema, ImageResponseSchema, ImageResponseWithUnknownSchema, ImageResponseArraySchema, LLMGatewayChatCompletionBaseResponseSchema, LLMGatewayNonStreamChatCompletionResponseSchema, LLMGatewayStreamChatCompletionChunkSchema, LLMGatewayChatLanguageModel = class {
|
|
57885
58297
|
constructor(modelId, settings, config2) {
|
|
57886
|
-
this.specificationVersion = "
|
|
58298
|
+
this.specificationVersion = "v3";
|
|
57887
58299
|
this.provider = "llmgateway";
|
|
57888
|
-
this.defaultObjectGenerationMode = "tool";
|
|
57889
58300
|
this.supportedUrls = {
|
|
57890
58301
|
"image/*": [
|
|
57891
58302
|
/^data:image\/[a-zA-Z]+;base64,/,
|
|
@@ -57968,7 +58379,7 @@ var __defProp3, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
|
|
|
57968
58379
|
return baseArgs;
|
|
57969
58380
|
}
|
|
57970
58381
|
async doGenerate(options) {
|
|
57971
|
-
var _a162, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y
|
|
58382
|
+
var _a162, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v, _w, _x, _y;
|
|
57972
58383
|
const providerOptions = options.providerOptions || {};
|
|
57973
58384
|
const llmgatewayOptions = providerOptions.llmgateway || {};
|
|
57974
58385
|
const args = __spreadValues(__spreadValues({}, this.getArgs(options)), llmgatewayOptions);
|
|
@@ -57990,19 +58401,31 @@ var __defProp3, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
|
|
|
57990
58401
|
throw new Error("No choice in response");
|
|
57991
58402
|
}
|
|
57992
58403
|
const usageInfo = response.usage ? {
|
|
57993
|
-
inputTokens:
|
|
57994
|
-
|
|
57995
|
-
|
|
57996
|
-
|
|
57997
|
-
|
|
58404
|
+
inputTokens: {
|
|
58405
|
+
total: (_b16 = response.usage.prompt_tokens) != null ? _b16 : undefined,
|
|
58406
|
+
noCache: undefined,
|
|
58407
|
+
cacheRead: (_d = (_c = response.usage.prompt_tokens_details) == null ? undefined : _c.cached_tokens) != null ? _d : undefined,
|
|
58408
|
+
cacheWrite: undefined
|
|
58409
|
+
},
|
|
58410
|
+
outputTokens: {
|
|
58411
|
+
total: (_e = response.usage.completion_tokens) != null ? _e : undefined,
|
|
58412
|
+
text: undefined,
|
|
58413
|
+
reasoning: (_g = (_f = response.usage.completion_tokens_details) == null ? undefined : _f.reasoning_tokens) != null ? _g : undefined
|
|
58414
|
+
}
|
|
57998
58415
|
} : {
|
|
57999
|
-
inputTokens:
|
|
58000
|
-
|
|
58001
|
-
|
|
58002
|
-
|
|
58003
|
-
|
|
58416
|
+
inputTokens: {
|
|
58417
|
+
total: undefined,
|
|
58418
|
+
noCache: undefined,
|
|
58419
|
+
cacheRead: undefined,
|
|
58420
|
+
cacheWrite: undefined
|
|
58421
|
+
},
|
|
58422
|
+
outputTokens: {
|
|
58423
|
+
total: undefined,
|
|
58424
|
+
text: undefined,
|
|
58425
|
+
reasoning: undefined
|
|
58426
|
+
}
|
|
58004
58427
|
};
|
|
58005
|
-
const reasoningDetails = (
|
|
58428
|
+
const reasoningDetails = (_h = choice2.message.reasoning_details) != null ? _h : [];
|
|
58006
58429
|
const reasoning = reasoningDetails.length > 0 ? reasoningDetails.map((detail) => {
|
|
58007
58430
|
switch (detail.type) {
|
|
58008
58431
|
case "reasoning.text": {
|
|
@@ -58056,7 +58479,7 @@ var __defProp3, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
|
|
|
58056
58479
|
for (const toolCall of choice2.message.tool_calls) {
|
|
58057
58480
|
content.push({
|
|
58058
58481
|
type: "tool-call",
|
|
58059
|
-
toolCallId: (
|
|
58482
|
+
toolCallId: (_i = toolCall.id) != null ? _i : generateId2(),
|
|
58060
58483
|
toolName: toolCall.function.name,
|
|
58061
58484
|
input: toolCall.function.arguments
|
|
58062
58485
|
});
|
|
@@ -58097,18 +58520,18 @@ var __defProp3, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
|
|
|
58097
58520
|
providerMetadata: includeUsageAccounting ? {
|
|
58098
58521
|
llmgateway: {
|
|
58099
58522
|
usage: {
|
|
58100
|
-
promptTokens: (
|
|
58101
|
-
completionTokens: (
|
|
58102
|
-
totalTokens: (
|
|
58103
|
-
cost: typeof ((
|
|
58523
|
+
promptTokens: (_j = usageInfo.inputTokens.total) != null ? _j : 0,
|
|
58524
|
+
completionTokens: (_k = usageInfo.outputTokens.total) != null ? _k : 0,
|
|
58525
|
+
totalTokens: ((_l = usageInfo.inputTokens.total) != null ? _l : 0) + ((_m = usageInfo.outputTokens.total) != null ? _m : 0),
|
|
58526
|
+
cost: typeof ((_n = response.usage) == null ? undefined : _n.cost) === "number" ? response.usage.cost : (_p = (_o = response.usage) == null ? undefined : _o.cost) == null ? undefined : _p.total_cost,
|
|
58104
58527
|
promptTokensDetails: {
|
|
58105
|
-
cachedTokens: (
|
|
58528
|
+
cachedTokens: (_s = (_r = (_q = response.usage) == null ? undefined : _q.prompt_tokens_details) == null ? undefined : _r.cached_tokens) != null ? _s : 0
|
|
58106
58529
|
},
|
|
58107
58530
|
completionTokensDetails: {
|
|
58108
|
-
reasoningTokens: (
|
|
58531
|
+
reasoningTokens: (_v = (_u = (_t = response.usage) == null ? undefined : _t.completion_tokens_details) == null ? undefined : _u.reasoning_tokens) != null ? _v : 0
|
|
58109
58532
|
},
|
|
58110
58533
|
costDetails: {
|
|
58111
|
-
upstreamInferenceCost: (
|
|
58534
|
+
upstreamInferenceCost: (_y = (_x = (_w = response.usage) == null ? undefined : _w.cost_details) == null ? undefined : _x.upstream_inference_cost) != null ? _y : 0
|
|
58112
58535
|
}
|
|
58113
58536
|
}
|
|
58114
58537
|
}
|
|
@@ -58141,13 +58564,19 @@ var __defProp3, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
|
|
|
58141
58564
|
fetch: this.config.fetch
|
|
58142
58565
|
});
|
|
58143
58566
|
const toolCalls = [];
|
|
58144
|
-
let finishReason = "other";
|
|
58567
|
+
let finishReason = { unified: "other", raw: undefined };
|
|
58145
58568
|
const usage = {
|
|
58146
|
-
inputTokens:
|
|
58147
|
-
|
|
58148
|
-
|
|
58149
|
-
|
|
58150
|
-
|
|
58569
|
+
inputTokens: {
|
|
58570
|
+
total: undefined,
|
|
58571
|
+
noCache: undefined,
|
|
58572
|
+
cacheRead: undefined,
|
|
58573
|
+
cacheWrite: undefined
|
|
58574
|
+
},
|
|
58575
|
+
outputTokens: {
|
|
58576
|
+
total: undefined,
|
|
58577
|
+
text: undefined,
|
|
58578
|
+
reasoning: undefined
|
|
58579
|
+
}
|
|
58151
58580
|
};
|
|
58152
58581
|
const llmgatewayUsage = {};
|
|
58153
58582
|
let textStarted = false;
|
|
@@ -58160,13 +58589,13 @@ var __defProp3, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
|
|
|
58160
58589
|
transform(chunk, controller) {
|
|
58161
58590
|
var _a162, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q;
|
|
58162
58591
|
if (!chunk.success) {
|
|
58163
|
-
finishReason = "error";
|
|
58592
|
+
finishReason = { unified: "error", raw: undefined };
|
|
58164
58593
|
controller.enqueue({ type: "error", error: chunk.error });
|
|
58165
58594
|
return;
|
|
58166
58595
|
}
|
|
58167
58596
|
const value = chunk.value;
|
|
58168
58597
|
if ("error" in value) {
|
|
58169
|
-
finishReason = "error";
|
|
58598
|
+
finishReason = { unified: "error", raw: undefined };
|
|
58170
58599
|
controller.enqueue({ type: "error", error: value.error });
|
|
58171
58600
|
return;
|
|
58172
58601
|
}
|
|
@@ -58184,13 +58613,12 @@ var __defProp3, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
|
|
|
58184
58613
|
});
|
|
58185
58614
|
}
|
|
58186
58615
|
if (value.usage != null) {
|
|
58187
|
-
usage.inputTokens = value.usage.prompt_tokens;
|
|
58188
|
-
usage.outputTokens = value.usage.completion_tokens;
|
|
58189
|
-
usage.totalTokens = value.usage.prompt_tokens + value.usage.completion_tokens;
|
|
58616
|
+
usage.inputTokens.total = value.usage.prompt_tokens;
|
|
58617
|
+
usage.outputTokens.total = value.usage.completion_tokens;
|
|
58190
58618
|
llmgatewayUsage.promptTokens = value.usage.prompt_tokens;
|
|
58191
58619
|
if (value.usage.prompt_tokens_details) {
|
|
58192
58620
|
const cachedInputTokens = (_a162 = value.usage.prompt_tokens_details.cached_tokens) != null ? _a162 : 0;
|
|
58193
|
-
usage.
|
|
58621
|
+
usage.inputTokens.cacheRead = cachedInputTokens;
|
|
58194
58622
|
llmgatewayUsage.promptTokensDetails = {
|
|
58195
58623
|
cachedTokens: cachedInputTokens
|
|
58196
58624
|
};
|
|
@@ -58198,7 +58626,7 @@ var __defProp3, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
|
|
|
58198
58626
|
llmgatewayUsage.completionTokens = value.usage.completion_tokens;
|
|
58199
58627
|
if (value.usage.completion_tokens_details) {
|
|
58200
58628
|
const reasoningTokens = (_b16 = value.usage.completion_tokens_details.reasoning_tokens) != null ? _b16 : 0;
|
|
58201
|
-
usage.
|
|
58629
|
+
usage.outputTokens.reasoning = reasoningTokens;
|
|
58202
58630
|
llmgatewayUsage.completionTokensDetails = {
|
|
58203
58631
|
reasoningTokens
|
|
58204
58632
|
};
|
|
@@ -58378,7 +58806,7 @@ var __defProp3, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
|
|
|
58378
58806
|
},
|
|
58379
58807
|
flush(controller) {
|
|
58380
58808
|
var _a162;
|
|
58381
|
-
if (finishReason === "tool-calls") {
|
|
58809
|
+
if (finishReason.unified === "tool-calls") {
|
|
58382
58810
|
for (const toolCall of toolCalls) {
|
|
58383
58811
|
if (toolCall && !toolCall.sent) {
|
|
58384
58812
|
controller.enqueue({
|
|
@@ -58415,14 +58843,13 @@ var __defProp3, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
|
|
|
58415
58843
|
});
|
|
58416
58844
|
}
|
|
58417
58845
|
})),
|
|
58418
|
-
warnings: [],
|
|
58419
58846
|
request: { body: args },
|
|
58420
58847
|
response: { headers: responseHeaders }
|
|
58421
58848
|
};
|
|
58422
58849
|
}
|
|
58423
58850
|
}, LLMGatewayCompletionChunkSchema, LLMGatewayCompletionLanguageModel = class {
|
|
58424
58851
|
constructor(modelId, settings, config2) {
|
|
58425
|
-
this.specificationVersion = "
|
|
58852
|
+
this.specificationVersion = "v3";
|
|
58426
58853
|
this.provider = "llmgateway";
|
|
58427
58854
|
this.supportedUrls = {
|
|
58428
58855
|
"image/*": [
|
|
@@ -58432,7 +58859,6 @@ var __defProp3, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
|
|
|
58432
58859
|
"text/*": [/^data:text\//, /^https?:\/\/.+$/],
|
|
58433
58860
|
"application/*": [/^data:application\//, /^https?:\/\/.+$/]
|
|
58434
58861
|
};
|
|
58435
|
-
this.defaultObjectGenerationMode = undefined;
|
|
58436
58862
|
this.modelId = modelId;
|
|
58437
58863
|
this.settings = settings;
|
|
58438
58864
|
this.config = config2;
|
|
@@ -58487,7 +58913,7 @@ var __defProp3, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
|
|
|
58487
58913
|
}, this.config.extraBody), this.settings.extraBody);
|
|
58488
58914
|
}
|
|
58489
58915
|
async doGenerate(options) {
|
|
58490
|
-
var _a162, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k
|
|
58916
|
+
var _a162, _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k;
|
|
58491
58917
|
const providerOptions = options.providerOptions || {};
|
|
58492
58918
|
const llmgatewayOptions = providerOptions.llmgateway || {};
|
|
58493
58919
|
const args = __spreadValues(__spreadValues({}, this.getArgs(options)), llmgatewayOptions);
|
|
@@ -58519,11 +58945,17 @@ var __defProp3, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
|
|
|
58519
58945
|
],
|
|
58520
58946
|
finishReason: mapLLMGatewayFinishReason(choice2.finish_reason),
|
|
58521
58947
|
usage: {
|
|
58522
|
-
inputTokens:
|
|
58523
|
-
|
|
58524
|
-
|
|
58525
|
-
|
|
58526
|
-
|
|
58948
|
+
inputTokens: {
|
|
58949
|
+
total: (_c = (_b16 = response.usage) == null ? undefined : _b16.prompt_tokens) != null ? _c : undefined,
|
|
58950
|
+
noCache: undefined,
|
|
58951
|
+
cacheRead: (_f = (_e = (_d = response.usage) == null ? undefined : _d.prompt_tokens_details) == null ? undefined : _e.cached_tokens) != null ? _f : undefined,
|
|
58952
|
+
cacheWrite: undefined
|
|
58953
|
+
},
|
|
58954
|
+
outputTokens: {
|
|
58955
|
+
total: (_h = (_g = response.usage) == null ? undefined : _g.completion_tokens) != null ? _h : undefined,
|
|
58956
|
+
text: undefined,
|
|
58957
|
+
reasoning: (_k = (_j = (_i = response.usage) == null ? undefined : _i.completion_tokens_details) == null ? undefined : _j.reasoning_tokens) != null ? _k : undefined
|
|
58958
|
+
}
|
|
58527
58959
|
},
|
|
58528
58960
|
warnings: [],
|
|
58529
58961
|
response: {
|
|
@@ -58550,13 +58982,19 @@ var __defProp3, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
|
|
|
58550
58982
|
abortSignal: options.abortSignal,
|
|
58551
58983
|
fetch: this.config.fetch
|
|
58552
58984
|
});
|
|
58553
|
-
let finishReason = "other";
|
|
58985
|
+
let finishReason = { unified: "other", raw: undefined };
|
|
58554
58986
|
const usage = {
|
|
58555
|
-
inputTokens:
|
|
58556
|
-
|
|
58557
|
-
|
|
58558
|
-
|
|
58559
|
-
|
|
58987
|
+
inputTokens: {
|
|
58988
|
+
total: undefined,
|
|
58989
|
+
noCache: undefined,
|
|
58990
|
+
cacheRead: undefined,
|
|
58991
|
+
cacheWrite: undefined
|
|
58992
|
+
},
|
|
58993
|
+
outputTokens: {
|
|
58994
|
+
total: undefined,
|
|
58995
|
+
text: undefined,
|
|
58996
|
+
reasoning: undefined
|
|
58997
|
+
}
|
|
58560
58998
|
};
|
|
58561
58999
|
const llmgatewayUsage = {};
|
|
58562
59000
|
return {
|
|
@@ -58564,24 +59002,23 @@ var __defProp3, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
|
|
|
58564
59002
|
transform(chunk, controller) {
|
|
58565
59003
|
var _a162, _b16, _c;
|
|
58566
59004
|
if (!chunk.success) {
|
|
58567
|
-
finishReason = "error";
|
|
59005
|
+
finishReason = { unified: "error", raw: undefined };
|
|
58568
59006
|
controller.enqueue({ type: "error", error: chunk.error });
|
|
58569
59007
|
return;
|
|
58570
59008
|
}
|
|
58571
59009
|
const value = chunk.value;
|
|
58572
59010
|
if ("error" in value) {
|
|
58573
|
-
finishReason = "error";
|
|
59011
|
+
finishReason = { unified: "error", raw: undefined };
|
|
58574
59012
|
controller.enqueue({ type: "error", error: value.error });
|
|
58575
59013
|
return;
|
|
58576
59014
|
}
|
|
58577
59015
|
if (value.usage != null) {
|
|
58578
|
-
usage.inputTokens = value.usage.prompt_tokens;
|
|
58579
|
-
usage.outputTokens = value.usage.completion_tokens;
|
|
58580
|
-
usage.totalTokens = value.usage.prompt_tokens + value.usage.completion_tokens;
|
|
59016
|
+
usage.inputTokens.total = value.usage.prompt_tokens;
|
|
59017
|
+
usage.outputTokens.total = value.usage.completion_tokens;
|
|
58581
59018
|
llmgatewayUsage.promptTokens = value.usage.prompt_tokens;
|
|
58582
59019
|
if (value.usage.prompt_tokens_details) {
|
|
58583
59020
|
const cachedInputTokens = (_a162 = value.usage.prompt_tokens_details.cached_tokens) != null ? _a162 : 0;
|
|
58584
|
-
usage.
|
|
59021
|
+
usage.inputTokens.cacheRead = cachedInputTokens;
|
|
58585
59022
|
llmgatewayUsage.promptTokensDetails = {
|
|
58586
59023
|
cachedTokens: cachedInputTokens
|
|
58587
59024
|
};
|
|
@@ -58589,7 +59026,7 @@ var __defProp3, __defProps, __getOwnPropDescs, __getOwnPropSymbols, __hasOwnProp
|
|
|
58589
59026
|
llmgatewayUsage.completionTokens = value.usage.completion_tokens;
|
|
58590
59027
|
if (value.usage.completion_tokens_details) {
|
|
58591
59028
|
const reasoningTokens = (_b16 = value.usage.completion_tokens_details.reasoning_tokens) != null ? _b16 : 0;
|
|
58592
|
-
usage.
|
|
59029
|
+
usage.outputTokens.reasoning = reasoningTokens;
|
|
58593
59030
|
llmgatewayUsage.completionTokensDetails = {
|
|
58594
59031
|
reasoningTokens
|
|
58595
59032
|
};
|
|
@@ -69088,6 +69525,34 @@ function splitLines3(chunk) {
|
|
|
69088
69525
|
function combineHeaders5(...headers) {
|
|
69089
69526
|
return headers.reduce((combinedHeaders, currentHeaders) => __spreadValues2(__spreadValues2({}, combinedHeaders), currentHeaders != null ? currentHeaders : {}), {});
|
|
69090
69527
|
}
|
|
69528
|
+
async function delay2(delayInMs, options) {
|
|
69529
|
+
if (delayInMs == null) {
|
|
69530
|
+
return Promise.resolve();
|
|
69531
|
+
}
|
|
69532
|
+
const signal = options == null ? undefined : options.abortSignal;
|
|
69533
|
+
return new Promise((resolve22, reject) => {
|
|
69534
|
+
if (signal == null ? undefined : signal.aborted) {
|
|
69535
|
+
reject(createAbortError2());
|
|
69536
|
+
return;
|
|
69537
|
+
}
|
|
69538
|
+
const timeoutId = setTimeout(() => {
|
|
69539
|
+
cleanup();
|
|
69540
|
+
resolve22();
|
|
69541
|
+
}, delayInMs);
|
|
69542
|
+
const cleanup = () => {
|
|
69543
|
+
clearTimeout(timeoutId);
|
|
69544
|
+
signal == null || signal.removeEventListener("abort", onAbort);
|
|
69545
|
+
};
|
|
69546
|
+
const onAbort = () => {
|
|
69547
|
+
cleanup();
|
|
69548
|
+
reject(createAbortError2());
|
|
69549
|
+
};
|
|
69550
|
+
signal == null || signal.addEventListener("abort", onAbort);
|
|
69551
|
+
});
|
|
69552
|
+
}
|
|
69553
|
+
function createAbortError2() {
|
|
69554
|
+
return new DOMException("Delay was aborted", "AbortError");
|
|
69555
|
+
}
|
|
69091
69556
|
function extractResponseHeaders5(response) {
|
|
69092
69557
|
return Object.fromEntries([...response.headers]);
|
|
69093
69558
|
}
|
|
@@ -69101,6 +69566,16 @@ function convertUint8ArrayToBase645(array3) {
|
|
|
69101
69566
|
function isAbortError5(error48) {
|
|
69102
69567
|
return (error48 instanceof Error || error48 instanceof DOMException) && (error48.name === "AbortError" || error48.name === "ResponseAborted" || error48.name === "TimeoutError");
|
|
69103
69568
|
}
|
|
69569
|
+
function isBunNetworkError2(error48) {
|
|
69570
|
+
if (!(error48 instanceof Error)) {
|
|
69571
|
+
return false;
|
|
69572
|
+
}
|
|
69573
|
+
const code = error48.code;
|
|
69574
|
+
if (typeof code === "string" && BUN_ERROR_CODES2.includes(code)) {
|
|
69575
|
+
return true;
|
|
69576
|
+
}
|
|
69577
|
+
return false;
|
|
69578
|
+
}
|
|
69104
69579
|
function handleFetchError5({
|
|
69105
69580
|
error: error48,
|
|
69106
69581
|
url: url2,
|
|
@@ -69121,6 +69596,15 @@ function handleFetchError5({
|
|
|
69121
69596
|
});
|
|
69122
69597
|
}
|
|
69123
69598
|
}
|
|
69599
|
+
if (isBunNetworkError2(error48)) {
|
|
69600
|
+
return new APICallError5({
|
|
69601
|
+
message: `Cannot connect to API: ${error48.message}`,
|
|
69602
|
+
cause: error48,
|
|
69603
|
+
url: url2,
|
|
69604
|
+
requestBodyValues,
|
|
69605
|
+
isRetryable: true
|
|
69606
|
+
});
|
|
69607
|
+
}
|
|
69124
69608
|
return error48;
|
|
69125
69609
|
}
|
|
69126
69610
|
function getRuntimeEnvironmentUserAgent5(globalThisAny = globalThis) {
|
|
@@ -69182,7 +69666,7 @@ function loadApiKey4({
|
|
|
69182
69666
|
}
|
|
69183
69667
|
if (typeof process === "undefined") {
|
|
69184
69668
|
throw new LoadAPIKeyError5({
|
|
69185
|
-
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter. Environment variables
|
|
69669
|
+
message: `${description} API key is missing. Pass it using the '${apiKeyParameterName}' parameter. Environment variables are not supported in this environment.`
|
|
69186
69670
|
});
|
|
69187
69671
|
}
|
|
69188
69672
|
apiKey = process.env[environmentVariableName];
|
|
@@ -69217,7 +69701,7 @@ function filter5(obj) {
|
|
|
69217
69701
|
if (Object.prototype.hasOwnProperty.call(node, "__proto__")) {
|
|
69218
69702
|
throw new SyntaxError("Object contains forbidden prototype property");
|
|
69219
69703
|
}
|
|
69220
|
-
if (Object.prototype.hasOwnProperty.call(node, "constructor") && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
69704
|
+
if (Object.prototype.hasOwnProperty.call(node, "constructor") && node.constructor !== null && typeof node.constructor === "object" && Object.prototype.hasOwnProperty.call(node.constructor, "prototype")) {
|
|
69221
69705
|
throw new SyntaxError("Object contains forbidden prototype property");
|
|
69222
69706
|
}
|
|
69223
69707
|
for (const key in node) {
|
|
@@ -69244,24 +69728,40 @@ function secureJsonParse5(text2) {
|
|
|
69244
69728
|
}
|
|
69245
69729
|
}
|
|
69246
69730
|
function addAdditionalPropertiesToJsonSchema5(jsonSchema22) {
|
|
69247
|
-
if (jsonSchema22.type === "object") {
|
|
69731
|
+
if (jsonSchema22.type === "object" || Array.isArray(jsonSchema22.type) && jsonSchema22.type.includes("object")) {
|
|
69248
69732
|
jsonSchema22.additionalProperties = false;
|
|
69249
|
-
const properties = jsonSchema22
|
|
69733
|
+
const { properties } = jsonSchema22;
|
|
69250
69734
|
if (properties != null) {
|
|
69251
|
-
for (const
|
|
69252
|
-
properties[
|
|
69735
|
+
for (const key of Object.keys(properties)) {
|
|
69736
|
+
properties[key] = visit5(properties[key]);
|
|
69253
69737
|
}
|
|
69254
69738
|
}
|
|
69255
69739
|
}
|
|
69256
|
-
if (jsonSchema22.
|
|
69257
|
-
|
|
69258
|
-
|
|
69259
|
-
|
|
69260
|
-
|
|
69740
|
+
if (jsonSchema22.items != null) {
|
|
69741
|
+
jsonSchema22.items = Array.isArray(jsonSchema22.items) ? jsonSchema22.items.map(visit5) : visit5(jsonSchema22.items);
|
|
69742
|
+
}
|
|
69743
|
+
if (jsonSchema22.anyOf != null) {
|
|
69744
|
+
jsonSchema22.anyOf = jsonSchema22.anyOf.map(visit5);
|
|
69745
|
+
}
|
|
69746
|
+
if (jsonSchema22.allOf != null) {
|
|
69747
|
+
jsonSchema22.allOf = jsonSchema22.allOf.map(visit5);
|
|
69748
|
+
}
|
|
69749
|
+
if (jsonSchema22.oneOf != null) {
|
|
69750
|
+
jsonSchema22.oneOf = jsonSchema22.oneOf.map(visit5);
|
|
69751
|
+
}
|
|
69752
|
+
const { definitions } = jsonSchema22;
|
|
69753
|
+
if (definitions != null) {
|
|
69754
|
+
for (const key of Object.keys(definitions)) {
|
|
69755
|
+
definitions[key] = visit5(definitions[key]);
|
|
69261
69756
|
}
|
|
69262
69757
|
}
|
|
69263
69758
|
return jsonSchema22;
|
|
69264
69759
|
}
|
|
69760
|
+
function visit5(def) {
|
|
69761
|
+
if (typeof def === "boolean")
|
|
69762
|
+
return def;
|
|
69763
|
+
return addAdditionalPropertiesToJsonSchema5(def);
|
|
69764
|
+
}
|
|
69265
69765
|
function parseAnyDef5() {
|
|
69266
69766
|
return {};
|
|
69267
69767
|
}
|
|
@@ -69973,9 +70473,9 @@ function asSchema5(schema) {
|
|
|
69973
70473
|
return schema == null ? jsonSchema5({ properties: {}, additionalProperties: false }) : isSchema5(schema) ? schema : ("~standard" in schema) ? schema["~standard"].vendor === "zod" ? zodSchema5(schema) : standardSchema5(schema) : schema();
|
|
69974
70474
|
}
|
|
69975
70475
|
function standardSchema5(standardSchema22) {
|
|
69976
|
-
return jsonSchema5(() => standardSchema22["~standard"].jsonSchema.input({
|
|
70476
|
+
return jsonSchema5(() => addAdditionalPropertiesToJsonSchema5(standardSchema22["~standard"].jsonSchema.input({
|
|
69977
70477
|
target: "draft-07"
|
|
69978
|
-
}), {
|
|
70478
|
+
})), {
|
|
69979
70479
|
validate: async (value) => {
|
|
69980
70480
|
const result = await standardSchema22["~standard"].validate(value);
|
|
69981
70481
|
return "value" in result ? { success: true, value: result.value } : {
|
|
@@ -70026,17 +70526,19 @@ function zodSchema5(zodSchema22, options) {
|
|
|
70026
70526
|
}
|
|
70027
70527
|
async function validateTypes5({
|
|
70028
70528
|
value,
|
|
70029
|
-
schema
|
|
70529
|
+
schema,
|
|
70530
|
+
context: context2
|
|
70030
70531
|
}) {
|
|
70031
|
-
const result = await safeValidateTypes5({ value, schema });
|
|
70532
|
+
const result = await safeValidateTypes5({ value, schema, context: context2 });
|
|
70032
70533
|
if (!result.success) {
|
|
70033
|
-
throw TypeValidationError5.wrap({ value, cause: result.error });
|
|
70534
|
+
throw TypeValidationError5.wrap({ value, cause: result.error, context: context2 });
|
|
70034
70535
|
}
|
|
70035
70536
|
return result.value;
|
|
70036
70537
|
}
|
|
70037
70538
|
async function safeValidateTypes5({
|
|
70038
70539
|
value,
|
|
70039
|
-
schema
|
|
70540
|
+
schema,
|
|
70541
|
+
context: context2
|
|
70040
70542
|
}) {
|
|
70041
70543
|
const actualSchema = asSchema5(schema);
|
|
70042
70544
|
try {
|
|
@@ -70049,13 +70551,13 @@ async function safeValidateTypes5({
|
|
|
70049
70551
|
}
|
|
70050
70552
|
return {
|
|
70051
70553
|
success: false,
|
|
70052
|
-
error: TypeValidationError5.wrap({ value, cause: result.error }),
|
|
70554
|
+
error: TypeValidationError5.wrap({ value, cause: result.error, context: context2 }),
|
|
70053
70555
|
rawValue: value
|
|
70054
70556
|
};
|
|
70055
70557
|
} catch (error48) {
|
|
70056
70558
|
return {
|
|
70057
70559
|
success: false,
|
|
70058
|
-
error: TypeValidationError5.wrap({ value, cause: error48 }),
|
|
70560
|
+
error: TypeValidationError5.wrap({ value, cause: error48, context: context2 }),
|
|
70059
70561
|
rawValue: value
|
|
70060
70562
|
};
|
|
70061
70563
|
}
|
|
@@ -70116,6 +70618,46 @@ function parseJsonEventStream5({
|
|
|
70116
70618
|
}
|
|
70117
70619
|
}));
|
|
70118
70620
|
}
|
|
70621
|
+
function tool3(tool22) {
|
|
70622
|
+
return tool22;
|
|
70623
|
+
}
|
|
70624
|
+
function createProviderToolFactory3({
|
|
70625
|
+
id,
|
|
70626
|
+
inputSchema
|
|
70627
|
+
}) {
|
|
70628
|
+
return (_a162) => {
|
|
70629
|
+
var _b16 = _a162, {
|
|
70630
|
+
execute,
|
|
70631
|
+
outputSchema: outputSchema2,
|
|
70632
|
+
needsApproval,
|
|
70633
|
+
toModelOutput,
|
|
70634
|
+
onInputStart,
|
|
70635
|
+
onInputDelta,
|
|
70636
|
+
onInputAvailable
|
|
70637
|
+
} = _b16, args = __objRest2(_b16, [
|
|
70638
|
+
"execute",
|
|
70639
|
+
"outputSchema",
|
|
70640
|
+
"needsApproval",
|
|
70641
|
+
"toModelOutput",
|
|
70642
|
+
"onInputStart",
|
|
70643
|
+
"onInputDelta",
|
|
70644
|
+
"onInputAvailable"
|
|
70645
|
+
]);
|
|
70646
|
+
return tool3({
|
|
70647
|
+
type: "provider",
|
|
70648
|
+
id,
|
|
70649
|
+
args,
|
|
70650
|
+
inputSchema,
|
|
70651
|
+
outputSchema: outputSchema2,
|
|
70652
|
+
execute,
|
|
70653
|
+
needsApproval,
|
|
70654
|
+
toModelOutput,
|
|
70655
|
+
onInputStart,
|
|
70656
|
+
onInputDelta,
|
|
70657
|
+
onInputAvailable
|
|
70658
|
+
});
|
|
70659
|
+
};
|
|
70660
|
+
}
|
|
70119
70661
|
function withoutTrailingSlash4(url2) {
|
|
70120
70662
|
return url2 == null ? undefined : url2.replace(/\/$/, "");
|
|
70121
70663
|
}
|
|
@@ -70255,6 +70797,27 @@ function withStreamErrorHandling(source, onError) {
|
|
|
70255
70797
|
}
|
|
70256
70798
|
});
|
|
70257
70799
|
}
|
|
70800
|
+
function deterministicStringify(value) {
|
|
70801
|
+
return JSON.stringify(sortKeys(value));
|
|
70802
|
+
}
|
|
70803
|
+
function sortKeys(value) {
|
|
70804
|
+
if (value === null || value === undefined) {
|
|
70805
|
+
return value;
|
|
70806
|
+
}
|
|
70807
|
+
if (Array.isArray(value)) {
|
|
70808
|
+
return value.map(sortKeys);
|
|
70809
|
+
}
|
|
70810
|
+
if (typeof value === "object") {
|
|
70811
|
+
const sorted = {};
|
|
70812
|
+
const entries = Object.entries(value);
|
|
70813
|
+
entries.sort(([a], [b]) => a.localeCompare(b));
|
|
70814
|
+
for (const [key, val] of entries) {
|
|
70815
|
+
sorted[key] = sortKeys(val);
|
|
70816
|
+
}
|
|
70817
|
+
return sorted;
|
|
70818
|
+
}
|
|
70819
|
+
return value;
|
|
70820
|
+
}
|
|
70258
70821
|
function isUrl2({
|
|
70259
70822
|
url: url2,
|
|
70260
70823
|
protocols
|
|
@@ -70484,7 +71047,7 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
70484
71047
|
type: "function",
|
|
70485
71048
|
function: {
|
|
70486
71049
|
name: part.toolName,
|
|
70487
|
-
arguments:
|
|
71050
|
+
arguments: deterministicStringify(part.input)
|
|
70488
71051
|
}
|
|
70489
71052
|
});
|
|
70490
71053
|
break;
|
|
@@ -70512,7 +71075,7 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
70512
71075
|
return true;
|
|
70513
71076
|
}
|
|
70514
71077
|
const format = (_a173 = detail.format) != null ? _a173 : DEFAULT_REASONING_FORMAT;
|
|
70515
|
-
if (format !== "anthropic-claude-v1") {
|
|
71078
|
+
if (format !== "anthropic-claude-v1" && format !== "google-gemini-v1") {
|
|
70516
71079
|
return true;
|
|
70517
71080
|
}
|
|
70518
71081
|
return !!detail.signature;
|
|
@@ -70520,7 +71083,7 @@ function convertToOpenRouterChatMessages(prompt) {
|
|
|
70520
71083
|
if (validDetails.length < candidateReasoningDetails.length) {
|
|
70521
71084
|
const logger = globalThis.AI_SDK_LOG_WARNINGS;
|
|
70522
71085
|
if (logger !== false && typeof logger !== "function") {
|
|
70523
|
-
console.warn("[openrouter] Some reasoning_details entries were removed because they were missing signatures. See https://github.com/OpenRouterTeam/ai-sdk-provider/issues/423 for more details.");
|
|
71086
|
+
console.warn("[openrouter] Some reasoning_details entries were removed because they were missing signatures. See https://github.com/OpenRouterTeam/ai-sdk-provider/issues/423 and https://github.com/OpenRouterTeam/ai-sdk-provider/issues/418 for more details.");
|
|
70524
71087
|
}
|
|
70525
71088
|
}
|
|
70526
71089
|
const uniqueDetails = [];
|
|
@@ -70727,6 +71290,22 @@ function getChatCompletionToolChoice2(toolChoice) {
|
|
|
70727
71290
|
}
|
|
70728
71291
|
}
|
|
70729
71292
|
}
|
|
71293
|
+
function mapProviderTool(tool22) {
|
|
71294
|
+
const [provider, toolName] = tool22.id.split(".");
|
|
71295
|
+
const apiToolType = `${provider}:${toolName}`;
|
|
71296
|
+
const mappedArgs = {};
|
|
71297
|
+
for (const [key, value] of Object.entries(tool22.args)) {
|
|
71298
|
+
if (value !== undefined) {
|
|
71299
|
+
mappedArgs[camelToSnake(key)] = value;
|
|
71300
|
+
}
|
|
71301
|
+
}
|
|
71302
|
+
return __spreadValues2({
|
|
71303
|
+
type: apiToolType
|
|
71304
|
+
}, mappedArgs);
|
|
71305
|
+
}
|
|
71306
|
+
function camelToSnake(str) {
|
|
71307
|
+
return str.replace(/[A-Z]/g, (letter) => `_${letter.toLowerCase()}`);
|
|
71308
|
+
}
|
|
70730
71309
|
function convertToOpenRouterCompletionPrompt({
|
|
70731
71310
|
prompt,
|
|
70732
71311
|
inputFormat,
|
|
@@ -70873,6 +71452,25 @@ function withUserAgentSuffix22(headers, ...userAgentSuffixParts) {
|
|
|
70873
71452
|
"user-agent": userAgent
|
|
70874
71453
|
});
|
|
70875
71454
|
}
|
|
71455
|
+
function convertImageToFrameImage(file2) {
|
|
71456
|
+
if (file2.type === "url") {
|
|
71457
|
+
return {
|
|
71458
|
+
type: "image_url",
|
|
71459
|
+
image_url: { url: file2.url },
|
|
71460
|
+
frame_type: "first_frame"
|
|
71461
|
+
};
|
|
71462
|
+
}
|
|
71463
|
+
const url2 = buildFileDataUrl({
|
|
71464
|
+
data: file2.data,
|
|
71465
|
+
mediaType: file2.mediaType,
|
|
71466
|
+
defaultMediaType: "image/png"
|
|
71467
|
+
});
|
|
71468
|
+
return {
|
|
71469
|
+
type: "image_url",
|
|
71470
|
+
image_url: { url: url2 },
|
|
71471
|
+
frame_type: "first_frame"
|
|
71472
|
+
};
|
|
71473
|
+
}
|
|
70876
71474
|
function createOpenRouter(options = {}) {
|
|
70877
71475
|
var _a162, _b16, _c;
|
|
70878
71476
|
const baseURL = (_b16 = withoutTrailingSlash4((_a162 = options.baseURL) != null ? _a162 : options.baseUrl)) != null ? _b16 : "https://openrouter.ai/api/v1";
|
|
@@ -70916,6 +71514,13 @@ function createOpenRouter(options = {}) {
|
|
|
70916
71514
|
fetch: options.fetch,
|
|
70917
71515
|
extraBody: options.extraBody
|
|
70918
71516
|
});
|
|
71517
|
+
const createVideoModel = (modelId, settings = {}) => new OpenRouterVideoModel(modelId, settings, {
|
|
71518
|
+
provider: "openrouter.video",
|
|
71519
|
+
url: ({ path }) => `${baseURL}${path}`,
|
|
71520
|
+
headers: getHeaders,
|
|
71521
|
+
fetch: options.fetch,
|
|
71522
|
+
extraBody: options.extraBody
|
|
71523
|
+
});
|
|
70919
71524
|
const createLanguageModel = (modelId, settings) => {
|
|
70920
71525
|
if (new.target) {
|
|
70921
71526
|
throw new Error("The OpenRouter model function cannot be called with the new keyword.");
|
|
@@ -70932,6 +71537,10 @@ function createOpenRouter(options = {}) {
|
|
|
70932
71537
|
provider.textEmbeddingModel = createEmbeddingModel;
|
|
70933
71538
|
provider.embedding = createEmbeddingModel;
|
|
70934
71539
|
provider.imageModel = createImageModel;
|
|
71540
|
+
provider.videoModel = createVideoModel;
|
|
71541
|
+
provider.tools = {
|
|
71542
|
+
webSearch: webSearch2
|
|
71543
|
+
};
|
|
70935
71544
|
return provider;
|
|
70936
71545
|
}
|
|
70937
71546
|
var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnProp3, __propIsEnum2, __typeError = (msg) => {
|
|
@@ -70957,7 +71566,7 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
70957
71566
|
target[prop] = source[prop];
|
|
70958
71567
|
}
|
|
70959
71568
|
return target;
|
|
70960
|
-
}, __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg), __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value), marker37 = "vercel.ai.error", symbol37, _a37, _b28, AISDKError5, name37 = "AI_APICallError", marker211, symbol211, _a211, _b27, APICallError5, name211 = "AI_EmptyResponseBodyError", marker38, symbol38, _a38, _b36, EmptyResponseBodyError5, name38 = "AI_InvalidArgumentError", marker47, symbol47, _a47, _b46, InvalidArgumentError6, name47 = "AI_InvalidPromptError", marker57, symbol57, _a57, _b56, InvalidPromptError5, name57 = "AI_InvalidResponseDataError", marker67, symbol67, _a67, _b66, InvalidResponseDataError5, name67 = "AI_JSONParseError", marker77, symbol77, _a77, _b76, JSONParseError5, name77 = "AI_LoadAPIKeyError", marker87, symbol87, _a87, _b86, LoadAPIKeyError5, name86 = "AI_LoadSettingError", marker96, symbol96, _a96, _b95, LoadSettingError5, name96 = "AI_NoContentGeneratedError", marker106, symbol106, _a106, _b105, NoContentGeneratedError5, name106 = "AI_NoSuchModelError", marker116, symbol116, _a116, _b115, NoSuchModelError5, name116 = "AI_TooManyEmbeddingValuesForCallError", marker126, symbol126, _a126, _b125, TooManyEmbeddingValuesForCallError5, name126 = "AI_TypeValidationError", marker136, symbol136, _a136, _b135, TypeValidationError5, name136 = "AI_UnsupportedFunctionalityError", marker146, symbol146, _a146, _b145, UnsupportedFunctionalityError5, ParseError3, EventSourceParserStream3, btoa6, atob6, name144 = "AI_DownloadError", marker154, symbol154, _a154, _b153, DownloadError5, createIdGenerator5 = ({
|
|
71569
|
+
}, __accessCheck = (obj, member, msg) => member.has(obj) || __typeError("Cannot " + msg), __privateGet = (obj, member, getter) => (__accessCheck(obj, member, "read from private field"), getter ? getter.call(obj) : member.get(obj)), __privateAdd = (obj, member, value) => member.has(obj) ? __typeError("Cannot add the same private member more than once") : member instanceof WeakSet ? member.add(obj) : member.set(obj, value), marker37 = "vercel.ai.error", symbol37, _a37, _b28, AISDKError5, name37 = "AI_APICallError", marker211, symbol211, _a211, _b27, APICallError5, name211 = "AI_EmptyResponseBodyError", marker38, symbol38, _a38, _b36, EmptyResponseBodyError5, name38 = "AI_InvalidArgumentError", marker47, symbol47, _a47, _b46, InvalidArgumentError6, name47 = "AI_InvalidPromptError", marker57, symbol57, _a57, _b56, InvalidPromptError5, name57 = "AI_InvalidResponseDataError", marker67, symbol67, _a67, _b66, InvalidResponseDataError5, name67 = "AI_JSONParseError", marker77, symbol77, _a77, _b76, JSONParseError5, name77 = "AI_LoadAPIKeyError", marker87, symbol87, _a87, _b86, LoadAPIKeyError5, name86 = "AI_LoadSettingError", marker96, symbol96, _a96, _b95, LoadSettingError5, name96 = "AI_NoContentGeneratedError", marker106, symbol106, _a106, _b105, NoContentGeneratedError5, name106 = "AI_NoSuchModelError", marker116, symbol116, _a116, _b115, NoSuchModelError5, name116 = "AI_TooManyEmbeddingValuesForCallError", marker126, symbol126, _a126, _b125, TooManyEmbeddingValuesForCallError5, name126 = "AI_TypeValidationError", marker136, symbol136, _a136, _b135, TypeValidationError5, name136 = "AI_UnsupportedFunctionalityError", marker146, symbol146, _a146, _b145, UnsupportedFunctionalityError5, ParseError3, EventSourceParserStream3, btoa6, atob6, name144 = "AI_DownloadError", marker154, symbol154, _a154, _b153, DownloadError5, DEFAULT_MAX_DOWNLOAD_SIZE2, createIdGenerator5 = ({
|
|
70961
71570
|
prefix,
|
|
70962
71571
|
size = 16,
|
|
70963
71572
|
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz",
|
|
@@ -70981,7 +71590,69 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
70981
71590
|
});
|
|
70982
71591
|
}
|
|
70983
71592
|
return () => `${prefix}${separator}${generator()}`;
|
|
70984
|
-
}, generateId5, FETCH_FAILED_ERROR_MESSAGES5, VERSION16 = "4.0.
|
|
71593
|
+
}, generateId5, FETCH_FAILED_ERROR_MESSAGES5, BUN_ERROR_CODES2, VERSION16 = "4.0.23", getOriginalFetch3 = () => globalThis.fetch, getFromApi2 = async ({
|
|
71594
|
+
url: url2,
|
|
71595
|
+
headers = {},
|
|
71596
|
+
successfulResponseHandler,
|
|
71597
|
+
failedResponseHandler,
|
|
71598
|
+
abortSignal,
|
|
71599
|
+
fetch: fetch2 = getOriginalFetch3()
|
|
71600
|
+
}) => {
|
|
71601
|
+
try {
|
|
71602
|
+
const response = await fetch2(url2, {
|
|
71603
|
+
method: "GET",
|
|
71604
|
+
headers: withUserAgentSuffix5(headers, `ai-sdk/provider-utils/${VERSION16}`, getRuntimeEnvironmentUserAgent5()),
|
|
71605
|
+
signal: abortSignal
|
|
71606
|
+
});
|
|
71607
|
+
const responseHeaders = extractResponseHeaders5(response);
|
|
71608
|
+
if (!response.ok) {
|
|
71609
|
+
let errorInformation;
|
|
71610
|
+
try {
|
|
71611
|
+
errorInformation = await failedResponseHandler({
|
|
71612
|
+
response,
|
|
71613
|
+
url: url2,
|
|
71614
|
+
requestBodyValues: {}
|
|
71615
|
+
});
|
|
71616
|
+
} catch (error48) {
|
|
71617
|
+
if (isAbortError5(error48) || APICallError5.isInstance(error48)) {
|
|
71618
|
+
throw error48;
|
|
71619
|
+
}
|
|
71620
|
+
throw new APICallError5({
|
|
71621
|
+
message: "Failed to process error response",
|
|
71622
|
+
cause: error48,
|
|
71623
|
+
statusCode: response.status,
|
|
71624
|
+
url: url2,
|
|
71625
|
+
responseHeaders,
|
|
71626
|
+
requestBodyValues: {}
|
|
71627
|
+
});
|
|
71628
|
+
}
|
|
71629
|
+
throw errorInformation.value;
|
|
71630
|
+
}
|
|
71631
|
+
try {
|
|
71632
|
+
return await successfulResponseHandler({
|
|
71633
|
+
response,
|
|
71634
|
+
url: url2,
|
|
71635
|
+
requestBodyValues: {}
|
|
71636
|
+
});
|
|
71637
|
+
} catch (error48) {
|
|
71638
|
+
if (error48 instanceof Error) {
|
|
71639
|
+
if (isAbortError5(error48) || APICallError5.isInstance(error48)) {
|
|
71640
|
+
throw error48;
|
|
71641
|
+
}
|
|
71642
|
+
}
|
|
71643
|
+
throw new APICallError5({
|
|
71644
|
+
message: "Failed to process successful response",
|
|
71645
|
+
cause: error48,
|
|
71646
|
+
statusCode: response.status,
|
|
71647
|
+
url: url2,
|
|
71648
|
+
responseHeaders,
|
|
71649
|
+
requestBodyValues: {}
|
|
71650
|
+
});
|
|
71651
|
+
}
|
|
71652
|
+
} catch (error48) {
|
|
71653
|
+
throw handleFetchError5({ error: error48, url: url2, requestBodyValues: {} });
|
|
71654
|
+
}
|
|
71655
|
+
}, suspectProtoRx5, suspectConstructorRx5, ignoreOverride5, defaultOptions5, getDefaultOptions5 = (options) => typeof options === "string" ? __spreadProps2(__spreadValues2({}, defaultOptions5), {
|
|
70985
71656
|
name: options
|
|
70986
71657
|
}) : __spreadValues2(__spreadValues2({}, defaultOptions5), options), parseCatchDef5 = (def, refs) => {
|
|
70987
71658
|
return parseDef5(def.innerType._def, refs);
|
|
@@ -71428,7 +72099,7 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
71428
72099
|
tools,
|
|
71429
72100
|
toolChoice
|
|
71430
72101
|
}) {
|
|
71431
|
-
var _a162;
|
|
72102
|
+
var _a162, _b16;
|
|
71432
72103
|
const baseArgs = __spreadValues2(__spreadValues2({
|
|
71433
72104
|
model: this.modelId,
|
|
71434
72105
|
models: this.settings.models,
|
|
@@ -71437,11 +72108,11 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
71437
72108
|
top_logprobs: typeof this.settings.logprobs === "number" ? this.settings.logprobs : typeof this.settings.logprobs === "boolean" ? this.settings.logprobs ? 0 : undefined : undefined,
|
|
71438
72109
|
user: this.settings.user,
|
|
71439
72110
|
parallel_tool_calls: this.settings.parallelToolCalls,
|
|
71440
|
-
max_tokens: maxOutputTokens,
|
|
71441
|
-
temperature,
|
|
71442
|
-
top_p: topP,
|
|
71443
|
-
frequency_penalty: frequencyPenalty,
|
|
71444
|
-
presence_penalty: presencePenalty,
|
|
72111
|
+
max_tokens: maxOutputTokens != null ? maxOutputTokens : this.settings.maxTokens,
|
|
72112
|
+
temperature: temperature != null ? temperature : this.settings.temperature,
|
|
72113
|
+
top_p: topP != null ? topP : this.settings.topP,
|
|
72114
|
+
frequency_penalty: frequencyPenalty != null ? frequencyPenalty : this.settings.frequencyPenalty,
|
|
72115
|
+
presence_penalty: presencePenalty != null ? presencePenalty : this.settings.presencePenalty,
|
|
71445
72116
|
seed,
|
|
71446
72117
|
stop: stopSequences,
|
|
71447
72118
|
response_format: (responseFormat == null ? undefined : responseFormat.type) === "json" ? responseFormat.schema != null ? {
|
|
@@ -71454,7 +72125,7 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
71454
72125
|
description: responseFormat.description
|
|
71455
72126
|
})
|
|
71456
72127
|
} : { type: "json_object" } : undefined,
|
|
71457
|
-
top_k: topK,
|
|
72128
|
+
top_k: topK != null ? topK : this.settings.topK,
|
|
71458
72129
|
messages: convertToOpenRouterChatMessages(prompt),
|
|
71459
72130
|
include_reasoning: this.settings.includeReasoning,
|
|
71460
72131
|
reasoning: this.settings.reasoning,
|
|
@@ -71466,14 +72137,25 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
71466
72137
|
cache_control: this.settings.cache_control
|
|
71467
72138
|
}, this.config.extraBody), this.settings.extraBody);
|
|
71468
72139
|
if (tools && tools.length > 0) {
|
|
71469
|
-
const mappedTools =
|
|
71470
|
-
|
|
71471
|
-
function
|
|
71472
|
-
|
|
71473
|
-
|
|
71474
|
-
|
|
72140
|
+
const mappedTools = [];
|
|
72141
|
+
for (const tool22 of tools) {
|
|
72142
|
+
if (tool22.type === "function") {
|
|
72143
|
+
const openrouterOptions = (_b16 = tool22.providerOptions) == null ? undefined : _b16.openrouter;
|
|
72144
|
+
const eagerInputStreaming = openrouterOptions == null ? undefined : openrouterOptions.eager_input_streaming;
|
|
72145
|
+
mappedTools.push(__spreadValues2({
|
|
72146
|
+
type: "function",
|
|
72147
|
+
function: {
|
|
72148
|
+
name: tool22.name,
|
|
72149
|
+
description: tool22.description,
|
|
72150
|
+
parameters: tool22.inputSchema
|
|
72151
|
+
}
|
|
72152
|
+
}, eagerInputStreaming != null && {
|
|
72153
|
+
eager_input_streaming: eagerInputStreaming
|
|
72154
|
+
}));
|
|
72155
|
+
} else if (tool22.type === "provider") {
|
|
72156
|
+
mappedTools.push(mapProviderTool(tool22));
|
|
71475
72157
|
}
|
|
71476
|
-
}
|
|
72158
|
+
}
|
|
71477
72159
|
return __spreadProps2(__spreadValues2({}, baseArgs), {
|
|
71478
72160
|
tools: mappedTools,
|
|
71479
72161
|
tool_choice: toolChoice ? getChatCompletionToolChoice2(toolChoice) : undefined
|
|
@@ -71482,7 +72164,7 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
71482
72164
|
return baseArgs;
|
|
71483
72165
|
}
|
|
71484
72166
|
async doGenerate(options) {
|
|
71485
|
-
var _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v
|
|
72167
|
+
var _b16, _c, _d, _e, _f, _g, _h, _i, _j, _k, _l, _m, _n, _o, _p, _q, _r, _s, _t, _u, _v;
|
|
71486
72168
|
const providerOptions = options.providerOptions || {};
|
|
71487
72169
|
const openrouterOptions = providerOptions.openrouter || {};
|
|
71488
72170
|
const _a162 = openrouterOptions, { cacheControl } = _a162, restOpenrouterOptions = __objRest2(_a162, ["cacheControl"]);
|
|
@@ -71574,12 +72256,18 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
71574
72256
|
}
|
|
71575
72257
|
if (choice2.message.tool_calls) {
|
|
71576
72258
|
let reasoningDetailsAttachedToToolCall = false;
|
|
72259
|
+
const seenToolCallIds = /* @__PURE__ */ new Set;
|
|
71577
72260
|
for (const toolCall of choice2.message.tool_calls) {
|
|
72261
|
+
let toolCallId = toolCall.id;
|
|
72262
|
+
if (!toolCallId || seenToolCallIds.has(toolCallId)) {
|
|
72263
|
+
toolCallId = generateId5();
|
|
72264
|
+
}
|
|
72265
|
+
seenToolCallIds.add(toolCallId);
|
|
71578
72266
|
content.push({
|
|
71579
72267
|
type: "tool-call",
|
|
71580
|
-
toolCallId
|
|
72268
|
+
toolCallId,
|
|
71581
72269
|
toolName: toolCall.function.name,
|
|
71582
|
-
input: (
|
|
72270
|
+
input: (_c = toolCall.function.arguments) != null ? _c : "{}",
|
|
71583
72271
|
providerMetadata: !reasoningDetailsAttachedToToolCall ? {
|
|
71584
72272
|
openrouter: {
|
|
71585
72273
|
reasoning_details: reasoningDetails
|
|
@@ -71606,23 +72294,23 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
71606
72294
|
sourceType: "url",
|
|
71607
72295
|
id: annotation.url_citation.url,
|
|
71608
72296
|
url: annotation.url_citation.url,
|
|
71609
|
-
title: (
|
|
72297
|
+
title: (_d = annotation.url_citation.title) != null ? _d : "",
|
|
71610
72298
|
providerMetadata: {
|
|
71611
72299
|
openrouter: {
|
|
71612
|
-
content: (
|
|
71613
|
-
startIndex: (
|
|
71614
|
-
endIndex: (
|
|
72300
|
+
content: (_e = annotation.url_citation.content) != null ? _e : "",
|
|
72301
|
+
startIndex: (_f = annotation.url_citation.start_index) != null ? _f : 0,
|
|
72302
|
+
endIndex: (_g = annotation.url_citation.end_index) != null ? _g : 0
|
|
71615
72303
|
}
|
|
71616
72304
|
}
|
|
71617
72305
|
});
|
|
71618
72306
|
}
|
|
71619
72307
|
}
|
|
71620
72308
|
}
|
|
71621
|
-
const fileAnnotations = (
|
|
72309
|
+
const fileAnnotations = (_h = choice2.message.annotations) == null ? undefined : _h.filter((a) => a.type === "file");
|
|
71622
72310
|
const hasToolCalls = choice2.message.tool_calls && choice2.message.tool_calls.length > 0;
|
|
71623
72311
|
const hasEncryptedReasoning = reasoningDetails.some((d) => d.type === "reasoning.encrypted" && d.data);
|
|
71624
72312
|
const shouldOverrideFinishReason = hasToolCalls && hasEncryptedReasoning && choice2.finish_reason === "stop";
|
|
71625
|
-
const mappedFinishReason = shouldOverrideFinishReason ? createFinishReason("tool-calls", (
|
|
72313
|
+
const mappedFinishReason = shouldOverrideFinishReason ? createFinishReason("tool-calls", (_i = choice2.finish_reason) != null ? _i : undefined) : mapOpenRouterFinishReason(choice2.finish_reason);
|
|
71626
72314
|
const effectiveFinishReason = hasToolCalls && mappedFinishReason.unified === "other" ? createFinishReason("tool-calls", mappedFinishReason.raw) : mappedFinishReason;
|
|
71627
72315
|
return {
|
|
71628
72316
|
content,
|
|
@@ -71631,22 +72319,22 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
71631
72319
|
warnings: [],
|
|
71632
72320
|
providerMetadata: {
|
|
71633
72321
|
openrouter: OpenRouterProviderMetadataSchema.parse({
|
|
71634
|
-
provider: (
|
|
71635
|
-
reasoning_details: (
|
|
72322
|
+
provider: (_j = response.provider) != null ? _j : "",
|
|
72323
|
+
reasoning_details: (_k = choice2.message.reasoning_details) != null ? _k : [],
|
|
71636
72324
|
annotations: fileAnnotations && fileAnnotations.length > 0 ? fileAnnotations : undefined,
|
|
71637
72325
|
usage: __spreadValues2(__spreadValues2(__spreadValues2(__spreadValues2({
|
|
71638
|
-
promptTokens: (
|
|
71639
|
-
completionTokens: (
|
|
71640
|
-
totalTokens: ((
|
|
71641
|
-
}, ((
|
|
72326
|
+
promptTokens: (_l = usageInfo.inputTokens.total) != null ? _l : 0,
|
|
72327
|
+
completionTokens: (_m = usageInfo.outputTokens.total) != null ? _m : 0,
|
|
72328
|
+
totalTokens: ((_n = usageInfo.inputTokens.total) != null ? _n : 0) + ((_o = usageInfo.outputTokens.total) != null ? _o : 0)
|
|
72329
|
+
}, ((_p = response.usage) == null ? undefined : _p.cost) != null ? { cost: response.usage.cost } : {}), ((_r = (_q = response.usage) == null ? undefined : _q.prompt_tokens_details) == null ? undefined : _r.cached_tokens) != null ? {
|
|
71642
72330
|
promptTokensDetails: {
|
|
71643
72331
|
cachedTokens: response.usage.prompt_tokens_details.cached_tokens
|
|
71644
72332
|
}
|
|
71645
|
-
} : {}), ((
|
|
72333
|
+
} : {}), ((_t = (_s = response.usage) == null ? undefined : _s.completion_tokens_details) == null ? undefined : _t.reasoning_tokens) != null ? {
|
|
71646
72334
|
completionTokensDetails: {
|
|
71647
72335
|
reasoningTokens: response.usage.completion_tokens_details.reasoning_tokens
|
|
71648
72336
|
}
|
|
71649
|
-
} : {}), ((
|
|
72337
|
+
} : {}), ((_v = (_u = response.usage) == null ? undefined : _u.cost_details) == null ? undefined : _v.upstream_inference_cost) != null ? {
|
|
71650
72338
|
costDetails: {
|
|
71651
72339
|
upstreamInferenceCost: response.usage.cost_details.upstream_inference_cost
|
|
71652
72340
|
}
|
|
@@ -71690,6 +72378,7 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
71690
72378
|
streamError = err;
|
|
71691
72379
|
});
|
|
71692
72380
|
const toolCalls = [];
|
|
72381
|
+
const seenToolCallIds = /* @__PURE__ */ new Set;
|
|
71693
72382
|
let finishReason = createFinishReason("other");
|
|
71694
72383
|
const usage = {
|
|
71695
72384
|
inputTokens: {
|
|
@@ -71788,18 +72477,16 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
71788
72477
|
return;
|
|
71789
72478
|
}
|
|
71790
72479
|
const delta = choice2.delta;
|
|
71791
|
-
const emitReasoningChunk = (chunkText
|
|
72480
|
+
const emitReasoningChunk = (chunkText) => {
|
|
71792
72481
|
if (!reasoningStarted) {
|
|
71793
72482
|
reasoningId = generateId5();
|
|
71794
72483
|
controller.enqueue({
|
|
71795
|
-
providerMetadata,
|
|
71796
72484
|
type: "reasoning-start",
|
|
71797
72485
|
id: reasoningId
|
|
71798
72486
|
});
|
|
71799
72487
|
reasoningStarted = true;
|
|
71800
72488
|
}
|
|
71801
72489
|
controller.enqueue({
|
|
71802
|
-
providerMetadata,
|
|
71803
72490
|
type: "reasoning-delta",
|
|
71804
72491
|
delta: chunkText,
|
|
71805
72492
|
id: reasoningId || generateId5()
|
|
@@ -71821,15 +72508,10 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
71821
72508
|
}
|
|
71822
72509
|
}
|
|
71823
72510
|
if (!textStarted) {
|
|
71824
|
-
const reasoningMetadata = {
|
|
71825
|
-
openrouter: {
|
|
71826
|
-
reasoning_details: accumulatedReasoningDetails.map((d) => __spreadValues2({}, d))
|
|
71827
|
-
}
|
|
71828
|
-
};
|
|
71829
72511
|
for (const detail of delta.reasoning_details) {
|
|
71830
72512
|
switch (detail.type) {
|
|
71831
72513
|
case "reasoning.text": {
|
|
71832
|
-
emitReasoningChunk(detail.text || ""
|
|
72514
|
+
emitReasoningChunk(detail.text || "");
|
|
71833
72515
|
break;
|
|
71834
72516
|
}
|
|
71835
72517
|
case "reasoning.encrypted": {
|
|
@@ -71837,7 +72519,7 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
71837
72519
|
}
|
|
71838
72520
|
case "reasoning.summary": {
|
|
71839
72521
|
if (detail.summary) {
|
|
71840
|
-
emitReasoningChunk(detail.summary
|
|
72522
|
+
emitReasoningChunk(detail.summary);
|
|
71841
72523
|
}
|
|
71842
72524
|
break;
|
|
71843
72525
|
}
|
|
@@ -71912,24 +72594,23 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
71912
72594
|
message: `Expected 'function' type.`
|
|
71913
72595
|
});
|
|
71914
72596
|
}
|
|
71915
|
-
if (toolCallDelta.id == null) {
|
|
71916
|
-
throw new InvalidResponseDataError5({
|
|
71917
|
-
data: toolCallDelta,
|
|
71918
|
-
message: `Expected 'id' to be a string.`
|
|
71919
|
-
});
|
|
71920
|
-
}
|
|
71921
72597
|
if (((_k = toolCallDelta.function) == null ? undefined : _k.name) == null) {
|
|
71922
72598
|
throw new InvalidResponseDataError5({
|
|
71923
72599
|
data: toolCallDelta,
|
|
71924
72600
|
message: `Expected 'function.name' to be a string.`
|
|
71925
72601
|
});
|
|
71926
72602
|
}
|
|
72603
|
+
let toolCallId = (_l = toolCallDelta.id) != null ? _l : "";
|
|
72604
|
+
if (!toolCallId || seenToolCallIds.has(toolCallId)) {
|
|
72605
|
+
toolCallId = generateId5();
|
|
72606
|
+
}
|
|
72607
|
+
seenToolCallIds.add(toolCallId);
|
|
71927
72608
|
toolCalls[index] = {
|
|
71928
|
-
id:
|
|
72609
|
+
id: toolCallId,
|
|
71929
72610
|
type: "function",
|
|
71930
72611
|
function: {
|
|
71931
72612
|
name: toolCallDelta.function.name,
|
|
71932
|
-
arguments: (
|
|
72613
|
+
arguments: (_m = toolCallDelta.function.arguments) != null ? _m : ""
|
|
71933
72614
|
},
|
|
71934
72615
|
inputStarted: false,
|
|
71935
72616
|
sent: false
|
|
@@ -71941,7 +72622,7 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
71941
72622
|
message: `Tool call at index ${index} is missing after creation.`
|
|
71942
72623
|
});
|
|
71943
72624
|
}
|
|
71944
|
-
if (((
|
|
72625
|
+
if (((_n = toolCall2.function) == null ? undefined : _n.name) != null && ((_o = toolCall2.function) == null ? undefined : _o.arguments) != null && isParsableJson4(toolCall2.function.arguments)) {
|
|
71945
72626
|
toolCall2.inputStarted = true;
|
|
71946
72627
|
controller.enqueue({
|
|
71947
72628
|
type: "tool-input-start",
|
|
@@ -71999,22 +72680,22 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
71999
72680
|
});
|
|
72000
72681
|
}
|
|
72001
72682
|
}
|
|
72002
|
-
if (((
|
|
72003
|
-
toolCall.function.arguments += (
|
|
72683
|
+
if (((_p = toolCallDelta.function) == null ? undefined : _p.arguments) != null) {
|
|
72684
|
+
toolCall.function.arguments += (_r = (_q = toolCallDelta.function) == null ? undefined : _q.arguments) != null ? _r : "";
|
|
72004
72685
|
}
|
|
72005
72686
|
controller.enqueue({
|
|
72006
72687
|
type: "tool-input-delta",
|
|
72007
72688
|
id: toolCall.id,
|
|
72008
|
-
delta: (
|
|
72689
|
+
delta: (_s = toolCallDelta.function.arguments) != null ? _s : ""
|
|
72009
72690
|
});
|
|
72010
|
-
if (((
|
|
72691
|
+
if (((_t = toolCall.function) == null ? undefined : _t.name) != null && ((_u = toolCall.function) == null ? undefined : _u.arguments) != null && isParsableJson4(toolCall.function.arguments)) {
|
|
72011
72692
|
controller.enqueue({
|
|
72012
72693
|
type: "tool-input-end",
|
|
72013
72694
|
id: toolCall.id
|
|
72014
72695
|
});
|
|
72015
72696
|
controller.enqueue({
|
|
72016
72697
|
type: "tool-call",
|
|
72017
|
-
toolCallId:
|
|
72698
|
+
toolCallId: toolCall.id,
|
|
72018
72699
|
toolName: toolCall.function.name,
|
|
72019
72700
|
input: toolCall.function.arguments,
|
|
72020
72701
|
providerMetadata: !reasoningDetailsAttachedToToolCall ? {
|
|
@@ -72039,7 +72720,6 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
72039
72720
|
}
|
|
72040
72721
|
},
|
|
72041
72722
|
flush(controller) {
|
|
72042
|
-
var _a173;
|
|
72043
72723
|
const hasToolCalls = toolCalls.length > 0;
|
|
72044
72724
|
if (streamError != null) {
|
|
72045
72725
|
finishReason = createFinishReason("error");
|
|
@@ -72074,7 +72754,7 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
72074
72754
|
});
|
|
72075
72755
|
controller.enqueue({
|
|
72076
72756
|
type: "tool-call",
|
|
72077
|
-
toolCallId:
|
|
72757
|
+
toolCallId: toolCall.id,
|
|
72078
72758
|
toolName: toolCall.function.name,
|
|
72079
72759
|
input,
|
|
72080
72760
|
providerMetadata: !reasoningDetailsAttachedToToolCall ? {
|
|
@@ -72117,6 +72797,12 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
72117
72797
|
if (accumulatedFileAnnotations.length > 0) {
|
|
72118
72798
|
openrouterMetadata.annotations = accumulatedFileAnnotations;
|
|
72119
72799
|
}
|
|
72800
|
+
if (usage.inputTokens.total === undefined && openrouterUsage.promptTokens !== undefined) {
|
|
72801
|
+
usage.inputTokens.total = openrouterUsage.promptTokens;
|
|
72802
|
+
}
|
|
72803
|
+
if (usage.outputTokens.total === undefined && openrouterUsage.completionTokens !== undefined) {
|
|
72804
|
+
usage.outputTokens.total = openrouterUsage.completionTokens;
|
|
72805
|
+
}
|
|
72120
72806
|
usage.raw = rawUsage;
|
|
72121
72807
|
controller.enqueue({
|
|
72122
72808
|
type: "finish",
|
|
@@ -72186,15 +72872,15 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
72186
72872
|
logprobs: typeof this.settings.logprobs === "number" ? this.settings.logprobs : typeof this.settings.logprobs === "boolean" ? this.settings.logprobs ? 0 : undefined : undefined,
|
|
72187
72873
|
suffix: this.settings.suffix,
|
|
72188
72874
|
user: this.settings.user,
|
|
72189
|
-
max_tokens: maxOutputTokens,
|
|
72190
|
-
temperature,
|
|
72191
|
-
top_p: topP,
|
|
72192
|
-
frequency_penalty: frequencyPenalty,
|
|
72193
|
-
presence_penalty: presencePenalty,
|
|
72875
|
+
max_tokens: maxOutputTokens != null ? maxOutputTokens : this.settings.maxTokens,
|
|
72876
|
+
temperature: temperature != null ? temperature : this.settings.temperature,
|
|
72877
|
+
top_p: topP != null ? topP : this.settings.topP,
|
|
72878
|
+
frequency_penalty: frequencyPenalty != null ? frequencyPenalty : this.settings.frequencyPenalty,
|
|
72879
|
+
presence_penalty: presencePenalty != null ? presencePenalty : this.settings.presencePenalty,
|
|
72194
72880
|
seed,
|
|
72195
72881
|
stop: stopSequences,
|
|
72196
72882
|
response_format: responseFormat,
|
|
72197
|
-
top_k: topK,
|
|
72883
|
+
top_k: topK != null ? topK : this.settings.topK,
|
|
72198
72884
|
prompt: completionPrompt,
|
|
72199
72885
|
include_reasoning: this.settings.includeReasoning,
|
|
72200
72886
|
reasoning: this.settings.reasoning
|
|
@@ -72559,7 +73245,150 @@ var __defProp4, __defProps2, __getOwnPropDescs2, __getOwnPropSymbols2, __hasOwnP
|
|
|
72559
73245
|
usage
|
|
72560
73246
|
};
|
|
72561
73247
|
}
|
|
72562
|
-
}, DEFAULT_IMAGE_MEDIA_TYPE = "image/png", VERSION22 = "2.
|
|
73248
|
+
}, DEFAULT_IMAGE_MEDIA_TYPE = "image/png", webSearchInputSchema2, webSearch2, VERSION22 = "2.8.0", VideoGenerationSubmitResponseSchema, VideoGenerationPollResponseSchema, DEFAULT_POLL_INTERVAL_MS = 2000, DEFAULT_MAX_POLL_TIME_MS = 600000, OpenRouterVideoModel = class {
|
|
73249
|
+
constructor(modelId, settings, config2) {
|
|
73250
|
+
this.specificationVersion = "v3";
|
|
73251
|
+
this.provider = "openrouter";
|
|
73252
|
+
this.maxVideosPerCall = 1;
|
|
73253
|
+
this.modelId = modelId;
|
|
73254
|
+
this.settings = settings;
|
|
73255
|
+
this.config = config2;
|
|
73256
|
+
}
|
|
73257
|
+
async doGenerate(options) {
|
|
73258
|
+
var _a162, _b16, _c, _d, _e;
|
|
73259
|
+
const {
|
|
73260
|
+
prompt,
|
|
73261
|
+
n,
|
|
73262
|
+
aspectRatio,
|
|
73263
|
+
resolution,
|
|
73264
|
+
duration: duration3,
|
|
73265
|
+
seed,
|
|
73266
|
+
image,
|
|
73267
|
+
abortSignal,
|
|
73268
|
+
headers,
|
|
73269
|
+
providerOptions
|
|
73270
|
+
} = options;
|
|
73271
|
+
const warnings = [];
|
|
73272
|
+
if (n > 1) {
|
|
73273
|
+
warnings.push({
|
|
73274
|
+
type: "unsupported",
|
|
73275
|
+
feature: "n > 1",
|
|
73276
|
+
details: `OpenRouter video generation returns 1 video per call. Requested ${n} videos.`
|
|
73277
|
+
});
|
|
73278
|
+
}
|
|
73279
|
+
const body = __spreadValues2(__spreadValues2(__spreadValues2(__spreadValues2(__spreadValues2(__spreadValues2(__spreadValues2(__spreadValues2(__spreadValues2({
|
|
73280
|
+
model: this.modelId,
|
|
73281
|
+
prompt: prompt != null ? prompt : ""
|
|
73282
|
+
}, aspectRatio !== undefined && { aspect_ratio: aspectRatio }), resolution !== undefined && { size: resolution }), duration3 !== undefined && { duration: duration3 }), seed !== undefined && { seed }), this.settings.generateAudio !== undefined && {
|
|
73283
|
+
generate_audio: this.settings.generateAudio
|
|
73284
|
+
}), image !== undefined && {
|
|
73285
|
+
frame_images: [convertImageToFrameImage(image)]
|
|
73286
|
+
}), this.config.extraBody), this.settings.extraBody), providerOptions.openrouter);
|
|
73287
|
+
const mergedHeaders = combineHeaders5(this.config.headers(), headers);
|
|
73288
|
+
const { value: submitResponse, responseHeaders } = await postJsonToApi5({
|
|
73289
|
+
url: this.config.url({
|
|
73290
|
+
path: "/videos",
|
|
73291
|
+
modelId: this.modelId
|
|
73292
|
+
}),
|
|
73293
|
+
headers: mergedHeaders,
|
|
73294
|
+
body,
|
|
73295
|
+
failedResponseHandler: openrouterFailedResponseHandler,
|
|
73296
|
+
successfulResponseHandler: createJsonResponseHandler5(VideoGenerationSubmitResponseSchema),
|
|
73297
|
+
abortSignal,
|
|
73298
|
+
fetch: this.config.fetch
|
|
73299
|
+
});
|
|
73300
|
+
const pollIntervalMs = (_a162 = this.settings.pollIntervalMs) != null ? _a162 : DEFAULT_POLL_INTERVAL_MS;
|
|
73301
|
+
const maxPollTimeMs = (_b16 = this.settings.maxPollTimeMs) != null ? _b16 : DEFAULT_MAX_POLL_TIME_MS;
|
|
73302
|
+
const pollResult = await this.pollUntilComplete({
|
|
73303
|
+
jobId: submitResponse.id,
|
|
73304
|
+
headers: mergedHeaders,
|
|
73305
|
+
abortSignal,
|
|
73306
|
+
pollIntervalMs,
|
|
73307
|
+
maxPollTimeMs
|
|
73308
|
+
});
|
|
73309
|
+
const videos = [];
|
|
73310
|
+
if (pollResult.unsigned_urls) {
|
|
73311
|
+
for (const url2 of pollResult.unsigned_urls) {
|
|
73312
|
+
videos.push({
|
|
73313
|
+
type: "url",
|
|
73314
|
+
url: url2,
|
|
73315
|
+
mediaType: "video/mp4"
|
|
73316
|
+
});
|
|
73317
|
+
}
|
|
73318
|
+
}
|
|
73319
|
+
const providerMetadata = {
|
|
73320
|
+
openrouter: {
|
|
73321
|
+
generationId: (_c = pollResult.generation_id) != null ? _c : null,
|
|
73322
|
+
cost: (_e = (_d = pollResult.usage) == null ? undefined : _d.cost) != null ? _e : null
|
|
73323
|
+
}
|
|
73324
|
+
};
|
|
73325
|
+
return {
|
|
73326
|
+
videos,
|
|
73327
|
+
warnings,
|
|
73328
|
+
providerMetadata,
|
|
73329
|
+
response: {
|
|
73330
|
+
timestamp: /* @__PURE__ */ new Date,
|
|
73331
|
+
modelId: this.modelId,
|
|
73332
|
+
headers: responseHeaders
|
|
73333
|
+
}
|
|
73334
|
+
};
|
|
73335
|
+
}
|
|
73336
|
+
async pollUntilComplete({
|
|
73337
|
+
jobId,
|
|
73338
|
+
headers,
|
|
73339
|
+
abortSignal,
|
|
73340
|
+
pollIntervalMs,
|
|
73341
|
+
maxPollTimeMs
|
|
73342
|
+
}) {
|
|
73343
|
+
var _a162;
|
|
73344
|
+
const startTime = Date.now();
|
|
73345
|
+
while (Date.now() - startTime < maxPollTimeMs) {
|
|
73346
|
+
abortSignal == null || abortSignal.throwIfAborted();
|
|
73347
|
+
await delay2(pollIntervalMs);
|
|
73348
|
+
abortSignal == null || abortSignal.throwIfAborted();
|
|
73349
|
+
const { value: pollResponse } = await getFromApi2({
|
|
73350
|
+
url: this.config.url({
|
|
73351
|
+
path: `/videos/${jobId}`,
|
|
73352
|
+
modelId: this.modelId
|
|
73353
|
+
}),
|
|
73354
|
+
headers,
|
|
73355
|
+
failedResponseHandler: openrouterFailedResponseHandler,
|
|
73356
|
+
successfulResponseHandler: createJsonResponseHandler5(VideoGenerationPollResponseSchema),
|
|
73357
|
+
abortSignal,
|
|
73358
|
+
fetch: this.config.fetch
|
|
73359
|
+
});
|
|
73360
|
+
if (pollResponse.status === "completed") {
|
|
73361
|
+
return {
|
|
73362
|
+
generation_id: pollResponse.generation_id,
|
|
73363
|
+
unsigned_urls: pollResponse.unsigned_urls,
|
|
73364
|
+
usage: pollResponse.usage
|
|
73365
|
+
};
|
|
73366
|
+
}
|
|
73367
|
+
if (pollResponse.status === "failed" || pollResponse.status === "dead" || pollResponse.status === "cancelled" || pollResponse.status === "expired") {
|
|
73368
|
+
throw new APICallError5({
|
|
73369
|
+
message: (_a162 = pollResponse.error) != null ? _a162 : `Video generation failed with status: ${pollResponse.status}`,
|
|
73370
|
+
url: this.config.url({
|
|
73371
|
+
path: `/videos/${jobId}`,
|
|
73372
|
+
modelId: this.modelId
|
|
73373
|
+
}),
|
|
73374
|
+
requestBodyValues: {},
|
|
73375
|
+
statusCode: 500,
|
|
73376
|
+
isRetryable: false
|
|
73377
|
+
});
|
|
73378
|
+
}
|
|
73379
|
+
}
|
|
73380
|
+
throw new APICallError5({
|
|
73381
|
+
message: `Video generation timed out after ${maxPollTimeMs}ms`,
|
|
73382
|
+
url: this.config.url({
|
|
73383
|
+
path: `/videos/${jobId}`,
|
|
73384
|
+
modelId: this.modelId
|
|
73385
|
+
}),
|
|
73386
|
+
requestBodyValues: {},
|
|
73387
|
+
statusCode: 408,
|
|
73388
|
+
isRetryable: true
|
|
73389
|
+
});
|
|
73390
|
+
}
|
|
73391
|
+
}, openrouter;
|
|
72563
73392
|
var init_dist22 = __esm(() => {
|
|
72564
73393
|
init_v4();
|
|
72565
73394
|
init_v3();
|
|
@@ -72574,6 +73403,8 @@ var init_dist22 = __esm(() => {
|
|
|
72574
73403
|
init_v4();
|
|
72575
73404
|
init_v4();
|
|
72576
73405
|
init_v4();
|
|
73406
|
+
init_v4();
|
|
73407
|
+
init_v4();
|
|
72577
73408
|
__defProp4 = Object.defineProperty;
|
|
72578
73409
|
__defProps2 = Object.defineProperties;
|
|
72579
73410
|
__getOwnPropDescs2 = Object.getOwnPropertyDescriptors;
|
|
@@ -72777,24 +73608,50 @@ Error message: ${getErrorMessage6(cause)}`,
|
|
|
72777
73608
|
marker136 = `vercel.ai.error.${name126}`;
|
|
72778
73609
|
symbol136 = Symbol.for(marker136);
|
|
72779
73610
|
TypeValidationError5 = class _TypeValidationError5 extends (_b135 = AISDKError5, _a136 = symbol136, _b135) {
|
|
72780
|
-
constructor({
|
|
73611
|
+
constructor({
|
|
73612
|
+
value,
|
|
73613
|
+
cause,
|
|
73614
|
+
context: context2
|
|
73615
|
+
}) {
|
|
73616
|
+
let contextPrefix = "Type validation failed";
|
|
73617
|
+
if (context2 == null ? undefined : context2.field) {
|
|
73618
|
+
contextPrefix += ` for ${context2.field}`;
|
|
73619
|
+
}
|
|
73620
|
+
if ((context2 == null ? undefined : context2.entityName) || (context2 == null ? undefined : context2.entityId)) {
|
|
73621
|
+
contextPrefix += " (";
|
|
73622
|
+
const parts = [];
|
|
73623
|
+
if (context2.entityName) {
|
|
73624
|
+
parts.push(context2.entityName);
|
|
73625
|
+
}
|
|
73626
|
+
if (context2.entityId) {
|
|
73627
|
+
parts.push(`id: "${context2.entityId}"`);
|
|
73628
|
+
}
|
|
73629
|
+
contextPrefix += parts.join(", ");
|
|
73630
|
+
contextPrefix += ")";
|
|
73631
|
+
}
|
|
72781
73632
|
super({
|
|
72782
73633
|
name: name126,
|
|
72783
|
-
message:
|
|
73634
|
+
message: `${contextPrefix}: Value: ${JSON.stringify(value)}.
|
|
72784
73635
|
Error message: ${getErrorMessage6(cause)}`,
|
|
72785
73636
|
cause
|
|
72786
73637
|
});
|
|
72787
73638
|
this[_a136] = true;
|
|
72788
73639
|
this.value = value;
|
|
73640
|
+
this.context = context2;
|
|
72789
73641
|
}
|
|
72790
73642
|
static isInstance(error48) {
|
|
72791
73643
|
return AISDKError5.hasMarker(error48, marker136);
|
|
72792
73644
|
}
|
|
72793
73645
|
static wrap({
|
|
72794
73646
|
value,
|
|
72795
|
-
cause
|
|
73647
|
+
cause,
|
|
73648
|
+
context: context2
|
|
72796
73649
|
}) {
|
|
72797
|
-
|
|
73650
|
+
var _a1522, _b1522, _c;
|
|
73651
|
+
if (_TypeValidationError5.isInstance(cause) && cause.value === value && ((_a1522 = cause.context) == null ? undefined : _a1522.field) === (context2 == null ? undefined : context2.field) && ((_b1522 = cause.context) == null ? undefined : _b1522.entityName) === (context2 == null ? undefined : context2.entityName) && ((_c = cause.context) == null ? undefined : _c.entityId) === (context2 == null ? undefined : context2.entityId)) {
|
|
73652
|
+
return cause;
|
|
73653
|
+
}
|
|
73654
|
+
return new _TypeValidationError5({ value, cause, context: context2 });
|
|
72798
73655
|
}
|
|
72799
73656
|
};
|
|
72800
73657
|
marker146 = `vercel.ai.error.${name136}`;
|
|
@@ -72860,11 +73717,21 @@ Error message: ${getErrorMessage6(cause)}`,
|
|
|
72860
73717
|
return AISDKError5.hasMarker(error48, marker154);
|
|
72861
73718
|
}
|
|
72862
73719
|
};
|
|
73720
|
+
DEFAULT_MAX_DOWNLOAD_SIZE2 = 2 * 1024 * 1024 * 1024;
|
|
72863
73721
|
generateId5 = createIdGenerator5();
|
|
72864
73722
|
FETCH_FAILED_ERROR_MESSAGES5 = ["fetch failed", "failed to fetch"];
|
|
72865
|
-
|
|
72866
|
-
|
|
72867
|
-
|
|
73723
|
+
BUN_ERROR_CODES2 = [
|
|
73724
|
+
"ConnectionRefused",
|
|
73725
|
+
"ConnectionClosed",
|
|
73726
|
+
"FailedToOpenSocket",
|
|
73727
|
+
"ECONNRESET",
|
|
73728
|
+
"ECONNREFUSED",
|
|
73729
|
+
"ETIMEDOUT",
|
|
73730
|
+
"EPIPE"
|
|
73731
|
+
];
|
|
73732
|
+
suspectProtoRx5 = /"(?:_|\\u005[Ff])(?:_|\\u005[Ff])(?:p|\\u0070)(?:r|\\u0072)(?:o|\\u006[Ff])(?:t|\\u0074)(?:o|\\u006[Ff])(?:_|\\u005[Ff])(?:_|\\u005[Ff])"\s*:/;
|
|
73733
|
+
suspectConstructorRx5 = /"(?:c|\\u0063)(?:o|\\u006[Ff])(?:n|\\u006[Ee])(?:s|\\u0073)(?:t|\\u0074)(?:r|\\u0072)(?:u|\\u0075)(?:c|\\u0063)(?:t|\\u0074)(?:o|\\u006[Ff])(?:r|\\u0072)"\s*:/;
|
|
73734
|
+
ignoreOverride5 = /* @__PURE__ */ Symbol("Let zodToJsonSchema decide on which parser to use");
|
|
72868
73735
|
defaultOptions5 = {
|
|
72869
73736
|
name: undefined,
|
|
72870
73737
|
$refStrategy: "root",
|
|
@@ -72915,7 +73782,7 @@ Error message: ${getErrorMessage6(cause)}`,
|
|
|
72915
73782
|
ZodBoolean: "boolean",
|
|
72916
73783
|
ZodNull: "null"
|
|
72917
73784
|
};
|
|
72918
|
-
schemaSymbol5 = Symbol.for("vercel.ai.schema");
|
|
73785
|
+
schemaSymbol5 = /* @__PURE__ */ Symbol.for("vercel.ai.schema");
|
|
72919
73786
|
ReasoningFormat = /* @__PURE__ */ ((ReasoningFormat2) => {
|
|
72920
73787
|
ReasoningFormat2["Unknown"] = "unknown";
|
|
72921
73788
|
ReasoningFormat2["OpenAIResponsesV1"] = "openai-responses-v1";
|
|
@@ -73316,6 +74183,31 @@ Error message: ${getErrorMessage6(cause)}`,
|
|
|
73316
74183
|
total_tokens: exports_external.number()
|
|
73317
74184
|
}).passthrough().optional()
|
|
73318
74185
|
}).passthrough();
|
|
74186
|
+
webSearchInputSchema2 = exports_external.object({
|
|
74187
|
+
results: exports_external.array(exports_external.unknown()).optional()
|
|
74188
|
+
});
|
|
74189
|
+
webSearch2 = createProviderToolFactory3({
|
|
74190
|
+
id: "openrouter.web_search",
|
|
74191
|
+
inputSchema: webSearchInputSchema2
|
|
74192
|
+
});
|
|
74193
|
+
VideoGenerationSubmitResponseSchema = exports_external.object({
|
|
74194
|
+
id: exports_external.string(),
|
|
74195
|
+
generation_id: exports_external.string().optional(),
|
|
74196
|
+
polling_url: exports_external.string(),
|
|
74197
|
+
status: exports_external.string()
|
|
74198
|
+
}).passthrough();
|
|
74199
|
+
VideoGenerationPollResponseSchema = exports_external.object({
|
|
74200
|
+
id: exports_external.string(),
|
|
74201
|
+
generation_id: exports_external.string().optional(),
|
|
74202
|
+
polling_url: exports_external.string(),
|
|
74203
|
+
status: exports_external.string(),
|
|
74204
|
+
unsigned_urls: exports_external.array(exports_external.string()).optional(),
|
|
74205
|
+
usage: exports_external.object({
|
|
74206
|
+
cost: exports_external.number().optional(),
|
|
74207
|
+
is_byok: exports_external.boolean().optional()
|
|
74208
|
+
}).passthrough().optional(),
|
|
74209
|
+
error: exports_external.string().optional()
|
|
74210
|
+
}).passthrough();
|
|
73319
74211
|
openrouter = createOpenRouter({
|
|
73320
74212
|
compatibility: "strict"
|
|
73321
74213
|
});
|
|
@@ -73518,7 +74410,7 @@ async function installProxy(version2) {
|
|
|
73518
74410
|
}
|
|
73519
74411
|
});
|
|
73520
74412
|
}
|
|
73521
|
-
var SOULFORGE_DIR, BIN_DIR, INSTALLS_DIR, FONTS_DIR, PROXY_VERSION = "6.9.
|
|
74413
|
+
var SOULFORGE_DIR, BIN_DIR, INSTALLS_DIR, FONTS_DIR, PROXY_VERSION = "6.9.28", PROXY_SUFFIXES;
|
|
73522
74414
|
var init_install = __esm(() => {
|
|
73523
74415
|
SOULFORGE_DIR = join7(homedir5(), ".soulforge");
|
|
73524
74416
|
BIN_DIR = join7(SOULFORGE_DIR, "bin");
|
|
@@ -73533,7 +74425,7 @@ var init_install = __esm(() => {
|
|
|
73533
74425
|
});
|
|
73534
74426
|
|
|
73535
74427
|
// src/core/proxy/lifecycle.ts
|
|
73536
|
-
import { execSync as execSync2, spawn as spawn4 } from "child_process";
|
|
74428
|
+
import { execFileSync, execSync as execSync2, spawn as spawn4 } from "child_process";
|
|
73537
74429
|
import { existsSync as existsSync3, mkdirSync as mkdirSync3, readdirSync as readdirSync3, readFileSync as readFileSync2, unlinkSync as unlinkSync2, writeFileSync as writeFileSync2 } from "fs";
|
|
73538
74430
|
import { homedir as homedir6 } from "os";
|
|
73539
74431
|
import { join as join8 } from "path";
|
|
@@ -73543,6 +74435,16 @@ function setState(state, error48 = null) {
|
|
|
73543
74435
|
for (const fn of stateListeners)
|
|
73544
74436
|
fn(state, error48);
|
|
73545
74437
|
}
|
|
74438
|
+
function getInstalledProxyVersion() {
|
|
74439
|
+
try {
|
|
74440
|
+
if (existsSync3(VERSION_FILE)) {
|
|
74441
|
+
const v = readFileSync2(VERSION_FILE, "utf-8").trim();
|
|
74442
|
+
if (v)
|
|
74443
|
+
return v;
|
|
74444
|
+
}
|
|
74445
|
+
} catch {}
|
|
74446
|
+
return PROXY_VERSION;
|
|
74447
|
+
}
|
|
73546
74448
|
function saveInstalledProxyVersion(version2) {
|
|
73547
74449
|
mkdirSync3(PROXY_CONFIG_DIR, {
|
|
73548
74450
|
recursive: true
|
|
@@ -73647,8 +74549,14 @@ async function ensureProxy() {
|
|
|
73647
74549
|
error: "Proxy is already starting"
|
|
73648
74550
|
};
|
|
73649
74551
|
}
|
|
74552
|
+
const installed = getInstalledProxyVersion();
|
|
74553
|
+
const needsUpgrade = installed !== PROXY_VERSION;
|
|
74554
|
+
if (needsUpgrade) {
|
|
74555
|
+
stopProxy();
|
|
74556
|
+
killProxyOnPort();
|
|
74557
|
+
}
|
|
73650
74558
|
const health = await healthCheck();
|
|
73651
|
-
if (health === "ok") {
|
|
74559
|
+
if (health === "ok" && !needsUpgrade) {
|
|
73652
74560
|
setState("running");
|
|
73653
74561
|
return {
|
|
73654
74562
|
ok: true
|
|
@@ -73746,8 +74654,41 @@ function stopProxy() {
|
|
|
73746
74654
|
}
|
|
73747
74655
|
proxyProcess = null;
|
|
73748
74656
|
}
|
|
74657
|
+
killProxyOnPort();
|
|
73749
74658
|
setState("stopped");
|
|
73750
74659
|
}
|
|
74660
|
+
function killProxyOnPort() {
|
|
74661
|
+
const portMatch = PROXY_URL.match(/:([0-9]+)/);
|
|
74662
|
+
if (!portMatch)
|
|
74663
|
+
return;
|
|
74664
|
+
const port = portMatch[1];
|
|
74665
|
+
let out = "";
|
|
74666
|
+
try {
|
|
74667
|
+
out = execFileSync("lsof", ["-ti", `tcp:${port}`], {
|
|
74668
|
+
encoding: "utf-8",
|
|
74669
|
+
timeout: 3000
|
|
74670
|
+
}).trim();
|
|
74671
|
+
} catch {
|
|
74672
|
+
try {
|
|
74673
|
+
out = execFileSync("fuser", [`${port}/tcp`], {
|
|
74674
|
+
encoding: "utf-8",
|
|
74675
|
+
timeout: 3000
|
|
74676
|
+
}).trim();
|
|
74677
|
+
} catch {
|
|
74678
|
+
return;
|
|
74679
|
+
}
|
|
74680
|
+
}
|
|
74681
|
+
if (!out)
|
|
74682
|
+
return;
|
|
74683
|
+
for (const token of out.split(/[\s\n]+/)) {
|
|
74684
|
+
const pid = Number.parseInt(token.trim(), 10);
|
|
74685
|
+
if (pid > 0 && pid !== process.pid) {
|
|
74686
|
+
try {
|
|
74687
|
+
process.kill(pid, "SIGTERM");
|
|
74688
|
+
} catch {}
|
|
74689
|
+
}
|
|
74690
|
+
}
|
|
74691
|
+
}
|
|
73751
74692
|
var proxyProcess = null, PROXY_URL, PROXY_API_KEY, PROXY_CONFIG_DIR, PROXY_CONFIG_PATH, HEALTH_TIMEOUT_MS = 2000, STARTUP_POLL_MS = 500, STARTUP_POLL_ATTEMPTS = 10, currentState = "stopped", lastError = null, stateListeners, VERSION_FILE, PERF_MARKER_PREFIX = "# soulforge-perf-defaults", PERF_MARKER_VERSION = 1, PERF_MARKER, PERF_KEYS, PERF_BLOCK, AUTH_DIR, VERSION_CACHE_TTL;
|
|
73752
74693
|
var init_lifecycle = __esm(() => {
|
|
73753
74694
|
init_errors4();
|
|
@@ -73808,6 +74749,9 @@ var init_proxy = __esm(() => {
|
|
|
73808
74749
|
stopProxy();
|
|
73809
74750
|
},
|
|
73810
74751
|
fallbackModels: [{
|
|
74752
|
+
id: "claude-opus-4-7",
|
|
74753
|
+
name: "Claude Opus 4.7"
|
|
74754
|
+
}, {
|
|
73811
74755
|
id: "claude-opus-4-6",
|
|
73812
74756
|
name: "Claude Opus 4.6"
|
|
73813
74757
|
}, {
|
|
@@ -73830,6 +74774,8 @@ var init_proxy = __esm(() => {
|
|
|
73830
74774
|
name: "Claude Haiku 3.5"
|
|
73831
74775
|
}],
|
|
73832
74776
|
contextWindows: [
|
|
74777
|
+
["claude-opus-4-7", 1e6],
|
|
74778
|
+
["claude-opus-4.7", 1e6],
|
|
73833
74779
|
["claude-opus-4-6", 1e6],
|
|
73834
74780
|
["claude-opus-4.6", 1e6],
|
|
73835
74781
|
["claude-sonnet-4-6", 1e6],
|
|
@@ -74073,20 +75019,20 @@ function prepareTools11({
|
|
|
74073
75019
|
return { tools: undefined, toolChoice: undefined, toolWarnings };
|
|
74074
75020
|
}
|
|
74075
75021
|
const xaiTools2 = [];
|
|
74076
|
-
for (const
|
|
74077
|
-
if (
|
|
75022
|
+
for (const tool4 of tools) {
|
|
75023
|
+
if (tool4.type === "provider") {
|
|
74078
75024
|
toolWarnings.push({
|
|
74079
75025
|
type: "unsupported",
|
|
74080
|
-
feature: `provider-defined tool ${
|
|
75026
|
+
feature: `provider-defined tool ${tool4.name}`
|
|
74081
75027
|
});
|
|
74082
75028
|
} else {
|
|
74083
75029
|
xaiTools2.push({
|
|
74084
75030
|
type: "function",
|
|
74085
75031
|
function: {
|
|
74086
|
-
name:
|
|
74087
|
-
description:
|
|
74088
|
-
parameters:
|
|
74089
|
-
...
|
|
75032
|
+
name: tool4.name,
|
|
75033
|
+
description: tool4.description,
|
|
75034
|
+
parameters: tool4.inputSchema,
|
|
75035
|
+
...tool4.strict != null ? { strict: tool4.strict } : {}
|
|
74090
75036
|
}
|
|
74091
75037
|
});
|
|
74092
75038
|
}
|
|
@@ -74121,7 +75067,7 @@ function prepareTools11({
|
|
|
74121
75067
|
async function convertToXaiResponsesInput({
|
|
74122
75068
|
prompt
|
|
74123
75069
|
}) {
|
|
74124
|
-
var _a31, _b16, _c, _d, _e;
|
|
75070
|
+
var _a31, _b16, _c, _d, _e, _f, _g, _h, _i;
|
|
74125
75071
|
const input = [];
|
|
74126
75072
|
const inputWarnings = [];
|
|
74127
75073
|
for (const message of prompt) {
|
|
@@ -74198,7 +75144,34 @@ async function convertToXaiResponsesInput({
|
|
|
74198
75144
|
case "tool-result": {
|
|
74199
75145
|
break;
|
|
74200
75146
|
}
|
|
74201
|
-
case "reasoning":
|
|
75147
|
+
case "reasoning": {
|
|
75148
|
+
const itemId = typeof ((_f = (_e = part.providerOptions) == null ? undefined : _e.xai) == null ? undefined : _f.itemId) === "string" ? part.providerOptions.xai.itemId : undefined;
|
|
75149
|
+
const encryptedContent = typeof ((_h = (_g = part.providerOptions) == null ? undefined : _g.xai) == null ? undefined : _h.reasoningEncryptedContent) === "string" ? part.providerOptions.xai.reasoningEncryptedContent : undefined;
|
|
75150
|
+
if (itemId != null || encryptedContent != null) {
|
|
75151
|
+
const summaryParts = [];
|
|
75152
|
+
if (part.text.length > 0) {
|
|
75153
|
+
summaryParts.push({
|
|
75154
|
+
type: "summary_text",
|
|
75155
|
+
text: part.text
|
|
75156
|
+
});
|
|
75157
|
+
}
|
|
75158
|
+
input.push({
|
|
75159
|
+
type: "reasoning",
|
|
75160
|
+
id: itemId != null ? itemId : "",
|
|
75161
|
+
summary: summaryParts,
|
|
75162
|
+
status: "completed",
|
|
75163
|
+
...encryptedContent != null && {
|
|
75164
|
+
encrypted_content: encryptedContent
|
|
75165
|
+
}
|
|
75166
|
+
});
|
|
75167
|
+
} else {
|
|
75168
|
+
inputWarnings.push({
|
|
75169
|
+
type: "other",
|
|
75170
|
+
message: "Reasoning parts without itemId or encrypted content cannot be sent back to xAI. Skipping."
|
|
75171
|
+
});
|
|
75172
|
+
}
|
|
75173
|
+
break;
|
|
75174
|
+
}
|
|
74202
75175
|
case "file": {
|
|
74203
75176
|
inputWarnings.push({
|
|
74204
75177
|
type: "other",
|
|
@@ -74230,7 +75203,7 @@ async function convertToXaiResponsesInput({
|
|
|
74230
75203
|
outputValue = output.value;
|
|
74231
75204
|
break;
|
|
74232
75205
|
case "execution-denied":
|
|
74233
|
-
outputValue = (
|
|
75206
|
+
outputValue = (_i = output.reason) != null ? _i : "tool execution denied";
|
|
74234
75207
|
break;
|
|
74235
75208
|
case "json":
|
|
74236
75209
|
case "error-json":
|
|
@@ -74316,13 +75289,13 @@ async function prepareResponsesTools2({
|
|
|
74316
75289
|
}
|
|
74317
75290
|
const xaiTools2 = [];
|
|
74318
75291
|
const toolByName = /* @__PURE__ */ new Map;
|
|
74319
|
-
for (const
|
|
74320
|
-
toolByName.set(
|
|
74321
|
-
if (
|
|
74322
|
-
switch (
|
|
75292
|
+
for (const tool4 of normalizedTools) {
|
|
75293
|
+
toolByName.set(tool4.name, tool4);
|
|
75294
|
+
if (tool4.type === "provider") {
|
|
75295
|
+
switch (tool4.id) {
|
|
74323
75296
|
case "xai.web_search": {
|
|
74324
75297
|
const args = await validateTypes({
|
|
74325
|
-
value:
|
|
75298
|
+
value: tool4.args,
|
|
74326
75299
|
schema: webSearchArgsSchema2
|
|
74327
75300
|
});
|
|
74328
75301
|
xaiTools2.push({
|
|
@@ -74335,7 +75308,7 @@ async function prepareResponsesTools2({
|
|
|
74335
75308
|
}
|
|
74336
75309
|
case "xai.x_search": {
|
|
74337
75310
|
const args = await validateTypes({
|
|
74338
|
-
value:
|
|
75311
|
+
value: tool4.args,
|
|
74339
75312
|
schema: xSearchArgsSchema
|
|
74340
75313
|
});
|
|
74341
75314
|
xaiTools2.push({
|
|
@@ -74369,7 +75342,7 @@ async function prepareResponsesTools2({
|
|
|
74369
75342
|
}
|
|
74370
75343
|
case "xai.file_search": {
|
|
74371
75344
|
const args = await validateTypes({
|
|
74372
|
-
value:
|
|
75345
|
+
value: tool4.args,
|
|
74373
75346
|
schema: fileSearchArgsSchema3
|
|
74374
75347
|
});
|
|
74375
75348
|
xaiTools2.push({
|
|
@@ -74381,7 +75354,7 @@ async function prepareResponsesTools2({
|
|
|
74381
75354
|
}
|
|
74382
75355
|
case "xai.mcp": {
|
|
74383
75356
|
const args = await validateTypes({
|
|
74384
|
-
value:
|
|
75357
|
+
value: tool4.args,
|
|
74385
75358
|
schema: mcpServerArgsSchema
|
|
74386
75359
|
});
|
|
74387
75360
|
xaiTools2.push({
|
|
@@ -74398,7 +75371,7 @@ async function prepareResponsesTools2({
|
|
|
74398
75371
|
default: {
|
|
74399
75372
|
toolWarnings.push({
|
|
74400
75373
|
type: "unsupported",
|
|
74401
|
-
feature: `provider-defined tool ${
|
|
75374
|
+
feature: `provider-defined tool ${tool4.name}`
|
|
74402
75375
|
});
|
|
74403
75376
|
break;
|
|
74404
75377
|
}
|
|
@@ -74406,10 +75379,10 @@ async function prepareResponsesTools2({
|
|
|
74406
75379
|
} else {
|
|
74407
75380
|
xaiTools2.push({
|
|
74408
75381
|
type: "function",
|
|
74409
|
-
name:
|
|
74410
|
-
description:
|
|
74411
|
-
parameters:
|
|
74412
|
-
...
|
|
75382
|
+
name: tool4.name,
|
|
75383
|
+
description: tool4.description,
|
|
75384
|
+
parameters: tool4.inputSchema,
|
|
75385
|
+
...tool4.strict != null ? { strict: tool4.strict } : {}
|
|
74413
75386
|
});
|
|
74414
75387
|
}
|
|
74415
75388
|
}
|
|
@@ -75072,7 +76045,7 @@ var webSourceSchema, xSourceSchema, newsSourceSchema, rssSourceSchema, searchSou
|
|
|
75072
76045
|
});
|
|
75073
76046
|
return value;
|
|
75074
76047
|
}
|
|
75075
|
-
}, xaiImageResponseSchema, annotationSchema, messageContentPartSchema, reasoningSummaryPartSchema, toolCallSchema, mcpCallSchema, outputItemSchema, xaiResponsesUsageSchema, xaiResponsesResponseSchema, xaiResponsesChunkSchema, xaiLanguageModelResponsesOptions, fileSearchArgsSchema3, fileSearchOutputSchema2, fileSearchToolFactory, fileSearch3 = (args) => fileSearchToolFactory(args), mcpServerArgsSchema, mcpServerOutputSchema, mcpServerToolFactory, mcpServer = (args) => mcpServerToolFactory(args), webSearchArgsSchema2, webSearchOutputSchema2, webSearchToolFactory2,
|
|
76048
|
+
}, xaiImageResponseSchema, annotationSchema, messageContentPartSchema, reasoningSummaryPartSchema, toolCallSchema, mcpCallSchema, outputItemSchema, xaiResponsesUsageSchema, xaiResponsesResponseSchema, xaiResponsesChunkSchema, xaiLanguageModelResponsesOptions, fileSearchArgsSchema3, fileSearchOutputSchema2, fileSearchToolFactory, fileSearch3 = (args) => fileSearchToolFactory(args), mcpServerArgsSchema, mcpServerOutputSchema, mcpServerToolFactory, mcpServer = (args) => mcpServerToolFactory(args), webSearchArgsSchema2, webSearchOutputSchema2, webSearchToolFactory2, webSearch3 = (args = {}) => webSearchToolFactory2(args), xSearchArgsSchema, xSearchOutputSchema, xSearchToolFactory, xSearch = (args = {}) => xSearchToolFactory(args), XaiResponsesLanguageModel = class {
|
|
75076
76049
|
constructor(modelId, config2) {
|
|
75077
76050
|
this.specificationVersion = "v3";
|
|
75078
76051
|
this.supportedUrls = {
|
|
@@ -75096,7 +76069,7 @@ var webSourceSchema, xSourceSchema, newsSourceSchema, rssSourceSchema, searchSou
|
|
|
75096
76069
|
tools,
|
|
75097
76070
|
toolChoice
|
|
75098
76071
|
}) {
|
|
75099
|
-
var _a31, _b16, _c, _d, _e, _f, _g;
|
|
76072
|
+
var _a31, _b16, _c, _d, _e, _f, _g, _h;
|
|
75100
76073
|
const warnings = [];
|
|
75101
76074
|
const options = (_a31 = await parseProviderOptions({
|
|
75102
76075
|
provider: "xai",
|
|
@@ -75106,14 +76079,14 @@ var webSourceSchema, xSourceSchema, newsSourceSchema, rssSourceSchema, searchSou
|
|
|
75106
76079
|
if (stopSequences != null) {
|
|
75107
76080
|
warnings.push({ type: "unsupported", feature: "stopSequences" });
|
|
75108
76081
|
}
|
|
75109
|
-
const webSearchToolName = (_b16 = tools == null ? undefined : tools.find((
|
|
75110
|
-
const xSearchToolName = (_c = tools == null ? undefined : tools.find((
|
|
75111
|
-
const codeExecutionToolName = (_d = tools == null ? undefined : tools.find((
|
|
75112
|
-
const mcpToolName = (_e = tools == null ? undefined : tools.find((
|
|
75113
|
-
const fileSearchToolName = (_f = tools == null ? undefined : tools.find((
|
|
76082
|
+
const webSearchToolName = (_b16 = tools == null ? undefined : tools.find((tool4) => tool4.type === "provider" && tool4.id === "xai.web_search")) == null ? undefined : _b16.name;
|
|
76083
|
+
const xSearchToolName = (_c = tools == null ? undefined : tools.find((tool4) => tool4.type === "provider" && tool4.id === "xai.x_search")) == null ? undefined : _c.name;
|
|
76084
|
+
const codeExecutionToolName = (_d = tools == null ? undefined : tools.find((tool4) => tool4.type === "provider" && tool4.id === "xai.code_execution")) == null ? undefined : _d.name;
|
|
76085
|
+
const mcpToolName = (_e = tools == null ? undefined : tools.find((tool4) => tool4.type === "provider" && tool4.id === "xai.mcp")) == null ? undefined : _e.name;
|
|
76086
|
+
const fileSearchToolName = (_f = tools == null ? undefined : tools.find((tool4) => tool4.type === "provider" && tool4.id === "xai.file_search")) == null ? undefined : _f.name;
|
|
75114
76087
|
const { input, inputWarnings } = await convertToXaiResponsesInput({
|
|
75115
76088
|
prompt,
|
|
75116
|
-
store: true
|
|
76089
|
+
store: (_g = options.store) != null ? _g : true
|
|
75117
76090
|
});
|
|
75118
76091
|
warnings.push(...inputWarnings);
|
|
75119
76092
|
const {
|
|
@@ -75147,7 +76120,7 @@ var webSourceSchema, xSourceSchema, newsSourceSchema, rssSourceSchema, searchSou
|
|
|
75147
76120
|
format: responseFormat.schema != null ? {
|
|
75148
76121
|
type: "json_schema",
|
|
75149
76122
|
strict: true,
|
|
75150
|
-
name: (
|
|
76123
|
+
name: (_h = responseFormat.name) != null ? _h : "response",
|
|
75151
76124
|
description: responseFormat.description,
|
|
75152
76125
|
schema: responseFormat.schema
|
|
75153
76126
|
} : { type: "json_object" }
|
|
@@ -75303,12 +76276,13 @@ var webSourceSchema, xSourceSchema, newsSourceSchema, rssSourceSchema, searchSou
|
|
|
75303
76276
|
}
|
|
75304
76277
|
case "reasoning": {
|
|
75305
76278
|
const summaryTexts = part.summary.map((s) => s.text).filter((text2) => text2 && text2.length > 0);
|
|
75306
|
-
|
|
75307
|
-
|
|
75308
|
-
|
|
75309
|
-
|
|
75310
|
-
|
|
75311
|
-
|
|
76279
|
+
const reasoningText = summaryTexts.join("");
|
|
76280
|
+
if (reasoningText || part.encrypted_content) {
|
|
76281
|
+
const hasMetadata = part.encrypted_content || part.id;
|
|
76282
|
+
content.push({
|
|
76283
|
+
type: "reasoning",
|
|
76284
|
+
text: reasoningText,
|
|
76285
|
+
...hasMetadata && {
|
|
75312
76286
|
providerMetadata: {
|
|
75313
76287
|
xai: {
|
|
75314
76288
|
...part.encrypted_content && {
|
|
@@ -75317,13 +76291,8 @@ var webSourceSchema, xSourceSchema, newsSourceSchema, rssSourceSchema, searchSou
|
|
|
75317
76291
|
...part.id && { itemId: part.id }
|
|
75318
76292
|
}
|
|
75319
76293
|
}
|
|
75320
|
-
}
|
|
75321
|
-
}
|
|
75322
|
-
content.push({
|
|
75323
|
-
type: "reasoning",
|
|
75324
|
-
text: reasoningText
|
|
75325
|
-
});
|
|
75326
|
-
}
|
|
76294
|
+
}
|
|
76295
|
+
});
|
|
75327
76296
|
}
|
|
75328
76297
|
break;
|
|
75329
76298
|
}
|
|
@@ -75781,7 +76750,7 @@ var webSourceSchema, xSourceSchema, newsSourceSchema, rssSourceSchema, searchSou
|
|
|
75781
76750
|
response: { headers: responseHeaders }
|
|
75782
76751
|
};
|
|
75783
76752
|
}
|
|
75784
|
-
}, codeExecutionOutputSchema, codeExecutionToolFactory, codeExecution2 = (args = {}) => codeExecutionToolFactory(args), viewImageOutputSchema, viewImageToolFactory, viewImage = (args = {}) => viewImageToolFactory(args), viewXVideoOutputSchema, viewXVideoToolFactory, viewXVideo = (args = {}) => viewXVideoToolFactory(args), xaiTools, VERSION17 = "3.0.
|
|
76753
|
+
}, codeExecutionOutputSchema, codeExecutionToolFactory, codeExecution2 = (args = {}) => codeExecutionToolFactory(args), viewImageOutputSchema, viewImageToolFactory, viewImage = (args = {}) => viewImageToolFactory(args), viewXVideoOutputSchema, viewXVideoToolFactory, viewXVideo = (args = {}) => viewXVideoToolFactory(args), xaiTools, VERSION17 = "3.0.83", nonEmptyStringSchema, resolutionSchema, modeSchema, baseFields, editVideoSchema, extendVideoSchema, referenceToVideoSchema, autoDetectSchema, xaiVideoModelOptions, runtimeSchema, xaiVideoModelOptionsSchema, RESOLUTION_MAP, XaiVideoModel = class {
|
|
75785
76754
|
constructor(modelId, config2) {
|
|
75786
76755
|
this.modelId = modelId;
|
|
75787
76756
|
this.config = config2;
|
|
@@ -76747,7 +77716,7 @@ var init_dist23 = __esm(() => {
|
|
|
76747
77716
|
mcpServer,
|
|
76748
77717
|
viewImage,
|
|
76749
77718
|
viewXVideo,
|
|
76750
|
-
webSearch:
|
|
77719
|
+
webSearch: webSearch3,
|
|
76751
77720
|
xSearch
|
|
76752
77721
|
};
|
|
76753
77722
|
nonEmptyStringSchema = exports_external.string().min(1);
|