@langchain/langgraph 1.3.7 → 1.4.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.
Files changed (215) hide show
  1. package/dist/channels/base.cjs +78 -2
  2. package/dist/channels/base.cjs.map +1 -1
  3. package/dist/channels/base.d.cts +35 -2
  4. package/dist/channels/base.d.cts.map +1 -1
  5. package/dist/channels/base.d.ts +35 -2
  6. package/dist/channels/base.d.ts.map +1 -1
  7. package/dist/channels/base.js +77 -4
  8. package/dist/channels/base.js.map +1 -1
  9. package/dist/channels/delta.cjs +136 -0
  10. package/dist/channels/delta.cjs.map +1 -0
  11. package/dist/channels/delta.d.cts +99 -0
  12. package/dist/channels/delta.d.cts.map +1 -0
  13. package/dist/channels/delta.d.ts +99 -0
  14. package/dist/channels/delta.d.ts.map +1 -0
  15. package/dist/channels/delta.js +136 -0
  16. package/dist/channels/delta.js.map +1 -0
  17. package/dist/channels/index.cjs +5 -0
  18. package/dist/channels/index.d.cts +3 -2
  19. package/dist/channels/index.d.ts +3 -2
  20. package/dist/channels/index.js +3 -2
  21. package/dist/constants.cjs +63 -4
  22. package/dist/constants.cjs.map +1 -1
  23. package/dist/constants.d.cts +33 -2
  24. package/dist/constants.d.cts.map +1 -1
  25. package/dist/constants.d.ts +33 -2
  26. package/dist/constants.d.ts.map +1 -1
  27. package/dist/constants.js +59 -5
  28. package/dist/constants.js.map +1 -1
  29. package/dist/errors.cjs +128 -0
  30. package/dist/errors.cjs.map +1 -1
  31. package/dist/errors.d.cts +86 -1
  32. package/dist/errors.d.cts.map +1 -1
  33. package/dist/errors.d.ts +86 -1
  34. package/dist/errors.d.ts.map +1 -1
  35. package/dist/errors.js +123 -1
  36. package/dist/errors.js.map +1 -1
  37. package/dist/func/index.cjs +9 -2
  38. package/dist/func/index.cjs.map +1 -1
  39. package/dist/func/index.d.cts +14 -0
  40. package/dist/func/index.d.cts.map +1 -1
  41. package/dist/func/index.d.ts +14 -0
  42. package/dist/func/index.d.ts.map +1 -1
  43. package/dist/func/index.js +9 -2
  44. package/dist/func/index.js.map +1 -1
  45. package/dist/graph/graph.cjs +44 -7
  46. package/dist/graph/graph.cjs.map +1 -1
  47. package/dist/graph/graph.d.cts +24 -2
  48. package/dist/graph/graph.d.cts.map +1 -1
  49. package/dist/graph/graph.d.ts +24 -2
  50. package/dist/graph/graph.d.ts.map +1 -1
  51. package/dist/graph/graph.js +44 -7
  52. package/dist/graph/graph.js.map +1 -1
  53. package/dist/graph/index.d.ts +3 -3
  54. package/dist/graph/messages_reducer.cjs +55 -0
  55. package/dist/graph/messages_reducer.cjs.map +1 -1
  56. package/dist/graph/messages_reducer.d.cts +28 -1
  57. package/dist/graph/messages_reducer.d.cts.map +1 -1
  58. package/dist/graph/messages_reducer.d.ts +28 -1
  59. package/dist/graph/messages_reducer.d.ts.map +1 -1
  60. package/dist/graph/messages_reducer.js +56 -2
  61. package/dist/graph/messages_reducer.js.map +1 -1
  62. package/dist/graph/state.cjs +208 -12
  63. package/dist/graph/state.cjs.map +1 -1
  64. package/dist/graph/state.d.cts +193 -17
  65. package/dist/graph/state.d.cts.map +1 -1
  66. package/dist/graph/state.d.ts +193 -17
  67. package/dist/graph/state.d.ts.map +1 -1
  68. package/dist/graph/state.js +210 -14
  69. package/dist/graph/state.js.map +1 -1
  70. package/dist/graph/zod/schema.cjs +5 -0
  71. package/dist/graph/zod/schema.cjs.map +1 -1
  72. package/dist/graph/zod/schema.d.cts.map +1 -1
  73. package/dist/graph/zod/schema.d.ts.map +1 -1
  74. package/dist/graph/zod/schema.js +5 -0
  75. package/dist/graph/zod/schema.js.map +1 -1
  76. package/dist/index.cjs +11 -0
  77. package/dist/index.cjs.map +1 -1
  78. package/dist/index.d.cts +11 -8
  79. package/dist/index.d.ts +11 -8
  80. package/dist/index.js +5 -3
  81. package/dist/index.js.map +1 -1
  82. package/dist/prebuilt/react_agent_executor.d.cts +1 -1
  83. package/dist/prebuilt/tool_node.cjs +69 -6
  84. package/dist/prebuilt/tool_node.cjs.map +1 -1
  85. package/dist/prebuilt/tool_node.d.cts +55 -3
  86. package/dist/prebuilt/tool_node.d.cts.map +1 -1
  87. package/dist/prebuilt/tool_node.d.ts +55 -3
  88. package/dist/prebuilt/tool_node.d.ts.map +1 -1
  89. package/dist/prebuilt/tool_node.js +69 -6
  90. package/dist/prebuilt/tool_node.js.map +1 -1
  91. package/dist/pregel/algo.cjs +182 -21
  92. package/dist/pregel/algo.cjs.map +1 -1
  93. package/dist/pregel/algo.d.cts +1 -1
  94. package/dist/pregel/algo.d.cts.map +1 -1
  95. package/dist/pregel/algo.d.ts +1 -1
  96. package/dist/pregel/algo.d.ts.map +1 -1
  97. package/dist/pregel/algo.js +185 -25
  98. package/dist/pregel/algo.js.map +1 -1
  99. package/dist/pregel/call.cjs +2 -1
  100. package/dist/pregel/call.cjs.map +1 -1
  101. package/dist/pregel/call.js +2 -1
  102. package/dist/pregel/call.js.map +1 -1
  103. package/dist/pregel/index.cjs +15 -3
  104. package/dist/pregel/index.cjs.map +1 -1
  105. package/dist/pregel/index.d.cts.map +1 -1
  106. package/dist/pregel/index.d.ts.map +1 -1
  107. package/dist/pregel/index.js +17 -5
  108. package/dist/pregel/index.js.map +1 -1
  109. package/dist/pregel/loop.cjs +362 -41
  110. package/dist/pregel/loop.cjs.map +1 -1
  111. package/dist/pregel/loop.js +365 -44
  112. package/dist/pregel/loop.js.map +1 -1
  113. package/dist/pregel/messages-v2.cjs +1 -1
  114. package/dist/pregel/messages-v2.js +1 -1
  115. package/dist/pregel/messages.cjs +1 -1
  116. package/dist/pregel/messages.js +1 -1
  117. package/dist/pregel/read.cjs +15 -5
  118. package/dist/pregel/read.cjs.map +1 -1
  119. package/dist/pregel/read.d.cts +9 -0
  120. package/dist/pregel/read.d.cts.map +1 -1
  121. package/dist/pregel/read.d.ts +9 -0
  122. package/dist/pregel/read.d.ts.map +1 -1
  123. package/dist/pregel/read.js +15 -5
  124. package/dist/pregel/read.js.map +1 -1
  125. package/dist/pregel/remote-run-stream.cjs +107 -0
  126. package/dist/pregel/remote-run-stream.cjs.map +1 -0
  127. package/dist/pregel/remote-run-stream.d.cts +33 -0
  128. package/dist/pregel/remote-run-stream.d.cts.map +1 -0
  129. package/dist/pregel/remote-run-stream.d.ts +33 -0
  130. package/dist/pregel/remote-run-stream.d.ts.map +1 -0
  131. package/dist/pregel/remote-run-stream.js +107 -0
  132. package/dist/pregel/remote-run-stream.js.map +1 -0
  133. package/dist/pregel/remote.cjs +61 -1
  134. package/dist/pregel/remote.cjs.map +1 -1
  135. package/dist/pregel/remote.d.cts +17 -0
  136. package/dist/pregel/remote.d.cts.map +1 -1
  137. package/dist/pregel/remote.d.ts +17 -0
  138. package/dist/pregel/remote.d.ts.map +1 -1
  139. package/dist/pregel/remote.js +61 -1
  140. package/dist/pregel/remote.js.map +1 -1
  141. package/dist/pregel/replay.cjs +62 -0
  142. package/dist/pregel/replay.cjs.map +1 -0
  143. package/dist/pregel/replay.js +62 -0
  144. package/dist/pregel/replay.js.map +1 -0
  145. package/dist/pregel/retry.cjs +8 -6
  146. package/dist/pregel/retry.cjs.map +1 -1
  147. package/dist/pregel/retry.js +8 -6
  148. package/dist/pregel/retry.js.map +1 -1
  149. package/dist/pregel/runnable_types.d.cts +20 -0
  150. package/dist/pregel/runnable_types.d.cts.map +1 -1
  151. package/dist/pregel/runnable_types.d.ts +20 -0
  152. package/dist/pregel/runnable_types.d.ts.map +1 -1
  153. package/dist/pregel/runner.cjs +48 -7
  154. package/dist/pregel/runner.cjs.map +1 -1
  155. package/dist/pregel/runner.js +50 -9
  156. package/dist/pregel/runner.js.map +1 -1
  157. package/dist/pregel/runtime.cjs +64 -0
  158. package/dist/pregel/runtime.cjs.map +1 -0
  159. package/dist/pregel/runtime.d.cts +57 -0
  160. package/dist/pregel/runtime.d.cts.map +1 -0
  161. package/dist/pregel/runtime.d.ts +57 -0
  162. package/dist/pregel/runtime.d.ts.map +1 -0
  163. package/dist/pregel/runtime.js +64 -0
  164. package/dist/pregel/runtime.js.map +1 -0
  165. package/dist/pregel/stream.cjs +2 -0
  166. package/dist/pregel/stream.cjs.map +1 -1
  167. package/dist/pregel/stream.js +2 -0
  168. package/dist/pregel/stream.js.map +1 -1
  169. package/dist/pregel/timeout.cjs +216 -0
  170. package/dist/pregel/timeout.cjs.map +1 -0
  171. package/dist/pregel/timeout.js +216 -0
  172. package/dist/pregel/timeout.js.map +1 -0
  173. package/dist/pregel/types.cjs +3 -1
  174. package/dist/pregel/types.cjs.map +1 -1
  175. package/dist/pregel/types.d.cts +13 -0
  176. package/dist/pregel/types.d.cts.map +1 -1
  177. package/dist/pregel/types.d.ts +14 -1
  178. package/dist/pregel/types.d.ts.map +1 -1
  179. package/dist/pregel/types.js +3 -1
  180. package/dist/pregel/types.js.map +1 -1
  181. package/dist/pregel/utils/config.cjs +18 -2
  182. package/dist/pregel/utils/config.cjs.map +1 -1
  183. package/dist/pregel/utils/config.d.cts +15 -1
  184. package/dist/pregel/utils/config.d.cts.map +1 -1
  185. package/dist/pregel/utils/config.d.ts +15 -1
  186. package/dist/pregel/utils/config.d.ts.map +1 -1
  187. package/dist/pregel/utils/config.js +18 -2
  188. package/dist/pregel/utils/config.js.map +1 -1
  189. package/dist/pregel/utils/index.cjs +1 -0
  190. package/dist/pregel/utils/index.cjs.map +1 -1
  191. package/dist/pregel/utils/index.d.cts +6 -1
  192. package/dist/pregel/utils/index.d.cts.map +1 -1
  193. package/dist/pregel/utils/index.d.ts +6 -1
  194. package/dist/pregel/utils/index.d.ts.map +1 -1
  195. package/dist/pregel/utils/index.js +1 -0
  196. package/dist/pregel/utils/index.js.map +1 -1
  197. package/dist/pregel/utils/timeout.cjs +34 -0
  198. package/dist/pregel/utils/timeout.cjs.map +1 -0
  199. package/dist/pregel/utils/timeout.d.cts +45 -0
  200. package/dist/pregel/utils/timeout.d.cts.map +1 -0
  201. package/dist/pregel/utils/timeout.d.ts +45 -0
  202. package/dist/pregel/utils/timeout.d.ts.map +1 -0
  203. package/dist/pregel/utils/timeout.js +34 -0
  204. package/dist/pregel/utils/timeout.js.map +1 -0
  205. package/dist/state/schema.cjs +12 -2
  206. package/dist/state/schema.cjs.map +1 -1
  207. package/dist/state/schema.d.cts.map +1 -1
  208. package/dist/state/schema.d.ts.map +1 -1
  209. package/dist/state/schema.js +12 -2
  210. package/dist/state/schema.js.map +1 -1
  211. package/dist/web.cjs +11 -0
  212. package/dist/web.d.cts +11 -8
  213. package/dist/web.d.ts +11 -8
  214. package/dist/web.js +5 -3
  215. package/package.json +5 -5
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","names":[],"sources":["../../src/state/schema.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { JSONSchema } from \"@langchain/core/utils/json_schema\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nimport type { RunnableLike } from \"../pregel/runnable_types.js\";\nimport {\n BaseChannel,\n LastValue,\n BinaryOperatorAggregate,\n} from \"../channels/index.js\";\nimport { UntrackedValueChannel } from \"../channels/untracked_value.js\";\n\nimport type { SerializableSchema } from \"./types.js\";\nimport { isStandardSchema } from \"./types.js\";\nimport { getJsonSchemaFromSchema, getSchemaDefaultGetter } from \"./adapter.js\";\nimport type { OverwriteValue } from \"../constants.js\";\nimport { ReducedValue } from \"./values/reduced.js\";\nimport { UntrackedValue } from \"./values/untracked.js\";\n\nconst STATE_SCHEMA_SYMBOL = Symbol.for(\"langgraph.state.state_schema\");\n\n/**\n * Maps a single StateSchema field definition to its corresponding Channel type.\n *\n * This utility type inspects the type of the field and returns an appropriate\n * `BaseChannel` type, parameterized with the state \"value\" and \"input\" types according to the field's shape.\n *\n * Rules:\n * - If the field (`F`) is a `ReducedValue<V, I>`, the channel will store values of type `V`\n * and accept input of type `I`.\n * - If the field is a `UntrackedValue<V>`, the channel will store and accept values of type `V`.\n * - If the field is a `SerializableSchema<I, O>`, the channel will store values of type `O`\n * (the schema's output/validated value) and accept input of type `I`.\n * - For all other types, a generic `BaseChannel<unknown, unknown>` is used as fallback.\n *\n * @template F - The StateSchema field type to map to a Channel type.\n *\n * @example\n * ```typescript\n * type MyField = ReducedValue<number, string>;\n * type ChannelType = StateSchemaFieldToChannel<MyField>;\n * // ChannelType is BaseChannel<number, string>\n * ```\n */\nexport type StateSchemaFieldToChannel<F> =\n F extends ReducedValue<infer V, infer I>\n ? BaseChannel<V, OverwriteValue<V> | I>\n : F extends UntrackedValue<infer V>\n ? BaseChannel<V, V>\n : F extends SerializableSchema<infer I, infer O>\n ? BaseChannel<O, I>\n : BaseChannel<unknown, unknown>;\n\n/**\n * Converts StateSchema fields into a strongly-typed\n * State Definition object, where each field is mapped to its channel type.\n *\n * This utility type is used internally to create the shape of the state channels for a given schema,\n * substituting each field with the result of `StateSchemaFieldToChannel`.\n *\n * If you define a state schema as:\n * ```typescript\n * const fields = {\n * a: ReducedValue<number, string>(),\n * b: UntrackedValue<boolean>(),\n * c: SomeSerializableSchemaType, // SerializableSchema<in, out>\n * }\n * ```\n * then `StateSchemaFieldsToStateDefinition<typeof fields>` yields:\n * ```typescript\n * {\n * a: BaseChannel<number, string>;\n * b: BaseChannel<boolean, boolean>;\n * c: BaseChannel<typeof schema's output type, typeof schema's input type>;\n * }\n * ```\n *\n * @template TFields - The mapping of field names to StateSchema field types.\n * @returns An object type mapping field names to channel types.\n *\n * @see StateSchemaFieldToChannel\n */\nexport type StateSchemaFieldsToStateDefinition<\n TFields extends StateSchemaFields,\n> = {\n [K in keyof TFields]: StateSchemaFieldToChannel<TFields[K]>;\n};\n\n/**\n * Valid field types for StateSchema.\n * Either a LangGraph state value type or a raw schema (e.g., Zod schema).\n */\nexport type StateSchemaField<Input = unknown, Output = Input> =\n | ReducedValue<Input, Output>\n | UntrackedValue<Output>\n | SerializableSchema<Input, Output>;\n\n/**\n * Init object for StateSchema constructor.\n * Uses `any` to allow variance in generic types (e.g., ReducedValue<string, string[]>).\n */\nexport type StateSchemaFields = {\n [key: string]: StateSchemaField<any, any>;\n};\n\n/**\n * Infer the State type from a StateSchemaFields.\n * This is the type of the full state object.\n *\n * - ReducedValue<Value, Input> → Value (the stored type)\n * - UntrackedValue<Value> → Value\n * - SerializableSchema<Input, Output> → Output (the validated type)\n */\nexport type InferStateSchemaValue<TFields extends StateSchemaFields> = {\n [K in keyof TFields]: TFields[K] extends ReducedValue<any, any>\n ? TFields[K][\"ValueType\"]\n : TFields[K] extends UntrackedValue<any>\n ? TFields[K][\"ValueType\"]\n : TFields[K] extends SerializableSchema<any, infer TOutput>\n ? TOutput\n : never;\n};\n\n/**\n * Infer the Update type from a StateSchemaFields.\n * This is the type for partial updates to state.\n *\n * - ReducedValue<Value, Input> → Input (the reducer input type)\n * - UntrackedValue<Value> → Value\n * - SerializableSchema<Input, Output> → Input (what you provide)\n */\nexport type InferStateSchemaUpdate<TFields extends StateSchemaFields> = {\n [K in keyof TFields]?: TFields[K] extends ReducedValue<infer V, infer I>\n ? OverwriteValue<V> | I\n : TFields[K] extends UntrackedValue<any>\n ? TFields[K][\"ValueType\"]\n : TFields[K] extends SerializableSchema<infer TInput, any>\n ? TInput\n : never;\n};\n\n/**\n * StateSchema provides a unified API for defining LangGraph state schemas.\n *\n * @example\n * ```ts\n * import { z } from \"zod\";\n * import { StateSchema, ReducedValue, MessagesValue } from \"@langchain/langgraph\";\n *\n * const AgentState = new StateSchema({\n * // Prebuilt messages value\n * messages: MessagesValue,\n * // Basic LastValue channel from any standard schema\n * currentStep: z.string(),\n * // LastValue with native default\n * count: z.number().default(0),\n * // ReducedValue for fields needing reducers\n * history: new ReducedValue(\n * z.array(z.string()).default(() => []),\n * {\n * inputSchema: z.string(),\n * reducer: (current, next) => [...current, next],\n * }\n * ),\n * });\n *\n * // Extract types\n * type State = typeof AgentState.State;\n * type Update = typeof AgentState.Update;\n *\n * // Use in StateGraph\n * const graph = new StateGraph(AgentState);\n * ```\n */\nexport class StateSchema<TFields extends StateSchemaFields> {\n /**\n * Symbol for runtime identification.\n * @internal Used by isInstance for runtime type checking\n */\n // @ts-expect-error - Symbol is read via `in` operator in isInstance\n private readonly [STATE_SCHEMA_SYMBOL] = true;\n\n /**\n * Type declaration for the full state type.\n * Use: `typeof myState.State`\n */\n declare State: InferStateSchemaValue<TFields>;\n\n /**\n * Type declaration for the update type.\n * Use: `typeof myState.Update`\n */\n declare Update: InferStateSchemaUpdate<TFields>;\n\n /**\n * Type declaration for node functions.\n * Use: `typeof myState.Node` to type node functions outside the graph builder.\n *\n * @example\n * ```typescript\n * const AgentState = new StateSchema({\n * count: z.number().default(0),\n * });\n *\n * const myNode: typeof AgentState.Node = (state) => {\n * return { count: state.count + 1 };\n * };\n * ```\n */\n declare Node: RunnableLike<\n InferStateSchemaValue<TFields>,\n InferStateSchemaUpdate<TFields>\n >;\n\n constructor(readonly fields: TFields) {}\n\n /**\n * Get the channel definitions for use with StateGraph.\n * This converts the StateSchema fields into BaseChannel instances.\n */\n getChannels(): Record<string, BaseChannel> {\n const channels: Record<string, BaseChannel> = {};\n\n for (const [key, value] of Object.entries(this.fields)) {\n if (ReducedValue.isInstance(value)) {\n // ReducedValue -> BinaryOperatorAggregate\n const defaultGetter = getSchemaDefaultGetter(value.valueSchema);\n channels[key] = new BinaryOperatorAggregate(\n value.reducer,\n defaultGetter\n );\n } else if (UntrackedValue.isInstance(value)) {\n // UntrackedValue -> UntrackedValueChannel\n const defaultGetter = value.schema\n ? getSchemaDefaultGetter(value.schema)\n : undefined;\n channels[key] = new UntrackedValueChannel({\n guard: value.guard,\n initialValueFactory: defaultGetter,\n });\n } else if (isStandardSchema(value)) {\n // Plain schema -> LastValue channel\n const defaultGetter = getSchemaDefaultGetter(value);\n channels[key] = new LastValue(defaultGetter);\n } else {\n throw new Error(\n `Invalid state field \"${key}\": must be a schema, ReducedValue, UntrackedValue, or ManagedValue`\n );\n }\n }\n\n return channels;\n }\n\n /**\n * Get the JSON schema for the full state type.\n * Used by Studio and API for schema introspection.\n */\n getJsonSchema(): JSONSchema {\n const properties: Record<string, JSONSchema> = {};\n const required: string[] = [];\n\n for (const [key, value] of Object.entries(this.fields)) {\n let fieldSchema: JSONSchema | undefined;\n\n if (ReducedValue.isInstance(value)) {\n fieldSchema = getJsonSchemaFromSchema(value.valueSchema) as JSONSchema;\n // Merge jsonSchemaExtra (e.g. langgraph_type) into the field schema,\n // even if base schema is undefined\n if (value.jsonSchemaExtra) {\n fieldSchema = { ...(fieldSchema ?? {}), ...value.jsonSchemaExtra };\n }\n } else if (UntrackedValue.isInstance(value)) {\n fieldSchema = value.schema\n ? (getJsonSchemaFromSchema(value.schema) as JSONSchema)\n : undefined;\n } else if (isStandardSchema(value)) {\n fieldSchema = getJsonSchemaFromSchema(value) as JSONSchema;\n }\n\n if (fieldSchema) {\n properties[key] = fieldSchema;\n\n // Field is required if it doesn't have a default\n let hasDefault = false;\n if (ReducedValue.isInstance(value)) {\n hasDefault = getSchemaDefaultGetter(value.valueSchema) !== undefined;\n } else if (UntrackedValue.isInstance(value)) {\n hasDefault = value.schema\n ? getSchemaDefaultGetter(value.schema) !== undefined\n : false;\n } else {\n hasDefault = getSchemaDefaultGetter(value) !== undefined;\n }\n\n if (!hasDefault) {\n required.push(key);\n }\n }\n }\n\n return {\n type: \"object\",\n properties,\n required: required.length > 0 ? required : undefined,\n };\n }\n\n /**\n * Get the JSON schema for the update/input type.\n * All fields are optional in updates.\n */\n getInputJsonSchema(): JSONSchema {\n const properties: Record<string, JSONSchema> = {};\n\n for (const [key, value] of Object.entries(this.fields)) {\n let fieldSchema: JSONSchema | undefined;\n\n if (ReducedValue.isInstance(value)) {\n // Use input schema for updates\n fieldSchema = getJsonSchemaFromSchema(value.inputSchema) as JSONSchema;\n // Merge jsonSchemaExtra (e.g. langgraph_type) into the field schema,\n // even if base schema is undefined\n if (value.jsonSchemaExtra) {\n fieldSchema = { ...(fieldSchema ?? {}), ...value.jsonSchemaExtra };\n }\n } else if (UntrackedValue.isInstance(value)) {\n fieldSchema = value.schema\n ? (getJsonSchemaFromSchema(value.schema) as JSONSchema)\n : undefined;\n } else if (isStandardSchema(value)) {\n fieldSchema = getJsonSchemaFromSchema(value) as JSONSchema;\n }\n\n if (fieldSchema) {\n properties[key] = fieldSchema;\n }\n }\n\n return {\n type: \"object\",\n properties,\n };\n }\n\n /**\n * Get the list of channel keys (excluding managed values).\n */\n getChannelKeys(): string[] {\n return Object.entries(this.fields).map(([key]) => key);\n }\n\n /**\n * Get all keys (channels + managed values).\n */\n getAllKeys(): string[] {\n return Object.keys(this.fields);\n }\n\n /**\n * Validate input data against the schema.\n * This validates each field using its corresponding schema.\n *\n * @param data - The input data to validate\n * @returns The validated data with coerced types\n */\n async validateInput<T>(data: T): Promise<T> {\n if (data == null || typeof data !== \"object\") {\n return data;\n }\n\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(data)) {\n const fieldDef = this.fields[key];\n\n if (fieldDef === undefined) {\n // Unknown field, pass through\n result[key] = value;\n continue;\n }\n\n // Get the schema to use for validation\n let schema: StandardSchemaV1 | undefined;\n\n if (ReducedValue.isInstance(fieldDef)) {\n schema = fieldDef.inputSchema;\n } else if (UntrackedValue.isInstance(fieldDef)) {\n schema = fieldDef.schema;\n } else if (isStandardSchema(fieldDef)) {\n schema = fieldDef;\n }\n\n if (schema) {\n // Validate using standard schema\n const validationResult = await schema[\"~standard\"].validate(value);\n if (validationResult.issues) {\n throw new Error(\n `Validation failed for field \"${key}\": ${JSON.stringify(\n validationResult.issues\n )}`\n );\n }\n result[key] = validationResult.value;\n } else {\n // No schema or not a standard schema, pass through\n result[key] = value;\n }\n }\n\n return result as T;\n }\n\n /**\n * Type guard to check if a value is a StateSchema instance.\n *\n * @param value - The value to check.\n * @returns True if the value is a StateSchema instance with the correct runtime tag.\n */\n static isInstance<TFields extends StateSchemaFields>(\n value: StateSchema<TFields>\n ): value is StateSchema<TFields>;\n\n static isInstance(value: unknown): value is StateSchema<any>;\n\n static isInstance<TFields extends StateSchemaFields>(\n value: unknown\n ): value is StateSchema<TFields> {\n return (\n typeof value === \"object\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OAAO;AAE7B,OAAI,aAAa,KAAA,GAAW;AAE1B,WAAO,OAAO;AACd;;GAIF,IAAI;AAEJ,OAAI,aAAa,WAAW,SAAS,CACnC,UAAS,SAAS;YACT,eAAe,WAAW,SAAS,CAC5C,UAAS,SAAS;YACT,iBAAiB,SAAS,CACnC,UAAS;AAGX,OAAI,QAAQ;IAEV,MAAM,mBAAmB,MAAM,OAAO,aAAa,SAAS,MAAM;AAClE,QAAI,iBAAiB,OACnB,OAAM,IAAI,MACR,gCAAgC,IAAI,KAAK,KAAK,UAC5C,iBAAiB,OAClB,GACF;AAEH,WAAO,OAAO,iBAAiB;SAG/B,QAAO,OAAO;;AAIlB,SAAO;;CAeT,OAAO,WACL,OAC+B;AAC/B,SACE,OAAO,UAAU,YACjB,UAAU,QACV,uBAAuB,SACvB,MAAM,yBAAyB"}
1
+ {"version":3,"file":"schema.js","names":[],"sources":["../../src/state/schema.ts"],"sourcesContent":["/* eslint-disable @typescript-eslint/no-explicit-any */\nimport type { JSONSchema } from \"@langchain/core/utils/json_schema\";\nimport type { StandardSchemaV1 } from \"@standard-schema/spec\";\n\nimport type { RunnableLike } from \"../pregel/runnable_types.js\";\nimport {\n BaseChannel,\n LastValue,\n BinaryOperatorAggregate,\n} from \"../channels/index.js\";\nimport { UntrackedValueChannel } from \"../channels/untracked_value.js\";\n\nimport type { SerializableSchema } from \"./types.js\";\nimport { isStandardSchema } from \"./types.js\";\nimport { getJsonSchemaFromSchema, getSchemaDefaultGetter } from \"./adapter.js\";\nimport {\n _getOverwriteValue,\n OVERWRITE,\n type OverwriteValue,\n} from \"../constants.js\";\nimport { ReducedValue } from \"./values/reduced.js\";\nimport { UntrackedValue } from \"./values/untracked.js\";\n\nconst STATE_SCHEMA_SYMBOL = Symbol.for(\"langgraph.state.state_schema\");\n\n/**\n * Maps a single StateSchema field definition to its corresponding Channel type.\n *\n * This utility type inspects the type of the field and returns an appropriate\n * `BaseChannel` type, parameterized with the state \"value\" and \"input\" types according to the field's shape.\n *\n * Rules:\n * - If the field (`F`) is a `ReducedValue<V, I>`, the channel will store values of type `V`\n * and accept input of type `I`.\n * - If the field is a `UntrackedValue<V>`, the channel will store and accept values of type `V`.\n * - If the field is a `SerializableSchema<I, O>`, the channel will store values of type `O`\n * (the schema's output/validated value) and accept input of type `I`.\n * - For all other types, a generic `BaseChannel<unknown, unknown>` is used as fallback.\n *\n * @template F - The StateSchema field type to map to a Channel type.\n *\n * @example\n * ```typescript\n * type MyField = ReducedValue<number, string>;\n * type ChannelType = StateSchemaFieldToChannel<MyField>;\n * // ChannelType is BaseChannel<number, string>\n * ```\n */\nexport type StateSchemaFieldToChannel<F> =\n F extends ReducedValue<infer V, infer I>\n ? BaseChannel<V, OverwriteValue<V> | I>\n : F extends UntrackedValue<infer V>\n ? BaseChannel<V, V>\n : F extends SerializableSchema<infer I, infer O>\n ? BaseChannel<O, I>\n : BaseChannel<unknown, unknown>;\n\n/**\n * Converts StateSchema fields into a strongly-typed\n * State Definition object, where each field is mapped to its channel type.\n *\n * This utility type is used internally to create the shape of the state channels for a given schema,\n * substituting each field with the result of `StateSchemaFieldToChannel`.\n *\n * If you define a state schema as:\n * ```typescript\n * const fields = {\n * a: ReducedValue<number, string>(),\n * b: UntrackedValue<boolean>(),\n * c: SomeSerializableSchemaType, // SerializableSchema<in, out>\n * }\n * ```\n * then `StateSchemaFieldsToStateDefinition<typeof fields>` yields:\n * ```typescript\n * {\n * a: BaseChannel<number, string>;\n * b: BaseChannel<boolean, boolean>;\n * c: BaseChannel<typeof schema's output type, typeof schema's input type>;\n * }\n * ```\n *\n * @template TFields - The mapping of field names to StateSchema field types.\n * @returns An object type mapping field names to channel types.\n *\n * @see StateSchemaFieldToChannel\n */\nexport type StateSchemaFieldsToStateDefinition<\n TFields extends StateSchemaFields,\n> = {\n [K in keyof TFields]: StateSchemaFieldToChannel<TFields[K]>;\n};\n\n/**\n * Valid field types for StateSchema.\n * Either a LangGraph state value type or a raw schema (e.g., Zod schema).\n */\nexport type StateSchemaField<Input = unknown, Output = Input> =\n | ReducedValue<Input, Output>\n | UntrackedValue<Output>\n | SerializableSchema<Input, Output>;\n\n/**\n * Init object for StateSchema constructor.\n * Uses `any` to allow variance in generic types (e.g., ReducedValue<string, string[]>).\n */\nexport type StateSchemaFields = {\n [key: string]: StateSchemaField<any, any>;\n};\n\n/**\n * Infer the State type from a StateSchemaFields.\n * This is the type of the full state object.\n *\n * - ReducedValue<Value, Input> → Value (the stored type)\n * - UntrackedValue<Value> → Value\n * - SerializableSchema<Input, Output> → Output (the validated type)\n */\nexport type InferStateSchemaValue<TFields extends StateSchemaFields> = {\n [K in keyof TFields]: TFields[K] extends ReducedValue<any, any>\n ? TFields[K][\"ValueType\"]\n : TFields[K] extends UntrackedValue<any>\n ? TFields[K][\"ValueType\"]\n : TFields[K] extends SerializableSchema<any, infer TOutput>\n ? TOutput\n : never;\n};\n\n/**\n * Infer the Update type from a StateSchemaFields.\n * This is the type for partial updates to state.\n *\n * - ReducedValue<Value, Input> → Input (the reducer input type)\n * - UntrackedValue<Value> → Value\n * - SerializableSchema<Input, Output> → Input (what you provide)\n */\nexport type InferStateSchemaUpdate<TFields extends StateSchemaFields> = {\n [K in keyof TFields]?: TFields[K] extends ReducedValue<infer V, infer I>\n ? OverwriteValue<V> | I\n : TFields[K] extends UntrackedValue<any>\n ? TFields[K][\"ValueType\"]\n : TFields[K] extends SerializableSchema<infer TInput, any>\n ? TInput\n : never;\n};\n\n/**\n * StateSchema provides a unified API for defining LangGraph state schemas.\n *\n * @example\n * ```ts\n * import { z } from \"zod\";\n * import { StateSchema, ReducedValue, MessagesValue } from \"@langchain/langgraph\";\n *\n * const AgentState = new StateSchema({\n * // Prebuilt messages value\n * messages: MessagesValue,\n * // Basic LastValue channel from any standard schema\n * currentStep: z.string(),\n * // LastValue with native default\n * count: z.number().default(0),\n * // ReducedValue for fields needing reducers\n * history: new ReducedValue(\n * z.array(z.string()).default(() => []),\n * {\n * inputSchema: z.string(),\n * reducer: (current, next) => [...current, next],\n * }\n * ),\n * });\n *\n * // Extract types\n * type State = typeof AgentState.State;\n * type Update = typeof AgentState.Update;\n *\n * // Use in StateGraph\n * const graph = new StateGraph(AgentState);\n * ```\n */\nexport class StateSchema<TFields extends StateSchemaFields> {\n /**\n * Symbol for runtime identification.\n * @internal Used by isInstance for runtime type checking\n */\n // @ts-expect-error - Symbol is read via `in` operator in isInstance\n private readonly [STATE_SCHEMA_SYMBOL] = true;\n\n /**\n * Type declaration for the full state type.\n * Use: `typeof myState.State`\n */\n declare State: InferStateSchemaValue<TFields>;\n\n /**\n * Type declaration for the update type.\n * Use: `typeof myState.Update`\n */\n declare Update: InferStateSchemaUpdate<TFields>;\n\n /**\n * Type declaration for node functions.\n * Use: `typeof myState.Node` to type node functions outside the graph builder.\n *\n * @example\n * ```typescript\n * const AgentState = new StateSchema({\n * count: z.number().default(0),\n * });\n *\n * const myNode: typeof AgentState.Node = (state) => {\n * return { count: state.count + 1 };\n * };\n * ```\n */\n declare Node: RunnableLike<\n InferStateSchemaValue<TFields>,\n InferStateSchemaUpdate<TFields>\n >;\n\n constructor(readonly fields: TFields) {}\n\n /**\n * Get the channel definitions for use with StateGraph.\n * This converts the StateSchema fields into BaseChannel instances.\n */\n getChannels(): Record<string, BaseChannel> {\n const channels: Record<string, BaseChannel> = {};\n\n for (const [key, value] of Object.entries(this.fields)) {\n if (ReducedValue.isInstance(value)) {\n // ReducedValue -> BinaryOperatorAggregate\n const defaultGetter = getSchemaDefaultGetter(value.valueSchema);\n channels[key] = new BinaryOperatorAggregate(\n value.reducer,\n defaultGetter\n );\n } else if (UntrackedValue.isInstance(value)) {\n // UntrackedValue -> UntrackedValueChannel\n const defaultGetter = value.schema\n ? getSchemaDefaultGetter(value.schema)\n : undefined;\n channels[key] = new UntrackedValueChannel({\n guard: value.guard,\n initialValueFactory: defaultGetter,\n });\n } else if (isStandardSchema(value)) {\n // Plain schema -> LastValue channel\n const defaultGetter = getSchemaDefaultGetter(value);\n channels[key] = new LastValue(defaultGetter);\n } else {\n throw new Error(\n `Invalid state field \"${key}\": must be a schema, ReducedValue, UntrackedValue, or ManagedValue`\n );\n }\n }\n\n return channels;\n }\n\n /**\n * Get the JSON schema for the full state type.\n * Used by Studio and API for schema introspection.\n */\n getJsonSchema(): JSONSchema {\n const properties: Record<string, JSONSchema> = {};\n const required: string[] = [];\n\n for (const [key, value] of Object.entries(this.fields)) {\n let fieldSchema: JSONSchema | undefined;\n\n if (ReducedValue.isInstance(value)) {\n fieldSchema = getJsonSchemaFromSchema(value.valueSchema) as JSONSchema;\n // Merge jsonSchemaExtra (e.g. langgraph_type) into the field schema,\n // even if base schema is undefined\n if (value.jsonSchemaExtra) {\n fieldSchema = { ...(fieldSchema ?? {}), ...value.jsonSchemaExtra };\n }\n } else if (UntrackedValue.isInstance(value)) {\n fieldSchema = value.schema\n ? (getJsonSchemaFromSchema(value.schema) as JSONSchema)\n : undefined;\n } else if (isStandardSchema(value)) {\n fieldSchema = getJsonSchemaFromSchema(value) as JSONSchema;\n }\n\n if (fieldSchema) {\n properties[key] = fieldSchema;\n\n // Field is required if it doesn't have a default\n let hasDefault = false;\n if (ReducedValue.isInstance(value)) {\n hasDefault = getSchemaDefaultGetter(value.valueSchema) !== undefined;\n } else if (UntrackedValue.isInstance(value)) {\n hasDefault = value.schema\n ? getSchemaDefaultGetter(value.schema) !== undefined\n : false;\n } else {\n hasDefault = getSchemaDefaultGetter(value) !== undefined;\n }\n\n if (!hasDefault) {\n required.push(key);\n }\n }\n }\n\n return {\n type: \"object\",\n properties,\n required: required.length > 0 ? required : undefined,\n };\n }\n\n /**\n * Get the JSON schema for the update/input type.\n * All fields are optional in updates.\n */\n getInputJsonSchema(): JSONSchema {\n const properties: Record<string, JSONSchema> = {};\n\n for (const [key, value] of Object.entries(this.fields)) {\n let fieldSchema: JSONSchema | undefined;\n\n if (ReducedValue.isInstance(value)) {\n // Use input schema for updates\n fieldSchema = getJsonSchemaFromSchema(value.inputSchema) as JSONSchema;\n // Merge jsonSchemaExtra (e.g. langgraph_type) into the field schema,\n // even if base schema is undefined\n if (value.jsonSchemaExtra) {\n fieldSchema = { ...(fieldSchema ?? {}), ...value.jsonSchemaExtra };\n }\n } else if (UntrackedValue.isInstance(value)) {\n fieldSchema = value.schema\n ? (getJsonSchemaFromSchema(value.schema) as JSONSchema)\n : undefined;\n } else if (isStandardSchema(value)) {\n fieldSchema = getJsonSchemaFromSchema(value) as JSONSchema;\n }\n\n if (fieldSchema) {\n properties[key] = fieldSchema;\n }\n }\n\n return {\n type: \"object\",\n properties,\n };\n }\n\n /**\n * Get the list of channel keys (excluding managed values).\n */\n getChannelKeys(): string[] {\n return Object.entries(this.fields).map(([key]) => key);\n }\n\n /**\n * Get all keys (channels + managed values).\n */\n getAllKeys(): string[] {\n return Object.keys(this.fields);\n }\n\n /**\n * Validate input data against the schema.\n * This validates each field using its corresponding schema.\n *\n * @param data - The input data to validate\n * @returns The validated data with coerced types\n */\n async validateInput<T>(data: T): Promise<T> {\n if (data == null || typeof data !== \"object\") {\n return data;\n }\n\n const result: Record<string, unknown> = {};\n\n for (const [key, value] of Object.entries(data)) {\n const fieldDef = this.fields[key];\n\n if (fieldDef === undefined) {\n // Unknown field, pass through\n result[key] = value;\n continue;\n }\n\n // Get the schema to use for validation\n let schema: StandardSchemaV1 | undefined;\n\n if (ReducedValue.isInstance(fieldDef)) {\n const [isOverwrite, overwriteValue] = _getOverwriteValue(value);\n if (isOverwrite) {\n schema = fieldDef.valueSchema;\n const validationResult =\n await schema[\"~standard\"].validate(overwriteValue);\n if (validationResult.issues) {\n throw new Error(\n `Validation failed for field \"${key}\": ${JSON.stringify(\n validationResult.issues\n )}`\n );\n }\n result[key] = { [OVERWRITE]: validationResult.value };\n continue;\n }\n\n schema = fieldDef.inputSchema;\n } else if (UntrackedValue.isInstance(fieldDef)) {\n schema = fieldDef.schema;\n } else if (isStandardSchema(fieldDef)) {\n schema = fieldDef;\n }\n\n if (schema) {\n // Validate using standard schema\n const validationResult = await schema[\"~standard\"].validate(value);\n if (validationResult.issues) {\n throw new Error(\n `Validation failed for field \"${key}\": ${JSON.stringify(\n validationResult.issues\n )}`\n );\n }\n result[key] = validationResult.value;\n } else {\n // No schema or not a standard schema, pass through\n result[key] = value;\n }\n }\n\n return result as T;\n }\n\n /**\n * Type guard to check if a value is a StateSchema instance.\n *\n * @param value - The value to check.\n * @returns True if the value is a StateSchema instance with the correct runtime tag.\n */\n static isInstance<TFields extends StateSchemaFields>(\n value: StateSchema<TFields>\n ): value is StateSchema<TFields>;\n\n static isInstance(value: unknown): value is StateSchema<any>;\n\n static isInstance<TFields extends StateSchemaFields>(\n value: unknown\n ): value is StateSchema<TFields> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n STATE_SCHEMA_SYMBOL in value &&\n value[STATE_SCHEMA_SYMBOL] === true\n );\n }\n}\n\nexport type AnyStateSchema = StateSchema<any>;\n"],"mappings":";;;;;;;;;;AAuBA,MAAM,sBAAsB,OAAO,IAAI,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2JtE,IAAa,cAAb,MAA4D;;;;;CAM1D,CAAkB,uBAAuB;CAkCzC,YAAY,QAA0B;AAAjB,OAAA,SAAA;;;;;;CAMrB,cAA2C;EACzC,MAAM,WAAwC,EAAE;AAEhD,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,OAAO,CACpD,KAAI,aAAa,WAAW,MAAM,EAAE;GAElC,MAAM,gBAAgB,uBAAuB,MAAM,YAAY;AAC/D,YAAS,OAAO,IAAI,wBAClB,MAAM,SACN,cACD;aACQ,eAAe,WAAW,MAAM,EAAE;GAE3C,MAAM,gBAAgB,MAAM,SACxB,uBAAuB,MAAM,OAAO,GACpC,KAAA;AACJ,YAAS,OAAO,IAAI,sBAAsB;IACxC,OAAO,MAAM;IACb,qBAAqB;IACtB,CAAC;aACO,iBAAiB,MAAM,CAGhC,UAAS,OAAO,IAAI,UADE,uBAAuB,MAAM,CACP;MAE5C,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AAM,yBAAyB"}
package/dist/web.cjs CHANGED
@@ -5,6 +5,7 @@ const require_base = require("./channels/base.cjs");
5
5
  const require_binop = require("./channels/binop.cjs");
6
6
  const require_annotation = require("./graph/annotation.cjs");
7
7
  const require_config = require("./pregel/utils/config.cjs");
8
+ const require_runtime = require("./pregel/runtime.cjs");
8
9
  const require_convert = require("./stream/convert.cjs");
9
10
  const require_stream_channel = require("./stream/stream-channel.cjs");
10
11
  const require_lifecycle = require("./stream/transformers/lifecycle.cjs");
@@ -18,6 +19,7 @@ const require_interrupt = require("./interrupt.cjs");
18
19
  const require_graph = require("./graph/graph.cjs");
19
20
  const require_types$1 = require("./state/types.cjs");
20
21
  const require_adapter = require("./state/adapter.cjs");
22
+ const require_delta = require("./channels/delta.cjs");
21
23
  const require_untracked_value = require("./channels/untracked_value.cjs");
22
24
  require("./channels/index.cjs");
23
25
  const require_reduced = require("./state/values/reduced.cjs");
@@ -66,12 +68,14 @@ Object.defineProperty(exports, "ChatModelStreamImpl", {
66
68
  exports.Command = require_constants.Command;
67
69
  exports.CommandInstance = require_constants.CommandInstance;
68
70
  exports.CompiledStateGraph = require_state.CompiledStateGraph;
71
+ exports.DeltaChannel = require_delta.DeltaChannel;
69
72
  exports.END = require_constants.END;
70
73
  exports.EmptyChannelError = require_errors.EmptyChannelError;
71
74
  exports.EmptyInputError = require_errors.EmptyInputError;
72
75
  exports.EventLog = require_stream_channel.StreamChannel;
73
76
  exports.Graph = require_graph.Graph;
74
77
  exports.GraphBubbleUp = require_errors.GraphBubbleUp;
78
+ exports.GraphDrained = require_errors.GraphDrained;
75
79
  exports.GraphInterrupt = require_errors.GraphInterrupt;
76
80
  exports.GraphRecursionError = require_errors.GraphRecursionError;
77
81
  exports.GraphRunStream = require_run_stream.GraphRunStream;
@@ -96,12 +100,15 @@ exports.MessagesValue = require_messages$1.MessagesValue;
96
100
  exports.MessagesZodMeta = require_messages_annotation.MessagesZodMeta;
97
101
  exports.MessagesZodState = require_messages_annotation.MessagesZodState;
98
102
  exports.MultipleSubgraphsError = require_errors.MultipleSubgraphsError;
103
+ exports.NodeError = require_errors.NodeError;
99
104
  exports.NodeInterrupt = require_errors.NodeInterrupt;
105
+ exports.NodeTimeoutError = require_errors.NodeTimeoutError;
100
106
  exports.Overwrite = require_constants.Overwrite;
101
107
  exports.ParentCommand = require_errors.ParentCommand;
102
108
  exports.REMOVE_ALL_MESSAGES = require_messages_reducer.REMOVE_ALL_MESSAGES;
103
109
  exports.ReducedValue = require_reduced.ReducedValue;
104
110
  exports.RemoteException = require_errors.RemoteException;
111
+ exports.RunControl = require_runtime.RunControl;
105
112
  exports.START = require_constants.START;
106
113
  exports.STREAM_EVENTS_V3_MODES = require_convert.STREAM_EVENTS_V3_MODES;
107
114
  exports.Send = require_constants.Send;
@@ -147,12 +154,16 @@ exports.interrupt = require_interrupt.interrupt;
147
154
  exports.isCheckpointEnvelope = require_convert.isCheckpointEnvelope;
148
155
  exports.isCommand = require_constants.isCommand;
149
156
  exports.isGraphBubbleUp = require_errors.isGraphBubbleUp;
157
+ exports.isGraphDrained = require_errors.isGraphDrained;
150
158
  exports.isGraphInterrupt = require_errors.isGraphInterrupt;
151
159
  exports.isInterrupted = require_constants.isInterrupted;
152
160
  exports.isNativeTransformer = require_types.isNativeTransformer;
161
+ exports.isNodeError = require_errors.isNodeError;
162
+ exports.isNodeTimeoutError = require_errors.isNodeTimeoutError;
153
163
  exports.isParentCommand = require_errors.isParentCommand;
154
164
  exports.isSerializableSchema = require_types$1.isSerializableSchema;
155
165
  exports.isStandardSchema = require_types$1.isStandardSchema;
166
+ exports.messagesDeltaReducer = require_messages_reducer.messagesDeltaReducer;
156
167
  exports.messagesStateReducer = require_messages_reducer.messagesStateReducer;
157
168
  exports.pushMessage = require_message.pushMessage;
158
169
  exports.task = require_index$3.task;
package/dist/web.d.cts CHANGED
@@ -1,5 +1,7 @@
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
+ import { TimeoutPolicy } from "./pregel/utils/timeout.cjs";
3
+ import { COMMAND_SYMBOL, Command, CommandInstance, CommandParams, END, INTERRUPT, Interrupt, Overwrite, OverwriteValue, START, Send, SendOptions, isCommand, isInterrupted } from "./constants.cjs";
4
+ import { DeltaChannel, DeltaReducer } from "./channels/delta.cjs";
3
5
  import { BinaryOperator, BinaryOperatorAggregate } from "./channels/binop.cjs";
4
6
  import { AnyValue } from "./channels/any_value.cjs";
5
7
  import { LastValue } from "./channels/last_value.cjs";
@@ -8,6 +10,7 @@ import { EphemeralValue } from "./channels/ephemeral_value.cjs";
8
10
  import { NamedBarrierValue } from "./channels/named_barrier_value.cjs";
9
11
  import { Topic } from "./channels/topic.cjs";
10
12
  import { UntrackedValueChannel } from "./channels/untracked_value.cjs";
13
+ import { RunControl } from "./pregel/runtime.cjs";
11
14
  import { ExecutionInfo, LangGraphRunnableConfig, Runtime, ServerInfo } from "./pregel/runnable_types.cjs";
12
15
  import { Annotation, AnnotationRoot, NodeType, SingleReducer, StateDefinition, StateType, UpdateType } from "./graph/annotation.cjs";
13
16
  import { CachePolicy, RetryPolicy } from "./pregel/utils/index.cjs";
@@ -24,22 +27,22 @@ import { createValuesTransformer } from "./stream/transformers/values.cjs";
24
27
  import { CreateGraphRunStreamOptions, GraphRunStream, SubgraphRunStream, createGraphRunStream } from "./stream/run-stream.cjs";
25
28
  import { ChatModelStreamImpl } from "./stream/index.cjs";
26
29
  import { Pregel } from "./pregel/index.cjs";
27
- import { AddNodeOptions, CompiledGraph, CompiledGraphType, Graph, NodeSpec } from "./graph/graph.cjs";
28
- import { InferInterruptInputType, InferInterruptResumeType, interrupt } from "./interrupt.cjs";
29
- import { InferWriterType, writer } from "./writer.cjs";
30
+ import { BaseLangGraphError, BaseLangGraphErrorFields, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphDrained, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeError, NodeInterrupt, NodeTimeoutError, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isNodeError, isNodeTimeoutError, isParentCommand } from "./errors.cjs";
30
31
  import { isSerializableSchema, isStandardSchema } from "./state/types.cjs";
31
32
  import { ReducedValue, ReducedValueInit } from "./state/values/reduced.cjs";
32
33
  import { UntrackedValue, UntrackedValueInit } from "./state/values/untracked.cjs";
33
34
  import { AnyStateSchema, InferStateSchemaUpdate, InferStateSchemaValue, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition } from "./state/schema.cjs";
34
35
  import { ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, ExtractStateType, ExtractUpdateType, GraphNode, GraphNodeReturnValue, GraphNodeTypes, StateDefinitionInit, StateGraphInit, StateGraphOptions, ToStateDefinition } from "./graph/types.cjs";
35
- import { CompiledStateGraph, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphNodeSpec } from "./graph/state.cjs";
36
- import { Messages, REMOVE_ALL_MESSAGES, messagesStateReducer } from "./graph/messages_reducer.cjs";
36
+ import { AddNodeOptions, CompiledGraph, CompiledGraphType, Graph, NodeSpec } from "./graph/graph.cjs";
37
+ import { InferInterruptInputType, InferInterruptResumeType, interrupt } from "./interrupt.cjs";
38
+ import { InferWriterType, writer } from "./writer.cjs";
39
+ import { CompiledStateGraph, NodePolicyOptions, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphNodeSpec } from "./graph/state.cjs";
40
+ import { Messages, REMOVE_ALL_MESSAGES, messagesDeltaReducer, messagesStateReducer } from "./graph/messages_reducer.cjs";
37
41
  import { MessageGraph, pushMessage } from "./graph/message.cjs";
38
- import { BaseLangGraphError, BaseLangGraphErrorFields, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeInterrupt, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphInterrupt, isParentCommand } from "./errors.cjs";
39
42
  import { EntrypointOptions, TaskOptions, entrypoint, getPreviousState, task } from "./func/index.cjs";
40
43
  import { MessagesAnnotation, MessagesZodMeta, MessagesZodState } from "./graph/messages_annotation.cjs";
41
44
  import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter.cjs";
42
45
  import { MessagesValue } from "./state/prebuilt/messages.cjs";
43
46
  import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.cjs";
44
47
  import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, Checkpoint, CheckpointMetadata, CheckpointTuple, GetOperation, InMemoryStore, Item, ListNamespacesOperation, MatchCondition, MemorySaver, NameSpacePath, NamespaceMatchType, Operation, OperationResults, PutOperation, SearchOperation, copyCheckpoint, emptyCheckpoint } from "@langchain/langgraph-checkpoint";
45
- export { type AddNodeOptions, type AgentStatus, Annotation, type AnnotationRoot, AnyStateSchema, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, type CachePolicy, type ChatModelStream, ChatModelStreamImpl, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, CommandInstance, type CommandParams, type CompiledGraph, type CompiledGraphType, CompiledStateGraph, type ConditionalEdgeRouter, type ConditionalEdgeRouterTypes, type ContextSchemaInit, type ConvertToProtocolEventOptions, type CreateGraphRunStreamOptions, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, StreamChannel as EventLog, type ExecutionInfo, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, type GraphNode, type GraphNodeReturnValue, type GraphNodeTypes, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, type InferExtensions, type InferInterruptInputType, type InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, type InferWriterType, type Interrupt, type InterruptPayload, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type LifecycleCause, type LifecycleData, type LifecycleEntry, type LifecycleProjection, type LifecycleTransformerOptions, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, type MessagesEventData, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type Namespace, type NamespaceMatchType, type NativeStreamTransformer, NodeInterrupt, type NodeSpec, type NodeType, type Operation, type OperationResults, Overwrite, type OverwriteValue, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type ProtocolEvent, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, type Runtime, START, STREAM_EVENTS_V3_MODES, type SearchOperation, Send, type ServerInfo, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, type StateDefinitionInit, StateGraph, type StateGraphAddNodeOptions, type StateGraphArgs, type StateGraphArgsWithInputOutputSchemas, type StateGraphArgsWithStateSchema, type StateGraphInit, StateGraphInputError, type StateGraphNodeSpec, type StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, type StateSnapshot, type StateType, StreamChannel, type StreamEmitter, type StreamMode, type StreamOutputMap, type StreamTransformer, type SubgraphDiscoveryProjection, type SubgraphDiscoveryTransformerOptions, SubgraphRunStream, type TaskOptions, type ToStateDefinition, type ToolCallStatus, type ToolCallStream, type ToolsEventData, type Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type UpdatesEventData, type UsageInfo, type WaitForNames, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isNativeTransformer, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
48
+ export { type AddNodeOptions, type AgentStatus, Annotation, type AnnotationRoot, AnyStateSchema, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, type CachePolicy, type ChatModelStream, ChatModelStreamImpl, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, CommandInstance, type CommandParams, type CompiledGraph, type CompiledGraphType, CompiledStateGraph, type ConditionalEdgeRouter, type ConditionalEdgeRouterTypes, type ContextSchemaInit, type ConvertToProtocolEventOptions, type CreateGraphRunStreamOptions, DeltaChannel, type DeltaReducer, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, StreamChannel as EventLog, type ExecutionInfo, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphDrained, GraphInterrupt, type GraphNode, type GraphNodeReturnValue, type GraphNodeTypes, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, type InferExtensions, type InferInterruptInputType, type InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, type InferWriterType, type Interrupt, type InterruptPayload, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type LifecycleCause, type LifecycleData, type LifecycleEntry, type LifecycleProjection, type LifecycleTransformerOptions, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, type MessagesEventData, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type Namespace, type NamespaceMatchType, type NativeStreamTransformer, NodeError, NodeInterrupt, type NodePolicyOptions, type NodeSpec, NodeTimeoutError, type NodeType, type Operation, type OperationResults, Overwrite, type OverwriteValue, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type ProtocolEvent, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, RunControl, type Runtime, START, STREAM_EVENTS_V3_MODES, type SearchOperation, Send, type SendOptions, type ServerInfo, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, type StateDefinitionInit, StateGraph, type StateGraphAddNodeOptions, type StateGraphArgs, type StateGraphArgsWithInputOutputSchemas, type StateGraphArgsWithStateSchema, type StateGraphInit, StateGraphInputError, type StateGraphNodeSpec, type StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, type StateSnapshot, type StateType, StreamChannel, type StreamEmitter, type StreamMode, type StreamOutputMap, type StreamTransformer, type SubgraphDiscoveryProjection, type SubgraphDiscoveryTransformerOptions, SubgraphRunStream, type TaskOptions, type TimeoutPolicy, type ToStateDefinition, type ToolCallStatus, type ToolCallStream, type ToolsEventData, type Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type UpdatesEventData, type UsageInfo, type WaitForNames, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isInterrupted, isNativeTransformer, isNodeError, isNodeTimeoutError, isParentCommand, isSerializableSchema, isStandardSchema, messagesDeltaReducer, messagesStateReducer, pushMessage, task, writer };
package/dist/web.d.ts CHANGED
@@ -1,5 +1,7 @@
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
+ import { TimeoutPolicy } from "./pregel/utils/timeout.js";
3
+ import { COMMAND_SYMBOL, Command, CommandInstance, CommandParams, END, INTERRUPT, Interrupt, Overwrite, OverwriteValue, START, Send, SendOptions, isCommand, isInterrupted } from "./constants.js";
4
+ import { DeltaChannel, DeltaReducer } from "./channels/delta.js";
3
5
  import { BinaryOperator, BinaryOperatorAggregate } from "./channels/binop.js";
4
6
  import { AnyValue } from "./channels/any_value.js";
5
7
  import { LastValue } from "./channels/last_value.js";
@@ -8,6 +10,7 @@ import { EphemeralValue } from "./channels/ephemeral_value.js";
8
10
  import { NamedBarrierValue } from "./channels/named_barrier_value.js";
9
11
  import { Topic } from "./channels/topic.js";
10
12
  import { UntrackedValueChannel } from "./channels/untracked_value.js";
13
+ import { RunControl } from "./pregel/runtime.js";
11
14
  import { ExecutionInfo, LangGraphRunnableConfig, Runtime, ServerInfo } from "./pregel/runnable_types.js";
12
15
  import { Annotation, AnnotationRoot, NodeType, SingleReducer, StateDefinition, StateType, UpdateType } from "./graph/annotation.js";
13
16
  import { CachePolicy, RetryPolicy } from "./pregel/utils/index.js";
@@ -24,22 +27,22 @@ import { createValuesTransformer } from "./stream/transformers/values.js";
24
27
  import { CreateGraphRunStreamOptions, GraphRunStream, SubgraphRunStream, createGraphRunStream } from "./stream/run-stream.js";
25
28
  import { ChatModelStreamImpl } from "./stream/index.js";
26
29
  import { Pregel } from "./pregel/index.js";
27
- import { AddNodeOptions, CompiledGraph, CompiledGraphType, Graph, NodeSpec } from "./graph/graph.js";
28
- import { InferInterruptInputType, InferInterruptResumeType, interrupt } from "./interrupt.js";
29
- import { InferWriterType, writer } from "./writer.js";
30
+ import { BaseLangGraphError, BaseLangGraphErrorFields, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphDrained, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeError, NodeInterrupt, NodeTimeoutError, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isNodeError, isNodeTimeoutError, isParentCommand } from "./errors.js";
30
31
  import { isSerializableSchema, isStandardSchema } from "./state/types.js";
31
32
  import { ReducedValue, ReducedValueInit } from "./state/values/reduced.js";
32
33
  import { UntrackedValue, UntrackedValueInit } from "./state/values/untracked.js";
33
34
  import { AnyStateSchema, InferStateSchemaUpdate, InferStateSchemaValue, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition } from "./state/schema.js";
34
35
  import { ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, ExtractStateType, ExtractUpdateType, GraphNode, GraphNodeReturnValue, GraphNodeTypes, StateDefinitionInit, StateGraphInit, StateGraphOptions, ToStateDefinition } from "./graph/types.js";
35
- import { CompiledStateGraph, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphNodeSpec } from "./graph/state.js";
36
- import { Messages, REMOVE_ALL_MESSAGES, messagesStateReducer } from "./graph/messages_reducer.js";
36
+ import { AddNodeOptions, CompiledGraph, CompiledGraphType, Graph, NodeSpec } from "./graph/graph.js";
37
+ import { InferInterruptInputType, InferInterruptResumeType, interrupt } from "./interrupt.js";
38
+ import { InferWriterType, writer } from "./writer.js";
39
+ import { CompiledStateGraph, NodePolicyOptions, StateGraph, StateGraphAddNodeOptions, StateGraphArgs, StateGraphArgsWithInputOutputSchemas, StateGraphArgsWithStateSchema, StateGraphNodeSpec } from "./graph/state.js";
40
+ import { Messages, REMOVE_ALL_MESSAGES, messagesDeltaReducer, messagesStateReducer } from "./graph/messages_reducer.js";
37
41
  import { MessageGraph, pushMessage } from "./graph/message.js";
38
- import { BaseLangGraphError, BaseLangGraphErrorFields, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeInterrupt, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphInterrupt, isParentCommand } from "./errors.js";
39
42
  import { EntrypointOptions, TaskOptions, entrypoint, getPreviousState, task } from "./func/index.js";
40
43
  import { MessagesAnnotation, MessagesZodMeta, MessagesZodState } from "./graph/messages_annotation.js";
41
44
  import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter.js";
42
45
  import { MessagesValue } from "./state/prebuilt/messages.js";
43
46
  import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.js";
44
47
  import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, Checkpoint, CheckpointMetadata, CheckpointTuple, GetOperation, InMemoryStore, Item, ListNamespacesOperation, MatchCondition, MemorySaver, NameSpacePath, NamespaceMatchType, Operation, OperationResults, PutOperation, SearchOperation, copyCheckpoint, emptyCheckpoint } from "@langchain/langgraph-checkpoint";
45
- export { type AddNodeOptions, type AgentStatus, Annotation, type AnnotationRoot, AnyStateSchema, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, type CachePolicy, type ChatModelStream, ChatModelStreamImpl, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, CommandInstance, type CommandParams, type CompiledGraph, type CompiledGraphType, CompiledStateGraph, type ConditionalEdgeRouter, type ConditionalEdgeRouterTypes, type ContextSchemaInit, type ConvertToProtocolEventOptions, type CreateGraphRunStreamOptions, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, StreamChannel as EventLog, type ExecutionInfo, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, type GraphNode, type GraphNodeReturnValue, type GraphNodeTypes, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, type InferExtensions, type InferInterruptInputType, type InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, type InferWriterType, type Interrupt, type InterruptPayload, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type LifecycleCause, type LifecycleData, type LifecycleEntry, type LifecycleProjection, type LifecycleTransformerOptions, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, type MessagesEventData, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type Namespace, type NamespaceMatchType, type NativeStreamTransformer, NodeInterrupt, type NodeSpec, type NodeType, type Operation, type OperationResults, Overwrite, type OverwriteValue, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type ProtocolEvent, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, type Runtime, START, STREAM_EVENTS_V3_MODES, type SearchOperation, Send, type ServerInfo, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, type StateDefinitionInit, StateGraph, type StateGraphAddNodeOptions, type StateGraphArgs, type StateGraphArgsWithInputOutputSchemas, type StateGraphArgsWithStateSchema, type StateGraphInit, StateGraphInputError, type StateGraphNodeSpec, type StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, type StateSnapshot, type StateType, StreamChannel, type StreamEmitter, type StreamMode, type StreamOutputMap, type StreamTransformer, type SubgraphDiscoveryProjection, type SubgraphDiscoveryTransformerOptions, SubgraphRunStream, type TaskOptions, type ToStateDefinition, type ToolCallStatus, type ToolCallStream, type ToolsEventData, type Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type UpdatesEventData, type UsageInfo, type WaitForNames, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isNativeTransformer, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
48
+ export { type AddNodeOptions, type AgentStatus, Annotation, type AnnotationRoot, AnyStateSchema, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, COMMAND_SYMBOL, type CachePolicy, type ChatModelStream, ChatModelStreamImpl, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, CommandInstance, type CommandParams, type CompiledGraph, type CompiledGraphType, CompiledStateGraph, type ConditionalEdgeRouter, type ConditionalEdgeRouterTypes, type ContextSchemaInit, type ConvertToProtocolEventOptions, type CreateGraphRunStreamOptions, DeltaChannel, type DeltaReducer, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, StreamChannel as EventLog, type ExecutionInfo, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphDrained, GraphInterrupt, type GraphNode, type GraphNodeReturnValue, type GraphNodeTypes, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, type InferExtensions, type InferInterruptInputType, type InferInterruptResumeType, InferStateSchemaUpdate, InferStateSchemaValue, type InferWriterType, type Interrupt, type InterruptPayload, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type LifecycleCause, type LifecycleData, type LifecycleEntry, type LifecycleProjection, type LifecycleTransformerOptions, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, type MessagesEventData, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type Namespace, type NamespaceMatchType, type NativeStreamTransformer, NodeError, NodeInterrupt, type NodePolicyOptions, type NodeSpec, NodeTimeoutError, type NodeType, type Operation, type OperationResults, Overwrite, type OverwriteValue, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type ProtocolEvent, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, RunControl, type Runtime, START, STREAM_EVENTS_V3_MODES, type SearchOperation, Send, type SendOptions, type ServerInfo, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, type StateDefinitionInit, StateGraph, type StateGraphAddNodeOptions, type StateGraphArgs, type StateGraphArgsWithInputOutputSchemas, type StateGraphArgsWithStateSchema, type StateGraphInit, StateGraphInputError, type StateGraphNodeSpec, type StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFieldToChannel, StateSchemaFields, StateSchemaFieldsToStateDefinition, type StateSnapshot, type StateType, StreamChannel, type StreamEmitter, type StreamMode, type StreamOutputMap, type StreamTransformer, type SubgraphDiscoveryProjection, type SubgraphDiscoveryTransformerOptions, SubgraphRunStream, type TaskOptions, type TimeoutPolicy, type ToStateDefinition, type ToolCallStatus, type ToolCallStream, type ToolsEventData, type Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type UpdatesEventData, type UsageInfo, type WaitForNames, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isInterrupted, isNativeTransformer, isNodeError, isNodeTimeoutError, isParentCommand, isSerializableSchema, isStandardSchema, messagesDeltaReducer, messagesStateReducer, pushMessage, task, writer };
package/dist/web.js CHANGED
@@ -1,9 +1,10 @@
1
1
  import { COMMAND_SYMBOL, Command, CommandInstance, END, INTERRUPT, Overwrite, START, Send, isCommand, isInterrupted } from "./constants.js";
2
- import { BaseLangGraphError, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeInterrupt, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphInterrupt, isParentCommand } from "./errors.js";
2
+ import { BaseLangGraphError, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphDrained, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeError, NodeInterrupt, NodeTimeoutError, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isNodeError, isNodeTimeoutError, isParentCommand } from "./errors.js";
3
3
  import { BaseChannel } from "./channels/base.js";
4
4
  import { BinaryOperatorAggregate } from "./channels/binop.js";
5
5
  import { Annotation } from "./graph/annotation.js";
6
6
  import { getConfig, getCurrentTaskInput, getStore, getWriter } from "./pregel/utils/config.js";
7
+ import { RunControl } from "./pregel/runtime.js";
7
8
  import { STREAM_EVENTS_V3_MODES, convertToProtocolEvent, isCheckpointEnvelope } from "./stream/convert.js";
8
9
  import { StreamChannel } from "./stream/stream-channel.js";
9
10
  import { createLifecycleTransformer, filterLifecycleEntries } from "./stream/transformers/lifecycle.js";
@@ -17,12 +18,13 @@ import { interrupt } from "./interrupt.js";
17
18
  import { Graph } from "./graph/graph.js";
18
19
  import { isSerializableSchema, isStandardSchema } from "./state/types.js";
19
20
  import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter.js";
21
+ import { DeltaChannel } from "./channels/delta.js";
20
22
  import { UntrackedValueChannel } from "./channels/untracked_value.js";
21
23
  import "./channels/index.js";
22
24
  import { ReducedValue } from "./state/values/reduced.js";
23
25
  import { UntrackedValue } from "./state/values/untracked.js";
24
26
  import { StateSchema } from "./state/schema.js";
25
- import { REMOVE_ALL_MESSAGES, messagesStateReducer } from "./graph/messages_reducer.js";
27
+ import { REMOVE_ALL_MESSAGES, messagesDeltaReducer, messagesStateReducer } from "./graph/messages_reducer.js";
26
28
  import { MessagesValue } from "./state/prebuilt/messages.js";
27
29
  import "./state/index.js";
28
30
  import { CompiledStateGraph, StateGraph } from "./graph/state.js";
@@ -32,4 +34,4 @@ import { entrypoint, getPreviousState, task } from "./func/index.js";
32
34
  import { MessagesAnnotation, MessagesZodMeta, MessagesZodState } from "./graph/messages_annotation.js";
33
35
  import { writer } from "./writer.js";
34
36
  import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, InMemoryStore, MemorySaver, copyCheckpoint, emptyCheckpoint } from "@langchain/langgraph-checkpoint";
35
- export { Annotation, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseStore, BinaryOperatorAggregate, COMMAND_SYMBOL, ChatModelStreamImpl, Command, CommandInstance, CompiledStateGraph, END, EmptyChannelError, EmptyInputError, StreamChannel as EventLog, Graph, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, InvalidUpdateError, MemorySaver, MessageGraph, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleSubgraphsError, NodeInterrupt, Overwrite, ParentCommand, REMOVE_ALL_MESSAGES, ReducedValue, RemoteException, START, STREAM_EVENTS_V3_MODES, Send, StateGraph, StateGraphInputError, StateSchema, StreamChannel, SubgraphRunStream, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isNativeTransformer, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, pushMessage, task, writer };
37
+ export { Annotation, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseStore, BinaryOperatorAggregate, COMMAND_SYMBOL, ChatModelStreamImpl, Command, CommandInstance, CompiledStateGraph, DeltaChannel, END, EmptyChannelError, EmptyInputError, StreamChannel as EventLog, Graph, GraphBubbleUp, GraphDrained, GraphInterrupt, GraphRecursionError, GraphRunStream, GraphValueError, INTERRUPT, InMemoryStore, InvalidUpdateError, MemorySaver, MessageGraph, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, MultipleSubgraphsError, NodeError, NodeInterrupt, NodeTimeoutError, Overwrite, ParentCommand, REMOVE_ALL_MESSAGES, ReducedValue, RemoteException, RunControl, START, STREAM_EVENTS_V3_MODES, Send, StateGraph, StateGraphInputError, StateSchema, StreamChannel, SubgraphRunStream, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, messagesStateReducer as addMessages, convertToProtocolEvent, copyCheckpoint, createGraphRunStream, createLifecycleTransformer, createMessagesTransformer, createSubgraphDiscoveryTransformer, createValuesTransformer, emptyCheckpoint, entrypoint, filterLifecycleEntries, filterSubgraphHandles, getConfig, getCurrentTaskInput, getJsonSchemaFromSchema, getPreviousState, getSchemaDefaultGetter, getStore, getSubgraphsSeenSet, getWriter, interrupt, isCheckpointEnvelope, isCommand, isGraphBubbleUp, isGraphDrained, isGraphInterrupt, isInterrupted, isNativeTransformer, isNodeError, isNodeTimeoutError, isParentCommand, isSerializableSchema, isStandardSchema, messagesDeltaReducer, messagesStateReducer, pushMessage, task, writer };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph",
3
- "version": "1.3.7",
3
+ "version": "1.4.1",
4
4
  "description": "LangGraph",
5
5
  "type": "module",
6
6
  "engines": {
@@ -19,8 +19,8 @@
19
19
  "@langchain/protocol": "^0.0.16",
20
20
  "@standard-schema/spec": "1.1.0",
21
21
  "uuid": "^14.0.0",
22
- "@langchain/langgraph-checkpoint": "^1.0.4",
23
- "@langchain/langgraph-sdk": "~1.9.19"
22
+ "@langchain/langgraph-checkpoint": "^1.1.0",
23
+ "@langchain/langgraph-sdk": "~1.9.21"
24
24
  },
25
25
  "peerDependencies": {
26
26
  "@langchain/core": "^1.1.48",
@@ -58,8 +58,8 @@
58
58
  "vite-plugin-node-polyfills": "^0.28.0",
59
59
  "vitest": "^4.1.0",
60
60
  "zod-to-json-schema": "^3.22.4",
61
- "@langchain/langgraph-checkpoint-postgres": "1.0.2",
62
- "@langchain/langgraph-checkpoint-sqlite": "1.0.2"
61
+ "@langchain/langgraph-checkpoint-postgres": "1.0.3",
62
+ "@langchain/langgraph-checkpoint-sqlite": "1.0.3"
63
63
  },
64
64
  "publishConfig": {
65
65
  "access": "public",