@mastra/schema-compat 1.3.16 → 1.3.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/_types/@internal_ai-sdk-v5/dist/index.d.ts +65 -13
- package/dist/_types/@internal_ai-v6/dist/index.d.ts +110 -35
- package/dist/{esm-DA8owk0L.js → esm-BG70JlG8.js} +39 -77
- package/dist/{esm-DA8owk0L.js.map → esm-BG70JlG8.js.map} +1 -1
- package/dist/{esm-zrVJTTxY.cjs → esm-BQeGF7AD.cjs} +39 -77
- package/dist/{esm-zrVJTTxY.cjs.map → esm-BQeGF7AD.cjs.map} +1 -1
- package/dist/index.cjs +66 -83
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +66 -83
- package/dist/index.js.map +1 -1
- package/dist/{json-schema-Dh7B27IP.cjs → json-schema-7oyknwMS.cjs} +189 -204
- package/dist/json-schema-7oyknwMS.cjs.map +1 -0
- package/dist/{json-schema-DcMkkbbI.js → json-schema-BdCwqjfN.js} +189 -204
- package/dist/json-schema-BdCwqjfN.js.map +1 -0
- package/dist/{json-schema-traverse-Jrimn_T_.js → json-schema-traverse-D0CId4oM.js} +3 -5
- package/dist/{json-schema-traverse-Jrimn_T_.js.map → json-schema-traverse-D0CId4oM.js.map} +1 -1
- package/dist/{json-schema-traverse-CKLDTw5l.cjs → json-schema-traverse-evfp8uQX.cjs} +3 -5
- package/dist/{json-schema-traverse-CKLDTw5l.cjs.map → json-schema-traverse-evfp8uQX.cjs.map} +1 -1
- package/dist/json-to-zod.cjs +70 -71
- package/dist/json-to-zod.cjs.map +1 -1
- package/dist/json-to-zod.d.ts.map +1 -1
- package/dist/json-to-zod.js +70 -71
- package/dist/json-to-zod.js.map +1 -1
- package/dist/provider-compats/anthropic.d.ts.map +1 -1
- package/dist/{schema-CzbEIyhE.js → schema-Bf12g7KC.js} +4 -6
- package/dist/{schema-CzbEIyhE.js.map → schema-Bf12g7KC.js.map} +1 -1
- package/dist/{schema-BXSe2bgB.cjs → schema-D2ab1-Dc.cjs} +5 -7
- package/dist/{schema-BXSe2bgB.cjs.map → schema-D2ab1-Dc.cjs.map} +1 -1
- package/dist/schema-compatibility-v3.d.ts.map +1 -1
- package/dist/schema-compatibility-v4.d.ts.map +1 -1
- package/dist/schema-compatibility.d.ts.map +1 -1
- package/dist/schema.cjs +1 -1
- package/dist/schema.js +1 -1
- package/dist/standard-schema/adapters/ai-sdk.cjs +1 -2
- package/dist/standard-schema/adapters/ai-sdk.js +1 -2
- package/dist/standard-schema/adapters/json-schema.cjs +1 -1
- package/dist/standard-schema/adapters/json-schema.js +1 -1
- package/dist/standard-schema/adapters/zod-v3.cjs +3 -4
- package/dist/standard-schema/adapters/zod-v3.cjs.map +1 -1
- package/dist/standard-schema/adapters/zod-v3.js +3 -4
- package/dist/standard-schema/adapters/zod-v3.js.map +1 -1
- package/dist/utils.d.ts.map +1 -1
- package/dist/zod-to-json.cjs +4 -4
- package/dist/zod-to-json.cjs.map +1 -1
- package/dist/zod-to-json.d.ts.map +1 -1
- package/dist/zod-to-json.js +4 -4
- package/dist/zod-to-json.js.map +1 -1
- package/package.json +21 -21
- package/dist/json-schema-DcMkkbbI.js.map +0 -1
- package/dist/json-schema-Dh7B27IP.cjs.map +0 -1
package/dist/index.cjs
CHANGED
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
-
const require_json_schema_traverse$1 = require("./json-schema-traverse-
|
|
2
|
+
const require_json_schema_traverse$1 = require("./json-schema-traverse-evfp8uQX.cjs");
|
|
3
3
|
const require_zod_to_json = require("./zod-to-json.cjs");
|
|
4
|
-
const require_schema = require("./schema-
|
|
4
|
+
const require_schema = require("./schema-D2ab1-Dc.cjs");
|
|
5
5
|
let zod_v3 = require("zod/v3");
|
|
6
6
|
let zod = require("zod");
|
|
7
7
|
let zod_from_json_schema = require("zod-from-json-schema");
|
|
8
8
|
let zod_v4 = require("zod/v4");
|
|
9
|
-
|
|
9
|
+
// ../../../../../setup-pnpm/node_modules/.bin/store/v11/links/@/zod-from-json-schema/0.0.5/8e273a13436172e49bb0898e3f9caf0fd3966851d12111764522ea958a085aeb/node_modules/zod-from-json-schema/dist/index.mjs
|
|
10
10
|
function convertJsonSchemaToZod$1(schema) {
|
|
11
11
|
function addMetadata(zodSchema, jsonSchema) {
|
|
12
12
|
if (jsonSchema.description) zodSchema = zodSchema.describe(jsonSchema.description);
|
|
@@ -136,8 +136,7 @@ function convertJsonSchemaToZod$1(schema) {
|
|
|
136
136
|
}
|
|
137
137
|
return addMetadata(zod.z.any(), schema);
|
|
138
138
|
}
|
|
139
|
-
|
|
140
|
-
//#region ../_vendored/ai_v4/dist/dist-Cm5DZgxA.js
|
|
139
|
+
// ../_vendored/ai_v4/dist/dist-DlRWVOEI.js
|
|
141
140
|
var marker$1 = "vercel.ai.error";
|
|
142
141
|
var symbol$1 = Symbol.for(marker$1);
|
|
143
142
|
var _a$1;
|
|
@@ -253,8 +252,7 @@ Error message: ${getErrorMessage(cause)}`,
|
|
|
253
252
|
};
|
|
254
253
|
_a13$1 = symbol13$1;
|
|
255
254
|
var TypeValidationError = _TypeValidationError;
|
|
256
|
-
|
|
257
|
-
//#region ../_vendored/ai_v4/dist/index.js
|
|
255
|
+
// ../_vendored/ai_v4/dist/index.js
|
|
258
256
|
var __create = Object.create;
|
|
259
257
|
var __defProp$1 = Object.defineProperty;
|
|
260
258
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
@@ -3362,8 +3360,7 @@ function trimStartOfStream() {
|
|
|
3362
3360
|
return text2;
|
|
3363
3361
|
};
|
|
3364
3362
|
}
|
|
3365
|
-
|
|
3366
|
-
//#region src/utils.ts
|
|
3363
|
+
// src/utils.ts
|
|
3367
3364
|
/**
|
|
3368
3365
|
* Converts a Zod schema to an AI SDK Schema with validation support.
|
|
3369
3366
|
*
|
|
@@ -3436,16 +3433,14 @@ function isZodType(value) {
|
|
|
3436
3433
|
*/
|
|
3437
3434
|
function convertSchemaToZod(schema) {
|
|
3438
3435
|
if (isZodType(schema)) return schema;
|
|
3439
|
-
|
|
3440
|
-
|
|
3441
|
-
|
|
3442
|
-
|
|
3443
|
-
|
|
3444
|
-
|
|
3445
|
-
|
|
3446
|
-
|
|
3447
|
-
throw new Error(errorMessage + (e instanceof Error ? `\n${e.stack}` : "\nUnknown error object"));
|
|
3448
|
-
}
|
|
3436
|
+
const jsonSchemaToConvert = "jsonSchema" in schema ? schema.jsonSchema : schema;
|
|
3437
|
+
try {
|
|
3438
|
+
if ("toJSONSchema" in zod.z) return (0, zod_from_json_schema.convertJsonSchemaToZod)(jsonSchemaToConvert);
|
|
3439
|
+
return convertJsonSchemaToZod$1(jsonSchemaToConvert);
|
|
3440
|
+
} catch (e) {
|
|
3441
|
+
const errorMessage = `[Schema Builder] Failed to convert schema parameters to Zod. Original schema: ${JSON.stringify(jsonSchemaToConvert)}`;
|
|
3442
|
+
console.error(errorMessage, e);
|
|
3443
|
+
throw new Error(errorMessage + (e instanceof Error ? `\n${e.stack}` : "\nUnknown error object"));
|
|
3449
3444
|
}
|
|
3450
3445
|
}
|
|
3451
3446
|
/**
|
|
@@ -3491,19 +3486,17 @@ function applyCompatLayer({ schema, compatLayers, mode }) {
|
|
|
3491
3486
|
return require_schema.standardSchemaToJSONSchema(compatSchema);
|
|
3492
3487
|
}
|
|
3493
3488
|
return require_schema.standardSchemaToJSONSchema(standardSchema);
|
|
3494
|
-
} else {
|
|
3495
|
-
let zodSchema;
|
|
3496
|
-
if (isZodType(schema)) zodSchema = schema;
|
|
3497
|
-
else {
|
|
3498
|
-
if (require_schema.isStandardSchemaWithJSON(schema)) throw new Error("StandardSchemaWithJSON is not supported for applyCompatLayer and aiSdkSchema mode");
|
|
3499
|
-
zodSchema = convertSchemaToZod(schema);
|
|
3500
|
-
}
|
|
3501
|
-
for (const compat of compatLayers) if (compat.shouldApply()) return compat.processToAISDKSchema(zodSchema);
|
|
3502
|
-
return convertZodSchemaToAISDKSchema(zodSchema);
|
|
3503
3489
|
}
|
|
3490
|
+
let zodSchema;
|
|
3491
|
+
if (isZodType(schema)) zodSchema = schema;
|
|
3492
|
+
else {
|
|
3493
|
+
if (require_schema.isStandardSchemaWithJSON(schema)) throw new Error("StandardSchemaWithJSON is not supported for applyCompatLayer and aiSdkSchema mode");
|
|
3494
|
+
zodSchema = convertSchemaToZod(schema);
|
|
3495
|
+
}
|
|
3496
|
+
for (const compat of compatLayers) if (compat.shouldApply()) return compat.processToAISDKSchema(zodSchema);
|
|
3497
|
+
return convertZodSchemaToAISDKSchema(zodSchema);
|
|
3504
3498
|
}
|
|
3505
|
-
|
|
3506
|
-
//#region src/schema-compatibility-v3.ts
|
|
3499
|
+
// src/schema-compatibility-v3.ts
|
|
3507
3500
|
/**
|
|
3508
3501
|
* All supported string validation check types that can be processed or converted to descriptions.
|
|
3509
3502
|
* @constant
|
|
@@ -3758,7 +3751,7 @@ var SchemaCompatLayer$1 = class {
|
|
|
3758
3751
|
*/
|
|
3759
3752
|
mergeParameterDescription(description, constraints) {
|
|
3760
3753
|
if (constraints.length > 0) return (description ? description + "\n" : "") + `constraints: ${constraints.join(`, `)}`;
|
|
3761
|
-
|
|
3754
|
+
return description;
|
|
3762
3755
|
}
|
|
3763
3756
|
/**
|
|
3764
3757
|
* Default handler for unsupported Zod types. Throws an error for specified unsupported types.
|
|
@@ -3923,7 +3916,7 @@ var SchemaCompatLayer$1 = class {
|
|
|
3923
3916
|
*/
|
|
3924
3917
|
defaultZodOptionalHandler(value, handleTypes = SUPPORTED_ZOD_TYPES) {
|
|
3925
3918
|
if (handleTypes.includes(value._def.innerType._def.typeName)) return this.processZodType(value._def.innerType).optional();
|
|
3926
|
-
|
|
3919
|
+
return value;
|
|
3927
3920
|
}
|
|
3928
3921
|
/**
|
|
3929
3922
|
* Default handler for Zod nullable types. Processes the inner type and maintains nullability.
|
|
@@ -3934,7 +3927,7 @@ var SchemaCompatLayer$1 = class {
|
|
|
3934
3927
|
*/
|
|
3935
3928
|
defaultZodNullableHandler(value, handleTypes = SUPPORTED_ZOD_TYPES) {
|
|
3936
3929
|
if (handleTypes.includes(value._def.innerType._def.typeName)) return this.processZodType(value._def.innerType).nullable();
|
|
3937
|
-
|
|
3930
|
+
return value;
|
|
3938
3931
|
}
|
|
3939
3932
|
/**
|
|
3940
3933
|
* Recursively collects leaf types from a ZodIntersection tree.
|
|
@@ -3978,8 +3971,7 @@ var SchemaCompatLayer$1 = class {
|
|
|
3978
3971
|
return this.processToAISDKSchema(zodSchema).jsonSchema;
|
|
3979
3972
|
}
|
|
3980
3973
|
};
|
|
3981
|
-
|
|
3982
|
-
//#region src/schema-compatibility-v4.ts
|
|
3974
|
+
// src/schema-compatibility-v4.ts
|
|
3983
3975
|
/**
|
|
3984
3976
|
* All supported string validation check types that can be processed or converted to descriptions.
|
|
3985
3977
|
* @constant
|
|
@@ -4236,7 +4228,7 @@ var SchemaCompatLayer$2 = class {
|
|
|
4236
4228
|
*/
|
|
4237
4229
|
mergeParameterDescription(description, constraints) {
|
|
4238
4230
|
if (constraints.length > 0) return (description ? description + "\n" : "") + `constraints: ${constraints.join(`, `)}`;
|
|
4239
|
-
|
|
4231
|
+
return description;
|
|
4240
4232
|
}
|
|
4241
4233
|
/**
|
|
4242
4234
|
* Default handler for unsupported Zod types. Throws an error for specified unsupported types.
|
|
@@ -4410,7 +4402,7 @@ var SchemaCompatLayer$2 = class {
|
|
|
4410
4402
|
defaultZodOptionalHandler(value, handleTypes = SUPPORTED_ZOD_TYPES$2) {
|
|
4411
4403
|
const innerType = value._zod?.def?.innerType;
|
|
4412
4404
|
if (innerType && handleTypes.includes(zodV4TypeName(innerType))) return this.processZodType(innerType).optional();
|
|
4413
|
-
|
|
4405
|
+
return value;
|
|
4414
4406
|
}
|
|
4415
4407
|
/**
|
|
4416
4408
|
* Default handler for Zod nullable types. Processes the inner type and maintains nullability.
|
|
@@ -4422,7 +4414,7 @@ var SchemaCompatLayer$2 = class {
|
|
|
4422
4414
|
defaultZodNullableHandler(value, handleTypes = SUPPORTED_ZOD_TYPES$2) {
|
|
4423
4415
|
const innerType = value._zod?.def?.innerType;
|
|
4424
4416
|
if (innerType && handleTypes.includes(zodV4TypeName(innerType))) return this.processZodType(innerType).nullable();
|
|
4425
|
-
|
|
4417
|
+
return value;
|
|
4426
4418
|
}
|
|
4427
4419
|
/**
|
|
4428
4420
|
* Recursively collects leaf types from a ZodIntersection tree.
|
|
@@ -4469,8 +4461,7 @@ var SchemaCompatLayer$2 = class {
|
|
|
4469
4461
|
return this.processToAISDKSchema(zodSchema).jsonSchema;
|
|
4470
4462
|
}
|
|
4471
4463
|
};
|
|
4472
|
-
|
|
4473
|
-
//#region src/json-schema/utils.ts
|
|
4464
|
+
// src/json-schema/utils.ts
|
|
4474
4465
|
var import_json_schema_traverse = /* @__PURE__ */ require_json_schema_traverse$1.__toESM(require_json_schema_traverse$1.require_json_schema_traverse(), 1);
|
|
4475
4466
|
/**
|
|
4476
4467
|
* Type guard to check if a JSON Schema has a specific type
|
|
@@ -4538,8 +4529,7 @@ function isOptionalSchema(propertyName, parentSchema) {
|
|
|
4538
4529
|
if (!parentSchema.required || !Array.isArray(parentSchema.required)) return true;
|
|
4539
4530
|
return !parentSchema.required.includes(propertyName);
|
|
4540
4531
|
}
|
|
4541
|
-
|
|
4542
|
-
//#region src/schema-compatibility.ts
|
|
4532
|
+
// src/schema-compatibility.ts
|
|
4543
4533
|
var SchemaCompatLayer = class {
|
|
4544
4534
|
model;
|
|
4545
4535
|
v3Layer;
|
|
@@ -4566,82 +4556,82 @@ var SchemaCompatLayer = class {
|
|
|
4566
4556
|
}
|
|
4567
4557
|
getUnsupportedZodTypes(value) {
|
|
4568
4558
|
if ("_zod" in value) return this.v4Layer.getUnsupportedZodTypes();
|
|
4569
|
-
|
|
4559
|
+
return this.v3Layer.getUnsupportedZodTypes();
|
|
4570
4560
|
}
|
|
4571
4561
|
isOptional(v) {
|
|
4572
4562
|
if ("_zod" in v) return this.v4Layer.isOptional(v);
|
|
4573
|
-
|
|
4563
|
+
return this.v3Layer.isOptional(v);
|
|
4574
4564
|
}
|
|
4575
4565
|
isObj(v) {
|
|
4576
4566
|
if ("_zod" in v) return this.v4Layer.isObj(v);
|
|
4577
|
-
|
|
4567
|
+
return this.v3Layer.isObj(v);
|
|
4578
4568
|
}
|
|
4579
4569
|
isNull(v) {
|
|
4580
4570
|
if ("_zod" in v) return this.v4Layer.isNull(v);
|
|
4581
|
-
|
|
4571
|
+
return this.v3Layer.isNull(v);
|
|
4582
4572
|
}
|
|
4583
4573
|
isNullable(v) {
|
|
4584
4574
|
if ("_zod" in v) return this.v4Layer.isNullable(v);
|
|
4585
|
-
|
|
4575
|
+
return this.v3Layer.isNullable(v);
|
|
4586
4576
|
}
|
|
4587
4577
|
isArr(v) {
|
|
4588
4578
|
if ("_zod" in v) return this.v4Layer.isArr(v);
|
|
4589
|
-
|
|
4579
|
+
return this.v3Layer.isArr(v);
|
|
4590
4580
|
}
|
|
4591
4581
|
isUnion(v) {
|
|
4592
4582
|
if ("_zod" in v) return this.v4Layer.isUnion(v);
|
|
4593
|
-
|
|
4583
|
+
return this.v3Layer.isUnion(v);
|
|
4594
4584
|
}
|
|
4595
4585
|
isString(v) {
|
|
4596
4586
|
if ("_zod" in v) return this.v4Layer.isString(v);
|
|
4597
|
-
|
|
4587
|
+
return this.v3Layer.isString(v);
|
|
4598
4588
|
}
|
|
4599
4589
|
isNumber(v) {
|
|
4600
4590
|
if ("_zod" in v) return this.v4Layer.isNumber(v);
|
|
4601
|
-
|
|
4591
|
+
return this.v3Layer.isNumber(v);
|
|
4602
4592
|
}
|
|
4603
4593
|
isDate(v) {
|
|
4604
4594
|
if ("_zod" in v) return this.v4Layer.isDate(v);
|
|
4605
|
-
|
|
4595
|
+
return this.v3Layer.isDate(v);
|
|
4606
4596
|
}
|
|
4607
4597
|
isDefault(v) {
|
|
4608
4598
|
if ("_zod" in v) return this.v4Layer.isDefault(v);
|
|
4609
|
-
|
|
4599
|
+
return this.v3Layer.isDefault(v);
|
|
4610
4600
|
}
|
|
4611
4601
|
isIntersection(v) {
|
|
4612
4602
|
if ("_zod" in v) return this.v4Layer.isIntersection(v);
|
|
4613
|
-
|
|
4603
|
+
return this.v3Layer.isIntersection(v);
|
|
4614
4604
|
}
|
|
4615
4605
|
defaultZodObjectHandler(value, options = { passthrough: true }) {
|
|
4616
4606
|
if ("_zod" in value) return this.v4Layer.defaultZodObjectHandler(value, options);
|
|
4617
|
-
|
|
4607
|
+
return this.v3Layer.defaultZodObjectHandler(value, options);
|
|
4618
4608
|
}
|
|
4619
4609
|
mergeParameterDescription(description, constraints) {
|
|
4620
4610
|
return this.v3Layer.mergeParameterDescription(description, constraints);
|
|
4621
4611
|
}
|
|
4622
4612
|
defaultUnsupportedZodTypeHandler(value, throwOnTypes) {
|
|
4623
4613
|
if ("_zod" in value) return this.v4Layer.defaultUnsupportedZodTypeHandler(value, throwOnTypes ?? UNSUPPORTED_ZOD_TYPES$2);
|
|
4624
|
-
|
|
4614
|
+
return this.v3Layer.defaultUnsupportedZodTypeHandler(value, throwOnTypes ?? UNSUPPORTED_ZOD_TYPES);
|
|
4625
4615
|
}
|
|
4626
4616
|
defaultZodArrayHandler(value, handleChecks = ALL_ARRAY_CHECKS) {
|
|
4627
4617
|
if ("_zod" in value) return this.v4Layer.defaultZodArrayHandler(value, handleChecks);
|
|
4628
|
-
|
|
4618
|
+
return this.v3Layer.defaultZodArrayHandler(value, handleChecks);
|
|
4629
4619
|
}
|
|
4630
4620
|
defaultZodUnionHandler(value) {
|
|
4631
4621
|
if ("_zod" in value) return this.v4Layer.defaultZodUnionHandler(value);
|
|
4632
|
-
|
|
4622
|
+
return this.v3Layer.defaultZodUnionHandler(value);
|
|
4633
4623
|
}
|
|
4634
4624
|
defaultZodStringHandler(value, handleChecks = ALL_STRING_CHECKS) {
|
|
4635
4625
|
if ("_zod" in value) return this.v4Layer.defaultZodStringHandler(value);
|
|
4636
|
-
|
|
4626
|
+
return this.v3Layer.defaultZodStringHandler(value, handleChecks);
|
|
4637
4627
|
}
|
|
4638
4628
|
defaultZodNumberHandler(value, handleChecks = ALL_NUMBER_CHECKS) {
|
|
4639
4629
|
if ("_zod" in value) return this.v4Layer.defaultZodNumberHandler(value);
|
|
4640
|
-
|
|
4630
|
+
return this.v3Layer.defaultZodNumberHandler(value, handleChecks);
|
|
4641
4631
|
}
|
|
4642
4632
|
defaultZodDateHandler(value) {
|
|
4643
4633
|
if ("_zod" in value) return this.v4Layer.defaultZodDateHandler(value);
|
|
4644
|
-
|
|
4634
|
+
return this.v3Layer.defaultZodDateHandler(value);
|
|
4645
4635
|
}
|
|
4646
4636
|
defaultZodOptionalHandler(value, handleTypes) {
|
|
4647
4637
|
if (!handleTypes) handleTypes = [
|
|
@@ -4662,16 +4652,18 @@ var SchemaCompatLayer = class {
|
|
|
4662
4652
|
const innerType = value._zod?.def?.innerType;
|
|
4663
4653
|
if (!innerType) return value;
|
|
4664
4654
|
return this.processZodType(innerType).optional();
|
|
4665
|
-
}
|
|
4666
|
-
|
|
4655
|
+
}
|
|
4656
|
+
return this.processZodType(value._def.innerType).optional();
|
|
4657
|
+
}
|
|
4658
|
+
return value;
|
|
4667
4659
|
}
|
|
4668
4660
|
defaultZodNullableHandler(value, handleTypes) {
|
|
4669
4661
|
if ("_zod" in value) return this.v4Layer.defaultZodNullableHandler(value, handleTypes ?? SUPPORTED_ZOD_TYPES$2);
|
|
4670
|
-
|
|
4662
|
+
return this.v3Layer.defaultZodNullableHandler(value, handleTypes ?? SUPPORTED_ZOD_TYPES);
|
|
4671
4663
|
}
|
|
4672
4664
|
defaultZodIntersectionHandler(value) {
|
|
4673
4665
|
if ("_zod" in value) return this.v4Layer.defaultZodIntersectionHandler(value);
|
|
4674
|
-
|
|
4666
|
+
return this.v3Layer.defaultZodIntersectionHandler(value);
|
|
4675
4667
|
}
|
|
4676
4668
|
/**
|
|
4677
4669
|
* @deprecated please use processToCompatSchema to usse StandardSchemaWithJSON
|
|
@@ -4945,8 +4937,7 @@ var SchemaCompatLayer = class {
|
|
|
4945
4937
|
return jsonSchema;
|
|
4946
4938
|
}
|
|
4947
4939
|
};
|
|
4948
|
-
|
|
4949
|
-
//#region src/null-to-undefined.ts
|
|
4940
|
+
// src/null-to-undefined.ts
|
|
4950
4941
|
/**
|
|
4951
4942
|
* Recursively converts null values to undefined in an object based on which
|
|
4952
4943
|
* properties are optional in the JSON Schema. This is needed because OpenAI
|
|
@@ -5092,8 +5083,7 @@ function isNullable(z) {
|
|
|
5092
5083
|
function isIntersection(z) {
|
|
5093
5084
|
return (v) => v instanceof z["ZodIntersection"];
|
|
5094
5085
|
}
|
|
5095
|
-
|
|
5096
|
-
//#region src/provider-compats/openai.ts
|
|
5086
|
+
// src/provider-compats/openai.ts
|
|
5097
5087
|
const allowedStringFormats = [
|
|
5098
5088
|
"date-time",
|
|
5099
5089
|
"time",
|
|
@@ -5448,8 +5438,7 @@ var OpenAISchemaCompatLayer = class extends SchemaCompatLayer {
|
|
|
5448
5438
|
function isDateFormat(schema) {
|
|
5449
5439
|
return schema.format === "date-time" || schema.format === "date";
|
|
5450
5440
|
}
|
|
5451
|
-
|
|
5452
|
-
//#region src/provider-compats/openai-reasoning.ts
|
|
5441
|
+
// src/provider-compats/openai-reasoning.ts
|
|
5453
5442
|
var OpenAIReasoningSchemaCompatLayer = class extends OpenAISchemaCompatLayer {
|
|
5454
5443
|
getSchemaTarget() {
|
|
5455
5444
|
return `openApi3`;
|
|
@@ -5497,8 +5486,7 @@ var OpenAIReasoningSchemaCompatLayer = class extends OpenAISchemaCompatLayer {
|
|
|
5497
5486
|
return this.defaultUnsupportedZodTypeHandler(value);
|
|
5498
5487
|
}
|
|
5499
5488
|
};
|
|
5500
|
-
|
|
5501
|
-
//#region src/standard-schema-compat.ts
|
|
5489
|
+
// src/standard-schema-compat.ts
|
|
5502
5490
|
/**
|
|
5503
5491
|
* Standard Schema compatibility utilities
|
|
5504
5492
|
*
|
|
@@ -5593,8 +5581,7 @@ function applyOpenAICompatToTools(tools, modelInfo) {
|
|
|
5593
5581
|
} else transformedTools[name] = tool;
|
|
5594
5582
|
return transformedTools;
|
|
5595
5583
|
}
|
|
5596
|
-
|
|
5597
|
-
//#region src/provider-compats/anthropic.ts
|
|
5584
|
+
// src/provider-compats/anthropic.ts
|
|
5598
5585
|
var AnthropicSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
5599
5586
|
constructor(model) {
|
|
5600
5587
|
super(model);
|
|
@@ -5641,7 +5628,7 @@ var AnthropicSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
|
5641
5628
|
else if (this.isUnion(value)) return this.defaultZodUnionHandler(value);
|
|
5642
5629
|
else if (this.isString(value)) {
|
|
5643
5630
|
if (this.getModel().modelId.includes("claude-3.5-haiku")) return this.defaultZodStringHandler(value, ["max", "min"]);
|
|
5644
|
-
|
|
5631
|
+
return value;
|
|
5645
5632
|
} else if (isNull(zod.z)(value)) return zod.z.any().refine((v) => v === null, { message: "must be null" }).describe(value.description || "must be null");
|
|
5646
5633
|
else if (isIntersection(zod.z)(value)) return this.defaultZodIntersectionHandler(value);
|
|
5647
5634
|
return this.defaultUnsupportedZodTypeHandler(value);
|
|
@@ -5949,8 +5936,7 @@ var AnthropicSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
|
5949
5936
|
}) ?? schema;
|
|
5950
5937
|
}
|
|
5951
5938
|
};
|
|
5952
|
-
|
|
5953
|
-
//#region src/provider-compats/deepseek.ts
|
|
5939
|
+
// src/provider-compats/deepseek.ts
|
|
5954
5940
|
var DeepSeekSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
5955
5941
|
constructor(model) {
|
|
5956
5942
|
super(model);
|
|
@@ -6043,8 +6029,7 @@ var DeepSeekSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
|
6043
6029
|
return schema;
|
|
6044
6030
|
}
|
|
6045
6031
|
};
|
|
6046
|
-
|
|
6047
|
-
//#region src/provider-compats/google.ts
|
|
6032
|
+
// src/provider-compats/google.ts
|
|
6048
6033
|
function fixAISDKNullableUnionTypes(schema) {
|
|
6049
6034
|
if (typeof schema !== "object" || schema === null) return schema;
|
|
6050
6035
|
const result = { ...schema };
|
|
@@ -6303,8 +6288,7 @@ var GoogleSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
|
6303
6288
|
return schema;
|
|
6304
6289
|
}
|
|
6305
6290
|
};
|
|
6306
|
-
|
|
6307
|
-
//#region src/provider-compats/meta.ts
|
|
6291
|
+
// src/provider-compats/meta.ts
|
|
6308
6292
|
var MetaSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
6309
6293
|
constructor(model) {
|
|
6310
6294
|
super(model);
|
|
@@ -6398,7 +6382,6 @@ var MetaSchemaCompatLayer = class extends SchemaCompatLayer {
|
|
|
6398
6382
|
return schema;
|
|
6399
6383
|
}
|
|
6400
6384
|
};
|
|
6401
|
-
//#endregion
|
|
6402
6385
|
exports.ALL_ARRAY_CHECKS = ALL_ARRAY_CHECKS;
|
|
6403
6386
|
exports.ALL_NUMBER_CHECKS = ALL_NUMBER_CHECKS;
|
|
6404
6387
|
exports.ALL_STRING_CHECKS = ALL_STRING_CHECKS;
|