@langchain/langgraph 1.1.5 → 1.2.0

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 (128) hide show
  1. package/dist/channels/binop.cjs +13 -2
  2. package/dist/channels/binop.cjs.map +1 -1
  3. package/dist/channels/binop.d.cts +4 -2
  4. package/dist/channels/binop.d.cts.map +1 -1
  5. package/dist/channels/binop.d.ts +4 -2
  6. package/dist/channels/binop.d.ts.map +1 -1
  7. package/dist/channels/binop.js +14 -3
  8. package/dist/channels/binop.js.map +1 -1
  9. package/dist/constants.cjs +78 -0
  10. package/dist/constants.cjs.map +1 -1
  11. package/dist/constants.d.cts +49 -1
  12. package/dist/constants.d.cts.map +1 -1
  13. package/dist/constants.d.ts +49 -1
  14. package/dist/constants.d.ts.map +1 -1
  15. package/dist/constants.js +76 -1
  16. package/dist/constants.js.map +1 -1
  17. package/dist/func/index.cjs +1 -1
  18. package/dist/func/index.d.cts +1 -1
  19. package/dist/func/index.d.ts +1 -1
  20. package/dist/func/index.js +1 -1
  21. package/dist/graph/annotation.cjs.map +1 -1
  22. package/dist/graph/annotation.d.cts +3 -2
  23. package/dist/graph/annotation.d.cts.map +1 -1
  24. package/dist/graph/annotation.d.ts +3 -2
  25. package/dist/graph/annotation.d.ts.map +1 -1
  26. package/dist/graph/annotation.js.map +1 -1
  27. package/dist/graph/graph.cjs +3 -6
  28. package/dist/graph/graph.cjs.map +1 -1
  29. package/dist/graph/graph.d.cts +2 -2
  30. package/dist/graph/graph.d.cts.map +1 -1
  31. package/dist/graph/graph.d.ts +2 -2
  32. package/dist/graph/graph.d.ts.map +1 -1
  33. package/dist/graph/graph.js +3 -6
  34. package/dist/graph/graph.js.map +1 -1
  35. package/dist/graph/index.cjs +1 -1
  36. package/dist/graph/index.d.ts +1 -1
  37. package/dist/graph/index.js +1 -1
  38. package/dist/graph/messages_annotation.d.cts +3 -2
  39. package/dist/graph/messages_annotation.d.cts.map +1 -1
  40. package/dist/graph/messages_annotation.d.ts +3 -2
  41. package/dist/graph/messages_annotation.d.ts.map +1 -1
  42. package/dist/graph/state.cjs +1 -1
  43. package/dist/graph/state.d.cts +1 -1
  44. package/dist/graph/state.d.ts +1 -1
  45. package/dist/graph/state.js +1 -1
  46. package/dist/graph/types.cjs +1 -1
  47. package/dist/graph/types.d.cts +1 -1
  48. package/dist/graph/types.d.ts +1 -1
  49. package/dist/graph/types.js +1 -1
  50. package/dist/graph/zod/meta.cjs.map +1 -1
  51. package/dist/graph/zod/meta.d.cts +3 -2
  52. package/dist/graph/zod/meta.d.cts.map +1 -1
  53. package/dist/graph/zod/meta.d.ts +3 -2
  54. package/dist/graph/zod/meta.d.ts.map +1 -1
  55. package/dist/graph/zod/meta.js.map +1 -1
  56. package/dist/index.cjs +2 -1
  57. package/dist/index.d.cts +2 -2
  58. package/dist/index.d.ts +2 -2
  59. package/dist/index.js +2 -2
  60. package/dist/interrupt.cjs +1 -1
  61. package/dist/interrupt.js +1 -1
  62. package/dist/prebuilt/react_agent_executor.cjs +1 -1
  63. package/dist/prebuilt/react_agent_executor.d.cts +5 -5
  64. package/dist/prebuilt/react_agent_executor.d.cts.map +1 -1
  65. package/dist/prebuilt/react_agent_executor.d.ts +5 -5
  66. package/dist/prebuilt/react_agent_executor.d.ts.map +1 -1
  67. package/dist/prebuilt/react_agent_executor.js +1 -1
  68. package/dist/prebuilt/tool_node.cjs +1 -1
  69. package/dist/prebuilt/tool_node.d.cts +1 -1
  70. package/dist/prebuilt/tool_node.d.ts +1 -1
  71. package/dist/prebuilt/tool_node.js +1 -1
  72. package/dist/pregel/algo.cjs +1 -1
  73. package/dist/pregel/algo.d.ts +1 -1
  74. package/dist/pregel/algo.js +1 -1
  75. package/dist/pregel/index.cjs +13 -1
  76. package/dist/pregel/index.cjs.map +1 -1
  77. package/dist/pregel/index.d.cts +2 -1
  78. package/dist/pregel/index.d.cts.map +1 -1
  79. package/dist/pregel/index.d.ts +2 -1
  80. package/dist/pregel/index.d.ts.map +1 -1
  81. package/dist/pregel/index.js +14 -2
  82. package/dist/pregel/index.js.map +1 -1
  83. package/dist/pregel/io.cjs +1 -1
  84. package/dist/pregel/io.js +1 -1
  85. package/dist/pregel/loop.cjs +1 -1
  86. package/dist/pregel/loop.js +1 -1
  87. package/dist/pregel/read.cjs +4 -1
  88. package/dist/pregel/read.cjs.map +1 -1
  89. package/dist/pregel/read.d.cts.map +1 -1
  90. package/dist/pregel/read.d.ts.map +1 -1
  91. package/dist/pregel/read.js +4 -1
  92. package/dist/pregel/read.js.map +1 -1
  93. package/dist/pregel/remote.cjs +1 -1
  94. package/dist/pregel/remote.js +1 -1
  95. package/dist/pregel/retry.cjs +1 -1
  96. package/dist/pregel/retry.js +1 -1
  97. package/dist/pregel/runner.cjs +1 -1
  98. package/dist/pregel/runner.js +1 -1
  99. package/dist/pregel/stream.cjs +81 -0
  100. package/dist/pregel/stream.cjs.map +1 -1
  101. package/dist/pregel/stream.d.ts +2 -1
  102. package/dist/pregel/stream.js +81 -1
  103. package/dist/pregel/stream.js.map +1 -1
  104. package/dist/pregel/types.cjs.map +1 -1
  105. package/dist/pregel/types.d.cts +27 -2
  106. package/dist/pregel/types.d.cts.map +1 -1
  107. package/dist/pregel/types.d.ts +27 -2
  108. package/dist/pregel/types.d.ts.map +1 -1
  109. package/dist/pregel/types.js.map +1 -1
  110. package/dist/pregel/write.cjs +2 -1
  111. package/dist/pregel/write.cjs.map +1 -1
  112. package/dist/pregel/write.d.cts +1 -1
  113. package/dist/pregel/write.d.cts.map +1 -1
  114. package/dist/pregel/write.d.ts +1 -1
  115. package/dist/pregel/write.d.ts.map +1 -1
  116. package/dist/pregel/write.js +2 -1
  117. package/dist/pregel/write.js.map +1 -1
  118. package/dist/state/schema.cjs.map +1 -1
  119. package/dist/state/schema.d.cts +3 -2
  120. package/dist/state/schema.d.cts.map +1 -1
  121. package/dist/state/schema.d.ts +3 -2
  122. package/dist/state/schema.d.ts.map +1 -1
  123. package/dist/state/schema.js.map +1 -1
  124. package/dist/web.cjs +2 -1
  125. package/dist/web.d.cts +2 -2
  126. package/dist/web.d.ts +2 -2
  127. package/dist/web.js +2 -2
  128. package/package.json +4 -4
@@ -1 +1 @@
1
- {"version":3,"file":"schema.cjs","names":["ReducedValue","getSchemaDefaultGetter","BinaryOperatorAggregate","UntrackedValue","UntrackedValueChannel","isStandardSchema","LastValue","getJsonSchemaFromSchema"],"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 { 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> = F extends ReducedValue<\n infer V,\n infer I\n>\n ? BaseChannel<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<any, any>\n ? TFields[K][\"InputType\"]\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 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 } 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\" &&\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":";;;;;;;;;;AAkBA,MAAM,sBAAsB,OAAO,IAAI,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6JtE,IAAa,cAAb,MAA4D;;;;;CAM1D,CAAkB,uBAAuB;CAkCzC,YAAY,AAAS,QAAiB;EAAjB;;;;;;CAMrB,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IlB,SAAO;;CAeT,OAAO,WACL,OAC+B;AAC/B,SACE,OAAO,UAAU,YACjB,UAAU,QACV,uBAAuB,SACvB,MAAM,yBAAyB"}
1
+ {"version":3,"file":"schema.cjs","names":["ReducedValue","getSchemaDefaultGetter","BinaryOperatorAggregate","UntrackedValue","UntrackedValueChannel","isStandardSchema","LastValue","getJsonSchemaFromSchema"],"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> = F extends ReducedValue<\n infer V,\n infer I\n>\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 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 } 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\" &&\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":";;;;;;;;;;AAmBA,MAAM,sBAAsB,OAAO,IAAI,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6JtE,IAAa,cAAb,MAA4D;;;;;CAM1D,CAAkB,uBAAuB;CAkCzC,YAAY,AAAS,QA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B;SAG/B,QAAO,OAAO;;AAIlB,SAAO;;CAeT,OAAO,WACL,OAC+B;AAC/B,SACE,OAAO,UAAU,YACjB,UAAU,QACV,uBAAuB,SACvB,MAAM,yBAAyB"}
@@ -1,4 +1,5 @@
1
1
  import { BaseChannel } from "../channels/base.cjs";
2
+ import { OverwriteValue } from "../constants.cjs";
2
3
  import { RunnableLike } from "../pregel/runnable_types.cjs";
3
4
  import { SerializableSchema } from "./types.cjs";
4
5
  import { ReducedValue } from "./values/reduced.cjs";
@@ -30,7 +31,7 @@ declare const STATE_SCHEMA_SYMBOL: unique symbol;
30
31
  * // ChannelType is BaseChannel<number, string>
31
32
  * ```
32
33
  */
33
- type StateSchemaFieldToChannel<F> = F extends ReducedValue<infer V, infer I> ? BaseChannel<V, I> : F extends UntrackedValue<infer V> ? BaseChannel<V, V> : F extends SerializableSchema<infer I, infer O> ? BaseChannel<O, I> : BaseChannel<unknown, unknown>;
34
+ type StateSchemaFieldToChannel<F> = F extends ReducedValue<infer V, infer I> ? BaseChannel<V, OverwriteValue<V> | I> : F extends UntrackedValue<infer V> ? BaseChannel<V, V> : F extends SerializableSchema<infer I, infer O> ? BaseChannel<O, I> : BaseChannel<unknown, unknown>;
34
35
  /**
35
36
  * Converts StateSchema fields into a strongly-typed
36
37
  * State Definition object, where each field is mapped to its channel type.
@@ -90,7 +91,7 @@ type InferStateSchemaValue<TFields extends StateSchemaFields> = { [K in keyof TF
90
91
  * - UntrackedValue<Value> → Value
91
92
  * - SerializableSchema<Input, Output> → Input (what you provide)
92
93
  */
93
- type InferStateSchemaUpdate<TFields extends StateSchemaFields> = { [K in keyof TFields]?: TFields[K] extends ReducedValue<any, any> ? TFields[K]["InputType"] : TFields[K] extends UntrackedValue<any> ? TFields[K]["ValueType"] : TFields[K] extends SerializableSchema<infer TInput, any> ? TInput : never };
94
+ type InferStateSchemaUpdate<TFields extends StateSchemaFields> = { [K in keyof TFields]?: TFields[K] extends ReducedValue<infer V, infer I> ? OverwriteValue<V> | I : TFields[K] extends UntrackedValue<any> ? TFields[K]["ValueType"] : TFields[K] extends SerializableSchema<infer TInput, any> ? TInput : never };
94
95
  /**
95
96
  * StateSchema provides a unified API for defining LangGraph state schemas.
96
97
  *
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.cts","names":[],"sources":["../../src/state/schema.ts"],"mappings":";;;;;;;;cAkBM,mBAAA;;AAFiD;;;;;AA2BvD;;;;;;;;;;;;;;;;;KAAY,yBAAA,MAA+B,CAAA,SAAU,YAAA,qBAIjD,WAAA,CAAY,CAAA,EAAG,CAAA,IACf,CAAA,SAAU,cAAA,YACV,WAAA,CAAY,CAAA,EAAG,CAAA,IACf,CAAA,SAAU,kBAAA,qBACV,WAAA,CAAY,CAAA,EAAG,CAAA,IACf,WAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BJ;;KAAY,kCAAA,iBACM,iBAAA,kBAEJ,OAAA,GAAU,yBAAA,CAA0B,OAAA,CAAQ,CAAA;;;;;KAO9C,gBAAA,2BAA2C,KAAA,IACnD,YAAA,CAAa,KAAA,EAAO,MAAA,IACpB,cAAA,CAAe,MAAA,IACf,kBAAA,CAAmB,KAAA,EAAO,MAAA;;;;;KAMlB,iBAAA;EAAA,CACT,GAAA,WAAc,gBAAA;AAAA;;;AAVjB;;;;;;KAqBY,qBAAA,iBAAsC,iBAAA,kBACpC,OAAA,GAAU,OAAA,CAAQ,CAAA,UAAW,YAAA,aACrC,OAAA,CAAQ,CAAA,iBACR,OAAA,CAAQ,CAAA,UAAW,cAAA,QACnB,OAAA,CAAQ,CAAA,iBACR,OAAA,CAAQ,CAAA,UAAW,kBAAA,uBACnB,OAAA;;;;;;;;;KAYM,sBAAA,iBAAuC,iBAAA,kBACrC,OAAA,IAAW,OAAA,CAAQ,CAAA,UAAW,YAAA,aACtC,OAAA,CAAQ,CAAA,iBACR,OAAA,CAAQ,CAAA,UAAW,cAAA,QACnB,OAAA,CAAQ,CAAA,iBACR,OAAA,CAAQ,CAAA,UA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AAQ,OAAA;EAjFL;;;;EAuFxB,WAAA,CAAA,GAAe,MAAA,SAAe,WAAA;EArFlB;;;;EA2HZ,aAAA,CAAA,GAAiB,UAAA;EA1HwB;;;;EA+KzC,kBAAA,CAAA,GAAsB,UAAA;EAnLC;;;EAkNvB,cAAA,CAAA;EAlNsE;;;EAyNtE,UAAA,CAAA;EAvNI;;;;;;;EAkOE,aAAA,GAAA,CAAiB,IAAA,EAAM,CAAA,GAAI,OAAA,CAAQ,CAAA;EAhOO;;;;AAsClD;;EAtCkD,OAqRzC,UAAA,iBAA2B,iBAAA,CAAA,CAChC,KAAA,EAAO,WAAA,CAAY,OAAA,IAClB,KAAA,IAAS,WAAA,CAAY,OAAA;EAAA,OAEjB,UAAA,CAAW,KAAA,YAAiB,KAAA,IAAS,WAAA;AAAA;AAAA,KAclC,cAAA,GAAiB,WAAA"}
@@ -1,4 +1,5 @@
1
1
  import { BaseChannel } from "../channels/base.js";
2
+ import { OverwriteValue } from "../constants.js";
2
3
  import "../channels/index.js";
3
4
  import { RunnableLike } from "../pregel/runnable_types.js";
4
5
  import { SerializableSchema } from "./types.js";
@@ -31,7 +32,7 @@ declare const STATE_SCHEMA_SYMBOL: unique symbol;
31
32
  * // ChannelType is BaseChannel<number, string>
32
33
  * ```
33
34
  */
34
- type StateSchemaFieldToChannel<F> = F extends ReducedValue<infer V, infer I> ? BaseChannel<V, I> : F extends UntrackedValue<infer V> ? BaseChannel<V, V> : F extends SerializableSchema<infer I, infer O> ? BaseChannel<O, I> : BaseChannel<unknown, unknown>;
35
+ type StateSchemaFieldToChannel<F> = F extends ReducedValue<infer V, infer I> ? BaseChannel<V, OverwriteValue<V> | I> : F extends UntrackedValue<infer V> ? BaseChannel<V, V> : F extends SerializableSchema<infer I, infer O> ? BaseChannel<O, I> : BaseChannel<unknown, unknown>;
35
36
  /**
36
37
  * Converts StateSchema fields into a strongly-typed
37
38
  * State Definition object, where each field is mapped to its channel type.
@@ -91,7 +92,7 @@ type InferStateSchemaValue<TFields extends StateSchemaFields> = { [K in keyof TF
91
92
  * - UntrackedValue<Value> → Value
92
93
  * - SerializableSchema<Input, Output> → Input (what you provide)
93
94
  */
94
- type InferStateSchemaUpdate<TFields extends StateSchemaFields> = { [K in keyof TFields]?: TFields[K] extends ReducedValue<any, any> ? TFields[K]["InputType"] : TFields[K] extends UntrackedValue<any> ? TFields[K]["ValueType"] : TFields[K] extends SerializableSchema<infer TInput, any> ? TInput : never };
95
+ type InferStateSchemaUpdate<TFields extends StateSchemaFields> = { [K in keyof TFields]?: TFields[K] extends ReducedValue<infer V, infer I> ? OverwriteValue<V> | I : TFields[K] extends UntrackedValue<any> ? TFields[K]["ValueType"] : TFields[K] extends SerializableSchema<infer TInput, any> ? TInput : never };
95
96
  /**
96
97
  * StateSchema provides a unified API for defining LangGraph state schemas.
97
98
  *
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","names":[],"sources":["../../src/state/schema.ts"],"mappings":";;;;;;;;;cAkBM,mBAAA;;;AAFiD;;;;;AA2BvD;;;;;;;;;;;;;;;;KAAY,yBAAA,MAA+B,CAAA,SAAU,YAAA,qBAIjD,WAAA,CAAY,CAAA,EAAG,CAAA,IACf,CAAA,SAAU,cAAA,YACV,WAAA,CAAY,CAAA,EAAG,CAAA,IACf,CAAA,SAAU,kBAAA,qBACV,WAAA,CAAY,CAAA,EAAG,CAAA,IACf,WAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA+BJ;KAAY,kCAAA,iBACM,iBAAA,kBAEJ,OAAA,GAAU,yBAAA,CAA0B,OAAA,CAAQ,CAAA;;;;;KAO9C,gBAAA,2BAA2C,KAAA,IACnD,YAAA,CAAa,KAAA,EAAO,MAAA,IACpB,cAAA,CAAe,MAAA,IACf,kBAAA,CAAmB,KAAA,EAAO,MAAA;;;;;KAMlB,iBAAA;EAAA,CACT,GAAA,WAAc,gBAAA;AAAA;;;;AAVjB;;;;;KAqBY,qBAAA,iBAAsC,iBAAA,kBACpC,OAAA,G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MAAA;;;;;;;;;;;;;AApCN;;;;;AAYA;;;;;;;;;;;;;;;;cA6Da,WAAA,iBAA4B,iBAAA;EAAA,SAwClB,MAAA,EAAQ,OAAA;EAhGY;;;;EAAA,kBA8DvB,mBAAA;EAlEN;;;;EAwEJ,KAAA,EAAO,qBAAA,CAAsB,OAAA;EAvEzB;;;;EA6EJ,MAAA,EAAQ,sBAAA,CAAuB,OAAA;EA3E3B;;;;;;;;AAcd;;;;;;;EA8EU,IAAA,EAAM,YAAA,CACZ,qBAAA,CAAsB,OAAA,GACtB,sBAAA,CAAuB,OAAA;EAGzB,WAAA,CAAqB,MAAA,EAAQ,OAAA;EAjFzB;;;;EAuFJ,WAAA,CAAA,GAAe,MAAA,SAAe,WAAA;EArF1B;;;;EA2HJ,aAAA,CAAA,GAAiB,UAAA;EA1HwB;;;;EA+KzC,kBAAA,CAAA,GAAsB,UAAA;EAnLV;;;EAkNZ,cAAA,CAAA;EAlN6D;;;EAyN7D,UAAA,CAAA;EAxNwB;;;;;;;EAmOlB,aAAA,GAAA,CAAiB,IAAA,EAAM,CAAA,GAAI,OAAA,CAAQ,CAAA;EAhOlB;;;;;AAsCzB;EAtCyB,OAqRhB,UAAA,iBAA2B,iBAAA,CAAA,CAChC,KAAA,EAAO,WAAA,CAAY,OAAA,IAClB,KAAA,IAAS,WAAA,CAAY,OAAA;EAAA,OAEjB,UAAA,CAAW,KAAA,YAAiB,KAAA,IAAS,WAAA;AAAA;AAAA,KAclC,cAAA,GAAiB,WAAA"}
@@ -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 { 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> = F extends ReducedValue<\n infer V,\n infer I\n>\n ? BaseChannel<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<any, any>\n ? TFields[K][\"InputType\"]\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 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 } 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\" &&\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":";;;;;;;;;;AAkBA,MAAM,sBAAsB,OAAO,IAAI,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6JtE,IAAa,cAAb,MAA4D;;;;;CAM1D,CAAkB,uBAAuB;CAkCzC,YAAY,AAAS,QAAiB;EAAjB;;;;;;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;AACJ,YAAS,OAAO,IAAI,sBAAsB;IACxC,OAAO,MAAM;IACb,qBAAqB;IACtB,CAAC;aACO,iBAAiB,MAAM,CAGhC,UAAS,OAAO,IAAI,UADE,uBAAuB,MAAM,CACP;MAE5C,OAAM,IAAI,MACR,wBAAwB,IAAI,oEAC7B;AAIL,S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SAAS,IAAI;;;;;CAMxD,aAAuB;AACrB,SAAO,OAAO,KAAK,KAAK,OAAO;;;;;;;;;CAUjC,MAAM,cAAiB,MAAqB;AAC1C,MAAI,QAAQ,QAAQ,OAAO,SAAS,SAClC,QAAO;EAGT,MAAM,SAAkC,EAAE;AAE1C,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,EAAE;GAC/C,MAAM,WAAW,KAAK,OAAO;AAE7B,OAAI,aAAa,QAAW;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 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> = F extends ReducedValue<\n infer V,\n infer I\n>\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 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 } 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\" &&\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":";;;;;;;;;;AAmBA,MAAM,sBAAsB,OAAO,IAAI,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6JtE,IAAa,cAAb,MAA4D;;;;;CAM1D,CAAkB,uBAAuB;CAkCzC,YAAY,AAAS,QAAiB;EAAjB;;;;;;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;AACJ,YAAS,OAAO,IAAI,sBAAsB;IACxC,OAAO,MAAM;IACb,qBAAqB;IACtB,CAAC;aACO,iBAAiB,MAAM,CAGhC,UAAS,OAAO,IAAI,UADE,uBAAuB,MAAM,CACP;MAE5C,OAAM,IAAI,MACR,wBAAwB,IAAI,oEAC7B;AAIL,SAAO;;;;;;CAOT,gBAA4B;EAC1B,MAAM,aAAyC,EAAE;EACjD,MAAM,WAAqB,EAAE;AAE7B,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO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AAQ,QAAQ,OAAO,SAAS,SAClC,QAAO;EAGT,MAAM,SAAkC,EAAE;AAE1C,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,EAAE;GAC/C,MAAM,WAAW,KAAK,OAAO;AAE7B,OAAI,aAAa,QAAW;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"}
package/dist/web.cjs CHANGED
@@ -1,9 +1,9 @@
1
1
  Object.defineProperty(exports, Symbol.toStringTag, { value: 'Module' });
2
+ const require_constants = require('./constants.cjs');
2
3
  const require_errors = require('./errors.cjs');
3
4
  const require_base = require('./channels/base.cjs');
4
5
  const require_binop = require('./channels/binop.cjs');
5
6
  const require_annotation = require('./graph/annotation.cjs');
6
- const require_constants = require('./constants.cjs');
7
7
  const require_graph = require('./graph/graph.cjs');
8
8
  const require_types = require('./state/types.cjs');
9
9
  const require_adapter = require('./state/adapter.cjs');
@@ -75,6 +75,7 @@ exports.MessagesZodMeta = require_messages_annotation.MessagesZodMeta;
75
75
  exports.MessagesZodState = require_messages_annotation.MessagesZodState;
76
76
  exports.MultipleSubgraphsError = require_errors.MultipleSubgraphsError;
77
77
  exports.NodeInterrupt = require_errors.NodeInterrupt;
78
+ exports.Overwrite = require_constants.Overwrite;
78
79
  exports.ParentCommand = require_errors.ParentCommand;
79
80
  exports.REMOVE_ALL_MESSAGES = require_messages_reducer.REMOVE_ALL_MESSAGES;
80
81
  exports.ReducedValue = require_reduced.ReducedValue;
package/dist/web.d.cts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { BaseChannel } from "./channels/base.cjs";
2
+ import { Command, 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";
@@ -29,4 +29,4 @@ import { MessagesAnnotation, MessagesZodMeta, MessagesZodState } from "./graph/m
29
29
  import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter.cjs";
30
30
  import { MessagesValue } from "./state/prebuilt/messages.cjs";
31
31
  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";
32
- export { Annotation, type AnnotationRoot, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, type CommandParams, type CompiledGraph, CompiledStateGraph, type ConditionalEdgeRouter, type ConditionalEdgeRouterTypes, type ContextSchemaInit, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, type GraphNode, type GraphNodeReturnValue, type GraphNodeTypes, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InferStateSchemaUpdate, InferStateSchemaValue, type Interrupt, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type NamespaceMatchType, NodeInterrupt, type NodeType, type Operation, type OperationResults, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, type Runtime, START, type SearchOperation, Send, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, type StateDefinitionInit, StateGraph, type StateGraphArgs, type StateGraphInit, StateGraphInputError, type StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFields, type StateSnapshot, type StateType, type StreamMode, type StreamOutputMap, type TaskOptions, type Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type WaitForNames, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getJsonSchemaFromSchema, getSchemaDefaultGetter, getSubgraphsSeenSet, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, task };
32
+ export { Annotation, type AnnotationRoot, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, type CommandParams, type CompiledGraph, CompiledStateGraph, type ConditionalEdgeRouter, type ConditionalEdgeRouterTypes, type ContextSchemaInit, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, type GraphNode, type GraphNodeReturnValue, type GraphNodeTypes, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InferStateSchemaUpdate, InferStateSchemaValue, type Interrupt, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type NamespaceMatchType, NodeInterrupt, type NodeType, type Operation, type OperationResults, Overwrite, type OverwriteValue, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, type Runtime, START, type SearchOperation, Send, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, type StateDefinitionInit, StateGraph, type StateGraphArgs, type StateGraphInit, StateGraphInputError, type StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFields, type StateSnapshot, type StateType, type StreamMode, type StreamOutputMap, type TaskOptions, type Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type WaitForNames, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getJsonSchemaFromSchema, getSchemaDefaultGetter, getSubgraphsSeenSet, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, task };
package/dist/web.d.ts CHANGED
@@ -1,4 +1,5 @@
1
1
  import { BaseChannel } from "./channels/base.js";
2
+ import { Command, 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";
@@ -12,7 +13,6 @@ import { LangGraphRunnableConfig, Runtime } from "./pregel/runnable_types.js";
12
13
  import { Annotation, AnnotationRoot, NodeType, SingleReducer, StateDefinition, StateType, UpdateType } from "./graph/annotation.js";
13
14
  import { RetryPolicy } from "./pregel/utils/index.js";
14
15
  import { PregelNode } from "./pregel/read.js";
15
- import { Command, CommandParams, END, INTERRUPT, Interrupt, START, Send, isCommand, isInterrupted } from "./constants.js";
16
16
  import { GetStateOptions, MultipleChannelSubscriptionOptions, PregelOptions, PregelParams, SingleChannelSubscriptionOptions, StateSnapshot, StreamMode, StreamOutputMap } from "./pregel/types.js";
17
17
  import { Pregel } from "./pregel/index.js";
18
18
  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 "./state/index.js";
34
34
  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";
35
- export { Annotation, type AnnotationRoot, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, type CommandParams, type CompiledGraph, CompiledStateGraph, type ConditionalEdgeRouter, type ConditionalEdgeRouterTypes, type ContextSchemaInit, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, type GraphNode, type GraphNodeReturnValue, type GraphNodeTypes, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InferStateSchemaUpdate, InferStateSchemaValue, type Interrupt, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type NamespaceMatchType, NodeInterrupt, type NodeType, type Operation, type OperationResults, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, type Runtime, START, type SearchOperation, Send, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, type StateDefinitionInit, StateGraph, type StateGraphArgs, type StateGraphInit, StateGraphInputError, type StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFields, type StateSnapshot, type StateType, type StreamMode, type StreamOutputMap, type TaskOptions, type Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type WaitForNames, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getJsonSchemaFromSchema, getSchemaDefaultGetter, getSubgraphsSeenSet, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, task };
35
+ export { Annotation, type AnnotationRoot, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, type CommandParams, type CompiledGraph, CompiledStateGraph, type ConditionalEdgeRouter, type ConditionalEdgeRouterTypes, type ContextSchemaInit, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, type GraphNode, type GraphNodeReturnValue, type GraphNodeTypes, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InferStateSchemaUpdate, InferStateSchemaValue, type Interrupt, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type NamespaceMatchType, NodeInterrupt, type NodeType, type Operation, type OperationResults, Overwrite, type OverwriteValue, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, type Runtime, START, type SearchOperation, Send, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, type StateDefinitionInit, StateGraph, type StateGraphArgs, type StateGraphInit, StateGraphInputError, type StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFields, type StateSnapshot, type StateType, type StreamMode, type StreamOutputMap, type TaskOptions, type Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type WaitForNames, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getJsonSchemaFromSchema, getSchemaDefaultGetter, getSubgraphsSeenSet, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, task };
package/dist/web.js CHANGED
@@ -1,8 +1,8 @@
1
+ import { Command, END, INTERRUPT, Overwrite, START, Send, isCommand, isInterrupted } from "./constants.js";
1
2
  import { BaseLangGraphError, EmptyChannelError, EmptyInputError, GraphBubbleUp, GraphInterrupt, GraphRecursionError, GraphValueError, InvalidUpdateError, MultipleSubgraphsError, NodeInterrupt, ParentCommand, RemoteException, StateGraphInputError, UnreachableNodeError, getSubgraphsSeenSet, isGraphBubbleUp, isGraphInterrupt, isParentCommand } from "./errors.js";
2
3
  import { BaseChannel } from "./channels/base.js";
3
4
  import { BinaryOperatorAggregate } from "./channels/binop.js";
4
5
  import { Annotation } from "./graph/annotation.js";
5
- import { Command, END, INTERRUPT, START, Send, isCommand, isInterrupted } from "./constants.js";
6
6
  import { Graph } from "./graph/graph.js";
7
7
  import { isSerializableSchema, isStandardSchema } from "./state/types.js";
8
8
  import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter.js";
@@ -21,4 +21,4 @@ import { entrypoint, task } from "./func/index.js";
21
21
  import { MessagesAnnotation, MessagesZodMeta, MessagesZodState } from "./graph/messages_annotation.js";
22
22
  import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, InMemoryStore, MemorySaver, copyCheckpoint, emptyCheckpoint } from "@langchain/langgraph-checkpoint";
23
23
 
24
- 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, getJsonSchemaFromSchema, getSchemaDefaultGetter, getSubgraphsSeenSet, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, task };
24
+ 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, Overwrite, ParentCommand, REMOVE_ALL_MESSAGES, ReducedValue, RemoteException, START, Send, StateGraph, StateGraphInputError, StateSchema, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getJsonSchemaFromSchema, getSchemaDefaultGetter, getSubgraphsSeenSet, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, task };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph",
3
- "version": "1.1.5",
3
+ "version": "1.2.0",
4
4
  "description": "LangGraph",
5
5
  "type": "module",
6
6
  "engines": {
@@ -19,7 +19,7 @@
19
19
  "@standard-schema/spec": "1.1.0",
20
20
  "uuid": "^10.0.0",
21
21
  "@langchain/langgraph-checkpoint": "^1.0.0",
22
- "@langchain/langgraph-sdk": "~2.0.0"
22
+ "@langchain/langgraph-sdk": "~1.6.5"
23
23
  },
24
24
  "peerDependencies": {
25
25
  "@langchain/core": "^1.1.16",
@@ -33,7 +33,7 @@
33
33
  },
34
34
  "devDependencies": {
35
35
  "@langchain/anthropic": "^1.0.0",
36
- "@langchain/core": "^1.1.16",
36
+ "@langchain/core": "^1.1.28",
37
37
  "@langchain/openai": "^1.0.0",
38
38
  "@langchain/scripts": ">=0.1.3 <0.2.0",
39
39
  "@langchain/tavily": "^1.0.0",
@@ -65,7 +65,7 @@
65
65
  "vite-plugin-node-polyfills": "^0.23.0",
66
66
  "vitest": "^3.2.4",
67
67
  "zod-to-json-schema": "^3.22.4",
68
- "@langchain/langgraph-checkpoint-postgres": "1.0.0",
68
+ "@langchain/langgraph-checkpoint-postgres": "1.0.1",
69
69
  "@langchain/langgraph-checkpoint-sqlite": "1.0.1"
70
70
  },
71
71
  "publishConfig": {