@langchain/langgraph 1.1.5 → 1.2.1
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/binop.cjs +13 -2
- package/dist/channels/binop.cjs.map +1 -1
- package/dist/channels/binop.d.cts +4 -2
- package/dist/channels/binop.d.cts.map +1 -1
- package/dist/channels/binop.d.ts +4 -2
- package/dist/channels/binop.d.ts.map +1 -1
- package/dist/channels/binop.js +14 -3
- package/dist/channels/binop.js.map +1 -1
- package/dist/constants.cjs +84 -1
- package/dist/constants.cjs.map +1 -1
- package/dist/constants.d.cts +54 -2
- package/dist/constants.d.cts.map +1 -1
- package/dist/constants.d.ts +54 -2
- package/dist/constants.d.ts.map +1 -1
- package/dist/constants.js +81 -2
- package/dist/constants.js.map +1 -1
- package/dist/func/index.cjs +1 -1
- package/dist/func/index.d.cts +1 -1
- package/dist/func/index.d.ts +1 -1
- package/dist/func/index.js +1 -1
- package/dist/graph/annotation.cjs.map +1 -1
- package/dist/graph/annotation.d.cts +3 -2
- package/dist/graph/annotation.d.cts.map +1 -1
- package/dist/graph/annotation.d.ts +3 -2
- package/dist/graph/annotation.d.ts.map +1 -1
- package/dist/graph/annotation.js.map +1 -1
- package/dist/graph/graph.cjs +3 -6
- package/dist/graph/graph.cjs.map +1 -1
- package/dist/graph/graph.d.cts +2 -2
- package/dist/graph/graph.d.cts.map +1 -1
- package/dist/graph/graph.d.ts +2 -2
- package/dist/graph/graph.d.ts.map +1 -1
- package/dist/graph/graph.js +3 -6
- package/dist/graph/graph.js.map +1 -1
- package/dist/graph/index.cjs +1 -1
- package/dist/graph/index.d.ts +1 -1
- package/dist/graph/index.js +1 -1
- package/dist/graph/messages_annotation.d.cts +3 -2
- package/dist/graph/messages_annotation.d.cts.map +1 -1
- package/dist/graph/messages_annotation.d.ts +3 -2
- package/dist/graph/messages_annotation.d.ts.map +1 -1
- package/dist/graph/state.cjs +1 -1
- package/dist/graph/state.d.cts +1 -1
- package/dist/graph/state.d.ts +1 -1
- package/dist/graph/state.js +1 -1
- package/dist/graph/types.cjs +1 -1
- package/dist/graph/types.d.cts +1 -1
- package/dist/graph/types.d.ts +1 -1
- package/dist/graph/types.js +1 -1
- package/dist/graph/zod/meta.cjs.map +1 -1
- package/dist/graph/zod/meta.d.cts +3 -2
- package/dist/graph/zod/meta.d.cts.map +1 -1
- package/dist/graph/zod/meta.d.ts +3 -2
- package/dist/graph/zod/meta.d.ts.map +1 -1
- package/dist/graph/zod/meta.js.map +1 -1
- package/dist/index.cjs +4 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +2 -2
- package/dist/interrupt.cjs +1 -1
- package/dist/interrupt.js +1 -1
- package/dist/prebuilt/react_agent_executor.cjs +1 -1
- package/dist/prebuilt/react_agent_executor.d.cts +5 -5
- package/dist/prebuilt/react_agent_executor.d.cts.map +1 -1
- package/dist/prebuilt/react_agent_executor.d.ts +5 -5
- package/dist/prebuilt/react_agent_executor.d.ts.map +1 -1
- package/dist/prebuilt/react_agent_executor.js +1 -1
- package/dist/prebuilt/tool_node.cjs +1 -1
- package/dist/prebuilt/tool_node.d.cts +1 -1
- package/dist/prebuilt/tool_node.d.ts +1 -1
- package/dist/prebuilt/tool_node.js +1 -1
- package/dist/pregel/algo.cjs +1 -1
- package/dist/pregel/algo.d.ts +1 -1
- package/dist/pregel/algo.js +1 -1
- package/dist/pregel/index.cjs +13 -1
- package/dist/pregel/index.cjs.map +1 -1
- package/dist/pregel/index.d.cts +2 -1
- package/dist/pregel/index.d.cts.map +1 -1
- package/dist/pregel/index.d.ts +2 -1
- package/dist/pregel/index.d.ts.map +1 -1
- package/dist/pregel/index.js +14 -2
- package/dist/pregel/index.js.map +1 -1
- package/dist/pregel/io.cjs +1 -1
- package/dist/pregel/io.js +1 -1
- package/dist/pregel/loop.cjs +1 -1
- package/dist/pregel/loop.js +1 -1
- package/dist/pregel/read.cjs +4 -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 +4 -1
- package/dist/pregel/read.js.map +1 -1
- package/dist/pregel/remote.cjs +1 -1
- package/dist/pregel/remote.js +1 -1
- package/dist/pregel/retry.cjs +1 -1
- package/dist/pregel/retry.js +1 -1
- package/dist/pregel/runner.cjs +1 -1
- package/dist/pregel/runner.js +1 -1
- package/dist/pregel/stream.cjs +81 -0
- package/dist/pregel/stream.cjs.map +1 -1
- package/dist/pregel/stream.d.ts +2 -1
- package/dist/pregel/stream.js +81 -1
- package/dist/pregel/stream.js.map +1 -1
- package/dist/pregel/types.cjs.map +1 -1
- package/dist/pregel/types.d.cts +27 -2
- package/dist/pregel/types.d.cts.map +1 -1
- package/dist/pregel/types.d.ts +27 -2
- package/dist/pregel/types.d.ts.map +1 -1
- package/dist/pregel/types.js.map +1 -1
- package/dist/pregel/write.cjs +2 -1
- package/dist/pregel/write.cjs.map +1 -1
- package/dist/pregel/write.d.cts +1 -1
- package/dist/pregel/write.d.cts.map +1 -1
- package/dist/pregel/write.d.ts +1 -1
- package/dist/pregel/write.d.ts.map +1 -1
- package/dist/pregel/write.js +2 -1
- package/dist/pregel/write.js.map +1 -1
- package/dist/state/schema.cjs.map +1 -1
- package/dist/state/schema.d.cts +3 -2
- package/dist/state/schema.d.cts.map +1 -1
- package/dist/state/schema.d.ts +3 -2
- package/dist/state/schema.d.ts.map +1 -1
- package/dist/state/schema.js.map +1 -1
- package/dist/state/values/reduced.cjs.map +1 -1
- package/dist/state/values/reduced.d.cts +2 -6
- package/dist/state/values/reduced.d.cts.map +1 -1
- package/dist/state/values/reduced.d.ts +2 -6
- package/dist/state/values/reduced.d.ts.map +1 -1
- package/dist/state/values/reduced.js.map +1 -1
- package/dist/state/values/untracked.cjs.map +1 -1
- package/dist/state/values/untracked.d.cts +2 -6
- package/dist/state/values/untracked.d.cts.map +1 -1
- package/dist/state/values/untracked.d.ts +2 -6
- package/dist/state/values/untracked.d.ts.map +1 -1
- package/dist/state/values/untracked.js.map +1 -1
- package/dist/web.cjs +4 -1
- package/dist/web.d.cts +2 -2
- package/dist/web.d.ts +2 -2
- package/dist/web.js +2 -2
- package/package.json +4 -4
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseChannel } from "../channels/base.cjs";
|
|
2
|
+
import { OverwriteValue } from "../constants.cjs";
|
|
2
3
|
import { ReducedZodChannel, SchemaMeta } from "./zod/meta.cjs";
|
|
3
4
|
import { AnnotationRoot } from "./annotation.cjs";
|
|
4
5
|
import { Messages } from "./messages_reducer.cjs";
|
|
@@ -44,7 +45,7 @@ import { BaseMessage } from "@langchain/core/messages";
|
|
|
44
45
|
* ```
|
|
45
46
|
*/
|
|
46
47
|
declare const MessagesAnnotation: AnnotationRoot<{
|
|
47
|
-
messages:
|
|
48
|
+
messages: BaseChannel<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], OverwriteValue<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[]> | Messages, unknown>;
|
|
48
49
|
}>;
|
|
49
50
|
/**
|
|
50
51
|
* Prebuilt schema meta for Zod state definition.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages_annotation.d.cts","names":[],"sources":["../../src/graph/messages_annotation.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"messages_annotation.d.cts","names":[],"sources":["../../src/graph/messages_annotation.ts"],"mappings":";;;;;;;;;;;;;;;;;;AA2CA;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,kBAAA;+EAKX,yBAAA,CAAA,cAAA;;;AAeF;;;;;;;;;;;;cAAa,eAAA,EAAiB,UAAA,CAAW,WAAA,IAAe,QAAA;AA6CxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,cAAa,gBAAA,EAAgB,CAAA,CAAA,SAAA;+FAE3B,yBAAA,CAAA,cAAA"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseChannel } from "../channels/base.js";
|
|
2
|
+
import { OverwriteValue } from "../constants.js";
|
|
2
3
|
import { ReducedZodChannel, SchemaMeta } from "./zod/meta.js";
|
|
3
4
|
import { AnnotationRoot } from "./annotation.js";
|
|
4
5
|
import { Messages } from "./messages_reducer.js";
|
|
@@ -45,7 +46,7 @@ import { z } from "zod/v3";
|
|
|
45
46
|
* ```
|
|
46
47
|
*/
|
|
47
48
|
declare const MessagesAnnotation: AnnotationRoot<{
|
|
48
|
-
messages:
|
|
49
|
+
messages: BaseChannel<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], OverwriteValue<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[]> | Messages, unknown>;
|
|
49
50
|
}>;
|
|
50
51
|
/**
|
|
51
52
|
* Prebuilt schema meta for Zod state definition.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"messages_annotation.d.ts","names":[],"sources":["../../src/graph/messages_annotation.ts"],"mappings":"
|
|
1
|
+
{"version":3,"file":"messages_annotation.d.ts","names":[],"sources":["../../src/graph/messages_annotation.ts"],"mappings":";;;;;;;;;;;;;;;;;;;;AA2CA;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,kBAAA;+EAKX,yBAAA,CAAA,cAAA;;;;AAeF;;;;;;;;;;;cAAa,eAAA,EAAiB,UAAA,CAAW,WAAA,IAAe,QAAA;;AA6CxD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;cAAa,gBAAA,EAAgB,CAAA,CAAA,SAAA;+FAE3B,yBAAA,CAAA,cAAA"}
|
package/dist/graph/state.cjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
const require_constants = require('../constants.cjs');
|
|
1
2
|
const require_errors = require('../errors.cjs');
|
|
2
3
|
const require_last_value = require('../channels/last_value.cjs');
|
|
3
4
|
const require_annotation = require('./annotation.cjs');
|
|
4
|
-
const require_constants = require('../constants.cjs');
|
|
5
5
|
const require_utils = require('../utils.cjs');
|
|
6
6
|
const require_write = require('../pregel/write.cjs');
|
|
7
7
|
const require_read = require('../pregel/read.cjs');
|
package/dist/graph/state.d.cts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseChannel } from "../channels/base.cjs";
|
|
2
|
+
import { Command, CommandInstance, END, INTERRUPT, Interrupt, START } from "../constants.cjs";
|
|
2
3
|
import { SchemaMetaRegistry } from "./zod/meta.cjs";
|
|
3
4
|
import { RunnableLike, Runtime } from "../pregel/runnable_types.cjs";
|
|
4
5
|
import { AnnotationRoot, SingleReducer, StateDefinition, StateType } from "./annotation.cjs";
|
|
5
6
|
import { CachePolicy, RetryPolicy } from "../pregel/utils/index.cjs";
|
|
6
|
-
import { Command, CommandInstance, END, INTERRUPT, Interrupt, START } from "../constants.cjs";
|
|
7
7
|
import { AddNodeOptions, Branch, CompiledGraph, Graph, NodeSpec } from "./graph.cjs";
|
|
8
8
|
import { InferInterruptInputType, InferInterruptResumeType } from "../interrupt.cjs";
|
|
9
9
|
import { InferWriterType } from "../writer.cjs";
|
package/dist/graph/state.d.ts
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { BaseChannel } from "../channels/base.js";
|
|
2
|
+
import { Command, CommandInstance, END, INTERRUPT, Interrupt, START } from "../constants.js";
|
|
2
3
|
import { SchemaMetaRegistry } from "./zod/meta.js";
|
|
3
4
|
import { RunnableLike, Runtime } from "../pregel/runnable_types.js";
|
|
4
5
|
import { AnnotationRoot, SingleReducer, StateDefinition, StateType } from "./annotation.js";
|
|
5
6
|
import { CachePolicy, RetryPolicy } from "../pregel/utils/index.js";
|
|
6
|
-
import { Command, CommandInstance, END, INTERRUPT, Interrupt, START } from "../constants.js";
|
|
7
7
|
import { AddNodeOptions, Branch, CompiledGraph, Graph, NodeSpec } from "./graph.js";
|
|
8
8
|
import { InferInterruptInputType, InferInterruptResumeType } from "../interrupt.js";
|
|
9
9
|
import { InferWriterType } from "../writer.js";
|
package/dist/graph/state.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { CHECKPOINT_NAMESPACE_END, CHECKPOINT_NAMESPACE_SEPARATOR, Command, END, SELF, START, TAG_HIDDEN, _isSend, isCommand, isInterrupted } from "../constants.js";
|
|
1
2
|
import { InvalidUpdateError, ParentCommand, StateGraphInputError } from "../errors.js";
|
|
2
3
|
import { LastValueAfterFinish } from "../channels/last_value.js";
|
|
3
4
|
import { AnnotationRoot, getChannel } from "./annotation.js";
|
|
4
|
-
import { CHECKPOINT_NAMESPACE_END, CHECKPOINT_NAMESPACE_SEPARATOR, Command, END, SELF, START, TAG_HIDDEN, _isSend, isCommand, isInterrupted } from "../constants.js";
|
|
5
5
|
import { RunnableCallable } from "../utils.js";
|
|
6
6
|
import { ChannelWrite, PASSTHROUGH } from "../pregel/write.js";
|
|
7
7
|
import { ChannelRead, PregelNode } from "../pregel/read.js";
|
package/dist/graph/types.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_base = require('../channels/base.cjs');
|
|
2
1
|
const require_constants = require('../constants.cjs');
|
|
2
|
+
const require_base = require('../channels/base.cjs');
|
|
3
3
|
const require_schema = require('../state/schema.cjs');
|
|
4
4
|
let _langchain_core_utils_types = require("@langchain/core/utils/types");
|
|
5
5
|
|
package/dist/graph/types.d.cts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { CommandInstance, END, Send } from "../constants.cjs";
|
|
1
2
|
import { InteropZodToStateDefinition } from "./zod/meta.cjs";
|
|
2
3
|
import { LangGraphRunnableConfig } from "../pregel/runnable_types.cjs";
|
|
3
4
|
import { AnnotationRoot, StateDefinition, StateType, UpdateType } from "./annotation.cjs";
|
|
4
|
-
import { CommandInstance, END, Send } from "../constants.cjs";
|
|
5
5
|
import { AnyStateSchema, StateSchema, StateSchemaFieldsToStateDefinition } from "../state/schema.cjs";
|
|
6
6
|
import { InteropZodObject } from "@langchain/core/utils/types";
|
|
7
7
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
package/dist/graph/types.d.ts
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
|
+
import { CommandInstance, END, Send } from "../constants.js";
|
|
1
2
|
import { InteropZodToStateDefinition } from "./zod/meta.js";
|
|
2
3
|
import { LangGraphRunnableConfig } from "../pregel/runnable_types.js";
|
|
3
4
|
import { AnnotationRoot, StateDefinition, StateType, UpdateType } from "./annotation.js";
|
|
4
|
-
import { CommandInstance, END, Send } from "../constants.js";
|
|
5
5
|
import { AnyStateSchema, StateSchema, StateSchemaFieldsToStateDefinition } from "../state/schema.js";
|
|
6
6
|
import { InteropZodObject } from "@langchain/core/utils/types";
|
|
7
7
|
import { StandardSchemaV1 } from "@standard-schema/spec";
|
package/dist/graph/types.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { isBaseChannel } from "../channels/base.js";
|
|
2
1
|
import { END } from "../constants.js";
|
|
2
|
+
import { isBaseChannel } from "../channels/base.js";
|
|
3
3
|
import { StateSchema } from "../state/schema.js";
|
|
4
4
|
import { isInteropZodObject } from "@langchain/core/utils/types";
|
|
5
5
|
|
|
@@ -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\";\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, 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<unknown>\n ? ReducerSchema extends InteropZodType<infer U>\n ? 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":";;;;;AAgBA,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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ACN;KACA,MAAM,oEACiB,aAAa,0DAAyB,OAAO;KACpE,MAAM,YAAY,KAAK,UAAU;MAC/B,GAAG,KAAK;MACR;MACD,CAAC;AACF,oBAAe,aAAa,SAC1B,GAAG,iCAAiC,YACrC;;AAEH,WAAO,CAAC,KAAK,aAAa;KAC1B;AACF,4EACE,QACA,OAAO,YAAY,gBAAgB,CACpC;AACD,sDAAkB,eAAe,CAC/B,gBAAe,KAAK,cAAc;;AAGtC,MAAI,QAAQ,UACV,2EAAyC,eAAe;AAG1D,QAAM,IAAI,QAAQ,eAAe;AACjC,OAAK,gBAAgB,IAAI,UAAU,MAAM;AACzC,SAAO;;;AAIX,MAAa,qBAAqB,IAAI,oBAAoB;AAkB1D,SAAgB,cAKd,QACA,MAC+D;AAC/D,KAAI,KAAK,WAAW,CAAC,KAAK,SAAS;EACjC,MAAM,iFAAgD,OAAO;AAC7D,MAAI,sBAAsB,KAExB,MAAK,UAAU;;AAGnB,KAAI,KAAK,SAAS;EAChB,MAAM,oBAAoB,OAAO,OAAO,QAAQ,EAC9C,mBAAmB,KAAK,SAAS,UAAU,QAC5C,CAAC;AACF,qBAAmB,OAAO,yBAAyB,KAAK;AACxD,SAAO;QACF;AACL,qBAAmB,OAAO,cAAc,KAAK;AAC7C,SAAO"}
|
|
1
|
+
{"version":3,"file":"meta.cjs","names":["BinaryOperatorAggregate","LastValue"],"sources":["../../../src/graph/zod/meta.ts"],"sourcesContent":["import {\n InferInteropZodOutput,\n InteropZodObject,\n InteropZodType,\n getInteropZodObjectShape,\n extendInteropZodObject,\n getInteropZodDefaultGetter,\n interopZodObjectPartial,\n InteropZodObjectShape,\n isZodSchemaV3,\n getSchemaDescription,\n} from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nimport { BinaryOperatorAggregate } from \"../../channels/binop.js\";\nimport { LastValue } from \"../../channels/last_value.js\";\nimport type { OverwriteValue } from \"../../constants.js\";\n\nexport const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n\n/** @internal */\nexport type ReducedZodChannel<\n T extends InteropZodType,\n TReducerSchema extends InteropZodType\n> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n\n/** @internal */\nexport type InteropZodToStateDefinition<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? BaseChannel<V, OverwriteValue<V> | U>\n : never\n : never\n : TShape[key] extends InteropZodType<infer V, infer U>\n ? BaseChannel<V, U>\n : never;\n};\n\nexport type UpdateType<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? OverwriteValue<V> | U\n : never\n : never\n : TShape[key] extends InteropZodType<unknown, infer U>\n ? U\n : never;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SchemaMeta<TValue = any, TUpdate = TValue> {\n jsonSchemaExtra?: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\" | \"messages\";\n [key: string]: unknown;\n };\n reducer?: {\n schema?: InteropZodType<TUpdate>;\n fn: (a: TValue, b: TUpdate) => TValue;\n };\n default?: () => TValue;\n}\n\n/**\n * A registry for storing and managing metadata associated with schemas.\n * This class provides methods to get, extend, remove, and check metadata for a given schema.\n */\nexport class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map = new Map<InteropZodType, SchemaMeta>();\n\n /**\n * Cache for extended schemas.\n * @internal\n */\n _extensionCache = new Map<string, Map<InteropZodType, InteropZodType>>();\n\n /**\n * Retrieves the metadata associated with a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to retrieve metadata for.\n * @returns The associated SchemaMeta, or undefined if not present.\n */\n get<TValue, TUpdate = TValue>(\n schema: InteropZodType<TValue>\n ): SchemaMeta<TValue, TUpdate> | undefined {\n return this._map.get(schema);\n }\n\n /**\n * Extends or sets the metadata for a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to extend metadata for.\n * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.\n */\n extend<TValue, TUpdate>(\n schema: InteropZodType<TValue>,\n predicate: (\n meta: SchemaMeta<TValue, TUpdate> | undefined\n ) => SchemaMeta<TValue, TUpdate>\n ) {\n const existingMeta = this.get<TValue, TUpdate>(schema);\n this._map.set(schema, predicate(existingMeta));\n }\n\n /**\n * Removes the metadata associated with a given schema.\n * @param schema The schema to remove metadata for.\n * @returns The SchemaMetaRegistry instance (for chaining).\n */\n remove(schema: InteropZodType): this {\n this._map.delete(schema);\n return this;\n }\n\n /**\n * Checks if metadata exists for a given schema.\n * @param schema The schema to check.\n * @returns True if metadata exists, false otherwise.\n */\n has(schema: InteropZodType): boolean {\n return this._map.has(schema);\n }\n\n /**\n * Returns a mapping of channel instances for each property in the schema\n * using the associated metadata in the registry.\n *\n * This is used to create the `channels` object that's passed to the `Graph` constructor.\n *\n * @template T The shape of the schema.\n * @param schema The schema to extract channels from.\n * @returns A mapping from property names to channel instances.\n */\n getChannelsForSchema<T extends InteropZodObject>(\n schema: T\n ): InteropZodToStateDefinition<T> {\n const channels = {} as Record<string, BaseChannel>;\n const shape = getInteropZodObjectShape(schema);\n for (const [key, channelSchema] of Object.entries(shape)) {\n const meta = this.get(channelSchema);\n if (meta?.reducer) {\n channels[key] = new BinaryOperatorAggregate<\n InferInteropZodOutput<typeof channelSchema>\n >(meta.reducer.fn, meta.default);\n } else {\n channels[key] = new LastValue(meta?.default);\n }\n }\n return channels as InteropZodToStateDefinition<T>;\n }\n\n /**\n * Returns a modified schema that introspectively looks at all keys of the provided\n * object schema, and applies the augmentations based on meta provided with those keys\n * in the registry and the selectors provided in the `effects` parameter.\n *\n * This assumes that the passed in schema is the \"root\" schema object for a graph where\n * the keys of the schema are the channels of the graph. Because we need to represent\n * the input of a graph in a couple of different ways, the `effects` parameter allows\n * us to apply those augmentations based on pre determined conditions.\n *\n * @param schema The root schema object to extend.\n * @param effects The effects that are being applied.\n * @returns The extended schema.\n */\n getExtendedChannelSchemas<T extends InteropZodObject>(\n schema: T,\n effects: {\n /**\n * Augments the shape by using the reducer's schema if it exists\n */\n withReducerSchema?: boolean;\n /**\n * Applies the stringified jsonSchemaExtra as a description to the schema.\n */\n withJsonSchemaExtrasAsDescription?: boolean;\n /**\n * Applies the `.partial()` modifier to the schema.\n */\n asPartial?: boolean;\n }\n ): InteropZodObject {\n // If no effects are being applied, return the schema unchanged\n if (Object.keys(effects).length === 0) {\n return schema;\n }\n\n // Cache key is determined by looking at the effects that are being applied\n const cacheKey = Object.entries(effects)\n .filter(([, v]) => v === true)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}:${v}`)\n .join(\"|\");\n\n const cache = this._extensionCache.get(cacheKey) ?? new Map();\n if (cache.has(schema)) return cache.get(schema)! as T;\n\n let modifiedSchema: InteropZodObject = schema;\n\n if (\n effects.withReducerSchema ||\n effects.withJsonSchemaExtrasAsDescription\n ) {\n const newShapeEntries = Object.entries(\n getInteropZodObjectShape(schema)\n ).map(([key, schema]) => {\n const meta = this.get(schema);\n let outputSchema = effects.withReducerSchema\n ? meta?.reducer?.schema ?? schema\n : schema;\n if (\n effects.withJsonSchemaExtrasAsDescription &&\n meta?.jsonSchemaExtra\n ) {\n const description =\n getSchemaDescription(outputSchema) ?? getSchemaDescription(schema);\n const strExtras = JSON.stringify({\n ...meta.jsonSchemaExtra,\n description,\n });\n outputSchema = outputSchema.describe(\n `${META_EXTRAS_DESCRIPTION_PREFIX}${strExtras}`\n );\n }\n return [key, outputSchema];\n });\n modifiedSchema = extendInteropZodObject(\n schema,\n Object.fromEntries(newShapeEntries)\n );\n if (isZodSchemaV3(modifiedSchema)) {\n modifiedSchema._def.unknownKeys = \"strip\";\n }\n }\n if (effects.asPartial) {\n modifiedSchema = interopZodObjectPartial(modifiedSchema);\n }\n\n cache.set(schema, modifiedSchema);\n this._extensionCache.set(cacheKey, cache);\n return modifiedSchema;\n }\n}\n\nexport const schemaMetaRegistry = new SchemaMetaRegistry();\n\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate> & { reducer?: undefined }\n): TSchema;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>> | TSchema {\n if (meta.reducer && !meta.default) {\n const defaultValueGetter = getInteropZodDefaultGetter(schema);\n if (defaultValueGetter != null) {\n // eslint-disable-next-line no-param-reassign\n meta.default = defaultValueGetter;\n }\n }\n if (meta.reducer) {\n const schemaWithReducer = Object.assign(schema, {\n lg_reducer_schema: meta.reducer?.schema ?? schema,\n });\n schemaMetaRegistry.extend(schemaWithReducer, () => meta);\n return schemaWithReducer;\n } else {\n schemaMetaRegistry.extend(schema, () => meta);\n return schema;\n }\n}\n"],"mappings":";;;;;AAiBA,MAAa,iCAAiC;;;;;AAiE9C,IAAa,qBAAb,MAAgC;;;;;CAK9B,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,KA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;KACpE,MAAM,YAAY,KAAK,UAAU;MAC/B,GAAG,KAAK;MACR;MACD,CAAC;AACF,oBAAe,aAAa,SAC1B,GAAG,iCAAiC,YACrC;;AAEH,WAAO,CAAC,KAAK,aAAa;KAC1B;AACF,4EACE,QACA,OAAO,YAAY,gBAAgB,CACpC;AACD,sDAAkB,eAAe,CAC/B,gBAAe,KAAK,cAAc;;AAGtC,MAAI,QAAQ,UACV,2EAAyC,eAAe;AAG1D,QAAM,IAAI,QAAQ,eAAe;AACjC,OAAK,gBAAgB,IAAI,UAAU,MAAM;AACzC,SAAO;;;AAIX,MAAa,qBAAqB,IAAI,oBAAoB;AAkB1D,SAAgB,cAKd,QACA,MAC+D;AAC/D,KAAI,KAAK,WAAW,CAAC,KAAK,SAAS;EACjC,MAAM,iFAAgD,OAAO;AAC7D,MAAI,sBAAsB,KAExB,MAAK,UAAU;;AAGnB,KAAI,KAAK,SAAS;EAChB,MAAM,oBAAoB,OAAO,OAAO,QAAQ,EAC9C,mBAAmB,KAAK,SAAS,UAAU,QAC5C,CAAC;AACF,qBAAmB,OAAO,yBAAyB,KAAK;AACxD,SAAO;QACF;AACL,qBAAmB,OAAO,cAAc,KAAK;AAC7C,SAAO"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseChannel } from "../../channels/base.cjs";
|
|
2
|
+
import { OverwriteValue } from "../../constants.cjs";
|
|
2
3
|
import { InteropZodObject, InteropZodObjectShape, InteropZodType } from "@langchain/core/utils/types";
|
|
3
4
|
|
|
4
5
|
//#region src/graph/zod/meta.d.ts
|
|
@@ -8,8 +9,8 @@ type ReducedZodChannel<T extends InteropZodType, TReducerSchema extends InteropZ
|
|
|
8
9
|
lg_reducer_schema: TReducerSchema;
|
|
9
10
|
};
|
|
10
11
|
/** @internal */
|
|
11
|
-
type InteropZodToStateDefinition<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<infer V> ? ReducerSchema extends InteropZodType<infer U> ? BaseChannel<V, U> : never : never : TShape[key] extends InteropZodType<infer V, infer U> ? BaseChannel<V, U> : never };
|
|
12
|
-
type UpdateType<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<
|
|
12
|
+
type InteropZodToStateDefinition<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<infer V> ? ReducerSchema extends InteropZodType<infer U> ? BaseChannel<V, OverwriteValue<V> | U> : never : never : TShape[key] extends InteropZodType<infer V, infer U> ? BaseChannel<V, U> : never };
|
|
13
|
+
type UpdateType<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<infer V> ? ReducerSchema extends InteropZodType<infer U> ? OverwriteValue<V> | U : never : never : TShape[key] extends InteropZodType<unknown, infer U> ? U : never };
|
|
13
14
|
interface SchemaMeta<TValue = any, TUpdate = TValue> {
|
|
14
15
|
jsonSchemaExtra?: {
|
|
15
16
|
langgraph_nodes?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.cts","names":[],"sources":["../../../src/graph/zod/meta.ts"],"mappings":"
|
|
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,S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BAAA,WAA+B,gBAAA,CAAA,CAC7B,MAAA,EAAQ,CAAA,GACP,2BAAA,CAA4B,CAAA;EAlH3B;;;;;AAIN;;;;;;;;;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"}
|
package/dist/graph/zod/meta.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseChannel } from "../../channels/base.js";
|
|
2
|
+
import { OverwriteValue } from "../../constants.js";
|
|
2
3
|
import { InteropZodObject, InteropZodObjectShape, InteropZodType } from "@langchain/core/utils/types";
|
|
3
4
|
|
|
4
5
|
//#region src/graph/zod/meta.d.ts
|
|
@@ -8,8 +9,8 @@ type ReducedZodChannel<T extends InteropZodType, TReducerSchema extends InteropZ
|
|
|
8
9
|
lg_reducer_schema: TReducerSchema;
|
|
9
10
|
};
|
|
10
11
|
/** @internal */
|
|
11
|
-
type InteropZodToStateDefinition<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<infer V> ? ReducerSchema extends InteropZodType<infer U> ? BaseChannel<V, U> : never : never : TShape[key] extends InteropZodType<infer V, infer U> ? BaseChannel<V, U> : never };
|
|
12
|
-
type UpdateType<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<
|
|
12
|
+
type InteropZodToStateDefinition<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<infer V> ? ReducerSchema extends InteropZodType<infer U> ? BaseChannel<V, OverwriteValue<V> | U> : never : never : TShape[key] extends InteropZodType<infer V, infer U> ? BaseChannel<V, U> : never };
|
|
13
|
+
type UpdateType<T extends InteropZodObject, TShape = InteropZodObjectShape<T>> = { [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<infer Schema, infer ReducerSchema> ? Schema extends InteropZodType<infer V> ? ReducerSchema extends InteropZodType<infer U> ? OverwriteValue<V> | U : never : never : TShape[key] extends InteropZodType<unknown, infer U> ? U : never };
|
|
13
14
|
interface SchemaMeta<TValue = any, TUpdate = TValue> {
|
|
14
15
|
jsonSchemaExtra?: {
|
|
15
16
|
langgraph_nodes?: string[];
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"meta.d.ts","names":[],"sources":["../../../src/graph/zod/meta.ts"],"mappings":"
|
|
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,M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H3B;;;;;AAIN;;;;;;;;;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\";\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, 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<unknown>\n ? ReducerSchema extends InteropZodType<infer U>\n ? 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":";;;;;AAgBA,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,QAAQ,yBAAyB,OAAO;AAC9C,OAAK,MAAM,CAAC,KAAK,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,QAAQ,UACV,kBAAiB,wBAAwB,eAAe;AAG1D,QAAM,IAAI,QAAQ,eAAe;AACjC,OAAK,gBAAgB,IAAI,UAAU,MAAM;AACzC,SAAO;;;AAIX,MAAa,qBAAqB,IAAI,oBAAoB;AAkB1D,SAAgB,cAKd,QACA,MAC+D;AAC/D,KAAI,KAAK,WAAW,CAAC,KAAK,SAAS;EACjC,MAAM,qBAAqB,2BAA2B,OAAO;AAC7D,MAAI,sBAAsB,KAExB,MAAK,UAAU;;AAGnB,KAAI,KAAK,SAAS;EAChB,MAAM,oBAAoB,OAAO,OAAO,QAAQ,EAC9C,mBAAmB,KAAK,SAAS,UAAU,QAC5C,CAAC;AACF,qBAAmB,OAAO,yBAAyB,KAAK;AACxD,SAAO;QACF;AACL,qBAAmB,OAAO,cAAc,KAAK;AAC7C,SAAO"}
|
|
1
|
+
{"version":3,"file":"meta.js","names":[],"sources":["../../../src/graph/zod/meta.ts"],"sourcesContent":["import {\n InferInteropZodOutput,\n InteropZodObject,\n InteropZodType,\n getInteropZodObjectShape,\n extendInteropZodObject,\n getInteropZodDefaultGetter,\n interopZodObjectPartial,\n InteropZodObjectShape,\n isZodSchemaV3,\n getSchemaDescription,\n} from \"@langchain/core/utils/types\";\nimport { BaseChannel } from \"../../channels/base.js\";\nimport { BinaryOperatorAggregate } from \"../../channels/binop.js\";\nimport { LastValue } from \"../../channels/last_value.js\";\nimport type { OverwriteValue } from \"../../constants.js\";\n\nexport const META_EXTRAS_DESCRIPTION_PREFIX = \"lg:\";\n\n/** @internal */\nexport type ReducedZodChannel<\n T extends InteropZodType,\n TReducerSchema extends InteropZodType\n> = T & {\n lg_reducer_schema: TReducerSchema;\n};\n\n/** @internal */\nexport type InteropZodToStateDefinition<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? BaseChannel<V, OverwriteValue<V> | U>\n : never\n : never\n : TShape[key] extends InteropZodType<infer V, infer U>\n ? BaseChannel<V, U>\n : never;\n};\n\nexport type UpdateType<\n T extends InteropZodObject,\n TShape = InteropZodObjectShape<T>\n> = {\n [key in keyof TShape]?: TShape[key] extends ReducedZodChannel<\n infer Schema,\n infer ReducerSchema\n >\n ? Schema extends InteropZodType<infer V>\n ? ReducerSchema extends InteropZodType<infer U>\n ? OverwriteValue<V> | U\n : never\n : never\n : TShape[key] extends InteropZodType<unknown, infer U>\n ? U\n : never;\n};\n\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport interface SchemaMeta<TValue = any, TUpdate = TValue> {\n jsonSchemaExtra?: {\n langgraph_nodes?: string[];\n langgraph_type?: \"prompt\" | \"messages\";\n [key: string]: unknown;\n };\n reducer?: {\n schema?: InteropZodType<TUpdate>;\n fn: (a: TValue, b: TUpdate) => TValue;\n };\n default?: () => TValue;\n}\n\n/**\n * A registry for storing and managing metadata associated with schemas.\n * This class provides methods to get, extend, remove, and check metadata for a given schema.\n */\nexport class SchemaMetaRegistry {\n /**\n * Internal map storing schema metadata.\n * @internal\n */\n _map = new Map<InteropZodType, SchemaMeta>();\n\n /**\n * Cache for extended schemas.\n * @internal\n */\n _extensionCache = new Map<string, Map<InteropZodType, InteropZodType>>();\n\n /**\n * Retrieves the metadata associated with a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to retrieve metadata for.\n * @returns The associated SchemaMeta, or undefined if not present.\n */\n get<TValue, TUpdate = TValue>(\n schema: InteropZodType<TValue>\n ): SchemaMeta<TValue, TUpdate> | undefined {\n return this._map.get(schema);\n }\n\n /**\n * Extends or sets the metadata for a given schema.\n * @template TValue The value type of the schema.\n * @template TUpdate The update type of the schema (defaults to TValue).\n * @param schema The schema to extend metadata for.\n * @param predicate A function that receives the existing metadata (or undefined) and returns the new metadata.\n */\n extend<TValue, TUpdate>(\n schema: InteropZodType<TValue>,\n predicate: (\n meta: SchemaMeta<TValue, TUpdate> | undefined\n ) => SchemaMeta<TValue, TUpdate>\n ) {\n const existingMeta = this.get<TValue, TUpdate>(schema);\n this._map.set(schema, predicate(existingMeta));\n }\n\n /**\n * Removes the metadata associated with a given schema.\n * @param schema The schema to remove metadata for.\n * @returns The SchemaMetaRegistry instance (for chaining).\n */\n remove(schema: InteropZodType): this {\n this._map.delete(schema);\n return this;\n }\n\n /**\n * Checks if metadata exists for a given schema.\n * @param schema The schema to check.\n * @returns True if metadata exists, false otherwise.\n */\n has(schema: InteropZodType): boolean {\n return this._map.has(schema);\n }\n\n /**\n * Returns a mapping of channel instances for each property in the schema\n * using the associated metadata in the registry.\n *\n * This is used to create the `channels` object that's passed to the `Graph` constructor.\n *\n * @template T The shape of the schema.\n * @param schema The schema to extract channels from.\n * @returns A mapping from property names to channel instances.\n */\n getChannelsForSchema<T extends InteropZodObject>(\n schema: T\n ): InteropZodToStateDefinition<T> {\n const channels = {} as Record<string, BaseChannel>;\n const shape = getInteropZodObjectShape(schema);\n for (const [key, channelSchema] of Object.entries(shape)) {\n const meta = this.get(channelSchema);\n if (meta?.reducer) {\n channels[key] = new BinaryOperatorAggregate<\n InferInteropZodOutput<typeof channelSchema>\n >(meta.reducer.fn, meta.default);\n } else {\n channels[key] = new LastValue(meta?.default);\n }\n }\n return channels as InteropZodToStateDefinition<T>;\n }\n\n /**\n * Returns a modified schema that introspectively looks at all keys of the provided\n * object schema, and applies the augmentations based on meta provided with those keys\n * in the registry and the selectors provided in the `effects` parameter.\n *\n * This assumes that the passed in schema is the \"root\" schema object for a graph where\n * the keys of the schema are the channels of the graph. Because we need to represent\n * the input of a graph in a couple of different ways, the `effects` parameter allows\n * us to apply those augmentations based on pre determined conditions.\n *\n * @param schema The root schema object to extend.\n * @param effects The effects that are being applied.\n * @returns The extended schema.\n */\n getExtendedChannelSchemas<T extends InteropZodObject>(\n schema: T,\n effects: {\n /**\n * Augments the shape by using the reducer's schema if it exists\n */\n withReducerSchema?: boolean;\n /**\n * Applies the stringified jsonSchemaExtra as a description to the schema.\n */\n withJsonSchemaExtrasAsDescription?: boolean;\n /**\n * Applies the `.partial()` modifier to the schema.\n */\n asPartial?: boolean;\n }\n ): InteropZodObject {\n // If no effects are being applied, return the schema unchanged\n if (Object.keys(effects).length === 0) {\n return schema;\n }\n\n // Cache key is determined by looking at the effects that are being applied\n const cacheKey = Object.entries(effects)\n .filter(([, v]) => v === true)\n .sort(([a], [b]) => a.localeCompare(b))\n .map(([k, v]) => `${k}:${v}`)\n .join(\"|\");\n\n const cache = this._extensionCache.get(cacheKey) ?? new Map();\n if (cache.has(schema)) return cache.get(schema)! as T;\n\n let modifiedSchema: InteropZodObject = schema;\n\n if (\n effects.withReducerSchema ||\n effects.withJsonSchemaExtrasAsDescription\n ) {\n const newShapeEntries = Object.entries(\n getInteropZodObjectShape(schema)\n ).map(([key, schema]) => {\n const meta = this.get(schema);\n let outputSchema = effects.withReducerSchema\n ? meta?.reducer?.schema ?? schema\n : schema;\n if (\n effects.withJsonSchemaExtrasAsDescription &&\n meta?.jsonSchemaExtra\n ) {\n const description =\n getSchemaDescription(outputSchema) ?? getSchemaDescription(schema);\n const strExtras = JSON.stringify({\n ...meta.jsonSchemaExtra,\n description,\n });\n outputSchema = outputSchema.describe(\n `${META_EXTRAS_DESCRIPTION_PREFIX}${strExtras}`\n );\n }\n return [key, outputSchema];\n });\n modifiedSchema = extendInteropZodObject(\n schema,\n Object.fromEntries(newShapeEntries)\n );\n if (isZodSchemaV3(modifiedSchema)) {\n modifiedSchema._def.unknownKeys = \"strip\";\n }\n }\n if (effects.asPartial) {\n modifiedSchema = interopZodObjectPartial(modifiedSchema);\n }\n\n cache.set(schema, modifiedSchema);\n this._extensionCache.set(cacheKey, cache);\n return modifiedSchema;\n }\n}\n\nexport const schemaMetaRegistry = new SchemaMetaRegistry();\n\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate> & { reducer?: undefined }\n): TSchema;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>>;\nexport function withLangGraph<\n TValue,\n TUpdate,\n TSchema extends InteropZodType<TValue>\n>(\n schema: TSchema,\n meta: SchemaMeta<TValue, TUpdate>\n): ReducedZodChannel<TSchema, InteropZodType<TUpdate>> | TSchema {\n if (meta.reducer && !meta.default) {\n const defaultValueGetter = getInteropZodDefaultGetter(schema);\n if (defaultValueGetter != null) {\n // eslint-disable-next-line no-param-reassign\n meta.default = defaultValueGetter;\n }\n }\n if (meta.reducer) {\n const schemaWithReducer = Object.assign(schema, {\n lg_reducer_schema: meta.reducer?.schema ?? schema,\n });\n schemaMetaRegistry.extend(schemaWithReducer, () => meta);\n return schemaWithReducer;\n } else {\n schemaMetaRegistry.extend(schema, () => meta);\n return schema;\n }\n}\n"],"mappings":";;;;;AAiBA,MAAa,iCAAiC;;;;;AAiE9C,IAAa,qBAAb,MAAgC;;;;;CAK9B,uBAAO,IAAI,KAAiC;;;;;CAM5C,kCAAkB,IAAI,KAAkD;;;;;;;;CASxE,IACE,QACyC;AACzC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;CAU9B,OACE,QACA,WAGA;EACA,MAAM,eAAe,KAAK,IAAqB,OAAO;AACtD,OAAK,KAAK,IAAI,QAAQ,UAAU,aAAa,CAAC;;;;;;;CAQhD,OAAO,QAA8B;AACnC,OAAK,KAAK,OAAO,OAAO;AACxB,SAAO;;;;;;;CAQT,IAAI,QAAiC;AACnC,SAAO,KAAK,KAAK,IAAI,OAAO;;;;;;;;;;;;CAa9B,qBACE,QACgC;EAChC,MAAM,WAAW,EAAE;EACnB,MAAM,QAAQ,yBAAyB,OAAO;AAC9C,OAAK,MAAM,CAAC,KAAK,kBAAkB,OA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V,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"}
|
package/dist/index.cjs
CHANGED
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
|
|
2
2
|
const require_async_local_storage = require('./setup/async_local_storage.cjs');
|
|
3
|
+
const require_constants = require('./constants.cjs');
|
|
3
4
|
const require_errors = require('./errors.cjs');
|
|
4
5
|
const require_base = require('./channels/base.cjs');
|
|
5
6
|
const require_binop = require('./channels/binop.cjs');
|
|
6
7
|
const require_annotation = require('./graph/annotation.cjs');
|
|
7
|
-
const require_constants = require('./constants.cjs');
|
|
8
8
|
const require_config = require('./pregel/utils/config.cjs');
|
|
9
9
|
const require_interrupt = require('./interrupt.cjs');
|
|
10
10
|
const require_graph = require('./graph/graph.cjs');
|
|
@@ -50,7 +50,9 @@ Object.defineProperty(exports, 'BaseStore', {
|
|
|
50
50
|
}
|
|
51
51
|
});
|
|
52
52
|
exports.BinaryOperatorAggregate = require_binop.BinaryOperatorAggregate;
|
|
53
|
+
exports.COMMAND_SYMBOL = require_constants.COMMAND_SYMBOL;
|
|
53
54
|
exports.Command = require_constants.Command;
|
|
55
|
+
exports.CommandInstance = require_constants.CommandInstance;
|
|
54
56
|
exports.CompiledStateGraph = require_state.CompiledStateGraph;
|
|
55
57
|
exports.END = require_constants.END;
|
|
56
58
|
exports.EmptyChannelError = require_errors.EmptyChannelError;
|
|
@@ -81,6 +83,7 @@ exports.MessagesZodMeta = require_messages_annotation.MessagesZodMeta;
|
|
|
81
83
|
exports.MessagesZodState = require_messages_annotation.MessagesZodState;
|
|
82
84
|
exports.MultipleSubgraphsError = require_errors.MultipleSubgraphsError;
|
|
83
85
|
exports.NodeInterrupt = require_errors.NodeInterrupt;
|
|
86
|
+
exports.Overwrite = require_constants.Overwrite;
|
|
84
87
|
exports.ParentCommand = require_errors.ParentCommand;
|
|
85
88
|
exports.REMOVE_ALL_MESSAGES = require_messages_reducer.REMOVE_ALL_MESSAGES;
|
|
86
89
|
exports.ReducedValue = require_reduced.ReducedValue;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseChannel } from "./channels/base.cjs";
|
|
2
|
+
import { COMMAND_SYMBOL, Command, CommandInstance, CommandParams, END, INTERRUPT, Interrupt, Overwrite, OverwriteValue, START, Send, isCommand, isInterrupted } from "./constants.cjs";
|
|
2
3
|
import { BinaryOperator, BinaryOperatorAggregate } from "./channels/binop.cjs";
|
|
3
4
|
import { AnyValue } from "./channels/any_value.cjs";
|
|
4
5
|
import { LastValue } from "./channels/last_value.cjs";
|
|
@@ -11,7 +12,6 @@ import { LangGraphRunnableConfig, Runtime } from "./pregel/runnable_types.cjs";
|
|
|
11
12
|
import { Annotation, AnnotationRoot, NodeType, SingleReducer, StateDefinition, StateType, UpdateType } from "./graph/annotation.cjs";
|
|
12
13
|
import { RetryPolicy } from "./pregel/utils/index.cjs";
|
|
13
14
|
import { PregelNode } from "./pregel/read.cjs";
|
|
14
|
-
import { Command, CommandParams, END, INTERRUPT, Interrupt, START, Send, isCommand, isInterrupted } from "./constants.cjs";
|
|
15
15
|
import { GetStateOptions, MultipleChannelSubscriptionOptions, PregelOptions, PregelParams, SingleChannelSubscriptionOptions, StateSnapshot, StreamMode, StreamOutputMap } from "./pregel/types.cjs";
|
|
16
16
|
import { Pregel } from "./pregel/index.cjs";
|
|
17
17
|
import { CompiledGraph, Graph } from "./graph/graph.cjs";
|
|
@@ -32,4 +32,4 @@ import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter
|
|
|
32
32
|
import { MessagesValue } from "./state/prebuilt/messages.cjs";
|
|
33
33
|
import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, Checkpoint, CheckpointMetadata, CheckpointTuple, GetOperation, InMemoryStore, Item, ListNamespacesOperation, MatchCondition, MemorySaver, NameSpacePath, NamespaceMatchType, Operation, OperationResults, PutOperation, SearchOperation, copyCheckpoint, emptyCheckpoint } from "./web.cjs";
|
|
34
34
|
import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.cjs";
|
|
35
|
-
export { Annotation, AnnotationRoot, AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, BinaryOperator, BinaryOperatorAggregate, Checkpoint, CheckpointMetadata, CheckpointTuple, Command, CommandParams, CompiledGraph, CompiledStateGraph, ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, EntrypointOptions, EphemeralValue, ExtractStateType, ExtractUpdateType, GetOperation, GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, GraphNode, GraphNodeReturnValue, GraphNodeTypes, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InferStateSchemaUpdate, InferStateSchemaValue, Interrupt, InvalidUpdateError, Item, LangGraphRunnableConfig, LastValue, ListNamespacesOperation, MatchCondition, MemorySaver, MessageGraph, Messages, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleChannelSubscriptionOptions, MultipleSubgraphsError, NameSpacePath, NamedBarrierValue, NamespaceMatchType, NodeInterrupt, NodeType, Operation, OperationResults, ParentCommand, Pregel, PregelNode, PregelOptions, PregelParams, PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, RetryPolicy, Runtime, START, SearchOperation, Send, SingleChannelSubscriptionOptions, SingleReducer, StateDefinition, StateDefinitionInit, StateGraph, StateGraphArgs, StateGraphInit, StateGraphInputError, StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFields, StateSnapshot, StateType, StreamMode, StreamOutputMap, TaskOptions, Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, UpdateType, WaitForNames, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
|
|
35
|
+
export { Annotation, AnnotationRoot, AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, Checkpoint, CheckpointMetadata, CheckpointTuple, Command, CommandInstance, CommandParams, CompiledGraph, CompiledStateGraph, ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, EntrypointOptions, EphemeralValue, ExtractStateType, ExtractUpdateType, GetOperation, GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, GraphNode, GraphNodeReturnValue, GraphNodeTypes, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InferStateSchemaUpdate, InferStateSchemaValue, Interrupt, InvalidUpdateError, Item, LangGraphRunnableConfig, LastValue, ListNamespacesOperation, MatchCondition, MemorySaver, MessageGraph, Messages, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleChannelSubscriptionOptions, MultipleSubgraphsError, NameSpacePath, NamedBarrierValue, NamespaceMatchType, NodeInterrupt, NodeType, Operation, OperationResults, Overwrite, OverwriteValue, ParentCommand, Pregel, PregelNode, PregelOptions, PregelParams, PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, RetryPolicy, Runtime, START, SearchOperation, Send, SingleChannelSubscriptionOptions, SingleReducer, StateDefinition, StateDefinitionInit, StateGraph, StateGraphArgs, StateGraphInit, StateGraphInputError, StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFields, StateSnapshot, StateType, StreamMode, StreamOutputMap, TaskOptions, Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, UpdateType, WaitForNames, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import { BaseChannel } from "./channels/base.js";
|
|
2
|
+
import { COMMAND_SYMBOL, Command, CommandInstance, CommandParams, END, INTERRUPT, Interrupt, Overwrite, OverwriteValue, START, Send, isCommand, isInterrupted } from "./constants.js";
|
|
2
3
|
import { BinaryOperator, BinaryOperatorAggregate } from "./channels/binop.js";
|
|
3
4
|
import { AnyValue } from "./channels/any_value.js";
|
|
4
5
|
import { LastValue } from "./channels/last_value.js";
|
|
@@ -11,7 +12,6 @@ import { LangGraphRunnableConfig, Runtime } from "./pregel/runnable_types.js";
|
|
|
11
12
|
import { Annotation, AnnotationRoot, NodeType, SingleReducer, StateDefinition, StateType, UpdateType } from "./graph/annotation.js";
|
|
12
13
|
import { RetryPolicy } from "./pregel/utils/index.js";
|
|
13
14
|
import { PregelNode } from "./pregel/read.js";
|
|
14
|
-
import { Command, CommandParams, END, INTERRUPT, Interrupt, START, Send, isCommand, isInterrupted } from "./constants.js";
|
|
15
15
|
import { GetStateOptions, MultipleChannelSubscriptionOptions, PregelOptions, PregelParams, SingleChannelSubscriptionOptions, StateSnapshot, StreamMode, StreamOutputMap } from "./pregel/types.js";
|
|
16
16
|
import { Pregel } from "./pregel/index.js";
|
|
17
17
|
import { CompiledGraph, Graph } from "./graph/graph.js";
|
|
@@ -32,4 +32,4 @@ import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter
|
|
|
32
32
|
import { MessagesValue } from "./state/prebuilt/messages.js";
|
|
33
33
|
import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, Checkpoint, CheckpointMetadata, CheckpointTuple, GetOperation, InMemoryStore, Item, ListNamespacesOperation, MatchCondition, MemorySaver, NameSpacePath, NamespaceMatchType, Operation, OperationResults, PutOperation, SearchOperation, copyCheckpoint, emptyCheckpoint } from "./web.js";
|
|
34
34
|
import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.js";
|
|
35
|
-
export { Annotation, AnnotationRoot, AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, BinaryOperator, BinaryOperatorAggregate, Checkpoint, CheckpointMetadata, CheckpointTuple, Command, CommandParams, CompiledGraph, CompiledStateGraph, ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, EntrypointOptions, EphemeralValue, ExtractStateType, ExtractUpdateType, GetOperation, GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, GraphNode, GraphNodeReturnValue, GraphNodeTypes, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InferStateSchemaUpdate, InferStateSchemaValue, Interrupt, InvalidUpdateError, Item, LangGraphRunnableConfig, LastValue, ListNamespacesOperation, MatchCondition, MemorySaver, MessageGraph, Messages, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleChannelSubscriptionOptions, MultipleSubgraphsError, NameSpacePath, NamedBarrierValue, NamespaceMatchType, NodeInterrupt, NodeType, Operation, OperationResults, ParentCommand, Pregel, PregelNode, PregelOptions, PregelParams, PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, RetryPolicy, Runtime, START, SearchOperation, Send, SingleChannelSubscriptionOptions, SingleReducer, StateDefinition, StateDefinitionInit, StateGraph, StateGraphArgs, StateGraphInit, StateGraphInputError, StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFields, StateSnapshot, StateType, StreamMode, StreamOutputMap, TaskOptions, Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, UpdateType, WaitForNames, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
|
|
35
|
+
export { Annotation, AnnotationRoot, AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, Checkpoint, CheckpointMetadata, CheckpointTuple, Command, CommandInstance, CommandParams, CompiledGraph, CompiledStateGraph, ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, EntrypointOptions, EphemeralValue, ExtractStateType, ExtractUpdateType, GetOperation, GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, GraphNode, GraphNodeReturnValue, GraphNodeTypes, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InferStateSchemaUpdate, InferStateSchemaValue, Interrupt, InvalidUpdateError, Item, LangGraphRunnableConfig, LastValue, ListNamespacesOperation, MatchCondition, MemorySaver, MessageGraph, Messages, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleChannelSubscriptionOptions, MultipleSubgraphsError, NameSpacePath, NamedBarrierValue, NamespaceMatchType, NodeInterrupt, NodeType, Operation, OperationResults, Overwrite, OverwriteValue, ParentCommand, Pregel, PregelNode, PregelOptions, PregelParams, PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, RetryPolicy, Runtime, START, SearchOperation, Send, SingleChannelSubscriptionOptions, SingleReducer, StateDefinition, StateDefinitionInit, StateGraph, StateGraphArgs, StateGraphInit, StateGraphInputError, StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFields, StateSnapshot, StateType, StreamMode, StreamOutputMap, TaskOptions, Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, UpdateType, WaitForNames, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
|
package/dist/index.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { initializeAsyncLocalStorageSingleton } from "./setup/async_local_storage.js";
|
|
2
|
+
import { COMMAND_SYMBOL, Command, CommandInstance, END, INTERRUPT, Overwrite, START, Send, isCommand, isInterrupted } from "./constants.js";
|
|
2
3
|
import { BaseLangGraphError, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeInterrupt, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphInterrupt, isParentCommand } from "./errors.js";
|
|
3
4
|
import { BaseChannel } from "./channels/base.js";
|
|
4
5
|
import { BinaryOperatorAggregate } from "./channels/binop.js";
|
|
5
6
|
import { Annotation } from "./graph/annotation.js";
|
|
6
|
-
import { Command, END, INTERRUPT, START, Send, isCommand, isInterrupted } from "./constants.js";
|
|
7
7
|
import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.js";
|
|
8
8
|
import { interrupt } from "./interrupt.js";
|
|
9
9
|
import { Graph } from "./graph/graph.js";
|
|
@@ -26,5 +26,5 @@ import { writer } from "./writer.js";
|
|
|
26
26
|
initializeAsyncLocalStorageSingleton();
|
|
27
27
|
|
|
28
28
|
//#endregion
|
|
29
|
-
export { Annotation, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseStore, BinaryOperatorAggregate, Command, CompiledStateGraph, END, EmptyChannelError, EmptyInputError, Graph, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InvalidUpdateError, MemorySaver, MessageGraph, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleSubgraphsError, NodeInterrupt, ParentCommand, REMOVE_ALL_MESSAGES, ReducedValue, RemoteException, START, Send, StateGraph, StateGraphInputError, StateSchema, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
|
|
29
|
+
export { Annotation, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseStore, BinaryOperatorAggregate, COMMAND_SYMBOL, Command, CommandInstance, CompiledStateGraph, END, EmptyChannelError, EmptyInputError, Graph, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InvalidUpdateError, MemorySaver, MessageGraph, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleSubgraphsError, NodeInterrupt, Overwrite, ParentCommand, REMOVE_ALL_MESSAGES, ReducedValue, RemoteException, START, Send, StateGraph, StateGraphInputError, StateSchema, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
|
|
30
30
|
//# sourceMappingURL=index.js.map
|
package/dist/interrupt.cjs
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_errors = require('./errors.cjs');
|
|
2
1
|
const require_constants = require('./constants.cjs');
|
|
2
|
+
const require_errors = require('./errors.cjs');
|
|
3
3
|
const require_hash = require('./hash.cjs');
|
|
4
4
|
let _langchain_core_singletons = require("@langchain/core/singletons");
|
|
5
5
|
|
package/dist/interrupt.js
CHANGED
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { GraphInterrupt, GraphValueError } from "./errors.js";
|
|
2
1
|
import { CHECKPOINT_NAMESPACE_SEPARATOR, CONFIG_KEY_CHECKPOINTER, CONFIG_KEY_CHECKPOINT_NS, CONFIG_KEY_SCRATCHPAD, CONFIG_KEY_SEND, RESUME } from "./constants.js";
|
|
2
|
+
import { GraphInterrupt, GraphValueError } from "./errors.js";
|
|
3
3
|
import { XXH3 } from "./hash.js";
|
|
4
4
|
import { AsyncLocalStorageProviderSingleton } from "@langchain/core/singletons";
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_annotation = require('../graph/annotation.cjs');
|
|
2
1
|
const require_constants = require('../constants.cjs');
|
|
2
|
+
const require_annotation = require('../graph/annotation.cjs');
|
|
3
3
|
const require_messages_reducer = require('../graph/messages_reducer.cjs');
|
|
4
4
|
const require_state = require('../graph/state.cjs');
|
|
5
5
|
require('../graph/index.cjs');
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseChannel } from "../channels/base.cjs";
|
|
2
|
+
import { OverwriteValue, START } from "../constants.cjs";
|
|
2
3
|
import { LastValue } from "../channels/last_value.cjs";
|
|
3
4
|
import { InteropZodToStateDefinition } from "../graph/zod/meta.cjs";
|
|
4
5
|
import { LangGraphRunnableConfig, Runtime } from "../pregel/runnable_types.cjs";
|
|
5
6
|
import { AnnotationRoot, SingleReducer, StateDefinition } from "../graph/annotation.cjs";
|
|
6
|
-
import { START } from "../constants.cjs";
|
|
7
7
|
import { CompiledStateGraph } from "../graph/state.cjs";
|
|
8
8
|
import { Messages } from "../graph/messages_reducer.cjs";
|
|
9
9
|
import { MessagesAnnotation } from "../graph/messages_annotation.cjs";
|
|
@@ -40,15 +40,15 @@ type StateModifier = Prompt;
|
|
|
40
40
|
/** @deprecated Use Prompt instead. */
|
|
41
41
|
type MessageModifier = SystemMessage | string | ((messages: BaseMessage[]) => BaseMessage[]) | ((messages: BaseMessage[]) => Promise<BaseMessage[]>) | Runnable;
|
|
42
42
|
declare const createReactAgentAnnotation: <T extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{
|
|
43
|
-
messages:
|
|
43
|
+
messages: BaseChannel<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], OverwriteValue<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[]> | Messages, unknown>;
|
|
44
44
|
structuredResponse: {
|
|
45
|
+
(annotation: SingleReducer<T, T>): BaseChannel<T, T | OverwriteValue<T>, unknown>;
|
|
45
46
|
(): LastValue<T>;
|
|
46
|
-
(annotation: SingleReducer<T, T>): BinaryOperatorAggregate<T, T>;
|
|
47
47
|
Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;
|
|
48
48
|
};
|
|
49
49
|
}>;
|
|
50
50
|
declare const PreHookAnnotation: AnnotationRoot<{
|
|
51
|
-
llmInputMessages:
|
|
51
|
+
llmInputMessages: BaseChannel<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], OverwriteValue<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[]> | Messages, unknown>;
|
|
52
52
|
}>;
|
|
53
53
|
type PreHookAnnotation = typeof PreHookAnnotation;
|
|
54
54
|
type AnyAnnotationRoot = AnnotationRoot<any>;
|
|
@@ -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;;K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,CACd,gBAAA,CAAiB,CAAA,YACjB,gBAAA,CAAiB,CAAA,aACjB,uBAAA;;;;;;;;;;;;EAcF,OAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA7KG;;;iBA6NW,gBAAA,WACJ,iBAAA,GAAoB,gBAAA,UAA0B,kBAAA,mCAEvB,MAAA,gBAAsB,MAAA,yBAC7C,iBAAA,GAAoB,gBAAA,GAAmB,iBAAA,CAAA,CAEjD,MAAA,EAAQ,sBAAA,CAAuB,CAAA,EAAG,wBAAA,EAA0B,CAAA,IAC3D,kBAAA,CACD,gBAAA,CAAiB,CAAA,YACjB,gBAAA,CAAiB,CAAA,yBAGV,kBAAA,CAAmB,IAAA,GAAO,gBAAA,CAAiB,CAAA,WAClD,UAAA,QACS,0BAAA,CAA2B,wBAAA,aAElC,gBAAA,CAAiB,CAAA"}
|
|
@@ -1,9 +1,9 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { BaseChannel } from "../channels/base.js";
|
|
2
|
+
import { OverwriteValue, START } from "../constants.js";
|
|
2
3
|
import { LastValue } from "../channels/last_value.js";
|
|
3
4
|
import { InteropZodToStateDefinition } from "../graph/zod/meta.js";
|
|
4
5
|
import { LangGraphRunnableConfig, Runtime } from "../pregel/runnable_types.js";
|
|
5
6
|
import { AnnotationRoot, SingleReducer, StateDefinition } from "../graph/annotation.js";
|
|
6
|
-
import { START } from "../constants.js";
|
|
7
7
|
import { CompiledStateGraph } from "../graph/state.js";
|
|
8
8
|
import { Messages } from "../graph/messages_reducer.js";
|
|
9
9
|
import "../graph/index.js";
|
|
@@ -42,15 +42,15 @@ type StateModifier = Prompt;
|
|
|
42
42
|
/** @deprecated Use Prompt instead. */
|
|
43
43
|
type MessageModifier = SystemMessage | string | ((messages: BaseMessage[]) => BaseMessage[]) | ((messages: BaseMessage[]) => Promise<BaseMessage[]>) | Runnable;
|
|
44
44
|
declare const createReactAgentAnnotation: <T extends Record<string, any> = Record<string, any>>() => AnnotationRoot<{
|
|
45
|
-
messages:
|
|
45
|
+
messages: BaseChannel<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], OverwriteValue<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[]> | Messages, unknown>;
|
|
46
46
|
structuredResponse: {
|
|
47
|
+
(annotation: SingleReducer<T, T>): BaseChannel<T, T | OverwriteValue<T>, unknown>;
|
|
47
48
|
(): LastValue<T>;
|
|
48
|
-
(annotation: SingleReducer<T, T>): BinaryOperatorAggregate<T, T>;
|
|
49
49
|
Root: <S extends StateDefinition>(sd: S) => AnnotationRoot<S>;
|
|
50
50
|
};
|
|
51
51
|
}>;
|
|
52
52
|
declare const PreHookAnnotation: AnnotationRoot<{
|
|
53
|
-
llmInputMessages:
|
|
53
|
+
llmInputMessages: BaseChannel<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[], OverwriteValue<BaseMessage<_langchain_core_messages0.MessageStructure<_langchain_core_messages0.MessageToolSet>, _langchain_core_messages0.MessageType>[]> | Messages, unknown>;
|
|
54
54
|
}>;
|
|
55
55
|
type PreHookAnnotation = typeof PreHookAnnotation;
|
|
56
56
|
type AnyAnnotationRoot = AnnotationRoot<any>;
|
|
@@ -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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SAAA;EAzHD;;;;;AAIT;;;;;AAGA;;;;;;;;EAqIE,cAAA,GACI,cAAA,CAAe,sBAAA,IACf,+BAAA,CAAgC,sBAAA,IAEhC,MAAA;EApIF;;;EAyIF,IAAA;EA3Ic;;;;EAiJd,WAAA;EAhJgC;;;;;AAGlC;EAsJE,gBAAA;EApJC;;;;EA0JD,YAAA,GAAe,YAAA,CACb,gBAAA,CAAiB,CAAA,aAAc,iBAAA,WAC/B,gBAAA,CAAiB,CAAA,cAAe,iBAAA,YAChC,uBAAA;;;;;EAOF,aAAA,GAAgB,YAAA,CACd,gBAAA,CAAiB,CAAA,YACjB,gBAAA,CAAiB,CAAA,aACjB,uBAAA;;;;;;;;;;;;EAcF,OAAA;AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA7KG;iBA6NW,gBAAA,WACJ,iBAAA,GAAoB,gBAAA,UAA0B,kBAAA,mCAEvB,MAAA,gBAAsB,MAAA,yBAC7C,iBAAA,GAAoB,gBAAA,GAAmB,iBAAA,CAAA,CAEjD,MAAA,EAAQ,sBAAA,CAAuB,CAAA,EAAG,wBAAA,EAA0B,CAAA,IAC3D,kBAAA,CACD,gBAAA,CAAiB,CAAA,YACjB,gBAAA,CAAiB,CAAA,yBAGV,kBAAA,CAAmB,IAAA,GAAO,gBAAA,CAAiB,CAAA,WAClD,UAAA,QACS,0BAAA,CAA2B,wBAAA,aAElC,gBAAA,CAAiB,CAAA"}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { Annotation } from "../graph/annotation.js";
|
|
2
1
|
import { END, START, Send } from "../constants.js";
|
|
2
|
+
import { Annotation } from "../graph/annotation.js";
|
|
3
3
|
import { messagesStateReducer } from "../graph/messages_reducer.js";
|
|
4
4
|
import { StateGraph } from "../graph/state.js";
|
|
5
5
|
import "../graph/index.js";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
const require_errors = require('../errors.cjs');
|
|
2
1
|
const require_constants = require('../constants.cjs');
|
|
2
|
+
const require_errors = require('../errors.cjs');
|
|
3
3
|
const require_utils = require('../utils.cjs');
|
|
4
4
|
let _langchain_core_messages = require("@langchain/core/messages");
|
|
5
5
|
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RunnableCallable } from "../utils.cjs";
|
|
2
1
|
import { Command, END } from "../constants.cjs";
|
|
2
|
+
import { RunnableCallable } from "../utils.cjs";
|
|
3
3
|
import { MessagesAnnotation } from "../graph/messages_annotation.cjs";
|
|
4
4
|
import { RunnableConfig, RunnableToolLike } from "@langchain/core/runnables";
|
|
5
5
|
import { BaseMessage, ToolMessage } from "@langchain/core/messages";
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import { RunnableCallable } from "../utils.js";
|
|
2
1
|
import { Command, END } from "../constants.js";
|
|
2
|
+
import { RunnableCallable } from "../utils.js";
|
|
3
3
|
import { MessagesAnnotation } from "../graph/messages_annotation.js";
|
|
4
4
|
import { RunnableConfig, RunnableToolLike } from "@langchain/core/runnables";
|
|
5
5
|
import { BaseMessage, ToolMessage } from "@langchain/core/messages";
|