@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.
- package/CHANGELOG.md +373 -11
- package/dist/index.d.ts +1460 -553
- package/dist/index.js +1044 -361
- package/dist/index.js.map +1 -1
- package/dist/test/index.d.ts +2 -1
- package/dist/test/index.js +18 -37
- package/dist/test/index.js.map +1 -1
- package/package.json +16 -16
- package/src/add-additional-properties-to-json-schema.ts +1 -1
- package/src/as-array.ts +12 -0
- package/src/cancel-response-body.ts +19 -0
- package/src/convert-image-model-file-to-data-uri.ts +1 -1
- package/src/convert-inline-file-data-to-uint8-array.ts +30 -0
- package/src/create-tool-name-mapping.ts +1 -1
- package/src/detect-media-type.ts +312 -0
- package/src/download-blob.ts +8 -9
- package/src/extract-lines.ts +31 -0
- package/src/fetch-with-validated-redirects.ts +87 -0
- package/src/filter-nullable.ts +11 -0
- package/src/get-error-message.ts +1 -15
- package/src/get-from-api.ts +2 -2
- package/src/has-required-key.ts +6 -0
- package/src/index.ts +47 -12
- package/src/inject-json-instruction.ts +1 -1
- package/src/is-browser-runtime.ts +13 -0
- package/src/is-buffer.ts +9 -0
- package/src/is-json-serializable.ts +29 -0
- package/src/is-provider-reference.ts +21 -0
- package/src/is-same-origin.ts +19 -0
- package/src/is-url-supported.ts +17 -2
- package/src/load-api-key.ts +1 -1
- package/src/load-setting.ts +1 -1
- package/src/map-reasoning-to-provider.ts +108 -0
- package/src/maybe-promise-like.ts +3 -0
- package/src/parse-json-event-stream.ts +3 -3
- package/src/parse-json.ts +3 -3
- package/src/parse-provider-options.ts +1 -1
- package/src/post-to-api.ts +4 -4
- package/src/provider-defined-tool-factory.ts +129 -0
- package/src/provider-executed-tool-factory.ts +69 -0
- package/src/read-response-with-size-limit.ts +4 -0
- package/src/resolve-full-media-type.ts +49 -0
- package/src/resolve-provider-reference.ts +26 -0
- package/src/resolve.ts +16 -1
- package/src/response-handler.ts +3 -3
- package/src/schema.ts +11 -4
- package/src/secure-json-parse.ts +1 -1
- package/src/serialize-model-options.ts +63 -0
- package/src/streaming-tool-call-tracker.ts +241 -0
- package/src/test/convert-response-stream-to-array.ts +1 -1
- package/src/test/is-node-version.ts +22 -1
- package/src/to-json-schema/zod3-to-json-schema/options.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parse-def.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parse-types.ts +22 -22
- package/src/to-json-schema/zod3-to-json-schema/parsers/array.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parsers/bigint.ts +1 -1
- package/src/to-json-schema/zod3-to-json-schema/parsers/branded.ts +2 -2
- package/src/to-json-schema/zod3-to-json-schema/parsers/catch.ts +2 -2
- package/src/to-json-schema/zod3-to-json-schema/parsers/date.ts +4 -4
- package/src/to-json-schema/zod3-to-json-schema/parsers/default.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parsers/effects.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parsers/enum.ts +1 -1
- package/src/to-json-schema/zod3-to-json-schema/parsers/intersection.ts +5 -5
- package/src/to-json-schema/zod3-to-json-schema/parsers/literal.ts +1 -1
- package/src/to-json-schema/zod3-to-json-schema/parsers/map.ts +4 -5
- package/src/to-json-schema/zod3-to-json-schema/parsers/native-enum.ts +1 -1
- package/src/to-json-schema/zod3-to-json-schema/parsers/never.ts +1 -2
- package/src/to-json-schema/zod3-to-json-schema/parsers/nullable.ts +4 -4
- package/src/to-json-schema/zod3-to-json-schema/parsers/number.ts +1 -1
- package/src/to-json-schema/zod3-to-json-schema/parsers/object.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parsers/optional.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parsers/pipeline.ts +10 -8
- package/src/to-json-schema/zod3-to-json-schema/parsers/promise.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parsers/readonly.ts +2 -2
- package/src/to-json-schema/zod3-to-json-schema/parsers/record.ts +9 -10
- package/src/to-json-schema/zod3-to-json-schema/parsers/set.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parsers/string.ts +2 -2
- package/src/to-json-schema/zod3-to-json-schema/parsers/tuple.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parsers/undefined.ts +1 -2
- package/src/to-json-schema/zod3-to-json-schema/parsers/union.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/parsers/unknown.ts +1 -2
- package/src/to-json-schema/zod3-to-json-schema/refs.ts +3 -3
- package/src/to-json-schema/zod3-to-json-schema/select-parser.ts +2 -2
- package/src/to-json-schema/zod3-to-json-schema/zod3-to-json-schema.ts +3 -3
- package/src/types/assistant-model-message.ts +5 -3
- package/src/types/content-part.ts +158 -19
- package/src/types/context.ts +4 -0
- package/src/types/executable-tool.ts +17 -0
- package/src/types/execute-tool.ts +29 -9
- package/src/types/file-data.ts +48 -0
- package/src/types/index.ts +29 -11
- package/src/types/infer-tool-context.ts +41 -0
- package/src/types/infer-tool-input.ts +7 -0
- package/src/types/infer-tool-output.ts +7 -0
- package/src/types/infer-tool-set-context.ts +44 -0
- package/src/types/model-message.ts +4 -4
- package/src/types/never-optional.ts +7 -0
- package/src/types/provider-options.ts +1 -1
- package/src/types/provider-reference.ts +10 -0
- package/src/types/sandbox.ts +217 -0
- package/src/types/system-model-message.ts +1 -1
- package/src/types/tool-approval-request.ts +13 -0
- package/src/types/tool-execute-function.ts +56 -0
- package/src/types/tool-model-message.ts +3 -3
- package/src/types/tool-needs-approval-function.ts +39 -0
- package/src/types/tool-set.ts +22 -0
- package/src/types/tool.ts +278 -225
- package/src/types/user-model-message.ts +2 -2
- package/src/validate-download-url.ts +120 -33
- package/src/validate-types.ts +5 -3
- package/dist/index.d.mts +0 -1455
- package/dist/index.mjs +0 -2754
- package/dist/index.mjs.map +0 -1
- package/dist/test/index.d.mts +0 -17
- package/dist/test/index.mjs +0 -77
- package/dist/test/index.mjs.map +0 -1
- 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 =
|
|
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 {
|
|
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,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(
|
|
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,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,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 {
|
|
7
|
-
|
|
6
|
+
import { parseRecordDef, type JsonSchema7RecordType } from './record';
|
|
8
7
|
export type JsonSchema7MapType = {
|
|
9
8
|
type: 'array';
|
|
10
9
|
maxItems: 125;
|
|
@@ -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,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
|
|
17
|
+
const inputSchema = parseDef(def.in._def, {
|
|
18
18
|
...refs,
|
|
19
19
|
currentPath: [...refs.currentPath, 'allOf', '0'],
|
|
20
20
|
});
|
|
21
|
-
const
|
|
21
|
+
const outputSchema = parseDef(def.out._def, {
|
|
22
22
|
...refs,
|
|
23
|
-
currentPath: [...refs.currentPath, 'allOf',
|
|
23
|
+
currentPath: [...refs.currentPath, 'allOf', inputSchema ? '1' : '0'],
|
|
24
24
|
});
|
|
25
25
|
|
|
26
26
|
return {
|
|
27
|
-
allOf: [
|
|
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 {
|
|
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,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,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,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
|