@mastra/memory 1.1.0-alpha.1 → 1.2.0-alpha.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +112 -0
- package/dist/_types/@internal_ai-sdk-v4/dist/index.d.ts +30 -17
- package/dist/{chunk-FQJWVCDF.cjs → chunk-AWE2QQPI.cjs} +1884 -312
- package/dist/chunk-AWE2QQPI.cjs.map +1 -0
- package/dist/chunk-EQ4M72KU.js +439 -0
- package/dist/chunk-EQ4M72KU.js.map +1 -0
- package/dist/{chunk-O3CS4UGX.cjs → chunk-IDRQZVB4.cjs} +4 -4
- package/dist/{chunk-O3CS4UGX.cjs.map → chunk-IDRQZVB4.cjs.map} +1 -1
- package/dist/{chunk-YF4R74L2.js → chunk-RC6RZVYE.js} +4 -4
- package/dist/{chunk-YF4R74L2.js.map → chunk-RC6RZVYE.js.map} +1 -1
- package/dist/{chunk-6TXUWFIU.js → chunk-TYVPTNCP.js} +1885 -313
- package/dist/chunk-TYVPTNCP.js.map +1 -0
- package/dist/chunk-ZD3BKU5O.cjs +441 -0
- package/dist/chunk-ZD3BKU5O.cjs.map +1 -0
- package/dist/docs/SKILL.md +51 -50
- package/dist/docs/{SOURCE_MAP.json → assets/SOURCE_MAP.json} +22 -22
- package/dist/docs/{agents/03-agent-approval.md → references/docs-agents-agent-approval.md} +19 -19
- package/dist/docs/references/docs-agents-agent-memory.md +212 -0
- package/dist/docs/{agents/04-network-approval.md → references/docs-agents-network-approval.md} +13 -12
- package/dist/docs/{agents/02-networks.md → references/docs-agents-networks.md} +10 -12
- package/dist/docs/{memory/06-memory-processors.md → references/docs-memory-memory-processors.md} +6 -8
- package/dist/docs/{memory/03-message-history.md → references/docs-memory-message-history.md} +31 -20
- package/dist/docs/references/docs-memory-observational-memory.md +238 -0
- package/dist/docs/{memory/01-overview.md → references/docs-memory-overview.md} +8 -8
- package/dist/docs/{memory/05-semantic-recall.md → references/docs-memory-semantic-recall.md} +33 -17
- package/dist/docs/{memory/02-storage.md → references/docs-memory-storage.md} +29 -39
- package/dist/docs/{memory/04-working-memory.md → references/docs-memory-working-memory.md} +16 -27
- package/dist/docs/references/reference-core-getMemory.md +50 -0
- package/dist/docs/references/reference-core-listMemory.md +56 -0
- package/dist/docs/references/reference-memory-clone-utilities.md +199 -0
- package/dist/docs/references/reference-memory-cloneThread.md +130 -0
- package/dist/docs/references/reference-memory-createThread.md +68 -0
- package/dist/docs/references/reference-memory-getThreadById.md +24 -0
- package/dist/docs/references/reference-memory-listThreads.md +145 -0
- package/dist/docs/references/reference-memory-memory-class.md +147 -0
- package/dist/docs/references/reference-memory-observational-memory.md +528 -0
- package/dist/docs/{processors/01-reference.md → references/reference-processors-token-limiter-processor.md} +25 -12
- package/dist/docs/references/reference-storage-dynamodb.md +282 -0
- package/dist/docs/references/reference-storage-libsql.md +135 -0
- package/dist/docs/references/reference-storage-mongodb.md +262 -0
- package/dist/docs/references/reference-storage-postgresql.md +529 -0
- package/dist/docs/references/reference-storage-upstash.md +160 -0
- package/dist/docs/references/reference-vectors-libsql.md +305 -0
- package/dist/docs/references/reference-vectors-mongodb.md +295 -0
- package/dist/docs/references/reference-vectors-pg.md +408 -0
- package/dist/docs/references/reference-vectors-upstash.md +294 -0
- package/dist/index.cjs +919 -507
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +914 -502
- package/dist/index.js.map +1 -1
- package/dist/{observational-memory-3Q42SITP.cjs → observational-memory-3UO64HYD.cjs} +14 -14
- package/dist/{observational-memory-3Q42SITP.cjs.map → observational-memory-3UO64HYD.cjs.map} +1 -1
- package/dist/{observational-memory-VXLHOSDZ.js → observational-memory-TVHT3HP4.js} +3 -3
- package/dist/{observational-memory-VXLHOSDZ.js.map → observational-memory-TVHT3HP4.js.map} +1 -1
- package/dist/processors/index.cjs +12 -12
- package/dist/processors/index.js +1 -1
- package/dist/processors/observational-memory/index.d.ts +1 -1
- package/dist/processors/observational-memory/index.d.ts.map +1 -1
- package/dist/processors/observational-memory/observational-memory.d.ts +267 -1
- package/dist/processors/observational-memory/observational-memory.d.ts.map +1 -1
- package/dist/processors/observational-memory/observer-agent.d.ts +3 -1
- package/dist/processors/observational-memory/observer-agent.d.ts.map +1 -1
- package/dist/processors/observational-memory/reflector-agent.d.ts +10 -3
- package/dist/processors/observational-memory/reflector-agent.d.ts.map +1 -1
- package/dist/processors/observational-memory/types.d.ts +243 -19
- package/dist/processors/observational-memory/types.d.ts.map +1 -1
- package/dist/{token-6GSAFR2W-WGTMOPEU.js → token-APYSY3BW-2DN6RAUY.js} +11 -11
- package/dist/token-APYSY3BW-2DN6RAUY.js.map +1 -0
- package/dist/{token-6GSAFR2W-2B4WM6AQ.cjs → token-APYSY3BW-ZQ7TMBY7.cjs} +14 -14
- package/dist/token-APYSY3BW-ZQ7TMBY7.cjs.map +1 -0
- package/dist/token-util-RMHT2CPJ-6TGPE335.cjs +10 -0
- package/dist/token-util-RMHT2CPJ-6TGPE335.cjs.map +1 -0
- package/dist/token-util-RMHT2CPJ-RJEA3FAN.js +8 -0
- package/dist/token-util-RMHT2CPJ-RJEA3FAN.js.map +1 -0
- package/dist/tools/working-memory.d.ts.map +1 -1
- package/package.json +9 -10
- package/dist/chunk-6TXUWFIU.js.map +0 -1
- package/dist/chunk-FQJWVCDF.cjs.map +0 -1
- package/dist/chunk-WM6IIUQW.js +0 -250
- package/dist/chunk-WM6IIUQW.js.map +0 -1
- package/dist/chunk-ZSBBXHNM.cjs +0 -252
- package/dist/chunk-ZSBBXHNM.cjs.map +0 -1
- package/dist/docs/README.md +0 -36
- package/dist/docs/agents/01-agent-memory.md +0 -166
- package/dist/docs/core/01-reference.md +0 -114
- package/dist/docs/memory/07-reference.md +0 -687
- package/dist/docs/storage/01-reference.md +0 -1218
- package/dist/docs/vectors/01-reference.md +0 -942
- package/dist/token-6GSAFR2W-2B4WM6AQ.cjs.map +0 -1
- package/dist/token-6GSAFR2W-WGTMOPEU.js.map +0 -1
- package/dist/token-util-NEHG7TUY-TV2H7N56.js +0 -8
- package/dist/token-util-NEHG7TUY-TV2H7N56.js.map +0 -1
- package/dist/token-util-NEHG7TUY-WJZIPNNX.cjs +0 -10
- package/dist/token-util-NEHG7TUY-WJZIPNNX.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
'use strict';
|
|
2
2
|
|
|
3
3
|
var chunk23EXJLET_cjs = require('./chunk-23EXJLET.cjs');
|
|
4
|
-
var
|
|
4
|
+
var chunkIDRQZVB4_cjs = require('./chunk-IDRQZVB4.cjs');
|
|
5
|
+
var v3 = require('zod/v3');
|
|
5
6
|
var zod = require('zod');
|
|
6
7
|
var z4 = require('zod/v4');
|
|
7
|
-
var v3 = require('zod/v3');
|
|
8
8
|
var agent = require('@mastra/core/agent');
|
|
9
9
|
var features = require('@mastra/core/features');
|
|
10
10
|
var memory = require('@mastra/core/memory');
|
|
@@ -179,13 +179,13 @@ var _AISDKError = class _AISDKError2 extends Error {
|
|
|
179
179
|
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
180
180
|
*/
|
|
181
181
|
constructor({
|
|
182
|
-
name:
|
|
182
|
+
name: name145,
|
|
183
183
|
message,
|
|
184
184
|
cause
|
|
185
185
|
}) {
|
|
186
186
|
super(message);
|
|
187
187
|
this[_a] = true;
|
|
188
|
-
this.name =
|
|
188
|
+
this.name = name145;
|
|
189
189
|
this.cause = cause;
|
|
190
190
|
}
|
|
191
191
|
/**
|
|
@@ -196,8 +196,8 @@ var _AISDKError = class _AISDKError2 extends Error {
|
|
|
196
196
|
static isInstance(error) {
|
|
197
197
|
return _AISDKError2.hasMarker(error, marker);
|
|
198
198
|
}
|
|
199
|
-
static hasMarker(error,
|
|
200
|
-
const markerSymbol = Symbol.for(
|
|
199
|
+
static hasMarker(error, marker155) {
|
|
200
|
+
const markerSymbol = Symbol.for(marker155);
|
|
201
201
|
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
202
202
|
}
|
|
203
203
|
};
|
|
@@ -499,11 +499,11 @@ var getRefs = (options) => {
|
|
|
499
499
|
flags: { hasReferencedOpenAiAnyType: false },
|
|
500
500
|
currentPath,
|
|
501
501
|
propertyPath: void 0,
|
|
502
|
-
seen: new Map(Object.entries(_options.definitions).map(([
|
|
502
|
+
seen: new Map(Object.entries(_options.definitions).map(([name173, def]) => [
|
|
503
503
|
def._def,
|
|
504
504
|
{
|
|
505
505
|
def: def._def,
|
|
506
|
-
path: [..._options.basePath, _options.definitionPath,
|
|
506
|
+
path: [..._options.basePath, _options.definitionPath, name173],
|
|
507
507
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
508
508
|
jsonSchema: void 0
|
|
509
509
|
}
|
|
@@ -550,7 +550,7 @@ function parseArrayDef(def, refs) {
|
|
|
550
550
|
const res = {
|
|
551
551
|
type: "array"
|
|
552
552
|
};
|
|
553
|
-
if (def.type?._def && def.type?._def?.typeName !==
|
|
553
|
+
if (def.type?._def && def.type?._def?.typeName !== v3.ZodFirstPartyTypeKind.ZodAny) {
|
|
554
554
|
res.items = parseDef(def.type._def, {
|
|
555
555
|
...refs,
|
|
556
556
|
currentPath: [...refs.currentPath, "items"]
|
|
@@ -1067,7 +1067,7 @@ function parseRecordDef(def, refs) {
|
|
|
1067
1067
|
if (refs.target === "openAi") {
|
|
1068
1068
|
console.warn("Warning: OpenAI may not support records in schemas! Try an array of key-value pairs instead.");
|
|
1069
1069
|
}
|
|
1070
|
-
if (refs.target === "openApi3" && def.keyType?._def.typeName ===
|
|
1070
|
+
if (refs.target === "openApi3" && def.keyType?._def.typeName === v3.ZodFirstPartyTypeKind.ZodEnum) {
|
|
1071
1071
|
return {
|
|
1072
1072
|
type: "object",
|
|
1073
1073
|
required: def.keyType._def.values,
|
|
@@ -1091,20 +1091,20 @@ function parseRecordDef(def, refs) {
|
|
|
1091
1091
|
if (refs.target === "openApi3") {
|
|
1092
1092
|
return schema;
|
|
1093
1093
|
}
|
|
1094
|
-
if (def.keyType?._def.typeName ===
|
|
1094
|
+
if (def.keyType?._def.typeName === v3.ZodFirstPartyTypeKind.ZodString && def.keyType._def.checks?.length) {
|
|
1095
1095
|
const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
|
|
1096
1096
|
return {
|
|
1097
1097
|
...schema,
|
|
1098
1098
|
propertyNames: keyType
|
|
1099
1099
|
};
|
|
1100
|
-
} else if (def.keyType?._def.typeName ===
|
|
1100
|
+
} else if (def.keyType?._def.typeName === v3.ZodFirstPartyTypeKind.ZodEnum) {
|
|
1101
1101
|
return {
|
|
1102
1102
|
...schema,
|
|
1103
1103
|
propertyNames: {
|
|
1104
1104
|
enum: def.keyType._def.values
|
|
1105
1105
|
}
|
|
1106
1106
|
};
|
|
1107
|
-
} else if (def.keyType?._def.typeName ===
|
|
1107
|
+
} else if (def.keyType?._def.typeName === v3.ZodFirstPartyTypeKind.ZodBranded && def.keyType._def.type._def.typeName === v3.ZodFirstPartyTypeKind.ZodString && def.keyType._def.type._def.checks?.length) {
|
|
1108
1108
|
const { type, ...keyType } = parseBrandedDef(def.keyType._def, refs);
|
|
1109
1109
|
return {
|
|
1110
1110
|
...schema,
|
|
@@ -1470,73 +1470,73 @@ var parseReadonlyDef = (def, refs) => {
|
|
|
1470
1470
|
};
|
|
1471
1471
|
var selectParser = (def, typeName, refs) => {
|
|
1472
1472
|
switch (typeName) {
|
|
1473
|
-
case
|
|
1473
|
+
case v3.ZodFirstPartyTypeKind.ZodString:
|
|
1474
1474
|
return parseStringDef(def, refs);
|
|
1475
|
-
case
|
|
1475
|
+
case v3.ZodFirstPartyTypeKind.ZodNumber:
|
|
1476
1476
|
return parseNumberDef(def, refs);
|
|
1477
|
-
case
|
|
1477
|
+
case v3.ZodFirstPartyTypeKind.ZodObject:
|
|
1478
1478
|
return parseObjectDef(def, refs);
|
|
1479
|
-
case
|
|
1479
|
+
case v3.ZodFirstPartyTypeKind.ZodBigInt:
|
|
1480
1480
|
return parseBigintDef(def, refs);
|
|
1481
|
-
case
|
|
1481
|
+
case v3.ZodFirstPartyTypeKind.ZodBoolean:
|
|
1482
1482
|
return parseBooleanDef();
|
|
1483
|
-
case
|
|
1483
|
+
case v3.ZodFirstPartyTypeKind.ZodDate:
|
|
1484
1484
|
return parseDateDef(def, refs);
|
|
1485
|
-
case
|
|
1485
|
+
case v3.ZodFirstPartyTypeKind.ZodUndefined:
|
|
1486
1486
|
return parseUndefinedDef(refs);
|
|
1487
|
-
case
|
|
1487
|
+
case v3.ZodFirstPartyTypeKind.ZodNull:
|
|
1488
1488
|
return parseNullDef(refs);
|
|
1489
|
-
case
|
|
1489
|
+
case v3.ZodFirstPartyTypeKind.ZodArray:
|
|
1490
1490
|
return parseArrayDef(def, refs);
|
|
1491
|
-
case
|
|
1492
|
-
case
|
|
1491
|
+
case v3.ZodFirstPartyTypeKind.ZodUnion:
|
|
1492
|
+
case v3.ZodFirstPartyTypeKind.ZodDiscriminatedUnion:
|
|
1493
1493
|
return parseUnionDef(def, refs);
|
|
1494
|
-
case
|
|
1494
|
+
case v3.ZodFirstPartyTypeKind.ZodIntersection:
|
|
1495
1495
|
return parseIntersectionDef(def, refs);
|
|
1496
|
-
case
|
|
1496
|
+
case v3.ZodFirstPartyTypeKind.ZodTuple:
|
|
1497
1497
|
return parseTupleDef(def, refs);
|
|
1498
|
-
case
|
|
1498
|
+
case v3.ZodFirstPartyTypeKind.ZodRecord:
|
|
1499
1499
|
return parseRecordDef(def, refs);
|
|
1500
|
-
case
|
|
1500
|
+
case v3.ZodFirstPartyTypeKind.ZodLiteral:
|
|
1501
1501
|
return parseLiteralDef(def, refs);
|
|
1502
|
-
case
|
|
1502
|
+
case v3.ZodFirstPartyTypeKind.ZodEnum:
|
|
1503
1503
|
return parseEnumDef(def);
|
|
1504
|
-
case
|
|
1504
|
+
case v3.ZodFirstPartyTypeKind.ZodNativeEnum:
|
|
1505
1505
|
return parseNativeEnumDef(def);
|
|
1506
|
-
case
|
|
1506
|
+
case v3.ZodFirstPartyTypeKind.ZodNullable:
|
|
1507
1507
|
return parseNullableDef(def, refs);
|
|
1508
|
-
case
|
|
1508
|
+
case v3.ZodFirstPartyTypeKind.ZodOptional:
|
|
1509
1509
|
return parseOptionalDef(def, refs);
|
|
1510
|
-
case
|
|
1510
|
+
case v3.ZodFirstPartyTypeKind.ZodMap:
|
|
1511
1511
|
return parseMapDef(def, refs);
|
|
1512
|
-
case
|
|
1512
|
+
case v3.ZodFirstPartyTypeKind.ZodSet:
|
|
1513
1513
|
return parseSetDef(def, refs);
|
|
1514
|
-
case
|
|
1514
|
+
case v3.ZodFirstPartyTypeKind.ZodLazy:
|
|
1515
1515
|
return () => def.getter()._def;
|
|
1516
|
-
case
|
|
1516
|
+
case v3.ZodFirstPartyTypeKind.ZodPromise:
|
|
1517
1517
|
return parsePromiseDef(def, refs);
|
|
1518
|
-
case
|
|
1519
|
-
case
|
|
1518
|
+
case v3.ZodFirstPartyTypeKind.ZodNaN:
|
|
1519
|
+
case v3.ZodFirstPartyTypeKind.ZodNever:
|
|
1520
1520
|
return parseNeverDef(refs);
|
|
1521
|
-
case
|
|
1521
|
+
case v3.ZodFirstPartyTypeKind.ZodEffects:
|
|
1522
1522
|
return parseEffectsDef(def, refs);
|
|
1523
|
-
case
|
|
1523
|
+
case v3.ZodFirstPartyTypeKind.ZodAny:
|
|
1524
1524
|
return parseAnyDef(refs);
|
|
1525
|
-
case
|
|
1525
|
+
case v3.ZodFirstPartyTypeKind.ZodUnknown:
|
|
1526
1526
|
return parseUnknownDef(refs);
|
|
1527
|
-
case
|
|
1527
|
+
case v3.ZodFirstPartyTypeKind.ZodDefault:
|
|
1528
1528
|
return parseDefaultDef(def, refs);
|
|
1529
|
-
case
|
|
1529
|
+
case v3.ZodFirstPartyTypeKind.ZodBranded:
|
|
1530
1530
|
return parseBrandedDef(def, refs);
|
|
1531
|
-
case
|
|
1531
|
+
case v3.ZodFirstPartyTypeKind.ZodReadonly:
|
|
1532
1532
|
return parseReadonlyDef(def, refs);
|
|
1533
|
-
case
|
|
1533
|
+
case v3.ZodFirstPartyTypeKind.ZodCatch:
|
|
1534
1534
|
return parseCatchDef(def, refs);
|
|
1535
|
-
case
|
|
1535
|
+
case v3.ZodFirstPartyTypeKind.ZodPipeline:
|
|
1536
1536
|
return parsePipelineDef(def, refs);
|
|
1537
|
-
case
|
|
1538
|
-
case
|
|
1539
|
-
case
|
|
1537
|
+
case v3.ZodFirstPartyTypeKind.ZodFunction:
|
|
1538
|
+
case v3.ZodFirstPartyTypeKind.ZodVoid:
|
|
1539
|
+
case v3.ZodFirstPartyTypeKind.ZodSymbol:
|
|
1540
1540
|
return void 0;
|
|
1541
1541
|
default:
|
|
1542
1542
|
return /* @__PURE__ */ ((_) => void 0)();
|
|
@@ -1598,17 +1598,17 @@ var addMeta = (def, refs, jsonSchema22) => {
|
|
|
1598
1598
|
};
|
|
1599
1599
|
var zodToJsonSchema = (schema, options) => {
|
|
1600
1600
|
const refs = getRefs(options);
|
|
1601
|
-
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [
|
|
1601
|
+
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce((acc, [name183, schema2]) => ({
|
|
1602
1602
|
...acc,
|
|
1603
|
-
[
|
|
1603
|
+
[name183]: parseDef(schema2._def, {
|
|
1604
1604
|
...refs,
|
|
1605
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
1605
|
+
currentPath: [...refs.basePath, refs.definitionPath, name183]
|
|
1606
1606
|
}, true) ?? parseAnyDef(refs)
|
|
1607
1607
|
}), {}) : void 0;
|
|
1608
|
-
const
|
|
1609
|
-
const main = parseDef(schema._def,
|
|
1608
|
+
const name173 = typeof options === "string" ? options : options?.nameStrategy === "title" ? void 0 : options?.name;
|
|
1609
|
+
const main = parseDef(schema._def, name173 === void 0 ? refs : {
|
|
1610
1610
|
...refs,
|
|
1611
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
1611
|
+
currentPath: [...refs.basePath, refs.definitionPath, name173]
|
|
1612
1612
|
}, false) ?? parseAnyDef(refs);
|
|
1613
1613
|
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
1614
1614
|
if (title !== void 0) {
|
|
@@ -1632,18 +1632,18 @@ var zodToJsonSchema = (schema, options) => {
|
|
|
1632
1632
|
};
|
|
1633
1633
|
}
|
|
1634
1634
|
}
|
|
1635
|
-
const combined =
|
|
1635
|
+
const combined = name173 === void 0 ? definitions ? {
|
|
1636
1636
|
...main,
|
|
1637
1637
|
[refs.definitionPath]: definitions
|
|
1638
1638
|
} : main : {
|
|
1639
1639
|
$ref: [
|
|
1640
1640
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
1641
1641
|
refs.definitionPath,
|
|
1642
|
-
|
|
1642
|
+
name173
|
|
1643
1643
|
].join("/"),
|
|
1644
1644
|
[refs.definitionPath]: {
|
|
1645
1645
|
...definitions,
|
|
1646
|
-
[
|
|
1646
|
+
[name173]: main
|
|
1647
1647
|
}
|
|
1648
1648
|
};
|
|
1649
1649
|
if (refs.target === "jsonSchema7") {
|
|
@@ -2251,8 +2251,8 @@ function formatDataStreamPart(type, value) {
|
|
|
2251
2251
|
`;
|
|
2252
2252
|
}
|
|
2253
2253
|
function zodSchema(zodSchema22, options) {
|
|
2254
|
-
var
|
|
2255
|
-
const useReferences = (
|
|
2254
|
+
var _a173;
|
|
2255
|
+
const useReferences = (_a173 = void 0 ) != null ? _a173 : false;
|
|
2256
2256
|
return jsonSchema(
|
|
2257
2257
|
esm_default(zodSchema22, {
|
|
2258
2258
|
$refStrategy: useReferences ? "root" : "none",
|
|
@@ -2357,11 +2357,11 @@ var major = VERSION.split(".")[0];
|
|
|
2357
2357
|
var GLOBAL_OPENTELEMETRY_API_KEY = /* @__PURE__ */ Symbol.for("opentelemetry.js.api." + major);
|
|
2358
2358
|
var _global = _globalThis;
|
|
2359
2359
|
function registerGlobal(type, instance, diag, allowOverride) {
|
|
2360
|
-
var
|
|
2360
|
+
var _a173;
|
|
2361
2361
|
if (allowOverride === void 0) {
|
|
2362
2362
|
allowOverride = false;
|
|
2363
2363
|
}
|
|
2364
|
-
var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (
|
|
2364
|
+
var api = _global[GLOBAL_OPENTELEMETRY_API_KEY] = (_a173 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) !== null && _a173 !== void 0 ? _a173 : {
|
|
2365
2365
|
version: VERSION
|
|
2366
2366
|
};
|
|
2367
2367
|
if (!allowOverride && api[type]) {
|
|
@@ -2379,8 +2379,8 @@ function registerGlobal(type, instance, diag, allowOverride) {
|
|
|
2379
2379
|
return true;
|
|
2380
2380
|
}
|
|
2381
2381
|
function getGlobal(type) {
|
|
2382
|
-
var
|
|
2383
|
-
var globalVersion = (
|
|
2382
|
+
var _a173, _b17;
|
|
2383
|
+
var globalVersion = (_a173 = _global[GLOBAL_OPENTELEMETRY_API_KEY]) === null || _a173 === void 0 ? void 0 : _a173.version;
|
|
2384
2384
|
if (!globalVersion || !isCompatible(globalVersion)) {
|
|
2385
2385
|
return;
|
|
2386
2386
|
}
|
|
@@ -2549,13 +2549,13 @@ var DiagAPI = (
|
|
|
2549
2549
|
}
|
|
2550
2550
|
var self = this;
|
|
2551
2551
|
var setLogger = function(logger, optionsOrLogLevel) {
|
|
2552
|
-
var
|
|
2552
|
+
var _a173, _b17, _c;
|
|
2553
2553
|
if (optionsOrLogLevel === void 0) {
|
|
2554
2554
|
optionsOrLogLevel = { logLevel: DiagLogLevel.INFO };
|
|
2555
2555
|
}
|
|
2556
2556
|
if (logger === self) {
|
|
2557
2557
|
var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
2558
|
-
self.error((
|
|
2558
|
+
self.error((_a173 = err.stack) !== null && _a173 !== void 0 ? _a173 : err.message);
|
|
2559
2559
|
return false;
|
|
2560
2560
|
}
|
|
2561
2561
|
if (typeof optionsOrLogLevel === "number") {
|
|
@@ -2607,14 +2607,14 @@ var BaseContext = (
|
|
|
2607
2607
|
return self._currentContext.get(key);
|
|
2608
2608
|
};
|
|
2609
2609
|
self.setValue = function(key, value) {
|
|
2610
|
-
var
|
|
2611
|
-
|
|
2612
|
-
return
|
|
2610
|
+
var context2 = new BaseContext22(self._currentContext);
|
|
2611
|
+
context2._currentContext.set(key, value);
|
|
2612
|
+
return context2;
|
|
2613
2613
|
};
|
|
2614
2614
|
self.deleteValue = function(key) {
|
|
2615
|
-
var
|
|
2616
|
-
|
|
2617
|
-
return
|
|
2615
|
+
var context2 = new BaseContext22(self._currentContext);
|
|
2616
|
+
context2._currentContext.delete(key);
|
|
2617
|
+
return context2;
|
|
2618
2618
|
};
|
|
2619
2619
|
}
|
|
2620
2620
|
return BaseContext22;
|
|
@@ -2719,16 +2719,16 @@ var ContextAPI = (
|
|
|
2719
2719
|
ContextAPI22.prototype.active = function() {
|
|
2720
2720
|
return this._getContextManager().active();
|
|
2721
2721
|
};
|
|
2722
|
-
ContextAPI22.prototype.with = function(
|
|
2723
|
-
var
|
|
2722
|
+
ContextAPI22.prototype.with = function(context2, fn, thisArg) {
|
|
2723
|
+
var _a173;
|
|
2724
2724
|
var args = [];
|
|
2725
2725
|
for (var _i = 3; _i < arguments.length; _i++) {
|
|
2726
2726
|
args[_i - 3] = arguments[_i];
|
|
2727
2727
|
}
|
|
2728
|
-
return (
|
|
2728
|
+
return (_a173 = this._getContextManager()).with.apply(_a173, __spreadArray4([context2, fn, thisArg], __read4(args), false));
|
|
2729
2729
|
};
|
|
2730
|
-
ContextAPI22.prototype.bind = function(
|
|
2731
|
-
return this._getContextManager().bind(
|
|
2730
|
+
ContextAPI22.prototype.bind = function(context2, target) {
|
|
2731
|
+
return this._getContextManager().bind(context2, target);
|
|
2732
2732
|
};
|
|
2733
2733
|
ContextAPI22.prototype._getContextManager = function() {
|
|
2734
2734
|
return getGlobal(API_NAME2) || NOOP_CONTEXT_MANAGER;
|
|
@@ -2796,24 +2796,24 @@ var NonRecordingSpan = (
|
|
|
2796
2796
|
})()
|
|
2797
2797
|
);
|
|
2798
2798
|
var SPAN_KEY = createContextKey("OpenTelemetry Context Key SPAN");
|
|
2799
|
-
function getSpan(
|
|
2800
|
-
return
|
|
2799
|
+
function getSpan(context2) {
|
|
2800
|
+
return context2.getValue(SPAN_KEY) || void 0;
|
|
2801
2801
|
}
|
|
2802
2802
|
function getActiveSpan() {
|
|
2803
2803
|
return getSpan(ContextAPI.getInstance().active());
|
|
2804
2804
|
}
|
|
2805
|
-
function setSpan(
|
|
2806
|
-
return
|
|
2805
|
+
function setSpan(context2, span) {
|
|
2806
|
+
return context2.setValue(SPAN_KEY, span);
|
|
2807
2807
|
}
|
|
2808
|
-
function deleteSpan(
|
|
2809
|
-
return
|
|
2808
|
+
function deleteSpan(context2) {
|
|
2809
|
+
return context2.deleteValue(SPAN_KEY);
|
|
2810
2810
|
}
|
|
2811
|
-
function setSpanContext(
|
|
2812
|
-
return setSpan(
|
|
2811
|
+
function setSpanContext(context2, spanContext) {
|
|
2812
|
+
return setSpan(context2, new NonRecordingSpan(spanContext));
|
|
2813
2813
|
}
|
|
2814
|
-
function getSpanContext(
|
|
2815
|
-
var
|
|
2816
|
-
return (
|
|
2814
|
+
function getSpanContext(context2) {
|
|
2815
|
+
var _a173;
|
|
2816
|
+
return (_a173 = getSpan(context2)) === null || _a173 === void 0 ? void 0 : _a173.spanContext();
|
|
2817
2817
|
}
|
|
2818
2818
|
var VALID_TRACEID_REGEX = /^([0-9a-f]{32})$/i;
|
|
2819
2819
|
var VALID_SPANID_REGEX = /^[0-9a-f]{16}$/i;
|
|
@@ -2835,22 +2835,22 @@ var NoopTracer = (
|
|
|
2835
2835
|
(function() {
|
|
2836
2836
|
function NoopTracer22() {
|
|
2837
2837
|
}
|
|
2838
|
-
NoopTracer22.prototype.startSpan = function(
|
|
2839
|
-
if (
|
|
2840
|
-
|
|
2838
|
+
NoopTracer22.prototype.startSpan = function(name173, options, context2) {
|
|
2839
|
+
if (context2 === void 0) {
|
|
2840
|
+
context2 = contextApi.active();
|
|
2841
2841
|
}
|
|
2842
2842
|
var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
|
|
2843
2843
|
if (root) {
|
|
2844
2844
|
return new NonRecordingSpan();
|
|
2845
2845
|
}
|
|
2846
|
-
var parentFromContext =
|
|
2846
|
+
var parentFromContext = context2 && getSpanContext(context2);
|
|
2847
2847
|
if (isSpanContext(parentFromContext) && isSpanContextValid(parentFromContext)) {
|
|
2848
2848
|
return new NonRecordingSpan(parentFromContext);
|
|
2849
2849
|
} else {
|
|
2850
2850
|
return new NonRecordingSpan();
|
|
2851
2851
|
}
|
|
2852
2852
|
};
|
|
2853
|
-
NoopTracer22.prototype.startActiveSpan = function(
|
|
2853
|
+
NoopTracer22.prototype.startActiveSpan = function(name173, arg2, arg3, arg4) {
|
|
2854
2854
|
var opts;
|
|
2855
2855
|
var ctx;
|
|
2856
2856
|
var fn;
|
|
@@ -2867,7 +2867,7 @@ var NoopTracer = (
|
|
|
2867
2867
|
fn = arg4;
|
|
2868
2868
|
}
|
|
2869
2869
|
var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi.active();
|
|
2870
|
-
var span = this.startSpan(
|
|
2870
|
+
var span = this.startSpan(name173, opts, parentContext);
|
|
2871
2871
|
var contextWithSpanSet = setSpan(parentContext, span);
|
|
2872
2872
|
return contextApi.with(contextWithSpanSet, fn, void 0, span);
|
|
2873
2873
|
};
|
|
@@ -2881,14 +2881,14 @@ var NOOP_TRACER = new NoopTracer();
|
|
|
2881
2881
|
var ProxyTracer = (
|
|
2882
2882
|
/** @class */
|
|
2883
2883
|
(function() {
|
|
2884
|
-
function ProxyTracer22(_provider,
|
|
2884
|
+
function ProxyTracer22(_provider, name173, version, options) {
|
|
2885
2885
|
this._provider = _provider;
|
|
2886
|
-
this.name =
|
|
2886
|
+
this.name = name173;
|
|
2887
2887
|
this.version = version;
|
|
2888
2888
|
this.options = options;
|
|
2889
2889
|
}
|
|
2890
|
-
ProxyTracer22.prototype.startSpan = function(
|
|
2891
|
-
return this._getTracer().startSpan(
|
|
2890
|
+
ProxyTracer22.prototype.startSpan = function(name173, options, context2) {
|
|
2891
|
+
return this._getTracer().startSpan(name173, options, context2);
|
|
2892
2892
|
};
|
|
2893
2893
|
ProxyTracer22.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
|
|
2894
2894
|
var tracer = this._getTracer();
|
|
@@ -2925,20 +2925,20 @@ var ProxyTracerProvider = (
|
|
|
2925
2925
|
(function() {
|
|
2926
2926
|
function ProxyTracerProvider22() {
|
|
2927
2927
|
}
|
|
2928
|
-
ProxyTracerProvider22.prototype.getTracer = function(
|
|
2929
|
-
var
|
|
2930
|
-
return (
|
|
2928
|
+
ProxyTracerProvider22.prototype.getTracer = function(name173, version, options) {
|
|
2929
|
+
var _a173;
|
|
2930
|
+
return (_a173 = this.getDelegateTracer(name173, version, options)) !== null && _a173 !== void 0 ? _a173 : new ProxyTracer(this, name173, version, options);
|
|
2931
2931
|
};
|
|
2932
2932
|
ProxyTracerProvider22.prototype.getDelegate = function() {
|
|
2933
|
-
var
|
|
2934
|
-
return (
|
|
2933
|
+
var _a173;
|
|
2934
|
+
return (_a173 = this._delegate) !== null && _a173 !== void 0 ? _a173 : NOOP_TRACER_PROVIDER;
|
|
2935
2935
|
};
|
|
2936
2936
|
ProxyTracerProvider22.prototype.setDelegate = function(delegate) {
|
|
2937
2937
|
this._delegate = delegate;
|
|
2938
2938
|
};
|
|
2939
|
-
ProxyTracerProvider22.prototype.getDelegateTracer = function(
|
|
2940
|
-
var
|
|
2941
|
-
return (
|
|
2939
|
+
ProxyTracerProvider22.prototype.getDelegateTracer = function(name173, version, options) {
|
|
2940
|
+
var _a173;
|
|
2941
|
+
return (_a173 = this._delegate) === null || _a173 === void 0 ? void 0 : _a173.getTracer(name173, version, options);
|
|
2942
2942
|
};
|
|
2943
2943
|
return ProxyTracerProvider22;
|
|
2944
2944
|
})()
|
|
@@ -2980,8 +2980,8 @@ var TraceAPI = (
|
|
|
2980
2980
|
TraceAPI22.prototype.getTracerProvider = function() {
|
|
2981
2981
|
return getGlobal(API_NAME3) || this._proxyTracerProvider;
|
|
2982
2982
|
};
|
|
2983
|
-
TraceAPI22.prototype.getTracer = function(
|
|
2984
|
-
return this.getTracerProvider().getTracer(
|
|
2983
|
+
TraceAPI22.prototype.getTracer = function(name173, version) {
|
|
2984
|
+
return this.getTracerProvider().getTracer(name173, version);
|
|
2985
2985
|
};
|
|
2986
2986
|
TraceAPI22.prototype.disable = function() {
|
|
2987
2987
|
unregisterGlobal(API_NAME3, DiagAPI.instance());
|
|
@@ -2993,8 +2993,8 @@ var TraceAPI = (
|
|
|
2993
2993
|
var trace = TraceAPI.getInstance();
|
|
2994
2994
|
var __defProp2 = Object.defineProperty;
|
|
2995
2995
|
var __export = (target, all) => {
|
|
2996
|
-
for (var
|
|
2997
|
-
__defProp2(target,
|
|
2996
|
+
for (var name173 in all)
|
|
2997
|
+
__defProp2(target, name173, { get: all[name173], enumerable: true });
|
|
2998
2998
|
};
|
|
2999
2999
|
function prepareResponseHeaders(headers, {
|
|
3000
3000
|
contentType,
|
|
@@ -3156,7 +3156,7 @@ function getBaseTelemetryAttributes({
|
|
|
3156
3156
|
telemetry,
|
|
3157
3157
|
headers
|
|
3158
3158
|
}) {
|
|
3159
|
-
var
|
|
3159
|
+
var _a173;
|
|
3160
3160
|
return {
|
|
3161
3161
|
"ai.model.provider": model.provider,
|
|
3162
3162
|
"ai.model.id": model.modelId,
|
|
@@ -3166,7 +3166,7 @@ function getBaseTelemetryAttributes({
|
|
|
3166
3166
|
return attributes;
|
|
3167
3167
|
}, {}),
|
|
3168
3168
|
// add metadata as attributes:
|
|
3169
|
-
...Object.entries((
|
|
3169
|
+
...Object.entries((_a173 = telemetry == null ? void 0 : telemetry.metadata) != null ? _a173 : {}).reduce(
|
|
3170
3170
|
(attributes, [key, value]) => {
|
|
3171
3171
|
attributes[`ai.telemetry.metadata.${key}`] = value;
|
|
3172
3172
|
return attributes;
|
|
@@ -3186,7 +3186,7 @@ var noopTracer = {
|
|
|
3186
3186
|
startSpan() {
|
|
3187
3187
|
return noopSpan;
|
|
3188
3188
|
},
|
|
3189
|
-
startActiveSpan(
|
|
3189
|
+
startActiveSpan(name173, arg1, arg2, arg3) {
|
|
3190
3190
|
if (typeof arg1 === "function") {
|
|
3191
3191
|
return arg1(noopSpan);
|
|
3192
3192
|
}
|
|
@@ -3251,13 +3251,13 @@ function getTracer({
|
|
|
3251
3251
|
return trace.getTracer("ai");
|
|
3252
3252
|
}
|
|
3253
3253
|
function recordSpan({
|
|
3254
|
-
name:
|
|
3254
|
+
name: name173,
|
|
3255
3255
|
tracer,
|
|
3256
3256
|
attributes,
|
|
3257
3257
|
fn,
|
|
3258
3258
|
endWhenDone = true
|
|
3259
3259
|
}) {
|
|
3260
|
-
return tracer.startActiveSpan(
|
|
3260
|
+
return tracer.startActiveSpan(name173, { attributes }, async (span) => {
|
|
3261
3261
|
try {
|
|
3262
3262
|
const result = await fn(span);
|
|
3263
3263
|
if (endWhenDone) {
|
|
@@ -3382,14 +3382,14 @@ async function embedMany({
|
|
|
3382
3382
|
}),
|
|
3383
3383
|
tracer,
|
|
3384
3384
|
fn: async (doEmbedSpan) => {
|
|
3385
|
-
var
|
|
3385
|
+
var _a173;
|
|
3386
3386
|
const modelResponse = await model.doEmbed({
|
|
3387
3387
|
values,
|
|
3388
3388
|
abortSignal,
|
|
3389
3389
|
headers
|
|
3390
3390
|
});
|
|
3391
3391
|
const embeddings3 = modelResponse.embeddings;
|
|
3392
|
-
const usage2 = (
|
|
3392
|
+
const usage2 = (_a173 = modelResponse.usage) != null ? _a173 : { tokens: NaN };
|
|
3393
3393
|
doEmbedSpan.setAttributes(
|
|
3394
3394
|
selectTelemetryAttributes({
|
|
3395
3395
|
telemetry,
|
|
@@ -3441,14 +3441,14 @@ async function embedMany({
|
|
|
3441
3441
|
}),
|
|
3442
3442
|
tracer,
|
|
3443
3443
|
fn: async (doEmbedSpan) => {
|
|
3444
|
-
var
|
|
3444
|
+
var _a173;
|
|
3445
3445
|
const modelResponse = await model.doEmbed({
|
|
3446
3446
|
values: chunk,
|
|
3447
3447
|
abortSignal,
|
|
3448
3448
|
headers
|
|
3449
3449
|
});
|
|
3450
3450
|
const embeddings2 = modelResponse.embeddings;
|
|
3451
|
-
const usage2 = (
|
|
3451
|
+
const usage2 = (_a173 = modelResponse.usage) != null ? _a173 : { tokens: NaN };
|
|
3452
3452
|
doEmbedSpan.setAttributes(
|
|
3453
3453
|
selectTelemetryAttributes({
|
|
3454
3454
|
telemetry,
|
|
@@ -3525,8 +3525,8 @@ var dataContentSchema = zod.z.union([
|
|
|
3525
3525
|
zod.z.custom(
|
|
3526
3526
|
// Buffer might not be available in some environments such as CloudFlare:
|
|
3527
3527
|
(value) => {
|
|
3528
|
-
var
|
|
3529
|
-
return (_b17 = (
|
|
3528
|
+
var _a173, _b17;
|
|
3529
|
+
return (_b17 = (_a173 = globalThis.Buffer) == null ? void 0 : _a173.isBuffer(value)) != null ? _b17 : false;
|
|
3530
3530
|
},
|
|
3531
3531
|
{ message: "Must be a Buffer" }
|
|
3532
3532
|
)
|
|
@@ -3730,16 +3730,16 @@ var object = ({
|
|
|
3730
3730
|
}
|
|
3731
3731
|
}
|
|
3732
3732
|
},
|
|
3733
|
-
parseOutput({ text: text22 },
|
|
3733
|
+
parseOutput({ text: text22 }, context2) {
|
|
3734
3734
|
const parseResult = safeParseJSON({ text: text22 });
|
|
3735
3735
|
if (!parseResult.success) {
|
|
3736
3736
|
throw new NoObjectGeneratedError({
|
|
3737
3737
|
message: "No object generated: could not parse the response.",
|
|
3738
3738
|
cause: parseResult.error,
|
|
3739
3739
|
text: text22,
|
|
3740
|
-
response:
|
|
3741
|
-
usage:
|
|
3742
|
-
finishReason:
|
|
3740
|
+
response: context2.response,
|
|
3741
|
+
usage: context2.usage,
|
|
3742
|
+
finishReason: context2.finishReason
|
|
3743
3743
|
});
|
|
3744
3744
|
}
|
|
3745
3745
|
const validationResult = safeValidateTypes({
|
|
@@ -3751,9 +3751,9 @@ var object = ({
|
|
|
3751
3751
|
message: "No object generated: response did not match schema.",
|
|
3752
3752
|
cause: validationResult.error,
|
|
3753
3753
|
text: text22,
|
|
3754
|
-
response:
|
|
3755
|
-
usage:
|
|
3756
|
-
finishReason:
|
|
3754
|
+
response: context2.response,
|
|
3755
|
+
usage: context2.usage,
|
|
3756
|
+
finishReason: context2.finishReason
|
|
3757
3757
|
});
|
|
3758
3758
|
}
|
|
3759
3759
|
return validationResult.value;
|
|
@@ -4015,7 +4015,7 @@ function toDataStreamInternal(stream, callbacks) {
|
|
|
4015
4015
|
return stream.pipeThrough(
|
|
4016
4016
|
new TransformStream({
|
|
4017
4017
|
transform: async (value, controller) => {
|
|
4018
|
-
var
|
|
4018
|
+
var _a173;
|
|
4019
4019
|
if (typeof value === "string") {
|
|
4020
4020
|
controller.enqueue(value);
|
|
4021
4021
|
return;
|
|
@@ -4023,7 +4023,7 @@ function toDataStreamInternal(stream, callbacks) {
|
|
|
4023
4023
|
if ("event" in value) {
|
|
4024
4024
|
if (value.event === "on_chat_model_stream") {
|
|
4025
4025
|
forwardAIMessageChunk(
|
|
4026
|
-
(
|
|
4026
|
+
(_a173 = value.data) == null ? void 0 : _a173.chunk,
|
|
4027
4027
|
controller
|
|
4028
4028
|
);
|
|
4029
4029
|
}
|
|
@@ -4046,7 +4046,7 @@ function toDataStream(stream, callbacks) {
|
|
|
4046
4046
|
);
|
|
4047
4047
|
}
|
|
4048
4048
|
function toDataStreamResponse(stream, options) {
|
|
4049
|
-
var
|
|
4049
|
+
var _a173;
|
|
4050
4050
|
const dataStream = toDataStreamInternal(
|
|
4051
4051
|
stream,
|
|
4052
4052
|
options == null ? void 0 : options.callbacks
|
|
@@ -4055,7 +4055,7 @@ function toDataStreamResponse(stream, options) {
|
|
|
4055
4055
|
const init = options == null ? void 0 : options.init;
|
|
4056
4056
|
const responseStream = data ? mergeStreams(data.stream, dataStream) : dataStream;
|
|
4057
4057
|
return new Response(responseStream, {
|
|
4058
|
-
status: (
|
|
4058
|
+
status: (_a173 = init == null ? void 0 : init.status) != null ? _a173 : 200,
|
|
4059
4059
|
statusText: init == null ? void 0 : init.statusText,
|
|
4060
4060
|
headers: prepareResponseHeaders(init == null ? void 0 : init.headers, {
|
|
4061
4061
|
contentType: "text/plain; charset=utf-8",
|
|
@@ -4106,14 +4106,14 @@ function toDataStream2(stream, callbacks) {
|
|
|
4106
4106
|
);
|
|
4107
4107
|
}
|
|
4108
4108
|
function toDataStreamResponse2(stream, options = {}) {
|
|
4109
|
-
var
|
|
4109
|
+
var _a173;
|
|
4110
4110
|
const { init, data, callbacks } = options;
|
|
4111
4111
|
const dataStream = toDataStreamInternal2(stream, callbacks).pipeThrough(
|
|
4112
4112
|
new TextEncoderStream()
|
|
4113
4113
|
);
|
|
4114
4114
|
const responseStream = data ? mergeStreams(data.stream, dataStream) : dataStream;
|
|
4115
4115
|
return new Response(responseStream, {
|
|
4116
|
-
status: (
|
|
4116
|
+
status: (_a173 = init == null ? void 0 : init.status) != null ? _a173 : 200,
|
|
4117
4117
|
statusText: init == null ? void 0 : init.statusText,
|
|
4118
4118
|
headers: prepareResponseHeaders(init == null ? void 0 : init.headers, {
|
|
4119
4119
|
contentType: "text/plain; charset=utf-8",
|
|
@@ -4148,13 +4148,13 @@ var _AISDKError3 = class _AISDKError22 extends Error {
|
|
|
4148
4148
|
* @param {unknown} [params.cause] - The underlying cause of the error.
|
|
4149
4149
|
*/
|
|
4150
4150
|
constructor({
|
|
4151
|
-
name:
|
|
4151
|
+
name: name145,
|
|
4152
4152
|
message,
|
|
4153
4153
|
cause
|
|
4154
4154
|
}) {
|
|
4155
4155
|
super(message);
|
|
4156
4156
|
this[_a17] = true;
|
|
4157
|
-
this.name =
|
|
4157
|
+
this.name = name145;
|
|
4158
4158
|
this.cause = cause;
|
|
4159
4159
|
}
|
|
4160
4160
|
/**
|
|
@@ -4165,8 +4165,8 @@ var _AISDKError3 = class _AISDKError22 extends Error {
|
|
|
4165
4165
|
static isInstance(error) {
|
|
4166
4166
|
return _AISDKError22.hasMarker(error, marker17);
|
|
4167
4167
|
}
|
|
4168
|
-
static hasMarker(error,
|
|
4169
|
-
const markerSymbol = Symbol.for(
|
|
4168
|
+
static hasMarker(error, marker155) {
|
|
4169
|
+
const markerSymbol = Symbol.for(marker155);
|
|
4170
4170
|
return error != null && typeof error === "object" && markerSymbol in error && typeof error[markerSymbol] === "boolean" && error[markerSymbol] === true;
|
|
4171
4171
|
}
|
|
4172
4172
|
};
|
|
@@ -4540,11 +4540,11 @@ function handleFetchError({
|
|
|
4540
4540
|
return error;
|
|
4541
4541
|
}
|
|
4542
4542
|
function getRuntimeEnvironmentUserAgent(globalThisAny = globalThis) {
|
|
4543
|
-
var
|
|
4543
|
+
var _a155, _b17, _c;
|
|
4544
4544
|
if (globalThisAny.window) {
|
|
4545
4545
|
return `runtime/browser`;
|
|
4546
4546
|
}
|
|
4547
|
-
if ((
|
|
4547
|
+
if ((_a155 = globalThisAny.navigator) == null ? void 0 : _a155.userAgent) {
|
|
4548
4548
|
return `runtime/${globalThisAny.navigator.userAgent.toLowerCase()}`;
|
|
4549
4549
|
}
|
|
4550
4550
|
if ((_c = (_b17 = globalThisAny.process) == null ? void 0 : _b17.versions) == null ? void 0 : _c.node) {
|
|
@@ -5066,11 +5066,11 @@ function parseAnyDef2() {
|
|
|
5066
5066
|
return {};
|
|
5067
5067
|
}
|
|
5068
5068
|
function parseArrayDef2(def, refs) {
|
|
5069
|
-
var
|
|
5069
|
+
var _a155, _b17, _c;
|
|
5070
5070
|
const res = {
|
|
5071
5071
|
type: "array"
|
|
5072
5072
|
};
|
|
5073
|
-
if (((
|
|
5073
|
+
if (((_a155 = def.type) == null ? void 0 : _a155._def) && ((_c = (_b17 = def.type) == null ? void 0 : _b17._def) == null ? void 0 : _c.typeName) !== v3.ZodFirstPartyTypeKind.ZodAny) {
|
|
5074
5074
|
res.items = parseDef2(def.type._def, {
|
|
5075
5075
|
...refs,
|
|
5076
5076
|
currentPath: [...refs.currentPath, "items"]
|
|
@@ -5429,8 +5429,8 @@ function escapeNonAlphaNumeric2(source) {
|
|
|
5429
5429
|
return result;
|
|
5430
5430
|
}
|
|
5431
5431
|
function addFormat2(schema, value, message, refs) {
|
|
5432
|
-
var
|
|
5433
|
-
if (schema.format || ((
|
|
5432
|
+
var _a155;
|
|
5433
|
+
if (schema.format || ((_a155 = schema.anyOf) == null ? void 0 : _a155.some((x) => x.format))) {
|
|
5434
5434
|
if (!schema.anyOf) {
|
|
5435
5435
|
schema.anyOf = [];
|
|
5436
5436
|
}
|
|
@@ -5449,8 +5449,8 @@ function addFormat2(schema, value, message, refs) {
|
|
|
5449
5449
|
}
|
|
5450
5450
|
}
|
|
5451
5451
|
function addPattern2(schema, regex, message, refs) {
|
|
5452
|
-
var
|
|
5453
|
-
if (schema.pattern || ((
|
|
5452
|
+
var _a155;
|
|
5453
|
+
if (schema.pattern || ((_a155 = schema.allOf) == null ? void 0 : _a155.some((x) => x.pattern))) {
|
|
5454
5454
|
if (!schema.allOf) {
|
|
5455
5455
|
schema.allOf = [];
|
|
5456
5456
|
}
|
|
@@ -5469,7 +5469,7 @@ function addPattern2(schema, regex, message, refs) {
|
|
|
5469
5469
|
}
|
|
5470
5470
|
}
|
|
5471
5471
|
function stringifyRegExpWithFlags2(regex, refs) {
|
|
5472
|
-
var
|
|
5472
|
+
var _a155;
|
|
5473
5473
|
if (!refs.applyRegexFlags || !regex.flags) {
|
|
5474
5474
|
return regex.source;
|
|
5475
5475
|
}
|
|
@@ -5499,7 +5499,7 @@ function stringifyRegExpWithFlags2(regex, refs) {
|
|
|
5499
5499
|
pattern += source[i];
|
|
5500
5500
|
pattern += `${source[i - 2]}-${source[i]}`.toUpperCase();
|
|
5501
5501
|
inCharRange = false;
|
|
5502
|
-
} else if (source[i + 1] === "-" && ((
|
|
5502
|
+
} else if (source[i + 1] === "-" && ((_a155 = source[i + 2]) == null ? void 0 : _a155.match(/[a-z]/))) {
|
|
5503
5503
|
pattern += source[i];
|
|
5504
5504
|
inCharRange = true;
|
|
5505
5505
|
} else {
|
|
@@ -5541,13 +5541,13 @@ function stringifyRegExpWithFlags2(regex, refs) {
|
|
|
5541
5541
|
return pattern;
|
|
5542
5542
|
}
|
|
5543
5543
|
function parseRecordDef2(def, refs) {
|
|
5544
|
-
var
|
|
5544
|
+
var _a155, _b17, _c, _d, _e, _f;
|
|
5545
5545
|
const schema = {
|
|
5546
5546
|
type: "object",
|
|
5547
|
-
additionalProperties: (
|
|
5547
|
+
additionalProperties: (_a155 = parseDef2(def.valueType._def, {
|
|
5548
5548
|
...refs,
|
|
5549
5549
|
currentPath: [...refs.currentPath, "additionalProperties"]
|
|
5550
|
-
})) != null ?
|
|
5550
|
+
})) != null ? _a155 : refs.allowedAdditionalProperties
|
|
5551
5551
|
};
|
|
5552
5552
|
if (((_b17 = def.keyType) == null ? void 0 : _b17._def.typeName) === v3.ZodFirstPartyTypeKind.ZodString && ((_c = def.keyType._def.checks) == null ? void 0 : _c.length)) {
|
|
5553
5553
|
const { type, ...keyType } = parseStringDef2(def.keyType._def, refs);
|
|
@@ -5804,8 +5804,8 @@ function safeIsOptional2(schema) {
|
|
|
5804
5804
|
}
|
|
5805
5805
|
}
|
|
5806
5806
|
var parseOptionalDef2 = (def, refs) => {
|
|
5807
|
-
var
|
|
5808
|
-
if (refs.currentPath.toString() === ((
|
|
5807
|
+
var _a155;
|
|
5808
|
+
if (refs.currentPath.toString() === ((_a155 = refs.propertyPath) == null ? void 0 : _a155.toString())) {
|
|
5809
5809
|
return parseDef2(def.innerType._def, refs);
|
|
5810
5810
|
}
|
|
5811
5811
|
const innerSchema = parseDef2(def.innerType._def, {
|
|
@@ -5975,10 +5975,10 @@ var selectParser2 = (def, typeName, refs) => {
|
|
|
5975
5975
|
}
|
|
5976
5976
|
};
|
|
5977
5977
|
function parseDef2(def, refs, forceResolution = false) {
|
|
5978
|
-
var
|
|
5978
|
+
var _a155;
|
|
5979
5979
|
const seenItem = refs.seen.get(def);
|
|
5980
5980
|
if (refs.override) {
|
|
5981
|
-
const overrideResult = (
|
|
5981
|
+
const overrideResult = (_a155 = refs.override) == null ? void 0 : _a155.call(
|
|
5982
5982
|
refs,
|
|
5983
5983
|
def,
|
|
5984
5984
|
refs,
|
|
@@ -6044,11 +6044,11 @@ var getRefs2 = (options) => {
|
|
|
6044
6044
|
currentPath,
|
|
6045
6045
|
propertyPath: void 0,
|
|
6046
6046
|
seen: new Map(
|
|
6047
|
-
Object.entries(_options.definitions).map(([
|
|
6047
|
+
Object.entries(_options.definitions).map(([name145, def]) => [
|
|
6048
6048
|
def._def,
|
|
6049
6049
|
{
|
|
6050
6050
|
def: def._def,
|
|
6051
|
-
path: [..._options.basePath, _options.definitionPath,
|
|
6051
|
+
path: [..._options.basePath, _options.definitionPath, name145],
|
|
6052
6052
|
// Resolution of references will be forced even though seen, so it's ok that the schema is undefined here for now.
|
|
6053
6053
|
jsonSchema: void 0
|
|
6054
6054
|
}
|
|
@@ -6057,7 +6057,7 @@ var getRefs2 = (options) => {
|
|
|
6057
6057
|
};
|
|
6058
6058
|
};
|
|
6059
6059
|
var zodToJsonSchema2 = (schema, options) => {
|
|
6060
|
-
var
|
|
6060
|
+
var _a155;
|
|
6061
6061
|
const refs = getRefs2(options);
|
|
6062
6062
|
let definitions = typeof options === "object" && options.definitions ? Object.entries(options.definitions).reduce(
|
|
6063
6063
|
(acc, [name224, schema2]) => {
|
|
@@ -6076,31 +6076,31 @@ var zodToJsonSchema2 = (schema, options) => {
|
|
|
6076
6076
|
},
|
|
6077
6077
|
{}
|
|
6078
6078
|
) : void 0;
|
|
6079
|
-
const
|
|
6080
|
-
const main = (
|
|
6079
|
+
const name145 = typeof options === "string" ? options : (options == null ? void 0 : options.nameStrategy) === "title" ? void 0 : options == null ? void 0 : options.name;
|
|
6080
|
+
const main = (_a155 = parseDef2(
|
|
6081
6081
|
schema._def,
|
|
6082
|
-
|
|
6082
|
+
name145 === void 0 ? refs : {
|
|
6083
6083
|
...refs,
|
|
6084
|
-
currentPath: [...refs.basePath, refs.definitionPath,
|
|
6084
|
+
currentPath: [...refs.basePath, refs.definitionPath, name145]
|
|
6085
6085
|
},
|
|
6086
6086
|
false
|
|
6087
|
-
)) != null ?
|
|
6087
|
+
)) != null ? _a155 : parseAnyDef2();
|
|
6088
6088
|
const title = typeof options === "object" && options.name !== void 0 && options.nameStrategy === "title" ? options.name : void 0;
|
|
6089
6089
|
if (title !== void 0) {
|
|
6090
6090
|
main.title = title;
|
|
6091
6091
|
}
|
|
6092
|
-
const combined =
|
|
6092
|
+
const combined = name145 === void 0 ? definitions ? {
|
|
6093
6093
|
...main,
|
|
6094
6094
|
[refs.definitionPath]: definitions
|
|
6095
6095
|
} : main : {
|
|
6096
6096
|
$ref: [
|
|
6097
6097
|
...refs.$refStrategy === "relative" ? [] : refs.basePath,
|
|
6098
6098
|
refs.definitionPath,
|
|
6099
|
-
|
|
6099
|
+
name145
|
|
6100
6100
|
].join("/"),
|
|
6101
6101
|
[refs.definitionPath]: {
|
|
6102
6102
|
...definitions,
|
|
6103
|
-
[
|
|
6103
|
+
[name145]: main
|
|
6104
6104
|
}
|
|
6105
6105
|
};
|
|
6106
6106
|
combined.$schema = "http://json-schema.org/draft-07/schema#";
|
|
@@ -6108,8 +6108,8 @@ var zodToJsonSchema2 = (schema, options) => {
|
|
|
6108
6108
|
};
|
|
6109
6109
|
var zod_to_json_schema_default = zodToJsonSchema2;
|
|
6110
6110
|
function zod3Schema(zodSchema22, options) {
|
|
6111
|
-
var
|
|
6112
|
-
const useReferences = (
|
|
6111
|
+
var _a155;
|
|
6112
|
+
const useReferences = (_a155 = void 0 ) != null ? _a155 : false;
|
|
6113
6113
|
return jsonSchema2(
|
|
6114
6114
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
6115
6115
|
() => zod_to_json_schema_default(zodSchema22, {
|
|
@@ -6124,8 +6124,8 @@ function zod3Schema(zodSchema22, options) {
|
|
|
6124
6124
|
);
|
|
6125
6125
|
}
|
|
6126
6126
|
function zod4Schema(zodSchema22, options) {
|
|
6127
|
-
var
|
|
6128
|
-
const useReferences = (
|
|
6127
|
+
var _a155;
|
|
6128
|
+
const useReferences = (_a155 = void 0 ) != null ? _a155 : false;
|
|
6129
6129
|
return jsonSchema2(
|
|
6130
6130
|
// defer json schema creation to avoid unnecessary computation when only validation is needed
|
|
6131
6131
|
() => z4__namespace.toJSONSchema(zodSchema22, {
|
|
@@ -6188,8 +6188,8 @@ var require_get_context = chunk23EXJLET_cjs.__commonJS({
|
|
|
6188
6188
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
6189
6189
|
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
6190
6190
|
var __export22 = (target, all) => {
|
|
6191
|
-
for (var
|
|
6192
|
-
__defProp22(target,
|
|
6191
|
+
for (var name163 in all)
|
|
6192
|
+
__defProp22(target, name163, { get: all[name163], enumerable: true });
|
|
6193
6193
|
};
|
|
6194
6194
|
var __copyProps2 = (to, from, except, desc) => {
|
|
6195
6195
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -6220,8 +6220,8 @@ var require_get_vercel_oidc_token = chunk23EXJLET_cjs.__commonJS({
|
|
|
6220
6220
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
6221
6221
|
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
6222
6222
|
var __export22 = (target, all) => {
|
|
6223
|
-
for (var
|
|
6224
|
-
__defProp22(target,
|
|
6223
|
+
for (var name163 in all)
|
|
6224
|
+
__defProp22(target, name163, { get: all[name163], enumerable: true });
|
|
6225
6225
|
};
|
|
6226
6226
|
var __copyProps2 = (to, from, except, desc) => {
|
|
6227
6227
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -6284,8 +6284,8 @@ var require_dist = chunk23EXJLET_cjs.__commonJS({
|
|
|
6284
6284
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
6285
6285
|
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
6286
6286
|
var __export22 = (target, all) => {
|
|
6287
|
-
for (var
|
|
6288
|
-
__defProp22(target,
|
|
6287
|
+
for (var name163 in all)
|
|
6288
|
+
__defProp22(target, name163, { get: all[name163], enumerable: true });
|
|
6289
6289
|
};
|
|
6290
6290
|
var __copyProps2 = (to, from, except, desc) => {
|
|
6291
6291
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -7238,11 +7238,11 @@ var major2 = VERSION22.split(".")[0];
|
|
|
7238
7238
|
var GLOBAL_OPENTELEMETRY_API_KEY2 = /* @__PURE__ */ Symbol.for("opentelemetry.js.api." + major2);
|
|
7239
7239
|
var _global2 = _globalThis2;
|
|
7240
7240
|
function registerGlobal2(type, instance, diag, allowOverride) {
|
|
7241
|
-
var
|
|
7241
|
+
var _a163;
|
|
7242
7242
|
if (allowOverride === void 0) {
|
|
7243
7243
|
allowOverride = false;
|
|
7244
7244
|
}
|
|
7245
|
-
var api = _global2[GLOBAL_OPENTELEMETRY_API_KEY2] = (
|
|
7245
|
+
var api = _global2[GLOBAL_OPENTELEMETRY_API_KEY2] = (_a163 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) !== null && _a163 !== void 0 ? _a163 : {
|
|
7246
7246
|
version: VERSION22
|
|
7247
7247
|
};
|
|
7248
7248
|
if (!allowOverride && api[type]) {
|
|
@@ -7260,8 +7260,8 @@ function registerGlobal2(type, instance, diag, allowOverride) {
|
|
|
7260
7260
|
return true;
|
|
7261
7261
|
}
|
|
7262
7262
|
function getGlobal2(type) {
|
|
7263
|
-
var
|
|
7264
|
-
var globalVersion = (
|
|
7263
|
+
var _a163, _b83;
|
|
7264
|
+
var globalVersion = (_a163 = _global2[GLOBAL_OPENTELEMETRY_API_KEY2]) === null || _a163 === void 0 ? void 0 : _a163.version;
|
|
7265
7265
|
if (!globalVersion || !isCompatible2(globalVersion)) {
|
|
7266
7266
|
return;
|
|
7267
7267
|
}
|
|
@@ -7430,13 +7430,13 @@ var DiagAPI2 = (
|
|
|
7430
7430
|
}
|
|
7431
7431
|
var self = this;
|
|
7432
7432
|
var setLogger = function(logger, optionsOrLogLevel) {
|
|
7433
|
-
var
|
|
7433
|
+
var _a163, _b83, _c;
|
|
7434
7434
|
if (optionsOrLogLevel === void 0) {
|
|
7435
7435
|
optionsOrLogLevel = { logLevel: DiagLogLevel2.INFO };
|
|
7436
7436
|
}
|
|
7437
7437
|
if (logger === self) {
|
|
7438
7438
|
var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
7439
|
-
self.error((
|
|
7439
|
+
self.error((_a163 = err.stack) !== null && _a163 !== void 0 ? _a163 : err.message);
|
|
7440
7440
|
return false;
|
|
7441
7441
|
}
|
|
7442
7442
|
if (typeof optionsOrLogLevel === "number") {
|
|
@@ -7488,14 +7488,14 @@ var BaseContext2 = (
|
|
|
7488
7488
|
return self._currentContext.get(key);
|
|
7489
7489
|
};
|
|
7490
7490
|
self.setValue = function(key, value) {
|
|
7491
|
-
var
|
|
7492
|
-
|
|
7493
|
-
return
|
|
7491
|
+
var context2 = new BaseContext22(self._currentContext);
|
|
7492
|
+
context2._currentContext.set(key, value);
|
|
7493
|
+
return context2;
|
|
7494
7494
|
};
|
|
7495
7495
|
self.deleteValue = function(key) {
|
|
7496
|
-
var
|
|
7497
|
-
|
|
7498
|
-
return
|
|
7496
|
+
var context2 = new BaseContext22(self._currentContext);
|
|
7497
|
+
context2._currentContext.delete(key);
|
|
7498
|
+
return context2;
|
|
7499
7499
|
};
|
|
7500
7500
|
}
|
|
7501
7501
|
return BaseContext22;
|
|
@@ -7600,16 +7600,16 @@ var ContextAPI2 = (
|
|
|
7600
7600
|
ContextAPI22.prototype.active = function() {
|
|
7601
7601
|
return this._getContextManager().active();
|
|
7602
7602
|
};
|
|
7603
|
-
ContextAPI22.prototype.with = function(
|
|
7604
|
-
var
|
|
7603
|
+
ContextAPI22.prototype.with = function(context2, fn, thisArg) {
|
|
7604
|
+
var _a163;
|
|
7605
7605
|
var args = [];
|
|
7606
7606
|
for (var _i = 3; _i < arguments.length; _i++) {
|
|
7607
7607
|
args[_i - 3] = arguments[_i];
|
|
7608
7608
|
}
|
|
7609
|
-
return (
|
|
7609
|
+
return (_a163 = this._getContextManager()).with.apply(_a163, __spreadArray42([context2, fn, thisArg], __read42(args), false));
|
|
7610
7610
|
};
|
|
7611
|
-
ContextAPI22.prototype.bind = function(
|
|
7612
|
-
return this._getContextManager().bind(
|
|
7611
|
+
ContextAPI22.prototype.bind = function(context2, target) {
|
|
7612
|
+
return this._getContextManager().bind(context2, target);
|
|
7613
7613
|
};
|
|
7614
7614
|
ContextAPI22.prototype._getContextManager = function() {
|
|
7615
7615
|
return getGlobal2(API_NAME22) || NOOP_CONTEXT_MANAGER2;
|
|
@@ -7677,24 +7677,24 @@ var NonRecordingSpan2 = (
|
|
|
7677
7677
|
})()
|
|
7678
7678
|
);
|
|
7679
7679
|
var SPAN_KEY2 = createContextKey2("OpenTelemetry Context Key SPAN");
|
|
7680
|
-
function getSpan2(
|
|
7681
|
-
return
|
|
7680
|
+
function getSpan2(context2) {
|
|
7681
|
+
return context2.getValue(SPAN_KEY2) || void 0;
|
|
7682
7682
|
}
|
|
7683
7683
|
function getActiveSpan2() {
|
|
7684
7684
|
return getSpan2(ContextAPI2.getInstance().active());
|
|
7685
7685
|
}
|
|
7686
|
-
function setSpan2(
|
|
7687
|
-
return
|
|
7686
|
+
function setSpan2(context2, span) {
|
|
7687
|
+
return context2.setValue(SPAN_KEY2, span);
|
|
7688
7688
|
}
|
|
7689
|
-
function deleteSpan2(
|
|
7690
|
-
return
|
|
7689
|
+
function deleteSpan2(context2) {
|
|
7690
|
+
return context2.deleteValue(SPAN_KEY2);
|
|
7691
7691
|
}
|
|
7692
|
-
function setSpanContext2(
|
|
7693
|
-
return setSpan2(
|
|
7692
|
+
function setSpanContext2(context2, spanContext) {
|
|
7693
|
+
return setSpan2(context2, new NonRecordingSpan2(spanContext));
|
|
7694
7694
|
}
|
|
7695
|
-
function getSpanContext2(
|
|
7696
|
-
var
|
|
7697
|
-
return (
|
|
7695
|
+
function getSpanContext2(context2) {
|
|
7696
|
+
var _a163;
|
|
7697
|
+
return (_a163 = getSpan2(context2)) === null || _a163 === void 0 ? void 0 : _a163.spanContext();
|
|
7698
7698
|
}
|
|
7699
7699
|
var VALID_TRACEID_REGEX2 = /^([0-9a-f]{32})$/i;
|
|
7700
7700
|
var VALID_SPANID_REGEX2 = /^[0-9a-f]{16}$/i;
|
|
@@ -7716,22 +7716,22 @@ var NoopTracer2 = (
|
|
|
7716
7716
|
(function() {
|
|
7717
7717
|
function NoopTracer22() {
|
|
7718
7718
|
}
|
|
7719
|
-
NoopTracer22.prototype.startSpan = function(
|
|
7720
|
-
if (
|
|
7721
|
-
|
|
7719
|
+
NoopTracer22.prototype.startSpan = function(name163, options, context2) {
|
|
7720
|
+
if (context2 === void 0) {
|
|
7721
|
+
context2 = contextApi2.active();
|
|
7722
7722
|
}
|
|
7723
7723
|
var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
|
|
7724
7724
|
if (root) {
|
|
7725
7725
|
return new NonRecordingSpan2();
|
|
7726
7726
|
}
|
|
7727
|
-
var parentFromContext =
|
|
7727
|
+
var parentFromContext = context2 && getSpanContext2(context2);
|
|
7728
7728
|
if (isSpanContext2(parentFromContext) && isSpanContextValid2(parentFromContext)) {
|
|
7729
7729
|
return new NonRecordingSpan2(parentFromContext);
|
|
7730
7730
|
} else {
|
|
7731
7731
|
return new NonRecordingSpan2();
|
|
7732
7732
|
}
|
|
7733
7733
|
};
|
|
7734
|
-
NoopTracer22.prototype.startActiveSpan = function(
|
|
7734
|
+
NoopTracer22.prototype.startActiveSpan = function(name163, arg2, arg3, arg4) {
|
|
7735
7735
|
var opts;
|
|
7736
7736
|
var ctx;
|
|
7737
7737
|
var fn;
|
|
@@ -7748,7 +7748,7 @@ var NoopTracer2 = (
|
|
|
7748
7748
|
fn = arg4;
|
|
7749
7749
|
}
|
|
7750
7750
|
var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi2.active();
|
|
7751
|
-
var span = this.startSpan(
|
|
7751
|
+
var span = this.startSpan(name163, opts, parentContext);
|
|
7752
7752
|
var contextWithSpanSet = setSpan2(parentContext, span);
|
|
7753
7753
|
return contextApi2.with(contextWithSpanSet, fn, void 0, span);
|
|
7754
7754
|
};
|
|
@@ -7762,14 +7762,14 @@ var NOOP_TRACER2 = new NoopTracer2();
|
|
|
7762
7762
|
var ProxyTracer2 = (
|
|
7763
7763
|
/** @class */
|
|
7764
7764
|
(function() {
|
|
7765
|
-
function ProxyTracer22(_provider,
|
|
7765
|
+
function ProxyTracer22(_provider, name163, version, options) {
|
|
7766
7766
|
this._provider = _provider;
|
|
7767
|
-
this.name =
|
|
7767
|
+
this.name = name163;
|
|
7768
7768
|
this.version = version;
|
|
7769
7769
|
this.options = options;
|
|
7770
7770
|
}
|
|
7771
|
-
ProxyTracer22.prototype.startSpan = function(
|
|
7772
|
-
return this._getTracer().startSpan(
|
|
7771
|
+
ProxyTracer22.prototype.startSpan = function(name163, options, context2) {
|
|
7772
|
+
return this._getTracer().startSpan(name163, options, context2);
|
|
7773
7773
|
};
|
|
7774
7774
|
ProxyTracer22.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
|
|
7775
7775
|
var tracer = this._getTracer();
|
|
@@ -7806,20 +7806,20 @@ var ProxyTracerProvider2 = (
|
|
|
7806
7806
|
(function() {
|
|
7807
7807
|
function ProxyTracerProvider22() {
|
|
7808
7808
|
}
|
|
7809
|
-
ProxyTracerProvider22.prototype.getTracer = function(
|
|
7810
|
-
var
|
|
7811
|
-
return (
|
|
7809
|
+
ProxyTracerProvider22.prototype.getTracer = function(name163, version, options) {
|
|
7810
|
+
var _a163;
|
|
7811
|
+
return (_a163 = this.getDelegateTracer(name163, version, options)) !== null && _a163 !== void 0 ? _a163 : new ProxyTracer2(this, name163, version, options);
|
|
7812
7812
|
};
|
|
7813
7813
|
ProxyTracerProvider22.prototype.getDelegate = function() {
|
|
7814
|
-
var
|
|
7815
|
-
return (
|
|
7814
|
+
var _a163;
|
|
7815
|
+
return (_a163 = this._delegate) !== null && _a163 !== void 0 ? _a163 : NOOP_TRACER_PROVIDER2;
|
|
7816
7816
|
};
|
|
7817
7817
|
ProxyTracerProvider22.prototype.setDelegate = function(delegate) {
|
|
7818
7818
|
this._delegate = delegate;
|
|
7819
7819
|
};
|
|
7820
|
-
ProxyTracerProvider22.prototype.getDelegateTracer = function(
|
|
7821
|
-
var
|
|
7822
|
-
return (
|
|
7820
|
+
ProxyTracerProvider22.prototype.getDelegateTracer = function(name163, version, options) {
|
|
7821
|
+
var _a163;
|
|
7822
|
+
return (_a163 = this._delegate) === null || _a163 === void 0 ? void 0 : _a163.getTracer(name163, version, options);
|
|
7823
7823
|
};
|
|
7824
7824
|
return ProxyTracerProvider22;
|
|
7825
7825
|
})()
|
|
@@ -7861,8 +7861,8 @@ var TraceAPI2 = (
|
|
|
7861
7861
|
TraceAPI22.prototype.getTracerProvider = function() {
|
|
7862
7862
|
return getGlobal2(API_NAME32) || this._proxyTracerProvider;
|
|
7863
7863
|
};
|
|
7864
|
-
TraceAPI22.prototype.getTracer = function(
|
|
7865
|
-
return this.getTracerProvider().getTracer(
|
|
7864
|
+
TraceAPI22.prototype.getTracer = function(name163, version) {
|
|
7865
|
+
return this.getTracerProvider().getTracer(name163, version);
|
|
7866
7866
|
};
|
|
7867
7867
|
TraceAPI22.prototype.disable = function() {
|
|
7868
7868
|
unregisterGlobal2(API_NAME32, DiagAPI2.instance());
|
|
@@ -7874,8 +7874,8 @@ var TraceAPI2 = (
|
|
|
7874
7874
|
var trace2 = TraceAPI2.getInstance();
|
|
7875
7875
|
var __defProp3 = Object.defineProperty;
|
|
7876
7876
|
var __export2 = (target, all) => {
|
|
7877
|
-
for (var
|
|
7878
|
-
__defProp3(target,
|
|
7877
|
+
for (var name163 in all)
|
|
7878
|
+
__defProp3(target, name163, { get: all[name163], enumerable: true });
|
|
7879
7879
|
};
|
|
7880
7880
|
var name222 = "AI_InvalidArgumentError";
|
|
7881
7881
|
var marker222 = `vercel.ai.error.${name222}`;
|
|
@@ -7973,8 +7973,8 @@ function resolveEmbeddingModel(model) {
|
|
|
7973
7973
|
);
|
|
7974
7974
|
}
|
|
7975
7975
|
function getGlobalProvider() {
|
|
7976
|
-
var
|
|
7977
|
-
return (
|
|
7976
|
+
var _a163;
|
|
7977
|
+
return (_a163 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a163 : gateway;
|
|
7978
7978
|
}
|
|
7979
7979
|
var VERSION32 = "5.0.101";
|
|
7980
7980
|
var dataContentSchema2 = z4.z.union([
|
|
@@ -7984,8 +7984,8 @@ var dataContentSchema2 = z4.z.union([
|
|
|
7984
7984
|
z4.z.custom(
|
|
7985
7985
|
// Buffer might not be available in some environments such as CloudFlare:
|
|
7986
7986
|
(value) => {
|
|
7987
|
-
var
|
|
7988
|
-
return (_b83 = (
|
|
7987
|
+
var _a163, _b83;
|
|
7988
|
+
return (_b83 = (_a163 = globalThis.Buffer) == null ? void 0 : _a163.isBuffer(value)) != null ? _b83 : false;
|
|
7989
7989
|
},
|
|
7990
7990
|
{ message: "Must be a Buffer" }
|
|
7991
7991
|
)
|
|
@@ -8137,7 +8137,7 @@ function getBaseTelemetryAttributes2({
|
|
|
8137
8137
|
telemetry,
|
|
8138
8138
|
headers
|
|
8139
8139
|
}) {
|
|
8140
|
-
var
|
|
8140
|
+
var _a163;
|
|
8141
8141
|
return {
|
|
8142
8142
|
"ai.model.provider": model.provider,
|
|
8143
8143
|
"ai.model.id": model.modelId,
|
|
@@ -8147,7 +8147,7 @@ function getBaseTelemetryAttributes2({
|
|
|
8147
8147
|
return attributes;
|
|
8148
8148
|
}, {}),
|
|
8149
8149
|
// add metadata as attributes:
|
|
8150
|
-
...Object.entries((
|
|
8150
|
+
...Object.entries((_a163 = telemetry == null ? void 0 : telemetry.metadata) != null ? _a163 : {}).reduce(
|
|
8151
8151
|
(attributes, [key, value]) => {
|
|
8152
8152
|
attributes[`ai.telemetry.metadata.${key}`] = value;
|
|
8153
8153
|
return attributes;
|
|
@@ -8167,7 +8167,7 @@ var noopTracer2 = {
|
|
|
8167
8167
|
startSpan() {
|
|
8168
8168
|
return noopSpan2;
|
|
8169
8169
|
},
|
|
8170
|
-
startActiveSpan(
|
|
8170
|
+
startActiveSpan(name163, arg1, arg2, arg3) {
|
|
8171
8171
|
if (typeof arg1 === "function") {
|
|
8172
8172
|
return arg1(noopSpan2);
|
|
8173
8173
|
}
|
|
@@ -8232,13 +8232,13 @@ function getTracer2({
|
|
|
8232
8232
|
return trace2.getTracer("ai");
|
|
8233
8233
|
}
|
|
8234
8234
|
function recordSpan2({
|
|
8235
|
-
name:
|
|
8235
|
+
name: name163,
|
|
8236
8236
|
tracer,
|
|
8237
8237
|
attributes,
|
|
8238
8238
|
fn,
|
|
8239
8239
|
endWhenDone = true
|
|
8240
8240
|
}) {
|
|
8241
|
-
return tracer.startActiveSpan(
|
|
8241
|
+
return tracer.startActiveSpan(name163, { attributes }, async (span) => {
|
|
8242
8242
|
try {
|
|
8243
8243
|
const result = await fn(span);
|
|
8244
8244
|
if (endWhenDone) {
|
|
@@ -8810,7 +8810,7 @@ async function embedMany2({
|
|
|
8810
8810
|
}),
|
|
8811
8811
|
tracer,
|
|
8812
8812
|
fn: async (span) => {
|
|
8813
|
-
var
|
|
8813
|
+
var _a163;
|
|
8814
8814
|
const [maxEmbeddingsPerCall, supportsParallelCalls] = await Promise.all([
|
|
8815
8815
|
model.maxEmbeddingsPerCall,
|
|
8816
8816
|
model.supportsParallelCalls
|
|
@@ -8836,7 +8836,7 @@ async function embedMany2({
|
|
|
8836
8836
|
}),
|
|
8837
8837
|
tracer,
|
|
8838
8838
|
fn: async (doEmbedSpan) => {
|
|
8839
|
-
var
|
|
8839
|
+
var _a173;
|
|
8840
8840
|
const modelResponse = await model.doEmbed({
|
|
8841
8841
|
values,
|
|
8842
8842
|
abortSignal,
|
|
@@ -8844,7 +8844,7 @@ async function embedMany2({
|
|
|
8844
8844
|
providerOptions
|
|
8845
8845
|
});
|
|
8846
8846
|
const embeddings3 = modelResponse.embeddings;
|
|
8847
|
-
const usage2 = (
|
|
8847
|
+
const usage2 = (_a173 = modelResponse.usage) != null ? _a173 : { tokens: NaN };
|
|
8848
8848
|
doEmbedSpan.setAttributes(
|
|
8849
8849
|
selectTelemetryAttributes2({
|
|
8850
8850
|
telemetry,
|
|
@@ -8918,7 +8918,7 @@ async function embedMany2({
|
|
|
8918
8918
|
}),
|
|
8919
8919
|
tracer,
|
|
8920
8920
|
fn: async (doEmbedSpan) => {
|
|
8921
|
-
var
|
|
8921
|
+
var _a173;
|
|
8922
8922
|
const modelResponse = await model.doEmbed({
|
|
8923
8923
|
values: chunk,
|
|
8924
8924
|
abortSignal,
|
|
@@ -8926,7 +8926,7 @@ async function embedMany2({
|
|
|
8926
8926
|
providerOptions
|
|
8927
8927
|
});
|
|
8928
8928
|
const embeddings2 = modelResponse.embeddings;
|
|
8929
|
-
const usage = (
|
|
8929
|
+
const usage = (_a173 = modelResponse.usage) != null ? _a173 : { tokens: NaN };
|
|
8930
8930
|
doEmbedSpan.setAttributes(
|
|
8931
8931
|
selectTelemetryAttributes2({
|
|
8932
8932
|
telemetry,
|
|
@@ -8963,7 +8963,7 @@ async function embedMany2({
|
|
|
8963
8963
|
result.providerMetadata
|
|
8964
8964
|
)) {
|
|
8965
8965
|
providerMetadata[providerName] = {
|
|
8966
|
-
...(
|
|
8966
|
+
...(_a163 = providerMetadata[providerName]) != null ? _a163 : {},
|
|
8967
8967
|
...metadata
|
|
8968
8968
|
};
|
|
8969
8969
|
}
|
|
@@ -9046,16 +9046,16 @@ var object2 = ({
|
|
|
9046
9046
|
}
|
|
9047
9047
|
}
|
|
9048
9048
|
},
|
|
9049
|
-
async parseOutput({ text: text22 },
|
|
9049
|
+
async parseOutput({ text: text22 }, context2) {
|
|
9050
9050
|
const parseResult = await safeParseJSON2({ text: text22 });
|
|
9051
9051
|
if (!parseResult.success) {
|
|
9052
9052
|
throw new NoObjectGeneratedError2({
|
|
9053
9053
|
message: "No object generated: could not parse the response.",
|
|
9054
9054
|
cause: parseResult.error,
|
|
9055
9055
|
text: text22,
|
|
9056
|
-
response:
|
|
9057
|
-
usage:
|
|
9058
|
-
finishReason:
|
|
9056
|
+
response: context2.response,
|
|
9057
|
+
usage: context2.usage,
|
|
9058
|
+
finishReason: context2.finishReason
|
|
9059
9059
|
});
|
|
9060
9060
|
}
|
|
9061
9061
|
const validationResult = await safeValidateTypes2({
|
|
@@ -9067,9 +9067,9 @@ var object2 = ({
|
|
|
9067
9067
|
message: "No object generated: response did not match schema.",
|
|
9068
9068
|
cause: validationResult.error,
|
|
9069
9069
|
text: text22,
|
|
9070
|
-
response:
|
|
9071
|
-
usage:
|
|
9072
|
-
finishReason:
|
|
9070
|
+
response: context2.response,
|
|
9071
|
+
usage: context2.usage,
|
|
9072
|
+
finishReason: context2.finishReason
|
|
9073
9073
|
});
|
|
9074
9074
|
}
|
|
9075
9075
|
return validationResult.value;
|
|
@@ -9219,34 +9219,61 @@ var symbol135 = Symbol.for(marker135);
|
|
|
9219
9219
|
var _a135;
|
|
9220
9220
|
var _b13;
|
|
9221
9221
|
var TypeValidationError3 = class _TypeValidationError4 extends (_b13 = AISDKError3, _a135 = symbol135, _b13) {
|
|
9222
|
-
constructor({
|
|
9222
|
+
constructor({
|
|
9223
|
+
value,
|
|
9224
|
+
cause,
|
|
9225
|
+
context: context2
|
|
9226
|
+
}) {
|
|
9227
|
+
let contextPrefix = "Type validation failed";
|
|
9228
|
+
if (context2 == null ? void 0 : context2.field) {
|
|
9229
|
+
contextPrefix += ` for ${context2.field}`;
|
|
9230
|
+
}
|
|
9231
|
+
if ((context2 == null ? void 0 : context2.entityName) || (context2 == null ? void 0 : context2.entityId)) {
|
|
9232
|
+
contextPrefix += " (";
|
|
9233
|
+
const parts = [];
|
|
9234
|
+
if (context2.entityName) {
|
|
9235
|
+
parts.push(context2.entityName);
|
|
9236
|
+
}
|
|
9237
|
+
if (context2.entityId) {
|
|
9238
|
+
parts.push(`id: "${context2.entityId}"`);
|
|
9239
|
+
}
|
|
9240
|
+
contextPrefix += parts.join(", ");
|
|
9241
|
+
contextPrefix += ")";
|
|
9242
|
+
}
|
|
9223
9243
|
super({
|
|
9224
9244
|
name: name125,
|
|
9225
|
-
message:
|
|
9245
|
+
message: `${contextPrefix}: Value: ${JSON.stringify(value)}.
|
|
9226
9246
|
Error message: ${getErrorMessage4(cause)}`,
|
|
9227
9247
|
cause
|
|
9228
9248
|
});
|
|
9229
9249
|
this[_a135] = true;
|
|
9230
9250
|
this.value = value;
|
|
9251
|
+
this.context = context2;
|
|
9231
9252
|
}
|
|
9232
9253
|
static isInstance(error) {
|
|
9233
9254
|
return AISDKError3.hasMarker(error, marker135);
|
|
9234
9255
|
}
|
|
9235
9256
|
/**
|
|
9236
9257
|
* Wraps an error into a TypeValidationError.
|
|
9237
|
-
* If the cause is already a TypeValidationError with the same value, it returns the cause.
|
|
9258
|
+
* If the cause is already a TypeValidationError with the same value and context, it returns the cause.
|
|
9238
9259
|
* Otherwise, it creates a new TypeValidationError.
|
|
9239
9260
|
*
|
|
9240
9261
|
* @param {Object} params - The parameters for wrapping the error.
|
|
9241
9262
|
* @param {unknown} params.value - The value that failed validation.
|
|
9242
9263
|
* @param {unknown} params.cause - The original error or cause of the validation failure.
|
|
9264
|
+
* @param {TypeValidationContext} params.context - Optional context about what is being validated.
|
|
9243
9265
|
* @returns {TypeValidationError} A TypeValidationError instance.
|
|
9244
9266
|
*/
|
|
9245
9267
|
static wrap({
|
|
9246
9268
|
value,
|
|
9247
|
-
cause
|
|
9269
|
+
cause,
|
|
9270
|
+
context: context2
|
|
9248
9271
|
}) {
|
|
9249
|
-
|
|
9272
|
+
var _a1522, _b152, _c;
|
|
9273
|
+
if (_TypeValidationError4.isInstance(cause) && cause.value === value && ((_a1522 = cause.context) == null ? void 0 : _a1522.field) === (context2 == null ? void 0 : context2.field) && ((_b152 = cause.context) == null ? void 0 : _b152.entityName) === (context2 == null ? void 0 : context2.entityName) && ((_c = cause.context) == null ? void 0 : _c.entityId) === (context2 == null ? void 0 : context2.entityId)) {
|
|
9274
|
+
return cause;
|
|
9275
|
+
}
|
|
9276
|
+
return new _TypeValidationError4({ value, cause, context: context2 });
|
|
9250
9277
|
}
|
|
9251
9278
|
};
|
|
9252
9279
|
var ParseError2 = class extends Error {
|
|
@@ -9412,6 +9439,14 @@ function createAbortError2() {
|
|
|
9412
9439
|
function extractResponseHeaders2(response) {
|
|
9413
9440
|
return Object.fromEntries([...response.headers]);
|
|
9414
9441
|
}
|
|
9442
|
+
var { btoa: btoa3} = globalThis;
|
|
9443
|
+
function convertUint8ArrayToBase643(array2) {
|
|
9444
|
+
let latin1string = "";
|
|
9445
|
+
for (let i = 0; i < array2.length; i++) {
|
|
9446
|
+
latin1string += String.fromCodePoint(array2[i]);
|
|
9447
|
+
}
|
|
9448
|
+
return btoa3(latin1string);
|
|
9449
|
+
}
|
|
9415
9450
|
var createIdGenerator3 = ({
|
|
9416
9451
|
prefix,
|
|
9417
9452
|
size = 16,
|
|
@@ -9455,6 +9490,25 @@ function isAbortError3(error) {
|
|
|
9455
9490
|
error.name === "TimeoutError");
|
|
9456
9491
|
}
|
|
9457
9492
|
var FETCH_FAILED_ERROR_MESSAGES2 = ["fetch failed", "failed to fetch"];
|
|
9493
|
+
var BUN_ERROR_CODES = [
|
|
9494
|
+
"ConnectionRefused",
|
|
9495
|
+
"ConnectionClosed",
|
|
9496
|
+
"FailedToOpenSocket",
|
|
9497
|
+
"ECONNRESET",
|
|
9498
|
+
"ECONNREFUSED",
|
|
9499
|
+
"ETIMEDOUT",
|
|
9500
|
+
"EPIPE"
|
|
9501
|
+
];
|
|
9502
|
+
function isBunNetworkError(error) {
|
|
9503
|
+
if (!(error instanceof Error)) {
|
|
9504
|
+
return false;
|
|
9505
|
+
}
|
|
9506
|
+
const code = error.code;
|
|
9507
|
+
if (typeof code === "string" && BUN_ERROR_CODES.includes(code)) {
|
|
9508
|
+
return true;
|
|
9509
|
+
}
|
|
9510
|
+
return false;
|
|
9511
|
+
}
|
|
9458
9512
|
function handleFetchError2({
|
|
9459
9513
|
error,
|
|
9460
9514
|
url,
|
|
@@ -9476,6 +9530,15 @@ function handleFetchError2({
|
|
|
9476
9530
|
});
|
|
9477
9531
|
}
|
|
9478
9532
|
}
|
|
9533
|
+
if (isBunNetworkError(error)) {
|
|
9534
|
+
return new APICallError3({
|
|
9535
|
+
message: `Cannot connect to API: ${error.message}`,
|
|
9536
|
+
cause: error,
|
|
9537
|
+
url,
|
|
9538
|
+
requestBodyValues,
|
|
9539
|
+
isRetryable: true
|
|
9540
|
+
});
|
|
9541
|
+
}
|
|
9479
9542
|
return error;
|
|
9480
9543
|
}
|
|
9481
9544
|
function getRuntimeEnvironmentUserAgent2(globalThisAny = globalThis) {
|
|
@@ -9524,7 +9587,7 @@ function withUserAgentSuffix2(headers, ...userAgentSuffixParts) {
|
|
|
9524
9587
|
);
|
|
9525
9588
|
return Object.fromEntries(normalizedHeaders.entries());
|
|
9526
9589
|
}
|
|
9527
|
-
var VERSION4 = "4.0.
|
|
9590
|
+
var VERSION4 = "4.0.13";
|
|
9528
9591
|
var getOriginalFetch3 = () => globalThis.fetch;
|
|
9529
9592
|
var getFromApi2 = async ({
|
|
9530
9593
|
url,
|
|
@@ -9657,30 +9720,39 @@ function secureJsonParse2(text4) {
|
|
|
9657
9720
|
}
|
|
9658
9721
|
}
|
|
9659
9722
|
function addAdditionalPropertiesToJsonSchema(jsonSchema22) {
|
|
9660
|
-
if (jsonSchema22.type === "object") {
|
|
9723
|
+
if (jsonSchema22.type === "object" || Array.isArray(jsonSchema22.type) && jsonSchema22.type.includes("object")) {
|
|
9661
9724
|
jsonSchema22.additionalProperties = false;
|
|
9662
|
-
const properties = jsonSchema22
|
|
9725
|
+
const { properties } = jsonSchema22;
|
|
9663
9726
|
if (properties != null) {
|
|
9664
|
-
for (const
|
|
9665
|
-
properties[
|
|
9666
|
-
properties[property]
|
|
9667
|
-
);
|
|
9727
|
+
for (const key of Object.keys(properties)) {
|
|
9728
|
+
properties[key] = visit(properties[key]);
|
|
9668
9729
|
}
|
|
9669
9730
|
}
|
|
9670
9731
|
}
|
|
9671
|
-
if (jsonSchema22.
|
|
9672
|
-
|
|
9673
|
-
|
|
9674
|
-
|
|
9675
|
-
|
|
9676
|
-
|
|
9677
|
-
|
|
9678
|
-
|
|
9679
|
-
|
|
9732
|
+
if (jsonSchema22.items != null) {
|
|
9733
|
+
jsonSchema22.items = Array.isArray(jsonSchema22.items) ? jsonSchema22.items.map(visit) : visit(jsonSchema22.items);
|
|
9734
|
+
}
|
|
9735
|
+
if (jsonSchema22.anyOf != null) {
|
|
9736
|
+
jsonSchema22.anyOf = jsonSchema22.anyOf.map(visit);
|
|
9737
|
+
}
|
|
9738
|
+
if (jsonSchema22.allOf != null) {
|
|
9739
|
+
jsonSchema22.allOf = jsonSchema22.allOf.map(visit);
|
|
9740
|
+
}
|
|
9741
|
+
if (jsonSchema22.oneOf != null) {
|
|
9742
|
+
jsonSchema22.oneOf = jsonSchema22.oneOf.map(visit);
|
|
9743
|
+
}
|
|
9744
|
+
const { definitions } = jsonSchema22;
|
|
9745
|
+
if (definitions != null) {
|
|
9746
|
+
for (const key of Object.keys(definitions)) {
|
|
9747
|
+
definitions[key] = visit(definitions[key]);
|
|
9680
9748
|
}
|
|
9681
9749
|
}
|
|
9682
9750
|
return jsonSchema22;
|
|
9683
9751
|
}
|
|
9752
|
+
function visit(def) {
|
|
9753
|
+
if (typeof def === "boolean") return def;
|
|
9754
|
+
return addAdditionalPropertiesToJsonSchema(def);
|
|
9755
|
+
}
|
|
9684
9756
|
var ignoreOverride3 = /* @__PURE__ */ Symbol(
|
|
9685
9757
|
"Let zodToJsonSchema decide on which parser to use"
|
|
9686
9758
|
);
|
|
@@ -10797,9 +10869,11 @@ function asSchema3(schema) {
|
|
|
10797
10869
|
}
|
|
10798
10870
|
function standardSchema(standardSchema2) {
|
|
10799
10871
|
return jsonSchema3(
|
|
10800
|
-
() =>
|
|
10801
|
-
|
|
10802
|
-
|
|
10872
|
+
() => addAdditionalPropertiesToJsonSchema(
|
|
10873
|
+
standardSchema2["~standard"].jsonSchema.input({
|
|
10874
|
+
target: "draft-07"
|
|
10875
|
+
})
|
|
10876
|
+
),
|
|
10803
10877
|
{
|
|
10804
10878
|
validate: async (value) => {
|
|
10805
10879
|
const result = await standardSchema2["~standard"].validate(value);
|
|
@@ -10862,17 +10936,19 @@ function zodSchema3(zodSchema22, options) {
|
|
|
10862
10936
|
}
|
|
10863
10937
|
async function validateTypes2({
|
|
10864
10938
|
value,
|
|
10865
|
-
schema
|
|
10939
|
+
schema,
|
|
10940
|
+
context: context2
|
|
10866
10941
|
}) {
|
|
10867
|
-
const result = await safeValidateTypes3({ value, schema });
|
|
10942
|
+
const result = await safeValidateTypes3({ value, schema, context: context2 });
|
|
10868
10943
|
if (!result.success) {
|
|
10869
|
-
throw TypeValidationError3.wrap({ value, cause: result.error });
|
|
10944
|
+
throw TypeValidationError3.wrap({ value, cause: result.error, context: context2 });
|
|
10870
10945
|
}
|
|
10871
10946
|
return result.value;
|
|
10872
10947
|
}
|
|
10873
10948
|
async function safeValidateTypes3({
|
|
10874
10949
|
value,
|
|
10875
|
-
schema
|
|
10950
|
+
schema,
|
|
10951
|
+
context: context2
|
|
10876
10952
|
}) {
|
|
10877
10953
|
const actualSchema = asSchema3(schema);
|
|
10878
10954
|
try {
|
|
@@ -10885,13 +10961,13 @@ async function safeValidateTypes3({
|
|
|
10885
10961
|
}
|
|
10886
10962
|
return {
|
|
10887
10963
|
success: false,
|
|
10888
|
-
error: TypeValidationError3.wrap({ value, cause: result.error }),
|
|
10964
|
+
error: TypeValidationError3.wrap({ value, cause: result.error, context: context2 }),
|
|
10889
10965
|
rawValue: value
|
|
10890
10966
|
};
|
|
10891
10967
|
} catch (error) {
|
|
10892
10968
|
return {
|
|
10893
10969
|
success: false,
|
|
10894
|
-
error: TypeValidationError3.wrap({ value, cause: error }),
|
|
10970
|
+
error: TypeValidationError3.wrap({ value, cause: error, context: context2 }),
|
|
10895
10971
|
rawValue: value
|
|
10896
10972
|
};
|
|
10897
10973
|
}
|
|
@@ -11039,6 +11115,38 @@ var postToApi2 = async ({
|
|
|
11039
11115
|
throw handleFetchError2({ error, url, requestBodyValues: body.values });
|
|
11040
11116
|
}
|
|
11041
11117
|
};
|
|
11118
|
+
function tool(tool2) {
|
|
11119
|
+
return tool2;
|
|
11120
|
+
}
|
|
11121
|
+
function createProviderToolFactoryWithOutputSchema({
|
|
11122
|
+
id,
|
|
11123
|
+
inputSchema,
|
|
11124
|
+
outputSchema: outputSchema3,
|
|
11125
|
+
supportsDeferredResults
|
|
11126
|
+
}) {
|
|
11127
|
+
return ({
|
|
11128
|
+
execute,
|
|
11129
|
+
needsApproval,
|
|
11130
|
+
toModelOutput,
|
|
11131
|
+
onInputStart,
|
|
11132
|
+
onInputDelta,
|
|
11133
|
+
onInputAvailable,
|
|
11134
|
+
...args
|
|
11135
|
+
}) => tool({
|
|
11136
|
+
type: "provider",
|
|
11137
|
+
id,
|
|
11138
|
+
args,
|
|
11139
|
+
inputSchema,
|
|
11140
|
+
outputSchema: outputSchema3,
|
|
11141
|
+
execute,
|
|
11142
|
+
needsApproval,
|
|
11143
|
+
toModelOutput,
|
|
11144
|
+
onInputStart,
|
|
11145
|
+
onInputDelta,
|
|
11146
|
+
onInputAvailable,
|
|
11147
|
+
supportsDeferredResults
|
|
11148
|
+
});
|
|
11149
|
+
}
|
|
11042
11150
|
async function resolve2(value) {
|
|
11043
11151
|
if (typeof value === "function") {
|
|
11044
11152
|
value = value();
|
|
@@ -11139,15 +11247,15 @@ var createJsonResponseHandler2 = (responseSchema) => async ({ response, url, req
|
|
|
11139
11247
|
function withoutTrailingSlash2(url) {
|
|
11140
11248
|
return url == null ? void 0 : url.replace(/\/$/, "");
|
|
11141
11249
|
}
|
|
11142
|
-
var require_get_context2 =
|
|
11143
|
-
"../../../node_modules/.pnpm/@vercel+oidc@3.0
|
|
11250
|
+
var require_get_context2 = chunkIDRQZVB4_cjs.__commonJS({
|
|
11251
|
+
"../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/get-context.js"(exports$1, module) {
|
|
11144
11252
|
var __defProp22 = Object.defineProperty;
|
|
11145
11253
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
11146
11254
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
11147
11255
|
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
11148
11256
|
var __export22 = (target, all) => {
|
|
11149
|
-
for (var
|
|
11150
|
-
__defProp22(target,
|
|
11257
|
+
for (var name21 in all)
|
|
11258
|
+
__defProp22(target, name21, { get: all[name21], enumerable: true });
|
|
11151
11259
|
};
|
|
11152
11260
|
var __copyProps2 = (to, from, except, desc) => {
|
|
11153
11261
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -11171,15 +11279,15 @@ var require_get_context2 = chunkO3CS4UGX_cjs.__commonJS({
|
|
|
11171
11279
|
}
|
|
11172
11280
|
}
|
|
11173
11281
|
});
|
|
11174
|
-
var require_get_vercel_oidc_token2 =
|
|
11175
|
-
"../../../node_modules/.pnpm/@vercel+oidc@3.0
|
|
11282
|
+
var require_get_vercel_oidc_token2 = chunkIDRQZVB4_cjs.__commonJS({
|
|
11283
|
+
"../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/get-vercel-oidc-token.js"(exports$1, module) {
|
|
11176
11284
|
var __defProp22 = Object.defineProperty;
|
|
11177
11285
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
11178
11286
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
11179
11287
|
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
11180
11288
|
var __export22 = (target, all) => {
|
|
11181
|
-
for (var
|
|
11182
|
-
__defProp22(target,
|
|
11289
|
+
for (var name21 in all)
|
|
11290
|
+
__defProp22(target, name21, { get: all[name21], enumerable: true });
|
|
11183
11291
|
};
|
|
11184
11292
|
var __copyProps2 = (to, from, except, desc) => {
|
|
11185
11293
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -11197,7 +11305,7 @@ var require_get_vercel_oidc_token2 = chunkO3CS4UGX_cjs.__commonJS({
|
|
|
11197
11305
|
});
|
|
11198
11306
|
module.exports = __toCommonJS(get_vercel_oidc_token_exports);
|
|
11199
11307
|
var import_get_context = require_get_context2();
|
|
11200
|
-
var import_token_error =
|
|
11308
|
+
var import_token_error = chunkIDRQZVB4_cjs.require_token_error();
|
|
11201
11309
|
async function getVercelOidcToken3() {
|
|
11202
11310
|
let token = "";
|
|
11203
11311
|
let err;
|
|
@@ -11208,19 +11316,23 @@ var require_get_vercel_oidc_token2 = chunkO3CS4UGX_cjs.__commonJS({
|
|
|
11208
11316
|
}
|
|
11209
11317
|
try {
|
|
11210
11318
|
const [{ getTokenPayload, isExpired }, { refreshToken }] = await Promise.all([
|
|
11211
|
-
await import('./token-util-
|
|
11212
|
-
await import('./token-
|
|
11319
|
+
await import('./token-util-RMHT2CPJ-6TGPE335.cjs'),
|
|
11320
|
+
await import('./token-APYSY3BW-ZQ7TMBY7.cjs')
|
|
11213
11321
|
]);
|
|
11214
11322
|
if (!token || isExpired(getTokenPayload(token))) {
|
|
11215
11323
|
await refreshToken();
|
|
11216
11324
|
token = getVercelOidcTokenSync2();
|
|
11217
11325
|
}
|
|
11218
11326
|
} catch (error) {
|
|
11219
|
-
|
|
11220
|
-
|
|
11327
|
+
let message = err instanceof Error ? err.message : "";
|
|
11328
|
+
if (error instanceof Error) {
|
|
11329
|
+
message = `${message}
|
|
11221
11330
|
${error.message}`;
|
|
11222
11331
|
}
|
|
11223
|
-
|
|
11332
|
+
if (message) {
|
|
11333
|
+
throw new import_token_error.VercelOidcTokenError(message);
|
|
11334
|
+
}
|
|
11335
|
+
throw error;
|
|
11224
11336
|
}
|
|
11225
11337
|
return token;
|
|
11226
11338
|
}
|
|
@@ -11235,15 +11347,15 @@ ${error.message}`;
|
|
|
11235
11347
|
}
|
|
11236
11348
|
}
|
|
11237
11349
|
});
|
|
11238
|
-
var require_dist2 =
|
|
11239
|
-
"../../../node_modules/.pnpm/@vercel+oidc@3.0
|
|
11350
|
+
var require_dist2 = chunkIDRQZVB4_cjs.__commonJS({
|
|
11351
|
+
"../../../node_modules/.pnpm/@vercel+oidc@3.1.0/node_modules/@vercel/oidc/dist/index.js"(exports$1, module) {
|
|
11240
11352
|
var __defProp22 = Object.defineProperty;
|
|
11241
11353
|
var __getOwnPropDesc2 = Object.getOwnPropertyDescriptor;
|
|
11242
11354
|
var __getOwnPropNames2 = Object.getOwnPropertyNames;
|
|
11243
11355
|
var __hasOwnProp2 = Object.prototype.hasOwnProperty;
|
|
11244
11356
|
var __export22 = (target, all) => {
|
|
11245
|
-
for (var
|
|
11246
|
-
__defProp22(target,
|
|
11357
|
+
for (var name21 in all)
|
|
11358
|
+
__defProp22(target, name21, { get: all[name21], enumerable: true });
|
|
11247
11359
|
};
|
|
11248
11360
|
var __copyProps2 = (to, from, except, desc) => {
|
|
11249
11361
|
if (from && typeof from === "object" || typeof from === "function") {
|
|
@@ -11265,8 +11377,8 @@ var require_dist2 = chunkO3CS4UGX_cjs.__commonJS({
|
|
|
11265
11377
|
var import_get_context = require_get_context2();
|
|
11266
11378
|
}
|
|
11267
11379
|
});
|
|
11268
|
-
var import_oidc3 =
|
|
11269
|
-
var import_oidc22 =
|
|
11380
|
+
var import_oidc3 = chunkIDRQZVB4_cjs.__toESM(require_dist2(), 1);
|
|
11381
|
+
var import_oidc22 = chunkIDRQZVB4_cjs.__toESM(require_dist2(), 1);
|
|
11270
11382
|
var marker20 = "vercel.ai.gateway.error";
|
|
11271
11383
|
var symbol20 = Symbol.for(marker20);
|
|
11272
11384
|
var _a20;
|
|
@@ -11275,12 +11387,14 @@ var GatewayError2 = class _GatewayError2 extends (_b16 = Error, _a20 = symbol20,
|
|
|
11275
11387
|
constructor({
|
|
11276
11388
|
message,
|
|
11277
11389
|
statusCode = 500,
|
|
11278
|
-
cause
|
|
11390
|
+
cause,
|
|
11391
|
+
generationId
|
|
11279
11392
|
}) {
|
|
11280
|
-
super(message);
|
|
11393
|
+
super(generationId ? `${message} [${generationId}]` : message);
|
|
11281
11394
|
this[_a20] = true;
|
|
11282
11395
|
this.statusCode = statusCode;
|
|
11283
11396
|
this.cause = cause;
|
|
11397
|
+
this.generationId = generationId;
|
|
11284
11398
|
}
|
|
11285
11399
|
/**
|
|
11286
11400
|
* Checks if the given error is a Gateway Error.
|
|
@@ -11303,9 +11417,10 @@ var GatewayAuthenticationError2 = class _GatewayAuthenticationError2 extends (_b
|
|
|
11303
11417
|
constructor({
|
|
11304
11418
|
message = "Authentication failed",
|
|
11305
11419
|
statusCode = 401,
|
|
11306
|
-
cause
|
|
11420
|
+
cause,
|
|
11421
|
+
generationId
|
|
11307
11422
|
} = {}) {
|
|
11308
|
-
super({ message, statusCode, cause });
|
|
11423
|
+
super({ message, statusCode, cause, generationId });
|
|
11309
11424
|
this[_a26] = true;
|
|
11310
11425
|
this.name = name20;
|
|
11311
11426
|
this.type = "authentication_error";
|
|
@@ -11321,7 +11436,8 @@ var GatewayAuthenticationError2 = class _GatewayAuthenticationError2 extends (_b
|
|
|
11321
11436
|
oidcTokenProvided,
|
|
11322
11437
|
message = "Authentication failed",
|
|
11323
11438
|
statusCode = 401,
|
|
11324
|
-
cause
|
|
11439
|
+
cause,
|
|
11440
|
+
generationId
|
|
11325
11441
|
}) {
|
|
11326
11442
|
let contextualMessage;
|
|
11327
11443
|
if (apiKeyProvided) {
|
|
@@ -11349,7 +11465,8 @@ Run 'npx vercel link' to link your project, then 'vc env pull' to fetch the toke
|
|
|
11349
11465
|
return new _GatewayAuthenticationError2({
|
|
11350
11466
|
message: contextualMessage,
|
|
11351
11467
|
statusCode,
|
|
11352
|
-
cause
|
|
11468
|
+
cause,
|
|
11469
|
+
generationId
|
|
11353
11470
|
});
|
|
11354
11471
|
}
|
|
11355
11472
|
};
|
|
@@ -11362,9 +11479,10 @@ var GatewayInvalidRequestError2 = class extends (_b33 = GatewayError2, _a36 = sy
|
|
|
11362
11479
|
constructor({
|
|
11363
11480
|
message = "Invalid request",
|
|
11364
11481
|
statusCode = 400,
|
|
11365
|
-
cause
|
|
11482
|
+
cause,
|
|
11483
|
+
generationId
|
|
11366
11484
|
} = {}) {
|
|
11367
|
-
super({ message, statusCode, cause });
|
|
11485
|
+
super({ message, statusCode, cause, generationId });
|
|
11368
11486
|
this[_a36] = true;
|
|
11369
11487
|
this.name = name26;
|
|
11370
11488
|
this.type = "invalid_request_error";
|
|
@@ -11382,9 +11500,10 @@ var GatewayRateLimitError2 = class extends (_b43 = GatewayError2, _a46 = symbol4
|
|
|
11382
11500
|
constructor({
|
|
11383
11501
|
message = "Rate limit exceeded",
|
|
11384
11502
|
statusCode = 429,
|
|
11385
|
-
cause
|
|
11503
|
+
cause,
|
|
11504
|
+
generationId
|
|
11386
11505
|
} = {}) {
|
|
11387
|
-
super({ message, statusCode, cause });
|
|
11506
|
+
super({ message, statusCode, cause, generationId });
|
|
11388
11507
|
this[_a46] = true;
|
|
11389
11508
|
this.name = name36;
|
|
11390
11509
|
this.type = "rate_limit_exceeded";
|
|
@@ -11410,9 +11529,10 @@ var GatewayModelNotFoundError2 = class extends (_b53 = GatewayError2, _a56 = sym
|
|
|
11410
11529
|
message = "Model not found",
|
|
11411
11530
|
statusCode = 404,
|
|
11412
11531
|
modelId,
|
|
11413
|
-
cause
|
|
11532
|
+
cause,
|
|
11533
|
+
generationId
|
|
11414
11534
|
} = {}) {
|
|
11415
|
-
super({ message, statusCode, cause });
|
|
11535
|
+
super({ message, statusCode, cause, generationId });
|
|
11416
11536
|
this[_a56] = true;
|
|
11417
11537
|
this.name = name46;
|
|
11418
11538
|
this.type = "model_not_found";
|
|
@@ -11431,9 +11551,10 @@ var GatewayInternalServerError2 = class extends (_b63 = GatewayError2, _a66 = sy
|
|
|
11431
11551
|
constructor({
|
|
11432
11552
|
message = "Internal server error",
|
|
11433
11553
|
statusCode = 500,
|
|
11434
|
-
cause
|
|
11554
|
+
cause,
|
|
11555
|
+
generationId
|
|
11435
11556
|
} = {}) {
|
|
11436
|
-
super({ message, statusCode, cause });
|
|
11557
|
+
super({ message, statusCode, cause, generationId });
|
|
11437
11558
|
this[_a66] = true;
|
|
11438
11559
|
this.name = name56;
|
|
11439
11560
|
this.type = "internal_server_error";
|
|
@@ -11453,9 +11574,10 @@ var GatewayResponseError2 = class extends (_b73 = GatewayError2, _a76 = symbol76
|
|
|
11453
11574
|
statusCode = 502,
|
|
11454
11575
|
response,
|
|
11455
11576
|
validationError,
|
|
11456
|
-
cause
|
|
11577
|
+
cause,
|
|
11578
|
+
generationId
|
|
11457
11579
|
} = {}) {
|
|
11458
|
-
super({ message, statusCode, cause });
|
|
11580
|
+
super({ message, statusCode, cause, generationId });
|
|
11459
11581
|
this[_a76] = true;
|
|
11460
11582
|
this.name = name66;
|
|
11461
11583
|
this.type = "response_error";
|
|
@@ -11473,34 +11595,49 @@ async function createGatewayErrorFromResponse2({
|
|
|
11473
11595
|
cause,
|
|
11474
11596
|
authMethod
|
|
11475
11597
|
}) {
|
|
11598
|
+
var _a832;
|
|
11476
11599
|
const parseResult = await safeValidateTypes3({
|
|
11477
11600
|
value: response,
|
|
11478
11601
|
schema: gatewayErrorResponseSchema2
|
|
11479
11602
|
});
|
|
11480
11603
|
if (!parseResult.success) {
|
|
11604
|
+
const rawGenerationId = typeof response === "object" && response !== null && "generationId" in response ? response.generationId : void 0;
|
|
11481
11605
|
return new GatewayResponseError2({
|
|
11482
11606
|
message: `Invalid error response format: ${defaultMessage}`,
|
|
11483
11607
|
statusCode,
|
|
11484
11608
|
response,
|
|
11485
11609
|
validationError: parseResult.error,
|
|
11486
|
-
cause
|
|
11610
|
+
cause,
|
|
11611
|
+
generationId: rawGenerationId
|
|
11487
11612
|
});
|
|
11488
11613
|
}
|
|
11489
11614
|
const validatedResponse = parseResult.value;
|
|
11490
11615
|
const errorType = validatedResponse.error.type;
|
|
11491
11616
|
const message = validatedResponse.error.message;
|
|
11617
|
+
const generationId = (_a832 = validatedResponse.generationId) != null ? _a832 : void 0;
|
|
11492
11618
|
switch (errorType) {
|
|
11493
11619
|
case "authentication_error":
|
|
11494
11620
|
return GatewayAuthenticationError2.createContextualError({
|
|
11495
11621
|
apiKeyProvided: authMethod === "api-key",
|
|
11496
11622
|
oidcTokenProvided: authMethod === "oidc",
|
|
11497
11623
|
statusCode,
|
|
11498
|
-
cause
|
|
11624
|
+
cause,
|
|
11625
|
+
generationId
|
|
11499
11626
|
});
|
|
11500
11627
|
case "invalid_request_error":
|
|
11501
|
-
return new GatewayInvalidRequestError2({
|
|
11628
|
+
return new GatewayInvalidRequestError2({
|
|
11629
|
+
message,
|
|
11630
|
+
statusCode,
|
|
11631
|
+
cause,
|
|
11632
|
+
generationId
|
|
11633
|
+
});
|
|
11502
11634
|
case "rate_limit_exceeded":
|
|
11503
|
-
return new GatewayRateLimitError2({
|
|
11635
|
+
return new GatewayRateLimitError2({
|
|
11636
|
+
message,
|
|
11637
|
+
statusCode,
|
|
11638
|
+
cause,
|
|
11639
|
+
generationId
|
|
11640
|
+
});
|
|
11504
11641
|
case "model_not_found": {
|
|
11505
11642
|
const modelResult = await safeValidateTypes3({
|
|
11506
11643
|
value: validatedResponse.error.param,
|
|
@@ -11510,13 +11647,24 @@ async function createGatewayErrorFromResponse2({
|
|
|
11510
11647
|
message,
|
|
11511
11648
|
statusCode,
|
|
11512
11649
|
modelId: modelResult.success ? modelResult.value.modelId : void 0,
|
|
11513
|
-
cause
|
|
11650
|
+
cause,
|
|
11651
|
+
generationId
|
|
11514
11652
|
});
|
|
11515
11653
|
}
|
|
11516
11654
|
case "internal_server_error":
|
|
11517
|
-
return new GatewayInternalServerError2({
|
|
11655
|
+
return new GatewayInternalServerError2({
|
|
11656
|
+
message,
|
|
11657
|
+
statusCode,
|
|
11658
|
+
cause,
|
|
11659
|
+
generationId
|
|
11660
|
+
});
|
|
11518
11661
|
default:
|
|
11519
|
-
return new GatewayInternalServerError2({
|
|
11662
|
+
return new GatewayInternalServerError2({
|
|
11663
|
+
message,
|
|
11664
|
+
statusCode,
|
|
11665
|
+
cause,
|
|
11666
|
+
generationId
|
|
11667
|
+
});
|
|
11520
11668
|
}
|
|
11521
11669
|
}
|
|
11522
11670
|
var gatewayErrorResponseSchema2 = lazySchema(
|
|
@@ -11527,7 +11675,8 @@ var gatewayErrorResponseSchema2 = lazySchema(
|
|
|
11527
11675
|
type: z4.z.string().nullish(),
|
|
11528
11676
|
param: z4.z.unknown().nullish(),
|
|
11529
11677
|
code: z4.z.union([z4.z.string(), z4.z.number()]).nullish()
|
|
11530
|
-
})
|
|
11678
|
+
}),
|
|
11679
|
+
generationId: z4.z.string().nullish()
|
|
11531
11680
|
})
|
|
11532
11681
|
)
|
|
11533
11682
|
);
|
|
@@ -11803,7 +11952,7 @@ var GatewayLanguageModel2 = class {
|
|
|
11803
11952
|
}
|
|
11804
11953
|
getModelConfigHeaders(modelId, streaming) {
|
|
11805
11954
|
return {
|
|
11806
|
-
"ai-language-model-specification-version": "
|
|
11955
|
+
"ai-language-model-specification-version": "3",
|
|
11807
11956
|
"ai-language-model-id": modelId,
|
|
11808
11957
|
"ai-language-model-streaming": String(streaming)
|
|
11809
11958
|
};
|
|
@@ -11871,7 +12020,7 @@ var GatewayEmbeddingModel2 = class {
|
|
|
11871
12020
|
}
|
|
11872
12021
|
getModelConfigHeaders() {
|
|
11873
12022
|
return {
|
|
11874
|
-
"ai-embedding-model-specification-version": "
|
|
12023
|
+
"ai-embedding-model-specification-version": "3",
|
|
11875
12024
|
"ai-model-id": this.modelId
|
|
11876
12025
|
};
|
|
11877
12026
|
}
|
|
@@ -11901,6 +12050,8 @@ var GatewayImageModel2 = class {
|
|
|
11901
12050
|
size,
|
|
11902
12051
|
aspectRatio,
|
|
11903
12052
|
seed,
|
|
12053
|
+
files,
|
|
12054
|
+
mask,
|
|
11904
12055
|
providerOptions,
|
|
11905
12056
|
headers,
|
|
11906
12057
|
abortSignal
|
|
@@ -11925,7 +12076,11 @@ var GatewayImageModel2 = class {
|
|
|
11925
12076
|
...size && { size },
|
|
11926
12077
|
...aspectRatio && { aspectRatio },
|
|
11927
12078
|
...seed && { seed },
|
|
11928
|
-
...providerOptions && { providerOptions }
|
|
12079
|
+
...providerOptions && { providerOptions },
|
|
12080
|
+
...files && {
|
|
12081
|
+
files: files.map((file) => maybeEncodeImageFile(file))
|
|
12082
|
+
},
|
|
12083
|
+
...mask && { mask: maybeEncodeImageFile(mask) }
|
|
11929
12084
|
},
|
|
11930
12085
|
successfulResponseHandler: createJsonResponseHandler2(
|
|
11931
12086
|
gatewayImageResponseSchema2
|
|
@@ -11957,11 +12112,20 @@ var GatewayImageModel2 = class {
|
|
|
11957
12112
|
}
|
|
11958
12113
|
getModelConfigHeaders() {
|
|
11959
12114
|
return {
|
|
11960
|
-
"ai-image-model-specification-version": "
|
|
12115
|
+
"ai-image-model-specification-version": "3",
|
|
11961
12116
|
"ai-model-id": this.modelId
|
|
11962
12117
|
};
|
|
11963
12118
|
}
|
|
11964
12119
|
};
|
|
12120
|
+
function maybeEncodeImageFile(file) {
|
|
12121
|
+
if (file.type === "file" && file.data instanceof Uint8Array) {
|
|
12122
|
+
return {
|
|
12123
|
+
...file,
|
|
12124
|
+
data: convertUint8ArrayToBase643(file.data)
|
|
12125
|
+
};
|
|
12126
|
+
}
|
|
12127
|
+
return file;
|
|
12128
|
+
}
|
|
11965
12129
|
var providerMetadataEntrySchema2 = z4.z.object({
|
|
11966
12130
|
images: z4.z.array(z4.z.unknown()).optional()
|
|
11967
12131
|
}).catchall(z4.z.unknown());
|
|
@@ -11976,11 +12140,183 @@ var gatewayImageResponseSchema2 = z4.z.object({
|
|
|
11976
12140
|
).optional(),
|
|
11977
12141
|
providerMetadata: z4.z.record(z4.z.string(), providerMetadataEntrySchema2).optional()
|
|
11978
12142
|
});
|
|
12143
|
+
var parallelSearchInputSchema = lazySchema(
|
|
12144
|
+
() => zodSchema3(
|
|
12145
|
+
zod.z.object({
|
|
12146
|
+
objective: zod.z.string().describe(
|
|
12147
|
+
"Natural-language description of the web research goal, including source or freshness guidance and broader context from the task. Maximum 5000 characters."
|
|
12148
|
+
),
|
|
12149
|
+
search_queries: zod.z.array(zod.z.string()).optional().describe(
|
|
12150
|
+
"Optional search queries to supplement the objective. Maximum 200 characters per query."
|
|
12151
|
+
),
|
|
12152
|
+
mode: zod.z.enum(["one-shot", "agentic"]).optional().describe(
|
|
12153
|
+
'Mode preset: "one-shot" for comprehensive results with longer excerpts (default), "agentic" for concise, token-efficient results for multi-step workflows.'
|
|
12154
|
+
),
|
|
12155
|
+
max_results: zod.z.number().optional().describe(
|
|
12156
|
+
"Maximum number of results to return (1-20). Defaults to 10 if not specified."
|
|
12157
|
+
),
|
|
12158
|
+
source_policy: zod.z.object({
|
|
12159
|
+
include_domains: zod.z.array(zod.z.string()).optional().describe("List of domains to include in search results."),
|
|
12160
|
+
exclude_domains: zod.z.array(zod.z.string()).optional().describe("List of domains to exclude from search results."),
|
|
12161
|
+
after_date: zod.z.string().optional().describe(
|
|
12162
|
+
"Only include results published after this date (ISO 8601 format)."
|
|
12163
|
+
)
|
|
12164
|
+
}).optional().describe(
|
|
12165
|
+
"Source policy for controlling which domains to include/exclude and freshness."
|
|
12166
|
+
),
|
|
12167
|
+
excerpts: zod.z.object({
|
|
12168
|
+
max_chars_per_result: zod.z.number().optional().describe("Maximum characters per result."),
|
|
12169
|
+
max_chars_total: zod.z.number().optional().describe("Maximum total characters across all results.")
|
|
12170
|
+
}).optional().describe("Excerpt configuration for controlling result length."),
|
|
12171
|
+
fetch_policy: zod.z.object({
|
|
12172
|
+
max_age_seconds: zod.z.number().optional().describe(
|
|
12173
|
+
"Maximum age in seconds for cached content. Set to 0 to always fetch fresh content."
|
|
12174
|
+
)
|
|
12175
|
+
}).optional().describe("Fetch policy for controlling content freshness.")
|
|
12176
|
+
})
|
|
12177
|
+
)
|
|
12178
|
+
);
|
|
12179
|
+
var parallelSearchOutputSchema = lazySchema(
|
|
12180
|
+
() => zodSchema3(
|
|
12181
|
+
zod.z.union([
|
|
12182
|
+
// Success response
|
|
12183
|
+
zod.z.object({
|
|
12184
|
+
searchId: zod.z.string(),
|
|
12185
|
+
results: zod.z.array(
|
|
12186
|
+
zod.z.object({
|
|
12187
|
+
url: zod.z.string(),
|
|
12188
|
+
title: zod.z.string(),
|
|
12189
|
+
excerpt: zod.z.string(),
|
|
12190
|
+
publishDate: zod.z.string().nullable().optional(),
|
|
12191
|
+
relevanceScore: zod.z.number().optional()
|
|
12192
|
+
})
|
|
12193
|
+
)
|
|
12194
|
+
}),
|
|
12195
|
+
// Error response
|
|
12196
|
+
zod.z.object({
|
|
12197
|
+
error: zod.z.enum([
|
|
12198
|
+
"api_error",
|
|
12199
|
+
"rate_limit",
|
|
12200
|
+
"timeout",
|
|
12201
|
+
"invalid_input",
|
|
12202
|
+
"configuration_error",
|
|
12203
|
+
"unknown"
|
|
12204
|
+
]),
|
|
12205
|
+
statusCode: zod.z.number().optional(),
|
|
12206
|
+
message: zod.z.string()
|
|
12207
|
+
})
|
|
12208
|
+
])
|
|
12209
|
+
)
|
|
12210
|
+
);
|
|
12211
|
+
var parallelSearchToolFactory = createProviderToolFactoryWithOutputSchema({
|
|
12212
|
+
id: "gateway.parallel_search",
|
|
12213
|
+
inputSchema: parallelSearchInputSchema,
|
|
12214
|
+
outputSchema: parallelSearchOutputSchema
|
|
12215
|
+
});
|
|
12216
|
+
var parallelSearch = (config = {}) => parallelSearchToolFactory(config);
|
|
12217
|
+
var perplexitySearchInputSchema = lazySchema(
|
|
12218
|
+
() => zodSchema3(
|
|
12219
|
+
zod.z.object({
|
|
12220
|
+
query: zod.z.union([zod.z.string(), zod.z.array(zod.z.string())]).describe(
|
|
12221
|
+
"Search query (string) or multiple queries (array of up to 5 strings). Multi-query searches return combined results from all queries."
|
|
12222
|
+
),
|
|
12223
|
+
max_results: zod.z.number().optional().describe(
|
|
12224
|
+
"Maximum number of search results to return (1-20, default: 10)"
|
|
12225
|
+
),
|
|
12226
|
+
max_tokens_per_page: zod.z.number().optional().describe(
|
|
12227
|
+
"Maximum number of tokens to extract per search result page (256-2048, default: 2048)"
|
|
12228
|
+
),
|
|
12229
|
+
max_tokens: zod.z.number().optional().describe(
|
|
12230
|
+
"Maximum total tokens across all search results (default: 25000, max: 1000000)"
|
|
12231
|
+
),
|
|
12232
|
+
country: zod.z.string().optional().describe(
|
|
12233
|
+
"Two-letter ISO 3166-1 alpha-2 country code for regional search results (e.g., 'US', 'GB', 'FR')"
|
|
12234
|
+
),
|
|
12235
|
+
search_domain_filter: zod.z.array(zod.z.string()).optional().describe(
|
|
12236
|
+
"List of domains to include or exclude from search results (max 20). To include: ['nature.com', 'science.org']. To exclude: ['-example.com', '-spam.net']"
|
|
12237
|
+
),
|
|
12238
|
+
search_language_filter: zod.z.array(zod.z.string()).optional().describe(
|
|
12239
|
+
"List of ISO 639-1 language codes to filter results (max 10, lowercase). Examples: ['en', 'fr', 'de']"
|
|
12240
|
+
),
|
|
12241
|
+
search_after_date: zod.z.string().optional().describe(
|
|
12242
|
+
"Include only results published after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
|
|
12243
|
+
),
|
|
12244
|
+
search_before_date: zod.z.string().optional().describe(
|
|
12245
|
+
"Include only results published before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
|
|
12246
|
+
),
|
|
12247
|
+
last_updated_after_filter: zod.z.string().optional().describe(
|
|
12248
|
+
"Include only results last updated after this date. Format: 'MM/DD/YYYY' (e.g., '3/1/2025'). Cannot be used with search_recency_filter."
|
|
12249
|
+
),
|
|
12250
|
+
last_updated_before_filter: zod.z.string().optional().describe(
|
|
12251
|
+
"Include only results last updated before this date. Format: 'MM/DD/YYYY' (e.g., '3/15/2025'). Cannot be used with search_recency_filter."
|
|
12252
|
+
),
|
|
12253
|
+
search_recency_filter: zod.z.enum(["day", "week", "month", "year"]).optional().describe(
|
|
12254
|
+
"Filter results by relative time period. Cannot be used with search_after_date or search_before_date."
|
|
12255
|
+
)
|
|
12256
|
+
})
|
|
12257
|
+
)
|
|
12258
|
+
);
|
|
12259
|
+
var perplexitySearchOutputSchema = lazySchema(
|
|
12260
|
+
() => zodSchema3(
|
|
12261
|
+
zod.z.union([
|
|
12262
|
+
// Success response
|
|
12263
|
+
zod.z.object({
|
|
12264
|
+
results: zod.z.array(
|
|
12265
|
+
zod.z.object({
|
|
12266
|
+
title: zod.z.string(),
|
|
12267
|
+
url: zod.z.string(),
|
|
12268
|
+
snippet: zod.z.string(),
|
|
12269
|
+
date: zod.z.string().optional(),
|
|
12270
|
+
lastUpdated: zod.z.string().optional()
|
|
12271
|
+
})
|
|
12272
|
+
),
|
|
12273
|
+
id: zod.z.string()
|
|
12274
|
+
}),
|
|
12275
|
+
// Error response
|
|
12276
|
+
zod.z.object({
|
|
12277
|
+
error: zod.z.enum([
|
|
12278
|
+
"api_error",
|
|
12279
|
+
"rate_limit",
|
|
12280
|
+
"timeout",
|
|
12281
|
+
"invalid_input",
|
|
12282
|
+
"unknown"
|
|
12283
|
+
]),
|
|
12284
|
+
statusCode: zod.z.number().optional(),
|
|
12285
|
+
message: zod.z.string()
|
|
12286
|
+
})
|
|
12287
|
+
])
|
|
12288
|
+
)
|
|
12289
|
+
);
|
|
12290
|
+
var perplexitySearchToolFactory = createProviderToolFactoryWithOutputSchema({
|
|
12291
|
+
id: "gateway.perplexity_search",
|
|
12292
|
+
inputSchema: perplexitySearchInputSchema,
|
|
12293
|
+
outputSchema: perplexitySearchOutputSchema
|
|
12294
|
+
});
|
|
12295
|
+
var perplexitySearch = (config = {}) => perplexitySearchToolFactory(config);
|
|
12296
|
+
var gatewayTools = {
|
|
12297
|
+
/**
|
|
12298
|
+
* Search the web using Parallel AI's Search API for LLM-optimized excerpts.
|
|
12299
|
+
*
|
|
12300
|
+
* Takes a natural language objective and returns relevant excerpts,
|
|
12301
|
+
* replacing multiple keyword searches with a single call for broad
|
|
12302
|
+
* or complex queries. Supports different search types for depth vs
|
|
12303
|
+
* breadth tradeoffs.
|
|
12304
|
+
*/
|
|
12305
|
+
parallelSearch,
|
|
12306
|
+
/**
|
|
12307
|
+
* Search the web using Perplexity's Search API for real-time information,
|
|
12308
|
+
* news, research papers, and articles.
|
|
12309
|
+
*
|
|
12310
|
+
* Provides ranked search results with advanced filtering options including
|
|
12311
|
+
* domain, language, date range, and recency filters.
|
|
12312
|
+
*/
|
|
12313
|
+
perplexitySearch
|
|
12314
|
+
};
|
|
11979
12315
|
async function getVercelRequestId2() {
|
|
11980
12316
|
var _a832;
|
|
11981
12317
|
return (_a832 = (0, import_oidc3.getContext)().headers) == null ? void 0 : _a832["x-vercel-id"];
|
|
11982
12318
|
}
|
|
11983
|
-
var VERSION5 = "3.0.
|
|
12319
|
+
var VERSION5 = "3.0.32";
|
|
11984
12320
|
var AI_GATEWAY_PROTOCOL_VERSION2 = "0.0.1";
|
|
11985
12321
|
function createGatewayProvider2(options = {}) {
|
|
11986
12322
|
var _a832, _b83;
|
|
@@ -11990,8 +12326,8 @@ function createGatewayProvider2(options = {}) {
|
|
|
11990
12326
|
let lastFetchTime = 0;
|
|
11991
12327
|
const baseURL = (_b83 = withoutTrailingSlash2(options.baseURL)) != null ? _b83 : "https://ai-gateway.vercel.sh/v3/ai";
|
|
11992
12328
|
const getHeaders = async () => {
|
|
11993
|
-
|
|
11994
|
-
|
|
12329
|
+
try {
|
|
12330
|
+
const auth = await getGatewayAuthToken2(options);
|
|
11995
12331
|
return withUserAgentSuffix2(
|
|
11996
12332
|
{
|
|
11997
12333
|
Authorization: `Bearer ${auth.token}`,
|
|
@@ -12001,12 +12337,14 @@ function createGatewayProvider2(options = {}) {
|
|
|
12001
12337
|
},
|
|
12002
12338
|
`ai-sdk/gateway/${VERSION5}`
|
|
12003
12339
|
);
|
|
12340
|
+
} catch (error) {
|
|
12341
|
+
throw GatewayAuthenticationError2.createContextualError({
|
|
12342
|
+
apiKeyProvided: false,
|
|
12343
|
+
oidcTokenProvided: false,
|
|
12344
|
+
statusCode: 401,
|
|
12345
|
+
cause: error
|
|
12346
|
+
});
|
|
12004
12347
|
}
|
|
12005
|
-
throw GatewayAuthenticationError2.createContextualError({
|
|
12006
|
-
apiKeyProvided: false,
|
|
12007
|
-
oidcTokenProvided: false,
|
|
12008
|
-
statusCode: 401
|
|
12009
|
-
});
|
|
12010
12348
|
};
|
|
12011
12349
|
const createO11yHeaders = () => {
|
|
12012
12350
|
const deploymentId = loadOptionalSetting2({
|
|
@@ -12105,6 +12443,7 @@ function createGatewayProvider2(options = {}) {
|
|
|
12105
12443
|
};
|
|
12106
12444
|
provider.embeddingModel = createEmbeddingModel;
|
|
12107
12445
|
provider.textEmbeddingModel = createEmbeddingModel;
|
|
12446
|
+
provider.tools = gatewayTools;
|
|
12108
12447
|
return provider;
|
|
12109
12448
|
}
|
|
12110
12449
|
var gateway2 = createGatewayProvider2();
|
|
@@ -12119,15 +12458,11 @@ async function getGatewayAuthToken2(options) {
|
|
|
12119
12458
|
authMethod: "api-key"
|
|
12120
12459
|
};
|
|
12121
12460
|
}
|
|
12122
|
-
|
|
12123
|
-
|
|
12124
|
-
|
|
12125
|
-
|
|
12126
|
-
|
|
12127
|
-
};
|
|
12128
|
-
} catch (e) {
|
|
12129
|
-
return null;
|
|
12130
|
-
}
|
|
12461
|
+
const oidcToken = await (0, import_oidc22.getVercelOidcToken)();
|
|
12462
|
+
return {
|
|
12463
|
+
token: oidcToken,
|
|
12464
|
+
authMethod: "oidc"
|
|
12465
|
+
};
|
|
12131
12466
|
}
|
|
12132
12467
|
var _globalThis3 = typeof globalThis === "object" ? globalThis : global;
|
|
12133
12468
|
var VERSION23 = "1.9.0";
|
|
@@ -12200,11 +12535,11 @@ var major3 = VERSION23.split(".")[0];
|
|
|
12200
12535
|
var GLOBAL_OPENTELEMETRY_API_KEY3 = /* @__PURE__ */ Symbol.for("opentelemetry.js.api." + major3);
|
|
12201
12536
|
var _global3 = _globalThis3;
|
|
12202
12537
|
function registerGlobal3(type, instance, diag, allowOverride) {
|
|
12203
|
-
var
|
|
12538
|
+
var _a21;
|
|
12204
12539
|
if (allowOverride === void 0) {
|
|
12205
12540
|
allowOverride = false;
|
|
12206
12541
|
}
|
|
12207
|
-
var api = _global3[GLOBAL_OPENTELEMETRY_API_KEY3] = (
|
|
12542
|
+
var api = _global3[GLOBAL_OPENTELEMETRY_API_KEY3] = (_a21 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) !== null && _a21 !== void 0 ? _a21 : {
|
|
12208
12543
|
version: VERSION23
|
|
12209
12544
|
};
|
|
12210
12545
|
if (!allowOverride && api[type]) {
|
|
@@ -12222,8 +12557,8 @@ function registerGlobal3(type, instance, diag, allowOverride) {
|
|
|
12222
12557
|
return true;
|
|
12223
12558
|
}
|
|
12224
12559
|
function getGlobal3(type) {
|
|
12225
|
-
var
|
|
12226
|
-
var globalVersion = (
|
|
12560
|
+
var _a21, _b83;
|
|
12561
|
+
var globalVersion = (_a21 = _global3[GLOBAL_OPENTELEMETRY_API_KEY3]) === null || _a21 === void 0 ? void 0 : _a21.version;
|
|
12227
12562
|
if (!globalVersion || !isCompatible3(globalVersion)) {
|
|
12228
12563
|
return;
|
|
12229
12564
|
}
|
|
@@ -12392,13 +12727,13 @@ var DiagAPI3 = (
|
|
|
12392
12727
|
}
|
|
12393
12728
|
var self = this;
|
|
12394
12729
|
var setLogger = function(logger, optionsOrLogLevel) {
|
|
12395
|
-
var
|
|
12730
|
+
var _a21, _b83, _c;
|
|
12396
12731
|
if (optionsOrLogLevel === void 0) {
|
|
12397
12732
|
optionsOrLogLevel = { logLevel: DiagLogLevel3.INFO };
|
|
12398
12733
|
}
|
|
12399
12734
|
if (logger === self) {
|
|
12400
12735
|
var err = new Error("Cannot use diag as the logger for itself. Please use a DiagLogger implementation like ConsoleDiagLogger or a custom implementation");
|
|
12401
|
-
self.error((
|
|
12736
|
+
self.error((_a21 = err.stack) !== null && _a21 !== void 0 ? _a21 : err.message);
|
|
12402
12737
|
return false;
|
|
12403
12738
|
}
|
|
12404
12739
|
if (typeof optionsOrLogLevel === "number") {
|
|
@@ -12450,14 +12785,14 @@ var BaseContext3 = (
|
|
|
12450
12785
|
return self._currentContext.get(key);
|
|
12451
12786
|
};
|
|
12452
12787
|
self.setValue = function(key, value) {
|
|
12453
|
-
var
|
|
12454
|
-
|
|
12455
|
-
return
|
|
12788
|
+
var context2 = new BaseContext22(self._currentContext);
|
|
12789
|
+
context2._currentContext.set(key, value);
|
|
12790
|
+
return context2;
|
|
12456
12791
|
};
|
|
12457
12792
|
self.deleteValue = function(key) {
|
|
12458
|
-
var
|
|
12459
|
-
|
|
12460
|
-
return
|
|
12793
|
+
var context2 = new BaseContext22(self._currentContext);
|
|
12794
|
+
context2._currentContext.delete(key);
|
|
12795
|
+
return context2;
|
|
12461
12796
|
};
|
|
12462
12797
|
}
|
|
12463
12798
|
return BaseContext22;
|
|
@@ -12562,16 +12897,16 @@ var ContextAPI3 = (
|
|
|
12562
12897
|
ContextAPI22.prototype.active = function() {
|
|
12563
12898
|
return this._getContextManager().active();
|
|
12564
12899
|
};
|
|
12565
|
-
ContextAPI22.prototype.with = function(
|
|
12566
|
-
var
|
|
12900
|
+
ContextAPI22.prototype.with = function(context2, fn, thisArg) {
|
|
12901
|
+
var _a21;
|
|
12567
12902
|
var args = [];
|
|
12568
12903
|
for (var _i = 3; _i < arguments.length; _i++) {
|
|
12569
12904
|
args[_i - 3] = arguments[_i];
|
|
12570
12905
|
}
|
|
12571
|
-
return (
|
|
12906
|
+
return (_a21 = this._getContextManager()).with.apply(_a21, __spreadArray43([context2, fn, thisArg], __read43(args), false));
|
|
12572
12907
|
};
|
|
12573
|
-
ContextAPI22.prototype.bind = function(
|
|
12574
|
-
return this._getContextManager().bind(
|
|
12908
|
+
ContextAPI22.prototype.bind = function(context2, target) {
|
|
12909
|
+
return this._getContextManager().bind(context2, target);
|
|
12575
12910
|
};
|
|
12576
12911
|
ContextAPI22.prototype._getContextManager = function() {
|
|
12577
12912
|
return getGlobal3(API_NAME23) || NOOP_CONTEXT_MANAGER3;
|
|
@@ -12639,24 +12974,24 @@ var NonRecordingSpan3 = (
|
|
|
12639
12974
|
})()
|
|
12640
12975
|
);
|
|
12641
12976
|
var SPAN_KEY3 = createContextKey3("OpenTelemetry Context Key SPAN");
|
|
12642
|
-
function getSpan3(
|
|
12643
|
-
return
|
|
12977
|
+
function getSpan3(context2) {
|
|
12978
|
+
return context2.getValue(SPAN_KEY3) || void 0;
|
|
12644
12979
|
}
|
|
12645
12980
|
function getActiveSpan3() {
|
|
12646
12981
|
return getSpan3(ContextAPI3.getInstance().active());
|
|
12647
12982
|
}
|
|
12648
|
-
function setSpan3(
|
|
12649
|
-
return
|
|
12983
|
+
function setSpan3(context2, span) {
|
|
12984
|
+
return context2.setValue(SPAN_KEY3, span);
|
|
12650
12985
|
}
|
|
12651
|
-
function deleteSpan3(
|
|
12652
|
-
return
|
|
12986
|
+
function deleteSpan3(context2) {
|
|
12987
|
+
return context2.deleteValue(SPAN_KEY3);
|
|
12653
12988
|
}
|
|
12654
|
-
function setSpanContext3(
|
|
12655
|
-
return setSpan3(
|
|
12989
|
+
function setSpanContext3(context2, spanContext) {
|
|
12990
|
+
return setSpan3(context2, new NonRecordingSpan3(spanContext));
|
|
12656
12991
|
}
|
|
12657
|
-
function getSpanContext3(
|
|
12658
|
-
var
|
|
12659
|
-
return (
|
|
12992
|
+
function getSpanContext3(context2) {
|
|
12993
|
+
var _a21;
|
|
12994
|
+
return (_a21 = getSpan3(context2)) === null || _a21 === void 0 ? void 0 : _a21.spanContext();
|
|
12660
12995
|
}
|
|
12661
12996
|
var VALID_TRACEID_REGEX3 = /^([0-9a-f]{32})$/i;
|
|
12662
12997
|
var VALID_SPANID_REGEX3 = /^[0-9a-f]{16}$/i;
|
|
@@ -12678,22 +13013,22 @@ var NoopTracer3 = (
|
|
|
12678
13013
|
(function() {
|
|
12679
13014
|
function NoopTracer22() {
|
|
12680
13015
|
}
|
|
12681
|
-
NoopTracer22.prototype.startSpan = function(
|
|
12682
|
-
if (
|
|
12683
|
-
|
|
13016
|
+
NoopTracer22.prototype.startSpan = function(name21, options, context2) {
|
|
13017
|
+
if (context2 === void 0) {
|
|
13018
|
+
context2 = contextApi3.active();
|
|
12684
13019
|
}
|
|
12685
13020
|
var root = Boolean(options === null || options === void 0 ? void 0 : options.root);
|
|
12686
13021
|
if (root) {
|
|
12687
13022
|
return new NonRecordingSpan3();
|
|
12688
13023
|
}
|
|
12689
|
-
var parentFromContext =
|
|
13024
|
+
var parentFromContext = context2 && getSpanContext3(context2);
|
|
12690
13025
|
if (isSpanContext3(parentFromContext) && isSpanContextValid3(parentFromContext)) {
|
|
12691
13026
|
return new NonRecordingSpan3(parentFromContext);
|
|
12692
13027
|
} else {
|
|
12693
13028
|
return new NonRecordingSpan3();
|
|
12694
13029
|
}
|
|
12695
13030
|
};
|
|
12696
|
-
NoopTracer22.prototype.startActiveSpan = function(
|
|
13031
|
+
NoopTracer22.prototype.startActiveSpan = function(name21, arg2, arg3, arg4) {
|
|
12697
13032
|
var opts;
|
|
12698
13033
|
var ctx;
|
|
12699
13034
|
var fn;
|
|
@@ -12710,7 +13045,7 @@ var NoopTracer3 = (
|
|
|
12710
13045
|
fn = arg4;
|
|
12711
13046
|
}
|
|
12712
13047
|
var parentContext = ctx !== null && ctx !== void 0 ? ctx : contextApi3.active();
|
|
12713
|
-
var span = this.startSpan(
|
|
13048
|
+
var span = this.startSpan(name21, opts, parentContext);
|
|
12714
13049
|
var contextWithSpanSet = setSpan3(parentContext, span);
|
|
12715
13050
|
return contextApi3.with(contextWithSpanSet, fn, void 0, span);
|
|
12716
13051
|
};
|
|
@@ -12724,14 +13059,14 @@ var NOOP_TRACER3 = new NoopTracer3();
|
|
|
12724
13059
|
var ProxyTracer3 = (
|
|
12725
13060
|
/** @class */
|
|
12726
13061
|
(function() {
|
|
12727
|
-
function ProxyTracer22(_provider,
|
|
13062
|
+
function ProxyTracer22(_provider, name21, version, options) {
|
|
12728
13063
|
this._provider = _provider;
|
|
12729
|
-
this.name =
|
|
13064
|
+
this.name = name21;
|
|
12730
13065
|
this.version = version;
|
|
12731
13066
|
this.options = options;
|
|
12732
13067
|
}
|
|
12733
|
-
ProxyTracer22.prototype.startSpan = function(
|
|
12734
|
-
return this._getTracer().startSpan(
|
|
13068
|
+
ProxyTracer22.prototype.startSpan = function(name21, options, context2) {
|
|
13069
|
+
return this._getTracer().startSpan(name21, options, context2);
|
|
12735
13070
|
};
|
|
12736
13071
|
ProxyTracer22.prototype.startActiveSpan = function(_name, _options, _context, _fn) {
|
|
12737
13072
|
var tracer = this._getTracer();
|
|
@@ -12768,20 +13103,20 @@ var ProxyTracerProvider3 = (
|
|
|
12768
13103
|
(function() {
|
|
12769
13104
|
function ProxyTracerProvider22() {
|
|
12770
13105
|
}
|
|
12771
|
-
ProxyTracerProvider22.prototype.getTracer = function(
|
|
12772
|
-
var
|
|
12773
|
-
return (
|
|
13106
|
+
ProxyTracerProvider22.prototype.getTracer = function(name21, version, options) {
|
|
13107
|
+
var _a21;
|
|
13108
|
+
return (_a21 = this.getDelegateTracer(name21, version, options)) !== null && _a21 !== void 0 ? _a21 : new ProxyTracer3(this, name21, version, options);
|
|
12774
13109
|
};
|
|
12775
13110
|
ProxyTracerProvider22.prototype.getDelegate = function() {
|
|
12776
|
-
var
|
|
12777
|
-
return (
|
|
13111
|
+
var _a21;
|
|
13112
|
+
return (_a21 = this._delegate) !== null && _a21 !== void 0 ? _a21 : NOOP_TRACER_PROVIDER3;
|
|
12778
13113
|
};
|
|
12779
13114
|
ProxyTracerProvider22.prototype.setDelegate = function(delegate) {
|
|
12780
13115
|
this._delegate = delegate;
|
|
12781
13116
|
};
|
|
12782
|
-
ProxyTracerProvider22.prototype.getDelegateTracer = function(
|
|
12783
|
-
var
|
|
12784
|
-
return (
|
|
13117
|
+
ProxyTracerProvider22.prototype.getDelegateTracer = function(name21, version, options) {
|
|
13118
|
+
var _a21;
|
|
13119
|
+
return (_a21 = this._delegate) === null || _a21 === void 0 ? void 0 : _a21.getTracer(name21, version, options);
|
|
12785
13120
|
};
|
|
12786
13121
|
return ProxyTracerProvider22;
|
|
12787
13122
|
})()
|
|
@@ -12792,6 +13127,7 @@ var SpanStatusCode3;
|
|
|
12792
13127
|
SpanStatusCode22[SpanStatusCode22["OK"] = 1] = "OK";
|
|
12793
13128
|
SpanStatusCode22[SpanStatusCode22["ERROR"] = 2] = "ERROR";
|
|
12794
13129
|
})(SpanStatusCode3 || (SpanStatusCode3 = {}));
|
|
13130
|
+
var context = ContextAPI3.getInstance();
|
|
12795
13131
|
var API_NAME33 = "trace";
|
|
12796
13132
|
var TraceAPI3 = (
|
|
12797
13133
|
/** @class */
|
|
@@ -12823,8 +13159,8 @@ var TraceAPI3 = (
|
|
|
12823
13159
|
TraceAPI22.prototype.getTracerProvider = function() {
|
|
12824
13160
|
return getGlobal3(API_NAME33) || this._proxyTracerProvider;
|
|
12825
13161
|
};
|
|
12826
|
-
TraceAPI22.prototype.getTracer = function(
|
|
12827
|
-
return this.getTracerProvider().getTracer(
|
|
13162
|
+
TraceAPI22.prototype.getTracer = function(name21, version) {
|
|
13163
|
+
return this.getTracerProvider().getTracer(name21, version);
|
|
12828
13164
|
};
|
|
12829
13165
|
TraceAPI22.prototype.disable = function() {
|
|
12830
13166
|
unregisterGlobal3(API_NAME33, DiagAPI3.instance());
|
|
@@ -12836,8 +13172,8 @@ var TraceAPI3 = (
|
|
|
12836
13172
|
var trace3 = TraceAPI3.getInstance();
|
|
12837
13173
|
var __defProp4 = Object.defineProperty;
|
|
12838
13174
|
var __export3 = (target, all) => {
|
|
12839
|
-
for (var
|
|
12840
|
-
__defProp4(target,
|
|
13175
|
+
for (var name21 in all)
|
|
13176
|
+
__defProp4(target, name21, { get: all[name21], enumerable: true });
|
|
12841
13177
|
};
|
|
12842
13178
|
var name76 = "AI_InvalidArgumentError";
|
|
12843
13179
|
var marker86 = `vercel.ai.error.${name76}`;
|
|
@@ -12862,10 +13198,10 @@ var InvalidArgumentError23 = class extends AISDKError3 {
|
|
|
12862
13198
|
}
|
|
12863
13199
|
};
|
|
12864
13200
|
_a86 = symbol86;
|
|
12865
|
-
var
|
|
12866
|
-
var
|
|
12867
|
-
var
|
|
12868
|
-
var
|
|
13201
|
+
var name86 = "AI_NoObjectGeneratedError";
|
|
13202
|
+
var marker823 = `vercel.ai.error.${name86}`;
|
|
13203
|
+
var symbol823 = Symbol.for(marker823);
|
|
13204
|
+
var _a823;
|
|
12869
13205
|
var NoObjectGeneratedError3 = class extends AISDKError3 {
|
|
12870
13206
|
constructor({
|
|
12871
13207
|
message = "No object generated.",
|
|
@@ -12875,18 +13211,18 @@ var NoObjectGeneratedError3 = class extends AISDKError3 {
|
|
|
12875
13211
|
usage,
|
|
12876
13212
|
finishReason
|
|
12877
13213
|
}) {
|
|
12878
|
-
super({ name:
|
|
12879
|
-
this[
|
|
13214
|
+
super({ name: name86, message, cause });
|
|
13215
|
+
this[_a823] = true;
|
|
12880
13216
|
this.text = text22;
|
|
12881
13217
|
this.response = response;
|
|
12882
13218
|
this.usage = usage;
|
|
12883
13219
|
this.finishReason = finishReason;
|
|
12884
13220
|
}
|
|
12885
13221
|
static isInstance(error) {
|
|
12886
|
-
return AISDKError3.hasMarker(error,
|
|
13222
|
+
return AISDKError3.hasMarker(error, marker823);
|
|
12887
13223
|
}
|
|
12888
13224
|
};
|
|
12889
|
-
|
|
13225
|
+
_a823 = symbol823;
|
|
12890
13226
|
var UnsupportedModelVersionError3 = class extends AISDKError3 {
|
|
12891
13227
|
constructor(options) {
|
|
12892
13228
|
super({
|
|
@@ -12898,27 +13234,27 @@ var UnsupportedModelVersionError3 = class extends AISDKError3 {
|
|
|
12898
13234
|
this.modelId = options.modelId;
|
|
12899
13235
|
}
|
|
12900
13236
|
};
|
|
12901
|
-
var
|
|
12902
|
-
var
|
|
12903
|
-
var
|
|
12904
|
-
var
|
|
13237
|
+
var name192 = "AI_RetryError";
|
|
13238
|
+
var marker192 = `vercel.ai.error.${name192}`;
|
|
13239
|
+
var symbol192 = Symbol.for(marker192);
|
|
13240
|
+
var _a192;
|
|
12905
13241
|
var RetryError3 = class extends AISDKError3 {
|
|
12906
13242
|
constructor({
|
|
12907
13243
|
message,
|
|
12908
13244
|
reason,
|
|
12909
13245
|
errors
|
|
12910
13246
|
}) {
|
|
12911
|
-
super({ name:
|
|
12912
|
-
this[
|
|
13247
|
+
super({ name: name192, message });
|
|
13248
|
+
this[_a192] = true;
|
|
12913
13249
|
this.reason = reason;
|
|
12914
13250
|
this.errors = errors;
|
|
12915
13251
|
this.lastError = errors[errors.length - 1];
|
|
12916
13252
|
}
|
|
12917
13253
|
static isInstance(error) {
|
|
12918
|
-
return AISDKError3.hasMarker(error,
|
|
13254
|
+
return AISDKError3.hasMarker(error, marker192);
|
|
12919
13255
|
}
|
|
12920
13256
|
};
|
|
12921
|
-
|
|
13257
|
+
_a192 = symbol192;
|
|
12922
13258
|
function formatWarning({
|
|
12923
13259
|
warning,
|
|
12924
13260
|
provider,
|
|
@@ -13023,10 +13359,19 @@ function resolveEmbeddingModel2(model) {
|
|
|
13023
13359
|
return getGlobalProvider2().embeddingModel(model);
|
|
13024
13360
|
}
|
|
13025
13361
|
function getGlobalProvider2() {
|
|
13026
|
-
var
|
|
13027
|
-
return (
|
|
13362
|
+
var _a21;
|
|
13363
|
+
return (_a21 = globalThis.AI_SDK_DEFAULT_PROVIDER) != null ? _a21 : gateway2;
|
|
13364
|
+
}
|
|
13365
|
+
function getTotalTimeoutMs(timeout) {
|
|
13366
|
+
if (timeout == null) {
|
|
13367
|
+
return void 0;
|
|
13368
|
+
}
|
|
13369
|
+
if (typeof timeout === "number") {
|
|
13370
|
+
return timeout;
|
|
13371
|
+
}
|
|
13372
|
+
return timeout.totalMs;
|
|
13028
13373
|
}
|
|
13029
|
-
var VERSION33 = "6.0.
|
|
13374
|
+
var VERSION33 = "6.0.69";
|
|
13030
13375
|
var dataContentSchema3 = z4.z.union([
|
|
13031
13376
|
z4.z.string(),
|
|
13032
13377
|
z4.z.instanceof(Uint8Array),
|
|
@@ -13034,8 +13379,8 @@ var dataContentSchema3 = z4.z.union([
|
|
|
13034
13379
|
z4.z.custom(
|
|
13035
13380
|
// Buffer might not be available in some environments such as CloudFlare:
|
|
13036
13381
|
(value) => {
|
|
13037
|
-
var
|
|
13038
|
-
return (_b83 = (
|
|
13382
|
+
var _a21, _b83;
|
|
13383
|
+
return (_b83 = (_a21 = globalThis.Buffer) == null ? void 0 : _a21.isBuffer(value)) != null ? _b83 : false;
|
|
13039
13384
|
},
|
|
13040
13385
|
{ message: "Must be a Buffer" }
|
|
13041
13386
|
)
|
|
@@ -13249,17 +13594,26 @@ function getBaseTelemetryAttributes3({
|
|
|
13249
13594
|
telemetry,
|
|
13250
13595
|
headers
|
|
13251
13596
|
}) {
|
|
13252
|
-
var
|
|
13597
|
+
var _a21;
|
|
13253
13598
|
return {
|
|
13254
13599
|
"ai.model.provider": model.provider,
|
|
13255
13600
|
"ai.model.id": model.modelId,
|
|
13256
13601
|
// settings:
|
|
13257
13602
|
...Object.entries(settings).reduce((attributes, [key, value]) => {
|
|
13258
|
-
|
|
13603
|
+
if (key === "timeout") {
|
|
13604
|
+
const totalTimeoutMs = getTotalTimeoutMs(
|
|
13605
|
+
value
|
|
13606
|
+
);
|
|
13607
|
+
if (totalTimeoutMs != null) {
|
|
13608
|
+
attributes[`ai.settings.${key}`] = totalTimeoutMs;
|
|
13609
|
+
}
|
|
13610
|
+
} else {
|
|
13611
|
+
attributes[`ai.settings.${key}`] = value;
|
|
13612
|
+
}
|
|
13259
13613
|
return attributes;
|
|
13260
13614
|
}, {}),
|
|
13261
13615
|
// add metadata as attributes:
|
|
13262
|
-
...Object.entries((
|
|
13616
|
+
...Object.entries((_a21 = telemetry == null ? void 0 : telemetry.metadata) != null ? _a21 : {}).reduce(
|
|
13263
13617
|
(attributes, [key, value]) => {
|
|
13264
13618
|
attributes[`ai.telemetry.metadata.${key}`] = value;
|
|
13265
13619
|
return attributes;
|
|
@@ -13279,7 +13633,7 @@ var noopTracer3 = {
|
|
|
13279
13633
|
startSpan() {
|
|
13280
13634
|
return noopSpan3;
|
|
13281
13635
|
},
|
|
13282
|
-
startActiveSpan(
|
|
13636
|
+
startActiveSpan(name21, arg1, arg2, arg3) {
|
|
13283
13637
|
if (typeof arg1 === "function") {
|
|
13284
13638
|
return arg1(noopSpan3);
|
|
13285
13639
|
}
|
|
@@ -13344,18 +13698,19 @@ function getTracer3({
|
|
|
13344
13698
|
return trace3.getTracer("ai");
|
|
13345
13699
|
}
|
|
13346
13700
|
async function recordSpan3({
|
|
13347
|
-
name:
|
|
13701
|
+
name: name21,
|
|
13348
13702
|
tracer,
|
|
13349
13703
|
attributes,
|
|
13350
13704
|
fn,
|
|
13351
13705
|
endWhenDone = true
|
|
13352
13706
|
}) {
|
|
13353
13707
|
return tracer.startActiveSpan(
|
|
13354
|
-
|
|
13708
|
+
name21,
|
|
13355
13709
|
{ attributes: await attributes },
|
|
13356
13710
|
async (span) => {
|
|
13711
|
+
const ctx = context.active();
|
|
13357
13712
|
try {
|
|
13358
|
-
const result = await fn(span);
|
|
13713
|
+
const result = await context.with(ctx, () => fn(span));
|
|
13359
13714
|
if (endWhenDone) {
|
|
13360
13715
|
span.end();
|
|
13361
13716
|
}
|
|
@@ -13884,37 +14239,42 @@ async function parsePartialJson3(jsonText) {
|
|
|
13884
14239
|
return { value: void 0, state: "failed-parse" };
|
|
13885
14240
|
}
|
|
13886
14241
|
var text3 = () => ({
|
|
14242
|
+
name: "text",
|
|
13887
14243
|
responseFormat: Promise.resolve({ type: "text" }),
|
|
13888
14244
|
async parseCompleteOutput({ text: text22 }) {
|
|
13889
14245
|
return text22;
|
|
13890
14246
|
},
|
|
13891
14247
|
async parsePartialOutput({ text: text22 }) {
|
|
13892
14248
|
return { partial: text22 };
|
|
14249
|
+
},
|
|
14250
|
+
createElementStreamTransform() {
|
|
14251
|
+
return void 0;
|
|
13893
14252
|
}
|
|
13894
14253
|
});
|
|
13895
14254
|
var object3 = ({
|
|
13896
14255
|
schema: inputSchema,
|
|
13897
|
-
name:
|
|
14256
|
+
name: name21,
|
|
13898
14257
|
description
|
|
13899
14258
|
}) => {
|
|
13900
14259
|
const schema = asSchema3(inputSchema);
|
|
13901
14260
|
return {
|
|
14261
|
+
name: "object",
|
|
13902
14262
|
responseFormat: resolve2(schema.jsonSchema).then((jsonSchema22) => ({
|
|
13903
14263
|
type: "json",
|
|
13904
14264
|
schema: jsonSchema22,
|
|
13905
|
-
...
|
|
14265
|
+
...name21 != null && { name: name21 },
|
|
13906
14266
|
...description != null && { description }
|
|
13907
14267
|
})),
|
|
13908
|
-
async parseCompleteOutput({ text: text22 },
|
|
14268
|
+
async parseCompleteOutput({ text: text22 }, context2) {
|
|
13909
14269
|
const parseResult = await safeParseJSON3({ text: text22 });
|
|
13910
14270
|
if (!parseResult.success) {
|
|
13911
14271
|
throw new NoObjectGeneratedError3({
|
|
13912
14272
|
message: "No object generated: could not parse the response.",
|
|
13913
14273
|
cause: parseResult.error,
|
|
13914
14274
|
text: text22,
|
|
13915
|
-
response:
|
|
13916
|
-
usage:
|
|
13917
|
-
finishReason:
|
|
14275
|
+
response: context2.response,
|
|
14276
|
+
usage: context2.usage,
|
|
14277
|
+
finishReason: context2.finishReason
|
|
13918
14278
|
});
|
|
13919
14279
|
}
|
|
13920
14280
|
const validationResult = await safeValidateTypes3({
|
|
@@ -13926,9 +14286,9 @@ var object3 = ({
|
|
|
13926
14286
|
message: "No object generated: response did not match schema.",
|
|
13927
14287
|
cause: validationResult.error,
|
|
13928
14288
|
text: text22,
|
|
13929
|
-
response:
|
|
13930
|
-
usage:
|
|
13931
|
-
finishReason:
|
|
14289
|
+
response: context2.response,
|
|
14290
|
+
usage: context2.usage,
|
|
14291
|
+
finishReason: context2.finishReason
|
|
13932
14292
|
});
|
|
13933
14293
|
}
|
|
13934
14294
|
return validationResult.value;
|
|
@@ -13948,16 +14308,20 @@ var object3 = ({
|
|
|
13948
14308
|
};
|
|
13949
14309
|
}
|
|
13950
14310
|
}
|
|
14311
|
+
},
|
|
14312
|
+
createElementStreamTransform() {
|
|
14313
|
+
return void 0;
|
|
13951
14314
|
}
|
|
13952
14315
|
};
|
|
13953
14316
|
};
|
|
13954
14317
|
var array = ({
|
|
13955
14318
|
element: inputElementSchema,
|
|
13956
|
-
name:
|
|
14319
|
+
name: name21,
|
|
13957
14320
|
description
|
|
13958
14321
|
}) => {
|
|
13959
14322
|
const elementSchema = asSchema3(inputElementSchema);
|
|
13960
14323
|
return {
|
|
14324
|
+
name: "array",
|
|
13961
14325
|
// JSON schema that describes an array of elements:
|
|
13962
14326
|
responseFormat: resolve2(elementSchema.jsonSchema).then((jsonSchema22) => {
|
|
13963
14327
|
const { $schema, ...itemSchema } = jsonSchema22;
|
|
@@ -13972,20 +14336,20 @@ var array = ({
|
|
|
13972
14336
|
required: ["elements"],
|
|
13973
14337
|
additionalProperties: false
|
|
13974
14338
|
},
|
|
13975
|
-
...
|
|
14339
|
+
...name21 != null && { name: name21 },
|
|
13976
14340
|
...description != null && { description }
|
|
13977
14341
|
};
|
|
13978
14342
|
}),
|
|
13979
|
-
async parseCompleteOutput({ text: text22 },
|
|
14343
|
+
async parseCompleteOutput({ text: text22 }, context2) {
|
|
13980
14344
|
const parseResult = await safeParseJSON3({ text: text22 });
|
|
13981
14345
|
if (!parseResult.success) {
|
|
13982
14346
|
throw new NoObjectGeneratedError3({
|
|
13983
14347
|
message: "No object generated: could not parse the response.",
|
|
13984
14348
|
cause: parseResult.error,
|
|
13985
14349
|
text: text22,
|
|
13986
|
-
response:
|
|
13987
|
-
usage:
|
|
13988
|
-
finishReason:
|
|
14350
|
+
response: context2.response,
|
|
14351
|
+
usage: context2.usage,
|
|
14352
|
+
finishReason: context2.finishReason
|
|
13989
14353
|
});
|
|
13990
14354
|
}
|
|
13991
14355
|
const outerValue = parseResult.value;
|
|
@@ -13997,9 +14361,9 @@ var array = ({
|
|
|
13997
14361
|
cause: "response must be an object with an elements array"
|
|
13998
14362
|
}),
|
|
13999
14363
|
text: text22,
|
|
14000
|
-
response:
|
|
14001
|
-
usage:
|
|
14002
|
-
finishReason:
|
|
14364
|
+
response: context2.response,
|
|
14365
|
+
usage: context2.usage,
|
|
14366
|
+
finishReason: context2.finishReason
|
|
14003
14367
|
});
|
|
14004
14368
|
}
|
|
14005
14369
|
for (const element of outerValue.elements) {
|
|
@@ -14012,9 +14376,9 @@ var array = ({
|
|
|
14012
14376
|
message: "No object generated: response did not match schema.",
|
|
14013
14377
|
cause: validationResult.error,
|
|
14014
14378
|
text: text22,
|
|
14015
|
-
response:
|
|
14016
|
-
usage:
|
|
14017
|
-
finishReason:
|
|
14379
|
+
response: context2.response,
|
|
14380
|
+
usage: context2.usage,
|
|
14381
|
+
finishReason: context2.finishReason
|
|
14018
14382
|
});
|
|
14019
14383
|
}
|
|
14020
14384
|
}
|
|
@@ -14047,15 +14411,28 @@ var array = ({
|
|
|
14047
14411
|
return { partial: parsedElements };
|
|
14048
14412
|
}
|
|
14049
14413
|
}
|
|
14414
|
+
},
|
|
14415
|
+
createElementStreamTransform() {
|
|
14416
|
+
let publishedElements = 0;
|
|
14417
|
+
return new TransformStream({
|
|
14418
|
+
transform({ partialOutput }, controller) {
|
|
14419
|
+
if (partialOutput != null) {
|
|
14420
|
+
for (; publishedElements < partialOutput.length; publishedElements++) {
|
|
14421
|
+
controller.enqueue(partialOutput[publishedElements]);
|
|
14422
|
+
}
|
|
14423
|
+
}
|
|
14424
|
+
}
|
|
14425
|
+
});
|
|
14050
14426
|
}
|
|
14051
14427
|
};
|
|
14052
14428
|
};
|
|
14053
14429
|
var choice = ({
|
|
14054
14430
|
options: choiceOptions,
|
|
14055
|
-
name:
|
|
14431
|
+
name: name21,
|
|
14056
14432
|
description
|
|
14057
14433
|
}) => {
|
|
14058
14434
|
return {
|
|
14435
|
+
name: "choice",
|
|
14059
14436
|
// JSON schema that describes an enumeration:
|
|
14060
14437
|
responseFormat: Promise.resolve({
|
|
14061
14438
|
type: "json",
|
|
@@ -14068,19 +14445,19 @@ var choice = ({
|
|
|
14068
14445
|
required: ["result"],
|
|
14069
14446
|
additionalProperties: false
|
|
14070
14447
|
},
|
|
14071
|
-
...
|
|
14448
|
+
...name21 != null && { name: name21 },
|
|
14072
14449
|
...description != null && { description }
|
|
14073
14450
|
}),
|
|
14074
|
-
async parseCompleteOutput({ text: text22 },
|
|
14451
|
+
async parseCompleteOutput({ text: text22 }, context2) {
|
|
14075
14452
|
const parseResult = await safeParseJSON3({ text: text22 });
|
|
14076
14453
|
if (!parseResult.success) {
|
|
14077
14454
|
throw new NoObjectGeneratedError3({
|
|
14078
14455
|
message: "No object generated: could not parse the response.",
|
|
14079
14456
|
cause: parseResult.error,
|
|
14080
14457
|
text: text22,
|
|
14081
|
-
response:
|
|
14082
|
-
usage:
|
|
14083
|
-
finishReason:
|
|
14458
|
+
response: context2.response,
|
|
14459
|
+
usage: context2.usage,
|
|
14460
|
+
finishReason: context2.finishReason
|
|
14084
14461
|
});
|
|
14085
14462
|
}
|
|
14086
14463
|
const outerValue = parseResult.value;
|
|
@@ -14092,9 +14469,9 @@ var choice = ({
|
|
|
14092
14469
|
cause: "response must be an object that contains a choice value."
|
|
14093
14470
|
}),
|
|
14094
14471
|
text: text22,
|
|
14095
|
-
response:
|
|
14096
|
-
usage:
|
|
14097
|
-
finishReason:
|
|
14472
|
+
response: context2.response,
|
|
14473
|
+
usage: context2.usage,
|
|
14474
|
+
finishReason: context2.finishReason
|
|
14098
14475
|
});
|
|
14099
14476
|
}
|
|
14100
14477
|
return outerValue.result;
|
|
@@ -14122,29 +14499,33 @@ var choice = ({
|
|
|
14122
14499
|
}
|
|
14123
14500
|
}
|
|
14124
14501
|
}
|
|
14502
|
+
},
|
|
14503
|
+
createElementStreamTransform() {
|
|
14504
|
+
return void 0;
|
|
14125
14505
|
}
|
|
14126
14506
|
};
|
|
14127
14507
|
};
|
|
14128
14508
|
var json = ({
|
|
14129
|
-
name:
|
|
14509
|
+
name: name21,
|
|
14130
14510
|
description
|
|
14131
14511
|
} = {}) => {
|
|
14132
14512
|
return {
|
|
14513
|
+
name: "json",
|
|
14133
14514
|
responseFormat: Promise.resolve({
|
|
14134
14515
|
type: "json",
|
|
14135
|
-
...
|
|
14516
|
+
...name21 != null && { name: name21 },
|
|
14136
14517
|
...description != null && { description }
|
|
14137
14518
|
}),
|
|
14138
|
-
async parseCompleteOutput({ text: text22 },
|
|
14519
|
+
async parseCompleteOutput({ text: text22 }, context2) {
|
|
14139
14520
|
const parseResult = await safeParseJSON3({ text: text22 });
|
|
14140
14521
|
if (!parseResult.success) {
|
|
14141
14522
|
throw new NoObjectGeneratedError3({
|
|
14142
14523
|
message: "No object generated: could not parse the response.",
|
|
14143
14524
|
cause: parseResult.error,
|
|
14144
14525
|
text: text22,
|
|
14145
|
-
response:
|
|
14146
|
-
usage:
|
|
14147
|
-
finishReason:
|
|
14526
|
+
response: context2.response,
|
|
14527
|
+
usage: context2.usage,
|
|
14528
|
+
finishReason: context2.finishReason
|
|
14148
14529
|
});
|
|
14149
14530
|
}
|
|
14150
14531
|
return parseResult.value;
|
|
@@ -14161,6 +14542,9 @@ var json = ({
|
|
|
14161
14542
|
return result.value === void 0 ? void 0 : { partial: result.value };
|
|
14162
14543
|
}
|
|
14163
14544
|
}
|
|
14545
|
+
},
|
|
14546
|
+
createElementStreamTransform() {
|
|
14547
|
+
return void 0;
|
|
14164
14548
|
}
|
|
14165
14549
|
};
|
|
14166
14550
|
};
|
|
@@ -14223,7 +14607,7 @@ async function embedMany3({
|
|
|
14223
14607
|
}),
|
|
14224
14608
|
tracer,
|
|
14225
14609
|
fn: async (span) => {
|
|
14226
|
-
var
|
|
14610
|
+
var _a21;
|
|
14227
14611
|
const [maxEmbeddingsPerCall, supportsParallelCalls] = await Promise.all([
|
|
14228
14612
|
model.maxEmbeddingsPerCall,
|
|
14229
14613
|
model.supportsParallelCalls
|
|
@@ -14248,7 +14632,7 @@ async function embedMany3({
|
|
|
14248
14632
|
}),
|
|
14249
14633
|
tracer,
|
|
14250
14634
|
fn: async (doEmbedSpan) => {
|
|
14251
|
-
var
|
|
14635
|
+
var _a2222;
|
|
14252
14636
|
const modelResponse = await model.doEmbed({
|
|
14253
14637
|
values,
|
|
14254
14638
|
abortSignal,
|
|
@@ -14256,7 +14640,7 @@ async function embedMany3({
|
|
|
14256
14640
|
providerOptions
|
|
14257
14641
|
});
|
|
14258
14642
|
const embeddings3 = modelResponse.embeddings;
|
|
14259
|
-
const usage2 = (
|
|
14643
|
+
const usage2 = (_a2222 = modelResponse.usage) != null ? _a2222 : { tokens: NaN };
|
|
14260
14644
|
doEmbedSpan.setAttributes(
|
|
14261
14645
|
await selectTelemetryAttributes3({
|
|
14262
14646
|
telemetry,
|
|
@@ -14337,7 +14721,7 @@ async function embedMany3({
|
|
|
14337
14721
|
}),
|
|
14338
14722
|
tracer,
|
|
14339
14723
|
fn: async (doEmbedSpan) => {
|
|
14340
|
-
var
|
|
14724
|
+
var _a2222;
|
|
14341
14725
|
const modelResponse = await model.doEmbed({
|
|
14342
14726
|
values: chunk,
|
|
14343
14727
|
abortSignal,
|
|
@@ -14345,7 +14729,7 @@ async function embedMany3({
|
|
|
14345
14729
|
providerOptions
|
|
14346
14730
|
});
|
|
14347
14731
|
const embeddings2 = modelResponse.embeddings;
|
|
14348
|
-
const usage = (
|
|
14732
|
+
const usage = (_a2222 = modelResponse.usage) != null ? _a2222 : { tokens: NaN };
|
|
14349
14733
|
doEmbedSpan.setAttributes(
|
|
14350
14734
|
await selectTelemetryAttributes3({
|
|
14351
14735
|
telemetry,
|
|
@@ -14384,7 +14768,7 @@ async function embedMany3({
|
|
|
14384
14768
|
result.providerMetadata
|
|
14385
14769
|
)) {
|
|
14386
14770
|
providerMetadata[providerName] = {
|
|
14387
|
-
...(
|
|
14771
|
+
...(_a21 = providerMetadata[providerName]) != null ? _a21 : {},
|
|
14388
14772
|
...metadata
|
|
14389
14773
|
};
|
|
14390
14774
|
}
|
|
@@ -14475,23 +14859,32 @@ var updateWorkingMemoryTool = (memoryConfig) => {
|
|
|
14475
14859
|
id: "update-working-memory",
|
|
14476
14860
|
description,
|
|
14477
14861
|
inputSchema,
|
|
14478
|
-
execute: async (inputData,
|
|
14479
|
-
const threadId =
|
|
14480
|
-
const resourceId =
|
|
14481
|
-
const memory =
|
|
14482
|
-
if (!
|
|
14483
|
-
throw new Error("
|
|
14484
|
-
}
|
|
14485
|
-
|
|
14486
|
-
if (!
|
|
14487
|
-
thread
|
|
14488
|
-
threadId,
|
|
14489
|
-
resourceId,
|
|
14490
|
-
memoryConfig
|
|
14491
|
-
});
|
|
14862
|
+
execute: async (inputData, context2) => {
|
|
14863
|
+
const threadId = context2?.agent?.threadId;
|
|
14864
|
+
const resourceId = context2?.agent?.resourceId;
|
|
14865
|
+
const memory = context2?.memory;
|
|
14866
|
+
if (!memory) {
|
|
14867
|
+
throw new Error("Memory instance is required for working memory updates");
|
|
14868
|
+
}
|
|
14869
|
+
const scope = memoryConfig?.workingMemory?.scope || "resource";
|
|
14870
|
+
if (scope === "thread" && !threadId) {
|
|
14871
|
+
throw new Error("Thread ID is required for thread-scoped working memory updates");
|
|
14492
14872
|
}
|
|
14493
|
-
if (
|
|
14494
|
-
throw new Error(
|
|
14873
|
+
if (scope === "resource" && !resourceId) {
|
|
14874
|
+
throw new Error("Resource ID is required for resource-scoped working memory updates");
|
|
14875
|
+
}
|
|
14876
|
+
if (threadId) {
|
|
14877
|
+
let thread = await memory.getThreadById({ threadId });
|
|
14878
|
+
if (!thread) {
|
|
14879
|
+
thread = await memory.createThread({
|
|
14880
|
+
threadId,
|
|
14881
|
+
resourceId,
|
|
14882
|
+
memoryConfig
|
|
14883
|
+
});
|
|
14884
|
+
}
|
|
14885
|
+
if (thread.resourceId && resourceId && thread.resourceId !== resourceId) {
|
|
14886
|
+
throw new Error(`Thread with id ${threadId} resourceId does not match the current resourceId ${resourceId}`);
|
|
14887
|
+
}
|
|
14495
14888
|
}
|
|
14496
14889
|
let workingMemory;
|
|
14497
14890
|
if (usesMergeSemantics) {
|
|
@@ -14554,23 +14947,32 @@ var __experimental_updateWorkingMemoryToolVNext = (config) => {
|
|
|
14554
14947
|
"The reason you're updating working memory. Passing any value other than 'append-new-memory' requires a searchString to be provided. Defaults to append-new-memory"
|
|
14555
14948
|
)
|
|
14556
14949
|
}),
|
|
14557
|
-
execute: async (inputData,
|
|
14558
|
-
const threadId =
|
|
14559
|
-
const resourceId =
|
|
14560
|
-
const memory =
|
|
14561
|
-
if (!
|
|
14562
|
-
throw new Error("
|
|
14563
|
-
}
|
|
14564
|
-
|
|
14565
|
-
if (!
|
|
14566
|
-
thread
|
|
14567
|
-
|
|
14568
|
-
|
|
14569
|
-
|
|
14570
|
-
});
|
|
14950
|
+
execute: async (inputData, context2) => {
|
|
14951
|
+
const threadId = context2?.agent?.threadId;
|
|
14952
|
+
const resourceId = context2?.agent?.resourceId;
|
|
14953
|
+
const memory = context2?.memory;
|
|
14954
|
+
if (!memory) {
|
|
14955
|
+
throw new Error("Memory instance is required for working memory updates");
|
|
14956
|
+
}
|
|
14957
|
+
const scope = config.workingMemory?.scope || "resource";
|
|
14958
|
+
if (scope === "thread" && !threadId) {
|
|
14959
|
+
throw new Error("Thread ID is required for thread-scoped working memory updates");
|
|
14960
|
+
}
|
|
14961
|
+
if (scope === "resource" && !resourceId) {
|
|
14962
|
+
throw new Error("Resource ID is required for resource-scoped working memory updates");
|
|
14571
14963
|
}
|
|
14572
|
-
if (
|
|
14573
|
-
|
|
14964
|
+
if (threadId) {
|
|
14965
|
+
let thread = await memory.getThreadById({ threadId });
|
|
14966
|
+
if (!thread) {
|
|
14967
|
+
thread = await memory.createThread({
|
|
14968
|
+
threadId,
|
|
14969
|
+
resourceId,
|
|
14970
|
+
memoryConfig: config
|
|
14971
|
+
});
|
|
14972
|
+
}
|
|
14973
|
+
if (thread.resourceId && resourceId && thread.resourceId !== resourceId) {
|
|
14974
|
+
throw new Error(`Thread with id ${threadId} resourceId does not match the current resourceId ${resourceId}`);
|
|
14975
|
+
}
|
|
14574
14976
|
}
|
|
14575
14977
|
const workingMemory = inputData.newMemory || "";
|
|
14576
14978
|
if (!inputData.updateReason) inputData.updateReason = `append-new-memory`;
|
|
@@ -14601,7 +15003,7 @@ var __experimental_updateWorkingMemoryToolVNext = (config) => {
|
|
|
14601
15003
|
});
|
|
14602
15004
|
};
|
|
14603
15005
|
function normalizeObservationalMemoryConfig(config) {
|
|
14604
|
-
if (config === true) return {};
|
|
15006
|
+
if (config === true) return { model: "google/gemini-2.5-flash" };
|
|
14605
15007
|
if (config === false || config === void 0) return void 0;
|
|
14606
15008
|
if (typeof config === "object" && config.enabled === false) return void 0;
|
|
14607
15009
|
return config;
|
|
@@ -15664,9 +16066,9 @@ Notes:
|
|
|
15664
16066
|
* @param context - Request context for runtime configuration
|
|
15665
16067
|
* @returns Array of input processors configured for this memory instance
|
|
15666
16068
|
*/
|
|
15667
|
-
async getInputProcessors(configuredProcessors = [],
|
|
15668
|
-
const processors = await super.getInputProcessors(configuredProcessors,
|
|
15669
|
-
const om = await this.createOMProcessor(configuredProcessors,
|
|
16069
|
+
async getInputProcessors(configuredProcessors = [], context2) {
|
|
16070
|
+
const processors = await super.getInputProcessors(configuredProcessors, context2);
|
|
16071
|
+
const om = await this.createOMProcessor(configuredProcessors, context2);
|
|
15670
16072
|
if (om) {
|
|
15671
16073
|
processors.push(om);
|
|
15672
16074
|
}
|
|
@@ -15677,9 +16079,9 @@ Notes:
|
|
|
15677
16079
|
* OM needs processOutputResult to save messages at the end of the agent turn,
|
|
15678
16080
|
* even when the observation threshold was never reached during the loop.
|
|
15679
16081
|
*/
|
|
15680
|
-
async getOutputProcessors(configuredProcessors = [],
|
|
15681
|
-
const processors = await super.getOutputProcessors(configuredProcessors,
|
|
15682
|
-
const om = await this.createOMProcessor(configuredProcessors,
|
|
16082
|
+
async getOutputProcessors(configuredProcessors = [], context2) {
|
|
16083
|
+
const processors = await super.getOutputProcessors(configuredProcessors, context2);
|
|
16084
|
+
const om = await this.createOMProcessor(configuredProcessors, context2);
|
|
15683
16085
|
if (om) {
|
|
15684
16086
|
processors.push(om);
|
|
15685
16087
|
}
|
|
@@ -15690,11 +16092,11 @@ Notes:
|
|
|
15690
16092
|
* A new instance is created per call — processorStates (e.g., sealedIds) are shared
|
|
15691
16093
|
* via the ProcessorRunner's state map keyed by processor ID, not by instance identity.
|
|
15692
16094
|
*/
|
|
15693
|
-
async createOMProcessor(configuredProcessors = [],
|
|
16095
|
+
async createOMProcessor(configuredProcessors = [], context2) {
|
|
15694
16096
|
const hasObservationalMemory = configuredProcessors.some(
|
|
15695
16097
|
(p) => !("workflow" in p) && p.id === "observational-memory"
|
|
15696
16098
|
);
|
|
15697
|
-
const memoryContext =
|
|
16099
|
+
const memoryContext = context2?.get("MastraMemory");
|
|
15698
16100
|
const runtimeMemoryConfig = memoryContext?.memoryConfig;
|
|
15699
16101
|
const effectiveConfig = runtimeMemoryConfig ? this.getMergedThreadConfig(runtimeMemoryConfig) : this.threadConfig;
|
|
15700
16102
|
const omConfig = normalizeObservationalMemoryConfig(effectiveConfig.observationalMemory);
|
|
@@ -15718,7 +16120,12 @@ Notes:
|
|
|
15718
16120
|
`Observational memory is enabled but the storage adapter (${memoryStore.constructor.name}) does not support it. If you're using @mastra/libsql, @mastra/pg, or @mastra/mongodb, upgrade to the latest version. Otherwise, use one of those adapters or disable observational memory.`
|
|
15719
16121
|
);
|
|
15720
16122
|
}
|
|
15721
|
-
|
|
16123
|
+
if (omConfig.observation?.bufferTokens !== false && !features.coreFeatures.has("asyncBuffering")) {
|
|
16124
|
+
throw new Error(
|
|
16125
|
+
"Observational memory async buffering is enabled by default but the installed version of @mastra/core does not support it. Either upgrade @mastra/core, @mastra/memory, and your storage adapter (@mastra/libsql, @mastra/pg, or @mastra/mongodb) to the latest version, or explicitly disable async buffering by setting `observation: { bufferTokens: false }` in your observationalMemory config."
|
|
16126
|
+
);
|
|
16127
|
+
}
|
|
16128
|
+
const { ObservationalMemory } = await import('./observational-memory-3UO64HYD.cjs');
|
|
15722
16129
|
return new ObservationalMemory({
|
|
15723
16130
|
storage: memoryStore,
|
|
15724
16131
|
scope: omConfig.scope,
|
|
@@ -15729,13 +16136,18 @@ Notes:
|
|
|
15729
16136
|
messageTokens: omConfig.observation.messageTokens,
|
|
15730
16137
|
modelSettings: omConfig.observation.modelSettings,
|
|
15731
16138
|
maxTokensPerBatch: omConfig.observation.maxTokensPerBatch,
|
|
15732
|
-
providerOptions: omConfig.observation.providerOptions
|
|
16139
|
+
providerOptions: omConfig.observation.providerOptions,
|
|
16140
|
+
bufferTokens: omConfig.observation.bufferTokens,
|
|
16141
|
+
bufferActivation: omConfig.observation.bufferActivation,
|
|
16142
|
+
blockAfter: omConfig.observation.blockAfter
|
|
15733
16143
|
} : void 0,
|
|
15734
16144
|
reflection: omConfig.reflection ? {
|
|
15735
16145
|
model: omConfig.reflection.model,
|
|
15736
16146
|
observationTokens: omConfig.reflection.observationTokens,
|
|
15737
16147
|
modelSettings: omConfig.reflection.modelSettings,
|
|
15738
|
-
providerOptions: omConfig.reflection.providerOptions
|
|
16148
|
+
providerOptions: omConfig.reflection.providerOptions,
|
|
16149
|
+
bufferActivation: omConfig.reflection.bufferActivation,
|
|
16150
|
+
blockAfter: omConfig.reflection.blockAfter
|
|
15739
16151
|
} : void 0
|
|
15740
16152
|
});
|
|
15741
16153
|
}
|