@langchain/langgraph 1.2.6 → 1.2.7
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/base.cjs.map +1 -1
- package/dist/channels/base.js.map +1 -1
- package/dist/channels/binop.cjs.map +1 -1
- package/dist/channels/binop.js.map +1 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js.map +1 -1
- package/dist/func/types.d.cts.map +1 -1
- package/dist/func/types.d.ts.map +1 -1
- package/dist/graph/annotation.cjs.map +1 -1
- package/dist/graph/annotation.d.cts.map +1 -1
- package/dist/graph/annotation.d.ts.map +1 -1
- package/dist/graph/annotation.js.map +1 -1
- package/dist/graph/graph.cjs +2 -2
- package/dist/graph/graph.cjs.map +1 -1
- package/dist/graph/graph.d.cts.map +1 -1
- package/dist/graph/graph.d.ts.map +1 -1
- package/dist/graph/graph.js +2 -2
- package/dist/graph/graph.js.map +1 -1
- package/dist/graph/state.cjs.map +1 -1
- package/dist/graph/state.d.cts.map +1 -1
- package/dist/graph/state.d.ts.map +1 -1
- package/dist/graph/state.js.map +1 -1
- package/dist/graph/types.cjs.map +1 -1
- package/dist/graph/types.d.cts.map +1 -1
- package/dist/graph/types.d.ts.map +1 -1
- package/dist/graph/types.js.map +1 -1
- package/dist/graph/zod/meta.cjs.map +1 -1
- package/dist/graph/zod/meta.d.cts.map +1 -1
- package/dist/graph/zod/meta.d.ts.map +1 -1
- package/dist/graph/zod/meta.js.map +1 -1
- package/dist/graph/zod/zod-registry.cjs.map +1 -1
- package/dist/graph/zod/zod-registry.d.cts.map +1 -1
- package/dist/graph/zod/zod-registry.d.ts.map +1 -1
- package/dist/graph/zod/zod-registry.js.map +1 -1
- package/dist/interrupt.cjs.map +1 -1
- package/dist/interrupt.d.cts.map +1 -1
- package/dist/interrupt.d.ts.map +1 -1
- package/dist/interrupt.js.map +1 -1
- package/dist/prebuilt/react_agent_executor.cjs.map +1 -1
- package/dist/prebuilt/react_agent_executor.d.cts.map +1 -1
- package/dist/prebuilt/react_agent_executor.d.ts.map +1 -1
- package/dist/prebuilt/react_agent_executor.js.map +1 -1
- package/dist/prebuilt/tool_executor.cjs.map +1 -1
- package/dist/prebuilt/tool_executor.d.cts.map +1 -1
- package/dist/prebuilt/tool_executor.d.ts.map +1 -1
- package/dist/prebuilt/tool_executor.js.map +1 -1
- package/dist/pregel/algo.cjs.map +1 -1
- package/dist/pregel/algo.js.map +1 -1
- package/dist/pregel/debug.cjs.map +1 -1
- package/dist/pregel/debug.js.map +1 -1
- package/dist/pregel/index.cjs.map +1 -1
- package/dist/pregel/index.d.cts.map +1 -1
- package/dist/pregel/index.d.ts.map +1 -1
- package/dist/pregel/index.js.map +1 -1
- package/dist/pregel/loop.cjs.map +1 -1
- package/dist/pregel/loop.js.map +1 -1
- package/dist/pregel/read.cjs.map +1 -1
- package/dist/pregel/read.d.cts.map +1 -1
- package/dist/pregel/read.d.ts.map +1 -1
- package/dist/pregel/read.js.map +1 -1
- package/dist/pregel/remote.cjs.map +1 -1
- package/dist/pregel/remote.d.cts.map +1 -1
- package/dist/pregel/remote.d.ts.map +1 -1
- package/dist/pregel/remote.js.map +1 -1
- package/dist/pregel/retry.cjs.map +1 -1
- package/dist/pregel/retry.js.map +1 -1
- package/dist/pregel/runnable_types.d.cts.map +1 -1
- package/dist/pregel/runnable_types.d.ts.map +1 -1
- package/dist/pregel/stream.cjs +1 -1
- package/dist/pregel/stream.cjs.map +1 -1
- package/dist/pregel/stream.js +1 -1
- package/dist/pregel/stream.js.map +1 -1
- package/dist/pregel/types.cjs.map +1 -1
- package/dist/pregel/types.d.cts.map +1 -1
- package/dist/pregel/types.d.ts.map +1 -1
- package/dist/pregel/types.js.map +1 -1
- package/dist/pregel/validate.cjs.map +1 -1
- package/dist/pregel/validate.js.map +1 -1
- package/dist/pregel/write.cjs.map +1 -1
- package/dist/pregel/write.js.map +1 -1
- package/dist/state/schema.cjs.map +1 -1
- package/dist/state/schema.d.cts.map +1 -1
- package/dist/state/schema.d.ts.map +1 -1
- package/dist/state/schema.js.map +1 -1
- package/dist/state/types.cjs.map +1 -1
- package/dist/state/types.d.cts.map +1 -1
- package/dist/state/types.d.ts.map +1 -1
- package/dist/state/types.js.map +1 -1
- package/dist/utils.cjs.map +1 -1
- package/dist/utils.js.map +1 -1
- package/package.json +7 -20
|
@@ -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;;;;;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,KAAK,OAAO,OAAO;AACxB,SAAO;;;;;;;CAQT,IAAI,QAAiC;AACnC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;;;;CAa9B,qBACE,QACgC;EAChC,MAAM,WAAW,EAAE;EACnB,MAAM,SAAA,GAAA,4BAAA,0BAAiC,OAAO;AAC9C,OAAK,MAAM,CAAC,KAAK,kBAAkB,OAAO,QAAQ,MAAM,EAAE;GACxD,MAAM,OAAO,KAAK,IAAI,cAAc;AACpC,OAAI,MAAM,QACR,UAAS,OAAO,IAAIA,cAAAA,wBAElB,KAAK,QAAQ,IAAI,KAAK,QAAQ;OAEhC,UAAS,OAAO,IAAIC,mBAAAA,UAAU,MAAM,QAAQ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,MAAa,qBAAqB,IAAI,oBAAoB;AAkB1D,SAAgB,cAKd,QACA,MAC+D;AAC/D,KAAI,KAAK,WAAW,CAAC,KAAK,SAAS;EACjC,MAAM,sBAAA,GAAA,4BAAA,4BAAgD,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,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,KAAK,OAAO,OAAO;AACxB,SAAO;;;;;;;CAQT,IAAI,QAAiC;AACnC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;;;;CAa9B,qBACE,QACgC;EAChC,MAAM,WAAW,EAAE;EACnB,MAAM,SAAA,GAAA,4BAAA,0BAAiC,OAAO;AAC9C,OAAK,MAAM,CAAC,KAAK,kBAAkB,OAAO,QAAQ,MAAM,EAAE;GACxD,MAAM,OAAO,KAAK,IAAI,cAAc;AACpC,OAAI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,UACV,mBAAA,GAAA,4BAAA,yBAAyC,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,sBAAA,GAAA,4BAAA,4BAAgD,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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.cts","names":[],"sources":["../../../src/graph/zod/meta.ts"],"mappings":";;;;;cAiBa,8BAAA;;KAGD,iBAAA,WACA,cAAA,yBACa,cAAA,IACrB,CAAA;EACF,iBAAA,EAAmB,cAAA;AAAA;;KAIT,2BAAA,WACA,gBAAA,WACD,qBAAA,CAAsB,CAAA,qBAEjB,MAAA,GAAS,MAAA,CAAO,GAAA,UAAa,iBAAA,sCAIvC,MAAA,SAAe,cAAA,YACb,aAAA,SAAsB,cAAA,YACpB,WAAA,CAAY,CAAA,EAAG,cAAA,CAAe,CAAA,IAAK,CAAA,oBAGvC,MAAA,CAAO,GAAA,UAAa,cAAA,
|
|
1
|
+
{"version":3,"file":"meta.d.cts","names":[],"sources":["../../../src/graph/zod/meta.ts"],"mappings":";;;;;cAiBa,8BAAA;;KAGD,iBAAA,WACA,cAAA,yBACa,cAAA,IACrB,CAAA;EACF,iBAAA,EAAmB,cAAA;AAAA;;KAIT,2BAAA,WACA,gBAAA,WACD,qBAAA,CAAsB,CAAA,qBAEjB,MAAA,GAAS,M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EA0GR,GAAA,CAAI,MAAA,EAAQ,cAAA;EAvGqC;;;;;;;;;;EAqHjD,oBAAA,WAA+B,gBAAA,CAAA,CAC7B,MAAA,EAAQ,CAAA,GACP,2BAAA,CAA4B,CAAA;EAlHzB;;;;;AAIR;;;;;;;;;EA4IE,yBAAA,WAAoC,gBAAA,CAAA,CAClC,MAAA,EAAQ,CAAA,EACR,OAAA;IAtIiB;;;IA0If,iBAAA;IAxIwB;;;IA4IxB,iCAAA;IAzIkC;;;IA6IlC,SAAA;EAAA,IAED,gBAAA;AAAA;AAAA,cA+DQ,kBAAA,EAAkB,kBAAA;AAAA,iBAEf,aAAA,kCAGE,cAAA,CAAe,MAAA,EAAA,CAE/B,MAAA,EAAQ,OAAA,EACR,IAAA,EAAM,UAAA,CAAW,MAAA,EAAQ,OAAA;EAAa,OAAA;AAAA,IACrC,OAAA;AAAA,iBACa,aAAA,kCAGE,cAAA,CAAe,MAAA,EAAA,CAE/B,MAAA,EAAQ,OAAA,EACR,IAAA,EAAM,UAAA,CAAW,MAAA,EAAQ,OAAA,IACxB,iBAAA,CAAkB,OAAA,EAAS,cAAA,CAAe,OAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","names":[],"sources":["../../../src/graph/zod/meta.ts"],"mappings":";;;;;cAiBa,8BAAA;;KAGD,iBAAA,WACA,cAAA,yBACa,cAAA,IACrB,CAAA;EACF,iBAAA,EAAmB,cAAA;AAAA;;KAIT,2BAAA,WACA,gBAAA,WACD,qBAAA,CAAsB,CAAA,qBAEjB,MAAA,GAAS,MAAA,CAAO,GAAA,UAAa,iBAAA,sCAIvC,MAAA,SAAe,cAAA,YACb,aAAA,SAAsB,cAAA,YACpB,WAAA,CAAY,CAAA,EAAG,cAAA,CAAe,CAAA,IAAK,CAAA,oBAGvC,MAAA,CAAO,GAAA,UAAa,cAAA,
|
|
1
|
+
{"version":3,"file":"meta.d.ts","names":[],"sources":["../../../src/graph/zod/meta.ts"],"mapp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A,CAAe,MAAA,GACvB,SAAA,GACE,IAAA,EAAM,UAAA,CAAW,MAAA,EAAQ,OAAA,kBACtB,UAAA,CAAW,MAAA,EAAQ,OAAA;EAvFzB;;;;;EAkGD,MAAA,CAAO,MAAA,EAAQ,cAAA;EAhGP;;;;;EA0GR,GAAA,CAAI,MAAA,EAAQ,cAAA;EAvGqC;;;;;;;;;;EAqHjD,oBAAA,WAA+B,gBAAA,CAAA,CAC7B,MAAA,EAAQ,CAAA,GACP,2BAAA,CAA4B,CAAA;EAlHzB;;;;;AAIR;;;;;;;;;EA4IE,yBAAA,WAAoC,gBAAA,CAAA,CAClC,MAAA,EAAQ,CAAA,EACR,OAAA;IAtIiB;;;IA0If,iBAAA;IAxIwB;;;IA4IxB,iCAAA;IAzIkC;;;IA6IlC,SAAA;EAAA,IAED,gBAAA;AAAA;AAAA,cA+DQ,kBAAA,EAAkB,kBAAA;AAAA,iBAEf,aAAA,kCAGE,cAAA,CAAe,MAAA,EAAA,CAE/B,MAAA,EAAQ,OAAA,EACR,IAAA,EAAM,UAAA,CAAW,MAAA,EAAQ,OAAA;EAAa,OAAA;AAAA,IACrC,OAAA;AAAA,iBACa,aAAA,kCAGE,cAAA,CAAe,MAAA,EAAA,CAE/B,MAAA,EAAQ,OAAA,EACR,IAAA,EAAM,UAAA,CAAW,MAAA,EAAQ,OAAA,IACxB,iBAAA,CAAkB,OAAA,EAAS,cAAA,CAAe,OAAA"}
|
|
@@ -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,IA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oBACvB,MAAM,SAAS,UAAU,SACzB;AACJ,QACE,QAAQ,qCACR,MAAM,iBACN;KACA,MAAM,cACJ,qBAAqB,aAAa,IAAI,qBAAqB,OAAO;KACpE,MAAM,YAAY,KAAK,UAAU;MAC/B,GAAG,KAAK;MACR;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
|
+
{"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;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AM,SAAS,UAAU,SAC1B;AACJ,QACE,QAAQ,qCACR,MAAM,iBACN;KACA,MAAM,cACJ,qBAAqB,aAAa,IAAI,qBAAqB,OAAO;KACpE,MAAM,YAAY,KAAK,UAAU;MAC/B,GAAG,KAAK;MACR;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 +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
|
|
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<Output, 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<TOutput, 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<Output, 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<TOutput, 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;;;AA8CtC,MAAa,WAAW,IAAI,yBAAyBC,aAAAA,mBAAmB"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-registry.d.cts","names":[],"sources":["../../../src/graph/zod/zod-registry.ts"],"mappings":";;;;;;;AA2BA;;;;;;;;;cAAa,wBAAA,cACE,UAAA,GAAa,UAAA,iBACX,QAAA,GAAW,QAAA,UAClB,YAAA,CAAa,IAAA;EAAA,CAAU,GAAA;AAAA,GAAyB,MAAA;EAAA,UAMlC,MAAA,EAAQ,kBAAA;EAWA;;;;;EAX9B,WAAA,CAAsB,MAAA,EAAQ,kBAAA;EAS9B,GAAA,WAAc,MAAA,CAAA,CACZ,MAAA,EAAQ,CAAA,KACL,KAAA,oBAAyB,IAAA;IAAA,CAAU,GAAA;EAAA,KACjC,QAAA,CAAS,IAAA;IAAA,CAAU,GAAA;EAAA,GAAyB,CAAA,OAC5C,QAAA,CAAS,IAAA;IAAA,CAAU,GAAA;EAAA,GAAyB,CAAA;AAAA;AAAA;EAAA,UAiBlC,OAAA,kEAGO,IAAA,CAAK,iBAAA,
|
|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AA,EAAO,SAAA;IACrC,QAAA,WACY,wBAAA,YACA,IAAA,CAAK,MAAA,iBACN,IAAA,CAAK,KAAA,2BACK,IAAA,CAAK,iBAAA,CAAkB,OAAA,EAAS,MAAA,IACjD,IAAA,CAAK,iBAAA,CAAkB,OAAA,EAAS,MAAA,GAElC,QAAA,EAAU,CAAA,EACV,IAAA,EAAM,UAAA,CAAW,OAAA,EAAS,MAAA,IACzB,iBAAA,OAAwB,WAAA,CAAY,OAAA,EAAS,MAAA,EAAQ,UAAA;EAAA;AAAA;AAAA,cAI/C,QAAA,EAAQ,wBAAA,CAAA,UAAA,YAAA,QAAA,mBAAA,IAAA,CAAA,iBAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"zod-registry.d.ts","names":[],"sources":["../../../src/graph/zod/zod-registry.ts"],"mappings":";;;;;;;AA2BA;;;;;;;;;cAAa,wBAAA,cACE,UAAA,GAAa,UAAA,iBACX,QAAA,GAAW,QAAA,UAClB,YAAA,CAAa,IAAA;EAAA,CAAU,GAAA;AAAA,GAAyB,MAAA;EAAA,UAMlC,MAAA,EAAQ,kBAAA;EAWA;;;;;EAX9B,WAAA,CAAsB,MAAA,EAAQ,kBAAA;EAS9B,GAAA,WAAc,MAAA,CAAA,CACZ,MAAA,EAAQ,CAAA,KACL,KAAA,oBAAyB,IAAA;IAAA,CAAU,GAAA;EAAA,KACjC,QAAA,CAAS,IAAA;IAAA,CAAU,GAAA;EAAA,GAAyB,CAAA,OAC5C,QAAA,CAAS,IAAA;IAAA,CAAU,GAAA;EAAA,GAAyB,CAAA;AAAA;AAAA;EAAA,UAiBlC,OAAA,kEAGO,IAAA,CAAK,iBAAA,
|
|
1
|
+
{"version":3,"file":"zod-registry.d.ts","names":[],"sources":["../../../src/graph/zod/zod-registry.ts"],"mappings":";;;;;;;AA2BA;;;;;;;;;cAAa,wBAAA,cACE,UAAA,GAAa,UAAA,iBACX,QAAA,GAAW,QAAA,UAClB,YAAA,CAAa,IAAA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AA,GAElC,QAAA,EAAU,CAAA,EACV,IAAA,EAAM,UAAA,CAAW,OAAA,EAAS,MAAA,IACzB,iBAAA,OAAwB,WAAA,CAAY,OAAA,EAAS,MAAA,EAAQ,UAAA;EAAA;AAAA;AAAA,cAI/C,QAAA,EAAQ,wBAAA,CAAA,UAAA,YAAA,QAAA,mBAAA,IAAA,CAAA,iBAAA"}
|
|
@@ -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
|
|
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<Output, 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<TOutput, 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<Output, 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<TOutput, 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;;;AA8CtC,MAAa,WAAW,IAAI,yBAAyB,mBAAmB"}
|
package/dist/interrupt.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interrupt.cjs","names":["AsyncLocalStorageProviderSingleton","GraphValueError","CONFIG_KEY_SCRATCHPAD","CONFIG_KEY_SEND","RESUME","CONFIG_KEY_CHECKPOINT_NS","GraphInterrupt","XXH3"],"sources":["../src/interrupt.ts"],"sourcesContent":["import { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport { RunnableConfig } from \"@langchain/core/runnables\";\nimport {\n BaseCheckpointSaver,\n type PendingWrite,\n} from \"@langchain/langgraph-checkpoint\";\nimport { GraphInterrupt, GraphValueError } from \"./errors.js\";\nimport {\n CONFIG_KEY_CHECKPOINT_NS,\n CONFIG_KEY_SCRATCHPAD,\n CONFIG_KEY_SEND,\n CONFIG_KEY_CHECKPOINTER,\n CHECKPOINT_NAMESPACE_SEPARATOR,\n RESUME,\n} from \"./constants.js\";\nimport { PregelScratchpad } from \"./pregel/types.js\";\nimport { XXH3 } from \"./hash.js\";\n\n/**\n * Interrupts the execution of a graph node.\n * This function can be used to pause execution of a node, and return the value of the `resume`\n * input when the graph is re-invoked using `Command`.\n * Multiple interrupts can be called within a single node, and each will be handled sequentially.\n *\n * When an interrupt is called:\n * 1. If there's a `resume` value available (from a previous `Command`), it returns that value.\n * 2. Otherwise, it throws a `GraphInterrupt` with the provided value\n * 3. The graph can be resumed by passing a `Command` with a `resume` value\n *\n * Because the `interrupt` function propagates by throwing a special `GraphInterrupt` error,\n * you should avoid using `try/catch` blocks around the `interrupt` function,\n * or if you do, ensure that the `GraphInterrupt` error is thrown again within your `catch` block.\n *\n * @param value - The value to include in the interrupt. This will be available in task.interrupts[].value\n * @returns The `resume` value provided when the graph is re-invoked with a Command\n *\n * @example\n * ```typescript\n * // Define a node that uses multiple interrupts\n * const nodeWithInterrupts = () => {\n * // First interrupt - will pause execution and include {value: 1} in task values\n * const answer1 = interrupt({ value: 1 });\n *\n * // Second interrupt - only called after first interrupt is resumed\n * const answer2 = interrupt({ value: 2 });\n *\n * // Use the resume values\n * return { myKey: answer1 + \" \" + answer2 };\n * };\n *\n * // Resume the graph after first interrupt\n * await graph.stream(new Command({ resume: \"answer 1\" }));\n *\n * // Resume the graph after second interrupt\n * await graph.stream(new Command({ resume: \"answer 2\" }));\n * // Final result: { myKey: \"answer 1 answer 2\" }\n * ```\n *\n * @throws {Error} If called outside the context of a graph\n * @throws {GraphInterrupt} When no resume value is available\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function interrupt<I = unknown, R = any>(value: I): R {\n const config: RunnableConfig | undefined =\n AsyncLocalStorageProviderSingleton.getRunnableConfig();\n if (!config) {\n throw new Error(\"Called interrupt() outside the context of a graph.\");\n }\n\n const conf = config.configurable;\n if (!conf) {\n throw new Error(\"No configurable found in config\");\n }\n\n const checkpointer: BaseCheckpointSaver = conf[CONFIG_KEY_CHECKPOINTER];\n if (!checkpointer) {\n throw new GraphValueError(\"No checkpointer set\", {\n lc_error_code: \"MISSING_CHECKPOINTER\",\n });\n }\n\n // Track interrupt index\n const scratchpad: PregelScratchpad = conf[CONFIG_KEY_SCRATCHPAD];\n scratchpad.interruptCounter += 1;\n const idx = scratchpad.interruptCounter;\n\n // Find previous resume values\n if (scratchpad.resume.length > 0 && idx < scratchpad.resume.length) {\n conf[CONFIG_KEY_SEND]?.([[RESUME, scratchpad.resume] as PendingWrite]);\n return scratchpad.resume[idx] as R;\n }\n\n // Find current resume value\n if (scratchpad.nullResume !== undefined) {\n if (scratchpad.resume.length !== idx) {\n throw new Error(\n `Resume length mismatch: ${scratchpad.resume.length} !== ${idx}`\n );\n }\n const v = scratchpad.consumeNullResume();\n scratchpad.resume.push(v);\n conf[CONFIG_KEY_SEND]?.([[RESUME, scratchpad.resume] as PendingWrite]);\n return v as R;\n }\n\n // No resume value found\n const ns: string[] | undefined = conf[CONFIG_KEY_CHECKPOINT_NS]?.split(\n CHECKPOINT_NAMESPACE_SEPARATOR\n );\n\n const id = ns ? XXH3(ns.join(CHECKPOINT_NAMESPACE_SEPARATOR)) : undefined;\n throw new GraphInterrupt([{ id, value }]);\n}\n\ntype FilterAny<X>
|
|
1
|
+
{"version":3,"file":"interrupt.cjs","names":["AsyncLocalStorageProviderSingleton","GraphValueError","CONFIG_KEY_SCRATCHPAD","CONFIG_KEY_SEND","RESUME","CONFIG_KEY_CHECKPOINT_NS","GraphInterrupt","XXH3"],"sources":["../src/interrupt.ts"],"sourcesContent":["import { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport { RunnableConfig } from \"@langchain/core/runnables\";\nimport {\n BaseCheckpointSaver,\n type PendingWrite,\n} from \"@langchain/langgraph-checkpoint\";\nimport { GraphInterrupt, GraphValueError } from \"./errors.js\";\nimport {\n CONFIG_KEY_CHECKPOINT_NS,\n CONFIG_KEY_SCRATCHPAD,\n CONFIG_KEY_SEND,\n CONFIG_KEY_CHECKPOINTER,\n CHECKPOINT_NAMESPACE_SEPARATOR,\n RESUME,\n} from \"./constants.js\";\nimport { PregelScratchpad } from \"./pregel/types.js\";\nimport { XXH3 } from \"./hash.js\";\n\n/**\n * Interrupts the execution of a graph node.\n * This function can be used to pause execution of a node, and return the value of the `resume`\n * input when the graph is re-invoked using `Command`.\n * Multiple interrupts can be called within a single node, and each will be handled sequentially.\n *\n * When an interrupt is called:\n * 1. If there's a `resume` value available (from a previous `Command`), it returns that value.\n * 2. Otherwise, it throws a `GraphInterrupt` with the provided value\n * 3. The graph can be resumed by passing a `Command` with a `resume` value\n *\n * Because the `interrupt` function propagates by throwing a special `GraphInterrupt` error,\n * you should avoid using `try/catch` blocks around the `interrupt` function,\n * or if you do, ensure that the `GraphInterrupt` error is thrown again within your `catch` block.\n *\n * @param value - The value to include in the interrupt. This will be available in task.interrupts[].value\n * @returns The `resume` value provided when the graph is re-invoked with a Command\n *\n * @example\n * ```typescript\n * // Define a node that uses multiple interrupts\n * const nodeWithInterrupts = () => {\n * // First interrupt - will pause execution and include {value: 1} in task values\n * const answer1 = interrupt({ value: 1 });\n *\n * // Second interrupt - only called after first interrupt is resumed\n * const answer2 = interrupt({ value: 2 });\n *\n * // Use the resume values\n * return { myKey: answer1 + \" \" + answer2 };\n * };\n *\n * // Resume the graph after first interrupt\n * await graph.stream(new Command({ resume: \"answer 1\" }));\n *\n * // Resume the graph after second interrupt\n * await graph.stream(new Command({ resume: \"answer 2\" }));\n * // Final result: { myKey: \"answer 1 answer 2\" }\n * ```\n *\n * @throws {Error} If called outside the context of a graph\n * @throws {GraphInterrupt} When no resume value is available\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function interrupt<I = unknown, R = any>(value: I): R {\n const config: RunnableConfig | undefined =\n AsyncLocalStorageProviderSingleton.getRunnableConfig();\n if (!config) {\n throw new Error(\"Called interrupt() outside the context of a graph.\");\n }\n\n const conf = config.configurable;\n if (!conf) {\n throw new Error(\"No configurable found in config\");\n }\n\n const checkpointer: BaseCheckpointSaver = conf[CONFIG_KEY_CHECKPOINTER];\n if (!checkpointer) {\n throw new GraphValueError(\"No checkpointer set\", {\n lc_error_code: \"MISSING_CHECKPOINTER\",\n });\n }\n\n // Track interrupt index\n const scratchpad: PregelScratchpad = conf[CONFIG_KEY_SCRATCHPAD];\n scratchpad.interruptCounter += 1;\n const idx = scratchpad.interruptCounter;\n\n // Find previous resume values\n if (scratchpad.resume.length > 0 && idx < scratchpad.resume.length) {\n conf[CONFIG_KEY_SEND]?.([[RESUME, scratchpad.resume] as PendingWrite]);\n return scratchpad.resume[idx] as R;\n }\n\n // Find current resume value\n if (scratchpad.nullResume !== undefined) {\n if (scratchpad.resume.length !== idx) {\n throw new Error(\n `Resume length mismatch: ${scratchpad.resume.length} !== ${idx}`\n );\n }\n const v = scratchpad.consumeNullResume();\n scratchpad.resume.push(v);\n conf[CONFIG_KEY_SEND]?.([[RESUME, scratchpad.resume] as PendingWrite]);\n return v as R;\n }\n\n // No resume value found\n const ns: string[] | undefined = conf[CONFIG_KEY_CHECKPOINT_NS]?.split(\n CHECKPOINT_NAMESPACE_SEPARATOR\n );\n\n const id = ns ? XXH3(ns.join(CHECKPOINT_NAMESPACE_SEPARATOR)) : undefined;\n throw new GraphInterrupt([{ id, value }]);\n}\n\ntype FilterAny<X> =\n (<T>() => T extends X ? 1 : 2) extends <\n T,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n >() => T extends any ? 1 : 2\n ? never\n : X;\n\nexport type InferInterruptInputType<T> = T extends typeof interrupt<\n infer I,\n unknown\n>\n ? I\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends { [key: string]: typeof interrupt<any, any> }\n ? { [K in keyof T]: InferInterruptInputType<T[K]> }[keyof T]\n : unknown;\n\nexport type InferInterruptResumeType<\n T,\n TInner = false,\n> = T extends typeof interrupt<never, infer R>\n ? TInner extends true\n ? FilterAny<R>\n : R\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends { [key: string]: typeof interrupt<any, any> }\n ? { [K in keyof T]: InferInterruptResumeType<T[K], true> }[keyof T]\n : unknown;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,UAAgC,OAAa;CAC3D,MAAM,SACJA,2BAAAA,mCAAmC,mBAAmB;AACxD,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,qDAAqD;CAGvE,MAAM,OAAO,OAAO;AACpB,KAAI,CAAC,KACH,OAAM,IAAI,MAAM,kCAAkC;AAIpD,KAAI,CADsC,KAAA,yBAExC,OAAM,IAAIC,eAAAA,gBAAgB,uBAAuB,EAC/C,eAAe,wBAChB,CAAC;CAIJ,MAAM,aAA+B,KAAKC,kBAAAA;AAC1C,YAAW,oBAAoB;CAC/B,MAAM,MAAM,WAAW;AAGvB,KAAI,WAAW,OAAO,SAAS,KAAK,MAAM,WAAW,OAAO,QAAQ;AAClE,OAAKC,kBAAAA,mBAAmB,CAAC,CAACC,kBAAAA,QAAQ,WAAW,OAAO,CAAiB,CAAC;AACtE,SAAO,WAAW,OAAO;;AAI3B,KAAI,WAAW,eAAe,KAAA,GAAW;AACvC,MAAI,WAAW,OAAO,WAAW,IAC/B,OAAM,IAAI,MACR,2BAA2B,WAAW,OAAO,OAAO,OAAO,MAC5D;EAEH,MAAM,IAAI,WAAW,mBAAmB;AACxC,aAAW,OAAO,KAAK,EAAE;AACzB,OAAKD,kBAAAA,mBAAmB,CAAC,CAACC,kBAAAA,QAAQ,WAAW,OAAO,CAAiB,CAAC;AACtE,SAAO;;CAIT,MAAM,KAA2B,KAAKC,kBAAAA,2BAA2B,MAAA,IAEhE;AAGD,OAAM,IAAIC,eAAAA,eAAe,CAAC;EAAE,IADjB,KAAKC,aAAAA,KAAK,GAAG,KAAA,IAAoC,CAAC,GAAG,KAAA;EAChC;EAAO,CAAC,CAAC"}
|
package/dist/interrupt.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interrupt.d.cts","names":[],"sources":["../src/interrupt.ts"],"mappings":";;AA8DA;;;;;;;;;;;AAkDC;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"interrupt.d.cts","names":[],"sources":["../src/interrupt.ts"],"mappings":";;AA8DA;;;;;;;;;;;AAkDC;;;;;;;;;;;;;;;;;;AAUD;;;;;;;;;;;;;iBA5DgB,SAAA,sBAAA,CAAgC,KAAA,EAAO,CAAA,GAAI,CAAA;AAAA,KAoDtD,SAAA,gBACO,CAAA,SAAU,CAAA,6BAGb,CAAA,iCAEH,CAAA;AAAA,KAEM,uBAAA,MAA6B,CAAA,gBAAiB,SAAA,qBAItD,CAAA,GAEA,CAAA;EAAA,CAAa,GAAA,kBAAqB,SAAA;AAAA,kBAClB,CAAA,GAAI,uBAAA,CAAwB,CAAA,CAAE,CAAA,WAAY,CAAA;AAAA,KAGlD,wBAAA,sBAGR,CAAA,gBAAiB,SAAA,mBACjB,MAAA,gBACE,SAAA,CAAU,CAAA,IACV,CAAA,GAEF,CAAA;EAAA,CAAa,GAAA,kBAAqB,SAAA;AAAA,kBAClB,CAAA,GAAI,wBAAA,CAAyB,CAAA,CAAE,CAAA,iBAAkB,CAAA"}
|
package/dist/interrupt.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interrupt.d.ts","names":[],"sources":["../src/interrupt.ts"],"mappings":";;AA8DA;;;;;;;;;;;AAkDC;;;;;;;;;;;;;;;;;;
|
|
1
|
+
{"version":3,"file":"interrupt.d.ts","names":[],"sources":["../src/interrupt.ts"],"mappings":";;AA8DA;;;;;;;;;;;AAkDC;;;;;;;;;;;;;;;;;;AAUD;;;;;;;;;;;;;iBA5DgB,SAAA,sBAAA,CAAgC,KAAA,EAAO,CAAA,GAAI,CAAA;AAAA,KAoDtD,SAAA,gBACO,CAAA,SAAU,CAAA,6BAGb,CAAA,iCAEH,CAAA;AAAA,KAEM,uBAAA,MAA6B,CAAA,gBAAiB,SAAA,qBAItD,CAAA,GAEA,CAAA;EAAA,CAAa,GAAA,kBAAqB,SAAA;AAAA,kBAClB,CAAA,GAAI,uBAAA,CAAwB,CAAA,CAAE,CAAA,WAAY,CAAA;AAAA,KAGlD,wBAAA,sBAGR,CAAA,gBAAiB,SAAA,mBACjB,MAAA,gBACE,SAAA,CAAU,CAAA,IACV,CAAA,GAEF,CAAA;EAAA,CAAa,GAAA,kBAAqB,SAAA;AAAA,kBAClB,CAAA,GAAI,wBAAA,CAAyB,CAAA,CAAE,CAAA,iBAAkB,CAAA"}
|
package/dist/interrupt.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"interrupt.js","names":[],"sources":["../src/interrupt.ts"],"sourcesContent":["import { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport { RunnableConfig } from \"@langchain/core/runnables\";\nimport {\n BaseCheckpointSaver,\n type PendingWrite,\n} from \"@langchain/langgraph-checkpoint\";\nimport { GraphInterrupt, GraphValueError } from \"./errors.js\";\nimport {\n CONFIG_KEY_CHECKPOINT_NS,\n CONFIG_KEY_SCRATCHPAD,\n CONFIG_KEY_SEND,\n CONFIG_KEY_CHECKPOINTER,\n CHECKPOINT_NAMESPACE_SEPARATOR,\n RESUME,\n} from \"./constants.js\";\nimport { PregelScratchpad } from \"./pregel/types.js\";\nimport { XXH3 } from \"./hash.js\";\n\n/**\n * Interrupts the execution of a graph node.\n * This function can be used to pause execution of a node, and return the value of the `resume`\n * input when the graph is re-invoked using `Command`.\n * Multiple interrupts can be called within a single node, and each will be handled sequentially.\n *\n * When an interrupt is called:\n * 1. If there's a `resume` value available (from a previous `Command`), it returns that value.\n * 2. Otherwise, it throws a `GraphInterrupt` with the provided value\n * 3. The graph can be resumed by passing a `Command` with a `resume` value\n *\n * Because the `interrupt` function propagates by throwing a special `GraphInterrupt` error,\n * you should avoid using `try/catch` blocks around the `interrupt` function,\n * or if you do, ensure that the `GraphInterrupt` error is thrown again within your `catch` block.\n *\n * @param value - The value to include in the interrupt. This will be available in task.interrupts[].value\n * @returns The `resume` value provided when the graph is re-invoked with a Command\n *\n * @example\n * ```typescript\n * // Define a node that uses multiple interrupts\n * const nodeWithInterrupts = () => {\n * // First interrupt - will pause execution and include {value: 1} in task values\n * const answer1 = interrupt({ value: 1 });\n *\n * // Second interrupt - only called after first interrupt is resumed\n * const answer2 = interrupt({ value: 2 });\n *\n * // Use the resume values\n * return { myKey: answer1 + \" \" + answer2 };\n * };\n *\n * // Resume the graph after first interrupt\n * await graph.stream(new Command({ resume: \"answer 1\" }));\n *\n * // Resume the graph after second interrupt\n * await graph.stream(new Command({ resume: \"answer 2\" }));\n * // Final result: { myKey: \"answer 1 answer 2\" }\n * ```\n *\n * @throws {Error} If called outside the context of a graph\n * @throws {GraphInterrupt} When no resume value is available\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function interrupt<I = unknown, R = any>(value: I): R {\n const config: RunnableConfig | undefined =\n AsyncLocalStorageProviderSingleton.getRunnableConfig();\n if (!config) {\n throw new Error(\"Called interrupt() outside the context of a graph.\");\n }\n\n const conf = config.configurable;\n if (!conf) {\n throw new Error(\"No configurable found in config\");\n }\n\n const checkpointer: BaseCheckpointSaver = conf[CONFIG_KEY_CHECKPOINTER];\n if (!checkpointer) {\n throw new GraphValueError(\"No checkpointer set\", {\n lc_error_code: \"MISSING_CHECKPOINTER\",\n });\n }\n\n // Track interrupt index\n const scratchpad: PregelScratchpad = conf[CONFIG_KEY_SCRATCHPAD];\n scratchpad.interruptCounter += 1;\n const idx = scratchpad.interruptCounter;\n\n // Find previous resume values\n if (scratchpad.resume.length > 0 && idx < scratchpad.resume.length) {\n conf[CONFIG_KEY_SEND]?.([[RESUME, scratchpad.resume] as PendingWrite]);\n return scratchpad.resume[idx] as R;\n }\n\n // Find current resume value\n if (scratchpad.nullResume !== undefined) {\n if (scratchpad.resume.length !== idx) {\n throw new Error(\n `Resume length mismatch: ${scratchpad.resume.length} !== ${idx}`\n );\n }\n const v = scratchpad.consumeNullResume();\n scratchpad.resume.push(v);\n conf[CONFIG_KEY_SEND]?.([[RESUME, scratchpad.resume] as PendingWrite]);\n return v as R;\n }\n\n // No resume value found\n const ns: string[] | undefined = conf[CONFIG_KEY_CHECKPOINT_NS]?.split(\n CHECKPOINT_NAMESPACE_SEPARATOR\n );\n\n const id = ns ? XXH3(ns.join(CHECKPOINT_NAMESPACE_SEPARATOR)) : undefined;\n throw new GraphInterrupt([{ id, value }]);\n}\n\ntype FilterAny<X>
|
|
1
|
+
{"version":3,"file":"interrupt.js","names":[],"sources":["../src/interrupt.ts"],"sourcesContent":["import { AsyncLocalStorageProviderSingleton } from \"@langchain/core/singletons\";\nimport { RunnableConfig } from \"@langchain/core/runnables\";\nimport {\n BaseCheckpointSaver,\n type PendingWrite,\n} from \"@langchain/langgraph-checkpoint\";\nimport { GraphInterrupt, GraphValueError } from \"./errors.js\";\nimport {\n CONFIG_KEY_CHECKPOINT_NS,\n CONFIG_KEY_SCRATCHPAD,\n CONFIG_KEY_SEND,\n CONFIG_KEY_CHECKPOINTER,\n CHECKPOINT_NAMESPACE_SEPARATOR,\n RESUME,\n} from \"./constants.js\";\nimport { PregelScratchpad } from \"./pregel/types.js\";\nimport { XXH3 } from \"./hash.js\";\n\n/**\n * Interrupts the execution of a graph node.\n * This function can be used to pause execution of a node, and return the value of the `resume`\n * input when the graph is re-invoked using `Command`.\n * Multiple interrupts can be called within a single node, and each will be handled sequentially.\n *\n * When an interrupt is called:\n * 1. If there's a `resume` value available (from a previous `Command`), it returns that value.\n * 2. Otherwise, it throws a `GraphInterrupt` with the provided value\n * 3. The graph can be resumed by passing a `Command` with a `resume` value\n *\n * Because the `interrupt` function propagates by throwing a special `GraphInterrupt` error,\n * you should avoid using `try/catch` blocks around the `interrupt` function,\n * or if you do, ensure that the `GraphInterrupt` error is thrown again within your `catch` block.\n *\n * @param value - The value to include in the interrupt. This will be available in task.interrupts[].value\n * @returns The `resume` value provided when the graph is re-invoked with a Command\n *\n * @example\n * ```typescript\n * // Define a node that uses multiple interrupts\n * const nodeWithInterrupts = () => {\n * // First interrupt - will pause execution and include {value: 1} in task values\n * const answer1 = interrupt({ value: 1 });\n *\n * // Second interrupt - only called after first interrupt is resumed\n * const answer2 = interrupt({ value: 2 });\n *\n * // Use the resume values\n * return { myKey: answer1 + \" \" + answer2 };\n * };\n *\n * // Resume the graph after first interrupt\n * await graph.stream(new Command({ resume: \"answer 1\" }));\n *\n * // Resume the graph after second interrupt\n * await graph.stream(new Command({ resume: \"answer 2\" }));\n * // Final result: { myKey: \"answer 1 answer 2\" }\n * ```\n *\n * @throws {Error} If called outside the context of a graph\n * @throws {GraphInterrupt} When no resume value is available\n */\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport function interrupt<I = unknown, R = any>(value: I): R {\n const config: RunnableConfig | undefined =\n AsyncLocalStorageProviderSingleton.getRunnableConfig();\n if (!config) {\n throw new Error(\"Called interrupt() outside the context of a graph.\");\n }\n\n const conf = config.configurable;\n if (!conf) {\n throw new Error(\"No configurable found in config\");\n }\n\n const checkpointer: BaseCheckpointSaver = conf[CONFIG_KEY_CHECKPOINTER];\n if (!checkpointer) {\n throw new GraphValueError(\"No checkpointer set\", {\n lc_error_code: \"MISSING_CHECKPOINTER\",\n });\n }\n\n // Track interrupt index\n const scratchpad: PregelScratchpad = conf[CONFIG_KEY_SCRATCHPAD];\n scratchpad.interruptCounter += 1;\n const idx = scratchpad.interruptCounter;\n\n // Find previous resume values\n if (scratchpad.resume.length > 0 && idx < scratchpad.resume.length) {\n conf[CONFIG_KEY_SEND]?.([[RESUME, scratchpad.resume] as PendingWrite]);\n return scratchpad.resume[idx] as R;\n }\n\n // Find current resume value\n if (scratchpad.nullResume !== undefined) {\n if (scratchpad.resume.length !== idx) {\n throw new Error(\n `Resume length mismatch: ${scratchpad.resume.length} !== ${idx}`\n );\n }\n const v = scratchpad.consumeNullResume();\n scratchpad.resume.push(v);\n conf[CONFIG_KEY_SEND]?.([[RESUME, scratchpad.resume] as PendingWrite]);\n return v as R;\n }\n\n // No resume value found\n const ns: string[] | undefined = conf[CONFIG_KEY_CHECKPOINT_NS]?.split(\n CHECKPOINT_NAMESPACE_SEPARATOR\n );\n\n const id = ns ? XXH3(ns.join(CHECKPOINT_NAMESPACE_SEPARATOR)) : undefined;\n throw new GraphInterrupt([{ id, value }]);\n}\n\ntype FilterAny<X> =\n (<T>() => T extends X ? 1 : 2) extends <\n T,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n >() => T extends any ? 1 : 2\n ? never\n : X;\n\nexport type InferInterruptInputType<T> = T extends typeof interrupt<\n infer I,\n unknown\n>\n ? I\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends { [key: string]: typeof interrupt<any, any> }\n ? { [K in keyof T]: InferInterruptInputType<T[K]> }[keyof T]\n : unknown;\n\nexport type InferInterruptResumeType<\n T,\n TInner = false,\n> = T extends typeof interrupt<never, infer R>\n ? TInner extends true\n ? FilterAny<R>\n : R\n : // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends { [key: string]: typeof interrupt<any, any> }\n ? { [K in keyof T]: InferInterruptResumeType<T[K], true> }[keyof T]\n : unknown;\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA8DA,SAAgB,UAAgC,OAAa;CAC3D,MAAM,SACJ,mCAAmC,mBAAmB;AACxD,KAAI,CAAC,OACH,OAAM,IAAI,MAAM,qDAAqD;CAGvE,MAAM,OAAO,OAAO;AACpB,KAAI,CAAC,KACH,OAAM,IAAI,MAAM,kCAAkC;AAIpD,KAAI,CADsC,KAAA,yBAExC,OAAM,IAAI,gBAAgB,uBAAuB,EAC/C,eAAe,wBAChB,CAAC;CAIJ,MAAM,aAA+B,KAAK;AAC1C,YAAW,oBAAoB;CAC/B,MAAM,MAAM,WAAW;AAGvB,KAAI,WAAW,OAAO,SAAS,KAAK,MAAM,WAAW,OAAO,QAAQ;AAClE,OAAK,mBAAmB,CAAC,CAAC,QAAQ,WAAW,OAAO,CAAiB,CAAC;AACtE,SAAO,WAAW,OAAO;;AAI3B,KAAI,WAAW,eAAe,KAAA,GAAW;AACvC,MAAI,WAAW,OAAO,WAAW,IAC/B,OAAM,IAAI,MACR,2BAA2B,WAAW,OAAO,OAAO,OAAO,MAC5D;EAEH,MAAM,IAAI,WAAW,mBAAmB;AACxC,aAAW,OAAO,KAAK,EAAE;AACzB,OAAK,mBAAmB,CAAC,CAAC,QAAQ,WAAW,OAAO,CAAiB,CAAC;AACtE,SAAO;;CAIT,MAAM,KAA2B,KAAK,2BAA2B,MAAA,IAEhE;AAGD,OAAM,IAAI,eAAe,CAAC;EAAE,IADjB,KAAK,KAAK,GAAG,KAAA,IAAoC,CAAC,GAAG,KAAA;EAChC;EAAO,CAAC,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react_agent_executor.cjs","names":["Runnable","RunnableLambda","SystemMessage","RunnableSequence","RunnableBinding","Annotation","messagesStateReducer","ToolNode","withAgentName","StateGraph","START","isToolMessage","Send","END"],"sources":["../../src/prebuilt/react_agent_executor.ts"],"sourcesContent":["import {\n BaseChatModel,\n BindToolsInput,\n} from \"@langchain/core/language_models/chat_models\";\nimport { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport {\n BaseMessage,\n BaseMessageLike,\n isAIMessage,\n isBaseMessage,\n isToolMessage,\n SystemMessage,\n type AIMessage,\n} from \"@langchain/core/messages\";\nimport {\n Runnable,\n RunnableLambda,\n RunnableToolLike,\n RunnableSequence,\n RunnableBinding,\n type RunnableLike,\n} from \"@langchain/core/runnables\";\nimport { DynamicTool, StructuredToolInterface } from \"@langchain/core/tools\";\nimport type {\n InteropZodObject,\n InteropZodType,\n} from \"@langchain/core/utils/types\";\nimport {\n All,\n BaseCheckpointSaver,\n BaseStore,\n} from \"@langchain/langgraph-checkpoint\";\n\nimport {\n StateGraph,\n type CompiledStateGraph,\n AnnotationRoot,\n} from \"../graph/index.js\";\nimport { MessagesAnnotation } from \"../graph/messages_annotation.js\";\nimport { ToolNode } from \"./tool_node.js\";\nimport { LangGraphRunnableConfig, Runtime } from \"../pregel/runnable_types.js\";\nimport { Annotation } from \"../graph/annotation.js\";\nimport { Messages, messagesStateReducer } from \"../graph/messages_reducer.js\";\nimport { END, Send, START } from \"../constants.js\";\nimport { withAgentName } from \"./agentName.js\";\nimport type { InteropZodToStateDefinition } from \"../graph/zod/meta.js\";\n\n/**\n * @deprecated `AgentState` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { AgentState } from \"langchain\";`\n */\nexport interface AgentState<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n StructuredResponseType extends Record<string, any> = Record<string, any>\n> {\n messages: BaseMessage[];\n // TODO: This won't be set until we\n // implement managed values in LangGraphJS\n // Will be useful for inserting a message on\n // graph recursion end\n // is_last_step: boolean;\n structuredResponse: StructuredResponseType;\n}\n\nexport type N = typeof START | \"agent\" | \"tools\";\n\ntype StructuredResponseSchemaOptions<StructuredResponseType> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: InteropZodType<StructuredResponseType> | Record<string, any>;\n prompt?: string;\n\n strict?: boolean;\n [key: string]: unknown;\n};\n\nfunction _convertMessageModifierToPrompt(\n messageModifier: MessageModifier\n): Prompt {\n // Handle string or SystemMessage\n if (\n typeof messageModifier === \"string\" ||\n (isBaseMessage(messageModifier) && messageModifier._getType() === \"system\")\n ) {\n return messageModifier;\n }\n\n // Handle callable function\n if (typeof messageModifier === \"function\") {\n return async (state: typeof MessagesAnnotation.State) =>\n messageModifier(state.messages);\n }\n\n // Handle Runnable\n if (Runnable.isRunnable(messageModifier)) {\n return RunnableLambda.from(\n (state: typeof MessagesAnnotation.State) => state.messages\n ).pipe(messageModifier);\n }\n\n throw new Error(\n `Unexpected type for messageModifier: ${typeof messageModifier}`\n );\n}\n\nconst PROMPT_RUNNABLE_NAME = \"prompt\";\n\nfunction _getPromptRunnable(prompt?: Prompt): Runnable {\n let promptRunnable: Runnable;\n\n if (prompt == null) {\n promptRunnable = RunnableLambda.from(\n (state: typeof MessagesAnnotation.State) => state.messages\n ).withConfig({ runName: PROMPT_RUNNABLE_NAME });\n } else if (typeof prompt === \"string\") {\n const systemMessage = new SystemMessage(prompt);\n promptRunnable = RunnableLambda.from(\n (state: typeof MessagesAnnotation.State) => {\n return [systemMessage, ...(state.messages ?? [])];\n }\n ).withConfig({ runName: PROMPT_RUNNABLE_NAME });\n } else if (isBaseMessage(prompt) && prompt._getType() === \"system\") {\n promptRunnable = RunnableLambda.from(\n (state: typeof MessagesAnnotation.State) => [prompt, ...state.messages]\n ).withConfig({ runName: PROMPT_RUNNABLE_NAME });\n } else if (typeof prompt === \"function\") {\n promptRunnable = RunnableLambda.from(prompt).withConfig({\n runName: PROMPT_RUNNABLE_NAME,\n });\n } else if (Runnable.isRunnable(prompt)) {\n promptRunnable = prompt;\n } else {\n throw new Error(`Got unexpected type for 'prompt': ${typeof prompt}`);\n }\n\n return promptRunnable;\n}\n\ntype ServerTool = Record<string, unknown>;\ntype ClientTool = StructuredToolInterface | DynamicTool | RunnableToolLike;\n\nfunction isClientTool(tool: ClientTool | ServerTool): tool is ClientTool {\n return Runnable.isRunnable(tool);\n}\n\nfunction _getPrompt(\n prompt?: Prompt,\n stateModifier?: CreateReactAgentParams[\"stateModifier\"],\n messageModifier?: CreateReactAgentParams[\"messageModifier\"]\n): Runnable {\n // Check if multiple modifiers exist\n const definedCount = [prompt, stateModifier, messageModifier].filter(\n (x) => x != null\n ).length;\n if (definedCount > 1) {\n throw new Error(\n \"Expected only one of prompt, stateModifier, or messageModifier, got multiple values\"\n );\n }\n\n let finalPrompt = prompt;\n if (stateModifier != null) {\n finalPrompt = stateModifier;\n } else if (messageModifier != null) {\n finalPrompt = _convertMessageModifierToPrompt(messageModifier);\n }\n\n return _getPromptRunnable(finalPrompt);\n}\n\nfunction _isBaseChatModel(model: LanguageModelLike): model is BaseChatModel {\n return (\n \"invoke\" in model &&\n typeof model.invoke === \"function\" &&\n \"_modelType\" in model\n );\n}\n\ninterface ConfigurableModelInterface {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _queuedMethodOperations: Record<string, any>;\n _model: () => Promise<BaseChatModel>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _isConfigurableModel(model: any): model is ConfigurableModelInterface {\n return (\n \"_queuedMethodOperations\" in model &&\n \"_model\" in model &&\n typeof model._model === \"function\"\n );\n}\n\nfunction _isChatModelWithBindTools(\n llm: LanguageModelLike\n): llm is BaseChatModel & Required<Pick<BaseChatModel, \"bindTools\">> {\n if (!_isBaseChatModel(llm)) return false;\n return \"bindTools\" in llm && typeof llm.bindTools === \"function\";\n}\n\nexport async function _shouldBindTools(\n llm: LanguageModelLike,\n tools: (ClientTool | ServerTool)[]\n): Promise<boolean> {\n // If model is a RunnableSequence, find a RunnableBinding or BaseChatModel in its steps\n let model = llm;\n if (RunnableSequence.isRunnableSequence(model)) {\n model =\n model.steps.find(\n (step) =>\n RunnableBinding.isRunnableBinding(step) ||\n _isBaseChatModel(step) ||\n _isConfigurableModel(step)\n ) || model;\n }\n\n if (_isConfigurableModel(model)) {\n model = await model._model();\n }\n\n // If not a RunnableBinding, we should bind tools\n if (!RunnableBinding.isRunnableBinding(model)) {\n return true;\n }\n\n let boundTools = (() => {\n // check if model.kwargs contain the tools key\n if (\n model.kwargs != null &&\n typeof model.kwargs === \"object\" &&\n \"tools\" in model.kwargs &&\n Array.isArray(model.kwargs.tools)\n ) {\n return (model.kwargs.tools ?? null) as BindToolsInput[] | null;\n }\n\n // Some models can bind the tools via `withConfig()` instead of `bind()`\n if (\n model.config != null &&\n typeof model.config === \"object\" &&\n \"tools\" in model.config &&\n Array.isArray(model.config.tools)\n ) {\n return (model.config.tools ?? null) as BindToolsInput[] | null;\n }\n\n return null;\n })();\n\n // google-style\n if (\n boundTools != null &&\n boundTools.length === 1 &&\n \"functionDeclarations\" in boundTools[0]\n ) {\n boundTools = boundTools[0].functionDeclarations;\n }\n\n // If no tools in kwargs, we should bind tools\n if (boundTools == null) return true;\n\n // Check if tools count matches\n if (tools.length !== boundTools.length) {\n throw new Error(\n \"Number of tools in the model.bindTools() and tools passed to createReactAgent must match\"\n );\n }\n\n const toolNames = new Set<string>(\n tools.flatMap((tool) => (isClientTool(tool) ? tool.name : []))\n );\n\n const boundToolNames = new Set<string>();\n\n for (const boundTool of boundTools) {\n let boundToolName: string | undefined;\n\n // OpenAI-style tool\n if (\"type\" in boundTool && boundTool.type === \"function\") {\n boundToolName = boundTool.function.name;\n }\n // Anthropic or Google-style tool\n else if (\"name\" in boundTool) {\n boundToolName = boundTool.name;\n }\n // Bedrock-style tool\n else if (\"toolSpec\" in boundTool && \"name\" in boundTool.toolSpec) {\n boundToolName = boundTool.toolSpec.name;\n }\n // unknown tool type so we'll ignore it\n else {\n continue;\n }\n\n if (boundToolName) {\n boundToolNames.add(boundToolName);\n }\n }\n\n const missingTools = [...toolNames].filter((x) => !boundToolNames.has(x));\n if (missingTools.length > 0) {\n throw new Error(\n `Missing tools '${missingTools}' in the model.bindTools().` +\n `Tools in the model.bindTools() must match the tools passed to createReactAgent.`\n );\n }\n\n return false;\n}\n\nconst _simpleBindTools = (\n llm: LanguageModelLike,\n toolClasses: (ClientTool | ServerTool)[]\n) => {\n if (_isChatModelWithBindTools(llm)) {\n return llm.bindTools(toolClasses);\n }\n\n if (\n RunnableBinding.isRunnableBinding(llm) &&\n _isChatModelWithBindTools(llm.bound)\n ) {\n const newBound = llm.bound.bindTools(toolClasses);\n\n if (RunnableBinding.isRunnableBinding(newBound)) {\n return new RunnableBinding({\n bound: newBound.bound,\n config: { ...llm.config, ...newBound.config },\n kwargs: { ...llm.kwargs, ...newBound.kwargs },\n configFactories: newBound.configFactories ?? llm.configFactories,\n });\n }\n\n return new RunnableBinding({\n bound: newBound,\n config: llm.config,\n kwargs: llm.kwargs,\n configFactories: llm.configFactories,\n });\n }\n\n return null;\n};\n\nexport async function _bindTools(\n llm: LanguageModelLike,\n toolClasses: (ClientTool | ServerTool)[]\n) {\n const model = _simpleBindTools(llm, toolClasses);\n if (model) return model;\n\n if (_isConfigurableModel(llm)) {\n const model = _simpleBindTools(await llm._model(), toolClasses);\n if (model) return model;\n }\n\n if (RunnableSequence.isRunnableSequence(llm)) {\n const modelStep = llm.steps.findIndex(\n (step) =>\n RunnableBinding.isRunnableBinding(step) ||\n _isBaseChatModel(step) ||\n _isConfigurableModel(step)\n );\n\n if (modelStep >= 0) {\n const model = _simpleBindTools(llm.steps[modelStep], toolClasses);\n if (model) {\n const nextSteps: unknown[] = llm.steps.slice();\n nextSteps.splice(modelStep, 1, model);\n\n return RunnableSequence.from(\n nextSteps as [RunnableLike, ...RunnableLike[], RunnableLike]\n );\n }\n }\n }\n\n throw new Error(`llm ${llm} must define bindTools method.`);\n}\n\nexport async function _getModel(\n llm: LanguageModelLike | ConfigurableModelInterface\n): Promise<LanguageModelLike> {\n // If model is a RunnableSequence, find a RunnableBinding or BaseChatModel in its steps\n let model = llm;\n if (RunnableSequence.isRunnableSequence(model)) {\n model =\n model.steps.find(\n (step) =>\n RunnableBinding.isRunnableBinding(step) ||\n _isBaseChatModel(step) ||\n _isConfigurableModel(step)\n ) || model;\n }\n\n if (_isConfigurableModel(model)) {\n model = await model._model();\n }\n\n // Get the underlying model from a RunnableBinding\n if (RunnableBinding.isRunnableBinding(model)) {\n model = model.bound;\n }\n\n if (!_isBaseChatModel(model)) {\n throw new Error(\n `Expected \\`llm\\` to be a ChatModel or RunnableBinding (e.g. llm.bind_tools(...)) with invoke() and generate() methods, got ${model.constructor.name}`\n );\n }\n\n return model;\n}\n\nexport type Prompt =\n | SystemMessage\n | string\n | ((\n state: typeof MessagesAnnotation.State,\n config: LangGraphRunnableConfig\n ) => BaseMessageLike[])\n | ((\n state: typeof MessagesAnnotation.State,\n config: LangGraphRunnableConfig\n ) => Promise<BaseMessageLike[]>)\n | Runnable;\n\n/** @deprecated Use Prompt instead. */\nexport type StateModifier = Prompt;\n\n/** @deprecated Use Prompt instead. */\nexport type MessageModifier =\n | SystemMessage\n | string\n | ((messages: BaseMessage[]) => BaseMessage[])\n | ((messages: BaseMessage[]) => Promise<BaseMessage[]>)\n | Runnable;\n\nexport const createReactAgentAnnotation = <\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Record<string, any> = Record<string, any>\n>() =>\n Annotation.Root({\n messages: Annotation<BaseMessage[], Messages>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n structuredResponse: Annotation<T>,\n });\n\ntype WithStateGraphNodes<K extends string, Graph> = Graph extends StateGraph<\n infer SD,\n infer S,\n infer U,\n infer N,\n infer I,\n infer O,\n infer C\n>\n ? StateGraph<SD, S, U, N | K, I, O, C>\n : never;\n\nconst PreHookAnnotation = Annotation.Root({\n llmInputMessages: Annotation<BaseMessage[], Messages>({\n reducer: (_, update) => messagesStateReducer([], update),\n default: () => [],\n }),\n});\n\ntype PreHookAnnotation = typeof PreHookAnnotation;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyAnnotationRoot = AnnotationRoot<any>;\n\ntype ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> =\n A extends AnyAnnotationRoot\n ? A\n : A extends InteropZodObject\n ? AnnotationRoot<InteropZodToStateDefinition<A>>\n : never;\n\n/**\n * @deprecated `CreateReactAgentParams` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { CreateAgentParams } from \"langchain\";`\n */\nexport type CreateReactAgentParams<\n A extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n StructuredResponseType extends Record<string, any> = Record<string, any>,\n C extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n> = {\n /** The chat model that can utilize OpenAI-style tool calling. */\n llm:\n | LanguageModelLike\n | ((\n state: ToAnnotationRoot<A>[\"State\"] & PreHookAnnotation[\"State\"],\n runtime: Runtime<ToAnnotationRoot<C>[\"State\"]>\n ) => Promise<LanguageModelLike> | LanguageModelLike);\n\n /** A list of tools or a ToolNode. */\n tools: ToolNode | (ServerTool | ClientTool)[];\n\n /**\n * @deprecated Use prompt instead.\n */\n messageModifier?: MessageModifier;\n\n /**\n * @deprecated Use prompt instead.\n */\n stateModifier?: StateModifier;\n\n /**\n * An optional prompt for the LLM. This takes full graph state BEFORE the LLM is called and prepares the input to LLM.\n *\n * Can take a few different forms:\n *\n * - str: This is converted to a SystemMessage and added to the beginning of the list of messages in state[\"messages\"].\n * - SystemMessage: this is added to the beginning of the list of messages in state[\"messages\"].\n * - Function: This function should take in full graph state and the output is then passed to the language model.\n * - Runnable: This runnable should take in full graph state and the output is then passed to the language model.\n *\n * Note:\n * Prior to `v0.2.46`, the prompt was set using `stateModifier` / `messagesModifier` parameters.\n * This is now deprecated and will be removed in a future release.\n */\n prompt?: Prompt;\n\n /**\n * Additional state schema for the agent.\n */\n stateSchema?: A;\n\n /**\n * An optional schema for the context.\n */\n contextSchema?: C;\n /** An optional checkpoint saver to persist the agent's state. */\n checkpointSaver?: BaseCheckpointSaver | boolean;\n /** An optional checkpoint saver to persist the agent's state. Alias of \"checkpointSaver\". */\n checkpointer?: BaseCheckpointSaver | boolean;\n /** An optional list of node names to interrupt before running. */\n interruptBefore?: N[] | All;\n /** An optional list of node names to interrupt after running. */\n interruptAfter?: N[] | All;\n store?: BaseStore;\n /**\n * An optional schema for the final agent output.\n *\n * If provided, output will be formatted to match the given schema and returned in the 'structuredResponse' state key.\n * If not provided, `structuredResponse` will not be present in the output state.\n *\n * Can be passed in as:\n * - Zod schema\n * - JSON schema\n * - { prompt, schema }, where schema is one of the above.\n * The prompt will be used together with the model that is being used to generate the structured response.\n *\n * @remarks\n * **Important**: `responseFormat` requires the model to support `.withStructuredOutput()`.\n *\n * **Note**: The graph will make a separate call to the LLM to generate the structured response after the agent loop is finished.\n * This is not the only strategy to get structured responses, see more options in [this guide](https://langchain-ai.github.io/langgraph/how-tos/react-agent-structured-output/).\n */\n responseFormat?:\n | InteropZodType<StructuredResponseType>\n | StructuredResponseSchemaOptions<StructuredResponseType>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>;\n\n /**\n * An optional name for the agent.\n */\n name?: string;\n\n /**\n * An optional description for the agent.\n * This can be used to describe the agent to the underlying supervisor LLM.\n */\n description?: string | undefined;\n\n /**\n * Use to specify how to expose the agent name to the underlying supervisor LLM.\n\n - undefined: Relies on the LLM provider {@link AIMessage#name}. Currently, only OpenAI supports this.\n - `\"inline\"`: Add the agent name directly into the content field of the {@link AIMessage} using XML-style tags.\n Example: `\"How can I help you\"` -> `\"<name>agent_name</name><content>How can I help you?</content>\"`\n */\n includeAgentName?: \"inline\" | undefined;\n\n /**\n * An optional node to add before the `agent` node (i.e., the node that calls the LLM).\n * Useful for managing long message histories (e.g., message trimming, summarization, etc.).\n */\n preModelHook?: RunnableLike<\n ToAnnotationRoot<A>[\"State\"] & PreHookAnnotation[\"State\"],\n ToAnnotationRoot<A>[\"Update\"] & PreHookAnnotation[\"Update\"],\n LangGraphRunnableConfig\n >;\n\n /**\n * An optional node to add after the `agent` node (i.e., the node that calls the LLM).\n * Useful for implementing human-in-the-loop, guardrails, validation, or other post-processing.\n */\n postModelHook?: RunnableLike<\n ToAnnotationRoot<A>[\"State\"],\n ToAnnotationRoot<A>[\"Update\"],\n LangGraphRunnableConfig\n >;\n\n /**\n * Determines the version of the graph to create.\n *\n * Can be one of\n * - `\"v1\"`: The tool node processes a single message. All tool calls in the message are\n * executed in parallel within the tool node.\n * - `\"v2\"`: The tool node processes a single tool call. Tool calls are distributed across\n * multiple instances of the tool node using the Send API.\n *\n * @default `\"v1\"`\n */\n version?: \"v1\" | \"v2\";\n};\n\n/**\n * @deprecated `createReactAgent` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { createAgent } from \"langchain\";`\n *\n * Creates a StateGraph agent that relies on a chat model utilizing tool calling.\n *\n * @example\n * ```ts\n * import { ChatOpenAI } from \"@langchain/openai\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n * import { createReactAgent } from \"@langchain/langgraph/prebuilt\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * })\n * })\n *\n * const agent = createReactAgent({ llm: model, tools: [getWeather] });\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await agent.stream(inputs, { streamMode: \"values\" });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\nexport function createReactAgent<\n A extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n C extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot\n>(\n params: CreateReactAgentParams<A, StructuredResponseFormat, C>\n): CompiledStateGraph<\n ToAnnotationRoot<A>[\"State\"],\n ToAnnotationRoot<A>[\"Update\"],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n any,\n typeof MessagesAnnotation.spec & ToAnnotationRoot<A>[\"spec\"],\n ReturnType<\n typeof createReactAgentAnnotation<StructuredResponseFormat>\n >[\"spec\"] &\n ToAnnotationRoot<A>[\"spec\"]\n> {\n const {\n llm,\n tools,\n messageModifier,\n stateModifier,\n prompt,\n stateSchema,\n contextSchema,\n checkpointSaver,\n checkpointer,\n interruptBefore,\n interruptAfter,\n store,\n responseFormat,\n preModelHook,\n postModelHook,\n name,\n description,\n version = \"v1\",\n includeAgentName,\n } = params;\n\n let toolClasses: (ClientTool | ServerTool)[];\n\n let toolNode: ToolNode;\n if (!Array.isArray(tools)) {\n toolClasses = tools.tools;\n toolNode = tools;\n } else {\n toolClasses = tools;\n toolNode = new ToolNode(toolClasses.filter(isClientTool));\n }\n\n let cachedStaticModel: Runnable | null = null;\n\n const _getStaticModel = async (llm: LanguageModelLike): Promise<Runnable> => {\n if (cachedStaticModel) return cachedStaticModel;\n\n let modelWithTools: LanguageModelLike;\n if (await _shouldBindTools(llm, toolClasses)) {\n modelWithTools = await _bindTools(llm, toolClasses);\n } else {\n modelWithTools = llm;\n }\n\n const promptRunnable = _getPrompt(prompt, stateModifier, messageModifier);\n const modelRunnable =\n includeAgentName === \"inline\"\n ? withAgentName(modelWithTools, includeAgentName)\n : modelWithTools;\n\n cachedStaticModel = promptRunnable.pipe(modelRunnable);\n return cachedStaticModel;\n };\n\n const _getDynamicModel = async (\n llm: (\n state: AgentState<StructuredResponseFormat> & PreHookAnnotation[\"State\"],\n runtime: Runtime<ToAnnotationRoot<C>[\"State\"]>\n ) => Promise<LanguageModelLike> | LanguageModelLike,\n state: AgentState<StructuredResponseFormat> & PreHookAnnotation[\"State\"],\n config: Runtime<ToAnnotationRoot<C>[\"State\"]>\n ) => {\n const model = await llm(state, config);\n\n return _getPrompt(prompt, stateModifier, messageModifier).pipe(\n includeAgentName === \"inline\"\n ? withAgentName(model, includeAgentName)\n : model\n );\n };\n\n // If any of the tools are configured to return_directly after running,\n // our graph needs to check if these were called\n const shouldReturnDirect = new Set(\n toolClasses\n .filter(isClientTool)\n .filter((tool) => \"returnDirect\" in tool && tool.returnDirect)\n .map((tool) => tool.name)\n );\n\n function getModelInputState(\n state: AgentState<StructuredResponseFormat> & PreHookAnnotation[\"State\"]\n ): Omit<AgentState<StructuredResponseFormat>, \"llmInputMessages\"> {\n const { messages, llmInputMessages, ...rest } = state;\n if (llmInputMessages != null && llmInputMessages.length > 0) {\n return { messages: llmInputMessages, ...rest };\n }\n return { messages, ...rest };\n }\n\n const generateStructuredResponse = async (\n state: AgentState<StructuredResponseFormat> & PreHookAnnotation[\"State\"],\n config: Runtime<ToAnnotationRoot<C>[\"State\"]>\n ) => {\n if (responseFormat == null) {\n throw new Error(\n \"Attempted to generate structured output with no passed response schema. Please contact us for help.\"\n );\n }\n const messages = [...state.messages];\n let modelWithStructuredOutput;\n\n const model: LanguageModelLike =\n typeof llm === \"function\"\n ? await llm(state, config)\n : await _getModel(llm);\n\n if (!_isBaseChatModel(model)) {\n throw new Error(\n `Expected \\`llm\\` to be a ChatModel with .withStructuredOutput() method, got ${model.constructor.name}`\n );\n }\n\n if (typeof responseFormat === \"object\" && \"schema\" in responseFormat) {\n const { prompt, schema, ...options } =\n responseFormat as StructuredResponseSchemaOptions<StructuredResponseFormat>;\n\n modelWithStructuredOutput = model.withStructuredOutput(schema, options);\n if (prompt != null) {\n messages.unshift(new SystemMessage({ content: prompt }));\n }\n } else {\n modelWithStructuredOutput = model.withStructuredOutput(responseFormat);\n }\n\n const response = await modelWithStructuredOutput.invoke(messages, config);\n return { structuredResponse: response };\n };\n\n const callModel = async (\n state: AgentState<StructuredResponseFormat> & PreHookAnnotation[\"State\"],\n config: Runtime<ToAnnotationRoot<C>[\"State\"]>\n ) => {\n // NOTE: we're dynamically creating the model runnable here\n // to ensure that we can validate ConfigurableModel properly\n const modelRunnable: Runnable =\n typeof llm === \"function\"\n ? await _getDynamicModel(llm, state, config)\n : await _getStaticModel(llm);\n\n // TODO: Auto-promote streaming.\n const response = (await modelRunnable.invoke(\n getModelInputState(state),\n config\n )) as BaseMessage;\n // add agent name to the AIMessage\n // TODO: figure out if we can avoid mutating the message directly\n response.name = name;\n response.lc_kwargs.name = name;\n return { messages: [response] };\n };\n\n const schema =\n stateSchema ?? createReactAgentAnnotation<StructuredResponseFormat>();\n\n const workflow = new StateGraph(\n schema as AnyAnnotationRoot,\n contextSchema\n ).addNode(\"tools\", toolNode);\n\n if (!(\"messages\" in workflow._schemaDefinition)) {\n throw new Error(\"Missing required `messages` key in state schema.\");\n }\n\n const allNodeWorkflows = workflow as WithStateGraphNodes<\n | \"pre_model_hook\"\n | \"post_model_hook\"\n | \"generate_structured_response\"\n | \"agent\",\n typeof workflow\n >;\n\n const conditionalMap = <T extends string>(map: Record<string, T | null>) => {\n return Object.fromEntries(\n Object.entries(map).filter(([_, v]) => v != null) as [string, T][]\n );\n };\n\n let entrypoint: \"agent\" | \"pre_model_hook\" = \"agent\";\n let inputSchema: AnnotationRoot<ToAnnotationRoot<A>[\"spec\"]> | undefined;\n if (preModelHook != null) {\n allNodeWorkflows\n .addNode(\"pre_model_hook\", preModelHook)\n .addEdge(\"pre_model_hook\", \"agent\");\n entrypoint = \"pre_model_hook\";\n\n inputSchema = Annotation.Root({\n ...workflow._schemaDefinition,\n ...PreHookAnnotation.spec,\n });\n } else {\n entrypoint = \"agent\";\n }\n\n allNodeWorkflows\n .addNode(\"agent\", callModel, { input: inputSchema })\n .addEdge(START, entrypoint);\n\n if (postModelHook != null) {\n allNodeWorkflows\n .addNode(\"post_model_hook\", postModelHook)\n .addEdge(\"agent\", \"post_model_hook\")\n .addConditionalEdges(\n \"post_model_hook\",\n (state) => {\n const { messages } = state as AgentState<StructuredResponseFormat>;\n\n const toolMessageIds: Set<string> = new Set(\n messages.filter(isToolMessage).map((msg) => msg.tool_call_id)\n );\n\n let lastAiMessage: AIMessage | undefined;\n for (let i = messages.length - 1; i >= 0; i -= 1) {\n const message = messages[i];\n if (isAIMessage(message)) {\n lastAiMessage = message;\n break;\n }\n }\n\n const pendingToolCalls =\n lastAiMessage?.tool_calls?.filter(\n (i) => i.id == null || !toolMessageIds.has(i.id)\n ) ?? [];\n\n const lastMessage = messages[messages.length - 1];\n if (pendingToolCalls.length > 0) {\n if (version === \"v2\") {\n return pendingToolCalls.map(\n (toolCall) =>\n new Send(\"tools\", { ...state, lg_tool_call: toolCall })\n );\n }\n return \"tools\";\n }\n\n if (lastMessage && isToolMessage(lastMessage)) return entrypoint;\n if (responseFormat != null) return \"generate_structured_response\";\n return END;\n },\n conditionalMap({\n tools: \"tools\",\n [entrypoint]: entrypoint,\n generate_structured_response:\n responseFormat != null ? \"generate_structured_response\" : null,\n [END]: responseFormat != null ? null : END,\n })\n );\n }\n\n if (responseFormat !== undefined) {\n workflow\n .addNode(\"generate_structured_response\", generateStructuredResponse)\n .addEdge(\"generate_structured_response\", END);\n }\n\n if (postModelHook == null) {\n allNodeWorkflows.addConditionalEdges(\n \"agent\",\n (state) => {\n const { messages } = state;\n const lastMessage = messages[messages.length - 1];\n\n // if there's no function call, we finish\n if (!isAIMessage(lastMessage) || !lastMessage.tool_calls?.length) {\n if (responseFormat != null) return \"generate_structured_response\";\n return END;\n }\n\n // there are function calls, we continue\n if (version === \"v2\") {\n return lastMessage.tool_calls.map(\n (toolCall) =>\n new Send(\"tools\", { ...state, lg_tool_call: toolCall })\n );\n }\n\n return \"tools\";\n },\n conditionalMap({\n tools: \"tools\",\n generate_structured_response:\n responseFormat != null ? \"generate_structured_response\" : null,\n [END]: responseFormat != null ? null : END,\n })\n );\n }\n\n if (shouldReturnDirect.size > 0) {\n allNodeWorkflows.addConditionalEdges(\n \"tools\",\n (state) => {\n const agentState = state;\n // Check the last consecutive tool calls\n for (let i = agentState.messages.length - 1; i >= 0; i -= 1) {\n const message = agentState.messages[i];\n if (!isToolMessage(message)) break;\n\n // Check if this tool is configured to return directly\n if (\n message.name !== undefined &&\n shouldReturnDirect.has(message.name)\n ) {\n return END;\n }\n }\n\n return entrypoint;\n },\n conditionalMap({ [entrypoint]: entrypoint, [END]: END })\n );\n } else {\n allNodeWorkflows.addEdge(\"tools\", entrypoint);\n }\n\n return allNodeWorkflows.compile({\n checkpointer: checkpointer ?? checkpointSaver,\n interruptBefore,\n interruptAfter,\n store,\n name,\n description,\n });\n}\n"],"mappings":";;;;;;;;;;AA2EA,SAAS,gCACP,iBACQ;AAER,KACE,OAAO,oBAAoB,aAAA,GAAA,yBAAA,eACZ,gBAAgB,IAAI,gBAAgB,UAAU,KAAK,SAElE,QAAO;AAIT,KAAI,OAAO,oBAAoB,WAC7B,QAAO,OAAO,UACZ,gBAAgB,MAAM,SAAS;AAInC,KAAIA,0BAAAA,SAAS,WAAW,gBAAgB,CACtC,QAAOC,0BAAAA,eAAe,MACnB,UAA2C,MAAM,SACnD,CAAC,KAAK,gBAAgB;AAGzB,OAAM,IAAI,MACR,wCAAwC,OAAO,kBAChD;;AAGH,MAAM,uBAAuB;AAE7B,SAAS,mBAAmB,QAA2B;CACrD,IAAI;AAEJ,KAAI,UAAU,KACZ,kBAAiBA,0BAAAA,eAAe,MAC7B,UAA2C,MAAM,SACnD,CAAC,WAAW,EAAE,SAAS,sBAAsB,CAAC;UACtC,OAAO,WAAW,UAAU;EACrC,MAAM,gBAAgB,IAAIC,yBAAAA,cAAc,OAAO;AAC/C,mBAAiBD,0BAAAA,eAAe,MAC7B,UAA2C;AAC1C,UAAO,CAAC,eAAe,GAAI,MAAM,YAAY,EAAE,CAAE;IAEpD,CAAC,WAAW,EAAE,SAAS,sBAAsB,CAAC;wDACxB,OAAO,IAAI,OAAO,UAAU,KAAK,SACxD,kBAAiBA,0BAAAA,eAAe,MAC7B,UAA2C,CAAC,QAAQ,GAAG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OAAO,EAC5B,kBAAiB,oBACf,UACC,UAAU;EACT,MAAM,aAAa;AAEnB,OAAK,IAAI,IAAI,WAAW,SAAS,SAAS,GAAG,KAAK,GAAG,KAAK,GAAG;GAC3D,MAAM,UAAU,WAAW,SAAS;AACpC,OAAI,EAAA,GAAA,yBAAA,eAAe,QAAQ,CAAE;AAG7B,OACE,QAAQ,SAAS,KAAA,KACjB,mBAAmB,IAAI,QAAQ,KAAK,CAEpC,QAAOA,kBAAAA;;AAIX,SAAO;IAET,eAAe;GAAG,aAAa;GAAaA,kBAAAA,MAAMA,kBAAAA;EAAK,CAAC,CACzD;KAED,kBAAiB,QAAQ,SAAS,WAAW;AAG/C,QAAO,iBAAiB,QAAQ;EAC9B,cAAc,gBAAgB;EAC9B;EACA;EACA;EACA;EACA;EACD,CAAC"}
|
|
1
|
+
{"version":3,"file":"react_agent_executor.cjs","names":["Runnable","RunnableLambda","SystemMessage","RunnableSequence","RunnableBinding","Annotation","messagesStateReducer","ToolNode","withAgentName","StateGraph","START","isToolMessage","Send","END"],"sources":["../../src/prebuilt/react_agent_executor.ts"],"sourcesContent":["import {\n BaseChatModel,\n BindToolsInput,\n} from \"@langchain/core/language_models/chat_models\";\nimport { LanguageModelLike } from \"@langchain/core/language_models/base\";\nimport {\n BaseMessage,\n BaseMessageLike,\n isAIMessage,\n isBaseMessage,\n isToolMessage,\n SystemMessage,\n type AIMessage,\n} from \"@langchain/core/messages\";\nimport {\n Runnable,\n RunnableLambda,\n RunnableToolLike,\n RunnableSequence,\n RunnableBinding,\n type RunnableLike,\n} from \"@langchain/core/runnables\";\nimport { DynamicTool, StructuredToolInterface } from \"@langchain/core/tools\";\nimport type {\n InteropZodObject,\n InteropZodType,\n} from \"@langchain/core/utils/types\";\nimport {\n All,\n BaseCheckpointSaver,\n BaseStore,\n} from \"@langchain/langgraph-checkpoint\";\n\nimport {\n StateGraph,\n type CompiledStateGraph,\n AnnotationRoot,\n} from \"../graph/index.js\";\nimport { MessagesAnnotation } from \"../graph/messages_annotation.js\";\nimport { ToolNode } from \"./tool_node.js\";\nimport { LangGraphRunnableConfig, Runtime } from \"../pregel/runnable_types.js\";\nimport { Annotation } from \"../graph/annotation.js\";\nimport { Messages, messagesStateReducer } from \"../graph/messages_reducer.js\";\nimport { END, Send, START } from \"../constants.js\";\nimport { withAgentName } from \"./agentName.js\";\nimport type { InteropZodToStateDefinition } from \"../graph/zod/meta.js\";\n\n/**\n * @deprecated `AgentState` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { AgentState } from \"langchain\";`\n */\nexport interface AgentState<\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n StructuredResponseType extends Record<string, any> = Record<string, any>,\n> {\n messages: BaseMessage[];\n // TODO: This won't be set until we\n // implement managed values in LangGraphJS\n // Will be useful for inserting a message on\n // graph recursion end\n // is_last_step: boolean;\n structuredResponse: StructuredResponseType;\n}\n\nexport type N = typeof START | \"agent\" | \"tools\";\n\ntype StructuredResponseSchemaOptions<StructuredResponseType> = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n schema: InteropZodType<StructuredResponseType> | Record<string, any>;\n prompt?: string;\n\n strict?: boolean;\n [key: string]: unknown;\n};\n\nfunction _convertMessageModifierToPrompt(\n messageModifier: MessageModifier\n): Prompt {\n // Handle string or SystemMessage\n if (\n typeof messageModifier === \"string\" ||\n (isBaseMessage(messageModifier) && messageModifier._getType() === \"system\")\n ) {\n return messageModifier;\n }\n\n // Handle callable function\n if (typeof messageModifier === \"function\") {\n return async (state: typeof MessagesAnnotation.State) =>\n messageModifier(state.messages);\n }\n\n // Handle Runnable\n if (Runnable.isRunnable(messageModifier)) {\n return RunnableLambda.from(\n (state: typeof MessagesAnnotation.State) => state.messages\n ).pipe(messageModifier);\n }\n\n throw new Error(\n `Unexpected type for messageModifier: ${typeof messageModifier}`\n );\n}\n\nconst PROMPT_RUNNABLE_NAME = \"prompt\";\n\nfunction _getPromptRunnable(prompt?: Prompt): Runnable {\n let promptRunnable: Runnable;\n\n if (prompt == null) {\n promptRunnable = RunnableLambda.from(\n (state: typeof MessagesAnnotation.State) => state.messages\n ).withConfig({ runName: PROMPT_RUNNABLE_NAME });\n } else if (typeof prompt === \"string\") {\n const systemMessage = new SystemMessage(prompt);\n promptRunnable = RunnableLambda.from(\n (state: typeof MessagesAnnotation.State) => {\n return [systemMessage, ...(state.messages ?? [])];\n }\n ).withConfig({ runName: PROMPT_RUNNABLE_NAME });\n } else if (isBaseMessage(prompt) && prompt._getType() === \"system\") {\n promptRunnable = RunnableLambda.from(\n (state: typeof MessagesAnnotation.State) => [prompt, ...state.messages]\n ).withConfig({ runName: PROMPT_RUNNABLE_NAME });\n } else if (typeof prompt === \"function\") {\n promptRunnable = RunnableLambda.from(prompt).withConfig({\n runName: PROMPT_RUNNABLE_NAME,\n });\n } else if (Runnable.isRunnable(prompt)) {\n promptRunnable = prompt;\n } else {\n throw new Error(`Got unexpected type for 'prompt': ${typeof prompt}`);\n }\n\n return promptRunnable;\n}\n\ntype ServerTool = Record<string, unknown>;\ntype ClientTool = StructuredToolInterface | DynamicTool | RunnableToolLike;\n\nfunction isClientTool(tool: ClientTool | ServerTool): tool is ClientTool {\n return Runnable.isRunnable(tool);\n}\n\nfunction _getPrompt(\n prompt?: Prompt,\n stateModifier?: CreateReactAgentParams[\"stateModifier\"],\n messageModifier?: CreateReactAgentParams[\"messageModifier\"]\n): Runnable {\n // Check if multiple modifiers exist\n const definedCount = [prompt, stateModifier, messageModifier].filter(\n (x) => x != null\n ).length;\n if (definedCount > 1) {\n throw new Error(\n \"Expected only one of prompt, stateModifier, or messageModifier, got multiple values\"\n );\n }\n\n let finalPrompt = prompt;\n if (stateModifier != null) {\n finalPrompt = stateModifier;\n } else if (messageModifier != null) {\n finalPrompt = _convertMessageModifierToPrompt(messageModifier);\n }\n\n return _getPromptRunnable(finalPrompt);\n}\n\nfunction _isBaseChatModel(model: LanguageModelLike): model is BaseChatModel {\n return (\n \"invoke\" in model &&\n typeof model.invoke === \"function\" &&\n \"_modelType\" in model\n );\n}\n\ninterface ConfigurableModelInterface {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n _queuedMethodOperations: Record<string, any>;\n _model: () => Promise<BaseChatModel>;\n}\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nfunction _isConfigurableModel(model: any): model is ConfigurableModelInterface {\n return (\n \"_queuedMethodOperations\" in model &&\n \"_model\" in model &&\n typeof model._model === \"function\"\n );\n}\n\nfunction _isChatModelWithBindTools(\n llm: LanguageModelLike\n): llm is BaseChatModel & Required<Pick<BaseChatModel, \"bindTools\">> {\n if (!_isBaseChatModel(llm)) return false;\n return \"bindTools\" in llm && typeof llm.bindTools === \"function\";\n}\n\nexport async function _shouldBindTools(\n llm: LanguageModelLike,\n tools: (ClientTool | ServerTool)[]\n): Promise<boolean> {\n // If model is a RunnableSequence, find a RunnableBinding or BaseChatModel in its steps\n let model = llm;\n if (RunnableSequence.isRunnableSequence(model)) {\n model =\n model.steps.find(\n (step) =>\n RunnableBinding.isRunnableBinding(step) ||\n _isBaseChatModel(step) ||\n _isConfigurableModel(step)\n ) || model;\n }\n\n if (_isConfigurableModel(model)) {\n model = await model._model();\n }\n\n // If not a RunnableBinding, we should bind tools\n if (!RunnableBinding.isRunnableBinding(model)) {\n return true;\n }\n\n let boundTools = (() => {\n // check if model.kwargs contain the tools key\n if (\n model.kwargs != null &&\n typeof model.kwargs === \"object\" &&\n \"tools\" in model.kwargs &&\n Array.isArray(model.kwargs.tools)\n ) {\n return (model.kwargs.tools ?? null) as BindToolsInput[] | null;\n }\n\n // Some models can bind the tools via `withConfig()` instead of `bind()`\n if (\n model.config != null &&\n typeof model.config === \"object\" &&\n \"tools\" in model.config &&\n Array.isArray(model.config.tools)\n ) {\n return (model.config.tools ?? null) as BindToolsInput[] | null;\n }\n\n return null;\n })();\n\n // google-style\n if (\n boundTools != null &&\n boundTools.length === 1 &&\n \"functionDeclarations\" in boundTools[0]\n ) {\n boundTools = boundTools[0].functionDeclarations;\n }\n\n // If no tools in kwargs, we should bind tools\n if (boundTools == null) return true;\n\n // Check if tools count matches\n if (tools.length !== boundTools.length) {\n throw new Error(\n \"Number of tools in the model.bindTools() and tools passed to createReactAgent must match\"\n );\n }\n\n const toolNames = new Set<string>(\n tools.flatMap((tool) => (isClientTool(tool) ? tool.name : []))\n );\n\n const boundToolNames = new Set<string>();\n\n for (const boundTool of boundTools) {\n let boundToolName: string | undefined;\n\n // OpenAI-style tool\n if (\"type\" in boundTool && boundTool.type === \"function\") {\n boundToolName = boundTool.function.name;\n }\n // Anthropic or Google-style tool\n else if (\"name\" in boundTool) {\n boundToolName = boundTool.name;\n }\n // Bedrock-style tool\n else if (\"toolSpec\" in boundTool && \"name\" in boundTool.toolSpec) {\n boundToolName = boundTool.toolSpec.name;\n }\n // unknown tool type so we'll ignore it\n else {\n continue;\n }\n\n if (boundToolName) {\n boundToolNames.add(boundToolName);\n }\n }\n\n const missingTools = [...toolNames].filter((x) => !boundToolNames.has(x));\n if (missingTools.length > 0) {\n throw new Error(\n `Missing tools '${missingTools}' in the model.bindTools().` +\n `Tools in the model.bindTools() must match the tools passed to createReactAgent.`\n );\n }\n\n return false;\n}\n\nconst _simpleBindTools = (\n llm: LanguageModelLike,\n toolClasses: (ClientTool | ServerTool)[]\n) => {\n if (_isChatModelWithBindTools(llm)) {\n return llm.bindTools(toolClasses);\n }\n\n if (\n RunnableBinding.isRunnableBinding(llm) &&\n _isChatModelWithBindTools(llm.bound)\n ) {\n const newBound = llm.bound.bindTools(toolClasses);\n\n if (RunnableBinding.isRunnableBinding(newBound)) {\n return new RunnableBinding({\n bound: newBound.bound,\n config: { ...llm.config, ...newBound.config },\n kwargs: { ...llm.kwargs, ...newBound.kwargs },\n configFactories: newBound.configFactories ?? llm.configFactories,\n });\n }\n\n return new RunnableBinding({\n bound: newBound,\n config: llm.config,\n kwargs: llm.kwargs,\n configFactories: llm.configFactories,\n });\n }\n\n return null;\n};\n\nexport async function _bindTools(\n llm: LanguageModelLike,\n toolClasses: (ClientTool | ServerTool)[]\n) {\n const model = _simpleBindTools(llm, toolClasses);\n if (model) return model;\n\n if (_isConfigurableModel(llm)) {\n const model = _simpleBindTools(await llm._model(), toolClasses);\n if (model) return model;\n }\n\n if (RunnableSequence.isRunnableSequence(llm)) {\n const modelStep = llm.steps.findIndex(\n (step) =>\n RunnableBinding.isRunnableBinding(step) ||\n _isBaseChatModel(step) ||\n _isConfigurableModel(step)\n );\n\n if (modelStep >= 0) {\n const model = _simpleBindTools(llm.steps[modelStep], toolClasses);\n if (model) {\n const nextSteps: unknown[] = llm.steps.slice();\n nextSteps.splice(modelStep, 1, model);\n\n return RunnableSequence.from(\n nextSteps as [RunnableLike, ...RunnableLike[], RunnableLike]\n );\n }\n }\n }\n\n throw new Error(`llm ${llm} must define bindTools method.`);\n}\n\nexport async function _getModel(\n llm: LanguageModelLike | ConfigurableModelInterface\n): Promise<LanguageModelLike> {\n // If model is a RunnableSequence, find a RunnableBinding or BaseChatModel in its steps\n let model = llm;\n if (RunnableSequence.isRunnableSequence(model)) {\n model =\n model.steps.find(\n (step) =>\n RunnableBinding.isRunnableBinding(step) ||\n _isBaseChatModel(step) ||\n _isConfigurableModel(step)\n ) || model;\n }\n\n if (_isConfigurableModel(model)) {\n model = await model._model();\n }\n\n // Get the underlying model from a RunnableBinding\n if (RunnableBinding.isRunnableBinding(model)) {\n model = model.bound;\n }\n\n if (!_isBaseChatModel(model)) {\n throw new Error(\n `Expected \\`llm\\` to be a ChatModel or RunnableBinding (e.g. llm.bind_tools(...)) with invoke() and generate() methods, got ${model.constructor.name}`\n );\n }\n\n return model;\n}\n\nexport type Prompt =\n | SystemMessage\n | string\n | ((\n state: typeof MessagesAnnotation.State,\n config: LangGraphRunnableConfig\n ) => BaseMessageLike[])\n | ((\n state: typeof MessagesAnnotation.State,\n config: LangGraphRunnableConfig\n ) => Promise<BaseMessageLike[]>)\n | Runnable;\n\n/** @deprecated Use Prompt instead. */\nexport type StateModifier = Prompt;\n\n/** @deprecated Use Prompt instead. */\nexport type MessageModifier =\n | SystemMessage\n | string\n | ((messages: BaseMessage[]) => BaseMessage[])\n | ((messages: BaseMessage[]) => Promise<BaseMessage[]>)\n | Runnable;\n\nexport const createReactAgentAnnotation = <\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n T extends Record<string, any> = Record<string, any>,\n>() =>\n Annotation.Root({\n messages: Annotation<BaseMessage[], Messages>({\n reducer: messagesStateReducer,\n default: () => [],\n }),\n structuredResponse: Annotation<T>,\n });\n\ntype WithStateGraphNodes<K extends string, Graph> =\n Graph extends StateGraph<\n infer SD,\n infer S,\n infer U,\n infer N,\n infer I,\n infer O,\n infer C\n >\n ? StateGraph<SD, S, U, N | K, I, O, C>\n : never;\n\nconst PreHookAnnotation = Annotation.Root({\n llmInputMessages: Annotation<BaseMessage[], Messages>({\n reducer: (_, update) => messagesStateReducer([], update),\n default: () => [],\n }),\n});\n\ntype PreHookAnnotation = typeof PreHookAnnotation;\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\ntype AnyAnnotationRoot = AnnotationRoot<any>;\n\ntype ToAnnotationRoot<A extends AnyAnnotationRoot | InteropZodObject> =\n A extends AnyAnnotationRoot\n ? A\n : A extends InteropZodObject\n ? AnnotationRoot<InteropZodToStateDefinition<A>>\n : never;\n\n/**\n * @deprecated `CreateReactAgentParams` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { CreateAgentParams } from \"langchain\";`\n */\nexport type CreateReactAgentParams<\n A extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n StructuredResponseType extends Record<string, any> = Record<string, any>,\n C extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot,\n> = {\n /** The chat model that can utilize OpenAI-style tool calling. */\n llm:\n | LanguageModelLike\n | ((\n state: ToAnnotationRoot<A>[\"State\"] & PreHookAnnotation[\"State\"],\n runtime: Runtime<ToAnnotationRoot<C>[\"State\"]>\n ) => Promise<LanguageModelLike> | LanguageModelLike);\n\n /** A list of tools or a ToolNode. */\n tools: ToolNode | (ServerTool | ClientTool)[];\n\n /**\n * @deprecated Use prompt instead.\n */\n messageModifier?: MessageModifier;\n\n /**\n * @deprecated Use prompt instead.\n */\n stateModifier?: StateModifier;\n\n /**\n * An optional prompt for the LLM. This takes full graph state BEFORE the LLM is called and prepares the input to LLM.\n *\n * Can take a few different forms:\n *\n * - str: This is converted to a SystemMessage and added to the beginning of the list of messages in state[\"messages\"].\n * - SystemMessage: this is added to the beginning of the list of messages in state[\"messages\"].\n * - Function: This function should take in full graph state and the output is then passed to the language model.\n * - Runnable: This runnable should take in full graph state and the output is then passed to the language model.\n *\n * Note:\n * Prior to `v0.2.46`, the prompt was set using `stateModifier` / `messagesModifier` parameters.\n * This is now deprecated and will be removed in a future release.\n */\n prompt?: Prompt;\n\n /**\n * Additional state schema for the agent.\n */\n stateSchema?: A;\n\n /**\n * An optional schema for the context.\n */\n contextSchema?: C;\n /** An optional checkpoint saver to persist the agent's state. */\n checkpointSaver?: BaseCheckpointSaver | boolean;\n /** An optional checkpoint saver to persist the agent's state. Alias of \"checkpointSaver\". */\n checkpointer?: BaseCheckpointSaver | boolean;\n /** An optional list of node names to interrupt before running. */\n interruptBefore?: N[] | All;\n /** An optional list of node names to interrupt after running. */\n interruptAfter?: N[] | All;\n store?: BaseStore;\n /**\n * An optional schema for the final agent output.\n *\n * If provided, output will be formatted to match the given schema and returned in the 'structuredResponse' state key.\n * If not provided, `structuredResponse` will not be present in the output state.\n *\n * Can be passed in as:\n * - Zod schema\n * - JSON schema\n * - { prompt, schema }, where schema is one of the above.\n * The prompt will be used together with the model that is being used to generate the structured response.\n *\n * @remarks\n * **Important**: `responseFormat` requires the model to support `.withStructuredOutput()`.\n *\n * **Note**: The graph will make a separate call to the LLM to generate the structured response after the agent loop is finished.\n * This is not the only strategy to get structured responses, see more options in [this guide](https://langchain-ai.github.io/langgraph/how-tos/react-agent-structured-output/).\n */\n responseFormat?:\n | InteropZodType<StructuredResponseType>\n | StructuredResponseSchemaOptions<StructuredResponseType>\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n | Record<string, any>;\n\n /**\n * An optional name for the agent.\n */\n name?: string;\n\n /**\n * An optional description for the agent.\n * This can be used to describe the agent to the underlying supervisor LLM.\n */\n description?: string | undefined;\n\n /**\n * Use to specify how to expose the agent name to the underlying supervisor LLM.\n\n - undefined: Relies on the LLM provider {@link AIMessage#name}. Currently, only OpenAI supports this.\n - `\"inline\"`: Add the agent name directly into the content field of the {@link AIMessage} using XML-style tags.\n Example: `\"How can I help you\"` -> `\"<name>agent_name</name><content>How can I help you?</content>\"`\n */\n includeAgentName?: \"inline\" | undefined;\n\n /**\n * An optional node to add before the `agent` node (i.e., the node that calls the LLM).\n * Useful for managing long message histories (e.g., message trimming, summarization, etc.).\n */\n preModelHook?: RunnableLike<\n ToAnnotationRoot<A>[\"State\"] & PreHookAnnotation[\"State\"],\n ToAnnotationRoot<A>[\"Update\"] & PreHookAnnotation[\"Update\"],\n LangGraphRunnableConfig\n >;\n\n /**\n * An optional node to add after the `agent` node (i.e., the node that calls the LLM).\n * Useful for implementing human-in-the-loop, guardrails, validation, or other post-processing.\n */\n postModelHook?: RunnableLike<\n ToAnnotationRoot<A>[\"State\"],\n ToAnnotationRoot<A>[\"Update\"],\n LangGraphRunnableConfig\n >;\n\n /**\n * Determines the version of the graph to create.\n *\n * Can be one of\n * - `\"v1\"`: The tool node processes a single message. All tool calls in the message are\n * executed in parallel within the tool node.\n * - `\"v2\"`: The tool node processes a single tool call. Tool calls are distributed across\n * multiple instances of the tool node using the Send API.\n *\n * @default `\"v1\"`\n */\n version?: \"v1\" | \"v2\";\n};\n\n/**\n * @deprecated `createReactAgent` has been moved to {@link https://www.npmjs.com/package/langchain langchain} package.\n * Update your import to `import { createAgent } from \"langchain\";`\n *\n * Creates a StateGraph agent that relies on a chat model utilizing tool calling.\n *\n * @example\n * ```ts\n * import { ChatOpenAI } from \"@langchain/openai\";\n * import { tool } from \"@langchain/core/tools\";\n * import { z } from \"zod\";\n * import { createReactAgent } from \"@langchain/langgraph/prebuilt\";\n *\n * const model = new ChatOpenAI({\n * model: \"gpt-4o\",\n * });\n *\n * const getWeather = tool((input) => {\n * if ([\"sf\", \"san francisco\"].includes(input.location.toLowerCase())) {\n * return \"It's 60 degrees and foggy.\";\n * } else {\n * return \"It's 90 degrees and sunny.\";\n * }\n * }, {\n * name: \"get_weather\",\n * description: \"Call to get the current weather.\",\n * schema: z.object({\n * location: z.string().describe(\"Location to get the weather for.\"),\n * })\n * })\n *\n * const agent = createReactAgent({ llm: model, tools: [getWeather] });\n *\n * const inputs = {\n * messages: [{ role: \"user\", content: \"what is the weather in SF?\" }],\n * };\n *\n * const stream = await agent.stream(inputs, { streamMode: \"values\" });\n *\n * for await (const { messages } of stream) {\n * console.log(messages);\n * }\n * // Returns the messages in the state at each step of execution\n * ```\n */\nexport function createReactAgent<\n A extends AnyAnnotationRoot | InteropZodObject = typeof MessagesAnnotation,\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n StructuredResponseFormat extends Record<string, any> = Record<string, any>,\n C extends AnyAnnotationRoot | InteropZodObject = AnyAnnotationRoot,\n>(\n params: CreateReactAgentParams<A, StructuredResponseFormat, C>\n): CompiledStateGraph<\n ToAnnotationRoot<A>[\"State\"],\n ToAnnotationRoot<A>[\"Update\"],\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n any,\n typeof MessagesAnnotation.spec & ToAnnotationRoot<A>[\"spec\"],\n ReturnType<\n typeof createReactAgentAnnotation<StructuredResponseFormat>\n >[\"spec\"] &\n ToAnnotationRoot<A>[\"spec\"]\n> {\n const {\n llm,\n tools,\n messageModifier,\n stateModifier,\n prompt,\n stateSchema,\n contextSchema,\n checkpointSaver,\n checkpointer,\n interruptBefore,\n interruptAfter,\n store,\n responseFormat,\n preModelHook,\n postModelHook,\n name,\n description,\n version = \"v1\",\n includeAgentName,\n } = params;\n\n let toolClasses: (ClientTool | ServerTool)[];\n\n let toolNode: ToolNode;\n if (!Array.isArray(tools)) {\n toolClasses = tools.tools;\n toolNode = tools;\n } else {\n toolClasses = tools;\n toolNode = new ToolNode(toolClasses.filter(isClientTool));\n }\n\n let cachedStaticModel: Runnable | null = null;\n\n const _getStaticModel = async (llm: LanguageModelLike): Promise<Runnable> => {\n if (cachedStaticModel) return cachedStaticModel;\n\n let modelWithTools: LanguageModelLike;\n if (await _shouldBindTools(llm, toolClasses)) {\n modelWithTools = await _bindTools(llm, toolClasses);\n } else {\n modelWithTools = llm;\n }\n\n const promptRunnable = _getPrompt(prompt, stateModifier, messageModifier);\n const modelRunnable =\n includeAgentName === \"inline\"\n ? withAgentName(modelWithTools, includeAgentName)\n : modelWithTools;\n\n cachedStaticModel = promptRunnable.pipe(modelRunnable);\n return cachedStaticModel;\n };\n\n const _getDynamicModel = async (\n llm: (\n state: AgentState<StructuredResponseFormat> & PreHookAnnotation[\"State\"],\n runtime: Runtime<ToAnnotationRoot<C>[\"State\"]>\n ) => Promise<LanguageModelLike> | LanguageModelLike,\n state: AgentState<StructuredResponseFormat> & PreHookAnnotation[\"State\"],\n config: Runtime<ToAnnotationRoot<C>[\"State\"]>\n ) => {\n const model = await llm(state, config);\n\n return _getPrompt(prompt, stateModifier, messageModifier).pipe(\n includeAgentName === \"inline\"\n ? withAgentName(model, includeAgentName)\n : model\n );\n };\n\n // If any of the tools are configured to return_directly after running,\n // our graph needs to check if these were called\n const shouldReturnDirect = new Set(\n toolClasses\n .filter(isClientTool)\n .filter((tool) => \"returnDirect\" in tool && tool.returnDirect)\n .map((tool) => tool.name)\n );\n\n function getModelInputState(\n state: AgentState<StructuredResponseFormat> & PreHookAnnotation[\"State\"]\n ): Omit<AgentState<StructuredResponseFormat>, \"llmInputMessages\"> {\n const { messages, llmInputMessages, ...rest } = state;\n if (llmInputMessages != null && llmInputMessages.length > 0) {\n return { messages: llmInputMessages, ...rest };\n }\n return { messages, ...rest };\n }\n\n const generateStructuredResponse = async (\n state: AgentState<StructuredResponseFormat> & PreHookAnnotation[\"State\"],\n config: Runtime<ToAnnotationRoot<C>[\"State\"]>\n ) => {\n if (responseFormat == null) {\n throw new Error(\n \"Attempted to generate structured output with no passed response schema. Please contact us for help.\"\n );\n }\n const messages = [...state.messages];\n let modelWithStructuredOutput;\n\n const model: LanguageModelLike =\n typeof llm === \"function\"\n ? await llm(state, config)\n : await _getModel(llm);\n\n if (!_isBaseChatModel(model)) {\n throw new Error(\n `Expected \\`llm\\` to be a ChatModel with .withStructuredOutput() method, got ${model.constructor.name}`\n );\n }\n\n if (typeof responseFormat === \"object\" && \"schema\" in responseFormat) {\n const { prompt, schema, ...options } =\n responseFormat as StructuredResponseSchemaOptions<StructuredResponseFormat>;\n\n modelWithStructuredOutput = model.withStructuredOutput(schema, options);\n if (prompt != null) {\n messages.unshift(new SystemMessage({ content: prompt }));\n }\n } else {\n modelWithStructuredOutput = model.withStructuredOutput(responseFormat);\n }\n\n const response = await modelWithStructuredOutput.invoke(messages, config);\n return { structuredResponse: response };\n };\n\n const callModel = async (\n state: AgentState<StructuredResponseFormat> & PreHookAnnotation[\"State\"],\n config: Runtime<ToAnnotationRoot<C>[\"State\"]>\n ) => {\n // NOTE: we're dynamically creating the model runnable here\n // to ensure that we can validate ConfigurableModel properly\n const modelRunnable: Runnable =\n typeof llm === \"function\"\n ? await _getDynamicModel(llm, state, config)\n : await _getStaticModel(llm);\n\n // TODO: Auto-promote streaming.\n const response = (await modelRunnable.invoke(\n getModelInputState(state),\n config\n )) as BaseMessage;\n // add agent name to the AIMessage\n // TODO: figure out if we can avoid mutating the message directly\n response.name = name;\n response.lc_kwargs.name = name;\n return { messages: [response] };\n };\n\n const schema =\n stateSchema ?? createReactAgentAnnotation<StructuredResponseFormat>();\n\n const workflow = new StateGraph(\n schema as AnyAnnotationRoot,\n contextSchema\n ).addNode(\"tools\", toolNode);\n\n if (!(\"messages\" in workflow._schemaDefinition)) {\n throw new Error(\"Missing required `messages` key in state schema.\");\n }\n\n const allNodeWorkflows = workflow as WithStateGraphNodes<\n | \"pre_model_hook\"\n | \"post_model_hook\"\n | \"generate_structured_response\"\n | \"agent\",\n typeof workflow\n >;\n\n const conditionalMap = <T extends string>(map: Record<string, T | null>) => {\n return Object.fromEntries(\n Object.entries(map).filter(([_, v]) => v != null) as [string, T][]\n );\n };\n\n let entrypoint: \"agent\" | \"pre_model_hook\" = \"agent\";\n let inputSchema: AnnotationRoot<ToAnnotationRoot<A>[\"spec\"]> | undefined;\n if (preModelHook != null) {\n allNodeWorkflows\n .addNode(\"pre_model_hook\", preModelHook)\n .addEdge(\"pre_model_hook\", \"agent\");\n entrypoint = \"pre_model_hook\";\n\n inputSchema = Annotation.Root({\n ...workflow._schemaDefinition,\n ...PreHookAnnotation.spec,\n });\n } else {\n entrypoint = \"agent\";\n }\n\n allNodeWorkflows\n .addNode(\"agent\", callModel, { input: inputSchema })\n .addEdge(START, entrypoint);\n\n if (postModelHook != null) {\n allNodeWorkflows\n .addNode(\"post_model_hook\", postModelHook)\n .addEdge(\"agent\", \"post_model_hook\")\n .addConditionalEdges(\n \"post_model_hook\",\n (state) => {\n const { messages } = state as AgentState<StructuredResponseFormat>;\n\n const toolMessageIds: Set<string> = new Set(\n messages.filter(isToolMessage).map((msg) => msg.tool_call_id)\n );\n\n let lastAiMessage: AIMessage | undefined;\n for (let i = messages.length - 1; i >= 0; i -= 1) {\n const message = messages[i];\n if (isAIMessage(message)) {\n lastAiMessage = message;\n break;\n }\n }\n\n const pendingToolCalls =\n lastAiMessage?.tool_calls?.filter(\n (i) => i.id == null || !toolMessageIds.has(i.id)\n ) ?? [];\n\n const lastMessage = messages[messages.length - 1];\n if (pendingToolCalls.length > 0) {\n if (version === \"v2\") {\n return pendingToolCalls.map(\n (toolCall) =>\n new Send(\"tools\", { ...state, lg_tool_call: toolCall })\n );\n }\n return \"tools\";\n }\n\n if (lastMessage && isToolMessage(lastMessage)) return entrypoint;\n if (responseFormat != null) return \"generate_structured_response\";\n return END;\n },\n conditionalMap({\n tools: \"tools\",\n [entrypoint]: entrypoint,\n generate_structured_response:\n responseFormat != null ? \"generate_structured_response\" : null,\n [END]: responseFormat != null ? null : END,\n })\n );\n }\n\n if (responseFormat !== undefined) {\n workflow\n .addNode(\"generate_structured_response\", generateStructuredResponse)\n .addEdge(\"generate_structured_response\", END);\n }\n\n if (postModelHook == null) {\n allNodeWorkflows.addConditionalEdges(\n \"agent\",\n (state) => {\n const { messages } = state;\n const lastMessage = messages[messages.length - 1];\n\n // if there's no function call, we finish\n if (!isAIMessage(lastMessage) || !lastMessage.tool_calls?.length) {\n if (responseFormat != null) return \"generate_structured_response\";\n return END;\n }\n\n // there are function calls, we continue\n if (version === \"v2\") {\n return lastMessage.tool_calls.map(\n (toolCall) =>\n new Send(\"tools\", { ...state, lg_tool_call: toolCall })\n );\n }\n\n return \"tools\";\n },\n conditionalMap({\n tools: \"tools\",\n generate_structured_response:\n responseFormat != null ? \"generate_structured_response\" : null,\n [END]: responseFormat != null ? null : END,\n })\n );\n }\n\n if (shouldReturnDirect.size > 0) {\n allNodeWorkflows.addConditionalEdges(\n \"tools\",\n (state) => {\n const agentState = state;\n // Check the last consecutive tool calls\n for (let i = agentState.messages.length - 1; i >= 0; i -= 1) {\n const message = agentState.messages[i];\n if (!isToolMessage(message)) break;\n\n // Check if this tool is configured to return directly\n if (\n message.name !== undefined &&\n shouldReturnDirect.has(message.name)\n ) {\n return END;\n }\n }\n\n return entrypoint;\n },\n conditionalMap({ [entrypoint]: entrypoint, [END]: END })\n );\n } else {\n allNodeWorkflows.addEdge(\"tools\", entrypoint);\n }\n\n return allNodeWorkflows.compile({\n checkpointer: checkpointer ?? checkpointSaver,\n interruptBefore,\n interruptAfter,\n store,\n name,\n description,\n });\n}\n"],"mappings":";;;;;;;;;;AA2EA,SAAS,gCACP,iBACQ;AAER,KACE,OAAO,oBAAoB,aAAA,GAAA,yBAAA,eACZ,gBAAgB,IAAI,gBAAg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A;EACA;EACA;EACA;EACD,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react_agent_executor.d.cts","names":[],"sources":["../../src/prebuilt/react_agent_executor.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;UAmDiB,UAAA,gCAEgB,MAAA,gBAAsB,MAAA;EAErD,QAAA,EAAU,WAAA;EAMV,kBAAA,EAAoB,sBAAA;AAAA;AAAA,KAGV,CAAA,UAAW,KAAA;AAAA,KAElB,+BAAA;EAEH,MAAA,EAAQ,cAAA,CAAe,sBAAA,IAA0B,MAAA;EACjD,MAAA;EAEA,MAAA;EAAA,CACC,GAAA;AAAA;AAAA,KAiEE,UAAA,GAAa,MAAA;AAAA,KACb,UAAA,GAAa,uBAAA,GAA0B,WAAA,GAAc,gBAAA;AAAA,KAkR9C,MAAA,GACR,aAAA,cAGE,KAAA,SAAc,kBAAA,CAAmB,KAAA,EACjC,MAAA,EAAQ,uBAAA,KACL,eAAA,QAEH,KAAA,SAAc,kBAAA,CAAmB,KAAA,EACjC,MAAA,EAAQ,uBAAA,KACL,OAAA,CAAQ,eAAA,OACb,QAAA;;KAGQ,aAAA,GAAgB,MAAA;;KAGhB,eAAA,GACR,aAAA,cAEE,QAAA,EAAU,WAAA,OAAkB,WAAA,QAC5B,QAAA,EAAU,WAAA,OAAkB,OAAA,CAAQ,WAAA,OACtC,QAAA;AAAA,cAES,0BAAA,aAEV,MAAA,gBAAA,MAAA,oBAAA,cAAA;+EAAA,yBAAA,CAAA,cAAA;;;;;;;
|
|
1
|
+
{"version":3,"file":"react_agent_executor.d.cts","names":[],"sources":["../../src/prebuilt/react_agent_executor.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;UAmDiB,UAAA,gCAEgB,MAAA,gBAAsB,MAAA;EAErD,QAAA,EAAU,WAAA;EAMV,kBAAA,EAAoB,sBAAA;AAAA;AAAA,KAGV,CAAA,UAAW,KAAA;AAAA,KAElB,+BAAA;EAEH,MAAA,EAAQ,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AO,gBAAA,CAAiB,CAAA,WAClD,UAAA,QACS,0BAAA,CAA2B,wBAAA,aAElC,gBAAA,CAAiB,CAAA"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"react_agent_executor.d.ts","names":[],"sources":["../../src/prebuilt/react_agent_executor.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;UAmDiB,UAAA,gCAEgB,MAAA,gBAAsB,MAAA;EAErD,QAAA,EAAU,WAAA;EAMV,kBAAA,EAAoB,sBAAA;AAAA;AAAA,KAGV,CAAA,UAAW,KAAA;AAAA,KAElB,+BAAA;EAEH,MAAA,EAAQ,cAAA,CAAe,sBAAA,IAA0B,MAAA;EACjD,MAAA;EAEA,MAAA;EAAA,CACC,GAAA;AAAA;AAAA,KAiEE,UAAA,GAAa,MAAA;AAAA,KACb,UAAA,GAAa,uBAAA,GAA0B,WAAA,GAAc,gBAAA;AAAA,KAkR9C,MAAA,GACR,aAAA,cAGE,KAAA,SAAc,kBAAA,CAAmB,KAAA,EACjC,MAAA,EAAQ,uBAAA,KACL,eAAA,QAEH,KAAA,SAAc,kBAAA,CAAmB,KAAA,EACjC,MAAA,EAAQ,uBAAA,KACL,OAAA,CAAQ,eAAA,OACb,QAAA;AAvWJ;AAAA,KA0WY,aAAA,GAAgB,MAAA;;KAGhB,eAAA,GACR,aAAA,cAEE,QAAA,EAAU,WAAA,OAAkB,WAAA,QAC5B,QAAA,EAAU,WAAA,OAAkB,OAAA,CAAQ,WAAA,OACtC,QAAA;AAAA,cAES,0BAAA,aAEV,MAAA,gBAAA,MAAA,oBAAA,cAAA;+EAAA,yBAAA,CAAA,cAAA;;;;;;;
|
|
1
|
+
{"version":3,"file":"react_agent_executor.d.ts","names":[],"sources":["../../src/prebuilt/react_agent_executor.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;UAmDiB,UAAA,gCAEgB,MAAA,gBAAsB,MAAA;EAErD,QAAA,EAAU,WAAA;EAMV,kBAAA,EAAoB,sBAAA;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