@langchain/langgraph 1.2.1 → 1.2.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/channels/any_value.cjs +3 -4
- package/dist/channels/any_value.cjs.map +1 -1
- package/dist/channels/any_value.js +1 -2
- package/dist/channels/any_value.js.map +1 -1
- package/dist/channels/base.cjs +2 -3
- package/dist/channels/base.cjs.map +1 -1
- package/dist/channels/base.js +1 -2
- package/dist/channels/base.js.map +1 -1
- package/dist/channels/binop.cjs +4 -5
- package/dist/channels/binop.cjs.map +1 -1
- package/dist/channels/binop.js +1 -2
- package/dist/channels/binop.js.map +1 -1
- package/dist/channels/dynamic_barrier_value.cjs +4 -5
- package/dist/channels/dynamic_barrier_value.cjs.map +1 -1
- package/dist/channels/dynamic_barrier_value.js +1 -2
- package/dist/channels/dynamic_barrier_value.js.map +1 -1
- package/dist/channels/ephemeral_value.cjs +3 -4
- package/dist/channels/ephemeral_value.cjs.map +1 -1
- package/dist/channels/ephemeral_value.js +1 -2
- package/dist/channels/ephemeral_value.js.map +1 -1
- package/dist/channels/index.cjs +11 -12
- package/dist/channels/index.js +1 -2
- package/dist/channels/last_value.cjs +3 -4
- package/dist/channels/last_value.cjs.map +1 -1
- package/dist/channels/last_value.js +1 -2
- package/dist/channels/last_value.js.map +1 -1
- package/dist/channels/named_barrier_value.cjs +3 -4
- package/dist/channels/named_barrier_value.cjs.map +1 -1
- package/dist/channels/named_barrier_value.js +1 -2
- package/dist/channels/named_barrier_value.js.map +1 -1
- package/dist/channels/topic.cjs +3 -4
- package/dist/channels/topic.cjs.map +1 -1
- package/dist/channels/topic.js +1 -2
- package/dist/channels/topic.js.map +1 -1
- package/dist/channels/untracked_value.cjs +3 -4
- package/dist/channels/untracked_value.cjs.map +1 -1
- package/dist/channels/untracked_value.js +1 -2
- package/dist/channels/untracked_value.js.map +1 -1
- package/dist/constants.cjs +4 -9
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.js +5 -7
- package/dist/constants.js.map +1 -1
- package/dist/errors.cjs +1 -2
- package/dist/errors.cjs.map +1 -1
- package/dist/errors.js +1 -1
- package/dist/errors.js.map +1 -1
- package/dist/func/index.cjs +9 -10
- package/dist/func/index.cjs.map +1 -1
- package/dist/func/index.js +1 -2
- package/dist/func/index.js.map +1 -1
- package/dist/graph/annotation.cjs +3 -4
- package/dist/graph/annotation.cjs.map +1 -1
- package/dist/graph/annotation.js +1 -2
- package/dist/graph/annotation.js.map +1 -1
- package/dist/graph/graph.cjs +23 -24
- package/dist/graph/graph.cjs.map +1 -1
- package/dist/graph/graph.js +16 -17
- package/dist/graph/graph.js.map +1 -1
- package/dist/graph/index.cjs +6 -6
- package/dist/graph/index.js +7 -8
- package/dist/graph/message.cjs +4 -5
- package/dist/graph/message.cjs.map +1 -1
- package/dist/graph/message.js +1 -2
- package/dist/graph/message.js.map +1 -1
- package/dist/graph/messages_annotation.cjs +4 -5
- package/dist/graph/messages_annotation.cjs.map +1 -1
- package/dist/graph/messages_annotation.d.ts +0 -1
- package/dist/graph/messages_annotation.d.ts.map +1 -1
- package/dist/graph/messages_annotation.js +1 -2
- package/dist/graph/messages_annotation.js.map +1 -1
- package/dist/graph/messages_reducer.cjs +2 -3
- package/dist/graph/messages_reducer.cjs.map +1 -1
- package/dist/graph/messages_reducer.js +2 -3
- package/dist/graph/messages_reducer.js.map +1 -1
- package/dist/graph/state.cjs +24 -25
- package/dist/graph/state.cjs.map +1 -1
- package/dist/graph/state.js +10 -11
- package/dist/graph/state.js.map +1 -1
- package/dist/graph/types.cjs +4 -5
- package/dist/graph/types.cjs.map +1 -1
- package/dist/graph/types.js +2 -3
- package/dist/graph/types.js.map +1 -1
- package/dist/graph/zod/index.cjs +5 -6
- package/dist/graph/zod/index.d.cts +0 -1
- package/dist/graph/zod/index.d.ts +0 -1
- package/dist/graph/zod/index.js +1 -2
- package/dist/graph/zod/meta.cjs +4 -5
- package/dist/graph/zod/meta.cjs.map +1 -1
- package/dist/graph/zod/meta.js +2 -3
- package/dist/graph/zod/meta.js.map +1 -1
- package/dist/graph/zod/plugin.cjs +2 -3
- package/dist/graph/zod/plugin.cjs.map +1 -1
- package/dist/graph/zod/plugin.js +2 -3
- package/dist/graph/zod/plugin.js.map +1 -1
- package/dist/graph/zod/schema.cjs +5 -6
- package/dist/graph/zod/schema.cjs.map +1 -1
- package/dist/graph/zod/schema.js +4 -5
- package/dist/graph/zod/schema.js.map +1 -1
- package/dist/graph/zod/zod-registry.cjs +2 -3
- package/dist/graph/zod/zod-registry.cjs.map +1 -1
- package/dist/graph/zod/zod-registry.js +1 -2
- package/dist/graph/zod/zod-registry.js.map +1 -1
- package/dist/hash.cjs +1 -2
- package/dist/hash.cjs.map +1 -1
- package/dist/hash.js +1 -1
- package/dist/index.cjs +60 -61
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +1 -2
- package/dist/index.js.map +1 -1
- package/dist/interrupt.cjs +7 -8
- package/dist/interrupt.cjs.map +1 -1
- package/dist/interrupt.js +5 -6
- package/dist/interrupt.js.map +1 -1
- package/dist/prebuilt/agentName.cjs +1 -2
- package/dist/prebuilt/agentName.cjs.map +1 -1
- package/dist/prebuilt/agentName.js +1 -2
- package/dist/prebuilt/agentName.js.map +1 -1
- package/dist/prebuilt/agent_executor.cjs +4 -5
- package/dist/prebuilt/agent_executor.cjs.map +1 -1
- package/dist/prebuilt/agent_executor.d.ts +0 -1
- package/dist/prebuilt/agent_executor.d.ts.map +1 -1
- package/dist/prebuilt/agent_executor.js +1 -2
- package/dist/prebuilt/agent_executor.js.map +1 -1
- package/dist/prebuilt/chat_agent_executor.cjs +4 -5
- package/dist/prebuilt/chat_agent_executor.cjs.map +1 -1
- package/dist/prebuilt/chat_agent_executor.js +1 -2
- package/dist/prebuilt/chat_agent_executor.js.map +1 -1
- package/dist/prebuilt/index.cjs +8 -9
- package/dist/prebuilt/index.js +1 -2
- package/dist/prebuilt/react_agent_executor.cjs +8 -9
- package/dist/prebuilt/react_agent_executor.cjs.map +1 -1
- package/dist/prebuilt/react_agent_executor.d.ts +0 -2
- package/dist/prebuilt/react_agent_executor.d.ts.map +1 -1
- package/dist/prebuilt/react_agent_executor.js +1 -2
- package/dist/prebuilt/react_agent_executor.js.map +1 -1
- package/dist/prebuilt/tool_executor.cjs +1 -2
- package/dist/prebuilt/tool_executor.cjs.map +1 -1
- package/dist/prebuilt/tool_executor.js +1 -2
- package/dist/prebuilt/tool_executor.js.map +1 -1
- package/dist/prebuilt/tool_node.cjs +4 -5
- package/dist/prebuilt/tool_node.cjs.map +1 -1
- package/dist/prebuilt/tool_node.js +1 -2
- package/dist/prebuilt/tool_node.js.map +1 -1
- package/dist/pregel/algo.cjs +30 -31
- package/dist/pregel/algo.cjs.map +1 -1
- package/dist/pregel/algo.d.ts +0 -5
- package/dist/pregel/algo.d.ts.map +1 -1
- package/dist/pregel/algo.js +23 -24
- package/dist/pregel/algo.js.map +1 -1
- package/dist/pregel/call.cjs +5 -6
- package/dist/pregel/call.cjs.map +1 -1
- package/dist/pregel/call.js +2 -3
- package/dist/pregel/call.js.map +1 -1
- package/dist/pregel/debug.cjs +10 -11
- package/dist/pregel/debug.cjs.map +1 -1
- package/dist/pregel/debug.js +8 -9
- package/dist/pregel/debug.js.map +1 -1
- package/dist/pregel/index.cjs +47 -48
- package/dist/pregel/index.cjs.map +1 -1
- package/dist/pregel/index.js +28 -29
- package/dist/pregel/index.js.map +1 -1
- package/dist/pregel/io.cjs +7 -8
- package/dist/pregel/io.cjs.map +1 -1
- package/dist/pregel/io.js +5 -6
- package/dist/pregel/io.js.map +1 -1
- package/dist/pregel/loop.cjs +29 -30
- package/dist/pregel/loop.cjs.map +1 -1
- package/dist/pregel/loop.js +20 -21
- package/dist/pregel/loop.js.map +1 -1
- package/dist/pregel/messages.cjs +4 -5
- package/dist/pregel/messages.cjs.map +1 -1
- package/dist/pregel/messages.js +4 -5
- package/dist/pregel/messages.js.map +1 -1
- package/dist/pregel/read.cjs +4 -5
- package/dist/pregel/read.cjs.map +1 -1
- package/dist/pregel/read.d.ts +0 -1
- package/dist/pregel/read.d.ts.map +1 -1
- package/dist/pregel/read.js +1 -2
- package/dist/pregel/read.js.map +1 -1
- package/dist/pregel/remote.cjs +9 -10
- package/dist/pregel/remote.cjs.map +1 -1
- package/dist/pregel/remote.d.ts +0 -2
- package/dist/pregel/remote.d.ts.map +1 -1
- package/dist/pregel/remote.js +7 -8
- package/dist/pregel/remote.js.map +1 -1
- package/dist/pregel/retry.cjs +8 -14
- package/dist/pregel/retry.cjs.map +1 -1
- package/dist/pregel/retry.js +4 -10
- package/dist/pregel/retry.js.map +1 -1
- package/dist/pregel/runner.cjs +8 -9
- package/dist/pregel/runner.cjs.map +1 -1
- package/dist/pregel/runner.js +4 -5
- package/dist/pregel/runner.js.map +1 -1
- package/dist/pregel/stream.cjs +3 -4
- package/dist/pregel/stream.cjs.map +1 -1
- package/dist/pregel/stream.d.ts +0 -1
- package/dist/pregel/stream.js +3 -4
- package/dist/pregel/stream.js.map +1 -1
- package/dist/pregel/types.cjs +1 -2
- package/dist/pregel/types.cjs.map +1 -1
- package/dist/pregel/types.js +1 -1
- package/dist/pregel/types.js.map +1 -1
- package/dist/pregel/utils/config.cjs +6 -7
- package/dist/pregel/utils/config.cjs.map +1 -1
- package/dist/pregel/utils/config.js +6 -7
- package/dist/pregel/utils/config.js.map +1 -1
- package/dist/pregel/utils/index.cjs +2 -3
- package/dist/pregel/utils/index.cjs.map +1 -1
- package/dist/pregel/utils/index.js +1 -2
- package/dist/pregel/utils/index.js.map +1 -1
- package/dist/pregel/utils/subgraph.cjs +1 -2
- package/dist/pregel/utils/subgraph.cjs.map +1 -1
- package/dist/pregel/utils/subgraph.js +1 -1
- package/dist/pregel/validate.cjs +4 -5
- package/dist/pregel/validate.cjs.map +1 -1
- package/dist/pregel/validate.js +2 -3
- package/dist/pregel/validate.js.map +1 -1
- package/dist/pregel/write.cjs +5 -8
- package/dist/pregel/write.cjs.map +1 -1
- package/dist/pregel/write.js +2 -5
- package/dist/pregel/write.js.map +1 -1
- package/dist/remote.cjs +3 -4
- package/dist/remote.js +1 -2
- package/dist/setup/async_local_storage.cjs +1 -2
- package/dist/setup/async_local_storage.cjs.map +1 -1
- package/dist/setup/async_local_storage.js +1 -2
- package/dist/setup/async_local_storage.js.map +1 -1
- package/dist/state/adapter.cjs +2 -3
- package/dist/state/adapter.cjs.map +1 -1
- package/dist/state/adapter.js +1 -2
- package/dist/state/adapter.js.map +1 -1
- package/dist/state/index.cjs +8 -8
- package/dist/state/index.d.ts +1 -2
- package/dist/state/index.js +7 -8
- package/dist/state/prebuilt/index.cjs +1 -1
- package/dist/state/prebuilt/index.js +2 -3
- package/dist/state/prebuilt/messages.cjs +3 -4
- package/dist/state/prebuilt/messages.cjs.map +1 -1
- package/dist/state/prebuilt/messages.js +3 -7
- package/dist/state/prebuilt/messages.js.map +1 -1
- package/dist/state/schema.cjs +16 -12
- package/dist/state/schema.cjs.map +1 -1
- package/dist/state/schema.d.cts.map +1 -1
- package/dist/state/schema.d.ts +0 -1
- package/dist/state/schema.d.ts.map +1 -1
- package/dist/state/schema.js +8 -4
- package/dist/state/schema.js.map +1 -1
- package/dist/state/types.cjs +1 -2
- package/dist/state/types.cjs.map +1 -1
- package/dist/state/types.js +1 -1
- package/dist/state/values/index.cjs +2 -2
- package/dist/state/values/index.js +3 -4
- package/dist/state/values/reduced.cjs +1 -2
- package/dist/state/values/reduced.cjs.map +1 -1
- package/dist/state/values/reduced.js +1 -1
- package/dist/state/values/reduced.js.map +1 -1
- package/dist/state/values/untracked.cjs +1 -2
- package/dist/state/values/untracked.cjs.map +1 -1
- package/dist/state/values/untracked.js +1 -1
- package/dist/state/values/untracked.js.map +1 -1
- package/dist/utils.cjs +2 -3
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js +1 -2
- package/dist/utils.js.map +1 -1
- package/dist/web.cjs +58 -59
- package/dist/web.d.ts +0 -3
- package/dist/web.js +1 -2
- package/dist/writer.cjs +1 -2
- package/dist/writer.cjs.map +1 -1
- package/dist/writer.js +1 -2
- package/dist/writer.js.map +1 -1
- package/package.json +3 -3
package/dist/graph/zod/meta.cjs
CHANGED
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
const require_binop = require(
|
|
2
|
-
const require_last_value = require(
|
|
1
|
+
const require_binop = require("../../channels/binop.cjs");
|
|
2
|
+
const require_last_value = require("../../channels/last_value.cjs");
|
|
3
3
|
let _langchain_core_utils_types = require("@langchain/core/utils/types");
|
|
4
|
-
|
|
5
4
|
//#region src/graph/zod/meta.ts
|
|
6
5
|
const META_EXTRAS_DESCRIPTION_PREFIX = "lg:";
|
|
7
6
|
/**
|
|
@@ -107,7 +106,7 @@ var SchemaMetaRegistry = class {
|
|
|
107
106
|
...meta.jsonSchemaExtra,
|
|
108
107
|
description
|
|
109
108
|
});
|
|
110
|
-
outputSchema = outputSchema.describe(
|
|
109
|
+
outputSchema = outputSchema.describe(`lg:${strExtras}`);
|
|
111
110
|
}
|
|
112
111
|
return [key, outputSchema];
|
|
113
112
|
});
|
|
@@ -135,10 +134,10 @@ function withLangGraph(schema, meta) {
|
|
|
135
134
|
return schema;
|
|
136
135
|
}
|
|
137
136
|
}
|
|
138
|
-
|
|
139
137
|
//#endregion
|
|
140
138
|
exports.META_EXTRAS_DESCRIPTION_PREFIX = META_EXTRAS_DESCRIPTION_PREFIX;
|
|
141
139
|
exports.SchemaMetaRegistry = SchemaMetaRegistry;
|
|
142
140
|
exports.schemaMetaRegistry = schemaMetaRegistry;
|
|
143
141
|
exports.withLangGraph = withLangGraph;
|
|
142
|
+
|
|
144
143
|
//# sourceMappingURL=meta.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.cjs","names":["BinaryOperatorAggregate","LastValue"],"sources":["../../../src/graph/zod/meta.ts"],"sourcesContent":["import {\n InferInteropZodOutput,\n InteropZodObject,\n InteropZodType,\n getInteropZodObjectShape,\n extendInteropZodObject,\n getInteropZodDefaultGetter,\n interopZodObjectPartial,\n InteropZodObjectShape,\n isZodSchemaV3,\n getSchemaDescription,\n} from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nimport { BinaryOperatorAggregate } from \"../../channels/binop.js\";\nimport { LastValue } from \"../../channels/last_value.js\";\nimport type { OverwriteValue } from \"../../constants.js\";\n\nexport const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n\n/** @internal */\nexport type ReducedZodChannel<\n T extends InteropZodType,\n TReducerSchema extends InteropZodType\n> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n\n/** @internal */\nexport type InteropZodToStateDefinition<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? BaseChannel<V, OverwriteValue<V> | U>\n : never\n : never\n : TShape[key] extends InteropZodType<infer V, infer U>\n ? BaseChannel<V, U>\n : never;\n};\n\nexport type UpdateType<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? OverwriteValue<V> | U\n : never\n : never\n : TShape[key] extends InteropZodType<unknown, infer U>\n ? U\n : never;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SchemaMeta<TValue = any, TUpdate = TValue> {\n jsonSchemaExtra?: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\" | \"messages\";\n [key: string]: unknown;\n };\n reducer?: {\n schema?: InteropZodType<TUpdate>;\n fn: (a: TValue, b: TUpdate) => TValue;\n };\n default?: () => TValue;\n}\n\n/**\n * A registry for storing and managing metadata associated with schemas.\n * This class provides methods to get, extend, remove, and check metadata for a given schema.\n */\nexport class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map = new Map<InteropZodType, SchemaMeta>();\n\n /**\n * Cache for extended schemas.\n * @internal\n */\n _extensionCache = new Map<string, Map<InteropZodType, InteropZodType>>();\n\n /**\n * Retrieves the metadata associated with a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to retrieve metadata for.\n * @returns The associated SchemaMeta, or undefined if not present.\n */\n get<TValue, TUpdate = TValue>(\n schema: InteropZodType<TValue>\n ): SchemaMeta<TValue, TUpdate> | undefined {\n return this._map.get(schema);\n }\n\n /**\n * Extends or sets the metadata for a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to extend metadata for.\n * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.\n */\n extend<TValue, TUpdate>(\n schema: InteropZodType<TValue>,\n predicate: (\n meta: SchemaMeta<TValue, TUpdate> | undefined\n ) => SchemaMeta<TValue, TUpdate>\n ) {\n const existingMeta = this.get<TValue, TUpdate>(schema);\n this._map.set(schema, predicate(existingMeta));\n }\n\n /**\n * Removes the metadata associated with a given schema.\n * @param schema The schema to remove metadata for.\n * @returns The SchemaMetaRegistry instance (for chaining).\n */\n remove(schema: InteropZodType): this {\n this._map.delete(schema);\n return this;\n }\n\n /**\n * Checks if metadata exists for a given schema.\n * @param schema The schema to check.\n * @returns True if metadata exists, false otherwise.\n */\n has(schema: InteropZodType): boolean {\n return this._map.has(schema);\n }\n\n /**\n * Returns a mapping of channel instances for each property in the schema\n * using the associated metadata in the registry.\n *\n * This is used to create the `channels` object that's passed to the `Graph` constructor.\n *\n * @template T The shape of the schema.\n * @param schema The schema to extract channels from.\n * @returns A mapping from property names to channel instances.\n */\n getChannelsForSchema<T extends InteropZodObject>(\n schema: T\n ): InteropZodToStateDefinition<T> {\n const channels = {} as Record<string, BaseChannel>;\n const shape = getInteropZodObjectShape(schema);\n for (const [key, channelSchema] of Object.entries(shape)) {\n const meta = this.get(channelSchema);\n if (meta?.reducer) {\n channels[key] = new BinaryOperatorAggregate<\n InferInteropZodOutput<typeof channelSchema>\n >(meta.reducer.fn, meta.default);\n } else {\n channels[key] = new LastValue(meta?.default);\n }\n }\n return channels as InteropZodToStateDefinition<T>;\n }\n\n /**\n * Returns a modified schema that introspectively looks at all keys of the provided\n * object schema, and applies the augmentations based on meta provided with those keys\n * in the registry and the selectors provided in the `effects` parameter.\n *\n * This assumes that the passed in schema is the \"root\" schema object for a graph where\n * the keys of the schema are the channels of the graph. Because we need to represent\n * the input of a graph in a couple of different ways, the `effects` parameter allows\n * us to apply those augmentations based on pre determined conditions.\n *\n * @param schema The root schema object to extend.\n * @param effects The effects that are being applied.\n * @returns The extended schema.\n */\n getExtendedChannelSchemas<T extends InteropZodObject>(\n schema: T,\n effects: {\n /**\n * Augments the shape by using the reducer's schema if it exists\n */\n withReducerSchema?: boolean;\n /**\n * Applies the stringified jsonSchemaExtra as a description to the schema.\n */\n withJsonSchemaExtrasAsDescription?: boolean;\n /**\n * Applies the `.partial()` modifier to the schema.\n */\n asPartial?: boolean;\n }\n ): InteropZodObject {\n // If no effects are being applied, return the schema unchanged\n if (Object.keys(effects).length === 0) {\n return schema;\n }\n\n // Cache key is determined by looking at the effects that are being applied\n const cacheKey = Object.entries(effects)\n .filter(([, v]) => v === true)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}:${v}`)\n .join(\"|\");\n\n const cache = this._extensionCache.get(cacheKey) ?? new Map();\n if (cache.has(schema)) return cache.get(schema)! as T;\n\n let modifiedSchema: InteropZodObject = schema;\n\n if (\n effects.withReducerSchema ||\n effects.withJsonSchemaExtrasAsDescription\n ) {\n const newShapeEntries = Object.entries(\n getInteropZodObjectShape(schema)\n ).map(([key, schema]) => {\n const meta = this.get(schema);\n let outputSchema = effects.withReducerSchema\n ? meta?.reducer?.schema ?? schema\n : schema;\n if (\n effects.withJsonSchemaExtrasAsDescription &&\n meta?.jsonSchemaExtra\n ) {\n const description =\n getSchemaDescription(outputSchema) ?? getSchemaDescription(schema);\n const strExtras = JSON.stringify({\n ...meta.jsonSchemaExtra,\n description,\n });\n outputSchema = outputSchema.describe(\n `${META_EXTRAS_DESCRIPTION_PREFIX}${strExtras}`\n );\n }\n return [key, outputSchema];\n });\n modifiedSchema = extendInteropZodObject(\n schema,\n Object.fromEntries(newShapeEntries)\n );\n if (isZodSchemaV3(modifiedSchema)) {\n modifiedSchema._def.unknownKeys = \"strip\";\n }\n }\n if (effects.asPartial) {\n modifiedSchema = interopZodObjectPartial(modifiedSchema);\n }\n\n cache.set(schema, modifiedSchema);\n this._extensionCache.set(cacheKey, cache);\n return modifiedSchema;\n }\n}\n\nexport const schemaMetaRegistry = new SchemaMetaRegistry();\n\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate> & { reducer?: undefined }\n): TSchema;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>> | TSchema {\n if (meta.reducer && !meta.default) {\n const defaultValueGetter = getInteropZodDefaultGetter(schema);\n if (defaultValueGetter != null) {\n // eslint-disable-next-line no-param-reassign\n meta.default = defaultValueGetter;\n }\n }\n if (meta.reducer) {\n const schemaWithReducer = Object.assign(schema, {\n lg_reducer_schema: meta.reducer?.schema ?? schema,\n });\n schemaMetaRegistry.extend(schemaWithReducer, () => meta);\n return schemaWithReducer;\n } else {\n schemaMetaRegistry.extend(schema, () => meta);\n return schema;\n }\n}\n"],"mappings":";;;;;AAiBA,MAAa,iCAAiC;;;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GACA,MAAM,kBAAkB,OAAO,kEACJ,OAAO,CACjC,CAAC,KAAK,CAAC,KAAK,YAAY;IACvB,MAAM,OAAO,KAAK,IAAI,OAAO;IAC7B,IAAI,eAAe,QAAQ,oBACvB,MAAM,SAAS,UAAU,SACzB;AACJ,QACE,QAAQ,qCACR,MAAM,iBACN;KACA,MAAM,oEACiB,aAAa,0DAAyB,OAAO;KACpE,MAAM,YAAY,KAAK,UAAU;MAC/B,GAAG,KAAK;MACR;MACD,CAAC;AACF,oBAAe,aAAa,SAC1B,GAAG,iCAAiC,YACrC;;AAEH,WAAO,CAAC,KAAK,aAAa;KAC1B;AACF,4EACE,QACA,OAAO,YAAY,gBAAgB,CACpC;AACD,sDAAkB,eAAe,CAC/B,gBAAe,KAAK,cAAc;;AAGtC,MAAI,QAAQ,UACV,2EAAyC,eAAe;AAG1D,QAAM,IAAI,QAAQ,eAAe;AACjC,OAAK,gBAAgB,IAAI,UAAU,MAAM;AACzC,SAAO;;;AAIX,MAAa,qBAAqB,IAAI,oBAAoB;AAkB1D,SAAgB,cAKd,QACA,MAC+D;AAC/D,KAAI,KAAK,WAAW,CAAC,KAAK,SAAS;EACjC,MAAM,iFAAgD,OAAO;AAC7D,MAAI,sBAAsB,KAExB,MAAK,UAAU;;AAGnB,KAAI,KAAK,SAAS;EAChB,MAAM,oBAAoB,OAAO,OAAO,QAAQ,EAC9C,mBAAmB,KAAK,SAAS,UAAU,QAC5C,CAAC;AACF,qBAAmB,OAAO,yBAAyB,KAAK;AACxD,SAAO;QACF;AACL,qBAAmB,OAAO,cAAc,KAAK;AAC7C,SAAO"}
|
|
1
|
+
{"version":3,"file":"meta.cjs","names":["BinaryOperatorAggregate","LastValue"],"sources":["../../../src/graph/zod/meta.ts"],"sourcesContent":["import {\n InferInteropZodOutput,\n InteropZodObject,\n InteropZodType,\n getInteropZodObjectShape,\n extendInteropZodObject,\n getInteropZodDefaultGetter,\n interopZodObjectPartial,\n InteropZodObjectShape,\n isZodSchemaV3,\n getSchemaDescription,\n} from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nimport { BinaryOperatorAggregate } from \"../../channels/binop.js\";\nimport { LastValue } from \"../../channels/last_value.js\";\nimport type { OverwriteValue } from \"../../constants.js\";\n\nexport const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n\n/** @internal */\nexport type ReducedZodChannel<\n T extends InteropZodType,\n TReducerSchema extends InteropZodType\n> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n\n/** @internal */\nexport type InteropZodToStateDefinition<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? BaseChannel<V, OverwriteValue<V> | U>\n : never\n : never\n : TShape[key] extends InteropZodType<infer V, infer U>\n ? BaseChannel<V, U>\n : never;\n};\n\nexport type UpdateType<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? OverwriteValue<V> | U\n : never\n : never\n : TShape[key] extends InteropZodType<unknown, infer U>\n ? U\n : never;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SchemaMeta<TValue = any, TUpdate = TValue> {\n jsonSchemaExtra?: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\" | \"messages\";\n [key: string]: unknown;\n };\n reducer?: {\n schema?: InteropZodType<TUpdate>;\n fn: (a: TValue, b: TUpdate) => TValue;\n };\n default?: () => TValue;\n}\n\n/**\n * A registry for storing and managing metadata associated with schemas.\n * This class provides methods to get, extend, remove, and check metadata for a given schema.\n */\nexport class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map = new Map<InteropZodType, SchemaMeta>();\n\n /**\n * Cache for extended schemas.\n * @internal\n */\n _extensionCache = new Map<string, Map<InteropZodType, InteropZodType>>();\n\n /**\n * Retrieves the metadata associated with a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to retrieve metadata for.\n * @returns The associated SchemaMeta, or undefined if not present.\n */\n get<TValue, TUpdate = TValue>(\n schema: InteropZodType<TValue>\n ): SchemaMeta<TValue, TUpdate> | undefined {\n return this._map.get(schema);\n }\n\n /**\n * Extends or sets the metadata for a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to extend metadata for.\n * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.\n */\n extend<TValue, TUpdate>(\n schema: InteropZodType<TValue>,\n predicate: (\n meta: SchemaMeta<TValue, TUpdate> | undefined\n ) => SchemaMeta<TValue, TUpdate>\n ) {\n const existingMeta = this.get<TValue, TUpdate>(schema);\n this._map.set(schema, predicate(existingMeta));\n }\n\n /**\n * Removes the metadata associated with a given schema.\n * @param schema The schema to remove metadata for.\n * @returns The SchemaMetaRegistry instance (for chaining).\n */\n remove(schema: InteropZodType): this {\n this._map.delete(schema);\n return this;\n }\n\n /**\n * Checks if metadata exists for a given schema.\n * @param schema The schema to check.\n * @returns True if metadata exists, false otherwise.\n */\n has(schema: InteropZodType): boolean {\n return this._map.has(schema);\n }\n\n /**\n * Returns a mapping of channel instances for each property in the schema\n * using the associated metadata in the registry.\n *\n * This is used to create the `channels` object that's passed to the `Graph` constructor.\n *\n * @template T The shape of the schema.\n * @param schema The schema to extract channels from.\n * @returns A mapping from property names to channel instances.\n */\n getChannelsForSchema<T extends InteropZodObject>(\n schema: T\n ): InteropZodToStateDefinition<T> {\n const channels = {} as Record<string, BaseChannel>;\n const shape = getInteropZodObjectShape(schema);\n for (const [key, channelSchema] of Object.entries(shape)) {\n const meta = this.get(channelSchema);\n if (meta?.reducer) {\n channels[key] = new BinaryOperatorAggregate<\n InferInteropZodOutput<typeof channelSchema>\n >(meta.reducer.fn, meta.default);\n } else {\n channels[key] = new LastValue(meta?.default);\n }\n }\n return channels as InteropZodToStateDefinition<T>;\n }\n\n /**\n * Returns a modified schema that introspectively looks at all keys of the provided\n * object schema, and applies the augmentations based on meta provided with those keys\n * in the registry and the selectors provided in the `effects` parameter.\n *\n * This assumes that the passed in schema is the \"root\" schema object for a graph where\n * the keys of the schema are the channels of the graph. Because we need to represent\n * the input of a graph in a couple of different ways, the `effects` parameter allows\n * us to apply those augmentations based on pre determined conditions.\n *\n * @param schema The root schema object to extend.\n * @param effects The effects that are being applied.\n * @returns The extended schema.\n */\n getExtendedChannelSchemas<T extends InteropZodObject>(\n schema: T,\n effects: {\n /**\n * Augments the shape by using the reducer's schema if it exists\n */\n withReducerSchema?: boolean;\n /**\n * Applies the stringified jsonSchemaExtra as a description to the schema.\n */\n withJsonSchemaExtrasAsDescription?: boolean;\n /**\n * Applies the `.partial()` modifier to the schema.\n */\n asPartial?: boolean;\n }\n ): InteropZodObject {\n // If no effects are being applied, return the schema unchanged\n if (Object.keys(effects).length === 0) {\n return schema;\n }\n\n // Cache key is determined by looking at the effects that are being applied\n const cacheKey = Object.entries(effects)\n .filter(([, v]) => v === true)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}:${v}`)\n .join(\"|\");\n\n const cache = this._extensionCache.get(cacheKey) ?? new Map();\n if (cache.has(schema)) return cache.get(schema)! as T;\n\n let modifiedSchema: InteropZodObject = schema;\n\n if (\n effects.withReducerSchema ||\n effects.withJsonSchemaExtrasAsDescription\n ) {\n const newShapeEntries = Object.entries(\n getInteropZodObjectShape(schema)\n ).map(([key, schema]) => {\n const meta = this.get(schema);\n let outputSchema = effects.withReducerSchema\n ? meta?.reducer?.schema ?? schema\n : schema;\n if (\n effects.withJsonSchemaExtrasAsDescription &&\n meta?.jsonSchemaExtra\n ) {\n const description =\n getSchemaDescription(outputSchema) ?? getSchemaDescription(schema);\n const strExtras = JSON.stringify({\n ...meta.jsonSchemaExtra,\n description,\n });\n outputSchema = outputSchema.describe(\n `${META_EXTRAS_DESCRIPTION_PREFIX}${strExtras}`\n );\n }\n return [key, outputSchema];\n });\n modifiedSchema = extendInteropZodObject(\n schema,\n Object.fromEntries(newShapeEntries)\n );\n if (isZodSchemaV3(modifiedSchema)) {\n modifiedSchema._def.unknownKeys = \"strip\";\n }\n }\n if (effects.asPartial) {\n modifiedSchema = interopZodObjectPartial(modifiedSchema);\n }\n\n cache.set(schema, modifiedSchema);\n this._extensionCache.set(cacheKey, cache);\n return modifiedSchema;\n }\n}\n\nexport const schemaMetaRegistry = new SchemaMetaRegistry();\n\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate> & { reducer?: undefined }\n): TSchema;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>> | TSchema {\n if (meta.reducer && !meta.default) {\n const defaultValueGetter = getInteropZodDefaultGetter(schema);\n if (defaultValueGetter != null) {\n // eslint-disable-next-line no-param-reassign\n meta.default = defaultValueGetter;\n }\n }\n if (meta.reducer) {\n const schemaWithReducer = Object.assign(schema, {\n lg_reducer_schema: meta.reducer?.schema ?? schema,\n });\n schemaMetaRegistry.extend(schemaWithReducer, () => meta);\n return schemaWithReducer;\n } else {\n schemaMetaRegistry.extend(schema, () => meta);\n return schema;\n }\n}\n"],"mappings":";;;;AAiBA,MAAa,iCAAiC;;;;;AAiE9C,IAAa,qBAAb,MAAgC;;;;;CAK9B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Value } from "../../channels/last_value.js";
|
|
3
3
|
import { extendInteropZodObject, getInteropZodDefaultGetter, getInteropZodObjectShape, getSchemaDescription, interopZodObjectPartial, isZodSchemaV3 } from "@langchain/core/utils/types";
|
|
4
|
-
|
|
5
4
|
//#region src/graph/zod/meta.ts
|
|
6
5
|
const META_EXTRAS_DESCRIPTION_PREFIX = "lg:";
|
|
7
6
|
/**
|
|
@@ -107,7 +106,7 @@ var SchemaMetaRegistry = class {
|
|
|
107
106
|
...meta.jsonSchemaExtra,
|
|
108
107
|
description
|
|
109
108
|
});
|
|
110
|
-
outputSchema = outputSchema.describe(
|
|
109
|
+
outputSchema = outputSchema.describe(`lg:${strExtras}`);
|
|
111
110
|
}
|
|
112
111
|
return [key, outputSchema];
|
|
113
112
|
});
|
|
@@ -135,7 +134,7 @@ function withLangGraph(schema, meta) {
|
|
|
135
134
|
return schema;
|
|
136
135
|
}
|
|
137
136
|
}
|
|
138
|
-
|
|
139
137
|
//#endregion
|
|
140
138
|
export { META_EXTRAS_DESCRIPTION_PREFIX, SchemaMetaRegistry, schemaMetaRegistry, withLangGraph };
|
|
139
|
+
|
|
141
140
|
//# sourceMappingURL=meta.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.js","names":[],"sources":["../../../src/graph/zod/meta.ts"],"sourcesContent":["import {\n InferInteropZodOutput,\n InteropZodObject,\n InteropZodType,\n getInteropZodObjectShape,\n extendInteropZodObject,\n getInteropZodDefaultGetter,\n interopZodObjectPartial,\n InteropZodObjectShape,\n isZodSchemaV3,\n getSchemaDescription,\n} from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nimport { BinaryOperatorAggregate } from \"../../channels/binop.js\";\nimport { LastValue } from \"../../channels/last_value.js\";\nimport type { OverwriteValue } from \"../../constants.js\";\n\nexport const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n\n/** @internal */\nexport type ReducedZodChannel<\n T extends InteropZodType,\n TReducerSchema extends InteropZodType\n> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n\n/** @internal */\nexport type InteropZodToStateDefinition<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? BaseChannel<V, OverwriteValue<V> | U>\n : never\n : never\n : TShape[key] extends InteropZodType<infer V, infer U>\n ? BaseChannel<V, U>\n : never;\n};\n\nexport type UpdateType<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? OverwriteValue<V> | U\n : never\n : never\n : TShape[key] extends InteropZodType<unknown, infer U>\n ? U\n : never;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SchemaMeta<TValue = any, TUpdate = TValue> {\n jsonSchemaExtra?: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\" | \"messages\";\n [key: string]: unknown;\n };\n reducer?: {\n schema?: InteropZodType<TUpdate>;\n fn: (a: TValue, b: TUpdate) => TValue;\n };\n default?: () => TValue;\n}\n\n/**\n * A registry for storing and managing metadata associated with schemas.\n * This class provides methods to get, extend, remove, and check metadata for a given schema.\n */\nexport class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map = new Map<InteropZodType, SchemaMeta>();\n\n /**\n * Cache for extended schemas.\n * @internal\n */\n _extensionCache = new Map<string, Map<InteropZodType, InteropZodType>>();\n\n /**\n * Retrieves the metadata associated with a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to retrieve metadata for.\n * @returns The associated SchemaMeta, or undefined if not present.\n */\n get<TValue, TUpdate = TValue>(\n schema: InteropZodType<TValue>\n ): SchemaMeta<TValue, TUpdate> | undefined {\n return this._map.get(schema);\n }\n\n /**\n * Extends or sets the metadata for a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to extend metadata for.\n * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.\n */\n extend<TValue, TUpdate>(\n schema: InteropZodType<TValue>,\n predicate: (\n meta: SchemaMeta<TValue, TUpdate> | undefined\n ) => SchemaMeta<TValue, TUpdate>\n ) {\n const existingMeta = this.get<TValue, TUpdate>(schema);\n this._map.set(schema, predicate(existingMeta));\n }\n\n /**\n * Removes the metadata associated with a given schema.\n * @param schema The schema to remove metadata for.\n * @returns The SchemaMetaRegistry instance (for chaining).\n */\n remove(schema: InteropZodType): this {\n this._map.delete(schema);\n return this;\n }\n\n /**\n * Checks if metadata exists for a given schema.\n * @param schema The schema to check.\n * @returns True if metadata exists, false otherwise.\n */\n has(schema: InteropZodType): boolean {\n return this._map.has(schema);\n }\n\n /**\n * Returns a mapping of channel instances for each property in the schema\n * using the associated metadata in the registry.\n *\n * This is used to create the `channels` object that's passed to the `Graph` constructor.\n *\n * @template T The shape of the schema.\n * @param schema The schema to extract channels from.\n * @returns A mapping from property names to channel instances.\n */\n getChannelsForSchema<T extends InteropZodObject>(\n schema: T\n ): InteropZodToStateDefinition<T> {\n const channels = {} as Record<string, BaseChannel>;\n const shape = getInteropZodObjectShape(schema);\n for (const [key, channelSchema] of Object.entries(shape)) {\n const meta = this.get(channelSchema);\n if (meta?.reducer) {\n channels[key] = new BinaryOperatorAggregate<\n InferInteropZodOutput<typeof channelSchema>\n >(meta.reducer.fn, meta.default);\n } else {\n channels[key] = new LastValue(meta?.default);\n }\n }\n return channels as InteropZodToStateDefinition<T>;\n }\n\n /**\n * Returns a modified schema that introspectively looks at all keys of the provided\n * object schema, and applies the augmentations based on meta provided with those keys\n * in the registry and the selectors provided in the `effects` parameter.\n *\n * This assumes that the passed in schema is the \"root\" schema object for a graph where\n * the keys of the schema are the channels of the graph. Because we need to represent\n * the input of a graph in a couple of different ways, the `effects` parameter allows\n * us to apply those augmentations based on pre determined conditions.\n *\n * @param schema The root schema object to extend.\n * @param effects The effects that are being applied.\n * @returns The extended schema.\n */\n getExtendedChannelSchemas<T extends InteropZodObject>(\n schema: T,\n effects: {\n /**\n * Augments the shape by using the reducer's schema if it exists\n */\n withReducerSchema?: boolean;\n /**\n * Applies the stringified jsonSchemaExtra as a description to the schema.\n */\n withJsonSchemaExtrasAsDescription?: boolean;\n /**\n * Applies the `.partial()` modifier to the schema.\n */\n asPartial?: boolean;\n }\n ): InteropZodObject {\n // If no effects are being applied, return the schema unchanged\n if (Object.keys(effects).length === 0) {\n return schema;\n }\n\n // Cache key is determined by looking at the effects that are being applied\n const cacheKey = Object.entries(effects)\n .filter(([, v]) => v === true)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}:${v}`)\n .join(\"|\");\n\n const cache = this._extensionCache.get(cacheKey) ?? new Map();\n if (cache.has(schema)) return cache.get(schema)! as T;\n\n let modifiedSchema: InteropZodObject = schema;\n\n if (\n effects.withReducerSchema ||\n effects.withJsonSchemaExtrasAsDescription\n ) {\n const newShapeEntries = Object.entries(\n getInteropZodObjectShape(schema)\n ).map(([key, schema]) => {\n const meta = this.get(schema);\n let outputSchema = effects.withReducerSchema\n ? meta?.reducer?.schema ?? schema\n : schema;\n if (\n effects.withJsonSchemaExtrasAsDescription &&\n meta?.jsonSchemaExtra\n ) {\n const description =\n getSchemaDescription(outputSchema) ?? getSchemaDescription(schema);\n const strExtras = JSON.stringify({\n ...meta.jsonSchemaExtra,\n description,\n });\n outputSchema = outputSchema.describe(\n `${META_EXTRAS_DESCRIPTION_PREFIX}${strExtras}`\n );\n }\n return [key, outputSchema];\n });\n modifiedSchema = extendInteropZodObject(\n schema,\n Object.fromEntries(newShapeEntries)\n );\n if (isZodSchemaV3(modifiedSchema)) {\n modifiedSchema._def.unknownKeys = \"strip\";\n }\n }\n if (effects.asPartial) {\n modifiedSchema = interopZodObjectPartial(modifiedSchema);\n }\n\n cache.set(schema, modifiedSchema);\n this._extensionCache.set(cacheKey, cache);\n return modifiedSchema;\n }\n}\n\nexport const schemaMetaRegistry = new SchemaMetaRegistry();\n\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate> & { reducer?: undefined }\n): TSchema;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>> | TSchema {\n if (meta.reducer && !meta.default) {\n const defaultValueGetter = getInteropZodDefaultGetter(schema);\n if (defaultValueGetter != null) {\n // eslint-disable-next-line no-param-reassign\n meta.default = defaultValueGetter;\n }\n }\n if (meta.reducer) {\n const schemaWithReducer = Object.assign(schema, {\n lg_reducer_schema: meta.reducer?.schema ?? schema,\n });\n schemaMetaRegistry.extend(schemaWithReducer, () => meta);\n return schemaWithReducer;\n } else {\n schemaMetaRegistry.extend(schema, () => meta);\n return schema;\n }\n}\n"],"mappings":";;;;;AAiBA,MAAa,iCAAiC;;;;;AAiE9C,IAAa,qBAAb,MAAgC;;;;;CAK9B,uBAAO,IAAI,KAAiC;;;;;CAM5C,kCAAkB,IAAI,KAAkD;;;;;;;;CASxE,IACE,QACyC;AACzC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;CAU9B,OACE,QACA,WAGA;EACA,MAAM,eAAe,KAAK,IAAqB,OAAO;AACtD,OAAK,KAAK,IAAI,QAAQ,UAAU,aAAa,CAAC;;;;;;;CAQhD,OAAO,QAA8B;AACn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AG,KAAK;MACR;MACD,CAAC;AACF,oBAAe,aAAa,SAC1B,GAAG,iCAAiC,YACrC;;AAEH,WAAO,CAAC,KAAK,aAAa;KAC1B;AACF,oBAAiB,uBACf,QACA,OAAO,YAAY,gBAAgB,CACpC;AACD,OAAI,cAAc,eAAe,CAC/B,gBAAe,KAAK,cAAc;;AAGtC,MAAI,QAAQ,UACV,kBAAiB,wBAAwB,eAAe;AAG1D,QAAM,IAAI,QAAQ,eAAe;AACjC,OAAK,gBAAgB,IAAI,UAAU,MAAM;AACzC,SAAO;;;AAIX,MAAa,qBAAqB,IAAI,oBAAoB;AAkB1D,SAAgB,cAKd,QACA,MAC+D;AAC/D,KAAI,KAAK,WAAW,CAAC,KAAK,SAAS;EACjC,MAAM,qBAAqB,2BAA2B,OAAO;AAC7D,MAAI,sBAAsB,KAExB,MAAK,UAAU;;AAGnB,KAAI,KAAK,SAAS;EAChB,MAAM,oBAAoB,OAAO,OAAO,QAAQ,EAC9C,mBAAmB,KAAK,SAAS,UAAU,QAC5C,CAAC;AACF,qBAAmB,OAAO,yBAAyB,KAAK;AACxD,SAAO;QACF;AACL,qBAAmB,OAAO,cAAc,KAAK;AAC7C,SAAO"}
|
|
1
|
+
{"version":3,"file":"meta.js","names":[],"sources":["../../../src/graph/zod/meta.ts"],"sourcesContent":["import {\n InferInteropZodOutput,\n InteropZodObject,\n InteropZodType,\n getInteropZodObjectShape,\n extendInteropZodObject,\n getInteropZodDefaultGetter,\n interopZodObjectPartial,\n InteropZodObjectShape,\n isZodSchemaV3,\n getSchemaDescription,\n} from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nimport { BinaryOperatorAggregate } from \"../../channels/binop.js\";\nimport { LastValue } from \"../../channels/last_value.js\";\nimport type { OverwriteValue } from \"../../constants.js\";\n\nexport const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n\n/** @internal */\nexport type ReducedZodChannel<\n T extends InteropZodType,\n TReducerSchema extends InteropZodType\n> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n\n/** @internal */\nexport type InteropZodToStateDefinition<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? BaseChannel<V, OverwriteValue<V> | U>\n : never\n : never\n : TShape[key] extends InteropZodType<infer V, infer U>\n ? BaseChannel<V, U>\n : never;\n};\n\nexport type UpdateType<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? OverwriteValue<V> | U\n : never\n : never\n : TShape[key] extends InteropZodType<unknown, infer U>\n ? U\n : never;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SchemaMeta<TValue = any, TUpdate = TValue> {\n jsonSchemaExtra?: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\" | \"messages\";\n [key: string]: unknown;\n };\n reducer?: {\n schema?: InteropZodType<TUpdate>;\n fn: (a: TValue, b: TUpdate) => TValue;\n };\n default?: () => TValue;\n}\n\n/**\n * A registry for storing and managing metadata associated with schemas.\n * This class provides methods to get, extend, remove, and check metadata for a given schema.\n */\nexport class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map = new Map<InteropZodType, SchemaMeta>();\n\n /**\n * Cache for extended schemas.\n * @internal\n */\n _extensionCache = new Map<string, Map<InteropZodType, InteropZodType>>();\n\n /**\n * Retrieves the metadata associated with a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to retrieve metadata for.\n * @returns The associated SchemaMeta, or undefined if not present.\n */\n get<TValue, TUpdate = TValue>(\n schema: InteropZodType<TValue>\n ): SchemaMeta<TValue, TUpdate> | undefined {\n return this._map.get(schema);\n }\n\n /**\n * Extends or sets the metadata for a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to extend metadata for.\n * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.\n */\n extend<TValue, TUpdate>(\n schema: InteropZodType<TValue>,\n predicate: (\n meta: SchemaMeta<TValue, TUpdate> | undefined\n ) => SchemaMeta<TValue, TUpdate>\n ) {\n const existingMeta = this.get<TValue, TUpdate>(schema);\n this._map.set(schema, predicate(existingMeta));\n }\n\n /**\n * Removes the metadata associated with a given schema.\n * @param schema The schema to remove metadata for.\n * @returns The SchemaMetaRegistry instance (for chaining).\n */\n remove(schema: InteropZodType): this {\n this._map.delete(schema);\n return this;\n }\n\n /**\n * Checks if metadata exists for a given schema.\n * @param schema The schema to check.\n * @returns True if metadata exists, false otherwise.\n */\n has(schema: InteropZodType): boolean {\n return this._map.has(schema);\n }\n\n /**\n * Returns a mapping of channel instances for each property in the schema\n * using the associated metadata in the registry.\n *\n * This is used to create the `channels` object that's passed to the `Graph` constructor.\n *\n * @template T The shape of the schema.\n * @param schema The schema to extract channels from.\n * @returns A mapping from property names to channel instances.\n */\n getChannelsForSchema<T extends InteropZodObject>(\n schema: T\n ): InteropZodToStateDefinition<T> {\n const channels = {} as Record<string, BaseChannel>;\n const shape = getInteropZodObjectShape(schema);\n for (const [key, channelSchema] of Object.entries(shape)) {\n const meta = this.get(channelSchema);\n if (meta?.reducer) {\n channels[key] = new BinaryOperatorAggregate<\n InferInteropZodOutput<typeof channelSchema>\n >(meta.reducer.fn, meta.default);\n } else {\n channels[key] = new LastValue(meta?.default);\n }\n }\n return channels as InteropZodToStateDefinition<T>;\n }\n\n /**\n * Returns a modified schema that introspectively looks at all keys of the provided\n * object schema, and applies the augmentations based on meta provided with those keys\n * in the registry and the selectors provided in the `effects` parameter.\n *\n * This assumes that the passed in schema is the \"root\" schema object for a graph where\n * the keys of the schema are the channels of the graph. Because we need to represent\n * the input of a graph in a couple of different ways, the `effects` parameter allows\n * us to apply those augmentations based on pre determined conditions.\n *\n * @param schema The root schema object to extend.\n * @param effects The effects that are being applied.\n * @returns The extended schema.\n */\n getExtendedChannelSchemas<T extends InteropZodObject>(\n schema: T,\n effects: {\n /**\n * Augments the shape by using the reducer's schema if it exists\n */\n withReducerSchema?: boolean;\n /**\n * Applies the stringified jsonSchemaExtra as a description to the schema.\n */\n withJsonSchemaExtrasAsDescription?: boolean;\n /**\n * Applies the `.partial()` modifier to the schema.\n */\n asPartial?: boolean;\n }\n ): InteropZodObject {\n // If no effects are being applied, return the schema unchanged\n if (Object.keys(effects).length === 0) {\n return schema;\n }\n\n // Cache key is determined by looking at the effects that are being applied\n const cacheKey = Object.entries(effects)\n .filter(([, v]) => v === true)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}:${v}`)\n .join(\"|\");\n\n const cache = this._extensionCache.get(cacheKey) ?? new Map();\n if (cache.has(schema)) return cache.get(schema)! as T;\n\n let modifiedSchema: InteropZodObject = schema;\n\n if (\n effects.withReducerSchema ||\n effects.withJsonSchemaExtrasAsDescription\n ) {\n const newShapeEntries = Object.entries(\n getInteropZodObjectShape(schema)\n ).map(([key, schema]) => {\n const meta = this.get(schema);\n let outputSchema = effects.withReducerSchema\n ? meta?.reducer?.schema ?? schema\n : schema;\n if (\n effects.withJsonSchemaExtrasAsDescription &&\n meta?.jsonSchemaExtra\n ) {\n const description =\n getSchemaDescription(outputSchema) ?? getSchemaDescription(schema);\n const strExtras = JSON.stringify({\n ...meta.jsonSchemaExtra,\n description,\n });\n outputSchema = outputSchema.describe(\n `${META_EXTRAS_DESCRIPTION_PREFIX}${strExtras}`\n );\n }\n return [key, outputSchema];\n });\n modifiedSchema = extendInteropZodObject(\n schema,\n Object.fromEntries(newShapeEntries)\n );\n if (isZodSchemaV3(modifiedSchema)) {\n modifiedSchema._def.unknownKeys = \"strip\";\n }\n }\n if (effects.asPartial) {\n modifiedSchema = interopZodObjectPartial(modifiedSchema);\n }\n\n cache.set(schema, modifiedSchema);\n this._extensionCache.set(cacheKey, cache);\n return modifiedSchema;\n }\n}\n\nexport const schemaMetaRegistry = new SchemaMetaRegistry();\n\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate> & { reducer?: undefined }\n): TSchema;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>> | TSchema {\n if (meta.reducer && !meta.default) {\n const defaultValueGetter = getInteropZodDefaultGetter(schema);\n if (defaultValueGetter != null) {\n // eslint-disable-next-line no-param-reassign\n meta.default = defaultValueGetter;\n }\n }\n if (meta.reducer) {\n const schemaWithReducer = Object.assign(schema, {\n lg_reducer_schema: meta.reducer?.schema ?? schema,\n });\n schemaMetaRegistry.extend(schemaWithReducer, () => meta);\n return schemaWithReducer;\n } else {\n schemaMetaRegistry.extend(schema, () => meta);\n return schema;\n }\n}\n"],"mappings":";;;;AAiBA,MAAa,iCAAiC;;;;;AAiE9C,IAAa,qBAAb,MAAgC;;;;;CAK9B,uBAAO,IAAI,KAAiC;;;;;CAM5C,kCAAkB,IAAI,KAAkD;;;;;;;;CASxE,IACE,QACyC;AACzC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;CAU9B,OACE,QACA,WAGA;EACA,MAAM,eAAe,KAAK,IAAqB,OAAO;AACtD,OAAK,KAAK,IAAI,QAAQ,UAAU,aAAa,CAAC;;;;;;;CAQhD,OAAO,QAA8B;AACnC,OAAK,KAA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R;MACD,CAAC;AACF,oBAAe,aAAa,SAC1B,MAAoC,YACrC;;AAEH,WAAO,CAAC,KAAK,aAAa;KAC1B;AACF,oBAAiB,uBACf,QACA,OAAO,YAAY,gBAAgB,CACpC;AACD,OAAI,cAAc,eAAe,CAC/B,gBAAe,KAAK,cAAc;;AAGtC,MAAI,QAAQ,UACV,kBAAiB,wBAAwB,eAAe;AAG1D,QAAM,IAAI,QAAQ,eAAe;AACjC,OAAK,gBAAgB,IAAI,UAAU,MAAM;AACzC,SAAO;;;AAIX,MAAa,qBAAqB,IAAI,oBAAoB;AAkB1D,SAAgB,cAKd,QACA,MAC+D;AAC/D,KAAI,KAAK,WAAW,CAAC,KAAK,SAAS;EACjC,MAAM,qBAAqB,2BAA2B,OAAO;AAC7D,MAAI,sBAAsB,KAExB,MAAK,UAAU;;AAGnB,KAAI,KAAK,SAAS;EAChB,MAAM,oBAAoB,OAAO,OAAO,QAAQ,EAC9C,mBAAmB,KAAK,SAAS,UAAU,QAC5C,CAAC;AACF,qBAAmB,OAAO,yBAAyB,KAAK;AACxD,SAAO;QACF;AACL,qBAAmB,OAAO,cAAc,KAAK;AAC7C,SAAO"}
|
|
@@ -1,8 +1,7 @@
|
|
|
1
|
-
const require_meta = require(
|
|
1
|
+
const require_meta = require("./meta.cjs");
|
|
2
2
|
let zod_v4 = require("zod/v4");
|
|
3
3
|
let _langchain_core_utils_types = require("@langchain/core/utils/types");
|
|
4
4
|
let zod_v3 = require("zod/v3");
|
|
5
|
-
|
|
6
5
|
//#region src/graph/zod/plugin.ts
|
|
7
6
|
const metaSymbol = Symbol.for("langgraph-zod");
|
|
8
7
|
if (!(metaSymbol in globalThis)) globalThis[metaSymbol] = /* @__PURE__ */ new WeakSet();
|
|
@@ -34,6 +33,6 @@ try {
|
|
|
34
33
|
} catch (error) {
|
|
35
34
|
throw new Error("Failed to extend Zod with LangGraph-related methods. This is most likely a bug, consider opening an issue and/or using `withLangGraph` to augment your Zod schema.", { cause: error });
|
|
36
35
|
}
|
|
37
|
-
|
|
38
36
|
//#endregion
|
|
37
|
+
|
|
39
38
|
//# sourceMappingURL=plugin.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.cjs","names":["withLangGraph","z3","z4"],"sources":["../../../src/graph/zod/plugin.ts"],"sourcesContent":["import { z as z4 } from \"zod/v4\";\nimport { z as z3 } from \"zod/v3\";\nimport {\n getInteropZodDefaultGetter,\n InteropZodType,\n} from \"@langchain/core/utils/types\";\nimport { SchemaMeta, withLangGraph } from \"./meta.js\";\n\nconst metaSymbol = Symbol.for(\"langgraph-zod\");\n\ninterface ZodLangGraphTypesV3<T extends z3.ZodTypeAny, Output> {\n reducer<Input = z3.output<T>>(\n transform: (a: Output, arg: Input) => Output,\n options?: z3.ZodType<Input>\n ): z3.ZodType<Output, z3.ZodEffectsDef<T>, Input>;\n\n metadata(payload: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\";\n\n [key: string]: unknown;\n }): T;\n}\n\ndeclare module \"zod\" {\n interface ZodType<Output> {\n /**\n * @deprecated Using the langgraph zod plugin is deprecated and will be removed in future versions\n * Consider upgrading to zod 4 and using the exported langgraph meta registry. {@link langgraphRegistry}\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n langgraph: ZodLangGraphTypesV3<any, Output>;\n }\n}\ndeclare module \"zod/v3\" {\n interface ZodType<Output> {\n /**\n * @deprecated Using the langgraph zod plugin is deprecated and will be removed in future versions\n * Consider upgrading to zod 4 and using the exported langgraph meta registry. {@link langgraphRegistry}\n */\n langgraph: ZodLangGraphTypesV3<this, Output>;\n }\n}\n\ninterface PluginGlobalType {\n [metaSymbol]?: WeakSet<object>;\n}\n\nif (!(metaSymbol in globalThis)) {\n (globalThis as PluginGlobalType)[metaSymbol] = new WeakSet();\n}\n\nfunction applyPluginPrototype(prototype: object) {\n const cache = (globalThis as PluginGlobalType)[metaSymbol]!;\n if (cache.has(prototype)) {\n return; // Already applied\n }\n\n Object.defineProperty(prototype, \"langgraph\", {\n get(this: InteropZodType) {\n // Actual return type is provided by module augmentation\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const zodThis = this;\n\n return {\n metadata(jsonSchemaExtra: SchemaMeta[\"jsonSchemaExtra\"]) {\n return withLangGraph(zodThis, { jsonSchemaExtra });\n },\n reducer(\n fn: (a: unknown, arg: unknown) => unknown,\n schema?: InteropZodType\n ) {\n const defaultFn = getInteropZodDefaultGetter(zodThis);\n return withLangGraph(zodThis, {\n default: defaultFn,\n reducer: { schema, fn },\n });\n },\n };\n },\n });\n cache.add(prototype);\n}\n\ntry {\n applyPluginPrototype(z3.ZodType.prototype);\n applyPluginPrototype(z4.ZodType.prototype);\n} catch (error) {\n throw new Error(\n \"Failed to extend Zod with LangGraph-related methods. This is most likely a bug, consider opening an issue and/or using `withLangGraph` to augment your Zod schema.\",\n { cause: error }\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.cjs","names":["withLangGraph","z3","z4"],"sources":["../../../src/graph/zod/plugin.ts"],"sourcesContent":["import { z as z4 } from \"zod/v4\";\nimport { z as z3 } from \"zod/v3\";\nimport {\n getInteropZodDefaultGetter,\n InteropZodType,\n} from \"@langchain/core/utils/types\";\nimport { SchemaMeta, withLangGraph } from \"./meta.js\";\n\nconst metaSymbol = Symbol.for(\"langgraph-zod\");\n\ninterface ZodLangGraphTypesV3<T extends z3.ZodTypeAny, Output> {\n reducer<Input = z3.output<T>>(\n transform: (a: Output, arg: Input) => Output,\n options?: z3.ZodType<Input>\n ): z3.ZodType<Output, z3.ZodEffectsDef<T>, Input>;\n\n metadata(payload: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\";\n\n [key: string]: unknown;\n }): T;\n}\n\ndeclare module \"zod\" {\n interface ZodType<Output> {\n /**\n * @deprecated Using the langgraph zod plugin is deprecated and will be removed in future versions\n * Consider upgrading to zod 4 and using the exported langgraph meta registry. {@link langgraphRegistry}\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n langgraph: ZodLangGraphTypesV3<any, Output>;\n }\n}\ndeclare module \"zod/v3\" {\n interface ZodType<Output> {\n /**\n * @deprecated Using the langgraph zod plugin is deprecated and will be removed in future versions\n * Consider upgrading to zod 4 and using the exported langgraph meta registry. {@link langgraphRegistry}\n */\n langgraph: ZodLangGraphTypesV3<this, Output>;\n }\n}\n\ninterface PluginGlobalType {\n [metaSymbol]?: WeakSet<object>;\n}\n\nif (!(metaSymbol in globalThis)) {\n (globalThis as PluginGlobalType)[metaSymbol] = new WeakSet();\n}\n\nfunction applyPluginPrototype(prototype: object) {\n const cache = (globalThis as PluginGlobalType)[metaSymbol]!;\n if (cache.has(prototype)) {\n return; // Already applied\n }\n\n Object.defineProperty(prototype, \"langgraph\", {\n get(this: InteropZodType) {\n // Actual return type is provided by module augmentation\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const zodThis = this;\n\n return {\n metadata(jsonSchemaExtra: SchemaMeta[\"jsonSchemaExtra\"]) {\n return withLangGraph(zodThis, { jsonSchemaExtra });\n },\n reducer(\n fn: (a: unknown, arg: unknown) => unknown,\n schema?: InteropZodType\n ) {\n const defaultFn = getInteropZodDefaultGetter(zodThis);\n return withLangGraph(zodThis, {\n default: defaultFn,\n reducer: { schema, fn },\n });\n },\n };\n },\n });\n cache.add(prototype);\n}\n\ntry {\n applyPluginPrototype(z3.ZodType.prototype);\n applyPluginPrototype(z4.ZodType.prototype);\n} catch (error) {\n throw new Error(\n \"Failed to extend Zod with LangGraph-related methods. This is most likely a bug, consider opening an issue and/or using `withLangGraph` to augment your Zod schema.\",\n { cause: error }\n );\n}\n"],"mappings":";;;;;AAQA,MAAM,aAAa,OAAO,IAAI,gBAAgB;AAwC9C,IAAI,EAAE,cAAc,YACjB,YAAgC,8BAAc,IAAI,SAAS;AAG9D,SAAS,qBAAqB,WAAmB;CAC/C,MAAM,QAAS,WAAgC;AAC/C,KAAI,MAAM,IAAI,UAAU,CACtB;AAGF,QAAO,eAAe,WAAW,aAAa,EAC5C,MAA0B;EAGxB,MAAM,UAAU;AAEhB,SAAO;GACL,SAAS,iBAAgD;AACvD,WAAOA,aAAAA,cAAc,SAAS,EAAE,iBAAiB,CAAC;;GAEpD,QACE,IACA,QACA;AAEA,WAAOA,aAAAA,cAAc,SAAS;KAC5B,UAAA,GAAA,4BAAA,4BAF2C,QAAQ;KAGnD,SAAS;MAAE;MAAQ;MAAI;KACxB,CAAC;;GAEL;IAEJ,CAAC;AACF,OAAM,IAAI,UAAU;;AAGtB,IAAI;AACF,sBAAqBC,OAAAA,EAAG,QAAQ,UAAU;AAC1C,sBAAqBC,OAAAA,EAAG,QAAQ,UAAU;SACnC,OAAO;AACd,OAAM,IAAI,MACR,sKACA,EAAE,OAAO,OAAO,CACjB"}
|
package/dist/graph/zod/plugin.js
CHANGED
|
@@ -2,7 +2,6 @@ import { withLangGraph } from "./meta.js";
|
|
|
2
2
|
import { z } from "zod/v4";
|
|
3
3
|
import { getInteropZodDefaultGetter } from "@langchain/core/utils/types";
|
|
4
4
|
import { z as z$1 } from "zod/v3";
|
|
5
|
-
|
|
6
5
|
//#region src/graph/zod/plugin.ts
|
|
7
6
|
const metaSymbol = Symbol.for("langgraph-zod");
|
|
8
7
|
if (!(metaSymbol in globalThis)) globalThis[metaSymbol] = /* @__PURE__ */ new WeakSet();
|
|
@@ -34,7 +33,7 @@ try {
|
|
|
34
33
|
} catch (error) {
|
|
35
34
|
throw new Error("Failed to extend Zod with LangGraph-related methods. This is most likely a bug, consider opening an issue and/or using `withLangGraph` to augment your Zod schema.", { cause: error });
|
|
36
35
|
}
|
|
37
|
-
|
|
38
36
|
//#endregion
|
|
39
|
-
export {
|
|
37
|
+
export {};
|
|
38
|
+
|
|
40
39
|
//# sourceMappingURL=plugin.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"plugin.js","names":["z3","z4"],"sources":["../../../src/graph/zod/plugin.ts"],"sourcesContent":["import { z as z4 } from \"zod/v4\";\nimport { z as z3 } from \"zod/v3\";\nimport {\n getInteropZodDefaultGetter,\n InteropZodType,\n} from \"@langchain/core/utils/types\";\nimport { SchemaMeta, withLangGraph } from \"./meta.js\";\n\nconst metaSymbol = Symbol.for(\"langgraph-zod\");\n\ninterface ZodLangGraphTypesV3<T extends z3.ZodTypeAny, Output> {\n reducer<Input = z3.output<T>>(\n transform: (a: Output, arg: Input) => Output,\n options?: z3.ZodType<Input>\n ): z3.ZodType<Output, z3.ZodEffectsDef<T>, Input>;\n\n metadata(payload: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\";\n\n [key: string]: unknown;\n }): T;\n}\n\ndeclare module \"zod\" {\n interface ZodType<Output> {\n /**\n * @deprecated Using the langgraph zod plugin is deprecated and will be removed in future versions\n * Consider upgrading to zod 4 and using the exported langgraph meta registry. {@link langgraphRegistry}\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n langgraph: ZodLangGraphTypesV3<any, Output>;\n }\n}\ndeclare module \"zod/v3\" {\n interface ZodType<Output> {\n /**\n * @deprecated Using the langgraph zod plugin is deprecated and will be removed in future versions\n * Consider upgrading to zod 4 and using the exported langgraph meta registry. {@link langgraphRegistry}\n */\n langgraph: ZodLangGraphTypesV3<this, Output>;\n }\n}\n\ninterface PluginGlobalType {\n [metaSymbol]?: WeakSet<object>;\n}\n\nif (!(metaSymbol in globalThis)) {\n (globalThis as PluginGlobalType)[metaSymbol] = new WeakSet();\n}\n\nfunction applyPluginPrototype(prototype: object) {\n const cache = (globalThis as PluginGlobalType)[metaSymbol]!;\n if (cache.has(prototype)) {\n return; // Already applied\n }\n\n Object.defineProperty(prototype, \"langgraph\", {\n get(this: InteropZodType) {\n // Actual return type is provided by module augmentation\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const zodThis = this;\n\n return {\n metadata(jsonSchemaExtra: SchemaMeta[\"jsonSchemaExtra\"]) {\n return withLangGraph(zodThis, { jsonSchemaExtra });\n },\n reducer(\n fn: (a: unknown, arg: unknown) => unknown,\n schema?: InteropZodType\n ) {\n const defaultFn = getInteropZodDefaultGetter(zodThis);\n return withLangGraph(zodThis, {\n default: defaultFn,\n reducer: { schema, fn },\n });\n },\n };\n },\n });\n cache.add(prototype);\n}\n\ntry {\n applyPluginPrototype(z3.ZodType.prototype);\n applyPluginPrototype(z4.ZodType.prototype);\n} catch (error) {\n throw new Error(\n \"Failed to extend Zod with LangGraph-related methods. This is most likely a bug, consider opening an issue and/or using `withLangGraph` to augment your Zod schema.\",\n { cause: error }\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"plugin.js","names":["z3","z4"],"sources":["../../../src/graph/zod/plugin.ts"],"sourcesContent":["import { z as z4 } from \"zod/v4\";\nimport { z as z3 } from \"zod/v3\";\nimport {\n getInteropZodDefaultGetter,\n InteropZodType,\n} from \"@langchain/core/utils/types\";\nimport { SchemaMeta, withLangGraph } from \"./meta.js\";\n\nconst metaSymbol = Symbol.for(\"langgraph-zod\");\n\ninterface ZodLangGraphTypesV3<T extends z3.ZodTypeAny, Output> {\n reducer<Input = z3.output<T>>(\n transform: (a: Output, arg: Input) => Output,\n options?: z3.ZodType<Input>\n ): z3.ZodType<Output, z3.ZodEffectsDef<T>, Input>;\n\n metadata(payload: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\";\n\n [key: string]: unknown;\n }): T;\n}\n\ndeclare module \"zod\" {\n interface ZodType<Output> {\n /**\n * @deprecated Using the langgraph zod plugin is deprecated and will be removed in future versions\n * Consider upgrading to zod 4 and using the exported langgraph meta registry. {@link langgraphRegistry}\n */\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n langgraph: ZodLangGraphTypesV3<any, Output>;\n }\n}\ndeclare module \"zod/v3\" {\n interface ZodType<Output> {\n /**\n * @deprecated Using the langgraph zod plugin is deprecated and will be removed in future versions\n * Consider upgrading to zod 4 and using the exported langgraph meta registry. {@link langgraphRegistry}\n */\n langgraph: ZodLangGraphTypesV3<this, Output>;\n }\n}\n\ninterface PluginGlobalType {\n [metaSymbol]?: WeakSet<object>;\n}\n\nif (!(metaSymbol in globalThis)) {\n (globalThis as PluginGlobalType)[metaSymbol] = new WeakSet();\n}\n\nfunction applyPluginPrototype(prototype: object) {\n const cache = (globalThis as PluginGlobalType)[metaSymbol]!;\n if (cache.has(prototype)) {\n return; // Already applied\n }\n\n Object.defineProperty(prototype, \"langgraph\", {\n get(this: InteropZodType) {\n // Actual return type is provided by module augmentation\n // eslint-disable-next-line @typescript-eslint/no-this-alias\n const zodThis = this;\n\n return {\n metadata(jsonSchemaExtra: SchemaMeta[\"jsonSchemaExtra\"]) {\n return withLangGraph(zodThis, { jsonSchemaExtra });\n },\n reducer(\n fn: (a: unknown, arg: unknown) => unknown,\n schema?: InteropZodType\n ) {\n const defaultFn = getInteropZodDefaultGetter(zodThis);\n return withLangGraph(zodThis, {\n default: defaultFn,\n reducer: { schema, fn },\n });\n },\n };\n },\n });\n cache.add(prototype);\n}\n\ntry {\n applyPluginPrototype(z3.ZodType.prototype);\n applyPluginPrototype(z4.ZodType.prototype);\n} catch (error) {\n throw new Error(\n \"Failed to extend Zod with LangGraph-related methods. This is most likely a bug, consider opening an issue and/or using `withLangGraph` to augment your Zod schema.\",\n { cause: error }\n );\n}\n"],"mappings":";;;;;AAQA,MAAM,aAAa,OAAO,IAAI,gBAAgB;AAwC9C,IAAI,EAAE,cAAc,YACjB,YAAgC,8BAAc,IAAI,SAAS;AAG9D,SAAS,qBAAqB,WAAmB;CAC/C,MAAM,QAAS,WAAgC;AAC/C,KAAI,MAAM,IAAI,UAAU,CACtB;AAGF,QAAO,eAAe,WAAW,aAAa,EAC5C,MAA0B;EAGxB,MAAM,UAAU;AAEhB,SAAO;GACL,SAAS,iBAAgD;AACvD,WAAO,cAAc,SAAS,EAAE,iBAAiB,CAAC;;GAEpD,QACE,IACA,QACA;AAEA,WAAO,cAAc,SAAS;KAC5B,SAFgB,2BAA2B,QAAQ;KAGnD,SAAS;MAAE;MAAQ;MAAI;KACxB,CAAC;;GAEL;IAEJ,CAAC;AACF,OAAM,IAAI,UAAU;;AAGtB,IAAI;AACF,sBAAqBA,IAAG,QAAQ,UAAU;AAC1C,sBAAqBC,EAAG,QAAQ,UAAU;SACnC,OAAO;AACd,OAAM,IAAI,MACR,sKACA,EAAE,OAAO,OAAO,CACjB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
Object.defineProperty(exports, Symbol.toStringTag, { value:
|
|
2
|
-
const require_meta = require(
|
|
1
|
+
Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
2
|
+
const require_meta = require("./meta.cjs");
|
|
3
3
|
let _langchain_core_utils_json_schema = require("@langchain/core/utils/json_schema");
|
|
4
|
-
|
|
5
4
|
//#region src/graph/zod/schema.ts
|
|
6
5
|
const PartialStateSchema = Symbol.for("langgraph.state.partial");
|
|
7
6
|
function isGraphWithZodLike(graph) {
|
|
@@ -13,8 +12,8 @@ function applyJsonSchemaExtrasFromDescription(schema) {
|
|
|
13
12
|
if (Array.isArray(schema)) return schema.map(applyJsonSchemaExtrasFromDescription);
|
|
14
13
|
if (typeof schema === "object" && schema != null) {
|
|
15
14
|
const output = Object.fromEntries(Object.entries(schema).map(([key, value]) => [key, applyJsonSchemaExtrasFromDescription(value)]));
|
|
16
|
-
if ("description" in output && typeof output.description === "string" && output.description.startsWith(
|
|
17
|
-
const strMeta = output.description.slice(
|
|
15
|
+
if ("description" in output && typeof output.description === "string" && output.description.startsWith("lg:")) {
|
|
16
|
+
const strMeta = output.description.slice(3);
|
|
18
17
|
delete output.description;
|
|
19
18
|
Object.assign(output, JSON.parse(strMeta));
|
|
20
19
|
}
|
|
@@ -89,11 +88,11 @@ function getConfigTypeSchema(graph, registry = require_meta.schemaMetaRegistry)
|
|
|
89
88
|
if (!configDef) return void 0;
|
|
90
89
|
return toJsonSchema(registry.getExtendedChannelSchemas(configDef, { withJsonSchemaExtrasAsDescription: true }));
|
|
91
90
|
}
|
|
92
|
-
|
|
93
91
|
//#endregion
|
|
94
92
|
exports.getConfigTypeSchema = getConfigTypeSchema;
|
|
95
93
|
exports.getInputTypeSchema = getInputTypeSchema;
|
|
96
94
|
exports.getOutputTypeSchema = getOutputTypeSchema;
|
|
97
95
|
exports.getStateTypeSchema = getStateTypeSchema;
|
|
98
96
|
exports.getUpdateTypeSchema = getUpdateTypeSchema;
|
|
97
|
+
|
|
99
98
|
//# sourceMappingURL=schema.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.cjs","names":["
|
|
1
|
+
{"version":3,"file":"schema.cjs","names":["schemaMetaRegistry"],"sources":["../../../src/graph/zod/schema.ts"],"sourcesContent":["import {\n type JSONSchema,\n toJsonSchema as interopToJsonSchema,\n} from \"@langchain/core/utils/json_schema\";\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\nimport {\n META_EXTRAS_DESCRIPTION_PREFIX,\n SchemaMetaRegistry,\n schemaMetaRegistry,\n} from \"./meta.js\";\n\nconst PartialStateSchema = Symbol.for(\"langgraph.state.partial\");\ntype PartialStateSchema = typeof PartialStateSchema;\n\ninterface GraphWithZodLike {\n builder: {\n _schemaRuntimeDefinition: InteropZodObject | undefined;\n _inputRuntimeDefinition: InteropZodObject | PartialStateSchema | undefined;\n _outputRuntimeDefinition: InteropZodObject | undefined;\n _configRuntimeSchema: InteropZodObject | undefined;\n };\n}\n\nfunction isGraphWithZodLike(graph: unknown): graph is GraphWithZodLike {\n if (!graph || typeof graph !== \"object\") return false;\n if (\n !(\"builder\" in graph) ||\n typeof graph.builder !== \"object\" ||\n graph.builder == null\n ) {\n return false;\n }\n return true;\n}\n\nfunction applyJsonSchemaExtrasFromDescription<T>(schema: T): unknown {\n if (Array.isArray(schema)) {\n return schema.map(applyJsonSchemaExtrasFromDescription);\n }\n if (typeof schema === \"object\" && schema != null) {\n const output = Object.fromEntries(\n Object.entries(schema).map(([key, value]) => [\n key,\n applyJsonSchemaExtrasFromDescription(value),\n ])\n );\n\n if (\n \"description\" in output &&\n typeof output.description === \"string\" &&\n output.description.startsWith(META_EXTRAS_DESCRIPTION_PREFIX)\n ) {\n const strMeta = output.description.slice(\n META_EXTRAS_DESCRIPTION_PREFIX.length\n );\n delete output.description;\n Object.assign(output, JSON.parse(strMeta));\n }\n\n return output as T;\n }\n return schema;\n}\n\nfunction toJsonSchema(schema: InteropZodObject): JSONSchema {\n return applyJsonSchemaExtrasFromDescription(\n interopToJsonSchema(schema)\n ) as JSONSchema;\n}\n\n/**\n * Get the state schema for a graph.\n * @param graph - The graph to get the state schema for.\n * @returns The state schema for the graph.\n */\nexport function getStateTypeSchema(\n graph: unknown,\n registry: SchemaMetaRegistry = schemaMetaRegistry\n): JSONSchema | undefined {\n if (!isGraphWithZodLike(graph)) return undefined;\n const schemaDef = graph.builder._schemaRuntimeDefinition;\n if (!schemaDef) return undefined;\n\n return toJsonSchema(\n registry.getExtendedChannelSchemas(schemaDef, {\n withJsonSchemaExtrasAsDescription: true,\n })\n );\n}\n\n/**\n * Get the update schema for a graph.\n * @param graph - The graph to get the update schema for.\n * @returns The update schema for the graph.\n */\nexport function getUpdateTypeSchema(\n graph: unknown,\n registry: SchemaMetaRegistry = schemaMetaRegistry\n): JSONSchema | undefined {\n if (!isGraphWithZodLike(graph)) return undefined;\n const schemaDef = graph.builder._schemaRuntimeDefinition;\n if (!schemaDef) return undefined;\n\n return toJsonSchema(\n registry.getExtendedChannelSchemas(schemaDef, {\n withReducerSchema: true,\n withJsonSchemaExtrasAsDescription: true,\n asPartial: true,\n })\n );\n}\n\n/**\n * Get the input schema for a graph.\n * @param graph - The graph to get the input schema for.\n * @returns The input schema for the graph.\n */\nexport function getInputTypeSchema(\n graph: unknown,\n registry: SchemaMetaRegistry = schemaMetaRegistry\n): JSONSchema | undefined {\n if (!isGraphWithZodLike(graph)) return undefined;\n let schemaDef = graph.builder._inputRuntimeDefinition;\n if (schemaDef === PartialStateSchema) {\n // No need to pass `.partial()` here, that's being done by `applyPlugin`\n schemaDef = graph.builder._schemaRuntimeDefinition;\n }\n if (!schemaDef) return undefined;\n\n return toJsonSchema(\n registry.getExtendedChannelSchemas(schemaDef, {\n withReducerSchema: true,\n withJsonSchemaExtrasAsDescription: true,\n asPartial: true,\n })\n );\n}\n\n/**\n * Get the output schema for a graph.\n * @param graph - The graph to get the output schema for.\n * @returns The output schema for the graph.\n */\nexport function getOutputTypeSchema(\n graph: unknown,\n registry: SchemaMetaRegistry = schemaMetaRegistry\n): JSONSchema | undefined {\n if (!isGraphWithZodLike(graph)) return undefined;\n const schemaDef = graph.builder._outputRuntimeDefinition;\n if (!schemaDef) return undefined;\n\n return toJsonSchema(\n registry.getExtendedChannelSchemas(schemaDef, {\n withJsonSchemaExtrasAsDescription: true,\n })\n );\n}\n\n/**\n * Get the config schema for a graph.\n * @param graph - The graph to get the config schema for.\n * @returns The config schema for the graph.\n */\nexport function getConfigTypeSchema(\n graph: unknown,\n registry: SchemaMetaRegistry = schemaMetaRegistry\n): JSONSchema | undefined {\n if (!isGraphWithZodLike(graph)) return undefined;\n const configDef = graph.builder._configRuntimeSchema;\n if (!configDef) return undefined;\n\n return toJsonSchema(\n registry.getExtendedChannelSchemas(configDef, {\n withJsonSchemaExtrasAsDescription: true,\n })\n );\n}\n"],"mappings":";;;;AAWA,MAAM,qBAAqB,OAAO,IAAI,0BAA0B;AAYhE,SAAS,mBAAmB,OAA2C;AACrE,KAAI,CAAC,SAAS,OAAO,UAAU,SAAU,QAAO;AAChD,KACE,EAAE,aAAa,UACf,OAAO,MAAM,YAAY,YACzB,MAAM,WAAW,KAEjB,QAAO;AAET,QAAO;;AAGT,SAAS,qCAAwC,QAAoB;AACnE,KAAI,MAAM,QAAQ,OAAO,CACvB,QAAO,OAAO,IAAI,qCAAqC;AAEzD,KAAI,OAAO,WAAW,YAAY,UAAU,MAAM;EAChD,MAAM,SAAS,OAAO,YACpB,OAAO,QAAQ,OAAO,CAAC,KAAK,CAAC,KAAK,WAAW,CAC3C,KACA,qCAAqC,MAAM,CAC5C,CAAC,CACH;AAED,M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YAAY,MAAM,QAAQ;AAChC,KAAI,CAAC,UAAW,QAAO,KAAA;AAEvB,QAAO,aACL,SAAS,0BAA0B,WAAW,EAC5C,mCAAmC,MACpC,CAAC,CACH;;;;;;;AAQH,SAAgB,oBACd,OACA,WAA+BA,aAAAA,oBACP;AACxB,KAAI,CAAC,mBAAmB,MAAM,CAAE,QAAO,KAAA;CACvC,MAAM,YAAY,MAAM,QAAQ;AAChC,KAAI,CAAC,UAAW,QAAO,KAAA;AAEvB,QAAO,aACL,SAAS,0BAA0B,WAAW,EAC5C,mCAAmC,MACpC,CAAC,CACH"}
|
package/dist/graph/zod/schema.js
CHANGED
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { schemaMetaRegistry } from "./meta.js";
|
|
2
2
|
import { toJsonSchema } from "@langchain/core/utils/json_schema";
|
|
3
|
-
|
|
4
3
|
//#region src/graph/zod/schema.ts
|
|
5
4
|
const PartialStateSchema = Symbol.for("langgraph.state.partial");
|
|
6
5
|
function isGraphWithZodLike(graph) {
|
|
@@ -12,8 +11,8 @@ function applyJsonSchemaExtrasFromDescription(schema) {
|
|
|
12
11
|
if (Array.isArray(schema)) return schema.map(applyJsonSchemaExtrasFromDescription);
|
|
13
12
|
if (typeof schema === "object" && schema != null) {
|
|
14
13
|
const output = Object.fromEntries(Object.entries(schema).map(([key, value]) => [key, applyJsonSchemaExtrasFromDescription(value)]));
|
|
15
|
-
if ("description" in output && typeof output.description === "string" && output.description.startsWith(
|
|
16
|
-
const strMeta = output.description.slice(
|
|
14
|
+
if ("description" in output && typeof output.description === "string" && output.description.startsWith("lg:")) {
|
|
15
|
+
const strMeta = output.description.slice(3);
|
|
17
16
|
delete output.description;
|
|
18
17
|
Object.assign(output, JSON.parse(strMeta));
|
|
19
18
|
}
|
|
@@ -88,7 +87,7 @@ function getConfigTypeSchema(graph, registry = schemaMetaRegistry) {
|
|
|
88
87
|
if (!configDef) return void 0;
|
|
89
88
|
return toJsonSchema$1(registry.getExtendedChannelSchemas(configDef, { withJsonSchemaExtrasAsDescription: true }));
|
|
90
89
|
}
|
|
91
|
-
|
|
92
90
|
//#endregion
|
|
93
91
|
export { getConfigTypeSchema, getInputTypeSchema, getOutputTypeSchema, getStateTypeSchema, getUpdateTypeSchema };
|
|
92
|
+
|
|
94
93
|
//# sourceMappingURL=schema.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"schema.js","names":["toJsonSchema","interopToJsonSchema"],"sources":["../../../src/graph/zod/schema.ts"],"sourcesContent":["import {\n type JSONSchema,\n toJsonSchema as interopToJsonSchema,\n} from \"@langchain/core/utils/json_schema\";\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\nimport {\n META_EXTRAS_DESCRIPTION_PREFIX,\n SchemaMetaRegistry,\n schemaMetaRegistry,\n} from \"./meta.js\";\n\nconst PartialStateSchema = Symbol.for(\"langgraph.state.partial\");\ntype PartialStateSchema = typeof PartialStateSchema;\n\ninterface GraphWithZodLike {\n builder: {\n _schemaRuntimeDefinition: InteropZodObject | undefined;\n _inputRuntimeDefinition: InteropZodObject | PartialStateSchema | undefined;\n _outputRuntimeDefinition: InteropZodObject | undefined;\n _configRuntimeSchema: InteropZodObject | undefined;\n };\n}\n\nfunction isGraphWithZodLike(graph: unknown): graph is GraphWithZodLike {\n if (!graph || typeof graph !== \"object\") return false;\n if (\n !(\"builder\" in graph) ||\n typeof graph.builder !== \"object\" ||\n graph.builder == null\n ) {\n return false;\n }\n return true;\n}\n\nfunction applyJsonSchemaExtrasFromDescription<T>(schema: T): unknown {\n if (Array.isArray(schema)) {\n return schema.map(applyJsonSchemaExtrasFromDescription);\n }\n if (typeof schema === \"object\" && schema != null) {\n const output = Object.fromEntries(\n Object.entries(schema).map(([key, value]) => [\n key,\n applyJsonSchemaExtrasFromDescription(value),\n ])\n );\n\n if (\n \"description\" in output &&\n typeof output.description === \"string\" &&\n output.description.startsWith(META_EXTRAS_DESCRIPTION_PREFIX)\n ) {\n const strMeta = output.description.slice(\n META_EXTRAS_DESCRIPTION_PREFIX.length\n );\n delete output.description;\n Object.assign(output, JSON.parse(strMeta));\n }\n\n return output as T;\n }\n return schema;\n}\n\nfunction toJsonSchema(schema: InteropZodObject): JSONSchema {\n return applyJsonSchemaExtrasFromDescription(\n interopToJsonSchema(schema)\n ) as JSONSchema;\n}\n\n/**\n * Get the state schema for a graph.\n * @param graph - The graph to get the state schema for.\n * @returns The state schema for the graph.\n */\nexport function getStateTypeSchema(\n graph: unknown,\n registry: SchemaMetaRegistry = schemaMetaRegistry\n): JSONSchema | undefined {\n if (!isGraphWithZodLike(graph)) return undefined;\n const schemaDef = graph.builder._schemaRuntimeDefinition;\n if (!schemaDef) return undefined;\n\n return toJsonSchema(\n registry.getExtendedChannelSchemas(schemaDef, {\n withJsonSchemaExtrasAsDescription: true,\n })\n );\n}\n\n/**\n * Get the update schema for a graph.\n * @param graph - The graph to get the update schema for.\n * @returns The update schema for the graph.\n */\nexport function getUpdateTypeSchema(\n graph: unknown,\n registry: SchemaMetaRegistry = schemaMetaRegistry\n): JSONSchema | undefined {\n if (!isGraphWithZodLike(graph)) return undefined;\n const schemaDef = graph.builder._schemaRuntimeDefinition;\n if (!schemaDef) return undefined;\n\n return toJsonSchema(\n registry.getExtendedChannelSchemas(schemaDef, {\n withReducerSchema: true,\n withJsonSchemaExtrasAsDescription: true,\n asPartial: true,\n })\n );\n}\n\n/**\n * Get the input schema for a graph.\n * @param graph - The graph to get the input schema for.\n * @returns The input schema for the graph.\n */\nexport function getInputTypeSchema(\n graph: unknown,\n registry: SchemaMetaRegistry = schemaMetaRegistry\n): JSONSchema | undefined {\n if (!isGraphWithZodLike(graph)) return undefined;\n let schemaDef = graph.builder._inputRuntimeDefinition;\n if (schemaDef === PartialStateSchema) {\n // No need to pass `.partial()` here, that's being done by `applyPlugin`\n schemaDef = graph.builder._schemaRuntimeDefinition;\n }\n if (!schemaDef) return undefined;\n\n return toJsonSchema(\n registry.getExtendedChannelSchemas(schemaDef, {\n withReducerSchema: true,\n withJsonSchemaExtrasAsDescription: true,\n asPartial: true,\n })\n );\n}\n\n/**\n * Get the output schema for a graph.\n * @param graph - The graph to get the output schema for.\n * @returns The output schema for the graph.\n */\nexport function getOutputTypeSchema(\n graph: unknown,\n registry: SchemaMetaRegistry = schemaMetaRegistry\n): JSONSchema | undefined {\n if (!isGraphWithZodLike(graph)) return undefined;\n const schemaDef = graph.builder._outputRuntimeDefinition;\n if (!schemaDef) return undefined;\n\n return toJsonSchema(\n registry.getExtendedChannelSchemas(schemaDef, {\n withJsonSchemaExtrasAsDescription: true,\n })\n );\n}\n\n/**\n * Get the config schema for a graph.\n * @param graph - The graph to get the config schema for.\n * @returns The config schema for the graph.\n */\nexport function getConfigTypeSchema(\n graph: unknown,\n registry: SchemaMetaRegistry = schemaMetaRegistry\n): JSONSchema | undefined {\n if (!isGraphWithZodLike(graph)) return undefined;\n const configDef = graph.builder._configRuntimeSchema;\n if (!configDef) return undefined;\n\n return toJsonSchema(\n registry.getExtendedChannelSchemas(configDef, {\n withJsonSchemaExtrasAsDescription: true,\n })\n );\n}\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"schema.js","names":["toJsonSchema","interopToJsonSchema"],"sources":["../../../src/graph/zod/schema.ts"],"sourcesContent":["import {\n type JSONSchema,\n toJsonSchema as interopToJsonSchema,\n} from \"@langchain/core/utils/json_schema\";\nimport { InteropZodObject } from \"@langchain/core/utils/types\";\nimport {\n META_EXTRAS_DESCRIPTION_PREFIX,\n SchemaMetaRegistry,\n schemaMetaRegistry,\n} from \"./meta.js\";\n\nconst PartialStateSchema = Symbol.for(\"langgraph.state.partial\");\ntype PartialStateSchema = typeof PartialStateSchema;\n\ninterface GraphWithZodLike {\n builder: {\n _schemaRuntimeDefinition: InteropZodObject | undefined;\n _inputRuntimeDefinition: InteropZodObject | PartialStateSchema | undefined;\n _outputRuntimeDefinition: InteropZodObject | undefined;\n _configRuntimeSchema: InteropZodObject | undefined;\n };\n}\n\nfunction isGraphWithZodLike(graph: unknown): graph is GraphWithZodLike {\n if (!graph || typeof graph !== \"object\") return false;\n if (\n !(\"builder\" in graph) ||\n typeof graph.builder !== \"object\" ||\n graph.builder == null\n ) {\n return false;\n }\n return true;\n}\n\nfunction applyJsonSchemaExtrasFromDescription<T>(schema: T): unknown {\n if (Array.isArray(schema)) {\n return schema.map(applyJsonSchemaExtrasFromDescription);\n }\n if (typeof schema === \"object\" && schema != null) {\n const output = Object.fromEntries(\n Object.entries(schema).map(([key, value]) => [\n key,\n applyJsonSchemaExtrasFromDescription(value),\n ])\n );\n\n if (\n \"description\" in output &&\n typeof output.description === \"string\" &&\n output.description.startsWith(META_EXTRAS_DESCRIPTION_PREFIX)\n ) {\n const strMeta = output.description.slice(\n META_EXTRAS_DESCRIPTION_PREFIX.length\n );\n delete output.description;\n Object.assign(output, JSON.parse(strMeta));\n }\n\n return output as T;\n }\n return schema;\n}\n\nfunction toJsonSchema(schema: InteropZodObject): JSONSchema {\n return applyJsonSchemaExtrasFromDescription(\n interopToJsonSchema(schema)\n ) as JSONSchema;\n}\n\n/**\n * Get the state schema for a graph.\n * @param graph - The graph to get the state schema for.\n * @returns The state schema for the graph.\n */\nexport function getStateTypeSchema(\n graph: unknown,\n registry: SchemaMetaRegistry = schemaMetaRegistry\n): JSONSchema | undefined {\n if (!isGraphWithZodLike(graph)) return undefined;\n const schemaDef = graph.builder._schemaRuntimeDefinition;\n if (!schemaDef) return undefined;\n\n return toJsonSchema(\n registry.getExtendedChannelSchemas(schemaDef, {\n withJsonSchemaExtrasAsDescription: true,\n })\n );\n}\n\n/**\n * Get the update schema for a graph.\n * @param graph - The graph to get the update schema for.\n * @returns The update schema for the graph.\n */\nexport function getUpdateTypeSchema(\n graph: unknown,\n registry: SchemaMetaRegistry = schemaMetaRegistry\n): JSONSchema | undefined {\n if (!isGraphWithZodLike(graph)) return undefined;\n const schemaDef = graph.builder._schemaRuntimeDefinition;\n if (!schemaDef) return undefined;\n\n return toJsonSchema(\n registry.getExtendedChannelSchemas(schemaDef, {\n withReducerSchema: true,\n withJsonSchemaExtrasAsDescription: true,\n asPartial: true,\n })\n );\n}\n\n/**\n * Get the input schema for a graph.\n * @param graph - The graph to get the input schema for.\n * @returns The input schema for the graph.\n */\nexport function getInputTypeSchema(\n graph: unknown,\n registry: SchemaMetaRegistry = schemaMetaRegistry\n): JSONSchema | undefined {\n if (!isGraphWithZodLike(graph)) return undefined;\n let schemaDef = graph.builder._inputRuntimeDefinition;\n if (schemaDef === PartialStateSchema) {\n // No need to pass `.partial()` here, that's being done by `applyPlugin`\n schemaDef = graph.builder._schemaRuntimeDefinition;\n }\n if (!schemaDef) return undefined;\n\n return toJsonSchema(\n registry.getExtendedChannelSchemas(schemaDef, {\n withReducerSchema: true,\n withJsonSchemaExtrasAsDescription: true,\n asPartial: true,\n })\n );\n}\n\n/**\n * Get the output schema for a graph.\n * @param graph - The graph to get the output schema for.\n * @returns The output schema for the graph.\n */\nexport function getOutputTypeSchema(\n graph: unknown,\n registry: SchemaMetaRegistry = schemaMetaRegistry\n): JSONSchema | undefined {\n if (!isGraphWithZodLike(graph)) return undefined;\n const schemaDef = graph.builder._outputRuntimeDefinition;\n if (!schemaDef) return undefined;\n\n return toJsonSchema(\n registry.getExtendedChannelSchemas(schemaDef, {\n withJsonSchemaExtrasAsDescription: true,\n })\n );\n}\n\n/**\n * Get the config schema for a graph.\n * @param graph - The graph to get the config schema for.\n * @returns The config schema for the graph.\n */\nexport function getConfigTypeSchema(\n graph: unknown,\n registry: SchemaMetaRegistry = schemaMetaRegistry\n): JSONSchema | undefined {\n if (!isGraphWithZodLike(graph)) return undefined;\n const configDef = graph.builder._configRuntimeSchema;\n if (!configDef) return undefined;\n\n return toJsonSchema(\n registry.getExtendedChannelSchemas(configDef, {\n withJsonSchemaExtrasAsDescription: true,\n })\n );\n}\n"],"mappings":";;;AAWA,MAAM,qBAAqB,OAAO,IAAI,0BAA0B;AAYhE,SAAS,mBAAmB,OAA2C;AACrE,KAAI,C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B,MAAM,CAAE,QAAO,KAAA;CACvC,IAAI,YAAY,MAAM,QAAQ;AAC9B,KAAI,cAAc,mBAEhB,aAAY,MAAM,QAAQ;AAE5B,KAAI,CAAC,UAAW,QAAO,KAAA;AAEvB,QAAOA,eACL,SAAS,0BAA0B,WAAW;EAC5C,mBAAmB;EACnB,mCAAmC;EACnC,WAAW;EACZ,CAAC,CACH;;;;;;;AAQH,SAAgB,oBACd,OACA,WAA+B,oBACP;AACxB,KAAI,CAAC,mBAAmB,MAAM,CAAE,QAAO,KAAA;CACvC,MAAM,YAAY,MAAM,QAAQ;AAChC,KAAI,CAAC,UAAW,QAAO,KAAA;AAEvB,QAAOA,eACL,SAAS,0BAA0B,WAAW,EAC5C,mCAAmC,MACpC,CAAC,CACH;;;;;;;AAQH,SAAgB,oBACd,OACA,WAA+B,oBACP;AACxB,KAAI,CAAC,mBAAmB,MAAM,CAAE,QAAO,KAAA;CACvC,MAAM,YAAY,MAAM,QAAQ;AAChC,KAAI,CAAC,UAAW,QAAO,KAAA;AAEvB,QAAOA,eACL,SAAS,0BAA0B,WAAW,EAC5C,mCAAmC,MACpC,CAAC,CACH"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
|
-
const require_meta = require(
|
|
1
|
+
const require_meta = require("./meta.cjs");
|
|
2
2
|
let _langchain_core_utils_types = require("@langchain/core/utils/types");
|
|
3
3
|
let zod_v4_core = require("zod/v4/core");
|
|
4
|
-
|
|
5
4
|
//#region src/graph/zod/zod-registry.ts
|
|
6
5
|
/**
|
|
7
6
|
* A Zod v4-compatible meta registry that extends the base registry.
|
|
@@ -35,8 +34,8 @@ var LanggraphZodMetaRegistry = class extends zod_v4_core.$ZodRegistry {
|
|
|
35
34
|
}
|
|
36
35
|
};
|
|
37
36
|
const registry = new LanggraphZodMetaRegistry(require_meta.schemaMetaRegistry);
|
|
38
|
-
|
|
39
37
|
//#endregion
|
|
40
38
|
exports.LanggraphZodMetaRegistry = LanggraphZodMetaRegistry;
|
|
41
39
|
exports.registry = registry;
|
|
40
|
+
|
|
42
41
|
//# sourceMappingURL=zod-registry.cjs.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-registry.cjs","names":["$ZodRegistry","schemaMetaRegistry"],"sources":["../../../src/graph/zod/zod-registry.ts"],"sourcesContent":["// @ts-expect-error If zod/v4 is not imported, the module augmentation will fail in build\nimport type { ZodType } from \"zod/v4\"; // eslint-disable-line @typescript-eslint/no-unused-vars\n\n// @ts-expect-error If zod/v4-mini is not imported, the module augmentation will fail in build\nimport type { ZodMiniType } from \"zod/v4-mini\"; // eslint-disable-line @typescript-eslint/no-unused-vars\n\nimport type * as core from \"zod/v4/core\";\nimport { getInteropZodDefaultGetter } from \"@langchain/core/utils/types\";\nimport { $ZodType, $ZodRegistry, $replace } from \"zod/v4/core\";\nimport {\n type ReducedZodChannel,\n type SchemaMeta,\n type SchemaMetaRegistry,\n schemaMetaRegistry,\n} from \"./meta.js\";\n\n/**\n * A Zod v4-compatible meta registry that extends the base registry.\n *\n * This registry allows you to associate and retrieve metadata for Zod schemas,\n * leveraging the base registry for storage. It is compatible with Zod v4 and\n * interoperates with the base registry to ensure consistent metadata management\n * across different Zod versions.\n *\n * @template Meta - The type of metadata associated with each schema.\n * @template Schema - The Zod schema type.\n */\nexport class LanggraphZodMetaRegistry<\n Meta extends SchemaMeta = SchemaMeta,\n Schema extends $ZodType = $ZodType\n> extends $ZodRegistry<Meta & { [key: string]: unknown }, Schema> {\n /**\n * Creates a new LanggraphZodMetaRegistry instance.\n *\n * @param parent - The base SchemaMetaRegistry to use for metadata storage.\n */\n constructor(protected parent: SchemaMetaRegistry) {\n super();\n // Use the parent's map for metadata storage\n this._map = this.parent._map as Map<\n Schema,\n $replace<Meta & { [key: string]: unknown }, Schema>\n >;\n }\n\n add<S extends Schema>(\n schema: S,\n ..._meta: undefined extends Meta & { [key: string]: unknown }\n ? [$replace<Meta & { [key: string]: unknown }, S>?]\n : [$replace<Meta & { [key: string]: unknown }, S>]\n ): this {\n const firstMeta = _meta[0];\n if (firstMeta && !firstMeta?.default) {\n const defaultValueGetter = getInteropZodDefaultGetter(schema);\n if (defaultValueGetter != null) {\n // eslint-disable-next-line no-param-reassign\n firstMeta.default = defaultValueGetter;\n }\n }\n return super.add(schema, ..._meta);\n }\n}\n\n// Augment the zod/v4 module nudging the `register` method\n// to use the user provided input schema if specified.\ndeclare module \"zod/v4\" {\n export interface ZodType<\n out Output = unknown,\n out Input = unknown,\n out Internals extends core.$ZodTypeInternals<\n Output,\n Input\n > = core.$ZodTypeInternals<Output, Input>\n > extends core.$ZodType<Output, Input, Internals> {\n register<\n R extends LanggraphZodMetaRegistry,\n TOutput = core.output<this>,\n TInput = core.input<this>,\n TInternals extends core.$ZodTypeInternals<\n TOutput,\n TInput\n > = core.$ZodTypeInternals<TOutput, TInput>\n >(\n registry: R,\n meta: SchemaMeta<TOutput, TInput>\n ): ReducedZodChannel<this, ZodType<TOutput, TInput, TInternals>>;\n }\n}\n\ndeclare module \"zod/v4-mini\" {\n export interface ZodMiniType<\n out Output = unknown,\n out Input = unknown,\n out Internals extends core.$ZodTypeInternals<\n Output,\n Input\n > = core.$ZodTypeInternals<Output, Input>\n > extends core.$ZodType<Output, Input, Internals> {\n register<\n R extends LanggraphZodMetaRegistry,\n TOutput = core.output<this>,\n TInput = core.input<this>,\n TInternals extends core.$ZodTypeInternals<\n TOutput,\n TInput\n > = core.$ZodTypeInternals<TOutput, TInput>\n >(\n registry: R,\n meta: SchemaMeta<TOutput, TInput>\n ): ReducedZodChannel<this, ZodMiniType<TOutput, TInput, TInternals>>;\n }\n}\n\nexport const registry = new LanggraphZodMetaRegistry(schemaMetaRegistry);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"zod-registry.cjs","names":["$ZodRegistry","schemaMetaRegistry"],"sources":["../../../src/graph/zod/zod-registry.ts"],"sourcesContent":["// @ts-expect-error If zod/v4 is not imported, the module augmentation will fail in build\nimport type { ZodType } from \"zod/v4\"; // eslint-disable-line @typescript-eslint/no-unused-vars\n\n// @ts-expect-error If zod/v4-mini is not imported, the module augmentation will fail in build\nimport type { ZodMiniType } from \"zod/v4-mini\"; // eslint-disable-line @typescript-eslint/no-unused-vars\n\nimport type * as core from \"zod/v4/core\";\nimport { getInteropZodDefaultGetter } from \"@langchain/core/utils/types\";\nimport { $ZodType, $ZodRegistry, $replace } from \"zod/v4/core\";\nimport {\n type ReducedZodChannel,\n type SchemaMeta,\n type SchemaMetaRegistry,\n schemaMetaRegistry,\n} from \"./meta.js\";\n\n/**\n * A Zod v4-compatible meta registry that extends the base registry.\n *\n * This registry allows you to associate and retrieve metadata for Zod schemas,\n * leveraging the base registry for storage. It is compatible with Zod v4 and\n * interoperates with the base registry to ensure consistent metadata management\n * across different Zod versions.\n *\n * @template Meta - The type of metadata associated with each schema.\n * @template Schema - The Zod schema type.\n */\nexport class LanggraphZodMetaRegistry<\n Meta extends SchemaMeta = SchemaMeta,\n Schema extends $ZodType = $ZodType\n> extends $ZodRegistry<Meta & { [key: string]: unknown }, Schema> {\n /**\n * Creates a new LanggraphZodMetaRegistry instance.\n *\n * @param parent - The base SchemaMetaRegistry to use for metadata storage.\n */\n constructor(protected parent: SchemaMetaRegistry) {\n super();\n // Use the parent's map for metadata storage\n this._map = this.parent._map as Map<\n Schema,\n $replace<Meta & { [key: string]: unknown }, Schema>\n >;\n }\n\n add<S extends Schema>(\n schema: S,\n ..._meta: undefined extends Meta & { [key: string]: unknown }\n ? [$replace<Meta & { [key: string]: unknown }, S>?]\n : [$replace<Meta & { [key: string]: unknown }, S>]\n ): this {\n const firstMeta = _meta[0];\n if (firstMeta && !firstMeta?.default) {\n const defaultValueGetter = getInteropZodDefaultGetter(schema);\n if (defaultValueGetter != null) {\n // eslint-disable-next-line no-param-reassign\n firstMeta.default = defaultValueGetter;\n }\n }\n return super.add(schema, ..._meta);\n }\n}\n\n// Augment the zod/v4 module nudging the `register` method\n// to use the user provided input schema if specified.\ndeclare module \"zod/v4\" {\n export interface ZodType<\n out Output = unknown,\n out Input = unknown,\n out Internals extends core.$ZodTypeInternals<\n Output,\n Input\n > = core.$ZodTypeInternals<Output, Input>\n > extends core.$ZodType<Output, Input, Internals> {\n register<\n R extends LanggraphZodMetaRegistry,\n TOutput = core.output<this>,\n TInput = core.input<this>,\n TInternals extends core.$ZodTypeInternals<\n TOutput,\n TInput\n > = core.$ZodTypeInternals<TOutput, TInput>\n >(\n registry: R,\n meta: SchemaMeta<TOutput, TInput>\n ): ReducedZodChannel<this, ZodType<TOutput, TInput, TInternals>>;\n }\n}\n\ndeclare module \"zod/v4-mini\" {\n export interface ZodMiniType<\n out Output = unknown,\n out Input = unknown,\n out Internals extends core.$ZodTypeInternals<\n Output,\n Input\n > = core.$ZodTypeInternals<Output, Input>\n > extends core.$ZodType<Output, Input, Internals> {\n register<\n R extends LanggraphZodMetaRegistry,\n TOutput = core.output<this>,\n TInput = core.input<this>,\n TInternals extends core.$ZodTypeInternals<\n TOutput,\n TInput\n > = core.$ZodTypeInternals<TOutput, TInput>\n >(\n registry: R,\n meta: SchemaMeta<TOutput, TInput>\n ): ReducedZodChannel<this, ZodMiniType<TOutput, TInput, TInternals>>;\n }\n}\n\nexport const registry = new LanggraphZodMetaRegistry(schemaMetaRegistry);\n"],"mappings":";;;;;;;;;;;;;;;AA2BA,IAAa,2BAAb,cAGUA,YAAAA,aAAwD;;;;;;CAMhE,YAAY,QAAsC;AAChD,SAAO;AADa,OAAA,SAAA;AAGpB,OAAK,OAAO,KAAK,OAAO;;CAM1B,IACE,QACA,GAAG,OAGG;EACN,MAAM,YAAY,MAAM;AACxB,MAAI,aAAa,CAAC,WAAW,SAAS;GACpC,MAAM,sBAAA,GAAA,4BAAA,4BAAgD,OAAO;AAC7D,OAAI,sBAAsB,KAExB,WAAU,UAAU;;AAGxB,SAAO,MAAM,IAAI,QAAQ,GAAG,MAAM;;;AAsDtC,MAAa,WAAW,IAAI,yBAAyBC,aAAAA,mBAAmB"}
|
|
@@ -1,7 +1,6 @@
|
|
|
1
1
|
import { schemaMetaRegistry } from "./meta.js";
|
|
2
2
|
import { getInteropZodDefaultGetter } from "@langchain/core/utils/types";
|
|
3
3
|
import { $ZodRegistry } from "zod/v4/core";
|
|
4
|
-
|
|
5
4
|
//#region src/graph/zod/zod-registry.ts
|
|
6
5
|
/**
|
|
7
6
|
* A Zod v4-compatible meta registry that extends the base registry.
|
|
@@ -35,7 +34,7 @@ var LanggraphZodMetaRegistry = class extends $ZodRegistry {
|
|
|
35
34
|
}
|
|
36
35
|
};
|
|
37
36
|
const registry = new LanggraphZodMetaRegistry(schemaMetaRegistry);
|
|
38
|
-
|
|
39
37
|
//#endregion
|
|
40
38
|
export { LanggraphZodMetaRegistry, registry };
|
|
39
|
+
|
|
41
40
|
//# sourceMappingURL=zod-registry.js.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-registry.js","names":[],"sources":["../../../src/graph/zod/zod-registry.ts"],"sourcesContent":["// @ts-expect-error If zod/v4 is not imported, the module augmentation will fail in build\nimport type { ZodType } from \"zod/v4\"; // eslint-disable-line @typescript-eslint/no-unused-vars\n\n// @ts-expect-error If zod/v4-mini is not imported, the module augmentation will fail in build\nimport type { ZodMiniType } from \"zod/v4-mini\"; // eslint-disable-line @typescript-eslint/no-unused-vars\n\nimport type * as core from \"zod/v4/core\";\nimport { getInteropZodDefaultGetter } from \"@langchain/core/utils/types\";\nimport { $ZodType, $ZodRegistry, $replace } from \"zod/v4/core\";\nimport {\n type ReducedZodChannel,\n type SchemaMeta,\n type SchemaMetaRegistry,\n schemaMetaRegistry,\n} from \"./meta.js\";\n\n/**\n * A Zod v4-compatible meta registry that extends the base registry.\n *\n * This registry allows you to associate and retrieve metadata for Zod schemas,\n * leveraging the base registry for storage. It is compatible with Zod v4 and\n * interoperates with the base registry to ensure consistent metadata management\n * across different Zod versions.\n *\n * @template Meta - The type of metadata associated with each schema.\n * @template Schema - The Zod schema type.\n */\nexport class LanggraphZodMetaRegistry<\n Meta extends SchemaMeta = SchemaMeta,\n Schema extends $ZodType = $ZodType\n> extends $ZodRegistry<Meta & { [key: string]: unknown }, Schema> {\n /**\n * Creates a new LanggraphZodMetaRegistry instance.\n *\n * @param parent - The base SchemaMetaRegistry to use for metadata storage.\n */\n constructor(protected parent: SchemaMetaRegistry) {\n super();\n // Use the parent's map for metadata storage\n this._map = this.parent._map as Map<\n Schema,\n $replace<Meta & { [key: string]: unknown }, Schema>\n >;\n }\n\n add<S extends Schema>(\n schema: S,\n ..._meta: undefined extends Meta & { [key: string]: unknown }\n ? [$replace<Meta & { [key: string]: unknown }, S>?]\n : [$replace<Meta & { [key: string]: unknown }, S>]\n ): this {\n const firstMeta = _meta[0];\n if (firstMeta && !firstMeta?.default) {\n const defaultValueGetter = getInteropZodDefaultGetter(schema);\n if (defaultValueGetter != null) {\n // eslint-disable-next-line no-param-reassign\n firstMeta.default = defaultValueGetter;\n }\n }\n return super.add(schema, ..._meta);\n }\n}\n\n// Augment the zod/v4 module nudging the `register` method\n// to use the user provided input schema if specified.\ndeclare module \"zod/v4\" {\n export interface ZodType<\n out Output = unknown,\n out Input = unknown,\n out Internals extends core.$ZodTypeInternals<\n Output,\n Input\n > = core.$ZodTypeInternals<Output, Input>\n > extends core.$ZodType<Output, Input, Internals> {\n register<\n R extends LanggraphZodMetaRegistry,\n TOutput = core.output<this>,\n TInput = core.input<this>,\n TInternals extends core.$ZodTypeInternals<\n TOutput,\n TInput\n > = core.$ZodTypeInternals<TOutput, TInput>\n >(\n registry: R,\n meta: SchemaMeta<TOutput, TInput>\n ): ReducedZodChannel<this, ZodType<TOutput, TInput, TInternals>>;\n }\n}\n\ndeclare module \"zod/v4-mini\" {\n export interface ZodMiniType<\n out Output = unknown,\n out Input = unknown,\n out Internals extends core.$ZodTypeInternals<\n Output,\n Input\n > = core.$ZodTypeInternals<Output, Input>\n > extends core.$ZodType<Output, Input, Internals> {\n register<\n R extends LanggraphZodMetaRegistry,\n TOutput = core.output<this>,\n TInput = core.input<this>,\n TInternals extends core.$ZodTypeInternals<\n TOutput,\n TInput\n > = core.$ZodTypeInternals<TOutput, TInput>\n >(\n registry: R,\n meta: SchemaMeta<TOutput, TInput>\n ): ReducedZodChannel<this, ZodMiniType<TOutput, TInput, TInternals>>;\n }\n}\n\nexport const registry = new LanggraphZodMetaRegistry(schemaMetaRegistry);\n"],"mappings":"
|
|
1
|
+
{"version":3,"file":"zod-registry.js","names":[],"sources":["../../../src/graph/zod/zod-registry.ts"],"sourcesContent":["// @ts-expect-error If zod/v4 is not imported, the module augmentation will fail in build\nimport type { ZodType } from \"zod/v4\"; // eslint-disable-line @typescript-eslint/no-unused-vars\n\n// @ts-expect-error If zod/v4-mini is not imported, the module augmentation will fail in build\nimport type { ZodMiniType } from \"zod/v4-mini\"; // eslint-disable-line @typescript-eslint/no-unused-vars\n\nimport type * as core from \"zod/v4/core\";\nimport { getInteropZodDefaultGetter } from \"@langchain/core/utils/types\";\nimport { $ZodType, $ZodRegistry, $replace } from \"zod/v4/core\";\nimport {\n type ReducedZodChannel,\n type SchemaMeta,\n type SchemaMetaRegistry,\n schemaMetaRegistry,\n} from \"./meta.js\";\n\n/**\n * A Zod v4-compatible meta registry that extends the base registry.\n *\n * This registry allows you to associate and retrieve metadata for Zod schemas,\n * leveraging the base registry for storage. It is compatible with Zod v4 and\n * interoperates with the base registry to ensure consistent metadata management\n * across different Zod versions.\n *\n * @template Meta - The type of metadata associated with each schema.\n * @template Schema - The Zod schema type.\n */\nexport class LanggraphZodMetaRegistry<\n Meta extends SchemaMeta = SchemaMeta,\n Schema extends $ZodType = $ZodType\n> extends $ZodRegistry<Meta & { [key: string]: unknown }, Schema> {\n /**\n * Creates a new LanggraphZodMetaRegistry instance.\n *\n * @param parent - The base SchemaMetaRegistry to use for metadata storage.\n */\n constructor(protected parent: SchemaMetaRegistry) {\n super();\n // Use the parent's map for metadata storage\n this._map = this.parent._map as Map<\n Schema,\n $replace<Meta & { [key: string]: unknown }, Schema>\n >;\n }\n\n add<S extends Schema>(\n schema: S,\n ..._meta: undefined extends Meta & { [key: string]: unknown }\n ? [$replace<Meta & { [key: string]: unknown }, S>?]\n : [$replace<Meta & { [key: string]: unknown }, S>]\n ): this {\n const firstMeta = _meta[0];\n if (firstMeta && !firstMeta?.default) {\n const defaultValueGetter = getInteropZodDefaultGetter(schema);\n if (defaultValueGetter != null) {\n // eslint-disable-next-line no-param-reassign\n firstMeta.default = defaultValueGetter;\n }\n }\n return super.add(schema, ..._meta);\n }\n}\n\n// Augment the zod/v4 module nudging the `register` method\n// to use the user provided input schema if specified.\ndeclare module \"zod/v4\" {\n export interface ZodType<\n out Output = unknown,\n out Input = unknown,\n out Internals extends core.$ZodTypeInternals<\n Output,\n Input\n > = core.$ZodTypeInternals<Output, Input>\n > extends core.$ZodType<Output, Input, Internals> {\n register<\n R extends LanggraphZodMetaRegistry,\n TOutput = core.output<this>,\n TInput = core.input<this>,\n TInternals extends core.$ZodTypeInternals<\n TOutput,\n TInput\n > = core.$ZodTypeInternals<TOutput, TInput>\n >(\n registry: R,\n meta: SchemaMeta<TOutput, TInput>\n ): ReducedZodChannel<this, ZodType<TOutput, TInput, TInternals>>;\n }\n}\n\ndeclare module \"zod/v4-mini\" {\n export interface ZodMiniType<\n out Output = unknown,\n out Input = unknown,\n out Internals extends core.$ZodTypeInternals<\n Output,\n Input\n > = core.$ZodTypeInternals<Output, Input>\n > extends core.$ZodType<Output, Input, Internals> {\n register<\n R extends LanggraphZodMetaRegistry,\n TOutput = core.output<this>,\n TInput = core.input<this>,\n TInternals extends core.$ZodTypeInternals<\n TOutput,\n TInput\n > = core.$ZodTypeInternals<TOutput, TInput>\n >(\n registry: R,\n meta: SchemaMeta<TOutput, TInput>\n ): ReducedZodChannel<this, ZodMiniType<TOutput, TInput, TInternals>>;\n }\n}\n\nexport const registry = new LanggraphZodMetaRegistry(schemaMetaRegistry);\n"],"mappings":";;;;;;;;;;;;;;;AA2BA,IAAa,2BAAb,cAGU,aAAwD;;;;;;CAMhE,YAAY,QAAsC;AAChD,SAAO;AADa,OAAA,SAAA;AAGpB,OAAK,OAAO,KAAK,OAAO;;CAM1B,IACE,QACA,GAAG,OAGG;EACN,MAAM,YAAY,MAAM;AACxB,MAAI,aAAa,CAAC,WAAW,SAAS;GACpC,MAAM,qBAAqB,2BAA2B,OAAO;AAC7D,OAAI,sBAAsB,KAExB,WAAU,UAAU;;AAGxB,SAAO,MAAM,IAAI,QAAQ,GAAG,MAAM;;;AAsDtC,MAAa,WAAW,IAAI,yBAAyB,mBAAmB"}
|
package/dist/hash.cjs
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
|
|
2
1
|
//#region src/hash.ts
|
|
3
2
|
const n = (n) => BigInt(n);
|
|
4
3
|
const view = (data, offset = 0) => new DataView(data.buffer, data.byteOffset + offset, data.byteLength - offset);
|
|
@@ -258,8 +257,8 @@ function XXH3(input, seed = n(0)) {
|
|
|
258
257
|
function isXXH3(value) {
|
|
259
258
|
return /^[0-9a-f]{32}$/.test(value);
|
|
260
259
|
}
|
|
261
|
-
|
|
262
260
|
//#endregion
|
|
263
261
|
exports.XXH3 = XXH3;
|
|
264
262
|
exports.isXXH3 = isXXH3;
|
|
263
|
+
|
|
265
264
|
//# sourceMappingURL=hash.cjs.map
|