@ai-sdk/provider-utils 5.0.0-beta.28 → 5.0.0-beta.29

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 (82) hide show
  1. package/CHANGELOG.md +11 -0
  2. package/dist/index.d.ts +967 -843
  3. package/dist/index.js +340 -4
  4. package/dist/index.js.map +1 -1
  5. package/package.json +2 -2
  6. package/src/add-additional-properties-to-json-schema.ts +1 -1
  7. package/src/convert-image-model-file-to-data-uri.ts +1 -1
  8. package/src/convert-inline-file-data-to-uint8-array.ts +30 -0
  9. package/src/create-tool-name-mapping.ts +1 -1
  10. package/src/detect-media-type.ts +312 -0
  11. package/src/get-from-api.ts +2 -2
  12. package/src/index.ts +8 -0
  13. package/src/inject-json-instruction.ts +1 -1
  14. package/src/is-buffer.ts +9 -0
  15. package/src/is-json-serializable.ts +1 -1
  16. package/src/is-provider-reference.ts +11 -8
  17. package/src/is-url-supported.ts +17 -2
  18. package/src/map-reasoning-to-provider.ts +4 -1
  19. package/src/parse-json-event-stream.ts +3 -3
  20. package/src/parse-json.ts +2 -2
  21. package/src/parse-provider-options.ts +1 -1
  22. package/src/post-to-api.ts +2 -2
  23. package/src/provider-defined-tool-factory.ts +10 -9
  24. package/src/provider-executed-tool-factory.ts +6 -7
  25. package/src/resolve-full-media-type.ts +49 -0
  26. package/src/resolve-provider-reference.ts +1 -2
  27. package/src/resolve.ts +1 -1
  28. package/src/response-handler.ts +2 -2
  29. package/src/schema.ts +6 -3
  30. package/src/serialize-model-options.ts +2 -2
  31. package/src/streaming-tool-call-tracker.ts +2 -2
  32. package/src/to-json-schema/zod3-to-json-schema/options.ts +3 -3
  33. package/src/to-json-schema/zod3-to-json-schema/parse-def.ts +3 -3
  34. package/src/to-json-schema/zod3-to-json-schema/parse-types.ts +22 -22
  35. package/src/to-json-schema/zod3-to-json-schema/parsers/array.ts +3 -3
  36. package/src/to-json-schema/zod3-to-json-schema/parsers/bigint.ts +1 -1
  37. package/src/to-json-schema/zod3-to-json-schema/parsers/branded.ts +2 -2
  38. package/src/to-json-schema/zod3-to-json-schema/parsers/catch.ts +2 -2
  39. package/src/to-json-schema/zod3-to-json-schema/parsers/date.ts +3 -3
  40. package/src/to-json-schema/zod3-to-json-schema/parsers/default.ts +3 -3
  41. package/src/to-json-schema/zod3-to-json-schema/parsers/effects.ts +3 -3
  42. package/src/to-json-schema/zod3-to-json-schema/parsers/enum.ts +1 -1
  43. package/src/to-json-schema/zod3-to-json-schema/parsers/intersection.ts +4 -4
  44. package/src/to-json-schema/zod3-to-json-schema/parsers/literal.ts +1 -1
  45. package/src/to-json-schema/zod3-to-json-schema/parsers/map.ts +4 -5
  46. package/src/to-json-schema/zod3-to-json-schema/parsers/native-enum.ts +1 -1
  47. package/src/to-json-schema/zod3-to-json-schema/parsers/never.ts +1 -2
  48. package/src/to-json-schema/zod3-to-json-schema/parsers/nullable.ts +4 -4
  49. package/src/to-json-schema/zod3-to-json-schema/parsers/number.ts +1 -1
  50. package/src/to-json-schema/zod3-to-json-schema/parsers/object.ts +3 -3
  51. package/src/to-json-schema/zod3-to-json-schema/parsers/optional.ts +3 -3
  52. package/src/to-json-schema/zod3-to-json-schema/parsers/pipeline.ts +4 -4
  53. package/src/to-json-schema/zod3-to-json-schema/parsers/promise.ts +3 -3
  54. package/src/to-json-schema/zod3-to-json-schema/parsers/readonly.ts +2 -2
  55. package/src/to-json-schema/zod3-to-json-schema/parsers/record.ts +7 -8
  56. package/src/to-json-schema/zod3-to-json-schema/parsers/set.ts +3 -3
  57. package/src/to-json-schema/zod3-to-json-schema/parsers/string.ts +2 -2
  58. package/src/to-json-schema/zod3-to-json-schema/parsers/tuple.ts +3 -3
  59. package/src/to-json-schema/zod3-to-json-schema/parsers/undefined.ts +1 -2
  60. package/src/to-json-schema/zod3-to-json-schema/parsers/union.ts +3 -3
  61. package/src/to-json-schema/zod3-to-json-schema/parsers/unknown.ts +1 -2
  62. package/src/to-json-schema/zod3-to-json-schema/refs.ts +3 -3
  63. package/src/to-json-schema/zod3-to-json-schema/select-parser.ts +2 -2
  64. package/src/to-json-schema/zod3-to-json-schema/zod3-to-json-schema.ts +3 -3
  65. package/src/types/assistant-model-message.ts +3 -3
  66. package/src/types/content-part.ts +37 -14
  67. package/src/types/executable-tool.ts +1 -1
  68. package/src/types/execute-tool.ts +6 -5
  69. package/src/types/file-data.ts +48 -0
  70. package/src/types/index.ts +16 -3
  71. package/src/types/infer-tool-context.ts +1 -1
  72. package/src/types/model-message.ts +4 -4
  73. package/src/types/never-optional.ts +7 -0
  74. package/src/types/provider-options.ts +1 -1
  75. package/src/types/provider-reference.ts +1 -1
  76. package/src/types/system-model-message.ts +1 -1
  77. package/src/types/tool-execute-function.ts +50 -0
  78. package/src/types/tool-model-message.ts +3 -3
  79. package/src/types/tool-needs-approval-function.ts +39 -0
  80. package/src/types/tool.ts +200 -271
  81. package/src/types/user-model-message.ts +2 -2
  82. package/src/validate-types.ts +5 -3
@@ -1,7 +1,6 @@
1
- import { FlexibleSchema } from './schema';
2
- import { Context } from './types/context';
3
- import { tool, Tool } from './types/tool';
4
-
1
+ import type { FlexibleSchema } from './schema';
2
+ import type { Context } from './types/context';
3
+ import { tool, type ProviderExecutedTool, type Tool } from './types/tool';
5
4
  /**
6
5
  * A provider-executed tool is a tool for which the provider executes the tool.
7
6
  */
@@ -16,7 +15,7 @@ export type ProviderExecutedToolFactory<
16
15
  onInputDelta?: Tool<INPUT, OUTPUT, CONTEXT>['onInputDelta'];
17
16
  onInputAvailable?: Tool<INPUT, OUTPUT, CONTEXT>['onInputAvailable'];
18
17
  },
19
- ) => Tool<INPUT, OUTPUT, CONTEXT>;
18
+ ) => ProviderExecutedTool<INPUT, OUTPUT, CONTEXT>;
20
19
 
21
20
  export function createProviderExecutedToolFactory<
22
21
  INPUT,
@@ -54,7 +53,7 @@ export function createProviderExecutedToolFactory<
54
53
  onInputStart?: Tool<INPUT, OUTPUT, CONTEXT>['onInputStart'];
55
54
  onInputDelta?: Tool<INPUT, OUTPUT, CONTEXT>['onInputDelta'];
56
55
  onInputAvailable?: Tool<INPUT, OUTPUT, CONTEXT>['onInputAvailable'];
57
- }): Tool<INPUT, OUTPUT, CONTEXT> =>
56
+ }): ProviderExecutedTool<INPUT, OUTPUT, CONTEXT> =>
58
57
  tool({
59
58
  type: 'provider',
60
59
  isProviderExecuted: true,
@@ -66,5 +65,5 @@ export function createProviderExecutedToolFactory<
66
65
  onInputDelta,
67
66
  onInputAvailable,
68
67
  supportsDeferredResults,
69
- });
68
+ }) as ProviderExecutedTool<INPUT, OUTPUT, CONTEXT>;
70
69
  }
@@ -0,0 +1,49 @@
1
+ import {
2
+ UnsupportedFunctionalityError,
3
+ type LanguageModelV4FilePart,
4
+ } from '@ai-sdk/provider';
5
+ import {
6
+ detectMediaType,
7
+ getTopLevelMediaType,
8
+ isFullMediaType,
9
+ } from './detect-media-type';
10
+
11
+ /**
12
+ * Resolves a file part's media type to a full `type/subtype` form required by
13
+ * providers whose API demands the full IANA media type.
14
+ *
15
+ * - If `part.mediaType` is already a full media type (e.g. `image/png`), it is
16
+ * returned as-is.
17
+ * - Otherwise, when inline bytes are available (`part.data.type === 'data'`),
18
+ * the subtype is sniffed from the bytes using the signature table that
19
+ * corresponds to the top-level segment.
20
+ * - When neither applies (e.g. top-level-only with a URL source, or bytes that
21
+ * cannot be detected), an `UnsupportedFunctionalityError` is thrown.
22
+ */
23
+ export function resolveFullMediaType({
24
+ part,
25
+ }: {
26
+ part: LanguageModelV4FilePart;
27
+ }): string {
28
+ if (isFullMediaType(part.mediaType)) {
29
+ return part.mediaType;
30
+ }
31
+
32
+ if (part.data.type === 'data') {
33
+ const detected = detectMediaType({
34
+ data: part.data.data,
35
+ topLevelType: getTopLevelMediaType(part.mediaType),
36
+ });
37
+ if (detected) {
38
+ return detected;
39
+ }
40
+
41
+ throw new UnsupportedFunctionalityError({
42
+ functionality: `file of media type "${part.mediaType}" must specify subtype since it could not be auto-detected`,
43
+ });
44
+ }
45
+
46
+ throw new UnsupportedFunctionalityError({
47
+ functionality: `file of media type "${part.mediaType}" must specify subtype since it is not passed as inline bytes`,
48
+ });
49
+ }
@@ -1,8 +1,7 @@
1
1
  import {
2
2
  NoSuchProviderReferenceError,
3
- SharedV4ProviderReference,
3
+ type SharedV4ProviderReference,
4
4
  } from '@ai-sdk/provider';
5
-
6
5
  /**
7
6
  * Resolves a provider reference to the provider-specific identifier for the
8
7
  * given provider. Throws `NoSuchProviderReferenceError` if the provider is not
package/src/resolve.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { MaybePromiseLike } from './maybe-promise-like';
1
+ import type { MaybePromiseLike } from './maybe-promise-like';
2
2
 
3
3
  /**
4
4
  * A value or a lazy provider of a value, each of which may be synchronous or asynchronous.
@@ -1,8 +1,8 @@
1
1
  import { APICallError, EmptyResponseBodyError } from '@ai-sdk/provider';
2
2
  import { extractResponseHeaders } from './extract-response-headers';
3
- import { parseJSON, ParseResult, safeParseJSON } from './parse-json';
3
+ import { parseJSON, safeParseJSON, type ParseResult } from './parse-json';
4
4
  import { parseJsonEventStream } from './parse-json-event-stream';
5
- import { FlexibleSchema } from './schema';
5
+ import type { FlexibleSchema } from './schema';
6
6
 
7
7
  export type ResponseHandler<RETURN_TYPE> = (options: {
8
8
  url: string;
package/src/schema.ts CHANGED
@@ -1,6 +1,9 @@
1
- import { JSONSchema7, TypeValidationError } from '@ai-sdk/provider';
2
- import { StandardSchemaV1, StandardJSONSchemaV1 } from '@standard-schema/spec';
3
- import * as z3 from 'zod/v3';
1
+ import { TypeValidationError, type JSONSchema7 } from '@ai-sdk/provider';
2
+ import type {
3
+ StandardSchemaV1,
4
+ StandardJSONSchemaV1,
5
+ } from '@standard-schema/spec';
6
+ import type * as z3 from 'zod/v3';
4
7
  import * as z4 from 'zod/v4';
5
8
  import { addAdditionalPropertiesToJsonSchema } from './add-additional-properties-to-json-schema';
6
9
  import { zod3ToJsonSchema } from './to-json-schema/zod3-to-json-schema';
@@ -1,6 +1,6 @@
1
- import { JSONObject } from '@ai-sdk/provider';
1
+ import type { JSONObject } from '@ai-sdk/provider';
2
2
  import { isJSONSerializable } from './is-json-serializable';
3
- import { Resolvable } from './resolve';
3
+ import type { Resolvable } from './resolve';
4
4
 
5
5
  /**
6
6
  * Serializes a model instance for workflow step boundaries.
@@ -1,7 +1,7 @@
1
1
  import {
2
2
  InvalidResponseDataError,
3
- LanguageModelV4StreamPart,
4
- SharedV4ProviderMetadata,
3
+ type LanguageModelV4StreamPart,
4
+ type SharedV4ProviderMetadata,
5
5
  } from '@ai-sdk/provider';
6
6
  import { generateId as defaultGenerateId } from './generate-id';
7
7
  import { isParsableJson } from './parse-json';
@@ -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
  | {
@@ -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[];
@@ -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>,
@@ -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'>;
@@ -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,4 @@
1
- import {
1
+ import type {
2
2
  CustomPart,
3
3
  FilePart,
4
4
  ReasoningFilePart,
@@ -7,8 +7,8 @@ import {
7
7
  ToolCallPart,
8
8
  ToolResultPart,
9
9
  } from './content-part';
10
- import { ProviderOptions } from './provider-options';
11
- import { ToolApprovalRequest } from './tool-approval-request';
10
+ import type { ProviderOptions } from './provider-options';
11
+ import type { ToolApprovalRequest } from './tool-approval-request';
12
12
 
13
13
  /**
14
14
  * An assistant message. It can contain text, tool calls, or a combination of text and tool calls.