@ai-sdk/provider-utils 5.0.0-beta.4 → 5.0.0-beta.49

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 (117) hide show
  1. package/CHANGELOG.md +373 -11
  2. package/dist/index.d.ts +1460 -553
  3. package/dist/index.js +1044 -361
  4. package/dist/index.js.map +1 -1
  5. package/dist/test/index.d.ts +2 -1
  6. package/dist/test/index.js +18 -37
  7. package/dist/test/index.js.map +1 -1
  8. package/package.json +16 -16
  9. package/src/add-additional-properties-to-json-schema.ts +1 -1
  10. package/src/as-array.ts +12 -0
  11. package/src/cancel-response-body.ts +19 -0
  12. package/src/convert-image-model-file-to-data-uri.ts +1 -1
  13. package/src/convert-inline-file-data-to-uint8-array.ts +30 -0
  14. package/src/create-tool-name-mapping.ts +1 -1
  15. package/src/detect-media-type.ts +312 -0
  16. package/src/download-blob.ts +8 -9
  17. package/src/extract-lines.ts +31 -0
  18. package/src/fetch-with-validated-redirects.ts +87 -0
  19. package/src/filter-nullable.ts +11 -0
  20. package/src/get-error-message.ts +1 -15
  21. package/src/get-from-api.ts +2 -2
  22. package/src/has-required-key.ts +6 -0
  23. package/src/index.ts +47 -12
  24. package/src/inject-json-instruction.ts +1 -1
  25. package/src/is-browser-runtime.ts +13 -0
  26. package/src/is-buffer.ts +9 -0
  27. package/src/is-json-serializable.ts +29 -0
  28. package/src/is-provider-reference.ts +21 -0
  29. package/src/is-same-origin.ts +19 -0
  30. package/src/is-url-supported.ts +17 -2
  31. package/src/load-api-key.ts +1 -1
  32. package/src/load-setting.ts +1 -1
  33. package/src/map-reasoning-to-provider.ts +108 -0
  34. package/src/maybe-promise-like.ts +3 -0
  35. package/src/parse-json-event-stream.ts +3 -3
  36. package/src/parse-json.ts +3 -3
  37. package/src/parse-provider-options.ts +1 -1
  38. package/src/post-to-api.ts +4 -4
  39. package/src/provider-defined-tool-factory.ts +129 -0
  40. package/src/provider-executed-tool-factory.ts +69 -0
  41. package/src/read-response-with-size-limit.ts +4 -0
  42. package/src/resolve-full-media-type.ts +49 -0
  43. package/src/resolve-provider-reference.ts +26 -0
  44. package/src/resolve.ts +16 -1
  45. package/src/response-handler.ts +3 -3
  46. package/src/schema.ts +11 -4
  47. package/src/secure-json-parse.ts +1 -1
  48. package/src/serialize-model-options.ts +63 -0
  49. package/src/streaming-tool-call-tracker.ts +241 -0
  50. package/src/test/convert-response-stream-to-array.ts +1 -1
  51. package/src/test/is-node-version.ts +22 -1
  52. package/src/to-json-schema/zod3-to-json-schema/options.ts +3 -3
  53. package/src/to-json-schema/zod3-to-json-schema/parse-def.ts +3 -3
  54. package/src/to-json-schema/zod3-to-json-schema/parse-types.ts +22 -22
  55. package/src/to-json-schema/zod3-to-json-schema/parsers/array.ts +3 -3
  56. package/src/to-json-schema/zod3-to-json-schema/parsers/bigint.ts +1 -1
  57. package/src/to-json-schema/zod3-to-json-schema/parsers/branded.ts +2 -2
  58. package/src/to-json-schema/zod3-to-json-schema/parsers/catch.ts +2 -2
  59. package/src/to-json-schema/zod3-to-json-schema/parsers/date.ts +4 -4
  60. package/src/to-json-schema/zod3-to-json-schema/parsers/default.ts +3 -3
  61. package/src/to-json-schema/zod3-to-json-schema/parsers/effects.ts +3 -3
  62. package/src/to-json-schema/zod3-to-json-schema/parsers/enum.ts +1 -1
  63. package/src/to-json-schema/zod3-to-json-schema/parsers/intersection.ts +5 -5
  64. package/src/to-json-schema/zod3-to-json-schema/parsers/literal.ts +1 -1
  65. package/src/to-json-schema/zod3-to-json-schema/parsers/map.ts +4 -5
  66. package/src/to-json-schema/zod3-to-json-schema/parsers/native-enum.ts +1 -1
  67. package/src/to-json-schema/zod3-to-json-schema/parsers/never.ts +1 -2
  68. package/src/to-json-schema/zod3-to-json-schema/parsers/nullable.ts +4 -4
  69. package/src/to-json-schema/zod3-to-json-schema/parsers/number.ts +1 -1
  70. package/src/to-json-schema/zod3-to-json-schema/parsers/object.ts +3 -3
  71. package/src/to-json-schema/zod3-to-json-schema/parsers/optional.ts +3 -3
  72. package/src/to-json-schema/zod3-to-json-schema/parsers/pipeline.ts +10 -8
  73. package/src/to-json-schema/zod3-to-json-schema/parsers/promise.ts +3 -3
  74. package/src/to-json-schema/zod3-to-json-schema/parsers/readonly.ts +2 -2
  75. package/src/to-json-schema/zod3-to-json-schema/parsers/record.ts +9 -10
  76. package/src/to-json-schema/zod3-to-json-schema/parsers/set.ts +3 -3
  77. package/src/to-json-schema/zod3-to-json-schema/parsers/string.ts +2 -2
  78. package/src/to-json-schema/zod3-to-json-schema/parsers/tuple.ts +3 -3
  79. package/src/to-json-schema/zod3-to-json-schema/parsers/undefined.ts +1 -2
  80. package/src/to-json-schema/zod3-to-json-schema/parsers/union.ts +3 -3
  81. package/src/to-json-schema/zod3-to-json-schema/parsers/unknown.ts +1 -2
  82. package/src/to-json-schema/zod3-to-json-schema/refs.ts +3 -3
  83. package/src/to-json-schema/zod3-to-json-schema/select-parser.ts +2 -2
  84. package/src/to-json-schema/zod3-to-json-schema/zod3-to-json-schema.ts +3 -3
  85. package/src/types/assistant-model-message.ts +5 -3
  86. package/src/types/content-part.ts +158 -19
  87. package/src/types/context.ts +4 -0
  88. package/src/types/executable-tool.ts +17 -0
  89. package/src/types/execute-tool.ts +29 -9
  90. package/src/types/file-data.ts +48 -0
  91. package/src/types/index.ts +29 -11
  92. package/src/types/infer-tool-context.ts +41 -0
  93. package/src/types/infer-tool-input.ts +7 -0
  94. package/src/types/infer-tool-output.ts +7 -0
  95. package/src/types/infer-tool-set-context.ts +44 -0
  96. package/src/types/model-message.ts +4 -4
  97. package/src/types/never-optional.ts +7 -0
  98. package/src/types/provider-options.ts +1 -1
  99. package/src/types/provider-reference.ts +10 -0
  100. package/src/types/sandbox.ts +217 -0
  101. package/src/types/system-model-message.ts +1 -1
  102. package/src/types/tool-approval-request.ts +13 -0
  103. package/src/types/tool-execute-function.ts +56 -0
  104. package/src/types/tool-model-message.ts +3 -3
  105. package/src/types/tool-needs-approval-function.ts +39 -0
  106. package/src/types/tool-set.ts +22 -0
  107. package/src/types/tool.ts +278 -225
  108. package/src/types/user-model-message.ts +2 -2
  109. package/src/validate-download-url.ts +120 -33
  110. package/src/validate-types.ts +5 -3
  111. package/dist/index.d.mts +0 -1455
  112. package/dist/index.mjs +0 -2754
  113. package/dist/index.mjs.map +0 -1
  114. package/dist/test/index.d.mts +0 -17
  115. package/dist/test/index.mjs +0 -77
  116. package/dist/test/index.mjs.map +0 -1
  117. package/src/provider-tool-factory.ts +0 -125
@@ -1,4 +1,25 @@
1
+ function getNodeVersionParts() {
2
+ return process.versions.node
3
+ .split('.')
4
+ .map(version => Number.parseInt(version, 10));
5
+ }
6
+
1
7
  export function isNodeVersion(version: number) {
2
- const nodeMajorVersion = parseInt(process.version.slice(1).split('.')[0], 10);
8
+ const [nodeMajorVersion] = getNodeVersionParts();
3
9
  return nodeMajorVersion === version;
4
10
  }
11
+
12
+ export function isNodeVersionAtLeast(major: number, minor = 0, patch = 0) {
13
+ const [nodeMajorVersion, nodeMinorVersion, nodePatchVersion] =
14
+ getNodeVersionParts();
15
+
16
+ if (nodeMajorVersion !== major) {
17
+ return nodeMajorVersion > major;
18
+ }
19
+
20
+ if (nodeMinorVersion !== minor) {
21
+ return nodeMinorVersion > minor;
22
+ }
23
+
24
+ return nodePatchVersion >= patch;
25
+ }
@@ -1,6 +1,6 @@
1
- import { ZodSchema, ZodTypeDef } from 'zod/v3';
2
- import { Refs, Seen } from './refs';
3
- import { JsonSchema7Type } from './parse-types';
1
+ import type { ZodSchema, ZodTypeDef } from 'zod/v3';
2
+ import type { Refs, Seen } from './refs';
3
+ import type { JsonSchema7Type } from './parse-types';
4
4
 
5
5
  export type DateStrategy =
6
6
  | 'format:date-time'
@@ -1,7 +1,7 @@
1
- import { ZodTypeDef } from 'zod/v3';
2
- import { Refs, Seen } from './refs';
1
+ import type { ZodTypeDef } from 'zod/v3';
2
+ import type { Refs, Seen } from './refs';
3
3
  import { ignoreOverride } from './options';
4
- import { JsonSchema7Type } from './parse-types';
4
+ import type { JsonSchema7Type } from './parse-types';
5
5
  import { selectParser } from './select-parser';
6
6
  import { getRelativePath } from './get-relative-path';
7
7
  import { parseAnyDef } from './parsers/any';
@@ -1,25 +1,25 @@
1
- import { JsonSchema7AnyType } from './parsers/any';
2
- import { JsonSchema7ArrayType } from './parsers/array';
3
- import { JsonSchema7BigintType } from './parsers/bigint';
4
- import { JsonSchema7BooleanType } from './parsers/boolean';
5
- import { JsonSchema7DateType } from './parsers/date';
6
- import { JsonSchema7EnumType } from './parsers/enum';
7
- import { JsonSchema7AllOfType } from './parsers/intersection';
8
- import { JsonSchema7LiteralType } from './parsers/literal';
9
- import { JsonSchema7MapType } from './parsers/map';
10
- import { JsonSchema7NativeEnumType } from './parsers/native-enum';
11
- import { JsonSchema7NeverType } from './parsers/never';
12
- import { JsonSchema7NullType } from './parsers/null';
13
- import { JsonSchema7NullableType } from './parsers/nullable';
14
- import { JsonSchema7NumberType } from './parsers/number';
15
- import { JsonSchema7ObjectType } from './parsers/object';
16
- import { JsonSchema7RecordType } from './parsers/record';
17
- import { JsonSchema7SetType } from './parsers/set';
18
- import { JsonSchema7StringType } from './parsers/string';
19
- import { JsonSchema7TupleType } from './parsers/tuple';
20
- import { JsonSchema7UndefinedType } from './parsers/undefined';
21
- import { JsonSchema7UnionType } from './parsers/union';
22
- import { JsonSchema7UnknownType } from './parsers/unknown';
1
+ import type { JsonSchema7AnyType } from './parsers/any';
2
+ import type { JsonSchema7ArrayType } from './parsers/array';
3
+ import type { JsonSchema7BigintType } from './parsers/bigint';
4
+ import type { JsonSchema7BooleanType } from './parsers/boolean';
5
+ import type { JsonSchema7DateType } from './parsers/date';
6
+ import type { JsonSchema7EnumType } from './parsers/enum';
7
+ import type { JsonSchema7AllOfType } from './parsers/intersection';
8
+ import type { JsonSchema7LiteralType } from './parsers/literal';
9
+ import type { JsonSchema7MapType } from './parsers/map';
10
+ import type { JsonSchema7NativeEnumType } from './parsers/native-enum';
11
+ import type { JsonSchema7NeverType } from './parsers/never';
12
+ import type { JsonSchema7NullType } from './parsers/null';
13
+ import type { JsonSchema7NullableType } from './parsers/nullable';
14
+ import type { JsonSchema7NumberType } from './parsers/number';
15
+ import type { JsonSchema7ObjectType } from './parsers/object';
16
+ import type { JsonSchema7RecordType } from './parsers/record';
17
+ import type { JsonSchema7SetType } from './parsers/set';
18
+ import type { JsonSchema7StringType } from './parsers/string';
19
+ import type { JsonSchema7TupleType } from './parsers/tuple';
20
+ import type { JsonSchema7UndefinedType } from './parsers/undefined';
21
+ import type { JsonSchema7UnionType } from './parsers/union';
22
+ import type { JsonSchema7UnknownType } from './parsers/unknown';
23
23
 
24
24
  type JsonSchema7RefType = { $ref: string };
25
25
  type JsonSchema7Meta = {
@@ -1,7 +1,7 @@
1
- import { ZodArrayDef, ZodFirstPartyTypeKind } from 'zod/v3';
1
+ import { ZodFirstPartyTypeKind, type ZodArrayDef } from 'zod/v3';
2
2
  import { parseDef } from '../parse-def';
3
- import { JsonSchema7Type } from '../parse-types';
4
- import { Refs } from '../refs';
3
+ import type { JsonSchema7Type } from '../parse-types';
4
+ import type { Refs } from '../refs';
5
5
 
6
6
  export type JsonSchema7ArrayType = {
7
7
  type: 'array';
@@ -1,4 +1,4 @@
1
- import { ZodBigIntDef } from 'zod/v3';
1
+ import type { ZodBigIntDef } from 'zod/v3';
2
2
 
3
3
  export type JsonSchema7BigintType = {
4
4
  type: 'integer';
@@ -1,6 +1,6 @@
1
- import { ZodBrandedDef } from 'zod/v3';
1
+ import type { ZodBrandedDef } from 'zod/v3';
2
2
  import { parseDef } from '../parse-def';
3
- import { Refs } from '../refs';
3
+ import type { Refs } from '../refs';
4
4
 
5
5
  export function parseBrandedDef(_def: ZodBrandedDef<any>, refs: Refs) {
6
6
  return parseDef(_def.type._def, refs);
@@ -1,6 +1,6 @@
1
- import { ZodCatchDef } from 'zod/v3';
1
+ import type { ZodCatchDef } from 'zod/v3';
2
2
  import { parseDef } from '../parse-def';
3
- import { Refs } from '../refs';
3
+ import type { Refs } from '../refs';
4
4
 
5
5
  export const parseCatchDef = (def: ZodCatchDef<any>, refs: Refs) => {
6
6
  return parseDef(def.innerType._def, refs);
@@ -1,6 +1,6 @@
1
- import { ZodDateDef } from 'zod/v3';
2
- import { Refs } from '../refs';
3
- import { DateStrategy } from '../options';
1
+ import type { ZodDateDef } from 'zod/v3';
2
+ import type { Refs } from '../refs';
3
+ import type { DateStrategy } from '../options';
4
4
 
5
5
  export type JsonSchema7DateType =
6
6
  | {
@@ -22,7 +22,7 @@ export function parseDateDef(
22
22
 
23
23
  if (Array.isArray(strategy)) {
24
24
  return {
25
- anyOf: strategy.map((item, i) => parseDateDef(def, refs, item)),
25
+ anyOf: strategy.map(item => parseDateDef(def, refs, item)),
26
26
  };
27
27
  }
28
28
 
@@ -1,7 +1,7 @@
1
- import { ZodDefaultDef } from 'zod/v3';
1
+ import type { ZodDefaultDef } from 'zod/v3';
2
2
  import { parseDef } from '../parse-def';
3
- import { JsonSchema7Type } from '../parse-types';
4
- import { Refs } from '../refs';
3
+ import type { JsonSchema7Type } from '../parse-types';
4
+ import type { Refs } from '../refs';
5
5
 
6
6
  export function parseDefaultDef(
7
7
  _def: ZodDefaultDef,
@@ -1,7 +1,7 @@
1
- import { ZodEffectsDef } from 'zod/v3';
1
+ import type { ZodEffectsDef } from 'zod/v3';
2
2
  import { parseDef } from '../parse-def';
3
- import { JsonSchema7Type } from '../parse-types';
4
- import { Refs } from '../refs';
3
+ import type { JsonSchema7Type } from '../parse-types';
4
+ import type { Refs } from '../refs';
5
5
  import { parseAnyDef } from './any';
6
6
 
7
7
  export function parseEffectsDef(
@@ -1,4 +1,4 @@
1
- import { ZodEnumDef } from 'zod/v3';
1
+ import type { ZodEnumDef } from 'zod/v3';
2
2
 
3
3
  export type JsonSchema7EnumType = {
4
4
  type: 'string';
@@ -1,8 +1,8 @@
1
- import { ZodIntersectionDef } from 'zod/v3';
1
+ import type { ZodIntersectionDef } from 'zod/v3';
2
2
  import { parseDef } from '../parse-def';
3
- import { JsonSchema7Type } from '../parse-types';
4
- import { Refs } from '../refs';
5
- import { JsonSchema7StringType } from './string';
3
+ import type { JsonSchema7Type } from '../parse-types';
4
+ import type { Refs } from '../refs';
5
+ import type { JsonSchema7StringType } from './string';
6
6
 
7
7
  export type JsonSchema7AllOfType = {
8
8
  allOf: JsonSchema7Type[];
@@ -42,7 +42,7 @@ export function parseIntersectionDef(
42
42
  'additionalProperties' in schema &&
43
43
  schema.additionalProperties === false
44
44
  ) {
45
- const { additionalProperties, ...rest } = schema;
45
+ const { additionalProperties: _additionalProperties, ...rest } = schema;
46
46
  nestedSchema = rest;
47
47
  }
48
48
  mergedAllOf.push(nestedSchema);
@@ -1,4 +1,4 @@
1
- import { ZodLiteralDef } from 'zod/v3';
1
+ import type { ZodLiteralDef } from 'zod/v3';
2
2
 
3
3
  export type JsonSchema7LiteralType =
4
4
  | {
@@ -1,10 +1,9 @@
1
- import { ZodMapDef } from 'zod/v3';
1
+ import type { ZodMapDef } from 'zod/v3';
2
2
  import { parseDef } from '../parse-def';
3
- import { JsonSchema7Type } from '../parse-types';
4
- import { Refs } from '../refs';
3
+ import type { JsonSchema7Type } from '../parse-types';
4
+ import type { Refs } from '../refs';
5
5
  import { parseAnyDef } from './any';
6
- import { JsonSchema7RecordType, parseRecordDef } from './record';
7
-
6
+ import { parseRecordDef, type JsonSchema7RecordType } from './record';
8
7
  export type JsonSchema7MapType = {
9
8
  type: 'array';
10
9
  maxItems: 125;
@@ -1,4 +1,4 @@
1
- import { ZodNativeEnumDef } from 'zod/v3';
1
+ import type { ZodNativeEnumDef } from 'zod/v3';
2
2
 
3
3
  export type JsonSchema7NativeEnumType = {
4
4
  type: 'string' | 'number' | ['string', 'number'];
@@ -1,5 +1,4 @@
1
- import { JsonSchema7AnyType, parseAnyDef } from './any';
2
-
1
+ import { parseAnyDef, type JsonSchema7AnyType } from './any';
3
2
  export type JsonSchema7NeverType = {
4
3
  not: JsonSchema7AnyType;
5
4
  };
@@ -1,8 +1,8 @@
1
- import { ZodNullableDef } from 'zod/v3';
1
+ import type { ZodNullableDef } from 'zod/v3';
2
2
  import { parseDef } from '../parse-def';
3
- import { JsonSchema7Type } from '../parse-types';
4
- import { Refs } from '../refs';
5
- import { JsonSchema7NullType } from './null';
3
+ import type { JsonSchema7Type } from '../parse-types';
4
+ import type { Refs } from '../refs';
5
+ import type { JsonSchema7NullType } from './null';
6
6
  import { primitiveMappings } from './union';
7
7
 
8
8
  export type JsonSchema7NullableType =
@@ -1,4 +1,4 @@
1
- import { ZodNumberDef } from 'zod/v3';
1
+ import type { ZodNumberDef } from 'zod/v3';
2
2
 
3
3
  export type JsonSchema7NumberType = {
4
4
  type: 'number' | 'integer';
@@ -1,7 +1,7 @@
1
- import { ZodObjectDef, ZodTypeAny } from 'zod/v3';
1
+ import type { ZodObjectDef, ZodTypeAny } from 'zod/v3';
2
2
  import { parseDef } from '../parse-def';
3
- import { JsonSchema7Type } from '../parse-types';
4
- import { Refs } from '../refs';
3
+ import type { JsonSchema7Type } from '../parse-types';
4
+ import type { Refs } from '../refs';
5
5
 
6
6
  export type JsonSchema7ObjectType = {
7
7
  type: 'object';
@@ -1,7 +1,7 @@
1
- import { ZodOptionalDef } from 'zod/v3';
1
+ import type { ZodOptionalDef } from 'zod/v3';
2
2
  import { parseDef } from '../parse-def';
3
- import { JsonSchema7Type } from '../parse-types';
4
- import { Refs } from '../refs';
3
+ import type { JsonSchema7Type } from '../parse-types';
4
+ import type { Refs } from '../refs';
5
5
  import { parseAnyDef } from './any';
6
6
 
7
7
  export const parseOptionalDef = (
@@ -1,8 +1,8 @@
1
- import { ZodPipelineDef } from 'zod/v3';
1
+ import type { ZodPipelineDef } from 'zod/v3';
2
2
  import { parseDef } from '../parse-def';
3
- import { JsonSchema7Type } from '../parse-types';
4
- import { Refs } from '../refs';
5
- import { JsonSchema7AllOfType } from './intersection';
3
+ import type { JsonSchema7Type } from '../parse-types';
4
+ import type { Refs } from '../refs';
5
+ import type { JsonSchema7AllOfType } from './intersection';
6
6
 
7
7
  export const parsePipelineDef = (
8
8
  def: ZodPipelineDef<any, any>,
@@ -14,16 +14,18 @@ export const parsePipelineDef = (
14
14
  return parseDef(def.out._def, refs);
15
15
  }
16
16
 
17
- const a = parseDef(def.in._def, {
17
+ const inputSchema = parseDef(def.in._def, {
18
18
  ...refs,
19
19
  currentPath: [...refs.currentPath, 'allOf', '0'],
20
20
  });
21
- const b = parseDef(def.out._def, {
21
+ const outputSchema = parseDef(def.out._def, {
22
22
  ...refs,
23
- currentPath: [...refs.currentPath, 'allOf', a ? '1' : '0'],
23
+ currentPath: [...refs.currentPath, 'allOf', inputSchema ? '1' : '0'],
24
24
  });
25
25
 
26
26
  return {
27
- allOf: [a, b].filter((x): x is JsonSchema7Type => x !== undefined),
27
+ allOf: [inputSchema, outputSchema].filter(
28
+ (schema): schema is JsonSchema7Type => schema !== undefined,
29
+ ),
28
30
  };
29
31
  };
@@ -1,7 +1,7 @@
1
- import { ZodPromiseDef } from 'zod/v3';
1
+ import type { ZodPromiseDef } from 'zod/v3';
2
2
  import { parseDef } from '../parse-def';
3
- import { JsonSchema7Type } from '../parse-types';
4
- import { Refs } from '../refs';
3
+ import type { JsonSchema7Type } from '../parse-types';
4
+ import type { Refs } from '../refs';
5
5
 
6
6
  export function parsePromiseDef(
7
7
  def: ZodPromiseDef,
@@ -1,6 +1,6 @@
1
- import { ZodReadonlyDef } from 'zod/v3';
1
+ import type { ZodReadonlyDef } from 'zod/v3';
2
2
  import { parseDef } from '../parse-def';
3
- import { Refs } from '../refs';
3
+ import type { Refs } from '../refs';
4
4
 
5
5
  export const parseReadonlyDef = (def: ZodReadonlyDef<any>, refs: Refs) => {
6
6
  return parseDef(def.innerType._def, refs);
@@ -1,16 +1,15 @@
1
1
  import {
2
2
  ZodFirstPartyTypeKind,
3
- ZodMapDef,
4
- ZodRecordDef,
5
- ZodTypeAny,
3
+ type ZodMapDef,
4
+ type ZodRecordDef,
5
+ type ZodTypeAny,
6
6
  } from 'zod/v3';
7
7
  import { parseDef } from '../parse-def';
8
- import { JsonSchema7Type } from '../parse-types';
9
- import { Refs } from '../refs';
8
+ import type { JsonSchema7Type } from '../parse-types';
9
+ import type { Refs } from '../refs';
10
10
  import { parseBrandedDef } from './branded';
11
- import { JsonSchema7EnumType } from './enum';
12
- import { JsonSchema7StringType, parseStringDef } from './string';
13
-
11
+ import type { JsonSchema7EnumType } from './enum';
12
+ import { parseStringDef, type JsonSchema7StringType } from './string';
14
13
  type JsonSchema7RecordPropertyNamesType =
15
14
  | Omit<JsonSchema7StringType, 'type'>
16
15
  | Omit<JsonSchema7EnumType, 'type'>;
@@ -38,7 +37,7 @@ export function parseRecordDef(
38
37
  def.keyType?._def.typeName === ZodFirstPartyTypeKind.ZodString &&
39
38
  def.keyType._def.checks?.length
40
39
  ) {
41
- const { type, ...keyType } = parseStringDef(def.keyType._def, refs);
40
+ const { type: _type, ...keyType } = parseStringDef(def.keyType._def, refs);
42
41
 
43
42
  return {
44
43
  ...schema,
@@ -56,7 +55,7 @@ export function parseRecordDef(
56
55
  def.keyType._def.type._def.typeName === ZodFirstPartyTypeKind.ZodString &&
57
56
  def.keyType._def.type._def.checks?.length
58
57
  ) {
59
- const { type, ...keyType } = parseBrandedDef(
58
+ const { type: _type, ...keyType } = parseBrandedDef(
60
59
  def.keyType._def,
61
60
  refs,
62
61
  ) as JsonSchema7StringType;
@@ -1,7 +1,7 @@
1
- import { ZodSetDef } from 'zod/v3';
1
+ import type { ZodSetDef } from 'zod/v3';
2
2
  import { parseDef } from '../parse-def';
3
- import { JsonSchema7Type } from '../parse-types';
4
- import { Refs } from '../refs';
3
+ import type { JsonSchema7Type } from '../parse-types';
4
+ import type { Refs } from '../refs';
5
5
 
6
6
  export type JsonSchema7SetType = {
7
7
  type: 'array';
@@ -1,5 +1,5 @@
1
- import { ZodStringDef } from 'zod/v3';
2
- import { Refs } from '../refs';
1
+ import type { ZodStringDef } from 'zod/v3';
2
+ import type { Refs } from '../refs';
3
3
 
4
4
  let emojiRegex: RegExp | undefined = undefined;
5
5
 
@@ -1,7 +1,7 @@
1
- import { ZodTupleDef, ZodTupleItems, ZodTypeAny } from 'zod/v3';
1
+ import type { ZodTupleDef, ZodTupleItems, ZodTypeAny } from 'zod/v3';
2
2
  import { parseDef } from '../parse-def';
3
- import { JsonSchema7Type } from '../parse-types';
4
- import { Refs } from '../refs';
3
+ import type { JsonSchema7Type } from '../parse-types';
4
+ import type { Refs } from '../refs';
5
5
 
6
6
  export type JsonSchema7TupleType = {
7
7
  type: 'array';
@@ -1,5 +1,4 @@
1
- import { JsonSchema7AnyType, parseAnyDef } from './any';
2
-
1
+ import { parseAnyDef, type JsonSchema7AnyType } from './any';
3
2
  export type JsonSchema7UndefinedType = {
4
3
  not: JsonSchema7AnyType;
5
4
  };
@@ -1,12 +1,12 @@
1
- import {
1
+ import type {
2
2
  ZodDiscriminatedUnionDef,
3
3
  ZodLiteralDef,
4
4
  ZodTypeAny,
5
5
  ZodUnionDef,
6
6
  } from 'zod/v3';
7
7
  import { parseDef } from '../parse-def';
8
- import { JsonSchema7Type } from '../parse-types';
9
- import { Refs } from '../refs';
8
+ import type { JsonSchema7Type } from '../parse-types';
9
+ import type { Refs } from '../refs';
10
10
 
11
11
  export const primitiveMappings = {
12
12
  ZodString: 'string',
@@ -1,5 +1,4 @@
1
- import { JsonSchema7AnyType, parseAnyDef } from './any';
2
-
1
+ import { parseAnyDef, type JsonSchema7AnyType } from './any';
3
2
  export type JsonSchema7UnknownType = JsonSchema7AnyType;
4
3
 
5
4
  export function parseUnknownDef(): JsonSchema7UnknownType {
@@ -1,6 +1,6 @@
1
- import { ZodTypeDef } from 'zod/v3';
2
- import { getDefaultOptions, Options } from './options';
3
- import { JsonSchema7Type } from './parse-types';
1
+ import type { ZodTypeDef } from 'zod/v3';
2
+ import { getDefaultOptions, type Options } from './options';
3
+ import type { JsonSchema7Type } from './parse-types';
4
4
 
5
5
  export type Refs = {
6
6
  seen: Map<ZodTypeDef, Seen>;
@@ -28,9 +28,9 @@ import { parseTupleDef } from './parsers/tuple';
28
28
  import { parseUndefinedDef } from './parsers/undefined';
29
29
  import { parseUnionDef } from './parsers/union';
30
30
  import { parseUnknownDef } from './parsers/unknown';
31
- import { Refs } from './refs';
31
+ import type { Refs } from './refs';
32
32
  import { parseReadonlyDef } from './parsers/readonly';
33
- import { JsonSchema7Type } from './parse-types';
33
+ import type { JsonSchema7Type } from './parse-types';
34
34
 
35
35
  export type InnerDefGetter = () => any;
36
36
 
@@ -1,7 +1,7 @@
1
- import { ZodSchema } from 'zod/v3';
2
- import { Options } from './options';
1
+ import type { ZodSchema } from 'zod/v3';
2
+ import type { Options } from './options';
3
3
  import { parseDef } from './parse-def';
4
- import { JsonSchema7Type } from './parse-types';
4
+ import type { JsonSchema7Type } from './parse-types';
5
5
  import { getRefs } from './refs';
6
6
  import { parseAnyDef } from './parsers/any';
7
7
 
@@ -1,4 +1,5 @@
1
- import {
1
+ import type {
2
+ CustomPart,
2
3
  FilePart,
3
4
  ReasoningFilePart,
4
5
  ReasoningPart,
@@ -6,8 +7,8 @@ import {
6
7
  ToolCallPart,
7
8
  ToolResultPart,
8
9
  } from './content-part';
9
- import { ProviderOptions } from './provider-options';
10
- import { ToolApprovalRequest } from './tool-approval-request';
10
+ import type { ProviderOptions } from './provider-options';
11
+ import type { ToolApprovalRequest } from './tool-approval-request';
11
12
 
12
13
  /**
13
14
  * An assistant message. It can contain text, tool calls, or a combination of text and tool calls.
@@ -32,6 +33,7 @@ export type AssistantContent =
32
33
  | string
33
34
  | Array<
34
35
  | TextPart
36
+ | CustomPart
35
37
  | FilePart
36
38
  | ReasoningPart
37
39
  | ReasoningFilePart