@mastra/schema-compat 0.0.0-taofeeq-fix-tool-call-showing-after-message-20250806184630 → 0.0.0-vnext-20251104230439

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.
Files changed (67) hide show
  1. package/CHANGELOG.md +131 -1
  2. package/README.md +0 -4
  3. package/dist/chunk-5WM4A32G.cjs +83 -0
  4. package/dist/chunk-5WM4A32G.cjs.map +1 -0
  5. package/dist/chunk-U2HXWNAF.js +77 -0
  6. package/dist/chunk-U2HXWNAF.js.map +1 -0
  7. package/dist/index.cjs +4560 -271
  8. package/dist/index.cjs.map +1 -1
  9. package/dist/index.d.ts +5 -1
  10. package/dist/index.d.ts.map +1 -1
  11. package/dist/index.js +4558 -272
  12. package/dist/index.js.map +1 -1
  13. package/dist/json-schema.d.ts +4 -0
  14. package/dist/json-schema.d.ts.map +1 -0
  15. package/dist/provider-compats/anthropic.d.ts +6 -4
  16. package/dist/provider-compats/anthropic.d.ts.map +1 -1
  17. package/dist/provider-compats/deepseek.d.ts +6 -4
  18. package/dist/provider-compats/deepseek.d.ts.map +1 -1
  19. package/dist/provider-compats/google.d.ts +6 -4
  20. package/dist/provider-compats/google.d.ts.map +1 -1
  21. package/dist/provider-compats/meta.d.ts +6 -4
  22. package/dist/provider-compats/meta.d.ts.map +1 -1
  23. package/dist/provider-compats/openai-reasoning.d.ts +6 -4
  24. package/dist/provider-compats/openai-reasoning.d.ts.map +1 -1
  25. package/dist/provider-compats/openai.d.ts +6 -4
  26. package/dist/provider-compats/openai.d.ts.map +1 -1
  27. package/dist/schema-compatibility-v3.d.ts +287 -0
  28. package/dist/schema-compatibility-v3.d.ts.map +1 -0
  29. package/dist/schema-compatibility-v4.d.ts +278 -0
  30. package/dist/schema-compatibility-v4.d.ts.map +1 -0
  31. package/dist/schema-compatibility.d.ts +81 -165
  32. package/dist/schema-compatibility.d.ts.map +1 -1
  33. package/dist/types.d.ts +7 -0
  34. package/dist/types.d.ts.map +1 -0
  35. package/dist/utils-test-suite.d.ts +2 -0
  36. package/dist/utils-test-suite.d.ts.map +1 -0
  37. package/dist/utils.d.ts +18 -6
  38. package/dist/utils.d.ts.map +1 -1
  39. package/dist/zod-to-json-test-suite.d.ts +6 -0
  40. package/dist/zod-to-json-test-suite.d.ts.map +1 -0
  41. package/dist/zod-to-json.cjs +12 -0
  42. package/dist/zod-to-json.cjs.map +1 -0
  43. package/dist/zod-to-json.d.ts +6 -0
  44. package/dist/zod-to-json.d.ts.map +1 -0
  45. package/dist/zod-to-json.js +3 -0
  46. package/dist/zod-to-json.js.map +1 -0
  47. package/dist/zodTypes.d.ts +21 -0
  48. package/dist/zodTypes.d.ts.map +1 -0
  49. package/package.json +33 -10
  50. package/.turbo/turbo-build.log +0 -4
  51. package/eslint.config.js +0 -6
  52. package/src/index.ts +0 -39
  53. package/src/provider-compats/anthropic.ts +0 -44
  54. package/src/provider-compats/deepseek.ts +0 -35
  55. package/src/provider-compats/google.ts +0 -63
  56. package/src/provider-compats/meta.ts +0 -36
  57. package/src/provider-compats/openai-reasoning.ts +0 -91
  58. package/src/provider-compats/openai.ts +0 -56
  59. package/src/provider-compats.test.ts +0 -312
  60. package/src/schema-compatibility.test.ts +0 -471
  61. package/src/schema-compatibility.ts +0 -588
  62. package/src/utils.test.ts +0 -434
  63. package/src/utils.ts +0 -205
  64. package/tsconfig.build.json +0 -9
  65. package/tsconfig.json +0 -5
  66. package/tsup.config.ts +0 -17
  67. package/vitest.config.ts +0 -7
@@ -0,0 +1,4 @@
1
+ export { jsonSchema } from '@internal/ai-sdk-v4/schema';
2
+ export type { Schema } from '@internal/ai-sdk-v4/schema';
3
+ export type { JSONSchema7 } from 'json-schema';
4
+ //# sourceMappingURL=json-schema.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"json-schema.d.ts","sourceRoot":"","sources":["../src/json-schema.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,4BAA4B,CAAC;AACxD,YAAY,EAAE,MAAM,EAAE,MAAM,4BAA4B,CAAC;AAEzD,YAAY,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
@@ -1,11 +1,13 @@
1
- import type { LanguageModelV1 } from 'ai';
2
- import type { ZodTypeAny } from 'zod';
1
+ import type { ZodType as ZodTypeV3 } from 'zod/v3';
2
+ import type { ZodType as ZodTypeV4 } from 'zod/v4';
3
3
  import type { Targets } from 'zod-to-json-schema';
4
4
  import { SchemaCompatLayer } from '../schema-compatibility.js';
5
+ import type { ModelInformation } from '../types.js';
5
6
  export declare class AnthropicSchemaCompatLayer extends SchemaCompatLayer {
6
- constructor(model: LanguageModelV1);
7
+ constructor(model: ModelInformation);
7
8
  getSchemaTarget(): Targets | undefined;
8
9
  shouldApply(): boolean;
9
- processZodType(value: ZodTypeAny): ZodTypeAny;
10
+ processZodType(value: ZodTypeV3): ZodTypeV3;
11
+ processZodType(value: ZodTypeV4): ZodTypeV4;
10
12
  }
11
13
  //# sourceMappingURL=anthropic.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/provider-compats/anthropic.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAA+C,MAAM,yBAAyB,CAAC;AAGzG,qBAAa,0BAA2B,SAAQ,iBAAiB;gBACnD,KAAK,EAAE,eAAe;IAIlC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,WAAW,IAAI,OAAO;IAItB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;CAwB9C"}
1
+ {"version":3,"file":"anthropic.d.ts","sourceRoot":"","sources":["../../src/provider-compats/anthropic.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,SAAS,EAA4B,MAAM,QAAQ,CAAC;AAC7E,OAAO,KAAK,EAAE,OAAO,IAAI,SAAS,EAA4B,MAAM,QAAQ,CAAC;AAC7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAG5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGjD,qBAAa,0BAA2B,SAAQ,iBAAiB;gBACnD,KAAK,EAAE,gBAAgB;IAInC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,WAAW,IAAI,OAAO;IAItB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS;IAC3C,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS;CAoC5C"}
@@ -1,11 +1,13 @@
1
- import type { LanguageModelV1 } from 'ai';
2
- import type { ZodTypeAny } from 'zod';
1
+ import type { ZodType as ZodTypeV3 } from 'zod/v3';
2
+ import type { ZodType as ZodTypeV4 } from 'zod/v4';
3
3
  import type { Targets } from 'zod-to-json-schema';
4
4
  import { SchemaCompatLayer } from '../schema-compatibility.js';
5
+ import type { ModelInformation } from '../types.js';
5
6
  export declare class DeepSeekSchemaCompatLayer extends SchemaCompatLayer {
6
- constructor(model: LanguageModelV1);
7
+ constructor(model: ModelInformation);
7
8
  getSchemaTarget(): Targets | undefined;
8
9
  shouldApply(): boolean;
9
- processZodType(value: ZodTypeAny): ZodTypeAny;
10
+ processZodType(value: ZodTypeV3): ZodTypeV3;
11
+ processZodType(value: ZodTypeV4): ZodTypeV4;
10
12
  }
11
13
  //# sourceMappingURL=deepseek.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"deepseek.d.ts","sourceRoot":"","sources":["../../src/provider-compats/deepseek.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAA+C,MAAM,yBAAyB,CAAC;AAEzG,qBAAa,yBAA0B,SAAQ,iBAAiB;gBAClD,KAAK,EAAE,eAAe;IAIlC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,WAAW,IAAI,OAAO;IAKtB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;CAe9C"}
1
+ {"version":3,"file":"deepseek.d.ts","sourceRoot":"","sources":["../../src/provider-compats/deepseek.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGjD,qBAAa,yBAA0B,SAAQ,iBAAiB;gBAClD,KAAK,EAAE,gBAAgB;IAInC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,WAAW,IAAI,OAAO;IAKtB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS;IAC3C,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS;CAgB5C"}
@@ -1,11 +1,13 @@
1
- import type { LanguageModelV1 } from 'ai';
2
- import type { ZodTypeAny } from 'zod';
1
+ import type { ZodType as ZodTypeV3 } from 'zod/v3';
2
+ import type { ZodType as ZodTypeV4 } from 'zod/v4';
3
3
  import type { Targets } from 'zod-to-json-schema';
4
4
  import { SchemaCompatLayer } from '../schema-compatibility.js';
5
+ import type { ModelInformation } from '../types.js';
5
6
  export declare class GoogleSchemaCompatLayer extends SchemaCompatLayer {
6
- constructor(model: LanguageModelV1);
7
+ constructor(model: ModelInformation);
7
8
  getSchemaTarget(): Targets | undefined;
8
9
  shouldApply(): boolean;
9
- processZodType(value: ZodTypeAny): ZodTypeAny;
10
+ processZodType(value: ZodTypeV3): ZodTypeV3;
11
+ processZodType(value: ZodTypeV4): ZodTypeV4;
10
12
  }
11
13
  //# sourceMappingURL=google.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../src/provider-compats/google.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AAEtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,iBAAiB,EASlB,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,uBAAwB,SAAQ,iBAAiB;gBAChD,KAAK,EAAE,eAAe;IAIlC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,WAAW,IAAI,OAAO;IAItB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;CAiC9C"}
1
+ {"version":3,"file":"google.d.ts","sourceRoot":"","sources":["../../src/provider-compats/google.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,SAAS,EAA4B,MAAM,QAAQ,CAAC;AAC7E,OAAO,KAAK,EAAE,OAAO,IAAI,SAAS,EAA4B,MAAM,QAAQ,CAAC;AAC7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGjD,qBAAa,uBAAwB,SAAQ,iBAAiB;gBAChD,KAAK,EAAE,gBAAgB;IAInC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,WAAW,IAAI,OAAO;IAGtB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS;IAC3C,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS;CA2B5C"}
@@ -1,11 +1,13 @@
1
- import type { LanguageModelV1 } from 'ai';
2
- import type { ZodTypeAny } from 'zod';
1
+ import type { ZodType as ZodTypeV3 } from 'zod/v3';
2
+ import type { ZodType as ZodTypeV4 } from 'zod/v4';
3
3
  import type { Targets } from 'zod-to-json-schema';
4
4
  import { SchemaCompatLayer } from '../schema-compatibility.js';
5
+ import type { ModelInformation } from '../types.js';
5
6
  export declare class MetaSchemaCompatLayer extends SchemaCompatLayer {
6
- constructor(model: LanguageModelV1);
7
+ constructor(model: ModelInformation);
7
8
  getSchemaTarget(): Targets | undefined;
8
9
  shouldApply(): boolean;
9
- processZodType(value: ZodTypeAny): ZodTypeAny;
10
+ processZodType(value: ZodTypeV3): ZodTypeV3;
11
+ processZodType(value: ZodTypeV4): ZodTypeV4;
10
12
  }
11
13
  //# sourceMappingURL=meta.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/provider-compats/meta.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAyD,MAAM,yBAAyB,CAAC;AAEnH,qBAAa,qBAAsB,SAAQ,iBAAiB;gBAC9C,KAAK,EAAE,eAAe;IAIlC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,WAAW,IAAI,OAAO;IAItB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;CAiB9C"}
1
+ {"version":3,"file":"meta.d.ts","sourceRoot":"","sources":["../../src/provider-compats/meta.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,QAAQ,CAAC;AACnD,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGjD,qBAAa,qBAAsB,SAAQ,iBAAiB;gBAC9C,KAAK,EAAE,gBAAgB;IAInC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,WAAW,IAAI,OAAO;IAItB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS;IAC3C,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS;CAkB5C"}
@@ -1,12 +1,14 @@
1
- import type { LanguageModelV1 } from 'ai';
2
- import type { ZodTypeAny } from 'zod';
1
+ import type { ZodType as ZodTypeV3 } from 'zod/v3';
2
+ import type { ZodType as ZodTypeV4 } from 'zod/v4';
3
3
  import type { Targets } from 'zod-to-json-schema';
4
4
  import { SchemaCompatLayer } from '../schema-compatibility.js';
5
+ import type { ModelInformation } from '../types.js';
5
6
  export declare class OpenAIReasoningSchemaCompatLayer extends SchemaCompatLayer {
6
- constructor(model: LanguageModelV1);
7
+ constructor(model: ModelInformation);
7
8
  getSchemaTarget(): Targets | undefined;
8
9
  isReasoningModel(): boolean;
9
10
  shouldApply(): boolean;
10
- processZodType(value: ZodTypeAny): ZodTypeAny;
11
+ processZodType(value: ZodTypeV3): ZodTypeV3;
12
+ processZodType(value: ZodTypeV4): ZodTypeV4;
11
13
  }
12
14
  //# sourceMappingURL=openai-reasoning.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"openai-reasoning.d.ts","sourceRoot":"","sources":["../../src/provider-compats/openai-reasoning.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAE1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EACL,iBAAiB,EASlB,MAAM,yBAAyB,CAAC;AAEjC,qBAAa,gCAAiC,SAAQ,iBAAiB;gBACzD,KAAK,EAAE,eAAe;IAIlC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,gBAAgB,IAAI,OAAO;IAU3B,WAAW,IAAI,OAAO;IAWtB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;CA4C9C"}
1
+ {"version":3,"file":"openai-reasoning.d.ts","sourceRoot":"","sources":["../../src/provider-compats/openai-reasoning.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,SAAS,EAA4B,MAAM,QAAQ,CAAC;AAC7E,OAAO,KAAK,EAAE,OAAO,IAAI,SAAS,EAA4B,MAAM,QAAQ,CAAC;AAC7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGjD,qBAAa,gCAAiC,SAAQ,iBAAiB;gBACzD,KAAK,EAAE,gBAAgB;IAInC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,gBAAgB,IAAI,OAAO;IAU3B,WAAW,IAAI,OAAO;IAWtB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS;IAC3C,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS;CA+C5C"}
@@ -1,11 +1,13 @@
1
- import type { LanguageModelV1 } from 'ai';
2
- import type { ZodTypeAny } from 'zod';
1
+ import type { ZodType as ZodTypeV3 } from 'zod/v3';
2
+ import type { ZodType as ZodTypeV4 } from 'zod/v4';
3
3
  import type { Targets } from 'zod-to-json-schema';
4
4
  import { SchemaCompatLayer } from '../schema-compatibility.js';
5
+ import type { ModelInformation } from '../types.js';
5
6
  export declare class OpenAISchemaCompatLayer extends SchemaCompatLayer {
6
- constructor(model: LanguageModelV1);
7
+ constructor(model: ModelInformation);
7
8
  getSchemaTarget(): Targets | undefined;
8
9
  shouldApply(): boolean;
9
- processZodType(value: ZodTypeAny): ZodTypeAny;
10
+ processZodType(value: ZodTypeV3): ZodTypeV3;
11
+ processZodType(value: ZodTypeV4): ZodTypeV4;
10
12
  }
11
13
  //# sourceMappingURL=openai.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/provider-compats/openai.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,IAAI,CAAC;AAC1C,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAA+C,MAAM,yBAAyB,CAAC;AAGzG,qBAAa,uBAAwB,SAAQ,iBAAiB;gBAChD,KAAK,EAAE,eAAe;IAIlC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,WAAW,IAAI,OAAO;IAWtB,cAAc,CAAC,KAAK,EAAE,UAAU,GAAG,UAAU;CA6B9C"}
1
+ {"version":3,"file":"openai.d.ts","sourceRoot":"","sources":["../../src/provider-compats/openai.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,OAAO,IAAI,SAAS,EAA4B,MAAM,QAAQ,CAAC;AAC7E,OAAO,KAAK,EAAE,OAAO,IAAI,SAAS,EAA4B,MAAM,QAAQ,CAAC;AAC7E,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,EAAE,iBAAiB,EAAE,MAAM,yBAAyB,CAAC;AAC5D,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGjD,qBAAa,uBAAwB,SAAQ,iBAAiB;gBAChD,KAAK,EAAE,gBAAgB;IAInC,eAAe,IAAI,OAAO,GAAG,SAAS;IAItC,WAAW,IAAI,OAAO;IAWtB,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS;IAC3C,cAAc,CAAC,KAAK,EAAE,SAAS,GAAG,SAAS;CAmC5C"}
@@ -0,0 +1,287 @@
1
+ import { z, ZodOptional, ZodObject, ZodArray, ZodUnion, ZodString, ZodNumber, ZodDate, ZodDefault, ZodNull } from 'zod';
2
+ import type { ZodTypeAny } from 'zod';
3
+ import type { Targets } from 'zod-to-json-schema';
4
+ import type { JSONSchema7 } from './json-schema.js';
5
+ import type { SchemaCompatLayer as ParentSchemaCompatLayer } from './schema-compatibility.js';
6
+ import type { Schema, ModelInformation } from './types.js';
7
+ /**
8
+ * All supported string validation check types that can be processed or converted to descriptions.
9
+ * @constant
10
+ */
11
+ export declare const ALL_STRING_CHECKS: readonly ["regex", "emoji", "email", "url", "uuid", "cuid", "min", "max"];
12
+ /**
13
+ * All supported number validation check types that can be processed or converted to descriptions.
14
+ * @constant
15
+ */
16
+ export declare const ALL_NUMBER_CHECKS: readonly ["min", "max", "multipleOf"];
17
+ /**
18
+ * All supported array validation check types that can be processed or converted to descriptions.
19
+ * @constant
20
+ */
21
+ export declare const ALL_ARRAY_CHECKS: readonly ["min", "max", "length"];
22
+ export declare const isOptional: (v: ZodTypeAny) => v is ZodOptional<any>;
23
+ export declare const isObj: (v: ZodTypeAny) => v is ZodObject<any, any, any>;
24
+ export declare const isNull: (v: ZodTypeAny) => v is ZodNull;
25
+ export declare const isArr: (v: ZodTypeAny) => v is ZodArray<any, any>;
26
+ export declare const isUnion: (v: ZodTypeAny) => v is ZodUnion<[ZodTypeAny, ...ZodTypeAny[]]>;
27
+ export declare const isString: (v: ZodTypeAny) => v is ZodString;
28
+ export declare const isNumber: (v: ZodTypeAny) => v is ZodNumber;
29
+ export declare const isDate: (v: ZodTypeAny) => v is ZodDate;
30
+ export declare const isDefault: (v: ZodTypeAny) => v is ZodDefault<any>;
31
+ /**
32
+ * Zod types that are not supported by most AI model providers and should be avoided.
33
+ * @constant
34
+ */
35
+ export declare const UNSUPPORTED_ZOD_TYPES: readonly ["ZodIntersection", "ZodNever", "ZodNull", "ZodTuple", "ZodUndefined"];
36
+ /**
37
+ * Zod types that are generally supported by AI model providers.
38
+ * @constant
39
+ */
40
+ export declare const SUPPORTED_ZOD_TYPES: readonly ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber", "ZodDate", "ZodAny", "ZodDefault"];
41
+ /**
42
+ * All Zod types (both supported and unsupported).
43
+ * @constant
44
+ */
45
+ export declare const ALL_ZOD_TYPES: readonly ["ZodObject", "ZodArray", "ZodUnion", "ZodString", "ZodNumber", "ZodDate", "ZodAny", "ZodDefault", "ZodIntersection", "ZodNever", "ZodNull", "ZodTuple", "ZodUndefined"];
46
+ /**
47
+ * Type representing string validation checks.
48
+ */
49
+ export type StringCheckType = (typeof ALL_STRING_CHECKS)[number];
50
+ /**
51
+ * Type representing number validation checks.
52
+ */
53
+ export type NumberCheckType = (typeof ALL_NUMBER_CHECKS)[number];
54
+ /**
55
+ * Type representing array validation checks.
56
+ */
57
+ export type ArrayCheckType = (typeof ALL_ARRAY_CHECKS)[number];
58
+ /**
59
+ * Type representing unsupported Zod schema types.
60
+ */
61
+ export type UnsupportedZodType = (typeof UNSUPPORTED_ZOD_TYPES)[number];
62
+ /**
63
+ * Type representing supported Zod schema types.
64
+ */
65
+ export type SupportedZodType = (typeof SUPPORTED_ZOD_TYPES)[number];
66
+ /**
67
+ * Type representing all Zod schema types (supported and unsupported).
68
+ */
69
+ export type AllZodType = (typeof ALL_ZOD_TYPES)[number];
70
+ /**
71
+ * Utility type to extract the shape of a Zod object schema.
72
+ */
73
+ export type ZodShape<T extends z.AnyZodObject> = T['shape'];
74
+ /**
75
+ * Utility type to extract the keys from a Zod object shape.
76
+ */
77
+ export type ShapeKey<T extends z.AnyZodObject> = keyof ZodShape<T>;
78
+ /**
79
+ * Utility type to extract the value types from a Zod object shape.
80
+ */
81
+ export type ShapeValue<T extends z.AnyZodObject> = ZodShape<T>[ShapeKey<T>];
82
+ type ConstraintHelperText = string[];
83
+ /**
84
+ * Abstract base class for creating schema compatibility layers for different AI model providers.
85
+ *
86
+ * This class provides a framework for transforming Zod schemas to work with specific AI model
87
+ * provider requirements and limitations. Each provider may have different support levels for
88
+ * JSON Schema features, validation constraints, and data types.
89
+ *
90
+ *
91
+ * @example
92
+ * ```typescript
93
+ * import { SchemaCompatLayer } from '@mastra/schema-compat';
94
+ * import type { LanguageModelV1 } from 'ai';
95
+ *
96
+ * class CustomProviderCompat extends SchemaCompatLayer {
97
+ * constructor(model: ModelInformation) {
98
+ * super(model);
99
+ * }
100
+ *
101
+ * shouldApply(): boolean {
102
+ * return this.getModel().provider === 'custom-provider';
103
+ * }
104
+ *
105
+ * getSchemaTarget() {
106
+ * return 'jsonSchema7';
107
+ * }
108
+ *
109
+ * processZodType<T extends z.AnyZodObject>(value: z.ZodTypeAny): ShapeValue<T> {
110
+ * // Custom processing logic for this provider
111
+ * switch (value._def.typeName) {
112
+ * case 'ZodString':
113
+ * return this.defaultZodStringHandler(value, ['email', 'url']);
114
+ * default:
115
+ * return this.defaultUnsupportedZodTypeHandler(value);
116
+ * }
117
+ * }
118
+ * }
119
+ * ```
120
+ */
121
+ export declare class SchemaCompatLayer {
122
+ private model;
123
+ private parent;
124
+ /**
125
+ * Creates a new schema compatibility instance.
126
+ *
127
+ * @param model - The language model this compatibility layer applies to
128
+ */
129
+ constructor(model: ModelInformation, parent: ParentSchemaCompatLayer);
130
+ /**
131
+ * Gets the language model associated with this compatibility layer.
132
+ *
133
+ * @returns The language model instance
134
+ */
135
+ getModel(): ModelInformation;
136
+ getUnsupportedZodTypes(): readonly string[];
137
+ /**
138
+ * Type guard for optional Zod types
139
+ */
140
+ isOptional(v: ZodTypeAny): v is ZodOptional<any>;
141
+ /**
142
+ * Type guard for object Zod types
143
+ */
144
+ isObj(v: ZodTypeAny): v is ZodObject<any, any, any>;
145
+ /**
146
+ * Type guard for null Zod types
147
+ */
148
+ isNull(v: ZodTypeAny): v is ZodNull;
149
+ /**
150
+ * Type guard for array Zod types
151
+ */
152
+ isArr(v: ZodTypeAny): v is ZodArray<any, any>;
153
+ /**
154
+ * Type guard for union Zod types
155
+ */
156
+ isUnion(v: ZodTypeAny): v is ZodUnion<[ZodTypeAny, ...ZodTypeAny[]]>;
157
+ /**
158
+ * Type guard for string Zod types
159
+ */
160
+ isString(v: ZodTypeAny): v is ZodString;
161
+ /**
162
+ * Type guard for number Zod types
163
+ */
164
+ isNumber(v: ZodTypeAny): v is ZodNumber;
165
+ /**
166
+ * Type guard for date Zod types
167
+ */
168
+ isDate(v: ZodTypeAny): v is ZodDate;
169
+ /**
170
+ * Type guard for default Zod types
171
+ */
172
+ isDefault(v: ZodTypeAny): v is ZodDefault<any>;
173
+ /**
174
+ * Determines whether this compatibility layer should be applied for the current model.
175
+ *
176
+ * @returns True if this compatibility layer should be used, false otherwise
177
+ * @abstract
178
+ */
179
+ shouldApply(): boolean;
180
+ /**
181
+ * Returns the JSON Schema target format for this provider.
182
+ *
183
+ * @returns The schema target format, or undefined to use the default 'jsonSchema7'
184
+ * @abstract
185
+ */
186
+ getSchemaTarget(): Targets | undefined;
187
+ /**
188
+ * Processes a specific Zod type according to the provider's requirements.
189
+ *
190
+ * @param value - The Zod type to process
191
+ * @returns The processed Zod type
192
+ * @abstract
193
+ */
194
+ processZodType(value: ZodTypeAny): ZodTypeAny;
195
+ /**
196
+ * Default handler for Zod object types. Recursively processes all properties in the object.
197
+ *
198
+ * @param value - The Zod object to process
199
+ * @returns The processed Zod object
200
+ */
201
+ defaultZodObjectHandler(value: ZodObject<any, any, any>, options?: {
202
+ passthrough?: boolean;
203
+ }): ZodObject<any, any, any>;
204
+ /**
205
+ * Merges validation constraints into a parameter description.
206
+ *
207
+ * This helper method converts validation constraints that may not be supported
208
+ * by a provider into human-readable descriptions.
209
+ *
210
+ * @param description - The existing parameter description
211
+ * @param constraints - The validation constraints to merge
212
+ * @returns The updated description with constraints, or undefined if no constraints
213
+ */
214
+ mergeParameterDescription(description: string | undefined, constraints: ConstraintHelperText): string | undefined;
215
+ /**
216
+ * Default handler for unsupported Zod types. Throws an error for specified unsupported types.
217
+ *
218
+ * @param value - The Zod type to check
219
+ * @param throwOnTypes - Array of type names to throw errors for
220
+ * @returns The original value if not in the throw list
221
+ * @throws Error if the type is in the unsupported list
222
+ */
223
+ defaultUnsupportedZodTypeHandler<T extends z.AnyZodObject>(value: z.ZodTypeAny, throwOnTypes?: readonly UnsupportedZodType[]): ShapeValue<T>;
224
+ /**
225
+ * Default handler for Zod array types. Processes array constraints according to provider support.
226
+ *
227
+ * @param value - The Zod array to process
228
+ * @param handleChecks - Array constraints to convert to descriptions vs keep as validation
229
+ * @returns The processed Zod array
230
+ */
231
+ defaultZodArrayHandler(value: ZodArray<any, any>, handleChecks?: readonly ArrayCheckType[]): ZodArray<any, any>;
232
+ /**
233
+ * Default handler for Zod union types. Processes all union options.
234
+ *
235
+ * @param value - The Zod union to process
236
+ * @returns The processed Zod union
237
+ * @throws Error if union has fewer than 2 options
238
+ */
239
+ defaultZodUnionHandler(value: ZodUnion<[ZodTypeAny, ...ZodTypeAny[]]>): ZodTypeAny;
240
+ /**
241
+ * Default handler for Zod string types. Processes string validation constraints.
242
+ *
243
+ * @param value - The Zod string to process
244
+ * @param handleChecks - String constraints to convert to descriptions vs keep as validation
245
+ * @returns The processed Zod string
246
+ */
247
+ defaultZodStringHandler(value: ZodString, handleChecks?: readonly StringCheckType[]): ZodString;
248
+ /**
249
+ * Default handler for Zod number types. Processes number validation constraints.
250
+ *
251
+ * @param value - The Zod number to process
252
+ * @param handleChecks - Number constraints to convert to descriptions vs keep as validation
253
+ * @returns The processed Zod number
254
+ */
255
+ defaultZodNumberHandler(value: ZodNumber, handleChecks?: readonly NumberCheckType[]): ZodNumber;
256
+ /**
257
+ * Default handler for Zod date types. Converts dates to ISO strings with constraint descriptions.
258
+ *
259
+ * @param value - The Zod date to process
260
+ * @returns A Zod string schema representing the date in ISO format
261
+ */
262
+ defaultZodDateHandler(value: ZodDate): ZodString;
263
+ /**
264
+ * Default handler for Zod optional types. Processes the inner type and maintains optionality.
265
+ *
266
+ * @param value - The Zod optional to process
267
+ * @param handleTypes - Types that should be processed vs passed through
268
+ * @returns The processed Zod optional
269
+ */
270
+ defaultZodOptionalHandler(value: ZodOptional<any>, handleTypes?: readonly AllZodType[]): ZodTypeAny;
271
+ /**
272
+ * Processes a Zod object schema and converts it to an AI SDK Schema.
273
+ *
274
+ * @param zodSchema - The Zod object schema to process
275
+ * @returns An AI SDK Schema with provider-specific compatibility applied
276
+ */
277
+ processToAISDKSchema(zodSchema: z.ZodSchema): Schema;
278
+ /**
279
+ * Processes a Zod object schema and converts it to a JSON Schema.
280
+ *
281
+ * @param zodSchema - The Zod object schema to process
282
+ * @returns A JSONSchema7 object with provider-specific compatibility applied
283
+ */
284
+ processToJSONSchema(zodSchema: z.ZodSchema): JSONSchema7;
285
+ }
286
+ export {};
287
+ //# sourceMappingURL=schema-compatibility-v3.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"schema-compatibility-v3.d.ts","sourceRoot":"","sources":["../src/schema-compatibility-v3.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,WAAW,EAAE,SAAS,EAAE,QAAQ,EAAE,QAAQ,EAAE,SAAS,EAAE,SAAS,EAAE,OAAO,EAAE,UAAU,EAAE,OAAO,EAAE,MAAM,KAAK,CAAC;AACxH,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,KAAK,CAAC;AACtC,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,oBAAoB,CAAC;AAClD,OAAO,KAAK,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AACjD,OAAO,KAAK,EAAE,iBAAiB,IAAI,uBAAuB,EAAE,MAAM,wBAAwB,CA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