@langchain/core 1.1.34 → 1.1.36

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 (71) hide show
  1. package/CHANGELOG.md +20 -0
  2. package/dist/callbacks/dispatch/index.d.ts +1 -0
  3. package/dist/callbacks/dispatch/index.d.ts.map +1 -1
  4. package/dist/callbacks/dispatch/web.d.ts +1 -0
  5. package/dist/callbacks/dispatch/web.d.ts.map +1 -1
  6. package/dist/language_models/base.cjs +1 -1
  7. package/dist/language_models/base.cjs.map +1 -1
  8. package/dist/language_models/base.d.cts +5 -7
  9. package/dist/language_models/base.d.cts.map +1 -1
  10. package/dist/language_models/base.d.ts +5 -7
  11. package/dist/language_models/base.d.ts.map +1 -1
  12. package/dist/language_models/base.js +1 -1
  13. package/dist/language_models/base.js.map +1 -1
  14. package/dist/language_models/chat_models.cjs +14 -3
  15. package/dist/language_models/chat_models.cjs.map +1 -1
  16. package/dist/language_models/chat_models.d.cts +12 -6
  17. package/dist/language_models/chat_models.d.cts.map +1 -1
  18. package/dist/language_models/chat_models.d.ts +12 -7
  19. package/dist/language_models/chat_models.d.ts.map +1 -1
  20. package/dist/language_models/chat_models.js +14 -3
  21. package/dist/language_models/chat_models.js.map +1 -1
  22. package/dist/language_models/llms.d.ts.map +1 -1
  23. package/dist/language_models/structured_output.d.ts.map +1 -1
  24. package/dist/messages/base.cjs +36 -12
  25. package/dist/messages/base.cjs.map +1 -1
  26. package/dist/messages/base.d.cts.map +1 -1
  27. package/dist/messages/base.d.ts.map +1 -1
  28. package/dist/messages/base.js +36 -12
  29. package/dist/messages/base.js.map +1 -1
  30. package/dist/messages/system.cjs +8 -4
  31. package/dist/messages/system.cjs.map +1 -1
  32. package/dist/messages/system.d.cts.map +1 -1
  33. package/dist/messages/system.d.ts.map +1 -1
  34. package/dist/messages/system.js +8 -4
  35. package/dist/messages/system.js.map +1 -1
  36. package/dist/output_parsers/base.d.ts.map +1 -1
  37. package/dist/output_parsers/openai_tools/json_output_tools_parsers.cjs.map +1 -1
  38. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts +3 -5
  39. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.cts.map +1 -1
  40. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts +3 -5
  41. package/dist/output_parsers/openai_tools/json_output_tools_parsers.d.ts.map +1 -1
  42. package/dist/output_parsers/openai_tools/json_output_tools_parsers.js.map +1 -1
  43. package/dist/prompts/structured.d.ts.map +1 -1
  44. package/dist/retrievers/index.d.ts.map +1 -1
  45. package/dist/runnables/branch.d.ts.map +1 -1
  46. package/dist/runnables/history.d.ts.map +1 -1
  47. package/dist/runnables/passthrough.d.ts.map +1 -1
  48. package/dist/runnables/router.d.ts.map +1 -1
  49. package/dist/tools/index.d.ts.map +1 -1
  50. package/dist/tools/types.cjs.map +1 -1
  51. package/dist/tools/types.d.cts +3 -4
  52. package/dist/tools/types.d.cts.map +1 -1
  53. package/dist/tools/types.d.ts +3 -4
  54. package/dist/tools/types.d.ts.map +1 -1
  55. package/dist/tools/types.js.map +1 -1
  56. package/dist/utils/json_schema.cjs.map +1 -1
  57. package/dist/utils/json_schema.d.cts +1 -1
  58. package/dist/utils/json_schema.d.cts.map +1 -1
  59. package/dist/utils/json_schema.d.ts.map +1 -1
  60. package/dist/utils/json_schema.js.map +1 -1
  61. package/dist/utils/types/index.d.cts +2 -2
  62. package/dist/utils/types/index.d.ts +2 -2
  63. package/dist/utils/types/zod.cjs +1 -1
  64. package/dist/utils/types/zod.cjs.map +1 -1
  65. package/dist/utils/types/zod.d.cts +141 -35
  66. package/dist/utils/types/zod.d.cts.map +1 -1
  67. package/dist/utils/types/zod.d.ts +141 -35
  68. package/dist/utils/types/zod.d.ts.map +1 -1
  69. package/dist/utils/types/zod.js +1 -1
  70. package/dist/utils/types/zod.js.map +1 -1
  71. package/package.json +3 -3
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","names":[],"sources":["../../src/tools/index.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AA,EAAS,WAAA,CAAY,MAAA,EAAQ,QAAA,MAC1B,WAAA,GAAc,OAAA,CAAQ,WAAA,GAC3B,MAAA,EAAQ,iBAAA,CAAkB,OAAA,EAAS,KAAA,IAClC,qBAAA,CACD,OAAA,EACA,aAAA,EACA,YAAA,EACA,WAAA,EACA,aAAA,EACA,KAAA;AAAA,iBAGc,IAAA,iBACE,eAAA,wCAEA,yBAAA,CAA0B,OAAA,kBAC3B,wBAAA,CAAyB,OAAA,iBAC1B,cAAA,uCAAA,CAId,IAAA,GACE,KAAA,EAAO,UAAA,CAAW,0BAAA,CAA2B,OAAA,eAC7C,OAAA,EAAS,WAAA,CAAY,MAAA,EAAQ,QAAA,MAC1B,WAAA,GAAc,OAAA,CAAQ,WAAA,GAC3B,MAAA,EAAQ,iBAAA,CAAkB,OAAA,EAAS,KAAA,IAClC,qBAAA,CACD,OAAA,EACA,aAAA,EACA,YAAA,EACA,WAAA,EACA,aAAA,EACA,KAAA;AAAA,iBAGc,IAAA,iBACE,gBAAA,GAAmB,cAAA,WAAyB,eAAA,GAC1D,gBAAA,iDAEc,yBAAA,CAA0B,OAAA,kBAC3B,wBAAA,CAAyB,OAAA,iBAC1B,cAAA,uCAAA,CAId,IAAA,GACE,KAAA,EAAO,aAAA,EACP,OAAA,EAAS,WAAA,CAAY,MAAA,EAAQ,QAAA,MAC1B,WAAA,GAAc,OAAA,CAAQ,WAAA,GAC3B,MAAA,EAAQ,iBAAA,CAAkB,OAAA,EAAS,KAAA,IAEjC,qBAAA,CACE,OAAA,EACA,aAAA,EACA,YAAA,EACA,WAAA,EACA,aAAA,EACA,KAAA,IAEF,WAAA,CAAY,WAAA;AAAA,KA0LJ,UAAA,GAAa,MAAA;AAAA,KACb,UAAA,GACR,uBAAA,GACA,WAAA,GACA,gBAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.cjs","names":["Runnable","isInteropZodSchema"],"sources":["../../src/tools/types.ts"],"sourcesContent":["import type { z as z3 } from \"zod/v3\";\nimport { CallbackManagerForToolRun } from \"../callbacks/manager.js\";\nimport type {\n BaseLangChainParams,\n ToolDefinition,\n} from \"../language_models/base.js\";\nimport type { RunnableConfig } from \"../runnables/config.js\";\nimport {\n Runnable,\n RunnableToolLike,\n type RunnableInterface,\n} from \"../runnables/base.js\";\nimport {\n type DirectToolOutput,\n type ToolCall,\n type ToolMessage,\n} from \"../messages/tool.js\";\nimport type { MessageContent } from \"../messages/base.js\";\nimport {\n type InferInteropZodInput,\n type InferInteropZodOutput,\n type InteropZodType,\n isInteropZodSchema,\n type InteropZodObject,\n} from \"../utils/types/zod.js\";\n\nimport { JSONSchema } from \"../utils/json_schema.js\";\nimport type { BaseStore } from \"../stores.js\";\n\nexport type ResponseFormat = \"content\" | \"content_and_artifact\" | string;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ToolOutputType = any;\n\nexport type ToolEventType = unknown;\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport type InferToolEventFromFunc<F> = F extends (\n ...args: any[]\n) => AsyncGenerator<infer Y, any, any>\n ? Y\n : ToolEventType;\n\nexport type InferToolOutputFromFunc<F> = F extends (\n ...args: any[]\n) => AsyncGenerator<any, infer R, any>\n ? R\n : F extends (...args: any[]) => Promise<infer R>\n ? R\n : F extends (...args: any[]) => infer R\n ? R\n : ToolOutputType;\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ContentAndArtifact = [MessageContent, any];\n\n/**\n * Conditional type that determines the return type of the {@link StructuredTool.invoke} method.\n * - If the input is a ToolCall, it returns a ToolMessage\n * - If the config is a runnable config and contains a toolCall property, it returns a ToolMessage\n * - Otherwise, it returns the original output type\n */\nexport type ToolReturnType<TInput, TConfig, TOutput> =\n TOutput extends DirectToolOutput\n ? TOutput\n : TConfig extends { toolCall: { id: string } }\n ? ToolMessage\n : TConfig extends { toolCall: { id: undefined } }\n ? TOutput\n : TConfig extends { toolCall: { id?: string } }\n ? TOutput | ToolMessage\n : TInput extends ToolCall\n ? ToolMessage\n : TOutput;\n\n/**\n * Base type that establishes the types of input schemas that can be used for LangChain tool\n * definitions.\n */\nexport type ToolInputSchemaBase = z3.ZodTypeAny | JSONSchema;\n\n/**\n * Parameters for the Tool classes.\n */\nexport interface ToolParams extends BaseLangChainParams {\n /**\n * The tool response format.\n *\n * If \"content\" then the output of the tool is interpreted as the contents of a\n * ToolMessage. If \"content_and_artifact\" then the output is expected to be a\n * two-tuple corresponding to the (content, artifact) of a ToolMessage.\n *\n * @default \"content\"\n */\n responseFormat?: ResponseFormat;\n /**\n * Default config object for the tool runnable.\n */\n defaultConfig?: ToolRunnableConfig;\n /**\n * Whether to show full details in the thrown parsing errors.\n *\n * @default false\n */\n verboseParsingErrors?: boolean;\n /**\n * Metadata for the tool.\n */\n metadata?: Record<string, unknown>;\n /**\n * Optional provider-specific extra fields for the tool.\n *\n * This is used to pass provider-specific configuration that doesn't fit into\n * standard tool fields.\n */\n extras?: Record<string, unknown>;\n}\n\nexport type ToolRunnableConfig<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ConfigurableFieldType extends Record<string, any> = Record<string, any>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ContextSchema = any,\n> = RunnableConfig<ConfigurableFieldType> & {\n toolCall?: ToolCall;\n context?: ContextSchema;\n};\n\n/**\n * Schema for defining tools.\n *\n * @version 0.2.19\n */\nexport interface StructuredToolParams extends Pick<\n StructuredToolInterface,\n \"name\" | \"schema\" | \"extras\"\n> {\n /**\n * An optional description of the tool to pass to the model.\n */\n description?: string;\n}\n\n/**\n * Utility type that resolves the output type of a tool input schema.\n *\n * Input & Output types are a concept used with Zod schema, as Zod allows for transforms to occur\n * during parsing. When using JSONSchema, input and output types are the same.\n *\n * The input type for a given schema should match the structure of the arguments that the LLM\n * generates as part of its {@link ToolCall}. The output type will be the type that results from\n * applying any transforms defined in your schema. If there are no transforms, the input and output\n * types will be the same.\n */\nexport type ToolInputSchemaOutputType<T> = T extends InteropZodType\n ? InferInteropZodOutput<T>\n : T extends JSONSchema\n ? unknown\n : never;\n\n/**\n * Utility type that resolves the input type of a tool input schema.\n *\n * Input & Output types are a concept used with Zod schema, as Zod allows for transforms to occur\n * during parsing. When using JSONSchema, input and output types are the same.\n *\n * The input type for a given schema should match the structure of the arguments that the LLM\n * generates as part of its {@link ToolCall}. The output type will be the type that results from\n * applying any transforms defined in your schema. If there are no transforms, the input and output\n * types will be the same.\n */\nexport type ToolInputSchemaInputType<T> = T extends InteropZodType\n ? InferInteropZodInput<T>\n : T extends JSONSchema\n ? unknown\n : never;\n\n/**\n * Defines the type that will be passed into a tool handler function as a result of a tool call.\n *\n * @param SchemaT - The type of the tool input schema. Usually you don't need to specify this.\n * @param SchemaInputT - The TypeScript type representing the structure of the tool arguments generated by the LLM. Useful for type checking tool handler functions when using JSONSchema.\n */\nexport type StructuredToolCallInput<\n SchemaT = ToolInputSchemaBase,\n SchemaInputT = ToolInputSchemaInputType<SchemaT>,\n> =\n | (ToolInputSchemaOutputType<SchemaT> extends string ? string : never)\n | SchemaInputT\n | ToolCall;\n\n/**\n * An input schema type for tools that accept a single string input.\n *\n * This schema defines a tool that takes an optional string parameter named \"input\".\n * It uses Zod's effects to transform the input and strip any extra properties.\n *\n * This is primarily used for creating simple string-based tools where the LLM\n * only needs to provide a single text value as input to the tool.\n */\nexport type StringInputToolSchema = z3.ZodType<\n string | undefined,\n z3.ZodTypeDef,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n any\n>;\n\n/**\n * Defines the type for input to a tool's call method.\n *\n * This type is a convenience alias for StructuredToolCallInput with the input type\n * derived from the schema. It represents the possible inputs that can be passed to a tool,\n * which can be either:\n * - A string (if the tool accepts string input)\n * - A structured input matching the tool's schema\n * - A ToolCall object (typically from an LLM)\n *\n * @param SchemaT - The schema type for the tool input, defaults to StringInputToolSchema\n */\nexport type ToolCallInput<SchemaT = StringInputToolSchema> =\n StructuredToolCallInput<SchemaT, ToolInputSchemaInputType<SchemaT>>;\n\n/**\n * Interface that defines the shape of a LangChain structured tool.\n *\n * A structured tool is a tool that uses a schema to define the structure of the arguments that the\n * LLM generates as part of its {@link ToolCall}.\n *\n * @param SchemaT - The type of the tool input schema. Usually you don't need to specify this.\n * @param SchemaInputT - The TypeScript type representing the structure of the tool arguments generated by the LLM. Useful for type checking tool handler functions when using JSONSchema.\n */\nexport interface StructuredToolInterface<\n SchemaT = ToolInputSchemaBase,\n SchemaInputT = ToolInputSchemaInputType<SchemaT>,\n ToolOutputT = ToolOutputType,\n> extends RunnableInterface<\n StructuredToolCallInput<SchemaT, SchemaInputT>,\n ToolOutputT | ToolMessage\n> {\n lc_namespace: string[];\n\n /**\n * A Zod schema representing the parameters of the tool.\n */\n schema: SchemaT;\n\n /**\n * Invokes the tool with the provided argument and configuration.\n * @param arg The input argument for the tool.\n * @param configArg Optional configuration for the tool call.\n * @returns A Promise that resolves with the tool's output.\n */\n invoke<\n TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>,\n TConfig extends ToolRunnableConfig | undefined,\n >(\n arg: TArg,\n configArg?: TConfig\n ): Promise<ToolReturnType<TArg, TConfig, ToolOutputT>>;\n\n /**\n * @deprecated Use .invoke() instead. Will be removed in 0.3.0.\n *\n * Calls the tool with the provided argument, configuration, and tags. It\n * parses the input according to the schema, handles any errors, and\n * manages callbacks.\n * @param arg The input argument for the tool.\n * @param configArg Optional configuration or callbacks for the tool.\n * @param tags Optional tags for the tool.\n * @returns A Promise that resolves with a string.\n */\n call<\n TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>,\n TConfig extends ToolRunnableConfig | undefined,\n >(\n arg: TArg,\n configArg?: TConfig,\n /** @deprecated */\n tags?: string[]\n ): Promise<ToolReturnType<TArg, TConfig, ToolOutputT>>;\n\n /**\n * The name of the tool.\n */\n name: string;\n\n /**\n * A description of the tool.\n */\n description: string;\n\n /**\n * Whether to return the tool's output directly.\n *\n * Setting this to true means that after the tool is called,\n * an agent should stop looping.\n */\n returnDirect: boolean;\n\n /**\n * Optional provider-specific extra fields for the tool.\n *\n * This is used to pass provider-specific configuration that doesn't fit into\n * standard tool fields.\n */\n extras?: Record<string, unknown>;\n}\n\n/**\n * A special interface for tools that accept a string input, usually defined with the {@link Tool} class.\n *\n * @param SchemaT - The type of the tool input schema. Usually you don't need to specify this.\n * @param SchemaInputT - The TypeScript type representing the structure of the tool arguments generated by the LLM. Useful for type checking tool handler functions when using JSONSchema.\n */\nexport interface ToolInterface<\n SchemaT = StringInputToolSchema,\n SchemaInputT = ToolInputSchemaInputType<SchemaT>,\n ToolOutputT = ToolOutputType,\n> extends StructuredToolInterface<SchemaT, SchemaInputT, ToolOutputT> {\n /**\n * @deprecated Use .invoke() instead. Will be removed in 0.3.0.\n *\n * Calls the tool with the provided argument and callbacks. It handles\n * string inputs specifically.\n * @param arg The input argument for the tool, which can be a string, undefined, or an input of the tool's schema.\n * @param callbacks Optional callbacks for the tool.\n * @returns A Promise that resolves with a string.\n */\n call<\n TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>,\n TConfig extends ToolRunnableConfig | undefined,\n >(\n // TODO: shouldn't this be narrowed based on SchemaT?\n arg: TArg,\n callbacks?: TConfig\n ): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;\n}\n\n/**\n * Base interface for the input parameters of the {@link DynamicTool} and\n * {@link DynamicStructuredTool} classes.\n */\nexport interface BaseDynamicToolInput extends ToolParams {\n name: string;\n description: string;\n /**\n * Whether to return the tool's output directly.\n *\n * Setting this to true means that after the tool is called,\n * an agent should stop looping.\n */\n returnDirect?: boolean;\n}\n\n/**\n * Interface for the input parameters of the DynamicTool class.\n *\n * @param ToolOutputT - The return type of the tool.\n * @param ToolEventT - The type of values yielded by the tool when using an async generator.\n */\nexport interface DynamicToolInput<\n ToolOutputT = ToolOutputType,\n ToolEventT = ToolEventType,\n> extends BaseDynamicToolInput {\n func: (\n input: string,\n runManager?: CallbackManagerForToolRun,\n config?: ToolRunnableConfig\n ) => Promise<ToolOutputT> | AsyncGenerator<ToolEventT, ToolOutputT>;\n}\n\n/**\n * Interface for the input parameters of the DynamicStructuredTool class.\n *\n * @param SchemaT - The type of the tool input schema. Usually you don't need to specify this.\n * @param SchemaOutputT - The TypeScript type representing the result of applying the schema to the tool arguments. Useful for type checking tool handler functions when using JSONSchema.\n * @param ToolOutputT - The return type of the tool.\n * @param ToolEventT - The type of values yielded by the tool when using an async generator.\n */\nexport interface DynamicStructuredToolInput<\n SchemaT = ToolInputSchemaBase,\n SchemaOutputT = ToolInputSchemaOutputType<SchemaT>,\n ToolOutputT = ToolOutputType,\n ToolEventT = ToolEventType,\n> extends BaseDynamicToolInput {\n /**\n * Tool handler function - the function that will be called when the tool is invoked.\n *\n * @param input - The input to the tool.\n * @param runManager - The run manager for the tool.\n * @param config - The configuration for the tool.\n * @returns The result of the tool.\n */\n func: (\n input: SchemaOutputT,\n runManager?: CallbackManagerForToolRun,\n config?: RunnableConfig\n ) => Promise<ToolOutputT> | AsyncGenerator<ToolEventT, ToolOutputT>;\n schema: SchemaT;\n}\n\n/**\n * Confirm whether the inputted tool is an instance of `StructuredToolInterface`.\n *\n * @param {StructuredToolInterface | JSONSchema | undefined} tool The tool to check if it is an instance of `StructuredToolInterface`.\n * @returns {tool is StructuredToolInterface} Whether the inputted tool is an instance of `StructuredToolInterface`.\n */\nexport function isStructuredTool(\n tool?: StructuredToolInterface | ToolDefinition | JSONSchema\n): tool is StructuredToolInterface {\n return (\n tool !== undefined &&\n Array.isArray((tool as StructuredToolInterface).lc_namespace)\n );\n}\n\n/**\n * Confirm whether the inputted tool is an instance of `RunnableToolLike`.\n *\n * @param {unknown | undefined} tool The tool to check if it is an instance of `RunnableToolLike`.\n * @returns {tool is RunnableToolLike} Whether the inputted tool is an instance of `RunnableToolLike`.\n */\nexport function isRunnableToolLike(tool?: unknown): tool is RunnableToolLike {\n return (\n tool !== undefined &&\n Runnable.isRunnable(tool) &&\n \"lc_name\" in tool.constructor &&\n typeof tool.constructor.lc_name === \"function\" &&\n tool.constructor.lc_name() === \"RunnableToolLike\"\n );\n}\n\n/**\n * Confirm whether or not the tool contains the necessary properties to be considered a `StructuredToolParams`.\n *\n * @param {unknown | undefined} tool The object to check if it is a `StructuredToolParams`.\n * @returns {tool is StructuredToolParams} Whether the inputted object is a `StructuredToolParams`.\n */\nexport function isStructuredToolParams(\n tool?: unknown\n): tool is StructuredToolParams {\n return (\n !!tool &&\n typeof tool === \"object\" &&\n \"name\" in tool &&\n \"schema\" in tool &&\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (isInteropZodSchema(tool.schema as Record<string, any>) ||\n (tool.schema != null &&\n typeof tool.schema === \"object\" &&\n \"type\" in tool.schema &&\n typeof tool.schema.type === \"string\" &&\n [\"null\", \"boolean\", \"object\", \"array\", \"number\", \"string\"].includes(\n tool.schema.type\n )))\n );\n}\n\n/**\n * Whether or not the tool is one of StructuredTool, RunnableTool or StructuredToolParams.\n * It returns `is StructuredToolParams` since that is the most minimal interface of the three,\n * while still containing the necessary properties to be passed to a LLM for tool calling.\n *\n * @param {unknown | undefined} tool The tool to check if it is a LangChain tool.\n * @returns {tool is StructuredToolParams} Whether the inputted tool is a LangChain tool.\n */\nexport function isLangChainTool(tool?: unknown): tool is StructuredToolParams {\n return (\n isStructuredToolParams(tool) ||\n isRunnableToolLike(tool) ||\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n isStructuredTool(tool as any)\n );\n}\n\n/**\n * Runtime context automatically injected into tools.\n *\n * When a tool function has a parameter named `tool_runtime` with type hint\n * `ToolRuntime`, the tool execution system will automatically inject an instance\n * containing:\n *\n * - `state`: The current graph state\n * - `toolCallId`: The ID of the current tool call\n * - `config`: `RunnableConfig` for the current execution\n * - `context`: Runtime context\n * - `store`: `BaseStore` instance for persistent storage\n * - `writer`: Stream writer for streaming output\n *\n * No `Annotated` wrapper is needed - just use `runtime: ToolRuntime`\n * as a parameter.\n *\n * @example\n * ```typescript\n * import { tool, type ToolRuntime } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n *\n * const stateSchema = z.object({\n * messages: z.array(z.any()),\n * userId: z.string().optional(),\n * });\n *\n * const greet = tool(\n * async ({ name }, runtime: ToolRuntime<typeof stateSchema>) => {\n * // Access state\n * const messages = runtime.state.messages;\n *\n * // Access tool_call_id\n * console.log(`Tool call ID: ${runtime.toolCallId}`);\n *\n * // Access config\n * console.log(`Run ID: ${runtime.config.runId}`);\n *\n * // Access runtime context\n * const userId = runtime.context?.userId;\n *\n * // Access store\n * await runtime.store?.mset([[\"key\", \"value\"]]);\n *\n * // Stream output\n * runtime.writer?.(\"Processing...\");\n *\n * return `Hello! User ID: ${runtime.state.userId || \"unknown\"} ${name}`;\n * },\n * {\n * name: \"greet\",\n * description: \"Use this to greet the user once you found their info.\",\n * schema: z.object({ name: z.string() }),\n * stateSchema,\n * }\n * );\n *\n * const agent = createAgent({\n * model,\n * tools: [greet],\n * stateSchema,\n * contextSchema,\n * });\n * ```\n *\n * @template StateT - The type of the state schema (inferred from stateSchema)\n * @template ContextT - The type of the context schema (inferred from contextSchema)\n */\nexport type ToolRuntime<\n TState = unknown,\n TContext = unknown,\n> = RunnableConfig & {\n /**\n * The current graph state.\n */\n state: TState extends InteropZodObject\n ? InferInteropZodOutput<TState>\n : TState extends Record<string, unknown>\n ? TState\n : unknown;\n /**\n * The ID of the current tool call.\n */\n toolCallId: string;\n /**\n * The current tool call.\n */\n toolCall?: ToolCall;\n /**\n * RunnableConfig for the current execution.\n */\n config: ToolRunnableConfig;\n /**\n * Runtime context (from langgraph `Runtime`).\n */\n context: TContext extends InteropZodObject\n ? InferInteropZodOutput<TContext>\n : TContext extends Record<string, unknown>\n ? TContext\n : unknown;\n /**\n * BaseStore instance for persistent storage (from langgraph `Runtime`).\n */\n store: BaseStore<string, unknown> | null;\n /**\n * Stream writer for streaming output (from langgraph `Runtime`).\n */\n writer: ((chunk: unknown) => void) | null;\n};\n"],"mappings":";;;;;;;;;AAwZA,SAAgB,iBACd,MACiC;AACjC,QACE,SAAS,KAAA,KACT,MAAM,QAAS,KAAiC,aAAa;;;;;;;;AAUjE,SAAgB,mBAAmB,MAA0C;AAC3E,QACE,SAAS,KAAA,KACTA,aAAAA,SAAS,WAAW,KAAK,IACzB,aAAa,KAAK,eAClB,OAAO,KAAK,YAAY,YAAY,cACpC,KAAK,YAAY,SAAS,KAAK;;;;;;;;AAUnC,SAAgB,uBACd,MAC8B;AAC9B,QACE,CAAC,CAAC,QACF,OAAO,SAAS,YAChB,UAAU,QACV,YAAY,SAEXC,YAAAA,mBAAmB,KAAK,OAA8B,IACpD,KAAK,UAAU,QACd,OAAO,KAAK,WAAW,YACvB,UAAU,KAAK,UACf,OAAO,KAAK,OAAO,SAAS,YAC5B;EAAC;EAAQ;EAAW;EAAU;EAAS;EAAU;EAAS,CAAC,SACzD,KAAK,OAAO,KACb;;;;;;;;;;AAYT,SAAgB,gBAAgB,MAA8C;AAC5E,QACE,uBAAuB,KAAK,IAC5B,mBAAmB,KAAK,IAExB,iBAAiB,KAAY"}
1
+ {"version":3,"file":"types.cjs","names":["Runnable","isInteropZodSchema"],"sources":["../../src/tools/types.ts"],"sourcesContent":["import type { ZodV3Like } from \"../utils/types/zod.js\";\nimport { CallbackManagerForToolRun } from \"../callbacks/manager.js\";\nimport type {\n BaseLangChainParams,\n ToolDefinition,\n} from \"../language_models/base.js\";\nimport type { RunnableConfig } from \"../runnables/config.js\";\nimport {\n Runnable,\n RunnableToolLike,\n type RunnableInterface,\n} from \"../runnables/base.js\";\nimport {\n type DirectToolOutput,\n type ToolCall,\n type ToolMessage,\n} from \"../messages/tool.js\";\nimport type { MessageContent } from \"../messages/base.js\";\nimport {\n type InferInteropZodInput,\n type InferInteropZodOutput,\n type InteropZodType,\n isInteropZodSchema,\n type InteropZodObject,\n} from \"../utils/types/zod.js\";\n\nimport { JSONSchema } from \"../utils/json_schema.js\";\nimport type { BaseStore } from \"../stores.js\";\n\nexport type ResponseFormat = \"content\" | \"content_and_artifact\" | string;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ToolOutputType = any;\n\nexport type ToolEventType = unknown;\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport type InferToolEventFromFunc<F> = F extends (\n ...args: any[]\n) => AsyncGenerator<infer Y, any, any>\n ? Y\n : ToolEventType;\n\nexport type InferToolOutputFromFunc<F> = F extends (\n ...args: any[]\n) => AsyncGenerator<any, infer R, any>\n ? R\n : F extends (...args: any[]) => Promise<infer R>\n ? R\n : F extends (...args: any[]) => infer R\n ? R\n : ToolOutputType;\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ContentAndArtifact = [MessageContent, any];\n\n/**\n * Conditional type that determines the return type of the {@link StructuredTool.invoke} method.\n * - If the input is a ToolCall, it returns a ToolMessage\n * - If the config is a runnable config and contains a toolCall property, it returns a ToolMessage\n * - Otherwise, it returns the original output type\n */\nexport type ToolReturnType<TInput, TConfig, TOutput> =\n TOutput extends DirectToolOutput\n ? TOutput\n : TConfig extends { toolCall: { id: string } }\n ? ToolMessage\n : TConfig extends { toolCall: { id: undefined } }\n ? TOutput\n : TConfig extends { toolCall: { id?: string } }\n ? TOutput | ToolMessage\n : TInput extends ToolCall\n ? ToolMessage\n : TOutput;\n\n/**\n * Base type that establishes the types of input schemas that can be used for LangChain tool\n * definitions.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ToolInputSchemaBase = ZodV3Like<any, any> | JSONSchema;\n\n/**\n * Parameters for the Tool classes.\n */\nexport interface ToolParams extends BaseLangChainParams {\n /**\n * The tool response format.\n *\n * If \"content\" then the output of the tool is interpreted as the contents of a\n * ToolMessage. If \"content_and_artifact\" then the output is expected to be a\n * two-tuple corresponding to the (content, artifact) of a ToolMessage.\n *\n * @default \"content\"\n */\n responseFormat?: ResponseFormat;\n /**\n * Default config object for the tool runnable.\n */\n defaultConfig?: ToolRunnableConfig;\n /**\n * Whether to show full details in the thrown parsing errors.\n *\n * @default false\n */\n verboseParsingErrors?: boolean;\n /**\n * Metadata for the tool.\n */\n metadata?: Record<string, unknown>;\n /**\n * Optional provider-specific extra fields for the tool.\n *\n * This is used to pass provider-specific configuration that doesn't fit into\n * standard tool fields.\n */\n extras?: Record<string, unknown>;\n}\n\nexport type ToolRunnableConfig<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ConfigurableFieldType extends Record<string, any> = Record<string, any>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ContextSchema = any,\n> = RunnableConfig<ConfigurableFieldType> & {\n toolCall?: ToolCall;\n context?: ContextSchema;\n};\n\n/**\n * Schema for defining tools.\n *\n * @version 0.2.19\n */\nexport interface StructuredToolParams extends Pick<\n StructuredToolInterface,\n \"name\" | \"schema\" | \"extras\"\n> {\n /**\n * An optional description of the tool to pass to the model.\n */\n description?: string;\n}\n\n/**\n * Utility type that resolves the output type of a tool input schema.\n *\n * Input & Output types are a concept used with Zod schema, as Zod allows for transforms to occur\n * during parsing. When using JSONSchema, input and output types are the same.\n *\n * The input type for a given schema should match the structure of the arguments that the LLM\n * generates as part of its {@link ToolCall}. The output type will be the type that results from\n * applying any transforms defined in your schema. If there are no transforms, the input and output\n * types will be the same.\n */\nexport type ToolInputSchemaOutputType<T> = T extends InteropZodType\n ? InferInteropZodOutput<T>\n : T extends JSONSchema\n ? unknown\n : never;\n\n/**\n * Utility type that resolves the input type of a tool input schema.\n *\n * Input & Output types are a concept used with Zod schema, as Zod allows for transforms to occur\n * during parsing. When using JSONSchema, input and output types are the same.\n *\n * The input type for a given schema should match the structure of the arguments that the LLM\n * generates as part of its {@link ToolCall}. The output type will be the type that results from\n * applying any transforms defined in your schema. If there are no transforms, the input and output\n * types will be the same.\n */\nexport type ToolInputSchemaInputType<T> = T extends InteropZodType\n ? InferInteropZodInput<T>\n : T extends JSONSchema\n ? unknown\n : never;\n\n/**\n * Defines the type that will be passed into a tool handler function as a result of a tool call.\n *\n * @param SchemaT - The type of the tool input schema. Usually you don't need to specify this.\n * @param SchemaInputT - The TypeScript type representing the structure of the tool arguments generated by the LLM. Useful for type checking tool handler functions when using JSONSchema.\n */\nexport type StructuredToolCallInput<\n SchemaT = ToolInputSchemaBase,\n SchemaInputT = ToolInputSchemaInputType<SchemaT>,\n> =\n | (ToolInputSchemaOutputType<SchemaT> extends string ? string : never)\n | SchemaInputT\n | ToolCall;\n\n/**\n * An input schema type for tools that accept a single string input.\n *\n * This schema defines a tool that takes an optional string parameter named \"input\".\n * It uses Zod's effects to transform the input and strip any extra properties.\n *\n * This is primarily used for creating simple string-based tools where the LLM\n * only needs to provide a single text value as input to the tool.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type StringInputToolSchema = ZodV3Like<string | undefined, any>;\n\n/**\n * Defines the type for input to a tool's call method.\n *\n * This type is a convenience alias for StructuredToolCallInput with the input type\n * derived from the schema. It represents the possible inputs that can be passed to a tool,\n * which can be either:\n * - A string (if the tool accepts string input)\n * - A structured input matching the tool's schema\n * - A ToolCall object (typically from an LLM)\n *\n * @param SchemaT - The schema type for the tool input, defaults to StringInputToolSchema\n */\nexport type ToolCallInput<SchemaT = StringInputToolSchema> =\n StructuredToolCallInput<SchemaT, ToolInputSchemaInputType<SchemaT>>;\n\n/**\n * Interface that defines the shape of a LangChain structured tool.\n *\n * A structured tool is a tool that uses a schema to define the structure of the arguments that the\n * LLM generates as part of its {@link ToolCall}.\n *\n * @param SchemaT - The type of the tool input schema. Usually you don't need to specify this.\n * @param SchemaInputT - The TypeScript type representing the structure of the tool arguments generated by the LLM. Useful for type checking tool handler functions when using JSONSchema.\n */\nexport interface StructuredToolInterface<\n SchemaT = ToolInputSchemaBase,\n SchemaInputT = ToolInputSchemaInputType<SchemaT>,\n ToolOutputT = ToolOutputType,\n> extends RunnableInterface<\n StructuredToolCallInput<SchemaT, SchemaInputT>,\n ToolOutputT | ToolMessage\n> {\n lc_namespace: string[];\n\n /**\n * A Zod schema representing the parameters of the tool.\n */\n schema: SchemaT;\n\n /**\n * Invokes the tool with the provided argument and configuration.\n * @param arg The input argument for the tool.\n * @param configArg Optional configuration for the tool call.\n * @returns A Promise that resolves with the tool's output.\n */\n invoke<\n TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>,\n TConfig extends ToolRunnableConfig | undefined,\n >(\n arg: TArg,\n configArg?: TConfig\n ): Promise<ToolReturnType<TArg, TConfig, ToolOutputT>>;\n\n /**\n * @deprecated Use .invoke() instead. Will be removed in 0.3.0.\n *\n * Calls the tool with the provided argument, configuration, and tags. It\n * parses the input according to the schema, handles any errors, and\n * manages callbacks.\n * @param arg The input argument for the tool.\n * @param configArg Optional configuration or callbacks for the tool.\n * @param tags Optional tags for the tool.\n * @returns A Promise that resolves with a string.\n */\n call<\n TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>,\n TConfig extends ToolRunnableConfig | undefined,\n >(\n arg: TArg,\n configArg?: TConfig,\n /** @deprecated */\n tags?: string[]\n ): Promise<ToolReturnType<TArg, TConfig, ToolOutputT>>;\n\n /**\n * The name of the tool.\n */\n name: string;\n\n /**\n * A description of the tool.\n */\n description: string;\n\n /**\n * Whether to return the tool's output directly.\n *\n * Setting this to true means that after the tool is called,\n * an agent should stop looping.\n */\n returnDirect: boolean;\n\n /**\n * Optional provider-specific extra fields for the tool.\n *\n * This is used to pass provider-specific configuration that doesn't fit into\n * standard tool fields.\n */\n extras?: Record<string, unknown>;\n}\n\n/**\n * A special interface for tools that accept a string input, usually defined with the {@link Tool} class.\n *\n * @param SchemaT - The type of the tool input schema. Usually you don't need to specify this.\n * @param SchemaInputT - The TypeScript type representing the structure of the tool arguments generated by the LLM. Useful for type checking tool handler functions when using JSONSchema.\n */\nexport interface ToolInterface<\n SchemaT = StringInputToolSchema,\n SchemaInputT = ToolInputSchemaInputType<SchemaT>,\n ToolOutputT = ToolOutputType,\n> extends StructuredToolInterface<SchemaT, SchemaInputT, ToolOutputT> {\n /**\n * @deprecated Use .invoke() instead. Will be removed in 0.3.0.\n *\n * Calls the tool with the provided argument and callbacks. It handles\n * string inputs specifically.\n * @param arg The input argument for the tool, which can be a string, undefined, or an input of the tool's schema.\n * @param callbacks Optional callbacks for the tool.\n * @returns A Promise that resolves with a string.\n */\n call<\n TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>,\n TConfig extends ToolRunnableConfig | undefined,\n >(\n // TODO: shouldn't this be narrowed based on SchemaT?\n arg: TArg,\n callbacks?: TConfig\n ): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;\n}\n\n/**\n * Base interface for the input parameters of the {@link DynamicTool} and\n * {@link DynamicStructuredTool} classes.\n */\nexport interface BaseDynamicToolInput extends ToolParams {\n name: string;\n description: string;\n /**\n * Whether to return the tool's output directly.\n *\n * Setting this to true means that after the tool is called,\n * an agent should stop looping.\n */\n returnDirect?: boolean;\n}\n\n/**\n * Interface for the input parameters of the DynamicTool class.\n *\n * @param ToolOutputT - The return type of the tool.\n * @param ToolEventT - The type of values yielded by the tool when using an async generator.\n */\nexport interface DynamicToolInput<\n ToolOutputT = ToolOutputType,\n ToolEventT = ToolEventType,\n> extends BaseDynamicToolInput {\n func: (\n input: string,\n runManager?: CallbackManagerForToolRun,\n config?: ToolRunnableConfig\n ) => Promise<ToolOutputT> | AsyncGenerator<ToolEventT, ToolOutputT>;\n}\n\n/**\n * Interface for the input parameters of the DynamicStructuredTool class.\n *\n * @param SchemaT - The type of the tool input schema. Usually you don't need to specify this.\n * @param SchemaOutputT - The TypeScript type representing the result of applying the schema to the tool arguments. Useful for type checking tool handler functions when using JSONSchema.\n * @param ToolOutputT - The return type of the tool.\n * @param ToolEventT - The type of values yielded by the tool when using an async generator.\n */\nexport interface DynamicStructuredToolInput<\n SchemaT = ToolInputSchemaBase,\n SchemaOutputT = ToolInputSchemaOutputType<SchemaT>,\n ToolOutputT = ToolOutputType,\n ToolEventT = ToolEventType,\n> extends BaseDynamicToolInput {\n /**\n * Tool handler function - the function that will be called when the tool is invoked.\n *\n * @param input - The input to the tool.\n * @param runManager - The run manager for the tool.\n * @param config - The configuration for the tool.\n * @returns The result of the tool.\n */\n func: (\n input: SchemaOutputT,\n runManager?: CallbackManagerForToolRun,\n config?: RunnableConfig\n ) => Promise<ToolOutputT> | AsyncGenerator<ToolEventT, ToolOutputT>;\n schema: SchemaT;\n}\n\n/**\n * Confirm whether the inputted tool is an instance of `StructuredToolInterface`.\n *\n * @param {StructuredToolInterface | JSONSchema | undefined} tool The tool to check if it is an instance of `StructuredToolInterface`.\n * @returns {tool is StructuredToolInterface} Whether the inputted tool is an instance of `StructuredToolInterface`.\n */\nexport function isStructuredTool(\n tool?: StructuredToolInterface | ToolDefinition | JSONSchema\n): tool is StructuredToolInterface {\n return (\n tool !== undefined &&\n Array.isArray((tool as StructuredToolInterface).lc_namespace)\n );\n}\n\n/**\n * Confirm whether the inputted tool is an instance of `RunnableToolLike`.\n *\n * @param {unknown | undefined} tool The tool to check if it is an instance of `RunnableToolLike`.\n * @returns {tool is RunnableToolLike} Whether the inputted tool is an instance of `RunnableToolLike`.\n */\nexport function isRunnableToolLike(tool?: unknown): tool is RunnableToolLike {\n return (\n tool !== undefined &&\n Runnable.isRunnable(tool) &&\n \"lc_name\" in tool.constructor &&\n typeof tool.constructor.lc_name === \"function\" &&\n tool.constructor.lc_name() === \"RunnableToolLike\"\n );\n}\n\n/**\n * Confirm whether or not the tool contains the necessary properties to be considered a `StructuredToolParams`.\n *\n * @param {unknown | undefined} tool The object to check if it is a `StructuredToolParams`.\n * @returns {tool is StructuredToolParams} Whether the inputted object is a `StructuredToolParams`.\n */\nexport function isStructuredToolParams(\n tool?: unknown\n): tool is StructuredToolParams {\n return (\n !!tool &&\n typeof tool === \"object\" &&\n \"name\" in tool &&\n \"schema\" in tool &&\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (isInteropZodSchema(tool.schema as Record<string, any>) ||\n (tool.schema != null &&\n typeof tool.schema === \"object\" &&\n \"type\" in tool.schema &&\n typeof tool.schema.type === \"string\" &&\n [\"null\", \"boolean\", \"object\", \"array\", \"number\", \"string\"].includes(\n tool.schema.type\n )))\n );\n}\n\n/**\n * Whether or not the tool is one of StructuredTool, RunnableTool or StructuredToolParams.\n * It returns `is StructuredToolParams` since that is the most minimal interface of the three,\n * while still containing the necessary properties to be passed to a LLM for tool calling.\n *\n * @param {unknown | undefined} tool The tool to check if it is a LangChain tool.\n * @returns {tool is StructuredToolParams} Whether the inputted tool is a LangChain tool.\n */\nexport function isLangChainTool(tool?: unknown): tool is StructuredToolParams {\n return (\n isStructuredToolParams(tool) ||\n isRunnableToolLike(tool) ||\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n isStructuredTool(tool as any)\n );\n}\n\n/**\n * Runtime context automatically injected into tools.\n *\n * When a tool function has a parameter named `tool_runtime` with type hint\n * `ToolRuntime`, the tool execution system will automatically inject an instance\n * containing:\n *\n * - `state`: The current graph state\n * - `toolCallId`: The ID of the current tool call\n * - `config`: `RunnableConfig` for the current execution\n * - `context`: Runtime context\n * - `store`: `BaseStore` instance for persistent storage\n * - `writer`: Stream writer for streaming output\n *\n * No `Annotated` wrapper is needed - just use `runtime: ToolRuntime`\n * as a parameter.\n *\n * @example\n * ```typescript\n * import { tool, type ToolRuntime } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n *\n * const stateSchema = z.object({\n * messages: z.array(z.any()),\n * userId: z.string().optional(),\n * });\n *\n * const greet = tool(\n * async ({ name }, runtime: ToolRuntime<typeof stateSchema>) => {\n * // Access state\n * const messages = runtime.state.messages;\n *\n * // Access tool_call_id\n * console.log(`Tool call ID: ${runtime.toolCallId}`);\n *\n * // Access config\n * console.log(`Run ID: ${runtime.config.runId}`);\n *\n * // Access runtime context\n * const userId = runtime.context?.userId;\n *\n * // Access store\n * await runtime.store?.mset([[\"key\", \"value\"]]);\n *\n * // Stream output\n * runtime.writer?.(\"Processing...\");\n *\n * return `Hello! User ID: ${runtime.state.userId || \"unknown\"} ${name}`;\n * },\n * {\n * name: \"greet\",\n * description: \"Use this to greet the user once you found their info.\",\n * schema: z.object({ name: z.string() }),\n * stateSchema,\n * }\n * );\n *\n * const agent = createAgent({\n * model,\n * tools: [greet],\n * stateSchema,\n * contextSchema,\n * });\n * ```\n *\n * @template StateT - The type of the state schema (inferred from stateSchema)\n * @template ContextT - The type of the context schema (inferred from contextSchema)\n */\nexport type ToolRuntime<\n TState = unknown,\n TContext = unknown,\n> = RunnableConfig & {\n /**\n * The current graph state.\n */\n state: TState extends InteropZodObject\n ? InferInteropZodOutput<TState>\n : TState extends Record<string, unknown>\n ? TState\n : unknown;\n /**\n * The ID of the current tool call.\n */\n toolCallId: string;\n /**\n * The current tool call.\n */\n toolCall?: ToolCall;\n /**\n * RunnableConfig for the current execution.\n */\n config: ToolRunnableConfig;\n /**\n * Runtime context (from langgraph `Runtime`).\n */\n context: TContext extends InteropZodObject\n ? InferInteropZodOutput<TContext>\n : TContext extends Record<string, unknown>\n ? TContext\n : unknown;\n /**\n * BaseStore instance for persistent storage (from langgraph `Runtime`).\n */\n store: BaseStore<string, unknown> | null;\n /**\n * Stream writer for streaming output (from langgraph `Runtime`).\n */\n writer: ((chunk: unknown) => void) | null;\n};\n"],"mappings":";;;;;;;;;AAqZA,SAAgB,iBACd,MACiC;AACjC,QACE,SAAS,KAAA,KACT,MAAM,QAAS,KAAiC,aAAa;;;;;;;;AAUjE,SAAgB,mBAAmB,MAA0C;AAC3E,QACE,SAAS,KAAA,KACTA,aAAAA,SAAS,WAAW,KAAK,IACzB,aAAa,KAAK,eAClB,OAAO,KAAK,YAAY,YAAY,cACpC,KAAK,YAAY,SAAS,KAAK;;;;;;;;AAUnC,SAAgB,uBACd,MAC8B;AAC9B,QACE,CAAC,CAAC,QACF,OAAO,SAAS,YAChB,UAAU,QACV,YAAY,SAEXC,YAAAA,mBAAmB,KAAK,OAA8B,IACpD,KAAK,UAAU,QACd,OAAO,KAAK,WAAW,YACvB,UAAU,KAAK,UACf,OAAO,KAAK,OAAO,SAAS,YAC5B;EAAC;EAAQ;EAAW;EAAU;EAAS;EAAU;EAAS,CAAC,SACzD,KAAK,OAAO,KACb;;;;;;;;;;AAYT,SAAgB,gBAAgB,MAA8C;AAC5E,QACE,uBAAuB,KAAK,IAC5B,mBAAmB,KAAK,IAExB,iBAAiB,KAAY"}
@@ -1,13 +1,12 @@
1
1
  import { MessageContent } from "../messages/base.cjs";
2
2
  import { DirectToolOutput, ToolCall, ToolMessage } from "../messages/tool.cjs";
3
- import { InferInteropZodInput, InferInteropZodOutput, InteropZodObject, InteropZodType } from "../utils/types/zod.cjs";
3
+ import { InferInteropZodInput, InferInteropZodOutput, InteropZodObject, InteropZodType, ZodV3Like } from "../utils/types/zod.cjs";
4
4
  import { CallbackManagerForToolRun } from "../callbacks/manager.cjs";
5
5
  import { RunnableConfig, RunnableInterface } from "../runnables/types.cjs";
6
6
  import { RunnableToolLike } from "../runnables/base.cjs";
7
7
  import { JsonSchema7Type } from "../utils/zod-to-json-schema/parseTypes.cjs";
8
8
  import { BaseLangChainParams, ToolDefinition } from "../language_models/base.cjs";
9
9
  import { BaseStore } from "../stores.cjs";
10
- import { z } from "zod/v3";
11
10
 
12
11
  //#region src/tools/types.d.ts
13
12
  type ResponseFormat = "content" | "content_and_artifact" | string;
@@ -39,7 +38,7 @@ type ToolReturnType<TInput, TConfig, TOutput> = TOutput extends DirectToolOutput
39
38
  * Base type that establishes the types of input schemas that can be used for LangChain tool
40
39
  * definitions.
41
40
  */
42
- type ToolInputSchemaBase = z.ZodTypeAny | JsonSchema7Type;
41
+ type ToolInputSchemaBase = ZodV3Like<any, any> | JsonSchema7Type;
43
42
  /**
44
43
  * Parameters for the Tool classes.
45
44
  */
@@ -131,7 +130,7 @@ type StructuredToolCallInput<SchemaT = ToolInputSchemaBase, SchemaInputT = ToolI
131
130
  * This is primarily used for creating simple string-based tools where the LLM
132
131
  * only needs to provide a single text value as input to the tool.
133
132
  */
134
- type StringInputToolSchema = z.ZodType<string | undefined, z.ZodTypeDef, any>;
133
+ type StringInputToolSchema = ZodV3Like<string | undefined, any>;
135
134
  /**
136
135
  * Interface that defines the shape of a LangChain structured tool.
137
136
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.cts","names":[],"sources":["../../src/tools/types.ts"],"mappings":";;;;;;;;;;;;KA6BY,cAAA;AAAA,KAGA,cAAA;AAAA,KAEA,aAAA;AAAA,KAGA,sBAAA,MAA4B,CAAA,cACnC,IAAA,YACA,cAAA,uBACD,CAAA,GACA,aAAA;AAAA,KAEQ,uBAAA,MAA6B,CAAA,cACpC,IAAA,YACA,cAAA,uBACD,CAAA,GACA,CAAA,cAAc,IAAA,YAAgB,OAAA,aAC5B,CAAA,GACA,CAAA,cAAc,IAAA,uBACZ,CAAA,GACA,cAAA;AAAA,KAII,kBAAA,IAAsB,cAAA;;AAvBlC;;;;;KA+BY,cAAA,6BACV,OAAA,SAAgB,gBAAA,GACZ,OAAA,GACA,OAAA;EAAkB,QAAA;IAAY,EAAA;EAAA;AAAA,IAC5B,WAAA,GACA,OAAA;EAAkB,QAAA;IAAY,EAAA;EAAA;AAAA,IAC5B,OAAA,GACA,OAAA;EAAkB,QAAA;IAAY,EAAA;EAAA;AAAA,IAC5B,OAAA,GAAU,WAAA,GACV,MAAA,SAAe,QAAA,GACb,WAAA,GACA,OAAA;;;;;KAMF,mBAAA,GAAsB,CAAA,CAAG,UAAA,GAAa,eAAA;;;;UAKjC,UAAA,SAAmB,mBAAA;EA1CxB;;;;;;;;;EAoDV,cAAA,GAAiB,cAAA;EA5CG;;;EAgDpB,aAAA,GAAgB,kBAAA;EAtDb;;;;;EA4DH,oBAAA;EA1D8C;;;EA8D9C,QAAA,GAAW,MAAA;EA5D6B;;;;;AAM1C;EA6DE,MAAA,GAAS,MAAA;AAAA;AAAA,KAGC,kBAAA,+BAEoB,MAAA,gBAAsB,MAAA,sCAGlD,cAAA,CAAe,qBAAA;EACjB,QAAA,GAAW,QAAA;EACX,OAAA,GAAU,aAAA;AAAA;;;;;;UAQ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;iBASM,gBAAA,CACd,IAAA,GAAO,uBAAA,GAA0B,cAAA,GAAiB,eAAA,GACjD,IAAA,IAAQ,uBAAA;;;;;;;iBAaK,kBAAA,CAAmB,IAAA,aAAiB,IAAA,IAAQ,gBAAA;;;;;;;iBAgB5C,sBAAA,CACd,IAAA,aACC,IAAA,IAAQ,oBAAA;;;;;;;;;iBA0BK,eAAA,CAAgB,IAAA,aAAiB,IAAA,IAAQ,oBAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAxJzD;;;;;;;;;;;;;;;;;;;;;KAqOY,WAAA,yCAGR,cAAA;EApOM;;;EAwOR,KAAA,EAAO,MAAA,SAAe,gBAAA,GAClB,qBAAA,CAAsB,MAAA,IACtB,MAAA,SAAe,MAAA,oBACb,MAAA;EA9OI;;;EAmPV,UAAA;EAjPA;;;EAqPA,QAAA,GAAW,QAAA;EApP8B;;;EAwPzC,MAAA,EAAQ,kBAAA;EA7OO;;;EAiPf,OAAA,EAAS,QAAA,SAAiB,gBAAA,GACtB,qBAAA,CAAsB,QAAA,IACtB,QAAA,SAAiB,MAAA,oBACf,QAAA;EAnPY;;;EAwPlB,KAAA,EAAO,SAAA;EApPL;;;EAwPF,MAAA,IAAU,KAAA;AAAA"}
@@ -1,13 +1,12 @@
1
1
  import { MessageContent } from "../messages/base.js";
2
2
  import { DirectToolOutput, ToolCall, ToolMessage } from "../messages/tool.js";
3
- import { InferInteropZodInput, InferInteropZodOutput, InteropZodObject, InteropZodType } from "../utils/types/zod.js";
3
+ import { InferInteropZodInput, InferInteropZodOutput, InteropZodObject, InteropZodType, ZodV3Like } from "../utils/types/zod.js";
4
4
  import { CallbackManagerForToolRun } from "../callbacks/manager.js";
5
5
  import { RunnableConfig, RunnableInterface } from "../runnables/types.js";
6
6
  import { RunnableToolLike } from "../runnables/base.js";
7
7
  import { JsonSchema7Type } from "../utils/zod-to-json-schema/parseTypes.js";
8
8
  import { BaseLangChainParams, ToolDefinition } from "../language_models/base.js";
9
9
  import { BaseStore } from "../stores.js";
10
- import { z } from "zod/v3";
11
10
 
12
11
  //#region src/tools/types.d.ts
13
12
  type ResponseFormat = "content" | "content_and_artifact" | string;
@@ -39,7 +38,7 @@ type ToolReturnType<TInput, TConfig, TOutput> = TOutput extends DirectToolOutput
39
38
  * Base type that establishes the types of input schemas that can be used for LangChain tool
40
39
  * definitions.
41
40
  */
42
- type ToolInputSchemaBase = z.ZodTypeAny | JsonSchema7Type;
41
+ type ToolInputSchemaBase = ZodV3Like<any, any> | JsonSchema7Type;
43
42
  /**
44
43
  * Parameters for the Tool classes.
45
44
  */
@@ -131,7 +130,7 @@ type StructuredToolCallInput<SchemaT = ToolInputSchemaBase, SchemaInputT = ToolI
131
130
  * This is primarily used for creating simple string-based tools where the LLM
132
131
  * only needs to provide a single text value as input to the tool.
133
132
  */
134
- type StringInputToolSchema = z.ZodType<string | undefined, z.ZodTypeDef, any>;
133
+ type StringInputToolSchema = ZodV3Like<string | undefined, any>;
135
134
  /**
136
135
  * Interface that defines the shape of a LangChain structured tool.
137
136
  *
@@ -1 +1 @@
1
- {"version":3,"file":"types.d.ts","names":[],"sources":["../../src/tools/types.ts"],"mappings":";;;;;;;;;;;;KA6BY,cAAA;AAAA,KAGA,cAAA;AAAA,KAEA,aAAA;AAAA,KAGA,sBAAA,MAA4B,CAAA,cACnC,IAAA,YACA,cAAA,uBACD,CAAA,GACA,aAAA;AAAA,KAEQ,uBAAA,MAA6B,CAAA,cACpC,IAAA,YACA,cAAA,uBACD,CAAA,GACA,CAAA,cAAc,IAAA,YAAgB,OAAA,aAC5B,CAAA,GACA,CAAA,cAAc,IAAA,uBACZ,CAAA,GACA,cAAA;AAAA,KAII,kBAAA,IAAsB,cAAA;;;;AAvBlC;;;KA+BY,cAAA,6BACV,OAAA,SAAgB,gBAAA,GACZ,OAAA,GACA,OAAA;EAAkB,QAAA;IAAY,EAAA;EAAA;AAAA,IAC5B,WAAA,GACA,OAAA;EAAkB,QAAA;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B,qBAAA,CAAsB,QAAA,IACtB,QAAA,SAAiB,MAAA,oBACf,QAAA;EAnPJ;;;EAwPF,KAAA,EAAO,SAAA;EApPO;;;EAwPd,MAAA,IAAU,KAAA;AAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"types.js","names":[],"sources":["../../src/tools/types.ts"],"sourcesContent":["import type { z as z3 } from \"zod/v3\";\nimport { CallbackManagerForToolRun } from \"../callbacks/manager.js\";\nimport type {\n BaseLangChainParams,\n ToolDefinition,\n} from \"../language_models/base.js\";\nimport type { RunnableConfig } from \"../runnables/config.js\";\nimport {\n Runnable,\n RunnableToolLike,\n type RunnableInterface,\n} from \"../runnables/base.js\";\nimport {\n type DirectToolOutput,\n type ToolCall,\n type ToolMessage,\n} from \"../messages/tool.js\";\nimport type { MessageContent } from \"../messages/base.js\";\nimport {\n type InferInteropZodInput,\n type InferInteropZodOutput,\n type InteropZodType,\n isInteropZodSchema,\n type InteropZodObject,\n} from \"../utils/types/zod.js\";\n\nimport { JSONSchema } from \"../utils/json_schema.js\";\nimport type { BaseStore } from \"../stores.js\";\n\nexport type ResponseFormat = \"content\" | \"content_and_artifact\" | string;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ToolOutputType = any;\n\nexport type ToolEventType = unknown;\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport type InferToolEventFromFunc<F> = F extends (\n ...args: any[]\n) => AsyncGenerator<infer Y, any, any>\n ? Y\n : ToolEventType;\n\nexport type InferToolOutputFromFunc<F> = F extends (\n ...args: any[]\n) => AsyncGenerator<any, infer R, any>\n ? R\n : F extends (...args: any[]) => Promise<infer R>\n ? R\n : F extends (...args: any[]) => infer R\n ? R\n : ToolOutputType;\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ContentAndArtifact = [MessageContent, any];\n\n/**\n * Conditional type that determines the return type of the {@link StructuredTool.invoke} method.\n * - If the input is a ToolCall, it returns a ToolMessage\n * - If the config is a runnable config and contains a toolCall property, it returns a ToolMessage\n * - Otherwise, it returns the original output type\n */\nexport type ToolReturnType<TInput, TConfig, TOutput> =\n TOutput extends DirectToolOutput\n ? TOutput\n : TConfig extends { toolCall: { id: string } }\n ? ToolMessage\n : TConfig extends { toolCall: { id: undefined } }\n ? TOutput\n : TConfig extends { toolCall: { id?: string } }\n ? TOutput | ToolMessage\n : TInput extends ToolCall\n ? ToolMessage\n : TOutput;\n\n/**\n * Base type that establishes the types of input schemas that can be used for LangChain tool\n * definitions.\n */\nexport type ToolInputSchemaBase = z3.ZodTypeAny | JSONSchema;\n\n/**\n * Parameters for the Tool classes.\n */\nexport interface ToolParams extends BaseLangChainParams {\n /**\n * The tool response format.\n *\n * If \"content\" then the output of the tool is interpreted as the contents of a\n * ToolMessage. If \"content_and_artifact\" then the output is expected to be a\n * two-tuple corresponding to the (content, artifact) of a ToolMessage.\n *\n * @default \"content\"\n */\n responseFormat?: ResponseFormat;\n /**\n * Default config object for the tool runnable.\n */\n defaultConfig?: ToolRunnableConfig;\n /**\n * Whether to show full details in the thrown parsing errors.\n *\n * @default false\n */\n verboseParsingErrors?: boolean;\n /**\n * Metadata for the tool.\n */\n metadata?: Record<string, unknown>;\n /**\n * Optional provider-specific extra fields for the tool.\n *\n * This is used to pass provider-specific configuration that doesn't fit into\n * standard tool fields.\n */\n extras?: Record<string, unknown>;\n}\n\nexport type ToolRunnableConfig<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ConfigurableFieldType extends Record<string, any> = Record<string, any>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ContextSchema = any,\n> = RunnableConfig<ConfigurableFieldType> & {\n toolCall?: ToolCall;\n context?: ContextSchema;\n};\n\n/**\n * Schema for defining tools.\n *\n * @version 0.2.19\n */\nexport interface StructuredToolParams extends Pick<\n StructuredToolInterface,\n \"name\" | \"schema\" | \"extras\"\n> {\n /**\n * An optional description of the tool to pass to the model.\n */\n description?: string;\n}\n\n/**\n * Utility type that resolves the output type of a tool input schema.\n *\n * Input & Output types are a concept used with Zod schema, as Zod allows for transforms to occur\n * during parsing. When using JSONSchema, input and output types are the same.\n *\n * The input type for a given schema should match the structure of the arguments that the LLM\n * generates as part of its {@link ToolCall}. The output type will be the type that results from\n * applying any transforms defined in your schema. If there are no transforms, the input and output\n * types will be the same.\n */\nexport type ToolInputSchemaOutputType<T> = T extends InteropZodType\n ? InferInteropZodOutput<T>\n : T extends JSONSchema\n ? unknown\n : never;\n\n/**\n * Utility type that resolves the input type of a tool input schema.\n *\n * Input & Output types are a concept used with Zod schema, as Zod allows for transforms to occur\n * during parsing. When using JSONSchema, input and output types are the same.\n *\n * The input type for a given schema should match the structure of the arguments that the LLM\n * generates as part of its {@link ToolCall}. The output type will be the type that results from\n * applying any transforms defined in your schema. If there are no transforms, the input and output\n * types will be the same.\n */\nexport type ToolInputSchemaInputType<T> = T extends InteropZodType\n ? InferInteropZodInput<T>\n : T extends JSONSchema\n ? unknown\n : never;\n\n/**\n * Defines the type that will be passed into a tool handler function as a result of a tool call.\n *\n * @param SchemaT - The type of the tool input schema. Usually you don't need to specify this.\n * @param SchemaInputT - The TypeScript type representing the structure of the tool arguments generated by the LLM. Useful for type checking tool handler functions when using JSONSchema.\n */\nexport type StructuredToolCallInput<\n SchemaT = ToolInputSchemaBase,\n SchemaInputT = ToolInputSchemaInputType<SchemaT>,\n> =\n | (ToolInputSchemaOutputType<SchemaT> extends string ? string : never)\n | SchemaInputT\n | ToolCall;\n\n/**\n * An input schema type for tools that accept a single string input.\n *\n * This schema defines a tool that takes an optional string parameter named \"input\".\n * It uses Zod's effects to transform the input and strip any extra properties.\n *\n * This is primarily used for creating simple string-based tools where the LLM\n * only needs to provide a single text value as input to the tool.\n */\nexport type StringInputToolSchema = z3.ZodType<\n string | undefined,\n z3.ZodTypeDef,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n any\n>;\n\n/**\n * Defines the type for input to a tool's call method.\n *\n * This type is a convenience alias for StructuredToolCallInput with the input type\n * derived from the schema. It represents the possible inputs that can be passed to a tool,\n * which can be either:\n * - A string (if the tool accepts string input)\n * - A structured input matching the tool's schema\n * - A ToolCall object (typically from an LLM)\n *\n * @param SchemaT - The schema type for the tool input, defaults to StringInputToolSchema\n */\nexport type ToolCallInput<SchemaT = StringInputToolSchema> =\n StructuredToolCallInput<SchemaT, ToolInputSchemaInputType<SchemaT>>;\n\n/**\n * Interface that defines the shape of a LangChain structured tool.\n *\n * A structured tool is a tool that uses a schema to define the structure of the arguments that the\n * LLM generates as part of its {@link ToolCall}.\n *\n * @param SchemaT - The type of the tool input schema. Usually you don't need to specify this.\n * @param SchemaInputT - The TypeScript type representing the structure of the tool arguments generated by the LLM. Useful for type checking tool handler functions when using JSONSchema.\n */\nexport interface StructuredToolInterface<\n SchemaT = ToolInputSchemaBase,\n SchemaInputT = ToolInputSchemaInputType<SchemaT>,\n ToolOutputT = ToolOutputType,\n> extends RunnableInterface<\n StructuredToolCallInput<SchemaT, SchemaInputT>,\n ToolOutputT | ToolMessage\n> {\n lc_namespace: string[];\n\n /**\n * A Zod schema representing the parameters of the tool.\n */\n schema: SchemaT;\n\n /**\n * Invokes the tool with the provided argument and configuration.\n * @param arg The input argument for the tool.\n * @param configArg Optional configuration for the tool call.\n * @returns A Promise that resolves with the tool's output.\n */\n invoke<\n TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>,\n TConfig extends ToolRunnableConfig | undefined,\n >(\n arg: TArg,\n configArg?: TConfig\n ): Promise<ToolReturnType<TArg, TConfig, ToolOutputT>>;\n\n /**\n * @deprecated Use .invoke() instead. Will be removed in 0.3.0.\n *\n * Calls the tool with the provided argument, configuration, and tags. It\n * parses the input according to the schema, handles any errors, and\n * manages callbacks.\n * @param arg The input argument for the tool.\n * @param configArg Optional configuration or callbacks for the tool.\n * @param tags Optional tags for the tool.\n * @returns A Promise that resolves with a string.\n */\n call<\n TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>,\n TConfig extends ToolRunnableConfig | undefined,\n >(\n arg: TArg,\n configArg?: TConfig,\n /** @deprecated */\n tags?: string[]\n ): Promise<ToolReturnType<TArg, TConfig, ToolOutputT>>;\n\n /**\n * The name of the tool.\n */\n name: string;\n\n /**\n * A description of the tool.\n */\n description: string;\n\n /**\n * Whether to return the tool's output directly.\n *\n * Setting this to true means that after the tool is called,\n * an agent should stop looping.\n */\n returnDirect: boolean;\n\n /**\n * Optional provider-specific extra fields for the tool.\n *\n * This is used to pass provider-specific configuration that doesn't fit into\n * standard tool fields.\n */\n extras?: Record<string, unknown>;\n}\n\n/**\n * A special interface for tools that accept a string input, usually defined with the {@link Tool} class.\n *\n * @param SchemaT - The type of the tool input schema. Usually you don't need to specify this.\n * @param SchemaInputT - The TypeScript type representing the structure of the tool arguments generated by the LLM. Useful for type checking tool handler functions when using JSONSchema.\n */\nexport interface ToolInterface<\n SchemaT = StringInputToolSchema,\n SchemaInputT = ToolInputSchemaInputType<SchemaT>,\n ToolOutputT = ToolOutputType,\n> extends StructuredToolInterface<SchemaT, SchemaInputT, ToolOutputT> {\n /**\n * @deprecated Use .invoke() instead. Will be removed in 0.3.0.\n *\n * Calls the tool with the provided argument and callbacks. It handles\n * string inputs specifically.\n * @param arg The input argument for the tool, which can be a string, undefined, or an input of the tool's schema.\n * @param callbacks Optional callbacks for the tool.\n * @returns A Promise that resolves with a string.\n */\n call<\n TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>,\n TConfig extends ToolRunnableConfig | undefined,\n >(\n // TODO: shouldn't this be narrowed based on SchemaT?\n arg: TArg,\n callbacks?: TConfig\n ): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;\n}\n\n/**\n * Base interface for the input parameters of the {@link DynamicTool} and\n * {@link DynamicStructuredTool} classes.\n */\nexport interface BaseDynamicToolInput extends ToolParams {\n name: string;\n description: string;\n /**\n * Whether to return the tool's output directly.\n *\n * Setting this to true means that after the tool is called,\n * an agent should stop looping.\n */\n returnDirect?: boolean;\n}\n\n/**\n * Interface for the input parameters of the DynamicTool class.\n *\n * @param ToolOutputT - The return type of the tool.\n * @param ToolEventT - The type of values yielded by the tool when using an async generator.\n */\nexport interface DynamicToolInput<\n ToolOutputT = ToolOutputType,\n ToolEventT = ToolEventType,\n> extends BaseDynamicToolInput {\n func: (\n input: string,\n runManager?: CallbackManagerForToolRun,\n config?: ToolRunnableConfig\n ) => Promise<ToolOutputT> | AsyncGenerator<ToolEventT, ToolOutputT>;\n}\n\n/**\n * Interface for the input parameters of the DynamicStructuredTool class.\n *\n * @param SchemaT - The type of the tool input schema. Usually you don't need to specify this.\n * @param SchemaOutputT - The TypeScript type representing the result of applying the schema to the tool arguments. Useful for type checking tool handler functions when using JSONSchema.\n * @param ToolOutputT - The return type of the tool.\n * @param ToolEventT - The type of values yielded by the tool when using an async generator.\n */\nexport interface DynamicStructuredToolInput<\n SchemaT = ToolInputSchemaBase,\n SchemaOutputT = ToolInputSchemaOutputType<SchemaT>,\n ToolOutputT = ToolOutputType,\n ToolEventT = ToolEventType,\n> extends BaseDynamicToolInput {\n /**\n * Tool handler function - the function that will be called when the tool is invoked.\n *\n * @param input - The input to the tool.\n * @param runManager - The run manager for the tool.\n * @param config - The configuration for the tool.\n * @returns The result of the tool.\n */\n func: (\n input: SchemaOutputT,\n runManager?: CallbackManagerForToolRun,\n config?: RunnableConfig\n ) => Promise<ToolOutputT> | AsyncGenerator<ToolEventT, ToolOutputT>;\n schema: SchemaT;\n}\n\n/**\n * Confirm whether the inputted tool is an instance of `StructuredToolInterface`.\n *\n * @param {StructuredToolInterface | JSONSchema | undefined} tool The tool to check if it is an instance of `StructuredToolInterface`.\n * @returns {tool is StructuredToolInterface} Whether the inputted tool is an instance of `StructuredToolInterface`.\n */\nexport function isStructuredTool(\n tool?: StructuredToolInterface | ToolDefinition | JSONSchema\n): tool is StructuredToolInterface {\n return (\n tool !== undefined &&\n Array.isArray((tool as StructuredToolInterface).lc_namespace)\n );\n}\n\n/**\n * Confirm whether the inputted tool is an instance of `RunnableToolLike`.\n *\n * @param {unknown | undefined} tool The tool to check if it is an instance of `RunnableToolLike`.\n * @returns {tool is RunnableToolLike} Whether the inputted tool is an instance of `RunnableToolLike`.\n */\nexport function isRunnableToolLike(tool?: unknown): tool is RunnableToolLike {\n return (\n tool !== undefined &&\n Runnable.isRunnable(tool) &&\n \"lc_name\" in tool.constructor &&\n typeof tool.constructor.lc_name === \"function\" &&\n tool.constructor.lc_name() === \"RunnableToolLike\"\n );\n}\n\n/**\n * Confirm whether or not the tool contains the necessary properties to be considered a `StructuredToolParams`.\n *\n * @param {unknown | undefined} tool The object to check if it is a `StructuredToolParams`.\n * @returns {tool is StructuredToolParams} Whether the inputted object is a `StructuredToolParams`.\n */\nexport function isStructuredToolParams(\n tool?: unknown\n): tool is StructuredToolParams {\n return (\n !!tool &&\n typeof tool === \"object\" &&\n \"name\" in tool &&\n \"schema\" in tool &&\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (isInteropZodSchema(tool.schema as Record<string, any>) ||\n (tool.schema != null &&\n typeof tool.schema === \"object\" &&\n \"type\" in tool.schema &&\n typeof tool.schema.type === \"string\" &&\n [\"null\", \"boolean\", \"object\", \"array\", \"number\", \"string\"].includes(\n tool.schema.type\n )))\n );\n}\n\n/**\n * Whether or not the tool is one of StructuredTool, RunnableTool or StructuredToolParams.\n * It returns `is StructuredToolParams` since that is the most minimal interface of the three,\n * while still containing the necessary properties to be passed to a LLM for tool calling.\n *\n * @param {unknown | undefined} tool The tool to check if it is a LangChain tool.\n * @returns {tool is StructuredToolParams} Whether the inputted tool is a LangChain tool.\n */\nexport function isLangChainTool(tool?: unknown): tool is StructuredToolParams {\n return (\n isStructuredToolParams(tool) ||\n isRunnableToolLike(tool) ||\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n isStructuredTool(tool as any)\n );\n}\n\n/**\n * Runtime context automatically injected into tools.\n *\n * When a tool function has a parameter named `tool_runtime` with type hint\n * `ToolRuntime`, the tool execution system will automatically inject an instance\n * containing:\n *\n * - `state`: The current graph state\n * - `toolCallId`: The ID of the current tool call\n * - `config`: `RunnableConfig` for the current execution\n * - `context`: Runtime context\n * - `store`: `BaseStore` instance for persistent storage\n * - `writer`: Stream writer for streaming output\n *\n * No `Annotated` wrapper is needed - just use `runtime: ToolRuntime`\n * as a parameter.\n *\n * @example\n * ```typescript\n * import { tool, type ToolRuntime } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n *\n * const stateSchema = z.object({\n * messages: z.array(z.any()),\n * userId: z.string().optional(),\n * });\n *\n * const greet = tool(\n * async ({ name }, runtime: ToolRuntime<typeof stateSchema>) => {\n * // Access state\n * const messages = runtime.state.messages;\n *\n * // Access tool_call_id\n * console.log(`Tool call ID: ${runtime.toolCallId}`);\n *\n * // Access config\n * console.log(`Run ID: ${runtime.config.runId}`);\n *\n * // Access runtime context\n * const userId = runtime.context?.userId;\n *\n * // Access store\n * await runtime.store?.mset([[\"key\", \"value\"]]);\n *\n * // Stream output\n * runtime.writer?.(\"Processing...\");\n *\n * return `Hello! User ID: ${runtime.state.userId || \"unknown\"} ${name}`;\n * },\n * {\n * name: \"greet\",\n * description: \"Use this to greet the user once you found their info.\",\n * schema: z.object({ name: z.string() }),\n * stateSchema,\n * }\n * );\n *\n * const agent = createAgent({\n * model,\n * tools: [greet],\n * stateSchema,\n * contextSchema,\n * });\n * ```\n *\n * @template StateT - The type of the state schema (inferred from stateSchema)\n * @template ContextT - The type of the context schema (inferred from contextSchema)\n */\nexport type ToolRuntime<\n TState = unknown,\n TContext = unknown,\n> = RunnableConfig & {\n /**\n * The current graph state.\n */\n state: TState extends InteropZodObject\n ? InferInteropZodOutput<TState>\n : TState extends Record<string, unknown>\n ? TState\n : unknown;\n /**\n * The ID of the current tool call.\n */\n toolCallId: string;\n /**\n * The current tool call.\n */\n toolCall?: ToolCall;\n /**\n * RunnableConfig for the current execution.\n */\n config: ToolRunnableConfig;\n /**\n * Runtime context (from langgraph `Runtime`).\n */\n context: TContext extends InteropZodObject\n ? InferInteropZodOutput<TContext>\n : TContext extends Record<string, unknown>\n ? TContext\n : unknown;\n /**\n * BaseStore instance for persistent storage (from langgraph `Runtime`).\n */\n store: BaseStore<string, unknown> | null;\n /**\n * Stream writer for streaming output (from langgraph `Runtime`).\n */\n writer: ((chunk: unknown) => void) | null;\n};\n"],"mappings":";;;;;;;;;AAwZA,SAAgB,iBACd,MACiC;AACjC,QACE,SAAS,KAAA,KACT,MAAM,QAAS,KAAiC,aAAa;;;;;;;;AAUjE,SAAgB,mBAAmB,MAA0C;AAC3E,QACE,SAAS,KAAA,KACT,SAAS,WAAW,KAAK,IACzB,aAAa,KAAK,eAClB,OAAO,KAAK,YAAY,YAAY,cACpC,KAAK,YAAY,SAAS,KAAK;;;;;;;;AAUnC,SAAgB,uBACd,MAC8B;AAC9B,QACE,CAAC,CAAC,QACF,OAAO,SAAS,YAChB,UAAU,QACV,YAAY,SAEX,mBAAmB,KAAK,OAA8B,IACpD,KAAK,UAAU,QACd,OAAO,KAAK,WAAW,YACvB,UAAU,KAAK,UACf,OAAO,KAAK,OAAO,SAAS,YAC5B;EAAC;EAAQ;EAAW;EAAU;EAAS;EAAU;EAAS,CAAC,SACzD,KAAK,OAAO,KACb;;;;;;;;;;AAYT,SAAgB,gBAAgB,MAA8C;AAC5E,QACE,uBAAuB,KAAK,IAC5B,mBAAmB,KAAK,IAExB,iBAAiB,KAAY"}
1
+ {"version":3,"file":"types.js","names":[],"sources":["../../src/tools/types.ts"],"sourcesContent":["import type { ZodV3Like } from \"../utils/types/zod.js\";\nimport { CallbackManagerForToolRun } from \"../callbacks/manager.js\";\nimport type {\n BaseLangChainParams,\n ToolDefinition,\n} from \"../language_models/base.js\";\nimport type { RunnableConfig } from \"../runnables/config.js\";\nimport {\n Runnable,\n RunnableToolLike,\n type RunnableInterface,\n} from \"../runnables/base.js\";\nimport {\n type DirectToolOutput,\n type ToolCall,\n type ToolMessage,\n} from \"../messages/tool.js\";\nimport type { MessageContent } from \"../messages/base.js\";\nimport {\n type InferInteropZodInput,\n type InferInteropZodOutput,\n type InteropZodType,\n isInteropZodSchema,\n type InteropZodObject,\n} from \"../utils/types/zod.js\";\n\nimport { JSONSchema } from \"../utils/json_schema.js\";\nimport type { BaseStore } from \"../stores.js\";\n\nexport type ResponseFormat = \"content\" | \"content_and_artifact\" | string;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ToolOutputType = any;\n\nexport type ToolEventType = unknown;\n\n/* eslint-disable @typescript-eslint/no-explicit-any */\nexport type InferToolEventFromFunc<F> = F extends (\n ...args: any[]\n) => AsyncGenerator<infer Y, any, any>\n ? Y\n : ToolEventType;\n\nexport type InferToolOutputFromFunc<F> = F extends (\n ...args: any[]\n) => AsyncGenerator<any, infer R, any>\n ? R\n : F extends (...args: any[]) => Promise<infer R>\n ? R\n : F extends (...args: any[]) => infer R\n ? R\n : ToolOutputType;\n/* eslint-enable @typescript-eslint/no-explicit-any */\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ContentAndArtifact = [MessageContent, any];\n\n/**\n * Conditional type that determines the return type of the {@link StructuredTool.invoke} method.\n * - If the input is a ToolCall, it returns a ToolMessage\n * - If the config is a runnable config and contains a toolCall property, it returns a ToolMessage\n * - Otherwise, it returns the original output type\n */\nexport type ToolReturnType<TInput, TConfig, TOutput> =\n TOutput extends DirectToolOutput\n ? TOutput\n : TConfig extends { toolCall: { id: string } }\n ? ToolMessage\n : TConfig extends { toolCall: { id: undefined } }\n ? TOutput\n : TConfig extends { toolCall: { id?: string } }\n ? TOutput | ToolMessage\n : TInput extends ToolCall\n ? ToolMessage\n : TOutput;\n\n/**\n * Base type that establishes the types of input schemas that can be used for LangChain tool\n * definitions.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type ToolInputSchemaBase = ZodV3Like<any, any> | JSONSchema;\n\n/**\n * Parameters for the Tool classes.\n */\nexport interface ToolParams extends BaseLangChainParams {\n /**\n * The tool response format.\n *\n * If \"content\" then the output of the tool is interpreted as the contents of a\n * ToolMessage. If \"content_and_artifact\" then the output is expected to be a\n * two-tuple corresponding to the (content, artifact) of a ToolMessage.\n *\n * @default \"content\"\n */\n responseFormat?: ResponseFormat;\n /**\n * Default config object for the tool runnable.\n */\n defaultConfig?: ToolRunnableConfig;\n /**\n * Whether to show full details in the thrown parsing errors.\n *\n * @default false\n */\n verboseParsingErrors?: boolean;\n /**\n * Metadata for the tool.\n */\n metadata?: Record<string, unknown>;\n /**\n * Optional provider-specific extra fields for the tool.\n *\n * This is used to pass provider-specific configuration that doesn't fit into\n * standard tool fields.\n */\n extras?: Record<string, unknown>;\n}\n\nexport type ToolRunnableConfig<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ConfigurableFieldType extends Record<string, any> = Record<string, any>,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n ContextSchema = any,\n> = RunnableConfig<ConfigurableFieldType> & {\n toolCall?: ToolCall;\n context?: ContextSchema;\n};\n\n/**\n * Schema for defining tools.\n *\n * @version 0.2.19\n */\nexport interface StructuredToolParams extends Pick<\n StructuredToolInterface,\n \"name\" | \"schema\" | \"extras\"\n> {\n /**\n * An optional description of the tool to pass to the model.\n */\n description?: string;\n}\n\n/**\n * Utility type that resolves the output type of a tool input schema.\n *\n * Input & Output types are a concept used with Zod schema, as Zod allows for transforms to occur\n * during parsing. When using JSONSchema, input and output types are the same.\n *\n * The input type for a given schema should match the structure of the arguments that the LLM\n * generates as part of its {@link ToolCall}. The output type will be the type that results from\n * applying any transforms defined in your schema. If there are no transforms, the input and output\n * types will be the same.\n */\nexport type ToolInputSchemaOutputType<T> = T extends InteropZodType\n ? InferInteropZodOutput<T>\n : T extends JSONSchema\n ? unknown\n : never;\n\n/**\n * Utility type that resolves the input type of a tool input schema.\n *\n * Input & Output types are a concept used with Zod schema, as Zod allows for transforms to occur\n * during parsing. When using JSONSchema, input and output types are the same.\n *\n * The input type for a given schema should match the structure of the arguments that the LLM\n * generates as part of its {@link ToolCall}. The output type will be the type that results from\n * applying any transforms defined in your schema. If there are no transforms, the input and output\n * types will be the same.\n */\nexport type ToolInputSchemaInputType<T> = T extends InteropZodType\n ? InferInteropZodInput<T>\n : T extends JSONSchema\n ? unknown\n : never;\n\n/**\n * Defines the type that will be passed into a tool handler function as a result of a tool call.\n *\n * @param SchemaT - The type of the tool input schema. Usually you don't need to specify this.\n * @param SchemaInputT - The TypeScript type representing the structure of the tool arguments generated by the LLM. Useful for type checking tool handler functions when using JSONSchema.\n */\nexport type StructuredToolCallInput<\n SchemaT = ToolInputSchemaBase,\n SchemaInputT = ToolInputSchemaInputType<SchemaT>,\n> =\n | (ToolInputSchemaOutputType<SchemaT> extends string ? string : never)\n | SchemaInputT\n | ToolCall;\n\n/**\n * An input schema type for tools that accept a single string input.\n *\n * This schema defines a tool that takes an optional string parameter named \"input\".\n * It uses Zod's effects to transform the input and strip any extra properties.\n *\n * This is primarily used for creating simple string-based tools where the LLM\n * only needs to provide a single text value as input to the tool.\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type StringInputToolSchema = ZodV3Like<string | undefined, any>;\n\n/**\n * Defines the type for input to a tool's call method.\n *\n * This type is a convenience alias for StructuredToolCallInput with the input type\n * derived from the schema. It represents the possible inputs that can be passed to a tool,\n * which can be either:\n * - A string (if the tool accepts string input)\n * - A structured input matching the tool's schema\n * - A ToolCall object (typically from an LLM)\n *\n * @param SchemaT - The schema type for the tool input, defaults to StringInputToolSchema\n */\nexport type ToolCallInput<SchemaT = StringInputToolSchema> =\n StructuredToolCallInput<SchemaT, ToolInputSchemaInputType<SchemaT>>;\n\n/**\n * Interface that defines the shape of a LangChain structured tool.\n *\n * A structured tool is a tool that uses a schema to define the structure of the arguments that the\n * LLM generates as part of its {@link ToolCall}.\n *\n * @param SchemaT - The type of the tool input schema. Usually you don't need to specify this.\n * @param SchemaInputT - The TypeScript type representing the structure of the tool arguments generated by the LLM. Useful for type checking tool handler functions when using JSONSchema.\n */\nexport interface StructuredToolInterface<\n SchemaT = ToolInputSchemaBase,\n SchemaInputT = ToolInputSchemaInputType<SchemaT>,\n ToolOutputT = ToolOutputType,\n> extends RunnableInterface<\n StructuredToolCallInput<SchemaT, SchemaInputT>,\n ToolOutputT | ToolMessage\n> {\n lc_namespace: string[];\n\n /**\n * A Zod schema representing the parameters of the tool.\n */\n schema: SchemaT;\n\n /**\n * Invokes the tool with the provided argument and configuration.\n * @param arg The input argument for the tool.\n * @param configArg Optional configuration for the tool call.\n * @returns A Promise that resolves with the tool's output.\n */\n invoke<\n TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>,\n TConfig extends ToolRunnableConfig | undefined,\n >(\n arg: TArg,\n configArg?: TConfig\n ): Promise<ToolReturnType<TArg, TConfig, ToolOutputT>>;\n\n /**\n * @deprecated Use .invoke() instead. Will be removed in 0.3.0.\n *\n * Calls the tool with the provided argument, configuration, and tags. It\n * parses the input according to the schema, handles any errors, and\n * manages callbacks.\n * @param arg The input argument for the tool.\n * @param configArg Optional configuration or callbacks for the tool.\n * @param tags Optional tags for the tool.\n * @returns A Promise that resolves with a string.\n */\n call<\n TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>,\n TConfig extends ToolRunnableConfig | undefined,\n >(\n arg: TArg,\n configArg?: TConfig,\n /** @deprecated */\n tags?: string[]\n ): Promise<ToolReturnType<TArg, TConfig, ToolOutputT>>;\n\n /**\n * The name of the tool.\n */\n name: string;\n\n /**\n * A description of the tool.\n */\n description: string;\n\n /**\n * Whether to return the tool's output directly.\n *\n * Setting this to true means that after the tool is called,\n * an agent should stop looping.\n */\n returnDirect: boolean;\n\n /**\n * Optional provider-specific extra fields for the tool.\n *\n * This is used to pass provider-specific configuration that doesn't fit into\n * standard tool fields.\n */\n extras?: Record<string, unknown>;\n}\n\n/**\n * A special interface for tools that accept a string input, usually defined with the {@link Tool} class.\n *\n * @param SchemaT - The type of the tool input schema. Usually you don't need to specify this.\n * @param SchemaInputT - The TypeScript type representing the structure of the tool arguments generated by the LLM. Useful for type checking tool handler functions when using JSONSchema.\n */\nexport interface ToolInterface<\n SchemaT = StringInputToolSchema,\n SchemaInputT = ToolInputSchemaInputType<SchemaT>,\n ToolOutputT = ToolOutputType,\n> extends StructuredToolInterface<SchemaT, SchemaInputT, ToolOutputT> {\n /**\n * @deprecated Use .invoke() instead. Will be removed in 0.3.0.\n *\n * Calls the tool with the provided argument and callbacks. It handles\n * string inputs specifically.\n * @param arg The input argument for the tool, which can be a string, undefined, or an input of the tool's schema.\n * @param callbacks Optional callbacks for the tool.\n * @returns A Promise that resolves with a string.\n */\n call<\n TArg extends StructuredToolCallInput<SchemaT, SchemaInputT>,\n TConfig extends ToolRunnableConfig | undefined,\n >(\n // TODO: shouldn't this be narrowed based on SchemaT?\n arg: TArg,\n callbacks?: TConfig\n ): Promise<ToolReturnType<NonNullable<TArg>, TConfig, ToolOutputT>>;\n}\n\n/**\n * Base interface for the input parameters of the {@link DynamicTool} and\n * {@link DynamicStructuredTool} classes.\n */\nexport interface BaseDynamicToolInput extends ToolParams {\n name: string;\n description: string;\n /**\n * Whether to return the tool's output directly.\n *\n * Setting this to true means that after the tool is called,\n * an agent should stop looping.\n */\n returnDirect?: boolean;\n}\n\n/**\n * Interface for the input parameters of the DynamicTool class.\n *\n * @param ToolOutputT - The return type of the tool.\n * @param ToolEventT - The type of values yielded by the tool when using an async generator.\n */\nexport interface DynamicToolInput<\n ToolOutputT = ToolOutputType,\n ToolEventT = ToolEventType,\n> extends BaseDynamicToolInput {\n func: (\n input: string,\n runManager?: CallbackManagerForToolRun,\n config?: ToolRunnableConfig\n ) => Promise<ToolOutputT> | AsyncGenerator<ToolEventT, ToolOutputT>;\n}\n\n/**\n * Interface for the input parameters of the DynamicStructuredTool class.\n *\n * @param SchemaT - The type of the tool input schema. Usually you don't need to specify this.\n * @param SchemaOutputT - The TypeScript type representing the result of applying the schema to the tool arguments. Useful for type checking tool handler functions when using JSONSchema.\n * @param ToolOutputT - The return type of the tool.\n * @param ToolEventT - The type of values yielded by the tool when using an async generator.\n */\nexport interface DynamicStructuredToolInput<\n SchemaT = ToolInputSchemaBase,\n SchemaOutputT = ToolInputSchemaOutputType<SchemaT>,\n ToolOutputT = ToolOutputType,\n ToolEventT = ToolEventType,\n> extends BaseDynamicToolInput {\n /**\n * Tool handler function - the function that will be called when the tool is invoked.\n *\n * @param input - The input to the tool.\n * @param runManager - The run manager for the tool.\n * @param config - The configuration for the tool.\n * @returns The result of the tool.\n */\n func: (\n input: SchemaOutputT,\n runManager?: CallbackManagerForToolRun,\n config?: RunnableConfig\n ) => Promise<ToolOutputT> | AsyncGenerator<ToolEventT, ToolOutputT>;\n schema: SchemaT;\n}\n\n/**\n * Confirm whether the inputted tool is an instance of `StructuredToolInterface`.\n *\n * @param {StructuredToolInterface | JSONSchema | undefined} tool The tool to check if it is an instance of `StructuredToolInterface`.\n * @returns {tool is StructuredToolInterface} Whether the inputted tool is an instance of `StructuredToolInterface`.\n */\nexport function isStructuredTool(\n tool?: StructuredToolInterface | ToolDefinition | JSONSchema\n): tool is StructuredToolInterface {\n return (\n tool !== undefined &&\n Array.isArray((tool as StructuredToolInterface).lc_namespace)\n );\n}\n\n/**\n * Confirm whether the inputted tool is an instance of `RunnableToolLike`.\n *\n * @param {unknown | undefined} tool The tool to check if it is an instance of `RunnableToolLike`.\n * @returns {tool is RunnableToolLike} Whether the inputted tool is an instance of `RunnableToolLike`.\n */\nexport function isRunnableToolLike(tool?: unknown): tool is RunnableToolLike {\n return (\n tool !== undefined &&\n Runnable.isRunnable(tool) &&\n \"lc_name\" in tool.constructor &&\n typeof tool.constructor.lc_name === \"function\" &&\n tool.constructor.lc_name() === \"RunnableToolLike\"\n );\n}\n\n/**\n * Confirm whether or not the tool contains the necessary properties to be considered a `StructuredToolParams`.\n *\n * @param {unknown | undefined} tool The object to check if it is a `StructuredToolParams`.\n * @returns {tool is StructuredToolParams} Whether the inputted object is a `StructuredToolParams`.\n */\nexport function isStructuredToolParams(\n tool?: unknown\n): tool is StructuredToolParams {\n return (\n !!tool &&\n typeof tool === \"object\" &&\n \"name\" in tool &&\n \"schema\" in tool &&\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n (isInteropZodSchema(tool.schema as Record<string, any>) ||\n (tool.schema != null &&\n typeof tool.schema === \"object\" &&\n \"type\" in tool.schema &&\n typeof tool.schema.type === \"string\" &&\n [\"null\", \"boolean\", \"object\", \"array\", \"number\", \"string\"].includes(\n tool.schema.type\n )))\n );\n}\n\n/**\n * Whether or not the tool is one of StructuredTool, RunnableTool or StructuredToolParams.\n * It returns `is StructuredToolParams` since that is the most minimal interface of the three,\n * while still containing the necessary properties to be passed to a LLM for tool calling.\n *\n * @param {unknown | undefined} tool The tool to check if it is a LangChain tool.\n * @returns {tool is StructuredToolParams} Whether the inputted tool is a LangChain tool.\n */\nexport function isLangChainTool(tool?: unknown): tool is StructuredToolParams {\n return (\n isStructuredToolParams(tool) ||\n isRunnableToolLike(tool) ||\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n isStructuredTool(tool as any)\n );\n}\n\n/**\n * Runtime context automatically injected into tools.\n *\n * When a tool function has a parameter named `tool_runtime` with type hint\n * `ToolRuntime`, the tool execution system will automatically inject an instance\n * containing:\n *\n * - `state`: The current graph state\n * - `toolCallId`: The ID of the current tool call\n * - `config`: `RunnableConfig` for the current execution\n * - `context`: Runtime context\n * - `store`: `BaseStore` instance for persistent storage\n * - `writer`: Stream writer for streaming output\n *\n * No `Annotated` wrapper is needed - just use `runtime: ToolRuntime`\n * as a parameter.\n *\n * @example\n * ```typescript\n * import { tool, type ToolRuntime } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n *\n * const stateSchema = z.object({\n * messages: z.array(z.any()),\n * userId: z.string().optional(),\n * });\n *\n * const greet = tool(\n * async ({ name }, runtime: ToolRuntime<typeof stateSchema>) => {\n * // Access state\n * const messages = runtime.state.messages;\n *\n * // Access tool_call_id\n * console.log(`Tool call ID: ${runtime.toolCallId}`);\n *\n * // Access config\n * console.log(`Run ID: ${runtime.config.runId}`);\n *\n * // Access runtime context\n * const userId = runtime.context?.userId;\n *\n * // Access store\n * await runtime.store?.mset([[\"key\", \"value\"]]);\n *\n * // Stream output\n * runtime.writer?.(\"Processing...\");\n *\n * return `Hello! User ID: ${runtime.state.userId || \"unknown\"} ${name}`;\n * },\n * {\n * name: \"greet\",\n * description: \"Use this to greet the user once you found their info.\",\n * schema: z.object({ name: z.string() }),\n * stateSchema,\n * }\n * );\n *\n * const agent = createAgent({\n * model,\n * tools: [greet],\n * stateSchema,\n * contextSchema,\n * });\n * ```\n *\n * @template StateT - The type of the state schema (inferred from stateSchema)\n * @template ContextT - The type of the context schema (inferred from contextSchema)\n */\nexport type ToolRuntime<\n TState = unknown,\n TContext = unknown,\n> = RunnableConfig & {\n /**\n * The current graph state.\n */\n state: TState extends InteropZodObject\n ? InferInteropZodOutput<TState>\n : TState extends Record<string, unknown>\n ? TState\n : unknown;\n /**\n * The ID of the current tool call.\n */\n toolCallId: string;\n /**\n * The current tool call.\n */\n toolCall?: ToolCall;\n /**\n * RunnableConfig for the current execution.\n */\n config: ToolRunnableConfig;\n /**\n * Runtime context (from langgraph `Runtime`).\n */\n context: TContext extends InteropZodObject\n ? InferInteropZodOutput<TContext>\n : TContext extends Record<string, unknown>\n ? TContext\n : unknown;\n /**\n * BaseStore instance for persistent storage (from langgraph `Runtime`).\n */\n store: BaseStore<string, unknown> | null;\n /**\n * Stream writer for streaming output (from langgraph `Runtime`).\n */\n writer: ((chunk: unknown) => void) | null;\n};\n"],"mappings":";;;;;;;;;AAqZA,SAAgB,iBACd,MACiC;AACjC,QACE,SAAS,KAAA,KACT,MAAM,QAAS,KAAiC,aAAa;;;;;;;;AAUjE,SAAgB,mBAAmB,MAA0C;AAC3E,QACE,SAAS,KAAA,KACT,SAAS,WAAW,KAAK,IACzB,aAAa,KAAK,eAClB,OAAO,KAAK,YAAY,YAAY,cACpC,KAAK,YAAY,SAAS,KAAK;;;;;;;;AAUnC,SAAgB,uBACd,MAC8B;AAC9B,QACE,CAAC,CAAC,QACF,OAAO,SAAS,YAChB,UAAU,QACV,YAAY,SAEX,mBAAmB,KAAK,OAA8B,IACpD,KAAK,UAAU,QACd,OAAO,KAAK,WAAW,YACvB,UAAU,KAAK,UACf,OAAO,KAAK,OAAO,SAAS,YAC5B;EAAC;EAAQ;EAAW;EAAU;EAAS;EAAU;EAAS,CAAC,SACzD,KAAK,OAAO,KACb;;;;;;;;;;AAYT,SAAgB,gBAAgB,MAA8C;AAC5E,QACE,uBAAuB,KAAK,IAC5B,mBAAmB,KAAK,IAExB,iBAAiB,KAAY"}
@@ -1 +1 @@
1
- {"version":3,"file":"json_schema.cjs","names":["isStandardJsonSchema","isZodSchemaV4","interopZodTransformInputSchema","isZodObjectV4","interopZodObjectStrict","isZodSchemaV3","zodToJsonSchema"],"sources":["../../src/utils/json_schema.ts"],"sourcesContent":["import { toJSONSchema } from \"zod/v4/core\";\nimport { dereference, type Schema } from \"@cfworker/json-schema\";\nimport {\n isZodSchemaV3,\n isZodSchemaV4,\n InteropZodType,\n interopZodObjectStrict,\n isZodObjectV4,\n ZodObjectV4,\n interopZodTransformInputSchema,\n} from \"./types/zod.js\";\nimport {\n type JsonSchema7Type as JSONSchema,\n zodToJsonSchema,\n} from \"./zod-to-json-schema/index.js\";\nimport { StandardJSONSchemaV1 } from \"@standard-schema/spec\";\nimport { isStandardJsonSchema } from \"./standard_schema.js\";\n\nexport { deepCompareStrict, Validator } from \"@cfworker/json-schema\";\n\nexport type ToJSONSchemaParams = NonNullable<\n Parameters<typeof toJSONSchema>[1]\n>;\n\n/**\n * Converts a Standard JSON schema, Zod schema or JSON schema to a JSON schema.\n * @param schema - The schema to convert.\n * @param params - The parameters to pass to the toJSONSchema function.\n * @returns The converted schema.\n */\nexport function toJsonSchema(\n schema: StandardJSONSchemaV1 | InteropZodType | JSONSchema,\n params?: ToJSONSchemaParams\n): JSONSchema {\n if (isStandardJsonSchema(schema) && !isZodSchemaV4(schema)) {\n return schema[\"~standard\"].jsonSchema.input({\n target: \"draft-07\",\n }) as JSONSchema;\n }\n if (isZodSchemaV4(schema)) {\n const inputSchema = interopZodTransformInputSchema(schema, true);\n if (isZodObjectV4(inputSchema)) {\n const strictSchema = interopZodObjectStrict(\n inputSchema,\n true\n ) as ZodObjectV4;\n return toJSONSchema(strictSchema, params);\n } else {\n return toJSONSchema(schema, params);\n }\n }\n if (isZodSchemaV3(schema)) {\n return zodToJsonSchema(schema);\n }\n return schema as JSONSchema;\n}\n\n/**\n * Validates if a JSON schema validates only strings. May return false negatives in some edge cases\n * (like recursive or unresolvable refs).\n *\n * @param schema - The schema to validate.\n * @returns `true` if the schema validates only strings, `false` otherwise.\n */\nexport function validatesOnlyStrings(schema: unknown): boolean {\n // Null, undefined, or empty schema\n if (\n !schema ||\n typeof schema !== \"object\" ||\n Object.keys(schema).length === 0 ||\n Array.isArray(schema)\n ) {\n return false; // Validates anything, not just strings\n }\n\n // Explicit type constraint\n if (\"type\" in schema) {\n if (typeof schema.type === \"string\") {\n return schema.type === \"string\";\n }\n\n if (Array.isArray(schema.type)) {\n // not sure why someone would do `\"type\": [\"string\"]` or especially `\"type\": [\"string\",\n // \"string\", \"string\", ...]` but we're not here to judge\n return schema.type.every((t) => t === \"string\");\n }\n return false; // Invalid or non-string type\n }\n\n // Enum with only string values\n if (\"enum\" in schema) {\n return (\n Array.isArray(schema.enum) &&\n schema.enum.length > 0 &&\n schema.enum.every((val) => typeof val === \"string\")\n );\n }\n\n // String constant\n if (\"const\" in schema) {\n return typeof schema.const === \"string\";\n }\n\n // Schema combinations\n if (\"allOf\" in schema && Array.isArray(schema.allOf)) {\n // If any subschema validates only strings, then the overall schema validates only strings\n return schema.allOf.some((subschema) => validatesOnlyStrings(subschema));\n }\n\n if (\n (\"anyOf\" in schema && Array.isArray(schema.anyOf)) ||\n (\"oneOf\" in schema && Array.isArray(schema.oneOf))\n ) {\n const subschemas = (\n \"anyOf\" in schema ? schema.anyOf : schema.oneOf\n ) as unknown[];\n\n // All subschemas must validate only strings\n return (\n subschemas.length > 0 &&\n subschemas.every((subschema) => validatesOnlyStrings(subschema))\n );\n }\n\n // We're not going to try on this one, it's too complex - we just assume if it has a \"not\" key and hasn't matched one of the above checks, it's not a string schema.\n if (\"not\" in schema) {\n return false; // The not case can validate non-strings\n }\n\n if (\"$ref\" in schema && typeof schema.$ref === \"string\") {\n const ref = schema.$ref as string;\n const resolved = dereference(schema as Schema);\n if (resolved[ref]) {\n return validatesOnlyStrings(resolved[ref]);\n }\n return false;\n }\n\n // ignore recursive refs and other cases where type is omitted for now\n // ignore other cases for now where type is omitted\n\n return false;\n}\n\n// Re-export of the types used throughout langchain for json schema serialization.\n// The plan is to eventually nix zod-to-json-schema altogether in place for\n// zod v4 / a more standardized way of serializing validated inputs, so its re-exported\n// here to remove the dependency on zod-to-json-schema in downstream packages until\n// a determination is made.\n\nexport {\n type JsonSchema7Type,\n type JsonSchema7Type as JSONSchema,\n type JsonSchema7ArrayType,\n type JsonSchema7ObjectType,\n type JsonSchema7StringType,\n type JsonSchema7NumberType,\n type JsonSchema7NullableType,\n} from \"./zod-to-json-schema/index.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,aACd,QACA,QACY;AACZ,KAAIA,8BAAAA,qBAAqB,OAAO,IAAI,CAACC,YAAAA,cAAc,OAAO,CACxD,QAAO,OAAO,aAAa,WAAW,MAAM,EAC1C,QAAQ,YACT,CAAC;AAEJ,KAAIA,YAAAA,cAAc,OAAO,EAAE;EACzB,MAAM,cAAcC,YAAAA,+BAA+B,QAAQ,KAAK;AAChE,MAAIC,YAAAA,cAAc,YAAY,CAK5B,SAAA,GAAA,YAAA,cAJqBC,YAAAA,uBACnB,aACA,KACD,EACiC,OAAO;MAEzC,SAAA,GAAA,YAAA,cAAoB,QAAQ,OAAO;;AAGvC,KAAIC,YAAAA,cAAc,OAAO,CACvB,QAAOC,wBAAAA,gBAAgB,OAAO;AAEhC,QAAO;;;;;;;;;AAUT,SAAgB,qBAAqB,QAA0B;AAE7D,KACE,CAAC,UACD,OAAO,WAAW,YAClB,OAAO,KAAK,OAAO,CAAC,WAAW,KAC/B,MAAM,QAAQ,OAAO,CAErB,QAAO;AAIT,KAAI,UAAU,QAAQ;AACpB,MAAI,OAAO,OAAO,SAAS,SACzB,QAAO,OAAO,SAAS;AAGzB,MAAI,MAAM,QAAQ,OAAO,KAAK,CAG5B,QAAO,OAAO,KAAK,OAAO,MAAM,MAAM,SAAS;AAEjD,SAAO;;AAIT,KAAI,UAAU,OACZ,QACE,MAAM,QAAQ,OAAO,KAAK,IAC1B,OAAO,KAAK,SAAS,KACrB,OAAO,KAAK,OAAO,QAAQ,OAAO,QAAQ,SAAS;AAKvD,KAAI,WAAW,OACb,QAAO,OAAO,OAAO,UAAU;AAIjC,KAAI,WAAW,UAAU,MAAM,QAAQ,OAAO,MAAM,CAElD,QAAO,OAAO,MAAM,MAAM,cAAc,qBAAqB,UAAU,CAAC;AAG1E,KACG,WAAW,UAAU,MAAM,QAAQ,OAAO,MAAM,IAChD,WAAW,UAAU,MAAM,QAAQ,OAAO,MAAM,EACjD;EACA,MAAM,aACJ,WAAW,SAAS,OAAO,QAAQ,OAAO;AAI5C,SACE,WAAW,SAAS,KACpB,WAAW,OAAO,cAAc,qBAAqB,UAAU,CAAC;;AAKpE,KAAI,SAAS,OACX,QAAO;AAGT,KAAI,UAAU,UAAU,OAAO,OAAO,SAAS,UAAU;EACvD,MAAM,MAAM,OAAO;EACnB,MAAM,YAAA,GAAA,sBAAA,aAAuB,OAAiB;AAC9C,MAAI,SAAS,KACX,QAAO,qBAAqB,SAAS,KAAK;AAE5C,SAAO;;AAMT,QAAO"}
1
+ {"version":3,"file":"json_schema.cjs","names":["isStandardJsonSchema","isZodSchemaV4","interopZodTransformInputSchema","isZodObjectV4","interopZodObjectStrict","isZodSchemaV3","zodToJsonSchema"],"sources":["../../src/utils/json_schema.ts"],"sourcesContent":["import { toJSONSchema, type $ZodType } from \"zod/v4/core\";\nimport { dereference, type Schema } from \"@cfworker/json-schema\";\nimport {\n isZodSchemaV3,\n isZodSchemaV4,\n InteropZodType,\n interopZodObjectStrict,\n isZodObjectV4,\n interopZodTransformInputSchema,\n} from \"./types/zod.js\";\nimport {\n type JsonSchema7Type as JSONSchema,\n zodToJsonSchema,\n} from \"./zod-to-json-schema/index.js\";\nimport { StandardJSONSchemaV1 } from \"@standard-schema/spec\";\nimport { isStandardJsonSchema } from \"./standard_schema.js\";\n\nexport { deepCompareStrict, Validator } from \"@cfworker/json-schema\";\n\nexport type ToJSONSchemaParams = NonNullable<\n Parameters<typeof toJSONSchema>[1]\n>;\n\n/**\n * Converts a Standard JSON schema, Zod schema or JSON schema to a JSON schema.\n * @param schema - The schema to convert.\n * @param params - The parameters to pass to the toJSONSchema function.\n * @returns The converted schema.\n */\nexport function toJsonSchema(\n schema: StandardJSONSchemaV1 | InteropZodType | JSONSchema,\n params?: ToJSONSchemaParams\n): JSONSchema {\n if (isStandardJsonSchema(schema) && !isZodSchemaV4(schema)) {\n return schema[\"~standard\"].jsonSchema.input({\n target: \"draft-07\",\n }) as JSONSchema;\n }\n if (isZodSchemaV4(schema)) {\n const inputSchema = interopZodTransformInputSchema(schema, true);\n if (isZodObjectV4(inputSchema)) {\n const strictSchema = interopZodObjectStrict(inputSchema, true);\n return toJSONSchema(strictSchema as unknown as $ZodType, params);\n } else {\n return toJSONSchema(schema as unknown as $ZodType, params);\n }\n }\n if (isZodSchemaV3(schema)) {\n return zodToJsonSchema(schema as never);\n }\n return schema as JSONSchema;\n}\n\n/**\n * Validates if a JSON schema validates only strings. May return false negatives in some edge cases\n * (like recursive or unresolvable refs).\n *\n * @param schema - The schema to validate.\n * @returns `true` if the schema validates only strings, `false` otherwise.\n */\nexport function validatesOnlyStrings(schema: unknown): boolean {\n // Null, undefined, or empty schema\n if (\n !schema ||\n typeof schema !== \"object\" ||\n Object.keys(schema).length === 0 ||\n Array.isArray(schema)\n ) {\n return false; // Validates anything, not just strings\n }\n\n // Explicit type constraint\n if (\"type\" in schema) {\n if (typeof schema.type === \"string\") {\n return schema.type === \"string\";\n }\n\n if (Array.isArray(schema.type)) {\n // not sure why someone would do `\"type\": [\"string\"]` or especially `\"type\": [\"string\",\n // \"string\", \"string\", ...]` but we're not here to judge\n return schema.type.every((t) => t === \"string\");\n }\n return false; // Invalid or non-string type\n }\n\n // Enum with only string values\n if (\"enum\" in schema) {\n return (\n Array.isArray(schema.enum) &&\n schema.enum.length > 0 &&\n schema.enum.every((val) => typeof val === \"string\")\n );\n }\n\n // String constant\n if (\"const\" in schema) {\n return typeof schema.const === \"string\";\n }\n\n // Schema combinations\n if (\"allOf\" in schema && Array.isArray(schema.allOf)) {\n // If any subschema validates only strings, then the overall schema validates only strings\n return schema.allOf.some((subschema) => validatesOnlyStrings(subschema));\n }\n\n if (\n (\"anyOf\" in schema && Array.isArray(schema.anyOf)) ||\n (\"oneOf\" in schema && Array.isArray(schema.oneOf))\n ) {\n const subschemas = (\n \"anyOf\" in schema ? schema.anyOf : schema.oneOf\n ) as unknown[];\n\n // All subschemas must validate only strings\n return (\n subschemas.length > 0 &&\n subschemas.every((subschema) => validatesOnlyStrings(subschema))\n );\n }\n\n // We're not going to try on this one, it's too complex - we just assume if it has a \"not\" key and hasn't matched one of the above checks, it's not a string schema.\n if (\"not\" in schema) {\n return false; // The not case can validate non-strings\n }\n\n if (\"$ref\" in schema && typeof schema.$ref === \"string\") {\n const ref = schema.$ref as string;\n const resolved = dereference(schema as Schema);\n if (resolved[ref]) {\n return validatesOnlyStrings(resolved[ref]);\n }\n return false;\n }\n\n // ignore recursive refs and other cases where type is omitted for now\n // ignore other cases for now where type is omitted\n\n return false;\n}\n\n// Re-export of the types used throughout langchain for json schema serialization.\n// The plan is to eventually nix zod-to-json-schema altogether in place for\n// zod v4 / a more standardized way of serializing validated inputs, so its re-exported\n// here to remove the dependency on zod-to-json-schema in downstream packages until\n// a determination is made.\n\nexport {\n type JsonSchema7Type,\n type JsonSchema7Type as JSONSchema,\n type JsonSchema7ArrayType,\n type JsonSchema7ObjectType,\n type JsonSchema7StringType,\n type JsonSchema7NumberType,\n type JsonSchema7NullableType,\n} from \"./zod-to-json-schema/index.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,aACd,QACA,QACY;AACZ,KAAIA,8BAAAA,qBAAqB,OAAO,IAAI,CAACC,YAAAA,cAAc,OAAO,CACxD,QAAO,OAAO,aAAa,WAAW,MAAM,EAC1C,QAAQ,YACT,CAAC;AAEJ,KAAIA,YAAAA,cAAc,OAAO,EAAE;EACzB,MAAM,cAAcC,YAAAA,+BAA+B,QAAQ,KAAK;AAChE,MAAIC,YAAAA,cAAc,YAAY,CAE5B,SAAA,GAAA,YAAA,cADqBC,YAAAA,uBAAuB,aAAa,KAAK,EACL,OAAO;MAEhE,SAAA,GAAA,YAAA,cAAoB,QAA+B,OAAO;;AAG9D,KAAIC,YAAAA,cAAc,OAAO,CACvB,QAAOC,wBAAAA,gBAAgB,OAAgB;AAEzC,QAAO;;;;;;;;;AAUT,SAAgB,qBAAqB,QAA0B;AAE7D,KACE,CAAC,UACD,OAAO,WAAW,YAClB,OAAO,KAAK,OAAO,CAAC,WAAW,KAC/B,MAAM,QAAQ,OAAO,CAErB,QAAO;AAIT,KAAI,UAAU,QAAQ;AACpB,MAAI,OAAO,OAAO,SAAS,SACzB,QAAO,OAAO,SAAS;AAGzB,MAAI,MAAM,QAAQ,OAAO,KAAK,CAG5B,QAAO,OAAO,KAAK,OAAO,MAAM,MAAM,SAAS;AAEjD,SAAO;;AAIT,KAAI,UAAU,OACZ,QACE,MAAM,QAAQ,OAAO,KAAK,IAC1B,OAAO,KAAK,SAAS,KACrB,OAAO,KAAK,OAAO,QAAQ,OAAO,QAAQ,SAAS;AAKvD,KAAI,WAAW,OACb,QAAO,OAAO,OAAO,UAAU;AAIjC,KAAI,WAAW,UAAU,MAAM,QAAQ,OAAO,MAAM,CAElD,QAAO,OAAO,MAAM,MAAM,cAAc,qBAAqB,UAAU,CAAC;AAG1E,KACG,WAAW,UAAU,MAAM,QAAQ,OAAO,MAAM,IAChD,WAAW,UAAU,MAAM,QAAQ,OAAO,MAAM,EACjD;EACA,MAAM,aACJ,WAAW,SAAS,OAAO,QAAQ,OAAO;AAI5C,SACE,WAAW,SAAS,KACpB,WAAW,OAAO,cAAc,qBAAqB,UAAU,CAAC;;AAKpE,KAAI,SAAS,OACX,QAAO;AAGT,KAAI,UAAU,UAAU,OAAO,OAAO,SAAS,UAAU;EACvD,MAAM,MAAM,OAAO;EACnB,MAAM,YAAA,GAAA,sBAAA,aAAuB,OAAiB;AAC9C,MAAI,SAAS,KACX,QAAO,qBAAqB,SAAS,KAAK;AAE5C,SAAO;;AAMT,QAAO"}
@@ -5,8 +5,8 @@ import { JsonSchema7StringType } from "./zod-to-json-schema/parsers/string.cjs";
5
5
  import { JsonSchema7NullableType } from "./zod-to-json-schema/parsers/nullable.cjs";
6
6
  import { JsonSchema7ObjectType } from "./zod-to-json-schema/parsers/object.cjs";
7
7
  import { JsonSchema7Type } from "./zod-to-json-schema/parseTypes.cjs";
8
- import { toJSONSchema } from "zod/v4/core";
9
8
  import { StandardJSONSchemaV1 } from "@standard-schema/spec";
9
+ import { toJSONSchema } from "zod/v4/core";
10
10
  import { Validator, deepCompareStrict } from "@cfworker/json-schema";
11
11
 
12
12
  //#region src/utils/json_schema.d.ts
@@ -1 +1 @@
1
- {"version":3,"file":"json_schema.d.cts","names":[],"sources":["../../src/utils/json_schema.ts"],"mappings":";;;;;;;;;;;;KAoBY,kBAAA,GAAqB,WAAA,CAC/B,UAAA,QAAkB,YAAA;;;;;;;iBASJ,YAAA,CACd,MAAA,EAAQ,oBAAA,GAAuB,cAAA,GAAiB,eAAA,EAChD,MAAA,GAAS,kBAAA,GACR,eAAA;;;;;;;;iBA+Ba,oBAAA,CAAqB,MAAA"}
1
+ {"version":3,"file":"json_schema.d.cts","names":[],"sources":["../../src/utils/json_schema.ts"],"mappings":";;;;;;;;;;;;KAmBY,kBAAA,GAAqB,WAAA,CAC/B,UAAA,QAAkB,YAAA;;;;;;;iBASJ,YAAA,CACd,MAAA,EAAQ,oBAAA,GAAuB,cAAA,GAAiB,eAAA,EAChD,MAAA,GAAS,kBAAA,GACR,eAAA;;;;;;;;iBA4Ba,oBAAA,CAAqB,MAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"json_schema.d.ts","names":[],"sources":["../../src/utils/json_schema.ts"],"mappings":";;;;;;;;;;;;KAoBY,kBAAA,GAAqB,WAAA,CAC/B,UAAA,QAAkB,YAAA;;;;;;;iBASJ,YAAA,CACd,MAAA,EAAQ,oBAAA,GAAuB,cAAA,GAAiB,eAAA,EAChD,MAAA,GAAS,kBAAA,GACR,eAAA;AAbH;;;;;;;AAAA,iBA4CgB,oBAAA,CAAqB,MAAA"}
1
+ {"version":3,"file":"json_schema.d.ts","names":[],"sources":["../../src/utils/json_schema.ts"],"mappings":";;;;;;;;;;;;KAmBY,kBAAA,GAAqB,WAAA,CAC/B,UAAA,QAAkB,YAAA;;;;;;;iBASJ,YAAA,CACd,MAAA,EAAQ,oBAAA,GAAuB,cAAA,GAAiB,eAAA,EAChD,MAAA,GAAS,kBAAA,GACR,eAAA;AAbH;;;;;;;AAAA,iBAyCgB,oBAAA,CAAqB,MAAA"}
@@ -1 +1 @@
1
- {"version":3,"file":"json_schema.js","names":[],"sources":["../../src/utils/json_schema.ts"],"sourcesContent":["import { toJSONSchema } from \"zod/v4/core\";\nimport { dereference, type Schema } from \"@cfworker/json-schema\";\nimport {\n isZodSchemaV3,\n isZodSchemaV4,\n InteropZodType,\n interopZodObjectStrict,\n isZodObjectV4,\n ZodObjectV4,\n interopZodTransformInputSchema,\n} from \"./types/zod.js\";\nimport {\n type JsonSchema7Type as JSONSchema,\n zodToJsonSchema,\n} from \"./zod-to-json-schema/index.js\";\nimport { StandardJSONSchemaV1 } from \"@standard-schema/spec\";\nimport { isStandardJsonSchema } from \"./standard_schema.js\";\n\nexport { deepCompareStrict, Validator } from \"@cfworker/json-schema\";\n\nexport type ToJSONSchemaParams = NonNullable<\n Parameters<typeof toJSONSchema>[1]\n>;\n\n/**\n * Converts a Standard JSON schema, Zod schema or JSON schema to a JSON schema.\n * @param schema - The schema to convert.\n * @param params - The parameters to pass to the toJSONSchema function.\n * @returns The converted schema.\n */\nexport function toJsonSchema(\n schema: StandardJSONSchemaV1 | InteropZodType | JSONSchema,\n params?: ToJSONSchemaParams\n): JSONSchema {\n if (isStandardJsonSchema(schema) && !isZodSchemaV4(schema)) {\n return schema[\"~standard\"].jsonSchema.input({\n target: \"draft-07\",\n }) as JSONSchema;\n }\n if (isZodSchemaV4(schema)) {\n const inputSchema = interopZodTransformInputSchema(schema, true);\n if (isZodObjectV4(inputSchema)) {\n const strictSchema = interopZodObjectStrict(\n inputSchema,\n true\n ) as ZodObjectV4;\n return toJSONSchema(strictSchema, params);\n } else {\n return toJSONSchema(schema, params);\n }\n }\n if (isZodSchemaV3(schema)) {\n return zodToJsonSchema(schema);\n }\n return schema as JSONSchema;\n}\n\n/**\n * Validates if a JSON schema validates only strings. May return false negatives in some edge cases\n * (like recursive or unresolvable refs).\n *\n * @param schema - The schema to validate.\n * @returns `true` if the schema validates only strings, `false` otherwise.\n */\nexport function validatesOnlyStrings(schema: unknown): boolean {\n // Null, undefined, or empty schema\n if (\n !schema ||\n typeof schema !== \"object\" ||\n Object.keys(schema).length === 0 ||\n Array.isArray(schema)\n ) {\n return false; // Validates anything, not just strings\n }\n\n // Explicit type constraint\n if (\"type\" in schema) {\n if (typeof schema.type === \"string\") {\n return schema.type === \"string\";\n }\n\n if (Array.isArray(schema.type)) {\n // not sure why someone would do `\"type\": [\"string\"]` or especially `\"type\": [\"string\",\n // \"string\", \"string\", ...]` but we're not here to judge\n return schema.type.every((t) => t === \"string\");\n }\n return false; // Invalid or non-string type\n }\n\n // Enum with only string values\n if (\"enum\" in schema) {\n return (\n Array.isArray(schema.enum) &&\n schema.enum.length > 0 &&\n schema.enum.every((val) => typeof val === \"string\")\n );\n }\n\n // String constant\n if (\"const\" in schema) {\n return typeof schema.const === \"string\";\n }\n\n // Schema combinations\n if (\"allOf\" in schema && Array.isArray(schema.allOf)) {\n // If any subschema validates only strings, then the overall schema validates only strings\n return schema.allOf.some((subschema) => validatesOnlyStrings(subschema));\n }\n\n if (\n (\"anyOf\" in schema && Array.isArray(schema.anyOf)) ||\n (\"oneOf\" in schema && Array.isArray(schema.oneOf))\n ) {\n const subschemas = (\n \"anyOf\" in schema ? schema.anyOf : schema.oneOf\n ) as unknown[];\n\n // All subschemas must validate only strings\n return (\n subschemas.length > 0 &&\n subschemas.every((subschema) => validatesOnlyStrings(subschema))\n );\n }\n\n // We're not going to try on this one, it's too complex - we just assume if it has a \"not\" key and hasn't matched one of the above checks, it's not a string schema.\n if (\"not\" in schema) {\n return false; // The not case can validate non-strings\n }\n\n if (\"$ref\" in schema && typeof schema.$ref === \"string\") {\n const ref = schema.$ref as string;\n const resolved = dereference(schema as Schema);\n if (resolved[ref]) {\n return validatesOnlyStrings(resolved[ref]);\n }\n return false;\n }\n\n // ignore recursive refs and other cases where type is omitted for now\n // ignore other cases for now where type is omitted\n\n return false;\n}\n\n// Re-export of the types used throughout langchain for json schema serialization.\n// The plan is to eventually nix zod-to-json-schema altogether in place for\n// zod v4 / a more standardized way of serializing validated inputs, so its re-exported\n// here to remove the dependency on zod-to-json-schema in downstream packages until\n// a determination is made.\n\nexport {\n type JsonSchema7Type,\n type JsonSchema7Type as JSONSchema,\n type JsonSchema7ArrayType,\n type JsonSchema7ObjectType,\n type JsonSchema7StringType,\n type JsonSchema7NumberType,\n type JsonSchema7NullableType,\n} from \"./zod-to-json-schema/index.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA8BA,SAAgB,aACd,QACA,QACY;AACZ,KAAI,qBAAqB,OAAO,IAAI,CAAC,cAAc,OAAO,CACxD,QAAO,OAAO,aAAa,WAAW,MAAM,EAC1C,QAAQ,YACT,CAAC;AAEJ,KAA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B,SAAS,KAAK;AAE5C,SAAO;;AAMT,QAAO"}
1
+ {"version":3,"file":"json_schema.js","names":[],"sources":["../../src/utils/json_schema.ts"],"sourcesContent":["import { toJSONSchema, type $ZodType } from \"zod/v4/core\";\nimport { dereference, type Schema } from \"@cfworker/json-schema\";\nimport {\n isZodSchemaV3,\n isZodSchemaV4,\n InteropZodType,\n interopZodObjectStrict,\n isZodObjectV4,\n interopZodTransformInputSchema,\n} from \"./types/zod.js\";\nimport {\n type JsonSchema7Type as JSONSchema,\n zodToJsonSchema,\n} from \"./zod-to-json-schema/index.js\";\nimport { StandardJSONSchemaV1 } from \"@standard-schema/spec\";\nimport { isStandardJsonSchema } from \"./standard_schema.js\";\n\nexport { deepCompareStrict, Validator } from \"@cfworker/json-schema\";\n\nexport type ToJSONSchemaParams = NonNullable<\n Parameters<typeof toJSONSchema>[1]\n>;\n\n/**\n * Converts a Standard JSON schema, Zod schema or JSON schema to a JSON schema.\n * @param schema - The schema to convert.\n * @param params - The parameters to pass to the toJSONSchema function.\n * @returns The converted schema.\n */\nexport function toJsonSchema(\n schema: StandardJSONSchemaV1 | InteropZodType | JSONSchema,\n params?: ToJSONSchemaParams\n): JSONSchema {\n if (isStandardJsonSchema(schema) && !isZodSchemaV4(schema)) {\n return schema[\"~standard\"].jsonSchema.input({\n target: \"draft-07\",\n }) as JSONSchema;\n }\n if (isZodSchemaV4(schema)) {\n const inputSchema = interopZodTransformInputSchema(schema, true);\n if (isZodObjectV4(inputSchema)) {\n const strictSchema = interopZodObjectStrict(inputSchema, true);\n return toJSONSchema(strictSchema as unknown as $ZodType, params);\n } else {\n return toJSONSchema(schema as unknown as $ZodType, params);\n }\n }\n if (isZodSchemaV3(schema)) {\n return zodToJsonSchema(schema as never);\n }\n return schema as JSONSchema;\n}\n\n/**\n * Validates if a JSON schema validates only strings. May return false negatives in some edge cases\n * (like recursive or unresolvable refs).\n *\n * @param schema - The schema to validate.\n * @returns `true` if the schema validates only strings, `false` otherwise.\n */\nexport function validatesOnlyStrings(schema: unknown): boolean {\n // Null, undefined, or empty schema\n if (\n !schema ||\n typeof schema !== \"object\" ||\n Object.keys(schema).length === 0 ||\n Array.isArray(schema)\n ) {\n return false; // Validates anything, not just strings\n }\n\n // Explicit type constraint\n if (\"type\" in schema) {\n if (typeof schema.type === \"string\") {\n return schema.type === \"string\";\n }\n\n if (Array.isArray(schema.type)) {\n // not sure why someone would do `\"type\": [\"string\"]` or especially `\"type\": [\"string\",\n // \"string\", \"string\", ...]` but we're not here to judge\n return schema.type.every((t) => t === \"string\");\n }\n return false; // Invalid or non-string type\n }\n\n // Enum with only string values\n if (\"enum\" in schema) {\n return (\n Array.isArray(schema.enum) &&\n schema.enum.length > 0 &&\n schema.enum.every((val) => typeof val === \"string\")\n );\n }\n\n // String constant\n if (\"const\" in schema) {\n return typeof schema.const === \"string\";\n }\n\n // Schema combinations\n if (\"allOf\" in schema && Array.isArray(schema.allOf)) {\n // If any subschema validates only strings, then the overall schema validates only strings\n return schema.allOf.some((subschema) => validatesOnlyStrings(subschema));\n }\n\n if (\n (\"anyOf\" in schema && Array.isArray(schema.anyOf)) ||\n (\"oneOf\" in schema && Array.isArray(schema.oneOf))\n ) {\n const subschemas = (\n \"anyOf\" in schema ? schema.anyOf : schema.oneOf\n ) as unknown[];\n\n // All subschemas must validate only strings\n return (\n subschemas.length > 0 &&\n subschemas.every((subschema) => validatesOnlyStrings(subschema))\n );\n }\n\n // We're not going to try on this one, it's too complex - we just assume if it has a \"not\" key and hasn't matched one of the above checks, it's not a string schema.\n if (\"not\" in schema) {\n return false; // The not case can validate non-strings\n }\n\n if (\"$ref\" in schema && typeof schema.$ref === \"string\") {\n const ref = schema.$ref as string;\n const resolved = dereference(schema as Schema);\n if (resolved[ref]) {\n return validatesOnlyStrings(resolved[ref]);\n }\n return false;\n }\n\n // ignore recursive refs and other cases where type is omitted for now\n // ignore other cases for now where type is omitted\n\n return false;\n}\n\n// Re-export of the types used throughout langchain for json schema serialization.\n// The plan is to eventually nix zod-to-json-schema altogether in place for\n// zod v4 / a more standardized way of serializing validated inputs, so its re-exported\n// here to remove the dependency on zod-to-json-schema in downstream packages until\n// a determination is made.\n\nexport {\n type JsonSchema7Type,\n type JsonSchema7Type as JSONSchema,\n type JsonSchema7ArrayType,\n type JsonSchema7ObjectType,\n type JsonSchema7StringType,\n type JsonSchema7NumberType,\n type JsonSchema7NullableType,\n} from \"./zod-to-json-schema/index.js\";\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AA6BA,SAAgB,aACd,QACA,QACY;AACZ,KAAI,qBAAqB,OAAO,IAAI,CAAC,cAAc,OAAO,CACxD,QAAO,OAAO,aAAa,WAAW,MAAM,EAC1C,QAAQ,YACT,CAAC;AAEJ,KAAI,cAAc,OAAO,EAAE;EACzB,MAAM,cAAc,+BAA+B,QAAQ,KAAK;AAChE,MAAI,cAAc,YAAY,CAE5B,QAAO,aADc,uBAAuB,aAAa,KAAK,EACL,OAAO;MAEhE,QAAO,aAAa,QAA+B,OAAO;;AAG9D,KAAI,cAAc,OAAO,CACvB,QAAO,gBAAgB,OAAgB;AAEzC,QAAO;;;;;;;;;AAUT,SAAgB,qBAAqB,QAA0B;AAE7D,KACE,CAAC,UACD,OAAO,WAAW,YAClB,OAAO,KAAK,OAAO,CAAC,WAAW,KAC/B,MAAM,QAAQ,OAAO,CAErB,QAAO;AAIT,KAAI,UAAU,QAAQ;AACpB,MAAI,OAAO,OAAO,SAAS,SACzB,QAAO,OAAO,SAAS;AAGzB,MAAI,MAAM,QAAQ,OAAO,KAAK,CAG5B,QAAO,OAAO,KAAK,OAAO,MAAM,MAAM,SAAS;AAEjD,SAAO;;AAIT,KAAI,UAAU,OACZ,QACE,MAAM,QAAQ,OAAO,KAAK,IAC1B,OAAO,KAAK,SAAS,KACrB,OAAO,KAAK,OAAO,QAAQ,OAAO,QAAQ,SAAS;AAKvD,KAAI,WAAW,OACb,QAAO,OAAO,OAAO,UAAU;AAIjC,KAAI,WAAW,UAAU,MAAM,QAAQ,OAAO,MAAM,CAElD,QAAO,OAAO,MAAM,MAAM,cAAc,qBAAqB,UAAU,CAAC;AAG1E,KACG,WAAW,UAAU,MAAM,QAAQ,OAAO,MAAM,IAChD,WAAW,UAAU,MAAM,QAAQ,OAAO,MAAM,EACjD;EACA,MAAM,aACJ,WAAW,SAAS,OAAO,QAAQ,OAAO;AAI5C,SACE,WAAW,SAAS,KACpB,WAAW,OAAO,cAAc,qBAAqB,UAAU,CAAC;;AAKpE,KAAI,SAAS,OACX,QAAO;AAGT,KAAI,UAAU,UAAU,OAAO,OAAO,SAAS,UAAU;EACvD,MAAM,MAAM,OAAO;EACnB,MAAM,WAAW,YAAY,OAAiB;AAC9C,MAAI,SAAS,KACX,QAAO,qBAAqB,SAAS,KAAK;AAE5C,SAAO;;AAMT,QAAO"}
@@ -1,4 +1,4 @@
1
- import { InferInteropZodInput, InferInteropZodOutput, InteropZodDefault, InteropZodIssue, InteropZodLiteral, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, ZodDefaultV3, ZodDefaultV4, ZodNullableV4, ZodObjectMain, ZodObjectV3, ZodObjectV4, ZodObjectV4Classic, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodNullableV4, isZodObjectV3, isZodObjectV4, isZodOptionalV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 } from "./zod.cjs";
1
+ import { InferInteropZodInput, InferInteropZodOutput, InteropZodDefault, InteropZodError, InteropZodIssue, InteropZodLiteral, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, ZodDefaultV3, ZodDefaultV4, ZodNullableV4, ZodObjectMain, ZodObjectV3, ZodObjectV4, ZodObjectV4Classic, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, ZodV3EffectsLike, ZodV3Like, ZodV3ObjectLike, ZodV3TypeDef, ZodV4ArrayLike, ZodV4Internals, ZodV4Like, ZodV4NullableLike, ZodV4ObjectLike, ZodV4OptionalLike, ZodV4PipeLike, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodNullableV4, isZodObjectV3, isZodObjectV4, isZodOptionalV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 } from "./zod.cjs";
2
2
 
3
3
  //#region src/utils/types/index.d.ts
4
4
  /**
@@ -9,5 +9,5 @@ type InputValues<K extends string = string> = Record<K, any>;
9
9
  type PartialValues<K extends string = string> = Record<K, string | (() => Promise<string>) | (() => string)>;
10
10
  type ChainValues = Record<string, any>;
11
11
  //#endregion
12
- export { ChainValues, InferInteropZodInput, InferInteropZodOutput, InputValues, InteropZodDefault, InteropZodIssue, InteropZodLiteral, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, PartialValues, StringWithAutocomplete, ZodDefaultV3, ZodDefaultV4, ZodNullableV4, ZodObjectMain, ZodObjectV3, ZodObjectV4, ZodObjectV4Classic, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodNullableV4, isZodObjectV3, isZodObjectV4, isZodOptionalV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 };
12
+ export { ChainValues, InferInteropZodInput, InferInteropZodOutput, InputValues, InteropZodDefault, InteropZodError, InteropZodIssue, InteropZodLiteral, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, PartialValues, StringWithAutocomplete, ZodDefaultV3, ZodDefaultV4, ZodNullableV4, ZodObjectMain, ZodObjectV3, ZodObjectV4, ZodObjectV4Classic, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, ZodV3EffectsLike, ZodV3Like, ZodV3ObjectLike, ZodV3TypeDef, ZodV4ArrayLike, ZodV4Internals, ZodV4Like, ZodV4NullableLike, ZodV4ObjectLike, ZodV4OptionalLike, ZodV4PipeLike, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodNullableV4, isZodObjectV3, isZodObjectV4, isZodOptionalV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 };
13
13
  //# sourceMappingURL=index.d.cts.map
@@ -1,4 +1,4 @@
1
- import { InferInteropZodInput, InferInteropZodOutput, InteropZodDefault, InteropZodIssue, InteropZodLiteral, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, ZodDefaultV3, ZodDefaultV4, ZodNullableV4, ZodObjectMain, ZodObjectV3, ZodObjectV4, ZodObjectV4Classic, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodNullableV4, isZodObjectV3, isZodObjectV4, isZodOptionalV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 } from "./zod.js";
1
+ import { InferInteropZodInput, InferInteropZodOutput, InteropZodDefault, InteropZodError, InteropZodIssue, InteropZodLiteral, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, ZodDefaultV3, ZodDefaultV4, ZodNullableV4, ZodObjectMain, ZodObjectV3, ZodObjectV4, ZodObjectV4Classic, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, ZodV3EffectsLike, ZodV3Like, ZodV3ObjectLike, ZodV3TypeDef, ZodV4ArrayLike, ZodV4Internals, ZodV4Like, ZodV4NullableLike, ZodV4ObjectLike, ZodV4OptionalLike, ZodV4PipeLike, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodNullableV4, isZodObjectV3, isZodObjectV4, isZodOptionalV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 } from "./zod.js";
2
2
 
3
3
  //#region src/utils/types/index.d.ts
4
4
  /**
@@ -9,5 +9,5 @@ type InputValues<K extends string = string> = Record<K, any>;
9
9
  type PartialValues<K extends string = string> = Record<K, string | (() => Promise<string>) | (() => string)>;
10
10
  type ChainValues = Record<string, any>;
11
11
  //#endregion
12
- export { ChainValues, InferInteropZodInput, InferInteropZodOutput, InputValues, InteropZodDefault, InteropZodIssue, InteropZodLiteral, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, PartialValues, StringWithAutocomplete, ZodDefaultV3, ZodDefaultV4, ZodNullableV4, ZodObjectMain, ZodObjectV3, ZodObjectV4, ZodObjectV4Classic, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodNullableV4, isZodObjectV3, isZodObjectV4, isZodOptionalV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 };
12
+ export { ChainValues, InferInteropZodInput, InferInteropZodOutput, InputValues, InteropZodDefault, InteropZodError, InteropZodIssue, InteropZodLiteral, InteropZodObject, InteropZodObjectShape, InteropZodOptional, InteropZodType, Mutable, PartialValues, StringWithAutocomplete, ZodDefaultV3, ZodDefaultV4, ZodNullableV4, ZodObjectMain, ZodObjectV3, ZodObjectV4, ZodObjectV4Classic, ZodOptionalV3, ZodOptionalV4, ZodStringV3, ZodStringV4, ZodV3EffectsLike, ZodV3Like, ZodV3ObjectLike, ZodV3TypeDef, ZodV4ArrayLike, ZodV4Internals, ZodV4Like, ZodV4NullableLike, ZodV4ObjectLike, ZodV4OptionalLike, ZodV4PipeLike, extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopParse, interopParseAsync, interopSafeParse, interopSafeParseAsync, interopZodObjectMakeFieldsOptional, interopZodObjectPartial, interopZodObjectPassthrough, interopZodObjectStrict, interopZodTransformInputSchema, isInteropZodError, isInteropZodLiteral, isInteropZodObject, isInteropZodSchema, isShapelessZodSchema, isSimpleStringZodSchema, isZodArrayV4, isZodLiteralV3, isZodLiteralV4, isZodNullableV4, isZodObjectV3, isZodObjectV4, isZodOptionalV4, isZodSchema, isZodSchemaV3, isZodSchemaV4 };
13
13
  //# sourceMappingURL=index.d.ts.map
@@ -294,7 +294,7 @@ function interopZodObjectPartial(schema) {
294
294
  * @throws {Error} If the schema is not a Zod v3 or v4 object.
295
295
  */
296
296
  function interopZodObjectStrict(schema, recursive = false) {
297
- if (isZodSchemaV3(schema)) return schema.strict();
297
+ if (isZodObjectV3(schema)) return schema.strict();
298
298
  if (isZodObjectV4(schema)) {
299
299
  const outputShape = schema._zod.def.shape;
300
300
  if (recursive) for (const [key, keySchema] of Object.entries(schema._zod.def.shape)) {