@ai-sdk/gateway 3.0.237 → 3.0.238
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +9 -0
- package/dist/index.d.mts +38 -4
- package/dist/index.d.ts +38 -4
- package/dist/index.js +528 -470
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +794 -737
- package/dist/index.mjs.map +1 -1
- package/package.json +2 -2
- package/src/errors/create-gateway-error.ts +21 -0
- package/src/errors/gateway-access-policy-denied-error.ts +72 -0
- package/src/errors/index.ts +1 -0
- package/src/gateway-language-model-settings.ts +2 -4
- package/src/index.ts +1 -0
package/dist/index.mjs
CHANGED
|
@@ -9,7 +9,7 @@ import {
|
|
|
9
9
|
import { APICallError } from "@ai-sdk/provider";
|
|
10
10
|
|
|
11
11
|
// src/errors/create-gateway-error.ts
|
|
12
|
-
import { z as
|
|
12
|
+
import { z as z4 } from "zod/v4";
|
|
13
13
|
|
|
14
14
|
// src/errors/gateway-error.ts
|
|
15
15
|
var marker = "vercel.ai.gateway.error";
|
|
@@ -271,12 +271,52 @@ var GatewayForbiddenError = class extends (_b8 = GatewayError, _a8 = symbol8, _b
|
|
|
271
271
|
}
|
|
272
272
|
};
|
|
273
273
|
|
|
274
|
-
// src/errors/gateway-
|
|
275
|
-
|
|
274
|
+
// src/errors/gateway-access-policy-denied-error.ts
|
|
275
|
+
import { z as z3 } from "zod/v4";
|
|
276
|
+
import { lazySchema as lazySchema3, zodSchema as zodSchema3 } from "@ai-sdk/provider-utils";
|
|
277
|
+
var name8 = "GatewayAccessPolicyDeniedError";
|
|
276
278
|
var marker9 = `vercel.ai.gateway.error.${name8}`;
|
|
277
279
|
var symbol9 = Symbol.for(marker9);
|
|
280
|
+
var accessPolicyDeniedParamSchema = lazySchema3(
|
|
281
|
+
() => zodSchema3(
|
|
282
|
+
z3.object({
|
|
283
|
+
policyIds: z3.optional(z3.array(z3.string())),
|
|
284
|
+
removedModels: z3.optional(z3.array(z3.string())),
|
|
285
|
+
removedProviders: z3.optional(z3.array(z3.string()))
|
|
286
|
+
})
|
|
287
|
+
)
|
|
288
|
+
);
|
|
278
289
|
var _a9, _b9;
|
|
279
|
-
var
|
|
290
|
+
var GatewayAccessPolicyDeniedError = class extends (_b9 = GatewayError, _a9 = symbol9, _b9) {
|
|
291
|
+
constructor({
|
|
292
|
+
message = "Access policy denied",
|
|
293
|
+
statusCode = 403,
|
|
294
|
+
cause,
|
|
295
|
+
generationId,
|
|
296
|
+
policyIds,
|
|
297
|
+
removedModels,
|
|
298
|
+
removedProviders
|
|
299
|
+
} = {}) {
|
|
300
|
+
super({ message, statusCode, cause, generationId });
|
|
301
|
+
this[_a9] = true;
|
|
302
|
+
// used in isInstance
|
|
303
|
+
this.name = name8;
|
|
304
|
+
this.type = "access_policy_denied";
|
|
305
|
+
this.policyIds = policyIds;
|
|
306
|
+
this.removedModels = removedModels;
|
|
307
|
+
this.removedProviders = removedProviders;
|
|
308
|
+
}
|
|
309
|
+
static isInstance(error) {
|
|
310
|
+
return GatewayError.hasMarker(error) && symbol9 in error;
|
|
311
|
+
}
|
|
312
|
+
};
|
|
313
|
+
|
|
314
|
+
// src/errors/gateway-response-error.ts
|
|
315
|
+
var name9 = "GatewayResponseError";
|
|
316
|
+
var marker10 = `vercel.ai.gateway.error.${name9}`;
|
|
317
|
+
var symbol10 = Symbol.for(marker10);
|
|
318
|
+
var _a10, _b10;
|
|
319
|
+
var GatewayResponseError = class extends (_b10 = GatewayError, _a10 = symbol10, _b10) {
|
|
280
320
|
constructor({
|
|
281
321
|
message = "Invalid response from Gateway",
|
|
282
322
|
statusCode = 502,
|
|
@@ -287,23 +327,23 @@ var GatewayResponseError = class extends (_b9 = GatewayError, _a9 = symbol9, _b9
|
|
|
287
327
|
isRetryable
|
|
288
328
|
} = {}) {
|
|
289
329
|
super({ message, statusCode, cause, generationId, isRetryable });
|
|
290
|
-
this[
|
|
330
|
+
this[_a10] = true;
|
|
291
331
|
// used in isInstance
|
|
292
|
-
this.name =
|
|
332
|
+
this.name = name9;
|
|
293
333
|
this.type = "response_error";
|
|
294
334
|
this.response = response;
|
|
295
335
|
this.validationError = validationError;
|
|
296
336
|
}
|
|
297
337
|
static isInstance(error) {
|
|
298
|
-
return GatewayError.hasMarker(error) &&
|
|
338
|
+
return GatewayError.hasMarker(error) && symbol10 in error;
|
|
299
339
|
}
|
|
300
340
|
};
|
|
301
341
|
|
|
302
342
|
// src/errors/create-gateway-error.ts
|
|
303
343
|
import {
|
|
304
|
-
lazySchema as
|
|
344
|
+
lazySchema as lazySchema4,
|
|
305
345
|
safeValidateTypes,
|
|
306
|
-
zodSchema as
|
|
346
|
+
zodSchema as zodSchema4
|
|
307
347
|
} from "@ai-sdk/provider-utils";
|
|
308
348
|
async function createGatewayErrorFromResponse({
|
|
309
349
|
response,
|
|
@@ -313,7 +353,7 @@ async function createGatewayErrorFromResponse({
|
|
|
313
353
|
authMethod,
|
|
314
354
|
isRetryable
|
|
315
355
|
}) {
|
|
316
|
-
var
|
|
356
|
+
var _a12;
|
|
317
357
|
const parseResult = await safeValidateTypes({
|
|
318
358
|
value: response,
|
|
319
359
|
schema: gatewayErrorResponseSchema
|
|
@@ -333,7 +373,7 @@ async function createGatewayErrorFromResponse({
|
|
|
333
373
|
const validatedResponse = parseResult.value;
|
|
334
374
|
const errorType = validatedResponse.error.type;
|
|
335
375
|
const message = validatedResponse.error.message;
|
|
336
|
-
const generationId = (
|
|
376
|
+
const generationId = (_a12 = validatedResponse.generationId) != null ? _a12 : void 0;
|
|
337
377
|
switch (errorType) {
|
|
338
378
|
case "authentication_error":
|
|
339
379
|
return GatewayAuthenticationError.createContextualError({
|
|
@@ -397,6 +437,22 @@ async function createGatewayErrorFromResponse({
|
|
|
397
437
|
ruleId: ruleResult.success ? ruleResult.value.ruleId : void 0
|
|
398
438
|
});
|
|
399
439
|
}
|
|
440
|
+
case "access_policy_denied": {
|
|
441
|
+
const paramResult = await safeValidateTypes({
|
|
442
|
+
value: validatedResponse.error.param,
|
|
443
|
+
schema: accessPolicyDeniedParamSchema
|
|
444
|
+
});
|
|
445
|
+
const param = paramResult.success ? paramResult.value : void 0;
|
|
446
|
+
return new GatewayAccessPolicyDeniedError({
|
|
447
|
+
message,
|
|
448
|
+
statusCode,
|
|
449
|
+
cause,
|
|
450
|
+
generationId,
|
|
451
|
+
policyIds: param == null ? void 0 : param.policyIds,
|
|
452
|
+
removedModels: param == null ? void 0 : param.removedModels,
|
|
453
|
+
removedProviders: param == null ? void 0 : param.removedProviders
|
|
454
|
+
});
|
|
455
|
+
}
|
|
400
456
|
default:
|
|
401
457
|
return new GatewayInternalServerError({
|
|
402
458
|
message,
|
|
@@ -406,16 +462,16 @@ async function createGatewayErrorFromResponse({
|
|
|
406
462
|
});
|
|
407
463
|
}
|
|
408
464
|
}
|
|
409
|
-
var gatewayErrorResponseSchema =
|
|
410
|
-
() =>
|
|
411
|
-
|
|
412
|
-
error:
|
|
413
|
-
message:
|
|
414
|
-
type:
|
|
415
|
-
param:
|
|
416
|
-
code:
|
|
465
|
+
var gatewayErrorResponseSchema = lazySchema4(
|
|
466
|
+
() => zodSchema4(
|
|
467
|
+
z4.object({
|
|
468
|
+
error: z4.object({
|
|
469
|
+
message: z4.string(),
|
|
470
|
+
type: z4.string().nullish(),
|
|
471
|
+
param: z4.unknown().nullish(),
|
|
472
|
+
code: z4.union([z4.string(), z4.number()]).nullish()
|
|
417
473
|
}),
|
|
418
|
-
generationId:
|
|
474
|
+
generationId: z4.string().nullish()
|
|
419
475
|
})
|
|
420
476
|
)
|
|
421
477
|
);
|
|
@@ -437,11 +493,11 @@ function extractApiCallResponse(error) {
|
|
|
437
493
|
}
|
|
438
494
|
|
|
439
495
|
// src/errors/gateway-timeout-error.ts
|
|
440
|
-
var
|
|
441
|
-
var
|
|
442
|
-
var
|
|
443
|
-
var
|
|
444
|
-
var GatewayTimeoutError = class _GatewayTimeoutError extends (
|
|
496
|
+
var name10 = "GatewayTimeoutError";
|
|
497
|
+
var marker11 = `vercel.ai.gateway.error.${name10}`;
|
|
498
|
+
var symbol11 = Symbol.for(marker11);
|
|
499
|
+
var _a11, _b11;
|
|
500
|
+
var GatewayTimeoutError = class _GatewayTimeoutError extends (_b11 = GatewayError, _a11 = symbol11, _b11) {
|
|
445
501
|
constructor({
|
|
446
502
|
message = "Request timed out",
|
|
447
503
|
statusCode = 408,
|
|
@@ -449,13 +505,13 @@ var GatewayTimeoutError = class _GatewayTimeoutError extends (_b10 = GatewayErro
|
|
|
449
505
|
generationId
|
|
450
506
|
} = {}) {
|
|
451
507
|
super({ message, statusCode, cause, generationId });
|
|
452
|
-
this[
|
|
508
|
+
this[_a11] = true;
|
|
453
509
|
// used in isInstance
|
|
454
|
-
this.name =
|
|
510
|
+
this.name = name10;
|
|
455
511
|
this.type = "timeout_error";
|
|
456
512
|
}
|
|
457
513
|
static isInstance(error) {
|
|
458
|
-
return GatewayError.hasMarker(error) &&
|
|
514
|
+
return GatewayError.hasMarker(error) && symbol11 in error;
|
|
459
515
|
}
|
|
460
516
|
/**
|
|
461
517
|
* Creates a helpful timeout error message with troubleshooting guidance
|
|
@@ -495,7 +551,7 @@ function isTimeoutError(error) {
|
|
|
495
551
|
return false;
|
|
496
552
|
}
|
|
497
553
|
async function asGatewayError(error, authMethod) {
|
|
498
|
-
var
|
|
554
|
+
var _a12;
|
|
499
555
|
if ((error instanceof Error || typeof DOMException === "function" && error instanceof DOMException) && (error.name === "AbortError" || error.name === "TimeoutError")) {
|
|
500
556
|
throw error;
|
|
501
557
|
}
|
|
@@ -517,7 +573,7 @@ async function asGatewayError(error, authMethod) {
|
|
|
517
573
|
}
|
|
518
574
|
return await createGatewayErrorFromResponse({
|
|
519
575
|
response: extractApiCallResponse(error),
|
|
520
|
-
statusCode: (
|
|
576
|
+
statusCode: (_a12 = error.statusCode) != null ? _a12 : 500,
|
|
521
577
|
defaultMessage: "Gateway request failed",
|
|
522
578
|
cause: error,
|
|
523
579
|
authMethod,
|
|
@@ -534,11 +590,11 @@ async function asGatewayError(error, authMethod) {
|
|
|
534
590
|
}
|
|
535
591
|
|
|
536
592
|
// src/errors/parse-auth-method.ts
|
|
537
|
-
import { z as
|
|
593
|
+
import { z as z5 } from "zod/v4";
|
|
538
594
|
import {
|
|
539
|
-
lazySchema as
|
|
595
|
+
lazySchema as lazySchema5,
|
|
540
596
|
safeValidateTypes as safeValidateTypes2,
|
|
541
|
-
zodSchema as
|
|
597
|
+
zodSchema as zodSchema5
|
|
542
598
|
} from "@ai-sdk/provider-utils";
|
|
543
599
|
var GATEWAY_AUTH_METHOD_HEADER = "ai-gateway-auth-method";
|
|
544
600
|
async function parseAuthMethod(headers) {
|
|
@@ -548,8 +604,8 @@ async function parseAuthMethod(headers) {
|
|
|
548
604
|
});
|
|
549
605
|
return result.success ? result.value : void 0;
|
|
550
606
|
}
|
|
551
|
-
var gatewayAuthMethodSchema =
|
|
552
|
-
() =>
|
|
607
|
+
var gatewayAuthMethodSchema = lazySchema5(
|
|
608
|
+
() => zodSchema5(z5.union([z5.literal("api-key"), z5.literal("oidc")]))
|
|
553
609
|
);
|
|
554
610
|
|
|
555
611
|
// src/gateway-fetch-metadata.ts
|
|
@@ -558,11 +614,11 @@ import {
|
|
|
558
614
|
createJsonResponseHandler,
|
|
559
615
|
getErrorMessage,
|
|
560
616
|
getFromApi,
|
|
561
|
-
lazySchema as
|
|
617
|
+
lazySchema as lazySchema6,
|
|
562
618
|
resolve,
|
|
563
|
-
zodSchema as
|
|
619
|
+
zodSchema as zodSchema6
|
|
564
620
|
} from "@ai-sdk/provider-utils";
|
|
565
|
-
import { z as
|
|
621
|
+
import { z as z6 } from "zod/v4";
|
|
566
622
|
|
|
567
623
|
// src/gateway-model-entry.ts
|
|
568
624
|
var KNOWN_MODEL_TYPES = [
|
|
@@ -589,10 +645,10 @@ var GatewayFetchMetadata = class {
|
|
|
589
645
|
gatewayAvailableModelsResponseSchema
|
|
590
646
|
),
|
|
591
647
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
592
|
-
errorSchema:
|
|
648
|
+
errorSchema: z6.any(),
|
|
593
649
|
errorToMessage: (data) => {
|
|
594
|
-
var
|
|
595
|
-
return (
|
|
650
|
+
var _a12;
|
|
651
|
+
return (_a12 = getErrorMessage(data)) != null ? _a12 : "unknown error";
|
|
596
652
|
}
|
|
597
653
|
}),
|
|
598
654
|
fetch: this.config.fetch
|
|
@@ -612,10 +668,10 @@ var GatewayFetchMetadata = class {
|
|
|
612
668
|
gatewayCreditsResponseSchema
|
|
613
669
|
),
|
|
614
670
|
failedResponseHandler: createJsonErrorResponseHandler({
|
|
615
|
-
errorSchema:
|
|
671
|
+
errorSchema: z6.any(),
|
|
616
672
|
errorToMessage: (data) => {
|
|
617
|
-
var
|
|
618
|
-
return (
|
|
673
|
+
var _a12;
|
|
674
|
+
return (_a12 = getErrorMessage(data)) != null ? _a12 : "unknown error";
|
|
619
675
|
}
|
|
620
676
|
}),
|
|
621
677
|
fetch: this.config.fetch
|
|
@@ -626,19 +682,19 @@ var GatewayFetchMetadata = class {
|
|
|
626
682
|
}
|
|
627
683
|
}
|
|
628
684
|
};
|
|
629
|
-
var gatewayAvailableModelsResponseSchema =
|
|
630
|
-
() =>
|
|
631
|
-
|
|
632
|
-
models:
|
|
633
|
-
|
|
634
|
-
id:
|
|
635
|
-
name:
|
|
636
|
-
description:
|
|
637
|
-
pricing:
|
|
638
|
-
input:
|
|
639
|
-
output:
|
|
640
|
-
input_cache_read:
|
|
641
|
-
input_cache_write:
|
|
685
|
+
var gatewayAvailableModelsResponseSchema = lazySchema6(
|
|
686
|
+
() => zodSchema6(
|
|
687
|
+
z6.object({
|
|
688
|
+
models: z6.array(
|
|
689
|
+
z6.object({
|
|
690
|
+
id: z6.string(),
|
|
691
|
+
name: z6.string(),
|
|
692
|
+
description: z6.string().nullish(),
|
|
693
|
+
pricing: z6.object({
|
|
694
|
+
input: z6.string(),
|
|
695
|
+
output: z6.string(),
|
|
696
|
+
input_cache_read: z6.string().nullish(),
|
|
697
|
+
input_cache_write: z6.string().nullish()
|
|
642
698
|
}).transform(
|
|
643
699
|
({ input, output, input_cache_read, input_cache_write }) => ({
|
|
644
700
|
input,
|
|
@@ -647,12 +703,12 @@ var gatewayAvailableModelsResponseSchema = lazySchema5(
|
|
|
647
703
|
...input_cache_write ? { cacheCreationInputTokens: input_cache_write } : {}
|
|
648
704
|
})
|
|
649
705
|
).nullish(),
|
|
650
|
-
specification:
|
|
651
|
-
specificationVersion:
|
|
652
|
-
provider:
|
|
653
|
-
modelId:
|
|
706
|
+
specification: z6.object({
|
|
707
|
+
specificationVersion: z6.literal("v3"),
|
|
708
|
+
provider: z6.string(),
|
|
709
|
+
modelId: z6.string()
|
|
654
710
|
}),
|
|
655
|
-
modelType:
|
|
711
|
+
modelType: z6.string().nullish()
|
|
656
712
|
})
|
|
657
713
|
).transform(
|
|
658
714
|
(models) => models.filter(
|
|
@@ -662,11 +718,11 @@ var gatewayAvailableModelsResponseSchema = lazySchema5(
|
|
|
662
718
|
})
|
|
663
719
|
)
|
|
664
720
|
);
|
|
665
|
-
var gatewayCreditsResponseSchema =
|
|
666
|
-
() =>
|
|
667
|
-
|
|
668
|
-
balance:
|
|
669
|
-
total_used:
|
|
721
|
+
var gatewayCreditsResponseSchema = lazySchema6(
|
|
722
|
+
() => zodSchema6(
|
|
723
|
+
z6.object({
|
|
724
|
+
balance: z6.string(),
|
|
725
|
+
total_used: z6.string()
|
|
670
726
|
}).transform(({ balance, total_used }) => ({
|
|
671
727
|
balance,
|
|
672
728
|
totalUsed: total_used
|
|
@@ -680,11 +736,11 @@ import {
|
|
|
680
736
|
createJsonResponseHandler as createJsonResponseHandler2,
|
|
681
737
|
getErrorMessage as getErrorMessage2,
|
|
682
738
|
getFromApi as getFromApi2,
|
|
683
|
-
lazySchema as
|
|
739
|
+
lazySchema as lazySchema7,
|
|
684
740
|
resolve as resolve2,
|
|
685
|
-
zodSchema as
|
|
741
|
+
zodSchema as zodSchema7
|
|
686
742
|
} from "@ai-sdk/provider-utils";
|
|
687
|
-
import { z as
|
|
743
|
+
import { z as z7 } from "zod/v4";
|
|
688
744
|
var GatewaySpendReport = class {
|
|
689
745
|
constructor(config) {
|
|
690
746
|
this.config = config;
|
|
@@ -723,10 +779,10 @@ var GatewaySpendReport = class {
|
|
|
723
779
|
gatewaySpendReportResponseSchema
|
|
724
780
|
),
|
|
725
781
|
failedResponseHandler: createJsonErrorResponseHandler2({
|
|
726
|
-
errorSchema:
|
|
782
|
+
errorSchema: z7.any(),
|
|
727
783
|
errorToMessage: (data) => {
|
|
728
|
-
var
|
|
729
|
-
return (
|
|
784
|
+
var _a12;
|
|
785
|
+
return (_a12 = getErrorMessage2(data)) != null ? _a12 : "unknown error";
|
|
730
786
|
}
|
|
731
787
|
}),
|
|
732
788
|
fetch: this.config.fetch
|
|
@@ -737,26 +793,26 @@ var GatewaySpendReport = class {
|
|
|
737
793
|
}
|
|
738
794
|
}
|
|
739
795
|
};
|
|
740
|
-
var gatewaySpendReportResponseSchema =
|
|
741
|
-
() =>
|
|
742
|
-
|
|
743
|
-
results:
|
|
744
|
-
|
|
745
|
-
day:
|
|
746
|
-
hour:
|
|
747
|
-
user:
|
|
748
|
-
model:
|
|
749
|
-
tag:
|
|
750
|
-
provider:
|
|
751
|
-
credential_type:
|
|
752
|
-
total_cost:
|
|
753
|
-
market_cost:
|
|
754
|
-
input_tokens:
|
|
755
|
-
output_tokens:
|
|
756
|
-
cached_input_tokens:
|
|
757
|
-
cache_creation_input_tokens:
|
|
758
|
-
reasoning_tokens:
|
|
759
|
-
request_count:
|
|
796
|
+
var gatewaySpendReportResponseSchema = lazySchema7(
|
|
797
|
+
() => zodSchema7(
|
|
798
|
+
z7.object({
|
|
799
|
+
results: z7.array(
|
|
800
|
+
z7.object({
|
|
801
|
+
day: z7.string().optional(),
|
|
802
|
+
hour: z7.string().optional(),
|
|
803
|
+
user: z7.string().optional(),
|
|
804
|
+
model: z7.string().optional(),
|
|
805
|
+
tag: z7.string().optional(),
|
|
806
|
+
provider: z7.string().optional(),
|
|
807
|
+
credential_type: z7.enum(["byok", "system"]).optional(),
|
|
808
|
+
total_cost: z7.number(),
|
|
809
|
+
market_cost: z7.number().optional(),
|
|
810
|
+
input_tokens: z7.number().optional(),
|
|
811
|
+
output_tokens: z7.number().optional(),
|
|
812
|
+
cached_input_tokens: z7.number().optional(),
|
|
813
|
+
cache_creation_input_tokens: z7.number().optional(),
|
|
814
|
+
reasoning_tokens: z7.number().optional(),
|
|
815
|
+
request_count: z7.number().optional()
|
|
760
816
|
}).transform(
|
|
761
817
|
({
|
|
762
818
|
credential_type,
|
|
@@ -793,11 +849,11 @@ import {
|
|
|
793
849
|
createJsonResponseHandler as createJsonResponseHandler3,
|
|
794
850
|
getErrorMessage as getErrorMessage3,
|
|
795
851
|
getFromApi as getFromApi3,
|
|
796
|
-
lazySchema as
|
|
852
|
+
lazySchema as lazySchema8,
|
|
797
853
|
resolve as resolve3,
|
|
798
|
-
zodSchema as
|
|
854
|
+
zodSchema as zodSchema8
|
|
799
855
|
} from "@ai-sdk/provider-utils";
|
|
800
|
-
import { z as
|
|
856
|
+
import { z as z8 } from "zod/v4";
|
|
801
857
|
var GatewayGenerationInfoFetcher = class {
|
|
802
858
|
constructor(config) {
|
|
803
859
|
this.config = config;
|
|
@@ -812,10 +868,10 @@ var GatewayGenerationInfoFetcher = class {
|
|
|
812
868
|
gatewayGenerationInfoResponseSchema
|
|
813
869
|
),
|
|
814
870
|
failedResponseHandler: createJsonErrorResponseHandler3({
|
|
815
|
-
errorSchema:
|
|
871
|
+
errorSchema: z8.any(),
|
|
816
872
|
errorToMessage: (data) => {
|
|
817
|
-
var
|
|
818
|
-
return (
|
|
873
|
+
var _a12;
|
|
874
|
+
return (_a12 = getErrorMessage3(data)) != null ? _a12 : "unknown error";
|
|
819
875
|
}
|
|
820
876
|
}),
|
|
821
877
|
fetch: this.config.fetch
|
|
@@ -826,28 +882,28 @@ var GatewayGenerationInfoFetcher = class {
|
|
|
826
882
|
}
|
|
827
883
|
}
|
|
828
884
|
};
|
|
829
|
-
var gatewayGenerationInfoResponseSchema =
|
|
830
|
-
() =>
|
|
831
|
-
|
|
832
|
-
data:
|
|
833
|
-
id:
|
|
834
|
-
total_cost:
|
|
835
|
-
upstream_inference_cost:
|
|
836
|
-
usage:
|
|
837
|
-
created_at:
|
|
838
|
-
model:
|
|
839
|
-
is_byok:
|
|
840
|
-
provider_name:
|
|
841
|
-
streamed:
|
|
842
|
-
finish_reason:
|
|
843
|
-
latency:
|
|
844
|
-
generation_time:
|
|
845
|
-
native_tokens_prompt:
|
|
846
|
-
native_tokens_completion:
|
|
847
|
-
native_tokens_reasoning:
|
|
848
|
-
native_tokens_cached:
|
|
849
|
-
native_tokens_cache_creation:
|
|
850
|
-
billable_web_search_calls:
|
|
885
|
+
var gatewayGenerationInfoResponseSchema = lazySchema8(
|
|
886
|
+
() => zodSchema8(
|
|
887
|
+
z8.object({
|
|
888
|
+
data: z8.object({
|
|
889
|
+
id: z8.string(),
|
|
890
|
+
total_cost: z8.number(),
|
|
891
|
+
upstream_inference_cost: z8.number(),
|
|
892
|
+
usage: z8.number(),
|
|
893
|
+
created_at: z8.string(),
|
|
894
|
+
model: z8.string(),
|
|
895
|
+
is_byok: z8.boolean(),
|
|
896
|
+
provider_name: z8.string(),
|
|
897
|
+
streamed: z8.boolean(),
|
|
898
|
+
finish_reason: z8.string(),
|
|
899
|
+
latency: z8.number(),
|
|
900
|
+
generation_time: z8.number(),
|
|
901
|
+
native_tokens_prompt: z8.number(),
|
|
902
|
+
native_tokens_completion: z8.number(),
|
|
903
|
+
native_tokens_reasoning: z8.number(),
|
|
904
|
+
native_tokens_cached: z8.number(),
|
|
905
|
+
native_tokens_cache_creation: z8.number(),
|
|
906
|
+
billable_web_search_calls: z8.number()
|
|
851
907
|
}).transform(
|
|
852
908
|
({
|
|
853
909
|
total_cost,
|
|
@@ -895,7 +951,7 @@ import {
|
|
|
895
951
|
postJsonToApi,
|
|
896
952
|
resolve as resolve4
|
|
897
953
|
} from "@ai-sdk/provider-utils";
|
|
898
|
-
import { z as
|
|
954
|
+
import { z as z9 } from "zod/v4";
|
|
899
955
|
var GatewayLanguageModel = class {
|
|
900
956
|
constructor(modelId, config) {
|
|
901
957
|
this.modelId = modelId;
|
|
@@ -914,7 +970,7 @@ var GatewayLanguageModel = class {
|
|
|
914
970
|
};
|
|
915
971
|
}
|
|
916
972
|
async doGenerate(options) {
|
|
917
|
-
var
|
|
973
|
+
var _a12;
|
|
918
974
|
const { args, warnings } = await this.getArgs(options);
|
|
919
975
|
const { abortSignal } = options;
|
|
920
976
|
const resolvedHeaders = await resolve4(this.config.headers());
|
|
@@ -932,12 +988,12 @@ var GatewayLanguageModel = class {
|
|
|
932
988
|
await resolve4(this.config.o11yHeaders)
|
|
933
989
|
),
|
|
934
990
|
body: args,
|
|
935
|
-
successfulResponseHandler: createJsonResponseHandler4(
|
|
991
|
+
successfulResponseHandler: createJsonResponseHandler4(z9.any()),
|
|
936
992
|
failedResponseHandler: createJsonErrorResponseHandler4({
|
|
937
|
-
errorSchema:
|
|
993
|
+
errorSchema: z9.any(),
|
|
938
994
|
errorToMessage: (data) => {
|
|
939
|
-
var
|
|
940
|
-
return (
|
|
995
|
+
var _a13;
|
|
996
|
+
return (_a13 = getErrorMessage4(data)) != null ? _a13 : "unknown error";
|
|
941
997
|
}
|
|
942
998
|
}),
|
|
943
999
|
...abortSignal && { abortSignal },
|
|
@@ -947,7 +1003,7 @@ var GatewayLanguageModel = class {
|
|
|
947
1003
|
...responseBody,
|
|
948
1004
|
request: { body: args },
|
|
949
1005
|
response: { headers: responseHeaders, body: rawResponse },
|
|
950
|
-
warnings: [...(
|
|
1006
|
+
warnings: [...(_a12 = responseBody.warnings) != null ? _a12 : [], ...warnings]
|
|
951
1007
|
};
|
|
952
1008
|
} catch (error) {
|
|
953
1009
|
throw await asGatewayError(error, await parseAuthMethod(resolvedHeaders));
|
|
@@ -967,12 +1023,12 @@ var GatewayLanguageModel = class {
|
|
|
967
1023
|
await resolve4(this.config.o11yHeaders)
|
|
968
1024
|
),
|
|
969
1025
|
body: args,
|
|
970
|
-
successfulResponseHandler: createEventSourceResponseHandler(
|
|
1026
|
+
successfulResponseHandler: createEventSourceResponseHandler(z9.any()),
|
|
971
1027
|
failedResponseHandler: createJsonErrorResponseHandler4({
|
|
972
|
-
errorSchema:
|
|
1028
|
+
errorSchema: z9.any(),
|
|
973
1029
|
errorToMessage: (data) => {
|
|
974
|
-
var
|
|
975
|
-
return (
|
|
1030
|
+
var _a12;
|
|
1031
|
+
return (_a12 = getErrorMessage4(data)) != null ? _a12 : "unknown error";
|
|
976
1032
|
}
|
|
977
1033
|
}),
|
|
978
1034
|
...abortSignal && { abortSignal },
|
|
@@ -1055,12 +1111,12 @@ import {
|
|
|
1055
1111
|
createJsonErrorResponseHandler as createJsonErrorResponseHandler5,
|
|
1056
1112
|
createJsonResponseHandler as createJsonResponseHandler5,
|
|
1057
1113
|
getErrorMessage as getErrorMessage5,
|
|
1058
|
-
lazySchema as
|
|
1114
|
+
lazySchema as lazySchema9,
|
|
1059
1115
|
postJsonToApi as postJsonToApi2,
|
|
1060
1116
|
resolve as resolve5,
|
|
1061
|
-
zodSchema as
|
|
1117
|
+
zodSchema as zodSchema9
|
|
1062
1118
|
} from "@ai-sdk/provider-utils";
|
|
1063
|
-
import { z as
|
|
1119
|
+
import { z as z10 } from "zod/v4";
|
|
1064
1120
|
var GatewayEmbeddingModel = class {
|
|
1065
1121
|
constructor(modelId, config) {
|
|
1066
1122
|
this.modelId = modelId;
|
|
@@ -1078,7 +1134,7 @@ var GatewayEmbeddingModel = class {
|
|
|
1078
1134
|
abortSignal,
|
|
1079
1135
|
providerOptions
|
|
1080
1136
|
}) {
|
|
1081
|
-
var
|
|
1137
|
+
var _a12, _b12;
|
|
1082
1138
|
const resolvedHeaders = await resolve5(this.config.headers());
|
|
1083
1139
|
try {
|
|
1084
1140
|
const {
|
|
@@ -1101,10 +1157,10 @@ var GatewayEmbeddingModel = class {
|
|
|
1101
1157
|
gatewayEmbeddingResponseSchema
|
|
1102
1158
|
),
|
|
1103
1159
|
failedResponseHandler: createJsonErrorResponseHandler5({
|
|
1104
|
-
errorSchema:
|
|
1160
|
+
errorSchema: z10.any(),
|
|
1105
1161
|
errorToMessage: (data) => {
|
|
1106
|
-
var
|
|
1107
|
-
return (
|
|
1162
|
+
var _a13;
|
|
1163
|
+
return (_a13 = getErrorMessage5(data)) != null ? _a13 : "unknown error";
|
|
1108
1164
|
}
|
|
1109
1165
|
}),
|
|
1110
1166
|
...abortSignal && { abortSignal },
|
|
@@ -1112,10 +1168,10 @@ var GatewayEmbeddingModel = class {
|
|
|
1112
1168
|
});
|
|
1113
1169
|
return {
|
|
1114
1170
|
embeddings: responseBody.embeddings,
|
|
1115
|
-
usage: (
|
|
1171
|
+
usage: (_a12 = responseBody.usage) != null ? _a12 : void 0,
|
|
1116
1172
|
providerMetadata: responseBody.providerMetadata,
|
|
1117
1173
|
response: { headers: responseHeaders, body: rawValue },
|
|
1118
|
-
warnings: (
|
|
1174
|
+
warnings: (_b12 = responseBody.warnings) != null ? _b12 : []
|
|
1119
1175
|
};
|
|
1120
1176
|
} catch (error) {
|
|
1121
1177
|
throw await asGatewayError(error, await parseAuthMethod(resolvedHeaders));
|
|
@@ -1131,37 +1187,37 @@ var GatewayEmbeddingModel = class {
|
|
|
1131
1187
|
};
|
|
1132
1188
|
}
|
|
1133
1189
|
};
|
|
1134
|
-
var gatewayEmbeddingWarningSchema = () =>
|
|
1135
|
-
|
|
1136
|
-
type:
|
|
1137
|
-
feature:
|
|
1138
|
-
details:
|
|
1190
|
+
var gatewayEmbeddingWarningSchema = () => z10.discriminatedUnion("type", [
|
|
1191
|
+
z10.object({
|
|
1192
|
+
type: z10.literal("unsupported"),
|
|
1193
|
+
feature: z10.string(),
|
|
1194
|
+
details: z10.string().optional()
|
|
1139
1195
|
}),
|
|
1140
|
-
|
|
1141
|
-
type:
|
|
1142
|
-
feature:
|
|
1143
|
-
details:
|
|
1196
|
+
z10.object({
|
|
1197
|
+
type: z10.literal("compatibility"),
|
|
1198
|
+
feature: z10.string(),
|
|
1199
|
+
details: z10.string().optional()
|
|
1144
1200
|
}),
|
|
1145
|
-
|
|
1146
|
-
type:
|
|
1147
|
-
message:
|
|
1201
|
+
z10.object({
|
|
1202
|
+
type: z10.literal("other"),
|
|
1203
|
+
message: z10.string()
|
|
1148
1204
|
})
|
|
1149
1205
|
]);
|
|
1150
|
-
var gatewayEmbeddingResponseSchema =
|
|
1151
|
-
() =>
|
|
1152
|
-
|
|
1153
|
-
embeddings:
|
|
1154
|
-
usage:
|
|
1155
|
-
warnings:
|
|
1156
|
-
providerMetadata:
|
|
1206
|
+
var gatewayEmbeddingResponseSchema = lazySchema9(
|
|
1207
|
+
() => zodSchema9(
|
|
1208
|
+
z10.object({
|
|
1209
|
+
embeddings: z10.array(z10.array(z10.number())),
|
|
1210
|
+
usage: z10.object({ tokens: z10.number() }).nullish(),
|
|
1211
|
+
warnings: z10.array(gatewayEmbeddingWarningSchema()).optional(),
|
|
1212
|
+
providerMetadata: z10.record(z10.string(), z10.record(z10.string(), z10.unknown())).optional()
|
|
1157
1213
|
})
|
|
1158
1214
|
)
|
|
1159
1215
|
);
|
|
1160
1216
|
|
|
1161
1217
|
// src/gateway-image-model.ts
|
|
1162
1218
|
import {
|
|
1163
|
-
lazySchema as
|
|
1164
|
-
zodSchema as
|
|
1219
|
+
lazySchema as lazySchema10,
|
|
1220
|
+
zodSchema as zodSchema10,
|
|
1165
1221
|
combineHeaders as combineHeaders3,
|
|
1166
1222
|
convertUint8ArrayToBase64,
|
|
1167
1223
|
createJsonErrorResponseHandler as createJsonErrorResponseHandler6,
|
|
@@ -1170,7 +1226,7 @@ import {
|
|
|
1170
1226
|
postJsonToApi as postJsonToApi3,
|
|
1171
1227
|
resolve as resolve6
|
|
1172
1228
|
} from "@ai-sdk/provider-utils";
|
|
1173
|
-
import { z as
|
|
1229
|
+
import { z as z11 } from "zod/v4";
|
|
1174
1230
|
|
|
1175
1231
|
// src/map-gateway-warnings.ts
|
|
1176
1232
|
function mapGatewayWarnings(warnings) {
|
|
@@ -1203,7 +1259,7 @@ var GatewayImageModel = class {
|
|
|
1203
1259
|
headers,
|
|
1204
1260
|
abortSignal
|
|
1205
1261
|
}) {
|
|
1206
|
-
var
|
|
1262
|
+
var _a12, _b12, _c;
|
|
1207
1263
|
const resolvedHeaders = await resolve6(this.config.headers());
|
|
1208
1264
|
try {
|
|
1209
1265
|
const {
|
|
@@ -1234,10 +1290,10 @@ var GatewayImageModel = class {
|
|
|
1234
1290
|
gatewayImageResponseSchema
|
|
1235
1291
|
),
|
|
1236
1292
|
failedResponseHandler: createJsonErrorResponseHandler6({
|
|
1237
|
-
errorSchema:
|
|
1293
|
+
errorSchema: z11.any(),
|
|
1238
1294
|
errorToMessage: (data) => {
|
|
1239
|
-
var
|
|
1240
|
-
return (
|
|
1295
|
+
var _a13;
|
|
1296
|
+
return (_a13 = getErrorMessage6(data)) != null ? _a13 : "unknown error";
|
|
1241
1297
|
}
|
|
1242
1298
|
}),
|
|
1243
1299
|
...abortSignal && { abortSignal },
|
|
@@ -1258,8 +1314,8 @@ var GatewayImageModel = class {
|
|
|
1258
1314
|
},
|
|
1259
1315
|
...responseBody.usage != null && {
|
|
1260
1316
|
usage: {
|
|
1261
|
-
inputTokens: (
|
|
1262
|
-
outputTokens: (
|
|
1317
|
+
inputTokens: (_a12 = responseBody.usage.inputTokens) != null ? _a12 : void 0,
|
|
1318
|
+
outputTokens: (_b12 = responseBody.usage.outputTokens) != null ? _b12 : void 0,
|
|
1263
1319
|
totalTokens: (_c = responseBody.usage.totalTokens) != null ? _c : void 0
|
|
1264
1320
|
}
|
|
1265
1321
|
}
|
|
@@ -1287,43 +1343,43 @@ function maybeEncodeImageFile(file) {
|
|
|
1287
1343
|
}
|
|
1288
1344
|
return file;
|
|
1289
1345
|
}
|
|
1290
|
-
var providerMetadataEntrySchema = () =>
|
|
1291
|
-
images:
|
|
1292
|
-
}).catchall(
|
|
1293
|
-
var gatewayImageWarningSchema = () =>
|
|
1294
|
-
|
|
1295
|
-
type:
|
|
1296
|
-
feature:
|
|
1297
|
-
details:
|
|
1346
|
+
var providerMetadataEntrySchema = () => z11.object({
|
|
1347
|
+
images: z11.array(z11.unknown()).optional()
|
|
1348
|
+
}).catchall(z11.unknown());
|
|
1349
|
+
var gatewayImageWarningSchema = () => z11.discriminatedUnion("type", [
|
|
1350
|
+
z11.object({
|
|
1351
|
+
type: z11.literal("unsupported"),
|
|
1352
|
+
feature: z11.string(),
|
|
1353
|
+
details: z11.string().optional()
|
|
1298
1354
|
}),
|
|
1299
|
-
|
|
1300
|
-
type:
|
|
1301
|
-
feature:
|
|
1302
|
-
details:
|
|
1355
|
+
z11.object({
|
|
1356
|
+
type: z11.literal("compatibility"),
|
|
1357
|
+
feature: z11.string(),
|
|
1358
|
+
details: z11.string().optional()
|
|
1303
1359
|
}),
|
|
1304
|
-
|
|
1305
|
-
type:
|
|
1306
|
-
setting:
|
|
1307
|
-
message:
|
|
1360
|
+
z11.object({
|
|
1361
|
+
type: z11.literal("deprecated"),
|
|
1362
|
+
setting: z11.string(),
|
|
1363
|
+
message: z11.string()
|
|
1308
1364
|
}),
|
|
1309
|
-
|
|
1310
|
-
type:
|
|
1311
|
-
message:
|
|
1365
|
+
z11.object({
|
|
1366
|
+
type: z11.literal("other"),
|
|
1367
|
+
message: z11.string()
|
|
1312
1368
|
})
|
|
1313
1369
|
]);
|
|
1314
|
-
var gatewayImageUsageSchema = () =>
|
|
1315
|
-
inputTokens:
|
|
1316
|
-
outputTokens:
|
|
1317
|
-
totalTokens:
|
|
1370
|
+
var gatewayImageUsageSchema = () => z11.object({
|
|
1371
|
+
inputTokens: z11.number().nullish(),
|
|
1372
|
+
outputTokens: z11.number().nullish(),
|
|
1373
|
+
totalTokens: z11.number().nullish()
|
|
1318
1374
|
});
|
|
1319
|
-
var gatewayImageResponseSchema =
|
|
1320
|
-
() =>
|
|
1321
|
-
|
|
1322
|
-
images:
|
|
1375
|
+
var gatewayImageResponseSchema = lazySchema10(
|
|
1376
|
+
() => zodSchema10(
|
|
1377
|
+
z11.object({
|
|
1378
|
+
images: z11.array(z11.string()),
|
|
1323
1379
|
// Always base64 strings over the wire
|
|
1324
|
-
isRetryable:
|
|
1325
|
-
warnings:
|
|
1326
|
-
providerMetadata:
|
|
1380
|
+
isRetryable: z11.boolean().optional(),
|
|
1381
|
+
warnings: z11.array(gatewayImageWarningSchema()).optional(),
|
|
1382
|
+
providerMetadata: z11.record(z11.string(), providerMetadataEntrySchema()).optional(),
|
|
1327
1383
|
usage: gatewayImageUsageSchema().optional()
|
|
1328
1384
|
})
|
|
1329
1385
|
)
|
|
@@ -1334,8 +1390,8 @@ import {
|
|
|
1334
1390
|
APICallError as APICallError2
|
|
1335
1391
|
} from "@ai-sdk/provider";
|
|
1336
1392
|
import {
|
|
1337
|
-
lazySchema as
|
|
1338
|
-
zodSchema as
|
|
1393
|
+
lazySchema as lazySchema11,
|
|
1394
|
+
zodSchema as zodSchema11,
|
|
1339
1395
|
combineHeaders as combineHeaders4,
|
|
1340
1396
|
convertUint8ArrayToBase64 as convertUint8ArrayToBase642,
|
|
1341
1397
|
createJsonErrorResponseHandler as createJsonErrorResponseHandler7,
|
|
@@ -1344,7 +1400,7 @@ import {
|
|
|
1344
1400
|
postJsonToApi as postJsonToApi4,
|
|
1345
1401
|
resolve as resolve7
|
|
1346
1402
|
} from "@ai-sdk/provider-utils";
|
|
1347
|
-
import { z as
|
|
1403
|
+
import { z as z12 } from "zod/v4";
|
|
1348
1404
|
var GatewayVideoModel = class {
|
|
1349
1405
|
constructor(modelId, config) {
|
|
1350
1406
|
this.modelId = modelId;
|
|
@@ -1471,10 +1527,10 @@ var GatewayVideoModel = class {
|
|
|
1471
1527
|
};
|
|
1472
1528
|
},
|
|
1473
1529
|
failedResponseHandler: createJsonErrorResponseHandler7({
|
|
1474
|
-
errorSchema:
|
|
1530
|
+
errorSchema: z12.any(),
|
|
1475
1531
|
errorToMessage: (data) => {
|
|
1476
|
-
var
|
|
1477
|
-
return (
|
|
1532
|
+
var _a12;
|
|
1533
|
+
return (_a12 = getErrorMessage7(data)) != null ? _a12 : "unknown error";
|
|
1478
1534
|
}
|
|
1479
1535
|
}),
|
|
1480
1536
|
...abortSignal && { abortSignal },
|
|
@@ -1513,57 +1569,57 @@ function maybeEncodeVideoFile(file) {
|
|
|
1513
1569
|
}
|
|
1514
1570
|
return file;
|
|
1515
1571
|
}
|
|
1516
|
-
var providerMetadataEntrySchema2 = () =>
|
|
1517
|
-
videos:
|
|
1518
|
-
}).catchall(
|
|
1519
|
-
var gatewayVideoDataSchema = () =>
|
|
1520
|
-
|
|
1521
|
-
type:
|
|
1522
|
-
url:
|
|
1523
|
-
mediaType:
|
|
1572
|
+
var providerMetadataEntrySchema2 = () => z12.object({
|
|
1573
|
+
videos: z12.array(z12.unknown()).optional()
|
|
1574
|
+
}).catchall(z12.unknown());
|
|
1575
|
+
var gatewayVideoDataSchema = () => z12.union([
|
|
1576
|
+
z12.object({
|
|
1577
|
+
type: z12.literal("url"),
|
|
1578
|
+
url: z12.string(),
|
|
1579
|
+
mediaType: z12.string()
|
|
1524
1580
|
}),
|
|
1525
|
-
|
|
1526
|
-
type:
|
|
1527
|
-
data:
|
|
1528
|
-
mediaType:
|
|
1581
|
+
z12.object({
|
|
1582
|
+
type: z12.literal("base64"),
|
|
1583
|
+
data: z12.string(),
|
|
1584
|
+
mediaType: z12.string()
|
|
1529
1585
|
})
|
|
1530
1586
|
]);
|
|
1531
|
-
var gatewayVideoWarningSchema = () =>
|
|
1532
|
-
|
|
1533
|
-
type:
|
|
1534
|
-
feature:
|
|
1535
|
-
details:
|
|
1587
|
+
var gatewayVideoWarningSchema = () => z12.discriminatedUnion("type", [
|
|
1588
|
+
z12.object({
|
|
1589
|
+
type: z12.literal("unsupported"),
|
|
1590
|
+
feature: z12.string(),
|
|
1591
|
+
details: z12.string().optional()
|
|
1536
1592
|
}),
|
|
1537
|
-
|
|
1538
|
-
type:
|
|
1539
|
-
feature:
|
|
1540
|
-
details:
|
|
1593
|
+
z12.object({
|
|
1594
|
+
type: z12.literal("compatibility"),
|
|
1595
|
+
feature: z12.string(),
|
|
1596
|
+
details: z12.string().optional()
|
|
1541
1597
|
}),
|
|
1542
|
-
|
|
1543
|
-
type:
|
|
1544
|
-
setting:
|
|
1545
|
-
message:
|
|
1598
|
+
z12.object({
|
|
1599
|
+
type: z12.literal("deprecated"),
|
|
1600
|
+
setting: z12.string(),
|
|
1601
|
+
message: z12.string()
|
|
1546
1602
|
}),
|
|
1547
|
-
|
|
1548
|
-
type:
|
|
1549
|
-
message:
|
|
1603
|
+
z12.object({
|
|
1604
|
+
type: z12.literal("other"),
|
|
1605
|
+
message: z12.string()
|
|
1550
1606
|
})
|
|
1551
1607
|
]);
|
|
1552
|
-
var gatewayVideoEventSchema =
|
|
1553
|
-
() =>
|
|
1554
|
-
|
|
1555
|
-
|
|
1556
|
-
type:
|
|
1557
|
-
videos:
|
|
1558
|
-
warnings:
|
|
1559
|
-
providerMetadata:
|
|
1608
|
+
var gatewayVideoEventSchema = lazySchema11(
|
|
1609
|
+
() => zodSchema11(
|
|
1610
|
+
z12.discriminatedUnion("type", [
|
|
1611
|
+
z12.object({
|
|
1612
|
+
type: z12.literal("result"),
|
|
1613
|
+
videos: z12.array(gatewayVideoDataSchema()),
|
|
1614
|
+
warnings: z12.array(gatewayVideoWarningSchema()).optional(),
|
|
1615
|
+
providerMetadata: z12.record(z12.string(), providerMetadataEntrySchema2()).optional()
|
|
1560
1616
|
}),
|
|
1561
|
-
|
|
1562
|
-
type:
|
|
1563
|
-
message:
|
|
1564
|
-
errorType:
|
|
1565
|
-
statusCode:
|
|
1566
|
-
param:
|
|
1617
|
+
z12.object({
|
|
1618
|
+
type: z12.literal("error"),
|
|
1619
|
+
message: z12.string(),
|
|
1620
|
+
errorType: z12.string(),
|
|
1621
|
+
statusCode: z12.number(),
|
|
1622
|
+
param: z12.unknown().nullable()
|
|
1567
1623
|
})
|
|
1568
1624
|
])
|
|
1569
1625
|
)
|
|
@@ -1575,12 +1631,12 @@ import {
|
|
|
1575
1631
|
createJsonErrorResponseHandler as createJsonErrorResponseHandler8,
|
|
1576
1632
|
createJsonResponseHandler as createJsonResponseHandler7,
|
|
1577
1633
|
getErrorMessage as getErrorMessage8,
|
|
1578
|
-
lazySchema as
|
|
1634
|
+
lazySchema as lazySchema12,
|
|
1579
1635
|
postJsonToApi as postJsonToApi5,
|
|
1580
1636
|
resolve as resolve8,
|
|
1581
|
-
zodSchema as
|
|
1637
|
+
zodSchema as zodSchema12
|
|
1582
1638
|
} from "@ai-sdk/provider-utils";
|
|
1583
|
-
import { z as
|
|
1639
|
+
import { z as z13 } from "zod/v4";
|
|
1584
1640
|
var GatewayRerankingModel = class {
|
|
1585
1641
|
constructor(modelId, config) {
|
|
1586
1642
|
this.modelId = modelId;
|
|
@@ -1598,7 +1654,7 @@ var GatewayRerankingModel = class {
|
|
|
1598
1654
|
abortSignal,
|
|
1599
1655
|
providerOptions
|
|
1600
1656
|
}) {
|
|
1601
|
-
var
|
|
1657
|
+
var _a12;
|
|
1602
1658
|
const resolvedHeaders = await resolve8(this.config.headers());
|
|
1603
1659
|
try {
|
|
1604
1660
|
const {
|
|
@@ -1623,10 +1679,10 @@ var GatewayRerankingModel = class {
|
|
|
1623
1679
|
gatewayRerankingResponseSchema
|
|
1624
1680
|
),
|
|
1625
1681
|
failedResponseHandler: createJsonErrorResponseHandler8({
|
|
1626
|
-
errorSchema:
|
|
1682
|
+
errorSchema: z13.any(),
|
|
1627
1683
|
errorToMessage: (data) => {
|
|
1628
|
-
var
|
|
1629
|
-
return (
|
|
1684
|
+
var _a13;
|
|
1685
|
+
return (_a13 = getErrorMessage8(data)) != null ? _a13 : "unknown error";
|
|
1630
1686
|
}
|
|
1631
1687
|
}),
|
|
1632
1688
|
...abortSignal && { abortSignal },
|
|
@@ -1636,7 +1692,7 @@ var GatewayRerankingModel = class {
|
|
|
1636
1692
|
ranking: responseBody.ranking,
|
|
1637
1693
|
providerMetadata: responseBody.providerMetadata,
|
|
1638
1694
|
response: { headers: responseHeaders, body: rawValue },
|
|
1639
|
-
warnings: (
|
|
1695
|
+
warnings: (_a12 = responseBody.warnings) != null ? _a12 : []
|
|
1640
1696
|
};
|
|
1641
1697
|
} catch (error) {
|
|
1642
1698
|
throw await asGatewayError(error, await parseAuthMethod(resolvedHeaders));
|
|
@@ -1652,41 +1708,41 @@ var GatewayRerankingModel = class {
|
|
|
1652
1708
|
};
|
|
1653
1709
|
}
|
|
1654
1710
|
};
|
|
1655
|
-
var gatewayRerankingWarningSchema = () =>
|
|
1656
|
-
|
|
1657
|
-
type:
|
|
1658
|
-
feature:
|
|
1659
|
-
details:
|
|
1711
|
+
var gatewayRerankingWarningSchema = () => z13.discriminatedUnion("type", [
|
|
1712
|
+
z13.object({
|
|
1713
|
+
type: z13.literal("unsupported"),
|
|
1714
|
+
feature: z13.string(),
|
|
1715
|
+
details: z13.string().optional()
|
|
1660
1716
|
}),
|
|
1661
|
-
|
|
1662
|
-
type:
|
|
1663
|
-
feature:
|
|
1664
|
-
details:
|
|
1717
|
+
z13.object({
|
|
1718
|
+
type: z13.literal("compatibility"),
|
|
1719
|
+
feature: z13.string(),
|
|
1720
|
+
details: z13.string().optional()
|
|
1665
1721
|
}),
|
|
1666
|
-
|
|
1667
|
-
type:
|
|
1668
|
-
message:
|
|
1722
|
+
z13.object({
|
|
1723
|
+
type: z13.literal("other"),
|
|
1724
|
+
message: z13.string()
|
|
1669
1725
|
})
|
|
1670
1726
|
]);
|
|
1671
|
-
var gatewayRerankingResponseSchema =
|
|
1672
|
-
() =>
|
|
1673
|
-
|
|
1674
|
-
ranking:
|
|
1675
|
-
|
|
1676
|
-
index:
|
|
1677
|
-
relevanceScore:
|
|
1727
|
+
var gatewayRerankingResponseSchema = lazySchema12(
|
|
1728
|
+
() => zodSchema12(
|
|
1729
|
+
z13.object({
|
|
1730
|
+
ranking: z13.array(
|
|
1731
|
+
z13.object({
|
|
1732
|
+
index: z13.number(),
|
|
1733
|
+
relevanceScore: z13.number()
|
|
1678
1734
|
})
|
|
1679
1735
|
),
|
|
1680
|
-
warnings:
|
|
1681
|
-
providerMetadata:
|
|
1736
|
+
warnings: z13.array(gatewayRerankingWarningSchema()).optional(),
|
|
1737
|
+
providerMetadata: z13.record(z13.string(), z13.record(z13.string(), z13.unknown())).optional()
|
|
1682
1738
|
})
|
|
1683
1739
|
)
|
|
1684
1740
|
);
|
|
1685
1741
|
|
|
1686
1742
|
// src/gateway-speech-model.ts
|
|
1687
1743
|
import {
|
|
1688
|
-
lazySchema as
|
|
1689
|
-
zodSchema as
|
|
1744
|
+
lazySchema as lazySchema13,
|
|
1745
|
+
zodSchema as zodSchema13,
|
|
1690
1746
|
combineHeaders as combineHeaders6,
|
|
1691
1747
|
createJsonErrorResponseHandler as createJsonErrorResponseHandler9,
|
|
1692
1748
|
createJsonResponseHandler as createJsonResponseHandler8,
|
|
@@ -1694,7 +1750,7 @@ import {
|
|
|
1694
1750
|
postJsonToApi as postJsonToApi6,
|
|
1695
1751
|
resolve as resolve9
|
|
1696
1752
|
} from "@ai-sdk/provider-utils";
|
|
1697
|
-
import { z as
|
|
1753
|
+
import { z as z14 } from "zod/v4";
|
|
1698
1754
|
var GatewaySpeechModel = class {
|
|
1699
1755
|
constructor(modelId, config) {
|
|
1700
1756
|
this.modelId = modelId;
|
|
@@ -1742,10 +1798,10 @@ var GatewaySpeechModel = class {
|
|
|
1742
1798
|
gatewaySpeechResponseSchema
|
|
1743
1799
|
),
|
|
1744
1800
|
failedResponseHandler: createJsonErrorResponseHandler9({
|
|
1745
|
-
errorSchema:
|
|
1801
|
+
errorSchema: z14.any(),
|
|
1746
1802
|
errorToMessage: (data) => {
|
|
1747
|
-
var
|
|
1748
|
-
return (
|
|
1803
|
+
var _a12;
|
|
1804
|
+
return (_a12 = getErrorMessage9(data)) != null ? _a12 : "unknown error";
|
|
1749
1805
|
}
|
|
1750
1806
|
}),
|
|
1751
1807
|
...abortSignal && { abortSignal },
|
|
@@ -1779,42 +1835,42 @@ var GatewaySpeechModel = class {
|
|
|
1779
1835
|
};
|
|
1780
1836
|
}
|
|
1781
1837
|
};
|
|
1782
|
-
var providerMetadataEntrySchema3 = () =>
|
|
1783
|
-
var gatewaySpeechWarningSchema = () =>
|
|
1784
|
-
|
|
1785
|
-
type:
|
|
1786
|
-
feature:
|
|
1787
|
-
details:
|
|
1838
|
+
var providerMetadataEntrySchema3 = () => z14.object({}).catchall(z14.unknown());
|
|
1839
|
+
var gatewaySpeechWarningSchema = () => z14.discriminatedUnion("type", [
|
|
1840
|
+
z14.object({
|
|
1841
|
+
type: z14.literal("unsupported"),
|
|
1842
|
+
feature: z14.string(),
|
|
1843
|
+
details: z14.string().optional()
|
|
1788
1844
|
}),
|
|
1789
|
-
|
|
1790
|
-
type:
|
|
1791
|
-
feature:
|
|
1792
|
-
details:
|
|
1845
|
+
z14.object({
|
|
1846
|
+
type: z14.literal("compatibility"),
|
|
1847
|
+
feature: z14.string(),
|
|
1848
|
+
details: z14.string().optional()
|
|
1793
1849
|
}),
|
|
1794
|
-
|
|
1795
|
-
type:
|
|
1796
|
-
setting:
|
|
1797
|
-
message:
|
|
1850
|
+
z14.object({
|
|
1851
|
+
type: z14.literal("deprecated"),
|
|
1852
|
+
setting: z14.string(),
|
|
1853
|
+
message: z14.string()
|
|
1798
1854
|
}),
|
|
1799
|
-
|
|
1800
|
-
type:
|
|
1801
|
-
message:
|
|
1855
|
+
z14.object({
|
|
1856
|
+
type: z14.literal("other"),
|
|
1857
|
+
message: z14.string()
|
|
1802
1858
|
})
|
|
1803
1859
|
]);
|
|
1804
|
-
var gatewaySpeechResponseSchema =
|
|
1805
|
-
() =>
|
|
1806
|
-
|
|
1807
|
-
audio:
|
|
1808
|
-
warnings:
|
|
1809
|
-
providerMetadata:
|
|
1860
|
+
var gatewaySpeechResponseSchema = lazySchema13(
|
|
1861
|
+
() => zodSchema13(
|
|
1862
|
+
z14.object({
|
|
1863
|
+
audio: z14.string(),
|
|
1864
|
+
warnings: z14.array(gatewaySpeechWarningSchema()).optional(),
|
|
1865
|
+
providerMetadata: z14.record(z14.string(), providerMetadataEntrySchema3()).optional()
|
|
1810
1866
|
})
|
|
1811
1867
|
)
|
|
1812
1868
|
);
|
|
1813
1869
|
|
|
1814
1870
|
// src/gateway-transcription-model.ts
|
|
1815
1871
|
import {
|
|
1816
|
-
lazySchema as
|
|
1817
|
-
zodSchema as
|
|
1872
|
+
lazySchema as lazySchema14,
|
|
1873
|
+
zodSchema as zodSchema14,
|
|
1818
1874
|
combineHeaders as combineHeaders7,
|
|
1819
1875
|
convertUint8ArrayToBase64 as convertUint8ArrayToBase643,
|
|
1820
1876
|
createJsonErrorResponseHandler as createJsonErrorResponseHandler10,
|
|
@@ -1823,7 +1879,7 @@ import {
|
|
|
1823
1879
|
postJsonToApi as postJsonToApi7,
|
|
1824
1880
|
resolve as resolve10
|
|
1825
1881
|
} from "@ai-sdk/provider-utils";
|
|
1826
|
-
import { z as
|
|
1882
|
+
import { z as z15 } from "zod/v4";
|
|
1827
1883
|
var GatewayTranscriptionModel = class {
|
|
1828
1884
|
constructor(modelId, config) {
|
|
1829
1885
|
this.modelId = modelId;
|
|
@@ -1840,7 +1896,7 @@ var GatewayTranscriptionModel = class {
|
|
|
1840
1896
|
headers,
|
|
1841
1897
|
abortSignal
|
|
1842
1898
|
}) {
|
|
1843
|
-
var
|
|
1899
|
+
var _a12, _b12, _c;
|
|
1844
1900
|
const resolvedHeaders = await resolve10(this.config.headers());
|
|
1845
1901
|
try {
|
|
1846
1902
|
const {
|
|
@@ -1864,10 +1920,10 @@ var GatewayTranscriptionModel = class {
|
|
|
1864
1920
|
gatewayTranscriptionResponseSchema
|
|
1865
1921
|
),
|
|
1866
1922
|
failedResponseHandler: createJsonErrorResponseHandler10({
|
|
1867
|
-
errorSchema:
|
|
1923
|
+
errorSchema: z15.any(),
|
|
1868
1924
|
errorToMessage: (data) => {
|
|
1869
|
-
var
|
|
1870
|
-
return (
|
|
1925
|
+
var _a13;
|
|
1926
|
+
return (_a13 = getErrorMessage10(data)) != null ? _a13 : "unknown error";
|
|
1871
1927
|
}
|
|
1872
1928
|
}),
|
|
1873
1929
|
...abortSignal && { abortSignal },
|
|
@@ -1875,8 +1931,8 @@ var GatewayTranscriptionModel = class {
|
|
|
1875
1931
|
});
|
|
1876
1932
|
return {
|
|
1877
1933
|
text: responseBody.text,
|
|
1878
|
-
segments: (
|
|
1879
|
-
language: (
|
|
1934
|
+
segments: (_a12 = responseBody.segments) != null ? _a12 : [],
|
|
1935
|
+
language: (_b12 = responseBody.language) != null ? _b12 : void 0,
|
|
1880
1936
|
durationInSeconds: (_c = responseBody.durationInSeconds) != null ? _c : void 0,
|
|
1881
1937
|
warnings: mapGatewayWarnings(responseBody.warnings),
|
|
1882
1938
|
providerMetadata: responseBody.providerMetadata,
|
|
@@ -1904,43 +1960,43 @@ var GatewayTranscriptionModel = class {
|
|
|
1904
1960
|
};
|
|
1905
1961
|
}
|
|
1906
1962
|
};
|
|
1907
|
-
var providerMetadataEntrySchema4 = () =>
|
|
1908
|
-
var gatewayTranscriptionWarningSchema = () =>
|
|
1909
|
-
|
|
1910
|
-
type:
|
|
1911
|
-
feature:
|
|
1912
|
-
details:
|
|
1963
|
+
var providerMetadataEntrySchema4 = () => z15.object({}).catchall(z15.unknown());
|
|
1964
|
+
var gatewayTranscriptionWarningSchema = () => z15.discriminatedUnion("type", [
|
|
1965
|
+
z15.object({
|
|
1966
|
+
type: z15.literal("unsupported"),
|
|
1967
|
+
feature: z15.string(),
|
|
1968
|
+
details: z15.string().optional()
|
|
1913
1969
|
}),
|
|
1914
|
-
|
|
1915
|
-
type:
|
|
1916
|
-
feature:
|
|
1917
|
-
details:
|
|
1970
|
+
z15.object({
|
|
1971
|
+
type: z15.literal("compatibility"),
|
|
1972
|
+
feature: z15.string(),
|
|
1973
|
+
details: z15.string().optional()
|
|
1918
1974
|
}),
|
|
1919
|
-
|
|
1920
|
-
type:
|
|
1921
|
-
setting:
|
|
1922
|
-
message:
|
|
1975
|
+
z15.object({
|
|
1976
|
+
type: z15.literal("deprecated"),
|
|
1977
|
+
setting: z15.string(),
|
|
1978
|
+
message: z15.string()
|
|
1923
1979
|
}),
|
|
1924
|
-
|
|
1925
|
-
type:
|
|
1926
|
-
message:
|
|
1980
|
+
z15.object({
|
|
1981
|
+
type: z15.literal("other"),
|
|
1982
|
+
message: z15.string()
|
|
1927
1983
|
})
|
|
1928
1984
|
]);
|
|
1929
|
-
var gatewayTranscriptionResponseSchema =
|
|
1930
|
-
() =>
|
|
1931
|
-
|
|
1932
|
-
text:
|
|
1933
|
-
segments:
|
|
1934
|
-
|
|
1935
|
-
text:
|
|
1936
|
-
startSecond:
|
|
1937
|
-
endSecond:
|
|
1985
|
+
var gatewayTranscriptionResponseSchema = lazySchema14(
|
|
1986
|
+
() => zodSchema14(
|
|
1987
|
+
z15.object({
|
|
1988
|
+
text: z15.string(),
|
|
1989
|
+
segments: z15.array(
|
|
1990
|
+
z15.object({
|
|
1991
|
+
text: z15.string(),
|
|
1992
|
+
startSecond: z15.number(),
|
|
1993
|
+
endSecond: z15.number()
|
|
1938
1994
|
})
|
|
1939
1995
|
).optional(),
|
|
1940
|
-
language:
|
|
1941
|
-
durationInSeconds:
|
|
1942
|
-
warnings:
|
|
1943
|
-
providerMetadata:
|
|
1996
|
+
language: z15.string().nullish(),
|
|
1997
|
+
durationInSeconds: z15.number().nullish(),
|
|
1998
|
+
warnings: z15.array(gatewayTranscriptionWarningSchema()).optional(),
|
|
1999
|
+
providerMetadata: z15.record(z15.string(), providerMetadataEntrySchema4()).optional()
|
|
1944
2000
|
})
|
|
1945
2001
|
)
|
|
1946
2002
|
);
|
|
@@ -1948,23 +2004,23 @@ var gatewayTranscriptionResponseSchema = lazySchema13(
|
|
|
1948
2004
|
// src/tool/browserbase-fetch.ts
|
|
1949
2005
|
import {
|
|
1950
2006
|
createProviderToolFactoryWithOutputSchema,
|
|
1951
|
-
lazySchema as
|
|
1952
|
-
zodSchema as
|
|
2007
|
+
lazySchema as lazySchema15,
|
|
2008
|
+
zodSchema as zodSchema15
|
|
1953
2009
|
} from "@ai-sdk/provider-utils";
|
|
1954
|
-
import { z as
|
|
1955
|
-
var jsonObjectSchema = () =>
|
|
1956
|
-
var browserbaseFetchInputSchema =
|
|
1957
|
-
() =>
|
|
1958
|
-
|
|
1959
|
-
url:
|
|
1960
|
-
allow_redirects:
|
|
1961
|
-
allow_insecure_ssl:
|
|
2010
|
+
import { z as z16 } from "zod";
|
|
2011
|
+
var jsonObjectSchema = () => z16.record(z16.string(), z16.unknown());
|
|
2012
|
+
var browserbaseFetchInputSchema = lazySchema15(
|
|
2013
|
+
() => zodSchema15(
|
|
2014
|
+
z16.object({
|
|
2015
|
+
url: z16.string().url().describe("URL of the page to fetch."),
|
|
2016
|
+
allow_redirects: z16.boolean().optional().describe("Whether to follow HTTP redirects (default: false)."),
|
|
2017
|
+
allow_insecure_ssl: z16.boolean().optional().describe(
|
|
1962
2018
|
"Whether to bypass TLS certificate verification (default: false). Only use for trusted hosts."
|
|
1963
2019
|
),
|
|
1964
|
-
proxies:
|
|
2020
|
+
proxies: z16.boolean().optional().describe(
|
|
1965
2021
|
"Whether to route the request through Browserbase proxies (default: false)."
|
|
1966
2022
|
),
|
|
1967
|
-
format:
|
|
2023
|
+
format: z16.enum(["raw", "json", "markdown"]).optional().describe(
|
|
1968
2024
|
"Output format. raw returns the response body unchanged, markdown returns page content as Markdown, and json returns structured content using schema."
|
|
1969
2025
|
),
|
|
1970
2026
|
schema: jsonObjectSchema().optional().describe(
|
|
@@ -1973,19 +2029,19 @@ var browserbaseFetchInputSchema = lazySchema14(
|
|
|
1973
2029
|
})
|
|
1974
2030
|
)
|
|
1975
2031
|
);
|
|
1976
|
-
var browserbaseFetchOutputSchema =
|
|
1977
|
-
() =>
|
|
1978
|
-
|
|
1979
|
-
|
|
1980
|
-
id:
|
|
1981
|
-
content:
|
|
1982
|
-
contentType:
|
|
1983
|
-
encoding:
|
|
1984
|
-
headers:
|
|
1985
|
-
statusCode:
|
|
2032
|
+
var browserbaseFetchOutputSchema = lazySchema15(
|
|
2033
|
+
() => zodSchema15(
|
|
2034
|
+
z16.union([
|
|
2035
|
+
z16.object({
|
|
2036
|
+
id: z16.string(),
|
|
2037
|
+
content: z16.union([z16.string(), jsonObjectSchema()]),
|
|
2038
|
+
contentType: z16.string(),
|
|
2039
|
+
encoding: z16.string(),
|
|
2040
|
+
headers: z16.record(z16.string(), z16.string()),
|
|
2041
|
+
statusCode: z16.number()
|
|
1986
2042
|
}),
|
|
1987
|
-
|
|
1988
|
-
error:
|
|
2043
|
+
z16.object({
|
|
2044
|
+
error: z16.enum([
|
|
1989
2045
|
"api_error",
|
|
1990
2046
|
"configuration_error",
|
|
1991
2047
|
"execution_error",
|
|
@@ -1994,8 +2050,8 @@ var browserbaseFetchOutputSchema = lazySchema14(
|
|
|
1994
2050
|
"timeout",
|
|
1995
2051
|
"unknown"
|
|
1996
2052
|
]),
|
|
1997
|
-
statusCode:
|
|
1998
|
-
message:
|
|
2053
|
+
statusCode: z16.number().optional(),
|
|
2054
|
+
message: z16.string()
|
|
1999
2055
|
})
|
|
2000
2056
|
])
|
|
2001
2057
|
)
|
|
@@ -2010,38 +2066,38 @@ var browserbaseFetch = (config = {}) => browserbaseFetchToolFactory(config);
|
|
|
2010
2066
|
// src/tool/browserbase-search.ts
|
|
2011
2067
|
import {
|
|
2012
2068
|
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema2,
|
|
2013
|
-
lazySchema as
|
|
2014
|
-
zodSchema as
|
|
2069
|
+
lazySchema as lazySchema16,
|
|
2070
|
+
zodSchema as zodSchema16
|
|
2015
2071
|
} from "@ai-sdk/provider-utils";
|
|
2016
|
-
import { z as
|
|
2017
|
-
var browserbaseSearchInputSchema =
|
|
2018
|
-
() =>
|
|
2019
|
-
|
|
2020
|
-
query:
|
|
2021
|
-
num_results:
|
|
2072
|
+
import { z as z17 } from "zod";
|
|
2073
|
+
var browserbaseSearchInputSchema = lazySchema16(
|
|
2074
|
+
() => zodSchema16(
|
|
2075
|
+
z17.object({
|
|
2076
|
+
query: z17.string().min(1).max(200).describe("Web search query. Must be between 1 and 200 characters."),
|
|
2077
|
+
num_results: z17.number().int().min(1).max(25).optional().describe("Maximum number of results to return (1-25, default: 10).")
|
|
2022
2078
|
})
|
|
2023
2079
|
)
|
|
2024
2080
|
);
|
|
2025
|
-
var browserbaseSearchOutputSchema =
|
|
2026
|
-
() =>
|
|
2027
|
-
|
|
2028
|
-
|
|
2029
|
-
query:
|
|
2030
|
-
requestId:
|
|
2031
|
-
results:
|
|
2032
|
-
|
|
2033
|
-
id:
|
|
2034
|
-
title:
|
|
2035
|
-
url:
|
|
2036
|
-
author:
|
|
2037
|
-
favicon:
|
|
2038
|
-
image:
|
|
2039
|
-
publishedDate:
|
|
2081
|
+
var browserbaseSearchOutputSchema = lazySchema16(
|
|
2082
|
+
() => zodSchema16(
|
|
2083
|
+
z17.union([
|
|
2084
|
+
z17.object({
|
|
2085
|
+
query: z17.string(),
|
|
2086
|
+
requestId: z17.string(),
|
|
2087
|
+
results: z17.array(
|
|
2088
|
+
z17.object({
|
|
2089
|
+
id: z17.string(),
|
|
2090
|
+
title: z17.string(),
|
|
2091
|
+
url: z17.string(),
|
|
2092
|
+
author: z17.string().optional(),
|
|
2093
|
+
favicon: z17.string().optional(),
|
|
2094
|
+
image: z17.string().optional(),
|
|
2095
|
+
publishedDate: z17.string().optional()
|
|
2040
2096
|
})
|
|
2041
2097
|
)
|
|
2042
2098
|
}),
|
|
2043
|
-
|
|
2044
|
-
error:
|
|
2099
|
+
z17.object({
|
|
2100
|
+
error: z17.enum([
|
|
2045
2101
|
"api_error",
|
|
2046
2102
|
"configuration_error",
|
|
2047
2103
|
"execution_error",
|
|
@@ -2050,8 +2106,8 @@ var browserbaseSearchOutputSchema = lazySchema15(
|
|
|
2050
2106
|
"timeout",
|
|
2051
2107
|
"unknown"
|
|
2052
2108
|
]),
|
|
2053
|
-
statusCode:
|
|
2054
|
-
message:
|
|
2109
|
+
statusCode: z17.number().optional(),
|
|
2110
|
+
message: z17.string()
|
|
2055
2111
|
})
|
|
2056
2112
|
])
|
|
2057
2113
|
)
|
|
@@ -2066,15 +2122,15 @@ var browserbaseSearch = (config = {}) => browserbaseSearchToolFactory(config);
|
|
|
2066
2122
|
// src/tool/deepseek-fetch.ts
|
|
2067
2123
|
import {
|
|
2068
2124
|
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema3,
|
|
2069
|
-
lazySchema as
|
|
2070
|
-
zodSchema as
|
|
2125
|
+
lazySchema as lazySchema17,
|
|
2126
|
+
zodSchema as zodSchema17
|
|
2071
2127
|
} from "@ai-sdk/provider-utils";
|
|
2072
|
-
import { z as
|
|
2128
|
+
import { z as z19 } from "zod";
|
|
2073
2129
|
|
|
2074
2130
|
// src/tool/gateway-tool-error.ts
|
|
2075
|
-
import { z as
|
|
2076
|
-
var gatewayToolErrorSchema = () =>
|
|
2077
|
-
error:
|
|
2131
|
+
import { z as z18 } from "zod";
|
|
2132
|
+
var gatewayToolErrorSchema = () => z18.object({
|
|
2133
|
+
error: z18.enum([
|
|
2078
2134
|
"api_error",
|
|
2079
2135
|
"configuration_error",
|
|
2080
2136
|
"execution_error",
|
|
@@ -2085,28 +2141,28 @@ var gatewayToolErrorSchema = () => z17.object({
|
|
|
2085
2141
|
"unknown",
|
|
2086
2142
|
"unknown_tool"
|
|
2087
2143
|
]),
|
|
2088
|
-
message:
|
|
2089
|
-
statusCode:
|
|
2090
|
-
retryAfter:
|
|
2091
|
-
statusText:
|
|
2144
|
+
message: z18.string(),
|
|
2145
|
+
statusCode: z18.number().optional(),
|
|
2146
|
+
retryAfter: z18.string().optional(),
|
|
2147
|
+
statusText: z18.string().optional()
|
|
2092
2148
|
}).passthrough();
|
|
2093
2149
|
|
|
2094
2150
|
// src/tool/deepseek-fetch.ts
|
|
2095
|
-
var deepseekFetchInputSchema =
|
|
2096
|
-
() =>
|
|
2097
|
-
|
|
2098
|
-
url:
|
|
2151
|
+
var deepseekFetchInputSchema = lazySchema17(
|
|
2152
|
+
() => zodSchema17(
|
|
2153
|
+
z19.object({
|
|
2154
|
+
url: z19.string().describe(
|
|
2099
2155
|
"URL to fetch, at most 8192 characters; HTTP(S) only, without a username or password."
|
|
2100
2156
|
)
|
|
2101
2157
|
})
|
|
2102
2158
|
)
|
|
2103
2159
|
);
|
|
2104
|
-
var deepseekFetchOutputSchema =
|
|
2105
|
-
() =>
|
|
2106
|
-
|
|
2107
|
-
|
|
2108
|
-
title:
|
|
2109
|
-
content:
|
|
2160
|
+
var deepseekFetchOutputSchema = lazySchema17(
|
|
2161
|
+
() => zodSchema17(
|
|
2162
|
+
z19.union([
|
|
2163
|
+
z19.object({
|
|
2164
|
+
title: z19.string().nullish(),
|
|
2165
|
+
content: z19.string()
|
|
2110
2166
|
}).passthrough(),
|
|
2111
2167
|
gatewayToolErrorSchema()
|
|
2112
2168
|
])
|
|
@@ -2122,38 +2178,38 @@ var deepseekFetch = (config = {}) => deepseekFetchToolFactory(config);
|
|
|
2122
2178
|
// src/tool/deepseek-search.ts
|
|
2123
2179
|
import {
|
|
2124
2180
|
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema4,
|
|
2125
|
-
lazySchema as
|
|
2126
|
-
zodSchema as
|
|
2181
|
+
lazySchema as lazySchema18,
|
|
2182
|
+
zodSchema as zodSchema18
|
|
2127
2183
|
} from "@ai-sdk/provider-utils";
|
|
2128
|
-
import { z as
|
|
2129
|
-
var deepseekSearchInputSchema =
|
|
2130
|
-
() =>
|
|
2131
|
-
|
|
2132
|
-
query:
|
|
2184
|
+
import { z as z20 } from "zod";
|
|
2185
|
+
var deepseekSearchInputSchema = lazySchema18(
|
|
2186
|
+
() => zodSchema18(
|
|
2187
|
+
z20.object({
|
|
2188
|
+
query: z20.string().describe(
|
|
2133
2189
|
"Web search query, 1 to 128 Unicode characters. Supports site:, -site:, lang:, after:, before:, and quoted phrases."
|
|
2134
2190
|
),
|
|
2135
|
-
count:
|
|
2136
|
-
need_content:
|
|
2137
|
-
ori_question:
|
|
2191
|
+
count: z20.number().int().optional().describe("Number of results, 1 to 50 (default: 10)."),
|
|
2192
|
+
need_content: z20.boolean().optional().describe("Include available page content (default: false)."),
|
|
2193
|
+
ori_question: z20.string().nullable().optional().describe("Original user question, 1 to 128 Unicode characters.")
|
|
2138
2194
|
})
|
|
2139
2195
|
)
|
|
2140
2196
|
);
|
|
2141
|
-
var deepseekSearchOutputSchema =
|
|
2142
|
-
() =>
|
|
2143
|
-
|
|
2144
|
-
|
|
2145
|
-
results:
|
|
2146
|
-
|
|
2147
|
-
authority:
|
|
2148
|
-
content:
|
|
2149
|
-
date:
|
|
2150
|
-
rerank_score:
|
|
2151
|
-
site_icon:
|
|
2152
|
-
site_name:
|
|
2153
|
-
snippet:
|
|
2154
|
-
summary:
|
|
2155
|
-
title:
|
|
2156
|
-
url:
|
|
2197
|
+
var deepseekSearchOutputSchema = lazySchema18(
|
|
2198
|
+
() => zodSchema18(
|
|
2199
|
+
z20.union([
|
|
2200
|
+
z20.object({
|
|
2201
|
+
results: z20.array(
|
|
2202
|
+
z20.object({
|
|
2203
|
+
authority: z20.number().nullish(),
|
|
2204
|
+
content: z20.string().nullish(),
|
|
2205
|
+
date: z20.string().nullish(),
|
|
2206
|
+
rerank_score: z20.number().nullish(),
|
|
2207
|
+
site_icon: z20.string().nullish(),
|
|
2208
|
+
site_name: z20.string().nullish(),
|
|
2209
|
+
snippet: z20.string().nullish(),
|
|
2210
|
+
summary: z20.string().nullish(),
|
|
2211
|
+
title: z20.string().nullish(),
|
|
2212
|
+
url: z20.string().nullish()
|
|
2157
2213
|
}).passthrough()
|
|
2158
2214
|
)
|
|
2159
2215
|
}).passthrough(),
|
|
@@ -2171,19 +2227,19 @@ var deepseekSearch = (config = {}) => deepseekSearchToolFactory(config);
|
|
|
2171
2227
|
// src/tool/exa-search.ts
|
|
2172
2228
|
import {
|
|
2173
2229
|
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema5,
|
|
2174
|
-
lazySchema as
|
|
2175
|
-
zodSchema as
|
|
2230
|
+
lazySchema as lazySchema19,
|
|
2231
|
+
zodSchema as zodSchema19
|
|
2176
2232
|
} from "@ai-sdk/provider-utils";
|
|
2177
|
-
import { z as
|
|
2178
|
-
var exaSearchInputSchema =
|
|
2179
|
-
() =>
|
|
2180
|
-
|
|
2181
|
-
query:
|
|
2182
|
-
type:
|
|
2233
|
+
import { z as z21 } from "zod";
|
|
2234
|
+
var exaSearchInputSchema = lazySchema19(
|
|
2235
|
+
() => zodSchema19(
|
|
2236
|
+
z21.object({
|
|
2237
|
+
query: z21.string().describe("Natural-language web search query. This is required."),
|
|
2238
|
+
type: z21.enum(["auto", "fast", "instant"]).optional().describe(
|
|
2183
2239
|
"Search method. Use auto for the default balance of speed and quality."
|
|
2184
2240
|
),
|
|
2185
|
-
num_results:
|
|
2186
|
-
category:
|
|
2241
|
+
num_results: z21.number().optional().describe("Maximum number of results to return (1-100, default: 10)."),
|
|
2242
|
+
category: z21.enum([
|
|
2187
2243
|
"company",
|
|
2188
2244
|
"people",
|
|
2189
2245
|
"research paper",
|
|
@@ -2191,20 +2247,20 @@ var exaSearchInputSchema = lazySchema18(
|
|
|
2191
2247
|
"personal site",
|
|
2192
2248
|
"financial report"
|
|
2193
2249
|
]).optional().describe("Optional content category to focus results."),
|
|
2194
|
-
user_location:
|
|
2195
|
-
include_domains:
|
|
2196
|
-
exclude_domains:
|
|
2197
|
-
start_published_date:
|
|
2198
|
-
end_published_date:
|
|
2199
|
-
contents:
|
|
2200
|
-
text:
|
|
2201
|
-
|
|
2202
|
-
|
|
2203
|
-
max_characters:
|
|
2204
|
-
include_html_tags:
|
|
2205
|
-
verbosity:
|
|
2206
|
-
include_sections:
|
|
2207
|
-
|
|
2250
|
+
user_location: z21.string().optional().describe("Two-letter ISO country code such as 'US'."),
|
|
2251
|
+
include_domains: z21.array(z21.string()).optional().describe("Only return results from these domains."),
|
|
2252
|
+
exclude_domains: z21.array(z21.string()).optional().describe("Exclude results from these domains."),
|
|
2253
|
+
start_published_date: z21.string().optional().describe("Only return links published after this ISO 8601 date."),
|
|
2254
|
+
end_published_date: z21.string().optional().describe("Only return links published before this ISO 8601 date."),
|
|
2255
|
+
contents: z21.object({
|
|
2256
|
+
text: z21.union([
|
|
2257
|
+
z21.boolean(),
|
|
2258
|
+
z21.object({
|
|
2259
|
+
max_characters: z21.number().optional(),
|
|
2260
|
+
include_html_tags: z21.boolean().optional(),
|
|
2261
|
+
verbosity: z21.enum(["compact", "standard", "full"]).optional(),
|
|
2262
|
+
include_sections: z21.array(
|
|
2263
|
+
z21.enum([
|
|
2208
2264
|
"header",
|
|
2209
2265
|
"navigation",
|
|
2210
2266
|
"banner",
|
|
@@ -2214,8 +2270,8 @@ var exaSearchInputSchema = lazySchema18(
|
|
|
2214
2270
|
"metadata"
|
|
2215
2271
|
])
|
|
2216
2272
|
).optional(),
|
|
2217
|
-
exclude_sections:
|
|
2218
|
-
|
|
2273
|
+
exclude_sections: z21.array(
|
|
2274
|
+
z21.enum([
|
|
2219
2275
|
"header",
|
|
2220
2276
|
"navigation",
|
|
2221
2277
|
"banner",
|
|
@@ -2227,59 +2283,59 @@ var exaSearchInputSchema = lazySchema18(
|
|
|
2227
2283
|
).optional()
|
|
2228
2284
|
})
|
|
2229
2285
|
]).optional(),
|
|
2230
|
-
highlights:
|
|
2231
|
-
|
|
2232
|
-
|
|
2233
|
-
query:
|
|
2234
|
-
max_characters:
|
|
2286
|
+
highlights: z21.union([
|
|
2287
|
+
z21.boolean(),
|
|
2288
|
+
z21.object({
|
|
2289
|
+
query: z21.string().optional(),
|
|
2290
|
+
max_characters: z21.number().optional()
|
|
2235
2291
|
})
|
|
2236
2292
|
]).optional(),
|
|
2237
|
-
max_age_hours:
|
|
2238
|
-
livecrawl_timeout:
|
|
2239
|
-
subpages:
|
|
2240
|
-
subpage_target:
|
|
2241
|
-
extras:
|
|
2242
|
-
links:
|
|
2243
|
-
image_links:
|
|
2293
|
+
max_age_hours: z21.number().optional(),
|
|
2294
|
+
livecrawl_timeout: z21.number().optional(),
|
|
2295
|
+
subpages: z21.number().optional(),
|
|
2296
|
+
subpage_target: z21.union([z21.string(), z21.array(z21.string())]).optional(),
|
|
2297
|
+
extras: z21.object({
|
|
2298
|
+
links: z21.number().optional(),
|
|
2299
|
+
image_links: z21.number().optional()
|
|
2244
2300
|
}).optional()
|
|
2245
2301
|
}).optional().describe("Controls extracted page content and freshness.")
|
|
2246
2302
|
})
|
|
2247
2303
|
)
|
|
2248
2304
|
);
|
|
2249
|
-
var exaSearchOutputSchema =
|
|
2250
|
-
() =>
|
|
2251
|
-
|
|
2252
|
-
|
|
2253
|
-
requestId:
|
|
2254
|
-
searchType:
|
|
2255
|
-
resolvedSearchType:
|
|
2256
|
-
results:
|
|
2257
|
-
|
|
2258
|
-
title:
|
|
2259
|
-
url:
|
|
2260
|
-
id:
|
|
2261
|
-
publishedDate:
|
|
2262
|
-
author:
|
|
2263
|
-
image:
|
|
2264
|
-
favicon:
|
|
2265
|
-
text:
|
|
2266
|
-
highlights:
|
|
2267
|
-
highlightScores:
|
|
2268
|
-
summary:
|
|
2269
|
-
subpages:
|
|
2270
|
-
extras:
|
|
2271
|
-
links:
|
|
2272
|
-
imageLinks:
|
|
2305
|
+
var exaSearchOutputSchema = lazySchema19(
|
|
2306
|
+
() => zodSchema19(
|
|
2307
|
+
z21.union([
|
|
2308
|
+
z21.object({
|
|
2309
|
+
requestId: z21.string(),
|
|
2310
|
+
searchType: z21.string().optional(),
|
|
2311
|
+
resolvedSearchType: z21.string().optional(),
|
|
2312
|
+
results: z21.array(
|
|
2313
|
+
z21.object({
|
|
2314
|
+
title: z21.string(),
|
|
2315
|
+
url: z21.string(),
|
|
2316
|
+
id: z21.string(),
|
|
2317
|
+
publishedDate: z21.string().nullable().optional(),
|
|
2318
|
+
author: z21.string().nullable().optional(),
|
|
2319
|
+
image: z21.string().nullable().optional(),
|
|
2320
|
+
favicon: z21.string().nullable().optional(),
|
|
2321
|
+
text: z21.string().optional(),
|
|
2322
|
+
highlights: z21.array(z21.string()).optional(),
|
|
2323
|
+
highlightScores: z21.array(z21.number()).optional(),
|
|
2324
|
+
summary: z21.string().optional(),
|
|
2325
|
+
subpages: z21.array(z21.any()).optional(),
|
|
2326
|
+
extras: z21.object({
|
|
2327
|
+
links: z21.array(z21.string()).optional(),
|
|
2328
|
+
imageLinks: z21.array(z21.string()).optional()
|
|
2273
2329
|
}).optional()
|
|
2274
2330
|
})
|
|
2275
2331
|
),
|
|
2276
|
-
costDollars:
|
|
2277
|
-
total:
|
|
2278
|
-
search:
|
|
2332
|
+
costDollars: z21.object({
|
|
2333
|
+
total: z21.number().optional(),
|
|
2334
|
+
search: z21.record(z21.number()).optional()
|
|
2279
2335
|
}).optional()
|
|
2280
2336
|
}),
|
|
2281
|
-
|
|
2282
|
-
error:
|
|
2337
|
+
z21.object({
|
|
2338
|
+
error: z21.enum([
|
|
2283
2339
|
"api_error",
|
|
2284
2340
|
"rate_limit",
|
|
2285
2341
|
"timeout",
|
|
@@ -2288,8 +2344,8 @@ var exaSearchOutputSchema = lazySchema18(
|
|
|
2288
2344
|
"execution_error",
|
|
2289
2345
|
"unknown"
|
|
2290
2346
|
]),
|
|
2291
|
-
statusCode:
|
|
2292
|
-
message:
|
|
2347
|
+
statusCode: z21.number().optional(),
|
|
2348
|
+
message: z21.string()
|
|
2293
2349
|
})
|
|
2294
2350
|
])
|
|
2295
2351
|
)
|
|
@@ -2304,10 +2360,10 @@ var exaSearch = (config = {}) => exaSearchToolFactory(config);
|
|
|
2304
2360
|
// src/tool/parallel-search.ts
|
|
2305
2361
|
import {
|
|
2306
2362
|
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema6,
|
|
2307
|
-
lazySchema as
|
|
2308
|
-
zodSchema as
|
|
2363
|
+
lazySchema as lazySchema20,
|
|
2364
|
+
zodSchema as zodSchema20
|
|
2309
2365
|
} from "@ai-sdk/provider-utils";
|
|
2310
|
-
import { z as
|
|
2366
|
+
import { z as z22 } from "zod";
|
|
2311
2367
|
var parallelSearchModes = [
|
|
2312
2368
|
"turbo",
|
|
2313
2369
|
"fast",
|
|
@@ -2316,79 +2372,79 @@ var parallelSearchModes = [
|
|
|
2316
2372
|
"one-shot",
|
|
2317
2373
|
"agentic"
|
|
2318
2374
|
];
|
|
2319
|
-
var parallelSearchInputSchema =
|
|
2320
|
-
() =>
|
|
2321
|
-
|
|
2322
|
-
objective:
|
|
2375
|
+
var parallelSearchInputSchema = lazySchema20(
|
|
2376
|
+
() => zodSchema20(
|
|
2377
|
+
z22.object({
|
|
2378
|
+
objective: z22.string().describe(
|
|
2323
2379
|
"Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."
|
|
2324
2380
|
),
|
|
2325
|
-
search_queries:
|
|
2381
|
+
search_queries: z22.array(z22.string()).optional().describe(
|
|
2326
2382
|
"Provide 2-3 concise keyword queries, 3-6 words each (max 5, 200 chars each). Strongly recommended; the search runs on these queries."
|
|
2327
2383
|
),
|
|
2328
|
-
mode:
|
|
2384
|
+
mode: z22.enum(parallelSearchModes).optional().describe(
|
|
2329
2385
|
'Search mode: "turbo" and "fast" return quickly with shorter excerpts, "basic" is balanced (default), "advanced" is the most thorough. "turbo" supports English and Japanese only. "one-shot" and "agentic" are deprecated aliases of "basic" and "advanced".'
|
|
2330
2386
|
),
|
|
2331
|
-
max_results:
|
|
2387
|
+
max_results: z22.number().optional().describe(
|
|
2332
2388
|
"Maximum number of results to return (1-20). Defaults to 10 if not specified."
|
|
2333
2389
|
),
|
|
2334
|
-
source_policy:
|
|
2335
|
-
include_domains:
|
|
2390
|
+
source_policy: z22.object({
|
|
2391
|
+
include_domains: z22.array(z22.string()).optional().describe(
|
|
2336
2392
|
"Domains or domain/path prefixes to restrict results to, without scheme or port. Example: ['wikipedia.org', 'docs.python.org/3']."
|
|
2337
2393
|
),
|
|
2338
|
-
exclude_domains:
|
|
2394
|
+
exclude_domains: z22.array(z22.string()).optional().describe(
|
|
2339
2395
|
"Domains or domain/path prefixes to exclude, without scheme or port. Example: ['reddit.com']."
|
|
2340
2396
|
),
|
|
2341
|
-
after_date:
|
|
2397
|
+
after_date: z22.string().optional().describe(
|
|
2342
2398
|
"Only include results published on or after this date. Use an ISO 8601 calendar date formatted YYYY-MM-DD (e.g. 2025-01-01); do not include a time."
|
|
2343
2399
|
)
|
|
2344
2400
|
}).optional().describe(
|
|
2345
2401
|
"Source policy for controlling which domains to include/exclude and freshness."
|
|
2346
2402
|
),
|
|
2347
|
-
excerpts:
|
|
2348
|
-
max_chars_per_result:
|
|
2349
|
-
max_chars_total:
|
|
2403
|
+
excerpts: z22.object({
|
|
2404
|
+
max_chars_per_result: z22.number().optional().describe("Maximum characters per result."),
|
|
2405
|
+
max_chars_total: z22.number().optional().describe("Deprecated: use the top-level max_chars_total.")
|
|
2350
2406
|
}).optional().describe("Excerpt configuration for controlling result length."),
|
|
2351
|
-
max_chars_total:
|
|
2352
|
-
fetch_policy:
|
|
2353
|
-
max_age_seconds:
|
|
2407
|
+
max_chars_total: z22.number().optional().describe("Maximum total characters across all result excerpts."),
|
|
2408
|
+
fetch_policy: z22.object({
|
|
2409
|
+
max_age_seconds: z22.number().optional().describe(
|
|
2354
2410
|
"Maximum age of cached content in seconds before a live fetch, minimum 600."
|
|
2355
2411
|
),
|
|
2356
|
-
timeout_seconds:
|
|
2412
|
+
timeout_seconds: z22.number().optional().describe(
|
|
2357
2413
|
"Timeout in seconds for a live fetch when content is not cached. Capped by the gateway tool timeout."
|
|
2358
2414
|
),
|
|
2359
|
-
disable_cache_fallback:
|
|
2415
|
+
disable_cache_fallback: z22.boolean().optional().describe(
|
|
2360
2416
|
"Return an error instead of older cached content when a live fetch fails."
|
|
2361
2417
|
)
|
|
2362
2418
|
}).optional().describe("Fetch policy for controlling content freshness."),
|
|
2363
|
-
location:
|
|
2419
|
+
location: z22.string().optional().describe(
|
|
2364
2420
|
'ISO 3166-1 alpha-2 country code to localize results, e.g. "us".'
|
|
2365
2421
|
)
|
|
2366
2422
|
})
|
|
2367
2423
|
)
|
|
2368
2424
|
);
|
|
2369
|
-
var parallelSearchOutputSchema =
|
|
2370
|
-
() =>
|
|
2371
|
-
|
|
2425
|
+
var parallelSearchOutputSchema = lazySchema20(
|
|
2426
|
+
() => zodSchema20(
|
|
2427
|
+
z22.union([
|
|
2372
2428
|
// Success response (Parallel's response, passed through by the gateway)
|
|
2373
|
-
|
|
2374
|
-
search_id:
|
|
2375
|
-
results:
|
|
2376
|
-
|
|
2377
|
-
url:
|
|
2378
|
-
title:
|
|
2379
|
-
publish_date:
|
|
2380
|
-
excerpts:
|
|
2429
|
+
z22.object({
|
|
2430
|
+
search_id: z22.string(),
|
|
2431
|
+
results: z22.array(
|
|
2432
|
+
z22.object({
|
|
2433
|
+
url: z22.string(),
|
|
2434
|
+
title: z22.string().nullable().optional(),
|
|
2435
|
+
publish_date: z22.string().nullable().optional(),
|
|
2436
|
+
excerpts: z22.array(z22.string())
|
|
2381
2437
|
})
|
|
2382
2438
|
),
|
|
2383
|
-
warnings:
|
|
2384
|
-
|
|
2385
|
-
type:
|
|
2386
|
-
message:
|
|
2387
|
-
detail:
|
|
2439
|
+
warnings: z22.array(
|
|
2440
|
+
z22.object({
|
|
2441
|
+
type: z22.string(),
|
|
2442
|
+
message: z22.string(),
|
|
2443
|
+
detail: z22.record(z22.string(), z22.unknown()).nullable().optional()
|
|
2388
2444
|
})
|
|
2389
2445
|
).nullable().optional(),
|
|
2390
|
-
usage:
|
|
2391
|
-
session_id:
|
|
2446
|
+
usage: z22.array(z22.object({ name: z22.string(), count: z22.number().optional() })).nullable().optional(),
|
|
2447
|
+
session_id: z22.string().optional()
|
|
2392
2448
|
}),
|
|
2393
2449
|
// Error response
|
|
2394
2450
|
gatewayToolErrorSchema()
|
|
@@ -2405,79 +2461,79 @@ var parallelSearch = (config = {}) => parallelSearchToolFactory(config);
|
|
|
2405
2461
|
// src/tool/perplexity-search.ts
|
|
2406
2462
|
import {
|
|
2407
2463
|
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema7,
|
|
2408
|
-
lazySchema as
|
|
2409
|
-
zodSchema as
|
|
2464
|
+
lazySchema as lazySchema21,
|
|
2465
|
+
zodSchema as zodSchema21
|
|
2410
2466
|
} from "@ai-sdk/provider-utils";
|
|
2411
|
-
import { z as
|
|
2412
|
-
var perplexitySearchInputSchema =
|
|
2413
|
-
() =>
|
|
2414
|
-
|
|
2415
|
-
query:
|
|
2467
|
+
import { z as z23 } from "zod";
|
|
2468
|
+
var perplexitySearchInputSchema = lazySchema21(
|
|
2469
|
+
() => zodSchema21(
|
|
2470
|
+
z23.object({
|
|
2471
|
+
query: z23.union([z23.string(), z23.array(z23.string())]).describe(
|
|
2416
2472
|
"Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."
|
|
2417
2473
|
),
|
|
2418
|
-
max_results:
|
|
2474
|
+
max_results: z23.number().optional().describe(
|
|
2419
2475
|
"Maximum number of search results to return (1-20, default: 10)"
|
|
2420
2476
|
),
|
|
2421
|
-
max_tokens_per_page:
|
|
2477
|
+
max_tokens_per_page: z23.number().optional().describe(
|
|
2422
2478
|
"Maximum number of tokens to extract per search result page (256-2048, default: 2048)"
|
|
2423
2479
|
),
|
|
2424
|
-
max_tokens:
|
|
2480
|
+
max_tokens: z23.number().optional().describe(
|
|
2425
2481
|
"Maximum total tokens across all search results (default: 25000, max: 1000000)"
|
|
2426
2482
|
),
|
|
2427
|
-
country:
|
|
2483
|
+
country: z23.string().optional().describe(
|
|
2428
2484
|
"Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')"
|
|
2429
2485
|
),
|
|
2430
|
-
search_domain_filter:
|
|
2486
|
+
search_domain_filter: z23.array(z23.string()).optional().describe(
|
|
2431
2487
|
"List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']"
|
|
2432
2488
|
),
|
|
2433
|
-
search_language_filter:
|
|
2489
|
+
search_language_filter: z23.array(z23.string()).optional().describe(
|
|
2434
2490
|
"List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']"
|
|
2435
2491
|
),
|
|
2436
|
-
search_after_date:
|
|
2492
|
+
search_after_date: z23.string().optional().describe(
|
|
2437
2493
|
"Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
|
|
2438
2494
|
),
|
|
2439
|
-
search_before_date:
|
|
2495
|
+
search_before_date: z23.string().optional().describe(
|
|
2440
2496
|
"Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
|
|
2441
2497
|
),
|
|
2442
|
-
last_updated_after_filter:
|
|
2498
|
+
last_updated_after_filter: z23.string().optional().describe(
|
|
2443
2499
|
"Include only results last updated after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
|
|
2444
2500
|
),
|
|
2445
|
-
last_updated_before_filter:
|
|
2501
|
+
last_updated_before_filter: z23.string().optional().describe(
|
|
2446
2502
|
"Include only results last updated before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
|
|
2447
2503
|
),
|
|
2448
|
-
search_recency_filter:
|
|
2504
|
+
search_recency_filter: z23.enum(["day", "week", "month", "year"]).optional().describe(
|
|
2449
2505
|
"Filter results by relative time period. Cannot be used with search_after_date or search_before_date."
|
|
2450
2506
|
)
|
|
2451
2507
|
})
|
|
2452
2508
|
)
|
|
2453
2509
|
);
|
|
2454
|
-
var perplexitySearchOutputSchema =
|
|
2455
|
-
() =>
|
|
2456
|
-
|
|
2510
|
+
var perplexitySearchOutputSchema = lazySchema21(
|
|
2511
|
+
() => zodSchema21(
|
|
2512
|
+
z23.union([
|
|
2457
2513
|
// Success response
|
|
2458
|
-
|
|
2459
|
-
results:
|
|
2460
|
-
|
|
2461
|
-
title:
|
|
2462
|
-
url:
|
|
2463
|
-
snippet:
|
|
2464
|
-
date:
|
|
2465
|
-
lastUpdated:
|
|
2514
|
+
z23.object({
|
|
2515
|
+
results: z23.array(
|
|
2516
|
+
z23.object({
|
|
2517
|
+
title: z23.string(),
|
|
2518
|
+
url: z23.string(),
|
|
2519
|
+
snippet: z23.string(),
|
|
2520
|
+
date: z23.string().optional(),
|
|
2521
|
+
lastUpdated: z23.string().optional()
|
|
2466
2522
|
})
|
|
2467
2523
|
),
|
|
2468
|
-
id:
|
|
2524
|
+
id: z23.string()
|
|
2469
2525
|
}),
|
|
2470
2526
|
// Error response
|
|
2471
|
-
|
|
2472
|
-
error:
|
|
2527
|
+
z23.object({
|
|
2528
|
+
error: z23.enum([
|
|
2473
2529
|
"api_error",
|
|
2474
2530
|
"rate_limit",
|
|
2475
2531
|
"timeout",
|
|
2476
2532
|
"invalid_input",
|
|
2477
2533
|
"unknown"
|
|
2478
2534
|
]),
|
|
2479
|
-
statusCode:
|
|
2480
|
-
message:
|
|
2535
|
+
statusCode: z23.number().optional(),
|
|
2536
|
+
message: z23.string()
|
|
2481
2537
|
})
|
|
2482
2538
|
])
|
|
2483
2539
|
)
|
|
@@ -2492,208 +2548,208 @@ var perplexitySearch = (config = {}) => perplexitySearchToolFactory(config);
|
|
|
2492
2548
|
// src/tool/tako-search.ts
|
|
2493
2549
|
import {
|
|
2494
2550
|
createProviderToolFactoryWithOutputSchema as createProviderToolFactoryWithOutputSchema8,
|
|
2495
|
-
lazySchema as
|
|
2496
|
-
zodSchema as
|
|
2551
|
+
lazySchema as lazySchema22,
|
|
2552
|
+
zodSchema as zodSchema22
|
|
2497
2553
|
} from "@ai-sdk/provider-utils";
|
|
2498
|
-
import { z as
|
|
2499
|
-
var takoDataSourceInputSchema = () =>
|
|
2500
|
-
count:
|
|
2554
|
+
import { z as z24 } from "zod";
|
|
2555
|
+
var takoDataSourceInputSchema = () => z24.object({
|
|
2556
|
+
count: z24.number().optional().describe(
|
|
2501
2557
|
"Maximum number of data results to return (1-20). When include_contents is true, each additional result adds its own data surcharge."
|
|
2502
2558
|
),
|
|
2503
|
-
include_contents:
|
|
2559
|
+
include_contents: z24.boolean().optional().describe(
|
|
2504
2560
|
"Inline rows for each data result. This adds a data surcharge based on row count and dataset source. To estimate cost, search with include_contents disabled and inspect cards.content.export_pricing. This applies to every returned card; limit sources.data.count and sources.data.max_rows to control cost."
|
|
2505
2561
|
),
|
|
2506
|
-
mode:
|
|
2562
|
+
mode: z24.enum(["inline", "url"]).optional().describe(
|
|
2507
2563
|
"Requested data delivery mode. Search card data is always inline."
|
|
2508
2564
|
),
|
|
2509
|
-
content_format:
|
|
2510
|
-
max_rows:
|
|
2565
|
+
content_format: z24.enum(["card_json", "csv", "json_compact", "json_records"]).optional().describe("Serialization for inlined card data."),
|
|
2566
|
+
max_rows: z24.number().optional().describe(
|
|
2511
2567
|
"Maximum rows to inline per result. Omit to use the allowance in cards.content.export_pricing. A data surcharge applies per 1,000 exported rows; lower values reduce cost."
|
|
2512
2568
|
),
|
|
2513
|
-
node_ids:
|
|
2514
|
-
strict:
|
|
2569
|
+
node_ids: z24.array(z24.string()).optional().describe("Data Graph node IDs to prioritize. Maximum 20."),
|
|
2570
|
+
strict: z24.boolean().optional().describe(
|
|
2515
2571
|
"Only return cards matching node_ids. Requires a non-empty node_ids."
|
|
2516
2572
|
)
|
|
2517
2573
|
});
|
|
2518
|
-
var takoWebSourceInputSchema = () =>
|
|
2519
|
-
count:
|
|
2520
|
-
include_contents:
|
|
2521
|
-
category:
|
|
2522
|
-
include_domains:
|
|
2523
|
-
exclude_domains:
|
|
2524
|
-
snippet_max_chars:
|
|
2525
|
-
highlights:
|
|
2574
|
+
var takoWebSourceInputSchema = () => z24.object({
|
|
2575
|
+
count: z24.number().optional().describe("Maximum number of web results to return (1-20)."),
|
|
2576
|
+
include_contents: z24.boolean().optional().describe("Inline extracted web page text. This can add a data charge."),
|
|
2577
|
+
category: z24.enum(["finance", "news", "sports"]).optional().describe("Optional web-result category filter."),
|
|
2578
|
+
include_domains: z24.array(z24.string()).optional().describe("Only return results from these bare domains."),
|
|
2579
|
+
exclude_domains: z24.array(z24.string()).optional().describe("Exclude results from these bare domains."),
|
|
2580
|
+
snippet_max_chars: z24.number().optional().describe("Maximum characters in each web-result snippet."),
|
|
2581
|
+
highlights: z24.boolean().optional().describe(
|
|
2526
2582
|
"Include highlighted passages in web results. Defaults to true in AI Gateway."
|
|
2527
2583
|
),
|
|
2528
|
-
article_content_max_chars:
|
|
2584
|
+
article_content_max_chars: z24.number().optional().describe(
|
|
2529
2585
|
"Maximum extracted characters per web page when including contents."
|
|
2530
2586
|
),
|
|
2531
|
-
published_after:
|
|
2587
|
+
published_after: z24.string().optional().describe(
|
|
2532
2588
|
"Keep results published on or after this ISO date (YYYY-MM-DD)."
|
|
2533
2589
|
),
|
|
2534
|
-
published_before:
|
|
2590
|
+
published_before: z24.string().optional().describe(
|
|
2535
2591
|
"Keep results published on or before this ISO date (YYYY-MM-DD)."
|
|
2536
2592
|
)
|
|
2537
2593
|
});
|
|
2538
|
-
var takoSearchInputSchema =
|
|
2539
|
-
() =>
|
|
2540
|
-
|
|
2541
|
-
query:
|
|
2594
|
+
var takoSearchInputSchema = lazySchema22(
|
|
2595
|
+
() => zodSchema22(
|
|
2596
|
+
z24.object({
|
|
2597
|
+
query: z24.string().describe(
|
|
2542
2598
|
'Natural-language search query. Include the entity, metric, and time period. Quote a phrase to force it to one entity, for example "Tesla":PRODUCT price.'
|
|
2543
2599
|
),
|
|
2544
|
-
effort:
|
|
2600
|
+
effort: z24.enum(["deep", "fast", "instant"]).optional().describe(
|
|
2545
2601
|
"Search effort. fast is the balanced default, instant favors cached results and low latency, and deep broadens retrieval with reranking at higher cost and latency."
|
|
2546
2602
|
),
|
|
2547
|
-
sources:
|
|
2603
|
+
sources: z24.object({
|
|
2548
2604
|
data: takoDataSourceInputSchema().optional(),
|
|
2549
2605
|
web: takoWebSourceInputSchema().optional()
|
|
2550
2606
|
}).optional().describe(
|
|
2551
2607
|
"Sources to search. Omit to search both curated data and the web. When provided, only keys present are searched."
|
|
2552
2608
|
),
|
|
2553
|
-
location:
|
|
2554
|
-
latitude:
|
|
2555
|
-
longitude:
|
|
2609
|
+
location: z24.object({
|
|
2610
|
+
latitude: z24.number().describe("Latitude between -90 and 90."),
|
|
2611
|
+
longitude: z24.number().describe("Longitude between -180 and 180.")
|
|
2556
2612
|
}).optional().describe("End-user coordinates for localized results."),
|
|
2557
|
-
country_code:
|
|
2558
|
-
locale:
|
|
2559
|
-
timezone:
|
|
2560
|
-
output_settings:
|
|
2561
|
-
image_dark_mode:
|
|
2562
|
-
force_refresh:
|
|
2613
|
+
country_code: z24.string().optional().describe("Two-letter ISO 3166-1 country code, such as 'US'."),
|
|
2614
|
+
locale: z24.string().optional().describe("BCP-47 locale, such as 'en-US'."),
|
|
2615
|
+
timezone: z24.string().optional().describe("IANA timezone, such as 'America/New_York'."),
|
|
2616
|
+
output_settings: z24.object({
|
|
2617
|
+
image_dark_mode: z24.boolean().optional().describe("Render card preview images in dark mode."),
|
|
2618
|
+
force_refresh: z24.boolean().optional().describe(
|
|
2563
2619
|
"Instant-effort only. Request a refreshed instant result."
|
|
2564
2620
|
)
|
|
2565
2621
|
}).optional().describe("Controls card rendering in the search response."),
|
|
2566
|
-
include_related:
|
|
2622
|
+
include_related: z24.number().optional().describe("Maximum related search suggestions to include (1-20).")
|
|
2567
2623
|
})
|
|
2568
2624
|
)
|
|
2569
2625
|
);
|
|
2570
|
-
var takoDatasetCellSchema = () =>
|
|
2571
|
-
var takoResultContentSchema = () =>
|
|
2572
|
-
content_format:
|
|
2573
|
-
cost:
|
|
2574
|
-
data:
|
|
2575
|
-
records:
|
|
2576
|
-
dataset:
|
|
2577
|
-
columns:
|
|
2578
|
-
|
|
2579
|
-
name:
|
|
2580
|
-
type:
|
|
2581
|
-
unit:
|
|
2626
|
+
var takoDatasetCellSchema = () => z24.union([z24.boolean(), z24.number(), z24.string()]).nullable();
|
|
2627
|
+
var takoResultContentSchema = () => z24.object({
|
|
2628
|
+
content_format: z24.enum(["card_json", "csv", "json_compact", "json_records"]).nullish(),
|
|
2629
|
+
cost: z24.number().optional(),
|
|
2630
|
+
data: z24.string().nullish(),
|
|
2631
|
+
records: z24.array(z24.record(z24.string(), takoDatasetCellSchema())).nullish(),
|
|
2632
|
+
dataset: z24.object({
|
|
2633
|
+
columns: z24.array(
|
|
2634
|
+
z24.object({
|
|
2635
|
+
name: z24.string(),
|
|
2636
|
+
type: z24.enum(["boolean", "date", "datetime", "number", "string"]),
|
|
2637
|
+
unit: z24.string().nullish()
|
|
2582
2638
|
})
|
|
2583
2639
|
),
|
|
2584
|
-
rows:
|
|
2585
|
-
total_rows:
|
|
2586
|
-
truncated:
|
|
2587
|
-
ref:
|
|
2588
|
-
sources:
|
|
2589
|
-
|
|
2590
|
-
name:
|
|
2591
|
-
index:
|
|
2640
|
+
rows: z24.array(z24.array(takoDatasetCellSchema())),
|
|
2641
|
+
total_rows: z24.number(),
|
|
2642
|
+
truncated: z24.boolean(),
|
|
2643
|
+
ref: z24.string(),
|
|
2644
|
+
sources: z24.array(
|
|
2645
|
+
z24.object({
|
|
2646
|
+
name: z24.string(),
|
|
2647
|
+
index: z24.enum(["data", "web"]).optional()
|
|
2592
2648
|
})
|
|
2593
2649
|
),
|
|
2594
|
-
provenance:
|
|
2650
|
+
provenance: z24.enum(["query", "web_extraction"]).optional()
|
|
2595
2651
|
}).nullish(),
|
|
2596
|
-
card_data:
|
|
2597
|
-
card_data_schema:
|
|
2598
|
-
url:
|
|
2599
|
-
expires_at:
|
|
2600
|
-
total_rows:
|
|
2601
|
-
truncated:
|
|
2602
|
-
premium_rows:
|
|
2603
|
-
redacted_cells:
|
|
2604
|
-
total_matching:
|
|
2605
|
-
export_pricing:
|
|
2606
|
-
baseline_usd:
|
|
2607
|
-
free_rows:
|
|
2608
|
-
max_rows_ceiling:
|
|
2609
|
-
row_cpm_usd:
|
|
2610
|
-
premium_row_cpm_usd:
|
|
2611
|
-
variable_cost_max_usd:
|
|
2652
|
+
card_data: z24.object({}).passthrough().nullish(),
|
|
2653
|
+
card_data_schema: z24.object({}).passthrough().nullish(),
|
|
2654
|
+
url: z24.string().nullish(),
|
|
2655
|
+
expires_at: z24.string().nullish(),
|
|
2656
|
+
total_rows: z24.number().nullish(),
|
|
2657
|
+
truncated: z24.boolean().optional(),
|
|
2658
|
+
premium_rows: z24.record(z24.string(), z24.number()).nullish(),
|
|
2659
|
+
redacted_cells: z24.record(z24.string(), z24.array(z24.number())).nullish(),
|
|
2660
|
+
total_matching: z24.number().nullish(),
|
|
2661
|
+
export_pricing: z24.object({
|
|
2662
|
+
baseline_usd: z24.number(),
|
|
2663
|
+
free_rows: z24.number().optional(),
|
|
2664
|
+
max_rows_ceiling: z24.number(),
|
|
2665
|
+
row_cpm_usd: z24.number(),
|
|
2666
|
+
premium_row_cpm_usd: z24.record(z24.string(), z24.number()).nullish(),
|
|
2667
|
+
variable_cost_max_usd: z24.number().nullish()
|
|
2612
2668
|
}).passthrough().nullish(),
|
|
2613
|
-
manifest:
|
|
2614
|
-
|
|
2615
|
-
dtype:
|
|
2616
|
-
entity:
|
|
2617
|
-
metric:
|
|
2618
|
-
name:
|
|
2619
|
-
unit:
|
|
2669
|
+
manifest: z24.array(
|
|
2670
|
+
z24.object({
|
|
2671
|
+
dtype: z24.enum(["boolean", "date", "datetime", "number", "string"]).nullish(),
|
|
2672
|
+
entity: z24.string().nullish(),
|
|
2673
|
+
metric: z24.string().nullish(),
|
|
2674
|
+
name: z24.string().nullish(),
|
|
2675
|
+
unit: z24.string().nullish()
|
|
2620
2676
|
})
|
|
2621
2677
|
).nullish()
|
|
2622
2678
|
}).passthrough();
|
|
2623
|
-
var takoCardSchema = () =>
|
|
2624
|
-
card_id:
|
|
2625
|
-
title:
|
|
2626
|
-
description:
|
|
2627
|
-
semantic_description:
|
|
2628
|
-
webpage_url:
|
|
2629
|
-
image_url:
|
|
2630
|
-
embed_url:
|
|
2631
|
-
sources:
|
|
2632
|
-
|
|
2633
|
-
source_name:
|
|
2634
|
-
source_description:
|
|
2635
|
-
source_index:
|
|
2636
|
-
source_text:
|
|
2637
|
-
url:
|
|
2679
|
+
var takoCardSchema = () => z24.object({
|
|
2680
|
+
card_id: z24.string().nullish(),
|
|
2681
|
+
title: z24.string().nullish(),
|
|
2682
|
+
description: z24.string().nullish(),
|
|
2683
|
+
semantic_description: z24.string().nullish(),
|
|
2684
|
+
webpage_url: z24.string().nullish(),
|
|
2685
|
+
image_url: z24.string().nullish(),
|
|
2686
|
+
embed_url: z24.string().nullish(),
|
|
2687
|
+
sources: z24.array(
|
|
2688
|
+
z24.object({
|
|
2689
|
+
source_name: z24.string().nullish(),
|
|
2690
|
+
source_description: z24.string().nullish(),
|
|
2691
|
+
source_index: z24.enum(["data", "web"]),
|
|
2692
|
+
source_text: z24.string().nullish(),
|
|
2693
|
+
url: z24.string().nullish()
|
|
2638
2694
|
})
|
|
2639
2695
|
).nullish(),
|
|
2640
|
-
methodologies:
|
|
2641
|
-
|
|
2642
|
-
methodology_name:
|
|
2643
|
-
methodology_description:
|
|
2696
|
+
methodologies: z24.array(
|
|
2697
|
+
z24.object({
|
|
2698
|
+
methodology_name: z24.string().nullable(),
|
|
2699
|
+
methodology_description: z24.string().nullable()
|
|
2644
2700
|
})
|
|
2645
2701
|
).nullish(),
|
|
2646
|
-
source_indexes:
|
|
2647
|
-
card_type:
|
|
2648
|
-
relevance:
|
|
2649
|
-
relevance_score:
|
|
2702
|
+
source_indexes: z24.array(z24.enum(["data", "web"])).nullish(),
|
|
2703
|
+
card_type: z24.string().nullish(),
|
|
2704
|
+
relevance: z24.enum(["High", "Low", "Medium"]).nullish(),
|
|
2705
|
+
relevance_score: z24.number().nullish(),
|
|
2650
2706
|
content: takoResultContentSchema().nullish(),
|
|
2651
|
-
exportable:
|
|
2652
|
-
nodes:
|
|
2653
|
-
|
|
2654
|
-
id:
|
|
2655
|
-
type:
|
|
2656
|
-
name:
|
|
2657
|
-
description:
|
|
2707
|
+
exportable: z24.boolean().optional(),
|
|
2708
|
+
nodes: z24.array(
|
|
2709
|
+
z24.object({
|
|
2710
|
+
id: z24.string(),
|
|
2711
|
+
type: z24.enum(["entity", "metric"]),
|
|
2712
|
+
name: z24.string(),
|
|
2713
|
+
description: z24.string().nullish()
|
|
2658
2714
|
})
|
|
2659
2715
|
).nullish(),
|
|
2660
|
-
metric_definitions:
|
|
2661
|
-
data_freshness:
|
|
2662
|
-
coverage_end:
|
|
2663
|
-
data_as_of:
|
|
2664
|
-
last_updated:
|
|
2716
|
+
metric_definitions: z24.array(z24.object({ name: z24.string(), definition: z24.string() })).nullish(),
|
|
2717
|
+
data_freshness: z24.object({
|
|
2718
|
+
coverage_end: z24.string().nullish(),
|
|
2719
|
+
data_as_of: z24.string().nullish(),
|
|
2720
|
+
last_updated: z24.string().nullish()
|
|
2665
2721
|
}).nullish(),
|
|
2666
|
-
placeholder:
|
|
2667
|
-
withheld_source:
|
|
2668
|
-
reason:
|
|
2722
|
+
placeholder: z24.object({
|
|
2723
|
+
withheld_source: z24.string(),
|
|
2724
|
+
reason: z24.enum(["not_served", "over_cap"]).nullish()
|
|
2669
2725
|
}).passthrough().nullish()
|
|
2670
2726
|
}).passthrough();
|
|
2671
|
-
var takoWebResultSchema = () =>
|
|
2672
|
-
title:
|
|
2673
|
-
url:
|
|
2674
|
-
snippet:
|
|
2675
|
-
source_name:
|
|
2676
|
-
publish_date:
|
|
2727
|
+
var takoWebResultSchema = () => z24.object({
|
|
2728
|
+
title: z24.string(),
|
|
2729
|
+
url: z24.string(),
|
|
2730
|
+
snippet: z24.string().nullish(),
|
|
2731
|
+
source_name: z24.string().nullish(),
|
|
2732
|
+
publish_date: z24.string().nullish(),
|
|
2677
2733
|
content: takoResultContentSchema().nullish()
|
|
2678
2734
|
}).passthrough();
|
|
2679
|
-
var takoSearchOutputSchema =
|
|
2680
|
-
() =>
|
|
2681
|
-
|
|
2682
|
-
|
|
2683
|
-
request_id:
|
|
2684
|
-
cards:
|
|
2685
|
-
web_results:
|
|
2686
|
-
usage:
|
|
2687
|
-
total_cost_usd:
|
|
2688
|
-
compute:
|
|
2689
|
-
data:
|
|
2690
|
-
cost_usd:
|
|
2691
|
-
datasets:
|
|
2692
|
-
data_points:
|
|
2735
|
+
var takoSearchOutputSchema = lazySchema22(
|
|
2736
|
+
() => zodSchema22(
|
|
2737
|
+
z24.union([
|
|
2738
|
+
z24.object({
|
|
2739
|
+
request_id: z24.string(),
|
|
2740
|
+
cards: z24.array(takoCardSchema()).optional(),
|
|
2741
|
+
web_results: z24.array(takoWebResultSchema()).optional(),
|
|
2742
|
+
usage: z24.object({
|
|
2743
|
+
total_cost_usd: z24.number(),
|
|
2744
|
+
compute: z24.object({ cost_usd: z24.number() }).passthrough().nullish(),
|
|
2745
|
+
data: z24.object({
|
|
2746
|
+
cost_usd: z24.number(),
|
|
2747
|
+
datasets: z24.number(),
|
|
2748
|
+
data_points: z24.number().nullish()
|
|
2693
2749
|
}).passthrough().nullish(),
|
|
2694
|
-
variable_cost:
|
|
2750
|
+
variable_cost: z24.object({ cost_usd: z24.number() }).passthrough().nullish()
|
|
2695
2751
|
}).passthrough().nullish(),
|
|
2696
|
-
related:
|
|
2752
|
+
related: z24.array(z24.object({}).passthrough()).nullish()
|
|
2697
2753
|
}).passthrough(),
|
|
2698
2754
|
gatewayToolErrorSchema()
|
|
2699
2755
|
])
|
|
@@ -2772,22 +2828,22 @@ var gatewayTools = {
|
|
|
2772
2828
|
import { getContext } from "@vercel/oidc";
|
|
2773
2829
|
import { getVercelOidcToken } from "@vercel/oidc";
|
|
2774
2830
|
async function getVercelRequestId() {
|
|
2775
|
-
var
|
|
2776
|
-
return (
|
|
2831
|
+
var _a12;
|
|
2832
|
+
return (_a12 = getContext().headers) == null ? void 0 : _a12["x-vercel-id"];
|
|
2777
2833
|
}
|
|
2778
2834
|
|
|
2779
2835
|
// src/version.ts
|
|
2780
|
-
var VERSION = true ? "3.0.
|
|
2836
|
+
var VERSION = true ? "3.0.238" : "0.0.0-test";
|
|
2781
2837
|
|
|
2782
2838
|
// src/gateway-provider.ts
|
|
2783
2839
|
var AI_GATEWAY_PROTOCOL_VERSION = "0.0.1";
|
|
2784
2840
|
function createGatewayProvider(options = {}) {
|
|
2785
|
-
var
|
|
2841
|
+
var _a12, _b12;
|
|
2786
2842
|
let pendingMetadata = null;
|
|
2787
2843
|
let metadataCache = null;
|
|
2788
|
-
const cacheRefreshMillis = (
|
|
2844
|
+
const cacheRefreshMillis = (_a12 = options.metadataCacheRefreshMillis) != null ? _a12 : 1e3 * 60 * 5;
|
|
2789
2845
|
let lastFetchTime = 0;
|
|
2790
|
-
const baseURL = (
|
|
2846
|
+
const baseURL = (_b12 = withoutTrailingSlash(options.baseURL)) != null ? _b12 : "https://ai-gateway.vercel.sh/v3/ai";
|
|
2791
2847
|
const getHeaders = async () => {
|
|
2792
2848
|
try {
|
|
2793
2849
|
const auth = await getGatewayAuthToken(options);
|
|
@@ -2847,8 +2903,8 @@ function createGatewayProvider(options = {}) {
|
|
|
2847
2903
|
});
|
|
2848
2904
|
};
|
|
2849
2905
|
const getAvailableModels = async () => {
|
|
2850
|
-
var
|
|
2851
|
-
const now = (_c = (
|
|
2906
|
+
var _a13, _b13, _c;
|
|
2907
|
+
const now = (_c = (_b13 = (_a13 = options._internal) == null ? void 0 : _a13.currentDate) == null ? void 0 : _b13.call(_a13).getTime()) != null ? _c : Date.now();
|
|
2852
2908
|
if (!pendingMetadata || now - lastFetchTime > cacheRefreshMillis) {
|
|
2853
2909
|
lastFetchTime = now;
|
|
2854
2910
|
pendingMetadata = new GatewayFetchMetadata({
|
|
@@ -3005,6 +3061,7 @@ async function getGatewayAuthToken(options) {
|
|
|
3005
3061
|
};
|
|
3006
3062
|
}
|
|
3007
3063
|
export {
|
|
3064
|
+
GatewayAccessPolicyDeniedError,
|
|
3008
3065
|
GatewayAuthenticationError,
|
|
3009
3066
|
GatewayError,
|
|
3010
3067
|
GatewayFailedDependencyError,
|