@langchain/langgraph 1.1.0 → 1.1.2

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 (104) hide show
  1. package/dist/errors.d.cts.map +1 -1
  2. package/dist/graph/annotation.cjs +3 -0
  3. package/dist/graph/annotation.cjs.map +1 -1
  4. package/dist/graph/annotation.d.cts +1 -0
  5. package/dist/graph/annotation.d.cts.map +1 -1
  6. package/dist/graph/annotation.d.ts +1 -0
  7. package/dist/graph/annotation.d.ts.map +1 -1
  8. package/dist/graph/annotation.js +3 -0
  9. package/dist/graph/annotation.js.map +1 -1
  10. package/dist/graph/graph.cjs +3 -3
  11. package/dist/graph/graph.cjs.map +1 -1
  12. package/dist/graph/graph.js +3 -3
  13. package/dist/graph/graph.js.map +1 -1
  14. package/dist/graph/message.d.cts +2 -2
  15. package/dist/graph/message.d.cts.map +1 -1
  16. package/dist/graph/message.d.ts +2 -2
  17. package/dist/graph/message.d.ts.map +1 -1
  18. package/dist/graph/messages_annotation.d.cts +5 -5
  19. package/dist/graph/messages_annotation.d.cts.map +1 -1
  20. package/dist/graph/messages_annotation.d.ts +5 -5
  21. package/dist/graph/messages_annotation.d.ts.map +1 -1
  22. package/dist/graph/state.cjs +98 -78
  23. package/dist/graph/state.cjs.map +1 -1
  24. package/dist/graph/state.d.cts +68 -35
  25. package/dist/graph/state.d.cts.map +1 -1
  26. package/dist/graph/state.d.ts +68 -35
  27. package/dist/graph/state.d.ts.map +1 -1
  28. package/dist/graph/state.js +99 -79
  29. package/dist/graph/state.js.map +1 -1
  30. package/dist/graph/types.cjs +41 -0
  31. package/dist/graph/types.cjs.map +1 -0
  32. package/dist/graph/types.d.cts +247 -18
  33. package/dist/graph/types.d.cts.map +1 -1
  34. package/dist/graph/types.d.ts +247 -18
  35. package/dist/graph/types.d.ts.map +1 -1
  36. package/dist/graph/types.js +40 -0
  37. package/dist/graph/types.js.map +1 -0
  38. package/dist/graph/zod/meta.cjs +4 -4
  39. package/dist/graph/zod/meta.cjs.map +1 -1
  40. package/dist/graph/zod/meta.js +4 -4
  41. package/dist/graph/zod/meta.js.map +1 -1
  42. package/dist/graph/zod/zod-registry.d.cts.map +1 -1
  43. package/dist/graph/zod/zod-registry.d.ts.map +1 -1
  44. package/dist/hash.cjs +1 -1
  45. package/dist/hash.cjs.map +1 -1
  46. package/dist/hash.js +1 -1
  47. package/dist/hash.js.map +1 -1
  48. package/dist/index.d.cts +3 -3
  49. package/dist/index.d.ts +3 -3
  50. package/dist/prebuilt/agent_executor.d.cts +5 -5
  51. package/dist/prebuilt/agent_executor.d.cts.map +1 -1
  52. package/dist/prebuilt/agent_executor.d.ts +5 -5
  53. package/dist/prebuilt/agent_executor.d.ts.map +1 -1
  54. package/dist/prebuilt/react_agent_executor.cjs +12 -12
  55. package/dist/prebuilt/react_agent_executor.cjs.map +1 -1
  56. package/dist/prebuilt/react_agent_executor.d.cts +3 -3
  57. package/dist/prebuilt/react_agent_executor.d.cts.map +1 -1
  58. package/dist/prebuilt/react_agent_executor.d.ts +3 -3
  59. package/dist/prebuilt/react_agent_executor.d.ts.map +1 -1
  60. package/dist/prebuilt/react_agent_executor.js +12 -12
  61. package/dist/prebuilt/react_agent_executor.js.map +1 -1
  62. package/dist/prebuilt/tool_node.cjs +1 -1
  63. package/dist/prebuilt/tool_node.cjs.map +1 -1
  64. package/dist/prebuilt/tool_node.js +1 -1
  65. package/dist/prebuilt/tool_node.js.map +1 -1
  66. package/dist/pregel/debug.cjs +9 -9
  67. package/dist/pregel/debug.cjs.map +1 -1
  68. package/dist/pregel/debug.js +9 -9
  69. package/dist/pregel/debug.js.map +1 -1
  70. package/dist/pregel/index.cjs +44 -44
  71. package/dist/pregel/index.cjs.map +1 -1
  72. package/dist/pregel/index.js +44 -44
  73. package/dist/pregel/index.js.map +1 -1
  74. package/dist/pregel/loop.cjs +1 -1
  75. package/dist/pregel/loop.cjs.map +1 -1
  76. package/dist/pregel/loop.js +1 -1
  77. package/dist/pregel/loop.js.map +1 -1
  78. package/dist/pregel/utils/subgraph.cjs +2 -2
  79. package/dist/pregel/utils/subgraph.cjs.map +1 -1
  80. package/dist/pregel/utils/subgraph.js +2 -2
  81. package/dist/pregel/utils/subgraph.js.map +1 -1
  82. package/dist/state/schema.cjs +8 -9
  83. package/dist/state/schema.cjs.map +1 -1
  84. package/dist/state/schema.d.cts +18 -22
  85. package/dist/state/schema.d.cts.map +1 -1
  86. package/dist/state/schema.d.ts +18 -22
  87. package/dist/state/schema.d.ts.map +1 -1
  88. package/dist/state/schema.js +8 -9
  89. package/dist/state/schema.js.map +1 -1
  90. package/dist/state/values/reduced.cjs.map +1 -1
  91. package/dist/state/values/reduced.d.cts +1 -1
  92. package/dist/state/values/reduced.d.cts.map +1 -1
  93. package/dist/state/values/reduced.d.ts +1 -1
  94. package/dist/state/values/reduced.d.ts.map +1 -1
  95. package/dist/state/values/reduced.js.map +1 -1
  96. package/dist/state/values/untracked.cjs.map +1 -1
  97. package/dist/state/values/untracked.d.cts +4 -0
  98. package/dist/state/values/untracked.d.cts.map +1 -1
  99. package/dist/state/values/untracked.d.ts +4 -0
  100. package/dist/state/values/untracked.d.ts.map +1 -1
  101. package/dist/state/values/untracked.js.map +1 -1
  102. package/dist/web.d.cts +3 -3
  103. package/dist/web.d.ts +3 -3
  104. package/package.json +6 -6
@@ -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;AACJ,YAAS,OAAO,IAAI,sBAAsB;IACxC,OAAO,MAAM;IACb,qBAAqB;IACtB,CAAC;aACO,iBAAiB,MAAM,CAGhC,UAAS,OAAO,IAAI,UADE,uBAAuB,MAAM,CACP;MAE5C,OAAM,IAAI,MACR,wBAAwB,IAAI,oEAC7B;AAIL,SAAO;;;;;;CAOT,gBAA4B;EAC1B,MAAM,aAAyC,EAAE;EACjD,MAAM,WAAqB,EAAE;AAE7B,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,KAAK,EAAE;GACpD,IAAI;AAEJ,OAAI,aAAa,WAAW,MAAM,EAAE;AAClC,kBAAc,wBAAwB,MAAM,YAAY;AACxD,QAAI,eAAe,MAAM,gBACvB,eAAc;KAAE,GAAG;KAAa,GAAG,MAAM;KAAiB;cAEnD,eAAe,WAAW,MAAM,CACzC,eAAc,MAAM,SACf,wBAAwB,MAAM,OAAO,GACtC;YACK,iBAAiB,MAAM,CAChC,eAAc,wBAAwB,MAAM;AAG9C,OAAI,aAAa;AACf,eAAW,OAAO;IAGlB,IAAI,aAAa;AACjB,QAAI,aAAa,WAAW,MAAM,CAChC,cAAa,uBAAuB,MAAM,YAAY,KAAK;aAClD,eAAe,WAAW,MAAM,CACzC,cAAa,MAAM,SACf,uBAAuB,MAAM,OAAO,KAAK,SACzC;QAEJ,cAAa,uBAAuB,MAAM,KAAK;AAGjD,QAAI,CAAC,WACH,UAAS,KAAK,IAAI;;;AAKxB,SAAO;GACL,MAAM;GACN;GACA,UAAU,SAAS,SAAS,IAAI,WAAW;GAC5C;;;;;;CAOH,qBAAiC;EAC/B,MAAM,aAAyC,EAAE;AAEjD,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,KAAK,EAAE;GACpD,IAAI;AAEJ,OAAI,aAAa,WAAW,MAAM,CAEhC,eAAc,wBAAwB,MAAM,YAAY;YAC/C,eAAe,WAAW,MAAM,CACzC,eAAc,MAAM,SACf,wBAAwB,MAAM,OAAO,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,SAAO;;;;;;CAOT,gBAA4B;EAC1B,MAAM,aAAyC,EAAE;EACjD,MAAM,WAAqB,EAAE;AAE7B,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,OAAO,EAAE;GACtD,IAAI;AAEJ,OAAI,aAAa,WAAW,MAAM,EAAE;AAClC,kBAAc,wBAAwB,MAAM,YAAY;AACxD,QAAI,eAAe,MAAM,gBACvB,eAAc;KAAE,GAAG;KAAa,GAAG,MAAM;KAAiB;cAEnD,eAAe,WAAW,MAAM,CACzC,eAAc,MAAM,SACf,wBAAwB,MAAM,OAAO,GACtC;YACK,iBAAiB,MAAM,CAChC,eAAc,wBAAwB,MAAM;AAG9C,OAAI,aAAa;AACf,eAAW,OAAO;IAGlB,IAAI,aAAa;AACjB,QAAI,aAAa,WAAW,MAAM,CAChC,cAAa,uBAAuB,MAAM,YAAY,KAAK;aAClD,eAAe,WAAW,MAAM,CACzC,cAAa,MAAM,SACf,uBAAuB,MAAM,OAAO,KAAK,SACzC;QAEJ,cAAa,uBAAuB,MAAM,KAAK;AAGjD,QAAI,CAAC,WACH,UAAS,KAAK,IAAI;;;AAKxB,SAAO;GACL,MAAM;GACN;GACA,UAAU,SAAS,SAAS,IAAI,WAAW;GAC5C;;;;;;CAOH,qBAAiC;EAC/B,MAAM,aAAyC,EAAE;AAEjD,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,OAAO,EAAE;GACtD,IAAI;AAEJ,OAAI,aAAa,WAAW,MAAM,CAEhC,eAAc,wBAAwB,MAAM,YAAY;YAC/C,eAAe,WAAW,MAAM,CACzC,eAAc,MAAM,SACf,wBAAwB,MAAM,OAAO,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,OAAO,CAAC,KAAK,CAAC,SAAS,IAAI;;;;;CAMxD,aAAuB;AACrB,SAAO,OAAO,KAAK,KAAK,OAAO;;;;;;;;;CAUjC,MAAM,cAAiB,MAAqB;AAC1C,MAAI,QAAQ,QAAQ,OAAO,SAAS,SAClC,QAAO;EAGT,MAAM,SAAkC,EAAE;AAE1C,OAAK,MAAM,CAAC,KAAK,UAAU,OAAO,QAAQ,KAAK,EAAE;GAC/C,MAAM,WAAW,KAAK,OAAO;AAE7B,OAAI,aAAa,QAAW;AAE1B,WAAO,OAAO;AACd;;GAIF,IAAI;AAEJ,OAAI,aAAa,WAAW,SAAS,CACnC,UAAS,SAAS;YACT,eAAe,WAAW,SAAS,CAC5C,UAAS,SAAS;YACT,iBAAiB,SAAS,CACnC,UAAS;AAGX,OAAI,QAAQ;IAEV,MAAM,mBAAmB,MAAM,OAAO,aAAa,SAAS,MAAM;AAClE,QAAI,iBAAiB,OACnB,OAAM,IAAI,MACR,gCAAgC,IAAI,KAAK,KAAK,UAC5C,iBAAiB,OAClB,GACF;AAEH,WAAO,OAAO,iBAAiB;SAG/B,QAAO,OAAO;;AAIlB,SAAO;;CAeT,OAAO,WACL,OAC+B;AAC/B,SACE,OAAO,UAAU,YACjB,UAAU,QACV,uBAAuB,SACvB,MAAM,yBAAyB"}
@@ -1 +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
  */
@@ -1 +1 @@
1
- {"version":3,"file":"reduced.d.ts","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.ts","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"}
@@ -1 +1 @@
1
- {"version":3,"file":"reduced.js","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.js","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"}
@@ -1 +1 @@
1
- {"version":3,"file":"untracked.cjs","names":[],"sources":["../../../src/state/values/untracked.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n\n/**\n * Symbol for runtime identification of UntrackedValue instances.\n */\nexport const UNTRACKED_VALUE_SYMBOL = Symbol.for(\n \"langgraph.state.untracked_value\"\n);\n\n/**\n * Initialization options for {@link UntrackedValue}.\n */\nexport interface UntrackedValueInit {\n /**\n * If true (default), throws an error if multiple updates are made in a single step.\n * If false, only the last value is kept per step.\n */\n guard?: boolean;\n}\n\n/**\n * Represents a state field whose value is transient and never checkpointed.\n *\n * Use {@link UntrackedValue} for state fields that should be tracked for the lifetime\n * of the process, but should not participate in durable checkpoints or recovery.\n *\n * @typeParam Value - The type of value stored in this field.\n *\n * @example\n * // Create an untracked in-memory cache\n * const cache = new UntrackedValue<Record<string, number>>();\n *\n * // Use with a type schema for basic runtime validation\n * import { z } from \"zod\";\n * const tempSession = new UntrackedValue(z.object({ token: z.string() }), { guard: false });\n *\n * // You can customize whether to throw on multiple updates per step:\n * const session = new UntrackedValue(undefined, { guard: false });\n */\nexport class UntrackedValue<Value = unknown> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [UNTRACKED_VALUE_SYMBOL] = true as const;\n\n /**\n * Optional schema describing the type and shape of the value stored in this field.\n *\n * If provided, this can be used for runtime validation or code generation.\n */\n readonly schema?: SerializableSchema<Value>;\n\n /**\n * Whether to guard against multiple updates to this untracked value in a single step.\n *\n * - If `true` (default), throws an error if multiple updates are received in one step.\n * - If `false`, only the last value from that step is kept, others are ignored.\n *\n * This helps prevent accidental state replacement within a step.\n */\n readonly guard: boolean;\n\n /**\n * Create a new untracked value state field.\n *\n * @param schema - Optional type schema describing the value (e.g. a Zod schema).\n * @param init - Optional options for tracking updates or enabling multiple-writes-per-step.\n */\n constructor(schema?: SerializableSchema<Value>, init?: UntrackedValueInit) {\n this.schema = schema;\n this.guard = init?.guard ?? true;\n }\n\n /**\n * Type guard to check if a value is an UntrackedValue instance.\n */\n static isInstance<Value = unknown>(\n value: UntrackedValue<Value>\n ): value is UntrackedValue<Value>;\n\n static isInstance(value: unknown): value is UntrackedValue;\n\n static isInstance<Value = unknown>(\n value: UntrackedValue<Value> | unknown\n ): value is UntrackedValue<Value> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n UNTRACKED_VALUE_SYMBOL in value\n );\n }\n}\n"],"mappings":";;;;;AAKA,MAAa,yBAAyB,OAAO,IAC3C,kCACD;;;;;;;;;;;;;;;;;;;;AAgCD,IAAa,iBAAb,MAA6C;;;;;CAK3C,CAAoB,0BAA0B;;;;;;CAO9C,AAAS;;;;;;;;;CAUT,AAAS;;;;;;;CAQT,YAAY,QAAoC,MAA2B;AACzE,OAAK,SAAS;AACd,OAAK,QAAQ,MAAM,SAAS;;CAY9B,OAAO,WACL,OACgC;AAChC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,0BAA0B"}
1
+ {"version":3,"file":"untracked.cjs","names":[],"sources":["../../../src/state/values/untracked.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n\n/**\n * Symbol for runtime identification of UntrackedValue instances.\n */\nexport const UNTRACKED_VALUE_SYMBOL = Symbol.for(\n \"langgraph.state.untracked_value\"\n);\n\n/**\n * Initialization options for {@link UntrackedValue}.\n */\nexport interface UntrackedValueInit {\n /**\n * If true (default), throws an error if multiple updates are made in a single step.\n * If false, only the last value is kept per step.\n */\n guard?: boolean;\n}\n\n/**\n * Represents a state field whose value is transient and never checkpointed.\n *\n * Use {@link UntrackedValue} for state fields that should be tracked for the lifetime\n * of the process, but should not participate in durable checkpoints or recovery.\n *\n * @typeParam Value - The type of value stored in this field.\n *\n * @example\n * // Create an untracked in-memory cache\n * const cache = new UntrackedValue<Record<string, number>>();\n *\n * // Use with a type schema for basic runtime validation\n * import { z } from \"zod\";\n * const tempSession = new UntrackedValue(z.object({ token: z.string() }), { guard: false });\n *\n * // You can customize whether to throw on multiple updates per step:\n * const session = new UntrackedValue(undefined, { guard: false });\n */\nexport class UntrackedValue<Value = unknown> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [UNTRACKED_VALUE_SYMBOL] = true as const;\n\n /**\n * Optional schema describing the type and shape of the value stored in this field.\n *\n * If provided, this can be used for runtime validation or code generation.\n */\n readonly schema?: SerializableSchema<Value>;\n\n /**\n * Whether to guard against multiple updates to this untracked value in a single step.\n *\n * - If `true` (default), throws an error if multiple updates are received in one step.\n * - If `false`, only the last value from that step is kept, others are ignored.\n *\n * This helps prevent accidental state replacement within a step.\n */\n readonly guard: boolean;\n\n /**\n * Represents the type of value stored in this untracked state field.\n */\n declare ValueType: Value;\n\n /**\n * Create a new untracked value state field.\n *\n * @param schema - Optional type schema describing the value (e.g. a Zod schema).\n * @param init - Optional options for tracking updates or enabling multiple-writes-per-step.\n */\n constructor(schema?: SerializableSchema<Value>, init?: UntrackedValueInit) {\n this.schema = schema;\n this.guard = init?.guard ?? true;\n }\n\n /**\n * Type guard to check if a value is an UntrackedValue instance.\n */\n static isInstance<Value = unknown>(\n value: UntrackedValue<Value>\n ): value is UntrackedValue<Value>;\n\n static isInstance(value: unknown): value is UntrackedValue;\n\n static isInstance<Value = unknown>(\n value: UntrackedValue<Value> | unknown\n ): value is UntrackedValue<Value> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n UNTRACKED_VALUE_SYMBOL in value\n );\n }\n}\n"],"mappings":";;;;;AAKA,MAAa,yBAAyB,OAAO,IAC3C,kCACD;;;;;;;;;;;;;;;;;;;;AAgCD,IAAa,iBAAb,MAA6C;;;;;CAK3C,CAAoB,0BAA0B;;;;;;CAO9C,AAAS;;;;;;;;;CAUT,AAAS;;;;;;;CAaT,YAAY,QAAoC,MAA2B;AACzE,OAAK,SAAS;AACd,OAAK,QAAQ,MAAM,SAAS;;CAY9B,OAAO,WACL,OACgC;AAChC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,0BAA0B"}
@@ -56,6 +56,10 @@ declare class UntrackedValue<Value = unknown> {
56
56
  * This helps prevent accidental state replacement within a step.
57
57
  */
58
58
  readonly guard: boolean;
59
+ /**
60
+ * Represents the type of value stored in this untracked state field.
61
+ */
62
+ ValueType: Value;
59
63
  /**
60
64
  * Create a new untracked value state field.
61
65
  *
@@ -1 +1 @@
1
- {"version":3,"file":"untracked.d.cts","names":["SerializableSchema","UNTRACKED_VALUE_SYMBOL","UntrackedValueInit","UntrackedValue","Value"],"sources":["../../../src/state/values/untracked.d.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n/**\n * Symbol for runtime identification of UntrackedValue instances.\n */\nexport declare const UNTRACKED_VALUE_SYMBOL: unique symbol;\n/**\n * Initialization options for {@link UntrackedValue}.\n */\nexport interface UntrackedValueInit {\n /**\n * If true (default), throws an error if multiple updates are made in a single step.\n * If false, only the last value is kept per step.\n */\n guard?: boolean;\n}\n/**\n * Represents a state field whose value is transient and never checkpointed.\n *\n * Use {@link UntrackedValue} for state fields that should be tracked for the lifetime\n * of the process, but should not participate in durable checkpoints or recovery.\n *\n * @typeParam Value - The type of value stored in this field.\n *\n * @example\n * // Create an untracked in-memory cache\n * const cache = new UntrackedValue<Record<string, number>>();\n *\n * // Use with a type schema for basic runtime validation\n * import { z } from \"zod\";\n * const tempSession = new UntrackedValue(z.object({ token: z.string() }), { guard: false });\n *\n * // You can customize whether to throw on multiple updates per step:\n * const session = new UntrackedValue(undefined, { guard: false });\n */\nexport declare class UntrackedValue<Value = unknown> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [UNTRACKED_VALUE_SYMBOL]: true;\n /**\n * Optional schema describing the type and shape of the value stored in this field.\n *\n * If provided, this can be used for runtime validation or code generation.\n */\n readonly schema?: SerializableSchema<Value>;\n /**\n * Whether to guard against multiple updates to this untracked value in a single step.\n *\n * - If `true` (default), throws an error if multiple updates are received in one step.\n * - If `false`, only the last value from that step is kept, others are ignored.\n *\n * This helps prevent accidental state replacement within a step.\n */\n readonly guard: boolean;\n /**\n * Create a new untracked value state field.\n *\n * @param schema - Optional type schema describing the value (e.g. a Zod schema).\n * @param init - Optional options for tracking updates or enabling multiple-writes-per-step.\n */\n constructor(schema?: SerializableSchema<Value>, init?: UntrackedValueInit);\n /**\n * Type guard to check if a value is an UntrackedValue instance.\n */\n static isInstance<Value = unknown>(value: UntrackedValue<Value>): value is UntrackedValue<Value>;\n static isInstance(value: unknown): value is UntrackedValue;\n}\n"],"mappings":";;;;;;AAIA;AAIiBE,cAJID,sBAIc,EAAA,OAAA,MAAA;AA0BnC;;;AAWyCG,UArCxBF,kBAAAA,CAqCwBE;;;;;OAoBoBA,CAAAA,EAAAA,OAAAA;;;;;;;;;;;;;;;;;;;;;cA/BxCD;;;;;sBAKGF,sBAAAA;;;;;;oBAMFD,mBAAmBI;;;;;;;;;;;;;;;;uBAgBhBJ,mBAAmBI,eAAeF;;;;4CAIbC,eAAeC,kBAAkBD,eAAeC;8CAC9CD"}
1
+ {"version":3,"file":"untracked.d.cts","names":["SerializableSchema","UNTRACKED_VALUE_SYMBOL","UntrackedValueInit","UntrackedValue","Value"],"sources":["../../../src/state/values/untracked.d.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n/**\n * Symbol for runtime identification of UntrackedValue instances.\n */\nexport declare const UNTRACKED_VALUE_SYMBOL: unique symbol;\n/**\n * Initialization options for {@link UntrackedValue}.\n */\nexport interface UntrackedValueInit {\n /**\n * If true (default), throws an error if multiple updates are made in a single step.\n * If false, only the last value is kept per step.\n */\n guard?: boolean;\n}\n/**\n * Represents a state field whose value is transient and never checkpointed.\n *\n * Use {@link UntrackedValue} for state fields that should be tracked for the lifetime\n * of the process, but should not participate in durable checkpoints or recovery.\n *\n * @typeParam Value - The type of value stored in this field.\n *\n * @example\n * // Create an untracked in-memory cache\n * const cache = new UntrackedValue<Record<string, number>>();\n *\n * // Use with a type schema for basic runtime validation\n * import { z } from \"zod\";\n * const tempSession = new UntrackedValue(z.object({ token: z.string() }), { guard: false });\n *\n * // You can customize whether to throw on multiple updates per step:\n * const session = new UntrackedValue(undefined, { guard: false });\n */\nexport declare class UntrackedValue<Value = unknown> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [UNTRACKED_VALUE_SYMBOL]: true;\n /**\n * Optional schema describing the type and shape of the value stored in this field.\n *\n * If provided, this can be used for runtime validation or code generation.\n */\n readonly schema?: SerializableSchema<Value>;\n /**\n * Whether to guard against multiple updates to this untracked value in a single step.\n *\n * - If `true` (default), throws an error if multiple updates are received in one step.\n * - If `false`, only the last value from that step is kept, others are ignored.\n *\n * This helps prevent accidental state replacement within a step.\n */\n readonly guard: boolean;\n /**\n * Represents the type of value stored in this untracked state field.\n */\n ValueType: Value;\n /**\n * Create a new untracked value state field.\n *\n * @param schema - Optional type schema describing the value (e.g. a Zod schema).\n * @param init - Optional options for tracking updates or enabling multiple-writes-per-step.\n */\n constructor(schema?: SerializableSchema<Value>, init?: UntrackedValueInit);\n /**\n * Type guard to check if a value is an UntrackedValue instance.\n */\n static isInstance<Value = unknown>(value: UntrackedValue<Value>): value is UntrackedValue<Value>;\n static isInstance(value: unknown): value is UntrackedValue;\n}\n"],"mappings":";;;;;;AAIA;AAIiBE,cAJID,sBAIc,EAAA,OAAA,MAAA;AA0BnC;;;AAWyCG,UArCxBF,kBAAAA,CAqCwBE;;;;;OAoBkBF,CAAAA,EAAAA,OAAAA;;;;;;;;;;;;;;;;;;;;;cA/BtCC;;;;;sBAKGF,sBAAAA;;;;;;oBAMFD,mBAAmBI;;;;;;;;;;;;;aAa1BA;;;;;;;uBAOUJ,mBAAmBI,eAAeF;;;;4CAIbC,eAAeC,kBAAkBD,eAAeC;8CAC9CD"}
@@ -56,6 +56,10 @@ declare class UntrackedValue<Value = unknown> {
56
56
  * This helps prevent accidental state replacement within a step.
57
57
  */
58
58
  readonly guard: boolean;
59
+ /**
60
+ * Represents the type of value stored in this untracked state field.
61
+ */
62
+ ValueType: Value;
59
63
  /**
60
64
  * Create a new untracked value state field.
61
65
  *
@@ -1 +1 @@
1
- {"version":3,"file":"untracked.d.ts","names":["SerializableSchema","UNTRACKED_VALUE_SYMBOL","UntrackedValueInit","UntrackedValue","Value"],"sources":["../../../src/state/values/untracked.d.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n/**\n * Symbol for runtime identification of UntrackedValue instances.\n */\nexport declare const UNTRACKED_VALUE_SYMBOL: unique symbol;\n/**\n * Initialization options for {@link UntrackedValue}.\n */\nexport interface UntrackedValueInit {\n /**\n * If true (default), throws an error if multiple updates are made in a single step.\n * If false, only the last value is kept per step.\n */\n guard?: boolean;\n}\n/**\n * Represents a state field whose value is transient and never checkpointed.\n *\n * Use {@link UntrackedValue} for state fields that should be tracked for the lifetime\n * of the process, but should not participate in durable checkpoints or recovery.\n *\n * @typeParam Value - The type of value stored in this field.\n *\n * @example\n * // Create an untracked in-memory cache\n * const cache = new UntrackedValue<Record<string, number>>();\n *\n * // Use with a type schema for basic runtime validation\n * import { z } from \"zod\";\n * const tempSession = new UntrackedValue(z.object({ token: z.string() }), { guard: false });\n *\n * // You can customize whether to throw on multiple updates per step:\n * const session = new UntrackedValue(undefined, { guard: false });\n */\nexport declare class UntrackedValue<Value = unknown> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [UNTRACKED_VALUE_SYMBOL]: true;\n /**\n * Optional schema describing the type and shape of the value stored in this field.\n *\n * If provided, this can be used for runtime validation or code generation.\n */\n readonly schema?: SerializableSchema<Value>;\n /**\n * Whether to guard against multiple updates to this untracked value in a single step.\n *\n * - If `true` (default), throws an error if multiple updates are received in one step.\n * - If `false`, only the last value from that step is kept, others are ignored.\n *\n * This helps prevent accidental state replacement within a step.\n */\n readonly guard: boolean;\n /**\n * Create a new untracked value state field.\n *\n * @param schema - Optional type schema describing the value (e.g. a Zod schema).\n * @param init - Optional options for tracking updates or enabling multiple-writes-per-step.\n */\n constructor(schema?: SerializableSchema<Value>, init?: UntrackedValueInit);\n /**\n * Type guard to check if a value is an UntrackedValue instance.\n */\n static isInstance<Value = unknown>(value: UntrackedValue<Value>): value is UntrackedValue<Value>;\n static isInstance(value: unknown): value is UntrackedValue;\n}\n"],"mappings":";;;;;;AAIA;AAIiBE,cAJID,sBAIc,EAAA,OAAA,MAAA;AA0BnC;;;AAWyCG,UArCxBF,kBAAAA,CAqCwBE;;;;;OAoBoBA,CAAAA,EAAAA,OAAAA;;;;;;;;;;;;;;;;;;;;;cA/BxCD;;;;;sBAKGF,sBAAAA;;;;;;oBAMFD,mBAAmBI;;;;;;;;;;;;;;;;uBAgBhBJ,mBAAmBI,eAAeF;;;;4CAIbC,eAAeC,kBAAkBD,eAAeC;8CAC9CD"}
1
+ {"version":3,"file":"untracked.d.ts","names":["SerializableSchema","UNTRACKED_VALUE_SYMBOL","UntrackedValueInit","UntrackedValue","Value"],"sources":["../../../src/state/values/untracked.d.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n/**\n * Symbol for runtime identification of UntrackedValue instances.\n */\nexport declare const UNTRACKED_VALUE_SYMBOL: unique symbol;\n/**\n * Initialization options for {@link UntrackedValue}.\n */\nexport interface UntrackedValueInit {\n /**\n * If true (default), throws an error if multiple updates are made in a single step.\n * If false, only the last value is kept per step.\n */\n guard?: boolean;\n}\n/**\n * Represents a state field whose value is transient and never checkpointed.\n *\n * Use {@link UntrackedValue} for state fields that should be tracked for the lifetime\n * of the process, but should not participate in durable checkpoints or recovery.\n *\n * @typeParam Value - The type of value stored in this field.\n *\n * @example\n * // Create an untracked in-memory cache\n * const cache = new UntrackedValue<Record<string, number>>();\n *\n * // Use with a type schema for basic runtime validation\n * import { z } from \"zod\";\n * const tempSession = new UntrackedValue(z.object({ token: z.string() }), { guard: false });\n *\n * // You can customize whether to throw on multiple updates per step:\n * const session = new UntrackedValue(undefined, { guard: false });\n */\nexport declare class UntrackedValue<Value = unknown> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [UNTRACKED_VALUE_SYMBOL]: true;\n /**\n * Optional schema describing the type and shape of the value stored in this field.\n *\n * If provided, this can be used for runtime validation or code generation.\n */\n readonly schema?: SerializableSchema<Value>;\n /**\n * Whether to guard against multiple updates to this untracked value in a single step.\n *\n * - If `true` (default), throws an error if multiple updates are received in one step.\n * - If `false`, only the last value from that step is kept, others are ignored.\n *\n * This helps prevent accidental state replacement within a step.\n */\n readonly guard: boolean;\n /**\n * Represents the type of value stored in this untracked state field.\n */\n ValueType: Value;\n /**\n * Create a new untracked value state field.\n *\n * @param schema - Optional type schema describing the value (e.g. a Zod schema).\n * @param init - Optional options for tracking updates or enabling multiple-writes-per-step.\n */\n constructor(schema?: SerializableSchema<Value>, init?: UntrackedValueInit);\n /**\n * Type guard to check if a value is an UntrackedValue instance.\n */\n static isInstance<Value = unknown>(value: UntrackedValue<Value>): value is UntrackedValue<Value>;\n static isInstance(value: unknown): value is UntrackedValue;\n}\n"],"mappings":";;;;;;AAIA;AAIiBE,cAJID,sBAIc,EAAA,OAAA,MAAA;AA0BnC;;;AAWyCG,UArCxBF,kBAAAA,CAqCwBE;;;;;OAoBkBF,CAAAA,EAAAA,OAAAA;;;;;;;;;;;;;;;;;;;;;cA/BtCC;;;;;sBAKGF,sBAAAA;;;;;;oBAMFD,mBAAmBI;;;;;;;;;;;;;aAa1BA;;;;;;;uBAOUJ,mBAAmBI,eAAeF;;;;4CAIbC,eAAeC,kBAAkBD,eAAeC;8CAC9CD"}
@@ -1 +1 @@
1
- {"version":3,"file":"untracked.js","names":[],"sources":["../../../src/state/values/untracked.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n\n/**\n * Symbol for runtime identification of UntrackedValue instances.\n */\nexport const UNTRACKED_VALUE_SYMBOL = Symbol.for(\n \"langgraph.state.untracked_value\"\n);\n\n/**\n * Initialization options for {@link UntrackedValue}.\n */\nexport interface UntrackedValueInit {\n /**\n * If true (default), throws an error if multiple updates are made in a single step.\n * If false, only the last value is kept per step.\n */\n guard?: boolean;\n}\n\n/**\n * Represents a state field whose value is transient and never checkpointed.\n *\n * Use {@link UntrackedValue} for state fields that should be tracked for the lifetime\n * of the process, but should not participate in durable checkpoints or recovery.\n *\n * @typeParam Value - The type of value stored in this field.\n *\n * @example\n * // Create an untracked in-memory cache\n * const cache = new UntrackedValue<Record<string, number>>();\n *\n * // Use with a type schema for basic runtime validation\n * import { z } from \"zod\";\n * const tempSession = new UntrackedValue(z.object({ token: z.string() }), { guard: false });\n *\n * // You can customize whether to throw on multiple updates per step:\n * const session = new UntrackedValue(undefined, { guard: false });\n */\nexport class UntrackedValue<Value = unknown> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [UNTRACKED_VALUE_SYMBOL] = true as const;\n\n /**\n * Optional schema describing the type and shape of the value stored in this field.\n *\n * If provided, this can be used for runtime validation or code generation.\n */\n readonly schema?: SerializableSchema<Value>;\n\n /**\n * Whether to guard against multiple updates to this untracked value in a single step.\n *\n * - If `true` (default), throws an error if multiple updates are received in one step.\n * - If `false`, only the last value from that step is kept, others are ignored.\n *\n * This helps prevent accidental state replacement within a step.\n */\n readonly guard: boolean;\n\n /**\n * Create a new untracked value state field.\n *\n * @param schema - Optional type schema describing the value (e.g. a Zod schema).\n * @param init - Optional options for tracking updates or enabling multiple-writes-per-step.\n */\n constructor(schema?: SerializableSchema<Value>, init?: UntrackedValueInit) {\n this.schema = schema;\n this.guard = init?.guard ?? true;\n }\n\n /**\n * Type guard to check if a value is an UntrackedValue instance.\n */\n static isInstance<Value = unknown>(\n value: UntrackedValue<Value>\n ): value is UntrackedValue<Value>;\n\n static isInstance(value: unknown): value is UntrackedValue;\n\n static isInstance<Value = unknown>(\n value: UntrackedValue<Value> | unknown\n ): value is UntrackedValue<Value> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n UNTRACKED_VALUE_SYMBOL in value\n );\n }\n}\n"],"mappings":";;;;AAKA,MAAa,yBAAyB,OAAO,IAC3C,kCACD;;;;;;;;;;;;;;;;;;;;AAgCD,IAAa,iBAAb,MAA6C;;;;;CAK3C,CAAoB,0BAA0B;;;;;;CAO9C,AAAS;;;;;;;;;CAUT,AAAS;;;;;;;CAQT,YAAY,QAAoC,MAA2B;AACzE,OAAK,SAAS;AACd,OAAK,QAAQ,MAAM,SAAS;;CAY9B,OAAO,WACL,OACgC;AAChC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,0BAA0B"}
1
+ {"version":3,"file":"untracked.js","names":[],"sources":["../../../src/state/values/untracked.ts"],"sourcesContent":["import type { SerializableSchema } from \"../types.js\";\n\n/**\n * Symbol for runtime identification of UntrackedValue instances.\n */\nexport const UNTRACKED_VALUE_SYMBOL = Symbol.for(\n \"langgraph.state.untracked_value\"\n);\n\n/**\n * Initialization options for {@link UntrackedValue}.\n */\nexport interface UntrackedValueInit {\n /**\n * If true (default), throws an error if multiple updates are made in a single step.\n * If false, only the last value is kept per step.\n */\n guard?: boolean;\n}\n\n/**\n * Represents a state field whose value is transient and never checkpointed.\n *\n * Use {@link UntrackedValue} for state fields that should be tracked for the lifetime\n * of the process, but should not participate in durable checkpoints or recovery.\n *\n * @typeParam Value - The type of value stored in this field.\n *\n * @example\n * // Create an untracked in-memory cache\n * const cache = new UntrackedValue<Record<string, number>>();\n *\n * // Use with a type schema for basic runtime validation\n * import { z } from \"zod\";\n * const tempSession = new UntrackedValue(z.object({ token: z.string() }), { guard: false });\n *\n * // You can customize whether to throw on multiple updates per step:\n * const session = new UntrackedValue(undefined, { guard: false });\n */\nexport class UntrackedValue<Value = unknown> {\n /**\n * Instance marker for runtime identification.\n * @internal\n */\n protected readonly [UNTRACKED_VALUE_SYMBOL] = true as const;\n\n /**\n * Optional schema describing the type and shape of the value stored in this field.\n *\n * If provided, this can be used for runtime validation or code generation.\n */\n readonly schema?: SerializableSchema<Value>;\n\n /**\n * Whether to guard against multiple updates to this untracked value in a single step.\n *\n * - If `true` (default), throws an error if multiple updates are received in one step.\n * - If `false`, only the last value from that step is kept, others are ignored.\n *\n * This helps prevent accidental state replacement within a step.\n */\n readonly guard: boolean;\n\n /**\n * Represents the type of value stored in this untracked state field.\n */\n declare ValueType: Value;\n\n /**\n * Create a new untracked value state field.\n *\n * @param schema - Optional type schema describing the value (e.g. a Zod schema).\n * @param init - Optional options for tracking updates or enabling multiple-writes-per-step.\n */\n constructor(schema?: SerializableSchema<Value>, init?: UntrackedValueInit) {\n this.schema = schema;\n this.guard = init?.guard ?? true;\n }\n\n /**\n * Type guard to check if a value is an UntrackedValue instance.\n */\n static isInstance<Value = unknown>(\n value: UntrackedValue<Value>\n ): value is UntrackedValue<Value>;\n\n static isInstance(value: unknown): value is UntrackedValue;\n\n static isInstance<Value = unknown>(\n value: UntrackedValue<Value> | unknown\n ): value is UntrackedValue<Value> {\n return (\n typeof value === \"object\" &&\n value !== null &&\n UNTRACKED_VALUE_SYMBOL in value\n );\n }\n}\n"],"mappings":";;;;AAKA,MAAa,yBAAyB,OAAO,IAC3C,kCACD;;;;;;;;;;;;;;;;;;;;AAgCD,IAAa,iBAAb,MAA6C;;;;;CAK3C,CAAoB,0BAA0B;;;;;;CAO9C,AAAS;;;;;;;;;CAUT,AAAS;;;;;;;CAaT,YAAY,QAAoC,MAA2B;AACzE,OAAK,SAAS;AACd,OAAK,QAAQ,MAAM,SAAS;;CAY9B,OAAO,WACL,OACgC;AAChC,SACE,OAAO,UAAU,YACjB,UAAU,QACV,0BAA0B"}
package/dist/web.d.cts CHANGED
@@ -18,8 +18,8 @@ import { CompiledGraph, Graph } from "./graph/graph.cjs";
18
18
  import { isSerializableSchema, isStandardSchema } from "./state/types.cjs";
19
19
  import { ReducedValue, ReducedValueInit } from "./state/values/reduced.cjs";
20
20
  import { UntrackedValue, UntrackedValueInit } from "./state/values/untracked.cjs";
21
- import { InferStateSchemaUpdate, InferStateSchemaValue, StateSchema, StateSchemaField, StateSchemaInit } from "./state/schema.cjs";
22
- import { ConditionalEdgeRouter, ExtractStateType, ExtractUpdateType, GraphNode } from "./graph/types.cjs";
21
+ import { InferStateSchemaUpdate, InferStateSchemaValue, StateSchema, StateSchemaField, StateSchemaFields } from "./state/schema.cjs";
22
+ import { ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, ExtractStateType, ExtractUpdateType, GraphNode, GraphNodeReturnValue, GraphNodeTypes, StateDefinitionInit, StateGraphInit, StateGraphOptions } from "./graph/types.cjs";
23
23
  import { CompiledStateGraph, StateGraph, StateGraphArgs } from "./graph/state.cjs";
24
24
  import { Messages, REMOVE_ALL_MESSAGES, messagesStateReducer } from "./graph/messages_reducer.cjs";
25
25
  import { MessageGraph } from "./graph/message.cjs";
@@ -29,4 +29,4 @@ import { MessagesAnnotation, MessagesZodMeta, MessagesZodState } from "./graph/m
29
29
  import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter.cjs";
30
30
  import { MessagesValue } from "./state/prebuilt/messages.cjs";
31
31
  import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, Checkpoint, CheckpointMetadata, CheckpointTuple, GetOperation, InMemoryStore, Item, ListNamespacesOperation, MatchCondition, MemorySaver, NameSpacePath, NamespaceMatchType, Operation, OperationResults, PutOperation, SearchOperation, copyCheckpoint, emptyCheckpoint } from "@langchain/langgraph-checkpoint";
32
- export { Annotation, type AnnotationRoot, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, type CommandParams, type CompiledGraph, CompiledStateGraph, type ConditionalEdgeRouter, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, type GraphNode, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InferStateSchemaUpdate, InferStateSchemaValue, type Interrupt, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type NamespaceMatchType, NodeInterrupt, type NodeType, type Operation, type OperationResults, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, type Runtime, START, type SearchOperation, Send, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, StateGraph, type StateGraphArgs, StateGraphInputError, StateSchema, StateSchemaField, StateSchemaInit, type StateSnapshot, type StateType, type StreamMode, type StreamOutputMap, type TaskOptions, type Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type WaitForNames, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getJsonSchemaFromSchema, getSchemaDefaultGetter, getSubgraphsSeenSet, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, task };
32
+ export { Annotation, type AnnotationRoot, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, type CommandParams, type CompiledGraph, CompiledStateGraph, type ConditionalEdgeRouter, type ConditionalEdgeRouterTypes, type ContextSchemaInit, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, type GraphNode, type GraphNodeReturnValue, type GraphNodeTypes, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InferStateSchemaUpdate, InferStateSchemaValue, type Interrupt, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type NamespaceMatchType, NodeInterrupt, type NodeType, type Operation, type OperationResults, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, type Runtime, START, type SearchOperation, Send, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, type StateDefinitionInit, StateGraph, type StateGraphArgs, type StateGraphInit, StateGraphInputError, type StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFields, type StateSnapshot, type StateType, type StreamMode, type StreamOutputMap, type TaskOptions, type Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type WaitForNames, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getJsonSchemaFromSchema, getSchemaDefaultGetter, getSubgraphsSeenSet, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, task };
package/dist/web.d.ts CHANGED
@@ -18,8 +18,8 @@ import { CompiledGraph, Graph } from "./graph/graph.js";
18
18
  import { isSerializableSchema, isStandardSchema } from "./state/types.js";
19
19
  import { ReducedValue, ReducedValueInit } from "./state/values/reduced.js";
20
20
  import { UntrackedValue, UntrackedValueInit } from "./state/values/untracked.js";
21
- import { InferStateSchemaUpdate, InferStateSchemaValue, StateSchema, StateSchemaField, StateSchemaInit } from "./state/schema.js";
22
- import { ConditionalEdgeRouter, ExtractStateType, ExtractUpdateType, GraphNode } from "./graph/types.js";
21
+ import { InferStateSchemaUpdate, InferStateSchemaValue, StateSchema, StateSchemaField, StateSchemaFields } from "./state/schema.js";
22
+ import { ConditionalEdgeRouter, ConditionalEdgeRouterTypes, ContextSchemaInit, ExtractStateType, ExtractUpdateType, GraphNode, GraphNodeReturnValue, GraphNodeTypes, StateDefinitionInit, StateGraphInit, StateGraphOptions } from "./graph/types.js";
23
23
  import { CompiledStateGraph, StateGraph, StateGraphArgs } from "./graph/state.js";
24
24
  import { Messages, REMOVE_ALL_MESSAGES, messagesStateReducer } from "./graph/messages_reducer.js";
25
25
  import { MessageGraph } from "./graph/message.js";
@@ -29,4 +29,4 @@ import { MessagesAnnotation, MessagesZodMeta, MessagesZodState } from "./graph/m
29
29
  import { getJsonSchemaFromSchema, getSchemaDefaultGetter } from "./state/adapter.js";
30
30
  import { MessagesValue } from "./state/prebuilt/messages.js";
31
31
  import { AsyncBatchedStore, BaseCheckpointSaver, BaseStore, Checkpoint, CheckpointMetadata, CheckpointTuple, GetOperation, InMemoryStore, Item, ListNamespacesOperation, MatchCondition, MemorySaver, NameSpacePath, NamespaceMatchType, Operation, OperationResults, PutOperation, SearchOperation, copyCheckpoint, emptyCheckpoint } from "@langchain/langgraph-checkpoint";
32
- export { Annotation, type AnnotationRoot, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, type CommandParams, type CompiledGraph, CompiledStateGraph, type ConditionalEdgeRouter, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, type GraphNode, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InferStateSchemaUpdate, InferStateSchemaValue, type Interrupt, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type NamespaceMatchType, NodeInterrupt, type NodeType, type Operation, type OperationResults, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, type Runtime, START, type SearchOperation, Send, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, StateGraph, type StateGraphArgs, StateGraphInputError, StateSchema, StateSchemaField, StateSchemaInit, type StateSnapshot, type StateType, type StreamMode, type StreamOutputMap, type TaskOptions, type Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type WaitForNames, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getJsonSchemaFromSchema, getSchemaDefaultGetter, getSubgraphsSeenSet, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, task };
32
+ export { Annotation, type AnnotationRoot, type AnyValue, AsyncBatchedStore, BaseChannel, BaseCheckpointSaver, BaseLangGraphError, BaseLangGraphErrorFields, BaseStore, type BinaryOperator, BinaryOperatorAggregate, type Checkpoint, type CheckpointMetadata, type CheckpointTuple, Command, type CommandParams, type CompiledGraph, CompiledStateGraph, type ConditionalEdgeRouter, type ConditionalEdgeRouterTypes, type ContextSchemaInit, type DynamicBarrierValue, END, EmptyChannelError, EmptyInputError, type EntrypointOptions, type EphemeralValue, type ExtractStateType, type ExtractUpdateType, type GetOperation, type GetStateOptions, Graph, GraphBubbleUp, GraphInterrupt, type GraphNode, type GraphNodeReturnValue, type GraphNodeTypes, GraphRecursionError, GraphValueError, INTERRUPT, InMemoryStore, InferStateSchemaUpdate, InferStateSchemaValue, type Interrupt, InvalidUpdateError, type Item, type LangGraphRunnableConfig, type LastValue, type ListNamespacesOperation, type MatchCondition, MemorySaver, MessageGraph, type Messages, MessagesAnnotation, MessagesValue, MessagesZodMeta, MessagesZodState, type MultipleChannelSubscriptionOptions, MultipleSubgraphsError, type NameSpacePath, type NamedBarrierValue, type NamespaceMatchType, NodeInterrupt, type NodeType, type Operation, type OperationResults, ParentCommand, type Pregel, type PregelNode, type PregelOptions, type PregelParams, type PutOperation, REMOVE_ALL_MESSAGES, ReducedValue, ReducedValueInit, RemoteException, type RetryPolicy, type Runtime, START, type SearchOperation, Send, type SingleChannelSubscriptionOptions, type SingleReducer, type StateDefinition, type StateDefinitionInit, StateGraph, type StateGraphArgs, type StateGraphInit, StateGraphInputError, type StateGraphOptions, StateSchema, StateSchemaField, StateSchemaFields, type StateSnapshot, type StateType, type StreamMode, type StreamOutputMap, type TaskOptions, type Topic, UnreachableNodeError, UntrackedValue, UntrackedValueChannel, UntrackedValueInit, type UpdateType, type WaitForNames, messagesStateReducer as addMessages, copyCheckpoint, emptyCheckpoint, entrypoint, getJsonSchemaFromSchema, getSchemaDefaultGetter, getSubgraphsSeenSet, isCommand, isGraphBubbleUp, isGraphInterrupt, isInterrupted, isParentCommand, isSerializableSchema, isStandardSchema, messagesStateReducer, task };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@langchain/langgraph",
3
- "version": "1.1.0",
3
+ "version": "1.1.2",
4
4
  "description": "LangGraph",
5
5
  "type": "module",
6
6
  "engines": {
@@ -16,9 +16,10 @@
16
16
  "author": "LangChain",
17
17
  "license": "MIT",
18
18
  "dependencies": {
19
+ "@standard-schema/spec": "1.1.0",
19
20
  "uuid": "^10.0.0",
20
- "@langchain/langgraph-sdk": "~1.5.4",
21
- "@langchain/langgraph-checkpoint": "^1.0.0"
21
+ "@langchain/langgraph-checkpoint": "^1.0.0",
22
+ "@langchain/langgraph-sdk": "~1.5.5"
22
23
  },
23
24
  "peerDependencies": {
24
25
  "@langchain/core": "^1.0.1",
@@ -36,7 +37,6 @@
36
37
  "@langchain/openai": "^1.0.0",
37
38
  "@langchain/scripts": ">=0.1.3 <0.2.0",
38
39
  "@langchain/tavily": "^1.0.0",
39
- "@standard-schema/spec": "1.1.0",
40
40
  "@swc/core": "^1.3.90",
41
41
  "@testing-library/dom": "^10.4.0",
42
42
  "@tsconfig/recommended": "^1.0.3",
@@ -65,8 +65,8 @@
65
65
  "vite-plugin-node-polyfills": "^0.23.0",
66
66
  "vitest": "^3.2.4",
67
67
  "zod-to-json-schema": "^3.22.4",
68
- "@langchain/langgraph-checkpoint-postgres": "1.0.0",
69
- "@langchain/langgraph-checkpoint-sqlite": "1.0.0"
68
+ "@langchain/langgraph-checkpoint-sqlite": "1.0.0",
69
+ "@langchain/langgraph-checkpoint-postgres": "1.0.0"
70
70
  },
71
71
  "publishConfig": {
72
72
  "access": "public",