@langchain/langgraph 1.1.0 → 1.1.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 (34) hide show
  1. package/dist/errors.d.cts.map +1 -1
  2. package/dist/graph/message.d.cts +2 -2
  3. package/dist/graph/message.d.cts.map +1 -1
  4. package/dist/graph/messages_annotation.d.cts +5 -5
  5. package/dist/graph/messages_annotation.d.cts.map +1 -1
  6. package/dist/index.d.cts +2 -2
  7. package/dist/index.d.ts +2 -2
  8. package/dist/prebuilt/agent_executor.d.cts +5 -5
  9. package/dist/prebuilt/agent_executor.d.cts.map +1 -1
  10. package/dist/prebuilt/react_agent_executor.d.cts +3 -3
  11. package/dist/prebuilt/react_agent_executor.d.cts.map +1 -1
  12. package/dist/state/schema.cjs +8 -9
  13. package/dist/state/schema.cjs.map +1 -1
  14. package/dist/state/schema.d.cts +18 -22
  15. package/dist/state/schema.d.cts.map +1 -1
  16. package/dist/state/schema.d.ts +18 -22
  17. package/dist/state/schema.d.ts.map +1 -1
  18. package/dist/state/schema.js +8 -9
  19. package/dist/state/schema.js.map +1 -1
  20. package/dist/state/values/reduced.cjs.map +1 -1
  21. package/dist/state/values/reduced.d.cts +1 -1
  22. package/dist/state/values/reduced.d.cts.map +1 -1
  23. package/dist/state/values/reduced.d.ts +1 -1
  24. package/dist/state/values/reduced.d.ts.map +1 -1
  25. package/dist/state/values/reduced.js.map +1 -1
  26. package/dist/state/values/untracked.cjs.map +1 -1
  27. package/dist/state/values/untracked.d.cts +4 -0
  28. package/dist/state/values/untracked.d.cts.map +1 -1
  29. package/dist/state/values/untracked.d.ts +4 -0
  30. package/dist/state/values/untracked.d.ts.map +1 -1
  31. package/dist/state/values/untracked.js.map +1 -1
  32. package/dist/web.d.cts +2 -2
  33. package/dist/web.d.ts +2 -2
  34. package/package.json +3 -3
@@ -32,8 +32,8 @@ declare const STATE_SCHEMA_SYMBOL: unique symbol;
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
34
  /**
35
- * Converts a StateSchema "init" object (field map) into a strongly-typed
36
- * State Definition object, where each key is mapped to its channel type.
35
+ * Converts StateSchema fields into a strongly-typed
36
+ * State Definition object, where each field is mapped to its channel type.
37
37
  *
38
38
  * This utility type is used internally to create the shape of the state channels for a given schema,
39
39
  * substituting each field with the result of `StateSchemaFieldToChannel`.
@@ -55,12 +55,12 @@ type StateSchemaFieldToChannel<F> = F extends ReducedValue<infer V, infer I> ? B
55
55
  * }
56
56
  * ```
57
57
  *
58
- * @template TInit - The mapping of field names to StateSchema field types.
59
- * @returns An object type mapping keys to channel types.
58
+ * @template TFields - The mapping of field names to StateSchema field types.
59
+ * @returns An object type mapping field names to channel types.
60
60
  *
61
61
  * @see StateSchemaFieldToChannel
62
62
  */
63
- type StateSchemaFieldsToStateDefinition<TInit extends StateSchemaInit> = { [K in keyof TInit]: StateSchemaFieldToChannel<TInit[K]> };
63
+ type StateSchemaFieldsToStateDefinition<TFields extends StateSchemaFields> = { [K in keyof TFields]: StateSchemaFieldToChannel<TFields[K]> };
64
64
  /**
65
65
  * Valid field types for StateSchema.
66
66
  * Either a LangGraph state value type or a raw schema (e.g., Zod schema).
@@ -70,31 +70,27 @@ type StateSchemaField<Input = unknown, Output = Input> = ReducedValue<Input, Out
70
70
  * Init object for StateSchema constructor.
71
71
  * Uses `any` to allow variance in generic types (e.g., ReducedValue<string, string[]>).
72
72
  */
73
- type StateSchemaInit = {
73
+ type StateSchemaFields = {
74
74
  [key: string]: StateSchemaField<any, any>;
75
75
  };
76
76
  /**
77
- * Infer the State type from a StateSchemaInit.
77
+ * Infer the State type from a StateSchemaFields.
78
78
  * This is the type of the full state object.
79
79
  *
80
80
  * - ReducedValue<Value, Input> → Value (the stored type)
81
81
  * - UntrackedValue<Value> → Value
82
82
  * - SerializableSchema<Input, Output> → Output (the validated type)
83
83
  */
84
- type InferStateSchemaValue<TInit extends StateSchemaInit> = { [K in keyof TInit]: TInit[K] extends {
85
- ValueType: infer TValue;
86
- } ? TValue : TInit[K] extends UntrackedValue<infer TValue> ? TValue : TInit[K] extends SerializableSchema<unknown, infer TOutput> ? TOutput : never };
84
+ type InferStateSchemaValue<TFields extends StateSchemaFields> = { [K in keyof TFields]: TFields[K] extends ReducedValue<any, any> ? TFields[K]["ValueType"] : TFields[K] extends UntrackedValue<any> ? TFields[K]["ValueType"] : TFields[K] extends SerializableSchema<any, infer TOutput> ? TOutput : never };
87
85
  /**
88
- * Infer the Update type from a StateSchemaInit.
86
+ * Infer the Update type from a StateSchemaFields.
89
87
  * This is the type for partial updates to state.
90
88
  *
91
89
  * - ReducedValue<Value, Input> → Input (the reducer input type)
92
90
  * - UntrackedValue<Value> → Value
93
91
  * - SerializableSchema<Input, Output> → Input (what you provide)
94
92
  */
95
- type InferStateSchemaUpdate<TInit extends StateSchemaInit> = { [K in keyof TInit]?: TInit[K] extends {
96
- InputType: infer TInput;
97
- } ? TInput : TInit[K] extends UntrackedValue<infer TValue> ? TValue : TInit[K] extends SerializableSchema<infer TInput, unknown> ? TInput : never };
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 };
98
94
  /**
99
95
  * StateSchema provides a unified API for defining LangGraph state schemas.
100
96
  *
@@ -128,8 +124,8 @@ type InferStateSchemaUpdate<TInit extends StateSchemaInit> = { [K in keyof TInit
128
124
  * const graph = new StateGraph(AgentState);
129
125
  * ```
130
126
  */
131
- declare class StateSchema<TInit extends StateSchemaInit> {
132
- readonly init: TInit;
127
+ declare class StateSchema<TFields extends StateSchemaFields> {
128
+ readonly fields: TFields;
133
129
  /**
134
130
  * Symbol for runtime identification.
135
131
  * @internal Used by isInstance for runtime type checking
@@ -139,12 +135,12 @@ declare class StateSchema<TInit extends StateSchemaInit> {
139
135
  * Type declaration for the full state type.
140
136
  * Use: `typeof myState.State`
141
137
  */
142
- State: InferStateSchemaValue<TInit>;
138
+ State: InferStateSchemaValue<TFields>;
143
139
  /**
144
140
  * Type declaration for the update type.
145
141
  * Use: `typeof myState.Update`
146
142
  */
147
- Update: InferStateSchemaUpdate<TInit>;
143
+ Update: InferStateSchemaUpdate<TFields>;
148
144
  /**
149
145
  * Type declaration for node functions.
150
146
  * Use: `typeof myState.Node` to type node functions outside the graph builder.
@@ -160,8 +156,8 @@ declare class StateSchema<TInit extends StateSchemaInit> {
160
156
  * };
161
157
  * ```
162
158
  */
163
- Node: RunnableLike<InferStateSchemaValue<TInit>, InferStateSchemaUpdate<TInit>>;
164
- constructor(init: TInit);
159
+ Node: RunnableLike<InferStateSchemaValue<TFields>, InferStateSchemaUpdate<TFields>>;
160
+ constructor(fields: TFields);
165
161
  /**
166
162
  * Get the channel definitions for use with StateGraph.
167
163
  * This converts the StateSchema fields into BaseChannel instances.
@@ -199,10 +195,10 @@ declare class StateSchema<TInit extends StateSchemaInit> {
199
195
  * @param value - The value to check.
200
196
  * @returns True if the value is a StateSchema instance with the correct runtime tag.
201
197
  */
202
- static isInstance<TInit extends StateSchemaInit>(value: StateSchema<TInit>): value is StateSchema<TInit>;
198
+ static isInstance<TFields extends StateSchemaFields>(value: StateSchema<TFields>): value is StateSchema<TFields>;
203
199
  static isInstance(value: unknown): value is StateSchema<any>;
204
200
  }
205
201
  type AnyStateSchema = StateSchema<any>;
206
202
  //#endregion
207
- export { AnyStateSchema, InferStateSchemaUpdate, InferStateSchemaValue, StateSchema, StateSchemaField, StateSchemaFieldsToStateDefinition, StateSchemaInit };
203
+ export { AnyStateSchema, InferStateSchemaUpdate, InferStateSchemaValue, StateSchema, StateSchemaField, StateSchemaFields, StateSchemaFieldsToStateDefinition };
208
204
  //# sourceMappingURL=schema.d.cts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.cts","names":["JSONSchema","RunnableLike","BaseChannel","SerializableSchema","ReducedValue","UntrackedValue","STATE_SCHEMA_SYMBOL","StateSchemaFieldToChannel","F","V","I","O","StateSchemaFieldsToStateDefinition","StateSchemaInit","TInit","K","StateSchemaField","Input","Output","InferStateSchemaValue","TValue","TOutput","InferStateSchemaUpdate","TInput","StateSchema","Record","T","Promise","AnyStateSchema"],"sources":["../../src/state/schema.d.ts"],"sourcesContent":["import type { JSONSchema } from \"@langchain/core/utils/json_schema\";\nimport type { RunnableLike } from \"../pregel/runnable_types.js\";\nimport { BaseChannel } from \"../channels/index.js\";\nimport type { SerializableSchema } from \"./types.js\";\nimport { ReducedValue } from \"./values/reduced.js\";\nimport { UntrackedValue } from \"./values/untracked.js\";\ndeclare const STATE_SCHEMA_SYMBOL: unique symbol;\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<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>;\n/**\n * Converts a StateSchema \"init\" object (field map) into a strongly-typed\n * State Definition object, where each key 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 TInit - The mapping of field names to StateSchema field types.\n * @returns An object type mapping keys to channel types.\n *\n * @see StateSchemaFieldToChannel\n */\nexport type StateSchemaFieldsToStateDefinition<TInit extends StateSchemaInit> = {\n [K in keyof TInit]: StateSchemaFieldToChannel<TInit[K]>;\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> = ReducedValue<Input, Output> | UntrackedValue<Output> | SerializableSchema<Input, Output>;\n/**\n * Init object for StateSchema constructor.\n * Uses `any` to allow variance in generic types (e.g., ReducedValue<string, string[]>).\n */\nexport type StateSchemaInit = {\n [key: string]: StateSchemaField<any, any>;\n};\n/**\n * Infer the State type from a StateSchemaInit.\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<TInit extends StateSchemaInit> = {\n [K in keyof TInit]: TInit[K] extends {\n ValueType: infer TValue;\n } ? TValue : TInit[K] extends UntrackedValue<infer TValue> ? TValue : TInit[K] extends SerializableSchema<unknown, infer TOutput> ? TOutput : never;\n};\n/**\n * Infer the Update type from a StateSchemaInit.\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<TInit extends StateSchemaInit> = {\n [K in keyof TInit]?: TInit[K] extends {\n InputType: infer TInput;\n } ? TInput : TInit[K] extends UntrackedValue<infer TValue> ? TValue : TInit[K] extends SerializableSchema<infer TInput, unknown> ? TInput : never;\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 declare class StateSchema<TInit extends StateSchemaInit> {\n readonly init: TInit;\n /**\n * Symbol for runtime identification.\n * @internal Used by isInstance for runtime type checking\n */\n private readonly [STATE_SCHEMA_SYMBOL];\n /**\n * Type declaration for the full state type.\n * Use: `typeof myState.State`\n */\n State: InferStateSchemaValue<TInit>;\n /**\n * Type declaration for the update type.\n * Use: `typeof myState.Update`\n */\n Update: InferStateSchemaUpdate<TInit>;\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 Node: RunnableLike<InferStateSchemaValue<TInit>, InferStateSchemaUpdate<TInit>>;\n constructor(init: TInit);\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 /**\n * Get the JSON schema for the full state type.\n * Used by Studio and API for schema introspection.\n */\n getJsonSchema(): JSONSchema;\n /**\n * Get the JSON schema for the update/input type.\n * All fields are optional in updates.\n */\n getInputJsonSchema(): JSONSchema;\n /**\n * Get the list of channel keys (excluding managed values).\n */\n getChannelKeys(): string[];\n /**\n * Get all keys (channels + managed values).\n */\n getAllKeys(): string[];\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 validateInput<T>(data: T): Promise<T>;\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<TInit extends StateSchemaInit>(value: StateSchema<TInit>): value is StateSchema<TInit>;\n static isInstance(value: unknown): value is StateSchema<any>;\n}\nexport type AnyStateSchema = StateSchema<any>;\nexport {};\n"],"mappings":";;;;;;;;cAMcM;;AADyC;AAyBvD;;;;;;;;;;;;;;;;;;;AA8BA;;AAA6DO,KA9BjDN,yBA8BiDM,CAAAA,CAAAA,CAAAA,GA9BlBL,CA8BkBK,SA9BRT,YA8BQS,CAAAA,KAAAA,EAAAA,EAAAA,KAAAA,EAAAA,CAAAA,GA9ByBX,WA8BzBW,CA9BqCJ,CA8BrCI,EA9BwCH,CA8BxCG,CAAAA,GA9B6CL,CA8B7CK,SA9BuDR,cA8BvDQ,CAAAA,KAAAA,EAAAA,CAAAA,GA9BiFX,WA8BjFW,CA9B6FJ,CA8B7FI,EA9BgGJ,CA8BhGI,CAAAA,GA9BqGL,CA8BrGK,SA9B+GV,kBA8B/GU,CAAAA,KAAAA,EAAAA,EAAAA,KAAAA,EAAAA,CAAAA,GA9BsJX,WA8BtJW,CA9BkKF,CA8BlKE,EA9BqKH,CA8BrKG,CAAAA,GA9B0KX,WA8B1KW,CAAAA,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,CA2EZU,CAAAA,SAAAA;EAKEzB,SAAAA,EAAAA,KAAAA,OAAAA;IA9EbuB,MAmFkBvB,GAnFTc,KAmFSd,CAnFHe,CAmFGf,CAAAA,SAnFQK,cAmFRL,CAAAA,KAAAA,OAAAA,CAAAA,GAnFuCoB,MAmFvCpB,GAnFgDc,KAmFhDd,CAnFsDe,CAmFtDf,CAAAA,SAnFiEG,kBAmFjEH,CAAAA,KAAAA,OAAAA,EAAAA,OAAAA,CAAAA,GAnF6GuB,MAmF7GvB,GAAAA,KAAAA;;;;;;;;;;AA0B1B;;;;;;;;;;;;;;;;;;;;;;;;cA1EqBwB,0BAA0BX;iBAC5BC;;;;;oBAKGR,mBAAAA;;;;;SAKXa,sBAAsBL;;;;;UAKrBQ,uBAAuBR;;;;;;;;;;;;;;;;QAgBzBb,aAAakB,sBAAsBL,QAAQQ,uBAAuBR;oBACtDA;;;;;iBAKHW,eAAevB;;;;;mBAKbF;;;;;wBAKKA;;;;;;;;;;;;;;;;yBAgBC0B,IAAIC,QAAQD;;;;;;;kCAOHb,wBAAwBW,YAAYV,kBAAkBU,YAAYV;8CACtDU;;KAEpCI,cAAAA,GAAiBJ"}
1
+ {"version":3,"file":"schema.d.cts","names":["JSONSchema","RunnableLike","BaseChannel","SerializableSchema","ReducedValue","UntrackedValue","STATE_SCHEMA_SYMBOL","StateSchemaFieldToChannel","F","V","I","O","StateSchemaFieldsToStateDefinition","StateSchemaFields","TFields","K","StateSchemaField","Input","Output","InferStateSchemaValue","TOutput","InferStateSchemaUpdate","TInput","StateSchema","Record","T","Promise","AnyStateSchema"],"sources":["../../src/state/schema.d.ts"],"sourcesContent":["import type { JSONSchema } from \"@langchain/core/utils/json_schema\";\nimport type { RunnableLike } from \"../pregel/runnable_types.js\";\nimport { BaseChannel } from \"../channels/index.js\";\nimport type { SerializableSchema } from \"./types.js\";\nimport { ReducedValue } from \"./values/reduced.js\";\nimport { UntrackedValue } from \"./values/untracked.js\";\ndeclare const STATE_SCHEMA_SYMBOL: unique symbol;\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<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>;\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<TFields extends StateSchemaFields> = {\n [K in keyof TFields]: StateSchemaFieldToChannel<TFields[K]>;\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> = ReducedValue<Input, Output> | UntrackedValue<Output> | SerializableSchema<Input, Output>;\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 * 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> ? TFields[K][\"ValueType\"] : TFields[K] extends UntrackedValue<any> ? TFields[K][\"ValueType\"] : TFields[K] extends SerializableSchema<any, infer TOutput> ? TOutput : never;\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> ? TFields[K][\"InputType\"] : TFields[K] extends UntrackedValue<any> ? TFields[K][\"ValueType\"] : TFields[K] extends SerializableSchema<infer TInput, any> ? TInput : never;\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 declare class StateSchema<TFields extends StateSchemaFields> {\n readonly fields: TFields;\n /**\n * Symbol for runtime identification.\n * @internal Used by isInstance for runtime type checking\n */\n private readonly [STATE_SCHEMA_SYMBOL];\n /**\n * Type declaration for the full state type.\n * Use: `typeof myState.State`\n */\n State: InferStateSchemaValue<TFields>;\n /**\n * Type declaration for the update type.\n * Use: `typeof myState.Update`\n */\n Update: InferStateSchemaUpdate<TFields>;\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 Node: RunnableLike<InferStateSchemaValue<TFields>, InferStateSchemaUpdate<TFields>>;\n constructor(fields: TFields);\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 /**\n * Get the JSON schema for the full state type.\n * Used by Studio and API for schema introspection.\n */\n getJsonSchema(): JSONSchema;\n /**\n * Get the JSON schema for the update/input type.\n * All fields are optional in updates.\n */\n getInputJsonSchema(): JSONSchema;\n /**\n * Get the list of channel keys (excluding managed values).\n */\n getChannelKeys(): string[];\n /**\n * Get all keys (channels + managed values).\n */\n getAllKeys(): string[];\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 validateInput<T>(data: T): Promise<T>;\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>(value: StateSchema<TFields>): value is StateSchema<TFields>;\n static isInstance(value: unknown): value is StateSchema<any>;\n}\nexport type AnyStateSchema = StateSchema<any>;\nexport {};\n"],"mappings":";;;;;;;;cAMcM;;AADyC;AAyBvD;;;;;;;;;;;;;;;;;;;AA8BA;;AAA+DO,KA9BnDN,yBA8BmDM,CAAAA,CAAAA,CAAAA,GA9BpBL,CA8BoBK,SA9BVT,YA8BUS,CAAAA,KAAAA,EAAAA,EAAAA,KAAAA,EAAAA,CAAAA,GA9BuBX,WA8BvBW,CA9BmCJ,CA8BnCI,EA9BsCH,CA8BtCG,CAAAA,GA9B2CL,CA8B3CK,SA9BqDR,cA8BrDQ,CAAAA,KAAAA,EAAAA,CAAAA,GA9B+EX,WA8B/EW,CA9B2FJ,CA8B3FI,EA9B8FJ,CA8B9FI,CAAAA,GA9BmGL,CA8BnGK,SA9B6GV,kBA8B7GU,CAAAA,KAAAA,EAAAA,EAAAA,KAAAA,EAAAA,CAAAA,GA9BoJX,WA8BpJW,CA9BgKF,CA8BhKE,EA9BmKH,CA8BnKG,CAAAA,GA9BwKX,WA8BxKW,CAAAA,OAAAA,EAAAA,OAAAA,CAAAA;;;;;;AAO/D;;;;;;;;;;;;AAKA;AAWA;;;;;;;;;;;AACmHR,KAxBvGO,kCAwBuGP,CAAAA,gBAxBpDQ,iBAwBoDR,CAAAA,GAAAA,QAAsBS,MAvBzHA,OAuByHA,GAvB/GP,yBAuB+GO,CAvBrFA,OAuBqFA,CAvB7EC,CAuB6ED,CAAAA,CAAAA;;;;;AAA6F,KAjB1NE,gBAiB0N,CAAA,QAAA,OAAA,EAAA,SAjB/KC,KAiB+K,CAAA,GAjBtKb,YAiBsK,CAjBzJa,KAiByJ,EAjBlJC,MAiBkJ,CAAA,GAjBxIb,cAiBwI,CAjBzHa,MAiByH,CAAA,GAjB/Gf,kBAiB+G,CAjB5Fc,KAiB4F,EAjBrFC,MAiBqF,CAAA;AAUtO;;;;AAC2BJ,KAvBfD,iBAAAA,GAuB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;;;AA0DZ;;;;;;;;;;;;;;cA1EqBE,4BAA4BV;mBAC5BC;;;;;oBAKCR,mBAAAA;;;;;SAKXa,sBAAsBL;;;;;UAKrBO,uBAAuBP;;;;;;;;;;;;;;;;QAgBzBb,aAAakB,sBAAsBL,UAAUO,uBAAuBP;sBACtDA;;;;;iBAKLU,eAAetB;;;;;mBAKbF;;;;;wBAKKA;;;;;;;;;;;;;;;;yBAgBCyB,IAAIC,QAAQD;;;;;;;oCAODZ,0BAA0BU,YAAYT,oBAAoBS,YAAYT;8CAC5DS;;KAEpCI,cAAAA,GAAiBJ"}
@@ -32,8 +32,8 @@ declare const STATE_SCHEMA_SYMBOL: unique symbol;
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
34
  /**
35
- * Converts a StateSchema "init" object (field map) into a strongly-typed
36
- * State Definition object, where each key is mapped to its channel type.
35
+ * Converts StateSchema fields into a strongly-typed
36
+ * State Definition object, where each field is mapped to its channel type.
37
37
  *
38
38
  * This utility type is used internally to create the shape of the state channels for a given schema,
39
39
  * substituting each field with the result of `StateSchemaFieldToChannel`.
@@ -55,12 +55,12 @@ type StateSchemaFieldToChannel<F> = F extends ReducedValue<infer V, infer I> ? B
55
55
  * }
56
56
  * ```
57
57
  *
58
- * @template TInit - The mapping of field names to StateSchema field types.
59
- * @returns An object type mapping keys to channel types.
58
+ * @template TFields - The mapping of field names to StateSchema field types.
59
+ * @returns An object type mapping field names to channel types.
60
60
  *
61
61
  * @see StateSchemaFieldToChannel
62
62
  */
63
- type StateSchemaFieldsToStateDefinition<TInit extends StateSchemaInit> = { [K in keyof TInit]: StateSchemaFieldToChannel<TInit[K]> };
63
+ type StateSchemaFieldsToStateDefinition<TFields extends StateSchemaFields> = { [K in keyof TFields]: StateSchemaFieldToChannel<TFields[K]> };
64
64
  /**
65
65
  * Valid field types for StateSchema.
66
66
  * Either a LangGraph state value type or a raw schema (e.g., Zod schema).
@@ -70,31 +70,27 @@ type StateSchemaField<Input = unknown, Output = Input> = ReducedValue<Input, Out
70
70
  * Init object for StateSchema constructor.
71
71
  * Uses `any` to allow variance in generic types (e.g., ReducedValue<string, string[]>).
72
72
  */
73
- type StateSchemaInit = {
73
+ type StateSchemaFields = {
74
74
  [key: string]: StateSchemaField<any, any>;
75
75
  };
76
76
  /**
77
- * Infer the State type from a StateSchemaInit.
77
+ * Infer the State type from a StateSchemaFields.
78
78
  * This is the type of the full state object.
79
79
  *
80
80
  * - ReducedValue<Value, Input> → Value (the stored type)
81
81
  * - UntrackedValue<Value> → Value
82
82
  * - SerializableSchema<Input, Output> → Output (the validated type)
83
83
  */
84
- type InferStateSchemaValue<TInit extends StateSchemaInit> = { [K in keyof TInit]: TInit[K] extends {
85
- ValueType: infer TValue;
86
- } ? TValue : TInit[K] extends UntrackedValue<infer TValue> ? TValue : TInit[K] extends SerializableSchema<unknown, infer TOutput> ? TOutput : never };
84
+ type InferStateSchemaValue<TFields extends StateSchemaFields> = { [K in keyof TFields]: TFields[K] extends ReducedValue<any, any> ? TFields[K]["ValueType"] : TFields[K] extends UntrackedValue<any> ? TFields[K]["ValueType"] : TFields[K] extends SerializableSchema<any, infer TOutput> ? TOutput : never };
87
85
  /**
88
- * Infer the Update type from a StateSchemaInit.
86
+ * Infer the Update type from a StateSchemaFields.
89
87
  * This is the type for partial updates to state.
90
88
  *
91
89
  * - ReducedValue<Value, Input> → Input (the reducer input type)
92
90
  * - UntrackedValue<Value> → Value
93
91
  * - SerializableSchema<Input, Output> → Input (what you provide)
94
92
  */
95
- type InferStateSchemaUpdate<TInit extends StateSchemaInit> = { [K in keyof TInit]?: TInit[K] extends {
96
- InputType: infer TInput;
97
- } ? TInput : TInit[K] extends UntrackedValue<infer TValue> ? TValue : TInit[K] extends SerializableSchema<infer TInput, unknown> ? TInput : never };
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 };
98
94
  /**
99
95
  * StateSchema provides a unified API for defining LangGraph state schemas.
100
96
  *
@@ -128,8 +124,8 @@ type InferStateSchemaUpdate<TInit extends StateSchemaInit> = { [K in keyof TInit
128
124
  * const graph = new StateGraph(AgentState);
129
125
  * ```
130
126
  */
131
- declare class StateSchema<TInit extends StateSchemaInit> {
132
- readonly init: TInit;
127
+ declare class StateSchema<TFields extends StateSchemaFields> {
128
+ readonly fields: TFields;
133
129
  /**
134
130
  * Symbol for runtime identification.
135
131
  * @internal Used by isInstance for runtime type checking
@@ -139,12 +135,12 @@ declare class StateSchema<TInit extends StateSchemaInit> {
139
135
  * Type declaration for the full state type.
140
136
  * Use: `typeof myState.State`
141
137
  */
142
- State: InferStateSchemaValue<TInit>;
138
+ State: InferStateSchemaValue<TFields>;
143
139
  /**
144
140
  * Type declaration for the update type.
145
141
  * Use: `typeof myState.Update`
146
142
  */
147
- Update: InferStateSchemaUpdate<TInit>;
143
+ Update: InferStateSchemaUpdate<TFields>;
148
144
  /**
149
145
  * Type declaration for node functions.
150
146
  * Use: `typeof myState.Node` to type node functions outside the graph builder.
@@ -160,8 +156,8 @@ declare class StateSchema<TInit extends StateSchemaInit> {
160
156
  * };
161
157
  * ```
162
158
  */
163
- Node: RunnableLike<InferStateSchemaValue<TInit>, InferStateSchemaUpdate<TInit>>;
164
- constructor(init: TInit);
159
+ Node: RunnableLike<InferStateSchemaValue<TFields>, InferStateSchemaUpdate<TFields>>;
160
+ constructor(fields: TFields);
165
161
  /**
166
162
  * Get the channel definitions for use with StateGraph.
167
163
  * This converts the StateSchema fields into BaseChannel instances.
@@ -199,10 +195,10 @@ declare class StateSchema<TInit extends StateSchemaInit> {
199
195
  * @param value - The value to check.
200
196
  * @returns True if the value is a StateSchema instance with the correct runtime tag.
201
197
  */
202
- static isInstance<TInit extends StateSchemaInit>(value: StateSchema<TInit>): value is StateSchema<TInit>;
198
+ static isInstance<TFields extends StateSchemaFields>(value: StateSchema<TFields>): value is StateSchema<TFields>;
203
199
  static isInstance(value: unknown): value is StateSchema<any>;
204
200
  }
205
201
  type AnyStateSchema = StateSchema<any>;
206
202
  //#endregion
207
- export { AnyStateSchema, InferStateSchemaUpdate, InferStateSchemaValue, StateSchema, StateSchemaField, StateSchemaFieldsToStateDefinition, StateSchemaInit };
203
+ export { AnyStateSchema, InferStateSchemaUpdate, InferStateSchemaValue, StateSchema, StateSchemaField, StateSchemaFields, StateSchemaFieldsToStateDefinition };
208
204
  //# sourceMappingURL=schema.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"schema.d.ts","names":["JSONSchema","RunnableLike","BaseChannel","SerializableSchema","ReducedValue","UntrackedValue","STATE_SCHEMA_SYMBOL","StateSchemaFieldToChannel","F","V","I","O","StateSchemaFieldsToStateDefinition","StateSchemaInit","TInit","K","StateSchemaField","Input","Output","InferStateSchemaValue","TValue","TOutput","InferStateSchemaUpdate","TInput","StateSchema","Record","T","Promise","AnyStateSchema"],"sources":["../../src/state/schema.d.ts"],"sourcesContent":["import type { JSONSchema } from \"@langchain/core/utils/json_schema\";\nimport type { RunnableLike } from \"../pregel/runnable_types.js\";\nimport { BaseChannel } from \"../channels/index.js\";\nimport type { SerializableSchema } from \"./types.js\";\nimport { ReducedValue } from \"./values/reduced.js\";\nimport { UntrackedValue } from \"./values/untracked.js\";\ndeclare const STATE_SCHEMA_SYMBOL: unique symbol;\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<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>;\n/**\n * Converts a StateSchema \"init\" object (field map) into a strongly-typed\n * State Definition object, where each key 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 TInit - The mapping of field names to StateSchema field types.\n * @returns An object type mapping keys to channel types.\n *\n * @see StateSchemaFieldToChannel\n */\nexport type StateSchemaFieldsToStateDefinition<TInit extends StateSchemaInit> = {\n [K in keyof TInit]: StateSchemaFieldToChannel<TInit[K]>;\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> = ReducedValue<Input, Output> | UntrackedValue<Output> | SerializableSchema<Input, Output>;\n/**\n * Init object for StateSchema constructor.\n * Uses `any` to allow variance in generic types (e.g., ReducedValue<string, string[]>).\n */\nexport type StateSchemaInit = {\n [key: string]: StateSchemaField<any, any>;\n};\n/**\n * Infer the State type from a StateSchemaInit.\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<TInit extends StateSchemaInit> = {\n [K in keyof TInit]: TInit[K] extends {\n ValueType: infer TValue;\n } ? TValue : TInit[K] extends UntrackedValue<infer TValue> ? TValue : TInit[K] extends SerializableSchema<unknown, infer TOutput> ? TOutput : never;\n};\n/**\n * Infer the Update type from a StateSchemaInit.\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<TInit extends StateSchemaInit> = {\n [K in keyof TInit]?: TInit[K] extends {\n InputType: infer TInput;\n } ? TInput : TInit[K] extends UntrackedValue<infer TValue> ? TValue : TInit[K] extends SerializableSchema<infer TInput, unknown> ? TInput : never;\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 declare class StateSchema<TInit extends StateSchemaInit> {\n readonly init: TInit;\n /**\n * Symbol for runtime identification.\n * @internal Used by isInstance for runtime type checking\n */\n private readonly [STATE_SCHEMA_SYMBOL];\n /**\n * Type declaration for the full state type.\n * Use: `typeof myState.State`\n */\n State: InferStateSchemaValue<TInit>;\n /**\n * Type declaration for the update type.\n * Use: `typeof myState.Update`\n */\n Update: InferStateSchemaUpdate<TInit>;\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 Node: RunnableLike<InferStateSchemaValue<TInit>, InferStateSchemaUpdate<TInit>>;\n constructor(init: TInit);\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 /**\n * Get the JSON schema for the full state type.\n * Used by Studio and API for schema introspection.\n */\n getJsonSchema(): JSONSchema;\n /**\n * Get the JSON schema for the update/input type.\n * All fields are optional in updates.\n */\n getInputJsonSchema(): JSONSchema;\n /**\n * Get the list of channel keys (excluding managed values).\n */\n getChannelKeys(): string[];\n /**\n * Get all keys (channels + managed values).\n */\n getAllKeys(): string[];\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 validateInput<T>(data: T): Promise<T>;\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<TInit extends StateSchemaInit>(value: StateSchema<TInit>): value is StateSchema<TInit>;\n static isInstance(value: unknown): value is StateSchema<any>;\n}\nexport type AnyStateSchema = StateSchema<any>;\nexport {};\n"],"mappings":";;;;;;;;cAMcM;;AADyC;AAyBvD;;;;;;;;;;;;;;;;;;;AA8BA;;AAA6DO,KA9BjDN,yBA8BiDM,CAAAA,CAAAA,CAAAA,GA9BlBL,CA8BkBK,SA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SerializableSchema","ReducedValue","UntrackedValue","STATE_SCHEMA_SYMBOL","StateSchemaFieldToChannel","F","V","I","O","StateSchemaFieldsToStateDefinition","StateSchemaFields","TFields","K","StateSchemaField","Input","Output","InferStateSchemaValue","TOutput","InferStateSchemaUpdate","TInput","StateSchema","Record","T","Promise","AnyStateSchema"],"sources":["../../src/state/schema.d.ts"],"sourcesContent":["import type { JSONSchema } from \"@langchain/core/utils/json_schema\";\nimport type { RunnableLike } from \"../pregel/runnable_types.js\";\nimport { BaseChannel } from \"../channels/index.js\";\nimport type { SerializableSchema } from \"./types.js\";\nimport { ReducedValue } from \"./values/reduced.js\";\nimport { UntrackedValue } from \"./values/untracked.js\";\ndeclare const STATE_SCHEMA_SYMBOL: unique symbol;\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<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>;\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<TFields extends StateSchemaFields> = {\n [K in keyof TFields]: StateSchemaFieldToChannel<TFields[K]>;\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> = ReducedValue<Input, Output> | UntrackedValue<Output> | SerializableSchema<Input, Output>;\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 * 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> ? TFields[K][\"ValueType\"] : TFields[K] extends UntrackedValue<any> ? TFields[K][\"ValueType\"] : TFields[K] extends SerializableSchema<any, infer TOutput> ? TOutput : never;\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> ? TFields[K][\"InputType\"] : TFields[K] extends UntrackedValue<any> ? TFields[K][\"ValueType\"] : TFields[K] extends SerializableSchema<infer TInput, any> ? TInput : never;\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 declare class StateSchema<TFields extends StateSchemaFields> {\n readonly fields: TFields;\n /**\n * Symbol for runtime identification.\n * @internal Used by isInstance for runtime type checking\n */\n private readonly [STATE_SCHEMA_SYMBOL];\n /**\n * Type declaration for the full state type.\n * Use: `typeof myState.State`\n */\n State: InferStateSchemaValue<TFields>;\n /**\n * Type declaration for the update type.\n * Use: `typeof myState.Update`\n */\n Update: InferStateSchemaUpdate<TFields>;\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 Node: RunnableLike<InferStateSchemaValue<TFields>, InferStateSchemaUpdate<TFields>>;\n constructor(fields: TFields);\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 /**\n * Get the JSON schema for the full state type.\n * Used by Studio and API for schema introspection.\n */\n getJsonSchema(): JSONSchema;\n /**\n * Get the JSON schema for the update/input type.\n * All fields are optional in updates.\n */\n getInputJsonSchema(): JSONSchema;\n /**\n * Get the list of channel keys (excluding managed values).\n */\n getChannelKeys(): string[];\n /**\n * Get all keys (channels + managed values).\n */\n getAllKeys(): string[];\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 validateInput<T>(data: T): Promise<T>;\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>(value: StateSchema<TFields>): value is StateSchema<TFields>;\n static isInstance(value: unknown): value is StateSchema<any>;\n}\nexport type AnyStateSchema = StateSchema<any>;\nexport {};\n"],"mappings":";;;;;;;;cAMcM;;AADyC;AAyBvD;;;;;;;;;;;;;;;;;;;AA8BA;;AAA+DO,KA9BnDN,yBA8BmDM,CAAAA,CAAAA,CAAAA,GA9BpBL,CA8BoBK,SA9BVT,YA8BUS,CAAAA,KAAAA,EAAAA,EAAAA,KAAAA,EAAAA,CAAAA,GA9BuBX,WA8BvBW,CA9BmCJ,CA8BnCI,EA9BsCH,CA8BtCG,CAAAA,GA9B2CL,CA8B3CK,SA9BqDR,cA8BrDQ,CAAAA,KAAAA,EAAAA,CAAAA,GA9B+EX,WA8B/EW,CA9B2FJ,CA8B3FI,EA9B8FJ,CA8B9FI,CAAAA,GA9BmGL,CA8BnGK,SA9B6GV,kBA8B7GU,CAAAA,KAAAA,EAAAA,EAAAA,KAAAA,EAAAA,CAAAA,GA9BoJX,WA8BpJW,CA9BgKF,CA8BhKE,EA9BmKH,CA8BnKG,CAAAA,GA9BwKX,WA8BxKW,CAAAA,OAAAA,EAAAA,OAAAA,CAAAA;;;;;;AAO/D;;;;;;;;;;;;AAKA;AAWA;;;;;;;;;;;AACmHR,KAx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AA,SAnDkCjB,YAmDlCiB,CAAAA,GAAAA,EAAAA,GAAAA,CAAAA,GAnD2DP,OAmD3DO,CAnDmEN,CAmDnEM,CAAAA,CAAAA,WAAAA,CAAAA,GAnDqFP,OAmDrFO,CAnD6FN,CAmD7FM,CAAAA,SAnDwGhB,cAmDxGgB,CAAAA,GAAAA,CAAAA,GAnD8HP,OAmD9HO,CAnDsIN,CAmDtIM,CAAAA,CAAAA,WAAAA,CAAAA,GAnDwJP,OAmDxJO,CAnDgKN,CAmDhKM,CAAAA,SAnD2KlB,kBAmD3KkB,CAAAA,KAAAA,OAAAA,EAAAA,GAAAA,CAAAA,GAnDmNC,MAmDnND,GAAAA,KAAAA;;;;;;;;;;;;;;;;;;;;AA0DZ;;;;;;;;;;;;;;cA1EqBE,4BAA4BV;mBAC5BC;;;;;oBAKCR,mBAAAA;;;;;SAKXa,sBAAsBL;;;;;UAKrBO,uBAAuBP;;;;;;;;;;;;;;;;QAgBzBb,aAAakB,sBAAsBL,UAAUO,uBAAuBP;sBACtDA;;;;;iBAKLU,eAAetB;;;;;mBAKbF;;;;;wBAKKA;;;;;;;;;;;;;;;;yBAgBCyB,IAAIC,QAAQD;;;;;;;oCAODZ,0BAA0BU,YAAYT,oBAAoBS,YAAYT;8CAC5DS;;KAEpCI,cAAAA,GAAiBJ"}
@@ -48,9 +48,8 @@ var StateSchema = class {
48
48
  * @internal Used by isInstance for runtime type checking
49
49
  */
50
50
  [STATE_SCHEMA_SYMBOL] = true;
51
- constructor(init) {
52
- this.init = init;
53
- this.init = init;
51
+ constructor(fields) {
52
+ this.fields = fields;
54
53
  }
55
54
  /**
56
55
  * Get the channel definitions for use with StateGraph.
@@ -58,7 +57,7 @@ var StateSchema = class {
58
57
  */
59
58
  getChannels() {
60
59
  const channels = {};
61
- for (const [key, value] of Object.entries(this.init)) if (ReducedValue.isInstance(value)) {
60
+ for (const [key, value] of Object.entries(this.fields)) if (ReducedValue.isInstance(value)) {
62
61
  const defaultGetter = getSchemaDefaultGetter(value.valueSchema);
63
62
  channels[key] = new BinaryOperatorAggregate(value.reducer, defaultGetter);
64
63
  } else if (UntrackedValue.isInstance(value)) {
@@ -78,7 +77,7 @@ var StateSchema = class {
78
77
  getJsonSchema() {
79
78
  const properties = {};
80
79
  const required = [];
81
- for (const [key, value] of Object.entries(this.init)) {
80
+ for (const [key, value] of Object.entries(this.fields)) {
82
81
  let fieldSchema;
83
82
  if (ReducedValue.isInstance(value)) {
84
83
  fieldSchema = getJsonSchemaFromSchema(value.valueSchema);
@@ -109,7 +108,7 @@ var StateSchema = class {
109
108
  */
110
109
  getInputJsonSchema() {
111
110
  const properties = {};
112
- for (const [key, value] of Object.entries(this.init)) {
111
+ for (const [key, value] of Object.entries(this.fields)) {
113
112
  let fieldSchema;
114
113
  if (ReducedValue.isInstance(value)) fieldSchema = getJsonSchemaFromSchema(value.inputSchema);
115
114
  else if (UntrackedValue.isInstance(value)) fieldSchema = value.schema ? getJsonSchemaFromSchema(value.schema) : void 0;
@@ -125,13 +124,13 @@ var StateSchema = class {
125
124
  * Get the list of channel keys (excluding managed values).
126
125
  */
127
126
  getChannelKeys() {
128
- return Object.entries(this.init).map(([key]) => key);
127
+ return Object.entries(this.fields).map(([key]) => key);
129
128
  }
130
129
  /**
131
130
  * Get all keys (channels + managed values).
132
131
  */
133
132
  getAllKeys() {
134
- return Object.keys(this.init);
133
+ return Object.keys(this.fields);
135
134
  }
136
135
  /**
137
136
  * Validate input data against the schema.
@@ -144,7 +143,7 @@ var StateSchema = class {
144
143
  if (data == null || typeof data !== "object") return data;
145
144
  const result = {};
146
145
  for (const [key, value] of Object.entries(data)) {
147
- const fieldDef = this.init[key];
146
+ const fieldDef = this.fields[key];
148
147
  if (fieldDef === void 0) {
149
148
  result[key] = value;
150
149
  continue;
@@ -1 +1 @@
1
- {"version":3,"file":"schema.js","names":[],"sources":["../../src/state/schema.ts"],"sourcesContent":["import 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 a StateSchema \"init\" object (field map) into a strongly-typed\n * State Definition object, where each key 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 TInit - The mapping of field names to StateSchema field types.\n * @returns An object type mapping keys to channel types.\n *\n * @see StateSchemaFieldToChannel\n */\nexport type StateSchemaFieldsToStateDefinition<TInit extends StateSchemaInit> =\n {\n [K in keyof TInit]: StateSchemaFieldToChannel<TInit[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 StateSchemaInit = {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n [key: string]: StateSchemaField<any, any>;\n};\n\n/**\n * Infer the State type from a StateSchemaInit.\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<TInit extends StateSchemaInit> = {\n [K in keyof TInit]: TInit[K] extends { ValueType: infer TValue }\n ? TValue\n : TInit[K] extends UntrackedValue<infer TValue>\n ? TValue\n : TInit[K] extends SerializableSchema<unknown, infer TOutput>\n ? TOutput\n : never;\n};\n\n/**\n * Infer the Update type from a StateSchemaInit.\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<TInit extends StateSchemaInit> = {\n [K in keyof TInit]?: TInit[K] extends { InputType: infer TInput }\n ? TInput\n : TInit[K] extends UntrackedValue<infer TValue>\n ? TValue\n : TInit[K] extends SerializableSchema<infer TInput, unknown>\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<TInit extends StateSchemaInit> {\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<TInit>;\n\n /**\n * Type declaration for the update type.\n * Use: `typeof myState.Update`\n */\n declare Update: InferStateSchemaUpdate<TInit>;\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<TInit>,\n InferStateSchemaUpdate<TInit>\n >;\n\n constructor(readonly init: TInit) {\n this.init = init;\n }\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.init)) {\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.init)) {\n let fieldSchema: JSONSchema | undefined;\n\n if (ReducedValue.isInstance(value)) {\n fieldSchema = getJsonSchemaFromSchema(value.valueSchema) as JSONSchema;\n if (fieldSchema && 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.init)) {\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.init).map(([key]) => key);\n }\n\n /**\n * Get all keys (channels + managed values).\n */\n getAllKeys(): string[] {\n return Object.keys(this.init);\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.init[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<TInit extends StateSchemaInit>(\n value: StateSchema<TInit>\n ): value is StateSchema<TInit>;\n\n // eslint-disable-next-line @typescript-eslint/no-explicit-any\n static isInstance(value: unknown): value is StateSchema<any>;\n\n static isInstance<TInit extends StateSchemaInit>(\n value: unknown\n ): value is StateSchema<TInit> {\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\n// eslint-disable-next-line @typescript-eslint/no-explicit-any\nexport type AnyStateSchema = StateSchema<any>;\n"],"mappings":";;;;;;;;;;AAiBA,MAAM,sBAAsB,OAAO,IAAI,+BAA+B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AA6JtE,IAAa,cAAb,MAAwD;;;;;CAMtD,CAAkB,uBAAuB;CAkCzC,YAAY,AAAS,MAAa;EAAb;AACnB,OAAK,OAAO;;;;;;CAOd,cAA2C;EACzC,MAAM,WAAwC,EAAE;AAEhD,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,KAAK,CAClD,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;A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O,GACtC;YACK,iBAAiB,MAAM,CAChC,eAAc,wBAAwB,MAAM;AAG9C,OAAI,YACF,YAAW,OAAO;;AAItB,SAAO;GACL,MAAM;GACN;GACD;;;;;CAMH,iBAA2B;AACzB,SAAO,OAAO,QAAQ,KAAK,KAAK,CAAC,KAAK,CAAC,SAAS,IAAI;;;;;CAMtD,aAAuB;AACrB,SAAO,OAAO,KAAK,KAAK,KAAK;;;;;;;;;CAU/B,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,KAAK;AAE3B,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;;CAgBT,OAAO,WACL,OAC6B;AAC7B,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 { 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 if (fieldSchema && 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,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S,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 +1 @@
1
- {"version":3,"file":"reduced.cjs","names":[],"sources":["../../../src/state/values/reduced.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n\n/**\n * Symbol for runtime identification of ReducedValue instances.\n */\nexport const REDUCED_VALUE_SYMBOL = Symbol.for(\"langgraph.state.reduced_value\");\n\ninterface ReducedValueInitBase<Value = unknown> {\n /**\n * The reducer function that determines how new input values are combined with the current state.\n * Receives the current output value and a new input value, and must return the updated output.\n *\n * @param current - The current value held in state.\n * @param next - The new input value to apply to the reducer.\n * @returns The next value to be stored in state.\n *\n * @remarks\n * - The logic for updating state in response to new inputs lives in this function.\n */\n reducer: (current: Value, next: Value) => Value;\n\n /**\n * Optional extra fields to be added to the exported JSON Schema for documentation or additional constraints.\n *\n * @remarks\n * - Use this property to attach metadata or documentation to the generated JSON Schema representation\n * of this value.\n * - These fields are merged into the generated schema, which can assist with code generation, UI hints,\n * or external documentation.\n */\n jsonSchemaExtra?: Record<string, unknown>;\n}\n\ninterface ReducedValueInitWithSchema<Value = unknown, Input = Value> {\n /**\n * Schema describing the type and validation logic for reducer input values.\n *\n * @remarks\n * - If provided, new values passed to the reducer will be validated using this schema before reduction.\n * - This allows the reducer to accept inputs distinct from the type stored in the state (output type).\n */\n inputSchema: SerializableSchema<unknown, Input>;\n\n /**\n * The reducer function that determines how new input values are combined with the current state.\n * Receives the current output value and a new input value (validated using `inputSchema`), and returns the updated output.\n *\n * @param current - The current value held in state.\n * @param next - The new validated input value to be applied.\n * @returns The next value to be stored in state.\n *\n * @remarks\n * - The logic for updating state in response to new inputs lives in this function.\n */\n reducer: (current: Value, next: Input) => Value;\n\n /**\n * Optional extra fields to be added to the exported JSON Schema for documentation or additional constraints.\n *\n * @remarks\n * - Use this property to attach metadata or documentation to the generated JSON Schema representation\n * of this value.\n * - These fields are merged into the generated schema, which can assist with code generation, UI hints,\n * or external documentation.\n */\n jsonSchemaExtra?: Record<string, unknown>;\n}\n\n/**\n * Initialization options for {@link ReducedValue}.\n *\n * Two forms are supported:\n * 1. Provide only a reducer (and optionally `jsonSchemaExtra`)—in this case, the reducer's inputs are validated using the output value schema.\n * 2. Provide an explicit `inputSchema` field to distinguish the reducer's input type from the stored/output type.\n *\n * @template Value - The type of value stored and produced after reduction.\n * @template Input - The type of inputs accepted by the reducer.\n *\n * @property inputSchema - The schema describing reducer inputs. If omitted, will use the value schema.\n * @property reducer - A function that receives the current output value and a new input, and returns the new output.\n * @property jsonSchemaExtra - (Optional) Extra fields to merge into the exported JSON Schema for documentation or additional constraints.\n */\nexport type ReducedValueInit<Value = unknown, Input = Value> =\n | ReducedValueInitWithSchema<Value, Input>\n | ReducedValueInitBase<Value>;\n\n/**\n * Represents a state field whose value is computed and updated using a reducer function.\n *\n * {@link ReducedValue} allows you to define accumulators, counters, aggregators, or other fields\n * whose value is determined incrementally by applying a reducer to incoming updates.\n *\n * Each time a new input is provided, the reducer function is called with the current output\n * and the new input, producing an updated value. Input validation can be controlled separately\n * from output validation by providing an explicit input schema.\n *\n * @template Value - The type of the value stored in state and produced by reduction.\n * @template Input - The type of updates accepted by the reducer.\n *\n * @example\n * // Accumulator with distinct input validation\n * const Sum = new ReducedValue(z.number(), {\n * inputSchema: z.number().min(1),\n * reducer: (total, toAdd) => total + toAdd\n * });\n *\n * @example\n * // Simple running max, using only the value schema\n * const Max = new ReducedValue(z.number(), {\n * reducer: (current, next) => Math.max(current, next)\n * });\n */\nexport class ReducedValue<Value = unknown, Input = Value> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [REDUCED_VALUE_SYMBOL] = true as const;\n\n /**\n * The schema that describes the type of value stored in state (i.e., after reduction).\n * Note: We use `unknown` for the input type to allow schemas with `.default()` wrappers,\n * where the input type includes `undefined`.\n */\n readonly valueSchema: SerializableSchema<unknown, Value>;\n\n /**\n * The schema used to validate reducer inputs.\n * If not specified explicitly, this defaults to `valueSchema`.\n */\n readonly inputSchema: SerializableSchema<unknown, Input | Value>;\n\n /**\n * The reducer function that combines a current output value and an incoming input.\n */\n readonly reducer: (current: Value, next: Input) => Value;\n\n /**\n * Optional extra fields to merge into the generated JSON Schema (e.g., for documentation or constraints).\n */\n readonly jsonSchemaExtra?: Record<string, unknown>;\n\n /**\n * Represents the value stored after all reductions.\n */\n declare ValueType: Value;\n\n /**\n * Represents the type that may be provided as input on each update.\n */\n declare InputType: Input;\n\n /**\n * Constructs a ReducedValue instance, which combines a value schema and a reducer function (plus optional input schema).\n *\n * @param valueSchema - The schema that describes the type of value stored in state (the \"running total\").\n * @param init - An object specifying the reducer function (required), inputSchema (optional), and jsonSchemaExtra (optional).\n */\n constructor(\n valueSchema: SerializableSchema<unknown, Value>,\n init: ReducedValueInitWithSchema<Value, Input>\n );\n\n constructor(\n valueSchema: SerializableSchema<unknown, Value>,\n init: ReducedValueInitBase<Value>\n );\n\n constructor(\n valueSchema: SerializableSchema<unknown, Value>,\n init: ReducedValueInit<Value, Input>\n ) {\n this.reducer = init.reducer as (current: Value, next: Input) => Value;\n this.jsonSchemaExtra = init.jsonSchemaExtra;\n this.valueSchema = valueSchema;\n this.inputSchema = \"inputSchema\" in init ? init.inputSchema : valueSchema;\n this.jsonSchemaExtra = init.jsonSchemaExtra;\n }\n\n /**\n * Type guard to check if a value is a ReducedValue instance.\n */\n static isInstance<Value = unknown, Input = Value>(\n value: ReducedValue<Value, Input>\n ): value is ReducedValue<Value, Input>;\n\n static isInstance(value: unknown): value is ReducedValue;\n\n static isInstance<Value = unknown, Input = Value>(\n value: ReducedValue<Value, Input> | unknown\n ): value is ReducedValue<Value, Input> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n REDUCED_VALUE_SYMBOL in value &&\n value[REDUCED_VALUE_SYMBOL] === true\n );\n }\n}\n"],"mappings":";;;;;AAKA,MAAa,uBAAuB,OAAO,IAAI,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2G/E,IAAa,eAAb,MAA0D;;;;;CAKxD,CAAoB,wBAAwB;;;;;;CAO5C,AAAS;;;;;CAMT,AAAS;;;;CAKT,AAAS;;;;CAKT,AAAS;CA4BT,YACE,aACA,MACA;AACA,OAAK,UAAU,KAAK;AACpB,OAAK,kBAAkB,KAAK;AAC5B,OAAK,cAAc;AACnB,OAAK,cAAc,iBAAiB,OAAO,KAAK,cAAc;AAC9D,OAAK,kBAAkB,KAAK;;CAY9B,OAAO,WACL,OACqC;AACrC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,wBAAwB,SACxB,MAAM,0BAA0B"}
1
+ {"version":3,"file":"reduced.cjs","names":[],"sources":["../../../src/state/values/reduced.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n\n/**\n * Symbol for runtime identification of ReducedValue instances.\n */\nexport const REDUCED_VALUE_SYMBOL = Symbol.for(\"langgraph.state.reduced_value\");\n\ninterface ReducedValueInitBase<Value = unknown> {\n /**\n * The reducer function that determines how new input values are combined with the current state.\n * Receives the current output value and a new input value, and must return the updated output.\n *\n * @param current - The current value held in state.\n * @param next - The new input value to apply to the reducer.\n * @returns The next value to be stored in state.\n *\n * @remarks\n * - The logic for updating state in response to new inputs lives in this function.\n */\n reducer: (current: Value, next: Value) => Value;\n\n /**\n * Optional extra fields to be added to the exported JSON Schema for documentation or additional constraints.\n *\n * @remarks\n * - Use this property to attach metadata or documentation to the generated JSON Schema representation\n * of this value.\n * - These fields are merged into the generated schema, which can assist with code generation, UI hints,\n * or external documentation.\n */\n jsonSchemaExtra?: Record<string, unknown>;\n}\n\ninterface ReducedValueInitWithSchema<Value = unknown, Input = Value> {\n /**\n * Schema describing the type and validation logic for reducer input values.\n *\n * @remarks\n * - If provided, new values passed to the reducer will be validated using this schema before reduction.\n * - This allows the reducer to accept inputs distinct from the type stored in the state (output type).\n */\n inputSchema: SerializableSchema<unknown, Input>;\n\n /**\n * The reducer function that determines how new input values are combined with the current state.\n * Receives the current output value and a new input value (validated using `inputSchema`), and returns the updated output.\n *\n * @param current - The current value held in state.\n * @param next - The new validated input value to be applied.\n * @returns The next value to be stored in state.\n *\n * @remarks\n * - The logic for updating state in response to new inputs lives in this function.\n */\n reducer: (current: Value, next: Input) => Value;\n\n /**\n * Optional extra fields to be added to the exported JSON Schema for documentation or additional constraints.\n *\n * @remarks\n * - Use this property to attach metadata or documentation to the generated JSON Schema representation\n * of this value.\n * - These fields are merged into the generated schema, which can assist with code generation, UI hints,\n * or external documentation.\n */\n jsonSchemaExtra?: Record<string, unknown>;\n}\n\n/**\n * Initialization options for {@link ReducedValue}.\n *\n * Two forms are supported:\n * 1. Provide only a reducer (and optionally `jsonSchemaExtra`)—in this case, the reducer's inputs are validated using the output value schema.\n * 2. Provide an explicit `inputSchema` field to distinguish the reducer's input type from the stored/output type.\n *\n * @template Value - The type of value stored and produced after reduction.\n * @template Input - The type of inputs accepted by the reducer.\n *\n * @property inputSchema - The schema describing reducer inputs. If omitted, will use the value schema.\n * @property reducer - A function that receives the current output value and a new input, and returns the new output.\n * @property jsonSchemaExtra - (Optional) Extra fields to merge into the exported JSON Schema for documentation or additional constraints.\n */\nexport type ReducedValueInit<Value = unknown, Input = Value> =\n | ReducedValueInitWithSchema<Value, Input>\n | ReducedValueInitBase<Value>;\n\n/**\n * Represents a state field whose value is computed and updated using a reducer function.\n *\n * {@link ReducedValue} allows you to define accumulators, counters, aggregators, or other fields\n * whose value is determined incrementally by applying a reducer to incoming updates.\n *\n * Each time a new input is provided, the reducer function is called with the current output\n * and the new input, producing an updated value. Input validation can be controlled separately\n * from output validation by providing an explicit input schema.\n *\n * @template Value - The type of the value stored in state and produced by reduction.\n * @template Input - The type of updates accepted by the reducer.\n *\n * @example\n * // Accumulator with distinct input validation\n * const Sum = new ReducedValue(z.number(), {\n * inputSchema: z.number().min(1),\n * reducer: (total, toAdd) => total + toAdd\n * });\n *\n * @example\n * // Simple running max, using only the value schema\n * const Max = new ReducedValue(z.number(), {\n * reducer: (current, next) => Math.max(current, next)\n * });\n */\nexport class ReducedValue<Value = unknown, Input = Value> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [REDUCED_VALUE_SYMBOL] = true as const;\n\n /**\n * The schema that describes the type of value stored in state (i.e., after reduction).\n * Note: We use `unknown` for the input type to allow schemas with `.default()` wrappers,\n * where the input type includes `undefined`.\n */\n readonly valueSchema: SerializableSchema<unknown, Value>;\n\n /**\n * The schema used to validate reducer inputs.\n * If not specified explicitly, this defaults to `valueSchema`.\n */\n readonly inputSchema: SerializableSchema<unknown, Input | Value>;\n\n /**\n * The reducer function that combines a current output value and an incoming input.\n */\n readonly reducer: (current: Value, next: Input) => Value;\n\n /**\n * Optional extra fields to merge into the generated JSON Schema (e.g., for documentation or constraints).\n */\n readonly jsonSchemaExtra?: Record<string, unknown>;\n\n /**\n * Represents the value stored after all reductions.\n */\n declare ValueType: Value;\n\n /**\n * Represents the type that may be provided as input on each update.\n */\n declare InputType: Input;\n\n /**\n * Constructs a ReducedValue instance, which combines a value schema and a reducer function (plus optional input schema).\n *\n * @param valueSchema - The schema that describes the type of value stored in state (the \"running total\").\n * @param init - An object specifying the reducer function (required), inputSchema (optional), and jsonSchemaExtra (optional).\n */\n constructor(\n valueSchema: SerializableSchema<unknown, Value>,\n init: ReducedValueInitWithSchema<Value, Input>\n );\n\n constructor(\n valueSchema: SerializableSchema<Input, Value>,\n init: ReducedValueInitBase<Value>\n );\n\n constructor(\n valueSchema: SerializableSchema<unknown, Value>,\n init: ReducedValueInit<Value, Input>\n ) {\n this.reducer = init.reducer as (current: Value, next: Input) => Value;\n this.jsonSchemaExtra = init.jsonSchemaExtra;\n this.valueSchema = valueSchema;\n this.inputSchema = \"inputSchema\" in init ? init.inputSchema : valueSchema;\n this.jsonSchemaExtra = init.jsonSchemaExtra;\n }\n\n /**\n * Type guard to check if a value is a ReducedValue instance.\n */\n static isInstance<Value = unknown, Input = Value>(\n value: ReducedValue<Value, Input>\n ): value is ReducedValue<Value, Input>;\n\n static isInstance(value: unknown): value is ReducedValue;\n\n static isInstance<Value = unknown, Input = Value>(\n value: ReducedValue<Value, Input> | unknown\n ): value is ReducedValue<Value, Input> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n REDUCED_VALUE_SYMBOL in value &&\n value[REDUCED_VALUE_SYMBOL] === true\n );\n }\n}\n"],"mappings":";;;;;AAKA,MAAa,uBAAuB,OAAO,IAAI,gCAAgC;;;;;;;;;;;;;;;;;;;;;;;;;;;AA2G/E,IAAa,eAAb,MAA0D;;;;;CAKxD,CAAoB,wBAAwB;;;;;;CAO5C,AAAS;;;;;CAMT,AAAS;;;;CAKT,AAAS;;;;CAKT,AAAS;CA4BT,YACE,aACA,MACA;AACA,OAAK,UAAU,KAAK;AACpB,OAAK,kBAAkB,KAAK;AAC5B,OAAK,cAAc;AACnB,OAAK,cAAc,iBAAiB,OAAO,KAAK,cAAc;AAC9D,OAAK,kBAAkB,KAAK;;CAY9B,OAAO,WACL,OACqC;AACrC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,wBAAwB,SACxB,MAAM,0BAA0B"}
@@ -143,7 +143,7 @@ declare class ReducedValue<Value = unknown, Input = Value> {
143
143
  * @param init - An object specifying the reducer function (required), inputSchema (optional), and jsonSchemaExtra (optional).
144
144
  */
145
145
  constructor(valueSchema: SerializableSchema<unknown, Value>, init: ReducedValueInitWithSchema<Value, Input>);
146
- constructor(valueSchema: SerializableSchema<unknown, Value>, init: ReducedValueInitBase<Value>);
146
+ constructor(valueSchema: SerializableSchema<Input, Value>, init: ReducedValueInitBase<Value>);
147
147
  /**
148
148
  * Type guard to check if a value is a ReducedValue instance.
149
149
  */
@@ -1 +1 @@
1
- {"version":3,"file":"reduced.d.cts","names":["SerializableSchema","REDUCED_VALUE_SYMBOL","ReducedValueInitBase","Value","Record","ReducedValueInitWithSchema","Input","ReducedValueInit","ReducedValue"],"sources":["../../../src/state/values/reduced.d.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n/**\n * Symbol for runtime identification of ReducedValue instances.\n */\nexport declare const REDUCED_VALUE_SYMBOL: unique symbol;\ninterface ReducedValueInitBase<Value = unknown> {\n /**\n * The reducer function that determines how new input values are combined with the current state.\n * Receives the current output value and a new input value, and must return the updated output.\n *\n * @param current - The current value held in state.\n * @param next - The new input value to apply to the reducer.\n * @returns The next value to be stored in state.\n *\n * @remarks\n * - The logic for updating state in response to new inputs lives in this function.\n */\n reducer: (current: Value, next: Value) => Value;\n /**\n * Optional extra fields to be added to the exported JSON Schema for documentation or additional constraints.\n *\n * @remarks\n * - Use this property to attach metadata or documentation to the generated JSON Schema representation\n * of this value.\n * - These fields are merged into the generated schema, which can assist with code generation, UI hints,\n * or external documentation.\n */\n jsonSchemaExtra?: Record<string, unknown>;\n}\ninterface ReducedValueInitWithSchema<Value = unknown, Input = Value> {\n /**\n * Schema describing the type and validation logic for reducer input values.\n *\n * @remarks\n * - If provided, new values passed to the reducer will be validated using this schema before reduction.\n * - This allows the reducer to accept inputs distinct from the type stored in the state (output type).\n */\n inputSchema: SerializableSchema<unknown, Input>;\n /**\n * The reducer function that determines how new input values are combined with the current state.\n * Receives the current output value and a new input value (validated using `inputSchema`), and returns the updated output.\n *\n * @param current - The current value held in state.\n * @param next - The new validated input value to be applied.\n * @returns The next value to be stored in state.\n *\n * @remarks\n * - The logic for updating state in response to new inputs lives in this function.\n */\n reducer: (current: Value, next: Input) => Value;\n /**\n * Optional extra fields to be added to the exported JSON Schema for documentation or additional constraints.\n *\n * @remarks\n * - Use this property to attach metadata or documentation to the generated JSON Schema representation\n * of this value.\n * - These fields are merged into the generated schema, which can assist with code generation, UI hints,\n * or external documentation.\n */\n jsonSchemaExtra?: Record<string, unknown>;\n}\n/**\n * Initialization options for {@link ReducedValue}.\n *\n * Two forms are supported:\n * 1. Provide only a reducer (and optionally `jsonSchemaExtra`)—in this case, the reducer's inputs are validated using the output value schema.\n * 2. Provide an explicit `inputSchema` field to distinguish the reducer's input type from the stored/output type.\n *\n * @template Value - The type of value stored and produced after reduction.\n * @template Input - The type of inputs accepted by the reducer.\n *\n * @property inputSchema - The schema describing reducer inputs. If omitted, will use the value schema.\n * @property reducer - A function that receives the current output value and a new input, and returns the new output.\n * @property jsonSchemaExtra - (Optional) Extra fields to merge into the exported JSON Schema for documentation or additional constraints.\n */\nexport type ReducedValueInit<Value = unknown, Input = Value> = ReducedValueInitWithSchema<Value, Input> | ReducedValueInitBase<Value>;\n/**\n * Represents a state field whose value is computed and updated using a reducer function.\n *\n * {@link ReducedValue} allows you to define accumulators, counters, aggregators, or other fields\n * whose value is determined incrementally by applying a reducer to incoming updates.\n *\n * Each time a new input is provided, the reducer function is called with the current output\n * and the new input, producing an updated value. Input validation can be controlled separately\n * from output validation by providing an explicit input schema.\n *\n * @template Value - The type of the value stored in state and produced by reduction.\n * @template Input - The type of updates accepted by the reducer.\n *\n * @example\n * // Accumulator with distinct input validation\n * const Sum = new ReducedValue(z.number(), {\n * inputSchema: z.number().min(1),\n * reducer: (total, toAdd) => total + toAdd\n * });\n *\n * @example\n * // Simple running max, using only the value schema\n * const Max = new ReducedValue(z.number(), {\n * reducer: (current, next) => Math.max(current, next)\n * });\n */\nexport declare class ReducedValue<Value = unknown, Input = Value> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [REDUCED_VALUE_SYMBOL]: true;\n /**\n * The schema that describes the type of value stored in state (i.e., after reduction).\n * Note: We use `unknown` for the input type to allow schemas with `.default()` wrappers,\n * where the input type includes `undefined`.\n */\n readonly valueSchema: SerializableSchema<unknown, Value>;\n /**\n * The schema used to validate reducer inputs.\n * If not specified explicitly, this defaults to `valueSchema`.\n */\n readonly inputSchema: SerializableSchema<unknown, Input | Value>;\n /**\n * The reducer function that combines a current output value and an incoming input.\n */\n readonly reducer: (current: Value, next: Input) => Value;\n /**\n * Optional extra fields to merge into the generated JSON Schema (e.g., for documentation or constraints).\n */\n readonly jsonSchemaExtra?: Record<string, unknown>;\n /**\n * Represents the value stored after all reductions.\n */\n ValueType: Value;\n /**\n * Represents the type that may be provided as input on each update.\n */\n InputType: Input;\n /**\n * Constructs a ReducedValue instance, which combines a value schema and a reducer function (plus optional input schema).\n *\n * @param valueSchema - The schema that describes the type of value stored in state (the \"running total\").\n * @param init - An object specifying the reducer function (required), inputSchema (optional), and jsonSchemaExtra (optional).\n */\n constructor(valueSchema: SerializableSchema<unknown, Value>, init: ReducedValueInitWithSchema<Value, Input>);\n constructor(valueSchema: SerializableSchema<unknown, Value>, init: ReducedValueInitBase<Value>);\n /**\n * Type guard to check if a value is a ReducedValue instance.\n */\n static isInstance<Value = unknown, Input = Value>(value: ReducedValue<Value, Input>): value is ReducedValue<Value, Input>;\n static isInstance(value: unknown): value is ReducedValue;\n}\nexport {};\n"],"mappings":";;;;;;AAIA;AACUE,cADWD,oBACS,EAAA,OAAA,MAAA;UAApBC,oBAAoB,CAAA,QAAA,OAAA,CAAA,CAAA;;;;;;AAsBF;;;;;;SAsBQI,EAAAA,CAAAA,OAAAA,EAhCbH,KAgCaG,EAAAA,IAAAA,EAhCAH,KAgCAG,EAAAA,GAhCUH,KAgCVG;;;;AA0BpC;;;;;;iBAA+HH,CAAAA,EAhDzGC,MAgDyGD,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;;UA9CrHE,0BA8CoH,CAAA,QAAA,OAAA,EAAA,QA9ChEF,KA8CgE,CAAA,CAAA;EA2BzGK;;;;;;;aAgByCL,EAjF7CH,kBAiF6CG,CAAAA,OAAAA,EAjFjBG,KAiFiBH,CAAAA;;;;;;;;;;;;SAuBSE,EAAAA,CAAAA,OAAAA,EA5FhDF,KA4FgDE,EAAAA,IAAAA,EA5FnCC,KA4FmCD,EAAAA,GA5FzBF,KA4FyBE;;;;;;;;;;iBAKgDC,CAAAA,EAvFjGF,MAuFiGE,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;;;;;;;;;;;;;;;;KAvE3GC,0CAA0CJ,SAASE,2BAA2BF,OAAOG,SAASJ,qBAAqBC;;;;;;;;;;;;;;;;;;;;;;;;;;;cA2B1GK,sCAAsCL;;;;;sBAKnCF,oBAAAA;;;;;;wBAMED,4BAA4BG;;;;;wBAK5BH,4BAA4BM,QAAQH;;;;8BAI9BA,aAAaG,UAAUH;;;;6BAIxBC;;;;aAIhBD;;;;aAIAG;;;;;;;2BAOcN,4BAA4BG,cAAcE,2BAA2BF,OAAOG;2BAC5EN,4BAA4BG,cAAcD,qBAAqBC;;;;6CAI7CA,cAAcK,aAAaL,OAAOG,kBAAkBE,aAAaL,OAAOG;8CACvEE"}
1
+ {"version":3,"file":"reduced.d.cts","names":["SerializableSchema","REDUCED_VALUE_SYMBOL","ReducedValueInitBase","Value","Record","ReducedValueInitWithSchema","Input","ReducedValueInit","ReducedValue"],"sources":["../../../src/state/values/reduced.d.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n/**\n * Symbol for runtime identification of ReducedValue instances.\n */\nexport declare const REDUCED_VALUE_SYMBOL: unique symbol;\ninterface ReducedValueInitBase<Value = unknown> {\n /**\n * The reducer function that determines how new input values are combined with the current state.\n * Receives the current output value and a new input value, and must return the updated output.\n *\n * @param current - The current value held in state.\n * @param next - The new input value to apply to the reducer.\n * @returns The next value to be stored in state.\n *\n * @remarks\n * - The logic for updating state in response to new inputs lives in this function.\n */\n reducer: (current: Value, next: Value) => Value;\n /**\n * Optional extra fields to be added to the exported JSON Schema for documentation or additional constraints.\n *\n * @remarks\n * - Use this property to attach metadata or documentation to the generated JSON Schema representation\n * of this value.\n * - These fields are merged into the generated schema, which can assist with code generation, UI hints,\n * or external documentation.\n */\n jsonSchemaExtra?: Record<string, unknown>;\n}\ninterface ReducedValueInitWithSchema<Value = unknown, Input = Value> {\n /**\n * Schema describing the type and validation logic for reducer input values.\n *\n * @remarks\n * - If provided, new values passed to the reducer will be validated using this schema before reduction.\n * - This allows the reducer to accept inputs distinct from the type stored in the state (output type).\n */\n inputSchema: SerializableSchema<unknown, Input>;\n /**\n * The reducer function that determines how new input values are combined with the current state.\n * Receives the current output value and a new input value (validated using `inputSchema`), and returns the updated output.\n *\n * @param current - The current value held in state.\n * @param next - The new validated input value to be applied.\n * @returns The next value to be stored in state.\n *\n * @remarks\n * - The logic for updating state in response to new inputs lives in this function.\n */\n reducer: (current: Value, next: Input) => Value;\n /**\n * Optional extra fields to be added to the exported JSON Schema for documentation or additional constraints.\n *\n * @remarks\n * - Use this property to attach metadata or documentation to the generated JSON Schema representation\n * of this value.\n * - These fields are merged into the generated schema, which can assist with code generation, UI hints,\n * or external documentation.\n */\n jsonSchemaExtra?: Record<string, unknown>;\n}\n/**\n * Initialization options for {@link ReducedValue}.\n *\n * Two forms are supported:\n * 1. Provide only a reducer (and optionally `jsonSchemaExtra`)—in this case, the reducer's inputs are validated using the output value schema.\n * 2. Provide an explicit `inputSchema` field to distinguish the reducer's input type from the stored/output type.\n *\n * @template Value - The type of value stored and produced after reduction.\n * @template Input - The type of inputs accepted by the reducer.\n *\n * @property inputSchema - The schema describing reducer inputs. If omitted, will use the value schema.\n * @property reducer - A function that receives the current output value and a new input, and returns the new output.\n * @property jsonSchemaExtra - (Optional) Extra fields to merge into the exported JSON Schema for documentation or additional constraints.\n */\nexport type ReducedValueInit<Value = unknown, Input = Value> = ReducedValueInitWithSchema<Value, Input> | ReducedValueInitBase<Value>;\n/**\n * Represents a state field whose value is computed and updated using a reducer function.\n *\n * {@link ReducedValue} allows you to define accumulators, counters, aggregators, or other fields\n * whose value is determined incrementally by applying a reducer to incoming updates.\n *\n * Each time a new input is provided, the reducer function is called with the current output\n * and the new input, producing an updated value. Input validation can be controlled separately\n * from output validation by providing an explicit input schema.\n *\n * @template Value - The type of the value stored in state and produced by reduction.\n * @template Input - The type of updates accepted by the reducer.\n *\n * @example\n * // Accumulator with distinct input validation\n * const Sum = new ReducedValue(z.number(), {\n * inputSchema: z.number().min(1),\n * reducer: (total, toAdd) => total + toAdd\n * });\n *\n * @example\n * // Simple running max, using only the value schema\n * const Max = new ReducedValue(z.number(), {\n * reducer: (current, next) => Math.max(current, next)\n * });\n */\nexport declare class ReducedValue<Value = unknown, Input = Value> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [REDUCED_VALUE_SYMBOL]: true;\n /**\n * The schema that describes the type of value stored in state (i.e., after reduction).\n * Note: We use `unknown` for the input type to allow schemas with `.default()` wrappers,\n * where the input type includes `undefined`.\n */\n readonly valueSchema: SerializableSchema<unknown, Value>;\n /**\n * The schema used to validate reducer inputs.\n * If not specified explicitly, this defaults to `valueSchema`.\n */\n readonly inputSchema: SerializableSchema<unknown, Input | Value>;\n /**\n * The reducer function that combines a current output value and an incoming input.\n */\n readonly reducer: (current: Value, next: Input) => Value;\n /**\n * Optional extra fields to merge into the generated JSON Schema (e.g., for documentation or constraints).\n */\n readonly jsonSchemaExtra?: Record<string, unknown>;\n /**\n * Represents the value stored after all reductions.\n */\n ValueType: Value;\n /**\n * Represents the type that may be provided as input on each update.\n */\n InputType: Input;\n /**\n * Constructs a ReducedValue instance, which combines a value schema and a reducer function (plus optional input schema).\n *\n * @param valueSchema - The schema that describes the type of value stored in state (the \"running total\").\n * @param init - An object specifying the reducer function (required), inputSchema (optional), and jsonSchemaExtra (optional).\n */\n constructor(valueSchema: SerializableSchema<unknown, Value>, init: ReducedValueInitWithSchema<Value, Input>);\n constructor(valueSchema: SerializableSchema<Input, Value>, init: ReducedValueInitBase<Value>);\n /**\n * Type guard to check if a value is a ReducedValue instance.\n */\n static isInstance<Value = unknown, Input = Value>(value: ReducedValue<Value, Input>): value is ReducedValue<Value, Input>;\n static isInstance(value: unknown): value is ReducedValue;\n}\nexport {};\n"],"mappings":";;;;;;AAIA;AACUE,cADWD,oBACS,EAAA,OAAA,MAAA;UAApBC,oBAAoB,CAAA,QAAA,OAAA,CAAA,CAAA;;;;;;AAsBF;;;;;;SAsBQI,EAAAA,CAAAA,OAAAA,EAhCbH,KAgCaG,EAAAA,IAAAA,EAhCAH,KAgCAG,EAAAA,GAhCUH,KAgCVG;;;;AA0BpC;;;;;;iBAA+HH,CAAAA,EAhDzGC,MAgDyGD,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;;UA9CrHE,0BA8CoH,CAAA,QAAA,OAAA,EAAA,QA9ChEF,KA8CgE,CAAA,CAAA;EA2BzGK;;;;;;;aAgByCL,EAjF7CH,kBAiF6CG,CAAAA,OAAAA,EAjFjBG,KAiFiBH,CAAAA;;;;;;;;;;;;SAuBSE,EAAAA,CAAAA,OAAAA,EA5FhDF,KA4FgDE,EAAAA,IAAAA,EA5FnCC,KA4FmCD,EAAAA,GA5FzBF,KA4FyBE;;;;;;;;;;iBAKyCF,CAAAA,EAvF1FC,MAuF0FD,CAAAA,MAAAA,EAAAA,OAAAA,CAAAA;;;;;;;;;;;;;;;;KAvEpGI,0CAA0CJ,SAASE,2BAA2BF,OAAOG,SAASJ,qBAAqBC;;;;;;;;;;;;;;;;;;;;;;;;;;;cA2B1GK,sCAAsCL;;;;;sBAKnCF,oBAAAA;;;;;;wBAMED,4BAA4BG;;;;;wBAK5BH,4BAA4BM,QAAQH;;;;8BAI9BA,aAAaG,UAAUH;;;;6BAIxBC;;;;aAIhBD;;;;aAIAG;;;;;;;2BAOcN,4BAA4BG,cAAcE,2BAA2BF,OAAOG;2BAC5EN,mBAAmBM,OAAOH,cAAcD,qBAAqBC;;;;6CAI3CA,cAAcK,aAAaL,OAAOG,kBAAkBE,aAAaL,OAAOG;8CACvEE"}
@@ -143,7 +143,7 @@ declare class ReducedValue<Value = unknown, Input = Value> {
143
143
  * @param init - An object specifying the reducer function (required), inputSchema (optional), and jsonSchemaExtra (optional).
144
144
  */
145
145
  constructor(valueSchema: SerializableSchema<unknown, Value>, init: ReducedValueInitWithSchema<Value, Input>);
146
- constructor(valueSchema: SerializableSchema<unknown, Value>, init: ReducedValueInitBase<Value>);
146
+ constructor(valueSchema: SerializableSchema<Input, Value>, init: ReducedValueInitBase<Value>);
147
147
  /**
148
148
  * Type guard to check if a value is a ReducedValue instance.
149
149
  */