import { ... } from "@langchain/core/utils/types";Extends a Zod object schema with additional fields, supporting both Zod v3 and v4.
Returns a getter function for the default value of a Zod schema, if one is defined. Supports both Zod v3 and v4 schemas. If the schema has a default value, the returned function will return that value when called. If no default is defined, returns undefined.
Retrieves the shape (fields) of a Zod object schema, supporting both Zod v3 and v4.
Retrieves the description from a schema definition (v3, v4, or plain object), if available.
Parses the input using the provided Zod schema (v3 or v4) and returns the parsed value. Throws an error if parsing fails or if the schema is not a recognized Zod v3 or v4 schema.
Asynchronously parses the input using the provided Zod schema (v3 or v4) and returns the parsed value. Throws an error if parsing fails or if the schema is not a recognized Zod v3 or v4 schema.
Safely parses the input using the provided Zod schema (v3 or v4) and returns a result object indicating success or failure. This function is compatible with both Zod v3 and v4 schemas.
Asynchronously parses the input using the provided Zod schema (v3 or v4) and returns a safe parse result. This function handles both Zod v3 and v4 schemas, returning a result object indicating success or failure.
Creates a modified version of a Zod object schema where fields matching a predicate are made optional. Supports both Zod v3 and v4 schemas and preserves the original schema version.
Returns a partial version of a Zod object schema, making all fields optional. Supports both Zod v3 and v4.
Returns a passthrough version of a Zod object schema, allowing unknown keys.
Supports both Zod v3 and v4 object schemas. If recursive is true, applies passthrough
recursively to all nested object schemas and arrays of object schemas.
Returns a strict version of a Zod object schema, disallowing unknown keys.
Supports both Zod v3 and v4 object schemas. If recursive is true, applies strictness
recursively to all nested object schemas and arrays of object schemas.
Returns the input type of a Zod transform schema, for both v3 and v4.
If the schema is not a transform, returns undefined. If recursive is true,
recursively processes nested object schemas and arrays of object schemas.
Determines if the provided value is an InteropZodLiteral (Zod v3 or v4 literal schema).
Determines if the provided value is an InteropZodObject (Zod v3 or v4 object schema).
Given either a Zod schema, or plain object, determine if the input is a Zod schema.
Determines if the provided Zod schema is "shapeless". A shapeless schema is one that does not define any object shape, such as ZodString, ZodNumber, ZodBoolean, ZodAny, etc. For ZodObject, it must have no shape keys to be considered shapeless. ZodRecord schemas are considered shapeless since they define dynamic key-value mappings without fixed keys.
Determines if the provided Zod schema should be treated as a simple string schema that maps to DynamicTool. This aligns with the type-level constraint of InteropZodType<string | undefined> which only matches basic string schemas. If the provided schema is just z.string(), we can make the determination that the tool is just a generic string tool that doesn't require any input validation.
This function only returns true for basic ZodString schemas, including:
This function returns false for everything else, including:
Backward compatible isZodSchema for Zod 3
Represents a string value with autocompleted, but not required, suggestions.